📄 os_q.ls1
字号:
*/
603 ; OS_EXIT_CRITICAL();
604 ; return (OS_Q_FULL);
605 ; }
606 ; if (pq->OSQOut == pq->OSQStart) { /* Wrap OUT ptr if we are at the 1s
t queue entry */
607 ; pq->OSQOut = pq->OSQEnd;
608 ; }
609 ; pq->OSQOut--;
610 ; *pq->OSQOut = msg; /* Insert message into queue
*/
611 ; pq->OSQEntries++; /* Update the nbr of entries in the
queue */
612 ; OS_EXIT_CRITICAL();
613 ; return (OS_NO_ERR);
614 ; }
615 ; #endif
616 ; /*$PAGE*/
617 ; /*
618 ; *****************************************************************************************
****************
619 ; * POST MESSAGE TO A QUEUE
620 ; *
621 ; * Description: This function sends a message to a queue. This call has been added to red
uce code size
622 ; * since it can replace both OSQPost() and OSQPostFront(). Also, this functi
on adds the
623 ; * capability to broadcast a message to ALL tasks waiting on the message queu
e.
624 ; *
625 ; * Arguments : pevent is a pointer to the event control block associated with the
A51 MACRO ASSEMBLER OS_Q 05/17/2005 11:19:56 PAGE 13
desired queue
626 ; *
627 ; * msg is a pointer to the message to send. You MUST NOT send a NU
LL pointer.
628 ; *
629 ; * opt determines the type of POST performed:
630 ; * OS_POST_OPT_NONE POST to a single waiting task
631 ; * (Identical to OSQPost())
632 ; * OS_POST_OPT_BROADCAST POST to ALL tasks that are waiting
on the queue
633 ; * OS_POST_OPT_FRONT POST as LIFO (Simulates OSQPostFron
t())
634 ; *
635 ; * Below is a list of ALL the possible combination of these fla
gs:
636 ; *
637 ; * 1) OS_POST_OPT_NONE
638 ; * identical to OSQPost()
639 ; *
640 ; * 2) OS_POST_OPT_FRONT
641 ; * identical to OSQPostFront()
642 ; *
643 ; * 3) OS_POST_OPT_BROADCAST
644 ; * identical to OSQPost() but will broadcast 'msg' to A
LL waiting tasks
645 ; *
646 ; * 4) OS_POST_OPT_FRONT + OS_POST_OPT_BROADCAST is identi
cal to
647 ; * OSQPostFront() except that will broadcast 'msg' to A
LL waiting tasks
648 ; *
649 ; * Returns : OS_NO_ERR The call was successful and the message was sent
650 ; * OS_Q_FULL If the queue cannot accept any more messages because
it is full.
651 ; * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a queue.
652 ; * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
653 ; * OS_ERR_POST_NULL_PTR If you are attempting to post a NULL pointer
654 ; *
655 ; * Warning : Interrupts can be disabled for a long time if you do a 'broadcast'. In fa
ct, the
656 ; * interrupt disable time is proportional to the number of tasks waiting on t
he queue.
657 ; *****************************************************************************************
****************
658 ; */
659 ;
660 ; #if OS_Q_POST_OPT_EN > 0
661 ; INT8U OSQPostOpt (OS_EVENT *pevent, void *msg, INT8U opt)LG_REENTRANT
662 ; {
663 ; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status regis
ter */
664 ; OS_CPU_SR cpu_sr;
665 ; #endif
666 ; OS_Q *pq;
667 ;
668 ;
669 ; #if OS_ARG_CHK_EN > 0
670 ; if (pevent == (OS_EVENT *)0) { /* Validate 'pevent'
*/
671 ; return (OS_ERR_PEVENT_NULL);
672 ; }
673 ; if (msg == (void *)0) { /* Make sure we are not posting a N
ULL pointer */
674 ; return (OS_ERR_POST_NULL_PTR);
675 ; }
676 ; if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type
A51 MACRO ASSEMBLER OS_Q 05/17/2005 11:19:56 PAGE 14
*/
677 ; return (OS_ERR_EVENT_TYPE);
678 ; }
679 ; #endif
680 ; OS_ENTER_CRITICAL();
681 ; if (pevent->OSEventGrp != 0x00) { /* See if any task pending on queue
*/
682 ; if ((opt & OS_POST_OPT_BROADCAST) != 0x00) { /* Do we need to post msg to ALL wa
iting tasks ? */
683 ; while (pevent->OSEventGrp != 0x00) { /* Yes, Post to ALL tasks waiting o
n queue */
684 ; OS_EventTaskRdy(pevent, msg, OS_STAT_Q);
685 ; }
686 ; } else {
687 ; OS_EventTaskRdy(pevent, msg, OS_STAT_Q); /* No, Post to HPT waiting on queu
e */
688 ; }
689 ; OS_EXIT_CRITICAL();
690 ; OS_Sched(); /* Find highest priority task ready
to run */
691 ; return (OS_NO_ERR);
692 ; }
693 ; pq = (OS_Q *)pevent->OSEventPtr; /* Point to queue control block
*/
694 ; if (pq->OSQEntries >= pq->OSQSize) { /* Make sure queue is not full
*/
695 ; OS_EXIT_CRITICAL();
696 ; return (OS_Q_FULL);
697 ; }
698 ; if ((opt & OS_POST_OPT_FRONT) != 0x00) { /* Do we post to the FRONT of the q
ueue? */
699 ; if (pq->OSQOut == pq->OSQStart) { /* Yes, Post as LIFO, Wrap OUT poin
ter if we ... */
700 ; pq->OSQOut = pq->OSQEnd; /* ... are at the 1st queue en
try */
701 ; }
702 ; pq->OSQOut--;
703 ; *pq->OSQOut = msg; /* Insert message into queue
*/
704 ; } else { /* No, Post as FIFO
*/
705 ; *pq->OSQIn++ = msg; /* Insert message into queue
*/
706 ; if (pq->OSQIn == pq->OSQEnd) { /* Wrap IN ptr if we are at en
d of queue */
707 ; pq->OSQIn = pq->OSQStart;
708 ; }
709 ; }
710 ; pq->OSQEntries++; /* Update the nbr of entries in the
queue */
711 ; OS_EXIT_CRITICAL();
712 ; return (OS_NO_ERR);
713 ; }
714 ; #endif
715 ; /*$PAGE*/
716 ; /*
717 ; *****************************************************************************************
****************
718 ; * QUERY A MESSAGE QUEUE
719 ; *
720 ; * Description: This function obtains information about a message queue.
721 ; *
722 ; * Arguments : pevent is a pointer to the event control block associated with the
desired queue
723 ; *
724 ; * pdata is a pointer to a structure that will contain information ab
A51 MACRO ASSEMBLER OS_Q 05/17/2005 11:19:56 PAGE 15
out the message
725 ; * queue.
726 ; *
727 ; * Returns : OS_NO_ERR The call was successful and the message was sent
728 ; * OS_ERR_EVENT_TYPE If you are attempting to obtain data from a non queue.
729 ; * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
730 ; *****************************************************************************************
****************
731 ; */
732 ;
733 ; #if OS_Q_QUERY_EN > 0
734 ; INT8U OSQQuery (OS_EVENT *pevent, OS_Q_DATA *os_pdata)LG_REENTRANT
735 ; {
736 ; #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status regis
ter */
737 ; OS_CPU_SR cpu_sr;
738 ; #endif
739 ; OS_Q *pq;
740 ; INT8U *psrc;
741 ; INT8U *pdest;
742 ;
743 ;
744 ; #if OS_ARG_CHK_EN > 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -