Fix and enable I2S tests on ESP32-S2 (#2181)
* Fix PDMA channels, use peripheral signal instead of external connection * Fix i2s test setup for esp32s2
This commit is contained in:
parent
344ee133bc
commit
d9532bbba7
@ -3,7 +3,7 @@
|
|||||||
//! This test uses I2S TX to transmit known data to I2S RX (forced to slave mode
|
//! This test uses I2S TX to transmit known data to I2S RX (forced to slave mode
|
||||||
//! with loopback mode enabled). It's using circular DMA mode
|
//! with loopback mode enabled). It's using circular DMA mode
|
||||||
|
|
||||||
//% CHIPS: esp32c3 esp32c6 esp32s3 esp32h2
|
//% CHIPS: esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -52,12 +52,19 @@ mod tests {
|
|||||||
fn test_i2s_loopback() {
|
fn test_i2s_loopback() {
|
||||||
let peripherals = esp_hal::init(esp_hal::Config::default());
|
let peripherals = esp_hal::init(esp_hal::Config::default());
|
||||||
|
|
||||||
let mut io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
|
let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
|
||||||
|
|
||||||
let delay = Delay::new();
|
let delay = Delay::new();
|
||||||
|
|
||||||
let dma = Dma::new(peripherals.DMA);
|
let dma = Dma::new(peripherals.DMA);
|
||||||
let dma_channel = dma.channel0;
|
|
||||||
|
cfg_if::cfg_if! {
|
||||||
|
if #[cfg(any(esp32, esp32s2))] {
|
||||||
|
let dma_channel = dma.i2s0channel;
|
||||||
|
} else {
|
||||||
|
let dma_channel = dma.channel0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let (mut rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(16000, 16000);
|
let (mut rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(16000, 16000);
|
||||||
|
|
||||||
@ -71,7 +78,9 @@ mod tests {
|
|||||||
tx_descriptors,
|
tx_descriptors,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (dout, din) = hil_test::common_test_pins!(io);
|
let (_, dout) = hil_test::common_test_pins!(io);
|
||||||
|
|
||||||
|
let din = dout.peripheral_input();
|
||||||
|
|
||||||
let mut i2s_tx = i2s
|
let mut i2s_tx = i2s
|
||||||
.i2s_tx
|
.i2s_tx
|
||||||
@ -90,15 +99,18 @@ mod tests {
|
|||||||
// enable loopback testing
|
// enable loopback testing
|
||||||
unsafe {
|
unsafe {
|
||||||
let i2s = esp_hal::peripherals::I2S0::steal();
|
let i2s = esp_hal::peripherals::I2S0::steal();
|
||||||
i2s.tx_conf().modify(|_, w| w.sig_loopback().set_bit());
|
cfg_if::cfg_if! {
|
||||||
|
if #[cfg(esp32s2)] {
|
||||||
|
i2s.conf().modify(|_, w| w.sig_loopback().set_bit());
|
||||||
|
i2s.conf().modify(|_, w| w.rx_slave_mod().set_bit());
|
||||||
|
} else {
|
||||||
|
i2s.tx_conf().modify(|_, w| w.sig_loopback().set_bit());
|
||||||
|
i2s.rx_conf().modify(|_, w| w.rx_slave_mod().set_bit());
|
||||||
|
|
||||||
i2s.rx_conf().modify(|_, w| w.rx_slave_mod().set_bit());
|
i2s.tx_conf().modify(|_, w| w.tx_update().set_bit());
|
||||||
|
i2s.rx_conf().modify(|_, w| w.rx_update().set_bit());
|
||||||
i2s.tx_conf().modify(|_, w| w.tx_update().clear_bit());
|
}
|
||||||
i2s.tx_conf().modify(|_, w| w.tx_update().set_bit());
|
}
|
||||||
|
|
||||||
i2s.rx_conf().modify(|_, w| w.rx_update().clear_bit());
|
|
||||||
i2s.rx_conf().modify(|_, w| w.rx_update().set_bit());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut samples = SampleSource::new();
|
let mut samples = SampleSource::new();
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
//! This test uses I2S TX to transmit known data to I2S RX (forced to slave mode
|
//! This test uses I2S TX to transmit known data to I2S RX (forced to slave mode
|
||||||
//! with loopback mode enabled). It's using circular DMA mode
|
//! with loopback mode enabled). It's using circular DMA mode
|
||||||
|
|
||||||
//% CHIPS: esp32c3 esp32c6 esp32s3 esp32h2
|
//% CHIPS: esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
//% FEATURES: generic-queue
|
//% FEATURES: generic-queue
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
@ -20,11 +20,8 @@ use esp_hal::{
|
|||||||
use hil_test as _;
|
use hil_test as _;
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(any(
|
if #[cfg(any(esp32, esp32s2))] {
|
||||||
feature = "esp32",
|
use esp_hal::dma::I2s0DmaChannel as DmaChannel0;
|
||||||
feature = "esp32s2",
|
|
||||||
))] {
|
|
||||||
use esp_hal::dma::Spi2DmaChannel as DmaChannel0;
|
|
||||||
} else {
|
} else {
|
||||||
use esp_hal::dma::DmaChannel0;
|
use esp_hal::dma::DmaChannel0;
|
||||||
}
|
}
|
||||||
@ -95,13 +92,13 @@ mod tests {
|
|||||||
|
|
||||||
let peripherals = esp_hal::init(esp_hal::Config::default());
|
let peripherals = esp_hal::init(esp_hal::Config::default());
|
||||||
|
|
||||||
let mut io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
|
let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
|
||||||
|
|
||||||
let dma = Dma::new(peripherals.DMA);
|
let dma = Dma::new(peripherals.DMA);
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
cfg_if::cfg_if! {
|
||||||
if #[cfg(any(feature = "esp32", feature = "esp32s2"))] {
|
if #[cfg(any(esp32, esp32s2))] {
|
||||||
let dma_channel = dma.spi2channel;
|
let dma_channel = dma.i2s0channel;
|
||||||
} else {
|
} else {
|
||||||
let dma_channel = dma.channel0;
|
let dma_channel = dma.channel0;
|
||||||
}
|
}
|
||||||
@ -120,7 +117,9 @@ mod tests {
|
|||||||
tx_descriptors,
|
tx_descriptors,
|
||||||
);
|
);
|
||||||
|
|
||||||
let (dout, din) = hil_test::common_test_pins!(io);
|
let (_, dout) = hil_test::common_test_pins!(io);
|
||||||
|
|
||||||
|
let din = dout.peripheral_input();
|
||||||
|
|
||||||
let i2s_tx = i2s
|
let i2s_tx = i2s
|
||||||
.i2s_tx
|
.i2s_tx
|
||||||
@ -139,15 +138,18 @@ mod tests {
|
|||||||
// enable loopback testing
|
// enable loopback testing
|
||||||
unsafe {
|
unsafe {
|
||||||
let i2s = esp_hal::peripherals::I2S0::steal();
|
let i2s = esp_hal::peripherals::I2S0::steal();
|
||||||
i2s.tx_conf().modify(|_, w| w.sig_loopback().set_bit());
|
cfg_if::cfg_if! {
|
||||||
|
if #[cfg(esp32s2)] {
|
||||||
|
i2s.conf().modify(|_, w| w.sig_loopback().set_bit());
|
||||||
|
i2s.conf().modify(|_, w| w.rx_slave_mod().set_bit());
|
||||||
|
} else {
|
||||||
|
i2s.tx_conf().modify(|_, w| w.sig_loopback().set_bit());
|
||||||
|
i2s.rx_conf().modify(|_, w| w.rx_slave_mod().set_bit());
|
||||||
|
|
||||||
i2s.rx_conf().modify(|_, w| w.rx_slave_mod().set_bit());
|
i2s.tx_conf().modify(|_, w| w.tx_update().set_bit());
|
||||||
|
i2s.rx_conf().modify(|_, w| w.rx_update().set_bit());
|
||||||
i2s.tx_conf().modify(|_, w| w.tx_update().clear_bit());
|
}
|
||||||
i2s.tx_conf().modify(|_, w| w.tx_update().set_bit());
|
}
|
||||||
|
|
||||||
i2s.rx_conf().modify(|_, w| w.rx_update().clear_bit());
|
|
||||||
i2s.rx_conf().modify(|_, w| w.rx_update().set_bit());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut rx_transfer = i2s_rx.read_dma_circular_async(rx_buffer).unwrap();
|
let mut rx_transfer = i2s_rx.read_dma_circular_async(rx_buffer).unwrap();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user