|
22 | 22 | extern volatile uint32_t pbdrv_clock_ticks; |
23 | 23 |
|
24 | 24 | // Core delay function that does an efficient sleep and may switch thread context. |
25 | | -// If IRQs are enabled then we must have the GIL. |
| 25 | +// We must have the GIL. |
26 | 26 | void mp_hal_delay_ms(mp_uint_t Delay) { |
27 | | - if (pbdrv_clock_is_ticking()) { |
28 | | - // IRQs enabled, so can use systick counter to do the delay |
29 | | - uint32_t start = pbdrv_clock_ticks; |
30 | | - // Wraparound of tick is taken care of by 2's complement arithmetic. |
31 | | - do { |
32 | | - // This macro will execute the necessary idle behaviour. It may |
33 | | - // raise an exception, switch threads or enter sleep mode (waiting for |
34 | | - // (at least) the SysTick interrupt). |
35 | | - MICROPY_EVENT_POLL_HOOK |
36 | | - } while (pbdrv_clock_ticks - start < Delay); |
37 | | - } else { |
38 | | - // IRQs disabled, so need to use a busy loop for the delay. |
39 | | - pbdrv_clock_busy_delay_ms(Delay); |
40 | | - } |
| 27 | + // Use systick counter to do the delay |
| 28 | + uint32_t start = pbdrv_clock_ticks; |
| 29 | + // Wraparound of tick is taken care of by 2's complement arithmetic. |
| 30 | + do { |
| 31 | + // This macro will execute the necessary idle behaviour. It may |
| 32 | + // raise an exception, switch threads or enter sleep mode (waiting for |
| 33 | + // (at least) the SysTick interrupt). |
| 34 | + MICROPY_EVENT_POLL_HOOK |
| 35 | + } while (pbdrv_clock_ticks - start < Delay); |
41 | 36 | } |
42 | 37 |
|
43 | 38 | uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags) { |
|
0 commit comments