From 95d63137d1b25e24e405c15537ed7107351ec6ca Mon Sep 17 00:00:00 2001 From: Darian Leung Date: Fri, 13 Oct 2017 18:27:53 +0800 Subject: [PATCH] bugfix/freertos_dual_core_hooks This commit fixes bugs with the dual core changes to freeRTOS tick and idle hooks. Interrupt watchdog now registers tick hooks to both cores. API for cross core tick and idle hook registration were also added --- components/esp32/freertos_hooks.c | 59 ++++++++++-------- components/esp32/include/esp_freertos_hooks.h | 60 +++++++++++++++---- components/esp32/int_wdt.c | 5 +- 3 files changed, 86 insertions(+), 38 deletions(-) diff --git a/components/esp32/freertos_hooks.c b/components/esp32/freertos_hooks.c index 6cea80b9d..599bc1962 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