STM32L4xx_HAL_Driver  1.14.0

Functions

__STATIC_INLINE void LL_SPI_Enable (SPI_TypeDef *SPIx)
 Enable SPI peripheral CR1 SPE LL_SPI_Enable. More...
 
__STATIC_INLINE void LL_SPI_Disable (SPI_TypeDef *SPIx)
 Disable SPI peripheral. More...
 
__STATIC_INLINE uint32_t LL_SPI_IsEnabled (SPI_TypeDef *SPIx)
 Check if SPI peripheral is enabled CR1 SPE LL_SPI_IsEnabled. More...
 
__STATIC_INLINE void LL_SPI_SetMode (SPI_TypeDef *SPIx, uint32_t Mode)
 Set SPI operation mode to Master or Slave. More...
 
__STATIC_INLINE uint32_t LL_SPI_GetMode (SPI_TypeDef *SPIx)
 Get SPI operation mode (Master or Slave) CR1 MSTR LL_SPI_GetMode
CR1 SSI LL_SPI_GetMode. More...
 
__STATIC_INLINE void LL_SPI_SetStandard (SPI_TypeDef *SPIx, uint32_t Standard)
 Set serial protocol used. More...
 
__STATIC_INLINE uint32_t LL_SPI_GetStandard (SPI_TypeDef *SPIx)
 Get serial protocol used CR2 FRF LL_SPI_GetStandard. More...
 
__STATIC_INLINE void LL_SPI_SetClockPhase (SPI_TypeDef *SPIx, uint32_t ClockPhase)
 Set clock phase. More...
 
__STATIC_INLINE uint32_t LL_SPI_GetClockPhase (SPI_TypeDef *SPIx)
 Get clock phase CR1 CPHA LL_SPI_GetClockPhase. More...
 
__STATIC_INLINE void LL_SPI_SetClockPolarity (SPI_TypeDef *SPIx, uint32_t ClockPolarity)
 Set clock polarity. More...
 
__STATIC_INLINE uint32_t LL_SPI_GetClockPolarity (SPI_TypeDef *SPIx)
 Get clock polarity CR1 CPOL LL_SPI_GetClockPolarity. More...
 
__STATIC_INLINE void LL_SPI_SetBaudRatePrescaler (SPI_TypeDef *SPIx, uint32_t BaudRate)
 Set baud rate prescaler. More...
 
__STATIC_INLINE uint32_t LL_SPI_GetBaudRatePrescaler (SPI_TypeDef *SPIx)
 Get baud rate prescaler CR1 BR LL_SPI_GetBaudRatePrescaler. More...
 
__STATIC_INLINE void LL_SPI_SetTransferBitOrder (SPI_TypeDef *SPIx, uint32_t BitOrder)
 Set transfer bit order. More...
 
__STATIC_INLINE uint32_t LL_SPI_GetTransferBitOrder (SPI_TypeDef *SPIx)
 Get transfer bit order CR1 LSBFIRST LL_SPI_GetTransferBitOrder. More...
 
__STATIC_INLINE void LL_SPI_SetTransferDirection (SPI_TypeDef *SPIx, uint32_t TransferDirection)
 Set transfer direction mode. More...
 
__STATIC_INLINE uint32_t LL_SPI_GetTransferDirection (SPI_TypeDef *SPIx)
 Get transfer direction mode CR1 RXONLY LL_SPI_GetTransferDirection
CR1 BIDIMODE LL_SPI_GetTransferDirection
CR1 BIDIOE LL_SPI_GetTransferDirection. More...
 
__STATIC_INLINE void LL_SPI_SetDataWidth (SPI_TypeDef *SPIx, uint32_t DataWidth)
 Set frame data width CR2 DS LL_SPI_SetDataWidth. More...
 
__STATIC_INLINE uint32_t LL_SPI_GetDataWidth (SPI_TypeDef *SPIx)
 Get frame data width CR2 DS LL_SPI_GetDataWidth. More...
 
__STATIC_INLINE void LL_SPI_SetRxFIFOThreshold (SPI_TypeDef *SPIx, uint32_t Threshold)
 Set threshold of RXFIFO that triggers an RXNE event CR2 FRXTH LL_SPI_SetRxFIFOThreshold. More...
 
__STATIC_INLINE uint32_t LL_SPI_GetRxFIFOThreshold (SPI_TypeDef *SPIx)
 Get threshold of RXFIFO that triggers an RXNE event CR2 FRXTH LL_SPI_GetRxFIFOThreshold. More...
 

Detailed Description

Function Documentation

◆ LL_SPI_Disable()

__STATIC_INLINE void LL_SPI_Disable ( SPI_TypeDef *  SPIx)

Disable SPI peripheral.

Note
When disabling the SPI, follow the procedure described in the Reference Manual. CR1 SPE LL_SPI_Disable
Parameters
SPIxSPI Instance
Return values
None

Definition at line 371 of file stm32l4xx_ll_spi.h.

372 {
373  CLEAR_BIT(SPIx->CR1, SPI_CR1_SPE);
374 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)

◆ LL_SPI_Enable()

__STATIC_INLINE void LL_SPI_Enable ( SPI_TypeDef *  SPIx)

Enable SPI peripheral CR1 SPE LL_SPI_Enable.

Parameters
SPIxSPI Instance
Return values
None

Definition at line 359 of file stm32l4xx_ll_spi.h.

360 {
361  SET_BIT(SPIx->CR1, SPI_CR1_SPE);
362 }

◆ LL_SPI_GetBaudRatePrescaler()

__STATIC_INLINE uint32_t LL_SPI_GetBaudRatePrescaler ( SPI_TypeDef *  SPIx)

Get baud rate prescaler CR1 BR LL_SPI_GetBaudRatePrescaler.

Parameters
SPIxSPI Instance
Return values
Returnedvalue can be one of the following values:
  • LL_SPI_BAUDRATEPRESCALER_DIV2
  • LL_SPI_BAUDRATEPRESCALER_DIV4
  • LL_SPI_BAUDRATEPRESCALER_DIV8
  • LL_SPI_BAUDRATEPRESCALER_DIV16
  • LL_SPI_BAUDRATEPRESCALER_DIV32
  • LL_SPI_BAUDRATEPRESCALER_DIV64
  • LL_SPI_BAUDRATEPRESCALER_DIV128
  • LL_SPI_BAUDRATEPRESCALER_DIV256

Definition at line 538 of file stm32l4xx_ll_spi.h.

539 {
540  return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_BR));
541 }

◆ LL_SPI_GetClockPhase()

__STATIC_INLINE uint32_t LL_SPI_GetClockPhase ( SPI_TypeDef *  SPIx)

Get clock phase CR1 CPHA LL_SPI_GetClockPhase.

Parameters
SPIxSPI Instance
Return values
Returnedvalue can be one of the following values:
  • LL_SPI_PHASE_1EDGE
  • LL_SPI_PHASE_2EDGE

Definition at line 469 of file stm32l4xx_ll_spi.h.

470 {
471  return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_CPHA));
472 }

◆ LL_SPI_GetClockPolarity()

__STATIC_INLINE uint32_t LL_SPI_GetClockPolarity ( SPI_TypeDef *  SPIx)

Get clock polarity CR1 CPOL LL_SPI_GetClockPolarity.

Parameters
SPIxSPI Instance
Return values
Returnedvalue can be one of the following values:
  • LL_SPI_POLARITY_LOW
  • LL_SPI_POLARITY_HIGH

Definition at line 498 of file stm32l4xx_ll_spi.h.

499 {
500  return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_CPOL));
501 }

◆ LL_SPI_GetDataWidth()

__STATIC_INLINE uint32_t LL_SPI_GetDataWidth ( SPI_TypeDef *  SPIx)

Get frame data width CR2 DS LL_SPI_GetDataWidth.

Parameters
SPIxSPI Instance
Return values
Returnedvalue can be one of the following values:
  • LL_SPI_DATAWIDTH_4BIT
  • LL_SPI_DATAWIDTH_5BIT
  • LL_SPI_DATAWIDTH_6BIT
  • LL_SPI_DATAWIDTH_7BIT
  • LL_SPI_DATAWIDTH_8BIT
  • LL_SPI_DATAWIDTH_9BIT
  • LL_SPI_DATAWIDTH_10BIT
  • LL_SPI_DATAWIDTH_11BIT
  • LL_SPI_DATAWIDTH_12BIT
  • LL_SPI_DATAWIDTH_13BIT
  • LL_SPI_DATAWIDTH_14BIT
  • LL_SPI_DATAWIDTH_15BIT
  • LL_SPI_DATAWIDTH_16BIT

Definition at line 652 of file stm32l4xx_ll_spi.h.

653 {
654  return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_DS));
655 }

◆ LL_SPI_GetMode()

__STATIC_INLINE uint32_t LL_SPI_GetMode ( SPI_TypeDef *  SPIx)

Get SPI operation mode (Master or Slave) CR1 MSTR LL_SPI_GetMode
CR1 SSI LL_SPI_GetMode.

Parameters
SPIxSPI Instance
Return values
Returnedvalue can be one of the following values:
  • LL_SPI_MODE_MASTER
  • LL_SPI_MODE_SLAVE

Definition at line 412 of file stm32l4xx_ll_spi.h.

413 {
414  return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_MSTR | SPI_CR1_SSI));
415 }

◆ LL_SPI_GetRxFIFOThreshold()

__STATIC_INLINE uint32_t LL_SPI_GetRxFIFOThreshold ( SPI_TypeDef *  SPIx)

Get threshold of RXFIFO that triggers an RXNE event CR2 FRXTH LL_SPI_GetRxFIFOThreshold.

Parameters
SPIxSPI Instance
Return values
Returnedvalue can be one of the following values:
  • LL_SPI_RX_FIFO_TH_HALF
  • LL_SPI_RX_FIFO_TH_QUARTER

Definition at line 679 of file stm32l4xx_ll_spi.h.

680 {
681  return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_FRXTH));
682 }

◆ LL_SPI_GetStandard()

__STATIC_INLINE uint32_t LL_SPI_GetStandard ( SPI_TypeDef *  SPIx)

Get serial protocol used CR2 FRF LL_SPI_GetStandard.

Parameters
SPIxSPI Instance
Return values
Returnedvalue can be one of the following values:
  • LL_SPI_PROTOCOL_MOTOROLA
  • LL_SPI_PROTOCOL_TI

Definition at line 440 of file stm32l4xx_ll_spi.h.

441 {
442  return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_FRF));
443 }

◆ LL_SPI_GetTransferBitOrder()

__STATIC_INLINE uint32_t LL_SPI_GetTransferBitOrder ( SPI_TypeDef *  SPIx)

Get transfer bit order CR1 LSBFIRST LL_SPI_GetTransferBitOrder.

Parameters
SPIxSPI Instance
Return values
Returnedvalue can be one of the following values:
  • LL_SPI_LSB_FIRST
  • LL_SPI_MSB_FIRST

Definition at line 566 of file stm32l4xx_ll_spi.h.

567 {
568  return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_LSBFIRST));
569 }

◆ LL_SPI_GetTransferDirection()

__STATIC_INLINE uint32_t LL_SPI_GetTransferDirection ( SPI_TypeDef *  SPIx)

Get transfer direction mode CR1 RXONLY LL_SPI_GetTransferDirection
CR1 BIDIMODE LL_SPI_GetTransferDirection
CR1 BIDIOE LL_SPI_GetTransferDirection.

Parameters
SPIxSPI Instance
Return values
Returnedvalue can be one of the following values:
  • LL_SPI_FULL_DUPLEX
  • LL_SPI_SIMPLEX_RX
  • LL_SPI_HALF_DUPLEX_RX
  • LL_SPI_HALF_DUPLEX_TX

Definition at line 603 of file stm32l4xx_ll_spi.h.

604 {
605  return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_RXONLY | SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE));
606 }

◆ LL_SPI_IsEnabled()

__STATIC_INLINE uint32_t LL_SPI_IsEnabled ( SPI_TypeDef *  SPIx)

Check if SPI peripheral is enabled CR1 SPE LL_SPI_IsEnabled.

Parameters
SPIxSPI Instance
Return values
Stateof bit (1 or 0).

Definition at line 382 of file stm32l4xx_ll_spi.h.

383 {
384  return ((READ_BIT(SPIx->CR1, SPI_CR1_SPE) == (SPI_CR1_SPE)) ? 1UL : 0UL);
385 }

◆ LL_SPI_SetBaudRatePrescaler()

__STATIC_INLINE void LL_SPI_SetBaudRatePrescaler ( SPI_TypeDef *  SPIx,
uint32_t  BaudRate 
)

Set baud rate prescaler.

Note
These bits should not be changed when communication is ongoing. SPI BaudRate = fPCLK/Prescaler. CR1 BR LL_SPI_SetBaudRatePrescaler
Parameters
SPIxSPI Instance
BaudRateThis parameter can be one of the following values:
  • LL_SPI_BAUDRATEPRESCALER_DIV2
  • LL_SPI_BAUDRATEPRESCALER_DIV4
  • LL_SPI_BAUDRATEPRESCALER_DIV8
  • LL_SPI_BAUDRATEPRESCALER_DIV16
  • LL_SPI_BAUDRATEPRESCALER_DIV32
  • LL_SPI_BAUDRATEPRESCALER_DIV64
  • LL_SPI_BAUDRATEPRESCALER_DIV128
  • LL_SPI_BAUDRATEPRESCALER_DIV256
Return values
None

Definition at line 519 of file stm32l4xx_ll_spi.h.

520 {
521  MODIFY_REG(SPIx->CR1, SPI_CR1_BR, BaudRate);
522 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
__STATIC_INLINE void uint32_t uint32_t BaudRate

◆ LL_SPI_SetClockPhase()

__STATIC_INLINE void LL_SPI_SetClockPhase ( SPI_TypeDef *  SPIx,
uint32_t  ClockPhase 
)

Set clock phase.

Note
This bit should not be changed when communication is ongoing. This bit is not used in SPI TI mode. CR1 CPHA LL_SPI_SetClockPhase
Parameters
SPIxSPI Instance
ClockPhaseThis parameter can be one of the following values:
  • LL_SPI_PHASE_1EDGE
  • LL_SPI_PHASE_2EDGE
Return values
None

Definition at line 456 of file stm32l4xx_ll_spi.h.

457 {
458  MODIFY_REG(SPIx->CR1, SPI_CR1_CPHA, ClockPhase);
459 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_SPI_SetClockPolarity()

__STATIC_INLINE void LL_SPI_SetClockPolarity ( SPI_TypeDef *  SPIx,
uint32_t  ClockPolarity 
)

Set clock polarity.

Note
This bit should not be changed when communication is ongoing. This bit is not used in SPI TI mode. CR1 CPOL LL_SPI_SetClockPolarity
Parameters
SPIxSPI Instance
ClockPolarityThis parameter can be one of the following values:
  • LL_SPI_POLARITY_LOW
  • LL_SPI_POLARITY_HIGH
Return values
None

Definition at line 485 of file stm32l4xx_ll_spi.h.

486 {
487  MODIFY_REG(SPIx->CR1, SPI_CR1_CPOL, ClockPolarity);
488 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_SPI_SetDataWidth()

__STATIC_INLINE void LL_SPI_SetDataWidth ( SPI_TypeDef *  SPIx,
uint32_t  DataWidth 
)

Set frame data width CR2 DS LL_SPI_SetDataWidth.

Parameters
SPIxSPI Instance
DataWidthThis parameter can be one of the following values:
  • LL_SPI_DATAWIDTH_4BIT
  • LL_SPI_DATAWIDTH_5BIT
  • LL_SPI_DATAWIDTH_6BIT
  • LL_SPI_DATAWIDTH_7BIT
  • LL_SPI_DATAWIDTH_8BIT
  • LL_SPI_DATAWIDTH_9BIT
  • LL_SPI_DATAWIDTH_10BIT
  • LL_SPI_DATAWIDTH_11BIT
  • LL_SPI_DATAWIDTH_12BIT
  • LL_SPI_DATAWIDTH_13BIT
  • LL_SPI_DATAWIDTH_14BIT
  • LL_SPI_DATAWIDTH_15BIT
  • LL_SPI_DATAWIDTH_16BIT
Return values
None

Definition at line 628 of file stm32l4xx_ll_spi.h.

629 {
630  MODIFY_REG(SPIx->CR2, SPI_CR2_DS, DataWidth);
631 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_SPI_SetMode()

__STATIC_INLINE void LL_SPI_SetMode ( SPI_TypeDef *  SPIx,
uint32_t  Mode 
)

Set SPI operation mode to Master or Slave.

Note
This bit should not be changed when communication is ongoing. CR1 MSTR LL_SPI_SetMode
CR1 SSI LL_SPI_SetMode
Parameters
SPIxSPI Instance
ModeThis parameter can be one of the following values:
  • LL_SPI_MODE_MASTER
  • LL_SPI_MODE_SLAVE
Return values
None

Definition at line 398 of file stm32l4xx_ll_spi.h.

399 {
400  MODIFY_REG(SPIx->CR1, SPI_CR1_MSTR | SPI_CR1_SSI, Mode);
401 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_SPI_SetRxFIFOThreshold()

__STATIC_INLINE void LL_SPI_SetRxFIFOThreshold ( SPI_TypeDef *  SPIx,
uint32_t  Threshold 
)

Set threshold of RXFIFO that triggers an RXNE event CR2 FRXTH LL_SPI_SetRxFIFOThreshold.

Parameters
SPIxSPI Instance
ThresholdThis parameter can be one of the following values:
  • LL_SPI_RX_FIFO_TH_HALF
  • LL_SPI_RX_FIFO_TH_QUARTER
Return values
None

Definition at line 666 of file stm32l4xx_ll_spi.h.

667 {
668  MODIFY_REG(SPIx->CR2, SPI_CR2_FRXTH, Threshold);
669 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_SPI_SetStandard()

__STATIC_INLINE void LL_SPI_SetStandard ( SPI_TypeDef *  SPIx,
uint32_t  Standard 
)

Set serial protocol used.

Note
This bit should be written only when SPI is disabled (SPE = 0) for correct operation. CR2 FRF LL_SPI_SetStandard
Parameters
SPIxSPI Instance
StandardThis parameter can be one of the following values:
  • LL_SPI_PROTOCOL_MOTOROLA
  • LL_SPI_PROTOCOL_TI
Return values
None

Definition at line 427 of file stm32l4xx_ll_spi.h.

428 {
429  MODIFY_REG(SPIx->CR2, SPI_CR2_FRF, Standard);
430 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_SPI_SetTransferBitOrder()

__STATIC_INLINE void LL_SPI_SetTransferBitOrder ( SPI_TypeDef *  SPIx,
uint32_t  BitOrder 
)

Set transfer bit order.

Note
This bit should not be changed when communication is ongoing. This bit is not used in SPI TI mode. CR1 LSBFIRST LL_SPI_SetTransferBitOrder
Parameters
SPIxSPI Instance
BitOrderThis parameter can be one of the following values:
  • LL_SPI_LSB_FIRST
  • LL_SPI_MSB_FIRST
Return values
None

Definition at line 553 of file stm32l4xx_ll_spi.h.

554 {
555  MODIFY_REG(SPIx->CR1, SPI_CR1_LSBFIRST, BitOrder);
556 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)

◆ LL_SPI_SetTransferDirection()

__STATIC_INLINE void LL_SPI_SetTransferDirection ( SPI_TypeDef *  SPIx,
uint32_t  TransferDirection 
)

Set transfer direction mode.

Note
For Half-Duplex mode, Rx Direction is set by default. In master mode, the MOSI pin is used and in slave mode, the MISO pin is used for Half-Duplex. CR1 RXONLY LL_SPI_SetTransferDirection
CR1 BIDIMODE LL_SPI_SetTransferDirection
CR1 BIDIOE LL_SPI_SetTransferDirection
Parameters
SPIxSPI Instance
TransferDirectionThis parameter can be one of the following values:
  • LL_SPI_FULL_DUPLEX
  • LL_SPI_SIMPLEX_RX
  • LL_SPI_HALF_DUPLEX_RX
  • LL_SPI_HALF_DUPLEX_TX
Return values
None

Definition at line 586 of file stm32l4xx_ll_spi.h.

587 {
588  MODIFY_REG(SPIx->CR1, SPI_CR1_RXONLY | SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE, TransferDirection);
589 }
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)