Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
420478a0
R
rt-thread
项目概览
BaiXuePrincess
/
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看板
未验证
提交
420478a0
编写于
11月 13, 2018
作者:
B
Bernard Xiong
提交者:
GitHub
11月 13, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1973 from Guozhanxin/master
[kernel]修改定时器 hook 函数
上级
ea171911
d343c657
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
8 deletion
+23
-8
include/rtthread.h
include/rtthread.h
+2
-1
src/timer.c
src/timer.c
+21
-7
未找到文件。
include/rtthread.h
浏览文件 @
420478a0
...
...
@@ -100,7 +100,8 @@ rt_tick_t rt_timer_next_timeout_tick(void);
void
rt_timer_check
(
void
);
#ifdef RT_USING_HOOK
void
rt_timer_timeout_sethook
(
void
(
*
hook
)(
struct
rt_timer
*
timer
));
void
rt_timer_enter_sethook
(
void
(
*
hook
)(
struct
rt_timer
*
timer
));
void
rt_timer_exit_sethook
(
void
(
*
hook
)(
struct
rt_timer
*
timer
));
#endif
/**@}*/
...
...
src/timer.c
浏览文件 @
420478a0
...
...
@@ -43,7 +43,8 @@ static rt_uint8_t timer_thread_stack[RT_TIMER_THREAD_STACK_SIZE];
#ifdef RT_USING_HOOK
extern
void
(
*
rt_object_take_hook
)(
struct
rt_object
*
object
);
extern
void
(
*
rt_object_put_hook
)(
struct
rt_object
*
object
);
static
void
(
*
rt_timer_timeout_hook
)(
struct
rt_timer
*
timer
);
static
void
(
*
rt_timer_enter_hook
)(
struct
rt_timer
*
timer
);
static
void
(
*
rt_timer_exit_hook
)(
struct
rt_timer
*
timer
);
/**
* @addtogroup Hook
...
...
@@ -52,14 +53,25 @@ static void (*rt_timer_timeout_hook)(struct rt_timer *timer);
/**@{*/
/**
* This function will set a hook function, which will be invoked when
tim
er
*
is timeout
.
* This function will set a hook function, which will be invoked when
ent
er
*
timer timeout callback function
.
*
* @param hook the hook function
*/
void
rt_timer_
timeout
_sethook
(
void
(
*
hook
)(
struct
rt_timer
*
timer
))
void
rt_timer_
enter
_sethook
(
void
(
*
hook
)(
struct
rt_timer
*
timer
))
{
rt_timer_timeout_hook
=
hook
;
rt_timer_enter_hook
=
hook
;
}
/**
* This function will set a hook function, which will be invoked when exit
* timer timeout callback function.
*
* @param hook the hook function
*/
void
rt_timer_exit_sethook
(
void
(
*
hook
)(
struct
rt_timer
*
timer
))
{
rt_timer_exit_hook
=
hook
;
}
/**@}*/
...
...
@@ -503,7 +515,7 @@ void rt_timer_check(void)
*/
if
((
current_tick
-
t
->
timeout_tick
)
<
RT_TICK_MAX
/
2
)
{
RT_OBJECT_HOOK_CALL
(
rt_timer_
timeout
_hook
,
(
t
));
RT_OBJECT_HOOK_CALL
(
rt_timer_
enter
_hook
,
(
t
));
/* remove timer from timer list firstly */
_rt_timer_remove
(
t
);
...
...
@@ -514,6 +526,7 @@ void rt_timer_check(void)
/* re-get tick */
current_tick
=
rt_tick_get
();
RT_OBJECT_HOOK_CALL
(
rt_timer_exit_hook
,
(
t
));
RT_DEBUG_LOG
(
RT_DEBUG_TIMER
,
(
"current tick: %d
\n
"
,
current_tick
));
if
((
t
->
parent
.
flag
&
RT_TIMER_FLAG_PERIODIC
)
&&
...
...
@@ -578,7 +591,7 @@ void rt_soft_timer_check(void)
*/
if
((
current_tick
-
t
->
timeout_tick
)
<
RT_TICK_MAX
/
2
)
{
RT_OBJECT_HOOK_CALL
(
rt_timer_
timeout
_hook
,
(
t
));
RT_OBJECT_HOOK_CALL
(
rt_timer_
enter
_hook
,
(
t
));
/* move node to the next */
n
=
n
->
next
;
...
...
@@ -594,6 +607,7 @@ void rt_soft_timer_check(void)
/* re-get tick */
current_tick
=
rt_tick_get
();
RT_OBJECT_HOOK_CALL
(
rt_timer_exit_hook
,
(
t
));
RT_DEBUG_LOG
(
RT_DEBUG_TIMER
,
(
"current tick: %d
\n
"
,
current_tick
));
/* lock scheduler */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录