你参考下面的例子,先写从机寄存器地址,然后读数据。
/* 读一个字节的数据*/
uint8_t iic_single_read(uint8_t reg_addr,uint8_t* read_data)
{
uint8_t ret=0;
delay(10);
iic_send_end_flag = 0;
R_RIIC0_Master_Send(MPU6050_SLAVE_ADDR,®_addr,1);
while(iic_send_end_flag == 0) nop();
delay(1);
iic_send_end_flag = 0;
iic_ret_status = R_RIIC0_Master_Receive(MPU6050_SLAVE_ADDR,read_data,1);
while(iic_rev_end_flag==0) nop();
iic_rev_end_flag = 0;
delay(10);
return ret;
}
你参考下面的例子,先写从机寄存器地址,然后读数据。
/* 读一个字节的数据*/
uint8_t iic_single_read(uint8_t reg_addr,uint8_t* read_data)
{
uint8_t ret=0;
delay(10);
iic_send_end_flag = 0;
R_RIIC0_Master_Send(MPU6050_SLAVE_ADDR,®_addr,1);
while(iic_send_end_flag == 0) nop();
delay(1);
iic_send_end_flag = 0;
iic_ret_status = R_RIIC0_Master_Receive(MPU6050_SLAVE_ADDR,read_data,1);
while(iic_rev_end_flag==0) nop();
iic_rev_end_flag = 0;
delay(10);
return ret;
}
举报