
#include<I2C.h>
#include<generic.h>

void main()
{
char BYTE_GET = 0x00,DATA_ = 0x11;
GREEN_LED = 0;//Just an indication for my hardware
YELLOW_LED = 0;//Just an indication for my hardware
sec_wait(1);//1 second delay
GREEN_LED = 1;//Just an indication for my hardware
YELLOW_LED = 1;//Just an indication for my hardware
sec_wait(1);//1 second delay

/********WRITE TO ADDRESS********/
i2c_transmit_start();
i2c_transmit_byte(0xA0);
i2c_transmit_byte(0xAA);//First Byte address
i2c_transmit_byte(0xAA);//Second Byte address
i2c_transmit_byte(DATA_);
i2c_transmit_stop();

/********READ FROM ADDRESS*******/
i2c_transmit_start();
i2c_transmit_byte(0xA0);
i2c_transmit_byte(0xAA);//First Byte address
i2c_transmit_byte(0xAA);//Second Byte address
i2c_transmit_start();
i2c_transmit_byte(0xA1);
BYTE_GET = i2c_receive_byte(I2C_NAK);

i2c_transmit_stop();

if(BYTE_GET == DATA_)//Comparing the data send to the data that is recieved
     GREEN_LED = 0;//GREEN glows if both are same
else
     YELLOW_LED = 0;//Yellow if both are different
sec_wait(1);
GREEN_LED = 1;
YELLOW_LED = 1;
sec_wait(1);
DATA_ ++;//data to be sent is incremented by one so that the next data send is different from the one that was sent last time.
