From 41c0e441857b139f6d9fcd948fbc55fb4fca1947 Mon Sep 17 00:00:00 2001 From: Zim Kalinowski Date: Mon, 30 Aug 2021 10:10:29 +0800 Subject: [PATCH] freertos: Upgrade to 10.4.3 - timers (cherry picked from commit c22a4c355603318a16adb3b898943744d9b826a5) --- components/freertos/include/freertos/timers.h | 41 ++++++++++++++++++- components/freertos/timers.c | 35 +++++++++++----- 2 files changed, 65 insertions(+), 11 deletions(-) diff --git a/components/freertos/include/freertos/timers.h b/components/freertos/include/freertos/timers.h index 53a23c3f19..69512f949e 100644 --- a/components/freertos/include/freertos/timers.h +++ b/components/freertos/include/freertos/timers.h @@ -447,6 +447,10 @@ void vTimerSetTimerID( TimerHandle_t xTimer, BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /** + * @cond + * TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ); + * @endcond + * * xTimerGetTimerDaemonTaskHandle() is only available if * INCLUDE_xTimerGetTimerDaemonTaskHandle is set to 1 in FreeRTOSConfig.h. * @@ -1254,7 +1258,7 @@ const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint * void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ); * * Updates a timer to be either an auto-reload timer, in which case the timer - * automatically resets itself each time it expires, or a one shot timer, in + * automatically resets itself each time it expires, or a one-shot timer, in * which case the timer will only expire once unless it is manually restarted. * * @param xTimer The handle of the timer being updated. @@ -1268,6 +1272,20 @@ const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION; +/** + * UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer ); + * + * Queries a timer to determine if it is an auto-reload timer, in which case the timer + * automatically resets itself each time it expires, or a one-shot timer, in + * which case the timer will only expire once unless it is manually restarted. + * + * @param xTimer The handle of the timer being queried. + * + * @return If the timer is an auto-reload timer then pdTRUE is returned, otherwise + * pdFALSE is returned. + */ +UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; + /** * TickType_t xTimerGetPeriod( TimerHandle_t xTimer ); * @@ -1315,6 +1333,27 @@ BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, /** @endcond */ +#if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + + /** + * @cond + * task.h + *
void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ) 
+ * @endcond + * + * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Timer Task TCB. This function is required when + * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION + * + * @param ppxTimerTaskTCBBuffer A handle to a statically allocated TCB buffer + * @param ppxTimerTaskStackBuffer A handle to a statically allocated Stack buffer for thie idle task + * @param pulTimerTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer + */ + void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, + StackType_t ** ppxTimerTaskStackBuffer, + uint32_t * pulTimerTaskStackSize ); + +#endif + /* *INDENT-OFF* */ #ifdef __cplusplus } diff --git a/components/freertos/timers.c b/components/freertos/timers.c index b0f1f265f7..076aaf4b1f 100644 --- a/components/freertos/timers.c +++ b/components/freertos/timers.c @@ -147,16 +147,6 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED; /*-----------------------------------------------------------*/ -#if( configSUPPORT_STATIC_ALLOCATION == 1 ) - - /* If static allocation is supported then the application must provide the - * following callback function - which enables the application to optionally - * provide the memory that will be used by the timer task as the task's stack - * and TCB. */ - extern void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ); - -#endif - /* * Initialise the infrastructure used by the timer service task if it has not * been initialised already. @@ -474,6 +464,31 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED; } /*-----------------------------------------------------------*/ + UBaseType_t uxTimerGetReloadMode( TimerHandle_t xTimer ) + { + Timer_t * pxTimer = xTimer; + UBaseType_t uxReturn; + + configASSERT( xTimer ); + taskENTER_CRITICAL( &xTimerMux ); + { + if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) == 0 ) + { + /* Not an auto-reload timer. */ + uxReturn = ( UBaseType_t ) pdFALSE; + } + else + { + /* Is an auto-reload timer. */ + uxReturn = ( UBaseType_t ) pdTRUE; + } + } + taskEXIT_CRITICAL( &xTimerMux ); + + return uxReturn; + } +/*-----------------------------------------------------------*/ + TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) { Timer_t * pxTimer = xTimer;