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

📄 os_core.lst

📁 uCOS-II_2.52在51上的移植程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
 431          *              waiting for an event to occur.
 432          *
 433          * Arguments  : pevent    is a pointer to the event control block corresponding to the event.
 434          *
 435          *              msg       is a pointer to a message.  This pointer is used by message oriented services
 436          *                        such as MAILBOXEs and QUEUEs.  The pointer is not used when called by other
 437          *                        service functions.
 438          *
 439          *              msk       is a mask that is used to clear the status byte of the TCB.  For example,
 440          *                        OSSemPost() will pass OS_STAT_SEM, OSMboxPost() will pass OS_STAT_MBOX etc.
 441          *
 442          * Returns    : none
 443          *
 444          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 445          *********************************************************************************************************
 446          */
 447          #if OS_EVENT_EN > 0
              INT8U  OS_EventTaskRdy (OS_EVENT *pevent, void *msg, INT8U msk)
              {
                  OS_TCB *ptcb;
                  INT8U   x;
                  INT8U   y;
                  INT8U   bitx;
                  INT8U   bity;
                  INT8U   prio;
              
              
                  y    = OSUnMapTbl[pevent->OSEventGrp];            /* Find highest prio. task waiting for message   */
                  bity = OSMapTbl[y];
                  x    = OSUnMapTbl[pevent->OSEventTbl[y]];
                  bitx = OSMapTbl[x];
                  prio = (INT8U)((y << 3) + x);                     /* Find priority of task getting the msg         */
                  if ((pevent->OSEventTbl[y] &= ~bitx) == 0x00) {   /* Remove this task from the waiting list        */
                      pevent->OSEventGrp &= ~bity;                  /* Clr group bit if this was only task pending   */
                  }
                  ptcb                 =  OSTCBPrioTbl[prio];       /* Point to this task's OS_TCB                   */
                  ptcb->OSTCBDly       =  0;                        /* Prevent OSTimeTick() from readying task       */
                  ptcb->OSTCBEventPtr  = (OS_EVENT *)0;             /* Unlink ECB from this task                     */
              #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0)
                  ptcb->OSTCBMsg       = msg;                       /* Send message directly to waiting task         */
              #else
                  msg                  = msg;                       /* Prevent compiler warning if not used          */
              #endif
                  ptcb->OSTCBStat     &= ~msk;                      /* Clear bit associated with event type          */
                  if (ptcb->OSTCBStat == OS_STAT_RDY) {             /* See if task is ready (could be susp'd)        */
                      OSRdyGrp        |=  bity;                     /* Put task in the ready to run list             */
                      OSRdyTbl[y]     |=  bitx;
                  }
C51 COMPILER V7.50   OS_CORE                                                               08/08/2005 12:35:30 PAGE 9   

                  return (prio);
              }
              #endif
 482          /*$PAGE*/
 483          /*
 484          *********************************************************************************************************
 485          *                                   MAKE TASK WAIT FOR EVENT TO OCCUR
 486          *
 487          * Description: This function is called by other uC/OS-II services to suspend a task because an event has
 488          *              not occurred.
 489          *
 490          * Arguments  : pevent   is a pointer to the event control block for which the task will be waiting for.
 491          *
 492          * Returns    : none
 493          *
 494          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 495          *********************************************************************************************************
 496          */
 497          #if OS_EVENT_EN > 0
              void  OS_EventTaskWait (OS_EVENT *pevent)
              {
                  OSTCBCur->OSTCBEventPtr = pevent;            /* Store pointer to event control block in TCB        */
                  if ((OSRdyTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0x00) {   /* Task no longer ready      */
                      OSRdyGrp &= ~OSTCBCur->OSTCBBitY;        /* Clear event grp bit if this was only task pending  */
                  }
                  pevent->OSEventTbl[OSTCBCur->OSTCBY] |= OSTCBCur->OSTCBBitX;          /* Put task in waiting list  */
                  pevent->OSEventGrp                   |= OSTCBCur->OSTCBBitY;
              }
              #endif
 508          /*$PAGE*/
 509          /*
 510          *********************************************************************************************************
 511          *                              MAKE TASK READY TO RUN BASED ON EVENT TIMEOUT
 512          *
 513          * Description: This function is called by other uC/OS-II services to make a task ready to run because a
 514          *              timeout occurred.
 515          *
 516          * Arguments  : pevent   is a pointer to the event control block which is readying a task.
 517          *
 518          * Returns    : none
 519          *
 520          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 521          *********************************************************************************************************
 522          */
 523          #if OS_EVENT_EN > 0
              void  OS_EventTO (OS_EVENT *pevent)
              {
                  if ((pevent->OSEventTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0x00) {
                      pevent->OSEventGrp &= ~OSTCBCur->OSTCBBitY;
                  }
                  OSTCBCur->OSTCBStat     = OS_STAT_RDY;       /* Set status to ready                                */
                  OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;     /* No longer waiting for event                        */
              }
              #endif
 533          /*$PAGE*/
 534          /*
 535          *********************************************************************************************************
 536          *                                 INITIALIZE EVENT CONTROL BLOCK'S WAIT LIST
 537          *
 538          * Description: This function is called by other uC/OS-II services to initialize the event wait list.
 539          *
 540          * Arguments  : pevent    is a pointer to the event control block allocated to the event.
C51 COMPILER V7.50   OS_CORE                                                               08/08/2005 12:35:30 PAGE 10  

 541          *
 542          * Returns    : none
 543          *
 544          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 545          *********************************************************************************************************
 546          */
 547          #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0) || (OS_SEM_EN > 0) || (OS_MUTEX_EN > 0)
              void  OS_EventWaitListInit (OS_EVENT *pevent)
              {
                  INT8U  *ptbl;
              
              
                  pevent->OSEventGrp = 0x00;                   /* No task waiting on event                           */
                  ptbl               = &pevent->OSEventTbl[0];
              
              #if OS_EVENT_TBL_SIZE > 0
                  *ptbl++            = 0x00;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 1
                  *ptbl++            = 0x00;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 2
                  *ptbl++            = 0x00;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 3
                  *ptbl++            = 0x00;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 4
                  *ptbl++            = 0x00;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 5
                  *ptbl++            = 0x00;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 6
                  *ptbl++            = 0x00;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 7
                  *ptbl              = 0x00;
              #endif
              }
              #endif
 589          /*$PAGE*/
 590          /*
 591          *********************************************************************************************************
 592          *                                             INITIALIZATION
 593          *                           INITIALIZE THE FREE LIST OF EVENT CONTROL BLOCKS
 594          *
 595          * Description: This function is called by OSInit() to initialize the free list of event control blocks.
 596          *
 597          * Arguments  : none
 598          *
 599          * Returns    : none
 600          *********************************************************************************************************
 601          */
 602          
C51 COMPILER V7.50   OS_CORE                                                               08/08/2005 12:35:30 PAGE 11  

 603          static  void  OS_InitEventList (void)
 604          {
 605   1      #if (OS_EVENT_EN > 0) && (OS_MAX_EVENTS > 0)
              #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
                  OSEventFreeList              = &OSEventTbl[0];               /* Only have ONE event control block     
             -   */
                  OSEventFreeList->OSEventType = OS_EVENT_TYPE_UNUSED;
                  OSEventFreeList->OSEventPtr  = (OS_EVENT *)0;
              #endif
              #endif
 629   1      }
 630          /*$PAGE*/
 631          /*
 632          *********************************************************************************************************
 633          *                                             INITIALIZATION
 634          *                                    INITIALIZE MISCELLANEOUS VARIABLES
 635          *
 636          * Description: This function is called by OSInit() to initialize miscellaneous variables.
 637          *
 638          * Arguments  : none
 639          *
 640          * Returns    : none
 641          *********************************************************************************************************
 642          */
 643          
 644          static  void  OS_InitMisc (void)
 645          {
 646   1      #if OS_TIME_GET_SET_EN > 0   
 647   1          OSTime        = 0L;                                          /* Clear the 32-bit system clock         
             -   */
 648   1      #endif
 649   1      
 650   1          OSIntNesting  = 0;                                           /* Clear the interrupt nesting counter   
             -   */
 651   1          OSLockNesting = 0;                                           /* Clear the scheduling lock counter     
             -   */

⌨️ 快捷键说明

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