3.3 I2C发送测试
Uint16 I2CA_WriteData_test(Uint16 data )
{
if (I2caRegs.I2CMDR.bit.STP == 1)
{
return I2C_STP_NOT_READY_ERROR;
}
// Setup slave address
I2caRegs.I2CSAR =0x50;
// Check if bus busy
if (I2caRegs.I2CSTR.bit.BB == 1)
{
return I2C_BUS_BUSY_ERROR;
}
// Setup number of bytes to send
// MsgBuffer + Address
I2caRegs.I2CCNT =1;
I2caRegs.I2CDXR =data;
// Send start as master transmitter
I2caRegs.I2CMDR.all = 0x6E20;//启动发送命令。STT,STP置1。产生起始、停止信号。TRX置1,发送模式。
return I2C_SUCCESS;
}
关闭
站长推荐
/2
用户190916 2013-7-26 10:23
用户1648059 2013-4-27 20:46
用户404956 2011-11-10 16:07