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

Enable I2S tests on ESP32 and work around first sample issue #2194

Merged
merged 3 commits into from
Sep 19, 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
1 change: 1 addition & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix I2C ending up in a state when only re-creating the peripheral makes it useable again (#2141)
- Fix `SpiBus::transfer` transferring data twice in some cases (#2159)
- Fixed UART freezing when using `RcFast` clock source on ESP32-C2/C3 (#2170)
- I2S: on ESP32 and ESP32-S2 data is now output to the right (WS=1) channel first. (#2194)

### Removed

Expand Down
13 changes: 9 additions & 4 deletions esp-hal/src/i2s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,10 +1137,15 @@ mod private {
// Short frame synchronization
w.tx_short_sync().bit(false);
w.rx_short_sync().bit(false);
w.tx_msb_right().clear_bit();
w.rx_msb_right().clear_bit();
w.tx_right_first().clear_bit();
w.rx_right_first().clear_bit();
// Send MSB to the right channel to be consistent with ESP32-S3 et al.
w.tx_msb_right().set_bit();
w.rx_msb_right().set_bit();
// ESP32 generates two clock pulses first. If the WS is low, those first clock
// pulses are indistinguishable from real data, which corrupts the first few
// samples. So we send the right channel first (which means WS is high during
// the first sample) to prevent this issue.
w.tx_right_first().set_bit();
w.rx_right_first().set_bit();
w.tx_mono().clear_bit();
w.rx_mono().clear_bit();
w.sig_loopback().clear_bit()
Expand Down
6 changes: 2 additions & 4 deletions hil-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ macro_rules! common_test_pins {
cfg_if::cfg_if! {
if #[cfg(any(esp32s2, esp32s3))] {
($io.pins.gpio9, $io.pins.gpio10)
}
else if #[cfg(esp32)] {
} else if #[cfg(esp32)] {
($io.pins.gpio26, $io.pins.gpio27)
}
else {
} else {
($io.pins.gpio2, $io.pins.gpio3)
}
}
Expand Down
2 changes: 1 addition & 1 deletion hil-test/tests/i2s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! This test uses I2S TX to transmit known data to I2S RX (forced to slave mode
//! with loopback mode enabled).

//% CHIPS: esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% CHIPS: esp32 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: generic-queue

#![no_std]
Expand Down
Loading