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

📄 os_time.lst

📁 成功的将UCOS操作系统
💻 LST
字号:
C51 COMPILER V8.02   OS_TIME                                                               08/05/2007 21:31:19 PAGE 1   


C51 COMPILER V8.02, COMPILATION OF MODULE OS_TIME
OBJECT MODULE PLACED IN .\Out File\OS_TIME.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE Ucos Core\OS_TIME.C LARGE BROWSE ORDER NOAREGS DEBUG OBJECTEXTEND PRINT(.\O
                    -ut File\OS_TIME.lst) TABS(6) OBJECT(.\Out File\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-2001, Jean J. Labrosse, Weston, FL
   8          *                                           All Rights Reserved
   9          *
  10          * File : OS_TIME.C
  11          * By   : Jean J. Labrosse
  12          *********************************************************************************************************
  13          */
  14          
  15          #ifndef  OS_MASTER_FILE
  16          #include "Ucos Core\\includes.h"
  17          #endif
  18          
  19          /*
  20          *********************************************************************************************************
  21          *                                DELAY TASK 'n' TICKS   (n from 0 to 65535)
  22          *
  23          * Description: This function is called to delay execution of the currently running task until the
  24          *              specified number of system ticks expires.  This, of course, directly equates to delaying
  25          *              the current task for some time to expire.  No delay will result If the specified delay is
  26          *              0.  If the specified delay is greater than 0 then, a context switch will result.
  27          *
  28          * Arguments  : ticks     is the time delay that the task will be suspended in number of clock 'ticks'.
  29          *                        Note that by specifying 0, the task will not be delayed.
  30          *
  31          * Returns    : none
  32          *********************************************************************************************************
  33          */
  34          
  35          void  OSTimeDly (INT16U ticks)KCREENTRANT 
  36          {
  37   1      #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
                  OS_CPU_SR  cpu_sr;
              #endif    
  40   1      
  41   1          if (ticks > 0) {                                                      /* 0 means no delay!         */
  42   2              OS_ENTER_CRITICAL();
  43   2              if ((OSRdyTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0) {  /* Delay current task        */
  44   3                  OSRdyGrp &= ~OSTCBCur->OSTCBBitY;
  45   3              }
  46   2              OSTCBCur->OSTCBDly = ticks;                                       /* Load ticks in TCB         */
  47   2              OS_EXIT_CRITICAL();
  48   2              OS_Sched();                                                       /* Find next task to run!    */
  49   2          }
  50   1      }
  51          /*$PAGE*/
  52          /*
  53          *********************************************************************************************************
  54          *                                     DELAY TASK FOR SPECIFIED TIME
C51 COMPILER V8.02   OS_TIME                                                               08/05/2007 21:31:19 PAGE 2   

  55          *
  56          * Description: This function is called to delay execution of the currently running task until some time
  57          *              expires.  This call allows you to specify the delay time in HOURS, MINUTES, SECONDS and
  58          *              MILLISECONDS instead of ticks.
  59          *
  60          * Arguments  : hours     specifies the number of hours that the task will be delayed (max. is 255)
  61          *              minutes   specifies the number of minutes (max. 59)
  62          *              seconds   specifies the number of seconds (max. 59)
  63          *              milli     specifies the number of milliseconds (max. 999)
  64          *
  65          * Returns    : OS_NO_ERR
  66          *              OS_TIME_INVALID_MINUTES
  67          *              OS_TIME_INVALID_SECONDS
  68          *              OS_TIME_INVALID_MS
  69          *              OS_TIME_ZERO_DLY
  70          *
  71          * Note(s)    : The resolution on the milliseconds depends on the tick rate.  For example, you can't do
  72          *              a 10 mS delay if the ticker interrupts every 100 mS.  In this case, the delay would be
  73          *              set to 0.  The actual delay is rounded to the nearest tick.
  74          *********************************************************************************************************
  75          */
  76          
  77          #if OS_TIME_DLY_HMSM_EN > 0
              INT8U  OSTimeDlyHMSM (INT8U hours, INT8U minutes, INT8U seconds, INT16U milli)KCREENTRANT
              {
                  INT32U ticks;
                  INT16U loops;
              
              
                  if (hours > 0 || minutes > 0 || seconds > 0 || milli > 0) {
                      if (minutes > 59) {
                          return (OS_TIME_INVALID_MINUTES);    /* Validate arguments to be within range              */
                      }
                      if (seconds > 59) {
                          return (OS_TIME_INVALID_SECONDS);
                      }
                      if (milli > 999) {
                          return (OS_TIME_INVALID_MILLI);
                      }
                                                               /* Compute the total number of clock ticks required.. */
                                                               /* .. (rounded to the nearest tick)                   */
                      ticks = ((INT32U)hours * 3600L + (INT32U)minutes * 60L + (INT32U)seconds) * OS_TICKS_PER_SEC
                            + OS_TICKS_PER_SEC * ((INT32U)milli + 500L / OS_TICKS_PER_SEC) / 1000L;
                      loops = (INT16U)(ticks / 65536L);        /* Compute the integral number of 65536 tick delays   */
                      ticks = ticks % 65536L;                  /* Obtain  the fractional number of ticks             */
                      OSTimeDly((INT16U)ticks);
                      while (loops > 0) {
                          OSTimeDly(32768);
                          OSTimeDly(32768);
                          loops--;
                      }
                      return (OS_NO_ERR);
                  }
                  return (OS_TIME_ZERO_DLY);
              }
              #endif
 111          /*$PAGE*/
 112          /*
 113          *********************************************************************************************************
 114          *                                         RESUME A DELAYED TASK
 115          *
 116          * Description: This function is used resume a task that has been delayed through a call to either
C51 COMPILER V8.02   OS_TIME                                                               08/05/2007 21:31:19 PAGE 3   

 117          *              OSTimeDly() or OSTimeDlyHMSM().  Note that you MUST NOT call this function to resume a
 118          *              task that is waiting for an event with timeout.  This situation would make the task look
 119          *              like a timeout occurred (unless you desire this effect).  Also, you cannot resume a task
 120          *              that has called OSTimeDlyHMSM() with a combined time that exceeds 65535 clock ticks.  In
 121          *              other words, if the clock tick runs at 100 Hz then, you will not be able to resume a
 122          *              delayed task that called OSTimeDlyHMSM(0, 10, 55, 350) or higher.
 123          *
 124          *                  (10 Minutes * 60 + 55 Seconds + 0.35) * 100 ticks/second.
 125          *
 126          * Arguments  : prio      specifies the priority of the task to resume
 127          *
 128          * Returns    : OS_NO_ERR                 Task has been resumed
 129          *              OS_PRIO_INVALID           if the priority you specify is higher that the maximum allowed
 130          *                                        (i.e. >= OS_LOWEST_PRIO)
 131          *              OS_TIME_NOT_DLY           Task is not waiting for time to expire
 132          *              OS_TASK_NOT_EXIST         The desired task has not been created
 133          *********************************************************************************************************
 134          */
 135          
 136          #if OS_TIME_DLY_RESUME_EN > 0
              INT8U  OSTimeDlyResume (INT8U prio)KCREENTRANT
              {
              #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
                  OS_CPU_SR  cpu_sr;
              #endif    
                  OS_TCB    *ptcb;
              
              
                  if (prio >= OS_LOWEST_PRIO) {
                      return (OS_PRIO_INVALID);
                  }
                  OS_ENTER_CRITICAL();
                  ptcb = (OS_TCB *)OSTCBPrioTbl[prio];                   /* Make sure that task exist                */
                  if (ptcb != (OS_TCB *)0) {
                      if (ptcb->OSTCBDly != 0) {                         /* See if task is delayed                   */
                          ptcb->OSTCBDly  = 0;                           /* Clear the time delay                     */
                          if ((ptcb->OSTCBStat & OS_STAT_SUSPEND) == 0x00) {  /* See if task is ready to run         */
                              OSRdyGrp               |= ptcb->OSTCBBitY;      /* Make task ready to run              */
                              OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
                              OS_EXIT_CRITICAL();
                              OS_Sched();                                /* See if this is new highest priority      */
                          } else {
                              OS_EXIT_CRITICAL();                        /* Task may be suspended                    */
                          }
                          return (OS_NO_ERR);
                      } else {
                          OS_EXIT_CRITICAL();
                          return (OS_TIME_NOT_DLY);                      /* Indicate that task was not delayed       */
                      }
                  }
                  OS_EXIT_CRITICAL();
                  return (OS_TASK_NOT_EXIST);                            /* The task does not exist                  */
              }
              #endif    
 171          /*$PAGE*/
 172          /*
 173          *********************************************************************************************************
 174          *                                         GET CURRENT SYSTEM TIME
 175          *
 176          * Description: This function is used by your application to obtain the current value of the 32-bit
 177          *              counter which keeps track of the number of clock ticks.
 178          *
C51 COMPILER V8.02   OS_TIME                                                               08/05/2007 21:31:19 PAGE 4   

 179          * Arguments  : none
 180          *
 181          * Returns    : The current value of OSTime
 182          *********************************************************************************************************
 183          */
 184          
 185          #if OS_TIME_GET_SET_EN > 0
              INT32U  OSTimeGet (void)KCREENTRANT
              {
              #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
                  OS_CPU_SR  cpu_sr;
              #endif    
                  INT32U     ticks;
              
              
                  OS_ENTER_CRITICAL();
                  ticks = OSTime;
                  OS_EXIT_CRITICAL();
                  return (ticks);
              }
              #endif    
 200          
 201          /*
 202          *********************************************************************************************************
 203          *                                            SET SYSTEM CLOCK
 204          *
 205          * Description: This function sets the 32-bit counter which keeps track of the number of clock ticks.
 206          *
 207          * Arguments  : ticks      specifies the new value that OSTime needs to take.
 208          *
 209          * Returns    : none
 210          *********************************************************************************************************
 211          */
 212          
 213          #if OS_TIME_GET_SET_EN > 0
              void  OSTimeSet (INT32U ticks)KCREENTRANT
              {
              #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
                  OS_CPU_SR  cpu_sr;
              #endif    
              
              
                  OS_ENTER_CRITICAL();
                  OSTime = ticks;
                  OS_EXIT_CRITICAL();
              }
              #endif    


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    105    ----
   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 + -