Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
724961c6
R
rt-thread
项目概览
BaiXuePrincess
/
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,发现更多精彩内容 >>
提交
724961c6
编写于
7月 17, 2015
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #519 from tuy0326/master
bsp stm32f10x rtc driver
上级
a6f0b844
62f0def0
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
6 addition
and
92 deletion
+6
-92
bsp/stm32f10x/drivers/stm32f1_rtc.c
bsp/stm32f10x/drivers/stm32f1_rtc.c
+3
-89
bsp/stm32f10x/drivers/stm32f1_rtc.h
bsp/stm32f10x/drivers/stm32f1_rtc.h
+3
-3
未找到文件。
bsp/stm32f10x/drivers/rtc.c
→
bsp/stm32f10x/drivers/
stm32f1_
rtc.c
浏览文件 @
724961c6
/*
* File : rtc.c
* File :
stm32f1_
rtc.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009, RT-Thread Development Team
*
...
...
@@ -11,11 +11,12 @@
* Date Author Notes
* 2009-01-05 Bernard the first version.
* 2011-11-26 aozima implementation time.
* 2015-07-16 FlyM rename rtc to stm32f1_rtc. remove finsh export function
*/
#include <rtthread.h>
#include <stm32f10x.h>
#include "rtc.h"
#include "
stm32f1_
rtc.h"
static
struct
rt_device
rtc
;
static
rt_err_t
rt_rtc_open
(
rt_device_t
dev
,
rt_uint16_t
oflag
)
...
...
@@ -159,91 +160,4 @@ void rt_hw_rtc_init(void)
return
;
}
#include <time.h>
#if defined (__IAR_SYSTEMS_ICC__) && (__VER__) >= 6020000
/* for IAR 6.2 later Compiler */
#pragma module_name = "?time"
time_t
(
__time32
)(
time_t
*
t
)
/* Only supports 32-bit timestamp */
#else
time_t
time
(
time_t
*
t
)
#endif
{
rt_device_t
device
;
time_t
time
=
0
;
device
=
rt_device_find
(
"rtc"
);
if
(
device
!=
RT_NULL
)
{
rt_device_control
(
device
,
RT_DEVICE_CTRL_RTC_GET_TIME
,
&
time
);
if
(
t
!=
RT_NULL
)
*
t
=
time
;
}
return
time
;
}
#ifdef RT_USING_FINSH
#include <finsh.h>
void
set_date
(
rt_uint32_t
year
,
rt_uint32_t
month
,
rt_uint32_t
day
)
{
time_t
now
;
struct
tm
*
ti
;
rt_device_t
device
;
ti
=
RT_NULL
;
/* get current time */
time
(
&
now
);
ti
=
localtime
(
&
now
);
if
(
ti
!=
RT_NULL
)
{
ti
->
tm_year
=
year
-
1900
;
ti
->
tm_mon
=
month
-
1
;
/* ti->tm_mon = month; 0~11 */
ti
->
tm_mday
=
day
;
}
now
=
mktime
(
ti
);
device
=
rt_device_find
(
"rtc"
);
if
(
device
!=
RT_NULL
)
{
rt_rtc_control
(
device
,
RT_DEVICE_CTRL_RTC_SET_TIME
,
&
now
);
}
}
FINSH_FUNCTION_EXPORT
(
set_date
,
set
date
.
e
.
g
:
set_date
(
2010
,
2
,
28
))
void
set_time
(
rt_uint32_t
hour
,
rt_uint32_t
minute
,
rt_uint32_t
second
)
{
time_t
now
;
struct
tm
*
ti
;
rt_device_t
device
;
ti
=
RT_NULL
;
/* get current time */
time
(
&
now
);
ti
=
localtime
(
&
now
);
if
(
ti
!=
RT_NULL
)
{
ti
->
tm_hour
=
hour
;
ti
->
tm_min
=
minute
;
ti
->
tm_sec
=
second
;
}
now
=
mktime
(
ti
);
device
=
rt_device_find
(
"rtc"
);
if
(
device
!=
RT_NULL
)
{
rt_rtc_control
(
device
,
RT_DEVICE_CTRL_RTC_SET_TIME
,
&
now
);
}
}
FINSH_FUNCTION_EXPORT
(
set_time
,
set
time
.
e
.
g
:
set_time
(
23
,
59
,
59
))
void
list_date
(
void
)
{
time_t
now
;
time
(
&
now
);
rt_kprintf
(
"%s
\n
"
,
ctime
(
&
now
));
}
FINSH_FUNCTION_EXPORT
(
list_date
,
show
date
and
time
.)
#endif
bsp/stm32f10x/drivers/rtc.h
→
bsp/stm32f10x/drivers/
stm32f1_
rtc.h
浏览文件 @
724961c6
/*
* File : rtc.h
* File :
stm32f1_
rtc.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009, RT-Thread Development Team
*
...
...
@@ -12,8 +12,8 @@
* 2009-01-05 Bernard the first version
*/
#ifndef __RTC_H__
#define __RTC_H__
#ifndef __
STM32F1_
RTC_H__
#define __
STM32F1_
RTC_H__
void
rt_hw_rtc_init
(
void
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录