/* * Reset and Initialize Display. */ void Init_LCD(void) { LCD_CtrlLinesConfig(); Delay(3000); LCD_FSMCConfig(); Delay(3000); TIM_Config(); LCD_BackLight(100); LCD_WriteReg(0x0007,0x0021); Delay(50); LCD_WriteReg(0x0000,0x0001); Delay(50); LCD_WriteReg(0x0007,0x0023); Delay(50); LCD_WriteReg(0x0010,0x0000); Delay(90); LCD_WriteReg(0x0007,0x0033); Delay(50); LCD_WriteReg(0x0011,0x6830); Delay(50); LCD_WriteReg(0x0002,0x0600); Delay(50); LCD_WriteReg(0x0012,0x6CEB); Delay(50); LCD_WriteReg(0x0003,0xA8A4); Delay(50); LCD_WriteReg(0x000C,0x0000); Delay(50); LCD_WriteReg(0x000D,0x080C); Delay(50); LCD_WriteReg(0x000E,0x2B00); Delay(50); LCD_WriteReg(0x001E,0x00B0); Delay(50); LCD_WriteReg(0x0001,0x2b3F); Delay(50); //RGB LCD_WriteReg(0x0005,0x0000); Delay(50); LCD_WriteReg(0x0006,0x0000); Delay(50); LCD_WriteReg(0x0016,0xEF1C); Delay(50); LCD_WriteReg(0x0017,0x0103); Delay(50); LCD_WriteReg(0x000B,0x0000); Delay(50); LCD_WriteReg(0x000F,0x0000); Delay(50); LCD_WriteReg(0x0041,0x0000); Delay(50); LCD_WriteReg(0x0042,0x0000); Delay(50); LCD_WriteReg(0x0048,0x0000); Delay(50); LCD_WriteReg(0x0049,0x013F); Delay(50); LCD_WriteReg(0x004A,0x0000); Delay(50); LCD_WriteReg(0x004B,0x0000); Delay(50); LCD_WriteReg(0x0044,0xEF00); Delay(50); LCD_WriteReg(0x0045,0x0000); Delay(50); LCD_WriteReg(0x0046,0x013F); Delay(50); LCD_WriteReg(0x0030,0x0707); Delay(50); LCD_WriteReg(0x0031,0x0204); Delay(50); LCD_WriteReg(0x0032,0x0204); Delay(50); LCD_WriteReg(0x0033,0x0502); Delay(50); LCD_WriteReg(0x0034,0x0507); Delay(50); LCD_WriteReg(0x0035,0x0204); Delay(50); LCD_WriteReg(0x0036,0x0204); Delay(50); LCD_WriteReg(0x0037,0x0502); Delay(50); LCD_WriteReg(0x003A,0x0302); Delay(50); LCD_WriteReg(0x002F,0x12BE); Delay(50); LCD_WriteReg(0x003B,0x0302); Delay(50); LCD_WriteReg(0x0023,0x0000); Delay(50); LCD_WriteReg(0x0024,0x0000); Delay(50); LCD_WriteReg(0x0025,0x8000); Delay(50); LCD_WriteReg(0x004f,0x0000); Delay(50); LCD_WriteReg(0x004e,0x0000); Delay(50); }
/** * @brief Initializes the LCD. * @param None * @retval None */ void STM32072B_LCD_Init(void) { /* Configure the LCD Control pins ------------------------------------------*/ LCD_CtrlLinesConfig(); /* Configure the LCD_SPI interface -----------------------------------------*/ LCD_SPIConfig(); LCD_Setup(); LCD_SetFont(&LCD_DEFAULT_FONT); }
/******************************************************************************* * Function Name : STM3210E_LCD_Init * Description : Initializes the LCD. * Input : None * Output : None * Return : None *******************************************************************************/ void STM3210E_LCD_Init(void) { #ifndef NO_LCD /* Configure the LCD Control pins --------------------------------------------*/ LCD_CtrlLinesConfig(); /* Configure the FSMC Parallel interface -------------------------------------*/ LCD_FSMCConfig(); LCD_Command = Display_Off; // delay(); LCD_Command = LCD_Reset; // reset_delay(); LCD_Command = Set_LCD_Bias_9; delay(); LCD_Command = Set_ADC_Normal; delay(); LCD_Command = COM_Scan_Dir_Reverse; delay(); LCD_Command = Set_Start_Line_X|0x0; delay(); LCD_Command = 0x2c; power_delay(); // 50ms requried LCD_Command = 0x2e; power_delay(); // 50ms LCD_Command = 0x2f; power_delay(); // 50ms LCD_Command = Set_Ref_Vol_Reg|0x05; delay(); LCD_Command = Set_Ref_Vol_Mode; delay(); LCD_Command = Set_Ref_Vol_Reg; delay(); LCD_Clear(); delay(); LCD_Command = Set_Page_Addr_X|0x0; delay(); LCD_Command = Set_ColH_Addr_X|0x0; delay(); LCD_Command = Set_ColL_Addr_X|0x0; delay(); LCD_Command = Display_On; // delay(); #endif }
//***************************************************************************** // //***************************************************************************** void hx8347_Init(void) { volatile uint32_t lcdid = 0; volatile uint16_t clrColor, red, green, blue, regValue; regValue = 0xE8; LCD_CtrlLinesConfig(); LCD_FSMCConfig(); Set_Rst(); delay_ms(10); Clr_Rst(); delay_ms(10); Set_Rst(); delay_ms(250); }
/** * @brief Setups the LCD. * @param None * @retval None */ void LCD_Setup(void) { /* Configure the LCD Control pins --------------------------------------------*/ LCD_CtrlLinesConfig(); /* Configure the LCD_SPI interface ----------------------------------------------*/ LCD_SPIConfig(); if(LCDType == LCD_ILI9320) { _delay_(5); /* Delay 50 ms */ /* Start Initial Sequence ------------------------------------------------*/ LCD_WriteReg(LCD_REG_229, 0x8000); /* Set the internal vcore voltage */ LCD_WriteReg(LCD_REG_0, 0x0001); /* Start internal OSC. */ LCD_WriteReg(LCD_REG_1, 0x0100); /* set SS and SM bit */ LCD_WriteReg(LCD_REG_2, 0x0700); /* set 1 line inversion */ LCD_WriteReg(LCD_REG_3, 0x1030); /* set GRAM write direction and BGR=1. */ LCD_WriteReg(LCD_REG_4, 0x0000); /* Resize register */ LCD_WriteReg(LCD_REG_8, 0x0202); /* set the back porch and front porch */ LCD_WriteReg(LCD_REG_9, 0x0000); /* set non-display area refresh cycle ISC[3:0] */ LCD_WriteReg(LCD_REG_10, 0x0000); /* FMARK function */ LCD_WriteReg(LCD_REG_12, 0x0000); /* RGB interface setting */ LCD_WriteReg(LCD_REG_13, 0x0000); /* Frame marker Position */ LCD_WriteReg(LCD_REG_15, 0x0000); /* RGB interface polarity */ /* Power On sequence -----------------------------------------------------*/ LCD_WriteReg(LCD_REG_16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(LCD_REG_17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ LCD_WriteReg(LCD_REG_18, 0x0000); /* VREG1OUT voltage */ LCD_WriteReg(LCD_REG_19, 0x0000); /* VDV[4:0] for VCOM amplitude */ _delay_(20); /* Dis-charge capacitor power voltage (200ms) */ LCD_WriteReg(LCD_REG_16, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(LCD_REG_17, 0x0137); /* DC1[2:0], DC0[2:0], VC[2:0] */ _delay_(5); /* Delay 50 ms */ LCD_WriteReg(LCD_REG_18, 0x0139); /* VREG1OUT voltage */ _delay_(5); /* Delay 50 ms */ LCD_WriteReg(LCD_REG_19, 0x1d00); /* VDV[4:0] for VCOM amplitude */ LCD_WriteReg(LCD_REG_41, 0x0013); /* VCM[4:0] for VCOMH */ _delay_(5); /* Delay 50 ms */ LCD_WriteReg(LCD_REG_32, 0x0000); /* GRAM horizontal Address */ LCD_WriteReg(LCD_REG_33, 0x0000); /* GRAM Vertical Address */ /* Adjust the Gamma Curve ------------------------------------------------*/ LCD_WriteReg(LCD_REG_48, 0x0006); LCD_WriteReg(LCD_REG_49, 0x0101); LCD_WriteReg(LCD_REG_50, 0x0003); LCD_WriteReg(LCD_REG_53, 0x0106); LCD_WriteReg(LCD_REG_54, 0x0b02); LCD_WriteReg(LCD_REG_55, 0x0302); LCD_WriteReg(LCD_REG_56, 0x0707); LCD_WriteReg(LCD_REG_57, 0x0007); LCD_WriteReg(LCD_REG_60, 0x0600); LCD_WriteReg(LCD_REG_61, 0x020b); /* Set GRAM area ---------------------------------------------------------*/ LCD_WriteReg(LCD_REG_80, 0x0000); /* Horizontal GRAM Start Address */ LCD_WriteReg(LCD_REG_81, 0x00EF); /* Horizontal GRAM End Address */ LCD_WriteReg(LCD_REG_82, 0x0000); /* Vertical GRAM Start Address */ LCD_WriteReg(LCD_REG_83, 0x013F); /* Vertical GRAM End Address */ LCD_WriteReg(LCD_REG_96, 0x2700); /* Gate Scan Line */ LCD_WriteReg(LCD_REG_97, 0x0001); /* NDL,VLE, REV */ LCD_WriteReg(LCD_REG_106, 0x0000); /* set scrolling line */ /* Partial Display Control -----------------------------------------------*/ LCD_WriteReg(LCD_REG_128, 0x0000); LCD_WriteReg(LCD_REG_129, 0x0000); LCD_WriteReg(LCD_REG_130, 0x0000); LCD_WriteReg(LCD_REG_131, 0x0000); LCD_WriteReg(LCD_REG_132, 0x0000); LCD_WriteReg(LCD_REG_133, 0x0000); /* Panel Control ---------------------------------------------------------*/ LCD_WriteReg(LCD_REG_144, 0x0010); LCD_WriteReg(LCD_REG_146, 0x0000); LCD_WriteReg(LCD_REG_147, 0x0003); LCD_WriteReg(LCD_REG_149, 0x0110); LCD_WriteReg(LCD_REG_151, 0x0000); LCD_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) */ LCD_WriteReg(LCD_REG_3, 0x1018); LCD_WriteReg(LCD_REG_7, 0x0173); /* 262K color and display ON */ } else if(LCDType == LCD_SPFD5408) { /* Start Initial Sequence --------------------------------------------------*/ LCD_WriteReg(LCD_REG_227, 0x3008); /* Set internal timing */ LCD_WriteReg(LCD_REG_231, 0x0012); /* Set internal timing */ LCD_WriteReg(LCD_REG_239, 0x1231); /* Set internal timing */ LCD_WriteReg(LCD_REG_1, 0x0100); /* Set SS and SM bit */ LCD_WriteReg(LCD_REG_2, 0x0700); /* Set 1 line inversion */ LCD_WriteReg(LCD_REG_3, 0x1030); /* Set GRAM write direction and BGR=1. */ LCD_WriteReg(LCD_REG_4, 0x0000); /* Resize register */ LCD_WriteReg(LCD_REG_8, 0x0202); /* Set the back porch and front porch */ LCD_WriteReg(LCD_REG_9, 0x0000); /* Set non-display area refresh cycle ISC[3:0] */ LCD_WriteReg(LCD_REG_10, 0x0000); /* FMARK function */ LCD_WriteReg(LCD_REG_12, 0x0000); /* RGB interface setting */ LCD_WriteReg(LCD_REG_13, 0x0000); /* Frame marker Position */ LCD_WriteReg(LCD_REG_15, 0x0000); /* RGB interface polarity */ /* Power On sequence -------------------------------------------------------*/ LCD_WriteReg(LCD_REG_16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(LCD_REG_17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ LCD_WriteReg(LCD_REG_18, 0x0000); /* VREG1OUT voltage */ LCD_WriteReg(LCD_REG_19, 0x0000); /* VDV[4:0] for VCOM amplitude */ _delay_(20); /* Dis-charge capacitor power voltage (200ms) */ LCD_WriteReg(LCD_REG_17, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */ _delay_(5); /* Delay 50 ms */ LCD_WriteReg(LCD_REG_16, 0x12B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ _delay_(5); /* Delay 50 ms */ LCD_WriteReg(LCD_REG_18, 0x01BD); /* External reference voltage= Vci */ _delay_(5); /* Delay 50 ms */ LCD_WriteReg(LCD_REG_19, 0x1400); /* VDV[4:0] for VCOM amplitude */ LCD_WriteReg(LCD_REG_41, 0x000E); /* VCM[4:0] for VCOMH */ _delay_(5); /* Delay 50 ms */ LCD_WriteReg(LCD_REG_32, 0x0000); /* GRAM horizontal Address */ LCD_WriteReg(LCD_REG_33, 0x013F); /* GRAM Vertical Address */ /* Adjust the Gamma Curve --------------------------------------------------*/ LCD_WriteReg(LCD_REG_48, 0x0007); LCD_WriteReg(LCD_REG_49, 0x0302); LCD_WriteReg(LCD_REG_50, 0x0105); LCD_WriteReg(LCD_REG_53, 0x0206); LCD_WriteReg(LCD_REG_54, 0x0808); LCD_WriteReg(LCD_REG_55, 0x0206); LCD_WriteReg(LCD_REG_56, 0x0504); LCD_WriteReg(LCD_REG_57, 0x0007); LCD_WriteReg(LCD_REG_60, 0x0105); LCD_WriteReg(LCD_REG_61, 0x0808); /* Set GRAM area -----------------------------------------------------------*/ LCD_WriteReg(LCD_REG_80, 0x0000); /* Horizontal GRAM Start Address */ LCD_WriteReg(LCD_REG_81, 0x00EF); /* Horizontal GRAM End Address */ LCD_WriteReg(LCD_REG_82, 0x0000); /* Vertical GRAM Start Address */ LCD_WriteReg(LCD_REG_83, 0x013F); /* Vertical GRAM End Address */ LCD_WriteReg(LCD_REG_96, 0xA700); /* Gate Scan Line */ LCD_WriteReg(LCD_REG_97, 0x0001); /* NDL,VLE, REV */ LCD_WriteReg(LCD_REG_106, 0x0000); /* Set scrolling line */ /* Partial Display Control -------------------------------------------------*/ LCD_WriteReg(LCD_REG_128, 0x0000); LCD_WriteReg(LCD_REG_129, 0x0000); LCD_WriteReg(LCD_REG_130, 0x0000); LCD_WriteReg(LCD_REG_131, 0x0000); LCD_WriteReg(LCD_REG_132, 0x0000); LCD_WriteReg(LCD_REG_133, 0x0000); /* Panel Control -----------------------------------------------------------*/ LCD_WriteReg(LCD_REG_144, 0x0010); LCD_WriteReg(LCD_REG_146, 0x0000); LCD_WriteReg(LCD_REG_147, 0x0003); LCD_WriteReg(LCD_REG_149, 0x0110); LCD_WriteReg(LCD_REG_151, 0x0000); LCD_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) */ LCD_WriteReg(LCD_REG_3, 0x1018); LCD_WriteReg(LCD_REG_7, 0x0112); /* 262K color and display ON */ } else if(LCDType == LCD_HX8347D) { /* Driving ability setting */ LCD_WriteReg(LCD_REG_234, 0x00); LCD_WriteReg(LCD_REG_235, 0x20); LCD_WriteReg(LCD_REG_236, 0x0C); LCD_WriteReg(LCD_REG_237, 0xC4); LCD_WriteReg(LCD_REG_232, 0x40); LCD_WriteReg(LCD_REG_233, 0x38); LCD_WriteReg(LCD_REG_241, 0x01); LCD_WriteReg(LCD_REG_242, 0x10); LCD_WriteReg(LCD_REG_39, 0xA3); /* Adjust the Gamma Curve */ LCD_WriteReg(LCD_REG_64, 0x01); LCD_WriteReg(LCD_REG_65, 0x00); LCD_WriteReg(LCD_REG_66, 0x00); LCD_WriteReg(LCD_REG_67, 0x10); LCD_WriteReg(LCD_REG_68, 0x0E); LCD_WriteReg(LCD_REG_69, 0x24); LCD_WriteReg(LCD_REG_70, 0x04); LCD_WriteReg(LCD_REG_71, 0x50); LCD_WriteReg(LCD_REG_72, 0x02); LCD_WriteReg(LCD_REG_73, 0x13); LCD_WriteReg(LCD_REG_74, 0x19); LCD_WriteReg(LCD_REG_75, 0x19); LCD_WriteReg(LCD_REG_76, 0x16); LCD_WriteReg(LCD_REG_80, 0x1B); LCD_WriteReg(LCD_REG_81, 0x31); LCD_WriteReg(LCD_REG_82, 0x2F); LCD_WriteReg(LCD_REG_83, 0x3F); LCD_WriteReg(LCD_REG_84, 0x3F); LCD_WriteReg(LCD_REG_85, 0x3E); LCD_WriteReg(LCD_REG_86, 0x2F); LCD_WriteReg(LCD_REG_87, 0x7B); LCD_WriteReg(LCD_REG_88, 0x09); LCD_WriteReg(LCD_REG_89, 0x06); LCD_WriteReg(LCD_REG_90, 0x06); LCD_WriteReg(LCD_REG_91, 0x0C); LCD_WriteReg(LCD_REG_92, 0x1D); LCD_WriteReg(LCD_REG_93, 0xCC); /* Power voltage setting */ LCD_WriteReg(LCD_REG_27, 0x1B); LCD_WriteReg(LCD_REG_26, 0x01); LCD_WriteReg(LCD_REG_36, 0x2F); LCD_WriteReg(LCD_REG_37, 0x57); /*****VCOM offset ****/ LCD_WriteReg(LCD_REG_35, 0x86); /* Power on setting up flow */ LCD_WriteReg(LCD_REG_24, 0x36); /* Display frame rate = 70Hz RADJ = '0110' */ LCD_WriteReg(LCD_REG_25, 0x01); /* OSC_EN = 1 */ LCD_WriteReg(LCD_REG_28, 0x06); /* AP[2:0] = 111 */ LCD_WriteReg(LCD_REG_29, 0x06); /* AP[2:0] = 111 */ LCD_WriteReg(LCD_REG_31,0x90); /* GAS=1, VOMG=00, PON=1, DK=0, XDK=0, DVDH_TRI=0, STB=0*/ LCD_WriteReg(LCD_REG_39, 1); /* REF = 1 */ _delay_(10); /* 262k/65k color selection */ LCD_WriteReg(LCD_REG_23, 0x05); /* default 0x06 262k color, 0x05 65k color */ /* SET PANEL */ LCD_WriteReg(LCD_REG_54, 0x09); /* SS_PANEL = 1, GS_PANEL = 0,REV_PANEL = 0, BGR_PANEL = 1 */ /* Display ON flow */ LCD_WriteReg(LCD_REG_40, 0x38); /* GON=1, DTE=1, D=10 */ _delay_(60); LCD_WriteReg(LCD_REG_40, 0x3C); /* GON=1, DTE=1, D=11 */ /* Set GRAM Area - Partial Display Control */ LCD_WriteReg(LCD_REG_1, 0x00); /* DP_STB = 0, DP_STB_S = 0, SCROLL = 0, */ LCD_WriteReg(LCD_REG_2, 0x00); /* Column address start 2 */ LCD_WriteReg(LCD_REG_3, 0x00); /* Column address start 1 */ LCD_WriteReg(LCD_REG_4, 0x01); /* Column address end 2 */ LCD_WriteReg(LCD_REG_5, 0x3F); /* Column address end 1 */ LCD_WriteReg(LCD_REG_6, 0x00); /* Row address start 2 */ LCD_WriteReg(LCD_REG_7, 0x00); /* Row address start 2 */ LCD_WriteReg(LCD_REG_8, 0x00); /* Row address end 2 */ LCD_WriteReg(LCD_REG_9, 0xEF); /* Row address end 1 */ LCD_WriteReg(LCD_REG_22, 0xE0); /* Memory access control: MY = 1, MX = 0, MV = 1, ML = 0 */ } /* Set default font */ LCD_SetFont(&LCD_DEFAULT_FONT); }
/******************************************************************************* * Function Name : LCD_Setup * Description : Setups the LCD. * Input : None * Output : None * Return : None *******************************************************************************/ void LCD_Setup(void) { /* Configure the LCD Control pins --------------------------------------------*/ LCD_CtrlLinesConfig(); /* Configure the SPI3 interface ----------------------------------------------*/ LCD_SPIConfig(); timerDly(5); /* Delay 50 ms */ /* Start Initial Sequence ------------------------------------------------*/ LCD_WriteReg(R229, 0x8000); /* Set the internal vcore voltage */ LCD_WriteReg(R0, 0x0001); /* Start internal OSC. */ LCD_WriteReg(R1, 0x0100); /* set SS and SM bit */ LCD_WriteReg(R2, 0x0700); /* set 1 line inversion */ LCD_WriteReg(R3, 0x1030); /* set GRAM write direction and BGR=1. */ LCD_WriteReg(R4, 0x0000); /* Resize register */ LCD_WriteReg(R8, 0x0202); /* set the back porch and front porch */ LCD_WriteReg(R9, 0x0000); /* set non-display area refresh cycle ISC[3:0] */ LCD_WriteReg(R10, 0x0000); /* FMARK function */ LCD_WriteReg(R12, 0x0000); /* RGB interface setting */ LCD_WriteReg(R13, 0x0000); /* Frame marker Position */ LCD_WriteReg(R15, 0x0000); /* RGB interface polarity */ /* Power On sequence -----------------------------------------------------*/ LCD_WriteReg(R16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(R17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ LCD_WriteReg(R18, 0x0000); /* VREG1OUT voltage */ LCD_WriteReg(R19, 0x0000); /* VDV[4:0] for VCOM amplitude */ timerDly(20); /* Dis-charge capacitor power voltage (200ms) */ LCD_WriteReg(R16, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(R17, 0x0137); /* DC1[2:0], DC0[2:0], VC[2:0] */ timerDly(5); /* Delay 50 ms */ LCD_WriteReg(R18, 0x0139); /* VREG1OUT voltage */ timerDly(5); /* Delay 50 ms */ LCD_WriteReg(R19, 0x1d00); /* VDV[4:0] for VCOM amplitude */ LCD_WriteReg(R41, 0x0013); /* VCM[4:0] for VCOMH */ timerDly(5); /* Delay 50 ms */ LCD_WriteReg(R32, 0x0000); /* GRAM horizontal Address */ LCD_WriteReg(R33, 0x0000); /* GRAM Vertical Address */ /* Adjust the Gamma Curve ------------------------------------------------*/ LCD_WriteReg(R48, 0x0006); LCD_WriteReg(R49, 0x0101); LCD_WriteReg(R50, 0x0003); LCD_WriteReg(R53, 0x0106); LCD_WriteReg(R54, 0x0b02); LCD_WriteReg(R55, 0x0302); LCD_WriteReg(R56, 0x0707); LCD_WriteReg(R57, 0x0007); LCD_WriteReg(R60, 0x0600); LCD_WriteReg(R61, 0x020b); /* Set GRAM area ---------------------------------------------------------*/ LCD_WriteReg(R80, 0x0000); /* Horizontal GRAM Start Address */ LCD_WriteReg(R81, 0x00EF); /* Horizontal GRAM End Address */ LCD_WriteReg(R82, 0x0000); /* Vertical GRAM Start Address */ LCD_WriteReg(R83, 0x013F); /* Vertical GRAM End Address */ LCD_WriteReg(R96, 0x2700); /* Gate Scan Line */ LCD_WriteReg(R97, 0x0001); /* NDL,VLE, REV */ LCD_WriteReg(R106, 0x0000); /* set scrolling line */ /* Partial Display Control -----------------------------------------------*/ LCD_WriteReg(R128, 0x0000); LCD_WriteReg(R129, 0x0000); LCD_WriteReg(R130, 0x0000); LCD_WriteReg(R131, 0x0000); LCD_WriteReg(R132, 0x0000); LCD_WriteReg(R133, 0x0000); /* Panel Control ---------------------------------------------------------*/ LCD_WriteReg(R144, 0x0010); LCD_WriteReg(R146, 0x0000); LCD_WriteReg(R147, 0x0003); LCD_WriteReg(R149, 0x0110); LCD_WriteReg(R151, 0x0000); LCD_WriteReg(R152, 0x0000); /* Set GRAM write direction and BGR = 1 */ /* I/D=01 (Horizontal : increment, Vertical : decrement) */ /* AM=1 (address is updated in vertical writing direction) */ LCD_WriteReg(R3, 0x1018); LCD_WriteReg(R7, 0x0173); /* 262K color and display ON */ }
/******************************************************************************* * Function Name : LCD_Setup * Description : Setups the LCD. * Input : None * Output : None * Return : None *******************************************************************************/ void LCD_Setup(void) { /* Configure the LCD Control pins --------------------------------------------*/ LCD_CtrlLinesConfig(); /* Configure the SPI2 interface ----------------------------------------------*/ LCD_SPIConfig(); if(LCDType == LCD_ILI9320) { Delay(5); /* Delay 50 ms */ /* Start Initial Sequence ------------------------------------------------*/ LCD_WriteReg(R229, 0x8000); /* Set the internal vcore voltage */ LCD_WriteReg(R0, 0x0001); /* Start internal OSC. */ LCD_WriteReg(R1, 0x0100); /* set SS and SM bit */ LCD_WriteReg(R2, 0x0700); /* set 1 line inversion */ LCD_WriteReg(R3, 0x1030); /* set GRAM write direction and BGR=1. */ LCD_WriteReg(R4, 0x0000); /* Resize register */ LCD_WriteReg(R8, 0x0202); /* set the back porch and front porch */ LCD_WriteReg(R9, 0x0000); /* set non-display area refresh cycle ISC[3:0] */ LCD_WriteReg(R10, 0x0000); /* FMARK function */ LCD_WriteReg(R12, 0x0000); /* RGB interface setting */ LCD_WriteReg(R13, 0x0000); /* Frame marker Position */ LCD_WriteReg(R15, 0x0000); /* RGB interface polarity */ /* Power On sequence -----------------------------------------------------*/ LCD_WriteReg(R16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(R17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ LCD_WriteReg(R18, 0x0000); /* VREG1OUT voltage */ LCD_WriteReg(R19, 0x0000); /* VDV[4:0] for VCOM amplitude */ Delay(20); /* Dis-charge capacitor power voltage (200ms) */ LCD_WriteReg(R16, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(R17, 0x0137); /* DC1[2:0], DC0[2:0], VC[2:0] */ Delay(5); /* Delay 50 ms */ LCD_WriteReg(R18, 0x0139); /* VREG1OUT voltage */ Delay(5); /* Delay 50 ms */ LCD_WriteReg(R19, 0x1d00); /* VDV[4:0] for VCOM amplitude */ LCD_WriteReg(R41, 0x0013); /* VCM[4:0] for VCOMH */ Delay(5); /* Delay 50 ms */ LCD_WriteReg(R32, 0x0000); /* GRAM horizontal Address */ LCD_WriteReg(R33, 0x0000); /* GRAM Vertical Address */ /* Adjust the Gamma Curve ------------------------------------------------*/ LCD_WriteReg(R48, 0x0006); LCD_WriteReg(R49, 0x0101); LCD_WriteReg(R50, 0x0003); LCD_WriteReg(R53, 0x0106); LCD_WriteReg(R54, 0x0b02); LCD_WriteReg(R55, 0x0302); LCD_WriteReg(R56, 0x0707); LCD_WriteReg(R57, 0x0007); LCD_WriteReg(R60, 0x0600); LCD_WriteReg(R61, 0x020b); /* Set GRAM area ---------------------------------------------------------*/ LCD_WriteReg(R80, 0x0000); /* Horizontal GRAM Start Address */ LCD_WriteReg(R81, 0x00EF); /* Horizontal GRAM End Address */ LCD_WriteReg(R82, 0x0000); /* Vertical GRAM Start Address */ LCD_WriteReg(R83, 0x013F); /* Vertical GRAM End Address */ LCD_WriteReg(R96, 0x2700); /* Gate Scan Line */ LCD_WriteReg(R97, 0x0001); /* NDL,VLE, REV */ LCD_WriteReg(R106, 0x0000); /* set scrolling line */ /* Partial Display Control -----------------------------------------------*/ LCD_WriteReg(R128, 0x0000); LCD_WriteReg(R129, 0x0000); LCD_WriteReg(R130, 0x0000); LCD_WriteReg(R131, 0x0000); LCD_WriteReg(R132, 0x0000); LCD_WriteReg(R133, 0x0000); /* Panel Control ---------------------------------------------------------*/ LCD_WriteReg(R144, 0x0010); LCD_WriteReg(R146, 0x0000); LCD_WriteReg(R147, 0x0003); LCD_WriteReg(R149, 0x0110); LCD_WriteReg(R151, 0x0000); LCD_WriteReg(R152, 0x0000); /* Set GRAM write direction and BGR = 1 */ /* I/D=01 (Horizontal : increment, Vertical : decrement) */ /* AM=1 (address is updated in vertical writing direction) */ LCD_WriteReg(R3, 0x1018); LCD_WriteReg(R7, 0x0173); /* 262K color and display ON */ } else if(LCDType == LCD_SPFD5408) { /* Start Initial Sequence --------------------------------------------------*/ LCD_WriteReg(R227, 0x3008); /* Set internal timing */ LCD_WriteReg(R231, 0x0012); /* Set internal timing */ LCD_WriteReg(R239, 0x1231); /* Set internal timing */ LCD_WriteReg(R1, 0x0100); /* Set SS and SM bit */ LCD_WriteReg(R2, 0x0700); /* Set 1 line inversion */ LCD_WriteReg(R3, 0x1030); /* Set GRAM write direction and BGR=1. */ LCD_WriteReg(R4, 0x0000); /* Resize register */ LCD_WriteReg(R8, 0x0202); /* Set the back porch and front porch */ LCD_WriteReg(R9, 0x0000); /* Set non-display area refresh cycle ISC[3:0] */ LCD_WriteReg(R10, 0x0000); /* FMARK function */ LCD_WriteReg(R12, 0x0000); /* RGB interface setting */ LCD_WriteReg(R13, 0x0000); /* Frame marker Position */ LCD_WriteReg(R15, 0x0000); /* RGB interface polarity */ /* Power On sequence -------------------------------------------------------*/ LCD_WriteReg(R16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(R17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ LCD_WriteReg(R18, 0x0000); /* VREG1OUT voltage */ LCD_WriteReg(R19, 0x0000); /* VDV[4:0] for VCOM amplitude */ Delay(20); /* Dis-charge capacitor power voltage (200ms) */ LCD_WriteReg(R17, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */ Delay(5); /* Delay 50 ms */ LCD_WriteReg(R16, 0x12B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ Delay(5); /* Delay 50 ms */ LCD_WriteReg(R18, 0x01BD); /* External reference voltage= Vci */ Delay(5); /* Delay 50 ms */ LCD_WriteReg(R19, 0x1400); /* VDV[4:0] for VCOM amplitude */ LCD_WriteReg(R41, 0x000E); /* VCM[4:0] for VCOMH */ Delay(5); /* Delay 50 ms */ LCD_WriteReg(R32, 0x0000); /* GRAM horizontal Address */ LCD_WriteReg(R33, 0x013F); /* GRAM Vertical Address */ /* Adjust the Gamma Curve --------------------------------------------------*/ LCD_WriteReg(R48, 0x0007); LCD_WriteReg(R49, 0x0302); LCD_WriteReg(R50, 0x0105); LCD_WriteReg(R53, 0x0206); LCD_WriteReg(R54, 0x0808); LCD_WriteReg(R55, 0x0206); LCD_WriteReg(R56, 0x0504); LCD_WriteReg(R57, 0x0007); LCD_WriteReg(R60, 0x0105); LCD_WriteReg(R61, 0x0808); /* Set GRAM area -----------------------------------------------------------*/ LCD_WriteReg(R80, 0x0000); /* Horizontal GRAM Start Address */ LCD_WriteReg(R81, 0x00EF); /* Horizontal GRAM End Address */ LCD_WriteReg(R82, 0x0000); /* Vertical GRAM Start Address */ LCD_WriteReg(R83, 0x013F); /* Vertical GRAM End Address */ LCD_WriteReg(R96, 0xA700); /* Gate Scan Line */ LCD_WriteReg(R97, 0x0001); /* NDL,VLE, REV */ LCD_WriteReg(R106, 0x0000); /* Set scrolling line */ /* Partial Display Control -------------------------------------------------*/ LCD_WriteReg(R128, 0x0000); LCD_WriteReg(R129, 0x0000); LCD_WriteReg(R130, 0x0000); LCD_WriteReg(R131, 0x0000); LCD_WriteReg(R132, 0x0000); LCD_WriteReg(R133, 0x0000); /* Panel Control -----------------------------------------------------------*/ LCD_WriteReg(R144, 0x0010); LCD_WriteReg(R146, 0x0000); LCD_WriteReg(R147, 0x0003); LCD_WriteReg(R149, 0x0110); LCD_WriteReg(R151, 0x0000); LCD_WriteReg(R152, 0x0000); /* Set GRAM write direction and BGR = 1 I/D=01 (Horizontal : increment, Vertical : decrement) AM=1 (address is updated in vertical writing direction) */ LCD_WriteReg(R3, 0x1018); LCD_WriteReg(R7, 0x0112); /* 262K color and display ON */ } else if(LCDType == LCD_HX8312) { /* Enable the LCD Oscillator ---------------------------------------------*/ LCD_WriteReg(R1, 0x10); LCD_WriteReg(R0, 0xA0); LCD_WriteReg(R3, 0x01); Delay(1); /* Delay 10 ms */ LCD_WriteReg(R3, 0x00); LCD_WriteReg(R43, 0x04); LCD_WriteReg(R40, 0x18); LCD_WriteReg(R26, 0x05); LCD_WriteReg(R37, 0x05); LCD_WriteReg(R25, 0x00); /* LCD Power On ----------------------------------------------------------*/ LCD_WriteReg(R28, 0x73); LCD_WriteReg(R36, 0x74); LCD_WriteReg(R30, 0x01); LCD_WriteReg(R24, 0xC1); Delay(1); /* Delay 10 ms */ LCD_WriteReg(R24, 0xE1); LCD_WriteReg(R24, 0xF1); Delay(6); /* Delay 60 ms */ LCD_WriteReg(R24, 0xF5); Delay(6); /* Delay 60 ms */ LCD_WriteReg(R27, 0x09); Delay(1); /* Delay 10 ms */ LCD_WriteReg(R31, 0x11); LCD_WriteReg(R32, 0x0E); LCD_WriteReg(R30, 0x81); Delay(1); /* Delay 10 ms */ /* Chip Set --------------------------------------------------------------*/ LCD_WriteReg(R157, 0x00); LCD_WriteReg(R192, 0x00); LCD_WriteReg(R14, 0x00); LCD_WriteReg(R15, 0x00); LCD_WriteReg(R16, 0x00); LCD_WriteReg(R17, 0x00); LCD_WriteReg(R18, 0x00); LCD_WriteReg(R19, 0x00); LCD_WriteReg(R20, 0x00); LCD_WriteReg(R21, 0x00); LCD_WriteReg(R22, 0x00); LCD_WriteReg(R23, 0x00); LCD_WriteReg(R52, 0x01); LCD_WriteReg(R53, 0x00); LCD_WriteReg(R75, 0x00); LCD_WriteReg(R76, 0x00); LCD_WriteReg(R78, 0x00); LCD_WriteReg(R79, 0x00); LCD_WriteReg(R80, 0x00); LCD_WriteReg(R60, 0x00); LCD_WriteReg(R61, 0x00); LCD_WriteReg(R62, 0x01); LCD_WriteReg(R63, 0x3F); LCD_WriteReg(R64, 0x02); LCD_WriteReg(R65, 0x02); LCD_WriteReg(R66, 0x00); LCD_WriteReg(R67, 0x00); LCD_WriteReg(R68, 0x00); LCD_WriteReg(R69, 0x00); LCD_WriteReg(R70, 0xEF); LCD_WriteReg(R71, 0x00); LCD_WriteReg(R72, 0x00); LCD_WriteReg(R73, 0x01); LCD_WriteReg(R74, 0x3F); LCD_WriteReg(R29, 0x08); /* R29:Gate scan direction setting */ LCD_WriteReg(R134, 0x00); LCD_WriteReg(R135, 0x30); LCD_WriteReg(R136, 0x02); LCD_WriteReg(R137, 0x05); LCD_WriteReg(R141, 0x01); /* R141:Register set-up mode for one line clock */ LCD_WriteReg(R139, 0x20); /* R139:One line SYSCLK number in one-line */ LCD_WriteReg(R51, 0x01); /* R51:N line inversion setting */ LCD_WriteReg(R55, 0x01); /* R55:Scanning method setting */ LCD_WriteReg(R118, 0x00); /* Gamma Set -------------------------------------------------------------*/ LCD_WriteReg(R143, 0x10); LCD_WriteReg(R144, 0x67); LCD_WriteReg(R145, 0x07); LCD_WriteReg(R146, 0x65); LCD_WriteReg(R147, 0x07); LCD_WriteReg(R148, 0x01); LCD_WriteReg(R149, 0x76); LCD_WriteReg(R150, 0x56); LCD_WriteReg(R151, 0x00); LCD_WriteReg(R152, 0x06); LCD_WriteReg(R153, 0x03); LCD_WriteReg(R154, 0x00); /* Display On ------------------------------------------------------------*/ LCD_WriteReg(R1, 0x50); LCD_WriteReg(R5, 0x04); LCD_WriteReg(R0, 0x80); LCD_WriteReg(R59, 0x01); Delay(4); /* Delay 40 ms */ LCD_WriteReg(R0, 0x20); } }
LCDTFTConf::LCDTFTConf() { CurrentFrameBuffer = LCD_FRAME_BUFFER; CurrentLayer = LCD_BACKGROUND_LAYER; LTDC_InitTypeDef LTDC_InitStruct; /* Configure the LCD Control pins ------------------------------------------*/ LCD_CtrlLinesConfig(); LCD_ChipSelect(DISABLE); LCD_ChipSelect(ENABLE); /* Configure the LCD_SPI interface -----------------------------------------*/ LCD_SPIConfig(); /* Power on the LCD --------------------------------------------------------*/ LCD_PowerOn(); /* Enable the LTDC Clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE); /* Enable the DMA2D Clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE); /* Configure the LCD Control pins */ LCD_AF_GPIOConfig(); /* Configure the FMC Parallel interface : SDRAM is used as Frame Buffer for LCD */ SDRAM_Init(); /* LTDC Configuration *********************************************************/ /* Polarity configuration */ /* Initialize the horizontal synchronization polarity as active low */ LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL; /* Initialize the vertical synchronization polarity as active low */ LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL; /* Initialize the data enable polarity as active low */ LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL; /* Initialize the pixel clock polarity as input pixel clock */ LTDC_InitStruct.LTDC_PCPolarity = LTDC_PCPolarity_IPC; /* Configure R,G,B component values for LCD background color */ LTDC_InitStruct.LTDC_BackgroundRedValue = 0; LTDC_InitStruct.LTDC_BackgroundGreenValue = 0; LTDC_InitStruct.LTDC_BackgroundBlueValue = 0; /* Configure PLLSAI prescalers for LCD */ /* Enable Pixel Clock */ /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAI_N = 192 Mhz */ /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAI_R = 192/4 = 48 Mhz */ /* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 48/8 = 6 Mhz */ RCC_PLLSAIConfig(192, 7, 4); RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div8); /* Enable PLLSAI Clock */ RCC_PLLSAICmd(ENABLE); /* Wait for PLLSAI activation */ while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET); /* Timing configuration */ /* Configure horizontal synchronization width */ LTDC_InitStruct.LTDC_HorizontalSync = 9; /* Configure vertical synchronization height */ LTDC_InitStruct.LTDC_VerticalSync = 1; /* Configure accumulated horizontal back porch */ LTDC_InitStruct.LTDC_AccumulatedHBP = 29; /* Configure accumulated vertical back porch */ LTDC_InitStruct.LTDC_AccumulatedVBP = 3; /* Configure accumulated active width */ LTDC_InitStruct.LTDC_AccumulatedActiveW = 269; /* Configure accumulated active height */ LTDC_InitStruct.LTDC_AccumulatedActiveH = 323; /* Configure total width */ LTDC_InitStruct.LTDC_TotalWidth = 279; /* Configure total height */ LTDC_InitStruct.LTDC_TotalHeigh = 327; LTDC_Init(<DC_InitStruct); LCD_LayerInit(); /* LTDC reload configuration */ LTDC_ReloadConfig(LTDC_IMReload); /* Enable the LTDC */ LTDC_Cmd(ENABLE); }
void LCD_Setup(void) { /* Configure the LCD Control pins --------------------------------------------*/ LCD_CtrlLinesConfig(); GPIO_ResetBits(GPIOC, GPIO_Pin_1); Delay(0x5FFFF); GPIO_SetBits(GPIOC, GPIO_Pin_1 ); Delay(0x5FFFF); //************* Start Initial Sequence **********// LCD_WriteReg(0x00E3, 0x3008); // Set u16ernal timing LCD_WriteReg(0x00E7, 0x0012); // Set u16ernal timing LCD_WriteReg(0x00EF, 0x1231); // Set u16ernal timing LCD_WriteReg(0x0001, 0x0100); // set SS and SM bit LCD_WriteReg(0x0002, 0x0700); // set 1 line inversion LCD_WriteReg(0x0003, 0x1038); // set GRAM write direction and BGR=1. LCD_WriteReg(0x0004, 0x0000); // Resize register LCD_WriteReg(0x0008, 0x020E); // set the back porch and front porch LCD_WriteReg(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0] LCD_WriteReg(0x000A, 0x0000); // FMARK function LCD_WriteReg(0x000C, 0x0000); // RGB u16erface setting LCD_WriteReg(0x000D, 0x0000); // Frame marker Position LCD_WriteReg(0x000F, 0x0000); // RGB u16erface polarity //*************Power On sequence ****************// LCD_WriteReg(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB LCD_WriteReg(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0] LCD_WriteReg(0x0012, 0x0000); // VREG1OUT voltage LCD_WriteReg(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude Delay(0XAFFFF); // Dis-charge capacitor power voltage LCD_WriteReg(0x0010, 0x1290); // SAP, BT[3:0], AP, DSTB, SLP, STB LCD_WriteReg(0x0011, 0x0221); // R11h=0x0221 at VCI=3.3V, DC1[2:0], DC0[2:0], VC[2:0] Delay(0XAFFFF); // Delay 50ms LCD_WriteReg(0x0012, 0x001A); // External reference voltage= Vci; Delay(0XAFFFF); // Delay 50ms LCD_WriteReg(0x0013, 0x1600); // R13=0F00 when R12=009E;VDV[4:0] for VCOM amplitude LCD_WriteReg(0x0029, 0x0022); // R29=0019 when R12=009E;VCM[5:0] for VCOMH LCD_WriteReg(0x002B, 0x000A); // Frame Rate Delay(0XAFFFF); // Delay 50ms LCD_WriteReg(0x0020, 0x0000); // GRAM horizontal Address LCD_WriteReg(0x0021, 0x0000); // GRAM Vertical Address // ----------- Adjust the Gamma Curve ----------// LCD_WriteReg(0x0030, 0x0000); LCD_WriteReg(0x0031, 0x0302); LCD_WriteReg(0x0032, 0x0202); LCD_WriteReg(0x0035, 0x0103); LCD_WriteReg(0x0036, 0x080C); LCD_WriteReg(0x0037, 0x0505); LCD_WriteReg(0x0038, 0x0504); LCD_WriteReg(0x0039, 0x0707); LCD_WriteReg(0x003C, 0x0301); LCD_WriteReg(0x003D, 0x1008); //------------------ Set GRAM area ---------------// LCD_WriteReg(0x0050, 0x0000); // Horizontal GRAM Start Address LCD_WriteReg(0x0051, 0x00EF); // Horizontal GRAM End Address LCD_WriteReg(0x0052, 0x0000); // Vertical GRAM Start Address LCD_WriteReg(0x0053, 0x013F); // Vertical GRAM Start Address LCD_WriteReg(0x0060, 0x2700); // Gate Scan Line LCD_WriteReg(0x0061, 0x0001); // NDL,VLE, REV LCD_WriteReg(0x006A, 0x0000); // set scrolling line //-------------- Partial Display Control ---------// LCD_WriteReg(0x0080, 0x0000); LCD_WriteReg(0x0081, 0x0000); LCD_WriteReg(0x0082, 0x0000); LCD_WriteReg(0x0083, 0x0000); LCD_WriteReg(0x0084, 0x0000); LCD_WriteReg(0x0085, 0x0000); //-------------- Panel Control -------------------// LCD_WriteReg(0x0090, 0x0010); LCD_WriteReg(0x0092, 0x0600); LCD_WriteReg(0x0093, 0x0003); LCD_WriteReg(0x0095, 0x0110); LCD_WriteReg(0x0097, 0x0000); LCD_WriteReg(0x0098, 0x0000); LCD_WriteReg(0x0007, 0x0133); // 262K color and display ON }
static void LCD_Config(void) { LTDC_InitTypeDef LTDC_InitStruct; LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct; GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); /* Configure NCS in Output Push-Pull mode */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOD, &GPIO_InitStructure); /* Configure the LCD Control pins ------------------------------------------*/ LCD_CtrlLinesConfig(); LCD_ChipSelect(DISABLE); LCD_ChipSelect(ENABLE); /* Configure the LCD_SPI interface -----------------------------------------*/ LCD_SPIConfig(); /* Power on the LCD --------------------------------------------------------*/ LCD_PowerOn(); /* Enable the LTDC Clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE); /* Enable the DMA2D Clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE); /* Configure the LCD Control pins */ LCD_AF_GPIOConfig(); /* Configure the FMC Parallel interface : SDRAM is used as Frame Buffer for LCD */ SDRAM_Init(); /* Enable Pixel Clock --------------------------------------------------------*/ /* Configure PLLSAI prescalers for LCD */ /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAI_N = 192 Mhz */ /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAI_R = 192/3 = 64 Mhz */ /* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 64/8 = 8 Mhz */ RCC_PLLSAIConfig(192, 7, 3); RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div8); /* Enable PLLSAI Clock */ RCC_PLLSAICmd(ENABLE); /* Wait for PLLSAI activation */ while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET) { } /* LTDC Initialization -------------------------------------------------------*/ /* Initialize the horizontal synchronization polarity as active low*/ LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL; /* Initialize the vertical synchronization polarity as active low */ LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL; /* Initialize the data enable polarity as active low */ LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL; /* Initialize the pixel clock polarity as input pixel clock */ LTDC_InitStruct.LTDC_PCPolarity = LTDC_PCPolarity_IPC; /* Timing configuration */ /* Configure horizontal synchronization width */ LTDC_InitStruct.LTDC_HorizontalSync = 9; /* Configure vertical synchronization height */ LTDC_InitStruct.LTDC_VerticalSync = 1; /* Configure accumulated horizontal back porch */ LTDC_InitStruct.LTDC_AccumulatedHBP = 29; /* Configure accumulated vertical back porch */ LTDC_InitStruct.LTDC_AccumulatedVBP = 3; /* Configure accumulated active width */ LTDC_InitStruct.LTDC_AccumulatedActiveW = 269; /* Configure accumulated active height */ LTDC_InitStruct.LTDC_AccumulatedActiveH = 323; /* Configure total width */ LTDC_InitStruct.LTDC_TotalWidth = 279; /* Configure total height */ LTDC_InitStruct.LTDC_TotalHeigh = 327; LTDC_Init(<DC_InitStruct); /* Configure R,G,B component values for LCD background color */ LTDC_InitStruct.LTDC_BackgroundRedValue = 0; LTDC_InitStruct.LTDC_BackgroundGreenValue = 0; LTDC_InitStruct.LTDC_BackgroundBlueValue = 0; LTDC_Init(<DC_InitStruct); /* LTDC initialization end ---------------------------------------------------*/ /* Layer1 Configuration ------------------------------------------------------*/ /* Windowing configuration */ /* In this case all the active display area is used to display a picture then : Horizontal start = horizontal synchronization + Horizontal back porch = 30 Horizontal stop = Horizontal start + window width -1 = 30 + 240 -1 Vertical start = vertical synchronization + vertical back porch = 4 Vertical stop = Vertical start + window height -1 = 4 + 320 -1 */ LTDC_Layer_InitStruct.LTDC_HorizontalStart = 30; LTDC_Layer_InitStruct.LTDC_HorizontalStop = (240 + 30 - 1); LTDC_Layer_InitStruct.LTDC_VerticalStart = 4; LTDC_Layer_InitStruct.LTDC_VerticalStop = (320 + 4 - 1); /* Pixel Format configuration*/ LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565; /* Alpha constant (255 totally opaque) */ LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 255; /* Configure blending factors */ LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA; LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA; /* Default Color configuration (configure A,R,G,B component values) */ LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0; LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0; LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0; LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = 0; /* Input Address configuration */ LTDC_Layer_InitStruct.LTDC_CFBStartAdress = (uint32_t)&RGB565_240x320; /* the length of one line of pixels in bytes + 3 then : Line Lenth = Active high width x number of bytes per pixel + 3 Active high width = 240 number of bytes per pixel = 2 (pixel_format : RGB565) */ LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((240 * 2) + 3); /* the pitch is the increment from the start of one line of pixels to the start of the next line in bytes, then : Pitch = Active high width x number of bytes per pixel */ LTDC_Layer_InitStruct.LTDC_CFBPitch = (240 * 2); /* configure the number of lines */ LTDC_Layer_InitStruct.LTDC_CFBLineNumber = 320; LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct); LTDC_DitherCmd(ENABLE); }
//****************************************************************************** // Universal Init void LCD_Init(void) { uint16_t lcdid = 0; // pointers = 0; fpLCD_SetWindow = 0; fpLCD_PutPixel = 0; fpLCD_DrawChar = 0; fpLCD_DrawFillRect = 0; fpLCD_DrawMonoPict = 0; fpLCD_WriteBMP = 0; // color config LCD_SetColorMode(colorIndex); // config gpio and fsmc LCD_CtrlLinesConfig(); LCD_FSMCConfig(); // displey reset LCD_Reset_Off(); guiDelay_ms(10); LCD_Reset_On(); guiDelay_ms(10); LCD_Reset_Off(); guiDelay_ms(250); // read display type lcdid = readTypeLCD(); if (lcdid == 0x9320) // ILI9320 { fpLCD_SetWindow = &LCD_SetWindow_ILI9320; fpLCD_PutPixel = &LCD_PutPixel_ILI9320; fpLCD_DrawChar = &LCD_DrawChar_ILI9320; fpLCD_DrawFillRect = &LCD_DrawFillRect_ILI9320; fpLCD_DrawMonoPict = &LCD_DrawMonoPict_ILI9320; fpLCD_WriteBMP = &LCD_WriteBMP_ILI9320; LCD_SetColorGRAM(lcdColorRGB_565); LCD_Init_ILI9320(); } if (lcdid == 0x9325) // ILI9325 { } if (lcdid == 0x1289) // SSD1289 { } if (lcdid == 0x0047) // HX8347-A { fpLCD_SetWindow = &LCD_SetWindow_HX8347A; fpLCD_PutPixel = &LCD_PutPixel_HX8347A; fpLCD_DrawChar = &LCD_DrawChar_HX8347A; fpLCD_DrawFillRect = &LCD_DrawFillRect_HX8347A; fpLCD_DrawMonoPict = &LCD_DrawMonoPict_HX8347A; fpLCD_WriteBMP = &LCD_WriteBMP_HX8347A; LCD_SetColorGRAM(lcdColorRGB_666); LCD_Init_HX8347A(); } if (lcdid == 0x8999) // SSD1298 { fpLCD_SetWindow = &LCD_SetWindow_SSD1298; fpLCD_PutPixel = &LCD_PutPixel_SSD1298; fpLCD_DrawChar = &LCD_DrawChar_SSD1298; fpLCD_DrawFillRect = &LCD_DrawFillRect_SSD1298; fpLCD_DrawMonoPict = &LCD_DrawMonoPict_SSD1298; fpLCD_WriteBMP = &LCD_WriteBMP_SSD1298; LCD_SetColorGRAM(lcdColorRGB_565); LCD_Init_SSD1298(); } // displwy clear LCD_Clear(LCD_COLOR_GREYL); LCD_SetFont(&LCD_DEFAULT_FONT); }
/** * @brief LCD Init. * @retval None */ uint8_t BSP_LCD_Init(void) { unsigned long ulCount; /* Configure the LCD Control pins */ LCD_CtrlLinesConfig(); /* Configure the FSMC Parallel interface */ LCD_FSMCConfig(); HAL_Delay(5); /* Reset LCD */ HAL_GPIO_WritePin(LCD_RST_PORT, LCD_RST_PIN, GPIO_PIN_RESET); HAL_Delay(10); HAL_GPIO_WritePin(LCD_RST_PORT, LCD_RST_PIN, GPIO_PIN_SET); /* SSD2119Init(void) */ /* Enter sleep mode (if we are not already there).*/ LCD_WriteReg(SSD2119_SLEEP_MODE_1_REG, 0x0001); /* Set initial power parameters. */ LCD_WriteReg(SSD2119_PWR_CTRL_5_REG, 0x00B2); LCD_WriteReg(SSD2119_VCOM_OTP_1_REG, 0x0006); /* Start the oscillator.*/ LCD_WriteReg(SSD2119_OSC_START_REG, 0x0001); /* Set pixel format and basic display orientation (scanning direction).*/ LCD_WriteReg(SSD2119_OUTPUT_CTRL_REG, 0x30EF); //RGB // LCD_WriteReg(SSD2119_OUTPUT_CTRL_REG, 0x38EF); //BGR LCD_WriteReg(SSD2119_LCD_DRIVE_AC_CTRL_REG, 0x0600); /* Exit sleep mode.*/ LCD_WriteReg(SSD2119_SLEEP_MODE_1_REG, 0x0000); HAL_Delay(5); /* Configure pixel color format and MCU interface parameters.*/ LCD_WriteReg(SSD2119_ENTRY_MODE_REG, ENTRY_MODE_DEFAULT); /* Set analog parameters */ LCD_WriteReg(SSD2119_SLEEP_MODE_2_REG, 0x0999); LCD_WriteReg(SSD2119_ANALOG_SET_REG, 0x3800); /* Enable the display */ LCD_WriteReg(SSD2119_DISPLAY_CTRL_REG, 0x0033); /* Set VCIX2 voltage to 6.1V.*/ LCD_WriteReg(SSD2119_PWR_CTRL_2_REG, 0x0005); /* Configure gamma correction.*/ LCD_WriteReg(SSD2119_GAMMA_CTRL_1_REG, 0x0000); LCD_WriteReg(SSD2119_GAMMA_CTRL_2_REG, 0x0303); LCD_WriteReg(SSD2119_GAMMA_CTRL_3_REG, 0x0407); LCD_WriteReg(SSD2119_GAMMA_CTRL_4_REG, 0x0301); LCD_WriteReg(SSD2119_GAMMA_CTRL_5_REG, 0x0301); LCD_WriteReg(SSD2119_GAMMA_CTRL_6_REG, 0x0403); LCD_WriteReg(SSD2119_GAMMA_CTRL_7_REG, 0x0707); LCD_WriteReg(SSD2119_GAMMA_CTRL_8_REG, 0x0400); LCD_WriteReg(SSD2119_GAMMA_CTRL_9_REG, 0x0a00); LCD_WriteReg(SSD2119_GAMMA_CTRL_10_REG, 0x1000); /* Configure Vlcd63 and VCOMl */ LCD_WriteReg(SSD2119_PWR_CTRL_3_REG, 0x000A); LCD_WriteReg(SSD2119_PWR_CTRL_4_REG, 0x2E00); /* Set the display size and ensure that the GRAM window is set to allow access to the full display buffer.*/ LCD_WriteReg(SSD2119_V_RAM_POS_REG, (LCD_PIXEL_HEIGHT-1) << 8); LCD_WriteReg(SSD2119_H_RAM_START_REG, 0x0000); LCD_WriteReg(SSD2119_H_RAM_END_REG, LCD_PIXEL_WIDTH-1); LCD_WriteReg(SSD2119_X_RAM_ADDR_REG, 0x00); LCD_WriteReg(SSD2119_Y_RAM_ADDR_REG, 0x00); /* clear the lcd */ LCD_WriteReg(SSD2119_RAM_DATA_REG, 0x0000); for(ulCount = 0; ulCount < (LCD_PIXEL_WIDTH * LCD_PIXEL_HEIGHT); ulCount++) { LCD_WriteRAM(0x0000); } /* Default value for draw propriety */ DrawProp.BackColor = 0xFFFF; DrawProp.pFont = &Font24; DrawProp.TextColor = 0x0000; BSP_LCD_SetFont(&LCD_DEFAULT_FONT); return 0; }
/** * @brief Initializes the LCD. * @param None * @retval None */ void STM3210E_LCD_Init(void) { /* Configure the LCD Control pins --------------------------------------------*/ LCD_CtrlLinesConfig(); /* Configure the FSMC Parallel interface -------------------------------------*/ LCD_FSMCConfig(); _delay_(5); /* delay 50 ms */ /* Check if the LCD is SPFD5408B Controller */ if(LCD_ReadReg(0x00) == 0x5408) { /* Start Initial Sequence ------------------------------------------------*/ LCD_WriteReg(R1, 0x0100); /* Set SS bit */ LCD_WriteReg(R2, 0x0700); /* Set 1 line inversion */ LCD_WriteReg(R3, 0x1030); /* Set GRAM write direction and BGR=1. */ LCD_WriteReg(R4, 0x0000); /* Resize register */ LCD_WriteReg(R8, 0x0202); /* Set the back porch and front porch */ LCD_WriteReg(R9, 0x0000); /* Set non-display area refresh cycle ISC[3:0] */ LCD_WriteReg(R10, 0x0000); /* FMARK function */ LCD_WriteReg(R12, 0x0000); /* RGB 18-bit System interface setting */ LCD_WriteReg(R13, 0x0000); /* Frame marker Position */ LCD_WriteReg(R15, 0x0000); /* RGB interface polarity, no impact */ /* Power On sequence -----------------------------------------------------*/ LCD_WriteReg(R16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(R17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ LCD_WriteReg(R18, 0x0000); /* VREG1OUT voltage */ LCD_WriteReg(R19, 0x0000); /* VDV[4:0] for VCOM amplitude */ _delay_(20); /* Dis-charge capacitor power voltage (200ms) */ LCD_WriteReg(R17, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */ _delay_(5); /* Delay 50 ms */ LCD_WriteReg(R16, 0x12B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ _delay_(5); /* Delay 50 ms */ LCD_WriteReg(R18, 0x01BD); /* External reference voltage= Vci */ _delay_(5); LCD_WriteReg(R19, 0x1400); /* VDV[4:0] for VCOM amplitude */ LCD_WriteReg(R41, 0x000E); /* VCM[4:0] for VCOMH */ _delay_(5); /* Delay 50 ms */ LCD_WriteReg(R32, 0x0000); /* GRAM horizontal Address */ LCD_WriteReg(R33, 0x013F); /* GRAM Vertical Address */ /* Adjust the Gamma Curve (SPFD5408B)-------------------------------------*/ LCD_WriteReg(R48, 0x0b0d); LCD_WriteReg(R49, 0x1923); LCD_WriteReg(R50, 0x1c26); LCD_WriteReg(R51, 0x261c); LCD_WriteReg(R52, 0x2419); LCD_WriteReg(R53, 0x0d0b); LCD_WriteReg(R54, 0x1006); LCD_WriteReg(R55, 0x0610); LCD_WriteReg(R56, 0x0706); LCD_WriteReg(R57, 0x0304); LCD_WriteReg(R58, 0x0e05); LCD_WriteReg(R59, 0x0e01); LCD_WriteReg(R60, 0x010e); LCD_WriteReg(R61, 0x050e); LCD_WriteReg(R62, 0x0403); LCD_WriteReg(R63, 0x0607); /* Set GRAM area ---------------------------------------------------------*/ LCD_WriteReg(R80, 0x0000); /* Horizontal GRAM Start Address */ LCD_WriteReg(R81, 0x00EF); /* Horizontal GRAM End Address */ LCD_WriteReg(R82, 0x0000); /* Vertical GRAM Start Address */ LCD_WriteReg(R83, 0x013F); /* Vertical GRAM End Address */ LCD_WriteReg(R96, 0xA700); /* Gate Scan Line */ LCD_WriteReg(R97, 0x0001); /* NDL, VLE, REV */ LCD_WriteReg(R106, 0x0000); /* set scrolling line */ /* Partial Display Control -----------------------------------------------*/ LCD_WriteReg(R128, 0x0000); LCD_WriteReg(R129, 0x0000); LCD_WriteReg(R130, 0x0000); LCD_WriteReg(R131, 0x0000); LCD_WriteReg(R132, 0x0000); LCD_WriteReg(R133, 0x0000); /* Panel Control ---------------------------------------------------------*/ LCD_WriteReg(R144, 0x0010); LCD_WriteReg(R146, 0x0000); LCD_WriteReg(R147, 0x0003); LCD_WriteReg(R149, 0x0110); LCD_WriteReg(R151, 0x0000); LCD_WriteReg(R152, 0x0000); /* Set GRAM write direction and BGR=1 I/D=01 (Horizontal : increment, Vertical : decrement) AM=1 (address is updated in vertical writing direction) */ LCD_WriteReg(R3, 0x1018); LCD_WriteReg(R7, 0x0112); /* 262K color and display ON */ return; } /* Start Initial Sequence ----------------------------------------------------*/ LCD_WriteReg(R229,0x8000); /* Set the internal vcore voltage */ LCD_WriteReg(R0, 0x0001); /* Start internal OSC. */ LCD_WriteReg(R1, 0x0100); /* set SS and SM bit */ LCD_WriteReg(R2, 0x0700); /* set 1 line inversion */ LCD_WriteReg(R3, 0x1030); /* set GRAM write direction and BGR=1. */ LCD_WriteReg(R4, 0x0000); /* Resize register */ LCD_WriteReg(R8, 0x0202); /* set the back porch and front porch */ LCD_WriteReg(R9, 0x0000); /* set non-display area refresh cycle ISC[3:0] */ LCD_WriteReg(R10, 0x0000); /* FMARK function */ LCD_WriteReg(R12, 0x0000); /* RGB interface setting */ LCD_WriteReg(R13, 0x0000); /* Frame marker Position */ LCD_WriteReg(R15, 0x0000); /* RGB interface polarity */ /* Power On sequence ---------------------------------------------------------*/ LCD_WriteReg(R16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(R17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ LCD_WriteReg(R18, 0x0000); /* VREG1OUT voltage */ LCD_WriteReg(R19, 0x0000); /* VDV[4:0] for VCOM amplitude */ _delay_(20); /* Dis-charge capacitor power voltage (200ms) */ LCD_WriteReg(R16, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(R17, 0x0137); /* DC1[2:0], DC0[2:0], VC[2:0] */ _delay_(5); /* Delay 50 ms */ LCD_WriteReg(R18, 0x0139); /* VREG1OUT voltage */ _delay_(5); /* Delay 50 ms */ LCD_WriteReg(R19, 0x1d00); /* VDV[4:0] for VCOM amplitude */ LCD_WriteReg(R41, 0x0013); /* VCM[4:0] for VCOMH */ _delay_(5); /* Delay 50 ms */ LCD_WriteReg(R32, 0x0000); /* GRAM horizontal Address */ LCD_WriteReg(R33, 0x0000); /* GRAM Vertical Address */ /* Adjust the Gamma Curve ----------------------------------------------------*/ LCD_WriteReg(R48, 0x0006); LCD_WriteReg(R49, 0x0101); LCD_WriteReg(R50, 0x0003); LCD_WriteReg(R53, 0x0106); LCD_WriteReg(R54, 0x0b02); LCD_WriteReg(R55, 0x0302); LCD_WriteReg(R56, 0x0707); LCD_WriteReg(R57, 0x0007); LCD_WriteReg(R60, 0x0600); LCD_WriteReg(R61, 0x020b); /* Set GRAM area -------------------------------------------------------------*/ LCD_WriteReg(R80, 0x0000); /* Horizontal GRAM Start Address */ LCD_WriteReg(R81, 0x00EF); /* Horizontal GRAM End Address */ LCD_WriteReg(R82, 0x0000); /* Vertical GRAM Start Address */ LCD_WriteReg(R83, 0x013F); /* Vertical GRAM End Address */ LCD_WriteReg(R96, 0x2700); /* Gate Scan Line */ LCD_WriteReg(R97, 0x0001); /* NDL,VLE, REV */ LCD_WriteReg(R106, 0x0000); /* set scrolling line */ /* Partial Display Control ---------------------------------------------------*/ LCD_WriteReg(R128, 0x0000); LCD_WriteReg(R129, 0x0000); LCD_WriteReg(R130, 0x0000); LCD_WriteReg(R131, 0x0000); LCD_WriteReg(R132, 0x0000); LCD_WriteReg(R133, 0x0000); /* Panel Control -------------------------------------------------------------*/ LCD_WriteReg(R144, 0x0010); LCD_WriteReg(R146, 0x0000); LCD_WriteReg(R147, 0x0003); LCD_WriteReg(R149, 0x0110); LCD_WriteReg(R151, 0x0000); LCD_WriteReg(R152, 0x0000); /* Set GRAM write direction and BGR = 1 */ /* I/D=01 (Horizontal : increment, Vertical : decrement) */ /* AM=1 (address is updated in vertical writing direction) */ LCD_WriteReg(R3, 0x1018); LCD_WriteReg(R7, 0x0173); /* 262K color and display ON */ }
/** * @brief Initializes the LCD. * @param None * @retval None */ void STM3210E_LCD_Init(void) { /* Configure the LCD Control pins */ LCD_CtrlLinesConfig(); /* Configure the FSMC Parallel interface */ LCD_FSMCConfig(); /* delay 50 ms */ _delay_(5); /* Read the LCD ID */ LCD_ID = LCD_ReadReg(0x00); /* Check if the LCD is HX8347D Controller */ if (LCD_ID == LCD_HX8347D) { /* Driving ability setting */ LCD_WriteReg(LCD_REG_234, 0x00); LCD_WriteReg(LCD_REG_235, 0x20); LCD_WriteReg(LCD_REG_236, 0x0C); LCD_WriteReg(LCD_REG_237, 0xC4); LCD_WriteReg(LCD_REG_232, 0x40); LCD_WriteReg(LCD_REG_233, 0x38); LCD_WriteReg(LCD_REG_241, 0x01); /* RGB 18-bit interface ;0x0110 */ LCD_WriteReg(LCD_REG_242, 0x10); LCD_WriteReg(LCD_REG_39, 0xA3); /* Adjust the Gamma Curve */ LCD_WriteReg(LCD_REG_64, 0x01); LCD_WriteReg(LCD_REG_65, 0x00); LCD_WriteReg(LCD_REG_66, 0x00); LCD_WriteReg(LCD_REG_67, 0x10); LCD_WriteReg(LCD_REG_68, 0x0E); LCD_WriteReg(LCD_REG_69, 0x24); LCD_WriteReg(LCD_REG_70, 0x04); LCD_WriteReg(LCD_REG_71, 0x50); LCD_WriteReg(LCD_REG_72, 0x02); LCD_WriteReg(LCD_REG_73, 0x13); LCD_WriteReg(LCD_REG_74, 0x19); LCD_WriteReg(LCD_REG_75, 0x19); LCD_WriteReg(LCD_REG_76, 0x16); LCD_WriteReg(LCD_REG_80, 0x1B); LCD_WriteReg(LCD_REG_81, 0x31); LCD_WriteReg(LCD_REG_82, 0x2F); LCD_WriteReg(LCD_REG_83, 0x3F); LCD_WriteReg(LCD_REG_84, 0x3F); LCD_WriteReg(LCD_REG_85, 0x3E); LCD_WriteReg(LCD_REG_86, 0x2F); LCD_WriteReg(LCD_REG_87, 0x7B); LCD_WriteReg(LCD_REG_88, 0x09); LCD_WriteReg(LCD_REG_89, 0x06); LCD_WriteReg(LCD_REG_90, 0x06); LCD_WriteReg(LCD_REG_91, 0x0C); LCD_WriteReg(LCD_REG_92, 0x1D); LCD_WriteReg(LCD_REG_93, 0xCC); /* Power voltage setting */ LCD_WriteReg(LCD_REG_27, 0x1B); LCD_WriteReg(LCD_REG_26, 0x01); LCD_WriteReg(LCD_REG_36, 0x2F); LCD_WriteReg(LCD_REG_37, 0x57); /*****VCOM offset ****/ LCD_WriteReg(LCD_REG_35, 0x86); /* Power on setting */ LCD_WriteReg(LCD_REG_24, 0x36); /* Display frame rate:75Hz(2.85MHz X 117%) */ LCD_WriteReg(LCD_REG_25, 0x01); /* Internal oscillator start to oscillate */ LCD_WriteReg(LCD_REG_1, 0x00); LCD_WriteReg(LCD_REG_31, 0x88); /* Step-up Circuit 1 on,open abnormal power-off monitor */ _delay_(6); LCD_WriteReg(LCD_REG_31, 0x80); /* Step-up Circuit 1 off */ _delay_(6); LCD_WriteReg(LCD_REG_31, 0x90); /* VCOML voltage can output to negative voltage, (1.0V ~ VCL+0.5V) */ _delay_(6); LCD_WriteReg(LCD_REG_31, 0xD0); /* Step-up Circuit 2 on */ _delay_(6); LCD_WriteReg(LCD_REG_23, 0x05); /* COLMOD control */ /* Set GRAM Area - Partial Display Control */ LCD_WriteReg(LCD_REG_1, 0x00); /* Scroll off */ LCD_WriteReg(LCD_REG_2, 0x00); LCD_WriteReg(LCD_REG_3, 0x00); LCD_WriteReg(LCD_REG_4, 0x01); /* X,Y swap */ LCD_WriteReg(LCD_REG_5, 0x3F); /* X,Y swap */ LCD_WriteReg(LCD_REG_6, 0x00); LCD_WriteReg(LCD_REG_7, 0x00); LCD_WriteReg(LCD_REG_8, 0x00); /* X,Y swap */ LCD_WriteReg(LCD_REG_9, 0xEF); /* X,Y swap */ /* Memory access control */ /* bit7 controls left,right swap(X) */ /* bit6 controls up,down swap(Y) */ /* bit5 controls X,Y swap */ LCD_WriteReg(LCD_REG_22, 0x28); /* SET PANEL */ LCD_WriteReg(LCD_REG_54, 0x00); /* Panel characteristic control */ LCD_WriteReg(LCD_REG_54, 0x04); /* Panel characteristic control: gate driver shift reverse[work] */ LCD_WriteReg(LCD_REG_40, 0x38); /* Display control3: source output->PT(0,0) */ _delay_(20); LCD_WriteReg(LCD_REG_40, 0x3C); /* Display control3: source output->Display */ } else { /* Check if the LCD is SPFD5408B Controller */ if (LCD_ReadReg(0x00) == 0x5408) { /* Start Initial Sequence ------------------------------------------------ */ LCD_WriteReg(LCD_REG_1, 0x0100); /* Set SS bit */ LCD_WriteReg(LCD_REG_2, 0x0700); /* Set 1 line inversion */ LCD_WriteReg(LCD_REG_3, 0x1030); /* Set GRAM write direction and BGR=1. */ LCD_WriteReg(LCD_REG_4, 0x0000); /* Resize register */ LCD_WriteReg(LCD_REG_8, 0x0202); /* Set the back porch and front porch */ LCD_WriteReg(LCD_REG_9, 0x0000); /* Set non-display area refresh cycle ISC[3:0] */ LCD_WriteReg(LCD_REG_10, 0x0000); /* FMARK function */ LCD_WriteReg(LCD_REG_12, 0x0000); /* RGB 18-bit System interface setting */ LCD_WriteReg(LCD_REG_13, 0x0000); /* Frame marker Position */ LCD_WriteReg(LCD_REG_15, 0x0000); /* RGB interface polarity, no impact */ /* Power On sequence ----------------------------------------------------- */ LCD_WriteReg(LCD_REG_16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(LCD_REG_17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ LCD_WriteReg(LCD_REG_18, 0x0000); /* VREG1OUT voltage */ LCD_WriteReg(LCD_REG_19, 0x0000); /* VDV[4:0] for VCOM amplitude */ _delay_(60); /* Dis-charge capacitor power voltage (200ms) */ LCD_WriteReg(LCD_REG_17, 0x0007); /* DC1[2:0], DC0[2:0], VC[2:0] */ _delay_(20); /* Delay 50 ms */ LCD_WriteReg(LCD_REG_16, 0x12B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ _delay_(20); /* Delay 50 ms */ LCD_WriteReg(LCD_REG_18, 0x01BD); /* External reference voltage= Vci */ _delay_(20); LCD_WriteReg(LCD_REG_19, 0x1400); /* VDV[4:0] for VCOM amplitude */ LCD_WriteReg(LCD_REG_41, 0x000E); /* VCM[4:0] for VCOMH */ _delay_(20); /* Delay 50 ms */ LCD_WriteReg(LCD_REG_32, 0x0000); /* GRAM horizontal Address */ LCD_WriteReg(LCD_REG_33, 0x013F); /* GRAM Vertical Address */ /* Adjust the Gamma Curve (SPFD5408B)------------------------------------- */ LCD_WriteReg(LCD_REG_48, 0x0b0d); LCD_WriteReg(LCD_REG_49, 0x1923); LCD_WriteReg(LCD_REG_50, 0x1c26); LCD_WriteReg(LCD_REG_51, 0x261c); LCD_WriteReg(LCD_REG_52, 0x2419); LCD_WriteReg(LCD_REG_53, 0x0d0b); LCD_WriteReg(LCD_REG_54, 0x1006); LCD_WriteReg(LCD_REG_55, 0x0610); LCD_WriteReg(LCD_REG_56, 0x0706); LCD_WriteReg(LCD_REG_57, 0x0304); LCD_WriteReg(LCD_REG_58, 0x0e05); LCD_WriteReg(LCD_REG_59, 0x0e01); LCD_WriteReg(LCD_REG_60, 0x010e); LCD_WriteReg(LCD_REG_61, 0x050e); LCD_WriteReg(LCD_REG_62, 0x0403); LCD_WriteReg(LCD_REG_63, 0x0607); /* Set GRAM area --------------------------------------------------------- */ LCD_WriteReg(LCD_REG_80, 0x0000); /* Horizontal GRAM Start Address */ LCD_WriteReg(LCD_REG_81, 0x00EF); /* Horizontal GRAM End Address */ LCD_WriteReg(LCD_REG_82, 0x0000); /* Vertical GRAM Start Address */ LCD_WriteReg(LCD_REG_83, 0x013F); /* Vertical GRAM End Address */ LCD_WriteReg(LCD_REG_96, 0xA700); /* Gate Scan Line */ LCD_WriteReg(LCD_REG_97, 0x0001); /* NDL, VLE, REV */ LCD_WriteReg(LCD_REG_106, 0x0000); /* set scrolling line */ /* Partial Display Control ----------------------------------------------- */ LCD_WriteReg(LCD_REG_128, 0x0000); LCD_WriteReg(LCD_REG_129, 0x0000); LCD_WriteReg(LCD_REG_130, 0x0000); LCD_WriteReg(LCD_REG_131, 0x0000); LCD_WriteReg(LCD_REG_132, 0x0000); LCD_WriteReg(LCD_REG_133, 0x0000); /* Panel Control --------------------------------------------------------- */ LCD_WriteReg(LCD_REG_144, 0x0010); LCD_WriteReg(LCD_REG_146, 0x0000); LCD_WriteReg(LCD_REG_147, 0x0003); LCD_WriteReg(LCD_REG_149, 0x0110); LCD_WriteReg(LCD_REG_151, 0x0000); LCD_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) */ LCD_WriteReg(LCD_REG_3, 0x1018); LCD_WriteReg(LCD_REG_7, 0x0112); /* 262K color and display ON */ LCD_SetFont(&LCD_DEFAULT_FONT); return; } /* Start Initial Sequence ---------------------------------------------------- */ LCD_WriteReg(LCD_REG_229, 0x8000); /* Set the internal vcore voltage */ LCD_WriteReg(LCD_REG_0, 0x0001); /* Start internal OSC. */ LCD_WriteReg(LCD_REG_1, 0x0100); /* set SS and SM bit */ LCD_WriteReg(LCD_REG_2, 0x0700); /* set 1 line inversion */ LCD_WriteReg(LCD_REG_3, 0x1030); /* set GRAM write direction and BGR=1. */ LCD_WriteReg(LCD_REG_4, 0x0000); /* Resize register */ LCD_WriteReg(LCD_REG_8, 0x0202); /* set the back porch and front porch */ LCD_WriteReg(LCD_REG_9, 0x0000); /* set non-display area refresh cycle ISC[3:0] */ LCD_WriteReg(LCD_REG_10, 0x0000); /* FMARK function */ LCD_WriteReg(LCD_REG_12, 0x0000); /* RGB interface setting */ LCD_WriteReg(LCD_REG_13, 0x0000); /* Frame marker Position */ LCD_WriteReg(LCD_REG_15, 0x0000); /* RGB interface polarity */ /* Power On sequence --------------------------------------------------------- */ LCD_WriteReg(LCD_REG_16, 0x0000); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(LCD_REG_17, 0x0000); /* DC1[2:0], DC0[2:0], VC[2:0] */ LCD_WriteReg(LCD_REG_18, 0x0000); /* VREG1OUT voltage */ LCD_WriteReg(LCD_REG_19, 0x0000); /* VDV[4:0] for VCOM amplitude */ _delay_(20); /* Dis-charge capacitor power voltage (200ms) */ LCD_WriteReg(LCD_REG_16, 0x17B0); /* SAP, BT[3:0], AP, DSTB, SLP, STB */ LCD_WriteReg(LCD_REG_17, 0x0137); /* DC1[2:0], DC0[2:0], VC[2:0] */ _delay_(20); /* Delay 50 ms */ LCD_WriteReg(LCD_REG_18, 0x0139); /* VREG1OUT voltage */ _delay_(20); /* Delay 50 ms */ LCD_WriteReg(LCD_REG_19, 0x1d00); /* VDV[4:0] for VCOM amplitude */ LCD_WriteReg(LCD_REG_41, 0x0013); /* VCM[4:0] for VCOMH */ _delay_(20); /* Delay 50 ms */ LCD_WriteReg(LCD_REG_32, 0x0000); /* GRAM horizontal Address */ LCD_WriteReg(LCD_REG_33, 0x0000); /* GRAM Vertical Address */ /* Adjust the Gamma Curve ---------------------------------------------------- */ LCD_WriteReg(LCD_REG_48, 0x0006); LCD_WriteReg(LCD_REG_49, 0x0101); LCD_WriteReg(LCD_REG_50, 0x0003); LCD_WriteReg(LCD_REG_53, 0x0106); LCD_WriteReg(LCD_REG_54, 0x0b02); LCD_WriteReg(LCD_REG_55, 0x0302); LCD_WriteReg(LCD_REG_56, 0x0707); LCD_WriteReg(LCD_REG_57, 0x0007); LCD_WriteReg(LCD_REG_60, 0x0600); LCD_WriteReg(LCD_REG_61, 0x020b); /* Set GRAM area ------------------------------------------------------------- */ LCD_WriteReg(LCD_REG_80, 0x0000); /* Horizontal GRAM Start Address */ LCD_WriteReg(LCD_REG_81, 0x00EF); /* Horizontal GRAM End Address */ LCD_WriteReg(LCD_REG_82, 0x0000); /* Vertical GRAM Start Address */ LCD_WriteReg(LCD_REG_83, 0x013F); /* Vertical GRAM End Address */ LCD_WriteReg(LCD_REG_96, 0x2700); /* Gate Scan Line */ LCD_WriteReg(LCD_REG_97, 0x0001); /* NDL,VLE, REV */ LCD_WriteReg(LCD_REG_106, 0x0000); /* set scrolling line */ /* Partial Display Control --------------------------------------------------- */ LCD_WriteReg(LCD_REG_128, 0x0000); LCD_WriteReg(LCD_REG_129, 0x0000); LCD_WriteReg(LCD_REG_130, 0x0000); LCD_WriteReg(LCD_REG_131, 0x0000); LCD_WriteReg(LCD_REG_132, 0x0000); LCD_WriteReg(LCD_REG_133, 0x0000); /* Panel Control ------------------------------------------------------------- */ LCD_WriteReg(LCD_REG_144, 0x0010); LCD_WriteReg(LCD_REG_146, 0x0000); LCD_WriteReg(LCD_REG_147, 0x0003); LCD_WriteReg(LCD_REG_149, 0x0110); LCD_WriteReg(LCD_REG_151, 0x0000); LCD_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) */ LCD_WriteReg(LCD_REG_3, 0x1018); LCD_WriteReg(LCD_REG_7, 0x0173); /* 262K color and display ON */ } LCD_SetFont(&LCD_DEFAULT_FONT); }