vTaskDelayUntil improvement (#77)

* vTaskDelayUntil improvement

* suggestions implemented

* xTaskDelayUntil #define added

* doc small fix

* small formatting stuff

* more small formatting stuff

* Update lexicon.txt

Co-authored-by: Carl Lundin <53273776+lundinc2@users.noreply.github.com>
Co-authored-by: Carl Lundin <lundinc@amazon.com>
This commit is contained in:
Spacefish 2020-10-09 02:46:47 +02:00 committed by GitHub
parent 3d4d17178f
commit 3260e228c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 16 deletions

View file

@ -781,7 +781,7 @@ 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_vTaskDelayUntil must be defined as 1 for this function to be available.
@ -799,7 +799,7 @@ 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 constant portTICK_PERIOD_MS can be used to calculate real time from the tick
@ -808,13 +808,16 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
* @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.
*
* Example usage: * Example usage:
* <pre> * <pre>
* // Perform an action every 10 ticks. * // Perform an action every 10 ticks.
@ -823,22 +826,28 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
* TickType_t xLastWakeTime; * TickType_t xLastWakeTime;
* const TickType_t xFrequency = 10; * const TickType_t xFrequency = 10;
* *
* // 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 ); * BaseType_t 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;
#define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \
{ \
xTaskDelayUntil ( pxPreviousWakeTime , xTimeIncrement ); \
}
/** /**
* task. h * task. h

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

@ -1246,7 +1246,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
#if ( INCLUDE_vTaskDelayUntil == 1 ) #if ( INCLUDE_vTaskDelayUntil == 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;
@ -1324,6 +1324,8 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )
{ {
mtCOVERAGE_TEST_MARKER(); mtCOVERAGE_TEST_MARKER();
} }
return xShouldDelay;
} }
#endif /* INCLUDE_vTaskDelayUntil */ #endif /* INCLUDE_vTaskDelayUntil */