Skip to content

Commit 669bb4f

Browse files
committed
Move writeBlock function outside of class.
1 parent af4e137 commit 669bb4f

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

libraries/EEPROM/examples/Example2_AllFunctions/Example2_AllFunctions.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void setup()
3030

3131
long startTime;
3232
long endTime;
33-
uint16_t randomLocation;
33+
int randomLocation;
3434

3535
//Test erase time
3636
startTime = millis();

libraries/EEPROM/src/EEPROM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
//Write a byte to a given "EEPROM" location
4444
void write(uint16_t eepromLocation, uint8_t dataToWrite)
4545
{
46-
EEPROM.writeBlockToEEPROM(eepromLocation, &dataToWrite, 1);
46+
writeBlockToEEPROM(eepromLocation, &dataToWrite, 1);
4747
}
4848

4949
//Read a byte from a given location in "EEPROM"
@@ -65,7 +65,7 @@ void EEPROMClass::erase()
6565
//2) Record user data into SRAM. Check if new data is different from flash.
6666
//3) Erase flash page (8k)
6767
//4) Write SRAM back into flash
68-
void EEPROMClass::writeBlockToEEPROM(uint16_t eepromLocation, const uint8_t *dataToWrite, uint16_t blockSize)
68+
void writeBlockToEEPROM(uint16_t eepromLocation, const uint8_t *dataToWrite, uint16_t blockSize)
6969
{
7070
//Error check
7171
if (eepromLocation + blockSize >= AP3_FLASH_EEPROM_SIZE)

libraries/EEPROM/src/EEPROM.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@
6464
Error : EEPROM start address must be divisble by 8192
6565
#endif
6666

67-
//By limiting EEPROM size to 1024 bytes, we reduce the amount of SRAM required and
68-
//time needed to mask in individual bytes and words into flash. It can be increased
69-
//to 8096 if needed
70-
#define AP3_FLASH_EEPROM_SIZE 1024 //In bytes
67+
//By limiting EEPROM size to 1024 bytes, we reduce the amount of SRAM required and
68+
//time needed to read/write words into flash. It can be increased
69+
//to 8096 if needed
70+
const int AP3_FLASH_EEPROM_SIZE = 1024 * 2; //In bytes
7171

72-
uint8_t
73-
read(uint16_t eepromLocation);
72+
uint8_t read(uint16_t eepromLocation);
7473
void write(uint16_t eepromLocation, uint8_t dataToWrite);
74+
void writeBlockToEEPROM(uint16_t eepromLocation, const uint8_t *dataToWrite, uint16_t blockSize);
7575

7676
struct EERef
7777
{
@@ -164,7 +164,6 @@ struct EEPROMClass
164164
void write(int idx, uint8_t val) { (EERef(idx)) = val; }
165165
void update(int idx, uint8_t val) { EERef(idx).update(val); }
166166
void erase();
167-
void writeBlockToEEPROM(uint16_t eepromLocation, const uint8_t *dataToWrite, uint16_t blockSize);
168167

169168
//STL and C++11 iteration capability.
170169
EEPtr

0 commit comments

Comments
 (0)