}
void SendData(char dat)
{
I2CTXD = dat; //Write data to the data buffer
busy = 1;
I2CMSCR = 0x82; //Send a SEND command
while (busy);
}
void RecvACK()
{
busy = 1;
I2CMSCR = 0x83; //Send read ACK command
while (busy);
}
char RecvData()
{
busy = 1;
I2CMSCR = 0x84; //Send RECV command
while (busy);
return I2CRXD;
}
void SendACK()
{
I2CMSST = 0x00; //Setup the ACK signal
busy = 1;
I2CMSCR = 0x85; //Send ACK command
while (busy);
}
void SendNAK()
{
I2CMSST = 0x01; //Setup the NAK signal
busy = 1;
I2CMSCR = 0x85; //Send ACK command
while (busy);
}
void Stop()
{
busy = 1;
I2CMSCR = 0x86; //Send STOP command
while (busy);
}
void Delay()
{
int i;
for (i=0; i<3000; i++)
{
_nop_();
_nop_();
_nop_();
_nop_();