Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wwsmg1
rt-thread
提交
7f738d9f
R
rt-thread
项目概览
wwsmg1
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
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,发现更多精彩内容 >>
提交
7f738d9f
编写于
3月 26, 2021
作者:
I
iysheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp][ab32vg1] Add alarm and 1 second interrupt support
上级
358bc60a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
73 addition
and
4 deletion
+73
-4
bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig
bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig
+4
-0
bsp/bluetrum/libraries/hal_drivers/drv_rtc.c
bsp/bluetrum/libraries/hal_drivers/drv_rtc.c
+65
-4
bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_rtc.h
...aries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_rtc.h
+4
-0
未找到文件。
bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig
浏览文件 @
7f738d9f
...
...
@@ -176,6 +176,10 @@ menu "On-chip Peripheral Drivers"
config RTC_USING_INTERNAL_CLK
bool "Using internal clock RTC"
default y
config RTC_USING_1S_INT
bool "Using 1 second interrupt"
depends on RT_USING_ALARM
default n
endif
menuconfig BSP_USING_ADC
...
...
bsp/bluetrum/libraries/hal_drivers/drv_rtc.c
浏览文件 @
7f738d9f
...
...
@@ -7,6 +7,7 @@
* Date Author Notes
* 2021-01-28 greedyhao first version
* 2021-03-19 iysheng modify just set time first power up
* 2021-03-26 iysheng add alarm and 1s interrupt support
*/
#include "board.h"
...
...
@@ -134,15 +135,22 @@ void hal_rtc_init(void)
irtc_time_write
(
RTCCNT_CMD
,
sec
);
}
#ifdef RT_USING_ALARM
RTCCON
|=
RTC_CON_ALM_INTERRUPT
;
#ifdef RTC_USING_1S_INT
RTCCON
|=
RTC_CON_1S_INTERRUPT
;
#endif
#endif
}
/************** HAL End *******************/
static
time_t
get_rtc_timestamp
(
void
)
static
time_t
get_rtc_time
_
stamp
(
void
)
{
time_t
sec
=
0
;
sec
=
irtc_time_read
(
RTCCNT_CMD
);
LOG_D
(
"get rtc time."
);
return
sec
;
}
...
...
@@ -153,6 +161,22 @@ static rt_err_t set_rtc_time_stamp(time_t time_stamp)
return
RT_EOK
;
}
static
rt_err_t
set_rtc_alarm_stamp
(
time_t
alarm_stamp
)
{
irtc_time_write
(
RTCALM_CMD
,
alarm_stamp
);
return
RT_EOK
;
}
static
time_t
get_rtc_alarm_stamp
(
void
)
{
time_t
sec
=
0
;
sec
=
irtc_time_read
(
RTCALM_CMD
);
return
sec
;
}
static
void
rt_rtc_init
(
void
)
{
hal_rtc_init
();
...
...
@@ -165,8 +189,8 @@ static rt_err_t rt_rtc_control(rt_device_t dev, int cmd, void *args)
switch
(
cmd
)
{
case
RT_DEVICE_CTRL_RTC_GET_TIME
:
*
(
rt_uint32_t
*
)
args
=
get_rtc_timestamp
();
LOG_D
(
"RTC: get rtc_time %x
\n
"
,
*
(
rt_uint32_t
*
)
args
);
*
(
rt_uint32_t
*
)
args
=
get_rtc_time
_
stamp
();
LOG_D
(
"RTC: get rtc_time %x"
,
*
(
rt_uint32_t
*
)
args
);
break
;
case
RT_DEVICE_CTRL_RTC_SET_TIME
:
...
...
@@ -174,7 +198,18 @@ static rt_err_t rt_rtc_control(rt_device_t dev, int cmd, void *args)
{
result
=
-
RT_ERROR
;
}
LOG_D
(
"RTC: set rtc_time %x
\n
"
,
*
(
rt_uint32_t
*
)
args
);
LOG_D
(
"RTC: set rtc_time %x"
,
*
(
rt_uint32_t
*
)
args
);
break
;
case
RT_DEVICE_CTRL_RTC_SET_ALARM
:
if
(
set_rtc_alarm_stamp
(
*
(
rt_uint32_t
*
)
args
))
{
result
=
-
RT_ERROR
;
}
LOG_D
(
"RTC: set alarm_stamp %x"
,
*
(
rt_uint32_t
*
)
args
);
break
;
case
RT_DEVICE_CTRL_RTC_GET_ALARM
:
*
(
rt_uint32_t
*
)
args
=
get_rtc_alarm_stamp
();
LOG_D
(
"RTC: get alarm_stamp %x"
,
*
(
rt_uint32_t
*
)
args
);
break
;
}
...
...
@@ -217,15 +252,41 @@ static rt_err_t rt_hw_rtc_register(rt_device_t device, const char *name, rt_uint
return
rt_device_register
(
device
,
name
,
flag
);
}
#ifdef RT_USING_ALARM
static
void
rtc_isr
(
int
vector
,
void
*
param
)
{
rt_interrupt_enter
();
if
(
RTCCON
&
RTC_CON_ALM_PEND
)
{
RTCCPND
|=
RTC_CPND_ALM
;
}
#ifdef RTC_USING_1S_INT
if
(
RTCCON
&
RTC_CON_1S_PEND
)
{
RTCCPND
|=
RTC_CPND_1S
;
}
#endif
rt_interrupt_leave
();
}
#endif
int
rt_hw_rtc_init
(
void
)
{
rt_err_t
result
;
result
=
rt_hw_rtc_register
(
&
rtc
,
"rtc"
,
RT_DEVICE_FLAG_RDWR
);
if
(
result
!=
RT_EOK
)
{
LOG_E
(
"rtc register err code: %d"
,
result
);
return
result
;
}
#ifdef RT_USING_ALARM
rt_hw_interrupt_install
(
IRQ_RTC_VECTOR
,
rtc_isr
,
RT_NULL
,
"rtc_isr"
);
#endif
LOG_D
(
"rtc init success"
);
return
RT_EOK
;
}
...
...
bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_rtc.h
浏览文件 @
7f738d9f
...
...
@@ -32,6 +32,10 @@ enum
#define RTC_CON_BAUD_SELECT (0x3u << 1)
/*!< Increase clock selection */
#define RTC_CON_CHIP_SELECT (0x1u << 0)
/*!< RTC chip select */
// RTCCPND
#define RTC_CPND_1S (0x1u << 18)
/*!< Clear RTC 1S pending */
#define RTC_CPND_ALM (0x1u << 17)
/*!< Clear RTC alarm pendind */
// RTCCON0
#define RTC_CON0_PWRUP_FIRST (0x01u << 7)
/*!< RTC first power up flag */
#define RTC_CON0_INTERNAL_32K (0x01u << 6)
/*!< Internal 32K select */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录