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

📄 os_mbox.lst

📁 ucos移植学习
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.02a   OS_MBOX                                                              10/16/2006 15:27:51 PAGE 1   


C51 COMPILER V7.02a, COMPILATION OF MODULE OS_MBOX
OBJECT MODULE PLACED IN .\OS_MBOX.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE ..\uc_os_II\OS_MBOX.C BROWSE DEBUG OBJECTEXTEND PRINT(.\OS_MBOX.lst) OBJECT
                    -(.\OS_MBOX.obj)

stmt level    source

   1          /*
   2          *********************************************************************************************************
   3          *                                                uC/OS-II
   4          *                                          The Real-Time Kernel
   5          *                                       MESSAGE MAILBOX MANAGEMENT
   6          *
   7          *                        (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
   8          *                                           All Rights Reserved
   9          *
  10          *                                                  V2.00
  11          *
  12          * File : OS_MBOX.C
  13          * By   : Jean J. Labrosse
  14          *********************************************************************************************************
  15          */
  16          
  17          #ifndef  OS_MASTER_FILE
  18          #include "includes.h"
  19          #endif
  20          
  21          #if OS_MBOX_EN
  22          /*
  23          *********************************************************************************************************
  24          *                                     ACCEPT MESSAGE FROM MAILBOX
  25          *
  26          * Description: This function checks the mailbox to see if a message is available.  Unlike OSMboxPend(),
  27          *              OSMboxAccept() does not suspend the calling task if a message is not available.
  28          *
  29          * Arguments  : pevent        is a pointer to the event control block
  30          *
  31          * Returns    : != (void *)0  is the message in the mailbox if one is available.  The mailbox is cleared
  32          *                            so the next time OSMboxAccept() is called, the mailbox will be empty.
  33          *              == (void *)0  if the mailbox is empty or if you didn't pass the proper event pointer.
  34          *********************************************************************************************************
  35          */
  36          
  37          void DT_XDATA *OSMboxAccept (OS_EVENT DT_XDATA * pevent) REENTRANT
  38          {
  39   1          void DT_XDATA * msg;
  40   1      
  41   1      
  42   1          OS_ENTER_CRITICAL();
  43   1          if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {      /* Validate event block type                 */
  44   2              OS_EXIT_CRITICAL();
  45   2              return ((void DT_XDATA *)0);
  46   2          }
  47   1          msg = pevent->OSEventPtr; 
  48   1          if (msg != (void DT_XDATA *)0) {                               /* See if there is already a message   
             -      */
  49   2              pevent->OSEventPtr = (void DT_XDATA *)0;                   /* Clear the mailbox                   
             -      */
  50   2          }
  51   1          OS_EXIT_CRITICAL();
  52   1          return (msg);                                         /* Return the message received (or NULL)     */
C51 COMPILER V7.02a   OS_MBOX                                                              10/16/2006 15:27:51 PAGE 2   

  53   1      }
  54          /*$PAGE*/
  55          /*
  56          *********************************************************************************************************
  57          *                                        CREATE A MESSAGE MAILBOX
  58          *
  59          * Description: This function creates a message mailbox if free event control blocks are available.
  60          *
  61          * Arguments  : msg           is a pointer to a message that you wish to deposit in the mailbox.  If
  62          *                            you set this value to the NULL pointer (i.e. (void *)0) then the mailbox
  63          *                            will be considered empty.
  64          *
  65          * Returns    : != (void *)0  is a pointer to the event control clock (OS_EVENT) associated with the
  66          *                            created mailbox
  67          *              == (void *)0  if no event control blocks were available
  68          *********************************************************************************************************
  69          */
  70          
  71          OS_EVENT DT_XDATA *OSMboxCreate (void DT_XDATA * msg) REENTRANT
  72          {
  73   1          OS_EVENT DT_XDATA *pevent;
  74   1      
  75   1      
  76   1          OS_ENTER_CRITICAL();
  77   1          pevent = OSEventFreeList;                    /* Get next free event control block                  */
  78   1          if (OSEventFreeList != (OS_EVENT DT_XDATA *)0) {      /* See if pool of free ECB pool was empty       
             -      */
  79   2              OSEventFreeList = (OS_EVENT DT_XDATA *)OSEventFreeList->OSEventPtr;
  80   2          }
  81   1          OS_EXIT_CRITICAL();
  82   1          if (pevent != (OS_EVENT DT_XDATA *)0) {
  83   2              pevent->OSEventType = OS_EVENT_TYPE_MBOX;
  84   2              pevent->OSEventPtr  = msg;               /* Deposit message in event control block             */
  85   2              OSEventWaitListInit(pevent);
  86   2          }
  87   1          return (pevent);                             /* Return pointer to event control block              */
  88   1      }
  89          /*$PAGE*/
  90          /*
  91          *********************************************************************************************************
  92          *                                      PEND ON MAILBOX FOR A MESSAGE
  93          *
  94          * Description: This function waits for a message to be sent to a mailbox
  95          *
  96          * Arguments  : pevent        is a pointer to the event control block associated with the desired mailbox
  97          *
  98          *              timeout       is an optional timeout period (in clock ticks).  If non-zero, your task will
  99          *                            wait for a message to arrive at the mailbox up to the amount of time 
 100          *                            specified by this argument.  If you specify 0, however, your task will wait 
 101          *                            forever at the specified mailbox or, until a message arrives.
 102          *
 103          *              err           is a pointer to where an error message will be deposited.  Possible error
 104          *                            messages are:
 105          *
 106          *                            OS_NO_ERR         The call was successful and your task received a message.
 107          *                            OS_TIMEOUT        A message was not received within the specified timeout
 108          *                            OS_ERR_EVENT_TYPE Invalid event type
 109          *                            OS_ERR_PEND_ISR   If you called this function from an ISR and the result
 110          *                                              would lead to a suspension.
 111          *
 112          * Returns    : != (void *)0  is a pointer to the message received
 113          *              == (void *)0  if no message was received or you didn't pass the proper pointer to the
C51 COMPILER V7.02a   OS_MBOX                                                              10/16/2006 15:27:51 PAGE 3   

 114          *                            event control block.
 115          *********************************************************************************************************
 116          */
 117          
 118          void DT_XDATA *OSMboxPend (OS_EVENT DT_XDATA *pevent, INT16U timeout, INT8U DT_XDATA *err) REENTRANT
 119          {
 120   1          void DT_XDATA *msg;
 121   1      
 122   1      
 123   1          OS_ENTER_CRITICAL();
 124   1          if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type                     */
 125   2              OS_EXIT_CRITICAL();
 126   2              *err = OS_ERR_EVENT_TYPE;
 127   2              return ((void DT_XDATA *)0);
 128   2          }

⌨️ 快捷键说明

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