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

📄 os_mbox.lst

📁 IAR project for MSP430 and uC/OS. All configured to start filling with tasks.
💻 LST
📖 第 1 页 / 共 5 页
字号:
    346          /*
    347          *********************************************************************************************************
    348          *                                       POST MESSAGE TO A MAILBOX
    349          *
    350          * Description: This function sends a message to a mailbox
    351          *
    352          * Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
    353          *
    354          *              msg           is a pointer to the message to send.  You MUST NOT send a NULL pointer.
    355          *
    356          *              opt           determines the type of POST performed:
    357          *                            OS_POST_OPT_NONE         POST to a single waiting task 
    358          *                                                     (Identical to OSMboxPost())
    359          *                            OS_POST_OPT_BROADCAST    POST to ALL tasks that are waiting on the mailbox
    360          *
    361          * Returns    : OS_NO_ERR            The call was successful and the message was sent
    362          *              OS_MBOX_FULL         If the mailbox already contains a message.  You can can only send one
    363          *                                   message at a time and thus, the message MUST be consumed before you
    364          *                                   are allowed to send another one.
    365          *              OS_ERR_EVENT_TYPE    If you are attempting to post to a non mailbox.
    366          *              OS_ERR_PEVENT_NULL   If 'pevent' is a NULL pointer
    367          *              OS_ERR_POST_NULL_PTR If you are attempting to post a NULL pointer
    368          *
    369          * Warning    : Interrupts can be disabled for a long time if you do a 'broadcast'.  In fact, the 
    370          *              interrupt disable time is proportional to the number of tasks waiting on the mailbox.
    371          *********************************************************************************************************
    372          */
    373          
    374          #if OS_MBOX_POST_OPT_EN > 0
    375          INT8U  OSMboxPostOpt (OS_EVENT *pevent, void *msg, INT8U opt)
    376          {
   \   0210  0A12              PUSH    R10     
   \   0212  0B12              PUSH    R11     
   \   0214  0B4C              MOV     R12,R11 
   \   0216  0A4E              MOV     R14,R10 
    377          #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    378              OS_CPU_SR  cpu_sr;
    379          #endif    
    380              
    381              
    382          #if OS_ARG_CHK_EN > 0
    383              if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
   \   0218  0B93              CMP     #0,R11  
   \   021A  0220              JNE     (?0112) 
    384                  return (OS_ERR_PEVENT_NULL);
   \   021C  6C42              MOV.B   #4,R12  
    385              }
   \   021E  2F3C              JMP     (?0127) 
   \   0220            ?0112:
    386              if (msg == (void *)0) {                           /* Make sure we are not posting a NULL pointer   */
   \   0220  0A93              CMP     #0,R10  
   \   0222  0320              JNE     (?0114) 
    387                  return (OS_ERR_POST_NULL_PTR);
   \   0224  7C400300          MOV.B   #3,R12  
    388              }
   \   0228  2A3C              JMP     (?0127) 
   \   022A            ?0114:
    389              if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type                     */
   \   022A  5C43              MOV.B   #1,R12  
   \   022C  6C9B              CMP.B   @R11,R12        
   \   022E  2720              JNE     (?0127) 
    390                  return (OS_ERR_EVENT_TYPE);
    391              }
    392          #endif
    393              OS_ENTER_CRITICAL();
   \   0230  32C2              DINT            
    394              if (pevent->OSEventGrp != 0x00) {                 /* See if any task pending on mailbox            */
   \   0232  CB930100          CMP.B   #0,1(R11)       
   \   0236  1824              JEQ     (?0118) 
    395                  if ((opt & OS_POST_OPT_BROADCAST) != 0x00) {  /* Do we need to post msg to ALL waiting tasks ? */
   \   0238  D1B30600          BIT.B   #1,6(SP)        
   \   023C  0A24              JEQ     (?0120) 
   \   023E            ?0119:
    396                      while (pevent->OSEventGrp != 0x00) {      /* Yes, Post to ALL tasks waiting on mailbox     */           
   \   023E  CB930100          CMP.B   #0,1(R11)       
   \   0242  0D24              JEQ     (?0124) 
    397                          OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);    
   \   0244  6312              PUSH.B  #2      
   \   0246  0E4A              MOV     R10,R14 
   \   0248  0C4B              MOV     R11,R12 
   \   024A  B0120000          CALL    #OS_EventTaskRdy        
   \   024E  2153              ADD     #2,SP   
    398                      }
    399                  } else {
   \   0250  F63F              JMP     (?0119) 
   \   0252            ?0120:
    400                      OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);    /* No,  Post to HPT waiting on mbox         */
   \   0252  6312              PUSH.B  #2      
   \   0254  0E4A              MOV     R10,R14 
   \   0256  0C4B              MOV     R11,R12 
   \   0258  B0120000          CALL    #OS_EventTaskRdy        
   \   025C  2153              ADD     #2,SP   
   \   025E            ?0124:
    401                  }
    402                  OS_EXIT_CRITICAL();
   \   025E  32D2              EINT            
    403                  OS_Sched();                                        /* Find highest priority task ready to run  */
   \   0260  B0120000          CALL    #OS_Sched       
    404                  return (OS_NO_ERR);
   \   0264  4C43              MOV.B   #0,R12  
    405              }
   \   0266  0B3C              JMP     (?0127) 
   \   0268            ?0118:
    406              if (pevent->OSEventPtr != (void *)0) {            /* Make sure mailbox doesn't already have a msg  */
   \   0268  8B930400          CMP     #0,4(R11)       
   \   026C  0424              JEQ     (?0126) 
    407                  OS_EXIT_CRITICAL();
   \   026E  32D2              EINT            
    408                  return (OS_MBOX_FULL);
   \   0270  7C401400          MOV.B   #20,R12 
    409              }
   \   0274  043C              JMP     (?0127) 
   \   0276            ?0126:
    410              pevent->OSEventPtr = msg;                         /* Place message in mailbox                      */
   \   0276  8B4A0400          MOV     R10,4(R11)      
    411              OS_EXIT_CRITICAL();
   \   027A  32D2              EINT            
    412              return (OS_NO_ERR);
   \   027C  4C43              MOV.B   #0,R12  
    413          }
   \   027E            ?0127:
   \   027E  3B41              POP     R11     
   \   0280  3A41              POP     R10     
   \   0282  3041              RET             
   \   0284            OSMboxQuery:
    414          #endif
    415          
    416          /*$PAGE*/
    417          /*
    418          *********************************************************************************************************
    419          *                                        QUERY A MESSAGE MAILBOX
    420          *
    421          * Description: This function obtains information about a message mailbox.
    422          *
    423          * Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
    424          *
    425          *              pdata         is a pointer to a structure that will contain information about the message
    426          *                            mailbox.
    427          *
    428          * Returns    : OS_NO_ERR           The call was successful and the message was sent
    429          *              OS_ERR_EVENT_TYPE   If you are attempting to obtain data from a non mailbox.
    430          *              OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
    431          *********************************************************************************************************
    432          */
    433          
    434          #if OS_MBOX_QUERY_EN > 0
    435          INT8U  OSMboxQuery (OS_EVENT *pevent, OS_MBOX_DATA *pdata)
    436          {
    437          #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
    438              OS_CPU_SR  cpu_sr;
    439          #endif    
    440              INT8U     *psrc;
    441              INT8U     *pdest;
    442          
    443          
    444          #if OS_ARG_CHK_EN > 0
    445              if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
   \   0284  0C93              CMP     #0,R12  
   \   0286  0220              JNE     (?0129) 
    446                  return (OS_ERR_PEVENT_NULL);
   \   0288  6C42              MOV.B   #4,R12  
    447              }
   \   028A  3041              RET             
   \   028C            ?0129:
    448              if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {       /* Validate event block type                */
   \   028C  5D43              MOV.B   #1,R13  
   \   028E  6D9C              CMP.B   @R12,R13        
   \   0290  0224              JEQ     (?0131) 
    449                  return (OS_ERR_EVENT_TYPE);
   \   0292  5C43              MOV.B   #1,R12  
    450              }
   \   0294  3041              RET             
   \   0296            ?0131:
    451          #endif
    452              OS_ENTER_CRITICAL();
   \   0296  32C2              DINT            
    453              pdata->OSEventGrp = pevent->OSEventGrp;                /* Copy message mailbox wait list           */
   \   0298  DE4C0100          MOV.B   1(R12),4(R14)   
   \   029C  0400
    454              psrc              = &pevent->OSEventTbl[0];
   \   029E  0F4C              MOV     R12,R15 
   \   02A0  3F500600          ADD     #6,R15  
    455              pdest             = &pdata->OSEventTbl[0];
   \   02A4  0D4E              MOV     R14,R13 
   \   02A6  2D53              ADD     #2,R13  
    456          
    457          #if OS_EVENT_TBL_SIZE > 0
    458              *pdest++          = *psrc++;
   \   02A8  FD4F0000          MOV.B   @R15+,0(R13)    
   \   02AC  1D53              ADD     #1,R13  
    459          #endif
    460          
    461          #if OS_EVENT_TBL_SIZE > 1
    462              *pdest++          = *psrc++;
   \   02AE  FD4F0000          MOV.B   @R15+,0(R13)    
    463          #endif
    464          
    465          #if OS_EVENT_TBL_SIZE > 2
    466              *pdest++          = *psrc++;
    467          #endif
    468          
    469          #if OS_EVENT_TBL_SIZE > 3
    470              *pdest++          = *psrc++;
    471          #endif
    472          
    473          #if OS_EVENT_TBL_SIZE > 4
    474              *pdest++          = *psrc++;
    475          #endif
    476          
    477          #if OS_EVENT_TBL_SIZE > 5
    478              *pdest++          = *psrc++;
    479          #endif

⌨️ 快捷键说明

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