Hi,
a few days ago, I started to write a library for my Microchip 24LC256 EEPROM to work seamlessly with my Arduino Due (or the DigiX).
As you will see, all instructions follow the same structure. Here are the functions that my library include:
-bytewise writing/reading: The basic access to your EEPROM.
--
void extEEPROMwrite(int address, byte data_to_be_stored); -> stores one byte at EEPROM address "addr"
--
byte extEEPROMread(int addr); -> reads the EEPROM at address "addr" and returns that value (byte)
You want to store your larger numbers in your external EEPROM? For example sensor values or even a 32 bit integer? You want very easy access to your values, without taking care for the segmentation and reconstruction process? Then take a look at the following ones:
-write/read Sensordata with up to 16 bits: For example your sensor data.
--
void extEEPROMwriteSensor(int addr, int data_to_be_stored);--
int extEEPROMreadSensor(int addr);-write/read a complete 32 bit integer: Don't care about sizes, just save your data!
--
void extEEPROMwriteInt(int addr, int data_to_be_stored);--
int extEEPROMreadInt(int addr);---> There is absolutely no difference between using byte "write"/"read" or "writeSensor"/"readSensor" + "writeInt"/"readInt"! Ok, if you use the "...Sensor" and "...Int" functions, you have to feed them with integers instead of bytes.
Another cool thing is "page writing/reading". You want to store an array in your EEPROM? No problem!
-write/read pages:
--
void extEEPROMwritePage(int startaddress, byte* data_origin_array, int amount_of_transfered_bytes); -> You have to specify three inputs: 1. The EEPROM address where you want to start writing / 2. a pointer to the array you want to save (see demo) / 3. the size of the array*
--
void extEEPROMreadPage(int startaddress, byte* data_target_array, int amount_of_transfered_bytes); -> Again three inputs: 1. Startaddress / 2. a pointer to an array where you want to save your data / 3. the number of bytes you want to read*
* = Due to the limitations of the Wire Library, you are only able to read 32 bytes / to write 30 bytes at once!!!
You can download my library and a demo sketch at:
https://github.com/IngloriousEngineer/ArduinoRoadmap:
a.) more functions will be included
b.) ability to have more than one EEPROM on a I2C/TWI bus. ---- DONE ✔
c.) Once I have the final specifications, I will adjust my code to work with the DigiX onboard I2C EEPROM!
If you have any questions or want to see a special function in future releases:
PLEASE LEAVE A COMMENT!