chenxibing0082011-12-27 09:33
xidianchinaunix: 炳哥,请教个问题。LPC3250的I2C如何通过查询方式(不使用中断)进行读写操作?是否通过查询I2C_STATE寄存器TFE和RFE即可?此时是否需要使能I2C_CTRL寄存器的相.....
查询方式I2C范例:
I2C1->i2c_ctrl = 0;
I2C1->i2c_txrx = ((sla & 0xfe) | I2C_START_BIT | I2C_WRITE_BIT);
//waiting for transmit OK
wait = 0;
while((I2C1->i2c_stat & mstatus_tfe) == 0) {
if (++wait > WAIT_TIME) {
i2c_reset();
return -1;
}
}