Controller area network (bxCAN)
Field Documentation
ï‚· uint32_t CanTxMsg::StdId
ï€ Specifies the standard identifier. This parameter can be a value between 0 to
0x7FF.
ï‚· uint32_t CanTxMsg::ExtId
ï€ Specifies the extended identifier. This parameter can be a value between 0 to
0x1FFFFFFF.
ï‚· uint8_t CanTxMsg::IDE
ï€ Specifies the type of identifier for the message that will be transmitted. This
parameter can be a value of CAN_identifier_type
ï‚· uint8_t CanTxMsg::RTR
ï€ Specifies the type of frame for the message that will be transmitted. This
parameter can be a value of CAN_remote_transmission_request
ï‚· uint8_t CanTxMsg::DLC
ï€ Specifies the length of the frame that will be transmitted. This parameter can be
a value between 0 to 8
ï‚· uint8_t CanTxMsg::Data[8]
ï€ Contains the data to be transmitted. It ranges from 0 to 0xFF.
4.2 CAN Firmware driver API description
The following section lists the various functions of the CAN library.
4.2.1 How to use this driver
1. Enable the CAN controller interface clock using
RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);
2. CAN pins configuration:
ï€ Enable the clock for the CAN GPIOs using the following function:
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOx, ENABLE);
ï€ Connect the involved CAN pins to AF9 using the following function
GPIO_PinAFConfig(GPIOx, GPIO_PinSourcex, GPIO_AF_CANx);
ï€ Configure these CAN pins in alternate function mode by calling the function
GPIO_Init();
3. Initialise and configure the CAN using CAN_Init() and CAN_FilterInit() functions.
4. Transmit the desired CAN frame using CAN_Transmit() function.
5. Check the transmission of a CAN frame using CAN_TransmitStatus() function.
6. Cancel the transmission of a CAN frame using CAN_CancelTransmit() function.
7. Receive a CAN frame using CAN_Recieve() function.
8. Release the receive FIFOs using CAN_FIFORelease() function.
9. Return the number of pending received frames using CAN_MessagePending()
function.
10. To control CAN events you can use one of the following two methods:
ï€ Check on CAN flags using the CAN_GetFlagStatus() function.
ï€ Use CAN interrupts through the function CAN_ITConfig() at initialization phase
and CAN_GetITStatus() function into interrupt routines to check if the event has
occurred or not. After checking on a flag you should clear it using