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

📄 os_q.lst

📁 ucOS移植到STC89C58RD上面的源代码
💻 LST
📖 第 1 页 / 共 4 页
字号:
                  }
                  if (msg == (void *)0) {                           /* Make sure we are not posting a NULL pointer   */
                      return (OS_ERR_POST_NULL_PTR);
                  }
                  if (pevent->OSEventType != OS_EVENT_TYPE_Q) {     /* Validate event block type                     */
                      return (OS_ERR_EVENT_TYPE);
                  }
              #endif
                  OS_ENTER_CRITICAL();
                  if (pevent->OSEventGrp != 0x00) {                 /* See if any task pending on queue              */
                      if ((opt & OS_POST_OPT_BROADCAST) != 0x00) {  /* Do we need to post msg to ALL waiting tasks ? */
                          while (pevent->OSEventGrp != 0x00) {      /* Yes, Post to ALL tasks waiting on queue       */ 
             -          
                              OS_EventTaskRdy(pevent, msg, OS_STAT_Q);    
                          }
                      } else {
                          OS_EventTaskRdy(pevent, msg, OS_STAT_Q);  /* No,  Post to HPT waiting on queue             */
                      }
                      OS_EXIT_CRITICAL();
                      OS_Sched();                                   /* Find highest priority task ready to run       */
                      return (OS_NO_ERR);
                  }
                  pq = (OS_Q *)pevent->OSEventPtr;                  /* Point to queue control block                  */
                  if (pq->OSQEntries >= pq->OSQSize) {              /* Make sure queue is not full                   */
                      OS_EXIT_CRITICAL();
                      return (OS_Q_FULL);
                  }
                  if ((opt & OS_POST_OPT_FRONT) != 0x00) {          /* Do we post to the FRONT of the queue?         */
                      if (pq->OSQOut == pq->OSQStart) {             /* Yes, Post as LIFO, Wrap OUT pointer if we ... */
                          pq->OSQOut = pq->OSQEnd;                  /*      ... are at the 1st queue entry           */
                      }
                      pq->OSQOut--;
                      *pq->OSQOut = msg;                            /*      Insert message into queue                */
                  } else {                                          /* No,  Post as FIFO                             */
                      *pq->OSQIn++ = msg;                           /*      Insert message into queue                */
                      if (pq->OSQIn == pq->OSQEnd) {                /*      Wrap IN ptr if we are at end of queue    */
                          pq->OSQIn = pq->OSQStart;
                      }
                  }
                  pq->OSQEntries++;                                 /* Update the nbr of entries in the queue        */
                  OS_EXIT_CRITICAL();
                  return (OS_NO_ERR);
              }
              #endif
              /*$PAGE*/
              /*
              *********************************************************************************************************
              *                                        QUERY A MESSAGE QUEUE
              *
              * Description: This function obtains information about a message queue.
              *
              * Arguments  : pevent        is a pointer to the event control block associated with the desired queue
              *
              *              ppdata         is a pointer to a structure that will contain information about the message
              *                            queue.
C51 COMPILER V7.50   OS_Q                                                                  12/14/2005 10:56:01 PAGE 11  

              *
              * Returns    : OS_NO_ERR           The call was successful and the message was sent
              *              OS_ERR_EVENT_TYPE   If you are attempting to obtain data from a non queue.
              *              OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
              *********************************************************************************************************
              */
              
              #if OS_Q_QUERY_EN > 0
              INT8U  OSQQuery (OS_EVENT *pevent, OS_Q_DATA *ppdata) reentrant
              {
              #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
                  OS_CPU_SR  cpu_sr;
              #endif    
                  OS_Q      *pq;
                  INT8U     *psrc;
                  INT8U     *pdest;
              
              
              #if OS_ARG_CHK_EN > 0
                  if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
                      return (OS_ERR_PEVENT_NULL);
                  }
                  if (pevent->OSEventType != OS_EVENT_TYPE_Q) {          /* Validate event block type                */
                      return (OS_ERR_EVENT_TYPE);
                  }
              #endif
                  OS_ENTER_CRITICAL();
                  ppdata->OSEventGrp = pevent->OSEventGrp;                /* Copy message queue wait list           */
                  psrc              = &pevent->OSEventTbl[0];
                  pdest             = &ppdata->OSEventTbl[0];
              #if OS_EVENT_TBL_SIZE > 0
                  *pdest++          = *psrc++;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 1
                  *pdest++          = *psrc++;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 2
                  *pdest++          = *psrc++;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 3
                  *pdest++          = *psrc++;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 4
                  *pdest++          = *psrc++;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 5
                  *pdest++          = *psrc++;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 6
                  *pdest++          = *psrc++;
              #endif
              
              #if OS_EVENT_TBL_SIZE > 7
                  *pdest            = *psrc;
              #endif
                  pq = (OS_Q *)pevent->OSEventPtr;
C51 COMPILER V7.50   OS_Q                                                                  12/14/2005 10:56:01 PAGE 12  

                  if (pq->OSQEntries > 0) {
                      ppdata->OSMsg = *pq->OSQOut;                         /* Get next message to return if available  *
             -/
                  } else {
                      ppdata->OSMsg = (void *)0;
                  }
                  ppdata->OSNMsgs = pq->OSQEntries;
                  ppdata->OSQSize = pq->OSQSize;
                  OS_EXIT_CRITICAL();
                  return (OS_NO_ERR);
              }
              #endif                                                     /* OS_Q_QUERY_EN                            */
              
              /*$PAGE*/
              /*
              *********************************************************************************************************
              *                                      QUEUE MODULE INITIALIZATION
              *
              * Description : This function is called by uC/OS-II to initialize the message queue module.  Your
              *               application MUST NOT call this function.
              *
              * Arguments   :  none
              *
              * Returns     : none
              *
              * Note(s)    : This function is INTERNAL to uC/OS-II and your application should not call it.
              *********************************************************************************************************
              */
              
              void  OS_QInit (void) reentrant
              {
              #if OS_MAX_QS == 1
                  OSQFreeList         = &OSQTbl[0];            /* Only ONE queue!                                    */
                  OSQFreeList->OSQPtr = (OS_Q *)0;
              #endif
              
              #if OS_MAX_QS >= 2
                  INT16U  i;
                  OS_Q   *pq1;
                  OS_Q   *pq2;
              
              
                  pq1 = &OSQTbl[0];
                  pq2 = &OSQTbl[1];
                  for (i = 0; i < (OS_MAX_QS - 1); i++) {      /* Init. list of free QUEUE control blocks            */
                      pq1->OSQPtr = pq2;
                      pq1++;
                      pq2++;
                  }
                  pq1->OSQPtr = (OS_Q *)0;
                  OSQFreeList = &OSQTbl[0];
              #endif
              }
              #endif                                                     /* OS_Q_EN                                  */


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   ----    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
C51 COMPILER V7.50   OS_Q                                                                  12/14/2005 10:56:01 PAGE 13  

   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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