HardFOC Core
API reference
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
hf::host::MockSpi Class Reference

#include <MockSpi.h>

Inheritance diagram for hf::host::MockSpi:

Public Types

using Responder = std::function< void(const uint8_t *tx, uint8_t *rx, uint16_t len)>
 

Public Member Functions

 MockSpi () noexcept=default
 
 ~MockSpi () noexcept override=default
 
bool Initialize () noexcept override
 
bool Deinitialize () noexcept override
 
hf_spi_err_t Transfer (const hf_u8_t *tx_data, hf_u8_t *rx_data, hf_u16_t length, hf_u32_t timeout_ms=0) noexcept override
 
const void * GetDeviceConfig () const noexcept override
 
void SetInitializeResult (bool ok) noexcept
 
void QueueResponse (std::vector< uint8_t > miso)
 
void FailNext (hf_spi_err_t error, size_t count=1) noexcept
 
void SetResponder (Responder responder)
 
void SetFillByte (uint8_t fill) noexcept
 
const std::vector< SpiTransaction > & Transactions () const noexcept
 
void ClearTransactions () noexcept
 
int InitializeCalls () const noexcept
 

Private Attributes

bool init_result_ {true}
 
int init_calls_ {0}
 
uint8_t fill_ {0x00}
 
std::deque< std::vector< uint8_t > > queued_
 
hf_spi_err_t fail_error_ {hf_spi_err_t::SPI_ERR_TRANSFER_FAILED}
 
size_t fail_count_ {0}
 
Responder responder_
 
std::vector< SpiTransaction > log_
 

Member Typedef Documentation

◆ Responder

using hf::host::MockSpi::Responder = std::function<void(const uint8_t* tx, uint8_t* rx, uint16_t len)>

Responder: fill rx (len bytes) for the MOSI frame tx.

Constructor & Destructor Documentation

◆ MockSpi()

hf::host::MockSpi::MockSpi ( )
defaultnoexcept

◆ ~MockSpi()

hf::host::MockSpi::~MockSpi ( )
overridedefaultnoexcept

Member Function Documentation

◆ ClearTransactions()

void hf::host::MockSpi::ClearTransactions ( )
inlinenoexcept

◆ Deinitialize()

bool hf::host::MockSpi::Deinitialize ( )
overridenoexcept

◆ FailNext()

void hf::host::MockSpi::FailNext ( hf_spi_err_t  error,
size_t  count = 1 
)
noexcept

◆ GetDeviceConfig()

const void * hf::host::MockSpi::GetDeviceConfig ( ) const
inlineoverridenoexcept

◆ Initialize()

bool hf::host::MockSpi::Initialize ( )
overridenoexcept

◆ InitializeCalls()

int hf::host::MockSpi::InitializeCalls ( ) const
inlinenoexcept

◆ QueueResponse()

void hf::host::MockSpi::QueueResponse ( std::vector< uint8_t >  miso)

◆ SetFillByte()

void hf::host::MockSpi::SetFillByte ( uint8_t  fill)
inlinenoexcept

◆ SetInitializeResult()

void hf::host::MockSpi::SetInitializeResult ( bool  ok)
inlinenoexcept

◆ SetResponder()

void hf::host::MockSpi::SetResponder ( Responder  responder)
inline

◆ Transactions()

const std::vector< SpiTransaction > & hf::host::MockSpi::Transactions ( ) const
inlinenoexcept

◆ Transfer()

hf_spi_err_t hf::host::MockSpi::Transfer ( const hf_u8_t *  tx_data,
hf_u8_t *  rx_data,
hf_u16_t  length,
hf_u32_t  timeout_ms = 0 
)
overridenoexcept

Member Data Documentation

◆ fail_count_

size_t hf::host::MockSpi::fail_count_ {0}
private

◆ fail_error_

hf_spi_err_t hf::host::MockSpi::fail_error_ {hf_spi_err_t::SPI_ERR_TRANSFER_FAILED}
private

◆ fill_

uint8_t hf::host::MockSpi::fill_ {0x00}
private

◆ init_calls_

int hf::host::MockSpi::init_calls_ {0}
private

◆ init_result_

bool hf::host::MockSpi::init_result_ {true}
private

◆ log_

std::vector<SpiTransaction> hf::host::MockSpi::log_
private

◆ queued_

std::deque<std::vector<uint8_t> > hf::host::MockSpi::queued_
private

◆ responder_

Responder hf::host::MockSpi::responder_
private

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