Универсальная библиотека для работы с внешней EEPROM (24XX02 - 24XX512) по I2C протоколу.
Работа с микросхемами типа 24C04, 24C16, 24C32 и т.д. Пример использования
#include "ds_external_eeprom_i2c.h"
// for AT24C256, address 0x50
ds_external_eeprom_i2c ext_eeprom(ds_external_eeprom_i2c::MODEL_24_256,0x50);
void setup(){
Serial.begin(9600);
Serial.print("Check EXT_EEPROM: ");
Serial.println(ext_eeprom.check() ? "OK":"FALSE");
Serial.println("Write byte to EEPROM memory...");
ext_eeprom.writeByte(0,0xAA);
Serial.print("Read byte from EEPROM memory... ");
Serial.println(ext_eeprom.readByte(0), HEX);
Serial.println("\n\n");
// Declare byte arrays.
byte inputBytes[100] = { 0 };
byte outputBytes[100] = { 0 };
// Fill input array.
for (byte i = 0; i < 32; i++) inputBytes[i] = i;
// Write input array to EEPROM memory.
Serial.println("Write bytes to EEPROM memory...");
ext_eeprom.writeBytes(0x00, 32, inputBytes);
// Read array with bytes read from EEPROM memory.
Serial.println("Read bytes from EEPROM memory...");
ext_eeprom.readBytes(0x00, 32, outputBytes);
for (byte i = 0; i < 32; i++){
Serial.print(outputBytes[i], HEX); Serial.print(" ");
}
}
void loop(){
}
|