[i2s_audio] Park the speaker data-out pin low at setup (#20226)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Keith Burzinski
2026-10-06 11:43:49 -06:00
committed by GitHub
co-authored by Claude Fable 5.1
parent 61ac0cb753
commit 1520d228bc
2 changed files with 14 additions and 3 deletions
@@ -40,6 +40,16 @@ void I2SAudioSpeakerBase::setup() {
// When no audio_dac is configured, this initializes software volume control.
this->set_volume(this->volume_);
this->set_mute_state(this->mute_state_);
// Until the I2S driver first starts, dout sits in its reset state (often pulled high, or a JTAG
// function on the ESP32-S3), which keeps a SPDIF optical transmitter lit. Park it low now.
this->park_dout_pin_();
}
void I2SAudioSpeakerBase::park_dout_pin_() {
gpio_reset_pin(this->dout_pin_);
gpio_set_direction(this->dout_pin_, GPIO_MODE_OUTPUT);
gpio_set_level(this->dout_pin_, 0);
}
void I2SAudioSpeakerBase::dump_config() {
@@ -303,9 +313,7 @@ void I2SAudioSpeakerBase::stop_i2s_driver_() {
// setup installed. If another speaker reuses this port (shared bus), its audio still reaches our
// dout. Detach the pin and drive it low so a stale output stops driving downstream hardware: a
// SPDIF optical transmitter would otherwise stay lit, and an analog DAC would emit noise.
gpio_reset_pin(this->dout_pin_);
gpio_set_direction(this->dout_pin_, GPIO_MODE_OUTPUT);
gpio_set_level(this->dout_pin_, 0);
this->park_dout_pin_();
}
this->parent_->unlock();
}
@@ -129,6 +129,9 @@ class I2SAudioSpeakerBase : public I2SAudioOut, public speaker::Speaker, public
/// @brief Stops the I2S driver and unlocks the I2S port
void stop_i2s_driver_();
/// @brief Detaches dout from the I2S signal and drives it low
void park_dout_pin_();
/// @brief Called in loop() when the task has stopped. Override for mode-specific cleanup.
virtual void on_task_stopped() {}