[C51代码]DS1302驱动
/*********************ds1302.h**********************/
#ifndef __ds1302_h__
#define __ds1302_h__
#include
#include "Atmel/AT89X51.h"
#include "LINK.h"
/*******************宏定义********************/
#define WRITE_SECOND 0x80
#define WRITE_MINUTE 0x82
#define WRITE_HOUR 0x84
#define WRITE_DAY 0x86
#define WRITE_MONTH 0x88
#define WRITE_WEEK 0x8A
#define WRITE_YEAR 0x8C
#define WRITE_PROTECT 0x8E
#define READ_SECOND 0x81
#define READ_MINUTE 0x83
#define READ_HOUR 0x85
#define READ_DAY 0x87
#define READ_MONTH 0x89
#define READ_WEEK 0x8B
#define READ_YEAR 0x8D
#define BCD2DEC(X) (((X&0x70)/16)*10 + (X&0x0F)) //用于将BCD码转成十进制的宏
#define DEC2BCD(X) ((X/10)*16 + (X%10)) //用于将十进制转成BCD码的宏
/*******************端口定义********************/
sbit RST =P2^3;
sbit SCLK=P2^4;
sbit DIO =P2^5;
/****DS1302的声明函数****/
extern void DS1302Writebyte(uchar addr,uchar dat);
extern uchar DS1302Readbyte(uchar addr);
extern void DS1302Initial(void);
extern uchar WeekDay20(uchar y, uchar m, uchar d);
extern void DS1302Gettime(void);
extern void DS1302DataConvert(void);
extern void DS1302Disp(void);
extern void DS1302DataConvert(void);
/*********************变量定义**********************/
extern uchar DataArrayYear[5];
extern uchar DataArrayMonth[3];
extern uchar DataArrayDay[3];
extern uchar TimeArray[9];
extern uchar WeekArray[7][4];
typedef struct //定义的时间类型结构体,全部数为十进制
{
uchar Second;
uchar Minute;
uchar Hour;
uchar Week;
uchar Day;
uchar Month;
uchar Year;
}systemtime;
extern systemtime Nowtime;
#endif
C51代码DS1302驱 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)