在将mpu6050官方dmp库移植到stm32平台的时候编译报错
hardware\mpu6050\inv_mpu.c(630): error: #41: expression must have arithmetic or pointer type
大概意思是要求表达式必须有算术或指针类型
//代引用的结构体
static struct gyro_state_s st = {
.reg = ®,
.hw = &hw,
.test = &test
};
//引用结构体的函数
//错无在if结构体成员应勇那,已加粗
static int set_int_enable(unsigned char enable)
{
unsigned char tmp;
if (st.chip_cfg.dmp_on) {
if (enable)
tmp = BIT_DMP_INT_EN;
else
tmp = 0x00;
**if (i2c_write(st.hw->addr, st.reg->int_enable, 1, &tmp))**
return -1;
st.chip_cfg.int_enable = tmp;
} else {
if (!st.chip_cfg.sensors)
return -1;
if (enable && st.chip_cfg.int_enable)
return 0;
if (enable)
tmp = BIT_DATA_RDY_EN;
else
tmp = 0x00;
** if (i2c_write(st.hw->addr, st.reg->int_enable, 1, &tmp))**
return -1;
st.chip_cfg.int_enable = tmp;
}
return 0;
}
hardware\mpu6050\inv_mpu.c(630): error: #41: expression must have arithmetic or pointer type
估计是结构体成员调用的问题
我不知道为什么结构体后会有两个名称,还有这种结构体成员是如和调用的
我也遇到这个问题了,我的问题根源是宏替换的i2c_write和i2c_read的原函数没有返回值,你可以参考一下另一个老哥给的链接中怎么写的
这个我已经解决了,是dmp库移植的问题,没有修改好