Skip to content

Commit

Permalink
rtos: fix delay with 0
Browse files Browse the repository at this point in the history
Fixes error osErrorParameter that triggers our assert.
RTX delay ignored 0 previously, it now returns osErrorParameter instead.
  • Loading branch information
Martin Kojtal committed Jul 29, 2021
1 parent 8538a59 commit 188b73f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rtos/source/ThisThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 188b73f

Please sign in to comment.