22[ ![ Arduino CI] ( https://github.com/RobTillaart/I2C_EEPROM/workflows/Arduino%20CI/badge.svg )] ( https://github.com/marketplace/actions/arduino_ci )
33[ ![ Arduino-lint] ( https://github.com/RobTillaart/I2C_EEPROM/actions/workflows/arduino-lint.yml/badge.svg )] ( https://github.com/RobTillaart/I2C_EEPROM/actions/workflows/arduino-lint.yml )
44[ ![ JSON check] ( https://github.com/RobTillaart/I2C_EEPROM/actions/workflows/jsoncheck.yml/badge.svg )] ( https://github.com/RobTillaart/I2C_EEPROM/actions/workflows/jsoncheck.yml )
5+ [ ![ GitHub issues] ( https://img.shields.io/github/issues/RobTillaart/I2C_EEPROM.svg )] ( https://github.com/RobTillaart/I2C_EEPROM/issues )
6+
57[ ![ License: MIT] ( https://img.shields.io/badge/license-MIT-green.svg )] ( https://github.com/RobTillaart/I2C_EEPROM/blob/master/LICENSE )
68[ ![ GitHub release] ( https://img.shields.io/github/release/RobTillaart/I2C_EEPROM.svg?maxAge=3600 )] ( https://github.com/RobTillaart/I2C_EEPROM/releases )
9+ [ ![ PlatformIO Registry] ( https://badges.registry.platformio.org/packages/robtillaart/library/I2C_EEPROM.svg )] ( https://registry.platformio.org/libraries/robtillaart/I2C_EEPROM )
10+
711
812
913# I2C_EEPROM
@@ -67,13 +71,17 @@ Most important difference is 32 bit memory addresses.
6771optional Wire interface.
6872- ** I2C_eeprom(uint8_t deviceAddress, uint32_t deviceSize, TwoWire \* wire = &Wire)**
6973constructor, with optional Wire interface.
70- - ** bool begin()** initializes the I2C bus with the default pins.
74+ - ** bool begin(uint8_t writeProtectPin = -1 )** initializes the I2C bus with the default pins.
7175Furthermore it checks if the deviceAddress is available on the I2C bus.
7276Returns true if deviceAddress is found on the bus, false otherwise.
73- - ** bool begin(uint8_t sda, uint8_t scl)** for ESP32 / ESP8266 / RP2040 and alike.
77+ Optionally one can set the ** WP** writeProtect pin. (see section below).
78+ If the ** WP** pin is defined the default will be to ** not** allow writing.
79+ - ** bool begin(uint8_t sda, uint8_t scl, uint8_t writeProtectPin = -1)** for ESP32 / ESP8266 / RP2040 and alike.
7480Initializes the I2C bus with the specified pins, thereby overruling the default pins.
7581Furthermore it checks if the deviceAddress is available on the I2C bus.
7682Returns true if deviceAddress is found on the bus, false otherwise.
83+ Optionally one can set the ** WP** writeProtect pin. (see section below).
84+ If the ** WP** pin is defined the default will be to ** not** allow writing.
7785- ** bool isConnected()** test to see if deviceAddress is found on the bus.
7886
7987
@@ -162,7 +170,7 @@ returns set size == 128, 256, ... 32768, 65536
162170returns set size == 8, 16, 32, 64, 128.
163171
164172
165- #### UpdateBlock()
173+ ### UpdateBlock()
166174
167175(new since 1.4.2)
168176
@@ -177,7 +185,7 @@ If data is changed often between writes, **updateBlock()** is slower than **writ
177185So you should verify if your sketch can make use of the advantages of ** updateBlock()**
178186
179187
180- #### ExtraWriteCycleTime (experimental)
188+ ### ExtraWriteCycleTime (experimental)
181189
182190To improve support older I2C EEPROMs e.g. IS24C16 two functions were
183191added to increase the waiting time before a read and/or write as some
@@ -191,6 +199,36 @@ Since 1.7.2 it is also possible to adjust the **I2C_WRITEDELAY** in the .h file
191199or overrule the define on the command line.
192200
193201
202+ ### WriteProtectPin WP (experimental)
203+
204+ (since 1.7.4)
205+
206+ The library can control the ** WP** = WriteProtect pin of the EEPROM.
207+ To do this one should connect a GPIO pin of the MCU to the ** WP** pin of the EEPROM.
208+ Furthermore the ** WP** should be defined as a parameter in ** begin()** .
209+ If the ** WP** pin is defined the default will be to ** not** allow writing.
210+ The user has to enable writing either by manual or automatic control.
211+
212+ In the automatic mode the library only allows writing to the EEPROM when it
213+ actually writes to the EEPROM.
214+ So it keeps the EEPROM in a read only mode as much as possible.
215+ This prevents accidental writes due to (noisy) signals on the I2C bus. (#57 )
216+
217+
218+ Status
219+ - ** bool hasWriteProtectPin()** returns true if ** WP** has been set.
220+
221+ Automatic control
222+ - ** void setAutoWriteProtect(bool b)** if set to true, the library enables writing
223+ only when the EEPROM is actually written. This setting ** overrules** the manual control.
224+ If ** setAutoWriteProtect()** is set to false (== default) the manual control is leading.
225+ - ** bool getAutoWriteProtect()** get current setting.
226+
227+ Manual control
228+ - ** void allowWrite()** allows writing by setting ** WP** to LOW.
229+ - ** void preventWrite()** disables writing by setting ** WP** to HIGH.
230+
231+
194232## Limitation
195233
196234The library does not offer multiple EEPROMS as one continuous storage device.
@@ -220,10 +258,20 @@ See examples
220258- investigate smarter strategy for ** updateBlock()**
221259 => find first and last changed position could possibly result in less writes.
222260- can ** setBlock()** use strategies from ** updateBlock()**
223- - ** \_ waitEEReady();** can return bool and could use isConnected() internally.
224- - added value?
261+
262+
263+ #### Wont
264+
225265- investigate the print interface?
226266 - circular buffer? (see FRAM library)
227267 - dump function?
228268
229- #### Wont
269+
270+ ## Support
271+
272+ If you appreciate my libraries, you can support the development and maintenance.
273+ Improve the quality of the libraries by providing issues and Pull Requests, or
274+ donate through PayPal or GitHub sponsors.
275+
276+ Thank you,
277+
0 commit comments