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