RTEMS 6.1-rc2
Loading...
Searching...
No Matches
Macros | Functions | Variables
mcan.c File Reference
#include "board.h"
#include "chip.h"
#include "mcan_config.h"
#include <assert.h>

Macros

#define MAILBOX_ADDRESS(address)   (0xFFFC & (address))
 
#define CAN_CLK_FREQ_HZ   MCAN_PROG_CLK_FREQ_HZ
 
#define MCAN0_TSEG1   (MCAN0_PROP_SEG + MCAN0_PHASE_SEG1)
 
#define MCAN0_TSEG2   (MCAN0_PHASE_SEG2)
 
#define MCAN0_BRP
 
#define MCAN0_SJW   (MCAN0_SYNC_JUMP - 1)
 
#define MCAN0_FTSEG1   (MCAN0_FAST_PROP_SEG + MCAN0_FAST_PHASE_SEG1)
 
#define MCAN0_FTSEG2   (MCAN0_FAST_PHASE_SEG2)
 
#define MCAN0_FBRP
 
#define MCAN0_FSJW   (MCAN0_FAST_SYNC_JUMP - 1)
 
#define MCAN0_STD_FLTS_WRDS   (MCAN0_NMBR_STD_FLTS)
 
#define MCAN0_EXT_FLTS_WRDS   (MCAN0_NMBR_EXT_FLTS * 2)
 
#define MCAN0_RX_FIFO0_WRDS
 
#define MCAN0_RX_FIFO1_WRDS
 
#define MCAN0_RX_DED_BUFS_WRDS
 
#define MCAN0_TX_EVT_FIFO_WRDS   (MCAN0_NMBR_TX_EVT_FIFO_ELMTS * 2)
 
#define MCAN0_TX_DED_BUF_WRDS
 
#define MCAN0_TX_FIFO_Q_WRDS
 
#define MCAN1_TSEG1   (MCAN1_PROP_SEG + MCAN1_PHASE_SEG1)
 
#define MCAN1_TSEG2   (MCAN1_PHASE_SEG2)
 
#define MCAN1_BRP
 
#define MCAN1_SJW   (MCAN1_SYNC_JUMP - 1)
 
#define MCAN1_FTSEG1   (MCAN1_FAST_PROP_SEG + MCAN1_FAST_PHASE_SEG1)
 
#define MCAN1_FTSEG2   (MCAN1_FAST_PHASE_SEG2)
 
#define MCAN1_FBRP
 
#define MCAN1_FSJW   (MCAN1_FAST_SYNC_JUMP - 1)
 
#define MCAN1_STD_FLTS_WRDS   (MCAN1_NMBR_STD_FLTS)
 
#define MCAN1_EXT_FLTS_WRDS   (MCAN1_NMBR_EXT_FLTS * 2)
 
#define MCAN1_RX_FIFO0_WRDS
 
#define MCAN1_RX_FIFO1_WRDS
 
#define MCAN1_RX_DED_BUFS_WRDS
 
#define MCAN1_TX_EVT_FIFO_WRDS   (MCAN1_NMBR_TX_EVT_FIFO_ELMTS * 2)
 
#define MCAN1_TX_DED_BUF_WRDS
 
#define MCAN1_TX_FIFO_Q_WRDS
 
#define CAN_11_BIT_ID_MASK   (0x7FF)
 
#define CAN_29_BIT_ID_MASK   (0x1FFFFFFF)
 
#define ELMT_SIZE_MASK   (0x1F)
 
#define BUFFER_XTD_MASK   (0x40000000)
 
#define BUFFER_EXT_ID_MASK   (0x1FFFFFFF)
 
#define BUFFER_STD_ID_MASK   (0x1FFC0000)
 
#define BUFFER_DLC_MASK   (0x000F0000)
 
#define BUFFER_RXTS_MASK   (0x0000FFFF)
 
#define STD_FILT_SFT_MASK   (3U << 30)
 
#define STD_FILT_SFT_RANGE   (0U << 30)
 
#define STD_FILT_SFT_DUAL   (1U << 30)
 
#define STD_FILT_SFT_CLASSIC   (2U << 30)
 
#define STD_FILT_SFEC_MASK   (7U << 27)
 
#define STD_FILT_SFEC_DISABLE   (0U << 27)
 
#define STD_FILT_SFEC_FIFO0   (1U << 27)
 
#define STD_FILT_SFEC_FIFO1   (2U << 27)
 
#define STD_FILT_SFEC_REJECT   (3U << 27)
 
#define STD_FILT_SFEC_PRIORITY   (4U << 27)
 
#define STD_FILT_SFEC_PRIORITY_FIFO0   (5U << 27)
 
#define STD_FILT_SFEC_PRIORITY_FIFO1   (6U << 27)
 
#define STD_FILT_SFEC_BUFFER   (7U << 27)
 
#define STD_FILT_SFID1_MASK   (0x03FFU << 16)
 
#define STD_FILT_SFID2_MASK   (0x3FFU << 0)
 
#define STD_FILT_SFID2_RX_BUFFER   (0U << 9)
 
#define STD_FILT_SFID2_DEBUG_A   (1U << 9)
 
#define STD_FILT_SFID2_DEBUG_B   (2U << 9)
 
#define STD_FILT_SFID2_DEBUG_C   (3U << 9)
 
#define STD_FILT_SFID2_BUFFER(nmbr)   (nmbr & 0x3F)
 
#define EXT_FILT_EFEC_MASK   (7U << 29)
 
#define EXT_FILT_EFEC_DISABLE   (0U << 29)
 
#define EXT_FILT_EFEC_FIFO0   (1U << 29)
 
#define EXT_FILT_EFEC_FIFO1   (2U << 29)
 
#define EXT_FILT_EFEC_REJECT   (3U << 29)
 
#define EXT_FILT_EFEC_PRIORITY   (4U << 29)
 
#define EXT_FILT_EFEC_PRIORITY_FIFO0   (5U << 29)
 
#define EXT_FILT_EFEC_PRIORITY_FIFO1   (6U << 29)
 
#define EXT_FILT_EFEC_BUFFER   (7U << 29)
 
#define EXT_FILT_EFID1_MASK   (0x1FFFFFFF)
 
#define EXT_FILT_EFT_MASK   (3U << 30)
 
#define EXT_FILT_EFT_RANGE   (0U << 30)
 
#define EXT_FILT_EFT_DUAL   (1U << 30)
 
#define EXT_FILT_EFT_CLASSIC   (2U << 30)
 
#define EXT_FILT_EFT_RANGE_NO_XIDAM   (3U << 30)
 
#define EXT_FILT_EFID2_MASK   (0x1FFFFFFF)
 
#define EXT_FILT_EFID2_RX_BUFFER   (0U << 9)
 
#define EXT_FILT_EFID2_DEBUG_A   (1U << 9)
 
#define EXT_FILT_EFID2_DEBUG_B   (2U << 9)
 
#define EXT_FILT_EFID2_DEBUG_C   (3U << 9)
 
#define EXT_FILT_EFID2_BUFFER(nmbr)   (nmbr & 0x3F)
 

Functions

void MCAN_Init (const MCan_ConfigType *mcanConfig)
 Initializes the MCAN hardware for giving peripheral. Default: Mixed mode TX Buffer + FIFO.
 
void MCAN_InitFdEnable (const MCan_ConfigType *mcanConfig)
 Enables a FUTURE switch to FD mode (tx & rx payloads up to 64 bytes) but transmits WITHOUT bit rate switching INIT must be set - so this should be called between MCAN_Init() and MCAN_Enable()
 
void MCAN_InitFdBitRateSwitchEnable (const MCan_ConfigType *mcanConfig)
 Enables a FUTURE switch to FD mode (tx & rx payloads up to 64 bytes) and transmits WITH bit rate switching INIT must be set - so this should be called between MCAN_Init() and MCAN_Enable()
 
void MCAN_InitLoopback (const MCan_ConfigType *mcanConfig)
 Initializes the MCAN in loop back mode. INIT must be set - so this should be called between MCAN_Init() and MCAN_Enable()
 
void MCAN_InitTxQueue (const MCan_ConfigType *mcanConfig)
 Initializes MCAN queue for TX INIT must be set - so this should be called between MCAN_Init() and MCAN_Enable()
 
void MCAN_Enable (const MCan_ConfigType *mcanConfig)
 Enable MCAN peripheral. INIT must be set - so this should be called between MCAN_Init()
 
void MCAN_RequestIso11898_1 (const MCan_ConfigType *mcanConfig)
 Requests switch to Iso11898-1 (standard / classic) mode (tx & rx payloads up to 8 bytes).
 
void MCAN_RequestFd (const MCan_ConfigType *mcanConfig)
 Requests switch to FD mode (tx & rx payloads up to 64 bytes) but transmits WITHOUT bit rate switching. requested mode should have been enabled at initialization.
 
void MCAN_RequestFdBitRateSwitch (const MCan_ConfigType *mcanConfig)
 Request switch to FD mode (tx & rx payloads up to 64 bytes) and transmits WITH bit rate switching. requested mode should have been enabled at initialization.
 
void MCAN_LoopbackOn (const MCan_ConfigType *mcanConfig)
 Switch on loop back mode. TEST must be set in MCAN_CCCR - e.g. by a prior call to MCAN_InitLoopback()
 
void MCAN_LoopbackOff (const MCan_ConfigType *mcanConfig)
 Switch off loop back mode.
 
void MCAN_IEnableMessageStoredToRxDedBuffer (const MCan_ConfigType *mcanConfig, MCan_IntrLineType line)
 Enable message line and message stored to Dedicated Receive Buffer Interrupt Line.
 
uint8_t * MCAN_ConfigTxDedBuffer (const MCan_ConfigType *mcanConfig, uint8_t buffer, uint32_t id, MCan_IdType idType, MCan_DlcType dlc)
 Configures a Dedicated TX Buffer.
 
void MCAN_SendTxDedBuffer (const MCan_ConfigType *mcanConfig, uint8_t buffer)
 Send Tx buffer.
 
uint32_t MCAN_AddToTxFifoQ (const MCan_ConfigType *mcanConfig, uint32_t id, MCan_IdType idType, MCan_DlcType dlc, uint8_t *data)
 Adds Message to TX Fifo / Queue.
 
uint8_t MCAN_IsBufferTxd (const MCan_ConfigType *mcanConfig, uint8_t buffer)
 Check if data transmitted from buffer/fifo/queue.
 
void MCAN_ConfigRxBufferFilter (const MCan_ConfigType *mcanConfig, uint32_t buffer, uint32_t filter, uint32_t id, MCan_IdType idType)
 Configure RX Buffer Filter ID must match exactly for a RX Buffer Filter.
 
void MCAN_ConfigRxClassicFilter (const MCan_ConfigType *mcanConfig, MCan_FifoType fifo, uint8_t filter, uint32_t id, MCan_IdType idType, uint32_t mask)
 Configure Classic Filter Classic Filters direct accepted messages to a FIFO & include both a ID and a ID mask.
 
uint8_t MCAN_IsNewDataInRxDedBuffer (const MCan_ConfigType *mcanConfig, uint8_t buffer)
 check if data received into buffer
 
void MCAN_GetRxDedBuffer (const MCan_ConfigType *mcanConfig, uint8_t buffer, Mailbox64Type *pRxMailbox)
 Get Rx buffer.
 
uint32_t MCAN_GetRxFifoBuffer (const MCan_ConfigType *mcanConfig, MCan_FifoType fifo, Mailbox64Type *pRxMailbox)
 Get from the receive FIFO and place in a application mailbox.
 

Variables

const MCan_ConfigType mcan0Config
 
const MCan_ConfigType mcan1Config
 

Detailed Description

Implements functions for Controller Area Network (CAN) peripheral operations.