📄 cxctcom.c
字号:
/*********************************************************
Copyright (c) CMX Company. 1999. All rights reserved
*********************************************************/
/* version 5.30 */
#define CMXMODULE 1
#include <cxfuncs.h> /* get cmx include header file */
#include <cxextern.h> /* get cmx include header file */
#ifdef CMXTRACKER
#include <cmxtrack.h> /* get cmx include header file */
#endif
/******************************************************************
This is the common routine that the most of the cyclic timer functions
will call. This function starts, or restarts a cyclic timer and possibly
also changes the cyclic timer's time parameters.
mode:
= 0: = just restart timer if not started
= 1: = change only initial time and start
= 2: = change only cyclic time and start
= 3: = change both initial time and cyclic time and start
**************************************************************************/
byte K_I_Cyclic_Common(byte timed_num,word16 timecnt, word16 cyclic,byte mode)
{
struct _tcproc *tpptr;
if (timed_num >= MAX_CYCLIC_TIMERS) /* have we exceeded the maximum number */
{
#ifdef CMXTRACKER
if (CMXTRACKER_ON)
{
cmxtracker_in2(CXCTCOM_K_ERROR,timed_num);
}
#endif
return(K_ERROR);
}
K_I_Disable_Sched(); /* set task block */
tpptr = &tcproc[timed_num]; /* get the CMX handler for this cyclic timer. */
if (mode & 0x01) /* see if mode bit 0 set. */
{
tpptr->tproc_timer = timecnt; /* load time period into counter */
}
if (mode & 0x02) /* see if mode bit 1 set. */
{
tpptr->reload_time = cyclic; /* load cyclic time into counter */
}
if (!(tpptr->tproc_start)) /* see if 0 */
{
tpptr->tproc_start = 1; /* start the timed procedure */
/* add to the cyclic timers doubly linked list. */
if (cyclic_lnk->ftlink != (struct _tcproc *)cyclic_lnk)
{
tpptr->ftlink = cyclic_lnk->btlink->ftlink;
cyclic_lnk->btlink->ftlink = tpptr;
tpptr->btlink = cyclic_lnk->btlink;
}
else
{
tpptr->ftlink = tpptr->btlink = (struct _tcproc *)cyclic_lnk;
cyclic_lnk->ftlink = tpptr;
}
cyclic_lnk->btlink = tpptr;
}
#ifdef CMXTRACKER
if (CMXTRACKER_ON)
{
if (mode == 3)
{
cmxtracker_in2(CXCTSTT_K_OK,timed_num);
}
else if (mode == 2)
{
cmxtracker_in2(CXCTRSTC_K_OK,timed_num);
}
else if (mode == 1)
{
cmxtracker_in2(CXCTRSTI_K_OK,timed_num);
}
else
{
cmxtracker_in2(CXCTRSTT_K_OK,timed_num);
}
}
#endif
K_I_Func_Return(); /* release task block */
return(K_OK); /* return good status */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -