Skip to content

Commit 6500c59

Browse files
authored
Add busy_wait_at_leasy_cycles to host (#1925)
1 parent 42e234f commit 6500c59

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/host/pico_platform/include/pico/platform.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ uint get_core_num();
148148

149149
static inline uint __get_current_exception(void) {
150150
return 0;
151+
151152
}
153+
154+
void busy_wait_at_least_cycles(uint32_t minimum_cycles);
155+
152156
#ifdef __cplusplus
153157
}
154158
#endif

src/host/pico_platform/platform_base.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#include <stdio.h>
88

99
#include "pico.h"
10+
#include "hardware/timer.h"
1011

1112
PICO_WEAK_FUNCTION_DEF(tight_loop_contents)
12-
1313
void PICO_WEAK_FUNCTION_IMPL_NAME(tight_loop_contents)() {
1414

1515
}
@@ -45,4 +45,10 @@ void __breakpoint() {
4545
#else
4646
__builtin_trap();
4747
#endif
48-
}
48+
}
49+
50+
PICO_WEAK_FUNCTION_DEF(busy_wait_at_least_cycles)
51+
void PICO_WEAK_FUNCTION_IMPL_NAME(busy_wait_at_least_cycles)(uint32_t cycles) {
52+
// fairly arbitrary; we'll use 125Mhz as a reference
53+
busy_wait_us((cycles + 124)/125);
54+
}

0 commit comments

Comments
 (0)