4 #include "AudioTools/CoreAudio/AudioPWM/PWMAudioBase.h"
14 using PWMDriver = PWMDriverESP32;
46 is_timer_started =
false;
47 for (
int j = 0; j < audio_config.
channels; j++) {
48 #if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0, 0)
49 ledcDetach(pins[j].gpio);
51 ledcDetachPin(pins[j].gpio);
64 is_timer_started =
true;
76 for (
int j = 0; j < audio_config.
channels; j++) {
77 pins[j].gpio = audio_config.pins()[j];
78 #if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0, 0)
81 LOGE(
"ledcAttach: %d", pins[j].gpio);
85 pins[j].pwm_channel = pwmChannel;
88 ledcAttachPin(pins[j].gpio, pins[j].pwm_channel);
90 LOGI(
"setupPWM: pin=%d, channel=%d, frequency=%u, resolution=%d",
91 pins[j].gpio, pins[j].pwm_channel, (
unsigned)audio_config.
pwm_frequency,
98 for (
int j = 0; j < pins.size(); j++) {
99 LOGI(
"pin%d: %d", j, pins[j].gpio);
105 timer.setCallbackParameter(
this);
106 timer.setIsSave(
false);
117 #if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5, 0, 0)
118 ledcWrite(pins[channel].gpio, value);
120 ledcWrite(pins[channel].pwm_channel, value);
127 uint32_t actual_timer_frequency = 0;
132 virtual int maxChannels() {
return 16; };
142 #if defined(ESP32S2) || defined(ESP32S3)
143 switch (resolution) {
157 switch (resolution) {
174 if (accessAudioPWM !=
nullptr) {