summaryrefslogtreecommitdiff
path: root/EEPROM_IO.h
diff options
context:
space:
mode:
authorMike Beattie <mike@ethernal.org>2012-03-20 23:23:47 +1300
committerMike Beattie <mike@ethernal.org>2012-03-20 23:23:47 +1300
commit13d22c5d2ab2fdb15d268ce75e8a9c35d6781944 (patch)
tree6e79bbe01e0cd7d6d0ba65a840739527858e50cc /EEPROM_IO.h
Initial import
Signed-off-by: Mike Beattie <mike@ethernal.org>
Diffstat (limited to 'EEPROM_IO.h')
-rw-r--r--EEPROM_IO.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/EEPROM_IO.h b/EEPROM_IO.h
new file mode 100644
index 0000000..1c59780
--- /dev/null
+++ b/EEPROM_IO.h
@@ -0,0 +1,24 @@
+#include <Arduino.h>
+
+
+/*********************************************************************************/
+/* EEPROM read/write functions */
+
+template <class T> int eepromWrite(int ee, const T& value) {
+ const byte* p = (const byte*)(const void*)&value;
+ unsigned int i;
+ for (i = 0; i < sizeof(value); i++)
+ EEPROM.write(ee++, *p++);
+ return i;
+}
+
+
+template <class T> int eepromRead(int ee, T& value) {
+ byte* p = (byte*)(void*)&value;
+ unsigned int i;
+ for (i = 0; i < sizeof(value); i++)
+ *p++ = EEPROM.read(ee++);
+ return i;
+}
+
+