Skip to content

Commit c2bc1cc

Browse files
committed
NVM: Add erase function
1 parent 55f9ea1 commit c2bc1cc

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Firmware/LoRaSerial/NVM.ino

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,29 @@ void nvmSaveVcUniqueId(int8_t vc)
198198
if (memcmp(id, virtualCircuitList[vc].uniqueId, sizeof(id)) != 0)
199199
nvmSaveUniqueId(vc, virtualCircuitList[vc].uniqueId);
200200
}
201+
202+
//Erase the entire EEPROM
203+
void nvmErase()
204+
{
205+
int address;
206+
int length;
207+
uint8_t value[64];
208+
209+
//Get the EEPROM length
210+
length = EEPROM.length();
211+
212+
//Set the erase value
213+
memset(&value, NVM_ERASE_VALUE, sizeof(value));
214+
215+
//Erase the EEPROM
216+
address = 0;
217+
while (address < length)
218+
{
219+
petWDT();
220+
EEPROM.put(address, value);
221+
address += sizeof(value);
222+
}
223+
224+
//Finish the write
225+
arch.eepromCommit();
226+
}

0 commit comments

Comments
 (0)