This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MCU-PLUS-SDK-AM261X: Defined gCanfdObj and gCanfdHandle symbols in ti_drivers_config.h

Part Number: MCU-PLUS-SDK-AM261X

Tool/software:

I have several files in my project that need to include the ti_drivers_config.h file. When adding CANFD according to mcu_plus_sdk_am261x_10_00_01_10\examples\drivers\mcan\canfd_loopback_interrupt\am261x-lp\r5fss0-0_freertos, two symbols, gCanfdObj and gCanfdHandle becomes defined in ti_drivers_config.h.

This is a One Definition Rule (ODR) violation in C/C++, and rightfully the linker complains on redefinitions, because now each file that includes ti_drivers_config.h will have these symbols defined.

So, first of all, I would consider this a bug in the generated code (based on e.g., mcan_v0_hld.h.xdt).

Secondly. Is there some workaround other than using the low level driver (mcan.h) instead?

This is the generated code in ti_drivers_config.h

/*
 * EDMA
 */
#include <drivers/edma.h>
#include <drivers/soc.h>

/* EDMA Instance Macros */
#define CONFIG_EDMA0_BASE_ADDR (CSL_TPCC0_U_BASE)
#define CONFIG_EDMA0 (0U)
#define CONFIG_EDMA_NUM_INSTANCES (1U)
/*
 * MCAN
 */
#include <drivers/mcan/v0/canfd.h>
#include <drivers/mcan/v0/mcan.h>


#define CONFIG_MCAN0_MCAN_STD_ID_FILT_START_ADDR     (0U)
#define CONFIG_MCAN0_MCAN_STD_ID_FILTER_NUM          (1U)
#define CONFIG_MCAN0_MCAN_EXT_ID_FILT_START_ADDR     (48U)
#define CONFIG_MCAN0_MCAN_EXT_ID_FILTER_NUM          (1U)
#define CONFIG_MCAN0_MCAN_TX_BUFF_SIZE               (10U)
#define CONFIG_MCAN0_MCAN_FIFO_1_NUM                 (10U)
#define CONFIG_MCAN0_MCAN_TX_EVENT_SIZE              (10U)
#define CONFIG_MCAN0_MCAN_FIFO_0_NUM                 (10U)

#define CONFIG_MCAN0              (0U)
#define CONFIG_MCAN0_BASE_ADDR    (CSL_MCAN0_MSG_RAM_U_BASE)

#define CONFIG_MCAN_NUM_INSTANCES (1U)

/*  CANFD objects - initialized by the driver */
CANFD_Object gCanfdObj[CONFIG_MCAN_NUM_INSTANCES];
/*  CANFD global configuration array */
extern CANFD_Config gCanfdConfig[CONFIG_MCAN_NUM_INSTANCES];
/* CANFD Driver handles */
CANFD_Handle gCanfdHandle[CONFIG_MCAN_NUM_INSTANCES];