#define uchar unsigned char
#endif
#define SEC
#define MIN
#define HOUR
#define DAY
#define WEEK
#define MONTH
#define YEAR
define read_ADD 0xA3 //Write device address
#define write_ADD 0xA2 //Read device address
tm timer_8563;
// char ResetTime[ResetTime_Len];
#define PCF8563_SCK_High()
#define PCF8563_SCK_Low()
#define PCF8563_DATA_High() {
#define PCF8563_DATA_Low()
#define PCF8563_DATA_In()
#define PCF8563_DATA_Sta()
void Delay_8563()
{
int i=100;
while(i--);
}
void Start()
{
PCF8563_DATA_High();
PCF8563_SCK_High();
Delay_8563();
PCF8563_DATA_Low();
Delay_8563();
PCF8563_SCK_Low();
}
void Stop()
{
PCF8563_DATA_Low();
PCF8563_SCK_Low();
Delay_8563();
PCF8563_SCK_High();
Delay_8563();
PCF8563_DATA_High();
Delay_8563();
}
void WriteACK(uchar ack)
{
if(ack)
{
PCF8563_SCK_High();
}
else
{
PCF8563_SCK_Low();
}
Delay_8563();
PCF8563_SCK_High();
Delay_8563();
PCF8563_SCK_Low();
}
void WaitACK()
{
uchar errtime=20;
PCF8563_DATA_High();
Delay_8563();
PCF8563_SCK_High();
Delay_8563();
PCF8563_DATA_In();
while(PCF8563_DATA_Sta())
{
errtime--;
if(!errtime) Stop();
}
PCF8563_SCK_Low();
Delay_8563();
}
void writebyte(uchar wdata)
{
uchar i;
for(i=0;i<8;i++)
{
if(wdata&0x80)
{
PCF8563_DATA_High();
}
else
{
PCF8563_DATA_Low();
}
wdata<<=1;
PCF8563_SCK_High();
Delay_8563();
PCF8563_SCK_Low();
}
WaitACK();
}
uchar Readbyte()
{
uchar i,bytedata;
PCF8563_DATA_High();
for(i=0;i<8;i++)
{
PCF8563_SCK_High();
bytedata<<=1;
PCF8563_DATA_In();
if(PCF8563_DATA_Sta())
bytedata|=0x01;
else
bytedata|=0x00;
PCF8563_SCK_Low();
Delay_8563();
}
return(bytedata);
}
void writeData(uchar address,uchar mdata)
{
Start();
writebyte(0xa2);
writebyte(address);
writebyte(mdata);
Stop();
}
uchar ReadData(uchar address)
{
uchar rdata;
Start();
writebyte(0xa2);
writebyte(address);
Start();
writebyte(0xa3);
rdata=Readbyte();
WriteACK(1);
Stop();
return(rdata);
}
void ReadData1(uchar address,uchar count,uchar * buff)
{
uchar i;
Start();
writebyte(0xa2);
writebyte(address);
Start();
writebyte(0xa3);
for(i=0;i
{
buff[i]=Readbyte();
if(i
}
WriteACK(1);
Stop();
}
void P8563_set_time(u8 year,u8 month,u8 day,u8 hour,u8 min,u8 sec,u8 week)
{
}
void P8563_get_time()
{
}
void P8563_init(void)
{
}
Previous article:SST25VF016B serial flash driver based on STM32F10x
Next article:Porting fatfs file system to STM32F10x
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- There is a new IoT product project that is about to be launched, but the definitions of the parameters of the Bluetooth chip NRF52832 are not yet clear,...
- [Io Development Notes] Gizwits Smart Watering Device Practice (3) - Automatically Generate Code Transplantation
- MSP430 Series Embedded Experiment Tutorial---Basics
- Which of the current mainstream smart home wireless protocols is better?
- I heard that some people don’t understand flexible arrays?
- I have a question for you. I made a buck circuit, but the inductor whistles when it is loaded. What is the reason?
- [STM32WB55 review]——by freebsder
- DSP 28335
- There is a large supply of microcontrollers!
- Share the C language program of FIR filter implemented by MSP430 microcontroller