//--------------------------------------------------


/**************************************************/		
// I2C power module controller		
/**************************************************/ 

void DisplayOn()
{
  Set_POWER(1,1,1,1);//1.8V ON, 2.8V ON, 5V ON, BL ON
}
/*
void SystemThread()
{
	Delay(5000);//5000x20us=1.2s

	DCS_Short_Read_NP(0x0a, 1, BUFFER+0);
	if(!memcmp("0x9c")) 
	{
		Delay(1000);
  		Write_LCD_REG(0xFFFC, 0x2003);//Hot start
  		Delay(350);
  		Write_LCD_REG(0xFFFC, 0x2103);
	}

	Read_UART_DAT(0xa0,BUFFER+0);//读回电流表报警状态
	if(memcmp("0x44"))//返回44到Buffer[0] 则电流已经超标
	{
		Delay(1000);
 		Write_LCD_REG(0xFFFC, 0x2003);//Hot start
		Delay(350);
 		Write_LCD_REG(0xFFFC, 0x2103);
	}
}*/

void PowerOffSequence()
{
	Generic_Short_Write_NP(0x28);
	Delay(200);
	Generic_Short_Write_NP(0x10);
	Delay(100);
	Set_STANDBY();//Video transfer stop
	Delay(50);

	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.00, 5.00, 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()
{

	
	
	//Delay(100);
	Set_POWER(1,0,0,0);//1.8V ON, 2.8V OFF, 5V OFF, BL OFF
	Delay(100);

	Set_POWER(1,1,1,0);//1.8V ON, 2.8V ON, 5V ON, BL OFF
	Delay(500);

	Set_BOOST(5.00,5.00,0x01,100);
	Delay(100);


	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(2,0);
		
	
	/**************************************************/		
	//LCDD (Peripheral) Setting		
      /**************************************************/	

/*
	SSD_SEND(0x01,0xF0,0x55,0xAA,0x52,0x08,0x00);
	SSD_SEND(0x01,0xF6,0x5A,0x87);

	SSD_SEND(0x01,0xC1,0x3F);
	SSD_SEND(0x01,0xC2,0x0E);
	SSD_SEND(0x01,0xC6,0xF8);
	SSD_SEND(0x01,0xC9,0x10);
	SSD_SEND(0x01,0xCD,0x25);



	SSD_SEND(0x01,0xFA,0x08,0x08,0x08);//	WriteData (0x04);
	SSD_SEND(0x01,0xF8,0x8A);
    SSD_SEND(0x01,0x71,0x48);
	SSD_SEND(0x01,0x72,0x48);
	SSD_SEND(0x01,0x73,0x00,0x44);

	SSD_SEND(0x01,0x97,0xee);//dd
	SSD_SEND(0x01,0x83,0x93);
	SSD_SEND(0x01,0xA3,0x22);
	SSD_SEND(0x01,0xFD,0x28,0x3C,0x00);
    SSD_SEND(0x01,0xAC,0x65);
	SSD_SEND(0x01,0xA7,0x47);
	SSD_SEND(0x01,0xA0,0xDD);	//0xee
	SSD_SEND(0x01,0x9A,0xC0);//80
	SSD_SEND(0x01,0x9B,0x40);//58
	SSD_SEND(0x01,0x82,0x3E,0x3E);//36

	SSD_SEND(0x01,0xB1,0x04);//10 04

	SSD_SEND(0x01,0x7A,0x13,0x1A);
	SSD_SEND(0x01,0x7B,0x13,0x1A);

	//SSD_SEND(0x01,0xB0,0x80,0x01,0x08,0x14,0x04);
    SSD_SEND(0x01,0xB0,0x80,0x04,0x08,0x14,0x04);
	SSD_SEND(0x01,0x6D,0x00,0x1F,0x19,0x1A,0x10,0x0E,0x0C,0x0A,0x02,0x08,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x07,0x01,0x09,0x0B,0x0D,0x0F,0x1A,0x19,0x1F,0x00);
	SSD_SEND(0x01,0x64,0x28,0x04,0x02,0x7C,0x03,0x03,0x28,0x03,0x02,0x7D,0x03,0x03,0x7A,0x7A,0x7A,0x7A);
	SSD_SEND(0x01,0x65,0x28,0x02,0x02,0x7E,0x03,0x03,0x28,0x01,0x02,0x7F,0x03,0x03,0x7A,0x7A,0x7A,0x7A);
	SSD_SEND(0x01,0x66,0x28,0x00,0x02,0x80,0x03,0x03,0x20,0x01,0x02,0x81,0x03,0x03,0x7A,0x7A,0x7A,0x7A);

	SSD_SEND(0x01,0x67,0x20,0x02,0x02,0x82,0x03,0x03,0x20,0x03,0x02,0x83,0x03,0x03,0x7A,0x7A,0x7A,0x7A);
	SSD_SEND(0x01,0x68,0x77,0x08,0x06,0x08,0x05,0x7A,0x7A,0x08,0x06,0x08,0x05,0x7A,0x7A);
	SSD_SEND(0x01,0x60,0x28,0x06,0x7A,0x7A,0x28,0x05,0x7A,0x7A);

	SSD_SEND(0x01,0x63,0x22,0x7E,0x7A,0x7A,0x22,0x7F,0x7A,0x7A);

	SSD_SEND(0x01,0x69,0x14,0x22,0x14,0x22,0x14,0x22,0x08);	
	SSD_SEND(0x01,0x6B,0x07);


	SSD_SEND(0x01,0xD1,0x00,0x00,0x00,0x80,0x00,0xBF,0x00,0xF8,0x01,0x20,0x01,0x4D,0x01,0x68,0x01,0x88,0x01,0xB8,0x01,0xF0,0x02,0x28,0x02,0x7D,0x02,0xB8,0x02,0xBA,0x03,0x00,0x03,0x4D,0x03,0x6A,0x03,0x88,0x03,0xA0,0x03,0xB5,0x03,0xC8,0x03,0xD0,0x03,0xE8,0x03,0xF0,0x03,0xF8,0x03,0xFF);
	SSD_SEND(0x01,0xD2,0x00,0x00,0x00,0x80,0x00,0xBF,0x00,0xF8,0x01,0x20,0x01,0x4D,0x01,0x68,0x01,0x88,0x01,0xB8,0x01,0xF0,0x02,0x28,0x02,0x7D,0x02,0xB8,0x02,0xBA,0x03,0x00,0x03,0x4D,0x03,0x6A,0x03,0x88,0x03,0xA0,0x03,0xB5,0x03,0xC8,0x03,0xD0,0x03,0xE8,0x03,0xF0,0x03,0xF8,0x03,0xFF);

	SSD_SEND(0x01,0xD3,0x00,0x00,0x00,0x80,0x00,0xBF,0x00,0xF8,0x01,0x20,0x01,0x4D,0x01,0x68,0x01,0x88,0x01,0xB8,0x01,0xF0,0x02,0x28,0x02,0x7D,0x02,0xB8,0x02,0xBA,0x03,0x00,0x03,0x4D,0x03,0x6A,0x03,0x88,0x03,0xA0,0x03,0xB5,0x03,0xC8,0x03,0xD0,0x03,0xE8,0x03,0xF0,0x03,0xF8,0x03,0xFF);

	SSD_SEND(0x01,0xD4,0x00,0x00,0x00,0x80,0x00,0xBF,0x00,0xF8,0x01,0x20,0x01,0x4D,0x01,0x68,0x01,0x88,0x01,0xB8,0x01,0xF0,0x02,0x28,0x02,0x7D,0x02,0xB8,0x02,0xBA,0x03,0x00,0x03,0x4D,0x03,0x6A,0x03,0x88,0x03,0xA0,0x03,0xB5,0x03,0xC8,0x03,0xD0,0x03,0xE8,0x03,0xF0,0x03,0xF8,0x03,0xFF);

	SSD_SEND(0x01,0xD5,0x00,0x00,0x00,0x80,0x00,0xBF,0x00,0xF8,0x01,0x20,0x01,0x4D,0x01,0x68,0x01,0x88,0x01,0xB8,0x01,0xF0,0x02,0x28,0x02,0x7D,0x02,0xB8,0x02,0xBA,0x03,0x00,0x03,0x4D,0x03,0x6A,0x03,0x88,0x03,0xA0,0x03,0xB5,0x03,0xC8,0x03,0xD0,0x03,0xE8,0x03,0xF0,0x03,0xF8,0x03,0xFF);

	SSD_SEND(0x01,0xD6,0x00,0x00,0x00,0x80,0x00,0xBF,0x00,0xF8,0x01,0x20,0x01,0x4D,0x01,0x68,0x01,0x88,0x01,0xB8,0x01,0xF0,0x02,0x28,0x02,0x7D,0x02,0xB8,0x02,0xBA,0x03,0x00,0x03,0x4D,0x03,0x6A,0x03,0x88,0x03,0xA0,0x03,0xB5,0x03,0xC8,0x03,0xD0,0x03,0xE8,0x03,0xF0,0x03,0xF8,0x03,0xFF);

	SSD_SEND(0x01,0x3A,0x50);

*/





SSD_SEND(0x01,0xF0,0x55, 0xAA, 0x52, 0x08, 0x00);

SSD_SEND(0x01,0xF6,0x5A, 0x87);

SSD_SEND(0x01,0xC1,0x3F);

SSD_SEND(0x01,0xC2,0x0E);

SSD_SEND(0x01,0xC6,0xF8);

SSD_SEND(0x01,0xC9,0x10);

SSD_SEND(0x01,0xCD,0x25);

SSD_SEND(0x01,0xfa,0x08,0x08,0x00,0x04);

SSD_SEND(0x01,0xF8,0x8A);

SSD_SEND(0x01,0x71,0x48);

SSD_SEND(0x01,0x72,0x48);

SSD_SEND(0x01,0x73,0x00, 0x44);

SSD_SEND(0x01,0x97,0xEE);

SSD_SEND(0x01,0x83,0x93);

SSD_SEND(0x01,0xA3,0x22);

SSD_SEND(0x01,0xFD,0x28, 0x3C, 0x00);

SSD_SEND(0x01,0xAC,0x45);

SSD_SEND(0x01,0xA7,0x47);

SSD_SEND(0x01,0xA0,0xDD);

SSD_SEND(0x01,0x9A,0xC0);

SSD_SEND(0x01,0x9B,0x40);

SSD_SEND(0x01,0x82,0x3E, 0x3E);

SSD_SEND(0x01,0xB1,0x10);

SSD_SEND(0x01,0x7A,0x13, 0x1A);

SSD_SEND(0x01,0x7B,0x13, 0x1A);

SSD_SEND(0x01,0x6D,0x00, 0x1F, 0x19, 0x1A, 0x10, 0x0E, 0x0C, 0x0A, 0x02, 0x08, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x07, 0x01, 0x09, 0x0B, 0x0D, 0x0F, 0x1A, 0x19, 0x1F, 0x00);

SSD_SEND(0x01,0x64,0x28, 0x04, 0x02, 0x7C, 0x03, 0x03, 0x28, 0x03, 0x02, 0x7D, 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A);

SSD_SEND(0x01,0x65,0x28, 0x02, 0x02, 0x7E, 0x03, 0x03, 0x28, 0x01, 0x02, 0x7F, 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A);

SSD_SEND(0x01,0x66,0x28, 0x00, 0x02, 0x80, 0x03, 0x03, 0x20, 0x01, 0x02, 0x81, 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A);

SSD_SEND(0x01,0x67,0x20, 0x02, 0x02, 0x82, 0x03, 0x03, 0x20, 0x03, 0x02, 0x83, 0x03, 0x03, 0x7A, 0x7A, 0x7A, 0x7A);

SSD_SEND(0x01,0x68,0x77, 0x08, 0x06, 0x08, 0x05, 0x7A, 0x7A, 0x08, 0x06, 0x08, 0x05, 0x7A, 0x7A);

SSD_SEND(0x01,0x60,0x28, 0x06, 0x7A, 0x7A, 0x28, 0x05, 0x7A, 0x7A);

SSD_SEND(0x01,0x63,0x22, 0x7E, 0x7A, 0x7A, 0x22, 0x7F, 0x7A, 0x7A);

SSD_SEND(0x01,0x69, 0x14, 0x22, 0x14, 0x22, 0x14, 0x22, 0x08);

SSD_SEND(0x01,0x6B,0x07);

SSD_SEND(0x01,0xD1,0x00, 0x00, 0x00, 0x80, 0x00, 0xBF, 0x00, 0xF8, 0x01, 0x20, 0x01, 0x4D, 0x01, 0x68, 0x01, 0x88, 0x01, 0xB8, 0x01, 0xF0, 0x02, 0x28, 0x02, 0x7D, 0x02, 0xB8, 0x02, 0xBA, 0x03, 0x00, 0x03, 0x4D, 0x03, 0x6A, 0x03, 0x88, 0x03, 0xA0, 0x03, 0xB5, 0x03, 0xC8, 0x03, 0xD0, 0x03, 0xE8, 0x03, 0xF0, 0x03, 0xF8, 0x03, 0xFF);

SSD_SEND(0x01,0xD2,0x00, 0x00, 0x00, 0x80, 0x00, 0xBF, 0x00, 0xF8, 0x01, 0x20, 0x01, 0x4D, 0x01, 0x68, 0x01, 0x88, 0x01, 0xB8, 0x01, 0xF0, 0x02, 0x28, 0x02, 0x7D, 0x02, 0xB8, 0x02, 0xBA, 0x03, 0x00, 0x03, 0x4D, 0x03, 0x6A, 0x03, 0x88, 0x03, 0xA0, 0x03, 0xB5, 0x03, 0xC8, 0x03, 0xD0, 0x03, 0xE8, 0x03, 0xF0, 0x03, 0xF8, 0x03, 0xFF);

SSD_SEND(0x01,0xD3,0x00, 0x00, 0x00, 0x80, 0x00, 0xBF, 0x00, 0xF8, 0x01, 0x20, 0x01, 0x4D, 0x01, 0x68, 0x01, 0x88, 0x01, 0xB8, 0x01, 0xF0, 0x02, 0x28, 0x02, 0x7D, 0x02, 0xB8, 0x02, 0xBA, 0x03, 0x00, 0x03, 0x4D, 0x03, 0x6A, 0x03, 0x88, 0x03, 0xA0, 0x03, 0xB5, 0x03, 0xC8, 0x03, 0xD0, 0x03, 0xE8, 0x03, 0xF0, 0x03, 0xF8, 0x03, 0xFF);

SSD_SEND(0x01,0xD4,0x00, 0x00, 0x00, 0x80, 0x00, 0xBF, 0x00, 0xF8, 0x01, 0x20, 0x01, 0x4D, 0x01, 0x68, 0x01, 0x88, 0x01, 0xB8, 0x01, 0xF0, 0x02, 0x28, 0x02, 0x7D, 0x02, 0xB8, 0x02, 0xBA, 0x03, 0x00, 0x03, 0x4D, 0x03, 0x6A, 0x03, 0x88, 0x03, 0xA0, 0x03, 0xB5, 0x03, 0xC8, 0x03, 0xD0, 0x03, 0xE8, 0x03, 0xF0, 0x03, 0xF8, 0x03, 0xFF);

SSD_SEND(0x01,0xD5,0x00, 0x00, 0x00, 0x80, 0x00, 0xBF, 0x00, 0xF8, 0x01, 0x20, 0x01, 0x4D, 0x01, 0x68, 0x01, 0x88, 0x01, 0xB8, 0x01, 0xF0, 0x02, 0x28, 0x02, 0x7D, 0x02, 0xB8, 0x02, 0xBA, 0x03, 0x00, 0x03, 0x4D, 0x03, 0x6A, 0x03, 0x88, 0x03, 0xA0, 0x03, 0xB5, 0x03, 0xC8, 0x03, 0xD0, 0x03, 0xE8, 0x03, 0xF0, 0x03, 0xF8, 0x03, 0xFF);

SSD_SEND(0x01,0xD6,0x00, 0x00, 0x00, 0x80, 0x00, 0xBF, 0x00, 0xF8, 0x01, 0x20, 0x01, 0x4D, 0x01, 0x68, 0x01, 0x88, 0x01, 0xB8, 0x01, 0xF0, 0x02, 0x28, 0x02, 0x7D, 0x02, 0xB8, 0x02, 0xBA, 0x03, 0x00, 0x03, 0x4D, 0x03, 0x6A, 0x03, 0x88, 0x03, 0xA0, 0x03, 0xB5, 0x03, 0xC8, 0x03, 0xD0, 0x03, 0xE8, 0x03, 0xF0, 0x03, 0xF8, 0x03, 0xFF);


SSD_SEND(0x01,0x21,0x00);

DCS_Short_Write_NP(0x11);
Delay(1500);   
DCS_Short_Write_NP(0x29);
Delay(120);

SSD_MODE(0,1);
}
