69 lines
1.7 KiB
C
69 lines
1.7 KiB
C
|
|
#ifndef __TIMER_H
|
|||
|
|
#define __TIMER_H
|
|||
|
|
|
|||
|
|
#include "main.h"
|
|||
|
|
|
|||
|
|
// TIM2<4D>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD>ض<EFBFBD><D8B6><EFBFBD>
|
|||
|
|
//typedef struct {
|
|||
|
|
// __IO uint32_t CR1;
|
|||
|
|
// __IO uint32_t CR2;
|
|||
|
|
// __IO uint32_t SMCR;
|
|||
|
|
// // ... <20><><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>壨<EFBFBD><E5A3A8><EFBFBD><EFBFBD>TIM<49>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>ṹ<EFBFBD><E1B9B9>
|
|||
|
|
//} TIM_RegTypeDef;
|
|||
|
|
|
|||
|
|
//#define MY_TIM2_BASE 0x40000000U
|
|||
|
|
//#define MY_TIM2 ((TIM_RegTypeDef *)TIM2_BASE)
|
|||
|
|
|
|||
|
|
// Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ģ<DEB8>
|
|||
|
|
#ifndef TIM2_PRESCALER
|
|||
|
|
#define TIM2_PRESCALER 3999//7999 // 80MHz -> 10kHz
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef TIM2_PERIOD
|
|||
|
|
#define TIM2_PERIOD 49 // 5ms<6D><73>ʱ
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifndef TIM2_IRQ_PRIORITY
|
|||
|
|
#define TIM2_IRQ_PRIORITY 1 // <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD>
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#define TIM1_PRESCALER 7999//3999//7999 // 80MHz -> 10kHz
|
|||
|
|
#define TIM1_PERIOD 9 // 1ms<6D><73>ʱ
|
|||
|
|
#define TIM1_IRQ_PRIORITY 0 // <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD>
|
|||
|
|
|
|||
|
|
//extern unsigned char Time1s_flag;
|
|||
|
|
#define VIB_TIME_COUNT 1000 //<2F><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|||
|
|
#define VIB_THRESHOLD 100 //
|
|||
|
|
#define VIB_DISABLEDELAY 100
|
|||
|
|
#define VIB_INTERVAl 10//32//10 //n*5ms <20><>ʱ10ms
|
|||
|
|
#define VIB_INTERVAl_TIME 100//32//10 //n*5ms <20><>ʱ10ms
|
|||
|
|
|
|||
|
|
#define UARTOVERTIME 60
|
|||
|
|
|
|||
|
|
#define VIB_GETDATAMAXTIME 1000//3200//1000 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>2KHz
|
|||
|
|
#define VIB_GETWOBMAXTIME 200//3200//1000 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>200Hz
|
|||
|
|
|
|||
|
|
#define VIB_MINTIME_COUNT 60//3200//1000 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>200Hz
|
|||
|
|
|
|||
|
|
// <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>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);
|
|||
|
|
|
|||
|
|
//<2F>ⲿ<EFBFBD>жϳ<D0B6>ʼ<EFBFBD><CABC>
|
|||
|
|
// <20><>ʼ<EFBFBD><CABC>PB10Ϊ<30>½<EFBFBD><C2BD><EFBFBD><EFBFBD>ⲿ<EFBFBD>ж<EFBFBD>
|
|||
|
|
extern void PB10_EXTI_Init(void);
|
|||
|
|
// <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>жϻص<CFBB><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
extern void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endif
|
|||
|
|
|