From be04d7ab4074ddaa8d39199321ff4517de687bfb Mon Sep 17 00:00:00 2001 From: Jan Prochazka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:20:48 +0200 Subject: [PATCH] feat(ledc): Print info about already set channel --- cores/esp32/esp32-hal-ledc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cores/esp32/esp32-hal-ledc.c b/cores/esp32/esp32-hal-ledc.c index 495303a8958..283ce079f2e 100644 --- a/cores/esp32/esp32-hal-ledc.c +++ b/cores/esp32/esp32-hal-ledc.c @@ -105,6 +105,12 @@ bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, uint8_t c uint8_t group = (channel / 8), timer = ((channel / 2) % 4); bool channel_used = ledc_handle.used_channels & (1UL << channel); if (channel_used) { + log_i("Channel %u is already set up, given frequency and resolution will be ignored", channel); + //log setup of the channel frequency and resolution + uint32_t channel_freq = ledc_get_freq(group, timer); + uint32_t channel_resolution = 0; + ledc_ll_get_duty_resolution(LEDC_LL_GET_HW(), group, timer, &channel_resolution); + log_i("Channel %u frequency: %u, resolution: %u", channel, channel_freq, channel_resolution); if (ledc_set_pin(pin, group, channel % 8) != ESP_OK) { log_e("Attaching pin to already used channel failed!"); return false;