Skip to content
Permalink
Browse files

drivers: can: stm32: Implement timestamp for RX frames

This commit implements timestamps for receiving frames on
stm32 CAN driver.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
  • Loading branch information...
alexanderwachter authored and jukkar committed Jul 24, 2019
1 parent 3febaad commit 9923cf2ddac04e0d8bee4462ca54ecaa26e3a33a
Showing with 6 additions and 0 deletions.
  1. +6 −0 drivers/can/can_stm32.c
@@ -52,6 +52,9 @@ static void can_stm32_get_msg_fifo(CAN_FIFOMailBox_TypeDef *mbox,
msg->dlc = mbox->RDTR & (CAN_RDT0R_DLC >> CAN_RDT0R_DLC_Pos);
msg->data_32[0] = mbox->RDLR;
msg->data_32[1] = mbox->RDHR;
#ifdef CONFIG_CAN_RX_TIMESTAMP
msg->timestamp = ((mbox->RDTR & CAN_RDT0R_TIME) >> CAN_RDT0R_TIME_Pos);
#endif
}

static inline
@@ -363,6 +366,9 @@ static int can_stm32_init(struct device *dev)
can->MCR |= CAN_MCR_TXFP;
can->MCR &= ~CAN_MCR_TTCM & ~CAN_MCR_TTCM & ~CAN_MCR_ABOM &
~CAN_MCR_AWUM & ~CAN_MCR_NART & ~CAN_MCR_RFLM;
#ifdef CONFIG_CAN_RX_TIMESTAMP
can->MCR |= CAN_MCR_TTCM;
#endif

ret = can_stm32_runtime_configure(dev, CAN_NORMAL_MODE, 0);
if (ret) {

0 comments on commit 9923cf2

Please sign in to comment.
You can’t perform that action at this time.