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

📄 os_mbox.lst

📁 uCOS 嵌入式操作系统的改进版,增加了网络通讯.
💻 LST
📖 第 1 页 / 共 3 页
字号:
 345   2          }
 346   1          if (pevent->OSEventPtr != (void *)0) {            /* Make sure mailbox doesn't already have a msg  */
 347   2              OS_EXIT_CRITICAL();
 348   2              return (OS_MBOX_FULL);
 349   2          }
 350   1          pevent->OSEventPtr = msg;                         /* Place message in mailbox                      */
 351   1          OS_EXIT_CRITICAL();
 352   1          return (OS_NO_ERR);
 353   1      }
 354          #endif
 355          
 356          /*$PAGE*/
 357          /*
 358          *********************************************************************************************************
 359          *                                       POST MESSAGE TO A MAILBOX
 360          *
 361          * Description: This function sends a message to a mailbox
 362          *
 363          * Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
 364          *
C51 COMPILER V7.06   OS_MBOX                                                               07/18/2003 11:05:58 PAGE 7   

 365          *              msg           is a pointer to the message to send.  You MUST NOT send a NULL pointer.
 366          *
 367          *              opt           determines the type of POST performed:
 368          *                            OS_POST_OPT_NONE         POST to a single waiting task 
 369          *                                                     (Identical to OSMboxPost())
 370          *                            OS_POST_OPT_BROADCAST    POST to ALL tasks that are waiting on the mailbox
 371          *
 372          * Returns    : OS_NO_ERR            The call was successful and the message was sent
 373          *              OS_MBOX_FULL         If the mailbox already contains a message.  You can can only send one
 374          *                                   message at a time and thus, the message MUST be consumed before you
 375          *                                   are allowed to send another one.
 376          *              OS_ERR_EVENT_TYPE    If you are attempting to post to a non mailbox.
 377          *              OS_ERR_PEVENT_NULL   If 'pevent' is a NULL pointer
 378          *              OS_ERR_POST_NULL_PTR If you are attempting to post a NULL pointer
 379          *
 380          * Warning    : Interrupts can be disabled for a long time if you do a 'broadcast'.  In fact, the 
 381          *              interrupt disable time is proportional to the number of tasks waiting on the mailbox.
 382          *********************************************************************************************************
 383          */
 384          
 385          #if OS_MBOX_POST_OPT_EN > 0
 386          INT8U  OSMboxPostOpt (OS_EVENT *pevent, void *msg, INT8U opt) reentrant //using 0
 387          {
 388   1      #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
 389   1          OS_CPU_SR  cpu_sr;
 390   1      #endif    
 391   1          
 392   1          
 393   1      #if OS_ARG_CHK_EN > 0
 394   1          if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
 395   2              return (OS_ERR_PEVENT_NULL);
 396   2          }
 397   1          if (msg == (void *)0) {                           /* Make sure we are not posting a NULL pointer   */
 398   2              return (OS_ERR_POST_NULL_PTR);
 399   2          }
 400   1      #endif
 401   1          if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type                     */
 402   2              return (OS_ERR_EVENT_TYPE);
 403   2          }
 404   1          OS_ENTER_CRITICAL();
 405   1          if (pevent->OSEventGrp != 0x00) {                 /* See if any task pending on mailbox            */
 406   2              if ((opt & OS_POST_OPT_BROADCAST) != 0x00) {  /* Do we need to post msg to ALL waiting tasks ? */
 407   3                  while (pevent->OSEventGrp != 0x00) {      /* Yes, Post to ALL tasks waiting on mailbox     */ 
             -          
 408   4                      OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);    
 409   4                  }
 410   3              } else {
 411   3                  OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);    /* No,  Post to HPT waiting on mbox         */
 412   3              }
 413   2              OS_EXIT_CRITICAL();
 414   2              OS_Sched();                                        /* Find highest priority task ready to run  */
 415   2              return (OS_NO_ERR);
 416   2          }
 417   1          if (pevent->OSEventPtr != (void *)0) {            /* Make sure mailbox doesn't already have a msg  */
 418   2              OS_EXIT_CRITICAL();
 419   2              return (OS_MBOX_FULL);
 420   2          }
 421   1          pevent->OSEventPtr = msg;                         /* Place message in mailbox                      */
 422   1          OS_EXIT_CRITICAL();
 423   1          return (OS_NO_ERR);
 424   1      }
 425          #endif
C51 COMPILER V7.06   OS_MBOX                                                               07/18/2003 11:05:58 PAGE 8   

 426          
 427          /*$PAGE*/
 428          /*
 429          *********************************************************************************************************
 430          *                                        QUERY A MESSAGE MAILBOX
 431          *
 432          * Description: This function obtains information about a message mailbox.
 433          *
 434          * Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
 435          *
 436          *              pdata         is a pointer to a structure that will contain information about the message
 437          *                            mailbox.
 438          *
 439          * Returns    : OS_NO_ERR           The call was successful and the message was sent
 440          *              OS_ERR_EVENT_TYPE   If you are attempting to obtain data from a non mailbox.
 441          *              OS_ERR_PEVENT_NULL  If 'pevent' is a NULL pointer
 442          *********************************************************************************************************
 443          */
 444          
 445          #if OS_MBOX_QUERY_EN > 0
 446          INT8U  OSMboxQuery (OS_EVENT *pevent, OS_MBOX_DATA *pndata) reentrant //using 0
 447          {
 448   1      #if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
 449   1          OS_CPU_SR  cpu_sr;
 450   1      #endif    
 451   1          INT8U     *psrc;
 452   1          INT8U     *pdest;
 453   1      
 454   1      
 455   1      #if OS_ARG_CHK_EN > 0
 456   1          if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
 457   2              return (OS_ERR_PEVENT_NULL);
 458   2          }
 459   1      #endif
 460   1          if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {       /* Validate event block type                */
 461   2              return (OS_ERR_EVENT_TYPE);
 462   2          }
 463   1          OS_ENTER_CRITICAL();
 464   1          pndata->OSEventGrp = pevent->OSEventGrp;                /* Copy message mailbox wait list           */
 465   1          psrc              = &pevent->OSEventTbl[0];
 466   1          pdest             = &pndata->OSEventTbl[0];
 467   1      
 468   1      #if OS_EVENT_TBL_SIZE > 0
 469   1          *pdest++          = *psrc++;
 470   1      #endif
 471   1      
 472   1      #if OS_EVENT_TBL_SIZE > 1
 473   1          *pdest++          = *psrc++;
 474   1      #endif
 475   1      
 476   1      #if OS_EVENT_TBL_SIZE > 2
 477   1          *pdest++          = *psrc++;
 478   1      #endif
 479   1      
 480   1      #if OS_EVENT_TBL_SIZE > 3
 481   1          *pdest++          = *psrc++;
 482   1      #endif
 483   1      
 484   1      #if OS_EVENT_TBL_SIZE > 4
 485   1          *pdest++          = *psrc++;
 486   1      #endif
 487   1      
C51 COMPILER V7.06   OS_MBOX                                                               07/18/2003 11:05:58 PAGE 9   

 488   1      #if OS_EVENT_TBL_SIZE > 5
 489   1          *pdest++          = *psrc++;
 490   1      #endif
 491   1      
 492   1      #if OS_EVENT_TBL_SIZE > 6
 493   1          *pdest++          = *psrc++;
 494   1      #endif
 495   1      
 496   1      #if OS_EVENT_TBL_SIZE > 7
 497   1          *pdest            = *psrc;
 498   1      #endif
 499   1          pndata->OSMsg = pevent->OSEventPtr;                     /* Get message from mailbox                 */
 500   1          OS_EXIT_CRITICAL();
 501   1          return (OS_NO_ERR);
 502   1      }
 503          #endif                                                     /* OS_MBOX_QUERY_EN                         */
 504          #endif                                                     /* OS_MBOX_EN                               */


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   3028    ----
   CONSTANT SIZE    =      2    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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