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