From 63b5c790b79895f66475bc098774ade079367557 Mon Sep 17 00:00:00 2001 From: Niklas Hauser Date: Wed, 31 May 2023 17:07:06 +0200 Subject: [PATCH] iotimer: Enable timer when configuring input capture We provide a latency measurement in the input capture handler. However, since the timer was not enabled, none of the counter were running therefore all counters were zero, thus latency was also zero. Since the HRT is used to provide a timestamp, the lack of the running timer was never noticed. After enabling the timer, latency now correctly shows 9-10 counts. --- .../nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c index 5a72cc9f5e..4246ea3585 100644 --- a/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c +++ b/platforms/nuttx/src/px4/stm/stm32_common/io_pins/io_timer.c @@ -898,11 +898,13 @@ int io_timer_set_enable(bool state, io_timer_channel_mode_t mode, io_timer_chann case IOTimerChanMode_Dshot: dier_bit = 0; - cr1_bit = state ? GTIM_CR1_CEN : 0; - break; - case IOTimerChanMode_PWMIn: + /* fallthrough */ case IOTimerChanMode_Capture: + cr1_bit = state ? GTIM_CR1_CEN : 0; + + /* fallthrough */ + case IOTimerChanMode_PWMIn: break; default: