Giter Club home page Giter Club logo

Comments (10)

RobTillaart avatar RobTillaart commented on August 16, 2024

Hi thjean,

Can you make a PR ? if not I can do it later this week / weekend.

from i2c_eeprom.

thjean avatar thjean commented on August 16, 2024

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.

RobTillaart avatar RobTillaart commented on August 16, 2024

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.

RobTillaart avatar RobTillaart commented on August 16, 2024

Good catch by the way, appreciated!

from i2c_eeprom.

thjean avatar thjean commented on August 16, 2024

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.

RobTillaart avatar RobTillaart commented on August 16, 2024

The change is made as local as possible so it should not affect the types that use 2 words.

from i2c_eeprom.

RobTillaart avatar RobTillaart commented on August 16, 2024

I will merge it later this week, so if you find other issues they might be included too

from i2c_eeprom.

thjean avatar thjean commented on August 16, 2024

Btw thanks for creating this library. I highly appreciate the update() functions, as they significantly help preserving device lifetime.

from i2c_eeprom.

RobTillaart avatar RobTillaart commented on August 16, 2024

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.

RobTillaart avatar RobTillaart commented on August 16, 2024

Fixed in 1.5.0

from i2c_eeprom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.