From 2c38c4b96b55c87502669fbf609bb2b5cca655cd Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Mon, 7 Apr 2014 14:50:43 +0400 Subject: [PATCH] STM32: Fixed race condition in clock driver --- libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp b/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp index c43dd692a7..07e22c9617 100644 --- a/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp +++ b/libuavcan_drivers/stm32/driver/src/uc_stm32_clock.cpp @@ -119,12 +119,12 @@ uavcan::MonotonicTime getMonotonic() { CriticalSectionLock locker; usec = sampleFromCriticalSection(&time_mono); - } #if !NDEBUG - static uavcan::uint64_t prev_usec = 0; // Self-test - assert(prev_usec <= usec); - prev_usec = usec; + static uavcan::uint64_t prev_usec = 0; // Self-test + assert(prev_usec <= usec); + prev_usec = usec; #endif + } return uavcan::MonotonicTime::fromUSec(usec); } @@ -239,7 +239,7 @@ UAVCAN_STM32_IRQ_HANDLER(TIMX_IRQHandler) { UAVCAN_STM32_IRQ_PROLOGUE(); - TIMX->SR = ~TIM_SR_UIF; + TIMX->SR = 0; using namespace uavcan_stm32::clock; assert(initialized);