📄 os_core.lst
字号:
427 *********************************************************************************************************
428 */
429
430 #if OS_TASK_DEL_EN > 0
431 void OS_Dummy (void) KCREENTRANT
432 {
433 1 }
434 #endif
435
436 /*$PAGE*/
437 /*
438 *********************************************************************************************************
439 * MAKE TASK READY TO RUN BASED ON EVENT OCCURING
440 *
441 * Description: This function is called by other uC/OS-II services and is used to ready a task that was
442 * waiting for an event to occur.
443 *
444 * Arguments : pevent is a pointer to the event control block corresponding to the event.
445 *
446 * msg is a pointer to a message. This pointer is used by message oriented services
447 * such as MAILBOXEs and QUEUEs. The pointer is not used when called by other
448 * service functions.
449 *
450 * msk is a mask that is used to clear the status byte of the TCB. For example,
451 * OSSemPost() will pass OS_STAT_SEM, OSMboxPost() will pass OS_STAT_MBOX etc.
452 *
453 * Returns : none
454 *
455 * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
456 *********************************************************************************************************
457 */
458 #if OS_EVENT_EN > 0
459 INT8U OS_EventTaskRdy (OS_EVENT *pevent, void *msg, INT8U msk) KCREENTRANT
460 {
461 1 OS_TCB *ptcb;
462 1 INT8U x;
463 1 INT8U y;
464 1 INT8U bitx;
465 1 INT8U bity;
466 1 INT8U prio;
467 1
468 1
469 1 y = OSUnMapTbl[pevent->OSEventGrp]; /* Find highest prio. task waiting for message */
470 1 bity = OSMapTbl[y];
471 1 x = OSUnMapTbl[pevent->OSEventTbl[y]];
472 1 bitx = OSMapTbl[x];
473 1 prio = (INT8U)((y << 3) + x); /* Find priority of task getting the msg */
474 1 if ((pevent->OSEventTbl[y] &= ~bitx) == 0x00) { /* Remove this task from the waiting list */
475 2 pevent->OSEventGrp &= ~bity; /* Clr group bit if this was only task pending */
476 2 }
477 1 ptcb = OSTCBPrioTbl[prio]; /* Point to this task's OS_TCB */
478 1 ptcb->OSTCBDly = 0; /* Prevent OSTimeTick() from readying task */
C51 COMPILER V6.23a OS_CORE 12/09/2004 16:50:24 PAGE 9
479 1 ptcb->OSTCBEventPtr = (OS_EVENT *)0; /* Unlink ECB from this task */
480 1 #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0)
481 1 ptcb->OSTCBMsg = msg; /* Send message directly to waiting task */
482 1 #else
msg = msg; /* Prevent compiler warning if not used */
#endif
485 1 ptcb->OSTCBStat &= ~msk; /* Clear bit associated with event type */
486 1 if (ptcb->OSTCBStat == OS_STAT_RDY) { /* See if task is ready (could be susp'd) */
487 2 OSRdyGrp |= bity; /* Put task in the ready to run list */
488 2 OSRdyTbl[y] |= bitx;
489 2 }
490 1 return (prio);
491 1 }
492 #endif
493 /*$PAGE*/
494 /*
495 *********************************************************************************************************
496 * MAKE TASK WAIT FOR EVENT TO OCCUR
497 *
498 * Description: This function is called by other uC/OS-II services to suspend a task because an event has
499 * not occurred.
500 *
501 * Arguments : pevent is a pointer to the event control block for which the task will be waiting for.
502 *
503 * Returns : none
504 *
505 * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
506 *********************************************************************************************************
507 */
508 #if OS_EVENT_EN > 0
509 void OS_EventTaskWait (OS_EVENT *pevent) KCREENTRANT
510 {
511 1 OSTCBCur->OSTCBEventPtr = pevent; /* Store pointer to event control block in TCB */
512 1 if ((OSRdyTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0x00) { /* Task no longer ready */
513 2 OSRdyGrp &= ~OSTCBCur->OSTCBBitY; /* Clear event grp bit if this was only task pending */
514 2 }
515 1 pevent->OSEventTbl[OSTCBCur->OSTCBY] |= OSTCBCur->OSTCBBitX; /* Put task in waiting list */
516 1 pevent->OSEventGrp |= OSTCBCur->OSTCBBitY;
517 1 }
518 #endif
519 /*$PAGE*/
520 /*
521 *********************************************************************************************************
522 * MAKE TASK READY TO RUN BASED ON EVENT TIMEOUT
523 *
524 * Description: This function is called by other uC/OS-II services to make a task ready to run because a
525 * timeout occurred.
526 *
527 * Arguments : pevent is a pointer to the event control block which is readying a task.
528 *
529 * Returns : none
530 *
531 * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
532 *********************************************************************************************************
533 */
534 #if OS_EVENT_EN > 0
535 void OS_EventTO (OS_EVENT *pevent) KCREENTRANT
536 {
537 1 if ((pevent->OSEventTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0x00) {
538 2 pevent->OSEventGrp &= ~OSTCBCur->OSTCBBitY;
539 2 }
540 1 OSTCBCur->OSTCBStat = OS_STAT_RDY; /* Set status to ready */
C51 COMPILER V6.23a OS_CORE 12/09/2004 16:50:24 PAGE 10
541 1 OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0; /* No longer waiting for event */
542 1 }
543 #endif
544 /*$PAGE*/
545 /*
546 *********************************************************************************************************
547 * INITIALIZE EVENT CONTROL BLOCK'S WAIT LIST
548 *
549 * Description: This function is called by other uC/OS-II services to initialize the event wait list.
550 *
551 * Arguments : pevent is a pointer to the event control block allocated to the event.
552 *
553 * Returns : none
554 *
555 * Note : This function is INTERNAL to uC/OS-II and your application should not call it.
556 *********************************************************************************************************
557 */
558 #if ((OS_Q_EN > 0) && (OS_MAX_QS > 0)) || (OS_MBOX_EN > 0) || (OS_SEM_EN > 0) || (OS_MUTEX_EN > 0)
559 void OS_EventWaitListInit (OS_EVENT *pevent) KCREENTRANT
560 {
561 1 INT8U *ptbl;
562 1
563 1
564 1 pevent->OSEventGrp = 0x00; /* No task waiting on event */
565 1 ptbl = &pevent->OSEventTbl[0];
566 1
567 1 #if OS_EVENT_TBL_SIZE > 0
568 1 *ptbl++ = 0x00;
569 1 #endif
570 1
571 1 #if OS_EVENT_TBL_SIZE > 1
572 1 *ptbl++ = 0x00;
573 1 #endif
574 1
575 1 #if OS_EVENT_TBL_SIZE > 2
*ptbl++ = 0x00;
#endif
578 1
579 1 #if OS_EVENT_TBL_SIZE > 3
*ptbl++ = 0x00;
#endif
582 1
583 1 #if OS_EVENT_TBL_SIZE > 4
*ptbl++ = 0x00;
#endif
586 1
587 1 #if OS_EVENT_TBL_SIZE > 5
*ptbl++ = 0x00;
#endif
590 1
591 1 #if OS_EVENT_TBL_SIZE > 6
*ptbl++ = 0x00;
#endif
594 1
595 1 #if OS_EVENT_TBL_SIZE > 7
*ptbl = 0x00;
#endif
598 1 }
599 #endif
600 /*$PAGE*/
601 /*
602 *********************************************************************************************************
C51 COMPILER V6.23a OS_CORE 12/09/2004 16:50:24 PAGE 11
603 * INITIALIZATION
604 * INITIALIZE THE FREE LIST OF EVENT CONTROL BLOCKS
605 *
606 * Description: This function is called by OSInit() to initialize the free list of event control blocks.
607 *
608 * Arguments : none
609 *
610 * Returns : none
611 *********************************************************************************************************
612 */
613
614 static void OS_InitEventList (void) KCREENTRANT
615 {
616 1 #if (OS_EVENT_EN > 0) && (OS_MAX_EVENTS > 0)
617 1 #if (OS_MAX_EVENTS > 1)
618 1 INT16U i;
619 1 OS_EVENT *pevent1;
620 1 OS_EVENT *pevent2;
621 1
622 1
623 1 pevent1 = &OSEventTbl[0];
624 1 pevent2 = &OSEventTbl[1];
625 1 for (i = 0; i < (OS_MAX_EVENTS - 1); i++) { /* Init. list of free EVENT control block
-s */
626 2 pevent1->OSEventType = OS_EVENT_TYPE_UNUSED;
627 2 pevent1->OSEventPtr = pevent2;
628 2 pevent1++;
629 2 pevent2++;
630 2 }
631 1 pevent1->OSEventType = OS_EVENT_TYPE_UNUSED;
632 1 pevent1->OSEventPtr = (OS_EVENT *)0;
633 1 OSEventFreeList = &OSEventTbl[0];
634 1 #else
OSEventFreeList = &OSEventTbl[0]; /* Only have ONE event control block
- */
OSEventFreeList->OSEventType = OS_EVENT_TYPE_UNUSED;
OSEventFreeList->OSEventPtr = (OS_EVENT *)0;
#endif
639 1 #endif
640 1 }
641 /*$PAGE*/
642 /*
643 *********************************************************************************************************
644 * INITIALIZATION
645 * INITIALIZE MISCELLANEOUS VARIABLES
646 *
647 * Description: This function is called by OSInit() to initialize miscellaneous variables.
648 *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -