PSoC6-512K (CY8C62x5) is the first device within the PSoC6 family having the CAN FD IP inside. As I still had an old professional inclination sensor in my lab (unfortunately only CAN, not CAN FD) I have got the idea of making a small fun game for my son, running through a maze.
Device PSoC6-512K (CY8C62x5)The Cypress block diagram shows the main features of the dual-core (M0+, M4F) device, and beside of standard peripheral it includes CAN, USB-FS, and SDHC interface. As usual for Cypress PSoC microcontrollers it supports also CapSense for touch control. Unfortunately, the device has no BLE embedded.
For my project I will focus on CAN and SDHC, as this is relatively new to me. The idea is to read the user labyrinth data from the SD-card, that allows to add new labyrinths and game levels without changing the firmware. A standard OLED-display 240x240 pixel is connected by SPI. And finally, the commercial inclination sensor is connected by CAN.
The ModusToolbox Software Environment is Cypress' IDE to develop application firmware for the PSoC 6 MCU. The integrated Device configurator allows to configure the on-chip peripherals and prepares the related API calls to be used together with the provided Peripheral Driver Library (PDL).
The PDL provides the basic function to work with each peripheral using the configuration structs generated by the Device Configurator. So, the user can focus on the application firmware by using the given PDL APIs.
My colleague has provided a functional software example for the basic functions (init, read, write) using the Elm-Chan FATFS file system driver. So, it was finally easy to read text-files (X=wall, S=start, F=finish, space=corridor), representing the labyrinths, from the SD-card and to show it on the display.
For the display some software was mainly be copied from the Arduino world, Adafruit-GFX-Library is a good starting point. One function was added (LoadPicBmpFromSd(char *filename, uint32_t u32Xpos, uint32_t u32Ypos)) to read and draw a BMP image directly from the SD-card. Arduino/Adafruit mostly uses special image format that requires to convert pictures first, what I did not like, and PSoC6 has enough performance to do that. The BMP-picture itself are used just for the start screen, and to have the Cypress logo there ;-)For some performance test, also a simple picture viewer was added beside of the maze game. It can be started (and afterwards closed) by pressing the user button.
Last but not least a TCPWM timer is used to measure the time one player needs to run through the maze. The time is displayed at the end of each game and stored in a high score list (but not yet stored to the SD card).
ResultOf course, I could have spent much more time to make the outcome more professional. But the aim was to learn about the new Cypress' product and features, and I ended up with some fun game. Especially due to Covid-19 limitation the project is still a good amusement while staying at home.
Well - that's it!... for the moment. Stay tuned!
Regards, Holger
Comments
Please log in or sign up to comment.