Serial peripheral interface (SPI)
1. SPI_I2S_FLAG_TXE : to indicate the status of the transmit buffer register.
2. SPI_I2S_FLAG_RXNE : to indicate the status of the receive buffer register.
3. SPI_I2S_FLAG_BSY : to indicate the state of the communication layer of the SPI.
4. SPI_FLAG_CRCERR : to indicate if a CRC Calculation error occur.
5. SPI_FLAG_MODF : to indicate if a Mode Fault error occur.
6. SPI_I2S_FLAG_OVR : to indicate if an Overrun error occur.
7. SPI_I2S_FLAG_FRE: to indicate a Frame Format error occurs.
8. I2S_FLAG_UDR: to indicate an Underrun error occurs.
9. I2S_FLAG_CHSIDE: to indicate Channel Side.
Do not use the BSY flag to handle each data transmission or reception. It is
better to use the TXE and RXNE flags instead.
In this Mode it is advised to use the following functions:
ï‚· FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
ï‚· void SPI_I2S_ClearFlag(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG);
Interrupt Mode
In Interrupt Mode, the SPI/I2S communication can be managed by 3 interrupt sources and
5 pending bits:
Pending Bits:
1. SPI_I2S_IT_TXE : to indicate the status of the transmit buffer register.
2. SPI_I2S_IT_RXNE : to indicate the status of the receive buffer register.
3. SPI_I2S_IT_OVR : to indicate if an Overrun error occur.
4. I2S_IT_UDR : to indicate an Underrun Error occurs.
5. SPI_I2S_FLAG_FRE : to indicate a Frame Format error occurs.
Interrupt Source:
1. SPI_I2S_IT_TXE: specifies the interrupt source for the Tx buffer empty interrupt.
2. SPI_I2S_IT_RXNE : specifies the interrupt source for the Rx buffer not empty
interrupt.
3. SPI_I2S_IT_ERR : specifies the interrupt source for the errors interrupt.
In this Mode it is advised to use the following functions:
ï‚· void SPI_I2S_ITConfig(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT, FunctionalState
NewState);
ï‚· ITStatus SPI_I2S_GetITStatus(SPI_TypeDef* SPIx, uint8_t SPI_I2S_IT);
FIFO Status
It is possible to monitor the FIFO status when a transfer is ongoing using the following
function:
ï‚· uint32_t SPI_GetFIFOStatus(uint8_t SPI_FIFO_Direction);
DMA Mode
In DMA Mode, the SPI communication can be managed by 2 DMA Channel requests:
1. SPI_I2S_DMAReq_Tx: specifies the Tx buffer DMA transfer request.
2. SPI_I2S_DMAReq_Rx: specifies the Rx buffer DMA transfer request.
In this Mode it is advised to use the following function: