-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add **uint32_t determineSizeNoWrite()**, kudos to roelandkluit - add example - minor edits
- Loading branch information
1 parent
0248508
commit 42cdf1a
Showing
7 changed files
with
109 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
examples/I2C_eeprom_determineSizeNoWrite/I2C_eeprom_determineSizeNoWrite.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// FILE: I2C_eeprom_determineSizeNoWrite.ino | ||
// AUTHOR: Rob Tillaart | ||
// PURPOSE: test determineSizeNoWrite() function | ||
|
||
|
||
#include "Wire.h" | ||
#include "I2C_eeprom.h" | ||
|
||
|
||
I2C_eeprom ee(0x50, I2C_DEVICESIZE_24LC256); | ||
|
||
uint32_t start, diff; | ||
|
||
|
||
void setup() | ||
{ | ||
Serial.begin(115200); | ||
while (!Serial); // wait for Serial port to connect. Needed for Leonardo only | ||
Serial.println(__FILE__); | ||
Serial.print("I2C_EEPROM_VERSION: "); | ||
Serial.println(I2C_EEPROM_VERSION); | ||
|
||
Wire.begin(); | ||
|
||
ee.begin(); | ||
if (! ee.isConnected()) | ||
{ | ||
Serial.println("ERROR: Can't find eeprom\nstopped..."); | ||
while (1); | ||
} | ||
|
||
Serial.println("\nDetermine size no write"); | ||
delay(100); | ||
|
||
start = micros(); | ||
uint32_t size = ee.determineSizeNoWrite(); | ||
diff = micros() - start; | ||
Serial.print("TIME: "); | ||
Serial.print(diff); | ||
Serial.println(" us."); | ||
if (size == 0) | ||
{ | ||
Serial.println("SIZE: could not determine size"); | ||
} | ||
else if (size > 1024) | ||
{ | ||
Serial.print("SIZE: "); | ||
Serial.print(size / 1024); | ||
Serial.println(" KB."); | ||
} | ||
else | ||
{ | ||
Serial.print("SIZE: "); | ||
Serial.print(size); | ||
Serial.println(" bytes."); | ||
} | ||
|
||
Serial.print("PAGE: "); | ||
uint8_t pageSize = ee.getPageSize(size); | ||
Serial.print(pageSize); | ||
Serial.println(" bytes."); | ||
|
||
Serial.println("Done..."); | ||
} | ||
|
||
|
||
void loop() | ||
{ | ||
} | ||
|
||
|
||
// -- END OF FILE -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters