Browse Source

Add eeprom tests

master
Starbeamrainbowlabs 2 years ago
parent
commit
bed9a808b9
Signed by: sbrl GPG Key ID: 1BE5172E637709C2
4 changed files with 74 additions and 0 deletions
  1. +3
    -0
      .gitmodules
  2. +41
    -0
      eeprom-search/eeprom-search.ino
  3. +29
    -0
      eeprom/eeprom.ino
  4. +1
    -0
      eeprom/lib/AT24Cx

+ 3
- 0
.gitmodules View File

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

+ 41
- 0
eeprom-search/eeprom-search.ino 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
- 0
eeprom/eeprom.ino 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
- 0
eeprom/lib/AT24Cx

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

Loading…
Cancel
Save