⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd.c

📁 手机开发 MTK平台 LCD屏幕驱动源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	LCD_DataWrite_ST7787(0x00);		// [-,-,-,-,-,STEP4BP_SEL(3:0)=0]		

	Delay(80);

	//LCD_CtrlWrite_ST7787(0xF2);		// 
	//LCD_DataWrite_ST7787(0x80);
	//Delay(50);

	LCD_CtrlWrite_ST7787(0xF4);		// Setting ARBIT_2
	LCD_DataWrite_ST7787(0xFF);		// [arb2_wr_sel(3:0)or men_scrd_sel(2:0),arb2_rd_sel(3:0)or men_wr_sel(2:0)]
	LCD_DataWrite_ST7787(0x3F);		// [ramwrn_sel,arb0_sel,arb2_st_sel(1:0),arb2_wrgap_sel(3:0)]

	LCD_CtrlWrite_ST7787(0xF5);		// PARAtin DISP
	LCD_DataWrite_ST7787(0x10);		// [PDM1,PDM0,oe_del_sel1,oe_del_sel0,eqpw1,eqpw0,-,-]	

	LCD_CtrlWrite_ST7787(0xFB);		// Vcom & Source EQ setting (1 PARAMETER)
	LCD_DataWrite_ST7787(0x7F);		// Vcom_porsel,Vcom_mul_mode,SV_mode,Vcom_mid2_sel(1:0),Vcom_mid1_sel(1:0)]


	LCD_CtrlWrite_ST7787(0xC5);		// VMCTR1: Setting VcomH(MTP block)
	LCD_DataWrite_ST7787(0xce);		// VMH_R: VCOMH(6:0) ,default:28); , 
	LCD_DataWrite_ST7787(0x25);		// VMH_COLOR8M(6:0): VCOMH ,default:28H
	Delay(80);

	LCD_CtrlWrite_ST7787(0xC6);		// VMCTR2: Setting VcomAC
	LCD_DataWrite_ST7787(0x20);		// VCOMAC voltage control 14H=5V , 06H=4.3V 
	LCD_DataWrite_ST7787(0x00);		// VCOMAC voltage control in idle mode :default: 0
	Delay(80);


	LCD_CtrlWrite_ST7787(0xC0);		// PWCTR1: Setting GVDD & Vci1 
	LCD_DataWrite_ST7787(0x00);		// VRH[4:0]==>GVDD
	



	

	//LCD_CtrlWrite_ST7787(0x20);		// INVON:DISPLAY INVERSE	
		
	LCD_CtrlWrite_ST7787(0x3A);		// Memory data access control 
	LCD_DataWrite_ST7787(0x05);

	Delay(50);

	LCD_CtrlWrite_ST7787(0x2A);		// COLMOD		
	LCD_DataWrite_ST7787(0x00);		// 65K	
	LCD_DataWrite_ST7787(0x00);
	LCD_DataWrite_ST7787(0x00);
	LCD_DataWrite_ST7787(0xEF);
	Delay(50);
	LCD_CtrlWrite_ST7787(0x2B);		// COLMOD		
	LCD_DataWrite_ST7787(0x00);		// 65K	
	LCD_DataWrite_ST7787(0x00);
	LCD_DataWrite_ST7787(0x01);
	LCD_DataWrite_ST7787(0x3F);
	Delay(50);	

	
	//LCD_CtrlWrite_ST7787(0x36);		// Memory data access control 
	//	LCD_DataWrite_ST7787(0x00);

	LCD_CtrlWrite_ST7787(0x29);		// DISPLAY ON

	LCD_CtrlWrite_ST7787(0xE0);		// COLMOD		
	LCD_DataWrite_ST7787(0x03);		// 65K	
	LCD_DataWrite_ST7787(0x03);
	LCD_DataWrite_ST7787(0x18);
	LCD_DataWrite_ST7787(0x1C);
	LCD_DataWrite_ST7787(0x19);		// 65K	
	LCD_DataWrite_ST7787(0x14);
	LCD_DataWrite_ST7787(0x10);
	LCD_DataWrite_ST7787(0x10);
	LCD_DataWrite_ST7787(0x18);		// 65K	
	LCD_DataWrite_ST7787(0x00);
	LCD_DataWrite_ST7787(0x0F);
	LCD_DataWrite_ST7787(0x03);
	LCD_DataWrite_ST7787(0x07);		// 65K	

	LCD_CtrlWrite_ST7787(0xE1);		// COLMOD		
	LCD_DataWrite_ST7787(0x08);		// 65K	
	LCD_DataWrite_ST7787(0x07);
	LCD_DataWrite_ST7787(0x1D);
	LCD_DataWrite_ST7787(0x1F);
	LCD_DataWrite_ST7787(0x1E);		// 65K	
	LCD_DataWrite_ST7787(0x19);
	LCD_DataWrite_ST7787(0x15);
	LCD_DataWrite_ST7787(0x14);
	LCD_DataWrite_ST7787(0x12);		// 65K	
	LCD_DataWrite_ST7787(0x05);
	LCD_DataWrite_ST7787(0x0F);
	LCD_DataWrite_ST7787(0x03);
	LCD_DataWrite_ST7787(0x03);		// 65K	
	
	
	
	
	Delay(20);


	LCD_ClearAll_ST7787(0x0000);
	
#elif (defined(tianma))
	
	LCD_CtrlWrite_ST7787(0x11); 		// SLPOUT:Sleep out & booster on
	Delay(100);
	Delay(100);

	LCD_CtrlWrite_ST7787(0xB1);	   	// FRMCTR1:
	LCD_DataWrite_ST7787(0x30);	   
	LCD_DataWrite_ST7787(0x02);	   
	LCD_DataWrite_ST7787(0x02);	   	

	LCD_CtrlWrite_ST7787(0xBC);		// ???	
	Delay(50);
    Delay(100);
	
	LCD_CtrlWrite_ST7787(0xC2);		// PWCTR3:( in normal)
	LCD_DataWrite_ST7787(0x03);		
	LCD_DataWrite_ST7787(0xe6);		
	LCD_DataWrite_ST7787(0x86);					  
	LCD_DataWrite_ST7787(0x00);		
	LCD_DataWrite_ST7787(0x00);		
	//Delay(80);

	LCD_CtrlWrite_ST7787(0xC3);		// PWCTR4:(in Idle mode ) 
	LCD_DataWrite_ST7787(0x01);		// Amount of Current in Operational Amplifier = [APB(2:0)=1]
	LCD_DataWrite_ST7787(0x22);		// [STEP1B_SEL(4:0)=0,-,STEP2B_SEL(3:0)=0]
	LCD_DataWrite_ST7787(0x01);		// [-,-,-,-,-,STEP4B_SEL(3:0)=0]
	LCD_DataWrite_ST7787(0x00);		// [-,STEP1BP_SEL(3:0)=0,-,STEP2BP_SEL(3:0)=0]
	LCD_DataWrite_ST7787(0x00);		// [-,-,-,-,-,STEP4BP_SEL(3:0)=0]		

	Delay(100);

	//LCD_CtrlWrite_ST7787(0xF2);		// 
	//LCD_DataWrite_ST7787(0x80);

	LCD_CtrlWrite_ST7787(0xF4);		// Setting ARBIT_2
	LCD_DataWrite_ST7787(0xFF);		// [arb2_wr_sel(3:0)or men_scrd_sel(2:0),arb2_rd_sel(3:0)or men_wr_sel(2:0)]
	LCD_DataWrite_ST7787(0x3F);		// [ramwrn_sel,arb0_sel,arb2_st_sel(1:0),arb2_wrgap_sel(3:0)]

	LCD_CtrlWrite_ST7787(0xF5);		// PARAtin DISP
	LCD_DataWrite_ST7787(0x10);		// [PDM1,PDM0,oe_del_sel1,oe_del_sel0,eqpw1,eqpw0,-,-]	

	LCD_CtrlWrite_ST7787(0xFB);		// Vcom & Source EQ setting (1 PARAMETER)
	LCD_DataWrite_ST7787(0x7F);		// Vcom_porsel,Vcom_mul_mode,SV_mode,Vcom_mid2_sel(1:0),Vcom_mid1_sel(1:0)]


	LCD_CtrlWrite_ST7787(0xC5);		// VMCTR1: Setting VcomH(MTP block)
	LCD_DataWrite_ST7787(0xc7);		// VMH_R: VCOMH(6:0) ,default:28); , 
	LCD_DataWrite_ST7787(0x1A);		// VMH_COLOR8M(6:0): VCOMH ,default:28H
	Delay(80);

	LCD_CtrlWrite_ST7787(0xC6);		// VMCTR2: Setting VcomAC
	LCD_DataWrite_ST7787(0x24);		// VCOMAC voltage control 14H=5V , 06H=4.3V 
	LCD_DataWrite_ST7787(0x00);		// VCOMAC voltage control in idle mode :default: 0
	//Delay(80);


	LCD_CtrlWrite_ST7787(0xC0);		// PWCTR1: Setting GVDD & Vci1 
	LCD_DataWrite_ST7787(0x00);		// VRH[4:0]==>GVDD
	Delay(80);

	LCD_CtrlWrite_ST7787(0xB6);		// DISSET5: DISPLAY FUNCTION SET
	LCD_DataWrite_ST7787(0x02);		 		
	LCD_DataWrite_ST7787(0x04);		 	

	//LCD_CtrlWrite_ST7787(0xBC);		// INVON:DISPLAY INVERSE	

	LCD_CtrlWrite_ST7787(0x2A);		// COLMOD		
	LCD_DataWrite_ST7787(0x00);		// 65K	
	LCD_DataWrite_ST7787(0x00);
	LCD_DataWrite_ST7787(0x00);
	LCD_DataWrite_ST7787(0xEF);
	//Delay(50);	

	LCD_CtrlWrite_ST7787(0x20);
		
	LCD_CtrlWrite_ST7787(0x3A);		// Memory data access control 
	LCD_DataWrite_ST7787(0x05);

	Delay(50);
	LCD_CtrlWrite_ST7787(0x2B);		// COLMOD		
	LCD_DataWrite_ST7787(0x00);		// 65K	
	LCD_DataWrite_ST7787(0x00);
	LCD_DataWrite_ST7787(0x01);
	LCD_DataWrite_ST7787(0x3F);
	//Delay(100);	

	
	LCD_CtrlWrite_ST7787(0x36);		// Memory data access control 
		LCD_DataWrite_ST7787(0x00);

	
	
	Delay(20);

	//LCD_CtrlWrite_ST7787(0xB4);		// COLMOD		
	//LCD_DataWrite_ST7787(0x04);		// 65K	
	
	//Delay(10);	

	LCD_CtrlWrite_ST7787(0x29);		// DISPLAY ON
	
	Delay(20);

	LCD_ClearAll_ST7787(0x0000);


	
#elif (defined(daonuo))
	 CLEAR_LCD_CTRL_RESET_PIN;
	    LCD_Delay(0x1000);
	    LCD_Delay(0x1000);

	    SET_LCD_CTRL_RESET_PIN;
	    LCD_Delay(0x1000);

	    LCD_Delay(0x1000);
	
	   // Delay(10);
		LCD_CtrlWrite_ST7787(0xE5); LCD_DataWrite_ST7787(0x8000);			 // Set the internal vcore voltage
		
		LCD_CtrlWrite_ST7787(0x00); LCD_DataWrite_ST7787(0x0001);			 // Start internal OSC.
		Delay(100);
		Delay(50);
		LCD_CtrlWrite_ST7787(0x01); LCD_DataWrite_ST7787(0x0100);			  // set SS and SM bit
		//LCD_CtrlWrite_ST7787(0x60); LCD_DataWrite_ST7787(0x2700);
		LCD_CtrlWrite_ST7787(0x02); LCD_DataWrite_ST7787(0x0700);			 // set 1 line inversion
		LCD_CtrlWrite_ST7787(0x03); LCD_DataWrite_ST7787(0x1030);			 // set GRAM write direction and BGR=1.
		LCD_CtrlWrite_ST7787(0x04); LCD_DataWrite_ST7787(0x0000);			  // Resize register
		LCD_CtrlWrite_ST7787(0x08); LCD_DataWrite_ST7787(0x0202);			  // set the back porch and front porch
		LCD_CtrlWrite_ST7787(0x09); LCD_DataWrite_ST7787(0x0000);			  // set non-display area refresh cycle ISC[3:0]
		//LCD_CtrlWrite_ST7787(0x0A); LCD_DataWrite_ST7787(0x0000);			  // FMARK function
		//LCD_CtrlWrite_ST7787(0x0C); LCD_DataWrite_ST7787(0x0000);			   // RGB interface setting
		//LCD_CtrlWrite_ST7787(0x0D); LCD_DataWrite_ST7787(0x0000);			   // Frame marker Position
		//LCD_CtrlWrite_ST7787(0x0F); LCD_DataWrite_ST7787(0x0000);			   // RGB interface polarity
	//*************Power On sequence ****************//
	
		LCD_CtrlWrite_ST7787(0x10); LCD_DataWrite_ST7787(0x0000);			   // SAP, BT[3:0], AP, DSTB, SLP, STB
		//Delay(20);
		LCD_CtrlWrite_ST7787(0x11); LCD_DataWrite_ST7787(0x0007);				//0x000   DC1[2:0], DC0[2:0], VC[2:0]
		LCD_CtrlWrite_ST7787(0x12); LCD_DataWrite_ST7787(0x0000);				// VREG1OUT voltage
		LCD_CtrlWrite_ST7787(0x13); LCD_DataWrite_ST7787(0x0000);				// VDV[4:0] for VCOM amplitude
		Delay(200);															// Dis-charge capacitor power voltage
		LCD_CtrlWrite_ST7787(0x10); LCD_DataWrite_ST7787(0x17B0);				// SAP, BT[3:0], AP, DSTB, SLP, STB
		LCD_CtrlWrite_ST7787(0x11); LCD_DataWrite_ST7787(0x0001);				 //0x0137	DC1[2:0], DC0[2:0], VC[2:0]0037
		Delay(300);															 // Delay 50ms
		LCD_CtrlWrite_ST7787(0x12); LCD_DataWrite_ST7787(0x013C);				 //0x0139	VREG1OUT voltage//013a
		Delay(300);															// Delay 50ms
		LCD_CtrlWrite_ST7787(0x13); LCD_DataWrite_ST7787(0x1500);				// 0x1700  VDV[4:0] for VCOM amplitude	CPT2.8 0x16-->CPT2.4 0x1a00//1600
		LCD_CtrlWrite_ST7787(0x29); LCD_DataWrite_ST7787(0x0007);				 //0x000C  VCM[4:0] for VCOMH
		Delay(300);															
		LCD_CtrlWrite_ST7787(0x20); LCD_DataWrite_ST7787(0x0000);				  // GRAM horizontal Address
		LCD_CtrlWrite_ST7787(0x21); LCD_DataWrite_ST7787(0x0000);				  // GRAM Vertical Address
	// ----------- Adjust the Gamma Curve ----------//
		//LCD_CtrlWrite_ST7787(0x30); LCD_DataWrite_ST7787(0x0000);				//0000//0504	 0x0000 
		//LCD_CtrlWrite_ST7787(0x31); LCD_DataWrite_ST7787(0x0505);				//0505		0x0507
		//LCD_CtrlWrite_ST7787(0x32); LCD_DataWrite_ST7787(0x0004);			   //0004	   0x0104
		//LCD_CtrlWrite_ST7787(0x35); LCD_DataWrite_ST7787(0x0006);			   //0006	  0x0105
		//LCD_CtrlWrite_ST7787(0x36); LCD_DataWrite_ST7787(0x0707);			   //0707	 0x404
		//LCD_CtrlWrite_ST7787(0x37); LCD_DataWrite_ST7787(0x0105);			   //0105  0x0603
		//LCD_CtrlWrite_ST7787(0x38); LCD_DataWrite_ST7787(0x0002);			  //0002   0x0004
		//LCD_CtrlWrite_ST7787(0x39); LCD_DataWrite_ST7787(0x0707);			 //0707   0x0007
		//LCD_CtrlWrite_ST7787(0x3C); LCD_DataWrite_ST7787(0x0704);			  //0704  0x0501
		//LCD_CtrlWrite_ST7787(0x3D); LCD_DataWrite_ST7787(0x0807);			 //0807   0x0404
	//------------------ Set GRAM area ---------------//
		LCD_CtrlWrite_ST7787(0x50); LCD_DataWrite_ST7787(0x0000);			   // Horizontal GRAM Start Address
		LCD_CtrlWrite_ST7787(0x51); LCD_DataWrite_ST7787(0x00EF);			   // Horizontal GRAM End Address
		LCD_CtrlWrite_ST7787(0x52); LCD_DataWrite_ST7787(0x0000);				 // Vertical GRAM Start Address
		LCD_CtrlWrite_ST7787(0x53); LCD_DataWrite_ST7787(0x013F);				// Vertical GRAM Start Address
		LCD_CtrlWrite_ST7787(0x60); LCD_DataWrite_ST7787(0x2700);			   // Gate Scan Line
		LCD_CtrlWrite_ST7787(0x61); LCD_DataWrite_ST7787(0x0001);			   // NDL,VLE, REV
		LCD_CtrlWrite_ST7787(0x6A); LCD_DataWrite_ST7787(0x0000);			   // set scrolling line
	//-------------- Partial Display Control ---------//
		//LCD_CtrlWrite_ST7787(0x80); LCD_DataWrite_ST7787(0x0000);
		//LCD_CtrlWrite_ST7787(0x81); LCD_DataWrite_ST7787(0x0000);
		//LCD_CtrlWrite_ST7787(0x82); LCD_DataWrite_ST7787(0x0000);
		//LCD_CtrlWrite_ST7787(0x83); LCD_DataWrite_ST7787(0x0000);
		//LCD_CtrlWrite_ST7787(0x84); LCD_DataWrite_ST7787(0x0000);
		//LCD_CtrlWrite_ST7787(0x85); LCD_DataWrite_ST7787(0x0000);
	//-------------- Panel Control -------------------//
	
		LCD_CtrlWrite_ST7787(0x90); LCD_DataWrite_ST7787(0x0010);
		LCD_CtrlWrite_ST7787(0x92); LCD_DataWrite_ST7787(0x0000);
		LCD_CtrlWrite_ST7787(0x93); LCD_DataWrite_ST7787(0x0003);

		LCD_CtrlWrite_ST7787(0x30); LCD_DataWrite_ST7787(0x0007);				//0000//0504	 0x0000 
		LCD_CtrlWrite_ST7787(0x31); LCD_DataWrite_ST7787(0x0403);				//0505		0x0507
		LCD_CtrlWrite_ST7787(0x32); LCD_DataWrite_ST7787(0x0404);			   //0004	   0x0104
		LCD_CtrlWrite_ST7787(0x35); LCD_DataWrite_ST7787(0x0002);			   //0006	  0x0105
		LCD_CtrlWrite_ST7787(0x36); LCD_DataWrite_ST7787(0x0707);			   //0707	 0x404
		LCD_CtrlWrite_ST7787(0x37); LCD_DataWrite_ST7787(0x0606);			   //0105  0x0603
		LCD_CtrlWrite_ST7787(0x38); LCD_DataWrite_ST7787(0x0106);			  //0002   0x0004
		LCD_CtrlWrite_ST7787(0x39); LCD_DataWrite_ST7787(0x0007);			 //0707   0x0007
		LCD_CtrlWrite_ST7787(0x3C); LCD_DataWrite_ST7787(0x0700);			  //0704  0x0501
		LCD_CtrlWrite_ST7787(0x3D); LCD_DataWrite_ST7787(0x0707);			 //0807   0x0404
		
		LCD_CtrlWrite_ST7787(0x07); LCD_DataWrite_ST7787(0x0021);
		Delay(200);
		LCD_CtrlWrite_ST7787(0x07); LCD_DataWrite_ST7787(0x0031);
		Delay(200);
		LCD_CtrlWrite_ST7787(0x07); LCD_DataWrite_ST7787(0x0173);
		//LCD_CtrlWrite_ST7787(0x07); LCD_DataWrite_ST7787(0x0173);
		Delay(200);
	
		LCD_CtrlWrite_ST7787(0x22);
#elif (defined(ili9320))
	CLEAR_LCD_CTRL_RESET_PIN;
    LCD_Delay(0x1000);
	LCD_Delay(0x1000);
	
	SET_LCD_CTRL_RESET_PIN;
	LCD_Delay(0x1000);
	
	LCD_Delay(0x1000);

    Delay(20);
    LCD_CtrlWrite_ST7787(0xE5);	LCD_DataWrite_ST7787(0x8000);	         // Set the internal vcore voltage
    //Delay(50);
    LCD_CtrlWrite_ST7787(0x00);	LCD_DataWrite_ST7787(0x0001);            // Start internal OSC.
    Delay(60);
    LCD_CtrlWrite_ST7787(0x01);	LCD_DataWrite_ST7787(0x0100);             // set SS and SM bit
   // LCD_CtrlWrite_ST7787(0x60);	LCD_DataWrite_ST7787(0x2700);
    LCD_CtrlWrite_ST7787(0x02);	LCD_DataWrite_ST7787(0x0700);            // set 1 line inversion
   // LCD_CtrlWrite_ST7787(0x03);	LCD_DataWrite_ST7787(0x1030);            // set GRAM write direction and BGR=1.
   LCD_CtrlWrite_ST7787(0x03);	LCD_DataWrite_ST7787(0x1030);    
    LCD_CtrlWrite_ST7787(0x04);	LCD_DataWrite_ST7787(0x0000);             // Resize register
    LCD_CtrlWrite_ST7787(0x08);	LCD_DataWrite_ST7787(0x0202);             // set the back porch and front porch
    LCD_CtrlWrite_ST7787(0x09);	LCD_DataWrite_ST7787(0x0000);             // set non-display area refresh cycle ISC[3:0]
    LCD_CtrlWrite_ST7787(0x0A);	LCD_DataWrite_ST7787(0x0000);             // FMARK function
    LCD_CtrlWrite_ST7787(0x0C);	LCD_DataWrite_ST7787(0x0000);              // RGB interface setting
    LCD_CtrlWrite_ST7787(0x0D);	LCD_DataWrite_ST7787(0x0000);              // Frame marker Position
    LCD_CtrlWrite_ST7787(0x0F);	LCD_DataWrite_ST7787(0x0000);              // RGB interface polarity
//*************Power On sequence ****************//

    LCD_CtrlWrite_ST7787(0x10);	LCD_DataWrite_ST7787(0x0000);              // SAP, BT[3:0], AP, DSTB, SLP, STB
   // Delay(20);
    LCD_CtrlWrite_ST7787(0x11);	LCD_DataWrite_ST7787(0x0007);               //0x000   DC1[2:0], DC0[2:0], VC[2:0]
    LCD_CtrlWrite_ST7787(0x12);	LCD_DataWrite_ST7787(0x0000);               // VREG1OUT voltage
    LCD_CtrlWrite_ST7787(0x13);	LCD_DataWrite_ST7787(0x0000);               // VDV[4:0] for VCOM amplitude
    Delay(100);                                                          // Dis-charge capacitor power voltage
    LCD_CtrlWrite_ST7787(0x10);	LCD_DataWrite_ST7787(0x17B0);               // SAP, BT[3:0], AP, DSTB, SLP, STB
    LCD_CtrlWrite_ST7787(0x11);	LCD_DataWrite_ST7787(0x0137);                //0x0137   DC1[2:0], DC0[2:0], VC[2:0]0037
    Delay(60);                                                           // Delay 50ms
    LCD_CtrlWrite_ST7787(0x12);	LCD_DataWrite_ST7787(0x013C);                //0x0139   VREG1OUT voltage//013a
    Delay(60);                                                          // Delay 50ms
    LCD_CtrlWrite_ST7787(0x13);	LCD_DataWrite_ST7787(0x1800);               // 0x1700  VDV[4:0] for VCOM amplitude  CPT2.8 0x16-->CPT2.4 0x1a00//1600
    LCD_CtrlWrite_ST7787(0x29);	LCD_DataWrite_ST7787(0x0017);                //0x000C  VCM[4:0] for VCOMH
    Delay(60);                                                

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -