void LCD_Init(void) { LCD_Bus_Init(); Set_Cs; Set_Rs; Set_nWr; Set_nRd; Clr_Rst; Delay_Ms(10); Set_Rst; Delay_Ms(10); Lcd_Light_ON; //driving ability LCD_WriteReg(0xEA, 0x0000); LCD_WriteReg(0xEB, 0x0020); LCD_WriteReg(0xEC, 0x000C); LCD_WriteReg(0xED, 0x00C4); LCD_WriteReg(0xE8, 0x0040); LCD_WriteReg(0xE9, 0x0038); LCD_WriteReg(0xF1, 0x0001); LCD_WriteReg(0xF2, 0x0010); LCD_WriteReg(0x27, 0x00A3); //power voltage LCD_WriteReg(0x1B, 0x001B); LCD_WriteReg(0x1A, 0x0001); LCD_WriteReg(0x24, 0x002F); LCD_WriteReg(0x25, 0x0057); //VCOM offset LCD_WriteReg(0x23, 0x008D); //for flicker adjust //power on LCD_WriteReg(0x18, 0x0036); LCD_WriteReg(0x19, 0x0001); //start osc LCD_WriteReg(0x01, 0x0000); //wakeup LCD_WriteReg(0x1F, 0x0088); Delay_Ms(5); LCD_WriteReg(0x1F, 0x0080); Delay_Ms(5); LCD_WriteReg(0x1F, 0x0090); Delay_Ms(5); LCD_WriteReg(0x1F, 0x00D0); Delay_Ms(5); //color selection LCD_WriteReg(0x17, 0x0005); //0x0005=65k, 0x0006=262k //panel characteristic LCD_WriteReg(0x36, 0x0000); //display on LCD_WriteReg(0x28, 0x0038); Delay_Ms(40); LCD_WriteReg(0x28, 0x003C); //display options LCD_WriteReg(0x16, 0x00A8); //MY=1 MX=0 MV=1 ML=0 BGR=1 LCD_Area(0, 0, (LCD_WIDTH-1), (LCD_HEIGHT-1)); }
/** * @brief Setup the LCD for the HX8347D Controller. * @param None * @retval None */ void LCD_Setup(void) { /* 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_(2); LCD_WriteReg(LCD_REG_31, 0x80); /* Step-up Circuit 1 off */ _delay_(2); LCD_WriteReg(LCD_REG_31, 0x90); /* VCOML voltage can output to negative voltage, (1.0V ~ VCL+0.5V) */ _delay_(2); LCD_WriteReg(LCD_REG_31, 0xD0); /* Step-up Circuit 2 on */ _delay_(2); 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_(6); LCD_WriteReg(LCD_REG_40, 0x3C); /* Display control3: source output->Display */ }
/******************************************************************************* * Function Name : LCD_SetCursor * Description : Sets the cursor position. * Input : - Xpos: specifies the X position. * - Ypos: specifies the Y position. * Output : None * Return : None *******************************************************************************/ void LCD_SetCursor(u8 Xpos, u16 Ypos) { LCD_WriteReg(R32, Xpos); LCD_WriteReg(R33, Ypos); }
/** * @brief Main program * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s) before to branch to application main. */ /* SysTick end of count event each 10ms */ RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency / 100); /* Initialize LEDs mounted on EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); STM_EVAL_LEDOn(LED1); /* Initialize the LCD */ LCD_Init(); LCD_Clear(Black); LCD_SetTextColor(White); LCD_LOG_SetHeader((uint8_t*)"STM32 Camera Demo"); LCD_LOG_SetFooter ((uint8_t*)" Copyright (c) STMicroelectronics" ); /* ADC configuration */ ADC_Config(); /* Initializes the DCMI interface (I2C and GPIO) used to configure the camera */ OV2640_HW_Init(); /* Read the OV9655/OV2640 Manufacturer identifier */ OV9655_ReadID(&OV9655_Camera_ID); OV2640_ReadID(&OV2640_Camera_ID); if(OV9655_Camera_ID.PID == 0x96) { Camera = OV9655_CAMERA; sprintf((char*)abuffer, "OV9655 Camera ID 0x%x", OV9655_Camera_ID.PID); ValueMax = 2; } else if(OV2640_Camera_ID.PIDH == 0x26) { Camera = OV2640_CAMERA; sprintf((char*)abuffer, "OV2640 Camera ID 0x%x", OV2640_Camera_ID.PIDH); ValueMax = 2; } else { LCD_SetTextColor(LCD_COLOR_RED); LCD_DisplayStringLine(LINE(4), (uint8_t*)"Check the Camera HW and try again"); while(1); } LCD_SetTextColor(LCD_COLOR_YELLOW); LCD_DisplayStringLine(LINE(4), (uint8_t*)abuffer); LCD_SetTextColor(LCD_COLOR_WHITE); Delay(200); /* Initialize demo */ ImageFormat = (ImageFormat_TypeDef)Demo_Init(); /* Configure the Camera module mounted on STM324xG-EVAL/STM324x7I-EVAL boards */ Demo_LCD_Clear(); LCD_DisplayStringLine(LINE(4), (uint8_t*)"Camera Init.. "); Camera_Config(); sprintf((char*)abuffer, " Image selected: %s", ImageForematArray[ImageFormat]); LCD_DisplayStringLine(LINE(4),(uint8_t*)abuffer); /* Enable DMA2 stream 1 and DCMI interface then start image capture */ DMA_Cmd(DMA2_Stream1, ENABLE); DCMI_Cmd(ENABLE); /* Insert 100ms delay: wait 100ms */ Delay(200); DCMI_CaptureCmd(ENABLE); LCD_ClearLine(LINE(4)); Demo_LCD_Clear(); if(ImageFormat == BMP_QQVGA) { /* LCD Display window */ LCD_SetDisplayWindow(179, 239, 120, 160); LCD_WriteReg(LCD_REG_3, 0x1038); LCD_WriteRAM_Prepare(); } else if(ImageFormat == BMP_QVGA) { /* LCD Display window */ LCD_SetDisplayWindow(239, 319, 240, 320); LCD_WriteReg(LCD_REG_3, 0x1038); LCD_WriteRAM_Prepare(); } while(1) { /* Blink LD1, LED2 and LED4 */ STM_EVAL_LEDToggle(LED1); STM_EVAL_LEDToggle(LED2); STM_EVAL_LEDToggle(LED3); STM_EVAL_LEDToggle(LED4); /* Insert 100ms delay */ Delay(10); /* Get the last ADC3 conversion result data */ uhADCVal = ADC_GetConversionValue(ADC3); /* Change the Brightness of camera using "Brightness Adjustment" register: For OV9655 camera Brightness can be positively (0x01 ~ 0x7F) and negatively (0x80 ~ 0xFF) adjusted For OV2640 camera Brightness can be positively (0x20 ~ 0x40) and negatively (0 ~ 0x20) adjusted */ if(Camera == OV9655_CAMERA) { OV9655_BrightnessConfig(uhADCVal); } if(Camera == OV2640_CAMERA) { OV2640_BrightnessConfig(uhADCVal/2); } } }
static void LCD_SetCursor( int x, int y ){ LCD_WriteReg( 0x20, y); LCD_WriteReg( 0x21, 320 - x ); }
/** * @brief Sets the cursor position. * @param Xpos: specifies the X position. * @param Ypos: specifies the Y position. * @retval None */ void LCD_SetCursor(uint8_t Xpos, uint16_t Ypos) { LCD_WriteReg(R32, Xpos); LCD_WriteReg(R33, Ypos); }
/* * 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); }
/******************************************************************************* * Function Name : LCD_DisplayOn * Description : Enables the Display. * Input : None * Output : None * Return : None *******************************************************************************/ void LCD_DisplayOn(void) { /* Display On */ LCD_WriteReg(0x26, 0x3C); /* 262K color and display ON */ }
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 }
/** * @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 Main program. * @param None * @retval None */ int main(void) { NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0000); Redbull_Init(); char buff[128] = { 0 }; LCD_DisplayStringLine(LINE(10), (uint8_t*) " Analog .............................."); Analog_Config(); printRight(10, "ok"); LCD_DisplayStringLine(LINE(11), (uint8_t*) " DAC ................................."); DAC_Config(); printRight(11, "ok"); f_mount(0, &fatfs); LCD_DisplayStringLine(LINE(12), (uint8_t*) " TEMP ................................"); OneWireInit(); float c = Read_Temperature(); sprintf(buff, "%.1f", c); printRight(12, buff); printf("%s\n", buff); RGBLED_GPIO_Config(0xff); RGBLED_Update(0xff,0xff,0xff); Delay(200); RGBLED_Update(0xff,0,0); Delay(200); RGBLED_Update(0,0xff,0); Delay(200); RGBLED_Update(0,0,0xff); Delay(200); RGBLED_Update(0,0,0); //static char path[1024] = "0:"; //LCD_Clear(LCD_COLOR_BLUE); //LCD_DisplayStringLine(0, (uint8_t*) "Loading..."); Delay(1000); //int i = 10; LCD_Clear(LCD_COLOR_BLACK); LCD_SetDisplayWindow(0, 0, 239, 319); LCD_WriteReg(3, 0x1000); LCD_WriteRAM_Prepare(); TIM_Cmd(TIM7, ENABLE); DMARead(); //float h = 0, s = 1, v = 1; while (1) { while (DMA_GetFlagStatus(DMA1_FLAG_TE1) == SET) { printf("DMA error\n"); Delay(100); } //uint32_t ms = millis(); uint16_t rem = DMA_GetCurrDataCounter(DMA1_Channel1); uint16_t cnt = 0xffff - rem; if (cnt >= 80 && cnt < 512) { continue; } uint32_t buff[160] = { 0 }; uint16_t tillend = cnt > 160 ? 160 : cnt; uint16_t fromstart = 160 - tillend; uint16_t bcnt = cnt - 160; // before SRAM_ReadBuffer((uint16_t*) &buff[0], bcnt * 4, tillend * 2); // after if (fromstart) { SRAM_ReadBuffer((uint16_t*) &buff[tillend], 0, fromstart * 2); } uint8_t prevsv = 0; for (uint16_t i = 0; i < 320; i++) { uint16_t val = 0; if (i & 1) { val = buff[i >> 1] & 0x0fff; } else { val = (buff[i >> 1] >> 16) & 0x0fff; } #define MAXV (17 * 238) val = val > MAXV ? MAXV : val; uint8_t sv = val / 17; sv = sv > 238 ? 238 : sv; sv++; if (!prevsv) { prevsv = sv; } uint16_t pbuf[240]; uint8_t minv = sv > prevsv ? prevsv : sv; uint8_t maxv = sv < prevsv ? prevsv : sv; for (uint8_t y = 0; y < 240; y++) { if (y >= minv && y <= maxv) { pbuf[y] = LCD_COLOR_YELLOW; } else { pbuf[y] = LCD_COLOR_BLACK; } } prevsv = sv; DMA_InitTypeDef DMA_InitStructure; DMA_DeInit(DMA2_Channel5); DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t) pbuf; DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t) &LCD->LCD_RAM; // FSMC DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; DMA_InitStructure.DMA_BufferSize = 240; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Enable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; DMA_InitStructure.DMA_Mode = DMA_Mode_Normal; DMA_InitStructure.DMA_Priority = DMA_Priority_Low; DMA_InitStructure.DMA_M2M = DMA_M2M_Enable; DMA_Init(DMA2_Channel5, &DMA_InitStructure); DMA_Cmd(DMA2_Channel5, ENABLE); RTC_t rtc; RTC_GetTime(&rtc); //RGBLED_Update((rtc.min & 1) ? 0 : (rtc.hour * 10), ((rtc.sec >> 2) & 1) ? 0 : (rtc.min * 4), rtc.sec * 4); while (!DMA_GetFlagStatus(DMA2_FLAG_TC5)) ; DMA_ClearFlag(DMA2_FLAG_TC5); while (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_8) == RESET) ; }
/***************************************************************************** ** �������: 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); }
void LCD_Init(void)//TFT初始化 { LCD_FSMC_Init(); //初始化FSMC delay_ms(50); //power参数 LCD_WriteReg(0x11,0x2004); LCD_WriteReg(0x13,0xCC00); LCD_WriteReg(0x15,0x2600); LCD_WriteReg(0x14,0x252A); LCD_WriteReg(0x12,0x0033); LCD_WriteReg(0x13,0xCC04); delay_ms(1); LCD_WriteReg(0x13,0xCC06); delay_ms(1); LCD_WriteReg(0x13,0xCC4F); delay_ms(1); LCD_WriteReg(0x13,0x674F); LCD_WriteReg(0x11,0x2003); delay_ms(1); //伽马控制参数 LCD_WriteReg(0x30,0x2609); LCD_WriteReg(0x31,0x242C); LCD_WriteReg(0x32,0x1F23); LCD_WriteReg(0x33,0x2425); LCD_WriteReg(0x34,0x2226); LCD_WriteReg(0x35,0x2523); LCD_WriteReg(0x36,0x1C1A); LCD_WriteReg(0x37,0x131D); LCD_WriteReg(0x38,0x0B11); LCD_WriteReg(0x39,0x1210); LCD_WriteReg(0x3A,0x1315); LCD_WriteReg(0x3B,0x3619); LCD_WriteReg(0x3C,0x0D00); LCD_WriteReg(0x3D,0x000D); LCD_WriteReg(0x16,0x0007); LCD_WriteReg(0x02,0x0013); LCD_WriteReg(0x03,0x0003); LCD_WriteReg(0x01,0x0127); delay_ms(1); LCD_WriteReg(0x08,0x0303); LCD_WriteReg(0x0A,0x000B); LCD_WriteReg(0x0B,0x0003); LCD_WriteReg(0x0C,0x0000); LCD_WriteReg(0x41,0x0000); LCD_WriteReg(0x50,0x0000); LCD_WriteReg(0x60,0x0005); LCD_WriteReg(0x70,0x000B); LCD_WriteReg(0x71,0x0000); LCD_WriteReg(0x78,0x0000); LCD_WriteReg(0x7A,0x0000); LCD_WriteReg(0x79,0x0007); LCD_WriteReg(0x07,0x0051); delay_ms(1); LCD_WriteReg(0x07,0x0053); LCD_WriteReg(0x79,0x0000); LCD_WR_REG(0x0022); }
//初始化lcd //该初始化函数可以初始化各种ILI93XX液晶,但是其他函数是基于ILI9320的!!! //在其他型号的驱动芯片上没有测试! void LCD_Init(void) { RCC->APB2ENR|=1<<3;//先使能外设PORTB时钟 RCC->APB2ENR|=1<<4;//先使能外设PORTC时钟 RCC->APB2ENR|=1<<0; //开启辅助时钟 JTAG_Set(SWD_ENABLE); //开启SWD //PORTC6~10复用推挽输出 GPIOC->CRH&=0XFFFFF000; GPIOC->CRH|=0X00000333; GPIOC->CRL&=0X00FFFFFF; GPIOC->CRL|=0X33000000; GPIOC->ODR|=0X07C0; //PORTB 推挽输出 GPIOB->CRH=0X33333333; GPIOB->CRL=0X33333333; GPIOB->ODR=0XFFFF; delay_ms(50); // delay 50 ms LCD_WriteReg(0x0000,0x0001); delay_ms(50); // delay 50 ms DeviceCode = LCD_ReadReg(0x0000); printf(" LCD ID:%x\n",DeviceCode); //打印LCD ID if(DeviceCode==0x9325) { LCD_WriteReg(0x00E5,0x78F0); 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,0x0000); LCD_WriteReg(0x000D,0x0000); LCD_WriteReg(0x000F,0x0000); //power on sequence VGHVGL LCD_WriteReg(0x0010,0x0000); LCD_WriteReg(0x0011,0x0007); LCD_WriteReg(0x0012,0x0000); LCD_WriteReg(0x0013,0x0000); LCD_WriteReg(0x0007,0x0000); //vgh LCD_WriteReg(0x0010,0x1690); LCD_WriteReg(0x0011,0x0227); //delayms(100); //vregiout LCD_WriteReg(0x0012,0x009D); //0x001b //delayms(100); //vom amplitude LCD_WriteReg(0x0013,0x1900); //delayms(100); //vom H LCD_WriteReg(0x0029,0x0025); LCD_WriteReg(0x002B,0x000D); //gamma LCD_WriteReg(0x0030,0x0007); LCD_WriteReg(0x0031,0x0303); LCD_WriteReg(0x0032,0x0003);// 0006 LCD_WriteReg(0x0035,0x0206); LCD_WriteReg(0x0036,0x0008); LCD_WriteReg(0x0037,0x0406); LCD_WriteReg(0x0038,0x0304);//0200 LCD_WriteReg(0x0039,0x0007); LCD_WriteReg(0x003C,0x0602);// 0504 LCD_WriteReg(0x003D,0x0008); //ram 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); LCD_WriteReg(0x00,0x0022);// }else if(DeviceCode==0x9328)//ILI9328 { LCD_WriteReg(0x00e7,0x0010); LCD_WriteReg(0x0000,0x0001);//开启内部时钟 LCD_WriteReg(0x0001,0x0100); LCD_WriteReg(0x0002,0x0700);//电源开启 //LCD_WriteReg(0x0003,(1<<3)|(1<<4) ); //65K RGB //DRIVE TABLE(寄存器 03H) //BIT3=AM BIT4:5=ID0:1 //AM ID0 ID1 FUNCATION // 0 0 0 R->L D->U // 1 0 0 D->U R->L // 0 1 0 L->R D->U // 1 1 0 D->U L->R // 0 0 1 R->L U->D // 1 0 1 U->D R->L // 0 1 1 L->R U->D 正常就用这个. // 1 1 1 U->D L->R LCD_WriteReg(0x0003,(1<<12)|(3<<4)|(0<<3) );//65K LCD_WriteReg(0x0004,0x0000); LCD_WriteReg(0x0008,0x0207); LCD_WriteReg(0x0009,0x0000); LCD_WriteReg(0x000a,0x0000);//display setting LCD_WriteReg(0x000c,0x0001);//display setting LCD_WriteReg(0x000d,0x0000);//0f3c LCD_WriteReg(0x000f,0x0000); //电源配置 LCD_WriteReg(0x0010,0x0000); LCD_WriteReg(0x0011,0x0007); LCD_WriteReg(0x0012,0x0000); LCD_WriteReg(0x0013,0x0000); delay_ms(50); LCD_WriteReg(0x0010,0x1590); LCD_WriteReg(0x0011,0x0227); delay_ms(50); LCD_WriteReg(0x0012,0x009c); delay_ms(50); LCD_WriteReg(0x0013,0x1900); LCD_WriteReg(0x0029,0x0023); LCD_WriteReg(0x002b,0x000e); delay_ms(50); LCD_WriteReg(0x0020,0x0000); LCD_WriteReg(0x0021,0x013f); delay_ms(50); //伽马校正 LCD_WriteReg(0x0030,0x0007); LCD_WriteReg(0x0031,0x0707); LCD_WriteReg(0x0032,0x0006); LCD_WriteReg(0x0035,0x0704); LCD_WriteReg(0x0036,0x1f04); LCD_WriteReg(0x0037,0x0004); LCD_WriteReg(0x0038,0x0000); LCD_WriteReg(0x0039,0x0706); LCD_WriteReg(0x003c,0x0701); LCD_WriteReg(0x003d,0x000f); delay_ms(50); LCD_WriteReg(0x0050,0x0000); //水平GRAM起始位置 LCD_WriteReg(0x0051,0x00ef); //水平GRAM终止位置 LCD_WriteReg(0x0052,0x0000); //垂直GRAM起始位置 LCD_WriteReg(0x0053,0x013f); //垂直GRAM终止位置 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,0x0000); LCD_WriteReg(0x0093,0x0003); LCD_WriteReg(0x0095,0x0110); LCD_WriteReg(0x0097,0x0000); LCD_WriteReg(0x0098,0x0000); //开启显示设置 LCD_WriteReg(0x0007,0x0133); LCD_WriteReg(0x0020,0x0000); LCD_WriteReg(0x0021,0x013f); }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. delay_ms(50); LCD_WriteReg(0x07,0x0101); //Display Contral. delay_ms(50); 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) }else if(DeviceCode==0x5408) { LCD_WriteReg(0x01,0x0100); LCD_WriteReg(0x02,0x0700);//LCD Driving Waveform Contral LCD_WriteReg(0x03,0x1030);//Entry Mode设置 //指针从左至右自上而下的自动增模式 //Normal Mode(Window Mode disable) //RGB格式 //16位数据2次传输的8总线设置 LCD_WriteReg(0x04,0x0000); //Scalling Control register LCD_WriteReg(0x08,0x0207); //Display Control 2 LCD_WriteReg(0x09,0x0000); //Display Control 3 LCD_WriteReg(0x0A,0x0000); //Frame Cycle Control LCD_WriteReg(0x0C,0x0000); //External Display Interface Control 1 LCD_WriteReg(0x0D,0x0000); //Frame Maker Position LCD_WriteReg(0x0F,0x0000); //External Display Interface Control 2 delay_ms(20); //TFT 液晶彩色图像显示方法14 LCD_WriteReg(0x10,0x16B0); //0x14B0 //Power Control 1 LCD_WriteReg(0x11,0x0001); //0x0007 //Power Control 2 LCD_WriteReg(0x17,0x0001); //0x0000 //Power Control 3 LCD_WriteReg(0x12,0x0138); //0x013B //Power Control 4 LCD_WriteReg(0x13,0x0800); //0x0800 //Power Control 5 LCD_WriteReg(0x29,0x0009); //NVM read data 2 LCD_WriteReg(0x2a,0x0009); //NVM read data 3 LCD_WriteReg(0xa4,0x0000); LCD_WriteReg(0x50,0x0000); //设置操作窗口的X轴开始列 LCD_WriteReg(0x51,0x00EF); //设置操作窗口的X轴结束列 LCD_WriteReg(0x52,0x0000); //设置操作窗口的Y轴开始行 LCD_WriteReg(0x53,0x013F); //设置操作窗口的Y轴结束行 LCD_WriteReg(0x60,0x2700); //Driver Output Control //设置屏幕的点数以及扫描的起始行 LCD_WriteReg(0x61,0x0001); //Driver Output Control LCD_WriteReg(0x6A,0x0000); //Vertical Scroll 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); //Display Position – Partial Display 2 LCD_WriteReg(0x84,0x0000); //RAM Address Start – Partial Display 2 LCD_WriteReg(0x85,0x0000); //RAM address End – Partail Display2 LCD_WriteReg(0x90,0x0013); //Frame Cycle Control LCD_WriteReg(0x92,0x0000); //Panel Interface Control 2 LCD_WriteReg(0x93,0x0003); //Panel Interface control 3 LCD_WriteReg(0x95,0x0110); //Frame Cycle Control LCD_WriteReg(0x07,0x0173); delay_ms(50); } else if(DeviceCode==0x1505) { // second release on 3/5 ,luminance is acceptable,water wave appear during camera preview LCD_WriteReg(0x0007,0x0000); delay_ms(50); LCD_WriteReg(0x0012,0x011C);//0x011A why need to set several times? LCD_WriteReg(0x00A4,0x0001);//NVM LCD_WriteReg(0x0008,0x000F); LCD_WriteReg(0x000A,0x0008); LCD_WriteReg(0x000D,0x0008); //伽马校正 LCD_WriteReg(0x0030,0x0707); LCD_WriteReg(0x0031,0x0007); //0x0707 LCD_WriteReg(0x0032,0x0603); LCD_WriteReg(0x0033,0x0700); LCD_WriteReg(0x0034,0x0202); LCD_WriteReg(0x0035,0x0002); //?0x0606 LCD_WriteReg(0x0036,0x1F0F); LCD_WriteReg(0x0037,0x0707); //0x0f0f 0x0105 LCD_WriteReg(0x0038,0x0000); LCD_WriteReg(0x0039,0x0000); LCD_WriteReg(0x003A,0x0707); LCD_WriteReg(0x003B,0x0000); //0x0303 LCD_WriteReg(0x003C,0x0007); //?0x0707 LCD_WriteReg(0x003D,0x0000); //0x1313//0x1f08 delay_ms(50); LCD_WriteReg(0x0007,0x0001); LCD_WriteReg(0x0017,0x0001);//开启电源 delay_ms(50); //电源配置 LCD_WriteReg(0x0010,0x17A0); LCD_WriteReg(0x0011,0x0217);//reference voltage VC[2:0] Vciout = 1.00*Vcivl LCD_WriteReg(0x0012,0x011E);//0x011c //Vreg1out = Vcilvl*1.80 is it the same as Vgama1out ? LCD_WriteReg(0x0013,0x0F00);//VDV[4:0]-->VCOM Amplitude VcomL = VcomH - Vcom Ampl LCD_WriteReg(0x002A,0x0000); LCD_WriteReg(0x0029,0x000A);//0x0001F Vcomh = VCM1[4:0]*Vreg1out gate source voltage?? LCD_WriteReg(0x0012,0x013E);// 0x013C power supply on //Coordinates Control// LCD_WriteReg(0x0050,0x0000);//0x0e00 LCD_WriteReg(0x0051,0x00EF); LCD_WriteReg(0x0052,0x0000); LCD_WriteReg(0x0053,0x013F); //Pannel Image Control// LCD_WriteReg(0x0060,0x2700); LCD_WriteReg(0x0061,0x0001); LCD_WriteReg(0x006A,0x0000); LCD_WriteReg(0x0080,0x0000); //Partial Image Control// LCD_WriteReg(0x0081,0x0000); LCD_WriteReg(0x0082,0x0000); LCD_WriteReg(0x0083,0x0000); LCD_WriteReg(0x0084,0x0000); LCD_WriteReg(0x0085,0x0000); //Panel Interface Control// LCD_WriteReg(0x0090,0x0013);//0x0010 frenqucy LCD_WriteReg(0x0092,0x0300); LCD_WriteReg(0x0093,0x0005); LCD_WriteReg(0x0095,0x0000); LCD_WriteReg(0x0097,0x0000); LCD_WriteReg(0x0098,0x0000); LCD_WriteReg(0x0001,0x0100); LCD_WriteReg(0x0002,0x0700); LCD_WriteReg(0x0003,0x1030); LCD_WriteReg(0x0004,0x0000); LCD_WriteReg(0x000C,0x0000); LCD_WriteReg(0x000F,0x0000); LCD_WriteReg(0x0020,0x0000); LCD_WriteReg(0x0021,0x0000); LCD_WriteReg(0x0007,0x0021); delay_ms(20); LCD_WriteReg(0x0007,0x0061); delay_ms(20); LCD_WriteReg(0x0007,0x0173); delay_ms(20); }else if(DeviceCode==0xB505) { LCD_WriteReg(0x0000,0x0000); LCD_WriteReg(0x0000,0x0000); LCD_WriteReg(0x0000,0x0000); LCD_WriteReg(0x0000,0x0000); LCD_WriteReg(0x00a4,0x0001); delay_ms(20); LCD_WriteReg(0x0060,0x2700); LCD_WriteReg(0x0008,0x0202); LCD_WriteReg(0x0030,0x0214); LCD_WriteReg(0x0031,0x3715); LCD_WriteReg(0x0032,0x0604); LCD_WriteReg(0x0033,0x0e16); LCD_WriteReg(0x0034,0x2211); LCD_WriteReg(0x0035,0x1500); LCD_WriteReg(0x0036,0x8507); LCD_WriteReg(0x0037,0x1407); LCD_WriteReg(0x0038,0x1403); LCD_WriteReg(0x0039,0x0020); LCD_WriteReg(0x0090,0x001a); LCD_WriteReg(0x0010,0x0000); LCD_WriteReg(0x0011,0x0007); LCD_WriteReg(0x0012,0x0000); LCD_WriteReg(0x0013,0x0000); delay_ms(20); LCD_WriteReg(0x0010,0x0730); LCD_WriteReg(0x0011,0x0137); delay_ms(20); LCD_WriteReg(0x0012,0x01b8); delay_ms(20); LCD_WriteReg(0x0013,0x0f00); LCD_WriteReg(0x002a,0x0080); LCD_WriteReg(0x0029,0x0048); delay_ms(20); LCD_WriteReg(0x0001,0x0100); LCD_WriteReg(0x0002,0x0700); LCD_WriteReg(0x0003,0x1230); LCD_WriteReg(0x0008,0x0202); LCD_WriteReg(0x000a,0x0000); LCD_WriteReg(0x000c,0x0000); LCD_WriteReg(0x000d,0x0000); LCD_WriteReg(0x000e,0x0030); LCD_WriteReg(0x0050,0x0000); LCD_WriteReg(0x0051,0x00ef); LCD_WriteReg(0x0052,0x0000); LCD_WriteReg(0x0053,0x013f); LCD_WriteReg(0x0060,0x2700); LCD_WriteReg(0x0061,0x0001); LCD_WriteReg(0x006a,0x0000); //LCD_WriteReg(0x0080,0x0000); //LCD_WriteReg(0x0081,0x0000); LCD_WriteReg(0x0090,0X0011); LCD_WriteReg(0x0092,0x0600); LCD_WriteReg(0x0093,0x0402); LCD_WriteReg(0x0094,0x0002); delay_ms(20); LCD_WriteReg(0x0007,0x0001); delay_ms(20); LCD_WriteReg(0x0007,0x0061); LCD_WriteReg(0x0007,0x0173); LCD_WriteReg(0x0020,0x0000); LCD_WriteReg(0x0021,0x0000); LCD_WriteReg(0x00,0x22); }else if(DeviceCode==0x8989) { LCD_WriteReg(0x0000,0x0001);//打开晶振 LCD_WriteReg(0x0003,0xA8A4);//0xA8A4 LCD_WriteReg(0x000C,0x0000); LCD_WriteReg(0x000D,0x080C); LCD_WriteReg(0x000E,0x2B00); LCD_WriteReg(0x001E,0x00B0); LCD_WriteReg(0x0001,0x2B3F);//驱动输出控制320*240 0x6B3F LCD_WriteReg(0x0002,0x0600); LCD_WriteReg(0x0010,0x0000); LCD_WriteReg(0x0011,0x6070); //定义数据格式 16位色 横屏 0x6058 LCD_WriteReg(0x0005,0x0000); LCD_WriteReg(0x0006,0x0000); LCD_WriteReg(0x0016,0xEF1C); LCD_WriteReg(0x0017,0x0003); LCD_WriteReg(0x0007,0x0233); //0x0233 LCD_WriteReg(0x000B,0x0000); LCD_WriteReg(0x000F,0x0000); //扫描开始地址 LCD_WriteReg(0x0041,0x0000); LCD_WriteReg(0x0042,0x0000); LCD_WriteReg(0x0048,0x0000); LCD_WriteReg(0x0049,0x013F); LCD_WriteReg(0x004A,0x0000); LCD_WriteReg(0x004B,0x0000); LCD_WriteReg(0x0044,0xEF00); LCD_WriteReg(0x0045,0x0000); LCD_WriteReg(0x0046,0x013F); LCD_WriteReg(0x0030,0x0707); LCD_WriteReg(0x0031,0x0204); LCD_WriteReg(0x0032,0x0204); LCD_WriteReg(0x0033,0x0502); LCD_WriteReg(0x0034,0x0507); LCD_WriteReg(0x0035,0x0204); LCD_WriteReg(0x0036,0x0204); LCD_WriteReg(0x0037,0x0502); LCD_WriteReg(0x003A,0x0302); LCD_WriteReg(0x003B,0x0302); LCD_WriteReg(0x0023,0x0000); LCD_WriteReg(0x0024,0x0000); LCD_WriteReg(0x0025,0x8000); LCD_WriteReg(0x004f,0); //行首址0 LCD_WriteReg(0x004e,0); //列首址0 }else if(DeviceCode==0x4531) { LCD_WriteReg(0X00,0X0001); delay_ms(10); LCD_WriteReg(0X10,0X1628); LCD_WriteReg(0X12,0X000e);//0x0006 LCD_WriteReg(0X13,0X0A39); delay_ms(10); LCD_WriteReg(0X11,0X0040); LCD_WriteReg(0X15,0X0050); delay_ms(10); LCD_WriteReg(0X12,0X001e);//16 delay_ms(10); LCD_WriteReg(0X10,0X1620); LCD_WriteReg(0X13,0X2A39); delay_ms(10); LCD_WriteReg(0X01,0X0100); LCD_WriteReg(0X02,0X0300); LCD_WriteReg(0X03,0X1030);//改变方向的 LCD_WriteReg(0X08,0X0202); LCD_WriteReg(0X0A,0X0008); LCD_WriteReg(0X30,0X0000); LCD_WriteReg(0X31,0X0402); LCD_WriteReg(0X32,0X0106); LCD_WriteReg(0X33,0X0503); LCD_WriteReg(0X34,0X0104); LCD_WriteReg(0X35,0X0301); LCD_WriteReg(0X36,0X0707); LCD_WriteReg(0X37,0X0305); LCD_WriteReg(0X38,0X0208); LCD_WriteReg(0X39,0X0F0B); LCD_WriteReg(0X41,0X0002); LCD_WriteReg(0X60,0X2700); LCD_WriteReg(0X61,0X0001); LCD_WriteReg(0X90,0X0210); LCD_WriteReg(0X92,0X010A); LCD_WriteReg(0X93,0X0004); LCD_WriteReg(0XA0,0X0100); LCD_WriteReg(0X07,0X0001); LCD_WriteReg(0X07,0X0021); LCD_WriteReg(0X07,0X0023); LCD_WriteReg(0X07,0X0033); LCD_WriteReg(0X07,0X0133); LCD_WriteReg(0XA0,0X0000); }else if(DeviceCode==0x4535) { LCD_WriteReg(0X15,0X0030); LCD_WriteReg(0X9A,0X0010); LCD_WriteReg(0X11,0X0020); LCD_WriteReg(0X10,0X3428); LCD_WriteReg(0X12,0X0002);//16 LCD_WriteReg(0X13,0X1038); delay_ms(40); LCD_WriteReg(0X12,0X0012);//16 delay_ms(40); LCD_WriteReg(0X10,0X3420); LCD_WriteReg(0X13,0X3038); delay_ms(70); LCD_WriteReg(0X30,0X0000); LCD_WriteReg(0X31,0X0402); LCD_WriteReg(0X32,0X0307); LCD_WriteReg(0X33,0X0304); LCD_WriteReg(0X34,0X0004); LCD_WriteReg(0X35,0X0401); LCD_WriteReg(0X36,0X0707); LCD_WriteReg(0X37,0X0305); LCD_WriteReg(0X38,0X0610); LCD_WriteReg(0X39,0X0610); LCD_WriteReg(0X01,0X0100); LCD_WriteReg(0X02,0X0300); LCD_WriteReg(0X03,0X1030);//改变方向的 LCD_WriteReg(0X08,0X0808); LCD_WriteReg(0X0A,0X0008); LCD_WriteReg(0X60,0X2700); LCD_WriteReg(0X61,0X0001); LCD_WriteReg(0X90,0X013E); LCD_WriteReg(0X92,0X0100); LCD_WriteReg(0X93,0X0100); LCD_WriteReg(0XA0,0X3000); LCD_WriteReg(0XA3,0X0010); LCD_WriteReg(0X07,0X0001); LCD_WriteReg(0X07,0X0021); LCD_WriteReg(0X07,0X0023); LCD_WriteReg(0X07,0X0033); LCD_WriteReg(0X07,0X0133); } LCD_LED=1;//点亮背光 LCD_Clear(WHITE); }
/******************************************************************************* * Function Name : LCD_DisplayOn * Description : Enables the Display. * Input : None * Output : None * Return : None *******************************************************************************/ void LCD_DisplayOn(void) { /* Display On */ LCD_WriteReg(R7, 0x0173); /* 262K color and display ON */ }
/******************************************************************************* * Function Name : LCD_SetCursor * Description : Sets the cursor position. * Input : - Xpos: specifies the X position. * - Ypos: specifies the Y position. * Output : None * Return : None *******************************************************************************/ void LCD_SetCursor(u8 Xpos, u16 Ypos) { LCD_WriteReg(0x0020, Xpos); LCD_WriteReg(0x0021, Ypos); }
/******************************************************************************* * Function Name : LCD_DisplayOff * Description : Disables the Display. * Input : None * Output : None * Return : None *******************************************************************************/ void LCD_DisplayOff(void) { /* Display Off */ LCD_WriteReg(R7, 0x0); }
//LCD开启显示 void LCD_DisplayOn(void) { LCD_WriteReg(R7, 0x0173); //26万色显示开启 }
/** * @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(); _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 */ }
//LCD关闭显示 void LCD_DisplayOff(void) { LCD_WriteReg(R7, 0x0);//关闭显示 }
void LCD_SetCursor(uint16_t Xpos, uint16_t Ypos) { LCD_WriteReg(LCD_REG_78, Xpos); LCD_WriteReg(LCD_REG_79, Ypos); }
//设置光标位置 //Xpos:横坐标 //Ypos:纵坐标 void LCD_SetCursor(u16 Xpos, u16 Ypos) { LCD_WriteReg(R32, Ypos); LCD_WriteReg(R33, 319-Xpos); }
static void register_write( int a, int d ){ LCD_WriteReg( a, d ); }
/////////////////////////////////////////////////////////初始化///////////////////////////////////////////// void LCD_Init_color(void) { delay(50, mS); // delay 50 ms LCD_WriteReg(0x0000,0x0001); delay(50, mS); // delay 50 ms //DeviceCode = LCD_ReadReg(0x0000); LCD_WriteReg(0x00e7,0x0010); LCD_WriteReg(0x0000,0x0001);//开启内部时钟 LCD_WriteReg(0x0001,0x0100); LCD_WriteReg(0x0002,0x0700);//电源开启 //LCD_WriteReg(0x0003,(1<<3)|(1<<4) ); //65K RGB //DRIVE TABLE(寄存器 03H) //BIT3=AM BIT4:5=ID0:1 //AM ID0 ID1 FUNCATION // 0 0 0 R->L D->U // 1 0 0 D->U R->L // 0 1 0 L->R D->U // 1 1 0 D->U L->R // 0 0 1 R->L U->D // 1 0 1 U->D R->L // 0 1 1 L->R U->D 正常就用这个. // 1 1 1 U->D L->R LCD_WriteReg(0x0003,(1<<12)|(3<<4)|(0<<3) );//65K LCD_WriteReg(0x0004,0x0000); LCD_WriteReg(0x0008,0x0207); LCD_WriteReg(0x0009,0x0000); LCD_WriteReg(0x000a,0x0000);//display setting LCD_WriteReg(0x000c,0x0001);//display setting LCD_WriteReg(0x000d,0x0000);//0f3c LCD_WriteReg(0x000f,0x0000); //电源配置 LCD_WriteReg(0x0010,0x0000); LCD_WriteReg(0x0011,0x0007); LCD_WriteReg(0x0012,0x0000); LCD_WriteReg(0x0013,0x0000); delay(50, mS); LCD_WriteReg(0x0010,0x1590); LCD_WriteReg(0x0011,0x0227); delay(50, mS); LCD_WriteReg(0x0012,0x009c); delay(50, mS); LCD_WriteReg(0x0013,0x1900); LCD_WriteReg(0x0029,0x0023); LCD_WriteReg(0x002b,0x000e); delay(50, mS); LCD_WriteReg(0x0020,0x0000); LCD_WriteReg(0x0021,0x013f); delay(50, mS); //伽马校正 LCD_WriteReg(0x0030,0x0007); LCD_WriteReg(0x0031,0x0707); LCD_WriteReg(0x0032,0x0006); LCD_WriteReg(0x0035,0x0704); LCD_WriteReg(0x0036,0x1f04); LCD_WriteReg(0x0037,0x0004); LCD_WriteReg(0x0038,0x0000); LCD_WriteReg(0x0039,0x0706); LCD_WriteReg(0x003c,0x0701); LCD_WriteReg(0x003d,0x000f); delay(50, mS); LCD_WriteReg(0x0050,0x0000); //水平GRAM起始位置 LCD_WriteReg(0x0051,0x00ef); //水平GRAM终止位置 LCD_WriteReg(0x0052,0x0000); //垂直GRAM起始位置 LCD_WriteReg(0x0053,0x013f); //垂直GRAM终止位置 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,0x0000); LCD_WriteReg(0x0093,0x0003); LCD_WriteReg(0x0095,0x0110); LCD_WriteReg(0x0097,0x0000); LCD_WriteReg(0x0098,0x0000); LCD_WriteReg(0x03,0x1018); //开启显示设置 LCD_WriteReg(0x0007,0x0133); LCD_WriteReg(0x0020,0x0000); LCD_WriteReg(0x0021,0x013f); }
/******************************************************************************* * 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); } }
void LCD_Init(void) { u32 lcdid=0; LCD_LineConf(); LCD_FSMCConf(); delay_ms(5); lcdid=LCD_ReadReg(0x00); if(lcdid == 0x9320) { LCD_WriteReg(0xE5,0x8000); LCD_WriteReg(0x00,0x0001); LCD_WriteReg(0x01,0x0100); LCD_WriteReg(0x02,0x0700); LCD_WriteReg(0x03,0x1030); LCD_WriteReg(0x04,0x0000); LCD_WriteReg(0x08,0x0202); LCD_WriteReg(0x09,0x0000); LCD_WriteReg(0x0A,0x0000); LCD_WriteReg(0x0B,0x0000); LCD_WriteReg(0x0C,0x0000); LCD_WriteReg(0x0F,0x0000); LCD_WriteReg(0x10,0x0000); LCD_WriteReg(0x11,0x0000); LCD_WriteReg(0x12,0x0000); LCD_WriteReg(0x13,0x0000); delay_ms(20); LCD_WriteReg(0x10,0x17B0); LCD_WriteReg(0x11,0x0137); delay_ms(5); LCD_WriteReg(0x12,0x0139); delay_ms(5); LCD_WriteReg(0x13,0x1d00); LCD_WriteReg(0x29,0x0013); delay_ms(5); LCD_WriteReg(0x20,0x0000); LCD_WriteReg(0x21,0x0000); LCD_WriteReg(0x30,0x0006); LCD_WriteReg(0x31,0x0101); LCD_WriteReg(0x32,0x0003); LCD_WriteReg(0x35,0x0106); LCD_WriteReg(0x36,0x0b02); LCD_WriteReg(0x37,0x0302); LCD_WriteReg(0x38,0x0707); LCD_WriteReg(0x39,0x0007); LCD_WriteReg(0x3C,0x0600); LCD_WriteReg(0x3D,0x020b); LCD_WriteReg(0x50,0x0000); LCD_WriteReg(0x51,0x00EF); LCD_WriteReg(0x52,0x0000); LCD_WriteReg(0x53,0x013F); LCD_WriteReg(0x60,0x2700); LCD_WriteReg(0x61,0x0001); LCD_WriteReg(0x6A,0x0000); LCD_WriteReg(0x80,0x0000); LCD_WriteReg(0x81,0x0000); LCD_WriteReg(0x82,0x0000); LCD_WriteReg(0x83,0x0000); LCD_WriteReg(0x84,0x0000); LCD_WriteReg(0x85,0x0000); LCD_WriteReg(0x90,0x0010); LCD_WriteReg(0x92,0x0000); LCD_WriteReg(0x93,0x0003); LCD_WriteReg(0x95,0x0110); LCD_WriteReg(0x97,0x0000); LCD_WriteReg(0x98,0x0000); LCD_WriteReg(0x03,0x1018); LCD_WriteReg(0x07,0x0173); } else if(lcdid == 0x9325) { LCD_WriteReg(0x00,0x0001); LCD_WriteReg(0x01,0x0100); LCD_WriteReg(0x02,0x0700); LCD_WriteReg(0x03,0x1018); LCD_WriteReg(0x04,0x0000); LCD_WriteReg(0x08,0x0202); LCD_WriteReg(0x09,0x0000); LCD_WriteReg(0x0A,0x0000); LCD_WriteReg(0x0C,0x0000); LCD_WriteReg(0x0D,0x0000); LCD_WriteReg(0x0F,0x0000); LCD_WriteReg(0x10,0x0000); LCD_WriteReg(0x11,0x0000); LCD_WriteReg(0x12,0x0000); LCD_WriteReg(0x13,0x0000); delay_ms(20); LCD_WriteReg(0x10,0x17B0); LCD_WriteReg(0x11,0x0137); delay_ms(5); LCD_WriteReg(0x12,0x0139); delay_ms(5); LCD_WriteReg(0x13,0x1d00); LCD_WriteReg(0x29,0x0013); delay_ms(5); LCD_WriteReg(0x20,0x0000); LCD_WriteReg(0x21,0x0000); LCD_WriteReg(0x30,0x0007); LCD_WriteReg(0x31,0x0302); LCD_WriteReg(0x32,0x0105); LCD_WriteReg(0x35,0x0206); LCD_WriteReg(0x36,0x0808); LCD_WriteReg(0x37,0x0206); LCD_WriteReg(0x38,0x0504); LCD_WriteReg(0x39,0x0007); LCD_WriteReg(0x3C,0x0105); LCD_WriteReg(0x3D,0x0808); LCD_WriteReg(0x50,0x0000); LCD_WriteReg(0x51,0x00EF); LCD_WriteReg(0x52,0x0000); LCD_WriteReg(0x53,0x013F); LCD_WriteReg(0x60,0xA700); LCD_WriteReg(0x61,0x0001); LCD_WriteReg(0x6A,0x0000); LCD_WriteReg(0x80,0x0000); LCD_WriteReg(0x81,0x0000); LCD_WriteReg(0x82,0x0000); LCD_WriteReg(0x83,0x0000); LCD_WriteReg(0x84,0x0000); LCD_WriteReg(0x85,0x0000); LCD_WriteReg(0x90,0x0010); LCD_WriteReg(0x92,0x0000); LCD_WriteReg(0x93,0x0003); LCD_WriteReg(0x95,0x0110); LCD_WriteReg(0x97,0x0000); LCD_WriteReg(0x98,0x0000); LCD_WriteReg(0x03,0x1018); LCD_WriteReg(0x07,0x0133); } else if(lcdid==0x4531) { LCD_WriteReg(0x00,0x0001); LCD_WriteReg(0x10,0x0628); LCD_WriteReg(0x12,0x0006); LCD_WriteReg(0x13,0x0A32); LCD_WriteReg(0x11,0x0040); LCD_WriteReg(0x15,0x0050); LCD_WriteReg(0x12,0x0016); delay_ms(15); LCD_WriteReg(0x10,0x5660); delay_ms(15); LCD_WriteReg(0x13,0x2A4E); LCD_WriteReg(0x01,0x0100); LCD_WriteReg(0x02,0x0300); LCD_WriteReg(0x03,0x1018); LCD_WriteReg(0x08,0x0202); LCD_WriteReg(0x0A,0x0000); LCD_WriteReg(0x30,0x0000); LCD_WriteReg(0x31,0x0402); LCD_WriteReg(0x32,0x0106); LCD_WriteReg(0x33,0x0700); LCD_WriteReg(0x34,0x0104); LCD_WriteReg(0x35,0x0301); LCD_WriteReg(0x36,0x0707); LCD_WriteReg(0x37,0x0305); LCD_WriteReg(0x38,0x0208); LCD_WriteReg(0x39,0x0F0B); delay_ms(15); LCD_WriteReg(0x41,0x0002); LCD_WriteReg(0x60,0x2700); LCD_WriteReg(0x61,0x0001); LCD_WriteReg(0x90,0x0119); LCD_WriteReg(0x92,0x010A); LCD_WriteReg(0x93,0x0004); LCD_WriteReg(0xA0,0x0100); delay_ms(15); delay_ms(15); LCD_WriteReg(0x07,0x0133); delay_ms(15); LCD_WriteReg(0xA0,0x0000); delay_ms(20); } LCD_Clear(BLUE); LCD_Font(&Font16x24); LCD_Mode(4); }
/*=====================================================================================================*/ void R61581_Init( void ) { // Reset LCD_RST = 0; Delay_1ms(15); LCD_RST = 1; Delay_1ms(5); Delay_1ms(50); LCD_WriteReg(0x00, 0x01); Delay_1ms(50); LCD_WriteCmd(0xB0); // {setc, [107], W, 0x000B0} LCD_WriteData(0x00); // {setp, [104], W, 0x00000} LCD_WriteCmd(0xB3); LCD_WriteData(0x02); LCD_WriteData(0x00); LCD_WriteData(0x00); LCD_WriteData(0x00); LCD_WriteCmd(0xB4); LCD_WriteData(0x00); LCD_WriteCmd(0xC0); LCD_WriteData(0x13); // LCD_WriteData(0x3B); // 480 LCD_WriteData(0x00); LCD_WriteData(0x03); // 02 LCD_WriteData(0x00); LCD_WriteData(0x01); LCD_WriteData(0x00); LCD_WriteData(0x43); LCD_WriteCmd(0xC1); LCD_WriteData(0x08); // 08 LCD_WriteData(0x10); // CLOCK//0x12 LCD_WriteData(0x08); LCD_WriteData(0x08); LCD_WriteCmd(0xC4); LCD_WriteData(0x11); LCD_WriteData(0x07); LCD_WriteData(0x03); LCD_WriteData(0x03); // Gamma For 3.5inch LCD_WriteCmd(0xC8); // Gamma setting LCD_WriteData(0x00); LCD_WriteData(0x25); LCD_WriteData(0x21); LCD_WriteData(0x05); LCD_WriteData(0x00); LCD_WriteData(0x0A); LCD_WriteData(0x65); LCD_WriteData(0x25); LCD_WriteData(0x77); LCD_WriteData(0x50); LCD_WriteData(0x0F); LCD_WriteData(0x00); LCD_WriteCmd(0x2A); LCD_WriteData(0x00); LCD_WriteData(0x00); LCD_WriteData(0x01); LCD_WriteData(0x3F); // 320 LCD_WriteCmd(0x2B); LCD_WriteData(0x00); LCD_WriteData(0x00); LCD_WriteData(0x01); LCD_WriteData(0xDF); // 480 LCD_WriteCmd(0x35); LCD_WriteData(0x00); LCD_WriteCmd(0x36); LCD_WriteData(0x31); LCD_WriteCmd(0x3A); LCD_WriteData(0x55); LCD_WriteCmd(0x44); LCD_WriteData(0x00); LCD_WriteData(0x01); LCD_WriteCmd(0x2C); LCD_WriteCmd(0x11); Delay_1ms(150); LCD_WriteCmd(0xD0); LCD_WriteData(0x07); LCD_WriteData(0x07); LCD_WriteData(0x1E); LCD_WriteData(0x03); // LCD_WriteData(0x0703); LCD_WriteCmd(0xD1); LCD_WriteData(0x03); LCD_WriteData(0x52); // VCM LCD_WriteData(0x10); // VDV LCD_WriteCmd(0xD2); LCD_WriteData(0x03); LCD_WriteData(0x24); LCD_WriteCmd(0xB0); // {setc, [107], W, 0x000B0} LCD_WriteData(0x00); // {setp, [104], W, 0x00000} LCD_WriteCmd(0x29); Delay_1ms(10); LCD_WriteReg(0x36, 0x31); LCD_Clear(BLACK); LCD_SetBackLight(BLIGHT_DEFAULT); }
void LCD_Cursor(u16 Xpos, u16 Ypos) { LCD_WriteReg(0x20, Xpos); LCD_WriteReg(0x21, Ypos); }
/******************************************************************************* * Function Name : LCD_WindowModeDisable * Description : Disables LCD Window mode. * Input : None * Output : None * Return : None *******************************************************************************/ void LCD_WindowModeDisable(void) { LCD_SetDisplayWindow(239, 0x13F, 240, 320); LCD_WriteReg(R3, 0x1018); }
/** * @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 */ }