I2S Fix Builtin DAC&PDM on ESP32 & compiling warning ESP32-C3 (#461)

* Update AudioOutputI2S.cpp

* Update AudioOutputSPDIF.cpp

* Fix PDM & DAC mode ESP32

The code for enabling compatibility with ESP32C3 had broken DAC builtin and PDM mode on ESP32. This should fix it again

* Update AudioOutputI2S.cpp
This commit is contained in:
FedericoBusero authored and GitHub committed 2021-12-17 19:31:49 -08:00
1 parent 933439fa3f
commit 7ac86f015f
2 files changed
+17 -5

No files matched your search

+12 -4
View File
@@ -175,15 +175,15 @@ bool AudioOutputI2S::begin(bool txDAC)
i2s_mode_t mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX);
if (output_mode == INTERNAL_DAC)
{
#ifdef I2S_MODE_DAC_BUILT_IN
#if CONFIG_IDF_TARGET_ESP32
mode = (i2s_mode_t)(mode | I2S_MODE_DAC_BUILT_IN);
#else
return false;
#endif
}
if (output_mode == INTERNAL_PDM)
else if (output_mode == INTERNAL_PDM)
{
#ifdef I2S_MODE_PDM
#if CONFIG_IDF_TARGET_ESP32
mode = (i2s_mode_t)(mode | I2S_MODE_PDM);
#else
return false;
@@ -193,7 +193,11 @@ bool AudioOutputI2S::begin(bool txDAC)
i2s_comm_format_t comm_fmt;
if (output_mode == INTERNAL_DAC)
{
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
comm_fmt = (i2s_comm_format_t) I2S_COMM_FORMAT_STAND_MSB;
#else
comm_fmt = (i2s_comm_format_t) I2S_COMM_FORMAT_I2S_MSB;
#endif
}
else if (lsb_justified)
{
@@ -201,7 +205,11 @@ bool AudioOutputI2S::begin(bool txDAC)
}
else
{
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
comm_fmt = (i2s_comm_format_t) (I2S_COMM_FORMAT_STAND_I2S);
#else
comm_fmt = (i2s_comm_format_t) (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB);
#endif
}
i2s_config_t i2s_config_dac = {
@@ -222,7 +230,7 @@ bool AudioOutputI2S::begin(bool txDAC)
}
if (output_mode == INTERNAL_DAC || output_mode == INTERNAL_PDM)
{
#ifdef I2S_DAC_CHANNEL_BOTH_EN
#if CONFIG_IDF_TARGET_ESP32
i2s_set_pin((i2s_port_t)portNo, NULL);
i2s_set_dac_mode(I2S_DAC_CHANNEL_BOTH_EN);
#else
+5 -1
View File
@@ -94,7 +94,11 @@ AudioOutputSPDIF::AudioOutputSPDIF(int dout_pin, int port, int dma_buf_count)
.sample_rate = 88200, // 2 x sampling_rate
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT, // 32bit words
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT, // Right than left
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_STAND_I2S),
#else
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),
#endif
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1, // lowest interrupt priority
.dma_buf_count = dma_buf_count,
.dma_buf_len = DMA_BUF_SIZE_DEFAULT, // bigger buffers, reduces interrupts