File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
libraries/CurieEEPROM/src Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 2626
2727#define EEPROM_SIZE 2048 // EEPROM size in bytes
2828
29- // #define EEPROM([(X)])=Y (EEPROM.write((X)*sizeof(uint32_t), Y))
3029
3130#include < inttypes.h>
3231#include " Arduino.h"
@@ -56,6 +55,11 @@ class CurieEEPROM
5655 // Functionality to 'get' and 'put' objects to and from EEPROM.
5756 template < typename T > T &get (uint32_t addr, T &t)
5857 {
58+ // make sure address is valid
59+ if ((addr > 0x7FC ) || (addr%4 ))
60+ {
61+ return t;
62+ }
5963 int byteCount = sizeof (T);
6064 // return if size of object is greater than size of EEPROM
6165 if (byteCount > EEPROM_SIZE)
@@ -72,6 +76,11 @@ class CurieEEPROM
7276 }
7377 template < typename T > T put (uint32_t addr, T t)
7478 {
79+ // make sure address is valid
80+ if ((addr > 0x7FC ) || (addr%4 ))
81+ {
82+ return t;
83+ }
7584 uint32_t rom_wr_ctrl = 0 ;
7685 int byteCount = sizeof (T);
7786 // return if size of object is greater than size of EEPROM
@@ -100,7 +109,6 @@ class CurieEEPROM
100109 }
101110 else
102111 {
103- Serial.println (" Block is not empty. Clearing and rewriting" );
104112 // read entire 2k of data
105113 uint32_t blockdata[EEPROM_SIZE/4 ];
106114 for (int i = 0 ; i < EEPROM_SIZE/4 ; i++)
You can’t perform that action at this time.
0 commit comments