Switching between multiple tasks, Part 1 [STM32 and FreeRTOS]
This is a sample program that switches between two tasks with an external switch. A dedicated task is provided to manage the switching.
The registered Task A and Task B processes have different LED blinking patterns, but the pushbutton switch input or not switches between Task A and Task B.
Execute switch task, create a dedicated task C as so called task management, and switch between task A and task B according to the input of the switch.
When I register a task, I create it with vTaskCreate().
vTaskCreate() is generated when registering tasks and specifies the task reference handler name for each task.
■ Task A handler name：xTaskHandle A
■ Task B handler name：xTaskHandle B
When creating a task with vTaskCreate(), the 6th argument is a pointer to the handle name &A and &B, respectively.
Tasks are switched using vTaskSuspend() and vTaskResume().
■ vTaskSuspend(A) TaskA inactive
■ vTaskResume(B) TaskB in running