⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_tmr.lst

📁 uCos-ii 2.86 在C8051F410单片机上移植成功!!! 其中包括:UART驱动
💻 LST
📖 第 1 页 / 共 5 页
字号:
                                 INT8U   *perr) reentrant
              {
C51 COMPILER V8.17   OS_TMR                                                                03/26/2009 14:24:25 PAGE 5   

              #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_ERR_NONE;
                           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_ERR_NONE;
                           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
 262          
 263          /*$PAGE*/
 264          /*
 265          **********************************************************************************************************
             -**************
 266          *                                             GET THE NAME OF A TIMER
 267          *
 268          * Description: This function is called to obtain the name of a timer.
C51 COMPILER V8.17   OS_TMR                                                                03/26/2009 14:24:25 PAGE 6   

 269          *
 270          * Arguments  : ptmr          Is a pointer to the timer to obtain the name for
 271          *
 272          *              pdest         Is a pointer to where the name of the timer will be placed.  It is the caller
             -'s responsibility
 273          *                            to ensure that he has sufficient storage in the destination, i.e. at least OS
             -_TMR_CFG_NAME_SIZE
 274          *
 275          *              perr          Is a pointer to an error code.  '*perr' will contain one of the following:
 276          *                               OS_ERR_NONE               The call was successful
 277          *                               OS_ERR_TMR_INVALID_DEST   'pdest' is a NULL pointer
 278          *                               OS_ERR_TMR_INVALID        'ptmr'  is a NULL pointer
 279          *                               OS_ERR_TMR_INVALID_TYPE   'ptmr'  is not pointing to an OS_TMR
 280          *                               OS_ERR_NAME_GET_ISR       if the call was made from an ISR
 281          *                               OS_ERR_TMR_INACTIVE       'ptmr'  points to a timer that is not active
 282          *                               OS_ERR_TMR_INVALID_STATE  the timer is in an invalid state
 283          *
 284          * Returns    : The length of the string or 0 if the timer does not exist.
 285          **********************************************************************************************************
             -**************
 286          */
 287          
 288          #if OS_TMR_EN > 0 && OS_TMR_CFG_NAME_SIZE > 0 && OS_TMR_NAMEGET_EN>0
              INT8U  OSTmrNameGet (OS_TMR  *ptmr,
                                   INT8U   *pdest,
                                   INT8U   *perr) reentrant
              {
                  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_NAME_GET_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_ERR_NONE;
                           return (len);
C51 COMPILER V8.17   OS_TMR                                                                03/26/2009 14:24:25 PAGE 7   

              
                      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
 339          
 340          /*$PAGE*/
 341          /*
 342          **********************************************************************************************************
             -**************
 343          *                                    GET HOW MUCH TIME IS LEFT BEFORE A TIMER EXPIRES
 344          *
 345          * Description: This function is called to get the number of ticks before a timer times out.
 346          *
 347          * Arguments  : ptmr          Is a pointer to the timer to obtain the remaining time from.
 348          *
 349          *              perr          Is a pointer to an error code.  '*perr' will contain one of the following:
 350          *                               OS_ERR_NONE
 351          *                               OS_ERR_TMR_INVALID        'ptmr' is a NULL pointer
 352          *                               OS_ERR_TMR_INVALID_TYPE   'ptmr'  is not pointing to an OS_TMR
 353          *                               OS_ERR_TMR_ISR            if the call was made from an ISR
 354          *                               OS_ERR_TMR_INACTIVE       'ptmr' points to a timer that is not active
 355          *                               OS_ERR_TMR_INVALID_STATE  the timer is in an invalid state
 356          *
 357          * Returns    : The time remaining for the timer to expire.  The time represents 'timer' increments.  In ot
             -her words, if
 358          *              OSTmr_Task() is signaled every 1/10 of a second then the returned value represents the numb
             -er of 1/10 of
 359          *              a second remaining before the timer expires.
 360          **********************************************************************************************************
             -**************
 361          */
 362          
 363          #if OS_TMR_EN > 0 && OS_TMR_REMAINGET_EN >0
              INT32U  OSTmrRemainGet (OS_TMR  *ptmr,
                                      INT8U   *perr)  reentrant
              {
                  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
                  if (ptmr->OSTmrType != OS_TMR_TYPE) {              /* Validate timer structure                        
             -            */
                      *perr = OS_ERR_TMR_INVALID_TYPE;
                      return (0);
C51 COMPILER V8.17   OS_TMR                                                                03/26/2009 14:24:25 PAGE 8   

                  }
                  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:
                           remain = ptmr->OSTmrMatch - OSTmrTime;    /* Determine how much time is left to timeout      
             -            */
                           OSTmr_Unlock();
                           *perr  = OS_ERR_NONE;
                           return (remain);
              
                      case OS_TMR_STATE_STOPPED:                     /* It's assumed that the timer has not started yet 
             -            */
                           switch (ptmr->OSTmrOpt) {
                               case OS_TMR_OPT_PERIODIC:
                                    if (ptmr->OSTmrDly == 0) {
                                        remain = ptmr->OSTmrPeriod;
                                    } else {
                                        remain = ptmr->OSTmrDly;
                                    }
                                    OSTmr_Unlock();
                                    *perr  = OS_ERR_NONE;
                                    break;
              
                               case OS_TMR_OPT_ONE_SHOT:
                               default:
                                    remain = ptmr->OSTmrDly;
                                    OSTmr_Unlock();
                                    *perr  = OS_ERR_NONE;
                                    break;
                           }
                           return (remain);
              
                      case OS_TMR_STATE_COMPLETED:                   /* Only ONE-SHOT that timed out can be in this stat
             -e           */
                           OSTmr_Unlock();
                           *perr = OS_ERR_NONE;
                           return (0);
              
                      case OS_TMR_STATE_UNUSED:
                           OSTmr_Unlock();
                           *perr = OS_ERR_TMR_INACTIVE;
                           return (0);
              
                      default:
                           OSTmr_Unlock();
                           *perr = OS_ERR_TMR_INVALID_STATE;
                           return (0);
                  }
              }
              #endif
 433          
 434          /*$PAGE*/
 435          /*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -