Message Queues
[Application Candies]

Message Queue Support. More...

Collaboration diagram for Message Queues:

Functions

NUTMSGQ * NutMsgQCreate (uint8_t bits)
 Allocate a new message que.
int NutMsgQBroadcast (uint8_t id, int param, void *data)
 Send a message to all message ques.
int NutMsgQPost (NUTMSGQ *que, uint8_t id, int param, void *data)
 Send a message to a que and return immediately.
int NutMsgQSend (NUTMSGQ *que, uint8_t id, int param, void *data)
 Send a message to a que and yields so that a waiting thread can act on the message.
int NutMsgQFull (NUTMSGQ *que)
 Checks the state of a que.
HANDLE NutMsgQStartTimer (NUTMSGQ *que, uint32_t ms, int param, void *data, uint8_t flags)
 Starts a periodic or one-shot timer on the given que.
void NutMsgQStopTimer (HANDLE timer)
 Stops a timer.
int NutMsgQGetMessage (NUTMSGQ *que, NUTMSG *msg, uint32_t timeout)
 Gets the next message from the que.
void NutMsgQFlush (NUTMSGQ *que)
 Removes all entries from a que.

Variables

NUTMSGQ * nutMsgQue
 global list of ques
NUTMSGTMR * nutMsgFreeTimers

Detailed Description

Message Queue Support.


Function Documentation

NUTMSGQ* NutMsgQCreate ( uint8_t  bits  ) 

Allocate a new message que.

Parameters:
bits size of the que in bits
Returns:
Handle of the new que
Note:
que size will be 2^bits

Definition at line 99 of file msg.c.

References ASSERT, NutHeapAllocClear, and nutMsgQue.

int NutMsgQBroadcast ( uint8_t  id,
int  param,
void *  data 
)

Send a message to all message ques.

Parameters:
id the id of the sent message
param the param of the sent message
data the data of the sent message
Returns:
0 if sent to all ques, < 0 if one or more ques were full

Definition at line 132 of file msg.c.

References NutMsgQPost(), and nutMsgQue.

int NutMsgQPost ( NUTMSGQ *  que,
uint8_t  id,
int  param,
void *  data 
)

Send a message to a que and return immediately.

Parameters:
que the que to send to
id the id of the sent message
param the param of the sent message
data the data of the sent message
Returns:
0 if sent, < 0 if the que is full

Definition at line 157 of file msg.c.

References NutEnterCritical, NutEventPostAsync(), NutExitCritical, NutJumpOutCritical, and NutMsgQFull().

Referenced by NutMsgQBroadcast(), and NutMsgQSend().

int NutMsgQSend ( NUTMSGQ *  que,
uint8_t  id,
int  param,
void *  data 
)

Send a message to a que and yields so that a waiting thread can act on the message.

The sending thread should have a lower priority than the receiver thread

Parameters:
que the que to send to
id the id of the sent message
param the param of the sent message
data the data of the sent message
Returns:
0 if sent, < 0 if the que is full

Definition at line 197 of file msg.c.

References NutMsgQPost(), and NutThreadYield().

int NutMsgQFull ( NUTMSGQ *  que  ) 

Checks the state of a que.

Returns:
-1 if full

Definition at line 211 of file msg.c.

Referenced by NutMsgQPost().

HANDLE NutMsgQStartTimer ( NUTMSGQ *  que,
uint32_t  ms,
int  param,
void *  data,
uint8_t  flags 
)

Starts a periodic or one-shot timer on the given que.

Parameters:
que the que to send to
ms timeout length of the timer
param the param of the sent message
data the data of the sent message
flags 0 or TM_ONESHOT
Returns:
HANDLE of the new timer

Definition at line 253 of file msg.c.

References ASSERT, NutHeapAlloc, nutMsgFreeTimers, NutTimerStart(), and TM_ONESHOT.

void NutMsgQStopTimer ( HANDLE  timer  ) 

Stops a timer.

Parameters:
timer HANDLE of the timer to stop
Note:
You must not stop a one shot that has already expired otherwise it *could* have been reused and you will end up stopping another timer

Definition at line 305 of file msg.c.

References MSG_NULL, MSG_TIMER, NutEnterCritical, NutExitCritical, and NutTimerStop().

int NutMsgQGetMessage ( NUTMSGQ *  que,
NUTMSG *  msg,
uint32_t  timeout 
)

Gets the next message from the que.

Parameters:
que the que to wait on
msg pointer to memory to return data to
timeout how long to wait for a message
Returns:
-1 on timeout, 0 if message retreived

Definition at line 345 of file msg.c.

References ASSERT, MSG_TIMER, NutEnterCritical, NutEventPostAsync(), NutEventWait(), NutExitCritical, NutJumpOutCritical, and TM_ONESHOT.

void NutMsgQFlush ( NUTMSGQ *  que  ) 

Removes all entries from a que.

Definition at line 383 of file msg.c.

References NutEnterCritical, and NutExitCritical.


Variable Documentation

NUTMSGQ* nutMsgQue

global list of ques

Definition at line 86 of file msg.c.

Referenced by NutMsgQBroadcast(), and NutMsgQCreate().

NUTMSGTMR* nutMsgFreeTimers

Definition at line 88 of file msg.c.

Referenced by NutMsgQStartTimer().


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/