freertos: Add config parameters to customize FreeRTOS behaviour.
The options are: - SUPPORT_STATIC_ALLOCATION - ENABLE_STATIC_TASK_CLEAN_UP_HOOK - TIMER_TASK_PRIORITY - TIMER_TASK_STACK_DEPTH - TIMER_QUEUE_LENGTH Merges #444 https://github.com/espressif/esp-idf/pull/444
This commit is contained in:
parent
3e7b786af5
commit
01ad387ac8
3 changed files with 87 additions and 8 deletions
|
@ -197,6 +197,81 @@ config FREERTOS_MAX_TASK_NAME_LEN
|
|||
|
||||
For most uses, the default of 16 is OK.
|
||||
|
||||
config SUPPORT_STATIC_ALLOCATION
|
||||
bool "Enable FreeRTOS static allocation API"
|
||||
default n
|
||||
help
|
||||
FreeRTOS gives the application writer the ability to instead provide the memory
|
||||
themselves, allowing the following objects to optionally be created without any
|
||||
memory being allocated dynamically:
|
||||
|
||||
- Tasks
|
||||
- Software Timers
|
||||
- Queues
|
||||
- Event Groups
|
||||
- Binary Semaphores
|
||||
- Counting Semaphores
|
||||
- Recursive Semaphores
|
||||
- Mutexes
|
||||
|
||||
Whether it is preferable to use static or dynamic memory allocation is dependent on
|
||||
the application, and the preference of the application writer. Both methods have pros
|
||||
and cons, and both methods can be used within the same RTOS application.
|
||||
|
||||
Creating RTOS objects using statically allocated RAM has the benefit of providing the
|
||||
application writer with more control: RTOS objects can be placed at specific memory locations.
|
||||
The maximum RAM footprint can be determined at link time, rather than run time.
|
||||
The application writer does not need to concern themselves with graceful handling of memory allocation failures.
|
||||
It allows the RTOS to be used in applications that simply don't allow any dynamic memory allocation
|
||||
(although FreeRTOS includes allocation schemes that can overcome most objections).
|
||||
|
||||
config ENABLE_STATIC_TASK_CLEAN_UP_HOOK
|
||||
bool "Enable static task clean up hook"
|
||||
depends on SUPPORT_STATIC_ALLOCATION
|
||||
default n
|
||||
help
|
||||
Enable this option to make FreeRTOS call the static task clean up hook when a task is deleted.
|
||||
|
||||
Bear in mind that if this option is enabled you will need to implement the following function:
|
||||
|
||||
void vPortCleanUpTCB ( void *pxTCB ) {
|
||||
// place clean up code here
|
||||
}
|
||||
|
||||
config TIMER_TASK_PRIORITY
|
||||
int "FreeRTOS timer task priority"
|
||||
range 1 25
|
||||
default 1
|
||||
help
|
||||
The timer service task (primarily) makes use of existing FreeRTOS features, allowing timer
|
||||
functionality to be added to an application with minimal impact on the size of the application's
|
||||
executable binary.
|
||||
|
||||
Use this constant to define the priority that the timer task will run at.
|
||||
|
||||
config TIMER_TASK_STACK_DEPTH
|
||||
int "FreeRTOS timer task stack size"
|
||||
range 1536 32768
|
||||
default 2048
|
||||
help
|
||||
The timer service task (primarily) makes use of existing FreeRTOS features, allowing timer
|
||||
functionality to be added to an application with minimal impact on the size of the application's
|
||||
executable binary.
|
||||
|
||||
Use this constant to define the size (in bytes) of the stack allocated for the timer task.
|
||||
|
||||
config TIMER_QUEUE_LENGTH
|
||||
int "FreeRTOS timer queue length"
|
||||
range 5 20
|
||||
default 10
|
||||
help
|
||||
FreeRTOS provides a set of timer related API functions. Many of these functions use a standard
|
||||
FreeRTOS queue to send commands to the timer service task. The queue used for this purpose is
|
||||
called the 'timer command queue'. The 'timer command queue' is private to the FreeRTOS timer
|
||||
implementation, and cannot be accessed directly.
|
||||
|
||||
For most uses the default value of 10 is OK.
|
||||
|
||||
menuconfig FREERTOS_DEBUG_INTERNALS
|
||||
bool "Debug FreeRTOS internals"
|
||||
default n
|
||||
|
|
|
@ -248,13 +248,21 @@
|
|||
#define configUSE_NEWLIB_REENTRANT 1
|
||||
|
||||
#define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||
#define configSUPPORT_STATIC_ALLOCATION CONFIG_SUPPORT_STATIC_ALLOCATION
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#if CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK
|
||||
extern void vPortCleanUpTCB ( void *pxTCB );
|
||||
#define portCLEAN_UP_TCB( pxTCB ) vPortCleanUpTCB( pxTCB )
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Test FreeRTOS timers (with timer task) and more. */
|
||||
/* Some files don't compile if this flag is disabled */
|
||||
#define configUSE_TIMERS 1
|
||||
#define configTIMER_TASK_PRIORITY 1
|
||||
#define configTIMER_QUEUE_LENGTH 10
|
||||
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
|
||||
#define configTIMER_TASK_PRIORITY CONFIG_TIMER_TASK_PRIORITY
|
||||
#define configTIMER_QUEUE_LENGTH CONFIG_TIMER_QUEUE_LENGTH
|
||||
#define configTIMER_TASK_STACK_DEPTH CONFIG_TIMER_TASK_STACK_DEPTH
|
||||
|
||||
#define INCLUDE_xTimerPendFunctionCall 1
|
||||
#define INCLUDE_eTaskGetState 1
|
||||
|
|
|
@ -3763,11 +3763,6 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask )
|
|||
|
||||
static void prvDeleteTCB( TCB_t *pxTCB )
|
||||
{
|
||||
/* This call is required specifically for the TriCore port. It must be
|
||||
above the vPortFree() calls. The call is also used by ports/demos that
|
||||
want to allocate and clean RAM statically. */
|
||||
portCLEAN_UP_TCB( pxTCB );
|
||||
|
||||
/* Free up the memory allocated by the scheduler for the task. It is up
|
||||
to the task to free any memory allocated at the application level. */
|
||||
#if ( configUSE_NEWLIB_REENTRANT == 1 )
|
||||
|
@ -3806,6 +3801,7 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask )
|
|||
/* Neither the stack nor the TCB were allocated dynamically, so
|
||||
nothing needs to be freed. */
|
||||
configASSERT( pxTCB->ucStaticallyAllocated == tskSTATICALLY_ALLOCATED_STACK_AND_TCB )
|
||||
portCLEAN_UP_TCB( pxTCB );
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue