2 ******************************************************************************
\r
3 * @file stm32l4xx_hal_uart_ex.h
\r
4 * @author MCD Application Team
\r
5 * @brief Header file of UART HAL Extended module.
\r
6 ******************************************************************************
\r
9 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
\r
10 * All rights reserved.</center></h2>
\r
12 * This software component is licensed by ST under BSD 3-Clause license,
\r
13 * the "License"; You may not use this file except in compliance with the
\r
14 * License. You may obtain a copy of the License at:
\r
15 * opensource.org/licenses/BSD-3-Clause
\r
17 ******************************************************************************
\r
20 /* Define to prevent recursive inclusion -------------------------------------*/
\r
21 #ifndef STM32L4xx_HAL_UART_EX_H
\r
22 #define STM32L4xx_HAL_UART_EX_H
\r
28 /* Includes ------------------------------------------------------------------*/
\r
29 #include "stm32l4xx_hal_def.h"
\r
31 /** @addtogroup STM32L4xx_HAL_Driver
\r
35 /** @addtogroup UARTEx
\r
39 /* Exported types ------------------------------------------------------------*/
\r
40 /** @defgroup UARTEx_Exported_Types UARTEx Exported Types
\r
45 * @brief UART wake up from stop mode parameters
\r
49 uint32_t WakeUpEvent; /*!< Specifies which event will activate the Wakeup from Stop mode flag (WUF).
\r
50 This parameter can be a value of @ref UART_WakeUp_from_Stop_Selection.
\r
51 If set to UART_WAKEUP_ON_ADDRESS, the two other fields below must
\r
54 uint16_t AddressLength; /*!< Specifies whether the address is 4 or 7-bit long.
\r
55 This parameter can be a value of @ref UARTEx_WakeUp_Address_Length. */
\r
57 uint8_t Address; /*!< UART/USART node address (7-bit long max). */
\r
58 } UART_WakeUpTypeDef;
\r
64 /* Exported constants --------------------------------------------------------*/
\r
65 /** @defgroup UARTEx_Exported_Constants UARTEx Exported Constants
\r
69 /** @defgroup UARTEx_Word_Length UARTEx Word Length
\r
72 #define UART_WORDLENGTH_7B USART_CR1_M1 /*!< 7-bit long UART frame */
\r
73 #define UART_WORDLENGTH_8B 0x00000000U /*!< 8-bit long UART frame */
\r
74 #define UART_WORDLENGTH_9B USART_CR1_M0 /*!< 9-bit long UART frame */
\r
79 /** @defgroup UARTEx_WakeUp_Address_Length UARTEx WakeUp Address Length
\r
82 #define UART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit long wake-up address */
\r
83 #define UART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit long wake-up address */
\r
88 #if defined(USART_CR1_FIFOEN)
\r
89 /** @defgroup UARTEx_FIFO_mode UARTEx FIFO mode
\r
90 * @brief UART FIFO mode
\r
93 #define UART_FIFOMODE_DISABLE 0x00000000U /*!< FIFO mode disable */
\r
94 #define UART_FIFOMODE_ENABLE USART_CR1_FIFOEN /*!< FIFO mode enable */
\r
99 /** @defgroup UARTEx_TXFIFO_threshold_level UARTEx TXFIFO threshold level
\r
100 * @brief UART TXFIFO threshold level
\r
103 #define UART_TXFIFO_THRESHOLD_1_8 0x00000000U /*!< TXFIFO reaches 1/8 of its depth */
\r
104 #define UART_TXFIFO_THRESHOLD_1_4 USART_CR3_TXFTCFG_0 /*!< TXFIFO reaches 1/4 of its depth */
\r
105 #define UART_TXFIFO_THRESHOLD_1_2 USART_CR3_TXFTCFG_1 /*!< TXFIFO reaches 1/2 of its depth */
\r
106 #define UART_TXFIFO_THRESHOLD_3_4 (USART_CR3_TXFTCFG_0|USART_CR3_TXFTCFG_1) /*!< TXFIFO reaches 3/4 of its depth */
\r
107 #define UART_TXFIFO_THRESHOLD_7_8 USART_CR3_TXFTCFG_2 /*!< TXFIFO reaches 7/8 of its depth */
\r
108 #define UART_TXFIFO_THRESHOLD_8_8 (USART_CR3_TXFTCFG_2|USART_CR3_TXFTCFG_0) /*!< TXFIFO becomes empty */
\r
113 /** @defgroup UARTEx_RXFIFO_threshold_level UARTEx RXFIFO threshold level
\r
114 * @brief UART RXFIFO threshold level
\r
117 #define UART_RXFIFO_THRESHOLD_1_8 0x00000000U /*!< RXFIFO FIFO reaches 1/8 of its depth */
\r
118 #define UART_RXFIFO_THRESHOLD_1_4 USART_CR3_RXFTCFG_0 /*!< RXFIFO FIFO reaches 1/4 of its depth */
\r
119 #define UART_RXFIFO_THRESHOLD_1_2 USART_CR3_RXFTCFG_1 /*!< RXFIFO FIFO reaches 1/2 of its depth */
\r
120 #define UART_RXFIFO_THRESHOLD_3_4 (USART_CR3_RXFTCFG_0|USART_CR3_RXFTCFG_1) /*!< RXFIFO FIFO reaches 3/4 of its depth */
\r
121 #define UART_RXFIFO_THRESHOLD_7_8 USART_CR3_RXFTCFG_2 /*!< RXFIFO FIFO reaches 7/8 of its depth */
\r
122 #define UART_RXFIFO_THRESHOLD_8_8 (USART_CR3_RXFTCFG_2|USART_CR3_RXFTCFG_0) /*!< RXFIFO FIFO becomes full */
\r
126 #endif /* USART_CR1_FIFOEN */
\r
132 /* Exported macros -----------------------------------------------------------*/
\r
133 /* Exported functions --------------------------------------------------------*/
\r
134 /** @addtogroup UARTEx_Exported_Functions
\r
138 /** @addtogroup UARTEx_Exported_Functions_Group1
\r
142 /* Initialization and de-initialization functions ****************************/
\r
143 HAL_StatusTypeDef HAL_RS485Ex_Init(UART_HandleTypeDef *huart, uint32_t Polarity, uint32_t AssertionTime,
\r
144 uint32_t DeassertionTime);
\r
150 /** @addtogroup UARTEx_Exported_Functions_Group2
\r
154 void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart);
\r
156 #if defined(USART_CR1_FIFOEN)
\r
157 void HAL_UARTEx_RxFifoFullCallback(UART_HandleTypeDef *huart);
\r
158 void HAL_UARTEx_TxFifoEmptyCallback(UART_HandleTypeDef *huart);
\r
159 #endif /* USART_CR1_FIFOEN */
\r
165 /** @addtogroup UARTEx_Exported_Functions_Group3
\r
169 /* Peripheral Control functions **********************************************/
\r
170 HAL_StatusTypeDef HAL_UARTEx_StopModeWakeUpSourceConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection);
\r
171 HAL_StatusTypeDef HAL_UARTEx_EnableStopMode(UART_HandleTypeDef *huart);
\r
172 HAL_StatusTypeDef HAL_UARTEx_DisableStopMode(UART_HandleTypeDef *huart);
\r
173 #if defined(USART_CR3_UCESM)
\r
174 HAL_StatusTypeDef HAL_UARTEx_EnableClockStopMode(UART_HandleTypeDef *huart);
\r
175 HAL_StatusTypeDef HAL_UARTEx_DisableClockStopMode(UART_HandleTypeDef *huart);
\r
176 #endif /* USART_CR3_UCESM */
\r
177 HAL_StatusTypeDef HAL_MultiProcessorEx_AddressLength_Set(UART_HandleTypeDef *huart, uint32_t AddressLength);
\r
178 #if defined(USART_CR1_FIFOEN)
\r
179 HAL_StatusTypeDef HAL_UARTEx_EnableFifoMode(UART_HandleTypeDef *huart);
\r
180 HAL_StatusTypeDef HAL_UARTEx_DisableFifoMode(UART_HandleTypeDef *huart);
\r
181 HAL_StatusTypeDef HAL_UARTEx_SetTxFifoThreshold(UART_HandleTypeDef *huart, uint32_t Threshold);
\r
182 HAL_StatusTypeDef HAL_UARTEx_SetRxFifoThreshold(UART_HandleTypeDef *huart, uint32_t Threshold);
\r
183 #endif /* USART_CR1_FIFOEN */
\r
193 /* Private macros ------------------------------------------------------------*/
\r
194 /** @defgroup UARTEx_Private_Macros UARTEx Private Macros
\r
198 /** @brief Report the UART clock source.
\r
199 * @param __HANDLE__ specifies the UART Handle.
\r
200 * @param __CLOCKSOURCE__ output variable.
\r
201 * @retval UART clocking source, written in __CLOCKSOURCE__.
\r
203 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) \
\r
204 || defined (STM32L496xx) || defined (STM32L4A6xx) \
\r
205 || defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)
\r
206 #define UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
\r
208 if((__HANDLE__)->Instance == USART1) \
\r
210 switch(__HAL_RCC_GET_USART1_SOURCE()) \
\r
212 case RCC_USART1CLKSOURCE_PCLK2: \
\r
213 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK2; \
\r
215 case RCC_USART1CLKSOURCE_HSI: \
\r
216 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
218 case RCC_USART1CLKSOURCE_SYSCLK: \
\r
219 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
221 case RCC_USART1CLKSOURCE_LSE: \
\r
222 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
225 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
229 else if((__HANDLE__)->Instance == USART2) \
\r
231 switch(__HAL_RCC_GET_USART2_SOURCE()) \
\r
233 case RCC_USART2CLKSOURCE_PCLK1: \
\r
234 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
236 case RCC_USART2CLKSOURCE_HSI: \
\r
237 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
239 case RCC_USART2CLKSOURCE_SYSCLK: \
\r
240 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
242 case RCC_USART2CLKSOURCE_LSE: \
\r
243 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
246 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
250 else if((__HANDLE__)->Instance == USART3) \
\r
252 switch(__HAL_RCC_GET_USART3_SOURCE()) \
\r
254 case RCC_USART3CLKSOURCE_PCLK1: \
\r
255 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
257 case RCC_USART3CLKSOURCE_HSI: \
\r
258 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
260 case RCC_USART3CLKSOURCE_SYSCLK: \
\r
261 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
263 case RCC_USART3CLKSOURCE_LSE: \
\r
264 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
267 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
271 else if((__HANDLE__)->Instance == UART4) \
\r
273 switch(__HAL_RCC_GET_UART4_SOURCE()) \
\r
275 case RCC_UART4CLKSOURCE_PCLK1: \
\r
276 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
278 case RCC_UART4CLKSOURCE_HSI: \
\r
279 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
281 case RCC_UART4CLKSOURCE_SYSCLK: \
\r
282 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
284 case RCC_UART4CLKSOURCE_LSE: \
\r
285 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
288 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
292 else if((__HANDLE__)->Instance == UART5) \
\r
294 switch(__HAL_RCC_GET_UART5_SOURCE()) \
\r
296 case RCC_UART5CLKSOURCE_PCLK1: \
\r
297 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
299 case RCC_UART5CLKSOURCE_HSI: \
\r
300 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
302 case RCC_UART5CLKSOURCE_SYSCLK: \
\r
303 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
305 case RCC_UART5CLKSOURCE_LSE: \
\r
306 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
309 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
313 else if((__HANDLE__)->Instance == LPUART1) \
\r
315 switch(__HAL_RCC_GET_LPUART1_SOURCE()) \
\r
317 case RCC_LPUART1CLKSOURCE_PCLK1: \
\r
318 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
320 case RCC_LPUART1CLKSOURCE_HSI: \
\r
321 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
323 case RCC_LPUART1CLKSOURCE_SYSCLK: \
\r
324 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
326 case RCC_LPUART1CLKSOURCE_LSE: \
\r
327 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
330 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
336 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
339 #elif defined (STM32L412xx) || defined (STM32L422xx) \
\r
340 || defined (STM32L431xx) || defined (STM32L433xx) || defined (STM32L443xx)
\r
341 #define UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
\r
343 if((__HANDLE__)->Instance == USART1) \
\r
345 switch(__HAL_RCC_GET_USART1_SOURCE()) \
\r
347 case RCC_USART1CLKSOURCE_PCLK2: \
\r
348 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK2; \
\r
350 case RCC_USART1CLKSOURCE_HSI: \
\r
351 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
353 case RCC_USART1CLKSOURCE_SYSCLK: \
\r
354 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
356 case RCC_USART1CLKSOURCE_LSE: \
\r
357 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
360 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
364 else if((__HANDLE__)->Instance == USART2) \
\r
366 switch(__HAL_RCC_GET_USART2_SOURCE()) \
\r
368 case RCC_USART2CLKSOURCE_PCLK1: \
\r
369 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
371 case RCC_USART2CLKSOURCE_HSI: \
\r
372 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
374 case RCC_USART2CLKSOURCE_SYSCLK: \
\r
375 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
377 case RCC_USART2CLKSOURCE_LSE: \
\r
378 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
381 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
385 else if((__HANDLE__)->Instance == USART3) \
\r
387 switch(__HAL_RCC_GET_USART3_SOURCE()) \
\r
389 case RCC_USART3CLKSOURCE_PCLK1: \
\r
390 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
392 case RCC_USART3CLKSOURCE_HSI: \
\r
393 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
395 case RCC_USART3CLKSOURCE_SYSCLK: \
\r
396 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
398 case RCC_USART3CLKSOURCE_LSE: \
\r
399 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
402 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
406 else if((__HANDLE__)->Instance == LPUART1) \
\r
408 switch(__HAL_RCC_GET_LPUART1_SOURCE()) \
\r
410 case RCC_LPUART1CLKSOURCE_PCLK1: \
\r
411 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
413 case RCC_LPUART1CLKSOURCE_HSI: \
\r
414 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
416 case RCC_LPUART1CLKSOURCE_SYSCLK: \
\r
417 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
419 case RCC_LPUART1CLKSOURCE_LSE: \
\r
420 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
423 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
429 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
432 #elif defined (STM32L432xx) || defined (STM32L442xx)
\r
433 #define UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
\r
435 if((__HANDLE__)->Instance == USART1) \
\r
437 switch(__HAL_RCC_GET_USART1_SOURCE()) \
\r
439 case RCC_USART1CLKSOURCE_PCLK2: \
\r
440 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK2; \
\r
442 case RCC_USART1CLKSOURCE_HSI: \
\r
443 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
445 case RCC_USART1CLKSOURCE_SYSCLK: \
\r
446 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
448 case RCC_USART1CLKSOURCE_LSE: \
\r
449 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
452 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
456 else if((__HANDLE__)->Instance == USART2) \
\r
458 switch(__HAL_RCC_GET_USART2_SOURCE()) \
\r
460 case RCC_USART2CLKSOURCE_PCLK1: \
\r
461 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
463 case RCC_USART2CLKSOURCE_HSI: \
\r
464 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
466 case RCC_USART2CLKSOURCE_SYSCLK: \
\r
467 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
469 case RCC_USART2CLKSOURCE_LSE: \
\r
470 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
473 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
477 else if((__HANDLE__)->Instance == LPUART1) \
\r
479 switch(__HAL_RCC_GET_LPUART1_SOURCE()) \
\r
481 case RCC_LPUART1CLKSOURCE_PCLK1: \
\r
482 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
484 case RCC_LPUART1CLKSOURCE_HSI: \
\r
485 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
487 case RCC_LPUART1CLKSOURCE_SYSCLK: \
\r
488 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
490 case RCC_LPUART1CLKSOURCE_LSE: \
\r
491 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
494 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
500 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
503 #elif defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx)
\r
504 #define UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
\r
506 if((__HANDLE__)->Instance == USART1) \
\r
508 switch(__HAL_RCC_GET_USART1_SOURCE()) \
\r
510 case RCC_USART1CLKSOURCE_PCLK2: \
\r
511 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK2; \
\r
513 case RCC_USART1CLKSOURCE_HSI: \
\r
514 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
516 case RCC_USART1CLKSOURCE_SYSCLK: \
\r
517 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
519 case RCC_USART1CLKSOURCE_LSE: \
\r
520 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
523 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
527 else if((__HANDLE__)->Instance == USART2) \
\r
529 switch(__HAL_RCC_GET_USART2_SOURCE()) \
\r
531 case RCC_USART2CLKSOURCE_PCLK1: \
\r
532 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
534 case RCC_USART2CLKSOURCE_HSI: \
\r
535 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
537 case RCC_USART2CLKSOURCE_SYSCLK: \
\r
538 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
540 case RCC_USART2CLKSOURCE_LSE: \
\r
541 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
544 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
548 else if((__HANDLE__)->Instance == USART3) \
\r
550 switch(__HAL_RCC_GET_USART3_SOURCE()) \
\r
552 case RCC_USART3CLKSOURCE_PCLK1: \
\r
553 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
555 case RCC_USART3CLKSOURCE_HSI: \
\r
556 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
558 case RCC_USART3CLKSOURCE_SYSCLK: \
\r
559 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
561 case RCC_USART3CLKSOURCE_LSE: \
\r
562 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
565 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
569 else if((__HANDLE__)->Instance == UART4) \
\r
571 switch(__HAL_RCC_GET_UART4_SOURCE()) \
\r
573 case RCC_UART4CLKSOURCE_PCLK1: \
\r
574 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
576 case RCC_UART4CLKSOURCE_HSI: \
\r
577 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
579 case RCC_UART4CLKSOURCE_SYSCLK: \
\r
580 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
582 case RCC_UART4CLKSOURCE_LSE: \
\r
583 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
586 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
590 else if((__HANDLE__)->Instance == LPUART1) \
\r
592 switch(__HAL_RCC_GET_LPUART1_SOURCE()) \
\r
594 case RCC_LPUART1CLKSOURCE_PCLK1: \
\r
595 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
\r
597 case RCC_LPUART1CLKSOURCE_HSI: \
\r
598 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
\r
600 case RCC_LPUART1CLKSOURCE_SYSCLK: \
\r
601 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
\r
603 case RCC_LPUART1CLKSOURCE_LSE: \
\r
604 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
\r
607 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
613 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
\r
616 #endif /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx ||
\r
617 * STM32L496xx || STM32L4A6xx ||
\r
618 * STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx
\r
621 /** @brief Report the UART mask to apply to retrieve the received data
\r
622 * according to the word length and to the parity bits activation.
\r
623 * @note If PCE = 1, the parity bit is not included in the data extracted
\r
624 * by the reception API().
\r
625 * This masking operation is not carried out in the case of
\r
627 * @param __HANDLE__ specifies the UART Handle.
\r
628 * @retval None, the mask to apply to UART RDR register is stored in (__HANDLE__)->Mask field.
\r
630 #define UART_MASK_COMPUTATION(__HANDLE__) \
\r
632 if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_9B) \
\r
634 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
\r
636 (__HANDLE__)->Mask = 0x01FFU ; \
\r
640 (__HANDLE__)->Mask = 0x00FFU ; \
\r
643 else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_8B) \
\r
645 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
\r
647 (__HANDLE__)->Mask = 0x00FFU ; \
\r
651 (__HANDLE__)->Mask = 0x007FU ; \
\r
654 else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_7B) \
\r
656 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
\r
658 (__HANDLE__)->Mask = 0x007FU ; \
\r
662 (__HANDLE__)->Mask = 0x003FU ; \
\r
667 (__HANDLE__)->Mask = 0x0000U; \
\r
672 * @brief Ensure that UART frame length is valid.
\r
673 * @param __LENGTH__ UART frame length.
\r
674 * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid)
\r
676 #define IS_UART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == UART_WORDLENGTH_7B) || \
\r
677 ((__LENGTH__) == UART_WORDLENGTH_8B) || \
\r
678 ((__LENGTH__) == UART_WORDLENGTH_9B))
\r
681 * @brief Ensure that UART wake-up address length is valid.
\r
682 * @param __ADDRESS__ UART wake-up address length.
\r
683 * @retval SET (__ADDRESS__ is valid) or RESET (__ADDRESS__ is invalid)
\r
685 #define IS_UART_ADDRESSLENGTH_DETECT(__ADDRESS__) (((__ADDRESS__) == UART_ADDRESS_DETECT_4B) || \
\r
686 ((__ADDRESS__) == UART_ADDRESS_DETECT_7B))
\r
688 #if defined(USART_CR1_FIFOEN)
\r
690 * @brief Ensure that UART TXFIFO threshold level is valid.
\r
691 * @param __THRESHOLD__ UART TXFIFO threshold level.
\r
692 * @retval SET (__THRESHOLD__ is valid) or RESET (__THRESHOLD__ is invalid)
\r
694 #define IS_UART_TXFIFO_THRESHOLD(__THRESHOLD__) (((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_1_8) || \
\r
695 ((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_1_4) || \
\r
696 ((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_1_2) || \
\r
697 ((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_3_4) || \
\r
698 ((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_7_8) || \
\r
699 ((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_8_8))
\r
702 * @brief Ensure that UART RXFIFO threshold level is valid.
\r
703 * @param __THRESHOLD__ UART RXFIFO threshold level.
\r
704 * @retval SET (__THRESHOLD__ is valid) or RESET (__THRESHOLD__ is invalid)
\r
706 #define IS_UART_RXFIFO_THRESHOLD(__THRESHOLD__) (((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_1_8) || \
\r
707 ((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_1_4) || \
\r
708 ((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_1_2) || \
\r
709 ((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_3_4) || \
\r
710 ((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_7_8) || \
\r
711 ((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_8_8))
\r
712 #endif /* USART_CR1_FIFOEN */
\r
718 /* Private functions ---------------------------------------------------------*/
\r
732 #endif /* STM32L4xx_HAL_UART_EX_H */
\r
734 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r