In this project, we demonstrate how Free RTOS can be used in a PSoC 4 BLE design.
Free RTOS is a truly free professional grade RTOS for microcontrollers that supports 35 MCU architectures and become a market leader. Through Free RTOS, we can create multiple tasks the microcontroller has to handle. Designing an RTOS based system helps in easy management of the various events and helps in addition/deletion/modification of a task much robustly.
Here is the PSoC Creator Top Design Schematic:
The RTOS library is also provided with the project and has been integrated using the Compiler Settings.
Also, the necessary port files are part of the project.
Here, we use three Tasks:
1. BLE Task to notify when there is a switch press and send the current switch press count
2. Capsense Task to detect when then there is a slider touch event and send the log over UART
3. Switch Task to detect if there is a switch press event
The project also demonstrates:
-> how to use Queues where data can be shared across tasks. In the Switch task, we add the current switch press count to the BLE queue so that the BLE task can use it
-> how to use semaphores when multiple tasks need to share the same hardware resource
You need PSoC Creator 4.0 to build the project. Build the project and program it to the PSoC 4 BLE device in the -042 BLE Kit. Also, open a COM port instance and set the Baud Rate to 115200.
Open CySmart and connect to the device "RTOS_Example". Discover All the attributes. Press the switch SW2 and see the current switch press count. Also, see in the UART terminal that the message "Switch Task" is displayed. Touch the slider and see that the message "Slider" gets displayed.