Comments (10)
Hi thjean,
Can you make a PR ? if not I can do it later this week / weekend.
from i2c_eeprom.
Hi Rob,
Thank you for coming back to the issue report. Unfortunately, I'm a total noob regarding a PR in Git, so it's probably easier for you to take over :).
Here is my local fix, probably not the most elegant one.
- First, I added a var in
I2C_eeprom::I2C_eeprom(const uint8_t deviceAddress, const uint32_t deviceSize, TwoWire *wire)
_devAddressBlk = deviceAddress;
- In
void I2C_eeprom::_beginTransmission(const uint16_t memoryAddress)
, I changed the two lines
uint8_t addr = _deviceAddress | ((memoryAddress >> 8) & 0x07);
_wire->beginTransmission(addr);
in the else-path of if (this->_isAddressSizeTwoWords)
to
_devAddressBlk = _deviceAddress | ((memoryAddress >> 8) & 0x07);
_wire->beginTransmission(_devAddressBlk);
- and finally in
uint8_t I2C_eeprom::_ReadBlock(const uint16_t memoryAddress, uint8_t* buffer, const uint8_t length)
, I use the newly introduced var_devAddressBlk
instead of_deviceAddress
uint8_t readBytes = _wire->requestFrom(_devAddressBlk, length);
I tested my local fix with a 24LC16B (Microchip), the addressing scheme seems to be identical to the one used by STM chips. The write operation was already ok as it just uses the combined address for _beginTransmission()
.
I did not test the fix with a two words address size EEPROM, as I currently do not have one at hands. As _devAddressBlk
is intialized with deviceAddress
, _ReadBlock()
should remain functional.
from i2c_eeprom.
Created a develop branch in which I added a minimal fix in _readBlock() only.
Can you verify it works for you?
It might not be the final version yet, but lets first tackle the problem, then try to optimize it.
from i2c_eeprom.
Good catch by the way, appreciated!
from i2c_eeprom.
Thank you for creating the development branch.
The fix works perfectly for the Microchip 24LC16. It should work with double-byte addressing EEPROMs as well, however I could not verify that due to lack of chips.
from i2c_eeprom.
The change is made as local as possible so it should not affect the types that use 2 words.
from i2c_eeprom.
I will merge it later this week, so if you find other issues they might be included too
from i2c_eeprom.
Btw thanks for creating this library. I highly appreciate the update() functions, as they significantly help preserving device lifetime.
from i2c_eeprom.
There might be better ways to safe lifetime. Sometimes you just do not need to write every change back to EEPROM.
Imagine that your project could detect a power failure, and has enough energy (backup battery or capacitor) to store the latest values.
from i2c_eeprom.
Fixed in 1.5.0
from i2c_eeprom.
Related Issues (20)
- 24LC1025-I support HOT 2
- 512kbit eeprom problem HOT 20
- example of reading/writing a cpp struct HOT 1
- read errors HOT 12
- Possible bug in EEPROM format example HOT 3
- 24LC32A HOT 9
- Probleme 24C16 et I2C_EEPROM HOT 55
- AT24C128C can i use this one? HOT 9
- writeBlock across page boundaries intermittently failing HOT 8
- Investigate Write with Verify functionality HOT 1
- update documentation and examples HOT 1
- should the library control the Write Protect pin? HOT 5
- Questions regarding begin() for ESP and speed tests HOT 12
- Suspected crash when calling begin() HOT 8
- writeByte / readByte HOT 28
- String structure bug HOT 11
- Using the library in RP2040 HOT 25
- Compile error for Arduino rp2040 linked to _wire->setSCL(scl) and _wire->setSDA(sda) HOT 9
- Support for WP-Pins HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i2c_eeprom.