#include #include #include "nrf_delay.h" #include "twi_master.h" #include "mpu9250.h" MPU_t mMPU9250; //************************************** //写入一个字节数据 //************************************** bool MPU9250_Write_Byte(uint8_t Device_Address,uint8_t REG_Address,uint8_t REG_data) { uint8_t buf[2]; buf[0] = REG_Address; buf[1] = REG_data; return twi_master_transfer(Device_Address, buf, 2, TWI_ISSUE_STOP); } //************************************** //读取N个字节数据 //************************************** bool MPU9250_Read_nBytes(uint8_t Device_Address,uint8_t REG_Address,uint8_t *readDataBuf,uint8_t readDataLen) { bool ret; ret = twi_master_transfer(Device_Address, ®_Address, 1, TWI_DONT_ISSUE_STOP); ret &= twi_master_transfer(Device_Address|TWI_READ_BIT, readDataBuf, readDataLen, TWI_ISSUE_STOP); return ret; } bool MPU9250_register_write_len(uint8_t Device_Address,uint8_t register_address, uint8_t len,uint8_t *buf) { uint8_t w2_data[50],i; w2_data[0] = register_address; for(i=0;i