Description
I'm working on embedded-platform
and am targeting nrf52840
devices as the first use-case.
Currently, I'm using this code to support serial writes: https://github.com/dflemstr/embedded-platform/blob/f9ae5e7b686fdbf66ee3f172c755aea543d4c102/platforms/nrf52840/src/serial.rs#L19-L23
I haven't started on SPI/I²C/... mappings but I suspect there will be similar challenges in making the code non-blocking.
The execution model I have chosen is to have the main thread always run wfi
when there is nothing happening, and rely on interrupts to wake it up, poll a main future, and do some work, before going back to wfi
.
Ideally, the baseline behavior I would like to see is to break apart some of the blocking transactions into multiple steps. Let's look at this section for example:
This could either be modeled as an explicit state machine (e.g. an enum
) where during each state transition, there is some sort of polling method instead of a while loop. So imagine a SerialTransaction
object with a poll()
method that would eventually return a successful status.
If this approach sounds sane, I can make it into a PR.