File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,24 +51,17 @@ void HAL_Delay(uint32_t Delay) {
5151}
5252
5353// Core delay function that does an efficient sleep and may switch thread context.
54- // Note: Upon entering this function we may or may not have the GIL.
54+ // If IRQs are enabled then we must have the GIL.
5555void mp_hal_delay_ms (mp_uint_t Delay ) {
5656 if (query_irq () == IRQ_STATE_ENABLED ) {
5757 // IRQs enabled, so can use systick counter to do the delay
5858 uint32_t start = uwTick ;
5959 // Wraparound of tick is taken care of by 2's complement arithmetic.
6060 while (uwTick - start < Delay ) {
61- // Enter sleep mode, waiting for (at least) the SysTick interrupt.
62- mp_handle_pending ();
63- #if MICROPY_PY_THREAD
64- if (pyb_thread_enabled ) {
65- pyb_thread_yield ();
66- } else {
67- __WFI ();
68- }
69- #else
70- __WFI ();
71- #endif
61+ // This macro will execute the necessary idle behaviour. It may
62+ // raise an exception, switch threads or enter sleep mode (waiting for
63+ // (at least) the SysTick interrupt).
64+ MICROPY_EVENT_POLL_HOOK
7265 }
7366 } else {
7467 // IRQs disabled, so need to use a busy loop for the delay.
You can’t perform that action at this time.
0 commit comments