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

📄 os_time.lst

📁 基于51单片机的ucosII源码
💻 LST
字号:
C51 COMPILER V8.05a   OS_TIME                                                              09/05/2008 14:42:04 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE OS_TIME
OBJECT MODULE PLACED IN .\OS_TIME.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE ..\uc_os_II\OS_TIME.C BROWSE DEBUG OBJECTEXTEND PRINT(.\OS_TIME.lst) OBJECT
                    -(.\OS_TIME.obj)

line level    source

   1          /*
   2          *********************************************************************************************************
   3          *                                                uC/OS-II
   4          *                                          The Real-Time Kernel
   5          *                                             TIME MANAGEMENT
   6          *
   7          *                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
   8          *                                           All Rights Reserved
   9          *
  10          *                                                  V2.00
  11          *
  12          * File : OS_TIME.C
  13          * By   : Jean J. Labrosse
  14          *********************************************************************************************************
  15          */
  16          
  17          #ifndef  OS_MASTER_FILE
  18          #include "includes.h"
  19          #endif
  20          
  21          /*
  22          *********************************************************************************************************
  23          *                                DELAY TASK 'n' TICKS   (n from 0 to 65535)
  24          *
  25          * Description: This function is called to delay execution of the currently running task until the 
  26          *              specified number of system ticks expires.  This, of course, directly equates to delaying
  27          *              the current task for some time to expire.  No delay will result If the specified delay is 
  28          *              0.  If the specified delay is greater than 0 then, a context switch will result.
  29          *
  30          * Arguments  : ticks     is the time delay that the task will be suspended in number of clock 'ticks'.  
  31          *                        Note that by specifying 0, the task will not be delayed.
  32          *
  33          * Returns    : none
  34          *********************************************************************************************************
  35          */
  36          
  37          void OSTimeDly (INT16U ticks) REENTRANT
  38          {
  39   1          if (ticks > 0) {                                                      /* 0 means no delay!         */
  40   2              OS_ENTER_CRITICAL();
  41   2              if ((OSRdyTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0) {  /* Delay current task        */
  42   3                  OSRdyGrp &= ~OSTCBCur->OSTCBBitY;
  43   3              }
  44   2              OSTCBCur->OSTCBDly = ticks;                                       /* Load ticks in TCB         */
  45   2              OS_EXIT_CRITICAL();
  46   2              OSSched();                                                        /* Find next task to run!    */
  47   2          }
  48   1      }
  49          /*$PAGE*/
  50          /*
  51          *********************************************************************************************************
  52          *                                     DELAY TASK FOR SPECIFIED TIME
  53          *
  54          * Description: This function is called to delay execution of the currently running task until some time
C51 COMPILER V8.05a   OS_TIME                                                              09/05/2008 14:42:04 PAGE 2   

  55          *              expires.  This call allows you to specify the delay time in HOURS, MINUTES, SECONDS and
  56          *              MILLISECONDS instead of ticks.
  57          *
  58          * Arguments  : hours     specifies the number of hours that the task will be delayed (max. is 255)
  59          *              minutes   specifies the number of minutes (max. 59)    
  60          *              seconds   specifies the number of seconds (max. 59)
  61          *              milli     specifies the number of milliseconds (max. 999)
  62          *
  63          * Returns    : OS_NO_ERR
  64          *              OS_TIME_INVALID_MINUTES
  65          *              OS_TIME_INVALID_SECONDS
  66          *              OS_TIME_INVALID_MS
  67          *              OS_TIME_ZERO_DLY
  68          *
  69          * Note(s)    : The resolution on the milliseconds depends on the tick rate.  For example, you can't do
  70          *              a 10 mS delay if the ticker interrupts every 100 mS.  In this case, the delay would be
  71          *              set to 0.  The actual delay is rounded to the nearest tick.
  72          *********************************************************************************************************
  73          */
  74          
  75          INT8U OSTimeDlyHMSM (INT8U hours, INT8U minutes, INT8U seconds, INT16U milli) REENTRANT
  76          {
  77   1          INT32U ticks;
  78   1          INT16U loops;
  79   1      
  80   1      
  81   1          if (hours > 0 || minutes > 0 || seconds > 0 || milli > 0) {
  82   2              if (minutes > 59) {
  83   3                  return (OS_TIME_INVALID_MINUTES);    /* Validate arguments to be within range              */
  84   3              }
  85   2              if (seconds > 59) {
  86   3                  return (OS_TIME_INVALID_SECONDS);
  87   3              }
  88   2              if (milli > 999) {
  89   3                  return (OS_TIME_INVALID_MILLI);
  90   3              }
  91   2                                                       /* Compute the total number of clock ticks required.. */
  92   2                                                       /* .. (rounded to the nearest tick)                   */
  93   2              ticks = ((INT32U)hours * 3600L + (INT32U)minutes * 60L + (INT32U)seconds) * OS_TICKS_PER_SEC
  94   2                    + OS_TICKS_PER_SEC * ((INT32U)milli + 500L / OS_TICKS_PER_SEC) / 1000L;
  95   2              loops = ticks / 65536L;                  /* Compute the integral number of 65536 tick delays   */
  96   2              ticks = ticks % 65536L;                  /* Obtain  the fractional number of ticks             */
  97   2              OSTimeDly(ticks);
  98   2              while (loops > 0)     
  99   2                      {
 100   3                  OSTimeDly(32768);
 101   3                  OSTimeDly(32768);
 102   3                  loops--;
 103   3              }
 104   2              return (OS_NO_ERR);
 105   2          } else {
 106   2              return (OS_TIME_ZERO_DLY);
 107   2          }
 108   1      }
 109          /*$PAGE*/
 110          /*
 111          *********************************************************************************************************
 112          *                                         RESUME A DELAYED TASK
 113          *
 114          * Description: This function is used resume a task that has been delayed through a call to either
 115          *              OSTimeDly() or OSTimeDlyHMSM().  Note that you MUST NOT call this function to resume a 
 116          *              task that is waiting for an event with timeout.  This situation would make the task look 
C51 COMPILER V8.05a   OS_TIME                                                              09/05/2008 14:42:04 PAGE 3   

 117          *              like a timeout occurred (unless you desire this effect).  Also, you cannot resume a task 
 118          *              that has called OSTimeDlyHMSM() with a combined time that exceeds 65535 clock ticks.  In 
 119          *              other words, if the clock tick runs at 100 Hz then, you will not be able to resume a 
 120          *              delayed task that called OSTimeDlyHMSM(0, 10, 55, 350) or higher.  
 121          *
 122          *                  (10 Minutes * 60 + 55 Seconds + 0.35) * 100 ticks/second.
 123          *
 124          * Arguments  : prio      specifies the priority of the task to resume
 125          *
 126          * Returns    : OS_NO_ERR                 Task has been resumed
 127          *              OS_PRIO_INVALID           if the priority you specify is higher that the maximum allowed 
 128          *                                        (i.e. >= OS_LOWEST_PRIO)
 129          *              OS_TIME_NOT_DLY           Task is not waiting for time to expire
 130          *              OS_TASK_NOT_EXIST         The desired task has not been created
 131          *********************************************************************************************************
 132          */
 133          
 134          INT8U OSTimeDlyResume (INT8U prio) REENTRANT
 135          {
 136   1          OS_TCB DT_XDATA *ptcb;
 137   1      
 138   1      
 139   1          if (prio >= OS_LOWEST_PRIO) {
 140   2              return (OS_PRIO_INVALID);
 141   2          }
 142   1          OS_ENTER_CRITICAL();
 143   1          ptcb = (OS_TCB DT_XDATA *)OSTCBPrioTbl[prio];                   /* Make sure that task exist          
             -      */
 144   1          if (ptcb != (OS_TCB DT_XDATA *)0) {
 145   2              if (ptcb->OSTCBDly != 0) {                         /* See if task is delayed                   */
 146   3                  ptcb->OSTCBDly  = 0;                           /* Clear the time delay                     */
 147   3                  if (!(ptcb->OSTCBStat & OS_STAT_SUSPEND)) {    /* See if task is ready to run              */
 148   4                      OSRdyGrp               |= ptcb->OSTCBBitY; /* Make task ready to run                   */
 149   4                      OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
 150   4                      OS_EXIT_CRITICAL();
 151   4                      OSSched();                                 /* See if this is new highest priority      */
 152   4                  } else {
 153   4                      OS_EXIT_CRITICAL();                        /* Task may be suspended                    */
 154   4                  }
 155   3                  return (OS_NO_ERR);
 156   3              } else {
 157   3                  OS_EXIT_CRITICAL();
 158   3                  return (OS_TIME_NOT_DLY);                      /* Indicate that task was not delayed       */
 159   3              }
 160   2          } else {
 161   2              OS_EXIT_CRITICAL();
 162   2              return (OS_TASK_NOT_EXIST);                        /* The task does not exist                  */
 163   2          }
 164   1      }
 165          /*$PAGE*/
 166          /*
 167          *********************************************************************************************************
 168          *                                         GET CURRENT SYSTEM TIME
 169          *
 170          * Description: This function is used by your application to obtain the current value of the 32-bit 
 171          *              counter which keeps track of the number of clock ticks.
 172          *
 173          * Arguments  : none
 174          *
 175          * Returns    : The current value of OSTime
 176          *********************************************************************************************************
 177          */
C51 COMPILER V8.05a   OS_TIME                                                              09/05/2008 14:42:04 PAGE 4   

 178          
 179          INT32U OSTimeGet (void) REENTRANT
 180          {
 181   1          INT32U ticks;
 182   1      
 183   1      
 184   1          OS_ENTER_CRITICAL();
 185   1          ticks = OSTime;
 186   1          OS_EXIT_CRITICAL();
 187   1          return (ticks);
 188   1      }
 189          
 190          /*
 191          *********************************************************************************************************
 192          *                                            SET SYSTEM CLOCK
 193          *
 194          * Description: This function sets the 32-bit counter which keeps track of the number of clock ticks.
 195          *
 196          * Arguments  : ticks      specifies the new value that OSTime needs to take.
 197          *
 198          * Returns    : none
 199          *********************************************************************************************************
 200          */
 201          
 202          void OSTimeSet (INT32U ticks) REENTRANT
 203          {
 204   1          OS_ENTER_CRITICAL();
 205   1          OSTime = ticks;
 206   1          OS_EXIT_CRITICAL();
 207   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    878    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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