Skip to content

Commit

Permalink
Migrate PARL_IO driver to newer DMA API (#3033)
Browse files Browse the repository at this point in the history
* Migrate PARL_IO driver to newer DMA API

* Register waker when necessary

* Basic HIL test

* fmt

* oops

* return resources on error

* Invert sampling edge

* Attempt manual formatting

---------

Co-authored-by: Dominic Fischer <[email protected]>
  • Loading branch information
Dominaezzz and Dominic Fischer authored Feb 3, 2025
1 parent 8ba212c commit fe53061
Show file tree
Hide file tree
Showing 7 changed files with 514 additions and 287 deletions.
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Rng` and `Trng` now implement `Peripheral<P = Self>` (#2992)
- SPI, UART, I2C: `with_<pin>` functions of peripheral drivers now disconnect the previously assigned pins from the peripheral. (#3012)
- SPI, UART, I2C: Dropping a driver now disconnects pins from their peripherals. (#3012)
- Migrate PARL_IO driver to DMA move API (#3033)
- `Async` drivers are no longer `Send` (#2980)
- GPIO drivers now take configuration structs (#2990, #3029)
- `flip-link` feature is now a config option (`ESP_HAL_CONFIG_FLIP_LINK`) (#3001)
Expand Down
29 changes: 29 additions & 0 deletions esp-hal/MIGRATING-0.23.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,35 @@ config/config.toml
+ ESP_HAL_CONFIG_PSRAM_MODE = "octal"
```

## PARL_IO changes
Parallel IO now uses the newer DMA Move API.

Changes on the TX side
```diff
let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, 32000);
+ let mut dma_tx_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap();

- let transfer = parl_io_tx.write_dma(&tx_buffer).unwrap();
- transfer.wait().unwrap();
+ let transfer = parl_io_tx.write(dma_tx_buf.len(), dma_tx_buf).unwrap();
+ (result, parl_io_tx, dma_tx_buf) = transfer.wait();
+ result.unwrap();
```

Changes on the RX side
```diff
let (rx_buffer, rx_descriptors, _, _) = dma_buffers!(32000, 0);
+ let mut dma_rx_buf = DmaRxBuf::new(rx_descriptors, rx_buffer).unwrap();
- let transfer = parl_io_rx.read_dma(&mut rx_buffer).unwrap();
- transfer.wait().unwrap();
+ let transfer = parl_io_rx.read(Some(dma_rx_buf.len()), dma_rx_buf).unwrap();
+ (_, parl_io_rx, dma_rx_buf) = transfer.wait();
```

On the RX side, the `EofMode` is now decided at transfer time, rather than config time.
- `EofMode::ByteLen` -> `Some(<number of bytes to receive>)`
- `EofMode::EnableSignal` -> `None`

## GPIO changes

GPIO drivers now take configuration structs.
Expand Down
Loading

0 comments on commit fe53061

Please sign in to comment.