86 #define MCR_DBF ((uint32_t)0x00010000) 89 #define TMIDxR_TXRQ ((uint32_t)0x00000001) 92 #define FMR_FINIT ((uint32_t)0x00000001) 95 #define INAK_TIMEOUT ((uint32_t)0x00FFFFFF) 97 #define SLAK_TIMEOUT ((uint32_t)0x00FFFFFF) 100 #define CAN_FLAGS_TSR ((uint32_t)0x08000000) 102 #define CAN_FLAGS_RF1R ((uint32_t)0x04000000) 104 #define CAN_FLAGS_RF0R ((uint32_t)0x02000000) 106 #define CAN_FLAGS_MSR ((uint32_t)0x01000000) 108 #define CAN_FLAGS_ESR ((uint32_t)0x00F00000) 111 #define CAN_TXMAILBOX_0 ((uint8_t)0x00) 112 #define CAN_TXMAILBOX_1 ((uint8_t)0x01) 113 #define CAN_TXMAILBOX_2 ((uint8_t)0x02) 115 #define CAN_MODE_MASK ((uint32_t) 0x00000003) 175 __IO uint32_t wait_ack = 0x00000000;
270 CANx->
BTR = (uint32_t)((uint32_t)CAN_InitStruct->
CAN_Mode << 30) | \
271 ((uint32_t)CAN_InitStruct->
CAN_SJW << 24) | \
272 ((uint32_t)CAN_InitStruct->
CAN_BS1 << 16) | \
273 ((uint32_t)CAN_InitStruct->
CAN_BS2 << 20) | \
311 uint32_t filter_number_bit_pos = 0;
319 filter_number_bit_pos = ((uint32_t)1) << CAN_FilterInitStruct->
CAN_FilterNumber;
325 CAN1->FA1R &= ~(uint32_t)filter_number_bit_pos;
331 CAN1->FS1R &= ~(uint32_t)filter_number_bit_pos;
349 CAN1->FS1R |= filter_number_bit_pos;
364 CAN1->FM1R &= ~(uint32_t)filter_number_bit_pos;
369 CAN1->FM1R |= (uint32_t)filter_number_bit_pos;
376 CAN1->FFA1R &= ~(uint32_t)filter_number_bit_pos;
382 CAN1->FFA1R |= (uint32_t)filter_number_bit_pos;
388 CAN1->FA1R |= filter_number_bit_pos;
452 CAN1->FMR &= (uint32_t)0xFFFFC0F1 ;
453 CAN1->FMR |= (uint32_t)(CAN_BankNumber)<<8;
553 uint8_t transmit_mailbox = 0;
563 transmit_mailbox = 0;
567 transmit_mailbox = 1;
571 transmit_mailbox = 2;
597 TxMessage->
DLC &= (uint8_t)0x0000000F;
603 ((uint32_t)TxMessage->
Data[2] << 16) |
604 ((uint32_t)TxMessage->
Data[1] << 8) |
605 ((uint32_t)TxMessage->
Data[0]));
607 ((uint32_t)TxMessage->
Data[6] << 16) |
608 ((uint32_t)TxMessage->
Data[5] << 8) |
609 ((uint32_t)TxMessage->
Data[4]));
613 return transmit_mailbox;
631 switch (TransmitMailbox)
668 return (uint8_t) state;
798 uint8_t message_pending=0;
804 message_pending = (uint8_t)(CANx->
RF0R&(uint32_t)0x03);
808 message_pending = (uint8_t)(CANx->
RF1R&(uint32_t)0x03);
814 return message_pending;
944 return (uint8_t)sleepstatus;
974 return (uint8_t)wakeupstatus;
1016 uint8_t errorcode=0;
1228 CANx->
IER |= CAN_IT;
1233 CANx->
IER &= ~CAN_IT;
1270 if ((CANx->
ESR & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
1284 if ((CANx->
MSR & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
1298 if ((CANx->
TSR & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
1312 if ((CANx->
RF0R & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
1326 if ((uint32_t)(CANx->
RF1R & (CAN_FLAG & 0x000FFFFF)) != (uint32_t)RESET)
1372 flagtmp = CAN_FLAG & 0x000FFFFF;
1377 CANx->
RF0R = (uint32_t)(flagtmp);
1382 CANx->
RF1R = (uint32_t)(flagtmp);
1387 CANx->
TSR = (uint32_t)(flagtmp);
1392 CANx->
MSR = (uint32_t)(flagtmp);
1604 if ((CAN_Reg & It_Bit) != (uint32_t)
RESET)
1607 pendingbitstatus =
SET;
1612 pendingbitstatus =
RESET;
1614 return pendingbitstatus;
#define IS_CAN_BANKNUMBER(BANKNUMBER)
void CAN_ClearITPendingBit(CAN_TypeDef *CANx, uint32_t CAN_IT)
Clears the CANx's interrupt pending bits.
#define IS_CAN_FILTER_FIFO(FIFO)
#define CAN_InitStatus_Failed
CAN init structure definition.
uint8_t CAN_Init(CAN_TypeDef *CANx, CAN_InitTypeDef *CAN_InitStruct)
Initializes the CAN peripheral according to the specified parameters in the CAN_InitStruct.
#define IS_CAN_OPERATING_MODE(MODE)
ITStatus CAN_GetITStatus(CAN_TypeDef *CANx, uint32_t CAN_IT)
Checks whether the specified CANx interrupt has occurred or not.
FunctionalState CAN_FilterActivation
This file contains all the functions prototypes for the CAN firmware library.
void CAN_DeInit(CAN_TypeDef *CANx)
Deinitializes the CAN peripheral registers to their default reset values.
uint16_t CAN_FilterIdHigh
void assert_param(int val)
static ITStatus CheckITStatus(uint32_t CAN_Reg, uint32_t It_Bit)
Checks whether the CAN interrupt has occurred or not.
#define CAN_OperatingMode_Normal
#define IS_FUNCTIONAL_STATE(STATE)
static volatile uint8_t * status
uint8_t CAN_OperatingModeRequest(CAN_TypeDef *CANx, uint8_t CAN_OperatingMode)
Selects the CAN Operation mode.
#define IS_CAN_ALL_PERIPH(PERIPH)
#define IS_CAN_GET_FLAG(FLAG)
FlagStatus CAN_GetFlagStatus(CAN_TypeDef *CANx, uint32_t CAN_FLAG)
Checks whether the specified CAN flag is set or not.
uint8_t CAN_MessagePending(CAN_TypeDef *CANx, uint8_t FIFONumber)
Returns the number of pending received messages.
void CAN_DBGFreeze(CAN_TypeDef *CANx, FunctionalState NewState)
Enables or disables the DBG Freeze for CAN.
void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Forces or releases Low Speed APB (APB1) peripheral reset.
This file contains all the functions prototypes for the RCC firmware library.
uint8_t CAN_GetReceiveErrorCounter(CAN_TypeDef *CANx)
Returns the CANx Receive Error Counter (REC).
#define IS_CAN_MODE(MODE)
#define IS_CAN_CLEAR_FLAG(FLAG)
#define IS_CAN_IDTYPE(IDTYPE)
void CAN_FIFORelease(CAN_TypeDef *CANx, uint8_t FIFONumber)
Releases the specified receive FIFO.
uint8_t CAN_TransmitStatus(CAN_TypeDef *CANx, uint8_t TransmitMailbox)
Checks the transmission status of a CAN Frame.
#define CAN_OperatingMode_Sleep
void CAN_Receive(CAN_TypeDef *CANx, uint8_t FIFONumber, CanRxMsg *RxMessage)
Receives a correct CAN frame.
#define IS_CAN_STDID(STDID)
#define CAN_TxStatus_NoMailBox
#define IS_CAN_CLEAR_IT(IT)
uint8_t CAN_WakeUp(CAN_TypeDef *CANx)
Wakes up the CAN peripheral from sleep mode .
#define IS_CAN_FILTER_NUMBER(NUMBER)
#define IS_CAN_EXTID(EXTID)
#define CAN_TxStatus_Pending
#define IS_CAN_PRESCALER(PRESCALER)
void CAN_CancelTransmit(CAN_TypeDef *CANx, uint8_t Mailbox)
Cancels a transmit request.
void CAN_ClearFlag(CAN_TypeDef *CANx, uint32_t CAN_FLAG)
Clears the CAN's pending flags.
#define IS_CAN_FILTER_SCALE(SCALE)
uint8_t CAN_GetLSBTransmitErrorCounter(CAN_TypeDef *CANx)
Returns the LSB of the 9-bit CANx Transmit Error Counter(TEC).
void CAN_TTComModeCmd(CAN_TypeDef *CANx, FunctionalState NewState)
Enables or disables the CAN Time TriggerOperation communication mode.
#define CAN_TxStatus_Failed
uint16_t CAN_FilterFIFOAssignment
#define CAN_FilterScale_32bit
void CAN_ITConfig(CAN_TypeDef *CANx, uint32_t CAN_IT, FunctionalState NewState)
Enables or disables the specified CANx interrupts.
void CAN_SlaveStartBank(uint8_t CAN_BankNumber)
Select the start bank filter for slave CAN.
#define IS_CAN_FILTER_MODE(MODE)
uint8_t CAN_GetLastErrorCode(CAN_TypeDef *CANx)
Returns the CANx's last error code (LEC).
CAN filter init structure definition.
CAN Tx message structure definition.
uint16_t CAN_FilterMaskIdHigh
#define CAN_ModeStatus_Failed
uint8_t CAN_Sleep(CAN_TypeDef *CANx)
Enters the Sleep (low power) mode.
#define CAN_WakeUp_Failed
CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]
#define CAN_FilterMode_IdMask
#define IS_CAN_FIFO(FIFO)
void CAN_FilterInit(CAN_FilterInitTypeDef *CAN_FilterInitStruct)
Configures the CAN reception filter according to the specified parameters in the CAN_FilterInitStruct...
void CAN_StructInit(CAN_InitTypeDef *CAN_InitStruct)
Fills each CAN_InitStruct member with its default value.
#define CAN_OperatingMode_Initialization
#define CAN_ModeStatus_Success
uint16_t CAN_FilterMaskIdLow
#define CAN_InitStatus_Success
#define RCC_APB1Periph_CAN1
CAN_TxMailBox_TypeDef sTxMailBox[3]
uint8_t CAN_Transmit(CAN_TypeDef *CANx, CanTxMsg *TxMessage)
Initiates and transmits a CAN frame message.
#define IS_CAN_TRANSMITMAILBOX(TRANSMITMAILBOX)
CAN Rx message structure definition.
#define CAN_FilterScale_16bit