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