EasyManuals Logo

ST STM32F31xx User Manual

ST STM32F31xx
584 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #407 background imageLoading...
Page #407 background image
UM1581
Serial peripheral interface (SPI)
DocID023800 Rev 1
407/584
1. Configure SPIx in I2S mode (I2S_Init() function) as described above.
2. Call the I2S_FullDuplexConfig() function using the same strucutre passed to I2S_Init()
function.
3. Call I2S_Cmd() for SPIx then for its extended block.
4. Configure interrupts or DMA requests and to get/clear flag status, use I2Sxext
instance for the extension block.
Functions that can be called with I2Sxext instances are: I2S_Cmd(),
I2S_FullDuplexConfig(), SPI_I2S_ReceiveData16(), SPI_I2S_SendData16(),
SPI_I2S_DMACmd(), SPI_I2S_ITConfig(), SPI_I2S_GetFlagStatus(), SPI_I2S_ClearFlag(),
SPI_I2S_GetITStatus() and SPI_I2S_ClearITPendingBit().
Example: To use SPI3 in Full duplex mode (SPI3 is Master Tx, I2S3ext is Slave Rx):
RCC_APB1PeriphClockCmd(RCC_APB1Periph_SPI3, ENABLE);
I2S_StructInit(&I2SInitStruct); I2SInitStruct.Mode = I2S_Mode_MasterTx; I2S_Init(SPI3,
&I2SInitStruct); I2S_FullDuplexConfig(SPI3ext, &I2SInitStruct) I2S_Cmd(SPI3, ENABLE);
I2S_Cmd(SPI3ext, ENABLE); ... while (SPI_I2S_GetFlagStatus(SPI2, SPI_FLAG_TXE) ==
RESET) {} SPI_I2S_SendData16(SPI3, txdata[i]); ... while
(SPI_I2S_GetFlagStatus(I2S3ext, SPI_FLAG_RXNE) == RESET) {} rxdata[i] =
SPI_I2S_ReceiveData16(I2S3ext); ...
In SPI mode: To use the SPI TI mode, call the function SPI_TIModeCmd() just
after calling the function SPI_Init().
20.2.2 Initialization and Configuration functions
This section provides a set of functions allowing to initialize the SPI Direction, SPI Mode,
SPI Data Size, SPI Polarity, SPI Phase, SPI NSS Management, SPI Baud Rate Prescaler,
SPI First Bit and SPI CRC Polynomial.
The SPI_Init() function follows the SPI configuration procedures for Master mode and
Slave mode (details for these procedures are available in reference manual).
When the Software NSS management (SPI_InitStruct->SPI_NSS = SPI_NSS_Soft) is
selected, use the following function to manage the NSS bit: void
SPI_NSSInternalSoftwareConfig(SPI_TypeDef* SPIx, uint16_t SPI_NSSInternalSoft);
In Master mode, when the Hardware NSS management (SPI_InitStruct->SPI_NSS =
SPI_NSS_Hard) is selected, use the follwoing function to enable the NSS output feature.
void SPI_SSOutputCmd(SPI_TypeDef* SPIx, FunctionalState NewState);
The NSS pulse mode can be managed by the SPI TI mode when enabling it using the
following function: void SPI_TIModeCmd(SPI_TypeDef* SPIx, FunctionalState NewState);
And it can be managed by software in the SPI Motorola mode using this function: void
SPI_NSSPulseModeCmd(SPI_TypeDef* SPIx, FunctionalState NewState);
This section provides also functions to initialize the I2S Mode, Standard, Data Format,
MCLK Output, Audio frequency and Polarity.
The I2S_Init() function follows the I2S configuration procedures for Master mode and
Slave mode.
ï‚· SPI_I2S_DeInit()
ï‚· SPI_StructInit()
ï‚· SPI_Init()

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the ST STM32F31xx and is the answer not in the manual?

ST STM32F31xx Specifications

General IconGeneral
BrandST
ModelSTM32F31xx
CategoryMicrocontrollers
LanguageEnglish

Related product manuals