资源描述
#ifndef _DS1302_H_#define _DS1302_H_#define uchar unsigned char#define uint unsigned int#includesbit SCLK = P32;sbit IO = P24;sbit RST = P33;#define R_Second 0x81#define W_Second 0x80#define R_Minute 0x83#define W_Minute 0x82#define R_Hour 0x85#define W_Hour 0x84h#define R_Day 0x87#define W_Day 0x86_n_#define R_Month 0x89 澝儙 #define W_Month 0x88 #define R_Week 0x8B#define W_Week 0x渢#define R_Year 0x8D#define W_Year 0x8C?#define R_Control 0xu _簭_?void DS1302_Write_Byte(uchar Date;?void Write_DS1302(uchar Adr,uchar Date;uchar Read_DS1302(uchar Adr;void Init_DS1302(;#endifW 燊/*函數名稱 _Z_k 謃?缧?_恄漀騋 单字节写葅发亽輸入參數 : 写的字节U 輸出參數 -_ 无 M;1,?備5% 注 :*/F_void DS1302_Write_Byte(uchar Date 琿彆 uchar i;G for(i = 0;i 8;i+ if(Date & 0x01IO=1;else_鞺穢齄 IO = 0;O_SCLK=1;3SCLK = 0; 诰搕謃鋃乓莗擾葞 U/*: uchar DS1302_Read_Byte(?函數功能: 单字节读恳輸入參數 蛈 w- 无 E轆儡 : |3?o 读出的数据備注 :*/uchar DS1302_Read_Byte(!buchar i,Temp = 0;for(i = 0;i 1;(_eTemp = Temp | 0x80;SCLK = 1;return Temp;Y仞 _Gv?+ 枊瞒 0 壇糪 f?_6 篢 2 擺 Pz;函數功能 : 写数据輸入參數 &率郷骋 確_F 澼 G?_弒u_q 无蘤窓膠 注 巓钌鑪*/v嗣趉 藁 mSCLK = 0;RST = 1;DS1302_Write_Byte(Adr; 濒 DS1302_Write_Byte(Date;i Mcn/*殧泛曋嬪 i: uchar Read_DS1302(uchar Adr齙鳑扼蝊 _嵖 ?輸入參數 檟_范:U?T啃禈輸出參數 : 读出的数据拥&_ 注 :_*/uchar Read_DS1302(uchar Adruchar Temp = 0;RST = 0;4_RST = 1;DS1302_Write_Byte(Adr;Temp = DS1302_Read_Byte(;RST = 0; 潵擾 ?_獐衉 悱 qG_?帶燙負 焉/*函數名稱 :_函數功能陕鮛 ?_kE_P_w?鋃 DS1302o 齙: 无 ?輸出參數 : U _?眶備注 :_2?蒧 void Init_DS1302( 癬窥 Q_u瞪 I _% 唼? _镈 Write_DS1302(W_Month,0x09; 中_#疴 FWrite_DS1302(W_Minute,0x11;Write_DS1302(W_Second,0x23;Write_DS1302(W_Control,0x80;_Ts
展开阅读全文