uTL
micro Template library
utl::spi_i< virtual_tag > Class Template Referenceabstract

A virtual base class implementation. More...

#include <spi.h>

Inheritance diagram for utl::spi_i< virtual_tag >:
utl::spi_bb_i< virtual_tag, CPOL, CPHA, BitOrder >

Public Types

using type = spi_i< virtual_tag >
 Export type as identity meta-function. More...
 

Public Member Functions

Get/Set functions provided by the interface
uint32_t clock () const
 
void clock (uint32_t c)
 set clock frequency of the bus More...
 
I/O functions provided by the interface
byte_t tx_data (byte_t out)
 
size_t tx_data (const byte_t *out, byte_t *in, size_t n)
 Transmit a number of bytes to the spi bus and read the response. More...
 
byte_t rx_data ()
 
size_t rx_data (byte_t *in, size_t n)
 Receive a number of bytes from the spi bus while transmitting 0xFFs. More...
 

Private Member Functions

Implementation requirements
virtual uint32_t _clock () const =0
 Read the clock frequency of the bus. More...
 
virtual void _clock (uint32_t)=0
 Set the clock frequency of the bus. More...
 
virtual byte_t _tx_data (byte_t)=0
 

Object lifetime

 spi_i ()=default
 Allow constructor from derived only. More...
 
 spi_i (const type &)=delete
 No copies. More...
 
typeoperator= (const type &)=delete
 
virtual ~spi_i ()=default
 

Detailed Description

template<>
class utl::spi_i< virtual_tag >

A virtual base class implementation.

Parameters
none

Definition at line 177 of file spi.h.

Member Typedef Documentation

◆ type

Export type as identity meta-function.

Definition at line 179 of file spi.h.

Constructor & Destructor Documentation

◆ spi_i() [1/2]

utl::spi_i< virtual_tag >::spi_i ( )
protecteddefault

Allow constructor from derived only.

◆ spi_i() [2/2]

utl::spi_i< virtual_tag >::spi_i ( const type )
protecteddelete

No copies.

◆ ~spi_i()

virtual utl::spi_i< virtual_tag >::~spi_i ( )
virtualdefault

Virtual default destructor

Member Function Documentation

◆ _clock() [1/2]

virtual uint32_t utl::spi_i< virtual_tag >::_clock ( ) const
privatepure virtual

Read the clock frequency of the bus.

Implemented in utl::spi_bb_i< virtual_tag, CPOL, CPHA, BitOrder >.

◆ _clock() [2/2]

virtual void utl::spi_i< virtual_tag >::_clock ( uint32_t  )
privatepure virtual

Set the clock frequency of the bus.

Implemented in utl::spi_bb_i< virtual_tag, CPOL, CPHA, BitOrder >.

◆ _tx_data()

virtual byte_t utl::spi_i< virtual_tag >::_tx_data ( byte_t  )
privatepure virtual

Transmit a byte on the bus and return the response

Implemented in utl::spi_bb_i< virtual_tag, CPOL, CPHA, BitOrder >.

◆ clock() [1/2]

uint32_t utl::spi_i< virtual_tag >::clock ( ) const
inline
Returns
clock frequency of the bus

Definition at line 208 of file spi.h.

◆ clock() [2/2]

void utl::spi_i< virtual_tag >::clock ( uint32_t  c)
inline

set clock frequency of the bus

Definition at line 209 of file spi.h.

◆ operator=()

type& utl::spi_i< virtual_tag >::operator= ( const type )
protecteddelete

◆ rx_data() [1/2]

byte_t utl::spi_i< virtual_tag >::rx_data ( )
inline

Receive a byte from spi bus while transmitting 0xFF

Definition at line 235 of file spi.h.

◆ rx_data() [2/2]

size_t utl::spi_i< virtual_tag >::rx_data ( byte_t in,
size_t  n 
)

Receive a number of bytes from the spi bus while transmitting 0xFFs.

Parameters
inPointer to buffer to store the data
nThe number of bytes to read
Returns
The number of received bytes.

Definition at line 270 of file spi.h.

◆ tx_data() [1/2]

byte_t utl::spi_i< virtual_tag >::tx_data ( byte_t  out)
inline

Transmit a byte to spi bus and return the response

Definition at line 220 of file spi.h.

◆ tx_data() [2/2]

size_t utl::spi_i< virtual_tag >::tx_data ( const byte_t out,
byte_t in,
size_t  n 
)

Transmit a number of bytes to the spi bus and read the response.

Parameters
outPointer to data to send to the bus
inPointer to buffer to store the data from the bus
nThe number of bytes to transmit/receive
Returns
The number of bytes.

Definition at line 258 of file spi.h.


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