nrf, samd: Run events at least once in mp_hal_delay_ms.#19289
Conversation
Per the docs for `time.sleep()` and `time.sleep_ms()`. This gets the `tests/micropython/schedule_sleep.py` test working when using the native emitter. Signed-off-by: Damien George <damien@micropython.org>
Per the docs for `time.sleep()` and `time.sleep_ms()`. This gets the `tests/micropython/schedule_sleep.py` test working when using the native emitter. The structure of `mp_hal_delay_ms()` matches the rp2 port. Signed-off-by: Damien George <damien@micropython.org>
3d97bbb to
a4a422a
Compare
|
Code size report: |
robert-hh
left a comment
There was a problem hiding this comment.
The code looks fine (obviously). Built and tested with SAMD ITSYBITSY M0 and M4, Micro.Bit and Arduino Nano 33 BLE. All but Micro.Bit tested with micropython/schedule_sleep.py. Micro.Bit tested with extmod/time_ms_us.py.
The additional test in the NRF port for ms == 0 is interesting. I'm not sure whether this is obsolete or helpful. At least, that way a minimal wait time until the next event is avoided.
|
Thanks for the quick review!
Yes, that bit of code has been there from the beginning and wasn't strictly necessary prior to the change in this PR. But now, the code needs a way to do 0-delay but still check events, and this explicit test is necessary. To make nrf more like samd (and rp2) it would first need to be converted to the new event system. |
Summary
Per the docs for
time.sleep()andtime.sleep_ms(), events must be run at least once inmp_hal_delay_ms().This gets the
tests/micropython/schedule_sleep.pytest working when using the native emitter.Testing
Tested on ARDUINO_NANO_33_BLE_SENSE (nrf) and ADAFRUIT_ITSYBITSY_M0_EXPRESS (samd), using:
It now passes instead of locking up.
Existing tests still pass OK.
Generative AI
Not used.