SmartSnippets DA1459x SDK
msg_queues.h
Go to the documentation of this file.
1 
41 #ifndef MSG_QUEUES_H_
42 #define MSG_QUEUES_H_
43 
44 #include <osal.h>
45 
46 typedef uint16_t MSG_SIZE;
47 typedef uint16_t MSG_ID;
48 typedef uint16_t MSG_TYPE;
50 typedef void (*MSG_FREE)(void *);
52 typedef void *(*MSG_ALLOC)(size_t);
61 #ifndef MSG_QUEUE_MALLOC
62 #define MSG_QUEUE_MALLOC OS_MALLOC_FUNC
63 #endif
64 
72 #ifndef MSG_QUEUE_FREE
73 #define MSG_QUEUE_FREE OS_FREE_FUNC
74 #endif
75 
93 typedef struct content_allocator {
97 
98 #if CONFIG_MSG_QUEUE_USE_ALLOCATORS
99 
107 #define DEFAULT_OS_ALLOCATOR (&default_os_allocator)
108 extern const content_allocator default_os_allocator;
109 
110 #else
111 
112 #define DEFAULT_OS_ALLOCATOR NULL
113 
114 #endif
115 
124 typedef struct msq_queue {
125  OS_QUEUE queue;
126 #if CONFIG_MSG_QUEUE_USE_ALLOCATORS
127  content_allocator *allocator;
128 #endif
129 } msg_queue;
130 
144 typedef struct msg {
148  uint8_t *data;
150 } msg;
151 
187 void msg_queue_create(msg_queue *queue, int queue_size, content_allocator *allocator);
188 
199 void msg_queue_delete(msg_queue *queue);
200 
244 int msg_queue_put(msg_queue *queue, msg *msg, OS_TICK_TIME timeout);
245 
269 int msg_queue_get(msg_queue *queue, msg *msg, OS_TICK_TIME timeout);
270 
289 void msg_init(msg *msg, MSG_ID id, MSG_TYPE type, void *buf, MSG_SIZE size, MSG_FREE free_cb);
290 
305 void msg_release(msg *msg);
306 
325 int msg_queue_init_msg(msg_queue *queue, msg *msg, MSG_ID id, MSG_TYPE type, MSG_SIZE size);
326 
368 int msg_queue_send(msg_queue *queue, MSG_ID id, MSG_TYPE type, void *buf, MSG_SIZE size,
369  OS_TICK_TIME timeout);
370 
416 int msq_queue_send_zero_copy(msg_queue *queue, MSG_ID id, MSG_TYPE type, void *buf,
417  MSG_SIZE size, OS_TICK_TIME timeout, MSG_FREE free_cb);
418 
419 #endif /* MSG_QUEUES_H_ */
420 
content_allocator::content_free
MSG_FREE content_free
Definition: msg_queues.h:95
MSG_ID
uint16_t MSG_ID
Definition: msg_queues.h:47
msq_queue::queue
OS_QUEUE queue
Definition: msg_queues.h:125
msg
struct msg msg
Structure for messages with id, type, data.
msg_init
void msg_init(msg *msg, MSG_ID id, MSG_TYPE type, void *buf, MSG_SIZE size, MSG_FREE free_cb)
Prepare message with freeing callback.
msg_queue_put
int msg_queue_put(msg_queue *queue, msg *msg, OS_TICK_TIME timeout)
Put message in queue.
MSG_TYPE
uint16_t MSG_TYPE
Definition: msg_queues.h:48
osal.h
OS abstraction layer API.
msq_queue
Message queue structure.
Definition: msg_queues.h:124
msg_queue_send
int msg_queue_send(msg_queue *queue, MSG_ID id, MSG_TYPE type, void *buf, MSG_SIZE size, OS_TICK_TIME timeout)
Send data to queue.
MSG_SIZE
uint16_t MSG_SIZE
Definition: msg_queues.h:46
MSG_FREE
void(* MSG_FREE)(void *)
Definition: msg_queues.h:50
msg::id
MSG_ID id
Definition: msg_queues.h:145
content_allocator
struct content_allocator content_allocator
Message queue content allocator.
msg_queue_init_msg
int msg_queue_init_msg(msg_queue *queue, msg *msg, MSG_ID id, MSG_TYPE type, MSG_SIZE size)
Initialize message with queue specific freeing callback.
msg::free_cb
MSG_FREE free_cb
Definition: msg_queues.h:149
msg_queue_get
int msg_queue_get(msg_queue *queue, msg *msg, OS_TICK_TIME timeout)
Get message from queue.
msg::type
MSG_TYPE type
Definition: msg_queues.h:146
msg_queue_create
void msg_queue_create(msg_queue *queue, int queue_size, content_allocator *allocator)
Create message queue.
msg::data
uint8_t * data
Definition: msg_queues.h:148
content_allocator
Message queue content allocator.
Definition: msg_queues.h:93
msg_queue
struct msq_queue msg_queue
Message queue structure.
msg_release
void msg_release(msg *msg)
Release message data.
content_allocator::content_alloc
MSG_ALLOC content_alloc
Definition: msg_queues.h:94
msq_queue_send_zero_copy
int msq_queue_send_zero_copy(msg_queue *queue, MSG_ID id, MSG_TYPE type, void *buf, MSG_SIZE size, OS_TICK_TIME timeout, MSG_FREE free_cb)
Send data to queue with zero copy.
MSG_ALLOC
void *(* MSG_ALLOC)(size_t)
Definition: msg_queues.h:52
msg_queue_delete
void msg_queue_delete(msg_queue *queue)
Delete message queue.
msg
Structure for messages with id, type, data.
Definition: msg_queues.h:144
msg::size
MSG_SIZE size
Definition: msg_queues.h:147