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

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

?? os_tmr.c

?? uc/os2.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

/*
************************************************************************************************************************
*                                                  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一区二区三区免费野_久草精品视频
日韩欧美一二三| 亚洲国产欧美一区二区三区丁香婷| 欧美激情一区二区三区全黄| 一区二区国产盗摄色噜噜| 久久99日本精品| 在线欧美一区二区| 国产女人水真多18毛片18精品视频| 无码av中文一区二区三区桃花岛| 东方aⅴ免费观看久久av| 666欧美在线视频| 玉米视频成人免费看| 成人性生交大合| 久久久久久99精品| 精品一区二区三区不卡| 欧美日韩视频在线观看一区二区三区| 久久久久免费观看| 久久精品国产久精国产爱| 欧美日韩亚洲高清一区二区| 亚洲视频1区2区| 成人激情免费网站| 久久久777精品电影网影网| 人人爽香蕉精品| 欧美日韩国产影片| 性久久久久久久| 99r国产精品| 亚洲欧美电影一区二区| 波多野结衣在线一区| 国产日韩欧美一区二区三区综合| 美女性感视频久久| 欧美四级电影网| 一级日本不卡的影视| 色综合久久综合中文综合网| 亚洲色欲色欲www| 97se亚洲国产综合自在线观| 亚洲欧美色一区| 色网综合在线观看| 亚洲一区在线看| 欧美老女人在线| 一区二区三区产品免费精品久久75| 99久久伊人精品| 亚洲一区二区五区| 欧美日韩专区在线| 天堂午夜影视日韩欧美一区二区| 欧美人动与zoxxxx乱| 日韩精品久久理论片| 欧美一区二区福利视频| 久草热8精品视频在线观看| 日韩久久久精品| 国产精品66部| 国产精品卡一卡二卡三| 一本大道av伊人久久综合| 亚洲国产sm捆绑调教视频| 欧美一区二区三区视频在线| 国产中文字幕一区| 国产精品成人一区二区三区夜夜夜| 91在线观看视频| 日韩av一区二区三区四区| 久久久亚洲午夜电影| 99久久精品国产观看| 日韩激情一二三区| 久久精品欧美日韩| 色婷婷av一区二区三区软件| 午夜免费久久看| 国产亚洲一区字幕| 欧美亚洲动漫精品| 国产自产2019最新不卡| 亚洲久本草在线中文字幕| 日韩欧美黄色影院| 一本久久精品一区二区| 欧美a级一区二区| 综合自拍亚洲综合图不卡区| 在线播放欧美女士性生活| 国产在线麻豆精品观看| 一区二区在线观看视频| 日韩视频免费观看高清完整版在线观看 | 91色视频在线| 免费精品99久久国产综合精品| 国产清纯在线一区二区www| 欧美揉bbbbb揉bbbbb| 国产精品66部| 久久爱另类一区二区小说| 亚洲欧美激情在线| 国产欧美精品一区aⅴ影院 | 色哟哟国产精品| 国产一区在线观看视频| 亚洲福利视频一区| 国产精品天干天干在观线| 欧美高清dvd| 91在线码无精品| 国产精品一品二品| 美女看a上一区| 亚洲一级二级在线| 国产精品久久久久久久岛一牛影视| 欧美精品日韩综合在线| 91麻豆精品视频| 国产成人三级在线观看| 日韩成人免费在线| 亚洲一区二区三区美女| 18涩涩午夜精品.www| 国产午夜精品久久久久久免费视 | 天天av天天翘天天综合网| 亚洲色图欧美偷拍| 国产精品污网站| 久久男人中文字幕资源站| 日韩精品在线网站| 欧美福利电影网| 欧美日韩在线播放三区| 欧美色大人视频| 在线一区二区三区做爰视频网站| 99在线精品视频| eeuss鲁片一区二区三区在线看| 国产精品1区二区.| 国产美女娇喘av呻吟久久| 紧缚奴在线一区二区三区| 日韩在线观看一区二区| 亚洲国产日韩一区二区| 午夜精品一区二区三区免费视频| 一级日本不卡的影视| 亚洲一二三四区不卡| 亚洲综合一区二区| 亚洲二区视频在线| 亚洲电影欧美电影有声小说| 五月天亚洲婷婷| 日本最新不卡在线| 久久国产精品露脸对白| 另类中文字幕网| 国产aⅴ精品一区二区三区色成熟| 国产成人小视频| 成人a免费在线看| 欧美性大战久久久久久久蜜臀| 在线日韩国产精品| 91精品国产综合久久精品麻豆| 日韩一区二区中文字幕| 日韩一区二区不卡| 国产亚洲综合av| 亚洲日本成人在线观看| 亚洲一区二区三区视频在线播放 | 亚洲一区二区欧美日韩| 日本不卡一区二区三区高清视频| 久久99在线观看| 成人动漫av在线| 欧美综合一区二区| 日韩一二三四区| 欧美国产精品专区| 亚洲国产中文字幕在线视频综合 | 午夜欧美电影在线观看| 激情五月婷婷综合网| 成人ar影院免费观看视频| 在线观看日韩高清av| 日韩三级视频在线看| 国产精品麻豆网站| 日韩电影免费在线| 99精品久久只有精品| 884aa四虎影成人精品一区| 国产亚洲一本大道中文在线| 亚洲欧美日韩在线不卡| 精品亚洲aⅴ乱码一区二区三区| 国产成人综合自拍| 欧美男男青年gay1069videost | 国产精品超碰97尤物18| 亚洲成人综合在线| 国产宾馆实践打屁股91| 欧美区一区二区三区| 日韩一区有码在线| 激情亚洲综合在线| 在线综合+亚洲+欧美中文字幕| 中文字幕国产一区二区| 日本sm残虐另类| 在线观看成人免费视频| 欧美国产精品久久| 蜜臀av性久久久久蜜臀aⅴ| 一本色道综合亚洲| 久久久噜噜噜久久中文字幕色伊伊 | 日韩欧美视频一区| 一区二区三区四区国产精品| 国产综合成人久久大片91| 欧美日本视频在线| 一区二区三区久久| 成人动漫视频在线| 久久精品一区二区三区av| 三级久久三级久久久| 在线视频一区二区免费| 国产精品久久久久久久久搜平片 | 久久久亚洲精品石原莉奈| 亚洲午夜三级在线| 99re成人在线| 国产欧美一区二区三区沐欲| 裸体健美xxxx欧美裸体表演| 91福利在线导航| 亚洲欧美色图小说| 成人午夜av在线| 久久综合久久综合亚洲| 日本女优在线视频一区二区| 欧美日韩亚洲综合| 午夜欧美一区二区三区在线播放| 在线观看不卡一区| 亚洲电影一区二区| 欧美老年两性高潮| 婷婷综合五月天| 欧美日韩1区2区|