stm32_ota/USER/GATE_TIMER/gate_timer.c

94 lines
3.3 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "gate_timer.h"
/********************************************************************************
* @file gate_timer.c
* @author 晏诚科技 Mr.Wang
* @version V1.0.0
* @date 11-Dec-2018
* @brief timer封装
******************************************************************************
* @attention:
*******************************************************************************/
/*****************************************
*驱动内部使用常变量
****************************************/
volatile uint32_t systickCount = 0 ;
/**************************************************************************************************
* 名 称: void CalculateTimerInit(void)
* 功 能: 使用TIMER7作为节拍计数器100ms中断一次
***************************************************************************************************/
void CalculateTimerInit(void)
{
Timerx_Init(TIMER7, 100, INT_RANK_14, DISABLE) ; //100ms中断一次
Timer_RegHookCallback(TIMER7, CalculateRunTime) ;
}
///**************************************************************************************************
//* 名 称: void Calculate_Timer_Init(void)
//* 功 能: 使用TIMER6作为OLED刷新显示时间定时器 1s中断一次
//***************************************************************************************************/
//void TimeRefreshTimerInit(void)
//{
// Timerx_Init(TIMER6, 1*1000, INT_RANK_15, DISABLE) ; //6s中断一次
// Timer_RegHookCallback(TIMER6, GreenLight_Timer) ;
//}
//void GreenLight_Timer(void)
//{
//}
///**************************************************************************************************
//* 名 称: void GreenLight_Timer_Start(void)
//* 功 能: 开启计时器
//***************************************************************************************************/
//void GreenLight_Timer_Start(void)
//{
// Timerx_Open(TIMER6) ;
//}
///**************************************************************************************************
//* 名 称: void GreenLight_Timer_Start(void)
//* 功 能: 结束节拍计时器并返回节拍数
//***************************************************************************************************/
//void GreenLight_Timer_Over(void)
//{
// Timerx_Close(TIMER6) ;
//}
/**************************************************************************************************
* 名 称: void CalculateStart(void)
* 功 能: 开启计时器
***************************************************************************************************/
void CalculateStart(void)
{
Timerx_Open(TIMER7) ;
systickCount = 0 ;
}
/**************************************************************************************************
* 名 称: uint32_t CalculateOver(void)
* 功 能: 结束节拍计时器并返回节拍数
***************************************************************************************************/
uint32_t CalculateOver(void)
{
Timerx_Close(TIMER7) ;
return systickCount ;
}
/**************************************************************************************************
* 名 称: void CalculateRunTime(void)
* 功 能: 节拍计时器timer7中断回调函数
***************************************************************************************************/
void CalculateRunTime(void)
{
systickCount++ ;
if( systickCount >= 0xFFFFFFFF) //systickCount溢出
{
systickCount = 0 ;
}
}