From 57b60d23cfc24fc12a0b78c6faf0e80758c15c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Redon?= Date: Tue, 24 Jul 2018 09:49:11 +0200 Subject: [PATCH] I2C: add wait time after write to let EEPROM write The Atmel AT24C02 defines a maximum tWR waiting time after a byte write of 5 ms before a next write. Enforcing this wait time also fixed the failed verification in qmod, where it was reading 0xffff instead of the written value. Change-Id: I42c90b8d0329e425f275067e87d584212a43a90b --- firmware/libboard/qmod/source/i2c.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/firmware/libboard/qmod/source/i2c.c b/firmware/libboard/qmod/source/i2c.c index 06c7565f..a7087047 100644 --- a/firmware/libboard/qmod/source/i2c.c +++ b/firmware/libboard/qmod/source/i2c.c @@ -185,6 +185,8 @@ int eeprom_write_byte(uint8_t slave, uint8_t addr, uint8_t byte) nack = i2c_write_byte(false, true, byte); if (nack) goto out_stop; + /* Wait tWR time to ensure EEPROM is writing correctly (tWR = 5 ms for AT24C02) */ + mdelay(5); out_stop: i2c_stop_cond();