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

📄 os_core.lst

📁 该源码是本人经调试通过的UCOS2操作系统在51单片机上移植好的源代码
💻 LST
📖 第 1 页 / 共 5 页
字号:
              {
              }
              #endif
 434          
 435          /*$PAGE*/
 436          /*
 437          *********************************************************************************************************
 438          *                             MAKE TASK READY TO RUN BASED ON EVENT OCCURING
 439          *
 440          * Description: This function is called by other uC/OS-II services and is used to ready a task that was
 441          *              waiting for an event to occur.
 442          *
 443          * Arguments  : pevent    is a pointer to the event control block corresponding to the event.
 444          *
 445          *              msg       is a pointer to a message.  This pointer is used by message oriented services
 446          *                        such as MAILBOXEs and QUEUEs.  The pointer is not used when called by other
 447          *                        service functions.
 448          *
 449          *              msk       is a mask that is used to clear the status byte of the TCB.  For example,
 450          *                        OSSemPost() will pass OS_STAT_SEM, OSMboxPost() will pass OS_STAT_MBOX etc.
 451          *
 452          * Returns    : none
 453          *
 454          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 455          *********************************************************************************************************
 456          */
 457          #if OS_EVENT_EN > 0
 458          INT8U  OS_EventTaskRdy (OS_EVENT *pevent, void *msg, INT8U msk)  reentrant
 459          {
 460   1          OS_TCB *ptcb;
 461   1          INT8U   x;
 462   1          INT8U   y;
 463   1          INT8U   bitx;
 464   1          INT8U   bity;
 465   1          INT8U   prio;
 466   1      
 467   1      
 468   1          y    = OSUnMapTbl[pevent->OSEventGrp];            /* Find highest prio. task waiting for message   */
 469   1          bity = OSMapTbl[y];
 470   1          x    = OSUnMapTbl[pevent->OSEventTbl[y]];
 471   1          bitx = OSMapTbl[x];
 472   1          prio = (INT8U)((y << 3) + x);                     /* Find priority of task getting the msg         */
 473   1          if ((pevent->OSEventTbl[y] &= ~bitx) == 0x00) {   /* Remove this task from the waiting list        */
 474   2              pevent->OSEventGrp &= ~bity;                  /* Clr group bit if this was only task pending   */
 475   2          }
 476   1          ptcb                 =  OSTCBPrioTbl[prio];       /* Point to this task's OS_TCB                   */
 477   1          ptcb->OSTCBDly       =  0;                        /* Prevent OSTimeTick() from readying task       */
 478   1          ptcb->OSTCBEventPtr  = (OS_EVENT *)0;             /* Unlink ECB from this task                     */
C51 COMPILER V7.20   OS_CORE                                                               09/25/2006 10:08:38 PAGE 9   

 479   1      #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0)
 480   1          ptcb->OSTCBMsg       = msg;                       /* Send message directly to waiting task         */
 481   1      #else
                  msg                  = msg;                       /* Prevent compiler warning if not used          */
              #endif
 484   1          ptcb->OSTCBStat     &= ~msk;                      /* Clear bit associated with event type          */
 485   1          if (ptcb->OSTCBStat == OS_STAT_RDY) {             /* See if task is ready (could be susp'd)        */
 486   2              OSRdyGrp        |=  bity;                     /* Put task in the ready to run list             */
 487   2              OSRdyTbl[y]     |=  bitx;
 488   2          }
 489   1          return (prio);
 490   1      }
 491          #endif
 492          /*$PAGE*/
 493          /*
 494          *********************************************************************************************************
 495          *                                   MAKE TASK WAIT FOR EVENT TO OCCUR
 496          *
 497          * Description: This function is called by other uC/OS-II services to suspend a task because an event has
 498          *              not occurred.
 499          *
 500          * Arguments  : pevent   is a pointer to the event control block for which the task will be waiting for.
 501          *
 502          * Returns    : none
 503          *
 504          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 505          *********************************************************************************************************
 506          */
 507          #if OS_EVENT_EN > 0
 508          void  OS_EventTaskWait (OS_EVENT *pevent)  reentrant
 509          {
 510   1          OSTCBCur->OSTCBEventPtr = pevent;            /* Store pointer to event control block in TCB        */
 511   1          if ((OSRdyTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0x00) {   /* Task no longer ready      */
 512   2              OSRdyGrp &= ~OSTCBCur->OSTCBBitY;        /* Clear event grp bit if this was only task pending  */
 513   2          }
 514   1          pevent->OSEventTbl[OSTCBCur->OSTCBY] |= OSTCBCur->OSTCBBitX;          /* Put task in waiting list  */
 515   1          pevent->OSEventGrp                   |= OSTCBCur->OSTCBBitY;
 516   1      }
 517          #endif
 518          /*$PAGE*/
 519          /*
 520          *********************************************************************************************************
 521          *                              MAKE TASK READY TO RUN BASED ON EVENT TIMEOUT
 522          *
 523          * Description: This function is called by other uC/OS-II services to make a task ready to run because a
 524          *              timeout occurred.
 525          *
 526          * Arguments  : pevent   is a pointer to the event control block which is readying a task.
 527          *
 528          * Returns    : none
 529          *
 530          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 531          *********************************************************************************************************
 532          */
 533          #if OS_EVENT_EN > 0
 534          void  OS_EventTO (OS_EVENT *pevent)  reentrant
 535          {
 536   1          if ((pevent->OSEventTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0x00) {
 537   2              pevent->OSEventGrp &= ~OSTCBCur->OSTCBBitY;
 538   2          }
 539   1          OSTCBCur->OSTCBStat     = OS_STAT_RDY;       /* Set status to ready                                */
 540   1          OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;     /* No longer waiting for event                        */
C51 COMPILER V7.20   OS_CORE                                                               09/25/2006 10:08:38 PAGE 10  

 541   1      }
 542          #endif
 543          /*$PAGE*/
 544          /*
 545          *********************************************************************************************************
 546          *                                 INITIALIZE EVENT CONTROL BLOCK'S WAIT LIST
 547          *
 548          * Description: This function is called by other uC/OS-II services to initialize the event wait list.
 549          *
 550          * Arguments  : pevent    is a pointer to the event control block allocated to the event.
 551          *
 552          * Returns    : none
 553          *
 554          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 555          *********************************************************************************************************
 556          */
 557          #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0) || (OS_SEM_EN > 0) || (OS_MUTEX_EN > 0)
 558          void  OS_EventWaitListInit (OS_EVENT *pevent) reentrant
 559          {
 560   1          INT8U  *ptbl;
 561   1      
 562   1      
 563   1          pevent->OSEventGrp = 0x00;                   /* No task waiting on event                           */
 564   1          ptbl               = &pevent->OSEventTbl[0];
 565   1      
 566   1      #if OS_EVENT_TBL_SIZE > 0
 567   1          *ptbl++            = 0x00;
 568   1      #endif
 569   1      
 570   1      #if OS_EVENT_TBL_SIZE > 1
 571   1          *ptbl++            = 0x00;
 572   1      #endif
 573   1      
 574   1      #if OS_EVENT_TBL_SIZE > 2
                  *ptbl++            = 0x00;
              #endif
 577   1      
 578   1      #if OS_EVENT_TBL_SIZE > 3
                  *ptbl++            = 0x00;
              #endif
 581   1      
 582   1      #if OS_EVENT_TBL_SIZE > 4
                  *ptbl++            = 0x00;
              #endif
 585   1      
 586   1      #if OS_EVENT_TBL_SIZE > 5
                  *ptbl++            = 0x00;
              #endif
 589   1      
 590   1      #if OS_EVENT_TBL_SIZE > 6
                  *ptbl++            = 0x00;
              #endif
 593   1      
 594   1      #if OS_EVENT_TBL_SIZE > 7
                  *ptbl              = 0x00;
              #endif
 597   1      }
 598          #endif
 599          /*$PAGE*/
 600          /*
 601          *********************************************************************************************************
 602          *                                             INITIALIZATION
C51 COMPILER V7.20   OS_CORE                                                               09/25/2006 10:08:38 PAGE 11  

 603          *                           INITIALIZE THE FREE LIST OF EVENT CONTROL BLOCKS
 604          *
 605          * Description: This function is called by OSInit() to initialize the free list of event control blocks.
 606          *
 607          * Arguments  : none
 608          *
 609          * Returns    : none
 610          *********************************************************************************************************
 611          */
 612          
 613          static  void  OS_InitEventList (void)  reentrant
 614          {
 615   1      #if (OS_EVENT_EN > 0) && (OS_MAX_EVENTS > 0)
 616   1      #if (OS_MAX_EVENTS > 1)
                  INT16U     i;
                  OS_EVENT  *pevent1;
                  OS_EVENT  *pevent2;
              
              
                  pevent1 = &OSEventTbl[0];
                  pevent2 = &OSEventTbl[1];
                  for (i = 0; i < (OS_MAX_EVENTS - 1); i++) {                  /* Init. list of free EVENT control block
             -s  */
                      pevent1->OSEventType = OS_EVENT_TYPE_UNUSED;
                      pevent1->OSEventPtr  = pevent2;
                      pevent1++;
                      pevent2++;
                  }
                  pevent1->OSEventType = OS_EVENT_TYPE_UNUSED;
                  pevent1->OSEventPtr  = (OS_EVENT *)0;
                  OSEventFreeList      = &OSEventTbl[0];
              #else
 634   1          OSEventFreeList              = &OSEventTbl[0];               /* Only have ONE event control block     
             -   */
 635   1          OSEventFreeList->OSEventType = OS_EVENT_TYPE_UNUSED;
 636   1          OSEventFreeList->OSEventPtr  = (OS_EVENT *)0;
 637   1      #endif
 638   1      #endif
 639   1      }
 640          /*$PAGE*/
 641          /*
 642          *********************************************************************************************************
 643          *                                             INITIALIZATION
 644          *                                    INITIALIZE MISCELLANEOUS VARIABLES
 645          *
 646          * Description: This function is called by OSInit() to initialize miscellaneous variables.
 647          *
 648          * Arguments  : none
 649          *
 650          * Returns    : none
 651          *********************************************************************************************************
 652          */
 653          
 654          static  void  OS_InitMisc (void)  reentrant

⌨️ 快捷键说明

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