Add busy_wait_at_leasy_cycles to host (#1925)

This commit is contained in:
Graham Sanderson 2024-09-11 18:33:33 -05:00 committed by GitHub
parent 42e234f8f3
commit 6500c59d70
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View file

@ -148,7 +148,11 @@ uint get_core_num();
static inline uint __get_current_exception(void) { static inline uint __get_current_exception(void) {
return 0; return 0;
} }
void busy_wait_at_least_cycles(uint32_t minimum_cycles);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -7,9 +7,9 @@
#include <stdio.h> #include <stdio.h>
#include "pico.h" #include "pico.h"
#include "hardware/timer.h"
PICO_WEAK_FUNCTION_DEF(tight_loop_contents) PICO_WEAK_FUNCTION_DEF(tight_loop_contents)
void PICO_WEAK_FUNCTION_IMPL_NAME(tight_loop_contents)() { void PICO_WEAK_FUNCTION_IMPL_NAME(tight_loop_contents)() {
} }
@ -45,4 +45,10 @@ void __breakpoint() {
#else #else
__builtin_trap(); __builtin_trap();
#endif #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);
}