mirror of
https://github.com/RobTillaart/I2C_EEPROM.git
synced 2026-07-27 20:06:07 +00:00
- fix #83, update readme.md (thanks to TonyRiddiough) - add calculatePageSize(deviceSize) to replace getPageSize(deviceSize) prep. - update GitHub actions - minor update examples - minor edits
This commit is contained in:
@@ -6,8 +6,8 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
- uses: arduino/arduino-lint-action@v1
|
- uses: arduino/arduino-lint-action@v2
|
||||||
with:
|
with:
|
||||||
library-manager: update
|
library-manager: update
|
||||||
compliance: strict
|
compliance: strict
|
||||||
@@ -8,7 +8,7 @@ jobs:
|
|||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
- uses: ruby/setup-ruby@v1
|
- uses: ruby/setup-ruby@v1
|
||||||
with:
|
with:
|
||||||
ruby-version: 2.6
|
ruby-version: 2.6
|
||||||
|
|||||||
@@ -5,13 +5,15 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- '**.json'
|
- '**.json'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- '**.json'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
- name: json-syntax-check
|
- name: json-syntax-check
|
||||||
uses: limitusus/json-syntax-check@v2
|
uses: limitusus/json-syntax-check@v2
|
||||||
with:
|
with:
|
||||||
|
|||||||
+7
-1
@@ -6,10 +6,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|||||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
|
||||||
|
## [1.9.4] - 2025-08-27
|
||||||
|
- fix #83, update readme.md (thanks to TonyRiddiough)
|
||||||
|
- add calculatePageSize(deviceSize) to replace getPageSize(deviceSize) prep.
|
||||||
|
- update GitHub actions
|
||||||
|
- minor update examples
|
||||||
|
- minor edits
|
||||||
|
|
||||||
## [1.9.3] - 2025-08-01
|
## [1.9.3] - 2025-08-01
|
||||||
- update readme.md
|
- update readme.md
|
||||||
|
|
||||||
|
|
||||||
## [1.9.2] - 2024-11-25
|
## [1.9.2] - 2024-11-25
|
||||||
- fix #79, wrong default in constructor - kudos to ekinohito
|
- fix #79, wrong default in constructor - kudos to ekinohito
|
||||||
|
|
||||||
|
|||||||
+22
-15
@@ -45,7 +45,7 @@ I2C_eeprom::I2C_eeprom(const uint8_t deviceAddress, const uint32_t deviceSize, T
|
|||||||
{
|
{
|
||||||
_deviceAddress = deviceAddress;
|
_deviceAddress = deviceAddress;
|
||||||
_deviceSize = setDeviceSize(deviceSize);
|
_deviceSize = setDeviceSize(deviceSize);
|
||||||
_pageSize = getPageSize(_deviceSize);
|
_pageSize = calculatePageSize(_deviceSize);
|
||||||
_wire = wire;
|
_wire = wire;
|
||||||
|
|
||||||
// Chips 16 Kbit (2048 Bytes) or smaller only have one-word addresses.
|
// Chips 16 Kbit (2048 Bytes) or smaller only have one-word addresses.
|
||||||
@@ -296,7 +296,7 @@ bool I2C_eeprom::updateBlockVerify(const uint16_t memoryAddress, const uint8_t *
|
|||||||
// 24LC01 128 B YES
|
// 24LC01 128 B YES
|
||||||
uint32_t I2C_eeprom::determineSize(const bool debug)
|
uint32_t I2C_eeprom::determineSize(const bool debug)
|
||||||
{
|
{
|
||||||
// try to read a byte to see if connected
|
// try to read a byte to see if connected
|
||||||
if (! isConnected()) return 0;
|
if (! isConnected()) return 0;
|
||||||
|
|
||||||
uint8_t patAA = 0xAA;
|
uint8_t patAA = 0xAA;
|
||||||
@@ -308,7 +308,7 @@ uint32_t I2C_eeprom::determineSize(const bool debug)
|
|||||||
|
|
||||||
// store old values
|
// store old values
|
||||||
bool addressSize = _isAddressSizeTwoWords;
|
bool addressSize = _isAddressSizeTwoWords;
|
||||||
_isAddressSizeTwoWords = size > I2C_DEVICESIZE_24LC16; // 2048
|
_isAddressSizeTwoWords = size > I2C_DEVICESIZE_24LC16; // 2048
|
||||||
uint8_t buf = readByte(size);
|
uint8_t buf = readByte(size);
|
||||||
|
|
||||||
// test folding
|
// test folding
|
||||||
@@ -338,7 +338,7 @@ uint32_t I2C_eeprom::determineSize(const bool debug)
|
|||||||
// new 1.8.1 #61
|
// new 1.8.1 #61
|
||||||
// updated 1.8.2 #63
|
// updated 1.8.2 #63
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// 0 if device size cannot be determined or device is not online
|
// 0 if device size cannot be determined or device is not online
|
||||||
// 1 if device has default bytes in first dataFirstBytes bytes [0-BUFSIZE]
|
// 1 if device has default bytes in first dataFirstBytes bytes [0-BUFSIZE]
|
||||||
// Write some dataFirstBytes to the first bytes and retry or use the determineSize method
|
// Write some dataFirstBytes to the first bytes and retry or use the determineSize method
|
||||||
@@ -402,14 +402,14 @@ uint32_t I2C_eeprom::determineSizeNoWrite()
|
|||||||
_isAddressSizeTwoWords = (size >= I2C_DEVICESIZE_24LC16); // == 2048
|
_isAddressSizeTwoWords = (size >= I2C_DEVICESIZE_24LC16); // == 2048
|
||||||
|
|
||||||
// Try to read last byte of the block, should return length of 0 when fails for single byte devices
|
// Try to read last byte of the block, should return length of 0 when fails for single byte devices
|
||||||
// Will return the same dataFirstBytes as initially read on other devices
|
// Will return the same dataFirstBytes as initially read on other devices
|
||||||
// as the data pointer could not be moved to the requested position
|
// as the data pointer could not be moved to the requested position
|
||||||
delay(2);
|
delay(2);
|
||||||
uint16_t bSize = readBlock(size, dataMatch, BUFSIZE);
|
uint16_t bSize = readBlock(size, dataMatch, BUFSIZE);
|
||||||
|
|
||||||
if (bSize == BUFSIZE && memcmp(dataFirstBytes, dataMatch, BUFSIZE) != 0)
|
if (bSize == BUFSIZE && memcmp(dataFirstBytes, dataMatch, BUFSIZE) != 0)
|
||||||
{
|
{
|
||||||
// Read is performed just over size (size + BUFSIZE),
|
// Read is performed just over size (size + BUFSIZE),
|
||||||
// this will only work for devices with mem > size;
|
// this will only work for devices with mem > size;
|
||||||
// therefore return size * 2
|
// therefore return size * 2
|
||||||
_isAddressSizeTwoWords = addressSize;
|
_isAddressSizeTwoWords = addressSize;
|
||||||
@@ -433,7 +433,7 @@ uint8_t I2C_eeprom::getPageSize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint8_t I2C_eeprom::getPageSize(uint32_t deviceSize)
|
uint8_t I2C_eeprom::calculatePageSize(uint32_t deviceSize)
|
||||||
{
|
{
|
||||||
// determine page size from device size
|
// determine page size from device size
|
||||||
// based on Microchip 24LCXX data sheets.
|
// based on Microchip 24LCXX data sheets.
|
||||||
@@ -441,8 +441,15 @@ uint8_t I2C_eeprom::getPageSize(uint32_t deviceSize)
|
|||||||
if (deviceSize <= I2C_DEVICESIZE_24LC16) return 16;
|
if (deviceSize <= I2C_DEVICESIZE_24LC16) return 16;
|
||||||
if (deviceSize <= I2C_DEVICESIZE_24LC64) return 32;
|
if (deviceSize <= I2C_DEVICESIZE_24LC64) return 32;
|
||||||
if (deviceSize <= I2C_DEVICESIZE_24LC256) return 64;
|
if (deviceSize <= I2C_DEVICESIZE_24LC256) return 64;
|
||||||
// I2C_DEVICESIZE_24LC512
|
if (deviceSize <= I2C_DEVICESIZE_24LC512) return 128;
|
||||||
return 128;
|
// Error.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t I2C_eeprom::getPageSize(uint32_t deviceSize)
|
||||||
|
{
|
||||||
|
return calculatePageSize(deviceSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -469,7 +476,7 @@ uint32_t I2C_eeprom::setDeviceSize(uint32_t deviceSize)
|
|||||||
|
|
||||||
uint8_t I2C_eeprom::setPageSize(uint8_t pageSize)
|
uint8_t I2C_eeprom::setPageSize(uint8_t pageSize)
|
||||||
{
|
{
|
||||||
// force power of 2.
|
// force power of 2.
|
||||||
if (pageSize >= 128) {
|
if (pageSize >= 128) {
|
||||||
_pageSize = 128;
|
_pageSize = 128;
|
||||||
}
|
}
|
||||||
@@ -616,7 +623,7 @@ int I2C_eeprom::_WriteBlock(const uint16_t memoryAddress, const uint8_t * buffer
|
|||||||
|
|
||||||
_lastWrite = micros();
|
_lastWrite = micros();
|
||||||
|
|
||||||
yield(); // For OS scheduling
|
yield(); // For OS scheduling
|
||||||
|
|
||||||
// if (rv != 0)
|
// if (rv != 0)
|
||||||
// {
|
// {
|
||||||
@@ -627,7 +634,7 @@ int I2C_eeprom::_WriteBlock(const uint16_t memoryAddress, const uint8_t * buffer
|
|||||||
// SPRN("\t");
|
// SPRN("\t");
|
||||||
// SPRNL(rv);
|
// SPRNL(rv);
|
||||||
// }
|
// }
|
||||||
// return -(abs(rv)); // error
|
// return -(abs(rv)); // error
|
||||||
// }
|
// }
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@@ -728,9 +735,9 @@ void I2C_eeprom::_waitEEReady()
|
|||||||
{
|
{
|
||||||
if (isConnected()) return;
|
if (isConnected()) return;
|
||||||
// TODO remove pre 1.7.4 code
|
// TODO remove pre 1.7.4 code
|
||||||
// _wire->beginTransmission(_deviceAddress);
|
// _wire->beginTransmission(_deviceAddress);
|
||||||
// int x = _wire->endTransmission();
|
// int x = _wire->endTransmission();
|
||||||
// if (x == 0) return;
|
// if (x == 0) return;
|
||||||
yield(); // For OS scheduling
|
yield(); // For OS scheduling
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
+8
-6
@@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// FILE: I2C_eeprom.h
|
// FILE: I2C_eeprom.h
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// VERSION: 1.9.3
|
// VERSION: 1.9.4
|
||||||
// PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al.
|
// PURPOSE: Arduino Library for external I2C EEPROM 24LC256 et al.
|
||||||
// URL: https://github.com/RobTillaart/I2C_EEPROM
|
// URL: https://github.com/RobTillaart/I2C_EEPROM
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "Wire.h"
|
#include "Wire.h"
|
||||||
|
|
||||||
|
|
||||||
#define I2C_EEPROM_VERSION (F("1.9.3"))
|
#define I2C_EEPROM_VERSION (F("1.9.4"))
|
||||||
|
|
||||||
#define I2C_DEVICESIZE_24LC512 65536
|
#define I2C_DEVICESIZE_24LC512 65536
|
||||||
#define I2C_DEVICESIZE_24LC256 32768
|
#define I2C_DEVICESIZE_24LC256 32768
|
||||||
@@ -74,17 +74,17 @@ public:
|
|||||||
* It will try to guess page size and address word size based on the size of the device.
|
* It will try to guess page size and address word size based on the size of the device.
|
||||||
*
|
*
|
||||||
* @param deviceAddress Byte address of the device.
|
* @param deviceAddress Byte address of the device.
|
||||||
* @param deviceSize Max size in bytes of the device (divide your device size in Kbits by 8)
|
* @param deviceSize Max size in bytes of the device (divide your device size in Kbits by 8 to get Kbytes)
|
||||||
* @param wire Select alternative Wire interface
|
* @param wire Select alternative Wire interface
|
||||||
*/
|
*/
|
||||||
I2C_eeprom(const uint8_t deviceAddress, const uint32_t deviceSize, TwoWire *wire = &Wire);
|
I2C_eeprom(const uint8_t deviceAddress, const uint32_t deviceSize, TwoWire *wire = &Wire);
|
||||||
|
|
||||||
// use default I2C pins.
|
|
||||||
bool begin(int8_t writeProtectPin = -1);
|
bool begin(int8_t writeProtectPin = -1);
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
uint8_t getAddress();
|
uint8_t getAddress();
|
||||||
|
|
||||||
|
|
||||||
|
// user is responsible that address is in range of the EEPROM used.
|
||||||
// writes a byte to memoryAddress
|
// writes a byte to memoryAddress
|
||||||
// returns I2C status, 0 = OK
|
// returns I2C status, 0 = OK
|
||||||
int writeByte(const uint16_t memoryAddress, const uint8_t value);
|
int writeByte(const uint16_t memoryAddress, const uint8_t value);
|
||||||
@@ -123,11 +123,13 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// Meta data functions
|
// Meta data functions
|
||||||
uint32_t determineSize(const bool debug = false);
|
|
||||||
uint32_t determineSizeNoWrite();
|
|
||||||
uint32_t getDeviceSize();
|
uint32_t getDeviceSize();
|
||||||
uint8_t getPageSize();
|
uint8_t getPageSize();
|
||||||
|
uint8_t calculatePageSize(uint32_t deviceSize);
|
||||||
|
[[deprecated("Use calculatePageSize(deviceSize) instead.")]]
|
||||||
uint8_t getPageSize(uint32_t deviceSize);
|
uint8_t getPageSize(uint32_t deviceSize);
|
||||||
|
uint32_t determineSizeNoWrite();
|
||||||
|
uint32_t determineSize(const bool debug = false);
|
||||||
uint32_t getLastWrite();
|
uint32_t getLastWrite();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
// VERSION: 1.0.0
|
// VERSION: 1.0.0
|
||||||
// PURPOSE: Supplemental utility class for I2C_EEPROM library
|
// PURPOSE: Supplemental utility class for I2C_EEPROM library
|
||||||
//
|
//
|
||||||
|
// URL: https://github.com/RobTillaart/I2C_EEPROM
|
||||||
|
|
||||||
|
|
||||||
#include <I2C_eeprom.h>
|
#include <I2C_eeprom.h>
|
||||||
|
|||||||
@@ -17,34 +17,42 @@ Arduino Library for external I2C EEPROM - 24LC512, 24LC256, 24LC64/32/16/08/04/0
|
|||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
This library is to access the external I2C EEPROM up to 64KB (= 512 Kbit) in size.
|
This library is used to access an external I2C EEPROM up to 64KB (= 512 Kbit) in size.
|
||||||
MicroChip 24LC512, 24LC256, 24LC64, 24LC32, 24LC16, 24LC08, 24LC04, 24LC02, 24LC01 and equivalents.
|
The MicroChip 24LC512, 24LC256, 24LC64, 24LC32, 24LC16, 24LC08, 24LC04, 24LC02, 24LC01
|
||||||
|
and equivalents are tested and working.
|
||||||
|
|
||||||
Also confirmed working M24512-W, M24512-R, M24512-DF (See #68).
|
Also confirmed working M24512-W, M24512-R, M24512-DF (See #68).
|
||||||
Not supported is the identification page functions.
|
Not supported are the identification page functions.
|
||||||
|
|
||||||
The **I2C_eeprom_cyclic_store** interface is documented [here](README_cyclic_store.md)
|
The **I2C_eeprom_cyclic_store** interface is documented [here](README_cyclic_store.md)
|
||||||
|
|
||||||
|
**Warning**
|
||||||
|
|
||||||
|
The user is responsible to verify the used memoryAddress (range) exists in the used EEPROM. (read / write / verify functions).
|
||||||
|
The library does not check this. If the address is larger than the EEPROM size,
|
||||||
|
the address used will probably be memoryAddress % deviceSize.
|
||||||
|
|
||||||
|
|
||||||
### RP2040
|
### RP2040
|
||||||
|
|
||||||
There are at least two boards modules for the RP2040 that use a different Wire libraries.
|
There are at least two boards modules for the RP2040 that use different Wire libraries.
|
||||||
One from "Earle F. Philhower" and an "MBED" one. See issues #53 and #55 for details.
|
One from "Earle F. Philhower" and an "MBED" one. See issues #53 and #55 for details.
|
||||||
|
|
||||||
In 1.7.3 defines are checked to select between these two and as far as tested this seems
|
In 1.7.3 defines are checked to select between these two and as far as tested this seems
|
||||||
to solve the issue #53 while being backwards compatible.
|
to solve the issue #53 while being backwards compatible.
|
||||||
If a better solution is found, it will be implemented.
|
If a better solution is found, it will be implemented.
|
||||||
|
|
||||||
|
|
||||||
### Breaking change
|
### Breaking change 1.9.0
|
||||||
|
|
||||||
Version 1.9.0 fixed a memory leak in **verifyBlock()**.
|
Version 1.9.0 fixed a memory leak in **verifyBlock()**.
|
||||||
|
|
||||||
|
### Breaking change 1.8.0
|
||||||
|
|
||||||
Version 1.8.0 introduced a breaking change.
|
Version 1.8.0 introduced a breaking change.
|
||||||
You cannot set the pins in **begin()** any more.
|
You cannot set the I2C pins in **begin()** any more.
|
||||||
This reduces the dependency of processor dependent Wire implementations.
|
This reduces the dependency of processor dependent Wire (I2C) implementations.
|
||||||
The user has to call **Wire.begin()** and can optionally set the Wire pins
|
The user has to call **Wire.begin()** and can optionally set the Wire pins
|
||||||
before calling **I2C_eeprom.begin()**.
|
(if the board supports this), before calling **I2C_eeprom.begin()**.
|
||||||
|
|
||||||
|
|
||||||
### Related
|
### Related
|
||||||
@@ -56,6 +64,8 @@ before calling **I2C_eeprom.begin()**.
|
|||||||
|
|
||||||
## Schematic
|
## Schematic
|
||||||
|
|
||||||
|
Verify the datasheet for your specific EEPROM.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
+---U---+
|
+---U---+
|
||||||
A0 | 1 8 | VCC = 1.7V to 5.5V
|
A0 | 1 8 | VCC = 1.7V to 5.5V
|
||||||
@@ -70,7 +80,7 @@ before calling **I2C_eeprom.begin()**.
|
|||||||
|
|
||||||
I2C address = 0x50 .. 0x57 depending on three address lines (A0, A1, A2).
|
I2C address = 0x50 .. 0x57 depending on three address lines (A0, A1, A2).
|
||||||
|
|
||||||
Read the datasheet, section device addressing.
|
Read the datasheet of your specific EEPROM, section device addressing.
|
||||||
|
|
||||||
|
|
||||||
### I2C multiplexing
|
### I2C multiplexing
|
||||||
@@ -91,7 +101,6 @@ too if they are behind the multiplexer.
|
|||||||
- https://github.com/RobTillaart/TCA9548
|
- https://github.com/RobTillaart/TCA9548
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Interface
|
## Interface
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
@@ -101,22 +110,46 @@ too if they are behind the multiplexer.
|
|||||||
The interface is kept quite identical to the I2C_24LC1025 library.
|
The interface is kept quite identical to the I2C_24LC1025 library.
|
||||||
https://github.com/RobTillaart/I2C_24LC1025
|
https://github.com/RobTillaart/I2C_24LC1025
|
||||||
|
|
||||||
Most important difference is 32 bit memory addresses.
|
Most important difference is that the latter uses 32 bit memory addresses.
|
||||||
|
|
||||||
|
|
||||||
### Constructor
|
### Constructor
|
||||||
|
|
||||||
- **I2C_eeprom(uint8_t deviceAddress, TwoWire \*wire = &Wire)** constructor,
|
- **I2C_eeprom(uint8_t deviceAddress, TwoWire \*wire = &Wire)** constructor, to set the
|
||||||
optional Wire interface.
|
device address and optional Wire interface. The deviceSize == I2C_DEVICESIZE_24LC256 (32KB)
|
||||||
|
is used as it is the most often used I2C_EEPROM size.
|
||||||
|
Be aware that if you use other sized EEPROMs you have to use the next constructor,
|
||||||
|
and name the deviceSize explicitly, otherwise errors might occur.
|
||||||
- **I2C_eeprom(uint8_t deviceAddress, uint32_t deviceSize, TwoWire \*wire = &Wire)**
|
- **I2C_eeprom(uint8_t deviceAddress, uint32_t deviceSize, TwoWire \*wire = &Wire)**
|
||||||
constructor, with optional Wire interface.
|
constructor, idem as above, furthermore the deviceSize can be any of the defines in the
|
||||||
- **bool begin(uint8_t writeProtectPin = -1)** initializes the I2C bus with the default pins.
|
table below or its number equivalent.
|
||||||
Furthermore it checks if the deviceAddress is available on the I2C bus.
|
The Wire interface is optional, default Wire.
|
||||||
Returns true if deviceAddress is found on the bus, false otherwise.
|
- **bool begin(uint8_t writeProtectPin = -1)** Optionally one can set the **WP**
|
||||||
Optionally one can set the **WP** writeProtect pin. (see section below).
|
writeProtect pin. (see section below).
|
||||||
If the **WP** pin is defined, the default behaviour will be to **not** allow writing.
|
If the **WP** pin is defined, the default behaviour will be to **not** allow writing.
|
||||||
- **bool isConnected()** test to see if deviceAddress is found on the bus.
|
Furthermore it checks if the deviceAddress given in the constructor is available
|
||||||
|
on the defined I2C bus.
|
||||||
|
Returns true if deviceAddress is found on the I2C bus, false otherwise.
|
||||||
|
- **bool isConnected()** returns true if the address given in the constructor is
|
||||||
|
available on the defined I2C bus.
|
||||||
- **uint8_t getAddress()** returns deviceAddress set in the constructor.
|
- **uint8_t getAddress()** returns deviceAddress set in the constructor.
|
||||||
|
Convenience.
|
||||||
|
|
||||||
|
|
||||||
|
Defined device sizes for constructor, more details see below.
|
||||||
|
|
||||||
|
| Define | bytes | Notes |
|
||||||
|
|:-------------------------|--------:|:--------|
|
||||||
|
| I2C_DEVICESIZE_24LC512 | 65536 |
|
||||||
|
| I2C_DEVICESIZE_24LC256 | 32768 | most used
|
||||||
|
| I2C_DEVICESIZE_24LC128 | 16384 |
|
||||||
|
| I2C_DEVICESIZE_24LC64 | 8192 |
|
||||||
|
| I2C_DEVICESIZE_24LC32 | 4096 |
|
||||||
|
| I2C_DEVICESIZE_24LC16 | 2048 |
|
||||||
|
| I2C_DEVICESIZE_24LC08 | 1024 |
|
||||||
|
| I2C_DEVICESIZE_24LC04 | 512 |
|
||||||
|
| I2C_DEVICESIZE_24LC02 | 256 |
|
||||||
|
| I2C_DEVICESIZE_24LC01 | 128 |
|
||||||
|
|
||||||
|
|
||||||
### Write functions
|
### Write functions
|
||||||
@@ -134,8 +167,11 @@ Returns I2C status, 0 = OK.
|
|||||||
|
|
||||||
### Update functions
|
### Update functions
|
||||||
|
|
||||||
|
Using update instead of write functions does not write if the value is the same.
|
||||||
|
The price is an extra read() call, but if there is no change the gain is performance.
|
||||||
|
|
||||||
- **int updateByte(uint16_t memoryAddress, uint8_t value)** write a single byte,
|
- **int updateByte(uint16_t memoryAddress, uint8_t value)** write a single byte,
|
||||||
but only if changed.
|
but only if the value has changed.
|
||||||
Returns 0 if value was same or write succeeded.
|
Returns 0 if value was same or write succeeded.
|
||||||
- **uint16_t updateBlock(uint16_t memoryAddress, uint8_t \* buffer, uint16_t length)**
|
- **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.
|
write a buffer starting at the specified memory address, but only if changed.
|
||||||
@@ -148,6 +184,7 @@ Returns bytes actually written <= length.
|
|||||||
- **uint16_t readBlock(uint16_t memoryAddress, uint8_t \* buffer, uint16_t length)**
|
- **uint16_t readBlock(uint16_t memoryAddress, uint8_t \* buffer, uint16_t length)**
|
||||||
read length bytes into buffer starting at specified memory address.
|
read length bytes into buffer starting at specified memory address.
|
||||||
Returns the number of bytes read, which should be length.
|
Returns the number of bytes read, which should be length.
|
||||||
|
The user is responsible that the used buffer can hold length bytes.
|
||||||
|
|
||||||
|
|
||||||
### Verify functions
|
### Verify functions
|
||||||
@@ -155,6 +192,7 @@ Returns the number of bytes read, which should be length.
|
|||||||
Since 1.6.0. - experimental, needs extensive testing.
|
Since 1.6.0. - experimental, needs extensive testing.
|
||||||
|
|
||||||
Same as write and update functions above. Returns true if successful, false indicates an error.
|
Same as write and update functions above. Returns true if successful, false indicates an error.
|
||||||
|
The user is responsible that the used buffer can hold length bytes.
|
||||||
|
|
||||||
- **bool writeByteVerify(uint16_t memoryAddress, uint8_t value)**
|
- **bool writeByteVerify(uint16_t memoryAddress, uint8_t value)**
|
||||||
- **bool writeBlockVerify(uint16_t memoryAddress, uint8_t \* buffer, uint16_t length)**
|
- **bool writeBlockVerify(uint16_t memoryAddress, uint8_t \* buffer, uint16_t length)**
|
||||||
@@ -162,23 +200,24 @@ Same as write and update functions above. Returns true if successful, false indi
|
|||||||
- **bool updateByteVerify(uint16_t memoryAddress, uint8_t value)**
|
- **bool updateByteVerify(uint16_t memoryAddress, uint8_t value)**
|
||||||
- **bool updateBlockVerify(uint16_t memoryAddress, uint8_t \* buffer, uint16_t length)**
|
- **bool updateBlockVerify(uint16_t memoryAddress, uint8_t \* buffer, uint16_t length)**
|
||||||
- **bool verifyBlock(uint16_t memoryAddress, uint8_t \* buffer, uint16_t length)**
|
- **bool verifyBlock(uint16_t memoryAddress, uint8_t \* buffer, uint16_t length)**
|
||||||
Returns true is buffer equals memoryAddres for length bytes.
|
Returns true is buffer equals memoryAddress for length bytes.
|
||||||
|
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
|
|
||||||
- **uint32_t getDeviceSize()** idem
|
- **uint32_t getDeviceSize()** returns the current set deviceSize.
|
||||||
- **uint8_t getPageSize()** idem
|
- **uint8_t getPageSize()** returns the current set pageSize.
|
||||||
- **uint8_t getPageSize(uint32_t deviceSize)** idem
|
- **uint8_t calculatePageSize(uint32_t deviceSize)** calculates the pageSize of a device
|
||||||
- **uint32_t getLastWrite()** idem
|
with deviceSize. Note it does not set the pageSize!
|
||||||
|
- **uint8_t getPageSize(uint32_t deviceSize)** deprecated, wrapper around calculatePageSize().
|
||||||
|
- **uint32_t getLastWrite()** returns timestamp in millis since start of program.
|
||||||
- **uint32_t determineSizeNoWrite()** function that determines the size of the EEPROM
|
- **uint32_t determineSizeNoWrite()** function that determines the size of the EEPROM
|
||||||
by detecting when a selected memory address is not readable. (new in 1.8.1).
|
by detecting when a selected memory address is not readable. (new in 1.8.1).
|
||||||
- **uint32_t determineSize(bool debug = false)**
|
- **uint32_t determineSize(bool debug = false)**
|
||||||
function that determines the size of the EEPROM by detecting when a memory address
|
function that determines the size of the EEPROM by detecting when a memory address
|
||||||
is folded upon memory address 0.
|
is folded upon memory address 0.
|
||||||
It is based upon the observation that memory wraps around.
|
It is based upon the observation that memory wraps around.
|
||||||
The debug flag prints some output to Serial.
|
The debug flag prints some output to Serial.
|
||||||
|
|
||||||
**Warning**: this function has changed (again) in 1.4.0
|
**Warning**: this function has changed (again) in 1.4.0
|
||||||
|
|
||||||
Test results **determineSize()**
|
Test results **determineSize()**
|
||||||
@@ -216,7 +255,7 @@ The function **updateBlock()** reads the block of data and compares it with the
|
|||||||
|
|
||||||
As the function reads/writes the data in blocks with a maximum length of **I2C_TWIBUFFERSIZE**
|
As the function reads/writes the data in blocks with a maximum length of **I2C_TWIBUFFERSIZE**
|
||||||
(== 30 AVR limitation; 128 for ESP32)
|
(== 30 AVR limitation; 128 for ESP32)
|
||||||
It does this comparison in chunks if the length exceeds this number.
|
It does this comparison in chunks if the length exceeds the length of the I2C buffer.
|
||||||
The result is that an **updateBlock()** call can result e.g. in 4 reads and only 2 writes under the hood.
|
The result is that an **updateBlock()** call can result e.g. in 4 reads and only 2 writes under the hood.
|
||||||
|
|
||||||
If data is changed often between writes, **updateBlock()** is slower than **writeBlock()**.
|
If data is changed often between writes, **updateBlock()** is slower than **writeBlock()**.
|
||||||
@@ -280,11 +319,12 @@ The library does not offer multiple EEPROMS as one continuous storage device.
|
|||||||
|
|
||||||
#### Should
|
#### Should
|
||||||
|
|
||||||
- investigate multi-EEPROM storage
|
- investigate multi-EEPROM storage ==> wrapper class!
|
||||||
- wrapper class?
|
- improve error handling
|
||||||
- improve error handling,
|
- address range check in begin
|
||||||
- write functions should return bytes written or so.
|
- write functions should return bytes written (like Print() does)
|
||||||
- make deviceSize explicit in examples?
|
now they return I2C status... => error / status.
|
||||||
|
- remove uint8_t getPageSize(uint32_t deviceSize) in 0.2.0. now deprecated.
|
||||||
|
|
||||||
#### Could
|
#### Could
|
||||||
|
|
||||||
@@ -292,7 +332,8 @@ The library does not offer multiple EEPROMS as one continuous storage device.
|
|||||||
=> find first and last changed position could possibly result in less writes.
|
=> find first and last changed position could possibly result in less writes.
|
||||||
- can **setBlock()** use strategies from **updateBlock()**
|
- can **setBlock()** use strategies from **updateBlock()**
|
||||||
- **pageBlock()**: incrBuffer is an implementation name, not a functional name.
|
- **pageBlock()**: incrBuffer is an implementation name, not a functional name.
|
||||||
|
- replace defines with const uint8_t / const uint16_t to force type checking?
|
||||||
|
- sync order .h file and readme.md.
|
||||||
|
|
||||||
#### Wont
|
#### Wont
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,12 @@ I2C_eeprom_cyclic_store<SampleData> cs;
|
|||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
while(!Serial);
|
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
||||||
|
Serial.println();
|
||||||
|
Serial.println(__FILE__);
|
||||||
|
Serial.print("I2C_EEPROM_VERSION: ");
|
||||||
|
Serial.println(I2C_EEPROM_VERSION);
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
@@ -45,9 +50,9 @@ void setup()
|
|||||||
sprintf(data.message, "Initialized to %x", data.counter);
|
sprintf(data.message, "Initialized to %x", data.counter);
|
||||||
cs.write(data);
|
cs.write(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
Serial.println(data.message);
|
Serial.println(data.message);
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ void setup()
|
|||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
||||||
|
Serial.println();
|
||||||
Serial.println(__FILE__);
|
Serial.println(__FILE__);
|
||||||
Serial.print("I2C_EEPROM_VERSION: ");
|
Serial.print("I2C_EEPROM_VERSION: ");
|
||||||
Serial.println(I2C_EEPROM_VERSION);
|
Serial.println(I2C_EEPROM_VERSION);
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
@@ -58,7 +60,7 @@ void setup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Serial.print("PAGE: ");
|
Serial.print("PAGE: ");
|
||||||
uint8_t pageSize = ee.getPageSize(size);
|
uint8_t pageSize = ee.calculatePageSize(size);
|
||||||
Serial.print(pageSize);
|
Serial.print(pageSize);
|
||||||
Serial.println(" bytes.");
|
Serial.println(" bytes.");
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ void setup()
|
|||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
||||||
|
Serial.println();
|
||||||
Serial.println(__FILE__);
|
Serial.println(__FILE__);
|
||||||
Serial.print("I2C_EEPROM_VERSION: ");
|
Serial.print("I2C_EEPROM_VERSION: ");
|
||||||
Serial.println(I2C_EEPROM_VERSION);
|
Serial.println(I2C_EEPROM_VERSION);
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
@@ -66,7 +68,7 @@ void setup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Serial.print("PAGE: ");
|
Serial.print("PAGE: ");
|
||||||
uint8_t pageSize = ee.getPageSize(size);
|
uint8_t pageSize = ee.calculatePageSize(size);
|
||||||
Serial.print(pageSize);
|
Serial.print(pageSize);
|
||||||
Serial.println(" bytes.");
|
Serial.println(" bytes.");
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ void setup()
|
|||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
||||||
|
Serial.println();
|
||||||
Serial.println(__FILE__);
|
Serial.println(__FILE__);
|
||||||
Serial.print("I2C_EEPROM_VERSION: ");
|
Serial.print("I2C_EEPROM_VERSION: ");
|
||||||
Serial.println(I2C_EEPROM_VERSION);
|
Serial.println(I2C_EEPROM_VERSION);
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
//
|
//
|
||||||
// uses a 24LC256 (32KB) EEPROM
|
// uses a 24LC256 (32KB) EEPROM
|
||||||
// as this test writes a lot it might wear out EEPROMs eventually.
|
// as this test writes a lot it might wear out EEPROMs eventually.
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
#include "Wire.h"
|
#include "Wire.h"
|
||||||
@@ -29,9 +28,11 @@ void setup()
|
|||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
||||||
|
Serial.println();
|
||||||
Serial.println(__FILE__);
|
Serial.println(__FILE__);
|
||||||
Serial.print("I2C_EEPROM_VERSION: ");
|
Serial.print("I2C_EEPROM_VERSION: ");
|
||||||
Serial.println(I2C_EEPROM_VERSION);
|
Serial.println(I2C_EEPROM_VERSION);
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ void setup()
|
|||||||
if (! ee.isConnected())
|
if (! ee.isConnected())
|
||||||
{
|
{
|
||||||
Serial.println("ERROR: Can't find eeprom (stopped)...");
|
Serial.println("ERROR: Can't find eeprom (stopped)...");
|
||||||
// while (1);
|
// while (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.print("size: \t");
|
Serial.print("size: \t");
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
// #define SERIAL_OUT SerialUSB
|
// #define SERIAL_OUT SerialUSB
|
||||||
|
|
||||||
|
|
||||||
I2C_eeprom ee(0x50);
|
I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC256);
|
||||||
// I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC256);
|
|
||||||
|
|
||||||
uint32_t start, diff, totals = 0;
|
uint32_t start, diff, totals = 0;
|
||||||
|
|
||||||
@@ -28,9 +27,11 @@ void setup()
|
|||||||
{
|
{
|
||||||
SERIAL_OUT.begin(115200);
|
SERIAL_OUT.begin(115200);
|
||||||
while (!SERIAL_OUT); // wait for SERIAL_OUT port to connect. Needed for Leonardo only
|
while (!SERIAL_OUT); // wait for SERIAL_OUT port to connect. Needed for Leonardo only
|
||||||
|
SERIAL_OUT.println();
|
||||||
SERIAL_OUT.println(__FILE__);
|
SERIAL_OUT.println(__FILE__);
|
||||||
SERIAL_OUT.print("I2C_EEPROM_VERSION: ");
|
SERIAL_OUT.print("I2C_EEPROM_VERSION: ");
|
||||||
SERIAL_OUT.println(I2C_EEPROM_VERSION);
|
SERIAL_OUT.println(I2C_EEPROM_VERSION);
|
||||||
|
SERIAL_OUT.println();
|
||||||
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ void setup()
|
|||||||
ee.setBlock(0, 0, 128);
|
ee.setBlock(0, 0, 128);
|
||||||
dumpEEPROM(0, 128);
|
dumpEEPROM(0, 128);
|
||||||
Serial.println("---");
|
Serial.println("---");
|
||||||
// char data[] = "11111111111111111111";
|
// char data[] = "11111111111111111111";
|
||||||
char data[] = "33333333333333333333";
|
char data[] = "33333333333333333333";
|
||||||
ee.writeBlock(60, (uint8_t*) data, 10);
|
ee.writeBlock(60, (uint8_t*) data, 10);
|
||||||
dumpEEPROM(0, 128);
|
dumpEEPROM(0, 128);
|
||||||
@@ -155,7 +156,7 @@ void setup()
|
|||||||
SERIAL_OUT.println(totals);
|
SERIAL_OUT.println(totals);
|
||||||
totals = 0;
|
totals = 0;
|
||||||
|
|
||||||
// same tests but now with a 5 millisec delay in between.
|
// same tests but now with a 5 millisec delay in between.
|
||||||
delay(5);
|
delay(5);
|
||||||
|
|
||||||
SERIAL_OUT.print("\nTEST: timing writeByte()\t");
|
SERIAL_OUT.print("\nTEST: timing writeByte()\t");
|
||||||
@@ -200,7 +201,7 @@ void setup()
|
|||||||
SERIAL_OUT.println(totals);
|
SERIAL_OUT.println(totals);
|
||||||
totals = 0;
|
totals = 0;
|
||||||
|
|
||||||
// does it go well?
|
// did it go well?
|
||||||
SERIAL_OUT.println(xx);
|
SERIAL_OUT.println(xx);
|
||||||
|
|
||||||
SERIAL_OUT.println("\tDone...");
|
SERIAL_OUT.println("\tDone...");
|
||||||
@@ -224,7 +225,7 @@ void dumpEEPROM(uint16_t memoryAddress, uint16_t length)
|
|||||||
}
|
}
|
||||||
SERIAL_OUT.println();
|
SERIAL_OUT.println();
|
||||||
|
|
||||||
// block to defined length
|
// block to defined length
|
||||||
memoryAddress = memoryAddress / BLOCK_TO_LENGTH * BLOCK_TO_LENGTH;
|
memoryAddress = memoryAddress / BLOCK_TO_LENGTH * BLOCK_TO_LENGTH;
|
||||||
length = (length + BLOCK_TO_LENGTH - 1) / BLOCK_TO_LENGTH * BLOCK_TO_LENGTH;
|
length = (length + BLOCK_TO_LENGTH - 1) / BLOCK_TO_LENGTH * BLOCK_TO_LENGTH;
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ void setup()
|
|||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
||||||
|
Serial.println();
|
||||||
Serial.println(__FILE__);
|
Serial.println(__FILE__);
|
||||||
Serial.print("I2C_EEPROM_VERSION: ");
|
Serial.print("I2C_EEPROM_VERSION: ");
|
||||||
Serial.println(I2C_EEPROM_VERSION);
|
Serial.println(I2C_EEPROM_VERSION);
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
@@ -140,7 +142,7 @@ void test()
|
|||||||
Serial.println(totals);
|
Serial.println(totals);
|
||||||
totals = 0;
|
totals = 0;
|
||||||
|
|
||||||
// does it go well?
|
// did it go well?
|
||||||
Serial.println(xx);
|
Serial.println(xx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +159,7 @@ void dumpEEPROM(uint16_t memoryAddress, uint16_t length)
|
|||||||
}
|
}
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
|
||||||
// block to defined length
|
// block to defined length
|
||||||
memoryAddress = memoryAddress / BLOCK_TO_LENGTH * BLOCK_TO_LENGTH;
|
memoryAddress = memoryAddress / BLOCK_TO_LENGTH * BLOCK_TO_LENGTH;
|
||||||
length = (length + BLOCK_TO_LENGTH - 1) / BLOCK_TO_LENGTH * BLOCK_TO_LENGTH;
|
length = (length + BLOCK_TO_LENGTH - 1) / BLOCK_TO_LENGTH * BLOCK_TO_LENGTH;
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ void setup()
|
|||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
||||||
|
Serial.println();
|
||||||
Serial.println(__FILE__);
|
Serial.println(__FILE__);
|
||||||
Serial.print("I2C_EEPROM_VERSION: ");
|
Serial.print("I2C_EEPROM_VERSION: ");
|
||||||
Serial.println(I2C_EEPROM_VERSION);
|
Serial.println(I2C_EEPROM_VERSION);
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,11 @@ void setup()
|
|||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
||||||
|
Serial.println();
|
||||||
Serial.println(__FILE__);
|
Serial.println(__FILE__);
|
||||||
Serial.print("I2C_EEPROM_VERSION: ");
|
Serial.print("I2C_EEPROM_VERSION: ");
|
||||||
Serial.println(I2C_EEPROM_VERSION);
|
Serial.println(I2C_EEPROM_VERSION);
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,11 @@ void setup()
|
|||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
||||||
|
Serial.println();
|
||||||
Serial.println(__FILE__);
|
Serial.println(__FILE__);
|
||||||
Serial.print("I2C_EEPROM_VERSION: ");
|
Serial.print("I2C_EEPROM_VERSION: ");
|
||||||
Serial.println(I2C_EEPROM_VERSION);
|
Serial.println(I2C_EEPROM_VERSION);
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ void setup()
|
|||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only
|
||||||
|
Serial.println();
|
||||||
Serial.println(__FILE__);
|
Serial.println(__FILE__);
|
||||||
Serial.print("I2C_EEPROM_VERSION: ");
|
Serial.print("I2C_EEPROM_VERSION: ");
|
||||||
Serial.println(I2C_EEPROM_VERSION);
|
Serial.println(I2C_EEPROM_VERSION);
|
||||||
|
Serial.println();
|
||||||
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
@@ -96,5 +98,4 @@ void disrupt(uint8_t location)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -- END OF FILE --
|
// -- END OF FILE --
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
//
|
//
|
||||||
// FILE: I2C_small_eeprom_test.ino
|
// FILE: I2C_small_eeprom_test.ino
|
||||||
// AUTHOR: Tyler Freeman
|
// AUTHOR: Tyler Freeman
|
||||||
// VERSION: 0.1.1
|
// VERSION: 0.1.2
|
||||||
// PURPOSE: show/test I2C_EEPROM library with small EEPROMS
|
// PURPOSE: show/test I2C_EEPROM library with small EEPROMS
|
||||||
// URL: https://github.com/RobTillaart/I2C_EEPROM
|
// URL: https://github.com/RobTillaart/I2C_EEPROM
|
||||||
// HISTORY
|
// HISTORY
|
||||||
// 0.1.0 2014-05-xx initial version
|
// 0.1.0 2014-05-xx initial version
|
||||||
// 0.1.1 2020-07-14 fix #1 compile for ESP; fix author
|
// 0.1.1 2020-07-14 fix #1 compile for ESP; fix author
|
||||||
|
// 0.1.2 2025-08-27 add print filename and version number of library
|
||||||
|
|
||||||
|
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
@@ -101,7 +102,12 @@ void readAndWritePage(unsigned int pageAddress, int bufferLen) {
|
|||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
SERIAL_DEBUG.begin(57600);
|
SERIAL_DEBUG.begin(57600);
|
||||||
while (!SERIAL_DEBUG); // wait for SERIAL_DEBUG port to connect. Needed for Leonardo only
|
while (!SERIAL_DEBUG); // wait for SERIAL_DEBUG port to connect. Needed for Leonardo only
|
||||||
|
SERIAL_DEBUG.println();
|
||||||
|
SERIAL_DEBUG.println(__FILE__);
|
||||||
|
SERIAL_DEBUG.print("I2C_EEPROM_VERSION: ");
|
||||||
|
SERIAL_DEBUG.println(I2C_EEPROM_VERSION);
|
||||||
|
SERIAL_DEBUG.println();
|
||||||
|
|
||||||
SERIAL_DEBUG.println("IT IS BEGINNING");
|
SERIAL_DEBUG.println("IT IS BEGINNING");
|
||||||
SERIAL_DEBUG.println("WAIT FOR IT");
|
SERIAL_DEBUG.println("WAIT FOR IT");
|
||||||
@@ -144,6 +150,6 @@ void setup()
|
|||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// Nothing to do during loop
|
// Nothing to do during loop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ determineSize KEYWORD2
|
|||||||
determineSizeNoWrite KEYWORD2
|
determineSizeNoWrite KEYWORD2
|
||||||
getDeviceSize KEYWORD2
|
getDeviceSize KEYWORD2
|
||||||
getPageSize KEYWORD2
|
getPageSize KEYWORD2
|
||||||
|
calculatePageSize KEYWORD2
|
||||||
getLastWrite KEYWORD2
|
getLastWrite KEYWORD2
|
||||||
|
|
||||||
setDeviceSize KEYWORD2
|
setDeviceSize KEYWORD2
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/RobTillaart/I2C_EEPROM.git"
|
"url": "https://github.com/RobTillaart/I2C_EEPROM.git"
|
||||||
},
|
},
|
||||||
"version": "1.9.3",
|
"version": "1.9.4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"frameworks": "*",
|
"frameworks": "*",
|
||||||
"platforms": "*",
|
"platforms": "*",
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
name=I2C_EEPROM
|
name=I2C_EEPROM
|
||||||
version=1.9.3
|
version=1.9.4
|
||||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
sentence=Library for I2C EEPROMS
|
sentence=Library for I2C EEPROMS
|
||||||
|
|||||||
Reference in New Issue
Block a user