Skip to content

Instantly share code, notes, and snippets.

@sash13
Created July 29, 2011 12:25
Show Gist options
  • Save sash13/1113715 to your computer and use it in GitHub Desktop.
Save sash13/1113715 to your computer and use it in GitHub Desktop.
kal_uint8 i2c_tp_Readid(void)
{
kal_uint8 lcd_id = 0xff;
///kal_uint32 savedMask;
kal_uint8 readid_cnt=0;
kal_uint8 readata;
//////tp_i2c_crystal_on();
//////i2c_tp_hw_init();
//I2C_TOUCH_INIT();
/////////////////////Trace_out("LYT in i2c_tp_Readid\n");
////////////////////////////////i2c_tp_all_init();
//GPIO_InitIO(0,SDA); //КдИлцї?
//GPIO_InitIO(0,SCL); //КдИлцї?
//yiaddtest
readid_cnt = 0;
while(1)
{
readid_cnt++;
//////1 /////savedMask = SaveAndSetIRQMask();//SAVEANDSETIRQMASK(); //disable all IRQ
tp_i2c_start();
tp_i2cTxByte(TP_ADRW); ///(0x40);
tp_ackcheck_s2h();
if(CF==0)
{
tp_i2cTxByte(0xE1); ///(0x00); //0xE1
tp_ackcheck_s2h();
if(CF==0)
{
tp_i2c_start();
tp_i2cTxByte(TP_ADRR);///(0x41);
tp_ackcheck_s2h();
if(CF==0)
{
lcd_id = tp_i2cRxByte();
tp_ackcheck_s2h();
if(CF==0)
{
tp_i2c_stop();
//Trace_out("1------lcd_id==%d",lcd_id);
if((0x01 == lcd_id) && (readid_cnt> 2))
{
i2c_tp_ReadDataFromReg(&readata, TP_IRQ_ADDRESS);
return 1;
}
}
else
{
tp_i2c_stop();
continue;
}
}
else
{
tp_i2c_stop();
continue;
}
}
else
{
tp_i2c_stop();
continue;
}
}
else
{
tp_i2c_stop();
continue;
}
/////// 1 ///RestoreIRQMask(savedMask); //enable all IRQ
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment