diff --git a/FRAM.cpp b/FRAM.cpp index 9e2d169..74f50ad 100644 --- a/FRAM.cpp +++ b/FRAM.cpp @@ -604,7 +604,8 @@ uint32_t FRAM32::clear(uint8_t value) void FRAM32::_writeBlock(uint32_t memAddr, uint8_t * obj, uint8_t size) { uint8_t _addr = _address; - if (memAddr & 0x00010000) _addr += 0x01; + if (memAddr & 0xFFFE0000) return; // ignore invalid memory addresses + if ((memAddr & 0x00010000) == 0x00010000) _addr += 0x01; _wire->beginTransmission(_addr); _wire->write((uint8_t) (memAddr >> 8)); @@ -621,7 +622,8 @@ void FRAM32::_writeBlock(uint32_t memAddr, uint8_t * obj, uint8_t size) void FRAM32::_readBlock(uint32_t memAddr, uint8_t * obj, uint8_t size) { uint8_t _addr = _address; - if (memAddr & 0x00010000) _addr += 0x01; + if (memAddr & 0xFFFE0000) return; // ignore invalid memory addresses + if ((memAddr & 0x00010000) == 0x00010000) _addr += 0x01; _wire->beginTransmission(_addr); _wire->write((uint8_t) (memAddr >> 8));