theCore C++ embedded framework
Collaboration diagram for Skeleton of SPI driver:

Data Structures

struct  ecl::skel::spi_cfg< ch >
 Base template class for the SPI configuration. More...
 
class  ecl::skel::spi< ch >
 Driver implementation for SPI. More...
 

Enumerations

enum  ecl::skel::spi_channel { ecl::skel::spi_channel::ch1, ecl::skel::spi_channel::ch2, ecl::skel::spi_channel::ch3 }
 List of avaliable SPI channels. More...
 
enum  ecl::skel::spi_type { ecl::skel::spi_type::master }
 SPI master/slave selection. More...
 
enum  ecl::skel::spi_cpol { ecl::skel::spi_cpol::low, ecl::skel::spi_cpol::high }
 SPI clock polarity. More...
 
enum  ecl::skel::spi_cpha { ecl::skel::spi_cpha::low, ecl::skel::spi_cpha::high }
 SPI clock phase. More...
 

Functions

static ecl::err ecl::skel::spi< ch >::init ()
 Lazy initialization. More...
 
static void ecl::skel::spi< ch >::set_rx (uint8_t *rx, size_t size)
 Sets rx buffer with given size. More...
 
static void ecl::skel::spi< ch >::set_tx (size_t size, uint8_t fill_byte=0xff)
 Sets tx buffer made-up from sequence of similar bytes. More...
 
static void ecl::skel::spi< ch >::set_tx (const uint8_t *tx, size_t size)
 Sets tx buffer with given size. More...
 
static void ecl::skel::spi< ch >::set_handler (const handler_fn &handler)
 Sets event handler. More...
 
static void ecl::skel::spi< ch >::reset_buffers ()
 Reset xfer buffers. More...
 
static void ecl::skel::spi< ch >::reset_handler ()
 Resets previously set handler. More...
 
static ecl::err ecl::skel::spi< ch >::do_xfer ()
 Executes xfer, using buffers previously set. More...
 
static void ecl::skel::spi< ch >::enable_circular_mode ()
 Enables circular mode for the bus. More...
 
static void ecl::skel::spi< ch >::disable_circular_mode ()
 Disables circular mode for the bus. More...
 
static bool ecl::skel::spi< ch >::is_circular_mode ()
 Returns the circular mode state. More...
 
static void ecl::skel::spi< ch >::irq_handler ()
 SPI interrupt handler. More...
 

Detailed Description

Enumeration Type Documentation

◆ spi_channel

List of avaliable SPI channels.

Enumerator
ch1 
ch2 
ch3 

◆ spi_type

enum ecl::skel::spi_type
strong

SPI master/slave selection.

Enumerator
master 

◆ spi_cpol

enum ecl::skel::spi_cpol
strong

SPI clock polarity.

Enumerator
low 
high 

CPOL = 0.

◆ spi_cpha

enum ecl::skel::spi_cpha
strong

SPI clock phase.

Enumerator
low 
high 

CPHA = 0.

Function Documentation

◆ init()

template<spi_channel ch>
ecl::err ecl::skel::spi< ch >::init ( )
static

Lazy initialization.

Returns
Status of operation.
Here is the call graph for this function:

◆ set_rx()

template<spi_channel ch>
void ecl::skel::spi< ch >::set_rx ( uint8_t *  rx,
size_t  size 
)
static

Sets rx buffer with given size.

Parameters
[in,out]rxBuffer to write data to. Optional.
[in]sizeSize

◆ set_tx() [1/2]

template<spi_channel ch>
void ecl::skel::spi< ch >::set_tx ( size_t  size,
uint8_t  fill_byte = 0xff 
)
static

Sets tx buffer made-up from sequence of similar bytes.

Parameters
[in]sizeSize of sequence
[in]fill_byteByte to fill a sequence. Optional.

◆ set_tx() [2/2]

template<spi_channel ch>
void ecl::skel::spi< ch >::set_tx ( const uint8_t *  tx,
size_t  size 
)
static

Sets tx buffer with given size.

Parameters
[in]txBuffer to transmit. Optional.
[in]sizeBuffer size.

◆ set_handler()

template<spi_channel ch>
void ecl::skel::spi< ch >::set_handler ( const handler_fn handler)
static

Sets event handler.

Handler will be used by the bus, until reset_handler() will be called.

Parameters
[in]handlerHandler itself.

◆ reset_buffers()

template<spi_channel ch>
void ecl::skel::spi< ch >::reset_buffers ( )
static

Reset xfer buffers.

Buffers that were set by set_tx() and set_rx() will be no longer used after this call.

◆ reset_handler()

template<spi_channel ch>
void ecl::skel::spi< ch >::reset_handler ( )
static

Resets previously set handler.

◆ do_xfer()

template<spi_channel ch>
ecl::err ecl::skel::spi< ch >::do_xfer ( )
static

Executes xfer, using buffers previously set.

When xfer is done, handler will be invoked.

Returns
Status of operation.

◆ enable_circular_mode()

template<spi_channel ch>
void ecl::skel::spi< ch >::enable_circular_mode ( )
static

Enables circular mode for the bus.

In circular mode when xfer is finished, the new xfer is started automatically without interruption. The same buffer is used. The process continues until circular mode is disabled. This method must not be called during xfer().

◆ disable_circular_mode()

template<spi_channel ch>
void ecl::skel::spi< ch >::disable_circular_mode ( )
static

Disables circular mode for the bus.

This method allows to stop xfer() that was started with circular mode. It is recommended to call this method in event handler during processing of the HT or TC event. The xfer is always stopped after TC. If circular mode is disabled during processing of the TC (or between HT and TC), the xfer will be stopped immediately after current TC will be processed. If circular mode is disabled during processing of the HT (or between TC and HT), the xfer will be finished after next TC will be processed. This method also can be called when xfer() is not active.

◆ is_circular_mode()

template<spi_channel ch>
bool ecl::skel::spi< ch >::is_circular_mode ( )
static

Returns the circular mode state.

Returns
true if circular mode is enabled, false otherwise

◆ irq_handler()

template<spi_channel ch>
void ecl::skel::spi< ch >::irq_handler ( )
staticprotected

SPI interrupt handler.

Receives interrupt from IRQ subsystem.