11.07.2015 Views

IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

MailboxesExampleSingle-byte mailbox as keyboard buffer:OS_MAILBOX MBKey;char MBKeyBuffer[6];void KEYMAN_StoreKey(char k) {OS_PutMail1(&MBKey, &k); /* Store key, wait if no space in buffer */}void KEYMAN_Init(void) {/* Create mailbox functioning as type ahead buffer */OS_CREATEMB(&MBKey, 1, sizeof(MBKeyBuffer), &MBKeyBuffer);}OS_PutMailCond() / OS_PutMailCond1()DescriptionStores a new message of a predefined size in a mailbox, if the mailbox is able to accept one more message.Prototypechar OS_PutMailCond (OS_MAILBOX* pMB,void* pMail);char OS_PutMailCond1 (OS_MAILBOX* pMB,const char* pMail);)ParameterDescriptionpMBPointer to the mailbox.pMailPointer to the message to store.Table 62: OS_PutMailCond() / OS_PutMailCond1() overviewReturn value0: Success; message stored.1: Message could not be stored (mailbox is full).Additional InformationIf the mailbox is full, the message is not stored.This function never suspends the calling task. It may therefore be called from an interrupt routine.ExampleOS_MAILBOX MBKey;char MBKeyBuffer[6];char KEYMAN_StoreCond(char k) {return OS_PutMailCond1(&MBKey, &k); /* Store key if space in buffer */}This example can be used with the sample program shown earlier to handle a mailbox as keyboard buffer.OS_PutMailFront() / OS_PutMailFront1()DescriptionStores a new message of a predefined size at the beginning of a mailbox in front of all other messages. This newmessage will be retrieved first.Prototypevoid OS_PutMailFront (OS_MAILBOX* pMB,void* pMail);void OS_PutMailFront1 (OS_MAILBOX* pMB,const char* pMail);ParameterDescriptionpMBpMailPointer to the mailbox.Pointer to the message to store.Table 63: OS_PutMailFront() / OS_PutMailFront1() parameter listPP<strong>RTOS</strong>-265

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

Saved successfully!

Ooh no, something went wrong!