void WriteChar(unsigned int addr,unsigned char ch)
{
unsigned char c;
c=((*((unsigned char *)&addr))<<1)&0x02;
Start();
SendChar(0xa0|c);
ACK();
SendChar(addr);
ACK();
SendChar(ch);
ACK();
Stop();
for(ch=0xff;ch!=0;ch--) ;
}
unsigned char ReadChar(unsigned int addr)
{
unsigned char ch;
ch=((*((unsigned char *)&addr))<<1)&0x02;
Start();
SendChar(0xa0|ch);
ACK();
SendChar(addr);
ACK();
Start();
SendChar(0xa1|ch);
ACK();
ch=RecChar();
Stop();
return ch;
}
//-----------------------------------------------------------------------------
// SiLabs_Startup() Routine
// ----------------------------------------------------------------------------
// This function is called immediately after reset, before the initialization
// code is run in SILABS_STARTUP.A51 (which runs before main() ). This is a
// useful place to disable the watchdog timer, which is enable by default
// and may trigger before main() in some instances.
//-----------------------------------------------------------------------------
void SiLabs_Startup (void)
{
// Disable the watchdog here
}
//-----------------------------------------------------------------------------
// main() Routine
// ----------------------------------------------------------------------------
// Note: the software watchdog timer is not disabled by default in this
// example, so a long-running program will reset periodically unless
// the timer is disabled or your program periodically writes to it.
//
// Review the "Watchdog Timer" section under the part family's datasheet
// for details. To find the datasheet, select your part in the
// Simplicity Launcher and click on "Data Sheet".
//-----------------------------------------------------------------------------
int main (void)
{
unsigned int i;
char flag=0;