Skip to content

CurieEEPROM fixes #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions libraries/CurieEEPROM/src/CurieEEPROM.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

#define EEPROM_SIZE 2048 //EEPROM size in bytes

//#define EEPROM([(X)])=Y (EEPROM.write((X)*sizeof(uint32_t), Y))

#include <inttypes.h>
#include "Arduino.h"
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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++)
Expand Down