ESPHome  2024.10.2
i2s_audio.cpp
Go to the documentation of this file.
1 #include "i2s_audio.h"
2 
3 #ifdef USE_ESP32
4 
5 #include "esphome/core/log.h"
6 
7 namespace esphome {
8 namespace i2s_audio {
9 
10 static const char *const TAG = "i2s_audio";
11 
12 #if defined(USE_ESP_IDF) && (ESP_IDF_VERSION_MAJOR >= 5)
13 static const uint8_t I2S_NUM_MAX = SOC_I2S_NUM; // because IDF 5+ took this away :(
14 #endif
15 
17  static i2s_port_t next_port_num = I2S_NUM_0;
18 
19  if (next_port_num >= I2S_NUM_MAX) {
20  ESP_LOGE(TAG, "Too many I2S Audio components!");
21  this->mark_failed();
22  return;
23  }
24 
25  this->port_ = next_port_num;
26  next_port_num = (i2s_port_t) (next_port_num + 1);
27 
28  ESP_LOGCONFIG(TAG, "Setting up I2S Audio...");
29 }
30 
31 } // namespace i2s_audio
32 } // namespace esphome
33 
34 #endif // USE_ESP32
virtual void mark_failed()
Mark this component as failed.
Definition: component.cpp:118
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7