From 4d6afcddfa70c86eeb6522c37bddda19098bbef4 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Fri, 4 Nov 2016 11:42:53 -0500 Subject: [PATCH] Fixed arithmetic error in rtos-based wait The value of `start` is taken from before that wait call, so the value of `us` shouldn't be changed --- platform/mbed_wait_api_rtos.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/platform/mbed_wait_api_rtos.cpp b/platform/mbed_wait_api_rtos.cpp index f0952d08e1..9ee2ff9c7e 100644 --- a/platform/mbed_wait_api_rtos.cpp +++ b/platform/mbed_wait_api_rtos.cpp @@ -37,13 +37,10 @@ void wait_us(int us) { int ms = us / 1000; if ((ms > 0) && core_util_are_interrupts_enabled()) { Thread::wait((uint32_t)ms); - us -= ms * 1000; } // Use busy waiting for sub-millisecond delays, or for the whole // interval if interrupts are not enabled - if (us > 0) { - while((us_ticker_read() - start) < (uint32_t)us); - } + while ((us_ticker_read() - start) < (uint32_t)us); } #endif // #if MBED_CONF_RTOS_PRESENT