Skip to content

Commit

Permalink
Added memSize() function
Browse files Browse the repository at this point in the history
  • Loading branch information
SV-Zanshin committed Sep 3, 2017
1 parent eab7f97 commit f6a09ce
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Examples/ReadWrite/ReadWrite.ino
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,15 @@ void setup() { //
Serial.println("\"."); // //
// //
if (chips>1) { // Demonstrate overlapping memories //
Serial.println("\nMultiple memories found, demonstrating overlapping."); // //
Serial.println("\nMultiple memories found:"); // //
for (uint8_t i=0;i<chips;i++) { // Display information for each mem //
Serial.print("Memory "); // //
Serial.print(i); // //
Serial.print(" has "); // //
Serial.print(FRAM.memSize(i)); // //
Serial.println(" bytes."); // //
} // for-next each memory chip found // //
Serial.println("\nDemonstrating overlapping."); // //
Serial.println("Assuming first memory is a 32Kb memory."); // //
uint32_t memAddress = 32768; // Change here if chip is different //
FRAM.write(memAddress-6,testArray); // Split test across 2 chips //
Expand Down
7 changes: 7 additions & 0 deletions MB85_FRAM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,10 @@ uint8_t MB85_FRAM_Class::getDevice(uint32_t &memAddress,uint32_t &endAddress){//
} // of for-next all possible devices // //
return device; // //
} // of internal method getDevice() //----------------------------------//

/*******************************************************************************************************************
** Method memSize() returns the device's size in Kb **
*******************************************************************************************************************/
uint16_t MB85_FRAM_Class::memSize(const uint8_t memNumber) { // Return memory size in bytes //
if(memNumber<=_DeviceCount) return(_I2C[memNumber]*1024); else return 0; // Return appropriate value //
} // of method memSize() //----------------------------------//
1 change: 1 addition & 0 deletions MB85_FRAM.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
~MB85_FRAM_Class(); // Class destructor //
uint8_t begin(); // Start using I2C Communications //
uint32_t totalBytes(); // Return the total memory available//
uint16_t memSize(const uint8_t memNumber); // Return memory size in bytes //
/*************************************************************************************************************
** Declare the read and write methods as template functions. All device I/O is done through these two **
** functions. If multiple memories have been found they are treated as if they were just one large memory, **
Expand Down

0 comments on commit f6a09ce

Please sign in to comment.