49 #define MCR_DBF ((uint32_t)0x00010000)
52 #define TMIDxR_TXRQ ((uint32_t)0x00000001)
55 #define FMR_FINIT ((uint32_t)0x00000001)
58 #define INAK_TIMEOUT ((uint32_t)0x0000FFFF)
60 #define SLAK_TIMEOUT ((uint32_t)0x0000FFFF)
65 #define CAN_FLAGS_TSR ((uint32_t)0x08000000)
67 #define CAN_FLAGS_RF1R ((uint32_t)0x04000000)
69 #define CAN_FLAGS_RF0R ((uint32_t)0x02000000)
71 #define CAN_FLAGS_MSR ((uint32_t)0x01000000)
73 #define CAN_FLAGS_ESR ((uint32_t)0x00F00000)
76 #define CAN_TXMAILBOX_0 ((uint8_t)0x00)
77 #define CAN_TXMAILBOX_1 ((uint8_t)0x01)
78 #define CAN_TXMAILBOX_2 ((uint8_t)0x02)
82 #define CAN_MODE_MASK ((uint32_t) 0x00000003)
107 static ITStatus CheckITStatus(uint32_t CAN_Reg, uint32_t It_Bit);
157 uint32_t wait_ack = 0x00000000;
252 CANx->
BTR = (uint32_t)((uint32_t)CAN_InitStruct->
CAN_Mode << 30) | \
253 ((uint32_t)CAN_InitStruct->
CAN_SJW << 24) | \
254 ((uint32_t)CAN_InitStruct->
CAN_BS1 << 16) | \
255 ((uint32_t)CAN_InitStruct->
CAN_BS2 << 20) | \
294 uint32_t filter_number_bit_pos = 0;
302 filter_number_bit_pos = ((uint32_t)1) << CAN_FilterInitStruct->
CAN_FilterNumber;
308 CAN1->FA1R &= ~(uint32_t)filter_number_bit_pos;
314 CAN1->FS1R &= ~(uint32_t)filter_number_bit_pos;
332 CAN1->FS1R |= filter_number_bit_pos;
347 CAN1->FM1R &= ~(uint32_t)filter_number_bit_pos;
352 CAN1->FM1R |= (uint32_t)filter_number_bit_pos;
359 CAN1->FFA1R &= ~(uint32_t)filter_number_bit_pos;
365 CAN1->FFA1R |= (uint32_t)filter_number_bit_pos;
371 CAN1->FA1R |= filter_number_bit_pos;
437 CAN1->FMR &= (uint32_t)0xFFFFC0F1 ;
438 CAN1->FMR |= (uint32_t)(CAN_BankNumber)<<8;
517 uint8_t transmit_mailbox = 0;
527 transmit_mailbox = 0;
531 transmit_mailbox = 1;
535 transmit_mailbox = 2;
561 TxMessage->
DLC &= (uint8_t)0x0000000F;
567 ((uint32_t)TxMessage->
Data[2] << 16) |
568 ((uint32_t)TxMessage->
Data[1] << 8) |
569 ((uint32_t)TxMessage->
Data[0]));
571 ((uint32_t)TxMessage->
Data[6] << 16) |
572 ((uint32_t)TxMessage->
Data[5] << 8) |
573 ((uint32_t)TxMessage->
Data[4]));
577 return transmit_mailbox;
597 switch (TransmitMailbox)
634 return (uint8_t) state;
745 uint8_t message_pending=0;
751 message_pending = (uint8_t)(CANx->
RF0R&(uint32_t)0x03);
755 message_pending = (uint8_t)(CANx->
RF1R&(uint32_t)0x03);
761 return message_pending;
847 return (uint8_t) status;
873 return (uint8_t)sleepstatus;
904 return (uint8_t)wakeupstatus;
1013 CANx->
IER |= CAN_IT;
1018 CANx->
IER &= ~CAN_IT;
1055 if ((CANx->
ESR & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
1069 if ((CANx->
MSR & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
1083 if ((CANx->
TSR & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
1097 if ((CANx->
RF0R & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
1111 if ((uint32_t)(CANx->
RF1R & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
1157 flagtmp = CAN_FLAG & 0x000FFFFF;
1162 CANx->
RF0R = (uint32_t)(flagtmp);
1167 CANx->
RF1R = (uint32_t)(flagtmp);
1172 CANx->
TSR = (uint32_t)(flagtmp);
1177 CANx->
MSR = (uint32_t)(flagtmp);
1385 static ITStatus CheckITStatus(uint32_t CAN_Reg, uint32_t It_Bit)
1389 if ((CAN_Reg & It_Bit) != (uint32_t)
RESET)
1392 pendingbitstatus =
SET;
1397 pendingbitstatus =
RESET;
1399 return pendingbitstatus;