From 3c4a0b96c161b97fadbe496fd94faaf30bf76fc6 Mon Sep 17 00:00:00 2001 From: Onath Claridge Date: Thu, 12 Aug 2021 13:22:03 -0700 Subject: [PATCH] [stm32f0xx] Fix type of overflow counter. stm32_timer_calc_value was using uint32_t for the overflow counter, ultimately causing timestamps to wrap as uint32_t. --- platform/stm32f0xx/timer_capture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/stm32f0xx/timer_capture.c b/platform/stm32f0xx/timer_capture.c index 403d6de2..b02654e2 100644 --- a/platform/stm32f0xx/timer_capture.c +++ b/platform/stm32f0xx/timer_capture.c @@ -222,7 +222,7 @@ static uint32_t stm32_timer_median_val(stm32_timer_capture_t *tc) { // Assumes interrupts are disabled. static uint64_t stm32_timer_calc_value(stm32_timer_capture_t *tc, uint32_t sr, uint32_t val) { - uint32_t overflow = tc->overflow; + uint64_t overflow = tc->overflow; // Since we could be processing an overflow and capture interrupts at the // same time, we don't know the ordering of the two. Here we assume // that if the capture event occurred in the lower half of the counter