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

📄 os_flag.lst

📁 一个关于UCOS的KEIL工程
💻 LST
📖 第 1 页 / 共 4 页
字号:
 682   2              return ((OS_FLAGS)0);
 683   2          }
 684   1      #endif
 685   1          OS_ENTER_CRITICAL();
 686   1          flags = pgrp->OSFlagFlags;
 687   1          OS_EXIT_CRITICAL();
 688   1          *err = OS_NO_ERR;
 689   1          return (flags);                               /* Return the current value of the event flags       */
 690   1      }
 691          #endif
 692          
 693          /*$PAGE*/
 694          /*
 695          *********************************************************************************************************
 696          *                         SUSPEND TASK UNTIL EVENT FLAG(s) RECEIVED OR TIMEOUT OCCURS
 697          *
 698          * Description: This function is internal to uC/OS-II and is used to put a task to sleep until the desired
 699          *              event flag bit(s) are set.
 700          *
 701          * Arguments  : pgrp          is a pointer to the desired event flag group.
 702          *
 703          *              pnode         is a pointer to a structure which contains data about the task waiting for
 704          *                            event flag bit(s) to be set.
 705          *
 706          *              flags         Is a bit pattern indicating which bit(s) (i.e. flags) you wish to check.
 707          *                            The bits you want are specified by setting the corresponding bits in
 708          *                            'flags'.  e.g. if your application wants to wait for bits 0 and 1 then
 709          *                            'flags' would contain 0x03.
 710          *
 711          *              wait_type     specifies whether you want ALL bits to be set/cleared or ANY of the bits
 712          *                            to be set/cleared.
 713          *                            You can specify the following argument:
 714          *
 715          *                            OS_FLAG_WAIT_CLR_ALL   You will check ALL bits in 'mask' to be clear (0)
 716          *                            OS_FLAG_WAIT_CLR_ANY   You will check ANY bit  in 'mask' to be clear (0)
 717          *                            OS_FLAG_WAIT_SET_ALL   You will check ALL bits in 'mask' to be set   (1)
 718          *                            OS_FLAG_WAIT_SET_ANY   You will check ANY bit  in 'mask' to be set   (1)
 719          *
 720          *              timeout       is the desired amount of time that the task will wait for the event flag
 721          *                            bit(s) to be set.
 722          *
 723          * Returns    : none
 724          *
 725          * Called by  : OSFlagPend()  OS_FLAG.C
 726          *
 727          * Note(s)    : This function is INTERNAL to uC/OS-II and your application should not call it.
 728          *********************************************************************************************************
 729          */
 730          
 731          static  void  OS_FlagBlock (OS_FLAG_GRP *pgrp, OS_FLAG_NODE *pnode, OS_FLAGS flags, INT8U wait_type, INT16
             -U timeout) KCREENTRANT
 732          {
 733   1          OS_FLAG_NODE  *pnode_next;
 734   1      
C51 COMPILER V6.23a  OS_FLAG                                                               12/09/2004 16:50:25 PAGE 13  

 735   1      
 736   1          OSTCBCur->OSTCBStat      |= OS_STAT_FLAG;
 737   1          OSTCBCur->OSTCBDly        = timeout;              /* Store timeout in task's TCB                   */
 738   1      #if OS_TASK_DEL_EN > 0
 739   1          OSTCBCur->OSTCBFlagNode   = pnode;                /* TCB to link to node                           */
 740   1      #endif
 741   1          pnode->OSFlagNodeFlags    = flags;                /* Save the flags that we need to wait for       */
 742   1          pnode->OSFlagNodeWaitType = wait_type;            /* Save the type of wait we are doing            */
 743   1          pnode->OSFlagNodeTCB      = (void *)OSTCBCur;     /* Link to task's TCB                            */
 744   1          pnode->OSFlagNodeNext     = pgrp->OSFlagWaitList; /* Add node at beginning of event flag wait list */
 745   1          pnode->OSFlagNodePrev     = (void *)0;
 746   1          pnode->OSFlagNodeFlagGrp  = (void *)pgrp;         /* Link to Event Flag Group                      */
 747   1          pnode_next                = (OS_FLAG_NODE *)pgrp->OSFlagWaitList;
 748   1          if (pnode_next != (void *)0) {                    /* Is this the first NODE to insert?             */
 749   2              pnode_next->OSFlagNodePrev = pnode;           /* No, link in doubly linked list                */
 750   2          }
 751   1          pgrp->OSFlagWaitList = (void *)pnode;
 752   1                                                            /* Suspend current task until flag(s) received   */
 753   1          if ((OSRdyTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0) {
 754   2              OSRdyGrp &= ~OSTCBCur->OSTCBBitY;
 755   2          }
 756   1      }
 757          
 758          /*$PAGE*/
 759          /*
 760          *********************************************************************************************************
 761          *                                    INITIALIZE THE EVENT FLAG MODULE
 762          *
 763          * Description: This function is called by uC/OS-II to initialize the event flag module.  Your application
 764          *              MUST NOT call this function.  In other words, this function is internal to uC/OS-II.
 765          *
 766          * Arguments  : none
 767          *
 768          * Returns    : none
 769          *
 770          * WARNING    : You MUST NOT call this function from your code.  This is an INTERNAL function to uC/OS-II.
 771          *********************************************************************************************************
 772          */
 773          
 774          void  OS_FlagInit (void) KCREENTRANT
 775          {
 776   1      #if OS_MAX_FLAGS == 1
                  OSFlagFreeList                 = (OS_FLAG_GRP *)&OSFlagTbl[0];  /* Only ONE event flag group!      */
                  OSFlagFreeList->OSFlagType     = OS_EVENT_TYPE_UNUSED;
                  OSFlagFreeList->OSFlagWaitList = (void *)0;
              #endif
 781   1      
 782   1      #if OS_MAX_FLAGS >= 2
 783   1          INT8U        i;
 784   1          OS_FLAG_GRP *pgrp1;
 785   1          OS_FLAG_GRP *pgrp2;
 786   1      
 787   1      
 788   1          pgrp1 = &OSFlagTbl[0];
 789   1          pgrp2 = &OSFlagTbl[1];
 790   1          for (i = 0; i < (OS_MAX_FLAGS - 1); i++) {                      /* Init. list of free EVENT FLAGS  */
 791   2              pgrp1->OSFlagType     = OS_EVENT_TYPE_UNUSED;
 792   2              pgrp1->OSFlagWaitList = (void *)pgrp2;
 793   2              pgrp1++;
 794   2              pgrp2++;
 795   2          }
 796   1          pgrp1->OSFlagWaitList = (void *)0;
C51 COMPILER V6.23a  OS_FLAG                                                               12/09/2004 16:50:25 PAGE 14  

 797   1          OSFlagFreeList        = (OS_FLAG_GRP *)&OSFlagTbl[0];
 798   1      #endif
 799   1      }
 800          
 801          /*$PAGE*/
 802          /*
 803          *********************************************************************************************************
 804          *                              MAKE TASK READY-TO-RUN, EVENT(s) OCCURRED
 805          *
 806          * Description: This function is internal to uC/OS-II and is used to make a task ready-to-run because the
 807          *              desired event flag bits have been set.
 808          *
 809          * Arguments  : pnode         is a pointer to a structure which contains data about the task waiting for
 810          *                            event flag bit(s) to be set.
 811          *
 812          *              flags_rdy     contains the bit pattern of the event flags that cause the task to become
 813          *                            ready-to-run.
 814          *
 815          * Returns    : none
 816          *
 817          * Called by  : OSFlagsPost() OS_FLAG.C
 818          *
 819          * Note(s)    : 1) This function assumes that interrupts are disabled.
 820          *              2) This function is INTERNAL to uC/OS-II and your application should not call it.
 821          *********************************************************************************************************
 822          */
 823          
 824          static  BOOLEAN  OS_FlagTaskRdy (OS_FLAG_NODE *pnode, OS_FLAGS flags_rdy) KCREENTRANT
 825          {
 826   1          OS_TCB   *ptcb;
 827   1          BOOLEAN   sched;
 828   1      
 829   1      
 830   1          ptcb                = (OS_TCB *)pnode->OSFlagNodeTCB;  /* Point to TCB of waiting task             */
 831   1          ptcb->OSTCBDly      = 0;
 832   1          ptcb->OSTCBFlagsRdy = flags_rdy;
 833   1          ptcb->OSTCBStat    &= ~OS_STAT_FLAG;
 834   1          if (ptcb->OSTCBStat == OS_STAT_RDY) {                  /* Put task into ready list                 */
 835   2              OSRdyGrp               |= ptcb->OSTCBBitY;
 836   2              OSRdyTbl[ptcb->OSTCBY] |= ptcb->OSTCBBitX;
 837   2              sched                   = TRUE;
 838   2          } else {
 839   2              sched                   = FALSE;
 840   2          }
 841   1          OS_FlagUnlink(pnode);
 842   1          return (sched);
 843   1      }
 844          
 845          /*$PAGE*/
 846          /*
 847          *********************************************************************************************************
 848          *                                  UNLINK EVENT FLAG NODE FROM WAITING LIST
 849          *
 850          * Description: This function is internal to uC/OS-II and is used to unlink an event flag node from a
 851          *              list of tasks waiting for the event flag.
 852          *
 853          * Arguments  : pnode         is a pointer to a structure which contains data about the task waiting for
 854          *                            event flag bit(s) to be set.
 855          *
 856          * Returns    : none
 857          *
 858          * Called by  : OS_FlagTaskRdy() OS_FLAG.C
C51 COMPILER V6.23a  OS_FLAG                                                               12/09/2004 16:50:25 PAGE 15  

 859          *              OSFlagPend()     OS_FLAG.C
 860          *              OSTaskDel()      OS_TASK.C
 861          *
 862          * Note(s)    : 1) This function assumes that interrupts are disabled.
 863          *              2) This function is INTERNAL to uC/OS-II and your application should not call it.
 864          *********************************************************************************************************
 865          */
 866          
 867          void  OS_FlagUnlink (OS_FLAG_NODE *pnode) KCREENTRANT
 868          {
 869   1      #if OS_TASK_DEL_EN > 0
 870   1          OS_TCB       *ptcb;
 871   1      #endif
 872   1          OS_FLAG_GRP  *pgrp;
 873   1          OS_FLAG_NODE *pnode_prev;
 874   1          OS_FLAG_NODE *pnode_next;
 875   1      
 876   1      
 877   1          pnode_prev = (OS_FLAG_NODE *)pnode->OSFlagNodePrev;
 878   1          pnode_next = (OS_FLAG_NODE *)pnode->OSFlagNodeNext;
 879   1          if (pnode_prev == (OS_FLAG_NODE *)0) {                      /* Is it first node in wait list?      */
 880   2              pgrp                 = (OS_FLAG_GRP *)pnode->OSFlagNodeFlagGrp;
 881   2              pgrp->OSFlagWaitList = (void *)pnode_next;              /*      Update list for new 1st node   */
 882   2              if (pnode_next != (OS_FLAG_NODE *)0) {
 883   3                  pnode_next->OSFlagNodePrev = (OS_FLAG_NODE *)0;     /*      Link new 1st node PREV to NULL */
 884   3              }
 885   2          } else {                                                    /* No,  A node somewhere in the list   */
 886   2              pnode_prev->OSFlagNodeNext = pnode_next;                /*      Link around the node to unlink */
 887   2              if (pnode_next != (OS_FLAG_NODE *)0) {                  /*      Was this the LAST node?        */
 888   3                  pnode_next->OSFlagNodePrev = pnode_prev;            /*      No, Link around current node   */
 889   3              }
 890   2          }
 891   1      #if OS_TASK_DEL_EN > 0
 892   1          ptcb                = (OS_TCB *)pnode->OSFlagNodeTCB;
 893   1          ptcb->OSTCBFlagNode = (OS_FLAG_NODE *)0;
 894   1      #endif
 895   1      }
 896          #endif


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   5211    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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