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

📄 os_core.lst

📁 51单片机嵌入ucos实例.通过此模块可以对其它型号的51系列单片机进行移值
💻 LST
📖 第 1 页 / 共 4 页
字号:
                      OSTaskCreate(OSTaskStat, 
                                   (void DT_XDATA *)0,                                   /* No args passed to OSTaskStat
             -()    */
                                   &OSTaskStatStk[0],                           /* Set Top-Of-Stack                  */
                                   OS_STAT_PRIO);                               /* One higher than the idle task     */
                      #endif
                  #endif
              #endif
 362   1      }
 363          /*$PAGE*/
 364          /*
 365          *********************************************************************************************************
 366          *                                              ENTER ISR
 367          *
 368          * Description: This function is used to notify uC/OS-II that you are about to service an interrupt
 369          *              service routine (ISR).  This allows uC/OS-II to keep track of interrupt nesting and thus
 370          *              only perform rescheduling at the last nested ISR.
 371          *
 372          * Arguments  : none
 373          *
 374          * Returns    : none
 375          *
 376          * Notes      : 1) Your ISR can directly increment OSIntNesting without calling this function because 
 377          *                 OSIntNesting has been declared 'global'.  You MUST, however, be sure that the increment
 378          *                 is performed 'indivisibly' by your processor to ensure proper access to this critical
 379          *                 resource.
 380          *              2) You MUST still call OSIntExit() even though you increment OSIntNesting directly.
 381          *              3) You MUST invoke OSIntEnter() and OSIntExit() in pair.  In other words, for every call
 382          *                 to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
 383          *                 end of the ISR.
 384          *********************************************************************************************************
 385          */
 386          
 387          void OSIntEnter (void) REENTRANT
 388          {
 389   1          OS_ENTER_CRITICAL();
 390   1          OSIntNesting++;                              /* Increment ISR nesting level                        */
 391   1          OS_EXIT_CRITICAL();
 392   1      }
 393          /*$PAGE*/
 394          /*
 395          *********************************************************************************************************
 396          *                                               EXIT ISR
 397          *
 398          * Description: This function is used to notify uC/OS-II that you have completed serviving an ISR.  When 
 399          *              the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether
 400          *              a new, high-priority task, is ready to run.
 401          *
 402          * Arguments  : none
 403          *
 404          * Returns    : none
 405          *
C51 COMPILER V7.06   OS_CORE                                                               07/30/2008 11:19:14 PAGE 8   

 406          * Notes      : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair.  In other words, for every call
 407          *                 to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the
 408          *                 end of the ISR.
 409          *              2) Rescheduling is prevented when the scheduler is locked (see OSSchedLock())
 410          *********************************************************************************************************
 411          */
 412          
 413          void OSIntExit (void) REENTRANT
 414          {
 415   1          OS_ENTER_CRITICAL();
 416   1          if ((--OSIntNesting | OSLockNesting) == 0) { /* Reschedule only if all ISRs completed & not locked */
 417   2              OSIntExitY    = OSUnMapTbl[OSRdyGrp];
 418   2              OSPrioHighRdy = (INT8U)((OSIntExitY << 3) + OSUnMapTbl[OSRdyTbl[OSIntExitY]]);
 419   2              if (OSPrioHighRdy != OSPrioCur) {        /* No context switch if current task is highest ready */
 420   3                  OSTCBHighRdy  = OSTCBPrioTbl[OSPrioHighRdy];
 421   3                  OSCtxSwCtr++;                        /* Keep track of the number of context switches       */
 422   3                  OSIntCtxSw();                        /* Perform interrupt level context switch             */
 423   3              }
 424   2          }
 425   1          OS_EXIT_CRITICAL();
 426   1      }
 427          /*$PAGE*/
 428          /*
 429          *********************************************************************************************************
 430          *                                              SCHEDULER
 431          *
 432          * Description: This function is called by other uC/OS-II services to determine whether a new, high
 433          *              priority task has been made ready to run.  This function is invoked by TASK level code
 434          *              and is not used to reschedule tasks from ISRs (see OSIntExit() for ISR rescheduling).
 435          *
 436          * Arguments  : none
 437          *
 438          * Returns    : none
 439          *
 440          * Notes      : 1) This function is INTERNAL to uC/OS-II and your application should not call it.
 441          *              2) Rescheduling is prevented when the scheduler is locked (see OSSchedLock())
 442          *********************************************************************************************************
 443          */
 444          
 445          void OSSched (void) REENTRANT
 446          {
 447   1          INT8U y;
 448   1      
 449   1      
 450   1          OS_ENTER_CRITICAL();
 451   1          if ((OSLockNesting | OSIntNesting) == 0) {   /* 不上锁且非中断中调用                                                           */
 452   2              y             = OSUnMapTbl[OSRdyGrp];    /* Get pointer to highest priority task ready to run  */
 453   2              OSPrioHighRdy = (INT8U)((y << 3) + OSUnMapTbl[OSRdyTbl[y]]);
 454   2              if (OSPrioHighRdy != OSPrioCur) {         /* No context switch if current task is highest ready */
 455   3                  OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];
 456   3                  OSCtxSwCtr++;                        /* Increment context switch counter                    */
 457   3                  OS_TASK_SW();                        /* Perform a context switch                            */
 458   3              }
 459   2          }
 460   1          OS_EXIT_CRITICAL();
 461   1      }
 462          /*$PAGE*/
 463          /*
 464          *********************************************************************************************************
 465          *                                          PREVENT SCHEDULING
 466          *
 467          * Description: This function is used to prevent rescheduling to take place.  This allows your application
C51 COMPILER V7.06   OS_CORE                                                               07/30/2008 11:19:14 PAGE 9   

 468          *              to prevent context switches until you are ready to permit context switching.
 469          *
 470          * Arguments  : none
 471          *
 472          * Returns    : none
 473          *
 474          * Notes      : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair.  In other words, for every 
 475          *                 call to OSSchedLock() you MUST have a call to OSSchedUnlock().
 476          *********************************************************************************************************
 477          */
 478          
 479          void OSSchedLock (void) REENTRANT
 480          {
 481   1          if (OSRunning == TRUE) {                     /* Make sure multitasking is running                  */
 482   2              OS_ENTER_CRITICAL();
 483   2              OSLockNesting++;                         /* Increment lock nesting level                       */
 484   2              OS_EXIT_CRITICAL();
 485   2          }
 486   1      }
 487          /*$PAGE*/
 488          /*
 489          *********************************************************************************************************
 490          *                                          ENABLE SCHEDULING
 491          *
 492          * Description: This function is used to re-allow rescheduling.  
 493          *
 494          * Arguments  : none
 495          *
 496          * Returns    : none
 497          *
 498          * Notes      : 1) You MUST invoke OSSchedLock() and OSSchedUnlock() in pair.  In other words, for every 
 499          *                 call to OSSchedLock() you MUST have a call to OSSchedUnlock().
 500          *********************************************************************************************************
 501          */
 502          
 503          void OSSchedUnlock (void) REENTRANT
 504          {
 505   1          if (OSRunning == TRUE) {                           /* Make sure multitasking is running            */
 506   2              OS_ENTER_CRITICAL();
 507   2              if (OSLockNesting > 0) {                       /* Do not decrement if already 0                */
 508   3                  OSLockNesting--;                           /* Decrement lock nesting level                 */
 509   3                  if ((OSLockNesting | OSIntNesting) == 0) { /* See if scheduling re-enabled and not an ISR  */
 510   4                      OS_EXIT_CRITICAL();
 511   4                      OSSched();                             /* See if a higher priority task is ready       */
 512   4                  } else {
 513   4                      OS_EXIT_CRITICAL();
 514   4                  }
 515   3              } else {
 516   3                  OS_EXIT_CRITICAL();
 517   3              }
 518   2          }
 519   1      }
 520          /*$PAGE*/
 521          /*
 522          *********************************************************************************************************
 523          *                                          START MULTITASKING
 524          *
 525          * Description: This function is used to start the multitasking process which lets uC/OS-II manages the
 526          *              task that you have created.  Before you can call OSStart(), you MUST have called OSInit()
 527          *              and you MUST have created at least one task.
 528          *
 529          * Arguments  : none
C51 COMPILER V7.06   OS_CORE                                                               07/30/2008 11:19:14 PAGE 10  

 530          *
 531          * Returns    : none
 532          *
 533          * Note       : OSStartHighRdy() MUST:
 534          *                 a) Call OSTaskSwHook() then,
 535          *                 b) Set OSRunning to TRUE.
 536          *********************************************************************************************************
 537          */
 538          
 539          /* refer to book P96 */
 540          void OSStart (void) REENTRANT
 541          {
 542   1          INT8U y;
 543   1          INT8U x;
 544   1      
 545   1      

⌨️ 快捷键说明

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