?? os_mbox.lst
字號:
C51 COMPILER V7.06 OS_MBOX 03/04/2005 14:28:18 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE OS_MBOX
OBJECT MODULE PLACED IN .\OS_MBOX.obj
COMPILER INVOKED BY: C:\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
/*
*********************************************************************************************************
* ACCEPT MESSAGE FROM MAILBOX
*
* Description: This function checks the mailbox to see if a message is available. Unlike OSMboxPend(),
* OSMboxAccept() does not suspend the calling task if a message is not available.
*
* Arguments : pevent is a pointer to the event control block
*
* Returns : != (void *)0 is the message in the mailbox if one is available. The mailbox is cleared
* so the next time OSMboxAccept() is called, the mailbox will be empty.
* == (void *)0 if the mailbox is empty or if you didn't pass the proper event pointer.
*********************************************************************************************************
*/
void DT_XDATA *OSMboxAccept (OS_EVENT DT_XDATA * pevent) REENTRANT
{
void DT_XDATA * msg;
OS_ENTER_CRITICAL();
if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) { /* Validate event block type */
OS_EXIT_CRITICAL();
return ((void DT_XDATA *)0);
}
msg = pevent->OSEventPtr;
if (msg != (void DT_XDATA *)0) { /* See if there is already a message
- */
pevent->OSEventPtr = (void DT_XDATA *)0; /* Clear the mailbox
- */
}
OS_EXIT_CRITICAL();
return (msg); /* Return the message received (or NULL) */
C51 COMPILER V7.06 OS_MBOX 03/04/2005 14:28:18 PAGE 2
}
/*$PAGE*/
/*
*********************************************************************************************************
* CREATE A MESSAGE MAILBOX
*
* Description: This function creates a message mailbox if free event control blocks are available.
*
* Arguments : msg is a pointer to a message that you wish to deposit in the mailbox. If
* you set this value to the NULL pointer (i.e. (void *)0) then the mailbox
* will be considered empty.
*
* Returns : != (void *)0 is a pointer to the event control clock (OS_EVENT) associated with the
* created mailbox
* == (void *)0 if no event control blocks were available
*********************************************************************************************************
*/
OS_EVENT DT_XDATA *OSMboxCreate (void DT_XDATA * msg) REENTRANT
{
OS_EVENT DT_XDATA *pevent;
OS_ENTER_CRITICAL();
pevent = OSEventFreeList; /* Get next free event control block */
if (OSEventFreeList != (OS_EVENT DT_XDATA *)0) { /* See if pool of free ECB pool was empty
- */
OSEventFreeList = (OS_EVENT DT_XDATA *)OSEventFreeList->OSEventPtr;
}
OS_EXIT_CRITICAL();
if (pevent != (OS_EVENT DT_XDATA *)0) {
pevent->OSEventType = OS_EVENT_TYPE_MBOX;
pevent->OSEventPtr = msg; /* Deposit message in event control block */
OSEventWaitListInit(pevent);
}
return (pevent); /* Return pointer to event control block */
}
/*$PAGE*/
/*
*********************************************************************************************************
* PEND ON MAILBOX FOR A MESSAGE
*
* Description: This function waits for a message to be sent to a mailbox
*
* Arguments : pevent is a pointer to the event control block associated with the desired mailbox
*
* timeout is an optional timeout period (in clock ticks). If non-zero, your task will
* wait for a message to arrive at the mailbox up to the amount of time
* specified by this argument. If you specify 0, however, your task will wait
* forever at the specified mailbox or, until a message arrives.
*
* err is a pointer to where an error message will be deposited. Possible error
* messages are:
*
* OS_NO_ERR The call was successful and your task received a message.
* OS_TIMEOUT A message was not received within the specified timeout
* OS_ERR_EVENT_TYPE Invalid event type
* OS_ERR_PEND_ISR If you called this function from an ISR and the result
* would lead to a suspension.
*
* Returns : != (void *)0 is a pointer to the message received
* == (void *)0 if no message was received or you didn't pass the proper pointer to the
C51 COMPILER V7.06 OS_MBOX 03/04/2005 14:28:18 PAGE 3
* event control block.
*********************************************************************************************************
*/
void DT_XDATA *OSMboxPend (OS_EVENT DT_XDATA *pevent, INT16U timeout, INT8U DT_XDATA *err) REENTRANT
{
void DT_XDATA *msg;
OS_ENTER_CRITICAL();
if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) { /* Validate event block type */
OS_EXIT_CRITICAL();
*err = OS_ERR_EVENT_TYPE;
return ((void DT_XDATA *)0);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -