Skip to content

Commit 30e63a2

Browse files
authored
Merge pull request #3202 from geky/fix-rtos-wait-math
Fix arithmetic error in rtos-based wait
2 parents e011341 + 4d6afcd commit 30e63a2

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

platform/mbed_wait_api_rtos.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,10 @@ void wait_us(int us) {
3737
int ms = us / 1000;
3838
if ((ms > 0) && core_util_are_interrupts_enabled()) {
3939
Thread::wait((uint32_t)ms);
40-
us -= ms * 1000;
4140
}
4241
// Use busy waiting for sub-millisecond delays, or for the whole
4342
// interval if interrupts are not enabled
44-
if (us > 0) {
45-
while((us_ticker_read() - start) < (uint32_t)us);
46-
}
43+
while ((us_ticker_read() - start) < (uint32_t)us);
4744
}
4845

4946
#endif // #if MBED_CONF_RTOS_PRESENT

0 commit comments

Comments
 (0)