(1) Finding out how Cypress FreeRTOS Demo Code runs
I wanted to modify as little of the original files as possible. So I put my code around the demo code. This is how the code runs from the main.c until it reaches the demo code.
In main.c (aws_demos/application_code/main.c)
- Startup task is vApplicationDaemonTaskStartupHook()
- It calls DEMO_RUNNER_RunDemos().
In iot_demo_runner.c,
- DEMO_RUNNER_RunDemos() will call DEMO_entryFUNCTION().
In iot_demo_runner.h
- DEMO_entryFUNCTION is defined as RunMqttDemo if CONFIG_MQTT_DEMO_ENABLED is defined.
In aws_demo_config.h,
- CONFIG_MQTT_DEMO_ENABLED is defined here.
(2) Modify to run my own code
I created my own app.c and app.h files with the startup function called RunMyApplication().
In aws_demo_config.h,
- I removed #define CONFIG_MQTT_DEMO_ENABLED
- And I added #define CONFIG_MY_APPLICATION
In iot_demo_runner.h,
- I pointed to my own function RunMyApplication() by creating a new definition as follows...
![](https://cdn.hackaday.io/images/9579671592710024793.png)
(3) How to add TFT display library
I used reference from this blog post:
Right click on the project inside Project Explorer > ModusToolbox > Library Manager
Turn on these Libraries
- Board Utils > CY8CKIT-028-TFT
- PSoC 6 Middleware > emwin
In the Makefile, add this to COMPONENTS. To indicate we are using an OS and it is Non-TouchScreen.
- COMPONENTS=EMWIN_OSNTS
In my RunMyApplication() function, I added these lines. To test the LED and the TFT display.
cyhal_gpio_init(CYBSP_USER_LED5, CYHAL_GPIO_DIR_OUTPUT, CYHAL_GPIO_DRIVE_STRONG, CYBSP_LED_STATE_ON);
GUI_Init();
GUI_SetFont(GUI_FONT_32B_1);
GUI_DispString("Hello World");
And now it looks like this
![](https://cdn.hackaday.io/images/4242041592710213471.jpg)
(4) How to add CapSense library
Do not add CapSense library. Leave capsense unchecked in the Library Manager. Because Cypress FreeRTOS already includes the CapSense library.
I created a new RTOS task and then initialised the CapSense using code from these examples.
- https://github.com/cypresssemiconductorco/mtb-example-psoc6-capsense-buttons-slider
- https://www.cypress.com/documentation/code-examples/ce218136-psoc-6-mcu-e-ink-display-capsense-rtos
One problem I faced is I cannot get the slider gesture to work (flick left / flick right). But I can get the slider position (value of 0 to 300) working perfectly.
This is a video of my progress for today. It shows the testing of CapSense, TFT display and WiFi working.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.