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 = CoPendMail (mailbox, 20, &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 />

/* Process mail here */<br />

}<br />

...<br />

}<br />

void TaskM (void *pdata)<br />

{<br />

StatusType result;<br />

unsigned int pridat;<br />

...<br />

pridat = 0x49;<br />

...<br />

result = CoPostMail (mailbox, &pridat);<br />

if (result != E_OK)<br />

{<br />

if (result == E_INVALID_ID)<br />

{<br />

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

}<br />

}<br />

}<br />

....<br />

Note:<br />

1) The function cann’t be used in the interrupt service program.<br />

2)It is used in pairs with CoAcceptMail() or Co PendMail().<br />

95

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

Saved successfully!

Ooh no, something went wrong!