|
|
@@ -867,7 +867,10 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
|
|
|
*----------------------------------------------------------*/
|
|
|
|
|
|
/**
|
|
|
- * Delay a task for a given number of ticks.
|
|
|
+ * task. h
|
|
|
+ * @code{c}
|
|
|
+ * void vTaskDelay( const TickType_t xTicksToDelay );
|
|
|
+ * @endcode
|
|
|
*
|
|
|
* Delay a task for a given number of ticks. The actual time that the
|
|
|
* task remains blocked depends on the tick rate. The constant
|
|
|
@@ -885,7 +888,7 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
|
|
|
* 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
|
|
|
* 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
|
|
|
* absolute time (rather than a relative time) at which the calling task should
|
|
|
* unblock.
|
|
|
@@ -917,9 +920,12 @@ void vTaskDelete( TaskHandle_t xTaskToDelete ) PRIVILEGED_FUNCTION;
|
|
|
void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
|
|
|
|
|
|
/**
|
|
|
- * Delay a task until a specified time.
|
|
|
+ * task. h
|
|
|
+ * @code{c}
|
|
|
+ * BaseType_t xTaskDelayUntil( TickType_t *pxPreviousWakeTime, const TickType_t xTimeIncrement );
|
|
|
+ * @endcode
|
|
|
*
|
|
|
- * 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.
|
|
|
*
|
|
|
* Delay a task until a specified time. This function can be used by periodic
|
|
|
@@ -934,22 +940,26 @@ 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
|
|
|
- * rate - with the resolution of one tick period.
|
|
|
+ * The macro pdMS_TO_TICKS() can be used to calculate the number of ticks from a
|
|
|
+ * time specified in milliseconds with a resolution of one tick period.
|
|
|
*
|
|
|
* @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. A task will not
|
|
|
+ * be delayed if the next expected wake time is in the past.
|
|
|
+ *
|
|
|
* Example usage:
|
|
|
* @code{c}
|
|
|
* // Perform an action every 10 ticks.
|
|
|
@@ -957,15 +967,17 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
|
|
|
* {
|
|
|
* TickType_t xLastWakeTime;
|
|
|
* const TickType_t xFrequency = 10;
|
|
|
+ * BaseType_t xWasDelayed;
|
|
|
*
|
|
|
* // Initialise the xLastWakeTime variable with the current time.
|
|
|
* xLastWakeTime = xTaskGetTickCount ();
|
|
|
* for( ;; )
|
|
|
* {
|
|
|
* // 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.
|
|
|
* }
|
|
|
* }
|
|
|
* @endcode
|
|
|
@@ -974,9 +986,19 @@ void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;
|
|
|
* @endcond
|
|
|
* \ingroup TaskCtrl
|
|
|
*/
|
|
|
-void vTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
|
|
|
+BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,
|
|
|
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 ); \
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @cond
|
|
|
* task. h
|