Skip to content

Commit

Permalink
Added method to change the ledc PWM frequency programmatically (#5003)
Browse files Browse the repository at this point in the history
Added method to change the ledc PWM frequence programmatically
Returning frequency from ledcChangeFrequency
  • Loading branch information
iTacco committed Apr 16, 2021
1 parent 57cf2fb commit 01c8cae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cores/esp32/esp32-hal-ledc.c
Expand Up @@ -318,3 +318,12 @@ void ledcDetachPin(uint8_t pin)
{
pinMatrixOutDetach(pin, false, false);
}

double ledcChangeFrequency(uint8_t chan, double freq, uint8_t bit_num)
{
if (chan > 15) {
return 0;
}
double res_freq = _ledcSetupTimerFreq(chan, freq, bit_num);
return res_freq;
}
1 change: 1 addition & 0 deletions cores/esp32/esp32-hal-ledc.h
Expand Up @@ -35,6 +35,7 @@ uint32_t ledcRead(uint8_t channel);
double ledcReadFreq(uint8_t channel);
void ledcAttachPin(uint8_t pin, uint8_t channel);
void ledcDetachPin(uint8_t pin);
double ledcChangeFrequency(uint8_t channel, double freq, uint8_t resolution_bits);


#ifdef __cplusplus
Expand Down

0 comments on commit 01c8cae

Please sign in to comment.