HardFOC Core
API reference
Loading...
Searching...
No Matches
Classes | Namespaces
MockI2c.h File Reference

Scriptable BaseI2c fake for host tests. More...

#include "base/BaseI2c.h"
#include <array>
#include <cstdint>
#include <deque>
#include <functional>
#include <vector>

Go to the source code of this file.

Classes

struct  hf::host::I2cTransaction
 
class  hf::host::MockI2c
 
struct  hf::host::MockI2c::Queued
 

Namespaces

namespace  hf
 
namespace  hf::host
 

Detailed Description

Scriptable BaseI2c fake for host tests.

Every call is recorded as an I2cTransaction. Reads are answered, in order of preference, by:

  1. a queued response (QueueRead), consumed first-in first-out;
  2. a responder callback (SetResponder), for protocol models;
  3. the register model, when enabled: a write of [reg, b0, b1, ...] stores b0.. at reg, reg+1, ...; a WriteRead of [reg] returns reg, reg+1, ...; a plain Read continues from the last register pointer;
  4. zero bytes. FailNext() makes the next N calls (of any kind) return an error without touching data; the failed calls are still recorded.