📄 os_q.ls1
字号:
451 ; * OS_Q_FULL If the queue cannot accept any more messages because
it is full.
452 ; * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a queue.
453 ; * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
454 ; * OS_ERR_POST_NULL_PTR If you are attempting to post a NULL pointer
455 ; *****************************************************************************************
****************
456 ; */
457 ;
458 ; #if OS_Q_POST_EN > 0
459 ; INT8U OSQPost (OS_EVENT *pevent, void *msg)
460 ; {
461 ;
462 ; OS_Q *pq;
463 ;
464 ;
465 ; #if OS_ARG_CHK_EN > 0
466 ; if (pevent == (OS_EVENT *)0) { /* Validate 'pevent'
*/
467 ; return (OS_ERR_PEVENT_NULL);
A51 MACRO ASSEMBLER OS_Q 08/08/2005 11:36:51 PAGE 10
468 ; }
469 ; if (msg == (void *)0) { /* Make sure we are not posting a N
ULL pointer */
470 ; return (OS_ERR_POST_NULL_PTR);
471 ; }
472 ; if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type
*/
473 ; return (OS_ERR_EVENT_TYPE);
474 ; }
475 ; #endif
476 ; OS_ENTER_CRITICAL();
477 ; if (pevent->OSEventGrp != 0x00) { /* See if any task pending on queue
*/
478 ; OS_EventTaskRdy(pevent, msg, OS_STAT_Q); /* Ready highest priority task wait
ing on event */
479 ; OS_EXIT_CRITICAL();
480 ; OS_Sched(); /* Find highest priority task ready
to run */
481 ; return (OS_NO_ERR);
482 ; }
483 ; pq = (OS_Q *)pevent->OSEventPtr; /* Point to queue control block
*/
484 ; if (pq->OSQEntries >= pq->OSQSize) { /* Make sure queue is not full
*/
485 ; OS_EXIT_CRITICAL();
486 ; return (OS_Q_FULL);
487 ; }
488 ; *pq->OSQIn++ = msg; /* Insert message into queue
*/
489 ; pq->OSQEntries++; /* Update the nbr of entries in the
queue */
490 ; if (pq->OSQIn == pq->OSQEnd) { /* Wrap IN ptr if we are at end of
queue */
491 ; pq->OSQIn = pq->OSQStart;
492 ; }
493 ; OS_EXIT_CRITICAL();
494 ; return (OS_NO_ERR);
495 ; }
496 ; #endif
497 ; /*$PAGE*/
498 ; /*
499 ; *****************************************************************************************
****************
500 ; * POST MESSAGE TO THE FRONT OF A QUEUE
501 ; *
502 ; * Description: This function sends a message to a queue but unlike OSQPost(), the message
is posted at
503 ; * the front instead of the end of the queue. Using OSQPostFront() allows yo
u to send
504 ; * 'priority' messages.
505 ; *
506 ; * Arguments : pevent is a pointer to the event control block associated with the
desired queue
507 ; *
508 ; * msg is a pointer to the message to send. You MUST NOT send a NU
LL pointer.
509 ; *
510 ; * Returns : OS_NO_ERR The call was successful and the message was sent
511 ; * OS_Q_FULL If the queue cannot accept any more messages because
it is full.
512 ; * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a queue.
513 ; * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
514 ; * OS_ERR_POST_NULL_PTR If you are attempting to post to a non queue.
515 ; *****************************************************************************************
****************
516 ; */
A51 MACRO ASSEMBLER OS_Q 08/08/2005 11:36:51 PAGE 11
517 ;
518 ; #if OS_Q_POST_FRONT_EN > 0
519 ; INT8U OSQPostFront (OS_EVENT *pevent, void *msg)
520 ; {
521 ;
522 ; OS_Q *pq;
523 ;
524 ;
525 ; #if OS_ARG_CHK_EN > 0
526 ; if (pevent == (OS_EVENT *)0) { /* Validate 'pevent'
*/
527 ; return (OS_ERR_PEVENT_NULL);
528 ; }
529 ; if (msg == (void *)0) { /* Make sure we are not posting a N
ULL pointer */
530 ; return (OS_ERR_POST_NULL_PTR);
531 ; }
532 ; if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type
*/
533 ; return (OS_ERR_EVENT_TYPE);
534 ; }
535 ; #endif
536 ; OS_ENTER_CRITICAL();
537 ; if (pevent->OSEventGrp != 0x00) { /* See if any task pending on queue
*/
538 ; OS_EventTaskRdy(pevent, msg, OS_STAT_Q); /* Ready highest priority task wait
ing on event */
539 ; OS_EXIT_CRITICAL();
540 ; OS_Sched(); /* Find highest priority task ready
to run */
541 ; return (OS_NO_ERR);
542 ; }
543 ; pq = (OS_Q *)pevent->OSEventPtr; /* Point to queue control block
*/
544 ; if (pq->OSQEntries >= pq->OSQSize) { /* Make sure queue is not full
*/
545 ; OS_EXIT_CRITICAL();
546 ; return (OS_Q_FULL);
547 ; }
548 ; if (pq->OSQOut == pq->OSQStart) { /* Wrap OUT ptr if we are at the 1s
t queue entry */
549 ; pq->OSQOut = pq->OSQEnd;
550 ; }
551 ; pq->OSQOut--;
552 ; *pq->OSQOut = msg; /* Insert message into queue
*/
553 ; pq->OSQEntries++; /* Update the nbr of entries in the
queue */
554 ; OS_EXIT_CRITICAL();
555 ; return (OS_NO_ERR);
556 ; }
557 ; #endif
558 ; /*$PAGE*/
559 ; /*
560 ; *****************************************************************************************
****************
561 ; * POST MESSAGE TO A QUEUE
562 ; *
563 ; * Description: This function sends a message to a queue. This call has been added to red
uce code size
564 ; * since it can replace both OSQPost() and OSQPostFront(). Also, this functi
on adds the
565 ; * capability to broadcast a message to ALL tasks waiting on the message queu
e.
566 ; *
567 ; * Arguments : pevent is a pointer to the event control block associated with the
A51 MACRO ASSEMBLER OS_Q 08/08/2005 11:36:51 PAGE 12
desired queue
568 ; *
569 ; * msg is a pointer to the message to send. You MUST NOT send a NU
LL pointer.
570 ; *
571 ; * opt determines the type of POST performed:
572 ; * OS_POST_OPT_NONE POST to a single waiting task
573 ; * (Identical to OSQPost())
574 ; * OS_POST_OPT_BROADCAST POST to ALL tasks that are waiting
on the queue
575 ; * OS_POST_OPT_FRONT POST as LIFO (Simulates OSQPostFron
t())
576 ; *
577 ; * Below is a list of ALL the possible combination of these fla
gs:
578 ; *
579 ; * 1) OS_POST_OPT_NONE
580 ; * identical to OSQPost()
581 ; *
582 ; * 2) OS_POST_OPT_FRONT
583 ; * identical to OSQPostFront()
584 ; *
585 ; * 3) OS_POST_OPT_BROADCAST
586 ; * identical to OSQPost() but will broadcast 'msg' to A
LL waiting tasks
587 ; *
588 ; * 4) OS_POST_OPT_FRONT + OS_POST_OPT_BROADCAST is identi
cal to
589 ; * OSQPostFront() except that will broadcast 'msg' to A
LL waiting tasks
590 ; *
591 ; * Returns : OS_NO_ERR The call was successful and the message was sent
592 ; * OS_Q_FULL If the queue cannot accept any more messages because
it is full.
593 ; * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a queue.
594 ; * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
595 ; * OS_ERR_POST_NULL_PTR If you are attempting to post a NULL pointer
596 ; *
597 ; * Warning : Interrupts can be disabled for a long time if you do a 'broadcast'. In fa
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -