2 ******************************************************************************
3 * @file stm32f1xx_ll_spi.h
4 * @author MCD Application Team
7 * @brief Header file of SPI LL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F1xx_LL_SPI_H
40 #define __STM32F1xx_LL_SPI_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f1xx.h"
49 /** @addtogroup STM32F1xx_LL_Driver
53 #if defined (SPI1) || defined (SPI2) || defined (SPI3)
55 /** @defgroup SPI_LL SPI
59 /* Private types -------------------------------------------------------------*/
60 /* Private variables ---------------------------------------------------------*/
61 /* Private macros ------------------------------------------------------------*/
63 /* Exported types ------------------------------------------------------------*/
64 #if defined(USE_FULL_LL_DRIVER)
65 /** @defgroup SPI_LL_ES_INIT SPI Exported Init structure
70 * @brief SPI Init structures definition
74 uint32_t TransferDirection
; /*!< Specifies the SPI unidirectional or bidirectional data mode.
75 This parameter can be a value of @ref SPI_LL_EC_TRANSFER_MODE.
77 This feature can be modified afterwards using unitary function @ref LL_SPI_SetTransferDirection().*/
79 uint32_t Mode
; /*!< Specifies the SPI mode (Master/Slave).
80 This parameter can be a value of @ref SPI_LL_EC_MODE.
82 This feature can be modified afterwards using unitary function @ref LL_SPI_SetMode().*/
84 uint32_t DataWidth
; /*!< Specifies the SPI data width.
85 This parameter can be a value of @ref SPI_LL_EC_DATAWIDTH.
87 This feature can be modified afterwards using unitary function @ref LL_SPI_SetDataWidth().*/
89 uint32_t ClockPolarity
; /*!< Specifies the serial clock steady state.
90 This parameter can be a value of @ref SPI_LL_EC_POLARITY.
92 This feature can be modified afterwards using unitary function @ref LL_SPI_SetClockPolarity().*/
94 uint32_t ClockPhase
; /*!< Specifies the clock active edge for the bit capture.
95 This parameter can be a value of @ref SPI_LL_EC_PHASE.
97 This feature can be modified afterwards using unitary function @ref LL_SPI_SetClockPhase().*/
99 uint32_t NSS
; /*!< Specifies whether the NSS signal is managed by hardware (NSS pin) or by software using the SSI bit.
100 This parameter can be a value of @ref SPI_LL_EC_NSS_MODE.
102 This feature can be modified afterwards using unitary function @ref LL_SPI_SetNSSMode().*/
104 uint32_t BaudRate
; /*!< Specifies the BaudRate prescaler value which will be used to configure the transmit and receive SCK clock.
105 This parameter can be a value of @ref SPI_LL_EC_BAUDRATEPRESCALER.
106 @note The communication clock is derived from the master clock. The slave clock does not need to be set.
108 This feature can be modified afterwards using unitary function @ref LL_SPI_SetBaudRatePrescaler().*/
110 uint32_t BitOrder
; /*!< Specifies whether data transfers start from MSB or LSB bit.
111 This parameter can be a value of @ref SPI_LL_EC_BIT_ORDER.
113 This feature can be modified afterwards using unitary function @ref LL_SPI_SetTransferBitOrder().*/
115 uint32_t CRCCalculation
; /*!< Specifies if the CRC calculation is enabled or not.
116 This parameter can be a value of @ref SPI_LL_EC_CRC_CALCULATION.
118 This feature can be modified afterwards using unitary functions @ref LL_SPI_EnableCRC() and @ref LL_SPI_DisableCRC().*/
120 uint32_t CRCPoly
; /*!< Specifies the polynomial used for the CRC calculation.
121 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFF.
123 This feature can be modified afterwards using unitary function @ref LL_SPI_SetCRCPolynomial().*/
125 } LL_SPI_InitTypeDef
;
130 #endif /* USE_FULL_LL_DRIVER */
132 /* Exported constants --------------------------------------------------------*/
133 /** @defgroup SPI_LL_Exported_Constants SPI Exported Constants
137 /** @defgroup SPI_LL_EC_GET_FLAG Get Flags Defines
138 * @brief Flags defines which can be used with LL_SPI_ReadReg function
141 #define LL_SPI_SR_RXNE SPI_SR_RXNE /*!< Rx buffer not empty flag */
142 #define LL_SPI_SR_TXE SPI_SR_TXE /*!< Tx buffer empty flag */
143 #define LL_SPI_SR_BSY SPI_SR_BSY /*!< Busy flag */
144 #define LL_SPI_SR_CRCERR SPI_SR_CRCERR /*!< CRC error flag */
145 #define LL_SPI_SR_MODF SPI_SR_MODF /*!< Mode fault flag */
146 #define LL_SPI_SR_OVR SPI_SR_OVR /*!< Overrun flag */
147 #define LL_SPI_SR_FRE SPI_SR_FRE /*!< TI mode frame format error flag */
152 /** @defgroup SPI_LL_EC_IT IT Defines
153 * @brief IT defines which can be used with LL_SPI_ReadReg and LL_SPI_WriteReg functions
156 #define LL_SPI_CR2_RXNEIE SPI_CR2_RXNEIE /*!< Rx buffer not empty interrupt enable */
157 #define LL_SPI_CR2_TXEIE SPI_CR2_TXEIE /*!< Tx buffer empty interrupt enable */
158 #define LL_SPI_CR2_ERRIE SPI_CR2_ERRIE /*!< Error interrupt enable */
163 /** @defgroup SPI_LL_EC_MODE Operation Mode
166 #define LL_SPI_MODE_MASTER (SPI_CR1_MSTR | SPI_CR1_SSI) /*!< Master configuration */
167 #define LL_SPI_MODE_SLAVE 0x00000000U /*!< Slave configuration */
173 /** @defgroup SPI_LL_EC_PHASE Clock Phase
176 #define LL_SPI_PHASE_1EDGE 0x00000000U /*!< First clock transition is the first data capture edge */
177 #define LL_SPI_PHASE_2EDGE (SPI_CR1_CPHA) /*!< Second clock transition is the first data capture edge */
182 /** @defgroup SPI_LL_EC_POLARITY Clock Polarity
185 #define LL_SPI_POLARITY_LOW 0x00000000U /*!< Clock to 0 when idle */
186 #define LL_SPI_POLARITY_HIGH (SPI_CR1_CPOL) /*!< Clock to 1 when idle */
191 /** @defgroup SPI_LL_EC_BAUDRATEPRESCALER Baud Rate Prescaler
194 #define LL_SPI_BAUDRATEPRESCALER_DIV2 0x00000000U /*!< BaudRate control equal to fPCLK/2 */
195 #define LL_SPI_BAUDRATEPRESCALER_DIV4 (SPI_CR1_BR_0) /*!< BaudRate control equal to fPCLK/4 */
196 #define LL_SPI_BAUDRATEPRESCALER_DIV8 (SPI_CR1_BR_1) /*!< BaudRate control equal to fPCLK/8 */
197 #define LL_SPI_BAUDRATEPRESCALER_DIV16 (SPI_CR1_BR_1 | SPI_CR1_BR_0) /*!< BaudRate control equal to fPCLK/16 */
198 #define LL_SPI_BAUDRATEPRESCALER_DIV32 (SPI_CR1_BR_2) /*!< BaudRate control equal to fPCLK/32 */
199 #define LL_SPI_BAUDRATEPRESCALER_DIV64 (SPI_CR1_BR_2 | SPI_CR1_BR_0) /*!< BaudRate control equal to fPCLK/64 */
200 #define LL_SPI_BAUDRATEPRESCALER_DIV128 (SPI_CR1_BR_2 | SPI_CR1_BR_1) /*!< BaudRate control equal to fPCLK/128 */
201 #define LL_SPI_BAUDRATEPRESCALER_DIV256 (SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0) /*!< BaudRate control equal to fPCLK/256 */
206 /** @defgroup SPI_LL_EC_BIT_ORDER Transmission Bit Order
209 #define LL_SPI_LSB_FIRST (SPI_CR1_LSBFIRST) /*!< Data is transmitted/received with the LSB first */
210 #define LL_SPI_MSB_FIRST 0x00000000U /*!< Data is transmitted/received with the MSB first */
215 /** @defgroup SPI_LL_EC_TRANSFER_MODE Transfer Mode
218 #define LL_SPI_FULL_DUPLEX 0x00000000U /*!< Full-Duplex mode. Rx and Tx transfer on 2 lines */
219 #define LL_SPI_SIMPLEX_RX (SPI_CR1_RXONLY) /*!< Simplex Rx mode. Rx transfer only on 1 line */
220 #define LL_SPI_HALF_DUPLEX_RX (SPI_CR1_BIDIMODE) /*!< Half-Duplex Rx mode. Rx transfer on 1 line */
221 #define LL_SPI_HALF_DUPLEX_TX (SPI_CR1_BIDIMODE | SPI_CR1_BIDIOE) /*!< Half-Duplex Tx mode. Tx transfer on 1 line */
226 /** @defgroup SPI_LL_EC_NSS_MODE Slave Select Pin Mode
229 #define LL_SPI_NSS_SOFT (SPI_CR1_SSM) /*!< NSS managed internally. NSS pin not used and free */
230 #define LL_SPI_NSS_HARD_INPUT 0x00000000U /*!< NSS pin used in Input. Only used in Master mode */
231 #define LL_SPI_NSS_HARD_OUTPUT (((uint32_t)SPI_CR2_SSOE << 16U)) /*!< NSS pin used in Output. Only used in Slave mode as chip select */
236 /** @defgroup SPI_LL_EC_DATAWIDTH Datawidth
239 #define LL_SPI_DATAWIDTH_8BIT 0x00000000U /*!< Data length for SPI transfer: 8 bits */
240 #define LL_SPI_DATAWIDTH_16BIT (SPI_CR1_DFF) /*!< Data length for SPI transfer: 16 bits */
244 #if defined(USE_FULL_LL_DRIVER)
246 /** @defgroup SPI_LL_EC_CRC_CALCULATION CRC Calculation
249 #define LL_SPI_CRCCALCULATION_DISABLE 0x00000000U /*!< CRC calculation disabled */
250 #define LL_SPI_CRCCALCULATION_ENABLE (SPI_CR1_CRCEN) /*!< CRC calculation enabled */
254 #endif /* USE_FULL_LL_DRIVER */
260 /* Exported macro ------------------------------------------------------------*/
261 /** @defgroup SPI_LL_Exported_Macros SPI Exported Macros
265 /** @defgroup SPI_LL_EM_WRITE_READ Common Write and read registers Macros
270 * @brief Write a value in SPI register
271 * @param __INSTANCE__ SPI Instance
272 * @param __REG__ Register to be written
273 * @param __VALUE__ Value to be written in the register
276 #define LL_SPI_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
279 * @brief Read a value in SPI register
280 * @param __INSTANCE__ SPI Instance
281 * @param __REG__ Register to be read
282 * @retval Register value
284 #define LL_SPI_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
293 /* Exported functions --------------------------------------------------------*/
294 /** @defgroup SPI_LL_Exported_Functions SPI Exported Functions
298 /** @defgroup SPI_LL_EF_Configuration Configuration
303 * @brief Enable SPI peripheral
304 * @rmtoll CR1 SPE LL_SPI_Enable
305 * @param SPIx SPI Instance
308 __STATIC_INLINE
void LL_SPI_Enable(SPI_TypeDef
*SPIx
)
310 SET_BIT(SPIx
->CR1
, SPI_CR1_SPE
);
314 * @brief Disable SPI peripheral
315 * @note When disabling the SPI, follow the procedure described in the Reference Manual.
316 * @rmtoll CR1 SPE LL_SPI_Disable
317 * @param SPIx SPI Instance
320 __STATIC_INLINE
void LL_SPI_Disable(SPI_TypeDef
*SPIx
)
322 CLEAR_BIT(SPIx
->CR1
, SPI_CR1_SPE
);
326 * @brief Check if SPI peripheral is enabled
327 * @rmtoll CR1 SPE LL_SPI_IsEnabled
328 * @param SPIx SPI Instance
329 * @retval State of bit (1 or 0).
331 __STATIC_INLINE
uint32_t LL_SPI_IsEnabled(SPI_TypeDef
*SPIx
)
333 return (READ_BIT(SPIx
->CR1
, SPI_CR1_SPE
) == (SPI_CR1_SPE
));
337 * @brief Set SPI operation mode to Master or Slave
338 * @note This bit should not be changed when communication is ongoing.
339 * @rmtoll CR1 MSTR LL_SPI_SetMode\n
340 * CR1 SSI LL_SPI_SetMode
341 * @param SPIx SPI Instance
342 * @param Mode This parameter can be one of the following values:
343 * @arg @ref LL_SPI_MODE_MASTER
344 * @arg @ref LL_SPI_MODE_SLAVE
347 __STATIC_INLINE
void LL_SPI_SetMode(SPI_TypeDef
*SPIx
, uint32_t Mode
)
349 MODIFY_REG(SPIx
->CR1
, SPI_CR1_MSTR
| SPI_CR1_SSI
, Mode
);
353 * @brief Get SPI operation mode (Master or Slave)
354 * @rmtoll CR1 MSTR LL_SPI_GetMode\n
355 * CR1 SSI LL_SPI_GetMode
356 * @param SPIx SPI Instance
357 * @retval Returned value can be one of the following values:
358 * @arg @ref LL_SPI_MODE_MASTER
359 * @arg @ref LL_SPI_MODE_SLAVE
361 __STATIC_INLINE
uint32_t LL_SPI_GetMode(SPI_TypeDef
*SPIx
)
363 return (uint32_t)(READ_BIT(SPIx
->CR1
, SPI_CR1_MSTR
| SPI_CR1_SSI
));
368 * @brief Set clock phase
369 * @note This bit should not be changed when communication is ongoing.
370 * This bit is not used in SPI TI mode.
371 * @rmtoll CR1 CPHA LL_SPI_SetClockPhase
372 * @param SPIx SPI Instance
373 * @param ClockPhase This parameter can be one of the following values:
374 * @arg @ref LL_SPI_PHASE_1EDGE
375 * @arg @ref LL_SPI_PHASE_2EDGE
378 __STATIC_INLINE
void LL_SPI_SetClockPhase(SPI_TypeDef
*SPIx
, uint32_t ClockPhase
)
380 MODIFY_REG(SPIx
->CR1
, SPI_CR1_CPHA
, ClockPhase
);
384 * @brief Get clock phase
385 * @rmtoll CR1 CPHA LL_SPI_GetClockPhase
386 * @param SPIx SPI Instance
387 * @retval Returned value can be one of the following values:
388 * @arg @ref LL_SPI_PHASE_1EDGE
389 * @arg @ref LL_SPI_PHASE_2EDGE
391 __STATIC_INLINE
uint32_t LL_SPI_GetClockPhase(SPI_TypeDef
*SPIx
)
393 return (uint32_t)(READ_BIT(SPIx
->CR1
, SPI_CR1_CPHA
));
397 * @brief Set clock polarity
398 * @note This bit should not be changed when communication is ongoing.
399 * This bit is not used in SPI TI mode.
400 * @rmtoll CR1 CPOL LL_SPI_SetClockPolarity
401 * @param SPIx SPI Instance
402 * @param ClockPolarity This parameter can be one of the following values:
403 * @arg @ref LL_SPI_POLARITY_LOW
404 * @arg @ref LL_SPI_POLARITY_HIGH
407 __STATIC_INLINE
void LL_SPI_SetClockPolarity(SPI_TypeDef
*SPIx
, uint32_t ClockPolarity
)
409 MODIFY_REG(SPIx
->CR1
, SPI_CR1_CPOL
, ClockPolarity
);
413 * @brief Get clock polarity
414 * @rmtoll CR1 CPOL LL_SPI_GetClockPolarity
415 * @param SPIx SPI Instance
416 * @retval Returned value can be one of the following values:
417 * @arg @ref LL_SPI_POLARITY_LOW
418 * @arg @ref LL_SPI_POLARITY_HIGH
420 __STATIC_INLINE
uint32_t LL_SPI_GetClockPolarity(SPI_TypeDef
*SPIx
)
422 return (uint32_t)(READ_BIT(SPIx
->CR1
, SPI_CR1_CPOL
));
426 * @brief Set baud rate prescaler
427 * @note These bits should not be changed when communication is ongoing. SPI BaudRate = fPCLK/Prescaler.
428 * @rmtoll CR1 BR LL_SPI_SetBaudRatePrescaler
429 * @param SPIx SPI Instance
430 * @param BaudRate This parameter can be one of the following values:
431 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV2
432 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV4
433 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV8
434 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV16
435 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV32
436 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV64
437 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV128
438 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV256
441 __STATIC_INLINE
void LL_SPI_SetBaudRatePrescaler(SPI_TypeDef
*SPIx
, uint32_t BaudRate
)
443 MODIFY_REG(SPIx
->CR1
, SPI_CR1_BR
, BaudRate
);
447 * @brief Get baud rate prescaler
448 * @rmtoll CR1 BR LL_SPI_GetBaudRatePrescaler
449 * @param SPIx SPI Instance
450 * @retval Returned value can be one of the following values:
451 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV2
452 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV4
453 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV8
454 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV16
455 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV32
456 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV64
457 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV128
458 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV256
460 __STATIC_INLINE
uint32_t LL_SPI_GetBaudRatePrescaler(SPI_TypeDef
*SPIx
)
462 return (uint32_t)(READ_BIT(SPIx
->CR1
, SPI_CR1_BR
));
466 * @brief Set transfer bit order
467 * @note This bit should not be changed when communication is ongoing. This bit is not used in SPI TI mode.
468 * @rmtoll CR1 LSBFIRST LL_SPI_SetTransferBitOrder
469 * @param SPIx SPI Instance
470 * @param BitOrder This parameter can be one of the following values:
471 * @arg @ref LL_SPI_LSB_FIRST
472 * @arg @ref LL_SPI_MSB_FIRST
475 __STATIC_INLINE
void LL_SPI_SetTransferBitOrder(SPI_TypeDef
*SPIx
, uint32_t BitOrder
)
477 MODIFY_REG(SPIx
->CR1
, SPI_CR1_LSBFIRST
, BitOrder
);
481 * @brief Get transfer bit order
482 * @rmtoll CR1 LSBFIRST LL_SPI_GetTransferBitOrder
483 * @param SPIx SPI Instance
484 * @retval Returned value can be one of the following values:
485 * @arg @ref LL_SPI_LSB_FIRST
486 * @arg @ref LL_SPI_MSB_FIRST
488 __STATIC_INLINE
uint32_t LL_SPI_GetTransferBitOrder(SPI_TypeDef
*SPIx
)
490 return (uint32_t)(READ_BIT(SPIx
->CR1
, SPI_CR1_LSBFIRST
));
494 * @brief Set transfer direction mode
495 * @note For Half-Duplex mode, Rx Direction is set by default.
496 * In master mode, the MOSI pin is used and in slave mode, the MISO pin is used for Half-Duplex.
497 * @rmtoll CR1 RXONLY LL_SPI_SetTransferDirection\n
498 * CR1 BIDIMODE LL_SPI_SetTransferDirection\n
499 * CR1 BIDIOE LL_SPI_SetTransferDirection
500 * @param SPIx SPI Instance
501 * @param TransferDirection This parameter can be one of the following values:
502 * @arg @ref LL_SPI_FULL_DUPLEX
503 * @arg @ref LL_SPI_SIMPLEX_RX
504 * @arg @ref LL_SPI_HALF_DUPLEX_RX
505 * @arg @ref LL_SPI_HALF_DUPLEX_TX
508 __STATIC_INLINE
void LL_SPI_SetTransferDirection(SPI_TypeDef
*SPIx
, uint32_t TransferDirection
)
510 MODIFY_REG(SPIx
->CR1
, SPI_CR1_RXONLY
| SPI_CR1_BIDIMODE
| SPI_CR1_BIDIOE
, TransferDirection
);
514 * @brief Get transfer direction mode
515 * @rmtoll CR1 RXONLY LL_SPI_GetTransferDirection\n
516 * CR1 BIDIMODE LL_SPI_GetTransferDirection\n
517 * CR1 BIDIOE LL_SPI_GetTransferDirection
518 * @param SPIx SPI Instance
519 * @retval Returned value can be one of the following values:
520 * @arg @ref LL_SPI_FULL_DUPLEX
521 * @arg @ref LL_SPI_SIMPLEX_RX
522 * @arg @ref LL_SPI_HALF_DUPLEX_RX
523 * @arg @ref LL_SPI_HALF_DUPLEX_TX
525 __STATIC_INLINE
uint32_t LL_SPI_GetTransferDirection(SPI_TypeDef
*SPIx
)
527 return (uint32_t)(READ_BIT(SPIx
->CR1
, SPI_CR1_RXONLY
| SPI_CR1_BIDIMODE
| SPI_CR1_BIDIOE
));
531 * @brief Set frame data width
532 * @rmtoll CR1 DFF LL_SPI_SetDataWidth
533 * @param SPIx SPI Instance
534 * @param DataWidth This parameter can be one of the following values:
535 * @arg @ref LL_SPI_DATAWIDTH_8BIT
536 * @arg @ref LL_SPI_DATAWIDTH_16BIT
539 __STATIC_INLINE
void LL_SPI_SetDataWidth(SPI_TypeDef
*SPIx
, uint32_t DataWidth
)
541 MODIFY_REG(SPIx
->CR1
, SPI_CR1_DFF
, DataWidth
);
545 * @brief Get frame data width
546 * @rmtoll CR1 DFF LL_SPI_GetDataWidth
547 * @param SPIx SPI Instance
548 * @retval Returned value can be one of the following values:
549 * @arg @ref LL_SPI_DATAWIDTH_8BIT
550 * @arg @ref LL_SPI_DATAWIDTH_16BIT
552 __STATIC_INLINE
uint32_t LL_SPI_GetDataWidth(SPI_TypeDef
*SPIx
)
554 return (uint32_t)(READ_BIT(SPIx
->CR1
, SPI_CR1_DFF
));
561 /** @defgroup SPI_LL_EF_CRC_Management CRC Management
567 * @note This bit should be written only when SPI is disabled (SPE = 0) for correct operation.
568 * @rmtoll CR1 CRCEN LL_SPI_EnableCRC
569 * @param SPIx SPI Instance
572 __STATIC_INLINE
void LL_SPI_EnableCRC(SPI_TypeDef
*SPIx
)
574 SET_BIT(SPIx
->CR1
, SPI_CR1_CRCEN
);
579 * @note This bit should be written only when SPI is disabled (SPE = 0) for correct operation.
580 * @rmtoll CR1 CRCEN LL_SPI_DisableCRC
581 * @param SPIx SPI Instance
584 __STATIC_INLINE
void LL_SPI_DisableCRC(SPI_TypeDef
*SPIx
)
586 CLEAR_BIT(SPIx
->CR1
, SPI_CR1_CRCEN
);
590 * @brief Check if CRC is enabled
591 * @note This bit should be written only when SPI is disabled (SPE = 0) for correct operation.
592 * @rmtoll CR1 CRCEN LL_SPI_IsEnabledCRC
593 * @param SPIx SPI Instance
594 * @retval State of bit (1 or 0).
596 __STATIC_INLINE
uint32_t LL_SPI_IsEnabledCRC(SPI_TypeDef
*SPIx
)
598 return (READ_BIT(SPIx
->CR1
, SPI_CR1_CRCEN
) == (SPI_CR1_CRCEN
));
602 * @brief Set CRCNext to transfer CRC on the line
603 * @note This bit has to be written as soon as the last data is written in the SPIx_DR register.
604 * @rmtoll CR1 CRCNEXT LL_SPI_SetCRCNext
605 * @param SPIx SPI Instance
608 __STATIC_INLINE
void LL_SPI_SetCRCNext(SPI_TypeDef
*SPIx
)
610 SET_BIT(SPIx
->CR1
, SPI_CR1_CRCNEXT
);
614 * @brief Set polynomial for CRC calculation
615 * @rmtoll CRCPR CRCPOLY LL_SPI_SetCRCPolynomial
616 * @param SPIx SPI Instance
617 * @param CRCPoly This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFFFF
620 __STATIC_INLINE
void LL_SPI_SetCRCPolynomial(SPI_TypeDef
*SPIx
, uint32_t CRCPoly
)
622 WRITE_REG(SPIx
->CRCPR
, (uint16_t)CRCPoly
);
626 * @brief Get polynomial for CRC calculation
627 * @rmtoll CRCPR CRCPOLY LL_SPI_GetCRCPolynomial
628 * @param SPIx SPI Instance
629 * @retval Returned value is a number between Min_Data = 0x00 and Max_Data = 0xFFFF
631 __STATIC_INLINE
uint32_t LL_SPI_GetCRCPolynomial(SPI_TypeDef
*SPIx
)
633 return (uint32_t)(READ_REG(SPIx
->CRCPR
));
638 * @rmtoll RXCRCR RXCRC LL_SPI_GetRxCRC
639 * @param SPIx SPI Instance
640 * @retval Returned value is a number between Min_Data = 0x00 and Max_Data = 0xFFFF
642 __STATIC_INLINE
uint32_t LL_SPI_GetRxCRC(SPI_TypeDef
*SPIx
)
644 return (uint32_t)(READ_REG(SPIx
->RXCRCR
));
649 * @rmtoll TXCRCR TXCRC LL_SPI_GetTxCRC
650 * @param SPIx SPI Instance
651 * @retval Returned value is a number between Min_Data = 0x00 and Max_Data = 0xFFFF
653 __STATIC_INLINE
uint32_t LL_SPI_GetTxCRC(SPI_TypeDef
*SPIx
)
655 return (uint32_t)(READ_REG(SPIx
->TXCRCR
));
662 /** @defgroup SPI_LL_EF_NSS_Management Slave Select Pin Management
667 * @brief Set NSS mode
668 * @note LL_SPI_NSS_SOFT Mode is not used in SPI TI mode.
669 * @rmtoll CR1 SSM LL_SPI_SetNSSMode\n
670 * @rmtoll CR2 SSOE LL_SPI_SetNSSMode
671 * @param SPIx SPI Instance
672 * @param NSS This parameter can be one of the following values:
673 * @arg @ref LL_SPI_NSS_SOFT
674 * @arg @ref LL_SPI_NSS_HARD_INPUT
675 * @arg @ref LL_SPI_NSS_HARD_OUTPUT
678 __STATIC_INLINE
void LL_SPI_SetNSSMode(SPI_TypeDef
*SPIx
, uint32_t NSS
)
680 MODIFY_REG(SPIx
->CR1
, SPI_CR1_SSM
, NSS
);
681 MODIFY_REG(SPIx
->CR2
, SPI_CR2_SSOE
, ((uint32_t)(NSS
>> 16U)));
685 * @brief Get NSS mode
686 * @rmtoll CR1 SSM LL_SPI_GetNSSMode\n
687 * @rmtoll CR2 SSOE LL_SPI_GetNSSMode
688 * @param SPIx SPI Instance
689 * @retval Returned value can be one of the following values:
690 * @arg @ref LL_SPI_NSS_SOFT
691 * @arg @ref LL_SPI_NSS_HARD_INPUT
692 * @arg @ref LL_SPI_NSS_HARD_OUTPUT
694 __STATIC_INLINE
uint32_t LL_SPI_GetNSSMode(SPI_TypeDef
*SPIx
)
696 register uint32_t Ssm
= (READ_BIT(SPIx
->CR1
, SPI_CR1_SSM
));
697 register uint32_t Ssoe
= (READ_BIT(SPIx
->CR2
, SPI_CR2_SSOE
) << 16U);
705 /** @defgroup SPI_LL_EF_FLAG_Management FLAG Management
710 * @brief Check if Rx buffer is not empty
711 * @rmtoll SR RXNE LL_SPI_IsActiveFlag_RXNE
712 * @param SPIx SPI Instance
713 * @retval State of bit (1 or 0).
715 __STATIC_INLINE
uint32_t LL_SPI_IsActiveFlag_RXNE(SPI_TypeDef
*SPIx
)
717 return (READ_BIT(SPIx
->SR
, SPI_SR_RXNE
) == (SPI_SR_RXNE
));
721 * @brief Check if Tx buffer is empty
722 * @rmtoll SR TXE LL_SPI_IsActiveFlag_TXE
723 * @param SPIx SPI Instance
724 * @retval State of bit (1 or 0).
726 __STATIC_INLINE
uint32_t LL_SPI_IsActiveFlag_TXE(SPI_TypeDef
*SPIx
)
728 return (READ_BIT(SPIx
->SR
, SPI_SR_TXE
) == (SPI_SR_TXE
));
732 * @brief Get CRC error flag
733 * @rmtoll SR CRCERR LL_SPI_IsActiveFlag_CRCERR
734 * @param SPIx SPI Instance
735 * @retval State of bit (1 or 0).
737 __STATIC_INLINE
uint32_t LL_SPI_IsActiveFlag_CRCERR(SPI_TypeDef
*SPIx
)
739 return (READ_BIT(SPIx
->SR
, SPI_SR_CRCERR
) == (SPI_SR_CRCERR
));
743 * @brief Get mode fault error flag
744 * @rmtoll SR MODF LL_SPI_IsActiveFlag_MODF
745 * @param SPIx SPI Instance
746 * @retval State of bit (1 or 0).
748 __STATIC_INLINE
uint32_t LL_SPI_IsActiveFlag_MODF(SPI_TypeDef
*SPIx
)
750 return (READ_BIT(SPIx
->SR
, SPI_SR_MODF
) == (SPI_SR_MODF
));
754 * @brief Get overrun error flag
755 * @rmtoll SR OVR LL_SPI_IsActiveFlag_OVR
756 * @param SPIx SPI Instance
757 * @retval State of bit (1 or 0).
759 __STATIC_INLINE
uint32_t LL_SPI_IsActiveFlag_OVR(SPI_TypeDef
*SPIx
)
761 return (READ_BIT(SPIx
->SR
, SPI_SR_OVR
) == (SPI_SR_OVR
));
765 * @brief Get busy flag
766 * @note The BSY flag is cleared under any one of the following conditions:
767 * -When the SPI is correctly disabled
768 * -When a fault is detected in Master mode (MODF bit set to 1)
769 * -In Master mode, when it finishes a data transmission and no new data is ready to be
771 * -In Slave mode, when the BSY flag is set to '0' for at least one SPI clock cycle between
772 * each data transfer.
773 * @rmtoll SR BSY LL_SPI_IsActiveFlag_BSY
774 * @param SPIx SPI Instance
775 * @retval State of bit (1 or 0).
777 __STATIC_INLINE
uint32_t LL_SPI_IsActiveFlag_BSY(SPI_TypeDef
*SPIx
)
779 return (READ_BIT(SPIx
->SR
, SPI_SR_BSY
) == (SPI_SR_BSY
));
784 * @brief Clear CRC error flag
785 * @rmtoll SR CRCERR LL_SPI_ClearFlag_CRCERR
786 * @param SPIx SPI Instance
789 __STATIC_INLINE
void LL_SPI_ClearFlag_CRCERR(SPI_TypeDef
*SPIx
)
791 CLEAR_BIT(SPIx
->SR
, SPI_SR_CRCERR
);
795 * @brief Clear mode fault error flag
796 * @note Clearing this flag is done by a read access to the SPIx_SR
797 * register followed by a write access to the SPIx_CR1 register
798 * @rmtoll SR MODF LL_SPI_ClearFlag_MODF
799 * @param SPIx SPI Instance
802 __STATIC_INLINE
void LL_SPI_ClearFlag_MODF(SPI_TypeDef
*SPIx
)
804 __IO
uint32_t tmpreg
;
807 tmpreg
= CLEAR_BIT(SPIx
->CR1
, SPI_CR1_SPE
);
812 * @brief Clear overrun error flag
813 * @note Clearing this flag is done by a read access to the SPIx_DR
814 * register followed by a read access to the SPIx_SR register
815 * @rmtoll SR OVR LL_SPI_ClearFlag_OVR
816 * @param SPIx SPI Instance
819 __STATIC_INLINE
void LL_SPI_ClearFlag_OVR(SPI_TypeDef
*SPIx
)
821 __IO
uint32_t tmpreg
;
833 /** @defgroup SPI_LL_EF_IT_Management Interrupt Management
838 * @brief Enable error interrupt
839 * @note This bit controls the generation of an interrupt when an error condition occurs (CRCERR, OVR, MODF in SPI mode, FRE at TI mode).
840 * @rmtoll CR2 ERRIE LL_SPI_EnableIT_ERR
841 * @param SPIx SPI Instance
844 __STATIC_INLINE
void LL_SPI_EnableIT_ERR(SPI_TypeDef
*SPIx
)
846 SET_BIT(SPIx
->CR2
, SPI_CR2_ERRIE
);
850 * @brief Enable Rx buffer not empty interrupt
851 * @rmtoll CR2 RXNEIE LL_SPI_EnableIT_RXNE
852 * @param SPIx SPI Instance
855 __STATIC_INLINE
void LL_SPI_EnableIT_RXNE(SPI_TypeDef
*SPIx
)
857 SET_BIT(SPIx
->CR2
, SPI_CR2_RXNEIE
);
861 * @brief Enable Tx buffer empty interrupt
862 * @rmtoll CR2 TXEIE LL_SPI_EnableIT_TXE
863 * @param SPIx SPI Instance
866 __STATIC_INLINE
void LL_SPI_EnableIT_TXE(SPI_TypeDef
*SPIx
)
868 SET_BIT(SPIx
->CR2
, SPI_CR2_TXEIE
);
872 * @brief Disable error interrupt
873 * @note This bit controls the generation of an interrupt when an error condition occurs (CRCERR, OVR, MODF in SPI mode, FRE at TI mode).
874 * @rmtoll CR2 ERRIE LL_SPI_DisableIT_ERR
875 * @param SPIx SPI Instance
878 __STATIC_INLINE
void LL_SPI_DisableIT_ERR(SPI_TypeDef
*SPIx
)
880 CLEAR_BIT(SPIx
->CR2
, SPI_CR2_ERRIE
);
884 * @brief Disable Rx buffer not empty interrupt
885 * @rmtoll CR2 RXNEIE LL_SPI_DisableIT_RXNE
886 * @param SPIx SPI Instance
889 __STATIC_INLINE
void LL_SPI_DisableIT_RXNE(SPI_TypeDef
*SPIx
)
891 CLEAR_BIT(SPIx
->CR2
, SPI_CR2_RXNEIE
);
895 * @brief Disable Tx buffer empty interrupt
896 * @rmtoll CR2 TXEIE LL_SPI_DisableIT_TXE
897 * @param SPIx SPI Instance
900 __STATIC_INLINE
void LL_SPI_DisableIT_TXE(SPI_TypeDef
*SPIx
)
902 CLEAR_BIT(SPIx
->CR2
, SPI_CR2_TXEIE
);
906 * @brief Check if error interrupt is enabled
907 * @rmtoll CR2 ERRIE LL_SPI_IsEnabledIT_ERR
908 * @param SPIx SPI Instance
909 * @retval State of bit (1 or 0).
911 __STATIC_INLINE
uint32_t LL_SPI_IsEnabledIT_ERR(SPI_TypeDef
*SPIx
)
913 return (READ_BIT(SPIx
->CR2
, SPI_CR2_ERRIE
) == (SPI_CR2_ERRIE
));
917 * @brief Check if Rx buffer not empty interrupt is enabled
918 * @rmtoll CR2 RXNEIE LL_SPI_IsEnabledIT_RXNE
919 * @param SPIx SPI Instance
920 * @retval State of bit (1 or 0).
922 __STATIC_INLINE
uint32_t LL_SPI_IsEnabledIT_RXNE(SPI_TypeDef
*SPIx
)
924 return (READ_BIT(SPIx
->CR2
, SPI_CR2_RXNEIE
) == (SPI_CR2_RXNEIE
));
928 * @brief Check if Tx buffer empty interrupt
929 * @rmtoll CR2 TXEIE LL_SPI_IsEnabledIT_TXE
930 * @param SPIx SPI Instance
931 * @retval State of bit (1 or 0).
933 __STATIC_INLINE
uint32_t LL_SPI_IsEnabledIT_TXE(SPI_TypeDef
*SPIx
)
935 return (READ_BIT(SPIx
->CR2
, SPI_CR2_TXEIE
) == (SPI_CR2_TXEIE
));
942 /** @defgroup SPI_LL_EF_DMA_Management DMA Management
947 * @brief Enable DMA Rx
948 * @rmtoll CR2 RXDMAEN LL_SPI_EnableDMAReq_RX
949 * @param SPIx SPI Instance
952 __STATIC_INLINE
void LL_SPI_EnableDMAReq_RX(SPI_TypeDef
*SPIx
)
954 SET_BIT(SPIx
->CR2
, SPI_CR2_RXDMAEN
);
958 * @brief Disable DMA Rx
959 * @rmtoll CR2 RXDMAEN LL_SPI_DisableDMAReq_RX
960 * @param SPIx SPI Instance
963 __STATIC_INLINE
void LL_SPI_DisableDMAReq_RX(SPI_TypeDef
*SPIx
)
965 CLEAR_BIT(SPIx
->CR2
, SPI_CR2_RXDMAEN
);
969 * @brief Check if DMA Rx is enabled
970 * @rmtoll CR2 RXDMAEN LL_SPI_IsEnabledDMAReq_RX
971 * @param SPIx SPI Instance
972 * @retval State of bit (1 or 0).
974 __STATIC_INLINE
uint32_t LL_SPI_IsEnabledDMAReq_RX(SPI_TypeDef
*SPIx
)
976 return (READ_BIT(SPIx
->CR2
, SPI_CR2_RXDMAEN
) == (SPI_CR2_RXDMAEN
));
980 * @brief Enable DMA Tx
981 * @rmtoll CR2 TXDMAEN LL_SPI_EnableDMAReq_TX
982 * @param SPIx SPI Instance
985 __STATIC_INLINE
void LL_SPI_EnableDMAReq_TX(SPI_TypeDef
*SPIx
)
987 SET_BIT(SPIx
->CR2
, SPI_CR2_TXDMAEN
);
991 * @brief Disable DMA Tx
992 * @rmtoll CR2 TXDMAEN LL_SPI_DisableDMAReq_TX
993 * @param SPIx SPI Instance
996 __STATIC_INLINE
void LL_SPI_DisableDMAReq_TX(SPI_TypeDef
*SPIx
)
998 CLEAR_BIT(SPIx
->CR2
, SPI_CR2_TXDMAEN
);
1002 * @brief Check if DMA Tx is enabled
1003 * @rmtoll CR2 TXDMAEN LL_SPI_IsEnabledDMAReq_TX
1004 * @param SPIx SPI Instance
1005 * @retval State of bit (1 or 0).
1007 __STATIC_INLINE
uint32_t LL_SPI_IsEnabledDMAReq_TX(SPI_TypeDef
*SPIx
)
1009 return (READ_BIT(SPIx
->CR2
, SPI_CR2_TXDMAEN
) == (SPI_CR2_TXDMAEN
));
1013 * @brief Get the data register address used for DMA transfer
1014 * @rmtoll DR DR LL_SPI_DMA_GetRegAddr
1015 * @param SPIx SPI Instance
1016 * @retval Address of data register
1018 __STATIC_INLINE
uint32_t LL_SPI_DMA_GetRegAddr(SPI_TypeDef
*SPIx
)
1020 return (uint32_t) & (SPIx
->DR
);
1027 /** @defgroup SPI_LL_EF_DATA_Management DATA Management
1032 * @brief Read 8-Bits in the data register
1033 * @rmtoll DR DR LL_SPI_ReceiveData8
1034 * @param SPIx SPI Instance
1035 * @retval RxData Value between Min_Data=0x00 and Max_Data=0xFF
1037 __STATIC_INLINE
uint8_t LL_SPI_ReceiveData8(SPI_TypeDef
*SPIx
)
1039 return (uint8_t)(READ_REG(SPIx
->DR
));
1043 * @brief Read 16-Bits in the data register
1044 * @rmtoll DR DR LL_SPI_ReceiveData16
1045 * @param SPIx SPI Instance
1046 * @retval RxData Value between Min_Data=0x00 and Max_Data=0xFFFF
1048 __STATIC_INLINE
uint16_t LL_SPI_ReceiveData16(SPI_TypeDef
*SPIx
)
1050 return (uint16_t)(READ_REG(SPIx
->DR
));
1054 * @brief Write 8-Bits in the data register
1055 * @rmtoll DR DR LL_SPI_TransmitData8
1056 * @param SPIx SPI Instance
1057 * @param TxData Value between Min_Data=0x00 and Max_Data=0xFF
1060 __STATIC_INLINE
void LL_SPI_TransmitData8(SPI_TypeDef
*SPIx
, uint8_t TxData
)
1066 * @brief Write 16-Bits in the data register
1067 * @rmtoll DR DR LL_SPI_TransmitData16
1068 * @param SPIx SPI Instance
1069 * @param TxData Value between Min_Data=0x00 and Max_Data=0xFFFF
1072 __STATIC_INLINE
void LL_SPI_TransmitData16(SPI_TypeDef
*SPIx
, uint16_t TxData
)
1080 #if defined(USE_FULL_LL_DRIVER)
1081 /** @defgroup SPI_LL_EF_Init Initialization and de-initialization functions
1085 ErrorStatus
LL_SPI_DeInit(SPI_TypeDef
*SPIx
);
1086 ErrorStatus
LL_SPI_Init(SPI_TypeDef
*SPIx
, LL_SPI_InitTypeDef
*SPI_InitStruct
);
1087 void LL_SPI_StructInit(LL_SPI_InitTypeDef
*SPI_InitStruct
);
1092 #endif /* USE_FULL_LL_DRIVER */
1101 #if defined(SPI_I2S_SUPPORT)
1102 /** @defgroup I2S_LL I2S
1106 /* Private variables ---------------------------------------------------------*/
1107 /* Private constants ---------------------------------------------------------*/
1108 /* Private macros ------------------------------------------------------------*/
1110 /* Exported types ------------------------------------------------------------*/
1111 #if defined(USE_FULL_LL_DRIVER)
1112 /** @defgroup I2S_LL_ES_INIT I2S Exported Init structure
1117 * @brief I2S Init structure definition
1122 uint32_t Mode
; /*!< Specifies the I2S operating mode.
1123 This parameter can be a value of @ref I2S_LL_EC_MODE
1125 This feature can be modified afterwards using unitary function @ref LL_I2S_SetTransferMode().*/
1127 uint32_t Standard
; /*!< Specifies the standard used for the I2S communication.
1128 This parameter can be a value of @ref I2S_LL_EC_STANDARD
1130 This feature can be modified afterwards using unitary function @ref LL_I2S_SetStandard().*/
1133 uint32_t DataFormat
; /*!< Specifies the data format for the I2S communication.
1134 This parameter can be a value of @ref I2S_LL_EC_DATA_FORMAT
1136 This feature can be modified afterwards using unitary function @ref LL_I2S_SetDataFormat().*/
1139 uint32_t MCLKOutput
; /*!< Specifies whether the I2S MCLK output is enabled or not.
1140 This parameter can be a value of @ref I2S_LL_EC_MCLK_OUTPUT
1142 This feature can be modified afterwards using unitary functions @ref LL_I2S_EnableMasterClock() or @ref LL_I2S_DisableMasterClock.*/
1145 uint32_t AudioFreq
; /*!< Specifies the frequency selected for the I2S communication.
1146 This parameter can be a value of @ref I2S_LL_EC_AUDIO_FREQ
1148 Audio Frequency can be modified afterwards using Reference manual formulas to calculate Prescaler Linear, Parity
1149 and unitary functions @ref LL_I2S_SetPrescalerLinear() and @ref LL_I2S_SetPrescalerParity() to set it.*/
1152 uint32_t ClockPolarity
; /*!< Specifies the idle state of the I2S clock.
1153 This parameter can be a value of @ref I2S_LL_EC_POLARITY
1155 This feature can be modified afterwards using unitary function @ref LL_I2S_SetClockPolarity().*/
1157 } LL_I2S_InitTypeDef
;
1162 #endif /*USE_FULL_LL_DRIVER*/
1164 /* Exported constants --------------------------------------------------------*/
1165 /** @defgroup I2S_LL_Exported_Constants I2S Exported Constants
1169 /** @defgroup I2S_LL_EC_GET_FLAG Get Flags Defines
1170 * @brief Flags defines which can be used with LL_I2S_ReadReg function
1173 #define LL_I2S_SR_RXNE LL_SPI_SR_RXNE /*!< Rx buffer not empty flag */
1174 #define LL_I2S_SR_TXE LL_SPI_SR_TXE /*!< Tx buffer empty flag */
1175 #define LL_I2S_SR_BSY LL_SPI_SR_BSY /*!< Busy flag */
1176 #define LL_I2S_SR_UDR SPI_SR_UDR /*!< Underrun flag */
1177 #define LL_I2S_SR_OVR LL_SPI_SR_OVR /*!< Overrun flag */
1178 #define LL_I2S_SR_FRE LL_SPI_SR_FRE /*!< TI mode frame format error flag */
1183 /** @defgroup SPI_LL_EC_IT IT Defines
1184 * @brief IT defines which can be used with LL_SPI_ReadReg and LL_SPI_WriteReg functions
1187 #define LL_I2S_CR2_RXNEIE LL_SPI_CR2_RXNEIE /*!< Rx buffer not empty interrupt enable */
1188 #define LL_I2S_CR2_TXEIE LL_SPI_CR2_TXEIE /*!< Tx buffer empty interrupt enable */
1189 #define LL_I2S_CR2_ERRIE LL_SPI_CR2_ERRIE /*!< Error interrupt enable */
1194 /** @defgroup I2S_LL_EC_DATA_FORMAT Data format
1197 #define LL_I2S_DATAFORMAT_16B 0x00000000U /*!< Data length 16 bits, Channel lenght 16bit */
1198 #define LL_I2S_DATAFORMAT_16B_EXTENDED (SPI_I2SCFGR_CHLEN) /*!< Data length 16 bits, Channel lenght 32bit */
1199 #define LL_I2S_DATAFORMAT_24B (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_0) /*!< Data length 24 bits, Channel lenght 32bit */
1200 #define LL_I2S_DATAFORMAT_32B (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_1) /*!< Data length 16 bits, Channel lenght 32bit */
1205 /** @defgroup I2S_LL_EC_POLARITY Clock Polarity
1208 #define LL_I2S_POLARITY_LOW 0x00000000U /*!< Clock steady state is low level */
1209 #define LL_I2S_POLARITY_HIGH (SPI_I2SCFGR_CKPOL) /*!< Clock steady state is high level */
1214 /** @defgroup I2S_LL_EC_STANDARD I2s Standard
1217 #define LL_I2S_STANDARD_PHILIPS 0x00000000U /*!< I2S standard philips */
1218 #define LL_I2S_STANDARD_MSB (SPI_I2SCFGR_I2SSTD_0) /*!< MSB justified standard (left justified) */
1219 #define LL_I2S_STANDARD_LSB (SPI_I2SCFGR_I2SSTD_1) /*!< LSB justified standard (right justified) */
1220 #define LL_I2S_STANDARD_PCM_SHORT (SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1) /*!< PCM standard, short frame synchronization */
1221 #define LL_I2S_STANDARD_PCM_LONG (SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1 | SPI_I2SCFGR_PCMSYNC) /*!< PCM standard, long frame synchronization */
1226 /** @defgroup I2S_LL_EC_MODE Operation Mode
1229 #define LL_I2S_MODE_SLAVE_TX 0x00000000U /*!< Slave Tx configuration */
1230 #define LL_I2S_MODE_SLAVE_RX (SPI_I2SCFGR_I2SCFG_0) /*!< Slave Rx configuration */
1231 #define LL_I2S_MODE_MASTER_TX (SPI_I2SCFGR_I2SCFG_1) /*!< Master Tx configuration */
1232 #define LL_I2S_MODE_MASTER_RX (SPI_I2SCFGR_I2SCFG_0 | SPI_I2SCFGR_I2SCFG_1) /*!< Master Rx configuration */
1237 /** @defgroup I2S_LL_EC_PRESCALER_FACTOR Prescaler Factor
1240 #define LL_I2S_PRESCALER_PARITY_EVEN 0x00000000U /*!< Odd factor: Real divider value is = I2SDIV * 2 */
1241 #define LL_I2S_PRESCALER_PARITY_ODD (SPI_I2SPR_ODD >> 8U) /*!< Odd factor: Real divider value is = (I2SDIV * 2)+1 */
1246 #if defined(USE_FULL_LL_DRIVER)
1248 /** @defgroup I2S_LL_EC_MCLK_OUTPUT MCLK Output
1251 #define LL_I2S_MCLK_OUTPUT_DISABLE 0x00000000U /*!< Master clock output is disabled */
1252 #define LL_I2S_MCLK_OUTPUT_ENABLE (SPI_I2SPR_MCKOE) /*!< Master clock output is enabled */
1257 /** @defgroup I2S_LL_EC_AUDIO_FREQ Audio Frequency
1261 #define LL_I2S_AUDIOFREQ_192K 192000U /*!< Audio Frequency configuration 192000 Hz */
1262 #define LL_I2S_AUDIOFREQ_96K 96000U /*!< Audio Frequency configuration 96000 Hz */
1263 #define LL_I2S_AUDIOFREQ_48K 48000U /*!< Audio Frequency configuration 48000 Hz */
1264 #define LL_I2S_AUDIOFREQ_44K 44100U /*!< Audio Frequency configuration 44100 Hz */
1265 #define LL_I2S_AUDIOFREQ_32K 32000U /*!< Audio Frequency configuration 32000 Hz */
1266 #define LL_I2S_AUDIOFREQ_22K 22050U /*!< Audio Frequency configuration 22050 Hz */
1267 #define LL_I2S_AUDIOFREQ_16K 16000U /*!< Audio Frequency configuration 16000 Hz */
1268 #define LL_I2S_AUDIOFREQ_11K 11025U /*!< Audio Frequency configuration 11025 Hz */
1269 #define LL_I2S_AUDIOFREQ_8K 8000U /*!< Audio Frequency configuration 8000 Hz */
1270 #define LL_I2S_AUDIOFREQ_DEFAULT 2U /*!< Audio Freq not specified. Register I2SDIV = 2 */
1274 #endif /* USE_FULL_LL_DRIVER */
1280 /* Exported macro ------------------------------------------------------------*/
1281 /** @defgroup I2S_LL_Exported_Macros I2S Exported Macros
1285 /** @defgroup I2S_LL_EM_WRITE_READ Common Write and read registers Macros
1290 * @brief Write a value in I2S register
1291 * @param __INSTANCE__ I2S Instance
1292 * @param __REG__ Register to be written
1293 * @param __VALUE__ Value to be written in the register
1296 #define LL_I2S_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
1299 * @brief Read a value in I2S register
1300 * @param __INSTANCE__ I2S Instance
1301 * @param __REG__ Register to be read
1302 * @retval Register value
1304 #define LL_I2S_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
1314 /* Exported functions --------------------------------------------------------*/
1316 /** @defgroup I2S_LL_Exported_Functions I2S Exported Functions
1320 /** @defgroup I2S_LL_EF_Configuration Configuration
1325 * @brief Select I2S mode and Enable I2S peripheral
1326 * @rmtoll I2SCFGR I2SMOD LL_I2S_Enable\n
1327 * I2SCFGR I2SE LL_I2S_Enable
1328 * @param SPIx SPI Instance
1331 __STATIC_INLINE
void LL_I2S_Enable(SPI_TypeDef
*SPIx
)
1333 SET_BIT(SPIx
->I2SCFGR
, SPI_I2SCFGR_I2SMOD
| SPI_I2SCFGR_I2SE
);
1337 * @brief Disable I2S peripheral
1338 * @rmtoll I2SCFGR I2SE LL_I2S_Disable
1339 * @param SPIx SPI Instance
1342 __STATIC_INLINE
void LL_I2S_Disable(SPI_TypeDef
*SPIx
)
1344 CLEAR_BIT(SPIx
->I2SCFGR
, SPI_I2SCFGR_I2SMOD
| SPI_I2SCFGR_I2SE
);
1348 * @brief Check if I2S peripheral is enabled
1349 * @rmtoll I2SCFGR I2SE LL_I2S_IsEnabled
1350 * @param SPIx SPI Instance
1351 * @retval State of bit (1 or 0).
1353 __STATIC_INLINE
uint32_t LL_I2S_IsEnabled(SPI_TypeDef
*SPIx
)
1355 return (READ_BIT(SPIx
->I2SCFGR
, SPI_I2SCFGR_I2SE
) == (SPI_I2SCFGR_I2SE
));
1359 * @brief Set I2S data frame length
1360 * @rmtoll I2SCFGR DATLEN LL_I2S_SetDataFormat\n
1361 * I2SCFGR CHLEN LL_I2S_SetDataFormat
1362 * @param SPIx SPI Instance
1363 * @param DataFormat This parameter can be one of the following values:
1364 * @arg @ref LL_I2S_DATAFORMAT_16B
1365 * @arg @ref LL_I2S_DATAFORMAT_16B_EXTENDED
1366 * @arg @ref LL_I2S_DATAFORMAT_24B
1367 * @arg @ref LL_I2S_DATAFORMAT_32B
1370 __STATIC_INLINE
void LL_I2S_SetDataFormat(SPI_TypeDef
*SPIx
, uint32_t DataFormat
)
1372 MODIFY_REG(SPIx
->I2SCFGR
, SPI_I2SCFGR_DATLEN
| SPI_I2SCFGR_CHLEN
, DataFormat
);
1376 * @brief Get I2S data frame length
1377 * @rmtoll I2SCFGR DATLEN LL_I2S_GetDataFormat\n
1378 * I2SCFGR CHLEN LL_I2S_GetDataFormat
1379 * @param SPIx SPI Instance
1380 * @retval Returned value can be one of the following values:
1381 * @arg @ref LL_I2S_DATAFORMAT_16B
1382 * @arg @ref LL_I2S_DATAFORMAT_16B_EXTENDED
1383 * @arg @ref LL_I2S_DATAFORMAT_24B
1384 * @arg @ref LL_I2S_DATAFORMAT_32B
1386 __STATIC_INLINE
uint32_t LL_I2S_GetDataFormat(SPI_TypeDef
*SPIx
)
1388 return (uint32_t)(READ_BIT(SPIx
->I2SCFGR
, SPI_I2SCFGR_DATLEN
| SPI_I2SCFGR_CHLEN
));
1392 * @brief Set I2S clock polarity
1393 * @rmtoll I2SCFGR CKPOL LL_I2S_SetClockPolarity
1394 * @param SPIx SPI Instance
1395 * @param ClockPolarity This parameter can be one of the following values:
1396 * @arg @ref LL_I2S_POLARITY_LOW
1397 * @arg @ref LL_I2S_POLARITY_HIGH
1400 __STATIC_INLINE
void LL_I2S_SetClockPolarity(SPI_TypeDef
*SPIx
, uint32_t ClockPolarity
)
1402 SET_BIT(SPIx
->I2SCFGR
, ClockPolarity
);
1406 * @brief Get I2S clock polarity
1407 * @rmtoll I2SCFGR CKPOL LL_I2S_GetClockPolarity
1408 * @param SPIx SPI Instance
1409 * @retval Returned value can be one of the following values:
1410 * @arg @ref LL_I2S_POLARITY_LOW
1411 * @arg @ref LL_I2S_POLARITY_HIGH
1413 __STATIC_INLINE
uint32_t LL_I2S_GetClockPolarity(SPI_TypeDef
*SPIx
)
1415 return (uint32_t)(READ_BIT(SPIx
->I2SCFGR
, SPI_I2SCFGR_CKPOL
));
1419 * @brief Set I2S standard protocol
1420 * @rmtoll I2SCFGR I2SSTD LL_I2S_SetStandard\n
1421 * I2SCFGR PCMSYNC LL_I2S_SetStandard
1422 * @param SPIx SPI Instance
1423 * @param Standard This parameter can be one of the following values:
1424 * @arg @ref LL_I2S_STANDARD_PHILIPS
1425 * @arg @ref LL_I2S_STANDARD_MSB
1426 * @arg @ref LL_I2S_STANDARD_LSB
1427 * @arg @ref LL_I2S_STANDARD_PCM_SHORT
1428 * @arg @ref LL_I2S_STANDARD_PCM_LONG
1431 __STATIC_INLINE
void LL_I2S_SetStandard(SPI_TypeDef
*SPIx
, uint32_t Standard
)
1433 MODIFY_REG(SPIx
->I2SCFGR
, SPI_I2SCFGR_I2SSTD
| SPI_I2SCFGR_PCMSYNC
, Standard
);
1437 * @brief Get I2S standard protocol
1438 * @rmtoll I2SCFGR I2SSTD LL_I2S_GetStandard\n
1439 * I2SCFGR PCMSYNC LL_I2S_GetStandard
1440 * @param SPIx SPI Instance
1441 * @retval Returned value can be one of the following values:
1442 * @arg @ref LL_I2S_STANDARD_PHILIPS
1443 * @arg @ref LL_I2S_STANDARD_MSB
1444 * @arg @ref LL_I2S_STANDARD_LSB
1445 * @arg @ref LL_I2S_STANDARD_PCM_SHORT
1446 * @arg @ref LL_I2S_STANDARD_PCM_LONG
1448 __STATIC_INLINE
uint32_t LL_I2S_GetStandard(SPI_TypeDef
*SPIx
)
1450 return (uint32_t)(READ_BIT(SPIx
->I2SCFGR
, SPI_I2SCFGR_I2SSTD
| SPI_I2SCFGR_PCMSYNC
));
1454 * @brief Set I2S transfer mode
1455 * @rmtoll I2SCFGR I2SCFG LL_I2S_SetTransferMode
1456 * @param SPIx SPI Instance
1457 * @param Mode This parameter can be one of the following values:
1458 * @arg @ref LL_I2S_MODE_SLAVE_TX
1459 * @arg @ref LL_I2S_MODE_SLAVE_RX
1460 * @arg @ref LL_I2S_MODE_MASTER_TX
1461 * @arg @ref LL_I2S_MODE_MASTER_RX
1464 __STATIC_INLINE
void LL_I2S_SetTransferMode(SPI_TypeDef
*SPIx
, uint32_t Mode
)
1466 MODIFY_REG(SPIx
->I2SCFGR
, SPI_I2SCFGR_I2SCFG
, Mode
);
1470 * @brief Get I2S transfer mode
1471 * @rmtoll I2SCFGR I2SCFG LL_I2S_GetTransferMode
1472 * @param SPIx SPI Instance
1473 * @retval Returned value can be one of the following values:
1474 * @arg @ref LL_I2S_MODE_SLAVE_TX
1475 * @arg @ref LL_I2S_MODE_SLAVE_RX
1476 * @arg @ref LL_I2S_MODE_MASTER_TX
1477 * @arg @ref LL_I2S_MODE_MASTER_RX
1479 __STATIC_INLINE
uint32_t LL_I2S_GetTransferMode(SPI_TypeDef
*SPIx
)
1481 return (uint32_t)(READ_BIT(SPIx
->I2SCFGR
, SPI_I2SCFGR_I2SCFG
));
1485 * @brief Set I2S linear prescaler
1486 * @rmtoll I2SPR I2SDIV LL_I2S_SetPrescalerLinear
1487 * @param SPIx SPI Instance
1488 * @param PrescalerLinear Value between Min_Data=0x02 and Max_Data=0xFF
1491 __STATIC_INLINE
void LL_I2S_SetPrescalerLinear(SPI_TypeDef
*SPIx
, uint8_t PrescalerLinear
)
1493 MODIFY_REG(SPIx
->I2SPR
, SPI_I2SPR_I2SDIV
, PrescalerLinear
);
1497 * @brief Get I2S linear prescaler
1498 * @rmtoll I2SPR I2SDIV LL_I2S_GetPrescalerLinear
1499 * @param SPIx SPI Instance
1500 * @retval PrescalerLinear Value between Min_Data=0x02 and Max_Data=0xFF
1502 __STATIC_INLINE
uint32_t LL_I2S_GetPrescalerLinear(SPI_TypeDef
*SPIx
)
1504 return (uint32_t)(READ_BIT(SPIx
->I2SPR
, SPI_I2SPR_I2SDIV
));
1508 * @brief Set I2S parity prescaler
1509 * @rmtoll I2SPR ODD LL_I2S_SetPrescalerParity
1510 * @param SPIx SPI Instance
1511 * @param PrescalerParity This parameter can be one of the following values:
1512 * @arg @ref LL_I2S_PRESCALER_PARITY_EVEN
1513 * @arg @ref LL_I2S_PRESCALER_PARITY_ODD
1516 __STATIC_INLINE
void LL_I2S_SetPrescalerParity(SPI_TypeDef
*SPIx
, uint32_t PrescalerParity
)
1518 MODIFY_REG(SPIx
->I2SPR
, SPI_I2SPR_ODD
, PrescalerParity
<< 8U);
1522 * @brief Get I2S parity prescaler
1523 * @rmtoll I2SPR ODD LL_I2S_GetPrescalerParity
1524 * @param SPIx SPI Instance
1525 * @retval Returned value can be one of the following values:
1526 * @arg @ref LL_I2S_PRESCALER_PARITY_EVEN
1527 * @arg @ref LL_I2S_PRESCALER_PARITY_ODD
1529 __STATIC_INLINE
uint32_t LL_I2S_GetPrescalerParity(SPI_TypeDef
*SPIx
)
1531 return (uint32_t)(READ_BIT(SPIx
->I2SPR
, SPI_I2SPR_ODD
) >> 8U);
1535 * @brief Enable the master clock ouput (Pin MCK)
1536 * @rmtoll I2SPR MCKOE LL_I2S_EnableMasterClock
1537 * @param SPIx SPI Instance
1540 __STATIC_INLINE
void LL_I2S_EnableMasterClock(SPI_TypeDef
*SPIx
)
1542 SET_BIT(SPIx
->I2SPR
, SPI_I2SPR_MCKOE
);
1546 * @brief Disable the master clock ouput (Pin MCK)
1547 * @rmtoll I2SPR MCKOE LL_I2S_DisableMasterClock
1548 * @param SPIx SPI Instance
1551 __STATIC_INLINE
void LL_I2S_DisableMasterClock(SPI_TypeDef
*SPIx
)
1553 CLEAR_BIT(SPIx
->I2SPR
, SPI_I2SPR_MCKOE
);
1557 * @brief Check if the master clock ouput (Pin MCK) is enabled
1558 * @rmtoll I2SPR MCKOE LL_I2S_IsEnabledMasterClock
1559 * @param SPIx SPI Instance
1560 * @retval State of bit (1 or 0).
1562 __STATIC_INLINE
uint32_t LL_I2S_IsEnabledMasterClock(SPI_TypeDef
*SPIx
)
1564 return (READ_BIT(SPIx
->I2SPR
, SPI_I2SPR_MCKOE
) == (SPI_I2SPR_MCKOE
));
1571 /** @defgroup I2S_LL_EF_FLAG FLAG Management
1576 * @brief Check if Rx buffer is not empty
1577 * @rmtoll SR RXNE LL_I2S_IsActiveFlag_RXNE
1578 * @param SPIx SPI Instance
1579 * @retval State of bit (1 or 0).
1581 __STATIC_INLINE
uint32_t LL_I2S_IsActiveFlag_RXNE(SPI_TypeDef
*SPIx
)
1583 return LL_SPI_IsActiveFlag_RXNE(SPIx
);
1587 * @brief Check if Tx buffer is empty
1588 * @rmtoll SR TXE LL_I2S_IsActiveFlag_TXE
1589 * @param SPIx SPI Instance
1590 * @retval State of bit (1 or 0).
1592 __STATIC_INLINE
uint32_t LL_I2S_IsActiveFlag_TXE(SPI_TypeDef
*SPIx
)
1594 return LL_SPI_IsActiveFlag_TXE(SPIx
);
1598 * @brief Get busy flag
1599 * @rmtoll SR BSY LL_I2S_IsActiveFlag_BSY
1600 * @param SPIx SPI Instance
1601 * @retval State of bit (1 or 0).
1603 __STATIC_INLINE
uint32_t LL_I2S_IsActiveFlag_BSY(SPI_TypeDef
*SPIx
)
1605 return LL_SPI_IsActiveFlag_BSY(SPIx
);
1609 * @brief Get overrun error flag
1610 * @rmtoll SR OVR LL_I2S_IsActiveFlag_OVR
1611 * @param SPIx SPI Instance
1612 * @retval State of bit (1 or 0).
1614 __STATIC_INLINE
uint32_t LL_I2S_IsActiveFlag_OVR(SPI_TypeDef
*SPIx
)
1616 return LL_SPI_IsActiveFlag_OVR(SPIx
);
1620 * @brief Get underrun error flag
1621 * @rmtoll SR UDR LL_I2S_IsActiveFlag_UDR
1622 * @param SPIx SPI Instance
1623 * @retval State of bit (1 or 0).
1625 __STATIC_INLINE
uint32_t LL_I2S_IsActiveFlag_UDR(SPI_TypeDef
*SPIx
)
1627 return (READ_BIT(SPIx
->SR
, SPI_SR_UDR
) == (SPI_SR_UDR
));
1631 * @brief Get channel side flag.
1632 * @note 0: Channel Left has to be transmitted or has been received\n
1633 * 1: Channel Right has to be transmitted or has been received\n
1634 * It has no significance in PCM mode.
1635 * @rmtoll SR CHSIDE LL_I2S_IsActiveFlag_CHSIDE
1636 * @param SPIx SPI Instance
1637 * @retval State of bit (1 or 0).
1639 __STATIC_INLINE
uint32_t LL_I2S_IsActiveFlag_CHSIDE(SPI_TypeDef
*SPIx
)
1641 return (READ_BIT(SPIx
->SR
, SPI_SR_CHSIDE
) == (SPI_SR_CHSIDE
));
1645 * @brief Clear overrun error flag
1646 * @rmtoll SR OVR LL_I2S_ClearFlag_OVR
1647 * @param SPIx SPI Instance
1650 __STATIC_INLINE
void LL_I2S_ClearFlag_OVR(SPI_TypeDef
*SPIx
)
1652 LL_SPI_ClearFlag_OVR(SPIx
);
1656 * @brief Clear underrun error flag
1657 * @rmtoll SR UDR LL_I2S_ClearFlag_UDR
1658 * @param SPIx SPI Instance
1661 __STATIC_INLINE
void LL_I2S_ClearFlag_UDR(SPI_TypeDef
*SPIx
)
1663 __IO
uint32_t tmpreg
;
1672 /** @defgroup I2S_LL_EF_IT Interrupt Management
1677 * @brief Enable error IT
1678 * @note This bit controls the generation of an interrupt when an error condition occurs (OVR, UDR and FRE in I2S mode).
1679 * @rmtoll CR2 ERRIE LL_I2S_EnableIT_ERR
1680 * @param SPIx SPI Instance
1683 __STATIC_INLINE
void LL_I2S_EnableIT_ERR(SPI_TypeDef
*SPIx
)
1685 LL_SPI_EnableIT_ERR(SPIx
);
1689 * @brief Enable Rx buffer not empty IT
1690 * @rmtoll CR2 RXNEIE LL_I2S_EnableIT_RXNE
1691 * @param SPIx SPI Instance
1694 __STATIC_INLINE
void LL_I2S_EnableIT_RXNE(SPI_TypeDef
*SPIx
)
1696 LL_SPI_EnableIT_RXNE(SPIx
);
1700 * @brief Enable Tx buffer empty IT
1701 * @rmtoll CR2 TXEIE LL_I2S_EnableIT_TXE
1702 * @param SPIx SPI Instance
1705 __STATIC_INLINE
void LL_I2S_EnableIT_TXE(SPI_TypeDef
*SPIx
)
1707 LL_SPI_EnableIT_TXE(SPIx
);
1711 * @brief Disable error IT
1712 * @note This bit controls the generation of an interrupt when an error condition occurs (OVR, UDR and FRE in I2S mode).
1713 * @rmtoll CR2 ERRIE LL_I2S_DisableIT_ERR
1714 * @param SPIx SPI Instance
1717 __STATIC_INLINE
void LL_I2S_DisableIT_ERR(SPI_TypeDef
*SPIx
)
1719 LL_SPI_DisableIT_ERR(SPIx
);
1723 * @brief Disable Rx buffer not empty IT
1724 * @rmtoll CR2 RXNEIE LL_I2S_DisableIT_RXNE
1725 * @param SPIx SPI Instance
1728 __STATIC_INLINE
void LL_I2S_DisableIT_RXNE(SPI_TypeDef
*SPIx
)
1730 LL_SPI_DisableIT_RXNE(SPIx
);
1734 * @brief Disable Tx buffer empty IT
1735 * @rmtoll CR2 TXEIE LL_I2S_DisableIT_TXE
1736 * @param SPIx SPI Instance
1739 __STATIC_INLINE
void LL_I2S_DisableIT_TXE(SPI_TypeDef
*SPIx
)
1741 LL_SPI_DisableIT_TXE(SPIx
);
1745 * @brief Check if ERR IT is enabled
1746 * @rmtoll CR2 ERRIE LL_I2S_IsEnabledIT_ERR
1747 * @param SPIx SPI Instance
1748 * @retval State of bit (1 or 0).
1750 __STATIC_INLINE
uint32_t LL_I2S_IsEnabledIT_ERR(SPI_TypeDef
*SPIx
)
1752 return LL_SPI_IsEnabledIT_ERR(SPIx
);
1756 * @brief Check if RXNE IT is enabled
1757 * @rmtoll CR2 RXNEIE LL_I2S_IsEnabledIT_RXNE
1758 * @param SPIx SPI Instance
1759 * @retval State of bit (1 or 0).
1761 __STATIC_INLINE
uint32_t LL_I2S_IsEnabledIT_RXNE(SPI_TypeDef
*SPIx
)
1763 return LL_SPI_IsEnabledIT_RXNE(SPIx
);
1767 * @brief Check if TXE IT is enabled
1768 * @rmtoll CR2 TXEIE LL_I2S_IsEnabledIT_TXE
1769 * @param SPIx SPI Instance
1770 * @retval State of bit (1 or 0).
1772 __STATIC_INLINE
uint32_t LL_I2S_IsEnabledIT_TXE(SPI_TypeDef
*SPIx
)
1774 return LL_SPI_IsEnabledIT_TXE(SPIx
);
1781 /** @defgroup I2S_LL_EF_DMA DMA Management
1786 * @brief Enable DMA Rx
1787 * @rmtoll CR2 RXDMAEN LL_I2S_EnableDMAReq_RX
1788 * @param SPIx SPI Instance
1791 __STATIC_INLINE
void LL_I2S_EnableDMAReq_RX(SPI_TypeDef
*SPIx
)
1793 LL_SPI_EnableDMAReq_RX(SPIx
);
1797 * @brief Disable DMA Rx
1798 * @rmtoll CR2 RXDMAEN LL_I2S_DisableDMAReq_RX
1799 * @param SPIx SPI Instance
1802 __STATIC_INLINE
void LL_I2S_DisableDMAReq_RX(SPI_TypeDef
*SPIx
)
1804 LL_SPI_DisableDMAReq_RX(SPIx
);
1808 * @brief Check if DMA Rx is enabled
1809 * @rmtoll CR2 RXDMAEN LL_I2S_IsEnabledDMAReq_RX
1810 * @param SPIx SPI Instance
1811 * @retval State of bit (1 or 0).
1813 __STATIC_INLINE
uint32_t LL_I2S_IsEnabledDMAReq_RX(SPI_TypeDef
*SPIx
)
1815 return LL_SPI_IsEnabledDMAReq_RX(SPIx
);
1819 * @brief Enable DMA Tx
1820 * @rmtoll CR2 TXDMAEN LL_I2S_EnableDMAReq_TX
1821 * @param SPIx SPI Instance
1824 __STATIC_INLINE
void LL_I2S_EnableDMAReq_TX(SPI_TypeDef
*SPIx
)
1826 LL_SPI_EnableDMAReq_TX(SPIx
);
1830 * @brief Disable DMA Tx
1831 * @rmtoll CR2 TXDMAEN LL_I2S_DisableDMAReq_TX
1832 * @param SPIx SPI Instance
1835 __STATIC_INLINE
void LL_I2S_DisableDMAReq_TX(SPI_TypeDef
*SPIx
)
1837 LL_SPI_DisableDMAReq_TX(SPIx
);
1841 * @brief Check if DMA Tx is enabled
1842 * @rmtoll CR2 TXDMAEN LL_I2S_IsEnabledDMAReq_TX
1843 * @param SPIx SPI Instance
1844 * @retval State of bit (1 or 0).
1846 __STATIC_INLINE
uint32_t LL_I2S_IsEnabledDMAReq_TX(SPI_TypeDef
*SPIx
)
1848 return LL_SPI_IsEnabledDMAReq_TX(SPIx
);
1855 /** @defgroup I2S_LL_EF_DATA DATA Management
1860 * @brief Read 16-Bits in data register
1861 * @rmtoll DR DR LL_I2S_ReceiveData16
1862 * @param SPIx SPI Instance
1863 * @retval RxData Value between Min_Data=0x0000 and Max_Data=0xFFFF
1865 __STATIC_INLINE
uint16_t LL_I2S_ReceiveData16(SPI_TypeDef
*SPIx
)
1867 return LL_SPI_ReceiveData16(SPIx
);
1871 * @brief Write 16-Bits in data register
1872 * @rmtoll DR DR LL_I2S_TransmitData16
1873 * @param SPIx SPI Instance
1874 * @param TxData Value between Min_Data=0x0000 and Max_Data=0xFFFF
1877 __STATIC_INLINE
void LL_I2S_TransmitData16(SPI_TypeDef
*SPIx
, uint16_t TxData
)
1879 LL_SPI_TransmitData16(SPIx
, TxData
);
1886 #if defined(USE_FULL_LL_DRIVER)
1887 /** @defgroup I2S_LL_EF_Init Initialization and de-initialization functions
1891 ErrorStatus
LL_I2S_DeInit(SPI_TypeDef
*SPIx
);
1892 ErrorStatus
LL_I2S_Init(SPI_TypeDef
*SPIx
, LL_I2S_InitTypeDef
*I2S_InitStruct
);
1893 void LL_I2S_StructInit(LL_I2S_InitTypeDef
*I2S_InitStruct
);
1894 void LL_I2S_ConfigPrescaler(SPI_TypeDef
*SPIx
, uint32_t PrescalerLinear
, uint32_t PrescalerParity
);
1899 #endif /* USE_FULL_LL_DRIVER */
1908 #endif /* SPI_I2S_SUPPORT */
1910 #endif /* defined (SPI1) || defined (SPI2) || defined (SPI3) */
1920 #endif /* __STM32F1xx_LL_SPI_H */
1922 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/