Merge pull request #3202 from geky/fix-rtos-wait-math

Fix arithmetic error in rtos-based wait
pull/3220/head
Sam Grove 2016-11-07 10:30:33 -06:00 committed by GitHub
commit 30e63a27b7
1 changed files with 1 additions and 4 deletions

View File

@ -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