📄 enabletimer.c
字号:
/*
* File : RZKEnableTimer.c
*
* Description : This file contains the RZKEnableTimer function
* which wakes up the timer
*
* Copyright 2004 ZiLOG Inc. ALL RIGHTS RESERVED.
*
* This file contains unpublished confidential and proprietary information
* of ZiLOG, Inc.
* NO PART OF THIS WORK MAY BE DUPLICATED, STORED, PUBLISHED OR DISCLOSED
* IN ANY FORM WITHOUT THE PRIOR WRITTEN CONSENT OF ZiLOG, INC.
* This is not a license and no use of any kind of this work is authorized
* in the absence of a written license granted by ZiLOG, Inc. in ZiLOG's
* sole discretion
*/
#include "ZSysgen.h"
#include "ZTypes.h"
#include "ZThread.h"
#include "ZQueue.h"
#include "ZTimer.h"
#define pTimer ((RZK_TIMER_t *) hTimer)
#define pCurrentThread ((RZK_TCB_t *) hCurrentThread)
extern void AddToTimeQ1 ( RZK_TCB_t * pObjectToAdd );
/** extern variables */
extern RZK_HANDLE_t hCurrentThread;
extern TICK_t tRZKTicks;
/*
* Function : RZKEnableTimer
*
* Description : This function enables a software timer and adds it to Time Queue1
*
* Inputs : hTimer - handle to timer object
*
* Outputs : RZKERR_INVALID_HANDLE - handle of the timer object is invalid.
* RZKERR_CB_BUSY - timer control block is being exclusively used by another object.
* RZKERR_SUCCESS - timer object is enabled
*
* Dependencies : None
*/
RZK_STATUS_t RZKEnableTimer(
RZK_TIMERHANDLE_t hTimer
)
{
/* Parameter Validation */
#ifdef RZK_DEBUG
if((pTimer == NULL)||(pTimer->uState == 0) || (pTimer->magic_num != MAGIC_NUM_TIMER))
return RZKERR_INVALID_HANDLE;
#endif
#ifndef RZK_PERFORMANCE
if(!(pTimer->uState & OBJECT_CREATED))
return RZKERR_CB_BUSY;
#endif
#ifndef RZK_PERFORMANCE
if(!(pTimer->uState & TIMER_DISABLE))
return RZKERR_OBJECT_IN_USE;
#endif
pTimer -> uState = (TIMER_RUNNING | OBJECT_BUSY | OBJECT_CREATED);
/* Set the statistics parameters */
#ifdef RZK_STATISTIC
pTimer->uFuncExecutionCount = 0;
pTimer->tMinTimeOfFuncEntry = MAX_INFINITE_SUSPEND;
pTimer->tMaxTimeOfFuncEntry = 0;
pTimer->tPrevTimeOfFuncEntry = tRZKTicks;
#endif
/* Initialize the wait time */
pTimer->tWaitTime = (pTimer->tInitialTime != 0) ? pTimer->tInitialTime : pTimer->tPeriod ;
AddToTimeQ1((RZK_TCB_t *)pTimer);
return RZKERR_SUCCESS;
} /* end of RZKEnableTimer */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -