Skip to content

Commit

Permalink
Add busy_wait_at_leasy_cycles to host
Browse files Browse the repository at this point in the history
  • Loading branch information
kilograham committed Sep 11, 2024
1 parent 0ed2840 commit cefa87e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/host/pico_platform/include/pico/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ uint get_core_num();

static inline uint __get_current_exception(void) {
return 0;

}

void busy_wait_at_least_cycles(uint32_t minimum_cycles);

#ifdef __cplusplus
}
#endif
Expand Down
10 changes: 8 additions & 2 deletions src/host/pico_platform/platform_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <stdio.h>

#include "pico.h"
#include "hardware/timer.h"

PICO_WEAK_FUNCTION_DEF(tight_loop_contents)

void PICO_WEAK_FUNCTION_IMPL_NAME(tight_loop_contents)() {

}
Expand Down Expand Up @@ -45,4 +45,10 @@ void __breakpoint() {
#else
__builtin_trap();
#endif
}
}

PICO_WEAK_FUNCTION_DEF(busy_wait_at_least_cycles)
void PICO_WEAK_FUNCTION_IMPL_NAME(busy_wait_at_least_cycles)(uint32_t cycles) {
// fairly arbitrary; we'll use 125Mhz as a reference
busy_wait_us((cycles + 124)/125);
}

0 comments on commit cefa87e

Please sign in to comment.