Base template class for the SPI/I2S configuration.
More...
#include </home/travis/build/forGGe/theCore/platform/stm32/export/aux/spi_i2s_bus.hpp>
template<spi_device dev>
struct ecl::spi_i2s_cfg< dev >
Base template class for the SPI/I2S configuration.
In order to advertise configuration parameters user must create template specialization for required SPI/I2S device. Since STM32 devices support either the SPI protocol or the I2S audio protocol there are two sets of parameters:
- common parameters for I2S and SPI modes
- special parameters for concrete mode. An example is given below parameter specification. Refer to it to get general idea how to configure SPI/I2S bus.
Common parameters:
- ecl::spi_bus_type bus_type - Defines which bus mode is required, SPI or I2S.
- See also
- ecl::spi_bus_type
- dma_tx alias - Specifies DMA TX wrapper. Refer to the implementation for the particular STM32 family to get insight how to properly define it.
- dma_rx alias - Specifies DMA RX wrapper. Refer to the implementation for the particular STM32 family to get insight how to properly define it.
I2S-specific parameters:
- I2S_InitTypeDef init_obj - Configuraion structure required for I2S mode. Refer to STM32 SPL documentation or check examples below to find I2S_InitTypeDef's fields.
SPI-specific parameters:
- SPI_InitTypeDef init_obj - Configuration structure required for SPI mode. Refer to STM32 SPL documentation or check examples below to find I2S_InitTypeDef's fields.
- SPI configuration example for STM32F4XX.
- In order to use this configuration class one must create configuration class in the
ecl
namespace before any acccess to spi_i2s_bus instance. {
template<>
{
static constexpr SPI_InitTypeDef init_obj = {
.SPI_Direction = SPI_Direction_2Lines_FullDuplex,
.SPI_Mode = SPI_Mode_Master,
.SPI_DataSize = SPI_DataSize_8b,
.SPI_CPOL = SPI_CPOL_High,
.SPI_CPHA = SPI_CPHA_2Edge,
.SPI_NSS = SPI_NSS_Soft,
.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4,
.SPI_FirstBit = SPI_FirstBit_MSB,
.SPI_CRCPolynomial = 7,
};
};
}
- I2S configuration example.
- In order to use this configuration class one must create configuration class in the
ecl
namespace before any acccess to spi_i2s_bus instance. {
template<>
{
static constexpr I2S_InitTypeDef init_obj = {
.I2S_Mode = I2S_Mode_MasterTx,
.I2S_Standard = I2S_Standard_Phillips,
.I2S_DataFormat = I2S_DataFormat_16b,
.I2S_MCLKOutput = I2S_MCLKOutput_Enable,
.I2S_AudioFreq = I2S_AudioFreq_44k,
.I2S_CPOL = I2S_CPOL_High,
};
};
}
- Warning
- To avoid potential problems with multiple configurations for single SPI/I2S bus, make sure that full specialization is placed in the header included (directly or indirectly) by all dependent modules.. Thus, redefinition of the config class for given SPI will result in compilation errors. Good practice is to place all SPI configuration class in the single target-related header.
The documentation for this struct was generated from the following file: