Hallo, Ich habe an einem MSP 430 2272 4 Taster (an Port 2) und 8 Led´s (an Port 1) angeschlossen. Nun habe ich eine interrupt routine geschrieben, mit der ich bestimmte Led´s an und ausmachen kann. Ich weiß nun aber nicht, wie ich meine interrupt routine in eine h und c Datei auslagern kann. Wäre über eine Hilfestellung dankbar. Hier ist noch mein aktueller Code:
1 | #include "io430.h" |
2 | #include "LedLauflichter.h" |
3 | |
4 | #ifndef __IAR_SYSTEMS_ICC__
|
5 | #include <signal.h> |
6 | #endif
|
7 | |
8 | // Function prototypes
|
9 | void DebounceDelay(void); // Software delay |
10 | |
11 | |
12 | int main(void) |
13 | {
|
14 | WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer |
15 | |
16 | P1DIR = 0xFF; // P1.0-P1.7 as output |
17 | P2IES = 0x27; // interrupt edge select for P2 input pins hi/lo |
18 | P2IE = 0x27; // interrupt enable for P2 input pins |
19 | __enable_interrupt(); // enable general interrupt |
20 | |
21 | for(;;) { |
22 | |
23 | }
|
24 | |
25 | }
|
26 | |
27 | // interrupt service routine for Port2
|
28 | #ifdef __IAR_SYSTEMS_ICC__
|
29 | #pragma vector=PORT2_VECTOR
|
30 | __interrupt void P2_ISR(void) |
31 | #else
|
32 | interrupt (PORT2_VECTOR) P2_ISR(void) |
33 | #endif
|
34 | {
|
35 | DebounceDelay(); // call delay subroutine |
36 | if(P2IFG & 0x01) // P2.0 caused the interrupt? |
37 | {
|
38 | Lauflicht(); |
39 | P2IFG &= ~ 0x01; // yes, toggle P1.0 and reset P2.0 interrupt flag |
40 | }
|
41 | else if(P2IFG & 0x02) // or P2.1 caused the interrupt? |
42 | {
|
43 | P1OUT ^= 0x02; |
44 | P2IFG &= ~ 0x02; // yes, toggle P1.1 and reset P2.1 interrupt flag |
45 | }
|
46 | else if(P2IFG & 0x04) // or P2.2 caused the interrupt? |
47 | {
|
48 | P1OUT ^= 0x04; |
49 | P2IFG &= ~ 0x04; // yes, toggle P1.2 and reset P2.2 interrupt flag |
50 | }
|
51 | else if(P2IFG & 0x10) // or P2.5 caused the interrupt? |
52 | {
|
53 | P1OUT ^= 0x10; |
54 | P2IFG &= ~ 0x20; // yes, toggle P1.3 and reset P2.5 interrupt flag |
55 | }
|
56 | }
|
57 | |
58 | void DebounceDelay(void) |
59 | {
|
60 | volatile unsigned int i; |
61 | for (i = 50000; i > 0; i--); |
62 | }
|