Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: M24512.cpp
- Revision:
- 3:b6d7714cd171
- Parent:
- 0:11e6262c2981
- Child:
- 4:336ef5db5e78
diff -r 1457e305e2b4 -r b6d7714cd171 M24512.cpp
--- a/M24512.cpp Thu Aug 29 12:48:39 2019 +0100
+++ b/M24512.cpp Mon Sep 16 16:30:00 2019 +0100
@@ -121,6 +121,7 @@
/** TODO - Change this to dynamic incase page size increase! */
char cmd[M24512_EEPROM_PAGE_SIZE];
int ret = 0;
+ int8_t retry = 3;
// check for overflow
if ( ( addr + size) > (get_page_size() * get_page_count()) )
@@ -143,14 +144,23 @@
cmd[2+i] = data[i];
}
- ret = _i2c.write(_addr | M24512_COMMAND_WRITE, (const char*)&cmd, size + 2 );
+ while (retry--)
+ {
+ ret = _i2c.write(_addr | M24512_COMMAND_WRITE, (const char*)&cmd, size + 2 );
+ if (ret != 0)
+ {
+ osDelay(100);
+ }else{
+ break;
+ }
+ }
+
if (ret != 0)
{
return M24512::M24512_I2C_ERROR;
}
return ready();
-
}