stm32/systick: Always POLL_HOOK when delaying for milliseconds.

Call MICROPY_EVENT_POLL_HOOK even on very short delays so that busy loops
that call sleep_ms still yield to events and other threads.

See related issue #5344.
This commit is contained in:
Josh Lloyd 2019-11-20 17:18:09 +13:00 committed by Damien George
parent a5221c47eb
commit 6bc50c4fa9

View File

@ -96,12 +96,12 @@ void mp_hal_delay_ms(mp_uint_t Delay) {
// IRQs enabled, so can use systick counter to do the delay // IRQs enabled, so can use systick counter to do the delay
uint32_t start = uwTick; uint32_t start = uwTick;
// Wraparound of tick is taken care of by 2's complement arithmetic. // Wraparound of tick is taken care of by 2's complement arithmetic.
while (uwTick - start < Delay) { do {
// This macro will execute the necessary idle behaviour. It may // This macro will execute the necessary idle behaviour. It may
// raise an exception, switch threads or enter sleep mode (waiting for // raise an exception, switch threads or enter sleep mode (waiting for
// (at least) the SysTick interrupt). // (at least) the SysTick interrupt).
MICROPY_EVENT_POLL_HOOK MICROPY_EVENT_POLL_HOOK
} } while (uwTick - start < Delay);
} else { } else {
// IRQs disabled, so need to use a busy loop for the delay. // IRQs disabled, so need to use a busy loop for the delay.
// To prevent possible overflow of the counter we use a double loop. // To prevent possible overflow of the counter we use a double loop.