-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
stm32: Convert port to use new event waiting functions. #18679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
stm32: Convert port to use new event waiting functions. #18679
Conversation
Signed-off-by: Damien George <damien@micropython.org>
|
@iabdalkader FYI |
|
Code size report: |
|
Thanks! I call |
I've used |
This depends on the tick rate. In practice, it waits for the next IRQ, whenever that occurs, since the timeout is ignored. Perhaps this is what confused me: #define MICROPY_INTERNAL_WFE(TIMEOUT_MS) __WFI()Technically, all of those are indefinite waits (
I checked Alif port, and this is how it's implemented: #define MICROPY_INTERNAL_WFE(TIMEOUT_MS) \
do { \
if ((TIMEOUT_MS) < 0) { \
__WFE(); \
} else { \
system_tick_wfe_with_timeout_us(TIMEOUT_MS * 1000); \
} \
} while (0)You were right to push back on updating this, it is tricky. At some point in the future, you may want to switch to a timer for stm32 port. This would also fix #17947 |
The stm32 port is designed around the assumption that SysTick is the highest priority IRQ and runs at 1kHz. So a
Yes, I tried to make the alif port "better" than stm32 in this regard, by being tickless. Eventually I want to make the stm32 port tickless but it's a lot of work, as seen here. |
Summary
Convert the stm32 port from the old
MICROPY_EVENT_POLL_HOOKmacro to use the newmp_event_wait_xxx()functions in conjunction withMICROPY_INTERNAL_WFE.This change should be functionally equivalent to the existing behaivour because
mp_event_wait_ms()andmp_event_wait_indefinite()are equal tomp_handle_pending(true); __WFI();, which is whatMICROPY_EVENT_POLL_HOOKwas.Testing
Tested on PYBD_SF6 running the test suite.
Trade-offs and Alternatives
The stm32 port doesn't have the ability to "wait for event" for an extended period of time, it only has
wfi. So that's all that is used forMICROPY_INTERNAL_WFE, similar to the renesas-ra port.The
CYW43_EVENT_POLL_HOOKmacro needed to be overridden, otherwise it would just callmp_event_handle_nowait()which would create power hungry busy loops.