STM8L15x Standard Peripherals Drivers: Initialization and Configuration functions

STM8L15x/16x Standard Peripherals Drivers

STM8L15x Standard Peripherals Drivers

Initialization and Configuration functions

Initialization and Configuration functions. More...

Functions

void SPI_BiDirectionalLineConfig (SPI_TypeDef *SPIx, SPI_Direction_TypeDef SPI_Direction)
 Selects the data transfer direction in Bi-directional mode.
void SPI_Cmd (SPI_TypeDef *SPIx, FunctionalState NewState)
 Enables or disables the SPI peripheral.
void SPI_DeInit (SPI_TypeDef *SPIx)
 Deinitializes the SPI peripheral registers to their default reset values.
void SPI_Init (SPI_TypeDef *SPIx, SPI_FirstBit_TypeDef SPI_FirstBit, SPI_BaudRatePrescaler_TypeDef SPI_BaudRatePrescaler, SPI_Mode_TypeDef SPI_Mode, SPI_CPOL_TypeDef SPI_CPOL, SPI_CPHA_TypeDef SPI_CPHA, SPI_DirectionMode_TypeDef SPI_Data_Direction, SPI_NSS_TypeDef SPI_Slave_Management, uint8_t CRCPolynomial)
 Initializes the SPI according to the specified parameters.
void SPI_NSSInternalSoftwareCmd (SPI_TypeDef *SPIx, FunctionalState NewState)
 Configures internally by software the NSS pin.

Detailed Description

Initialization and Configuration functions.

 ===============================================================================
                  Initialization and Configuration functions
 ===============================================================================  

  This section provides a set of functions allowing to initialize the SPI Direction,
  SPI Mode, SPI Data Size, SPI Polarity, SPI Phase, SPI NSS Management, SPI Baud
  Rate Prescaler, SPI First Bit and SPI CRC Polynomial.
  
  The SPI_Init() function follows the SPI configuration procedures for Master mode
  and Slave mode (details for these procedures are available in reference manual
  (RM0031)).
  

Function Documentation

void SPI_BiDirectionalLineConfig ( SPI_TypeDef SPIx,
SPI_Direction_TypeDef  SPI_Direction 
)

Selects the data transfer direction in Bi-directional mode.

Parameters:
SPIx,:where x can be 1 to select the specified SPI peripheral.
SPI_DirectionSpecifies the data transfer direction in Bi-directional mode. This parameter can be one of the following values:
  • SPI_Direction_Rx: Select Rx receive direction in bi-directional mode
  • SPI_Direction_Tx: Select Tx transmission direction in bi-directional mode
Return values:
None

Definition at line 265 of file stm8l15x_spi.c.

References SPI_struct::CR2, IS_SPI_DIRECTION, SPI_CR2_BDOE, and SPI_Direction_Rx.

void SPI_Cmd ( SPI_TypeDef SPIx,
FunctionalState  NewState 
)

Enables or disables the SPI peripheral.

Parameters:
SPIx,:where x can be 1 to select the specified SPI peripheral.
NewStateNew state of the SPI peripheral. This parameter can be: ENABLE or DISABLE
Return values:
None

Definition at line 219 of file stm8l15x_spi.c.

References SPI_struct::CR1, DISABLE, IS_FUNCTIONAL_STATE, and SPI_CR1_SPE.

Referenced by SPI_CalculateCRCCmd(), and SPI_ResetCRC().

void SPI_DeInit ( SPI_TypeDef SPIx)

Deinitializes the SPI peripheral registers to their default reset values.

Parameters:
SPIx,:where x can be 1 to select the specified SPI peripheral.
None
Return values:
None

Definition at line 122 of file stm8l15x_spi.c.

References SPI_struct::CR1, SPI_struct::CR2, SPI_struct::CR3, SPI_struct::CRCPR, SPI_CR1_RESET_VALUE, SPI_CR2_RESET_VALUE, SPI_CR3_RESET_VALUE, SPI_CRCPR_RESET_VALUE, SPI_SR_RESET_VALUE, and SPI_struct::SR.

void SPI_Init ( SPI_TypeDef SPIx,
SPI_FirstBit_TypeDef  SPI_FirstBit,
SPI_BaudRatePrescaler_TypeDef  SPI_BaudRatePrescaler,
SPI_Mode_TypeDef  SPI_Mode,
SPI_CPOL_TypeDef  SPI_CPOL,
SPI_CPHA_TypeDef  SPI_CPHA,
SPI_DirectionMode_TypeDef  SPI_Data_Direction,
SPI_NSS_TypeDef  SPI_Slave_Management,
uint8_t  CRCPolynomial 
)

Initializes the SPI according to the specified parameters.

Parameters:
SPIx,:where x can be 1 to select the specified SPI peripheral.
SPI_FirstBit,:This parameter can be any of the This parameter can be one of the following values:
  • SPI_FirstBit_MSB: MSB bit will be transmitted first
  • SPI_FirstBit_LSB: LSB bit will be transmitted first
SPI_BaudRatePrescaler,:This parameter can be any of the This parameter can be one of the following values:
  • SPI_BaudRatePrescaler_2: SPI frequency = frequency(CPU)/2
  • SPI_BaudRatePrescaler_4: SPI frequency = frequency(CPU)/4
  • SPI_BaudRatePrescaler_8: SPI frequency = frequency(CPU)/8
  • SPI_BaudRatePrescaler_16: SPI frequency = frequency(CPU)/16
  • SPI_BaudRatePrescaler_32: SPI frequency = frequency(CPU)/32
  • SPI_BaudRatePrescaler_64: SPI frequency = frequency(CPU)/64
  • SPI_BaudRatePrescaler_128: SPI frequency = frequency(CPU)/128
  • SPI_BaudRatePrescaler_256: SPI frequency = frequency(CPU)/256
SPI_Mode,:Mode This parameter can be one of the following values:
  • SPI_Mode_Master: SPI Master configuration
  • SPI_Mode_Slave: SPI Slave configuration
SPI_CPOL,:Clock Polarity This parameter can be one of the following values:
  • SPI_CPOL_Low: Clock to 0 when idle
  • SPI_CPOL_High: Clock to 1 when idle
SPI_CPHA,:Clock Phase This parameter can be one of the following values:
  • SPI_CPHA_1Edge: The first clock transition is the first data capture edge
  • SPI_CPHA_2Edge: The second clock transition is the first data capture edge
SPI_Data_Direction,:Data direction This parameter can be one of the following values:
  • SPI_Direction_Rx: Select Rx receive direction in bi-directional mode
  • SPI_Direction_Tx: Select Tx transmission direction in bi-directional mode
SPI_Slave_Management,:Slave management This parameter can be one of the following values:
  • SPI_NSS_Soft: Software slave management disabled
  • SPI_NSS_Hard: Software slave management enabled
CRCPolynomial,:Configures the CRC polynomial.
Return values:
None

Definition at line 171 of file stm8l15x_spi.c.

References SPI_struct::CR1, SPI_struct::CR2, SPI_struct::CRCPR, IS_SPI_BAUDRATE_PRESCALER, IS_SPI_CRC_POLYNOMIAL, IS_SPI_DATA_DIRECTION, IS_SPI_FIRSTBIT, IS_SPI_MODE, IS_SPI_PHASE, IS_SPI_POLARITY, IS_SPI_SLAVEMANAGEMENT, SPI_CR2_SSI, and SPI_Mode_Master.

void SPI_NSSInternalSoftwareCmd ( SPI_TypeDef SPIx,
FunctionalState  NewState 
)

Configures internally by software the NSS pin.

Parameters:
SPIx,:where x can be 1 to select the specified SPI peripheral.
NewStateIndicates the new state of the SPI Software slave management. This parameter can be: ENABLE or DISABLE.
Return values:
None

Definition at line 241 of file stm8l15x_spi.c.

References SPI_struct::CR2, DISABLE, IS_FUNCTIONAL_STATE, and SPI_CR2_SSI.

STM8S Firmware Library: Overview

 

 

 

For complete documentation on STM8L15x 8-bit microcontrollers platform visit www.st.com