arm的i2c接口读,需要连读2次才可以吗?
quarticarm发表于 昨天 13:32 | 只看该作者 回复 引用 编辑 订阅 收藏 分享 评分打印楼主: arm的i2c接口读,需要连读2次才可以吗?接口, arm, activity, register, addressint 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);}