Add typestate-based control over the PIO RX buffer access #936
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #935.
Open Questions:
StateMachine::clear_fifos
is probably not sound with a non-FIFO RX buffer. It is not fully clear according to the reference manual though.The reference manual states that enabling the PUT/GET modes will cause the joining (which
clear_fifos
uses) to be disabled, but it doesn't say what happens if you enable joining while in non-FIFO mode.My proposal to fix this is to move the
clear_fifos
method onto theRx<_>
struct and constrain it to only be available in RxFifo mode.The other option would be to actually carry the
RxFifoConfig
type state through to theStateMachine
to hide theclear_fifos
method in such cases. That can probably be done, but has implications on the state machine groups (which will also have to carry that typestate).I can do either variant, but I'd like a judgement call from the maintainers on which way to go here.
TODOs:
I will add an example which uses this feature later, as well as fix the existing example.Fixed example and added my original LED matrix code as another example.