Merge branch 'zim-freertos-upgrade' into 'master'

FreeRTOS upgrade to v10.4.3 - part 2

See merge request espressif/esp-idf!14756
This commit is contained in:
Zim Kalinowski
2021-08-17 08:10:52 +00:00
16 changed files with 4832 additions and 3502 deletions

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
#ifndef INC_FREERTOS_H #ifndef INC_FREERTOS_H
@@ -48,9 +47,12 @@
*/ */
#include <stdint.h> /* READ COMMENT ABOVE. */ #include <stdint.h> /* READ COMMENT ABOVE. */
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* *INDENT-ON* */
/* for likely and unlikely */ /* for likely and unlikely */
#include "esp_compiler.h" #include "esp_compiler.h"
@@ -72,6 +74,7 @@ extern "C" {
#if ( configUSE_NEWLIB_REENTRANT == 1 ) #if ( configUSE_NEWLIB_REENTRANT == 1 )
#include <reent.h> #include <reent.h>
#endif #endif
/* /*
* Check all the required application specific macros have been defined. * Check all the required application specific macros have been defined.
* These macros are application specific and (as downloaded) are defined * These macros are application specific and (as downloaded) are defined
@@ -244,12 +247,12 @@ extern "C" {
#endif #endif
/* configPRECONDITION should be resolve to configASSERT. /* configPRECONDITION should be resolve to configASSERT.
The CBMC proofs need a way to track assumptions and assertions. * The CBMC proofs need a way to track assumptions and assertions.
A configPRECONDITION statement should express an implicit invariant or assumption made. * A configPRECONDITION statement should express an implicit invariant or assumption made.
A configASSERT statement should express an invariant that must hold explicit before calling * A configASSERT statement should express an invariant that must hold explicit before calling
the code. */ * the code. */
#ifndef configPRECONDITION #ifndef configPRECONDITION
#define configPRECONDITION( X ) configASSERT(X) #define configPRECONDITION( X ) configASSERT( X )
#define configPRECONDITION_DEFINED 0 #define configPRECONDITION_DEFINED 0
#else #else
#define configPRECONDITION_DEFINED 1 #define configPRECONDITION_DEFINED 1
@@ -312,26 +315,30 @@ extern "C" {
/* Remove any unused trace macros. */ /* Remove any unused trace macros. */
#ifndef traceSTART #ifndef traceSTART
/* Used to perform any necessary initialisation - for example, open a file
into which trace is to be written. */ /* Used to perform any necessary initialisation - for example, open a file
* into which trace is to be written. */
#define traceSTART() #define traceSTART()
#endif #endif
#ifndef traceEND #ifndef traceEND
/* Use to close a trace, for example close a file into which trace has been
written. */ /* Use to close a trace, for example close a file into which trace has been
* written. */
#define traceEND() #define traceEND()
#endif #endif
#ifndef traceTASK_SWITCHED_IN #ifndef traceTASK_SWITCHED_IN
/* Called after a task has been selected to run. pxCurrentTCB holds a pointer
to the task control block of the selected task. */ /* Called after a task has been selected to run. pxCurrentTCB holds a pointer
* to the task control block of the selected task. */
#define traceTASK_SWITCHED_IN() #define traceTASK_SWITCHED_IN()
#endif #endif
#ifndef traceINCREASE_TICK_COUNT #ifndef traceINCREASE_TICK_COUNT
/* Called before stepping the tick count after waking from tickless idle
sleep. */ /* Called before stepping the tick count after waking from tickless idle
* sleep. */
#define traceINCREASE_TICK_COUNT( x ) #define traceINCREASE_TICK_COUNT( x )
#endif #endif
@@ -346,49 +353,55 @@ extern "C" {
#endif #endif
#ifndef traceTASK_SWITCHED_OUT #ifndef traceTASK_SWITCHED_OUT
/* Called before a task has been selected to run. pxCurrentTCB holds a pointer
to the task control block of the task being switched out. */ /* Called before a task has been selected to run. pxCurrentTCB holds a pointer
* to the task control block of the task being switched out. */
#define traceTASK_SWITCHED_OUT() #define traceTASK_SWITCHED_OUT()
#endif #endif
#ifndef traceTASK_PRIORITY_INHERIT #ifndef traceTASK_PRIORITY_INHERIT
/* Called when a task attempts to take a mutex that is already held by a
lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task /* Called when a task attempts to take a mutex that is already held by a
that holds the mutex. uxInheritedPriority is the priority the mutex holder * lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task
will inherit (the priority of the task that is attempting to obtain the * that holds the mutex. uxInheritedPriority is the priority the mutex holder
muted. */ * will inherit (the priority of the task that is attempting to obtain the
* muted. */
#define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority ) #define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority )
#endif #endif
#ifndef traceTASK_PRIORITY_DISINHERIT #ifndef traceTASK_PRIORITY_DISINHERIT
/* Called when a task releases a mutex, the holding of which had resulted in
the task inheriting the priority of a higher priority task. /* Called when a task releases a mutex, the holding of which had resulted in
pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the * the task inheriting the priority of a higher priority task.
mutex. uxOriginalPriority is the task's configured (base) priority. */ * pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the
* mutex. uxOriginalPriority is the task's configured (base) priority. */
#define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority ) #define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority )
#endif #endif
#ifndef traceBLOCKING_ON_QUEUE_RECEIVE #ifndef traceBLOCKING_ON_QUEUE_RECEIVE
/* Task is about to block because it cannot read from a
queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore /* Task is about to block because it cannot read from a
upon which the read was attempted. pxCurrentTCB points to the TCB of the * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
task that attempted the read. */ * upon which the read was attempted. pxCurrentTCB points to the TCB of the
* task that attempted the read. */
#define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue ) #define traceBLOCKING_ON_QUEUE_RECEIVE( pxQueue )
#endif #endif
#ifndef traceBLOCKING_ON_QUEUE_PEEK #ifndef traceBLOCKING_ON_QUEUE_PEEK
/* Task is about to block because it cannot read from a
queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore /* Task is about to block because it cannot read from a
upon which the read was attempted. pxCurrentTCB points to the TCB of the * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
task that attempted the read. */ * upon which the read was attempted. pxCurrentTCB points to the TCB of the
* task that attempted the read. */
#define traceBLOCKING_ON_QUEUE_PEEK( pxQueue ) #define traceBLOCKING_ON_QUEUE_PEEK( pxQueue )
#endif #endif
#ifndef traceBLOCKING_ON_QUEUE_SEND #ifndef traceBLOCKING_ON_QUEUE_SEND
/* Task is about to block because it cannot write to a
queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore /* Task is about to block because it cannot write to a
upon which the write was attempted. pxCurrentTCB points to the TCB of the * queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
task that attempted the write. */ * upon which the write was attempted. pxCurrentTCB points to the TCB of the
* task that attempted the write. */
#define traceBLOCKING_ON_QUEUE_SEND( pxQueue ) #define traceBLOCKING_ON_QUEUE_SEND( pxQueue )
#endif #endif
@@ -631,15 +644,15 @@ extern "C" {
#endif #endif
#ifndef tracePEND_FUNC_CALL #ifndef tracePEND_FUNC_CALL
#define tracePEND_FUNC_CALL(xFunctionToPend, pvParameter1, ulParameter2, ret) #define tracePEND_FUNC_CALL( xFunctionToPend, pvParameter1, ulParameter2, ret )
#endif #endif
#ifndef tracePEND_FUNC_CALL_FROM_ISR #ifndef tracePEND_FUNC_CALL_FROM_ISR
#define tracePEND_FUNC_CALL_FROM_ISR(xFunctionToPend, pvParameter1, ulParameter2, ret) #define tracePEND_FUNC_CALL_FROM_ISR( xFunctionToPend, pvParameter1, ulParameter2, ret )
#endif #endif
#ifndef traceQUEUE_REGISTRY_ADD #ifndef traceQUEUE_REGISTRY_ADD
#define traceQUEUE_REGISTRY_ADD(xQueue, pcQueueName) #define traceQUEUE_REGISTRY_ADD( xQueue, pcQueueName )
#endif #endif
#ifndef traceTASK_NOTIFY_TAKE_BLOCK #ifndef traceTASK_NOTIFY_TAKE_BLOCK
@@ -875,30 +888,30 @@ extern "C" {
#endif #endif
#ifndef configSTACK_DEPTH_TYPE #ifndef configSTACK_DEPTH_TYPE
/* Defaults to uint16_t for backward compatibility, but can be overridden /* Defaults to uint16_t for backward compatibility, but can be overridden
in FreeRTOSConfig.h if uint16_t is too restrictive. */ * in FreeRTOSConfig.h if uint16_t is too restrictive. */
#define configSTACK_DEPTH_TYPE uint16_t #define configSTACK_DEPTH_TYPE uint16_t
#endif #endif
#ifndef configMESSAGE_BUFFER_LENGTH_TYPE #ifndef configMESSAGE_BUFFER_LENGTH_TYPE
/* Defaults to size_t for backward compatibility, but can be overridden /* Defaults to size_t for backward compatibility, but can be overridden
in FreeRTOSConfig.h if lengths will always be less than the number of bytes * in FreeRTOSConfig.h if lengths will always be less than the number of bytes
in a size_t. */ * in a size_t. */
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t #define configMESSAGE_BUFFER_LENGTH_TYPE size_t
#endif #endif
/* Sanity check the configuration. */ /* Sanity check the configuration. */
#if( configUSE_TICKLESS_IDLE != 0 ) #if ( configUSE_TICKLESS_IDLE != 0 )
#if( INCLUDE_vTaskSuspend != 1 ) #if ( INCLUDE_vTaskSuspend != 1 )
#error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0 #error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0
#endif /* INCLUDE_vTaskSuspend */ #endif /* INCLUDE_vTaskSuspend */
#endif /* configUSE_TICKLESS_IDLE */ #endif /* configUSE_TICKLESS_IDLE */
#if( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) ) #if ( ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 0 ) )
#error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1. #error configSUPPORT_STATIC_ALLOCATION and configSUPPORT_DYNAMIC_ALLOCATION cannot both be 0, but can both be 1.
#endif #endif
#if( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) ) #if ( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) )
#error configUSE_MUTEXES must be set to 1 to use recursive mutexes #error configUSE_MUTEXES must be set to 1 to use recursive mutexes
#endif #endif
@@ -906,52 +919,56 @@ extern "C" {
#define configINITIAL_TICK_COUNT 0 #define configINITIAL_TICK_COUNT 0
#endif #endif
#if( portTICK_TYPE_IS_ATOMIC == 0 ) #if ( portTICK_TYPE_IS_ATOMIC == 0 )
/* Either variables of tick type cannot be read atomically, or /* Either variables of tick type cannot be read atomically, or
portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when * portTICK_TYPE_IS_ATOMIC was not set - map the critical sections used when
the tick count is returned to the standard critical section macros. */ * the tick count is returned to the standard critical section macros. */
#define portTICK_TYPE_ENTER_CRITICAL(mux) portENTER_CRITICAL(mux) #define portTICK_TYPE_ENTER_CRITICAL(mux) portENTER_CRITICAL(mux)
#define portTICK_TYPE_EXIT_CRITICAL(mux) portEXIT_CRITICAL(mux) #define portTICK_TYPE_EXIT_CRITICAL(mux) portEXIT_CRITICAL(mux)
#define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR() #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() portSET_INTERRUPT_MASK_FROM_ISR()
#define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) ) #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) portCLEAR_INTERRUPT_MASK_FROM_ISR( ( x ) )
#else #else
/* The tick type can be read atomically, so critical sections used when the
tick count is returned can be defined away. */ /* The tick type can be read atomically, so critical sections used when the
* tick count is returned can be defined away. */
#define portTICK_TYPE_ENTER_CRITICAL() #define portTICK_TYPE_ENTER_CRITICAL()
#define portTICK_TYPE_EXIT_CRITICAL() #define portTICK_TYPE_EXIT_CRITICAL()
#define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0 #define portTICK_TYPE_SET_INTERRUPT_MASK_FROM_ISR() 0
#define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) ( void ) x #define portTICK_TYPE_CLEAR_INTERRUPT_MASK_FROM_ISR( x ) ( void ) x
#endif #endif /* if ( portTICK_TYPE_IS_ATOMIC == 0 ) */
/* Definitions to allow backward compatibility with FreeRTOS versions prior to /* Definitions to allow backward compatibility with FreeRTOS versions prior to
V8 if desired. */ * V8 if desired. */
#ifndef configENABLE_BACKWARD_COMPATIBILITY #ifndef configENABLE_BACKWARD_COMPATIBILITY
#define configENABLE_BACKWARD_COMPATIBILITY 1 #define configENABLE_BACKWARD_COMPATIBILITY 1
#endif #endif
#ifndef configPRINTF #ifndef configPRINTF
/* configPRINTF() was not defined, so define it away to nothing. To use
configPRINTF() then define it as follows (where MyPrintFunction() is
provided by the application writer):
void MyPrintFunction(const char *pcFormat, ... ); /* configPRINTF() was not defined, so define it away to nothing. To use
* configPRINTF() then define it as follows (where MyPrintFunction() is
* provided by the application writer):
*
* void MyPrintFunction(const char *pcFormat, ... );
#define configPRINTF( X ) MyPrintFunction X #define configPRINTF( X ) MyPrintFunction X
*
Then call like a standard printf() function, but placing brackets around * Then call like a standard printf() function, but placing brackets around
all parameters so they are passed as a single parameter. For example: * all parameters so they are passed as a single parameter. For example:
configPRINTF( ("Value = %d", MyVariable) ); */ * configPRINTF( ("Value = %d", MyVariable) ); */
#define configPRINTF( X ) #define configPRINTF( X )
#endif #endif
#ifndef configMAX #ifndef configMAX
/* The application writer has not provided their own MAX macro, so define
the following generic implementation. */ /* The application writer has not provided their own MAX macro, so define
* the following generic implementation. */
#define configMAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) #define configMAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
#endif #endif
#ifndef configMIN #ifndef configMIN
/* The application writer has not provided their own MAX macro, so define
the following generic implementation. */ /* The application writer has not provided their own MAX macro, so define
* the following generic implementation. */
#define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) #define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
#endif #endif
@@ -976,15 +993,15 @@ V8 if desired. */
#define pcQueueGetQueueName pcQueueGetName #define pcQueueGetQueueName pcQueueGetName
#define vTaskGetTaskInfo vTaskGetInfo #define vTaskGetTaskInfo vTaskGetInfo
/* Backward compatibility within the scheduler code only - these definitions /* Backward compatibility within the scheduler code only - these definitions
are not really required but are included for completeness. */ * are not really required but are included for completeness. */
#define tmrTIMER_CALLBACK TimerCallbackFunction_t #define tmrTIMER_CALLBACK TimerCallbackFunction_t
#define pdTASK_CODE TaskFunction_t #define pdTASK_CODE TaskFunction_t
#define xListItem ListItem_t #define xListItem ListItem_t
#define xList List_t #define xList List_t
/* For libraries that break the list data hiding, and access list structure /* For libraries that break the list data hiding, and access list structure
members directly (which is not supposed to be done). */ * members directly (which is not supposed to be done). */
#define pxContainer pvContainer #define pxContainer pvContainer
#endif /* configENABLE_BACKWARD_COMPATIBILITY */ #endif /* configENABLE_BACKWARD_COMPATIBILITY */
@@ -992,38 +1009,38 @@ V8 if desired. */
#define configESP32_PER_TASK_DATA 1 #define configESP32_PER_TASK_DATA 1
#endif #endif
#if( configUSE_ALTERNATIVE_API != 0 ) #if ( configUSE_ALTERNATIVE_API != 0 )
#error The alternative API was deprecated some time ago, and was removed in FreeRTOS V9.0 0 #error The alternative API was deprecated some time ago, and was removed in FreeRTOS V9.0 0
#endif #endif
/* Set configUSE_TASK_FPU_SUPPORT to 0 to omit floating point support even /* Set configUSE_TASK_FPU_SUPPORT to 0 to omit floating point support even
if floating point hardware is otherwise supported by the FreeRTOS port in use. * if floating point hardware is otherwise supported by the FreeRTOS port in use.
This constant is not supported by all FreeRTOS ports that include floating * This constant is not supported by all FreeRTOS ports that include floating
point support. */ * point support. */
#ifndef configUSE_TASK_FPU_SUPPORT #ifndef configUSE_TASK_FPU_SUPPORT
#define configUSE_TASK_FPU_SUPPORT 1 #define configUSE_TASK_FPU_SUPPORT 1
#endif #endif
/* Set configENABLE_MPU to 1 to enable MPU support and 0 to disable it. This is /* Set configENABLE_MPU to 1 to enable MPU support and 0 to disable it. This is
currently used in ARMv8M ports. */ * currently used in ARMv8M ports. */
#ifndef configENABLE_MPU #ifndef configENABLE_MPU
#define configENABLE_MPU 0 #define configENABLE_MPU 0
#endif #endif
/* Set configENABLE_FPU to 1 to enable FPU support and 0 to disable it. This is /* Set configENABLE_FPU to 1 to enable FPU support and 0 to disable it. This is
currently used in ARMv8M ports. */ * currently used in ARMv8M ports. */
#ifndef configENABLE_FPU #ifndef configENABLE_FPU
#define configENABLE_FPU 1 #define configENABLE_FPU 1
#endif #endif
/* Set configENABLE_TRUSTZONE to 1 enable TrustZone support and 0 to disable it. /* Set configENABLE_TRUSTZONE to 1 enable TrustZone support and 0 to disable it.
This is currently used in ARMv8M ports. */ * This is currently used in ARMv8M ports. */
#ifndef configENABLE_TRUSTZONE #ifndef configENABLE_TRUSTZONE
#define configENABLE_TRUSTZONE 1 #define configENABLE_TRUSTZONE 1
#endif #endif
/* Set configRUN_FREERTOS_SECURE_ONLY to 1 to run the FreeRTOS ARMv8M port on /* Set configRUN_FREERTOS_SECURE_ONLY to 1 to run the FreeRTOS ARMv8M port on
the Secure Side only. */ * the Secure Side only. */
#ifndef configRUN_FREERTOS_SECURE_ONLY #ifndef configRUN_FREERTOS_SECURE_ONLY
#define configRUN_FREERTOS_SECURE_ONLY 0 #define configRUN_FREERTOS_SECURE_ONLY 0
#endif #endif
@@ -1070,7 +1087,8 @@ the Secure Side only. */
* | | | | xTaskCreateRestrictedStatic | | | | * | | | | xTaskCreateRestrictedStatic | | | |
* +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+ * +-----+---------+--------+-----------------------------+-----------------------------------+------------------+-----------+
*/ */
#define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE ( ( ( portUSING_MPU_WRAPPERS == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) || \ #define tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE \
( ( ( portUSING_MPU_WRAPPERS == 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) || \
( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) ) ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) )
/* /*
@@ -1085,12 +1103,12 @@ the Secure Side only. */
*/ */
struct xSTATIC_LIST_ITEM struct xSTATIC_LIST_ITEM
{ {
#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
TickType_t xDummy1; TickType_t xDummy1;
#endif #endif
TickType_t xDummy2; TickType_t xDummy2;
void *pvDummy3[ 4 ]; void * pvDummy3[ 4 ];
#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
TickType_t xDummy4; TickType_t xDummy4;
#endif #endif
}; };
@@ -1099,24 +1117,24 @@ typedef struct xSTATIC_LIST_ITEM StaticListItem_t;
/* See the comments above the struct xSTATIC_LIST_ITEM definition. */ /* See the comments above the struct xSTATIC_LIST_ITEM definition. */
struct xSTATIC_MINI_LIST_ITEM struct xSTATIC_MINI_LIST_ITEM
{ {
#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
TickType_t xDummy1; TickType_t xDummy1;
#endif #endif
TickType_t xDummy2; TickType_t xDummy2;
void *pvDummy3[ 2 ]; void * pvDummy3[ 2 ];
}; };
typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t; typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t;
/* See the comments above the struct xSTATIC_LIST_ITEM definition. */ /* See the comments above the struct xSTATIC_LIST_ITEM definition. */
typedef struct xSTATIC_LIST typedef struct xSTATIC_LIST
{ {
#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
TickType_t xDummy1; TickType_t xDummy1;
#endif #endif
UBaseType_t uxDummy2; UBaseType_t uxDummy2;
void *pvDummy3; void * pvDummy3;
StaticMiniListItem_t xDummy4; StaticMiniListItem_t xDummy4;
#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 )
TickType_t xDummy5; TickType_t xDummy5;
#endif #endif
} StaticList_t; } StaticList_t;
@@ -1136,17 +1154,17 @@ typedef struct xSTATIC_LIST
*/ */
typedef struct xSTATIC_TCB typedef struct xSTATIC_TCB
{ {
void *pxDummy1; void * pxDummy1;
#if ( portUSING_MPU_WRAPPERS == 1 ) #if ( portUSING_MPU_WRAPPERS == 1 )
xMPU_SETTINGS xDummy2; xMPU_SETTINGS xDummy2;
#endif #endif
StaticListItem_t xDummy3[ 2 ]; StaticListItem_t xDummy3[ 2 ];
UBaseType_t uxDummy5; UBaseType_t uxDummy5;
void *pxDummy6; void * pxDummy6;
uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ]; uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ];
BaseType_t xDummyCore; BaseType_t xDummyCore;
#if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) ) #if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
void *pxDummy8; void * pxDummy8;
#endif #endif
#if ( portCRITICAL_NESTING_IN_TCB == 1 ) #if ( portCRITICAL_NESTING_IN_TCB == 1 )
UBaseType_t uxDummy9; UBaseType_t uxDummy9;
@@ -1158,10 +1176,10 @@ typedef struct xSTATIC_TCB
UBaseType_t uxDummy12[ 2 ]; UBaseType_t uxDummy12[ 2 ];
#endif #endif
#if ( configUSE_APPLICATION_TASK_TAG == 1 ) #if ( configUSE_APPLICATION_TASK_TAG == 1 )
void *pxDummy14; void * pxDummy14;
#endif #endif
#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
void *pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; void * pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
#if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS ) #if ( configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS )
void *pvDummyLocalStorageCallBack[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ]; void *pvDummyLocalStorageCallBack[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
#endif #endif
@@ -1180,7 +1198,7 @@ typedef struct xSTATIC_TCB
uint8_t uxDummy20; uint8_t uxDummy20;
#endif #endif
#if( INCLUDE_xTaskAbortDelay == 1 ) #if ( INCLUDE_xTaskAbortDelay == 1 )
uint8_t ucDummy21; uint8_t ucDummy21;
#endif #endif
#if ( configUSE_POSIX_ERRNO == 1 ) #if ( configUSE_POSIX_ERRNO == 1 )
@@ -1204,11 +1222,11 @@ typedef struct xSTATIC_TCB
*/ */
typedef struct xSTATIC_QUEUE typedef struct xSTATIC_QUEUE
{ {
void *pvDummy1[ 3 ]; void * pvDummy1[ 3 ];
union union
{ {
void *pvDummy2; void * pvDummy2;
UBaseType_t uxDummy2; UBaseType_t uxDummy2;
} u; } u;
@@ -1216,12 +1234,12 @@ typedef struct xSTATIC_QUEUE
UBaseType_t uxDummy4[ 3 ]; UBaseType_t uxDummy4[ 3 ];
uint8_t ucDummy5[ 2 ]; uint8_t ucDummy5[ 2 ];
#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
uint8_t ucDummy6; uint8_t ucDummy6;
#endif #endif
#if ( configUSE_QUEUE_SETS == 1 ) #if ( configUSE_QUEUE_SETS == 1 )
void *pvDummy7; void * pvDummy7;
#endif #endif
#if ( configUSE_TRACE_FACILITY == 1 ) #if ( configUSE_TRACE_FACILITY == 1 )
@@ -1253,11 +1271,11 @@ typedef struct xSTATIC_EVENT_GROUP
TickType_t xDummy1; TickType_t xDummy1;
StaticList_t xDummy2; StaticList_t xDummy2;
#if( configUSE_TRACE_FACILITY == 1 ) #if ( configUSE_TRACE_FACILITY == 1 )
UBaseType_t uxDummy3; UBaseType_t uxDummy3;
#endif #endif
#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
uint8_t ucDummy4; uint8_t ucDummy4;
#endif #endif
@@ -1281,31 +1299,31 @@ typedef struct xSTATIC_EVENT_GROUP
*/ */
typedef struct xSTATIC_TIMER typedef struct xSTATIC_TIMER
{ {
void *pvDummy1; void * pvDummy1;
StaticListItem_t xDummy2; StaticListItem_t xDummy2;
TickType_t xDummy3; TickType_t xDummy3;
void *pvDummy5; void * pvDummy5;
TaskFunction_t pvDummy6; TaskFunction_t pvDummy6;
#if( configUSE_TRACE_FACILITY == 1 ) #if ( configUSE_TRACE_FACILITY == 1 )
UBaseType_t uxDummy7; UBaseType_t uxDummy7;
#endif #endif
uint8_t ucDummy8; uint8_t ucDummy8;
} StaticTimer_t; } StaticTimer_t;
/* /*
* In line with software engineering best practice, especially when supplying a * In line with software engineering best practice, especially when supplying a
* library that is likely to change in future versions, FreeRTOS implements a * library that is likely to change in future versions, FreeRTOS implements a
* strict data hiding policy. This means the stream buffer structure used * strict data hiding policy. This means the stream buffer structure used
* internally by FreeRTOS is not accessible to application code. However, if * internally by FreeRTOS is not accessible to application code. However, if
* the application writer wants to statically allocate the memory required to * the application writer wants to statically allocate the memory required to
* create a stream buffer then the size of the stream buffer object needs to be * create a stream buffer then the size of the stream buffer object needs to be
* know. The StaticStreamBuffer_t structure below is provided for this purpose. * know. The StaticStreamBuffer_t structure below is provided for this purpose.
* Its size and alignment requirements are guaranteed to match those of the * Its size and alignment requirements are guaranteed to match those of the
* genuine structure, no matter which architecture is being used, and no matter * genuine structure, no matter which architecture is being used, and no matter
* how the values in FreeRTOSConfig.h are set. Its contents are somewhat * how the values in FreeRTOSConfig.h are set. Its contents are somewhat
* obfuscated in the hope users will recognise that it would be unwise to make * obfuscated in the hope users will recognise that it would be unwise to make
* direct use of the structure members. * direct use of the structure members.
*/ */
typedef struct xSTATIC_STREAM_BUFFER typedef struct xSTATIC_STREAM_BUFFER
{ {
size_t uxDummy1[ 4 ]; size_t uxDummy1[ 4 ];
@@ -1322,8 +1340,10 @@ typedef struct xSTATIC_STREAM_BUFFER
/* Message buffers are built on stream buffers. */ /* Message buffers are built on stream buffers. */
typedef StaticStreamBuffer_t StaticMessageBuffer_t; typedef StaticStreamBuffer_t StaticMessageBuffer_t;
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* *INDENT-ON* */
#endif /* INC_FREERTOS_H */ #endif /* INC_FREERTOS_H */

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,19 +19,18 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
/** /**
* @file atomic.h * @file atomic.h
* @brief FreeRTOS atomic operation support. * @brief FreeRTOS atomic operation support.
* *
* This file implements atomic by disabling interrupts globally. * This file implements atomic functions by disabling interrupts globally.
* Implementation with architecture specific atomic instructions * Implementations with architecture specific atomic instructions can be
* are to be provided under each compiler directory. * provided under each compiler directory.
*/ */
#ifndef ATOMIC_H #ifndef ATOMIC_H
@@ -44,19 +43,23 @@
/* Standard includes. */ /* Standard includes. */
#include <stdint.h> #include <stdint.h>
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* *INDENT-ON* */
/* Port specific definitions -- entering/exiting critical section. /*
* Port specific definitions -- entering/exiting critical section.
* Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h * Refer template -- ./lib/FreeRTOS/portable/Compiler/Arch/portmacro.h
* *
* Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with * Every call to ATOMIC_EXIT_CRITICAL() must be closely paired with
* ATOMIC_ENTER_CRITICAL(). * ATOMIC_ENTER_CRITICAL().
* */ *
*/
#if defined( portSET_INTERRUPT_MASK_FROM_ISR ) #if defined( portSET_INTERRUPT_MASK_FROM_ISR )
/* Nested interrupt scheme is supported in this port. */ /* Nested interrupt scheme is supported in this port. */
#define ATOMIC_ENTER_CRITICAL() \ #define ATOMIC_ENTER_CRITICAL() \
UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR() UBaseType_t uxCriticalSectionType = portSET_INTERRUPT_MASK_FROM_ISR()
@@ -65,17 +68,18 @@ extern "C" {
#else #else
/* Nested interrupt scheme is NOT supported in this port. */ /* Nested interrupt scheme is NOT supported in this port. */
#define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL() #define ATOMIC_ENTER_CRITICAL() portENTER_CRITICAL()
#define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL() #define ATOMIC_EXIT_CRITICAL() portEXIT_CRITICAL()
#endif /* portSET_INTERRUPT_MASK_FROM_ISR() */ #endif /* portSET_INTERRUPT_MASK_FROM_ISR() */
/* Port specific definition -- "always inline". /*
* Inline is compiler specific, and may not always get inlined depending on your optimization level. * Port specific definition -- "always inline".
* Also, inline is considerred as performance optimization for atomic. * Inline is compiler specific, and may not always get inlined depending on your
* Thus, if portFORCE_INLINE is not provided by portmacro.h, instead of resulting error, * optimization level. Also, inline is considered as performance optimization
* simply define it. * for atomic. Thus, if portFORCE_INLINE is not provided by portmacro.h,
* instead of resulting error, simply define it away.
*/ */
#ifndef portFORCE_INLINE #ifndef portFORCE_INLINE
#define portFORCE_INLINE #define portFORCE_INLINE
@@ -91,66 +95,67 @@ extern "C" {
* *
* @brief Performs an atomic compare-and-swap operation on the specified values. * @brief Performs an atomic compare-and-swap operation on the specified values.
* *
* @param[in, out] pDestination Pointer to memory location from where value is * @param[in, out] pulDestination Pointer to memory location from where value is
* to be loaded and checked. * to be loaded and checked.
* @param[in] ulExchange If condition meets, write this value to memory. * @param[in] ulExchange If condition meets, write this value to memory.
* @param[in] ulComparand Swap condition. * @param[in] ulComparand Swap condition.
* *
* @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped. * @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped.
* *
* @note This function only swaps *pDestination with ulExchange, if previous * @note This function only swaps *pulDestination with ulExchange, if previous
* *pDestination value equals ulComparand. * *pulDestination value equals ulComparand.
*/ */
static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( static portFORCE_INLINE uint32_t Atomic_CompareAndSwap_u32( uint32_t volatile * pulDestination,
uint32_t volatile * pDestination,
uint32_t ulExchange, uint32_t ulExchange,
uint32_t ulComparand ) uint32_t ulComparand )
{ {
uint32_t ulReturnValue;
uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
ATOMIC_ENTER_CRITICAL(); ATOMIC_ENTER_CRITICAL();
if ( *pDestination == ulComparand )
{ {
*pDestination = ulExchange; if( *pulDestination == ulComparand )
{
*pulDestination = ulExchange;
ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
} }
else
{
ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
}
}
ATOMIC_EXIT_CRITICAL(); ATOMIC_EXIT_CRITICAL();
return ulReturnValue; return ulReturnValue;
} }
/*-----------------------------------------------------------*/
/** /**
* Atomic swap (pointers) * Atomic swap (pointers)
* *
* @brief Atomically sets the address pointed to by *ppDestination to the value * @brief Atomically sets the address pointed to by *ppvDestination to the value
* of *pExchange. * of *pvExchange.
* *
* @param[in, out] ppDestination Pointer to memory location from where a pointer * @param[in, out] ppvDestination Pointer to memory location from where a pointer
* value is to be loaded and written back to. * value is to be loaded and written back to.
* @param[in] pExchange Pointer value to be written to *ppDestination. * @param[in] pvExchange Pointer value to be written to *ppvDestination.
* *
* @return The initial value of *ppDestination. * @return The initial value of *ppvDestination.
*/ */
static portFORCE_INLINE void * Atomic_SwapPointers_p32( static portFORCE_INLINE void * Atomic_SwapPointers_p32( void * volatile * ppvDestination,
void * volatile * ppDestination, void * pvExchange )
void * pExchange )
{ {
void * pReturnValue; void * pReturnValue;
ATOMIC_ENTER_CRITICAL(); ATOMIC_ENTER_CRITICAL();
{
pReturnValue = *ppDestination; pReturnValue = *ppvDestination;
*ppvDestination = pvExchange;
*ppDestination = pExchange; }
ATOMIC_EXIT_CRITICAL(); ATOMIC_EXIT_CRITICAL();
return pReturnValue; return pReturnValue;
} }
/*-----------------------------------------------------------*/
/** /**
* Atomic compare-and-swap (pointers) * Atomic compare-and-swap (pointers)
@@ -158,30 +163,30 @@ static portFORCE_INLINE void * Atomic_SwapPointers_p32(
* @brief Performs an atomic compare-and-swap operation on the specified pointer * @brief Performs an atomic compare-and-swap operation on the specified pointer
* values. * values.
* *
* @param[in, out] ppDestination Pointer to memory location from where a pointer * @param[in, out] ppvDestination Pointer to memory location from where a pointer
* value is to be loaded and checked. * value is to be loaded and checked.
* @param[in] pExchange If condition meets, write this value to memory. * @param[in] pvExchange If condition meets, write this value to memory.
* @param[in] pComparand Swap condition. * @param[in] pvComparand Swap condition.
* *
* @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped. * @return Unsigned integer of value 1 or 0. 1 for swapped, 0 for not swapped.
* *
* @note This function only swaps *ppDestination with pExchange, if previous * @note This function only swaps *ppvDestination with pvExchange, if previous
* *ppDestination value equals pComparand. * *ppvDestination value equals pvComparand.
*/ */
static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32( void * volatile * ppvDestination,
void * volatile * ppDestination, void * pvExchange,
void * pExchange, void * pComparand ) void * pvComparand )
{ {
uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE; uint32_t ulReturnValue = ATOMIC_COMPARE_AND_SWAP_FAILURE;
ATOMIC_ENTER_CRITICAL(); ATOMIC_ENTER_CRITICAL();
if ( *ppDestination == pComparand )
{ {
*ppDestination = pExchange; if( *ppvDestination == pvComparand )
{
*ppvDestination = pvExchange;
ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS;
} }
}
ATOMIC_EXIT_CRITICAL(); ATOMIC_EXIT_CRITICAL();
return ulReturnValue; return ulReturnValue;
@@ -195,28 +200,27 @@ static portFORCE_INLINE uint32_t Atomic_CompareAndSwapPointers_p32(
* *
* @brief Atomically adds count to the value of the specified pointer points to. * @brief Atomically adds count to the value of the specified pointer points to.
* *
* @param[in,out] pAddend Pointer to memory location from where value is to be * @param[in,out] pulAddend Pointer to memory location from where value is to be
* loaded and written back to. * loaded and written back to.
* @param[in] ulCount Value to be added to *pAddend. * @param[in] ulCount Value to be added to *pulAddend.
* *
* @return previous *pAddend value. * @return previous *pulAddend value.
*/ */
static portFORCE_INLINE uint32_t Atomic_Add_u32( static portFORCE_INLINE uint32_t Atomic_Add_u32( uint32_t volatile * pulAddend,
uint32_t volatile * pAddend,
uint32_t ulCount ) uint32_t ulCount )
{ {
uint32_t ulCurrent; uint32_t ulCurrent;
ATOMIC_ENTER_CRITICAL(); ATOMIC_ENTER_CRITICAL();
{
ulCurrent = *pAddend; ulCurrent = *pulAddend;
*pulAddend += ulCount;
*pAddend += ulCount; }
ATOMIC_EXIT_CRITICAL(); ATOMIC_EXIT_CRITICAL();
return ulCurrent; return ulCurrent;
} }
/*-----------------------------------------------------------*/
/** /**
* Atomic subtract * Atomic subtract
@@ -224,74 +228,72 @@ static portFORCE_INLINE uint32_t Atomic_Add_u32(
* @brief Atomically subtracts count from the value of the specified pointer * @brief Atomically subtracts count from the value of the specified pointer
* pointers to. * pointers to.
* *
* @param[in,out] pAddend Pointer to memory location from where value is to be * @param[in,out] pulAddend Pointer to memory location from where value is to be
* loaded and written back to. * loaded and written back to.
* @param[in] ulCount Value to be subtract from *pAddend. * @param[in] ulCount Value to be subtract from *pulAddend.
* *
* @return previous *pAddend value. * @return previous *pulAddend value.
*/ */
static portFORCE_INLINE uint32_t Atomic_Subtract_u32( static portFORCE_INLINE uint32_t Atomic_Subtract_u32( uint32_t volatile * pulAddend,
uint32_t volatile * pAddend,
uint32_t ulCount ) uint32_t ulCount )
{ {
uint32_t ulCurrent; uint32_t ulCurrent;
ATOMIC_ENTER_CRITICAL(); ATOMIC_ENTER_CRITICAL();
{
ulCurrent = *pAddend; ulCurrent = *pulAddend;
*pulAddend -= ulCount;
*pAddend -= ulCount; }
ATOMIC_EXIT_CRITICAL(); ATOMIC_EXIT_CRITICAL();
return ulCurrent; return ulCurrent;
} }
/*-----------------------------------------------------------*/
/** /**
* Atomic increment * Atomic increment
* *
* @brief Atomically increments the value of the specified pointer points to. * @brief Atomically increments the value of the specified pointer points to.
* *
* @param[in,out] pAddend Pointer to memory location from where value is to be * @param[in,out] pulAddend Pointer to memory location from where value is to be
* loaded and written back to. * loaded and written back to.
* *
* @return *pAddend value before increment. * @return *pulAddend value before increment.
*/ */
static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pAddend ) static portFORCE_INLINE uint32_t Atomic_Increment_u32( uint32_t volatile * pulAddend )
{ {
uint32_t ulCurrent; uint32_t ulCurrent;
ATOMIC_ENTER_CRITICAL(); ATOMIC_ENTER_CRITICAL();
{
ulCurrent = *pAddend; ulCurrent = *pulAddend;
*pulAddend += 1;
*pAddend += 1; }
ATOMIC_EXIT_CRITICAL(); ATOMIC_EXIT_CRITICAL();
return ulCurrent; return ulCurrent;
} }
/*-----------------------------------------------------------*/
/** /**
* Atomic decrement * Atomic decrement
* *
* @brief Atomically decrements the value of the specified pointer points to * @brief Atomically decrements the value of the specified pointer points to
* *
* @param[in,out] pAddend Pointer to memory location from where value is to be * @param[in,out] pulAddend Pointer to memory location from where value is to be
* loaded and written back to. * loaded and written back to.
* *
* @return *pAddend value before decrement. * @return *pulAddend value before decrement.
*/ */
static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAddend ) static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pulAddend )
{ {
uint32_t ulCurrent; uint32_t ulCurrent;
ATOMIC_ENTER_CRITICAL(); ATOMIC_ENTER_CRITICAL();
{
ulCurrent = *pAddend; ulCurrent = *pulAddend;
*pulAddend -= 1;
*pAddend -= 1; }
ATOMIC_EXIT_CRITICAL(); ATOMIC_EXIT_CRITICAL();
return ulCurrent; return ulCurrent;
@@ -304,115 +306,112 @@ static portFORCE_INLINE uint32_t Atomic_Decrement_u32( uint32_t volatile * pAdde
* *
* @brief Performs an atomic OR operation on the specified values. * @brief Performs an atomic OR operation on the specified values.
* *
* @param [in, out] pDestination Pointer to memory location from where value is * @param [in, out] pulDestination Pointer to memory location from where value is
* to be loaded and written back to. * to be loaded and written back to.
* @param [in] ulValue Value to be ORed with *pDestination. * @param [in] ulValue Value to be ORed with *pulDestination.
* *
* @return The original value of *pDestination. * @return The original value of *pulDestination.
*/ */
static portFORCE_INLINE uint32_t Atomic_OR_u32( static portFORCE_INLINE uint32_t Atomic_OR_u32( uint32_t volatile * pulDestination,
uint32_t volatile * pDestination,
uint32_t ulValue ) uint32_t ulValue )
{ {
uint32_t ulCurrent; uint32_t ulCurrent;
ATOMIC_ENTER_CRITICAL(); ATOMIC_ENTER_CRITICAL();
{
ulCurrent = *pDestination; ulCurrent = *pulDestination;
*pulDestination |= ulValue;
*pDestination |= ulValue; }
ATOMIC_EXIT_CRITICAL(); ATOMIC_EXIT_CRITICAL();
return ulCurrent; return ulCurrent;
} }
/*-----------------------------------------------------------*/
/** /**
* Atomic AND * Atomic AND
* *
* @brief Performs an atomic AND operation on the specified values. * @brief Performs an atomic AND operation on the specified values.
* *
* @param [in, out] pDestination Pointer to memory location from where value is * @param [in, out] pulDestination Pointer to memory location from where value is
* to be loaded and written back to. * to be loaded and written back to.
* @param [in] ulValue Value to be ANDed with *pDestination. * @param [in] ulValue Value to be ANDed with *pulDestination.
* *
* @return The original value of *pDestination. * @return The original value of *pulDestination.
*/ */
static portFORCE_INLINE uint32_t Atomic_AND_u32( static portFORCE_INLINE uint32_t Atomic_AND_u32( uint32_t volatile * pulDestination,
uint32_t volatile * pDestination,
uint32_t ulValue ) uint32_t ulValue )
{ {
uint32_t ulCurrent; uint32_t ulCurrent;
ATOMIC_ENTER_CRITICAL(); ATOMIC_ENTER_CRITICAL();
{
ulCurrent = *pDestination; ulCurrent = *pulDestination;
*pulDestination &= ulValue;
*pDestination &= ulValue; }
ATOMIC_EXIT_CRITICAL(); ATOMIC_EXIT_CRITICAL();
return ulCurrent; return ulCurrent;
} }
/*-----------------------------------------------------------*/
/** /**
* Atomic NAND * Atomic NAND
* *
* @brief Performs an atomic NAND operation on the specified values. * @brief Performs an atomic NAND operation on the specified values.
* *
* @param [in, out] pDestination Pointer to memory location from where value is * @param [in, out] pulDestination Pointer to memory location from where value is
* to be loaded and written back to. * to be loaded and written back to.
* @param [in] ulValue Value to be NANDed with *pDestination. * @param [in] ulValue Value to be NANDed with *pulDestination.
* *
* @return The original value of *pDestination. * @return The original value of *pulDestination.
*/ */
static portFORCE_INLINE uint32_t Atomic_NAND_u32( static portFORCE_INLINE uint32_t Atomic_NAND_u32( uint32_t volatile * pulDestination,
uint32_t volatile * pDestination,
uint32_t ulValue ) uint32_t ulValue )
{ {
uint32_t ulCurrent; uint32_t ulCurrent;
ATOMIC_ENTER_CRITICAL(); ATOMIC_ENTER_CRITICAL();
{
ulCurrent = *pDestination; ulCurrent = *pulDestination;
*pulDestination = ~( ulCurrent & ulValue );
*pDestination = ~(ulCurrent & ulValue); }
ATOMIC_EXIT_CRITICAL(); ATOMIC_EXIT_CRITICAL();
return ulCurrent; return ulCurrent;
} }
/*-----------------------------------------------------------*/
/** /**
* Atomic XOR * Atomic XOR
* *
* @brief Performs an atomic XOR operation on the specified values. * @brief Performs an atomic XOR operation on the specified values.
* *
* @param [in, out] pDestination Pointer to memory location from where value is * @param [in, out] pulDestination Pointer to memory location from where value is
* to be loaded and written back to. * to be loaded and written back to.
* @param [in] ulValue Value to be XORed with *pDestination. * @param [in] ulValue Value to be XORed with *pulDestination.
* *
* @return The original value of *pDestination. * @return The original value of *pulDestination.
*/ */
static portFORCE_INLINE uint32_t Atomic_XOR_u32( static portFORCE_INLINE uint32_t Atomic_XOR_u32( uint32_t volatile * pulDestination,
uint32_t volatile * pDestination,
uint32_t ulValue ) uint32_t ulValue )
{ {
uint32_t ulCurrent; uint32_t ulCurrent;
ATOMIC_ENTER_CRITICAL(); ATOMIC_ENTER_CRITICAL();
{
ulCurrent = *pDestination; ulCurrent = *pulDestination;
*pulDestination ^= ulValue;
*pDestination ^= ulValue; }
ATOMIC_EXIT_CRITICAL(); ATOMIC_EXIT_CRITICAL();
return ulCurrent; return ulCurrent;
} }
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* *INDENT-ON* */
#endif /* ATOMIC_H */ #endif /* ATOMIC_H */

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
#ifndef CO_ROUTINE_H #ifndef CO_ROUTINE_H
@@ -34,17 +33,20 @@
#include "list.h" #include "list.h"
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* *INDENT-ON* */
/* Used to hide the implementation of the co-routine control block. The /* Used to hide the implementation of the co-routine control block. The
control block structure however has to be included in the header due to * control block structure however has to be included in the header due to
the macro implementation of the co-routine functionality. */ * the macro implementation of the co-routine functionality. */
typedef void * CoRoutineHandle_t; typedef void * CoRoutineHandle_t;
/* Defines the prototype to which co-routine functions must conform. */ /* Defines the prototype to which co-routine functions must conform. */
typedef void (*crCOROUTINE_CODE)( CoRoutineHandle_t, UBaseType_t ); typedef void (* crCOROUTINE_CODE)( CoRoutineHandle_t,
UBaseType_t );
typedef struct corCoRoutineControlBlock typedef struct corCoRoutineControlBlock
{ {
@@ -57,13 +59,16 @@ typedef struct corCoRoutineControlBlock
} CRCB_t; /* Co-routine control block. Note must be identical in size down to uxPriority with TCB_t. */ } CRCB_t; /* Co-routine control block. Note must be identical in size down to uxPriority with TCB_t. */
/** /**
* @cond
* croutine. h * croutine. h
*<pre> * <pre>
BaseType_t xCoRoutineCreate( * BaseType_t xCoRoutineCreate(
crCOROUTINE_CODE pxCoRoutineCode, * crCOROUTINE_CODE pxCoRoutineCode,
UBaseType_t uxPriority, * UBaseType_t uxPriority,
UBaseType_t uxIndex * UBaseType_t uxIndex
);</pre> * );
* </pre>
* @endcond
* *
* Create a new co-routine and add it to the list of co-routines that are * Create a new co-routine and add it to the list of co-routines that are
* ready to run. * ready to run.
@@ -83,59 +88,65 @@ typedef struct corCoRoutineControlBlock
* list, otherwise an error code defined with ProjDefs.h. * list, otherwise an error code defined with ProjDefs.h.
* *
* Example usage: * Example usage:
<pre> * @code{c}
// Co-routine to be created. * // Co-routine to be created.
void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) * void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
{ * {
// Variables in co-routines must be declared static if they must maintain value across a blocking call. * // Variables in co-routines must be declared static if they must maintain value across a blocking call.
// This may not be necessary for const variables. * // This may not be necessary for const variables.
static const char cLedToFlash[ 2 ] = { 5, 6 }; * static const char cLedToFlash[ 2 ] = { 5, 6 };
static const TickType_t uxFlashRates[ 2 ] = { 200, 400 }; * static const TickType_t uxFlashRates[ 2 ] = { 200, 400 };
*
// Must start every co-routine with a call to crSTART(); * // Must start every co-routine with a call to crSTART();
crSTART( xHandle ); * crSTART( xHandle );
*
for( ;; ) * for( ;; )
{ * {
// This co-routine just delays for a fixed period, then toggles * // This co-routine just delays for a fixed period, then toggles
// an LED. Two co-routines are created using this function, so * // an LED. Two co-routines are created using this function, so
// the uxIndex parameter is used to tell the co-routine which * // the uxIndex parameter is used to tell the co-routine which
// LED to flash and how int32_t to delay. This assumes xQueue has * // LED to flash and how int32_t to delay. This assumes xQueue has
// already been created. * // already been created.
vParTestToggleLED( cLedToFlash[ uxIndex ] ); * vParTestToggleLED( cLedToFlash[ uxIndex ] );
crDELAY( xHandle, uxFlashRates[ uxIndex ] ); * crDELAY( xHandle, uxFlashRates[ uxIndex ] );
} * }
*
// Must end every co-routine with a call to crEND(); * // Must end every co-routine with a call to crEND();
crEND(); * crEND();
} * }
*
// Function that creates two co-routines. * // Function that creates two co-routines.
void vOtherFunction( void ) * void vOtherFunction( void )
{ * {
uint8_t ucParameterToPass; * uint8_t ucParameterToPass;
TaskHandle_t xHandle; * TaskHandle_t xHandle;
*
// Create two co-routines at priority 0. The first is given index 0 * // Create two co-routines at priority 0. The first is given index 0
// so (from the code above) toggles LED 5 every 200 ticks. The second * // so (from the code above) toggles LED 5 every 200 ticks. The second
// is given index 1 so toggles LED 6 every 400 ticks. * // is given index 1 so toggles LED 6 every 400 ticks.
for( uxIndex = 0; uxIndex < 2; uxIndex++ ) * for( uxIndex = 0; uxIndex < 2; uxIndex++ )
{ * {
xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex ); * xCoRoutineCreate( vFlashCoRoutine, 0, uxIndex );
} * }
} * }
</pre> * @endcode
* @cond
* \defgroup xCoRoutineCreate xCoRoutineCreate * \defgroup xCoRoutineCreate xCoRoutineCreate
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex ); BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode,
UBaseType_t uxPriority,
UBaseType_t uxIndex );
/** /**
* @cond
* croutine. h * croutine. h
*<pre> * <pre>
void vCoRoutineSchedule( void );</pre> * void vCoRoutineSchedule( void );
* * </pre>
* @endcond
* Run a co-routine. * Run a co-routine.
* *
* vCoRoutineSchedule() executes the highest priority co-routine that is able * vCoRoutineSchedule() executes the highest priority co-routine that is able
@@ -148,88 +159,105 @@ BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPri
* hook). * hook).
* *
* Example usage: * Example usage:
<pre> * @code{c}
// This idle task hook will schedule a co-routine each time it is called. * // This idle task hook will schedule a co-routine each time it is called.
// The rest of the idle task will execute between co-routine calls. * // The rest of the idle task will execute between co-routine calls.
void vApplicationIdleHook( void ) * void vApplicationIdleHook( void )
{ * {
vCoRoutineSchedule(); * vCoRoutineSchedule();
} * }
*
// Alternatively, if you do not require any other part of the idle task to * // Alternatively, if you do not require any other part of the idle task to
// execute, the idle task hook can call vCoRoutineScheduler() within an * // execute, the idle task hook can call vCoRoutineScheduler() within an
// infinite loop. * // infinite loop.
void vApplicationIdleHook( void ) * void vApplicationIdleHook( void )
{ * {
for( ;; ) * for( ;; )
{ * {
vCoRoutineSchedule(); * vCoRoutineSchedule();
} * }
} * }
</pre> * </pre>
* @endcode
* @cond
* \defgroup vCoRoutineSchedule vCoRoutineSchedule * \defgroup vCoRoutineSchedule vCoRoutineSchedule
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
void vCoRoutineSchedule( void ); void vCoRoutineSchedule( void );
/** /**
* @cond
* croutine. h * croutine. h
* <pre> * <pre>
crSTART( CoRoutineHandle_t xHandle );</pre> * crSTART( CoRoutineHandle_t xHandle );
* </pre>
* @endcond
* *
* This macro MUST always be called at the start of a co-routine function. * This macro MUST always be called at the start of a co-routine function.
* *
* Example usage: * Example usage:
<pre> * @code{c}
// Co-routine to be created. * // Co-routine to be created.
void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) * void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
{ * {
// Variables in co-routines must be declared static if they must maintain value across a blocking call. * // Variables in co-routines must be declared static if they must maintain value across a blocking call.
static int32_t ulAVariable; * static int32_t ulAVariable;
*
// Must start every co-routine with a call to crSTART(); * // Must start every co-routine with a call to crSTART();
crSTART( xHandle ); * crSTART( xHandle );
*
for( ;; ) * for( ;; )
{ * {
// Co-routine functionality goes here. * // Co-routine functionality goes here.
} * }
*
// Must end every co-routine with a call to crEND(); * // Must end every co-routine with a call to crEND();
crEND(); * crEND();
}</pre> * }
* @endcode
* @cond
* \defgroup crSTART crSTART * \defgroup crSTART crSTART
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
#define crSTART( pxCRCB ) switch( ( ( CRCB_t * )( pxCRCB ) )->uxState ) { case 0: #define crSTART( pxCRCB ) \
switch( ( ( CRCB_t * ) ( pxCRCB ) )->uxState ) { \
case 0:
/** /**
* @cond
* croutine. h * croutine. h
* <pre> * <pre>
crEND();</pre> * crEND();
* </pre>
* @endcond
* *
* This macro MUST always be called at the end of a co-routine function. * This macro MUST always be called at the end of a co-routine function.
* *
* Example usage: * Example usage:
<pre> * @code{c}
// Co-routine to be created. * // Co-routine to be created.
void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) * void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
{ * {
// Variables in co-routines must be declared static if they must maintain value across a blocking call. * // Variables in co-routines must be declared static if they must maintain value across a blocking call.
static int32_t ulAVariable; * static int32_t ulAVariable;
*
// Must start every co-routine with a call to crSTART(); * // Must start every co-routine with a call to crSTART();
crSTART( xHandle ); * crSTART( xHandle );
*
for( ;; ) * for( ;; )
{ * {
// Co-routine functionality goes here. * // Co-routine functionality goes here.
} * }
*
// Must end every co-routine with a call to crEND(); * // Must end every co-routine with a call to crEND();
crEND(); * crEND();
}</pre> * }
* @endcode
* @cond
* \defgroup crSTART crSTART * \defgroup crSTART crSTART
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
#define crEND() } #define crEND() }
@@ -238,13 +266,20 @@ void vCoRoutineSchedule( void );
* These macros are intended for internal use by the co-routine implementation * These macros are intended for internal use by the co-routine implementation
* only. The macros should not be used directly by application writers. * only. The macros should not be used directly by application writers.
*/ */
#define crSET_STATE0( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2): #define crSET_STATE0( xHandle ) \
#define crSET_STATE1( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1): ( ( CRCB_t * ) ( xHandle ) )->uxState = ( __LINE__ * 2 ); return; \
case ( __LINE__ * 2 ):
#define crSET_STATE1( xHandle ) \
( ( CRCB_t * ) ( xHandle ) )->uxState = ( ( __LINE__ * 2 ) + 1 ); return; \
case ( ( __LINE__ * 2 ) + 1 ):
/** /**
* @cond
* croutine. h * croutine. h
*<pre> * <pre>
crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay );</pre> * crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay );
* </pre>
* @endcond
* *
* Delay a co-routine for a fixed period of time. * Delay a co-routine for a fixed period of time.
* *
@@ -261,30 +296,33 @@ void vCoRoutineSchedule( void );
* can be used to convert ticks to milliseconds. * can be used to convert ticks to milliseconds.
* *
* Example usage: * Example usage:
<pre> * @code{c}
// Co-routine to be created. * // Co-routine to be created.
void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) * void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
{ * {
// Variables in co-routines must be declared static if they must maintain value across a blocking call. * // Variables in co-routines must be declared static if they must maintain value across a blocking call.
// This may not be necessary for const variables. * // This may not be necessary for const variables.
// We are to delay for 200ms. * // We are to delay for 200ms.
static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS; * static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS;
*
// Must start every co-routine with a call to crSTART(); * // Must start every co-routine with a call to crSTART();
crSTART( xHandle ); * crSTART( xHandle );
*
for( ;; ) * for( ;; )
{ * {
// Delay for 200ms. * // Delay for 200ms.
crDELAY( xHandle, xDelayTime ); * crDELAY( xHandle, xDelayTime );
*
// Do something here. * // Do something here.
} * }
*
// Must end every co-routine with a call to crEND(); * // Must end every co-routine with a call to crEND();
crEND(); * crEND();
}</pre> * }
* @endcode
* @cond
* \defgroup crDELAY crDELAY * \defgroup crDELAY crDELAY
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
#define crDELAY( xHandle, xTicksToDelay ) \ #define crDELAY( xHandle, xTicksToDelay ) \
@@ -295,14 +333,17 @@ void vCoRoutineSchedule( void );
crSET_STATE0( ( xHandle ) ); crSET_STATE0( ( xHandle ) );
/** /**
* @cond
* <pre> * <pre>
crQUEUE_SEND( * crQUEUE_SEND(
CoRoutineHandle_t xHandle, * CoRoutineHandle_t xHandle,
QueueHandle_t pxQueue, * QueueHandle_t pxQueue,
void *pvItemToQueue, * void *pvItemToQueue,
TickType_t xTicksToWait, * TickType_t xTicksToWait,
BaseType_t *pxResult * BaseType_t *pxResult
)</pre> * )
* </pre>
* @endcond
* *
* The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine
* equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks.
@@ -342,44 +383,47 @@ void vCoRoutineSchedule( void );
* error defined within ProjDefs.h. * error defined within ProjDefs.h.
* *
* Example usage: * Example usage:
<pre> * @code{c}
// Co-routine function that blocks for a fixed period then posts a number onto * // Co-routine function that blocks for a fixed period then posts a number onto
// a queue. * // a queue.
static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) * static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
{ * {
// Variables in co-routines must be declared static if they must maintain value across a blocking call. * // Variables in co-routines must be declared static if they must maintain value across a blocking call.
static BaseType_t xNumberToPost = 0; * static BaseType_t xNumberToPost = 0;
static BaseType_t xResult; * static BaseType_t xResult;
*
// Co-routines must begin with a call to crSTART(). * // Co-routines must begin with a call to crSTART().
crSTART( xHandle ); * crSTART( xHandle );
*
for( ;; ) * for( ;; )
{ * {
// This assumes the queue has already been created. * // This assumes the queue has already been created.
crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult ); * crQUEUE_SEND( xHandle, xCoRoutineQueue, &xNumberToPost, NO_DELAY, &xResult );
*
if( xResult != pdPASS ) * if( xResult != pdPASS )
{ * {
// The message was not posted! * // The message was not posted!
} * }
*
// Increment the number to be posted onto the queue. * // Increment the number to be posted onto the queue.
xNumberToPost++; * xNumberToPost++;
*
// Delay for 100 ticks. * // Delay for 100 ticks.
crDELAY( xHandle, 100 ); * crDELAY( xHandle, 100 );
} * }
*
// Co-routines must end with a call to crEND(). * // Co-routines must end with a call to crEND().
crEND(); * crEND();
}</pre> * }
* @endcode
* @cond
* \defgroup crQUEUE_SEND crQUEUE_SEND * \defgroup crQUEUE_SEND crQUEUE_SEND
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \ #define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \
{ \ { \
*( pxResult ) = xQueueCRSend( ( pxQueue) , ( pvItemToQueue) , ( xTicksToWait ) ); \ *( pxResult ) = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), ( xTicksToWait ) ); \
if( *( pxResult ) == errQUEUE_BLOCKED ) \ if( *( pxResult ) == errQUEUE_BLOCKED ) \
{ \ { \
crSET_STATE0( ( xHandle ) ); \ crSET_STATE0( ( xHandle ) ); \
@@ -390,18 +434,21 @@ void vCoRoutineSchedule( void );
crSET_STATE1( ( xHandle ) ); \ crSET_STATE1( ( xHandle ) ); \
*pxResult = pdPASS; \ *pxResult = pdPASS; \
} \ } \
} }
/** /**
* @cond
* croutine. h * croutine. h
* <pre> * <pre>
crQUEUE_RECEIVE( * crQUEUE_RECEIVE(
CoRoutineHandle_t xHandle, * CoRoutineHandle_t xHandle,
QueueHandle_t pxQueue, * QueueHandle_t pxQueue,
void *pvBuffer, * void *pvBuffer,
TickType_t xTicksToWait, * TickType_t xTicksToWait,
BaseType_t *pxResult * BaseType_t *pxResult
)</pre> * )
* </pre>
* @endcond
* *
* The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine
* equivalent to the xQueueSend() and xQueueReceive() functions used by tasks. * equivalent to the xQueueSend() and xQueueReceive() functions used by tasks.
@@ -440,58 +487,65 @@ void vCoRoutineSchedule( void );
* an error code as defined within ProjDefs.h. * an error code as defined within ProjDefs.h.
* *
* Example usage: * Example usage:
<pre> * @code{c}
// A co-routine receives the number of an LED to flash from a queue. It * // A co-routine receives the number of an LED to flash from a queue. It
// blocks on the queue until the number is received. * // blocks on the queue until the number is received.
static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) * static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
{ * {
// Variables in co-routines must be declared static if they must maintain value across a blocking call. * // Variables in co-routines must be declared static if they must maintain value across a blocking call.
static BaseType_t xResult; * static BaseType_t xResult;
static UBaseType_t uxLEDToFlash; * static UBaseType_t uxLEDToFlash;
*
// All co-routines must start with a call to crSTART(). * // All co-routines must start with a call to crSTART().
crSTART( xHandle ); * crSTART( xHandle );
*
for( ;; ) * for( ;; )
{ * {
// Wait for data to become available on the queue. * // Wait for data to become available on the queue.
crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult ); * crQUEUE_RECEIVE( xHandle, xCoRoutineQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
*
if( xResult == pdPASS ) * if( xResult == pdPASS )
{ * {
// We received the LED to flash - flash it! * // We received the LED to flash - flash it!
vParTestToggleLED( uxLEDToFlash ); * vParTestToggleLED( uxLEDToFlash );
} * }
} * }
*
crEND(); * crEND();
}</pre> * }
* </pre>
* @endcode
* @cond
* \defgroup crQUEUE_RECEIVE crQUEUE_RECEIVE * \defgroup crQUEUE_RECEIVE crQUEUE_RECEIVE
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \ #define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \
{ \ { \
*( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), ( xTicksToWait ) ); \ *( pxResult ) = xQueueCRReceive( ( pxQueue ), ( pvBuffer ), ( xTicksToWait ) ); \
if( *( pxResult ) == errQUEUE_BLOCKED ) \ if( *( pxResult ) == errQUEUE_BLOCKED ) \
{ \ { \
crSET_STATE0( ( xHandle ) ); \ crSET_STATE0( ( xHandle ) ); \
*( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), 0 ); \ *( pxResult ) = xQueueCRReceive( ( pxQueue ), ( pvBuffer ), 0 ); \
} \ } \
if( *( pxResult ) == errQUEUE_YIELD ) \ if( *( pxResult ) == errQUEUE_YIELD ) \
{ \ { \
crSET_STATE1( ( xHandle ) ); \ crSET_STATE1( ( xHandle ) ); \
*( pxResult ) = pdPASS; \ *( pxResult ) = pdPASS; \
} \ } \
} }
/** /**
* @cond
* croutine. h * croutine. h
* <pre> * <pre>
crQUEUE_SEND_FROM_ISR( * crQUEUE_SEND_FROM_ISR(
QueueHandle_t pxQueue, * QueueHandle_t pxQueue,
void *pvItemToQueue, * void *pvItemToQueue,
BaseType_t xCoRoutinePreviouslyWoken * BaseType_t xCoRoutinePreviouslyWoken
)</pre> * )
* </pre>
* @endcond
* *
* The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the
* co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR()
@@ -526,69 +580,76 @@ void vCoRoutineSchedule( void );
* the ISR. * the ISR.
* *
* Example usage: * Example usage:
<pre> * @code{c}
// A co-routine that blocks on a queue waiting for characters to be received. * // A co-routine that blocks on a queue waiting for characters to be received.
static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) * static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
{ * {
char cRxedChar; * char cRxedChar;
BaseType_t xResult; * BaseType_t xResult;
*
// All co-routines must start with a call to crSTART(). * // All co-routines must start with a call to crSTART().
crSTART( xHandle ); * crSTART( xHandle );
*
for( ;; ) * for( ;; )
{ * {
// Wait for data to become available on the queue. This assumes the * // Wait for data to become available on the queue. This assumes the
// queue xCommsRxQueue has already been created! * // queue xCommsRxQueue has already been created!
crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult ); * crQUEUE_RECEIVE( xHandle, xCommsRxQueue, &uxLEDToFlash, portMAX_DELAY, &xResult );
*
// Was a character received? * // Was a character received?
if( xResult == pdPASS ) * if( xResult == pdPASS )
{ * {
// Process the character here. * // Process the character here.
} * }
} * }
*
// All co-routines must end with a call to crEND(). * // All co-routines must end with a call to crEND().
crEND(); * crEND();
} * }
*
// An ISR that uses a queue to send characters received on a serial port to * // An ISR that uses a queue to send characters received on a serial port to
// a co-routine. * // a co-routine.
void vUART_ISR( void ) * void vUART_ISR( void )
{ * {
char cRxedChar; * char cRxedChar;
BaseType_t xCRWokenByPost = pdFALSE; * BaseType_t xCRWokenByPost = pdFALSE;
*
// We loop around reading characters until there are none left in the UART. * // We loop around reading characters until there are none left in the UART.
while( UART_RX_REG_NOT_EMPTY() ) * while( UART_RX_REG_NOT_EMPTY() )
{ * {
// Obtain the character from the UART. * // Obtain the character from the UART.
cRxedChar = UART_RX_REG; * cRxedChar = UART_RX_REG;
*
// Post the character onto a queue. xCRWokenByPost will be pdFALSE * // Post the character onto a queue. xCRWokenByPost will be pdFALSE
// the first time around the loop. If the post causes a co-routine * // the first time around the loop. If the post causes a co-routine
// to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE. * // to be woken (unblocked) then xCRWokenByPost will be set to pdTRUE.
// In this manner we can ensure that if more than one co-routine is * // In this manner we can ensure that if more than one co-routine is
// blocked on the queue only one is woken by this ISR no matter how * // blocked on the queue only one is woken by this ISR no matter how
// many characters are posted to the queue. * // many characters are posted to the queue.
xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost ); * xCRWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsRxQueue, &cRxedChar, xCRWokenByPost );
} * }
}</pre> * }
* @endcode
* @cond
* \defgroup crQUEUE_SEND_FROM_ISR crQUEUE_SEND_FROM_ISR * \defgroup crQUEUE_SEND_FROM_ISR crQUEUE_SEND_FROM_ISR
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) ) #define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) \
xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) )
/** /**
* @cond
* croutine. h * croutine. h
* <pre> * <pre>
crQUEUE_SEND_FROM_ISR( * crQUEUE_SEND_FROM_ISR(
QueueHandle_t pxQueue, * QueueHandle_t pxQueue,
void *pvBuffer, * void *pvBuffer,
BaseType_t * pxCoRoutineWoken * BaseType_t * pxCoRoutineWoken
)</pre> * )
* </pre>
* @endcond
* *
* The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the
* co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR() * co-routine equivalent to the xQueueSendFromISR() and xQueueReceiveFromISR()
@@ -623,75 +684,79 @@ void vCoRoutineSchedule( void );
* pdFALSE. * pdFALSE.
* *
* Example usage: * Example usage:
<pre> * @code{c}
// A co-routine that posts a character to a queue then blocks for a fixed * // A co-routine that posts a character to a queue then blocks for a fixed
// period. The character is incremented each time. * // period. The character is incremented each time.
static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) * static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )
{ * {
// cChar holds its value while this co-routine is blocked and must therefore * // cChar holds its value while this co-routine is blocked and must therefore
// be declared static. * // be declared static.
static char cCharToTx = 'a'; * static char cCharToTx = 'a';
BaseType_t xResult; * BaseType_t xResult;
*
// All co-routines must start with a call to crSTART(). * // All co-routines must start with a call to crSTART().
crSTART( xHandle ); * crSTART( xHandle );
*
for( ;; ) * for( ;; )
{ * {
// Send the next character to the queue. * // Send the next character to the queue.
crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult ); * crQUEUE_SEND( xHandle, xCoRoutineQueue, &cCharToTx, NO_DELAY, &xResult );
*
if( xResult == pdPASS ) * if( xResult == pdPASS )
{ * {
// The character was successfully posted to the queue. * // The character was successfully posted to the queue.
} * }
else * else
{ * {
// Could not post the character to the queue. * // Could not post the character to the queue.
} * }
*
// Enable the UART Tx interrupt to cause an interrupt in this * // Enable the UART Tx interrupt to cause an interrupt in this
// hypothetical UART. The interrupt will obtain the character * // hypothetical UART. The interrupt will obtain the character
// from the queue and send it. * // from the queue and send it.
ENABLE_RX_INTERRUPT(); * ENABLE_RX_INTERRUPT();
*
// Increment to the next character then block for a fixed period. * // Increment to the next character then block for a fixed period.
// cCharToTx will maintain its value across the delay as it is * // cCharToTx will maintain its value across the delay as it is
// declared static. * // declared static.
cCharToTx++; * cCharToTx++;
if( cCharToTx > 'x' ) * if( cCharToTx > 'x' )
{ * {
cCharToTx = 'a'; * cCharToTx = 'a';
} * }
crDELAY( 100 ); * crDELAY( 100 );
} * }
*
// All co-routines must end with a call to crEND(). * // All co-routines must end with a call to crEND().
crEND(); * crEND();
} * }
*
// An ISR that uses a queue to receive characters to send on a UART. * // An ISR that uses a queue to receive characters to send on a UART.
void vUART_ISR( void ) * void vUART_ISR( void )
{ * {
char cCharToTx; * char cCharToTx;
BaseType_t xCRWokenByPost = pdFALSE; * BaseType_t xCRWokenByPost = pdFALSE;
*
while( UART_TX_REG_EMPTY() ) * while( UART_TX_REG_EMPTY() )
{ * {
// Are there any characters in the queue waiting to be sent? * // Are there any characters in the queue waiting to be sent?
// xCRWokenByPost will automatically be set to pdTRUE if a co-routine * // xCRWokenByPost will automatically be set to pdTRUE if a co-routine
// is woken by the post - ensuring that only a single co-routine is * // is woken by the post - ensuring that only a single co-routine is
// woken no matter how many times we go around this loop. * // woken no matter how many times we go around this loop.
if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) ) * if( crQUEUE_RECEIVE_FROM_ISR( pxQueue, &cCharToTx, &xCRWokenByPost ) )
{ * {
SEND_CHARACTER( cCharToTx ); * SEND_CHARACTER( cCharToTx );
} * }
} * }
}</pre> * }
* @endcode
* @cond
* \defgroup crQUEUE_RECEIVE_FROM_ISR crQUEUE_RECEIVE_FROM_ISR * \defgroup crQUEUE_RECEIVE_FROM_ISR crQUEUE_RECEIVE_FROM_ISR
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) ) #define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) \
xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) )
/* /*
* This function is intended for internal use by the co-routine macros only. * This function is intended for internal use by the co-routine macros only.
@@ -702,7 +767,8 @@ void vCoRoutineSchedule( void );
* Removes the current co-routine from its ready list and places it in the * Removes the current co-routine from its ready list and places it in the
* appropriate delayed list. * appropriate delayed list.
*/ */
void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList ); void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay,
List_t * pxEventList );
/* /*
* This function is intended for internal use by the queue implementation only. * This function is intended for internal use by the queue implementation only.
@@ -711,10 +777,12 @@ void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList )
* Removes the highest priority co-routine from the event list and places it in * Removes the highest priority co-routine from the event list and places it in
* the pending ready list. * the pending ready list.
*/ */
BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList ); BaseType_t xCoRoutineRemoveFromEventList( const List_t * pxEventList );
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* *INDENT-ON* */
#endif /* CO_ROUTINE_H */ #endif /* CO_ROUTINE_H */

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
#ifndef DEPRECATED_DEFINITIONS_H #ifndef DEPRECATED_DEFINITIONS_H
@@ -30,22 +29,22 @@
/* Each FreeRTOS port has a unique portmacro.h header file. Originally a /* Each FreeRTOS port has a unique portmacro.h header file. Originally a
pre-processor definition was used to ensure the pre-processor found the correct * pre-processor definition was used to ensure the pre-processor found the correct
portmacro.h file for the port being used. That scheme was deprecated in favour * portmacro.h file for the port being used. That scheme was deprecated in favour
of setting the compiler's include path such that it found the correct * of setting the compiler's include path such that it found the correct
portmacro.h file - removing the need for the constant and allowing the * portmacro.h file - removing the need for the constant and allowing the
portmacro.h file to be located anywhere in relation to the port being used. The * portmacro.h file to be located anywhere in relation to the port being used. The
definitions below remain in the code for backward compatibility only. New * definitions below remain in the code for backward compatibility only. New
projects should not use them. */ * projects should not use them. */
#ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT #ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT
#include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h" #include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h"
typedef void ( __interrupt __far *pxISR )(); typedef void ( __interrupt __far * pxISR )();
#endif #endif
#ifdef OPEN_WATCOM_FLASH_LITE_186_PORT #ifdef OPEN_WATCOM_FLASH_LITE_186_PORT
#include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h" #include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h"
typedef void ( __interrupt __far *pxISR )(); typedef void ( __interrupt __far * pxISR )();
#endif #endif
#ifdef GCC_MEGA_AVR #ifdef GCC_MEGA_AVR
@@ -209,19 +208,21 @@ projects should not use them. */
#endif #endif
#ifdef BCC_INDUSTRIAL_PC_PORT #ifdef BCC_INDUSTRIAL_PC_PORT
/* A short file name has to be used in place of the normal
FreeRTOSConfig.h when using the Borland compiler. */ /* A short file name has to be used in place of the normal
* FreeRTOSConfig.h when using the Borland compiler. */
#include "frconfig.h" #include "frconfig.h"
#include "..\portable\BCC\16BitDOS\PC\prtmacro.h" #include "..\portable\BCC\16BitDOS\PC\prtmacro.h"
typedef void ( __interrupt __far *pxISR )(); typedef void ( __interrupt __far * pxISR )();
#endif #endif
#ifdef BCC_FLASH_LITE_186_PORT #ifdef BCC_FLASH_LITE_186_PORT
/* A short file name has to be used in place of the normal
FreeRTOSConfig.h when using the Borland compiler. */ /* A short file name has to be used in place of the normal
* FreeRTOSConfig.h when using the Borland compiler. */
#include "frconfig.h" #include "frconfig.h"
#include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h" #include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h"
typedef void ( __interrupt __far *pxISR )(); typedef void ( __interrupt __far * pxISR )();
#endif #endif
#ifdef __GNUC__ #ifdef __GNUC__

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
#ifndef EVENT_GROUPS_H #ifndef EVENT_GROUPS_H
@@ -35,9 +34,11 @@
/* FreeRTOS includes. */ /* FreeRTOS includes. */
#include "timers.h" #include "timers.h"
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* *INDENT-ON* */
/** /**
* An event group is a collection of bits to which an application can assign a * An event group is a collection of bits to which an application can assign a
@@ -63,6 +64,9 @@ extern "C" {
* used to create a synchronisation point between multiple tasks (a * used to create a synchronisation point between multiple tasks (a
* 'rendezvous'). * 'rendezvous').
* *
* @cond
* \defgroup EventGroup EventGroup
* @endcond
*/ */
@@ -74,7 +78,9 @@ extern "C" {
* xEventGroupCreate() returns an EventGroupHandle_t variable that can then * xEventGroupCreate() returns an EventGroupHandle_t variable that can then
* be used as a parameter to other event group functions. * be used as a parameter to other event group functions.
* *
* @cond
* \defgroup EventGroupHandle_t EventGroupHandle_t * \defgroup EventGroupHandle_t EventGroupHandle_t
* @endcond
* \ingroup EventGroup * \ingroup EventGroup
*/ */
struct EventGroupDef_t; struct EventGroupDef_t;
@@ -86,13 +92,20 @@ typedef void * EventGroupHandle_t;
* number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1, * number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1,
* 32 bits if set to 0. * 32 bits if set to 0.
* *
* @cond
* \defgroup EventBits_t EventBits_t * \defgroup EventBits_t EventBits_t
* @endcond
* \ingroup EventGroup * \ingroup EventGroup
*/ */
typedef TickType_t EventBits_t; typedef TickType_t EventBits_t;
/** /**
* * @cond
* event_groups.h
* <pre>
* EventGroupHandle_t xEventGroupCreate( void );
* </pre>
* @endcond
* *
* Create a new event group. * Create a new event group.
* *
@@ -100,7 +113,7 @@ typedef TickType_t EventBits_t;
* block of memory, in which the event group's structure is stored. If an event * block of memory, in which the event group's structure is stored. If an event
* groups is created using xEventGroupCreate() then the required memory is * groups is created using xEventGroupCreate() then the required memory is
* automatically dynamically allocated inside the xEventGroupCreate() function. * automatically dynamically allocated inside the xEventGroupCreate() function.
* (see http://www.freertos.org/a00111.html). If an event group is created * (see https://www.FreeRTOS.org/a00111.html). If an event group is created
* using xEventGroupCreateStatic() then the application writer must instead * using xEventGroupCreateStatic() then the application writer must instead
* provide the memory that will get used by the event group. * provide the memory that will get used by the event group.
* xEventGroupCreateStatic() therefore allows an event group to be created * xEventGroupCreateStatic() therefore allows an event group to be created
@@ -116,7 +129,7 @@ typedef TickType_t EventBits_t;
* *
* @return If the event group was created then a handle to the event group is * @return If the event group was created then a handle to the event group is
* returned. If there was insufficient FreeRTOS heap available to create the * returned. If there was insufficient FreeRTOS heap available to create the
* event group then NULL is returned. See http://www.freertos.org/a00111.html * event group then NULL is returned. See https://www.FreeRTOS.org/a00111.html
* *
* Example usage: * Example usage:
* @code{c} * @code{c}
@@ -137,20 +150,30 @@ typedef TickType_t EventBits_t;
* // The event group was created. * // The event group was created.
* } * }
* @endcode * @endcode
* @cond
* \defgroup xEventGroupCreate xEventGroupCreate
* @endcond
* \ingroup EventGroup * \ingroup EventGroup
*/ */
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION; EventGroupHandle_t xEventGroupCreate( void ) PRIVILEGED_FUNCTION;
#endif #endif
/** /**
* @cond
* event_groups.h
* <pre>
* EventGroupHandle_t xEventGroupCreateStatic( EventGroupHandle_t * pxEventGroupBuffer );
* </pre>
* @endcond
*
* Create a new event group. * Create a new event group.
* *
* Internally, within the FreeRTOS implementation, event groups use a [small] * Internally, within the FreeRTOS implementation, event groups use a [small]
* block of memory, in which the event group's structure is stored. If an event * block of memory, in which the event group's structure is stored. If an event
* groups is created using xEventGroupCreate() then the required memory is * groups is created using xEventGroupCreate() then the required memory is
* automatically dynamically allocated inside the xEventGroupCreate() function. * automatically dynamically allocated inside the xEventGroupCreate() function.
* (see http://www.freertos.org/a00111.html). If an event group is created * (see https://www.FreeRTOS.org/a00111.html). If an event group is created
* using xEventGroupCreateStatic() then the application writer must instead * using xEventGroupCreateStatic() then the application writer must instead
* provide the memory that will get used by the event group. * provide the memory that will get used by the event group.
* xEventGroupCreateStatic() therefore allows an event group to be created * xEventGroupCreateStatic() therefore allows an event group to be created
@@ -187,11 +210,22 @@ typedef TickType_t EventBits_t;
* xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer ); * xEventGroup = xEventGroupCreateStatic( &xEventGroupBuffer );
* @endcode * @endcode
*/ */
#if( configSUPPORT_STATIC_ALLOCATION == 1 ) #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
EventGroupHandle_t xEventGroupCreateStatic( StaticEventGroup_t *pxEventGroupBuffer ) PRIVILEGED_FUNCTION; EventGroupHandle_t xEventGroupCreateStatic( StaticEventGroup_t * pxEventGroupBuffer ) PRIVILEGED_FUNCTION;
#endif #endif
/** /**
* @cond
* event_groups.h
* <pre>
* EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
* const EventBits_t uxBitsToWaitFor,
* const BaseType_t xClearOnExit,
* const BaseType_t xWaitForAllBits,
* const TickType_t xTicksToWait );
* </pre>
* @endcond
*
* [Potentially] block to wait for one or more bits to be set within a * [Potentially] block to wait for one or more bits to be set within a
* previously created event group. * previously created event group.
* *
@@ -235,8 +269,8 @@ typedef TickType_t EventBits_t;
* *
* Example usage: * Example usage:
* @code{c} * @code{c}
* #define BIT_0 ( 1 << 0 ) * \#define BIT_0 ( 1 << 0 )
* #define BIT_4 ( 1 << 4 ) * \#define BIT_4 ( 1 << 4 )
* *
* void aFunction( EventGroupHandle_t xEventGroup ) * void aFunction( EventGroupHandle_t xEventGroup )
* { * {
@@ -270,12 +304,25 @@ typedef TickType_t EventBits_t;
* // without either BIT_0 or BIT_4 becoming set. * // without either BIT_0 or BIT_4 becoming set.
* } * }
* } * }
* @endcode{c} * @endcode
* @cond
* \defgroup xEventGroupWaitBits xEventGroupWaitBits
* @endcond
* \ingroup EventGroup * \ingroup EventGroup
*/ */
EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToWaitFor, const BaseType_t xClearOnExit, const BaseType_t xWaitForAllBits, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToWaitFor,
const BaseType_t xClearOnExit,
const BaseType_t xWaitForAllBits,
TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* event_groups.h
* <pre>
* EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear );
* </pre>
* @endcond
* *
* Clear bits within an event group. This function cannot be called from an * Clear bits within an event group. This function cannot be called from an
* interrupt. * interrupt.
@@ -290,8 +337,8 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits
* *
* Example usage: * Example usage:
* @code{c} * @code{c}
* #define BIT_0 ( 1 << 0 ) * \#define BIT_0 ( 1 << 0 )
* #define BIT_4 ( 1 << 4 ) * \#define BIT_4 ( 1 << 4 )
* *
* void aFunction( EventGroupHandle_t xEventGroup ) * void aFunction( EventGroupHandle_t xEventGroup )
* { * {
@@ -323,11 +370,21 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup, const EventBits
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xEventGroupClearBits xEventGroupClearBits
* @endcond
* \ingroup EventGroup * \ingroup EventGroup
*/ */
EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* event_groups.h
* <pre>
* BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
* </pre>
* @endcond
* *
* A version of xEventGroupClearBits() that can be called from an interrupt. * A version of xEventGroupClearBits() that can be called from an interrupt.
* *
@@ -353,8 +410,8 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit
* *
* Example usage: * Example usage:
* @code{c} * @code{c}
* #define BIT_0 ( 1 << 0 ) * \#define BIT_0 ( 1 << 0 )
* #define BIT_4 ( 1 << 4 ) * \#define BIT_4 ( 1 << 4 )
* *
* // An event group which it is assumed has already been created by a call to * // An event group which it is assumed has already been created by a call to
* // xEventGroupCreate(). * // xEventGroupCreate().
@@ -373,15 +430,26 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xEventGroupClearBitsFromISR xEventGroupClearBitsFromISR
* @endcond
* \ingroup EventGroup * \ingroup EventGroup
*/ */
#if( configUSE_TRACE_FACILITY == 1 ) #if ( configUSE_TRACE_FACILITY == 1 )
BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION; BaseType_t xEventGroupClearBitsFromISR( EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToClear ) PRIVILEGED_FUNCTION;
#else #else
#define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL ) #define xEventGroupClearBitsFromISR( xEventGroup, uxBitsToClear ) \
xTimerPendFunctionCallFromISR( vEventGroupClearBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToClear, NULL )
#endif #endif
/** /**
* @cond
* event_groups.h
* <pre>
* EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet );
* </pre>
* @endcond
* *
* Set bits within an event group. * Set bits within an event group.
* This function cannot be called from an interrupt. xEventGroupSetBitsFromISR() * This function cannot be called from an interrupt. xEventGroupSetBitsFromISR()
@@ -408,8 +476,8 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit
* *
* Example usage: * Example usage:
* @code{c} * @code{c}
* #define BIT_0 ( 1 << 0 ) * \#define BIT_0 ( 1 << 0 )
* #define BIT_4 ( 1 << 4 ) * \#define BIT_4 ( 1 << 4 )
* *
* void aFunction( EventGroupHandle_t xEventGroup ) * void aFunction( EventGroupHandle_t xEventGroup )
* { * {
@@ -445,12 +513,22 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup, const EventBit
* // cleared as the task left the Blocked state. * // cleared as the task left the Blocked state.
* } * }
* } * }
* @endcode{c} * @endcode
* @cond
* \defgroup xEventGroupSetBits xEventGroupSetBits
* @endcond
* \ingroup EventGroup * \ingroup EventGroup
*/ */
EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION; EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToSet ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* event_groups.h
* <pre>
* BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken );
* </pre>
* @endcond
* *
* A version of xEventGroupSetBits() that can be called from an interrupt. * A version of xEventGroupSetBits() that can be called from an interrupt.
* *
@@ -484,8 +562,8 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_
* *
* Example usage: * Example usage:
* @code{c} * @code{c}
* #define BIT_0 ( 1 << 0 ) * \#define BIT_0 ( 1 << 0 )
* #define BIT_4 ( 1 << 4 ) * \#define BIT_4 ( 1 << 4 )
* *
* // An event group which it is assumed has already been created by a call to * // An event group which it is assumed has already been created by a call to
* // xEventGroupCreate(). * // xEventGroupCreate().
@@ -515,15 +593,30 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xEventGroupSetBitsFromISR xEventGroupSetBitsFromISR
* @endcond
* \ingroup EventGroup * \ingroup EventGroup
*/ */
#if( configUSE_TRACE_FACILITY == 1 ) #if ( configUSE_TRACE_FACILITY == 1 )
BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToSet,
BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
#else #else
#define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken ) #define xEventGroupSetBitsFromISR( xEventGroup, uxBitsToSet, pxHigherPriorityTaskWoken ) \
xTimerPendFunctionCallFromISR( vEventGroupSetBitsCallback, ( void * ) xEventGroup, ( uint32_t ) uxBitsToSet, pxHigherPriorityTaskWoken )
#endif #endif
/** /**
* @cond
* event_groups.h
* <pre>
* EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
* const EventBits_t uxBitsToSet,
* const EventBits_t uxBitsToWaitFor,
* TickType_t xTicksToWait );
* </pre>
* @endcond
* *
* Atomically set bits within an event group, then wait for a combination of * Atomically set bits within an event group, then wait for a combination of
* bits to be set within the same event group. This functionality is typically * bits to be set within the same event group. This functionality is typically
@@ -564,11 +657,11 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_
* Example usage: * Example usage:
* @code{c} * @code{c}
* // Bits used by the three tasks. * // Bits used by the three tasks.
* #define TASK_0_BIT ( 1 << 0 ) * \#define TASK_0_BIT ( 1 << 0 )
* #define TASK_1_BIT ( 1 << 1 ) * \#define TASK_1_BIT ( 1 << 1 )
* #define TASK_2_BIT ( 1 << 2 ) * \#define TASK_2_BIT ( 1 << 2 )
* *
* #define ALL_SYNC_BITS ( TASK_0_BIT | TASK_1_BIT | TASK_2_BIT ) * \#define ALL_SYNC_BITS ( TASK_0_BIT | TASK_1_BIT | TASK_2_BIT )
* *
* // Use an event group to synchronise three tasks. It is assumed this event * // Use an event group to synchronise three tasks. It is assumed this event
* // group has already been created elsewhere. * // group has already been created elsewhere.
@@ -612,7 +705,7 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_
* xEventGroupSync( xEventBits, TASK_1_BIT, ALL_SYNC_BITS, portMAX_DELAY ); * xEventGroupSync( xEventBits, TASK_1_BIT, ALL_SYNC_BITS, portMAX_DELAY );
* *
* // xEventGroupSync() was called with an indefinite block time, so * // xEventGroupSync() was called with an indefinite block time, so
* // this task will only reach here if the syncrhonisation was made by all * // this task will only reach here if the synchronisation was made by all
* // three tasks, so there is no need to test the return value. * // three tasks, so there is no need to test the return value.
* } * }
* } * }
@@ -631,18 +724,30 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, const EventBits_
* xEventGroupSync( xEventBits, TASK_2_BIT, ALL_SYNC_BITS, portMAX_DELAY ); * xEventGroupSync( xEventBits, TASK_2_BIT, ALL_SYNC_BITS, portMAX_DELAY );
* *
* // xEventGroupSync() was called with an indefinite block time, so * // xEventGroupSync() was called with an indefinite block time, so
* // this task will only reach here if the syncrhonisation was made by all * // this task will only reach here if the synchronisation was made by all
* // three tasks, so there is no need to test the return value. * // three tasks, so there is no need to test the return value.
* } * }
* } * }
* *
* @endcode * @endcode
* @cond
* \defgroup xEventGroupSync xEventGroupSync
* @endcond
* \ingroup EventGroup * \ingroup EventGroup
*/ */
EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t uxBitsToSet, const EventBits_t uxBitsToWaitFor, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToSet,
const EventBits_t uxBitsToWaitFor,
TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* event_groups.h
* <pre>
* EventBits_t xEventGroupGetBits( EventGroupHandle_t xEventGroup );
* </pre>
* @endcond
* *
* Returns the current value of the bits in an event group. This function * Returns the current value of the bits in an event group. This function
* cannot be used from an interrupt. * cannot be used from an interrupt.
@@ -651,11 +756,20 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t u
* *
* @return The event group bits at the time xEventGroupGetBits() was called. * @return The event group bits at the time xEventGroupGetBits() was called.
* *
* @cond
* \defgroup xEventGroupGetBits xEventGroupGetBits
* @endcond
* \ingroup EventGroup * \ingroup EventGroup
*/ */
#define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 ) #define xEventGroupGetBits( xEventGroup ) xEventGroupClearBits( xEventGroup, 0 )
/** /**
* @cond
* event_groups.h
* <pre>
* EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup );
* </pre>
* @endcond
* *
* A version of xEventGroupGetBits() that can be called from an ISR. * A version of xEventGroupGetBits() that can be called from an ISR.
* *
@@ -663,11 +777,21 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, const EventBits_t u
* *
* @return The event group bits at the time xEventGroupGetBitsFromISR() was called. * @return The event group bits at the time xEventGroupGetBitsFromISR() was called.
* *
* @cond
* \defgroup xEventGroupGetBitsFromISR xEventGroupGetBitsFromISR
* @endcond
* \ingroup EventGroup * \ingroup EventGroup
*/ */
EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION; EventBits_t xEventGroupGetBitsFromISR( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* event_groups.h
* <pre>
* void xEventGroupDelete( EventGroupHandle_t xEventGroup );
* </pre>
* @endcond
*
* Delete an event group that was previously created by a call to * Delete an event group that was previously created by a call to
* xEventGroupCreate(). Tasks that are blocked on the event group will be * xEventGroupCreate(). Tasks that are blocked on the event group will be
* unblocked and obtain 0 as the event group's value. * unblocked and obtain 0 as the event group's value.
@@ -679,19 +803,24 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup ) PRIVILEGED_FUNCTION;
/** @cond */ /** @cond */
/* For internal use only. */ /* For internal use only. */
void vEventGroupSetBitsCallback( void *pvEventGroup, const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION; void vEventGroupSetBitsCallback( void * pvEventGroup,
void vEventGroupClearBitsCallback( void *pvEventGroup, const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION; const uint32_t ulBitsToSet ) PRIVILEGED_FUNCTION;
void vEventGroupClearBitsCallback( void * pvEventGroup,
const uint32_t ulBitsToClear ) PRIVILEGED_FUNCTION;
#if (configUSE_TRACE_FACILITY == 1) #if ( configUSE_TRACE_FACILITY == 1 )
UBaseType_t uxEventGroupGetNumber( void* xEventGroup ) PRIVILEGED_FUNCTION; UBaseType_t uxEventGroupGetNumber( void * xEventGroup ) PRIVILEGED_FUNCTION;
void vEventGroupSetNumber( void* xEventGroup, UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION; void vEventGroupSetNumber( void * xEventGroup,
UBaseType_t uxEventGroupNumber ) PRIVILEGED_FUNCTION;
#endif #endif
/** @endcond */ /** @endcond */
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* *INDENT-ON* */
#endif /* EVENT_GROUPS_H */ #endif /* EVENT_GROUPS_H */

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
/* /*
@@ -54,7 +53,7 @@
*/ */
#ifndef INC_FREERTOS_H #ifndef INC_FREERTOS_H
#error FreeRTOS.h must be included before list.h #error "FreeRTOS.h must be included before list.h"
#endif #endif
#ifndef LIST_H #ifndef LIST_H
@@ -92,16 +91,18 @@
#define configLIST_VOLATILE #define configLIST_VOLATILE
#endif /* configSUPPORT_CROSS_MODULE_OPTIMISATION */ #endif /* configSUPPORT_CROSS_MODULE_OPTIMISATION */
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* *INDENT-ON* */
/* Macros that can be used to place known values within the list structures, /* Macros that can be used to place known values within the list structures,
then check that the known values do not get corrupted during the execution of * then check that the known values do not get corrupted during the execution of
the application. These may catch the list data structures being overwritten in * the application. These may catch the list data structures being overwritten in
memory. They will not catch data errors caused by incorrect configuration or * memory. They will not catch data errors caused by incorrect configuration or
use of FreeRTOS.*/ * use of FreeRTOS.*/
#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 )
/* Define the macros to do nothing. */ /* Define the macros to do nothing. */
#define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE
#define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE
@@ -113,21 +114,21 @@ use of FreeRTOS.*/
#define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList )
#define listTEST_LIST_ITEM_INTEGRITY( pxItem ) #define listTEST_LIST_ITEM_INTEGRITY( pxItem )
#define listTEST_LIST_INTEGRITY( pxList ) #define listTEST_LIST_INTEGRITY( pxList )
#else #else /* if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) */
/* Define macros that add new members into the list structures. */ /* Define macros that add new members into the list structures. */
#define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue1; #define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue1;
#define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue2; #define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue2;
#define listFIRST_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue1; #define listFIRST_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue1;
#define listSECOND_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue2; #define listSECOND_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue2;
/* Define macros that set the new structure members to known values. */ /* Define macros that set the new structure members to known values. */
#define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE #define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE
#define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE #define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE
#define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE
#define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE
/* Define macros that will assert if one of the structure members does not /* Define macros that will assert if one of the structure members does not
contain its expected value. */ * contain its expected value. */
#define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) )
#define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) #define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) )
#endif /* configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES */ #endif /* configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES */
@@ -275,8 +276,8 @@ typedef struct xLIST
* \ingroup LinkedList * \ingroup LinkedList
*/ */
#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \ #define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \
{ \ { \
List_t * const pxConstList = ( pxList ); \ List_t * const pxConstList = ( pxList ); \
/* Increment the index to the next item and return the item, ensuring */ \ /* Increment the index to the next item and return the item, ensuring */ \
/* we don't return the marker used at the end of the list. */ \ /* we don't return the marker used at the end of the list. */ \
( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \
@@ -285,7 +286,7 @@ List_t * const pxConstList = ( pxList ); \
( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \ ( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \
} \ } \
( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \ ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \
} }
/* /*
@@ -304,7 +305,7 @@ List_t * const pxConstList = ( pxList ); \
* \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY * \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY
* \ingroup LinkedList * \ingroup LinkedList
*/ */
#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( (&( ( pxList )->xListEnd ))->pxNext->pvOwner ) #define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( ( &( ( pxList )->xListEnd ) )->pxNext->pvOwner )
/* /*
* Check to see if a list item is within a list. The list item maintains a * Check to see if a list item is within a list. The list item maintains a
@@ -366,7 +367,8 @@ void vListInitialiseItem( ListItem_t * const pxItem ) PRIVILEGED_FUNCTION;
* \page vListInsert vListInsert * \page vListInsert vListInsert
* \ingroup LinkedList * \ingroup LinkedList
*/ */
void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; void vListInsert( List_t * const pxList,
ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION;
/* /*
* Insert a list item into a list. The item will be inserted in a position * Insert a list item into a list. The item will be inserted in a position
@@ -387,7 +389,8 @@ void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIV
* \page vListInsertEnd vListInsertEnd * \page vListInsertEnd vListInsertEnd
* \ingroup LinkedList * \ingroup LinkedList
*/ */
void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION; void vListInsertEnd( List_t * const pxList,
ListItem_t * const pxNewListItem ) PRIVILEGED_FUNCTION;
/* /*
* Remove an item from a list. The list item has a pointer to the list that * Remove an item from a list. The list item has a pointer to the list that
@@ -404,8 +407,10 @@ void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) P
*/ */
UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) PRIVILEGED_FUNCTION; UBaseType_t uxListRemove( ListItem_t * const pxItemToRemove ) PRIVILEGED_FUNCTION;
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* *INDENT-ON* */
#endif #endif /* ifndef LIST_H */

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
@@ -69,9 +68,11 @@
/* Message buffers are built onto of stream buffers. */ /* Message buffers are built onto of stream buffers. */
#include "stream_buffer.h" #include "stream_buffer.h"
/* *INDENT-OFF* */
#if defined( __cplusplus ) #if defined( __cplusplus )
extern "C" { extern "C" {
#endif #endif
/* *INDENT-ON* */
/** /**
* Type by which message buffers are referenced. For example, a call to * Type by which message buffers are referenced. For example, a call to
@@ -84,6 +85,14 @@ typedef void * MessageBufferHandle_t;
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/** /**
* @cond
* message_buffer.h
*
* <pre>
* MessageBufferHandle_t xMessageBufferCreate( size_t xBufferSizeBytes );
* </pre>
* @endcond
*
* Creates a new message buffer using dynamically allocated memory. See * Creates a new message buffer using dynamically allocated memory. See
* xMessageBufferCreateStatic() for a version that uses statically allocated * xMessageBufferCreateStatic() for a version that uses statically allocated
* memory (memory that is allocated at compile time). * memory (memory that is allocated at compile time).
@@ -130,11 +139,24 @@ typedef void * MessageBufferHandle_t;
* } * }
* *
* @endcode * @endcode
* @cond
* \defgroup xMessageBufferCreate xMessageBufferCreate
* @endcond
* \ingroup MessageBufferManagement * \ingroup MessageBufferManagement
*/ */
#define xMessageBufferCreate( xBufferSizeBytes ) ( MessageBufferHandle_t ) xStreamBufferGenericCreate( xBufferSizeBytes, ( size_t ) 0, pdTRUE ) #define xMessageBufferCreate( xBufferSizeBytes ) \
( MessageBufferHandle_t ) xStreamBufferGenericCreate( xBufferSizeBytes, ( size_t ) 0, pdTRUE )
/** /**
* @cond
* message_buffer.h
*
* <pre>
* MessageBufferHandle_t xMessageBufferCreateStatic( size_t xBufferSizeBytes,
* uint8_t *pucMessageBufferStorageArea,
* StaticMessageBuffer_t *pxStaticMessageBuffer );
* </pre>
* @endcond
* Creates a new message buffer using statically allocated memory. See * Creates a new message buffer using statically allocated memory. See
* xMessageBufferCreate() for a version that uses dynamically allocated memory. * xMessageBufferCreate() for a version that uses dynamically allocated memory.
* *
@@ -163,7 +185,7 @@ typedef void * MessageBufferHandle_t;
* *
* // Used to dimension the array used to hold the messages. The available space * // Used to dimension the array used to hold the messages. The available space
* // will actually be one less than this, so 999. * // will actually be one less than this, so 999.
* #define STORAGE_SIZE_BYTES 1000 * \#define STORAGE_SIZE_BYTES 1000
* *
* // Defines the memory that will actually hold the messages within the message * // Defines the memory that will actually hold the messages within the message
* // buffer. * // buffer.
@@ -188,11 +210,26 @@ typedef void * MessageBufferHandle_t;
* } * }
* *
* @endcode * @endcode
* @cond
* \defgroup xMessageBufferCreateStatic xMessageBufferCreateStatic
* @endcond
* \ingroup MessageBufferManagement * \ingroup MessageBufferManagement
*/ */
#define xMessageBufferCreateStatic( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer ) ( MessageBufferHandle_t ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, 0, pdTRUE, pucMessageBufferStorageArea, pxStaticMessageBuffer ) #define xMessageBufferCreateStatic( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer ) \
( MessageBufferHandle_t ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, 0, pdTRUE, pucMessageBufferStorageArea, pxStaticMessageBuffer )
/** /**
* @cond
* message_buffer.h
*
* <pre>
* size_t xMessageBufferSend( MessageBufferHandle_t xMessageBuffer,
* const void *pvTxData,
* size_t xDataLengthBytes,
* TickType_t xTicksToWait );
* </pre>
* @endcond
*
* Sends a discrete message to the message buffer. The message can be any * Sends a discrete message to the message buffer. The message can be any
* length that fits within the buffer's free space, and is copied into the * length that fits within the buffer's free space, and is copied into the
* buffer. * buffer.
@@ -277,11 +314,26 @@ typedef void * MessageBufferHandle_t;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xMessageBufferSend xMessageBufferSend
* @endcond
* \ingroup MessageBufferManagement * \ingroup MessageBufferManagement
*/ */
#define xMessageBufferSend( xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) xStreamBufferSend( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) #define xMessageBufferSend( xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) \
xStreamBufferSend( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait )
/** /**
* @cond
* message_buffer.h
*
* <pre>
* size_t xMessageBufferSendFromISR( MessageBufferHandle_t xMessageBuffer,
* const void *pvTxData,
* size_t xDataLengthBytes,
* BaseType_t *pxHigherPriorityTaskWoken );
* </pre>
* @endcond
*
* Interrupt safe version of the API function that sends a discrete message to * Interrupt safe version of the API function that sends a discrete message to
* the message buffer. The message can be any length that fits within the * the message buffer. The message can be any length that fits within the
* buffer's free space, and is copied into the buffer. * buffer's free space, and is copied into the buffer.
@@ -371,11 +423,26 @@ typedef void * MessageBufferHandle_t;
* portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); * portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
* } * }
* @endcode * @endcode
* @cond
* \defgroup xMessageBufferSendFromISR xMessageBufferSendFromISR
* @endcond
* \ingroup MessageBufferManagement * \ingroup MessageBufferManagement
*/ */
#define xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferSendFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) #define xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) \
xStreamBufferSendFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken )
/** /**
* @cond
* message_buffer.h
*
* <pre>
* size_t xMessageBufferReceive( MessageBufferHandle_t xMessageBuffer,
* void *pvRxData,
* size_t xBufferLengthBytes,
* TickType_t xTicksToWait );
* </pre>
* @endcond
*
* Receives a discrete message from a message buffer. Messages can be of * Receives a discrete message from a message buffer. Messages can be of
* variable length and are copied out of the buffer. * variable length and are copied out of the buffer.
* *
@@ -449,12 +516,27 @@ typedef void * MessageBufferHandle_t;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xMessageBufferReceive xMessageBufferReceive
* @endcond
* \ingroup MessageBufferManagement * \ingroup MessageBufferManagement
*/ */
#define xMessageBufferReceive( xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) xStreamBufferReceive( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) #define xMessageBufferReceive( xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) \
xStreamBufferReceive( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait )
/** /**
* @cond
* message_buffer.h
*
* <pre>
* size_t xMessageBufferReceiveFromISR( MessageBufferHandle_t xMessageBuffer,
* void *pvRxData,
* size_t xBufferLengthBytes,
* BaseType_t *pxHigherPriorityTaskWoken );
* </pre>
* @endcond
*
* An interrupt safe version of the API function that receives a discrete * An interrupt safe version of the API function that receives a discrete
* message from a message buffer. Messages can be of variable length and are * message from a message buffer. Messages can be of variable length and are
* copied out of the buffer. * copied out of the buffer.
@@ -540,11 +622,23 @@ typedef void * MessageBufferHandle_t;
* portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); * portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
* } * }
* @endcode * @endcode
* @cond
* \defgroup xMessageBufferReceiveFromISR xMessageBufferReceiveFromISR
* @endcond
* \ingroup MessageBufferManagement * \ingroup MessageBufferManagement
*/ */
#define xMessageBufferReceiveFromISR( xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferReceiveFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) #define xMessageBufferReceiveFromISR( xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) \
xStreamBufferReceiveFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken )
/** /**
* @cond
* message_buffer.h
*
* <pre>
* void vMessageBufferDelete( MessageBufferHandle_t xMessageBuffer );
* </pre>
* @endcond
*
* Deletes a message buffer that was previously created using a call to * Deletes a message buffer that was previously created using a call to
* xMessageBufferCreate() or xMessageBufferCreateStatic(). If the message * xMessageBufferCreate() or xMessageBufferCreateStatic(). If the message
* buffer was created using dynamic memory (that is, by xMessageBufferCreate()), * buffer was created using dynamic memory (that is, by xMessageBufferCreate()),
@@ -556,9 +650,17 @@ typedef void * MessageBufferHandle_t;
* @param xMessageBuffer The handle of the message buffer to be deleted. * @param xMessageBuffer The handle of the message buffer to be deleted.
* *
*/ */
#define vMessageBufferDelete( xMessageBuffer ) vStreamBufferDelete( ( StreamBufferHandle_t ) xMessageBuffer ) #define vMessageBufferDelete( xMessageBuffer ) \
vStreamBufferDelete( ( StreamBufferHandle_t ) xMessageBuffer )
/** /**
* @cond
* message_buffer.h
* <pre>
* BaseType_t xMessageBufferIsFull( MessageBufferHandle_t xMessageBuffer ) );
* </pre>
* @endcond
*
* Tests to see if a message buffer is full. A message buffer is full if it * Tests to see if a message buffer is full. A message buffer is full if it
* cannot accept any more messages, of any size, until space is made available * cannot accept any more messages, of any size, until space is made available
* by a message being removed from the message buffer. * by a message being removed from the message buffer.
@@ -568,9 +670,17 @@ typedef void * MessageBufferHandle_t;
* @return If the message buffer referenced by xMessageBuffer is full then * @return If the message buffer referenced by xMessageBuffer is full then
* pdTRUE is returned. Otherwise pdFALSE is returned. * pdTRUE is returned. Otherwise pdFALSE is returned.
*/ */
#define xMessageBufferIsFull( xMessageBuffer ) xStreamBufferIsFull( ( StreamBufferHandle_t ) xMessageBuffer ) #define xMessageBufferIsFull( xMessageBuffer ) \
xStreamBufferIsFull( ( StreamBufferHandle_t ) xMessageBuffer )
/** /**
* @cond
* message_buffer.h
* <pre>
* BaseType_t xMessageBufferIsEmpty( MessageBufferHandle_t xMessageBuffer ) );
* </pre>
* @endcond
*
* Tests to see if a message buffer is empty (does not contain any messages). * Tests to see if a message buffer is empty (does not contain any messages).
* *
* @param xMessageBuffer The handle of the message buffer being queried. * @param xMessageBuffer The handle of the message buffer being queried.
@@ -579,9 +689,17 @@ typedef void * MessageBufferHandle_t;
* pdTRUE is returned. Otherwise pdFALSE is returned. * pdTRUE is returned. Otherwise pdFALSE is returned.
* *
*/ */
#define xMessageBufferIsEmpty( xMessageBuffer ) xStreamBufferIsEmpty( ( StreamBufferHandle_t ) xMessageBuffer ) #define xMessageBufferIsEmpty( xMessageBuffer ) \
xStreamBufferIsEmpty( ( StreamBufferHandle_t ) xMessageBuffer )
/** /**
* @cond
* message_buffer.h
* <pre>
* BaseType_t xMessageBufferReset( MessageBufferHandle_t xMessageBuffer );
* </pre>
* @endcond
*
* Resets a message buffer to its initial empty state, discarding any message it * Resets a message buffer to its initial empty state, discarding any message it
* contained. * contained.
* *
@@ -594,12 +712,23 @@ typedef void * MessageBufferHandle_t;
* the message queue to wait for space to become available, or to wait for a * the message queue to wait for space to become available, or to wait for a
* a message to be available, then pdFAIL is returned. * a message to be available, then pdFAIL is returned.
* *
* @cond
* \defgroup xMessageBufferReset xMessageBufferReset
* @endcond
* \ingroup MessageBufferManagement * \ingroup MessageBufferManagement
*/ */
#define xMessageBufferReset( xMessageBuffer ) xStreamBufferReset( ( StreamBufferHandle_t ) xMessageBuffer ) #define xMessageBufferReset( xMessageBuffer ) \
xStreamBufferReset( ( StreamBufferHandle_t ) xMessageBuffer )
/** /**
* @cond
* message_buffer.h
* <pre>
* size_t xMessageBufferSpaceAvailable( MessageBufferHandle_t xMessageBuffer ) );
* </pre>
* @endcond
*
* Returns the number of bytes of free space in the message buffer. * Returns the number of bytes of free space in the message buffer.
* *
* @param xMessageBuffer The handle of the message buffer being queried. * @param xMessageBuffer The handle of the message buffer being queried.
@@ -611,12 +740,24 @@ typedef void * MessageBufferHandle_t;
* architecture, so if xMessageBufferSpacesAvailable() returns 10, then the size * architecture, so if xMessageBufferSpacesAvailable() returns 10, then the size
* of the largest message that can be written to the message buffer is 6 bytes. * of the largest message that can be written to the message buffer is 6 bytes.
* *
* @cond
* \defgroup xMessageBufferSpaceAvailable xMessageBufferSpaceAvailable
* @endcond
* \ingroup MessageBufferManagement * \ingroup MessageBufferManagement
*/ */
#define xMessageBufferSpaceAvailable( xMessageBuffer ) xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) #define xMessageBufferSpaceAvailable( xMessageBuffer ) \
#define xMessageBufferSpacesAvailable( xMessageBuffer ) xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) /* Corrects typo in original macro name. */ xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer )
#define xMessageBufferSpacesAvailable( xMessageBuffer ) \
xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer ) /* Corrects typo in original macro name. */
/** /**
* @cond
* message_buffer.h
* <pre>
* size_t xMessageBufferNextLengthBytes( MessageBufferHandle_t xMessageBuffer ) );
* </pre>
* @endcond
*
* Returns the length (in bytes) of the next message in a message buffer. * Returns the length (in bytes) of the next message in a message buffer.
* Useful if xMessageBufferReceive() returned 0 because the size of the buffer * Useful if xMessageBufferReceive() returned 0 because the size of the buffer
* passed into xMessageBufferReceive() was too small to hold the next message. * passed into xMessageBufferReceive() was too small to hold the next message.
@@ -626,11 +767,23 @@ typedef void * MessageBufferHandle_t;
* @return The length (in bytes) of the next message in the message buffer, or 0 * @return The length (in bytes) of the next message in the message buffer, or 0
* if the message buffer is empty. * if the message buffer is empty.
* *
* @cond
* \defgroup xMessageBufferNextLengthBytes xMessageBufferNextLengthBytes
* @endcond
* \ingroup MessageBufferManagement * \ingroup MessageBufferManagement
*/ */
#define xMessageBufferNextLengthBytes( xMessageBuffer ) xStreamBufferNextMessageLengthBytes( ( StreamBufferHandle_t ) xMessageBuffer ) PRIVILEGED_FUNCTION; #define xMessageBufferNextLengthBytes( xMessageBuffer ) \
xStreamBufferNextMessageLengthBytes( ( StreamBufferHandle_t ) xMessageBuffer ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* message_buffer.h
*
* <pre>
* BaseType_t xMessageBufferSendCompletedFromISR( MessageBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken );
* </pre>
* @endcond
*
* For advanced users only. * For advanced users only.
* *
* The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when * The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when
@@ -658,11 +811,23 @@ typedef void * MessageBufferHandle_t;
* @return If a task was removed from the Blocked state then pdTRUE is returned. * @return If a task was removed from the Blocked state then pdTRUE is returned.
* Otherwise pdFALSE is returned. * Otherwise pdFALSE is returned.
* *
* @cond
* \defgroup xMessageBufferSendCompletedFromISR xMessageBufferSendCompletedFromISR
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
#define xMessageBufferSendCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferSendCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) #define xMessageBufferSendCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) \
xStreamBufferSendCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken )
/** /**
* @cond
* message_buffer.h
*
* <pre>
* BaseType_t xMessageBufferReceiveCompletedFromISR( MessageBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken );
* </pre>
* @endcond
*
* For advanced users only. * For advanced users only.
* *
* The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when * The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when
@@ -691,12 +856,18 @@ typedef void * MessageBufferHandle_t;
* @return If a task was removed from the Blocked state then pdTRUE is returned. * @return If a task was removed from the Blocked state then pdTRUE is returned.
* Otherwise pdFALSE is returned. * Otherwise pdFALSE is returned.
* *
* @cond
* \defgroup xMessageBufferReceiveCompletedFromISR xMessageBufferReceiveCompletedFromISR
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
#define xMessageBufferReceiveCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferReceiveCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken ) #define xMessageBufferReceiveCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) \
xStreamBufferReceiveCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken )
/* *INDENT-OFF* */
#if defined( __cplusplus ) #if defined( __cplusplus )
} /* extern "C" */ } /* extern "C" */
#endif #endif
/* *INDENT-ON* */
#endif /* !defined( FREERTOS_MESSAGE_BUFFER_H ) */ #endif /* !defined( FREERTOS_MESSAGE_BUFFER_H ) */

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,25 +19,24 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
#ifndef MPU_WRAPPERS_H #ifndef MPU_WRAPPERS_H
#define MPU_WRAPPERS_H #define MPU_WRAPPERS_H
/* This file redefines API functions to be called through a wrapper macro, but /* This file redefines API functions to be called through a wrapper macro, but
only for ports that are using the MPU. */ * only for ports that are using the MPU. */
#if portUSING_MPU_WRAPPERS #if portUSING_MPU_WRAPPERS
/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is
included from queue.c or task.c to prevent it from having an effect within * included from queue.c or task.c to prevent it from having an effect within
those files. */ * those files. */
#ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE #ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
/* /*
* Map standard (non MPU) API functions to equivalents that start * Map standard (non MPU) API functions to equivalents that start
* "MPU_". This will cause the application code to call the MPU_ * "MPU_". This will cause the application code to call the MPU_
* version, which wraps the non-MPU version with privilege promoting * version, which wraps the non-MPU version with privilege promoting
@@ -45,7 +44,7 @@ only for ports that are using the MPU. */
* privileges. * privileges.
*/ */
/* Map standard tasks.h API functions to the MPU equivalents. */ /* Map standard tasks.h API functions to the MPU equivalents. */
#define xTaskCreate MPU_xTaskCreate #define xTaskCreate MPU_xTaskCreate
#define xTaskCreateStatic MPU_xTaskCreateStatic #define xTaskCreateStatic MPU_xTaskCreateStatic
#define xTaskCreateRestricted MPU_xTaskCreateRestricted #define xTaskCreateRestricted MPU_xTaskCreateRestricted
@@ -112,13 +111,13 @@ only for ports that are using the MPU. */
#define xQueueSelectFromSet MPU_xQueueSelectFromSet #define xQueueSelectFromSet MPU_xQueueSelectFromSet
#define xQueueGenericReset MPU_xQueueGenericReset #define xQueueGenericReset MPU_xQueueGenericReset
#if( configQUEUE_REGISTRY_SIZE > 0 ) #if ( configQUEUE_REGISTRY_SIZE > 0 )
#define vQueueAddToRegistry MPU_vQueueAddToRegistry #define vQueueAddToRegistry MPU_vQueueAddToRegistry
#define vQueueUnregisterQueue MPU_vQueueUnregisterQueue #define vQueueUnregisterQueue MPU_vQueueUnregisterQueue
#define pcQueueGetName MPU_pcQueueGetName #define pcQueueGetName MPU_pcQueueGetName
#endif #endif
/* Map standard timer.h API functions to the MPU equivalents. */ /* Map standard timer.h API functions to the MPU equivalents. */
#define xTimerCreate MPU_xTimerCreate #define xTimerCreate MPU_xTimerCreate
#define xTimerCreateStatic MPU_xTimerCreateStatic #define xTimerCreateStatic MPU_xTimerCreateStatic
#define pvTimerGetTimerID MPU_pvTimerGetTimerID #define pvTimerGetTimerID MPU_pvTimerGetTimerID
@@ -132,7 +131,7 @@ only for ports that are using the MPU. */
#define xTimerGetExpiryTime MPU_xTimerGetExpiryTime #define xTimerGetExpiryTime MPU_xTimerGetExpiryTime
#define xTimerGenericCommand MPU_xTimerGenericCommand #define xTimerGenericCommand MPU_xTimerGenericCommand
/* Map standard event_group.h API functions to the MPU equivalents. */ /* Map standard event_group.h API functions to the MPU equivalents. */
#define xEventGroupCreate MPU_xEventGroupCreate #define xEventGroupCreate MPU_xEventGroupCreate
#define xEventGroupCreateStatic MPU_xEventGroupCreateStatic #define xEventGroupCreateStatic MPU_xEventGroupCreateStatic
#define xEventGroupWaitBits MPU_xEventGroupWaitBits #define xEventGroupWaitBits MPU_xEventGroupWaitBits
@@ -141,8 +140,8 @@ only for ports that are using the MPU. */
#define xEventGroupSync MPU_xEventGroupSync #define xEventGroupSync MPU_xEventGroupSync
#define vEventGroupDelete MPU_vEventGroupDelete #define vEventGroupDelete MPU_vEventGroupDelete
/* Map standard message/stream_buffer.h API functions to the MPU /* Map standard message/stream_buffer.h API functions to the MPU
equivalents. */ * equivalents. */
#define xStreamBufferSend MPU_xStreamBufferSend #define xStreamBufferSend MPU_xStreamBufferSend
#define xStreamBufferReceive MPU_xStreamBufferReceive #define xStreamBufferReceive MPU_xStreamBufferReceive
#define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes #define xStreamBufferNextMessageLengthBytes MPU_xStreamBufferNextMessageLengthBytes
@@ -157,19 +156,19 @@ only for ports that are using the MPU. */
#define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic #define xStreamBufferGenericCreateStatic MPU_xStreamBufferGenericCreateStatic
/* Remove the privileged function macro, but keep the PRIVILEGED_DATA /* Remove the privileged function macro, but keep the PRIVILEGED_DATA
macro so applications can place data in privileged access sections * macro so applications can place data in privileged access sections
(useful when using statically allocated objects). */ * (useful when using statically allocated objects). */
#define PRIVILEGED_FUNCTION #define PRIVILEGED_FUNCTION
#define PRIVILEGED_DATA __attribute__((section("privileged_data"))) #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) )
#define FREERTOS_SYSTEM_CALL #define FREERTOS_SYSTEM_CALL
#else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ #else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
/* Ensure API functions go in the privileged execution section. */ /* Ensure API functions go in the privileged execution section. */
#define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions"))) #define PRIVILEGED_FUNCTION __attribute__( ( section( "privileged_functions" ) ) )
#define PRIVILEGED_DATA __attribute__((section("privileged_data"))) #define PRIVILEGED_DATA __attribute__( ( section( "privileged_data" ) ) )
#define FREERTOS_SYSTEM_CALL __attribute__((section( "freertos_system_calls"))) #define FREERTOS_SYSTEM_CALL __attribute__( ( section( "freertos_system_calls" ) ) )
#endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */ #endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
/*----------------------------------------------------------- /*-----------------------------------------------------------
@@ -33,21 +32,21 @@
#define PORTABLE_H #define PORTABLE_H
/* Each FreeRTOS port has a unique portmacro.h header file. Originally a /* Each FreeRTOS port has a unique portmacro.h header file. Originally a
pre-processor definition was used to ensure the pre-processor found the correct * pre-processor definition was used to ensure the pre-processor found the correct
portmacro.h file for the port being used. That scheme was deprecated in favour * portmacro.h file for the port being used. That scheme was deprecated in favour
of setting the compiler's include path such that it found the correct * of setting the compiler's include path such that it found the correct
portmacro.h file - removing the need for the constant and allowing the * portmacro.h file - removing the need for the constant and allowing the
portmacro.h file to be located anywhere in relation to the port being used. * portmacro.h file to be located anywhere in relation to the port being used.
Purely for reasons of backward compatibility the old method is still valid, but * Purely for reasons of backward compatibility the old method is still valid, but
to make it clear that new projects should not use it, support for the port * to make it clear that new projects should not use it, support for the port
specific constants has been moved into the deprecated_definitions.h header * specific constants has been moved into the deprecated_definitions.h header
file. */ * file. */
#include "deprecated_definitions.h" #include "deprecated_definitions.h"
/* If portENTER_CRITICAL is not defined then including deprecated_definitions.h /* If portENTER_CRITICAL is not defined then including deprecated_definitions.h
did not result in a portmacro.h header file being included - and it should be * did not result in a portmacro.h header file being included - and it should be
included here. In this case the path to the correct portmacro.h header file * included here. In this case the path to the correct portmacro.h header file
must be set in the compiler's include path. */ * must be set in the compiler's include path. */
#ifndef portENTER_CRITICAL #ifndef portENTER_CRITICAL
#include "freertos/portmacro.h" #include "freertos/portmacro.h"
#endif #endif
@@ -92,9 +91,11 @@ must be set in the compiler's include path. */
#define portARCH_NAME NULL #define portARCH_NAME NULL
#endif #endif
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* *INDENT-ON* */
#include "mpu_wrappers.h" #include "mpu_wrappers.h"
@@ -104,27 +105,39 @@ extern "C" {
* the order that the port expects to find them. * the order that the port expects to find them.
* *
*/ */
#if( portUSING_MPU_WRAPPERS == 1 ) #if ( portUSING_MPU_WRAPPERS == 1 )
#if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 )
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
StackType_t * pxEndOfStack,
TaskFunction_t pxCode,
void * pvParameters,
BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION;
#else #else
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION; StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
TaskFunction_t pxCode,
void * pvParameters,
BaseType_t xRunPrivileged ) PRIVILEGED_FUNCTION;
#endif #endif
#else #else /* if ( portUSING_MPU_WRAPPERS == 1 ) */
#if( portHAS_STACK_OVERFLOW_CHECKING == 1 ) #if ( portHAS_STACK_OVERFLOW_CHECKING == 1 )
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, StackType_t *pxEndOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
StackType_t * pxEndOfStack,
TaskFunction_t pxCode,
void * pvParameters ) PRIVILEGED_FUNCTION;
#else #else
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters ) PRIVILEGED_FUNCTION; StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
TaskFunction_t pxCode,
void * pvParameters ) PRIVILEGED_FUNCTION;
#endif #endif
#endif #endif
#ifdef configUSE_FREERTOS_PROVIDED_HEAP #ifdef configUSE_FREERTOS_PROVIDED_HEAP
/* Used by heap_5.c to define the start address and size of each memory region /* Used by heap_5.c to define the start address and size of each memory region
that together comprise the total FreeRTOS heap space. */ * that together comprise the total FreeRTOS heap space. */
typedef struct HeapRegion typedef struct HeapRegion
{ {
uint8_t *pucStartAddress; uint8_t * pucStartAddress;
size_t xSizeInBytes; size_t xSizeInBytes;
} HeapRegion_t; } HeapRegion_t;
@@ -157,12 +170,13 @@ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEG
* Returns a HeapStats_t structure filled with information about the current * Returns a HeapStats_t structure filled with information about the current
* heap state. * heap state.
*/ */
void vPortGetHeapStats( HeapStats_t *pxHeapStats ); void vPortGetHeapStats( HeapStats_t * pxHeapStats );
/* /*
* Map to the memory management routines required for the port. * Map to the memory management routines required for the port.
*/ */
void *pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION; void * pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
void vPortFree( void *pv ) PRIVILEGED_FUNCTION; void vPortFree( void * pv ) PRIVILEGED_FUNCTION;
void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION; void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;
@@ -196,8 +210,10 @@ BaseType_t xPortStartScheduler( void ) PRIVILEGED_FUNCTION;
*/ */
void vPortEndScheduler( void ) PRIVILEGED_FUNCTION; void vPortEndScheduler( void ) PRIVILEGED_FUNCTION;
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* *INDENT-ON* */
#endif /* PORTABLE_H */ #endif /* PORTABLE_H */

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
#ifndef PROJDEFS_H #ifndef PROJDEFS_H
@@ -32,11 +31,11 @@
* Defines the prototype to which task functions must conform. Defined in this * Defines the prototype to which task functions must conform. Defined in this
* file to ensure the type is known before portable.h is included. * file to ensure the type is known before portable.h is included.
*/ */
typedef void (*TaskFunction_t)( void * ); typedef void (* TaskFunction_t)( void * );
/* Converts a time in milliseconds to a time in ticks. This macro can be /* Converts a time in milliseconds to a time in ticks. This macro can be
overridden by a macro of the same name defined in FreeRTOSConfig.h in case the * overridden by a macro of the same name defined in FreeRTOSConfig.h in case the
definition here is not suitable for your application. */ * definition here is not suitable for your application. */
#ifndef pdMS_TO_TICKS #ifndef pdMS_TO_TICKS
#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) ) #define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) )
#endif #endif
@@ -64,14 +63,14 @@ definition here is not suitable for your application. */
#define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0
#endif #endif
#if( configUSE_16_BIT_TICKS == 1 ) #if ( configUSE_16_BIT_TICKS == 1 )
#define pdINTEGRITY_CHECK_VALUE 0x5a5a #define pdINTEGRITY_CHECK_VALUE 0x5a5a
#else #else
#define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL
#endif #endif
/* The following errno values are used by FreeRTOS+ components, not FreeRTOS /* The following errno values are used by FreeRTOS+ components, not FreeRTOS
itself. */ * itself. */
#define pdFREERTOS_ERRNO_NONE 0 /* No errors */ #define pdFREERTOS_ERRNO_NONE 0 /* No errors */
#define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */ #define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */
#define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */ #define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */
@@ -114,7 +113,7 @@ itself. */
#define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */ #define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */
/* The following endian values are used by FreeRTOS+ components, not FreeRTOS /* The following endian values are used by FreeRTOS+ components, not FreeRTOS
itself. */ * itself. */
#define pdFREERTOS_LITTLE_ENDIAN 0 #define pdFREERTOS_LITTLE_ENDIAN 0
#define pdFREERTOS_BIG_ENDIAN 1 #define pdFREERTOS_BIG_ENDIAN 1

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
@@ -33,9 +32,11 @@
#error "include FreeRTOS.h" must appear in source files before "include queue.h" #error "include FreeRTOS.h" must appear in source files before "include queue.h"
#endif #endif
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* *INDENT-ON* */
#include "task.h" #include "task.h"
@@ -123,13 +124,27 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* // ... Rest of task code. * // ... Rest of task code.
* } * }
* @endcode * @endcode
* @cond
* \defgroup xQueueCreate xQueueCreate
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
#define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( ( uxQueueLength ), ( uxItemSize ), ( queueQUEUE_TYPE_BASE ) ) #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( ( uxQueueLength ), ( uxItemSize ), ( queueQUEUE_TYPE_BASE ) )
#endif #endif
/** /**
* @cond
* queue. h
* <pre>
* QueueHandle_t xQueueCreateStatic(
* UBaseType_t uxQueueLength,
* UBaseType_t uxItemSize,
* uint8_t *pucQueueStorageBuffer,
* StaticQueue_t *pxQueueBuffer
* );
* </pre>
* @endcond
* Creates a new queue instance, and returns a handle by which the new queue * Creates a new queue instance, and returns a handle by which the new queue
* can be referenced. * can be referenced.
* *
@@ -138,12 +153,12 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* second block is used to hold items placed into the queue. If a queue is * second block is used to hold items placed into the queue. If a queue is
* created using xQueueCreate() then both blocks of memory are automatically * created using xQueueCreate() then both blocks of memory are automatically
* dynamically allocated inside the xQueueCreate() function. (see * dynamically allocated inside the xQueueCreate() function. (see
* http://www.freertos.org/a00111.html). If a queue is created using * https://www.FreeRTOS.org/a00111.html). If a queue is created using
* xQueueCreateStatic() then the application writer must provide the memory that * xQueueCreateStatic() then the application writer must provide the memory that
* will get used by the queue. xQueueCreateStatic() therefore allows a queue to * will get used by the queue. xQueueCreateStatic() therefore allows a queue to
* be created without using any dynamic memory allocation. * be created without using any dynamic memory allocation.
* *
* http://www.FreeRTOS.org/Embedded-RTOS-Queues.html * https://www.FreeRTOS.org/Embedded-RTOS-Queues.html
* *
* @param uxQueueLength The maximum number of items that the queue can contain. * @param uxQueueLength The maximum number of items that the queue can contain.
* *
@@ -172,8 +187,8 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* char ucData[ 20 ]; * char ucData[ 20 ];
* }; * };
* *
* #define QUEUE_LENGTH 10 * \#define QUEUE_LENGTH 10
* #define ITEM_SIZE sizeof( uint32_t ) * \#define ITEM_SIZE sizeof( uint32_t )
* *
* // xQueueBuffer will hold the queue structure. * // xQueueBuffer will hold the queue structure.
* StaticQueue_t xQueueBuffer; * StaticQueue_t xQueueBuffer;
@@ -198,13 +213,27 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* // ... Rest of task code. * // ... Rest of task code.
* } * }
* @endcode * @endcode
* @cond
* \defgroup xQueueCreateStatic xQueueCreateStatic
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
#if( configSUPPORT_STATIC_ALLOCATION == 1 ) #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
#define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) ) #define xQueueCreateStatic( uxQueueLength, uxItemSize, pucQueueStorage, pxQueueBuffer ) xQueueGenericCreateStatic( ( uxQueueLength ), ( uxItemSize ), ( pucQueueStorage ), ( pxQueueBuffer ), ( queueQUEUE_TYPE_BASE ) )
#endif /* configSUPPORT_STATIC_ALLOCATION */ #endif /* configSUPPORT_STATIC_ALLOCATION */
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueueSendToToFront(
* QueueHandle_t xQueue,
* const void *pvItemToQueue,
* TickType_t xTicksToWait
* );
* </pre>
* @endcond
*
* Post an item to the front of a queue. The item is queued by copy, not by * Post an item to the front of a queue. The item is queued by copy, not by
* reference. This function must not be called from an interrupt service * reference. This function must not be called from an interrupt service
* routine. See xQueueSendFromISR () for an alternative which may be used * routine. See xQueueSendFromISR () for an alternative which may be used
@@ -270,11 +299,26 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* // ... Rest of task code. * // ... Rest of task code.
* } * }
* @endcode * @endcode
* @cond
* \defgroup xQueueSend xQueueSend
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
#define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT ) #define xQueueSendToFront( xQueue, pvItemToQueue, xTicksToWait ) \
xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_FRONT )
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueueSendToBack(
* QueueHandle_t xQueue,
* const void *pvItemToQueue,
* TickType_t xTicksToWait
* );
* </pre>
* @endcond
*
* This is a macro that calls xQueueGenericSend(). * This is a macro that calls xQueueGenericSend().
* *
* Post an item to the back of a queue. The item is queued by copy, not by * Post an item to the back of a queue. The item is queued by copy, not by
@@ -342,11 +386,26 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* // ... Rest of task code. * // ... Rest of task code.
* } * }
* @endcode * @endcode
* @cond
* \defgroup xQueueSend xQueueSend
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
#define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) #define xQueueSendToBack( xQueue, pvItemToQueue, xTicksToWait ) \
xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueueSend(
* QueueHandle_t xQueue,
* const void * pvItemToQueue,
* TickType_t xTicksToWait
* );
* </pre>
* @endcond
*
* This is a macro that calls xQueueGenericSend(). It is included for * This is a macro that calls xQueueGenericSend(). It is included for
* backward compatibility with versions of FreeRTOS.org that did not * backward compatibility with versions of FreeRTOS.org that did not
* include the xQueueSendToFront() and xQueueSendToBack() macros. It is * include the xQueueSendToFront() and xQueueSendToBack() macros. It is
@@ -416,11 +475,25 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* // ... Rest of task code. * // ... Rest of task code.
* } * }
* @endcode * @endcode
* @cond
* \defgroup xQueueSend xQueueSend
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
#define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK ) #define xQueueSend( xQueue, pvItemToQueue, xTicksToWait ) \
xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), ( xTicksToWait ), queueSEND_TO_BACK )
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueueOverwrite(
* QueueHandle_t xQueue,
* const void * pvItemToQueue
* );
* </pre>
* @endcond
*
* Only for use with queues that have a length of one - so the queue is either * Only for use with queues that have a length of one - so the queue is either
* empty or full. * empty or full.
* *
@@ -490,12 +563,28 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* // ... * // ...
* } * }
* @endcode * @endcode
* @cond
* \defgroup xQueueOverwrite xQueueOverwrite
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
#define xQueueOverwrite( xQueue, pvItemToQueue ) xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE ) #define xQueueOverwrite( xQueue, pvItemToQueue ) \
xQueueGenericSend( ( xQueue ), ( pvItemToQueue ), 0, queueOVERWRITE )
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueueGenericSend(
* QueueHandle_t xQueue,
* const void * pvItemToQueue,
* TickType_t xTicksToWait
* BaseType_t xCopyPosition
* );
* </pre>
* @endcond
*
* It is preferred that the macros xQueueSend(), xQueueSendToFront() and * It is preferred that the macros xQueueSend(), xQueueSendToFront() and
* xQueueSendToBack() are used in place of calling this function directly. * xQueueSendToBack() are used in place of calling this function directly.
* *
@@ -567,11 +656,28 @@ typedef struct QueueDefinition * QueueSetMemberHandle_t;
* // ... Rest of task code. * // ... Rest of task code.
* } * }
* @endcode * @endcode
* @cond
* \defgroup xQueueSend xQueueSend
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQueue, TickType_t xTicksToWait, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; BaseType_t xQueueGenericSend( QueueHandle_t xQueue,
const void * const pvItemToQueue,
TickType_t xTicksToWait,
const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueuePeek(
* QueueHandle_t xQueue,
* void * const pvBuffer,
* TickType_t xTicksToWait
* );
* </pre>
* @endcond
*
* Receive an item from a queue without removing the item from the queue. * Receive an item from a queue without removing the item from the queue.
* The item is received by copy so a buffer of adequate size must be * The item is received by copy so a buffer of adequate size must be
* provided. The number of bytes copied into the buffer was defined when * provided. The number of bytes copied into the buffer was defined when
@@ -652,11 +758,26 @@ BaseType_t xQueueGenericSend( QueueHandle_t xQueue, const void * const pvItemToQ
* // ... Rest of task code. * // ... Rest of task code.
* } * }
* @endcode * @endcode
* @cond
* \defgroup xQueuePeek xQueuePeek
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; BaseType_t xQueuePeek( QueueHandle_t xQueue,
void * const pvBuffer,
TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueuePeekFromISR(
* QueueHandle_t xQueue,
* void *pvBuffer,
* );
* </pre>
* @endcond
*
* A version of xQueuePeek() that can be called from an interrupt service * A version of xQueuePeek() that can be called from an interrupt service
* routine (ISR). * routine (ISR).
* *
@@ -677,11 +798,26 @@ BaseType_t xQueuePeek( QueueHandle_t xQueue, void * const pvBuffer, TickType_t x
* @return pdTRUE if an item was successfully received from the queue, * @return pdTRUE if an item was successfully received from the queue,
* otherwise pdFALSE. * otherwise pdFALSE.
* *
* @cond
* \defgroup xQueuePeekFromISR xQueuePeekFromISR
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIVILEGED_FUNCTION; BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue,
void * const pvBuffer ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueueReceive(
* QueueHandle_t xQueue,
* void *pvBuffer,
* TickType_t xTicksToWait
* );
* @endcode
* @endcond
*
* Receive an item from a queue. The item is received by copy so a buffer of * Receive an item from a queue. The item is received by copy so a buffer of
* adequate size must be provided. The number of bytes copied into the buffer * adequate size must be provided. The number of bytes copied into the buffer
* was defined when the queue was created. * was defined when the queue was created.
@@ -759,22 +895,44 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, void * const pvBuffer ) PRIV
* // ... Rest of task code. * // ... Rest of task code.
* } * }
* @endcode * @endcode
* @cond
* \defgroup xQueueReceive xQueueReceive
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
BaseType_t xQueueReceive( QueueHandle_t xQueue, void * const pvBuffer, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; BaseType_t xQueueReceive( QueueHandle_t xQueue,
void * const pvBuffer,
TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* queue. h
* <pre>
* UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue );
* </pre>
* @endcond
*
* Return the number of messages stored in a queue. * Return the number of messages stored in a queue.
* *
* @param xQueue A handle to the queue being queried. * @param xQueue A handle to the queue being queried.
* *
* @return The number of messages available in the queue. * @return The number of messages available in the queue.
* *
* @cond
* \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* queue. h
* <pre>
* UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue );
* </pre>
* @endcond
*
* Return the number of free spaces available in a queue. This is equal to the * Return the number of free spaces available in a queue. This is equal to the
* number of items that can be sent to the queue before the queue becomes full * number of items that can be sent to the queue before the queue becomes full
* if no items are removed. * if no items are removed.
@@ -783,21 +941,45 @@ UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) PRIVILEGED_FUNC
* *
* @return The number of spaces available in the queue. * @return The number of spaces available in the queue.
* *
* @cond
* \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* queue. h
* <pre>
* void vQueueDelete( QueueHandle_t xQueue );
* </pre>
* @endcond
*
* Delete a queue - freeing all the memory allocated for storing of items * Delete a queue - freeing all the memory allocated for storing of items
* placed on the queue. * placed on the queue.
* *
* @param xQueue A handle to the queue to be deleted. * @param xQueue A handle to the queue to be deleted.
* *
* @cond
* \defgroup vQueueDelete vQueueDelete
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueueSendToFrontFromISR(
* QueueHandle_t xQueue,
* const void *pvItemToQueue,
* BaseType_t *pxHigherPriorityTaskWoken
* );
* </pre>
* @endcond
*
* This is a macro that calls xQueueGenericSendFromISR(). * This is a macro that calls xQueueGenericSendFromISR().
* *
* Post an item to the front of a queue. It is safe to use this macro from * Post an item to the front of a queue. It is safe to use this macro from
@@ -852,12 +1034,28 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
* } * }
* } * }
* @endcode * @endcode
*
* @cond
* \defgroup xQueueSendFromISR xQueueSendFromISR
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
#define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT ) #define xQueueSendToFrontFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \
xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_FRONT )
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueueSendToBackFromISR(
* QueueHandle_t xQueue,
* const void *pvItemToQueue,
* BaseType_t *pxHigherPriorityTaskWoken
* );
* </pre>
* @endcond
*
* This is a macro that calls xQueueGenericSendFromISR(). * This is a macro that calls xQueueGenericSendFromISR().
* *
* Post an item to the back of a queue. It is safe to use this macro from * Post an item to the back of a queue. It is safe to use this macro from
@@ -912,11 +1110,27 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
* } * }
* } * }
* @endcode * @endcode
*
* @cond
* \defgroup xQueueSendFromISR xQueueSendFromISR
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
#define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) #define xQueueSendToBackFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \
xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueueOverwriteFromISR(
* QueueHandle_t xQueue,
* const void * pvItemToQueue,
* BaseType_t *pxHigherPriorityTaskWoken
* );
* </pre>
* @endcond
*
* A version of xQueueOverwrite() that can be used in an interrupt service * A version of xQueueOverwrite() that can be used in an interrupt service
* routine (ISR). * routine (ISR).
* *
@@ -947,12 +1161,13 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
* *
* Example usage: * Example usage:
* @code{c} * @code{c}
*
* QueueHandle_t xQueue; * QueueHandle_t xQueue;
* *
* void vFunction( void *pvParameters ) * void vFunction( void *pvParameters )
* { * {
* // Create a queue to hold one uint32_t value. It is strongly * // Create a queue to hold one uint32_t value. It is strongly
* // recommended *not* to use xQueueOverwriteFromISR() on queues that can * // recommended \*not\* to use xQueueOverwriteFromISR() on queues that can
* // contain more than one value, and doing so will trigger an assertion * // contain more than one value, and doing so will trigger an assertion
* // if configASSERT() is defined. * // if configASSERT() is defined.
* xQueue = xQueueCreate( 1, sizeof( uint32_t ) ); * xQueue = xQueueCreate( 1, sizeof( uint32_t ) );
@@ -988,11 +1203,26 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xQueueOverwriteFromISR xQueueOverwriteFromISR
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
#define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE ) #define xQueueOverwriteFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \
xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueOVERWRITE )
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueueSendFromISR(
* QueueHandle_t xQueue,
* const void *pvItemToQueue,
* BaseType_t *pxHigherPriorityTaskWoken
* );
* </pre>
* @endcond
*
* This is a macro that calls xQueueGenericSendFromISR(). It is included * This is a macro that calls xQueueGenericSendFromISR(). It is included
* for backward compatibility with versions of FreeRTOS.org that did not * for backward compatibility with versions of FreeRTOS.org that did not
* include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR() * include the xQueueSendToBackFromISR() and xQueueSendToFrontFromISR()
@@ -1052,12 +1282,29 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
* } * }
* @endcode * @endcode
* *
* @cond
* \defgroup xQueueSendFromISR xQueueSendFromISR
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
#define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK ) #define xQueueSendFromISR( xQueue, pvItemToQueue, pxHigherPriorityTaskWoken ) \
xQueueGenericSendFromISR( ( xQueue ), ( pvItemToQueue ), ( pxHigherPriorityTaskWoken ), queueSEND_TO_BACK )
/** @cond */
/**@{*/ /**@{*/
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueueGenericSendFromISR(
* QueueHandle_t xQueue,
* const void *pvItemToQueue,
* BaseType_t *pxHigherPriorityTaskWoken,
* BaseType_t xCopyPosition
* );
* </pre>
* @endcond
*
* It is preferred that the macros xQueueSendFromISR(), * It is preferred that the macros xQueueSendFromISR(),
* xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place * xQueueSendToFrontFromISR() and xQueueSendToBackFromISR() be used in place
* of calling this function directly. xQueueGiveFromISR() is an * of calling this function directly. xQueueGiveFromISR() is an
@@ -1120,13 +1367,30 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
* } * }
* } * }
* @endcode * @endcode
*
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue, const void * const pvItemToQueue, BaseType_t * const pxHigherPriorityTaskWoken, const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION; BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,
BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; const void * const pvItemToQueue,
BaseType_t * const pxHigherPriorityTaskWoken,
const BaseType_t xCopyPosition ) PRIVILEGED_FUNCTION;
BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
/**@}*/ /**@}*/
/** @endcond */
/** /**
* @cond
* queue. h
* <pre>
* BaseType_t xQueueReceiveFromISR(
* QueueHandle_t xQueue,
* void *pvBuffer,
* BaseType_t *pxTaskWoken
* );
* </pre>
* @endcond
*
* Receive an item from a queue. It is safe to use this function from within an * Receive an item from a queue. It is safe to use this function from within an
* interrupt service routine. * interrupt service routine.
* *
@@ -1146,6 +1410,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherP
* *
* Example usage: * Example usage:
* @code{c} * @code{c}
*
* QueueHandle_t xQueue; * QueueHandle_t xQueue;
* *
* // Function to create a queue and post some values. * // Function to create a queue and post some values.
@@ -1200,9 +1465,14 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue, BaseType_t * const pxHigherP
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xQueueReceiveFromISR xQueueReceiveFromISR
* @endcond
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue, void * const pvBuffer, BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue,
void * const pvBuffer,
BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
/* /*
* Utilities to query queues that are safe to use from an ISR. These utilities * Utilities to query queues that are safe to use from an ISR. These utilities
@@ -1213,7 +1483,7 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUN
UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
/** @cond */ /** @cond */
/** /*
* The functions defined above are for passing data to and from tasks. The * The functions defined above are for passing data to and from tasks. The
* functions below are the equivalents for passing data to and from * functions below are the equivalents for passing data to and from
* co-routines. * co-routines.
@@ -1222,10 +1492,18 @@ UBaseType_t uxQueueMessagesWaitingFromISR( const QueueHandle_t xQueue ) PRIVILEG
* should not be called directly from application code. Instead use the macro * should not be called directly from application code. Instead use the macro
* wrappers defined within croutine.h. * wrappers defined within croutine.h.
*/ */
BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue, const void *pvItemToQueue, BaseType_t xCoRoutinePreviouslyWoken ); BaseType_t xQueueCRSendFromISR( QueueHandle_t xQueue,
BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue, void *pvBuffer, BaseType_t *pxTaskWoken ); const void * pvItemToQueue,
BaseType_t xQueueCRSend( QueueHandle_t xQueue, const void *pvItemToQueue, TickType_t xTicksToWait ); BaseType_t xCoRoutinePreviouslyWoken );
BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait ); BaseType_t xQueueCRReceiveFromISR( QueueHandle_t xQueue,
void * pvBuffer,
BaseType_t * pxTaskWoken );
BaseType_t xQueueCRSend( QueueHandle_t xQueue,
const void * pvItemToQueue,
TickType_t xTicksToWait );
BaseType_t xQueueCRReceive( QueueHandle_t xQueue,
void * pvBuffer,
TickType_t xTicksToWait );
/** /**
* For internal use only. Use xSemaphoreCreateMutex(), * For internal use only. Use xSemaphoreCreateMutex(),
@@ -1233,10 +1511,15 @@ BaseType_t xQueueCRReceive( QueueHandle_t xQueue, void *pvBuffer, TickType_t xTi
* these functions directly. * these functions directly.
*/ */
QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; QueueHandle_t xQueueCreateMutex( const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType, StaticQueue_t *pxStaticQueue ) PRIVILEGED_FUNCTION; QueueHandle_t xQueueCreateMutexStatic( const uint8_t ucQueueType,
QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION; StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount, const UBaseType_t uxInitialCount, StaticQueue_t *pxStaticQueue ) PRIVILEGED_FUNCTION; QueueHandle_t xQueueCreateCountingSemaphore( const UBaseType_t uxMaxCount,
BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; const UBaseType_t uxInitialCount ) PRIVILEGED_FUNCTION;
QueueHandle_t xQueueCreateCountingSemaphoreStatic( const UBaseType_t uxMaxCount,
const UBaseType_t uxInitialCount,
StaticQueue_t * pxStaticQueue ) PRIVILEGED_FUNCTION;
BaseType_t xQueueSemaphoreTake( QueueHandle_t xQueue,
TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; TaskHandle_t xQueueGetMutexHolder( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;
TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION; TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_FUNCTION;
@@ -1244,7 +1527,8 @@ TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore ) PRIVILEGED_
* For internal use only. Use xSemaphoreTakeMutexRecursive() or * For internal use only. Use xSemaphoreTakeMutexRecursive() or
* xSemaphoreGiveMutexRecursive() instead of calling these functions directly. * xSemaphoreGiveMutexRecursive() instead of calling these functions directly.
*/ */
BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; BaseType_t xQueueTakeMutexRecursive( QueueHandle_t xMutex,
TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION; BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION;
/** @endcond */ /** @endcond */
@@ -1277,8 +1561,8 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION;
* stores a pointer to the string - so the string must be persistent (global or * stores a pointer to the string - so the string must be persistent (global or
* preferably in ROM/Flash), not on the stack. * preferably in ROM/Flash), not on the stack.
*/ */
#if( configQUEUE_REGISTRY_SIZE > 0 ) #if ( configQUEUE_REGISTRY_SIZE > 0 )
void vQueueAddToRegistry( QueueHandle_t xQueue, const char *pcQueueName ) PRIVILEGED_FUNCTION; /**lint !e971 Unqualified char types are allowed for strings and single characters only. */ void vQueueAddToRegistry( QueueHandle_t xQueue, const char * pcQueueName ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
#endif #endif
/** /**
@@ -1291,7 +1575,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION;
* *
* @param xQueue The handle of the queue being removed from the registry. * @param xQueue The handle of the queue being removed from the registry.
*/ */
#if( configQUEUE_REGISTRY_SIZE > 0 ) #if ( configQUEUE_REGISTRY_SIZE > 0 )
void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; void vQueueUnregisterQueue( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
#endif #endif
@@ -1306,26 +1590,32 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION;
* queue is returned. If the queue is not in the registry then NULL is * queue is returned. If the queue is not in the registry then NULL is
* returned. * returned.
*/ */
#if( configQUEUE_REGISTRY_SIZE > 0 ) #if ( configQUEUE_REGISTRY_SIZE > 0 )
const char *pcQueueGetName( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /**lint !e971 Unqualified char types are allowed for strings and single characters only. */ const char * pcQueueGetName( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
#endif #endif
/** /**
* Generic version of the function used to creaet a queue using dynamic memory * Generic version of the function used to create a queue using dynamic memory
* allocation. This is called by other functions and macros that create other * allocation. This is called by other functions and macros that create other
* RTOS objects that use the queue structure as their base. * RTOS objects that use the queue structure as their base.
*/ */
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength,
const UBaseType_t uxItemSize,
const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
#endif #endif
/** /**
* Generic version of the function used to creaet a queue using dynamic memory * Generic version of the function used to create a queue using dynamic memory
* allocation. This is called by other functions and macros that create other * allocation. This is called by other functions and macros that create other
* RTOS objects that use the queue structure as their base. * RTOS objects that use the queue structure as their base.
*/ */
#if( configSUPPORT_STATIC_ALLOCATION == 1 ) #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType ) PRIVILEGED_FUNCTION; QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength,
const UBaseType_t uxItemSize,
uint8_t * pucQueueStorage,
StaticQueue_t * pxStaticQueue,
const uint8_t ucQueueType ) PRIVILEGED_FUNCTION;
#endif #endif
/** /**
@@ -1342,7 +1632,7 @@ BaseType_t xQueueGiveMutexRecursive( QueueHandle_t xMutex ) PRIVILEGED_FUNCTION;
* or semaphores contained in the set is in a state where a queue read or * or semaphores contained in the set is in a state where a queue read or
* semaphore take operation would be successful. * semaphore take operation would be successful.
* *
* Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html * Note 1: See the documentation on https://www.FreeRTOS.org/RTOS-queue-sets.html
* for reasons why queue sets are very rarely needed in practice as there are * for reasons why queue sets are very rarely needed in practice as there are
* simpler methods of blocking on multiple objects. * simpler methods of blocking on multiple objects.
* *
@@ -1400,7 +1690,8 @@ QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength ) PRIVILE
* queue set because it is already a member of a different queue set then pdFAIL * queue set because it is already a member of a different queue set then pdFAIL
* is returned. * is returned.
*/ */
BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore,
QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
/** /**
* Removes a queue or semaphore from a queue set. A queue or semaphore can only * Removes a queue or semaphore from a queue set. A queue or semaphore can only
@@ -1419,7 +1710,8 @@ BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHan
* then pdPASS is returned. If the queue was not in the queue set, or the * then pdPASS is returned. If the queue was not in the queue set, or the
* queue (or semaphore) was not empty, then pdFAIL is returned. * queue (or semaphore) was not empty, then pdFAIL is returned.
*/ */
BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION; BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore,
QueueSetHandle_t xQueueSet ) PRIVILEGED_FUNCTION;
/** /**
* xQueueSelectFromSet() selects from the members of a queue set a queue or * xQueueSelectFromSet() selects from the members of a queue set a queue or
@@ -1431,7 +1723,7 @@ BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueS
* See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this * See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this
* function. * function.
* *
* Note 1: See the documentation on http://wwwFreeRTOS.org/RTOS-queue-sets.html * Note 1: See the documentation on https://www.FreeRTOS.org/RTOS-queue-sets.html
* for reasons why queue sets are very rarely needed in practice as there are * for reasons why queue sets are very rarely needed in practice as there are
* simpler methods of blocking on multiple objects. * simpler methods of blocking on multiple objects.
* *
@@ -1455,7 +1747,8 @@ BaseType_t xQueueRemoveFromSet( QueueSetMemberHandle_t xQueueOrSemaphore, QueueS
* in the queue set that is available, or NULL if no such queue or semaphore * in the queue set that is available, or NULL if no such queue or semaphore
* exists before before the specified block time expires. * exists before before the specified block time expires.
*/ */
QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet,
const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
/** /**
* A version of xQueueSelectFromSet() that can be used from an ISR. * A version of xQueueSelectFromSet() that can be used from an ISR.
@@ -1465,16 +1758,22 @@ QueueSetMemberHandle_t xQueueSelectFromSetFromISR( QueueSetHandle_t xQueueSet )
/** @cond */ /** @cond */
/* Not public API functions. */ /* Not public API functions. */
void vQueueWaitForMessageRestricted( QueueHandle_t xQueue, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; void vQueueWaitForMessageRestricted( QueueHandle_t xQueue,
BaseType_t xQueueGenericReset( QueueHandle_t xQueue, BaseType_t xNewQueue ) PRIVILEGED_FUNCTION; TickType_t xTicksToWait,
void vQueueSetQueueNumber( QueueHandle_t xQueue, UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION; const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
BaseType_t xNewQueue ) PRIVILEGED_FUNCTION;
void vQueueSetQueueNumber( QueueHandle_t xQueue,
UBaseType_t uxQueueNumber ) PRIVILEGED_FUNCTION;
UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
/** @endcond */ /** @endcond */
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* *INDENT-ON* */
#endif /* QUEUE_H */ #endif /* QUEUE_H */

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
#ifndef SEMAPHORE_H #ifndef SEMAPHORE_H
@@ -43,11 +42,13 @@ typedef QueueHandle_t SemaphoreHandle_t;
/** @cond */ /** @cond */
/** /**
* semphr. h * semphr. h
* <pre>vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore )</pre> * <pre>
* vSemaphoreCreateBinary( SemaphoreHandle_t xSemaphore );
* </pre>
* *
* In many usage scenarios it is faster and more memory efficient to use a * In many usage scenarios it is faster and more memory efficient to use a
* direct to task notification in place of a binary semaphore! * direct to task notification in place of a binary semaphore!
* http://www.freertos.org/RTOS-task-notifications.html * https://www.FreeRTOS.org/RTOS-task-notifications.html
* *
* This old vSemaphoreCreateBinary() macro is now deprecated in favour of the * This old vSemaphoreCreateBinary() macro is now deprecated in favour of the
* xSemaphoreCreateBinary() function. Note that binary semaphores created using * xSemaphoreCreateBinary() function. Note that binary semaphores created using
@@ -71,7 +72,7 @@ typedef QueueHandle_t SemaphoreHandle_t;
* @param xSemaphore Handle to the created semaphore. Should be of type SemaphoreHandle_t. * @param xSemaphore Handle to the created semaphore. Should be of type SemaphoreHandle_t.
* *
* Example usage: * Example usage:
* @code{c} * <pre>
* SemaphoreHandle_t xSemaphore = NULL; * SemaphoreHandle_t xSemaphore = NULL;
* *
* void vATask( void * pvParameters ) * void vATask( void * pvParameters )
@@ -86,10 +87,13 @@ typedef QueueHandle_t SemaphoreHandle_t;
* // The semaphore can now be used. * // The semaphore can now be used.
* } * }
* } * }
* @endcode * </pre>
* @cond
* \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary
* @endcond
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
#define vSemaphoreCreateBinary( xSemaphore ) \ #define vSemaphoreCreateBinary( xSemaphore ) \
{ \ { \
( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \ ( xSemaphore ) = xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \
@@ -102,18 +106,25 @@ typedef QueueHandle_t SemaphoreHandle_t;
/** @endcond */ /** @endcond */
/** /**
* @cond
* semphr. h
* <pre>
* SemaphoreHandle_t xSemaphoreCreateBinary( void );
* </pre>
* @endcond
*
* Creates a new binary semaphore instance, and returns a handle by which the * Creates a new binary semaphore instance, and returns a handle by which the
* new semaphore can be referenced. * new semaphore can be referenced.
* *
* In many usage scenarios it is faster and more memory efficient to use a * In many usage scenarios it is faster and more memory efficient to use a
* direct to task notification in place of a binary semaphore! * direct to task notification in place of a binary semaphore!
* http://www.freertos.org/RTOS-task-notifications.html * https://www.FreeRTOS.org/RTOS-task-notifications.html
* *
* Internally, within the FreeRTOS implementation, binary semaphores use a block * Internally, within the FreeRTOS implementation, binary semaphores use a block
* of memory, in which the semaphore structure is stored. If a binary semaphore * of memory, in which the semaphore structure is stored. If a binary semaphore
* is created using xSemaphoreCreateBinary() then the required memory is * is created using xSemaphoreCreateBinary() then the required memory is
* automatically dynamically allocated inside the xSemaphoreCreateBinary() * automatically dynamically allocated inside the xSemaphoreCreateBinary()
* function. (see http://www.freertos.org/a00111.html). If a binary semaphore * function. (see https://www.FreeRTOS.org/a00111.html). If a binary semaphore
* is created using xSemaphoreCreateBinaryStatic() then the application writer * is created using xSemaphoreCreateBinaryStatic() then the application writer
* must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a * must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a
* binary semaphore to be created without using any dynamic memory allocation. * binary semaphore to be created without using any dynamic memory allocation.
@@ -141,7 +152,7 @@ typedef QueueHandle_t SemaphoreHandle_t;
* *
* void vATask( void * pvParameters ) * void vATask( void * pvParameters )
* { * {
* // Semaphore cannot be used before a call to vSemaphoreCreateBinary (). * // Semaphore cannot be used before a call to vSemaphoreCreateBinary().
* // This is a macro so pass the variable in directly. * // This is a macro so pass the variable in directly.
* xSemaphore = xSemaphoreCreateBinary(); * xSemaphore = xSemaphoreCreateBinary();
* *
@@ -152,25 +163,35 @@ typedef QueueHandle_t SemaphoreHandle_t;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xSemaphoreCreateBinary xSemaphoreCreateBinary
* @endcond
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
#define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ) #define xSemaphoreCreateBinary() xQueueGenericCreate( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE )
#endif #endif
/** /**
* @cond
* semphr. h
* <pre>
* SemaphoreHandle_t xSemaphoreCreateBinaryStatic( StaticSemaphore_t *pxSemaphoreBuffer );
* </pre>
* @endcond
*
* Creates a new binary semaphore instance, and returns a handle by which the * Creates a new binary semaphore instance, and returns a handle by which the
* new semaphore can be referenced. * new semaphore can be referenced.
* *
* NOTE: In many usage scenarios it is faster and more memory efficient to use a * NOTE: In many usage scenarios it is faster and more memory efficient to use a
* direct to task notification in place of a binary semaphore! * direct to task notification in place of a binary semaphore!
* http://www.freertos.org/RTOS-task-notifications.html * https://www.FreeRTOS.org/RTOS-task-notifications.html
* *
* Internally, within the FreeRTOS implementation, binary semaphores use a block * Internally, within the FreeRTOS implementation, binary semaphores use a block
* of memory, in which the semaphore structure is stored. If a binary semaphore * of memory, in which the semaphore structure is stored. If a binary semaphore
* is created using xSemaphoreCreateBinary() then the required memory is * is created using xSemaphoreCreateBinary() then the required memory is
* automatically dynamically allocated inside the xSemaphoreCreateBinary() * automatically dynamically allocated inside the xSemaphoreCreateBinary()
* function. (see http://www.freertos.org/a00111.html). If a binary semaphore * function. (see https://www.FreeRTOS.org/a00111.html). If a binary semaphore
* is created using xSemaphoreCreateBinaryStatic() then the application writer * is created using xSemaphoreCreateBinaryStatic() then the application writer
* must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a * must provide the memory. xSemaphoreCreateBinaryStatic() therefore allows a
* binary semaphore to be created without using any dynamic memory allocation. * binary semaphore to be created without using any dynamic memory allocation.
@@ -208,21 +229,34 @@ typedef QueueHandle_t SemaphoreHandle_t;
* // Rest of task code goes here. * // Rest of task code goes here.
* } * }
* @endcode * @endcode
* @cond
* \defgroup xSemaphoreCreateBinaryStatic xSemaphoreCreateBinaryStatic
* @endcond
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#if( configSUPPORT_STATIC_ALLOCATION == 1 ) #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
#define xSemaphoreCreateBinaryStatic( pxStaticSemaphore ) xQueueGenericCreateStatic( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticSemaphore, queueQUEUE_TYPE_BINARY_SEMAPHORE ) #define xSemaphoreCreateBinaryStatic( pxStaticSemaphore ) xQueueGenericCreateStatic( ( UBaseType_t ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, pxStaticSemaphore, queueQUEUE_TYPE_BINARY_SEMAPHORE )
#endif /* configSUPPORT_STATIC_ALLOCATION */ #endif /* configSUPPORT_STATIC_ALLOCATION */
/** /**
* @cond
* semphr. h
* <pre>
* xSemaphoreTake(
* SemaphoreHandle_t xSemaphore,
* TickType_t xBlockTime
* );
* </pre>
* @endcond
*
* <i>Macro</i> to obtain a semaphore. The semaphore must have previously been * <i>Macro</i> to obtain a semaphore. The semaphore must have previously been
* created with a call to xSemaphoreCreateBinary(), xSemaphoreCreateMutex() or * created with a call to xSemaphoreCreateBinary(), xSemaphoreCreateMutex() or
* xSemaphoreCreateCounting(). * xSemaphoreCreateCounting().
* *
* @param xSemaphore A handle to the semaphore being taken - obtained when * param xSemaphore A handle to the semaphore being taken - obtained when
* the semaphore was created. * the semaphore was created.
* *
* @param xBlockTime The time in ticks to wait for the semaphore to become * param xBlockTime The time in ticks to wait for the semaphore to become
* available. The macro portTICK_PERIOD_MS can be used to convert this to a * available. The macro portTICK_PERIOD_MS can be used to convert this to a
* real time. A block time of zero can be used to poll the semaphore. A block * real time. A block time of zero can be used to poll the semaphore. A block
* time of portMAX_DELAY can be used to block indefinitely (provided * time of portMAX_DELAY can be used to block indefinitely (provided
@@ -270,6 +304,9 @@ typedef QueueHandle_t SemaphoreHandle_t;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xSemaphoreTake xSemaphoreTake
* @endcond
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueSemaphoreTake( ( xSemaphore ), ( xBlockTime ) ) #define xSemaphoreTake( xSemaphore, xBlockTime ) xQueueSemaphoreTake( ( xSemaphore ), ( xBlockTime ) )
@@ -356,6 +393,9 @@ typedef QueueHandle_t SemaphoreHandle_t;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xSemaphoreTakeRecursive xSemaphoreTakeRecursive
* @endcond
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) ) #define xSemaphoreTakeRecursive( xMutex, xBlockTime ) xQueueTakeMutexRecursive( ( xMutex ), ( xBlockTime ) )
@@ -431,13 +471,20 @@ typedef QueueHandle_t SemaphoreHandle_t;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xSemaphoreGive xSemaphoreGive
* @endcond
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK ) #define xSemaphoreGive( xSemaphore ) xQueueGenericSend( ( QueueHandle_t ) ( xSemaphore ), NULL, semGIVE_BLOCK_TIME, queueSEND_TO_BACK )
/** /**
* @cond
* semphr. h * semphr. h
* <pre>xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex )</pre> * <pre>
* xSemaphoreGiveRecursive( SemaphoreHandle_t xMutex );
* </pre>
* @endcond
* *
* <i>Macro</i> to recursively release, or 'give', a mutex type semaphore. * <i>Macro</i> to recursively release, or 'give', a mutex type semaphore.
* The mutex must have previously been created using a call to * The mutex must have previously been created using a call to
@@ -514,6 +561,9 @@ typedef QueueHandle_t SemaphoreHandle_t;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xSemaphoreGiveRecursive xSemaphoreGiveRecursive
* @endcond
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) ) #define xSemaphoreGiveRecursive( xMutex ) xQueueGiveMutexRecursive( ( xMutex ) )
@@ -614,11 +664,24 @@ typedef QueueHandle_t SemaphoreHandle_t;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xSemaphoreGiveFromISR xSemaphoreGiveFromISR
* @endcond
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) ) #define xSemaphoreGiveFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueGiveFromISR( ( QueueHandle_t ) ( xSemaphore ), ( pxHigherPriorityTaskWoken ) )
/** /**
* @cond
* semphr. h
* <pre>
* xSemaphoreTakeFromISR(
* SemaphoreHandle_t xSemaphore,
* BaseType_t *pxHigherPriorityTaskWoken
* );
* </pre>
* @endcond
*
* <i>Macro</i> to take a semaphore from an ISR. The semaphore must have * <i>Macro</i> to take a semaphore from an ISR. The semaphore must have
* previously been created with a call to xSemaphoreCreateBinary() or * previously been created with a call to xSemaphoreCreateBinary() or
* xSemaphoreCreateCounting(). * xSemaphoreCreateCounting().
@@ -646,14 +709,21 @@ typedef QueueHandle_t SemaphoreHandle_t;
#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) ) #define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) )
/** /**
* <i>Macro</i> that implements a mutex semaphore by using the existing queue * @cond
* mechanism. * semphr. h
* <pre>
* SemaphoreHandle_t xSemaphoreCreateMutex( void );
* </pre>
* @endcond
*
* Creates a new mutex type semaphore instance, and returns a handle by which
* the new mutex can be referenced.
* *
* Internally, within the FreeRTOS implementation, mutex semaphores use a block * Internally, within the FreeRTOS implementation, mutex semaphores use a block
* of memory, in which the mutex structure is stored. If a mutex is created * of memory, in which the mutex structure is stored. If a mutex is created
* using xSemaphoreCreateMutex() then the required memory is automatically * using xSemaphoreCreateMutex() then the required memory is automatically
* dynamically allocated inside the xSemaphoreCreateMutex() function. (see * dynamically allocated inside the xSemaphoreCreateMutex() function. (see
* http://www.freertos.org/a00111.html). If a mutex is created using * https://www.FreeRTOS.org/a00111.html). If a mutex is created using
* xSemaphoreCreateMutexStatic() then the application writer must provided the * xSemaphoreCreateMutexStatic() then the application writer must provided the
* memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created * memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created
* without using any dynamic memory allocation. * without using any dynamic memory allocation.
@@ -694,13 +764,23 @@ typedef QueueHandle_t SemaphoreHandle_t;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xSemaphoreCreateMutex xSemaphoreCreateMutex
* @endcond
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
#define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX ) #define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX )
#endif #endif
/** /**
* @cond
* semphr. h
* <pre>
* SemaphoreHandle_t xSemaphoreCreateMutexStatic( StaticSemaphore_t *pxMutexBuffer );
* </pre>
* @endcond
*
* Creates a new mutex type semaphore instance, and returns a handle by which * Creates a new mutex type semaphore instance, and returns a handle by which
* the new mutex can be referenced. * the new mutex can be referenced.
* *
@@ -708,7 +788,7 @@ typedef QueueHandle_t SemaphoreHandle_t;
* of memory, in which the mutex structure is stored. If a mutex is created * of memory, in which the mutex structure is stored. If a mutex is created
* using xSemaphoreCreateMutex() then the required memory is automatically * using xSemaphoreCreateMutex() then the required memory is automatically
* dynamically allocated inside the xSemaphoreCreateMutex() function. (see * dynamically allocated inside the xSemaphoreCreateMutex() function. (see
* http://www.freertos.org/a00111.html). If a mutex is created using * https://www.FreeRTOS.org/a00111.html). If a mutex is created using
* xSemaphoreCreateMutexStatic() then the application writer must provided the * xSemaphoreCreateMutexStatic() then the application writer must provided the
* memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created * memory. xSemaphoreCreateMutexStatic() therefore allows a mutex to be created
* without using any dynamic memory allocation. * without using any dynamic memory allocation.
@@ -736,7 +816,7 @@ typedef QueueHandle_t SemaphoreHandle_t;
* mutex is returned. If pxMutexBuffer was NULL then NULL is returned. * mutex is returned. If pxMutexBuffer was NULL then NULL is returned.
* *
* Example usage: * Example usage:
* @code * @code{c}
* SemaphoreHandle_t xSemaphore; * SemaphoreHandle_t xSemaphore;
* StaticSemaphore_t xMutexBuffer; * StaticSemaphore_t xMutexBuffer;
* *
@@ -751,9 +831,12 @@ typedef QueueHandle_t SemaphoreHandle_t;
* // so there is no need to check it. * // so there is no need to check it.
* } * }
* @endcode * @endcode
* @cond
* \defgroup xSemaphoreCreateMutexStatic xSemaphoreCreateMutexStatic
* @endcond
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#if( configSUPPORT_STATIC_ALLOCATION == 1 ) #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
#define xSemaphoreCreateMutexStatic( pxMutexBuffer ) xQueueCreateMutexStatic( queueQUEUE_TYPE_MUTEX, ( pxMutexBuffer ) ) #define xSemaphoreCreateMutexStatic( pxMutexBuffer ) xQueueCreateMutexStatic( queueQUEUE_TYPE_MUTEX, ( pxMutexBuffer ) )
#endif /* configSUPPORT_STATIC_ALLOCATION */ #endif /* configSUPPORT_STATIC_ALLOCATION */
@@ -830,7 +913,7 @@ typedef QueueHandle_t SemaphoreHandle_t;
* created using xSemaphoreCreateRecursiveMutex() then the required memory is * created using xSemaphoreCreateRecursiveMutex() then the required memory is
* automatically dynamically allocated inside the * automatically dynamically allocated inside the
* xSemaphoreCreateRecursiveMutex() function. (see * xSemaphoreCreateRecursiveMutex() function. (see
* http://www.freertos.org/a00111.html). If a recursive mutex is created using * https://www.FreeRTOS.org/a00111.html). If a recursive mutex is created using
* xSemaphoreCreateRecursiveMutexStatic() then the application writer must * xSemaphoreCreateRecursiveMutexStatic() then the application writer must
* provide the memory that will get used by the mutex. * provide the memory that will get used by the mutex.
* xSemaphoreCreateRecursiveMutexStatic() therefore allows a recursive mutex to * xSemaphoreCreateRecursiveMutexStatic() therefore allows a recursive mutex to
@@ -886,24 +969,31 @@ typedef QueueHandle_t SemaphoreHandle_t;
* @endcode * @endcode
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) ) #if ( ( configSUPPORT_STATIC_ALLOCATION == 1 ) && ( configUSE_RECURSIVE_MUTEXES == 1 ) )
#define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutexStatic( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore ) #define xSemaphoreCreateRecursiveMutexStatic( pxStaticSemaphore ) xQueueCreateMutexStatic( queueQUEUE_TYPE_RECURSIVE_MUTEX, pxStaticSemaphore )
#endif /* configSUPPORT_STATIC_ALLOCATION */ #endif /* configSUPPORT_STATIC_ALLOCATION */
/** /**
* @cond
* semphr. h
* <pre>
* SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount );
* </pre>
* @endcond
*
* Creates a new counting semaphore instance, and returns a handle by which the * Creates a new counting semaphore instance, and returns a handle by which the
* new counting semaphore can be referenced. * new counting semaphore can be referenced.
* *
* In many usage scenarios it is faster and more memory efficient to use a * In many usage scenarios it is faster and more memory efficient to use a
* direct to task notification in place of a counting semaphore! * direct to task notification in place of a counting semaphore!
* http://www.freertos.org/RTOS-task-notifications.html * https://www.FreeRTOS.org/RTOS-task-notifications.html
* *
* Internally, within the FreeRTOS implementation, counting semaphores use a * Internally, within the FreeRTOS implementation, counting semaphores use a
* block of memory, in which the counting semaphore structure is stored. If a * block of memory, in which the counting semaphore structure is stored. If a
* counting semaphore is created using xSemaphoreCreateCounting() then the * counting semaphore is created using xSemaphoreCreateCounting() then the
* required memory is automatically dynamically allocated inside the * required memory is automatically dynamically allocated inside the
* xSemaphoreCreateCounting() function. (see * xSemaphoreCreateCounting() function. (see
* http://www.freertos.org/a00111.html). If a counting semaphore is created * https://www.FreeRTOS.org/a00111.html). If a counting semaphore is created
* using xSemaphoreCreateCountingStatic() then the application writer can * using xSemaphoreCreateCountingStatic() then the application writer can
* instead optionally provide the memory that will get used by the counting * instead optionally provide the memory that will get used by the counting
* semaphore. xSemaphoreCreateCountingStatic() therefore allows a counting * semaphore. xSemaphoreCreateCountingStatic() therefore allows a counting
@@ -960,26 +1050,36 @@ typedef QueueHandle_t SemaphoreHandle_t;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xSemaphoreCreateCounting xSemaphoreCreateCounting
* @endcond
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
#define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) ) #define xSemaphoreCreateCounting( uxMaxCount, uxInitialCount ) xQueueCreateCountingSemaphore( ( uxMaxCount ), ( uxInitialCount ) )
#endif #endif
/** /**
* @cond
* semphr. h
* <pre>
* SemaphoreHandle_t xSemaphoreCreateCountingStatic( UBaseType_t uxMaxCount, UBaseType_t uxInitialCount, StaticSemaphore_t *pxSemaphoreBuffer );
* </pre>
* @endcond
*
* Creates a new counting semaphore instance, and returns a handle by which the * Creates a new counting semaphore instance, and returns a handle by which the
* new counting semaphore can be referenced. * new counting semaphore can be referenced.
* *
* In many usage scenarios it is faster and more memory efficient to use a * In many usage scenarios it is faster and more memory efficient to use a
* direct to task notification in place of a counting semaphore! * direct to task notification in place of a counting semaphore!
* http://www.freertos.org/RTOS-task-notifications.html * https://www.FreeRTOS.org/RTOS-task-notifications.html
* *
* Internally, within the FreeRTOS implementation, counting semaphores use a * Internally, within the FreeRTOS implementation, counting semaphores use a
* block of memory, in which the counting semaphore structure is stored. If a * block of memory, in which the counting semaphore structure is stored. If a
* counting semaphore is created using xSemaphoreCreateCounting() then the * counting semaphore is created using xSemaphoreCreateCounting() then the
* required memory is automatically dynamically allocated inside the * required memory is automatically dynamically allocated inside the
* xSemaphoreCreateCounting() function. (see * xSemaphoreCreateCounting() function. (see
* http://www.freertos.org/a00111.html). If a counting semaphore is created * https://www.FreeRTOS.org/a00111.html). If a counting semaphore is created
* using xSemaphoreCreateCountingStatic() then the application writer must * using xSemaphoreCreateCountingStatic() then the application writer must
* provide the memory. xSemaphoreCreateCountingStatic() therefore allows a * provide the memory. xSemaphoreCreateCountingStatic() therefore allows a
* counting semaphore to be created without using any dynamic memory allocation. * counting semaphore to be created without using any dynamic memory allocation.
@@ -1041,23 +1141,43 @@ typedef QueueHandle_t SemaphoreHandle_t;
* // is no need to check its value. * // is no need to check its value.
* } * }
* @endcode * @endcode
* @cond
* \defgroup xSemaphoreCreateCountingStatic xSemaphoreCreateCountingStatic
* @endcond
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#if( configSUPPORT_STATIC_ALLOCATION == 1 ) #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
#define xSemaphoreCreateCountingStatic( uxMaxCount, uxInitialCount, pxSemaphoreBuffer ) xQueueCreateCountingSemaphoreStatic( ( uxMaxCount ), ( uxInitialCount ), ( pxSemaphoreBuffer ) ) #define xSemaphoreCreateCountingStatic( uxMaxCount, uxInitialCount, pxSemaphoreBuffer ) xQueueCreateCountingSemaphoreStatic( ( uxMaxCount ), ( uxInitialCount ), ( pxSemaphoreBuffer ) )
#endif /* configSUPPORT_STATIC_ALLOCATION */ #endif /* configSUPPORT_STATIC_ALLOCATION */
/** /**
* @cond
* semphr. h
* <pre>
* void vSemaphoreDelete( SemaphoreHandle_t xSemaphore );
* </pre>
* @endcond
*
* Delete a semaphore. This function must be used with care. For example, * Delete a semaphore. This function must be used with care. For example,
* do not delete a mutex type semaphore if the mutex is held by a task. * do not delete a mutex type semaphore if the mutex is held by a task.
* *
* @param xSemaphore A handle to the semaphore to be deleted. * @param xSemaphore A handle to the semaphore to be deleted.
* *
* @cond
* \defgroup vSemaphoreDelete vSemaphoreDelete
* @endcond
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) ) #define vSemaphoreDelete( xSemaphore ) vQueueDelete( ( QueueHandle_t ) ( xSemaphore ) )
/** /**
* @cond
* semphr.h
* <pre>
* TaskHandle_t xSemaphoreGetMutexHolder( SemaphoreHandle_t xMutex );
* </pre>
* @endcond
*
* If xMutex is indeed a mutex type semaphore, return the current mutex holder. * If xMutex is indeed a mutex type semaphore, return the current mutex holder.
* If xMutex is not a mutex type semaphore, or the mutex is available (not held * If xMutex is not a mutex type semaphore, or the mutex is available (not held
* by a task), return NULL. * by a task), return NULL.
@@ -1070,6 +1190,12 @@ typedef QueueHandle_t SemaphoreHandle_t;
#define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) ) #define xSemaphoreGetMutexHolder( xSemaphore ) xQueueGetMutexHolder( ( xSemaphore ) )
/** /**
* @cond
* semphr.h
* <pre>
* TaskHandle_t xSemaphoreGetMutexHolderFromISR( SemaphoreHandle_t xMutex );
* </pre>
* @endcond
* *
* If xMutex is indeed a mutex type semaphore, return the current mutex holder. * If xMutex is indeed a mutex type semaphore, return the current mutex holder.
* If xMutex is not a mutex type semaphore, or the mutex is available (not held * If xMutex is not a mutex type semaphore, or the mutex is available (not held
@@ -1079,8 +1205,12 @@ typedef QueueHandle_t SemaphoreHandle_t;
#define xSemaphoreGetMutexHolderFromISR( xSemaphore ) xQueueGetMutexHolderFromISR( ( xSemaphore ) ) #define xSemaphoreGetMutexHolderFromISR( xSemaphore ) xQueueGetMutexHolderFromISR( ( xSemaphore ) )
/** /**
* @cond
* semphr.h * semphr.h
* <pre>UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore );</pre> * <pre>
* UBaseType_t uxSemaphoreGetCount( SemaphoreHandle_t xSemaphore );
* </pre>
* @endcond
* *
* If the semaphore is a counting semaphore then uxSemaphoreGetCount() returns * If the semaphore is a counting semaphore then uxSemaphoreGetCount() returns
* its current count value. If the semaphore is a binary semaphore then * its current count value. If the semaphore is a binary semaphore then

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
#ifndef STACK_MACROS_H #ifndef STACK_MACROS_H
@@ -64,7 +63,7 @@
#if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH < 0 ) ) #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH < 0 ) )
/* Only the current stack state is to be checked. */ /* Only the current stack state is to be checked. */
#define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \
{ \ { \
/* Is the currently saved stack pointer within the stack limit? */ \ /* Is the currently saved stack pointer within the stack limit? */ \
@@ -79,7 +78,7 @@
#if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH > 0 ) ) #if( ( configCHECK_FOR_STACK_OVERFLOW > 0 ) && ( portSTACK_GROWTH > 0 ) )
/* Only the current stack state is to be checked. */ /* Only the current stack state is to be checked. */
#define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \ #define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \
{ \ { \
\ \
@@ -114,7 +113,7 @@
#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */ #endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) ) #if ( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH > 0 ) )
#define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \ #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \
{ \ { \

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
/* /*
@@ -43,7 +42,7 @@
* (such as xStreamBufferSend()) inside a critical section and set the send * (such as xStreamBufferSend()) inside a critical section and set the send
* block time to 0. Likewise, if there are to be multiple different readers * block time to 0. Likewise, if there are to be multiple different readers
* then the application writer must place each call to a reading API function * then the application writer must place each call to a reading API function
* (such as xStreamBufferRead()) inside a critical section section and set the * (such as xStreamBufferReceive()) inside a critical section section and set the
* receive block time to 0. * receive block time to 0.
* *
*/ */
@@ -55,9 +54,11 @@
#error "include FreeRTOS.h must appear in source files before include stream_buffer.h" #error "include FreeRTOS.h must appear in source files before include stream_buffer.h"
#endif #endif
/* *INDENT-OFF* */
#if defined( __cplusplus ) #if defined( __cplusplus )
extern "C" { extern "C" {
#endif #endif
/* *INDENT-ON* */
/** /**
* Type by which stream buffers are referenced. For example, a call to * Type by which stream buffers are referenced. For example, a call to
@@ -68,7 +69,16 @@ extern "C" {
struct StreamBufferDef_t; struct StreamBufferDef_t;
typedef struct StreamBufferDef_t * StreamBufferHandle_t; typedef struct StreamBufferDef_t * StreamBufferHandle_t;
/** /**
* @cond
* message_buffer.h
*
* <pre>
* StreamBufferHandle_t xStreamBufferCreate( size_t xBufferSizeBytes, size_t xTriggerLevelBytes );
* </pre>
* @endcond
*
* Creates a new stream buffer using dynamically allocated memory. See * Creates a new stream buffer using dynamically allocated memory. See
* xStreamBufferCreateStatic() for a version that uses statically allocated * xStreamBufferCreateStatic() for a version that uses statically allocated
* memory (memory that is allocated at compile time). * memory (memory that is allocated at compile time).
@@ -124,11 +134,25 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xStreamBufferCreate xStreamBufferCreate
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
#define xStreamBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE ) #define xStreamBufferCreate( xBufferSizeBytes, xTriggerLevelBytes ) xStreamBufferGenericCreate( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE )
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* StreamBufferHandle_t xStreamBufferCreateStatic( size_t xBufferSizeBytes,
* size_t xTriggerLevelBytes,
* uint8_t *pucStreamBufferStorageArea,
* StaticStreamBuffer_t *pxStaticStreamBuffer );
* </pre>
* @endcond
*
* Creates a new stream buffer using statically allocated memory. See * Creates a new stream buffer using statically allocated memory. See
* xStreamBufferCreate() for a version that uses dynamically allocated memory. * xStreamBufferCreate() for a version that uses dynamically allocated memory.
* *
@@ -169,7 +193,7 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
* *
* // Used to dimension the array used to hold the streams. The available space * // Used to dimension the array used to hold the streams. The available space
* // will actually be one less than this, so 999. * // will actually be one less than this, so 999.
* #define STORAGE_SIZE_BYTES 1000 * \#define STORAGE_SIZE_BYTES 1000
* *
* // Defines the memory that will actually hold the streams within the stream * // Defines the memory that will actually hold the streams within the stream
* // buffer. * // buffer.
@@ -196,11 +220,26 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
* } * }
* *
* @endcode * @endcode
* @cond
* \defgroup xStreamBufferCreateStatic xStreamBufferCreateStatic
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
#define xStreamBufferCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE, pucStreamBufferStorageArea, pxStaticStreamBuffer ) #define xStreamBufferCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pucStreamBufferStorageArea, pxStaticStreamBuffer ) \
xStreamBufferGenericCreateStatic( xBufferSizeBytes, xTriggerLevelBytes, pdFALSE, pucStreamBufferStorageArea, pxStaticStreamBuffer )
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
* const void *pvTxData,
* size_t xDataLengthBytes,
* TickType_t xTicksToWait );
* </pre>
* @endcond
*
* Sends bytes to a stream buffer. The bytes are copied into the stream buffer. * Sends bytes to a stream buffer. The bytes are copied into the stream buffer.
* *
* ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
@@ -215,7 +254,7 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
* (such as xStreamBufferSend()) inside a critical section and set the send * (such as xStreamBufferSend()) inside a critical section and set the send
* block time to 0. Likewise, if there are to be multiple different readers * block time to 0. Likewise, if there are to be multiple different readers
* then the application writer must place each call to a reading API function * then the application writer must place each call to a reading API function
* (such as xStreamBufferRead()) inside a critical section and set the receive * (such as xStreamBufferReceive()) inside a critical section and set the receive
* block time to 0. * block time to 0.
* *
* Use xStreamBufferSend() to write to a stream buffer from a task. Use * Use xStreamBufferSend() to write to a stream buffer from a task. Use
@@ -280,14 +319,28 @@ typedef struct StreamBufferDef_t * StreamBufferHandle_t;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xStreamBufferSend xStreamBufferSend
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer, size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
const void *pvTxData, const void * pvTxData,
size_t xDataLengthBytes, size_t xDataLengthBytes,
TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
* const void *pvTxData,
* size_t xDataLengthBytes,
* BaseType_t *pxHigherPriorityTaskWoken );
* </pre>
* @endcond
*
* Interrupt safe version of the API function that sends a stream of bytes to * Interrupt safe version of the API function that sends a stream of bytes to
* the stream buffer. * the stream buffer.
* *
@@ -303,7 +356,7 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
* (such as xStreamBufferSend()) inside a critical section and set the send * (such as xStreamBufferSend()) inside a critical section and set the send
* block time to 0. Likewise, if there are to be multiple different readers * block time to 0. Likewise, if there are to be multiple different readers
* then the application writer must place each call to a reading API function * then the application writer must place each call to a reading API function
* (such as xStreamBufferRead()) inside a critical section and set the receive * (such as xStreamBufferReceive()) inside a critical section and set the receive
* block time to 0. * block time to 0.
* *
* Use xStreamBufferSend() to write to a stream buffer from a task. Use * Use xStreamBufferSend() to write to a stream buffer from a task. Use
@@ -339,7 +392,7 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
* *
* Example use: * Example use:
* @code{c} * @code{c}
* //A stream buffer that has already been created. * // A stream buffer that has already been created.
* StreamBufferHandle_t xStreamBuffer; * StreamBufferHandle_t xStreamBuffer;
* *
* void vAnInterruptServiceRoutine( void ) * void vAnInterruptServiceRoutine( void )
@@ -371,14 +424,28 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
* taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken );
* } * }
* @endcode * @endcode
* @cond
* \defgroup xStreamBufferSendFromISR xStreamBufferSendFromISR
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer, size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
const void *pvTxData, const void * pvTxData,
size_t xDataLengthBytes, size_t xDataLengthBytes,
BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
* void *pvRxData,
* size_t xBufferLengthBytes,
* TickType_t xTicksToWait );
* </pre>
* @endcond
*
* Receives bytes from a stream buffer. * Receives bytes from a stream buffer.
* *
* ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
@@ -393,7 +460,7 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
* (such as xStreamBufferSend()) inside a critical section and set the send * (such as xStreamBufferSend()) inside a critical section and set the send
* block time to 0. Likewise, if there are to be multiple different readers * block time to 0. Likewise, if there are to be multiple different readers
* then the application writer must place each call to a reading API function * then the application writer must place each call to a reading API function
* (such as xStreamBufferRead()) inside a critical section and set the receive * (such as xStreamBufferReceive()) inside a critical section and set the receive
* block time to 0. * block time to 0.
* *
* Use xStreamBufferReceive() to read from a stream buffer from a task. Use * Use xStreamBufferReceive() to read from a stream buffer from a task. Use
@@ -450,15 +517,28 @@ size_t xStreamBufferSendFromISR( StreamBufferHandle_t xStreamBuffer,
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xStreamBufferReceive xStreamBufferReceive
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer, size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
void *pvRxData, void * pvRxData,
size_t xBufferLengthBytes, size_t xBufferLengthBytes,
TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
* void *pvRxData,
* size_t xBufferLengthBytes,
* BaseType_t *pxHigherPriorityTaskWoken );
* </pre>
* @endcond
*
* An interrupt safe version of the API function that receives bytes from a * An interrupt safe version of the API function that receives bytes from a
* stream buffer. * stream buffer.
* *
@@ -527,14 +607,25 @@ size_t xStreamBufferReceive( StreamBufferHandle_t xStreamBuffer,
* taskYIELD_FROM_ISR( xHigherPriorityTaskWoken ); * taskYIELD_FROM_ISR( xHigherPriorityTaskWoken );
* } * }
* @endcode * @endcode
* @cond
* \defgroup xStreamBufferReceiveFromISR xStreamBufferReceiveFromISR
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer, size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
void *pvRxData, void * pvRxData,
size_t xBufferLengthBytes, size_t xBufferLengthBytes,
BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; BaseType_t * const pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer );
* </pre>
* @endcond
*
* Deletes a stream buffer that was previously created using a call to * Deletes a stream buffer that was previously created using a call to
* xStreamBufferCreate() or xStreamBufferCreateStatic(). If the stream * xStreamBufferCreate() or xStreamBufferCreateStatic(). If the stream
* buffer was created using dynamic memory (that is, by xStreamBufferCreate()), * buffer was created using dynamic memory (that is, by xStreamBufferCreate()),
@@ -545,11 +636,22 @@ size_t xStreamBufferReceiveFromISR( StreamBufferHandle_t xStreamBuffer,
* *
* @param xStreamBuffer The handle of the stream buffer to be deleted. * @param xStreamBuffer The handle of the stream buffer to be deleted.
* *
* @cond
* \defgroup vStreamBufferDelete vStreamBufferDelete
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer );
* </pre>
* @endcond
*
* Queries a stream buffer to see if it is full. A stream buffer is full if it * Queries a stream buffer to see if it is full. A stream buffer is full if it
* does not have any free space, and therefore cannot accept any more data. * does not have any free space, and therefore cannot accept any more data.
* *
@@ -558,11 +660,22 @@ void vStreamBufferDelete( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTI
* @return If the stream buffer is full then pdTRUE is returned. Otherwise * @return If the stream buffer is full then pdTRUE is returned. Otherwise
* pdFALSE is returned. * pdFALSE is returned.
* *
* @cond
* \defgroup xStreamBufferIsFull xStreamBufferIsFull
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer );
* </pre>
* @endcond
*
* Queries a stream buffer to see if it is empty. A stream buffer is empty if * Queries a stream buffer to see if it is empty. A stream buffer is empty if
* it does not contain any data. * it does not contain any data.
* *
@@ -571,11 +684,22 @@ BaseType_t xStreamBufferIsFull( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_
* @return If the stream buffer is empty then pdTRUE is returned. Otherwise * @return If the stream buffer is empty then pdTRUE is returned. Otherwise
* pdFALSE is returned. * pdFALSE is returned.
* *
* @cond
* \defgroup xStreamBufferIsEmpty xStreamBufferIsEmpty
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer );
* </pre>
* @endcond
*
* Resets a stream buffer to its initial, empty, state. Any data that was in * Resets a stream buffer to its initial, empty, state. Any data that was in
* the stream buffer is discarded. A stream buffer can only be reset if there * the stream buffer is discarded. A stream buffer can only be reset if there
* are no tasks blocked waiting to either send to or receive from the stream * are no tasks blocked waiting to either send to or receive from the stream
@@ -587,11 +711,22 @@ BaseType_t xStreamBufferIsEmpty( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED
* a task blocked waiting to send to or read from the stream buffer then the * a task blocked waiting to send to or read from the stream buffer then the
* stream buffer is not reset and pdFAIL is returned. * stream buffer is not reset and pdFAIL is returned.
* *
* @cond
* \defgroup xStreamBufferReset xStreamBufferReset
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer );
* </pre>
* @endcond
*
* Queries a stream buffer to see how much free space it contains, which is * Queries a stream buffer to see how much free space it contains, which is
* equal to the amount of data that can be sent to the stream buffer before it * equal to the amount of data that can be sent to the stream buffer before it
* is full. * is full.
@@ -601,12 +736,22 @@ BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_F
* @return The number of bytes that can be written to the stream buffer before * @return The number of bytes that can be written to the stream buffer before
* the stream buffer would be full. * the stream buffer would be full.
* *
* @cond
* \defgroup xStreamBufferSpacesAvailable xStreamBufferSpacesAvailable * \defgroup xStreamBufferSpacesAvailable xStreamBufferSpacesAvailable
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer );
* </pre>
* @endcond
*
* Queries a stream buffer to see how much data it contains, which is equal to * Queries a stream buffer to see how much data it contains, which is equal to
* the number of bytes that can be read from the stream buffer before the stream * the number of bytes that can be read from the stream buffer before the stream
* buffer would be empty. * buffer would be empty.
@@ -616,12 +761,22 @@ size_t xStreamBufferSpacesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVIL
* @return The number of bytes that can be read from the stream buffer before * @return The number of bytes that can be read from the stream buffer before
* the stream buffer would be empty. * the stream buffer would be empty.
* *
* @cond
* \defgroup xStreamBufferBytesAvailable xStreamBufferBytesAvailable * \defgroup xStreamBufferBytesAvailable xStreamBufferBytesAvailable
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel );
* </pre>
* @endcond
*
* A stream buffer's trigger level is the number of bytes that must be in the * A stream buffer's trigger level is the number of bytes that must be in the
* stream buffer before a task that is blocked on the stream buffer to * stream buffer before a task that is blocked on the stream buffer to
* wait for data is moved out of the blocked state. For example, if a task is * wait for data is moved out of the blocked state. For example, if a task is
@@ -647,11 +802,23 @@ size_t xStreamBufferBytesAvailable( StreamBufferHandle_t xStreamBuffer ) PRIVILE
* then the trigger level will be updated and pdTRUE is returned. Otherwise * then the trigger level will be updated and pdTRUE is returned. Otherwise
* pdFALSE is returned. * pdFALSE is returned.
* *
* @cond
* \defgroup xStreamBufferSetTriggerLevel xStreamBufferSetTriggerLevel
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, size_t xTriggerLevel ) PRIVILEGED_FUNCTION; BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer,
size_t xTriggerLevel ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken );
* </pre>
* @endcond
*
* For advanced users only. * For advanced users only.
* *
* The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when * The sbSEND_COMPLETED() macro is called from within the FreeRTOS APIs when
@@ -679,11 +846,23 @@ BaseType_t xStreamBufferSetTriggerLevel( StreamBufferHandle_t xStreamBuffer, siz
* @return If a task was removed from the Blocked state then pdTRUE is returned. * @return If a task was removed from the Blocked state then pdTRUE is returned.
* Otherwise pdFALSE is returned. * Otherwise pdFALSE is returned.
* *
* @cond
* \defgroup xStreamBufferSendCompletedFromISR xStreamBufferSendCompletedFromISR
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer,
BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* stream_buffer.h
*
* <pre>
* BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken );
* </pre>
* @endcond
*
* For advanced users only. * For advanced users only.
* *
* The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when * The sbRECEIVE_COMPLETED() macro is called from within the FreeRTOS APIs when
@@ -712,9 +891,13 @@ BaseType_t xStreamBufferSendCompletedFromISR( StreamBufferHandle_t xStreamBuffer
* @return If a task was removed from the Blocked state then pdTRUE is returned. * @return If a task was removed from the Blocked state then pdTRUE is returned.
* Otherwise pdFALSE is returned. * Otherwise pdFALSE is returned.
* *
* @cond
* \defgroup xStreamBufferReceiveCompletedFromISR xStreamBufferReceiveCompletedFromISR
* @endcond
* \ingroup StreamBufferManagement * \ingroup StreamBufferManagement
*/ */
BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; BaseType_t xStreamBufferReceiveCompletedFromISR( StreamBufferHandle_t xStreamBuffer,
BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
/** @cond */ /** @cond */
/* Functions below here are not part of the public API. */ /* Functions below here are not part of the public API. */
@@ -730,16 +913,19 @@ StreamBufferHandle_t xStreamBufferGenericCreateStatic( size_t xBufferSizeBytes,
size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; size_t xStreamBufferNextMessageLengthBytes( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
#if( configUSE_TRACE_FACILITY == 1 ) #if ( configUSE_TRACE_FACILITY == 1 )
void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer, UBaseType_t uxStreamBufferNumber ) PRIVILEGED_FUNCTION; void vStreamBufferSetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer,
UBaseType_t uxStreamBufferNumber ) PRIVILEGED_FUNCTION;
UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; UBaseType_t uxStreamBufferGetStreamBufferNumber( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION; uint8_t ucStreamBufferGetStreamBufferType( StreamBufferHandle_t xStreamBuffer ) PRIVILEGED_FUNCTION;
#endif #endif
/** @endcond */ /** @endcond */
/* *INDENT-OFF* */
#if defined( __cplusplus ) #if defined( __cplusplus )
} }
#endif #endif
/* *INDENT-ON* */
#endif /* !defined( STREAM_BUFFER_H ) */ #endif /* !defined( STREAM_BUFFER_H ) */

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
@@ -36,9 +35,11 @@
#include "list.h" #include "list.h"
#include "freertos/portmacro.h" #include "freertos/portmacro.h"
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* *INDENT-ON* */
/*----------------------------------------------------------- /*-----------------------------------------------------------
* MACROS AND DEFINITIONS * MACROS AND DEFINITIONS
@@ -59,10 +60,15 @@ extern "C" {
#define tskNO_AFFINITY ( 0x7FFFFFFF ) #define tskNO_AFFINITY ( 0x7FFFFFFF )
/** /**
* task. h
*
* Type by which tasks are referenced. For example, a call to xTaskCreate * Type by which tasks are referenced. For example, a call to xTaskCreate
* returns (via a pointer parameter) an TaskHandle_t variable that can then * returns (via a pointer parameter) an TaskHandle_t variable that can then
* be used as a parameter to vTaskDelete to delete the task. * be used as a parameter to vTaskDelete to delete the task.
* *
* @cond
* \defgroup TaskHandle_t TaskHandle_t
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */ struct tskTaskControlBlock; /* The old naming convention is used to prevent breaking kernel aware debuggers. */
@@ -72,7 +78,7 @@ typedef void* TaskHandle_t;
* Defines the prototype to which the application task hook function must * Defines the prototype to which the application task hook function must
* conform. * conform.
*/ */
typedef BaseType_t (*TaskHookFunction_t)( void * ); typedef BaseType_t (* TaskHookFunction_t)( void * );
/** Task states returned by eTaskGetState. */ /** Task states returned by eTaskGetState. */
typedef enum typedef enum
@@ -110,7 +116,7 @@ typedef struct xTIME_OUT
*/ */
typedef struct xMEMORY_REGION typedef struct xMEMORY_REGION
{ {
void *pvBaseAddress; void * pvBaseAddress;
uint32_t ulLengthInBytes; uint32_t ulLengthInBytes;
uint32_t ulParameters; uint32_t ulParameters;
} MemoryRegion_t; } MemoryRegion_t;
@@ -123,9 +129,9 @@ typedef struct xTASK_PARAMETERS
TaskFunction_t pvTaskCode; TaskFunction_t pvTaskCode;
const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ const char * const pcName; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
configSTACK_DEPTH_TYPE usStackDepth; configSTACK_DEPTH_TYPE usStackDepth;
void *pvParameters; void * pvParameters;
UBaseType_t uxPriority; UBaseType_t uxPriority;
StackType_t *puxStackBuffer; StackType_t * puxStackBuffer;
MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ]; MemoryRegion_t xRegions[ portNUM_CONFIGURABLE_REGIONS ];
#if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
StaticTask_t * const pxTaskBuffer; StaticTask_t * const pxTaskBuffer;
@@ -139,7 +145,7 @@ typedef struct xTASK_PARAMETERS
typedef struct xTASK_STATUS typedef struct xTASK_STATUS
{ {
TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */ TaskHandle_t xHandle; /* The handle of the task to which the rest of the information in the structure relates. */
const char *pcTaskName; /* A pointer to the task's name. This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ const char * pcTaskName; /* A pointer to the task's name. This value will be invalid if the task was deleted since the structure was populated! */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
UBaseType_t xTaskNumber; /* A number unique to the task. */ UBaseType_t xTaskNumber; /* A number unique to the task. */
eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */ eTaskState eCurrentState; /* The state in which the task existed when the structure was populated. */
UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */ UBaseType_t uxCurrentPriority; /* The priority at which the task was running (may be inherited) when the structure was populated. */
@@ -172,19 +178,29 @@ typedef enum
#define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U ) #define tskIDLE_PRIORITY ( ( UBaseType_t ) 0U )
/** /**
* task. h
*
* Macro for forcing a context switch. * Macro for forcing a context switch.
* *
* @cond
* \defgroup taskYIELD taskYIELD
* @endcond
* \ingroup SchedulerControl * \ingroup SchedulerControl
*/ */
#define taskYIELD() portYIELD() #define taskYIELD() portYIELD()
/** /**
* task. h
*
* Macro to mark the start of a critical code region. Preemptive context * Macro to mark the start of a critical code region. Preemptive context
* switches cannot occur when in a critical region. * switches cannot occur when in a critical region.
* *
* @note This may alter the stack (depending on the portable implementation) * @note This may alter the stack (depending on the portable implementation)
* so must be used with care! * so must be used with care!
* *
* @cond
* \defgroup taskENTER_CRITICAL taskENTER_CRITICAL
* @endcond
* \ingroup SchedulerControl * \ingroup SchedulerControl
*/ */
#define taskENTER_CRITICAL( x ) portENTER_CRITICAL( x ) #define taskENTER_CRITICAL( x ) portENTER_CRITICAL( x )
@@ -192,12 +208,17 @@ typedef enum
#define taskENTER_CRITICAL_ISR(mux) portENTER_CRITICAL_ISR(mux) #define taskENTER_CRITICAL_ISR(mux) portENTER_CRITICAL_ISR(mux)
/** /**
* task. h
*
* Macro to mark the end of a critical code region. Preemptive context * Macro to mark the end of a critical code region. Preemptive context
* switches cannot occur when in a critical region. * switches cannot occur when in a critical region.
* *
* @note This may alter the stack (depending on the portable implementation) * @note This may alter the stack (depending on the portable implementation)
* so must be used with care! * so must be used with care!
* *
* @cond
* \defgroup taskEXIT_CRITICAL taskEXIT_CRITICAL
* @endcond
* \ingroup SchedulerControl * \ingroup SchedulerControl
*/ */
#define taskEXIT_CRITICAL( x ) portEXIT_CRITICAL( x ) #define taskEXIT_CRITICAL( x ) portEXIT_CRITICAL( x )
@@ -205,22 +226,32 @@ typedef enum
#define taskEXIT_CRITICAL_ISR(mux) portEXIT_CRITICAL_ISR(mux) #define taskEXIT_CRITICAL_ISR(mux) portEXIT_CRITICAL_ISR(mux)
/** /**
* task. h
*
* Macro to disable all maskable interrupts. * Macro to disable all maskable interrupts.
* *
* @cond
* \defgroup taskDISABLE_INTERRUPTS taskDISABLE_INTERRUPTS
* @endcond
* \ingroup SchedulerControl * \ingroup SchedulerControl
*/ */
#define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS() #define taskDISABLE_INTERRUPTS() portDISABLE_INTERRUPTS()
/** /**
* task. h
*
* Macro to enable microcontroller interrupts. * Macro to enable microcontroller interrupts.
* *
* @cond
* \defgroup taskENABLE_INTERRUPTS taskENABLE_INTERRUPTS
* @endcond
* \ingroup SchedulerControl * \ingroup SchedulerControl
*/ */
#define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS() #define taskENABLE_INTERRUPTS() portENABLE_INTERRUPTS()
/* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is /* Definitions returned by xTaskGetSchedulerState(). taskSCHEDULER_SUSPENDED is
0 to generate more optimal code when configASSERT() is defined as the constant * 0 to generate more optimal code when configASSERT() is defined as the constant
is used in assert() statements. */ * is used in assert() statements. */
#define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 ) #define taskSCHEDULER_SUSPENDED ( ( BaseType_t ) 0 )
#define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 ) #define taskSCHEDULER_NOT_STARTED ( ( BaseType_t ) 1 )
#define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 ) #define taskSCHEDULER_RUNNING ( ( BaseType_t ) 2 )
@@ -289,7 +320,7 @@ is used in assert() statements. */
* second block is used by the task as its stack. If a task is created using * second block is used by the task as its stack. If a task is created using
* xTaskCreate() then both blocks of memory are automatically dynamically * xTaskCreate() then both blocks of memory are automatically dynamically
* allocated inside the xTaskCreate() function. (see * allocated inside the xTaskCreate() function. (see
* http://www.freertos.org/a00111.html). If a task is created using * https://www.FreeRTOS.org/a00111.html). If a task is created using
* xTaskCreateStatic() then the application writer must provide the required * xTaskCreateStatic() then the application writer must provide the required
* memory. xTaskCreateStatic() therefore allows a task to be created without * memory. xTaskCreateStatic() therefore allows a task to be created without
* using any dynamic memory allocation. * using any dynamic memory allocation.
@@ -362,10 +393,12 @@ is used in assert() statements. */
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xTaskCreate xTaskCreate
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
static inline IRAM_ATTR BaseType_t xTaskCreate( static inline IRAM_ATTR BaseType_t xTaskCreate(
TaskFunction_t pvTaskCode, TaskFunction_t pvTaskCode,
@@ -488,7 +521,7 @@ is used in assert() statements. */
* // Dimensions the buffer that the task being created will use as its stack. * // Dimensions the buffer that the task being created will use as its stack.
* // NOTE: This is the number of bytes the stack will hold, not the number of * // NOTE: This is the number of bytes the stack will hold, not the number of
* // words as found in vanilla FreeRTOS. * // words as found in vanilla FreeRTOS.
* #define STACK_SIZE 200 * \#define STACK_SIZE 200
* *
* // Structure that will hold the TCB of the task being created. * // Structure that will hold the TCB of the task being created.
* StaticTask_t xTaskBuffer; * StaticTask_t xTaskBuffer;
@@ -560,12 +593,12 @@ is used in assert() statements. */
* See xTaskCreateRestrictedStatic() for a version that does not use any * See xTaskCreateRestrictedStatic() for a version that does not use any
* dynamic memory allocation. * dynamic memory allocation.
* *
* param pxTaskDefinition Pointer to a structure that contains a member * @param pxTaskDefinition Pointer to a structure that contains a member
* for each of the normal xTaskCreate() parameters (see the xTaskCreate() API * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
* documentation) plus an optional stack buffer and the memory region * documentation) plus an optional stack buffer and the memory region
* definitions. * definitions.
* *
* param pxCreatedTask Used to pass back a handle by which the created task * @param pxCreatedTask Used to pass back a handle by which the created task
* can be referenced. * can be referenced.
* *
* return pdPASS if the task was successfully created and added to a ready * return pdPASS if the task was successfully created and added to a ready
@@ -612,10 +645,14 @@ is used in assert() statements. */
* for( ;; ); * for( ;; );
* } * }
* @endcode * @endcode
* @cond
* \defgroup xTaskCreateRestricted xTaskCreateRestricted
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
#if( portUSING_MPU_WRAPPERS == 1 ) #if ( portUSING_MPU_WRAPPERS == 1 )
BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition,
TaskHandle_t * pxCreatedTask );
#endif #endif
/* /*
@@ -635,14 +672,14 @@ is used in assert() statements. */
* xTaskCreateRestrictedStatic() therefore allows a memory protected task to be * xTaskCreateRestrictedStatic() therefore allows a memory protected task to be
* created without using any dynamic memory allocation. * created without using any dynamic memory allocation.
* *
* param pxTaskDefinition Pointer to a structure that contains a member * @param pxTaskDefinition Pointer to a structure that contains a member
* for each of the normal xTaskCreate() parameters (see the xTaskCreate() API * for each of the normal xTaskCreate() parameters (see the xTaskCreate() API
* documentation) plus an optional stack buffer and the memory region * documentation) plus an optional stack buffer and the memory region
* definitions. If configSUPPORT_STATIC_ALLOCATION is set to 1 the structure * definitions. If configSUPPORT_STATIC_ALLOCATION is set to 1 the structure
* contains an additional member, which is used to point to a variable of type * contains an additional member, which is used to point to a variable of type
* StaticTask_t - which is then used to hold the task's data structure. * StaticTask_t - which is then used to hold the task's data structure.
* *
* param pxCreatedTask Used to pass back a handle by which the created task * @param pxCreatedTask Used to pass back a handle by which the created task
* can be referenced. * can be referenced.
* *
* return pdPASS if the task was successfully created and added to a ready * return pdPASS if the task was successfully created and added to a ready
@@ -695,24 +732,34 @@ is used in assert() statements. */
* for( ;; ); * for( ;; );
* } * }
* @endcode * @endcode
* @cond
* \defgroup xTaskCreateRestrictedStatic xTaskCreateRestrictedStatic
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
#if( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) #if ( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition, TaskHandle_t *pxCreatedTask ); BaseType_t xTaskCreateRestrictedStatic( const TaskParameters_t * const pxTaskDefinition,
TaskHandle_t * pxCreatedTask );
#endif #endif
/* /**
* @cond
* task. h
* <pre>
* void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions );
* </pre>
* @endcond
*
* Memory regions are assigned to a restricted task when the task is created by * Memory regions are assigned to a restricted task when the task is created by
* a call to xTaskCreateRestricted(). These regions can be redefined using * a call to xTaskCreateRestricted(). These regions can be redefined using
* vTaskAllocateMPURegions(). * vTaskAllocateMPURegions().
* *
* param xTask The handle of the task being updated. * @param xTask The handle of the task being updated.
* *
* param pxRegions A pointer to an MemoryRegion_t structure that contains the * @param pxRegions A pointer to an MemoryRegion_t structure that contains the
* new memory region definitions. * new memory region definitions.
* *
* Example usage: * Example usage:
*
* @code{c} * @code{c}
* // Define an array of MemoryRegion_t structures that configures an MPU region * // Define an array of MemoryRegion_t structures that configures an MPU region
* // allowing read/write access for 1024 bytes starting at the beginning of the * // allowing read/write access for 1024 bytes starting at the beginning of the
@@ -741,9 +788,13 @@ is used in assert() statements. */
* // defined or shared regions have been declared elsewhere). * // defined or shared regions have been declared elsewhere).
* } * }
* @endcode * @endcode
* @cond
* \defgroup xTaskCreateRestricted xTaskCreateRestricted
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION; void vTaskAllocateMPURegions( TaskHandle_t xTask,
const MemoryRegion_t * const pxRegions ) PRIVILEGED_FUNCTION;
/** /**
* Remove a task from the RTOS real time kernel's management. The task being * Remove a task from the RTOS real time kernel's management. The task being
@@ -752,6 +803,9 @@ void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const p
* INCLUDE_vTaskDelete must be defined as 1 for this function to be available. * INCLUDE_vTaskDelete must be defined as 1 for this function to be available.
* See the configuration section for more information. * See the configuration section for more information.
* *
* Remove a task from the RTOS real time kernel's management. The task being
* deleted will be removed from all ready, blocked, suspended and event lists.
*
* NOTE: The idle task is responsible for freeing the kernel allocated * NOTE: The idle task is responsible for freeing the kernel allocated
* memory from tasks that have been deleted. It is therefore important that * memory from tasks that have been deleted. It is therefore important that
* the idle task is not starved of microcontroller processing time if your * the idle task is not starved of microcontroller processing time if your
@@ -778,6 +832,9 @@ void vTaskAllocateMPURegions( TaskHandle_t xTask, const MemoryRegion_t * const p
* vTaskDelete( xHandle ); * vTaskDelete( xHandle );
* } * }
* @endcode * @endcode
* @cond
* \defgroup vTaskDelete vTaskDelete
* @endcond
* \ingroup Tasks * \ingroup Tasks
*/ */
void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION; void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
@@ -797,6 +854,7 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
* INCLUDE_vTaskDelay must be defined as 1 for this function to be available. * INCLUDE_vTaskDelay must be defined as 1 for this function to be available.
* See the configuration section for more information. * See the configuration section for more information.
* *
*
* vTaskDelay() specifies a time at which the task wishes to unblock relative to * vTaskDelay() specifies a time at which the task wishes to unblock relative to
* the time at which vTaskDelay() is called. For example, specifying a block * the time at which vTaskDelay() is called. For example, specifying a block
* period of 100 ticks will cause the task to unblock 100 ticks after * period of 100 ticks will cause the task to unblock 100 ticks after
@@ -827,6 +885,10 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
* } * }
* } * }
* @endcode * @endcode
*
* @cond
* \defgroup vTaskDelay vTaskDelay
* @endcond
* \ingroup TaskCtrl * \ingroup TaskCtrl
*/ */
void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
@@ -884,11 +946,22 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xTaskDelayUntil xTaskDelayUntil
* @endcond
* \ingroup TaskCtrl * \ingroup TaskCtrl
*/ */
void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* task. h
* <pre>
* BaseType_t xTaskAbortDelay( TaskHandle_t xTask );
* </pre>
* @endcond
*
* INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this * INCLUDE_xTaskAbortDelay must be defined as 1 in FreeRTOSConfig.h for this
* function to be available. * function to be available.
* *
@@ -900,22 +973,36 @@ void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xT
* task will leave the Blocked state, and return from whichever function call * task will leave the Blocked state, and return from whichever function call
* placed the task into the Blocked state. * placed the task into the Blocked state.
* *
* There is no 'FromISR' version of this function as an interrupt would need to
* know which object a task was blocked on in order to know which actions to
* take. For example, if the task was blocked on a queue the interrupt handler
* would then need to know if the queue was locked.
*
* @param xTask The handle of the task to remove from the Blocked state. * @param xTask The handle of the task to remove from the Blocked state.
* *
* @return If the task referenced by xTask was not in the Blocked state then * @return If the task referenced by xTask was not in the Blocked state then
* pdFAIL is returned. Otherwise pdPASS is returned. * pdFAIL is returned. Otherwise pdPASS is returned.
* *
* @cond
* \defgroup xTaskAbortDelay xTaskAbortDelay * \defgroup xTaskAbortDelay xTaskAbortDelay
* @endcond
* \ingroup TaskCtrl * \ingroup TaskCtrl
*/ */
BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
/** /**
* Obtain the priority of any task. * @cond
* task. h
* <pre>
* UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask );
* </pre>
* @endcond
* *
* INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available. * INCLUDE_uxTaskPriorityGet must be defined as 1 for this function to be available.
* See the configuration section for more information. * See the configuration section for more information.
* *
* Obtain the priority of any task.
*
* @param xTask Handle of the task to be queried. Passing a NULL * @param xTask Handle of the task to be queried. Passing a NULL
* handle results in the priority of the calling task being returned. * handle results in the priority of the calling task being returned.
* *
@@ -949,23 +1036,39 @@ BaseType_t xTaskAbortDelay( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup uxTaskPriorityGet uxTaskPriorityGet
* @endcond
* \ingroup TaskCtrl * \ingroup TaskCtrl
*/ */
UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; UBaseType_t uxTaskPriorityGet( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* task. h
* <pre>
* UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask );
* </pre>
* @endcond
*
* A version of uxTaskPriorityGet() that can be used from an ISR. * A version of uxTaskPriorityGet() that can be used from an ISR.
*/ */
UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION; UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
/** /**
* Obtain the state of any task. * @cond
* * task. h
* States are encoded by the eTaskState enumerated type. * <pre>
* eTaskState eTaskGetState( TaskHandle_t xTask );
* </pre>
* @endcond
* *
* INCLUDE_eTaskGetState must be defined as 1 for this function to be available. * INCLUDE_eTaskGetState must be defined as 1 for this function to be available.
* See the configuration section for more information. * See the configuration section for more information.
* *
* Obtain the state of any task. States are encoded by the eTaskState
* enumerated type.
*
* @param xTask Handle of the task to be queried. * @param xTask Handle of the task to be queried.
* *
* @return The state of xTask at the time the function was called. Note the * @return The state of xTask at the time the function was called. Note the
@@ -975,11 +1078,17 @@ UBaseType_t uxTaskPriorityGetFromISR( const TaskHandle_t xTask ) PRIVILEGED_FUNC
eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
/** /**
* Populates a TaskStatus_t structure with information about a task. * @cond
* task. h
* <pre>
* void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState );
* </pre>
* @endcond
* *
* configUSE_TRACE_FACILITY must be defined as 1 for this function to be * configUSE_TRACE_FACILITY must be defined as 1 for this function to be
* available. See the configuration section for more information. * available. See the configuration section for more information.
* *
* Populates a TaskStatus_t structure with information about a task.
* *
* @param xTask Handle of the task being queried. If xTask is NULL then * @param xTask Handle of the task being queried. If xTask is NULL then
* information will be returned about the calling task. * information will be returned about the calling task.
@@ -1023,16 +1132,29 @@ eTaskState eTaskGetState( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
* eInvalid ); // Include the task state in xTaskDetails. * eInvalid ); // Include the task state in xTaskDetails.
* } * }
* @endcode * @endcode
* @cond
* \defgroup vTaskGetInfo vTaskGetInfo
* @endcond
* \ingroup TaskCtrl * \ingroup TaskCtrl
*/ */
void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xGetFreeStackSpace, eTaskState eState ) PRIVILEGED_FUNCTION; void vTaskGetInfo( TaskHandle_t xTask,
TaskStatus_t * pxTaskStatus,
BaseType_t xGetFreeStackSpace,
eTaskState eState ) PRIVILEGED_FUNCTION;
/** /**
* Set the priority of any task. * @cond
* task. h
* <pre>
* void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority );
* </pre>
* @endcond
* *
* INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available. * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available.
* See the configuration section for more information. * See the configuration section for more information.
* *
* Set the priority of any task.
*
* A context switch will occur before the function returns if the priority * A context switch will occur before the function returns if the priority
* being set is higher than the currently executing task. * being set is higher than the currently executing task.
* *
@@ -1061,9 +1183,13 @@ void vTaskGetInfo( TaskHandle_t xTask, TaskStatus_t *pxTaskStatus, BaseType_t xG
* vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 ); * vTaskPrioritySet( NULL, tskIDLE_PRIORITY + 1 );
* } * }
* @endcode * @endcode
* @cond
* \defgroup vTaskPrioritySet vTaskPrioritySet
* @endcond
* \ingroup TaskCtrl * \ingroup TaskCtrl
*/ */
void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION; void vTaskPrioritySet( TaskHandle_t xTask,
UBaseType_t uxNewPriority ) PRIVILEGED_FUNCTION;
/** /**
* Suspend a task. * Suspend a task.
@@ -1110,16 +1236,26 @@ void vTaskPrioritySet( TaskHandle_t xTask, UBaseType_t uxNewPriority ) PRIVILEGE
* // with our handle as the parameter. * // with our handle as the parameter.
* } * }
* @endcode * @endcode
* @cond
* \defgroup vTaskSuspend vTaskSuspend
* @endcond
* \ingroup TaskCtrl * \ingroup TaskCtrl
*/ */
void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION; void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION;
/** /**
* Resumes a suspended task. * @cond
* task. h
* <pre>
* void vTaskResume( TaskHandle_t xTaskToResume );
* </pre>
* @endcond
* *
* INCLUDE_vTaskSuspend must be defined as 1 for this function to be available. * INCLUDE_vTaskSuspend must be defined as 1 for this function to be available.
* See the configuration section for more information. * See the configuration section for more information.
* *
* Resumes a suspended task.
*
* A task that has been suspended by one or more calls to vTaskSuspend () * A task that has been suspended by one or more calls to vTaskSuspend ()
* will be made available for running again by a single call to * will be made available for running again by a single call to
* vTaskResume (). * vTaskResume ().
@@ -1155,6 +1291,9 @@ void vTaskSuspend( TaskHandle_t xTaskToSuspend ) PRIVILEGED_FUNCTION;
* // time in accordance with its priority within the system. * // time in accordance with its priority within the system.
* } * }
* @endcode * @endcode
* @cond
* \defgroup vTaskResume vTaskResume
* @endcond
* \ingroup TaskCtrl * \ingroup TaskCtrl
*/ */
void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
@@ -1180,6 +1319,9 @@ void vTaskResume( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
* otherwise pdFALSE. This is used by the ISR to determine if a context switch * otherwise pdFALSE. This is used by the ISR to determine if a context switch
* may be required following the ISR. * may be required following the ISR.
* *
* @cond
* \defgroup vTaskResumeFromISR vTaskResumeFromISR
* @endcond
* \ingroup TaskCtrl * \ingroup TaskCtrl
*/ */
BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION; BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
@@ -1201,7 +1343,7 @@ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
* tasks and starting the kernel. * tasks and starting the kernel.
* *
* Example usage: * Example usage:
* @code{c} * <pre>
* void vAFunction( void ) * void vAFunction( void )
* { * {
* // Create at least one task before starting the kernel. * // Create at least one task before starting the kernel.
@@ -1212,8 +1354,11 @@ BaseType_t xTaskResumeFromISR( TaskHandle_t xTaskToResume ) PRIVILEGED_FUNCTION;
* *
* // Will not get here unless a task calls vTaskEndScheduler () * // Will not get here unless a task calls vTaskEndScheduler ()
* } * }
* @endcode * </pre>
* *
* @cond
* \defgroup vTaskStartScheduler vTaskStartScheduler
* @endcond
* \ingroup SchedulerControl * \ingroup SchedulerControl
*/ */
void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION; void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
@@ -1241,7 +1386,7 @@ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
* tasks. * tasks.
* *
* Example usage: * Example usage:
* @code{c} * <pre>
* void vTaskCode( void * pvParameters ) * void vTaskCode( void * pvParameters )
* { * {
* for( ;; ) * for( ;; )
@@ -1266,7 +1411,11 @@ void vTaskStartScheduler( void ) PRIVILEGED_FUNCTION;
* // vTaskEndScheduler (). When we get here we are back to single task * // vTaskEndScheduler (). When we get here we are back to single task
* // execution. * // execution.
* } * }
* @endcode * </pre>
*
* @cond
* \defgroup vTaskEndScheduler vTaskEndScheduler
* @endcond
* \ingroup SchedulerControl * \ingroup SchedulerControl
*/ */
void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION; void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
@@ -1317,11 +1466,21 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup vTaskSuspendAll vTaskSuspendAll
* @endcond
* \ingroup SchedulerControl * \ingroup SchedulerControl
*/ */
void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION; void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* task. h
* <pre>
* BaseType_t xTaskResumeAll( void );
* </pre>
* @endcond
*
* Resumes scheduler activity after it was suspended by a call to * Resumes scheduler activity after it was suspended by a call to
* vTaskSuspendAll(). * vTaskSuspendAll().
* *
@@ -1367,6 +1526,9 @@ void vTaskSuspendAll( void ) PRIVILEGED_FUNCTION;
* } * }
* } * }
* @endcode * @endcode
* @cond
* \defgroup xTaskResumeAll xTaskResumeAll
* @endcond
* \ingroup SchedulerControl * \ingroup SchedulerControl
*/ */
BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION; BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;
@@ -1380,6 +1542,9 @@ BaseType_t xTaskResumeAll( void ) PRIVILEGED_FUNCTION;
* *
* @return The count of ticks since vTaskStartScheduler was called. * @return The count of ticks since vTaskStartScheduler was called.
* *
* @cond
* \defgroup xTaskGetTickCount xTaskGetTickCount
* @endcond
* \ingroup TaskUtils * \ingroup TaskUtils
*/ */
TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION; TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;
@@ -1394,6 +1559,9 @@ TickType_t xTaskGetTickCount( void ) PRIVILEGED_FUNCTION;
* microcontroller being used or interrupt nesting is either not supported or * microcontroller being used or interrupt nesting is either not supported or
* not being used. * not being used.
* *
* @cond
* \defgroup xTaskGetTickCountFromISR xTaskGetTickCountFromISR
* @endcond
* \ingroup TaskUtils * \ingroup TaskUtils
*/ */
TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION; TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;
@@ -1406,6 +1574,9 @@ TickType_t xTaskGetTickCountFromISR( void ) PRIVILEGED_FUNCTION;
* has been deleted but not yet freed by the idle task will also be * has been deleted but not yet freed by the idle task will also be
* included in the count. * included in the count.
* *
* @cond
* \defgroup uxTaskGetNumberOfTasks uxTaskGetNumberOfTasks
* @endcond
* \ingroup TaskUtils * \ingroup TaskUtils
*/ */
UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION; UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
@@ -1417,6 +1588,9 @@ UBaseType_t uxTaskGetNumberOfTasks( void ) PRIVILEGED_FUNCTION;
* xTaskToQuery. A task can query its own name by either passing in its own * xTaskToQuery. A task can query its own name by either passing in its own
* handle, or by setting xTaskToQuery to NULL. * handle, or by setting xTaskToQuery to NULL.
* *
* @cond
* \defgroup pcTaskGetName pcTaskGetName
* @endcond
* \ingroup TaskUtils * \ingroup TaskUtils
*/ */
char *pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ char *pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
@@ -1429,9 +1603,12 @@ char *pcTaskGetName( TaskHandle_t xTaskToQuery ) PRIVILEGED_FUNCTION; /*lint !e9
* NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle * NULL is returned if no matching name is found. INCLUDE_xTaskGetHandle
* must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available. * must be set to 1 in FreeRTOSConfig.h for pcTaskGetHandle() to be available.
* *
* @cond
* \defgroup pcTaskGetHandle pcTaskGetHandle
* @endcond
* \ingroup TaskUtils * \ingroup TaskUtils
*/ */
TaskHandle_t xTaskGetHandle( const char *pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ TaskHandle_t xTaskGetHandle( const char * pcNameToQuery ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
/** /**
* Returns the high water mark of the stack associated with xTask. * Returns the high water mark of the stack associated with xTask.
@@ -1501,23 +1678,37 @@ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVIL
uint8_t* pxTaskGetStackStart( TaskHandle_t xTask) PRIVILEGED_FUNCTION; uint8_t* pxTaskGetStackStart( TaskHandle_t xTask) PRIVILEGED_FUNCTION;
/* When using trace macros it is sometimes necessary to include task.h before /* When using trace macros it is sometimes necessary to include task.h before
FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined, * FreeRTOS.h. When this is done TaskHookFunction_t will not yet have been defined,
so the following two prototypes will cause a compilation error. This can be * so the following two prototypes will cause a compilation error. This can be
fixed by simply guarding against the inclusion of these two prototypes unless * fixed by simply guarding against the inclusion of these two prototypes unless
they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration * they are explicitly required by the configUSE_APPLICATION_TASK_TAG configuration
constant. */ * constant. */
#ifdef configUSE_APPLICATION_TASK_TAG #ifdef configUSE_APPLICATION_TASK_TAG
#if configUSE_APPLICATION_TASK_TAG == 1 #if configUSE_APPLICATION_TASK_TAG == 1
/** /**
* @cond
* task.h
* <pre>
* void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction );
* </pre>
* @endcond
*
* Sets pxHookFunction to be the task hook function used by the task xTask. * Sets pxHookFunction to be the task hook function used by the task xTask.
* @param xTask Handle of the task to set the hook function for * @param xTask Handle of the task to set the hook function for
* Passing xTask as NULL has the effect of setting the calling * Passing xTask as NULL has the effect of setting the calling
* tasks hook function. * tasks hook function.
* @param pxHookFunction Pointer to the hook function. * @param pxHookFunction Pointer to the hook function.
*/ */
void vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION; void vTaskSetApplicationTaskTag( TaskHandle_t xTask,
TaskHookFunction_t pxHookFunction ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* task.h
* <pre>
* void xTaskGetApplicationTaskTag( TaskHandle_t xTask );
* </pre>
* @endcond
* *
* Returns the pxHookFunction value assigned to the task xTask. Do not * Returns the pxHookFunction value assigned to the task xTask. Do not
* call from an interrupt service routine - call * call from an interrupt service routine - call
@@ -1525,7 +1716,13 @@ constant. */
*/ */
TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; TaskHookFunction_t xTaskGetApplicationTaskTag( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
/** /**
* @cond
* task.h
* <pre>
* void xTaskGetApplicationTaskTagFromISR( TaskHandle_t xTask );
* </pre>
* @endcond
* *
* Returns the pxHookFunction value assigned to the task xTask. Can * Returns the pxHookFunction value assigned to the task xTask. Can
* be called from an interrupt service routine. * be called from an interrupt service routine.
@@ -1534,7 +1731,7 @@ constant. */
#endif /* configUSE_APPLICATION_TASK_TAG ==1 */ #endif /* configUSE_APPLICATION_TASK_TAG ==1 */
#endif /* ifdef configUSE_APPLICATION_TASK_TAG */ #endif /* ifdef configUSE_APPLICATION_TASK_TAG */
#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 ) #if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
/** /**
* Set local storage pointer specific to the given task. * Set local storage pointer specific to the given task.
@@ -1603,6 +1800,13 @@ constant. */
#endif #endif
/** /**
* @cond
* task.h
* <pre>
* BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );
* </pre>
* @endcond
*
* Calls the hook function associated with xTask. Passing xTask as NULL has * Calls the hook function associated with xTask. Passing xTask as NULL has
* the effect of calling the Running tasks (the calling task) hook function. * the effect of calling the Running tasks (the calling task) hook function.
* *
@@ -1611,7 +1815,8 @@ constant. */
* wants. The return value is the value returned by the task hook function * wants. The return value is the value returned by the task hook function
* registered by the user. * registered by the user.
*/ */
BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) PRIVILEGED_FUNCTION; BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask,
void * pvParameter ) PRIVILEGED_FUNCTION;
/** /**
* xTaskGetIdleTaskHandle() is only available if * xTaskGetIdleTaskHandle() is only available if
@@ -1632,7 +1837,7 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
* of run time consumed by the task. See the TaskStatus_t structure * of run time consumed by the task. See the TaskStatus_t structure
* definition in this file for the full member list. * definition in this file for the full member list.
* *
* @note This function is intended for debugging use only as its use results in * NOTE: This function is intended for debugging use only as its use results in
* the scheduler remaining suspended for an extended period. * the scheduler remaining suspended for an extended period.
* *
* @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures. * @param pxTaskStatusArray A pointer to an array of TaskStatus_t structures.
@@ -1648,7 +1853,7 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
* @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in * @param pulTotalRunTime If configGENERATE_RUN_TIME_STATS is set to 1 in
* FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the * FreeRTOSConfig.h then *pulTotalRunTime is set by uxTaskGetSystemState() to the
* total run time (as defined by the run time stats clock, see * total run time (as defined by the run time stats clock, see
* http://www.freertos.org/rtos-run-time-stats.html) since the target booted. * https://www.FreeRTOS.org/rtos-run-time-stats.html) since the target booted.
* pulTotalRunTime can be set to NULL to omit the total run time information. * pulTotalRunTime can be set to NULL to omit the total run time information.
* *
* @return The number of TaskStatus_t structures that were populated by * @return The number of TaskStatus_t structures that were populated by
@@ -1719,7 +1924,9 @@ TaskHandle_t xTaskGetIdleTaskHandle( void ) PRIVILEGED_FUNCTION;
* } * }
* @endcode * @endcode
*/ */
UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION; UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray,
const UBaseType_t uxArraySize,
uint32_t * const pulTotalRunTime ) PRIVILEGED_FUNCTION;
/** /**
* List all the current tasks. * List all the current tasks.
@@ -1728,7 +1935,7 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const
* both be defined as 1 for this function to be available. See the * both be defined as 1 for this function to be available. See the
* configuration section of the FreeRTOS.org website for more information. * configuration section of the FreeRTOS.org website for more information.
* *
* @note This function will disable interrupts for its duration. It is * NOTE 1: This function will disable interrupts for its duration. It is
* not intended for normal application runtime use but as a debug aid. * not intended for normal application runtime use but as a debug aid.
* *
* Lists all the current tasks, along with their current state and stack * Lists all the current tasks, along with their current state and stack
@@ -1737,7 +1944,9 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const
* Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or * Tasks are reported as blocked ('B'), ready ('R'), deleted ('D') or
* suspended ('S'). * suspended ('S').
* *
* @note This function is provided for convenience only, and is used by many of the * PLEASE NOTE:
*
* This function is provided for convenience only, and is used by many of the
* demo applications. Do not consider it to be part of the scheduler. * demo applications. Do not consider it to be part of the scheduler.
* *
* vTaskList() calls uxTaskGetSystemState(), then formats part of the * vTaskList() calls uxTaskGetSystemState(), then formats part of the
@@ -1760,6 +1969,9 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const
* enough to contain the generated report. Approximately 40 bytes per * enough to contain the generated report. Approximately 40 bytes per
* task should be sufficient. * task should be sufficient.
* *
* @cond
* \defgroup vTaskList vTaskList
* @endcond
* \ingroup TaskUtils * \ingroup TaskUtils
*/ */
void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
@@ -1775,7 +1987,7 @@ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unquali
* value respectively. The counter should be at least 10 times the frequency of * value respectively. The counter should be at least 10 times the frequency of
* the tick count. * the tick count.
* *
* @note This function will disable interrupts for its duration. It is * NOTE 1: This function will disable interrupts for its duration. It is
* not intended for normal application runtime use but as a debug aid. * not intended for normal application runtime use but as a debug aid.
* *
* Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
@@ -1786,7 +1998,9 @@ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unquali
* task into a buffer, both as an absolute count value and as a percentage * task into a buffer, both as an absolute count value and as a percentage
* of the total system execution time. * of the total system execution time.
* *
* @note This function is provided for convenience only, and is used by many of the * NOTE 2:
*
* This function is provided for convenience only, and is used by many of the
* demo applications. Do not consider it to be part of the scheduler. * demo applications. Do not consider it to be part of the scheduler.
* *
* vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the * vTaskGetRunTimeStats() calls uxTaskGetSystemState(), then formats part of the
@@ -1810,34 +2024,45 @@ void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unquali
* contain the generated report. Approximately 40 bytes per task should * contain the generated report. Approximately 40 bytes per task should
* be sufficient. * be sufficient.
* *
* @cond
* \defgroup vTaskGetRunTimeStats vTaskGetRunTimeStats
* @endcond
* \ingroup TaskUtils * \ingroup TaskUtils
*/ */
void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ void vTaskGetRunTimeStats( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
/** /**
* configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS * @cond
* must both be defined as 1 for this function to be available. The application * task. h
* must also then provide definitions for * <pre>uint32_t ulTaskGetIdleRunTimeCounter( void );</pre>
* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE() * @endcond
* to configure a peripheral timer/counter and return the timers current count *
* value respectively. The counter should be at least 10 times the frequency of * configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS
* the tick count. * must both be defined as 1 for this function to be available. The application
* * must also then provide definitions for
* Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total * portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()
* accumulated execution time being stored for each task. The resolution * to configure a peripheral timer/counter and return the timers current count
* of the accumulated time value depends on the frequency of the timer * value respectively. The counter should be at least 10 times the frequency of
* configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro. * the tick count.
* While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total *
* execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter() * Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total
* returns the total execution time of just the idle task. * accumulated execution time being stored for each task. The resolution
* * of the accumulated time value depends on the frequency of the timer
* @return The total run time of the idle task. This is the amount of time the * configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.
* idle task has actually been executing. The unit of time is dependent on the * While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total
* frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and * execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter()
* portGET_RUN_TIME_COUNTER_VALUE() macros. * returns the total execution time of just the idle task.
* *
* \ingroup TaskUtils * @return The total run time of the idle task. This is the amount of time the
*/ * idle task has actually been executing. The unit of time is dependent on the
* frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and
* portGET_RUN_TIME_COUNTER_VALUE() macros.
*
* @cond
* \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter
* @endcond
* \ingroup TaskUtils
*/
uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION; uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;
/** /**
@@ -2341,8 +2566,11 @@ BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
* portTICK_PERIOD_MS can be used to convert kernel ticks into a real time * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time
* period. * period.
*/ */
void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; void vTaskPlaceOnEventList( List_t * const pxEventList,
void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
void vTaskPlaceOnUnorderedEventList( List_t * pxEventList,
const TickType_t xItemValue,
const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
/* /*
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
@@ -2355,7 +2583,9 @@ void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xIte
* indefinitely, whereas vTaskPlaceOnEventList() does. * indefinitely, whereas vTaskPlaceOnEventList() does.
* *
*/ */
void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTicksToWait, const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION; void vTaskPlaceOnEventListRestricted( List_t * const pxEventList,
TickType_t xTicksToWait,
const BaseType_t xWaitIndefinitely ) PRIVILEGED_FUNCTION;
/* /*
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS AN
@@ -2382,7 +2612,8 @@ void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, TickType_t xTi
* making the call, otherwise pdFALSE. * making the call, otherwise pdFALSE.
*/ */
BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION; BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION;
BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) PRIVILEGED_FUNCTION; BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem,
const TickType_t xItemValue ) PRIVILEGED_FUNCTION;
/* /*
* THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY
@@ -2448,7 +2679,8 @@ BaseType_t xTaskPriorityDisinherit( TaskHandle_t const pxMutexHolder ) PRIVILEGE
* the highest priority task that is still waiting for the mutex (if there were * the highest priority task that is still waiting for the mutex (if there were
* more than one task waiting for the mutex). * more than one task waiting for the mutex).
*/ */
void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION; void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder,
UBaseType_t uxHighestPriorityWaitingTask ) PRIVILEGED_FUNCTION;
/* /*
* Get the uxTCBNumber assigned to the task referenced by the xTask parameter. * Get the uxTCBNumber assigned to the task referenced by the xTask parameter.
@@ -2464,7 +2696,8 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask ) PRIVILEGED_FUNCTION;
* Set the uxTaskNumber of the task referenced by the xTask parameter to * Set the uxTaskNumber of the task referenced by the xTask parameter to
* uxHandle. * uxHandle.
*/ */
void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION; void vTaskSetTaskNumber( TaskHandle_t xTask,
const UBaseType_t uxHandle ) PRIVILEGED_FUNCTION;
/* /*
* Only available when configUSE_TICKLESS_IDLE is set to 1. * Only available when configUSE_TICKLESS_IDLE is set to 1.
@@ -2512,7 +2745,7 @@ eSleepModeStatus eTaskConfirmSleepModeStatus( void ) PRIVILEGED_FUNCTION;
TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION; TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;
/* /*
* For internal use only. Same as vTaskSetTimeOutState(), but without a critial * For internal use only. Same as vTaskSetTimeOutState(), but without a critical
* section. * section.
*/ */
void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION; void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
@@ -2521,7 +2754,9 @@ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNC
#include "freertos/task_snapshot.h" #include "freertos/task_snapshot.h"
/** @endcond */ /** @endcond */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* *INDENT-ON* */
#endif /* INC_TASK_H */ #endif /* INC_TASK_H */

View File

@@ -1,6 +1,6 @@
/* /*
* FreeRTOS Kernel V10.2.1 * FreeRTOS Kernel V10.2.1
* Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -19,10 +19,9 @@
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* *
* http://www.FreeRTOS.org * https://www.FreeRTOS.org
* http://aws.amazon.com/freertos * https://github.com/FreeRTOS
* *
* 1 tab == 4 spaces!
*/ */
@@ -34,23 +33,25 @@
#endif #endif
/*lint -save -e537 This headers are only multiply included if the application code /*lint -save -e537 This headers are only multiply included if the application code
happens to also be including task.h. */ * happens to also be including task.h. */
#include "task.h" #include "task.h"
/*lint -restore */ /*lint -restore */
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* *INDENT-ON* */
/*----------------------------------------------------------- /*-----------------------------------------------------------
* MACROS AND DEFINITIONS * MACROS AND DEFINITIONS
*----------------------------------------------------------*/ *----------------------------------------------------------*/
/* IDs for commands that can be sent/received on the timer queue. These are to /* IDs for commands that can be sent/received on the timer queue. These are to
be used solely through the macros that make up the public software timer API, * be used solely through the macros that make up the public software timer API,
as defined below. The commands that are sent from interrupts must use the * as defined below. The commands that are sent from interrupts must use the
highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task * highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task
or interrupt version of the queue send function should be used. */ * or interrupt version of the queue send function should be used. */
#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 ) #define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 )
#define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 ) #define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 )
#define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 ) #define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 )
@@ -79,15 +80,22 @@ typedef void* TimerHandle_t;
/* /*
* Defines the prototype to which timer callback functions must conform. * Defines the prototype to which timer callback functions must conform.
*/ */
typedef void (*TimerCallbackFunction_t)( TimerHandle_t xTimer ); typedef void (* TimerCallbackFunction_t)( TimerHandle_t xTimer );
/* /*
* Defines the prototype to which functions used with the * Defines the prototype to which functions used with the
* xTimerPendFunctionCallFromISR() function must conform. * xTimerPendFunctionCallFromISR() function must conform.
*/ */
typedef void (*PendedFunction_t)( void *, uint32_t ); typedef void (* PendedFunction_t)( void *,
uint32_t );
/** /**
* TimerHandle_t xTimerCreate( const char * const pcTimerName,
* TickType_t xTimerPeriodInTicks,
* UBaseType_t uxAutoReload,
* void * pvTimerID,
* TimerCallbackFunction_t pxCallbackFunction );
*
* Creates a new software timer instance, and returns a handle by which the * Creates a new software timer instance, and returns a handle by which the
* created software timer can be referenced. * created software timer can be referenced.
* *
@@ -95,7 +103,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
* of memory, in which the timer data structure is stored. If a software timer * of memory, in which the timer data structure is stored. If a software timer
* is created using xTimerCreate() then the required memory is automatically * is created using xTimerCreate() then the required memory is automatically
* dynamically allocated inside the xTimerCreate() function. (see * dynamically allocated inside the xTimerCreate() function. (see
* http://www.freertos.org/a00111.html). If a software timer is created using * https://www.FreeRTOS.org/a00111.html). If a software timer is created using
* xTimerCreateStatic() then the application writer must provide the memory that * xTimerCreateStatic() then the application writer must provide the memory that
* will get used by the software timer. xTimerCreateStatic() therefore allows a * will get used by the software timer. xTimerCreateStatic() therefore allows a
* software timer to be created without using any dynamic memory allocation. * software timer to be created without using any dynamic memory allocation.
@@ -115,7 +123,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
* after 100 ticks, then xTimerPeriodInTicks should be set to 100. * after 100 ticks, then xTimerPeriodInTicks should be set to 100.
* Alternatively, if the timer must expire after 500ms, then xPeriod can be set * Alternatively, if the timer must expire after 500ms, then xPeriod can be set
* to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or * to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or
* equal to 1000. * equal to 1000. Time timer period must be greater than 0.
* *
* @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
* expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter.
@@ -137,7 +145,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
* structures, or the timer period was set to 0) then NULL is returned. * structures, or the timer period was set to 0) then NULL is returned.
* *
* Example usage: * Example usage:
* @code{c} * @verbatim
* #define NUM_TIMERS 5 * #define NUM_TIMERS 5
* *
* // An array to hold handles to the created timers. * // An array to hold handles to the created timers.
@@ -216,9 +224,9 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
* // Should not reach here. * // Should not reach here.
* for( ;; ); * for( ;; );
* } * }
* @endcode * @endverbatim
*/ */
#if( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ TimerHandle_t xTimerCreate( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const TickType_t xTimerPeriodInTicks, const TickType_t xTimerPeriodInTicks,
const UBaseType_t uxAutoReload, const UBaseType_t uxAutoReload,
@@ -226,7 +234,14 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION; TimerCallbackFunction_t pxCallbackFunction ) PRIVILEGED_FUNCTION;
#endif #endif
/** /**
* TimerHandle_t xTimerCreateStatic(const char * const pcTimerName,
* TickType_t xTimerPeriodInTicks,
* UBaseType_t uxAutoReload,
* void * pvTimerID,
* TimerCallbackFunction_t pxCallbackFunction,
* StaticTimer_t *pxTimerBuffer );
*
* Creates a new software timer instance, and returns a handle by which the * Creates a new software timer instance, and returns a handle by which the
* created software timer can be referenced. * created software timer can be referenced.
* *
@@ -234,7 +249,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
* of memory, in which the timer data structure is stored. If a software timer * of memory, in which the timer data structure is stored. If a software timer
* is created using xTimerCreate() then the required memory is automatically * is created using xTimerCreate() then the required memory is automatically
* dynamically allocated inside the xTimerCreate() function. (see * dynamically allocated inside the xTimerCreate() function. (see
* http://www.freertos.org/a00111.html). If a software timer is created using * https://www.FreeRTOS.org/a00111.html). If a software timer is created using
* xTimerCreateStatic() then the application writer must provide the memory that * xTimerCreateStatic() then the application writer must provide the memory that
* will get used by the software timer. xTimerCreateStatic() therefore allows a * will get used by the software timer. xTimerCreateStatic() therefore allows a
* software timer to be created without using any dynamic memory allocation. * software timer to be created without using any dynamic memory allocation.
@@ -254,7 +269,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
* after 100 ticks, then xTimerPeriodInTicks should be set to 100. * after 100 ticks, then xTimerPeriodInTicks should be set to 100.
* Alternatively, if the timer must expire after 500ms, then xPeriod can be set * Alternatively, if the timer must expire after 500ms, then xPeriod can be set
* to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or * to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or
* equal to 1000. * equal to 1000. The timer period must be greater than 0.
* *
* @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will * @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will
* expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter.
@@ -278,7 +293,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
* returned. If pxTimerBuffer was NULL then NULL is returned. * returned. If pxTimerBuffer was NULL then NULL is returned.
* *
* Example usage: * Example usage:
* @code{c} * @verbatim
* *
* // The buffer used to hold the software timer's data structure. * // The buffer used to hold the software timer's data structure.
* static StaticTimer_t xTimerBuffer; * static StaticTimer_t xTimerBuffer;
@@ -339,15 +354,15 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
* // Should not reach here. * // Should not reach here.
* for( ;; ); * for( ;; );
* } * }
* @endcode * @endverbatim
*/ */
#if( configSUPPORT_STATIC_ALLOCATION == 1 ) #if ( configSUPPORT_STATIC_ALLOCATION == 1 )
TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, TimerHandle_t xTimerCreateStatic( const char * const pcTimerName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const TickType_t xTimerPeriodInTicks, const TickType_t xTimerPeriodInTicks,
const UBaseType_t uxAutoReload, const UBaseType_t uxAutoReload,
void * const pvTimerID, void * const pvTimerID,
TimerCallbackFunction_t pxCallbackFunction, TimerCallbackFunction_t pxCallbackFunction,
StaticTimer_t *pxTimerBuffer ) PRIVILEGED_FUNCTION; StaticTimer_t * pxTimerBuffer ) PRIVILEGED_FUNCTION;
#endif /* configSUPPORT_STATIC_ALLOCATION */ #endif /* configSUPPORT_STATIC_ALLOCATION */
/** /**
@@ -370,7 +385,7 @@ typedef void (*PendedFunction_t)( void *, uint32_t );
* *
* See the xTimerCreate() API function example usage scenario. * See the xTimerCreate() API function example usage scenario.
*/ */
void *pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; void * pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
/** /**
* void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ); * void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID );
@@ -391,7 +406,8 @@ void *pvTimerGetTimerID( const TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
* *
* See the xTimerCreate() API function example usage scenario. * See the xTimerCreate() API function example usage scenario.
*/ */
void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION; void vTimerSetTimerID( TimerHandle_t xTimer,
void * pvNewID ) PRIVILEGED_FUNCTION;
/** /**
* BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ); * BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer );
@@ -413,7 +429,7 @@ void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION
* pdFALSE will be returned if the timer is active. * pdFALSE will be returned if the timer is active.
* *
* Example usage: * Example usage:
* @code{c} * @verbatim
* // This function assumes xTimer has already been created. * // This function assumes xTimer has already been created.
* void vAFunction( TimerHandle_t xTimer ) * void vAFunction( TimerHandle_t xTimer )
* { * {
@@ -426,7 +442,7 @@ void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ) PRIVILEGED_FUNCTION
* // xTimer is not active, do something else. * // xTimer is not active, do something else.
* } * }
* } * }
* @endcode * @endverbatim
*/ */
BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
@@ -489,9 +505,12 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* See the xTimerCreate() API function example usage scenario. * See the xTimerCreate() API function example usage scenario.
* *
*/ */
#define xTimerStart( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) ) #define xTimerStart( xTimer, xTicksToWait ) \
xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )
/** /**
* BaseType_t xTimerStop( TimerHandle_t xTimer, TickType_t xTicksToWait );
*
* Timer functionality is provided by a timer service/daemon task. Many of the * Timer functionality is provided by a timer service/daemon task. Many of the
* public FreeRTOS timer API functions send commands to the timer service task * public FreeRTOS timer API functions send commands to the timer service task
* through a queue called the timer command queue. The timer command queue is * through a queue called the timer command queue. The timer command queue is
@@ -529,9 +548,14 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* See the xTimerCreate() API function example usage scenario. * See the xTimerCreate() API function example usage scenario.
* *
*/ */
#define xTimerStop( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) ) #define xTimerStop( xTimer, xTicksToWait ) \
xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xTicksToWait ) )
/** /**
* BaseType_t xTimerChangePeriod( TimerHandle_t xTimer,
* TickType_t xNewPeriod,
* TickType_t xTicksToWait );
*
* Timer functionality is provided by a timer service/daemon task. Many of the * Timer functionality is provided by a timer service/daemon task. Many of the
* public FreeRTOS timer API functions send commands to the timer service task * public FreeRTOS timer API functions send commands to the timer service task
* through a queue called the timer command queue. The timer command queue is * through a queue called the timer command queue. The timer command queue is
@@ -573,7 +597,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* configTIMER_TASK_PRIORITY configuration constant. * configTIMER_TASK_PRIORITY configuration constant.
* *
* Example usage: * Example usage:
* @code{c} * @verbatim
* // This function assumes xTimer has already been created. If the timer * // This function assumes xTimer has already been created. If the timer
* // referenced by xTimer is already active when it is called, then the timer * // referenced by xTimer is already active when it is called, then the timer
* // is deleted. If the timer referenced by xTimer is not active when it is * // is deleted. If the timer referenced by xTimer is not active when it is
@@ -603,11 +627,14 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* } * }
* } * }
* } * }
* @endcode * @endverbatim
*/ */
#define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) ) #define xTimerChangePeriod( xTimer, xNewPeriod, xTicksToWait ) \
xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xTicksToWait ) )
/** /**
* BaseType_t xTimerDelete( TimerHandle_t xTimer, TickType_t xTicksToWait );
*
* Timer functionality is provided by a timer service/daemon task. Many of the * Timer functionality is provided by a timer service/daemon task. Many of the
* public FreeRTOS timer API functions send commands to the timer service task * public FreeRTOS timer API functions send commands to the timer service task
* through a queue called the timer command queue. The timer command queue is * through a queue called the timer command queue. The timer command queue is
@@ -641,9 +668,12 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* *
* See the xTimerChangePeriod() API function example usage scenario. * See the xTimerChangePeriod() API function example usage scenario.
*/ */
#define xTimerDelete( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) ) #define xTimerDelete( xTimer, xTicksToWait ) \
xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xTicksToWait ) )
/** /**
* BaseType_t xTimerReset( TimerHandle_t xTimer, TickType_t xTicksToWait );
*
* Timer functionality is provided by a timer service/daemon task. Many of the * Timer functionality is provided by a timer service/daemon task. Many of the
* public FreeRTOS timer API functions send commands to the timer service task * public FreeRTOS timer API functions send commands to the timer service task
* through a queue called the timer command queue. The timer command queue is * through a queue called the timer command queue. The timer command queue is
@@ -689,7 +719,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* configuration constant. * configuration constant.
* *
* Example usage: * Example usage:
* @code{c} * @verbatim
* // When a key is pressed, an LCD back-light is switched on. If 5 seconds pass * // When a key is pressed, an LCD back-light is switched on. If 5 seconds pass
* // without a key being pressed, then the LCD back-light is switched off. In * // without a key being pressed, then the LCD back-light is switched off. In
* // this case, the timer is a one-shot timer. * // this case, the timer is a one-shot timer.
@@ -761,11 +791,15 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* // Should not reach here. * // Should not reach here.
* for( ;; ); * for( ;; );
* } * }
* @endcode * @endverbatim
*/ */
#define xTimerReset( xTimer, xTicksToWait ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) ) #define xTimerReset( xTimer, xTicksToWait ) \
xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET, ( xTaskGetTickCount() ), NULL, ( xTicksToWait ) )
/** /**
* BaseType_t xTimerStartFromISR( TimerHandle_t xTimer,
* BaseType_t *pxHigherPriorityTaskWoken );
*
* A version of xTimerStart() that can be called from an interrupt service * A version of xTimerStart() that can be called from an interrupt service
* routine. * routine.
* *
@@ -793,7 +827,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* configuration constant. * configuration constant.
* *
* Example usage: * Example usage:
* @code{c} * @verbatim
* // This scenario assumes xBacklightTimer has already been created. When a * // This scenario assumes xBacklightTimer has already been created. When a
* // key is pressed, an LCD back-light is switched on. If 5 seconds pass * // key is pressed, an LCD back-light is switched on. If 5 seconds pass
* // without a key being pressed, then the LCD back-light is switched off. In * // without a key being pressed, then the LCD back-light is switched off. In
@@ -844,11 +878,15 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* // depends on the FreeRTOS port being used). * // depends on the FreeRTOS port being used).
* } * }
* } * }
* @endcode * @endverbatim
*/ */
#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) #define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) \
xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
/** /**
* BaseType_t xTimerStopFromISR( TimerHandle_t xTimer,
* BaseType_t *pxHigherPriorityTaskWoken );
*
* A version of xTimerStop() that can be called from an interrupt service * A version of xTimerStop() that can be called from an interrupt service
* routine. * routine.
* *
@@ -874,7 +912,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* priority is set by the configTIMER_TASK_PRIORITY configuration constant. * priority is set by the configTIMER_TASK_PRIORITY configuration constant.
* *
* Example usage: * Example usage:
* @code{c} * @verbatim
* // This scenario assumes xTimer has already been created and started. When * // This scenario assumes xTimer has already been created and started. When
* // an interrupt occurs, the timer should be simply stopped. * // an interrupt occurs, the timer should be simply stopped.
* *
@@ -904,11 +942,16 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* // depends on the FreeRTOS port being used). * // depends on the FreeRTOS port being used).
* } * }
* } * }
* @endcode * @endverbatim
*/ */
#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U ) #define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) \
xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP_FROM_ISR, 0, ( pxHigherPriorityTaskWoken ), 0U )
/** /**
* BaseType_t xTimerChangePeriodFromISR( TimerHandle_t xTimer,
* TickType_t xNewPeriod,
* BaseType_t *pxHigherPriorityTaskWoken );
*
* A version of xTimerChangePeriod() that can be called from an interrupt * A version of xTimerChangePeriod() that can be called from an interrupt
* service routine. * service routine.
* *
@@ -943,7 +986,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* priority is set by the configTIMER_TASK_PRIORITY configuration constant. * priority is set by the configTIMER_TASK_PRIORITY configuration constant.
* *
* Example usage: * Example usage:
* @code{c} * @verbatim
* // This scenario assumes xTimer has already been created and started. When * // This scenario assumes xTimer has already been created and started. When
* // an interrupt occurs, the period of xTimer should be changed to 500ms. * // an interrupt occurs, the period of xTimer should be changed to 500ms.
* *
@@ -973,11 +1016,15 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* // depends on the FreeRTOS port being used). * // depends on the FreeRTOS port being used).
* } * }
* } * }
* @endcode * @endverbatim
*/ */
#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U ) #define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) \
xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U )
/** /**
* BaseType_t xTimerResetFromISR( TimerHandle_t xTimer,
* BaseType_t *pxHigherPriorityTaskWoken );
*
* A version of xTimerReset() that can be called from an interrupt service * A version of xTimerReset() that can be called from an interrupt service
* routine. * routine.
* *
@@ -1005,7 +1052,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* task priority is set by the configTIMER_TASK_PRIORITY configuration constant. * task priority is set by the configTIMER_TASK_PRIORITY configuration constant.
* *
* Example usage: * Example usage:
* @code{c} * @verbatim
* // This scenario assumes xBacklightTimer has already been created. When a * // This scenario assumes xBacklightTimer has already been created. When a
* // key is pressed, an LCD back-light is switched on. If 5 seconds pass * // key is pressed, an LCD back-light is switched on. If 5 seconds pass
* // without a key being pressed, then the LCD back-light is switched off. In * // without a key being pressed, then the LCD back-light is switched off. In
@@ -1056,12 +1103,19 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* // depends on the FreeRTOS port being used). * // depends on the FreeRTOS port being used).
* } * }
* } * }
* @endcode * @endverbatim
*/ */
#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U ) #define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) \
xTimerGenericCommand( ( xTimer ), tmrCOMMAND_RESET_FROM_ISR, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )
/** /**
* BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend,
* void *pvParameter1,
* uint32_t ulParameter2,
* BaseType_t *pxHigherPriorityTaskWoken );
*
*
* Used from application interrupt service routines to defer the execution of a * Used from application interrupt service routines to defer the execution of a
* function to the RTOS daemon task (the timer service task, hence this function * function to the RTOS daemon task (the timer service task, hence this function
* is implemented in timers.c and is prefixed with 'Timer'). * is implemented in timers.c and is prefixed with 'Timer').
@@ -1103,7 +1157,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* timer daemon task, otherwise pdFALSE is returned. * timer daemon task, otherwise pdFALSE is returned.
* *
* Example usage: * Example usage:
* @code{c} * @verbatim
* *
* // The callback function that will execute in the context of the daemon task. * // The callback function that will execute in the context of the daemon task.
* // Note callback functions must all use this same prototype. * // Note callback functions must all use this same prototype.
@@ -1141,11 +1195,20 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void ) PRIVILEGED_FUNCTION;
* portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); * portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
* *
* } * }
* @endcode * @endverbatim
*/ */
BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION; BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend,
void * pvParameter1,
uint32_t ulParameter2,
BaseType_t * pxHigherPriorityTaskWoken ) PRIVILEGED_FUNCTION;
/** /**
* BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend,
* void *pvParameter1,
* uint32_t ulParameter2,
* TickType_t xTicksToWait );
*
*
* Used to defer the execution of a function to the RTOS daemon task (the timer * Used to defer the execution of a function to the RTOS daemon task (the timer
* service task, hence this function is implemented in timers.c and is prefixed * service task, hence this function is implemented in timers.c and is prefixed
* with 'Timer'). * with 'Timer').
@@ -1171,7 +1234,10 @@ BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void
* timer daemon task, otherwise pdFALSE is returned. * timer daemon task, otherwise pdFALSE is returned.
* *
*/ */
BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend,
void * pvParameter1,
uint32_t ulParameter2,
TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
/** /**
* const char * const pcTimerGetName( TimerHandle_t xTimer ); * const char * const pcTimerGetName( TimerHandle_t xTimer );
@@ -1187,7 +1253,7 @@ const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint
/** /**
* void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ); * void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload );
* *
* Updates a timer to be either an autoreload timer, in which case the timer * 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. * which case the timer will only expire once unless it is manually restarted.
* *
@@ -1199,7 +1265,8 @@ const char * pcTimerGetName( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; /*lint
* uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and * uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and
* enter the dormant state after it expires. * enter the dormant state after it expires.
*/ */
void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION; void vTimerSetReloadMode( TimerHandle_t xTimer,
const UBaseType_t uxAutoReload ) PRIVILEGED_FUNCTION;
/** /**
* TickType_t xTimerGetPeriod( TimerHandle_t xTimer ); * TickType_t xTimerGetPeriod( TimerHandle_t xTimer );
@@ -1213,18 +1280,18 @@ void vTimerSetReloadMode( TimerHandle_t xTimer, const UBaseType_t uxAutoReload )
TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; TickType_t xTimerGetPeriod( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
/** /**
* TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ); * TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer );
* *
* Returns the time in ticks at which the timer will expire. If this is less * Returns the time in ticks at which the timer will expire. If this is less
* than the current tick count then the expiry time has overflowed from the * than the current tick count then the expiry time has overflowed from the
* current time. * current time.
* *
* @param xTimer The handle of the timer being queried. * @param xTimer The handle of the timer being queried.
* *
* @return If the timer is running then the time in ticks at which the timer * @return If the timer is running then the time in ticks at which the timer
* will next expire is returned. If the timer is not running then the return * will next expire is returned. If the timer is not running then the return
* value is undefined. * value is undefined.
*/ */
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
/** @cond */ /** @cond */
@@ -1234,16 +1301,23 @@ TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
* for use by the kernel only. * for use by the kernel only.
*/ */
BaseType_t xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION; BaseType_t xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION;
BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION; BaseType_t xTimerGenericCommand( TimerHandle_t xTimer,
const BaseType_t xCommandID,
const TickType_t xOptionalValue,
BaseType_t * const pxHigherPriorityTaskWoken,
const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
#if( configUSE_TRACE_FACILITY == 1 ) #if ( configUSE_TRACE_FACILITY == 1 )
void vTimerSetTimerNumber( TimerHandle_t xTimer, UBaseType_t uxTimerNumber ) PRIVILEGED_FUNCTION; void vTimerSetTimerNumber( TimerHandle_t xTimer,
UBaseType_t uxTimerNumber ) PRIVILEGED_FUNCTION;
UBaseType_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION; UBaseType_t uxTimerGetTimerNumber( TimerHandle_t xTimer ) PRIVILEGED_FUNCTION;
#endif #endif
/** @endcond */ /** @endcond */
/* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* *INDENT-ON* */
#endif /* TIMERS_H */ #endif /* TIMERS_H */