drivers: pwm: ledc: esp32: Enable RC_FAST clock source
RC_FAST needs to be enabled and calibrated in order to be used as clock source. Otherwise, clock source is selected but no PWM is generated. Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
This commit is contained in:
parent
709a373768
commit
00372dd6a9
1 changed files with 16 additions and 4 deletions
|
@ -10,6 +10,8 @@
|
|||
#include <hal/ledc_hal.h>
|
||||
#include <hal/ledc_types.h>
|
||||
#include <esp_clk_tree.h>
|
||||
#include <soc/rtc.h>
|
||||
#include <clk_ctrl_os.h>
|
||||
|
||||
#include <soc.h>
|
||||
#include <errno.h>
|
||||
|
@ -150,10 +152,20 @@ static int pwm_led_esp32_timer_config(struct pwm_ledc_esp32_channel_config *chan
|
|||
* Try each clock source available depending on the device and channel type.
|
||||
*/
|
||||
for (int i = 0; i < clock_src_num; i++) {
|
||||
channel->clock_src = clock_src[i];
|
||||
esp_clk_tree_src_get_freq_hz(channel->clock_src,
|
||||
ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED,
|
||||
&channel->clock_src_hz);
|
||||
if (clock_src[i] == LEDC_SLOW_CLK_RC_FAST) {
|
||||
/* RC_FAST requires enabling and calibrating */
|
||||
if (!rtc_dig_8m_enabled() && !periph_rtc_dig_clk8m_enable()) {
|
||||
/* skip RC_FAST as clock source */
|
||||
continue;
|
||||
}
|
||||
channel->clock_src = clock_src[i];
|
||||
channel->clock_src_hz = periph_rtc_dig_clk8m_get_freq();
|
||||
} else {
|
||||
channel->clock_src = clock_src[i];
|
||||
esp_clk_tree_src_get_freq_hz(channel->clock_src,
|
||||
ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED,
|
||||
&channel->clock_src_hz);
|
||||
}
|
||||
if (!pwm_led_esp32_calculate_max_resolution(channel)) {
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue