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

feature(ledc): Add output invert option for LEDC pin + minor fixes #9257

Merged
merged 10 commits into from
Feb 21, 2024
Prev Previous commit
Next Next commit
fix(ledc): Added freq check to ledcChangeFrequency
  • Loading branch information
P-R-O-C-H-Y committed Feb 20, 2024
commit a02e31d15178ffdc5fe3f29d11c8731f4cee6a0c
9 changes: 6 additions & 3 deletions cores/esp32/esp32-hal-ledc.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,12 @@ uint32_t ledcChangeFrequency(uint8_t pin, uint32_t freq, uint8_t resolution)
{
ledc_channel_handle_t *bus = (ledc_channel_handle_t*)perimanGetPinBus(pin, ESP32_BUS_TYPE_LEDC);
if(bus != NULL){

if(resolution > LEDC_MAX_BIT_WIDTH){
log_e("LEDC resolution too big (maximum %u)", LEDC_MAX_BIT_WIDTH);
if (freq == 0) {
log_e("LEDC pin %u - frequency can't be zero.", pin);
return 0;
}
if (resolution == 0 || resolution > LEDC_MAX_BIT_WIDTH){
log_e("LEDC pin %u - resolution is zero or it is too big (maximum %u)", pin, LEDC_MAX_BIT_WIDTH);
return 0;
}
uint8_t group=(bus->channel/8), timer=((bus->channel/2)%4);
Expand Down