Hardware manual

RX600 Series CAN Application Programming Interface
R01AN0339EU0203 Rev. 2.03 Page 10 of 29
Mar 23, 2013
R_CAN_Control
Set CAN operating modes
Controls transition to CAN operating modes determined by the CAN Control register. For example, the Halt mode
should be used to later configure a receive mailbox.
Format
uint32_t R_CAN_Control( const uint32_t ch_nr,
const uint32_t action_type );
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.
action_type Peripheral actions:
EXITSLEEP_CANMODE Exit CAN Sleep mode, the default state when the
peripheral starts up. See 12.
ENTERSLEEP_CANMODE Enter CAN Sleep mode to save power.
RESET_CANMODE Put the CAN peripheral into Reset mode.
HALT_CANMODE Put the CAN peripheral into Halt mode. CAN peripheral
is still connected to the but stops communicating.
OPERATE_CANMODE Put the CAN peripheral into normal Operation mode.
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_BAD_ACTION_TYPE No such action type exists for this function.
R_CAN_SW_WAKEUP_ERR The CAN peripheral did not wake up from Sleep mode.
R_CAN_SW_SLEEP_ERR The CAN peripheral did not enter Sleep mode.
R_CAN_SW_RST_ERR The CAN peripheral did not enter Halt mode.
R_CAN_SW_HALT_ERR The CAN peripheral did not enter Halt mode.
R_CAN_SW_RST_ERR The CAN peripheral did not enter Reset mode.
See also R_CAN_PortSet return values.
Properties
Prototyped in r_can_api.h
Implemented in r_can_api.c
Comments
Other than calling this API to enter Halt mode, CAN mode transitions are called via the other API functions
automatically. For example, the default mode when starting up is CAN Sleep mode. Use the API to switch to
other operating modes, for example first ‘Exit Sleep’ followed by ‘Reset‘ to initialize the CAN registers for
bitrate and interrupts, then enter ‘Halt’ mode to configure mailboxes.
Example
/* Normal CAN bus usage. */
result = R_CAN_Control(0, OPERATE_CANMODE); //Check that result is = R_CAN_OK.