30 lines
996 B
C
30 lines
996 B
C
#ifndef __DS1302_H
|
|
#define __DS1302_H
|
|
|
|
#include "stm32f10x.h"
|
|
|
|
// DS1302时间结构体
|
|
typedef struct {
|
|
uint16_t year; // 年份 (2000-2099)
|
|
uint8_t month; // 月份 (1-12)
|
|
uint8_t day; // 日期 (1-31)
|
|
uint8_t hour; // 小时 (0-23)
|
|
uint8_t minute; // 分钟 (0-59)
|
|
uint8_t second; // 秒钟 (0-59)
|
|
uint8_t week; // 星期 (1-7, 1=周一)
|
|
} DS1302_Time;
|
|
|
|
// 函数声明
|
|
// 函数作用:初始化 DS1302 时钟芯片使用的 GPIO 引脚和通信状态。
|
|
void DS1302_Init(void);
|
|
// 函数作用:把指定时间写入 DS1302 时钟芯片。
|
|
void DS1302_SetTime(DS1302_Time* time);
|
|
// 函数作用:从 DS1302 时钟芯片读取当前日期和时间。
|
|
void DS1302_GetTime(DS1302_Time* time);
|
|
// 函数作用:从 DS1302 指定寄存器地址读取一个字节数据。
|
|
uint8_t DS1302_ReadByte(uint8_t addr);
|
|
// 函数作用:向 DS1302 指定寄存器地址写入一个字节数据。
|
|
void DS1302_WriteByte(uint8_t addr, uint8_t dat);
|
|
|
|
#endif
|