implement verifyBlock (#67)

- Fix #64, compiler warning.
- add **verifyBlock(memoryAddress, buffer, length)**
- add example **I2C_eeprom_verifyBlock.ino**
- update GitHub actions
- update keywords.txt
- update examples
- update readme.md
This commit is contained in:
Rob Tillaart
2024-03-28 10:35:30 +01:00
committed by GitHub
parent af9448c770
commit f3e70ff3cf
14 changed files with 258 additions and 26 deletions
@@ -39,11 +39,6 @@ void setup()
SERIAL_OUT.println("ERROR: Can't find eeprom\nstopped...");
while (1);
}
SERIAL_OUT.print("I2C eeprom library: ");
SERIAL_OUT.print(I2C_EEPROM_VERSION);
SERIAL_OUT.println("\n");
SERIAL_OUT.print("isConnected:\t");
SERIAL_OUT.println(ee.isConnected());
@@ -0,0 +1,44 @@
I2C_EEPROM_VERSION: 1.8.2
Testruns NN: 100
TEST: NN x writeByte()
DUR1: 466516
TEST: NN x writeByteVerify()
DUR1: 542336
TEST: NN x updateByte() same data
DUR2: 58616
TEST: NN x updateByteVerify() same data
DUR2: 116896
TEST: NN x updateByteVerify() not same data
DUR2: 596672
TEST: NN x writeBlock()
DUR1: 1414432
TEST: NN x writeBlockVerify()
DUR1: 2010844
TEST: NN x updateBlock() same data
DUR2: 594796
TEST: NN x updateBlockVerify() same data
DUR2: 1186644
TEST: NN x updateBlockVerify() not same data
DUR2: 1204960
TEST: NN x setBlock() same data
DUR2: 1415932
TEST: NN x setBlockVerify() same data
DUR2: 2014048
TEST: NN x setBlockVerify() not same data
DUR2: 2009780
done...
@@ -0,0 +1,99 @@
//
// FILE: I2C_eeprom_verifyBlock.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo I2C_EEPROM library
//
// uses a 24LC256 (32KB) EEPROM
#include "Wire.h"
#include "I2C_eeprom.h"
I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC256);
uint32_t start, dur1;
char buffer[] = "12345678901234567890123456789012345678901234567890"; // 50 bytes
void setup()
{
Serial.begin(115200);
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
Serial.println(__FILE__);
Serial.print("I2C_EEPROM_VERSION: ");
Serial.println(I2C_EEPROM_VERSION);
Wire.begin();
ee.begin();
if (! ee.isConnected())
{
Serial.println("ERROR: Can't find eeprom\nstopped...");
while (1);
}
delay(10);
//////////////////////////////////////////////////////////////////////
Serial.println("\nTEST: writeBlock()");
delay(10);
start = micros();
ee.writeBlock(0, (uint8_t *) buffer, 50);
dur1 = micros() - start;
Serial.print("DUR1: ");
Serial.println(dur1);
delay(10);
Serial.println("\nTEST: verifyBlock() no change");
delay(10);
start = micros();
if (ee.verifyBlock(0, (uint8_t *) buffer, 50) == false)
{
Serial.print("X");
}
dur1 = micros() - start;
Serial.print("DUR1: ");
Serial.println(dur1);
delay(10);
for (uint8_t loc = 0; loc < 50; loc += 5)
{
disrupt(loc);
}
Serial.println("done...");
}
void loop()
{
}
void disrupt(uint8_t location)
{
bool flag = true;
// disrupt memory
Serial.print("\nTEST: verifyBlock() after change @ ");
Serial.println(location);
delay(10);
ee.writeBlock(0, (uint8_t *) buffer, 50);
ee.writeByte(location, 255);
start = micros();
if (ee.verifyBlock(0, (uint8_t *) buffer, 50) == false)
{
flag = false;
}
dur1 = micros() - start;
Serial.print("DUR1: ");
Serial.println(dur1);
Serial.println(flag);
delay(10);
}
// -- END OF FILE --