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