我正在尝试使用HAL库在STM32F板上设置通用计时器。到目前为止,这是我的专长:
static TIM_HandleTypeDef s_TimerInstance = {
.Instance = TIM2
};
void InitializeTimer() {
__TIM2_CLK_ENABLE();
s_TimerInstance.Init.Prescaler = 40000;
s_TimerInstance.Init.CounterMode = TIM_COUNTERMODE_UP;
s_TimerInstance.Init.Period = 500;
s_TimerInstance.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
s_TimerInstance.Init.RepetitionCounter = 0;
HAL_TIM_Base_Init(&s_TimerInstance);
HAL_TIM_Base_Start(&s_TimerInstance);
}
我无法访问s_TimerInstance
的成员。
字段'Init'无法解析
包含的头文件如下:
#include "stm32f0xx_hal.h"
#include "stm32f072xb.h"
#include "stm32f0xx_hal_tim.h"
TIM_HandleTypeDef的定义如下:
typedef struct
{
TIM_TypeDef *Instance; /*!< Register base address */
TIM_Base_InitTypeDef Init; /*!< TIM Time Base required parameters */
HAL_TIM_ActiveChannel Channel; /*!< Active channel */
DMA_HandleTypeDef *hdma[7]; /*!< DMA Handlers array
This array is accessed by a @ref TIM_DMA_Handle_index */
HAL_LockTypeDef Lock; /*!< Locking object */
__IO HAL_TIM_StateTypeDef State; /*!< TIM operation state */
}TIM_HandleTypeDef;