icyphy / lf-buckler

Programming an nRF embedded board with a Berkeley Buckler daughter card using Lingua Franca.
BSD 2-Clause "Simplified" License
7 stars 0 forks source link

Support for scheduling physical actions #14

Closed lhstrh closed 2 years ago

lhstrh commented 2 years ago

Fixes #12.

Remaining issues:

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.

erlingrj commented 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

lhstrh commented 2 years ago

Great find! Does it work?

erlingrj commented 2 years ago

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.

lhstrh commented 2 years ago

I think this was a hack around issues that should no longer exist with our updated runtime. Let's remove it.

erlingrj commented 2 years ago

Update:

  1. Removed the 100ms delay
  2. Moved to nrf_pwr_mgmt which works.
  3. Overflow timer should trigger at t=0x00 not t=0xffffffff
erlingrj commented 2 years ago

@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.