📄 os_q.lst
字号:
return (OS_ERR_PEVENT_NULL);
}
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
602 /*$PAGE*/
603 /*
604 *********************************************************************************************************
605 * QUERY A MESSAGE QUEUE
606 *
607 * Description: This function obtains information about a message queue.
608 *
609 * Arguments : pevent is a pointer to the event control block associated with the desired queue
610 *
611 * ppdata is a pointer to a structure that will contain information about the message
C51 COMPILER V7.06 OS_Q 03/05/2008 20:23:54 PAGE 11
612 * queue.
613 *
614 * Returns : OS_NO_ERR The call was successful and the message was sent
615 * OS_ERR_EVENT_TYPE If you are attempting to obtain data from a non queue.
616 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
617 *********************************************************************************************************
618 */
619
620 #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
C51 COMPILER V7.06 OS_Q 03/05/2008 20:23:54 PAGE 12
pq = (OS_Q *)pevent->OSEventPtr;
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 */
686
687 /*$PAGE*/
688 /*
689 *********************************************************************************************************
690 * QUEUE MODULE INITIALIZATION
691 *
692 * Description : This function is called by uC/OS-II to initialize the message queue module. Your
693 * application MUST NOT call this function.
694 *
695 * Arguments : none
696 *
697 * Returns : none
698 *
699 * Note(s) : This function is INTERNAL to uC/OS-II and your application should not call it.
700 *********************************************************************************************************
701 */
702
703 void OS_QInit (void) reentrant
704 {
705 1 #if OS_MAX_QS == 1
OSQFreeList = &OSQTbl[0]; /* Only ONE queue! */
OSQFreeList->OSQPtr = (OS_Q *)0;
#endif
709 1
710 1 #if OS_MAX_QS >= 2
711 1 INT16U i;
712 1 OS_Q *pq1;
713 1 OS_Q *pq2;
714 1
715 1
716 1 pq1 = &OSQTbl[0];
717 1 pq2 = &OSQTbl[1];
718 1 for (i = 0; i < (OS_MAX_QS - 1); i++) { /* Init. list of free QUEUE control blocks */
719 2 pq1->OSQPtr = pq2;
720 2 pq1++;
721 2 pq2++;
722 2 }
723 1 pq1->OSQPtr = (OS_Q *)0;
724 1 OSQFreeList = &OSQTbl[0];
725 1 #endif
726 1 }
727 #endif /* OS_Q_EN */
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 2345 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
C51 COMPILER V7.06 OS_Q 03/05/2008 20:23:54 PAGE 13
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 + -