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

📄 os_core.lst

📁 51单片机嵌入ucos实例.通过此模块可以对其它型号的51系列单片机进行移值
💻 LST
📖 第 1 页 / 共 4 页
字号:
 177          {
 178   1          if ((pevent->OSEventTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0) {
 179   2              pevent->OSEventGrp &= ~OSTCBCur->OSTCBBitY;
 180   2          }
 181   1          OSTCBCur->OSTCBStat     = OS_STAT_RDY;       /* Set status to ready                                */
 182   1          OSTCBCur->OSTCBEventPtr = (OS_EVENT DT_XDATA *)0;     /* No longer waiting for event                  
             -      */
 183   1      }
 184          #endif
 185          /*$PAGE*/
 186          /*
 187          *********************************************************************************************************
 188          *                                 INITIALIZE EVENT CONTROL BLOCK'S WAIT LIST
 189          *
 190          * Description: This function is called by other uC/OS-II services to initialize the event wait list.
 191          *
 192          * Arguments  : pevent    is a pointer to the event control block allocated to the event.
 193          *
 194          * Returns    : none
 195          *
 196          * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 197          *********************************************************************************************************
 198          */
 199          #if  (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_SEM_EN
 200          void  OSEventWaitListInit (OS_EVENT DT_XDATA * pevent) REENTRANT
 201          {
 202   1          INT8U i;
 203   1          
 204   1          
 205   1          pevent->OSEventGrp = 0x00;                   /* No task waiting on event                           */
 206   1          for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
 207   2              pevent->OSEventTbl[i] = 0x00;
 208   2          }
 209   1      }
 210          #endif
 211          /*$PAGE*/
 212          /*
 213          *********************************************************************************************************
 214          *                                             INITIALIZATION
 215          *
 216          * Description: This function is used to initialize the internals of uC/OS-II and MUST be called prior to
 217          *              creating any uC/OS-II object and, prior to calling OSStart().
 218          *
 219          * Arguments  : none
 220          *
 221          * Returns    : none
 222          *********************************************************************************************************
 223          */
 224          
 225          void OSInit (void) REENTRANT
 226          {
 227   1          INT16U i;
 228   1      
 229   1      
 230   1          OSTime        = 0L;                                    /* Clear the 32-bit system clock            */
 231   1          OSIntNesting  = 0;                                     /* Clear the interrupt nesting counter      */
 232   1          OSLockNesting = 0;                                     /* Clear the scheduling lock counter        */
 233   1      
C51 COMPILER V7.06   OS_CORE                                                               07/30/2008 11:19:14 PAGE 5   

 234   1              /* counters */
 235   1      #if OS_TASK_CREATE_EN  || OS_TASK_CREATE_EXT_EN || OS_TASK_DEL_EN
 236   1          OSTaskCtr     = 0;                                     /* Clear the number of tasks                */
 237   1      #endif
 238   1          OSRunning     = FALSE;                                 /* Indicate that multitasking not started   */
 239   1          OSIdleCtr     = 0L;                                    /* Clear the 32-bit idle counter            */
 240   1      #if OS_TASK_STAT_EN && OS_TASK_CREATE_EXT_EN                            
                  OSIdleCtrRun  = 0L;                                                                         /* current counter used for static */
                  OSIdleCtrMax  = 0L;                                                                         /* Max currrent used for statice */
                  OSStatRdy     = FALSE;                                 /* Statistic task is not ready              */
              #endif
 245   1          OSCtxSwCtr    = 0;                                     /* Clear the context switch counter         */
 246   1      
 247   1              /* read list, OS_RDY_TBL_SIZE = ((OS_LOWEST_PRIO) / 8 + 1) */
 248   1          OSRdyGrp      = 0;                                     /* Clear the ready list                     */
 249   1          for (i = 0; i < OS_RDY_TBL_SIZE; i++) {
 250   2              OSRdyTbl[i] = 0;
 251   2          }
 252   1          
 253   1          /* tcbs */
 254   1          OSPrioCur     = 0;
 255   1          OSPrioHighRdy = 0;                                           
 256   1          OSTCBHighRdy  = (OS_TCB DT_XDATA *)0;                                 /* TCB Initialization           
             -      */
 257   1          OSTCBCur      = (OS_TCB DT_XDATA *)0;
 258   1          OSTCBList     = (OS_TCB DT_XDATA *)0;                                                       /* TCB list. Note it isn't free tcb list */
 259   1      
 260   1              /* clear OSTCBPrioTbl */
 261   1          for (i = 0; i < (OS_LOWEST_PRIO + 1); i++) {                 /* Clear the priority table           */
 262   2              OSTCBPrioTbl[i] = (OS_TCB DT_XDATA *)0;
 263   2          }
 264   1      
 265   1              /* Init. list of free TCBs. OSTCBTbl is TCB list defined in OS_Core.c. OS_N_SYS_TASKS is system task nmbe
             -r.*/
 266   1          //20个任务+1个IDLE任务+(1个统计任务--可选)共需21个,总一个元素的NEXT等于下一下元素的地址
 267   1              for (i = 0; i < (OS_MAX_TASKS + OS_N_SYS_TASKS - 1); i++) 
 268   1              {  /* Init. list of free TCBs            */
 269   2              OSTCBTbl[i].OSTCBNext = &OSTCBTbl[i + 1];
 270   2          }
 271   1              //最后一个任务的NEXT为NULL空,OSTCBFreeList初始化为第一个数组元素的地址
 272   1          OSTCBTbl[OS_MAX_TASKS + OS_N_SYS_TASKS - 1].OSTCBNext = (OS_TCB DT_XDATA *)0;    /* Last OS_TCB       
             -      */
 273   1          OSTCBFreeList                                         = &OSTCBTbl[0];
 274   1      
 275   1              /* Init. list of free EVENT control blocks  */
 276   1      #if OS_MAX_EVENTS >= 2
 277   1          for (i = 0; i < (OS_MAX_EVENTS - 1); i++) {            
 278   2              OSEventTbl[i].OSEventPtr = (OS_EVENT DT_XDATA *)&OSEventTbl[i + 1];
 279   2          }
 280   1          OSEventTbl[OS_MAX_EVENTS - 1].OSEventPtr = (OS_EVENT DT_XDATA *)0;
 281   1          OSEventFreeList                          = &OSEventTbl[0];    
 282   1      #endif
 283   1      
 284   1              /* Initialize the message queue structures  */
 285   1      #if OS_Q_EN && (OS_MAX_QS >= 2)
                  OSQInit();                                             
              #endif
 288   1      
 289   1              /* Initialize the memory manager            */
 290   1      #if OS_MEM_EN && OS_MAX_MEM_PART >= 2
                  OSMemInit();                                           
              #endif    
C51 COMPILER V7.06   OS_CORE                                                               07/30/2008 11:19:14 PAGE 6   

 293   1      
 294   1              /* creat OSTaskIdle task */
 295   1      #if OS_STK_GROWTH == 1
                  #if OS_TASK_CREATE_EXT_EN
                  OSTaskCreateExt(OSTaskIdle, 
                                  (void DT_XDATA *)0,                                 /* No arguments passed to OSTaskId
             -le()  */
                                  &OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE - 1], /* Set Top-Of-Stack                     */
                                  OS_IDLE_PRIO,                              /* Lowest priority level                */
                                  OS_TASK_IDLE_ID,
                                  &OSTaskIdleStk[0],                         /* Set Bottom-Of-Stack                  */
                                  OS_TASK_IDLE_STK_SIZE, 
                                  (void DT_XDATA *)0,                                 /* No TCB extension               
             -      */
                                  OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);/* Enable stack checking + clear stack  */
                  #else
                  OSTaskCreate(OSTaskIdle, (void DT_XDATA *)0, &OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE - 1], OS_IDLE_PRIO);
             -        /* OS_IDLE _PROIO == OS_LOWEST_PROIO */
                  #endif
              #else
 310   1          #if OS_TASK_CREATE_EXT_EN
                  OSTaskCreateExt(OSTaskIdle, 
                                  (void DT_XDATA *)0,                                 /* No arguments passed to OSTaskId
             -le()  */
                                  &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 DT_XDATA *)0,                                 /* No TCB extension               
             -      */
                                  OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);/* Enable stack checking + clear stack  */
                  #else
 321   1          OSTaskCreate(OSTaskIdle, (void DT_XDATA *)0, &OSTaskIdleStk[0], OS_IDLE_PRIO);
 322   1          #endif
 323   1      #endif
 324   1      
 325   1      #if OS_TASK_STAT_EN 
                  #if OS_TASK_CREATE_EXT_EN
                      #if OS_STK_GROWTH == 1
                      OSTaskCreateExt(OSTaskStat, 
                                      (void DT_XDATA *)0,                                /* No args passed to OSTaskStat
             -()    */
                                      &OSTaskStatStk[OS_TASK_STAT_STK_SIZE - 1],/* Set Top-Of-Stack                  */
                                      OS_STAT_PRIO,                             /* One higher than the idle task     */
                                      OS_TASK_STAT_ID,
                                      &OSTaskStatStk[0],                        /* Set Bottom-Of-Stack               */
                                      OS_TASK_STAT_STK_SIZE, 
                                      (void DT_XDATA *)0,                                /* No TCB extension            
             -      */
                                      OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);  /* Enable stack checking + clear  */
                      #else
                      OSTaskCreateExt(OSTaskStat, 
                                      (void DT_XDATA *)0,                                /* No args passed to OSTaskStat
             -()    */
                                      &OSTaskStatStk[0],                        /* Set Top-Of-Stack                  */
                                      OS_STAT_PRIO,                             /* One higher than the idle task     */
                                      OS_TASK_STAT_ID,
                                      &OSTaskStatStk[OS_TASK_STAT_STK_SIZE - 1],/* Set Bottom-Of-Stack               */
                                      OS_TASK_STAT_STK_SIZE, 
                                      (void DT_XDATA *)0,                                /* No TCB extension            
             -      */
C51 COMPILER V7.06   OS_CORE                                                               07/30/2008 11:19:14 PAGE 7   

                                      OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);  /* Enable stack checking + clear  */
                      #endif
                  #else
                      #if OS_STK_GROWTH == 1
                      OSTaskCreate(OSTaskStat, 
                                   (void DT_XDATA *)0,                                   /* No args passed to OSTaskStat
             -()    */
                                   &OSTaskStatStk[OS_TASK_STAT_STK_SIZE - 1],   /* Set Top-Of-Stack                  */
                                   OS_STAT_PRIO);                               /* One higher than the idle task     */
                      #else

⌨️ 快捷键说明

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