|
版主及兄弟们好,我用艾克姆的标准24le1板子及配套软件,iic/w2编程,配置为主模式,外接I2C mpu9250设备地址0x68,调用w2的接口,w2读写函数都会直接卡死。
硬件和连接没有问题,请指导下,谢谢。代码如下:
#include "hal_w2.h"
hal_w2_configure_master(HAL_W2_100KHZ);
delay(10);
buf[0] = readMpuReg(WHO_AM_I); //卡死
//writeMpuReg(PWR_MGMT_1, 0x00); //解除休眠状态,卡死
//mpu9250
void writeMpuReg(uint8_t fu8Add, uint8_t fu8Data)
{
uint8_t lau8Data[2] = {0};
lau8Data[0] = fu8Add;
lau8Data[1] = fu8Data;
hal_w2_write(I2C_DEV_ADDR, lau8Data, 2);
}
uint8_t readMpuReg(uint8_t fu8Add)
{
uint8_t lu8Data = {0};
lu8Data = fu8Add;
hal_w2_write(I2C_DEV_ADDR, &lu8Data, 1);
hal_w2_read(I2C_DEV_ADDR, &lu8Data, 1);
return lu8Data;
} |
|