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

📄 os_flag.ls1

📁 uCOS-II_2.52在51上的移植程序
💻 LS1
📖 第 1 页 / 共 5 页
字号:
                             e' argument.
                     434     ; *
                     435     ; * Returns    : The new state of the flags in the event flag group when the task is resume
                             d or,
                     436     ; *              0 if a timeout or an error occurred.
                     437     ; *
                     438     ; * Called from: Task ONLY
                     439     ; *****************************************************************************************
                             ****************
                     440     ; */
                     441     ; 
                     442     ; OS_FLAGS  OSFlagPend (OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U wait_type, INT16U timeout,
                              INT8U *err)
                     443     ; {
                     444     ; 
                     445     ;     OS_FLAG_NODE  node;
                     446     ;     OS_FLAGS      flags_cur;
                     447     ;     OS_FLAGS      flags_rdy;
                     448     ;     BOOLEAN       consume;
                     449     ; 
                     450     ; 
                     451     ;     if (OSIntNesting > 0) {                                /* See if called from ISR ... 
                                           */
                     452     ;         *err = OS_ERR_PEND_ISR;                            /* ... can't PEND from an ISR 
                                           */
                     453     ;         return ((OS_FLAGS)0);
                     454     ;     }
                     455     ; #if OS_ARG_CHK_EN > 0
                     456     ;     if (pgrp == (OS_FLAG_GRP *)0) {                        /* Validate 'pgrp'            
                                           */
                     457     ;         *err = OS_FLAG_INVALID_PGRP;
                     458     ;         return ((OS_FLAGS)0);
                     459     ;     }
                     460     ;     if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) {          /* Validate event block type  
                                           */
                     461     ;         *err = OS_ERR_EVENT_TYPE;
                     462     ;         return ((OS_FLAGS)0);
                     463     ;     }
A51 MACRO ASSEMBLER  OS_FLAG                                                              08/08/2005 11:36:41 PAGE    10

                     464     ; #endif
                     465     ;     if (wait_type & OS_FLAG_CONSUME) {                     /* See if we need to consume t
                             he flags      */
                     466     ;         wait_type &= ~OS_FLAG_CONSUME;
                     467     ;         consume    = TRUE;
                     468     ;     } else {
                     469     ;         consume    = FALSE;
                     470     ;     }
                     471     ; /*$PAGE*/
                     472     ;     OS_ENTER_CRITICAL();
                     473     ;     switch (wait_type) {
                     474     ;         case OS_FLAG_WAIT_SET_ALL:                         /* See if all required flags a
                             re set        */
                     475     ;              flags_rdy = pgrp->OSFlagFlags & flags;        /* Extract only the bits we wa
                             nt            */
                     476     ;              if (flags_rdy == flags) {                     /* Must match ALL the bits tha
                             t we want     */
                     477     ;                  if (consume == TRUE) {                    /* See if we need to consume t
                             he flags      */
                     478     ;                      pgrp->OSFlagFlags &= ~flags_rdy;      /* Clear ONLY the flags that w
                             e wanted      */
                     479     ;                  }
                     480     ;                  flags_cur = pgrp->OSFlagFlags;            /* Will return the state of th
                             e group       */
                     481     ;                  OS_EXIT_CRITICAL();                       /* Yes, condition met, return 
                             to caller     */
                     482     ;                  *err      = OS_NO_ERR;
                     483     ;                  return (flags_cur);
                     484     ;              } else {                                      /* Block task until events occ
                             ur or timeout */
                     485     ;                  OS_FlagBlock(pgrp, &node, flags, wait_type, timeout);
                     486     ;                  OS_EXIT_CRITICAL();
                     487     ;              }
                     488     ;              break;
                     489     ; 
                     490     ;         case OS_FLAG_WAIT_SET_ANY:
                     491     ;              flags_rdy = pgrp->OSFlagFlags & flags;        /* Extract only the bits we wa
                             nt            */
                     492     ;              if (flags_rdy != (OS_FLAGS)0) {               /* See if any flag set        
                                           */
                     493     ;                  if (consume == TRUE) {                    /* See if we need to consume t
                             he flags      */
                     494     ;                      pgrp->OSFlagFlags &= ~flags_rdy;      /* Clear ONLY the flags that w
                             e got         */
                     495     ;                  }
                     496     ;                  flags_cur = pgrp->OSFlagFlags;            /* Will return the state of th
                             e group       */
                     497     ;                  OS_EXIT_CRITICAL();                       /* Yes, condition met, return 
                             to caller     */
                     498     ;                  *err      = OS_NO_ERR;
                     499     ;                  return (flags_cur);
                     500     ;              } else {                                      /* Block task until events occ
                             ur or timeout */
                     501     ;                  OS_FlagBlock(pgrp, &node, flags, wait_type, timeout);
                     502     ;                  OS_EXIT_CRITICAL();
                     503     ;              }
                     504     ;              break;
                     505     ; 
                     506     ; #if OS_FLAG_WAIT_CLR_EN > 0
                     507     ;         case OS_FLAG_WAIT_CLR_ALL:                         /* See if all required flags a
                             re cleared    */
                     508     ;              flags_rdy = ~pgrp->OSFlagFlags & flags;       /* Extract only the bits we wa
                             nt            */
                     509     ;              if (flags_rdy == flags) {                     /* Must match ALL the bits tha
                             t we want     */
                     510     ;                  if (consume == TRUE) {                    /* See if we need to consume t
A51 MACRO ASSEMBLER  OS_FLAG                                                              08/08/2005 11:36:41 PAGE    11

                             he flags      */
                     511     ;                      pgrp->OSFlagFlags |= flags_rdy;       /* Set ONLY the flags that we 
                             wanted        */
                     512     ;                  }
                     513     ;                  flags_cur = pgrp->OSFlagFlags;            /* Will return the state of th
                             e group       */
                     514     ;                  OS_EXIT_CRITICAL();                       /* Yes, condition met, return 
                             to caller     */
                     515     ;                  *err      = OS_NO_ERR;
                     516     ;                  return (flags_cur);
                     517     ;              } else {                                      /* Block task until events occ
                             ur or timeout */
                     518     ;                  OS_FlagBlock(pgrp, &node, flags, wait_type, timeout);
                     519     ;                  OS_EXIT_CRITICAL();
                     520     ;              }
                     521     ;              break;
                     522     ; 
                     523     ;         case OS_FLAG_WAIT_CLR_ANY:
                     524     ;              flags_rdy = ~pgrp->OSFlagFlags & flags;       /* Extract only the bits we wa
                             nt            */
                     525     ;              if (flags_rdy != (OS_FLAGS)0) {               /* See if any flag cleared    
                                           */
                     526     ;                  if (consume == TRUE) {                    /* See if we need to consume t
                             he flags      */
                     527     ;                      pgrp->OSFlagFlags |= flags_rdy;       /* Set ONLY the flags that we 
                             got           */
                     528     ;                  }
                     529     ;                  flags_cur = pgrp->OSFlagFlags;            /* Will return the state of th
                             e group       */
                     530     ;                  OS_EXIT_CRITICAL();                       /* Yes, condition met, return 
                             to caller     */
                     531     ;                  *err      = OS_NO_ERR;
                     532     ;                  return (flags_cur);
                     533     ;              } else {                                      /* Block task until events occ
                             ur or timeout */
                     534     ;                  OS_FlagBlock(pgrp, &node, flags, wait_type, timeout);
                     535     ;                  OS_EXIT_CRITICAL();
                     536     ;              }
                     537     ;              break;
                     538     ; #endif
                     539     ; 
                     540     ;         default:
                     541     ;              OS_EXIT_CRITICAL();
                     542     ;              flags_cur = (OS_FLAGS)0;
                     543     ;              *err      = OS_FLAG_ERR_WAIT_TYPE;
                     544     ;              return (flags_cur);
                     545     ;     }
                     546     ;     OS_Sched();                                            /* Find next HPT ready to run 
                                           */
                     547     ;     OS_ENTER_CRITICAL();
                     548     ;     if (OSTCBCur->OSTCBStat & OS_STAT_FLAG) {              /* Have we timed-out?         
                                           */
                     549     ;         OS_FlagUnlink(&node);
                     550     ;         OSTCBCur->OSTCBStat = OS_STAT_RDY;                 /* Yes, make task ready-to-run
                                           */
                     551     ;         OS_EXIT_CRITICAL();
                     552     ;         flags_cur           = (OS_FLAGS)0;
                     553     ;         *err                = OS_TIMEOUT;                  /* Indicate that we timed-out 
                             waiting       */
                     554     ;     } else {
                     555     ;         if (consume == TRUE) {                             /* See if we need to consume t
                             he flags      */
                     556     ;             switch (wait_type) {
                     557     ;                 case OS_FLAG_WAIT_SET_ALL:
                     558     ;                 case OS_FLAG_WAIT_SET_ANY:                 /* Clear ONLY the flags we got
                                           */
A51 MACRO ASSEMBLER  OS_FLAG                                                              08/08/2005 11:36:41 PAGE    12

                     559     ;                      pgrp->OSFlagFlags &= ~OSTCBCur->OSTCBFlagsRdy;
                     560     ;                      break;
                     561     ; 
                     562     ; #if OS_FLAG_WAIT_CLR_EN > 0
                     563     ;                 case OS_FLAG_WAIT_CLR_ALL:
                     564     ;                 case OS_FLAG_WAIT_CLR_ANY:                 /* Set   ONLY the flags we got
                                           */
                     565     ;                      pgrp->OSFlagFlags |= OSTCBCur->OSTCBFlagsRdy;
                     566     ;                      break;
                     567     ; #endif
                     568     ;             }
                     569     ;         }
                     570     ;         flags_cur = pgrp->OSFlagFlags;
                     571     ;         OS_EXIT_CRITICAL();
                     572     ;         *err      = OS_NO_ERR;                             /* Event(s) must have occurred

⌨️ 快捷键说明

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