utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder > Class Template Reference

A bit banking implementation of spi bus inherited from spi_i base class. More...

`#include <spi_bb.h>`

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

## Public Types

using | type = spi_bb_i< impl_t, CPOL, CPHA, BitOrder >
| Export type as identity meta-function. More...
Public Types inherited from utl::spi_i< spi_bb_i< impl_t, CPOL, CPHA, BitOrder > >
using | type = spi_i< spi_bb_i< impl_t, CPOL, CPHA, BitOrder > >
| Export type as identity meta-function. More...

## Protected Member Functions

Object lifetime
| ~spi_bb_i ()=default
| spi_bb_i (uint32_t clk) noexcept
| A default constructor. More...
Protected Member Functions inherited from utl::spi_i< spi_bb_i< impl_t, CPOL, CPHA, BitOrder > >
| spi_i ()=default
| Allow constructor from derived only. More...
| spi_i (const type &)=delete
| No copies. More...
| ~spi_i ()=default
| Allow destructor from derived only. More...
type & | operator= (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

void | MOSI (bool st)
| Implementers's MOSI pin function. More...
bool | MISO ()
| Implementers's MISO pin function. More...
void | SCLK (bool st)
| Implementers's SCLK pin function. More...
void | delay (uint32_t nsec)
Implementation of base requirements
uint32_t | _clock () const
void | _clock (uint32_t c)
byte_t | _tx_data (byte_t out)
template<spi::cpha C = CPHA>
meta::enable_if_t<(C==spi::cpha::LOW), byte_t > | _tx_data_impl (byte_t out)
| _tx_data implementation for CPHA == LOW Out at preceding clock trailing edge, In at leading clock edge More...
template<spi::cpha C = CPHA>
meta::enable_if_t<(C==spi::cpha::HIGH), byte_t > | _tx_data_impl (byte_t out)
| _tx_data implementation CPHA == HIGH Out at leading clock edge, In at trailing clock edge More...

## Private Attributes

friend | spi_i< spi_bb_i< impl_t, CPOL, CPHA, BitOrder > >
| Syntactic sugar to CRTP casting. More...
uint32_t | nsec_

## SPI implementation specific functions

static constexpr bool | clkH_ {clkHigh()}
static constexpr bool | clkL_ {clkLow()}
template<spi::bitOrder B = BitOrder>
constexpr meta::enable_if_t<(B==spi::bitOrder::LSB_First), void > | shift (byte_t &b)
template<spi::bitOrder B = BitOrder>
constexpr meta::enable_if_t<(B==spi::bitOrder::MSB_First), void > | shift (byte_t &b)
template<spi::cpol C = CPOL>
static constexpr bool | clkHigh ()
template<spi::cpol C = CPOL>
static constexpr bool | clkLow ()

## Additional Inherited Members

Public Member Functions inherited from utl::spi_i< spi_bb_i< impl_t, CPOL, CPHA, BitOrder > >
uint32_t | clock () const
void | clock (uint32_t c)
| set clock frequency of the bus More...
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...

## Detailed Description

### template<typename impl_t, spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>
class utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >

A bit banking implementation of spi bus inherited from spi_i base class.

See also
  spi_i

SPI bit banking interface template class using CRTP. Using the private interface we provide the interface from spi_i<impl_t>

Parameters

  impl_t | The CRTP type (the derived/implementation class typename).
  CPOL | Clock polarity
  CPHA | Clock phase
  BitOrder | Data transfer bit order

Definition at line 56 of file spi_bb.h.

## Member Typedef Documentation

## type

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

using utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::type = spi_bb_i<impl_t, CPOL, CPHA, BitOrder>

Export type as identity meta-function.

Definition at line 60 of file spi_bb.h.

## Constructor & Destructor Documentation

## ~spi_bb_i()

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::~spi_bb_i | ( |  | ) |

protecteddefault

A default destructor, allow destructor from derived only

## spi_bb_i()

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::spi_bb_i | ( | uint32_t | clk | ) |

inlineprotectednoexcept

A default constructor.

Definition at line 69 of file spi_bb.h.

## Member Function Documentation

## _clock() [1/2]

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

uint32_t utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::_clock | ( |  | ) | const

inlineprivate

Definition at line 111 of file spi_bb.h.

## _clock() [2/2]

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

void utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::_clock | ( | uint32_t | c | ) |

inlineprivate

Definition at line 112 of file spi_bb.h.

## _CRTP_IMPL()

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::_CRTP_IMPL | ( | impl_t |  | ) |

private

## _tx_data()

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

byte_t utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::_tx_data | ( | byte_t | out | ) |

inlineprivate

Definition at line 113 of file spi_bb.h.

## _tx_data_impl() [1/2]

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder>
template<spi::cpha C>

meta::enable_if_t<(C==spi::cpha::LOW), byte_t > utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::_tx_data_impl | ( | byte_t | out | ) |

private

_tx_data implementation for CPHA == LOW Out at preceding clock trailing edge, In at leading clock edge

Parameters

  out | The byte to send to SPI bus

Returns
  The byte read from the bus

Definition at line 138 of file spi_bb.h.

## _tx_data_impl() [2/2]

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder>
template<spi::cpha C>

meta::enable_if_t<(C==spi::cpha::HIGH), byte_t > utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::_tx_data_impl | ( | byte_t | out | ) |

private

_tx_data implementation CPHA == HIGH Out at leading clock edge, In at trailing clock edge

Parameters

  out | The byte to send to SPI bus

Returns
  The byte read from the bus

Definition at line 162 of file spi_bb.h.

## clkHigh()

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>
template<spi::cpol C = CPOL>

static constexpr bool utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::clkHigh | ( |  | ) |

inlinestaticprivate

Definition at line 81 of file spi_bb.h.

## clkLow()

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>
template<spi::cpol C = CPOL>

static constexpr bool utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::clkLow | ( |  | ) |

inlinestaticprivate

Definition at line 84 of file spi_bb.h.

## delay()

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

void utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::delay | ( | uint32_t | nsec | ) |

inlineprivate

Implementers's half period delay function

Definition at line 102 of file spi_bb.h.

## MISO()

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

bool utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::MISO | ( |  | ) |

inlineprivate

Implementers's MISO pin function.

Definition at line 100 of file spi_bb.h.

## MOSI()

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

void utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::MOSI | ( | bool | st | ) |

inlineprivate

Implementers's MOSI pin function.

Definition at line 99 of file spi_bb.h.

## SCLK()

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

void utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::SCLK | ( | bool | st | ) |

inlineprivate

Implementers's SCLK pin function.

Definition at line 101 of file spi_bb.h.

## shift() [1/2]

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>
template<spi::bitOrder B = BitOrder>

constexpr meta::enable_if_t<(B == spi::bitOrder::LSB_First), void> utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::shift | ( | byte_t & | b | ) |

inlineprivate

Definition at line 78 of file spi_bb.h.

## shift() [2/2]

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>
template<spi::bitOrder B = BitOrder>

constexpr meta::enable_if_t<(B == spi::bitOrder::MSB_First), void> utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::shift | ( | byte_t & | b | ) |

inlineprivate

Definition at line 80 of file spi_bb.h.

## Member Data Documentation

## clkH_

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

constexpr bool utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::clkH_ {clkHigh()}

staticprivate

Definition at line 87 of file spi_bb.h.

## clkL_

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

constexpr bool utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::clkL_ {clkLow()}

staticprivate

Definition at line 88 of file spi_bb.h.

## nsec_

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

uint32_t utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::nsec_

private

Data membershalf period of SPI bus

Definition at line 124 of file spi_bb.h.

## spi_i< spi_bb_i< impl_t, CPOL, CPHA, BitOrder > >

template<typename impl_t , spi::cpol CPOL, spi::cpha CPHA, spi::bitOrder BitOrder = spi::bitOrder::MSB_First>

friend utl::spi_bb_i< impl_t, CPOL, CPHA, BitOrder >::spi_i< spi_bb_i< impl_t, CPOL, CPHA, BitOrder > >

private

Syntactic sugar to CRTP casting.

Definition at line 58 of file spi_bb.h.

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

- include/utl/com/spi_bb.h