ZestCode
 
Loading...
Searching...
No Matches
task_delay

task. h

void task_delay( const uint32_t xTicksToDelay );

Delay a task for a given number of ticks. The actual time that the task remains blocked depends on the tick rate. The constant portTICK_PERIOD_MS can be used to calculate real time from the tick rate - with the resolution of one tick period.

INCLUDE_vTaskDelay must be defined as 1 for this function to be available. See the configuration section for more information.

task_delay() specifies a time at which the task wishes to unblock relative to the time at which task_delay() is called. For example, specifying a block period of 100 ticks will cause the task to unblock 100 ticks after task_delay() is called. task_delay() does not therefore provide a good method 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 task_delay() gets called and therefore the time at which the task next executes. See task_delay_until() 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.

Parameters
xTicksToDelayThe amount of time, in tick periods, that the calling task should block.

Example usage:

void vTaskFunction( void * pvParameters ) { Block for 500ms. const uint32_t xDelay = 500 / portTICK_PERIOD_MS;

for( ;; )
{

Simply toggle the LED every 500ms, blocking between each toggle. vToggleLED(); task_delay( xDelay ); } }