bit allow,genggai,ok,wanbi,retry,close,qinchu,enter;
sbit beep=P3^6;
sbit Lock=P3^7;
sbit GLED=P3^5;
sbit RLED=P3^4;
sbit SCL = P3^3;
sbit SDA = P3^2; //定义引脚变量
unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,
0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00,0x40,0x5e,0x79,0x77,0x08}; // 定 义 数
组
void InitI2C();
void I2CStart();
void I2CStop();
void I2CSend(uchar byte);
uchar I2CRead();
uchar read_eeprom(uchar addr);
void write_eeprom(uchar addr, uchar databyte);
void delay(unsigned int i)
{uint j,k;for(j=i;j>0;j--)for(k=125;k>0;k--);} //延时子程序
void InitI2C()
{SDA = 1;SCL = 1;} //配置模拟 I2C 的 IO 端口
void I2CStart()
{SDA = 1;
delay(1);
SCL = 1;delay(1);
SDA = 0;
delay(1);
SCL = 0;
} //发送 I2C 总线起始状态
void I2CStop()
{SCL = 0;
delay(1);
SDA = 0;
delay(1);
SCL = 1;
delay(1);
SDA = 1;
评论0
最新资源