Merge pull request #11270 from haslinghuis/rename_attr
[betaflight.git] / lib / main / STM32H7 / Drivers / STM32H7xx_HAL_Driver / Inc / stm32h7xx_ll_usart.h
blob7b4121e2c51adb7a3f7591a87a2afdd813621fa9
1 /**
2 ******************************************************************************
3 * @file stm32h7xx_ll_usart.h
4 * @author MCD Application Team
5 * @brief Header file of USART LL module.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.</center></h2>
12 * This software component is licensed by ST under BSD 3-Clause license,
13 * the "License"; You may not use this file except in compliance with the
14 * License. You may obtain a copy of the License at:
15 * opensource.org/licenses/BSD-3-Clause
17 ******************************************************************************
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef STM32H7xx_LL_USART_H
22 #define STM32H7xx_LL_USART_H
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32h7xx.h"
31 /** @addtogroup STM32H7xx_LL_Driver
32 * @{
35 #if defined (USART1) || defined (USART2) || defined (USART3) || defined (USART6) || defined (UART4) || defined (UART5) || defined (UART7) || defined (UART8) || defined (UART9) || defined (USART10)
37 /** @defgroup USART_LL USART
38 * @{
41 /* Private types -------------------------------------------------------------*/
42 /* Private variables ---------------------------------------------------------*/
43 /** @defgroup USART_LL_Private_Variables USART Private Variables
44 * @{
46 /* Array used to get the USART prescaler division decimal values versus @ref USART_LL_EC_PRESCALER values */
47 static const uint32_t USART_PRESCALER_TAB[] =
49 1UL,
50 2UL,
51 4UL,
52 6UL,
53 8UL,
54 10UL,
55 12UL,
56 16UL,
57 32UL,
58 64UL,
59 128UL,
60 256UL
62 /**
63 * @}
66 /* Private constants ---------------------------------------------------------*/
67 /* Private macros ------------------------------------------------------------*/
68 #if defined(USE_FULL_LL_DRIVER)
69 /** @defgroup USART_LL_Private_Macros USART Private Macros
70 * @{
72 /**
73 * @}
75 #endif /*USE_FULL_LL_DRIVER*/
77 /* Exported types ------------------------------------------------------------*/
78 #if defined(USE_FULL_LL_DRIVER)
79 /** @defgroup USART_LL_ES_INIT USART Exported Init structures
80 * @{
83 /**
84 * @brief LL USART Init Structure definition
86 typedef struct
88 uint32_t PrescalerValue; /*!< Specifies the Prescaler to compute the communication baud rate.
89 This parameter can be a value of @ref USART_LL_EC_PRESCALER.
91 This feature can be modified afterwards using unitary function @ref LL_USART_SetPrescaler().*/
93 uint32_t BaudRate; /*!< This field defines expected Usart communication baud rate.
95 This feature can be modified afterwards using unitary function @ref LL_USART_SetBaudRate().*/
97 uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame.
98 This parameter can be a value of @ref USART_LL_EC_DATAWIDTH.
100 This feature can be modified afterwards using unitary function @ref LL_USART_SetDataWidth().*/
102 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
103 This parameter can be a value of @ref USART_LL_EC_STOPBITS.
105 This feature can be modified afterwards using unitary function @ref LL_USART_SetStopBitsLength().*/
107 uint32_t Parity; /*!< Specifies the parity mode.
108 This parameter can be a value of @ref USART_LL_EC_PARITY.
110 This feature can be modified afterwards using unitary function @ref LL_USART_SetParity().*/
112 uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled.
113 This parameter can be a value of @ref USART_LL_EC_DIRECTION.
115 This feature can be modified afterwards using unitary function @ref LL_USART_SetTransferDirection().*/
117 uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled.
118 This parameter can be a value of @ref USART_LL_EC_HWCONTROL.
120 This feature can be modified afterwards using unitary function @ref LL_USART_SetHWFlowCtrl().*/
122 uint32_t OverSampling; /*!< Specifies whether USART oversampling mode is 16 or 8.
123 This parameter can be a value of @ref USART_LL_EC_OVERSAMPLING.
125 This feature can be modified afterwards using unitary function @ref LL_USART_SetOverSampling().*/
127 } LL_USART_InitTypeDef;
130 * @brief LL USART Clock Init Structure definition
132 typedef struct
134 uint32_t ClockOutput; /*!< Specifies whether the USART clock is enabled or disabled.
135 This parameter can be a value of @ref USART_LL_EC_CLOCK.
137 USART HW configuration can be modified afterwards using unitary functions
138 @ref LL_USART_EnableSCLKOutput() or @ref LL_USART_DisableSCLKOutput().
139 For more details, refer to description of this function. */
141 uint32_t ClockPolarity; /*!< Specifies the steady state of the serial clock.
142 This parameter can be a value of @ref USART_LL_EC_POLARITY.
144 USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPolarity().
145 For more details, refer to description of this function. */
147 uint32_t ClockPhase; /*!< Specifies the clock transition on which the bit capture is made.
148 This parameter can be a value of @ref USART_LL_EC_PHASE.
150 USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPhase().
151 For more details, refer to description of this function. */
153 uint32_t LastBitClockPulse; /*!< Specifies whether the clock pulse corresponding to the last transmitted
154 data bit (MSB) has to be output on the SCLK pin in synchronous mode.
155 This parameter can be a value of @ref USART_LL_EC_LASTCLKPULSE.
157 USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetLastClkPulseOutput().
158 For more details, refer to description of this function. */
160 } LL_USART_ClockInitTypeDef;
163 * @}
165 #endif /* USE_FULL_LL_DRIVER */
167 /* Exported constants --------------------------------------------------------*/
168 /** @defgroup USART_LL_Exported_Constants USART Exported Constants
169 * @{
172 /** @defgroup USART_LL_EC_CLEAR_FLAG Clear Flags Defines
173 * @brief Flags defines which can be used with LL_USART_WriteReg function
174 * @{
176 #define LL_USART_ICR_PECF USART_ICR_PECF /*!< Parity error flag */
177 #define LL_USART_ICR_FECF USART_ICR_FECF /*!< Framing error flag */
178 #define LL_USART_ICR_NECF USART_ICR_NECF /*!< Noise error detected flag */
179 #define LL_USART_ICR_ORECF USART_ICR_ORECF /*!< Overrun error flag */
180 #define LL_USART_ICR_IDLECF USART_ICR_IDLECF /*!< Idle line detected flag */
181 #define LL_USART_ICR_TXFECF USART_ICR_TXFECF /*!< TX FIFO Empty Clear flag */
182 #define LL_USART_ICR_TCCF USART_ICR_TCCF /*!< Transmission complete flag */
183 #define LL_USART_ICR_TCBGTCF USART_ICR_TCBGTCF /*!< Transmission completed before guard time flag */
184 #define LL_USART_ICR_LBDCF USART_ICR_LBDCF /*!< LIN break detection flag */
185 #define LL_USART_ICR_CTSCF USART_ICR_CTSCF /*!< CTS flag */
186 #define LL_USART_ICR_RTOCF USART_ICR_RTOCF /*!< Receiver timeout flag */
187 #define LL_USART_ICR_EOBCF USART_ICR_EOBCF /*!< End of block flag */
188 #define LL_USART_ICR_UDRCF USART_ICR_UDRCF /*!< SPI Slave Underrun Clear flag */
189 #define LL_USART_ICR_CMCF USART_ICR_CMCF /*!< Character match flag */
190 #define LL_USART_ICR_WUCF USART_ICR_WUCF /*!< Wakeup from Stop mode flag */
192 * @}
195 /** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines
196 * @brief Flags defines which can be used with LL_USART_ReadReg function
197 * @{
199 #define LL_USART_ISR_PE USART_ISR_PE /*!< Parity error flag */
200 #define LL_USART_ISR_FE USART_ISR_FE /*!< Framing error flag */
201 #define LL_USART_ISR_NE USART_ISR_NE /*!< Noise detected flag */
202 #define LL_USART_ISR_ORE USART_ISR_ORE /*!< Overrun error flag */
203 #define LL_USART_ISR_IDLE USART_ISR_IDLE /*!< Idle line detected flag */
204 #define LL_USART_ISR_RXNE_RXFNE USART_ISR_RXNE_RXFNE /*!< Read data register or RX FIFO not empty flag */
205 #define LL_USART_ISR_TC USART_ISR_TC /*!< Transmission complete flag */
206 #define LL_USART_ISR_TXE_TXFNF USART_ISR_TXE_TXFNF /*!< Transmit data register empty or TX FIFO Not Full flag*/
207 #define LL_USART_ISR_LBDF USART_ISR_LBDF /*!< LIN break detection flag */
208 #define LL_USART_ISR_CTSIF USART_ISR_CTSIF /*!< CTS interrupt flag */
209 #define LL_USART_ISR_CTS USART_ISR_CTS /*!< CTS flag */
210 #define LL_USART_ISR_RTOF USART_ISR_RTOF /*!< Receiver timeout flag */
211 #define LL_USART_ISR_EOBF USART_ISR_EOBF /*!< End of block flag */
212 #define LL_USART_ISR_UDR USART_ISR_UDR /*!< SPI Slave underrun error flag */
213 #define LL_USART_ISR_ABRE USART_ISR_ABRE /*!< Auto baud rate error flag */
214 #define LL_USART_ISR_ABRF USART_ISR_ABRF /*!< Auto baud rate flag */
215 #define LL_USART_ISR_BUSY USART_ISR_BUSY /*!< Busy flag */
216 #define LL_USART_ISR_CMF USART_ISR_CMF /*!< Character match flag */
217 #define LL_USART_ISR_SBKF USART_ISR_SBKF /*!< Send break flag */
218 #define LL_USART_ISR_RWU USART_ISR_RWU /*!< Receiver wakeup from Mute mode flag */
219 #define LL_USART_ISR_WUF USART_ISR_WUF /*!< Wakeup from Stop mode flag */
220 #define LL_USART_ISR_TEACK USART_ISR_TEACK /*!< Transmit enable acknowledge flag */
221 #define LL_USART_ISR_REACK USART_ISR_REACK /*!< Receive enable acknowledge flag */
222 #define LL_USART_ISR_TXFE USART_ISR_TXFE /*!< TX FIFO empty flag */
223 #define LL_USART_ISR_RXFF USART_ISR_RXFF /*!< RX FIFO full flag */
224 #define LL_USART_ISR_TCBGT USART_ISR_TCBGT /*!< Transmission complete before guard time completion flag */
225 #define LL_USART_ISR_RXFT USART_ISR_RXFT /*!< RX FIFO threshold flag */
226 #define LL_USART_ISR_TXFT USART_ISR_TXFT /*!< TX FIFO threshold flag */
228 * @}
231 /** @defgroup USART_LL_EC_IT IT Defines
232 * @brief IT defines which can be used with LL_USART_ReadReg and LL_USART_WriteReg functions
233 * @{
235 #define LL_USART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */
236 #define LL_USART_CR1_RXNEIE_RXFNEIE USART_CR1_RXNEIE_RXFNEIE /*!< Read data register and RXFIFO not empty interrupt enable */
237 #define LL_USART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */
238 #define LL_USART_CR1_TXEIE_TXFNFIE USART_CR1_TXEIE_TXFNFIE /*!< Transmit data register empty and TX FIFO not full interrupt enable */
239 #define LL_USART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */
240 #define LL_USART_CR1_CMIE USART_CR1_CMIE /*!< Character match interrupt enable */
241 #define LL_USART_CR1_RTOIE USART_CR1_RTOIE /*!< Receiver timeout interrupt enable */
242 #define LL_USART_CR1_EOBIE USART_CR1_EOBIE /*!< End of Block interrupt enable */
243 #define LL_USART_CR1_TXFEIE USART_CR1_TXFEIE /*!< TX FIFO empty interrupt enable */
244 #define LL_USART_CR1_RXFFIE USART_CR1_RXFFIE /*!< RX FIFO full interrupt enable */
245 #define LL_USART_CR2_LBDIE USART_CR2_LBDIE /*!< LIN break detection interrupt enable */
246 #define LL_USART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */
247 #define LL_USART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */
248 #define LL_USART_CR3_WUFIE USART_CR3_WUFIE /*!< Wakeup from Stop mode interrupt enable */
249 #define LL_USART_CR3_TXFTIE USART_CR3_TXFTIE /*!< TX FIFO threshold interrupt enable */
250 #define LL_USART_CR3_TCBGTIE USART_CR3_TCBGTIE /*!< Transmission complete before guard time interrupt enable */
251 #define LL_USART_CR3_RXFTIE USART_CR3_RXFTIE /*!< RX FIFO threshold interrupt enable */
253 * @}
256 /** @defgroup USART_LL_EC_FIFOTHRESHOLD FIFO Threshold
257 * @{
259 #define LL_USART_FIFOTHRESHOLD_1_8 0x00000000U /*!< FIFO reaches 1/8 of its depth */
260 #define LL_USART_FIFOTHRESHOLD_1_4 0x00000001U /*!< FIFO reaches 1/4 of its depth */
261 #define LL_USART_FIFOTHRESHOLD_1_2 0x00000002U /*!< FIFO reaches 1/2 of its depth */
262 #define LL_USART_FIFOTHRESHOLD_3_4 0x00000003U /*!< FIFO reaches 3/4 of its depth */
263 #define LL_USART_FIFOTHRESHOLD_7_8 0x00000004U /*!< FIFO reaches 7/8 of its depth */
264 #define LL_USART_FIFOTHRESHOLD_8_8 0x00000005U /*!< FIFO becomes empty for TX and full for RX */
266 * @}
269 /** @defgroup USART_LL_EC_DIRECTION Communication Direction
270 * @{
272 #define LL_USART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */
273 #define LL_USART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */
274 #define LL_USART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */
275 #define LL_USART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */
277 * @}
280 /** @defgroup USART_LL_EC_PARITY Parity Control
281 * @{
283 #define LL_USART_PARITY_NONE 0x00000000U /*!< Parity control disabled */
284 #define LL_USART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */
285 #define LL_USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */
287 * @}
290 /** @defgroup USART_LL_EC_WAKEUP Wakeup
291 * @{
293 #define LL_USART_WAKEUP_IDLELINE 0x00000000U /*!< USART wake up from Mute mode on Idle Line */
294 #define LL_USART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< USART wake up from Mute mode on Address Mark */
296 * @}
299 /** @defgroup USART_LL_EC_DATAWIDTH Datawidth
300 * @{
302 #define LL_USART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */
303 #define LL_USART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
304 #define LL_USART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
306 * @}
309 /** @defgroup USART_LL_EC_OVERSAMPLING Oversampling
310 * @{
312 #define LL_USART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */
313 #define LL_USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */
315 * @}
318 #if defined(USE_FULL_LL_DRIVER)
319 /** @defgroup USART_LL_EC_CLOCK Clock Signal
320 * @{
323 #define LL_USART_CLOCK_DISABLE 0x00000000U /*!< Clock signal not provided */
324 #define LL_USART_CLOCK_ENABLE USART_CR2_CLKEN /*!< Clock signal provided */
326 * @}
328 #endif /*USE_FULL_LL_DRIVER*/
330 /** @defgroup USART_LL_EC_LASTCLKPULSE Last Clock Pulse
331 * @{
333 #define LL_USART_LASTCLKPULSE_NO_OUTPUT 0x00000000U /*!< The clock pulse of the last data bit is not output to the SCLK pin */
334 #define LL_USART_LASTCLKPULSE_OUTPUT USART_CR2_LBCL /*!< The clock pulse of the last data bit is output to the SCLK pin */
336 * @}
339 /** @defgroup USART_LL_EC_PHASE Clock Phase
340 * @{
342 #define LL_USART_PHASE_1EDGE 0x00000000U /*!< The first clock transition is the first data capture edge */
343 #define LL_USART_PHASE_2EDGE USART_CR2_CPHA /*!< The second clock transition is the first data capture edge */
345 * @}
348 /** @defgroup USART_LL_EC_POLARITY Clock Polarity
349 * @{
351 #define LL_USART_POLARITY_LOW 0x00000000U /*!< Steady low value on SCLK pin outside transmission window*/
352 #define LL_USART_POLARITY_HIGH USART_CR2_CPOL /*!< Steady high value on SCLK pin outside transmission window */
354 * @}
357 /** @defgroup USART_LL_EC_PRESCALER Clock Source Prescaler
358 * @{
360 #define LL_USART_PRESCALER_DIV1 0x00000000U /*!< Input clock not devided */
361 #define LL_USART_PRESCALER_DIV2 (USART_PRESC_PRESCALER_0) /*!< Input clock devided by 2 */
362 #define LL_USART_PRESCALER_DIV4 (USART_PRESC_PRESCALER_1) /*!< Input clock devided by 4 */
363 #define LL_USART_PRESCALER_DIV6 (USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock devided by 6 */
364 #define LL_USART_PRESCALER_DIV8 (USART_PRESC_PRESCALER_2) /*!< Input clock devided by 8 */
365 #define LL_USART_PRESCALER_DIV10 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_0) /*!< Input clock devided by 10 */
366 #define LL_USART_PRESCALER_DIV12 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_1) /*!< Input clock devided by 12 */
367 #define LL_USART_PRESCALER_DIV16 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock devided by 16 */
368 #define LL_USART_PRESCALER_DIV32 (USART_PRESC_PRESCALER_3) /*!< Input clock devided by 32 */
369 #define LL_USART_PRESCALER_DIV64 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_0) /*!< Input clock devided by 64 */
370 #define LL_USART_PRESCALER_DIV128 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_1) /*!< Input clock devided by 128 */
371 #define LL_USART_PRESCALER_DIV256 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock devided by 256 */
373 * @}
376 /** @defgroup USART_LL_EC_STOPBITS Stop Bits
377 * @{
379 #define LL_USART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< 0.5 stop bit */
380 #define LL_USART_STOPBITS_1 0x00000000U /*!< 1 stop bit */
381 #define LL_USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< 1.5 stop bits */
382 #define LL_USART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */
384 * @}
387 /** @defgroup USART_LL_EC_TXRX TX RX Pins Swap
388 * @{
390 #define LL_USART_TXRX_STANDARD 0x00000000U /*!< TX/RX pins are used as defined in standard pinout */
391 #define LL_USART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */
393 * @}
396 /** @defgroup USART_LL_EC_RXPIN_LEVEL RX Pin Active Level Inversion
397 * @{
399 #define LL_USART_RXPIN_LEVEL_STANDARD 0x00000000U /*!< RX pin signal works using the standard logic levels */
400 #define LL_USART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */
402 * @}
405 /** @defgroup USART_LL_EC_TXPIN_LEVEL TX Pin Active Level Inversion
406 * @{
408 #define LL_USART_TXPIN_LEVEL_STANDARD 0x00000000U /*!< TX pin signal works using the standard logic levels */
409 #define LL_USART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */
411 * @}
414 /** @defgroup USART_LL_EC_BINARY_LOGIC Binary Data Inversion
415 * @{
417 #define LL_USART_BINARY_LOGIC_POSITIVE 0x00000000U /*!< Logical data from the data register are send/received in positive/direct logic. (1=H, 0=L) */
418 #define LL_USART_BINARY_LOGIC_NEGATIVE USART_CR2_DATAINV /*!< Logical data from the data register are send/received in negative/inverse logic. (1=L, 0=H). The parity bit is also inverted. */
420 * @}
423 /** @defgroup USART_LL_EC_BITORDER Bit Order
424 * @{
426 #define LL_USART_BITORDER_LSBFIRST 0x00000000U /*!< data is transmitted/received with data bit 0 first, following the start bit */
427 #define LL_USART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first, following the start bit */
429 * @}
432 /** @defgroup USART_LL_EC_AUTOBAUD_DETECT_ON Autobaud Detection
433 * @{
435 #define LL_USART_AUTOBAUD_DETECT_ON_STARTBIT 0x00000000U /*!< Measurement of the start bit is used to detect the baud rate */
436 #define LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE USART_CR2_ABRMODE_0 /*!< Falling edge to falling edge measurement. Received frame must start with a single bit = 1 -> Frame = Start10xxxxxx */
437 #define LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME USART_CR2_ABRMODE_1 /*!< 0x7F frame detection */
438 #define LL_USART_AUTOBAUD_DETECT_ON_55_FRAME (USART_CR2_ABRMODE_1 | USART_CR2_ABRMODE_0) /*!< 0x55 frame detection */
440 * @}
443 /** @defgroup USART_LL_EC_ADDRESS_DETECT Address Length Detection
444 * @{
446 #define LL_USART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit address detection method selected */
447 #define LL_USART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */
449 * @}
452 /** @defgroup USART_LL_EC_HWCONTROL Hardware Control
453 * @{
455 #define LL_USART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */
456 #define LL_USART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */
457 #define LL_USART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */
458 #define LL_USART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */
460 * @}
463 /** @defgroup USART_LL_EC_WAKEUP_ON Wakeup Activation
464 * @{
466 #define LL_USART_WAKEUP_ON_ADDRESS 0x00000000U /*!< Wake up active on address match */
467 #define LL_USART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wake up active on Start bit detection */
468 #define LL_USART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wake up active on RXNE */
470 * @}
473 /** @defgroup USART_LL_EC_IRDA_POWER IrDA Power
474 * @{
476 #define LL_USART_IRDA_POWER_NORMAL 0x00000000U /*!< IrDA normal power mode */
477 #define LL_USART_IRDA_POWER_LOW USART_CR3_IRLP /*!< IrDA low power mode */
479 * @}
482 /** @defgroup USART_LL_EC_LINBREAK_DETECT LIN Break Detection Length
483 * @{
485 #define LL_USART_LINBREAK_DETECT_10B 0x00000000U /*!< 10-bit break detection method selected */
486 #define LL_USART_LINBREAK_DETECT_11B USART_CR2_LBDL /*!< 11-bit break detection method selected */
488 * @}
491 /** @defgroup USART_LL_EC_DE_POLARITY Driver Enable Polarity
492 * @{
494 #define LL_USART_DE_POLARITY_HIGH 0x00000000U /*!< DE signal is active high */
495 #define LL_USART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */
497 * @}
500 /** @defgroup USART_LL_EC_DMA_REG_DATA DMA Register Data
501 * @{
503 #define LL_USART_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */
504 #define LL_USART_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */
506 * @}
510 * @}
513 /* Exported macro ------------------------------------------------------------*/
514 /** @defgroup USART_LL_Exported_Macros USART Exported Macros
515 * @{
518 /** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros
519 * @{
523 * @brief Write a value in USART register
524 * @param __INSTANCE__ USART Instance
525 * @param __REG__ Register to be written
526 * @param __VALUE__ Value to be written in the register
527 * @retval None
529 #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
532 * @brief Read a value in USART register
533 * @param __INSTANCE__ USART Instance
534 * @param __REG__ Register to be read
535 * @retval Register value
537 #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
539 * @}
542 /** @defgroup USART_LL_EM_Exported_Macros_Helper Exported_Macros_Helper
543 * @{
547 * @brief Compute USARTDIV value according to Peripheral Clock and
548 * expected Baud Rate in 8 bits sampling mode (32 bits value of USARTDIV is returned)
549 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance
550 * @param __PRESCALER__ This parameter can be one of the following values:
551 * @arg @ref LL_USART_PRESCALER_DIV1
552 * @arg @ref LL_USART_PRESCALER_DIV2
553 * @arg @ref LL_USART_PRESCALER_DIV4
554 * @arg @ref LL_USART_PRESCALER_DIV6
555 * @arg @ref LL_USART_PRESCALER_DIV8
556 * @arg @ref LL_USART_PRESCALER_DIV10
557 * @arg @ref LL_USART_PRESCALER_DIV12
558 * @arg @ref LL_USART_PRESCALER_DIV16
559 * @arg @ref LL_USART_PRESCALER_DIV32
560 * @arg @ref LL_USART_PRESCALER_DIV64
561 * @arg @ref LL_USART_PRESCALER_DIV128
562 * @arg @ref LL_USART_PRESCALER_DIV256
563 * @param __BAUDRATE__ Baud rate value to achieve
564 * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case
566 #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __PRESCALER__, __BAUDRATE__) (((((__PERIPHCLK__)/(USART_PRESCALER_TAB[(__PRESCALER__)]))*2U)\
567 + ((__BAUDRATE__)/2U))/(__BAUDRATE__))
570 * @brief Compute USARTDIV value according to Peripheral Clock and
571 * expected Baud Rate in 16 bits sampling mode (32 bits value of USARTDIV is returned)
572 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance
573 * @param __PRESCALER__ This parameter can be one of the following values:
574 * @arg @ref LL_USART_PRESCALER_DIV1
575 * @arg @ref LL_USART_PRESCALER_DIV2
576 * @arg @ref LL_USART_PRESCALER_DIV4
577 * @arg @ref LL_USART_PRESCALER_DIV6
578 * @arg @ref LL_USART_PRESCALER_DIV8
579 * @arg @ref LL_USART_PRESCALER_DIV10
580 * @arg @ref LL_USART_PRESCALER_DIV12
581 * @arg @ref LL_USART_PRESCALER_DIV16
582 * @arg @ref LL_USART_PRESCALER_DIV32
583 * @arg @ref LL_USART_PRESCALER_DIV64
584 * @arg @ref LL_USART_PRESCALER_DIV128
585 * @arg @ref LL_USART_PRESCALER_DIV256
586 * @param __BAUDRATE__ Baud rate value to achieve
587 * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case
589 #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __PRESCALER__, __BAUDRATE__) ((((__PERIPHCLK__)/(USART_PRESCALER_TAB[(__PRESCALER__)]))\
590 + ((__BAUDRATE__)/2U))/(__BAUDRATE__))
593 * @}
597 * @}
600 /* Exported functions --------------------------------------------------------*/
602 /** @defgroup USART_LL_Exported_Functions USART Exported Functions
603 * @{
606 /** @defgroup USART_LL_EF_Configuration Configuration functions
607 * @{
611 * @brief USART Enable
612 * @rmtoll CR1 UE LL_USART_Enable
613 * @param USARTx USART Instance
614 * @retval None
616 __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx)
618 SET_BIT(USARTx->CR1, USART_CR1_UE);
622 * @brief USART Disable (all USART prescalers and outputs are disabled)
623 * @note When USART is disabled, USART prescalers and outputs are stopped immediately,
624 * and current operations are discarded. The configuration of the USART is kept, but all the status
625 * flags, in the USARTx_ISR are set to their default values.
626 * @rmtoll CR1 UE LL_USART_Disable
627 * @param USARTx USART Instance
628 * @retval None
630 __STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx)
632 CLEAR_BIT(USARTx->CR1, USART_CR1_UE);
636 * @brief Indicate if USART is enabled
637 * @rmtoll CR1 UE LL_USART_IsEnabled
638 * @param USARTx USART Instance
639 * @retval State of bit (1 or 0).
641 __STATIC_INLINE uint32_t LL_USART_IsEnabled(USART_TypeDef *USARTx)
643 return ((READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE)) ? 1UL : 0UL);
647 * @brief FIFO Mode Enable
648 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
649 * FIFO mode feature is supported by the USARTx instance.
650 * @rmtoll CR1 FIFOEN LL_USART_EnableFIFO
651 * @param USARTx USART Instance
652 * @retval None
654 __STATIC_INLINE void LL_USART_EnableFIFO(USART_TypeDef *USARTx)
656 SET_BIT(USARTx->CR1, USART_CR1_FIFOEN);
660 * @brief FIFO Mode Disable
661 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
662 * FIFO mode feature is supported by the USARTx instance.
663 * @rmtoll CR1 FIFOEN LL_USART_DisableFIFO
664 * @param USARTx USART Instance
665 * @retval None
667 __STATIC_INLINE void LL_USART_DisableFIFO(USART_TypeDef *USARTx)
669 CLEAR_BIT(USARTx->CR1, USART_CR1_FIFOEN);
673 * @brief Indicate if FIFO Mode is enabled
674 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
675 * FIFO mode feature is supported by the USARTx instance.
676 * @rmtoll CR1 FIFOEN LL_USART_IsEnabledFIFO
677 * @param USARTx USART Instance
678 * @retval State of bit (1 or 0).
680 __STATIC_INLINE uint32_t LL_USART_IsEnabledFIFO(USART_TypeDef *USARTx)
682 return ((READ_BIT(USARTx->CR1, USART_CR1_FIFOEN) == (USART_CR1_FIFOEN)) ? 1UL : 0UL);
686 * @brief Configure TX FIFO Threshold
687 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
688 * FIFO mode feature is supported by the USARTx instance.
689 * @rmtoll CR3 TXFTCFG LL_USART_SetTXFIFOThreshold
690 * @param USARTx USART Instance
691 * @param Threshold This parameter can be one of the following values:
692 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8
693 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4
694 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2
695 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4
696 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8
697 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8
698 * @retval None
700 __STATIC_INLINE void LL_USART_SetTXFIFOThreshold(USART_TypeDef *USARTx, uint32_t Threshold)
702 MODIFY_REG(USARTx->CR3, USART_CR3_TXFTCFG, Threshold << USART_CR3_TXFTCFG_Pos);
706 * @brief Return TX FIFO Threshold Configuration
707 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
708 * FIFO mode feature is supported by the USARTx instance.
709 * @rmtoll CR3 TXFTCFG LL_USART_GetTXFIFOThreshold
710 * @param USARTx USART Instance
711 * @retval Returned value can be one of the following values:
712 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8
713 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4
714 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2
715 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4
716 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8
717 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8
719 __STATIC_INLINE uint32_t LL_USART_GetTXFIFOThreshold(USART_TypeDef *USARTx)
721 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_TXFTCFG) >> USART_CR3_TXFTCFG_Pos);
725 * @brief Configure RX FIFO Threshold
726 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
727 * FIFO mode feature is supported by the USARTx instance.
728 * @rmtoll CR3 RXFTCFG LL_USART_SetRXFIFOThreshold
729 * @param USARTx USART Instance
730 * @param Threshold This parameter can be one of the following values:
731 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8
732 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4
733 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2
734 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4
735 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8
736 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8
737 * @retval None
739 __STATIC_INLINE void LL_USART_SetRXFIFOThreshold(USART_TypeDef *USARTx, uint32_t Threshold)
741 MODIFY_REG(USARTx->CR3, USART_CR3_RXFTCFG, Threshold << USART_CR3_RXFTCFG_Pos);
745 * @brief Return RX FIFO Threshold Configuration
746 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
747 * FIFO mode feature is supported by the USARTx instance.
748 * @rmtoll CR3 RXFTCFG LL_USART_GetRXFIFOThreshold
749 * @param USARTx USART Instance
750 * @retval Returned value can be one of the following values:
751 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8
752 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4
753 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2
754 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4
755 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8
756 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8
758 __STATIC_INLINE uint32_t LL_USART_GetRXFIFOThreshold(USART_TypeDef *USARTx)
760 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RXFTCFG) >> USART_CR3_RXFTCFG_Pos);
764 * @brief Configure TX and RX FIFOs Threshold
765 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
766 * FIFO mode feature is supported by the USARTx instance.
767 * @rmtoll CR3 TXFTCFG LL_USART_ConfigFIFOsThreshold\n
768 * CR3 RXFTCFG LL_USART_ConfigFIFOsThreshold
769 * @param USARTx USART Instance
770 * @param TXThreshold This parameter can be one of the following values:
771 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8
772 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4
773 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2
774 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4
775 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8
776 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8
777 * @param RXThreshold This parameter can be one of the following values:
778 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8
779 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4
780 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2
781 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4
782 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8
783 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8
784 * @retval None
786 __STATIC_INLINE void LL_USART_ConfigFIFOsThreshold(USART_TypeDef *USARTx, uint32_t TXThreshold, uint32_t RXThreshold)
788 MODIFY_REG(USARTx->CR3, USART_CR3_TXFTCFG | USART_CR3_RXFTCFG, (TXThreshold << USART_CR3_TXFTCFG_Pos) | (RXThreshold << USART_CR3_RXFTCFG_Pos));
792 * @brief USART enabled in STOP Mode.
793 * @note When this function is enabled, USART is able to wake up the MCU from Stop mode, provided that
794 * USART clock selection is HSI or LSE in RCC.
795 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
796 * Wake-up from Stop mode feature is supported by the USARTx instance.
797 * @rmtoll CR1 UESM LL_USART_EnableInStopMode
798 * @param USARTx USART Instance
799 * @retval None
801 __STATIC_INLINE void LL_USART_EnableInStopMode(USART_TypeDef *USARTx)
803 SET_BIT(USARTx->CR1, USART_CR1_UESM);
807 * @brief USART disabled in STOP Mode.
808 * @note When this function is disabled, USART is not able to wake up the MCU from Stop mode
809 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
810 * Wake-up from Stop mode feature is supported by the USARTx instance.
811 * @rmtoll CR1 UESM LL_USART_DisableInStopMode
812 * @param USARTx USART Instance
813 * @retval None
815 __STATIC_INLINE void LL_USART_DisableInStopMode(USART_TypeDef *USARTx)
817 CLEAR_BIT(USARTx->CR1, USART_CR1_UESM);
821 * @brief Indicate if USART is enabled in STOP Mode (able to wake up MCU from Stop mode or not)
822 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
823 * Wake-up from Stop mode feature is supported by the USARTx instance.
824 * @rmtoll CR1 UESM LL_USART_IsEnabledInStopMode
825 * @param USARTx USART Instance
826 * @retval State of bit (1 or 0).
828 __STATIC_INLINE uint32_t LL_USART_IsEnabledInStopMode(USART_TypeDef *USARTx)
830 return ((READ_BIT(USARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM)) ? 1UL : 0UL);
834 * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit)
835 * @rmtoll CR1 RE LL_USART_EnableDirectionRx
836 * @param USARTx USART Instance
837 * @retval None
839 __STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx)
841 SET_BIT(USARTx->CR1, USART_CR1_RE);
845 * @brief Receiver Disable
846 * @rmtoll CR1 RE LL_USART_DisableDirectionRx
847 * @param USARTx USART Instance
848 * @retval None
850 __STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx)
852 CLEAR_BIT(USARTx->CR1, USART_CR1_RE);
856 * @brief Transmitter Enable
857 * @rmtoll CR1 TE LL_USART_EnableDirectionTx
858 * @param USARTx USART Instance
859 * @retval None
861 __STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx)
863 SET_BIT(USARTx->CR1, USART_CR1_TE);
867 * @brief Transmitter Disable
868 * @rmtoll CR1 TE LL_USART_DisableDirectionTx
869 * @param USARTx USART Instance
870 * @retval None
872 __STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx)
874 CLEAR_BIT(USARTx->CR1, USART_CR1_TE);
878 * @brief Configure simultaneously enabled/disabled states
879 * of Transmitter and Receiver
880 * @rmtoll CR1 RE LL_USART_SetTransferDirection\n
881 * CR1 TE LL_USART_SetTransferDirection
882 * @param USARTx USART Instance
883 * @param TransferDirection This parameter can be one of the following values:
884 * @arg @ref LL_USART_DIRECTION_NONE
885 * @arg @ref LL_USART_DIRECTION_RX
886 * @arg @ref LL_USART_DIRECTION_TX
887 * @arg @ref LL_USART_DIRECTION_TX_RX
888 * @retval None
890 __STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t TransferDirection)
892 MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection);
896 * @brief Return enabled/disabled states of Transmitter and Receiver
897 * @rmtoll CR1 RE LL_USART_GetTransferDirection\n
898 * CR1 TE LL_USART_GetTransferDirection
899 * @param USARTx USART Instance
900 * @retval Returned value can be one of the following values:
901 * @arg @ref LL_USART_DIRECTION_NONE
902 * @arg @ref LL_USART_DIRECTION_RX
903 * @arg @ref LL_USART_DIRECTION_TX
904 * @arg @ref LL_USART_DIRECTION_TX_RX
906 __STATIC_INLINE uint32_t LL_USART_GetTransferDirection(USART_TypeDef *USARTx)
908 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE));
912 * @brief Configure Parity (enabled/disabled and parity mode if enabled).
913 * @note This function selects if hardware parity control (generation and detection) is enabled or disabled.
914 * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position
915 * (9th or 8th bit depending on data width) and parity is checked on the received data.
916 * @rmtoll CR1 PS LL_USART_SetParity\n
917 * CR1 PCE LL_USART_SetParity
918 * @param USARTx USART Instance
919 * @param Parity This parameter can be one of the following values:
920 * @arg @ref LL_USART_PARITY_NONE
921 * @arg @ref LL_USART_PARITY_EVEN
922 * @arg @ref LL_USART_PARITY_ODD
923 * @retval None
925 __STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t Parity)
927 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity);
931 * @brief Return Parity configuration (enabled/disabled and parity mode if enabled)
932 * @rmtoll CR1 PS LL_USART_GetParity\n
933 * CR1 PCE LL_USART_GetParity
934 * @param USARTx USART Instance
935 * @retval Returned value can be one of the following values:
936 * @arg @ref LL_USART_PARITY_NONE
937 * @arg @ref LL_USART_PARITY_EVEN
938 * @arg @ref LL_USART_PARITY_ODD
940 __STATIC_INLINE uint32_t LL_USART_GetParity(USART_TypeDef *USARTx)
942 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE));
946 * @brief Set Receiver Wake Up method from Mute mode.
947 * @rmtoll CR1 WAKE LL_USART_SetWakeUpMethod
948 * @param USARTx USART Instance
949 * @param Method This parameter can be one of the following values:
950 * @arg @ref LL_USART_WAKEUP_IDLELINE
951 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK
952 * @retval None
954 __STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method)
956 MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method);
960 * @brief Return Receiver Wake Up method from Mute mode
961 * @rmtoll CR1 WAKE LL_USART_GetWakeUpMethod
962 * @param USARTx USART Instance
963 * @retval Returned value can be one of the following values:
964 * @arg @ref LL_USART_WAKEUP_IDLELINE
965 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK
967 __STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(USART_TypeDef *USARTx)
969 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE));
973 * @brief Set Word length (i.e. nb of data bits, excluding start and stop bits)
974 * @rmtoll CR1 M0 LL_USART_SetDataWidth\n
975 * CR1 M1 LL_USART_SetDataWidth
976 * @param USARTx USART Instance
977 * @param DataWidth This parameter can be one of the following values:
978 * @arg @ref LL_USART_DATAWIDTH_7B
979 * @arg @ref LL_USART_DATAWIDTH_8B
980 * @arg @ref LL_USART_DATAWIDTH_9B
981 * @retval None
983 __STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth)
985 MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth);
989 * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits)
990 * @rmtoll CR1 M0 LL_USART_GetDataWidth\n
991 * CR1 M1 LL_USART_GetDataWidth
992 * @param USARTx USART Instance
993 * @retval Returned value can be one of the following values:
994 * @arg @ref LL_USART_DATAWIDTH_7B
995 * @arg @ref LL_USART_DATAWIDTH_8B
996 * @arg @ref LL_USART_DATAWIDTH_9B
998 __STATIC_INLINE uint32_t LL_USART_GetDataWidth(USART_TypeDef *USARTx)
1000 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M));
1004 * @brief Allow switch between Mute Mode and Active mode
1005 * @rmtoll CR1 MME LL_USART_EnableMuteMode
1006 * @param USARTx USART Instance
1007 * @retval None
1009 __STATIC_INLINE void LL_USART_EnableMuteMode(USART_TypeDef *USARTx)
1011 SET_BIT(USARTx->CR1, USART_CR1_MME);
1015 * @brief Prevent Mute Mode use. Set Receiver in active mode permanently.
1016 * @rmtoll CR1 MME LL_USART_DisableMuteMode
1017 * @param USARTx USART Instance
1018 * @retval None
1020 __STATIC_INLINE void LL_USART_DisableMuteMode(USART_TypeDef *USARTx)
1022 CLEAR_BIT(USARTx->CR1, USART_CR1_MME);
1026 * @brief Indicate if switch between Mute Mode and Active mode is allowed
1027 * @rmtoll CR1 MME LL_USART_IsEnabledMuteMode
1028 * @param USARTx USART Instance
1029 * @retval State of bit (1 or 0).
1031 __STATIC_INLINE uint32_t LL_USART_IsEnabledMuteMode(USART_TypeDef *USARTx)
1033 return ((READ_BIT(USARTx->CR1, USART_CR1_MME) == (USART_CR1_MME)) ? 1UL : 0UL);
1037 * @brief Set Oversampling to 8-bit or 16-bit mode
1038 * @rmtoll CR1 OVER8 LL_USART_SetOverSampling
1039 * @param USARTx USART Instance
1040 * @param OverSampling This parameter can be one of the following values:
1041 * @arg @ref LL_USART_OVERSAMPLING_16
1042 * @arg @ref LL_USART_OVERSAMPLING_8
1043 * @retval None
1045 __STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling)
1047 MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling);
1051 * @brief Return Oversampling mode
1052 * @rmtoll CR1 OVER8 LL_USART_GetOverSampling
1053 * @param USARTx USART Instance
1054 * @retval Returned value can be one of the following values:
1055 * @arg @ref LL_USART_OVERSAMPLING_16
1056 * @arg @ref LL_USART_OVERSAMPLING_8
1058 __STATIC_INLINE uint32_t LL_USART_GetOverSampling(USART_TypeDef *USARTx)
1060 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8));
1064 * @brief Configure if Clock pulse of the last data bit is output to the SCLK pin or not
1065 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not
1066 * Synchronous mode is supported by the USARTx instance.
1067 * @rmtoll CR2 LBCL LL_USART_SetLastClkPulseOutput
1068 * @param USARTx USART Instance
1069 * @param LastBitClockPulse This parameter can be one of the following values:
1070 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
1071 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
1072 * @retval None
1074 __STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LastBitClockPulse)
1076 MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LastBitClockPulse);
1080 * @brief Retrieve Clock pulse of the last data bit output configuration
1081 * (Last bit Clock pulse output to the SCLK pin or not)
1082 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not
1083 * Synchronous mode is supported by the USARTx instance.
1084 * @rmtoll CR2 LBCL LL_USART_GetLastClkPulseOutput
1085 * @param USARTx USART Instance
1086 * @retval Returned value can be one of the following values:
1087 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
1088 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
1090 __STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(USART_TypeDef *USARTx)
1092 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL));
1096 * @brief Select the phase of the clock output on the SCLK pin in synchronous mode
1097 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not
1098 * Synchronous mode is supported by the USARTx instance.
1099 * @rmtoll CR2 CPHA LL_USART_SetClockPhase
1100 * @param USARTx USART Instance
1101 * @param ClockPhase This parameter can be one of the following values:
1102 * @arg @ref LL_USART_PHASE_1EDGE
1103 * @arg @ref LL_USART_PHASE_2EDGE
1104 * @retval None
1106 __STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t ClockPhase)
1108 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, ClockPhase);
1112 * @brief Return phase of the clock output on the SCLK pin in synchronous mode
1113 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not
1114 * Synchronous mode is supported by the USARTx instance.
1115 * @rmtoll CR2 CPHA LL_USART_GetClockPhase
1116 * @param USARTx USART Instance
1117 * @retval Returned value can be one of the following values:
1118 * @arg @ref LL_USART_PHASE_1EDGE
1119 * @arg @ref LL_USART_PHASE_2EDGE
1121 __STATIC_INLINE uint32_t LL_USART_GetClockPhase(USART_TypeDef *USARTx)
1123 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA));
1127 * @brief Select the polarity of the clock output on the SCLK pin in synchronous mode
1128 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not
1129 * Synchronous mode is supported by the USARTx instance.
1130 * @rmtoll CR2 CPOL LL_USART_SetClockPolarity
1131 * @param USARTx USART Instance
1132 * @param ClockPolarity This parameter can be one of the following values:
1133 * @arg @ref LL_USART_POLARITY_LOW
1134 * @arg @ref LL_USART_POLARITY_HIGH
1135 * @retval None
1137 __STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t ClockPolarity)
1139 MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, ClockPolarity);
1143 * @brief Return polarity of the clock output on the SCLK pin in synchronous mode
1144 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not
1145 * Synchronous mode is supported by the USARTx instance.
1146 * @rmtoll CR2 CPOL LL_USART_GetClockPolarity
1147 * @param USARTx USART Instance
1148 * @retval Returned value can be one of the following values:
1149 * @arg @ref LL_USART_POLARITY_LOW
1150 * @arg @ref LL_USART_POLARITY_HIGH
1152 __STATIC_INLINE uint32_t LL_USART_GetClockPolarity(USART_TypeDef *USARTx)
1154 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL));
1158 * @brief Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse)
1159 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not
1160 * Synchronous mode is supported by the USARTx instance.
1161 * @note Call of this function is equivalent to following function call sequence :
1162 * - Clock Phase configuration using @ref LL_USART_SetClockPhase() function
1163 * - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function
1164 * - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function
1165 * @rmtoll CR2 CPHA LL_USART_ConfigClock\n
1166 * CR2 CPOL LL_USART_ConfigClock\n
1167 * CR2 LBCL LL_USART_ConfigClock
1168 * @param USARTx USART Instance
1169 * @param Phase This parameter can be one of the following values:
1170 * @arg @ref LL_USART_PHASE_1EDGE
1171 * @arg @ref LL_USART_PHASE_2EDGE
1172 * @param Polarity This parameter can be one of the following values:
1173 * @arg @ref LL_USART_POLARITY_LOW
1174 * @arg @ref LL_USART_POLARITY_HIGH
1175 * @param LBCPOutput This parameter can be one of the following values:
1176 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
1177 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
1178 * @retval None
1180 __STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput)
1182 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput);
1186 * @brief Configure Clock source prescaler for baudrate generator and oversampling
1187 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
1188 * FIFO mode feature is supported by the USARTx instance.
1189 * @rmtoll PRESC PRESCALER LL_USART_SetPrescaler
1190 * @param USARTx USART Instance
1191 * @param PrescalerValue This parameter can be one of the following values:
1192 * @arg @ref LL_USART_PRESCALER_DIV1
1193 * @arg @ref LL_USART_PRESCALER_DIV2
1194 * @arg @ref LL_USART_PRESCALER_DIV4
1195 * @arg @ref LL_USART_PRESCALER_DIV6
1196 * @arg @ref LL_USART_PRESCALER_DIV8
1197 * @arg @ref LL_USART_PRESCALER_DIV10
1198 * @arg @ref LL_USART_PRESCALER_DIV12
1199 * @arg @ref LL_USART_PRESCALER_DIV16
1200 * @arg @ref LL_USART_PRESCALER_DIV32
1201 * @arg @ref LL_USART_PRESCALER_DIV64
1202 * @arg @ref LL_USART_PRESCALER_DIV128
1203 * @arg @ref LL_USART_PRESCALER_DIV256
1204 * @retval None
1206 __STATIC_INLINE void LL_USART_SetPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
1208 MODIFY_REG(USARTx->PRESC, USART_PRESC_PRESCALER, (uint16_t)PrescalerValue);
1212 * @brief Retrieve the Clock source prescaler for baudrate generator and oversampling
1213 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
1214 * FIFO mode feature is supported by the USARTx instance.
1215 * @rmtoll PRESC PRESCALER LL_USART_GetPrescaler
1216 * @param USARTx USART Instance
1217 * @retval Returned value can be one of the following values:
1218 * @arg @ref LL_USART_PRESCALER_DIV1
1219 * @arg @ref LL_USART_PRESCALER_DIV2
1220 * @arg @ref LL_USART_PRESCALER_DIV4
1221 * @arg @ref LL_USART_PRESCALER_DIV6
1222 * @arg @ref LL_USART_PRESCALER_DIV8
1223 * @arg @ref LL_USART_PRESCALER_DIV10
1224 * @arg @ref LL_USART_PRESCALER_DIV12
1225 * @arg @ref LL_USART_PRESCALER_DIV16
1226 * @arg @ref LL_USART_PRESCALER_DIV32
1227 * @arg @ref LL_USART_PRESCALER_DIV64
1228 * @arg @ref LL_USART_PRESCALER_DIV128
1229 * @arg @ref LL_USART_PRESCALER_DIV256
1231 __STATIC_INLINE uint32_t LL_USART_GetPrescaler(USART_TypeDef *USARTx)
1233 return (uint32_t)(READ_BIT(USARTx->PRESC, USART_PRESC_PRESCALER));
1237 * @brief Enable Clock output on SCLK pin
1238 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not
1239 * Synchronous mode is supported by the USARTx instance.
1240 * @rmtoll CR2 CLKEN LL_USART_EnableSCLKOutput
1241 * @param USARTx USART Instance
1242 * @retval None
1244 __STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx)
1246 SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
1250 * @brief Disable Clock output on SCLK pin
1251 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not
1252 * Synchronous mode is supported by the USARTx instance.
1253 * @rmtoll CR2 CLKEN LL_USART_DisableSCLKOutput
1254 * @param USARTx USART Instance
1255 * @retval None
1257 __STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx)
1259 CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN);
1263 * @brief Indicate if Clock output on SCLK pin is enabled
1264 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not
1265 * Synchronous mode is supported by the USARTx instance.
1266 * @rmtoll CR2 CLKEN LL_USART_IsEnabledSCLKOutput
1267 * @param USARTx USART Instance
1268 * @retval State of bit (1 or 0).
1270 __STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(USART_TypeDef *USARTx)
1272 return ((READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN)) ? 1UL : 0UL);
1276 * @brief Set the length of the stop bits
1277 * @rmtoll CR2 STOP LL_USART_SetStopBitsLength
1278 * @param USARTx USART Instance
1279 * @param StopBits This parameter can be one of the following values:
1280 * @arg @ref LL_USART_STOPBITS_0_5
1281 * @arg @ref LL_USART_STOPBITS_1
1282 * @arg @ref LL_USART_STOPBITS_1_5
1283 * @arg @ref LL_USART_STOPBITS_2
1284 * @retval None
1286 __STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits)
1288 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
1292 * @brief Retrieve the length of the stop bits
1293 * @rmtoll CR2 STOP LL_USART_GetStopBitsLength
1294 * @param USARTx USART Instance
1295 * @retval Returned value can be one of the following values:
1296 * @arg @ref LL_USART_STOPBITS_0_5
1297 * @arg @ref LL_USART_STOPBITS_1
1298 * @arg @ref LL_USART_STOPBITS_1_5
1299 * @arg @ref LL_USART_STOPBITS_2
1301 __STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(USART_TypeDef *USARTx)
1303 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP));
1307 * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits)
1308 * @note Call of this function is equivalent to following function call sequence :
1309 * - Data Width configuration using @ref LL_USART_SetDataWidth() function
1310 * - Parity Control and mode configuration using @ref LL_USART_SetParity() function
1311 * - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function
1312 * @rmtoll CR1 PS LL_USART_ConfigCharacter\n
1313 * CR1 PCE LL_USART_ConfigCharacter\n
1314 * CR1 M0 LL_USART_ConfigCharacter\n
1315 * CR1 M1 LL_USART_ConfigCharacter\n
1316 * CR2 STOP LL_USART_ConfigCharacter
1317 * @param USARTx USART Instance
1318 * @param DataWidth This parameter can be one of the following values:
1319 * @arg @ref LL_USART_DATAWIDTH_7B
1320 * @arg @ref LL_USART_DATAWIDTH_8B
1321 * @arg @ref LL_USART_DATAWIDTH_9B
1322 * @param Parity This parameter can be one of the following values:
1323 * @arg @ref LL_USART_PARITY_NONE
1324 * @arg @ref LL_USART_PARITY_EVEN
1325 * @arg @ref LL_USART_PARITY_ODD
1326 * @param StopBits This parameter can be one of the following values:
1327 * @arg @ref LL_USART_STOPBITS_0_5
1328 * @arg @ref LL_USART_STOPBITS_1
1329 * @arg @ref LL_USART_STOPBITS_1_5
1330 * @arg @ref LL_USART_STOPBITS_2
1331 * @retval None
1333 __STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t Parity,
1334 uint32_t StopBits)
1336 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth);
1337 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
1341 * @brief Configure TX/RX pins swapping setting.
1342 * @rmtoll CR2 SWAP LL_USART_SetTXRXSwap
1343 * @param USARTx USART Instance
1344 * @param SwapConfig This parameter can be one of the following values:
1345 * @arg @ref LL_USART_TXRX_STANDARD
1346 * @arg @ref LL_USART_TXRX_SWAPPED
1347 * @retval None
1349 __STATIC_INLINE void LL_USART_SetTXRXSwap(USART_TypeDef *USARTx, uint32_t SwapConfig)
1351 MODIFY_REG(USARTx->CR2, USART_CR2_SWAP, SwapConfig);
1355 * @brief Retrieve TX/RX pins swapping configuration.
1356 * @rmtoll CR2 SWAP LL_USART_GetTXRXSwap
1357 * @param USARTx USART Instance
1358 * @retval Returned value can be one of the following values:
1359 * @arg @ref LL_USART_TXRX_STANDARD
1360 * @arg @ref LL_USART_TXRX_SWAPPED
1362 __STATIC_INLINE uint32_t LL_USART_GetTXRXSwap(USART_TypeDef *USARTx)
1364 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_SWAP));
1368 * @brief Configure RX pin active level logic
1369 * @rmtoll CR2 RXINV LL_USART_SetRXPinLevel
1370 * @param USARTx USART Instance
1371 * @param PinInvMethod This parameter can be one of the following values:
1372 * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD
1373 * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED
1374 * @retval None
1376 __STATIC_INLINE void LL_USART_SetRXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod)
1378 MODIFY_REG(USARTx->CR2, USART_CR2_RXINV, PinInvMethod);
1382 * @brief Retrieve RX pin active level logic configuration
1383 * @rmtoll CR2 RXINV LL_USART_GetRXPinLevel
1384 * @param USARTx USART Instance
1385 * @retval Returned value can be one of the following values:
1386 * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD
1387 * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED
1389 __STATIC_INLINE uint32_t LL_USART_GetRXPinLevel(USART_TypeDef *USARTx)
1391 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_RXINV));
1395 * @brief Configure TX pin active level logic
1396 * @rmtoll CR2 TXINV LL_USART_SetTXPinLevel
1397 * @param USARTx USART Instance
1398 * @param PinInvMethod This parameter can be one of the following values:
1399 * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD
1400 * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED
1401 * @retval None
1403 __STATIC_INLINE void LL_USART_SetTXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod)
1405 MODIFY_REG(USARTx->CR2, USART_CR2_TXINV, PinInvMethod);
1409 * @brief Retrieve TX pin active level logic configuration
1410 * @rmtoll CR2 TXINV LL_USART_GetTXPinLevel
1411 * @param USARTx USART Instance
1412 * @retval Returned value can be one of the following values:
1413 * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD
1414 * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED
1416 __STATIC_INLINE uint32_t LL_USART_GetTXPinLevel(USART_TypeDef *USARTx)
1418 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_TXINV));
1422 * @brief Configure Binary data logic.
1423 * @note Allow to define how Logical data from the data register are send/received :
1424 * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H)
1425 * @rmtoll CR2 DATAINV LL_USART_SetBinaryDataLogic
1426 * @param USARTx USART Instance
1427 * @param DataLogic This parameter can be one of the following values:
1428 * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE
1429 * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE
1430 * @retval None
1432 __STATIC_INLINE void LL_USART_SetBinaryDataLogic(USART_TypeDef *USARTx, uint32_t DataLogic)
1434 MODIFY_REG(USARTx->CR2, USART_CR2_DATAINV, DataLogic);
1438 * @brief Retrieve Binary data configuration
1439 * @rmtoll CR2 DATAINV LL_USART_GetBinaryDataLogic
1440 * @param USARTx USART Instance
1441 * @retval Returned value can be one of the following values:
1442 * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE
1443 * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE
1445 __STATIC_INLINE uint32_t LL_USART_GetBinaryDataLogic(USART_TypeDef *USARTx)
1447 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_DATAINV));
1451 * @brief Configure transfer bit order (either Less or Most Significant Bit First)
1452 * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
1453 * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
1454 * @rmtoll CR2 MSBFIRST LL_USART_SetTransferBitOrder
1455 * @param USARTx USART Instance
1456 * @param BitOrder This parameter can be one of the following values:
1457 * @arg @ref LL_USART_BITORDER_LSBFIRST
1458 * @arg @ref LL_USART_BITORDER_MSBFIRST
1459 * @retval None
1461 __STATIC_INLINE void LL_USART_SetTransferBitOrder(USART_TypeDef *USARTx, uint32_t BitOrder)
1463 MODIFY_REG(USARTx->CR2, USART_CR2_MSBFIRST, BitOrder);
1467 * @brief Return transfer bit order (either Less or Most Significant Bit First)
1468 * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
1469 * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
1470 * @rmtoll CR2 MSBFIRST LL_USART_GetTransferBitOrder
1471 * @param USARTx USART Instance
1472 * @retval Returned value can be one of the following values:
1473 * @arg @ref LL_USART_BITORDER_LSBFIRST
1474 * @arg @ref LL_USART_BITORDER_MSBFIRST
1476 __STATIC_INLINE uint32_t LL_USART_GetTransferBitOrder(USART_TypeDef *USARTx)
1478 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_MSBFIRST));
1482 * @brief Enable Auto Baud-Rate Detection
1483 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
1484 * Auto Baud Rate detection feature is supported by the USARTx instance.
1485 * @rmtoll CR2 ABREN LL_USART_EnableAutoBaudRate
1486 * @param USARTx USART Instance
1487 * @retval None
1489 __STATIC_INLINE void LL_USART_EnableAutoBaudRate(USART_TypeDef *USARTx)
1491 SET_BIT(USARTx->CR2, USART_CR2_ABREN);
1495 * @brief Disable Auto Baud-Rate Detection
1496 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
1497 * Auto Baud Rate detection feature is supported by the USARTx instance.
1498 * @rmtoll CR2 ABREN LL_USART_DisableAutoBaudRate
1499 * @param USARTx USART Instance
1500 * @retval None
1502 __STATIC_INLINE void LL_USART_DisableAutoBaudRate(USART_TypeDef *USARTx)
1504 CLEAR_BIT(USARTx->CR2, USART_CR2_ABREN);
1508 * @brief Indicate if Auto Baud-Rate Detection mechanism is enabled
1509 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
1510 * Auto Baud Rate detection feature is supported by the USARTx instance.
1511 * @rmtoll CR2 ABREN LL_USART_IsEnabledAutoBaud
1512 * @param USARTx USART Instance
1513 * @retval State of bit (1 or 0).
1515 __STATIC_INLINE uint32_t LL_USART_IsEnabledAutoBaud(USART_TypeDef *USARTx)
1517 return ((READ_BIT(USARTx->CR2, USART_CR2_ABREN) == (USART_CR2_ABREN)) ? 1UL : 0UL);
1521 * @brief Set Auto Baud-Rate mode bits
1522 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
1523 * Auto Baud Rate detection feature is supported by the USARTx instance.
1524 * @rmtoll CR2 ABRMODE LL_USART_SetAutoBaudRateMode
1525 * @param USARTx USART Instance
1526 * @param AutoBaudRateMode This parameter can be one of the following values:
1527 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT
1528 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE
1529 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME
1530 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME
1531 * @retval None
1533 __STATIC_INLINE void LL_USART_SetAutoBaudRateMode(USART_TypeDef *USARTx, uint32_t AutoBaudRateMode)
1535 MODIFY_REG(USARTx->CR2, USART_CR2_ABRMODE, AutoBaudRateMode);
1539 * @brief Return Auto Baud-Rate mode
1540 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
1541 * Auto Baud Rate detection feature is supported by the USARTx instance.
1542 * @rmtoll CR2 ABRMODE LL_USART_GetAutoBaudRateMode
1543 * @param USARTx USART Instance
1544 * @retval Returned value can be one of the following values:
1545 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT
1546 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE
1547 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME
1548 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME
1550 __STATIC_INLINE uint32_t LL_USART_GetAutoBaudRateMode(USART_TypeDef *USARTx)
1552 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ABRMODE));
1556 * @brief Enable Receiver Timeout
1557 * @rmtoll CR2 RTOEN LL_USART_EnableRxTimeout
1558 * @param USARTx USART Instance
1559 * @retval None
1561 __STATIC_INLINE void LL_USART_EnableRxTimeout(USART_TypeDef *USARTx)
1563 SET_BIT(USARTx->CR2, USART_CR2_RTOEN);
1567 * @brief Disable Receiver Timeout
1568 * @rmtoll CR2 RTOEN LL_USART_DisableRxTimeout
1569 * @param USARTx USART Instance
1570 * @retval None
1572 __STATIC_INLINE void LL_USART_DisableRxTimeout(USART_TypeDef *USARTx)
1574 CLEAR_BIT(USARTx->CR2, USART_CR2_RTOEN);
1578 * @brief Indicate if Receiver Timeout feature is enabled
1579 * @rmtoll CR2 RTOEN LL_USART_IsEnabledRxTimeout
1580 * @param USARTx USART Instance
1581 * @retval State of bit (1 or 0).
1583 __STATIC_INLINE uint32_t LL_USART_IsEnabledRxTimeout(USART_TypeDef *USARTx)
1585 return ((READ_BIT(USARTx->CR2, USART_CR2_RTOEN) == (USART_CR2_RTOEN)) ? 1UL : 0UL);
1589 * @brief Set Address of the USART node.
1590 * @note This is used in multiprocessor communication during Mute mode or Stop mode,
1591 * for wake up with address mark detection.
1592 * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7.
1593 * (b7-b4 should be set to 0)
1594 * 8bits address node is used when 7-bit Address Detection is selected in ADDM7.
1595 * (This is used in multiprocessor communication during Mute mode or Stop mode,
1596 * for wake up with 7-bit address mark detection.
1597 * The MSB of the character sent by the transmitter should be equal to 1.
1598 * It may also be used for character detection during normal reception,
1599 * Mute mode inactive (for example, end of block detection in ModBus protocol).
1600 * In this case, the whole received character (8-bit) is compared to the ADD[7:0]
1601 * value and CMF flag is set on match)
1602 * @rmtoll CR2 ADD LL_USART_ConfigNodeAddress\n
1603 * CR2 ADDM7 LL_USART_ConfigNodeAddress
1604 * @param USARTx USART Instance
1605 * @param AddressLen This parameter can be one of the following values:
1606 * @arg @ref LL_USART_ADDRESS_DETECT_4B
1607 * @arg @ref LL_USART_ADDRESS_DETECT_7B
1608 * @param NodeAddress 4 or 7 bit Address of the USART node.
1609 * @retval None
1611 __STATIC_INLINE void LL_USART_ConfigNodeAddress(USART_TypeDef *USARTx, uint32_t AddressLen, uint32_t NodeAddress)
1613 MODIFY_REG(USARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7,
1614 (uint32_t)(AddressLen | (NodeAddress << USART_CR2_ADD_Pos)));
1618 * @brief Return 8 bit Address of the USART node as set in ADD field of CR2.
1619 * @note If 4-bit Address Detection is selected in ADDM7,
1620 * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant)
1621 * If 7-bit Address Detection is selected in ADDM7,
1622 * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant)
1623 * @rmtoll CR2 ADD LL_USART_GetNodeAddress
1624 * @param USARTx USART Instance
1625 * @retval Address of the USART node (Value between Min_Data=0 and Max_Data=255)
1627 __STATIC_INLINE uint32_t LL_USART_GetNodeAddress(USART_TypeDef *USARTx)
1629 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD) >> USART_CR2_ADD_Pos);
1633 * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit)
1634 * @rmtoll CR2 ADDM7 LL_USART_GetNodeAddressLen
1635 * @param USARTx USART Instance
1636 * @retval Returned value can be one of the following values:
1637 * @arg @ref LL_USART_ADDRESS_DETECT_4B
1638 * @arg @ref LL_USART_ADDRESS_DETECT_7B
1640 __STATIC_INLINE uint32_t LL_USART_GetNodeAddressLen(USART_TypeDef *USARTx)
1642 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADDM7));
1646 * @brief Enable RTS HW Flow Control
1647 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
1648 * Hardware Flow control feature is supported by the USARTx instance.
1649 * @rmtoll CR3 RTSE LL_USART_EnableRTSHWFlowCtrl
1650 * @param USARTx USART Instance
1651 * @retval None
1653 __STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx)
1655 SET_BIT(USARTx->CR3, USART_CR3_RTSE);
1659 * @brief Disable RTS HW Flow Control
1660 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
1661 * Hardware Flow control feature is supported by the USARTx instance.
1662 * @rmtoll CR3 RTSE LL_USART_DisableRTSHWFlowCtrl
1663 * @param USARTx USART Instance
1664 * @retval None
1666 __STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx)
1668 CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE);
1672 * @brief Enable CTS HW Flow Control
1673 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
1674 * Hardware Flow control feature is supported by the USARTx instance.
1675 * @rmtoll CR3 CTSE LL_USART_EnableCTSHWFlowCtrl
1676 * @param USARTx USART Instance
1677 * @retval None
1679 __STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx)
1681 SET_BIT(USARTx->CR3, USART_CR3_CTSE);
1685 * @brief Disable CTS HW Flow Control
1686 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
1687 * Hardware Flow control feature is supported by the USARTx instance.
1688 * @rmtoll CR3 CTSE LL_USART_DisableCTSHWFlowCtrl
1689 * @param USARTx USART Instance
1690 * @retval None
1692 __STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx)
1694 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE);
1698 * @brief Configure HW Flow Control mode (both CTS and RTS)
1699 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
1700 * Hardware Flow control feature is supported by the USARTx instance.
1701 * @rmtoll CR3 RTSE LL_USART_SetHWFlowCtrl\n
1702 * CR3 CTSE LL_USART_SetHWFlowCtrl
1703 * @param USARTx USART Instance
1704 * @param HardwareFlowControl This parameter can be one of the following values:
1705 * @arg @ref LL_USART_HWCONTROL_NONE
1706 * @arg @ref LL_USART_HWCONTROL_RTS
1707 * @arg @ref LL_USART_HWCONTROL_CTS
1708 * @arg @ref LL_USART_HWCONTROL_RTS_CTS
1709 * @retval None
1711 __STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HardwareFlowControl)
1713 MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl);
1717 * @brief Return HW Flow Control configuration (both CTS and RTS)
1718 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
1719 * Hardware Flow control feature is supported by the USARTx instance.
1720 * @rmtoll CR3 RTSE LL_USART_GetHWFlowCtrl\n
1721 * CR3 CTSE LL_USART_GetHWFlowCtrl
1722 * @param USARTx USART Instance
1723 * @retval Returned value can be one of the following values:
1724 * @arg @ref LL_USART_HWCONTROL_NONE
1725 * @arg @ref LL_USART_HWCONTROL_RTS
1726 * @arg @ref LL_USART_HWCONTROL_CTS
1727 * @arg @ref LL_USART_HWCONTROL_RTS_CTS
1729 __STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(USART_TypeDef *USARTx)
1731 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE));
1735 * @brief Enable One bit sampling method
1736 * @rmtoll CR3 ONEBIT LL_USART_EnableOneBitSamp
1737 * @param USARTx USART Instance
1738 * @retval None
1740 __STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx)
1742 SET_BIT(USARTx->CR3, USART_CR3_ONEBIT);
1746 * @brief Disable One bit sampling method
1747 * @rmtoll CR3 ONEBIT LL_USART_DisableOneBitSamp
1748 * @param USARTx USART Instance
1749 * @retval None
1751 __STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx)
1753 CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT);
1757 * @brief Indicate if One bit sampling method is enabled
1758 * @rmtoll CR3 ONEBIT LL_USART_IsEnabledOneBitSamp
1759 * @param USARTx USART Instance
1760 * @retval State of bit (1 or 0).
1762 __STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(USART_TypeDef *USARTx)
1764 return ((READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT)) ? 1UL : 0UL);
1768 * @brief Enable Overrun detection
1769 * @rmtoll CR3 OVRDIS LL_USART_EnableOverrunDetect
1770 * @param USARTx USART Instance
1771 * @retval None
1773 __STATIC_INLINE void LL_USART_EnableOverrunDetect(USART_TypeDef *USARTx)
1775 CLEAR_BIT(USARTx->CR3, USART_CR3_OVRDIS);
1779 * @brief Disable Overrun detection
1780 * @rmtoll CR3 OVRDIS LL_USART_DisableOverrunDetect
1781 * @param USARTx USART Instance
1782 * @retval None
1784 __STATIC_INLINE void LL_USART_DisableOverrunDetect(USART_TypeDef *USARTx)
1786 SET_BIT(USARTx->CR3, USART_CR3_OVRDIS);
1790 * @brief Indicate if Overrun detection is enabled
1791 * @rmtoll CR3 OVRDIS LL_USART_IsEnabledOverrunDetect
1792 * @param USARTx USART Instance
1793 * @retval State of bit (1 or 0).
1795 __STATIC_INLINE uint32_t LL_USART_IsEnabledOverrunDetect(USART_TypeDef *USARTx)
1797 return ((READ_BIT(USARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS) ? 1UL : 0UL);
1801 * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits)
1802 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
1803 * Wake-up from Stop mode feature is supported by the USARTx instance.
1804 * @rmtoll CR3 WUS LL_USART_SetWKUPType
1805 * @param USARTx USART Instance
1806 * @param Type This parameter can be one of the following values:
1807 * @arg @ref LL_USART_WAKEUP_ON_ADDRESS
1808 * @arg @ref LL_USART_WAKEUP_ON_STARTBIT
1809 * @arg @ref LL_USART_WAKEUP_ON_RXNE
1810 * @retval None
1812 __STATIC_INLINE void LL_USART_SetWKUPType(USART_TypeDef *USARTx, uint32_t Type)
1814 MODIFY_REG(USARTx->CR3, USART_CR3_WUS, Type);
1818 * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits)
1819 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
1820 * Wake-up from Stop mode feature is supported by the USARTx instance.
1821 * @rmtoll CR3 WUS LL_USART_GetWKUPType
1822 * @param USARTx USART Instance
1823 * @retval Returned value can be one of the following values:
1824 * @arg @ref LL_USART_WAKEUP_ON_ADDRESS
1825 * @arg @ref LL_USART_WAKEUP_ON_STARTBIT
1826 * @arg @ref LL_USART_WAKEUP_ON_RXNE
1828 __STATIC_INLINE uint32_t LL_USART_GetWKUPType(USART_TypeDef *USARTx)
1830 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_WUS));
1834 * @brief Configure USART BRR register for achieving expected Baud Rate value.
1835 * @note Compute and set USARTDIV value in BRR Register (full BRR content)
1836 * according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values
1837 * @note Peripheral clock and Baud rate values provided as function parameters should be valid
1838 * (Baud rate value != 0)
1839 * @note In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d.
1840 * @rmtoll BRR BRR LL_USART_SetBaudRate
1841 * @param USARTx USART Instance
1842 * @param PeriphClk Peripheral Clock
1843 * @param PrescalerValue This parameter can be one of the following values:
1844 * @arg @ref LL_USART_PRESCALER_DIV1
1845 * @arg @ref LL_USART_PRESCALER_DIV2
1846 * @arg @ref LL_USART_PRESCALER_DIV4
1847 * @arg @ref LL_USART_PRESCALER_DIV6
1848 * @arg @ref LL_USART_PRESCALER_DIV8
1849 * @arg @ref LL_USART_PRESCALER_DIV10
1850 * @arg @ref LL_USART_PRESCALER_DIV12
1851 * @arg @ref LL_USART_PRESCALER_DIV16
1852 * @arg @ref LL_USART_PRESCALER_DIV32
1853 * @arg @ref LL_USART_PRESCALER_DIV64
1854 * @arg @ref LL_USART_PRESCALER_DIV128
1855 * @arg @ref LL_USART_PRESCALER_DIV256
1856 * @param OverSampling This parameter can be one of the following values:
1857 * @arg @ref LL_USART_OVERSAMPLING_16
1858 * @arg @ref LL_USART_OVERSAMPLING_8
1859 * @param BaudRate Baud Rate
1860 * @retval None
1862 __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t PrescalerValue,
1863 uint32_t OverSampling,
1864 uint32_t BaudRate)
1866 uint32_t usartdiv;
1867 uint32_t brrtemp;
1869 if (PrescalerValue > LL_USART_PRESCALER_DIV256)
1871 /* Do not overstep the size of USART_PRESCALER_TAB */
1873 else if (OverSampling == LL_USART_OVERSAMPLING_8)
1875 usartdiv = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, (uint8_t)PrescalerValue, BaudRate));
1876 brrtemp = usartdiv & 0xFFF0U;
1877 brrtemp |= (uint16_t)((usartdiv & (uint16_t)0x000FU) >> 1U);
1878 USARTx->BRR = brrtemp;
1880 else
1882 USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, (uint8_t)PrescalerValue, BaudRate));
1887 * @brief Return current Baud Rate value, according to USARTDIV present in BRR register
1888 * (full BRR content), and to used Peripheral Clock and Oversampling mode values
1889 * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned.
1890 * @note In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d.
1891 * @rmtoll BRR BRR LL_USART_GetBaudRate
1892 * @param USARTx USART Instance
1893 * @param PeriphClk Peripheral Clock
1894 * @param PrescalerValue This parameter can be one of the following values:
1895 * @arg @ref LL_USART_PRESCALER_DIV1
1896 * @arg @ref LL_USART_PRESCALER_DIV2
1897 * @arg @ref LL_USART_PRESCALER_DIV4
1898 * @arg @ref LL_USART_PRESCALER_DIV6
1899 * @arg @ref LL_USART_PRESCALER_DIV8
1900 * @arg @ref LL_USART_PRESCALER_DIV10
1901 * @arg @ref LL_USART_PRESCALER_DIV12
1902 * @arg @ref LL_USART_PRESCALER_DIV16
1903 * @arg @ref LL_USART_PRESCALER_DIV32
1904 * @arg @ref LL_USART_PRESCALER_DIV64
1905 * @arg @ref LL_USART_PRESCALER_DIV128
1906 * @arg @ref LL_USART_PRESCALER_DIV256
1907 * @param OverSampling This parameter can be one of the following values:
1908 * @arg @ref LL_USART_OVERSAMPLING_16
1909 * @arg @ref LL_USART_OVERSAMPLING_8
1910 * @retval Baud Rate
1912 __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t PrescalerValue,
1913 uint32_t OverSampling)
1915 uint32_t usartdiv;
1916 uint32_t brrresult = 0x0U;
1917 uint32_t periphclkpresc = (uint32_t)(PeriphClk / (USART_PRESCALER_TAB[(uint8_t)PrescalerValue]));
1919 usartdiv = USARTx->BRR;
1921 if (usartdiv == 0U)
1923 /* Do not perform a division by 0 */
1925 else if (OverSampling == LL_USART_OVERSAMPLING_8)
1927 usartdiv = (uint16_t)((usartdiv & 0xFFF0U) | ((usartdiv & 0x0007U) << 1U)) ;
1928 if (usartdiv != 0U)
1930 brrresult = (periphclkpresc * 2U) / usartdiv;
1933 else
1935 if ((usartdiv & 0xFFFFU) != 0U)
1937 brrresult = periphclkpresc / usartdiv;
1940 return (brrresult);
1944 * @brief Set Receiver Time Out Value (expressed in nb of bits duration)
1945 * @rmtoll RTOR RTO LL_USART_SetRxTimeout
1946 * @param USARTx USART Instance
1947 * @param Timeout Value between Min_Data=0x00 and Max_Data=0x00FFFFFF
1948 * @retval None
1950 __STATIC_INLINE void LL_USART_SetRxTimeout(USART_TypeDef *USARTx, uint32_t Timeout)
1952 MODIFY_REG(USARTx->RTOR, USART_RTOR_RTO, Timeout);
1956 * @brief Get Receiver Time Out Value (expressed in nb of bits duration)
1957 * @rmtoll RTOR RTO LL_USART_GetRxTimeout
1958 * @param USARTx USART Instance
1959 * @retval Value between Min_Data=0x00 and Max_Data=0x00FFFFFF
1961 __STATIC_INLINE uint32_t LL_USART_GetRxTimeout(USART_TypeDef *USARTx)
1963 return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_RTO));
1967 * @brief Set Block Length value in reception
1968 * @rmtoll RTOR BLEN LL_USART_SetBlockLength
1969 * @param USARTx USART Instance
1970 * @param BlockLength Value between Min_Data=0x00 and Max_Data=0xFF
1971 * @retval None
1973 __STATIC_INLINE void LL_USART_SetBlockLength(USART_TypeDef *USARTx, uint32_t BlockLength)
1975 MODIFY_REG(USARTx->RTOR, USART_RTOR_BLEN, BlockLength << USART_RTOR_BLEN_Pos);
1979 * @brief Get Block Length value in reception
1980 * @rmtoll RTOR BLEN LL_USART_GetBlockLength
1981 * @param USARTx USART Instance
1982 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
1984 __STATIC_INLINE uint32_t LL_USART_GetBlockLength(USART_TypeDef *USARTx)
1986 return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_BLEN) >> USART_RTOR_BLEN_Pos);
1990 * @}
1993 /** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature
1994 * @{
1998 * @brief Enable IrDA mode
1999 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2000 * IrDA feature is supported by the USARTx instance.
2001 * @rmtoll CR3 IREN LL_USART_EnableIrda
2002 * @param USARTx USART Instance
2003 * @retval None
2005 __STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx)
2007 SET_BIT(USARTx->CR3, USART_CR3_IREN);
2011 * @brief Disable IrDA mode
2012 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2013 * IrDA feature is supported by the USARTx instance.
2014 * @rmtoll CR3 IREN LL_USART_DisableIrda
2015 * @param USARTx USART Instance
2016 * @retval None
2018 __STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx)
2020 CLEAR_BIT(USARTx->CR3, USART_CR3_IREN);
2024 * @brief Indicate if IrDA mode is enabled
2025 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2026 * IrDA feature is supported by the USARTx instance.
2027 * @rmtoll CR3 IREN LL_USART_IsEnabledIrda
2028 * @param USARTx USART Instance
2029 * @retval State of bit (1 or 0).
2031 __STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(USART_TypeDef *USARTx)
2033 return ((READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN)) ? 1UL : 0UL);
2037 * @brief Configure IrDA Power Mode (Normal or Low Power)
2038 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2039 * IrDA feature is supported by the USARTx instance.
2040 * @rmtoll CR3 IRLP LL_USART_SetIrdaPowerMode
2041 * @param USARTx USART Instance
2042 * @param PowerMode This parameter can be one of the following values:
2043 * @arg @ref LL_USART_IRDA_POWER_NORMAL
2044 * @arg @ref LL_USART_IRDA_POWER_LOW
2045 * @retval None
2047 __STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode)
2049 MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode);
2053 * @brief Retrieve IrDA Power Mode configuration (Normal or Low Power)
2054 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2055 * IrDA feature is supported by the USARTx instance.
2056 * @rmtoll CR3 IRLP LL_USART_GetIrdaPowerMode
2057 * @param USARTx USART Instance
2058 * @retval Returned value can be one of the following values:
2059 * @arg @ref LL_USART_IRDA_POWER_NORMAL
2060 * @arg @ref LL_USART_PHASE_2EDGE
2062 __STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(USART_TypeDef *USARTx)
2064 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP));
2068 * @brief Set Irda prescaler value, used for dividing the USART clock source
2069 * to achieve the Irda Low Power frequency (8 bits value)
2070 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2071 * IrDA feature is supported by the USARTx instance.
2072 * @rmtoll GTPR PSC LL_USART_SetIrdaPrescaler
2073 * @param USARTx USART Instance
2074 * @param PrescalerValue Value between Min_Data=0x00 and Max_Data=0xFF
2075 * @retval None
2077 __STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
2079 MODIFY_REG(USARTx->GTPR, (uint16_t)USART_GTPR_PSC, (uint16_t)PrescalerValue);
2083 * @brief Return Irda prescaler value, used for dividing the USART clock source
2084 * to achieve the Irda Low Power frequency (8 bits value)
2085 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2086 * IrDA feature is supported by the USARTx instance.
2087 * @rmtoll GTPR PSC LL_USART_GetIrdaPrescaler
2088 * @param USARTx USART Instance
2089 * @retval Irda prescaler value (Value between Min_Data=0x00 and Max_Data=0xFF)
2091 __STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(USART_TypeDef *USARTx)
2093 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
2097 * @}
2100 /** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature
2101 * @{
2105 * @brief Enable Smartcard NACK transmission
2106 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2107 * Smartcard feature is supported by the USARTx instance.
2108 * @rmtoll CR3 NACK LL_USART_EnableSmartcardNACK
2109 * @param USARTx USART Instance
2110 * @retval None
2112 __STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx)
2114 SET_BIT(USARTx->CR3, USART_CR3_NACK);
2118 * @brief Disable Smartcard NACK transmission
2119 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2120 * Smartcard feature is supported by the USARTx instance.
2121 * @rmtoll CR3 NACK LL_USART_DisableSmartcardNACK
2122 * @param USARTx USART Instance
2123 * @retval None
2125 __STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx)
2127 CLEAR_BIT(USARTx->CR3, USART_CR3_NACK);
2131 * @brief Indicate if Smartcard NACK transmission is enabled
2132 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2133 * Smartcard feature is supported by the USARTx instance.
2134 * @rmtoll CR3 NACK LL_USART_IsEnabledSmartcardNACK
2135 * @param USARTx USART Instance
2136 * @retval State of bit (1 or 0).
2138 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(USART_TypeDef *USARTx)
2140 return ((READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK)) ? 1UL : 0UL);
2144 * @brief Enable Smartcard mode
2145 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2146 * Smartcard feature is supported by the USARTx instance.
2147 * @rmtoll CR3 SCEN LL_USART_EnableSmartcard
2148 * @param USARTx USART Instance
2149 * @retval None
2151 __STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx)
2153 SET_BIT(USARTx->CR3, USART_CR3_SCEN);
2157 * @brief Disable Smartcard mode
2158 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2159 * Smartcard feature is supported by the USARTx instance.
2160 * @rmtoll CR3 SCEN LL_USART_DisableSmartcard
2161 * @param USARTx USART Instance
2162 * @retval None
2164 __STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx)
2166 CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN);
2170 * @brief Indicate if Smartcard mode is enabled
2171 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2172 * Smartcard feature is supported by the USARTx instance.
2173 * @rmtoll CR3 SCEN LL_USART_IsEnabledSmartcard
2174 * @param USARTx USART Instance
2175 * @retval State of bit (1 or 0).
2177 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(USART_TypeDef *USARTx)
2179 return ((READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN)) ? 1UL : 0UL);
2183 * @brief Set Smartcard Auto-Retry Count value (SCARCNT[2:0] bits)
2184 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2185 * Smartcard feature is supported by the USARTx instance.
2186 * @note This bit-field specifies the number of retries in transmit and receive, in Smartcard mode.
2187 * In transmission mode, it specifies the number of automatic retransmission retries, before
2188 * generating a transmission error (FE bit set).
2189 * In reception mode, it specifies the number or erroneous reception trials, before generating a
2190 * reception error (RXNE and PE bits set)
2191 * @rmtoll CR3 SCARCNT LL_USART_SetSmartcardAutoRetryCount
2192 * @param USARTx USART Instance
2193 * @param AutoRetryCount Value between Min_Data=0 and Max_Data=7
2194 * @retval None
2196 __STATIC_INLINE void LL_USART_SetSmartcardAutoRetryCount(USART_TypeDef *USARTx, uint32_t AutoRetryCount)
2198 MODIFY_REG(USARTx->CR3, USART_CR3_SCARCNT, AutoRetryCount << USART_CR3_SCARCNT_Pos);
2202 * @brief Return Smartcard Auto-Retry Count value (SCARCNT[2:0] bits)
2203 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2204 * Smartcard feature is supported by the USARTx instance.
2205 * @rmtoll CR3 SCARCNT LL_USART_GetSmartcardAutoRetryCount
2206 * @param USARTx USART Instance
2207 * @retval Smartcard Auto-Retry Count value (Value between Min_Data=0 and Max_Data=7)
2209 __STATIC_INLINE uint32_t LL_USART_GetSmartcardAutoRetryCount(USART_TypeDef *USARTx)
2211 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_SCARCNT) >> USART_CR3_SCARCNT_Pos);
2215 * @brief Set Smartcard prescaler value, used for dividing the USART clock
2216 * source to provide the SMARTCARD Clock (5 bits value)
2217 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2218 * Smartcard feature is supported by the USARTx instance.
2219 * @rmtoll GTPR PSC LL_USART_SetSmartcardPrescaler
2220 * @param USARTx USART Instance
2221 * @param PrescalerValue Value between Min_Data=0 and Max_Data=31
2222 * @retval None
2224 __STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
2226 MODIFY_REG(USARTx->GTPR, (uint16_t)USART_GTPR_PSC, (uint16_t)PrescalerValue);
2230 * @brief Return Smartcard prescaler value, used for dividing the USART clock
2231 * source to provide the SMARTCARD Clock (5 bits value)
2232 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2233 * Smartcard feature is supported by the USARTx instance.
2234 * @rmtoll GTPR PSC LL_USART_GetSmartcardPrescaler
2235 * @param USARTx USART Instance
2236 * @retval Smartcard prescaler value (Value between Min_Data=0 and Max_Data=31)
2238 __STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(USART_TypeDef *USARTx)
2240 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
2244 * @brief Set Smartcard Guard time value, expressed in nb of baud clocks periods
2245 * (GT[7:0] bits : Guard time value)
2246 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2247 * Smartcard feature is supported by the USARTx instance.
2248 * @rmtoll GTPR GT LL_USART_SetSmartcardGuardTime
2249 * @param USARTx USART Instance
2250 * @param GuardTime Value between Min_Data=0x00 and Max_Data=0xFF
2251 * @retval None
2253 __STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime)
2255 MODIFY_REG(USARTx->GTPR, (uint16_t)USART_GTPR_GT, (uint16_t)(GuardTime << USART_GTPR_GT_Pos));
2259 * @brief Return Smartcard Guard time value, expressed in nb of baud clocks periods
2260 * (GT[7:0] bits : Guard time value)
2261 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2262 * Smartcard feature is supported by the USARTx instance.
2263 * @rmtoll GTPR GT LL_USART_GetSmartcardGuardTime
2264 * @param USARTx USART Instance
2265 * @retval Smartcard Guard time value (Value between Min_Data=0x00 and Max_Data=0xFF)
2267 __STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(USART_TypeDef *USARTx)
2269 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_GTPR_GT_Pos);
2273 * @}
2276 /** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature
2277 * @{
2281 * @brief Enable Single Wire Half-Duplex mode
2282 * @note Macro IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
2283 * Half-Duplex mode is supported by the USARTx instance.
2284 * @rmtoll CR3 HDSEL LL_USART_EnableHalfDuplex
2285 * @param USARTx USART Instance
2286 * @retval None
2288 __STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx)
2290 SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
2294 * @brief Disable Single Wire Half-Duplex mode
2295 * @note Macro IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
2296 * Half-Duplex mode is supported by the USARTx instance.
2297 * @rmtoll CR3 HDSEL LL_USART_DisableHalfDuplex
2298 * @param USARTx USART Instance
2299 * @retval None
2301 __STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx)
2303 CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL);
2307 * @brief Indicate if Single Wire Half-Duplex mode is enabled
2308 * @note Macro IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
2309 * Half-Duplex mode is supported by the USARTx instance.
2310 * @rmtoll CR3 HDSEL LL_USART_IsEnabledHalfDuplex
2311 * @param USARTx USART Instance
2312 * @retval State of bit (1 or 0).
2314 __STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(USART_TypeDef *USARTx)
2316 return ((READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL)) ? 1UL : 0UL);
2320 * @}
2323 /** @defgroup USART_LL_EF_Configuration_SPI_SLAVE Configuration functions related to SPI Slave feature
2324 * @{
2327 * @brief Enable SPI Synchronous Slave mode
2328 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
2329 * SPI Slave mode feature is supported by the USARTx instance.
2330 * @rmtoll CR2 SLVEN LL_USART_EnableSPISlave
2331 * @param USARTx USART Instance
2332 * @retval None
2334 __STATIC_INLINE void LL_USART_EnableSPISlave(USART_TypeDef *USARTx)
2336 SET_BIT(USARTx->CR2, USART_CR2_SLVEN);
2340 * @brief Disable SPI Synchronous Slave mode
2341 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
2342 * SPI Slave mode feature is supported by the USARTx instance.
2343 * @rmtoll CR2 SLVEN LL_USART_DisableSPISlave
2344 * @param USARTx USART Instance
2345 * @retval None
2347 __STATIC_INLINE void LL_USART_DisableSPISlave(USART_TypeDef *USARTx)
2349 CLEAR_BIT(USARTx->CR2, USART_CR2_SLVEN);
2353 * @brief Indicate if SPI Synchronous Slave mode is enabled
2354 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
2355 * SPI Slave mode feature is supported by the USARTx instance.
2356 * @rmtoll CR2 SLVEN LL_USART_IsEnabledSPISlave
2357 * @param USARTx USART Instance
2358 * @retval State of bit (1 or 0).
2360 __STATIC_INLINE uint32_t LL_USART_IsEnabledSPISlave(USART_TypeDef *USARTx)
2362 return ((READ_BIT(USARTx->CR2, USART_CR2_SLVEN) == (USART_CR2_SLVEN)) ? 1UL : 0UL);
2366 * @brief Enable SPI Slave Selection using NSS input pin
2367 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
2368 * SPI Slave mode feature is supported by the USARTx instance.
2369 * @note SPI Slave Selection depends on NSS input pin
2370 * (The slave is selected when NSS is low and deselected when NSS is high).
2371 * @rmtoll CR2 DIS_NSS LL_USART_EnableSPISlaveSelect
2372 * @param USARTx USART Instance
2373 * @retval None
2375 __STATIC_INLINE void LL_USART_EnableSPISlaveSelect(USART_TypeDef *USARTx)
2377 CLEAR_BIT(USARTx->CR2, USART_CR2_DIS_NSS);
2381 * @brief Disable SPI Slave Selection using NSS input pin
2382 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
2383 * SPI Slave mode feature is supported by the USARTx instance.
2384 * @note SPI Slave will be always selected and NSS input pin will be ignored.
2385 * @rmtoll CR2 DIS_NSS LL_USART_DisableSPISlaveSelect
2386 * @param USARTx USART Instance
2387 * @retval None
2389 __STATIC_INLINE void LL_USART_DisableSPISlaveSelect(USART_TypeDef *USARTx)
2391 SET_BIT(USARTx->CR2, USART_CR2_DIS_NSS);
2395 * @brief Indicate if SPI Slave Selection depends on NSS input pin
2396 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
2397 * SPI Slave mode feature is supported by the USARTx instance.
2398 * @rmtoll CR2 DIS_NSS LL_USART_IsEnabledSPISlaveSelect
2399 * @param USARTx USART Instance
2400 * @retval State of bit (1 or 0).
2402 __STATIC_INLINE uint32_t LL_USART_IsEnabledSPISlaveSelect(USART_TypeDef *USARTx)
2404 return ((READ_BIT(USARTx->CR2, USART_CR2_DIS_NSS) != (USART_CR2_DIS_NSS)) ? 1UL : 0UL);
2408 * @}
2411 /** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature
2412 * @{
2416 * @brief Set LIN Break Detection Length
2417 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
2418 * LIN feature is supported by the USARTx instance.
2419 * @rmtoll CR2 LBDL LL_USART_SetLINBrkDetectionLen
2420 * @param USARTx USART Instance
2421 * @param LINBDLength This parameter can be one of the following values:
2422 * @arg @ref LL_USART_LINBREAK_DETECT_10B
2423 * @arg @ref LL_USART_LINBREAK_DETECT_11B
2424 * @retval None
2426 __STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength)
2428 MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength);
2432 * @brief Return LIN Break Detection Length
2433 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
2434 * LIN feature is supported by the USARTx instance.
2435 * @rmtoll CR2 LBDL LL_USART_GetLINBrkDetectionLen
2436 * @param USARTx USART Instance
2437 * @retval Returned value can be one of the following values:
2438 * @arg @ref LL_USART_LINBREAK_DETECT_10B
2439 * @arg @ref LL_USART_LINBREAK_DETECT_11B
2441 __STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(USART_TypeDef *USARTx)
2443 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL));
2447 * @brief Enable LIN mode
2448 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
2449 * LIN feature is supported by the USARTx instance.
2450 * @rmtoll CR2 LINEN LL_USART_EnableLIN
2451 * @param USARTx USART Instance
2452 * @retval None
2454 __STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx)
2456 SET_BIT(USARTx->CR2, USART_CR2_LINEN);
2460 * @brief Disable LIN mode
2461 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
2462 * LIN feature is supported by the USARTx instance.
2463 * @rmtoll CR2 LINEN LL_USART_DisableLIN
2464 * @param USARTx USART Instance
2465 * @retval None
2467 __STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx)
2469 CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN);
2473 * @brief Indicate if LIN mode is enabled
2474 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
2475 * LIN feature is supported by the USARTx instance.
2476 * @rmtoll CR2 LINEN LL_USART_IsEnabledLIN
2477 * @param USARTx USART Instance
2478 * @retval State of bit (1 or 0).
2480 __STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(USART_TypeDef *USARTx)
2482 return ((READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN)) ? 1UL : 0UL);
2486 * @}
2489 /** @defgroup USART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature
2490 * @{
2494 * @brief Set DEDT (Driver Enable De-Assertion Time), Time value expressed on 5 bits ([4:0] bits).
2495 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2496 * Driver Enable feature is supported by the USARTx instance.
2497 * @rmtoll CR1 DEDT LL_USART_SetDEDeassertionTime
2498 * @param USARTx USART Instance
2499 * @param Time Value between Min_Data=0 and Max_Data=31
2500 * @retval None
2502 __STATIC_INLINE void LL_USART_SetDEDeassertionTime(USART_TypeDef *USARTx, uint32_t Time)
2504 MODIFY_REG(USARTx->CR1, USART_CR1_DEDT, Time << USART_CR1_DEDT_Pos);
2508 * @brief Return DEDT (Driver Enable De-Assertion Time)
2509 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2510 * Driver Enable feature is supported by the USARTx instance.
2511 * @rmtoll CR1 DEDT LL_USART_GetDEDeassertionTime
2512 * @param USARTx USART Instance
2513 * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31
2515 __STATIC_INLINE uint32_t LL_USART_GetDEDeassertionTime(USART_TypeDef *USARTx)
2517 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEDT) >> USART_CR1_DEDT_Pos);
2521 * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits).
2522 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2523 * Driver Enable feature is supported by the USARTx instance.
2524 * @rmtoll CR1 DEAT LL_USART_SetDEAssertionTime
2525 * @param USARTx USART Instance
2526 * @param Time Value between Min_Data=0 and Max_Data=31
2527 * @retval None
2529 __STATIC_INLINE void LL_USART_SetDEAssertionTime(USART_TypeDef *USARTx, uint32_t Time)
2531 MODIFY_REG(USARTx->CR1, USART_CR1_DEAT, Time << USART_CR1_DEAT_Pos);
2535 * @brief Return DEAT (Driver Enable Assertion Time)
2536 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2537 * Driver Enable feature is supported by the USARTx instance.
2538 * @rmtoll CR1 DEAT LL_USART_GetDEAssertionTime
2539 * @param USARTx USART Instance
2540 * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31
2542 __STATIC_INLINE uint32_t LL_USART_GetDEAssertionTime(USART_TypeDef *USARTx)
2544 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEAT) >> USART_CR1_DEAT_Pos);
2548 * @brief Enable Driver Enable (DE) Mode
2549 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2550 * Driver Enable feature is supported by the USARTx instance.
2551 * @rmtoll CR3 DEM LL_USART_EnableDEMode
2552 * @param USARTx USART Instance
2553 * @retval None
2555 __STATIC_INLINE void LL_USART_EnableDEMode(USART_TypeDef *USARTx)
2557 SET_BIT(USARTx->CR3, USART_CR3_DEM);
2561 * @brief Disable Driver Enable (DE) Mode
2562 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2563 * Driver Enable feature is supported by the USARTx instance.
2564 * @rmtoll CR3 DEM LL_USART_DisableDEMode
2565 * @param USARTx USART Instance
2566 * @retval None
2568 __STATIC_INLINE void LL_USART_DisableDEMode(USART_TypeDef *USARTx)
2570 CLEAR_BIT(USARTx->CR3, USART_CR3_DEM);
2574 * @brief Indicate if Driver Enable (DE) Mode is enabled
2575 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2576 * Driver Enable feature is supported by the USARTx instance.
2577 * @rmtoll CR3 DEM LL_USART_IsEnabledDEMode
2578 * @param USARTx USART Instance
2579 * @retval State of bit (1 or 0).
2581 __STATIC_INLINE uint32_t LL_USART_IsEnabledDEMode(USART_TypeDef *USARTx)
2583 return ((READ_BIT(USARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM)) ? 1UL : 0UL);
2587 * @brief Select Driver Enable Polarity
2588 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2589 * Driver Enable feature is supported by the USARTx instance.
2590 * @rmtoll CR3 DEP LL_USART_SetDESignalPolarity
2591 * @param USARTx USART Instance
2592 * @param Polarity This parameter can be one of the following values:
2593 * @arg @ref LL_USART_DE_POLARITY_HIGH
2594 * @arg @ref LL_USART_DE_POLARITY_LOW
2595 * @retval None
2597 __STATIC_INLINE void LL_USART_SetDESignalPolarity(USART_TypeDef *USARTx, uint32_t Polarity)
2599 MODIFY_REG(USARTx->CR3, USART_CR3_DEP, Polarity);
2603 * @brief Return Driver Enable Polarity
2604 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2605 * Driver Enable feature is supported by the USARTx instance.
2606 * @rmtoll CR3 DEP LL_USART_GetDESignalPolarity
2607 * @param USARTx USART Instance
2608 * @retval Returned value can be one of the following values:
2609 * @arg @ref LL_USART_DE_POLARITY_HIGH
2610 * @arg @ref LL_USART_DE_POLARITY_LOW
2612 __STATIC_INLINE uint32_t LL_USART_GetDESignalPolarity(USART_TypeDef *USARTx)
2614 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_DEP));
2618 * @}
2621 /** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services
2622 * @{
2626 * @brief Perform basic configuration of USART for enabling use in Asynchronous Mode (UART)
2627 * @note In UART mode, the following bits must be kept cleared:
2628 * - LINEN bit in the USART_CR2 register,
2629 * - CLKEN bit in the USART_CR2 register,
2630 * - SCEN bit in the USART_CR3 register,
2631 * - IREN bit in the USART_CR3 register,
2632 * - HDSEL bit in the USART_CR3 register.
2633 * @note Call of this function is equivalent to following function call sequence :
2634 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
2635 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
2636 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
2637 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
2638 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
2639 * @note Other remaining configurations items related to Asynchronous Mode
2640 * (as Baud Rate, Word length, Parity, ...) should be set using
2641 * dedicated functions
2642 * @rmtoll CR2 LINEN LL_USART_ConfigAsyncMode\n
2643 * CR2 CLKEN LL_USART_ConfigAsyncMode\n
2644 * CR3 SCEN LL_USART_ConfigAsyncMode\n
2645 * CR3 IREN LL_USART_ConfigAsyncMode\n
2646 * CR3 HDSEL LL_USART_ConfigAsyncMode
2647 * @param USARTx USART Instance
2648 * @retval None
2650 __STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx)
2652 /* In Asynchronous mode, the following bits must be kept cleared:
2653 - LINEN, CLKEN bits in the USART_CR2 register,
2654 - SCEN, IREN and HDSEL bits in the USART_CR3 register.
2656 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
2657 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
2661 * @brief Perform basic configuration of USART for enabling use in Synchronous Mode
2662 * @note In Synchronous mode, the following bits must be kept cleared:
2663 * - LINEN bit in the USART_CR2 register,
2664 * - SCEN bit in the USART_CR3 register,
2665 * - IREN bit in the USART_CR3 register,
2666 * - HDSEL bit in the USART_CR3 register.
2667 * This function also sets the USART in Synchronous mode.
2668 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not
2669 * Synchronous mode is supported by the USARTx instance.
2670 * @note Call of this function is equivalent to following function call sequence :
2671 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
2672 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
2673 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
2674 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
2675 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
2676 * @note Other remaining configurations items related to Synchronous Mode
2677 * (as Baud Rate, Word length, Parity, Clock Polarity, ...) should be set using
2678 * dedicated functions
2679 * @rmtoll CR2 LINEN LL_USART_ConfigSyncMode\n
2680 * CR2 CLKEN LL_USART_ConfigSyncMode\n
2681 * CR3 SCEN LL_USART_ConfigSyncMode\n
2682 * CR3 IREN LL_USART_ConfigSyncMode\n
2683 * CR3 HDSEL LL_USART_ConfigSyncMode
2684 * @param USARTx USART Instance
2685 * @retval None
2687 __STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx)
2689 /* In Synchronous mode, the following bits must be kept cleared:
2690 - LINEN bit in the USART_CR2 register,
2691 - SCEN, IREN and HDSEL bits in the USART_CR3 register.
2693 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
2694 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
2695 /* set the UART/USART in Synchronous mode */
2696 SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
2700 * @brief Perform basic configuration of USART for enabling use in LIN Mode
2701 * @note In LIN mode, the following bits must be kept cleared:
2702 * - STOP and CLKEN bits in the USART_CR2 register,
2703 * - SCEN bit in the USART_CR3 register,
2704 * - IREN bit in the USART_CR3 register,
2705 * - HDSEL bit in the USART_CR3 register.
2706 * This function also set the UART/USART in LIN mode.
2707 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
2708 * LIN feature is supported by the USARTx instance.
2709 * @note Call of this function is equivalent to following function call sequence :
2710 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
2711 * - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
2712 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
2713 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
2714 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
2715 * - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function
2716 * @note Other remaining configurations items related to LIN Mode
2717 * (as Baud Rate, Word length, LIN Break Detection Length, ...) should be set using
2718 * dedicated functions
2719 * @rmtoll CR2 CLKEN LL_USART_ConfigLINMode\n
2720 * CR2 STOP LL_USART_ConfigLINMode\n
2721 * CR2 LINEN LL_USART_ConfigLINMode\n
2722 * CR3 IREN LL_USART_ConfigLINMode\n
2723 * CR3 SCEN LL_USART_ConfigLINMode\n
2724 * CR3 HDSEL LL_USART_ConfigLINMode
2725 * @param USARTx USART Instance
2726 * @retval None
2728 __STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx)
2730 /* In LIN mode, the following bits must be kept cleared:
2731 - STOP and CLKEN bits in the USART_CR2 register,
2732 - IREN, SCEN and HDSEL bits in the USART_CR3 register.
2734 CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP));
2735 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL));
2736 /* Set the UART/USART in LIN mode */
2737 SET_BIT(USARTx->CR2, USART_CR2_LINEN);
2741 * @brief Perform basic configuration of USART for enabling use in Half Duplex Mode
2742 * @note In Half Duplex mode, the following bits must be kept cleared:
2743 * - LINEN bit in the USART_CR2 register,
2744 * - CLKEN bit in the USART_CR2 register,
2745 * - SCEN bit in the USART_CR3 register,
2746 * - IREN bit in the USART_CR3 register,
2747 * This function also sets the UART/USART in Half Duplex mode.
2748 * @note Macro IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
2749 * Half-Duplex mode is supported by the USARTx instance.
2750 * @note Call of this function is equivalent to following function call sequence :
2751 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
2752 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
2753 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
2754 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
2755 * - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function
2756 * @note Other remaining configurations items related to Half Duplex Mode
2757 * (as Baud Rate, Word length, Parity, ...) should be set using
2758 * dedicated functions
2759 * @rmtoll CR2 LINEN LL_USART_ConfigHalfDuplexMode\n
2760 * CR2 CLKEN LL_USART_ConfigHalfDuplexMode\n
2761 * CR3 HDSEL LL_USART_ConfigHalfDuplexMode\n
2762 * CR3 SCEN LL_USART_ConfigHalfDuplexMode\n
2763 * CR3 IREN LL_USART_ConfigHalfDuplexMode
2764 * @param USARTx USART Instance
2765 * @retval None
2767 __STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx)
2769 /* In Half Duplex mode, the following bits must be kept cleared:
2770 - LINEN and CLKEN bits in the USART_CR2 register,
2771 - SCEN and IREN bits in the USART_CR3 register.
2773 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
2774 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN));
2775 /* set the UART/USART in Half Duplex mode */
2776 SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
2780 * @brief Perform basic configuration of USART for enabling use in Smartcard Mode
2781 * @note In Smartcard mode, the following bits must be kept cleared:
2782 * - LINEN bit in the USART_CR2 register,
2783 * - IREN bit in the USART_CR3 register,
2784 * - HDSEL bit in the USART_CR3 register.
2785 * This function also configures Stop bits to 1.5 bits and
2786 * sets the USART in Smartcard mode (SCEN bit).
2787 * Clock Output is also enabled (CLKEN).
2788 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2789 * Smartcard feature is supported by the USARTx instance.
2790 * @note Call of this function is equivalent to following function call sequence :
2791 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
2792 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
2793 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
2794 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
2795 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
2796 * - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function
2797 * @note Other remaining configurations items related to Smartcard Mode
2798 * (as Baud Rate, Word length, Parity, ...) should be set using
2799 * dedicated functions
2800 * @rmtoll CR2 LINEN LL_USART_ConfigSmartcardMode\n
2801 * CR2 STOP LL_USART_ConfigSmartcardMode\n
2802 * CR2 CLKEN LL_USART_ConfigSmartcardMode\n
2803 * CR3 HDSEL LL_USART_ConfigSmartcardMode\n
2804 * CR3 SCEN LL_USART_ConfigSmartcardMode
2805 * @param USARTx USART Instance
2806 * @retval None
2808 __STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx)
2810 /* In Smartcard mode, the following bits must be kept cleared:
2811 - LINEN bit in the USART_CR2 register,
2812 - IREN and HDSEL bits in the USART_CR3 register.
2814 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
2815 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL));
2816 /* Configure Stop bits to 1.5 bits */
2817 /* Synchronous mode is activated by default */
2818 SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN));
2819 /* set the UART/USART in Smartcard mode */
2820 SET_BIT(USARTx->CR3, USART_CR3_SCEN);
2824 * @brief Perform basic configuration of USART for enabling use in Irda Mode
2825 * @note In IRDA mode, the following bits must be kept cleared:
2826 * - LINEN bit in the USART_CR2 register,
2827 * - STOP and CLKEN bits in the USART_CR2 register,
2828 * - SCEN bit in the USART_CR3 register,
2829 * - HDSEL bit in the USART_CR3 register.
2830 * This function also sets the UART/USART in IRDA mode (IREN bit).
2831 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2832 * IrDA feature is supported by the USARTx instance.
2833 * @note Call of this function is equivalent to following function call sequence :
2834 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
2835 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
2836 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
2837 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
2838 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
2839 * - Set IREN in CR3 using @ref LL_USART_EnableIrda() function
2840 * @note Other remaining configurations items related to Irda Mode
2841 * (as Baud Rate, Word length, Power mode, ...) should be set using
2842 * dedicated functions
2843 * @rmtoll CR2 LINEN LL_USART_ConfigIrdaMode\n
2844 * CR2 CLKEN LL_USART_ConfigIrdaMode\n
2845 * CR2 STOP LL_USART_ConfigIrdaMode\n
2846 * CR3 SCEN LL_USART_ConfigIrdaMode\n
2847 * CR3 HDSEL LL_USART_ConfigIrdaMode\n
2848 * CR3 IREN LL_USART_ConfigIrdaMode
2849 * @param USARTx USART Instance
2850 * @retval None
2852 __STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx)
2854 /* In IRDA mode, the following bits must be kept cleared:
2855 - LINEN, STOP and CLKEN bits in the USART_CR2 register,
2856 - SCEN and HDSEL bits in the USART_CR3 register.
2858 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP));
2859 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
2860 /* set the UART/USART in IRDA mode */
2861 SET_BIT(USARTx->CR3, USART_CR3_IREN);
2865 * @brief Perform basic configuration of USART for enabling use in Multi processor Mode
2866 * (several USARTs connected in a network, one of the USARTs can be the master,
2867 * its TX output connected to the RX inputs of the other slaves USARTs).
2868 * @note In MultiProcessor mode, the following bits must be kept cleared:
2869 * - LINEN bit in the USART_CR2 register,
2870 * - CLKEN bit in the USART_CR2 register,
2871 * - SCEN bit in the USART_CR3 register,
2872 * - IREN bit in the USART_CR3 register,
2873 * - HDSEL bit in the USART_CR3 register.
2874 * @note Call of this function is equivalent to following function call sequence :
2875 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
2876 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
2877 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
2878 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
2879 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
2880 * @note Other remaining configurations items related to Multi processor Mode
2881 * (as Baud Rate, Wake Up Method, Node address, ...) should be set using
2882 * dedicated functions
2883 * @rmtoll CR2 LINEN LL_USART_ConfigMultiProcessMode\n
2884 * CR2 CLKEN LL_USART_ConfigMultiProcessMode\n
2885 * CR3 SCEN LL_USART_ConfigMultiProcessMode\n
2886 * CR3 HDSEL LL_USART_ConfigMultiProcessMode\n
2887 * CR3 IREN LL_USART_ConfigMultiProcessMode
2888 * @param USARTx USART Instance
2889 * @retval None
2891 __STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx)
2893 /* In Multi Processor mode, the following bits must be kept cleared:
2894 - LINEN and CLKEN bits in the USART_CR2 register,
2895 - IREN, SCEN and HDSEL bits in the USART_CR3 register.
2897 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
2898 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN));
2902 * @}
2905 /** @defgroup USART_LL_EF_FLAG_Management FLAG_Management
2906 * @{
2910 * @brief Check if the USART Parity Error Flag is set or not
2911 * @rmtoll ISR PE LL_USART_IsActiveFlag_PE
2912 * @param USARTx USART Instance
2913 * @retval State of bit (1 or 0).
2915 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(USART_TypeDef *USARTx)
2917 return ((READ_BIT(USARTx->ISR, USART_ISR_PE) == (USART_ISR_PE)) ? 1UL : 0UL);
2921 * @brief Check if the USART Framing Error Flag is set or not
2922 * @rmtoll ISR FE LL_USART_IsActiveFlag_FE
2923 * @param USARTx USART Instance
2924 * @retval State of bit (1 or 0).
2926 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(USART_TypeDef *USARTx)
2928 return ((READ_BIT(USARTx->ISR, USART_ISR_FE) == (USART_ISR_FE)) ? 1UL : 0UL);
2932 * @brief Check if the USART Noise error detected Flag is set or not
2933 * @rmtoll ISR NE LL_USART_IsActiveFlag_NE
2934 * @param USARTx USART Instance
2935 * @retval State of bit (1 or 0).
2937 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(USART_TypeDef *USARTx)
2939 return ((READ_BIT(USARTx->ISR, USART_ISR_NE) == (USART_ISR_NE)) ? 1UL : 0UL);
2943 * @brief Check if the USART OverRun Error Flag is set or not
2944 * @rmtoll ISR ORE LL_USART_IsActiveFlag_ORE
2945 * @param USARTx USART Instance
2946 * @retval State of bit (1 or 0).
2948 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(USART_TypeDef *USARTx)
2950 return ((READ_BIT(USARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE)) ? 1UL : 0UL);
2954 * @brief Check if the USART IDLE line detected Flag is set or not
2955 * @rmtoll ISR IDLE LL_USART_IsActiveFlag_IDLE
2956 * @param USARTx USART Instance
2957 * @retval State of bit (1 or 0).
2959 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(USART_TypeDef *USARTx)
2961 return ((READ_BIT(USARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE)) ? 1UL : 0UL);
2964 /* Legacy define */
2965 #define LL_USART_IsActiveFlag_RXNE LL_USART_IsActiveFlag_RXNE_RXFNE
2968 * @brief Check if the USART Read Data Register or USART RX FIFO Not Empty Flag is set or not
2969 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
2970 * FIFO mode feature is supported by the USARTx instance.
2971 * @rmtoll ISR RXNE_RXFNE LL_USART_IsActiveFlag_RXNE_RXFNE
2972 * @param USARTx USART Instance
2973 * @retval State of bit (1 or 0).
2975 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE_RXFNE(USART_TypeDef *USARTx)
2977 return ((READ_BIT(USARTx->ISR, USART_ISR_RXNE_RXFNE) == (USART_ISR_RXNE_RXFNE)) ? 1UL : 0UL);
2981 * @brief Check if the USART Transmission Complete Flag is set or not
2982 * @rmtoll ISR TC LL_USART_IsActiveFlag_TC
2983 * @param USARTx USART Instance
2984 * @retval State of bit (1 or 0).
2986 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(USART_TypeDef *USARTx)
2988 return ((READ_BIT(USARTx->ISR, USART_ISR_TC) == (USART_ISR_TC)) ? 1UL : 0UL);
2991 /* Legacy define */
2992 #define LL_USART_IsActiveFlag_TXE LL_USART_IsActiveFlag_TXE_TXFNF
2995 * @brief Check if the USART Transmit Data Register Empty or USART TX FIFO Not Full Flag is set or not
2996 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
2997 * FIFO mode feature is supported by the USARTx instance.
2998 * @rmtoll ISR TXE_TXFNF LL_USART_IsActiveFlag_TXE_TXFNF
2999 * @param USARTx USART Instance
3000 * @retval State of bit (1 or 0).
3002 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE_TXFNF(USART_TypeDef *USARTx)
3004 return ((READ_BIT(USARTx->ISR, USART_ISR_TXE_TXFNF) == (USART_ISR_TXE_TXFNF)) ? 1UL : 0UL);
3008 * @brief Check if the USART LIN Break Detection Flag is set or not
3009 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
3010 * LIN feature is supported by the USARTx instance.
3011 * @rmtoll ISR LBDF LL_USART_IsActiveFlag_LBD
3012 * @param USARTx USART Instance
3013 * @retval State of bit (1 or 0).
3015 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(USART_TypeDef *USARTx)
3017 return ((READ_BIT(USARTx->ISR, USART_ISR_LBDF) == (USART_ISR_LBDF)) ? 1UL : 0UL);
3021 * @brief Check if the USART CTS interrupt Flag is set or not
3022 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
3023 * Hardware Flow control feature is supported by the USARTx instance.
3024 * @rmtoll ISR CTSIF LL_USART_IsActiveFlag_nCTS
3025 * @param USARTx USART Instance
3026 * @retval State of bit (1 or 0).
3028 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(USART_TypeDef *USARTx)
3030 return ((READ_BIT(USARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF)) ? 1UL : 0UL);
3034 * @brief Check if the USART CTS Flag is set or not
3035 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
3036 * Hardware Flow control feature is supported by the USARTx instance.
3037 * @rmtoll ISR CTS LL_USART_IsActiveFlag_CTS
3038 * @param USARTx USART Instance
3039 * @retval State of bit (1 or 0).
3041 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CTS(USART_TypeDef *USARTx)
3043 return ((READ_BIT(USARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS)) ? 1UL : 0UL);
3047 * @brief Check if the USART Receiver Time Out Flag is set or not
3048 * @rmtoll ISR RTOF LL_USART_IsActiveFlag_RTO
3049 * @param USARTx USART Instance
3050 * @retval State of bit (1 or 0).
3052 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RTO(USART_TypeDef *USARTx)
3054 return ((READ_BIT(USARTx->ISR, USART_ISR_RTOF) == (USART_ISR_RTOF)) ? 1UL : 0UL);
3058 * @brief Check if the USART End Of Block Flag is set or not
3059 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
3060 * Smartcard feature is supported by the USARTx instance.
3061 * @rmtoll ISR EOBF LL_USART_IsActiveFlag_EOB
3062 * @param USARTx USART Instance
3063 * @retval State of bit (1 or 0).
3065 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_EOB(USART_TypeDef *USARTx)
3067 return ((READ_BIT(USARTx->ISR, USART_ISR_EOBF) == (USART_ISR_EOBF)) ? 1UL : 0UL);
3071 * @brief Check if the SPI Slave Underrun error flag is set or not
3072 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
3073 * SPI Slave mode feature is supported by the USARTx instance.
3074 * @rmtoll ISR UDR LL_USART_IsActiveFlag_UDR
3075 * @param USARTx USART Instance
3076 * @retval State of bit (1 or 0).
3078 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_UDR(USART_TypeDef *USARTx)
3080 return ((READ_BIT(USARTx->ISR, USART_ISR_UDR) == (USART_ISR_UDR)) ? 1UL : 0UL);
3084 * @brief Check if the USART Auto-Baud Rate Error Flag is set or not
3085 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
3086 * Auto Baud Rate detection feature is supported by the USARTx instance.
3087 * @rmtoll ISR ABRE LL_USART_IsActiveFlag_ABRE
3088 * @param USARTx USART Instance
3089 * @retval State of bit (1 or 0).
3091 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABRE(USART_TypeDef *USARTx)
3093 return ((READ_BIT(USARTx->ISR, USART_ISR_ABRE) == (USART_ISR_ABRE)) ? 1UL : 0UL);
3097 * @brief Check if the USART Auto-Baud Rate Flag is set or not
3098 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
3099 * Auto Baud Rate detection feature is supported by the USARTx instance.
3100 * @rmtoll ISR ABRF LL_USART_IsActiveFlag_ABR
3101 * @param USARTx USART Instance
3102 * @retval State of bit (1 or 0).
3104 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABR(USART_TypeDef *USARTx)
3106 return ((READ_BIT(USARTx->ISR, USART_ISR_ABRF) == (USART_ISR_ABRF)) ? 1UL : 0UL);
3110 * @brief Check if the USART Busy Flag is set or not
3111 * @rmtoll ISR BUSY LL_USART_IsActiveFlag_BUSY
3112 * @param USARTx USART Instance
3113 * @retval State of bit (1 or 0).
3115 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_BUSY(USART_TypeDef *USARTx)
3117 return ((READ_BIT(USARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY)) ? 1UL : 0UL);
3121 * @brief Check if the USART Character Match Flag is set or not
3122 * @rmtoll ISR CMF LL_USART_IsActiveFlag_CM
3123 * @param USARTx USART Instance
3124 * @retval State of bit (1 or 0).
3126 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CM(USART_TypeDef *USARTx)
3128 return ((READ_BIT(USARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF)) ? 1UL : 0UL);
3132 * @brief Check if the USART Send Break Flag is set or not
3133 * @rmtoll ISR SBKF LL_USART_IsActiveFlag_SBK
3134 * @param USARTx USART Instance
3135 * @retval State of bit (1 or 0).
3137 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(USART_TypeDef *USARTx)
3139 return ((READ_BIT(USARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF)) ? 1UL : 0UL);
3143 * @brief Check if the USART Receive Wake Up from mute mode Flag is set or not
3144 * @rmtoll ISR RWU LL_USART_IsActiveFlag_RWU
3145 * @param USARTx USART Instance
3146 * @retval State of bit (1 or 0).
3148 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(USART_TypeDef *USARTx)
3150 return ((READ_BIT(USARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU)) ? 1UL : 0UL);
3154 * @brief Check if the USART Wake Up from stop mode Flag is set or not
3155 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
3156 * Wake-up from Stop mode feature is supported by the USARTx instance.
3157 * @rmtoll ISR WUF LL_USART_IsActiveFlag_WKUP
3158 * @param USARTx USART Instance
3159 * @retval State of bit (1 or 0).
3161 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_WKUP(USART_TypeDef *USARTx)
3163 return ((READ_BIT(USARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF)) ? 1UL : 0UL);
3167 * @brief Check if the USART Transmit Enable Acknowledge Flag is set or not
3168 * @rmtoll ISR TEACK LL_USART_IsActiveFlag_TEACK
3169 * @param USARTx USART Instance
3170 * @retval State of bit (1 or 0).
3172 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TEACK(USART_TypeDef *USARTx)
3174 return ((READ_BIT(USARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK)) ? 1UL : 0UL);
3178 * @brief Check if the USART Receive Enable Acknowledge Flag is set or not
3179 * @rmtoll ISR REACK LL_USART_IsActiveFlag_REACK
3180 * @param USARTx USART Instance
3181 * @retval State of bit (1 or 0).
3183 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_REACK(USART_TypeDef *USARTx)
3185 return ((READ_BIT(USARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK)) ? 1UL : 0UL);
3189 * @brief Check if the USART TX FIFO Empty Flag is set or not
3190 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3191 * FIFO mode feature is supported by the USARTx instance.
3192 * @rmtoll ISR TXFE LL_USART_IsActiveFlag_TXFE
3193 * @param USARTx USART Instance
3194 * @retval State of bit (1 or 0).
3196 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXFE(USART_TypeDef *USARTx)
3198 return ((READ_BIT(USARTx->ISR, USART_ISR_TXFE) == (USART_ISR_TXFE)) ? 1UL : 0UL);
3202 * @brief Check if the USART RX FIFO Full Flag is set or not
3203 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3204 * FIFO mode feature is supported by the USARTx instance.
3205 * @rmtoll ISR RXFF LL_USART_IsActiveFlag_RXFF
3206 * @param USARTx USART Instance
3207 * @retval State of bit (1 or 0).
3209 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXFF(USART_TypeDef *USARTx)
3211 return ((READ_BIT(USARTx->ISR, USART_ISR_RXFF) == (USART_ISR_RXFF)) ? 1UL : 0UL);
3215 * @brief Check if the Smartcard Transmission Complete Before Guard Time Flag is set or not
3216 * @rmtoll ISR TCBGT LL_USART_IsActiveFlag_TCBGT
3217 * @param USARTx USART Instance
3218 * @retval State of bit (1 or 0).
3220 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TCBGT(USART_TypeDef *USARTx)
3222 return ((READ_BIT(USARTx->ISR, USART_ISR_TCBGT) == (USART_ISR_TCBGT)) ? 1UL : 0UL);
3226 * @brief Check if the USART TX FIFO Threshold Flag is set or not
3227 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3228 * FIFO mode feature is supported by the USARTx instance.
3229 * @rmtoll ISR TXFT LL_USART_IsActiveFlag_TXFT
3230 * @param USARTx USART Instance
3231 * @retval State of bit (1 or 0).
3233 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXFT(USART_TypeDef *USARTx)
3235 return ((READ_BIT(USARTx->ISR, USART_ISR_TXFT) == (USART_ISR_TXFT)) ? 1UL : 0UL);
3239 * @brief Check if the USART RX FIFO Threshold Flag is set or not
3240 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3241 * FIFO mode feature is supported by the USARTx instance.
3242 * @rmtoll ISR RXFT LL_USART_IsActiveFlag_RXFT
3243 * @param USARTx USART Instance
3244 * @retval State of bit (1 or 0).
3246 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXFT(USART_TypeDef *USARTx)
3248 return ((READ_BIT(USARTx->ISR, USART_ISR_RXFT) == (USART_ISR_RXFT)) ? 1UL : 0UL);
3252 * @brief Clear Parity Error Flag
3253 * @rmtoll ICR PECF LL_USART_ClearFlag_PE
3254 * @param USARTx USART Instance
3255 * @retval None
3257 __STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx)
3259 WRITE_REG(USARTx->ICR, USART_ICR_PECF);
3263 * @brief Clear Framing Error Flag
3264 * @rmtoll ICR FECF LL_USART_ClearFlag_FE
3265 * @param USARTx USART Instance
3266 * @retval None
3268 __STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx)
3270 WRITE_REG(USARTx->ICR, USART_ICR_FECF);
3274 * @brief Clear Noise Error detected Flag
3275 * @rmtoll ICR NECF LL_USART_ClearFlag_NE
3276 * @param USARTx USART Instance
3277 * @retval None
3279 __STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx)
3281 WRITE_REG(USARTx->ICR, USART_ICR_NECF);
3285 * @brief Clear OverRun Error Flag
3286 * @rmtoll ICR ORECF LL_USART_ClearFlag_ORE
3287 * @param USARTx USART Instance
3288 * @retval None
3290 __STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx)
3292 WRITE_REG(USARTx->ICR, USART_ICR_ORECF);
3296 * @brief Clear IDLE line detected Flag
3297 * @rmtoll ICR IDLECF LL_USART_ClearFlag_IDLE
3298 * @param USARTx USART Instance
3299 * @retval None
3301 __STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx)
3303 WRITE_REG(USARTx->ICR, USART_ICR_IDLECF);
3307 * @brief Clear TX FIFO Empty Flag
3308 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3309 * FIFO mode feature is supported by the USARTx instance.
3310 * @rmtoll ICR TXFECF LL_USART_ClearFlag_TXFE
3311 * @param USARTx USART Instance
3312 * @retval None
3314 __STATIC_INLINE void LL_USART_ClearFlag_TXFE(USART_TypeDef *USARTx)
3316 WRITE_REG(USARTx->ICR, USART_ICR_TXFECF);
3320 * @brief Clear Transmission Complete Flag
3321 * @rmtoll ICR TCCF LL_USART_ClearFlag_TC
3322 * @param USARTx USART Instance
3323 * @retval None
3325 __STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx)
3327 WRITE_REG(USARTx->ICR, USART_ICR_TCCF);
3331 * @brief Clear Smartcard Transmission Complete Before Guard Time Flag
3332 * @rmtoll ICR TCBGTCF LL_USART_ClearFlag_TCBGT
3333 * @param USARTx USART Instance
3334 * @retval None
3336 __STATIC_INLINE void LL_USART_ClearFlag_TCBGT(USART_TypeDef *USARTx)
3338 WRITE_REG(USARTx->ICR, USART_ICR_TCBGTCF);
3342 * @brief Clear LIN Break Detection Flag
3343 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
3344 * LIN feature is supported by the USARTx instance.
3345 * @rmtoll ICR LBDCF LL_USART_ClearFlag_LBD
3346 * @param USARTx USART Instance
3347 * @retval None
3349 __STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx)
3351 WRITE_REG(USARTx->ICR, USART_ICR_LBDCF);
3355 * @brief Clear CTS Interrupt Flag
3356 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
3357 * Hardware Flow control feature is supported by the USARTx instance.
3358 * @rmtoll ICR CTSCF LL_USART_ClearFlag_nCTS
3359 * @param USARTx USART Instance
3360 * @retval None
3362 __STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx)
3364 WRITE_REG(USARTx->ICR, USART_ICR_CTSCF);
3368 * @brief Clear Receiver Time Out Flag
3369 * @rmtoll ICR RTOCF LL_USART_ClearFlag_RTO
3370 * @param USARTx USART Instance
3371 * @retval None
3373 __STATIC_INLINE void LL_USART_ClearFlag_RTO(USART_TypeDef *USARTx)
3375 WRITE_REG(USARTx->ICR, USART_ICR_RTOCF);
3379 * @brief Clear End Of Block Flag
3380 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
3381 * Smartcard feature is supported by the USARTx instance.
3382 * @rmtoll ICR EOBCF LL_USART_ClearFlag_EOB
3383 * @param USARTx USART Instance
3384 * @retval None
3386 __STATIC_INLINE void LL_USART_ClearFlag_EOB(USART_TypeDef *USARTx)
3388 WRITE_REG(USARTx->ICR, USART_ICR_EOBCF);
3392 * @brief Clear SPI Slave Underrun Flag
3393 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
3394 * SPI Slave mode feature is supported by the USARTx instance.
3395 * @rmtoll ICR UDRCF LL_USART_ClearFlag_UDR
3396 * @param USARTx USART Instance
3397 * @retval None
3399 __STATIC_INLINE void LL_USART_ClearFlag_UDR(USART_TypeDef *USARTx)
3401 WRITE_REG(USARTx->ICR, USART_ICR_UDRCF);
3405 * @brief Clear Character Match Flag
3406 * @rmtoll ICR CMCF LL_USART_ClearFlag_CM
3407 * @param USARTx USART Instance
3408 * @retval None
3410 __STATIC_INLINE void LL_USART_ClearFlag_CM(USART_TypeDef *USARTx)
3412 WRITE_REG(USARTx->ICR, USART_ICR_CMCF);
3416 * @brief Clear Wake Up from stop mode Flag
3417 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
3418 * Wake-up from Stop mode feature is supported by the USARTx instance.
3419 * @rmtoll ICR WUCF LL_USART_ClearFlag_WKUP
3420 * @param USARTx USART Instance
3421 * @retval None
3423 __STATIC_INLINE void LL_USART_ClearFlag_WKUP(USART_TypeDef *USARTx)
3425 WRITE_REG(USARTx->ICR, USART_ICR_WUCF);
3429 * @}
3432 /** @defgroup USART_LL_EF_IT_Management IT_Management
3433 * @{
3437 * @brief Enable IDLE Interrupt
3438 * @rmtoll CR1 IDLEIE LL_USART_EnableIT_IDLE
3439 * @param USARTx USART Instance
3440 * @retval None
3442 __STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx)
3444 SET_BIT(USARTx->CR1, USART_CR1_IDLEIE);
3447 /* Legacy define */
3448 #define LL_USART_EnableIT_RXNE LL_USART_EnableIT_RXNE_RXFNE
3451 * @brief Enable RX Not Empty and RX FIFO Not Empty Interrupt
3452 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3453 * FIFO mode feature is supported by the USARTx instance.
3454 * @rmtoll CR1 RXNEIE_RXFNEIE LL_USART_EnableIT_RXNE_RXFNE
3455 * @param USARTx USART Instance
3456 * @retval None
3458 __STATIC_INLINE void LL_USART_EnableIT_RXNE_RXFNE(USART_TypeDef *USARTx)
3460 SET_BIT(USARTx->CR1, USART_CR1_RXNEIE_RXFNEIE);
3464 * @brief Enable Transmission Complete Interrupt
3465 * @rmtoll CR1 TCIE LL_USART_EnableIT_TC
3466 * @param USARTx USART Instance
3467 * @retval None
3469 __STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx)
3471 SET_BIT(USARTx->CR1, USART_CR1_TCIE);
3474 /* Legacy define */
3475 #define LL_USART_EnableIT_TXE LL_USART_EnableIT_TXE_TXFNF
3478 * @brief Enable TX Empty and TX FIFO Not Full Interrupt
3479 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3480 * FIFO mode feature is supported by the USARTx instance.
3481 * @rmtoll CR1 TXEIE_TXFNFIE LL_USART_EnableIT_TXE_TXFNF
3482 * @param USARTx USART Instance
3483 * @retval None
3485 __STATIC_INLINE void LL_USART_EnableIT_TXE_TXFNF(USART_TypeDef *USARTx)
3487 SET_BIT(USARTx->CR1, USART_CR1_TXEIE_TXFNFIE);
3491 * @brief Enable Parity Error Interrupt
3492 * @rmtoll CR1 PEIE LL_USART_EnableIT_PE
3493 * @param USARTx USART Instance
3494 * @retval None
3496 __STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx)
3498 SET_BIT(USARTx->CR1, USART_CR1_PEIE);
3502 * @brief Enable Character Match Interrupt
3503 * @rmtoll CR1 CMIE LL_USART_EnableIT_CM
3504 * @param USARTx USART Instance
3505 * @retval None
3507 __STATIC_INLINE void LL_USART_EnableIT_CM(USART_TypeDef *USARTx)
3509 SET_BIT(USARTx->CR1, USART_CR1_CMIE);
3513 * @brief Enable Receiver Timeout Interrupt
3514 * @rmtoll CR1 RTOIE LL_USART_EnableIT_RTO
3515 * @param USARTx USART Instance
3516 * @retval None
3518 __STATIC_INLINE void LL_USART_EnableIT_RTO(USART_TypeDef *USARTx)
3520 SET_BIT(USARTx->CR1, USART_CR1_RTOIE);
3524 * @brief Enable End Of Block Interrupt
3525 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
3526 * Smartcard feature is supported by the USARTx instance.
3527 * @rmtoll CR1 EOBIE LL_USART_EnableIT_EOB
3528 * @param USARTx USART Instance
3529 * @retval None
3531 __STATIC_INLINE void LL_USART_EnableIT_EOB(USART_TypeDef *USARTx)
3533 SET_BIT(USARTx->CR1, USART_CR1_EOBIE);
3537 * @brief Enable TX FIFO Empty Interrupt
3538 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3539 * FIFO mode feature is supported by the USARTx instance.
3540 * @rmtoll CR1 TXFEIE LL_USART_EnableIT_TXFE
3541 * @param USARTx USART Instance
3542 * @retval None
3544 __STATIC_INLINE void LL_USART_EnableIT_TXFE(USART_TypeDef *USARTx)
3546 SET_BIT(USARTx->CR1, USART_CR1_TXFEIE);
3550 * @brief Enable RX FIFO Full Interrupt
3551 * @rmtoll CR1 RXFFIE LL_USART_EnableIT_RXFF
3552 * @param USARTx USART Instance
3553 * @retval None
3555 __STATIC_INLINE void LL_USART_EnableIT_RXFF(USART_TypeDef *USARTx)
3557 SET_BIT(USARTx->CR1, USART_CR1_RXFFIE);
3561 * @brief Enable LIN Break Detection Interrupt
3562 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
3563 * LIN feature is supported by the USARTx instance.
3564 * @rmtoll CR2 LBDIE LL_USART_EnableIT_LBD
3565 * @param USARTx USART Instance
3566 * @retval None
3568 __STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx)
3570 SET_BIT(USARTx->CR2, USART_CR2_LBDIE);
3574 * @brief Enable Error Interrupt
3575 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
3576 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register).
3577 * 0: Interrupt is inhibited
3578 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register.
3579 * @rmtoll CR3 EIE LL_USART_EnableIT_ERROR
3580 * @param USARTx USART Instance
3581 * @retval None
3583 __STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx)
3585 SET_BIT(USARTx->CR3, USART_CR3_EIE);
3589 * @brief Enable CTS Interrupt
3590 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
3591 * Hardware Flow control feature is supported by the USARTx instance.
3592 * @rmtoll CR3 CTSIE LL_USART_EnableIT_CTS
3593 * @param USARTx USART Instance
3594 * @retval None
3596 __STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx)
3598 SET_BIT(USARTx->CR3, USART_CR3_CTSIE);
3602 * @brief Enable Wake Up from Stop Mode Interrupt
3603 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
3604 * Wake-up from Stop mode feature is supported by the USARTx instance.
3605 * @rmtoll CR3 WUFIE LL_USART_EnableIT_WKUP
3606 * @param USARTx USART Instance
3607 * @retval None
3609 __STATIC_INLINE void LL_USART_EnableIT_WKUP(USART_TypeDef *USARTx)
3611 SET_BIT(USARTx->CR3, USART_CR3_WUFIE);
3615 * @brief Enable TX FIFO Threshold Interrupt
3616 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3617 * FIFO mode feature is supported by the USARTx instance.
3618 * @rmtoll CR3 TXFTIE LL_USART_EnableIT_TXFT
3619 * @param USARTx USART Instance
3620 * @retval None
3622 __STATIC_INLINE void LL_USART_EnableIT_TXFT(USART_TypeDef *USARTx)
3624 SET_BIT(USARTx->CR3, USART_CR3_TXFTIE);
3628 * @brief Enable Smartcard Transmission Complete Before Guard Time Interrupt
3629 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
3630 * Smartcard feature is supported by the USARTx instance.
3631 * @rmtoll CR3 TCBGTIE LL_USART_EnableIT_TCBGT
3632 * @param USARTx USART Instance
3633 * @retval None
3635 __STATIC_INLINE void LL_USART_EnableIT_TCBGT(USART_TypeDef *USARTx)
3637 SET_BIT(USARTx->CR3, USART_CR3_TCBGTIE);
3641 * @brief Enable RX FIFO Threshold Interrupt
3642 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3643 * FIFO mode feature is supported by the USARTx instance.
3644 * @rmtoll CR3 RXFTIE LL_USART_EnableIT_RXFT
3645 * @param USARTx USART Instance
3646 * @retval None
3648 __STATIC_INLINE void LL_USART_EnableIT_RXFT(USART_TypeDef *USARTx)
3650 SET_BIT(USARTx->CR3, USART_CR3_RXFTIE);
3654 * @brief Disable IDLE Interrupt
3655 * @rmtoll CR1 IDLEIE LL_USART_DisableIT_IDLE
3656 * @param USARTx USART Instance
3657 * @retval None
3659 __STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx)
3661 CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE);
3664 /* Legacy define */
3665 #define LL_USART_DisableIT_RXNE LL_USART_DisableIT_RXNE_RXFNE
3668 * @brief Disable RX Not Empty and RX FIFO Not Empty Interrupt
3669 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3670 * FIFO mode feature is supported by the USARTx instance.
3671 * @rmtoll CR1 RXNEIE_RXFNEIE LL_USART_DisableIT_RXNE_RXFNE
3672 * @param USARTx USART Instance
3673 * @retval None
3675 __STATIC_INLINE void LL_USART_DisableIT_RXNE_RXFNE(USART_TypeDef *USARTx)
3677 CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE_RXFNEIE);
3681 * @brief Disable Transmission Complete Interrupt
3682 * @rmtoll CR1 TCIE LL_USART_DisableIT_TC
3683 * @param USARTx USART Instance
3684 * @retval None
3686 __STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx)
3688 CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE);
3691 /* Legacy define */
3692 #define LL_USART_DisableIT_TXE LL_USART_DisableIT_TXE_TXFNF
3695 * @brief Disable TX Empty and TX FIFO Not Full Interrupt
3696 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3697 * FIFO mode feature is supported by the USARTx instance.
3698 * @rmtoll CR1 TXEIE_TXFNFIE LL_USART_DisableIT_TXE_TXFNF
3699 * @param USARTx USART Instance
3700 * @retval None
3702 __STATIC_INLINE void LL_USART_DisableIT_TXE_TXFNF(USART_TypeDef *USARTx)
3704 CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE_TXFNFIE);
3708 * @brief Disable Parity Error Interrupt
3709 * @rmtoll CR1 PEIE LL_USART_DisableIT_PE
3710 * @param USARTx USART Instance
3711 * @retval None
3713 __STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx)
3715 CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE);
3719 * @brief Disable Character Match Interrupt
3720 * @rmtoll CR1 CMIE LL_USART_DisableIT_CM
3721 * @param USARTx USART Instance
3722 * @retval None
3724 __STATIC_INLINE void LL_USART_DisableIT_CM(USART_TypeDef *USARTx)
3726 CLEAR_BIT(USARTx->CR1, USART_CR1_CMIE);
3730 * @brief Disable Receiver Timeout Interrupt
3731 * @rmtoll CR1 RTOIE LL_USART_DisableIT_RTO
3732 * @param USARTx USART Instance
3733 * @retval None
3735 __STATIC_INLINE void LL_USART_DisableIT_RTO(USART_TypeDef *USARTx)
3737 CLEAR_BIT(USARTx->CR1, USART_CR1_RTOIE);
3741 * @brief Disable End Of Block Interrupt
3742 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
3743 * Smartcard feature is supported by the USARTx instance.
3744 * @rmtoll CR1 EOBIE LL_USART_DisableIT_EOB
3745 * @param USARTx USART Instance
3746 * @retval None
3748 __STATIC_INLINE void LL_USART_DisableIT_EOB(USART_TypeDef *USARTx)
3750 CLEAR_BIT(USARTx->CR1, USART_CR1_EOBIE);
3754 * @brief Disable TX FIFO Empty Interrupt
3755 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3756 * FIFO mode feature is supported by the USARTx instance.
3757 * @rmtoll CR1 TXFEIE LL_USART_DisableIT_TXFE
3758 * @param USARTx USART Instance
3759 * @retval None
3761 __STATIC_INLINE void LL_USART_DisableIT_TXFE(USART_TypeDef *USARTx)
3763 CLEAR_BIT(USARTx->CR1, USART_CR1_TXFEIE);
3767 * @brief Disable RX FIFO Full Interrupt
3768 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3769 * FIFO mode feature is supported by the USARTx instance.
3770 * @rmtoll CR1 RXFFIE LL_USART_DisableIT_RXFF
3771 * @param USARTx USART Instance
3772 * @retval None
3774 __STATIC_INLINE void LL_USART_DisableIT_RXFF(USART_TypeDef *USARTx)
3776 CLEAR_BIT(USARTx->CR1, USART_CR1_RXFFIE);
3780 * @brief Disable LIN Break Detection Interrupt
3781 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
3782 * LIN feature is supported by the USARTx instance.
3783 * @rmtoll CR2 LBDIE LL_USART_DisableIT_LBD
3784 * @param USARTx USART Instance
3785 * @retval None
3787 __STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx)
3789 CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE);
3793 * @brief Disable Error Interrupt
3794 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
3795 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register).
3796 * 0: Interrupt is inhibited
3797 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register.
3798 * @rmtoll CR3 EIE LL_USART_DisableIT_ERROR
3799 * @param USARTx USART Instance
3800 * @retval None
3802 __STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx)
3804 CLEAR_BIT(USARTx->CR3, USART_CR3_EIE);
3808 * @brief Disable CTS Interrupt
3809 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
3810 * Hardware Flow control feature is supported by the USARTx instance.
3811 * @rmtoll CR3 CTSIE LL_USART_DisableIT_CTS
3812 * @param USARTx USART Instance
3813 * @retval None
3815 __STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx)
3817 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE);
3821 * @brief Disable Wake Up from Stop Mode Interrupt
3822 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
3823 * Wake-up from Stop mode feature is supported by the USARTx instance.
3824 * @rmtoll CR3 WUFIE LL_USART_DisableIT_WKUP
3825 * @param USARTx USART Instance
3826 * @retval None
3828 __STATIC_INLINE void LL_USART_DisableIT_WKUP(USART_TypeDef *USARTx)
3830 CLEAR_BIT(USARTx->CR3, USART_CR3_WUFIE);
3834 * @brief Disable TX FIFO Threshold Interrupt
3835 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3836 * FIFO mode feature is supported by the USARTx instance.
3837 * @rmtoll CR3 TXFTIE LL_USART_DisableIT_TXFT
3838 * @param USARTx USART Instance
3839 * @retval None
3841 __STATIC_INLINE void LL_USART_DisableIT_TXFT(USART_TypeDef *USARTx)
3843 CLEAR_BIT(USARTx->CR3, USART_CR3_TXFTIE);
3847 * @brief Disable Smartcard Transmission Complete Before Guard Time Interrupt
3848 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
3849 * Smartcard feature is supported by the USARTx instance.
3850 * @rmtoll CR3 TCBGTIE LL_USART_DisableIT_TCBGT
3851 * @param USARTx USART Instance
3852 * @retval None
3854 __STATIC_INLINE void LL_USART_DisableIT_TCBGT(USART_TypeDef *USARTx)
3856 CLEAR_BIT(USARTx->CR3, USART_CR3_TCBGTIE);
3860 * @brief Disable RX FIFO Threshold Interrupt
3861 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3862 * FIFO mode feature is supported by the USARTx instance.
3863 * @rmtoll CR3 RXFTIE LL_USART_DisableIT_RXFT
3864 * @param USARTx USART Instance
3865 * @retval None
3867 __STATIC_INLINE void LL_USART_DisableIT_RXFT(USART_TypeDef *USARTx)
3869 CLEAR_BIT(USARTx->CR3, USART_CR3_RXFTIE);
3873 * @brief Check if the USART IDLE Interrupt source is enabled or disabled.
3874 * @rmtoll CR1 IDLEIE LL_USART_IsEnabledIT_IDLE
3875 * @param USARTx USART Instance
3876 * @retval State of bit (1 or 0).
3878 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(USART_TypeDef *USARTx)
3880 return ((READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE)) ? 1UL : 0UL);
3883 /* Legacy define */
3884 #define LL_USART_IsEnabledIT_RXNE LL_USART_IsEnabledIT_RXNE_RXFNE
3887 * @brief Check if the USART RX Not Empty and USART RX FIFO Not Empty Interrupt is enabled or disabled.
3888 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3889 * FIFO mode feature is supported by the USARTx instance.
3890 * @rmtoll CR1 RXNEIE_RXFNEIE LL_USART_IsEnabledIT_RXNE_RXFNE
3891 * @param USARTx USART Instance
3892 * @retval State of bit (1 or 0).
3894 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE_RXFNE(USART_TypeDef *USARTx)
3896 return ((READ_BIT(USARTx->CR1, USART_CR1_RXNEIE_RXFNEIE) == (USART_CR1_RXNEIE_RXFNEIE)) ? 1UL : 0UL);
3900 * @brief Check if the USART Transmission Complete Interrupt is enabled or disabled.
3901 * @rmtoll CR1 TCIE LL_USART_IsEnabledIT_TC
3902 * @param USARTx USART Instance
3903 * @retval State of bit (1 or 0).
3905 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(USART_TypeDef *USARTx)
3907 return ((READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE)) ? 1UL : 0UL);
3910 /* Legacy define */
3911 #define LL_USART_IsEnabledIT_TXE LL_USART_IsEnabledIT_TXE_TXFNF
3914 * @brief Check if the USART TX Empty and USART TX FIFO Not Full Interrupt is enabled or disabled
3915 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3916 * FIFO mode feature is supported by the USARTx instance.
3917 * @rmtoll CR1 TXEIE_TXFNFIE LL_USART_IsEnabledIT_TXE_TXFNF
3918 * @param USARTx USART Instance
3919 * @retval State of bit (1 or 0).
3921 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE_TXFNF(USART_TypeDef *USARTx)
3923 return ((READ_BIT(USARTx->CR1, USART_CR1_TXEIE_TXFNFIE) == (USART_CR1_TXEIE_TXFNFIE)) ? 1UL : 0UL);
3927 * @brief Check if the USART Parity Error Interrupt is enabled or disabled.
3928 * @rmtoll CR1 PEIE LL_USART_IsEnabledIT_PE
3929 * @param USARTx USART Instance
3930 * @retval State of bit (1 or 0).
3932 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(USART_TypeDef *USARTx)
3934 return ((READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE)) ? 1UL : 0UL);
3938 * @brief Check if the USART Character Match Interrupt is enabled or disabled.
3939 * @rmtoll CR1 CMIE LL_USART_IsEnabledIT_CM
3940 * @param USARTx USART Instance
3941 * @retval State of bit (1 or 0).
3943 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CM(USART_TypeDef *USARTx)
3945 return ((READ_BIT(USARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE)) ? 1UL : 0UL);
3949 * @brief Check if the USART Receiver Timeout Interrupt is enabled or disabled.
3950 * @rmtoll CR1 RTOIE LL_USART_IsEnabledIT_RTO
3951 * @param USARTx USART Instance
3952 * @retval State of bit (1 or 0).
3954 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RTO(USART_TypeDef *USARTx)
3956 return ((READ_BIT(USARTx->CR1, USART_CR1_RTOIE) == (USART_CR1_RTOIE)) ? 1UL : 0UL);
3960 * @brief Check if the USART End Of Block Interrupt is enabled or disabled.
3961 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
3962 * Smartcard feature is supported by the USARTx instance.
3963 * @rmtoll CR1 EOBIE LL_USART_IsEnabledIT_EOB
3964 * @param USARTx USART Instance
3965 * @retval State of bit (1 or 0).
3967 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_EOB(USART_TypeDef *USARTx)
3969 return ((READ_BIT(USARTx->CR1, USART_CR1_EOBIE) == (USART_CR1_EOBIE)) ? 1UL : 0UL);
3973 * @brief Check if the USART TX FIFO Empty Interrupt is enabled or disabled
3974 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3975 * FIFO mode feature is supported by the USARTx instance.
3976 * @rmtoll CR1 TXFEIE LL_USART_IsEnabledIT_TXFE
3977 * @param USARTx USART Instance
3978 * @retval State of bit (1 or 0).
3980 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXFE(USART_TypeDef *USARTx)
3982 return ((READ_BIT(USARTx->CR1, USART_CR1_TXFEIE) == (USART_CR1_TXFEIE)) ? 1UL : 0UL);
3986 * @brief Check if the USART RX FIFO Full Interrupt is enabled or disabled
3987 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3988 * FIFO mode feature is supported by the USARTx instance.
3989 * @rmtoll CR1 RXFFIE LL_USART_IsEnabledIT_RXFF
3990 * @param USARTx USART Instance
3991 * @retval State of bit (1 or 0).
3993 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXFF(USART_TypeDef *USARTx)
3995 return ((READ_BIT(USARTx->CR1, USART_CR1_RXFFIE) == (USART_CR1_RXFFIE)) ? 1UL : 0UL);
3999 * @brief Check if the USART LIN Break Detection Interrupt is enabled or disabled.
4000 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
4001 * LIN feature is supported by the USARTx instance.
4002 * @rmtoll CR2 LBDIE LL_USART_IsEnabledIT_LBD
4003 * @param USARTx USART Instance
4004 * @retval State of bit (1 or 0).
4006 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(USART_TypeDef *USARTx)
4008 return ((READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE)) ? 1UL : 0UL);
4012 * @brief Check if the USART Error Interrupt is enabled or disabled.
4013 * @rmtoll CR3 EIE LL_USART_IsEnabledIT_ERROR
4014 * @param USARTx USART Instance
4015 * @retval State of bit (1 or 0).
4017 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(USART_TypeDef *USARTx)
4019 return ((READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE)) ? 1UL : 0UL);
4023 * @brief Check if the USART CTS Interrupt is enabled or disabled.
4024 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
4025 * Hardware Flow control feature is supported by the USARTx instance.
4026 * @rmtoll CR3 CTSIE LL_USART_IsEnabledIT_CTS
4027 * @param USARTx USART Instance
4028 * @retval State of bit (1 or 0).
4030 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(USART_TypeDef *USARTx)
4032 return ((READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE)) ? 1UL : 0UL);
4036 * @brief Check if the USART Wake Up from Stop Mode Interrupt is enabled or disabled.
4037 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
4038 * Wake-up from Stop mode feature is supported by the USARTx instance.
4039 * @rmtoll CR3 WUFIE LL_USART_IsEnabledIT_WKUP
4040 * @param USARTx USART Instance
4041 * @retval State of bit (1 or 0).
4043 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_WKUP(USART_TypeDef *USARTx)
4045 return ((READ_BIT(USARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE)) ? 1UL : 0UL);
4049 * @brief Check if USART TX FIFO Threshold Interrupt is enabled or disabled
4050 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4051 * FIFO mode feature is supported by the USARTx instance.
4052 * @rmtoll CR3 TXFTIE LL_USART_IsEnabledIT_TXFT
4053 * @param USARTx USART Instance
4054 * @retval State of bit (1 or 0).
4056 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXFT(USART_TypeDef *USARTx)
4058 return ((READ_BIT(USARTx->CR3, USART_CR3_TXFTIE) == (USART_CR3_TXFTIE)) ? 1UL : 0UL);
4062 * @brief Check if the Smartcard Transmission Complete Before Guard Time Interrupt is enabled or disabled.
4063 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
4064 * Smartcard feature is supported by the USARTx instance.
4065 * @rmtoll CR3 TCBGTIE LL_USART_IsEnabledIT_TCBGT
4066 * @param USARTx USART Instance
4067 * @retval State of bit (1 or 0).
4069 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TCBGT(USART_TypeDef *USARTx)
4071 return ((READ_BIT(USARTx->CR3, USART_CR3_TCBGTIE) == (USART_CR3_TCBGTIE)) ? 1UL : 0UL);
4075 * @brief Check if USART RX FIFO Threshold Interrupt is enabled or disabled
4076 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4077 * FIFO mode feature is supported by the USARTx instance.
4078 * @rmtoll CR3 RXFTIE LL_USART_IsEnabledIT_RXFT
4079 * @param USARTx USART Instance
4080 * @retval State of bit (1 or 0).
4082 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXFT(USART_TypeDef *USARTx)
4084 return ((READ_BIT(USARTx->CR3, USART_CR3_RXFTIE) == (USART_CR3_RXFTIE)) ? 1UL : 0UL);
4088 * @}
4091 /** @defgroup USART_LL_EF_DMA_Management DMA_Management
4092 * @{
4096 * @brief Enable DMA Mode for reception
4097 * @rmtoll CR3 DMAR LL_USART_EnableDMAReq_RX
4098 * @param USARTx USART Instance
4099 * @retval None
4101 __STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx)
4103 SET_BIT(USARTx->CR3, USART_CR3_DMAR);
4107 * @brief Disable DMA Mode for reception
4108 * @rmtoll CR3 DMAR LL_USART_DisableDMAReq_RX
4109 * @param USARTx USART Instance
4110 * @retval None
4112 __STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx)
4114 CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR);
4118 * @brief Check if DMA Mode is enabled for reception
4119 * @rmtoll CR3 DMAR LL_USART_IsEnabledDMAReq_RX
4120 * @param USARTx USART Instance
4121 * @retval State of bit (1 or 0).
4123 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(USART_TypeDef *USARTx)
4125 return ((READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR)) ? 1UL : 0UL);
4129 * @brief Enable DMA Mode for transmission
4130 * @rmtoll CR3 DMAT LL_USART_EnableDMAReq_TX
4131 * @param USARTx USART Instance
4132 * @retval None
4134 __STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx)
4136 SET_BIT(USARTx->CR3, USART_CR3_DMAT);
4140 * @brief Disable DMA Mode for transmission
4141 * @rmtoll CR3 DMAT LL_USART_DisableDMAReq_TX
4142 * @param USARTx USART Instance
4143 * @retval None
4145 __STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx)
4147 CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT);
4151 * @brief Check if DMA Mode is enabled for transmission
4152 * @rmtoll CR3 DMAT LL_USART_IsEnabledDMAReq_TX
4153 * @param USARTx USART Instance
4154 * @retval State of bit (1 or 0).
4156 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(USART_TypeDef *USARTx)
4158 return ((READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT)) ? 1UL : 0UL);
4162 * @brief Enable DMA Disabling on Reception Error
4163 * @rmtoll CR3 DDRE LL_USART_EnableDMADeactOnRxErr
4164 * @param USARTx USART Instance
4165 * @retval None
4167 __STATIC_INLINE void LL_USART_EnableDMADeactOnRxErr(USART_TypeDef *USARTx)
4169 SET_BIT(USARTx->CR3, USART_CR3_DDRE);
4173 * @brief Disable DMA Disabling on Reception Error
4174 * @rmtoll CR3 DDRE LL_USART_DisableDMADeactOnRxErr
4175 * @param USARTx USART Instance
4176 * @retval None
4178 __STATIC_INLINE void LL_USART_DisableDMADeactOnRxErr(USART_TypeDef *USARTx)
4180 CLEAR_BIT(USARTx->CR3, USART_CR3_DDRE);
4184 * @brief Indicate if DMA Disabling on Reception Error is disabled
4185 * @rmtoll CR3 DDRE LL_USART_IsEnabledDMADeactOnRxErr
4186 * @param USARTx USART Instance
4187 * @retval State of bit (1 or 0).
4189 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMADeactOnRxErr(USART_TypeDef *USARTx)
4191 return ((READ_BIT(USARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE)) ? 1UL : 0UL);
4195 * @brief Get the data register address used for DMA transfer
4196 * @rmtoll RDR RDR LL_USART_DMA_GetRegAddr\n
4197 * @rmtoll TDR TDR LL_USART_DMA_GetRegAddr
4198 * @param USARTx USART Instance
4199 * @param Direction This parameter can be one of the following values:
4200 * @arg @ref LL_USART_DMA_REG_DATA_TRANSMIT
4201 * @arg @ref LL_USART_DMA_REG_DATA_RECEIVE
4202 * @retval Address of data register
4204 __STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(USART_TypeDef *USARTx, uint32_t Direction)
4206 uint32_t data_reg_addr;
4208 if (Direction == LL_USART_DMA_REG_DATA_TRANSMIT)
4210 /* return address of TDR register */
4211 data_reg_addr = (uint32_t) &(USARTx->TDR);
4213 else
4215 /* return address of RDR register */
4216 data_reg_addr = (uint32_t) &(USARTx->RDR);
4219 return data_reg_addr;
4223 * @}
4226 /** @defgroup USART_LL_EF_Data_Management Data_Management
4227 * @{
4231 * @brief Read Receiver Data register (Receive Data value, 8 bits)
4232 * @rmtoll RDR RDR LL_USART_ReceiveData8
4233 * @param USARTx USART Instance
4234 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
4236 __STATIC_INLINE uint8_t LL_USART_ReceiveData8(USART_TypeDef *USARTx)
4238 return (uint8_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR) & 0xFFU);
4242 * @brief Read Receiver Data register (Receive Data value, 9 bits)
4243 * @rmtoll RDR RDR LL_USART_ReceiveData9
4244 * @param USARTx USART Instance
4245 * @retval Value between Min_Data=0x00 and Max_Data=0x1FF
4247 __STATIC_INLINE uint16_t LL_USART_ReceiveData9(USART_TypeDef *USARTx)
4249 return (uint16_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR));
4253 * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits)
4254 * @rmtoll TDR TDR LL_USART_TransmitData8
4255 * @param USARTx USART Instance
4256 * @param Value between Min_Data=0x00 and Max_Data=0xFF
4257 * @retval None
4259 __STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value)
4261 USARTx->TDR = Value;
4265 * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits)
4266 * @rmtoll TDR TDR LL_USART_TransmitData9
4267 * @param USARTx USART Instance
4268 * @param Value between Min_Data=0x00 and Max_Data=0x1FF
4269 * @retval None
4271 __STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value)
4273 USARTx->TDR = (uint16_t)(Value & 0x1FFUL);
4277 * @}
4280 /** @defgroup USART_LL_EF_Execution Execution
4281 * @{
4285 * @brief Request an Automatic Baud Rate measurement on next received data frame
4286 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
4287 * Auto Baud Rate detection feature is supported by the USARTx instance.
4288 * @rmtoll RQR ABRRQ LL_USART_RequestAutoBaudRate
4289 * @param USARTx USART Instance
4290 * @retval None
4292 __STATIC_INLINE void LL_USART_RequestAutoBaudRate(USART_TypeDef *USARTx)
4294 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_ABRRQ);
4298 * @brief Request Break sending
4299 * @rmtoll RQR SBKRQ LL_USART_RequestBreakSending
4300 * @param USARTx USART Instance
4301 * @retval None
4303 __STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx)
4305 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_SBKRQ);
4309 * @brief Put USART in mute mode and set the RWU flag
4310 * @rmtoll RQR MMRQ LL_USART_RequestEnterMuteMode
4311 * @param USARTx USART Instance
4312 * @retval None
4314 __STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx)
4316 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_MMRQ);
4320 * @brief Request a Receive Data and FIFO flush
4321 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4322 * FIFO mode feature is supported by the USARTx instance.
4323 * @note Allows to discard the received data without reading them, and avoid an overrun
4324 * condition.
4325 * @rmtoll RQR RXFRQ LL_USART_RequestRxDataFlush
4326 * @param USARTx USART Instance
4327 * @retval None
4329 __STATIC_INLINE void LL_USART_RequestRxDataFlush(USART_TypeDef *USARTx)
4331 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_RXFRQ);
4335 * @brief Request a Transmit data and FIFO flush
4336 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4337 * FIFO mode feature is supported by the USARTx instance.
4338 * @rmtoll RQR TXFRQ LL_USART_RequestTxDataFlush
4339 * @param USARTx USART Instance
4340 * @retval None
4342 __STATIC_INLINE void LL_USART_RequestTxDataFlush(USART_TypeDef *USARTx)
4344 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_TXFRQ);
4348 * @}
4351 #if defined(USE_FULL_LL_DRIVER)
4352 /** @defgroup USART_LL_EF_Init Initialization and de-initialization functions
4353 * @{
4355 ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx);
4356 ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct);
4357 void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct);
4358 ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
4359 void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
4361 * @}
4363 #endif /* USE_FULL_LL_DRIVER */
4366 * @}
4370 * @}
4373 #endif /* USART1 || USART2 || USART3 || USART6 || UART4 || UART5 || UART7 || UART8 || UART9 || USART10 */
4376 * @}
4379 #ifdef __cplusplus
4381 #endif
4383 #endif /* STM32H7xx_LL_USART_H */
4385 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/