Okay, what would I actually want to await on in an embedded system?
- Timer
- This would probably be for timeouts or "scheduling".
- I could probably use groundhog for a global instance?
- I guess I could have a queue that wakes intelligently, with a fallback to polling if the queue is too long or something?
- Serial Protocol
- I guess the peripheral could be owned?
- We're probably waiting for one of two things to happen:
- Waiting for an event (e.g. peripherals, UART RX, buttons) we don't control
- Would this make sense to even handle in async context? Wait for a flag?
- Operate the entire async state machine in the interrupt context?
- Waiting for a transfer to complete (could be rx or tx, DMA basically)
- Waiting for an event (e.g. peripherals, UART RX, buttons) we don't control
Is there any other kind of thing we could be waiting for?
I guess I could see "downstream" futures/async tasks waiting on async items from other tasks
What if we made those go through channels? Then we'd still probably have to poll on the channels, or implement a waker of some kind.
I guess the problem with wakers is that they are of a variable size. I guess we could go full RTIC and have a declarative DSL that registers all wakers ahead of time?
This might be possible if we disallow dynamic task spawning. I wonder if I could make this happen in an RTIC task with message sending or something?
I need to come up with a good use case to have an axe to grind. I think the keyboard might be a really good use case, because I have buttons and LEDs and stuff, the LEDs could be doing some kind of visual pattern, but still be responsive to input?
Something like:
- Leds go through a pattern
- If there is a key input, they trigger a ripple or something?
- We have buttons that do some kind of debouncing, e.g. wait for low, wait 2ms, check again, if still low, trigger, wait for going high (with debounce?)
- Can I really have interrupt driven keys with row/scan behavior? I guess that's more polling.
- Maybe just look at one column or something so I can use interrupts still.