📄 watch.c
字号:
/*
********************************************************************************
* Copyright (c) 2004, Comba Telecom System
* All Rights Reserved
*
* File Name : watch.c
* Purpose : 钟表定时处理
* Revision history
------------------
V1.0,2004/06/22,Ldn 创建
********************************************************************************
*/
/* includes */
#define _WATCH_VAR_EXT
#include "config.h"
///设定超时时间
void watchReset(WATCH *pWatch)
{
pWatch->bOn = FALSE;
pWatch->bOver = FALSE;
pWatch->hour = 0;
pWatch->min = 0;
pWatch->second = 0;
pWatch->ms = 0;
pWatch->needTicks = 0;
pWatch->startTicks = OSTimeGet();
}
///设定超时时间
void watchSetTimeout(WATCH *pWatch, INT8U hour, INT8U min, INT8U second, INT8U ms)
{
pWatch->bOn = TRUE;
pWatch->bOver = FALSE;
pWatch->hour = hour;
pWatch->min = min;
pWatch->second = second;
pWatch->ms = ms;
pWatch->needTicks = ( (INT32U)pWatch->hour * 3600L
+ (INT32U)pWatch->min * 60L
+ (INT32U)pWatch->second ) * OS_TICKS_PER_SEC
+ OS_TICKS_PER_SEC * ( (INT32U) pWatch->ms + 500L / OS_TICKS_PER_SEC) / 1000L;
pWatch->startTicks = OSTimeGet();
}
//钟表时间计数
void watchRun(WATCH *pWatch)
{
INT32U nowTicks;
if ( pWatch->bOn && (! pWatch->bOver ) )
{
nowTicks = OSTimeGet();
if (nowTicks >= pWatch->startTicks )
{
if (nowTicks - pWatch->startTicks >= pWatch->needTicks)
{
//超时发生
pWatch->bOver = TRUE;
}
}
else
{
if (nowTicks + (~ pWatch->startTicks) >= pWatch->needTicks)
{
//超时发生
pWatch->bOver = TRUE;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -