Skip to content
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

Fix I2S examples #2139

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions esp-hal/MIGRATING-0.20.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ To avoid confusion with the `Rtc::current_time` wall clock time APIs, we've rena

## RX/TX Order

Previously, our API was pretty inconsitent with the RX/TX ordering, and different peripherals had different order. Now, all
the peripherals use rx-tx. Make sure your methods are expecting the rigth RX/TX order, for example an SPI DMA app should be updated to:
Previously, our API was pretty inconsistent with the RX/TX ordering, and different peripherals had different order. Now, all
the peripherals use rx-tx. Make sure your methods are expecting the right RX/TX order, for example an SPI DMA app should be updated to:

```diff
- let (tx_buffer, tx_descriptors, rx_buffer, rx_descriptors) = dma_buffers!(4);
Expand All @@ -103,6 +103,13 @@ let dma_rx_buf = DmaRxBuf::new(rx_descriptors, rx_buffer).unwrap();
.unwrap();
```

When using the asymmetric variant of the macro to create DMA buffers and descriptors make sure to swap the order of parameters

```diff
- let (tx_buffer, tx_descriptors, _, _) = dma_buffers!(32000, 0);
+ let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, 32000);
```

## Removed UART constructors

The `Uart::new_with_default_pins` and `Uart::new_async_with_default_pins` constructors
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/embassy_i2s_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async fn main(_spawner: Spawner) {
#[cfg(not(any(feature = "esp32", feature = "esp32s2")))]
let dma_channel = dma.channel0;

let (rx_buffer, rx_descriptors, _, tx_descriptors) = dma_buffers!(0, 4092 * 4);
let (rx_buffer, rx_descriptors, _, tx_descriptors) = dma_buffers!(4092 * 4, 0);

let i2s = I2s::new(
peripherals.I2S0,
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/embassy_i2s_sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async fn main(_spawner: Spawner) {
#[cfg(not(any(feature = "esp32", feature = "esp32s2")))]
let dma_channel = dma.channel0;

let (_, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(32000, 0);
let (_, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(0, 32000);

let i2s = I2s::new(
peripherals.I2S0,
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/embassy_parl_io_rx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async fn main(_spawner: Spawner) {

let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);

let (rx_buffer, rx_descriptors, _, _) = dma_buffers!(0, 32000);
let (rx_buffer, rx_descriptors, _, _) = dma_buffers!(32000, 0);

let dma = Dma::new(peripherals.DMA);
let dma_channel = dma.channel0;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/embassy_parl_io_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async fn main(_spawner: Spawner) {

let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);

let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(32000, 0);
let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, 32000);

let dma = Dma::new(peripherals.DMA);
let dma_channel = dma.channel0;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/i2s_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn main() -> ! {
#[cfg(not(any(feature = "esp32", feature = "esp32s2")))]
let dma_channel = dma.channel0;

let (mut rx_buffer, rx_descriptors, _, tx_descriptors) = dma_buffers!(0, 4 * 4092);
let (mut rx_buffer, rx_descriptors, _, tx_descriptors) = dma_buffers!(4 * 4092, 0);

// Here we test that the type is
// 1) reasonably simple (or at least this will flag changes that may make it
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/i2s_sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn main() -> ! {
#[cfg(not(any(feature = "esp32", feature = "esp32s2")))]
let dma_channel = dma.channel0;

let (_, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(32000, 0);
let (_, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(0, 32000);

let i2s = I2s::new(
peripherals.I2S0,
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/lcd_cam_ov2640.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn main() -> ! {
let dma = Dma::new(peripherals.DMA);
let channel = dma.channel0;

let (rx_buffer, rx_descriptors, _, _) = dma_buffers!(0, 32678);
let (rx_buffer, rx_descriptors, _, _) = dma_buffers!(32678, 0);

let channel = channel.configure(false, DmaPriority::Priority0);

Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/lcd_i8080.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() -> ! {
let dma = Dma::new(peripherals.DMA);
let channel = dma.channel0;

let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(32678, 0);
let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, 32678);

let channel = channel.configure(false, DmaPriority::Priority0);

Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/parl_io_rx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() -> ! {

let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);

let (rx_buffer, rx_descriptors, _, _) = dma_buffers!(0, 32000);
let (rx_buffer, rx_descriptors, _, _) = dma_buffers!(32000, 0);

let dma = Dma::new(peripherals.DMA);
let dma_channel = dma.channel0;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/parl_io_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() -> ! {

let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);

let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(32000, 0);
let (_, _, tx_buffer, tx_descriptors) = dma_buffers!(0, 32000);

let dma = Dma::new(peripherals.DMA);
let dma_channel = dma.channel0;
Expand Down
2 changes: 1 addition & 1 deletion examples/src/bin/qspi_flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ fn main() -> ! {
}
}

let (rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(256, 320);
let (rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(320, 256);
let mut dma_rx_buf = DmaRxBuf::new(rx_descriptors, rx_buffer).unwrap();
let mut dma_tx_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap();

Expand Down