/*****************************************
AT24C64C语言程序
copyright@lance
******************************************/
#include <REG51.H>
#include <intrins.h>
//#include"AT24C64.h"
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
sbit ISDA=P1^0;
sbit ISCL=P1^1;
sbit LED=P2^0;
void Delay16(unsigned int i)
{
while(i--);
}
/*****************************************
i2c project
******************************************/
void I2cInit(void);
void I2cStart(void);
void I2cStop(void);
void I2cWait(void);
bit I2cSentByte(uchar bytedata);
void SendAcknowledge(bit ack);
/*****************************************
i2c start
condition SDA 1-0 while SCL=1
******************************************/
void I2cStart(void)
{
ISDA=1;
ISCL=1;
I2cWait();
ISDA=0;
I2cWait();
ISCL=0;
}
/*****************************************
I2c sotp
condition SDA=0-1 while SCL=1
******************************************/
void I2cStop(void)
{
ISDA=0;
I2cWait();
ISCL=1;
I2cWait();
ISDA=1;
}