Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
AdRainty
rt-thread
提交
2236024d
R
rt-thread
项目概览
AdRainty
/
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,发现更多精彩内容 >>
提交
2236024d
编写于
4月 01, 2019
作者:
W
wangyq2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp/es32f0654] add rtc driver
上级
1e1c73c7
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
199 addition
and
7 deletion
+199
-7
bsp/es32f0654/.config
bsp/es32f0654/.config
+5
-0
bsp/es32f0654/README.md
bsp/es32f0654/README.md
+1
-0
bsp/es32f0654/drivers/Kconfig
bsp/es32f0654/drivers/Kconfig
+7
-0
bsp/es32f0654/drivers/SConscript
bsp/es32f0654/drivers/SConscript
+4
-0
bsp/es32f0654/drivers/drv_rtc.c
bsp/es32f0654/drivers/drv_rtc.c
+157
-0
bsp/es32f0654/drivers/drv_rtc.h
bsp/es32f0654/drivers/drv_rtc.h
+16
-0
bsp/es32f0654/libraries/SConscript
bsp/es32f0654/libraries/SConscript
+5
-6
bsp/es32f0654/rtconfig.h
bsp/es32f0654/rtconfig.h
+3
-0
bsp/es32f0654/rtconfig.py
bsp/es32f0654/rtconfig.py
+1
-1
未找到文件。
bsp/es32f0654/.config
浏览文件 @
2236024d
...
...
@@ -354,6 +354,11 @@ CONFIG_BSP_USING_UART2=y
# CONFIG_BSP_USING_HWTIMER2 is not set
# CONFIG_BSP_USING_HWTIMER3 is not set
#
# RTC Drivers
#
# CONFIG_BSP_USING_RTC is not set
#
# Onboard Peripheral Drivers
#
...
...
bsp/es32f0654/README.md
浏览文件 @
2236024d
...
...
@@ -42,6 +42,7 @@ ES-PDS-ES32F0654-V1.1
| I2C | 支持 | I2C0/1 |
| PWM | 支持 | PWM0/1/2/3 |
| TIMER | 支持 | TIMER0/1/2/3 |
| RTC | 支持 | RTC |
### 1.2 注意事项
...
...
bsp/es32f0654/drivers/Kconfig
浏览文件 @
2236024d
...
...
@@ -102,6 +102,13 @@ menu "Hardware Drivers Config"
default n
endmenu
menu "RTC Drivers"
config BSP_USING_RTC
bool "Using RTC"
select RT_USING_RTC
default n
endmenu
endmenu
menu "Onboard Peripheral Drivers"
...
...
bsp/es32f0654/drivers/SConscript
浏览文件 @
2236024d
...
...
@@ -35,6 +35,10 @@ if GetDepend('BSP_USING_PWM0') or GetDepend('BSP_USING_PWM1') or GetDepend('BSP_
if
GetDepend
(
'BSP_USING_HWTIMER0'
)
or
GetDepend
(
'BSP_USING_HWTIMER1'
)
or
GetDepend
(
'BSP_USING_HWTIMER2'
)
or
GetDepend
(
'BSP_USING_HWTIMER3'
):
src
+=
[
'drv_hwtimer.c'
]
# add rtc driver code
if
GetDepend
([
'BSP_USING_RTC'
]):
src
+=
[
'drv_rtc.c'
]
CPPPATH
=
[
cwd
]
group
=
DefineGroup
(
'Drivers'
,
src
,
depend
=
[
''
],
CPPPATH
=
CPPPATH
)
...
...
bsp/es32f0654/drivers/drv_rtc.c
0 → 100644
浏览文件 @
2236024d
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-03-22 wangyq the first version
*/
#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>
#include <string.h>
#include "board.h"
#include "drv_rtc.h"
#include <ald_cmu.h>
#include <ald_rtc.h>
#ifdef RT_USING_RTC
static
void
rtc_init
(
rtc_init_t
*
init
)
{
assert_param
(
IS_RTC_HOUR_FORMAT
(
init
->
hour_format
));
assert_param
(
IS_RTC_OUTPUT_SEL
(
init
->
output
));
assert_param
(
IS_RTC_OUTPUT_POLARITY
(
init
->
output_polarity
));
rtc_reset
();
RTC_UNLOCK
();
MODIFY_REG
(
RTC
->
CON
,
RTC_CON_HFM_MSK
,
init
->
hour_format
<<
RTC_CON_HFM_POS
);
MODIFY_REG
(
RTC
->
CON
,
RTC_CON_EOS_MSK
,
init
->
output
<<
RTC_CON_EOS_POSS
);
MODIFY_REG
(
RTC
->
CON
,
RTC_CON_POL_MSK
,
init
->
output_polarity
<<
RTC_CON_POL_POS
);
MODIFY_REG
(
RTC
->
PSR
,
RTC_PSR_SPRS_MSK
,
init
->
synch_pre_div
<<
RTC_PSR_SPRS_POSS
);
MODIFY_REG
(
RTC
->
PSR
,
RTC_PSR_APRS_MSK
,
init
->
asynch_pre_div
<<
RTC_PSR_APRS_POSS
);
RTC_LOCK
();
return
;
}
static
rt_err_t
es32f0_rtc_control
(
rt_device_t
dev
,
int
cmd
,
void
*
args
)
{
rt_err_t
result
=
RT_EOK
;
struct
tm
time_temp
;
struct
tm
*
pNow
;
rtc_date_t
date
;
rtc_time_t
time
;
switch
(
cmd
)
{
case
RT_DEVICE_CTRL_RTC_GET_TIME
:
rtc_get_date_time
(
&
date
,
&
time
,
RTC_FORMAT_DEC
);
time_temp
.
tm_sec
=
time
.
second
;
time_temp
.
tm_min
=
time
.
minute
;
time_temp
.
tm_hour
=
time
.
hour
;
time_temp
.
tm_mday
=
date
.
day
;
time_temp
.
tm_mon
=
date
.
month
-
1
;
time_temp
.
tm_year
=
date
.
year
-
1900
+
2000
;
*
((
time_t
*
)
args
)
=
mktime
(
&
time_temp
);
break
;
case
RT_DEVICE_CTRL_RTC_SET_TIME
:
rt_enter_critical
();
/* converts calendar time time into local time. */
pNow
=
localtime
((
const
time_t
*
)
args
);
/* copy the statically located variable */
memcpy
(
&
time_temp
,
pNow
,
sizeof
(
struct
tm
));
/* unlock scheduler. */
rt_exit_critical
();
time
.
hour
=
time_temp
.
tm_hour
;
time
.
minute
=
time_temp
.
tm_min
;
time
.
second
=
time_temp
.
tm_sec
;
date
.
year
=
time_temp
.
tm_year
+
1900
-
2000
;
date
.
month
=
time_temp
.
tm_mon
+
1
;
date
.
day
=
time_temp
.
tm_mday
;
rtc_set_time
(
&
time
,
RTC_FORMAT_DEC
);
rtc_set_date
(
&
date
,
RTC_FORMAT_DEC
);
/* start RTC */
RTC_UNLOCK
();
SET_BIT
(
RTC
->
CON
,
RTC_CON_GO_MSK
);
RTC_LOCK
();
break
;
case
RT_DEVICE_CTRL_RTC_GET_ALARM
:
break
;
case
RT_DEVICE_CTRL_RTC_SET_ALARM
:
break
;
default:
break
;
}
return
result
;
}
#ifdef RT_USING_DEVICE_OPS
const
static
struct
rt_device_ops
es32f0_rtc_ops
=
{
RT_NULL
,
RT_NULL
,
RT_NULL
,
RT_NULL
,
RT_NULL
,
es32f0_rtc_control
};
#endif
int
rt_hw_rtc_init
(
void
)
{
rt_err_t
ret
=
RT_EOK
;
static
struct
rt_device
rtc_dev
;
rtc_init_t
rtc_initstruct
;
/* enable external 32.768kHz */
CMU_LOSC_ENABLE
();
cmu_losc_safe_config
(
ENABLE
);
/* set default time */
RTC_UNLOCK
();
WRITE_REG
(
RTC
->
TIME
,
0x134251
);
WRITE_REG
(
RTC
->
DATE
,
0x1190401
);
RTC_LOCK
();
/* RTC function initialization */
rtc_initstruct
.
hour_format
=
RTC_HOUR_FORMAT_24
;
rtc_initstruct
.
asynch_pre_div
=
0
;
rtc_initstruct
.
synch_pre_div
=
32767
;
rtc_initstruct
.
output
=
RTC_OUTPUT_DISABLE
;
rtc_init
(
&
rtc_initstruct
);
rtc_dev
.
type
=
RT_Device_Class_RTC
;
rtc_dev
.
rx_indicate
=
RT_NULL
;
rtc_dev
.
tx_complete
=
RT_NULL
;
#ifdef RT_USING_DEVICE_OPS
rtc_dev
.
ops
=
&
es32f0_rtc_ops
;
#else
rtc_dev
.
init
=
RT_NULL
;
rtc_dev
.
open
=
RT_NULL
;
rtc_dev
.
close
=
RT_NULL
;
rtc_dev
.
read
=
RT_NULL
;
rtc_dev
.
write
=
RT_NULL
;
rtc_dev
.
control
=
es32f0_rtc_control
;
#endif
rtc_dev
.
user_data
=
RTC
;
ret
=
rt_device_register
(
&
rtc_dev
,
"rtc"
,
RT_DEVICE_FLAG_RDWR
);
return
ret
;
}
INIT_DEVICE_EXPORT
(
rt_hw_rtc_init
);
#endif
bsp/es32f0654/drivers/drv_rtc.h
0 → 100644
浏览文件 @
2236024d
/*
* Copyright (C) 2018 Shanghai Eastsoft Microelectronics Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2019-03-22 wangyq the first version
*/
#ifndef DRV_RTC_H__
#define DRV_RTC_H__
int
rt_hw_rtc_init
(
void
);
#endif
bsp/es32f0654/libraries/SConscript
浏览文件 @
2236024d
...
...
@@ -10,18 +10,17 @@ src = []
src
+=
Glob
(
'ES32F065x_ALD_StdPeriph_Driver/Source/*.c'
)
#add for startup script
#add for startup script
if
rtconfig
.
CROSS_TOOL
==
'gcc'
:
src
=
src
+
[
'CMSIS/Device/EastSoft/ES32F065x/Startup/gcc/startup_es32f065x.s'
]
elif
rtconfig
.
CROSS_TOOL
==
'keil'
:
src
=
src
+
[
'CMSIS/Device/EastSoft/ES32F065x/Startup/keil/startup_es32f065x.s'
]
elif
rtconfig
.
CROSS_TOOL
==
'iar'
:
src
=
src
+
[
'CMSIS/Device/EastSoft/ES32F065x/Startup/iar/startup_es32f065x.s'
]
src
=
src
+
[
'CMSIS/Device/EastSoft/ES32F065x/Startup/iar/startup_es32f065x.s'
]
path
=
[
cwd
+
'/CMSIS/Device/EastSoft/ES32F065x/Include'
,
cwd
+
'/CMSIS/Include'
,
cwd
+
'/ES32F065x_ALD_StdPeriph_Driver/Include'
]
path
=
[
cwd
+
'/CMSIS/Device/EastSoft/ES32F065x/Include'
,
cwd
+
'/CMSIS/Include'
,
cwd
+
'/ES32F065x_ALD_StdPeriph_Driver/Include'
]
group
=
DefineGroup
(
'Libraries'
,
src
,
depend
=
[
''
],
CPPPATH
=
path
)
...
...
bsp/es32f0654/rtconfig.h
浏览文件 @
2236024d
...
...
@@ -175,6 +175,9 @@
/* HWtimer Drivers */
/* RTC Drivers */
/* Onboard Peripheral Drivers */
...
...
bsp/es32f0654/rtconfig.py
浏览文件 @
2236024d
...
...
@@ -46,7 +46,7 @@ if PLATFORM == 'gcc':
DEVICE
=
' -mcpu='
+
CPU
+
' -mthumb -ffunction-sections -fdata-sections'
CFLAGS
=
DEVICE
+
' -std=c99'
AFLAGS
=
' -c'
+
DEVICE
+
' -x assembler-with-cpp -Wa,-mimplicit-it=thumb'
LFLAGS
=
DEVICE
+
' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T
board
/linker_scripts/link.lds'
LFLAGS
=
DEVICE
+
' -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,Reset_Handler -T
drivers
/linker_scripts/link.lds'
CPATH
=
''
LPATH
=
''
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录