Skip to content

Commit f2527d6

Browse files
committed
Replace removed templates
1 parent dfaa991 commit f2527d6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/EEPROM/elrs_eeprom.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,20 @@ class ELRS_EEPROM
1212
uint8_t ReadByte(const uint32_t address);
1313
void WriteByte(const uint32_t address, const uint8_t value);
1414
void Commit();
15+
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)
19+
{
20+
uint8_t* p = (uint8_t*)(void*)&value;
21+
size_t i = sizeof(value);
22+
while(i--) *p++ = ReadByte(addr++);
23+
};
24+
25+
template <typename T> const void Put(uint32_t addr, const T &value)
26+
{
27+
const uint8_t* p = (const uint8_t*)(const void*)&value;
28+
size_t i = sizeof(value);
29+
while(i--) WriteByte(addr++, *p++);
30+
};
1531
};

0 commit comments

Comments
 (0)