#include "BspPhy.h"
uint8_t TimerFlag;
//****************************************************************
//****** 定时器6初始化函数
//****** 输入参数: 无
//****** 返回值: 无
//****************************************************************
void PhyTimerInit()
{
CRM->apb1en_bit.tmr6en = 1;
TMR6->pr = psc; //周期值
TMR6->div = arr; // 分频系数
TMR6->swevt_bit.ovfswtr = TRUE; //软件触发溢出事件
TMR6->ctrl1_bit.cnt_dir = 0; //向上数
TMR6->iden = 1; //溢出中断使能
TMR6->ctrl1_bit.tmren = 1; //使能定时器
nvic_priority_group_config(NVIC_PRIORITY_GROUP_1);
nvic_irq_enable(TMR6_GLOBAL_IRQn, 1, 1);
}
//****************************************************************
//****** 定时器6中断处理函数
//****** 输入参数: 无
//****** 返回值: 无
//****************************************************************
void TMR6_GLOBAL_IRQHandler()
{
if(TMR6->ists_bit.ovfif == 1)
{
TimerFlag = 1;
TMR6->ists_bit.ovfif = 0;
}
}
/******************************Timer**************************************/
#define SET100MS
#ifdef SET100MS
#define arr (1000-1)
#define psc (12000-1)
#endif
#ifdef SET500MS
#define arr (5000-1)
#define psc (12000-1)
#endif
#ifdef SET1000MS
#define arr (5000-1)
#define psc (10800-1)
#endif
void PhyTimerInit(void);
/*************************************************************************/