mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-06-05 13:16:37 +08:00
feat(freertos): Cleanup tick/idle hook functionality
Closes https://github.com/espressif/ESP8266_RTOS_SDK/issues/500
This commit is contained in:
@ -39,6 +39,17 @@ config FREERTOS_ISR_STACKSIZE
|
|||||||
help
|
help
|
||||||
The interrupt handlers have their own stack. The size of the stack can be defined here.
|
The interrupt handlers have their own stack. The size of the stack can be defined here.
|
||||||
|
|
||||||
|
config FREERTOS_EXTENED_HOOKS
|
||||||
|
bool "Use FreeRTOS extened hooks"
|
||||||
|
default n
|
||||||
|
help
|
||||||
|
By using the "esp_register_freertos_xxx_hook system", extened hook function offers a number
|
||||||
|
of registerable hooks/callback functions that are called when a timer tick happens,
|
||||||
|
the idle thread runs etc.
|
||||||
|
|
||||||
|
Otherwise User can also use FreeRTOS raw hook functions "vApplicationIdleHook" and
|
||||||
|
"vApplicationTickHook".
|
||||||
|
|
||||||
config FREERTOS_GLOBAL_DATA_LINK_IRAM
|
config FREERTOS_GLOBAL_DATA_LINK_IRAM
|
||||||
bool "Link FreeRTOS global data to IRAM"
|
bool "Link FreeRTOS global data to IRAM"
|
||||||
default y
|
default y
|
||||||
|
@ -2752,6 +2752,12 @@ BaseType_t xSwitchRequired = pdFALSE;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* configUSE_TICK_HOOK */
|
#endif /* configUSE_TICK_HOOK */
|
||||||
|
|
||||||
|
#ifdef CONFIG_FREERTOS_EXTENED_HOOKS
|
||||||
|
{
|
||||||
|
esp_vApplicationTickHook();
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_FREERTOS_EXTENED_HOOKS */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2764,6 +2770,12 @@ BaseType_t xSwitchRequired = pdFALSE;
|
|||||||
vApplicationTickHook();
|
vApplicationTickHook();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_FREERTOS_EXTENED_HOOKS
|
||||||
|
{
|
||||||
|
esp_vApplicationTickHook();
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_FREERTOS_EXTENED_HOOKS */
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ( configUSE_PREEMPTION == 1 )
|
#if ( configUSE_PREEMPTION == 1 )
|
||||||
@ -3309,6 +3321,18 @@ static portTASK_FUNCTION( prvIdleTask, pvParameters )
|
|||||||
vApplicationIdleHook();
|
vApplicationIdleHook();
|
||||||
}
|
}
|
||||||
#endif /* configUSE_IDLE_HOOK */
|
#endif /* configUSE_IDLE_HOOK */
|
||||||
|
#ifdef CONFIG_FREERTOS_EXTENED_HOOKS
|
||||||
|
{
|
||||||
|
/* Call the esp-idf hook system */
|
||||||
|
esp_vApplicationIdleHook();
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_FREERTOS_EXTENED_HOOKS */
|
||||||
|
|
||||||
|
{
|
||||||
|
extern void esp_internal_idle_hook(void);
|
||||||
|
|
||||||
|
esp_internal_idle_hook();
|
||||||
|
}
|
||||||
|
|
||||||
#if CONFIG_ENABLE_FREERTOS_SLEEP
|
#if CONFIG_ENABLE_FREERTOS_SLEEP
|
||||||
/* This conditional compilation should use inequality to 0, not equality
|
/* This conditional compilation should use inequality to 0, not equality
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_FREERTOS_EXTENED_HOOKS
|
||||||
|
|
||||||
//We use just a static array here because it's not expected many components will need
|
//We use just a static array here because it's not expected many components will need
|
||||||
//an idle or tick hook.
|
//an idle or tick hook.
|
||||||
#define MAX_HOOKS CONFIG_FREERTOS_MAX_HOOK
|
#define MAX_HOOKS CONFIG_FREERTOS_MAX_HOOK
|
||||||
@ -158,3 +160,4 @@ void esp_deregister_freertos_tick_hook(esp_freertos_tick_cb_t old_tick_cb)
|
|||||||
portEXIT_CRITICAL(&hooks_spinlock);
|
portEXIT_CRITICAL(&hooks_spinlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_FREERTOS_EXTENED_HOOKS */
|
||||||
|
@ -50,8 +50,10 @@
|
|||||||
|
|
||||||
#define portNUM_PROCESSORS 1
|
#define portNUM_PROCESSORS 1
|
||||||
#define configUSE_PREEMPTION 1
|
#define configUSE_PREEMPTION 1
|
||||||
|
|
||||||
#define configUSE_IDLE_HOOK 1
|
#define configUSE_IDLE_HOOK 1
|
||||||
#define configUSE_TICK_HOOK 0
|
#define configUSE_TICK_HOOK 1
|
||||||
|
|
||||||
#define configUSE_TICKLESS_IDLE 1
|
#define configUSE_TICKLESS_IDLE 1
|
||||||
#define configCPU_CLOCK_HZ ( ( unsigned long ) 80000000 )
|
#define configCPU_CLOCK_HZ ( ( unsigned long ) 80000000 )
|
||||||
#define configTICK_RATE_HZ ( ( portTickType ) CONFIG_FREERTOS_HZ )
|
#define configTICK_RATE_HZ ( ( portTickType ) CONFIG_FREERTOS_HZ )
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
#ifndef __ESP_FREERTOS_HOOKS_H__
|
#ifndef __ESP_FREERTOS_HOOKS_H__
|
||||||
#define __ESP_FREERTOS_HOOKS_H__
|
#define __ESP_FREERTOS_HOOKS_H__
|
||||||
|
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_FREERTOS_EXTENED_HOOKS
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
|
|
||||||
@ -127,5 +131,6 @@ void esp_deregister_freertos_tick_hook(esp_freertos_tick_cb_t old_tick_cb);
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* CONFIG_FREERTOS_EXTENED_HOOKS */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -205,6 +205,9 @@ void _xt_enter_first_task(void);
|
|||||||
#define xTaskCreatePinnedToCore(pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pvCreatedTask, tskNO_AFFINITY) \
|
#define xTaskCreatePinnedToCore(pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pvCreatedTask, tskNO_AFFINITY) \
|
||||||
xTaskCreate(pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pvCreatedTask)
|
xTaskCreate(pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pvCreatedTask)
|
||||||
|
|
||||||
|
extern void esp_vApplicationIdleHook( void );
|
||||||
|
extern void esp_vApplicationTickHook( void );
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -344,15 +344,29 @@ BaseType_t xQueueGenericReceive(QueueHandle_t xQueue, void * const pvBuffer,
|
|||||||
return xQueueReceive(xQueue, pvBuffer, xTicksToWait);
|
return xQueueReceive(xQueue, pvBuffer, xTicksToWait);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vApplicationIdleHook(void)
|
void esp_internal_idle_hook(void)
|
||||||
{
|
{
|
||||||
extern void pmIdleHook(void);
|
extern void pmIdleHook(void);
|
||||||
extern void esp_task_wdt_reset(void);
|
extern void esp_task_wdt_reset(void);
|
||||||
|
|
||||||
pmIdleHook();
|
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
|
pmIdleHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if configUSE_IDLE_HOOK == 1
|
||||||
|
void __attribute__((weak)) vApplicationIdleHook(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if configUSE_TICK_HOOK == 1
|
||||||
|
void __attribute__((weak)) vApplicationTickHook(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t xPortGetTickRateHz(void)
|
uint32_t xPortGetTickRateHz(void)
|
||||||
{
|
{
|
||||||
return (uint32_t)configTICK_RATE_HZ;
|
return (uint32_t)configTICK_RATE_HZ;
|
||||||
|
Reference in New Issue
Block a user