kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'bugfix/fix_ledc_timer_update_usage' into 'master'
ledc: Fix the usage of ledc_ls_timer_update and ledc_timer_rst See merge request espressif/esp-idf!19637pull/9363/head^2
commit
aae3c7ba08
|
@ -276,7 +276,6 @@ esp_err_t ledc_timer_rst(ledc_mode_t speed_mode, ledc_timer_t timer_sel)
|
|||
LEDC_CHECK(p_ledc_obj[speed_mode] != NULL, LEDC_NOT_INIT, ESP_ERR_INVALID_STATE);
|
||||
portENTER_CRITICAL(&ledc_spinlock);
|
||||
ledc_hal_timer_rst(&(p_ledc_obj[speed_mode]->ledc_hal), timer_sel);
|
||||
ledc_ls_timer_update(speed_mode, timer_sel);
|
||||
portEXIT_CRITICAL(&ledc_spinlock);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@ -288,7 +287,6 @@ esp_err_t ledc_timer_pause(ledc_mode_t speed_mode, ledc_timer_t timer_sel)
|
|||
LEDC_CHECK(p_ledc_obj[speed_mode] != NULL, LEDC_NOT_INIT, ESP_ERR_INVALID_STATE);
|
||||
portENTER_CRITICAL(&ledc_spinlock);
|
||||
ledc_hal_timer_pause(&(p_ledc_obj[speed_mode]->ledc_hal), timer_sel);
|
||||
ledc_ls_timer_update(speed_mode, timer_sel);
|
||||
portEXIT_CRITICAL(&ledc_spinlock);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@ -300,7 +298,6 @@ esp_err_t ledc_timer_resume(ledc_mode_t speed_mode, ledc_timer_t timer_sel)
|
|||
LEDC_CHECK(p_ledc_obj[speed_mode] != NULL, LEDC_NOT_INIT, ESP_ERR_INVALID_STATE);
|
||||
portENTER_CRITICAL(&ledc_spinlock);
|
||||
ledc_hal_timer_resume(&(p_ledc_obj[speed_mode]->ledc_hal), timer_sel);
|
||||
ledc_ls_timer_update(speed_mode, timer_sel);
|
||||
portEXIT_CRITICAL(&ledc_spinlock);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@ -581,9 +578,6 @@ static esp_err_t ledc_set_timer_div(ledc_mode_t speed_mode, ledc_timer_t timer_n
|
|||
|
||||
/* The divisor is correct, we can write in the hardware. */
|
||||
ledc_timer_set(speed_mode, timer_num, div_param, duty_resolution, timer_clk_src);
|
||||
|
||||
/* Reset the timer. */
|
||||
ledc_timer_rst(speed_mode, timer_num);
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
|
@ -618,7 +612,12 @@ esp_err_t ledc_timer_config(const ledc_timer_config_t *timer_conf)
|
|||
ledc_hal_init(&(p_ledc_obj[speed_mode]->ledc_hal), speed_mode);
|
||||
}
|
||||
|
||||
return ledc_set_timer_div(speed_mode, timer_num, timer_conf->clk_cfg, freq_hz, duty_resolution);
|
||||
esp_err_t ret = ledc_set_timer_div(speed_mode, timer_num, timer_conf->clk_cfg, freq_hz, duty_resolution);
|
||||
if (ret == ESP_OK) {
|
||||
/* Reset the timer. */
|
||||
ledc_timer_rst(speed_mode, timer_num);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t ledc_set_pin(int gpio_num, ledc_mode_t speed_mode, ledc_channel_t ledc_channel)
|
||||
|
|
|
@ -611,6 +611,7 @@ TEST_CASE("LEDC timer pause and resume", "[ledc]")
|
|||
printf("reset ledc timer\n");
|
||||
TEST_ESP_OK(ledc_timer_rst(test_speed_mode, LEDC_TIMER_0));
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
count = wave_count(1000);
|
||||
TEST_ASSERT_UINT32_WITHIN(5, count, 5000);
|
||||
tear_testbench();
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue