1 #ifndef _MOCK_EEPROM_ABSTRACTION_H_
2 #define _MOCK_EEPROM_ABSTRACTION_H_
27 data =
new uint8_t[size];
30 memset(data, 0, memSize);
37 void clearError() {errorFlag =
false;}
40 if(uint16_t(pos + len) >= memSize) {
41 serlogF2(SER_DEBUG,
"checkbounds exceeded: ", pos+len);
47 memset(data, 0, memSize);
51 checkBounds(position, 1);
52 return data[position];
56 checkBounds(position, 1);
61 return read8(position) | (
read8(position + 1) << 8);
66 write8(position + 1, val >> 8);
70 checkBounds(position, 4);
71 return (uint32_t)
read8(position) | ((uint32_t)
read8(position + 1) << 8) | ((uint32_t)
read8(position + 2) << 16) | ((uint32_t)
read8(position + 3) << 24);
75 checkBounds(position, 4);
77 write8(position + 1, val >> 8);
78 write8(position + 2, val >> 16);
79 write8(position + 3, val >> 24);
83 checkBounds(romSrc, len);
84 memcpy(memDest, &data[romSrc], len);
88 checkBounds(romDest, len);
89 memcpy(&data[romDest], memSrc, len);
92 void serPrintContents(
int start,
int len) {
94 serlogF(SER_DEBUG,
"Mock rom debug - len too big");
100 for(i=0; i<len; i++) {
101 if(data[i + start] >= 30)
102 str[i] = data[i + start];
107 serlogF4(SER_DEBUG,
"MockRom contents start, len, data: ", start, len, str);
Wraps up EEPROM support in a way that is compatible between implementations. For example presently th...
uint16_t EepromPosition
Definition: EepromAbstraction.h:26
Definition: EepromAbstraction.h:33
This file contains implementations of the EepromAbstraction that are useful for dev & testing....
Definition: MockEepromAbstraction.h:20
void write16(EepromPosition position, uint16_t val) override
Definition: MockEepromAbstraction.h:64
virtual uint32_t read32(EepromPosition position) override
Definition: MockEepromAbstraction.h:69
virtual void readIntoMemArray(uint8_t *memDest, EepromPosition romSrc, uint8_t len) override
Definition: MockEepromAbstraction.h:82
bool hasErrorOccurred() override
Definition: MockEepromAbstraction.h:36
uint16_t read16(EepromPosition position) override
Definition: MockEepromAbstraction.h:60
uint8_t read8(EepromPosition position) override
Definition: MockEepromAbstraction.h:50
virtual void write32(EepromPosition position, uint32_t val) override
Definition: MockEepromAbstraction.h:74
virtual void writeArrayToRom(EepromPosition romDest, const uint8_t *memSrc, uint8_t len) override
Definition: MockEepromAbstraction.h:87
void write8(EepromPosition position, uint8_t val) override
Definition: MockEepromAbstraction.h:55