E015.D.011-FXLS90230/Drivers/BSP/timer.h

69 lines
1.7 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __TIMER_H
#define __TIMER_H
#include "main.h"
// TIM2寄存器结构体重定义
//typedef struct {
// __IO uint32_t CR1;
// __IO uint32_t CR2;
// __IO uint32_t SMCR;
// // ... 其他寄存器定义完整TIM寄存器结构
//} TIM_RegTypeDef;
//#define MY_TIM2_BASE 0x40000000U
//#define MY_TIM2 ((TIM_RegTypeDef *)TIM2_BASE)
// 默认配置参数(用户可修改)
#ifndef TIM2_PRESCALER
#define TIM2_PRESCALER 3999//7999 // 80MHz -> 10kHz
#endif
#ifndef TIM2_PERIOD
#define TIM2_PERIOD 49 // 5ms定时
#endif
#ifndef TIM2_IRQ_PRIORITY
#define TIM2_IRQ_PRIORITY 1 // 中断优先级
#endif
#define TIM1_PRESCALER 7999//3999//7999 // 80MHz -> 10kHz
#define TIM1_PERIOD 9 // 1ms定时
#define TIM1_IRQ_PRIORITY 0 // 中断优先级
//extern unsigned char Time1s_flag;
#define VIB_TIME_COUNT 1000 //定时计数
#define VIB_THRESHOLD 100 //
#define VIB_DISABLEDELAY 100
#define VIB_INTERVAl 10//32//10 //n*5ms 定时10ms
#define VIB_INTERVAl_TIME 100//32//10 //n*5ms 定时10ms
#define UARTOVERTIME 60
#define VIB_GETDATAMAXTIME 1000//3200//1000 //计数点数 最高频率2KHz
#define VIB_GETWOBMAXTIME 200//3200//1000 //计数点数 最高频率200Hz
#define VIB_MINTIME_COUNT 60//3200//1000 //计数点数 最高频率200Hz
// 定时器操作API
void TIM2_Reg_Init(uint32_t prescaler, uint32_t period);
void TIM2_Reg_Start(void);
void TIM2_Reg_Stop(void);
void TIM2_Reg_SetPeriod(uint32_t period);
void TIM1_Init(uint32_t prescaler, uint32_t period);
void TIM1_Start(void);
void TIM1_Stop(void);
void TIM1_SetPeriod(uint32_t period);
//外部中断初始化
// 初始化PB10为下降沿外部中断
extern void PB10_EXTI_Init(void);
// 自定义中断回调函数
extern void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin);
#endif