void _IIC_write(I2C_Handle hI2C,
Uint8 devAddress,
Uint32 subAddress,
Uint8 data
)
{
I2C_Config prevI2CCfg;
/* Wait until bus is free */
while (I2C_bb(hI2C));
/* Save old settings */
I2C_getConfig(hI2C, &prevI2CCfg);
/* Restore settings for AIC23 */
SEEDDM642IIC_Configt.i2csar = devAddress;
I2C_config(hI2C, &SEEDDM642IIC_Configt);
/* Submit the MSB for transmit */
I2C_RSETH(hI2C, I2CDXR, (subAddress) & 0xff);
/* Generate start condition, starts transmission */
I2C_start(hI2C);
/* Wait until MSB transmit is done */
while(!I2C_xrdy(hI2C));
/* Submit the LSB for transmit */
I2C_RSETH(hI2C, I2CDXR,data);
// EVMDM642_waitusec(350);
/* Generate stop condition */
I2C_sendStop(hI2C);
/* Wait until bus is free */
while (I2C_bb(hI2C));
EVMDM642_waitusec(350);
/* Reconfigure I2C with old settings */
I2C_config(hI2C, &prevI2CCfg);
}
=========================================================
首先void _IIC_write(I2C_Handle hI2C,
Uint8 devAddress,
Uint32 subAddress,
Uint8 data
)
这4个参数分别代表什么意思呢?
其次能详细讲解下每一行代码都表示什么意思吗?这个是库函数里面的I2C程序,我查了书和网上的资料都没有关于它的讲解。新手没什么分,只能在此谢过大神了! |