使用 Cube IDE 创建一个项目。编译时,由于自动生成的驱动程序中的错误,编译失败。为了解决这个问题,我删除了所有驱动程序并用 MX 再次导入,但错误仍然存在。
错误:
invalid type argument of '->' (have 'TIM_HandleTypeDef {aka struct <anonymous>}') stm32f1xx_hal_tim.h />Project</Drivers/STM32F1xx_HAL_Driver/Inc line 1222 C/C++ Problem invalid type argument of '->' (have 'TIM_HandleTypeDef {aka struct <anonymous>}') stm32f1xx_hal_tim.h />Project</Drivers/STM32F1xx_HAL_Driver/Inc line 1229 C/C++ Problem make: *** [Src/subdir.mk:73: Src/stm32f1xx_it.o] Error 1 >Project< C/C++ Problem make: *** Waiting for unfinished jobs.... >Project< C/C++ Problem
代码:
#define __HAL_TIM_SET_COUNTER(__HANDLE__, __COUNTER__) ((__HANDLE__)->Instance->CNT = (__COUNTER__)) /** * @brief Get the TIM Counter Register value on runtime. * @param __HANDLE__ TIM handle. * @retval 16-bit or 32-bit value of the timer counter register (TIMx_CNT) */#define __HAL_TIM_GET_COUNTER(__HANDLE__) ((__HANDLE__)->Instance->CNT) /** * @brief Set the TIM Autoreload Register value on runtime without calling another time any Init function. * @param __HANDLE__ TIM handle. * @param __AUTORELOAD__ specifies the Counter register new value. * @retval None */