EndPoint Class Reference

yasimavr: SPI::EndPoint Class Reference
yasimavr
Loading...
Searching...
No Matches
SPI::EndPoint Class Referenceabstract

An endpoint connected to a SPI bus. Represents a device connected to a SPI bus model and acting as a host or client. This is primarily intended to help simulate peripherals connected to the MCU model. Note that this class only implements the logic require to shift bytes across the SPI bus in all modes or bit orders. More...

#include <sim_spi.h>

Inheritance diagram for SPI::EndPoint:
ArchAVR_SPI::_Controller ArchXT_SPI::_Controller

Public Member Functions

 EndPoint ()
 
virtual ~EndPoint ()=default
 
void set_serial_mode (SerialMode mode)
 
SerialMode serial_mode () const
 
void set_bit_order (BitOrder order)
 
BitOrder bit_order () const
 
void set_shift_data (uint8_t frame)
 
uint8_t shift_data () const
 
bool complete_frame () const
 Returns true when a complete byte has been transferred/received.
 

Protected Member Functions

void set_active (bool active)
 Enable/disable the endpoint A disabled endpoint will ignore any clock change but still keeps track of them.
 
bool active () const
 
virtual void frame_completed ()
 
virtual void write_data_output (bool level)=0
 
virtual bool read_data_input ()=0
 
void set_shift_clock (bool state)
 
bool shift_clock () const
 

Detailed Description

An endpoint connected to a SPI bus. Represents a device connected to a SPI bus model and acting as a host or client. This is primarily intended to help simulate peripherals connected to the MCU model. Note that this class only implements the logic require to shift bytes across the SPI bus in all modes or bit orders.

Constructor & Destructor Documentation

◆ EndPoint()

EndPoint::EndPoint ( )

◆ ~EndPoint()

virtual SPI::EndPoint::~EndPoint ( )
virtualdefault

Member Function Documentation

◆ active()

bool SPI::EndPoint::active ( ) const
inlineprotected

◆ bit_order()

BitOrder SPI::EndPoint::bit_order ( ) const
inline

◆ complete_frame()

bool SPI::EndPoint::complete_frame ( ) const
inline

Returns true when a complete byte has been transferred/received.

◆ frame_completed()

void EndPoint::frame_completed ( )
protectedvirtual

Virtual callback function called on the last clock edge of a byte shift. Can be overriden by upper layers to signal when the transmission/reception of a byte has been completed. The base function does nothing.

Reimplemented in ArchAVR_SPI::_Controller, and ArchXT_SPI::_Controller.

◆ read_data_input()

virtual bool SPI::EndPoint::read_data_input ( )
protectedpure virtual

Virtual function called by the internal logic to read the DATA IN line

Returns
level Line level true=HIGH, false=LOW

Implemented in ArchAVR_SPI::_Controller, and ArchXT_SPI::_Controller.

◆ serial_mode()

SerialMode SPI::EndPoint::serial_mode ( ) const
inline

◆ set_active()

void EndPoint::set_active ( bool  active)
protected

Enable/disable the endpoint A disabled endpoint will ignore any clock change but still keeps track of them.

◆ set_bit_order()

void EndPoint::set_bit_order ( BitOrder  order)

◆ set_serial_mode()

void EndPoint::set_serial_mode ( SerialMode  mode)

◆ set_shift_clock()

void EndPoint::set_shift_clock ( bool  state)
protected

Upper layers should call this function to flip the clock line state. The logic will shift bit values to the Data IN/Out wires as appropriate according to the mode and bitorder selected. Does nothing if the clock state is unchanged or the endpoint is inactive.

Parameters
statenew clock line state true=clock rise, false=clock fall

◆ set_shift_data()

void EndPoint::set_shift_data ( uint8_t  frame)

Set the byte to be transmitted in the next transfer.

◆ shift_clock()

bool SPI::EndPoint::shift_clock ( ) const
inlineprotected

◆ shift_data()

uint8_t SPI::EndPoint::shift_data ( ) const
inline

Return the content of the shift register. When called after a transfer, it contains the received byte.

◆ write_data_output()

virtual void SPI::EndPoint::write_data_output ( bool  level)
protectedpure virtual

Virtual function called by the internal logic to write to the DATA OUT line

Parameters
levelLine level true=HIGH, false=LOW

Implemented in ArchAVR_SPI::_Controller, and ArchXT_SPI::_Controller.


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