Skip to content

Commit

Permalink
eeprom_i2c wp pin: when setting the WP pin to protected, first write …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
purdeaandrei committed Jun 21, 2021
1 parent fec9c75 commit 2547b07
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/eeprom/eeprom_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

0 comments on commit 2547b07

Please sign in to comment.