RTEMS: Can_module

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Macros | Functions | Variables
Can_module
Board Support Packages » ARM » Atmel/Microchip SAM E70, S70, V70 and V71 » Contributed Code

## 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

## Macro Definition Documentation

## ◆ MCAN0_BRP

#define MCAN0_BRP

Value:
((uint32_t) (((float) CAN_CLK_FREQ_HZ / \
((float)(MCAN0_TSEG1 + MCAN0_TSEG2 + 3) *\
(float) MCAN0_BIT_RATE_BPS)) - 1))

## ◆ MCAN0_FBRP

#define MCAN0_FBRP

Value:
((uint32_t) (((float) CAN_CLK_FREQ_HZ / \
((float)(MCAN0_FTSEG1 + MCAN0_FTSEG2 + 3) * \
(float) MCAN0_FAST_BIT_RATE_BPS)) - 1))

## ◆ MCAN0_RX_DED_BUFS_WRDS

#define MCAN0_RX_DED_BUFS_WRDS

Value:
(MCAN0_NMBR_RX_DED_BUF_ELMTS * \
((MCAN0_RX_BUF_ELMT_SZ/4) + 2))

## ◆ MCAN0_RX_FIFO0_WRDS

#define MCAN0_RX_FIFO0_WRDS

Value:
(MCAN0_NMBR_RX_FIFO0_ELMTS * \
((MCAN0_RX_FIFO0_ELMT_SZ/4) + 2))

## ◆ MCAN0_RX_FIFO1_WRDS

#define MCAN0_RX_FIFO1_WRDS

Value:
(MCAN0_NMBR_RX_FIFO1_ELMTS *\
((MCAN0_RX_FIFO1_ELMT_SZ/4) + 2))

## ◆ MCAN0_TX_DED_BUF_WRDS

#define MCAN0_TX_DED_BUF_WRDS

Value:
(MCAN0_NMBR_TX_DED_BUF_ELMTS * \
((MCAN0_TX_BUF_ELMT_SZ/4) + 2))

## ◆ MCAN0_TX_FIFO_Q_WRDS

#define MCAN0_TX_FIFO_Q_WRDS

Value:
(MCAN0_NMBR_TX_FIFO_Q_ELMTS *\
((MCAN0_TX_BUF_ELMT_SZ/4) + 2))

## ◆ MCAN1_BRP

#define MCAN1_BRP

Value:
((uint32_t) (((float) CAN_CLK_FREQ_HZ / \
((float)(MCAN1_TSEG1 + MCAN1_TSEG2 + 3) *\
(float) MCAN1_BIT_RATE_BPS)) - 1))

## ◆ MCAN1_FBRP

#define MCAN1_FBRP

Value:
((uint32_t) (((float) CAN_CLK_FREQ_HZ /\
((float)(MCAN1_FTSEG1 + MCAN1_FTSEG2 + 3) *\
(float) MCAN1_FAST_BIT_RATE_BPS)) - 1))

## ◆ MCAN1_RX_DED_BUFS_WRDS

#define MCAN1_RX_DED_BUFS_WRDS

Value:
(MCAN1_NMBR_RX_DED_BUF_ELMTS * \
((MCAN1_RX_BUF_ELMT_SZ/4) + 2))

## ◆ MCAN1_RX_FIFO0_WRDS

#define MCAN1_RX_FIFO0_WRDS

Value:
(MCAN1_NMBR_RX_FIFO0_ELMTS * \
((MCAN1_RX_FIFO0_ELMT_SZ/4) + 2))

## ◆ MCAN1_RX_FIFO1_WRDS

#define MCAN1_RX_FIFO1_WRDS

Value:
(MCAN1_NMBR_RX_FIFO1_ELMTS *\
((MCAN1_RX_FIFO1_ELMT_SZ/4) + 2))

## ◆ MCAN1_TX_DED_BUF_WRDS

#define MCAN1_TX_DED_BUF_WRDS

Value:
(MCAN1_NMBR_TX_DED_BUF_ELMTS * \
((MCAN1_TX_BUF_ELMT_SZ/4) + 2))

## ◆ MCAN1_TX_FIFO_Q_WRDS

#define MCAN1_TX_FIFO_Q_WRDS

Value:
(MCAN1_NMBR_TX_FIFO_Q_ELMTS * \
((MCAN1_TX_BUF_ELMT_SZ/4) + 2))

## Function Documentation

## ◆ MCAN_AddToTxFifoQ()

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.

Parameters

  mcanConfig | Pointer to a MCAN instance.
  id | Message ID.
  idType | Type of ID
  dlc | Type of dlc.
  data | Pointer to data.

## ◆ MCAN_ConfigRxBufferFilter()

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.

Parameters

  mcanConfig | Pointer to a MCAN instance.
  buffer | Pointer to data buffer.
  filter | data of filter.
  idType | Type of ID

## ◆ MCAN_ConfigRxClassicFilter()

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.

Parameters

  mcanConfig | Pointer to a MCAN instance.
  buffer | Pointer to data buffer.
  fifo | fifo Number.
  filter | data of filter.
  idType | Type of ID
  mask | Mask to be match

## ◆ MCAN_ConfigTxDedBuffer()

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.

Parameters

  mcanConfig | Pointer to a MCAN instance.
  buffer | Pointer to buffer.
  id | Message ID.
  idType | Type of ID
  dlc | Type of dlc.

## ◆ MCAN_Enable()

void MCAN_Enable | ( | const MCan_ConfigType * | mcanConfig | ) |

Enable MCAN peripheral. INIT must be set - so this should be called between MCAN_Init()

Parameters

  mcanConfig | Pointer to a MCAN instance.

## ◆ MCAN_GetRxDedBuffer()

void MCAN_GetRxDedBuffer | ( | const MCan_ConfigType * | mcanConfig,
|  | uint8_t | buffer,
|  | Mailbox64Type * | pRxMailbox
| ) |  |

Get Rx buffer.

Parameters

  mcanConfig | Pointer to a MCAN instance.
  buffer | Pointer to data buffer.
  pRxMailbox | Pointer to rx Mailbox.

## ◆ MCAN_GetRxFifoBuffer()

uint32_t MCAN_GetRxFifoBuffer | ( | const MCan_ConfigType * | mcanConfig,
|  | MCan_FifoType | fifo,
|  | Mailbox64Type * | pRxMailbox
| ) |  |

Get from the receive FIFO and place in a application mailbox.

Parameters

  mcanConfig | Pointer to a MCAN instance.
  fifo | Fifo Number
  pRxMailbox | Pointer to rx Mailbox.

Returns
  : # of fifo entries at the start of the function 0 -> FIFO was empty at start 1 -> FIFO had 1 entry at start, but is empty at finish 2 -> FIFO had 2 entries at start, has 1 entry at finish

## ◆ MCAN_IEnableMessageStoredToRxDedBuffer()

void MCAN_IEnableMessageStoredToRxDedBuffer | ( | const MCan_ConfigType * | mcanConfig,
|  | MCan_IntrLineType | line
| ) |  |

Enable message line and message stored to Dedicated Receive Buffer Interrupt Line.

Parameters

  mcanConfig | Pointer to a MCAN instance.
  line | Message line.

## ◆ MCAN_Init()

void MCAN_Init | ( | const MCan_ConfigType * | mcanConfig | ) |

Initializes the MCAN hardware for giving peripheral. Default: Mixed mode TX Buffer + FIFO.

Parameters

  mcanConfig | Pointer to a MCAN instance.

## ◆ MCAN_InitFdBitRateSwitchEnable()

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()

Parameters

  mcanConfig | Pointer to a MCAN instance.

## ◆ MCAN_InitFdEnable()

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()

Parameters

  mcanConfig | Pointer to a MCAN instance.

## ◆ MCAN_InitLoopback()

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()

Parameters

  mcanConfig | Pointer to a MCAN instance.

## ◆ MCAN_InitTxQueue()

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()

Parameters

  mcanConfig | Pointer to a MCAN instance.

## ◆ MCAN_IsBufferTxd()

uint8_t MCAN_IsBufferTxd | ( | const MCan_ConfigType * | mcanConfig,
|  | uint8_t | buffer
| ) |  |

Check if data transmitted from buffer/fifo/queue.

Parameters

  mcanConfig | Pointer to a MCAN instance.
  buffer | Pointer to data buffer.

## ◆ MCAN_IsNewDataInRxDedBuffer()

uint8_t MCAN_IsNewDataInRxDedBuffer | ( | const MCan_ConfigType * | mcanConfig,
|  | uint8_t | buffer
| ) |  |

check if data received into buffer

Parameters

  mcanConfig | Pointer to a MCAN instance.
  buffer | Pointer to data buffer.

## ◆ MCAN_LoopbackOff()

void MCAN_LoopbackOff | ( | const MCan_ConfigType * | mcanConfig | ) |

Switch off loop back mode.

Parameters

  mcanConfig | Pointer to a MCAN instance.

## ◆ MCAN_LoopbackOn()

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()

Parameters

  mcanConfig | Pointer to a MCAN instance.

## ◆ MCAN_RequestFd()

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.

Parameters

  mcanConfig | Pointer to a MCAN instance.

## ◆ MCAN_RequestFdBitRateSwitch()

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.

Parameters

  mcanConfig | Pointer to a MCAN instance.

## ◆ MCAN_RequestIso11898_1()

void MCAN_RequestIso11898_1 | ( | const MCan_ConfigType * | mcanConfig | ) |

Requests switch to Iso11898-1 (standard / classic) mode (tx & rx payloads up to 8 bytes).

Parameters

  mcanConfig | Pointer to a MCAN instance.

## ◆ MCAN_SendTxDedBuffer()

void MCAN_SendTxDedBuffer | ( | const MCan_ConfigType * | mcanConfig,
|  | uint8_t | buffer
| ) |  |

Send Tx buffer.

Parameters

  mcanConfig | Pointer to a MCAN instance.
  buffer | Pointer to buffer.