MG32F10x Standard Peripherals Firmware Library
结构体 | 宏定义 | 函数
mg32f10x_spi.h 文件参考

This file contains all the functions prototypes for the SPI firmware library. 更多...

#include "mg32f10x.h"

浏览源代码.

结构体

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 更多...
 

宏定义

#define SPI_TransferMode_TxAndRx   ((uint16_t)SPI_CR0_TMOD_TX_AND_RX)
 
#define SPI_TransferMode_TxOnly   ((uint16_t)SPI_CR0_TMOD_TX_ONLY)
 
#define SPI_TransferMode_RxOnly   ((uint16_t)SPI_CR0_TMOD_RX_ONLY)
 
#define SPI_TransferMode_EepromRead   ((uint16_t)SPI_CR0_TMOD_EEPROM_READ)
 
#define SPI_DataSize_4b   ((uint16_t)SPI_CR0_DFS_4BITS)
 
#define SPI_DataSize_5b   ((uint16_t)SPI_CR0_DFS_5BITS)
 
#define SPI_DataSize_6b   ((uint16_t)SPI_CR0_DFS_6BITS)
 
#define SPI_DataSize_7b   ((uint16_t)SPI_CR0_DFS_7BITS)
 
#define SPI_DataSize_8b   ((uint16_t)SPI_CR0_DFS_8BITS)
 
#define SPI_DataSize_9b   ((uint16_t)SPI_CR0_DFS_9BITS)
 
#define SPI_DataSize_10b   ((uint16_t)SPI_CR0_DFS_10BITS)
 
#define SPI_DataSize_11b   ((uint16_t)SPI_CR0_DFS_11BITS)
 
#define SPI_DataSize_12b   ((uint16_t)SPI_CR0_DFS_12BITS)
 
#define SPI_DataSize_13b   ((uint16_t)SPI_CR0_DFS_13BITS)
 
#define SPI_DataSize_14b   ((uint16_t)SPI_CR0_DFS_14BITS)
 
#define SPI_DataSize_15b   ((uint16_t)SPI_CR0_DFS_15BITS)
 
#define SPI_DataSize_16b   ((uint16_t)SPI_CR0_DFS_16BITS)
 
#define SPI_CPOL_Low   ((uint16_t)0x00)
 
#define SPI_CPOL_High   ((uint16_t)0x80)
 
#define SPI_CPHA_1Edge   ((uint16_t)0x00)
 
#define SPI_CPHA_2Edge   ((uint16_t)0x40)
 
#define SPI_FrameFormat_SPI   ((uint16_t)SPI_CR0_FRF_SPI)
 
#define SPI_FrameFormat_SSP   ((uint16_t)SPI_CR0_FRF_SSP)
 
#define SPI_FrameFormat_Microwire   ((uint16_t)SPI_CR0_FRF_NS)
 
#define SPI_MicrowireControlFrameSize_1b   ((uint16_t)SPI_CR0_CFS_01_BIT)
 
#define SPI_MicrowireControlFrameSize_2b   ((uint16_t)SPI_CR0_CFS_02_BIT)
 
#define SPI_MicrowireControlFrameSize_3b   ((uint16_t)SPI_CR0_CFS_03_BIT)
 
#define SPI_MicrowireControlFrameSize_4b   ((uint16_t)SPI_CR0_CFS_04_BIT)
 
#define SPI_MicrowireControlFrameSize_5b   ((uint16_t)SPI_CR0_CFS_05_BIT)
 
#define SPI_MicrowireControlFrameSize_6b   ((uint16_t)SPI_CR0_CFS_06_BIT)
 
#define SPI_MicrowireControlFrameSize_7b   ((uint16_t)SPI_CR0_CFS_07_BIT)
 
#define SPI_MicrowireControlFrameSize_8b   ((uint16_t)SPI_CR0_CFS_08_BIT)
 
#define SPI_MicrowireControlFrameSize_9b   ((uint16_t)SPI_CR0_CFS_09_BIT)
 
#define SPI_MicrowireControlFrameSize_10b   ((uint16_t)SPI_CR0_CFS_10_BIT)
 
#define SPI_MicrowireControlFrameSize_11b   ((uint16_t)SPI_CR0_CFS_11_BIT)
 
#define SPI_MicrowireControlFrameSize_12b   ((uint16_t)SPI_CR0_CFS_12_BIT)
 
#define SPI_MicrowireControlFrameSize_13b   ((uint16_t)SPI_CR0_CFS_13_BIT)
 
#define SPI_MicrowireControlFrameSize_14b   ((uint16_t)SPI_CR0_CFS_14_BIT)
 
#define SPI_MicrowireControlFrameSize_15b   ((uint16_t)SPI_CR0_CFS_15_BIT)
 
#define SPI_MicrowireControlFrameSize_16b   ((uint16_t)SPI_CR0_CFS_16_BIT)
 
#define SPI_MicrowireTransferMode_NonSequential   ((uint16_t)0x00)
 
#define SPI_MicrowireTransferMode_Sequential   ((uint16_t)0x01)
 
#define SPI_MicrowireDirection_Receive   ((uint16_t)0x00)
 
#define SPI_MicrowireDirection_Transmit   ((uint16_t)0x02)
 
#define SPI_MicrowireHandshaking_Enable   ((uint16_t)0x04)
 
#define SPI_MicrowireHandshaking_Disable   ((uint16_t)0x00)
 
#define SPI_SpiMode_Standard   (SPI_CR0_SPI_MODE_STD)
 
#define SPI_SpiMode_Dual   (SPI_CR0_SPI_MODE_DUAL)
 
#define SPI_SpiMode_Quad   (SPI_CR0_SPI_MODE_QUAD)
 
#define SPI_EnhancedSpiTransferType_0   ((uint16_t)0x00)
 
#define SPI_EnhancedSpiTransferType_1   ((uint16_t)0x01)
 
#define SPI_EnhancedSpiTransferType_2   ((uint16_t)0x02)
 
#define SPI_EnhancedSpiInstructionLength_0b   ((uint16_t)SPI_ESPICR_INSTL_0BIT)
 
#define SPI_EnhancedSpiInstructionLength_4b   ((uint16_t)SPI_ESPICR_INSTL_4BIT)
 
#define SPI_EnhancedSpiInstructionLength_8b   ((uint16_t)SPI_ESPICR_INSTL_8BIT)
 
#define SPI_EnhancedSpiInstructionLength_16b   ((uint16_t)SPI_ESPICR_INSTL_16BIT)
 
#define SPI_EnhancedSpiAddressLength_0b   ((uint16_t)SPI_ESPICR_ADDRL_0BIT)
 
#define SPI_EnhancedSpiAddressLength_4b   ((uint16_t)SPI_ESPICR_ADDRL_4BIT)
 
#define SPI_EnhancedSpiAddressLength_8b   ((uint16_t)SPI_ESPICR_ADDRL_8BIT)
 
#define SPI_EnhancedSpiAddressLength_12b   ((uint16_t)SPI_ESPICR_ADDRL_12BIT)
 
#define SPI_EnhancedSpiAddressLength_16b   ((uint16_t)SPI_ESPICR_ADDRL_16BIT)
 
#define SPI_EnhancedSpiAddressLength_20b   ((uint16_t)SPI_ESPICR_ADDRL_20BIT)
 
#define SPI_EnhancedSpiAddressLength_24b   ((uint16_t)SPI_ESPICR_ADDRL_24BIT)
 
#define SPI_EnhancedSpiAddressLength_28b   ((uint16_t)SPI_ESPICR_ADDRL_28BIT)
 
#define SPI_EnhancedSpiAddressLength_32b   ((uint16_t)SPI_ESPICR_ADDRL_32BIT)
 
#define SPI_EnhancedSpiAddressLength_36b   ((uint16_t)SPI_ESPICR_ADDRL_36BIT)
 
#define SPI_EnhancedSpiAddressLength_40b   ((uint16_t)SPI_ESPICR_ADDRL_40BIT)
 
#define SPI_EnhancedSpiAddressLength_44b   ((uint16_t)SPI_ESPICR_ADDRL_44BIT)
 
#define SPI_EnhancedSpiAddressLength_48b   ((uint16_t)SPI_ESPICR_ADDRL_48BIT)
 
#define SPI_EnhancedSpiAddressLength_52b   ((uint16_t)SPI_ESPICR_ADDRL_52BIT)
 
#define SPI_EnhancedSpiAddressLength_56b   ((uint16_t)SPI_ESPICR_ADDRL_56BIT)
 
#define SPI_EnhancedSpiAddressLength_60b   ((uint16_t)SPI_ESPICR_ADDRL_60BIT)
 
#define SPI_NSS_0   (0x01)
 
#define SPI_NSS_1   (0x02)
 
#define SPI_NSS_2   (0x04)
 
#define SPI_FLAG_BUSY   ((uint8_t)SPI_SR_BUSY)
 
#define SPI_FLAG_TFNF   ((uint8_t)SPI_SR_TFNF)
 
#define SPI_FLAG_TFE   ((uint8_t)SPI_SR_TFE)
 
#define SPI_FLAG_RFNE   ((uint8_t)SPI_SR_RFNE)
 
#define SPI_FLAG_RFF   ((uint8_t)SPI_SR_RFF)
 
#define SPI_FLAG_TXERR   ((uint8_t)SPI_SR_TXERR)
 
#define SPI_FLAG_DCOL   ((uint8_t)SPI_SR_DCOL)
 
#define SPI_IT_TXE   (0x1 << 0)
 
#define SPI_IT_TXO   (0x1 << 1)
 
#define SPI_IT_RXU   (0x1 << 2)
 
#define SPI_IT_RXO   (0x1 << 3)
 
#define SPI_IT_RXF   (0x1 << 4)
 
#define SPI_IT_MST   (0x1 << 5)
 
#define SPI_DMAReq_Rx   0x01
 
#define SPI_DMAReq_Tx   0x02
 

函数

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. 更多...
 

详细描述

This file contains all the functions prototypes for the SPI firmware library.

作者
megawin Application Team
版本
V0.1.10
日期
05-January-2023