Rev 85 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 85 | Rev 86 | ||
|---|---|---|---|
| 1 | /********************************************************************* |
1 | /********************************************************************* |
| 2 | * |
2 | * |
| 3 | * CAN |
3 | * CAN module |
| 4 | * |
4 | * |
| 5 | ********************************************************************* |
5 | ********************************************************************* |
| 6 | * FileName: CAN.c |
6 | * FileName: $HeadURL: https://svn.auml.se/svn/HomeAutomation/trunk/EmbeddedSoftware/PIC/canBase/Source/CAN.c $ |
| 7 | * |
- | |
| 8 | * |
7 | * Last changed: $LastChangedDate: 2006-11-14 10:55:38 +0100 (Tue, 14 Nov 2006) $ |
| 9 | * |
8 | * By: $LastChangedBy: johboh $ |
| 10 | * |
9 | * Revision: $Revision: 86 $ |
| 11 | ********************************************************************/ |
10 | ********************************************************************/ |
| 12 | 11 | ||
| 13 | #include <CANdefs.h> |
12 | #include <CANdefs.h> |
| 14 | #include <stackTasks.h> |
13 | #include <stackTasks.h> |
| 15 | #include <CAN.h> |
14 | #include <CAN.h> |
| 16 | 15 | ||
| 17 | static void canGetPacket(void); |
16 | static void canGetPacket(void); |
| 18 | 17 | ||
| 19 | #ifdef USE_CAN |
18 | #ifdef USE_CAN |
| 20 | 19 | ||
| 21 | 20 | ||
| 22 | /* |
21 | /* |
| 23 | * Function: canInit |
22 | * Function: canInit |
| 24 | * |
23 | * |
| 25 | * Input: none |
24 | * Input: none |
| 26 | * Output: none |
25 | * Output: none |
| 27 | * Pre-conditions: none |
26 | * Pre-conditions: none |
| 28 | * Affects: Changes can registers. |
27 | * Affects: Changes can registers. |
| 29 | * Depends: none. |
28 | * Depends: none. |
| 30 | */ |
29 | */ |
| 31 | void canInit() |
30 | void canInit() |
| 32 | { |
31 | { |
| 33 | CANCON = 0x80; //request config mode |
32 | CANCON = 0x80; //request config mode |
| 34 | while ((CANSTAT & 0xE0) != 0x80 ); //wait for config mode request |
33 | while ((CANSTAT & 0xE0) != 0x80 ); //wait for config mode request |
| 35 | 34 | ||
| 36 | // BAUD AND TQS |
35 | // BAUD AND TQS |
| 37 | 36 | ||
| 38 | BRGCON1=0; |
37 | BRGCON1=0; |
| 39 | 38 | ||
| 40 | // Sync_Seq = 2 x TQ = 1 |
39 | // Sync_Seq = 2 x TQ = 1 |
| 41 | BRGCON1bits.SJW1=0; |
40 | BRGCON1bits.SJW1=0; |
| 42 | BRGCON1bits.SJW0=1; |
41 | BRGCON1bits.SJW0=1; |
| 43 | 42 | ||
| 44 | // Setting BRP. |
43 | // Setting BRP. |
| 45 | BRGCON1=BRGCON1|CAN_BRP; |
44 | BRGCON1=BRGCON1|CAN_BRP; |
| 46 | 45 | ||
| 47 | // Maximum PHEG1 |
46 | // Maximum PHEG1 |
| 48 | BRGCON2bits.SEG2PHTS = 1; |
47 | BRGCON2bits.SEG2PHTS = 1; |
| 49 | 48 | ||
| 50 | // Phase_Seg1 = 2 x TQ = 1 |
49 | // Phase_Seg1 = 2 x TQ = 1 |
| 51 | BRGCON2bits.SEG1PH2 = 0; |
50 | BRGCON2bits.SEG1PH2 = 0; |
| 52 | BRGCON2bits.SEG1PH1 = 0; |
51 | BRGCON2bits.SEG1PH1 = 0; |
| 53 | BRGCON2bits.SEG1PH0 = 1; |
52 | BRGCON2bits.SEG1PH0 = 1; |
| 54 | 53 | ||
| 55 | // Prop_Seq = 2 x TQ = 1 |
54 | // Prop_Seq = 2 x TQ = 1 |
| 56 | BRGCON2bits.PRSEG2 = 0; |
55 | BRGCON2bits.PRSEG2 = 0; |
| 57 | BRGCON2bits.PRSEG1 = 0; |
56 | BRGCON2bits.PRSEG1 = 0; |
| 58 | BRGCON2bits.PRSEG0 = 1; |
57 | BRGCON2bits.PRSEG0 = 1; |
| 59 | 58 | ||
| 60 | // Enableing bus wake-up |
59 | // Enableing bus wake-up |
| 61 | BRGCON3bits.WAKDIS = 0; |
60 | BRGCON3bits.WAKDIS = 0; |
| 62 | 61 | ||
| 63 | // Dont use filter when wakeup |
62 | // Dont use filter when wakeup |
| 64 | BRGCON3bits.WAKFIL = 0; |
63 | BRGCON3bits.WAKFIL = 0; |
| 65 | 64 | ||
| 66 | // Phase_Seg2 = 2 x TQ = 1 |
65 | // Phase_Seg2 = 2 x TQ = 1 |
| 67 | BRGCON3bits.SEG2PH2 = 0; |
66 | BRGCON3bits.SEG2PH2 = 0; |
| 68 | BRGCON3bits.SEG2PH1 = 0; |
67 | BRGCON3bits.SEG2PH1 = 0; |
| 69 | BRGCON3bits.SEG2PH0 = 1; |
68 | BRGCON3bits.SEG2PH0 = 1; |
| 70 | 69 | ||
| 71 | ECANCON=0; |
70 | ECANCON=0; |
| 72 | ECANCONbits.MDSEL1 = 0; |
71 | ECANCONbits.MDSEL1 = 0; |
| 73 | ECANCONbits.MDSEL0 = 1; |
72 | ECANCONbits.MDSEL0 = 1; |
| 74 | 73 | ||
| 75 | 74 | ||
| 76 | // FILTERS AND MASKS |
75 | // FILTERS AND MASKS |
| 77 | RXB0CONbits.RXM1=1; |
76 | RXB0CONbits.RXM1=1; |
| 78 | RXB0CONbits.RXM0=0; |
77 | RXB0CONbits.RXM0=0; |
| 79 | 78 | ||
| 80 | 79 | ||
| 81 | // INTERRUPTS |
80 | // INTERRUPTS |
| 82 | 81 | ||
| 83 | // Diable transmit interrupt |
82 | // Diable transmit interrupt |
| 84 | TXBIE = 0; |
83 | TXBIE = 0; |
| 85 | 84 | ||
| 86 | //rx any interrupt |
85 | //rx any interrupt |
| 87 | PIR3 = 0; |
86 | PIR3 = 0; |
| 88 | PIE3 = 0b00000011; |
87 | PIE3 = 0b00000011; |
| 89 | 88 | ||
| 90 | // High interrupt |
89 | // High interrupt |
| 91 | IPR3 =0b00000011; |
90 | IPR3 =0b00000011; |
| 92 | 91 | ||
| 93 | // Programmable buffers interrupt |
92 | // Programmable buffers interrupt |
| 94 | BIE0 = 0xFF; |
93 | BIE0 = 0xFF; |
| 95 | 94 | ||
| 96 | 95 | ||
| 97 | //loopback mode or not |
96 | //loopback mode or not |
| 98 | #ifdef CAN_LOOPBACK_MODE |
97 | #ifdef CAN_LOOPBACK_MODE |
| 99 | CANCON = 0x40;//request loopback mode |
98 | CANCON = 0x40;//request loopback mode |
| 100 | while ((CANSTAT & 0xE0) != 0x40 );//wait for loopback mode |
99 | while ((CANSTAT & 0xE0) != 0x40 );//wait for loopback mode |
| 101 | #else |
100 | #else |
| 102 | CANCON = 0x00;//request normal mode |
101 | CANCON = 0x00;//request normal mode |
| 103 | while ((CANSTAT & 0xE0) != 0x00 );//wait for normal mode |
102 | while ((CANSTAT & 0xE0) != 0x00 );//wait for normal mode |
| 104 | #endif |
103 | #endif |
| 105 | 104 | ||
| 106 | } |
105 | } |
| 107 | 106 | ||
| 108 | 107 | ||
| 109 | /* |
108 | /* |
| 110 | * Function: canISR |
109 | * Function: canISR |
| 111 | * |
110 | * |
| 112 | * Input: none |
111 | * Input: none |
| 113 | * Output: none |
112 | * Output: none |
| 114 | * Pre-conditions: a call to canInit() |
113 | * Pre-conditions: a call to canInit() |
| 115 | * Affects: interrupt registers and receive data buffers |
114 | * Affects: interrupt registers and receive data buffers |
| 116 | * Depends: .. |
115 | * Depends: .. |
| 117 | */ |
116 | */ |
| 118 | void canISR() |
117 | void canISR() |
| 119 | { |
118 | { |
| 120 | 119 | ||
| 121 | 120 | ||
| 122 | if (PIR3bits.RXBnIF || PIR3bits.RXB1IF || PIR3bits.RXB0IF) |
121 | if (PIR3bits.RXBnIF || PIR3bits.RXB1IF || PIR3bits.RXB0IF) |
| 123 | { |
122 | { |
| 124 | // Get which buffer that is ful. |
123 | // Get which buffer that is ful. |
| 125 | if (RXB0CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10000; canGetPacket(); } |
124 | if (RXB0CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10000; canGetPacket(); } |
| 126 | else if (RXB1CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10001; canGetPacket(); } |
125 | else if (RXB1CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10001; canGetPacket(); } |
| 127 | else if (B0CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10010; canGetPacket(); } |
126 | else if (B0CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10010; canGetPacket(); } |
| 128 | else if (B1CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10011; canGetPacket(); } |
127 | else if (B1CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10011; canGetPacket(); } |
| 129 | else if (B2CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10100; canGetPacket(); } |
128 | else if (B2CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10100; canGetPacket(); } |
| 130 | else if (B3CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10101; canGetPacket(); } |
129 | else if (B3CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10101; canGetPacket(); } |
| 131 | else if (B4CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10110; canGetPacket(); } |
130 | else if (B4CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10110; canGetPacket(); } |
| 132 | else if (B5CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10111; canGetPacket(); } |
131 | else if (B5CONbits.RXFUL) { ECANCON=(ECANCON&0b00000)|0b10111; canGetPacket(); } |
| 133 | 132 | ||
| 134 | if (PIR3bits.RXBnIF) {PIR3bits.RXBnIF = 0;} |
133 | if (PIR3bits.RXBnIF) {PIR3bits.RXBnIF = 0;} |
| 135 | if (PIR3bits.RXB1IF) {PIR3bits.RXB1IF = 0;} |
134 | if (PIR3bits.RXB1IF) {PIR3bits.RXB1IF = 0;} |
| 136 | if (PIR3bits.RXB0IF) {PIR3bits.RXB0IF = 0;} |
135 | if (PIR3bits.RXB0IF) {PIR3bits.RXB0IF = 0;} |
| 137 | 136 | ||
| 138 | } |
137 | } |
| 139 | } |
138 | } |
| 140 | 139 | ||
| 141 | 140 | ||
| 142 | /* |
141 | /* |
| 143 | * Function: canGetPacket |
142 | * Function: canGetPacket |
| 144 | * |
143 | * |
| 145 | * Input: none |
144 | * Input: none |
| 146 | * Output: none |
145 | * Output: none |
| 147 | * Pre-conditions: a call to canISR and an packet is available and banked to RXB0 |
146 | * Pre-conditions: a call to canISR and an packet is available and banked to RXB0 |
| 148 | * Affects: Calls canParse() function in main for parsing received packet. |
147 | * Affects: Calls canParse() function in main for parsing received packet. |
| 149 | * Depends: none. |
148 | * Depends: none. |
| 150 | */ |
149 | */ |
| 151 | void canGetPacket() |
150 | void canGetPacket() |
| 152 | { |
151 | { |
| 153 | CAN_MESSAGE cm; |
152 | CAN_MESSAGE cm; |
| 154 | 153 | ||
| 155 | // Set extended mode or not. |
- | |
| 156 | cm.extended=(RXB0SIDLbits.EXID==0?FALSE:TRUE); |
- | |
| 157 | - | ||
| 158 | // Clear |
- | |
| 159 | cm.ident=0; |
- | |
| 160 | - | ||
| 161 | - | ||
| 162 | if (cm.extended==TRUE) |
- | |
| 163 | { |
- | |
| 164 | //Read extended ident. |
- | |
| 165 | - | ||
| 166 | //xx xx xx 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 |
- | |
| 167 | - | ||
| 168 | //RXB0SIDH 28 27 26 25 24 23 22 21 |
154 | //RXB0SIDH 28 27 26 25 24 23 22 21 |
| 169 | //RXB0SIDL 20 19 18 xx xx xx 17 16 |
155 | //RXB0SIDL 20 19 18 xx xx xx 17 16 |
| 170 | //RXB0EIDH 15 14 13 12 11 10 09 08 |
156 | //RXB0EIDH 15 14 13 12 11 10 09 08 |
| 171 | //RXB0EIDL 07 06 05 04 03 02 01 00 |
157 | //RXB0EIDL 07 06 05 04 03 02 01 00 |
| 172 | 158 | ||
| - | 159 | //funct xx xx xx xx 28 27 26 25 |
|
| - | 160 | //funcc xx xx xx xx xx xx 24 23 22 21 20 19 18 17 16 15 |
|
| - | 161 | //nid xx xx 14 13 12 11 10 09 |
|
| - | 162 | //sid xx xx xx xx xx xx xx 08 07 06 05 04 03 02 01 00 |
|
| - | 163 | ||
| - | 164 | ||
| - | 165 | cm.funct=((RXB0SIDH & 0xF0)>>4); |
|
| - | 166 | cm.funcc=(((WORD)(RXB0SIDH & 0x0F))<<6)+(((WORD)(RXB0SIDL & 0xE0))>>2)+(((WORD)(RXB0SIDL & 0x03))<<1)+(((WORD)(RXB0EIDH & 0x80))>>7); |
|
| - | 167 | cm.nid=((RXB0EIDH & 0x7E)>>1); |
|
| - | 168 | cm.sid=(((WORD)(RXB0EIDH & 0x01))<<8)+RXB0EIDL; |
|
| 173 | 169 | ||
| 174 | cm.ident = (((DWORD)RXB0SIDH)<<21) + (((DWORD)(RXB0SIDL & 0xE0))<<13) + (((DWORD)(RXB0SIDL & 0x03))<<16) + (((DWORD)RXB0EIDH)<<8) + (BYTE)RXB0EIDL; |
- | |
| 175 | - | ||
| 176 | } |
- | |
| 177 | else |
- | |
| 178 | { |
- | |
| 179 | //Read standard ident. |
- | |
| 180 | - | ||
| 181 | //xx xx xx xx xx 10 09 08 07 06 05 04 03 02 01 00 |
- | |
| 182 | - | ||
| 183 | //RXB0SIDH 10 09 08 07 06 05 04 03 |
- | |
| 184 | //RXB0SIDL 02 01 00 xx xx xx xx xx |
- | |
| 185 | - | ||
| 186 | cm.ident = (((DWORD)RXB0SIDH)<<3) + (((DWORD)RXB0SIDL)>>5); |
- | |
| 187 | } |
- | |
| 188 | 170 | ||
| 189 | // Data length |
171 | // Data length |
| 190 | cm.data_length=(RXB0DLCbits.DLC3<<3)+(RXB0DLCbits.DLC2<<2)+(RXB0DLCbits.DLC1<<1)+RXB0DLCbits.DLC0; |
172 | cm.data_length=(RXB0DLCbits.DLC3<<3)+(RXB0DLCbits.DLC2<<2)+(RXB0DLCbits.DLC1<<1)+RXB0DLCbits.DLC0; |
| 191 | 173 | ||
| 192 | // Remote request |
- | |
| 193 | cm.remote_request=(RXB0DLCbits.RXRTR==0?FALSE:TRUE); |
- | |
| 194 | - | ||
| 195 | // Data one bye one, for speed |
174 | // Data one bye one, for speed |
| 196 | cm.data[0]=RXB0D0; cm.data[1]=RXB0D1; |
175 | cm.data[0]=RXB0D0; cm.data[1]=RXB0D1; |
| 197 | cm.data[2]=RXB0D2; cm.data[3]=RXB0D3; |
176 | cm.data[2]=RXB0D2; cm.data[3]=RXB0D3; |
| 198 | cm.data[4]=RXB0D4; cm.data[5]=RXB0D5; |
177 | cm.data[4]=RXB0D4; cm.data[5]=RXB0D5; |
| 199 | cm.data[6]=RXB0D6; cm.data[7]=RXB0D7; |
178 | cm.data[6]=RXB0D6; cm.data[7]=RXB0D7; |
| 200 | 179 | ||
| 201 | // Clear ful status |
180 | // Clear ful status |
| 202 | RXB0CONbits.RXFUL=0; |
181 | RXB0CONbits.RXFUL=0; |
| 203 | 182 | ||
| 204 | //Call main parser |
183 | //Call main parser |
| 205 | canParse(cm); |
184 | canParse(cm); |
| 206 | } |
185 | } |
| 207 | 186 | ||
| 208 | 187 | ||
| 209 | /* |
188 | /* |
| 210 | * Function: canSendMessage |
189 | * Function: canSendMessage |
| 211 | * |
190 | * |
| 212 | * Input: CAN_MESSAGE to send |
191 | * Input: CAN_MESSAGE to send |
| 213 | * Output: True if packet scheduled sucess, false otherwise. |
192 | * Output: True if packet scheduled sucess, false otherwise. |
| 214 | * Pre-conditions: canInit |
193 | * Pre-conditions: canInit |
| 215 | * Affects: .. |
194 | * Affects: .. |
| 216 | * Depends: .. |
195 | * Depends: .. |
| 217 | */ |
196 | */ |
| 218 | BOOL canSendMessage(CAN_MESSAGE cm,CAN_PRIORITY prio) |
197 | BOOL canSendMessage(CAN_MESSAGE cm,CAN_PRIORITY prio) |
| 219 | { |
198 | { |
| 220 | 199 | ||
| 221 | if ( TXB0CONbits.TXREQ == 0 ) { ECANCON=(ECANCON&0b00000)|0b00011; } |
200 | if ( TXB0CONbits.TXREQ == 0 ) { ECANCON=(ECANCON&0b00000)|0b00011; } |
| 222 | if ( TXB1CONbits.TXREQ == 0 ) { ECANCON=(ECANCON&0b00000)|0b00100; } |
201 | if ( TXB1CONbits.TXREQ == 0 ) { ECANCON=(ECANCON&0b00000)|0b00100; } |
| 223 | if ( TXB2CONbits.TXREQ == 0 ) { ECANCON=(ECANCON&0b00000)|0b00101; } |
202 | if ( TXB2CONbits.TXREQ == 0 ) { ECANCON=(ECANCON&0b00000)|0b00101; } |
| 224 | // None of the transmit buffers were empty. |
203 | // None of the transmit buffers were empty. |
| 225 | else { return FALSE;} |
204 | else { return FALSE;} |
| 226 | 205 | ||
| 227 | if (prio<0 || prio>3) prio = 0; |
206 | if (prio<0 || prio>3) prio = 0; |
| 228 | 207 | ||
| 229 | - | ||
| 230 | if (cm.extended==TRUE) |
- | |
| 231 | { |
- | |
| 232 | //Write extended ident. |
- | |
| 233 | - | ||
| 234 | //xx xx xx 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 |
- | |
| 235 | 208 | ||
| 236 | //RXB0SIDH 28 27 26 25 24 23 22 21 |
209 | //RXB0SIDH 28 27 26 25 24 23 22 21 |
| 237 | //RXB0SIDL 20 19 18 xx xx xx 17 16 |
210 | //RXB0SIDL 20 19 18 xx xx xx 17 16 |
| 238 | //RXB0EIDH 15 14 13 12 11 10 09 08 |
211 | //RXB0EIDH 15 14 13 12 11 10 09 08 |
| 239 | //RXB0EIDL 07 06 05 04 03 02 01 00 |
212 | //RXB0EIDL 07 06 05 04 03 02 01 00 |
| 240 | 213 | ||
| - | 214 | //funct xx xx xx xx 28 27 26 25 |
|
| - | 215 | //funcc xx xx xx xx xx xx 24 23 22 21 20 19 18 17 16 15 |
|
| - | 216 | //nid xx xx 14 13 12 11 10 09 |
|
| - | 217 | //sid xx xx xx xx xx xx xx 08 07 06 05 04 03 02 01 00 |
|
| 241 | 218 | ||
| 242 |
|
219 | RXB0SIDH = (BYTE)((cm.funct & 0x0F)<<4)+(BYTE)((cm.funcc & 0x03C0)>>6); |
| 243 |
|
220 | RXB0SIDL = (BYTE)((cm.funcc & 0x003F)<<2)+(BYTE)((cm.funcc & 0x0006)>>1); |
| 244 |
|
221 | RXB0EIDH = (BYTE)((cm.funcc & 0x0001)<<7)+(BYTE)((cm.nid & 0x3F)<<1)+(BYTE)((cm.sid & 0x0100)>>8); |
| 245 | RXB0EIDL = (BYTE)cm.ident; |
- | |
| 246 | - | ||
| 247 | } |
- | |
| 248 | else |
- | |
| 249 | { |
- | |
| 250 | //Write standard ident. |
- | |
| 251 | - | ||
| 252 | //xx xx xx xx xx 10 09 08 07 06 05 04 03 02 01 00 |
- | |
| 253 | - | ||
| 254 | //RXB0SIDH 10 09 08 07 06 05 04 03 |
- | |
| 255 | //RXB0SIDL 02 01 00 xx xx xx xx xx |
- | |
| 256 | - | ||
| 257 | RXB0SIDH= (BYTE)(cm.ident>>3); |
- | |
| 258 |
|
222 | RXB0EIDL = (BYTE)((cm.sid & 0x00FF)); |
| 259 | - | ||
| 260 | } |
- | |
| 261 | 223 | ||
| 262 | // Data length |
224 | // Data length |
| 263 | RXB0DLC = 0; |
225 | RXB0DLC = 0; |
| 264 | if (cm.data_length>8) RXB0DLC=8; else RXB0DLC=cm.data_length; |
226 | if (cm.data_length>8) RXB0DLC=8; else RXB0DLC=cm.data_length; |
| 265 | 227 | ||
| 266 | // Remote request |
- | |
| 267 | if (cm.remote_request==TRUE) |
- | |
| 268 | { |
228 | |
| 269 | _asm |
- | |
| 270 |
|
229 | // NOT Remote request |
| 271 | _endasm |
- | |
| 272 | } |
- | |
| 273 | else |
- | |
| 274 | { |
- | |
| 275 | _asm |
230 | _asm |
| 276 | bcf RXB0DLC, 6, 0 |
231 | bcf RXB0DLC, 6, 0 |
| 277 | _endasm |
232 | _endasm |
| 278 |
|
233 | |
| 279 | 234 | ||
| 280 | // Data one bye one, for speed |
235 | // Data one bye one, for speed |
| 281 | RXB0D0=cm.data[0]; RXB0D1=cm.data[1]; |
236 | RXB0D0=cm.data[0]; RXB0D1=cm.data[1]; |
| 282 | RXB0D2=cm.data[2]; RXB0D3=cm.data[3]; |
237 | RXB0D2=cm.data[2]; RXB0D3=cm.data[3]; |
| 283 | RXB0D4=cm.data[4]; RXB0D5=cm.data[5]; |
238 | RXB0D4=cm.data[4]; RXB0D5=cm.data[5]; |
| 284 | RXB0D6=cm.data[6]; RXB0D7=cm.data[7]; |
239 | RXB0D6=cm.data[6]; RXB0D7=cm.data[7]; |
| 285 | 240 | ||
| 286 | // set extended |
241 | // set extended |
| 287 | RXB0SIDLbits.EXID= |
242 | RXB0SIDLbits.EXID=1; |
| 288 | 243 | ||
| 289 | // Priority |
244 | // Priority |
| 290 | RXB0CON = (RXB0CON & 0b11111100) | prio; |
245 | RXB0CON = (RXB0CON & 0b11111100) | prio; |
| 291 | 246 | ||
| 292 | // mark as redy to transmit |
247 | // mark as redy to transmit |
| 293 | _asm |
248 | _asm |
| 294 | bsf RXB0CON, 3, 0 |
249 | bsf RXB0CON, 3, 0 |
| 295 | _endasm |
250 | _endasm |
| 296 | 251 | ||
| 297 | return TRUE; |
252 | return TRUE; |
| 298 | 253 | ||
| 299 | } |
254 | } |
| 300 | 255 | ||
| 301 | 256 | ||
| 302 | 257 | ||
| 303 | #endif //USE_CAN |
258 | #endif //USE_CAN |
| 304 | 259 | ||