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

📄 os_flag.lst

📁 1. UC/OS 8051中完全应用。 2. 显示各个任务的执行时间, 执行时间占总时间百分比, tick计数器 3.任务中信号量,消息以及消息队列的使用。 我自己仔细测试过了
💻 LST
📖 第 1 页 / 共 4 页
字号:
                      return ((OS_FLAGS)0);
                  }
              #endif    
                  OS_ENTER_CRITICAL();
                  flags = pgrp->OSFlagFlags;
                  OS_EXIT_CRITICAL();
                  *err = OS_NO_ERR;
                  return (flags);                               /* Return the current value of the event flags       */
              }
              #endif
 693          
 694          /*$PAGE*/
 695          /*
 696          *********************************************************************************************************
 697          *                         SUSPEND TASK UNTIL EVENT FLAG(s) RECEIVED OR TIMEOUT OCCURS
 698          *
 699          * Description: This function is internal to uC/OS-II and is used to put a task to sleep until the desired
 700          *              event flag bit(s) are set.
 701          *
 702          * Arguments  : pgrp          is a pointer to the desired event flag group.
 703          *
 704          *              pnode         is a pointer to a structure which contains data about the task waiting for 
 705          *                            event flag bit(s) to be set.
 706          *
 707          *              flags         Is a bit pattern indicating which bit(s) (i.e. flags) you wish to check.  
 708          *                            The bits you want are specified by setting the corresponding bits in 
 709          *                            'flags'.  e.g. if your application wants to wait for bits 0 and 1 then 
 710          *                            'flags' would contain 0x03.
 711          *
 712          *              wait_type     specifies whether you want ALL bits to be set/cleared or ANY of the bits 
 713          *                            to be set/cleared.
 714          *                            You can specify the following argument:
 715          *
 716          *                            OS_FLAG_WAIT_CLR_ALL   You will check ALL bits in 'mask' to be clear (0)
 717          *                            OS_FLAG_WAIT_CLR_ANY   You will check ANY bit  in 'mask' to be clear (0)
 718          *                            OS_FLAG_WAIT_SET_ALL   You will check ALL bits in 'mask' to be set   (1)
 719          *                            OS_FLAG_WAIT_SET_ANY   You will check ANY bit  in 'mask' to be set   (1)
 720          *
 721          *              timeout       is the desired amount of time that the task will wait for the event flag 
 722          *                            bit(s) to be set.
 723          *
 724          * Returns    : none
 725          *
 726          * Called by  : OSFlagPend()  OS_FLAG.C
 727          *
 728          * Note(s)    : This function is INTERNAL to uC/OS-II and your application should not call it.
 729          *********************************************************************************************************
 730          */
 731          
 732          static  void  OS_FlagBlock (OS_FLAG_GRP *pgrp, OS_FLAG_NODE *pnode, OS_FLAGS flags, INT8U wait_type, INT16
             -U timeout) reentrant
C51 COMPILER V8.08   OS_FLAG                                                               08/19/2008 10:59:08 PAGE 13  

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

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

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


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   3026    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
   EDATA SIZE       =   ----    ----
   HDATA SIZE       =   ----    ----
   XDATA CONST SIZE =   ----    ----
   FAR CONST SIZE   =   ----    ----
END OF MODULE INFORMATION.


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

⌨️ 快捷键说明

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