Driver library for Microchip I2C EERAM (47x04 and 47x16) 4 kbit or 16 kbit EEPROM backed SRAM.
Diff: EERAM.cpp
- Revision:
- 5:9444f29f3429
- Parent:
- 4:fd84e2f0d1de
- Child:
- 6:b3f9b29b07ba
diff -r fd84e2f0d1de -r 9444f29f3429 EERAM.cpp --- a/EERAM.cpp Fri Apr 28 13:38:52 2017 +0000 +++ b/EERAM.cpp Tue May 09 07:01:45 2017 +0000 @@ -2,7 +2,7 @@ * @file EERAM.cpp * @brief mbed driver for Microchip I2C EERAM devices (47x04 and 47x16) * @author Mark Peter Vargha, vmp@varghamarkpeter.hu -* @version 1.3.0 +* @version 1.4.0 * * Copyright (c) 2017 * @@ -38,10 +38,8 @@ void EERAM::putAddressIntoBuffer(uint16_t address, char *data) { - MemoryAddress location; - location.address = address; - data[0] = location.bytes[1]; - data[1] = location.bytes[0]; + data[0] = (address >> (8 * 0)) & 0xff; + data[1] = (address >> (8 * 1)) & 0xff; } bool EERAM::checkAddressRange(uint16_t start, uint16_t length) @@ -253,9 +251,7 @@ bool EERAM::setMemoryPointer(uint16_t address, bool stop) { - MemoryAddress location; - location.address = address; - return setMemoryPointer(location.bytes[0], location.bytes[1], stop); + return setMemoryPointer((address >> (8 * 1)) & 0xff, (address >> (8 * 0)) & 0xff, stop); } bool EERAM::setMemoryPointer(uint8_t address_0, uint8_t address_1, bool stop)