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

📄 os_flag.lst

📁 uCos-ii 2.86 在C8051F410单片机上移植成功!!! 其中包括:UART驱动
💻 LST
📖 第 1 页 / 共 5 页
字号:
              {
                  INT8U      len;
              #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 (0);
                  }
                  if (pgrp == (OS_FLAG_GRP *)0) {              /* Is 'pgrp' a NULL pointer?                          */
                      *perr = OS_ERR_FLAG_INVALID_PGRP;
                      return (0);
                  }
                  if (pname == (INT8U *)0) {                   /* Is 'pname' a NULL pointer?                         */
                      *perr = OS_ERR_PNAME_NULL;
                      return (0);
                  }
              #endif
                  if (OSIntNesting > 0) {                      /* See if trying to call from an ISR                  */
                      *perr = OS_ERR_NAME_GET_ISR;
                      return (0);
                  }
                  OS_ENTER_CRITICAL();
C51 COMPILER V8.17   OS_FLAG                                                               03/26/2009 14:24:24 PAGE 8   

                  if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) {
                      OS_EXIT_CRITICAL();
                      *perr = OS_ERR_EVENT_TYPE;
                      return (0);
                  }
                  len   = OS_StrCopy(pname, pgrp->OSFlagName); /* Copy name from OS_FLAG_GRP                         */
                  OS_EXIT_CRITICAL();
                  *perr = OS_ERR_NONE;
                  return (len);
              }
              #endif
              
              /*$PAGE*/
              /*
              *********************************************************************************************************
              *                                 ASSIGN A NAME TO AN EVENT FLAG GROUP
              *
              * Description: This function assigns a name to an event flag group.
              *
              * Arguments  : pgrp      is a pointer to the event flag group.
              *
              *              pname     is a pointer to an ASCII string that will be used as the name of the event flag
              *                        group.  The string must be able to hold at least OS_FLAG_NAME_SIZE characters.
              *
              *              perr      is a pointer to an error code that can contain one of the following values:
              *
              *                        OS_ERR_NONE                if the requested task is resumed
              *                        OS_ERR_EVENT_TYPE          if 'pevent' is not pointing to an event flag group
              *                        OS_ERR_PNAME_NULL          You passed a NULL pointer for 'pname'
              *                        OS_ERR_FLAG_INVALID_PGRP   if you passed a NULL pointer for 'pgrp'
              *                        OS_ERR_NAME_SET_ISR        if you called this function from an ISR
              *
              * Returns    : None
              *********************************************************************************************************
              */
              
              #if OS_FLAG_NAME_SIZE > 1
              void  OSFlagNameSet (OS_FLAG_GRP *pgrp, INT8U *pname, INT8U *perr) reentrant
              {
                  INT8U      len;
              #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;
                  }
                  if (pgrp == (OS_FLAG_GRP *)0) {              /* Is 'pgrp' a NULL pointer?                          */
                      *perr = OS_ERR_FLAG_INVALID_PGRP;
                      return;
                  }
                  if (pname == (INT8U *)0) {                   /* Is 'pname' a NULL pointer?                         */
                      *perr = OS_ERR_PNAME_NULL;
                      return;
                  }
              #endif
                  if (OSIntNesting > 0) {                      /* See if trying to call from an ISR                  */
                      *perr = OS_ERR_NAME_SET_ISR;
                      return;
C51 COMPILER V8.17   OS_FLAG                                                               03/26/2009 14:24:24 PAGE 9   

                  }
                  OS_ENTER_CRITICAL();
                  if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) {
                      OS_EXIT_CRITICAL();
                      *perr = OS_ERR_EVENT_TYPE;
                      return;
                  }
                  len = OS_StrLen(pname);                      /* Can we fit the string in the storage area?         */
                  if (len > (OS_FLAG_NAME_SIZE - 1)) {         /* No                                                 */
                      OS_EXIT_CRITICAL();
                      *perr = OS_ERR_FLAG_NAME_TOO_LONG;
                      return;
                  }
                  (void)OS_StrCopy(pgrp->OSFlagName, pname);   /* Yes, copy name from OS_FLAG_GRP                    */
                  OS_EXIT_CRITICAL();
                  *perr = OS_ERR_NONE;
                  return;
              }
              #endif
              
              /*$PAGE*/
              /*
              *********************************************************************************************************
              *                                        WAIT ON AN EVENT FLAG GROUP
              *
              * Description: This function is called to wait for a combination of bits to be set in an event flag
              *              group.  Your application can wait for ANY bit to be set or ALL bits to be set.
              *
              * Arguments  : pgrp          is a pointer to the desired event flag group.
              *
              *              flags         Is a bit pattern indicating which bit(s) (i.e. flags) you wish to wait for.
              *                            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 or ANY of the bits to be set.
              *                            You can specify the following argument:
              *
              *                            OS_FLAG_WAIT_CLR_ALL   You will wait for ALL bits in 'mask' to be clear (0)
              *                            OS_FLAG_WAIT_SET_ALL   You will wait for ALL bits in 'mask' to be set   (1)
              *                            OS_FLAG_WAIT_CLR_ANY   You will wait for ANY bit  in 'mask' to be clear (0)
              *                            OS_FLAG_WAIT_SET_ANY   You will wait for ANY bit  in 'mask' to be set   (1)
              *
              *                            NOTE: Add OS_FLAG_CONSUME if you want the event flag to be 'consumed' by
              *                                  the call.  Example, to wait for any flag in a group AND then clear
              *                                  the flags that are present, set 'wait_type' to:
              *
              *                                  OS_FLAG_WAIT_SET_ANY + OS_FLAG_CONSUME
              *
              *              timeout       is an optional timeout (in clock ticks) that your task will wait for the
              *                            desired bit combination.  If you specify 0, however, your task will wait
              *                            forever at the specified event flag group or, until a message arrives.
              *
              *              perr          is a pointer to an error code and can be:
              *                            OS_ERR_NONE               The desired bits have been set within the specified
              *                                                      'timeout'.
              *                            OS_ERR_PEND_ISR           If you tried to PEND from an ISR
              *                            OS_ERR_FLAG_INVALID_PGRP  If 'pgrp' is a NULL pointer.
              *                            OS_ERR_EVENT_TYPE         You are not pointing to an event flag group
              *                            OS_ERR_TIMEOUT            The bit(s) have not been set in the specified
              *                                                      'timeout'.
              *                            OS_ERR_PEND_ABORT         The wait on the flag was aborted.
C51 COMPILER V8.17   OS_FLAG                                                               03/26/2009 14:24:24 PAGE 10  

              *                            OS_ERR_FLAG_WAIT_TYPE     You didn't specify a proper 'wait_type' argument.
              *
              * Returns    : The flags in the event flag group that made the task ready or, 0 if a timeout or an error
              *              occurred.
              *
              * Called from: Task ONLY
              *
              * Note(s)    : 1) IMPORTANT, the behavior of this function has changed from PREVIOUS versions.  The
              *                 function NOW returns the flags that were ready INSTEAD of the current state of the
              *                 event flags.
              *********************************************************************************************************
              */
              
              OS_FLAGS  OSFlagPend (OS_FLAG_GRP *pgrp, OS_FLAGS flags, INT8U wait_type, INT16U timeout, INT8U *perr) ree
             -ntrant
              {
                  OS_FLAG_NODE  node;
                  OS_FLAGS      flags_rdy;
                  INT8U         result;
                  INT8U         pend_stat;
                  BOOLEAN       consume;
              #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 (OSIntNesting > 0) {                                /* See if called from ISR ...               */
                      *perr = OS_ERR_PEND_ISR;                           /* ... can't PEND from an ISR               */
                      return ((OS_FLAGS)0);
                  }
                  if (OSLockNesting > 0) {                               /* See if called with scheduler locked ...  */
                      *perr = OS_ERR_PEND_LOCKED;                        /* ... can't PEND when locked               */
                      return ((OS_FLAGS)0);
                  }
                  if (pgrp->OSFlagType != OS_EVENT_TYPE_FLAG) {          /* Validate event block type                */
                      *perr = OS_ERR_EVENT_TYPE;
                      return ((OS_FLAGS)0);
                  }
                  result = (INT8U)(wait_type & OS_FLAG_CONSUME);
                  if (result != (INT8U)0) {                             /* See if we need to consume the flags      */
                      wait_type &= ~(INT8U)OS_FLAG_CONSUME;
                      consume    = OS_TRUE;
                  } else {
                      consume    = OS_FALSE;
                  }

⌨️ 快捷键说明

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