From 1331c47c9e2ed9c0b42a9978a8996015e412c900 Mon Sep 17 00:00:00 2001 From: Graham Sanderson Date: Mon, 13 Feb 2023 15:22:03 -0600 Subject: [PATCH] Add missing busy_wait_ms functino to host platform (#1254) --- src/host/hardware_timer/timer.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/host/hardware_timer/timer.c b/src/host/hardware_timer/timer.c index 3cb81387b..3ae825e36 100644 --- a/src/host/hardware_timer/timer.c +++ b/src/host/hardware_timer/timer.c @@ -13,7 +13,7 @@ #endif // in our case not a busy wait -PICO_WEAK_FUNCTION_DEF(busy_wait_us) +PICO_WEAK_FUNCTION_DEF(busy_wait_us_32) void PICO_WEAK_FUNCTION_IMPL_NAME(busy_wait_us_32)(uint32_t delay_us) { #if defined(__unix__) || defined(__APPLE__) usleep(delay_us); @@ -21,6 +21,7 @@ void PICO_WEAK_FUNCTION_IMPL_NAME(busy_wait_us_32)(uint32_t delay_us) { assert(false); #endif } + PICO_WEAK_FUNCTION_DEF(busy_wait_us) void PICO_WEAK_FUNCTION_IMPL_NAME(busy_wait_us)(uint64_t delay_us) { absolute_time_t t; @@ -28,6 +29,15 @@ void PICO_WEAK_FUNCTION_IMPL_NAME(busy_wait_us)(uint64_t delay_us) { busy_wait_until(t); } +PICO_WEAK_FUNCTION_DEF(busy_wait_ms) +void PICO_WEAK_FUNCTION_IMPL_NAME(busy_wait_ms)(uint32_t delay_ms) { +#if defined(__unix__) || defined(__APPLE__) + usleep(delay_ms * 1000); +#else + assert(false); +#endif +} + // this may or may not wrap PICO_WEAK_FUNCTION_DEF(time_us_64) uint64_t PICO_WEAK_FUNCTION_IMPL_NAME(time_us_64)() {