IAR PowerPac RTOS User Guide

IAR PowerPac RTOS User Guide IAR PowerPac RTOS User Guide

ie.ksu.edu.tw
from ie.ksu.edu.tw More from this publisher
11.07.2015 Views

OS_Q_GetPtrTimed()DescriptionRetrieves a message from a queue within a specified time if a message is available.Prototypeint OS_Q_GetPtrTimed (OS_Q* pQ,void** ppData,OS_TIME Timeout);ParameterDescriptionpQppDataTimeoutReturn value0: No message available in queue.>0: Size of message that was retrieved from queue.Additional InformationIf the queue is empty, no message is retrieved, the task is suspended for the given timeout. The task continues execution,according to the rules of the scheduler, as soon as a message is available within the given timeout, or after the timeoutvalue has expired.Examplestatic void MemoryTask(void) {char MemoryEvent;int Len;char* pData;while (1) {Len = OS_Q_GetPtrTimed(&_MemoryQ, &pData, 10); /* Check message */if (Len > 0) {Memory_WritePacket(*(U32*)pData, pData+4, Len); /* Process message */OS_Q_Purge(&_MemoryQ); /* Delete message */} else { /* Timeout */DoSomethingElse();}}}OS_Q_Purge()DescriptionDeletes the last retrieved message in a queue.Prototypevoid OS_Q_Purge (OS_Q* pQ);ParameterDescriptionAdditional InformationPointer to the queue.Table 77: OS_Q_GetPtrCond() parameter listpQTable 78: OS_Q_Purge() parameter listAddress of pointer to the message to be retrieved from queue.Maximum time in timer ticks until the requested message has to be available. The data typeOS_TIME defaults to an integer, therefore valid values are1

QueuesExamplestatic void MemoryTask(void) {char MemoryEvent;int Len;char* pData;}while (1) {Len = OS_Q_GetPtr(&_MemoryQ, &pData); /* Get message */Memory_WritePacket(*(U32*)pData, pData+4, Len); /* Process message */OS_Q_Purge(&_MemoryQ); /* Delete message */}OS_Q_Clear()DescriptionDeletes all message in a queue.Prototypevoid OS_Q_Clear (OS_Q* pQ);ParameterDescriptionpQPointer to the queue.Table 79: OS_Q_Clear() parameter listOS_Q_GetMessageCnt()DescriptionReturns the number of messages currently in a queue.Prototypeint OS_Q_GetMessageCnt (OS_Q* pQ);ParameterDescriptionpQReturn valuePointer to the queue.Table 80: OS_Q_GetMessageCnt() parameter listThe number of messages in the queue.PPRTOS-275

QueuesExamplestatic void MemoryTask(void) {char MemoryEvent;int Len;char* pData;}while (1) {Len = OS_Q_GetPtr(&_MemoryQ, &pData); /* Get message */Memory_WritePacket(*(U32*)pData, pData+4, Len); /* Process message */OS_Q_Purge(&_MemoryQ); /* Delete message */}OS_Q_Clear()DescriptionDeletes all message in a queue.Prototypevoid OS_Q_Clear (OS_Q* pQ);ParameterDescriptionpQPointer to the queue.Table 79: OS_Q_Clear() parameter listOS_Q_GetMessageCnt()DescriptionReturns the number of messages currently in a queue.Prototypeint OS_Q_GetMessageCnt (OS_Q* pQ);ParameterDescriptionpQReturn valuePointer to the queue.Table 80: OS_Q_GetMessageCnt() parameter listThe number of messages in the queue.PP<strong>RTOS</strong>-275

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

Saved successfully!

Ooh no, something went wrong!