diff --git a/components/esp32/freertos_hooks.c b/components/esp32/freertos_hooks.c index 6cea80b9d8..599bc19620 100644 --- a/components/esp32/freertos_hooks.c +++ b/components/esp32/freertos_hooks.c @@ -56,14 +56,33 @@ void esp_vApplicationIdleHook() } } - -esp_err_t esp_register_freertos_idle_hook(esp_freertos_idle_cb_t new_idle_cb) +esp_err_t esp_register_freertos_idle_hook_for_cpu(esp_freertos_idle_cb_t new_idle_cb, UBaseType_t cpuid) { - int n; - int core = xPortGetCoreID(); - for (n=0; n= portNUM_PROCESSORS){ + return ESP_ERR_INVALID_ARG; + } + for(int n = 0; n < MAX_HOOKS; n++){ + if (idle_cb[cpuid][n]==NULL) { + idle_cb[cpuid][n]=new_idle_cb; + return ESP_OK; + } + } + return ESP_ERR_NO_MEM; +} + +esp_err_t esp_register_freertos_idle_hook(esp_freertos_idle_cb_t new_idle_cb) +{ + return esp_register_freertos_idle_hook_for_cpu(new_idle_cb, xPortGetCoreID()); +} + +esp_err_t esp_register_freertos_tick_hook_for_cpu(esp_freertos_tick_cb_t new_tick_cb, UBaseType_t cpuid) +{ + if(cpuid >= portNUM_PROCESSORS){ + return ESP_ERR_INVALID_ARG; + } + for(int n = 0; n < MAX_HOOKS; n++){ + if (tick_cb[cpuid][n]==NULL) { + tick_cb[cpuid][n]=new_tick_cb; return ESP_OK; } } @@ -72,32 +91,24 @@ esp_err_t esp_register_freertos_idle_hook(esp_freertos_idle_cb_t new_idle_cb) esp_err_t esp_register_freertos_tick_hook(esp_freertos_tick_cb_t new_tick_cb) { - int n; - int core = xPortGetCoreID(); - for (n=0; n