Skip to content

Commit

Permalink
feat(ledc): Print info about already set channel
Browse files Browse the repository at this point in the history
  • Loading branch information
P-R-O-C-H-Y committed Jul 15, 2024
1 parent 477527d commit be04d7a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cores/esp32/esp32-hal-ledc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit be04d7a

Please sign in to comment.