//===================================================================
//===================================================================
void GP5_Init(void)
{
GP5_SDAENABLE();
GP5_SDASwitchOut();
GP5_SDALevelUp();
}
//===================================================================
//===================================================================
void I2CSlaveInit(void)
{
GP6_SDAENABLE();
//GP6_SDASwitchOut();
GP6_SDASwitchIn();
//GP6_SDALevelUp();
GP7_SCLENABLE();
//GP7_SCLSwitchOut();
GP7_SCLSwitchIn();
//GP7_SCLLevelUp();
}
//===================================================================
//===================================================================
u8 IIC_slave_start(void)
{
u32 m = 0 ;
while(GP7_SCLLevelGet()) // wait SCL is 1
{
if(GP6_SDALevelGet()==1) //SDA
{
}
else
{
m++;
if(m > 2 )
{
return 0;
}
}
}
return 1;
}
//===================================================================
//===================================================================
u8 IIC_slave_wait_start(void)
{
u32 m = 0, n = 0 ;
while(GP7_SCLLevelGet()) // wait SCL is 1
{
n++ ;
if (n > 150000)
{
return 1;
}
if(GP6_SDALevelGet()==1)
{
m++ ;
if (m > 150000)
{
return 1;
}
}
else
{
if(m > 3 )
{
return 0;
}
}
}
return 1;
}