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.
Revision 4:d8f51b136dbd, committed 2020-03-28
- Comitter:
- skyscraper
- Date:
- Sat Mar 28 01:50:44 2020 +0000
- Parent:
- 3:b2a132553b02
- Child:
- 5:315872eec0ae
- Commit message:
- Streamline EEprom and remove some unneded functionality
Changed in this revision
| I2CEeprom.cpp | Show annotated file Show diff for this revision Revisions of this file |
| I2CEeprom.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/I2CEeprom.cpp Sat Mar 28 01:38:00 2020 +0000
+++ b/I2CEeprom.cpp Sat Mar 28 01:50:44 2020 +0000
@@ -92,7 +92,7 @@
}
return 0;
}
-// works ok
+
size_t I2CEeprom::write(size_t address, char value)
{
// Check the address and size fit onto the chip.
@@ -109,7 +109,6 @@
return 1;
}
-
size_t I2CEeprom::ll_write(size_t address, const char *buffer, size_t size)
{
// TODO: change i2c address bits dependent on eeprom data address
@@ -122,7 +121,6 @@
return size;
}
-// ret num written
size_t I2CEeprom::write(size_t address, const char *buffer, size_t size)
{
if (!checkSpace(address, size)) {
@@ -157,28 +155,12 @@
void I2CEeprom::waitForWrite()
{
-
ThisThread::sleep_for(m_writeCycleTime_ms);
// The chip doesn't ACK while writing to the actual EEPROM
// so loop trying to do a zero byte write until it is ACKed
// by the chip.
while (m_i2c.write(m_i2cAddress, 0, 0) != 0) {
- // Wait for ack.
ThisThread::sleep_for(1);
}
}
-bool I2CEeprom::checkSpace(size_t address, size_t size)
-{
- // Only check, if chip size is non-zero.
- if (m_chipSize != 0) {
- // Check that the address start in the chip and doesn't
- // extend past.
- if ((address >= m_chipSize) || ((address + size) >= m_chipSize))
- return false;
- else
- return true;
- }
-
- return true;
-}
--- a/I2CEeprom.h Sat Mar 28 01:38:00 2020 +0000
+++ b/I2CEeprom.h Sat Mar 28 01:50:44 2020 +0000
@@ -93,7 +93,10 @@
// Validate that the proposed opperation will fit in the size of
// the chip.
- bool checkSpace(size_t address, size_t size);
+ bool checkSpace(size_t address, size_t size)
+ {
+ return (address + size) < m_chipSize ;
+ }
private:
I2C & m_i2c;