鲍勃,
谢谢你的回复。
MpU6050库包含在项目中,所以我不确定哪一个.h文件丢失。代码编译并在UART上打印数字。只是这些读数在MPU6050中是不可用的。
在我下载文件的页面上,您回答了I2C API改变了。塞巴斯蒂安后来用下面的代码修改了那部分:
事业单位的旧代码
无效I2CeRADEnter(UIT88T DEVADDR,UIT88T RADADR,UIT88T长度,UIT88T*值){
UIT88T I=0;
I2CYMPU6050AI2CMASTESTESTART(DEVADDR,I2CYMPU6050AI2CX Wrad EX-Felx模式);
I2CYMPU6050II2CMASTEMWRITE字节(RADADR);
I2CYMPU6050AI2CMASTESTEnReST(DeDADDR,I2CYMPU6050AI2CX Read x Felx模式);
而(i++lt;(长度-1)){
*值+++=I2CYMPU6050AI2CMASTRADEDALVEL字节(I2CYMPU6050AI2CYACKYDATA);
}
*值=I2CYMPU6050AI2CMASTRADESENTELL字节(I2CYMPU6050AI2CY-NAKYDATA);
I2CYMPU6050AI2CMASTESTESTSTOP();
}
公共事业=新法规
无效I2CeRADEnter(UIT88T DEVADDR,UIT88T RADADR,UIT88T长度,UIT88T*值){
UIT88T I=0;
I2CYMPU6050AI2CMASTESTESTART(DEVADDR,I2CYMPU6050AI2CX WrreEX-FelyMod,0);
I2CYMPU6050AI2CMASTEMWRITE字节(RADADR,0);
I2CYMPU6050AI2CMASTESTEnRead(DeDADDR,I2CYMPU6050AI2CYRADYXFEXY MODE,0);
而(i++lt;(长度-1)){
I2CYMPU6050AI2CSTMASTRADEQUALTELL(I2CYMPU6050II2CYACKY DATA,Value++,0);
}
I2CYMPU6050AI2CSTMASTRADEQUALTELL(I2CYMPU6050II2CYNKAL数据,值,0);
I2CYMPU6050AI2CMASTESTONSTOP(0);
}
事业单位
恐怕这部分代码会影响阅读部分。你能帮帮我吗?
最好的,
阿波奥瓦
以上来自于百度翻译
以下为原文
Bob,
Thanks for replying.
The MPU6050 library is included in the project-- so i am not sure which .h files are missing. The code compiles, and prints numbers on the UART. Just that readings are not available the MPU6050.
On the page from where I downloaded the file, you had replied that i2c API changed. Sebastian later modified that part with the following piece of the code:
=============================old code===========================================
void I2CReadBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *value) {
uint8_t i=0;
I2C_MPU6050_I2CMasterSendStart(devAddr, I2C_MPU6050_I2C_WRITE_XFER_MODE);
I2C_MPU6050_I2CMasterWriteByte(regAddr);
I2C_MPU6050_I2CMasterSendRestart(devAddr, I2C_MPU6050_I2C_READ_XFER_MODE);
while (i++ < (length-1)) {
*value++ = I2C_MPU6050_I2CMasterReadByte(I2C_MPU6050_I2C_ACK_DATA);
}
*value = I2C_MPU6050_I2CMasterReadByte(I2C_MPU6050_I2C_NAK_DATA);
I2C_MPU6050_I2CMasterSendStop();
}
=============================new code===========================================
void I2CReadBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *value) {
uint8_t i=0;
I2C_MPU6050_I2CMasterSendStart(devAddr, I2C_MPU6050_I2C_WRITE_XFER_MODE,0);
I2C_MPU6050_I2CMasterWriteByte(regAddr,0);
I2C_MPU6050_I2CMasterSendRestart(devAddr, I2C_MPU6050_I2C_READ_XFER_MODE,0);
while (i++ < (length-1)) {
I2C_MPU6050_I2CMasterReadByte(I2C_MPU6050_I2C_ACK_DATA,value++,0);
}
I2C_MPU6050_I2CMasterReadByte(I2C_MPU6050_I2C_NAK_DATA,value,0);
I2C_MPU6050_I2CMasterSendStop(0);
}
===============================================================================
I am afraid that this the part of the code that is affecting the reading part. Could you please help me?
Best,
Apoorva