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

📄 os_flag.lst

📁 uCos-ii 2.86 在C8051F410单片机上移植成功!!! 其中包括:UART驱动
💻 LST
📖 第 1 页 / 共 5 页
字号:
              #endif
              
              
              
              #if OS_ARG_CHK_EN > 0
                  if (perr == (INT8U *)0) {                        /* Validate 'perr'                                */
                      return ((OS_FLAGS)0);
                  }
                  if (pgrp == (OS_FLAG_GRP *)0) {                  /* Validate 'pgrp'                                */
                      *perr = OS_ERR_FLAG_INVALID_PGRP;
                      return ((OS_FLAGS)0);
                  }
              #endif
                  if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) {    /* Make sure we are pointing to an event flag grp */
                      *perr = OS_ERR_EVENT_TYPE;
                      return ((OS_FLAGS)0);
                  }
              /*$PAGE*/
                  OS_ENTER_CRITICAL();
                  switch (opt) {
                      case OS_FLAG_CLR:
                           pgrp->OSFlagFlags &= ~flags;            /* Clear the flags specified in the group         */
                           break;
              
                      case OS_FLAG_SET:
                           pgrp->OSFlagFlags |=  flags;            /* Set   the flags specified in the group         */
                           break;
              
                      default:
                           OS_EXIT_CRITICAL();                     /* INVALID option                                 */
                           *perr = OS_ERR_FLAG_INVALID_OPT;
                           return ((OS_FLAGS)0);
                  }
                  sched = OS_FALSE;                                /* Indicate that we don't need rescheduling       */
                  pnode = (OS_FLAG_NODE *)pgrp->OSFlagWaitList;
                  while (pnode != (OS_FLAG_NODE *)0) {             /* Go through all tasks waiting on event flag(s)  */
                      switch (pnode->OSFlagNodeWaitType) {
                          case OS_FLAG_WAIT_SET_ALL:               /* See if all req. flags are set for current node */
                               flags_rdy = (OS_FLAGS)(pgrp->OSFlagFlags & pnode->OSFlagNodeFlags);
                               if (flags_rdy == pnode->OSFlagNodeFlags) {
                                   rdy = OS_FlagTaskRdy(pnode, flags_rdy);  /* Make task RTR, event(s) Rx'd          */
                                   if (rdy == OS_TRUE) {
                                       sched = OS_TRUE;                     /* When done we will reschedule          */
                                   }
                               }
                               break;
              
                          case OS_FLAG_WAIT_SET_ANY:               /* See if any flag set                            */
                               flags_rdy = (OS_FLAGS)(pgrp->OSFlagFlags & pnode->OSFlagNodeFlags);
                               if (flags_rdy != (OS_FLAGS)0) {
                                   rdy = OS_FlagTaskRdy(pnode, flags_rdy);  /* Make task RTR, event(s) Rx'd          */
                                   if (rdy == OS_TRUE) {
C51 COMPILER V8.17   OS_FLAG                                                               03/26/2009 14:24:24 PAGE 15  

                                       sched = OS_TRUE;                     /* When done we will reschedule          */
                                   }
                               }
                               break;
              
              #if OS_FLAG_WAIT_CLR_EN > 0
                          case OS_FLAG_WAIT_CLR_ALL:               /* See if all req. flags are set for current node */
                               flags_rdy = (OS_FLAGS)(~pgrp->OSFlagFlags & pnode->OSFlagNodeFlags);
                               if (flags_rdy == pnode->OSFlagNodeFlags) {
                                   rdy = OS_FlagTaskRdy(pnode, flags_rdy);  /* Make task RTR, event(s) Rx'd          */
                                   if (rdy == OS_TRUE) {
                                       sched = OS_TRUE;                     /* When done we will reschedule          */
                                   }
                               }
                               break;
              
                          case OS_FLAG_WAIT_CLR_ANY:               /* See if any flag set                            */
                               flags_rdy = (OS_FLAGS)(~pgrp->OSFlagFlags & pnode->OSFlagNodeFlags);
                               if (flags_rdy != (OS_FLAGS)0) {
                                   rdy = OS_FlagTaskRdy(pnode, flags_rdy);  /* Make task RTR, event(s) Rx'd          */
                                   if (rdy == OS_TRUE) {
                                       sched = OS_TRUE;                     /* When done we will reschedule          */
                                   }
                               }
                               break;
              #endif
                          default:
                               OS_EXIT_CRITICAL();
                               *perr = OS_ERR_FLAG_WAIT_TYPE;
                               return ((OS_FLAGS)0);
                      }
                      pnode = (OS_FLAG_NODE *)pnode->OSFlagNodeNext; /* Point to next task waiting for event flag(s) */
                  }
                  OS_EXIT_CRITICAL();
                  if (sched == OS_TRUE) {
                      OS_Sched();
                  }
                  OS_ENTER_CRITICAL();
                  flags_cur = pgrp->OSFlagFlags;
                  OS_EXIT_CRITICAL();
                  *perr     = OS_ERR_NONE;
                  return (flags_cur);
              }
              /*$PAGE*/
              /*
              *********************************************************************************************************
              *                                           QUERY EVENT FLAG
              *
              * Description: This function is used to check the value of the event flag group.
              *
              * Arguments  : pgrp         is a pointer to the desired event flag group.
              *
              *              perr          is a pointer to an error code returned to the called:
              *                            OS_ERR_NONE                The call was successfull
              *                            OS_ERR_FLAG_INVALID_PGRP   You passed a NULL pointer
              *                            OS_ERR_EVENT_TYPE          You are not pointing to an event flag group
              *
              * Returns    : The current value of the event flag group.
              *
              * Called From: Task or ISR
              *********************************************************************************************************
              */
C51 COMPILER V8.17   OS_FLAG                                                               03/26/2009 14:24:24 PAGE 16  

              
              #if OS_FLAG_QUERY_EN > 0
              OS_FLAGS  OSFlagQuery (OS_FLAG_GRP *pgrp, INT8U *perr) reentrant
              {
                  OS_FLAGS   flags;
              #if OS_CRITICAL_METHOD == 3                       /* Allocate storage for CPU status register          */
                  OS_CPU_SR  cpu_sr = 0;
              #endif
              
              
              
              #if OS_ARG_CHK_EN > 0
                  if (perr == (INT8U *)0) {                     /* Validate 'perr'                                   */
                      return ((OS_FLAGS)0);
                  }
                  if (pgrp == (OS_FLAG_GRP *)0) {               /* Validate 'pgrp'                                   */
                      *perr = OS_ERR_FLAG_INVALID_PGRP;
                      return ((OS_FLAGS)0);
                  }
              #endif
                  if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) { /* Validate event block type                         */
                      *perr = OS_ERR_EVENT_TYPE;
                      return ((OS_FLAGS)0);
                  }
                  OS_ENTER_CRITICAL();
                  flags = pgrp->OSFlagFlags;
                  OS_EXIT_CRITICAL();
                  *perr = OS_ERR_NONE;
                  return (flags);                               /* Return the current value of the event flags       */
              }
              #endif
              
              /*$PAGE*/
              /*
              *********************************************************************************************************
              *                         SUSPEND TASK UNTIL EVENT FLAG(s) RECEIVED OR TIMEOUT OCCURS
              *
              * Description: This function is internal to uC/OS-II and is used to put a task to sleep until the desired
              *              event flag bit(s) are set.
              *
              * Arguments  : pgrp          is a pointer to the desired event flag group.
              *
              *              pnode         is a pointer to a structure which contains data about the task waiting for
              *                            event flag bit(s) to be set.
              *
              *              flags         Is a bit pattern indicating which bit(s) (i.e. flags) you wish to check.
              *                            The bits you want are specified by setting the corresponding bits in
              *                            'flags'.  e.g. if your application wants to wait for bits 0 and 1 then
              *                            'flags' would contain 0x03.
              *
              *              wait_type     specifies whether you want ALL bits to be set/cleared or ANY of the bits
              *                            to be set/cleared.
              *                            You can specify the following argument:
              *
              *                            OS_FLAG_WAIT_CLR_ALL   You will check ALL bits in 'mask' to be clear (0)
              *                            OS_FLAG_WAIT_CLR_ANY   You will check ANY bit  in 'mask' to be clear (0)
              *                            OS_FLAG_WAIT_SET_ALL   You will check ALL bits in 'mask' to be set   (1)
              *                            OS_FLAG_WAIT_SET_ANY   You will check ANY bit  in 'mask' to be set   (1)
              *
              *              timeout       is the desired amount of time that the task will wait for the event flag
              *                            bit(s) to be set.
              *
C51 COMPILER V8.17   OS_FLAG                                                               03/26/2009 14:24:24 PAGE 17  

              * Returns    : none
              *
              * Called by  : OSFlagPend()  OS_FLAG.C
              *
              * Note(s)    : This function is INTERNAL to uC/OS-II and your application should not call it.
              *********************************************************************************************************
              */
              
              static  void  OS_FlagBlock (OS_FLAG_GRP *pgrp, OS_FLAG_NODE *pnode, OS_FLAGS flags, INT8U wait_type, INT16
             -U timeout) reentrant
              {
                  OS_FLAG_NODE  *pnode_next;
                  INT8U          y;
              
              
                  OSTCBCur->OSTCBStat      |= OS_STAT_FLAG;
                  OSTCBCur->OSTCBStatPend   = OS_STAT_PEND_OK;
                  OSTCBCur->OSTCBDly        = timeout;              /* Store timeout in task's TCB                   */
              #if OS_TASK_DEL_EN > 0
                  OSTCBCur->OSTCBFlagNode   = pnode;                /* TCB to link to node                           */
              #endif
                  pnode->OSFlagNodeFlags    = flags;                /* Save the flags that we need to wait for       */
                  pnode->OSFlagNodeWaitType = wait_type;            /* Save the type of wait we are doing            */
                  pnode->OSFlagNodeTCB      = (void *)OSTCBCur;     /* Link to task's TCB                            */
                  pnode->OSFlagNodeNext     = pgrp->OSFlagWaitList; /* Add node at beginning of event flag wait list */
                  pnod

⌨️ 快捷键说明

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