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