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