From ab1d7d861740f286c510072bf6fa2a2988c81eab Mon Sep 17 00:00:00 2001 From: RobTillaart Date: Wed, 19 Apr 2017 12:45:38 +0200 Subject: [PATCH] + I2C_eeprom 1.2.4 + remove timeout - github issue #63 --- libraries/I2C_EEPROM/I2C_eeprom.cpp | 9 +++++---- libraries/I2C_EEPROM/I2C_eeprom.h | 9 +++------ libraries/I2C_EEPROM/library.properties | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/libraries/I2C_EEPROM/I2C_eeprom.cpp b/libraries/I2C_EEPROM/I2C_eeprom.cpp index 71654f2e..6f04bfbf 100644 --- a/libraries/I2C_EEPROM/I2C_eeprom.cpp +++ b/libraries/I2C_EEPROM/I2C_eeprom.cpp @@ -1,7 +1,7 @@ // // FILE: I2C_eeprom.cpp // AUTHOR: Rob Tillaart -// VERSION: 1.2.03 +// VERSION: 1.2.4 // PURPOSE: I2C_eeprom library for Arduino with EEPROM 24LC256 et al. // // HISTORY: @@ -24,6 +24,7 @@ // 1.2.01 - 2014-05-21 Refactoring // 1.2.02 - 2015-03-06 stricter interface // 1.2.03 - 2015-05-15 bugfix in _pageBlock & example (thanks ifreislich ) +// 1.2.4 - 2017-04-19 remove timeout - https://github.com/RobTillaart/Arduino/issues/63 // // Released to the public domain // @@ -241,10 +242,10 @@ uint8_t I2C_eeprom::_ReadBlock(const uint16_t memoryAddress, uint8_t* buffer, co Wire.requestFrom(_deviceAddress, length); uint8_t cnt = 0; - uint32_t before = millis(); - while ((cnt < length) && ((millis() - before) < I2C_EEPROM_TIMEOUT)) + uint8_t n = Wire.available(); + while ((cnt < n) && (cnt < length)) { - if (Wire.available()) buffer[cnt++] = WIRE_READ(); + buffer[cnt++] = WIRE_READ(); } return cnt; } diff --git a/libraries/I2C_EEPROM/I2C_eeprom.h b/libraries/I2C_EEPROM/I2C_eeprom.h index 556f705e..61cda82a 100644 --- a/libraries/I2C_EEPROM/I2C_eeprom.h +++ b/libraries/I2C_EEPROM/I2C_eeprom.h @@ -4,14 +4,14 @@ // FILE: I2C_eeprom.h // AUTHOR: Rob Tillaart // PURPOSE: I2C_eeprom library for Arduino with EEPROM 24LC256 et al. -// VERSION: 1.2.03 +// VERSION: 1.2.4 // HISTORY: See I2C_eeprom.cpp // URL: http://arduino.cc/playground/Main/LibraryForI2CEEPROM // // Released to the public domain // -#include +#include "Wire.h" #if defined(ARDUINO) && ARDUINO >= 100 #include "Arduino.h" @@ -21,7 +21,7 @@ #include "Wiring.h" #endif -#define I2C_EEPROM_VERSION "1.2.03" +#define I2C_EEPROM_VERSION "1.2.4" // The DEFAULT page size. This is overriden if you use the second constructor. // I2C_EEPROM_PAGESIZE must be multiple of 2 e.g. 16, 32 or 64 @@ -32,9 +32,6 @@ // 1 byte for eeprom register address is available in txbuffer #define I2C_TWIBUFFERSIZE 30 -// to break blocking read/write after n millis() -#define I2C_EEPROM_TIMEOUT 1000 - // comment next line to keep lib small (idea a read only lib?) #define I2C_EEPROM_EXTENDED diff --git a/libraries/I2C_EEPROM/library.properties b/libraries/I2C_EEPROM/library.properties index 88fb339f..63dc8e8a 100644 --- a/libraries/I2C_EEPROM/library.properties +++ b/libraries/I2C_EEPROM/library.properties @@ -1,5 +1,5 @@ name=I2C_EEPROM -version=1.2.03 +version=1.2.4 author=Rob Tillaart maintainer=Rob Tillaart sentence=Library for I2C EEPROMS.