diff options
| author | joe.dumoulin <joe.dumoulin@gmail.com> | 2017-07-30 14:28:05 -0700 |
|---|---|---|
| committer | joe.dumoulin <joe.dumoulin@gmail.com> | 2017-07-30 14:28:05 -0700 |
| commit | f17634478969895d92b062877c04df5e3e90317f (patch) | |
| tree | 5ce59ceac9ec24e5c0946d23f6e218694d81d1ee /m0EEPROM.h | |
| parent | 801bf60c7911078a94f48c3f3c25b988e8b4ac21 (diff) | |
Diffstat (limited to 'm0EEPROM.h')
| -rw-r--r-- | m0EEPROM.h | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -1,11 +1,22 @@ // m0EEPROM.h - definitions for 24LC256 EEPROM read and write for m0 SAMD21G18 and adafruit feather +/* The test code has a bunch of examples of usage. +* +* Note that when using multibyte reads or writes, both the SERIAL_BUFFER_SIZE and the PAGE_SIZE are +* _assumed_ to be powers of 2. +*/ #ifndef M0EEPROM_H #define M0EEPROM_H +#include "Wire.h" + class eeprom { int _device_address; // chip address. currently only supporting one public: - begin(device_address=0x50) : _device_address(device_address){} + void begin(int device_address=0x50) + { + _device_address = device_address; + Wire.begin(); + } // read a byte from the specified address in eeprom memory uint8_t read_byte(uint16_t address); @@ -22,7 +33,9 @@ public: // 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);` + void write_bytes(uint16_t address, uint8_t* data, uint16_t size); }; +extern eeprom Eeprom; + #endif // M0EEPROM_H |
