Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2345VOR
rt-thread
提交
db9b5fb5
R
rt-thread
项目概览
2345VOR
/
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,发现更多精彩内容 >>
未验证
提交
db9b5fb5
编写于
3月 07, 2021
作者:
B
Bernard Xiong
提交者:
GitHub
3月 07, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4423 from mysterywolf/examples
[example] 格式化整理
上级
ecb1798b
08af426f
变更
30
显示空白变更内容
内联
并排
Showing
30 changed file
with
1132 addition
and
1132 deletion
+1132
-1132
examples/file/listdir.c
examples/file/listdir.c
+1
-1
examples/file/readspeed.c
examples/file/readspeed.c
+3
-3
examples/file/readwrite.c
examples/file/readwrite.c
+104
-104
examples/file/seekdir.c
examples/file/seekdir.c
+26
-26
examples/file/writespeed.c
examples/file/writespeed.c
+1
-1
examples/kernel/tc_comm.h
examples/kernel/tc_comm.h
+1
-1
examples/kernel/timer_control.c
examples/kernel/timer_control.c
+1
-1
examples/kernel/timer_timeout.c
examples/kernel/timer_timeout.c
+34
-34
examples/libc/dirent.c
examples/libc/dirent.c
+41
-41
examples/libc/env.c
examples/libc/env.c
+4
-4
examples/libc/ex1.c
examples/libc/ex1.c
+17
-17
examples/libc/ex6.c
examples/libc/ex6.c
+19
-19
examples/libc/ex7.c
examples/libc/ex7.c
+73
-73
examples/libc/file.c
examples/libc/file.c
+484
-484
examples/libc/memory.c
examples/libc/memory.c
+27
-27
examples/libc/mq.c
examples/libc/mq.c
+81
-81
examples/libc/printf.c
examples/libc/printf.c
+29
-29
examples/libc/rand.c
examples/libc/rand.c
+28
-28
examples/libc/sem.c
examples/libc/sem.c
+41
-41
examples/libc/time.c
examples/libc/time.c
+7
-7
examples/network/tcpsendpacket.c
examples/network/tcpsendpacket.c
+2
-2
examples/pm/timer_app.c
examples/pm/timer_app.c
+1
-1
examples/pm/wakeup_app.c
examples/pm/wakeup_app.c
+1
-1
examples/test/dhry.h
examples/test/dhry.h
+23
-23
examples/test/dhry_1.c
examples/test/dhry_1.c
+21
-21
examples/test/dhry_2.c
examples/test/dhry_2.c
+6
-6
examples/test/hwtimer_test.c
examples/test/hwtimer_test.c
+11
-11
examples/test/net_test.c
examples/test/net_test.c
+25
-25
examples/test/rtc_test.c
examples/test/rtc_test.c
+19
-19
examples/ulog/ulog_example.c
examples/ulog/ulog_example.c
+1
-1
未找到文件。
examples/file/listdir.c
浏览文件 @
db9b5fb5
/*
* Copyright (c) 2006-202
0
, RT-Thread Development Team
* Copyright (c) 2006-202
1
, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
...
...
examples/file/readspeed.c
浏览文件 @
db9b5fb5
/*
* Copyright (c) 2006-202
0
, RT-Thread Development Team
* Copyright (c) 2006-202
1
, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
...
...
examples/file/readwrite.c
浏览文件 @
db9b5fb5
/*
* Copyright (c) 2006-202
0
, RT-Thread Development Team
* Copyright (c) 2006-202
1
, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
...
...
examples/file/seekdir.c
浏览文件 @
db9b5fb5
/*
* Copyright (c) 2006-202
0
, RT-Thread Development Team
* Copyright (c) 2006-202
1
, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
...
...
examples/file/writespeed.c
浏览文件 @
db9b5fb5
/*
* Copyright (c) 2006-202
0
, RT-Thread Development Team
* Copyright (c) 2006-202
1
, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
...
...
examples/kernel/tc_comm.h
浏览文件 @
db9b5fb5
examples/kernel/timer_control.c
浏览文件 @
db9b5fb5
examples/kernel/timer_timeout.c
浏览文件 @
db9b5fb5
/*
*
程序清单:消息队列例程
*
程序清单:消息队列例程
*
*
这个程序会创建3个动态线程,一个线程会从消息队列中收取消息;一个线程会定时给消
*
息队列发送消息;一个线程会定时给消息队列发送紧急消息。
*
这个程序会创建3个动态线程,一个线程会从消息队列中收取消息;一个线程会定时给消
*
息队列发送消息;一个线程会定时给消息队列发送紧急消息。
*/
#include <rtthread.h>
#include "tc_comm.h"
/*
指向线程控制块的指针
*/
/*
指向线程控制块的指针 */
static
rt_thread_t
tid
=
RT_NULL
;
/*
消息队列控制块
*/
/*
消息队列控制块 */
static
struct
rt_messagequeue
mq
;
/*
消息队列中用到的放置消息的内存池
*/
/*
消息队列中用到的放置消息的内存池 */
static
char
msg_pool
[
2048
];
/*
定时器的控制块
*/
/*
定时器的控制块 */
static
struct
rt_timer
timer
;
static
rt_uint16_t
no
=
0
;
static
void
timer_timeout
(
void
*
parameter
)
...
...
@@ -27,24 +27,24 @@ static void timer_timeout(void* parameter)
rt_mq_send
(
&
mq
,
&
buf
[
0
],
length
);
}
/*
线程入口函数
*/
/*
线程入口函数 */
static
void
thread_entry
(
void
*
parameter
)
{
char
buf
[
64
];
rt_err_t
result
;
/*
初始化定时器
*/
rt_timer_init
(
&
timer
,
"timer"
,
/*
定时器名字是
timer1 */
timer_timeout
,
/*
超时时回调的处理函数
*/
RT_NULL
,
/*
超时函数的入口参数
*/
1
,
/*
定时长度,以OS Tick为单位,即1个
OS Tick */
RT_TIMER_FLAG_PERIODIC
);
/*
周期性定时器
*/
/*
初始化定时器 */
rt_timer_init
(
&
timer
,
"timer"
,
/*
定时器名字是 ti
mer1 */
timer_timeout
,
/*
超时时回调的处理函数 */
RT_NULL
,
/*
超时函数的入口参数 */
1
,
/*
定时长度,以OS Tick为单位,即1个OS T
ick */
RT_TIMER_FLAG_PERIODIC
);
/*
周期性定时器 */
while
(
1
)
{
rt_memset
(
&
buf
[
0
],
0
,
sizeof
(
buf
));
/*
从消息队列中接收消息
*/
/*
从消息队列中接收消息 */
result
=
rt_mq_recv
(
&
mq
,
&
buf
[
0
],
sizeof
(
buf
),
1
);
if
(
result
==
RT_EOK
)
{
...
...
@@ -59,16 +59,16 @@ static void thread_entry(void* parameter)
int
timer_timeout_init
()
{
/*
初始化消息队列
*/
/*
初始化消息队列 */
rt_mq_init
(
&
mq
,
"mqt"
,
&
msg_pool
[
0
],
/*
内存池指向msg_pool */
128
-
sizeof
(
void
*
),
/*
每个消息的大小是
128 - void* */
sizeof
(
msg_pool
),
/*
内存池的大小是msg_pool的大小
*/
RT_IPC_FLAG_FIFO
);
/*
如果有多个线程等待,按照先来先得到的方法分配消息
*/
&
msg_pool
[
0
],
/*
内存池指向msg_pool */
128
-
sizeof
(
void
*
),
/*
每个消息的大小是 128
- void* */
sizeof
(
msg_pool
),
/*
内存池的大小是msg_pool的大小 */
RT_IPC_FLAG_FIFO
);
/*
如果有多个线程等待,按照先来先得到的方法分配消息 */
/*
创建线程
*/
/*
创建线程 *
/
tid
=
rt_thread_create
(
"t"
,
thread_entry
,
RT_NULL
,
/*
线程入口是thread_entry, 入口参数是R
T_NULL */
thread_entry
,
RT_NULL
,
/*
线程入口是thread_entry, 入口参数是RT_NU
LL */
THREAD_STACK_SIZE
,
THREAD_PRIORITY
,
THREAD_TIMESLICE
);
if
(
tid
!=
RT_NULL
)
rt_thread_startup
(
tid
);
...
...
@@ -81,38 +81,38 @@ int timer_timeout_init()
#ifdef RT_USING_TC
static
void
_tc_cleanup
()
{
/*
调度器上锁,上锁后,将不再切换到其他线程,仅响应中断
*/
/*
调度器上锁,上锁后,将不再切换到其他线程,仅响应中断 */
rt_enter_critical
();
/*
删除线程
*/
/*
删除线程 *
/
if
(
tid
!=
RT_NULL
&&
tid
->
stat
!=
RT_THREAD_CLOSE
)
rt_thread_delete
(
tid
);
/*
执行消息队列对象脱离
*/
/*
执行消息队列对象脱离 */
rt_mq_detach
(
&
mq
);
/*
执行定时器脱离
*/
/*
执行定时器脱离 */
rt_timer_detach
(
&
timer
);
/*
调度器解锁
*/
/*
调度器解锁 *
/
rt_exit_critical
();
/*
设置TestCase状态
*/
/*
设置TestCase状态
*/
tc_done
(
TC_STAT_PASSED
);
}
int
_tc_timer_timeout
()
{
/*
设置TestCase清理回调函数
*/
/*
设置TestCase清理回调函数 */
tc_cleanup
(
_tc_cleanup
);
timer_timeout_init
();
/*
返回TestCase运行的最长时间
*/
/*
返回TestCase运行的最长时间 */
return
100
;
}
/*
输出函数命令到finsh shell中
*/
/*
输出函数命令到finsh shell中 */
FINSH_FUNCTION_EXPORT
(
_tc_timer_timeout
,
a
thread
timer
testcase
);
#else
/*
用户应用入口
*/
/*
用户应用入口 */
int
rt_application_init
()
{
timer_timeout_init
();
...
...
examples/libc/dirent.c
浏览文件 @
db9b5fb5
examples/libc/env.c
浏览文件 @
db9b5fb5
examples/libc/ex1.c
浏览文件 @
db9b5fb5
examples/libc/ex6.c
浏览文件 @
db9b5fb5
examples/libc/ex7.c
浏览文件 @
db9b5fb5
examples/libc/file.c
浏览文件 @
db9b5fb5
examples/libc/memory.c
浏览文件 @
db9b5fb5
examples/libc/mq.c
浏览文件 @
db9b5fb5
examples/libc/printf.c
浏览文件 @
db9b5fb5
examples/libc/rand.c
浏览文件 @
db9b5fb5
examples/libc/sem.c
浏览文件 @
db9b5fb5
examples/libc/time.c
浏览文件 @
db9b5fb5
examples/network/tcpsendpacket.c
浏览文件 @
db9b5fb5
examples/pm/timer_app.c
浏览文件 @
db9b5fb5
/*
* Copyright (c) 2006-20
18
, RT-Thread Development Team
* Copyright (c) 2006-20
21
, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
...
...
examples/pm/wakeup_app.c
浏览文件 @
db9b5fb5
/*
* Copyright (c) 2006-20
18
, RT-Thread Development Team
* Copyright (c) 2006-20
21
, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
...
...
examples/test/dhry.h
浏览文件 @
db9b5fb5
examples/test/dhry_1.c
浏览文件 @
db9b5fb5
examples/test/dhry_2.c
浏览文件 @
db9b5fb5
examples/test/hwtimer_test.c
浏览文件 @
db9b5fb5
...
...
@@ -35,8 +35,8 @@ int hwtimer(void)
return
-
1
;
}
/*
时间测量
*/
/*
计数时钟设置(默认1Mhz或支持的最小计数频率
) */
/*
时间测量 *
/
/*
计数时钟设置(默认1Mhz或支持的最小计数频率) */
err
=
rt_device_control
(
dev
,
HWTIMER_CTRL_FREQ_SET
,
&
freq
);
if
(
err
!=
RT_EOK
)
{
...
...
@@ -44,13 +44,13 @@ int hwtimer(void)
goto
EXIT
;
}
/*
周期模式
*/
/*
周期模式 *
/
mode
=
HWTIMER_MODE_PERIOD
;
err
=
rt_device_control
(
dev
,
HWTIMER_CTRL_MODE_SET
,
&
mode
);
tick
=
rt_tick_get
();
rt_kprintf
(
"Start Timer> Tick: %d
\n
"
,
tick
);
/*
设置定时器超时值并启动定时器
*/
/*
设置定时器超时值并启动定时器 */
val
.
sec
=
t
;
val
.
usec
=
0
;
rt_kprintf
(
"SetTime: Sec %d, Usec %d
\n
"
,
val
.
sec
,
val
.
usec
);
...
...
@@ -62,22 +62,22 @@ int hwtimer(void)
rt_kprintf
(
"Sleep %d sec
\n
"
,
t
);
rt_thread_delay
(
t
*
RT_TICK_PER_SECOND
);
/*
停止定时器
*/
/*
停止定时器 *
/
err
=
rt_device_control
(
dev
,
HWTIMER_CTRL_STOP
,
RT_NULL
);
rt_kprintf
(
"Timer Stoped
\n
"
);
/*
读取计数
*/
/*
读取计数 *
/
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
);
...
...
@@ -87,7 +87,7 @@ int hwtimer(void)
goto
EXIT
;
}
/*
等待回调函数执行
*/
/*
等待回调函数执行 */
rt_thread_delay
((
t
+
1
)
*
RT_TICK_PER_SECOND
);
EXIT:
...
...
examples/test/net_test.c
浏览文件 @
db9b5fb5
examples/test/rtc_test.c
浏览文件 @
db9b5fb5
examples/ulog/ulog_example.c
浏览文件 @
db9b5fb5
/*
* Copyright (c) 2006-20
18
, RT-Thread Development Team
* Copyright (c) 2006-20
21
, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录