I need help to integrate a ILI9488 LCD-Controller on the FSMC-BUS with STemWin Library.
The display works but only without STemWin Library ("#define ILI9488DEBUG" in the attached main.c).
When I want use the STemWin Library (Comment "#define ILI9488DEBUG" in the attached main.c) the display doesn't work.
I think I have some misstake in the attached LCDConf.c. Can you help me where?
I read the ILI9488 Controller is supported by the library but what's wrong?
LCDConf.c
Display All
ILI9488.c
Display All
main.c
Display All
The display works but only without STemWin Library ("#define ILI9488DEBUG" in the attached main.c).
When I want use the STemWin Library (Comment "#define ILI9488DEBUG" in the attached main.c) the display doesn't work.
I think I have some misstake in the attached LCDConf.c. Can you help me where?
I read the ILI9488 Controller is supported by the library but what's wrong?
LCDConf.c
C Source Code
- #include "GUI.h"
- #include "GUIDRV_FlexColor.h"
- #include "stm32f1xx_hal.h"
- #include "ILI9488.h"
- #define XSIZE_PHYS 320 // To be adapted to x-screen size
- #define YSIZE_PHYS 480 // To be adapted to y-screen size
- #ifndef VXSIZE_PHYS
- #define VXSIZE_PHYS XSIZE_PHYS
- #endif
- #ifndef VYSIZE_PHYS
- #define VYSIZE_PHYS YSIZE_PHYS
- #endif
- #ifndef XSIZE_PHYS
- #error Physical X size of display is not defined!
- #endif
- #ifndef YSIZE_PHYS
- #error Physical Y size of display is not defined!
- #endif
- #ifndef GUICC_565
- #error Color conversion not defined!
- #endif
- #ifndef GUIDRV_FLEXCOLOR
- #error No display driver defined!
- #endif
- static void LcdWriteReg(U16 Data) {
- // ... TBD by user
- ILI9488WriteReg(Data);
- }
- static void LcdWriteData(U16 Data) {
- // ... TBD by user
- ILI9488WriteData(Data);
- }
- static void LcdWriteDataMultiple(U16 * pData, int NumItems) {
- while (NumItems--) {
- // ... TBD by user
- ILI9488WriteData(pData++);
- }
- }
- static void LcdReadDataMultiple(U16 * pData, int NumItems) {
- while (NumItems--) {
- // ... TBD by user
- *pData++=LCD_DATA_ADDRESS;
- }
- }
- void LCD_X_Config(void) {
- GUI_DEVICE * pDevice;
- CONFIG_FLEXCOLOR Config = {0};
- GUI_PORT_API PortAPI = {0};
- //
- // Set display driver and color conversion
- //
- pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_565, 0, 0);
- //
- // Display driver configuration, required for Lin-driver
- //
- LCD_SetSizeEx (0, XSIZE_PHYS , YSIZE_PHYS);
- LCD_SetVSizeEx(0, VXSIZE_PHYS, VYSIZE_PHYS);
- //
- // Orientation
- //
- Config.Orientation = GUI_SWAP_XY | GUI_MIRROR_Y;
- GUIDRV_FlexColor_Config(pDevice, &Config);
- //
- // Set controller and operation mode
- //
- PortAPI.pfWrite16_A0 = LcdWriteReg;
- PortAPI.pfWrite16_A1 = LcdWriteData;
- PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;
- PortAPI.pfReadM16_A1 = LcdReadDataMultiple;
- GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66709, GUIDRV_FLEXCOLOR_M16C0B16);
- }
- int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {
- int r;
- (void) LayerIndex;
- (void) pData;
- switch (Cmd) {
- case LCD_X_INITCONTROLLER: {
- //ILI9488_35_Initial_Code();
- return 0;
- }
- default:
- r = -1;
- }
- return r;
- }
ILI9488.c
C Source Code
- #include "ILI9488.h"
- #include "stm32f1xx_hal.h" /* include for HAL_Delay */
- void ILI9488_35_Initial_Code(void)
- {
- /* PGAMCTRL (Positive Gamma Control) (E0h) */
- ILI9488WriteReg(0xE0);
- ILI9488WriteData(0x00);
- ILI9488WriteData(0x07);
- ILI9488WriteData(0x0f);
- ILI9488WriteData(0x0D);
- ILI9488WriteData(0x1B);
- ILI9488WriteData(0x0A);
- ILI9488WriteData(0x3c);
- ILI9488WriteData(0x78);
- ILI9488WriteData(0x4A);
- ILI9488WriteData(0x07);
- ILI9488WriteData(0x0E);
- ILI9488WriteData(0x09);
- ILI9488WriteData(0x1B);
- ILI9488WriteData(0x1e);
- ILI9488WriteData(0x0f);
- /* NGAMCTRL (Negative Gamma Control) (E1h) */
- ILI9488WriteReg(0xE1);
- ILI9488WriteData(0x00);
- ILI9488WriteData(0x22);
- ILI9488WriteData(0x24);
- ILI9488WriteData(0x06);
- ILI9488WriteData(0x12);
- ILI9488WriteData(0x07);
- ILI9488WriteData(0x36);
- ILI9488WriteData(0x47);
- ILI9488WriteData(0x47);
- ILI9488WriteData(0x06);
- ILI9488WriteData(0x0a);
- ILI9488WriteData(0x07);
- ILI9488WriteData(0x30);
- ILI9488WriteData(0x37);
- ILI9488WriteData(0x0f);
- /* Power Control 1 (C0h) */
- ILI9488WriteReg(0xC0);
- ILI9488WriteData(0x10);
- ILI9488WriteData(0x10);
- /* Power Control 2 (C1h) */
- ILI9488WriteReg(0xC1);
- ILI9488WriteData(0x41);
- /* VCOM Control (C5h) */
- ILI9488WriteReg(0xC5);
- ILI9488WriteData(0x00);
- ILI9488WriteData(0x2c); // VCOM
- ILI9488WriteData(0x80);
- /* Memory Access Control (36h) */
- ILI9488WriteReg(0x36);
- ILI9488WriteData(0x08);
- /* Interface Pixel Format (3Ah) */
- ILI9488WriteReg(0x3A); //Interface Mode Control
- ILI9488WriteData(0x55);
- ILI9488WriteReg(0xB0); //Interface Mode Control
- ILI9488WriteData(0x00);
- ILI9488WriteReg(0xB1); //Frame rate 70HZ
- ILI9488WriteData(0xB0);
- /* Display Inversion Control (B4h) */
- ILI9488WriteReg(0xB4);
- ILI9488WriteData(0x02);
- /* Display Function Control (B6h) */
- ILI9488WriteReg(0xB6); //RGB/MCU Interface Control
- ILI9488WriteData(0x02);
- ILI9488WriteData(0x22);
- /* Set Image Function (E9h) */
- ILI9488WriteReg(0xE9);
- ILI9488WriteData(0x00);
- /* Adjust Control 3 (F7h) */
- ILI9488WriteReg(0XF7);
- ILI9488WriteData(0xA9);
- ILI9488WriteData(0x51);
- ILI9488WriteData(0x2C);
- ILI9488WriteData(0x82);
- /* Sleep Out (11h) */
- ILI9488WriteReg(0x11);
- HAL_Delay(150);
- /* Display ON (29h) */
- ILI9488WriteReg(0x29);
- }
- unsigned long ILI9488_ReadID(void) {
- unsigned char buf[4];
- ILI9488WriteReg(0x04);
- buf[0] = LCD_REG_ADDRESS;
- buf[1] = LCD_REG_ADDRESS;
- buf[2] = LCD_REG_ADDRESS;
- buf[3] = LCD_REG_ADDRESS;
- return (buf[1]<<16)+(buf[2]<<8)+(buf[3]);
- }
- void ILI9488DisplayOn()
- {
- ILI9488WriteReg(0x29);
- }
- void ILI9488DisplayOff()
- {
- ILI9488WriteReg(0x28);
- }
- void ILI9488MemoryWrite(unsigned short * pData, unsigned long size)
- {
- unsigned long i;
- ILI9488WriteReg(0x2C);
- for(i=0;i<size;i++)
- {
- ILI9488WriteData(*pData++);
- }
- }
- void ILI9488MemoryRead(unsigned short * pData, unsigned short size)
- {
- unsigned short i;
- ILI9488WriteReg(0x2E);
- for(i=0;i<size;i++)
- {
- *pData++ = LCD_REG_ADDRESS;
- }
- }
- unsigned long ILI9488ReadDisplayStatus()
- {
- volatile unsigned long tmp;
- ILI9488WriteReg(0x09);
- tmp = LCD_REG_ADDRESS;
- tmp = (LCD_REG_ADDRESS & 0x00FF) << 24;
- tmp |= (LCD_REG_ADDRESS & 0x00FF) << 16;
- tmp |= (LCD_REG_ADDRESS & 0x00FF) << 8;
- tmp |= (LCD_REG_ADDRESS & 0x00FF);
- return tmp;
- }
- void ILI9488RamAddress(void)
- {
- // set column address
- ILI9488WriteReg(0x2a);
- ILI9488WriteData(0x00);
- ILI9488WriteData(0x00);
- ILI9488WriteData(0x01);
- ILI9488WriteData(0x3f);
- // set page address
- ILI9488WriteReg(0x2b);
- ILI9488WriteData(0x00);
- ILI9488WriteData(0x00);
- ILI9488WriteData(0x01);
- ILI9488WriteData(0xdf);
- // send command memory write
- ILI9488WriteReg(0x2c);
- }
- void ILI9844NormalDisplayModeOn()
- {
- ILI9488WriteReg(0x13);
- }
- void ILI9844AllPixelOn()
- {
- ILI9488WriteReg(0x23);
- }
- void ILI9844AllPixelOff()
- {
- ILI9488WriteReg(0x22);
- }
- void ILI9844ColumnAddressSet(unsigned short SC, unsigned short EC)
- {
- ILI9488WriteReg(0x2A);
- ILI9488WriteData( (SC & 0xFF00) >> 8);
- ILI9488WriteData(SC & 0xFF);
- ILI9488WriteData( (EC & 0xFF00) >> 8);
- ILI9488WriteData(EC & 0xFF);
- }
- void Ili9844PageAddressSet(unsigned short SP, unsigned short EP)
- {
- ILI9488WriteReg(0x2B);
- ILI9488WriteData( (SP & 0xFF00) >> 8);
- ILI9488WriteData(SP & 0xFF);
- ILI9488WriteData( (EP & 0xFF00) >> 8);
- ILI9488WriteData(EP & 0xFF);
- }
- unsigned short ILI9844ReadNumberOfTheErrorsOnDsi()
- {
- volatile unsigned short tmp;
- ILI9488WriteReg(0x05);
- tmp = LCD_REG_ADDRESS;
- tmp = LCD_REG_ADDRESS;
- return tmp;
- }
main.c
C Source Code
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f1xx_hal.h"
- /* USER CODE BEGIN Includes */
- #include "GUI.h"
- #include "ILI9488.h"
- #include "LCDConf.h"
- #include "testtable.h"
- #define ILI9488DEBUG 1
- CRC_HandleTypeDef hcrc;
- SRAM_HandleTypeDef hsram1;
- void SystemClock_Config(void);
- static void MX_GPIO_Init(void);
- static void MX_CRC_Init(void);
- static void MX_FSMC_Init(void);
- int main(void)
- {
- uint32_t LcdStatus=0;
- HAL_Init();
- SystemClock_Config();
- MX_GPIO_Init();
- MX_CRC_Init();
- MX_FSMC_Init();
- // Reset LCD Display
- HAL_GPIO_WritePin(GPIOC, GPIO_PIN_5, GPIO_PIN_RESET);
- HAL_Delay(100);
- HAL_GPIO_WritePin(GPIOC, GPIO_PIN_5, GPIO_PIN_SET);
- HAL_Delay(10);
- // initialize display driver
- ILI9488_35_Initial_Code();
- LcdStatus = ILI9488ReadDisplayStatus();
- #ifndef ILI9488DEBUG
- GUI_Init();
- LcdStatus = ILI9488ReadDisplayStatus();
- #endif
- #ifdef ILI9488DEBUG
- // Fill Screen with testtable
- ILI9488MemoryWrite(testtable, 320*480);
- LcdStatus = ILI9488ReadDisplayStatus();
- #else
- GUI_SetBkColor(GUI_BLACK);
- LcdStatus = ILI9488ReadDisplayStatus();
- GUI_SetColor(GUI_WHITE);
- LcdStatus = ILI9488ReadDisplayStatus();
- GUI_DrawRect(10,10,200,200);
- LcdStatus = ILI9488ReadDisplayStatus();
- #endif
- while (1)
- {
- // Toggle Power LED
- HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_9);
- HAL_Delay(1000);
- }
- }