Closed lhstrh closed 2 years ago
We can use nrf_pwr_mgmt_run() to sleep. It checks if SD is enabled and also enables a more low power sleep. It calls __WFE twice so I think it is expected behavior that it returns quickly first
https://devzone.nordicsemi.com/f/nordic-q-a/62079/is-there-any-setting-for-using-wfe
Great find! Does it work?
I see that Edward added a 100ms delay in the printf macro. I don't see why that is necessary. Also it really messes with the temporal behaviour.
I think this was a hack around issues that should no longer exist with our updated runtime. Let's remove it.
Update:
@lhstrh The critical change here is that we keep next() in the critical section. Edward feared that there might be some racing condition if not. the threaded c-rutime apparently implements it like that and thus it is a more safe approach for now.
Fixes #12.
Remaining issues:
Sleep sometimes gets interrupted without the scheduling of a physical action. This is not a show stopper, but we should understand why this happens.We should introduce an extra variable to track the scheduling of events, so that we can restart the timer inlf_sleep_until
instead of returning-1
. See #15.Tested solutions:
A word of caution: This PR brings in a few extra runtime files, the changes in which should find their way into the mainstream reactor-c runtime once they are mature enough to include them.