STM8S/A Standard Peripherals Drivers: SPI_Public_Functions

STM8S/A

STM8S/A Standard Peripherals Drivers
SPI_Public_Functions

Functions

void SPI_BiDirectionalLineConfig (SPI_Direction_TypeDef SPI_Direction)
 Selects the data transfer direction in bi-directional mode.
void SPI_CalculateCRCCmd (FunctionalState NewState)
 Enables or disables the CRC value calculation of the transferred bytes.
void SPI_ClearFlag (SPI_Flag_TypeDef SPI_FLAG)
 Clears the SPI flags.
void SPI_ClearITPendingBit (SPI_IT_TypeDef SPI_IT)
 Clears the interrupt pending bits.
void SPI_Cmd (FunctionalState NewState)
 Enables or disables the SPI peripheral.
void SPI_DeInit (void)
 Deinitializes the SPI peripheral registers to their default reset values.
uint8_t SPI_GetCRC (SPI_CRC_TypeDef SPI_CRC)
 Returns the transmit or the receive CRC register value.
uint8_t SPI_GetCRCPolynomial (void)
 Returns the CRC Polynomial register value.
FlagStatus SPI_GetFlagStatus (SPI_Flag_TypeDef SPI_FLAG)
 Checks whether the specified SPI flag is set or not.
ITStatus SPI_GetITStatus (SPI_IT_TypeDef SPI_IT)
 Checks whether the specified interrupt has occurred or not.
void SPI_Init (SPI_FirstBit_TypeDef FirstBit, SPI_BaudRatePrescaler_TypeDef BaudRatePrescaler, SPI_Mode_TypeDef Mode, SPI_ClockPolarity_TypeDef ClockPolarity, SPI_ClockPhase_TypeDef ClockPhase, SPI_DataDirection_TypeDef Data_Direction, SPI_NSS_TypeDef Slave_Management, uint8_t CRCPolynomial)
 Initializes the SPI according to the specified parameters.
void SPI_ITConfig (SPI_IT_TypeDef SPI_IT, FunctionalState NewState)
 Enables or disables the specified interrupts.
void SPI_NSSInternalSoftwareCmd (FunctionalState NewState)
 Configures internally by software the NSS pin.
uint8_t SPI_ReceiveData (void)
 Returns the most recent received data by the SPI peripheral.
void SPI_ResetCRC (void)
 Reset the Rx CRCR and Tx CRCR registers.
void SPI_SendData (uint8_t Data)
 Transmits a Data through the SPI peripheral.
void SPI_TransmitCRC (void)
 Enables the transmit of the CRC value.

Function Documentation

void SPI_BiDirectionalLineConfig ( SPI_Direction_TypeDef  SPI_Direction)

Selects the data transfer direction in bi-directional mode.

Parameters:
SPI_DirectionSpecifies the data transfer direction in bi-directional mode.
Return values:
None

Definition at line 288 of file stm8s_spi.c.

References IS_SPI_DIRECTION_OK, SPI, SPI_CR2_BDOE, and SPI_DIRECTION_RX.

void SPI_CalculateCRCCmd ( FunctionalState  NewState)

Enables or disables the CRC value calculation of the transferred bytes.

Parameters:
NewStateIndicates the new state of the SPI CRC value calculation. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 218 of file stm8s_spi.c.

References DISABLE, IS_FUNCTIONALSTATE_OK, SPI, and SPI_CR2_CRCEN.

Referenced by SPI_ResetCRC().

void SPI_ClearFlag ( SPI_Flag_TypeDef  SPI_FLAG)

Clears the SPI flags.

Parameters:
SPI_FLAG: Specifies the flag to clear. This parameter can be one of the following values:
  • SPI_FLAG_CRCERR
  • SPI_FLAG_WKUP
Note:
- OVR (OverRun Error) interrupt pending bit is cleared by software sequence: a read operation to SPI_DR register (SPI_ReceiveData()) followed by a read operation to SPI_SR register (SPI_GetFlagStatus()).
  • MODF (Mode Fault) interrupt pending bit is cleared by software sequence: a read/write operation to SPI_SR register (SPI_GetFlagStatus()) followed by a write operation to SPI_CR1 register (SPI_Cmd() to enable the SPI).
Return values:
None

Definition at line 346 of file stm8s_spi.c.

References IS_SPI_CLEAR_FLAGS_OK, and SPI.

void SPI_ClearITPendingBit ( SPI_IT_TypeDef  SPI_IT)

Clears the interrupt pending bits.

Parameters:
SPI_IT,:Specifies the interrupt pending bit to clear. This parameter can be one of the following values:
  • SPI_IT_CRCERR
  • SPI_IT_WKUP
Note:
- OVR (OverRun Error) interrupt pending bit is cleared by software sequence: a read operation to SPI_DR register (SPI_ReceiveData()) followed by a read operation to SPI_SR register (SPI_GetITStatus()).
  • MODF (Mode Fault) interrupt pending bit is cleared by software sequence: a read/write operation to SPI_SR register (SPI_GetITStatus()) followed by a write operation to SPI_CR1 register (SPI_Cmd() to enable the SPI).
Return values:
None

Definition at line 412 of file stm8s_spi.c.

References IS_SPI_CLEAR_IT_OK, and SPI.

void SPI_Cmd ( FunctionalState  NewState)

Enables or disables the SPI peripheral.

Parameters:
NewStateNew state of the SPI peripheral. This parameter can be: ENABLE or DISABLE
Return values:
None

Definition at line 119 of file stm8s_spi.c.

References DISABLE, IS_FUNCTIONALSTATE_OK, SPI, and SPI_CR1_SPE.

Referenced by SPI_ResetCRC().

void SPI_DeInit ( void  )

Deinitializes the SPI peripheral registers to their default reset values.

Parameters:
None
Return values:
None

Definition at line 50 of file stm8s_spi.c.

References SPI, SPI_CR1_RESET_VALUE, SPI_CR2_RESET_VALUE, SPI_CRCPR_RESET_VALUE, SPI_ICR_RESET_VALUE, and SPI_SR_RESET_VALUE.

uint8_t SPI_GetCRC ( SPI_CRC_TypeDef  SPI_CRC)

Returns the transmit or the receive CRC register value.

Parameters:
SPI_CRCSpecifies the CRC register to be read.
Return values:
Theselected CRC register value.

Definition at line 238 of file stm8s_spi.c.

References IS_SPI_CRC_OK, SPI, and SPI_CRC_RX.

uint8_t SPI_GetCRCPolynomial ( void  )

Returns the CRC Polynomial register value.

Parameters:
None
Return values:
TheCRC Polynomial register value.

Definition at line 278 of file stm8s_spi.c.

References SPI.

FlagStatus SPI_GetFlagStatus ( SPI_Flag_TypeDef  SPI_FLAG)

Checks whether the specified SPI flag is set or not.

Parameters:
SPI_FLAG: Specifies the flag to check. This parameter can be any of the SPI_Flag_TypeDef enumeration.
Return values:
FlagStatus: Indicates the state of SPI_FLAG. This parameter can be any of the FlagStatus enumeration.

Definition at line 311 of file stm8s_spi.c.

References IS_SPI_FLAGS_OK, RESET, SET, and SPI.

ITStatus SPI_GetITStatus ( SPI_IT_TypeDef  SPI_IT)

Checks whether the specified interrupt has occurred or not.

Parameters:
SPI_IT,:Specifies the SPI interrupt pending bit to check. This parameter can be one of the following values:
  • SPI_IT_CRCERR
  • SPI_IT_WKUP
  • SPI_IT_OVR
  • SPI_IT_MODF
  • SPI_IT_RXNE
  • SPI_IT_TXE
Return values:
ITStatus: Indicates the state of the SPI_IT. This parameter can be any of the ITStatus enumeration.

Definition at line 366 of file stm8s_spi.c.

References IS_SPI_GET_IT_OK, RESET, SET, and SPI.

void SPI_Init ( SPI_FirstBit_TypeDef  FirstBit,
SPI_BaudRatePrescaler_TypeDef  BaudRatePrescaler,
SPI_Mode_TypeDef  Mode,
SPI_ClockPolarity_TypeDef  ClockPolarity,
SPI_ClockPhase_TypeDef  ClockPhase,
SPI_DataDirection_TypeDef  Data_Direction,
SPI_NSS_TypeDef  Slave_Management,
uint8_t  CRCPolynomial 
)

Initializes the SPI according to the specified parameters.

Parameters:
FirstBit: This parameter can be any of the SPI_FirstBit_TypeDef enumeration.
BaudRatePrescaler: This parameter can be any of the SPI_BaudRatePrescaler_TypeDef enumeration.
Mode: This parameter can be any of the SPI_Mode_TypeDef enumeration.
ClockPolarity: This parameter can be any of the SPI_ClockPolarity_TypeDef enumeration.
ClockPhase: This parameter can be any of the SPI_ClockPhase_TypeDef enumeration.
Data_Direction: This parameter can be any of the SPI_DataDirection_TypeDef enumeration.
Slave_Management: This parameter can be any of the SPI_NSS_TypeDef enumeration.
CRCPolynomial: Configures the CRC polynomial.
Return values:
None

Definition at line 78 of file stm8s_spi.c.

References IS_SPI_BAUDRATE_PRESCALER_OK, IS_SPI_CRC_POLYNOMIAL_OK, IS_SPI_DATA_DIRECTION_OK, IS_SPI_FIRSTBIT_OK, IS_SPI_MODE_OK, IS_SPI_PHASE_OK, IS_SPI_POLARITY_OK, IS_SPI_SLAVEMANAGEMENT_OK, SPI, SPI_CR2_SSI, and SPI_MODE_MASTER.

void SPI_ITConfig ( SPI_IT_TypeDef  SPI_IT,
FunctionalState  NewState 
)

Enables or disables the specified interrupts.

Parameters:
SPI_ITSpecifies the SPI interrupts sources to be enabled or disabled.
NewState,:The new state of the specified SPI interrupts. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 141 of file stm8s_spi.c.

References DISABLE, IS_FUNCTIONALSTATE_OK, IS_SPI_CONFIG_IT_OK, and SPI.

void SPI_NSSInternalSoftwareCmd ( FunctionalState  NewState)

Configures internally by software the NSS pin.

Parameters:
NewStateIndicates the new state of the SPI Software slave management. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 187 of file stm8s_spi.c.

References DISABLE, IS_FUNCTIONALSTATE_OK, SPI, and SPI_CR2_SSI.

uint8_t SPI_ReceiveData ( void  )

Returns the most recent received data by the SPI peripheral.

Parameters:
None
Return values:
Thevalue of the received data.

Definition at line 176 of file stm8s_spi.c.

References SPI.

void SPI_ResetCRC ( void  )

Reset the Rx CRCR and Tx CRCR registers.

Parameters:
None
Return values:
None

Definition at line 263 of file stm8s_spi.c.

References ENABLE, SPI_CalculateCRCCmd(), and SPI_Cmd().

void SPI_SendData ( uint8_t  Data)

Transmits a Data through the SPI peripheral.

Parameters:
Data: Byte to be transmitted.
Return values:
None

Definition at line 166 of file stm8s_spi.c.

References SPI.

void SPI_TransmitCRC ( void  )

Enables the transmit of the CRC value.

Parameters:
None
Return values:
None

Definition at line 207 of file stm8s_spi.c.

References SPI, and SPI_CR2_CRCNEXT.

STM8 Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM8 8-bit Microcontrollers platform visit www.st.com