Skip to content

Commit

Permalink
improved checking for max channel number and made sure PWM_CHANNEL_NU…
Browse files Browse the repository at this point in the history
…M_MAX is set correctly
  • Loading branch information
pljakobs committed Oct 31, 2024
1 parent 9329a2e commit 8dc5c2c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions Sming/Arch/Esp32/Core/HardwarePWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,8 @@ uint32_t maxDuty(ledc_timer_bit_t bits)

HardwarePWM::HardwarePWM(uint8_t* pins, uint8_t no_of_pins) : channel_count(no_of_pins)
{
assert(no_of_pins <= SOC_LEDC_CHANNEL_NUM);

if(no_of_pins == 0) {
return;
}
assert(no_of_pins > 0 && no_of_pins <= SOC_LEDC_CHANNEL_NUM);
no_of_pins = std::min(uint8_t(SOC_LEDC_CHANNEL_NUM), no_of_pins);

periph_module_enable(PERIPH_LEDC_MODULE);

Expand Down

0 comments on commit 8dc5c2c

Please sign in to comment.