Download Standard Peripheral Library

Transcript
Serial peripheral interface (SPI)
Interrupt Mode
UM1061
In Interrupt Mode, the SPI communication can be managed by 3 interrupt sources and 7
pending bits:



Pending Bits:

SPI_I2S_IT_TXE : to indicate the status of the transmit buffer register

SPI_I2S_IT_RXNE : to indicate the status of the receive buffer register

SPI_IT_CRCERR : to indicate if a CRC Calculation error occur (available in SPI
mode only)

SPI_IT_MODF : to indicate if a Mode Fault error occur (available in SPI mode
only)

SPI_I2S_IT_OVR : to indicate if an Overrun error occur

I2S_IT_UDR : to indicate an Underrun Error occurs (available in I2S mode only).

I2S_FLAG_TIFRFE : to indicate a Frame Format error occurs (available in TI
mode only).
Interrupt Source:

SPI_I2S_IT_TXE: specifies the interrupt source for the Tx buffer empty interrupt.

SPI_I2S_IT_RXNE : specifies the interrupt source for the Rx buffer not empty
interrupt.

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);

void SPI_I2S_ClearITPendingBit(SPI_TypeDef SPIx, uint8_t SPI_I2S_IT);
DMA Mode In DMA Mode, the SPI communication can be managed by 2 DMA
Channel requests:

SPI_I2S_DMAReq_Tx: specifies the Tx buffer DMA transfer request

SPI_I2S_DMAReq_Rx: specifies the Rx buffer DMA transfer request In this Mode
it is advised to use the following function:

void SPI_I2S_DMACmd(SPI_TypeDef SPIx, uint16_t SPI_I2S_DMAReq,
FunctionalState NewState);
The following functions can be used to manage the SPI flags and interrupts:





SPI_I2S_ITConfig()
SPI_I2S_GetFlagStatus()
SPI_I2S_ClearFlag()
SPI_I2S_GetITStatus()
SPI_I2S_ClearITPendingBit()
23.2.7
Initialization and configuration functions
23.2.7.1
SPI_I2S_DeInit
488/634
Function Name
void SPI_I2S_DeInit ( SPI_TypeDef * SPIx)
Function Description
Deinitialize the SPIx peripheral registers to their default reset
values.
Parameters

SPIx : To select the SPIx/I2Sx peripheral, where x can be: 1,
2 or 3 in SPI mode or 2 or 3 in I2S mode.
DocID 18540 Rev 1