3#if defined(USE_ESP32) && defined(USE_I2S_AUDIO_FULL_DUPLEX)
17 i2s_chan_config_t chan_cfg{};
18 i2s_std_config_t tx_cfg{};
19 i2s_std_config_t rx_cfg{};
26 err = i2s_channel_init_std_mode(this->
rx_handle_, &rx_cfg);
29 err = i2s_channel_init_std_mode(this->
tx_handle_, &tx_cfg);
32 ESP_LOGE(TAG,
"Full duplex channel setup failed: %s", esp_err_to_name(err));
82 esp_err_t err = needed ? i2s_channel_enable(this->
rx_handle_) : i2s_channel_disable(this->
rx_handle_);
84 ESP_LOGE(TAG,
"Failed to %s RX channel: %s", needed ? LOG_STR_LITERAL(
"enable") : LOG_STR_LITERAL(
"disable"),
85 esp_err_to_name(err));
void mark_failed()
Mark this component as failed.
i2s_chan_handle_t tx_handle_
i2s_chan_handle_t acquire_rx_channel()
Enables the full duplex RX channel.
bool is_full_duplex() const
True when a microphone and a speaker share this bus at the same time.
i2s_chan_handle_t rx_handle_
i2s_chan_handle_t acquire_(bool &in_use, i2s_chan_handle_t handle)
Marks one side active and brings the shared clocks up; undoes the mark if that fails.
bool update_rx_channel_()
Enables the RX channel while either side is active, since it drives the shared clocks.
void release_rx_channel()
Releases the RX channel; it keeps running while the TX side needs its clocks. Main loop only.
i2s_chan_handle_t acquire_tx_channel()
Starts the shared clocks and hands over the full duplex TX channel, still disabled,...
void release_tx_channel()
Disables the TX channel and stops the shared clocks if the RX side is idle.
virtual void build_full_duplex_config(i2s_std_config_t &std_cfg)=0
Builds the RX configuration the parent uses to set up a full duplex channel pair.
virtual void build_full_duplex_config(i2s_chan_config_t &chan_cfg, i2s_std_config_t &std_cfg)
Builds the TX configuration the parent uses to set up a full duplex channel pair.
ESPHOME_LOG_TAG(TAG, "i2s_audio")
spi_device_handle_t handle