From 7a346bee2645bb849b8a6deddaf7bda3aec49a47 Mon Sep 17 00:00:00 2001 From: Claudio Micheli Date: Mon, 25 May 2020 10:29:42 +0200 Subject: [PATCH] stm32f7: Add the option to include RTR in CAN header Signed-off-by: Claudio Micheli --- arch/arm/src/stm32f7/stm32_can.c | 7 +++++-- drivers/can/Kconfig | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm/src/stm32f7/stm32_can.c b/arch/arm/src/stm32f7/stm32_can.c index 6c76472af5..6f5ccda13f 100644 --- a/arch/arm/src/stm32f7/stm32_can.c +++ b/arch/arm/src/stm32f7/stm32_can.c @@ -1288,8 +1288,11 @@ static int stm32can_send(FAR struct can_dev_s *dev, } #else - regval &= ~CAN_TIR_STID_MASK; - regval |= (uint32_t)msg->cm_hdr.ch_id << CAN_TIR_STID_SHIFT; + regval |= ( ( (uint32_t) msg->cm_hdr.ch_id << CAN_TIR_STID_SHIFT) & CAN_TIR_STID_MASK ); + +#ifdef CONFIG_CAN_USE_RTR + regval |= (msg->cm_hdr.ch_rtr ? CAN_TIR_RTR : 0); +#endif #endif stm32can_putreg(priv, STM32_CAN_TIR_OFFSET(txmb), regval); diff --git a/drivers/can/Kconfig b/drivers/can/Kconfig index d5298d77e7..ae54205550 100644 --- a/drivers/can/Kconfig +++ b/drivers/can/Kconfig @@ -128,6 +128,12 @@ config CAN_NPOLLWAITERS ---help--- The maximum number of threads that may be waiting on the poll method. + +config CAN_USE_RTR + bool "Include RTR in CAN header" + default n + ---help--- + This selection includes RTR bitfield in the CAN header. comment "CAN Bus Controllers:"