#ifndef _HT1380_H_ #define _HT1380_H_ //#include "ht1380.h" //读数据长度 #define Long_ReadData (uint8)3//7 //读取的数据转换成显示数据 #define ClockSwitch_TSEC(x) ((x>>4)&0X07)*10 + (x&0x0f) #define ClockSwitch_TMIN(x) ((x>>4)&0X07)*10 + (x&0x0f) #define ClockSwitch_THOR(x) ((x>>4)&0x03)*10 + (x&0x0f) //显示数据转换成读取的数据 -- 设置时间时 #define ClockSwitchB_TSEC(x) (((x/10)<<4) + (x%10)) #define ClockSwitchB_TMIN(x) (((x/10)<<4) + (x%10)) #define ClockSwitchB_THOR(x) (((x/10)<<4) + (x%10)) /* //----HT1381----DS1302 #define P_SLK1380 PB2_OUT #define P_DAT1380Out PB3_OUT #define P_DAT1380In PB3_IN #define P_RST1380 PB4_OUT */ //==================================== extern void HT1380SetTime(uint8 *pSecDa) ; extern void HT1380ReadTime(uint8 *ucCurtime) ; extern void Init_TH1380(void) ; extern void ClockSwitchMCU(uint8 *ClockDat,uint8 *McuDat ) ; extern void MCUSwitchClock(uint8 *McuDat,uint8 *ClockDat) ; #endif #include "global.h" #include "ht1380.h" #define HT1380OSC_ENB (uint8)0X00 //振荡使能 #define HT1380OSC_DIS (uint8)0X80 #define MCLOCK24H (uint8)0x00 //24H 制 #define MCLOCK12H (uint8)0x80 //----------------------------- #define HT1380SLK_HIGH P_SLK1380 = 1 #define HT1380SLK_LOW P_SLK1380 = 0 #define HT1380DAT_HIGH P_DAT1380Out = 1 #define HT1380DAT_LOW P_DAT1380Out = 0 #define HT1380RST_HIGH P_RST1380 = 1 #define HT1380RST_LOW P_RST1380 = 0 //读数据端口 #define HT1380DatIn P_DAT1380In //----------------------------------------- void delay1380(void) { uint8 i = 0 ; for(i=10;i>0;i--) { _asm("nop"); _asm("nop"); _asm("nop"); _asm("nop"); _asm("nop"); _asm("nop"); _asm("nop"); } } /******************************************************************** * * 名称: HT1380WriteByte * 说明: * 功能: 往 HT1381 写入 1Byte 数据 * 调用: * 输入: ucDa 写入的数据 * 返回值: 无 ******************...