Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Keyboard Man_俊
rt-thread
提交
1874bd25
R
rt-thread
项目概览
Keyboard Man_俊
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / 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,发现更多精彩内容 >>
提交
1874bd25
编写于
1月 16, 2022
作者:
mysterywolf
提交者:
Bernard Xiong
1月 20, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[timer] improve parameter checking
上级
65ecca80
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
12 deletion
+19
-12
components/drivers/src/workqueue.c
components/drivers/src/workqueue.c
+2
-1
src/timer.c
src/timer.c
+17
-11
未找到文件。
components/drivers/src/workqueue.c
浏览文件 @
1874bd25
...
...
@@ -98,7 +98,7 @@ static rt_err_t _workqueue_submit_work(struct rt_workqueue *queue,
/* remove list */
rt_list_remove
(
&
(
work
->
list
));
work
->
flags
&=
~
RT_WORK_STATE_PENDING
;
/* */
if
(
ticks
==
0
)
{
if
(
queue
->
work_current
!=
work
)
...
...
@@ -288,6 +288,7 @@ rt_err_t rt_workqueue_dowork(struct rt_workqueue *queue, struct rt_work *work)
* @param queue A pointer to the workqueue object.
* @param work A pointer to the work item object.
* @param time The delay time (unit: OS ticks) for the work item to be submitted to the work queue.
* The max timeout tick should be no more than (RT_TICK_MAX/2 - 1)
*
* @return RT_EOK Success.
* @return -RT_EBUSY This work item is executing.
...
...
src/timer.c
浏览文件 @
1874bd25
...
...
@@ -246,9 +246,12 @@ void rt_timer_dump(rt_list_t timer_heads[])
*
* @param parameter is the param of the callback
*
* @param time is the ticks of timer
* @param time is timeout ticks of timer
*
* NOTE: The max timeout tick should be no more than (RT_TICK_MAX/2 - 1).
*
* @param flag is the flag of timer
*
*/
void
rt_timer_init
(
rt_timer_t
timer
,
const
char
*
name
,
...
...
@@ -259,6 +262,8 @@ void rt_timer_init(rt_timer_t timer,
{
/* parameter check */
RT_ASSERT
(
timer
!=
RT_NULL
);
RT_ASSERT
(
timeout
!=
RT_NULL
);
RT_ASSERT
(
timer
->
init_tick
<
RT_TICK_MAX
/
2
);
/* timer object initialization */
rt_object_init
(
&
(
timer
->
parent
),
RT_Object_Class_Timer
,
name
);
...
...
@@ -303,15 +308,17 @@ RTM_EXPORT(rt_timer_detach);
/**
* @brief This function will create a timer
*
* @param name the name of timer
* @param name
is
the name of timer
*
* @param timeout the timeout function
* @param timeout
is
the timeout function
*
* @param parameter the parameter of timeout function
* @param parameter
is
the parameter of timeout function
*
* @param time
the tick of
timer
* @param time
is timeout ticks of the
timer
*
* @param flag the flag of timer
* NOTE: The max timeout tick should be no more than (RT_TICK_MAX/2 - 1).
*
* @param flag is the flag of timer
*
* @return the created timer object
*/
...
...
@@ -323,6 +330,10 @@ rt_timer_t rt_timer_create(const char *name,
{
struct
rt_timer
*
timer
;
/* parameter check */
RT_ASSERT
(
timeout
!=
RT_NULL
);
RT_ASSERT
(
timer
->
init_tick
<
RT_TICK_MAX
/
2
);
/* allocate a object */
timer
=
(
struct
rt_timer
*
)
rt_object_allocate
(
RT_Object_Class_Timer
,
name
);
if
(
timer
==
RT_NULL
)
...
...
@@ -401,11 +412,6 @@ rt_err_t rt_timer_start(rt_timer_t timer)
RT_OBJECT_HOOK_CALL
(
rt_object_take_hook
,
(
&
(
timer
->
parent
)));
/*
* get timeout tick,
* the max timeout tick shall not great than RT_TICK_MAX/2
*/
RT_ASSERT
(
timer
->
init_tick
<
RT_TICK_MAX
/
2
);
timer
->
timeout_tick
=
rt_tick_get
()
+
timer
->
init_tick
;
#ifdef RT_USING_TIMER_SOFT
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录