This repository has been archived by the owner on Feb 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
EEPROM_Clear.ino
58 lines (42 loc) · 1.84 KB
/
EEPROM_Clear.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/******************************************************************************************************************************************
EEPROM_Clear.ino
For STM32 using Flash emulated-EEPROM
The FlashStorage_STM32 library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
of STM32F/L/H/G/WB/MP1. It's using the buffered read and write to minimize the access to Flash.
It now supports writing and reading the whole object, not just byte-and-byte.
Inspired by Cristian Maglie's FlashStorage (https://github.com/cmaglie/FlashStorage)
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_STM32
Licensed under MIT license
******************************************************************************************************************************************/
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <FlashStorage_STM32.h>
void setup()
{
Serial.begin(115200);
while (!Serial);
delay(200);
Serial.print(F("\nStart EEPROM_Clear on "));
Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32_VERSION);
// initialize the LED pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Serial.print("Emulated EEPROM length (bytes) = ");
Serial.println(EEPROM.length());
unsigned long startMillis = millis();
for (int i = 0 ; i < EEPROM.length() ; i++)
{
EEPROM.write(i, 0);
}
EEPROM.commit();
// The time spent can be very short (4-5ms) if the EEPROM is not dirty.
// For F767ZI, the time is around 1.1s for 16384 bytes of emulated-EEPROM
Serial.print("Done clearing emulated EEPROM. Time spent (ms) = ");
Serial.println(millis() - startMillis);
// turn the LED on when we're done
digitalWrite(LED_BUILTIN, HIGH);
}
void loop()
{
/** Empty loop. **/
}