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

📄 os_q.lst

📁 uCos-ii 2.86 在C8051F410单片机上移植成功!!! 其中包括:UART驱动
💻 LST
📖 第 1 页 / 共 4 页
字号:
                  }
                  if (pq->OSQOut == pq->OSQStart) {                 /* Wrap OUT ptr if we are at the 1st queue entry */
                      pq->OSQOut = pq->OSQEnd;
                  }
                  pq->OSQOut--;
                  *pq->OSQOut = pmsg;                               /* Insert message into queue                     */
                  pq->OSQEntries++;                                 /* Update the nbr of entries in the queue        */
                  OS_EXIT_CRITICAL();
                  return (OS_ERR_NONE);
              }
              #endif
C51 COMPILER V8.17   OS_Q                                                                  03/26/2009 14:24:25 PAGE 12  

              /*$PAGE*/
              /*
              *********************************************************************************************************
              *                                        POST MESSAGE TO A QUEUE
              *
              * Description: This function sends a message to a queue.  This call has been added to reduce code size
              *              since it can replace both OSQPost() and OSQPostFront().  Also, this function adds the
              *              capability to broadcast a message to ALL tasks waiting on the message queue.
              *
              * Arguments  : pevent        is a pointer to the event control block associated with the desired queue
              *
              *              pmsg          is a pointer to the message to send.
              *
              *              opt           determines the type of POST performed:
              *                            OS_POST_OPT_NONE         POST to a single waiting task
              *                                                     (Identical to OSQPost())
              *                            OS_POST_OPT_BROADCAST    POST to ALL tasks that are waiting on the queue
              *                            OS_POST_OPT_FRONT        POST as LIFO (Simulates OSQPostFront())
              *                            OS_POST_OPT_NO_SCHED     Indicates that the scheduler will NOT be invoked
              *
              * Returns    : OS_ERR_NONE           The call was successful and the message was sent
              *              OS_ERR_Q_FULL         If the queue cannot accept any more messages because it is full.
              *              OS_ERR_EVENT_TYPE     If you didn't pass a pointer to a queue.
              *              OS_ERR_PEVENT_NULL    If 'pevent' is a NULL pointer
              *
              * Warning    : Interrupts can be disabled for a long time if you do a 'broadcast'.  In fact, the
              *              interrupt disable time is proportional to the number of tasks waiting on the queue.
              *********************************************************************************************************
              */
              
              #if OS_Q_POST_OPT_EN > 0
              INT8U  OSQPostOpt (OS_EVENT *pevent, void *pmsg, INT8U opt) reentrant
              {
                  OS_Q      *pq;
              #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 (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
                      return (OS_ERR_PEVENT_NULL);
                  }
              #endif
                  if (pevent->OSEventType != OS_EVENT_TYPE_Q) {     /* Validate event block type                     */
                      return (OS_ERR_EVENT_TYPE);
                  }
                  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 != 0) {         /* Yes, Post to ALL tasks waiting on queue       */
                              (void)OS_EventTaskRdy(pevent, pmsg, OS_STAT_Q, OS_STAT_PEND_OK);
                          }
                      } else {                                      /* No,  Post to HPT waiting on queue             */
                          (void)OS_EventTaskRdy(pevent, pmsg, OS_STAT_Q, OS_STAT_PEND_OK);
                      }
                      OS_EXIT_CRITICAL();
                      if ((opt & OS_POST_OPT_NO_SCHED) == 0) {    /* See if scheduler needs to be invoked          */
                          OS_Sched();                               /* Find highest priority task ready to run       */
                      }
                      return (OS_ERR_NONE);
C51 COMPILER V8.17   OS_Q                                                                  03/26/2009 14:24:25 PAGE 13  

                  }
                  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_ERR_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 = pmsg;                           /*      Insert message into queue                */
                  } else {                                          /* No,  Post as FIFO                             */
                      *pq->OSQIn++ = pmsg;                          /*      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_ERR_NONE);
              }
              #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
              *
              *              p_q_data      is a pointer to a structure that will contain information about the message
              *                            queue.
              *
              * Returns    : OS_ERR_NONE         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
              *              OS_ERR_PDATA_NULL   If 'p_q_data' is a NULL pointer
              *********************************************************************************************************
              */
              
              #if OS_Q_QUERY_EN > 0
              INT8U  OSQQuery (OS_EVENT *pevent, OS_Q_DATA *p_q_data) reentrant
              {
                  OS_Q      *pq;
                  INT8U      i;
              #if OS_LOWEST_PRIO <= 63
                  INT8U     *psrc;
                  INT8U     *pdest;
              #else
                  INT16U    *psrc;
                  INT16U    *pdest;
              #endif
              #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 (pevent == (OS_EVENT *)0) {                     /* Validate 'pevent'                            */
C51 COMPILER V8.17   OS_Q                                                                  03/26/2009 14:24:25 PAGE 14  

                      return (OS_ERR_PEVENT_NULL);
                  }
                  if (p_q_data == (OS_Q_DATA *)0) {                  /* Validate 'p_q_data'                          */
                      return (OS_ERR_PDATA_NULL);
                  }
              #endif
                  if (pevent->OSEventType != OS_EVENT_TYPE_Q) {      /* Validate event block type                    */
                      return (OS_ERR_EVENT_TYPE);
                  }
                  OS_ENTER_CRITICAL();
                  p_q_data->OSEventGrp = pevent->OSEventGrp;         /* Copy message queue wait list                 */
                  psrc                 = &pevent->OSEventTbl[0];
                  pdest                = &p_q_data->OSEventTbl[0];
                  for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
                      *pdest++ = *psrc++;
                  }
                  pq = (OS_Q *)pevent->OSEventPtr;
                  if (pq->OSQEntries > 0) {
                      p_q_data->OSMsg = *pq->OSQOut;                 /* Get next message to return if available      */
                  } else {
                      p_q_data->OSMsg = (void *)0;
                  }
                  p_q_data->OSNMsgs = pq->OSQEntries;
                  p_q_data->OSQSize = pq->OSQSize;
                  OS_EXIT_CRITICAL();
                  return (OS_ERR_NONE);
              }
              #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;
              
              
              
                  OS_MemClr((INT8U *)&OSQTbl[0], sizeof(OSQTbl));  /* Clear the queue table                          */
                  pq1 = &OSQTbl[0];
                  pq2 = &OSQTbl[1];
C51 COMPILER V8.17   OS_Q                                                                  03/26/2009 14:24:25 PAGE 15  

                  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        =   ----    ----
   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 + -