i2s: public bclk_div and add a default config for PDM TX DAC
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- |
|
||||
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- |
|
||||
|
||||
# I2S Basic PDM Mode Example
|
||||
|
||||
@@ -99,9 +99,9 @@ This example is going to show how to use the PDM TX and RX mode.
|
||||
#### PDM TX
|
||||
|
||||
* An earphone or a speaker
|
||||
* An audio power amplifier that can input PDM signal. If the power amplifier can only receive the analog signal without PDM clock, a low-pass passive or active filter is required to restore the PDM data wave into analog signal, before it is transmitted to the power amplifier.
|
||||
* An audio power amplifier that can input PDM signal. If the power amplifier can only receive the analog signal without PDM clock (i.e. DAC line mode, otherwise codec line mode), a low-pass passive or active filter is required to restore the PDM data wave into analog signal, before it is transmitted to the power amplifier.
|
||||
|
||||
**MAX98358**
|
||||
**MAX98358 (codec case)**
|
||||
|
||||
Please refer to the [Datasheet of MAX98358](https://datasheets.maximintegrated.com/en/ds/MAX98358.pdf) for more details.
|
||||
|
||||
@@ -121,7 +121,7 @@ Please refer to the [Datasheet of MAX98358](https://datasheets.maximintegrated.c
|
||||
└────────────────────────┘ └───────────────┘
|
||||
```
|
||||
|
||||
**NS4150**
|
||||
**NS4150 (dac case)**
|
||||
|
||||
Please refer to the NS4150 datasheet for more details.
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
set(srcs "i2s_pdm_example_main.c")
|
||||
|
||||
if(CONFIG_SOC_I2S_SUPPORTS_PDM_TX)
|
||||
if(CONFIG_SOC_I2S_SUPPORTS_PDM_TX AND CONFIG_EXAMPLE_PDM_TX)
|
||||
list(APPEND srcs "i2s_pdm_tx.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_I2S_SUPPORTS_PDM_RX)
|
||||
if(CONFIG_SOC_I2S_SUPPORTS_PDM_RX AND CONFIG_EXAMPLE_PDM_RX)
|
||||
list(APPEND srcs "i2s_pdm_rx.c")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -19,4 +19,28 @@ menu "I2S PDM Example Configuration"
|
||||
PDM RX example will show the received data from a PDM microphone.
|
||||
endchoice
|
||||
|
||||
choice EXAMPLE_PDM_TX_LINE_MODE
|
||||
prompt "I2S PDM TX Line Mode"
|
||||
depends on EXAMPLE_PDM_TX && SOC_I2S_HW_VERSION_2
|
||||
default EXAMPLE_PDM_TX_CODEC
|
||||
help
|
||||
Decide to output PDM signal into a PDM codec or a low-pass filter
|
||||
|
||||
config EXAMPLE_PDM_TX_CODEC
|
||||
bool "Codec line mode"
|
||||
help
|
||||
Output PDM signal to a PDM codec. The PDM clock signal is mandatory for PDM codec,
|
||||
the codec can differentiate the left and right sound channels by sampling data
|
||||
on positive or negative edges. That means the data of the left and right channels
|
||||
can coexist on a same data line.
|
||||
|
||||
config EXAMPLE_PDM_TX_DAC
|
||||
bool "DAC line mode"
|
||||
help
|
||||
Output PDM signal to a low-pass filter, so that the low-pass filter can restore the PDM
|
||||
signal to analog wave. Therefore, each data line can only contains one sound channel,
|
||||
if both left and right channels are required, two data lines should be specified as well.
|
||||
Normally the PDM signal is not sufficient in DAC line mode.
|
||||
endchoice
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -54,9 +54,15 @@ static i2s_chan_handle_t i2s_example_init_pdm_tx(void)
|
||||
* These two helper macros is defined in 'i2s_pdm.h' which can only be used in PDM TX mode.
|
||||
* They can help to specify the slot and clock configurations for initialization or re-configuring */
|
||||
i2s_pdm_tx_config_t pdm_tx_cfg = {
|
||||
#if CONFIG_EXAMPLE_PDM_TX_DAC
|
||||
.clk_cfg = I2S_PDM_TX_CLK_DAC_DEFAULT_CONFIG(EXAMPLE_PDM_TX_FREQ_HZ),
|
||||
/* The data bit-width of PDM mode is fixed to 16 */
|
||||
.slot_cfg = I2S_PDM_TX_SLOT_DAC_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_MONO),
|
||||
#else
|
||||
.clk_cfg = I2S_PDM_TX_CLK_DEFAULT_CONFIG(EXAMPLE_PDM_TX_FREQ_HZ),
|
||||
/* The data bit-width of PDM mode is fixed to 16 */
|
||||
.slot_cfg = I2S_PDM_TX_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_MONO),
|
||||
#endif
|
||||
.gpio_cfg = {
|
||||
.clk = EXAMPLE_PDM_TX_CLK_IO,
|
||||
.dout = EXAMPLE_PDM_TX_DOUT_IO,
|
||||
|
||||
@@ -9,7 +9,7 @@ from pytest_embedded import Dut
|
||||
@pytest.mark.esp32s3
|
||||
@pytest.mark.esp32c3
|
||||
@pytest.mark.esp32c6
|
||||
# @pytest.mark.esp32h2 IDF-6808
|
||||
@pytest.mark.esp32h2
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.parametrize(
|
||||
'config',
|
||||
|
||||
Reference in New Issue
Block a user