Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ports/nrf/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,13 @@ void mp_hal_delay_us(mp_uint_t us) {
void mp_hal_delay_ms(mp_uint_t ms) {
uint32_t now;
if (ms == 0) {
mp_handle_pending(MP_HANDLE_PENDING_CALLBACKS_AND_EXCEPTIONS);
return;
}
now = mp_hal_ticks_ms();
while (mp_hal_ticks_ms() - now < ms) {
do {
MICROPY_EVENT_POLL_HOOK
}
} while (mp_hal_ticks_ms() - now < ms);
}

#else
Expand Down
8 changes: 5 additions & 3 deletions ports/samd/mphalport.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ void mp_hal_clr_pin_mux(mp_hal_pin_obj_t pin) {

void mp_hal_delay_ms(mp_uint_t ms) {
uint32_t t0 = systick_ms;
while (systick_ms - t0 < ms) {
mp_event_wait_ms(1);
}
uint32_t elapsed = 0;
do {
mp_event_wait_ms(ms - elapsed);
elapsed = systick_ms - t0;
} while (elapsed < ms);
}

void mp_hal_delay_us(mp_uint_t us) {
Expand Down
7 changes: 6 additions & 1 deletion ports/samd/mphalport.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@
#define MICROPY_PY_PENDSV_EXIT restore_irq_pri(atomic_state)

// Port level Wait-for-Event macro.
#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) __WFE()
#define MICROPY_INTERNAL_WFE(TIMEOUT_MS) \
do { \
if (TIMEOUT_MS != 0) { \
__WFE(); \
} \
} while (0)

#define MICROPY_HW_USB_CDC_TX_TIMEOUT (500)

Expand Down
Loading