Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
天中雨水
rt-thread
提交
94a93329
R
rt-thread
项目概览
天中雨水
/
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,发现更多精彩内容 >>
提交
94a93329
编写于
7月 30, 2021
作者:
mysterywolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[rtc] 移除rtc_core.c/.h 将内容转移到rtc.c/.h
上级
9e47b95e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
156 addition
and
215 deletion
+156
-215
bsp/efm32/drv_rtc.c
bsp/efm32/drv_rtc.c
+12
-44
components/drivers/include/drivers/rtc.h
components/drivers/include/drivers/rtc.h
+31
-2
components/drivers/include/drivers/rtc_core.h
components/drivers/include/drivers/rtc_core.h
+0
-45
components/drivers/rtc/SConscript
components/drivers/rtc/SConscript
+1
-1
components/drivers/rtc/rtc.c
components/drivers/rtc/rtc.c
+112
-0
components/drivers/rtc/rtc_core.c
components/drivers/rtc/rtc_core.c
+0
-123
未找到文件。
bsp/efm32/drv_rtc.c
浏览文件 @
94a93329
...
...
@@ -128,49 +128,6 @@ void rt_hw_rtc_isr(rt_device_t device)
RTC
->
IFC
=
_RTC_IFC_MASK
;
}
/***************************************************************************//**
* @brief
* Register RTC device
*
* @details
*
* @note
*
* @param[in] device
* Pointer to device descriptor
*
* @param[in] name
* Device name
*
* @param[in] flag
* Configuration flags
*
* @return
* Error code
******************************************************************************/
rt_err_t
rt_hw_rtc_register
(
rt_device_t
device
,
const
char
*
name
,
rt_uint32_t
flag
)
{
RT_ASSERT
(
device
!=
RT_NULL
);
device
->
type
=
RT_Device_Class_RTC
;
device
->
rx_indicate
=
RT_NULL
;
device
->
tx_complete
=
RT_NULL
;
device
->
init
=
RT_NULL
;
device
->
open
=
rt_rtc_open
;
device
->
close
=
RT_NULL
;
device
->
read
=
rt_rtc_read
;
device
->
write
=
RT_NULL
;
device
->
control
=
rt_rtc_control
;
device
->
user_data
=
RT_NULL
;
/* no private */
/* register a character device */
return
rt_device_register
(
device
,
name
,
RT_DEVICE_FLAG_RDWR
|
flag
);
}
/***************************************************************************//**
* @brief
* Initialize all RTC module related hardware and register RTC device to kernel
...
...
@@ -224,7 +181,18 @@ void rt_hw_rtc_init(void)
}
/* register rtc device */
rt_hw_rtc_register
(
&
rtc
,
RT_RTC_NAME
,
EFM32_NO_DATA
);
rtc
.
type
=
RT_Device_Class_RTC
;
rtc
.
rx_indicate
=
RT_NULL
;
rtc
.
tx_complete
=
RT_NULL
;
rtc
.
init
=
RT_NULL
;
rtc
.
open
=
rt_rtc_open
;
rtc
.
close
=
RT_NULL
;
rtc
.
read
=
rt_rtc_read
;
rtc
.
write
=
RT_NULL
;
rtc
.
control
=
rt_rtc_control
;
rtc
.
user_data
=
RT_NULL
;
/* no private */
rt_device_register
(
&
rtc
,
RT_RTC_NAME
,
RT_DEVICE_FLAG_RDWR
|
EFM32_NO_DATA
);
}
#endif
...
...
components/drivers/include/drivers/rtc.h
浏览文件 @
94a93329
...
...
@@ -6,13 +6,42 @@
* Change Logs:
* Date Author Notes
* 2012-10-10 aozima first version.
* 2021-06-11 iysheng implement RTC v2.0
*/
#ifndef __RTC_H__
#define __RTC_H__
#include <rtconfig.h>
#include <drivers/rtc_core.h>
#include <rtdef.h>
#define RT_DEVICE_CTRL_RTC_GET_TIME 0x10
/**< get second time */
#define RT_DEVICE_CTRL_RTC_SET_TIME 0x11
/**< set second time */
#define RT_DEVICE_CTRL_RTC_GET_TIME_US 0x12
/**< get microsecond time */
#define RT_DEVICE_CTRL_RTC_SET_TIME_US 0x13
/**< set microsecond time */
#define RT_DEVICE_CTRL_RTC_GET_ALARM 0x14
/**< get alarm */
#define RT_DEVICE_CTRL_RTC_SET_ALARM 0x15
/**< set alarm */
struct
rt_rtc_ops
{
rt_err_t
(
*
init
)(
void
);
rt_err_t
(
*
get_secs
)(
void
*
arg
);
rt_err_t
(
*
set_secs
)(
void
*
arg
);
rt_err_t
(
*
get_alarm
)(
void
*
arg
);
rt_err_t
(
*
set_alarm
)(
void
*
arg
);
rt_err_t
(
*
get_usecs
)(
void
*
arg
);
rt_err_t
(
*
set_usecs
)(
void
*
arg
);
};
typedef
struct
rt_rtc_device
{
struct
rt_device
parent
;
const
struct
rt_rtc_ops
*
ops
;
}
rt_rtc_dev_t
;
rt_err_t
rt_hw_rtc_register
(
rt_rtc_dev_t
*
rtc
,
const
char
*
name
,
rt_uint32_t
flag
,
void
*
data
);
rt_err_t
set_date
(
rt_uint32_t
year
,
rt_uint32_t
month
,
rt_uint32_t
day
);
rt_err_t
set_time
(
rt_uint32_t
hour
,
rt_uint32_t
minute
,
rt_uint32_t
second
);
...
...
components/drivers/include/drivers/rtc_core.h
已删除
100644 → 0
浏览文件 @
9e47b95e
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-06-11 iysheng first version.
*/
#ifndef __RTC_CORE_H__
#define __RTC_CORE_H__
#include <rtthread.h>
#define RT_DEVICE_CTRL_RTC_GET_TIME 0x10
/**< get second time */
#define RT_DEVICE_CTRL_RTC_SET_TIME 0x11
/**< set second time */
#define RT_DEVICE_CTRL_RTC_GET_TIME_US 0x12
/**< get microsecond time */
#define RT_DEVICE_CTRL_RTC_SET_TIME_US 0x13
/**< set microsecond time */
#define RT_DEVICE_CTRL_RTC_GET_ALARM 0x14
/**< get alarm */
#define RT_DEVICE_CTRL_RTC_SET_ALARM 0x15
/**< set alarm */
struct
rt_rtc_ops
{
rt_err_t
(
*
init
)(
void
);
rt_err_t
(
*
get_secs
)(
void
*
arg
);
rt_err_t
(
*
set_secs
)(
void
*
arg
);
rt_err_t
(
*
get_alarm
)(
void
*
arg
);
rt_err_t
(
*
set_alarm
)(
void
*
arg
);
rt_err_t
(
*
get_usecs
)(
void
*
arg
);
rt_err_t
(
*
set_usecs
)(
void
*
arg
);
};
typedef
struct
rt_rtc_device
{
struct
rt_device
parent
;
const
struct
rt_rtc_ops
*
ops
;
}
rt_rtc_dev_t
;
rt_err_t
rt_hw_rtc_register
(
rt_rtc_dev_t
*
rtc
,
const
char
*
name
,
rt_uint32_t
flag
,
void
*
data
);
#endif
/* __RTC_CORE_H__ */
components/drivers/rtc/SConscript
浏览文件 @
94a93329
...
...
@@ -7,7 +7,7 @@ CPPPATH = [cwd + '/../include']
group
=
[]
if
GetDepend
([
'RT_USING_RTC'
]):
src
=
src
+
[
'rtc.c'
,
'rtc_core.c'
]
src
=
src
+
[
'rtc.c'
]
if
GetDepend
([
'RT_USING_ALARM'
]):
src
=
src
+
[
'alarm.c'
]
if
GetDepend
([
'RT_USING_SOFT_RTC'
]):
...
...
components/drivers/rtc/rtc.c
浏览文件 @
94a93329
...
...
@@ -10,6 +10,7 @@
* 2012-04-16 aozima add scheduler lock for set_date and set_time.
* 2018-02-16 armink add auto sync time by NTP
* 2021-05-09 Meco Man remove NTP
* 2021-06-11 iysheng implement RTC v2.0
*/
#include <time.h>
...
...
@@ -20,6 +21,117 @@
#ifdef RT_USING_RTC
#define TRY_DO_RTC_FUNC(rt_rtc_dev, func_name, args) \
rt_rtc_dev->ops->func_name ? rt_rtc_dev->ops->func_name(args) : -RT_EINVAL;
/*
* This function initializes rtc_core
*/
static
rt_err_t
rt_rtc_core_init
(
struct
rt_device
*
dev
)
{
rt_rtc_dev_t
*
rtc_core
;
RT_ASSERT
(
dev
!=
RT_NULL
);
rtc_core
=
(
rt_rtc_dev_t
*
)
dev
;
if
(
rtc_core
->
ops
->
init
)
{
return
(
rtc_core
->
ops
->
init
());
}
return
(
-
RT_ENOSYS
);
}
static
rt_err_t
rt_rtc_core_open
(
struct
rt_device
*
dev
,
rt_uint16_t
oflag
)
{
return
(
RT_EOK
);
}
static
rt_err_t
rt_rtc_core_close
(
struct
rt_device
*
dev
)
{
/* Add close member function in rt_rtc_ops when need,
* then call that function here.
* */
return
(
RT_EOK
);
}
static
rt_err_t
rt_rtc_core_control
(
struct
rt_device
*
dev
,
int
cmd
,
void
*
args
)
{
rt_rtc_dev_t
*
rtc_core
;
rt_err_t
ret
=
-
RT_EINVAL
;
RT_ASSERT
(
dev
!=
RT_NULL
);
rtc_core
=
(
rt_rtc_dev_t
*
)
dev
;
switch
(
cmd
)
{
case
RT_DEVICE_CTRL_RTC_GET_TIME
:
ret
=
TRY_DO_RTC_FUNC
(
rtc_core
,
get_secs
,
args
);
break
;
case
RT_DEVICE_CTRL_RTC_SET_TIME
:
ret
=
TRY_DO_RTC_FUNC
(
rtc_core
,
set_secs
,
args
);
break
;
case
RT_DEVICE_CTRL_RTC_GET_TIME_US
:
ret
=
TRY_DO_RTC_FUNC
(
rtc_core
,
get_usecs
,
args
);
break
;
case
RT_DEVICE_CTRL_RTC_SET_TIME_US
:
ret
=
TRY_DO_RTC_FUNC
(
rtc_core
,
set_usecs
,
args
);
break
;
case
RT_DEVICE_CTRL_RTC_GET_ALARM
:
ret
=
TRY_DO_RTC_FUNC
(
rtc_core
,
get_alarm
,
args
);
break
;
case
RT_DEVICE_CTRL_RTC_SET_ALARM
:
ret
=
TRY_DO_RTC_FUNC
(
rtc_core
,
set_alarm
,
args
);
break
;
default:
break
;
}
return
ret
;
}
#ifdef RT_USING_DEVICE_OPS
const
static
struct
rt_device_ops
rtc_core_ops
=
{
rt_rtc_core_init
,
rt_rtc_core_open
,
rt_rtc_core_close
,
RT_NULL
,
RT_NULL
,
rt_rtc_core_control
,
};
#endif
rt_err_t
rt_hw_rtc_register
(
rt_rtc_dev_t
*
rtc
,
const
char
*
name
,
rt_uint32_t
flag
,
void
*
data
)
{
struct
rt_device
*
device
;
RT_ASSERT
(
rtc
!=
RT_NULL
);
device
=
&
(
rtc
->
parent
);
device
->
type
=
RT_Device_Class_RTC
;
device
->
rx_indicate
=
RT_NULL
;
device
->
tx_complete
=
RT_NULL
;
#ifdef RT_USING_DEVICE_OPS
device
->
ops
=
&
rtc_core_ops
;
#else
device
->
init
=
rt_rtc_core_init
;
device
->
open
=
rt_rtc_core_open
;
device
->
close
=
rt_rtc_core_close
;
device
->
read
=
RT_NULL
;
device
->
write
=
RT_NULL
;
device
->
control
=
rt_rtc_core_control
;
#endif
device
->
user_data
=
data
;
/* register a character device */
return
rt_device_register
(
device
,
name
,
flag
);
}
/**
* Set system date(time not modify, local timezone).
*
...
...
components/drivers/rtc/rtc_core.c
已删除
100644 → 0
浏览文件 @
9e47b95e
/*
* COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-06-11 iysheng first version.
*/
#include <drivers/rtc_core.h>
#define TRY_DO_RTC_FUNC(rt_rtc_dev, func_name, args) \
rt_rtc_dev->ops->func_name ? rt_rtc_dev->ops->func_name(args) : -RT_EINVAL;
/*
* This function initializes rtc_core
*/
static
rt_err_t
rt_rtc_core_init
(
struct
rt_device
*
dev
)
{
rt_rtc_dev_t
*
rtc_core
;
RT_ASSERT
(
dev
!=
RT_NULL
);
rtc_core
=
(
rt_rtc_dev_t
*
)
dev
;
if
(
rtc_core
->
ops
->
init
)
{
return
(
rtc_core
->
ops
->
init
());
}
return
(
-
RT_ENOSYS
);
}
static
rt_err_t
rt_rtc_core_open
(
struct
rt_device
*
dev
,
rt_uint16_t
oflag
)
{
return
(
RT_EOK
);
}
static
rt_err_t
rt_rtc_core_close
(
struct
rt_device
*
dev
)
{
/* Add close member function in rt_rtc_ops when need,
* then call that function here.
* */
return
(
RT_EOK
);
}
static
rt_err_t
rt_rtc_core_control
(
struct
rt_device
*
dev
,
int
cmd
,
void
*
args
)
{
rt_rtc_dev_t
*
rtc_core
;
rt_err_t
ret
=
-
RT_EINVAL
;
RT_ASSERT
(
dev
!=
RT_NULL
);
rtc_core
=
(
rt_rtc_dev_t
*
)
dev
;
switch
(
cmd
)
{
case
RT_DEVICE_CTRL_RTC_GET_TIME
:
ret
=
TRY_DO_RTC_FUNC
(
rtc_core
,
get_secs
,
args
);
break
;
case
RT_DEVICE_CTRL_RTC_SET_TIME
:
ret
=
TRY_DO_RTC_FUNC
(
rtc_core
,
set_secs
,
args
);
break
;
case
RT_DEVICE_CTRL_RTC_GET_TIME_US
:
ret
=
TRY_DO_RTC_FUNC
(
rtc_core
,
get_usecs
,
args
);
break
;
case
RT_DEVICE_CTRL_RTC_SET_TIME_US
:
ret
=
TRY_DO_RTC_FUNC
(
rtc_core
,
set_usecs
,
args
);
break
;
case
RT_DEVICE_CTRL_RTC_GET_ALARM
:
ret
=
TRY_DO_RTC_FUNC
(
rtc_core
,
get_alarm
,
args
);
break
;
case
RT_DEVICE_CTRL_RTC_SET_ALARM
:
ret
=
TRY_DO_RTC_FUNC
(
rtc_core
,
set_alarm
,
args
);
break
;
default:
break
;
}
return
ret
;
}
#ifdef RT_USING_DEVICE_OPS
const
static
struct
rt_device_ops
rtc_core_ops
=
{
rt_rtc_core_init
,
rt_rtc_core_open
,
rt_rtc_core_close
,
RT_NULL
,
RT_NULL
,
rt_rtc_core_control
,
};
#endif
rt_err_t
rt_hw_rtc_register
(
rt_rtc_dev_t
*
rtc
,
const
char
*
name
,
rt_uint32_t
flag
,
void
*
data
)
{
struct
rt_device
*
device
;
RT_ASSERT
(
rtc
!=
RT_NULL
);
device
=
&
(
rtc
->
parent
);
device
->
type
=
RT_Device_Class_RTC
;
device
->
rx_indicate
=
RT_NULL
;
device
->
tx_complete
=
RT_NULL
;
#ifdef RT_USING_DEVICE_OPS
device
->
ops
=
&
rtc_core_ops
;
#else
device
->
init
=
rt_rtc_core_init
;
device
->
open
=
rt_rtc_core_open
;
device
->
close
=
rt_rtc_core_close
;
device
->
read
=
RT_NULL
;
device
->
write
=
RT_NULL
;
device
->
control
=
rt_rtc_core_control
;
#endif
device
->
user_data
=
data
;
/* register a character device */
return
rt_device_register
(
device
,
name
,
flag
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录