Arduino-Storage
External Memory Storage library for Arduino
EEPROM.ino
Go to the documentation of this file.
1 
17 #include "Storage.h"
18 #include "Driver/EEPROM.h"
19 
20 // EEPROM internal storage
22 
23 // Local memory buffer
24 const int BUF_MAX = 1000;
25 static uint8_t buf[BUF_MAX];
26 
27 void setup()
28 {
29  Serial.begin(57600);
30  while (!Serial);
31  }
32 
33 void loop()
34 {
35  static uint8_t n = 0;
36  for (int i = 0; i < BUF_MAX; i++) buf[i] = n + i;
37 
38  Serial.print(F("eeprom.SIZE(bytes): "));
39  Serial.println(eeprom.SIZE);
40  Serial.println();
41 
42  // Benchmark#1: Measure write with increasing buffer size
43  Serial.println(F("write(N, us, us/byte, kbyte/s)"));
44  Serial.flush();
45  for (int i = 1; i < 10000; i *= 10) {
46  uint32_t start = micros();
47  eeprom.write(0x0000, buf, i);
48  uint32_t us = micros() - start;
49  float uspb = ((float) us) / i;
50  Serial.print(i);
51  Serial.print(F(", "));
52  Serial.print(us);
53  Serial.print(F(", "));
54  Serial.print(uspb);
55  Serial.print(F(", "));
56  Serial.println(1000 / uspb);
57  Serial.flush();
58  }
59  Serial.println();
60 
61  for (int i = 0; i < BUF_MAX; i++) buf[i] = 0;
62 
63  // Benchmark#2: Measure read with increasing buffer size
64  Serial.println(F("read(N, us, us/byte, kbyte/s)"));
65  Serial.flush();
66  for (int i = 1; i < 10000; i *= 10) {
67  uint32_t start = micros();
68  eeprom.read(buf, 0x0000, i);
69  uint32_t us = micros() - start;
70  float uspb = ((float) us) / i;
71  Serial.print(i);
72  Serial.print(F(", "));
73  Serial.print(us);
74  Serial.print(F(", "));
75  Serial.print(uspb);
76  Serial.print(F(", "));
77  Serial.println(1000 / uspb);
78  Serial.flush();
79  }
80  Serial.println();
81 
82  for (int i = 0; i < BUF_MAX; i++) {
83  if (buf[i] != ((n + i) & 0xff)) {
84  Serial.print(i);
85  Serial.println(F(": verification error"));
86  break;
87  }
88  }
89  n += 1;
90 
91  delay(5000);
92 }
const uint32_t SIZE
Definition: Storage.h:30
Definition: EEPROM.h:27
const int BUF_MAX
Definition: EEPROM.ino:24
static uint8_t buf[BUF_MAX]
Definition: EEPROM.ino:25
virtual int read(void *dst, uint32_t src, size_t count)
Definition: EEPROM.h:44
virtual int write(uint32_t dst, const void *src, size_t count)
Definition: EEPROM.h:60
void setup()
Definition: EEPROM.ino:27
void loop()
Definition: EEPROM.ino:33
EEPROM eeprom
Definition: EEPROM.ino:21