xref: /btstack/port/stm32-l451-miromico-sx1280/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_ll_usart.h (revision 2fd737d36a1de5d778cacc671d4b4d8c4f3fed82)
1 /**
2   ******************************************************************************
3   * @file    stm32l4xx_ll_usart.h
4   * @author  MCD Application Team
5   * @brief   Header file of USART LL module.
6   ******************************************************************************
7   * @attention
8   *
9   * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
10   * All rights reserved.</center></h2>
11   *
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
16   *
17   ******************************************************************************
18   */
19 
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef STM32L4xx_LL_USART_H
22 #define STM32L4xx_LL_USART_H
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32l4xx.h"
30 
31 /** @addtogroup STM32L4xx_LL_Driver
32   * @{
33   */
34 
35 #if defined (USART1) || defined (USART2) || defined (USART3) || defined (UART4) || defined (UART5)
36 
37 /** @defgroup USART_LL USART
38   * @{
39   */
40 
41 /* Private types -------------------------------------------------------------*/
42 /* Private variables ---------------------------------------------------------*/
43 #if defined(USART_PRESC_PRESCALER)
44 /** @defgroup USART_LL_Private_Variables USART Private Variables
45   * @{
46   */
47 /* Array used to get the USART prescaler division decimal values versus @ref USART_LL_EC_PRESCALER values */
48 static const uint32_t USART_PRESCALER_TAB[] =
49 {
50   1UL,
51   2UL,
52   4UL,
53   6UL,
54   8UL,
55   10UL,
56   12UL,
57   16UL,
58   32UL,
59   64UL,
60   128UL,
61   256UL
62 };
63 /**
64   * @}
65   */
66 #endif /* USART_PRESC_PRESCALER */
67 
68 /* Private constants ---------------------------------------------------------*/
69 /* Private macros ------------------------------------------------------------*/
70 #if defined(USE_FULL_LL_DRIVER)
71 /** @defgroup USART_LL_Private_Macros USART Private Macros
72   * @{
73   */
74 /**
75   * @}
76   */
77 #endif /*USE_FULL_LL_DRIVER*/
78 
79 /* Exported types ------------------------------------------------------------*/
80 #if defined(USE_FULL_LL_DRIVER)
81 /** @defgroup USART_LL_ES_INIT USART Exported Init structures
82   * @{
83   */
84 
85 /**
86   * @brief LL USART Init Structure definition
87   */
88 typedef struct
89 {
90 #if defined(USART_PRESC_PRESCALER)
91   uint32_t PrescalerValue;            /*!< Specifies the Prescaler to compute the communication baud rate.
92                                            This parameter can be a value of @ref USART_LL_EC_PRESCALER.
93 
94                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetPrescaler().*/
95 #endif /* USART_PRESC_PRESCALER */
96 
97   uint32_t BaudRate;                  /*!< This field defines expected Usart communication baud rate.
98 
99                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetBaudRate().*/
100 
101   uint32_t DataWidth;                 /*!< Specifies the number of data bits transmitted or received in a frame.
102                                            This parameter can be a value of @ref USART_LL_EC_DATAWIDTH.
103 
104                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetDataWidth().*/
105 
106   uint32_t StopBits;                  /*!< Specifies the number of stop bits transmitted.
107                                            This parameter can be a value of @ref USART_LL_EC_STOPBITS.
108 
109                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetStopBitsLength().*/
110 
111   uint32_t Parity;                    /*!< Specifies the parity mode.
112                                            This parameter can be a value of @ref USART_LL_EC_PARITY.
113 
114                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetParity().*/
115 
116   uint32_t TransferDirection;         /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled.
117                                            This parameter can be a value of @ref USART_LL_EC_DIRECTION.
118 
119                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetTransferDirection().*/
120 
121   uint32_t HardwareFlowControl;       /*!< Specifies whether the hardware flow control mode is enabled or disabled.
122                                            This parameter can be a value of @ref USART_LL_EC_HWCONTROL.
123 
124                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetHWFlowCtrl().*/
125 
126   uint32_t OverSampling;              /*!< Specifies whether USART oversampling mode is 16 or 8.
127                                            This parameter can be a value of @ref USART_LL_EC_OVERSAMPLING.
128 
129                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetOverSampling().*/
130 
131 } LL_USART_InitTypeDef;
132 
133 /**
134   * @brief LL USART Clock Init Structure definition
135   */
136 typedef struct
137 {
138   uint32_t ClockOutput;               /*!< Specifies whether the USART clock is enabled or disabled.
139                                            This parameter can be a value of @ref USART_LL_EC_CLOCK.
140 
141                                            USART HW configuration can be modified afterwards using unitary functions
142                                            @ref LL_USART_EnableSCLKOutput() or @ref LL_USART_DisableSCLKOutput().
143                                            For more details, refer to description of this function. */
144 
145   uint32_t ClockPolarity;             /*!< Specifies the steady state of the serial clock.
146                                            This parameter can be a value of @ref USART_LL_EC_POLARITY.
147 
148                                            USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPolarity().
149                                            For more details, refer to description of this function. */
150 
151   uint32_t ClockPhase;                /*!< Specifies the clock transition on which the bit capture is made.
152                                            This parameter can be a value of @ref USART_LL_EC_PHASE.
153 
154                                            USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPhase().
155                                            For more details, refer to description of this function. */
156 
157   uint32_t LastBitClockPulse;         /*!< Specifies whether the clock pulse corresponding to the last transmitted
158                                            data bit (MSB) has to be output on the SCLK pin in synchronous mode.
159                                            This parameter can be a value of @ref USART_LL_EC_LASTCLKPULSE.
160 
161                                            USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetLastClkPulseOutput().
162                                            For more details, refer to description of this function. */
163 
164 } LL_USART_ClockInitTypeDef;
165 
166 /**
167   * @}
168   */
169 #endif /* USE_FULL_LL_DRIVER */
170 
171 /* Exported constants --------------------------------------------------------*/
172 /** @defgroup USART_LL_Exported_Constants USART Exported Constants
173   * @{
174   */
175 
176 /** @defgroup USART_LL_EC_CLEAR_FLAG Clear Flags Defines
177   * @brief    Flags defines which can be used with LL_USART_WriteReg function
178   * @{
179   */
180 #define LL_USART_ICR_PECF                       USART_ICR_PECF                /*!< Parity error flag */
181 #define LL_USART_ICR_FECF                       USART_ICR_FECF                /*!< Framing error flag */
182 #define LL_USART_ICR_NECF                       USART_ICR_NECF                /*!< Noise error detected flag */
183 #define LL_USART_ICR_ORECF                      USART_ICR_ORECF               /*!< Overrun error flag */
184 #define LL_USART_ICR_IDLECF                     USART_ICR_IDLECF              /*!< Idle line detected flag */
185 #if defined(USART_CR1_FIFOEN)
186 #define LL_USART_ICR_TXFECF                     USART_ICR_TXFECF              /*!< TX FIFO Empty Clear flag */
187 #endif /* USART_CR1_FIFOEN */
188 #define LL_USART_ICR_TCCF                       USART_ICR_TCCF                /*!< Transmission complete flag */
189 #if defined(USART_TCBGT_SUPPORT)
190 #define LL_USART_ICR_TCBGTCF                    USART_ICR_TCBGTCF             /*!< Transmission completed before guard time flag */
191 #endif /* USART_TCBGT_SUPPORT */
192 #define LL_USART_ICR_LBDCF                      USART_ICR_LBDCF               /*!< LIN break detection flag */
193 #define LL_USART_ICR_CTSCF                      USART_ICR_CTSCF               /*!< CTS flag */
194 #define LL_USART_ICR_RTOCF                      USART_ICR_RTOCF               /*!< Receiver timeout flag */
195 #define LL_USART_ICR_EOBCF                      USART_ICR_EOBCF               /*!< End of block flag */
196 #if defined(USART_CR2_SLVEN)
197 #define LL_USART_ICR_UDRCF                      USART_ICR_UDRCF               /*!< SPI Slave Underrun Clear flag */
198 #endif /* USART_CR2_SLVEN */
199 #define LL_USART_ICR_CMCF                       USART_ICR_CMCF                /*!< Character match flag */
200 #define LL_USART_ICR_WUCF                       USART_ICR_WUCF                /*!< Wakeup from Stop mode flag */
201 /**
202   * @}
203   */
204 
205 /** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines
206   * @brief    Flags defines which can be used with LL_USART_ReadReg function
207   * @{
208   */
209 #define LL_USART_ISR_PE                         USART_ISR_PE                  /*!< Parity error flag */
210 #define LL_USART_ISR_FE                         USART_ISR_FE                  /*!< Framing error flag */
211 #define LL_USART_ISR_NE                         USART_ISR_NE                  /*!< Noise detected flag */
212 #define LL_USART_ISR_ORE                        USART_ISR_ORE                 /*!< Overrun error flag */
213 #define LL_USART_ISR_IDLE                       USART_ISR_IDLE                /*!< Idle line detected flag */
214 #if defined(USART_CR1_FIFOEN)
215 #define LL_USART_ISR_RXNE_RXFNE                 USART_ISR_RXNE_RXFNE          /*!< Read data register or RX FIFO not empty flag */
216 #else
217 #define LL_USART_ISR_RXNE                       USART_ISR_RXNE                /*!< Read data register not empty flag */
218 #endif /* USART_CR1_FIFOEN */
219 #define LL_USART_ISR_TC                         USART_ISR_TC                  /*!< Transmission complete flag */
220 #if defined(USART_CR1_FIFOEN)
221 #define LL_USART_ISR_TXE_TXFNF                  USART_ISR_TXE_TXFNF           /*!< Transmit data register empty or TX FIFO Not Full flag*/
222 #else
223 #define LL_USART_ISR_TXE                        USART_ISR_TXE                 /*!< Transmit data register empty flag */
224 #endif /* USART_CR1_FIFOEN */
225 #define LL_USART_ISR_LBDF                       USART_ISR_LBDF                /*!< LIN break detection flag */
226 #define LL_USART_ISR_CTSIF                      USART_ISR_CTSIF               /*!< CTS interrupt flag */
227 #define LL_USART_ISR_CTS                        USART_ISR_CTS                 /*!< CTS flag */
228 #define LL_USART_ISR_RTOF                       USART_ISR_RTOF                /*!< Receiver timeout flag */
229 #define LL_USART_ISR_EOBF                       USART_ISR_EOBF                /*!< End of block flag */
230 #if defined(USART_CR2_SLVEN)
231 #define LL_USART_ISR_UDR                        USART_ISR_UDR                 /*!< SPI Slave underrun error flag */
232 #endif /* USART_CR2_SLVEN */
233 #define LL_USART_ISR_ABRE                       USART_ISR_ABRE                /*!< Auto baud rate error flag */
234 #define LL_USART_ISR_ABRF                       USART_ISR_ABRF                /*!< Auto baud rate flag */
235 #define LL_USART_ISR_BUSY                       USART_ISR_BUSY                /*!< Busy flag */
236 #define LL_USART_ISR_CMF                        USART_ISR_CMF                 /*!< Character match flag */
237 #define LL_USART_ISR_SBKF                       USART_ISR_SBKF                /*!< Send break flag */
238 #define LL_USART_ISR_RWU                        USART_ISR_RWU                 /*!< Receiver wakeup from Mute mode flag */
239 #define LL_USART_ISR_WUF                        USART_ISR_WUF                 /*!< Wakeup from Stop mode flag */
240 #define LL_USART_ISR_TEACK                      USART_ISR_TEACK               /*!< Transmit enable acknowledge flag */
241 #define LL_USART_ISR_REACK                      USART_ISR_REACK               /*!< Receive enable acknowledge flag */
242 #if defined(USART_CR1_FIFOEN)
243 #define LL_USART_ISR_TXFE                       USART_ISR_TXFE                /*!< TX FIFO empty flag */
244 #define LL_USART_ISR_RXFF                       USART_ISR_RXFF                /*!< RX FIFO full flag */
245 #endif /* USART_CR1_FIFOEN */
246 #if defined(USART_TCBGT_SUPPORT)
247 #define LL_USART_ISR_TCBGT                      USART_ISR_TCBGT               /*!< Transmission complete before guard time completion flag */
248 #endif /* USART_TCBGT_SUPPORT */
249 #if defined(USART_CR1_FIFOEN)
250 #define LL_USART_ISR_RXFT                       USART_ISR_RXFT                /*!< RX FIFO threshold flag */
251 #define LL_USART_ISR_TXFT                       USART_ISR_TXFT                /*!< TX FIFO threshold flag */
252 #endif /* USART_CR1_FIFOEN */
253 /**
254   * @}
255   */
256 
257 /** @defgroup USART_LL_EC_IT IT Defines
258   * @brief    IT defines which can be used with LL_USART_ReadReg and  LL_USART_WriteReg functions
259   * @{
260   */
261 #define LL_USART_CR1_IDLEIE                     USART_CR1_IDLEIE              /*!< IDLE interrupt enable */
262 #if defined(USART_CR1_FIFOEN)
263 #define LL_USART_CR1_RXNEIE_RXFNEIE             USART_CR1_RXNEIE_RXFNEIE      /*!< Read data register and RXFIFO not empty interrupt enable */
264 #else
265 #define LL_USART_CR1_RXNEIE                     USART_CR1_RXNEIE              /*!< Read data register not empty interrupt enable */
266 #endif /* USART_CR1_FIFOEN */
267 #define LL_USART_CR1_TCIE                       USART_CR1_TCIE                /*!< Transmission complete interrupt enable */
268 #if defined(USART_CR1_FIFOEN)
269 #define LL_USART_CR1_TXEIE_TXFNFIE              USART_CR1_TXEIE_TXFNFIE       /*!< Transmit data register empty and TX FIFO not full interrupt enable */
270 #else
271 #define LL_USART_CR1_TXEIE                      USART_CR1_TXEIE               /*!< Transmit data register empty interrupt enable */
272 #endif /* USART_CR1_FIFOEN */
273 #define LL_USART_CR1_PEIE                       USART_CR1_PEIE                /*!< Parity error */
274 #define LL_USART_CR1_CMIE                       USART_CR1_CMIE                /*!< Character match interrupt enable */
275 #define LL_USART_CR1_RTOIE                      USART_CR1_RTOIE               /*!< Receiver timeout interrupt enable */
276 #define LL_USART_CR1_EOBIE                      USART_CR1_EOBIE               /*!< End of Block interrupt enable */
277 #if defined(USART_CR1_FIFOEN)
278 #define LL_USART_CR1_TXFEIE                     USART_CR1_TXFEIE              /*!< TX FIFO empty interrupt enable */
279 #define LL_USART_CR1_RXFFIE                     USART_CR1_RXFFIE              /*!< RX FIFO full interrupt enable */
280 #endif /* USART_CR1_FIFOEN */
281 #define LL_USART_CR2_LBDIE                      USART_CR2_LBDIE               /*!< LIN break detection interrupt enable */
282 #define LL_USART_CR3_EIE                        USART_CR3_EIE                 /*!< Error interrupt enable */
283 #define LL_USART_CR3_CTSIE                      USART_CR3_CTSIE               /*!< CTS interrupt enable */
284 #define LL_USART_CR3_WUFIE                      USART_CR3_WUFIE               /*!< Wakeup from Stop mode interrupt enable */
285 #if defined(USART_CR1_FIFOEN)
286 #define LL_USART_CR3_TXFTIE                     USART_CR3_TXFTIE              /*!< TX FIFO threshold interrupt enable */
287 #endif /* USART_CR1_FIFOEN */
288 #if defined(USART_TCBGT_SUPPORT)
289 #define LL_USART_CR3_TCBGTIE                    USART_CR3_TCBGTIE             /*!< Transmission complete before guard time interrupt enable */
290 #endif /* USART_TCBGT_SUPPORT */
291 #if defined(USART_CR1_FIFOEN)
292 #define LL_USART_CR3_RXFTIE                     USART_CR3_RXFTIE              /*!< RX FIFO threshold interrupt enable */
293 #endif /* USART_CR1_FIFOEN */
294 /**
295   * @}
296   */
297 
298 #if defined(USART_CR1_FIFOEN)
299 /** @defgroup USART_LL_EC_FIFOTHRESHOLD FIFO Threshold
300   * @{
301   */
302 #define LL_USART_FIFOTHRESHOLD_1_8              0x00000000U /*!< FIFO reaches 1/8 of its depth */
303 #define LL_USART_FIFOTHRESHOLD_1_4              0x00000001U /*!< FIFO reaches 1/4 of its depth */
304 #define LL_USART_FIFOTHRESHOLD_1_2              0x00000002U /*!< FIFO reaches 1/2 of its depth */
305 #define LL_USART_FIFOTHRESHOLD_3_4              0x00000003U /*!< FIFO reaches 3/4 of its depth */
306 #define LL_USART_FIFOTHRESHOLD_7_8              0x00000004U /*!< FIFO reaches 7/8 of its depth */
307 #define LL_USART_FIFOTHRESHOLD_8_8              0x00000005U /*!< FIFO becomes empty for TX and full for RX */
308 /**
309   * @}
310   */
311 
312 #endif /* USART_CR1_FIFOEN */
313 /** @defgroup USART_LL_EC_DIRECTION Communication Direction
314   * @{
315   */
316 #define LL_USART_DIRECTION_NONE                 0x00000000U                        /*!< Transmitter and Receiver are disabled */
317 #define LL_USART_DIRECTION_RX                   USART_CR1_RE                       /*!< Transmitter is disabled and Receiver is enabled */
318 #define LL_USART_DIRECTION_TX                   USART_CR1_TE                       /*!< Transmitter is enabled and Receiver is disabled */
319 #define LL_USART_DIRECTION_TX_RX                (USART_CR1_TE |USART_CR1_RE)       /*!< Transmitter and Receiver are enabled */
320 /**
321   * @}
322   */
323 
324 /** @defgroup USART_LL_EC_PARITY Parity Control
325   * @{
326   */
327 #define LL_USART_PARITY_NONE                    0x00000000U                          /*!< Parity control disabled */
328 #define LL_USART_PARITY_EVEN                    USART_CR1_PCE                        /*!< Parity control enabled and Even Parity is selected */
329 #define LL_USART_PARITY_ODD                     (USART_CR1_PCE | USART_CR1_PS)       /*!< Parity control enabled and Odd Parity is selected */
330 /**
331   * @}
332   */
333 
334 /** @defgroup USART_LL_EC_WAKEUP Wakeup
335   * @{
336   */
337 #define LL_USART_WAKEUP_IDLELINE                0x00000000U           /*!<  USART wake up from Mute mode on Idle Line */
338 #define LL_USART_WAKEUP_ADDRESSMARK             USART_CR1_WAKE        /*!<  USART wake up from Mute mode on Address Mark */
339 /**
340   * @}
341   */
342 
343 /** @defgroup USART_LL_EC_DATAWIDTH Datawidth
344   * @{
345   */
346 #define LL_USART_DATAWIDTH_7B                   USART_CR1_M1            /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */
347 #define LL_USART_DATAWIDTH_8B                   0x00000000U             /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
348 #define LL_USART_DATAWIDTH_9B                   USART_CR1_M0            /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
349 /**
350   * @}
351   */
352 
353 /** @defgroup USART_LL_EC_OVERSAMPLING Oversampling
354   * @{
355   */
356 #define LL_USART_OVERSAMPLING_16                0x00000000U            /*!< Oversampling by 16 */
357 #define LL_USART_OVERSAMPLING_8                 USART_CR1_OVER8        /*!< Oversampling by 8 */
358 /**
359   * @}
360   */
361 
362 #if defined(USE_FULL_LL_DRIVER)
363 /** @defgroup USART_LL_EC_CLOCK Clock Signal
364   * @{
365   */
366 
367 #define LL_USART_CLOCK_DISABLE                  0x00000000U            /*!< Clock signal not provided */
368 #define LL_USART_CLOCK_ENABLE                   USART_CR2_CLKEN        /*!< Clock signal provided */
369 /**
370   * @}
371   */
372 #endif /*USE_FULL_LL_DRIVER*/
373 
374 /** @defgroup USART_LL_EC_LASTCLKPULSE Last Clock Pulse
375   * @{
376   */
377 #define LL_USART_LASTCLKPULSE_NO_OUTPUT         0x00000000U           /*!< The clock pulse of the last data bit is not output to the SCLK pin */
378 #define LL_USART_LASTCLKPULSE_OUTPUT            USART_CR2_LBCL        /*!< The clock pulse of the last data bit is output to the SCLK pin */
379 /**
380   * @}
381   */
382 
383 /** @defgroup USART_LL_EC_PHASE Clock Phase
384   * @{
385   */
386 #define LL_USART_PHASE_1EDGE                    0x00000000U           /*!< The first clock transition is the first data capture edge */
387 #define LL_USART_PHASE_2EDGE                    USART_CR2_CPHA        /*!< The second clock transition is the first data capture edge */
388 /**
389   * @}
390   */
391 
392 /** @defgroup USART_LL_EC_POLARITY Clock Polarity
393   * @{
394   */
395 #define LL_USART_POLARITY_LOW                   0x00000000U           /*!< Steady low value on SCLK pin outside transmission window*/
396 #define LL_USART_POLARITY_HIGH                  USART_CR2_CPOL        /*!< Steady high value on SCLK pin outside transmission window */
397 /**
398   * @}
399   */
400 
401 #if defined(USART_PRESC_PRESCALER)
402 /** @defgroup USART_LL_EC_PRESCALER Clock Source Prescaler
403   * @{
404   */
405 #define LL_USART_PRESCALER_DIV1                 0x00000000U                                                                   /*!< Input clock not devided   */
406 #define LL_USART_PRESCALER_DIV2                 (USART_PRESC_PRESCALER_0)                                                     /*!< Input clock devided by 2  */
407 #define LL_USART_PRESCALER_DIV4                 (USART_PRESC_PRESCALER_1)                                                     /*!< Input clock devided by 4  */
408 #define LL_USART_PRESCALER_DIV6                 (USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0)                           /*!< Input clock devided by 6  */
409 #define LL_USART_PRESCALER_DIV8                 (USART_PRESC_PRESCALER_2)                                                     /*!< Input clock devided by 8  */
410 #define LL_USART_PRESCALER_DIV10                (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_0)                           /*!< Input clock devided by 10 */
411 #define LL_USART_PRESCALER_DIV12                (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_1)                           /*!< Input clock devided by 12 */
412 #define LL_USART_PRESCALER_DIV16                (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock devided by 16 */
413 #define LL_USART_PRESCALER_DIV32                (USART_PRESC_PRESCALER_3)                                                     /*!< Input clock devided by 32 */
414 #define LL_USART_PRESCALER_DIV64                (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_0)                           /*!< Input clock devided by 64 */
415 #define LL_USART_PRESCALER_DIV128               (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_1)                           /*!< Input clock devided by 128 */
416 #define LL_USART_PRESCALER_DIV256               (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock devided by 256 */
417 /**
418   * @}
419   */
420 
421 #endif /* USART_PRESC_PRESCALER */
422 /** @defgroup USART_LL_EC_STOPBITS Stop Bits
423   * @{
424   */
425 #define LL_USART_STOPBITS_0_5                   USART_CR2_STOP_0                           /*!< 0.5 stop bit */
426 #define LL_USART_STOPBITS_1                     0x00000000U                                /*!< 1 stop bit */
427 #define LL_USART_STOPBITS_1_5                   (USART_CR2_STOP_0 | USART_CR2_STOP_1)      /*!< 1.5 stop bits */
428 #define LL_USART_STOPBITS_2                     USART_CR2_STOP_1                           /*!< 2 stop bits */
429 /**
430   * @}
431   */
432 
433 /** @defgroup USART_LL_EC_TXRX TX RX Pins Swap
434   * @{
435   */
436 #define LL_USART_TXRX_STANDARD                  0x00000000U           /*!< TX/RX pins are used as defined in standard pinout */
437 #define LL_USART_TXRX_SWAPPED                   (USART_CR2_SWAP)      /*!< TX and RX pins functions are swapped.             */
438 /**
439   * @}
440   */
441 
442 /** @defgroup USART_LL_EC_RXPIN_LEVEL RX Pin Active Level Inversion
443   * @{
444   */
445 #define LL_USART_RXPIN_LEVEL_STANDARD           0x00000000U           /*!< RX pin signal works using the standard logic levels */
446 #define LL_USART_RXPIN_LEVEL_INVERTED           (USART_CR2_RXINV)     /*!< RX pin signal values are inverted.                  */
447 /**
448   * @}
449   */
450 
451 /** @defgroup USART_LL_EC_TXPIN_LEVEL TX Pin Active Level Inversion
452   * @{
453   */
454 #define LL_USART_TXPIN_LEVEL_STANDARD           0x00000000U           /*!< TX pin signal works using the standard logic levels */
455 #define LL_USART_TXPIN_LEVEL_INVERTED           (USART_CR2_TXINV)     /*!< TX pin signal values are inverted.                  */
456 /**
457   * @}
458   */
459 
460 /** @defgroup USART_LL_EC_BINARY_LOGIC Binary Data Inversion
461   * @{
462   */
463 #define LL_USART_BINARY_LOGIC_POSITIVE          0x00000000U           /*!< Logical data from the data register are send/received in positive/direct logic. (1=H, 0=L) */
464 #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. */
465 /**
466   * @}
467   */
468 
469 /** @defgroup USART_LL_EC_BITORDER Bit Order
470   * @{
471   */
472 #define LL_USART_BITORDER_LSBFIRST              0x00000000U           /*!< data is transmitted/received with data bit 0 first, following the start bit */
473 #define LL_USART_BITORDER_MSBFIRST              USART_CR2_MSBFIRST    /*!< data is transmitted/received with the MSB first, following the start bit */
474 /**
475   * @}
476   */
477 
478 /** @defgroup USART_LL_EC_AUTOBAUD_DETECT_ON Autobaud Detection
479   * @{
480   */
481 #define LL_USART_AUTOBAUD_DETECT_ON_STARTBIT    0x00000000U                                 /*!< Measurement of the start bit is used to detect the baud rate */
482 #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 */
483 #define LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME    USART_CR2_ABRMODE_1                         /*!< 0x7F frame detection */
484 #define LL_USART_AUTOBAUD_DETECT_ON_55_FRAME    (USART_CR2_ABRMODE_1 | USART_CR2_ABRMODE_0) /*!< 0x55 frame detection */
485 /**
486   * @}
487   */
488 
489 /** @defgroup USART_LL_EC_ADDRESS_DETECT Address Length Detection
490   * @{
491   */
492 #define LL_USART_ADDRESS_DETECT_4B              0x00000000U           /*!< 4-bit address detection method selected */
493 #define LL_USART_ADDRESS_DETECT_7B              USART_CR2_ADDM7       /*!< 7-bit address detection (in 8-bit data mode) method selected */
494 /**
495   * @}
496   */
497 
498 /** @defgroup USART_LL_EC_HWCONTROL Hardware Control
499   * @{
500   */
501 #define LL_USART_HWCONTROL_NONE                 0x00000000U                          /*!< CTS and RTS hardware flow control disabled */
502 #define LL_USART_HWCONTROL_RTS                  USART_CR3_RTSE                       /*!< RTS output enabled, data is only requested when there is space in the receive buffer */
503 #define LL_USART_HWCONTROL_CTS                  USART_CR3_CTSE                       /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */
504 #define LL_USART_HWCONTROL_RTS_CTS              (USART_CR3_RTSE | USART_CR3_CTSE)    /*!< CTS and RTS hardware flow control enabled */
505 /**
506   * @}
507   */
508 
509 /** @defgroup USART_LL_EC_WAKEUP_ON Wakeup Activation
510   * @{
511   */
512 #define LL_USART_WAKEUP_ON_ADDRESS              0x00000000U                             /*!< Wake up active on address match */
513 #define LL_USART_WAKEUP_ON_STARTBIT             USART_CR3_WUS_1                         /*!< Wake up active on Start bit detection */
514 #define LL_USART_WAKEUP_ON_RXNE                 (USART_CR3_WUS_0 | USART_CR3_WUS_1)     /*!< Wake up active on RXNE */
515 /**
516   * @}
517   */
518 
519 /** @defgroup USART_LL_EC_IRDA_POWER IrDA Power
520   * @{
521   */
522 #define LL_USART_IRDA_POWER_NORMAL              0x00000000U           /*!< IrDA normal power mode */
523 #define LL_USART_IRDA_POWER_LOW                 USART_CR3_IRLP        /*!< IrDA low power mode */
524 /**
525   * @}
526   */
527 
528 /** @defgroup USART_LL_EC_LINBREAK_DETECT LIN Break Detection Length
529   * @{
530   */
531 #define LL_USART_LINBREAK_DETECT_10B            0x00000000U           /*!< 10-bit break detection method selected */
532 #define LL_USART_LINBREAK_DETECT_11B            USART_CR2_LBDL        /*!< 11-bit break detection method selected */
533 /**
534   * @}
535   */
536 
537 /** @defgroup USART_LL_EC_DE_POLARITY Driver Enable Polarity
538   * @{
539   */
540 #define LL_USART_DE_POLARITY_HIGH               0x00000000U           /*!< DE signal is active high */
541 #define LL_USART_DE_POLARITY_LOW                USART_CR3_DEP         /*!< DE signal is active low */
542 /**
543   * @}
544   */
545 
546 /** @defgroup USART_LL_EC_DMA_REG_DATA DMA Register Data
547   * @{
548   */
549 #define LL_USART_DMA_REG_DATA_TRANSMIT          0x00000000U          /*!< Get address of data register used for transmission */
550 #define LL_USART_DMA_REG_DATA_RECEIVE           0x00000001U          /*!< Get address of data register used for reception */
551 /**
552   * @}
553   */
554 
555 /**
556   * @}
557   */
558 
559 /* Exported macro ------------------------------------------------------------*/
560 /** @defgroup USART_LL_Exported_Macros USART Exported Macros
561   * @{
562   */
563 
564 /** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros
565   * @{
566   */
567 
568 /**
569   * @brief  Write a value in USART register
570   * @param  __INSTANCE__ USART Instance
571   * @param  __REG__ Register to be written
572   * @param  __VALUE__ Value to be written in the register
573   * @retval None
574   */
575 #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
576 
577 /**
578   * @brief  Read a value in USART register
579   * @param  __INSTANCE__ USART Instance
580   * @param  __REG__ Register to be read
581   * @retval Register value
582   */
583 #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
584 /**
585   * @}
586   */
587 
588 /** @defgroup USART_LL_EM_Exported_Macros_Helper Exported_Macros_Helper
589   * @{
590   */
591 
592 /**
593   * @brief  Compute USARTDIV value according to Peripheral Clock and
594   *         expected Baud Rate in 8 bits sampling mode (32 bits value of USARTDIV is returned)
595   * @param  __PERIPHCLK__ Peripheral Clock frequency used for USART instance
596   @if USART_PRESC_PRESCALER
597   * @param  __PRESCALER__ This parameter can be one of the following values:
598   *         @arg @ref LL_USART_PRESCALER_DIV1
599   *         @arg @ref LL_USART_PRESCALER_DIV2
600   *         @arg @ref LL_USART_PRESCALER_DIV4
601   *         @arg @ref LL_USART_PRESCALER_DIV6
602   *         @arg @ref LL_USART_PRESCALER_DIV8
603   *         @arg @ref LL_USART_PRESCALER_DIV10
604   *         @arg @ref LL_USART_PRESCALER_DIV12
605   *         @arg @ref LL_USART_PRESCALER_DIV16
606   *         @arg @ref LL_USART_PRESCALER_DIV32
607   *         @arg @ref LL_USART_PRESCALER_DIV64
608   *         @arg @ref LL_USART_PRESCALER_DIV128
609   *         @arg @ref LL_USART_PRESCALER_DIV256
610   @endif
611   * @param  __BAUDRATE__ Baud rate value to achieve
612   * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case
613   */
614 #if defined(USART_PRESC_PRESCALER)
615 #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __PRESCALER__, __BAUDRATE__) (((((__PERIPHCLK__)/(USART_PRESCALER_TAB[(__PRESCALER__)]))*2U)\
616                                                                                + ((__BAUDRATE__)/2U))/(__BAUDRATE__))
617 #else
618 #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) ((((__PERIPHCLK__)*2U)\
619                                                                 + ((__BAUDRATE__)/2U))/(__BAUDRATE__))
620 #endif /* USART_PRESC_PRESCALER */
621 
622 /**
623   * @brief  Compute USARTDIV value according to Peripheral Clock and
624   *         expected Baud Rate in 16 bits sampling mode (32 bits value of USARTDIV is returned)
625   * @param  __PERIPHCLK__ Peripheral Clock frequency used for USART instance
626   @if USART_PRESC_PRESCALER
627   * @param  __PRESCALER__ This parameter can be one of the following values:
628   *         @arg @ref LL_USART_PRESCALER_DIV1
629   *         @arg @ref LL_USART_PRESCALER_DIV2
630   *         @arg @ref LL_USART_PRESCALER_DIV4
631   *         @arg @ref LL_USART_PRESCALER_DIV6
632   *         @arg @ref LL_USART_PRESCALER_DIV8
633   *         @arg @ref LL_USART_PRESCALER_DIV10
634   *         @arg @ref LL_USART_PRESCALER_DIV12
635   *         @arg @ref LL_USART_PRESCALER_DIV16
636   *         @arg @ref LL_USART_PRESCALER_DIV32
637   *         @arg @ref LL_USART_PRESCALER_DIV64
638   *         @arg @ref LL_USART_PRESCALER_DIV128
639   *         @arg @ref LL_USART_PRESCALER_DIV256
640   @endif
641   * @param  __BAUDRATE__ Baud rate value to achieve
642   * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case
643   */
644 #if defined(USART_PRESC_PRESCALER)
645 #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __PRESCALER__, __BAUDRATE__) ((((__PERIPHCLK__)/(USART_PRESCALER_TAB[(__PRESCALER__)]))\
646                                                                                 + ((__BAUDRATE__)/2U))/(__BAUDRATE__))
647 #else
648 #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__) + ((__BAUDRATE__)/2U))/(__BAUDRATE__))
649 #endif /* USART_PRESC_PRESCALER */
650 
651 /**
652   * @}
653   */
654 
655 /**
656   * @}
657   */
658 
659 /* Exported functions --------------------------------------------------------*/
660 
661 /** @defgroup USART_LL_Exported_Functions USART Exported Functions
662   * @{
663   */
664 
665 /** @defgroup USART_LL_EF_Configuration Configuration functions
666   * @{
667   */
668 
669 /**
670   * @brief  USART Enable
671   * @rmtoll CR1          UE            LL_USART_Enable
672   * @param  USARTx USART Instance
673   * @retval None
674   */
LL_USART_Enable(USART_TypeDef * USARTx)675 __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx)
676 {
677   SET_BIT(USARTx->CR1, USART_CR1_UE);
678 }
679 
680 /**
681   * @brief  USART Disable (all USART prescalers and outputs are disabled)
682   * @note   When USART is disabled, USART prescalers and outputs are stopped immediately,
683   *         and current operations are discarded. The configuration of the USART is kept, but all the status
684   *         flags, in the USARTx_ISR are set to their default values.
685   * @rmtoll CR1          UE            LL_USART_Disable
686   * @param  USARTx USART Instance
687   * @retval None
688   */
LL_USART_Disable(USART_TypeDef * USARTx)689 __STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx)
690 {
691   CLEAR_BIT(USARTx->CR1, USART_CR1_UE);
692 }
693 
694 /**
695   * @brief  Indicate if USART is enabled
696   * @rmtoll CR1          UE            LL_USART_IsEnabled
697   * @param  USARTx USART Instance
698   * @retval State of bit (1 or 0).
699   */
LL_USART_IsEnabled(USART_TypeDef * USARTx)700 __STATIC_INLINE uint32_t LL_USART_IsEnabled(USART_TypeDef *USARTx)
701 {
702   return ((READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE)) ? 1UL : 0UL);
703 }
704 
705 #if defined(USART_CR1_FIFOEN)
706 /**
707   * @brief  FIFO Mode Enable
708   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
709   *         FIFO mode feature is supported by the USARTx instance.
710   * @rmtoll CR1          FIFOEN        LL_USART_EnableFIFO
711   * @param  USARTx USART Instance
712   * @retval None
713   */
LL_USART_EnableFIFO(USART_TypeDef * USARTx)714 __STATIC_INLINE void LL_USART_EnableFIFO(USART_TypeDef *USARTx)
715 {
716   SET_BIT(USARTx->CR1, USART_CR1_FIFOEN);
717 }
718 
719 /**
720   * @brief  FIFO Mode Disable
721   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
722   *         FIFO mode feature is supported by the USARTx instance.
723   * @rmtoll CR1          FIFOEN        LL_USART_DisableFIFO
724   * @param  USARTx USART Instance
725   * @retval None
726   */
LL_USART_DisableFIFO(USART_TypeDef * USARTx)727 __STATIC_INLINE void LL_USART_DisableFIFO(USART_TypeDef *USARTx)
728 {
729   CLEAR_BIT(USARTx->CR1, USART_CR1_FIFOEN);
730 }
731 
732 /**
733   * @brief  Indicate if FIFO Mode is enabled
734   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
735   *         FIFO mode feature is supported by the USARTx instance.
736   * @rmtoll CR1          FIFOEN        LL_USART_IsEnabledFIFO
737   * @param  USARTx USART Instance
738   * @retval State of bit (1 or 0).
739   */
LL_USART_IsEnabledFIFO(USART_TypeDef * USARTx)740 __STATIC_INLINE uint32_t LL_USART_IsEnabledFIFO(USART_TypeDef *USARTx)
741 {
742   return ((READ_BIT(USARTx->CR1, USART_CR1_FIFOEN) == (USART_CR1_FIFOEN)) ? 1UL : 0UL);
743 }
744 
745 /**
746   * @brief  Configure TX FIFO Threshold
747   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
748   *         FIFO mode feature is supported by the USARTx instance.
749   * @rmtoll CR3          TXFTCFG       LL_USART_SetTXFIFOThreshold
750   * @param  USARTx USART Instance
751   * @param  Threshold This parameter can be one of the following values:
752   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_8
753   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_4
754   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_2
755   *         @arg @ref LL_USART_FIFOTHRESHOLD_3_4
756   *         @arg @ref LL_USART_FIFOTHRESHOLD_7_8
757   *         @arg @ref LL_USART_FIFOTHRESHOLD_8_8
758   * @retval None
759   */
LL_USART_SetTXFIFOThreshold(USART_TypeDef * USARTx,uint32_t Threshold)760 __STATIC_INLINE void LL_USART_SetTXFIFOThreshold(USART_TypeDef *USARTx, uint32_t Threshold)
761 {
762   MODIFY_REG(USARTx->CR3, USART_CR3_TXFTCFG, Threshold << USART_CR3_TXFTCFG_Pos);
763 }
764 
765 /**
766   * @brief  Return TX FIFO Threshold Configuration
767   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
768   *         FIFO mode feature is supported by the USARTx instance.
769   * @rmtoll CR3          TXFTCFG       LL_USART_GetTXFIFOThreshold
770   * @param  USARTx USART Instance
771   * @retval Returned value can be one of the following values:
772   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_8
773   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_4
774   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_2
775   *         @arg @ref LL_USART_FIFOTHRESHOLD_3_4
776   *         @arg @ref LL_USART_FIFOTHRESHOLD_7_8
777   *         @arg @ref LL_USART_FIFOTHRESHOLD_8_8
778   */
LL_USART_GetTXFIFOThreshold(USART_TypeDef * USARTx)779 __STATIC_INLINE uint32_t LL_USART_GetTXFIFOThreshold(USART_TypeDef *USARTx)
780 {
781   return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_TXFTCFG) >> USART_CR3_TXFTCFG_Pos);
782 }
783 
784 /**
785   * @brief  Configure RX FIFO Threshold
786   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
787   *         FIFO mode feature is supported by the USARTx instance.
788   * @rmtoll CR3          RXFTCFG       LL_USART_SetRXFIFOThreshold
789   * @param  USARTx USART Instance
790   * @param  Threshold This parameter can be one of the following values:
791   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_8
792   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_4
793   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_2
794   *         @arg @ref LL_USART_FIFOTHRESHOLD_3_4
795   *         @arg @ref LL_USART_FIFOTHRESHOLD_7_8
796   *         @arg @ref LL_USART_FIFOTHRESHOLD_8_8
797   * @retval None
798   */
LL_USART_SetRXFIFOThreshold(USART_TypeDef * USARTx,uint32_t Threshold)799 __STATIC_INLINE void LL_USART_SetRXFIFOThreshold(USART_TypeDef *USARTx, uint32_t Threshold)
800 {
801   MODIFY_REG(USARTx->CR3, USART_CR3_RXFTCFG, Threshold << USART_CR3_RXFTCFG_Pos);
802 }
803 
804 /**
805   * @brief  Return RX FIFO Threshold Configuration
806   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
807   *         FIFO mode feature is supported by the USARTx instance.
808   * @rmtoll CR3          RXFTCFG       LL_USART_GetRXFIFOThreshold
809   * @param  USARTx USART Instance
810   * @retval Returned value can be one of the following values:
811   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_8
812   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_4
813   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_2
814   *         @arg @ref LL_USART_FIFOTHRESHOLD_3_4
815   *         @arg @ref LL_USART_FIFOTHRESHOLD_7_8
816   *         @arg @ref LL_USART_FIFOTHRESHOLD_8_8
817   */
LL_USART_GetRXFIFOThreshold(USART_TypeDef * USARTx)818 __STATIC_INLINE uint32_t LL_USART_GetRXFIFOThreshold(USART_TypeDef *USARTx)
819 {
820   return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RXFTCFG) >> USART_CR3_RXFTCFG_Pos);
821 }
822 
823 /**
824   * @brief  Configure TX and RX FIFOs Threshold
825   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
826   *         FIFO mode feature is supported by the USARTx instance.
827   * @rmtoll CR3          TXFTCFG       LL_USART_ConfigFIFOsThreshold\n
828   *         CR3          RXFTCFG       LL_USART_ConfigFIFOsThreshold
829   * @param  USARTx USART Instance
830   * @param  TXThreshold This parameter can be one of the following values:
831   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_8
832   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_4
833   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_2
834   *         @arg @ref LL_USART_FIFOTHRESHOLD_3_4
835   *         @arg @ref LL_USART_FIFOTHRESHOLD_7_8
836   *         @arg @ref LL_USART_FIFOTHRESHOLD_8_8
837   * @param  RXThreshold This parameter can be one of the following values:
838   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_8
839   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_4
840   *         @arg @ref LL_USART_FIFOTHRESHOLD_1_2
841   *         @arg @ref LL_USART_FIFOTHRESHOLD_3_4
842   *         @arg @ref LL_USART_FIFOTHRESHOLD_7_8
843   *         @arg @ref LL_USART_FIFOTHRESHOLD_8_8
844   * @retval None
845   */
LL_USART_ConfigFIFOsThreshold(USART_TypeDef * USARTx,uint32_t TXThreshold,uint32_t RXThreshold)846 __STATIC_INLINE void LL_USART_ConfigFIFOsThreshold(USART_TypeDef *USARTx, uint32_t TXThreshold, uint32_t RXThreshold)
847 {
848   MODIFY_REG(USARTx->CR3, USART_CR3_TXFTCFG | USART_CR3_RXFTCFG, (TXThreshold << USART_CR3_TXFTCFG_Pos) | (RXThreshold << USART_CR3_RXFTCFG_Pos));
849 }
850 
851 #endif /* USART_CR1_FIFOEN */
852 /**
853   * @brief  USART enabled in STOP Mode.
854   * @note   When this function is enabled, USART is able to wake up the MCU from Stop mode, provided that
855   *         USART clock selection is HSI or LSE in RCC.
856   * @note   Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
857   *         Wake-up from Stop mode feature is supported by the USARTx instance.
858   * @rmtoll CR1          UESM          LL_USART_EnableInStopMode
859   * @param  USARTx USART Instance
860   * @retval None
861   */
LL_USART_EnableInStopMode(USART_TypeDef * USARTx)862 __STATIC_INLINE void LL_USART_EnableInStopMode(USART_TypeDef *USARTx)
863 {
864   SET_BIT(USARTx->CR1, USART_CR1_UESM);
865 }
866 
867 /**
868   * @brief  USART disabled in STOP Mode.
869   * @note   When this function is disabled, USART is not able to wake up the MCU from Stop mode
870   * @note   Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
871   *         Wake-up from Stop mode feature is supported by the USARTx instance.
872   * @rmtoll CR1          UESM          LL_USART_DisableInStopMode
873   * @param  USARTx USART Instance
874   * @retval None
875   */
LL_USART_DisableInStopMode(USART_TypeDef * USARTx)876 __STATIC_INLINE void LL_USART_DisableInStopMode(USART_TypeDef *USARTx)
877 {
878   CLEAR_BIT(USARTx->CR1, USART_CR1_UESM);
879 }
880 
881 /**
882   * @brief  Indicate if USART is enabled in STOP Mode (able to wake up MCU from Stop mode or not)
883   * @note   Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
884   *         Wake-up from Stop mode feature is supported by the USARTx instance.
885   * @rmtoll CR1          UESM          LL_USART_IsEnabledInStopMode
886   * @param  USARTx USART Instance
887   * @retval State of bit (1 or 0).
888   */
LL_USART_IsEnabledInStopMode(USART_TypeDef * USARTx)889 __STATIC_INLINE uint32_t LL_USART_IsEnabledInStopMode(USART_TypeDef *USARTx)
890 {
891   return ((READ_BIT(USARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM)) ? 1UL : 0UL);
892 }
893 
894 #if defined(USART_CR3_UCESM)
895 /**
896   * @brief  USART Clock enabled in STOP Mode
897   * @note   When this function is called, USART Clock is enabled while in STOP mode
898   * @rmtoll CR3          UCESM         LL_USART_EnableClockInStopMode
899   * @param  USARTx USART Instance
900   * @retval None
901   */
LL_USART_EnableClockInStopMode(USART_TypeDef * USARTx)902 __STATIC_INLINE void LL_USART_EnableClockInStopMode(USART_TypeDef *USARTx)
903 {
904   SET_BIT(USARTx->CR3, USART_CR3_UCESM);
905 }
906 
907 /**
908   * @brief  USART clock disabled in STOP Mode
909   * @note   When this function is called, USART Clock is disabled while in STOP mode
910   * @rmtoll CR3          UCESM         LL_USART_DisableClockInStopMode
911   * @param  USARTx USART Instance
912   * @retval None
913   */
LL_USART_DisableClockInStopMode(USART_TypeDef * USARTx)914 __STATIC_INLINE void LL_USART_DisableClockInStopMode(USART_TypeDef *USARTx)
915 {
916   CLEAR_BIT(USARTx->CR3, USART_CR3_UCESM);
917 }
918 
919 /**
920   * @brief  Indicate if USART clock is enabled in STOP Mode
921   * @rmtoll CR3          UCESM         LL_USART_IsClockEnabledInStopMode
922   * @param  USARTx USART Instance
923   * @retval State of bit (1 or 0).
924   */
LL_USART_IsClockEnabledInStopMode(USART_TypeDef * USARTx)925 __STATIC_INLINE uint32_t LL_USART_IsClockEnabledInStopMode(USART_TypeDef *USARTx)
926 {
927   return (READ_BIT(USARTx->CR3, USART_CR3_UCESM) == (USART_CR3_UCESM));
928 }
929 
930 #endif /* USART_CR3_UCESM */
931 /**
932   * @brief  Receiver Enable (Receiver is enabled and begins searching for a start bit)
933   * @rmtoll CR1          RE            LL_USART_EnableDirectionRx
934   * @param  USARTx USART Instance
935   * @retval None
936   */
LL_USART_EnableDirectionRx(USART_TypeDef * USARTx)937 __STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx)
938 {
939   SET_BIT(USARTx->CR1, USART_CR1_RE);
940 }
941 
942 /**
943   * @brief  Receiver Disable
944   * @rmtoll CR1          RE            LL_USART_DisableDirectionRx
945   * @param  USARTx USART Instance
946   * @retval None
947   */
LL_USART_DisableDirectionRx(USART_TypeDef * USARTx)948 __STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx)
949 {
950   CLEAR_BIT(USARTx->CR1, USART_CR1_RE);
951 }
952 
953 /**
954   * @brief  Transmitter Enable
955   * @rmtoll CR1          TE            LL_USART_EnableDirectionTx
956   * @param  USARTx USART Instance
957   * @retval None
958   */
LL_USART_EnableDirectionTx(USART_TypeDef * USARTx)959 __STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx)
960 {
961   SET_BIT(USARTx->CR1, USART_CR1_TE);
962 }
963 
964 /**
965   * @brief  Transmitter Disable
966   * @rmtoll CR1          TE            LL_USART_DisableDirectionTx
967   * @param  USARTx USART Instance
968   * @retval None
969   */
LL_USART_DisableDirectionTx(USART_TypeDef * USARTx)970 __STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx)
971 {
972   CLEAR_BIT(USARTx->CR1, USART_CR1_TE);
973 }
974 
975 /**
976   * @brief  Configure simultaneously enabled/disabled states
977   *         of Transmitter and Receiver
978   * @rmtoll CR1          RE            LL_USART_SetTransferDirection\n
979   *         CR1          TE            LL_USART_SetTransferDirection
980   * @param  USARTx USART Instance
981   * @param  TransferDirection This parameter can be one of the following values:
982   *         @arg @ref LL_USART_DIRECTION_NONE
983   *         @arg @ref LL_USART_DIRECTION_RX
984   *         @arg @ref LL_USART_DIRECTION_TX
985   *         @arg @ref LL_USART_DIRECTION_TX_RX
986   * @retval None
987   */
LL_USART_SetTransferDirection(USART_TypeDef * USARTx,uint32_t TransferDirection)988 __STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t TransferDirection)
989 {
990   MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection);
991 }
992 
993 /**
994   * @brief  Return enabled/disabled states of Transmitter and Receiver
995   * @rmtoll CR1          RE            LL_USART_GetTransferDirection\n
996   *         CR1          TE            LL_USART_GetTransferDirection
997   * @param  USARTx USART Instance
998   * @retval Returned value can be one of the following values:
999   *         @arg @ref LL_USART_DIRECTION_NONE
1000   *         @arg @ref LL_USART_DIRECTION_RX
1001   *         @arg @ref LL_USART_DIRECTION_TX
1002   *         @arg @ref LL_USART_DIRECTION_TX_RX
1003   */
LL_USART_GetTransferDirection(USART_TypeDef * USARTx)1004 __STATIC_INLINE uint32_t LL_USART_GetTransferDirection(USART_TypeDef *USARTx)
1005 {
1006   return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE));
1007 }
1008 
1009 /**
1010   * @brief  Configure Parity (enabled/disabled and parity mode if enabled).
1011   * @note   This function selects if hardware parity control (generation and detection) is enabled or disabled.
1012   *         When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position
1013   *         (9th or 8th bit depending on data width) and parity is checked on the received data.
1014   * @rmtoll CR1          PS            LL_USART_SetParity\n
1015   *         CR1          PCE           LL_USART_SetParity
1016   * @param  USARTx USART Instance
1017   * @param  Parity This parameter can be one of the following values:
1018   *         @arg @ref LL_USART_PARITY_NONE
1019   *         @arg @ref LL_USART_PARITY_EVEN
1020   *         @arg @ref LL_USART_PARITY_ODD
1021   * @retval None
1022   */
LL_USART_SetParity(USART_TypeDef * USARTx,uint32_t Parity)1023 __STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t Parity)
1024 {
1025   MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity);
1026 }
1027 
1028 /**
1029   * @brief  Return Parity configuration (enabled/disabled and parity mode if enabled)
1030   * @rmtoll CR1          PS            LL_USART_GetParity\n
1031   *         CR1          PCE           LL_USART_GetParity
1032   * @param  USARTx USART Instance
1033   * @retval Returned value can be one of the following values:
1034   *         @arg @ref LL_USART_PARITY_NONE
1035   *         @arg @ref LL_USART_PARITY_EVEN
1036   *         @arg @ref LL_USART_PARITY_ODD
1037   */
LL_USART_GetParity(USART_TypeDef * USARTx)1038 __STATIC_INLINE uint32_t LL_USART_GetParity(USART_TypeDef *USARTx)
1039 {
1040   return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE));
1041 }
1042 
1043 /**
1044   * @brief  Set Receiver Wake Up method from Mute mode.
1045   * @rmtoll CR1          WAKE          LL_USART_SetWakeUpMethod
1046   * @param  USARTx USART Instance
1047   * @param  Method This parameter can be one of the following values:
1048   *         @arg @ref LL_USART_WAKEUP_IDLELINE
1049   *         @arg @ref LL_USART_WAKEUP_ADDRESSMARK
1050   * @retval None
1051   */
LL_USART_SetWakeUpMethod(USART_TypeDef * USARTx,uint32_t Method)1052 __STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method)
1053 {
1054   MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method);
1055 }
1056 
1057 /**
1058   * @brief  Return Receiver Wake Up method from Mute mode
1059   * @rmtoll CR1          WAKE          LL_USART_GetWakeUpMethod
1060   * @param  USARTx USART Instance
1061   * @retval Returned value can be one of the following values:
1062   *         @arg @ref LL_USART_WAKEUP_IDLELINE
1063   *         @arg @ref LL_USART_WAKEUP_ADDRESSMARK
1064   */
LL_USART_GetWakeUpMethod(USART_TypeDef * USARTx)1065 __STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(USART_TypeDef *USARTx)
1066 {
1067   return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE));
1068 }
1069 
1070 /**
1071   * @brief  Set Word length (i.e. nb of data bits, excluding start and stop bits)
1072   * @rmtoll CR1          M0            LL_USART_SetDataWidth\n
1073   *         CR1          M1            LL_USART_SetDataWidth
1074   * @param  USARTx USART Instance
1075   * @param  DataWidth This parameter can be one of the following values:
1076   *         @arg @ref LL_USART_DATAWIDTH_7B
1077   *         @arg @ref LL_USART_DATAWIDTH_8B
1078   *         @arg @ref LL_USART_DATAWIDTH_9B
1079   * @retval None
1080   */
LL_USART_SetDataWidth(USART_TypeDef * USARTx,uint32_t DataWidth)1081 __STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth)
1082 {
1083   MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth);
1084 }
1085 
1086 /**
1087   * @brief  Return Word length (i.e. nb of data bits, excluding start and stop bits)
1088   * @rmtoll CR1          M0            LL_USART_GetDataWidth\n
1089   *         CR1          M1            LL_USART_GetDataWidth
1090   * @param  USARTx USART Instance
1091   * @retval Returned value can be one of the following values:
1092   *         @arg @ref LL_USART_DATAWIDTH_7B
1093   *         @arg @ref LL_USART_DATAWIDTH_8B
1094   *         @arg @ref LL_USART_DATAWIDTH_9B
1095   */
LL_USART_GetDataWidth(USART_TypeDef * USARTx)1096 __STATIC_INLINE uint32_t LL_USART_GetDataWidth(USART_TypeDef *USARTx)
1097 {
1098   return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M));
1099 }
1100 
1101 /**
1102   * @brief  Allow switch between Mute Mode and Active mode
1103   * @rmtoll CR1          MME           LL_USART_EnableMuteMode
1104   * @param  USARTx USART Instance
1105   * @retval None
1106   */
LL_USART_EnableMuteMode(USART_TypeDef * USARTx)1107 __STATIC_INLINE void LL_USART_EnableMuteMode(USART_TypeDef *USARTx)
1108 {
1109   SET_BIT(USARTx->CR1, USART_CR1_MME);
1110 }
1111 
1112 /**
1113   * @brief  Prevent Mute Mode use. Set Receiver in active mode permanently.
1114   * @rmtoll CR1          MME           LL_USART_DisableMuteMode
1115   * @param  USARTx USART Instance
1116   * @retval None
1117   */
LL_USART_DisableMuteMode(USART_TypeDef * USARTx)1118 __STATIC_INLINE void LL_USART_DisableMuteMode(USART_TypeDef *USARTx)
1119 {
1120   CLEAR_BIT(USARTx->CR1, USART_CR1_MME);
1121 }
1122 
1123 /**
1124   * @brief  Indicate if switch between Mute Mode and Active mode is allowed
1125   * @rmtoll CR1          MME           LL_USART_IsEnabledMuteMode
1126   * @param  USARTx USART Instance
1127   * @retval State of bit (1 or 0).
1128   */
LL_USART_IsEnabledMuteMode(USART_TypeDef * USARTx)1129 __STATIC_INLINE uint32_t LL_USART_IsEnabledMuteMode(USART_TypeDef *USARTx)
1130 {
1131   return ((READ_BIT(USARTx->CR1, USART_CR1_MME) == (USART_CR1_MME)) ? 1UL : 0UL);
1132 }
1133 
1134 /**
1135   * @brief  Set Oversampling to 8-bit or 16-bit mode
1136   * @rmtoll CR1          OVER8         LL_USART_SetOverSampling
1137   * @param  USARTx USART Instance
1138   * @param  OverSampling This parameter can be one of the following values:
1139   *         @arg @ref LL_USART_OVERSAMPLING_16
1140   *         @arg @ref LL_USART_OVERSAMPLING_8
1141   * @retval None
1142   */
LL_USART_SetOverSampling(USART_TypeDef * USARTx,uint32_t OverSampling)1143 __STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling)
1144 {
1145   MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling);
1146 }
1147 
1148 /**
1149   * @brief  Return Oversampling mode
1150   * @rmtoll CR1          OVER8         LL_USART_GetOverSampling
1151   * @param  USARTx USART Instance
1152   * @retval Returned value can be one of the following values:
1153   *         @arg @ref LL_USART_OVERSAMPLING_16
1154   *         @arg @ref LL_USART_OVERSAMPLING_8
1155   */
LL_USART_GetOverSampling(USART_TypeDef * USARTx)1156 __STATIC_INLINE uint32_t LL_USART_GetOverSampling(USART_TypeDef *USARTx)
1157 {
1158   return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8));
1159 }
1160 
1161 /**
1162   * @brief  Configure if Clock pulse of the last data bit is output to the SCLK pin or not
1163   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
1164   *         Synchronous mode is supported by the USARTx instance.
1165   * @rmtoll CR2          LBCL          LL_USART_SetLastClkPulseOutput
1166   * @param  USARTx USART Instance
1167   * @param  LastBitClockPulse This parameter can be one of the following values:
1168   *         @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
1169   *         @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
1170   * @retval None
1171   */
LL_USART_SetLastClkPulseOutput(USART_TypeDef * USARTx,uint32_t LastBitClockPulse)1172 __STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LastBitClockPulse)
1173 {
1174   MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LastBitClockPulse);
1175 }
1176 
1177 /**
1178   * @brief  Retrieve Clock pulse of the last data bit output configuration
1179   *         (Last bit Clock pulse output to the SCLK pin or not)
1180   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
1181   *         Synchronous mode is supported by the USARTx instance.
1182   * @rmtoll CR2          LBCL          LL_USART_GetLastClkPulseOutput
1183   * @param  USARTx USART Instance
1184   * @retval Returned value can be one of the following values:
1185   *         @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
1186   *         @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
1187   */
LL_USART_GetLastClkPulseOutput(USART_TypeDef * USARTx)1188 __STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(USART_TypeDef *USARTx)
1189 {
1190   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL));
1191 }
1192 
1193 /**
1194   * @brief  Select the phase of the clock output on the SCLK pin in synchronous mode
1195   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
1196   *         Synchronous mode is supported by the USARTx instance.
1197   * @rmtoll CR2          CPHA          LL_USART_SetClockPhase
1198   * @param  USARTx USART Instance
1199   * @param  ClockPhase This parameter can be one of the following values:
1200   *         @arg @ref LL_USART_PHASE_1EDGE
1201   *         @arg @ref LL_USART_PHASE_2EDGE
1202   * @retval None
1203   */
LL_USART_SetClockPhase(USART_TypeDef * USARTx,uint32_t ClockPhase)1204 __STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t ClockPhase)
1205 {
1206   MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, ClockPhase);
1207 }
1208 
1209 /**
1210   * @brief  Return phase of the clock output on the SCLK pin in synchronous mode
1211   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
1212   *         Synchronous mode is supported by the USARTx instance.
1213   * @rmtoll CR2          CPHA          LL_USART_GetClockPhase
1214   * @param  USARTx USART Instance
1215   * @retval Returned value can be one of the following values:
1216   *         @arg @ref LL_USART_PHASE_1EDGE
1217   *         @arg @ref LL_USART_PHASE_2EDGE
1218   */
LL_USART_GetClockPhase(USART_TypeDef * USARTx)1219 __STATIC_INLINE uint32_t LL_USART_GetClockPhase(USART_TypeDef *USARTx)
1220 {
1221   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA));
1222 }
1223 
1224 /**
1225   * @brief  Select the polarity of the clock output on the SCLK pin in synchronous mode
1226   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
1227   *         Synchronous mode is supported by the USARTx instance.
1228   * @rmtoll CR2          CPOL          LL_USART_SetClockPolarity
1229   * @param  USARTx USART Instance
1230   * @param  ClockPolarity This parameter can be one of the following values:
1231   *         @arg @ref LL_USART_POLARITY_LOW
1232   *         @arg @ref LL_USART_POLARITY_HIGH
1233   * @retval None
1234   */
LL_USART_SetClockPolarity(USART_TypeDef * USARTx,uint32_t ClockPolarity)1235 __STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t ClockPolarity)
1236 {
1237   MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, ClockPolarity);
1238 }
1239 
1240 /**
1241   * @brief  Return polarity of the clock output on the SCLK pin in synchronous mode
1242   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
1243   *         Synchronous mode is supported by the USARTx instance.
1244   * @rmtoll CR2          CPOL          LL_USART_GetClockPolarity
1245   * @param  USARTx USART Instance
1246   * @retval Returned value can be one of the following values:
1247   *         @arg @ref LL_USART_POLARITY_LOW
1248   *         @arg @ref LL_USART_POLARITY_HIGH
1249   */
LL_USART_GetClockPolarity(USART_TypeDef * USARTx)1250 __STATIC_INLINE uint32_t LL_USART_GetClockPolarity(USART_TypeDef *USARTx)
1251 {
1252   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL));
1253 }
1254 
1255 /**
1256   * @brief  Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse)
1257   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
1258   *         Synchronous mode is supported by the USARTx instance.
1259   * @note   Call of this function is equivalent to following function call sequence :
1260   *         - Clock Phase configuration using @ref LL_USART_SetClockPhase() function
1261   *         - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function
1262   *         - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function
1263   * @rmtoll CR2          CPHA          LL_USART_ConfigClock\n
1264   *         CR2          CPOL          LL_USART_ConfigClock\n
1265   *         CR2          LBCL          LL_USART_ConfigClock
1266   * @param  USARTx USART Instance
1267   * @param  Phase This parameter can be one of the following values:
1268   *         @arg @ref LL_USART_PHASE_1EDGE
1269   *         @arg @ref LL_USART_PHASE_2EDGE
1270   * @param  Polarity This parameter can be one of the following values:
1271   *         @arg @ref LL_USART_POLARITY_LOW
1272   *         @arg @ref LL_USART_POLARITY_HIGH
1273   * @param  LBCPOutput This parameter can be one of the following values:
1274   *         @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
1275   *         @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
1276   * @retval None
1277   */
LL_USART_ConfigClock(USART_TypeDef * USARTx,uint32_t Phase,uint32_t Polarity,uint32_t LBCPOutput)1278 __STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput)
1279 {
1280   MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput);
1281 }
1282 
1283 #if defined(USART_PRESC_PRESCALER)
1284 /**
1285   * @brief  Configure Clock source prescaler for baudrate generator and oversampling
1286   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
1287   *         FIFO mode feature is supported by the USARTx instance.
1288   * @rmtoll PRESC        PRESCALER     LL_USART_SetPrescaler
1289   * @param  USARTx USART Instance
1290   * @param  PrescalerValue This parameter can be one of the following values:
1291   *         @arg @ref LL_USART_PRESCALER_DIV1
1292   *         @arg @ref LL_USART_PRESCALER_DIV2
1293   *         @arg @ref LL_USART_PRESCALER_DIV4
1294   *         @arg @ref LL_USART_PRESCALER_DIV6
1295   *         @arg @ref LL_USART_PRESCALER_DIV8
1296   *         @arg @ref LL_USART_PRESCALER_DIV10
1297   *         @arg @ref LL_USART_PRESCALER_DIV12
1298   *         @arg @ref LL_USART_PRESCALER_DIV16
1299   *         @arg @ref LL_USART_PRESCALER_DIV32
1300   *         @arg @ref LL_USART_PRESCALER_DIV64
1301   *         @arg @ref LL_USART_PRESCALER_DIV128
1302   *         @arg @ref LL_USART_PRESCALER_DIV256
1303   * @retval None
1304   */
LL_USART_SetPrescaler(USART_TypeDef * USARTx,uint32_t PrescalerValue)1305 __STATIC_INLINE void LL_USART_SetPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
1306 {
1307   MODIFY_REG(USARTx->PRESC, USART_PRESC_PRESCALER, (uint16_t)PrescalerValue);
1308 }
1309 
1310 /**
1311   * @brief  Retrieve the Clock source prescaler for baudrate generator and oversampling
1312   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
1313   *         FIFO mode feature is supported by the USARTx instance.
1314   * @rmtoll PRESC        PRESCALER     LL_USART_GetPrescaler
1315   * @param  USARTx USART Instance
1316   * @retval Returned value can be one of the following values:
1317   *         @arg @ref LL_USART_PRESCALER_DIV1
1318   *         @arg @ref LL_USART_PRESCALER_DIV2
1319   *         @arg @ref LL_USART_PRESCALER_DIV4
1320   *         @arg @ref LL_USART_PRESCALER_DIV6
1321   *         @arg @ref LL_USART_PRESCALER_DIV8
1322   *         @arg @ref LL_USART_PRESCALER_DIV10
1323   *         @arg @ref LL_USART_PRESCALER_DIV12
1324   *         @arg @ref LL_USART_PRESCALER_DIV16
1325   *         @arg @ref LL_USART_PRESCALER_DIV32
1326   *         @arg @ref LL_USART_PRESCALER_DIV64
1327   *         @arg @ref LL_USART_PRESCALER_DIV128
1328   *         @arg @ref LL_USART_PRESCALER_DIV256
1329   */
LL_USART_GetPrescaler(USART_TypeDef * USARTx)1330 __STATIC_INLINE uint32_t LL_USART_GetPrescaler(USART_TypeDef *USARTx)
1331 {
1332   return (uint32_t)(READ_BIT(USARTx->PRESC, USART_PRESC_PRESCALER));
1333 }
1334 
1335 #endif /* USART_PRESC_PRESCALER */
1336 /**
1337   * @brief  Enable Clock output on SCLK pin
1338   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
1339   *         Synchronous mode is supported by the USARTx instance.
1340   * @rmtoll CR2          CLKEN         LL_USART_EnableSCLKOutput
1341   * @param  USARTx USART Instance
1342   * @retval None
1343   */
LL_USART_EnableSCLKOutput(USART_TypeDef * USARTx)1344 __STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx)
1345 {
1346   SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
1347 }
1348 
1349 /**
1350   * @brief  Disable Clock output on SCLK pin
1351   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
1352   *         Synchronous mode is supported by the USARTx instance.
1353   * @rmtoll CR2          CLKEN         LL_USART_DisableSCLKOutput
1354   * @param  USARTx USART Instance
1355   * @retval None
1356   */
LL_USART_DisableSCLKOutput(USART_TypeDef * USARTx)1357 __STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx)
1358 {
1359   CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN);
1360 }
1361 
1362 /**
1363   * @brief  Indicate if Clock output on SCLK pin is enabled
1364   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
1365   *         Synchronous mode is supported by the USARTx instance.
1366   * @rmtoll CR2          CLKEN         LL_USART_IsEnabledSCLKOutput
1367   * @param  USARTx USART Instance
1368   * @retval State of bit (1 or 0).
1369   */
LL_USART_IsEnabledSCLKOutput(USART_TypeDef * USARTx)1370 __STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(USART_TypeDef *USARTx)
1371 {
1372   return ((READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN)) ? 1UL : 0UL);
1373 }
1374 
1375 /**
1376   * @brief  Set the length of the stop bits
1377   * @rmtoll CR2          STOP          LL_USART_SetStopBitsLength
1378   * @param  USARTx USART Instance
1379   * @param  StopBits This parameter can be one of the following values:
1380   *         @arg @ref LL_USART_STOPBITS_0_5
1381   *         @arg @ref LL_USART_STOPBITS_1
1382   *         @arg @ref LL_USART_STOPBITS_1_5
1383   *         @arg @ref LL_USART_STOPBITS_2
1384   * @retval None
1385   */
LL_USART_SetStopBitsLength(USART_TypeDef * USARTx,uint32_t StopBits)1386 __STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits)
1387 {
1388   MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
1389 }
1390 
1391 /**
1392   * @brief  Retrieve the length of the stop bits
1393   * @rmtoll CR2          STOP          LL_USART_GetStopBitsLength
1394   * @param  USARTx USART Instance
1395   * @retval Returned value can be one of the following values:
1396   *         @arg @ref LL_USART_STOPBITS_0_5
1397   *         @arg @ref LL_USART_STOPBITS_1
1398   *         @arg @ref LL_USART_STOPBITS_1_5
1399   *         @arg @ref LL_USART_STOPBITS_2
1400   */
LL_USART_GetStopBitsLength(USART_TypeDef * USARTx)1401 __STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(USART_TypeDef *USARTx)
1402 {
1403   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP));
1404 }
1405 
1406 /**
1407   * @brief  Configure Character frame format (Datawidth, Parity control, Stop Bits)
1408   * @note   Call of this function is equivalent to following function call sequence :
1409   *         - Data Width configuration using @ref LL_USART_SetDataWidth() function
1410   *         - Parity Control and mode configuration using @ref LL_USART_SetParity() function
1411   *         - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function
1412   * @rmtoll CR1          PS            LL_USART_ConfigCharacter\n
1413   *         CR1          PCE           LL_USART_ConfigCharacter\n
1414   *         CR1          M0            LL_USART_ConfigCharacter\n
1415   *         CR1          M1            LL_USART_ConfigCharacter\n
1416   *         CR2          STOP          LL_USART_ConfigCharacter
1417   * @param  USARTx USART Instance
1418   * @param  DataWidth This parameter can be one of the following values:
1419   *         @arg @ref LL_USART_DATAWIDTH_7B
1420   *         @arg @ref LL_USART_DATAWIDTH_8B
1421   *         @arg @ref LL_USART_DATAWIDTH_9B
1422   * @param  Parity This parameter can be one of the following values:
1423   *         @arg @ref LL_USART_PARITY_NONE
1424   *         @arg @ref LL_USART_PARITY_EVEN
1425   *         @arg @ref LL_USART_PARITY_ODD
1426   * @param  StopBits This parameter can be one of the following values:
1427   *         @arg @ref LL_USART_STOPBITS_0_5
1428   *         @arg @ref LL_USART_STOPBITS_1
1429   *         @arg @ref LL_USART_STOPBITS_1_5
1430   *         @arg @ref LL_USART_STOPBITS_2
1431   * @retval None
1432   */
LL_USART_ConfigCharacter(USART_TypeDef * USARTx,uint32_t DataWidth,uint32_t Parity,uint32_t StopBits)1433 __STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t Parity,
1434                                               uint32_t StopBits)
1435 {
1436   MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth);
1437   MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
1438 }
1439 
1440 /**
1441   * @brief  Configure TX/RX pins swapping setting.
1442   * @rmtoll CR2          SWAP          LL_USART_SetTXRXSwap
1443   * @param  USARTx USART Instance
1444   * @param  SwapConfig This parameter can be one of the following values:
1445   *         @arg @ref LL_USART_TXRX_STANDARD
1446   *         @arg @ref LL_USART_TXRX_SWAPPED
1447   * @retval None
1448   */
LL_USART_SetTXRXSwap(USART_TypeDef * USARTx,uint32_t SwapConfig)1449 __STATIC_INLINE void LL_USART_SetTXRXSwap(USART_TypeDef *USARTx, uint32_t SwapConfig)
1450 {
1451   MODIFY_REG(USARTx->CR2, USART_CR2_SWAP, SwapConfig);
1452 }
1453 
1454 /**
1455   * @brief  Retrieve TX/RX pins swapping configuration.
1456   * @rmtoll CR2          SWAP          LL_USART_GetTXRXSwap
1457   * @param  USARTx USART Instance
1458   * @retval Returned value can be one of the following values:
1459   *         @arg @ref LL_USART_TXRX_STANDARD
1460   *         @arg @ref LL_USART_TXRX_SWAPPED
1461   */
LL_USART_GetTXRXSwap(USART_TypeDef * USARTx)1462 __STATIC_INLINE uint32_t LL_USART_GetTXRXSwap(USART_TypeDef *USARTx)
1463 {
1464   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_SWAP));
1465 }
1466 
1467 /**
1468   * @brief  Configure RX pin active level logic
1469   * @rmtoll CR2          RXINV         LL_USART_SetRXPinLevel
1470   * @param  USARTx USART Instance
1471   * @param  PinInvMethod This parameter can be one of the following values:
1472   *         @arg @ref LL_USART_RXPIN_LEVEL_STANDARD
1473   *         @arg @ref LL_USART_RXPIN_LEVEL_INVERTED
1474   * @retval None
1475   */
LL_USART_SetRXPinLevel(USART_TypeDef * USARTx,uint32_t PinInvMethod)1476 __STATIC_INLINE void LL_USART_SetRXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod)
1477 {
1478   MODIFY_REG(USARTx->CR2, USART_CR2_RXINV, PinInvMethod);
1479 }
1480 
1481 /**
1482   * @brief  Retrieve RX pin active level logic configuration
1483   * @rmtoll CR2          RXINV         LL_USART_GetRXPinLevel
1484   * @param  USARTx USART Instance
1485   * @retval Returned value can be one of the following values:
1486   *         @arg @ref LL_USART_RXPIN_LEVEL_STANDARD
1487   *         @arg @ref LL_USART_RXPIN_LEVEL_INVERTED
1488   */
LL_USART_GetRXPinLevel(USART_TypeDef * USARTx)1489 __STATIC_INLINE uint32_t LL_USART_GetRXPinLevel(USART_TypeDef *USARTx)
1490 {
1491   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_RXINV));
1492 }
1493 
1494 /**
1495   * @brief  Configure TX pin active level logic
1496   * @rmtoll CR2          TXINV         LL_USART_SetTXPinLevel
1497   * @param  USARTx USART Instance
1498   * @param  PinInvMethod This parameter can be one of the following values:
1499   *         @arg @ref LL_USART_TXPIN_LEVEL_STANDARD
1500   *         @arg @ref LL_USART_TXPIN_LEVEL_INVERTED
1501   * @retval None
1502   */
LL_USART_SetTXPinLevel(USART_TypeDef * USARTx,uint32_t PinInvMethod)1503 __STATIC_INLINE void LL_USART_SetTXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod)
1504 {
1505   MODIFY_REG(USARTx->CR2, USART_CR2_TXINV, PinInvMethod);
1506 }
1507 
1508 /**
1509   * @brief  Retrieve TX pin active level logic configuration
1510   * @rmtoll CR2          TXINV         LL_USART_GetTXPinLevel
1511   * @param  USARTx USART Instance
1512   * @retval Returned value can be one of the following values:
1513   *         @arg @ref LL_USART_TXPIN_LEVEL_STANDARD
1514   *         @arg @ref LL_USART_TXPIN_LEVEL_INVERTED
1515   */
LL_USART_GetTXPinLevel(USART_TypeDef * USARTx)1516 __STATIC_INLINE uint32_t LL_USART_GetTXPinLevel(USART_TypeDef *USARTx)
1517 {
1518   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_TXINV));
1519 }
1520 
1521 /**
1522   * @brief  Configure Binary data logic.
1523   * @note   Allow to define how Logical data from the data register are send/received :
1524   *         either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H)
1525   * @rmtoll CR2          DATAINV       LL_USART_SetBinaryDataLogic
1526   * @param  USARTx USART Instance
1527   * @param  DataLogic This parameter can be one of the following values:
1528   *         @arg @ref LL_USART_BINARY_LOGIC_POSITIVE
1529   *         @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE
1530   * @retval None
1531   */
LL_USART_SetBinaryDataLogic(USART_TypeDef * USARTx,uint32_t DataLogic)1532 __STATIC_INLINE void LL_USART_SetBinaryDataLogic(USART_TypeDef *USARTx, uint32_t DataLogic)
1533 {
1534   MODIFY_REG(USARTx->CR2, USART_CR2_DATAINV, DataLogic);
1535 }
1536 
1537 /**
1538   * @brief  Retrieve Binary data configuration
1539   * @rmtoll CR2          DATAINV       LL_USART_GetBinaryDataLogic
1540   * @param  USARTx USART Instance
1541   * @retval Returned value can be one of the following values:
1542   *         @arg @ref LL_USART_BINARY_LOGIC_POSITIVE
1543   *         @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE
1544   */
LL_USART_GetBinaryDataLogic(USART_TypeDef * USARTx)1545 __STATIC_INLINE uint32_t LL_USART_GetBinaryDataLogic(USART_TypeDef *USARTx)
1546 {
1547   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_DATAINV));
1548 }
1549 
1550 /**
1551   * @brief  Configure transfer bit order (either Less or Most Significant Bit First)
1552   * @note   MSB First means data is transmitted/received with the MSB first, following the start bit.
1553   *         LSB First means data is transmitted/received with data bit 0 first, following the start bit.
1554   * @rmtoll CR2          MSBFIRST      LL_USART_SetTransferBitOrder
1555   * @param  USARTx USART Instance
1556   * @param  BitOrder This parameter can be one of the following values:
1557   *         @arg @ref LL_USART_BITORDER_LSBFIRST
1558   *         @arg @ref LL_USART_BITORDER_MSBFIRST
1559   * @retval None
1560   */
LL_USART_SetTransferBitOrder(USART_TypeDef * USARTx,uint32_t BitOrder)1561 __STATIC_INLINE void LL_USART_SetTransferBitOrder(USART_TypeDef *USARTx, uint32_t BitOrder)
1562 {
1563   MODIFY_REG(USARTx->CR2, USART_CR2_MSBFIRST, BitOrder);
1564 }
1565 
1566 /**
1567   * @brief  Return transfer bit order (either Less or Most Significant Bit First)
1568   * @note   MSB First means data is transmitted/received with the MSB first, following the start bit.
1569   *         LSB First means data is transmitted/received with data bit 0 first, following the start bit.
1570   * @rmtoll CR2          MSBFIRST      LL_USART_GetTransferBitOrder
1571   * @param  USARTx USART Instance
1572   * @retval Returned value can be one of the following values:
1573   *         @arg @ref LL_USART_BITORDER_LSBFIRST
1574   *         @arg @ref LL_USART_BITORDER_MSBFIRST
1575   */
LL_USART_GetTransferBitOrder(USART_TypeDef * USARTx)1576 __STATIC_INLINE uint32_t LL_USART_GetTransferBitOrder(USART_TypeDef *USARTx)
1577 {
1578   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_MSBFIRST));
1579 }
1580 
1581 /**
1582   * @brief  Enable Auto Baud-Rate Detection
1583   * @note   Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
1584   *         Auto Baud Rate detection feature is supported by the USARTx instance.
1585   * @rmtoll CR2          ABREN         LL_USART_EnableAutoBaudRate
1586   * @param  USARTx USART Instance
1587   * @retval None
1588   */
LL_USART_EnableAutoBaudRate(USART_TypeDef * USARTx)1589 __STATIC_INLINE void LL_USART_EnableAutoBaudRate(USART_TypeDef *USARTx)
1590 {
1591   SET_BIT(USARTx->CR2, USART_CR2_ABREN);
1592 }
1593 
1594 /**
1595   * @brief  Disable Auto Baud-Rate Detection
1596   * @note   Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
1597   *         Auto Baud Rate detection feature is supported by the USARTx instance.
1598   * @rmtoll CR2          ABREN         LL_USART_DisableAutoBaudRate
1599   * @param  USARTx USART Instance
1600   * @retval None
1601   */
LL_USART_DisableAutoBaudRate(USART_TypeDef * USARTx)1602 __STATIC_INLINE void LL_USART_DisableAutoBaudRate(USART_TypeDef *USARTx)
1603 {
1604   CLEAR_BIT(USARTx->CR2, USART_CR2_ABREN);
1605 }
1606 
1607 /**
1608   * @brief  Indicate if Auto Baud-Rate Detection mechanism is enabled
1609   * @note   Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
1610   *         Auto Baud Rate detection feature is supported by the USARTx instance.
1611   * @rmtoll CR2          ABREN         LL_USART_IsEnabledAutoBaud
1612   * @param  USARTx USART Instance
1613   * @retval State of bit (1 or 0).
1614   */
LL_USART_IsEnabledAutoBaud(USART_TypeDef * USARTx)1615 __STATIC_INLINE uint32_t LL_USART_IsEnabledAutoBaud(USART_TypeDef *USARTx)
1616 {
1617   return ((READ_BIT(USARTx->CR2, USART_CR2_ABREN) == (USART_CR2_ABREN)) ? 1UL : 0UL);
1618 }
1619 
1620 /**
1621   * @brief  Set Auto Baud-Rate mode bits
1622   * @note   Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
1623   *         Auto Baud Rate detection feature is supported by the USARTx instance.
1624   * @rmtoll CR2          ABRMODE       LL_USART_SetAutoBaudRateMode
1625   * @param  USARTx USART Instance
1626   * @param  AutoBaudRateMode This parameter can be one of the following values:
1627   *         @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT
1628   *         @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE
1629   *         @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME
1630   *         @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME
1631   * @retval None
1632   */
LL_USART_SetAutoBaudRateMode(USART_TypeDef * USARTx,uint32_t AutoBaudRateMode)1633 __STATIC_INLINE void LL_USART_SetAutoBaudRateMode(USART_TypeDef *USARTx, uint32_t AutoBaudRateMode)
1634 {
1635   MODIFY_REG(USARTx->CR2, USART_CR2_ABRMODE, AutoBaudRateMode);
1636 }
1637 
1638 /**
1639   * @brief  Return Auto Baud-Rate mode
1640   * @note   Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
1641   *         Auto Baud Rate detection feature is supported by the USARTx instance.
1642   * @rmtoll CR2          ABRMODE       LL_USART_GetAutoBaudRateMode
1643   * @param  USARTx USART Instance
1644   * @retval Returned value can be one of the following values:
1645   *         @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT
1646   *         @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE
1647   *         @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME
1648   *         @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME
1649   */
LL_USART_GetAutoBaudRateMode(USART_TypeDef * USARTx)1650 __STATIC_INLINE uint32_t LL_USART_GetAutoBaudRateMode(USART_TypeDef *USARTx)
1651 {
1652   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ABRMODE));
1653 }
1654 
1655 /**
1656   * @brief  Enable Receiver Timeout
1657   * @rmtoll CR2          RTOEN         LL_USART_EnableRxTimeout
1658   * @param  USARTx USART Instance
1659   * @retval None
1660   */
LL_USART_EnableRxTimeout(USART_TypeDef * USARTx)1661 __STATIC_INLINE void LL_USART_EnableRxTimeout(USART_TypeDef *USARTx)
1662 {
1663   SET_BIT(USARTx->CR2, USART_CR2_RTOEN);
1664 }
1665 
1666 /**
1667   * @brief  Disable Receiver Timeout
1668   * @rmtoll CR2          RTOEN         LL_USART_DisableRxTimeout
1669   * @param  USARTx USART Instance
1670   * @retval None
1671   */
LL_USART_DisableRxTimeout(USART_TypeDef * USARTx)1672 __STATIC_INLINE void LL_USART_DisableRxTimeout(USART_TypeDef *USARTx)
1673 {
1674   CLEAR_BIT(USARTx->CR2, USART_CR2_RTOEN);
1675 }
1676 
1677 /**
1678   * @brief  Indicate if Receiver Timeout feature is enabled
1679   * @rmtoll CR2          RTOEN         LL_USART_IsEnabledRxTimeout
1680   * @param  USARTx USART Instance
1681   * @retval State of bit (1 or 0).
1682   */
LL_USART_IsEnabledRxTimeout(USART_TypeDef * USARTx)1683 __STATIC_INLINE uint32_t LL_USART_IsEnabledRxTimeout(USART_TypeDef *USARTx)
1684 {
1685   return ((READ_BIT(USARTx->CR2, USART_CR2_RTOEN) == (USART_CR2_RTOEN)) ? 1UL : 0UL);
1686 }
1687 
1688 /**
1689   * @brief  Set Address of the USART node.
1690   * @note   This is used in multiprocessor communication during Mute mode or Stop mode,
1691   *         for wake up with address mark detection.
1692   * @note   4bits address node is used when 4-bit Address Detection is selected in ADDM7.
1693   *         (b7-b4 should be set to 0)
1694   *         8bits address node is used when 7-bit Address Detection is selected in ADDM7.
1695   *         (This is used in multiprocessor communication during Mute mode or Stop mode,
1696   *         for wake up with 7-bit address mark detection.
1697   *         The MSB of the character sent by the transmitter should be equal to 1.
1698   *         It may also be used for character detection during normal reception,
1699   *         Mute mode inactive (for example, end of block detection in ModBus protocol).
1700   *         In this case, the whole received character (8-bit) is compared to the ADD[7:0]
1701   *         value and CMF flag is set on match)
1702   * @rmtoll CR2          ADD           LL_USART_ConfigNodeAddress\n
1703   *         CR2          ADDM7         LL_USART_ConfigNodeAddress
1704   * @param  USARTx USART Instance
1705   * @param  AddressLen This parameter can be one of the following values:
1706   *         @arg @ref LL_USART_ADDRESS_DETECT_4B
1707   *         @arg @ref LL_USART_ADDRESS_DETECT_7B
1708   * @param  NodeAddress 4 or 7 bit Address of the USART node.
1709   * @retval None
1710   */
LL_USART_ConfigNodeAddress(USART_TypeDef * USARTx,uint32_t AddressLen,uint32_t NodeAddress)1711 __STATIC_INLINE void LL_USART_ConfigNodeAddress(USART_TypeDef *USARTx, uint32_t AddressLen, uint32_t NodeAddress)
1712 {
1713   MODIFY_REG(USARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7,
1714              (uint32_t)(AddressLen | (NodeAddress << USART_CR2_ADD_Pos)));
1715 }
1716 
1717 /**
1718   * @brief  Return 8 bit Address of the USART node as set in ADD field of CR2.
1719   * @note   If 4-bit Address Detection is selected in ADDM7,
1720   *         only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant)
1721   *         If 7-bit Address Detection is selected in ADDM7,
1722   *         only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant)
1723   * @rmtoll CR2          ADD           LL_USART_GetNodeAddress
1724   * @param  USARTx USART Instance
1725   * @retval Address of the USART node (Value between Min_Data=0 and Max_Data=255)
1726   */
LL_USART_GetNodeAddress(USART_TypeDef * USARTx)1727 __STATIC_INLINE uint32_t LL_USART_GetNodeAddress(USART_TypeDef *USARTx)
1728 {
1729   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD) >> USART_CR2_ADD_Pos);
1730 }
1731 
1732 /**
1733   * @brief  Return Length of Node Address used in Address Detection mode (7-bit or 4-bit)
1734   * @rmtoll CR2          ADDM7         LL_USART_GetNodeAddressLen
1735   * @param  USARTx USART Instance
1736   * @retval Returned value can be one of the following values:
1737   *         @arg @ref LL_USART_ADDRESS_DETECT_4B
1738   *         @arg @ref LL_USART_ADDRESS_DETECT_7B
1739   */
LL_USART_GetNodeAddressLen(USART_TypeDef * USARTx)1740 __STATIC_INLINE uint32_t LL_USART_GetNodeAddressLen(USART_TypeDef *USARTx)
1741 {
1742   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADDM7));
1743 }
1744 
1745 /**
1746   * @brief  Enable RTS HW Flow Control
1747   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
1748   *         Hardware Flow control feature is supported by the USARTx instance.
1749   * @rmtoll CR3          RTSE          LL_USART_EnableRTSHWFlowCtrl
1750   * @param  USARTx USART Instance
1751   * @retval None
1752   */
LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef * USARTx)1753 __STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx)
1754 {
1755   SET_BIT(USARTx->CR3, USART_CR3_RTSE);
1756 }
1757 
1758 /**
1759   * @brief  Disable RTS HW Flow Control
1760   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
1761   *         Hardware Flow control feature is supported by the USARTx instance.
1762   * @rmtoll CR3          RTSE          LL_USART_DisableRTSHWFlowCtrl
1763   * @param  USARTx USART Instance
1764   * @retval None
1765   */
LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef * USARTx)1766 __STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx)
1767 {
1768   CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE);
1769 }
1770 
1771 /**
1772   * @brief  Enable CTS HW Flow Control
1773   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
1774   *         Hardware Flow control feature is supported by the USARTx instance.
1775   * @rmtoll CR3          CTSE          LL_USART_EnableCTSHWFlowCtrl
1776   * @param  USARTx USART Instance
1777   * @retval None
1778   */
LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef * USARTx)1779 __STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx)
1780 {
1781   SET_BIT(USARTx->CR3, USART_CR3_CTSE);
1782 }
1783 
1784 /**
1785   * @brief  Disable CTS HW Flow Control
1786   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
1787   *         Hardware Flow control feature is supported by the USARTx instance.
1788   * @rmtoll CR3          CTSE          LL_USART_DisableCTSHWFlowCtrl
1789   * @param  USARTx USART Instance
1790   * @retval None
1791   */
LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef * USARTx)1792 __STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx)
1793 {
1794   CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE);
1795 }
1796 
1797 /**
1798   * @brief  Configure HW Flow Control mode (both CTS and RTS)
1799   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
1800   *         Hardware Flow control feature is supported by the USARTx instance.
1801   * @rmtoll CR3          RTSE          LL_USART_SetHWFlowCtrl\n
1802   *         CR3          CTSE          LL_USART_SetHWFlowCtrl
1803   * @param  USARTx USART Instance
1804   * @param  HardwareFlowControl This parameter can be one of the following values:
1805   *         @arg @ref LL_USART_HWCONTROL_NONE
1806   *         @arg @ref LL_USART_HWCONTROL_RTS
1807   *         @arg @ref LL_USART_HWCONTROL_CTS
1808   *         @arg @ref LL_USART_HWCONTROL_RTS_CTS
1809   * @retval None
1810   */
LL_USART_SetHWFlowCtrl(USART_TypeDef * USARTx,uint32_t HardwareFlowControl)1811 __STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HardwareFlowControl)
1812 {
1813   MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl);
1814 }
1815 
1816 /**
1817   * @brief  Return HW Flow Control configuration (both CTS and RTS)
1818   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
1819   *         Hardware Flow control feature is supported by the USARTx instance.
1820   * @rmtoll CR3          RTSE          LL_USART_GetHWFlowCtrl\n
1821   *         CR3          CTSE          LL_USART_GetHWFlowCtrl
1822   * @param  USARTx USART Instance
1823   * @retval Returned value can be one of the following values:
1824   *         @arg @ref LL_USART_HWCONTROL_NONE
1825   *         @arg @ref LL_USART_HWCONTROL_RTS
1826   *         @arg @ref LL_USART_HWCONTROL_CTS
1827   *         @arg @ref LL_USART_HWCONTROL_RTS_CTS
1828   */
LL_USART_GetHWFlowCtrl(USART_TypeDef * USARTx)1829 __STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(USART_TypeDef *USARTx)
1830 {
1831   return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE));
1832 }
1833 
1834 /**
1835   * @brief  Enable One bit sampling method
1836   * @rmtoll CR3          ONEBIT        LL_USART_EnableOneBitSamp
1837   * @param  USARTx USART Instance
1838   * @retval None
1839   */
LL_USART_EnableOneBitSamp(USART_TypeDef * USARTx)1840 __STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx)
1841 {
1842   SET_BIT(USARTx->CR3, USART_CR3_ONEBIT);
1843 }
1844 
1845 /**
1846   * @brief  Disable One bit sampling method
1847   * @rmtoll CR3          ONEBIT        LL_USART_DisableOneBitSamp
1848   * @param  USARTx USART Instance
1849   * @retval None
1850   */
LL_USART_DisableOneBitSamp(USART_TypeDef * USARTx)1851 __STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx)
1852 {
1853   CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT);
1854 }
1855 
1856 /**
1857   * @brief  Indicate if One bit sampling method is enabled
1858   * @rmtoll CR3          ONEBIT        LL_USART_IsEnabledOneBitSamp
1859   * @param  USARTx USART Instance
1860   * @retval State of bit (1 or 0).
1861   */
LL_USART_IsEnabledOneBitSamp(USART_TypeDef * USARTx)1862 __STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(USART_TypeDef *USARTx)
1863 {
1864   return ((READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT)) ? 1UL : 0UL);
1865 }
1866 
1867 /**
1868   * @brief  Enable Overrun detection
1869   * @rmtoll CR3          OVRDIS        LL_USART_EnableOverrunDetect
1870   * @param  USARTx USART Instance
1871   * @retval None
1872   */
LL_USART_EnableOverrunDetect(USART_TypeDef * USARTx)1873 __STATIC_INLINE void LL_USART_EnableOverrunDetect(USART_TypeDef *USARTx)
1874 {
1875   CLEAR_BIT(USARTx->CR3, USART_CR3_OVRDIS);
1876 }
1877 
1878 /**
1879   * @brief  Disable Overrun detection
1880   * @rmtoll CR3          OVRDIS        LL_USART_DisableOverrunDetect
1881   * @param  USARTx USART Instance
1882   * @retval None
1883   */
LL_USART_DisableOverrunDetect(USART_TypeDef * USARTx)1884 __STATIC_INLINE void LL_USART_DisableOverrunDetect(USART_TypeDef *USARTx)
1885 {
1886   SET_BIT(USARTx->CR3, USART_CR3_OVRDIS);
1887 }
1888 
1889 /**
1890   * @brief  Indicate if Overrun detection is enabled
1891   * @rmtoll CR3          OVRDIS        LL_USART_IsEnabledOverrunDetect
1892   * @param  USARTx USART Instance
1893   * @retval State of bit (1 or 0).
1894   */
LL_USART_IsEnabledOverrunDetect(USART_TypeDef * USARTx)1895 __STATIC_INLINE uint32_t LL_USART_IsEnabledOverrunDetect(USART_TypeDef *USARTx)
1896 {
1897   return ((READ_BIT(USARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS) ? 1UL : 0UL);
1898 }
1899 
1900 /**
1901   * @brief  Select event type for Wake UP Interrupt Flag (WUS[1:0] bits)
1902   * @note   Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
1903   *         Wake-up from Stop mode feature is supported by the USARTx instance.
1904   * @rmtoll CR3          WUS           LL_USART_SetWKUPType
1905   * @param  USARTx USART Instance
1906   * @param  Type This parameter can be one of the following values:
1907   *         @arg @ref LL_USART_WAKEUP_ON_ADDRESS
1908   *         @arg @ref LL_USART_WAKEUP_ON_STARTBIT
1909   *         @arg @ref LL_USART_WAKEUP_ON_RXNE
1910   * @retval None
1911   */
LL_USART_SetWKUPType(USART_TypeDef * USARTx,uint32_t Type)1912 __STATIC_INLINE void LL_USART_SetWKUPType(USART_TypeDef *USARTx, uint32_t Type)
1913 {
1914   MODIFY_REG(USARTx->CR3, USART_CR3_WUS, Type);
1915 }
1916 
1917 /**
1918   * @brief  Return event type for Wake UP Interrupt Flag (WUS[1:0] bits)
1919   * @note   Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
1920   *         Wake-up from Stop mode feature is supported by the USARTx instance.
1921   * @rmtoll CR3          WUS           LL_USART_GetWKUPType
1922   * @param  USARTx USART Instance
1923   * @retval Returned value can be one of the following values:
1924   *         @arg @ref LL_USART_WAKEUP_ON_ADDRESS
1925   *         @arg @ref LL_USART_WAKEUP_ON_STARTBIT
1926   *         @arg @ref LL_USART_WAKEUP_ON_RXNE
1927   */
LL_USART_GetWKUPType(USART_TypeDef * USARTx)1928 __STATIC_INLINE uint32_t LL_USART_GetWKUPType(USART_TypeDef *USARTx)
1929 {
1930   return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_WUS));
1931 }
1932 
1933 /**
1934   * @brief  Configure USART BRR register for achieving expected Baud Rate value.
1935   * @note   Compute and set USARTDIV value in BRR Register (full BRR content)
1936   *         according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values
1937   * @note   Peripheral clock and Baud rate values provided as function parameters should be valid
1938   *         (Baud rate value != 0)
1939   * @note   In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d.
1940   * @rmtoll BRR          BRR           LL_USART_SetBaudRate
1941   * @param  USARTx USART Instance
1942   * @param  PeriphClk Peripheral Clock
1943   @if USART_PRESC_PRESCALER
1944   * @param  PrescalerValue This parameter can be one of the following values:
1945   *         @arg @ref LL_USART_PRESCALER_DIV1
1946   *         @arg @ref LL_USART_PRESCALER_DIV2
1947   *         @arg @ref LL_USART_PRESCALER_DIV4
1948   *         @arg @ref LL_USART_PRESCALER_DIV6
1949   *         @arg @ref LL_USART_PRESCALER_DIV8
1950   *         @arg @ref LL_USART_PRESCALER_DIV10
1951   *         @arg @ref LL_USART_PRESCALER_DIV12
1952   *         @arg @ref LL_USART_PRESCALER_DIV16
1953   *         @arg @ref LL_USART_PRESCALER_DIV32
1954   *         @arg @ref LL_USART_PRESCALER_DIV64
1955   *         @arg @ref LL_USART_PRESCALER_DIV128
1956   *         @arg @ref LL_USART_PRESCALER_DIV256
1957   @endif
1958   * @param  OverSampling This parameter can be one of the following values:
1959   *         @arg @ref LL_USART_OVERSAMPLING_16
1960   *         @arg @ref LL_USART_OVERSAMPLING_8
1961   * @param  BaudRate Baud Rate
1962   * @retval None
1963   */
1964 #if defined(USART_PRESC_PRESCALER)
LL_USART_SetBaudRate(USART_TypeDef * USARTx,uint32_t PeriphClk,uint32_t PrescalerValue,uint32_t OverSampling,uint32_t BaudRate)1965 __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t PrescalerValue,
1966                                           uint32_t OverSampling,
1967                                           uint32_t BaudRate)
1968 #else
1969 __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling,
1970                                           uint32_t BaudRate)
1971 #endif /* USART_PRESC_PRESCALER */
1972 {
1973   uint32_t usartdiv;
1974   register uint32_t brrtemp;
1975 
1976 #if defined(USART_PRESC_PRESCALER)
1977   if (PrescalerValue > LL_USART_PRESCALER_DIV256)
1978   {
1979     /* Do not overstep the size of USART_PRESCALER_TAB */
1980   }
1981   else if (OverSampling == LL_USART_OVERSAMPLING_8)
1982 #else
1983   if (OverSampling == LL_USART_OVERSAMPLING_8)
1984 #endif /* USART_PRESC_PRESCALER */
1985   {
1986 #if defined(USART_PRESC_PRESCALER)
1987     usartdiv = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, (uint8_t)PrescalerValue, BaudRate));
1988 #else
1989     usartdiv = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, BaudRate));
1990 #endif /* USART_PRESC_PRESCALER */
1991     brrtemp = usartdiv & 0xFFF0U;
1992     brrtemp |= (uint16_t)((usartdiv & (uint16_t)0x000FU) >> 1U);
1993     USARTx->BRR = brrtemp;
1994   }
1995   else
1996   {
1997 #if defined(USART_PRESC_PRESCALER)
1998     USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, (uint8_t)PrescalerValue, BaudRate));
1999 #else
2000     USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate));
2001 #endif /* USART_PRESC_PRESCALER */
2002   }
2003 }
2004 
2005 /**
2006   * @brief  Return current Baud Rate value, according to USARTDIV present in BRR register
2007   *         (full BRR content), and to used Peripheral Clock and Oversampling mode values
2008   * @note   In case of non-initialized or invalid value stored in BRR register, value 0 will be returned.
2009   * @note   In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d.
2010   * @rmtoll BRR          BRR           LL_USART_GetBaudRate
2011   * @param  USARTx USART Instance
2012   * @param  PeriphClk Peripheral Clock
2013   @if USART_PRESC_PRESCALER
2014   * @param  PrescalerValue This parameter can be one of the following values:
2015   *         @arg @ref LL_USART_PRESCALER_DIV1
2016   *         @arg @ref LL_USART_PRESCALER_DIV2
2017   *         @arg @ref LL_USART_PRESCALER_DIV4
2018   *         @arg @ref LL_USART_PRESCALER_DIV6
2019   *         @arg @ref LL_USART_PRESCALER_DIV8
2020   *         @arg @ref LL_USART_PRESCALER_DIV10
2021   *         @arg @ref LL_USART_PRESCALER_DIV12
2022   *         @arg @ref LL_USART_PRESCALER_DIV16
2023   *         @arg @ref LL_USART_PRESCALER_DIV32
2024   *         @arg @ref LL_USART_PRESCALER_DIV64
2025   *         @arg @ref LL_USART_PRESCALER_DIV128
2026   *         @arg @ref LL_USART_PRESCALER_DIV256
2027   @endif
2028   * @param  OverSampling This parameter can be one of the following values:
2029   *         @arg @ref LL_USART_OVERSAMPLING_16
2030   *         @arg @ref LL_USART_OVERSAMPLING_8
2031   * @retval Baud Rate
2032   */
2033 #if defined(USART_PRESC_PRESCALER)
LL_USART_GetBaudRate(USART_TypeDef * USARTx,uint32_t PeriphClk,uint32_t PrescalerValue,uint32_t OverSampling)2034 __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t PrescalerValue,
2035                                               uint32_t OverSampling)
2036 #else
2037 __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling)
2038 #endif /* USART_PRESC_PRESCALER */
2039 {
2040   register uint32_t usartdiv;
2041   register uint32_t brrresult = 0x0U;
2042 #if defined(USART_PRESC_PRESCALER)
2043   register uint32_t periphclkpresc = (uint32_t)(PeriphClk / (USART_PRESCALER_TAB[(uint8_t)PrescalerValue]));
2044 #endif /* USART_PRESC_PRESCALER */
2045 
2046   usartdiv = USARTx->BRR;
2047 
2048   if (usartdiv == 0U)
2049   {
2050     /* Do not perform a division by 0 */
2051   }
2052   else if (OverSampling == LL_USART_OVERSAMPLING_8)
2053   {
2054     usartdiv = (uint16_t)((usartdiv & 0xFFF0U) | ((usartdiv & 0x0007U) << 1U)) ;
2055     if (usartdiv != 0U)
2056     {
2057 #if defined(USART_PRESC_PRESCALER)
2058       brrresult = (periphclkpresc * 2U) / usartdiv;
2059 #else
2060       brrresult = (PeriphClk * 2U) / usartdiv;
2061 #endif /* USART_PRESC_PRESCALER */
2062     }
2063   }
2064   else
2065   {
2066     if ((usartdiv & 0xFFFFU) != 0U)
2067     {
2068 #if defined(USART_PRESC_PRESCALER)
2069       brrresult = periphclkpresc / usartdiv;
2070 #else
2071       brrresult = PeriphClk / usartdiv;
2072 #endif /* USART_PRESC_PRESCALER */
2073     }
2074   }
2075   return (brrresult);
2076 }
2077 
2078 /**
2079   * @brief  Set Receiver Time Out Value (expressed in nb of bits duration)
2080   * @rmtoll RTOR         RTO           LL_USART_SetRxTimeout
2081   * @param  USARTx USART Instance
2082   * @param  Timeout Value between Min_Data=0x00 and Max_Data=0x00FFFFFF
2083   * @retval None
2084   */
LL_USART_SetRxTimeout(USART_TypeDef * USARTx,uint32_t Timeout)2085 __STATIC_INLINE void LL_USART_SetRxTimeout(USART_TypeDef *USARTx, uint32_t Timeout)
2086 {
2087   MODIFY_REG(USARTx->RTOR, USART_RTOR_RTO, Timeout);
2088 }
2089 
2090 /**
2091   * @brief  Get Receiver Time Out Value (expressed in nb of bits duration)
2092   * @rmtoll RTOR         RTO           LL_USART_GetRxTimeout
2093   * @param  USARTx USART Instance
2094   * @retval Value between Min_Data=0x00 and Max_Data=0x00FFFFFF
2095   */
LL_USART_GetRxTimeout(USART_TypeDef * USARTx)2096 __STATIC_INLINE uint32_t LL_USART_GetRxTimeout(USART_TypeDef *USARTx)
2097 {
2098   return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_RTO));
2099 }
2100 
2101 /**
2102   * @brief  Set Block Length value in reception
2103   * @rmtoll RTOR         BLEN          LL_USART_SetBlockLength
2104   * @param  USARTx USART Instance
2105   * @param  BlockLength Value between Min_Data=0x00 and Max_Data=0xFF
2106   * @retval None
2107   */
LL_USART_SetBlockLength(USART_TypeDef * USARTx,uint32_t BlockLength)2108 __STATIC_INLINE void LL_USART_SetBlockLength(USART_TypeDef *USARTx, uint32_t BlockLength)
2109 {
2110   MODIFY_REG(USARTx->RTOR, USART_RTOR_BLEN, BlockLength << USART_RTOR_BLEN_Pos);
2111 }
2112 
2113 /**
2114   * @brief  Get Block Length value in reception
2115   * @rmtoll RTOR         BLEN          LL_USART_GetBlockLength
2116   * @param  USARTx USART Instance
2117   * @retval Value between Min_Data=0x00 and Max_Data=0xFF
2118   */
LL_USART_GetBlockLength(USART_TypeDef * USARTx)2119 __STATIC_INLINE uint32_t LL_USART_GetBlockLength(USART_TypeDef *USARTx)
2120 {
2121   return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_BLEN) >> USART_RTOR_BLEN_Pos);
2122 }
2123 
2124 /**
2125   * @}
2126   */
2127 
2128 /** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature
2129   * @{
2130   */
2131 
2132 /**
2133   * @brief  Enable IrDA mode
2134   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2135   *         IrDA feature is supported by the USARTx instance.
2136   * @rmtoll CR3          IREN          LL_USART_EnableIrda
2137   * @param  USARTx USART Instance
2138   * @retval None
2139   */
LL_USART_EnableIrda(USART_TypeDef * USARTx)2140 __STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx)
2141 {
2142   SET_BIT(USARTx->CR3, USART_CR3_IREN);
2143 }
2144 
2145 /**
2146   * @brief  Disable IrDA mode
2147   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2148   *         IrDA feature is supported by the USARTx instance.
2149   * @rmtoll CR3          IREN          LL_USART_DisableIrda
2150   * @param  USARTx USART Instance
2151   * @retval None
2152   */
LL_USART_DisableIrda(USART_TypeDef * USARTx)2153 __STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx)
2154 {
2155   CLEAR_BIT(USARTx->CR3, USART_CR3_IREN);
2156 }
2157 
2158 /**
2159   * @brief  Indicate if IrDA mode is enabled
2160   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2161   *         IrDA feature is supported by the USARTx instance.
2162   * @rmtoll CR3          IREN          LL_USART_IsEnabledIrda
2163   * @param  USARTx USART Instance
2164   * @retval State of bit (1 or 0).
2165   */
LL_USART_IsEnabledIrda(USART_TypeDef * USARTx)2166 __STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(USART_TypeDef *USARTx)
2167 {
2168   return ((READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN)) ? 1UL : 0UL);
2169 }
2170 
2171 /**
2172   * @brief  Configure IrDA Power Mode (Normal or Low Power)
2173   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2174   *         IrDA feature is supported by the USARTx instance.
2175   * @rmtoll CR3          IRLP          LL_USART_SetIrdaPowerMode
2176   * @param  USARTx USART Instance
2177   * @param  PowerMode This parameter can be one of the following values:
2178   *         @arg @ref LL_USART_IRDA_POWER_NORMAL
2179   *         @arg @ref LL_USART_IRDA_POWER_LOW
2180   * @retval None
2181   */
LL_USART_SetIrdaPowerMode(USART_TypeDef * USARTx,uint32_t PowerMode)2182 __STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode)
2183 {
2184   MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode);
2185 }
2186 
2187 /**
2188   * @brief  Retrieve IrDA Power Mode configuration (Normal or Low Power)
2189   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2190   *         IrDA feature is supported by the USARTx instance.
2191   * @rmtoll CR3          IRLP          LL_USART_GetIrdaPowerMode
2192   * @param  USARTx USART Instance
2193   * @retval Returned value can be one of the following values:
2194   *         @arg @ref LL_USART_IRDA_POWER_NORMAL
2195   *         @arg @ref LL_USART_PHASE_2EDGE
2196   */
LL_USART_GetIrdaPowerMode(USART_TypeDef * USARTx)2197 __STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(USART_TypeDef *USARTx)
2198 {
2199   return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP));
2200 }
2201 
2202 /**
2203   * @brief  Set Irda prescaler value, used for dividing the USART clock source
2204   *         to achieve the Irda Low Power frequency (8 bits value)
2205   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2206   *         IrDA feature is supported by the USARTx instance.
2207   * @rmtoll GTPR         PSC           LL_USART_SetIrdaPrescaler
2208   * @param  USARTx USART Instance
2209   * @param  PrescalerValue Value between Min_Data=0x00 and Max_Data=0xFF
2210   * @retval None
2211   */
LL_USART_SetIrdaPrescaler(USART_TypeDef * USARTx,uint32_t PrescalerValue)2212 __STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
2213 {
2214   MODIFY_REG(USARTx->GTPR, (uint16_t)USART_GTPR_PSC, (uint16_t)PrescalerValue);
2215 }
2216 
2217 /**
2218   * @brief  Return Irda prescaler value, used for dividing the USART clock source
2219   *         to achieve the Irda Low Power frequency (8 bits value)
2220   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2221   *         IrDA feature is supported by the USARTx instance.
2222   * @rmtoll GTPR         PSC           LL_USART_GetIrdaPrescaler
2223   * @param  USARTx USART Instance
2224   * @retval Irda prescaler value (Value between Min_Data=0x00 and Max_Data=0xFF)
2225   */
LL_USART_GetIrdaPrescaler(USART_TypeDef * USARTx)2226 __STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(USART_TypeDef *USARTx)
2227 {
2228   return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
2229 }
2230 
2231 /**
2232   * @}
2233   */
2234 
2235 /** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature
2236   * @{
2237   */
2238 
2239 /**
2240   * @brief  Enable Smartcard NACK transmission
2241   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2242   *         Smartcard feature is supported by the USARTx instance.
2243   * @rmtoll CR3          NACK          LL_USART_EnableSmartcardNACK
2244   * @param  USARTx USART Instance
2245   * @retval None
2246   */
LL_USART_EnableSmartcardNACK(USART_TypeDef * USARTx)2247 __STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx)
2248 {
2249   SET_BIT(USARTx->CR3, USART_CR3_NACK);
2250 }
2251 
2252 /**
2253   * @brief  Disable Smartcard NACK transmission
2254   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2255   *         Smartcard feature is supported by the USARTx instance.
2256   * @rmtoll CR3          NACK          LL_USART_DisableSmartcardNACK
2257   * @param  USARTx USART Instance
2258   * @retval None
2259   */
LL_USART_DisableSmartcardNACK(USART_TypeDef * USARTx)2260 __STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx)
2261 {
2262   CLEAR_BIT(USARTx->CR3, USART_CR3_NACK);
2263 }
2264 
2265 /**
2266   * @brief  Indicate if Smartcard NACK transmission is enabled
2267   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2268   *         Smartcard feature is supported by the USARTx instance.
2269   * @rmtoll CR3          NACK          LL_USART_IsEnabledSmartcardNACK
2270   * @param  USARTx USART Instance
2271   * @retval State of bit (1 or 0).
2272   */
LL_USART_IsEnabledSmartcardNACK(USART_TypeDef * USARTx)2273 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(USART_TypeDef *USARTx)
2274 {
2275   return ((READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK)) ? 1UL : 0UL);
2276 }
2277 
2278 /**
2279   * @brief  Enable Smartcard mode
2280   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2281   *         Smartcard feature is supported by the USARTx instance.
2282   * @rmtoll CR3          SCEN          LL_USART_EnableSmartcard
2283   * @param  USARTx USART Instance
2284   * @retval None
2285   */
LL_USART_EnableSmartcard(USART_TypeDef * USARTx)2286 __STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx)
2287 {
2288   SET_BIT(USARTx->CR3, USART_CR3_SCEN);
2289 }
2290 
2291 /**
2292   * @brief  Disable Smartcard mode
2293   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2294   *         Smartcard feature is supported by the USARTx instance.
2295   * @rmtoll CR3          SCEN          LL_USART_DisableSmartcard
2296   * @param  USARTx USART Instance
2297   * @retval None
2298   */
LL_USART_DisableSmartcard(USART_TypeDef * USARTx)2299 __STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx)
2300 {
2301   CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN);
2302 }
2303 
2304 /**
2305   * @brief  Indicate if Smartcard mode is enabled
2306   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2307   *         Smartcard feature is supported by the USARTx instance.
2308   * @rmtoll CR3          SCEN          LL_USART_IsEnabledSmartcard
2309   * @param  USARTx USART Instance
2310   * @retval State of bit (1 or 0).
2311   */
LL_USART_IsEnabledSmartcard(USART_TypeDef * USARTx)2312 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(USART_TypeDef *USARTx)
2313 {
2314   return ((READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN)) ? 1UL : 0UL);
2315 }
2316 
2317 /**
2318   * @brief  Set Smartcard Auto-Retry Count value (SCARCNT[2:0] bits)
2319   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2320   *         Smartcard feature is supported by the USARTx instance.
2321   * @note   This bit-field specifies the number of retries in transmit and receive, in Smartcard mode.
2322   *         In transmission mode, it specifies the number of automatic retransmission retries, before
2323   *         generating a transmission error (FE bit set).
2324   *         In reception mode, it specifies the number or erroneous reception trials, before generating a
2325   *         reception error (RXNE and PE bits set)
2326   * @rmtoll CR3          SCARCNT       LL_USART_SetSmartcardAutoRetryCount
2327   * @param  USARTx USART Instance
2328   * @param  AutoRetryCount Value between Min_Data=0 and Max_Data=7
2329   * @retval None
2330   */
LL_USART_SetSmartcardAutoRetryCount(USART_TypeDef * USARTx,uint32_t AutoRetryCount)2331 __STATIC_INLINE void LL_USART_SetSmartcardAutoRetryCount(USART_TypeDef *USARTx, uint32_t AutoRetryCount)
2332 {
2333   MODIFY_REG(USARTx->CR3, USART_CR3_SCARCNT, AutoRetryCount << USART_CR3_SCARCNT_Pos);
2334 }
2335 
2336 /**
2337   * @brief  Return Smartcard Auto-Retry Count value (SCARCNT[2:0] bits)
2338   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2339   *         Smartcard feature is supported by the USARTx instance.
2340   * @rmtoll CR3          SCARCNT       LL_USART_GetSmartcardAutoRetryCount
2341   * @param  USARTx USART Instance
2342   * @retval Smartcard Auto-Retry Count value (Value between Min_Data=0 and Max_Data=7)
2343   */
LL_USART_GetSmartcardAutoRetryCount(USART_TypeDef * USARTx)2344 __STATIC_INLINE uint32_t LL_USART_GetSmartcardAutoRetryCount(USART_TypeDef *USARTx)
2345 {
2346   return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_SCARCNT) >> USART_CR3_SCARCNT_Pos);
2347 }
2348 
2349 /**
2350   * @brief  Set Smartcard prescaler value, used for dividing the USART clock
2351   *         source to provide the SMARTCARD Clock (5 bits value)
2352   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2353   *         Smartcard feature is supported by the USARTx instance.
2354   * @rmtoll GTPR         PSC           LL_USART_SetSmartcardPrescaler
2355   * @param  USARTx USART Instance
2356   * @param  PrescalerValue Value between Min_Data=0 and Max_Data=31
2357   * @retval None
2358   */
LL_USART_SetSmartcardPrescaler(USART_TypeDef * USARTx,uint32_t PrescalerValue)2359 __STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
2360 {
2361   MODIFY_REG(USARTx->GTPR, (uint16_t)USART_GTPR_PSC, (uint16_t)PrescalerValue);
2362 }
2363 
2364 /**
2365   * @brief  Return Smartcard prescaler value, used for dividing the USART clock
2366   *         source to provide the SMARTCARD Clock (5 bits value)
2367   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2368   *         Smartcard feature is supported by the USARTx instance.
2369   * @rmtoll GTPR         PSC           LL_USART_GetSmartcardPrescaler
2370   * @param  USARTx USART Instance
2371   * @retval Smartcard prescaler value (Value between Min_Data=0 and Max_Data=31)
2372   */
LL_USART_GetSmartcardPrescaler(USART_TypeDef * USARTx)2373 __STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(USART_TypeDef *USARTx)
2374 {
2375   return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
2376 }
2377 
2378 /**
2379   * @brief  Set Smartcard Guard time value, expressed in nb of baud clocks periods
2380   *         (GT[7:0] bits : Guard time value)
2381   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2382   *         Smartcard feature is supported by the USARTx instance.
2383   * @rmtoll GTPR         GT            LL_USART_SetSmartcardGuardTime
2384   * @param  USARTx USART Instance
2385   * @param  GuardTime Value between Min_Data=0x00 and Max_Data=0xFF
2386   * @retval None
2387   */
LL_USART_SetSmartcardGuardTime(USART_TypeDef * USARTx,uint32_t GuardTime)2388 __STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime)
2389 {
2390   MODIFY_REG(USARTx->GTPR, (uint16_t)USART_GTPR_GT, (uint16_t)(GuardTime << USART_GTPR_GT_Pos));
2391 }
2392 
2393 /**
2394   * @brief  Return Smartcard Guard time value, expressed in nb of baud clocks periods
2395   *         (GT[7:0] bits : Guard time value)
2396   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2397   *         Smartcard feature is supported by the USARTx instance.
2398   * @rmtoll GTPR         GT            LL_USART_GetSmartcardGuardTime
2399   * @param  USARTx USART Instance
2400   * @retval Smartcard Guard time value (Value between Min_Data=0x00 and Max_Data=0xFF)
2401   */
LL_USART_GetSmartcardGuardTime(USART_TypeDef * USARTx)2402 __STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(USART_TypeDef *USARTx)
2403 {
2404   return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_GTPR_GT_Pos);
2405 }
2406 
2407 /**
2408   * @}
2409   */
2410 
2411 /** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature
2412   * @{
2413   */
2414 
2415 /**
2416   * @brief  Enable Single Wire Half-Duplex mode
2417   * @note   Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
2418   *         Half-Duplex mode is supported by the USARTx instance.
2419   * @rmtoll CR3          HDSEL         LL_USART_EnableHalfDuplex
2420   * @param  USARTx USART Instance
2421   * @retval None
2422   */
LL_USART_EnableHalfDuplex(USART_TypeDef * USARTx)2423 __STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx)
2424 {
2425   SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
2426 }
2427 
2428 /**
2429   * @brief  Disable Single Wire Half-Duplex mode
2430   * @note   Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
2431   *         Half-Duplex mode is supported by the USARTx instance.
2432   * @rmtoll CR3          HDSEL         LL_USART_DisableHalfDuplex
2433   * @param  USARTx USART Instance
2434   * @retval None
2435   */
LL_USART_DisableHalfDuplex(USART_TypeDef * USARTx)2436 __STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx)
2437 {
2438   CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL);
2439 }
2440 
2441 /**
2442   * @brief  Indicate if Single Wire Half-Duplex mode is enabled
2443   * @note   Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
2444   *         Half-Duplex mode is supported by the USARTx instance.
2445   * @rmtoll CR3          HDSEL         LL_USART_IsEnabledHalfDuplex
2446   * @param  USARTx USART Instance
2447   * @retval State of bit (1 or 0).
2448   */
LL_USART_IsEnabledHalfDuplex(USART_TypeDef * USARTx)2449 __STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(USART_TypeDef *USARTx)
2450 {
2451   return ((READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL)) ? 1UL : 0UL);
2452 }
2453 
2454 /**
2455   * @}
2456   */
2457 
2458 #if defined(USART_CR2_SLVEN)
2459 /** @defgroup USART_LL_EF_Configuration_SPI_SLAVE Configuration functions related to SPI Slave feature
2460   * @{
2461   */
2462 /**
2463   * @brief  Enable SPI Synchronous Slave mode
2464   * @note   Macro @ref IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
2465   *         SPI Slave mode feature is supported by the USARTx instance.
2466   * @rmtoll CR2          SLVEN         LL_USART_EnableSPISlave
2467   * @param  USARTx USART Instance
2468   * @retval None
2469   */
LL_USART_EnableSPISlave(USART_TypeDef * USARTx)2470 __STATIC_INLINE void LL_USART_EnableSPISlave(USART_TypeDef *USARTx)
2471 {
2472   SET_BIT(USARTx->CR2, USART_CR2_SLVEN);
2473 }
2474 
2475 /**
2476   * @brief  Disable SPI Synchronous Slave mode
2477   * @note   Macro @ref IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
2478   *         SPI Slave mode feature is supported by the USARTx instance.
2479   * @rmtoll CR2          SLVEN         LL_USART_DisableSPISlave
2480   * @param  USARTx USART Instance
2481   * @retval None
2482   */
LL_USART_DisableSPISlave(USART_TypeDef * USARTx)2483 __STATIC_INLINE void LL_USART_DisableSPISlave(USART_TypeDef *USARTx)
2484 {
2485   CLEAR_BIT(USARTx->CR2, USART_CR2_SLVEN);
2486 }
2487 
2488 /**
2489   * @brief  Indicate if  SPI Synchronous Slave mode is enabled
2490   * @note   Macro @ref IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
2491   *         SPI Slave mode feature is supported by the USARTx instance.
2492   * @rmtoll CR2          SLVEN         LL_USART_IsEnabledSPISlave
2493   * @param  USARTx USART Instance
2494   * @retval State of bit (1 or 0).
2495   */
LL_USART_IsEnabledSPISlave(USART_TypeDef * USARTx)2496 __STATIC_INLINE uint32_t LL_USART_IsEnabledSPISlave(USART_TypeDef *USARTx)
2497 {
2498   return ((READ_BIT(USARTx->CR2, USART_CR2_SLVEN) == (USART_CR2_SLVEN)) ? 1UL : 0UL);
2499 }
2500 
2501 /**
2502   * @brief  Enable SPI Slave Selection using NSS input pin
2503   * @note   Macro @ref IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
2504   *         SPI Slave mode feature is supported by the USARTx instance.
2505   * @note   SPI Slave Selection depends on NSS input pin
2506   *         (The slave is selected when NSS is low and deselected when NSS is high).
2507   * @rmtoll CR2          DIS_NSS       LL_USART_EnableSPISlaveSelect
2508   * @param  USARTx USART Instance
2509   * @retval None
2510   */
LL_USART_EnableSPISlaveSelect(USART_TypeDef * USARTx)2511 __STATIC_INLINE void LL_USART_EnableSPISlaveSelect(USART_TypeDef *USARTx)
2512 {
2513   CLEAR_BIT(USARTx->CR2, USART_CR2_DIS_NSS);
2514 }
2515 
2516 /**
2517   * @brief  Disable SPI Slave Selection using NSS input pin
2518   * @note   Macro @ref IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
2519   *         SPI Slave mode feature is supported by the USARTx instance.
2520   * @note   SPI Slave will be always selected and NSS input pin will be ignored.
2521   * @rmtoll CR2          DIS_NSS       LL_USART_DisableSPISlaveSelect
2522   * @param  USARTx USART Instance
2523   * @retval None
2524   */
LL_USART_DisableSPISlaveSelect(USART_TypeDef * USARTx)2525 __STATIC_INLINE void LL_USART_DisableSPISlaveSelect(USART_TypeDef *USARTx)
2526 {
2527   SET_BIT(USARTx->CR2, USART_CR2_DIS_NSS);
2528 }
2529 
2530 /**
2531   * @brief  Indicate if  SPI Slave Selection depends on NSS input pin
2532   * @note   Macro @ref IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
2533   *         SPI Slave mode feature is supported by the USARTx instance.
2534   * @rmtoll CR2          DIS_NSS       LL_USART_IsEnabledSPISlaveSelect
2535   * @param  USARTx USART Instance
2536   * @retval State of bit (1 or 0).
2537   */
LL_USART_IsEnabledSPISlaveSelect(USART_TypeDef * USARTx)2538 __STATIC_INLINE uint32_t LL_USART_IsEnabledSPISlaveSelect(USART_TypeDef *USARTx)
2539 {
2540   return ((READ_BIT(USARTx->CR2, USART_CR2_DIS_NSS) != (USART_CR2_DIS_NSS)) ? 1UL : 0UL);
2541 }
2542 
2543 /**
2544   * @}
2545   */
2546 
2547 #endif /* USART_CR2_SLVEN */
2548 /** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature
2549   * @{
2550   */
2551 
2552 /**
2553   * @brief  Set LIN Break Detection Length
2554   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
2555   *         LIN feature is supported by the USARTx instance.
2556   * @rmtoll CR2          LBDL          LL_USART_SetLINBrkDetectionLen
2557   * @param  USARTx USART Instance
2558   * @param  LINBDLength This parameter can be one of the following values:
2559   *         @arg @ref LL_USART_LINBREAK_DETECT_10B
2560   *         @arg @ref LL_USART_LINBREAK_DETECT_11B
2561   * @retval None
2562   */
LL_USART_SetLINBrkDetectionLen(USART_TypeDef * USARTx,uint32_t LINBDLength)2563 __STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength)
2564 {
2565   MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength);
2566 }
2567 
2568 /**
2569   * @brief  Return LIN Break Detection Length
2570   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
2571   *         LIN feature is supported by the USARTx instance.
2572   * @rmtoll CR2          LBDL          LL_USART_GetLINBrkDetectionLen
2573   * @param  USARTx USART Instance
2574   * @retval Returned value can be one of the following values:
2575   *         @arg @ref LL_USART_LINBREAK_DETECT_10B
2576   *         @arg @ref LL_USART_LINBREAK_DETECT_11B
2577   */
LL_USART_GetLINBrkDetectionLen(USART_TypeDef * USARTx)2578 __STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(USART_TypeDef *USARTx)
2579 {
2580   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL));
2581 }
2582 
2583 /**
2584   * @brief  Enable LIN mode
2585   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
2586   *         LIN feature is supported by the USARTx instance.
2587   * @rmtoll CR2          LINEN         LL_USART_EnableLIN
2588   * @param  USARTx USART Instance
2589   * @retval None
2590   */
LL_USART_EnableLIN(USART_TypeDef * USARTx)2591 __STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx)
2592 {
2593   SET_BIT(USARTx->CR2, USART_CR2_LINEN);
2594 }
2595 
2596 /**
2597   * @brief  Disable LIN mode
2598   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
2599   *         LIN feature is supported by the USARTx instance.
2600   * @rmtoll CR2          LINEN         LL_USART_DisableLIN
2601   * @param  USARTx USART Instance
2602   * @retval None
2603   */
LL_USART_DisableLIN(USART_TypeDef * USARTx)2604 __STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx)
2605 {
2606   CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN);
2607 }
2608 
2609 /**
2610   * @brief  Indicate if LIN mode is enabled
2611   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
2612   *         LIN feature is supported by the USARTx instance.
2613   * @rmtoll CR2          LINEN         LL_USART_IsEnabledLIN
2614   * @param  USARTx USART Instance
2615   * @retval State of bit (1 or 0).
2616   */
LL_USART_IsEnabledLIN(USART_TypeDef * USARTx)2617 __STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(USART_TypeDef *USARTx)
2618 {
2619   return ((READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN)) ? 1UL : 0UL);
2620 }
2621 
2622 /**
2623   * @}
2624   */
2625 
2626 /** @defgroup USART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature
2627   * @{
2628   */
2629 
2630 /**
2631   * @brief  Set DEDT (Driver Enable De-Assertion Time), Time value expressed on 5 bits ([4:0] bits).
2632   * @note   Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2633   *         Driver Enable feature is supported by the USARTx instance.
2634   * @rmtoll CR1          DEDT          LL_USART_SetDEDeassertionTime
2635   * @param  USARTx USART Instance
2636   * @param  Time Value between Min_Data=0 and Max_Data=31
2637   * @retval None
2638   */
LL_USART_SetDEDeassertionTime(USART_TypeDef * USARTx,uint32_t Time)2639 __STATIC_INLINE void LL_USART_SetDEDeassertionTime(USART_TypeDef *USARTx, uint32_t Time)
2640 {
2641   MODIFY_REG(USARTx->CR1, USART_CR1_DEDT, Time << USART_CR1_DEDT_Pos);
2642 }
2643 
2644 /**
2645   * @brief  Return DEDT (Driver Enable De-Assertion Time)
2646   * @note   Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2647   *         Driver Enable feature is supported by the USARTx instance.
2648   * @rmtoll CR1          DEDT          LL_USART_GetDEDeassertionTime
2649   * @param  USARTx USART Instance
2650   * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31
2651   */
LL_USART_GetDEDeassertionTime(USART_TypeDef * USARTx)2652 __STATIC_INLINE uint32_t LL_USART_GetDEDeassertionTime(USART_TypeDef *USARTx)
2653 {
2654   return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEDT) >> USART_CR1_DEDT_Pos);
2655 }
2656 
2657 /**
2658   * @brief  Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits).
2659   * @note   Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2660   *         Driver Enable feature is supported by the USARTx instance.
2661   * @rmtoll CR1          DEAT          LL_USART_SetDEAssertionTime
2662   * @param  USARTx USART Instance
2663   * @param  Time Value between Min_Data=0 and Max_Data=31
2664   * @retval None
2665   */
LL_USART_SetDEAssertionTime(USART_TypeDef * USARTx,uint32_t Time)2666 __STATIC_INLINE void LL_USART_SetDEAssertionTime(USART_TypeDef *USARTx, uint32_t Time)
2667 {
2668   MODIFY_REG(USARTx->CR1, USART_CR1_DEAT, Time << USART_CR1_DEAT_Pos);
2669 }
2670 
2671 /**
2672   * @brief  Return DEAT (Driver Enable Assertion Time)
2673   * @note   Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2674   *         Driver Enable feature is supported by the USARTx instance.
2675   * @rmtoll CR1          DEAT          LL_USART_GetDEAssertionTime
2676   * @param  USARTx USART Instance
2677   * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31
2678   */
LL_USART_GetDEAssertionTime(USART_TypeDef * USARTx)2679 __STATIC_INLINE uint32_t LL_USART_GetDEAssertionTime(USART_TypeDef *USARTx)
2680 {
2681   return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEAT) >> USART_CR1_DEAT_Pos);
2682 }
2683 
2684 /**
2685   * @brief  Enable Driver Enable (DE) Mode
2686   * @note   Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2687   *         Driver Enable feature is supported by the USARTx instance.
2688   * @rmtoll CR3          DEM           LL_USART_EnableDEMode
2689   * @param  USARTx USART Instance
2690   * @retval None
2691   */
LL_USART_EnableDEMode(USART_TypeDef * USARTx)2692 __STATIC_INLINE void LL_USART_EnableDEMode(USART_TypeDef *USARTx)
2693 {
2694   SET_BIT(USARTx->CR3, USART_CR3_DEM);
2695 }
2696 
2697 /**
2698   * @brief  Disable Driver Enable (DE) Mode
2699   * @note   Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2700   *         Driver Enable feature is supported by the USARTx instance.
2701   * @rmtoll CR3          DEM           LL_USART_DisableDEMode
2702   * @param  USARTx USART Instance
2703   * @retval None
2704   */
LL_USART_DisableDEMode(USART_TypeDef * USARTx)2705 __STATIC_INLINE void LL_USART_DisableDEMode(USART_TypeDef *USARTx)
2706 {
2707   CLEAR_BIT(USARTx->CR3, USART_CR3_DEM);
2708 }
2709 
2710 /**
2711   * @brief  Indicate if Driver Enable (DE) Mode is enabled
2712   * @note   Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2713   *         Driver Enable feature is supported by the USARTx instance.
2714   * @rmtoll CR3          DEM           LL_USART_IsEnabledDEMode
2715   * @param  USARTx USART Instance
2716   * @retval State of bit (1 or 0).
2717   */
LL_USART_IsEnabledDEMode(USART_TypeDef * USARTx)2718 __STATIC_INLINE uint32_t LL_USART_IsEnabledDEMode(USART_TypeDef *USARTx)
2719 {
2720   return ((READ_BIT(USARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM)) ? 1UL : 0UL);
2721 }
2722 
2723 /**
2724   * @brief  Select Driver Enable Polarity
2725   * @note   Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2726   *         Driver Enable feature is supported by the USARTx instance.
2727   * @rmtoll CR3          DEP           LL_USART_SetDESignalPolarity
2728   * @param  USARTx USART Instance
2729   * @param  Polarity This parameter can be one of the following values:
2730   *         @arg @ref LL_USART_DE_POLARITY_HIGH
2731   *         @arg @ref LL_USART_DE_POLARITY_LOW
2732   * @retval None
2733   */
LL_USART_SetDESignalPolarity(USART_TypeDef * USARTx,uint32_t Polarity)2734 __STATIC_INLINE void LL_USART_SetDESignalPolarity(USART_TypeDef *USARTx, uint32_t Polarity)
2735 {
2736   MODIFY_REG(USARTx->CR3, USART_CR3_DEP, Polarity);
2737 }
2738 
2739 /**
2740   * @brief  Return Driver Enable Polarity
2741   * @note   Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
2742   *         Driver Enable feature is supported by the USARTx instance.
2743   * @rmtoll CR3          DEP           LL_USART_GetDESignalPolarity
2744   * @param  USARTx USART Instance
2745   * @retval Returned value can be one of the following values:
2746   *         @arg @ref LL_USART_DE_POLARITY_HIGH
2747   *         @arg @ref LL_USART_DE_POLARITY_LOW
2748   */
LL_USART_GetDESignalPolarity(USART_TypeDef * USARTx)2749 __STATIC_INLINE uint32_t LL_USART_GetDESignalPolarity(USART_TypeDef *USARTx)
2750 {
2751   return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_DEP));
2752 }
2753 
2754 /**
2755   * @}
2756   */
2757 
2758 /** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services
2759   * @{
2760   */
2761 
2762 /**
2763   * @brief  Perform basic configuration of USART for enabling use in Asynchronous Mode (UART)
2764   * @note   In UART mode, the following bits must be kept cleared:
2765   *           - LINEN bit in the USART_CR2 register,
2766   *           - CLKEN bit in the USART_CR2 register,
2767   *           - SCEN bit in the USART_CR3 register,
2768   *           - IREN bit in the USART_CR3 register,
2769   *           - HDSEL bit in the USART_CR3 register.
2770   * @note   Call of this function is equivalent to following function call sequence :
2771   *         - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
2772   *         - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
2773   *         - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
2774   *         - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
2775   *         - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
2776   * @note   Other remaining configurations items related to Asynchronous Mode
2777   *         (as Baud Rate, Word length, Parity, ...) should be set using
2778   *         dedicated functions
2779   * @rmtoll CR2          LINEN         LL_USART_ConfigAsyncMode\n
2780   *         CR2          CLKEN         LL_USART_ConfigAsyncMode\n
2781   *         CR3          SCEN          LL_USART_ConfigAsyncMode\n
2782   *         CR3          IREN          LL_USART_ConfigAsyncMode\n
2783   *         CR3          HDSEL         LL_USART_ConfigAsyncMode
2784   * @param  USARTx USART Instance
2785   * @retval None
2786   */
LL_USART_ConfigAsyncMode(USART_TypeDef * USARTx)2787 __STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx)
2788 {
2789   /* In Asynchronous mode, the following bits must be kept cleared:
2790   - LINEN, CLKEN bits in the USART_CR2 register,
2791   - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/
2792   CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
2793   CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
2794 }
2795 
2796 /**
2797   * @brief  Perform basic configuration of USART for enabling use in Synchronous Mode
2798   * @note   In Synchronous mode, the following bits must be kept cleared:
2799   *           - LINEN bit in the USART_CR2 register,
2800   *           - SCEN bit in the USART_CR3 register,
2801   *           - IREN bit in the USART_CR3 register,
2802   *           - HDSEL bit in the USART_CR3 register.
2803   *         This function also sets the USART in Synchronous mode.
2804   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
2805   *         Synchronous mode is supported by the USARTx instance.
2806   * @note   Call of this function is equivalent to following function call sequence :
2807   *         - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
2808   *         - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
2809   *         - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
2810   *         - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
2811   *         - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
2812   * @note   Other remaining configurations items related to Synchronous Mode
2813   *         (as Baud Rate, Word length, Parity, Clock Polarity, ...) should be set using
2814   *         dedicated functions
2815   * @rmtoll CR2          LINEN         LL_USART_ConfigSyncMode\n
2816   *         CR2          CLKEN         LL_USART_ConfigSyncMode\n
2817   *         CR3          SCEN          LL_USART_ConfigSyncMode\n
2818   *         CR3          IREN          LL_USART_ConfigSyncMode\n
2819   *         CR3          HDSEL         LL_USART_ConfigSyncMode
2820   * @param  USARTx USART Instance
2821   * @retval None
2822   */
LL_USART_ConfigSyncMode(USART_TypeDef * USARTx)2823 __STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx)
2824 {
2825   /* In Synchronous mode, the following bits must be kept cleared:
2826   - LINEN bit in the USART_CR2 register,
2827   - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/
2828   CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
2829   CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
2830   /* set the UART/USART in Synchronous mode */
2831   SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
2832 }
2833 
2834 /**
2835   * @brief  Perform basic configuration of USART for enabling use in LIN Mode
2836   * @note   In LIN mode, the following bits must be kept cleared:
2837   *           - STOP and CLKEN bits in the USART_CR2 register,
2838   *           - SCEN bit in the USART_CR3 register,
2839   *           - IREN bit in the USART_CR3 register,
2840   *           - HDSEL bit in the USART_CR3 register.
2841   *         This function also set the UART/USART in LIN mode.
2842   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
2843   *         LIN feature is supported by the USARTx instance.
2844   * @note   Call of this function is equivalent to following function call sequence :
2845   *         - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
2846   *         - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
2847   *         - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
2848   *         - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
2849   *         - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
2850   *         - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function
2851   * @note   Other remaining configurations items related to LIN Mode
2852   *         (as Baud Rate, Word length, LIN Break Detection Length, ...) should be set using
2853   *         dedicated functions
2854   * @rmtoll CR2          CLKEN         LL_USART_ConfigLINMode\n
2855   *         CR2          STOP          LL_USART_ConfigLINMode\n
2856   *         CR2          LINEN         LL_USART_ConfigLINMode\n
2857   *         CR3          IREN          LL_USART_ConfigLINMode\n
2858   *         CR3          SCEN          LL_USART_ConfigLINMode\n
2859   *         CR3          HDSEL         LL_USART_ConfigLINMode
2860   * @param  USARTx USART Instance
2861   * @retval None
2862   */
LL_USART_ConfigLINMode(USART_TypeDef * USARTx)2863 __STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx)
2864 {
2865   /* In LIN mode, the following bits must be kept cleared:
2866   - STOP and CLKEN bits in the USART_CR2 register,
2867   - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/
2868   CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP));
2869   CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL));
2870   /* Set the UART/USART in LIN mode */
2871   SET_BIT(USARTx->CR2, USART_CR2_LINEN);
2872 }
2873 
2874 /**
2875   * @brief  Perform basic configuration of USART for enabling use in Half Duplex Mode
2876   * @note   In Half Duplex mode, the following bits must be kept cleared:
2877   *           - LINEN bit in the USART_CR2 register,
2878   *           - CLKEN bit in the USART_CR2 register,
2879   *           - SCEN bit in the USART_CR3 register,
2880   *           - IREN bit in the USART_CR3 register,
2881   *         This function also sets the UART/USART in Half Duplex mode.
2882   * @note   Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
2883   *         Half-Duplex mode is supported by the USARTx instance.
2884   * @note   Call of this function is equivalent to following function call sequence :
2885   *         - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
2886   *         - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
2887   *         - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
2888   *         - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
2889   *         - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function
2890   * @note   Other remaining configurations items related to Half Duplex Mode
2891   *         (as Baud Rate, Word length, Parity, ...) should be set using
2892   *         dedicated functions
2893   * @rmtoll CR2          LINEN         LL_USART_ConfigHalfDuplexMode\n
2894   *         CR2          CLKEN         LL_USART_ConfigHalfDuplexMode\n
2895   *         CR3          HDSEL         LL_USART_ConfigHalfDuplexMode\n
2896   *         CR3          SCEN          LL_USART_ConfigHalfDuplexMode\n
2897   *         CR3          IREN          LL_USART_ConfigHalfDuplexMode
2898   * @param  USARTx USART Instance
2899   * @retval None
2900   */
LL_USART_ConfigHalfDuplexMode(USART_TypeDef * USARTx)2901 __STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx)
2902 {
2903   /* In Half Duplex mode, the following bits must be kept cleared:
2904   - LINEN and CLKEN bits in the USART_CR2 register,
2905   - SCEN and IREN bits in the USART_CR3 register.*/
2906   CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
2907   CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN));
2908   /* set the UART/USART in Half Duplex mode */
2909   SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
2910 }
2911 
2912 /**
2913   * @brief  Perform basic configuration of USART for enabling use in Smartcard Mode
2914   * @note   In Smartcard mode, the following bits must be kept cleared:
2915   *           - LINEN bit in the USART_CR2 register,
2916   *           - IREN bit in the USART_CR3 register,
2917   *           - HDSEL bit in the USART_CR3 register.
2918   *         This function also configures Stop bits to 1.5 bits and
2919   *         sets the USART in Smartcard mode (SCEN bit).
2920   *         Clock Output is also enabled (CLKEN).
2921   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
2922   *         Smartcard feature is supported by the USARTx instance.
2923   * @note   Call of this function is equivalent to following function call sequence :
2924   *         - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
2925   *         - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
2926   *         - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
2927   *         - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
2928   *         - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
2929   *         - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function
2930   * @note   Other remaining configurations items related to Smartcard Mode
2931   *         (as Baud Rate, Word length, Parity, ...) should be set using
2932   *         dedicated functions
2933   * @rmtoll CR2          LINEN         LL_USART_ConfigSmartcardMode\n
2934   *         CR2          STOP          LL_USART_ConfigSmartcardMode\n
2935   *         CR2          CLKEN         LL_USART_ConfigSmartcardMode\n
2936   *         CR3          HDSEL         LL_USART_ConfigSmartcardMode\n
2937   *         CR3          SCEN          LL_USART_ConfigSmartcardMode
2938   * @param  USARTx USART Instance
2939   * @retval None
2940   */
LL_USART_ConfigSmartcardMode(USART_TypeDef * USARTx)2941 __STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx)
2942 {
2943   /* In Smartcard mode, the following bits must be kept cleared:
2944   - LINEN bit in the USART_CR2 register,
2945   - IREN and HDSEL bits in the USART_CR3 register.*/
2946   CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
2947   CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL));
2948   /* Configure Stop bits to 1.5 bits */
2949   /* Synchronous mode is activated by default */
2950   SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN));
2951   /* set the UART/USART in Smartcard mode */
2952   SET_BIT(USARTx->CR3, USART_CR3_SCEN);
2953 }
2954 
2955 /**
2956   * @brief  Perform basic configuration of USART for enabling use in Irda Mode
2957   * @note   In IRDA mode, the following bits must be kept cleared:
2958   *           - LINEN bit in the USART_CR2 register,
2959   *           - STOP and CLKEN bits in the USART_CR2 register,
2960   *           - SCEN bit in the USART_CR3 register,
2961   *           - HDSEL bit in the USART_CR3 register.
2962   *         This function also sets the UART/USART in IRDA mode (IREN bit).
2963   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
2964   *         IrDA feature is supported by the USARTx instance.
2965   * @note   Call of this function is equivalent to following function call sequence :
2966   *         - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
2967   *         - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
2968   *         - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
2969   *         - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
2970   *         - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
2971   *         - Set IREN in CR3 using @ref LL_USART_EnableIrda() function
2972   * @note   Other remaining configurations items related to Irda Mode
2973   *         (as Baud Rate, Word length, Power mode, ...) should be set using
2974   *         dedicated functions
2975   * @rmtoll CR2          LINEN         LL_USART_ConfigIrdaMode\n
2976   *         CR2          CLKEN         LL_USART_ConfigIrdaMode\n
2977   *         CR2          STOP          LL_USART_ConfigIrdaMode\n
2978   *         CR3          SCEN          LL_USART_ConfigIrdaMode\n
2979   *         CR3          HDSEL         LL_USART_ConfigIrdaMode\n
2980   *         CR3          IREN          LL_USART_ConfigIrdaMode
2981   * @param  USARTx USART Instance
2982   * @retval None
2983   */
LL_USART_ConfigIrdaMode(USART_TypeDef * USARTx)2984 __STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx)
2985 {
2986   /* In IRDA mode, the following bits must be kept cleared:
2987   - LINEN, STOP and CLKEN bits in the USART_CR2 register,
2988   - SCEN and HDSEL bits in the USART_CR3 register.*/
2989   CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP));
2990   CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
2991   /* set the UART/USART in IRDA mode */
2992   SET_BIT(USARTx->CR3, USART_CR3_IREN);
2993 }
2994 
2995 /**
2996   * @brief  Perform basic configuration of USART for enabling use in Multi processor Mode
2997   *         (several USARTs connected in a network, one of the USARTs can be the master,
2998   *         its TX output connected to the RX inputs of the other slaves USARTs).
2999   * @note   In MultiProcessor mode, the following bits must be kept cleared:
3000   *           - LINEN bit in the USART_CR2 register,
3001   *           - CLKEN bit in the USART_CR2 register,
3002   *           - SCEN bit in the USART_CR3 register,
3003   *           - IREN bit in the USART_CR3 register,
3004   *           - HDSEL bit in the USART_CR3 register.
3005   * @note   Call of this function is equivalent to following function call sequence :
3006   *         - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
3007   *         - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
3008   *         - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
3009   *         - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
3010   *         - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
3011   * @note   Other remaining configurations items related to Multi processor Mode
3012   *         (as Baud Rate, Wake Up Method, Node address, ...) should be set using
3013   *         dedicated functions
3014   * @rmtoll CR2          LINEN         LL_USART_ConfigMultiProcessMode\n
3015   *         CR2          CLKEN         LL_USART_ConfigMultiProcessMode\n
3016   *         CR3          SCEN          LL_USART_ConfigMultiProcessMode\n
3017   *         CR3          HDSEL         LL_USART_ConfigMultiProcessMode\n
3018   *         CR3          IREN          LL_USART_ConfigMultiProcessMode
3019   * @param  USARTx USART Instance
3020   * @retval None
3021   */
LL_USART_ConfigMultiProcessMode(USART_TypeDef * USARTx)3022 __STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx)
3023 {
3024   /* In Multi Processor mode, the following bits must be kept cleared:
3025   - LINEN and CLKEN bits in the USART_CR2 register,
3026   - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/
3027   CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
3028   CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN));
3029 }
3030 
3031 /**
3032   * @}
3033   */
3034 
3035 /** @defgroup USART_LL_EF_FLAG_Management FLAG_Management
3036   * @{
3037   */
3038 
3039 /**
3040   * @brief  Check if the USART Parity Error Flag is set or not
3041   * @rmtoll ISR          PE            LL_USART_IsActiveFlag_PE
3042   * @param  USARTx USART Instance
3043   * @retval State of bit (1 or 0).
3044   */
LL_USART_IsActiveFlag_PE(USART_TypeDef * USARTx)3045 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(USART_TypeDef *USARTx)
3046 {
3047   return ((READ_BIT(USARTx->ISR, USART_ISR_PE) == (USART_ISR_PE)) ? 1UL : 0UL);
3048 }
3049 
3050 /**
3051   * @brief  Check if the USART Framing Error Flag is set or not
3052   * @rmtoll ISR          FE            LL_USART_IsActiveFlag_FE
3053   * @param  USARTx USART Instance
3054   * @retval State of bit (1 or 0).
3055   */
LL_USART_IsActiveFlag_FE(USART_TypeDef * USARTx)3056 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(USART_TypeDef *USARTx)
3057 {
3058   return ((READ_BIT(USARTx->ISR, USART_ISR_FE) == (USART_ISR_FE)) ? 1UL : 0UL);
3059 }
3060 
3061 /**
3062   * @brief  Check if the USART Noise error detected Flag is set or not
3063   * @rmtoll ISR          NE            LL_USART_IsActiveFlag_NE
3064   * @param  USARTx USART Instance
3065   * @retval State of bit (1 or 0).
3066   */
LL_USART_IsActiveFlag_NE(USART_TypeDef * USARTx)3067 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(USART_TypeDef *USARTx)
3068 {
3069   return ((READ_BIT(USARTx->ISR, USART_ISR_NE) == (USART_ISR_NE)) ? 1UL : 0UL);
3070 }
3071 
3072 /**
3073   * @brief  Check if the USART OverRun Error Flag is set or not
3074   * @rmtoll ISR          ORE           LL_USART_IsActiveFlag_ORE
3075   * @param  USARTx USART Instance
3076   * @retval State of bit (1 or 0).
3077   */
LL_USART_IsActiveFlag_ORE(USART_TypeDef * USARTx)3078 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(USART_TypeDef *USARTx)
3079 {
3080   return ((READ_BIT(USARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE)) ? 1UL : 0UL);
3081 }
3082 
3083 /**
3084   * @brief  Check if the USART IDLE line detected Flag is set or not
3085   * @rmtoll ISR          IDLE          LL_USART_IsActiveFlag_IDLE
3086   * @param  USARTx USART Instance
3087   * @retval State of bit (1 or 0).
3088   */
LL_USART_IsActiveFlag_IDLE(USART_TypeDef * USARTx)3089 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(USART_TypeDef *USARTx)
3090 {
3091   return ((READ_BIT(USARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE)) ? 1UL : 0UL);
3092 }
3093 
3094 #if defined(USART_CR1_FIFOEN)
3095 /* Legacy define */
3096 #define LL_USART_IsActiveFlag_RXNE  LL_USART_IsActiveFlag_RXNE_RXFNE
3097 
3098 /**
3099   * @brief  Check if the USART Read Data Register or USART RX FIFO Not Empty Flag is set or not
3100   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3101   *         FIFO mode feature is supported by the USARTx instance.
3102   * @rmtoll ISR          RXNE_RXFNE    LL_USART_IsActiveFlag_RXNE_RXFNE
3103   * @param  USARTx USART Instance
3104   * @retval State of bit (1 or 0).
3105   */
LL_USART_IsActiveFlag_RXNE_RXFNE(USART_TypeDef * USARTx)3106 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE_RXFNE(USART_TypeDef *USARTx)
3107 {
3108   return ((READ_BIT(USARTx->ISR, USART_ISR_RXNE_RXFNE) == (USART_ISR_RXNE_RXFNE)) ? 1UL : 0UL);
3109 }
3110 
3111 #else
3112 /**
3113   * @brief  Check if the USART Read Data Register Not Empty Flag is set or not
3114   * @rmtoll ISR          RXNE          LL_USART_IsActiveFlag_RXNE
3115   * @param  USARTx USART Instance
3116   * @retval State of bit (1 or 0).
3117   */
LL_USART_IsActiveFlag_RXNE(USART_TypeDef * USARTx)3118 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE(USART_TypeDef *USARTx)
3119 {
3120   return ((READ_BIT(USARTx->ISR, USART_ISR_RXNE) == (USART_ISR_RXNE)) ? 1UL : 0UL);
3121 }
3122 
3123 #endif /* USART_CR1_FIFOEN */
3124 /**
3125   * @brief  Check if the USART Transmission Complete Flag is set or not
3126   * @rmtoll ISR          TC            LL_USART_IsActiveFlag_TC
3127   * @param  USARTx USART Instance
3128   * @retval State of bit (1 or 0).
3129   */
LL_USART_IsActiveFlag_TC(USART_TypeDef * USARTx)3130 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(USART_TypeDef *USARTx)
3131 {
3132   return ((READ_BIT(USARTx->ISR, USART_ISR_TC) == (USART_ISR_TC)) ? 1UL : 0UL);
3133 }
3134 
3135 #if defined(USART_CR1_FIFOEN)
3136 /* Legacy define */
3137 #define LL_USART_IsActiveFlag_TXE  LL_USART_IsActiveFlag_TXE_TXFNF
3138 
3139 /**
3140   * @brief  Check if the USART Transmit Data Register Empty or USART TX FIFO Not Full Flag is set or not
3141   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3142   *         FIFO mode feature is supported by the USARTx instance.
3143   * @rmtoll ISR          TXE_TXFNF     LL_USART_IsActiveFlag_TXE_TXFNF
3144   * @param  USARTx USART Instance
3145   * @retval State of bit (1 or 0).
3146   */
LL_USART_IsActiveFlag_TXE_TXFNF(USART_TypeDef * USARTx)3147 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE_TXFNF(USART_TypeDef *USARTx)
3148 {
3149   return ((READ_BIT(USARTx->ISR, USART_ISR_TXE_TXFNF) == (USART_ISR_TXE_TXFNF)) ? 1UL : 0UL);
3150 }
3151 
3152 #else
3153 /**
3154   * @brief  Check if the USART Transmit Data Register Empty Flag is set or not
3155   * @rmtoll ISR          TXE           LL_USART_IsActiveFlag_TXE
3156   * @param  USARTx USART Instance
3157   * @retval State of bit (1 or 0).
3158   */
LL_USART_IsActiveFlag_TXE(USART_TypeDef * USARTx)3159 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE(USART_TypeDef *USARTx)
3160 {
3161   return ((READ_BIT(USARTx->ISR, USART_ISR_TXE) == (USART_ISR_TXE)) ? 1UL : 0UL);
3162 }
3163 
3164 #endif /* USART_CR1_FIFOEN */
3165 /**
3166   * @brief  Check if the USART LIN Break Detection Flag is set or not
3167   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
3168   *         LIN feature is supported by the USARTx instance.
3169   * @rmtoll ISR          LBDF          LL_USART_IsActiveFlag_LBD
3170   * @param  USARTx USART Instance
3171   * @retval State of bit (1 or 0).
3172   */
LL_USART_IsActiveFlag_LBD(USART_TypeDef * USARTx)3173 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(USART_TypeDef *USARTx)
3174 {
3175   return ((READ_BIT(USARTx->ISR, USART_ISR_LBDF) == (USART_ISR_LBDF)) ? 1UL : 0UL);
3176 }
3177 
3178 /**
3179   * @brief  Check if the USART CTS interrupt Flag is set or not
3180   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
3181   *         Hardware Flow control feature is supported by the USARTx instance.
3182   * @rmtoll ISR          CTSIF         LL_USART_IsActiveFlag_nCTS
3183   * @param  USARTx USART Instance
3184   * @retval State of bit (1 or 0).
3185   */
LL_USART_IsActiveFlag_nCTS(USART_TypeDef * USARTx)3186 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(USART_TypeDef *USARTx)
3187 {
3188   return ((READ_BIT(USARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF)) ? 1UL : 0UL);
3189 }
3190 
3191 /**
3192   * @brief  Check if the USART CTS Flag is set or not
3193   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
3194   *         Hardware Flow control feature is supported by the USARTx instance.
3195   * @rmtoll ISR          CTS           LL_USART_IsActiveFlag_CTS
3196   * @param  USARTx USART Instance
3197   * @retval State of bit (1 or 0).
3198   */
LL_USART_IsActiveFlag_CTS(USART_TypeDef * USARTx)3199 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CTS(USART_TypeDef *USARTx)
3200 {
3201   return ((READ_BIT(USARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS)) ? 1UL : 0UL);
3202 }
3203 
3204 /**
3205   * @brief  Check if the USART Receiver Time Out Flag is set or not
3206   * @rmtoll ISR          RTOF          LL_USART_IsActiveFlag_RTO
3207   * @param  USARTx USART Instance
3208   * @retval State of bit (1 or 0).
3209   */
LL_USART_IsActiveFlag_RTO(USART_TypeDef * USARTx)3210 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RTO(USART_TypeDef *USARTx)
3211 {
3212   return ((READ_BIT(USARTx->ISR, USART_ISR_RTOF) == (USART_ISR_RTOF)) ? 1UL : 0UL);
3213 }
3214 
3215 /**
3216   * @brief  Check if the USART End Of Block Flag is set or not
3217   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
3218   *         Smartcard feature is supported by the USARTx instance.
3219   * @rmtoll ISR          EOBF          LL_USART_IsActiveFlag_EOB
3220   * @param  USARTx USART Instance
3221   * @retval State of bit (1 or 0).
3222   */
LL_USART_IsActiveFlag_EOB(USART_TypeDef * USARTx)3223 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_EOB(USART_TypeDef *USARTx)
3224 {
3225   return ((READ_BIT(USARTx->ISR, USART_ISR_EOBF) == (USART_ISR_EOBF)) ? 1UL : 0UL);
3226 }
3227 
3228 #if defined(USART_CR2_SLVEN)
3229 /**
3230   * @brief  Check if the SPI Slave Underrun error flag is set or not
3231   * @note   Macro @ref IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
3232   *         SPI Slave mode feature is supported by the USARTx instance.
3233   * @rmtoll ISR          UDR           LL_USART_IsActiveFlag_UDR
3234   * @param  USARTx USART Instance
3235   * @retval State of bit (1 or 0).
3236   */
LL_USART_IsActiveFlag_UDR(USART_TypeDef * USARTx)3237 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_UDR(USART_TypeDef *USARTx)
3238 {
3239   return ((READ_BIT(USARTx->ISR, USART_ISR_UDR) == (USART_ISR_UDR)) ? 1UL : 0UL);
3240 }
3241 
3242 #endif /* USART_CR2_SLVEN */
3243 /**
3244   * @brief  Check if the USART Auto-Baud Rate Error Flag is set or not
3245   * @note   Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
3246   *         Auto Baud Rate detection feature is supported by the USARTx instance.
3247   * @rmtoll ISR          ABRE          LL_USART_IsActiveFlag_ABRE
3248   * @param  USARTx USART Instance
3249   * @retval State of bit (1 or 0).
3250   */
LL_USART_IsActiveFlag_ABRE(USART_TypeDef * USARTx)3251 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABRE(USART_TypeDef *USARTx)
3252 {
3253   return ((READ_BIT(USARTx->ISR, USART_ISR_ABRE) == (USART_ISR_ABRE)) ? 1UL : 0UL);
3254 }
3255 
3256 /**
3257   * @brief  Check if the USART Auto-Baud Rate Flag is set or not
3258   * @note   Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
3259   *         Auto Baud Rate detection feature is supported by the USARTx instance.
3260   * @rmtoll ISR          ABRF          LL_USART_IsActiveFlag_ABR
3261   * @param  USARTx USART Instance
3262   * @retval State of bit (1 or 0).
3263   */
LL_USART_IsActiveFlag_ABR(USART_TypeDef * USARTx)3264 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABR(USART_TypeDef *USARTx)
3265 {
3266   return ((READ_BIT(USARTx->ISR, USART_ISR_ABRF) == (USART_ISR_ABRF)) ? 1UL : 0UL);
3267 }
3268 
3269 /**
3270   * @brief  Check if the USART Busy Flag is set or not
3271   * @rmtoll ISR          BUSY          LL_USART_IsActiveFlag_BUSY
3272   * @param  USARTx USART Instance
3273   * @retval State of bit (1 or 0).
3274   */
LL_USART_IsActiveFlag_BUSY(USART_TypeDef * USARTx)3275 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_BUSY(USART_TypeDef *USARTx)
3276 {
3277   return ((READ_BIT(USARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY)) ? 1UL : 0UL);
3278 }
3279 
3280 /**
3281   * @brief  Check if the USART Character Match Flag is set or not
3282   * @rmtoll ISR          CMF           LL_USART_IsActiveFlag_CM
3283   * @param  USARTx USART Instance
3284   * @retval State of bit (1 or 0).
3285   */
LL_USART_IsActiveFlag_CM(USART_TypeDef * USARTx)3286 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CM(USART_TypeDef *USARTx)
3287 {
3288   return ((READ_BIT(USARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF)) ? 1UL : 0UL);
3289 }
3290 
3291 /**
3292   * @brief  Check if the USART Send Break Flag is set or not
3293   * @rmtoll ISR          SBKF          LL_USART_IsActiveFlag_SBK
3294   * @param  USARTx USART Instance
3295   * @retval State of bit (1 or 0).
3296   */
LL_USART_IsActiveFlag_SBK(USART_TypeDef * USARTx)3297 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(USART_TypeDef *USARTx)
3298 {
3299   return ((READ_BIT(USARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF)) ? 1UL : 0UL);
3300 }
3301 
3302 /**
3303   * @brief  Check if the USART Receive Wake Up from mute mode Flag is set or not
3304   * @rmtoll ISR          RWU           LL_USART_IsActiveFlag_RWU
3305   * @param  USARTx USART Instance
3306   * @retval State of bit (1 or 0).
3307   */
LL_USART_IsActiveFlag_RWU(USART_TypeDef * USARTx)3308 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(USART_TypeDef *USARTx)
3309 {
3310   return ((READ_BIT(USARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU)) ? 1UL : 0UL);
3311 }
3312 
3313 /**
3314   * @brief  Check if the USART Wake Up from stop mode Flag is set or not
3315   * @note   Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
3316   *         Wake-up from Stop mode feature is supported by the USARTx instance.
3317   * @rmtoll ISR          WUF           LL_USART_IsActiveFlag_WKUP
3318   * @param  USARTx USART Instance
3319   * @retval State of bit (1 or 0).
3320   */
LL_USART_IsActiveFlag_WKUP(USART_TypeDef * USARTx)3321 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_WKUP(USART_TypeDef *USARTx)
3322 {
3323   return ((READ_BIT(USARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF)) ? 1UL : 0UL);
3324 }
3325 
3326 /**
3327   * @brief  Check if the USART Transmit Enable Acknowledge Flag is set or not
3328   * @rmtoll ISR          TEACK         LL_USART_IsActiveFlag_TEACK
3329   * @param  USARTx USART Instance
3330   * @retval State of bit (1 or 0).
3331   */
LL_USART_IsActiveFlag_TEACK(USART_TypeDef * USARTx)3332 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TEACK(USART_TypeDef *USARTx)
3333 {
3334   return ((READ_BIT(USARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK)) ? 1UL : 0UL);
3335 }
3336 
3337 /**
3338   * @brief  Check if the USART Receive Enable Acknowledge Flag is set or not
3339   * @rmtoll ISR          REACK         LL_USART_IsActiveFlag_REACK
3340   * @param  USARTx USART Instance
3341   * @retval State of bit (1 or 0).
3342   */
LL_USART_IsActiveFlag_REACK(USART_TypeDef * USARTx)3343 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_REACK(USART_TypeDef *USARTx)
3344 {
3345   return ((READ_BIT(USARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK)) ? 1UL : 0UL);
3346 }
3347 
3348 #if defined(USART_CR1_FIFOEN)
3349 /**
3350   * @brief  Check if the USART TX FIFO Empty Flag is set or not
3351   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3352   *         FIFO mode feature is supported by the USARTx instance.
3353   * @rmtoll ISR          TXFE          LL_USART_IsActiveFlag_TXFE
3354   * @param  USARTx USART Instance
3355   * @retval State of bit (1 or 0).
3356   */
LL_USART_IsActiveFlag_TXFE(USART_TypeDef * USARTx)3357 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXFE(USART_TypeDef *USARTx)
3358 {
3359   return ((READ_BIT(USARTx->ISR, USART_ISR_TXFE) == (USART_ISR_TXFE)) ? 1UL : 0UL);
3360 }
3361 
3362 /**
3363   * @brief  Check if the USART RX FIFO Full Flag is set or not
3364   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3365   *         FIFO mode feature is supported by the USARTx instance.
3366   * @rmtoll ISR          RXFF          LL_USART_IsActiveFlag_RXFF
3367   * @param  USARTx USART Instance
3368   * @retval State of bit (1 or 0).
3369   */
LL_USART_IsActiveFlag_RXFF(USART_TypeDef * USARTx)3370 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXFF(USART_TypeDef *USARTx)
3371 {
3372   return ((READ_BIT(USARTx->ISR, USART_ISR_RXFF) == (USART_ISR_RXFF)) ? 1UL : 0UL);
3373 }
3374 
3375 #endif /* USART_CR1_FIFOEN */
3376 #if defined(USART_TCBGT_SUPPORT)
3377 /* Function available only on devices supporting Transmit Complete before Guard Time feature */
3378 /**
3379   * @brief  Check if the Smartcard Transmission Complete Before Guard Time Flag is set or not
3380   * @rmtoll ISR          TCBGT         LL_USART_IsActiveFlag_TCBGT
3381   * @param  USARTx USART Instance
3382   * @retval State of bit (1 or 0).
3383   */
LL_USART_IsActiveFlag_TCBGT(USART_TypeDef * USARTx)3384 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TCBGT(USART_TypeDef *USARTx)
3385 {
3386   return ((READ_BIT(USARTx->ISR, USART_ISR_TCBGT) == (USART_ISR_TCBGT)) ? 1UL : 0UL);
3387 }
3388 #endif /* USART_TCBGT_SUPPORT */
3389 
3390 #if defined(USART_CR1_FIFOEN)
3391 /**
3392   * @brief  Check if the USART TX FIFO Threshold Flag is set or not
3393   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3394   *         FIFO mode feature is supported by the USARTx instance.
3395   * @rmtoll ISR          TXFT          LL_USART_IsActiveFlag_TXFT
3396   * @param  USARTx USART Instance
3397   * @retval State of bit (1 or 0).
3398   */
LL_USART_IsActiveFlag_TXFT(USART_TypeDef * USARTx)3399 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXFT(USART_TypeDef *USARTx)
3400 {
3401   return ((READ_BIT(USARTx->ISR, USART_ISR_TXFT) == (USART_ISR_TXFT)) ? 1UL : 0UL);
3402 }
3403 
3404 /**
3405   * @brief  Check if the USART RX FIFO Threshold Flag is set or not
3406   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3407   *         FIFO mode feature is supported by the USARTx instance.
3408   * @rmtoll ISR          RXFT          LL_USART_IsActiveFlag_RXFT
3409   * @param  USARTx USART Instance
3410   * @retval State of bit (1 or 0).
3411   */
LL_USART_IsActiveFlag_RXFT(USART_TypeDef * USARTx)3412 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXFT(USART_TypeDef *USARTx)
3413 {
3414   return ((READ_BIT(USARTx->ISR, USART_ISR_RXFT) == (USART_ISR_RXFT)) ? 1UL : 0UL);
3415 }
3416 
3417 #endif /* USART_CR1_FIFOEN */
3418 /**
3419   * @brief  Clear Parity Error Flag
3420   * @rmtoll ICR          PECF          LL_USART_ClearFlag_PE
3421   * @param  USARTx USART Instance
3422   * @retval None
3423   */
LL_USART_ClearFlag_PE(USART_TypeDef * USARTx)3424 __STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx)
3425 {
3426   WRITE_REG(USARTx->ICR, USART_ICR_PECF);
3427 }
3428 
3429 /**
3430   * @brief  Clear Framing Error Flag
3431   * @rmtoll ICR          FECF          LL_USART_ClearFlag_FE
3432   * @param  USARTx USART Instance
3433   * @retval None
3434   */
LL_USART_ClearFlag_FE(USART_TypeDef * USARTx)3435 __STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx)
3436 {
3437   WRITE_REG(USARTx->ICR, USART_ICR_FECF);
3438 }
3439 
3440 /**
3441   * @brief  Clear Noise Error detected Flag
3442   * @rmtoll ICR          NECF          LL_USART_ClearFlag_NE
3443   * @param  USARTx USART Instance
3444   * @retval None
3445   */
LL_USART_ClearFlag_NE(USART_TypeDef * USARTx)3446 __STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx)
3447 {
3448   WRITE_REG(USARTx->ICR, USART_ICR_NECF);
3449 }
3450 
3451 /**
3452   * @brief  Clear OverRun Error Flag
3453   * @rmtoll ICR          ORECF         LL_USART_ClearFlag_ORE
3454   * @param  USARTx USART Instance
3455   * @retval None
3456   */
LL_USART_ClearFlag_ORE(USART_TypeDef * USARTx)3457 __STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx)
3458 {
3459   WRITE_REG(USARTx->ICR, USART_ICR_ORECF);
3460 }
3461 
3462 /**
3463   * @brief  Clear IDLE line detected Flag
3464   * @rmtoll ICR          IDLECF        LL_USART_ClearFlag_IDLE
3465   * @param  USARTx USART Instance
3466   * @retval None
3467   */
LL_USART_ClearFlag_IDLE(USART_TypeDef * USARTx)3468 __STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx)
3469 {
3470   WRITE_REG(USARTx->ICR, USART_ICR_IDLECF);
3471 }
3472 
3473 #if defined(USART_CR1_FIFOEN)
3474 /**
3475   * @brief  Clear TX FIFO Empty Flag
3476   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3477   *         FIFO mode feature is supported by the USARTx instance.
3478   * @rmtoll ICR          TXFECF        LL_USART_ClearFlag_TXFE
3479   * @param  USARTx USART Instance
3480   * @retval None
3481   */
LL_USART_ClearFlag_TXFE(USART_TypeDef * USARTx)3482 __STATIC_INLINE void LL_USART_ClearFlag_TXFE(USART_TypeDef *USARTx)
3483 {
3484   WRITE_REG(USARTx->ICR, USART_ICR_TXFECF);
3485 }
3486 
3487 #endif /* USART_CR1_FIFOEN */
3488 /**
3489   * @brief  Clear Transmission Complete Flag
3490   * @rmtoll ICR          TCCF          LL_USART_ClearFlag_TC
3491   * @param  USARTx USART Instance
3492   * @retval None
3493   */
LL_USART_ClearFlag_TC(USART_TypeDef * USARTx)3494 __STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx)
3495 {
3496   WRITE_REG(USARTx->ICR, USART_ICR_TCCF);
3497 }
3498 
3499 #if defined(USART_TCBGT_SUPPORT)
3500 /* Function available only on devices supporting Transmit Complete before Guard Time feature */
3501 /**
3502   * @brief  Clear Smartcard Transmission Complete Before Guard Time Flag
3503   * @rmtoll ICR          TCBGTCF       LL_USART_ClearFlag_TCBGT
3504   * @param  USARTx USART Instance
3505   * @retval None
3506   */
LL_USART_ClearFlag_TCBGT(USART_TypeDef * USARTx)3507 __STATIC_INLINE void LL_USART_ClearFlag_TCBGT(USART_TypeDef *USARTx)
3508 {
3509   WRITE_REG(USARTx->ICR, USART_ICR_TCBGTCF);
3510 }
3511 #endif /* USART_TCBGT_SUPPORT */
3512 
3513 /**
3514   * @brief  Clear LIN Break Detection Flag
3515   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
3516   *         LIN feature is supported by the USARTx instance.
3517   * @rmtoll ICR          LBDCF         LL_USART_ClearFlag_LBD
3518   * @param  USARTx USART Instance
3519   * @retval None
3520   */
LL_USART_ClearFlag_LBD(USART_TypeDef * USARTx)3521 __STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx)
3522 {
3523   WRITE_REG(USARTx->ICR, USART_ICR_LBDCF);
3524 }
3525 
3526 /**
3527   * @brief  Clear CTS Interrupt Flag
3528   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
3529   *         Hardware Flow control feature is supported by the USARTx instance.
3530   * @rmtoll ICR          CTSCF         LL_USART_ClearFlag_nCTS
3531   * @param  USARTx USART Instance
3532   * @retval None
3533   */
LL_USART_ClearFlag_nCTS(USART_TypeDef * USARTx)3534 __STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx)
3535 {
3536   WRITE_REG(USARTx->ICR, USART_ICR_CTSCF);
3537 }
3538 
3539 /**
3540   * @brief  Clear Receiver Time Out Flag
3541   * @rmtoll ICR          RTOCF         LL_USART_ClearFlag_RTO
3542   * @param  USARTx USART Instance
3543   * @retval None
3544   */
LL_USART_ClearFlag_RTO(USART_TypeDef * USARTx)3545 __STATIC_INLINE void LL_USART_ClearFlag_RTO(USART_TypeDef *USARTx)
3546 {
3547   WRITE_REG(USARTx->ICR, USART_ICR_RTOCF);
3548 }
3549 
3550 /**
3551   * @brief  Clear End Of Block Flag
3552   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
3553   *         Smartcard feature is supported by the USARTx instance.
3554   * @rmtoll ICR          EOBCF         LL_USART_ClearFlag_EOB
3555   * @param  USARTx USART Instance
3556   * @retval None
3557   */
LL_USART_ClearFlag_EOB(USART_TypeDef * USARTx)3558 __STATIC_INLINE void LL_USART_ClearFlag_EOB(USART_TypeDef *USARTx)
3559 {
3560   WRITE_REG(USARTx->ICR, USART_ICR_EOBCF);
3561 }
3562 
3563 #if defined(USART_CR2_SLVEN)
3564 /**
3565   * @brief  Clear SPI Slave Underrun Flag
3566   * @note   Macro @ref IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not
3567   *         SPI Slave mode feature is supported by the USARTx instance.
3568   * @rmtoll ICR          UDRCF         LL_USART_ClearFlag_UDR
3569   * @param  USARTx USART Instance
3570   * @retval None
3571   */
LL_USART_ClearFlag_UDR(USART_TypeDef * USARTx)3572 __STATIC_INLINE void LL_USART_ClearFlag_UDR(USART_TypeDef *USARTx)
3573 {
3574   WRITE_REG(USARTx->ICR, USART_ICR_UDRCF);
3575 }
3576 
3577 #endif /* USART_CR2_SLVEN */
3578 /**
3579   * @brief  Clear Character Match Flag
3580   * @rmtoll ICR          CMCF          LL_USART_ClearFlag_CM
3581   * @param  USARTx USART Instance
3582   * @retval None
3583   */
LL_USART_ClearFlag_CM(USART_TypeDef * USARTx)3584 __STATIC_INLINE void LL_USART_ClearFlag_CM(USART_TypeDef *USARTx)
3585 {
3586   WRITE_REG(USARTx->ICR, USART_ICR_CMCF);
3587 }
3588 
3589 /**
3590   * @brief  Clear Wake Up from stop mode Flag
3591   * @note   Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
3592   *         Wake-up from Stop mode feature is supported by the USARTx instance.
3593   * @rmtoll ICR          WUCF          LL_USART_ClearFlag_WKUP
3594   * @param  USARTx USART Instance
3595   * @retval None
3596   */
LL_USART_ClearFlag_WKUP(USART_TypeDef * USARTx)3597 __STATIC_INLINE void LL_USART_ClearFlag_WKUP(USART_TypeDef *USARTx)
3598 {
3599   WRITE_REG(USARTx->ICR, USART_ICR_WUCF);
3600 }
3601 
3602 /**
3603   * @}
3604   */
3605 
3606 /** @defgroup USART_LL_EF_IT_Management IT_Management
3607   * @{
3608   */
3609 
3610 /**
3611   * @brief  Enable IDLE Interrupt
3612   * @rmtoll CR1          IDLEIE        LL_USART_EnableIT_IDLE
3613   * @param  USARTx USART Instance
3614   * @retval None
3615   */
LL_USART_EnableIT_IDLE(USART_TypeDef * USARTx)3616 __STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx)
3617 {
3618   SET_BIT(USARTx->CR1, USART_CR1_IDLEIE);
3619 }
3620 
3621 #if defined(USART_CR1_FIFOEN)
3622 /* Legacy define */
3623 #define LL_USART_EnableIT_RXNE  LL_USART_EnableIT_RXNE_RXFNE
3624 
3625 /**
3626   * @brief  Enable RX Not Empty and RX FIFO Not Empty Interrupt
3627   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3628   *         FIFO mode feature is supported by the USARTx instance.
3629   * @rmtoll CR1        RXNEIE_RXFNEIE  LL_USART_EnableIT_RXNE_RXFNE
3630   * @param  USARTx USART Instance
3631   * @retval None
3632   */
LL_USART_EnableIT_RXNE_RXFNE(USART_TypeDef * USARTx)3633 __STATIC_INLINE void LL_USART_EnableIT_RXNE_RXFNE(USART_TypeDef *USARTx)
3634 {
3635   SET_BIT(USARTx->CR1, USART_CR1_RXNEIE_RXFNEIE);
3636 }
3637 
3638 #else
3639 /**
3640   * @brief  Enable RX Not Empty Interrupt
3641   * @rmtoll CR1          RXNEIE        LL_USART_EnableIT_RXNE
3642   * @param  USARTx USART Instance
3643   * @retval None
3644   */
LL_USART_EnableIT_RXNE(USART_TypeDef * USARTx)3645 __STATIC_INLINE void LL_USART_EnableIT_RXNE(USART_TypeDef *USARTx)
3646 {
3647   SET_BIT(USARTx->CR1, USART_CR1_RXNEIE);
3648 }
3649 
3650 #endif /* USART_CR1_FIFOEN */
3651 /**
3652   * @brief  Enable Transmission Complete Interrupt
3653   * @rmtoll CR1          TCIE          LL_USART_EnableIT_TC
3654   * @param  USARTx USART Instance
3655   * @retval None
3656   */
LL_USART_EnableIT_TC(USART_TypeDef * USARTx)3657 __STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx)
3658 {
3659   SET_BIT(USARTx->CR1, USART_CR1_TCIE);
3660 }
3661 
3662 #if defined(USART_CR1_FIFOEN)
3663 /* Legacy define */
3664 #define LL_USART_EnableIT_TXE  LL_USART_EnableIT_TXE_TXFNF
3665 
3666 /**
3667   * @brief  Enable TX Empty and TX FIFO Not Full Interrupt
3668   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3669   *         FIFO mode feature is supported by the USARTx instance.
3670   * @rmtoll CR1         TXEIE_TXFNFIE  LL_USART_EnableIT_TXE_TXFNF
3671   * @param  USARTx USART Instance
3672   * @retval None
3673   */
LL_USART_EnableIT_TXE_TXFNF(USART_TypeDef * USARTx)3674 __STATIC_INLINE void LL_USART_EnableIT_TXE_TXFNF(USART_TypeDef *USARTx)
3675 {
3676   SET_BIT(USARTx->CR1, USART_CR1_TXEIE_TXFNFIE);
3677 }
3678 
3679 #else
3680 /**
3681   * @brief  Enable TX Empty Interrupt
3682   * @rmtoll CR1          TXEIE         LL_USART_EnableIT_TXE
3683   * @param  USARTx USART Instance
3684   * @retval None
3685   */
LL_USART_EnableIT_TXE(USART_TypeDef * USARTx)3686 __STATIC_INLINE void LL_USART_EnableIT_TXE(USART_TypeDef *USARTx)
3687 {
3688   SET_BIT(USARTx->CR1, USART_CR1_TXEIE);
3689 }
3690 
3691 #endif /* USART_CR1_FIFOEN */
3692 /**
3693   * @brief  Enable Parity Error Interrupt
3694   * @rmtoll CR1          PEIE          LL_USART_EnableIT_PE
3695   * @param  USARTx USART Instance
3696   * @retval None
3697   */
LL_USART_EnableIT_PE(USART_TypeDef * USARTx)3698 __STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx)
3699 {
3700   SET_BIT(USARTx->CR1, USART_CR1_PEIE);
3701 }
3702 
3703 /**
3704   * @brief  Enable Character Match Interrupt
3705   * @rmtoll CR1          CMIE          LL_USART_EnableIT_CM
3706   * @param  USARTx USART Instance
3707   * @retval None
3708   */
LL_USART_EnableIT_CM(USART_TypeDef * USARTx)3709 __STATIC_INLINE void LL_USART_EnableIT_CM(USART_TypeDef *USARTx)
3710 {
3711   SET_BIT(USARTx->CR1, USART_CR1_CMIE);
3712 }
3713 
3714 /**
3715   * @brief  Enable Receiver Timeout Interrupt
3716   * @rmtoll CR1          RTOIE         LL_USART_EnableIT_RTO
3717   * @param  USARTx USART Instance
3718   * @retval None
3719   */
LL_USART_EnableIT_RTO(USART_TypeDef * USARTx)3720 __STATIC_INLINE void LL_USART_EnableIT_RTO(USART_TypeDef *USARTx)
3721 {
3722   SET_BIT(USARTx->CR1, USART_CR1_RTOIE);
3723 }
3724 
3725 /**
3726   * @brief  Enable End Of Block Interrupt
3727   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
3728   *         Smartcard feature is supported by the USARTx instance.
3729   * @rmtoll CR1          EOBIE         LL_USART_EnableIT_EOB
3730   * @param  USARTx USART Instance
3731   * @retval None
3732   */
LL_USART_EnableIT_EOB(USART_TypeDef * USARTx)3733 __STATIC_INLINE void LL_USART_EnableIT_EOB(USART_TypeDef *USARTx)
3734 {
3735   SET_BIT(USARTx->CR1, USART_CR1_EOBIE);
3736 }
3737 
3738 #if defined(USART_CR1_FIFOEN)
3739 /**
3740   * @brief  Enable TX FIFO Empty Interrupt
3741   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3742   *         FIFO mode feature is supported by the USARTx instance.
3743   * @rmtoll CR1          TXFEIE        LL_USART_EnableIT_TXFE
3744   * @param  USARTx USART Instance
3745   * @retval None
3746   */
LL_USART_EnableIT_TXFE(USART_TypeDef * USARTx)3747 __STATIC_INLINE void LL_USART_EnableIT_TXFE(USART_TypeDef *USARTx)
3748 {
3749   SET_BIT(USARTx->CR1, USART_CR1_TXFEIE);
3750 }
3751 
3752 /**
3753   * @brief  Enable RX FIFO Full Interrupt
3754   * @rmtoll CR1          RXFFIE        LL_USART_EnableIT_RXFF
3755   * @param  USARTx USART Instance
3756   * @retval None
3757   */
LL_USART_EnableIT_RXFF(USART_TypeDef * USARTx)3758 __STATIC_INLINE void LL_USART_EnableIT_RXFF(USART_TypeDef *USARTx)
3759 {
3760   SET_BIT(USARTx->CR1, USART_CR1_RXFFIE);
3761 }
3762 
3763 #endif /* USART_CR1_FIFOEN */
3764 /**
3765   * @brief  Enable LIN Break Detection Interrupt
3766   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
3767   *         LIN feature is supported by the USARTx instance.
3768   * @rmtoll CR2          LBDIE         LL_USART_EnableIT_LBD
3769   * @param  USARTx USART Instance
3770   * @retval None
3771   */
LL_USART_EnableIT_LBD(USART_TypeDef * USARTx)3772 __STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx)
3773 {
3774   SET_BIT(USARTx->CR2, USART_CR2_LBDIE);
3775 }
3776 
3777 /**
3778   * @brief  Enable Error Interrupt
3779   * @note   When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
3780   *         error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register).
3781   *           0: Interrupt is inhibited
3782   *           1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register.
3783   * @rmtoll CR3          EIE           LL_USART_EnableIT_ERROR
3784   * @param  USARTx USART Instance
3785   * @retval None
3786   */
LL_USART_EnableIT_ERROR(USART_TypeDef * USARTx)3787 __STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx)
3788 {
3789   SET_BIT(USARTx->CR3, USART_CR3_EIE);
3790 }
3791 
3792 /**
3793   * @brief  Enable CTS Interrupt
3794   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
3795   *         Hardware Flow control feature is supported by the USARTx instance.
3796   * @rmtoll CR3          CTSIE         LL_USART_EnableIT_CTS
3797   * @param  USARTx USART Instance
3798   * @retval None
3799   */
LL_USART_EnableIT_CTS(USART_TypeDef * USARTx)3800 __STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx)
3801 {
3802   SET_BIT(USARTx->CR3, USART_CR3_CTSIE);
3803 }
3804 
3805 /**
3806   * @brief  Enable Wake Up from Stop Mode Interrupt
3807   * @note   Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
3808   *         Wake-up from Stop mode feature is supported by the USARTx instance.
3809   * @rmtoll CR3          WUFIE         LL_USART_EnableIT_WKUP
3810   * @param  USARTx USART Instance
3811   * @retval None
3812   */
LL_USART_EnableIT_WKUP(USART_TypeDef * USARTx)3813 __STATIC_INLINE void LL_USART_EnableIT_WKUP(USART_TypeDef *USARTx)
3814 {
3815   SET_BIT(USARTx->CR3, USART_CR3_WUFIE);
3816 }
3817 
3818 #if defined(USART_CR1_FIFOEN)
3819 /**
3820   * @brief  Enable TX FIFO Threshold Interrupt
3821   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3822   *         FIFO mode feature is supported by the USARTx instance.
3823   * @rmtoll CR3          TXFTIE        LL_USART_EnableIT_TXFT
3824   * @param  USARTx USART Instance
3825   * @retval None
3826   */
LL_USART_EnableIT_TXFT(USART_TypeDef * USARTx)3827 __STATIC_INLINE void LL_USART_EnableIT_TXFT(USART_TypeDef *USARTx)
3828 {
3829   SET_BIT(USARTx->CR3, USART_CR3_TXFTIE);
3830 }
3831 
3832 #endif /* USART_CR1_FIFOEN */
3833 #if defined(USART_TCBGT_SUPPORT)
3834 /* Function available only on devices supporting Transmit Complete before Guard Time feature */
3835 /**
3836   * @brief  Enable Smartcard Transmission Complete Before Guard Time Interrupt
3837   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
3838   *         Smartcard feature is supported by the USARTx instance.
3839   * @rmtoll CR3          TCBGTIE       LL_USART_EnableIT_TCBGT
3840   * @param  USARTx USART Instance
3841   * @retval None
3842   */
LL_USART_EnableIT_TCBGT(USART_TypeDef * USARTx)3843 __STATIC_INLINE void LL_USART_EnableIT_TCBGT(USART_TypeDef *USARTx)
3844 {
3845   SET_BIT(USARTx->CR3, USART_CR3_TCBGTIE);
3846 }
3847 #endif /* USART_TCBGT_SUPPORT */
3848 
3849 #if defined(USART_CR1_FIFOEN)
3850 /**
3851   * @brief  Enable RX FIFO Threshold Interrupt
3852   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3853   *         FIFO mode feature is supported by the USARTx instance.
3854   * @rmtoll CR3          RXFTIE        LL_USART_EnableIT_RXFT
3855   * @param  USARTx USART Instance
3856   * @retval None
3857   */
LL_USART_EnableIT_RXFT(USART_TypeDef * USARTx)3858 __STATIC_INLINE void LL_USART_EnableIT_RXFT(USART_TypeDef *USARTx)
3859 {
3860   SET_BIT(USARTx->CR3, USART_CR3_RXFTIE);
3861 }
3862 
3863 #endif /* USART_CR1_FIFOEN */
3864 /**
3865   * @brief  Disable IDLE Interrupt
3866   * @rmtoll CR1          IDLEIE        LL_USART_DisableIT_IDLE
3867   * @param  USARTx USART Instance
3868   * @retval None
3869   */
LL_USART_DisableIT_IDLE(USART_TypeDef * USARTx)3870 __STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx)
3871 {
3872   CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE);
3873 }
3874 
3875 #if defined(USART_CR1_FIFOEN)
3876 /* Legacy define */
3877 #define LL_USART_DisableIT_RXNE  LL_USART_DisableIT_RXNE_RXFNE
3878 
3879 /**
3880   * @brief  Disable RX Not Empty and RX FIFO Not Empty Interrupt
3881   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3882   *         FIFO mode feature is supported by the USARTx instance.
3883   * @rmtoll CR1        RXNEIE_RXFNEIE  LL_USART_DisableIT_RXNE_RXFNE
3884   * @param  USARTx USART Instance
3885   * @retval None
3886   */
LL_USART_DisableIT_RXNE_RXFNE(USART_TypeDef * USARTx)3887 __STATIC_INLINE void LL_USART_DisableIT_RXNE_RXFNE(USART_TypeDef *USARTx)
3888 {
3889   CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE_RXFNEIE);
3890 }
3891 
3892 #else
3893 /**
3894   * @brief  Disable RX Not Empty Interrupt
3895   * @rmtoll CR1          RXNEIE        LL_USART_DisableIT_RXNE
3896   * @param  USARTx USART Instance
3897   * @retval None
3898   */
LL_USART_DisableIT_RXNE(USART_TypeDef * USARTx)3899 __STATIC_INLINE void LL_USART_DisableIT_RXNE(USART_TypeDef *USARTx)
3900 {
3901   CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE);
3902 }
3903 
3904 #endif /* USART_CR1_FIFOEN */
3905 /**
3906   * @brief  Disable Transmission Complete Interrupt
3907   * @rmtoll CR1          TCIE          LL_USART_DisableIT_TC
3908   * @param  USARTx USART Instance
3909   * @retval None
3910   */
LL_USART_DisableIT_TC(USART_TypeDef * USARTx)3911 __STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx)
3912 {
3913   CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE);
3914 }
3915 
3916 #if defined(USART_CR1_FIFOEN)
3917 /* Legacy define */
3918 #define LL_USART_DisableIT_TXE  LL_USART_DisableIT_TXE_TXFNF
3919 
3920 /**
3921   * @brief  Disable TX Empty and TX FIFO Not Full Interrupt
3922   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3923   *         FIFO mode feature is supported by the USARTx instance.
3924   * @rmtoll CR1        TXEIE_TXFNFIE  LL_USART_DisableIT_TXE_TXFNF
3925   * @param  USARTx USART Instance
3926   * @retval None
3927   */
LL_USART_DisableIT_TXE_TXFNF(USART_TypeDef * USARTx)3928 __STATIC_INLINE void LL_USART_DisableIT_TXE_TXFNF(USART_TypeDef *USARTx)
3929 {
3930   CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE_TXFNFIE);
3931 }
3932 
3933 #else
3934 /**
3935   * @brief  Disable TX Empty Interrupt
3936   * @rmtoll CR1          TXEIE         LL_USART_DisableIT_TXE
3937   * @param  USARTx USART Instance
3938   * @retval None
3939   */
LL_USART_DisableIT_TXE(USART_TypeDef * USARTx)3940 __STATIC_INLINE void LL_USART_DisableIT_TXE(USART_TypeDef *USARTx)
3941 {
3942   CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE);
3943 }
3944 
3945 #endif /* USART_CR1_FIFOEN */
3946 /**
3947   * @brief  Disable Parity Error Interrupt
3948   * @rmtoll CR1          PEIE          LL_USART_DisableIT_PE
3949   * @param  USARTx USART Instance
3950   * @retval None
3951   */
LL_USART_DisableIT_PE(USART_TypeDef * USARTx)3952 __STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx)
3953 {
3954   CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE);
3955 }
3956 
3957 /**
3958   * @brief  Disable Character Match Interrupt
3959   * @rmtoll CR1          CMIE          LL_USART_DisableIT_CM
3960   * @param  USARTx USART Instance
3961   * @retval None
3962   */
LL_USART_DisableIT_CM(USART_TypeDef * USARTx)3963 __STATIC_INLINE void LL_USART_DisableIT_CM(USART_TypeDef *USARTx)
3964 {
3965   CLEAR_BIT(USARTx->CR1, USART_CR1_CMIE);
3966 }
3967 
3968 /**
3969   * @brief  Disable Receiver Timeout Interrupt
3970   * @rmtoll CR1          RTOIE         LL_USART_DisableIT_RTO
3971   * @param  USARTx USART Instance
3972   * @retval None
3973   */
LL_USART_DisableIT_RTO(USART_TypeDef * USARTx)3974 __STATIC_INLINE void LL_USART_DisableIT_RTO(USART_TypeDef *USARTx)
3975 {
3976   CLEAR_BIT(USARTx->CR1, USART_CR1_RTOIE);
3977 }
3978 
3979 /**
3980   * @brief  Disable End Of Block Interrupt
3981   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
3982   *         Smartcard feature is supported by the USARTx instance.
3983   * @rmtoll CR1          EOBIE         LL_USART_DisableIT_EOB
3984   * @param  USARTx USART Instance
3985   * @retval None
3986   */
LL_USART_DisableIT_EOB(USART_TypeDef * USARTx)3987 __STATIC_INLINE void LL_USART_DisableIT_EOB(USART_TypeDef *USARTx)
3988 {
3989   CLEAR_BIT(USARTx->CR1, USART_CR1_EOBIE);
3990 }
3991 
3992 #if defined(USART_CR1_FIFOEN)
3993 /**
3994   * @brief  Disable TX FIFO Empty Interrupt
3995   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
3996   *         FIFO mode feature is supported by the USARTx instance.
3997   * @rmtoll CR1          TXFEIE        LL_USART_DisableIT_TXFE
3998   * @param  USARTx USART Instance
3999   * @retval None
4000   */
LL_USART_DisableIT_TXFE(USART_TypeDef * USARTx)4001 __STATIC_INLINE void LL_USART_DisableIT_TXFE(USART_TypeDef *USARTx)
4002 {
4003   CLEAR_BIT(USARTx->CR1, USART_CR1_TXFEIE);
4004 }
4005 
4006 /**
4007   * @brief  Disable RX FIFO Full Interrupt
4008   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4009   *         FIFO mode feature is supported by the USARTx instance.
4010   * @rmtoll CR1          RXFFIE        LL_USART_DisableIT_RXFF
4011   * @param  USARTx USART Instance
4012   * @retval None
4013   */
LL_USART_DisableIT_RXFF(USART_TypeDef * USARTx)4014 __STATIC_INLINE void LL_USART_DisableIT_RXFF(USART_TypeDef *USARTx)
4015 {
4016   CLEAR_BIT(USARTx->CR1, USART_CR1_RXFFIE);
4017 }
4018 
4019 #endif /* USART_CR1_FIFOEN */
4020 /**
4021   * @brief  Disable LIN Break Detection Interrupt
4022   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
4023   *         LIN feature is supported by the USARTx instance.
4024   * @rmtoll CR2          LBDIE         LL_USART_DisableIT_LBD
4025   * @param  USARTx USART Instance
4026   * @retval None
4027   */
LL_USART_DisableIT_LBD(USART_TypeDef * USARTx)4028 __STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx)
4029 {
4030   CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE);
4031 }
4032 
4033 /**
4034   * @brief  Disable Error Interrupt
4035   * @note   When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
4036   *         error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register).
4037   *           0: Interrupt is inhibited
4038   *           1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register.
4039   * @rmtoll CR3          EIE           LL_USART_DisableIT_ERROR
4040   * @param  USARTx USART Instance
4041   * @retval None
4042   */
LL_USART_DisableIT_ERROR(USART_TypeDef * USARTx)4043 __STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx)
4044 {
4045   CLEAR_BIT(USARTx->CR3, USART_CR3_EIE);
4046 }
4047 
4048 /**
4049   * @brief  Disable CTS Interrupt
4050   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
4051   *         Hardware Flow control feature is supported by the USARTx instance.
4052   * @rmtoll CR3          CTSIE         LL_USART_DisableIT_CTS
4053   * @param  USARTx USART Instance
4054   * @retval None
4055   */
LL_USART_DisableIT_CTS(USART_TypeDef * USARTx)4056 __STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx)
4057 {
4058   CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE);
4059 }
4060 
4061 /**
4062   * @brief  Disable Wake Up from Stop Mode Interrupt
4063   * @note   Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
4064   *         Wake-up from Stop mode feature is supported by the USARTx instance.
4065   * @rmtoll CR3          WUFIE         LL_USART_DisableIT_WKUP
4066   * @param  USARTx USART Instance
4067   * @retval None
4068   */
LL_USART_DisableIT_WKUP(USART_TypeDef * USARTx)4069 __STATIC_INLINE void LL_USART_DisableIT_WKUP(USART_TypeDef *USARTx)
4070 {
4071   CLEAR_BIT(USARTx->CR3, USART_CR3_WUFIE);
4072 }
4073 
4074 #if defined(USART_CR1_FIFOEN)
4075 /**
4076   * @brief  Disable TX FIFO Threshold Interrupt
4077   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4078   *         FIFO mode feature is supported by the USARTx instance.
4079   * @rmtoll CR3          TXFTIE        LL_USART_DisableIT_TXFT
4080   * @param  USARTx USART Instance
4081   * @retval None
4082   */
LL_USART_DisableIT_TXFT(USART_TypeDef * USARTx)4083 __STATIC_INLINE void LL_USART_DisableIT_TXFT(USART_TypeDef *USARTx)
4084 {
4085   CLEAR_BIT(USARTx->CR3, USART_CR3_TXFTIE);
4086 }
4087 
4088 #endif /* USART_CR1_FIFOEN */
4089 #if defined(USART_TCBGT_SUPPORT)
4090 /* Function available only on devices supporting Transmit Complete before Guard Time feature */
4091 /**
4092   * @brief  Disable Smartcard Transmission Complete Before Guard Time Interrupt
4093   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
4094   *         Smartcard feature is supported by the USARTx instance.
4095   * @rmtoll CR3          TCBGTIE       LL_USART_DisableIT_TCBGT
4096   * @param  USARTx USART Instance
4097   * @retval None
4098   */
LL_USART_DisableIT_TCBGT(USART_TypeDef * USARTx)4099 __STATIC_INLINE void LL_USART_DisableIT_TCBGT(USART_TypeDef *USARTx)
4100 {
4101   CLEAR_BIT(USARTx->CR3, USART_CR3_TCBGTIE);
4102 }
4103 #endif /* USART_TCBGT_SUPPORT */
4104 
4105 #if defined(USART_CR1_FIFOEN)
4106 /**
4107   * @brief  Disable RX FIFO Threshold Interrupt
4108   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4109   *         FIFO mode feature is supported by the USARTx instance.
4110   * @rmtoll CR3          RXFTIE        LL_USART_DisableIT_RXFT
4111   * @param  USARTx USART Instance
4112   * @retval None
4113   */
LL_USART_DisableIT_RXFT(USART_TypeDef * USARTx)4114 __STATIC_INLINE void LL_USART_DisableIT_RXFT(USART_TypeDef *USARTx)
4115 {
4116   CLEAR_BIT(USARTx->CR3, USART_CR3_RXFTIE);
4117 }
4118 
4119 #endif /* USART_CR1_FIFOEN */
4120 /**
4121   * @brief  Check if the USART IDLE Interrupt  source is enabled or disabled.
4122   * @rmtoll CR1          IDLEIE        LL_USART_IsEnabledIT_IDLE
4123   * @param  USARTx USART Instance
4124   * @retval State of bit (1 or 0).
4125   */
LL_USART_IsEnabledIT_IDLE(USART_TypeDef * USARTx)4126 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(USART_TypeDef *USARTx)
4127 {
4128   return ((READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE)) ? 1UL : 0UL);
4129 }
4130 
4131 #if defined(USART_CR1_FIFOEN)
4132 /* Legacy define */
4133 #define LL_USART_IsEnabledIT_RXNE  LL_USART_IsEnabledIT_RXNE_RXFNE
4134 
4135 /**
4136   * @brief  Check if the USART RX Not Empty and USART RX FIFO Not Empty Interrupt is enabled or disabled.
4137   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4138   *         FIFO mode feature is supported by the USARTx instance.
4139   * @rmtoll CR1        RXNEIE_RXFNEIE  LL_USART_IsEnabledIT_RXNE_RXFNE
4140   * @param  USARTx USART Instance
4141   * @retval State of bit (1 or 0).
4142   */
LL_USART_IsEnabledIT_RXNE_RXFNE(USART_TypeDef * USARTx)4143 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE_RXFNE(USART_TypeDef *USARTx)
4144 {
4145   return ((READ_BIT(USARTx->CR1, USART_CR1_RXNEIE_RXFNEIE) == (USART_CR1_RXNEIE_RXFNEIE)) ? 1UL : 0UL);
4146 }
4147 
4148 #else
4149 /**
4150   * @brief  Check if the USART RX Not Empty Interrupt is enabled or disabled.
4151   * @rmtoll CR1          RXNEIE        LL_USART_IsEnabledIT_RXNE
4152   * @param  USARTx USART Instance
4153   * @retval State of bit (1 or 0).
4154   */
LL_USART_IsEnabledIT_RXNE(USART_TypeDef * USARTx)4155 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE(USART_TypeDef *USARTx)
4156 {
4157   return ((READ_BIT(USARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE)) ? 1U : 0U);
4158 }
4159 
4160 #endif /* USART_CR1_FIFOEN */
4161 /**
4162   * @brief  Check if the USART Transmission Complete Interrupt is enabled or disabled.
4163   * @rmtoll CR1          TCIE          LL_USART_IsEnabledIT_TC
4164   * @param  USARTx USART Instance
4165   * @retval State of bit (1 or 0).
4166   */
LL_USART_IsEnabledIT_TC(USART_TypeDef * USARTx)4167 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(USART_TypeDef *USARTx)
4168 {
4169   return ((READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE)) ? 1UL : 0UL);
4170 }
4171 
4172 #if defined(USART_CR1_FIFOEN)
4173 /* Legacy define */
4174 #define LL_USART_IsEnabledIT_TXE  LL_USART_IsEnabledIT_TXE_TXFNF
4175 
4176 /**
4177   * @brief  Check if the USART TX Empty and USART TX FIFO Not Full Interrupt is enabled or disabled
4178   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4179   *         FIFO mode feature is supported by the USARTx instance.
4180   * @rmtoll CR1         TXEIE_TXFNFIE  LL_USART_IsEnabledIT_TXE_TXFNF
4181   * @param  USARTx USART Instance
4182   * @retval State of bit (1 or 0).
4183   */
LL_USART_IsEnabledIT_TXE_TXFNF(USART_TypeDef * USARTx)4184 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE_TXFNF(USART_TypeDef *USARTx)
4185 {
4186   return ((READ_BIT(USARTx->CR1, USART_CR1_TXEIE_TXFNFIE) == (USART_CR1_TXEIE_TXFNFIE)) ? 1UL : 0UL);
4187 }
4188 
4189 #else
4190 /**
4191   * @brief  Check if the USART TX Empty Interrupt is enabled or disabled.
4192   * @rmtoll CR1          TXEIE         LL_USART_IsEnabledIT_TXE
4193   * @param  USARTx USART Instance
4194   * @retval State of bit (1 or 0).
4195   */
LL_USART_IsEnabledIT_TXE(USART_TypeDef * USARTx)4196 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE(USART_TypeDef *USARTx)
4197 {
4198   return ((READ_BIT(USARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE)) ? 1U : 0U);
4199 }
4200 
4201 #endif /* USART_CR1_FIFOEN */
4202 /**
4203   * @brief  Check if the USART Parity Error Interrupt is enabled or disabled.
4204   * @rmtoll CR1          PEIE          LL_USART_IsEnabledIT_PE
4205   * @param  USARTx USART Instance
4206   * @retval State of bit (1 or 0).
4207   */
LL_USART_IsEnabledIT_PE(USART_TypeDef * USARTx)4208 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(USART_TypeDef *USARTx)
4209 {
4210   return ((READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE)) ? 1UL : 0UL);
4211 }
4212 
4213 /**
4214   * @brief  Check if the USART Character Match Interrupt is enabled or disabled.
4215   * @rmtoll CR1          CMIE          LL_USART_IsEnabledIT_CM
4216   * @param  USARTx USART Instance
4217   * @retval State of bit (1 or 0).
4218   */
LL_USART_IsEnabledIT_CM(USART_TypeDef * USARTx)4219 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CM(USART_TypeDef *USARTx)
4220 {
4221   return ((READ_BIT(USARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE)) ? 1UL : 0UL);
4222 }
4223 
4224 /**
4225   * @brief  Check if the USART Receiver Timeout Interrupt is enabled or disabled.
4226   * @rmtoll CR1          RTOIE         LL_USART_IsEnabledIT_RTO
4227   * @param  USARTx USART Instance
4228   * @retval State of bit (1 or 0).
4229   */
LL_USART_IsEnabledIT_RTO(USART_TypeDef * USARTx)4230 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RTO(USART_TypeDef *USARTx)
4231 {
4232   return ((READ_BIT(USARTx->CR1, USART_CR1_RTOIE) == (USART_CR1_RTOIE)) ? 1UL : 0UL);
4233 }
4234 
4235 /**
4236   * @brief  Check if the USART End Of Block Interrupt is enabled or disabled.
4237   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
4238   *         Smartcard feature is supported by the USARTx instance.
4239   * @rmtoll CR1          EOBIE         LL_USART_IsEnabledIT_EOB
4240   * @param  USARTx USART Instance
4241   * @retval State of bit (1 or 0).
4242   */
LL_USART_IsEnabledIT_EOB(USART_TypeDef * USARTx)4243 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_EOB(USART_TypeDef *USARTx)
4244 {
4245   return ((READ_BIT(USARTx->CR1, USART_CR1_EOBIE) == (USART_CR1_EOBIE)) ? 1UL : 0UL);
4246 }
4247 
4248 #if defined(USART_CR1_FIFOEN)
4249 /**
4250   * @brief  Check if the USART TX FIFO Empty Interrupt is enabled or disabled
4251   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4252   *         FIFO mode feature is supported by the USARTx instance.
4253   * @rmtoll CR1          TXFEIE        LL_USART_IsEnabledIT_TXFE
4254   * @param  USARTx USART Instance
4255   * @retval State of bit (1 or 0).
4256   */
LL_USART_IsEnabledIT_TXFE(USART_TypeDef * USARTx)4257 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXFE(USART_TypeDef *USARTx)
4258 {
4259   return ((READ_BIT(USARTx->CR1, USART_CR1_TXFEIE) == (USART_CR1_TXFEIE)) ? 1UL : 0UL);
4260 }
4261 
4262 /**
4263   * @brief  Check if the USART RX FIFO Full Interrupt is enabled or disabled
4264   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4265   *         FIFO mode feature is supported by the USARTx instance.
4266   * @rmtoll CR1          RXFFIE        LL_USART_IsEnabledIT_RXFF
4267   * @param  USARTx USART Instance
4268   * @retval State of bit (1 or 0).
4269   */
LL_USART_IsEnabledIT_RXFF(USART_TypeDef * USARTx)4270 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXFF(USART_TypeDef *USARTx)
4271 {
4272   return ((READ_BIT(USARTx->CR1, USART_CR1_RXFFIE) == (USART_CR1_RXFFIE)) ? 1UL : 0UL);
4273 }
4274 
4275 #endif /* USART_CR1_FIFOEN */
4276 /**
4277   * @brief  Check if the USART LIN Break Detection Interrupt is enabled or disabled.
4278   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
4279   *         LIN feature is supported by the USARTx instance.
4280   * @rmtoll CR2          LBDIE         LL_USART_IsEnabledIT_LBD
4281   * @param  USARTx USART Instance
4282   * @retval State of bit (1 or 0).
4283   */
LL_USART_IsEnabledIT_LBD(USART_TypeDef * USARTx)4284 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(USART_TypeDef *USARTx)
4285 {
4286   return ((READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE)) ? 1UL : 0UL);
4287 }
4288 
4289 /**
4290   * @brief  Check if the USART Error Interrupt is enabled or disabled.
4291   * @rmtoll CR3          EIE           LL_USART_IsEnabledIT_ERROR
4292   * @param  USARTx USART Instance
4293   * @retval State of bit (1 or 0).
4294   */
LL_USART_IsEnabledIT_ERROR(USART_TypeDef * USARTx)4295 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(USART_TypeDef *USARTx)
4296 {
4297   return ((READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE)) ? 1UL : 0UL);
4298 }
4299 
4300 /**
4301   * @brief  Check if the USART CTS Interrupt is enabled or disabled.
4302   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
4303   *         Hardware Flow control feature is supported by the USARTx instance.
4304   * @rmtoll CR3          CTSIE         LL_USART_IsEnabledIT_CTS
4305   * @param  USARTx USART Instance
4306   * @retval State of bit (1 or 0).
4307   */
LL_USART_IsEnabledIT_CTS(USART_TypeDef * USARTx)4308 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(USART_TypeDef *USARTx)
4309 {
4310   return ((READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE)) ? 1UL : 0UL);
4311 }
4312 
4313 /**
4314   * @brief  Check if the USART Wake Up from Stop Mode Interrupt is enabled or disabled.
4315   * @note   Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
4316   *         Wake-up from Stop mode feature is supported by the USARTx instance.
4317   * @rmtoll CR3          WUFIE         LL_USART_IsEnabledIT_WKUP
4318   * @param  USARTx USART Instance
4319   * @retval State of bit (1 or 0).
4320   */
LL_USART_IsEnabledIT_WKUP(USART_TypeDef * USARTx)4321 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_WKUP(USART_TypeDef *USARTx)
4322 {
4323   return ((READ_BIT(USARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE)) ? 1UL : 0UL);
4324 }
4325 
4326 #if defined(USART_CR1_FIFOEN)
4327 /**
4328   * @brief  Check if USART TX FIFO Threshold Interrupt is enabled or disabled
4329   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4330   *         FIFO mode feature is supported by the USARTx instance.
4331   * @rmtoll CR3          TXFTIE        LL_USART_IsEnabledIT_TXFT
4332   * @param  USARTx USART Instance
4333   * @retval State of bit (1 or 0).
4334   */
LL_USART_IsEnabledIT_TXFT(USART_TypeDef * USARTx)4335 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXFT(USART_TypeDef *USARTx)
4336 {
4337   return ((READ_BIT(USARTx->CR3, USART_CR3_TXFTIE) == (USART_CR3_TXFTIE)) ? 1UL : 0UL);
4338 }
4339 
4340 #endif /* USART_CR1_FIFOEN */
4341 #if defined(USART_TCBGT_SUPPORT)
4342 /* Function available only on devices supporting Transmit Complete before Guard Time feature */
4343 /**
4344   * @brief  Check if the Smartcard Transmission Complete Before Guard Time Interrupt is enabled or disabled.
4345   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
4346   *         Smartcard feature is supported by the USARTx instance.
4347   * @rmtoll CR3          TCBGTIE       LL_USART_IsEnabledIT_TCBGT
4348   * @param  USARTx USART Instance
4349   * @retval State of bit (1 or 0).
4350   */
LL_USART_IsEnabledIT_TCBGT(USART_TypeDef * USARTx)4351 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TCBGT(USART_TypeDef *USARTx)
4352 {
4353   return ((READ_BIT(USARTx->CR3, USART_CR3_TCBGTIE) == (USART_CR3_TCBGTIE)) ? 1UL : 0UL);
4354 }
4355 #endif /* USART_TCBGT_SUPPORT */
4356 
4357 #if defined(USART_CR1_FIFOEN)
4358 /**
4359   * @brief  Check if USART RX FIFO Threshold Interrupt is enabled or disabled
4360   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4361   *         FIFO mode feature is supported by the USARTx instance.
4362   * @rmtoll CR3          RXFTIE        LL_USART_IsEnabledIT_RXFT
4363   * @param  USARTx USART Instance
4364   * @retval State of bit (1 or 0).
4365   */
LL_USART_IsEnabledIT_RXFT(USART_TypeDef * USARTx)4366 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXFT(USART_TypeDef *USARTx)
4367 {
4368   return ((READ_BIT(USARTx->CR3, USART_CR3_RXFTIE) == (USART_CR3_RXFTIE)) ? 1UL : 0UL);
4369 }
4370 
4371 #endif /* USART_CR1_FIFOEN */
4372 /**
4373   * @}
4374   */
4375 
4376 /** @defgroup USART_LL_EF_DMA_Management DMA_Management
4377   * @{
4378   */
4379 
4380 /**
4381   * @brief  Enable DMA Mode for reception
4382   * @rmtoll CR3          DMAR          LL_USART_EnableDMAReq_RX
4383   * @param  USARTx USART Instance
4384   * @retval None
4385   */
LL_USART_EnableDMAReq_RX(USART_TypeDef * USARTx)4386 __STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx)
4387 {
4388   SET_BIT(USARTx->CR3, USART_CR3_DMAR);
4389 }
4390 
4391 /**
4392   * @brief  Disable DMA Mode for reception
4393   * @rmtoll CR3          DMAR          LL_USART_DisableDMAReq_RX
4394   * @param  USARTx USART Instance
4395   * @retval None
4396   */
LL_USART_DisableDMAReq_RX(USART_TypeDef * USARTx)4397 __STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx)
4398 {
4399   CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR);
4400 }
4401 
4402 /**
4403   * @brief  Check if DMA Mode is enabled for reception
4404   * @rmtoll CR3          DMAR          LL_USART_IsEnabledDMAReq_RX
4405   * @param  USARTx USART Instance
4406   * @retval State of bit (1 or 0).
4407   */
LL_USART_IsEnabledDMAReq_RX(USART_TypeDef * USARTx)4408 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(USART_TypeDef *USARTx)
4409 {
4410   return ((READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR)) ? 1UL : 0UL);
4411 }
4412 
4413 /**
4414   * @brief  Enable DMA Mode for transmission
4415   * @rmtoll CR3          DMAT          LL_USART_EnableDMAReq_TX
4416   * @param  USARTx USART Instance
4417   * @retval None
4418   */
LL_USART_EnableDMAReq_TX(USART_TypeDef * USARTx)4419 __STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx)
4420 {
4421   SET_BIT(USARTx->CR3, USART_CR3_DMAT);
4422 }
4423 
4424 /**
4425   * @brief  Disable DMA Mode for transmission
4426   * @rmtoll CR3          DMAT          LL_USART_DisableDMAReq_TX
4427   * @param  USARTx USART Instance
4428   * @retval None
4429   */
LL_USART_DisableDMAReq_TX(USART_TypeDef * USARTx)4430 __STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx)
4431 {
4432   CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT);
4433 }
4434 
4435 /**
4436   * @brief  Check if DMA Mode is enabled for transmission
4437   * @rmtoll CR3          DMAT          LL_USART_IsEnabledDMAReq_TX
4438   * @param  USARTx USART Instance
4439   * @retval State of bit (1 or 0).
4440   */
LL_USART_IsEnabledDMAReq_TX(USART_TypeDef * USARTx)4441 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(USART_TypeDef *USARTx)
4442 {
4443   return ((READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT)) ? 1UL : 0UL);
4444 }
4445 
4446 /**
4447   * @brief  Enable DMA Disabling on Reception Error
4448   * @rmtoll CR3          DDRE          LL_USART_EnableDMADeactOnRxErr
4449   * @param  USARTx USART Instance
4450   * @retval None
4451   */
LL_USART_EnableDMADeactOnRxErr(USART_TypeDef * USARTx)4452 __STATIC_INLINE void LL_USART_EnableDMADeactOnRxErr(USART_TypeDef *USARTx)
4453 {
4454   SET_BIT(USARTx->CR3, USART_CR3_DDRE);
4455 }
4456 
4457 /**
4458   * @brief  Disable DMA Disabling on Reception Error
4459   * @rmtoll CR3          DDRE          LL_USART_DisableDMADeactOnRxErr
4460   * @param  USARTx USART Instance
4461   * @retval None
4462   */
LL_USART_DisableDMADeactOnRxErr(USART_TypeDef * USARTx)4463 __STATIC_INLINE void LL_USART_DisableDMADeactOnRxErr(USART_TypeDef *USARTx)
4464 {
4465   CLEAR_BIT(USARTx->CR3, USART_CR3_DDRE);
4466 }
4467 
4468 /**
4469   * @brief  Indicate if DMA Disabling on Reception Error is disabled
4470   * @rmtoll CR3          DDRE          LL_USART_IsEnabledDMADeactOnRxErr
4471   * @param  USARTx USART Instance
4472   * @retval State of bit (1 or 0).
4473   */
LL_USART_IsEnabledDMADeactOnRxErr(USART_TypeDef * USARTx)4474 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMADeactOnRxErr(USART_TypeDef *USARTx)
4475 {
4476   return ((READ_BIT(USARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE)) ? 1UL : 0UL);
4477 }
4478 
4479 /**
4480   * @brief  Get the data register address used for DMA transfer
4481   * @rmtoll RDR          RDR           LL_USART_DMA_GetRegAddr\n
4482   * @rmtoll TDR          TDR           LL_USART_DMA_GetRegAddr
4483   * @param  USARTx USART Instance
4484   * @param  Direction This parameter can be one of the following values:
4485   *         @arg @ref LL_USART_DMA_REG_DATA_TRANSMIT
4486   *         @arg @ref LL_USART_DMA_REG_DATA_RECEIVE
4487   * @retval Address of data register
4488   */
LL_USART_DMA_GetRegAddr(USART_TypeDef * USARTx,uint32_t Direction)4489 __STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(USART_TypeDef *USARTx, uint32_t Direction)
4490 {
4491   register uint32_t data_reg_addr;
4492 
4493   if (Direction == LL_USART_DMA_REG_DATA_TRANSMIT)
4494   {
4495     /* return address of TDR register */
4496     data_reg_addr = (uint32_t) &(USARTx->TDR);
4497   }
4498   else
4499   {
4500     /* return address of RDR register */
4501     data_reg_addr = (uint32_t) &(USARTx->RDR);
4502   }
4503 
4504   return data_reg_addr;
4505 }
4506 
4507 /**
4508   * @}
4509   */
4510 
4511 /** @defgroup USART_LL_EF_Data_Management Data_Management
4512   * @{
4513   */
4514 
4515 /**
4516   * @brief  Read Receiver Data register (Receive Data value, 8 bits)
4517   * @rmtoll RDR          RDR           LL_USART_ReceiveData8
4518   * @param  USARTx USART Instance
4519   * @retval Value between Min_Data=0x00 and Max_Data=0xFF
4520   */
LL_USART_ReceiveData8(USART_TypeDef * USARTx)4521 __STATIC_INLINE uint8_t LL_USART_ReceiveData8(USART_TypeDef *USARTx)
4522 {
4523   return (uint8_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR) & 0xFFU);
4524 }
4525 
4526 /**
4527   * @brief  Read Receiver Data register (Receive Data value, 9 bits)
4528   * @rmtoll RDR          RDR           LL_USART_ReceiveData9
4529   * @param  USARTx USART Instance
4530   * @retval Value between Min_Data=0x00 and Max_Data=0x1FF
4531   */
LL_USART_ReceiveData9(USART_TypeDef * USARTx)4532 __STATIC_INLINE uint16_t LL_USART_ReceiveData9(USART_TypeDef *USARTx)
4533 {
4534   return (uint16_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR));
4535 }
4536 
4537 /**
4538   * @brief  Write in Transmitter Data Register (Transmit Data value, 8 bits)
4539   * @rmtoll TDR          TDR           LL_USART_TransmitData8
4540   * @param  USARTx USART Instance
4541   * @param  Value between Min_Data=0x00 and Max_Data=0xFF
4542   * @retval None
4543   */
LL_USART_TransmitData8(USART_TypeDef * USARTx,uint8_t Value)4544 __STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value)
4545 {
4546   USARTx->TDR = Value;
4547 }
4548 
4549 /**
4550   * @brief  Write in Transmitter Data Register (Transmit Data value, 9 bits)
4551   * @rmtoll TDR          TDR           LL_USART_TransmitData9
4552   * @param  USARTx USART Instance
4553   * @param  Value between Min_Data=0x00 and Max_Data=0x1FF
4554   * @retval None
4555   */
LL_USART_TransmitData9(USART_TypeDef * USARTx,uint16_t Value)4556 __STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value)
4557 {
4558   USARTx->TDR = (uint16_t)(Value & 0x1FFUL);
4559 }
4560 
4561 /**
4562   * @}
4563   */
4564 
4565 /** @defgroup USART_LL_EF_Execution Execution
4566   * @{
4567   */
4568 
4569 /**
4570   * @brief  Request an Automatic Baud Rate measurement on next received data frame
4571   * @note   Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
4572   *         Auto Baud Rate detection feature is supported by the USARTx instance.
4573   * @rmtoll RQR          ABRRQ         LL_USART_RequestAutoBaudRate
4574   * @param  USARTx USART Instance
4575   * @retval None
4576   */
LL_USART_RequestAutoBaudRate(USART_TypeDef * USARTx)4577 __STATIC_INLINE void LL_USART_RequestAutoBaudRate(USART_TypeDef *USARTx)
4578 {
4579   SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_ABRRQ);
4580 }
4581 
4582 /**
4583   * @brief  Request Break sending
4584   * @rmtoll RQR          SBKRQ         LL_USART_RequestBreakSending
4585   * @param  USARTx USART Instance
4586   * @retval None
4587   */
LL_USART_RequestBreakSending(USART_TypeDef * USARTx)4588 __STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx)
4589 {
4590   SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_SBKRQ);
4591 }
4592 
4593 /**
4594   * @brief  Put USART in mute mode and set the RWU flag
4595   * @rmtoll RQR          MMRQ          LL_USART_RequestEnterMuteMode
4596   * @param  USARTx USART Instance
4597   * @retval None
4598   */
LL_USART_RequestEnterMuteMode(USART_TypeDef * USARTx)4599 __STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx)
4600 {
4601   SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_MMRQ);
4602 }
4603 
4604 /**
4605   @if USART_CR1_FIFOEN
4606   * @brief  Request a Receive Data and FIFO flush
4607   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4608   *         FIFO mode feature is supported by the USARTx instance.
4609   * @note   Allows to discard the received data without reading them, and avoid an overrun
4610   *         condition.
4611   @else
4612   * @brief  Request a Receive Data flush
4613   @endif
4614   * @rmtoll RQR          RXFRQ         LL_USART_RequestRxDataFlush
4615   * @param  USARTx USART Instance
4616   * @retval None
4617   */
LL_USART_RequestRxDataFlush(USART_TypeDef * USARTx)4618 __STATIC_INLINE void LL_USART_RequestRxDataFlush(USART_TypeDef *USARTx)
4619 {
4620   SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_RXFRQ);
4621 }
4622 
4623 /**
4624   @if USART_CR1_FIFOEN
4625   * @brief  Request a Transmit data and FIFO flush
4626   * @note   Macro @ref IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not
4627   *         FIFO mode feature is supported by the USARTx instance.
4628   @else
4629   * @brief  Request a Transmit data flush
4630   @endif
4631   * @rmtoll RQR          TXFRQ         LL_USART_RequestTxDataFlush
4632   * @param  USARTx USART Instance
4633   * @retval None
4634   */
LL_USART_RequestTxDataFlush(USART_TypeDef * USARTx)4635 __STATIC_INLINE void LL_USART_RequestTxDataFlush(USART_TypeDef *USARTx)
4636 {
4637   SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_TXFRQ);
4638 }
4639 
4640 /**
4641   * @}
4642   */
4643 
4644 #if defined(USE_FULL_LL_DRIVER)
4645 /** @defgroup USART_LL_EF_Init Initialization and de-initialization functions
4646   * @{
4647   */
4648 ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx);
4649 ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct);
4650 void        LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct);
4651 ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
4652 void        LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
4653 /**
4654   * @}
4655   */
4656 #endif /* USE_FULL_LL_DRIVER */
4657 
4658 /**
4659   * @}
4660   */
4661 
4662 /**
4663   * @}
4664   */
4665 
4666 #endif /* USART1 || USART2 || USART3 || UART4 || UART5 */
4667 
4668 /**
4669   * @}
4670   */
4671 
4672 #ifdef __cplusplus
4673 }
4674 #endif
4675 
4676 #endif /* STM32L4xx_LL_USART_H */
4677 
4678 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
4679