From 2547b07849044186335a34cece17d6cc3c312bcd Mon Sep 17 00:00:00 2001 From: Purdea Andrei Date: Sun, 25 Apr 2021 02:21:58 +0300 Subject: [PATCH] eeprom_i2c wp pin: when setting the WP pin to protected, first write the pin value to 1, to make sure there are at least two bit-flips that are needed to change the pin back to 0 --- drivers/eeprom/eeprom_i2c.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/eeprom/eeprom_i2c.c b/drivers/eeprom/eeprom_i2c.c index 2c245bf8d3bf..8e80ff544fc6 100644 --- a/drivers/eeprom/eeprom_i2c.c +++ b/drivers/eeprom/eeprom_i2c.c @@ -56,6 +56,8 @@ static inline void fill_target_address(uint8_t *buffer, const void *addr) { void eeprom_driver_init(void) { i2c_init(); #if defined(EXTERNAL_EEPROM_WP_PIN) + /* We are setting the WP pin to high in a way that requires at least two bit-flips to change back to 0 */ + writePin(EXTERNAL_EEPROM_WP_PIN, 1); setPinInputHigh(EXTERNAL_EEPROM_WP_PIN); #endif } @@ -131,6 +133,8 @@ void eeprom_write_block(const void *buf, void *addr, size_t len) { } #if defined(EXTERNAL_EEPROM_WP_PIN) + /* We are setting the WP pin to high in a way that requires at least two bit-flips to change back to 0 */ + writePin(EXTERNAL_EEPROM_WP_PIN, 1); setPinInputHigh(EXTERNAL_EEPROM_WP_PIN); #endif }