#include "STC8h.h"
#include "usart.h"
#include "delay.h"
#include "stdio.h"
#include "intrins.h"
sbit SDA = P1^4;
sbit SCL = P1^5;
unsigned char Register_Data;
bit busy;
void I2C_Isr() interrupt 24
{
// _push_(P_SW2);
P_SW2 |= 0x80;
if (I2CMSST & 0x40)
{
I2CMSST &= ~0x40; //?????
busy = 0;
}
// _pop_(P_SW2);
}
void Start()
{
busy = 1;
I2CMSCR = 0x81; //??START??
while (busy);
}
void SendData(char dat)
{
I2CTXD = dat; //?????????
busy = 1;
I2CMSCR = 0x82; //??SEND??
while (busy);
usart_send_char(busy);
}
void RecvACK()
{
busy = 1;
I2CMSCR = 0x83; //???ACK??
while (busy);
}
char RecvData()
{
busy = 1;
I2CMSCR = 0x84; //??RECV??
while (busy);
return I2CRXD;