Skip to content

Commit 7eabbe4

Browse files
RMT: Support wrapping everywhere (#4049)
* RMT: refactor async_interrupt_handler - simplification and preparation for also supporting threshold interrupts - the split into a generic async_interrupt_handler and chip_specific::handle_channel_interrupts didn't really simplify things: It avoided a little bit of repetition, at the cost of quite a bit of syntax, and was also a poor representation of the differences between chips (namely the fact that on esp32 and esp32s2, the ch_err interrupt does not differentiate rx/tx). * RMT: handle Threshold in async_interrupt_handler Preparatory work for async wrapping rx/tx. This has no effect for now, since the corresponding interrupts are never enabled. * RMT: return actual amount of data read from rx methods While not essential to parse received data, which will typically look for an end marker to determine the actual end of the data, this still appears useful. * RMT: only read up to hw pointer on final poll instead of copying some garbage to the result buffer * RMT: add CHANNEL_RAM_SIZE and SUPPORTS_WRAP constants will be helpful for HIL tests * RMT: extend check_data_eq HIL helper - handle wrapping rx (and varying device support) - fix/simplify logic around end markers - check that the rx buffer is not overwritten beyond the actually received data * RMT: impl async wrapping Tx + HIL test * RMT: add wrapping support to low-level rx methods * RMT: impl blocking wrapping rx + HIL test * RMT: impl async wrapping rx + HIL test * RMT: avoid duplicate call to clear_tx_interrupts() in start_send() which would happen for async tx * RMT: avoid duplicate call to clear_rx_interrupts() in start_receive() which would happen for async rx * RMT: on rx error, read all available data * RMT: Refactor RmtRxFuture::poll to match RmtTxFuture::poll more closely * RMT: don't hang in RmtRxFuture::drop if rx was never started this can happen if a large buffer is supplied to Channel::receive, which produces an InvalidDataLength Error and does not start rx, but still returns RmtRxFuture (which will yield an error when polled for the first time) * RMT: changelog * RMT: migration guide --------- Co-authored-by: Juraj Sadel <[email protected]>
1 parent 4a5d56d commit 7eabbe4

File tree

5 files changed

+435
-192
lines changed

5 files changed

+435
-192
lines changed

esp-hal/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4040
- `ram(reclaimed)` as an alias for `link_section = ".dram2_uninit"` (#4245)
4141
- `rmt::MAX_TX_LOOPCOUNT` and `rmt::MAX_RX_IDLE_THRESHOLD` constants have been added (#4276)
4242
- Added support for `embedded-io 0.7` (#4280)
43+
- RMT: Wrapping the hardware buffer is now supported for rx/tx and blocking/async channels (#4049)
44+
- `rmt::CHANNEL_RAM_SIZE` and `rmt::HAS_RX_WRAP` constants have been added (#4049)
4345
- A new option `ESP_HAL_CONFIG_WRITE_VEC_TABLE_MONITORING` (disabled by default) to check that no unintentional writes to a very vital memory area are made. (Only RISC-V) (#4225)
4446

4547
### Changed
@@ -82,6 +84,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8284
- RMT: `Channel::transmit_continuously` now takes an additional `LoopStop` argument. (#4260)
8385
- RMT: `LoopCount::Finite` and `ContinuousTxTransaction::is_tx_loopcount_interrupt_set` are only defined when the hardware supports it (all except ESP32). (#4260)
8486
- RMT: `Channel::transmit_continuously` now verifies that loop counts don't exceed the hardware limit (#4276)
87+
- RMT: Receive operations read only received codes instead of the entire buffer and return the number of codes read (#4049)
8588
- `esp_hal::clock::{RtcFastClock, RtcSlowClock, RtcClock}` and `esp_hal::gpio::Event` have been marked unstable (#4293)
8689

8790
### Fixed

esp-hal/MIGRATING-1.0.0-rc.0.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ The `rmt::Channel::transmit_continuously` and
175175
+let tx_trans1 = tx_channel1.transmit_continuously(&data, LoopCount::Finite(count));
176176
```
177177

178+
The receiver methods `rmt::Channel::<'_, Blocking>::receive` and
179+
`rmt::Channel::<'_, Async>::receive` now return the actual amount of data read,
180+
which may be shorter than the buffer size if the idle threshold was exceeded:
181+
182+
```diff
183+
-let channel = channel.receive(&mut buffer)?.wait().unwrap();
184+
+let (_count, channel) = channel.receive(&mut buffer)?.wait().unwrap();
185+
186+
-let () = async_channel.receive(&mut buffer).await.unwrap();
187+
+let _count = async_channel.receive(&mut buffer).await.unwrap();
188+
```
189+
178190
### RMT lifetime changes
179191

180192
The RMT driver didn't use to properly tie together lifetimes of its types and

0 commit comments

Comments
 (0)