MessageQueueP.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
48 #ifndef ti_dpl_MessageQueueP__include
49 #define ti_dpl_MessageQueueP__include
50 
51 #include <stdint.h>
52 #include <stdbool.h>
53 #include <stddef.h>
54 #include <ti/devices/DeviceFamily.h>
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
66 #define MessageQueueP_STRUCT_SIZE (104)
67 
81 #if ((DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X0_CC26X0) || \
82  (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X2_CC26X2) || \
83  (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X1_CC26X1) || \
84  (DeviceFamily_PARENT == DeviceFamily_PARENT_CC13X4_CC26X3_CC26X4) || \
85  (DeviceFamily_PARENT == DeviceFamily_PARENT_CC32XX))
86  #define MessageQueueP_BUFFER_SIZE(msgSize, msgCount) ((msgCount) * ((msgSize) + 8))
87 #else
88  #define MessageQueueP_BUFFER_SIZE(msgSize, msgCount) ((msgCount) * (msgSize))
89 #endif
90 
96 typedef union MessageQueueP_Struct
97 {
98  uint32_t dummy;
101 
105 #define MessageQueueP_WAIT_FOREVER ~(0)
106 
110 #define MessageQueueP_NO_WAIT (0)
111 
115 typedef enum
116 {
122 
131 typedef void *MessageQueueP_Handle;
132 
153 extern MessageQueueP_Handle MessageQueueP_create(size_t msgSize, size_t msgCount);
154 
182 MessageQueueP_Handle MessageQueueP_construct(MessageQueueP_Struct *queueStruct,
183  size_t msgSize,
184  size_t msgCount,
185  void *msgBuf);
186 
199 extern void MessageQueueP_delete(MessageQueueP_Handle handle);
200 
212 extern void MessageQueueP_destruct(MessageQueueP_Handle handle);
213 
230 extern MessageQueueP_Status MessageQueueP_pend(MessageQueueP_Handle handle, void *message, uint32_t timeout);
231 
249 extern MessageQueueP_Status MessageQueueP_peek(MessageQueueP_Handle handle, void *message, uint32_t timeout);
250 
267 extern MessageQueueP_Status MessageQueueP_post(MessageQueueP_Handle handle, const void *message, uint32_t timeout);
268 
285 extern MessageQueueP_Status MessageQueueP_postFront(MessageQueueP_Handle handle, const void *message, uint32_t timeout);
286 
297 extern size_t MessageQueueP_getPendingCount(MessageQueueP_Handle handle);
298 
309 extern size_t MessageQueueP_getFreeCount(MessageQueueP_Handle handle);
310 
311 #ifdef __cplusplus
312 }
313 #endif
314 
315 #endif /* ti_dpl_MessageQueueP__include */
size_t MessageQueueP_getPendingCount(MessageQueueP_Handle handle)
Get the number of messages stored in a message queue.
uint8_t data[(104)]
Definition: MessageQueueP.h:99
void MessageQueueP_delete(MessageQueueP_Handle handle)
Delete a MessageQueueP.
union MessageQueueP_Struct MessageQueueP_Struct
MessageQueueP structure.
void * MessageQueueP_Handle
Opaque client reference to an instance of a MessageQueueP.
Definition: MessageQueueP.h:131
#define MessageQueueP_STRUCT_SIZE
Number of bytes greater than or equal to the size of any RTOS Queue/Mailbox data structure.
Definition: MessageQueueP.h:66
size_t MessageQueueP_getFreeCount(MessageQueueP_Handle handle)
Get the number of free spaces in a message queue.
void MessageQueueP_destruct(MessageQueueP_Handle handle)
Destruct a MessageQueueP.
MessageQueueP_Status
Status codes for MessageQueueP APIs.
Definition: MessageQueueP.h:115
MessageQueueP_Status MessageQueueP_pend(MessageQueueP_Handle handle, void *message, uint32_t timeout)
Receive an item from a message queue.
MessageQueueP_Handle MessageQueueP_create(size_t msgSize, size_t msgCount)
Create a MessageQueueP, allocating memory on the heap.
MessageQueueP_Status MessageQueueP_postFront(MessageQueueP_Handle handle, const void *message, uint32_t timeout)
Post an item in the front of a message queue.
MessageQueueP_Status MessageQueueP_peek(MessageQueueP_Handle handle, void *message, uint32_t timeout)
Receive an item from a message queue without removing the item from the queue.
uint32_t dummy
Definition: MessageQueueP.h:98
MessageQueueP structure.
Definition: MessageQueueP.h:96
MessageQueueP_Handle MessageQueueP_construct(MessageQueueP_Struct *queueStruct, size_t msgSize, size_t msgCount, void *msgBuf)
Construct a MessageQueueP from statically allocated memory.
Definition: MessageQueueP.h:118
Definition: MessageQueueP.h:120
MessageQueueP_Status MessageQueueP_post(MessageQueueP_Handle handle, const void *message, uint32_t timeout)
Post an item on a message queue.
© Copyright 1995-2023, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale