MG32L003 Standard Peripherals Firmware Library
Modules | Data Structures | Macros | Functions

SPI driver modules. More...

Modules

 SPI_Exported_Constants
 
 SPI_Private_Functions
 

Data Structures

struct  SPI_InitTypeDef
 SPI Init structure definition. More...
 

Macros

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

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

Detailed Description

SPI driver modules.

Macro Definition Documentation

◆ IS_SPI_BAUDRATE_PRESCALER

#define IS_SPI_BAUDRATE_PRESCALER (   PRESCALER)
Value:
(((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)
Value:
(((CPHA) == SPI_CPHA_1Edge) || \
((CPHA) == SPI_CPHA_2Edge))

◆ IS_SPI_CPOL

#define IS_SPI_CPOL (   CPOL)
Value:
(((CPOL) == SPI_CPOL_Low) || \
((CPOL) == SPI_CPOL_High))

◆ IS_SPI_MODE

#define IS_SPI_MODE (   MODE)
Value:
(((MODE) == SPI_MODE_SLAVE) || \
((MODE) == SPI_MODE_MASTER))

◆ IS_SPI_NSS

#define IS_SPI_NSS (   NSS)
Value:
(((NSS) == SPI_NSS_MODE_HIGH) || \
((NSS) == SPI_NSS_MODE_LOW))

Function Documentation

◆ SPI_Cmd()

void SPI_Cmd ( SPI_TypeDef SPIx,
FunctionalState  NewState 
)

Enables or disables the specified SPI peripheral.

Parameters
SPIxPointer to selected SPI peripheral. This parameter can be one of the following values: SPI.
NewStatenew state of the SPIx peripheral. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ SPI_DeInit()

void SPI_DeInit ( SPI_TypeDef SPIx)

Deinitializes the SPIx peripheral registers to their default reset values.

Parameters
SPIxPointer to selected SPI peripheral. This parameter can be one of the following values: SPI.
Return values
None

◆ SPI_GetFlagStatus()

FlagStatus SPI_GetFlagStatus ( SPI_TypeDef SPIx,
uint8_t  SPI_FLAG 
)

Checks whether the specified SPIx flag is set or not.

Parameters
SPIxPointer to selected SPI peripheral. This parameter can be one of the following values: SPI.
SPI_FLAGspecifies 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.
Return values
Thenew 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.

Parameters
SPIxPointer to selected SPI peripheral. This parameter can be one of the following values: SPI.
SPI_InitStructpointer to a SPI_InitTypeDef structure that contains the configuration information for the specified SPI peripheral.
Return values
None

◆ SPI_NSSConfig()

void SPI_NSSConfig ( SPI_TypeDef SPIx,
FunctionalState  NewState 
)

Enables or disables the specified slave select line.

Parameters
SPIxPointer to selected SPI peripheral. This parameter can be one of the following values: SPI.
NewStatenew state of the slave select line. This parameter can be: ENABLE or DISABLE.
Return values
None

◆ SPI_ReadData()

uint8_t SPI_ReadData ( SPI_TypeDef SPIx)

Read one data from DATA register.

Parameters
SPIxPointer to selected SPI peripheral. This parameter can be one of the following values: SPI.
Return values
Theread data.

◆ SPI_WriteData()

void SPI_WriteData ( SPI_TypeDef SPIx,
uint8_t  Data 
)

Write one data to DATA register.

Parameters
SPIxPointer to selected SPI peripheral. This parameter can be one of the following values: SPI.
DataThe data to write.
Return values
None