
/**************************************************/		
// I2C power module controller		
/**************************************************/ 

void DisplayOn()
{
  Set_POWER(1,1,1,1);//1.8V ON, 2.8V ON, 5V ON, BL ON
/*
if (memcmp("0x38,0x21,0x1f"))//Check BUFFER: 1 OK, 0 NG
	{ 
   //  Set_TEXT(0, 0, 0x00);//Draw Text: ID
	Set_TEXT(0, 0, 0x01);//Draw Text: "PASS"
	}
	else
	{
     Set_TEXT(0, 0, 0x22);//Draw Text: "fail"
      Delay (10000);
	Set_BOOST(0,0,0,0);
	Set_POWER(0,0,0,0);
	}
*/
/*
//TE
Set_TEXT(3, 0, 0x04);//Draw Text: TEST
DCS_Short_Write_1P(0x35, 0x00);//TE Enable
Delay (5000);

Set_TEXT(3, 0, 0x05);//Draw Text: OFF
DCS_Short_Write_NP(0x34);//TE Disable
Delay (5000);
*/

//Get_HardwareID();
/*
SSD_SEND(0x01,0x35,0x00);//TE 开启
Read_TE(60, 2, 10);
Set_TEXT(3, 0, 0x00);//Draw Text: data
*/
/*
Read_ADC(1.6, 2, 0.1);//read id level ok
Set_TEXT(0, 0, 0x00);
*/
}
void PowerOffSequence()
{
	DCS_Short_Write_NP(0x28);
	Delay(200);
	DCS_Short_Write_NP(0x10);
	Delay(100);
	Set_STANDBY();//Video transfer stop
	Delay(50);

  //  Wait_Key(500); //Delay 100ms -> Wait_Key();


	Set_RESET(1,0);//MIPI RESET 1, LCD RESET 0
	Delay(50);
	Set_RESET(0,0);//MIPI RESET 0, LCD RESET 0
	Delay(50);

	Set_POWER(1,1,0,1);//1.8V ON, 2.8V ON, 5V OFF, BL ON
	Delay(50);

	Set_BOOST(5.0, 5.0, 0x81, 50);//VDD, VEE, OFF:VDD->VEE, 10ms
	Delay(50);

	Set_POWER(1,0,0,1);//1.8V ON, 2.8V OFF, 5V OFF, BL ON
	Delay(100);
	Set_POWER(0,0,0,0);//1.8V OFF, 2.8V OFF, 5V OFF, BL OFF

}


void main()
{

	
	Set_POWER(1,0,0,0);//1.8V ON, 2.8V OFF, 5V OFF, BL OFF
	Delay(200);

	Set_POWER(1,1,1,0);//1.8V ON, 2.8V ON, 5V ON, BL OFF
	Delay(200);

	Set_BOOST(5.00,5.00,0x01,50);
	Delay(50);

	Set_RESET(1,0);//MIPI RESET 1, LCD RESET 0
	Delay(100);
	Set_RESET(1,1);//MIPI RESET 1, LCD RESET 1
	Delay(200);
		
	
	SSD_LANE(1,0);//1,0

      Delay(100);





//Tips:	Set_BOOST([0], [1], [2], [3])
	//		[0]	VSP
	//		[1]	VSN
	//		[2]	Power On:	
	//          0x01 VSP On -> Delay -> VSN On
	//					0x02 VSN On -> Delay -> VSP On
	//					0x03 VSP VSN一起上电
	//Power Off:0x81 VDD Off -> Delay -> VEE Off
	//					0x82 VEE Off -> Delay -> VDD Off
	//					0x83 VSP VSN一起下电
	//		[3]	Delay: Unit 200uS

	/*************************************************/
	//SSD2828 initial setting - LP mode
	/*************************************************/

//初始化填写说明
//SSD_SEND(0x01,驱动命令,参数1,参数2,参数3,...,最多256个参数);//DCS长包填写
//SSD_SEND(0x11,驱动命令,参数1,参数2,参数3,...,最多256个参数);//GEN长包填写
//SSD_SEND(0x00,驱动命令,参数);//DCS短包填写
//SSD_SEND(0x10,驱动命令,参数);//GEN短包填写

	//*************************************************//		
	//LCDD (Peripheral) Setting	
     //*************************************************// 
	
       Delay(800);

		SSD_SEND(0X10,0xF0,0xC3);

		SSD_SEND(0X10,0xF0,0x96);

		SSD_SEND(0X10,0xF0,0xA5);

		SSD_SEND(0X11,0xC1,0x77,0x07,0xCF,0x17);

		SSD_SEND(0X11,0xC2,0x77,0x07,0xCF,0x17);

		SSD_SEND(0X11,0xC3,0x22,0x02,0x22,0x04);

		SSD_SEND(0X11,0xC4,0x22,0x02,0x22,0x04);

		SSD_SEND(0X10,0xC5,0xBa);//b7

		SSD_SEND(0X10,0xD6,0x00);

		SSD_SEND(0X10,0xD7,0x00);

		SSD_SEND(0X11,0xE0,0x87,0x0A,0x0E,0x09,0x08,0x05,0x2E,0x33,0x44,0x28,0x14,0x14,0x29,0x2D);

		SSD_SEND(0X11,0xE1,0x87,0x09,0x0D,0x08,0x08,0x25,0x2D,0x33,0x44,0x37,0x14,0x13,0x28,0x2D);

		SSD_SEND(0X11,0xE5,0x00,0xF5,0x00,0x22,0x22,0x25,0x10,0x44,0x44,0x44,0x44,0x44,0x44,0x44);

		SSD_SEND(0X11,0xE6,0x00,0xF5,0x00,0x22,0x22,0x25,0x10,0x22,0x22,0x22,0x22,0x22,0x22,0x22);

		SSD_SEND(0X11,0xEC,0x00,0x55,0x00,0x00,0x00,0x88);

		SSD_SEND(0X10,0x36,0x0C);

		SSD_SEND(0X10,0x3A,0x07);

		SSD_SEND(0X10,0xB2,0x10);

		SSD_SEND(0X10,0xB3,0x01);

		SSD_SEND(0X10,0xB4,0x01);

		SSD_SEND(0X11,0xB5,0x00,0x08,0x00,0x08);

		SSD_SEND(0X11,0xB6,0xEf,0x18);

		SSD_SEND(0X11,0xA4,0xC0,0x6B);

		SSD_SEND(0X11,0xA5,0x00,0x00,0x00,0x00,0x00,0x15,0x2A,0x8A,0x02);

		SSD_SEND(0X11,0xA6,0x00,0x00,0x00,0x00,0x00,0x15,0x2A,0x8A,0x02);

		SSD_SEND(0X11,0xBA,0x0A,0x5A,0x23,0x10,0x22,0x01,0x00);

		SSD_SEND(0X11,0xBB,0x00,0x25,0x00,0x28,0x82,0x07,0x18,0x00);

		SSD_SEND(0X11,0xBC,0x00,0x21,0x00,0x28,0x82,0x07,0x18,0x00);

		SSD_SEND(0X11,0xBD,0x58,0x67,0x76,0x85,0x43,0x34,0x21,0x12,0xFF,0xFF,0x0F);

		SSD_SEND(0X10,0x35,0x00); 
		
		SSD_SEND(0X10,0x21,0x00); 

		DCS_Short_Write_NP(0x11);
		Delay(800);

		DCS_Short_Write_NP(0x29);
		Delay(150);





    SSD_MODE(0,1);



//Tips:	SSD_MODE([0], [1])
	//		[0]	Video Mode:	0 - Non burst mode with sync pulses
	//						1 - Non burst mode with sync events
	//						2 - Burst mode
	//						3 - Command mode
	//		[1]	HS Mode:		0 - No operation
	//						1 - Enable HS mode



}





