Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
混口饭吃,
rt-thread
提交
1cf8370b
R
rt-thread
项目概览
混口饭吃,
/
rt-thread
与 Fork 源项目一致
Fork自
Mr_Pangza / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1cf8370b
编写于
12月 01, 2021
作者:
B
Bernard Xiong
提交者:
GitHub
12月 01, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5295 from ousugo/addComment
Add dataqueue.c function annotation
上级
d5001ab0
b329611e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
84 addition
and
0 deletion
+84
-0
components/drivers/src/dataqueue.c
components/drivers/src/dataqueue.c
+84
-0
未找到文件。
components/drivers/src/dataqueue.c
浏览文件 @
1cf8370b
...
...
@@ -21,6 +21,23 @@ struct rt_data_item
rt_size_t
data_size
;
};
/**
* @brief This function will initialize the data queue. Calling this function will
* initialize the data queue control block and set the notification callback function.
*
* @param queue is a pointer to the data queue object.
*
* @param size is the maximum number of data in the data queue.
*
* @param lwm is low water mark.
* When the number of data in the data queue is less than this value, this function will
* wake up the thread waiting for write data.
*
* @param evt_notify is the notification callback function.
*
* @return Return the operation status. When the return value is RT_EOK, the initialization is successful.
* When the return value is RT_ENOMEM, it means insufficient memory allocation failed.
*/
rt_err_t
rt_data_queue_init
(
struct
rt_data_queue
*
queue
,
rt_uint16_t
size
,
...
...
@@ -54,6 +71,21 @@ rt_data_queue_init(struct rt_data_queue *queue,
}
RTM_EXPORT
(
rt_data_queue_init
);
/**
* @brief This function will write data to the data queue. If the data queue is full,
* the thread will suspend for the specified amount of time.
*
* @param queue is a pointer to the data queue object.
* .
* @param data_ptr is the buffer pointer of the data to be written.
*
* @param size is the size in bytes of the data to be written.
*
* @param timeout is the waiting time.
*
* @return Return the operation status. When the return value is RT_EOK, the operation is successful.
* When the return value is RT_ETIMEOUT, it means the specified time out.
*/
rt_err_t
rt_data_queue_push
(
struct
rt_data_queue
*
queue
,
const
void
*
data_ptr
,
rt_size_t
data_size
,
...
...
@@ -153,6 +185,24 @@ __exit:
}
RTM_EXPORT
(
rt_data_queue_push
);
/**
* @brief This function will pop data from the data queue. If the data queue is empty,the thread
* will suspend for the specified amount of time.
*
* @note When the number of data in the data queue is less than lwm(low water mark), will
* wake up the thread waiting for write data.
*
* @param queue is a pointer to the data queue object.
*
* @param data_ptr is the buffer pointer of the data to be fetched.
*
* @param size is the size in bytes of the data to be fetched.
*
* @param timeout is the waiting time.
*
* @return Return the operation status. When the return value is RT_EOK, the operation is successful.
* When the return value is RT_ETIMEOUT, it means the specified time out.
*/
rt_err_t
rt_data_queue_pop
(
struct
rt_data_queue
*
queue
,
const
void
**
data_ptr
,
rt_size_t
*
size
,
...
...
@@ -264,6 +314,18 @@ __exit:
}
RTM_EXPORT
(
rt_data_queue_pop
);
/**
* @brief This function will fetch but retaining data in the data queue.
*
* @param queue is a pointer to the data queue object.
*
* @param data_ptr is the buffer pointer of the data to be fetched.
*
* @param size is the size in bytes of the data to be fetched.
*
* @return Return the operation status. When the return value is RT_EOK, the operation is successful.
* When the return value is -RT_EEMPTY, it means the data queue is empty.
*/
rt_err_t
rt_data_queue_peek
(
struct
rt_data_queue
*
queue
,
const
void
**
data_ptr
,
rt_size_t
*
size
)
...
...
@@ -289,6 +351,14 @@ rt_err_t rt_data_queue_peek(struct rt_data_queue *queue,
}
RTM_EXPORT
(
rt_data_queue_peek
);
/**
* @brief This function will reset the data queue.
*
* @note Calling this function will wake up all threads on the data queue
* that are hanging and waiting.
*
* @param queue is a pointer to the data queue object.
*/
void
rt_data_queue_reset
(
struct
rt_data_queue
*
queue
)
{
rt_ubase_t
level
;
...
...
@@ -362,6 +432,13 @@ void rt_data_queue_reset(struct rt_data_queue *queue)
}
RTM_EXPORT
(
rt_data_queue_reset
);
/**
* @brief This function will deinit the data queue.
*
* @param queue is a pointer to the data queue object.
*
* @return Return the operation status. When the return value is RT_EOK, the operation is successful.
*/
rt_err_t
rt_data_queue_deinit
(
struct
rt_data_queue
*
queue
)
{
rt_ubase_t
level
;
...
...
@@ -382,6 +459,13 @@ rt_err_t rt_data_queue_deinit(struct rt_data_queue *queue)
}
RTM_EXPORT
(
rt_data_queue_deinit
);
/**
* @brief This function will get the number of data in the data queue.
*
* @param queue is a pointer to the data queue object.
*
* @return Return the number of data in the data queue.
*/
rt_uint16_t
rt_data_queue_len
(
struct
rt_data_queue
*
queue
)
{
rt_ubase_t
level
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录