From 3722dbad6c816a82759be5615dff66ac187fd468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Proch=C3=A1zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:16:55 +0200 Subject: [PATCH] fix(ledc): Fix freeing channel if not used anymore (#10094) --- cores/esp32/esp32-hal-ledc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index eb2e51382..15466390e 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -52,8 +52,8 @@ static bool ledcDetachBus(void *bus) { bool channel_found = false; // Check if more pins are attached to the same ledc channel for (uint8_t i = 0; i < SOC_GPIO_PIN_COUNT; i++) { - if (!perimanPinIsValid(i)) { - continue; //invalid pin, skip + if (!perimanPinIsValid(i) || i == handle->pin) { + continue; //invalid pin or same pin } peripheral_bus_type_t type = perimanGetPinBusType(i); if (type == ESP32_BUS_TYPE_LEDC) {