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

📄 os_core.lst

📁 UCOSII2.85针对8051单片机的移植版本
💻 LST
📖 第 1 页 / 共 5 页
字号:
 443   4                      OS_EXIT_CRITICAL();
 444   4                  }
 445   3              } else {
 446   3                  OS_EXIT_CRITICAL();
 447   3              }
 448   2          }
 449   1      }
 450          #endif
 451          
 452          /*$PAGE*/
 453          /*
 454          *********************************************************************************************************
 455          *                                          START MULTITASKING
 456          *
 457          * Description: This function is used to start the multitasking process which lets uC/OS-II manages the
 458          *              task that you have created.  Before you can call OSStart(), you MUST have called OSInit()
 459          *              and you MUST have created at least one task.
 460          *
 461          * Arguments  : none
 462          *
 463          * Returns    : none
 464          *
 465          * Note       : OSStartHighRdy() MUST:
 466          *                 a) Call OSTaskSwHook() then,
 467          *                 b) Set OSRunning to OS_TRUE.
 468          *                 c) Load the context of the task pointed to by OSTCBHighRdy.
 469          *                 d_ Execute the task.
 470          *********************************************************************************************************
 471          */
 472          
 473          void  OSStart (void) reentrant
 474          {
 475   1          if (OSRunning == OS_FALSE) {
 476   2              OS_SchedNew();                               /* Find highest priority's task priority number   */
C51 COMPILER V7.50   OS_CORE                                                               12/14/2007 08:25:29 PAGE 9   

 477   2              OSPrioCur     = OSPrioHighRdy;
 478   2              OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy]; /* Point to highest priority task ready to run    */
 479   2              OSTCBCur      = OSTCBHighRdy;
 480   2              OSStartHighRdy();                            /* Execute target specific code to start task     */
 481   2          }
 482   1      }
 483          /*$PAGE*/
 484          /*
 485          *********************************************************************************************************
 486          *                                        STATISTICS INITIALIZATION
 487          *
 488          * Description: This function is called by your application to establish CPU usage by first determining
 489          *              how high a 32-bit counter would count to in 1 second if no other tasks were to execute
 490          *              during that time.  CPU usage is then determined by a low priority task which keeps track
 491          *              of this 32-bit counter every second but this time, with other tasks running.  CPU usage is
 492          *              determined by:
 493          *
 494          *                                             OSIdleCtr
 495          *                 CPU Usage (%) = 100 * (1 - ------------)
 496          *                                            OSIdleCtrMax
 497          *
 498          * Arguments  : none
 499          *
 500          * Returns    : none
 501          *********************************************************************************************************
 502          */
 503          
 504          #if OS_TASK_STAT_EN > 0
 505          void  OSStatInit (void) reentrant
 506          {
 507   1      #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
                  OS_CPU_SR  cpu_sr = 0;
              #endif
 510   1      
 511   1      
 512   1      
 513   1          OSTimeDly(2);                                /* Synchronize with clock tick                        */
 514   1          OS_ENTER_CRITICAL();
 515   1          OSIdleCtr    = 0L;                           /* Clear idle counter                                 */
 516   1          OS_EXIT_CRITICAL();
 517   1          OSTimeDly(OS_TICKS_PER_SEC / 10);            /* Determine MAX. idle counter value for 1/10 second  */
 518   1          OS_ENTER_CRITICAL();
 519   1          OSIdleCtrMax = OSIdleCtr;                    /* Store maximum idle counter count in 1/10 second    */
 520   1          OSStatRdy    = OS_TRUE;
 521   1          OS_EXIT_CRITICAL();
 522   1      }
 523          #endif
 524          /*$PAGE*/
 525          /*
 526          *********************************************************************************************************
 527          *                                         PROCESS SYSTEM TICK
 528          *
 529          * Description: This function is used to signal to uC/OS-II the occurrence of a 'system tick' (also known
 530          *              as a 'clock tick').  This function should be called by the ticker ISR but, can also be
 531          *              called by a high priority task.
 532          *
 533          * Arguments  : none
 534          *
 535          * Returns    : none
 536          *********************************************************************************************************
 537          */
 538          
C51 COMPILER V7.50   OS_CORE                                                               12/14/2007 08:25:29 PAGE 10  

 539          void  OSTimeTick (void) reentrant
 540          {
 541   1          OS_TCB    *ptcb;
 542   1      #if OS_TICK_STEP_EN > 0
                  BOOLEAN    step;
              #endif
 545   1      #if OS_CRITICAL_METHOD == 3                                /* Allocate storage for CPU status register    
             - */
                  OS_CPU_SR  cpu_sr = 0;
              #endif
 548   1      
 549   1      
 550   1      
 551   1      #if OS_TIME_TICK_HOOK_EN > 0
 552   1          OSTimeTickHook();                                      /* Call user definable hook                    
             - */
 553   1      #endif
 554   1      #if OS_TIME_GET_SET_EN > 0
 555   1          OS_ENTER_CRITICAL();                                   /* Update the 32-bit tick counter              
             - */
 556   1          OSTime++;
 557   1          OS_EXIT_CRITICAL();
 558   1      #endif
 559   1          if (OSRunning == OS_TRUE) {
 560   2      #if OS_TICK_STEP_EN > 0
                      switch (OSTickStepState) {                         /* Determine whether we need to process a tick 
             - */
                          case OS_TICK_STEP_DIS:                         /* Yes, stepping is disabled                   
             - */
                               step = OS_TRUE;
                               break;
              
                          case OS_TICK_STEP_WAIT:                        /* No,  waiting for uC/OS-View to set ...      
             - */
                               step = OS_FALSE;                          /*      .. OSTickStepState to OS_TICK_STEP_ONCE
             - */
                               break;
              
                          case OS_TICK_STEP_ONCE:                        /* Yes, process tick once and wait for next ...
             - */
                               step            = OS_TRUE;                /*      ... step command from uC/OS-View       
             - */
                               OSTickStepState = OS_TICK_STEP_WAIT;
                               break;
              
                          default:                                       /* Invalid case, correct situation             
             - */
                               step            = OS_TRUE;
                               OSTickStepState = OS_TICK_STEP_DIS;
                               break;
                      }
                      if (step == OS_FALSE) {                            /* Return if waiting for step command          
             - */
                          return;
                      }
              #endif
 584   2              ptcb = OSTCBList;                                  /* Point at first TCB in TCB list              
             - */
 585   2              while (ptcb->OSTCBPrio != OS_TASK_IDLE_PRIO) {     /* Go through all TCBs in TCB list             
             - */
 586   3                  OS_ENTER_CRITICAL();
 587   3                  if (ptcb->OSTCBDly != 0) {                     /* No, Delayed or waiting for event with TO    
C51 COMPILER V7.50   OS_CORE                                                               12/14/2007 08:25:29 PAGE 11  

             - */
 588   4                      if (--ptcb->OSTCBDly == 0) {               /* Decrement nbr of ticks to end of delay      
             - */
 589   5                                                                 /* Check for timeout                           
             - */
 590   5                          if ((ptcb->OSTCBStat & OS_STAT_PEND_ANY) != OS_STAT_RDY) {
 591   6                              ptcb->OSTCBStat  &= ~(INT8U)OS_STAT_PEND_ANY;          /* Yes, Clear status flag  
             - */
 592   6                              ptcb->OSTCBStatPend = OS_STAT_PEND_TO;                 /* Indicate PEND timeout   
             - */
 593   6                          } else {
 594   6                              ptcb->OSTCBStatPend = OS_STAT_PEND_OK;
 595   6                          }
 596   5      
 597   5                          if ((ptcb->OSTCBStat & OS_STAT_SUSPEND) == OS_STAT_RDY) {  /* Is task suspended?      
             - */
 598   6                              OSRdyGrp               |= ptcb->OSTCBBitY;             /* No,  Make ready         
             - */
 599   6                              OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
 600   6                          }
 601   5                      }
 602   4                  }
 603   3                  ptcb = ptcb->OSTCBNext;                        /* Point at next TCB in TCB list               
             - */
 604   3                  OS_EXIT_CRITICAL();
 605   3              }
 606   2          }
 607   1      }
 608          
 609          /*$PAGE*/
 610          /*
 611          *********************************************************************************************************
 612          *                                             GET VERSION
 613          *
 614          * Description: This function is used to return the version number of uC/OS-II.  The returned value
 615          *              corresponds to uC/OS-II's version number multiplied by 100.  In other words, version 2.00
 616          *              would be returned as 200.
 617          *
 618          * Arguments  : none
 619          *
 620          * Returns    : the version number of uC/OS-II multiplied by 100.
 621          *********************************************************************************************************
 622          */
 623          
 624          INT16U  OSVersion (void) reentrant
 625          {
 626   1          return (OS_VERSION);
 627   1      }
 628          
 629          /*$PAGE*/
 630          /*
 631          *********************************************************************************************************
 632          *                                            DUMMY FUNCTION
 633          *
 634          * Description: This function doesn't do anything.  It is called by OSTaskDel().
 635          *
 636          * Arguments  : none
 637          *
 638          * Returns    : none
 639          *********************************************************************************************************
 640          */
 641          
C51 COMPILER V7.50   OS_CORE                                                               12/14/2007 08:25:29 PAGE 12  

 642          #if OS_TASK_DEL_EN > 0
 643          void  OS_Dummy (void) reentrant
 644          {
 645   1      }
 646          #endif
 647          
 648          /*$PAGE*/
 649          /*
 650          *********************************************************************************************************
 651          *                             MAKE TASK READY TO RUN BASED ON EVENT OCCURING
 652          *

⌨️ 快捷键说明

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