Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Aug 15, 2024
1 parent c7568f3 commit 70da165
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
6 changes: 1 addition & 5 deletions esp-hal/src/i2s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2251,8 +2251,6 @@ pub mod asynch {
}

/// An in-progress async circular DMA write transfer.
#[non_exhaustive]

pub struct I2sWriteDmaTransferAsync<'d, T, CH, BUFFER>
where
T: RegisterAccess,
Expand Down Expand Up @@ -2313,7 +2311,7 @@ pub mod asynch {
/// One-shot read I2S.
async fn read_dma_async(&mut self, words: &mut [u8]) -> Result<(), Error>;

/// Continuously read frm I2S. Returns [I2sReadDmaTransferAsync]
/// Continuously read from I2S. Returns [I2sReadDmaTransferAsync]
fn read_dma_circular_async<RXBUF>(
self,
words: RXBUF,
Expand Down Expand Up @@ -2407,8 +2405,6 @@ pub mod asynch {
}

/// An in-progress async circular DMA read transfer.
#[non_exhaustive]

pub struct I2sReadDmaTransferAsync<'d, T, CH, BUFFER>
where
T: RegisterAccess,
Expand Down
20 changes: 8 additions & 12 deletions hil-test/tests/i2s_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use esp_hal::{
gpio::Io,
i2s::{asynch::*, DataFormat, I2s, I2sTx, Standard},
peripheral::Peripheral,
peripherals::{I2S0, Peripherals},
peripherals::{Peripherals, I2S0},
prelude::*,
system::SystemControl,
Async,
Expand Down Expand Up @@ -52,15 +52,7 @@ impl Iterator for SampleSource {
}

#[embassy_executor::task]
async fn writer(
tx_buffer: &'static mut [u8],
i2s_tx: I2sTx<
'static,
I2S0,
DmaChannel0,
Async
>,
) {
async fn writer(tx_buffer: &'static mut [u8], i2s_tx: I2sTx<'static, I2S0, DmaChannel0, Async>) {
let mut samples = SampleSource::new();
for b in tx_buffer.iter_mut() {
*b = samples.next().unwrap();
Expand Down Expand Up @@ -144,8 +136,8 @@ mod tests {
i2s.rx_conf().modify(|_, w| w.rx_update().set_bit());
}

spawner.must_spawn(writer(tx_buffer, i2s_tx));
let mut rx_transfer = i2s_rx.read_dma_circular_async(rx_buffer).unwrap();
spawner.must_spawn(writer(tx_buffer, i2s_tx));

let mut rcv = [0u8; BUFFER_SIZE];
let mut sample_idx = 0;
Expand All @@ -154,7 +146,11 @@ mod tests {
let len = rx_transfer.pop(&mut rcv).await.unwrap();
for &b in &rcv[..len] {
let expected = samples.next().unwrap();
assert_eq!(b, expected, "Sample #{} does not match ({} != {})", sample_idx, b, expected);
assert_eq!(
b, expected,
"Sample #{} does not match ({} != {})",
sample_idx, b, expected
);
sample_idx += 1;
}
}
Expand Down

0 comments on commit 70da165

Please sign in to comment.