adjust buffer size AVR / ESP +rename (#26)

This commit is contained in:
Rob Tillaart authored and GitHub committed 2021-05-05 14:09:36 +02:00
1 parent 65312aedeb
commit 0e3c2e26c7
4 files changed
+18 -15

No files matched your search

+14 -11
View File
@@ -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 <I2C_eeprom.h>
@@ -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)
{
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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": "*"
}
+1 -1
View File
@@ -1,5 +1,5 @@
name=I2C_EEPROM
version=1.4.2
version=1.4.3
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Library for I2C EEPROMS