亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? os_tmr.c

?? uCos_II到ARM7的移植
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
************************************************************************************************************************
*                                                      uC/OS-III
*                                                 The Real-Time Kernel
*
*                                     (c) Copyright 2005-2006, Micrium, Weston, FL
*                                                  All Rights Reserved
*
*                                                   TIMER MANAGEMENT
*
* File    : OS_TMR.C
* By      : Jean J. Labrosse
* Version : V2.83
************************************************************************************************************************
*/

#include <ucos_ii.h>

/*
************************************************************************************************************************
*                                                        NOTES
*
* 1) Your application MUST define the following #define constants:
*
*    OS_TASK_TMR_PRIO          The priority of the Timer management task
*    OS_TASK_TMR_STK_SIZE      The size     of the Timer management task's stack
*
* 2) You must call OSTmrSignal() to notify the Timer management task that it's time to update the timers.
************************************************************************************************************************
*/

/*
************************************************************************************************************************
*                                                     CONSTANTS
************************************************************************************************************************
*/

#define  OS_TMR_LINK_DLY       0
#define  OS_TMR_LINK_PERIODIC  1

/*
************************************************************************************************************************
*                                                  LOCAL PROTOTYPES
************************************************************************************************************************
*/

#if OS_TMR_EN > 0
static  OS_TMR  *OSTmr_Alloc         (void);
static  void     OSTmr_Free          (OS_TMR *ptmr);
static  void     OSTmr_InitTask      (void);
static  void     OSTmr_Link          (OS_TMR *ptmr, INT8U type);
static  void     OSTmr_Unlink        (OS_TMR *ptmr);
static  void     OSTmr_Lock          (void);
static  void     OSTmr_Unlock        (void);
static  void     OSTmr_Task          (void   *p_arg);
#endif

/*$PAGE*/
/*
************************************************************************************************************************
*                                                   CREATE A TIMER
*
* Description: This function is called by your application code to create a timer.
*
* Arguments  : dly           Initial delay.
*                            If the timer is configured for ONE-SHOT mode, this is the timeout used
*                            If the timer is configured for PERIODIC mode, this is the first timeout to wait for
*                               before the timer starts entering periodic mode
*
*              period        The 'period' being repeated for the timer.
*                               If you specified 'OS_TMR_OPT_PERIODIC' as an option, when the timer expires, it will
*                               automatically restart with the same period.
*
*              opt           Specifies either:
*                               OS_TMR_OPT_ONE_SHOT       The timer counts down only once
*                               OS_TMR_OPT_PERIODIC       The timer counts down and then reloads itself
*
*              callback      Is a pointer to a callback function that will be called when the timer expires.  The
*                               callback function must be declared as follows:
*
*                               void MyCallback (OS_TMR *ptmr, void *p_arg);
*
*              callback_arg  Is an argument (a pointer) that is passed to the callback function when it is called.
*
*              pname         Is a pointer to an ASCII string that is used to name the timer.  Names are useful for
*                               debugging.  The length of the ASCII string for the name can be as big as:
*
*                               OS_TMR_CFG_NAME_SIZE and should be found in OS_CFG.H
*
*              perr          Is a pointer to an error code.  '*perr' will contain one of the following:
*                               OS_NO_ERR
*                               OS_ERR_TMR_INVALID_DLY     you specified an invalid delay
*                               OS_ERR_TMR_INVALID_PERIOD  you specified an invalid period
*                               OS_ERR_TMR_INVALID_OPT     you specified an invalid option
*                               OS_ERR_TMR_ISR             if the call was made from an ISR
*                               OS_ERR_TMR_NON_AVAIL       if there are no free timers from the timer pool
*                               OS_ERR_TMR_NAME_TOO_LONG   if the timer name is too long to fit
*
* Returns    : A pointer to an OS_TMR data structure.  This is the 'handle' that you application will use to reference
*              the timer created/started.
************************************************************************************************************************
*/

#if OS_TMR_EN > 0
OS_TMR  *OSTmrCreate (INT32U           dly,
                      INT32U           period,
                      INT8U            opt,
                      OS_TMR_CALLBACK  callback,
                      void            *callback_arg,
                      INT8U           *pname,
                      INT8U           *perr)
{
    OS_TMR   *ptmr;
#if OS_TMR_CFG_NAME_SIZE > 0
    INT8U     len;
#endif


#if OS_ARG_CHK_EN > 0
    if (perr == (INT8U *)0) {                               /* Validate arguments                                     */
        return ((OS_TMR *)0);
    }
    switch (opt) {
        case OS_TMR_OPT_PERIODIC:
             if (period == 0) {
                 *perr = OS_ERR_TMR_INVALID_PERIOD;
                 return ((OS_TMR *)0);
             }
             break;

        case OS_TMR_OPT_ONE_SHOT:
             if (dly == 0) {
                 *perr = OS_ERR_TMR_INVALID_DLY;
                 return ((OS_TMR *)0);
             }
             break;

        default:
             *perr = OS_ERR_TMR_INVALID_OPT;
             return ((OS_TMR *)0);
    }
#endif
    if (OSIntNesting > 0) {                                 /* See if trying to call from an ISR                      */
        *perr  = OS_ERR_TMR_ISR;
        return ((OS_TMR *)0);
    }
    OSTmr_Lock();
    ptmr = OSTmr_Alloc();                                   /* Obtain a timer from the free pool                      */
    if (ptmr == (OS_TMR *)0) {
        OSTmr_Unlock();
        *perr = OS_ERR_TMR_NON_AVAIL;
        return ((OS_TMR *)0);
    }
    ptmr->OSTmrState       = OS_TMR_STATE_STOPPED;          /* Indicate that timer is not running yet                 */
    ptmr->OSTmrDly         = dly;
    ptmr->OSTmrPeriod      = period;
    ptmr->OSTmrOpt         = opt;
    ptmr->OSTmrCallback    = callback;
    ptmr->OSTmrCallbackArg = callback_arg;
#if OS_TMR_CFG_NAME_SIZE > 0
    if (pname !=(INT8U *)0) {
        len = OS_StrLen(pname);                             /* Copy timer name                                        */
        if (len < OS_TMR_CFG_NAME_SIZE) {
            (void)OS_StrCopy(ptmr->OSTmrName, pname);
        } else {
#if OS_TMR_CFG_NAME_SIZE > 1
            ptmr->OSTmrName[0] = '#';                       /* Invalid size specified                                 */
            ptmr->OSTmrName[1] = OS_ASCII_NUL;
#endif
            *perr              = OS_ERR_TMR_NAME_TOO_LONG;
            OSTmr_Unlock();
            return (ptmr);
        }
    }
#endif
    OSTmr_Unlock();
    *perr = OS_NO_ERR;
    return (ptmr);
}
#endif

/*$PAGE*/
/*
************************************************************************************************************************
*                                                   DELETE A TIMER
*
* Description: This function is called by your application code to delete a timer.
*
* Arguments  : ptmr          Is a pointer to the timer to stop and delete.
*
*              perr          Is a pointer to an error code.  '*perr' will contain one of the following:
*                               OS_NO_ERR
*                               OS_ERR_TMR_INVALID        'ptmr'  is a NULL pointer
*                               OS_ERR_TMR_INVALID_TYPE   'ptmr'  is not pointing to an OS_TMR
*                               OS_ERR_TMR_ISR            if the function was called from an ISR
*                               OS_ERR_TMR_INACTIVE       if the timer was not created
*                               OS_ERR_TMR_INVALID_STATE  the timer is in an invalid state
*
* Returns    : OS_TRUE       If the call was successful
*              OS_FALSE      If not
************************************************************************************************************************
*/

#if OS_TMR_EN > 0
BOOLEAN  OSTmrDel (OS_TMR  *ptmr,
                   INT8U   *perr)
{
#if OS_ARG_CHK_EN > 0
    if (perr == (INT8U *)0) {                               /* Validate arguments                                     */
        return (OS_FALSE);
    }
    if (ptmr == (OS_TMR *)0) {
        *perr = OS_ERR_TMR_INVALID;
        return (OS_FALSE);
    }
#endif
    if (ptmr->OSTmrType != OS_TMR_TYPE) {                   /* Validate timer structure                               */
        *perr = OS_ERR_TMR_INVALID_TYPE;
        return (OS_FALSE);
    }
    if (OSIntNesting > 0) {                                 /* See if trying to call from an ISR                      */
        *perr  = OS_ERR_TMR_ISR;
        return (OS_FALSE);
    }
    OSTmr_Lock();
    switch (ptmr->OSTmrState) {
        case OS_TMR_STATE_RUNNING:
             OSTmr_Unlink(ptmr);                            /* Remove from current wheel spoke                        */
             OSTmr_Free(ptmr);                              /* Return timer to free list of timers                    */
             OSTmr_Unlock();
             *perr = OS_NO_ERR;
             return (OS_TRUE);

        case OS_TMR_STATE_STOPPED:                          /* Timer has not started or ...                           */
        case OS_TMR_STATE_COMPLETED:                        /* ... timer has completed the ONE-SHOT time              */
             OSTmr_Free(ptmr);                              /* Return timer to free list of timers                    */
             OSTmr_Unlock();
             *perr = OS_NO_ERR;
             return (OS_TRUE);

        case OS_TMR_STATE_UNUSED:                           /* Already deleted                                        */
             OSTmr_Unlock();
             *perr = OS_ERR_TMR_INACTIVE;
             return (OS_FALSE);

        default:
             OSTmr_Unlock();
             *perr = OS_ERR_TMR_INVALID_STATE;
             return (OS_FALSE);
    }
}
#endif

/*$PAGE*/
/*
************************************************************************************************************************
*                                             GET THE NAME OF A TIMER
*
* Description: This function is called to obtain the name of a timer.
*
* Arguments  : ptmr          Is a pointer to the timer to obtain the name for
*
*              pdest         Is a pointer to where the name of the timer will be placed.  It is the caller's responsibility
*                            to ensure that he has sufficient storage in the destination, i.e. at least OS_TMR_CFG_NAME_SIZE
*
*              perr          Is a pointer to an error code.  '*perr' will contain one of the following:
*                               OS_NO_ERR                 The call was successful
*                               OS_ERR_TMR_INVALID_DEST   'pdest' is a NULL pointer
*                               OS_ERR_TMR_INVALID        'ptmr'  is a NULL pointer
*                               OS_ERR_TMR_INVALID_TYPE   'ptmr'  is not pointing to an OS_TMR
*                               OS_ERR_TMR_ISR            if the call was made from an ISR
*                               OS_ERR_TMR_INACTIVE       'ptmr'  points to a timer that is not active
*                               OS_ERR_TMR_INVALID_STATE  the timer is in an invalid state
*
* Returns    : The length of the string or 0 if the timer does not exist.
************************************************************************************************************************
*/

#if OS_TMR_EN > 0 && OS_TMR_CFG_NAME_SIZE > 0
INT8U  OSTmrNameGet (OS_TMR  *ptmr,
                     INT8U   *pdest,
                     INT8U   *perr)
{
    INT8U  len;


#if OS_ARG_CHK_EN > 0
    if (perr == (INT8U *)0) {
        return (0);
    }
    if (pdest == (INT8U *)0) {
        *perr = OS_ERR_TMR_INVALID_DEST;
        return (0);
    }
    if (ptmr == (OS_TMR *)0) {
        *perr = OS_ERR_TMR_INVALID;
        return (0);
    }
#endif
    if (ptmr->OSTmrType != OS_TMR_TYPE) {              /* Validate timer structure                                    */
        *perr = OS_ERR_TMR_INVALID_TYPE;
        return (0);
    }
    if (OSIntNesting > 0) {                            /* See if trying to call from an ISR                           */
        *perr  = OS_ERR_TMR_ISR;
        return (0);
    }
    OSTmr_Lock();
    switch (ptmr->OSTmrState) {
        case OS_TMR_STATE_RUNNING:
        case OS_TMR_STATE_STOPPED:
        case OS_TMR_STATE_COMPLETED:
             len   = OS_StrCopy(pdest, ptmr->OSTmrName);
             OSTmr_Unlock();
             *perr = OS_NO_ERR;
             return (len);

        case OS_TMR_STATE_UNUSED:                      /* Timer is not allocated                                      */
             OSTmr_Unlock();
             *perr = OS_ERR_TMR_INACTIVE;
             return (0);

        default:
             OSTmr_Unlock();
             *perr = OS_ERR_TMR_INVALID_STATE;
             return (0);
    }
}
#endif

/*$PAGE*/
/*
************************************************************************************************************************
*                                    GET HOW MUCH TIME IS LEFT BEFORE A TIMER EXPIRES
*
* Description: This function is called to get the number of ticks before a timer times out.
*
* Arguments  : ptmr          Is a pointer to the timer to obtain the remaining time from.
*
*              perr          Is a pointer to an error code.  '*perr' will contain one of the following:
*                               OS_NO_ERR
*                               OS_ERR_TMR_INVALID        'ptmr' is a NULL pointer
*                               OS_ERR_TMR_INVALID_TYPE   'ptmr'  is not pointing to an OS_TMR
*                               OS_ERR_TMR_ISR            if the call was made from an ISR
*                               OS_ERR_TMR_INACTIVE       'ptmr' points to a timer that is not active
*                               OS_ERR_TMR_INVALID_STATE  the timer is in an invalid state
*
* Returns    : The time remaining for the timer to expire.  The time represents 'timer' increments.  In other words, if
*              OSTmr_Task() is signaled every 1/10 of a second then the returned value represents the number of 1/10 of
*              a second remaining before the timer expires.
************************************************************************************************************************
*/

#if OS_TMR_EN > 0
INT32U  OSTmrRemainGet (OS_TMR  *ptmr,
                        INT8U   *perr)
{
    INT32U  remain;


#if OS_ARG_CHK_EN > 0
    if (perr == (INT8U *)0) {
        return (0);
    }
    if (ptmr == (OS_TMR *)0) {
        *perr = OS_ERR_TMR_INVALID;
        return (0);
    }
#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区久久| 亚洲欧美另类久久久精品2019| 久久精品国产成人一区二区三区| 亚洲亚洲人成综合网络| 久久久亚洲精品一区二区三区| 欧美精品免费视频| 欧美一区二区三区免费在线看 | 不卡一二三区首页| av综合在线播放| 欧美在线免费播放| 色婷婷精品久久二区二区蜜臀av| 91亚洲精品一区二区乱码| 在线免费亚洲电影| 欧美一区二区三区视频在线观看| 精品精品国产高清a毛片牛牛 | 国产精品入口麻豆九色| 国产精品女上位| 亚洲女同一区二区| 免费美女久久99| 成人午夜免费电影| 欧美理论片在线| 欧美经典一区二区| 一区二区久久久久久| 久久疯狂做爰流白浆xx| 日本精品一区二区三区四区的功能| 欧美午夜在线观看| 中文字幕一区二区三区在线观看| 亚洲乱码精品一二三四区日韩在线| 午夜视黄欧洲亚洲| 91美女片黄在线观看91美女| 日韩网站在线看片你懂的| 久久麻豆一区二区| 日韩不卡在线观看日韩不卡视频| 极品美女销魂一区二区三区 | 99久久99精品久久久久久| 日韩一级二级三级精品视频| 一级特黄大欧美久久久| 高清在线不卡av| 精品av综合导航| 亚洲激情第一区| 欧美日韩精品一区二区天天拍小说| 久久久99精品免费观看| 奇米精品一区二区三区在线观看一| 色综合久久久久网| 午夜电影一区二区三区| 色婷婷精品久久二区二区蜜臀av| 欧美国产一区在线| 国产成人丝袜美腿| 国产精品的网站| 色94色欧美sute亚洲13| 天天综合日日夜夜精品| 在线观看av不卡| 日韩精品欧美精品| 日本一区二区免费在线| 欧美伊人久久久久久午夜久久久久| 亚洲欧美日韩精品久久久久| 欧美猛男超大videosgay| 视频一区视频二区中文字幕| 久久亚区不卡日本| 国产mv日韩mv欧美| 亚洲精品v日韩精品| 欧美老人xxxx18| 成人爱爱电影网址| 日韩福利电影在线观看| 精品国产伦一区二区三区免费| 国产传媒欧美日韩成人| 亚洲欧美激情一区二区| 亚洲精品一线二线三线| 岛国精品一区二区| 九九视频精品免费| 一区二区三区日韩精品| 国产欧美日韩综合| 精品国产一区二区三区忘忧草| www.日韩av| 国产在线一区二区综合免费视频| 亚洲一区二区三区在线| 日本一区二区三区电影| 日韩一区二区免费视频| 色悠久久久久综合欧美99| 国产一区二区三区免费看| 午夜伦欧美伦电影理论片| 国产欧美日韩不卡免费| 日韩一区二区三区电影在线观看 | 欧洲激情一区二区| 欧美中文字幕一区二区三区| 成人少妇影院yyyy| 国产一区二区三区香蕉| 国内成人精品2018免费看| 日韩精品91亚洲二区在线观看 | 免费观看在线色综合| 五月综合激情日本mⅴ| 石原莉奈在线亚洲三区| 午夜精品久久一牛影视| 午夜欧美2019年伦理| 日韩激情一区二区| 国产精品99久久久久久有的能看 | 精品国产成人系列| 久久综合狠狠综合久久综合88| 欧美视频在线一区二区三区| 欧美日韩在线三区| 欧美成人在线直播| 国产人成一区二区三区影院| 国产精品水嫩水嫩| 艳妇臀荡乳欲伦亚洲一区| 免费国产亚洲视频| 欧日韩精品视频| 日韩视频免费观看高清完整版在线观看 | 久久精品国产亚洲5555| 五月天视频一区| 成人小视频在线观看| 欧美日本一区二区在线观看| 精品国产伦一区二区三区观看方式| 国产欧美日韩另类一区| 亚洲成人综合在线| 成人午夜av在线| 精品久久久三级丝袜| 亚洲在线视频一区| 国产精品一区二区免费不卡 | 午夜精品福利在线| av动漫一区二区| 国产精品久久影院| 蜜臀av性久久久久蜜臀aⅴ流畅 | 欧美国产日韩一二三区| 亚洲一区二区三区三| 91亚洲男人天堂| 国产精品久久久久永久免费观看| 日本亚洲电影天堂| 欧美精品少妇一区二区三区| 亚洲高清中文字幕| 欧美日精品一区视频| 亚洲免费在线视频| 97se亚洲国产综合自在线不卡 | 一区二区三区欧美在线观看| 日本高清不卡一区| 亚洲成人综合视频| 欧美成人艳星乳罩| 国模少妇一区二区三区| 国产午夜精品久久| 91原创在线视频| 一区二区三区不卡视频| 欧美日韩高清一区| 蜜桃精品视频在线| 国产日韩av一区| 丁香婷婷综合五月| 久久精品视频一区二区| 国产精品69毛片高清亚洲| 国产女人18水真多18精品一级做| 国产成人免费视频一区| 亚洲欧美另类久久久精品| 欧美情侣在线播放| 国产精品亚洲第一区在线暖暖韩国 | 99热在这里有精品免费| 日日夜夜精品免费视频| 国产偷v国产偷v亚洲高清| 精东粉嫩av免费一区二区三区| 久久久久久亚洲综合| 欧美色欧美亚洲另类二区| 国产中文字幕精品| 五月婷婷综合网| 中文字幕 久热精品 视频在线| 884aa四虎影成人精品一区| 国产成人午夜高潮毛片| 久久国产生活片100| 亚洲精品视频一区| 久久综合久久久久88| 日韩一区二区视频| 欧美吻胸吃奶大尺度电影| 国产福利精品一区二区| 国产一二精品视频| 男人操女人的视频在线观看欧美| 中文字幕一区三区| 亚洲视频小说图片| 亚洲chinese男男1069| 亚洲综合999| 一区二区三区国产精华| 国产无人区一区二区三区| 久久亚洲一区二区三区明星换脸| 91国产免费看| 在线观看不卡视频| 日韩亚洲欧美中文三级| 欧美久久久久久蜜桃| 91精品国产综合久久蜜臀 | 久久理论电影网| 国产人成亚洲第一网站在线播放| 久久久精品国产99久久精品芒果| 精品乱码亚洲一区二区不卡| 久久久国际精品| 国产女人18水真多18精品一级做| 久久精品在这里| 亚洲日本电影在线| 亚洲.国产.中文慕字在线| 久久精品国产亚洲5555| 懂色av一区二区在线播放| 色综合天天天天做夜夜夜夜做| 99久久精品国产导航| 欧美日韩一区二区三区视频| 欧美电影在线免费观看| 久久久91精品国产一区二区精品 | 色哟哟一区二区| 精品国产sm最大网站|