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

📄 os_flag.ls1

📁 uCOS-II_2.52在51上的移植程序
💻 LS1
📖 第 1 页 / 共 5 页
字号:
                                           */
                     573     ;     }
                     574     ;     return (flags_cur);
                     575     ; }
                     576     ; /*$PAGE*/
                     577     ; /*
                     578     ; *****************************************************************************************
                             ****************
                     579     ; *                                         POST EVENT FLAG BIT(S)
                     580     ; *
                     581     ; * Description: This function is called to set or clear some bits in an event flag group. 
                              The bits to
                     582     ; *              set or clear are specified by a 'bit mask'.
                     583     ; *
                     584     ; * Arguments  : pgrp          is a pointer to the desired event flag group.
                     585     ; *
                     586     ; *              flags         If 'opt' (see below) is OS_FLAG_SET, each bit that is set in
                              'flags' will
                     587     ; *                            set the corresponding bit in the event flag group.  e.g. to 
                             set bits 0, 4
                     588     ; *                            and 5 you would set 'flags' to:
                     589     ; *
                     590     ; *                                0x31     (note, bit 0 is least significant bit)
                     591     ; *
                     592     ; *                            If 'opt' (see below) is OS_FLAG_CLR, each bit that is set in
                              'flags' will
                     593     ; *                            CLEAR the corresponding bit in the event flag group.  e.g. t
                             o clear bits 0,
                     594     ; *                            4 and 5 you would specify 'flags' as:
                     595     ; *
                     596     ; *                                0x31     (note, bit 0 is least significant bit)
                     597     ; *
                     598     ; *              opt           indicates whether the flags will be:
                     599     ; *                                set     (OS_FLAG_SET) or
                     600     ; *                                cleared (OS_FLAG_CLR)
                     601     ; *
                     602     ; *              err           is a pointer to an error code and can be:
                     603     ; *                            OS_NO_ERR              The call was successfull
                     604     ; *                            OS_FLAG_INVALID_PGRP   You passed a NULL pointer
                     605     ; *                            OS_ERR_EVENT_TYPE      You are not pointing to an event flag
                              group
                     606     ; *                            OS_FLAG_INVALID_OPT    You specified an invalid option
                     607     ; *
                     608     ; * Returns    : the new value of the event flags bits that are still set.
                     609     ; *
                     610     ; * Called From: Task or ISR
                     611     ; *
                     612     ; * WARNING(s) : 1) The execution time of this function depends on the number of tasks wait
                             ing on the event
                     613     ; *                 flag group.
                     614     ; *              2) The amount of time interrupts are DISABLED depends on the number of tas
A51 MACRO ASSEMBLER  OS_FLAG                                                              08/08/2005 11:36:41 PAGE    13

                             ks waiting on
                     615     ; *                 the event flag group.
                     616     ; *****************************************************************************************
                             ****************
                     617     ; */
                     618     ; OS_FLAGS  OSFlagPost (OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U opt, INT8U *err)
                     619     ; {
                     620     ; 
                     621     ;     OS_FLAG_NODE *pnode;
                     622     ;     BOOLEAN       sched;
                     623     ;     OS_FLAGS      flags_cur;
                     624     ;     OS_FLAGS      flags_rdy;
                     625     ; 
                     626     ; 
                     627     ; #if OS_ARG_CHK_EN > 0
                     628     ;     if (pgrp == (OS_FLAG_GRP *)0) {                  /* Validate 'pgrp'                  
                                           */
                     629     ;         *err = OS_FLAG_INVALID_PGRP;
                     630     ;         return ((OS_FLAGS)0);
                     631     ;     }
                     632     ;     if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) {    /* Make sure we are pointing to an e
                             vent flag grp */
                     633     ;         *err = OS_ERR_EVENT_TYPE;
                     634     ;         return ((OS_FLAGS)0);
                     635     ;     }
                     636     ; #endif
                     637     ; /*$PAGE*/
                     638     ;     OS_ENTER_CRITICAL();
                     639     ;     switch (opt) {
                     640     ;         case OS_FLAG_CLR:
                     641     ;              pgrp->OSFlagFlags &= ~flags;            /* Clear the flags specified in the 
                             group         */
                     642     ;              break;
                     643     ; 
                     644     ;         case OS_FLAG_SET:
                     645     ;              pgrp->OSFlagFlags |=  flags;            /* Set   the flags specified in the 
                             group         */
                     646     ;              break;
                     647     ; 
                     648     ;         default:
                     649     ;              OS_EXIT_CRITICAL();                     /* INVALID option                   
                                           */
                     650     ;              *err = OS_FLAG_INVALID_OPT;
                     651     ;              return ((OS_FLAGS)0);
                     652     ;     }
                     653     ;     sched = FALSE;                                   /* Indicate that we don't need resch
                             eduling       */
                     654     ;     pnode = (OS_FLAG_NODE *)pgrp->OSFlagWaitList;
                     655     ;     while (pnode != (OS_FLAG_NODE *)0) {             /* Go through all tasks waiting on e
                             vent flag(s)  */
                     656     ;         switch (pnode->OSFlagNodeWaitType) {
                     657     ;             case OS_FLAG_WAIT_SET_ALL:               /* See if all req. flags are set for
                              current node */
                     658     ;                  flags_rdy = pgrp->OSFlagFlags & pnode->OSFlagNodeFlags;
                     659     ;                  if (flags_rdy == pnode->OSFlagNodeFlags) {
                     660     ;                      if (OS_FlagTaskRdy(pnode, flags_rdy) == TRUE) { /* Make task RTR, ev
                             ent(s) Rx'd   */
                     661     ;                          sched = TRUE;                               /* When done we will
                              reschedule   */
                     662     ;                      }
                     663     ;                  }
                     664     ;                  break;
                     665     ; 
                     666     ;             case OS_FLAG_WAIT_SET_ANY:               /* See if any flag set              
                                           */
                     667     ;                  flags_rdy = pgrp->OSFlagFlags & pnode->OSFlagNodeFlags;
A51 MACRO ASSEMBLER  OS_FLAG                                                              08/08/2005 11:36:41 PAGE    14

                     668     ;                  if (flags_rdy != (OS_FLAGS)0) {
                     669     ;                      if (OS_FlagTaskRdy(pnode, flags_rdy) == TRUE) { /* Make task RTR, ev
                             ent(s) Rx'd   */
                     670     ;                          sched = TRUE;                               /* When done we will
                              reschedule   */
                     671     ;                      }
                     672     ;                  }
                     673     ;                  break;
                     674     ; 
                     675     ; #if OS_FLAG_WAIT_CLR_EN > 0
                     676     ;             case OS_FLAG_WAIT_CLR_ALL:               /* See if all req. flags are set for
                              current node */
                     677     ;                  flags_rdy = ~pgrp->OSFlagFlags & pnode->OSFlagNodeFlags;
                     678     ;                  if (flags_rdy == pnode->OSFlagNodeFlags) {
                     679     ;                      if (OS_FlagTaskRdy(pnode, flags_rdy) == TRUE) { /* Make task RTR, ev
                             ent(s) Rx'd   */
                     680     ;                          sched = TRUE;                               /* When done we will
                              reschedule   */
                     681     ;                      }
                     682     ;                  }
                     683     ;                  break;
                     684     ; 
                     685     ;             case OS_FLAG_WAIT_CLR_ANY:               /* See if any flag set              
                                           */
                     686     ;                  flags_rdy = ~pgrp->OSFlagFlags & pnode->OSFlagNodeFlags;
                     687     ;                  if (flags_rdy != (OS_FLAGS)0) {
                     688     ;                      if (OS_FlagTaskRdy(pnode, flags_rdy) == TRUE) { /* Make task RTR, ev
                             ent(s) Rx'd   */
                     689     ;                          sched = TRUE;                               /* When done we will
                              reschedule   */
                     690     ;                      }
                     691     ;                  }
                     692     ;                  break;
                     693     ; #endif
                     694     ;         }
                     695     ;         pnode = (OS_FLAG_NODE *)pnode->OSFlagNodeNext; /* Point to next task waiting for 
                             event flag(s) */
                     696     ;     }
                     697     ;     OS_EXIT_CRITICAL();
                     698     ;     if (sched == TRUE) {
                     699     ;         OS_Sched();
                     700     ;     }
                     701     ;     OS_ENTER_CRITICAL();
                     702     ;     flags_cur = pgrp->OSFlagFlags;
                     703     ;     OS_EXIT_CRITICAL();
                     704     ;     *err      = OS_NO_ERR;
                     705     ;     return (flags_cur);
                     706     ; }
                     707     ; /*$PAGE*/
                     708     ; /*
                     709     ; *****************************************************************************************
                             ****************
                     710     ; *                                           QUERY EVENT FLAG
                     711     ; *
                     712     ; * Description: This function is used to check the value of the event flag group.
                     713     ; *
                     714     ; * Arguments  : pgrp         is a pointer to the desired event flag group.
                     715     ; *
                     716     ; *              err           is a pointer to an error code returned to the called:
                     717     ; *                            OS_NO_ERR              The call was successfull
                     718     ; *                            OS_FLAG_INVALID_PGRP   You passed a NULL pointer
                     719     ; *                            OS_ERR_EVENT_TYPE      You are not pointing to an event flag
                              group
                     720     ; *
                     721     ; * Returns    : The current value of the event flag group.
                     722     ; *
A51 MACRO ASSEM

⌨️ 快捷键说明

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