Add eeprom tests

This commit is contained in:
Starbeamrainbowlabs 2018-04-27 23:16:29 +01:00
parent a01a7607f8
commit bed9a808b9
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
4 changed files with 74 additions and 0 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "eeprom/lib/AT24Cx"]
path = eeprom/lib/AT24Cx
url = https://github.com/cyberp/AT24Cx.git

View file

@ -0,0 +1,41 @@
/*
*
* Search for an EEPROM.
* This sketch iterate the eight possible I2C addresses and
* checks if an EEPROM is found.
*
* Written by Christian Paul, 2014-11-24
*
*
*/
// include libraries
#include <Wire.h>
// setup
void setup() {
Serial.begin(9600);
Serial.println("AT24CX search");
Serial.println("-------------------------");
Wire.begin();
int i2c = 0x50;
for (int i=0; i<8; i++) {
Serial.print("Search at [");
Serial.print(i2c, HEX);
Serial.print("]: ");
Wire.beginTransmission(i2c);
int result = Wire.endTransmission();
if (result==0)
Serial.println("FOUND!");
else
Serial.println("not found");
i2c++;
}
}
// main loop
void loop() {}

29
eeprom/eeprom.ino Normal file
View file

@ -0,0 +1,29 @@
#include "lib/AT24Cx/AT24CX.h"
#include "lib/AT24Cx/AT24CX.cpp"
char dataTemplate[] = "Heya!";
AT24C64 eeprom;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print("Writing to chip - ");
eeprom.writeChars(200, dataTemplate, sizeof(dataTemplate));
Serial.println("done");
Serial.print("Data: ");
Serial.print(dataTemplate);
Serial.println();
delay(1000);
Serial.print("Data on chip: '");
char data[5];
eeprom.readChars(200, data, sizeof(data));
Serial.print(data);
Serial.println("'");
delay(1000);
}

1
eeprom/lib/AT24Cx Submodule

@ -0,0 +1 @@
Subproject commit a271dcb7a1a4881692fd81f13f53f80b1863bf24