1 Star 0 Fork 0

Fulgora/STM8S-Library

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
sys_timer.h 2.31 KB
一键复制 编辑 原始数据 按行查看 历史
tim 提交于 2014-08-25 17:59 . Add library files
/**
******************************************************************************
* @file sys_timer.h
* @author Khusainov Timur
* @version 0.0.0.4
* @date 18.01.2012
* @brief System interval timer (ms)
******************************************************************************
* @attention
* <h2><center>&copy; COPYRIGHT timyik@gmail.com </center></h2>
******************************************************************************
*/
#ifndef BSP_SYS_TIMER_H
#define BSP_SYS_TIMER_H
//------------------------------------------------------------------------------
typedef uint16_t tBSP_SysTimerType;
extern volatile tBSP_SysTimerType BSP_SysTimer;
#define BSP_SysTimerGet() (BSP_SysTimer)
#define BSP_SysTimerSet(t) (BSP_SysTimer = t)
//------------------------------------------------------------------------------
enum {BSP_SYS_TIMER_DISCRETE_MS = (1)};
#define BSP_SysTimerCalcMs(value) (value/BSP_SYS_TIMER_DISCRETE_MS)
#define BSP_SysTimerCalcSec(value) ((value * 1000)/BSP_SYS_TIMER_DISCRETE_MS)
//------------------------------------------------------------------------------
typedef struct
{
tBSP_SysTimerType TimeStart;
tBSP_SysTimerType TimeNeed;
} tBSP_SysTimer;
#define BSP_SysTimerNew(m_st, m_time_need)\
do\
{\
m_st.TimeStart = BSP_SysTimerGet();\
m_st.TimeNeed = m_time_need;\
} while(0)
#define BSP_SysTimerRe(m_st)\
do\
{\
m_st.TimeStart = BSP_SysTimerGet();\
} while(0)
#define BSP_SysTimerCheck(m_st) ((BSP_SysTimer - m_st.TimeStart) >= m_st.TimeNeed)
#define BSP_SysTimerOver(m_st) ((tBSP_SysTimerType)(BSP_SysTimer - m_st.TimeStart))
//------------------------------------------------------------------------------
typedef enum
{
BSP_SYS_TIMER_STATE_NOINIT = 0,
BSP_SYS_TIMER_STATE_STOP,
BSP_SYS_TIMER_STATE_RUN
} tBSP_SysTimerState;
extern volatile tBSP_SysTimerState BSP_SysTimerState;
#define BSP_SysTimerGetState() (BSP_SysTimerState)
//------------------------------------------------------------------------------
void BSP_InitSysTimer(void);
void BSP_StartSysTimer(void);
void BSP_StopSysTimer(void);
#define BSP_RestartSysTimer() do{BSP_SysTimerSet(0);}while(0)
//------------------------------------------------------------------------------
#endif // BSP_SYS_TIMER_H
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Fulgora/STM8S-Library.git
git@gitee.com:Fulgora/STM8S-Library.git
Fulgora
STM8S-Library
STM8S-Library
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385