Rev 53 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 53 | Rev 56 | ||
|---|---|---|---|
| Line 17... | Line 17... | ||
| 17 | #ifdef USE_CAN |
17 | #ifdef USE_CAN |
| 18 | #include <CAN.h> |
18 | #include <CAN.h> |
| 19 | #endif |
19 | #endif |
| 20 | 20 | ||
| 21 | static void mainInit(void); |
21 | static void mainInit(void); |
| - | 22 | ||
| - | 23 | unsigned int heartcnt=0; |
|
| 22 | 24 | ||
| 23 | void main() |
25 | void main() |
| 24 | { |
26 | { |
| 25 | static TICK t = 0; |
27 | static TICK t = 0; |
| 26 | 28 | ||
| 27 | // Inits |
29 | // Inits |
| 28 | 30 | ||
| 29 | mainInit(); |
31 | mainInit(); |
| 30 | 32 | ||
| 31 | #ifdef USE_CAN |
33 | #ifdef USE_CAN |
| 32 | canInit(); |
34 | canInit(); |
| 33 | #endif |
35 | #endif |
| 34 | 36 | ||
| 35 | tickInit(); |
37 | tickInit(); |
| 36 | 38 | ||
| 37 | while(1) |
39 | while(1) |
| 38 | { |
40 | { |
| 39 | #ifdef USE_CAN |
41 | #ifdef USE_CAN |
| 40 | if ((tickGet()-t)>=5*TICK_SECOND) |
42 | if ((tickGet()-t)>=5*TICK_SECOND) |
| 41 | { |
43 | { |
| 42 | CAN_MESSAGE cm; |
44 | CAN_MESSAGE cm; |
| 43 | 45 | ||
| 44 | t = tickGet(); |
46 | t = tickGet(); |
| 45 | 47 | ||
| 46 | // Send heartbeat |
48 | // Send heartbeat |
| 47 | cm.ident=0x00000666; |
49 | cm.ident=0x00000666; |
| 48 | cm.extended=FALSE; |
50 | cm.extended=FALSE; |
| 49 | cm.data_length= |
51 | cm.data_length=5; |
| 50 | cm.data[0]='H'; |
52 | cm.data[0]='H'; |
| - | 53 | cm.data[1]=(BYTE)((heartcnt & 0x000000FF)); |
|
| - | 54 | cm.data[2]=(BYTE)((heartcnt & 0x0000FF00)>>1); |
|
| - | 55 | cm.data[3]=(BYTE)((heartcnt & 0x00FF0000)>>2); |
|
| - | 56 | cm.data[4]=(BYTE)((heartcnt & 0xFF000000)>>3); |
|
| - | 57 | ||
| - | 58 | heartcnt++; |
|
| 51 | 59 | ||
| 52 | while(!canSendMessage(cm)); |
60 | while(!canSendMessage(cm,PRIO_LOW)); |
| 53 | } |
61 | } |
| 54 | #endif |
62 | #endif |
| 55 | } |
63 | } |
| 56 | } |
64 | } |
| 57 | 65 | ||
| Line 77... | Line 85... | ||
| 77 | LED0_IO=~LED0_IO; |
85 | LED0_IO=~LED0_IO; |
| 78 | 86 | ||
| 79 | // Send heartbeat |
87 | // Send heartbeat |
| 80 | cm.ident=0x1F910091; |
88 | cm.ident=0x1F910091; |
| 81 | cm.extended=TRUE; |
89 | cm.extended=TRUE; |
| - | 90 | cm.remote_request=TRUE; |
|
| 82 | cm.data_length=1; |
91 | cm.data_length=1; |
| 83 | cm.data[0]=0x01; |
92 | cm.data[0]=0x01; |
| 84 | cm.data[1]=0x07; |
93 | cm.data[1]=0x07; |
| 85 | cm.data[2]=0x09; |
94 | cm.data[2]=0x09; |
| 86 | cm.data[3]=0x08; |
95 | cm.data[3]=0x08; |
| 87 | cm.data[4]=0x03; |
96 | cm.data[4]=0x03; |
| 88 | 97 | ||
| 89 | while(!canSendMessage(cm)); |
98 | while(!canSendMessage(cm,PRIO_LOW)); |
| 90 | 99 | ||
| 91 | t=tickGet(); |
100 | t=tickGet(); |
| 92 | } |
101 | } |
| 93 | 102 | ||
| 94 | INTCONbits.INT0IF=0; |
103 | INTCONbits.INT0IF=0; |
| Line 170... | Line 179... | ||
| 170 | { |
179 | { |
| 171 | cm.ident=0x00000303; |
180 | cm.ident=0x00000303; |
| 172 | cm.extended=FALSE; |
181 | cm.extended=FALSE; |
| 173 | cm.data_length=1; |
182 | cm.data_length=1; |
| 174 | cm.data[0]=LED0_IO; |
183 | cm.data[0]=LED0_IO; |
| 175 | while(!canSendMessage(cm)); |
184 | while(!canSendMessage(cm,PRIO_LOW)); |
| 176 | 185 | ||
| 177 | } |
186 | } |
| 178 | } |
187 | } |
| 179 | 188 | ||
| 180 | 189 | ||