Cordio Stack and Cordio Profiles  r2p3-02rel0
wsf_msg.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file wsf_msg.h
4  *
5  * \brief Message passing service.
6  *
7  * Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
8  * Arm Ltd. confidential and proprietary.
9  *
10  * IMPORTANT. Your use of this file is governed by a Software License Agreement
11  * ("Agreement") that must be accepted in order to download or otherwise receive a
12  * copy of this file. You may not use or copy this file for any purpose other than
13  * as described in the Agreement. If you do not agree to all of the terms of the
14  * Agreement do not use this file and delete all copies in your possession or control;
15  * if you do not have a copy of the Agreement, you must contact Arm Ltd. prior
16  * to any use, copying or further distribution of this software.
17  */
18 /*************************************************************************************************/
19 #ifndef WSF_MSG_H
20 #define WSF_MSG_H
21 
22 #include "wsf_queue.h"
23 #include "wsf_os.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 /*! \addtogroup WSF_MSG_API
30  * \{ */
31 
32 /**************************************************************************************************
33  Function Declarations
34 **************************************************************************************************/
35 
36 /*************************************************************************************************/
37 /*!
38  * \brief Allocate a data message buffer to be sent with WsfMsgSend().
39  *
40  * \param len Message length in bytes.
41  * \param tailroom Tailroom length in bytes.
42  *
43  * \return Pointer to data message buffer or NULL if allocation failed.
44  */
45 /*************************************************************************************************/
46 void *WsfMsgDataAlloc(uint16_t len, uint8_t tailroom);
47 
48 /*************************************************************************************************/
49 /*!
50  * \brief Allocate a message buffer to be sent with WsfMsgSend().
51  *
52  * \param len Message length in bytes.
53  *
54  * \return Pointer to message buffer or NULL if allocation failed.
55  */
56 /*************************************************************************************************/
57 void *WsfMsgAlloc(uint16_t len);
58 
59 /*************************************************************************************************/
60 /*!
61  * \brief Free a message buffer allocated with WsfMsgAlloc().
62  *
63  * \param pMsg Pointer to message buffer.
64  *
65  * \return None.
66  */
67 /*************************************************************************************************/
68 void WsfMsgFree(void *pMsg);
69 
70 /*************************************************************************************************/
71 /*!
72  * \brief Send a message to an event handler.
73  *
74  * \param handlerId Event handler ID.
75  * \param pMsg Pointer to message buffer.
76  *
77  * \return None.
78  */
79 /*************************************************************************************************/
80 void WsfMsgSend(wsfHandlerId_t handlerId, void *pMsg);
81 
82 /*************************************************************************************************/
83 /*!
84  * \brief Enqueue a message.
85  *
86  * \param pQueue Pointer to queue.
87  * \param handlerId Set message handler ID to this value.
88  * \param pMsg Pointer to message buffer.
89  *
90  * \return None.
91  */
92 /*************************************************************************************************/
93 void WsfMsgEnq(wsfQueue_t *pQueue, wsfHandlerId_t handlerId, void *pMsg);
94 
95 /*************************************************************************************************/
96 /*!
97  * \brief Dequeue a message.
98  *
99  * \param pQueue Pointer to queue.
100  * \param pHandlerId Handler ID of returned message; this is a return parameter.
101  *
102  * \return Pointer to message that has been dequeued or NULL if queue is empty.
103  */
104 /*************************************************************************************************/
105 void *WsfMsgDeq(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId);
106 
107 /*************************************************************************************************/
108 /*!
109  * \brief Get the next message without removing it from the queue.
110  *
111  * \param pQueue Pointer to queue.
112  * \param pHandlerId Handler ID of returned message; this is a return parameter.
113  *
114  * \return Pointer to the next message on the queue or NULL if queue is empty.
115  */
116 /*************************************************************************************************/
117 void *WsfMsgPeek(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId);
118 
119 /*! \} */ /* WSF_MSG_API */
120 
121 #ifdef __cplusplus
122 };
123 #endif
124 
125 #endif /* WSF_MSG_H */
void WsfMsgEnq(wsfQueue_t *pQueue, wsfHandlerId_t handlerId, void *pMsg)
Enqueue a message.
void WsfMsgSend(wsfHandlerId_t handlerId, void *pMsg)
Send a message to an event handler.
uint8_t wsfHandlerId_t
Event handler ID data type.
Definition: wsf_os.h:74
Queue structure.
Definition: wsf_queue.h:41
void * WsfMsgPeek(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId)
Get the next message without removing it from the queue.
void * WsfMsgAlloc(uint16_t len)
Allocate a message buffer to be sent with WsfMsgSend().
void * WsfMsgDataAlloc(uint16_t len, uint8_t tailroom)
Allocate a data message buffer to be sent with WsfMsgSend().
unsigned short uint16_t
Unsigned 16-bit value.
Definition: wsf_types.h:67
General purpose queue service.
void WsfMsgFree(void *pMsg)
Free a message buffer allocated with WsfMsgAlloc().
Software foundation OS API.
unsigned char uint8_t
Unsigned 8-bit value.
Definition: wsf_types.h:63
void * WsfMsgDeq(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId)
Dequeue a message.