Skip to content

Commit

Permalink
Add missing busy_wait_ms functino to host platform (#1254)
Browse files Browse the repository at this point in the history
  • Loading branch information
kilograham authored Feb 13, 2023
1 parent c2af4e8 commit 1331c47
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/host/hardware_timer/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,31 @@
#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);
#else
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;
update_us_since_boot(&t, time_us_64() + 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)() {
Expand Down

0 comments on commit 1331c47

Please sign in to comment.