theCore C++ embedded framework
Collaboration diagram for I2S and SPI driver:

Data Structures

struct  ecl::spi_i2s_cfg< dev >
 Base template class for the SPI/I2S configuration. More...
 
class  ecl::spi_i2s_bus< dev >
 Driver implementation for SPI and I2S. More...
 

Enumerations

enum  ecl::spi_bus_type { ecl::spi_bus_type::spi, ecl::spi_bus_type::i2s }
 Defines type of the bus. More...
 

Functions

static ecl::err ecl::spi_i2s_bus< dev >::init ()
 Lazy initialization. More...
 
static void ecl::spi_i2s_bus< dev >::set_rx (uint8_t *rx, size_t size)
 Sets rx buffer with given size. More...
 
static void ecl::spi_i2s_bus< dev >::set_tx (size_t size, uint8_t fill_byte=0xff)
 Sets tx buffer made-up from sequence of similar bytes. More...
 
static void ecl::spi_i2s_bus< dev >::set_tx (const uint8_t *tx, size_t size)
 Sets tx buffer with given size. More...
 
static void ecl::spi_i2s_bus< dev >::set_handler (const handler_fn &handler)
 Sets event handler. More...
 
static void ecl::spi_i2s_bus< dev >::reset_buffers ()
 Reset xfer buffers. More...
 
static void ecl::spi_i2s_bus< dev >::reset_handler ()
 Resets previously set handler. More...
 
static ecl::err ecl::spi_i2s_bus< dev >::do_xfer ()
 Executes xfer, using buffers previously set. More...
 
template<ecl::i2s::audio_frequency frequency, class Iface_cfg = config>
static std::enable_if_t< Iface_cfg::bus_type==spi_bus_type::i2s, ecl::errecl::spi_i2s_bus< dev >::i2s_set_audio_frequency ()
 Sets audio frequency for I2S mode. More...
 
template<ecl::i2s::data_format format, class Iface_cfg = config>
static std::enable_if_t< Iface_cfg::bus_type==spi_bus_type::i2s, ecl::errecl::spi_i2s_bus< dev >::i2s_set_data_format ()
 Sets data format for I2S mode. More...
 
static void ecl::spi_i2s_bus< dev >::enable_circular_mode ()
 Enables circular mode for the bus. More...
 
static void ecl::spi_i2s_bus< dev >::disable_circular_mode ()
 Disables circular mode for the bus. More...
 
static bool ecl::spi_i2s_bus< dev >::is_circular_mode ()
 Returns the circular mode state. More...
 

Detailed Description

Enumeration Type Documentation

◆ spi_bus_type

enum ecl::spi_bus_type
strong

Defines type of the bus.

Enumerator
spi 
i2s 

Function Documentation

◆ init()

template<spi_device dev>
ecl::err ecl::spi_i2s_bus< dev >::init ( )
static

Lazy initialization.

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

◆ set_rx()

template<spi_device dev>
void ecl::spi_i2s_bus< dev >::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_device dev>
void ecl::spi_i2s_bus< dev >::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_device dev>
void ecl::spi_i2s_bus< dev >::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_device dev>
void ecl::spi_i2s_bus< dev >::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_device dev>
void ecl::spi_i2s_bus< dev >::reset_buffers ( )
static

Reset xfer buffers.

Buffers that were set by

See also
set_tx() and
set_rx() will be no longer used after this call.

◆ reset_handler()

template<spi_device dev>
void ecl::spi_i2s_bus< dev >::reset_handler ( )
static

Resets previously set handler.

◆ do_xfer()

template<spi_device dev>
ecl::err ecl::spi_i2s_bus< dev >::do_xfer ( )
static

Executes xfer, using buffers previously set.

When it will be done, handler will be invoked.

Returns
Status of operation.

◆ i2s_set_audio_frequency()

template<spi_device dev>
template<ecl::i2s::audio_frequency frequency, class Iface_cfg >
std::enable_if_t< Iface_cfg::bus_type==spi_bus_type::i2s, ecl::err > ecl::spi_i2s_bus< dev >::i2s_set_audio_frequency ( )
static

Sets audio frequency for I2S mode.

Is not used in SPI mode.

Template Parameters
frequencyCan be a type of ecl::i2s::audio_frequency
Iface_cfgUsed for correct enable_if mechanism. Must not be passed by user.
Returns
Status of operation.

◆ i2s_set_data_format()

template<spi_device dev>
template<ecl::i2s::data_format format, class Iface_cfg >
std::enable_if_t< Iface_cfg::bus_type==spi_bus_type::i2s, ecl::err > ecl::spi_i2s_bus< dev >::i2s_set_data_format ( )
static

Sets data format for I2S mode.

Is not used in SPI mode.

Template Parameters
formatCan be a type of ecl::i2s::data_format
Iface_cfgUsed for correct enable_if mechanism. Must not be passed by user.
Returns
Status of operation.

◆ enable_circular_mode()

template<spi_device dev>
void ecl::spi_i2s_bus< dev >::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_device dev>
void ecl::spi_i2s_bus< dev >::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_device dev>
bool ecl::spi_i2s_bus< dev >::is_circular_mode ( )
static

Returns the circular mode state.

Returns
true if circular mode is enabled, false otherwise