int i2c_read(int reg_offset)
{
int data;
int activity;
// reg_offset = reg_offset | 0x100 ;
// mem_wr_i2c(0x10, reg_offset); // IC_DATA_CMD: set register address
*(volatile UINT32 *)0x18500010 = reg_offset;
// mem_wr_i2c(0x10, 0x100); // IC_DATA_CMD: set read bit
*(volatile UINT32 *)0x18500010 = 0x100;
ic_status = mem_rd_i2c(0x70); // IC STATUS register. LSB is the common activity bit
activity = ic_status & 0x1;
while (activity == 0)
{
ic_status = mem_rd_i2c(0x70); // IC STATUS register. LSB is the common activity bit
activity = ic_status & 0x1;
}
data = mem_rd_i2c(0x10); // IC_DATA_CMD: read returned register value
//printf("1:%d\n",data);
ic_status = mem_rd_i2c(0x70); // IC STATUS register. LSB is the common activity bit
activity = ic_status & 0x1;
while (activity == 1)
{
readCounter++;
ic_status = mem_rd_i2c(0x70); // IC STATUS register. LSB is the common activity bit
activity = ic_status & 0x1;
}
data = mem_rd_i2c(0x10); // IC_DATA_CMD: read returned register value
printf("2:%d\n",data);
return (data);
} |