📄 net_tmr.c
字号:
}
#endif
ptmr->Fnct = fnct;
ptmr->TmrVal = time;
*perr = NET_TMR_ERR_NONE;
}
/*$PAGE*/
/*
*********************************************************************************************************
* NetTmr_PoolStatGet()
*
* Description : Get network timer statistics pool.
*
* Argument(s) : none.
*
* Return(s) : Network timer statistics pool, if NO errors.
*
* NULL statistics pool, otherwise.
*
* Caller(s) : Application.
*
* This function is a network protocol suite application interface (API) function & MAY be
* called by application function(s).
*
* Note(s) : (1) NetTmr_PoolStatGet() blocked until network initialization completes; return NULL
* statistics pool.
*********************************************************************************************************
*/
NET_STAT_POOL NetTmr_PoolStatGet (void)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
CPU_SR cpu_sr;
#endif
#if (NET_ERR_CFG_ARG_CHK_EXT_EN == DEF_ENABLED)
NET_ERR err;
#endif
NET_STAT_POOL stat_pool;
#if (NET_ERR_CFG_ARG_CHK_EXT_EN == DEF_ENABLED)
if (Net_InitDone != DEF_YES) { /* If init NOT complete, ... */
NetStat_PoolClr(&stat_pool, &err);
return (stat_pool); /* ... rtn NULL stat pool (see Note #1). */
}
#endif
CPU_CRITICAL_ENTER();
stat_pool = NetTmr_PoolStat;
CPU_CRITICAL_EXIT();
return (stat_pool);
}
/*$PAGE*/
/*
*********************************************************************************************************
* NetTmr_PoolStatResetMaxUsed()
*
* Description : Reset network timer statistics pool's maximum number of entries used.
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : Application.
*
* This function is a network protocol suite application interface (API) function & MAY be
* called by application function(s).
*
* Note(s) : none.
*********************************************************************************************************
*/
void NetTmr_PoolStatResetMaxUsed (void)
{
NET_ERR err;
NetStat_PoolResetUsedMax(&NetTmr_PoolStat, &err);
}
/*$PAGE*/
/*
*********************************************************************************************************
*********************************************************************************************************
* LOCAL FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* NetTmr_Clr()
*
* Description : Clear network timer controls.
*
* Argument(s) : ptmr Pointer to a network timer.
* ---- Argument validated in NetTmr_Init(),
* NetTmr_Free().
*
* Return(s) : none.
*
* Caller(s) : NetTmr_Init(),
* NetTmr_Free().
*
* Note(s) : none.
*********************************************************************************************************
*/
#if (NET_DBG_CFG_MEM_CLR_EN == DEF_ENABLED)
static void NetTmr_Clr (NET_TMR *ptmr)
{
ptmr->PrevPtr = (void *)0;
ptmr->NextPtr = (void *)0;
ptmr->Obj = (void *)0;
ptmr->Fnct = (CPU_FNCT_PTR)0;
ptmr->TmrVal = NET_TMR_TIME_0S;
ptmr->Flags = NET_TMR_FLAG_NONE;
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* NetTmr_Discard()
*
* Description : (1) Discard an invalid/corrupted network timer :
*
* (a) Discard timer from available timer pool See Note #2
* (b) Update timer pool statistics
*
* (2) Assumes timer is invalid/corrupt & MUST be removed. Timer removed simply by NOT
* returning the timer back to the timer pool.
*
*
* Argument(s) : ptmr Pointer to an invalid/corrupted network timer.
* ---- Argument checked in NetTmr_Get(),
* NetTmr_Free(),
* NetTmr_Set().
*
* Return(s) : none.
*
* Caller(s) : NetTmr_Get(),
* NetTmr_Free(),
* NetTmr_Set().
*
* Note(s) : none.
*********************************************************************************************************
*/
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
static void NetTmr_Discard (NET_TMR *ptmr)
{
NET_ERR stat_err;
/* ------------------- DISCARD TMR -------------------- */
(void)&ptmr; /* Prevent compiler warning (see Note #2). */
/* --------------- UPDATE DISCARD STATS --------------- */
NetStat_PoolEntryLostInc(&NetTmr_PoolStat, &stat_err);
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* NetTmr_DiscardTaskTmr()
*
* Description : (1) Discard a corrupted Timer Task List timer :
*
* (a) Unlink Timer Task timer from Timer Task List
*
* (1) Consequently, any valid or corrupted network timers that may have been linked
* following the corrupted Timer Task timer in the Timer Task List are :
*
* (A) Unlinked from the Timer Task List; ...
* (B) Discarded/lost without :
* (1) possibility of recovery; ...
* (2) measure of the number of network timers lost.
*
* See also 'NetTmr_TaskHandler() Note #4b1A'.
*
* (b) Discard Timer Task timer
*
* (1) Discard the following invalid/corrupted timers :
*
* (A) Invalid Timer Type
*
* (2) Do NOT discard the following invalid timers :
*
* (A) Unused timers
*
* (c) Clear Timer Task timer pointer
*
*
* (2) (a) Assumes Timer Task List timer ('NetTmr_TaskListPtr') is already corrupted.
*
* (b) Assumes ALL timers in Timer Task List prior to Timer Task List timer are valid.
*
* See also 'NetTmr_TaskHandler() Note #4b'.
*
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : NetTmr_TaskHandler().
*
* Note(s) : none.
*********************************************************************************************************
*/
#if (NET_ERR_CFG_ARG_CHK_DBG_EN == DEF_ENABLED)
static void NetTmr_DiscardTaskTmr (void)
{
NET_TMR *ptmr;
NET_TMR *pprev;
CPU_BOOLEAN discard;
ptmr = (NET_TMR *)NetTmr_TaskListHead;
pprev = (NET_TMR *)0;
while ((ptmr != (NET_TMR *)0) && /* Srch entire Tmr Task List ... */
(ptmr != (NET_TMR *)NetTmr_TaskListPtr)) { /* ... for corrupted tmr task ptr (see Note #2a). */
pprev = (NET_TMR *)ptmr;
ptmr = (NET_TMR *)ptmr->NextPtr;
}
/* Unlink corrupted tmr task ptr from Tmr Task List : */
if (pprev != (NET_TMR *)0) { /* If NOT @ head of Tmr Task List, ... */
pprev->NextPtr = (void *)0; /* ... clr prev tmr's next tmr. */
} else { /* Else clr Tmr Task List. */
NetTmr_TaskListHead = (NET_TMR *)0;
}
/* Discard invalid Tmr Task tmr (see Note #1b1). */
discard = (NetTmr_TaskListPtr->Type != NET_TMR_TYPE_TMR) ? DEF_YES : DEF_NO;
if (discard == DEF_YES) {
NetTmr_Discard(NetTmr_TaskListPtr);
}
NetTmr_TaskListPtr = (NET_TMR *)0; /* Clr Tmr Task ptr. */
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -