This recipe will illustrate how to use CMSIS-RTOS to make an LED blink. We'll define two tasks or threads. The job of one task is to switch the LED ON, and the other one is to switch it OFF. The ON and OFF events are triggered by the tasks sending messages to each other. CMSIS-RTOS supports a number of intertask-communication strategies; our program uses event flags. We can illustrate our program using a state diagram, as follows:
We'll call our first recipe, RTOS_Blinky_c8v0
.
Create a new project (in a new folder) named RTOS_Binky
and use the Run-Time Environment manager to select Board Support → LED (API) and CMSIS → Keil RTX as shown in the following screenshot. As usual, we can select Resolve to fix the warning messages. Note that this RTE is the same as the one that we introduced in Chapter 2, C Language Programming.