我知道0x20是IDLE位为1,但是我在调试代码时查看寄存器值得变化发现用I2CMasterControl没法使得I2CMCS的值发生改变,甚至用HWREG函数操作都不行,代码如下,求救啊
unsigned int XX7299A_I2CRead(unsigned int I2C_BASE,uchar REG_ADDR,uchar ID)
{
uchar DATA;
unsigned int i;
I2CMasterInitExpClk(I2C_BASE,SysCtlClockGet(),true);
I2CMasterSlaveAddrSet(I2C_BASE,ID,true);
I2CMasterDataPut(I2C_BASE,REG_ADDR);
//查询忙与错误
while(I2CMasterBusBusy(I2C_BASE));
I2CMasterControl(I2C_BASE,I2C_MASTER_CMD_BURST_SEND_ERROR_STOP);
while(I2CMasterBusy(I2C_BASE));
i = I2CMasterErr(I2C_BASE);
I2CMasterSlaveAddrSet(I2C_BASE,ID,false);
I2CMasterControl(I2C_BASE,I2C_MASTER_CMD_BURST_RECEIVE_FINISH);
while(I2CMasterBusy(I2C_BASE));
i = I2CMasterErr(I2C_BASE);
switch(i)
{
case I2C_MASTER_ERR_NONE:
{
//
DATA = I2CMasterDataGet(I2C_BASE);
return DATA;
};break;
case I2C_MASTER_ERR_ADDR_ACK:XX7299A_I2CRead(I2C_BASE,REG_ADDR,ID);break;
case I2C_MASTER_ERR_DATA_ACK:XX7299A_I2CRead(I2C_BASE,REG_ADDR,ID);break;
case I2C_MASTER_ERR_ARB_LOST:XX7299A_I2CRead(I2C_BASE,REG_ADDR,ID);break;
case I2C_MASTER_ERR_CLK_TOUT:XX7299A_I2CRead(I2C_BASE,REG_ADDR,ID);break;
default:XX7299A_I2CRead(I2C_BASE,REG_ADDR,ID);
}
}
X tank:
I2CMDR寄存器也没法输入值