| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- /*
- * Copyright (c) 2024, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- * 2024-xx-xx user first version
- */
- #ifndef __RTC_H__
- #define __RTC_H__
- #include <rtthread.h>
- #include <stm32f4xx_hal.h>
- /* RTC备份寄存器标记地址 - 使用RTC_BKP_DR0 */
- #define RTC_BKP_FLAG RTC_BKP_DR0
- /* RTC已初始化标记值 */
- #define RTC_INIT_FLAG 0x3568
- /* 默认日期时间: 2024-01-01 00:00:00 */
- #define RTC_DEFAULT_YEAR 26 /* 2000 + 24 = 2024 */
- #define RTC_DEFAULT_MONTH 1
- #define RTC_DEFAULT_DATE 1
- #define RTC_DEFAULT_HOUR 0
- #define RTC_DEFAULT_MINUTE 0
- #define RTC_DEFAULT_SECOND 0
- /* RTC时间结构体 */
- struct rtc_time
- {
- rt_uint16_t year; /* 年份: 2000-2099 */
- rt_uint8_t month; /* 月份: 1-12 */
- rt_uint8_t date; /* 日期: 1-31 */
- rt_uint8_t hour; /* 小时: 0-23 */
- rt_uint8_t minute; /* 分钟: 0-59 */
- rt_uint8_t second; /* 秒钟: 0-59 */
- rt_uint8_t weekday; /* 星期: 0-6 */
- };
- /* RTC初始化函数 */
- int rt_hw_rtc_init(void);
- /* 获取RTC时间 */
- int rtc_get_time(struct rtc_time *time);
- /* 设置RTC时间 */
- int rtc_set_time(struct rtc_time *time);
- /* 将RTC时间转换为字符串 */
- void rtc_time_to_str(const struct rtc_time *time, char *buf, rt_size_t size);
- struct TM {
- uint8_t tm_sec;
- uint8_t tm_min;
- uint8_t tm_hour;
- uint8_t tm_mday;
- uint8_t tm_mon;
- uint8_t tm_year;
- };
- // typedef struct
- // {
- // struct TM Time_Stampe; // 时间戳
- // uint16_t code; // 异常码
- // uint16_t para; // 附带参数
- // uint32_t num; // 序号
- // char detail[52]; // 内容
- // } Record;
- // typedef enum
- // {
- // e_reboot = 1,
- // e_clearecode,
- // e_test_fun,
- // e_typeMAX
- // } ecode_list;
- #endif /* __RTC_H__ */
|