Skip to content

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.

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.

@wisp3rwind
Copy link
Contributor Author

Rebased on main, removed #[doc(hidden)] and restored the changelog entry. The CI failure for esp32s3 looks spurious, the RMT tests succeed and the failure is related to BLE.

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.

Regarding the implementation of the place_rmt_driver_in_ram feature for these
methods, note that `#[ram]` implies `[inline(never)]`.

Thus, this uses `#[inline(always)]` for `poll` and `wait` in that case,
which are rather simple methods.
If putting them in ram actually matters, the calling user code should
probably be placed in ram as well, and then, forced inlining of both
methods should have the desired effect.

`poll_internal` in turn
- contains more code and is called from `poll` and `wait`
	-> it seems sensible that it is not inlined to reduce code size.
- includes the hot loop that copies to the hardware buffer
	-> should be forced to ram
so `#[ram]` makes sense.

Note that none of this was benchmarked.
Their use has entirely be replaced by get_tx_status and get_rx_status
@bugadani bugadani added this pull request to the merge queue Jul 30, 2025
Merged via the queue into esp-rs:main with commit 3c21662 Jul 30, 2025
29 of 30 checks passed
@wisp3rwind wisp3rwind mentioned this pull request Aug 13, 2025
13 tasks
@wisp3rwind wisp3rwind mentioned this pull request Sep 25, 2025
6 tasks
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