11 const uint32_t totalKBytes = 32;
14 const uint8_t btnStart = 6;
18 pinMode(btnStart, INPUT_PULLUP);
22 Serial.print(F(
"extEEPROM.begin() failed, status = "));
23 Serial.println(eepStatus);
27 Serial.println(F(
"Press button to start..."));
28 while (digitalRead(btnStart) ==
HIGH) {
49 void eeWrite(uint8_t chunk)
54 Serial.println(F(
"Writing..."));
55 uint32_t msStart = millis();
57 for (uint32_t addr = 0; addr < totalKBytes * 1024; addr += chunk) {
58 if ( (addr & 0xFFF) == 0 ) {
61 for (uint8_t c = 0; c < chunk; c += 4) {
62 data[c + 0] = val >> 24;
63 data[c + 1] = val >> 16;
64 data[c + 2] = val >> 8;
70 uint32_t msLapse = millis() - msStart;
71 Serial.print(F(
"Write lapse: "));
72 Serial.print(msLapse);
73 Serial.println(F(
" ms"));
77 void eeRead(uint8_t chunk)
81 uint32_t val = 0, testVal;
82 Serial.println(F(
"Reading..."));
83 uint32_t msStart = millis();
85 for (uint32_t addr = 0; addr < totalKBytes * 1024; addr += chunk) {
86 if ( (addr & 0xFFF) == 0 ) {
90 for (uint8_t c = 0; c < chunk; c += 4) {
91 testVal = ((uint32_t)
data[c + 0] << 24) + ((uint32_t)
data[c + 1] << 16) + ((
92 uint32_t)
data[c + 2] << 8) + (uint32_t)
data[c + 3];
94 Serial.print(F(
"Error @ addr "));
95 Serial.print(addr + c);
96 Serial.print(F(
" Expected "));
98 Serial.print(F(
" Read "));
99 Serial.print(testVal);
100 Serial.print(F(
" 0x"));
101 Serial.println(testVal, HEX);
106 uint32_t msLapse = millis() - msStart;
107 Serial.print(F(
"Last value: "));
109 Serial.print(F(
" Read lapse: "));
110 Serial.print(msLapse);
111 Serial.println(F(
" ms"));
115 void eeErase(uint8_t chunk, uint32_t startAddr, uint32_t endAddr)
119 Serial.println(F(
"Erasing..."));
120 for (
int i = 0; i < chunk; i++) {
123 uint32_t msStart = millis();
125 for (uint32_t a = startAddr; a <= endAddr; a += chunk) {
126 if ( (a & 0xFFF) == 0 ) {
131 uint32_t msLapse = millis() - msStart;
132 Serial.print(F(
"Erase lapse: "));
133 Serial.print(msLapse);
134 Serial.print(F(
" ms"));
139 void dump(uint32_t startAddr, uint32_t nBytes)
141 Serial.print(F(
"EEPROM DUMP 0x"));
142 Serial.print(startAddr, HEX);
143 Serial.print(F(
" 0x"));
144 Serial.print(nBytes, HEX);
145 Serial.print(F(
" "));
146 Serial.print(startAddr);
147 Serial.print(F(
" "));
148 Serial.println(nBytes);
149 uint32_t nRows = (nBytes + 15) >> 4;
152 for (uint32_t r = 0; r < nRows; r++) {
153 uint32_t a = startAddr + 16 * r;
155 Serial.print(F(
"0x"));
156 if ( a < 16 * 16 * 16 ) {
157 Serial.print(F(
"0"));
160 Serial.print(F(
"0"));
163 Serial.print(F(
"0"));
165 Serial.print(a, HEX);
166 Serial.print(F(
" "));
167 for (
int c = 0; c < 16; c++ ) {
169 Serial.print(F(
"0"));
170 Serial.print(d[c], HEX);
171 Serial.print( c == 7 ?
" " :
" ");
174 Serial.println(F(
""));