Serial peripheral interface (SPI)
ï‚· I2S_StructInit()
ï‚· I2S_Init()
ï‚· SPI_Cmd()
ï‚· SPI_TIModeCmd()
ï‚· I2S_Cmd()
ï‚· SPI_DataSizeConfig()
ï‚· SPI_RxFIFOThresholdConfig()
ï‚· SPI_BiDirectionalLineConfig()
ï‚· SPI_NSSInternalSoftwareConfig()
ï‚· I2S_FullDuplexConfig()
ï‚· SPI_SSOutputCmd()
ï‚· SPI_NSSPulseModeCmd()
20.2.3 Data transfers functions
This section provides a set of functions allowing to manage the SPI or I2S data transfers.
In reception, data are received and then stored into an internal Rx buffer while In
transmission, data are first stored into an internal Tx buffer before being transmitted.
The read access of the SPI_DR register can be done using the SPI_I2S_ReceiveData()
function and returns the Rx buffered value. Whereas a write access to the SPI_DR can be
done using SPI_I2S_SendData() function and stores the written data into Tx buffer.
ï‚· SPI_SendData8()
ï‚· SPI_I2S_SendData16()
ï‚· SPI_ReceiveData8()
ï‚· SPI_I2S_ReceiveData16()
20.2.4 Hardware CRC Calculation functions
This section provides a set of functions allowing to manage the SPI CRC hardware
calculation.
SPI communication using CRC is possible through the following procedure:
1. Program the Data direction, Polarity, Phase, First Data, Baud Rate Prescaler, Slave
Management, Peripheral Mode and CRC Polynomial values using the SPI_Init()
function.
2. Enable the CRC calculation using the SPI_CalculateCRC() function.
3. Enable the SPI using the SPI_Cmd() function
4. Before writing the last data to the TX buffer, set the CRCNext bit using the
SPI_TransmitCRC() function to indicate that after transmission of the last data, the
CRC should be transmitted.
5. After transmitting the last data, the SPI transmits the CRC. The SPI_CR1_CRCNEXT
bit is reset. The CRC is also received and compared against the SPI_RXCRCR value.
If the value does not match, the SPI_FLAG_CRCERR flag is set and an interrupt can
be generated when the SPI_I2S_IT_ERR interrupt is enabled.
ï‚· It is advised to don't read the calculate CRC values during the
communication.
ï‚· When the SPI is in slave mode, be careful to enable CRC calculation only
when the clock is stable, that is, when the clock is in the steady state. If not,
a wrong CRC calculation may be done. In fact, the CRC is sensitive to the