You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/06/29 12:05:55 UTC
[incubator-nuttx] 04/04: stm32l4: extend CAN ioctrl with NART/ABOM.
Add RTR to CAN header
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 10f93b9d9b4c2b199a20397e4cd8310f28188699
Author: Claudio Micheli <cl...@auterion.com>
AuthorDate: Mon May 25 14:01:58 2020 +0200
stm32l4: extend CAN ioctrl with NART/ABOM. Add RTR to CAN header
Signed-off-by: Claudio Micheli <cl...@auterion.com>
---
arch/arm/src/stm32l4/stm32l4_can.c | 51 ++++++++++++++++++++++++++++++++++++--
1 file changed, 49 insertions(+), 2 deletions(-)
diff --git a/arch/arm/src/stm32l4/stm32l4_can.c b/arch/arm/src/stm32l4/stm32l4_can.c
index 81cc833..3caca66 100644
--- a/arch/arm/src/stm32l4/stm32l4_can.c
+++ b/arch/arm/src/stm32l4/stm32l4_can.c
@@ -1073,6 +1073,50 @@ static int stm32l4can_ioctl(FAR struct can_dev_s *dev, int cmd,
}
break;
+ case CANIOC_SET_NART:
+ {
+ uint32_t regval;
+ ret = stm32can_enterinitmode(priv);
+ if (ret != 0)
+ {
+ return ret;
+ }
+ regval = stm32can_getreg(priv, STM32_CAN_MCR_OFFSET);
+ if (arg == 1)
+ {
+ regval |= CAN_MCR_NART;
+ }
+ else
+ {
+ regval &= ~CAN_MCR_NART;
+ }
+ stm32can_putreg(priv, STM32_CAN_MCR_OFFSET, regval);
+ return stm32can_exitinitmode(priv);
+ }
+ break;
+
+ case CANIOC_SET_ABOM:
+ {
+ uint32_t regval;
+ ret = stm32can_enterinitmode(priv);
+ if (ret != 0)
+ {
+ return ret;
+ }
+ regval = stm32can_getreg(priv, STM32_CAN_MCR_OFFSET);
+ if (arg == 1)
+ {
+ regval |= CAN_MCR_ABOM;
+ }
+ else
+ {
+ regval &= ~CAN_MCR_ABOM;
+ }
+ stm32can_putreg(priv, STM32_CAN_MCR_OFFSET, regval);
+ return stm32can_exitinitmode(priv);
+ }
+ break;
+
/* Unsupported/unrecognized command */
default:
@@ -1182,8 +1226,11 @@ static int stm32l4can_send(FAR struct can_dev_s *dev,
regval |= msg->cm_hdr.ch_id << CAN_TIR_STID_SHIFT;
}
#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
stm32l4can_putreg(priv, STM32L4_CAN_TIR_OFFSET(txmb), regval);