Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaobo07
rt-thread
提交
569facb1
R
rt-thread
项目概览
Xiaobo07
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
569facb1
编写于
5月 16, 2022
作者:
mysterywolf
提交者:
guo
5月 19, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[simulator] 增加RTC配置项(默认开启)
上级
e43548f4
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
42 addition
and
39 deletion
+42
-39
bsp/simulator/.config
bsp/simulator/.config
+6
-2
bsp/simulator/Kconfig
bsp/simulator/Kconfig
+12
-1
bsp/simulator/applications/mnt.c
bsp/simulator/applications/mnt.c
+1
-1
bsp/simulator/drivers/SConscript
bsp/simulator/drivers/SConscript
+2
-0
bsp/simulator/drivers/drv_rtc.c
bsp/simulator/drivers/drv_rtc.c
+18
-34
bsp/simulator/rtconfig.h
bsp/simulator/rtconfig.h
+3
-1
未找到文件。
bsp/simulator/.config
浏览文件 @
569facb1
...
...
@@ -164,7 +164,9 @@ CONFIG_RT_SERIAL_RB_BUFSZ=64
# CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NAND is not set
# CONFIG_RT_USING_PM is not set
# CONFIG_RT_USING_RTC is not set
CONFIG_RT_USING_RTC
=
y
# CONFIG_RT_USING_ALARM is not set
# CONFIG_RT_USING_SOFT_RTC is not set
# CONFIG_RT_USING_SDIO is not set
# CONFIG_RT_USING_SPI is not set
# CONFIG_RT_USING_WDT is not set
...
...
@@ -705,8 +707,10 @@ CONFIG_NETDEV_IPV6=0
CONFIG_SOC_SIMULATOR
=
y
#
#
Onboard
Peripheral Drivers
# Peripheral Drivers
#
CONFIG_RT_USING_DFS_WINSHAREDIR
=
y
CONFIG_BSP_USING_RTC
=
y
# CONFIG_BSP_USING_ALARM is not set
CONFIG_BSP_USING_SOCKET
=
y
# CONFIG_BSP_USING_LVGL is not set
bsp/simulator/Kconfig
浏览文件 @
569facb1
...
...
@@ -24,13 +24,24 @@ config SOC_SIMULATOR
select RT_USING_USER_MAIN
default y
menu "
Onboard
Peripheral Drivers"
menu "Peripheral Drivers"
config RT_USING_DFS_WINSHAREDIR
bool "Enable shared file system between Windows"
select RT_USING_POSIX_FS
default y
config BSP_USING_RTC
bool "Enable RTC"
select RT_USING_RTC
default y
config BSP_USING_ALARM
bool "Enable RTC alarm"
select RT_USING_ALARM
depends on BSP_USING_RTC
default n
config BSP_USING_SOCKET
bool "Enable BSD Socket"
select RT_USING_POSIX_FS
...
...
bsp/simulator/applications/mnt.c
浏览文件 @
569facb1
...
...
@@ -42,7 +42,7 @@ static int mnt_init(void)
else
{
LOG_W
(
"[sd0] File System on SD ('sd0') initialization failed!"
);
LOG_W
(
"[sd0] Try to format and re-mount
again
..."
);
LOG_W
(
"[sd0] Try to format and re-mount..."
);
if
(
dfs_mkfs
(
"elm"
,
"sd0"
)
==
0
)
{
if
(
dfs_mount
(
"sd0"
,
"/sd"
,
"elm"
,
0
,
0
)
==
0
)
...
...
bsp/simulator/drivers/SConscript
浏览文件 @
569facb1
...
...
@@ -38,6 +38,8 @@ else:
LIBPATH
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
cwd
,
'../SDL2/lib/x86'
)))
CPPPATH
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
cwd
,
'../SDL2/include'
)))
if
GetDepend
(
'BSP_USING_RTC'
)
==
False
:
SrcRemove
(
src
,
'drv_rtc.c'
)
if
GetDepend
(
'RT_USING_DFS'
)
==
False
or
GetDepend
(
'RT_USING_DFS_ELMFAT'
)
==
False
:
SrcRemove
(
src
,
'sd_sim.c'
)
if
GetDepend
(
'RT_USING_DFS'
)
==
False
or
GetDepend
(
'RT_USING_MTD_NAND'
)
==
False
:
...
...
bsp/simulator/drivers/drv_rtc.c
浏览文件 @
569facb1
...
...
@@ -6,19 +6,15 @@
* Change Logs:
* Date Author Notes
* 2021-04-13 armink the first version
* 2022-05-17 Meco Man improve and beautify
*/
#include <sys/time.h>
#include <string.h>
#include <rtthread.h>
#include <rtdevice.h>
#ifdef RT_USING_RTC
static
struct
rt_device
rtc_dev
;
#ifdef RT_USING_ALARM
#ifdef BSP_USING_ALARM
static
struct
rt_rtc_wkalarm
wkalarm
;
static
struct
rt_timer
alarm_time
;
...
...
@@ -42,15 +38,15 @@ static void soft_rtc_alarm_update(struct rt_rtc_wkalarm *palarm)
rt_timer_stop
(
&
alarm_time
);
}
}
#endif
#endif
/* BSP_USING_ALARM */
static
void
get_rtc_timeval
(
struct
timeval
*
tv
)
{
struct
tm
newtime
=
{
0
};
SYSTEMTIME
sys_time
;
GetSystemTime
(
&
sys_time
);
GetSystemTime
(
&
sys_time
);
/* get RTC from Windows */
newtime
.
tm_year
=
sys_time
.
wYear
-
1900
;
newtime
.
tm_mon
=
sys_time
.
wMonth
-
1
;
newtime
.
tm_mday
=
sys_time
.
wDay
;
...
...
@@ -62,9 +58,8 @@ static void get_rtc_timeval(struct timeval *tv)
tv
->
tv_usec
=
sys_time
.
wMilliseconds
*
1000UL
;
}
static
rt_err_t
soft
_rtc_control
(
rt_device_t
dev
,
int
cmd
,
void
*
args
)
static
rt_err_t
windows
_rtc_control
(
rt_device_t
dev
,
int
cmd
,
void
*
args
)
{
__time32_t
*
t
;
struct
tm
newtime
;
RT_ASSERT
(
dev
!=
RT_NULL
);
...
...
@@ -83,22 +78,24 @@ static rt_err_t soft_rtc_control(rt_device_t dev, int cmd, void *args)
get_rtc_timeval
((
struct
timeval
*
)
args
);
break
;
}
#ifdef BSP_USING_ALARM
case
RT_DEVICE_CTRL_RTC_SET_TIME
:
{
#ifdef RT_USING_ALARM
soft_rtc_alarm_update
(
&
wkalarm
);
#endif
break
;
}
#ifdef RT_USING_ALARM
case
RT_DEVICE_CTRL_RTC_GET_ALARM
:
{
*
((
struct
rt_rtc_wkalarm
*
)
args
)
=
wkalarm
;
break
;
}
case
RT_DEVICE_CTRL_RTC_SET_ALARM
:
{
wkalarm
=
*
((
struct
rt_rtc_wkalarm
*
)
args
);
soft_rtc_alarm_update
(
&
wkalarm
);
break
;
#endif
}
#endif
/* BSP_USING_ALARM */
default:
return
-
RT_ERROR
;
}
...
...
@@ -114,22 +111,16 @@ const static struct rt_device_ops soft_rtc_ops =
RT_NULL
,
RT_NULL
,
RT_NULL
,
soft
_rtc_control
windows
_rtc_control
};
#endif
int
rt_win_rtc_init
(
void
)
int
rt_win
dows
_rtc_init
(
void
)
{
static
rt_bool_t
init_ok
=
RT_FALSE
;
if
(
init_ok
)
{
return
0
;
}
/* make sure only one 'rtc' device */
RT_ASSERT
(
!
rt_device_find
(
"rtc"
));
#ifdef
RT
_USING_ALARM
#ifdef
BSP
_USING_ALARM
rt_timer_init
(
&
alarm_time
,
"alarm"
,
alarm_timeout
,
...
...
@@ -149,18 +140,11 @@ int rt_win_rtc_init(void)
rtc_dev
.
close
=
RT_NULL
;
rtc_dev
.
read
=
RT_NULL
;
rtc_dev
.
write
=
RT_NULL
;
rtc_dev
.
control
=
soft
_rtc_control
;
rtc_dev
.
control
=
windows
_rtc_control
;
#endif
/* no private */
rtc_dev
.
user_data
=
RT_NULL
;
rtc_dev
.
user_data
=
RT_NULL
;
/* no private */
rt_device_register
(
&
rtc_dev
,
"rtc"
,
RT_DEVICE_FLAG_RDWR
);
init_ok
=
RT_TRUE
;
return
0
;
}
INIT_BOARD_EXPORT
(
rt_win_rtc_init
);
#endif
/* RT_USING_RTC */
INIT_BOARD_EXPORT
(
rt_windows_rtc_init
);
bsp/simulator/rtconfig.h
浏览文件 @
569facb1
...
...
@@ -98,6 +98,7 @@
#define RT_USING_SERIAL_V1
#define RT_SERIAL_USING_DMA
#define RT_SERIAL_RB_BUFSZ 64
#define RT_USING_RTC
/* Using USB */
...
...
@@ -217,9 +218,10 @@
#define SOC_SIMULATOR
/*
Onboard
Peripheral Drivers */
/* Peripheral Drivers */
#define RT_USING_DFS_WINSHAREDIR
#define BSP_USING_RTC
#define BSP_USING_SOCKET
#include "rtconfig_project.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录