Complete the code to create a FreeRTOS task that prints "Hello RTOS".
void vTaskCode( void * pvParameters ) {
for( ;; ) {
printf([1]);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}The printf function requires a string literal in double quotes to print text.
Complete the code to start the FreeRTOS scheduler.
int main(void) {
// Create tasks here
[1]();
for( ;; );
}The FreeRTOS function to start the scheduler is vTaskStartScheduler().
Fix the error in the task creation code by filling the missing parameter.
xTaskCreate(
vTaskCode, // Task function
"Task1", // Name
1000, // Stack size
NULL, // Parameters
1, // Priority
[1] // Task handle
);The last parameter is a pointer to a task handle. Passing NULL means we don't need to store the handle.
Fill both blanks to create a dictionary of task names and their priorities.
const char* tasks[] = {"TaskA", "TaskB", "TaskC"};
int priorities[] = {1, 2, 3};
for(int i = 0; i < 3; i++) {
printf("%s priority: %d\n", [1], [2]);
}To print each task name and its priority, use the indexed arrays with tasks[i] and priorities[i].
Fill all three blanks to create a task that toggles an LED every 500ms.
void [1]( void * pvParameters ) { for( ;; ) { [2](); vTaskDelay([3] / portTICK_PERIOD_MS); } }
The task function is named vTaskToggleLED, calls vToggleLED() to toggle the LED, and delays 500 milliseconds.