makes GPIO_PIN_RST optional for the sx1276
[ExpressLRS.git] / src / lib / EEPROM / elrs_eeprom.h
blob8dd117dfd9bdc093b1196031de1d7e6c2e3d0ede
1 #pragma once
3 #include <stdint.h>
4 #include <cstddef>
6 #define RESERVED_EEPROM_SIZE 1024
8 class ELRS_EEPROM
10 public:
11 void Begin();
12 uint8_t ReadByte(const uint32_t address);
13 void WriteByte(const uint32_t address, const uint8_t value);
14 void Commit();
16 // The extEEPROM lib that we use for STM doesn't have the get and put templates
17 // These templates need to be reimplemented here
18 template <typename T> void Get(uint32_t addr, T &value)
20 uint8_t* p = (uint8_t*)(void*)&value;
21 size_t i = sizeof(value);
22 while(i--) *p++ = ReadByte(addr++);
25 template <typename T> const void Put(uint32_t addr, const T &value)
27 const uint8_t* p = (const uint8_t*)(const void*)&value;
28 size_t i = sizeof(value);
29 while(i--) WriteByte(addr++, *p++);