diff --git a/I2C_eeprom.cpp b/I2C_eeprom.cpp index d71d4d0..977cde4 100644 --- a/I2C_eeprom.cpp +++ b/I2C_eeprom.cpp @@ -1,7 +1,7 @@ // // FILE: I2C_eeprom.cpp // AUTHOR: Rob Tillaart -// VERSION: 1.4.2 +// VERSION: 1.4.3 // PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al. // URL: https://github.com/RobTillaart/I2C_EEPROM.git // @@ -37,6 +37,7 @@ // 1.4.1 2021-01-28 fixed addressing bug 24LC04/08/16 equivalents from ST e.g. m24c08w // add Wire1..WireN; // 1.4.2 2021-01-31 add updateBlock() +// 1.4.3 2021-05-05 adjust buffer size AVR / ESP +rename #include @@ -56,9 +57,11 @@ // TWI buffer needs max 2 bytes for eeprom address // 1 byte for eeprom register address is available in txbuffer -// NOTE this is typical on an UNO. -// TODO investigate -#define I2C_TWIBUFFERSIZE 30 +#if defined(ESP32) || defined(ESP8266) +#define I2C_BUFFERSIZE 128 +#else +#define I2C_BUFFERSIZE 30 // AVR, STM +#endif I2C_eeprom::I2C_eeprom(const uint8_t deviceAddress, TwoWire *wire) @@ -120,8 +123,8 @@ int I2C_eeprom::writeByte(const uint16_t memoryAddress, const uint8_t data) int I2C_eeprom::setBlock(const uint16_t memoryAddress, const uint8_t data, const uint16_t length) { - uint8_t buffer[I2C_TWIBUFFERSIZE]; - for (uint8_t i = 0; i < I2C_TWIBUFFERSIZE; i++) + uint8_t buffer[I2C_BUFFERSIZE]; + for (uint8_t i = 0; i < I2C_BUFFERSIZE; i++) { buffer[i] = data; } @@ -152,7 +155,7 @@ uint16_t I2C_eeprom::readBlock(const uint16_t memoryAddress, uint8_t* buffer, co uint16_t rv = 0; while (len > 0) { - uint8_t cnt = I2C_TWIBUFFERSIZE; + uint8_t cnt = I2C_BUFFERSIZE; if (cnt > len) cnt = len; rv += _ReadBlock(addr, buffer, cnt); addr += cnt; @@ -177,8 +180,8 @@ int I2C_eeprom::updateBlock(const uint16_t memoryAddress, const uint8_t* buffer, uint16_t rv = 0; while (len > 0) { - uint8_t buf[I2C_TWIBUFFERSIZE]; - uint8_t cnt = I2C_TWIBUFFERSIZE; + uint8_t buf[I2C_BUFFERSIZE]; + uint8_t cnt = I2C_BUFFERSIZE; if (cnt > len) cnt = len; rv += _ReadBlock(addr, buf, cnt); @@ -281,7 +284,7 @@ int I2C_eeprom::_pageBlock(const uint16_t memoryAddress, const uint8_t* buffer, { uint8_t bytesUntilPageBoundary = this->_pageSize - addr % this->_pageSize; - uint8_t cnt = I2C_TWIBUFFERSIZE; + uint8_t cnt = I2C_BUFFERSIZE; if (cnt > len) cnt = len; if (cnt > bytesUntilPageBoundary) cnt = bytesUntilPageBoundary; @@ -316,7 +319,7 @@ void I2C_eeprom::_beginTransmission(const uint16_t memoryAddress) } -// pre: length <= this->_pageSize && length <= I2C_TWIBUFFERSIZE; +// pre: length <= this->_pageSize && length <= I2C_BUFFERSIZE; // returns 0 = OK otherwise error int I2C_eeprom::_WriteBlock(const uint16_t memoryAddress, const uint8_t* buffer, const uint8_t length) { diff --git a/I2C_eeprom.h b/I2C_eeprom.h index 0c139c7..e0323d5 100644 --- a/I2C_eeprom.h +++ b/I2C_eeprom.h @@ -2,7 +2,7 @@ // // FILE: I2C_eeprom.h // AUTHOR: Rob Tillaart -// VERSION: 1.4.2 +// VERSION: 1.4.3 // PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al. // URL: https://github.com/RobTillaart/I2C_EEPROM.git // @@ -13,7 +13,7 @@ #include "Wire.h" -#define I2C_EEPROM_VERSION (F("1.4.2")) +#define I2C_EEPROM_VERSION (F("1.4.3")) #define I2C_DEVICESIZE_24LC512 65536 diff --git a/library.json b/library.json index 647c980..9f3d000 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/I2C_EEPROM.git" }, - "version":"1.4.2", + "version":"1.4.3", "frameworks": "arduino", "platforms": "*" } diff --git a/library.properties b/library.properties index 02e2b52..09e17f7 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=I2C_EEPROM -version=1.4.2 +version=1.4.3 author=Rob Tillaart maintainer=Rob Tillaart sentence=Library for I2C EEPROMS