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

📄 ucos_ii.lst

📁 UCOSII源码,三星4510下面的uCOSII源码.
💻 LST
📖 第 1 页 / 共 5 页
字号:
   8      =1  *                                           All Rights Reserved
   9      =1  *
  10      =1  *                                                  V2.00
  11      =1  *
  12      =1  * File : OS_CORE.C
  13      =1  * By   : Jean J. Labrosse
  14      =1  *********************************************************************************************************
  15      =1  */
  16      =1  
  17      =1  #ifndef  OS_MASTER_FILE
           =1 #define  OS_GLOBALS
           =1 #include "includes.h"
           =1 #endif
  21      =1  
  22      =1  /*
  23      =1  *********************************************************************************************************
  24      =1  *                                         LOCAL GLOBAL VARIABLES
  25      =1  *********************************************************************************************************
  26      =1  */
  27      =1                                         
  28      =1  static  INT8U        OSIntExitY;               /* Variable used by 'OSIntExit' to prevent using locals */
  29      =1  
  30      =1  static  OS_STK       OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE];       /* Idle       task stack              */
  31      =1  
  32      =1  #if     OS_TASK_STAT_EN
           =1 static  OS_STK       OSTaskStatStk[OS_TASK_STAT_STK_SIZE];      /* Statistics task stack               */
           =1 #endif
  35      =1  
  36      =1  static  OS_TCB       OSTCBTbl[OS_MAX_TASKS + OS_N_SYS_TASKS];   /* Table of TCBs                       */
  37      =1  
  38      =1  /*$PAGE*/
  39      =1  /*
  40      =1  *********************************************************************************************************
  41      =1  *                              MAPPING TABLE TO MAP BIT POSITION TO BIT MASK
  42      =1  *
  43      =1  * Note: Index into table is desired bit position, 0..7
  44      =1  *       Indexed value corresponds to bit mask
  45      =1  *********************************************************************************************************
  46      =1  */
  47      =1  
  48      =1  INT8U const OSMapTbl[]   = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
  49      =1  
  50      =1  /*
  51      =1  *********************************************************************************************************
  52      =1  *                                       PRIORITY RESOLUTION TABLE
  53      =1  *
  54      =1  * Note: Index into table is bit pattern to resolve highest priority
  55      =1  *       Indexed value corresponds to highest priority bit position (i.e. 0..7)
  56      =1  *********************************************************************************************************
  57      =1  */
  58      =1  
  59      =1  INT8U const OSUnMapTbl[] = {
  60      =1      0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  61      =1      4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  62      =1      5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  63      =1      4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
C51 COMPILER V7.50   UCOS_II                                                               03/31/2006 10:11:11 PAGE 16  

  64      =1      6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  65      =1      4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  66      =1      5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  67      =1      4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  68      =1      7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  69      =1      4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  70      =1      5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  71      =1      4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  72      =1      6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  73      =1      4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  74      =1      5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
  75      =1      4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
  76      =1  };
  77      =1  
  78      =1  /*$PAGE*/
  79      =1  /*
  80      =1  *********************************************************************************************************
  81      =1  *                             MAKE TASK READY TO RUN BASED ON EVENT OCCURING
  82      =1  *
  83      =1  * Description: This function is called by other uC/OS-II services and is used to ready a task that was
  84      =1  *              waiting for an event to occur.
  85      =1  *
  86      =1  * Arguments  : pevent    is a pointer to the event control block corresponding to the event.
  87      =1  *
  88      =1  *              msg       is a pointer to a message.  This pointer is used by message oriented services
  89      =1  *                        such as MAILBOXEs and QUEUEs.  The pointer is not used when called by other
  90      =1  *                        service functions.
  91      =1  *
  92      =1  *              msk       is a mask that is used to clear the status byte of the TCB.  For example,
  93      =1  *                        OSSemPost() will pass OS_STAT_SEM, OSMboxPost() will pass OS_STAT_MBOX etc.
  94      =1  *
  95      =1  * Returns    : none
  96      =1  *
  97      =1  * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
  98      =1  *********************************************************************************************************
  99      =1  */
 100      =1  #if  (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_SEM_EN
 101      =1  void  OSEventTaskRdy (OS_EVENT *pevent, void *msg, INT8U msk) reentrant
 102      =1  {
 103   1  =1      OS_TCB *ptcb;
 104   1  =1      INT8U   x;
 105   1  =1      INT8U   y;
 106   1  =1      INT8U   bitx;
 107   1  =1      INT8U   bity;
 108   1  =1      INT8U   prio;
 109   1  =1  
 110   1  =1  
 111   1  =1      y    = OSUnMapTbl[pevent->OSEventGrp];            /* Find highest prio. task waiting for message   */
 112   1  =1      bity = OSMapTbl[y];
 113   1  =1      x    = OSUnMapTbl[pevent->OSEventTbl[y]];
 114   1  =1      bitx = OSMapTbl[x];
 115   1  =1      prio = (INT8U)((y << 3) + x);                     /* Find priority of task getting the msg         */
 116   1  =1      if ((pevent->OSEventTbl[y] &= ~bitx) == 0) {      /* Remove this task from the waiting list        */
 117   2  =1          pevent->OSEventGrp &= ~bity;
 118   2  =1      }
 119   1  =1      ptcb                 =  OSTCBPrioTbl[prio];       /* Point to this task's OS_TCB                   */
 120   1  =1      ptcb->OSTCBDly       =  0;                        /* Prevent OSTimeTick() from readying task       */
 121   1  =1      ptcb->OSTCBEventPtr  = (OS_EVENT *)0;             /* Unlink ECB from this task                     */
 122   1  =1  #if (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN
 123   1  =1      ptcb->OSTCBMsg       = msg;                       /* Send message directly to waiting task         */
 124   1  =1  #else
           =1     msg                  = msg;                       /* Prevent compiler warning if not used          */ 
C51 COMPILER V7.50   UCOS_II                                                               03/31/2006 10:11:11 PAGE 17  

             -   
           =1 #endif    
 127   1  =1      ptcb->OSTCBStat     &= ~msk;                      /* Clear bit associated with event type          */
 128   1  =1      if (ptcb->OSTCBStat == OS_STAT_RDY) {             /* See if task is ready (could be susp'd)        */
 129   2  =1          OSRdyGrp        |=  bity;                     /* Put task in the ready to run list             */
 130   2  =1          OSRdyTbl[y]     |=  bitx;
 131   2  =1      }
 132   1  =1  }
 133      =1  #endif
 134      =1  /*$PAGE*/
 135      =1  /*
 136      =1  *********************************************************************************************************
 137      =1  *                                   MAKE TASK WAIT FOR EVENT TO OCCUR
 138      =1  *
 139      =1  * Description: This function is called by other uC/OS-II services to suspend a task because an event has
 140      =1  *              not occurred.
 141      =1  *
 142      =1  * Arguments  : pevent   is a pointer to the event control block for which the task will be waiting for.
 143      =1  *
 144      =1  * Returns    : none
 145      =1  *
 146      =1  * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 147      =1  *********************************************************************************************************
 148      =1  */
 149      =1  #if  (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_SEM_EN
 150      =1  void  OSEventTaskWait (OS_EVENT *pevent) reentrant
 151      =1  {
 152   1  =1      OSTCBCur->OSTCBEventPtr = pevent;            /* Store pointer to event control block in TCB        */
 153   1  =1      if ((OSRdyTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0) {      /* Task no longer ready      */
 154   2  =1          OSRdyGrp &= ~OSTCBCur->OSTCBBitY;
 155   2  =1      }
 156   1  =1      pevent->OSEventTbl[OSTCBCur->OSTCBY] |= OSTCBCur->OSTCBBitX;          /* Put task in waiting list  */
 157   1  =1      pevent->OSEventGrp                   |= OSTCBCur->OSTCBBitY;
 158   1  =1  }
 159      =1  #endif
 160      =1  /*$PAGE*/
 161      =1  /*
 162      =1  *********************************************************************************************************
 163      =1  *                              MAKE TASK READY TO RUN BASED ON EVENT TIMEOUT
 164      =1  *
 165      =1  * Description: This function is called by other uC/OS-II services to make a task ready to run because a
 166      =1  *              timeout occurred.
 167      =1  *
 168      =1  * Arguments  : pevent   is a pointer to the event control block which is readying a task.
 169      =1  *
 170      =1  * Returns    : none
 171      =1  *
 172      =1  * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 173      =1  *********************************************************************************************************
 174      =1  */
 175      =1  #if  (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_SEM_EN
 176      =1  void  OSEventTO (OS_EVENT *pevent) reentrant
 177      =1  {
 178   1  =1      if ((pevent->OSEventTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0) {
 179   2  =1          pevent->OSEventGrp &= ~OSTCBCur->OSTCBBitY;
 180   2  =1      }
 181   1  =1      OSTCBCur->OSTCBStat     = OS_STAT_RDY;       /* Set status to ready                                */
 182   1  =1      OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0;     /* No longer waiting for event                        */
 183   1  =1  }
 184      =1  #endif
 185      =1  /*$PAGE*/
 186      =1  /*
C51 COMPILER V7.50   UCOS_II                                                               03/31/2006 10:11:11 PAGE 18  

 187      =1  *********************************************************************************************************
 188      =1  *                                 INITIALIZE EVENT CONTROL BLOCK'S WAIT LIST
 189      =1  *
 190      =1  * Description: This function is called by other uC/OS-II services to initialize the event wait list.
 191      =1  *
 192      =1  * Arguments  : pevent    is a pointer to the event control block allocated to the event.
 193      =1  *
 194      =1  * Returns    : none
 195      =1  *
 196      =1  * Note       : This function is INTERNAL to uC/OS-II and your application should not call it.
 197      =1  *********************************************************************************************************
 198      =1  */
 199      =1  #if  (OS_Q_EN && (OS_MAX_QS >= 2)) || OS_MBOX_EN || OS_SEM_EN
 200      =1  void  OSEventWaitListInit (OS_EVENT *pevent) reentrant
 201      =1  {
 202   1  =1      INT8U i;
 203   1  =1      
 204   1  =1      
 205   1  =1      pevent->OSEventGrp = 0x00;                   /* No task waiting on event                           */
 206   1  =1      for (i = 0; i < OS_EVENT_TBL_SIZE; i++) {
 207   2  =1          pevent->OSEventTbl[i] = 0x00;
 208   2  =1      }
 209   1  =1  }
 210      =1  #endif
 211      =1  /*$PAGE*/
 212      =1  /*
 213      =1  *********************************************************************************************************
 214      =1  *                                             INITIALIZATION
 215      =1  *
 216      =1  * Description: This function is used to initialize the internals of uC/OS-II and MUST be called prior to
 217      =1  *              creating any uC/OS-II object and, prior to calling OSStart().
 218      =1  *
 219      =1  * Arguments  : none
 220      =1  *
 221      =1  * Returns    : none
 222      =1  *********************************************************************************************************
 223      =1  */
 224      =1  
 2

⌨️ 快捷键说明

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