diff --git a/include/task.h b/include/task.h index 730deec5a..75e324dde 100644 --- a/include/task.h +++ b/include/task.h @@ -781,7 +781,7 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; /** * task. h *
- * void vTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement ); + * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement ); ** * 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]. * * 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. * * 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 * 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 - * automatically updated within vTaskDelayUntil (). + * automatically updated within xTaskDelayUntil (). * * @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 * 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: *
* // Perform an action every 10 ticks. @@ -823,22 +826,28 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION; * TickType_t xLastWakeTime; * const TickType_t xFrequency = 10; * - * // Initialise the xLastWakeTime variable with the current time. - * xLastWakeTime = xTaskGetTickCount (); - * for( ;; ) - * { - * // Wait for the next cycle. - * vTaskDelayUntil( &xLastWakeTime, xFrequency ); + * // Initialise the xLastWakeTime variable with the current time. + * xLastWakeTime = xTaskGetTickCount (); + * for( ;; ) + * { + * // Wait for the next cycle. + * 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. + * } * } *- * \defgroup vTaskDelayUntil vTaskDelayUntil + * \defgroup xTaskDelayUntil xTaskDelayUntil * \ingroup TaskCtrl */ -void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, - const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; +BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, + const TickType_t xTimeIncrement ) PRIVILEGED_FUNCTION; +#define vTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ) \ +{ \ + xTaskDelayUntil ( pxPreviousWakeTime , xTimeIncrement ); \ +} + /** * task. h diff --git a/lexicon.txt b/lexicon.txt index 8cb6e9f9b..2e6e9a956 100644 --- a/lexicon.txt +++ b/lexicon.txt @@ -2976,6 +2976,7 @@ xtaskcreate xtaskcreaterestricted xtaskcreaterestrictedstatic xtaskcreatestatic +xtaskdelayuntil xtaskdetails xtaskendscheduler xtaskgetapplicationtasktag @@ -3076,6 +3077,7 @@ xvalueofinsertion xvtorconst xwaitforallbits xwantedsize +xwasdelayed xwritevalue xxr xyieldpending diff --git a/tasks.c b/tasks.c index cbd23b98c..16322e197 100644 --- a/tasks.c +++ b/tasks.c @@ -1246,7 +1246,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) #if ( INCLUDE_vTaskDelayUntil == 1 ) - void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime, + BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime, const TickType_t xTimeIncrement ) { TickType_t xTimeToWake; @@ -1324,6 +1324,8 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) { mtCOVERAGE_TEST_MARKER(); } + + return xShouldDelay; } #endif /* INCLUDE_vTaskDelayUntil */