change(esp_timer): esp_timer_init_os now returns ESP_OK if already initialized

Previously it would return ESP_ERR_INVALID_STATE, which meant that if called from
user-code before the system tries to initialize the timer then esp-idf would
fail to boot.

This could happen if a user wanted to use esp-timer from a cpp constructor.

Closes https://github.com/espressif/esp-idf/issues/9679
This commit is contained in:
Marius Vikhammer
2025-09-22 13:53:28 +08:00
parent 02b2f6994c
commit 16cdbd9f5c

View File

@@ -564,7 +564,13 @@ esp_err_t esp_timer_init(void)
*/
ESP_SYSTEM_INIT_FN(esp_timer_init_os, SECONDARY, ESP_TIMER_INIT_MASK, 100)
{
return esp_timer_init();
esp_err_t err = ESP_OK;
if (is_initialized()) {
err = ESP_OK;
} else {
err = esp_timer_init();
}
return err;
}
esp_err_t esp_timer_deinit(void)