diff options
| author | iysheng <[email protected]> | 2021-07-05 11:34:11 +0800 |
|---|---|---|
| committer | iysheng <[email protected]> | 2021-07-08 22:41:06 +0800 |
| commit | a2a7f3c2d926388c71d0be5fca0309bfef81e523 (patch) | |
| tree | bf133529b101e5dcb63ba30d130f5ec765418336 /components/drivers/include | |
| parent | 2fda55d898826a1ee79babc4e0852ce539a3bff4 (diff) | |
[components][rtc] Add RTC framework V2.0 to simplify RTC registration process
Diffstat (limited to 'components/drivers/include')
| -rw-r--r-- | components/drivers/include/drivers/rtc.h | 3 | ||||
| -rw-r--r-- | components/drivers/include/drivers/rtc_core.h | 43 |
2 files changed, 46 insertions, 0 deletions
diff --git a/components/drivers/include/drivers/rtc.h b/components/drivers/include/drivers/rtc.h index 4845937113..3a318357da 100644 --- a/components/drivers/include/drivers/rtc.h +++ b/components/drivers/include/drivers/rtc.h @@ -11,6 +11,9 @@ #ifndef __RTC_H__ #define __RTC_H__ +#include <rtconfig.h> +#include <drivers/rtc_core.h> + 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); diff --git a/components/drivers/include/drivers/rtc_core.h b/components/drivers/include/drivers/rtc_core.h new file mode 100644 index 0000000000..c093a1d749 --- /dev/null +++ b/components/drivers/include/drivers/rtc_core.h @@ -0,0 +1,43 @@ +/* + * 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); +}; + +typedef struct rt_rtc_device +{ + struct rt_device parent; + const struct rt_rtc_ops *ops; +} rt_rtc_dev_t; + +rt_err_t rt_rtc_dev_register(rt_rtc_dev_t *rtc, + const char *name, + rt_uint32_t flag, + void *data); + +#endif /* __RTC_CORE_H__ */ |
