Skip to content

Commit 276ef91

Browse files
Michael Schwarcz0xc0170
authored andcommitted
wait_us using wait_ns
1 parent 7ed16fb commit 276ef91

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

platform/mbed_wait_api_no_rtos.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,19 @@ void wait_ms(int ms)
3737

3838
void wait_us(int us)
3939
{
40+
#if DEVICE_USTICKER
4041
const ticker_data_t *const ticker = get_us_ticker_data();
4142
uint32_t start = ticker_read(ticker);
4243
while ((ticker_read(ticker) - start) < (uint32_t)us);
44+
#else // fallback to wait_ns for targets without usticker
45+
while (us > 1000) {
46+
us -= 1000;
47+
wait_ns(1000000);
48+
}
49+
if (us > 0) {
50+
wait_ns(us * 1000);
51+
}
52+
#endif // DEVICE_USTICKER
4353
}
4454

4555
#endif // #ifndef MBED_CONF_RTOS_PRESENT

0 commit comments

Comments
 (0)