Merge pull request #9896 from kfnta/wait_us_no_usticker

wait_us without usticker
pull/9914/head
Martin Kojtal 2019-03-14 09:44:25 +01:00 committed by GitHub
commit 943254c78c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -37,9 +37,19 @@ void wait_ms(int ms)
void wait_us(int us)
{
#if DEVICE_USTICKER
const ticker_data_t *const ticker = get_us_ticker_data();
uint32_t start = ticker_read(ticker);
while ((ticker_read(ticker) - start) < (uint32_t)us);
#else // fallback to wait_ns for targets without usticker
while (us > 1000) {
us -= 1000;
wait_ns(1000000);
}
if (us > 0) {
wait_ns(us * 1000);
}
#endif // DEVICE_USTICKER
}
#endif // #ifndef MBED_CONF_RTOS_PRESENT