MG32F10x Standard Peripherals Firmware Library

模块 | 结构体 | 函数
SPI
MG32F10x_StdPeriph_Driver

SPI driver modules 更多...

## 模块
| SPI_Exported_Constants
| SPI_Private_Functions

## 结构体
struct | SPI_InitTypeDef
| SPI Init structure definition 更多...
struct | SPI_MicrowireInitTypeDef
| SPI Microwire Init structure definition 更多...
struct | SPI_EnhancedSpiInitTypeDef
| SPI Enhanced SPI Mode Init structure definition 更多...

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

## 详细描述

SPI driver modules

## 函数说明

## ◆ SPI_ClearITPendingBit()

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

Clears the SPIx's interrupt pending bits.

参数

  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)

返回
  None.

## ◆ SPI_Cmd()

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

Enables or disables the specified SPI peripheral.

参数

  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.

返回
  None

## ◆ SPI_DeInit()

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

Deinitializes the SPIx peripheral registers to their default reset values.

参数

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

返回
  None

## ◆ SPI_DMACmd()

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

Enables or disables the SPIx's DMA interface.

参数

  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.

返回
  None.

## ◆ SPI_DMARxReqLevelConfig()

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

Configures the DMA Rx request level.

参数

  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.

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

返回
  None.

## ◆ SPI_DMATxReqLevelConfig()

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

Configures the DMA Tx request level.

参数

  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.

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

返回
  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).

参数

  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.

返回
  None

## ◆ SPI_EnhancedSpiStructInit()

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

Fills each SPI_EnhancedSpiInitStruct member with its default value.

参数

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

返回
  None

## ◆ SPI_GetFlagStatus()

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

Checks whether the specified SPIx flag is set or not.

参数

  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).

返回
  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.

参数

  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)

返回
  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.

参数

  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)

返回
  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.

参数

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

返回
  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.

参数

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

返回
  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.

参数

  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.

返回
  None

## ◆ SPI_ITConfig()

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

Enables or disables the specified SPI interrupts.

参数

  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.

返回
  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.

参数

  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.

返回
  None

## ◆ SPI_MicrowireStructInit()

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

Fills each SPI_MicrowireInitStruct member with its default value.

参数

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

返回
  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).

参数

  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.

返回
  None

## ◆ SPI_NSSToggleModeCmd()

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

Enables or disables the slave select toggle mode.

参数

  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.

返回
  None

## ◆ SPI_ReadData()

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

Read one data from Rx FIFO.

参数

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

返回
  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).

参数

  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.

返回
  None

## ◆ SPI_RxdSampleDelayConfig()

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

Configures the rxd sample delay value.

参数

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

返回
  None.

## ◆ SPI_RxFIFOThresholdConfig()

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

Configures the Rx FIFO threshold.

参数

  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.

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

返回
  None.

## ◆ SPI_SlaveOutputCmd()

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

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

参数

  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.

返回
  None

## ◆ SPI_SpiModeConfig()

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

Configures the Spi Mode.

参数

  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

返回
  None

## ◆ SPI_StructInit()

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

Fills each SPI_InitStruct member with its default value.

参数

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

返回
  None

## ◆ SPI_TransferModeConfig()

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

Configures the transfer mode.

参数

  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

返回
  None

## ◆ SPI_TxFIFOThresholdConfig()

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

Configures the Tx FIFO threshold.

参数

  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.

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

返回
  None.

## ◆ SPI_WriteData()

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

Write one data to Tx FIFO.

参数

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

返回
  None