?? os_q.lst
字號:
if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
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
600 /*$PAGE*/
601 /*
602 *********************************************************************************************************
603 * QUERY A MESSAGE QUEUE
604 *
605 * Description: This function obtains information about a message queue.
606 *
607 * Arguments : pevent is a pointer to the event control block associated with the desired queue
608 *
609 * pdata is a pointer to a structure that will contain information about the message
610 * queue.
611 *
612 * Returns : OS_NO_ERR The call was successful and the message was sent
C51 COMPILER V8.02 OS_Q 05/22/2008 18:01:52 PAGE 11
613 * OS_ERR_EVENT_TYPE If you are attempting to obtain data from a non queue.
614 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
615 *********************************************************************************************************
616 */
617
618 #if OS_Q_QUERY_EN > 0
INT8U OSQQuery (OS_EVENT *pevent, OS_Q_DATA *ppdata) KCREENTRANT
{
#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;
if (pq->OSQEntries > 0) {
ppdata->OSMsg = *pq->OSQOut; /* Get next message to return if available */
C51 COMPILER V8.02 OS_Q 05/22/2008 18:01:52 PAGE 12
} 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 */
684
685 /*$PAGE*/
686 /*
687 *********************************************************************************************************
688 * QUEUE MODULE INITIALIZATION
689 *
690 * Description : This function is called by uC/OS-II to initialize the message queue module. Your
691 * application MUST NOT call this function.
692 *
693 * Arguments : none
694 *
695 * Returns : none
696 *
697 * Note(s) : This function is INTERNAL to uC/OS-II and your application should not call it.
698 *********************************************************************************************************
699 */
700
701 void OS_QInit (void) KCREENTRANT
702 {
703 1 #if OS_MAX_QS == 1
704 1 OSQFreeList = &OSQTbl[0]; /* Only ONE queue! */
705 1 OSQFreeList->OSQPtr = (OS_Q *)0;
706 1 #endif
707 1
708 1 #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
724 1 }
725 #endif /* OS_Q_EN */
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 3212 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILER V8.02 OS_Q 05/22/2008 18:01:52 PAGE 13
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -