Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Mr_Pangza
rt-thread
提交
ebc14b09
R
rt-thread
项目概览
Mr_Pangza
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
1
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
ebc14b09
编写于
1月 02, 2019
作者:
armink_ztl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[example] Sync to latest version.
上级
77623e81
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
6 deletion
+28
-6
examples/pm/timer_app.c
examples/pm/timer_app.c
+1
-1
examples/test/hwtimer_test.c
examples/test/hwtimer_test.c
+26
-4
include/rtdef.h
include/rtdef.h
+1
-1
未找到文件。
examples/pm/timer_app.c
浏览文件 @
ebc14b09
...
...
@@ -48,7 +48,7 @@ static int timer_app_init(void)
return
-
1
;
}
}
INIT_
EXPORT_APP
(
timer_app_init
);
INIT_
APP_EXPORT
(
timer_app_init
);
#endif
/* RT_USING_PM */
examples/test/hwtimer_test.c
浏览文件 @
ebc14b09
...
...
@@ -8,7 +8,7 @@
static
rt_err_t
timer_timeout_cb
(
rt_device_t
dev
,
rt_size_t
size
)
{
rt_kprintf
(
"
HT %d
\n
"
,
rt_tick_get
()
);
rt_kprintf
(
"
enter hardware timer isr
\n
"
);
return
0
;
}
...
...
@@ -35,7 +35,7 @@ int hwtimer(void)
return
-
1
;
}
rt_device_set_rx_indicate
(
dev
,
timer_timeout_cb
);
/* 时间测量 */
/* 计数时钟设置(默认1Mhz或支持的最小计数频率) */
err
=
rt_device_control
(
dev
,
HWTIMER_CTRL_FREQ_SET
,
&
freq
);
if
(
err
!=
RT_EOK
)
...
...
@@ -69,12 +69,34 @@ int hwtimer(void)
rt_device_read
(
dev
,
0
,
&
val
,
sizeof
(
val
));
rt_kprintf
(
"Read: Sec = %d, Usec = %d
\n
"
,
val
.
sec
,
val
.
usec
);
/* 定时执行回调函数 -- 单次模式 */
/* 设置超时回调函数 */
rt_device_set_rx_indicate
(
dev
,
timer_timeout_cb
);
/* 单次模式 */
mode
=
HWTIMER_MODE_PERIOD
;
err
=
rt_device_control
(
dev
,
HWTIMER_CTRL_MODE_SET
,
&
mode
);
/* 设置定时器超时值并启动定时器 */
val
.
sec
=
t
;
val
.
usec
=
0
;
rt_kprintf
(
"SetTime: Sec %d, Usec %d
\n
"
,
val
.
sec
,
val
.
usec
);
if
(
rt_device_write
(
dev
,
0
,
&
val
,
sizeof
(
val
))
!=
sizeof
(
val
))
{
rt_kprintf
(
"SetTime Fail
\n
"
);
goto
EXIT
;
}
/* 等待回调函数执行 */
rt_thread_delay
((
t
+
1
)
*
RT_TICK_PER_SECOND
);
EXIT:
err
=
rt_device_close
(
dev
);
rt_kprintf
(
"Close %s
\n
"
,
TIMER
);
return
err
;
}
FINSH_FUNCTION
_EXPORT
(
hwtimer
,
"Test hardware timer"
);
#ifdef FINSH_USING_MSH
MSH_CMD
_EXPORT
(
hwtimer
,
"Test hardware timer"
);
#endif
#endif
/* RT_USING_HWTIMER */
include/rtdef.h
浏览文件 @
ebc14b09
...
...
@@ -77,7 +77,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define RT_TRUE 1
/**< boolean true */
#define RT_FALSE 0
/**< boolean fails */
/*@}*/
/*
*
@}*/
/* maximum value of base type */
#define RT_UINT8_MAX 0xff
/**< Maxium number of UINT8 */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录