Sunday, August 25, 2019

[Study FreeRTOS-API] 2.31 vTaskStartScheduler ()

#include "FreeRTOS.h"
#include "task.h"

void vTaskStartScheduler(void);

Summary
Starts the FreeRTOS scheduler running.
Typically, before the scheduler has been started, main() (or a function called by main()) will be
executing. After the scheduler has been started, only tasks and interrupts will ever execute.
Starting the scheduler causes the highest priority task that was created while the scheduler
was in the Initialization state to enter the Running state.

Parameters
None.

Return Values
The Idle task is created  automatically  when the scheduler is started. vTaskStartScheduler()
will only return if there is not enough FreeRTOS heap memory available for the Idle task to be
created.

Notes
Ports  that  execute  on  ARM7  and  ARM9  microcontrollers  require  the  processor  to  be  in
Supervisor mode before vTaskStartScheduler() is called.


Example
TaskHandle_t xHandle;
/* Define a task function. */
void vATask( void )
{
for( ;; )
{
/* Task code goes here. */
}
}
void main( void )
{
/* Create at least one task, in this case the task function defined above is created.  Calling vTaskStartScheduler() before any tasks have been created will cause the idle task to enter the Running state. */

xTaskCreate( vTaskCode, "task name", STACK_SIZE, NULL, TASK_PRIORITY, NULL );

/* Start the scheduler. */
vTaskStartScheduler();

/* This code will only be reached if the idle task could not be created inside
vTaskStartScheduler(). An infinite loop is used to assist debugging by
ensuring this scenario does not result in main() exiting. */

for( ;; );
}

No comments:

Post a Comment

Back to Top