Files

30 lines
509 B
C++
Raw Permalink Normal View History

2026-10-13 00:23:07 +02:00
// In-memory EEPROM for the native tests (starts erased, all 0xFF like a new chip)
#pragma once
#include <cstdint>
#include <cstring>
class FakeEEPROM
{
public:
uint8_t mem[1024];
FakeEEPROM() { erase(); }
void erase() { memset(mem, 0xFF, sizeof(mem)); }
template <typename T>
T &get(int addr, T &t)
{
memcpy(&t, mem + addr, sizeof(T));
return t;
}
template <typename T>
const T &put(int addr, const T &t)
{
memcpy(mem + addr, &t, sizeof(T));
return t;
}
};
inline FakeEEPROM EEPROM;