Skip to content

Commit 0bd21b1

Browse files
authored
Merge pull request #18 from romain145/multi_page_write_fix
Fix multi-page write
2 parents 271b3c6 + 0b937de commit 0bd21b1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/SparkFun_External_EEPROM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void ExternalEEPROM::write(uint32_t eepromLocation, const uint8_t *dataToWrite,
209209
uint16_t pageNumber1 = (eepromLocation + recorded) / settings.pageSize_bytes;
210210
uint16_t pageNumber2 = (eepromLocation + recorded + amtToWrite - 1) / settings.pageSize_bytes;
211211
if (pageNumber2 > pageNumber1)
212-
amtToWrite = (pageNumber2 * settings.pageSize_bytes) - (eepromLocation + recorded); //Limit the read amt to go right up to edge of page barrier
212+
amtToWrite = ((pageNumber1+1) * settings.pageSize_bytes) - (eepromLocation + recorded); //Limit the write amt to go right up to edge of page barrier
213213
}
214214

215215
uint8_t i2cAddress = settings.deviceAddress;

0 commit comments

Comments
 (0)