RA Flexible Software Package Documentation  Release v5.7.0

 
CAN (r_can)

Functions

fsp_err_t R_CAN_Open (can_ctrl_t *const p_api_ctrl, can_cfg_t const *const p_cfg)
 
fsp_err_t R_CAN_Close (can_ctrl_t *const p_api_ctrl)
 
fsp_err_t R_CAN_Write (can_ctrl_t *const p_api_ctrl, uint32_t mailbox, can_frame_t *const p_frame)
 
fsp_err_t R_CAN_Read (can_ctrl_t *const p_api_ctrl, uint32_t mailbox, can_frame_t *const p_frame)
 
fsp_err_t R_CAN_ModeTransition (can_ctrl_t *const p_api_ctrl, can_operation_mode_t operation_mode, can_test_mode_t test_mode)
 
fsp_err_t R_CAN_InfoGet (can_ctrl_t *const p_api_ctrl, can_info_t *const p_info)
 
fsp_err_t R_CAN_CallbackSet (can_ctrl_t *const p_api_ctrl, void(*p_callback)(can_callback_args_t *), void const *const p_context, can_callback_args_t *const p_callback_memory)
 

Detailed Description

Driver for the CAN peripheral on RA MCUs. This module implements the CAN Interface.

Overview

The Controller Area network (CAN) HAL module provides a high-level API for CAN applications and supports the CAN peripherals available on RA microcontroller hardware. A user-callback function must be defined that the driver will invoke when transmit, receive or error interrupts are received. The callback is passed a parameter which indicates the channel, mailbox and event as well as the received data (if available).

Features

Configuration

Build Time Configurations for r_can

The following build time configurations are defined in fsp_cfg/r_can_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.
FIFO Support
  • Disabled
  • Enabled
Disabled When FIFOs are enabled, a transmit FIFO replaces mailboxes 24-27 and a receive FIFO replaces mailboxes 28-31.

Configurations for Connectivity > CAN (r_can)

This module can be added to the Stacks tab via New Stack > Connectivity > CAN (r_can). Non-secure callable guard functions can be generated for this module by right clicking the module in the RA Configuration tool and checking the "Non-secure Callable" box.

ConfigurationOptionsDefaultDescription
General
NameName must be a valid C symbolg_can0 Module name.
ChannelChannel should be 0 or 10 Specify the CAN channel to use.
Clock SourceMCU Specific OptionsSelect the CAN clock source.
Overwrite/Overrrun Mode
  • Overwrite Mode
  • Overrrun Mode
Overwrite Mode Select whether receive mailbox will be overwritten or overrun if data is not read in time.
Global ID Mode
  • Standard ID Mode
  • Extended ID Mode
  • Mixed ID Mode
Standard ID Mode Select whether the driver will use CAN Standard IDs, Extended IDs or a mix of both.
Number of Mailboxes
  • 4 Mailboxes
  • 8 Mailboxes
  • 16 Mailboxes
  • 24 Mailboxes
  • 32 Mailboxes
32 Mailboxes Select 4, 8, 16, 24 or 32 mailboxes. In FIFO mailbox mode up to 24 mailboxes are available.
Baud Rate Settings
Baud Rate Settings > Auto-generated Settings
Sample-Point (%)Must be a valid integer between 0 and 100. Ignore when Override Baud Settings is Enabled.75 Sample-Point = (TSEG1 + 1) / (TSEG1 + TSEG2 + 1).
CAN Baud Rate (Hz)Must be a valid integer configurable upto maximum 1MHz. Ignore when Override Baud Settings is Enabled.500000 Specify baud rate in Hz.

If the requested baud rate cannot be achieved, the settings with the largest possible baud rate that is less than or equal to the requested baud rate is used. If multiple combinations would result in the best baud rate, the combination with the least absolute error for the ratio is chosen. The theoretical calculated baud rate and ratio are printed in a comment in the generated can_bit_timing_cfg_t structure.
Baud Rate Settings > Override Auto-generated Settings
Override Baud Settings
  • Enabled
  • Disabled
Disabled Override calculated baudrate parameters and instead use the ones specified below. This option ignores the parameters specified under Sample-Point (%) and CAN Baud Rate (Hz)
Baud Rate PrescalerValue must be a non-negative integer between 1 and 1024.1 Specify division value of baud rate prescaler (baud rate prescalar + 1).
Time Segment 1Refer to the RA Configuration tool for available options.4 Time Quanta Select the time segment 1 value. (4-16). Check module usage notes for how to calculate this value.
Time Segment 2
  • 2 Time Quanta
  • 3 Time Quanta
  • 4 Time Quanta
  • 5 Time Quanta
  • 6 Time Quanta
  • 7 Time Quanta
  • 8 Time Quanta
2 Time Quanta Select the time segment 2 value (2-8). Check module usage notes for how to calculate this value.
Synchronization Jump Width
  • 1 Time Quanta
  • 2 Time Quanta
  • 3 Time Quanta
  • 4 Time Quanta
1 Time Quanta Select the Synchronization Jump Width value (1-4). Check module usage notes for how to calculate this value.
Interrupts
CallbackName must be a valid C symbolcan_callback A user callback function. If this callback function is provided, it is called from the interrupt service routine (ISR) each time any interrupt occurs.
Interrupt Priority LevelMCU Specific OptionsTransmit/Receive/Error interrupt priority.
Transmit FIFO Interrupt Mode
  • Every Message
  • Empty
Every Message Select whether the receive FIFO should throw an interrupt on every received message or when it becomes empty.
Input
Input > Receive FIFO
Input > Receive FIFO > Receive ID 1
IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.0 Select the first ID for the receive FIFO, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs.
ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the receive FIFO is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Frame Type
  • Data Mailbox
  • Remote Mailbox
Remote Mailbox Select whether the receive FIFO is used to capture data frames or remote frames.
MaskValue must be decimal or HEX integer of 0x1FFFFFFF or less.0x1FFFFFFF Select the Mask for the receive FIFO. In Mixed ID Mode the Standard ID mask is the upper 11 bits of the full 29-bit mask value.
Input > Receive FIFO > Receive ID 2
IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.0 Select the second ID for the receive FIFO, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs.
ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the receive FIFO is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Frame Type
  • Data Mailbox
  • Remote Mailbox
Remote Mailbox Select whether the receive FIFO is used to capture data frames or remote frames.
MaskValue must be decimal or HEX integer of 0x1FFFFFFF or less.0x1FFFFFFF Select the Mask for the receive FIFO. In Mixed ID Mode the Standard ID mask is the upper 11 bits of the full 29-bit mask value.
Input > Mailbox 0-3 Group
Input > Mailbox 0-3 Group > Mailbox ID
Mailbox 0 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.0 Select the receive ID for mailbox 0, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 1 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.1 Select the receive ID for mailbox 1, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 2 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.2 Select the receive ID for mailbox 2, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 3 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.3 Select the receive ID for mailbox 3, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Input > Mailbox 0-3 Group > Mailbox ID Mode
Mailbox 0 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 1 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 2 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 3 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Input > Mailbox 0-3 Group > Mailbox Type
Mailbox 0 Type
  • Receive Mailbox
  • Transmit Mailbox
Transmit Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 1 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 2 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 3 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Input > Mailbox 0-3 Group > Mailbox Frame Type
Mailbox 0 Frame Type
  • Data Mailbox
  • Remote Mailbox
Remote Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 1 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 2 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 3 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 0-3 Group MaskValue must be decimal or HEX integer of 0x1FFFFFFF or less.0x1FFFFFFF Select the Mask for mailboxes 0-3. In Mixed ID Mode the Standard ID mask is the upper 11 bits of the full 29-bit mask value.
Input > Mailbox 4-7 Group
Input > Mailbox 4-7 Group > Mailbox ID
Mailbox 4 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.4 Select the receive ID for mailbox 4, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 5 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.5 Select the receive ID for mailbox 5, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 6 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.6 Select the receive ID for mailbox 6, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 7 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.7 Select the receive ID for mailbox 7, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Input > Mailbox 4-7 Group > Mailbox ID Mode
Mailbox 4 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 5 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 6 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 7 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Input > Mailbox 4-7 Group > Mailbox Type
Mailbox 4 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 5 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 6 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 7 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Input > Mailbox 4-7 Group > Mailbox Frame Type
Mailbox 4 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 5 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 6 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 7 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 4-7 Group MaskValue must be decimal or HEX integer of 0x1FFFFFFF or less.0x1FFFFFFF >Select the Mask for mailboxes 4-7. In Mixed ID Mode the Standard ID mask is the upper 11 bits of the full 29-bit mask value.
Input > Mailbox 8-11 Group
Input > Mailbox 8-11 Group > Mailbox ID
Mailbox 8 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.8 Select the receive ID for mailbox 8, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 9 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.9 Select the receive ID for mailbox 9, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 10 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.10 Select the receive ID for mailbox 10, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 11 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.11 Select the receive ID for mailbox 11, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Input > Mailbox 8-11 Group > Mailbox ID Mode
Mailbox 8 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 9 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 10 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 11 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Input > Mailbox 8-11 Group > Mailbox Type
Mailbox 8 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 9 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 10 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 11 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Input > Mailbox 8-11 Group > Mailbox Frame Type
Mailbox 8 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 9 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 10 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 11 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 8-11 Group MaskValue must be decimal or HEX integer of 0x1FFFFFFF or less.0x1FFFFFFF Select the Mask for mailboxes 8-11. In Mixed ID Mode the Standard ID mask is the upper 11 bits of the full 29-bit mask value.
Input > Mailbox 12-15 Group
Input > Mailbox 12-15 Group > Mailbox ID
Mailbox 12 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.12 Select the receive ID for mailbox 12, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 13 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.13 Select the receive ID for mailbox 13, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 14 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.14 Select the receive ID for mailbox 14, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 15 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.15 Select the receive ID for mailbox 15, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Input > Mailbox 12-15 Group > Mailbox ID Mode
Mailbox 12 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 13 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 14 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 15 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Input > Mailbox 12-15 Group > Mailbox Type
Mailbox 12 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 13 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 14 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 15 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Input > Mailbox 12-15 Group > Mailbox Frame Type
Mailbox 12 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 13 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 14 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 15 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 12-15 Group MaskValue must be decimal or HEX integer of 0x1FFFFFFF or less.0x1FFFFFFF Select the Mask for mailboxes 12-15. In Mixed ID Mode the Standard ID mask is the upper 11 bits of the full 29-bit mask value.
Input > Mailbox 16-19 Group
Input > Mailbox 16-19 Group > Mailbox ID
Mailbox 16 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.16 Select the receive ID for mailbox 16, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 17 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.17 Select the receive ID for mailbox 17, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 18 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.18 Select the receive ID for mailbox 18, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 19 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.19 Select the receive ID for mailbox 19, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Input > Mailbox 16-19 Group > Mailbox ID Mode
Mailbox 16 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 17 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 18 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 19 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Input > Mailbox 16-19 Group > Mailbox Type
Mailbox 16 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 17 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 18 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 19 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Input > Mailbox 16-19 Group > Mailbox Frame Type
Mailbox 16 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 17 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 18 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 19 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 16-19 Group MaskValue must be decimal or HEX integer of 0x1FFFFFFF or less.0x1FFFFFFF Select the Mask for mailboxes 16-19. In Mixed ID Mode the Standard ID mask is the upper 11 bits of the full 29-bit mask value.
Input > Mailbox 20-23 Group
Input > Mailbox 20-23 Group > Mailbox ID
Mailbox 20 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.20 Select the receive ID for mailbox 20, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 21 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.21 Select the receive ID for mailbox 21, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 22 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.22 Select the receive ID for mailbox 22, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 23 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.23 Select the receive ID for mailbox 23, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Input > Mailbox 20-23 Group > Mailbox ID Mode
Mailbox 20 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 21 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 22 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 23 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Input > Mailbox 20-23 Group > Mailbox Type
Mailbox 20 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 21 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 22 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 23 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Input > Mailbox 20-23 Group > Mailbox Frame Type
Mailbox 20 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 21 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 22 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 23 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 20-23 Group MaskValue must be decimal or HEX integer of 0x1FFFFFFF or less.0x1FFFFFFF Select the Mask for mailboxes 20-23. In Mixed ID Mode the Standard ID mask is the upper 11 bits of the full 29-bit mask value.
Input > Mailbox 24-27 Group
Input > Mailbox 24-27 Group > Mailbox ID
Mailbox 24 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.24 Select the receive ID for mailbox 24, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 25 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.25 Select the receive ID for mailbox 25, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 26 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.26 Select the receive ID for mailbox 26, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 27 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.27 Select the receive ID for mailbox 27, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Input > Mailbox 24-27 Group > Mailbox ID Mode
Mailbox 24 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 25 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 26 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 27 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Input > Mailbox 24-27 Group > Mailbox Type
Mailbox 24 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 25 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 26 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 27 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Input > Mailbox 24-27 Group > Mailbox Frame Type
Mailbox 24 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 25 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 26 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 27 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 24-27 Group MaskValue must be decimal or HEX integer of 0x1FFFFFFF or less.0x1FFFFFFF Select the Mask for mailboxes 24-27. In Mixed ID Mode the Standard ID mask is the upper 11 bits of the full 29-bit mask value.
Input > Mailbox 28-31 Group
Input > Mailbox 28-31 Group > Mailbox ID
Mailbox 28 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.28 Select the receive ID for mailbox 28, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 29 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.29 Select the receive ID for mailbox 29, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 30 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.30 Select the receive ID for mailbox 30, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Mailbox 31 IDValue must be decimal or HEX integer of 0x1FFFFFFF or less.31 Select the receive ID for mailbox 31, between 0 and 0x7ff when using standard IDs, between 0 and 0x1FFFFFFF when using extended IDs. Value is not used when the mailbox is set as transmit type.
Input > Mailbox 28-31 Group > Mailbox ID Mode
Mailbox 28 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 29 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 30 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Mailbox 31 ID Mode
  • Standard ID
  • Extended ID
Standard ID Select whether the mailbox is used to receive Standard or Extended ID messages. This setting is only valid when Global ID Mode is set to 'Mixed ID Mode'.
Input > Mailbox 28-31 Group > Mailbox Type
Mailbox 28 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 29 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 30 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Mailbox 31 Type
  • Receive Mailbox
  • Transmit Mailbox
Receive Mailbox Select whether the mailbox is used for receive or transmit.
Input > Mailbox 28-31 Group > Mailbox Frame Type
Mailbox 28 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 29 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 30 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 31 Frame Type
  • Data Mailbox
  • Remote Mailbox
Data Mailbox Select whether the mailbox is used to capture data frames or remote frames (ignored for transmit mailboxes).
Mailbox 28-31 Group MaskValue must be decimal or HEX integer of 0x1FFFFFFF or less.0x1FFFFFFF Select the Mask for mailboxes 28-31. In Mixed ID Mode the Standard ID mask is the upper 11 bits of the full 29-bit mask value.

Clock Configuration

The CAN peripheral uses the CANMCLK (main-clock oscillator) or PCLKB as its clock source (fCAN, CAN System Clock.) The default CAN configuration will provide a CAN bit rate of 500 Kbit using CANMCLK as the clock source. To set the PCLKB frequency, use the Clocks tab of the RA Configuration editor. To change the clock frequency at run-time, use the CGC Interface. Refer to the CGC module guide for more information on configuring clocks.

Warning
RA2 devices only support CANMCLK (MOSC/XTAL) for the CAN clock source. If MOSC is not used as the main clock source it will not be started automatically. In this case, be sure to start it before opening the CAN driver.

Clock Limitations

The following clock limitations apply when using the CAN peripheral:

Pin Configuration

The CAN peripheral module uses pins on the MCU to communicate to external devices. I/O pins must be selected and configured as required by the external device. A CAN channel would consist of two pins - CRX and CTX for data transmission/reception.

Usage Notes

Bit Rate Calculation

For convenience, the baudrate of the CAN peripheral is automatically set through the RA Configuration editor using a best effort approach. If the auto-generated baud settings cause deviation that is not tolerable by the application, the user can override the auto-generated settings and put in manually calculated values through RA Configuration editor. For more details on how the baudrate is set refer to section 37.4 "Data Transfer Rate Configuration" of the RA6M3 User's Manual (R01UH0886EJ0100).

FIFO Support

When FIFO Support is enabled, mailboxes 24-27 form a 4-stage transmit FIFO and mailboxes 28-31 form a 4-stage receive FIFO. The receive FIFO supports two independent ID/mask settings for acceptance filtering.

Note
Only the base mailbox of each FIFO may be accessed. When writing to the TX FIFO it is recommended to use CAN_MAILBOX_ID_TX_FIFO.

Limitations

Developers should be aware of the following limitations when using CAN:

Examples

Basic Example

This is a basic example of minimal use of the CAN in an application.

can_frame_t g_can_tx_frame;
can_frame_t g_can_rx_frame;
volatile bool g_rx_flag = false;
volatile bool g_tx_flag = false;
volatile bool g_err_flag = false;
volatile uint32_t g_rx_id;
void can_callback (can_callback_args_t * p_args)
{
switch (p_args->event)
{
case CAN_EVENT_RX_COMPLETE: /* Receive complete event. */
{
g_rx_flag = true;
g_rx_id = p_args->frame.id;
/* Read received frame */
g_can_rx_frame = p_args->frame;
break;
}
case CAN_EVENT_TX_COMPLETE: /* Transmit complete event. */
{
g_tx_flag = true;
break;
}
case CAN_EVENT_ERR_BUS_OFF: /* Bus error event. (bus off) */
case CAN_EVENT_ERR_PASSIVE: /* Bus error event. (error passive) */
case CAN_EVENT_ERR_WARNING: /* Bus error event. (error warning) */
case CAN_EVENT_BUS_RECOVERY: /* Bus error event. (bus recovery) */
case CAN_EVENT_MAILBOX_MESSAGE_LOST: /* Overwrite/overrun error */
{
/* Set error flag */
g_err_flag = true;
break;
}
default:
{
break;
}
}
}
void basic_example (void)
{
fsp_err_t err;
uint32_t i;
uint32_t timeout_ms = CAN_BUSY_DELAY;
/* Initialize the CAN module */
err = R_CAN_Open(&g_can0_ctrl, &g_can0_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
g_can_tx_frame.id = CAN_DESTINATION_DEVICE_MAILBOX_NUMBER; /* CAN Destination Device ID */
g_can_tx_frame.type = CAN_FRAME_TYPE_DATA;
g_can_tx_frame.data_length_code = CAN_FRAME_TRANSMIT_DATA_BYTES;
/* Write some data to the transmit frame */
for (i = 0; i < sizeof(g_can_tx_frame.data); i++)
{
g_can_tx_frame.data[i] = (uint8_t) i;
}
/* Send data on the bus */
g_tx_flag = false;
g_err_flag = false;
err = R_CAN_Write(&g_can0_ctrl, CAN_MAILBOX_NUMBER_31, &g_can_tx_frame);
assert(FSP_SUCCESS == err);
/* Since there is nothing else to do, block until Callback triggers*/
while ((true != g_tx_flag) && timeout_ms)
{
timeout_ms--;
}
if (true == g_err_flag)
{
__BKPT(0);
}
}

External Loop-back Test

This example requires the CTX and CRX pins to be connected. If a CAN tranciever is onboard a 120 Ohm resistor should be connected across CANH and CANL instead. The mailbox numbers are arbitrarily chosen.

void can_external_loopback_example (void)
{
fsp_err_t err;
uint32_t timeout_ms = CAN_BUSY_DELAY;
int diff = 0;
uint32_t i = 0;
err = R_CAN_Open(&g_can0_ctrl, &g_can0_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
err = R_CAN_ModeTransition(&g_can0_ctrl, operation_mode, test_mode);
assert(FSP_SUCCESS == err);
/* Clear the data part of receive frame */
memset(g_can_rx_frame.data, 0, CAN_FRAME_TRANSMIT_DATA_BYTES);
/* CAN Destination Device ID, in this case it is the same device with another mailbox */
g_can_tx_frame.id = CAN_MAILBOX_NUMBER_4;
g_can_tx_frame.type = CAN_FRAME_TYPE_DATA;
g_can_tx_frame.data_length_code = CAN_FRAME_TRANSMIT_DATA_BYTES;
/* Write some data to the transmit frame */
for (i = 0; i < sizeof(g_can_tx_frame.data); i++)
{
g_can_tx_frame.data[i] = (uint8_t) i;
}
/* Send data on the bus */
g_rx_flag = false;
g_err_flag = false;
err = R_CAN_Write(&g_can0_ctrl, CAN_MAILBOX_NUMBER_31, &g_can_tx_frame);
assert(FSP_SUCCESS == err);
/* Since there is nothing else to do, block until Callback triggers*/
while ((true != g_rx_flag) && timeout_ms)
{
timeout_ms--;
}
if (true == g_err_flag)
{
__BKPT(0);
}
/* Verify received data */
diff = memcmp(&g_can_rx_frame.data[0], &g_can_tx_frame.data[0], CAN_FRAME_TRANSMIT_DATA_BYTES);
if (0 != diff)
{
__BKPT(0);
}
}

Data Structures

struct  can_mailbox_t
 
struct  can_fifo_interrupt_cfg_t
 
struct  can_rx_fifo_cfg_t
 
struct  can_extended_cfg_t
 

Enumerations

enum  can_status_t
 
enum  can_error_t
 
enum  can_mailbox_number_t
 
enum  can_mailbox_send_receive_t
 
enum  can_global_id_mode_t
 
enum  can_message_mode_t
 
enum  can_clock_source_t
 
enum  can_fifo_interrupt_mode_t
 

Data Structure Documentation

◆ can_mailbox_t

struct can_mailbox_t

CAN Mailbox

Data Fields
uint32_t mailbox_id Mailbox ID.
can_id_mode_t id_mode Standard or Extended ID. Only used in Mixed ID mode.
can_frame_type_t frame_type Frame type for receive mailbox.
can_mailbox_send_receive_t mailbox_type Receive or Transmit mailbox type.

◆ can_fifo_interrupt_cfg_t

struct can_fifo_interrupt_cfg_t

CAN FIFO interrupt configuration

Data Fields
can_fifo_interrupt_mode_t fifo_int_mode FIFO interrupts mode (RX and TX combined).
IRQn_Type tx_fifo_irq TX FIFO IRQ.
IRQn_Type rx_fifo_irq RX FIFO IRQ.

◆ can_rx_fifo_cfg_t

struct can_rx_fifo_cfg_t

CAN RX FIFO configuration

Data Fields
uint32_t rx_fifo_mask1 RX FIFO acceptance filter mask 1.
uint32_t rx_fifo_mask2 RX FIFO acceptance filter mask 1.
can_mailbox_t rx_fifo_id1 RX FIFO acceptance filter ID 1.
can_mailbox_t rx_fifo_id2 RX FIFO acceptance filter ID 2.

◆ can_extended_cfg_t

struct can_extended_cfg_t

CAN extended configuration

Data Fields
can_clock_source_t clock_source Source of the CAN clock.
uint32_t * p_mailbox_mask Mailbox mask, one for every 4 mailboxes.
can_mailbox_t * p_mailbox Pointer to mailboxes.
can_global_id_mode_t global_id_mode Standard or Extended ID mode.
uint32_t mailbox_count Number of mailboxes.
can_message_mode_t message_mode Overwrite message or overrun.
can_fifo_interrupt_cfg_t const * p_fifo_int_cfg Pointer to FIFO interrupt configuration.
can_rx_fifo_cfg_t * p_rx_fifo_cfg Pointer to RX FIFO configuration.

Enumeration Type Documentation

◆ can_status_t

CAN Status

Enumerator
CAN_STATUS_NEW_DATA 

New Data status flag.

CAN_STATUS_SENT_DATA 

Sent Data status flag.

CAN_STATUS_RECEIVE_FIFO 

Receive FIFO status flag.

CAN_STATUS_TRANSMIT_FIFO 

Transmit FIFO status flag.

CAN_STATUS_NORMAL_MBOX_MESSAGE_LOST 

Normal mailbox message lost status flag.

CAN_STATUS_FIFO_MBOX_MESSAGE_LOST 

FIFO mailbox message lost status flag.

CAN_STATUS_TRANSMISSION_ABORT 

Transmission abort status flag.

CAN_STATUS_ERROR 

Error status flag.

CAN_STATUS_RESET_MODE 

Reset mode status flag.

CAN_STATUS_HALT_MODE 

Halt mode status flag.

CAN_STATUS_SLEEP_MODE 

Sleep mode status flag.

CAN_STATUS_ERROR_PASSIVE 

Error-passive status flag.

CAN_STATUS_BUS_OFF 

Bus-off status flag.

◆ can_error_t

CAN Error Code

Enumerator
CAN_ERROR_STUFF 

Stuff Error.

CAN_ERROR_FORM 

Form Error.

CAN_ERROR_ACK 

ACK Error.

CAN_ERROR_CRC 

CRC Error.

CAN_ERROR_BIT_RECESSIVE 

Bit Error (recessive) Error.

CAN_ERROR_BIT_DOMINANT 

Bit Error (dominant) Error.

CAN_ERROR_ACK_DELIMITER 

ACK Delimiter Error.

◆ can_mailbox_number_t

CAN Mailbox IDs (MB + FIFO)

◆ can_mailbox_send_receive_t

CAN Mailbox type

Enumerator
CAN_MAILBOX_RECEIVE 

Mailbox is for receiving.

CAN_MAILBOX_TRANSMIT 

Mailbox is for sending.

◆ can_global_id_mode_t

Global CAN ID mode settings

Enumerator
CAN_GLOBAL_ID_MODE_STANDARD 

Standard IDs of 11 bits used.

CAN_GLOBAL_ID_MODE_EXTENDED 

Extended IDs of 29 bits used.

CAN_GLOBAL_ID_MODE_MIXED 

Both Standard and Extended IDs used.

◆ can_message_mode_t

CAN Message Modes

Enumerator
CAN_MESSAGE_MODE_OVERWRITE 

Receive data will be overwritten if not read before the next frame.

CAN_MESSAGE_MODE_OVERRUN 

Receive data will be retained until it is read.

◆ can_clock_source_t

CAN Source Clock

Enumerator
CAN_CLOCK_SOURCE_PCLKB 

PCLKB is the source of the CAN Clock.

CAN_CLOCK_SOURCE_CANMCLK 

CANMCLK is the source of the CAN Clock.

◆ can_fifo_interrupt_mode_t

CAN FIFO Interrupt Modes

Function Documentation

◆ R_CAN_Open()

fsp_err_t R_CAN_Open ( can_ctrl_t *const  p_api_ctrl,
can_cfg_t const *const  p_cfg 
)

Open and configure the CAN channel for operation.

Example:

/* Initialize the CAN module */
err = R_CAN_Open(&g_can0_ctrl, &g_can0_cfg);
Return values
FSP_SUCCESSChannel opened successfully
FSP_ERR_ALREADY_OPENDriver already open.
FSP_ERR_CAN_INIT_FAILEDChannel failed to initialize.
FSP_ERR_ASSERTIONNull pointer presented.

◆ R_CAN_Close()

fsp_err_t R_CAN_Close ( can_ctrl_t *const  p_api_ctrl)

Close the CAN channel.

Return values
FSP_SUCCESSChannel closed successfully.
FSP_ERR_NOT_OPENControl block not open.
FSP_ERR_ASSERTIONNull pointer presented.

◆ R_CAN_Write()

fsp_err_t R_CAN_Write ( can_ctrl_t *const  p_api_ctrl,
uint32_t  mailbox,
can_frame_t *const  p_frame 
)

Write data to the CAN channel. Write up to eight bytes to the channel mailbox.

Example:

err = R_CAN_Write(&g_can0_ctrl, CAN_MAILBOX_NUMBER_31, &g_can_tx_frame);
assert(FSP_SUCCESS == err);
Return values
FSP_SUCCESSOperation succeeded.
FSP_ERR_NOT_OPENControl block not open.
FSP_ERR_CAN_TRANSMIT_NOT_READYTransmit in progress, cannot write data at this time.
FSP_ERR_CAN_TRANSMIT_FIFO_FULLTransmit FIFO is full.
FSP_ERR_CAN_RECEIVE_MAILBOXMailbox is setup for receive and cannot send.
FSP_ERR_INVALID_ARGUMENTData length or frame type invalid.
FSP_ERR_ASSERTIONNull pointer presented

◆ R_CAN_Read()

fsp_err_t R_CAN_Read ( can_ctrl_t *const  p_api_ctrl,
uint32_t  mailbox,
can_frame_t *const  p_frame 
)

Read data from a mailbox or FIFO.

Note
This function is not supported.
Return values
FSP_ERR_UNSUPPORTEDFunction not supported.

◆ R_CAN_ModeTransition()

fsp_err_t R_CAN_ModeTransition ( can_ctrl_t *const  p_api_ctrl,
can_operation_mode_t  operation_mode,
can_test_mode_t  test_mode 
)

CAN Mode Transition is used to change CAN driver state.

Example:

err = R_CAN_ModeTransition(&g_can0_ctrl, operation_mode, test_mode);
assert(FSP_SUCCESS == err);
Return values
FSP_SUCCESSOperation succeeded.
FSP_ERR_NOT_OPENControl block not open.
FSP_ERR_ASSERTIONNull pointer presented

◆ R_CAN_InfoGet()

fsp_err_t R_CAN_InfoGet ( can_ctrl_t *const  p_api_ctrl,
can_info_t *const  p_info 
)

Get CAN state and status information for the channel.

Return values
FSP_SUCCESSOperation succeeded.
FSP_ERR_NOT_OPENControl block not open.
FSP_ERR_ASSERTIONNull pointer presented

◆ R_CAN_CallbackSet()

fsp_err_t R_CAN_CallbackSet ( can_ctrl_t *const  p_api_ctrl,
void(*)(can_callback_args_t *)  p_callback,
void const *const  p_context,
can_callback_args_t *const  p_callback_memory 
)

Updates the user callback with the option to provide memory for the callback argument structure. Implements can_api_t::callbackSet.

Return values
FSP_SUCCESSCallback updated successfully.
FSP_ERR_ASSERTIONA required pointer is NULL.
FSP_ERR_NOT_OPENThe control block has not been opened.
FSP_ERR_NO_CALLBACK_MEMORYp_callback is non-secure and p_callback_memory is either secure or NULL.