Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
okll00
rt-thread
提交
e1ae4706
R
rt-thread
项目概览
okll00
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e1ae4706
编写于
11月 08, 2016
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/RT-Thread/rt-thread
上级
2d7486fc
90f1939e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
27 deletion
+14
-27
components/drivers/include/rtdevice.h
components/drivers/include/rtdevice.h
+0
-1
components/drivers/src/dataqueue.c
components/drivers/src/dataqueue.c
+14
-26
未找到文件。
components/drivers/include/rtdevice.h
浏览文件 @
e1ae4706
...
...
@@ -134,7 +134,6 @@ struct rt_data_queue
{
rt_uint16_t
size
;
rt_uint16_t
lwm
;
rt_bool_t
waiting_lwm
;
rt_uint16_t
get_index
;
rt_uint16_t
put_index
;
...
...
components/drivers/src/dataqueue.c
浏览文件 @
e1ae4706
...
...
@@ -20,6 +20,7 @@
* Change Logs:
* Date Author Notes
* 2012-09-30 Bernard first version.
* 2016-10-31 armink fix some resume push and pop thread bugs
*/
#include <rtthread.h>
...
...
@@ -44,7 +45,6 @@ rt_data_queue_init(struct rt_data_queue *queue,
queue
->
size
=
size
;
queue
->
lwm
=
lwm
;
queue
->
waiting_lwm
=
RT_FALSE
;
queue
->
get_index
=
0
;
queue
->
put_index
=
0
;
...
...
@@ -67,7 +67,6 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
rt_size_t
data_size
,
rt_int32_t
timeout
)
{
rt_uint16_t
mask
;
rt_ubase_t
level
;
rt_thread_t
thread
;
rt_err_t
result
;
...
...
@@ -76,13 +75,10 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
result
=
RT_EOK
;
thread
=
rt_thread_self
();
mask
=
queue
->
size
-
1
;
level
=
rt_hw_interrupt_disable
();
while
(
queue
->
put_index
-
queue
->
get_index
==
queue
->
size
)
{
queue
->
waiting_lwm
=
RT_TRUE
;
/* queue is full */
if
(
timeout
==
0
)
{
...
...
@@ -122,14 +118,13 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue,
if
(
result
!=
RT_EOK
)
goto
__exit
;
}
queue
->
queue
[
queue
->
put_index
&
mask
].
data_ptr
=
data_ptr
;
queue
->
queue
[
queue
->
put_index
&
mask
].
data_size
=
data_size
;
queue
->
queue
[
queue
->
put_index
%
queue
->
size
].
data_ptr
=
data_ptr
;
queue
->
queue
[
queue
->
put_index
%
queue
->
size
].
data_size
=
data_size
;
queue
->
put_index
+=
1
;
/* there is at least one thread in suspended list */
if
(
!
rt_list_isempty
(
&
(
queue
->
suspended_pop_list
)))
{
/* there is at least one thread in suspended list */
/* get thread entry */
thread
=
rt_list_entry
(
queue
->
suspended_pop_list
.
next
,
struct
rt_thread
,
...
...
@@ -164,7 +159,6 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
rt_ubase_t
level
;
rt_thread_t
thread
;
rt_err_t
result
;
rt_uint16_t
mask
;
RT_ASSERT
(
queue
!=
RT_NULL
);
RT_ASSERT
(
data_ptr
!=
RT_NULL
);
...
...
@@ -172,7 +166,6 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
result
=
RT_EOK
;
thread
=
rt_thread_self
();
mask
=
queue
->
size
-
1
;
level
=
rt_hw_interrupt_disable
();
while
(
queue
->
get_index
==
queue
->
put_index
)
...
...
@@ -216,20 +209,14 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
goto
__exit
;
}
*
data_ptr
=
queue
->
queue
[
queue
->
get_index
&
mask
].
data_ptr
;
*
size
=
queue
->
queue
[
queue
->
get_index
&
mask
].
data_size
;
*
data_ptr
=
queue
->
queue
[
queue
->
get_index
%
queue
->
size
].
data_ptr
;
*
size
=
queue
->
queue
[
queue
->
get_index
%
queue
->
size
].
data_size
;
queue
->
get_index
+=
1
;
if
((
queue
->
waiting_lwm
==
RT_TRUE
)
&&
(
queue
->
put_index
-
queue
->
get_index
)
<=
queue
->
lwm
)
if
((
queue
->
put_index
-
queue
->
get_index
)
<=
queue
->
lwm
)
{
queue
->
waiting_lwm
=
RT_FALSE
;
/*
* there is at least one thread in suspended list
* and less than low water mark
*/
/* there is at least one thread in suspended list */
if
(
!
rt_list_isempty
(
&
(
queue
->
suspended_push_list
)))
{
/* get thread entry */
...
...
@@ -244,6 +231,10 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue,
/* perform a schedule */
rt_schedule
();
}
else
{
rt_hw_interrupt_enable
(
level
);
}
if
(
queue
->
evt_notify
!=
RT_NULL
)
queue
->
evt_notify
(
queue
,
RT_DATAQUEUE_EVENT_LWM
);
...
...
@@ -267,12 +258,9 @@ rt_err_t rt_data_queue_peak(struct rt_data_queue *queue,
rt_size_t
*
size
)
{
rt_ubase_t
level
;
rt_uint16_t
mask
;
RT_ASSERT
(
queue
!=
RT_NULL
);
mask
=
queue
->
size
-
1
;
level
=
rt_hw_interrupt_disable
();
if
(
queue
->
get_index
==
queue
->
put_index
)
...
...
@@ -282,8 +270,8 @@ rt_err_t rt_data_queue_peak(struct rt_data_queue *queue,
return
-
RT_EEMPTY
;
}
*
data_ptr
=
queue
->
queue
[
queue
->
get_index
&
mask
].
data_ptr
;
*
size
=
queue
->
queue
[
queue
->
get_index
&
mask
].
data_size
;
*
data_ptr
=
queue
->
queue
[
queue
->
get_index
%
queue
->
size
].
data_ptr
;
*
size
=
queue
->
queue
[
queue
->
get_index
%
queue
->
size
].
data_size
;
rt_hw_interrupt_enable
(
level
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录