TMS320F28335 Library  1.0
Documentation
can.c
Go to the documentation of this file.
1 
8 #include "can.h"
9 
10 static long CAN_setBittiming(TMPS_CAN, Uint16 tseg1, Uint16 tseg2, Uint32);
11 static long CAN_setBaudrate(TMPS_CAN, Uint32);
13 
31 int16 init_CAN(CanInterface CAN_Int, Uint32 baudrate){
32  TMPS_CAN CAN = CAN_getInterface(CAN_Int.cantx); // Call function to assign correct address-value to variable for register-access
33  static int CAN_A_in_use=0;
34  static int CAN_B_in_use=0;
35  int i=0;
36 
37  EALLOW;
38  switch(CAN_Int.canrx){
39  case 10: if(!CAN_B_in_use){
40  TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.canrx); // Enable pull-up for GPIO(CANRXB)
41  TMC_BASE_PIO->CTL[0].QSEL1 |= ((Uint32)0x3 << 20); // Asynch qual for GPIO10 (CANRXB)
42  TMC_BASE_PIO->CTL[0].MUX1 |= ((Uint32)0x2 << 20); // Configure GPIO10 for CANRXB
43  switch(CAN_Int.cantx){
44  case 8: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO8 (CANTXB)
45  TMC_BASE_PIO->CTL[0].MUX1 |= ((Uint32)0x2 << 16); // Configure GPIO8 for CANTXB
46  break;
47  case 12: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXB)
48  TMC_BASE_PIO->CTL[0].MUX1 |= ((Uint32)0x2 << 24); // Configure GPIO for CANTXB
49  break;
50  case 16: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXB)
51  TMC_BASE_PIO->CTL[0].MUX2 |= (0x2); // Configure GPIO for CANTXB
52  break;
53  case 20: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXB)
54  TMC_BASE_PIO->CTL[0].MUX2 |= (0x3 << 8); // Configure GPIO for CANTXB
55  break;
56  default: EDIS;
57  return -2;
58  }
59  CAN_B_in_use=1;
60  }
61  else{
62  return -10;
63  }
64  break;
65  case 13: if(!CAN_B_in_use){
66  TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.canrx); // Enable pull-up for GPIO(CANRXB)
67  TMC_BASE_PIO->CTL[0].QSEL1 |= (0x3 << (CAN_Int.canrx*2)); // Asynch qual for GPIO (CANRXB)
68  TMC_BASE_PIO->CTL[0].MUX1 |= ((Uint32)0x2 << 26); // Configure GPIO for CANRXB
69  switch(CAN_Int.cantx){
70  case 8: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO8 (CANTXB)
71  TMC_BASE_PIO->CTL[0].MUX1 |= ((Uint32)0x2 << 16); // Configure GPIO8 for CANTXB
72  break;
73  case 12: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXB)
74  TMC_BASE_PIO->CTL[0].MUX1 |= ((Uint32)0x2 << 24); // Configure GPIO for CANTXB
75  break;
76  case 16: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXB)
77  TMC_BASE_PIO->CTL[0].MUX2 |= (0x2); // Configure GPIO for CANTXB
78  break;
79  case 20: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXB)
80  TMC_BASE_PIO->CTL[0].MUX2 |= (0x3 << 8); // Configure GPIO for CANTXB
81  break;
82  default: EDIS;
83  return -2;
84  }
85  CAN_B_in_use=1;
86  }
87  else{
88  return -10;
89  }
90  break;
91  case 17: if(!CAN_B_in_use){
92  TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.canrx); // Enable pull-up for GPIO(CANRXB)
93  TMC_BASE_PIO->CTL[0].QSEL2 |= (0x3 << 2); // Asynch qual for GPIO (CANRXB)
94  TMC_BASE_PIO->CTL[0].MUX2 |= (0x2 << 2); // Configure GPIO for CANRXB
95  switch(CAN_Int.cantx){
96  case 8: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO8 (CANTXB)
97  TMC_BASE_PIO->CTL[0].MUX1 |= ((Uint32)0x2 << 16); // Configure GPIO8 for CANTXB
98  break;
99  case 12: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXB)
100  TMC_BASE_PIO->CTL[0].MUX1 |= ((Uint32)0x2 << 24); // Configure GPIO for CANTXB
101  break;
102  case 16: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXB)
103  TMC_BASE_PIO->CTL[0].MUX2 |= (0x2); // Configure GPIO for CANTXB
104  break;
105  case 20: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXB)
106  TMC_BASE_PIO->CTL[0].MUX2 |= (0x3 << 8); // Configure GPIO for CANTXB
107  break;
108  default: EDIS;
109  return -2;
110  }
111  CAN_B_in_use=1;
112  }
113  else{
114  return -10;
115  }
116  break;
117  case 18: if(!CAN_A_in_use){
118  TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.canrx); // Enable pull-up for GPIO(CANRXA)
119  TMC_BASE_PIO->CTL[0].QSEL2 |= (0x3 << 4); // Asynch qual for GPIO (CANRXA)
120  TMC_BASE_PIO->CTL[0].MUX2 |= (0x3 << 4); // Configure GPIO for CANRXA
121  switch(CAN_Int.cantx){
122  case 19: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXA)
123  TMC_BASE_PIO->CTL[0].MUX2 |= (0x3 << 6); // Configure GPIO for CANTXA
124  break;
125  case 31: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXA)
126  TMC_BASE_PIO->CTL[0].MUX2 |= ((Uint32)0x1 << 30); // Configure GPIO for CANTXA
127  break;
128  default: EDIS;
129  return -2;
130  }
131  CAN_A_in_use=1;
132  }
133  else{
134  return -10;
135  }
136  break;
137  case 21: if(!CAN_B_in_use){
138  TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.canrx); // Enable pull-up for GPIO(CANRXB)
139  TMC_BASE_PIO->CTL[0].QSEL2 |= (0x3 << 10); // Asynch qual for GPIO (CANRXB)
140  TMC_BASE_PIO->CTL[0].MUX2 |= (0x3 << 10); // Configure GPIO for CANRXB
141  switch(CAN_Int.cantx){
142  case 8: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO8 (CANTXB)
143  TMC_BASE_PIO->CTL[0].MUX1 |= ((Uint32)0x2 << 16); // Configure GPIO8 for CANTXB
144  break;
145  case 12: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXB)
146  TMC_BASE_PIO->CTL[0].MUX1 |= ((Uint32)0x2 << 24); // Configure GPIO for CANTXB
147  break;
148  case 16: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXB)
149  TMC_BASE_PIO->CTL[0].MUX2 |= (0x2); // Configure GPIO for CANTXB
150  break;
151  case 20: TMC_BASE_PIO->CTL[0].PUD &= ~(0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXB)
152  TMC_BASE_PIO->CTL[0].MUX2 |= (0x3 << 8); // Configure GPIO for CANTXB
153  break;
154  default: EDIS;
155  return -2;
156  }
157  CAN_B_in_use=1;
158  }
159  else{
160  return -10;
161  }
162  break;
163  case 30: if(!CAN_A_in_use){
164  TMC_BASE_PIO->CTL[0].PUD &= ~((Uint32)0x1 << CAN_Int.canrx); // Enable pull-up for GPIO(CANRXA)
165  TMC_BASE_PIO->CTL[0].QSEL2 |= ((Uint32)0x3 << 28); // Asynch qual for GPIO (CANRXA)
166  TMC_BASE_PIO->CTL[0].MUX2 |= ((Uint32)0x1 << 28); // Configure GPIO for CANRXA
167  switch(CAN_Int.cantx){
168  case 19: TMC_BASE_PIO->CTL[0].PUD &= ~((Uint32)0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXA)
169  TMC_BASE_PIO->CTL[0].MUX2 |= (0x3 << 6); // Configure GPIO for CANTXA
170  break;
171  case 31: TMC_BASE_PIO->CTL[0].PUD &= ~((Uint32)0x1 << CAN_Int.cantx); // Enable pull-up for GPIO (CANTXA)
172  TMC_BASE_PIO->CTL[0].MUX2 |= ((Uint32)0x1 << 30); // Configure GPIO for CANTXA
173  break;
174  default: EDIS;
175  return -2;
176  }
177  CAN_A_in_use=1;
178  }
179  else{
180  return -10;
181  }
182  break;
183  default: EDIS;
184  return -1;
185  }
186 
187  EALLOW;
188  CAN->RIOC = 0x08; // CANRX pin is used for the CAN receive functions.
189  CAN->TIOC = 0x08; // CANTX pin is used for the CAN transmit functions
190  CAN->MC |= (0x1 << 10); // The data is received or transmitted least significant byte first
191  CAN->MC |= (0x1 << 13); // Select eCAN mode: 32 Mailboxes
192  CAN->MC |= ((Uint32)0x1 << 16); // Free mode: The peripheral continues to run in SUSPEND
193  TMC_BASE_SCR->PCLKCR0 |= (0x1 << 14);
194  EDIS;
195 
196  for(i=0;i<32;i++) { // Clear all values of mailboxes
197  CAN->MO[i].CTRL = 0;
198  CAN->MO[i].ID = 0;
199  CAN->MO[i].MDH = 0;
200  CAN->MO[i].MDL = 0;
201  }
202 
203  return CAN_setBaudrate(CAN, baudrate);
204 }
205 
212 static long CAN_setBaudrate(TMPS_CAN CAN, Uint32 baudrate){
213  Uint16 ok=0;
214  int32 rate,rate2;
215  Uint16 brp;
216 
217  struct timing{
218  int32 rest;
219  Uint16 prop;
220  Uint16 phase1;
221  Uint16 phase2;
222  };
223 
224  struct timing act_setting = {0,1,2,2};
225  struct timing best_setting = {1000000,1,1,2};
226 
227  while(!ok){
228  // calc values for baudrate
229  brp = (F_CPU_HALF/(baudrate*(act_setting.phase1+act_setting.phase2+act_setting.prop+1)))-1;
230  rate = (F_CPU_HALF/((brp+1)*(act_setting.phase1+act_setting.phase2+act_setting.prop+1)));
231  if(rate!=baudrate) rate2 = (F_CPU_HALF/(((brp+1)+1)*(act_setting.phase1+act_setting.phase2+act_setting.prop+1)));
232  if((baudrate-rate2)<(rate-baudrate)) rate = rate2;
233 
234 
235  if(rate == baudrate){
236  best_setting.prop = act_setting.prop;
237  best_setting.phase1 = act_setting.phase1;
238  best_setting.phase2 = act_setting.phase2;
239  ok=1;
240  }
241 
242  else{
243  if(rate> baudrate) act_setting.rest = rate - baudrate;
244  else act_setting.rest = baudrate - rate;
245 
246  if(act_setting.rest<best_setting.rest){
247  best_setting.rest = act_setting.rest;
248  best_setting.phase1 = act_setting.phase1;
249  best_setting.phase2 = act_setting.phase2;
250  best_setting.prop = act_setting.prop;
251  }
252  act_setting.prop++;
253  if(act_setting.prop==9){
254  act_setting.prop=1;
255  act_setting.phase1++;
256  act_setting.phase2++;
257  if(act_setting.phase1==9) ok = 1; // return -2: not able to set baudrate
258  }
259  }
260  }
261  return CAN_setBittiming(CAN, best_setting.prop+best_setting.phase1,best_setting.phase2, baudrate);
262 }
263 
280 static long CAN_setBittiming(TMPS_CAN CAN, Uint16 tseg1, Uint16 tseg2, Uint32 baudrate){
281  Uint32 brp;
282  Uint32 rate1,rate2;
283  if(baudrate>1000000) return -9; // Return -9: Baudrate too high 1Mbit/s
284  if(tseg1<tseg2) return -11; // Return -11: Tseg1 < Tseg2; Tseg1 needs to be >= Tseg2
285  if(tseg1>16) return -12; // Return -12: Tseg1: maximal 16Tq
286  if(tseg2>8) return -13; // Return -13: Tseg2: maximal 8Tq
287  if(tseg1<2) return -14; // Return -14: Tseg1: minimal 2Tq
288  if(tseg2<1) return -15; // Return -15: Tseg2: minimal 1Tq
289 
290  brp = (F_CPU_HALF/(baudrate*(tseg1+tseg2+1)))-1; // Calculation of Baudrate-Prescaler for one Bit
291  rate1 = (F_CPU_HALF/((brp+1)*(tseg1+tseg2+1)));
292  if(rate1!=baudrate) rate2 = (F_CPU_HALF/(((brp+1)+1)*(tseg1+tseg2+1)));
293  if((baudrate-rate2)<(rate1-baudrate)){
294  brp +=1;
295  rate1 = rate2;
296  }
297 
298  if(brp>255) return -8; // Return -8: not able to set baudrate, baudrate too low
299 
300  EALLOW;
301  CAN->MC |= (1<<12); // Start Configuration Change
302  while(!(CAN->ES&(1<<4)));
303 
304  CAN->BTC = (brp<<16)|((tseg1-1)<<3)|(tseg2-1)|(1<<8); // Set Bit-Timing-Register
305  if(brp>=5) CAN->BTC |= (1<<7); // Triple Sample Mode only if Prescaler >= 5
306 
307  CAN->MC &= (~(1<<12)); // Finish Configuration Change
308  while(CAN->ES&(1<<4));
309  EDIS;
310 
311  return 0; // Return 0 when operation successful
312 }
313 
321 void CAN_setupMailbox(CanInterface CAN_Int, Uint16 mb_number, CanMailbox *mailbox){
322  TMPS_CAN CAN = CAN_getInterface(CAN_Int.canrx);
323 
324  Uint32 temp;
325  Uint32 temp1;
326  Uint32 temp2;
327  if(mailbox->extended) {
328  temp = ((Uint32)mailbox->Message_ID) | ((Uint32)0x1<<31);
329  } else {
330  temp = ((Uint32)mailbox->Message_ID<<18); //MSGID is stored in in bits 28:18.
331  }
332 
333  // Write Id-Register only when change is pending
334  if(CAN->MO[mb_number].ID != temp) {
335  temp1 = CAN->ME;
336  CAN->ME &= ~((Uint32)0x1<<mb_number); // Set off mailbox for Id change
337  CAN->MO[mb_number].ID = temp; // Write Id-register
338  }
339 
340  CAN->MO[mb_number].CTRL = (CAN->MO[mb_number].CTRL &= ~0x0F ) | mailbox->messageLength;
341 
342  if(mailbox->direction == CAN_Rx) {
343  temp2 = CAN->MD;
344  temp2 |= (1UL<<mb_number);
345  CAN->MD = temp2; // Mailbox Direction
346  } else if (mailbox->direction == CAN_Tx) {
347  CAN->MD &= ~((Uint32)0x1<<mb_number); // Mailbox Direction
348  }
349 
350  if(mailbox->active) {
351  temp1 |= (Uint32)(CAN->ME | (1<<mb_number));
352  CAN->ME = temp1; // Activate Mailbox
353  } else {
354  CAN->ME &= ~((Uint32)0x1<<mb_number); // Deactivate Mailbox
355  }
356 }
357 
358 
370 int16 CAN_sendDataOnMailbox(CanInterface CAN_Int, Uint16 mb_number, Uint64* data, Uint16 length) {
371  TMPS_CAN CAN = CAN_getInterface(CAN_Int.canrx);
372 
373  if(length>8){
374  return -21;
375  }
376  if(CAN->MD & ((Uint32)0x1<<mb_number)){
377  return -22;
378  }
379 
380  CAN->MO[mb_number].MDL = 0;
381  CAN->MO[mb_number].MDH = 0;
382 
383  if(length<4) {
384  CAN->MO[mb_number].MDL |= (*data&0xFFFFFFFF);
385  } else {
386  CAN->MO[mb_number].MDL |= (*data&0xFFFFFFFF);
387  CAN->MO[mb_number].MDH |= (*data>>32)&0xFFFFFFFF;
388  }
389 
390  if(CAN->TA & ((Uint32)0x1<<mb_number)){
391  CAN->TA |= ((Uint32)0x1<<mb_number);
392  }
393 
394  CAN->TRS = ((Uint32)0x1<<mb_number); // Send Mailbox
395  return 0;
396 }
397 
406  TMPS_CAN CAN = CAN_getInterface(CAN_Int.canrx);
407 
408  return CAN->RMP?1:0;
409 }
410 
420  TMPS_CAN CAN = CAN_getInterface(CAN_Int.canrx);
421 
422  return CAN->RMP&(1<<mb_number)?1:0;
423 }
424 
425 
426 
435 void CAN_getDataFromMailbox(CanInterface CAN_Int, Uint16 mb_number, Uint64 *data, Uint16 length) { //Funktion zum Auslesen von Mailbox DATEN
436  TMPS_CAN CAN = CAN_getInterface(CAN_Int.canrx);
437 
438  if(length<4){
439  *data |= CAN->MO[mb_number].MDL;
440  }
441  else{
442  *data |= CAN->MO[mb_number].MDL;
443  *data |= ((Uint64)CAN->MO[mb_number].MDH<<32);
444  }
445 
446  CAN->RMP |= (1<<mb_number);
447 }
448 
455 void CAN_resetMailbox(CanInterface CAN_Int, Uint16 mb_number) { //Funktion zum Löschen des "neue Nachricht" bit
456  TMPS_CAN CAN = CAN_getInterface(CAN_Int.canrx);
457 
458  CAN->RMP |= (1<<mb_number);
459 }
460 
469 int CAN_mailboxActive(CanInterface CAN_Int, Uint16 mb_number) {
470  TMPS_CAN CAN = CAN_getInterface(CAN_Int.canrx);
471  return (CAN->ME & (1UL<<mb_number))?1:0;
472 }
473 
482  TMPS_CAN CAN = CAN_getInterface(CAN_Int.canrx);
483 
484  int i;
485  for(i=0; i<32; i++) {
486  if(!(CAN->ME & (1UL<<i))) {
487  return i;
488  }
489  }
490  return -1;
491 
492 }
493 
501 void CAN_getMailboxInformation(CanInterface CAN_Int, Uint16 mb_number, CanMailbox *data) {
502  TMPS_CAN CAN = CAN_getInterface(CAN_Int.canrx);
503 
504  if(CAN->MO[mb_number].ID>>31 != 0) {
505  data->Message_ID = CAN->MO[mb_number].ID&0x1FFFFFFF;
506  data->extended = 1;
507  } else {
508  data->Message_ID = (CAN->MO[mb_number].ID>>18)&0x7FF;
509  data->extended = 0;
510  }
511  data->messageLength = CAN->MO[mb_number].CTRL&0x0F;
512  data->direction = (CAN_direction)(CAN->MD&(1UL<<mb_number));
513  data->active = CAN->ME&(1UL<<mb_number)?1:0;
514 }
515 
524  TMPS_CAN CAN;
525  switch(gpio){
526  case 8: CAN = TMC_BASE_CANB;
527  break;
528  case 10: CAN = TMC_BASE_CANB;
529  break;
530  case 12: CAN = TMC_BASE_CANB;
531  break;
532  case 13: CAN = TMC_BASE_CANB;
533  break;
534  case 16: CAN = TMC_BASE_CANB;
535  break;
536  case 17: CAN = TMC_BASE_CANB;
537  break;
538  case 18: CAN = TMC_BASE_CANA;
539  break;
540  case 19: CAN = TMC_BASE_CANA;
541  break;
542  case 20: CAN = TMC_BASE_CANB;
543  break;
544  case 21: CAN = TMC_BASE_CANB;
545  break;
546  case 30: CAN = TMC_BASE_CANA;
547  break;
548  case 31: CAN = TMC_BASE_CANA;
549  break;
550  default: break;
551  }
552  return CAN;
553 }
554 
_CanMailbox
CAN Mailbox Strucutre for instantiation of CAN-Mailboxes.
Definition: can.h:19
TMC_BASE_SCR.h
System-Control-Register header file.
int16
int int16
16 Bit Variable: - 32.768 .. 32.767
Definition: global_defines.h:17
_TMS_CAN::ES
TM_REG32 ES
Error and status.
Definition: TMC_BASE_CAN.h:37
_TMS_CAN_MO::CTRL
TM_REG32 CTRL
Message Control.
Definition: TMC_BASE_CAN.h:14
_TMS_CAN::TRS
TM_REG32 TRS
Transmit request set.
Definition: TMC_BASE_CAN.h:27
CAN_getMailboxInformation
void CAN_getMailboxInformation(CanInterface CAN_Int, Uint16 mb_number, CanMailbox *data)
Gets mailbox information.
Definition: can.c:501
Uint64
unsigned long long Uint64
64 Bit Variable: 0 .. 18.446.744.073.709.551.615
Definition: global_defines.h:23
_TMS_CAN_MO::MDL
TM_REG32 MDL
Message Data Low.
Definition: TMC_BASE_CAN.h:15
_TMS_CAN::MO
TMS_CAN_MO MO[32]
Mailboxes.
Definition: TMC_BASE_CAN.h:55
_CanMailbox::messageLength
Uint8 messageLength
Set amount of bytes to send or receive: (0-8)
Definition: can.h:22
_CanMailbox::Message_ID
Uint32 Message_ID
Message Identifier for CAN-Mailbox (standard: 11 Bit, extended: 29 Bit)
Definition: can.h:20
_CanMailbox::direction
CAN_direction direction
Set mailbox-direction: CAN_Tx / CAN_Rx.
Definition: can.h:23
CAN_getInterface
TMPS_CAN CAN_getInterface(Uint16)
get_can_interface for matching right CANInterfaces.
Definition: can.c:523
_TMS_CAN_MO::MDH
TM_REG32 MDH
Message Data High.
Definition: TMC_BASE_CAN.h:16
_TMS_CAN
CAN Register (TMC_BASE_CANA / TMC_BASE_CANB).
Definition: TMC_BASE_CAN.h:24
_TMS_CAN::MC
TM_REG32 MC
Master control.
Definition: TMC_BASE_CAN.h:35
CAN_Rx
@ CAN_Rx
Definition: can.h:15
_TMS_CAN::TIOC
TM_REG32 TIOC
TX I/O control.
Definition: TMC_BASE_CAN.h:46
CAN_dataAvailableAtMailbox
int16 CAN_dataAvailableAtMailbox(CanInterface CAN_Int, Uint16 mb_number)
Checks if a CAN message is available in the passed CAN mailbox.
Definition: can.c:419
_CanMailbox::extended
Uint8 extended
Set standard/extended Identifier-Mode: (standard = 0, extended = 1)
Definition: can.h:21
_TMS_CAN_MO::ID
TM_REG32 ID
Message Identifier.
Definition: TMC_BASE_CAN.h:13
_CanInterface
CAN Interface: Assign GPIOs to CAN_A or CAN_B.
Definition: can.h:29
CAN_resetMailbox
void CAN_resetMailbox(CanInterface CAN_Int, Uint16 mb_number)
Erases the "new message" bit for the passed mailbox.
Definition: can.c:455
CAN_dataAvailable
int16 CAN_dataAvailable(CanInterface CAN_Int)
Checks if a CAN message is available in the passed CAN interface.
Definition: can.c:405
CAN_direction
enum _CAN_direction CAN_direction
The enumeration for CAN directions.
Uint16
unsigned int Uint16
16 Bit Variable: 0 .. 65.535
Definition: global_defines.h:21
TMC_BASE_CAN.h
CAN-Register header file.
int32
long int32
32 Bit Variable: - 2.147.483.648 .. 2.147.483.647
Definition: global_defines.h:18
_TMS_CAN::TA
TM_REG32 TA
Transmission acknowledge.
Definition: TMC_BASE_CAN.h:29
CAN_setupMailbox
void CAN_setupMailbox(CanInterface CAN_Int, Uint16 mb_number, CanMailbox *mailbox)
CAN_setup_Mailbox - Configures Register for a CAN mailbox.
Definition: can.c:321
_CanInterface::canrx
Uint16 canrx
CAN Rx GPIO.
Definition: can.h:30
CAN_mailboxActive
int CAN_mailboxActive(CanInterface CAN_Int, Uint16 mb_number)
Checks if the passed mailbox is in use already (active).
Definition: can.c:469
_CanInterface::cantx
Uint16 cantx
CAN Tx GPIO.
Definition: can.h:31
CAN_getDataFromMailbox
void CAN_getDataFromMailbox(CanInterface CAN_Int, Uint16 mb_number, Uint64 *data, Uint16 length)
Gets the content of a received CAN message on specific mailbox and writes it to data-address.
Definition: can.c:435
CAN_sendDataOnMailbox
int16 CAN_sendDataOnMailbox(CanInterface CAN_Int, Uint16 mb_number, Uint64 *data, Uint16 length)
CAN_send - Sends a CAN message.
Definition: can.c:370
_TMS_CAN::ME
TM_REG32 ME
Mailbox enable.
Definition: TMC_BASE_CAN.h:25
can.h
Header file for ADC module.
TMC_BASE_PIO.h
GPIO-Register header file.
_TMS_CAN::MD
TM_REG32 MD
Mailbox direction.
Definition: TMC_BASE_CAN.h:26
init_CAN
int16 init_CAN(CanInterface CAN_Int, Uint32 baudrate)
Initializes a CAN interface with the passed baud rate.
Definition: can.c:31
_TMS_CAN::BTC
TM_REG32 BTC
Bit-timing configuration.
Definition: TMC_BASE_CAN.h:36
_TMS_CAN::RMP
TM_REG32 RMP
Receive message pending.
Definition: TMC_BASE_CAN.h:31
CAN_getNextInactiveMailbox
int CAN_getNextInactiveMailbox(CanInterface CAN_Int)
Get the lowest inactive mailbox from a CAN interface (0-31).
Definition: can.c:481
_TMS_CAN::RIOC
TM_REG32 RIOC
RX I/O control.
Definition: TMC_BASE_CAN.h:47
_CanMailbox::active
Uint8 active
Activate / Deactivate mailbox: 0 = inactive, 1= active.
Definition: can.h:24
CAN_Tx
@ CAN_Tx
Definition: can.h:15
Uint32
unsigned long Uint32
32 Bit Variable: 0 .. 4.294.967.295
Definition: global_defines.h:22