mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 20:54:24 +00:00
fix(newlib): Fixed an issue where usleep() could consume more CPU cycles
The following changes are made in this commit: 1. This commit updates the implementation of usleep() to now always yield CPU time if undergoing a multi-tick sleep. This reduces the accuracy of usleep() but in turn allows the scheduler to schedule different tasks. 2. The commit also updates the MCPWM unit test which fails due to the change in the behavior of usleep(). Closes: https://github.com/espressif/esp-idf/pull/15132
This commit is contained in:
@@ -172,7 +172,7 @@ static uint32_t pcnt_get_pulse_number(pcnt_unit_handle_t pwm_pcnt_unit, int capt
|
||||
int count_value = 0;
|
||||
TEST_ESP_OK(pcnt_unit_clear_count(pwm_pcnt_unit));
|
||||
TEST_ESP_OK(pcnt_unit_start(pwm_pcnt_unit));
|
||||
usleep(capture_window_ms * 1000);
|
||||
vTaskDelay(pdMS_TO_TICKS(capture_window_ms));
|
||||
TEST_ESP_OK(pcnt_unit_stop(pwm_pcnt_unit));
|
||||
TEST_ESP_OK(pcnt_unit_get_count(pwm_pcnt_unit, &count_value));
|
||||
printf("count value: %d\r\n", count_value);
|
||||
|
Reference in New Issue
Block a user