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...

Create successful ePaper yourself

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

ExampleMailbox used as keyboard buffer:OS_MAILBOX MBKey;char MBKeyBuffer[6];void InitKeyMan(void) {/* Create mailbox, functioning as type ahead buffer */OS_CREATEMB(&MBKey, 1, sizeof(MBKeyBuffer), &MBKeyBuffer);}Mailbox used for transfering complex commands from one task to another:/** Example of mailbox used for transfering commands to a task* that controls 2 motors*/typedef struct {char Cmd;int Speed[2];int Position[2];} MOTORCMD ;OS_MAILBOX MBMotor;#define MOTORCMD_SIZE 4char BufferMotor[sizeof(MOTORCMD)*MOTORCMD_SIZE];void MOTOR_Init(void) {/* Create mailbox that holds commands messages */OS_CREATEMB(&MBMotor, sizeof(MOTORCMD), MOTORCMD_SIZE, &BufferMotor);}OS_PutMail() / OS_PutMail1()DescriptionStores a new message of a predefined size in a mailbox.Prototypevoid OS_PutMail (OS_MAILBOX* pMB,void* pMail);void OS_PutMail1 (OS_MAILBOX* pMB,const char* pMail);ParameterDescriptionpMBpMailAdditional InformationIf the mailbox is full, the calling task is suspended.Because this routine might require a suspension, it must not be called from an interrupt routine. UseOS_PutMailCond()/OS_PutMailCond1() instead if you have to store data in a mailbox from within an ISR.ImportantPointer to the mailbox.Pointer to the message to store.Table 61: OS_PutMail() / OS_PutMail1() parameter listThis function may not be called from within an interrupt handler.64<strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong>for ARM CoresPP<strong>RTOS</strong>-2

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

Saved successfully!

Ooh no, something went wrong!