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.

Event objectsExampleif (OS_EVENT_WaitTimed(&_HW_Event, 10) == 0) {/* event was signaled within tim out time, handle event */...} else {/* event was not signaled within tim out time, handle timeout */...}OS_EVENT_Set()DescriptionSets an event object to signaled state, or resumes tasks which are waiting at the event object.Prototypevoid OS_EVENT_Set (OS_EVENT* pEvent)ParameterDescriptionpEventPointer to the event object which should be set to signaled state.Table 93: OS_EVENT_Set() parameter listAdditional InformationIf no tasks are waiting at the event object, the event object is set to signaled state. If at least one task is already waitingat the event object, all waiting tasks are resumed and the event object is not set to the signaled state. pEvent has toaddress an existing event object, which has to be created before by a call of of OS_EVENT_Create(). The debugversion of <strong>IAR</strong> <strong>PowerPac</strong> <strong>RTOS</strong> will check whether pEvent addresses a valid event object and will callOS_Error() with error code OS_ERR_EVENT_INVALID in case of an error.ExampleThe following example uses event objects to synchronize tasks to a hardware initilization function.#include "<strong>RTOS</strong>.h"OS_STACKPTR int StackHP[128], StackLP[128]; /* Task stacks */OS_TASK TCBHP, TCBLP; /* Task-control-blocks *//********************************************************************//****** Interface to HW module **************************************/void HW_Wait(void);void HW_Free(void);void HW_Init(void);/********************************************************************//****** HW module ***************************************************/OS_STACKPTR int _StackHW[128]; /* Task stack */OS_TASK _TCBHW; /* Task-control-block *//****** local data **************************************************/static OS_EVENT _HW_Event;/****** local functions *********************************************/static void _HWTask(void) {/* Initialize HW functionallity */OS_Delay(100);/* Init done, send broadcast to waiting tasks */HW_Free();while (1) {OS_Delay (40);}}PP<strong>RTOS</strong>-285

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

Saved successfully!

Ooh no, something went wrong!