PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
can.c File Reference
#include "can.h"
Include dependency graph for can.c:

Go to the source code of this file.

Macros

#define CAN_INSTANCE_COUNT   (uint32_t)(sizeof(m_astcCanInstanceDataLut) / sizeof(m_astcCanInstanceDataLut[0]))
 Macro to return the number of enabled CAN instances. More...
 
#define CAN_STATUS_INTERRUPT   (1 << 15)
 Status interrupt detected. More...
 
#define CAN_NO_LEC_CHANGE   7
 
#define CAN_MSG_DIR_RX   0
 WRRD bit indicating read direction. More...
 
#define CAN_MSG_DIR_TX   1
 WRRD bit indicating write direction. More...
 
#define CAN_MSG_ID_EXTENDED   1
 Extended msg id is used. More...
 

Functions

static stc_can_intern_data_t * CanGetInternDataPtr (volatile stc_cann_t *pstcCan)
 Return the internal data for a certain CAN instance. More...
 
static void Can_InitInterrupt (volatile stc_cann_t *pstcCan)
 Set NVIC Interrupt depending on CAN instance. More...
 
static void Can_DeInitInterrupt (volatile stc_cann_t *pstcCan)
 Clear NVIC Interrupt depending on CAN instance. More...
 
void CanIrqHandler (volatile stc_cann_t *pstcCan, stc_can_intern_data_t *pstcCanInternData)
 CAN (Status/Error/Rx/Tx) interrupt ISR. More...
 
en_result_t Can_Init (volatile stc_cann_t *pstcCan, const stc_can_config_t *pstcConfig)
 Initializes the CAN module. More...
 
en_result_t Can_DeInit (volatile stc_cann_t *pstcCan)
 Deinitializes the CAN module. Any pending transmission or receiption will be aborted and all CAN related registers are reset to their default values. More...
 
static en_result_t CanIsMbUpdatePossible (volatile stc_cann_t *pstcCan, uint8_t u8MsgBuf)
 Check if the given Message Buffer can be updated. More...
 
en_result_t Can_SetTransmitMsgBuffer (volatile stc_cann_t *pstcCan, uint8_t u8MsgBuf, const stc_can_msg_id_t *pstcMsgId, can_tx_msg_func_ptr_t pfnCallback)
 Configures a message buffer for transmission. Setting of new values is not possible if a transmission is pending, except remote transmission mode. The callback function pfnCallback can be NULL, but there will be no notification of a successful transmission. This function has to be called at least once before function Can_UpdateAndTransmitMsgBuffer() can be used with the same message buffer index. More...
 
en_result_t Can_UpdateAndTransmitMsgBuffer (volatile stc_cann_t *pstcCan, uint8_t u8MsgBuf, const stc_can_msg_data_t *pstcMsgData, en_can_tx_mode_t enTxMode)
 Updates the message data of a message buffer and/or start transmission. Transmits the message immediately (immediate transmission mode) or on reception of a matching remote frame (remote transmission mode). Function Can_SetTransmitMsgBuffer() must be called before setup the identifier and enable this message buffer. More...
 
en_result_t Can_UpdateAndTransmitFifoMsgBuffer (volatile stc_cann_t *pstcCan, uint8_t u8MsgBuf, const stc_can_msg_data_t *pstcMsgData, en_can_tx_mode_t enTxMode)
 Updates the message data of a message buffer and/or start with EOB = 0 (Msg Buffer as FIFO) transmission. The function calls Can_UpdateAndTransmitMsgBuffer() More...
 
en_result_t Can_SetReceiveMsgBuffer (volatile stc_cann_t *pstcCan, uint8_t u8MsgBuf, stc_can_msg_t *pstcMsgBuffer, uint32_t u32MsgIdMask, can_rx_msg_func_ptr_t pfnCallback)
 Configure a message buffer for reception. Configure and enable a message buffer for reception. The acceptance filter is set by pstcMsgBuffer->stcIdentifier and u32MsgIdMask. Each '0' bit in u32MsgIdMask masks the corresponding bit of the received message ID before comparing it to the configured identifier (set by pstcMsgBuffer->stcIdentifier). This allows receiving messages with different identifier. Setting all bits of u32MsgIdMask to '1' will only accept messages that match the configured identifier. If extended identifier is used, the u32MsgIdMask will also be interpreted as extended mask identifier. If 11 bit identifier is used, than u32MsgIdMask will be used as 11 bit mask identifier. The application must provide a message buffer object (pstcMsgBuffer) to be filled with received data. After reception of a message that passed the acceptance filter, the message's identifier, data and data length is copied into the provided message buffer and its bNew flag is set to TRUE. The message buffer has to be kept valid until this message buffer is reset (Can_ResetMsgBuffer()). More...
 
en_result_t Can_SetReceiveFifoMsgBuffer (volatile stc_cann_t *pstcCan, uint8_t u8MsgBuf, stc_can_msg_t *pstcMsgBuffer, uint32_t u32MsgIdMask, can_rx_msg_func_ptr_t pfnCallback)
 Configure a message buffer for reception with EOB = 0 (FIFO mode). This function calls Can_SetReceiveMsgBuffer() More...
 
en_result_t Can_ResetMsgBuffer (volatile stc_cann_t *pstcCan, uint8_t u8MsgBuf)
 Stop any message buffer operation i.e. disable it. More...
 

Variables

stc_can_instance_data_t m_astcCanInstanceDataLut []
 Look-up table for all enabled CAN instances and their internal data. More...
 

Detailed Description

A detailed description is available at CAN Module description

History:

  • 2013-08-21 1.0 MWi First version.

Definition in file can.c.