Part of the configuration for this library is made in VPC so is not a stand-alone library, It initializes and drives an Adafruit 160×80 0.96″ TFT display that I bought for the SLR film camera project.
Using the library
Before including the header in the main.c source, you have to define which SPI you are using like below:
#define ST7735_SPI_TYPE 2 #include <st7735r_mini.h>
which means that we will use the SPI2 peripheral (change the value to 1 for SPI1 and 3 for SPI3). By this time, you already have everything configured in VPC, all the pins needed to connect the display. This part will be addressed in a separate article that will present a demonstration project (which is already published along with the library in the VPC repository).
If there are missing definitions, the library will complain with an error message or will assume that the SPI used is SPI1. For RST, CS and DC pins, the library has it’s own definitions so you have to label the pins in VPC accordingly – for these three, you can set any pin you want, if there are no conflicts, of course. It is enough to set them as GPIO_Output and label them as per library requirement (look inside). No matter which pin, if it is an output and has the right label, the library will use it correctly. Yep, that is how you design a library that is to be used in combination with VPC or CubeMX from ST Microelectronics.
As usual regarding the user defined libraries, you will find this one in the spl_library folder. Don’t worry, the folder is taken care of in the auto-generated Makefile.