#include <startup.h>
#include <LPC214x.H>                        /* LPC21xx definitions */
#include <TFT018.h>
#include <rprintf.h>
#include "EEPROM.h"

#define C02 0x0

char s[20], *sp;
int input_str(int ch){
	*sp ++ = (char)ch;
	*sp = 0;
	return ch;
}

/*----------------------------------------------------------*\
 | MAIN ENTRY                                               |
\*----------------------------------------------------------*/
int main() {
	char s[20];
	unsigned char Addr,Data;

	Initialize();
	BacklightOn();
	LCD_Init();
	LCD_Clear_Screen(Blue);
	InitEEPROM();

	Addr = 0x01;
	Data = 0xA5;

	LCD_PutString(10,10,"IIC Test",0xF800,0xFFE0);

	WriteEEPROM(C02, Addr, Data);
	sp = s;
	rprintf_devopen( input_str );
	rprintf("ADDR %X WRITE %X",Addr,Data);
	LCD_PutString(1,30,s,0xF800,0xFFE0);

	AddressEEPROM(C02,Addr);
	Data = ReadEEPROM(C02);
	sp = s;
	rprintf_devopen( input_str );
	rprintf("ADDR %X READ %X",Addr,Data);
	LCD_PutString(1,60,s,0xF800,0xFFE0);

	for(;;) {
		}
	}
