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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? os_tmr.c

?? uCOS在Cortex-M3芯片上的移植
?? 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

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人在线观看| 日韩欧美国产精品| 精品播放一区二区| 一区二区高清免费观看影视大全| 免费黄网站欧美| 欧美色图一区二区三区| 国产亚洲欧美日韩在线一区| 天堂午夜影视日韩欧美一区二区| 99精品视频中文字幕| 久久久久九九视频| 秋霞电影网一区二区| 欧美三级资源在线| 一区二区三区精品久久久| 岛国av在线一区| 久久久精品欧美丰满| 精品影院一区二区久久久| 欧美精品高清视频| 亚洲影院在线观看| 色婷婷香蕉在线一区二区| 国产精品视频麻豆| 成人av片在线观看| 国产精品青草久久| 国产成+人+日韩+欧美+亚洲| 精品国产乱码久久久久久闺蜜| 无码av免费一区二区三区试看 | 亚洲乱码精品一二三四区日韩在线| 久久国产精品99久久久久久老狼 | 91免费小视频| 亚洲婷婷综合久久一本伊一区| 国产成人99久久亚洲综合精品| 2023国产精品视频| 国产一区二三区| 久久久91精品国产一区二区精品 | 欧美激情综合网| 国产精品18久久久久久久久| 国产婷婷色一区二区三区在线| 经典一区二区三区| 久久久久久日产精品| 国产曰批免费观看久久久| 国产无一区二区| av高清不卡在线| 亚洲一区二区三区三| 欧美私人免费视频| 日韩二区三区四区| 精品久久国产97色综合| 国产精品一区专区| 国产精品成人免费在线| 欧亚一区二区三区| 日本美女一区二区三区视频| 精品福利在线导航| 成人禁用看黄a在线| 一区二区三区高清在线| 日韩一区二区三区在线视频| 国产精品伊人色| 亚洲精品欧美激情| 日韩一区二区在线观看| 风流少妇一区二区| 亚洲444eee在线观看| 久久婷婷综合激情| 色狠狠av一区二区三区| 美女视频一区在线观看| 亚洲国产成人一区二区三区| 欧美丝袜丝交足nylons图片| 国内精品久久久久影院薰衣草| 中文字幕一区二区三区四区不卡| 欧美视频在线观看一区二区| 激情综合亚洲精品| 亚洲欧美aⅴ...| 精品国产一区二区三区久久影院 | 精品国内片67194| 99re8在线精品视频免费播放| 日韩精品乱码av一区二区| 国产亚洲成年网址在线观看| 欧美视频一区二区三区在线观看| 激情综合色播激情啊| 亚洲一区免费观看| 亚洲国产精品高清| 日韩一卡二卡三卡四卡| av激情综合网| 国产美女精品在线| 香蕉加勒比综合久久| 欧美高清在线一区二区| 日韩视频在线观看一区二区| 91在线国产观看| 国产精品18久久久久久久久| 偷拍日韩校园综合在线| 国产精品久久久一本精品| 精品国产制服丝袜高跟| 欧美精品日韩一本| 91色婷婷久久久久合中文| 国产一区二区日韩精品| 日韩电影在线免费看| 亚洲精品视频在线观看网站| 国产欧美一区视频| 欧美不卡一二三| 欧美人xxxx| 亚洲激情图片一区| 色综合久久综合| 国产一区在线不卡| 日韩一区精品字幕| 亚洲一区精品在线| 亚洲欧美成人一区二区三区| 国产欧美日韩综合精品一区二区| 日韩免费电影一区| 欧美一区二区性放荡片| 欧美美女一区二区三区| 欧美日韩国产综合一区二区| 91蝌蚪国产九色| 91免费版pro下载短视频| av激情亚洲男人天堂| 99久久精品国产导航| 99精品久久只有精品| 91视视频在线直接观看在线看网页在线看| 国产一区二区三区高清播放| 国产精品1区2区3区在线观看| 国产精品综合久久| 国产裸体歌舞团一区二区| 国产一区91精品张津瑜| 国产成人亚洲精品狼色在线| 日韩激情av在线| 国产一区二区0| 国产资源精品在线观看| 国产精品一区二区在线看| 国产一区二区三区日韩| 粉嫩久久99精品久久久久久夜| 国产精品18久久久久久久久久久久| 国产黑丝在线一区二区三区| 成人精品国产免费网站| 色综合久久中文综合久久牛| 欧美色电影在线| 欧美一卡二卡三卡| 国产午夜精品一区二区三区嫩草| 国产精品色呦呦| 亚洲精品国产无天堂网2021| 午夜视频一区二区| 精彩视频一区二区| 94色蜜桃网一区二区三区| 欧美日韩久久久| 国产日韩欧美麻豆| 尤物av一区二区| 国内精品写真在线观看| www.av亚洲| 91精品黄色片免费大全| 久久精品无码一区二区三区| 久久国产精品色婷婷| 精品国产不卡一区二区三区| 国产日韩精品一区| 一区二区三区色| 国产呦萝稀缺另类资源| 91麻豆精品一区二区三区| 欧美一级在线观看| 亚洲婷婷综合久久一本伊一区| 日韩国产欧美在线观看| 成人午夜激情在线| 91精品国产色综合久久ai换脸| 国产欧美一区二区精品秋霞影院| 一区二区高清在线| 国产精品18久久久久久久久| 欧美视频中文字幕| 国产精品每日更新| 久久97超碰国产精品超碰| 色婷婷激情综合| 久久久亚洲国产美女国产盗摄| 亚洲国产裸拍裸体视频在线观看乱了 | 国产欧美日韩在线视频| 亚瑟在线精品视频| 91视频一区二区| 久久久噜噜噜久久人人看 | 日韩三级中文字幕| 亚洲狠狠丁香婷婷综合久久久| 国产福利一区在线| 制服丝袜中文字幕亚洲| 亚洲视频狠狠干| 丰满亚洲少妇av| 久久久噜噜噜久久人人看| 欧美a一区二区| 欧美日韩一区二区三区四区五区| 国产精品美女久久久久aⅴ| 裸体健美xxxx欧美裸体表演| 欧美性大战久久| 亚洲特黄一级片| av不卡免费电影| 国产精品入口麻豆原神| 国内精品国产成人| 欧美本精品男人aⅴ天堂| 肉色丝袜一区二区| 欧美日韩激情一区二区| 一区二区三区免费看视频| 不卡影院免费观看| 国产精品日韩精品欧美在线 | 香蕉久久夜色精品国产使用方法| 91丨九色丨蝌蚪富婆spa| 日本一区二区三区电影| 国产福利电影一区二区三区| 久久久夜色精品亚洲| 国产麻豆欧美日韩一区| 久久久久久**毛片大全| 国产高清不卡一区二区| 中文字幕av免费专区久久| 丁香亚洲综合激情啪啪综合|