1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-23 19:18:17 +00:00
pimdo 497cf8742f
Make i2s_audio compatible with IDF 5+ (#6534)
* Update i2s_audio.cpp

Replace usage of I2S_NUM_MAX with I2S_NUM_1

* Update i2s_audio_microphone.cpp

Replace I2S_MCLK_MULTIPLE_DEFAULT with I2S_MCLK_MULTIPLE_256

* Update i2s_audio_speaker.cpp

Replace I2S_MCLK_MULTIPLE_DEFAULT with I2S_MCLK_MULTIPLE_256

* Update voice_assistant.cpp

Fix  msg.event_type format

* check SOC_I2S_NUM for c3

* use I2S_NUM_AUTO

* Update i2s_audio.cpp

* Couple tweaks

* Why did they take away I2S_NUM_MAX

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>

---------

Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2024-05-28 01:42:59 +00:00

35 lines
734 B
C++

#include "i2s_audio.h"
#ifdef USE_ESP32
#include "esphome/core/log.h"
namespace esphome {
namespace i2s_audio {
static const char *const TAG = "i2s_audio";
#if defined(USE_ESP_IDF) && (ESP_IDF_VERSION_MAJOR >= 5)
static const uint8_t I2S_NUM_MAX = SOC_I2S_NUM; // because IDF 5+ took this away :(
#endif
void I2SAudioComponent::setup() {
static i2s_port_t next_port_num = I2S_NUM_0;
if (next_port_num >= I2S_NUM_MAX) {
ESP_LOGE(TAG, "Too many I2S Audio components!");
this->mark_failed();
return;
}
this->port_ = next_port_num;
next_port_num = (i2s_port_t) (next_port_num + 1);
ESP_LOGCONFIG(TAG, "Setting up I2S Audio...");
}
} // namespace i2s_audio
} // namespace esphome
#endif // USE_ESP32