MG32L003 Standard Peripherals Firmware Library

模块 | 结构体 | 宏定义 | 函数
SPI
MG32L003_StdPeriph_Driver

SPI driver modules 更多...

## 模块
| SPI_Exported_Constants
| SPI_Private_Functions

## 结构体
struct | SPI_InitTypeDef
| SPI Init structure definition 更多...

## 宏定义
#define | IS_SPI_MODE(MODE)
#define | IS_SPI_CPOL(CPOL)
#define | IS_SPI_CPHA(CPHA)
#define | IS_SPI_NSS(NSS)
#define | IS_SPI_BAUDRATE_PRESCALER(PRESCALER)
#define | IS_SPI_ALL_PERIPH(PERIPH) ((PERIPH) == SPI)

## 函数
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_Cmd (SPI_TypeDef *SPIx, FunctionalState NewState)
| Enables or disables the specified SPI peripheral. 更多...
void | SPI_NSSConfig (SPI_TypeDef *SPIx, FunctionalState NewState)
| Enables or disables the specified slave select line. 更多...
uint8_t | SPI_ReadData (SPI_TypeDef *SPIx)
| Read one data from DATA register. 更多...
void | SPI_WriteData (SPI_TypeDef *SPIx, uint8_t Data)
| Write one data to DATA register. 更多...
FlagStatus | SPI_GetFlagStatus (SPI_TypeDef *SPIx, uint8_t SPI_FLAG)
| Checks whether the specified SPIx flag is set or not. 更多...

## 详细描述

SPI driver modules

## 宏定义说明

## ◆ IS_SPI_BAUDRATE_PRESCALER

#define IS_SPI_BAUDRATE_PRESCALER | ( |  | PRESCALER | ) |

值:
(((PRESCALER) == SPI_BAUD_RATE_PRESCALER_2) || \
((PRESCALER) == SPI_BAUD_RATE_PRESCALER_4) || \
((PRESCALER) == SPI_BAUD_RATE_PRESCALER_8) || \
((PRESCALER) == SPI_BAUD_RATE_PRESCALER_16) || \
((PRESCALER) == SPI_BAUD_RATE_PRESCALER_32) || \
((PRESCALER) == SPI_BAUD_RATE_PRESCALER_64) || \
((PRESCALER) == SPI_BAUD_RATE_PRESCALER_128))

## ◆ IS_SPI_CPHA

#define IS_SPI_CPHA | ( |  | CPHA | ) |

值:
(((CPHA) == SPI_CPHA_1Edge) || \
((CPHA) == SPI_CPHA_2Edge))

## ◆ IS_SPI_CPOL

#define IS_SPI_CPOL | ( |  | CPOL | ) |

值:
(((CPOL) == SPI_CPOL_Low) || \
((CPOL) == SPI_CPOL_High))

## ◆ IS_SPI_MODE

#define IS_SPI_MODE | ( |  | MODE | ) |

值:
(((MODE) == SPI_MODE_SLAVE) || \
((MODE) == SPI_MODE_MASTER))

## ◆ IS_SPI_NSS

#define IS_SPI_NSS | ( |  | NSS | ) |

值:
(((NSS) == SPI_NSS_MODE_HIGH) || \
((NSS) == SPI_NSS_MODE_LOW))

## 函数说明

## ◆ 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: SPI.
  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: SPI.

返回值

  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: SPI.
  SPI_FLAG | specifies the SPI flag to check. This parameter can be one of the following values: SPI_FLAG_SPIF: End of transmission flag. SPI_FLAG_WCOL: Write conflict flag. SPI_FLAG_SSERR: Slave mode SSN error flag. SPI_FLAG_MDF: Host mode error flag.

返回值

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

## ◆ 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: SPI.
  SPI_InitStruct | pointer to a SPI_InitTypeDef structure that contains the configuration information for the specified SPI peripheral.

返回值

  None |

## ◆ SPI_NSSConfig()

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

Enables or disables the specified slave select line.

参数

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

返回值

  None |

## ◆ SPI_ReadData()

uint8_t SPI_ReadData | ( | SPI_TypeDef * | SPIx | ) |

Read one data from DATA register.

参数

  SPIx | Pointer to selected SPI peripheral. This parameter can be one of the following values: SPI.

返回值

  The | read data.

## ◆ SPI_WriteData()

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

Write one data to DATA register.

参数

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

返回值

  None |