WB32F10x Standard Peripherals Firmware Library

Functions
SPI_Private_Functions
WB32F10x_StdPeriph_Driver » SPI

## Functions
void | SPI_DeInit (SPI_TypeDef *SPIx)
| Deinitializes the SPIx peripheral registers to their default reset values. More...
void | SPI_Init (SPI_TypeDef *SPIx, SPI_InitTypeDef *SPI_InitStruct)
| Initializes the SPIx peripheral according to the specified parameters in the SPI_InitStruct. More...
void | SPI_StructInit (SPI_InitTypeDef *SPI_InitStruct)
| Fills each SPI_InitStruct member with its default value. More...
void | SPI_Cmd (SPI_TypeDef *SPIx, FunctionalState NewState)
| Enables or disables the specified SPI peripheral. More...
void | SPI_TransferModeConfig (SPI_TypeDef *SPIx, uint16_t SPI_TransferMode)
| Configures the transfer mode. More...
void | SPI_SlaveOutputCmd (SPI_TypeDef *SPIx, FunctionalState NewState)
| Enables or disables the slave output (only used for SPISx). More...
void | SPI_NSSConfig (SPI_TypeDef *SPIx, uint32_t SPI_NSS, FunctionalState NewState)
| Enables or disables the specified slave select line (only used for SPIMx). More...
void | SPI_NSSToggleModeCmd (SPI_TypeDef *SPIx, FunctionalState NewState)
| Enables or disables the slave select toggle mode. More...
void | SPI_ReceiveDataLengthConfig (SPI_TypeDef *SPIx, uint32_t DataLength)
| Configures the number of data frames to be continuously received (only used for SPIMx). More...
void | SPI_MicrowireConfig (SPI_TypeDef *SPIx, SPI_MicrowireInitTypeDef *SPI_MicrowireInitStruct)
| Configures the Microwire frame format according to the specified parameters in the SPI_MicrowireInitStruct. More...
void | SPI_MicrowireStructInit (SPI_MicrowireInitTypeDef *SPI_MicrowireInitStruct)
| Fills each SPI_MicrowireInitStruct member with its default value. More...
void | SPI_SpiModeConfig (SPI_TypeDef *SPIx, uint32_t SPI_SpiMode)
| Configures the Spi Mode. More...
void | SPI_EnhancedSpiConfig (SPI_TypeDef *SPIx, SPI_EnhancedSpiInitTypeDef *SPI_EnhancedSpiInitStruct)
| Configures the Enhanced SPI Mode according to the specified parameters in the SPI_EnhancedSpiInitStruct (only used for QSPI). More...
void | SPI_EnhancedSpiStructInit (SPI_EnhancedSpiInitTypeDef *SPI_EnhancedSpiInitStruct)
| Fills each SPI_EnhancedSpiInitStruct member with its default value. More...
uint16_t | SPI_ReadData (SPI_TypeDef *SPIx)
| Read one data from Rx FIFO. More...
void | SPI_WriteData (SPI_TypeDef *SPIx, uint16_t Data)
| Write one data to Tx FIFO. More...
FlagStatus | SPI_GetFlagStatus (SPI_TypeDef *SPIx, uint8_t SPI_FLAG)
| Checks whether the specified SPIx flag is set or not. More...
void | SPI_ITConfig (SPI_TypeDef *SPIx, uint8_t SPI_IT, FunctionalState NewState)
| Enables or disables the specified SPI interrupts. More...
ITStatus | SPI_GetRawITStatus (SPI_TypeDef *SPIx, uint8_t SPI_IT)
| Checks whether the specified SPIx raw interrupt status. More...
ITStatus | SPI_GetITStatus (SPI_TypeDef *SPIx, uint8_t SPI_IT)
| Checks whether the specified SPIx interrupt has occurred or not. More...
void | SPI_ClearITPendingBit (SPI_TypeDef *SPIx, uint8_t SPI_IT)
| Clears the SPIx's interrupt pending bits. More...
void | SPI_RxFIFOThresholdConfig (SPI_TypeDef *SPIx, uint8_t Threshold)
| Configures the Rx FIFO threshold. More...
void | SPI_TxFIFOThresholdConfig (SPI_TypeDef *SPIx, uint8_t Threshold)
| Configures the Tx FIFO threshold. More...
uint8_t | SPI_GetRxFIFOLevel (SPI_TypeDef *SPIx)
| Returns the number of data can be read from Rx FIFO. More...
uint8_t | SPI_GetTxFIFOLevel (SPI_TypeDef *SPIx)
| Returns the number of data left in Tx FIFO. More...
void | SPI_DMARxReqLevelConfig (SPI_TypeDef *SPIx, uint8_t DMARxReqLevel)
| Configures the DMA Rx request level. More...
void | SPI_DMATxReqLevelConfig (SPI_TypeDef *SPIx, uint8_t DMATxReqLevel)
| Configures the DMA Tx request level. More...
void | SPI_DMACmd (SPI_TypeDef *SPIx, uint32_t SPI_DMAReq, FunctionalState NewState)
| Enables or disables the SPIx's DMA interface. More...
void | SPI_RxdSampleDelayConfig (SPI_TypeDef *SPIx, uint8_t DelayValue)
| Configures the rxd sample delay value. More...

## Detailed Description

## Function Documentation

## ◆ SPI_ClearITPendingBit()

void SPI_ClearITPendingBit | ( | SPI_TypeDef * | SPIx,
|  | uint8_t | SPI_IT
| ) |  |

Clears the SPIx's interrupt pending bits.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  SPI_IT | specifies the interrupt pending bit to clear. This parameter can be a combination of the following values: SPI_IT_TXO: Transmit FIFO overflow interrupt SPI_IT_RXU: Receive FIFO underflow interrupt SPI_IT_RXO: Receive FIFO overflow interrupt SPI_IT_MST: Multi-Master contention interrupt (Only for QSPI and SPIM2)

Returns
  None.

## ◆ SPI_Cmd()

void SPI_Cmd | ( | SPI_TypeDef * | SPIx,
|  | FunctionalState | NewState
| ) |  |

Enables or disables the specified SPI peripheral.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  NewState | new state of the SPIx peripheral. This parameter can be: ENABLE or DISABLE.

Returns
  None

## ◆ SPI_DeInit()

void SPI_DeInit | ( | SPI_TypeDef * | SPIx | ) |

Deinitializes the SPIx peripheral registers to their default reset values.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.

Returns
  None

## ◆ SPI_DMACmd()

void SPI_DMACmd | ( | SPI_TypeDef * | SPIx,
|  | uint32_t | SPI_DMAReq,
|  | FunctionalState | NewState
| ) |  |

Enables or disables the SPIx's DMA interface.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  SPI_DMAReq | specifies the DMA request. This parameter can be any combination of the following values: SPI_DMAReq_Rx: SPI DMA receive request SPI_DMAReq_Tx: SPI DMA transmit request
  NewState | new state of the DMA Request sources. This parameter can be: ENABLE or DISABLE.

Returns
  None.

## ◆ SPI_DMARxReqLevelConfig()

void SPI_DMARxReqLevelConfig | ( | SPI_TypeDef * | SPIx,
|  | uint8_t | DMARxReqLevel
| ) |  |

Configures the DMA Rx request level.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  Level | The level of the DMA Rx request to set.

Note
  The DMA Rx request will trigger when the rx fifo level > DMARxReqLevel.

Returns
  None.

## ◆ SPI_DMATxReqLevelConfig()

void SPI_DMATxReqLevelConfig | ( | SPI_TypeDef * | SPIx,
|  | uint8_t | DMATxReqLevel
| ) |  |

Configures the DMA Tx request level.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  Level | The level of the DMA Tx request to set.

Note
  The DMA Tx request will trigger when the tx fifo level <= DMATxReqLevel.

Returns
  None.

## ◆ SPI_EnhancedSpiConfig()

void SPI_EnhancedSpiConfig | ( | SPI_TypeDef * | SPIx,
|  | SPI_EnhancedSpiInitTypeDef * | SPI_EnhancedSpiInitStruct
| ) |  |

Configures the Enhanced SPI Mode according to the specified parameters in the SPI_EnhancedSpiInitStruct (only used for QSPI).

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter must be QSPI.
  SPI_EnhancedSpiInitStruct | pointer to a SPI_EnhancedSpiInitTypeDef structure that contains the configuration information for the Enhanced SPI Mode.

Returns
  None

## ◆ SPI_EnhancedSpiStructInit()

void SPI_EnhancedSpiStructInit | ( | SPI_EnhancedSpiInitTypeDef * | SPI_EnhancedSpiInitStruct | ) |

Fills each SPI_EnhancedSpiInitStruct member with its default value.

Parameters

  SPI_EnhancedSpiInitStruct | pointer to a SPI_EnhancedSpiInitTypeDef structure which will be initialized.

Returns
  None

## ◆ SPI_GetFlagStatus()

FlagStatus SPI_GetFlagStatus | ( | SPI_TypeDef * | SPIx,
|  | uint8_t | SPI_FLAG
| ) |  |

Checks whether the specified SPIx flag is set or not.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  SPI_FLAG | specifies the SPI flag to check. This parameter can be one of the following values: SPI_FLAG_BUSY: SPI busy flag. SPI_FLAG_TFNF: Transmit FIFO not full. SPI_FLAG_TFE: Transmit FIFO empty. SPI_FLAG_RFNE: Receive FIFO not empty. SPI_FLAG_RFF: Receive FIFO full. SPI_FLAG_TXERR: Transmission error (only for SPIS1 and SPIS2). SPI_FLAG_DCOL: Data collision error (only for QSPI and SPIM2).

Returns
  The new state of SPI_FLAG (SET or RESET).

## ◆ SPI_GetITStatus()

ITStatus SPI_GetITStatus | ( | SPI_TypeDef * | SPIx,
|  | uint8_t | SPI_IT
| ) |  |

Checks whether the specified SPIx interrupt has occurred or not.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  SPI_IT | specifies the SPI interrupt source to check. This parameter can be one of the following values: SPI_IT_TXE: Transmit FIFO empty interrupt SPI_IT_TXO: Transmit FIFO overflow interrupt SPI_IT_RXU: Receive FIFO underflow interrupt SPI_IT_RXO: Receive FIFO overflow interrupt SPI_IT_RXF: Receive FIFO full interrupt SPI_IT_MST: Multi-Master contention interrupt (Only for QSPI and SPIM2)

Returns
  The new state of SPI_IT (SET or RESET).

## ◆ SPI_GetRawITStatus()

ITStatus SPI_GetRawITStatus | ( | SPI_TypeDef * | SPIx,
|  | uint8_t | SPI_IT
| ) |  |

Checks whether the specified SPIx raw interrupt status.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  SPI_IT | specifies the SPI interrupt source to check. This parameter can be one of the following values: SPI_IT_TXE: Transmit FIFO empty interrupt SPI_IT_TXO: Transmit FIFO overflow interrupt SPI_IT_RXU: Receive FIFO underflow interrupt SPI_IT_RXO: Receive FIFO overflow interrupt SPI_IT_RXF: Receive FIFO full interrupt SPI_IT_MST: Multi-Master contention interrupt (only for QSPI and SPIM2)

Returns
  The new state of raw SPI_IT (SET or RESET).

## ◆ SPI_GetRxFIFOLevel()

uint8_t SPI_GetRxFIFOLevel | ( | SPI_TypeDef * | SPIx | ) |

Returns the number of data can be read from Rx FIFO.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.

Returns
  The number of data can be read from Rx FIFO.

## ◆ SPI_GetTxFIFOLevel()

uint8_t SPI_GetTxFIFOLevel | ( | SPI_TypeDef * | SPIx | ) |

Returns the number of data left in Tx FIFO.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.

Returns
  The number of data left in Tx FIFO.

## ◆ SPI_Init()

void SPI_Init | ( | SPI_TypeDef * | SPIx,
|  | SPI_InitTypeDef * | SPI_InitStruct
| ) |  |

Initializes the SPIx peripheral according to the specified parameters in the SPI_InitStruct.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  SPI_InitStruct | pointer to a SPI_InitTypeDef structure that contains the configuration information for the specified SPI peripheral.

Returns
  None

## ◆ SPI_ITConfig()

void SPI_ITConfig | ( | SPI_TypeDef * | SPIx,
|  | uint8_t | SPI_IT,
|  | FunctionalState | NewState
| ) |  |

Enables or disables the specified SPI interrupts.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  SPI_IT | specifies the SPI interrupt source to be enabled or disabled. This parameter can be a combination of the following values: SPI_IT_TXE: Transmit FIFO empty interrupt mask SPI_IT_TXO: Transmit FIFO overflow interrupt mask SPI_IT_RXU: Receive FIFO underflow interrupt mask SPI_IT_RXO: Receive FIFO overflow interrupt mask SPI_IT_RXF: Receive FIFO full interrupt mask SPI_IT_MST: Multi-Master contention interrupt mask (only for QSPI and SPIM2)
  NewState | new state of the specified SPI interrupt. This parameter can be: ENABLE or DISABLE.

Returns
  None.

## ◆ SPI_MicrowireConfig()

void SPI_MicrowireConfig | ( | SPI_TypeDef * | SPIx,
|  | SPI_MicrowireInitTypeDef * | SPI_MicrowireInitStruct
| ) |  |

Configures the Microwire frame format according to the specified parameters in the SPI_MicrowireInitStruct.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  SPI_MicrowireInitStruct | pointer to a SPI_MicrowireInitTypeDef structure that contains the configuration information for the Microwire frame format.

Returns
  None

## ◆ SPI_MicrowireStructInit()

void SPI_MicrowireStructInit | ( | SPI_MicrowireInitTypeDef * | SPI_MicrowireInitStruct | ) |

Fills each SPI_MicrowireInitStruct member with its default value.

Parameters

  SPI_MicrowireInitStruct | pointer to a SPI_MicrowireInitTypeDef structure which will be initialized.

Returns
  None

## ◆ SPI_NSSConfig()

void SPI_NSSConfig | ( | SPI_TypeDef * | SPIx,
|  | uint32_t | SPI_NSS,
|  | FunctionalState | NewState
| ) |  |

Enables or disables the specified slave select line (only used for SPIMx).

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2.
  SPI_NSS | specifies the slave select line to be enabled or disabled. This parameter can be one of the following values: SPI_NSS_0 SPI_NSS_1 SPI_NSS_2
  NewState | new state of the slave select line. This parameter can be: ENABLE or DISABLE.

Returns
  None

## ◆ SPI_NSSToggleModeCmd()

void SPI_NSSToggleModeCmd | ( | SPI_TypeDef * | SPIx,
|  | FunctionalState | NewState
| ) |  |

Enables or disables the slave select toggle mode.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  NewState | new state of the slave select toggle mode. This parameter can be: ENABLE or DISABLE.

Returns
  None

## ◆ SPI_ReadData()

uint16_t SPI_ReadData | ( | SPI_TypeDef * | SPIx | ) |

Read one data from Rx FIFO.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.

Returns
  The read data.

## ◆ SPI_ReceiveDataLengthConfig()

void SPI_ReceiveDataLengthConfig | ( | SPI_TypeDef * | SPIx,
|  | uint32_t | DataLength
| ) |  |

Configures the number of data frames to be continuously received (only used for SPIMx).

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2.
  DataLength | specifies the number of data frames to be continuously received.

Returns
  None

## ◆ SPI_RxdSampleDelayConfig()

void SPI_RxdSampleDelayConfig | ( | SPI_TypeDef * | SPIx,
|  | uint8_t | DelayValue
| ) |  |

Configures the rxd sample delay value.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2.
  DelayValue | specifies the rxd sample delay value.

Returns
  None.

## ◆ SPI_RxFIFOThresholdConfig()

void SPI_RxFIFOThresholdConfig | ( | SPI_TypeDef * | SPIx,
|  | uint8_t | Threshold
| ) |  |

Configures the Rx FIFO threshold.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  Threshold | The Rx FIFO threshold to set.

Note
  The Receive FIFO Full interrupt will trigger when the level > Threshold.

Returns
  None.

## ◆ SPI_SlaveOutputCmd()

void SPI_SlaveOutputCmd | ( | SPI_TypeDef * | SPIx,
|  | FunctionalState | NewState
| ) |  |

Enables or disables the slave output (only used for SPISx).

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: SPIS1, SPIS2.
  NewState | new state of the slave output. This parameter can be: ENABLE or DISABLE.

Returns
  None

## ◆ SPI_SpiModeConfig()

void SPI_SpiModeConfig | ( | SPI_TypeDef * | SPIx,
|  | uint32_t | SPI_SpiMode
| ) |  |

Configures the Spi Mode.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter must be QSPI.
  SPI_SpiMode | specifies the Spi Mode. This parameter can be one of the following values: SPI_SpiMode_Standard SPI_SpiMode_Dual SPI_SpiMode_Quad

Returns
  None

## ◆ SPI_StructInit()

void SPI_StructInit | ( | SPI_InitTypeDef * | SPI_InitStruct | ) |

Fills each SPI_InitStruct member with its default value.

Parameters

  SPI_InitStruct | pointer to a SPI_InitTypeDef structure which will be initialized.

Returns
  None

## ◆ SPI_TransferModeConfig()

void SPI_TransferModeConfig | ( | SPI_TypeDef * | SPIx,
|  | uint16_t | SPI_TransferMode
| ) |  |

Configures the transfer mode.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  SPI_TransferMode | specifies the transfer mode. This parameter can be one of the following values: SPI_TransferMode_TxAndRx SPI_TransferMode_TxOnly SPI_TransferMode_RxOnly SPI_TransferMode_EepromRead

Returns
  None

## ◆ SPI_TxFIFOThresholdConfig()

void SPI_TxFIFOThresholdConfig | ( | SPI_TypeDef * | SPIx,
|  | uint8_t | Threshold
| ) |  |

Configures the Tx FIFO threshold.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  Threshold | The Tx FIFO threshold to set.

Note
  The Transmit FIFO Empty interrupt will trigger when the level <= Threshold.

Returns
  None.

## ◆ SPI_WriteData()

void SPI_WriteData | ( | SPI_TypeDef * | SPIx,
|  | uint16_t | Data
| ) |  |

Write one data to Tx FIFO.

Parameters

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: QSPI, SPIM2, SPIS1, SPIS2.
  Data | The data to write.

Returns
  None