mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-26 20:00:32 +00:00
Add Config structure for I2s (#3985)
* Add Config structure for I2s * Add apply_config for I2sTx/I2sRx
This commit is contained in:
parent
2e958d2bb7
commit
46eed04403
@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- ESP32: Expose `psram_vaddr_mode` via `PsramConfig` (#3990)
|
||||
- ESP32-S3: Expose more `Camera` config options (#3996)
|
||||
- `ShaBackend, Sha<N>Context`: Work-queue based SHA driver (#4013)
|
||||
- I2S: `i2s::master::Config` with support for more TDM mode standards (#3985)
|
||||
|
||||
### Changed
|
||||
|
||||
@ -52,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `RtcSlowClock::RtcFastClock8m` has been renamed to `RtcFastClock::RtcFastClockRcFast` (#3993)
|
||||
- `RtcSlowClock::RtcSlowClockRtc` has been renamed to `RtcSlowClock::RtcSlowClockRcSlow` (#3993)
|
||||
- The `Raw: RawChannelAccess` of `rmt::Channel` has been erased; channel numbers are always dynamic now. (#3980)
|
||||
- ESP32-S2: `i2s::master::DataFormat` now includes 8-bit and 24-bit data widths (#3985)
|
||||
|
||||
### Fixed
|
||||
|
||||
@ -72,6 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `AesFlavour` trait and `AesX` structs have been removed. (#3880)
|
||||
- `Xtal::Other` has been removed (#3983)
|
||||
- ESP32-C3/S3: removed the UHCI1 peripheral singleton (#4007)
|
||||
- `i2s::master::Standard` has been removed (#3985)
|
||||
|
||||
## [v1.0.0-rc.0] - 2025-07-16
|
||||
|
||||
|
@ -221,3 +221,21 @@ let peripherals = esp_hal::init(
|
||||
+ .with_data6(peripherals.GPIO16)
|
||||
+ .with_data7(peripherals.GPIO15);
|
||||
```
|
||||
|
||||
## I2S Changes
|
||||
|
||||
I2S configuration is now done using `i2s::master::Config`. Sample rate and data format, previously passed
|
||||
to the constructor, have to be assigned to `Config` instead.
|
||||
|
||||
```diff
|
||||
let i2s = I2s::new(
|
||||
peripherals.I2S0,
|
||||
- Standard::Philips,
|
||||
- DataFormat::Data16Channel16,
|
||||
- Rate::from_hz(44100),
|
||||
dma_channel,
|
||||
+ Config::new_tdm_philips()
|
||||
+ .with_data_format(DataFormat::Data16Channel16)
|
||||
+ .with_sample_rate(Rate::from_hz(44100)),
|
||||
);
|
||||
```
|
||||
|
File diff suppressed because it is too large
Load Diff
4
esp-hal/src/i2s/tdm_slot_msb.svg
Normal file
4
esp-hal/src/i2s/tdm_slot_msb.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 53 KiB |
1
esp-hal/src/i2s/tdm_slot_pcm_long.svg
Normal file
1
esp-hal/src/i2s/tdm_slot_pcm_long.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 54 KiB |
1
esp-hal/src/i2s/tdm_slot_pcm_short.svg
Normal file
1
esp-hal/src/i2s/tdm_slot_pcm_short.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 54 KiB |
4
esp-hal/src/i2s/tdm_slot_philips.svg
Normal file
4
esp-hal/src/i2s/tdm_slot_philips.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 54 KiB |
@ -145,11 +145,13 @@ mod test {
|
||||
#[cfg(not(any(esp32, esp32s2, esp32s3)))]
|
||||
let other_peripheral = esp_hal::i2s::master::I2s::new(
|
||||
peripherals.I2S0,
|
||||
esp_hal::i2s::master::Standard::Philips,
|
||||
esp_hal::i2s::master::DataFormat::Data8Channel8,
|
||||
Rate::from_khz(8),
|
||||
dma_channel2,
|
||||
);
|
||||
esp_hal::i2s::master::Config::new_tdm_philips()
|
||||
.with_sample_rate(Rate::from_khz(8))
|
||||
.with_data_format(esp_hal::i2s::master::DataFormat::Data16Channel16)
|
||||
.with_channels(esp_hal::i2s::master::Channels::STEREO),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let sw_ints = SoftwareInterruptControl::new(peripherals.SW_INTERRUPT);
|
||||
|
||||
|
@ -15,7 +15,7 @@ use esp_hal::{
|
||||
delay::Delay,
|
||||
dma_buffers,
|
||||
gpio::{AnyPin, NoPin, Pin},
|
||||
i2s::master::{DataFormat, I2s, I2sTx, Standard},
|
||||
i2s::master::{Channels, Config, DataFormat, I2s, I2sTx},
|
||||
peripherals::I2S0,
|
||||
time::Rate,
|
||||
};
|
||||
@ -137,11 +137,13 @@ mod tests {
|
||||
|
||||
let i2s = I2s::new(
|
||||
ctx.i2s,
|
||||
Standard::Philips,
|
||||
DataFormat::Data16Channel16,
|
||||
Rate::from_hz(16000),
|
||||
ctx.dma_channel,
|
||||
Config::new_tdm_philips()
|
||||
.with_sample_rate(Rate::from_hz(16000))
|
||||
.with_data_format(DataFormat::Data16Channel16)
|
||||
.with_channels(Channels::STEREO),
|
||||
)
|
||||
.unwrap()
|
||||
.into_async();
|
||||
|
||||
let (din, dout) = unsafe { ctx.dout.split() };
|
||||
@ -188,11 +190,13 @@ mod tests {
|
||||
|
||||
let i2s = I2s::new(
|
||||
ctx.i2s,
|
||||
Standard::Philips,
|
||||
DataFormat::Data16Channel16,
|
||||
Rate::from_hz(16000),
|
||||
ctx.dma_channel,
|
||||
);
|
||||
Config::new_tdm_philips()
|
||||
.with_sample_rate(Rate::from_hz(16000))
|
||||
.with_data_format(DataFormat::Data16Channel16)
|
||||
.with_channels(Channels::STEREO),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let (din, dout) = unsafe { ctx.dout.split() };
|
||||
|
||||
@ -295,11 +299,13 @@ mod tests {
|
||||
|
||||
let i2s = I2s::new(
|
||||
ctx.i2s,
|
||||
Standard::Philips,
|
||||
DataFormat::Data16Channel16,
|
||||
Rate::from_hz(16000),
|
||||
ctx.dma_channel,
|
||||
);
|
||||
Config::new_tdm_philips()
|
||||
.with_sample_rate(Rate::from_hz(16000))
|
||||
.with_data_format(DataFormat::Data16Channel16)
|
||||
.with_channels(Channels::STEREO),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut i2s_tx = i2s
|
||||
.i2s_tx
|
||||
@ -323,11 +329,13 @@ mod tests {
|
||||
|
||||
let i2s = I2s::new(
|
||||
ctx.i2s,
|
||||
Standard::Philips,
|
||||
DataFormat::Data16Channel16,
|
||||
Rate::from_hz(16000),
|
||||
ctx.dma_channel,
|
||||
);
|
||||
Config::new_tdm_philips()
|
||||
.with_sample_rate(Rate::from_hz(16000))
|
||||
.with_data_format(DataFormat::Data16Channel16)
|
||||
.with_channels(Channels::STEREO),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut i2s_rx = i2s
|
||||
.i2s_rx
|
||||
|
@ -20,7 +20,7 @@ use embassy_executor::Spawner;
|
||||
use esp_backtrace as _;
|
||||
use esp_hal::{
|
||||
dma_buffers,
|
||||
i2s::master::{DataFormat, I2s, Standard},
|
||||
i2s::master::{Channels, Config, DataFormat, I2s},
|
||||
time::Rate,
|
||||
timer::timg::TimerGroup,
|
||||
};
|
||||
@ -48,11 +48,13 @@ async fn main(_spawner: Spawner) {
|
||||
|
||||
let i2s = I2s::new(
|
||||
peripherals.I2S0,
|
||||
Standard::Philips,
|
||||
DataFormat::Data16Channel16,
|
||||
Rate::from_hz(44100),
|
||||
dma_channel,
|
||||
Config::new_tdm_philips()
|
||||
.with_sample_rate(Rate::from_hz(44100))
|
||||
.with_data_format(DataFormat::Data16Channel16)
|
||||
.with_channels(Channels::STEREO),
|
||||
)
|
||||
.unwrap()
|
||||
.into_async();
|
||||
|
||||
#[cfg(not(feature = "esp32"))]
|
||||
|
@ -34,7 +34,7 @@ use embassy_executor::Spawner;
|
||||
use esp_backtrace as _;
|
||||
use esp_hal::{
|
||||
dma_buffers,
|
||||
i2s::master::{DataFormat, I2s, Standard},
|
||||
i2s::master::{Channels, Config, DataFormat, I2s},
|
||||
time::Rate,
|
||||
timer::timg::TimerGroup,
|
||||
};
|
||||
@ -70,11 +70,13 @@ async fn main(_spawner: Spawner) {
|
||||
|
||||
let i2s = I2s::new(
|
||||
peripherals.I2S0,
|
||||
Standard::Philips,
|
||||
DataFormat::Data16Channel16,
|
||||
Rate::from_hz(44100),
|
||||
dma_channel,
|
||||
Config::new_tdm_philips()
|
||||
.with_sample_rate(Rate::from_hz(44100))
|
||||
.with_data_format(DataFormat::Data16Channel16)
|
||||
.with_channels(Channels::STEREO),
|
||||
)
|
||||
.unwrap()
|
||||
.into_async();
|
||||
|
||||
let i2s_tx = i2s
|
||||
|
Loading…
x
Reference in New Issue
Block a user