📄 os_mbox.lst
字号:
C51 COMPILER V7.10 OS_MBOX 08/23/2004 01:45:17 PAGE 1
C51 COMPILER V7.10, COMPILATION OF MODULE OS_MBOX
OBJECT MODULE PLACED IN OS_MBOX.OBJ
COMPILER INVOKED BY: D:\keil51\C51\BIN\C51.EXE OS_MBOX.C BROWSE DEBUG OBJECTEXTEND
line 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.
*********************************************************************************************************
*/
#if OS_Mbox_Accept_EN
void *OSMboxAccept (OS_EVENT *pevent)reentrant
{
void *msg;
OS_ENTER_CRITICAL();
if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) { /* Validate event block type */
OS_EXIT_CRITICAL();
return ((void *)0);
}
msg = pevent->OSEventPtr;
if (msg != (void *)0) { /* See if there is already a message */
pevent->OSEventPtr = (void *)0; /* Clear the mailbox */
}
OS_EXIT_CRITICAL();
return (msg); /* Return the message received (or NULL) */
}
#endif
/*$PAGE*/
C51 COMPILER V7.10 OS_MBOX 08/23/2004 01:45:17 PAGE 2
/*
*********************************************************************************************************
* 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
*********************************************************************************************************
*/
#if OS_Mbox_Create_EN
OS_EVENT *OSMboxCreate (void *msg)reentrant
{
OS_EVENT *pevent;
OS_ENTER_CRITICAL();
pevent = OSEventFreeList; /* Get next free event control block */
if (OSEventFreeList != (OS_EVENT *)0) { /* See if pool of free ECB pool was empty */
OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
}
OS_EXIT_CRITICAL();
if (pevent != (OS_EVENT *)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 */
}
#endif
/*$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
* event control block.
*********************************************************************************************************
C51 COMPILER V7.10 OS_MBOX 08/23/2004 01:45:17 PAGE 3
*/
#if OS_Mbox_Pend_EN
void *OSMboxPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)reentrant
{
void *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 *)0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -