Handshake
FreeRTOS Shared Console Exercise
Task
At a water pump station, one serial console records everything. A log task writes the station's readings to it line by line, and an alarm task must report the moment the pump trips. The night operator reads the console the next morning. A line with another broken into the middle of it is no use to anyone.
Write print_line and the two FreeRTOS tasks, so every line reaches the console whole: log task, priority 1: prints the eight lines of log_lines, once, in order; alarm task, priority 2: prints FAULT: PUMP TRIPPED each time wait_trip() returns. The FreeRTOS calls for this are xTaskCreate, vTaskStartScheduler, vTaskDelete, xSemaphoreCreateMutex, xSemaphoreTake and xSemaphoreGive; the Reference tab shows each one.
Circuit
Pass condition
The eight log lines print in order. Each trip prints FAULT: PUMP TRIPPED once, as soon as the console is free, right after the line printing when PA0 rose.
Notes
The pump driver trips while your program runs, pulsing PA0 high for 2 ms. Leave the given code as is. FreeRTOS V11.1.0 is preemptive with a 1 ms tick. A task with a higher priority number runs as soon as it is ready.