Hardware manual
RX600 Series CAN Application Programming Interface
R01AN0339EU0203 Rev. 2.03 Page 5 of 29
Mar 23, 2013
6. Adding the CAN API to Your Project
Follow the steps below to add the CAN API code to your project. These steps assume that the Flash API has already
been added to your project.
1. Copy the r_can_api directory (packaged with this application note) to your project directory.
2. Add the file r_can_api.c to your project.
3. Add an include path to the r_can_api directory.
4. Add an include path to the r_can_api\src directory.
5. Configure the middleware with config_r_can_api.h.
7. The CAN Config File
It may be necessary to make modifications to the config_r_can_rapi.h file to customize the application
for the way you wish to run it. For example, there is the option of running in CAN polled mode or CAN
interrupt mode.
config_r_can_rapi.h is the place where this is selected.
Do not change anything in the
r_can_api.c file, which contains the Renesas CAN API functions for your Renesas
MCU.
Interrupts vs. Polling
USE_CAN_POLL
Include the macro USE_CAN_POLL if you want to poll CAN mailboxes for messages received and sent. Do not
include to use the CAN interrupts.
CAN Interrupt Settings
CAN0_INT_LVL
Sets the CAN interrupt level.
USE_CAN_API_SEARCH
Not implemented in the latest code releases to not cause confusion with the existing example code. If you have many
mailboxes configured and alot of CAN traffic, you may want to consider using this feature. Please see the MCU
hardware manual.
Max Time to Poll a Register
MAX_CANREG_POLLCYCLES
Max loops to poll a CAN register bit for expected value. If you are using polled mode, and If you wish to wait a certain
time to check that a mailbox has recieved a frame, increase this value. This can be set to a very low value, but do not set
to zero or the mailbox may not be chacded at all.!
Transceiver Control Pin Mapping
TRANSCEIVER STANDBY, TRANSCEIVER ENABLE
Specify where you have the transceiver control pins connected. Some transceivers may have other control pins. You
would have to configure this yourself.
Using Standard/Extended ID
FRAME_ID_MODE
Select what type of CAN ID type to enable in the driver, that is, usage of 11-bit or 29-bit IDs.
FRAME_ID_MODE can be set to STD_ID_MODE, EXT_ID_MODE, or MIXED_ID_MODE. The first two settings
enable only those functions belonging to that ID mode. If it is set to mixed mode, the whole API becomes available. It is
preferable to not set mixed mode for the driver if it is to be used in a network using only one ID type. Messages with the
wrong ID type for the network will only cause wasted bandwidth (no node will receive them).