移植MPU6050 DMP到uCOS II中,出现如下错误,求高手指点迷津
时间:10-02
整理:3721RD
点击:
源代码inv_mpu.c中应该是没有错误的,直接copy过来的
..\eMPL\inv_mpu.c(344): error: #40: expected an identifier
};
..\eMPL\inv_mpu.c(666): error: #20: identifier "st" is undefined
if (st.chip_cfg.dmp_on) {
..\eMPL\inv_mpu.c(671): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->int_enable, 1, &tmp))
..\eMPL\inv_mpu.c(683): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->int_enable, 1, &tmp))
..\eMPL\inv_mpu.c(699): error: #20: identifier "st" is undefined
for (ii = 0; ii < st.hw->num_reg; ii++) {
..\eMPL\inv_mpu.c(702): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, ii, 1, &data))
..\eMPL\inv_mpu.c(718): error: #20: identifier "st" is undefined
if (reg == st.reg->fifo_r_w || reg == st.reg->mem_r_w)
..\eMPL\inv_mpu.c(722): warning: #223-D: function "i2c_read" declared implicitly
return i2c_read(st.hw->addr, reg, 1, data);
..\eMPL\inv_mpu.c(745): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 1, &(data[0])))
..\eMPL\inv_mpu.c(745): error: #20: identifier "st" is undefined
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 1, &(data[0])))
..\eMPL\inv_mpu.c(740): warning: #177-D: variable "rev" was declared but never referenced
unsigned char data[6], rev;
..\eMPL\inv_mpu.c(882): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 2, tmp))
..\eMPL\inv_mpu.c(882): error: #20: identifier "st" is undefined
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 2, tmp))
..\eMPL\inv_mpu.c(941): error: #20: identifier "st" is undefined
st.chip_cfg.sensors = INV_XYZ_ACCEL;
..\eMPL\inv_mpu.c(959): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors & INV_XYZ_GYRO))
..\eMPL\inv_mpu.c(962): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, st.reg->raw_gyro, 6, tmp))
..\eMPL\inv_mpu.c(968): warning: #223-D: function "get_ms" declared implicitly
get_ms(timestamp);
..\eMPL\inv_mpu.c(982): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors & INV_XYZ_ACCEL))
..\eMPL\inv_mpu.c(985): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, st.reg->raw_accel, 6, tmp))
..\eMPL\inv_mpu.c(991): warning: #223-D: function "get_ms" declared implicitly
get_ms(timestamp);
..\eMPL\inv_mpu.c(1006): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors))
..\eMPL\inv_mpu.c(1009): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, st.reg->temp, 2, tmp))
..\eMPL\inv_mpu.c(1013): warning: #223-D: function "get_ms" declared implicitly
get_ms(timestamp);
..\eMPL\inv_mpu.c(1038): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, 3, 3, data))
..\eMPL\inv_mpu.c(1038): error: #20: identifier "st" is undefined
if (i2c_read(st.hw->addr, 3, 3, data))
..\eMPL\inv_mpu.c(1066): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, 0x06, 6, data))
..\eMPL\inv_mpu.c(1079): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors))
..\eMPL\inv_mpu.c(1083): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->int_enable, 1, &data))
..\eMPL\inv_mpu.c(1139): error: #20: identifier "st" is undefined
switch (st.chip_cfg.gyro_fsr) {
..\eMPL\inv_mpu.c(1168): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors))
..\eMPL\inv_mpu.c(1190): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->gyro_cfg, 1, &data))
..\eMPL\inv_mpu.c(1203): error: #20: identifier "st" is undefined
switch (st.chip_cfg.accel_fsr) {
..\eMPL\inv_mpu.c(1233): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors))
..\eMPL\inv_mpu.c(1255): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->accel_cfg, 1, &data))
..\eMPL\inv_mpu.c(1268): error: #20: identifier "st" is undefined
switch (st.chip_cfg.lpf) {
..\eMPL\inv_mpu.c(1306): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors))
..\eMPL\inv_mpu.c(1324): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->lpf, 1, &data))
..\eMPL\inv_mpu.c(1337): error: #20: identifier "st" is undefined
if (st.chip_cfg.dmp_on)
..\eMPL\inv_mpu.c(1354): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors))
..\eMPL\inv_mpu.c(1377): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->rate_div, 1, &data))
..\eMPL\inv_mpu.c(1443): error: #20: identifier "st" is undefined
switch (st.chip_cfg.gyro_fsr) {
..\eMPL\inv_mpu.c(1469): error: #20: identifier "st" is undefined
switch (st.chip_cfg.accel_fsr) {
..\eMPL\inv_mpu.c(1501): error: #20: identifier "st" is undefined
sensors[0] = st.chip_cfg.fifo_enable;
..\eMPL\inv_mpu.c(1522): error: #20: identifier "st" is undefined
if (st.chip_cfg.dmp_on)
..\eMPL\inv_mpu.c(1558): error: #20: identifier "st" is undefined
if (st.chip_cfg.sensors)
..\eMPL\inv_mpu.c(1588): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 1, &data)) {
..\eMPL\inv_mpu.c(1588): error: #20: identifier "st" is undefined
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 1, &data)) {
..\eMPL\inv_mpu.c(1655): error: #20: identifier "st" is undefined
if (!st.chip_cfg.sensors)
..\eMPL\inv_mpu.c(1657): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, st.reg->dmp_int_status, 2, tmp))
..\eMPL\inv_mpu.c(1689): error: #20: identifier "st" is undefined
if (st.chip_cfg.dmp_on)
..\eMPL\inv_mpu.c(1707): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, st.reg->fifo_count_h, 2, data))
..\eMPL\inv_mpu.c(1722): warning: #223-D: function "get_ms" declared implicitly
get_ms((unsigned long*)timestamp);
..\eMPL\inv_mpu.c(1767): error: #20: identifier "st" is undefined
if (!st.chip_cfg.dmp_on)
..\eMPL\inv_mpu.c(1772): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, st.reg->fifo_count_h, 2, tmp))
..\eMPL\inv_mpu.c(1804): error: #20: identifier "st" is undefined
if (st.chip_cfg.bypass_mode == bypass_on)
..\eMPL\inv_mpu.c: 25 warnings, 30 errors
".\myled.axf" - 30 Error(s), 25 Warning(s).
..\eMPL\inv_mpu.c(344): error: #40: expected an identifier
};
..\eMPL\inv_mpu.c(666): error: #20: identifier "st" is undefined
if (st.chip_cfg.dmp_on) {
..\eMPL\inv_mpu.c(671): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->int_enable, 1, &tmp))
..\eMPL\inv_mpu.c(683): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->int_enable, 1, &tmp))
..\eMPL\inv_mpu.c(699): error: #20: identifier "st" is undefined
for (ii = 0; ii < st.hw->num_reg; ii++) {
..\eMPL\inv_mpu.c(702): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, ii, 1, &data))
..\eMPL\inv_mpu.c(718): error: #20: identifier "st" is undefined
if (reg == st.reg->fifo_r_w || reg == st.reg->mem_r_w)
..\eMPL\inv_mpu.c(722): warning: #223-D: function "i2c_read" declared implicitly
return i2c_read(st.hw->addr, reg, 1, data);
..\eMPL\inv_mpu.c(745): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 1, &(data[0])))
..\eMPL\inv_mpu.c(745): error: #20: identifier "st" is undefined
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 1, &(data[0])))
..\eMPL\inv_mpu.c(740): warning: #177-D: variable "rev" was declared but never referenced
unsigned char data[6], rev;
..\eMPL\inv_mpu.c(882): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 2, tmp))
..\eMPL\inv_mpu.c(882): error: #20: identifier "st" is undefined
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 2, tmp))
..\eMPL\inv_mpu.c(941): error: #20: identifier "st" is undefined
st.chip_cfg.sensors = INV_XYZ_ACCEL;
..\eMPL\inv_mpu.c(959): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors & INV_XYZ_GYRO))
..\eMPL\inv_mpu.c(962): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, st.reg->raw_gyro, 6, tmp))
..\eMPL\inv_mpu.c(968): warning: #223-D: function "get_ms" declared implicitly
get_ms(timestamp);
..\eMPL\inv_mpu.c(982): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors & INV_XYZ_ACCEL))
..\eMPL\inv_mpu.c(985): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, st.reg->raw_accel, 6, tmp))
..\eMPL\inv_mpu.c(991): warning: #223-D: function "get_ms" declared implicitly
get_ms(timestamp);
..\eMPL\inv_mpu.c(1006): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors))
..\eMPL\inv_mpu.c(1009): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, st.reg->temp, 2, tmp))
..\eMPL\inv_mpu.c(1013): warning: #223-D: function "get_ms" declared implicitly
get_ms(timestamp);
..\eMPL\inv_mpu.c(1038): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, 3, 3, data))
..\eMPL\inv_mpu.c(1038): error: #20: identifier "st" is undefined
if (i2c_read(st.hw->addr, 3, 3, data))
..\eMPL\inv_mpu.c(1066): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, 0x06, 6, data))
..\eMPL\inv_mpu.c(1079): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors))
..\eMPL\inv_mpu.c(1083): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->int_enable, 1, &data))
..\eMPL\inv_mpu.c(1139): error: #20: identifier "st" is undefined
switch (st.chip_cfg.gyro_fsr) {
..\eMPL\inv_mpu.c(1168): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors))
..\eMPL\inv_mpu.c(1190): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->gyro_cfg, 1, &data))
..\eMPL\inv_mpu.c(1203): error: #20: identifier "st" is undefined
switch (st.chip_cfg.accel_fsr) {
..\eMPL\inv_mpu.c(1233): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors))
..\eMPL\inv_mpu.c(1255): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->accel_cfg, 1, &data))
..\eMPL\inv_mpu.c(1268): error: #20: identifier "st" is undefined
switch (st.chip_cfg.lpf) {
..\eMPL\inv_mpu.c(1306): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors))
..\eMPL\inv_mpu.c(1324): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->lpf, 1, &data))
..\eMPL\inv_mpu.c(1337): error: #20: identifier "st" is undefined
if (st.chip_cfg.dmp_on)
..\eMPL\inv_mpu.c(1354): error: #20: identifier "st" is undefined
if (!(st.chip_cfg.sensors))
..\eMPL\inv_mpu.c(1377): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->rate_div, 1, &data))
..\eMPL\inv_mpu.c(1443): error: #20: identifier "st" is undefined
switch (st.chip_cfg.gyro_fsr) {
..\eMPL\inv_mpu.c(1469): error: #20: identifier "st" is undefined
switch (st.chip_cfg.accel_fsr) {
..\eMPL\inv_mpu.c(1501): error: #20: identifier "st" is undefined
sensors[0] = st.chip_cfg.fifo_enable;
..\eMPL\inv_mpu.c(1522): error: #20: identifier "st" is undefined
if (st.chip_cfg.dmp_on)
..\eMPL\inv_mpu.c(1558): error: #20: identifier "st" is undefined
if (st.chip_cfg.sensors)
..\eMPL\inv_mpu.c(1588): warning: #223-D: function "i2c_write" declared implicitly
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 1, &data)) {
..\eMPL\inv_mpu.c(1588): error: #20: identifier "st" is undefined
if (i2c_write(st.hw->addr, st.reg->pwr_mgmt_1, 1, &data)) {
..\eMPL\inv_mpu.c(1655): error: #20: identifier "st" is undefined
if (!st.chip_cfg.sensors)
..\eMPL\inv_mpu.c(1657): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, st.reg->dmp_int_status, 2, tmp))
..\eMPL\inv_mpu.c(1689): error: #20: identifier "st" is undefined
if (st.chip_cfg.dmp_on)
..\eMPL\inv_mpu.c(1707): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, st.reg->fifo_count_h, 2, data))
..\eMPL\inv_mpu.c(1722): warning: #223-D: function "get_ms" declared implicitly
get_ms((unsigned long*)timestamp);
..\eMPL\inv_mpu.c(1767): error: #20: identifier "st" is undefined
if (!st.chip_cfg.dmp_on)
..\eMPL\inv_mpu.c(1772): warning: #223-D: function "i2c_read" declared implicitly
if (i2c_read(st.hw->addr, st.reg->fifo_count_h, 2, tmp))
..\eMPL\inv_mpu.c(1804): error: #20: identifier "st" is undefined
if (st.chip_cfg.bypass_mode == bypass_on)
..\eMPL\inv_mpu.c: 25 warnings, 30 errors
".\myled.axf" - 30 Error(s), 25 Warning(s).
这么看来很多都是定义问题啊
谢谢分享,共同学习...
那个st是不是忘了定义或者没有申明外部变量
可以参考一下 正点原子上面的,可以使用的
学习中----
我也是碰到这个问题
解决了,是设置的不对
target potion里面c++选项define里面加入MOTION_DRIVER_TARGET_STM32,MPU6050
你好,我这么设置了还是不行啊。麻烦说详细点好吗?可能是我其他地方设置有误