Rev 56 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 56 | Rev 64 | ||
|---|---|---|---|
| Line 23... | Line 23... | ||
| 23 | #endif |
23 | #endif |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | static void mainInit(void); |
27 | static void mainInit(void); |
| 28 | - | ||
| 29 | 28 | ||
| 30 | void main() |
29 | void main() |
| 31 | { |
30 | { |
| 32 | static TICK t = 0; |
31 | static TICK t = 0; |
| 33 | 32 | ||
| 34 | // Inits |
33 | // Inits |
| 35 | 34 | ||
| 36 | mainInit(); |
35 | mainInit(); |
| 37 | 36 | ||
| 38 | #ifdef USE_CAN |
37 | #ifdef USE_CAN |
| 39 | canInit(); |
38 | canInit(); |
| 40 | #endif |
39 | #endif |
| 41 | 40 | ||
| 42 | #ifdef USE_UART |
41 | #ifdef USE_UART |
| 43 | uartInit(); |
42 | uartInit(); |
| 44 | #endif |
43 | #endif |
| 45 | 44 | ||
| 46 | tickInit(); |
45 | tickInit(); |
| - | 46 | ||
| - | 47 | ||
| 47 | 48 | ||
| 48 | while(1) |
49 | while(1) |
| 49 | { |
50 | { |
| 50 | } |
51 | } |
| 51 | 52 | ||
| 52 | } |
53 | } |
| 53 | 54 | ||
| 54 | 55 | ||
| 55 | #pragma interruptlow HighISR |
56 | #pragma interruptlow HighISR |
| 56 | void HighISR(void) |
57 | void HighISR(void) |
| 57 | { |
58 | { |
| 58 | 59 | ||
| 59 | 60 | ||
| 60 | #ifdef USE_UART |
61 | #ifdef USE_UART |
| 61 | uartISR(); |
62 | uartISR(); |
| 62 | #endif |
63 | #endif |
| 63 | 64 | ||
| 64 | #ifdef USE_CAN |
65 | #ifdef USE_CAN |
| 65 | canISR(); |
66 | canISR(); |
| 66 | #endif |
67 | #endif |
| 67 | 68 | ||
| 68 | 69 | ||
| Line 128... | Line 129... | ||
| 128 | */ |
129 | */ |
| 129 | #ifdef USE_CAN |
130 | #ifdef USE_CAN |
| 130 | void canParse(CAN_MESSAGE cm) |
131 | void canParse(CAN_MESSAGE cm) |
| 131 | { |
132 | { |
| 132 | int i=0; |
133 | int i=0; |
| 133 | 134 | ||
| 134 | uartPutc(UART_START_BYTE); |
135 | uartPutc(UART_START_BYTE); |
| 135 | uartPutc((BYTE)(cm.ident)); |
136 | uartPutc((BYTE)(cm.ident)); |
| 136 | uartPutc((BYTE)(cm.ident>>8)); |
137 | uartPutc((BYTE)(cm.ident>>8)); |
| 137 | uartPutc((BYTE)(cm.ident>>16)); |
138 | uartPutc((BYTE)(cm.ident>>16)); |
| 138 | uartPutc((BYTE)(cm.ident>>24)); |
139 | uartPutc((BYTE)(cm.ident>>24)); |
| Line 162... | Line 163... | ||
| 162 | unsigned int wait = 0; |
163 | unsigned int wait = 0; |
| 163 | CAN_MESSAGE cm; |
164 | CAN_MESSAGE cm; |
| 164 | static BOOL waitingMessage = FALSE; |
165 | static BOOL waitingMessage = FALSE; |
| 165 | static TICK timeout=0; |
166 | static TICK timeout=0; |
| 166 | static BYTE count=0; |
167 | static BYTE count=0; |
| 167 | - | ||
| 168 | 168 | ||
| 169 | if (waitingMessage==TRUE && (tickGet()-timeout)>TICK_SECOND/20) |
169 | if (waitingMessage==TRUE && (tickGet()-timeout)>TICK_SECOND/20) |
| 170 | { |
170 | { |
| 171 | waitingMessage=FALSE; |
171 | waitingMessage=FALSE; |
| 172 | } |
172 | } |
| Line 182... | Line 182... | ||
| 182 | if(count>=15) |
182 | if(count>=15) |
| 183 | { |
183 | { |
| 184 | if (c==UART_END_BYTE) |
184 | if (c==UART_END_BYTE) |
| 185 | { |
185 | { |
| 186 | LED0_IO=~LED0_IO; |
186 | LED0_IO=~LED0_IO; |
| - | 187 | //canParse(cm); |
|
| 187 | while(!canSendMessage(cm, |
188 | while(!canSendMessage(cm,PRIO_HIGEST)); |
| 188 | } |
189 | } |
| 189 | waitingMessage=FALSE; |
190 | waitingMessage=FALSE; |
| 190 | return; |
191 | return; |
| 191 | } |
192 | } |
| 192 | 193 | ||