头文件
#ifndef SD2405_H__
#define SD2405_H__
#include "main.h"
#include "delay.h"
#define IIC_SCL PBout(13)
#define IIC_SDA PBout(14)
#define READ_SDA PBin(14)
/// SD2405寄存器地址定义 ///
#define SD2405_ADDR_YEAR 6
#define SD2405_ADDR_MONTH 5
#define SD2405_ADDR_DAY 4
#define SD2405_ADDR_WEEK 3
#define SD2405_ADDR_HOUR 2
#define SD2405_ADDR_MINUTE 1
#define SD2405_ADDR_SECOND 0
#define SD2405_ADDR_CTR1 0X0F
#define SD2405_ADDR_CTR2 0X10
#define SD2405_ADDR_CTR3 0X11
#define UChar2BCD(chr) ((((chr) / 10) << 4) | ((chr) % 10))
#define BCD2UChar(bcd) ((((bcd) >> 4) * 10) + ((bcd) & 0X0F))
#pragma pack(1)
typedef struct
{
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t minute;
uint8_t second;
uint8_t week;
}SD2405_DateTypedef;
#pragma pack()
void SD2405_Init(void);
void SD2405_Write_Time(SD2405_DateTypedef* date);
SD2405_DateTypedef* SD2405_Read_Time(void);
#endif
|