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

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

?? os_tmr.c

?? 移植好的UCOS2.86版
?? 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_EN  *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_CFG_MAX   *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一区二区三区免费野_久草精品视频
久久综合久久综合久久| 国产麻豆一精品一av一免费| 日产欧产美韩系列久久99| 韩国三级在线一区| 欧洲人成人精品| 久久久国产精华| 日本亚洲天堂网| 欧洲日韩一区二区三区| 国产精品网站在线播放| 美女国产一区二区三区| 欧美日韩精品一区二区天天拍小说 | 欧美一级在线视频| 中文字幕欧美一区| 国产成人精品综合在线观看| 91精品国产综合久久久久久久久久 | 国产亚洲成aⅴ人片在线观看| 国产精品国产三级国产三级人妇 | 国产.欧美.日韩| 日韩视频免费直播| 五月天精品一区二区三区| 91在线免费视频观看| 国产亚洲一二三区| 国产精品系列在线播放| 欧美一区二区三区视频在线观看| 亚洲午夜久久久久久久久电影院 | 91精品国产高清一区二区三区蜜臀 | 免费成人结看片| 色偷偷成人一区二区三区91| 国产精品久久久久aaaa樱花| 美女国产一区二区| 欧美tickling网站挠脚心| 天天影视网天天综合色在线播放 | 国产麻豆午夜三级精品| 久久网站最新地址| 国产精品99久久久| 国产精品嫩草影院com| 懂色av一区二区三区蜜臀| 国产色一区二区| 成人国产精品免费观看| 1024成人网| 欧美色国产精品| 日韩成人一级片| 久久久精品国产免费观看同学| 国产曰批免费观看久久久| 日韩精品一区二区在线| 国产在线精品一区二区不卡了| 久久精品欧美一区二区三区不卡| 国产成人高清在线| 亚洲免费观看高清完整| 欧美午夜精品久久久| 日本欧美韩国一区三区| 久久亚洲精精品中文字幕早川悠里 | 中文字幕一区二区三区精华液 | 欧洲一区二区三区在线| 香蕉久久夜色精品国产使用方法 | 理论片日本一区| 国产欧美一区视频| 欧美综合色免费| 美女网站色91| 亚洲天堂免费在线观看视频| 在线观看精品一区| 久久草av在线| 一区二区三区四区中文字幕| 69堂国产成人免费视频| 成人性生交大片免费看在线播放| 亚洲蜜臀av乱码久久精品| 日韩写真欧美这视频| 成人精品一区二区三区中文字幕| 亚洲国产va精品久久久不卡综合 | 中文字幕佐山爱一区二区免费| 欧美日韩精品一区二区三区四区 | 国产伦精品一区二区三区免费迷| 亚洲欧美视频在线观看视频| 日韩视频在线一区二区| 91小视频免费看| 国产主播一区二区三区| 亚洲综合免费观看高清在线观看| 91精品国产综合久久福利软件| 高清国产一区二区三区| 日韩电影在线一区二区| 亚洲男同1069视频| 久久久久国产精品麻豆| 6080日韩午夜伦伦午夜伦| 成人午夜在线播放| 麻豆国产精品官网| 一区二区三区四区精品在线视频| 久久久久88色偷偷免费| 欧美日韩另类一区| 一本久久a久久精品亚洲| 国产乱理伦片在线观看夜一区| 天天综合色天天综合| 亚洲欧美一区二区三区国产精品| 2023国产一二三区日本精品2022| 在线播放日韩导航| 欧美中文字幕亚洲一区二区va在线| 国产成人aaa| 国产一区二区三区蝌蚪| 美女精品一区二区| 五月天激情小说综合| 一区二区成人在线| 国产精品对白交换视频 | 欧美一级夜夜爽| 欧美影院一区二区| 色婷婷国产精品综合在线观看| 成人丝袜18视频在线观看| 韩国av一区二区| 久久99热国产| 九九热在线视频观看这里只有精品| 天天操天天干天天综合网| 一区二区三区日韩精品| 亚洲乱码一区二区三区在线观看| 国产精品家庭影院| 中文字幕在线一区免费| 国产精品国产a| 国产精品对白交换视频 | 国产欧美精品一区二区三区四区| 欧美不卡一区二区三区四区| 欧美精选午夜久久久乱码6080| 欧美日韩在线三级| 91精品国产综合久久婷婷香蕉| 538在线一区二区精品国产| 666欧美在线视频| 精品国产污污免费网站入口| 精品捆绑美女sm三区| 久久亚洲精品国产精品紫薇| 日本一区二区三区高清不卡 | 丰满亚洲少妇av| 成人97人人超碰人人99| 一本久久综合亚洲鲁鲁五月天 | 国产精品国产三级国产普通话三级| 欧美激情艳妇裸体舞| 亚洲欧美中日韩| 偷拍自拍另类欧美| 久久66热偷产精品| 国产成人午夜片在线观看高清观看| 国产成人免费在线观看| 一本大道久久a久久精品综合| 欧美日韩免费观看一区二区三区| 日韩欧美中文字幕一区| 久久久综合精品| 亚洲精品亚洲人成人网 | 日韩欧美一区二区三区在线| 久久亚洲一区二区三区明星换脸| 国产精品久久久久天堂| 一区二区三区四区亚洲| 日韩av不卡在线观看| 国产mv日韩mv欧美| 欧美日高清视频| 欧美—级在线免费片| 亚洲不卡一区二区三区| 国产老女人精品毛片久久| 在线一区二区视频| 久久五月婷婷丁香社区| 亚洲高清不卡在线| 国产另类ts人妖一区二区| 欧美视频一区二区三区| 久久久精品2019中文字幕之3| 一区二区三区精品视频在线| 久久超级碰视频| 欧美视频一区二区| 亚洲国产高清在线| 日韩国产欧美在线播放| 99re这里只有精品首页| 日韩亚洲欧美高清| 亚洲精品综合在线| 国产露脸91国语对白| 在线综合视频播放| 亚洲区小说区图片区qvod| 国模少妇一区二区三区| 欧美色视频在线| 亚洲视频在线观看三级| 国产乱码精品一区二区三区五月婷| 欧美午夜视频网站| 亚洲天堂av一区| 成人深夜在线观看| 精品久久久三级丝袜| 日韩电影一区二区三区四区| 色国产综合视频| 综合色中文字幕| 成人黄页毛片网站| 国产亚洲欧美日韩俺去了| 美国欧美日韩国产在线播放| 欧美日韩视频在线观看一区二区三区 | 欧美男女性生活在线直播观看| 日韩精品一区二区三区老鸭窝| 一区二区三区成人在线视频| 成人av网站在线| 中文成人av在线| 国产a精品视频| 久久久综合九色合综国产精品| 国产iv一区二区三区| 久久婷婷色综合| 国产一区二区日韩精品| 久久久无码精品亚洲日韩按摩| 免费一级欧美片在线观看| 91精品国产综合久久久久久久 | 国产精品1024久久| 久久精品视频免费| 国产成人精品网址| 日本一区二区免费在线观看视频|