From bc178344a9d023f85a89ceb4fa6a83388ccce9b8 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Sat, 5 Feb 2022 16:40:43 +0100 Subject: [PATCH] net/can: add an option to control CAN EXTID support --- arch/arm/src/stm32/stm32_can_sock.c | 6 +++--- arch/arm/src/stm32/stm32_fdcan_sock.c | 8 ++++---- boards/arm/stm32/nucleo-f446re/configs/cansock/defconfig | 2 +- net/can/Kconfig | 7 +++++++ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/arch/arm/src/stm32/stm32_can_sock.c b/arch/arm/src/stm32/stm32_can_sock.c index ff13b54297..8b35726215 100644 --- a/arch/arm/src/stm32/stm32_can_sock.c +++ b/arch/arm/src/stm32/stm32_can_sock.c @@ -881,7 +881,7 @@ static int stm32can_transmit(FAR struct stm32_can_s *priv) /* Set up the ID, standard 11-bit or extended 29-bit. */ -#ifdef CONFIG_CAN_EXTID +#ifdef CONFIG_NET_CAN_EXTID regval &= ~CAN_TIR_EXID_MASK; if (frame->can_id & CAN_EFF_FLAG) { @@ -1205,7 +1205,7 @@ static int stm32can_rxinterrupt_work(FAR struct stm32_can_s *priv, int rxmb) regval = stm32can_getreg(priv, STM32_CAN_RIR_OFFSET(rxmb)); -#ifdef CONFIG_CAN_EXTID +#ifdef CONFIG_NET_CAN_EXTID if ((regval & CAN_RIR_IDE) != 0) { frame->can_id = (regval & CAN_RIR_EXID_MASK) >> CAN_RIR_EXID_SHIFT; @@ -1277,7 +1277,7 @@ static int stm32can_rxinterrupt_work(FAR struct stm32_can_s *priv, int rxmb) /* Release the FIFO */ -#ifndef CONFIG_CAN_EXTID +#ifndef CONFIG_NET_CAN_EXTID errout: #endif regval = stm32can_getreg(priv, STM32_CAN_RFR_OFFSET(rxmb)); diff --git a/arch/arm/src/stm32/stm32_fdcan_sock.c b/arch/arm/src/stm32/stm32_fdcan_sock.c index fafecbedf0..6d61d06560 100644 --- a/arch/arm/src/stm32/stm32_fdcan_sock.c +++ b/arch/arm/src/stm32/stm32_fdcan_sock.c @@ -520,14 +520,14 @@ struct stm32_fdcan_s const struct stm32_config_s *config; uint8_t state; /* See enum can_state_s */ -#ifdef CONFIG_CAN_EXTID +#ifdef CONFIG_NET_CAN_EXTID uint8_t nextalloc; /* Number of allocated extended filters */ #endif uint8_t nstdalloc; /* Number of allocated standard filters */ uint32_t nbtp; /* Current nominal bit timing */ uint32_t dbtp; /* Current data bit timing */ -#ifdef CONFIG_CAN_EXTID +#ifdef CONFIG_NET_CAN_EXTID uint32_t extfilters[2]; /* Extended filter bit allocator. 2*32=64 */ #endif uint32_t stdfilters[4]; /* Standard filter bit allocator. 4*32=128 */ @@ -1718,7 +1718,7 @@ static int fdcan_send(FAR struct stm32_fdcan_s *priv) * Extended Identifier (XTD) - Depends on configuration. */ -#ifdef CONFIG_CAN_EXTID +#ifdef CONFIG_NET_CAN_EXTID if (frame->can_id & CAN_EFF_FLAG) { DEBUGASSERT(frame->can_id < (1 << 29)); @@ -2409,7 +2409,7 @@ static void fdcan_receive(FAR struct stm32_fdcan_s *priv, frame->can_id |= CAN_RTR_FLAG; } -#ifdef CONFIG_CAN_EXTID +#ifdef CONFIG_NET_CAN_EXTID if ((regval & BUFFER_R0_XTD) != 0) { /* Save the extended ID of the newly received message */ diff --git a/boards/arm/stm32/nucleo-f446re/configs/cansock/defconfig b/boards/arm/stm32/nucleo-f446re/configs/cansock/defconfig index 462bdba21b..96e4263fe5 100644 --- a/boards/arm/stm32/nucleo-f446re/configs/cansock/defconfig +++ b/boards/arm/stm32/nucleo-f446re/configs/cansock/defconfig @@ -24,7 +24,6 @@ CONFIG_ARCH_STACKDUMP=y CONFIG_BOARD_LATE_INITIALIZE=y CONFIG_BOARD_LOOPSPERMSEC=8499 CONFIG_BUILTIN=y -CONFIG_CAN_EXTID=y CONFIG_DEBUG_FULLOPT=y CONFIG_DEBUG_SYMBOLS=y CONFIG_FS_PROCFS=y @@ -37,6 +36,7 @@ CONFIG_NETDEVICES=y CONFIG_NETDEV_IFINDEX=y CONFIG_NETDEV_LATEINIT=y CONFIG_NET_CAN=y +CONFIG_NET_CAN_EXTID=y CONFIG_NET_SOCKOPTS=y CONFIG_NET_STATISTICS=y CONFIG_NSH_BUILTIN_APPS=y diff --git a/net/can/Kconfig b/net/can/Kconfig index cd29c369e7..85c77c078e 100644 --- a/net/can/Kconfig +++ b/net/can/Kconfig @@ -36,6 +36,13 @@ config CAN_CONNS ---help--- Maximum number of CAN connections (all tasks). +config NET_CAN_EXTID + bool "Enable CAN extended IDs" + default n + ---help--- + Enables support for the 29-bit extended ID in SocketCAN stack. + Default Standard 11-bit IDs. + config NET_CAN_CANFD bool "Enable CAN FD support" default y