summaryrefslogtreecommitdiff
path: root/m0EEPROM.h
diff options
context:
space:
mode:
authorjoe.dumoulin <joe.dumoulin@gmail.com>2017-07-20 20:21:56 -0700
committerjoe.dumoulin <joe.dumoulin@gmail.com>2017-07-20 20:21:56 -0700
commit801bf60c7911078a94f48c3f3c25b988e8b4ac21 (patch)
treec8b3808ad0c902a17f0114dab3e8e9fc3a0c34cc /m0EEPROM.h
first commit
Diffstat (limited to 'm0EEPROM.h')
-rw-r--r--m0EEPROM.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/m0EEPROM.h b/m0EEPROM.h
new file mode 100644
index 0000000..8f58942
--- /dev/null
+++ b/m0EEPROM.h
@@ -0,0 +1,28 @@
+// m0EEPROM.h - definitions for 24LC256 EEPROM read and write for m0 SAMD21G18 and adafruit feather
+#ifndef M0EEPROM_H
+#define M0EEPROM_H
+
+class eeprom {
+ int _device_address; // chip address. currently only supporting one
+public:
+ begin(device_address=0x50) : _device_address(device_address){}
+
+ // read a byte from the specified address in eeprom memory
+ uint8_t read_byte(uint16_t address);
+
+ // write a single byte of data to the given address in eeprom memory
+ void write_byte(uint16_t address, uint8_t value);
+
+ // read a structure of arbitrary size from address.
+ // the size of the structure must be less than 64K-address.
+ // returns a byte array of memory specified. The byte array data
+ // must be preallocated to the expected size.
+ uint8_t* read_bytes(uint16_t address, uint8_t* data, uint16_t size);
+
+ // write a structure of arbitrary size to memory at address.
+ // the size of the structure must be less than 64K-address.
+ // The structure is passed as a byte array.
+ void write_bytes(uint16_t address, uint8_t* data, uint16_t size);`
+};
+
+#endif // M0EEPROM_H