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

📄 os_time.lst

📁 UCOSII2.85针对8051单片机的移植版本
💻 LST
📖 第 1 页 / 共 2 页
字号:
 138   1      }
 139          #endif
 140          /*$PAGE*/
 141          /*
 142          *********************************************************************************************************
 143          *                                         RESUME A DELAYED TASK
 144          *
 145          * Description: This function is used resume a task that has been delayed through a call to either
 146          *              OSTimeDly() or OSTimeDlyHMSM().  Note that you can call this function to resume a
 147          *              task that is waiting for an event with timeout.  This would make the task look
 148          *              like a timeout occurred.
 149          *
 150          *              Also, you cannot resume a task that has called OSTimeDlyHMSM() with a combined time that
 151          *              exceeds 65535 clock ticks.  In other words, if the clock tick runs at 100 Hz then, you will
 152          *              not be able to resume a delayed task that called OSTimeDlyHMSM(0, 10, 55, 350) or higher:
 153          *
 154          *                  (10 Minutes * 60 + 55 Seconds + 0.35) * 100 ticks/second.
 155          *
 156          * Arguments  : prio                      specifies the priority of the task to resume
 157          *
 158          * Returns    : OS_ERR_NONE               Task has been resumed
 159          *              OS_ERR_PRIO_INVALID       if the priority you specify is higher that the maximum allowed
 160          *                                        (i.e. >= OS_LOWEST_PRIO)
 161          *              OS_ERR_TIME_NOT_DLY       Task is not waiting for time to expire
 162          *              OS_ERR_TASK_NOT_EXIST     The desired task has not been created or has been assigned to a M
             -utex.
 163          *********************************************************************************************************
 164          */
 165          
 166          #if OS_TIME_DLY_RESUME_EN > 0
 167          INT8U  OSTimeDlyResume (INT8U prio) reentrant
 168          {
 169   1          OS_TCB    *ptcb;
 170   1      #if OS_CRITICAL_METHOD == 3                                    /* Storage for CPU status register      */
                  OS_CPU_SR  cpu_sr = 0;
              #endif
 173   1      
 174   1      
 175   1      
 176   1          if (prio >= OS_LOWEST_PRIO) {
 177   2              return (OS_ERR_PRIO_INVALID);
C51 COMPILER V7.50   OS_TIME                                                               12/14/2007 08:25:39 PAGE 4   

 178   2          }
 179   1          OS_ENTER_CRITICAL();
 180   1          ptcb = OSTCBPrioTbl[prio];                                 /* Make sure that task exist            */
 181   1          if (ptcb == (OS_TCB *)0) {
 182   2              OS_EXIT_CRITICAL();
 183   2              return (OS_ERR_TASK_NOT_EXIST);                        /* The task does not exist              */
 184   2          }
 185   1          if (ptcb == OS_TCB_RESERVED) {
 186   2              OS_EXIT_CRITICAL();
 187   2              return (OS_ERR_TASK_NOT_EXIST);                        /* The task does not exist              */
 188   2          }
 189   1          if (ptcb->OSTCBDly == 0) {                                 /* See if task is delayed               */
 190   2              OS_EXIT_CRITICAL();
 191   2              return (OS_ERR_TIME_NOT_DLY);                          /* Indicate that task was not delayed   */
 192   2          }
 193   1      
 194   1          ptcb->OSTCBDly = 0;                                        /* Clear the time delay                 */
 195   1          if ((ptcb->OSTCBStat & OS_STAT_PEND_ANY) != OS_STAT_RDY) {
 196   2              ptcb->OSTCBStat     &= ~OS_STAT_PEND_ANY;              /* Yes, Clear status flag               */
 197   2              ptcb->OSTCBStatPend  =  OS_STAT_PEND_TO;               /* Indicate PEND timeout                */
 198   2          } else {
 199   2              ptcb->OSTCBStatPend  =  OS_STAT_PEND_OK;
 200   2          }
 201   1          if ((ptcb->OSTCBStat & OS_STAT_SUSPEND) == OS_STAT_RDY) {  /* Is task suspended?                   */
 202   2              OSRdyGrp               |= ptcb->OSTCBBitY;             /* No,  Make ready                      */
 203   2              OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
 204   2              OS_EXIT_CRITICAL();
 205   2              OS_Sched();                                            /* See if this is new highest priority  */
 206   2          } else {
 207   2              OS_EXIT_CRITICAL();                                    /* Task may be suspended                */
 208   2          }
 209   1          return (OS_ERR_NONE);
 210   1      }
 211          #endif
 212          /*$PAGE*/
 213          /*
 214          *********************************************************************************************************
 215          *                                         GET CURRENT SYSTEM TIME
 216          *
 217          * Description: This function is used by your application to obtain the current value of the 32-bit
 218          *              counter which keeps track of the number of clock ticks.
 219          *
 220          * Arguments  : none
 221          *
 222          * Returns    : The current value of OSTime
 223          *********************************************************************************************************
 224          */
 225          
 226          #if OS_TIME_GET_SET_EN > 0
 227          INT32U  OSTimeGet (void) reentrant
 228          {
 229   1          INT32U     ticks;
 230   1      #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
                  OS_CPU_SR  cpu_sr = 0;
              #endif
 233   1      
 234   1      
 235   1      
 236   1          OS_ENTER_CRITICAL();
 237   1          ticks = OSTime;
 238   1          OS_EXIT_CRITICAL();
 239   1          return (ticks);
C51 COMPILER V7.50   OS_TIME                                                               12/14/2007 08:25:39 PAGE 5   

 240   1      }
 241          #endif
 242          
 243          /*
 244          *********************************************************************************************************
 245          *                                            SET SYSTEM CLOCK
 246          *
 247          * Description: This function sets the 32-bit counter which keeps track of the number of clock ticks.
 248          *
 249          * Arguments  : ticks      specifies the new value that OSTime needs to take.
 250          *
 251          * Returns    : none
 252          *********************************************************************************************************
 253          */
 254          
 255          #if OS_TIME_GET_SET_EN > 0
 256          void  OSTimeSet (INT32U ticks) reentrant
 257          {
 258   1      #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
                  OS_CPU_SR  cpu_sr = 0;
              #endif
 261   1      
 262   1      
 263   1      
 264   1          OS_ENTER_CRITICAL();
 265   1          OSTime = ticks;
 266   1          OS_EXIT_CRITICAL();
 267   1      }
 268          #endif


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