diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index ac00535d..04bdd680 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -15,5 +15,12 @@ config FREERTOS_HZ default 100 help Select the tick rate at which FreeRTOS does pre-emptive context switching. + +config FREERTOS_MAX_HOOK + int "FreeRTOS hook max number" + range 1 16 + default 2 + help + configurate the max number of FreeRTOS hook function. endmenu diff --git a/components/freertos/port/esp8266/freertos_hooks.c b/components/freertos/port/esp8266/freertos_hooks.c index 328ef36e..6d133711 100644 --- a/components/freertos/port/esp8266/freertos_hooks.c +++ b/components/freertos/port/esp8266/freertos_hooks.c @@ -21,16 +21,22 @@ #include "esp_freertos_hooks.h" #include "sdkconfig.h" -#include "esp_pm.h" -#include "pm_impl.h" //We use just a static array here because it's not expected many components will need //an idle or tick hook. -#define MAX_HOOKS 8 +#define MAX_HOOKS CONFIG_FREERTOS_MAX_HOOK +#undef portENTER_CRITICAL +#undef portEXIT_CRITICAL + +#define portENTER_CRITICAL(_s) vPortEnterCritical() +#define portEXIT_CRITICAL(_s) vPortExitCritical() + +#if portNUM_PROCESSORS > 1 static portMUX_TYPE hooks_spinlock = portMUX_INITIALIZER_UNLOCKED; -static esp_freertos_idle_cb_t idle_cb[portNUM_PROCESSORS][MAX_HOOKS]={0}; -static esp_freertos_tick_cb_t tick_cb[portNUM_PROCESSORS][MAX_HOOKS]={0}; +#endif +static esp_freertos_idle_cb_t idle_cb[portNUM_PROCESSORS][MAX_HOOKS]; +static esp_freertos_tick_cb_t tick_cb[portNUM_PROCESSORS][MAX_HOOKS]; void IRAM_ATTR esp_vApplicationTickHook() { diff --git a/components/freertos/port/esp8266/include/freertos/FreeRTOSConfig.h b/components/freertos/port/esp8266/include/freertos/FreeRTOSConfig.h index e39f9716..2d728385 100644 --- a/components/freertos/port/esp8266/include/freertos/FreeRTOSConfig.h +++ b/components/freertos/port/esp8266/include/freertos/FreeRTOSConfig.h @@ -83,6 +83,7 @@ * See http://www.freertos.org/a00110.html. *----------------------------------------------------------*/ +#define portNUM_PROCESSORS 1 #define configUSE_PREEMPTION 1 #define configUSE_IDLE_HOOK 1 #define configUSE_TICK_HOOK 0 diff --git a/components/freertos/port/esp8266/include/freertos/portmacro.h b/components/freertos/port/esp8266/include/freertos/portmacro.h index d04b4558..0c1ad695 100644 --- a/components/freertos/port/esp8266/include/freertos/portmacro.h +++ b/components/freertos/port/esp8266/include/freertos/portmacro.h @@ -167,6 +167,8 @@ void PortEnableInt_NoNest( void ); #define portENTER_CRITICAL() vPortEnterCritical() #define portEXIT_CRITICAL() vPortExitCritical() +#define xPortGetCoreID() 0 + // no need to disable/enable lvl1 isr again in ISR //#define portSET_INTERRUPT_MASK_FROM_ISR() PortDisableInt_NoNest() //#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) PortEnableInt_NoNest()