/* CAN4 port */
&can3
{
status = "okay";
};
2. Assigning CAN3 to Baremetal
In baremetal, the port is allocated through the
flexcan.c
file. The flexcan.c path is
industry-uboot/drivers/flexcan/
flexcan.c
. In this file, you need to define the following variables:
a.
struct can_bittiming_t flexcan3_bittiming = CAN_BITTIM_INIT(CAN_500K);
Set bit timing and baud rate (500K) of the CAN port.
NOTE
b. struct can_ctrlmode_t flexcan3_ctrlmode
struct can_ctrlmode_t flexcan3_ctrlmode =
{
.loopmode = 0, /* Indicates whether the loop mode is enabled */
.listenonly = 0, /* Indicates whether the only-listen mode is enabled */
.samples = 0,
.err_report = 1,
};
c. struct can_init_t flexcan3
struct can_init_t flexcan3 =
{
.canx = CAN3, /* Specify CAN port */
.bt = &flexcan3_bittiming,
.ctrlmode = &flexcan3_ctrlmode,
.reg_ctrl_default = 0,
.reg_esr = 0
};
d. Optional parameters
• CAN port
#define CAN3 ((struct can_module *)CAN3_BASE)
#define CAN4 ((struct can_module *)CAN4_BASE)
• Baud rate
#define CAN_1000K 10
#define CAN_500K 20
#define CAN_250K 40
#define CAN_200K 50
#define CAN_125K 80
#define CAN_100K 100
#define CAN_50K 200
#define CAN_20K 500
#define CAN_10K 1000
#define CAN_5K 2000
NXP Semiconductors
FlexCAN
Open Industrial User Guide, Rev. 1.8, 05/2020
User's Guide
168 / 199