小学生
最后登录1970-1-1
在线时间 小时
注册时间2014-1-21
|
static void I2C_6050_ByteWrite(u8 WriteAddr,u8 pBuffer)
{
/*wait until I2C bus is not busy*/
while(I2C_GetFlagStatus(I2C1,I2C_FLAG_BUSY));
/* Send START condition */
I2C_GenerateSTART(I2C1, ENABLE);
/* Test on EV5 and clear it */
while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT)); 程序一直卡在这里过不去
/* Send MMA address for write */
I2C_Send7bitAddress(I2C1, ADRESS_6050, I2C_Direction_Transmitter);
/* Test on EV6 and clear it */
while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED));
/* Send the MMA's Register address to write to */
I2C_SendData(I2C1, WriteAddr);
/* Test on EARM and clear it */
while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
/* Send the byte to be written */
I2C_SendData(I2C1, pBuffer);
/* Test on EARM and clear it */
while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
/* Send STOP condition */
I2C_GenerateSTOP(I2C1, ENABLE);
} |
|