⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_core.lst

📁 在51上运行的小的OS系统
💻 LST
📖 第 1 页 / 共 5 页
字号:
 810          * Returns    : none
 811          *********************************************************************************************************
 812          */
 813          
 814          static  void  OS_InitEventList (void)
 815          {
 816          #if OS_EVENT_EN && (OS_MAX_EVENTS > 0)
 817          #if (OS_MAX_EVENTS > 1)
 818              INT16U     i;
 819              OS_EVENT  *pevent1;
 820              OS_EVENT  *pevent2;
 821          
 822          
 823              OS_MemClr((INT8U *)&OSEventTbl[0], sizeof(OSEventTbl)); /* Clear the event table                   */
 824              pevent1 = &OSEventTbl[0];
 825              pevent2 = &OSEventTbl[1];
 826              for (i = 0; i < (OS_MAX_EVENTS - 1); i++) {             /* Init. list of free EVENT control blocks */
 827                  pevent1->OSEventType    = OS_EVENT_TYPE_UNUSED;
 828                  pevent1->OSEventPtr     = pevent2;
 829          #if OS_EVENT_NAME_SIZE > 1
 830                  pevent1->OSEventName[0] = '?';                      /* Unknown name                            */
 831                  pevent1->OSEventName[1] = OS_ASCII_NUL;
 832          #endif
 833                  pevent1++;
C51 COMPILER V8.08   OS_CORE                                                               08/04/2008 21:49:51 PAGE 16  

 834                  pevent2++;
 835              }
 836              pevent1->OSEventType            = OS_EVENT_TYPE_UNUSED;
 837              pevent1->OSEventPtr             = (OS_EVENT *)0;
 838          #if OS_EVENT_NAME_SIZE > 1
 839              pevent1->OSEventName[0]         = '?';
 840              pevent1->OSEventName[1]         = OS_ASCII_NUL;
 841          #endif
 842              OSEventFreeList                 = &OSEventTbl[0];
 843          #else
                  OSEventFreeList                 = &OSEventTbl[0];       /* Only have ONE event control block       */
                  OSEventFreeList->OSEventType    = OS_EVENT_TYPE_UNUSED;
                  OSEventFreeList->OSEventPtr     = (OS_EVENT *)0;
              #if OS_EVENT_NAME_SIZE > 1
                  OSEventFreeList->OSEventName[0] = '?';                  /* Unknown name                            */
                  OSEventFreeList->OSEventName[1] = OS_ASCII_NUL;
              #endif
              #endif
 852          #endif
 853          }
 854          /*$PAGE*/
 855          /*
 856          *********************************************************************************************************
 857          *                                             INITIALIZATION
 858          *                                    INITIALIZE MISCELLANEOUS VARIABLES
 859          *
 860          * Description: This function is called by OSInit() to initialize miscellaneous variables.
 861          *
 862          * Arguments  : none
 863          *
 864          * Returns    : none
 865          *********************************************************************************************************
 866          */
 867          
 868          static  void  OS_InitMisc (void)
 869          {
 870          #if OS_TIME_GET_SET_EN > 0
 871              OSTime        = 0L;                                    /* Clear the 32-bit system clock            */
 872          #endif
 873          
 874              OSIntNesting  = 0;                                     /* Clear the interrupt nesting counter      */
 875              OSLockNesting = 0;                                     /* Clear the scheduling lock counter        */
 876          
 877              OSTaskCtr     = 0;                                     /* Clear the number of tasks                */
 878          
 879              OSRunning     = FALSE;                                 /* Indicate that multitasking not started   */
 880          
 881              OSCtxSwCtr    = 0;                                     /* Clear the context switch counter         */
 882              OSIdleCtr     = 0L;                                    /* Clear the 32-bit idle counter            */
 883          
 884          #if OS_TASK_STAT_EN > 0
 885              OSIdleCtrRun  = 0L;
 886              OSIdleCtrMax  = 0L;
 887              OSStatRdy     = FALSE;                                 /* Statistic task is not ready              */
 888          #endif
 889          }
 890          /*$PAGE*/
 891          /*
 892          *********************************************************************************************************
 893          *                                             INITIALIZATION
 894          *                                       INITIALIZE THE READY LIST
 895          *
C51 COMPILER V8.08   OS_CORE                                                               08/04/2008 21:49:51 PAGE 17  

 896          * Description: This function is called by OSInit() to initialize the Ready List.
 897          *
 898          * Arguments  : none
 899          *
 900          * Returns    : none
 901          *********************************************************************************************************
 902          */
 903          
 904          static  void  OS_InitRdyList (void)
 905          {
 906              INT8U    i;
 907          #if OS_LOWEST_PRIO <= 63
 908              INT8U   *prdytbl;
 909          #else
                  INT16U  *prdytbl;
              #endif
 912          
 913          
 914              OSRdyGrp      = 0;                                     /* Clear the ready list                     */
 915              prdytbl       = &OSRdyTbl[0];
 916              for (i = 0; i < OS_RDY_TBL_SIZE; i++) {
 917                  *prdytbl++ = 0;
 918              }
 919          
 920              OSPrioCur     = 0;
 921              OSPrioHighRdy = 0;
 922          
 923              OSTCBHighRdy  = (OS_TCB *)0;
 924              OSTCBCur      = (OS_TCB *)0;
 925          }
 926          
 927          /*$PAGE*/
 928          /*
 929          *********************************************************************************************************
 930          *                                             INITIALIZATION
 931          *                                         CREATING THE IDLE TASK
 932          *
 933          * Description: This function creates the Idle Task.
 934          *
 935          * Arguments  : none
 936          *
 937          * Returns    : none
 938          *********************************************************************************************************
 939          */
 940          
 941          static  void  OS_InitTaskIdle (void)
 942          {
 943          #if OS_TASK_NAME_SIZE > 14
 944              INT8U  err;
 945          #endif
 946          
 947          
 948          #if OS_TASK_CREATE_EXT_EN > 0
 949              #if OS_STK_GROWTH == 1
 950              (void)OSTaskCreateExt(OS_TaskIdle,
 951                                    (void *)0,                                 /* No arguments passed to OS_TaskIdle
             -() */
 952                                    &OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE - 1], /* Set Top-Of-Stack                  
             -   */
 953                                    OS_IDLE_PRIO,                              /* Lowest priority level             
             -   */
 954                                    OS_TASK_IDLE_ID,
C51 COMPILER V8.08   OS_CORE                                                               08/04/2008 21:49:51 PAGE 18  

 955                                    &OSTaskIdleStk[0],                         /* Set Bottom-Of-Stack               
             -   */
 956                                    OS_TASK_IDLE_STK_SIZE,
 957                                    (void *)0,                                 /* No TCB extension                  
             -   */
 958                                    OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);/* Enable stack checking + clear stac
             -k  */
 959              #else
                  (void)OSTaskCreateExt(OS_TaskIdle,
                                        (void *)0,                                 /* No arguments passed to OS_TaskIdle
             -() */
                                        &OSTaskIdleStk[0],                         /* Set Top-Of-Stack                  
             -   */
                                        OS_IDLE_PRIO,                              /* Lowest priority level             
             -   */
                                        OS_TASK_IDLE_ID,
                                        &OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE - 1], /* Set Bottom-Of-Stack               
             -   */
                                        OS_TASK_IDLE_STK_SIZE,
                                        (void *)0,                                 /* No TCB extension                  
             -   */
                                        OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);/* Enable stack checking + clear stac
             -k  */
                  #endif
 970          #else
                  #if OS_STK_GROWTH == 1
                  (void)OSTaskCreate(OS_TaskIdle,
                                     (void *)0,
                                     &OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE - 1],
                                     OS_IDLE_PRIO);
                  #else
                  (void)OSTaskCreate(OS_TaskIdle,
                                     (void *)0,
                                     &OSTaskIdleStk[0],
                                     OS_IDLE_PRIO);
                  #endif
              #endif
 983          
 984          #if OS_TASK_NAME_SIZE > 14
 985              OSTaskNameSet(OS_IDLE_PRIO, (INT8U *)"uC/OS-II Idle", &err);
 986          #endif
 987          }
 988          /*$PAGE*/
 989          /*
 990          *********************************************************************************************************
 991          *                                             INITIALIZATION
 992          *                                      CREATING THE STATISTIC TASK
 993          *
 994          * Description: This function creates the Statistic Task.
 995          *
 996          * Arguments  : none
 997          *
 998          * Returns    : none
 999          *********************************************************************************************************
1000          */
1001          
1002          #if OS_TASK_STAT_EN > 0
1003          static  void  OS_InitTaskStat (void)
1004          {
1005          #if OS_TASK_NAME_SIZE > 14
1006              INT8U  err;
1007          #endif
C51 COMPILER V8.08   OS_CORE                                                               08/04/2008 21:49:51 PAGE 19  

1008          
1009          
1010          #if OS_TASK_CREATE_EXT_EN > 0
1011              #if OS_STK_GROWTH == 1
1012              (void)OSTaskCreateExt(OS_TaskStat,
1013                                    (void *)0,                                   /* No args passed to OS_TaskStat()*
             -/
1014                                    &OSTaskStatStk[OS_TASK_STAT_STK_SIZE - 1],   /* Set Top-Of-Stack               *
             -/
1015                                    OS_STAT_PRIO,                                /* One higher than the idle task  *
             -/
1016                                    OS_TASK_STAT_ID,
1017                                    &OSTaskStatStk[0],                           /*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -