Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HardwarePWM Esp32 - added assert for max pwm channels #2904

Merged
merged 13 commits into from
Nov 4, 2024
8 changes: 5 additions & 3 deletions Sming/Arch/Esp32/Core/HardwarePWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,14 @@ uint32_t maxDuty(ledc_timer_bit_t bits)

HardwarePWM::HardwarePWM(uint8_t* pins, uint8_t no_of_pins) : channel_count(no_of_pins)
{
debug_d("starting HardwarePWM init");
periph_module_enable(PERIPH_LEDC_MODULE);
if((no_of_pins == 0) || (no_of_pins > SOC_LEDC_CHANNEL_NUM)) {
assert(no_of_pins <= SOC_LEDC_CHANNEL_NUM);

if(no_of_pins == 0) {
return;
}
pljakobs marked this conversation as resolved.
Show resolved Hide resolved

periph_module_enable(PERIPH_LEDC_MODULE);

for(uint8_t i = 0; i < no_of_pins; i++) {
channels[i] = pins[i];

Expand Down
Loading