Skip to content

Commit d1753ea

Browse files
author
Nathan Seidle
committed
Byte write() now uses block write.
1 parent faa9632 commit d1753ea

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

libraries/EEPROM/examples/Example2_AllFunctions/Example2_AllFunctions.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void setup()
5757
EEPROM.write(randomLocation, myValue1); //(location, data)
5858
endTime = millis();
5959

60-
Serial.printf("Write identical byte to same location (should be 0): %dms\n", endTime - startTime);
60+
Serial.printf("Write identical byte to same location (should be ~1): %dms\n", endTime - startTime);
6161

6262
byte response1 = EEPROM.read(randomLocation);
6363
byte response2 = EEPROM.read(randomLocation + 1);

libraries/EEPROM/src/EEPROM.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@
4747
//affecting other bytes in this flash word
4848
void write(uint16_t eepromLocation, uint8_t dataToWrite)
4949
{
50-
uint32_t flashLocation = AP3_FLASH_EEPROM_START + eepromLocation;
51-
writeWordToFlash(flashLocation, (uint32_t)dataToWrite | 0xFFFFFF00);
50+
EEPROM.writeBlockToEEPROM(eepromLocation, &dataToWrite, 1);
5251
}
5352

5453
//Read a byte from a given location in "EEPROM"
@@ -206,17 +205,7 @@ void EEPROMClass::writeBlockToEEPROM(uint16_t eepromLocation, const uint8_t *dat
206205
spot++;
207206
}
208207

209-
// Serial.println("");
210-
// Serial.print("EEPROM Contents:");
211-
// for (uint16_t x = 0; x < 32; x++)
212-
// {
213-
// if (x % 8 == 0)
214-
// Serial.println();
215-
// Serial.printf("0x%08X ", eepromContentWords[x]);
216-
// }
217-
// Serial.println();
218-
219-
// //Then we write the contents of the array back
208+
//Then we write the contents of the array back
220209
am_hal_flash_program_main(AM_HAL_FLASH_PROGRAM_KEY,
221210
flashContent,
222211
(uint32_t *)AP3_FLASH_EEPROM_START,

0 commit comments

Comments
 (0)