From 4932616c873d7b06af99698214a718f572a404f6 Mon Sep 17 00:00:00 2001 From: Dino Tinitigan Date: Tue, 19 Jan 2016 15:53:12 -0800 Subject: [PATCH] CurieEEPROM fixes -remove leftover debug prints -put() and get() should only support 32-bit alligned addresses --- libraries/CurieEEPROM/src/CurieEEPROM.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libraries/CurieEEPROM/src/CurieEEPROM.h b/libraries/CurieEEPROM/src/CurieEEPROM.h index 9832047c..fe0e9d06 100644 --- a/libraries/CurieEEPROM/src/CurieEEPROM.h +++ b/libraries/CurieEEPROM/src/CurieEEPROM.h @@ -26,7 +26,6 @@ #define EEPROM_SIZE 2048 //EEPROM size in bytes -//#define EEPROM([(X)])=Y (EEPROM.write((X)*sizeof(uint32_t), Y)) #include #include "Arduino.h" @@ -56,6 +55,11 @@ class CurieEEPROM //Functionality to 'get' and 'put' objects to and from EEPROM. template< typename T > T &get(uint32_t addr, T &t) { + //make sure address is valid + if((addr > 0x7FC) || (addr%4)) + { + return t; + } int byteCount = sizeof(T); //return if size of object is greater than size of EEPROM if(byteCount > EEPROM_SIZE) @@ -72,6 +76,11 @@ class CurieEEPROM } template< typename T > T put(uint32_t addr, T t) { + //make sure address is valid + if((addr > 0x7FC) || (addr%4)) + { + return t; + } uint32_t rom_wr_ctrl = 0; int byteCount = sizeof(T); //return if size of object is greater than size of EEPROM @@ -100,7 +109,6 @@ class CurieEEPROM } else { - Serial.println("Block is not empty. Clearing and rewriting"); //read entire 2k of data uint32_t blockdata[EEPROM_SIZE/4]; for(int i = 0; i < EEPROM_SIZE/4; i++)