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