Merge remote-tracking branch 'upstream/master' into master

This commit is contained in:
Jon Snow 2020-10-12 00:07:27 -04:00
commit ae16b3cac6
8 changed files with 100 additions and 54 deletions

View file

@ -126,8 +126,28 @@
#define INCLUDE_vTaskSuspend 0 #define INCLUDE_vTaskSuspend 0
#endif #endif
#ifndef INCLUDE_vTaskDelayUntil #ifdef INCLUDE_xTaskDelayUntil
#define INCLUDE_vTaskDelayUntil 0 #ifdef INCLUDE_vTaskDelayUntil
/* INCLUDE_vTaskDelayUntil was replaced by INCLUDE_xTaskDelayUntil. Backward
* compatibility is maintained if only one or the other is defined, but
* there is a conflict if both are defined. */
#error INCLUDE_vTaskDelayUntil and INCLUDE_xTaskDelayUntil are both defined. INCLUDE_vTaskDelayUntil is no longer required and should be removed
#endif
#endif
#ifndef INCLUDE_xTaskDelayUntil
#ifdef INCLUDE_vTaskDelayUntil
/* If INCLUDE_vTaskDelayUntil is set but INCLUDE_xTaskDelayUntil is not then
* the project's FreeRTOSConfig.h probably pre-dates the introduction of
* xTaskDelayUntil and setting INCLUDE_xTaskDelayUntil to whatever
* INCLUDE_vTaskDelayUntil is set to will ensure backward compatibility.
*/
#define INCLUDE_xTaskDelayUntil INCLUDE_vTaskDelayUntil
#endif
#endif
#ifndef INCLUDE_xTaskDelayUntil
#define INCLUDE_xTaskDelayUntil 0
#endif #endif
#ifndef INCLUDE_vTaskDelay #ifndef INCLUDE_vTaskDelay

View file

@ -58,7 +58,7 @@ void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask,
const MemoryRegion_t * const pxRegions ) FREERTOS_SYSTEM_CALL; const MemoryRegion_t * const pxRegions ) FREERTOS_SYSTEM_CALL;
void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) FREERTOS_SYSTEM_CALL; void MPU_vTaskDelete( TaskHandle_t xTaskToDelete ) FREERTOS_SYSTEM_CALL;
void MPU_vTaskDelay( const TickType_t xTicksToDelay ) FREERTOS_SYSTEM_CALL; void MPU_vTaskDelay( const TickType_t xTicksToDelay ) FREERTOS_SYSTEM_CALL;
void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
const TickType_t xTimeIncrement ) FREERTOS_SYSTEM_CALL; const TickType_t xTimeIncrement ) FREERTOS_SYSTEM_CALL;
BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; BaseType_t MPU_xTaskAbortDelay( TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;
UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL; UBaseType_t MPU_uxTaskPriorityGet( const TaskHandle_t xTask ) FREERTOS_SYSTEM_CALL;

View file

@ -51,7 +51,7 @@
#define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions #define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions
#define vTaskDelete MPU_vTaskDelete #define vTaskDelete MPU_vTaskDelete
#define vTaskDelay MPU_vTaskDelay #define vTaskDelay MPU_vTaskDelay
#define vTaskDelayUntil MPU_vTaskDelayUntil #define xTaskDelayUntil MPU_xTaskDelayUntil
#define xTaskAbortDelay MPU_xTaskAbortDelay #define xTaskAbortDelay MPU_xTaskAbortDelay
#define uxTaskPriorityGet MPU_uxTaskPriorityGet #define uxTaskPriorityGet MPU_uxTaskPriorityGet
#define eTaskGetState MPU_eTaskGetState #define eTaskGetState MPU_eTaskGetState

View file

@ -750,7 +750,7 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
* of controlling the frequency of a periodic task as the path taken through the * of controlling the frequency of a periodic task as the path taken through the
* code, as well as other task and interrupt activity, will effect the frequency * code, as well as other task and interrupt activity, will effect the frequency
* at which vTaskDelay() gets called and therefore the time at which the task * at which vTaskDelay() gets called and therefore the time at which the task
* next executes. See vTaskDelayUntil() for an alternative API function designed * next executes. See xTaskDelayUntil() for an alternative API function designed
* to facilitate fixed frequency execution. It does this by specifying an * to facilitate fixed frequency execution. It does this by specifying an
* absolute time (rather than a relative time) at which the calling task should * absolute time (rather than a relative time) at which the calling task should
* unblock. * unblock.
@ -781,10 +781,10 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
/** /**
* task. h * task. h
* <pre> * <pre>
* void vTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement ); * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
* </pre> * </pre>
* *
* INCLUDE_vTaskDelayUntil must be defined as 1 for this function to be available. * INCLUDE_xTaskDelayUntil 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.
* *
* Delay a task until a specified time. This function can be used by periodic * Delay a task until a specified time. This function can be used by periodic
@ -799,22 +799,26 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
* each time it executes]. * each time it executes].
* *
* Whereas vTaskDelay () specifies a wake time relative to the time at which the function * Whereas vTaskDelay () specifies a wake time relative to the time at which the function
* is called, vTaskDelayUntil () specifies the absolute (exact) time at which it wishes to * is called, xTaskDelayUntil () specifies the absolute (exact) time at which it wishes to
* unblock. * unblock.
* *
* The constant portTICK_PERIOD_MS can be used to calculate real time from the tick * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a
* rate - with the resolution of one tick period. * time specified in milliseconds with a resolution of one tick period.
* *
* @param pxPreviousWakeTime Pointer to a variable that holds the time at which the * @param pxPreviousWakeTime Pointer to a variable that holds the time at which the
* task was last unblocked. The variable must be initialised with the current time * task was last unblocked. The variable must be initialised with the current time
* prior to its first use (see the example below). Following this the variable is * prior to its first use (see the example below). Following this the variable is
* automatically updated within vTaskDelayUntil (). * automatically updated within xTaskDelayUntil ().
* *
* @param xTimeIncrement The cycle time period. The task will be unblocked at * @param xTimeIncrement The cycle time period. The task will be unblocked at
* time *pxPreviousWakeTime + xTimeIncrement. Calling vTaskDelayUntil with the * time *pxPreviousWakeTime + xTimeIncrement. Calling xTaskDelayUntil with the
* same xTimeIncrement parameter value will cause the task to execute with * same xTimeIncrement parameter value will cause the task to execute with
* a fixed interface period. * a fixed interface period.
* *
* @return Value which can be used to check whether the task was actually delayed.
* Will be pdTRUE if the task way delayed and pdFALSE otherwise. A task will not
* be delayed if the next expected wake time is in the past.
*
* Example usage: * Example usage:
* <pre> * <pre>
* // Perform an action every 10 ticks. * // Perform an action every 10 ticks.
@ -822,23 +826,35 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
* { * {
* TickType_t xLastWakeTime; * TickType_t xLastWakeTime;
* const TickType_t xFrequency = 10; * const TickType_t xFrequency = 10;
* BaseType_t xWasDelayed;
* *
* // Initialise the xLastWakeTime variable with the current time. * // Initialise the xLastWakeTime variable with the current time.
* xLastWakeTime = xTaskGetTickCount (); * xLastWakeTime = xTaskGetTickCount ();
* for( ;; ) * for( ;; )
* { * {
* // Wait for the next cycle. * // Wait for the next cycle.
* vTaskDelayUntil( &xLastWakeTime, xFrequency ); * xWasDelayed = xTaskDelayUntil( &xLastWakeTime, xFrequency );
* *
* // Perform action here. * // Perform action here. xWasDelayed value can be used to determine
* } * // whether a deadline was missed if the code here took too long.
* }
* } * }
* </pre> * </pre>
* \defgroup vTaskDelayUntil vTaskDelayUntil * \defgroup xTaskDelayUntil xTaskDelayUntil
* \ingroup TaskCtrl * \ingroup TaskCtrl
*/ */
void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION;
/*
* vTaskDelayUntil() is the older version of xTaskDelayUntil() and does not
* return a value.
*/
#define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \
{ \
( void ) xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); \
}
/** /**
* task. h * task. h
@ -1299,7 +1315,7 @@ void vTaskEndScheduler( void ) PRIVILEGED_FUNCTION;
* made. * made.
* *
* API functions that have the potential to cause a context switch (for example, * API functions that have the potential to cause a context switch (for example,
* vTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler * xTaskDelayUntil(), xQueueSend(), etc.) must not be called while the scheduler
* is suspended. * is suspended.
* *
* Example usage: * Example usage:
@ -1585,28 +1601,28 @@ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVIL
#endif #endif
#if ( configCHECK_FOR_STACK_OVERFLOW > 0 ) #if ( configCHECK_FOR_STACK_OVERFLOW > 0 )
/** /**
* task.h * task.h
* <pre>void vApplicationStackOverflowHook( TaskHandle_t xTask char *pcTaskName); </pre> * <pre>void vApplicationStackOverflowHook( TaskHandle_t xTask char *pcTaskName); </pre>
* *
* The application stack overflow hook is called when a stack overflow is detected for a task. * The application stack overflow hook is called when a stack overflow is detected for a task.
* *
* Details on stack overflow detection can be found here: https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html * Details on stack overflow detection can be found here: https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html
* *
* @param xTask the task that just exceeded its stack boundaries. * @param xTask the task that just exceeded its stack boundaries.
* @param pcTaskName A character string containing the name of the offending task. * @param pcTaskName A character string containing the name of the offending task.
*/ */
void vApplicationStackOverflowHook( TaskHandle_t xTask, void vApplicationStackOverflowHook( TaskHandle_t xTask,
char * pcTaskName ); char * pcTaskName );
#endif #endif
#if ( configUSE_TICK_HOOK > 0 ) #if ( configUSE_TICK_HOOK > 0 )
/** /**
* task.h * task.h
* <pre>void vApplicationTickHook( void ); </pre> * <pre>void vApplicationTickHook( void ); </pre>
* *
* This hook function is called in the system tick handler after any OS work is completed. * This hook function is called in the system tick handler after any OS work is completed.
*/ */
void vApplicationTickHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */ void vApplicationTickHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */
@ -1617,10 +1633,10 @@ configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask ) PRIVIL
/** /**
* task.h * task.h
* <pre>void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) </pre> * <pre>void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) </pre>
* *
* This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Task TCB. This function is required when * This function is used to provide a statically allocated block of memory to FreeRTOS to hold the Idle Task TCB. This function is required when
* configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION * configSUPPORT_STATIC_ALLOCATION is set. For more information see this URI: https://www.FreeRTOS.org/a00110.html#configSUPPORT_STATIC_ALLOCATION
* *
* @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer * @param ppxIdleTaskTCBBuffer A handle to a statically allocated TCB buffer
* @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for thie idle task * @param ppxIdleTaskStackBuffer A handle to a statically allocated Stack buffer for thie idle task
* @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer * @param pulIdleTaskStackSize A pointer to the number of elements that will fit in the allocated stack buffer
@ -2458,7 +2474,7 @@ void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
* task. h * task. h
* <pre> * <pre>
* uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn, BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); * uint32_t ulTaskNotifyTakeIndexed( UBaseType_t uxIndexToWaitOn, BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
* *
* uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait ); * uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );
* </pre> * </pre>
* *
@ -2564,7 +2580,7 @@ uint32_t ulTaskGenericNotifyTake( UBaseType_t uxIndexToWaitOn,
* task. h * task. h
* <pre> * <pre>
* BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToCLear ); * BaseType_t xTaskNotifyStateClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToCLear );
* *
* BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask ); * BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );
* </pre> * </pre>
* *
@ -2628,7 +2644,7 @@ BaseType_t xTaskGenericNotifyStateClear( TaskHandle_t xTask,
* task. h * task. h
* <pre> * <pre>
* uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear ); * uint32_t ulTaskNotifyValueClearIndexed( TaskHandle_t xTask, UBaseType_t uxIndexToClear, uint32_t ulBitsToClear );
* *
* uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear ); * uint32_t ulTaskNotifyValueClear( TaskHandle_t xTask, uint32_t ulBitsToClear );
* </pre> * </pre>
* *

View file

@ -2976,6 +2976,7 @@ xtaskcreate
xtaskcreaterestricted xtaskcreaterestricted
xtaskcreaterestrictedstatic xtaskcreaterestrictedstatic
xtaskcreatestatic xtaskcreatestatic
xtaskdelayuntil
xtaskdetails xtaskdetails
xtaskendscheduler xtaskendscheduler
xtaskgetapplicationtasktag xtaskgetapplicationtasktag
@ -3076,6 +3077,7 @@ xvalueofinsertion
xvtorconst xvtorconst
xwaitforallbits xwaitforallbits
xwantedsize xwantedsize
xwasdelayed
xwritevalue xwritevalue
xxr xxr
xyieldpending xyieldpending

View file

@ -171,14 +171,16 @@ void MPU_vTaskAllocateMPURegions( TaskHandle_t xTask,
#endif #endif
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
#if ( INCLUDE_vTaskDelayUntil == 1 ) #if ( INCLUDE_xTaskDelayUntil == 1 )
void MPU_vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, BaseType_t MPU_xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
TickType_t xTimeIncrement ) /* FREERTOS_SYSTEM_CALL */ TickType_t xTimeIncrement ) /* FREERTOS_SYSTEM_CALL */
{ {
BaseType_t xRunningPrivileged = xPortRaisePrivilege(); BaseType_t xRunningPrivileged = xPortRaisePrivilege();
BaseType_t xReturn;
vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); xReturn = xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement );
vPortResetPrivilege( xRunningPrivileged ); vPortResetPrivilege( xRunningPrivileged );
return xReturn;
} }
#endif #endif
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -513,7 +515,7 @@ BaseType_t MPU_xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) /* FREERTOS_SYSTE
#endif #endif
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
#if ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) #if ( ( INCLUDE_xTaskGetCurrentTaskHandle == 1 ) || ( configUSE_MUTEXES == 1 ))
TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */ TaskHandle_t MPU_xTaskGetCurrentTaskHandle( void ) /* FREERTOS_SYSTEM_CALL */
{ {
TaskHandle_t xReturn; TaskHandle_t xReturn;

View file

@ -518,6 +518,10 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
size_t xRequiredSpace = xDataLengthBytes; size_t xRequiredSpace = xDataLengthBytes;
TimeOut_t xTimeOut; TimeOut_t xTimeOut;
/* The maximum amount of space a stream buffer will ever report is its length
* minus 1. */
const size_t xMaxReportedSpace = pxStreamBuffer->xLength - ( size_t ) 1;
configASSERT( pvTxData ); configASSERT( pvTxData );
configASSERT( pxStreamBuffer ); configASSERT( pxStreamBuffer );
@ -534,7 +538,7 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
/* If this is a message buffer then it must be possible to write the /* If this is a message buffer then it must be possible to write the
* whole message. */ * whole message. */
if( xRequiredSpace > pxStreamBuffer->xLength ) if( xRequiredSpace > xMaxReportedSpace )
{ {
/* The message would not fit even if the entire buffer was empty, /* The message would not fit even if the entire buffer was empty,
* so don't wait for space. */ * so don't wait for space. */
@ -550,9 +554,9 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
/* If this is a stream buffer then it is acceptable to write only part /* If this is a stream buffer then it is acceptable to write only part
* of the message to the buffer. Cap the length to the total length of * of the message to the buffer. Cap the length to the total length of
* the buffer. */ * the buffer. */
if( xRequiredSpace > pxStreamBuffer->xLength ) if( xRequiredSpace > xMaxReportedSpace )
{ {
xRequiredSpace = pxStreamBuffer->xLength; xRequiredSpace = xMaxReportedSpace;
} }
else else
{ {

14
tasks.c
View file

@ -1244,10 +1244,10 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
#endif /* INCLUDE_vTaskDelete */ #endif /* INCLUDE_vTaskDelete */
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
#if ( INCLUDE_vTaskDelayUntil == 1 ) #if ( INCLUDE_xTaskDelayUntil == 1 )
void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
const TickType_t xTimeIncrement ) const TickType_t xTimeIncrement )
{ {
TickType_t xTimeToWake; TickType_t xTimeToWake;
BaseType_t xAlreadyYielded, xShouldDelay = pdFALSE; BaseType_t xAlreadyYielded, xShouldDelay = pdFALSE;
@ -1324,9 +1324,11 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
{ {
mtCOVERAGE_TEST_MARKER(); mtCOVERAGE_TEST_MARKER();
} }
return xShouldDelay;
} }
#endif /* INCLUDE_vTaskDelayUntil */ #endif /* INCLUDE_xTaskDelayUntil */
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
#if ( INCLUDE_vTaskDelay == 1 ) #if ( INCLUDE_vTaskDelay == 1 )
@ -2098,8 +2100,8 @@ void vTaskStartScheduler( void )
/* Prevent compiler warnings if INCLUDE_xTaskGetIdleTaskHandle is set to 0, /* Prevent compiler warnings if INCLUDE_xTaskGetIdleTaskHandle is set to 0,
* meaning xIdleTaskHandle is not used anywhere else. */ * meaning xIdleTaskHandle is not used anywhere else. */
( void ) xIdleTaskHandle; ( void ) xIdleTaskHandle;
/* OpenOCD makes use of uxTopUsedPriority for thread debugging. Prevent uxTopUsedPriority /* OpenOCD makes use of uxTopUsedPriority for thread debugging. Prevent uxTopUsedPriority
* from getting optimized out as it is no longer used by the kernel. */ * from getting optimized out as it is no longer used by the kernel. */
( void ) uxTopUsedPriority; ( void ) uxTopUsedPriority;
} }