autoquad使用定时器用作系统获取时间的来源。该部分在初始化时调用timerInit()函数用来初始化定时器,其内部具体内容如下
void timerInit(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
// Enable the TIMER_TIM global Interrupt
NVIC_InitStructure.NVIC_IRQChannel = TIMER_IRQ_CH;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
TIMER_EN;
// stop timer when core halted (debug)
DBGMCU_APB1PeriphConfig(TIMER_CORE_HALT, ENABLE);
/* Time base configuration for 1MHz (us)*/
TIM_TimeBaseStructure.TIM_Period = 0xFFFFFFFF;
TIM_TimeBaseStructure.TIM_Prescaler = (TIMER_CLOCK / 1000000) - 1;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIMER_TIM, &TIM_TimeBaseStructure);
// reset
TIM_SetCounter