summaryrefslogtreecommitdiffstats
path: root/firmware/drivers/eeprom_24cxx.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/eeprom_24cxx.c')
-rw-r--r--firmware/drivers/eeprom_24cxx.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/firmware/drivers/eeprom_24cxx.c b/firmware/drivers/eeprom_24cxx.c
index 03e5a3d620..9a8fa5d86d 100644
--- a/firmware/drivers/eeprom_24cxx.c
+++ b/firmware/drivers/eeprom_24cxx.c
@@ -275,7 +275,7 @@ int eeprom_24cxx_read_byte(unsigned int address, char *c)
{
int ret;
char byte;
- int count = 10;
+ int count = 0;
if (address >= EEPROM_SIZE)
{
@@ -287,19 +287,20 @@ int eeprom_24cxx_read_byte(unsigned int address, char *c)
do
{
ret = sw_i2c_read(address, &byte);
- if (ret < 0)
- {
- /* keep between {} as logf is whitespace in normal builds */
- logf("EEPROM rFail: %d/%d", ret, address);
- }
- } while (ret < 0 && count--);
+ } while (ret < 0 && count++ < 200);
if (ret < 0)
{
- logf("EEPROM RFail: %d/%d", ret, address);
+ logf("EEPROM RFail: %d/%d/%d", ret, address, count);
return ret;
}
+ if (count)
+ {
+ /* keep between {} as logf is whitespace in normal builds */
+ logf("EEPROM rOK: %d retries", count);
+ }
+
*c = byte;
return 0;
}
@@ -307,7 +308,7 @@ int eeprom_24cxx_read_byte(unsigned int address, char *c)
int eeprom_24cxx_write_byte(unsigned int address, char c)
{
int ret;
- int count = 100;
+ int count = 0;
if (address >= EEPROM_SIZE)
{
@@ -318,12 +319,7 @@ int eeprom_24cxx_write_byte(unsigned int address, char c)
do
{
ret = sw_i2c_write_byte(address, c);
- if (ret < 0)
- {
- /* keep between {} as logf is whitespace in normal builds */
- logf("EEPROM wFail: %d/%d", ret, address);
- }
- } while (ret < 0 && count--) ;
+ } while (ret < 0 && count++ < 200) ;
if (ret < 0)
{
@@ -331,6 +327,12 @@ int eeprom_24cxx_write_byte(unsigned int address, char c)
return ret;
}
+ if (count)
+ {
+ /* keep between {} as logf is whitespace in normal builds */
+ logf("EEPROM wOK: %d retries", count);
+ }
+
return 0;
}