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>
This commit is contained in:
pimdo 2024-05-28 02:42:59 +01:00 committed by GitHub
parent d2b35adcc8
commit 497cf8742f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 4 deletions

View File

@ -9,6 +9,10 @@ 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;

View File

@ -57,7 +57,7 @@ void I2SAudioMicrophone::start_() {
.use_apll = this->use_apll_,
.tx_desc_auto_clear = false,
.fixed_mclk = 0,
.mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT,
.mclk_multiple = I2S_MCLK_MULTIPLE_256,
.bits_per_chan = I2S_BITS_PER_CHAN_DEFAULT,
};

View File

@ -51,7 +51,7 @@ void I2SAudioSpeaker::player_task(void *params) {
.use_apll = false,
.tx_desc_auto_clear = true,
.fixed_mclk = I2S_PIN_NO_CHANGE,
.mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT,
.mclk_multiple = I2S_MCLK_MULTIPLE_256,
.bits_per_chan = I2S_BITS_PER_CHAN_DEFAULT,
};
#if SOC_I2S_SUPPORTS_DAC

View File

@ -4,6 +4,7 @@
#include "esphome/core/log.h"
#include <cinttypes>
#include <cstdio>
namespace esphome {
@ -622,7 +623,7 @@ void VoiceAssistant::signal_stop_() {
}
void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) {
ESP_LOGD(TAG, "Event Type: %d", msg.event_type);
ESP_LOGD(TAG, "Event Type: %" PRId32, msg.event_type);
switch (msg.event_type) {
case api::enums::VOICE_ASSISTANT_RUN_START:
ESP_LOGD(TAG, "Assist Pipeline running");
@ -785,7 +786,7 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) {
this->defer([this]() { this->stt_vad_end_trigger_->trigger(); });
break;
default:
ESP_LOGD(TAG, "Unhandled event type: %d", msg.event_type);
ESP_LOGD(TAG, "Unhandled event type: %" PRId32, msg.event_type);
break;
}
}