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

📄 os_flag.ls1

📁 uCOS-II_2.52在51上的移植程序
💻 LS1
📖 第 1 页 / 共 5 页
字号:
                     155     ; 
                     156     ; 
                     157     ; #if OS_ARG_CHK_EN > 0
                     158     ;     if (pgrp == (OS_FLAG_GRP *)0) {                        /* Validate 'pgrp'            
                                           */
                     159     ;         *err = OS_FLAG_INVALID_PGRP;
                     160     ;         return ((OS_FLAGS)0);
                     161     ;     }
                     162     ;     if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) {          /* Validate event block type  
                                           */
                     163     ;         *err = OS_ERR_EVENT_TYPE;
                     164     ;         return ((OS_FLAGS)0);
A51 MACRO ASSEMBLER  OS_FLAG                                                              08/08/2005 11:36:41 PAGE     4

                     165     ;     }
                     166     ; #endif
                     167     ;     if (wait_type & OS_FLAG_CONSUME) {                     /* See if we need to consume t
                             he flags      */
                     168     ;         wait_type &= ~OS_FLAG_CONSUME;
                     169     ;         consume    = TRUE;
                     170     ;     } else {
                     171     ;         consume    = FALSE;
                     172     ;     }
                     173     ; /*$PAGE*/
                     174     ;     *err = OS_NO_ERR;                                      /* Assume NO error until prove
                             n otherwise.  */
                     175     ;     OS_ENTER_CRITICAL();
                     176     ;     switch (wait_type) {
                     177     ;         case OS_FLAG_WAIT_SET_ALL:                         /* See if all required flags a
                             re set        */
                     178     ;              flags_rdy = pgrp->OSFlagFlags & flags;        /* Extract only the bits we wa
                             nt            */
                     179     ;              if (flags_rdy == flags) {                     /* Must match ALL the bits tha
                             t we want     */
                     180     ;                  if (consume == TRUE) {                    /* See if we need to consume t
                             he flags      */
                     181     ;                      pgrp->OSFlagFlags &= ~flags_rdy;      /* Clear ONLY the flags that w
                             e wanted      */
                     182     ;                  }
                     183     ;              } else {
                     184     ;                  *err  = OS_FLAG_ERR_NOT_RDY;
                     185     ;              }
                     186     ;              flags_cur = pgrp->OSFlagFlags;                /* Will return the state of th
                             e group       */
                     187     ;              OS_EXIT_CRITICAL();
                     188     ;              break;
                     189     ; 
                     190     ;         case OS_FLAG_WAIT_SET_ANY:
                     191     ;              flags_rdy = pgrp->OSFlagFlags & flags;        /* Extract only the bits we wa
                             nt            */
                     192     ;              if (flags_rdy != (OS_FLAGS)0) {               /* See if any flag set        
                                           */
                     193     ;                  if (consume == TRUE) {                    /* See if we need to consume t
                             he flags      */
                     194     ;                      pgrp->OSFlagFlags &= ~flags_rdy;      /* Clear ONLY the flags that w
                             e got         */
                     195     ;                  }
                     196     ;              } else {
                     197     ;                  *err  = OS_FLAG_ERR_NOT_RDY;
                     198     ;              }
                     199     ;              flags_cur = pgrp->OSFlagFlags;                /* Will return the state of th
                             e group       */
                     200     ;              OS_EXIT_CRITICAL();
                     201     ;              break;
                     202     ; 
                     203     ; #if OS_FLAG_WAIT_CLR_EN > 0
                     204     ;         case OS_FLAG_WAIT_CLR_ALL:                         /* See if all required flags a
                             re cleared    */
                     205     ;              flags_rdy = ~pgrp->OSFlagFlags & flags;       /* Extract only the bits we wa
                             nt            */
                     206     ;              if (flags_rdy == flags) {                     /* Must match ALL the bits tha
                             t we want     */
                     207     ;                  if (consume == TRUE) {                    /* See if we need to consume t
                             he flags      */
                     208     ;                      pgrp->OSFlagFlags |= flags_rdy;       /* Set ONLY the flags that we 
                             wanted        */
                     209     ;                  }
                     210     ;              } else {
                     211     ;                  *err  = OS_FLAG_ERR_NOT_RDY;
                     212     ;              }
A51 MACRO ASSEMBLER  OS_FLAG                                                              08/08/2005 11:36:41 PAGE     5

                     213     ;              flags_cur = pgrp->OSFlagFlags;                /* Will return the state of th
                             e group       */
                     214     ;              OS_EXIT_CRITICAL();
                     215     ;              break;
                     216     ; 
                     217     ;         case OS_FLAG_WAIT_CLR_ANY:
                     218     ;              flags_rdy = ~pgrp->OSFlagFlags & flags;       /* Extract only the bits we wa
                             nt            */
                     219     ;              if (flags_rdy != (OS_FLAGS)0) {               /* See if any flag cleared    
                                           */
                     220     ;                  if (consume == TRUE) {                    /* See if we need to consume t
                             he flags      */
                     221     ;                      pgrp->OSFlagFlags |= flags_rdy;       /* Set ONLY the flags that we 
                             got           */
                     222     ;                  }
                     223     ;              } else {
                     224     ;                  *err  = OS_FLAG_ERR_NOT_RDY;
                     225     ;              }
                     226     ;              flags_cur = pgrp->OSFlagFlags;                /* Will return the state of th
                             e group       */
                     227     ;              OS_EXIT_CRITICAL();
                     228     ;              break;
                     229     ; #endif
                     230     ; 
                     231     ;         default:
                     232     ;              OS_EXIT_CRITICAL();
                     233     ;              flags_cur = (OS_FLAGS)0;
                     234     ;              *err      = OS_FLAG_ERR_WAIT_TYPE;
                     235     ;              break;
                     236     ;     }
                     237     ;     return (flags_cur);
                     238     ; }
                     239     ; #endif
                     240     ; 
                     241     ; /*$PAGE*/
                     242     ; /*
                     243     ; *****************************************************************************************
                             ****************
                     244     ; *                                           CREATE AN EVENT FLAG
                     245     ; *
                     246     ; * Description: This function is called to create an event flag group.
                     247     ; *
                     248     ; * Arguments  : flags         Contains the initial value to store in the event flag group.
                     249     ; *
                     250     ; *              err           is a pointer to an error code which will be returned to your
                              application:
                     251     ; *                               OS_NO_ERR                if the call was successful.
                     252     ; *                               OS_ERR_CREATE_ISR        if you attempted to create an Ev
                             ent Flag from an
                     253     ; *                                                        ISR.
                     254     ; *                               OS_FLAG_GRP_DEPLETED     if there are no more event flag 
                             groups
                     255     ; *
                     256     ; * Returns    : A pointer to an event flag group or a NULL pointer if no more groups are a
                             vailable.
                     257     ; *
                     258     ; * Called from: Task ONLY
                     259     ; *****************************************************************************************
                             ****************
                     260     ; */
                     261     ; 
                     262     ; OS_FLAG_GRP  *OSFlagCreate (OS_FLAGS flags, INT8U *err)
                     263     ; {
                     264     ; 
                     265     ;     OS_FLAG_GRP *pgrp;
                     266     ; 
A51 MACRO ASSEMBLER  OS_FLAG                                                              08/08/2005 11:36:41 PAGE     6

                     267     ; 
                     268     ;     if (OSIntNesting > 0) {                         /* See if called from ISR ...        
                                           */
                     269     ;         *err = OS_ERR_CREATE_ISR;                   /* ... can't CREATE from an ISR      
                                           */
                     270     ;         return ((OS_FLAG_GRP *)0);
                     271     ;     }
                     272     ;     OS_ENTER_CRITICAL();
                     273     ;     pgrp = OSFlagFreeList;                          /* Get next free event flag          
                                           */
                     274     ;     if (pgrp != (OS_FLAG_GRP *)0) {                 /* See if we have event flag groups a
                             vailable      */
                     275     ;                                                     /* Adjust free list                  
                                           */
                     276     ;         OSFlagFreeList       = (OS_FLAG_GRP *)OSFlagFreeList->OSFlagWaitList;
                     277     ;         pgrp->OSFlagType     = OS_EVENT_TYPE_FLAG;  /* Set to event flag group type      
                                           */
                     278     ;         pgrp->OSFlagFlags    = flags;               /* Set to desired initial value      
                                           */
                     279     ;         pgrp->OSFlagWaitList = (void *)0;           /* Clear list of tasks waiting on fla
                             gs            */
                     280     ;         OS_EXIT_CRITICAL();
                     281     ;         *err                 = OS_NO_ERR;
                     282     ;     } else {
                     283     ;         OS_EXIT_CRITICAL();
                     284     ;         *err                 = OS_FLAG_GRP_DEPLETED;
                     285     ;     }
                     286     ;     return (pgrp);                                  /* Return pointer to event flag group
                                           */
                     287     ; }
                     288     ; 
                     289     ; /*$PAGE*/
                     290     ; /*
                     291     ; *****************************************************************************************
                             ****************
                     292     ; *                                     DELETE AN EVENT FLAG GROUP
                     293     ; *
                     294     ; * Description: This function deletes an event flag group and readies all tasks pending on
                              the event flag
                     295     ; *              group.
                     296     ; *

⌨️ 快捷键说明

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