让你写个定时器的驱动,你回如何写?
1> TIM结构体抽象
2> TIM句柄结构体
/*!< Peripheral base address in the alias region */
#define PERIPH_BASE 0x40000000UL
#define APB1PERIPH_BASE PERIPH_BASE
#define TIM6_BASE (APB1PERIPH_BASE + 0x1000UL)
#define TIM6 ((TIM_TypeDef *) TIM6_BASE)
结构体成员:
1》 Instance :STM32芯片具体定时器的地址,如TIM6;
2》Init : 初始化参数的结构体;
3> stm32f4xx_hal_tim.c 文件
3.1> 函数框架
阅读HAL库手册: Description of STM32F4xx HAL drivers
阅读源码
1> Time Base functions
2> TIM Output Compare functions
3> TIM PWM functions
4> TIM Input Capture functions
5> TIM One Pulse functions
6> TIM Encoder functions
7> IRQ handler management
8> Peripheral Control functions
9> TIM Callbacks functions
10> Peripheral State functions