/*************************************************************************************************************
* 文件名 : stm32f4_timer.h
* 功能 : STM32F4 timer驱动
* 作者 : cp1300@139.com
* 创建时间 : 2017-08-24
* 最后修改时间 : 2017-08-24
* 详细: 高级定时器:tim1,time8(16位)
通用定时器:tim3,tim4(16位),tim2,tim5(32位)
通用定时器:tim9-tim14(16位)
基本定时器:tim6-tim7(16位)
*************************************************************************************************************/
#ifndef __STM32F4_TIMER_H_
#define __STM32F4_TIMER_H_
#include "system.h"
//定时器选择,定时器1,8高级定时器,2,3,4,5 9-14为通用定时器,6,7为基本定时器
typedef enum
{
TIMER1 = 0,
TIMER2 = 1,
TIMER3 = 2,
TIMER4 = 3,
TIMER5 = 4,
TIMER6 = 5,
TIMER7 = 6,
TIMER8 = 7,
TIMER9 = 8,
TIMER10 = 9,
TIMER11 = 10,
TIMER12 = 11,
TIMER13 = 12,
TIMER14 = 13,
} TIMER_CH;
//定时器PWM通道,每个定时器有4路PWM输出通道
typedef enum
{
PWM_CH1 = 0,
PWM_CH2 = 1,
PWM_CH3 = 2,
PWM_CH4 = 3,
} TIMER_PWM_CH;
//API
void TimerPWM_Init(TIMER_CH timerCh, TIMER_PWM_CH pwmCh,u16 psc, u16 arr); //初始化定时器PWM输出
void TimerPWM_Set(TIMER_CH timerCh, TIMER_PWM_CH pwmCh,u16 pwm); //设置PWM占空比
u32 TIMER_GetTimeClockSpeed(TIMER_CH timerCh); //STM32F4获取定时器时钟频率
#endif //__STM32F4_TIMER_H_
|