我现在在读MPU6050,下面是我向MPU6050的内部某个寄存器写入一个字节的数据,麻烦帮我看下有没有问题,谢谢,谢谢!
void I2C_write(unsigned char reg_address, unsigned char data)
{
I2CMasterSlaveAddrSet(I2C1_BASE, slave_address, false); // false代表主模块发送,从模块接收
I2CMasterDataPut(I2C1_BASE, reg_address); // 发送寄存器地址
I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
while(I2CMasterBusy(I2C1_BASE));
I2CMasterDataPut(I2C1_BASE, data); // 发送数据
I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2CMasterBusy(I2C1_BASE));
I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_STOP);
while(I2CMasterBusy(I2C1_BASE));
}
|