📄 ds1302.h
字号:
#ifndef _DS1302_H
#define _DS1302_H
/*
#ifndef __C8051F020_H__
#include <c8051f020.h>
#endif
#ifndef _MACRO_H
#include "macro.h"
#endif
*/
sbit ACC0 = ACC ^ 0;
sbit ACC7 = ACC ^ 7;
sbit DSRST = P1 ^ 2; //时钟复位信号线
sbit DSDIO = P1 ^ 1; //时钟数据线
sbit DSCLK = P1 ^ 0; //时钟时钟线
/*注意事项:
1.每次上电,必须把秒寄存器高位(第7位)设置为0,时钟才能走时。
2.如果需要写入数据和时钟日历信息,必须把“写保护”寄存器设置成为0,方法入下:
write_clock(0xc1 0x7,0);
3.使能“慢速充电”,方法如下:
write_clock(0xc1 0x8,0xaa);
*/
#define SEC_WRI 0x80
#define SEC_READ 0x81
#define MIN_WRI 0x82
#define MIN_READ 0x83
#define HR_WRI 0x84
#define HR_READ 0x85
#define DATE_WRI 0x86
#define DATE_READ 0x87
#define MON_WRI 0x88
#define MON_READ 0x89
#define WEEK_WRI 0x8A
#define WEEK_READ 0x8B
#define YEAR_WRI 0x8C
#define YEAR_READ 0x8D
#define WRI_PROTECT_WRI 0x8E
#define WRI_PROTECT_READ 0x8F
#define CLOCK_MULTI_BYTE_WRI 0xBE
#define CLOCK_MULTI_BYTE_READ 0xBF
#define RAM_MULTI_BYTE_WRI 0xFE
#define RAM_MULTI_BYTE_READ 0xFF
#define DSRSTLOW() DSRST = 0; _nop_(); _nop_(); _nop_(); _nop_();\
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); \
_nop_(); _nop_(); _nop_(); _nop_(); _nop_()
#define DSRSTHIGH() DSRST = 1; _nop_(); _nop_(); _nop_(); _nop_();\
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); \
_nop_(); _nop_(); _nop_(); _nop_(); _nop_()
#define DSCLKLOW() DSCLK = 0; _nop_(); _nop_(); _nop_(); _nop_();\
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); \
_nop_(); _nop_(); _nop_(); _nop_(); _nop_()
#define DSCLKHIGH() DSCLK = 1; _nop_(); _nop_(); _nop_(); _nop_();\
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); \
_nop_(); _nop_(); _nop_(); _nop_(); _nop_()
uchar dsWriDsI ;
uchar dsWriCh ;
uchar dsReadDsK ;
uchar dsReadCl ;
uchar ds1302SettimerBuffer[];
uchar ds1302GettimerBuffer[];
void WriDs(uchar addr, uchar dat);
uchar ReadDs(uchar addr);
void SetTimer(uchar *pSetTimer);
void GetTimer(uchar *pGetTimer);
void OscEnable();
void Osc24();
void ChargeEnable();
void DsInit();
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -