62 lines
1.5 KiB
C
62 lines
1.5 KiB
C
/**
|
|
* @file rtc_rx8010.h
|
|
* @author xxx
|
|
* @date 2023-08-30 14:05:55
|
|
* @brief 头文件 rtc_rx8010.h
|
|
* @copyright Copyright (c) 2023 by xxx, All Rights Reserved.
|
|
*/
|
|
|
|
#ifndef __RTC_RX8010_H__
|
|
#define __RTC_RX8010_H__
|
|
#include "main.h"
|
|
|
|
#define RTC_DEVICE_ADDR 0x32
|
|
|
|
#define RTC_WR_ADDR ((RTC_DEVICE_ADDR << 1) | 0)
|
|
#define RTC_RD_ADDR ((RTC_DEVICE_ADDR << 1) | 1)
|
|
|
|
#define RTC_FLAG_ADDR 0x1e
|
|
#define RTC_CLOCK_ADDR 0x10
|
|
#define RTC_CONTROL_ADDR 0x1f
|
|
|
|
#define RTC_REG17_ADDR 0x17
|
|
#define RTC_REG17_DATA 0xd8
|
|
|
|
#define RTC_REG30_ADDR 0x30
|
|
#define RTC_REG30_DATA 0x00
|
|
|
|
#define RTC_REG31_ADDR 0x31
|
|
#define RTC_REG31_DATA 0x08
|
|
|
|
#define RTC_IRQ_ADDR 0x32
|
|
#define RTC_IRQ_DATA 0x00
|
|
|
|
typedef enum
|
|
{
|
|
SUN = BIT0,
|
|
MON = BIT1,
|
|
TUE = BIT2,
|
|
WED = BIT3,
|
|
THUR = BIT4,
|
|
FRI = BIT5,
|
|
SAT = BIT6
|
|
} rtc_week_e; // 星期码
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t year; // 7 bit - 1 63
|
|
uint8_t month; // 4 bit
|
|
uint8_t day; // 5 bit
|
|
uint8_t weekday; // rtc_week_e
|
|
uint8_t hour; // 5 bit
|
|
uint8_t minute; // 6 bit
|
|
uint8_t second; // 6 bit
|
|
} rtc_date;
|
|
|
|
extern BOOL rtc_init(void); ///< RTC芯片初始化
|
|
extern BOOL rtc_get_clock_time(uint8_t *read_buf); ///< 从RTC芯片读取时间
|
|
extern BOOL rtc_set_clock_time(rtc_date *data); ///< 向RTC芯片写入时间
|
|
extern void rtc_weekday_convert(uint8_t *weekday); ///< 将星期转为星期码
|
|
extern void rtc_weekday_rconvert(uint8_t *weekday); ///< 将星期码转为星期
|
|
#endif // !__RTC_RX8010_H__
|