mirror of
https://github.com/RobTillaart/I2C_EEPROM.git
synced 2026-07-27 20:06:07 +00:00
- fix #77, updateBlock() returns bytes actually written. - minor edits
This commit is contained in:
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [1.9.1] - 2024-10-26
|
||||
- fix #77, updateBlock() returns bytes actually written.
|
||||
- minor edits
|
||||
|
||||
## [1.9.0] - 2024-10-09
|
||||
- Fix #74, memory leak in setBlockVerify() - kudos to cmichailidis
|
||||
|
||||
|
||||
+6
-4
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: I2C_eeprom.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 1.9.0
|
||||
// VERSION: 1.9.1
|
||||
// PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al.
|
||||
// URL: https://github.com/RobTillaart/I2C_EEPROM
|
||||
|
||||
@@ -182,7 +182,7 @@ int I2C_eeprom::updateByte(const uint16_t memoryAddress, const uint8_t data)
|
||||
}
|
||||
|
||||
|
||||
// returns bytes written.
|
||||
// returns bytes actually written <= length
|
||||
uint16_t I2C_eeprom::updateBlock(const uint16_t memoryAddress, const uint8_t * buffer, const uint16_t length)
|
||||
{
|
||||
uint16_t address = memoryAddress;
|
||||
@@ -194,10 +194,11 @@ uint16_t I2C_eeprom::updateBlock(const uint16_t memoryAddress, const uint8_t * b
|
||||
uint8_t count = I2C_BUFFERSIZE;
|
||||
|
||||
if (count > len) count = len;
|
||||
bytes += _ReadBlock(address, buf, count);
|
||||
_ReadBlock(address, buf, count);
|
||||
if (memcmp(buffer, buf, count) != 0)
|
||||
{
|
||||
_pageBlock(address, buffer, count, true);
|
||||
bytes += count;
|
||||
}
|
||||
address += count;
|
||||
buffer += count;
|
||||
@@ -265,7 +266,8 @@ bool I2C_eeprom::updateByteVerify(const uint16_t memoryAddress, const uint8_t va
|
||||
// return false if write or verify failed.
|
||||
bool I2C_eeprom::updateBlockVerify(const uint16_t memoryAddress, const uint8_t * buffer, const uint16_t length)
|
||||
{
|
||||
if (updateBlock(memoryAddress, buffer, length) != length) return false;
|
||||
// zero bytes written means nothing needs to be verified
|
||||
if (0 == updateBlock(memoryAddress, buffer, length)) return true;
|
||||
return verifyBlock(memoryAddress, buffer, length);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: I2C_eeprom.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 1.9.0
|
||||
// VERSION: 1.9.1
|
||||
// PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al.
|
||||
// URL: https://github.com/RobTillaart/I2C_EEPROM
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define I2C_EEPROM_VERSION (F("1.9.0"))
|
||||
#define I2C_EEPROM_VERSION (F("1.9.1"))
|
||||
|
||||
#define I2C_DEVICESIZE_24LC512 65536
|
||||
#define I2C_DEVICESIZE_24LC256 32768
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
// updates a block in memory, writes only if there is a new value.
|
||||
// only to be used when you expect to write same buffer multiple times.
|
||||
// test your performance gains!
|
||||
// returns bytes written.
|
||||
// returns bytes actually written <= length
|
||||
uint16_t updateBlock(const uint16_t memoryAddress, const uint8_t * buffer, const uint16_t length);
|
||||
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ but only if changed.
|
||||
Returns 0 if value was same or write succeeded.
|
||||
- **uint16_t updateBlock(uint16_t memoryAddress, uint8_t \* buffer, uint16_t length)**
|
||||
write a buffer starting at the specified memory address, but only if changed.
|
||||
Returns bytes written.
|
||||
Returns bytes actually written <= length.
|
||||
|
||||
|
||||
### Read functions
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/I2C_EEPROM.git"
|
||||
},
|
||||
"version": "1.9.0",
|
||||
"version": "1.9.1",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
name=I2C_EEPROM
|
||||
version=1.9.0
|
||||
version=1.9.1
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Library for I2C EEPROMS
|
||||
|
||||
Reference in New Issue
Block a user