More problems with Digilent EEPROM library. Made functions from their stuff - not sure if correct, but it works.
//#include
#include
#define IOShieldEEPROMAddr 0x50
int ld4 = 74;
void setup() {
char buf[26];
char single;
int i;
pinMode(ld4, OUTPUT);
Serial.begin(9600);
Serial.println("Serial Port 9600");
Wire.begin();
//Write the alphabet to the EEPROM
//The data length is assumed in this example because the data
//is a string. If you write an array numbers to EEPROM then the
//length of the array must be provided.
//IOShieldEEPROM.writeString(0,"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
//char new_string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//uint8_t data = new_string.toInt();
writeString(0,"ABCDEFGHIJKLMNOPQRSTUVWXYZ",strlen("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
digitalWrite(ld4, HIGH); // set the LED on
delay(2000);
//Read alphabet back and print to monitor
//IOShieldEEPROM.readString(0, buf, 26);
readString(0, buf, 26);
Serial.print(buf);
Serial.println();
//Write a single character
write(20,'@');
//Read all characters back
readString(0, buf, 26);
Serial.print(buf);
Serial.println();
//Read back last letter
single = read(20);
Serial.print(single);
}
void loop() {
Serial.println("hello");
delay(5000);
}
uint8_t read(uint16_t address) {
char temp;
readString(address, &temp, 1);
return temp;
}
void write(uint16_t address, char data) {
writeString(address, &data, 1);
}
void readString(uint16_t address, char *sz, int size) {
uint8_t temp[2] = {0,0};
int index = 0;
temp[0] = (address >> 8);
temp[1] = (address & 0xFF);
Wire.beginTransmission(IOShieldEEPROMAddr);
Wire.send(temp, 2);
Wire.endTransmission();
Wire.requestFrom(IOShieldEEPROMAddr, size);
while(Wire.available()) {
sz[index++] = Wire.receive();
}
//twi_writeTo(IOShieldEEPROMAddr, temp, 2, 1);
//twi_readFrom(IOShieldEEPROMAddr, sz, size);
}
void writeString(uint16_t address, char *data, int size) {
int i;
uint8_t temp[67] = {0,0,0};
temp[0] = (address >> 8);
temp[1] = (address & 0xFF);
if(size > 64) {
size = 64;
}
for(i=0; i