Hardware manual

RX600 Series CAN Application Programming Interface
R01AN0339EU0203 Rev. 2.03 Page 18 of 29
Mar 23, 2013
R_CAN_RxRead
Read the CAN data frame content from a mailbox
The API checks if a given mailbox has received a message. If so, a copy of the mailbox’s dataframe will be written to
the given structure.
Format
uint32_t R_CAN_RxRead( const uint32_t ch_nr,
const uint32_t mbox_nr,
can_std_frame_t * const frame_p );
Arguments
ch_nr 0,1,2,3 Which CAN bus to use. 1-4 channels may be available.
mbox_nr 0-32 Which CAN mailbox to check.
frame_p * Refers to a pointer to a data frame structure in memory.
It is an address to the data structure into which the function will place a
copy of the mailbox’s received CAN dataframe.
Return Values
R_CAN_OK There is a message waiting.
R_CAN_SW_BAD_MBX Bad mailbox number.
R_CAN_BAD_CH_NR The channel number does not exist.
R_CAN_MSGLOST Message was overwritten or lost.
Properties
Prototyped in r_can_api.h
Implemented in r_can_api.c
Comments
Use R_CAN_PollRxCAN() first to check whether the mailbox has received a message.
This function is used to fetch the message from a mailbox, either when using polled mode or from a CAN receive
interrupt.
Example
#define MY_RX_SLOT 8
can_std_frame_t my_rx_dataframe;
api_status = R_CAN_RxPoll(0, CANBOX_RX_DIAG);
if (api_status == R_CAN_OK)
R_CAN_RxRead(0, CANBOX_RX_DIAG, &my_rx_dataframe);