Skip to content

Commit dc1f263

Browse files
committed
Add dataqueue.c function annotation
1 parent 9bbcd1a commit dc1f263

File tree

1 file changed

+67
-1
lines changed

1 file changed

+67
-1
lines changed

components/drivers/src/dataqueue.c

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ struct rt_data_item
2121
rt_size_t data_size;
2222
};
2323

24+
/**
25+
* @brief This function will initialize a data queue.Calling this function will
26+
* initialize the data queue control block and set the notification callback function.
27+
*
28+
* @param queue The data queue object
29+
* @param size The maximum number of data in the data queue
30+
* @param lwm Low water mark, when the number of data in the data queue is less than this value,
31+
* will wake up the thread waiting for write data.
32+
* @param evt_notify The notification callback function
33+
*
34+
* @return the operation status, RT_EOK on successful,
35+
* RT_ENOMEM on insufficient memory allocation failed.
36+
*/
2437
rt_err_t
2538
rt_data_queue_init(struct rt_data_queue *queue,
2639
rt_uint16_t size,
@@ -32,7 +45,7 @@ rt_data_queue_init(struct rt_data_queue *queue,
3245

3346
queue->evt_notify = evt_notify;
3447

35-
queue->magic = DATAQUEUE_MAGIC;
48+
queue->magic = DATAQUEUE_MAGIC;
3649
queue->size = size;
3750
queue->lwm = lwm;
3851

@@ -54,6 +67,17 @@ rt_data_queue_init(struct rt_data_queue *queue,
5467
}
5568
RTM_EXPORT(rt_data_queue_init);
5669

70+
/**
71+
* @brief This function will write data to the data queue. If the data queue is full,
72+
* the thread will suspend for the specified amount of time.
73+
*
74+
* @param queue The data queue object
75+
* @param data_ptr The buffer pointer of the data to be written
76+
* @param size The size in bytes of the data to be written
77+
* @param timeout The waiting time
78+
*
79+
* @return the operation status, RT_EOK on successful
80+
*/
5781
rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
5882
const void *data_ptr,
5983
rt_size_t data_size,
@@ -153,6 +177,20 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
153177
}
154178
RTM_EXPORT(rt_data_queue_push);
155179

180+
/**
181+
* @brief This function will pop data from the data queue. If the data queue is empty,
182+
* the thread will suspend for the specified amount of time.
183+
*
184+
* @attention when the number of data in the data queue is less than lwm(low water mark),
185+
* will wake up the thread waiting for write data.
186+
*
187+
* @param queue The data queue object
188+
* @param data_ptr The buffer pointer of the data to be fetched
189+
* @param size The size in bytes of the data to be fetched
190+
* @param timeout The waiting time
191+
*
192+
* @return Operation status, RT_EOK on successful, RT_ETIMEOUT on timeout.
193+
*/
156194
rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
157195
const void** data_ptr,
158196
rt_size_t *size,
@@ -264,6 +302,15 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
264302
}
265303
RTM_EXPORT(rt_data_queue_pop);
266304

305+
/**
306+
* @brief This function will fetching but retaining data in the data queue.
307+
*
308+
* @param queue The data queue object
309+
* @param data_ptr The buffer pointer of the data to be fetched
310+
* @param size The size in bytes of the data to be fetched
311+
*
312+
* @return The operation status, RT_EOK on successful
313+
*/
267314
rt_err_t rt_data_queue_peek(struct rt_data_queue *queue,
268315
const void** data_ptr,
269316
rt_size_t *size)
@@ -289,6 +336,12 @@ rt_err_t rt_data_queue_peek(struct rt_data_queue *queue,
289336
}
290337
RTM_EXPORT(rt_data_queue_peek);
291338

339+
/**
340+
* @brief Reset a data queue. Calling this function will wake up all threads on the data queue
341+
* that are hanging and waiting.
342+
*
343+
* @param queue The data queue object
344+
*/
292345
void rt_data_queue_reset(struct rt_data_queue *queue)
293346
{
294347
rt_ubase_t level;
@@ -362,6 +415,13 @@ void rt_data_queue_reset(struct rt_data_queue *queue)
362415
}
363416
RTM_EXPORT(rt_data_queue_reset);
364417

418+
/**
419+
* @brief Deinit a data queue.
420+
*
421+
* @param queue The data queue object
422+
*
423+
* @return operation status, RT_EOK on successful.
424+
*/
365425
rt_err_t rt_data_queue_deinit(struct rt_data_queue *queue)
366426
{
367427
rt_ubase_t level;
@@ -382,6 +442,12 @@ rt_err_t rt_data_queue_deinit(struct rt_data_queue *queue)
382442
}
383443
RTM_EXPORT(rt_data_queue_deinit);
384444

445+
/**
446+
* @brief This function get the number of data in the data queue.
447+
*
448+
* @param queue The data queue object
449+
* @return The number of data in the data queue
450+
*/
385451
rt_uint16_t rt_data_queue_len(struct rt_data_queue *queue)
386452
{
387453
rt_ubase_t level;

0 commit comments

Comments
 (0)