Skip to content

RMT: Refactor state checks, support non-blocking poll on blocking transactions #3716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

wisp3rwind
Copy link
Contributor

@wisp3rwind wisp3rwind commented Jun 28, 2025

Thank you for your contribution!

We appreciate the time and effort you've put into this pull request.
To help us review it efficiently, please ensure you've gone through the following checklist:

Submission Checklist 📝

  • I have updated existing examples or added new ones (if applicable).
  • I have used cargo xtask fmt-packages command to ensure that all changed code is formatted correctly.
  • My changes were added to the CHANGELOG.md in the proper section.
  • I have added necessary changes to user code to the Migration Guide.
  • My changes are in accordance to the esp-rs developer guidelines

Extra:

Pull Request Details 📖

This refactors accesses to hardware state flags to avoid unnecessarily repeated volatile reads. Additionally, by using match statements, the resulting code becomes more idiomatic and better exposes the similarities of blocking and async code. Finally, this PR add non-blocking poll methods to blocking transactions, which are quite similar to their async equivalent. They enable proper interleaving of such transactions with other work. This is currently only relevant for tx due to the lack of wrapping rx support, but the latter will also be added as part of #3509.

Except for the new methods, there should be no user-facing changes, hence no need for adding to the migration guide.

This should be easiest to review commit-by-commit while ignoring whitespace changes; see individual commit messages for more details on the rationale for some changes.

In the last commit, I removed the now unused low-level state getters. Does this seem reasonable to you, or should they be kept in case they'll be needed again? (FWIW, I'm not using them anywhere in #3509.)

Part of #3509.

Closes #3184
Closes #1749
(Not completely sure about both of these issues since they don't describe their use case in a lot of detail, but this does enable non-blocking operations.)

Testing

HIL tests on esp32c3, in addition to testing as part of #3509.

Unused right now; these methods allow to look at all flags without several
volatile reads (in contrast to calling is_tx_done/is_rx_done,
is_tx_threshold_set, is_error individually). `match`ing on their result
leads to very idiomatic code, and also result in blocking and async code
that is very similar.

The #[inline] attribute might not be required, but better be sure: We
really don't want the Option<Event> to actually be constructed, but
rather that the compiler completely optimized it away in favor of direct
bit tests in the calling function.
by avoiding repeated register reads
this allows properly interleaving several such transactions (as the HIL
loopback tests do, in fact) or other work
Their use has entirely be replaced by get_tx_status and get_rx_status
Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo it can land with poll publicly documented. Please also add a changelog entry.

//
// Returns whether transmission has ended (whether successfully or with an
// error). In that case, a subsequent call to `wait()` returns immediately.
#[doc(hidden)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rmt is unstable so wee can make this public, even if it's not ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RMT - Access to .is_done on SingleShotTxTransaction RMT API no wait
4 participants