[ledc] Fix ESP-IDF 6.0 compatibility for peripheral reset (#14790)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Swoboda
2026-03-14 15:02:13 -04:00
committed by GitHub
parent d4e1e32a30
commit b126f3af3b

View File

@@ -5,10 +5,9 @@
#include <driver/ledc.h>
#include <cinttypes>
#include <esp_idf_version.h>
#include <esp_private/periph_ctrl.h>
#if !defined(SOC_LEDC_SUPPORT_FADE_STOP)
#include <hal/ledc_ll.h>
#endif
#define CLOCK_FREQUENCY 80e6f
@@ -161,7 +160,14 @@ void LEDCOutput::write_state(float state) {
void LEDCOutput::setup() {
if (!ledc_peripheral_reset_done) {
ESP_LOGV(TAG, "Resetting LEDC peripheral to clear stale state after reboot");
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)
PERIPH_RCC_ATOMIC() {
ledc_ll_enable_reset_reg(true);
ledc_ll_enable_reset_reg(false);
}
#else
periph_module_reset(PERIPH_LEDC_MODULE);
#endif
ledc_peripheral_reset_done = true;
}