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.

6.8.6 isr_PostMail()<br />

Function Prototype:<br />

StatusType isr_PostMail(<br />

OS_EventID id,<br />

void* pmail<br />

);<br />

Descriptions:<br />

To send message to a mailbox whose ID was designated in the interrupt<br />

service program.<br />

Parameters:<br />

[IN] id<br />

the designated mailbox ID<br />

[IN] pmail<br />

message pointer<br />

Returns:<br />

E_SEV_REQ_FULL, interrupt service requests is full<br />

E_INVALID_ID, the semaphore ID that was incomed is invalid<br />

E_MBOX_FULL, the mailbox has been full<br />

E_OK,<br />

send message to mailbox successfully<br />

Example usage:<br />

#include "CCRTOS.h"<br />

OS_EventID mailbox;<br />

int IsrDat;<br />

void XXX_IRQHandler(void)<br />

{<br />

StatusType result;<br />

EnterISR();<br />

// Enter ISR<br />

...<br />

IsrDat = 0x90;<br />

/* Post a mail to Mailbox that created by other tase */<br />

result = isr_PostMail (mailbox, &IsrDat);<br />

if (result != E_OK) {<br />

if (result == E_SEV_REQ_FULL) {<br />

printf("Service requst queue is full !\n");<br />

}<br />

}<br />

...<br />

ExitISR();<br />

// Exit ISR<br />

}<br />

Note:<br />

1)It is used in the interrupt service program.<br />

2)Interrupt service routine can not call CoPostMail()to send mailbox<br />

message ,otherwise the system will lead to confusion.<br />

96

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

Saved successfully!

Ooh no, something went wrong!