Hardware manual
RX600 Series CAN Application Programming Interface
R01AN0339EU0203 Rev. 2.03 Page 8 of 29
Mar 23, 2013
R_CAN_Create
Initializes the CAN peripheral, sets bitrate, masks, mailbox defaults and configures
CAN interrupts
This function will by default invoke the rest of the initialization functions. It also sets the CAN interrupt levels. It will
also call all other relevant set-up functions such as
• R_CAN_SetBitrate()
• R_CAN_RxSetMask ()
• R_CAN_PortSet ()
Format
uint32_t R_CAN_Create(const uint32_t ch_nr);
Arguments
ch_nr 0,1,2,3 Which CAN bus to use. The number of available channels
depends on part. 1-4 channels may be available.
Return Values
R_CAN_OK Action completed successfully.
R_CAN_SW_BAD_MBX Bad mailbox number.
R_CAN_BAD_CH_NR The channel number does not exist.
R_CAN_SW_RST_ERR The CAN peripheral did not enter Reset mode.
R_CAN_MODULE_STOP_ERR Whole CAN peripheral is in stop state (low power). Perhaps the PRCR
register was not used to unlock the module stop register.
See also R_CAN_Control return values.
Properties
Prototyped in r_can_api.h
Implemented in r_can_api.c
Comments
This function wakes the peripheral from CAN Sleep mode and puts it in CAN Reset mode. It configures the mailboxes
with these default settings:
• Overwrite an unread mailbox data when new frames arrive
• Sets the device to use ID priority (normal CAN behavior, not the optional mailbox number priority).
• Sets all mailboxes’ masks invalid.
R_CAN_Create calls the R_CAN_SetBitrate function and configures CAN interrupts if USE_CAN_POLL is
commented in config_r_can_rapi.h.
Before returning, it clears all mailboxes, sets the peripheral into Operation mode, and clears any errors.
Example
/* Init CAN. */
api_status = R_CAN_Create(0);