#include "timer.h"
		
TIM_HandleTypeDef htim7;

void TIMER_config()
{
		__HAL_RCC_TIM7_CLK_ENABLE();

    htim7.Instance = TIM7;
    htim7.Init.Prescaler = 59999;
    htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
    htim7.Init.Period = 5999;
    HAL_TIM_Base_Init(&htim7);
		__HAL_TIM_ENABLE(&htim7);

}

void delay_ms(uint32_t ms)
{
		uint32_t start_time = __HAL_TIM_GET_COUNTER(&htim7); // 获取当前定时器计数值
    while ((TIM7->CNT - start_time) < ms); // 等待经过指定的延时时间
}

void TIM7_IRQHandler(void)
{
    HAL_TIM_IRQHandler(&htim7);
}
