/** * @brief Disables the Display. * @param None * @retval None */ void st7735_DisplayOff(void) { uint8_t data = 0; LCD_IO_WriteReg(LCD_REG_19); LCD_Delay(10); LCD_IO_WriteReg(LCD_REG_40); LCD_Delay(10); LCD_IO_WriteReg(LCD_REG_54); data = 0xC0; LCD_IO_WriteMultipleData(&data, 1); }
void Write_com(char x) { LCD_rs=0; LCD_rw=0; LCD_e=0; LCD_Delay(); P0=x; LCD_e=1; LCD_Delay(); LCD_e=0; }
static void LCD_WriteDataAuto(unsigned char nData) { CheckBusy(0x08); GPIO_RESET(CD); LCD_WRITE_DATA(nData); //向MCU写入数据,准备向LCD输出数据 GPIO_RESET(WR); LCD_SET_DATA_OUT(); LCD_Delay(NS100_DLY(2)); //延时 GPIO_SET(WR); LCD_Delay(NS100_DLY(4)); LCD_SET_DATA_IN(); }
/**************************************************************************** * 名 称: void LCD_WriteCommand(uint8 nCmd) * 功 能: 写LCD命令 * 入口参数:u8 命令 * 出口参数:无 * 说 明: 无 ****************************************************************************/ void LCD_WriteCommand(unsigned char nCmd) { CheckBusy(0x03); GPIO_SET(CD); LCD_WRITE_DATA(nCmd); //向MCU写入数据,准备向LCD输出数据 GPIO_RESET(WR); LCD_SET_DATA_OUT(); LCD_Delay(NS100_DLY(2)); //延时 GPIO_SET(WR); LCD_Delay(NS100_DLY(4)); LCD_SET_DATA_IN(); }
/** * @brief Enables the Display. * @param None * @retval None */ void spfd5408_DisplayOn(void) { /* Power On sequence ---------------------------------------------------------*/ spfd5408_WriteReg(LCD_REG_24, 0x36); /* Display frame rate = 70Hz RADJ = '0110' */ spfd5408_WriteReg(LCD_REG_25, 0x01); /* OSC_EN = 1 */ spfd5408_WriteReg(LCD_REG_28, 0x06); /* AP[2:0] = 111 */ spfd5408_WriteReg(LCD_REG_31,0x90); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/ LCD_Delay(10); /* 262k/65k color selection */ spfd5408_WriteReg(LCD_REG_23, 0x05); /* default 0x06 262k color, 0x05 65k color */ /* SET PANEL */ spfd5408_WriteReg(LCD_REG_54, 0x09); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */ /* Display On */ spfd5408_WriteReg(LCD_REG_40, 0x38); LCD_Delay(60); spfd5408_WriteReg(LCD_REG_40, 0x3C); }
/** * @brief Disables the Display. * @param None * @retval None */ void spfd5408_DisplayOff(void) { /* Power Off sequence ---------------------------------------------------------*/ spfd5408_WriteReg(LCD_REG_23, 0x0000); /* default 0x06 262k color, 0x05 65k color */ spfd5408_WriteReg(LCD_REG_24, 0x0000); /* Display frame rate = 70Hz RADJ = '0110' */ spfd5408_WriteReg(LCD_REG_25, 0x0000); /* OSC_EN = 1 */ spfd5408_WriteReg(LCD_REG_28, 0x0000); /* AP[2:0] = 111 */ spfd5408_WriteReg(LCD_REG_31, 0x0000); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/ spfd5408_WriteReg(LCD_REG_54, 0x0000); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */ /* Display Off */ spfd5408_WriteReg(LCD_REG_40, 0x38); LCD_Delay(60); spfd5408_WriteReg(LCD_REG_40, 0x04); }
/**************************************************************************** * 名 称: bool CheckBusy(unsigned char nMask) * 功 能: LCD忙检测 * 入口参数: u8: 判忙类型 * 出口参数: bool: false--忙 ; true--不忙 * 说 明: 无 ****************************************************************************/ static bool CheckBusy(unsigned char nMask) { unsigned char nState; unsigned short int i = 0; GPIO_SET(CD); GPIO_RESET(RD); LCD_Delay(NS100_DLY(1)); //延时 do{ nState = fLCD_ReadData_Row(); if(++i > 10000) { GPIO_SET(RD); return false; } }while((nState & nMask) != nMask); GPIO_SET(RD); return true; }
/** * @brief Initialise the SPFD5408 LCD Component. * @param None * @retval None */ void spfd5408_Init(void) { if(Is_spfd5408_Initialized == 0) { Is_spfd5408_Initialized = 1; /* Initialise SPFD5408 low level bus layer --------------------------------*/ LCD_IO_Init(); /* Start Initial Sequence --------------------------------------------------*/ spfd5408_WriteReg(LCD_REG_227, 0x3008); /* Set internal timing */ spfd5408_WriteReg(LCD_REG_231, 0x0012); /* Set internal timing */ spfd5408_WriteReg(LCD_REG_239, 0x1231); /* Set internal timing */ spfd5408_WriteReg(LCD_REG_1, 0x0100); /* Set SS and SM bit */ spfd5408_WriteReg(LCD_REG_2, 0x0700); /* Set 1 line inversion */ spfd5408_WriteReg(LCD_REG_3, 0x1030); /* Set GRAM write direction and BGR=1. */ spfd5408_WriteReg(LCD_REG_4, 0x0000); /* Resize register */ spfd5408_WriteReg(LCD_REG_8, 0x0202); /* Set the back porch and front porch */ spfd5408_WriteReg(LCD_REG_9, 0x0000); /* Set non-display area refresh cycle ISC[3:0] */ spfd5408_WriteReg(LCD_REG_10, 0x0000); /* FMARK function */ spfd5408_WriteReg(LCD_REG_12, 0x0000); /* RGB interface setting */ spfd5408_WriteReg(LCD_REG_13, 0x0000); /* Frame marker Position */ spfd5408_WriteReg(LCD_REG_15, 0x0000); /* RGB interface polarity */ /* Power On sequence -------------------------------------------------------*/ spfd5408_WriteReg(LCD_REG_16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ spfd5408_WriteReg(LCD_REG_17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ spfd5408_WriteReg(LCD_REG_18, 0x0000); /* VREG1OUT voltage */ spfd5408_WriteReg(LCD_REG_19, 0x0000); /* VDV[4:0] for VCOM amplitude */ LCD_Delay(200); /* Dis-charge capacitor power voltage (200ms) */ spfd5408_WriteReg(LCD_REG_17, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */ LCD_Delay(50); /* Delay 50 ms */ spfd5408_WriteReg(LCD_REG_16, 0x12B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_Delay(50); /* Delay 50 ms */ spfd5408_WriteReg(LCD_REG_18, 0x01BD); /* External reference voltage= Vci */ LCD_Delay(50); /* Delay 50 ms */ spfd5408_WriteReg(LCD_REG_19, 0x1400); /* VDV[4:0] for VCOM amplitude */ spfd5408_WriteReg(LCD_REG_41, 0x000E); /* VCM[4:0] for VCOMH */ LCD_Delay(50); /* Delay 50 ms */ spfd5408_WriteReg(LCD_REG_32, 0x0000); /* GRAM horizontal Address */ spfd5408_WriteReg(LCD_REG_33, 0x013F); /* GRAM Vertical Address */ /* Adjust the Gamma Curve --------------------------------------------------*/ spfd5408_WriteReg(LCD_REG_48, 0x0007); spfd5408_WriteReg(LCD_REG_49, 0x0302); spfd5408_WriteReg(LCD_REG_50, 0x0105); spfd5408_WriteReg(LCD_REG_53, 0x0206); spfd5408_WriteReg(LCD_REG_54, 0x0808); spfd5408_WriteReg(LCD_REG_55, 0x0206); spfd5408_WriteReg(LCD_REG_56, 0x0504); spfd5408_WriteReg(LCD_REG_57, 0x0007); spfd5408_WriteReg(LCD_REG_60, 0x0105); spfd5408_WriteReg(LCD_REG_61, 0x0808); /* Set GRAM area -----------------------------------------------------------*/ spfd5408_WriteReg(LCD_REG_80, 0x0000); /* Horizontal GRAM Start Address */ spfd5408_WriteReg(LCD_REG_81, 0x00EF); /* Horizontal GRAM End Address */ spfd5408_WriteReg(LCD_REG_82, 0x0000); /* Vertical GRAM Start Address */ spfd5408_WriteReg(LCD_REG_83, 0x013F); /* Vertical GRAM End Address */ spfd5408_WriteReg(LCD_REG_96, 0xA700); /* Gate Scan Line */ spfd5408_WriteReg(LCD_REG_97, 0x0001); /* NDL,VLE, REV */ spfd5408_WriteReg(LCD_REG_106, 0x0000); /* Set scrolling line */ /* Partial Display Control -------------------------------------------------*/ spfd5408_WriteReg(LCD_REG_128, 0x0000); spfd5408_WriteReg(LCD_REG_129, 0x0000); spfd5408_WriteReg(LCD_REG_130, 0x0000); spfd5408_WriteReg(LCD_REG_131, 0x0000); spfd5408_WriteReg(LCD_REG_132, 0x0000); spfd5408_WriteReg(LCD_REG_133, 0x0000); /* Panel Control -----------------------------------------------------------*/ spfd5408_WriteReg(LCD_REG_144, 0x0010); spfd5408_WriteReg(LCD_REG_146, 0x0000); spfd5408_WriteReg(LCD_REG_147, 0x0003); spfd5408_WriteReg(LCD_REG_149, 0x0110); spfd5408_WriteReg(LCD_REG_151, 0x0000); spfd5408_WriteReg(LCD_REG_152, 0x0000); /* Set GRAM write direction and BGR = 1 I/D=01 (Horizontal : increment, Vertical : decrement) AM=1 (address is updated in vertical writing direction) */ spfd5408_WriteReg(LCD_REG_3, 0x1018); spfd5408_WriteReg(LCD_REG_7, 0x0112); /* 262K color and display ON */ } /* Set the Cursor */ spfd5408_SetCursor(0, 0); /* Prepare to write GRAM */ LCD_IO_WriteReg(LCD_REG_34); }
/********************************************************************* * Function: void ResetDevice() * * PreCondition: none * * Input: none * * Output: none * * Side Effects: none * * Overview: Resets LCD, initializes PMP * Initialize low level IO port for mcu, * initialize SSD1963 for PCLK, * HSYNC, VSYNC etc * * Note: Need to set the backlight intensity by SetBacklight(BYTE intensity) * in main() * ********************************************************************/ void LCD_ResetDevice(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15; // Initialization of Data pins GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin =GPIO_Pin_13; GPIO_Init(GPIOC, &GPIO_InitStructure); Set_Rst; Set_Cs; // SSD1963 is not selected by default Set_nRd; Set_nWr; Clr_Rst; LCD_Delay(1); // wait stablize Set_Rst; // release from reset state to sleep state //Set MN(multipliers) of PLL, VCO = crystal freq * (N+1) //PLL freq = VCO/M with 250MHz < VCO < 800MHz //The max PLL freq is around 120MHz. To obtain 120MHz as the PLL freq LCD_WriteCommand(0xE2); // Set PLL with OSC = 10MHz (hardware) // Multiplier N = 35, VCO (>250MHz)= OSC*(N+1), VCO = 360MHz Clr_Cs; LCD_WriteData(0x23); LCD_WriteData(0x02); // Divider M = 2, PLL = 360/(M+1) = 120MHz LCD_WriteData(0x54); // Validate M and N values Set_Cs; LCD_WriteCommand(0xE0); // Start PLL command Clr_Cs; LCD_WriteData(0x01); // enable PLL Set_Cs; LCD_Delay(1); // wait stablize LCD_WriteCommand(0xE0); // Start PLL command again Clr_Cs; LCD_WriteData(0x03); // now, use PLL output as system clock Set_Cs; LCD_WriteCommand(0x01); // Soft reset LCD_Delay(10); //Set LSHIFT freq, i.e. the DCLK with PLL freq 120MHz set previously //Typical DCLK for TY700TFT800480 is 33.3MHz(datasheet), experiment shows 30MHz gives a stable result //30MHz = 120MHz*(LCDC_FPR+1)/2^20 //LCDC_FPR = 262143 (0x3FFFF) //Time per line = (DISP_HOR_RESOLUTION+DISP_HOR_PULSE_WIDTH+DISP_HOR_BACK_PORCH+DISP_HOR_FRONT_PORCH)/30 us = 1056/30 = 35.2us LCD_WriteCommand(0xE6); Clr_Cs; LCD_WriteData(0x04); LCD_WriteData(0xff); LCD_WriteData(0xff); Set_Cs; //Set panel mode, varies from individual manufacturer LCD_WriteCommand(0xB0); Clr_Cs; LCD_WriteData(0x10); // set 18-bit for 7" panel TY700TFT800480 LCD_WriteData(0x80); // set TTL mode LCD_WriteData((DISP_HOR_RESOLUTION-1)>>8); //Set panel size LCD_WriteData(DISP_HOR_RESOLUTION-1); LCD_WriteData((DISP_VER_RESOLUTION-1)>>8); LCD_WriteData(DISP_VER_RESOLUTION-1); LCD_WriteData(0x00); //RGB sequence Set_Cs; //Set horizontal period LCD_WriteCommand(0xB4); #define HT (DISP_HOR_RESOLUTION+DISP_HOR_PULSE_WIDTH+DISP_HOR_BACK_PORCH+DISP_HOR_FRONT_PORCH) Clr_Cs; LCD_WriteData((HT-1)>>8); LCD_WriteData(HT-1); #define HPS (DISP_HOR_PULSE_WIDTH+DISP_HOR_BACK_PORCH) LCD_WriteData((HPS-1)>>8); LCD_WriteData(HPS-1); LCD_WriteData(DISP_HOR_PULSE_WIDTH-1); LCD_WriteData(0x00); LCD_WriteData(0x00); LCD_WriteData(0x00); Set_Cs; //Set vertical period LCD_WriteCommand(0xB6); #define VT (DISP_VER_PULSE_WIDTH+DISP_VER_BACK_PORCH+DISP_VER_FRONT_PORCH+DISP_VER_RESOLUTION) Clr_Cs; LCD_WriteData((VT-1)>>8); LCD_WriteData(VT-1); #define VSP (DISP_VER_PULSE_WIDTH+DISP_VER_BACK_PORCH) LCD_WriteData((VSP-1)>>8); LCD_WriteData(VSP-1); LCD_WriteData(DISP_VER_PULSE_WIDTH-1); LCD_WriteData(0x00); LCD_WriteData(0x00); Set_Cs; //Set pixel format, i.e. the bpp LCD_WriteCommand(0x3A); Clr_Cs; LCD_WriteData(0x55); // set 16bpp Set_Cs; //Set pixel data interface LCD_WriteCommand(0xF0); Clr_Cs; LCD_WriteData(0x03); //16-bit(565 format) data for 16bpp PIC32MX only /*LCD_WriteData(0x00); //8-bit data for 16bpp, PIC24 series Set_Cs;*/ LCD_WriteCommand(0x29); // Turn on display; show the image on display }
/***************************************************************************** ** �������: LCD_Init ** ��������: LCD��ʼ�� ** �� ����: Dream ** �ա� ��: 2010��12��06�� *****************************************************************************/ void LCD_Init(void) { static uint16_t DeviceCode; LCD_Configuration(); LCD_WriteReg(0x0000,0x0001); LCD_Delay(5); // LCD_Delay 50 ms DeviceCode = LCD_ReadReg(0x0000); printf(" ID=0x%x\n",DeviceCode); if(DeviceCode==0x9325||DeviceCode==0x9328)//ILI9325 { LCD_WriteReg(0x00e5,0x78F0); // LCD_WriteReg(0x0000,0x0001); LCD_WriteReg(0x0001,0x0100); LCD_WriteReg(0x0002,0x0700); LCD_WriteReg(0x0003,0x1030); LCD_WriteReg(0x0004,0x0000); LCD_WriteReg(0x0008,0x0202); LCD_WriteReg(0x0009,0x0000); LCD_WriteReg(0x000a,0x0000); LCD_WriteReg(0x000c,0x0001); LCD_WriteReg(0x000d,0x0000); LCD_WriteReg(0x000f,0x0000); //Power On sequence // LCD_WriteReg(0x0010,0x0000); LCD_WriteReg(0x0011,0x0007); LCD_WriteReg(0x0012,0x0000); LCD_WriteReg(0x0013,0x0000); LCD_WriteReg(0x0007,0x0001); LCD_Delay(5); LCD_WriteReg(0x0010,0x1690); LCD_WriteReg(0x0011,0x0227); LCD_Delay(5); LCD_WriteReg(0x0012,0x009d); LCD_Delay(5); LCD_WriteReg(0x0013,0x1900); LCD_WriteReg(0x0029,0x0025); LCD_WriteReg(0x002b,0x000d); LCD_Delay(5); LCD_WriteReg(0x0020,0x0000); LCD_WriteReg(0x0021,0x0000); LCD_Delay(5); //٤��У�� LCD_WriteReg(0x0030,0x0007); LCD_WriteReg(0x0031,0x0303); LCD_WriteReg(0x0032,0x0003); LCD_WriteReg(0x0035,0x0206); LCD_WriteReg(0x0036,0x0008); LCD_WriteReg(0x0037,0x0406); LCD_WriteReg(0x0038,0x0304); LCD_WriteReg(0x0039,0x0007); LCD_WriteReg(0x003c,0x0602); LCD_WriteReg(0x003d,0x0008); LCD_Delay(5); LCD_WriteReg(0x0050,0x0000); LCD_WriteReg(0x0051,0x00ef); LCD_WriteReg(0x0052,0x0000); LCD_WriteReg(0x0053,0x013f); LCD_WriteReg(0x0060,0xa700); LCD_WriteReg(0x0061,0x0001); LCD_WriteReg(0x006a,0x0000); LCD_WriteReg(0x0080,0x0000); LCD_WriteReg(0x0081,0x0000); LCD_WriteReg(0x0082,0x0000); LCD_WriteReg(0x0083,0x0000); LCD_WriteReg(0x0084,0x0000); LCD_WriteReg(0x0085,0x0000); LCD_WriteReg(0x0090,0x0010); LCD_WriteReg(0x0092,0x0600); LCD_WriteReg(0x0007,0x0133); } else if(DeviceCode==0x9320||DeviceCode==0x9300) { LCD_WriteReg(0x00,0x0000); LCD_WriteReg(0x01,0x0100); //Driver Output Contral. LCD_WriteReg(0x02,0x0700); //LCD Driver Waveform Contral. LCD_WriteReg(0x03,0x1030);//Entry Mode Set. //LCD_WriteReg(0x03,0x1018); //Entry Mode Set. LCD_WriteReg(0x04,0x0000); //Scalling Contral. LCD_WriteReg(0x08,0x0202); //Display Contral 2.(0x0207) LCD_WriteReg(0x09,0x0000); //Display Contral 3.(0x0000) LCD_WriteReg(0x0a,0x0000); //Frame Cycle Contal.(0x0000) LCD_WriteReg(0x0c,(1<<0)); //Extern Display Interface Contral 1.(0x0000) LCD_WriteReg(0x0d,0x0000); //Frame Maker Position. LCD_WriteReg(0x0f,0x0000); //Extern Display Interface Contral 2. LCD_Delay(10); LCD_WriteReg(0x07,0x0101); //Display Contral. LCD_Delay(10); LCD_WriteReg(0x10,(1<<12)|(0<<8)|(1<<7)|(1<<6)|(0<<4)); //Power Control 1.(0x16b0) LCD_WriteReg(0x11,0x0007); //Power Control 2.(0x0001) LCD_WriteReg(0x12,(1<<8)|(1<<4)|(0<<0)); //Power Control 3.(0x0138) LCD_WriteReg(0x13,0x0b00); //Power Control 4. LCD_WriteReg(0x29,0x0000); //Power Control 7. LCD_WriteReg(0x2b,(1<<14)|(1<<4)); LCD_WriteReg(0x50,0); //Set X Star //ˮƽGRAM��ֹλ��Set X End. LCD_WriteReg(0x51,239); //Set Y Star LCD_WriteReg(0x52,0); //Set Y End.t. LCD_WriteReg(0x53,319); // LCD_WriteReg(0x60,0x2700); //Driver Output Control. LCD_WriteReg(0x61,0x0001); //Driver Output Control. LCD_WriteReg(0x6a,0x0000); //Vertical Srcoll Control. LCD_WriteReg(0x80,0x0000); //Display Position? Partial Display 1. LCD_WriteReg(0x81,0x0000); //RAM Address Start? Partial Display 1. LCD_WriteReg(0x82,0x0000); //RAM Address End-Partial Display 1. LCD_WriteReg(0x83,0x0000); //Displsy Position? Partial Display 2. LCD_WriteReg(0x84,0x0000); //RAM Address Start? Partial Display 2. LCD_WriteReg(0x85,0x0000); //RAM Address End? Partial Display 2. LCD_WriteReg(0x90,(0<<7)|(16<<0)); //Frame Cycle Contral.(0x0013) LCD_WriteReg(0x92,0x0000); //Panel Interface Contral 2.(0x0000) LCD_WriteReg(0x93,0x0001); //Panel Interface Contral 3. LCD_WriteReg(0x95,0x0110); //Frame Cycle Contral.(0x0110) LCD_WriteReg(0x97,(0<<8)); // LCD_WriteReg(0x98,0x0000); //Frame Cycle Contral. LCD_WriteReg(0x07,0x0173); //(0x0173) LCD_Delay(10); } LCD_Clear(BACK_COLOR); }
/** * @brief Power on the LCD. * @param None * @retval None */ void ili9341_Init(void) { if (Is_ili9341_Initialized == 0) { Is_ili9341_Initialized = 1; /* Initialise ILI9341 low level bus layer --------------------------------*/ LCD_IO_Init(); /*Configure LCD*/ ili9341_WriteReg(0xCA); ili9341_WriteData(0xC3); ili9341_WriteData(0x08); ili9341_WriteData(0x50); ili9341_WriteReg(LCD_POWERB); ili9341_WriteData(0x00); ili9341_WriteData(0xC1); ili9341_WriteData(0x30); ili9341_WriteReg(LCD_POWER_SEQ); ili9341_WriteData(0x64); ili9341_WriteData(0x03); ili9341_WriteData(0x12); ili9341_WriteData(0x81); ili9341_WriteReg(LCD_DTCA); ili9341_WriteData(0x85); ili9341_WriteData(0x00); ili9341_WriteData(0x78); ili9341_WriteReg(LCD_POWERA); ili9341_WriteData(0x39); ili9341_WriteData(0x2C); ili9341_WriteData(0x00); ili9341_WriteData(0x34); ili9341_WriteData(0x02); ili9341_WriteReg(LCD_PRC); ili9341_WriteData(0x20); ili9341_WriteReg(LCD_DTCB); ili9341_WriteData(0x00); ili9341_WriteData(0x00); ili9341_WriteReg(LCD_FRMCTR1); ili9341_WriteData(0x00); ili9341_WriteData(0x1B); ili9341_WriteReg(LCD_DFC); ili9341_WriteData(0x0A); ili9341_WriteData(0xA2); ili9341_WriteReg(LCD_POWER1); ili9341_WriteData(0x10); ili9341_WriteReg(LCD_POWER2); ili9341_WriteData(0x10); ili9341_WriteReg(LCD_VCOM1); ili9341_WriteData(0x45); ili9341_WriteData(0x15); ili9341_WriteReg(LCD_VCOM2); ili9341_WriteData(0x90); ili9341_WriteReg(LCD_MAC); ili9341_WriteData(0xC8); ili9341_WriteReg(LCD_3GAMMA_EN); ili9341_WriteData(0x00); ili9341_WriteReg(LCD_RGB_INTERFACE); ili9341_WriteData(0xC2); ili9341_WriteReg(LCD_DFC); ili9341_WriteData(0x0A); ili9341_WriteData(0xA7); ili9341_WriteData(0x27); ili9341_WriteData(0x04); /* colomn address set */ ili9341_WriteReg(LCD_COLUMN_ADDR); ili9341_WriteData(0x00); ili9341_WriteData(0x00); ili9341_WriteData(0x00); ili9341_WriteData(0xEF); /* Page Address Set */ ili9341_WriteReg(LCD_PAGE_ADDR); ili9341_WriteData(0x00); ili9341_WriteData(0x00); ili9341_WriteData(0x01); ili9341_WriteData(0x3F); ili9341_WriteReg(LCD_INTERFACE); ili9341_WriteData(0x01); ili9341_WriteData(0x00); ili9341_WriteData(0x06); ili9341_WriteReg(LCD_GRAM); LCD_Delay(200); ili9341_WriteReg(LCD_GAMMA); ili9341_WriteData(0x01); ili9341_WriteReg(LCD_PGAMMA); ili9341_WriteData(0x0F); ili9341_WriteData(0x29); ili9341_WriteData(0x24); ili9341_WriteData(0x0C); ili9341_WriteData(0x0E); ili9341_WriteData(0x09); ili9341_WriteData(0x4E); ili9341_WriteData(0x78); ili9341_WriteData(0x3C); ili9341_WriteData(0x09); ili9341_WriteData(0x13); ili9341_WriteData(0x05); ili9341_WriteData(0x17); ili9341_WriteData(0x11); ili9341_WriteData(0x00); ili9341_WriteReg(LCD_NGAMMA); ili9341_WriteData(0x00); ili9341_WriteData(0x16); ili9341_WriteData(0x1B); ili9341_WriteData(0x04); ili9341_WriteData(0x11); ili9341_WriteData(0x07); ili9341_WriteData(0x31); ili9341_WriteData(0x33); ili9341_WriteData(0x42); ili9341_WriteData(0x05); ili9341_WriteData(0x0C); ili9341_WriteData(0x0A); ili9341_WriteData(0x28); ili9341_WriteData(0x2F); ili9341_WriteData(0x0F); ili9341_WriteReg(LCD_SLEEP_OUT); LCD_Delay(200); ili9341_WriteReg(LCD_DISPLAY_ON); /* GRAM start writing */ ili9341_WriteReg(LCD_GRAM); } }
/** * @brief Initialise the HX8347D LCD Component. * @param None * @retval None */ void hx8347d_Init(void) { if(Is_hx8347d_Initialized == 0) { Is_hx8347d_Initialized = 1; /* Initialise HX8347D low level bus layer --------------------------------*/ LCD_IO_Init(); /* Driving ability setting */ hx8347d_WriteReg(LCD_REG_234, 0x00); hx8347d_WriteReg(LCD_REG_235, 0x20); hx8347d_WriteReg(LCD_REG_236, 0x0C); hx8347d_WriteReg(LCD_REG_237, 0xC4); hx8347d_WriteReg(LCD_REG_232, 0x40); hx8347d_WriteReg(LCD_REG_233, 0x38); hx8347d_WriteReg(LCD_REG_241, 0x01); hx8347d_WriteReg(LCD_REG_242, 0x10); hx8347d_WriteReg(LCD_REG_39, 0xA3); /* Adjust the Gamma Curve */ hx8347d_WriteReg(LCD_REG_64, 0x01); hx8347d_WriteReg(LCD_REG_65, 0x00); hx8347d_WriteReg(LCD_REG_66, 0x00); hx8347d_WriteReg(LCD_REG_67, 0x10); hx8347d_WriteReg(LCD_REG_68, 0x0E); hx8347d_WriteReg(LCD_REG_69, 0x24); hx8347d_WriteReg(LCD_REG_70, 0x04); hx8347d_WriteReg(LCD_REG_71, 0x50); hx8347d_WriteReg(LCD_REG_72, 0x02); hx8347d_WriteReg(LCD_REG_73, 0x13); hx8347d_WriteReg(LCD_REG_74, 0x19); hx8347d_WriteReg(LCD_REG_75, 0x19); hx8347d_WriteReg(LCD_REG_76, 0x16); hx8347d_WriteReg(LCD_REG_80, 0x1B); hx8347d_WriteReg(LCD_REG_81, 0x31); hx8347d_WriteReg(LCD_REG_82, 0x2F); hx8347d_WriteReg(LCD_REG_83, 0x3F); hx8347d_WriteReg(LCD_REG_84, 0x3F); hx8347d_WriteReg(LCD_REG_85, 0x3E); hx8347d_WriteReg(LCD_REG_86, 0x2F); hx8347d_WriteReg(LCD_REG_87, 0x7B); hx8347d_WriteReg(LCD_REG_88, 0x09); hx8347d_WriteReg(LCD_REG_89, 0x06); hx8347d_WriteReg(LCD_REG_90, 0x06); hx8347d_WriteReg(LCD_REG_91, 0x0C); hx8347d_WriteReg(LCD_REG_92, 0x1D); hx8347d_WriteReg(LCD_REG_93, 0xCC); /* Power voltage setting */ hx8347d_WriteReg(LCD_REG_27, 0x1B); hx8347d_WriteReg(LCD_REG_26, 0x01); hx8347d_WriteReg(LCD_REG_36, 0x2F); hx8347d_WriteReg(LCD_REG_37, 0x57); /*****VCOM offset ****/ hx8347d_WriteReg(LCD_REG_35, 0x86); /* Power on setting up flow */ hx8347d_WriteReg(LCD_REG_24, 0x36); /* Display frame rate = 70Hz RADJ = '0110' */ hx8347d_WriteReg(LCD_REG_25, 0x01); /* OSC_EN = 1 */ hx8347d_WriteReg(LCD_REG_28, 0x06); /* AP[2:0] = 111 */ hx8347d_WriteReg(LCD_REG_29, 0x06); /* AP[2:0] = 111 */ hx8347d_WriteReg(LCD_REG_31,0x90); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/ hx8347d_WriteReg(LCD_REG_39, 1); /* REF = 1 */ LCD_Delay(10); /* 262k/65k color selection */ hx8347d_WriteReg(LCD_REG_23, 0x05); /* default 0x06 262k color, 0x05 65k color */ /* SET PANEL */ hx8347d_WriteReg(LCD_REG_54, 0x09); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */ /* Display ON flow */ hx8347d_WriteReg(LCD_REG_40, 0x38); /* GON=1, DTE=1, D=10 */ LCD_Delay(60); hx8347d_WriteReg(LCD_REG_40, 0x3C); /* GON=1, DTE=1, D=11 */ /* Set GRAM Area - Partial Display Control */ hx8347d_WriteReg(LCD_REG_1, 0x00); /* DP_STB = 0, DP_STB_S = 0, SCROLL = 0, */ hx8347d_WriteReg(LCD_REG_2, 0x00); /* Column address start 2 */ hx8347d_WriteReg(LCD_REG_3, 0x00); /* Column address start 1 */ hx8347d_WriteReg(LCD_REG_4, 0x01); /* Column address end 2 */ hx8347d_WriteReg(LCD_REG_5, 0x3F); /* Column address end 1 */ hx8347d_WriteReg(LCD_REG_6, 0x00); /* Row address start 2 */ hx8347d_WriteReg(LCD_REG_7, 0x00); /* Row address start 2 */ hx8347d_WriteReg(LCD_REG_8, 0x00); /* Row address end 2 */ hx8347d_WriteReg(LCD_REG_9, 0xEF); /* Row address end 1 */ hx8347d_WriteReg(LCD_REG_22, 0xE0); /* Memory access control: MY = 1, MX = 0, MV = 1, ML = 0 */ } /* Set the Cursor */ hx8347d_SetCursor(0, 0); /* Prepare to write GRAM */ LCD_IO_WriteReg(LCD_REG_34); }
/** * @brief Power on the LCD. * @param None * @retval None */ void ili9341_Init(void) { /* Initialize ILI9341 low level bus layer ----------------------------------*/ LCD_IO_Init(); /* Configure LCD */ ili9341_WriteReg(0xCA); ili9341_WriteData(0xC3); ili9341_WriteData(0x08); ili9341_WriteData(0x50); ili9341_WriteReg(LCD_POWERB); ili9341_WriteData(0x00); ili9341_WriteData(0xC1); ili9341_WriteData(0x30); ili9341_WriteReg(LCD_POWER_SEQ); ili9341_WriteData(0x64); ili9341_WriteData(0x03); ili9341_WriteData(0x12); ili9341_WriteData(0x81); ili9341_WriteReg(LCD_DTCA); ili9341_WriteData(0x85); ili9341_WriteData(0x00); ili9341_WriteData(0x78); ili9341_WriteReg(LCD_POWERA); ili9341_WriteData(0x39); ili9341_WriteData(0x2C); ili9341_WriteData(0x00); ili9341_WriteData(0x34); ili9341_WriteData(0x02); ili9341_WriteReg(LCD_PRC); ili9341_WriteData(0x20); ili9341_WriteReg(LCD_DTCB); ili9341_WriteData(0x00); ili9341_WriteData(0x00); ili9341_WriteReg(LCD_FRMCTR1); ili9341_WriteData(0x00); ili9341_WriteData(0x1B); ili9341_WriteReg(LCD_DFC); ili9341_WriteData(0x0A); ili9341_WriteData(0xA2); ili9341_WriteReg(LCD_POWER1); ili9341_WriteData(0x10); ili9341_WriteReg(LCD_POWER2); ili9341_WriteData(0x10); ili9341_WriteReg(LCD_VCOM1); ili9341_WriteData(0x45); ili9341_WriteData(0x15); ili9341_WriteReg(LCD_VCOM2); ili9341_WriteData(0x90); ili9341_WriteReg(LCD_MAC); #if 1 // test ili9341_WriteData(0x28); #else ili9341_WriteData(0xC8); #endif ili9341_WriteReg(LCD_3GAMMA_EN); ili9341_WriteData(0x00); #ifndef LCD_IF_MCU_ONLY ili9341_WriteReg(LCD_RGB_INTERFACE); ili9341_WriteData(0xC2); #endif ili9341_WriteReg(LCD_DFC); ili9341_WriteData(0x0A); ili9341_WriteData(0xA7); ili9341_WriteData(0x27); ili9341_WriteData(0x04); #if 1 // test /* Colomn address set */ ili9341_WriteReg(LCD_COLUMN_ADDR); ili9341_WriteData(0x00); ili9341_WriteData(0x00); ili9341_WriteData(0x01); ili9341_WriteData(0x3F); /* Page address set */ ili9341_WriteReg(LCD_PAGE_ADDR); ili9341_WriteData(0x00); ili9341_WriteData(0x00); ili9341_WriteData(0x00); ili9341_WriteData(0xEF); #else /* Colomn address set */ ili9341_WriteReg(LCD_COLUMN_ADDR); ili9341_WriteData(0x00); ili9341_WriteData(0x00); ili9341_WriteData(0x00); ili9341_WriteData(0xEF); /* Page address set */ ili9341_WriteReg(LCD_PAGE_ADDR); ili9341_WriteData(0x00); ili9341_WriteData(0x00); ili9341_WriteData(0x01); ili9341_WriteData(0x3F); #endif #ifdef LCD_IF_MCU_ONLY ili9341_WriteReg(LCD_INTERFACE); ili9341_WriteData(0x01); ili9341_WriteData(0x00); ili9341_WriteData(0x00); #ifdef LCD_RGB_565 ili9341_WriteReg(LCD_PIXEL_FORMAT); ili9341_WriteData(0x55); #endif #else ili9341_WriteReg(LCD_INTERFACE); ili9341_WriteData(0x01); ili9341_WriteData(0x00); ili9341_WriteData(0x06); #endif ili9341_WriteReg(LCD_GRAM); LCD_Delay(200); ili9341_WriteReg(LCD_GAMMA); ili9341_WriteData(0x01); ili9341_WriteReg(LCD_PGAMMA); ili9341_WriteData(0x0F); ili9341_WriteData(0x29); ili9341_WriteData(0x24); ili9341_WriteData(0x0C); ili9341_WriteData(0x0E); ili9341_WriteData(0x09); ili9341_WriteData(0x4E); ili9341_WriteData(0x78); ili9341_WriteData(0x3C); ili9341_WriteData(0x09); ili9341_WriteData(0x13); ili9341_WriteData(0x05); ili9341_WriteData(0x17); ili9341_WriteData(0x11); ili9341_WriteData(0x00); ili9341_WriteReg(LCD_NGAMMA); ili9341_WriteData(0x00); ili9341_WriteData(0x16); ili9341_WriteData(0x1B); ili9341_WriteData(0x04); ili9341_WriteData(0x11); ili9341_WriteData(0x07); ili9341_WriteData(0x31); ili9341_WriteData(0x33); ili9341_WriteData(0x42); ili9341_WriteData(0x05); ili9341_WriteData(0x0C); ili9341_WriteData(0x0A); ili9341_WriteData(0x28); ili9341_WriteData(0x2F); ili9341_WriteData(0x0F); ili9341_WriteReg(LCD_SLEEP_OUT); LCD_Delay(200); ili9341_WriteReg(LCD_DISPLAY_ON); /* GRAM start writing */ ili9341_WriteReg(LCD_GRAM); }