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

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

?? os_tmr.c

?? keil mdk 3.22下移植的uCOS II 2.83
?? 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

#define OS_TASK_TMR_PRIO 20

/*
************************************************************************************************************************
*                                                  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);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲午夜精品一区二区三区他趣| 国产日韩欧美激情| 婷婷丁香久久五月婷婷| 欧美日本精品一区二区三区| 污片在线观看一区二区| 91精品国产色综合久久不卡蜜臀| 美腿丝袜一区二区三区| 欧美成人欧美edvon| 成人免费高清视频在线观看| 亚洲精品综合在线| 7777精品伊人久久久大香线蕉| 日韩国产在线观看| 久久久国际精品| 97se亚洲国产综合在线| 午夜欧美视频在线观看| 2022国产精品视频| 99精品视频在线免费观看| 日日摸夜夜添夜夜添亚洲女人| 精品国产在天天线2019| 99麻豆久久久国产精品免费优播| 亚洲精品久久嫩草网站秘色| 欧美一区二区视频在线观看2020 | 美国欧美日韩国产在线播放| 久久午夜国产精品| 91福利在线免费观看| 激情综合五月婷婷| 亚洲少妇30p| 精品福利av导航| 欧美在线不卡一区| 国产乱一区二区| 香蕉av福利精品导航| 欧美国产一区在线| 欧美久久久久中文字幕| 国产iv一区二区三区| 午夜视黄欧洲亚洲| 中文字幕在线不卡视频| 精品日韩在线观看| 欧美日韩中字一区| 不卡在线观看av| 日韩av中文在线观看| 国产精品久久久久三级| 日韩视频在线永久播放| 91国产免费观看| 粉嫩一区二区三区在线看| 亚洲一区二区三区国产| 中文av一区二区| 欧美不卡123| 欧美日韩不卡一区二区| 91免费看视频| 国产精品一卡二| 久久99精品久久只有精品| 视频一区免费在线观看| 亚洲日本在线a| 国产精品污污网站在线观看| 亚洲精品一区二区三区四区高清| 日本福利一区二区| youjizz国产精品| 国产不卡视频在线播放| 奇米精品一区二区三区在线观看一| 亚洲天堂中文字幕| 国产拍揄自揄精品视频麻豆| 久久色中文字幕| 欧美一级理论性理论a| 欧美视频在线观看一区| 91原创在线视频| 91在线云播放| 99精品在线观看视频| 成人国产精品免费观看| 国产精品中文字幕日韩精品| 男男gaygay亚洲| 美女视频黄频大全不卡视频在线播放| 一级精品视频在线观看宜春院| 中文字幕在线一区免费| 中文字幕不卡在线观看| 精品日韩欧美一区二区| 精品福利视频一区二区三区| 精品剧情v国产在线观看在线| 日韩一二在线观看| 欧美xxxxxxxxx| 久久精品亚洲一区二区三区浴池| 精品蜜桃在线看| 国产亚洲欧洲997久久综合| 久久久久久9999| 国产精品国产三级国产aⅴ入口 | 91免费小视频| 在线观看国产精品网站| 1区2区3区国产精品| 99精品视频在线免费观看| av午夜一区麻豆| 成人免费视频app| 91在线免费看| 欧美三级电影一区| 欧美一区二区三区四区高清| 日韩精品最新网址| 国产精品视频麻豆| 亚洲综合一区二区| 亚洲bt欧美bt精品777| 男人的j进女人的j一区| 激情欧美一区二区| 懂色av噜噜一区二区三区av| 91亚洲精品久久久蜜桃网站| 欧美日韩国产三级| 精品粉嫩超白一线天av| 日韩毛片一二三区| 日韩黄色一级片| 成人免费电影视频| 欧美撒尿777hd撒尿| 欧美精品一区二区三区高清aⅴ| 中文一区二区完整视频在线观看| 亚洲黄色在线视频| 久久99精品久久久久久国产越南| 成人av网址在线| 91精品国产免费| 国产精品美女久久久久久| 午夜婷婷国产麻豆精品| 国内欧美视频一区二区| 色婷婷综合久色| 欧美tickle裸体挠脚心vk| 中文字幕在线一区免费| 蜜臀精品一区二区三区在线观看 | 亚洲国产精品尤物yw在线观看| 老司机免费视频一区二区三区| 成人av在线一区二区三区| 欧美一区二区三区性视频| 国产精品乱人伦一区二区| 日韩成人伦理电影在线观看| 国产成人8x视频一区二区| 91精品午夜视频| 亚洲免费观看视频| 国产精品自拍毛片| 欧美一区二区三区免费大片| 亚洲人成小说网站色在线| 国产一区二区按摩在线观看| 欧美日本一区二区三区| 亚洲欧洲一区二区在线播放| 久久99国产精品久久99果冻传媒| 在线视频一区二区免费| 中文一区在线播放| 国产在线精品免费| 在线91免费看| 一区二区三区波多野结衣在线观看| 国产最新精品免费| 91精品国产高清一区二区三区| 亚洲激情校园春色| eeuss鲁一区二区三区| 欧美精品一区二区久久婷婷 | 欧美一卡2卡三卡4卡5免费| 中文字幕佐山爱一区二区免费| 国产剧情在线观看一区二区 | 欧美va日韩va| 青娱乐精品视频| 欧美疯狂做受xxxx富婆| 一区二区三区在线免费视频| 成人黄色av电影| 欧美国产激情二区三区| 国产精品亚洲成人| 精品三级av在线| 久久国产精品区| 精品国产髙清在线看国产毛片| 丝袜亚洲另类欧美| 4438x亚洲最大成人网| 亚洲综合在线五月| 欧美午夜精品一区| 亚洲综合免费观看高清在线观看| 一本大道久久a久久综合| 亚洲人成网站在线| 欧美一a一片一级一片| 一区二区三区成人在线视频| 在线精品观看国产| 午夜久久福利影院| 91精品欧美久久久久久动漫 | 欧美亚洲综合网| 婷婷成人激情在线网| 日韩一区二区视频在线观看| 久久国产夜色精品鲁鲁99| 久久综合色天天久久综合图片| 激情都市一区二区| 国产欧美一区在线| 91丨九色丨蝌蚪丨老版| 亚洲精品久久久蜜桃| 欧美日韩国产天堂| 黑人巨大精品欧美一区| 中文字幕乱码久久午夜不卡| 成人免费毛片a| 亚洲综合在线五月| 欧美一级片在线看| 大美女一区二区三区| 中文字幕一区二区三区不卡在线| 91麻豆免费在线观看| 亚洲高清三级视频| 精品精品国产高清a毛片牛牛 | 免费在线观看视频一区| 久久久一区二区三区| 91麻豆自制传媒国产之光| 日韩综合一区二区| 国产亚洲欧美中文| 色噜噜偷拍精品综合在线| 毛片av一区二区三区| 国产精品卡一卡二| 欧美一区二区在线免费播放|