tombalabomba Posted January 4, 2018 Report Share Posted January 4, 2018 Hi folks! I'd like to run uGFX on an STM32F429I-DISCO board using an external 1.8" TFT (ST7735). Unfortunately since I'm quite a newbe, I face already problems setting up my IDE. Since I'm using System Workbench for STM32 (version 2.3) I followed the instructions shown here https://wiki.ugfx.io/index.php/Using_Eclipse . I created a new C-project including already the right firmware for the STM32F429 MCU. Then I imported the uGFX lib and configured the includes and source locaton according: . Finally, I copied gfxconf.example.h to inc directory renamed it to gfxconf.h and configured GFX_USE_OS_RAW32 to TRUE. So far so good, but a soon as I include gfx.h I get compiling errors: 09:55:32 **** Incremental Build of configuration Debug for project ST32F4_ST7735 **** make all Building file: ../src/main.c Invoking: MCU GCC Compiler /home/tombalabomba/embedded/Demo/ST32F4_ST7735/Debug arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DSTM32 -DSTM32F4 -DSTM32F429ZITx -DDEBUG -DSTM32F429xx -DUSE_HAL_DRIVER -I"/home/tombalabomba/embedded/Demo/ST32F4_ST7735/HAL_Driver/Inc/Legacy" -I"/home/tombalabomba/embedded/Demo/ST32F4_ST7735/inc" -I"/home/tombalabomba/embedded/Demo/ST32F4_ST7735/CMSIS/device" -I"/home/tombalabomba/embedded/Demo/ST32F4_ST7735/CMSIS/core" -I"/home/tombalabomba/embedded/Demo/ST32F4_ST7735/HAL_Driver/Inc" -O0 -g3 -Wall -fmessage-length=0 -ffunction-sections -c -MMD -MP -MF"src/main.d" -MT"src/main.o" -o "src/main.o" "../src/main.c" ../src/main.c:13:17: fatal error: gfx.h: No such file or directory #include "gfx.h" ^ src/subdir.mk:27: recipe for target 'src/main.o' failed compilation terminated. make: *** [src/main.o] Error 1 09:55:32 Build Finished (took 469ms) That's quite odd since gfx.h has been added to the include path. Has anyone faced already a similar problem? Apart from my IDE issue I wonder if there exists a board template file for the ST7735 controller. Suprisingly, just for this controller there is no such a file located in the according drivers/gdisp directory. Any help is highly appreciated. BR Thomas Link to comment Share on other sites More sharing options...
cpu20 Posted January 4, 2018 Report Share Posted January 4, 2018 Two things to start with: - Did you do a clean build? (right click on project->clean) - In the includes did you add the uGFX directory to all languages or only to assembly? If you did add it only for assembly do it for all the other languages too. Link to comment Share on other sites More sharing options...
tombalabomba Posted January 4, 2018 Author Report Share Posted January 4, 2018 Hi CPU20, it's kinda embarrassing but it seems I forgot to add it to the other languages as well. Many thanks for this hint. This brings me directly to my second question. Since I couldn't find a board template file for the ST7735 controller, I struggle a bit to set up the board file. Do have a template available or is it similar to another controller? In case of the second I kindly ask you to give me a hint which one it is. BR Link to comment Share on other sites More sharing options...
cpu20 Posted January 4, 2018 Report Share Posted January 4, 2018 It seems that there is no board file for the ST7735 which is strange. You should however be able to use the board file from the ST7565 and modify it for the ST7735. Just correctly rename the file and remove all the defines at the top. After that you can start implementing the functions for your platform. This could guide you for what each function should do: Link to comment Share on other sites More sharing options...
tombalabomba Posted January 5, 2018 Author Report Share Posted January 5, 2018 Hi CPU20, can I interchange also the rest of the files of the ST7565 folder? The reason I'm asking this question is that I found several bugs in ST7735/gdisp_lld_ST7735.c: line 77: #include "drivers/gdisp/ST7735/st7735.h" line 85: #define write_data_repeat(g, data, count) { int i; for (i = 0; i < count; ++i) write_data (g, data) ;} line 205: static void execute_cmds (GDisplay *g, const uint8_t *addr) { line 210: write_data_byte (g,*addr++) is implicit declared. I guess it should be write_data(.) but in that case the argument list doesn't fit If the ST7565 driver is similar to the ST7735 and only a few modifications are required I guess it would be easier to do it that way. Hence, I kindly ask you to advice which modifications apart from changing "ST7567" to "ST7735" are required. Many Thanks Link to comment Share on other sites More sharing options...
cpu20 Posted January 5, 2018 Report Share Posted January 5, 2018 I was under the impression that this driver was fixed in the past... In this thread it was discussed that the driver doesn't work and @doc_rob seemed to be able to fix it: Maybe @doc_rob can share the fixed driver? Link to comment Share on other sites More sharing options...
doc_rob Posted January 5, 2018 Report Share Posted January 5, 2018 #ifndef _GDISP_LLD_BOARD_H #define _GDISP_LLD_BOARD_H #include "gdisp_lld_config.h" // Pin & SPI setup #define SPI_DRIVER (&SPID1) #define SPI_PORT GPIOA #define SCK_PAD 5 //PA5 #define MISO_PAD 6 //PA6 #define MOSI_PAD 7 //PA7 #define CS_PORT GPIOA #define RESET_PORT GPIOA #define DC_PORT GPIOA #define CS_PAD 4 // PA4 -- 0 = chip selected #define RESET_PAD 1 // PA1 -- 0 = reset #define DC_PAD 0 // PA0 -- control=0, data=1 -- DNC or D/C static SPIConfig spi_cfg_8 = { //Config for 8bits NULL, CS_PORT, CS_PAD, SPI_CR1_BR_1 //| SPI_CR1_BR_2) }; static SPIConfig spi_cfg_16 = { //Config for 16bits NULL, CS_PORT, CS_PAD, (SPI_CR1_DFF | SPI_CR1_BR_1)//| SPI_CR1_BR_2) }; #define SET_SPI_16bit {spiStop(SPI_DRIVER); spiStart(SPI_DRIVER, &spi_cfg_16);} #define SET_SPI_8bit {spiStop(SPI_DRIVER); spiStart(SPI_DRIVER, &spi_cfg_8);} /* PWM Setup for Backlight*/ #if ST7735_NEED_BACKLIGHT #warning "Dont forget to turn on PWM in mcuconf.h and in halconf.h" static PWMConfig pwmcfg = { 100000U, /* PWM clock frequency in Hz. (100kHz) depending on SYSCLK, HCLK, PCLK1 or PCLK2 and prescaler*/ 100, /* Initial PWM period in Ticks. Auto Reload Register (ARR) 1Tick = 10ns, Overflow16=655.36us 100 means 100Tics per Periode -> 1kHz PWM Frequency */ NULL, /* Callback */ { {PWM_OUTPUT_DISABLED, NULL}, {PWM_OUTPUT_DISABLED, NULL}, {PWM_OUTPUT_ACTIVE_HIGH, NULL}, {PWM_OUTPUT_DISABLED, NULL} }, 0, //CR 0 //DIER }; #endif /* Define one of these! */ #define GREENTAB TRUE //#define REDTAB TRUE //#define BLACKTAB TRUE static GFXINLINE void write_cmd(GDisplay* g, uint16_t cmd); //------------ST7735_InvertDisplay------------ // Send the command to invert all of the colors. // Requires 1 byte of transmission // Input: i 0 to disable inversion; non-zero to enable inversion // Output: none static GFXINLINE void set_backlight(GDisplay* g, int bl){ (void)g; #if ST7735_NEED_BACKLIGHT pwmEnableChannel(&PWMD2, 2, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, bl*100)); #endif } static GFXINLINE void init_board(GDisplay* g) { (void)g; g->board = 0; // Set pin modes palSetPadMode(SPI_PORT, SCK_PAD, PAL_MODE_ALTERNATE(5) | PAL_STM32_OSPEED_HIGHEST); palSetPadMode(SPI_PORT, MOSI_PAD, PAL_MODE_ALTERNATE(5) | PAL_STM32_OSPEED_HIGHEST); palSetPadMode(RESET_PORT, RESET_PAD, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); palSetPadMode(CS_PORT, CS_PAD, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); palSetPadMode(DC_PORT, DC_PAD, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); // Apply default states palSetPad(CS_PORT, CS_PAD); palSetPad(RESET_PORT, RESET_PAD); palClearPad(DC_PORT, DC_PAD); // Start the SPI driver spiStart(SPI_DRIVER, &spi_cfg_8); #if ST7735_NEED_BACKLIGHT pwmStart(&PWMD2, &pwmcfg); palSetPadMode(GPIOB, 10, PAL_MODE_ALTERNATE(1)); //PB10 to Timer2/Ch.2 pwmEnablePeriodicNotification(&PWMD2); pwmEnableChannel(&PWMD2, 2, PWM_PERCENTAGE_TO_WIDTH(&PWMD2, 5000)); pwmEnableChannelNotification(&PWMD2, 2); #endif } static GFXINLINE void post_init_board(GDisplay* g) { (void)g; } static GFXINLINE void setpin_reset(GDisplay* g, bool_t state){ (void)g; palWritePad(RESET_PORT, RESET_PAD, !state); //Low Active } static GFXINLINE void acquire_bus(GDisplay* g){ (void)g; spiAcquireBus(SPI_DRIVER); spiSelect(SPI_DRIVER); } static GFXINLINE void release_bus(GDisplay* g){ (void)g; spiUnselect(SPI_DRIVER); spiReleaseBus(SPI_DRIVER); } static GFXINLINE void write_cmd(GDisplay* g, uint16_t cmd){ (void)g; uint16_t d = cmd; palClearPad(DC_PORT, DC_PAD); spiSend(SPI_DRIVER, 1, &d); palSetPad(DC_PORT, DC_PAD); } static GFXINLINE void write_data(GDisplay* g, uint16_t data){ (void)g; spiSend(SPI_DRIVER, 1, &data); } static GFXINLINE void write_data8(GDisplay* g, uint8_t data){ (void)g; spiSend(SPI_DRIVER, 1, &data); } #endif /* _GDISP_LLD_BOARD_H */ This worked for me. best regards. Link to comment Share on other sites More sharing options...
tombalabomba Posted January 7, 2018 Author Report Share Posted January 7, 2018 It lookls like this is a quite good starting point. Many Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now