uTL
micro Template library
utl::spi_i< impl_t > Class Template Reference

#include <spi.h>

Public Types

using type = spi_i< impl_t >
 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...
 

Protected Member Functions

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

Private Member Functions

 _CRTP_IMPL (impl_t)
 
Implementation requirements
Note
In order for the implementation to have the following as private members it also need to declare this class as friend
uint32_t _clock () const
 clock frequency of the bus [Hz] More...
 
void _clock (uint32_t c)
 set clock frequency of the bus [Hz] More...
 
byte_t _tx_data (byte_t b)
 

Detailed Description

template<typename impl_t>
class utl::spi_i< impl_t >

Template base class for SPI communication interface using CRTP This class force a common interface for SPI communication protocol implementations.

Parameters
impl_tThe CRTP type (the derived/implementation class typename).

Definition at line 67 of file spi.h.

Member Typedef Documentation

◆ type

template<typename impl_t>
using utl::spi_i< impl_t >::type = spi_i<impl_t>

Export type as identity meta-function.

Definition at line 71 of file spi.h.

Constructor & Destructor Documentation

◆ spi_i() [1/2]

template<typename impl_t>
utl::spi_i< impl_t >::spi_i ( )
protecteddefault

Allow constructor from derived only.

◆ ~spi_i()

template<typename impl_t>
utl::spi_i< impl_t >::~spi_i ( )
protecteddefault

Allow destructor from derived only.

◆ spi_i() [2/2]

template<typename impl_t>
utl::spi_i< impl_t >::spi_i ( const type )
protecteddelete

No copies.

Member Function Documentation

◆ _clock() [1/2]

template<typename impl_t>
uint32_t utl::spi_i< impl_t >::_clock ( ) const
inlineprivate

clock frequency of the bus [Hz]

Definition at line 92 of file spi.h.

◆ _clock() [2/2]

template<typename impl_t>
void utl::spi_i< impl_t >::_clock ( uint32_t  c)
inlineprivate

set clock frequency of the bus [Hz]

Definition at line 93 of file spi.h.

◆ _CRTP_IMPL()

template<typename impl_t>
utl::spi_i< impl_t >::_CRTP_IMPL ( impl_t  )
private

◆ _tx_data()

template<typename impl_t>
byte_t utl::spi_i< impl_t >::_tx_data ( byte_t  b)
inlineprivate

Transmit a byte on the bus and return the response

Definition at line 94 of file spi.h.

◆ clock() [1/2]

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

Definition at line 102 of file spi.h.

◆ clock() [2/2]

template<typename impl_t>
void utl::spi_i< impl_t >::clock ( uint32_t  c)
inline

set clock frequency of the bus

Definition at line 103 of file spi.h.

◆ operator=()

template<typename impl_t>
type& utl::spi_i< impl_t >::operator= ( const type )
protecteddelete

◆ rx_data() [1/2]

template<typename impl_t>
byte_t utl::spi_i< impl_t >::rx_data ( )
inline

Receive a byte from spi bus while transmitting 0xFF

Definition at line 129 of file spi.h.

◆ rx_data() [2/2]

template<typename _I >
size_t utl::spi_i< _I >::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 165 of file spi.h.

◆ tx_data() [1/2]

template<typename impl_t>
byte_t utl::spi_i< impl_t >::tx_data ( byte_t  out)
inline

Transmit a byte to spi bus and return the response

Definition at line 114 of file spi.h.

◆ tx_data() [2/2]

template<typename _I >
size_t utl::spi_i< _I >::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 152 of file spi.h.


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