Skip to content

Commit 1cf8370

Browse files
authored
Merge pull request #5295 from ousugo/addComment
Add dataqueue.c function annotation
2 parents d5001ab + b329611 commit 1cf8370

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

components/drivers/src/dataqueue.c

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ struct rt_data_item
2121
rt_size_t data_size;
2222
};
2323

24+
/**
25+
* @brief This function will initialize the data queue. Calling this function will
26+
* initialize the data queue control block and set the notification callback function.
27+
*
28+
* @param queue is a pointer to the data queue object.
29+
*
30+
* @param size is the maximum number of data in the data queue.
31+
*
32+
* @param lwm is low water mark.
33+
* When the number of data in the data queue is less than this value, this function will
34+
* wake up the thread waiting for write data.
35+
*
36+
* @param evt_notify is the notification callback function.
37+
*
38+
* @return Return the operation status. When the return value is RT_EOK, the initialization is successful.
39+
* When the return value is RT_ENOMEM, it means insufficient memory allocation failed.
40+
*/
2441
rt_err_t
2542
rt_data_queue_init(struct rt_data_queue *queue,
2643
rt_uint16_t size,
@@ -54,6 +71,21 @@ rt_data_queue_init(struct rt_data_queue *queue,
5471
}
5572
RTM_EXPORT(rt_data_queue_init);
5673

74+
/**
75+
* @brief This function will write data to the data queue. If the data queue is full,
76+
* the thread will suspend for the specified amount of time.
77+
*
78+
* @param queue is a pointer to the data queue object.
79+
* .
80+
* @param data_ptr is the buffer pointer of the data to be written.
81+
*
82+
* @param size is the size in bytes of the data to be written.
83+
*
84+
* @param timeout is the waiting time.
85+
*
86+
* @return Return the operation status. When the return value is RT_EOK, the operation is successful.
87+
* When the return value is RT_ETIMEOUT, it means the specified time out.
88+
*/
5789
rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
5890
const void *data_ptr,
5991
rt_size_t data_size,
@@ -153,6 +185,24 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
153185
}
154186
RTM_EXPORT(rt_data_queue_push);
155187

188+
/**
189+
* @brief This function will pop data from the data queue. If the data queue is empty,the thread
190+
* will suspend for the specified amount of time.
191+
*
192+
* @note When the number of data in the data queue is less than lwm(low water mark), will
193+
* wake up the thread waiting for write data.
194+
*
195+
* @param queue is a pointer to the data queue object.
196+
*
197+
* @param data_ptr is the buffer pointer of the data to be fetched.
198+
*
199+
* @param size is the size in bytes of the data to be fetched.
200+
*
201+
* @param timeout is the waiting time.
202+
*
203+
* @return Return the operation status. When the return value is RT_EOK, the operation is successful.
204+
* When the return value is RT_ETIMEOUT, it means the specified time out.
205+
*/
156206
rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
157207
const void** data_ptr,
158208
rt_size_t *size,
@@ -264,6 +314,18 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
264314
}
265315
RTM_EXPORT(rt_data_queue_pop);
266316

317+
/**
318+
* @brief This function will fetch but retaining data in the data queue.
319+
*
320+
* @param queue is a pointer to the data queue object.
321+
*
322+
* @param data_ptr is the buffer pointer of the data to be fetched.
323+
*
324+
* @param size is the size in bytes of the data to be fetched.
325+
*
326+
* @return Return the operation status. When the return value is RT_EOK, the operation is successful.
327+
* When the return value is -RT_EEMPTY, it means the data queue is empty.
328+
*/
267329
rt_err_t rt_data_queue_peek(struct rt_data_queue *queue,
268330
const void** data_ptr,
269331
rt_size_t *size)
@@ -289,6 +351,14 @@ rt_err_t rt_data_queue_peek(struct rt_data_queue *queue,
289351
}
290352
RTM_EXPORT(rt_data_queue_peek);
291353

354+
/**
355+
* @brief This function will reset the data queue.
356+
*
357+
* @note Calling this function will wake up all threads on the data queue
358+
* that are hanging and waiting.
359+
*
360+
* @param queue is a pointer to the data queue object.
361+
*/
292362
void rt_data_queue_reset(struct rt_data_queue *queue)
293363
{
294364
rt_ubase_t level;
@@ -362,6 +432,13 @@ void rt_data_queue_reset(struct rt_data_queue *queue)
362432
}
363433
RTM_EXPORT(rt_data_queue_reset);
364434

435+
/**
436+
* @brief This function will deinit the data queue.
437+
*
438+
* @param queue is a pointer to the data queue object.
439+
*
440+
* @return Return the operation status. When the return value is RT_EOK, the operation is successful.
441+
*/
365442
rt_err_t rt_data_queue_deinit(struct rt_data_queue *queue)
366443
{
367444
rt_ubase_t level;
@@ -382,6 +459,13 @@ rt_err_t rt_data_queue_deinit(struct rt_data_queue *queue)
382459
}
383460
RTM_EXPORT(rt_data_queue_deinit);
384461

462+
/**
463+
* @brief This function will get the number of data in the data queue.
464+
*
465+
* @param queue is a pointer to the data queue object.
466+
*
467+
* @return Return the number of data in the data queue.
468+
*/
385469
rt_uint16_t rt_data_queue_len(struct rt_data_queue *queue)
386470
{
387471
rt_ubase_t level;

0 commit comments

Comments
 (0)