소스 검색

esp_timer: perform initialization using ESP_SYSTEM_INIT_FN

(startup.c still calls esp_timer_early_init directly)
Ivan Grokhotkov 3 년 전
부모
커밋
bb771fb7c4
3개의 변경된 파일8개의 추가작업 그리고 2개의 파일을 삭제
  1. 0 2
      components/esp_system/startup.c
  2. 3 0
      components/esp_system/system_init_fn.txt
  3. 5 0
      components/esp_timer/src/esp_timer.c

+ 0 - 2
components/esp_system/startup.c

@@ -447,8 +447,6 @@ static void start_cpu0_default(void)
 
 ESP_SYSTEM_INIT_FN(init_components0, BIT(0), 200)
 {
-    esp_timer_init();
-
 #if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND && !CONFIG_PM_SLP_DISABLE_GPIO
     // Configure to isolate (disable the Input/Output/Pullup/Pulldown
     // function of the pin) all GPIO pins in sleep state

+ 3 - 0
components/esp_system/system_init_fn.txt

@@ -13,6 +13,9 @@
 #   affinity_expression: bit map of cores the function is executed on
 
 
+# esp_timer has to be initialized early, since it is used by several other components
+100: esp_timer_startup_init in components/esp_timer/src/esp_timer.c on BIT(0)
+
 # the rest of the components which are initialized from startup.c
 # [refactor-todo]: move init calls into respective components
 200: init_components0 in components/esp_system/startup.c on BIT(0)

+ 5 - 0
components/esp_timer/src/esp_timer.c

@@ -460,6 +460,11 @@ out:
     return ESP_ERR_NO_MEM;
 }
 
+ESP_SYSTEM_INIT_FN(esp_timer_startup_init, BIT(0), 100)
+{
+    return esp_timer_init();
+}
+
 esp_err_t esp_timer_deinit(void)
 {
     if (!is_initialized()) {