Mercurial > public > ostc4
comparison Common/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usart.h @ 160:e3ca52b8e7fa
Merge with FlipDisplay
author | heinrichsweikamp |
---|---|
date | Thu, 07 Mar 2019 15:06:43 +0100 |
parents | c78bcbd5deda |
children |
comparison
equal
deleted
inserted
replaced
80:cc2bb7bb8456 | 160:e3ca52b8e7fa |
---|---|
1 /** | |
2 ****************************************************************************** | |
3 * @file stm32f4xx_ll_usart.h | |
4 * @author MCD Application Team | |
5 * @brief Header file of USART LL module. | |
6 ****************************************************************************** | |
7 * @attention | |
8 * | |
9 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> | |
10 * | |
11 * Redistribution and use in source and binary forms, with or without modification, | |
12 * are permitted provided that the following conditions are met: | |
13 * 1. Redistributions of source code must retain the above copyright notice, | |
14 * this list of conditions and the following disclaimer. | |
15 * 2. Redistributions in binary form must reproduce the above copyright notice, | |
16 * this list of conditions and the following disclaimer in the documentation | |
17 * and/or other materials provided with the distribution. | |
18 * 3. Neither the name of STMicroelectronics nor the names of its contributors | |
19 * may be used to endorse or promote products derived from this software | |
20 * without specific prior written permission. | |
21 * | |
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 * | |
33 ****************************************************************************** | |
34 */ | |
35 | |
36 /* Define to prevent recursive inclusion -------------------------------------*/ | |
37 #ifndef __STM32F4xx_LL_USART_H | |
38 #define __STM32F4xx_LL_USART_H | |
39 | |
40 #ifdef __cplusplus | |
41 extern "C" { | |
42 #endif | |
43 | |
44 /* Includes ------------------------------------------------------------------*/ | |
45 #include "stm32f4xx.h" | |
46 | |
47 /** @addtogroup STM32F4xx_LL_Driver | |
48 * @{ | |
49 */ | |
50 | |
51 #if defined (USART1) || defined (USART2) || defined (USART3) || defined (USART6) || defined (UART4) || defined (UART5) || defined (UART7) || defined (UART8) || defined (UART9) || defined (UART10) | |
52 | |
53 /** @defgroup USART_LL USART | |
54 * @{ | |
55 */ | |
56 | |
57 /* Private types -------------------------------------------------------------*/ | |
58 /* Private variables ---------------------------------------------------------*/ | |
59 | |
60 /* Private constants ---------------------------------------------------------*/ | |
61 /** @defgroup USART_LL_Private_Constants USART Private Constants | |
62 * @{ | |
63 */ | |
64 | |
65 /* Defines used for the bit position in the register and perform offsets*/ | |
66 #define USART_POSITION_GTPR_GT USART_GTPR_GT_Pos | |
67 /** | |
68 * @} | |
69 */ | |
70 | |
71 /* Private macros ------------------------------------------------------------*/ | |
72 #if defined(USE_FULL_LL_DRIVER) | |
73 /** @defgroup USART_LL_Private_Macros USART Private Macros | |
74 * @{ | |
75 */ | |
76 /** | |
77 * @} | |
78 */ | |
79 #endif /*USE_FULL_LL_DRIVER*/ | |
80 | |
81 /* Exported types ------------------------------------------------------------*/ | |
82 #if defined(USE_FULL_LL_DRIVER) | |
83 /** @defgroup USART_LL_ES_INIT USART Exported Init structures | |
84 * @{ | |
85 */ | |
86 | |
87 /** | |
88 * @brief LL USART Init Structure definition | |
89 */ | |
90 typedef struct | |
91 { | |
92 uint32_t BaudRate; /*!< This field defines expected Usart communication baud rate. | |
93 | |
94 This feature can be modified afterwards using unitary function @ref LL_USART_SetBaudRate().*/ | |
95 | |
96 uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame. | |
97 This parameter can be a value of @ref USART_LL_EC_DATAWIDTH. | |
98 | |
99 This feature can be modified afterwards using unitary function @ref LL_USART_SetDataWidth().*/ | |
100 | |
101 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. | |
102 This parameter can be a value of @ref USART_LL_EC_STOPBITS. | |
103 | |
104 This feature can be modified afterwards using unitary function @ref LL_USART_SetStopBitsLength().*/ | |
105 | |
106 uint32_t Parity; /*!< Specifies the parity mode. | |
107 This parameter can be a value of @ref USART_LL_EC_PARITY. | |
108 | |
109 This feature can be modified afterwards using unitary function @ref LL_USART_SetParity().*/ | |
110 | |
111 uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled. | |
112 This parameter can be a value of @ref USART_LL_EC_DIRECTION. | |
113 | |
114 This feature can be modified afterwards using unitary function @ref LL_USART_SetTransferDirection().*/ | |
115 | |
116 uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled. | |
117 This parameter can be a value of @ref USART_LL_EC_HWCONTROL. | |
118 | |
119 This feature can be modified afterwards using unitary function @ref LL_USART_SetHWFlowCtrl().*/ | |
120 | |
121 uint32_t OverSampling; /*!< Specifies whether USART oversampling mode is 16 or 8. | |
122 This parameter can be a value of @ref USART_LL_EC_OVERSAMPLING. | |
123 | |
124 This feature can be modified afterwards using unitary function @ref LL_USART_SetOverSampling().*/ | |
125 | |
126 } LL_USART_InitTypeDef; | |
127 | |
128 /** | |
129 * @brief LL USART Clock Init Structure definition | |
130 */ | |
131 typedef struct | |
132 { | |
133 uint32_t ClockOutput; /*!< Specifies whether the USART clock is enabled or disabled. | |
134 This parameter can be a value of @ref USART_LL_EC_CLOCK. | |
135 | |
136 USART HW configuration can be modified afterwards using unitary functions | |
137 @ref LL_USART_EnableSCLKOutput() or @ref LL_USART_DisableSCLKOutput(). | |
138 For more details, refer to description of this function. */ | |
139 | |
140 uint32_t ClockPolarity; /*!< Specifies the steady state of the serial clock. | |
141 This parameter can be a value of @ref USART_LL_EC_POLARITY. | |
142 | |
143 USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPolarity(). | |
144 For more details, refer to description of this function. */ | |
145 | |
146 uint32_t ClockPhase; /*!< Specifies the clock transition on which the bit capture is made. | |
147 This parameter can be a value of @ref USART_LL_EC_PHASE. | |
148 | |
149 USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPhase(). | |
150 For more details, refer to description of this function. */ | |
151 | |
152 uint32_t LastBitClockPulse; /*!< Specifies whether the clock pulse corresponding to the last transmitted | |
153 data bit (MSB) has to be output on the SCLK pin in synchronous mode. | |
154 This parameter can be a value of @ref USART_LL_EC_LASTCLKPULSE. | |
155 | |
156 USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetLastClkPulseOutput(). | |
157 For more details, refer to description of this function. */ | |
158 | |
159 } LL_USART_ClockInitTypeDef; | |
160 | |
161 /** | |
162 * @} | |
163 */ | |
164 #endif /* USE_FULL_LL_DRIVER */ | |
165 | |
166 /* Exported constants --------------------------------------------------------*/ | |
167 /** @defgroup USART_LL_Exported_Constants USART Exported Constants | |
168 * @{ | |
169 */ | |
170 | |
171 /** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines | |
172 * @brief Flags defines which can be used with LL_USART_ReadReg function | |
173 * @{ | |
174 */ | |
175 #define LL_USART_SR_PE USART_SR_PE /*!< Parity error flag */ | |
176 #define LL_USART_SR_FE USART_SR_FE /*!< Framing error flag */ | |
177 #define LL_USART_SR_NE USART_SR_NE /*!< Noise detected flag */ | |
178 #define LL_USART_SR_ORE USART_SR_ORE /*!< Overrun error flag */ | |
179 #define LL_USART_SR_IDLE USART_SR_IDLE /*!< Idle line detected flag */ | |
180 #define LL_USART_SR_RXNE USART_SR_RXNE /*!< Read data register not empty flag */ | |
181 #define LL_USART_SR_TC USART_SR_TC /*!< Transmission complete flag */ | |
182 #define LL_USART_SR_TXE USART_SR_TXE /*!< Transmit data register empty flag */ | |
183 #define LL_USART_SR_LBD USART_SR_LBD /*!< LIN break detection flag */ | |
184 #define LL_USART_SR_CTS USART_SR_CTS /*!< CTS flag */ | |
185 /** | |
186 * @} | |
187 */ | |
188 | |
189 /** @defgroup USART_LL_EC_IT IT Defines | |
190 * @brief IT defines which can be used with LL_USART_ReadReg and LL_USART_WriteReg functions | |
191 * @{ | |
192 */ | |
193 #define LL_USART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */ | |
194 #define LL_USART_CR1_RXNEIE USART_CR1_RXNEIE /*!< Read data register not empty interrupt enable */ | |
195 #define LL_USART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */ | |
196 #define LL_USART_CR1_TXEIE USART_CR1_TXEIE /*!< Transmit data register empty interrupt enable */ | |
197 #define LL_USART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */ | |
198 #define LL_USART_CR2_LBDIE USART_CR2_LBDIE /*!< LIN break detection interrupt enable */ | |
199 #define LL_USART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */ | |
200 #define LL_USART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */ | |
201 /** | |
202 * @} | |
203 */ | |
204 | |
205 /** @defgroup USART_LL_EC_DIRECTION Communication Direction | |
206 * @{ | |
207 */ | |
208 #define LL_USART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */ | |
209 #define LL_USART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */ | |
210 #define LL_USART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */ | |
211 #define LL_USART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */ | |
212 /** | |
213 * @} | |
214 */ | |
215 | |
216 /** @defgroup USART_LL_EC_PARITY Parity Control | |
217 * @{ | |
218 */ | |
219 #define LL_USART_PARITY_NONE 0x00000000U /*!< Parity control disabled */ | |
220 #define LL_USART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */ | |
221 #define LL_USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */ | |
222 /** | |
223 * @} | |
224 */ | |
225 | |
226 /** @defgroup USART_LL_EC_WAKEUP Wakeup | |
227 * @{ | |
228 */ | |
229 #define LL_USART_WAKEUP_IDLELINE 0x00000000U /*!< USART wake up from Mute mode on Idle Line */ | |
230 #define LL_USART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< USART wake up from Mute mode on Address Mark */ | |
231 /** | |
232 * @} | |
233 */ | |
234 | |
235 /** @defgroup USART_LL_EC_DATAWIDTH Datawidth | |
236 * @{ | |
237 */ | |
238 #define LL_USART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */ | |
239 #define LL_USART_DATAWIDTH_9B USART_CR1_M /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */ | |
240 /** | |
241 * @} | |
242 */ | |
243 | |
244 /** @defgroup USART_LL_EC_OVERSAMPLING Oversampling | |
245 * @{ | |
246 */ | |
247 #define LL_USART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */ | |
248 #define LL_USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */ | |
249 /** | |
250 * @} | |
251 */ | |
252 | |
253 #if defined(USE_FULL_LL_DRIVER) | |
254 /** @defgroup USART_LL_EC_CLOCK Clock Signal | |
255 * @{ | |
256 */ | |
257 | |
258 #define LL_USART_CLOCK_DISABLE 0x00000000U /*!< Clock signal not provided */ | |
259 #define LL_USART_CLOCK_ENABLE USART_CR2_CLKEN /*!< Clock signal provided */ | |
260 /** | |
261 * @} | |
262 */ | |
263 #endif /*USE_FULL_LL_DRIVER*/ | |
264 | |
265 /** @defgroup USART_LL_EC_LASTCLKPULSE Last Clock Pulse | |
266 * @{ | |
267 */ | |
268 #define LL_USART_LASTCLKPULSE_NO_OUTPUT 0x00000000U /*!< The clock pulse of the last data bit is not output to the SCLK pin */ | |
269 #define LL_USART_LASTCLKPULSE_OUTPUT USART_CR2_LBCL /*!< The clock pulse of the last data bit is output to the SCLK pin */ | |
270 /** | |
271 * @} | |
272 */ | |
273 | |
274 /** @defgroup USART_LL_EC_PHASE Clock Phase | |
275 * @{ | |
276 */ | |
277 #define LL_USART_PHASE_1EDGE 0x00000000U /*!< The first clock transition is the first data capture edge */ | |
278 #define LL_USART_PHASE_2EDGE USART_CR2_CPHA /*!< The second clock transition is the first data capture edge */ | |
279 /** | |
280 * @} | |
281 */ | |
282 | |
283 /** @defgroup USART_LL_EC_POLARITY Clock Polarity | |
284 * @{ | |
285 */ | |
286 #define LL_USART_POLARITY_LOW 0x00000000U /*!< Steady low value on SCLK pin outside transmission window*/ | |
287 #define LL_USART_POLARITY_HIGH USART_CR2_CPOL /*!< Steady high value on SCLK pin outside transmission window */ | |
288 /** | |
289 * @} | |
290 */ | |
291 | |
292 /** @defgroup USART_LL_EC_STOPBITS Stop Bits | |
293 * @{ | |
294 */ | |
295 #define LL_USART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< 0.5 stop bit */ | |
296 #define LL_USART_STOPBITS_1 0x00000000U /*!< 1 stop bit */ | |
297 #define LL_USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< 1.5 stop bits */ | |
298 #define LL_USART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */ | |
299 /** | |
300 * @} | |
301 */ | |
302 | |
303 /** @defgroup USART_LL_EC_HWCONTROL Hardware Control | |
304 * @{ | |
305 */ | |
306 #define LL_USART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */ | |
307 #define LL_USART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */ | |
308 #define LL_USART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */ | |
309 #define LL_USART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */ | |
310 /** | |
311 * @} | |
312 */ | |
313 | |
314 /** @defgroup USART_LL_EC_IRDA_POWER IrDA Power | |
315 * @{ | |
316 */ | |
317 #define LL_USART_IRDA_POWER_NORMAL 0x00000000U /*!< IrDA normal power mode */ | |
318 #define LL_USART_IRDA_POWER_LOW USART_CR3_IRLP /*!< IrDA low power mode */ | |
319 /** | |
320 * @} | |
321 */ | |
322 | |
323 /** @defgroup USART_LL_EC_LINBREAK_DETECT LIN Break Detection Length | |
324 * @{ | |
325 */ | |
326 #define LL_USART_LINBREAK_DETECT_10B 0x00000000U /*!< 10-bit break detection method selected */ | |
327 #define LL_USART_LINBREAK_DETECT_11B USART_CR2_LBDL /*!< 11-bit break detection method selected */ | |
328 /** | |
329 * @} | |
330 */ | |
331 | |
332 /** | |
333 * @} | |
334 */ | |
335 | |
336 /* Exported macro ------------------------------------------------------------*/ | |
337 /** @defgroup USART_LL_Exported_Macros USART Exported Macros | |
338 * @{ | |
339 */ | |
340 | |
341 /** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros | |
342 * @{ | |
343 */ | |
344 | |
345 /** | |
346 * @brief Write a value in USART register | |
347 * @param __INSTANCE__ USART Instance | |
348 * @param __REG__ Register to be written | |
349 * @param __VALUE__ Value to be written in the register | |
350 * @retval None | |
351 */ | |
352 #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) | |
353 | |
354 /** | |
355 * @brief Read a value in USART register | |
356 * @param __INSTANCE__ USART Instance | |
357 * @param __REG__ Register to be read | |
358 * @retval Register value | |
359 */ | |
360 #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) | |
361 /** | |
362 * @} | |
363 */ | |
364 | |
365 /** @defgroup USART_LL_EM_Exported_Macros_Helper Exported_Macros_Helper | |
366 * @{ | |
367 */ | |
368 | |
369 /** | |
370 * @brief Compute USARTDIV value according to Peripheral Clock and | |
371 * expected Baud Rate in 8 bits sampling mode (32 bits value of USARTDIV is returned) | |
372 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance | |
373 * @param __BAUDRATE__ Baud rate value to achieve | |
374 * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case | |
375 */ | |
376 #define __LL_USART_DIV_SAMPLING8_100(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__)*25)/(2*(__BAUDRATE__))) | |
377 #define __LL_USART_DIVMANT_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (__LL_USART_DIV_SAMPLING8_100((__PERIPHCLK__), (__BAUDRATE__))/100) | |
378 #define __LL_USART_DIVFRAQ_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIV_SAMPLING8_100((__PERIPHCLK__), (__BAUDRATE__)) - (__LL_USART_DIVMANT_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) * 100)) * 8 + 50) / 100) | |
379 /* UART BRR = mantissa + overflow + fraction | |
380 = (UART DIVMANT << 4) + ((UART DIVFRAQ & 0xF8) << 1) + (UART DIVFRAQ & 0x07) */ | |
381 #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIVMANT_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) << 4) + \ | |
382 ((__LL_USART_DIVFRAQ_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) & 0xF8) << 1)) + \ | |
383 (__LL_USART_DIVFRAQ_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) & 0x07)) | |
384 | |
385 /** | |
386 * @brief Compute USARTDIV value according to Peripheral Clock and | |
387 * expected Baud Rate in 16 bits sampling mode (32 bits value of USARTDIV is returned) | |
388 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance | |
389 * @param __BAUDRATE__ Baud rate value to achieve | |
390 * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case | |
391 */ | |
392 #define __LL_USART_DIV_SAMPLING16_100(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__)*25)/(4*(__BAUDRATE__))) | |
393 #define __LL_USART_DIVMANT_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (__LL_USART_DIV_SAMPLING16_100((__PERIPHCLK__), (__BAUDRATE__))/100) | |
394 #define __LL_USART_DIVFRAQ_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIV_SAMPLING16_100((__PERIPHCLK__), (__BAUDRATE__)) - (__LL_USART_DIVMANT_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) * 100)) * 16 + 50) / 100) | |
395 /* USART BRR = mantissa + overflow + fraction | |
396 = (USART DIVMANT << 4) + (USART DIVFRAQ & 0xF0) + (USART DIVFRAQ & 0x0F) */ | |
397 #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIVMANT_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) << 4) + \ | |
398 (__LL_USART_DIVFRAQ_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) & 0xF0)) + \ | |
399 (__LL_USART_DIVFRAQ_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) & 0x0F)) | |
400 | |
401 /** | |
402 * @} | |
403 */ | |
404 | |
405 /** | |
406 * @} | |
407 */ | |
408 | |
409 /* Exported functions --------------------------------------------------------*/ | |
410 | |
411 /** @defgroup USART_LL_Exported_Functions USART Exported Functions | |
412 * @{ | |
413 */ | |
414 | |
415 /** @defgroup USART_LL_EF_Configuration Configuration functions | |
416 * @{ | |
417 */ | |
418 | |
419 /** | |
420 * @brief USART Enable | |
421 * @rmtoll CR1 UE LL_USART_Enable | |
422 * @param USARTx USART Instance | |
423 * @retval None | |
424 */ | |
425 __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx) | |
426 { | |
427 SET_BIT(USARTx->CR1, USART_CR1_UE); | |
428 } | |
429 | |
430 /** | |
431 * @brief USART Disable (all USART prescalers and outputs are disabled) | |
432 * @note When USART is disabled, USART prescalers and outputs are stopped immediately, | |
433 * and current operations are discarded. The configuration of the USART is kept, but all the status | |
434 * flags, in the USARTx_SR are set to their default values. | |
435 * @rmtoll CR1 UE LL_USART_Disable | |
436 * @param USARTx USART Instance | |
437 * @retval None | |
438 */ | |
439 __STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx) | |
440 { | |
441 CLEAR_BIT(USARTx->CR1, USART_CR1_UE); | |
442 } | |
443 | |
444 /** | |
445 * @brief Indicate if USART is enabled | |
446 * @rmtoll CR1 UE LL_USART_IsEnabled | |
447 * @param USARTx USART Instance | |
448 * @retval State of bit (1 or 0). | |
449 */ | |
450 __STATIC_INLINE uint32_t LL_USART_IsEnabled(USART_TypeDef *USARTx) | |
451 { | |
452 return (READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE)); | |
453 } | |
454 | |
455 /** | |
456 * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit) | |
457 * @rmtoll CR1 RE LL_USART_EnableDirectionRx | |
458 * @param USARTx USART Instance | |
459 * @retval None | |
460 */ | |
461 __STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx) | |
462 { | |
463 SET_BIT(USARTx->CR1, USART_CR1_RE); | |
464 } | |
465 | |
466 /** | |
467 * @brief Receiver Disable | |
468 * @rmtoll CR1 RE LL_USART_DisableDirectionRx | |
469 * @param USARTx USART Instance | |
470 * @retval None | |
471 */ | |
472 __STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx) | |
473 { | |
474 CLEAR_BIT(USARTx->CR1, USART_CR1_RE); | |
475 } | |
476 | |
477 /** | |
478 * @brief Transmitter Enable | |
479 * @rmtoll CR1 TE LL_USART_EnableDirectionTx | |
480 * @param USARTx USART Instance | |
481 * @retval None | |
482 */ | |
483 __STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx) | |
484 { | |
485 SET_BIT(USARTx->CR1, USART_CR1_TE); | |
486 } | |
487 | |
488 /** | |
489 * @brief Transmitter Disable | |
490 * @rmtoll CR1 TE LL_USART_DisableDirectionTx | |
491 * @param USARTx USART Instance | |
492 * @retval None | |
493 */ | |
494 __STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx) | |
495 { | |
496 CLEAR_BIT(USARTx->CR1, USART_CR1_TE); | |
497 } | |
498 | |
499 /** | |
500 * @brief Configure simultaneously enabled/disabled states | |
501 * of Transmitter and Receiver | |
502 * @rmtoll CR1 RE LL_USART_SetTransferDirection\n | |
503 * CR1 TE LL_USART_SetTransferDirection | |
504 * @param USARTx USART Instance | |
505 * @param TransferDirection This parameter can be one of the following values: | |
506 * @arg @ref LL_USART_DIRECTION_NONE | |
507 * @arg @ref LL_USART_DIRECTION_RX | |
508 * @arg @ref LL_USART_DIRECTION_TX | |
509 * @arg @ref LL_USART_DIRECTION_TX_RX | |
510 * @retval None | |
511 */ | |
512 __STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t TransferDirection) | |
513 { | |
514 MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection); | |
515 } | |
516 | |
517 /** | |
518 * @brief Return enabled/disabled states of Transmitter and Receiver | |
519 * @rmtoll CR1 RE LL_USART_GetTransferDirection\n | |
520 * CR1 TE LL_USART_GetTransferDirection | |
521 * @param USARTx USART Instance | |
522 * @retval Returned value can be one of the following values: | |
523 * @arg @ref LL_USART_DIRECTION_NONE | |
524 * @arg @ref LL_USART_DIRECTION_RX | |
525 * @arg @ref LL_USART_DIRECTION_TX | |
526 * @arg @ref LL_USART_DIRECTION_TX_RX | |
527 */ | |
528 __STATIC_INLINE uint32_t LL_USART_GetTransferDirection(USART_TypeDef *USARTx) | |
529 { | |
530 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE)); | |
531 } | |
532 | |
533 /** | |
534 * @brief Configure Parity (enabled/disabled and parity mode if enabled). | |
535 * @note This function selects if hardware parity control (generation and detection) is enabled or disabled. | |
536 * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position | |
537 * (9th or 8th bit depending on data width) and parity is checked on the received data. | |
538 * @rmtoll CR1 PS LL_USART_SetParity\n | |
539 * CR1 PCE LL_USART_SetParity | |
540 * @param USARTx USART Instance | |
541 * @param Parity This parameter can be one of the following values: | |
542 * @arg @ref LL_USART_PARITY_NONE | |
543 * @arg @ref LL_USART_PARITY_EVEN | |
544 * @arg @ref LL_USART_PARITY_ODD | |
545 * @retval None | |
546 */ | |
547 __STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t Parity) | |
548 { | |
549 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity); | |
550 } | |
551 | |
552 /** | |
553 * @brief Return Parity configuration (enabled/disabled and parity mode if enabled) | |
554 * @rmtoll CR1 PS LL_USART_GetParity\n | |
555 * CR1 PCE LL_USART_GetParity | |
556 * @param USARTx USART Instance | |
557 * @retval Returned value can be one of the following values: | |
558 * @arg @ref LL_USART_PARITY_NONE | |
559 * @arg @ref LL_USART_PARITY_EVEN | |
560 * @arg @ref LL_USART_PARITY_ODD | |
561 */ | |
562 __STATIC_INLINE uint32_t LL_USART_GetParity(USART_TypeDef *USARTx) | |
563 { | |
564 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE)); | |
565 } | |
566 | |
567 /** | |
568 * @brief Set Receiver Wake Up method from Mute mode. | |
569 * @rmtoll CR1 WAKE LL_USART_SetWakeUpMethod | |
570 * @param USARTx USART Instance | |
571 * @param Method This parameter can be one of the following values: | |
572 * @arg @ref LL_USART_WAKEUP_IDLELINE | |
573 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK | |
574 * @retval None | |
575 */ | |
576 __STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method) | |
577 { | |
578 MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method); | |
579 } | |
580 | |
581 /** | |
582 * @brief Return Receiver Wake Up method from Mute mode | |
583 * @rmtoll CR1 WAKE LL_USART_GetWakeUpMethod | |
584 * @param USARTx USART Instance | |
585 * @retval Returned value can be one of the following values: | |
586 * @arg @ref LL_USART_WAKEUP_IDLELINE | |
587 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK | |
588 */ | |
589 __STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(USART_TypeDef *USARTx) | |
590 { | |
591 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE)); | |
592 } | |
593 | |
594 /** | |
595 * @brief Set Word length (i.e. nb of data bits, excluding start and stop bits) | |
596 * @rmtoll CR1 M LL_USART_SetDataWidth | |
597 * @param USARTx USART Instance | |
598 * @param DataWidth This parameter can be one of the following values: | |
599 * @arg @ref LL_USART_DATAWIDTH_8B | |
600 * @arg @ref LL_USART_DATAWIDTH_9B | |
601 * @retval None | |
602 */ | |
603 __STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth) | |
604 { | |
605 MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth); | |
606 } | |
607 | |
608 /** | |
609 * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits) | |
610 * @rmtoll CR1 M LL_USART_GetDataWidth | |
611 * @param USARTx USART Instance | |
612 * @retval Returned value can be one of the following values: | |
613 * @arg @ref LL_USART_DATAWIDTH_8B | |
614 * @arg @ref LL_USART_DATAWIDTH_9B | |
615 */ | |
616 __STATIC_INLINE uint32_t LL_USART_GetDataWidth(USART_TypeDef *USARTx) | |
617 { | |
618 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M)); | |
619 } | |
620 | |
621 /** | |
622 * @brief Set Oversampling to 8-bit or 16-bit mode | |
623 * @rmtoll CR1 OVER8 LL_USART_SetOverSampling | |
624 * @param USARTx USART Instance | |
625 * @param OverSampling This parameter can be one of the following values: | |
626 * @arg @ref LL_USART_OVERSAMPLING_16 | |
627 * @arg @ref LL_USART_OVERSAMPLING_8 | |
628 * @retval None | |
629 */ | |
630 __STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling) | |
631 { | |
632 MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling); | |
633 } | |
634 | |
635 /** | |
636 * @brief Return Oversampling mode | |
637 * @rmtoll CR1 OVER8 LL_USART_GetOverSampling | |
638 * @param USARTx USART Instance | |
639 * @retval Returned value can be one of the following values: | |
640 * @arg @ref LL_USART_OVERSAMPLING_16 | |
641 * @arg @ref LL_USART_OVERSAMPLING_8 | |
642 */ | |
643 __STATIC_INLINE uint32_t LL_USART_GetOverSampling(USART_TypeDef *USARTx) | |
644 { | |
645 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8)); | |
646 } | |
647 | |
648 /** | |
649 * @brief Configure if Clock pulse of the last data bit is output to the SCLK pin or not | |
650 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not | |
651 * Synchronous mode is supported by the USARTx instance. | |
652 * @rmtoll CR2 LBCL LL_USART_SetLastClkPulseOutput | |
653 * @param USARTx USART Instance | |
654 * @param LastBitClockPulse This parameter can be one of the following values: | |
655 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT | |
656 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT | |
657 * @retval None | |
658 */ | |
659 __STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LastBitClockPulse) | |
660 { | |
661 MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LastBitClockPulse); | |
662 } | |
663 | |
664 /** | |
665 * @brief Retrieve Clock pulse of the last data bit output configuration | |
666 * (Last bit Clock pulse output to the SCLK pin or not) | |
667 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not | |
668 * Synchronous mode is supported by the USARTx instance. | |
669 * @rmtoll CR2 LBCL LL_USART_GetLastClkPulseOutput | |
670 * @param USARTx USART Instance | |
671 * @retval Returned value can be one of the following values: | |
672 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT | |
673 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT | |
674 */ | |
675 __STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(USART_TypeDef *USARTx) | |
676 { | |
677 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL)); | |
678 } | |
679 | |
680 /** | |
681 * @brief Select the phase of the clock output on the SCLK pin in synchronous mode | |
682 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not | |
683 * Synchronous mode is supported by the USARTx instance. | |
684 * @rmtoll CR2 CPHA LL_USART_SetClockPhase | |
685 * @param USARTx USART Instance | |
686 * @param ClockPhase This parameter can be one of the following values: | |
687 * @arg @ref LL_USART_PHASE_1EDGE | |
688 * @arg @ref LL_USART_PHASE_2EDGE | |
689 * @retval None | |
690 */ | |
691 __STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t ClockPhase) | |
692 { | |
693 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, ClockPhase); | |
694 } | |
695 | |
696 /** | |
697 * @brief Return phase of the clock output on the SCLK pin in synchronous mode | |
698 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not | |
699 * Synchronous mode is supported by the USARTx instance. | |
700 * @rmtoll CR2 CPHA LL_USART_GetClockPhase | |
701 * @param USARTx USART Instance | |
702 * @retval Returned value can be one of the following values: | |
703 * @arg @ref LL_USART_PHASE_1EDGE | |
704 * @arg @ref LL_USART_PHASE_2EDGE | |
705 */ | |
706 __STATIC_INLINE uint32_t LL_USART_GetClockPhase(USART_TypeDef *USARTx) | |
707 { | |
708 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA)); | |
709 } | |
710 | |
711 /** | |
712 * @brief Select the polarity of the clock output on the SCLK pin in synchronous mode | |
713 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not | |
714 * Synchronous mode is supported by the USARTx instance. | |
715 * @rmtoll CR2 CPOL LL_USART_SetClockPolarity | |
716 * @param USARTx USART Instance | |
717 * @param ClockPolarity This parameter can be one of the following values: | |
718 * @arg @ref LL_USART_POLARITY_LOW | |
719 * @arg @ref LL_USART_POLARITY_HIGH | |
720 * @retval None | |
721 */ | |
722 __STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t ClockPolarity) | |
723 { | |
724 MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, ClockPolarity); | |
725 } | |
726 | |
727 /** | |
728 * @brief Return polarity of the clock output on the SCLK pin in synchronous mode | |
729 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not | |
730 * Synchronous mode is supported by the USARTx instance. | |
731 * @rmtoll CR2 CPOL LL_USART_GetClockPolarity | |
732 * @param USARTx USART Instance | |
733 * @retval Returned value can be one of the following values: | |
734 * @arg @ref LL_USART_POLARITY_LOW | |
735 * @arg @ref LL_USART_POLARITY_HIGH | |
736 */ | |
737 __STATIC_INLINE uint32_t LL_USART_GetClockPolarity(USART_TypeDef *USARTx) | |
738 { | |
739 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL)); | |
740 } | |
741 | |
742 /** | |
743 * @brief Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse) | |
744 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not | |
745 * Synchronous mode is supported by the USARTx instance. | |
746 * @note Call of this function is equivalent to following function call sequence : | |
747 * - Clock Phase configuration using @ref LL_USART_SetClockPhase() function | |
748 * - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function | |
749 * - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function | |
750 * @rmtoll CR2 CPHA LL_USART_ConfigClock\n | |
751 * CR2 CPOL LL_USART_ConfigClock\n | |
752 * CR2 LBCL LL_USART_ConfigClock | |
753 * @param USARTx USART Instance | |
754 * @param Phase This parameter can be one of the following values: | |
755 * @arg @ref LL_USART_PHASE_1EDGE | |
756 * @arg @ref LL_USART_PHASE_2EDGE | |
757 * @param Polarity This parameter can be one of the following values: | |
758 * @arg @ref LL_USART_POLARITY_LOW | |
759 * @arg @ref LL_USART_POLARITY_HIGH | |
760 * @param LBCPOutput This parameter can be one of the following values: | |
761 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT | |
762 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT | |
763 * @retval None | |
764 */ | |
765 __STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput) | |
766 { | |
767 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput); | |
768 } | |
769 | |
770 /** | |
771 * @brief Enable Clock output on SCLK pin | |
772 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not | |
773 * Synchronous mode is supported by the USARTx instance. | |
774 * @rmtoll CR2 CLKEN LL_USART_EnableSCLKOutput | |
775 * @param USARTx USART Instance | |
776 * @retval None | |
777 */ | |
778 __STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx) | |
779 { | |
780 SET_BIT(USARTx->CR2, USART_CR2_CLKEN); | |
781 } | |
782 | |
783 /** | |
784 * @brief Disable Clock output on SCLK pin | |
785 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not | |
786 * Synchronous mode is supported by the USARTx instance. | |
787 * @rmtoll CR2 CLKEN LL_USART_DisableSCLKOutput | |
788 * @param USARTx USART Instance | |
789 * @retval None | |
790 */ | |
791 __STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx) | |
792 { | |
793 CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN); | |
794 } | |
795 | |
796 /** | |
797 * @brief Indicate if Clock output on SCLK pin is enabled | |
798 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not | |
799 * Synchronous mode is supported by the USARTx instance. | |
800 * @rmtoll CR2 CLKEN LL_USART_IsEnabledSCLKOutput | |
801 * @param USARTx USART Instance | |
802 * @retval State of bit (1 or 0). | |
803 */ | |
804 __STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(USART_TypeDef *USARTx) | |
805 { | |
806 return (READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN)); | |
807 } | |
808 | |
809 /** | |
810 * @brief Set the length of the stop bits | |
811 * @rmtoll CR2 STOP LL_USART_SetStopBitsLength | |
812 * @param USARTx USART Instance | |
813 * @param StopBits This parameter can be one of the following values: | |
814 * @arg @ref LL_USART_STOPBITS_0_5 | |
815 * @arg @ref LL_USART_STOPBITS_1 | |
816 * @arg @ref LL_USART_STOPBITS_1_5 | |
817 * @arg @ref LL_USART_STOPBITS_2 | |
818 * @retval None | |
819 */ | |
820 __STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits) | |
821 { | |
822 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits); | |
823 } | |
824 | |
825 /** | |
826 * @brief Retrieve the length of the stop bits | |
827 * @rmtoll CR2 STOP LL_USART_GetStopBitsLength | |
828 * @param USARTx USART Instance | |
829 * @retval Returned value can be one of the following values: | |
830 * @arg @ref LL_USART_STOPBITS_0_5 | |
831 * @arg @ref LL_USART_STOPBITS_1 | |
832 * @arg @ref LL_USART_STOPBITS_1_5 | |
833 * @arg @ref LL_USART_STOPBITS_2 | |
834 */ | |
835 __STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(USART_TypeDef *USARTx) | |
836 { | |
837 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP)); | |
838 } | |
839 | |
840 /** | |
841 * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits) | |
842 * @note Call of this function is equivalent to following function call sequence : | |
843 * - Data Width configuration using @ref LL_USART_SetDataWidth() function | |
844 * - Parity Control and mode configuration using @ref LL_USART_SetParity() function | |
845 * - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function | |
846 * @rmtoll CR1 PS LL_USART_ConfigCharacter\n | |
847 * CR1 PCE LL_USART_ConfigCharacter\n | |
848 * CR1 M LL_USART_ConfigCharacter\n | |
849 * CR2 STOP LL_USART_ConfigCharacter | |
850 * @param USARTx USART Instance | |
851 * @param DataWidth This parameter can be one of the following values: | |
852 * @arg @ref LL_USART_DATAWIDTH_8B | |
853 * @arg @ref LL_USART_DATAWIDTH_9B | |
854 * @param Parity This parameter can be one of the following values: | |
855 * @arg @ref LL_USART_PARITY_NONE | |
856 * @arg @ref LL_USART_PARITY_EVEN | |
857 * @arg @ref LL_USART_PARITY_ODD | |
858 * @param StopBits This parameter can be one of the following values: | |
859 * @arg @ref LL_USART_STOPBITS_0_5 | |
860 * @arg @ref LL_USART_STOPBITS_1 | |
861 * @arg @ref LL_USART_STOPBITS_1_5 | |
862 * @arg @ref LL_USART_STOPBITS_2 | |
863 * @retval None | |
864 */ | |
865 __STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t Parity, | |
866 uint32_t StopBits) | |
867 { | |
868 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth); | |
869 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits); | |
870 } | |
871 | |
872 /** | |
873 * @brief Set Address of the USART node. | |
874 * @note This is used in multiprocessor communication during Mute mode or Stop mode, | |
875 * for wake up with address mark detection. | |
876 * @rmtoll CR2 ADD LL_USART_SetNodeAddress | |
877 * @param USARTx USART Instance | |
878 * @param NodeAddress 4 bit Address of the USART node. | |
879 * @retval None | |
880 */ | |
881 __STATIC_INLINE void LL_USART_SetNodeAddress(USART_TypeDef *USARTx, uint32_t NodeAddress) | |
882 { | |
883 MODIFY_REG(USARTx->CR2, USART_CR2_ADD, (NodeAddress & USART_CR2_ADD)); | |
884 } | |
885 | |
886 /** | |
887 * @brief Return 4 bit Address of the USART node as set in ADD field of CR2. | |
888 * @note only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant) | |
889 * @rmtoll CR2 ADD LL_USART_GetNodeAddress | |
890 * @param USARTx USART Instance | |
891 * @retval Address of the USART node (Value between Min_Data=0 and Max_Data=255) | |
892 */ | |
893 __STATIC_INLINE uint32_t LL_USART_GetNodeAddress(USART_TypeDef *USARTx) | |
894 { | |
895 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD)); | |
896 } | |
897 | |
898 /** | |
899 * @brief Enable RTS HW Flow Control | |
900 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not | |
901 * Hardware Flow control feature is supported by the USARTx instance. | |
902 * @rmtoll CR3 RTSE LL_USART_EnableRTSHWFlowCtrl | |
903 * @param USARTx USART Instance | |
904 * @retval None | |
905 */ | |
906 __STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx) | |
907 { | |
908 SET_BIT(USARTx->CR3, USART_CR3_RTSE); | |
909 } | |
910 | |
911 /** | |
912 * @brief Disable RTS HW Flow Control | |
913 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not | |
914 * Hardware Flow control feature is supported by the USARTx instance. | |
915 * @rmtoll CR3 RTSE LL_USART_DisableRTSHWFlowCtrl | |
916 * @param USARTx USART Instance | |
917 * @retval None | |
918 */ | |
919 __STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx) | |
920 { | |
921 CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE); | |
922 } | |
923 | |
924 /** | |
925 * @brief Enable CTS HW Flow Control | |
926 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not | |
927 * Hardware Flow control feature is supported by the USARTx instance. | |
928 * @rmtoll CR3 CTSE LL_USART_EnableCTSHWFlowCtrl | |
929 * @param USARTx USART Instance | |
930 * @retval None | |
931 */ | |
932 __STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx) | |
933 { | |
934 SET_BIT(USARTx->CR3, USART_CR3_CTSE); | |
935 } | |
936 | |
937 /** | |
938 * @brief Disable CTS HW Flow Control | |
939 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not | |
940 * Hardware Flow control feature is supported by the USARTx instance. | |
941 * @rmtoll CR3 CTSE LL_USART_DisableCTSHWFlowCtrl | |
942 * @param USARTx USART Instance | |
943 * @retval None | |
944 */ | |
945 __STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx) | |
946 { | |
947 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE); | |
948 } | |
949 | |
950 /** | |
951 * @brief Configure HW Flow Control mode (both CTS and RTS) | |
952 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not | |
953 * Hardware Flow control feature is supported by the USARTx instance. | |
954 * @rmtoll CR3 RTSE LL_USART_SetHWFlowCtrl\n | |
955 * CR3 CTSE LL_USART_SetHWFlowCtrl | |
956 * @param USARTx USART Instance | |
957 * @param HardwareFlowControl This parameter can be one of the following values: | |
958 * @arg @ref LL_USART_HWCONTROL_NONE | |
959 * @arg @ref LL_USART_HWCONTROL_RTS | |
960 * @arg @ref LL_USART_HWCONTROL_CTS | |
961 * @arg @ref LL_USART_HWCONTROL_RTS_CTS | |
962 * @retval None | |
963 */ | |
964 __STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HardwareFlowControl) | |
965 { | |
966 MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl); | |
967 } | |
968 | |
969 /** | |
970 * @brief Return HW Flow Control configuration (both CTS and RTS) | |
971 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not | |
972 * Hardware Flow control feature is supported by the USARTx instance. | |
973 * @rmtoll CR3 RTSE LL_USART_GetHWFlowCtrl\n | |
974 * CR3 CTSE LL_USART_GetHWFlowCtrl | |
975 * @param USARTx USART Instance | |
976 * @retval Returned value can be one of the following values: | |
977 * @arg @ref LL_USART_HWCONTROL_NONE | |
978 * @arg @ref LL_USART_HWCONTROL_RTS | |
979 * @arg @ref LL_USART_HWCONTROL_CTS | |
980 * @arg @ref LL_USART_HWCONTROL_RTS_CTS | |
981 */ | |
982 __STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(USART_TypeDef *USARTx) | |
983 { | |
984 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE)); | |
985 } | |
986 | |
987 /** | |
988 * @brief Enable One bit sampling method | |
989 * @rmtoll CR3 ONEBIT LL_USART_EnableOneBitSamp | |
990 * @param USARTx USART Instance | |
991 * @retval None | |
992 */ | |
993 __STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx) | |
994 { | |
995 SET_BIT(USARTx->CR3, USART_CR3_ONEBIT); | |
996 } | |
997 | |
998 /** | |
999 * @brief Disable One bit sampling method | |
1000 * @rmtoll CR3 ONEBIT LL_USART_DisableOneBitSamp | |
1001 * @param USARTx USART Instance | |
1002 * @retval None | |
1003 */ | |
1004 __STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx) | |
1005 { | |
1006 CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT); | |
1007 } | |
1008 | |
1009 /** | |
1010 * @brief Indicate if One bit sampling method is enabled | |
1011 * @rmtoll CR3 ONEBIT LL_USART_IsEnabledOneBitSamp | |
1012 * @param USARTx USART Instance | |
1013 * @retval State of bit (1 or 0). | |
1014 */ | |
1015 __STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(USART_TypeDef *USARTx) | |
1016 { | |
1017 return (READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT)); | |
1018 } | |
1019 | |
1020 /** | |
1021 * @brief Configure USART BRR register for achieving expected Baud Rate value. | |
1022 * @note Compute and set USARTDIV value in BRR Register (full BRR content) | |
1023 * according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values | |
1024 * @note Peripheral clock and Baud rate values provided as function parameters should be valid | |
1025 * (Baud rate value != 0) | |
1026 * @rmtoll BRR BRR LL_USART_SetBaudRate | |
1027 * @param USARTx USART Instance | |
1028 * @param PeriphClk Peripheral Clock | |
1029 * @param OverSampling This parameter can be one of the following values: | |
1030 * @arg @ref LL_USART_OVERSAMPLING_16 | |
1031 * @arg @ref LL_USART_OVERSAMPLING_8 | |
1032 * @param BaudRate Baud Rate | |
1033 * @retval None | |
1034 */ | |
1035 __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling, | |
1036 uint32_t BaudRate) | |
1037 { | |
1038 if (OverSampling == LL_USART_OVERSAMPLING_8) | |
1039 { | |
1040 USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, BaudRate)); | |
1041 } | |
1042 else | |
1043 { | |
1044 USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate)); | |
1045 } | |
1046 } | |
1047 | |
1048 /** | |
1049 * @brief Return current Baud Rate value, according to USARTDIV present in BRR register | |
1050 * (full BRR content), and to used Peripheral Clock and Oversampling mode values | |
1051 * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned. | |
1052 * @rmtoll BRR BRR LL_USART_GetBaudRate | |
1053 * @param USARTx USART Instance | |
1054 * @param PeriphClk Peripheral Clock | |
1055 * @param OverSampling This parameter can be one of the following values: | |
1056 * @arg @ref LL_USART_OVERSAMPLING_16 | |
1057 * @arg @ref LL_USART_OVERSAMPLING_8 | |
1058 * @retval Baud Rate | |
1059 */ | |
1060 __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling) | |
1061 { | |
1062 register uint32_t usartdiv = 0x0U; | |
1063 register uint32_t brrresult = 0x0U; | |
1064 | |
1065 usartdiv = USARTx->BRR; | |
1066 | |
1067 if (OverSampling == LL_USART_OVERSAMPLING_8) | |
1068 { | |
1069 if ((usartdiv & 0xFFF7U) != 0U) | |
1070 { | |
1071 usartdiv = (uint16_t)((usartdiv & 0xFFF0U) | ((usartdiv & 0x0007U) << 1U)) ; | |
1072 brrresult = (PeriphClk * 2U) / usartdiv; | |
1073 } | |
1074 } | |
1075 else | |
1076 { | |
1077 if ((usartdiv & 0xFFFFU) != 0U) | |
1078 { | |
1079 brrresult = PeriphClk / usartdiv; | |
1080 } | |
1081 } | |
1082 return (brrresult); | |
1083 } | |
1084 | |
1085 /** | |
1086 * @} | |
1087 */ | |
1088 | |
1089 /** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature | |
1090 * @{ | |
1091 */ | |
1092 | |
1093 /** | |
1094 * @brief Enable IrDA mode | |
1095 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not | |
1096 * IrDA feature is supported by the USARTx instance. | |
1097 * @rmtoll CR3 IREN LL_USART_EnableIrda | |
1098 * @param USARTx USART Instance | |
1099 * @retval None | |
1100 */ | |
1101 __STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx) | |
1102 { | |
1103 SET_BIT(USARTx->CR3, USART_CR3_IREN); | |
1104 } | |
1105 | |
1106 /** | |
1107 * @brief Disable IrDA mode | |
1108 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not | |
1109 * IrDA feature is supported by the USARTx instance. | |
1110 * @rmtoll CR3 IREN LL_USART_DisableIrda | |
1111 * @param USARTx USART Instance | |
1112 * @retval None | |
1113 */ | |
1114 __STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx) | |
1115 { | |
1116 CLEAR_BIT(USARTx->CR3, USART_CR3_IREN); | |
1117 } | |
1118 | |
1119 /** | |
1120 * @brief Indicate if IrDA mode is enabled | |
1121 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not | |
1122 * IrDA feature is supported by the USARTx instance. | |
1123 * @rmtoll CR3 IREN LL_USART_IsEnabledIrda | |
1124 * @param USARTx USART Instance | |
1125 * @retval State of bit (1 or 0). | |
1126 */ | |
1127 __STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(USART_TypeDef *USARTx) | |
1128 { | |
1129 return (READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN)); | |
1130 } | |
1131 | |
1132 /** | |
1133 * @brief Configure IrDA Power Mode (Normal or Low Power) | |
1134 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not | |
1135 * IrDA feature is supported by the USARTx instance. | |
1136 * @rmtoll CR3 IRLP LL_USART_SetIrdaPowerMode | |
1137 * @param USARTx USART Instance | |
1138 * @param PowerMode This parameter can be one of the following values: | |
1139 * @arg @ref LL_USART_IRDA_POWER_NORMAL | |
1140 * @arg @ref LL_USART_IRDA_POWER_LOW | |
1141 * @retval None | |
1142 */ | |
1143 __STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode) | |
1144 { | |
1145 MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode); | |
1146 } | |
1147 | |
1148 /** | |
1149 * @brief Retrieve IrDA Power Mode configuration (Normal or Low Power) | |
1150 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not | |
1151 * IrDA feature is supported by the USARTx instance. | |
1152 * @rmtoll CR3 IRLP LL_USART_GetIrdaPowerMode | |
1153 * @param USARTx USART Instance | |
1154 * @retval Returned value can be one of the following values: | |
1155 * @arg @ref LL_USART_IRDA_POWER_NORMAL | |
1156 * @arg @ref LL_USART_PHASE_2EDGE | |
1157 */ | |
1158 __STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(USART_TypeDef *USARTx) | |
1159 { | |
1160 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP)); | |
1161 } | |
1162 | |
1163 /** | |
1164 * @brief Set Irda prescaler value, used for dividing the USART clock source | |
1165 * to achieve the Irda Low Power frequency (8 bits value) | |
1166 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not | |
1167 * IrDA feature is supported by the USARTx instance. | |
1168 * @rmtoll GTPR PSC LL_USART_SetIrdaPrescaler | |
1169 * @param USARTx USART Instance | |
1170 * @param PrescalerValue Value between Min_Data=0x00 and Max_Data=0xFF | |
1171 * @retval None | |
1172 */ | |
1173 __STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) | |
1174 { | |
1175 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue); | |
1176 } | |
1177 | |
1178 /** | |
1179 * @brief Return Irda prescaler value, used for dividing the USART clock source | |
1180 * to achieve the Irda Low Power frequency (8 bits value) | |
1181 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not | |
1182 * IrDA feature is supported by the USARTx instance. | |
1183 * @rmtoll GTPR PSC LL_USART_GetIrdaPrescaler | |
1184 * @param USARTx USART Instance | |
1185 * @retval Irda prescaler value (Value between Min_Data=0x00 and Max_Data=0xFF) | |
1186 */ | |
1187 __STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(USART_TypeDef *USARTx) | |
1188 { | |
1189 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC)); | |
1190 } | |
1191 | |
1192 /** | |
1193 * @} | |
1194 */ | |
1195 | |
1196 /** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature | |
1197 * @{ | |
1198 */ | |
1199 | |
1200 /** | |
1201 * @brief Enable Smartcard NACK transmission | |
1202 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not | |
1203 * Smartcard feature is supported by the USARTx instance. | |
1204 * @rmtoll CR3 NACK LL_USART_EnableSmartcardNACK | |
1205 * @param USARTx USART Instance | |
1206 * @retval None | |
1207 */ | |
1208 __STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx) | |
1209 { | |
1210 SET_BIT(USARTx->CR3, USART_CR3_NACK); | |
1211 } | |
1212 | |
1213 /** | |
1214 * @brief Disable Smartcard NACK transmission | |
1215 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not | |
1216 * Smartcard feature is supported by the USARTx instance. | |
1217 * @rmtoll CR3 NACK LL_USART_DisableSmartcardNACK | |
1218 * @param USARTx USART Instance | |
1219 * @retval None | |
1220 */ | |
1221 __STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx) | |
1222 { | |
1223 CLEAR_BIT(USARTx->CR3, USART_CR3_NACK); | |
1224 } | |
1225 | |
1226 /** | |
1227 * @brief Indicate if Smartcard NACK transmission is enabled | |
1228 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not | |
1229 * Smartcard feature is supported by the USARTx instance. | |
1230 * @rmtoll CR3 NACK LL_USART_IsEnabledSmartcardNACK | |
1231 * @param USARTx USART Instance | |
1232 * @retval State of bit (1 or 0). | |
1233 */ | |
1234 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(USART_TypeDef *USARTx) | |
1235 { | |
1236 return (READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK)); | |
1237 } | |
1238 | |
1239 /** | |
1240 * @brief Enable Smartcard mode | |
1241 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not | |
1242 * Smartcard feature is supported by the USARTx instance. | |
1243 * @rmtoll CR3 SCEN LL_USART_EnableSmartcard | |
1244 * @param USARTx USART Instance | |
1245 * @retval None | |
1246 */ | |
1247 __STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx) | |
1248 { | |
1249 SET_BIT(USARTx->CR3, USART_CR3_SCEN); | |
1250 } | |
1251 | |
1252 /** | |
1253 * @brief Disable Smartcard mode | |
1254 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not | |
1255 * Smartcard feature is supported by the USARTx instance. | |
1256 * @rmtoll CR3 SCEN LL_USART_DisableSmartcard | |
1257 * @param USARTx USART Instance | |
1258 * @retval None | |
1259 */ | |
1260 __STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx) | |
1261 { | |
1262 CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN); | |
1263 } | |
1264 | |
1265 /** | |
1266 * @brief Indicate if Smartcard mode is enabled | |
1267 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not | |
1268 * Smartcard feature is supported by the USARTx instance. | |
1269 * @rmtoll CR3 SCEN LL_USART_IsEnabledSmartcard | |
1270 * @param USARTx USART Instance | |
1271 * @retval State of bit (1 or 0). | |
1272 */ | |
1273 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(USART_TypeDef *USARTx) | |
1274 { | |
1275 return (READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN)); | |
1276 } | |
1277 | |
1278 /** | |
1279 * @brief Set Smartcard prescaler value, used for dividing the USART clock | |
1280 * source to provide the SMARTCARD Clock (5 bits value) | |
1281 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not | |
1282 * Smartcard feature is supported by the USARTx instance. | |
1283 * @rmtoll GTPR PSC LL_USART_SetSmartcardPrescaler | |
1284 * @param USARTx USART Instance | |
1285 * @param PrescalerValue Value between Min_Data=0 and Max_Data=31 | |
1286 * @retval None | |
1287 */ | |
1288 __STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) | |
1289 { | |
1290 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue); | |
1291 } | |
1292 | |
1293 /** | |
1294 * @brief Return Smartcard prescaler value, used for dividing the USART clock | |
1295 * source to provide the SMARTCARD Clock (5 bits value) | |
1296 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not | |
1297 * Smartcard feature is supported by the USARTx instance. | |
1298 * @rmtoll GTPR PSC LL_USART_GetSmartcardPrescaler | |
1299 * @param USARTx USART Instance | |
1300 * @retval Smartcard prescaler value (Value between Min_Data=0 and Max_Data=31) | |
1301 */ | |
1302 __STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(USART_TypeDef *USARTx) | |
1303 { | |
1304 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC)); | |
1305 } | |
1306 | |
1307 /** | |
1308 * @brief Set Smartcard Guard time value, expressed in nb of baud clocks periods | |
1309 * (GT[7:0] bits : Guard time value) | |
1310 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not | |
1311 * Smartcard feature is supported by the USARTx instance. | |
1312 * @rmtoll GTPR GT LL_USART_SetSmartcardGuardTime | |
1313 * @param USARTx USART Instance | |
1314 * @param GuardTime Value between Min_Data=0x00 and Max_Data=0xFF | |
1315 * @retval None | |
1316 */ | |
1317 __STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime) | |
1318 { | |
1319 MODIFY_REG(USARTx->GTPR, USART_GTPR_GT, GuardTime << USART_POSITION_GTPR_GT); | |
1320 } | |
1321 | |
1322 /** | |
1323 * @brief Return Smartcard Guard time value, expressed in nb of baud clocks periods | |
1324 * (GT[7:0] bits : Guard time value) | |
1325 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not | |
1326 * Smartcard feature is supported by the USARTx instance. | |
1327 * @rmtoll GTPR GT LL_USART_GetSmartcardGuardTime | |
1328 * @param USARTx USART Instance | |
1329 * @retval Smartcard Guard time value (Value between Min_Data=0x00 and Max_Data=0xFF) | |
1330 */ | |
1331 __STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(USART_TypeDef *USARTx) | |
1332 { | |
1333 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_POSITION_GTPR_GT); | |
1334 } | |
1335 | |
1336 /** | |
1337 * @} | |
1338 */ | |
1339 | |
1340 /** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature | |
1341 * @{ | |
1342 */ | |
1343 | |
1344 /** | |
1345 * @brief Enable Single Wire Half-Duplex mode | |
1346 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not | |
1347 * Half-Duplex mode is supported by the USARTx instance. | |
1348 * @rmtoll CR3 HDSEL LL_USART_EnableHalfDuplex | |
1349 * @param USARTx USART Instance | |
1350 * @retval None | |
1351 */ | |
1352 __STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx) | |
1353 { | |
1354 SET_BIT(USARTx->CR3, USART_CR3_HDSEL); | |
1355 } | |
1356 | |
1357 /** | |
1358 * @brief Disable Single Wire Half-Duplex mode | |
1359 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not | |
1360 * Half-Duplex mode is supported by the USARTx instance. | |
1361 * @rmtoll CR3 HDSEL LL_USART_DisableHalfDuplex | |
1362 * @param USARTx USART Instance | |
1363 * @retval None | |
1364 */ | |
1365 __STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx) | |
1366 { | |
1367 CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL); | |
1368 } | |
1369 | |
1370 /** | |
1371 * @brief Indicate if Single Wire Half-Duplex mode is enabled | |
1372 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not | |
1373 * Half-Duplex mode is supported by the USARTx instance. | |
1374 * @rmtoll CR3 HDSEL LL_USART_IsEnabledHalfDuplex | |
1375 * @param USARTx USART Instance | |
1376 * @retval State of bit (1 or 0). | |
1377 */ | |
1378 __STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(USART_TypeDef *USARTx) | |
1379 { | |
1380 return (READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL)); | |
1381 } | |
1382 | |
1383 /** | |
1384 * @} | |
1385 */ | |
1386 | |
1387 /** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature | |
1388 * @{ | |
1389 */ | |
1390 | |
1391 /** | |
1392 * @brief Set LIN Break Detection Length | |
1393 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not | |
1394 * LIN feature is supported by the USARTx instance. | |
1395 * @rmtoll CR2 LBDL LL_USART_SetLINBrkDetectionLen | |
1396 * @param USARTx USART Instance | |
1397 * @param LINBDLength This parameter can be one of the following values: | |
1398 * @arg @ref LL_USART_LINBREAK_DETECT_10B | |
1399 * @arg @ref LL_USART_LINBREAK_DETECT_11B | |
1400 * @retval None | |
1401 */ | |
1402 __STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength) | |
1403 { | |
1404 MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength); | |
1405 } | |
1406 | |
1407 /** | |
1408 * @brief Return LIN Break Detection Length | |
1409 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not | |
1410 * LIN feature is supported by the USARTx instance. | |
1411 * @rmtoll CR2 LBDL LL_USART_GetLINBrkDetectionLen | |
1412 * @param USARTx USART Instance | |
1413 * @retval Returned value can be one of the following values: | |
1414 * @arg @ref LL_USART_LINBREAK_DETECT_10B | |
1415 * @arg @ref LL_USART_LINBREAK_DETECT_11B | |
1416 */ | |
1417 __STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(USART_TypeDef *USARTx) | |
1418 { | |
1419 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL)); | |
1420 } | |
1421 | |
1422 /** | |
1423 * @brief Enable LIN mode | |
1424 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not | |
1425 * LIN feature is supported by the USARTx instance. | |
1426 * @rmtoll CR2 LINEN LL_USART_EnableLIN | |
1427 * @param USARTx USART Instance | |
1428 * @retval None | |
1429 */ | |
1430 __STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx) | |
1431 { | |
1432 SET_BIT(USARTx->CR2, USART_CR2_LINEN); | |
1433 } | |
1434 | |
1435 /** | |
1436 * @brief Disable LIN mode | |
1437 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not | |
1438 * LIN feature is supported by the USARTx instance. | |
1439 * @rmtoll CR2 LINEN LL_USART_DisableLIN | |
1440 * @param USARTx USART Instance | |
1441 * @retval None | |
1442 */ | |
1443 __STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx) | |
1444 { | |
1445 CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN); | |
1446 } | |
1447 | |
1448 /** | |
1449 * @brief Indicate if LIN mode is enabled | |
1450 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not | |
1451 * LIN feature is supported by the USARTx instance. | |
1452 * @rmtoll CR2 LINEN LL_USART_IsEnabledLIN | |
1453 * @param USARTx USART Instance | |
1454 * @retval State of bit (1 or 0). | |
1455 */ | |
1456 __STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(USART_TypeDef *USARTx) | |
1457 { | |
1458 return (READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN)); | |
1459 } | |
1460 | |
1461 /** | |
1462 * @} | |
1463 */ | |
1464 | |
1465 /** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services | |
1466 * @{ | |
1467 */ | |
1468 | |
1469 /** | |
1470 * @brief Perform basic configuration of USART for enabling use in Asynchronous Mode (UART) | |
1471 * @note In UART mode, the following bits must be kept cleared: | |
1472 * - LINEN bit in the USART_CR2 register, | |
1473 * - CLKEN bit in the USART_CR2 register, | |
1474 * - SCEN bit in the USART_CR3 register, | |
1475 * - IREN bit in the USART_CR3 register, | |
1476 * - HDSEL bit in the USART_CR3 register. | |
1477 * @note Call of this function is equivalent to following function call sequence : | |
1478 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function | |
1479 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function | |
1480 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function | |
1481 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function | |
1482 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function | |
1483 * @note Other remaining configurations items related to Asynchronous Mode | |
1484 * (as Baud Rate, Word length, Parity, ...) should be set using | |
1485 * dedicated functions | |
1486 * @rmtoll CR2 LINEN LL_USART_ConfigAsyncMode\n | |
1487 * CR2 CLKEN LL_USART_ConfigAsyncMode\n | |
1488 * CR3 SCEN LL_USART_ConfigAsyncMode\n | |
1489 * CR3 IREN LL_USART_ConfigAsyncMode\n | |
1490 * CR3 HDSEL LL_USART_ConfigAsyncMode | |
1491 * @param USARTx USART Instance | |
1492 * @retval None | |
1493 */ | |
1494 __STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx) | |
1495 { | |
1496 /* In Asynchronous mode, the following bits must be kept cleared: | |
1497 - LINEN, CLKEN bits in the USART_CR2 register, | |
1498 - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/ | |
1499 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); | |
1500 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL)); | |
1501 } | |
1502 | |
1503 /** | |
1504 * @brief Perform basic configuration of USART for enabling use in Synchronous Mode | |
1505 * @note In Synchronous mode, the following bits must be kept cleared: | |
1506 * - LINEN bit in the USART_CR2 register, | |
1507 * - SCEN bit in the USART_CR3 register, | |
1508 * - IREN bit in the USART_CR3 register, | |
1509 * - HDSEL bit in the USART_CR3 register. | |
1510 * This function also sets the USART in Synchronous mode. | |
1511 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not | |
1512 * Synchronous mode is supported by the USARTx instance. | |
1513 * @note Call of this function is equivalent to following function call sequence : | |
1514 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function | |
1515 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function | |
1516 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function | |
1517 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function | |
1518 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function | |
1519 * @note Other remaining configurations items related to Synchronous Mode | |
1520 * (as Baud Rate, Word length, Parity, Clock Polarity, ...) should be set using | |
1521 * dedicated functions | |
1522 * @rmtoll CR2 LINEN LL_USART_ConfigSyncMode\n | |
1523 * CR2 CLKEN LL_USART_ConfigSyncMode\n | |
1524 * CR3 SCEN LL_USART_ConfigSyncMode\n | |
1525 * CR3 IREN LL_USART_ConfigSyncMode\n | |
1526 * CR3 HDSEL LL_USART_ConfigSyncMode | |
1527 * @param USARTx USART Instance | |
1528 * @retval None | |
1529 */ | |
1530 __STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx) | |
1531 { | |
1532 /* In Synchronous mode, the following bits must be kept cleared: | |
1533 - LINEN bit in the USART_CR2 register, | |
1534 - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/ | |
1535 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN)); | |
1536 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL)); | |
1537 /* set the UART/USART in Synchronous mode */ | |
1538 SET_BIT(USARTx->CR2, USART_CR2_CLKEN); | |
1539 } | |
1540 | |
1541 /** | |
1542 * @brief Perform basic configuration of USART for enabling use in LIN Mode | |
1543 * @note In LIN mode, the following bits must be kept cleared: | |
1544 * - STOP and CLKEN bits in the USART_CR2 register, | |
1545 * - SCEN bit in the USART_CR3 register, | |
1546 * - IREN bit in the USART_CR3 register, | |
1547 * - HDSEL bit in the USART_CR3 register. | |
1548 * This function also set the UART/USART in LIN mode. | |
1549 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not | |
1550 * LIN feature is supported by the USARTx instance. | |
1551 * @note Call of this function is equivalent to following function call sequence : | |
1552 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function | |
1553 * - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function | |
1554 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function | |
1555 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function | |
1556 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function | |
1557 * - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function | |
1558 * @note Other remaining configurations items related to LIN Mode | |
1559 * (as Baud Rate, Word length, LIN Break Detection Length, ...) should be set using | |
1560 * dedicated functions | |
1561 * @rmtoll CR2 CLKEN LL_USART_ConfigLINMode\n | |
1562 * CR2 STOP LL_USART_ConfigLINMode\n | |
1563 * CR2 LINEN LL_USART_ConfigLINMode\n | |
1564 * CR3 IREN LL_USART_ConfigLINMode\n | |
1565 * CR3 SCEN LL_USART_ConfigLINMode\n | |
1566 * CR3 HDSEL LL_USART_ConfigLINMode | |
1567 * @param USARTx USART Instance | |
1568 * @retval None | |
1569 */ | |
1570 __STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx) | |
1571 { | |
1572 /* In LIN mode, the following bits must be kept cleared: | |
1573 - STOP and CLKEN bits in the USART_CR2 register, | |
1574 - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/ | |
1575 CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP)); | |
1576 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL)); | |
1577 /* Set the UART/USART in LIN mode */ | |
1578 SET_BIT(USARTx->CR2, USART_CR2_LINEN); | |
1579 } | |
1580 | |
1581 /** | |
1582 * @brief Perform basic configuration of USART for enabling use in Half Duplex Mode | |
1583 * @note In Half Duplex mode, the following bits must be kept cleared: | |
1584 * - LINEN bit in the USART_CR2 register, | |
1585 * - CLKEN bit in the USART_CR2 register, | |
1586 * - SCEN bit in the USART_CR3 register, | |
1587 * - IREN bit in the USART_CR3 register, | |
1588 * This function also sets the UART/USART in Half Duplex mode. | |
1589 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not | |
1590 * Half-Duplex mode is supported by the USARTx instance. | |
1591 * @note Call of this function is equivalent to following function call sequence : | |
1592 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function | |
1593 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function | |
1594 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function | |
1595 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function | |
1596 * - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function | |
1597 * @note Other remaining configurations items related to Half Duplex Mode | |
1598 * (as Baud Rate, Word length, Parity, ...) should be set using | |
1599 * dedicated functions | |
1600 * @rmtoll CR2 LINEN LL_USART_ConfigHalfDuplexMode\n | |
1601 * CR2 CLKEN LL_USART_ConfigHalfDuplexMode\n | |
1602 * CR3 HDSEL LL_USART_ConfigHalfDuplexMode\n | |
1603 * CR3 SCEN LL_USART_ConfigHalfDuplexMode\n | |
1604 * CR3 IREN LL_USART_ConfigHalfDuplexMode | |
1605 * @param USARTx USART Instance | |
1606 * @retval None | |
1607 */ | |
1608 __STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx) | |
1609 { | |
1610 /* In Half Duplex mode, the following bits must be kept cleared: | |
1611 - LINEN and CLKEN bits in the USART_CR2 register, | |
1612 - SCEN and IREN bits in the USART_CR3 register.*/ | |
1613 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); | |
1614 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN)); | |
1615 /* set the UART/USART in Half Duplex mode */ | |
1616 SET_BIT(USARTx->CR3, USART_CR3_HDSEL); | |
1617 } | |
1618 | |
1619 /** | |
1620 * @brief Perform basic configuration of USART for enabling use in Smartcard Mode | |
1621 * @note In Smartcard mode, the following bits must be kept cleared: | |
1622 * - LINEN bit in the USART_CR2 register, | |
1623 * - IREN bit in the USART_CR3 register, | |
1624 * - HDSEL bit in the USART_CR3 register. | |
1625 * This function also configures Stop bits to 1.5 bits and | |
1626 * sets the USART in Smartcard mode (SCEN bit). | |
1627 * Clock Output is also enabled (CLKEN). | |
1628 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not | |
1629 * Smartcard feature is supported by the USARTx instance. | |
1630 * @note Call of this function is equivalent to following function call sequence : | |
1631 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function | |
1632 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function | |
1633 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function | |
1634 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function | |
1635 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function | |
1636 * - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function | |
1637 * @note Other remaining configurations items related to Smartcard Mode | |
1638 * (as Baud Rate, Word length, Parity, ...) should be set using | |
1639 * dedicated functions | |
1640 * @rmtoll CR2 LINEN LL_USART_ConfigSmartcardMode\n | |
1641 * CR2 STOP LL_USART_ConfigSmartcardMode\n | |
1642 * CR2 CLKEN LL_USART_ConfigSmartcardMode\n | |
1643 * CR3 HDSEL LL_USART_ConfigSmartcardMode\n | |
1644 * CR3 SCEN LL_USART_ConfigSmartcardMode | |
1645 * @param USARTx USART Instance | |
1646 * @retval None | |
1647 */ | |
1648 __STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx) | |
1649 { | |
1650 /* In Smartcard mode, the following bits must be kept cleared: | |
1651 - LINEN bit in the USART_CR2 register, | |
1652 - IREN and HDSEL bits in the USART_CR3 register.*/ | |
1653 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN)); | |
1654 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL)); | |
1655 /* Configure Stop bits to 1.5 bits */ | |
1656 /* Synchronous mode is activated by default */ | |
1657 SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN)); | |
1658 /* set the UART/USART in Smartcard mode */ | |
1659 SET_BIT(USARTx->CR3, USART_CR3_SCEN); | |
1660 } | |
1661 | |
1662 /** | |
1663 * @brief Perform basic configuration of USART for enabling use in Irda Mode | |
1664 * @note In IRDA mode, the following bits must be kept cleared: | |
1665 * - LINEN bit in the USART_CR2 register, | |
1666 * - STOP and CLKEN bits in the USART_CR2 register, | |
1667 * - SCEN bit in the USART_CR3 register, | |
1668 * - HDSEL bit in the USART_CR3 register. | |
1669 * This function also sets the UART/USART in IRDA mode (IREN bit). | |
1670 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not | |
1671 * IrDA feature is supported by the USARTx instance. | |
1672 * @note Call of this function is equivalent to following function call sequence : | |
1673 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function | |
1674 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function | |
1675 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function | |
1676 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function | |
1677 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function | |
1678 * - Set IREN in CR3 using @ref LL_USART_EnableIrda() function | |
1679 * @note Other remaining configurations items related to Irda Mode | |
1680 * (as Baud Rate, Word length, Power mode, ...) should be set using | |
1681 * dedicated functions | |
1682 * @rmtoll CR2 LINEN LL_USART_ConfigIrdaMode\n | |
1683 * CR2 CLKEN LL_USART_ConfigIrdaMode\n | |
1684 * CR2 STOP LL_USART_ConfigIrdaMode\n | |
1685 * CR3 SCEN LL_USART_ConfigIrdaMode\n | |
1686 * CR3 HDSEL LL_USART_ConfigIrdaMode\n | |
1687 * CR3 IREN LL_USART_ConfigIrdaMode | |
1688 * @param USARTx USART Instance | |
1689 * @retval None | |
1690 */ | |
1691 __STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx) | |
1692 { | |
1693 /* In IRDA mode, the following bits must be kept cleared: | |
1694 - LINEN, STOP and CLKEN bits in the USART_CR2 register, | |
1695 - SCEN and HDSEL bits in the USART_CR3 register.*/ | |
1696 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP)); | |
1697 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL)); | |
1698 /* set the UART/USART in IRDA mode */ | |
1699 SET_BIT(USARTx->CR3, USART_CR3_IREN); | |
1700 } | |
1701 | |
1702 /** | |
1703 * @brief Perform basic configuration of USART for enabling use in Multi processor Mode | |
1704 * (several USARTs connected in a network, one of the USARTs can be the master, | |
1705 * its TX output connected to the RX inputs of the other slaves USARTs). | |
1706 * @note In MultiProcessor mode, the following bits must be kept cleared: | |
1707 * - LINEN bit in the USART_CR2 register, | |
1708 * - CLKEN bit in the USART_CR2 register, | |
1709 * - SCEN bit in the USART_CR3 register, | |
1710 * - IREN bit in the USART_CR3 register, | |
1711 * - HDSEL bit in the USART_CR3 register. | |
1712 * @note Call of this function is equivalent to following function call sequence : | |
1713 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function | |
1714 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function | |
1715 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function | |
1716 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function | |
1717 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function | |
1718 * @note Other remaining configurations items related to Multi processor Mode | |
1719 * (as Baud Rate, Wake Up Method, Node address, ...) should be set using | |
1720 * dedicated functions | |
1721 * @rmtoll CR2 LINEN LL_USART_ConfigMultiProcessMode\n | |
1722 * CR2 CLKEN LL_USART_ConfigMultiProcessMode\n | |
1723 * CR3 SCEN LL_USART_ConfigMultiProcessMode\n | |
1724 * CR3 HDSEL LL_USART_ConfigMultiProcessMode\n | |
1725 * CR3 IREN LL_USART_ConfigMultiProcessMode | |
1726 * @param USARTx USART Instance | |
1727 * @retval None | |
1728 */ | |
1729 __STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx) | |
1730 { | |
1731 /* In Multi Processor mode, the following bits must be kept cleared: | |
1732 - LINEN and CLKEN bits in the USART_CR2 register, | |
1733 - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/ | |
1734 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); | |
1735 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN)); | |
1736 } | |
1737 | |
1738 /** | |
1739 * @} | |
1740 */ | |
1741 | |
1742 /** @defgroup USART_LL_EF_FLAG_Management FLAG_Management | |
1743 * @{ | |
1744 */ | |
1745 | |
1746 /** | |
1747 * @brief Check if the USART Parity Error Flag is set or not | |
1748 * @rmtoll SR PE LL_USART_IsActiveFlag_PE | |
1749 * @param USARTx USART Instance | |
1750 * @retval State of bit (1 or 0). | |
1751 */ | |
1752 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(USART_TypeDef *USARTx) | |
1753 { | |
1754 return (READ_BIT(USARTx->SR, USART_SR_PE) == (USART_SR_PE)); | |
1755 } | |
1756 | |
1757 /** | |
1758 * @brief Check if the USART Framing Error Flag is set or not | |
1759 * @rmtoll SR FE LL_USART_IsActiveFlag_FE | |
1760 * @param USARTx USART Instance | |
1761 * @retval State of bit (1 or 0). | |
1762 */ | |
1763 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(USART_TypeDef *USARTx) | |
1764 { | |
1765 return (READ_BIT(USARTx->SR, USART_SR_FE) == (USART_SR_FE)); | |
1766 } | |
1767 | |
1768 /** | |
1769 * @brief Check if the USART Noise error detected Flag is set or not | |
1770 * @rmtoll SR NF LL_USART_IsActiveFlag_NE | |
1771 * @param USARTx USART Instance | |
1772 * @retval State of bit (1 or 0). | |
1773 */ | |
1774 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(USART_TypeDef *USARTx) | |
1775 { | |
1776 return (READ_BIT(USARTx->SR, USART_SR_NE) == (USART_SR_NE)); | |
1777 } | |
1778 | |
1779 /** | |
1780 * @brief Check if the USART OverRun Error Flag is set or not | |
1781 * @rmtoll SR ORE LL_USART_IsActiveFlag_ORE | |
1782 * @param USARTx USART Instance | |
1783 * @retval State of bit (1 or 0). | |
1784 */ | |
1785 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(USART_TypeDef *USARTx) | |
1786 { | |
1787 return (READ_BIT(USARTx->SR, USART_SR_ORE) == (USART_SR_ORE)); | |
1788 } | |
1789 | |
1790 /** | |
1791 * @brief Check if the USART IDLE line detected Flag is set or not | |
1792 * @rmtoll SR IDLE LL_USART_IsActiveFlag_IDLE | |
1793 * @param USARTx USART Instance | |
1794 * @retval State of bit (1 or 0). | |
1795 */ | |
1796 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(USART_TypeDef *USARTx) | |
1797 { | |
1798 return (READ_BIT(USARTx->SR, USART_SR_IDLE) == (USART_SR_IDLE)); | |
1799 } | |
1800 | |
1801 /** | |
1802 * @brief Check if the USART Read Data Register Not Empty Flag is set or not | |
1803 * @rmtoll SR RXNE LL_USART_IsActiveFlag_RXNE | |
1804 * @param USARTx USART Instance | |
1805 * @retval State of bit (1 or 0). | |
1806 */ | |
1807 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE(USART_TypeDef *USARTx) | |
1808 { | |
1809 return (READ_BIT(USARTx->SR, USART_SR_RXNE) == (USART_SR_RXNE)); | |
1810 } | |
1811 | |
1812 /** | |
1813 * @brief Check if the USART Transmission Complete Flag is set or not | |
1814 * @rmtoll SR TC LL_USART_IsActiveFlag_TC | |
1815 * @param USARTx USART Instance | |
1816 * @retval State of bit (1 or 0). | |
1817 */ | |
1818 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(USART_TypeDef *USARTx) | |
1819 { | |
1820 return (READ_BIT(USARTx->SR, USART_SR_TC) == (USART_SR_TC)); | |
1821 } | |
1822 | |
1823 /** | |
1824 * @brief Check if the USART Transmit Data Register Empty Flag is set or not | |
1825 * @rmtoll SR TXE LL_USART_IsActiveFlag_TXE | |
1826 * @param USARTx USART Instance | |
1827 * @retval State of bit (1 or 0). | |
1828 */ | |
1829 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE(USART_TypeDef *USARTx) | |
1830 { | |
1831 return (READ_BIT(USARTx->SR, USART_SR_TXE) == (USART_SR_TXE)); | |
1832 } | |
1833 | |
1834 /** | |
1835 * @brief Check if the USART LIN Break Detection Flag is set or not | |
1836 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not | |
1837 * LIN feature is supported by the USARTx instance. | |
1838 * @rmtoll SR LBD LL_USART_IsActiveFlag_LBD | |
1839 * @param USARTx USART Instance | |
1840 * @retval State of bit (1 or 0). | |
1841 */ | |
1842 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(USART_TypeDef *USARTx) | |
1843 { | |
1844 return (READ_BIT(USARTx->SR, USART_SR_LBD) == (USART_SR_LBD)); | |
1845 } | |
1846 | |
1847 /** | |
1848 * @brief Check if the USART CTS Flag is set or not | |
1849 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not | |
1850 * Hardware Flow control feature is supported by the USARTx instance. | |
1851 * @rmtoll SR CTS LL_USART_IsActiveFlag_nCTS | |
1852 * @param USARTx USART Instance | |
1853 * @retval State of bit (1 or 0). | |
1854 */ | |
1855 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(USART_TypeDef *USARTx) | |
1856 { | |
1857 return (READ_BIT(USARTx->SR, USART_SR_CTS) == (USART_SR_CTS)); | |
1858 } | |
1859 | |
1860 /** | |
1861 * @brief Check if the USART Send Break Flag is set or not | |
1862 * @rmtoll CR1 SBK LL_USART_IsActiveFlag_SBK | |
1863 * @param USARTx USART Instance | |
1864 * @retval State of bit (1 or 0). | |
1865 */ | |
1866 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(USART_TypeDef *USARTx) | |
1867 { | |
1868 return (READ_BIT(USARTx->CR1, USART_CR1_SBK) == (USART_CR1_SBK)); | |
1869 } | |
1870 | |
1871 /** | |
1872 * @brief Check if the USART Receive Wake Up from mute mode Flag is set or not | |
1873 * @rmtoll CR1 RWU LL_USART_IsActiveFlag_RWU | |
1874 * @param USARTx USART Instance | |
1875 * @retval State of bit (1 or 0). | |
1876 */ | |
1877 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(USART_TypeDef *USARTx) | |
1878 { | |
1879 return (READ_BIT(USARTx->CR1, USART_CR1_RWU) == (USART_CR1_RWU)); | |
1880 } | |
1881 | |
1882 /** | |
1883 * @brief Clear Parity Error Flag | |
1884 * @note Clearing this flag is done by a read access to the USARTx_SR | |
1885 * register followed by a read access to the USARTx_DR register. | |
1886 * @note Please also consider that when clearing this flag, other flags as | |
1887 * NE, FE, ORE, IDLE would also be cleared. | |
1888 * @rmtoll SR PE LL_USART_ClearFlag_PE | |
1889 * @param USARTx USART Instance | |
1890 * @retval None | |
1891 */ | |
1892 __STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx) | |
1893 { | |
1894 __IO uint32_t tmpreg; | |
1895 tmpreg = USARTx->SR; | |
1896 (void) tmpreg; | |
1897 tmpreg = USARTx->DR; | |
1898 (void) tmpreg; | |
1899 } | |
1900 | |
1901 /** | |
1902 * @brief Clear Framing Error Flag | |
1903 * @note Clearing this flag is done by a read access to the USARTx_SR | |
1904 * register followed by a read access to the USARTx_DR register. | |
1905 * @note Please also consider that when clearing this flag, other flags as | |
1906 * PE, NE, ORE, IDLE would also be cleared. | |
1907 * @rmtoll SR FE LL_USART_ClearFlag_FE | |
1908 * @param USARTx USART Instance | |
1909 * @retval None | |
1910 */ | |
1911 __STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx) | |
1912 { | |
1913 __IO uint32_t tmpreg; | |
1914 tmpreg = USARTx->SR; | |
1915 (void) tmpreg; | |
1916 tmpreg = USARTx->DR; | |
1917 (void) tmpreg; | |
1918 } | |
1919 | |
1920 /** | |
1921 * @brief Clear Noise detected Flag | |
1922 * @note Clearing this flag is done by a read access to the USARTx_SR | |
1923 * register followed by a read access to the USARTx_DR register. | |
1924 * @note Please also consider that when clearing this flag, other flags as | |
1925 * PE, FE, ORE, IDLE would also be cleared. | |
1926 * @rmtoll SR NF LL_USART_ClearFlag_NE | |
1927 * @param USARTx USART Instance | |
1928 * @retval None | |
1929 */ | |
1930 __STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx) | |
1931 { | |
1932 __IO uint32_t tmpreg; | |
1933 tmpreg = USARTx->SR; | |
1934 (void) tmpreg; | |
1935 tmpreg = USARTx->DR; | |
1936 (void) tmpreg; | |
1937 } | |
1938 | |
1939 /** | |
1940 * @brief Clear OverRun Error Flag | |
1941 * @note Clearing this flag is done by a read access to the USARTx_SR | |
1942 * register followed by a read access to the USARTx_DR register. | |
1943 * @note Please also consider that when clearing this flag, other flags as | |
1944 * PE, NE, FE, IDLE would also be cleared. | |
1945 * @rmtoll SR ORE LL_USART_ClearFlag_ORE | |
1946 * @param USARTx USART Instance | |
1947 * @retval None | |
1948 */ | |
1949 __STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx) | |
1950 { | |
1951 __IO uint32_t tmpreg; | |
1952 tmpreg = USARTx->SR; | |
1953 (void) tmpreg; | |
1954 tmpreg = USARTx->DR; | |
1955 (void) tmpreg; | |
1956 } | |
1957 | |
1958 /** | |
1959 * @brief Clear IDLE line detected Flag | |
1960 * @note Clearing this flag is done by a read access to the USARTx_SR | |
1961 * register followed by a read access to the USARTx_DR register. | |
1962 * @note Please also consider that when clearing this flag, other flags as | |
1963 * PE, NE, FE, ORE would also be cleared. | |
1964 * @rmtoll SR IDLE LL_USART_ClearFlag_IDLE | |
1965 * @param USARTx USART Instance | |
1966 * @retval None | |
1967 */ | |
1968 __STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx) | |
1969 { | |
1970 __IO uint32_t tmpreg; | |
1971 tmpreg = USARTx->SR; | |
1972 (void) tmpreg; | |
1973 tmpreg = USARTx->DR; | |
1974 (void) tmpreg; | |
1975 } | |
1976 | |
1977 /** | |
1978 * @brief Clear Transmission Complete Flag | |
1979 * @rmtoll SR TC LL_USART_ClearFlag_TC | |
1980 * @param USARTx USART Instance | |
1981 * @retval None | |
1982 */ | |
1983 __STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx) | |
1984 { | |
1985 WRITE_REG(USARTx->SR , ~(USART_SR_TC)); | |
1986 } | |
1987 | |
1988 /** | |
1989 * @brief Clear RX Not Empty Flag | |
1990 * @rmtoll SR RXNE LL_USART_ClearFlag_RXNE | |
1991 * @param USARTx USART Instance | |
1992 * @retval None | |
1993 */ | |
1994 __STATIC_INLINE void LL_USART_ClearFlag_RXNE(USART_TypeDef *USARTx) | |
1995 { | |
1996 WRITE_REG(USARTx->SR , ~(USART_SR_RXNE)); | |
1997 } | |
1998 | |
1999 /** | |
2000 * @brief Clear LIN Break Detection Flag | |
2001 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not | |
2002 * LIN feature is supported by the USARTx instance. | |
2003 * @rmtoll SR LBD LL_USART_ClearFlag_LBD | |
2004 * @param USARTx USART Instance | |
2005 * @retval None | |
2006 */ | |
2007 __STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx) | |
2008 { | |
2009 WRITE_REG(USARTx->SR , ~(USART_SR_LBD)); | |
2010 } | |
2011 | |
2012 /** | |
2013 * @brief Clear CTS Interrupt Flag | |
2014 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not | |
2015 * Hardware Flow control feature is supported by the USARTx instance. | |
2016 * @rmtoll SR CTS LL_USART_ClearFlag_nCTS | |
2017 * @param USARTx USART Instance | |
2018 * @retval None | |
2019 */ | |
2020 __STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx) | |
2021 { | |
2022 WRITE_REG(USARTx->SR , ~(USART_SR_CTS)); | |
2023 } | |
2024 | |
2025 /** | |
2026 * @} | |
2027 */ | |
2028 | |
2029 /** @defgroup USART_LL_EF_IT_Management IT_Management | |
2030 * @{ | |
2031 */ | |
2032 | |
2033 /** | |
2034 * @brief Enable IDLE Interrupt | |
2035 * @rmtoll CR1 IDLEIE LL_USART_EnableIT_IDLE | |
2036 * @param USARTx USART Instance | |
2037 * @retval None | |
2038 */ | |
2039 __STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx) | |
2040 { | |
2041 SET_BIT(USARTx->CR1, USART_CR1_IDLEIE); | |
2042 } | |
2043 | |
2044 /** | |
2045 * @brief Enable RX Not Empty Interrupt | |
2046 * @rmtoll CR1 RXNEIE LL_USART_EnableIT_RXNE | |
2047 * @param USARTx USART Instance | |
2048 * @retval None | |
2049 */ | |
2050 __STATIC_INLINE void LL_USART_EnableIT_RXNE(USART_TypeDef *USARTx) | |
2051 { | |
2052 SET_BIT(USARTx->CR1, USART_CR1_RXNEIE); | |
2053 } | |
2054 | |
2055 /** | |
2056 * @brief Enable Transmission Complete Interrupt | |
2057 * @rmtoll CR1 TCIE LL_USART_EnableIT_TC | |
2058 * @param USARTx USART Instance | |
2059 * @retval None | |
2060 */ | |
2061 __STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx) | |
2062 { | |
2063 SET_BIT(USARTx->CR1, USART_CR1_TCIE); | |
2064 } | |
2065 | |
2066 /** | |
2067 * @brief Enable TX Empty Interrupt | |
2068 * @rmtoll CR1 TXEIE LL_USART_EnableIT_TXE | |
2069 * @param USARTx USART Instance | |
2070 * @retval None | |
2071 */ | |
2072 __STATIC_INLINE void LL_USART_EnableIT_TXE(USART_TypeDef *USARTx) | |
2073 { | |
2074 SET_BIT(USARTx->CR1, USART_CR1_TXEIE); | |
2075 } | |
2076 | |
2077 /** | |
2078 * @brief Enable Parity Error Interrupt | |
2079 * @rmtoll CR1 PEIE LL_USART_EnableIT_PE | |
2080 * @param USARTx USART Instance | |
2081 * @retval None | |
2082 */ | |
2083 __STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx) | |
2084 { | |
2085 SET_BIT(USARTx->CR1, USART_CR1_PEIE); | |
2086 } | |
2087 | |
2088 /** | |
2089 * @brief Enable LIN Break Detection Interrupt | |
2090 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not | |
2091 * LIN feature is supported by the USARTx instance. | |
2092 * @rmtoll CR2 LBDIE LL_USART_EnableIT_LBD | |
2093 * @param USARTx USART Instance | |
2094 * @retval None | |
2095 */ | |
2096 __STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx) | |
2097 { | |
2098 SET_BIT(USARTx->CR2, USART_CR2_LBDIE); | |
2099 } | |
2100 | |
2101 /** | |
2102 * @brief Enable Error Interrupt | |
2103 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing | |
2104 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_SR register). | |
2105 * 0: Interrupt is inhibited | |
2106 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_SR register. | |
2107 * @rmtoll CR3 EIE LL_USART_EnableIT_ERROR | |
2108 * @param USARTx USART Instance | |
2109 * @retval None | |
2110 */ | |
2111 __STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx) | |
2112 { | |
2113 SET_BIT(USARTx->CR3, USART_CR3_EIE); | |
2114 } | |
2115 | |
2116 /** | |
2117 * @brief Enable CTS Interrupt | |
2118 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not | |
2119 * Hardware Flow control feature is supported by the USARTx instance. | |
2120 * @rmtoll CR3 CTSIE LL_USART_EnableIT_CTS | |
2121 * @param USARTx USART Instance | |
2122 * @retval None | |
2123 */ | |
2124 __STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx) | |
2125 { | |
2126 SET_BIT(USARTx->CR3, USART_CR3_CTSIE); | |
2127 } | |
2128 | |
2129 /** | |
2130 * @brief Disable IDLE Interrupt | |
2131 * @rmtoll CR1 IDLEIE LL_USART_DisableIT_IDLE | |
2132 * @param USARTx USART Instance | |
2133 * @retval None | |
2134 */ | |
2135 __STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx) | |
2136 { | |
2137 CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE); | |
2138 } | |
2139 | |
2140 /** | |
2141 * @brief Disable RX Not Empty Interrupt | |
2142 * @rmtoll CR1 RXNEIE LL_USART_DisableIT_RXNE | |
2143 * @param USARTx USART Instance | |
2144 * @retval None | |
2145 */ | |
2146 __STATIC_INLINE void LL_USART_DisableIT_RXNE(USART_TypeDef *USARTx) | |
2147 { | |
2148 CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE); | |
2149 } | |
2150 | |
2151 /** | |
2152 * @brief Disable Transmission Complete Interrupt | |
2153 * @rmtoll CR1 TCIE LL_USART_DisableIT_TC | |
2154 * @param USARTx USART Instance | |
2155 * @retval None | |
2156 */ | |
2157 __STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx) | |
2158 { | |
2159 CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE); | |
2160 } | |
2161 | |
2162 /** | |
2163 * @brief Disable TX Empty Interrupt | |
2164 * @rmtoll CR1 TXEIE LL_USART_DisableIT_TXE | |
2165 * @param USARTx USART Instance | |
2166 * @retval None | |
2167 */ | |
2168 __STATIC_INLINE void LL_USART_DisableIT_TXE(USART_TypeDef *USARTx) | |
2169 { | |
2170 CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE); | |
2171 } | |
2172 | |
2173 /** | |
2174 * @brief Disable Parity Error Interrupt | |
2175 * @rmtoll CR1 PEIE LL_USART_DisableIT_PE | |
2176 * @param USARTx USART Instance | |
2177 * @retval None | |
2178 */ | |
2179 __STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx) | |
2180 { | |
2181 CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE); | |
2182 } | |
2183 | |
2184 /** | |
2185 * @brief Disable LIN Break Detection Interrupt | |
2186 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not | |
2187 * LIN feature is supported by the USARTx instance. | |
2188 * @rmtoll CR2 LBDIE LL_USART_DisableIT_LBD | |
2189 * @param USARTx USART Instance | |
2190 * @retval None | |
2191 */ | |
2192 __STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx) | |
2193 { | |
2194 CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE); | |
2195 } | |
2196 | |
2197 /** | |
2198 * @brief Disable Error Interrupt | |
2199 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing | |
2200 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_SR register). | |
2201 * 0: Interrupt is inhibited | |
2202 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_SR register. | |
2203 * @rmtoll CR3 EIE LL_USART_DisableIT_ERROR | |
2204 * @param USARTx USART Instance | |
2205 * @retval None | |
2206 */ | |
2207 __STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx) | |
2208 { | |
2209 CLEAR_BIT(USARTx->CR3, USART_CR3_EIE); | |
2210 } | |
2211 | |
2212 /** | |
2213 * @brief Disable CTS Interrupt | |
2214 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not | |
2215 * Hardware Flow control feature is supported by the USARTx instance. | |
2216 * @rmtoll CR3 CTSIE LL_USART_DisableIT_CTS | |
2217 * @param USARTx USART Instance | |
2218 * @retval None | |
2219 */ | |
2220 __STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx) | |
2221 { | |
2222 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE); | |
2223 } | |
2224 | |
2225 /** | |
2226 * @brief Check if the USART IDLE Interrupt source is enabled or disabled. | |
2227 * @rmtoll CR1 IDLEIE LL_USART_IsEnabledIT_IDLE | |
2228 * @param USARTx USART Instance | |
2229 * @retval State of bit (1 or 0). | |
2230 */ | |
2231 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(USART_TypeDef *USARTx) | |
2232 { | |
2233 return (READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE)); | |
2234 } | |
2235 | |
2236 /** | |
2237 * @brief Check if the USART RX Not Empty Interrupt is enabled or disabled. | |
2238 * @rmtoll CR1 RXNEIE LL_USART_IsEnabledIT_RXNE | |
2239 * @param USARTx USART Instance | |
2240 * @retval State of bit (1 or 0). | |
2241 */ | |
2242 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE(USART_TypeDef *USARTx) | |
2243 { | |
2244 return (READ_BIT(USARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE)); | |
2245 } | |
2246 | |
2247 /** | |
2248 * @brief Check if the USART Transmission Complete Interrupt is enabled or disabled. | |
2249 * @rmtoll CR1 TCIE LL_USART_IsEnabledIT_TC | |
2250 * @param USARTx USART Instance | |
2251 * @retval State of bit (1 or 0). | |
2252 */ | |
2253 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(USART_TypeDef *USARTx) | |
2254 { | |
2255 return (READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE)); | |
2256 } | |
2257 | |
2258 /** | |
2259 * @brief Check if the USART TX Empty Interrupt is enabled or disabled. | |
2260 * @rmtoll CR1 TXEIE LL_USART_IsEnabledIT_TXE | |
2261 * @param USARTx USART Instance | |
2262 * @retval State of bit (1 or 0). | |
2263 */ | |
2264 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE(USART_TypeDef *USARTx) | |
2265 { | |
2266 return (READ_BIT(USARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE)); | |
2267 } | |
2268 | |
2269 /** | |
2270 * @brief Check if the USART Parity Error Interrupt is enabled or disabled. | |
2271 * @rmtoll CR1 PEIE LL_USART_IsEnabledIT_PE | |
2272 * @param USARTx USART Instance | |
2273 * @retval State of bit (1 or 0). | |
2274 */ | |
2275 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(USART_TypeDef *USARTx) | |
2276 { | |
2277 return (READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE)); | |
2278 } | |
2279 | |
2280 /** | |
2281 * @brief Check if the USART LIN Break Detection Interrupt is enabled or disabled. | |
2282 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not | |
2283 * LIN feature is supported by the USARTx instance. | |
2284 * @rmtoll CR2 LBDIE LL_USART_IsEnabledIT_LBD | |
2285 * @param USARTx USART Instance | |
2286 * @retval State of bit (1 or 0). | |
2287 */ | |
2288 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(USART_TypeDef *USARTx) | |
2289 { | |
2290 return (READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE)); | |
2291 } | |
2292 | |
2293 /** | |
2294 * @brief Check if the USART Error Interrupt is enabled or disabled. | |
2295 * @rmtoll CR3 EIE LL_USART_IsEnabledIT_ERROR | |
2296 * @param USARTx USART Instance | |
2297 * @retval State of bit (1 or 0). | |
2298 */ | |
2299 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(USART_TypeDef *USARTx) | |
2300 { | |
2301 return (READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE)); | |
2302 } | |
2303 | |
2304 /** | |
2305 * @brief Check if the USART CTS Interrupt is enabled or disabled. | |
2306 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not | |
2307 * Hardware Flow control feature is supported by the USARTx instance. | |
2308 * @rmtoll CR3 CTSIE LL_USART_IsEnabledIT_CTS | |
2309 * @param USARTx USART Instance | |
2310 * @retval State of bit (1 or 0). | |
2311 */ | |
2312 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(USART_TypeDef *USARTx) | |
2313 { | |
2314 return (READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE)); | |
2315 } | |
2316 | |
2317 /** | |
2318 * @} | |
2319 */ | |
2320 | |
2321 /** @defgroup USART_LL_EF_DMA_Management DMA_Management | |
2322 * @{ | |
2323 */ | |
2324 | |
2325 /** | |
2326 * @brief Enable DMA Mode for reception | |
2327 * @rmtoll CR3 DMAR LL_USART_EnableDMAReq_RX | |
2328 * @param USARTx USART Instance | |
2329 * @retval None | |
2330 */ | |
2331 __STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx) | |
2332 { | |
2333 SET_BIT(USARTx->CR3, USART_CR3_DMAR); | |
2334 } | |
2335 | |
2336 /** | |
2337 * @brief Disable DMA Mode for reception | |
2338 * @rmtoll CR3 DMAR LL_USART_DisableDMAReq_RX | |
2339 * @param USARTx USART Instance | |
2340 * @retval None | |
2341 */ | |
2342 __STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx) | |
2343 { | |
2344 CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR); | |
2345 } | |
2346 | |
2347 /** | |
2348 * @brief Check if DMA Mode is enabled for reception | |
2349 * @rmtoll CR3 DMAR LL_USART_IsEnabledDMAReq_RX | |
2350 * @param USARTx USART Instance | |
2351 * @retval State of bit (1 or 0). | |
2352 */ | |
2353 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(USART_TypeDef *USARTx) | |
2354 { | |
2355 return (READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR)); | |
2356 } | |
2357 | |
2358 /** | |
2359 * @brief Enable DMA Mode for transmission | |
2360 * @rmtoll CR3 DMAT LL_USART_EnableDMAReq_TX | |
2361 * @param USARTx USART Instance | |
2362 * @retval None | |
2363 */ | |
2364 __STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx) | |
2365 { | |
2366 SET_BIT(USARTx->CR3, USART_CR3_DMAT); | |
2367 } | |
2368 | |
2369 /** | |
2370 * @brief Disable DMA Mode for transmission | |
2371 * @rmtoll CR3 DMAT LL_USART_DisableDMAReq_TX | |
2372 * @param USARTx USART Instance | |
2373 * @retval None | |
2374 */ | |
2375 __STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx) | |
2376 { | |
2377 CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT); | |
2378 } | |
2379 | |
2380 /** | |
2381 * @brief Check if DMA Mode is enabled for transmission | |
2382 * @rmtoll CR3 DMAT LL_USART_IsEnabledDMAReq_TX | |
2383 * @param USARTx USART Instance | |
2384 * @retval State of bit (1 or 0). | |
2385 */ | |
2386 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(USART_TypeDef *USARTx) | |
2387 { | |
2388 return (READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT)); | |
2389 } | |
2390 | |
2391 /** | |
2392 * @brief Get the data register address used for DMA transfer | |
2393 * @rmtoll DR DR LL_USART_DMA_GetRegAddr | |
2394 * @note Address of Data Register is valid for both Transmit and Receive transfers. | |
2395 * @param USARTx USART Instance | |
2396 * @retval Address of data register | |
2397 */ | |
2398 __STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(USART_TypeDef *USARTx) | |
2399 { | |
2400 /* return address of DR register */ | |
2401 return ((uint32_t) &(USARTx->DR)); | |
2402 } | |
2403 | |
2404 /** | |
2405 * @} | |
2406 */ | |
2407 | |
2408 /** @defgroup USART_LL_EF_Data_Management Data_Management | |
2409 * @{ | |
2410 */ | |
2411 | |
2412 /** | |
2413 * @brief Read Receiver Data register (Receive Data value, 8 bits) | |
2414 * @rmtoll DR DR LL_USART_ReceiveData8 | |
2415 * @param USARTx USART Instance | |
2416 * @retval Value between Min_Data=0x00 and Max_Data=0xFF | |
2417 */ | |
2418 __STATIC_INLINE uint8_t LL_USART_ReceiveData8(USART_TypeDef *USARTx) | |
2419 { | |
2420 return (uint8_t)(READ_BIT(USARTx->DR, USART_DR_DR)); | |
2421 } | |
2422 | |
2423 /** | |
2424 * @brief Read Receiver Data register (Receive Data value, 9 bits) | |
2425 * @rmtoll DR DR LL_USART_ReceiveData9 | |
2426 * @param USARTx USART Instance | |
2427 * @retval Value between Min_Data=0x00 and Max_Data=0x1FF | |
2428 */ | |
2429 __STATIC_INLINE uint16_t LL_USART_ReceiveData9(USART_TypeDef *USARTx) | |
2430 { | |
2431 return (uint16_t)(READ_BIT(USARTx->DR, USART_DR_DR)); | |
2432 } | |
2433 | |
2434 /** | |
2435 * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits) | |
2436 * @rmtoll DR DR LL_USART_TransmitData8 | |
2437 * @param USARTx USART Instance | |
2438 * @param Value between Min_Data=0x00 and Max_Data=0xFF | |
2439 * @retval None | |
2440 */ | |
2441 __STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value) | |
2442 { | |
2443 USARTx->DR = Value; | |
2444 } | |
2445 | |
2446 /** | |
2447 * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits) | |
2448 * @rmtoll DR DR LL_USART_TransmitData9 | |
2449 * @param USARTx USART Instance | |
2450 * @param Value between Min_Data=0x00 and Max_Data=0x1FF | |
2451 * @retval None | |
2452 */ | |
2453 __STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value) | |
2454 { | |
2455 USARTx->DR = Value & 0x1FFU; | |
2456 } | |
2457 | |
2458 /** | |
2459 * @} | |
2460 */ | |
2461 | |
2462 /** @defgroup USART_LL_EF_Execution Execution | |
2463 * @{ | |
2464 */ | |
2465 | |
2466 /** | |
2467 * @brief Request Break sending | |
2468 * @rmtoll CR1 SBK LL_USART_RequestBreakSending | |
2469 * @param USARTx USART Instance | |
2470 * @retval None | |
2471 */ | |
2472 __STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx) | |
2473 { | |
2474 SET_BIT(USARTx->CR1, USART_CR1_SBK); | |
2475 } | |
2476 | |
2477 /** | |
2478 * @brief Put USART in Mute mode | |
2479 * @rmtoll CR1 RWU LL_USART_RequestEnterMuteMode | |
2480 * @param USARTx USART Instance | |
2481 * @retval None | |
2482 */ | |
2483 __STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx) | |
2484 { | |
2485 SET_BIT(USARTx->CR1, USART_CR1_RWU); | |
2486 } | |
2487 | |
2488 /** | |
2489 * @brief Put USART in Active mode | |
2490 * @rmtoll CR1 RWU LL_USART_RequestExitMuteMode | |
2491 * @param USARTx USART Instance | |
2492 * @retval None | |
2493 */ | |
2494 __STATIC_INLINE void LL_USART_RequestExitMuteMode(USART_TypeDef *USARTx) | |
2495 { | |
2496 CLEAR_BIT(USARTx->CR1, USART_CR1_RWU); | |
2497 } | |
2498 | |
2499 /** | |
2500 * @} | |
2501 */ | |
2502 | |
2503 #if defined(USE_FULL_LL_DRIVER) | |
2504 /** @defgroup USART_LL_EF_Init Initialization and de-initialization functions | |
2505 * @{ | |
2506 */ | |
2507 ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx); | |
2508 ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct); | |
2509 void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct); | |
2510 ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct); | |
2511 void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct); | |
2512 /** | |
2513 * @} | |
2514 */ | |
2515 #endif /* USE_FULL_LL_DRIVER */ | |
2516 | |
2517 /** | |
2518 * @} | |
2519 */ | |
2520 | |
2521 /** | |
2522 * @} | |
2523 */ | |
2524 | |
2525 #endif /* USART1 || USART2 || USART3 || USART6 || UART4 || UART5 || UART7 || UART8 || UART9 || UART10 */ | |
2526 | |
2527 /** | |
2528 * @} | |
2529 */ | |
2530 | |
2531 #ifdef __cplusplus | |
2532 } | |
2533 #endif | |
2534 | |
2535 #endif /* __STM32F4xx_LL_USART_H */ | |
2536 | |
2537 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |