From 188b73f98351987268feb1ac50af9764e513e464 Mon Sep 17 00:00:00 2001 From: Martin Kojtal <--global> Date: Tue, 27 Jul 2021 12:49:28 +0100 Subject: [PATCH] rtos: fix delay with 0 Fixes error osErrorParameter that triggers our assert. RTX delay ignored 0 previously, it now returns osErrorParameter instead. --- rtos/source/ThisThread.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rtos/source/ThisThread.cpp b/rtos/source/ThisThread.cpp index b5c00372d750..8b8bf3b5ba4b 100644 --- a/rtos/source/ThisThread.cpp +++ b/rtos/source/ThisThread.cpp @@ -221,9 +221,12 @@ void ThisThread::sleep_for(uint32_t millisec) void ThisThread::sleep_for(Clock::duration_u32 rel_time) { #if MBED_CONF_RTOS_PRESENT - osStatus_t status = osDelay(rel_time.count()); - MBED_ASSERT(status == osOK); - (void) status; + uint32_t delay = rel_time.count(); + if (delay != 0) { + osStatus_t status = osDelay(delay); + MBED_ASSERT(status == osOK); + (void) status; + } #else thread_sleep_for(rel_time.count()); #endif