111111111

1111111111111

/* * 立创开发板软硬件资料与相关扩展板软硬件资料官网全部开源 * 开发板官网:www.lckfb.com * 文档网站:wiki.lckfb.com * 技术支持常驻论坛,任何技术问题欢迎随时交流学习 * 嘉立创社区问答:https://www.jlc-bbs.com/lckfb * 关注bilibili账号:【立创开发板】,掌握我们的最新动态! * 不靠卖板赚钱,以培养中国工程师为己任 */ #include "bsp_encoder.h" #include "bsp_tb6612.h" #include "board.h" #include "PID.h" #include <ti/driverlib/driverlib.h> // 添加DriverLib头文件 // 声明外部函数(根据您的项目结构调整) #if defined(MPU6050) void Read_Quad(void); // 添加函数声明 #endif uint32_t gpio_interrup1, gpio_interrup2; int Get_Encoder_countA, Get_Encoder_countB; /******************************************************* 函数功能:外部中断模拟编码器信号 入口函数:无 返回 值:无 ***********************************************************/ void encoder_Init(void) { NVIC_ClearPendingIRQ(GPIOB_INT_IRQn); NVIC_EnableIRQ(GPIOB_INT_IRQn); } static void handle_encoder1(void); static void handle_encoder2(void); // 修复1:移除宏定义末尾的分号 #if defined(MPU6050) #define GPIO_MPU6050_INT_IIDX // 正确格式 #endif void GROUP1_IRQHandler(void) { // 获取所有编码器引脚的中断状态 uint32_t gpio_status = DL_GPIO_getEnabledInterruptStatus( ENCODER_PORT, ENCODER_E1A_PIN | ENCODER_E1B_PIN | ENCODER_E2A_PIN | ENCODER_E2B_PIN ); // 处理编码器1中断 if (gpio_status & (ENCODER_E1A_PIN | ENCODER_E1B_PIN)) { handle_encoder1(); DL_GPIO_clearInterruptStatus(ENCODER_PORT, ENCODER_E1A_PIN | ENCODER_E1B_PIN); } // 处理编码器2中断 if (gpio_status & (ENCODER_E2A_PIN | ENCODER_E2B_PIN)) { handle_encoder2(); DL_GPIO_clearInterruptStatus(ENCODER_PORT, ENCODER_E2A_PIN | ENCODER_E2B_PIN); } // 处理MPU6050中断 - 修复2:使用正确的条件编译 #if defined(GPIO_MPU6050_INT_IIDX) && defined(MPU6050) if (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1) == GPIO_MPU6050_INT_IIDX) { Read_Quad(); // 确保此函数已声明 } #endif } // 编码器1处理函数 static void handle_encoder1(void) { uint32_t gpio_interrup = DL_GPIO_getEnabledInterruptStatus( ENCODER_PORT, ENCODER_E1A_PIN | ENCODER_E1B_PIN ); // encoderB (原始逻辑) if ((gpio_interrup & ENCODER_E1A_PIN) == ENCODER_E1A_PIN) { if (!DL_GPIO_readPins(ENCODER_PORT, ENCODER_E1B_PIN)) { Get_Encoder_countB--; } else { Get_Encoder_countB++; } } else if ((gpio_interrup & ENCODER_E1B_PIN) == ENCODER_E1B_PIN) { if (!DL_GPIO_readPins(ENCODER_PORT, ENCODER_E1A_PIN)) { Get_Encoder_countB++; } else { Get_Encoder_countB--; } } } // 编码器2处理函数 static void handle_encoder2(void) { uint32_t gpio_interrup = DL_GPIO_getEnabledInterruptStatus( ENCODER_PORT, ENCODER_E2A_PIN | ENCODER_E2B_PIN ); // encoderA (原始逻辑) if ((gpio_interrup & ENCODER_E2A_PIN) == ENCODER_E2A_PIN) { if (!DL_GPIO_readPins(ENCODER_PORT, ENCODER_E2B_PIN)) { Get_Encoder_countA--; } else { Get_Encoder_countA++; } } else if ((gpio_interrup & ENCODER_E2B_PIN) == ENCODER_E2B_PIN) { if (!DL_GPIO_readPins(ENCODER_PORT, ENCODER_E2A_PIN)) { Get_Encoder_countA++; } else { Get_Encoder_countA--; } } } [0]**** Clean-only build of configuration Debug for project 111111111 **** [1]"C:\\ti\\ccs2020\\ccs\\utils\\bin\\gmake" -k -j 16 clean -O [2]**** Build of configuration Debug for project 111111111 **** [3]"C:\\ti\\ccs2020\\ccs\\utils\\bin\\gmake" -k -j 16 all -O [4]Building file: "../empty.syscfg" [5]Invoking: SysConfig [6]"C:/ti/ccs2020/ccs/utils/sysconfig_1.24.0/sysconfig_cli.bat" --script "C:/Users/Administrator/workspace_ccstheia/111111111/empty.syscfg" -o "." -s "C:/ti/mspm0_sdk_2_05_01_00/.metadata/product.json" --compiler ticlang [7]Running script... [8]Validating... [9]info: PWM_0(/ti/driverlib/PWM): Peripheral does not retain register contents in STOP or STANDBY modes. User should take care to save and restore register configuration in application. See Retention Configuration section for more details. [10]info: TIMER_1(/ti/driverlib/TIMER): Peripheral does not retain register contents in STOP or STANDBY modes. User should take care to save and restore register configuration in application. See Retention Configuration section for more details. [11]Generating Code (empty.syscfg)... [12]Writing C:\Users\Administrator\workspace_ccstheia\111111111\Debug\device_linker.cmd... [13]Writing C:\Users\Administrator\workspace_ccstheia\111111111\Debug\device.opt... [14]Writing C:\Users\Administrator\workspace_ccstheia\111111111\Debug\device.cmd.genlibs... [15]Writing C:\Users\Administrator\workspace_ccstheia\111111111\Debug\ti_msp_dl_config.c... [16]Writing C:\Users\Administrator\workspace_ccstheia\111111111\Debug\ti_msp_dl_config.h... [17]Writing C:\Users\Administrator\workspace_ccstheia\111111111\Debug\Event.dot... [18]Finished building: "../empty.syscfg" [19]Building file: "C:/ti/mspm0_sdk_2_05_01_00/source/ti/devices/msp/m0p/startup_system_files/ticlang/startup_mspm0g350x_ticlang.c" [20]Invoking: Arm Compiler [21]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"startup_mspm0g350x_ticlang.d_raw" -MT"startup_mspm0g350x_ticlang.o" @"./device.opt" -o"startup_mspm0g350x_ticlang.o" "C:/ti/mspm0_sdk_2_05_01_00/source/ti/devices/msp/m0p/startup_system_files/ticlang/startup_mspm0g350x_ticlang.c" [22]Finished building: "C:/ti/mspm0_sdk_2_05_01_00/source/ti/devices/msp/m0p/startup_system_files/ticlang/startup_mspm0g350x_ticlang.c" [23]Building file: "../empty.c" [24]Invoking: Arm Compiler [25]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"empty.d_raw" -MT"empty.o" @"./device.opt" -o"empty.o" "../empty.c" [26]Finished building: "../empty.c" [27]Building file: "ti_msp_dl_config.c" [28]Invoking: Arm Compiler [29]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"ti_msp_dl_config.d_raw" -MT"ti_msp_dl_config.o" @"./device.opt" -o"ti_msp_dl_config.o" "ti_msp_dl_config.c" [30]Finished building: "ti_msp_dl_config.c" [31]Building file: "../BSP/MPU6050/inv_mpu.c" [32]Invoking: Arm Compiler [33]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"BSP/MPU6050/inv_mpu.d_raw" -MT"BSP/MPU6050/inv_mpu.o" @"./device.opt" -o"BSP/MPU6050/inv_mpu.o" "../BSP/MPU6050/inv_mpu.c" [34]Finished building: "../BSP/MPU6050/inv_mpu.c" [35]Building file: "../BSP/MPU6050/mspm0_i2c.c" [36]Invoking: Arm Compiler [37]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"BSP/MPU6050/mspm0_i2c.d_raw" -MT"BSP/MPU6050/mspm0_i2c.o" @"./device.opt" -o"BSP/MPU6050/mspm0_i2c.o" "../BSP/MPU6050/mspm0_i2c.c" [38]Finished building: "../BSP/MPU6050/mspm0_i2c.c" [39]Building file: "../BSP/MPU6050/mpu6050.c" [40]Invoking: Arm Compiler [41]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"BSP/MPU6050/mpu6050.d_raw" -MT"BSP/MPU6050/mpu6050.o" @"./device.opt" -o"BSP/MPU6050/mpu6050.o" "../BSP/MPU6050/mpu6050.c" [42]Finished building: "../BSP/MPU6050/mpu6050.c" [43]Building file: "../BSP/src/bsp_encoder.c" [44]Invoking: Arm Compiler [45]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"BSP/src/bsp_encoder.d_raw" -MT"BSP/src/bsp_encoder.o" @"./device.opt" -o"BSP/src/bsp_encoder.o" "../BSP/src/bsp_encoder.c" [46]Building file: "../BSP/MPU6050/inv_mpu_dmp_motion_driver.c" [47]Invoking: Arm Compiler [48]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"BSP/MPU6050/inv_mpu_dmp_motion_driver.d_raw" -MT"BSP/MPU6050/inv_mpu_dmp_motion_driver.o" @"./device.opt" -o"BSP/MPU6050/inv_mpu_dmp_motion_driver.o" "../BSP/MPU6050/inv_mpu_dmp_motion_driver.c" [49]../BSP/src/bsp_encoder.c:67:84: error: expected expression [50] 67 | if (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1) == GPIO_MPU6050_INT_IIDX) { [51] | ^ [52]1 error generated. [53]gmake: *** [BSP/src/subdir_rules.mk:11: BSP/src/bsp_encoder.o] Error 1 [54]Finished building: "../BSP/MPU6050/inv_mpu_dmp_motion_driver.c" [55]Building file: "../BSP/src/PID.c" [56]Invoking: Arm Compiler [57]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"BSP/src/PID.d_raw" -MT"BSP/src/PID.o" @"./device.opt" -o"BSP/src/PID.o" "../BSP/src/PID.c" [58]Finished building: "../BSP/src/PID.c" [59]Building file: "../BSP/OLED/oled_software_i2c.c" [60]Invoking: Arm Compiler [61]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"BSP/OLED/oled_software_i2c.d_raw" -MT"BSP/OLED/oled_software_i2c.o" @"./device.opt" -o"BSP/OLED/oled_software_i2c.o" "../BSP/OLED/oled_software_i2c.c" [62]Finished building: "../BSP/OLED/oled_software_i2c.c" [63]Building file: "../BSP/src/XUNJI.c" [64]Invoking: Arm Compiler [65]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"BSP/src/XUNJI.d_raw" -MT"BSP/src/XUNJI.o" @"./device.opt" -o"BSP/src/XUNJI.o" "../BSP/src/XUNJI.c" [66]Finished building: "../BSP/src/XUNJI.c" [67]Building file: "../BSP/src/bsp_tb6612.c" [68]Invoking: Arm Compiler [69]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"BSP/src/bsp_tb6612.d_raw" -MT"BSP/src/bsp_tb6612.o" @"./device.opt" -o"BSP/src/bsp_tb6612.o" "../BSP/src/bsp_tb6612.c" [70]Finished building: "../BSP/src/bsp_tb6612.c" [71]Building file: "../BSP/src/timer.c" [72]Invoking: Arm Compiler [73]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"BSP/src/timer.d_raw" -MT"BSP/src/timer.o" @"./device.opt" -o"BSP/src/timer.o" "../BSP/src/timer.c" [74]Finished building: "../BSP/src/timer.c" [75]Building file: "../Board/board.c" [76]Invoking: Arm Compiler [77]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"Board/board.d_raw" -MT"Board/board.o" @"./device.opt" -o"Board/board.o" "../Board/board.c" [78]Finished building: "../Board/board.c" [79]Building file: "../MSPM0/interrupt.c" [80]Invoking: Arm Compiler [81]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"MSPM0/interrupt.d_raw" -MT"MSPM0/interrupt.o" @"./device.opt" -o"MSPM0/interrupt.o" "../MSPM0/interrupt.c" [82]Finished building: "../MSPM0/interrupt.c" [83]Building file: "../MSPM0/clock.c" [84]Invoking: Arm Compiler [85]"C:/ti/ccs2020/ccs/tools/compiler/ti-cgt-armllvm_4.0.3.LTS/bin/tiarmclang.exe" -c @"device.opt" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -O0 -I"C:/Users/Administrator/workspace_ccstheia/111111111" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Board" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/MPU6050" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/OLED" -I"C:/Users/Administrator/workspace_ccstheia/111111111/MSPM0" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP" -I"C:/Users/Administrator/workspace_ccstheia/111111111/BSP/inc" -I"C:/Users/Administrator/workspace_ccstheia/111111111/Debug" -I"C:/ti/mspm0_sdk_2_05_01_00/source/third_party/CMSIS/Core/Include" -I"C:/ti/mspm0_sdk_2_05_01_00/source" -DMOTION_DRIVER_TARGET_MSPM0 -DMPU6050 -D__MSPM0G3507__ -gdwarf-3 -MMD -MP -MF"MSPM0/clock.d_raw" -MT"MSPM0/clock.o" @"./device.opt" -o"MSPM0/clock.o" "../MSPM0/clock.c" [86]Finished building: "../MSPM0/clock.c" [87]gmake: Target 'all' not remade because of errors. [88]**** Build Finished ****
08-01
<think>根据编译错误信息,问题出现在`bsp_encoder.c`文件的第67行: ```c if (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1) == GPIO_MPU6050_INT_IIDX) { ``` 错误信息是:`expected expression`,意思是期望一个表达式。这通常是因为`GPIO_MPU6050_INT_IIDX`没有被正确定义。 在代码中,我们有以下定义: ```c #if defined(MPU6050) #define GPIO_MPU6050_INT_IIDX // 正确格式 #endif ``` 这里定义了一个宏`GPIO_MPU6050_INT_IIDX`,但它没有值。在条件判断中,我们将其与`DL_Interrupt_getPendingGroup`的返回值比较,这要求`GPIO_MPU6050_INT_IIDX`必须是一个整数(中断索引号)。 因此,我们需要给`GPIO_MPU6050_INT_IIDX`一个具体的值。这个值应该是MPU6050中断对应的中断索引号(IIDX)。这个值通常可以在设备头文件或通过SysConfig工具配置后生成的定义中找到。 ### 修复步骤: 1. **确定MPU6050中断的IIDX值**: 在SysConfig配置中,为MPU6050的中断引脚配置中断,并查看生成代码中的定义。例如,如果使用PA0作为中断引脚,那么它的中断索引号可能是`DL_INTERRUPT_INDEX0`或其他。 2. **修改宏定义**: 将`GPIO_MPU6050_INT_IIDX`定义为一个具体的值,例如: ```c #if defined(MPU6050) #define GPIO_MPU6050_INT_IIDX DL_INTERRUPT_INDEX0 #endif ``` 注意:具体的索引号需要根据实际使用的GPIO引脚和中断配置来确定。 ### 修改后的代码片段: ```c // 修复1:定义宏为具体的中断索引号 #if defined(MPU6050) // 假设MPU6050的中断引脚配置在PA0,则中断索引号可能是DL_INTERRUPT_INDEX0 #define GPIO_MPU6050_INT_IIDX DL_INTERRUPT_INDEX0 #endif void GROUP1_IRQHandler(void) { // ... 编码器中断处理 ... // 处理MPU6050中断 #if defined(GPIO_MPU6050_INT_IIDX) && defined(MPU6050) if (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1) == GPIO_MPU6050_INT_IIDX) { Read_Quad(); } #endif } ``` ### 注意事项: 1. 确保在SysConfig中正确配置了MPU6050的中断引脚,并且生成了相应的中断索引号。 2. 如果无法确定具体的中断索引号,可以查看生成的`ti_msp_dl_config.h`文件,其中会有类似这样的定义: ```c #define CONFIG_GPIO_MPU6050_INT_IIDX DL_INTERRUPT_INDEX0 ``` 然后在代码中使用这个定义。 ### 完整修复后的代码: ```c /* * 立创开发板软硬件资料与相关扩展板软硬件资料官网全部开源 * 开发板官网:www.lckfb.com * 文档网站:wiki.lckfb.com * 技术支持常驻论坛,任何技术问题欢迎随时交流学习 * 嘉立创社区问答:https://www.jlc-bbs.com/lckfb * 关注bilibili账号:【立创开发板】,掌握我们的最新动态! * 不靠卖板赚钱,以培养中国工程师为己任 */ #include "bsp_encoder.h" #include "bsp_tb6612.h" #include "board.h" #include "PID.h" #include <ti/driverlib/driverlib.h> // 添加DriverLib头文件 // 声明外部函数(根据您的项目结构调整) #if defined(MPU6050) void Read_Quad(void); // 添加函数声明 #endif uint32_t gpio_interrup1, gpio_interrup2; int Get_Encoder_countA, Get_Encoder_countB; /******************************************************* 函数功能:外部中断模拟编码器信号 入口函数:无 返回 值:无 ***********************************************************/ void encoder_Init(void) { NVIC_ClearPendingIRQ(GPIOB_INT_IRQn); NVIC_EnableIRQ(GPIOB_INT_IRQn); } static void handle_encoder1(void); static void handle_encoder2(void); // 修复1:定义宏为具体的中断索引号(根据实际配置修改) #if defined(MPU6050) // 这里需要根据实际配置填写正确的中断索引号,例如DL_INTERRUPT_INDEX0 #define GPIO_MPU6050_INT_IIDX DL_INTERRUPT_INDEX0 #endif void GROUP1_IRQHandler(void) { // 获取所有编码器引脚的中断状态 uint32_t gpio_status = DL_GPIO_getEnabledInterruptStatus( ENCODER_PORT, ENCODER_E1A_PIN | ENCODER_E1B_PIN | ENCODER_E2A_PIN | ENCODER_E2B_PIN ); // 处理编码器1中断 if (gpio_status & (ENCODER_E1A_PIN | ENCODER_E1B_PIN)) { handle_encoder1(); DL_GPIO_clearInterruptStatus(ENCODER_PORT, ENCODER_E1A_PIN | ENCODER_E1B_PIN); } // 处理编码器2中断 if (gpio_status & (ENCODER_E2A_PIN | ENCODER_E2B_PIN)) { handle_encoder2(); DL_GPIO_clearInterruptStatus(ENCODER_PORT, ENCODER_E2A_PIN | ENCODER_E2B_PIN); } // 处理MPU6050中断 - 修复2:使用正确的条件编译 #if defined(GPIO_MPU6050_INT_IIDX) && defined(MPU6050) if (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1) == GPIO_MPU6050_INT_IIDX) { Read_Quad(); // 确保此函数已声明 } #endif } // ... 以下handle_encoder1和handle_encoder2函数保持不变 ... ``` ### 验证: 重新编译项目,确保错误消失。 ### 补充: 如果仍然不确定中断索引号,可以暂时注释掉MPU6050中断处理部分,先确保编码器功能正常。待确定中断索引号后再添加。 §§相关问题§§ 1.在MSPM0中如何正确配置GPIO中断的索引号(IIDX)? 2.如何通过SysConfig工具为外设(如MPU6050)配置中断引脚? 3.在共享中断向量的系统中,如何区分不同GPIO引脚触发的中断? 4.如果中断索引号配置错误,会导致哪些运行时问题? 5.在DriverLib中,DL_Interrupt_getPendingGroup函数返回值的具体含义是什么?</think>### 问题分析与修复 根据编译错误信息,问题出现在`bsp_encoder.c`文件的第67行: ```c if (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1) == GPIO_MPU6050_INT_IIDX) { ``` 错误信息是:`expected expression`,意思是期望一个表达式。这通常是因为`GPIO_MPU6050_INT_IIDX`没有被正确定义。 在代码中,我们有以下定义: ```c #if defined(MPU6050) #define GPIO_MPU6050_INT_IIDX // 正确格式 #endif ``` 这里定义了一个宏`GPIO_MPU6050_INT_IIDX`,但它没有值。在条件判断中,我们将其与`DL_Interrupt_getPendingGroup`的返回值比较,这要求`GPIO_MPU6050_INT_IIDX`必须是一个整数(中断索引号)。 ### 完整修复方案 ```c /* * 立创开发板软硬件资料与相关扩展板软硬件资料官网全部开源 * 开发板官网:www.lckfb.com * 文档网站:wiki.lckfb.com * 技术支持常驻论坛,任何技术问题欢迎随时交流学习 * 嘉立创社区问答:https://www.jlc-bbs.com/lckfb * 关注bilibili账号:【立创开发板】,掌握我们的最新动态! * 不靠卖板赚钱,以培养中国工程师为己任 */ #include "bsp_encoder.h" #include "bsp_tb6612.h" #include "board.h" #include "PID.h" #include <ti/driverlib/driverlib.h> // 添加DriverLib头文件 // 声明外部函数(根据您的项目结构调整) #if defined(MPU6050) void Read_Quad(void); // 添加函数声明 #endif uint32_t gpio_interrup1, gpio_interrup2; int Get_Encoder_countA, Get_Encoder_countB; /******************************************************* 函数功能:外部中断模拟编码器信号 入口函数:无 返回 值:无 ***********************************************************/ void encoder_Init(void) { NVIC_ClearPendingIRQ(GPIOB_INT_IRQn); NVIC_EnableIRQ(GPIOB_INT_IRQn); } static void handle_encoder1(void); static void handle_encoder2(void); // 关键修复:定义具体的中断索引号 #if defined(MPU6050) // 根据实际硬件连接确定中断索引号 // 例如:如果MPU6050连接在PA0引脚,则使用DL_INTERRUPT_INDEX0 #define GPIO_MPU6050_INT_IIDX DL_INTERRUPT_INDEX0 #endif void GROUP1_IRQHandler(void) { // 获取所有编码器引脚的中断状态 uint32_t gpio_status = DL_GPIO_getEnabledInterruptStatus( ENCODER_PORT, ENCODER_E1A_PIN | ENCODER_E1B_PIN | ENCODER_E2A_PIN | ENCODER_E2B_PIN ); // 处理编码器1中断 if (gpio_status & (ENCODER_E1A_PIN | ENCODER_E1B_PIN)) { handle_encoder1(); DL_GPIO_clearInterruptStatus(ENCODER_PORT, ENCODER_E1A_PIN | ENCODER_E1B_PIN); } // 处理编码器2中断 if (gpio_status & (ENCODER_E2A_PIN | ENCODER_E2B_PIN)) { handle_encoder2(); DL_GPIO_clearInterruptStatus(ENCODER_PORT, ENCODER_E2A_PIN | ENCODER_E2B_PIN); } // 处理MPU6050中断 - 修复2:使用正确的条件编译 #if defined(GPIO_MPU6050_INT_IIDX) && defined(MPU6050) if (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1) == GPIO_MPU6050_INT_IIDX) { Read_Quad(); // 确保此函数已声明 } #endif } // ... 以下handle_encoder1和handle_encoder2函数保持不变 ... ``` ### 关键修复点: 1. **中断索引号定义**: ```c #if defined(MPU6050) // 根据实际硬件连接确定中断索引号 #define GPIO_MPU6050_INT_IIDX DL_INTERRUPT_INDEX0 #endif ``` - `DL_INTERRUPT_INDEX0` 是示例值,需根据实际硬件连接确定 - 中断索引号范围:`DL_INTERRUPT_INDEX0` 到 `DL_INTERRUPT_INDEX15` 2. **确定正确的中断索引号**: - 查看芯片手册或SysConfig配置,确定MPU6050中断引脚对应的中断索引号 - 例如: - PA0 -> DL_INTERRUPT_INDEX0 - PA1 -> DL_INTERRUPT_INDEX1 - PB0 -> DL_INTERRUPT_INDEX8 3. **SysConfig配置建议**: 在SysConfig中配置MPU6050中断引脚时: ```c // 在SysConfig生成的代码中查找类似定义 #define CONFIG_GPIO_MPU6050_INT_IIDX DL_INTERRUPT_INDEX2 ``` 然后在代码中使用此定义: ```c #if defined(MPU6050) #define GPIO_MPU6050_INT_IIDX CONFIG_GPIO_MPU6050_INT_IIDX #endif ``` ### 验证步骤: 1. 替换修复后的代码 2. 确认SysConfig中MPU6050中断引脚的配置 3. 重新编译项目: ```bash **** Build Finished **** ``` 4. 使用调试器验证中断功能: - 触发编码器中断,验证计数是否正确 - 触发MPU6050中断,验证数据读取是否正常 ### 补充建议: 如果暂时不需要MPU6050功能,可以完全禁用相关代码: ```c // 注释掉MPU6050相关代码 /* #if defined(MPU6050) #define GPIO_MPU6050_INT_IIDX ... #endif ... #if defined(GPIO_MPU6050_INT_IIDX) && defined(MPU6050) if (...) { Read_Quad(); } #endif */ ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值