IoAbstraction
Public Member Functions | List of all members
MockEepromAbstraction Class Reference

This file contains implementations of the EepromAbstraction that are useful for dev & testing. None of the implementations in this file are designed for production use. More...

#include <MockEepromAbstraction.h>

Inheritance diagram for MockEepromAbstraction:
EepromAbstraction

Public Member Functions

 MockEepromAbstraction (unsigned int size=128)
 
bool hasErrorOccurred () override
 
void clearError ()
 
void checkBounds (EepromPosition pos, int len)
 
void reset ()
 
uint8_t read8 (EepromPosition position) override
 
void write8 (EepromPosition position, uint8_t val) override
 
uint16_t read16 (EepromPosition position) override
 
void write16 (EepromPosition position, uint16_t val) override
 
virtual uint32_t read32 (EepromPosition position) override
 
virtual void write32 (EepromPosition position, uint32_t val) override
 
virtual void readIntoMemArray (uint8_t *memDest, EepromPosition romSrc, uint8_t len) override
 
virtual void writeArrayToRom (EepromPosition romDest, const uint8_t *memSrc, uint8_t len) override
 
void serPrintContents (int start, int len)
 

Detailed Description

This file contains implementations of the EepromAbstraction that are useful for dev & testing. None of the implementations in this file are designed for production use.

@ file MockEepromAbstraction.h @ file MockEepromAbstraction.h

An in memory eeprom implementation that can be used in unit tests the verify the behaviour of your application without needing to write to an actual eeprom. It by default allocates 128 bytes for storage, but can be changed by adjusting the defined size in the header file

Member Function Documentation

◆ hasErrorOccurred()

bool MockEepromAbstraction::hasErrorOccurred ( )
inlineoverridevirtual

Best efforts error flag that will clear once read.

Reimplemented from EepromAbstraction.

◆ read8()

uint8_t MockEepromAbstraction::read8 ( EepromPosition  position)
inlineoverridevirtual

Read an 8 bit (byte) value at a specified position

Parameters
positionaddress at which to read

Implements EepromAbstraction.

◆ write8()

void MockEepromAbstraction::write8 ( EepromPosition  position,
uint8_t  val 
)
inlineoverridevirtual

write an 8 bit (byte) value to the specified position

Parameters
positionthe position at which to write
valthe new value

Implements EepromAbstraction.

◆ read16()

uint16_t MockEepromAbstraction::read16 ( EepromPosition  position)
inlineoverridevirtual

read a 16 bit value at position at a specified position

Parameters
positionthe position at which to read

Implements EepromAbstraction.

◆ write16()

void MockEepromAbstraction::write16 ( EepromPosition  position,
uint16_t  val 
)
inlineoverridevirtual

write a 16 bit value to the specified position

Parameters
positionthe position at which to write
valthe value to read

Implements EepromAbstraction.

◆ read32()

virtual uint32_t MockEepromAbstraction::read32 ( EepromPosition  position)
inlineoverridevirtual

read a 32 bit value at a specified position

Parameters
positionthe position at which to read

Implements EepromAbstraction.

◆ write32()

virtual void MockEepromAbstraction::write32 ( EepromPosition  position,
uint32_t  val 
)
inlineoverridevirtual

write a 32 bit value to position

Parameters
positionthe position at which to write
valthe value to write out.

Implements EepromAbstraction.

◆ readIntoMemArray()

virtual void MockEepromAbstraction::readIntoMemArray ( uint8_t *  memDest,
EepromPosition  romSrc,
uint8_t  len 
)
inlineoverridevirtual

Read an array of bytes from EEPROM into memory

Parameters
memDestthe memory where the EEPROM data should be copied to
romSrcthe source position in EEPROM storage
lenthe length of the array

Implements EepromAbstraction.

◆ writeArrayToRom()

virtual void MockEepromAbstraction::writeArrayToRom ( EepromPosition  romDest,
const uint8_t *  memSrc,
uint8_t  len 
)
inlineoverridevirtual

Writes an array of bytes from memory to EEPROM storage

Parameters
romDestthe start position in eeprom storage that the array should be copied to
memSrcthe memory where the rom should be copied from
lenthe length of the array

Implements EepromAbstraction.


The documentation for this class was generated from the following file: