예제 #1
0
//ADS1115 have 4 channel. We can select on of them in one moment.
void selectInput(uint8_t number)
{
	 uint8_t conf[2];
	 conf[1] = 227;

	 //create config for selecting channel
	 if(number == 0)
	 	 {
	 		 conf[0] = 195;
	 	 }
	 if(number == 1)
	 	 {
	 		 conf[0] = 211;
	 	 }
	 if(number == 2)
	 	 {
	 		 conf[0] = 227;
	 	 }
	 if(number == 3)
	 	 {
	 		 conf[0] = 243;
	 	 }

	//send config
	 I2C_StartTransmission(I2C1,I2C_Direction_Transmitter,0x90);
	 I2C_Write_Data(I2C1,0x01);
	 I2C_Write_Data(I2C1,conf[0]);
	 I2C_Write_Data(I2C1,conf[1]);
	 //I2C_GenerateSTOP(I2C1,ENABLE);
}
예제 #2
0
void InitADS1115()
{
	I2c_Init();
	uint8_t conf[2];
	//Request
	I2C_StartTransmission(I2C1,I2C_Direction_Transmitter,0x90);
	I2C_Write_Data(I2C1,0x01);
	I2C_GenerateSTOP(I2C1,ENABLE);
	//Response
	I2C_StartTransmission(I2C1,I2C_Direction_Receiver,0x90);
	conf[0] = I2C_Read_ack(I2C1);
	conf[1] = I2C_Read_nack(I2C1);
	I2C_GenerateSTOP(I2C1,ENABLE);
}
예제 #3
0
uint_fast16_t getData(uint8_t number)
{

	uint8_t i2c_data[2];
	//Request
	I2C_StartTransmission(I2C1,I2C_Direction_Transmitter,0x90);
	I2C_Write_Data(I2C1,0x00);
	I2C_GenerateSTOP(I2C1,ENABLE);
	//Response
	I2C_StartTransmission(I2C1,I2C_Direction_Receiver,0x90);
	i2c_data[0] = I2C_Read_ack(I2C1);
	i2c_data[1] = I2C_Read_nack(I2C1);
	uint_fast16_t adc = i2c_data[0] <<  8 | i2c_data[1];
	//I2C_GenerateSTOP(I2C1,ENABLE);
	return adc;
}
예제 #4
0
파일: CIS.C 프로젝트: Riiich/Cheddar
// Be sure to POWER UP sensor by set Power_Down pin to 0, then it's workable to write register to sensor by I2C.
void InitSensor(void)
{	
	unsigned char i;
	
#ifdef OV9155

	// OV9155 VGA YUV RGB 30FPS
	I2C_Write_Data(0x60,0x12,0x80); 
	DelayMS(2);
	I2C_Write_Data(0x60,0x00,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x01,0x80); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x02,0x80); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x03,0x12); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x04,0x03); 
	for(i=0;i<50;i++);
	//I2C_Write_Data(0x60,0x09,0x10);
	//for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x0B,0x57); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x0E,0x61); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x0F,0x42); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x11,0x01); 	// 30 FPS
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x12,0x62); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x13,0xE7); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x14,0x3A); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x16,0x24); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x17,0x16);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x18,0x02);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x19,0x01);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x1A,0x3D); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x1E,0x04); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x24,0x3C); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x25,0x36); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x26,0x72); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x27,0x08); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x28,0x08); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x29,0x15); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x2A,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x2B,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x2C,0x08); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x32,0xFF); //Bruce BF
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x33,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x34,0x3F); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x35,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x36,0xFA); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x38,0x72); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x39,0x57); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x3A,0x84);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x3B,0x04); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x3D,0x99); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x3E,0x0C);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x3F,0xC1);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x40,0xC0);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x41,0x00);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x42,0xC0);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x43,0x0A);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x44,0xF0);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x45,0x46);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x46,0x62);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x47,0x2A);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x48,0x3C);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x4A,0xFC);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x4B,0xFC);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x4C,0x7F);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x4D,0x7F);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x4E,0x7F);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x52,0x28);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x53,0x88);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x54,0xB0);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x4F,0x98);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x50,0x98);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x51,0x00);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x58,0x1A);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x59,0x85);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x5a,0xA9);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x5B,0x64);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x5C,0x84);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x5D,0x53);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x5E,0x0E);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x5F,0xF0);
	for(i=0;i<50;i++);
	
	I2C_Write_Data(0x60,0x60,0xF0);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x61,0xF0);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x62,0x00);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x63,0x00);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x64,0x02);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x65,0x20);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x66,0x00);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x69,0x0A);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x6B,0x5A);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x6C,0x04);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x6D,0x55);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x6E,0x00);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x6F,0x9D);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x70,0x21);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x71,0x78);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x72,0x00);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x73,0x00);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x74,0x3A);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x75,0x35);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x76,0x01);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x77,0x02);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x7A,0x12);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x7B,0x08);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x7C,0x15);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x7D,0x24);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x7E,0x45);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x7F,0x55);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x80,0x6A);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x81,0x78);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x82,0x87);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x83,0x96);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x84,0xa3);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x85,0xb4);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x86,0xc3);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x87,0xd6);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x88,0xe6);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x89,0xf2);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x8C,0x8D);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x90,0x7d);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x91,0x7b);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x9D,0x02);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x9E,0x02);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0x9F,0x7A);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xA0,0x79);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xA1,0x40);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xA4,0x50);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xA5,0x68);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xA6,0x4a);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xA8,0xC1);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xA9,0xEF);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xAA,0x92);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xAB,0x04);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xAC,0x80);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xAD,0x80);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xAE,0x80);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xAF,0x80);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xB2,0xF2);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xB3,0x20);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xB4,0x20);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xB5,0x00);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xB6,0xAF);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xBB,0xAE);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xBC,0x7F);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xBD,0x7F);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xBE,0x7F);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xBF,0x7F);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xC0,0xAA);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xC1,0xC0);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xC2,0x01);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xC3,0x4E);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xC6,0x05);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xC7,0x80);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xC9,0xE0);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xCA,0xE8);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xCB,0xF0);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xCC,0xD8);
	for(i=0;i<50;i++);
	I2C_Write_Data(0x60,0xCD,0x93);
	for(i=0;i<50;i++);
#else

	I2C_Write_Data(0x42,0x12,0x80); 	//reset all registers to default value
	DelayMS(2);

	I2C_Write_Data(0x42,0x09,0x10); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xC1,0x7F);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x11,0x80);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x3A,0x0C);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x3D,0xC0);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x12,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x15,0x40);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x17,0x13);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x18,0x01);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x32,0xBF);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x19,0x02);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x1A,0x7A);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x03,0x0A);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x0C,0x00);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x3E,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x70,0x3A);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x71,0x35);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x72,0x11); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x73,0xF0);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0xA2,0x02);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x7A,0x20);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x7B,0x03); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x7C,0x0A);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x7D,0x1A); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x7E,0x3F);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x7F,0x4E);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x80,0x5B); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x81,0x68);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x82,0x75);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x83,0x7F);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x84,0x89);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x85,0x9A);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x86,0xA6);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x87,0xBD);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x88,0xD3);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x89,0xE8);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x13,0xE0);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x00,0x00);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x10,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x0D,0x40);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x14,0x28);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0xA5,0x02); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xAB,0x02); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x24,0x68);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x25,0x58);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x26,0xC2); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x9F,0x78);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0xA0,0x68);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0xA1,0x03);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0xA6,0xD8);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0xA7,0xD8);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0xA8,0xF0);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0xA9,0x90); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xAA,0x14);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x13,0xE5);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x0E,0x61);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x0F,0x4B);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x16,0x02); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x1E,0x07); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x21,0x02);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x22,0x91);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x29,0x07); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x33,0x0B);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x35,0x0B);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x37,0x1D);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x38,0x71);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x39,0x2A);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x3C,0x78);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x4D,0x40);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x4E,0x20); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x69,0x00);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x6B,0x0A); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x74,0x10);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x8D,0x4F);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x8E,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x8F,0x00);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x90,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x91,0x00);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x96,0x00);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x9A,0x80); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xB0,0x84);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0xB1,0x0C);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0xB2,0x0E); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xB3,0x82); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xB8,0x12); //set DOVDD = 2.8V
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x43,0x0A);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x44,0xF2);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x45,0x39);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x46,0x62); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x47,0x3D); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x48,0x55); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x59,0x83); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x5A,0x0D);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x5B,0xCD); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x5C,0x8C);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x5D,0x77);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x5E,0x16);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x6C,0x0A); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x6D,0x65); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x6E,0x11); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x6A,0x40); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x01,0x56);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x02,0x44);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x13,0xE7); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x4F,0x88); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x50,0x8B); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x51,0x04);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x52,0x11); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x53,0x8C); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x54,0x9D); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x55,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x56,0x40); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x34,0x11);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x3B,0x12); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xA4,0x88);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x96,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x97,0x30); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x98,0x20); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x99,0x30); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x9A,0x84); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x9B,0x29); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x9C,0x03); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x9D,0x99); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x9E,0x7F); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x78,0x04); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x79,0x01); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xC8,0xF0);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x79,0x0F); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xC8,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x79,0x10); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xC8,0x7E);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x79,0x0A); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xC8,0x80); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x79,0x0B);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0xC8,0x01); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x79,0x0C);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0xC8,0x0F);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x79,0x0D); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xC8,0x20);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x79,0x09);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0xC8,0x80);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x79,0x02); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xC8,0xC0); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x79,0x03); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xC8,0x40);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x79,0x05); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0xC8,0x30);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x79,0x26); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x62,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x63,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x64,0x06); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x65,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x66,0x05); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x94,0x05);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x95,0x09); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x2A,0x10);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x2B,0xC2);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x15,0x00);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x3A,0x04); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x3D,0xC3);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x19,0x03);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x1A,0x7B);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x2A,0x00);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x2B,0x00);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x18,0x01); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x66,0x05); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x62,0x10); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x63,0x0B);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x65,0x07); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x64,0x0F); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x94,0x0E); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x95,0x10); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x4F,0x87); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x50,0x68);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x51,0x1E); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x52,0x15); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x53,0x7C); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x54,0x91); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x58,0x1E); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x41,0x38);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x76,0xE0);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x24,0x40); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x25,0x38); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x26,0x91);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x7A,0x09);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x7B,0x0C);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x7C,0x16); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x7D,0x28); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x7E,0x48);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x15,0x00); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x3A,0x04); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x3D,0xC3);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x19,0x03); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x1A,0x7B); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x2A,0x00);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x2B,0x00);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x18,0x01);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x66,0x05); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x62,0x10);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x63,0x0B); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x65,0x07);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x64,0x0F); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x94,0x0E); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x95,0x10);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x4F,0x87);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x50,0x68); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x51,0x1E); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x52,0x15); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x53,0x7C); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x54,0x91); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x58,0x1E); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x41,0x38);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x76,0xE0); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x24,0x40); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x25,0x38); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x26,0x91); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x7A,0x09); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x7B,0x0C); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x7C,0x16);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x7D,0x28);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x7E,0x48); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x7F,0x57);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x80,0x64); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x81,0x71); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x82,0x7E); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x83,0x89);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x84,0x94);
	for(i=0;i<50;i++); 
	I2C_Write_Data(0x42,0x85,0xA8); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x86,0xBA); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x87,0xD7); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x88,0xEC); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x89,0xF9); 
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x09,0x01); 
	for(i=0;i<50;i++);

	I2C_Write_Data(0x42,0x71,0x00); 	//8-bar color bar
	for(i=0;i<50;i++);
	I2C_Write_Data(0x42,0x70,0x00); 	//8-bar color bar
#endif

}