02.01.2015 Views

CooCox CoOS User's Guide

CooCox CoOS User's Guide

CooCox CoOS User's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example usage:<br />

#include "CCRTOS.h"<br />

OS_EventID mailbox;<br />

void TaskN (void *pdata)<br />

{<br />

StatusType result;<br />

void *msg;<br />

...<br />

/* Create a mailbox */<br />

msg = CoAcceptMail (mailbox, &result);<br />

if (result != E_OK)<br />

{<br />

if (result == E_INVALID_ID)<br />

{<br />

printf("Invalid event ID !\n");<br />

}<br />

}<br />

else<br />

{<br />

…<br />

/* Process mail here */<br />

…<br />

}<br />

...<br />

}<br />

Note:<br />

If the message pointer of the designated mailbox is not empty while<br />

calling AcceptSem(),this function will get the message pointer and empty<br />

the mailbox;otherwise,return error immediately.<br />

6.8.4 CoPendMail()<br />

Function Prototype:<br />

void* CoPendMail(<br />

OS_EventID id,<br />

U32<br />

timeout,<br />

StatusType* perr<br />

);<br />

Descriptions:<br />

To wait the message of the designated mailbox.<br />

Parameters:<br />

[in] id<br />

the designated mailbox ID<br />

91

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!