Skip to content

Commit 80a4f63

Browse files
committed
rp2/cyw43_configport: Make cyw43_delay_ms() a busy loop.
Currently, `cyw43_delay_ms()` calls `mp_hal_delay_ms()` which uses PendSV to set up a timer and wait for an interrupt, using wfe. But in the cyw43 initialisation stage PendSV is disabled and so this delay suspends on the wfe instruction for an indefinite amount of time. Work around this by changing the implementation of `cyw43_delay_ms()` to a busy loop. Fixes issue micropython#15220. Signed-off-by: Damien George <[email protected]>
1 parent 3c8089d commit 80a4f63

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Diff for: ports/rp2/cyw43_configport.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,12 @@ static inline void cyw43_delay_us(uint32_t us) {
117117
}
118118

119119
static inline void cyw43_delay_ms(uint32_t ms) {
120-
mp_hal_delay_ms(ms);
120+
// PendSV may be disabled via CYW43_THREAD_ENTER, so this delay is a busy loop.
121+
uint32_t us = ms * 1000;
122+
uint32_t start = mp_hal_ticks_us();
123+
while (mp_hal_ticks_us() - start < us) {
124+
mp_event_handle_nowait();
125+
}
121126
}
122127

123128
#define CYW43_EVENT_POLL_HOOK mp_event_handle_nowait()

0 commit comments

Comments
 (0)