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

📄 os_core.lst

📁 在51上运行的小的OS系统
💻 LST
📖 第 1 页 / 共 5 页
字号:
 584          /*
 585          *********************************************************************************************************
C51 COMPILER V8.08   OS_CORE                                                               08/04/2008 21:49:51 PAGE 12  

 586          *                                             GET VERSION
 587          *
 588          * Description: This function is used to return the version number of uC/OS-II.  The returned value
 589          *              corresponds to uC/OS-II's version number multiplied by 100.  In other words, version 2.00
 590          *              would be returned as 200.
 591          *
 592          * Arguments  : none
 593          *
 594          * Returns    : the version number of uC/OS-II multiplied by 100.
 595          *********************************************************************************************************
 596          */
 597          
 598          INT16U  OSVersion (void)
 599          {
 600              return (OS_VERSION);
 601          }
 602          
 603          /*$PAGE*/
 604          /*
 605          *********************************************************************************************************
 606          *                                            DUMMY FUNCTION
 607          *
 608          * Description: This function doesn't do anything.  It is called by OSTaskDel().
 609          *
 610          * Arguments  : none
 611          *
 612          * Returns    : none
 613          *********************************************************************************************************
 614          */
 615          
 616          #if OS_TASK_DEL_EN > 0
 617          void  OS_Dummy (void)
 618          {
 619          }
 620          #endif
 621          
 622          /*$PAGE*/
 623          /*
 624          *********************************************************************************************************
 625          *                             MAKE TASK READY TO RUN BASED ON EVENT OCCURING
 626          *
 627          * Description: This function is called by other uC/OS-II services and is used to ready a task that was
 628          *              waiting for an event to occur.
 629          *
 630          * Arguments  : pevent    is a pointer to the event control block corresponding to the event.
 631          *
 632          *              msg       is a pointer to a message.  This pointer is used by message oriented services
 633          *                        such as MAILBOXEs and QUEUEs.  The pointer is not used when called by other
 634          *                        service functions.
 635          *
 636          *              msk       is a mask that is used to clear the status byte of the TCB.  For example,
 637          *                        OSSemPost() will pass OS_STAT_SEM, OSMboxPost() will pass OS_STAT_MBOX etc.
 638          *
 639          * Returns    : none
 640          *
 641          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 642          *********************************************************************************************************
 643          */
 644          #if OS_EVENT_EN
 645          INT8U  OS_EventTaskRdy (OS_EVENT *pevent, void *msg, INT8U msk)
 646          {
 647              OS_TCB  *ptcb;
C51 COMPILER V8.08   OS_CORE                                                               08/04/2008 21:49:51 PAGE 13  

 648              INT8U    x;
 649              INT8U    y;
 650              INT8U    prio;
 651          #if OS_LOWEST_PRIO <= 63
 652              INT8U    bitx;
 653              INT8U    bity;
 654          #else
                  INT16U   bitx;
                  INT16U   bity;
                  INT16U  *ptbl;
              #endif
 659          
 660          
 661          #if OS_LOWEST_PRIO <= 63
 662              y     = OSUnMapTbl[pevent->OSEventGrp];             /* Find HPT waiting for message                */
 663              bity  = 1 << y;
 664              x     = OSUnMapTbl[pevent->OSEventTbl[y]];
 665              bitx  = 1 << x;
 666              prio  = (INT8U)((y << 3) + x);                      /* Find priority of task getting the msg       */
 667          #else
                  if ((pevent->OSEventGrp & 0xFF) != 0) {             /* Find HPT waiting for message                */
                      y = OSUnMapTbl[pevent->OSEventGrp & 0xFF];
                  } else {
                      y = OSUnMapTbl[(pevent->OSEventGrp >> 8) & 0xFF] + 8;
                  }
                  bity = 1 << y;
                  ptbl = &pevent->OSEventTbl[y];
                  if ((*ptbl & 0xFF) != 0) {
                      x = OSUnMapTbl[*ptbl & 0xFF];
                  } else {
                      x = OSUnMapTbl[(*ptbl >> 8) & 0xFF] + 8;
                  }
                  bitx = 1 << x;
                  prio = (INT8U)((y << 4) + x);                       /* Find priority of task getting the msg       */
              #endif
 683          
 684              pevent->OSEventTbl[y] &= ~bitx;                     /* Remove this task from the waiting list      */
 685              if (pevent->OSEventTbl[y] == 0) {
 686                  pevent->OSEventGrp &= ~bity;                    /* Clr group bit if this was only task pending */
 687              }
 688              ptcb                 =  OSTCBPrioTbl[prio];         /* Point to this task's OS_TCB                 */
 689              ptcb->OSTCBDly       =  0;                          /* Prevent OSTimeTick() from readying task     */
 690              ptcb->OSTCBEventPtr  = (OS_EVENT *)0;               /* Unlink ECB from this task                   */
 691          #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0)
 692              ptcb->OSTCBMsg       = msg;                         /* Send message directly to waiting task       */
 693          #else
                  msg                  = msg;                         /* Prevent compiler warning if not used        */
              #endif
 696              ptcb->OSTCBPendTO    = FALSE;                       /* Cancel 'any' timeout because of post        */
 697              ptcb->OSTCBStat     &= ~msk;                        /* Clear bit associated with event type        */
 698              if (ptcb->OSTCBStat == OS_STAT_RDY) {               /* See if task is ready (could be susp'd)      */
 699                  OSRdyGrp        |=  bity;                       /* Put task in the ready to run list           */
 700                  OSRdyTbl[y]     |=  bitx;
 701              }
 702              return (prio);
 703          }
 704          #endif
 705          /*$PAGE*/
 706          /*
 707          *********************************************************************************************************
 708          *                                   MAKE TASK WAIT FOR EVENT TO OCCUR
 709          *
C51 COMPILER V8.08   OS_CORE                                                               08/04/2008 21:49:51 PAGE 14  

 710          * Description: This function is called by other uC/OS-II services to suspend a task because an event has
 711          *              not occurred.
 712          *
 713          * Arguments  : pevent   is a pointer to the event control block for which the task will be waiting for.
 714          *
 715          * Returns    : none
 716          *
 717          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 718          *********************************************************************************************************
 719          */
 720          #if OS_EVENT_EN
 721          void  OS_EventTaskWait (OS_EVENT *pevent)
 722          {
 723              INT8U  y;
 724          
 725          
 726              OSTCBCur->OSTCBEventPtr = pevent;             /* Store pointer to event control block in TCB       */
 727              y                       = OSTCBCur->OSTCBY;   /* Task no longer ready                              */
 728              OSRdyTbl[y]            &= ~OSTCBCur->OSTCBBitX;
 729              if (OSRdyTbl[y] == 0) {
 730                  OSRdyGrp &= ~OSTCBCur->OSTCBBitY;         /* Clear event grp bit if this was only task pending */
 731              }
 732              pevent->OSEventTbl[OSTCBCur->OSTCBY] |= OSTCBCur->OSTCBBitX;          /* Put task in waiting list  */
 733              pevent->OSEventGrp                   |= OSTCBCur->OSTCBBitY;
 734          }
 735          #endif
 736          /*$PAGE*/
 737          /*
 738          *********************************************************************************************************
 739          *                              MAKE TASK READY TO RUN BASED ON EVENT TIMEOUT
 740          *
 741          * Description: This function is called by other uC/OS-II services to make a task ready to run because a
 742          *              timeout occurred.
 743          *
 744          * Arguments  : pevent   is a pointer to the event control block which is readying a task.
 745          *
 746          * Returns    : none
 747          *
 748          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 749          *********************************************************************************************************
 750          */
 751          #if OS_EVENT_EN
 752          void  OS_EventTO (OS_EVENT *pevent)
 753          {
 754              INT8U  y;
 755          
 756          
 757              y                      = OSTCBCur->OSTCBY;
 758              pevent->OSEventTbl[y] &= ~OSTCBCur->OSTCBBitX;     /* Remove task from wait list                   */
 759              if (pevent->OSEventTbl[y] == 0x00) {
 760                  pevent->OSEventGrp &= ~OSTCBCur->OSTCBBitY;
 761              }
 762              OSTCBCur->OSTCBPendTO   = FALSE;                   /* Clear the Pend Timeout flag                  */
 763              OSTCBCur->OSTCBStat     = OS_STAT_RDY;             /* Set status to ready                          */
 764              OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;           /* No longer waiting for event                  */
 765          }
 766          #endif
 767          /*$PAGE*/
 768          /*
 769          *********************************************************************************************************
 770          *                                 INITIALIZE EVENT CONTROL BLOCK'S WAIT LIST
 771          *
C51 COMPILER V8.08   OS_CORE                                                               08/04/2008 21:49:51 PAGE 15  

 772          * Description: This function is called by other uC/OS-II services to initialize the event wait list.
 773          *
 774          * Arguments  : pevent    is a pointer to the event control block allocated to the event.
 775          *
 776          * Returns    : none
 777          *
 778          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 779          *********************************************************************************************************
 780          */
 781          #if OS_EVENT_EN
 782          void  OS_EventWaitListInit (OS_EVENT *pevent)
 783          {
 784          #if OS_LOWEST_PRIO <= 63
 785              INT8U  *ptbl;
 786          #else
                  INT16U *ptbl;
              #endif
 789              INT8U   i;
 790          
 791          
 792              pevent->OSEventGrp = 0;                      /* No task waiting on event                           */
 793              ptbl               = &pevent->OSEventTbl[0];
 794          
 795              for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
 796                  *ptbl++ = 0;
 797              }
 798          }
 799          #endif
 800          /*$PAGE*/
 801          /*
 802          *********************************************************************************************************
 803          *                                             INITIALIZATION
 804          *                           INITIALIZE THE FREE LIST OF EVENT CONTROL BLOCKS
 805          *
 806          * Description: This function is called by OSInit() to initialize the free list of event control blocks.
 807          *
 808          * Arguments  : none
 809          *

⌨️ 快捷键说明

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