mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
107:4f6c30876dfa
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 107:4f6c30876dfa 1 /**
Kojto 107:4f6c30876dfa 2 ******************************************************************************
Kojto 107:4f6c30876dfa 3 * @file stm32l4xx_hal_uart_ex.h
Kojto 107:4f6c30876dfa 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.5.1
Kojto 122:f9eeca106725 6 * @date 31-May-2016
Kojto 107:4f6c30876dfa 7 * @brief Header file of UART HAL Extended module.
Kojto 107:4f6c30876dfa 8 ******************************************************************************
Kojto 107:4f6c30876dfa 9 * @attention
Kojto 107:4f6c30876dfa 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 107:4f6c30876dfa 12 *
Kojto 107:4f6c30876dfa 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 107:4f6c30876dfa 14 * are permitted provided that the following conditions are met:
Kojto 107:4f6c30876dfa 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 107:4f6c30876dfa 16 * this list of conditions and the following disclaimer.
Kojto 107:4f6c30876dfa 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 107:4f6c30876dfa 18 * this list of conditions and the following disclaimer in the documentation
Kojto 107:4f6c30876dfa 19 * and/or other materials provided with the distribution.
Kojto 107:4f6c30876dfa 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 107:4f6c30876dfa 21 * may be used to endorse or promote products derived from this software
Kojto 107:4f6c30876dfa 22 * without specific prior written permission.
Kojto 107:4f6c30876dfa 23 *
Kojto 107:4f6c30876dfa 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 107:4f6c30876dfa 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 107:4f6c30876dfa 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 107:4f6c30876dfa 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 107:4f6c30876dfa 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 107:4f6c30876dfa 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 107:4f6c30876dfa 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 107:4f6c30876dfa 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 107:4f6c30876dfa 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 107:4f6c30876dfa 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 107:4f6c30876dfa 34 *
Kojto 107:4f6c30876dfa 35 ******************************************************************************
Kojto 107:4f6c30876dfa 36 */
Kojto 107:4f6c30876dfa 37
Kojto 107:4f6c30876dfa 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 107:4f6c30876dfa 39 #ifndef __STM32L4xx_HAL_UART_EX_H
Kojto 107:4f6c30876dfa 40 #define __STM32L4xx_HAL_UART_EX_H
Kojto 107:4f6c30876dfa 41
Kojto 107:4f6c30876dfa 42 #ifdef __cplusplus
Kojto 107:4f6c30876dfa 43 extern "C" {
Kojto 107:4f6c30876dfa 44 #endif
Kojto 107:4f6c30876dfa 45
Kojto 107:4f6c30876dfa 46 /* Includes ------------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 47 #include "stm32l4xx_hal_def.h"
Kojto 107:4f6c30876dfa 48
Kojto 107:4f6c30876dfa 49 /** @addtogroup STM32L4xx_HAL_Driver
Kojto 107:4f6c30876dfa 50 * @{
Kojto 107:4f6c30876dfa 51 */
Kojto 107:4f6c30876dfa 52
Kojto 107:4f6c30876dfa 53 /** @addtogroup UARTEx
Kojto 107:4f6c30876dfa 54 * @{
Kojto 107:4f6c30876dfa 55 */
Kojto 107:4f6c30876dfa 56
Kojto 107:4f6c30876dfa 57 /* Exported types ------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 58 /** @defgroup UARTEx_Exported_Types UARTEx Exported Types
Kojto 107:4f6c30876dfa 59 * @{
Kojto 107:4f6c30876dfa 60 */
Kojto 107:4f6c30876dfa 61
Kojto 107:4f6c30876dfa 62 /**
Kojto 107:4f6c30876dfa 63 * @brief UART wake up from stop mode parameters
Kojto 107:4f6c30876dfa 64 */
Kojto 107:4f6c30876dfa 65 typedef struct
Kojto 107:4f6c30876dfa 66 {
Kojto 107:4f6c30876dfa 67 uint32_t WakeUpEvent; /*!< Specifies which event will activat the Wakeup from Stop mode flag (WUF).
Kojto 107:4f6c30876dfa 68 This parameter can be a value of @ref UART_WakeUp_from_Stop_Selection.
Kojto 107:4f6c30876dfa 69 If set to UART_WAKEUP_ON_ADDRESS, the two other fields below must
Kojto 107:4f6c30876dfa 70 be filled up. */
Kojto 107:4f6c30876dfa 71
Kojto 107:4f6c30876dfa 72 uint16_t AddressLength; /*!< Specifies whether the address is 4 or 7-bit long.
Kojto 107:4f6c30876dfa 73 This parameter can be a value of @ref UARTEx_WakeUp_Address_Length. */
Kojto 107:4f6c30876dfa 74
Kojto 107:4f6c30876dfa 75 uint8_t Address; /*!< UART/USART node address (7-bit long max). */
Kojto 107:4f6c30876dfa 76 } UART_WakeUpTypeDef;
Kojto 107:4f6c30876dfa 77
Kojto 107:4f6c30876dfa 78 /**
Kojto 107:4f6c30876dfa 79 * @}
Kojto 107:4f6c30876dfa 80 */
Kojto 107:4f6c30876dfa 81
Kojto 107:4f6c30876dfa 82 /* Exported constants --------------------------------------------------------*/
Kojto 107:4f6c30876dfa 83 /** @defgroup UARTEx_Exported_Constants UARTEx Exported Constants
Kojto 107:4f6c30876dfa 84 * @{
Kojto 107:4f6c30876dfa 85 */
Kojto 107:4f6c30876dfa 86
Kojto 107:4f6c30876dfa 87 /** @defgroup UARTEx_Word_Length UART Word Length
Kojto 107:4f6c30876dfa 88 * @{
Kojto 107:4f6c30876dfa 89 */
Kojto 107:4f6c30876dfa 90 #define UART_WORDLENGTH_7B ((uint32_t)USART_CR1_M1) /*!< 7-bit long UART frame */
Kojto 107:4f6c30876dfa 91 #define UART_WORDLENGTH_8B ((uint32_t)0x00000000) /*!< 8-bit long UART frame */
Kojto 107:4f6c30876dfa 92 #define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M0) /*!< 9-bit long UART frame */
Kojto 107:4f6c30876dfa 93 /**
Kojto 107:4f6c30876dfa 94 * @}
Kojto 107:4f6c30876dfa 95 */
Kojto 122:f9eeca106725 96
Kojto 107:4f6c30876dfa 97 /** @defgroup UARTEx_WakeUp_Address_Length UART Extended WakeUp Address Length
Kojto 107:4f6c30876dfa 98 * @{
Kojto 107:4f6c30876dfa 99 */
Kojto 107:4f6c30876dfa 100 #define UART_ADDRESS_DETECT_4B ((uint32_t)0x00000000) /*!< 4-bit long wake-up address */
Kojto 107:4f6c30876dfa 101 #define UART_ADDRESS_DETECT_7B ((uint32_t)USART_CR2_ADDM7) /*!< 7-bit long wake-up address */
Kojto 107:4f6c30876dfa 102 /**
Kojto 107:4f6c30876dfa 103 * @}
Kojto 107:4f6c30876dfa 104 */
Kojto 107:4f6c30876dfa 105
Kojto 107:4f6c30876dfa 106 /**
Kojto 107:4f6c30876dfa 107 * @}
Kojto 107:4f6c30876dfa 108 */
Kojto 107:4f6c30876dfa 109
Kojto 107:4f6c30876dfa 110 /* Exported macros -----------------------------------------------------------*/
Kojto 107:4f6c30876dfa 111 /* Exported functions --------------------------------------------------------*/
Kojto 107:4f6c30876dfa 112 /** @addtogroup UARTEx_Exported_Functions
Kojto 107:4f6c30876dfa 113 * @{
Kojto 107:4f6c30876dfa 114 */
Kojto 107:4f6c30876dfa 115
Kojto 107:4f6c30876dfa 116 /** @addtogroup UARTEx_Exported_Functions_Group1
Kojto 107:4f6c30876dfa 117 * @{
Kojto 107:4f6c30876dfa 118 */
Kojto 107:4f6c30876dfa 119
Kojto 107:4f6c30876dfa 120 /* Initialization and de-initialization functions ****************************/
Kojto 107:4f6c30876dfa 121 HAL_StatusTypeDef HAL_RS485Ex_Init(UART_HandleTypeDef *huart, uint32_t Polarity, uint32_t AssertionTime, uint32_t DeassertionTime);
Kojto 107:4f6c30876dfa 122
Kojto 107:4f6c30876dfa 123 /**
Kojto 107:4f6c30876dfa 124 * @}
Kojto 107:4f6c30876dfa 125 */
Kojto 107:4f6c30876dfa 126
Kojto 107:4f6c30876dfa 127 /* IO operation functions *****************************************************/
Kojto 107:4f6c30876dfa 128
Kojto 107:4f6c30876dfa 129 /** @addtogroup UARTEx_Exported_Functions_Group3
Kojto 107:4f6c30876dfa 130 * @{
Kojto 107:4f6c30876dfa 131 */
Kojto 107:4f6c30876dfa 132
Kojto 107:4f6c30876dfa 133 /* Peripheral Control functions **********************************************/
Kojto 107:4f6c30876dfa 134 HAL_StatusTypeDef HAL_UARTEx_StopModeWakeUpSourceConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection);
Kojto 107:4f6c30876dfa 135 HAL_StatusTypeDef HAL_UARTEx_EnableStopMode(UART_HandleTypeDef *huart);
Kojto 107:4f6c30876dfa 136 HAL_StatusTypeDef HAL_UARTEx_DisableStopMode(UART_HandleTypeDef *huart);
Kojto 107:4f6c30876dfa 137 HAL_StatusTypeDef HAL_MultiProcessorEx_AddressLength_Set(UART_HandleTypeDef *huart, uint32_t AddressLength);
Kojto 107:4f6c30876dfa 138 void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart);
Kojto 107:4f6c30876dfa 139
Kojto 107:4f6c30876dfa 140 /**
Kojto 107:4f6c30876dfa 141 * @}
Kojto 107:4f6c30876dfa 142 */
Kojto 107:4f6c30876dfa 143
Kojto 107:4f6c30876dfa 144 /**
Kojto 107:4f6c30876dfa 145 * @}
Kojto 107:4f6c30876dfa 146 */
Kojto 107:4f6c30876dfa 147
Kojto 107:4f6c30876dfa 148 /* Private macros ------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 149 /** @defgroup UARTEx_Private_Macros UARTEx Private Macros
Kojto 107:4f6c30876dfa 150 * @{
Kojto 107:4f6c30876dfa 151 */
Kojto 107:4f6c30876dfa 152
Kojto 107:4f6c30876dfa 153 /** @brief Report the UART clock source.
Kojto 107:4f6c30876dfa 154 * @param __HANDLE__: specifies the UART Handle.
Kojto 107:4f6c30876dfa 155 * @param __CLOCKSOURCE__: output variable.
Kojto 107:4f6c30876dfa 156 * @retval UART clocking source, written in __CLOCKSOURCE__.
Kojto 107:4f6c30876dfa 157 */
Kojto 122:f9eeca106725 158 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 107:4f6c30876dfa 159 #define UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 107:4f6c30876dfa 160 do { \
Kojto 107:4f6c30876dfa 161 if((__HANDLE__)->Instance == USART1) \
Kojto 107:4f6c30876dfa 162 { \
Kojto 107:4f6c30876dfa 163 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 107:4f6c30876dfa 164 { \
Kojto 107:4f6c30876dfa 165 case RCC_USART1CLKSOURCE_PCLK2: \
Kojto 107:4f6c30876dfa 166 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK2; \
Kojto 107:4f6c30876dfa 167 break; \
Kojto 107:4f6c30876dfa 168 case RCC_USART1CLKSOURCE_HSI: \
Kojto 107:4f6c30876dfa 169 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 107:4f6c30876dfa 170 break; \
Kojto 107:4f6c30876dfa 171 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 107:4f6c30876dfa 172 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 107:4f6c30876dfa 173 break; \
Kojto 107:4f6c30876dfa 174 case RCC_USART1CLKSOURCE_LSE: \
Kojto 107:4f6c30876dfa 175 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 107:4f6c30876dfa 176 break; \
Kojto 107:4f6c30876dfa 177 default: \
Kojto 107:4f6c30876dfa 178 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 107:4f6c30876dfa 179 break; \
Kojto 107:4f6c30876dfa 180 } \
Kojto 107:4f6c30876dfa 181 } \
Kojto 107:4f6c30876dfa 182 else if((__HANDLE__)->Instance == USART2) \
Kojto 107:4f6c30876dfa 183 { \
Kojto 107:4f6c30876dfa 184 switch(__HAL_RCC_GET_USART2_SOURCE()) \
Kojto 107:4f6c30876dfa 185 { \
Kojto 107:4f6c30876dfa 186 case RCC_USART2CLKSOURCE_PCLK1: \
Kojto 107:4f6c30876dfa 187 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 107:4f6c30876dfa 188 break; \
Kojto 107:4f6c30876dfa 189 case RCC_USART2CLKSOURCE_HSI: \
Kojto 107:4f6c30876dfa 190 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 107:4f6c30876dfa 191 break; \
Kojto 107:4f6c30876dfa 192 case RCC_USART2CLKSOURCE_SYSCLK: \
Kojto 107:4f6c30876dfa 193 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 107:4f6c30876dfa 194 break; \
Kojto 107:4f6c30876dfa 195 case RCC_USART2CLKSOURCE_LSE: \
Kojto 107:4f6c30876dfa 196 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 107:4f6c30876dfa 197 break; \
Kojto 107:4f6c30876dfa 198 default: \
Kojto 107:4f6c30876dfa 199 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 107:4f6c30876dfa 200 break; \
Kojto 107:4f6c30876dfa 201 } \
Kojto 107:4f6c30876dfa 202 } \
Kojto 107:4f6c30876dfa 203 else if((__HANDLE__)->Instance == USART3) \
Kojto 107:4f6c30876dfa 204 { \
Kojto 107:4f6c30876dfa 205 switch(__HAL_RCC_GET_USART3_SOURCE()) \
Kojto 107:4f6c30876dfa 206 { \
Kojto 107:4f6c30876dfa 207 case RCC_USART3CLKSOURCE_PCLK1: \
Kojto 107:4f6c30876dfa 208 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 107:4f6c30876dfa 209 break; \
Kojto 107:4f6c30876dfa 210 case RCC_USART3CLKSOURCE_HSI: \
Kojto 107:4f6c30876dfa 211 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 107:4f6c30876dfa 212 break; \
Kojto 107:4f6c30876dfa 213 case RCC_USART3CLKSOURCE_SYSCLK: \
Kojto 107:4f6c30876dfa 214 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 107:4f6c30876dfa 215 break; \
Kojto 107:4f6c30876dfa 216 case RCC_USART3CLKSOURCE_LSE: \
Kojto 107:4f6c30876dfa 217 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 107:4f6c30876dfa 218 break; \
Kojto 107:4f6c30876dfa 219 default: \
Kojto 107:4f6c30876dfa 220 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 107:4f6c30876dfa 221 break; \
Kojto 107:4f6c30876dfa 222 } \
Kojto 107:4f6c30876dfa 223 } \
Kojto 107:4f6c30876dfa 224 else if((__HANDLE__)->Instance == UART4) \
Kojto 107:4f6c30876dfa 225 { \
Kojto 107:4f6c30876dfa 226 switch(__HAL_RCC_GET_UART4_SOURCE()) \
Kojto 107:4f6c30876dfa 227 { \
Kojto 107:4f6c30876dfa 228 case RCC_UART4CLKSOURCE_PCLK1: \
Kojto 107:4f6c30876dfa 229 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 107:4f6c30876dfa 230 break; \
Kojto 107:4f6c30876dfa 231 case RCC_UART4CLKSOURCE_HSI: \
Kojto 107:4f6c30876dfa 232 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 107:4f6c30876dfa 233 break; \
Kojto 107:4f6c30876dfa 234 case RCC_UART4CLKSOURCE_SYSCLK: \
Kojto 107:4f6c30876dfa 235 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 107:4f6c30876dfa 236 break; \
Kojto 107:4f6c30876dfa 237 case RCC_UART4CLKSOURCE_LSE: \
Kojto 107:4f6c30876dfa 238 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 107:4f6c30876dfa 239 break; \
Kojto 107:4f6c30876dfa 240 default: \
Kojto 107:4f6c30876dfa 241 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 107:4f6c30876dfa 242 break; \
Kojto 107:4f6c30876dfa 243 } \
Kojto 107:4f6c30876dfa 244 } \
Kojto 107:4f6c30876dfa 245 else if ((__HANDLE__)->Instance == UART5) \
Kojto 107:4f6c30876dfa 246 { \
Kojto 107:4f6c30876dfa 247 switch(__HAL_RCC_GET_UART5_SOURCE()) \
Kojto 107:4f6c30876dfa 248 { \
Kojto 107:4f6c30876dfa 249 case RCC_UART5CLKSOURCE_PCLK1: \
Kojto 107:4f6c30876dfa 250 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 107:4f6c30876dfa 251 break; \
Kojto 107:4f6c30876dfa 252 case RCC_UART5CLKSOURCE_HSI: \
Kojto 107:4f6c30876dfa 253 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 107:4f6c30876dfa 254 break; \
Kojto 107:4f6c30876dfa 255 case RCC_UART5CLKSOURCE_SYSCLK: \
Kojto 107:4f6c30876dfa 256 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 107:4f6c30876dfa 257 break; \
Kojto 107:4f6c30876dfa 258 case RCC_UART5CLKSOURCE_LSE: \
Kojto 107:4f6c30876dfa 259 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 107:4f6c30876dfa 260 break; \
Kojto 107:4f6c30876dfa 261 default: \
Kojto 107:4f6c30876dfa 262 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 107:4f6c30876dfa 263 break; \
Kojto 107:4f6c30876dfa 264 } \
Kojto 107:4f6c30876dfa 265 } \
Kojto 107:4f6c30876dfa 266 else if((__HANDLE__)->Instance == LPUART1) \
Kojto 107:4f6c30876dfa 267 { \
Kojto 107:4f6c30876dfa 268 switch(__HAL_RCC_GET_LPUART1_SOURCE()) \
Kojto 107:4f6c30876dfa 269 { \
Kojto 107:4f6c30876dfa 270 case RCC_LPUART1CLKSOURCE_PCLK1: \
Kojto 107:4f6c30876dfa 271 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 107:4f6c30876dfa 272 break; \
Kojto 107:4f6c30876dfa 273 case RCC_LPUART1CLKSOURCE_HSI: \
Kojto 107:4f6c30876dfa 274 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 107:4f6c30876dfa 275 break; \
Kojto 107:4f6c30876dfa 276 case RCC_LPUART1CLKSOURCE_SYSCLK: \
Kojto 107:4f6c30876dfa 277 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 107:4f6c30876dfa 278 break; \
Kojto 107:4f6c30876dfa 279 case RCC_LPUART1CLKSOURCE_LSE: \
Kojto 107:4f6c30876dfa 280 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 107:4f6c30876dfa 281 break; \
Kojto 107:4f6c30876dfa 282 default: \
Kojto 107:4f6c30876dfa 283 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 107:4f6c30876dfa 284 break; \
Kojto 107:4f6c30876dfa 285 } \
Kojto 107:4f6c30876dfa 286 } \
Kojto 107:4f6c30876dfa 287 } while(0)
Kojto 122:f9eeca106725 288 #elif defined (STM32L431xx) || defined (STM32L433xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 289 #define UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 122:f9eeca106725 290 do { \
Kojto 122:f9eeca106725 291 if((__HANDLE__)->Instance == USART1) \
Kojto 122:f9eeca106725 292 { \
Kojto 122:f9eeca106725 293 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 122:f9eeca106725 294 { \
Kojto 122:f9eeca106725 295 case RCC_USART1CLKSOURCE_PCLK2: \
Kojto 122:f9eeca106725 296 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK2; \
Kojto 122:f9eeca106725 297 break; \
Kojto 122:f9eeca106725 298 case RCC_USART1CLKSOURCE_HSI: \
Kojto 122:f9eeca106725 299 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 122:f9eeca106725 300 break; \
Kojto 122:f9eeca106725 301 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 122:f9eeca106725 302 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 122:f9eeca106725 303 break; \
Kojto 122:f9eeca106725 304 case RCC_USART1CLKSOURCE_LSE: \
Kojto 122:f9eeca106725 305 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 122:f9eeca106725 306 break; \
Kojto 122:f9eeca106725 307 default: \
Kojto 122:f9eeca106725 308 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 309 break; \
Kojto 122:f9eeca106725 310 } \
Kojto 122:f9eeca106725 311 } \
Kojto 122:f9eeca106725 312 else if((__HANDLE__)->Instance == USART2) \
Kojto 122:f9eeca106725 313 { \
Kojto 122:f9eeca106725 314 switch(__HAL_RCC_GET_USART2_SOURCE()) \
Kojto 122:f9eeca106725 315 { \
Kojto 122:f9eeca106725 316 case RCC_USART2CLKSOURCE_PCLK1: \
Kojto 122:f9eeca106725 317 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 122:f9eeca106725 318 break; \
Kojto 122:f9eeca106725 319 case RCC_USART2CLKSOURCE_HSI: \
Kojto 122:f9eeca106725 320 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 122:f9eeca106725 321 break; \
Kojto 122:f9eeca106725 322 case RCC_USART2CLKSOURCE_SYSCLK: \
Kojto 122:f9eeca106725 323 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 122:f9eeca106725 324 break; \
Kojto 122:f9eeca106725 325 case RCC_USART2CLKSOURCE_LSE: \
Kojto 122:f9eeca106725 326 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 122:f9eeca106725 327 break; \
Kojto 122:f9eeca106725 328 default: \
Kojto 122:f9eeca106725 329 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 330 break; \
Kojto 122:f9eeca106725 331 } \
Kojto 122:f9eeca106725 332 } \
Kojto 122:f9eeca106725 333 else if((__HANDLE__)->Instance == USART3) \
Kojto 122:f9eeca106725 334 { \
Kojto 122:f9eeca106725 335 switch(__HAL_RCC_GET_USART3_SOURCE()) \
Kojto 122:f9eeca106725 336 { \
Kojto 122:f9eeca106725 337 case RCC_USART3CLKSOURCE_PCLK1: \
Kojto 122:f9eeca106725 338 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 122:f9eeca106725 339 break; \
Kojto 122:f9eeca106725 340 case RCC_USART3CLKSOURCE_HSI: \
Kojto 122:f9eeca106725 341 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 122:f9eeca106725 342 break; \
Kojto 122:f9eeca106725 343 case RCC_USART3CLKSOURCE_SYSCLK: \
Kojto 122:f9eeca106725 344 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 122:f9eeca106725 345 break; \
Kojto 122:f9eeca106725 346 case RCC_USART3CLKSOURCE_LSE: \
Kojto 122:f9eeca106725 347 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 122:f9eeca106725 348 break; \
Kojto 122:f9eeca106725 349 default: \
Kojto 122:f9eeca106725 350 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 351 break; \
Kojto 122:f9eeca106725 352 } \
Kojto 122:f9eeca106725 353 } \
Kojto 122:f9eeca106725 354 else if((__HANDLE__)->Instance == LPUART1) \
Kojto 122:f9eeca106725 355 { \
Kojto 122:f9eeca106725 356 switch(__HAL_RCC_GET_LPUART1_SOURCE()) \
Kojto 122:f9eeca106725 357 { \
Kojto 122:f9eeca106725 358 case RCC_LPUART1CLKSOURCE_PCLK1: \
Kojto 122:f9eeca106725 359 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 122:f9eeca106725 360 break; \
Kojto 122:f9eeca106725 361 case RCC_LPUART1CLKSOURCE_HSI: \
Kojto 122:f9eeca106725 362 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 122:f9eeca106725 363 break; \
Kojto 122:f9eeca106725 364 case RCC_LPUART1CLKSOURCE_SYSCLK: \
Kojto 122:f9eeca106725 365 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 122:f9eeca106725 366 break; \
Kojto 122:f9eeca106725 367 case RCC_LPUART1CLKSOURCE_LSE: \
Kojto 122:f9eeca106725 368 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 122:f9eeca106725 369 break; \
Kojto 122:f9eeca106725 370 default: \
Kojto 122:f9eeca106725 371 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 372 break; \
Kojto 122:f9eeca106725 373 } \
Kojto 122:f9eeca106725 374 } \
Kojto 122:f9eeca106725 375 } while(0)
Kojto 122:f9eeca106725 376 #elif defined (STM32L432xx) || defined (STM32L442xx)
Kojto 122:f9eeca106725 377 #define UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 122:f9eeca106725 378 do { \
Kojto 122:f9eeca106725 379 if((__HANDLE__)->Instance == USART1) \
Kojto 122:f9eeca106725 380 { \
Kojto 122:f9eeca106725 381 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 122:f9eeca106725 382 { \
Kojto 122:f9eeca106725 383 case RCC_USART1CLKSOURCE_PCLK2: \
Kojto 122:f9eeca106725 384 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK2; \
Kojto 122:f9eeca106725 385 break; \
Kojto 122:f9eeca106725 386 case RCC_USART1CLKSOURCE_HSI: \
Kojto 122:f9eeca106725 387 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 122:f9eeca106725 388 break; \
Kojto 122:f9eeca106725 389 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 122:f9eeca106725 390 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 122:f9eeca106725 391 break; \
Kojto 122:f9eeca106725 392 case RCC_USART1CLKSOURCE_LSE: \
Kojto 122:f9eeca106725 393 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 122:f9eeca106725 394 break; \
Kojto 122:f9eeca106725 395 default: \
Kojto 122:f9eeca106725 396 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 397 break; \
Kojto 122:f9eeca106725 398 } \
Kojto 122:f9eeca106725 399 } \
Kojto 122:f9eeca106725 400 else if((__HANDLE__)->Instance == USART2) \
Kojto 122:f9eeca106725 401 { \
Kojto 122:f9eeca106725 402 switch(__HAL_RCC_GET_USART2_SOURCE()) \
Kojto 122:f9eeca106725 403 { \
Kojto 122:f9eeca106725 404 case RCC_USART2CLKSOURCE_PCLK1: \
Kojto 122:f9eeca106725 405 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 122:f9eeca106725 406 break; \
Kojto 122:f9eeca106725 407 case RCC_USART2CLKSOURCE_HSI: \
Kojto 122:f9eeca106725 408 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 122:f9eeca106725 409 break; \
Kojto 122:f9eeca106725 410 case RCC_USART2CLKSOURCE_SYSCLK: \
Kojto 122:f9eeca106725 411 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 122:f9eeca106725 412 break; \
Kojto 122:f9eeca106725 413 case RCC_USART2CLKSOURCE_LSE: \
Kojto 122:f9eeca106725 414 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 122:f9eeca106725 415 break; \
Kojto 122:f9eeca106725 416 default: \
Kojto 122:f9eeca106725 417 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 418 break; \
Kojto 122:f9eeca106725 419 } \
Kojto 122:f9eeca106725 420 } \
Kojto 122:f9eeca106725 421 else if((__HANDLE__)->Instance == LPUART1) \
Kojto 122:f9eeca106725 422 { \
Kojto 122:f9eeca106725 423 switch(__HAL_RCC_GET_LPUART1_SOURCE()) \
Kojto 122:f9eeca106725 424 { \
Kojto 122:f9eeca106725 425 case RCC_LPUART1CLKSOURCE_PCLK1: \
Kojto 122:f9eeca106725 426 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 122:f9eeca106725 427 break; \
Kojto 122:f9eeca106725 428 case RCC_LPUART1CLKSOURCE_HSI: \
Kojto 122:f9eeca106725 429 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 122:f9eeca106725 430 break; \
Kojto 122:f9eeca106725 431 case RCC_LPUART1CLKSOURCE_SYSCLK: \
Kojto 122:f9eeca106725 432 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 122:f9eeca106725 433 break; \
Kojto 122:f9eeca106725 434 case RCC_LPUART1CLKSOURCE_LSE: \
Kojto 122:f9eeca106725 435 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 122:f9eeca106725 436 break; \
Kojto 122:f9eeca106725 437 default: \
Kojto 122:f9eeca106725 438 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 439 break; \
Kojto 122:f9eeca106725 440 } \
Kojto 122:f9eeca106725 441 } \
Kojto 122:f9eeca106725 442 } while(0)
Kojto 122:f9eeca106725 443 #endif
Kojto 107:4f6c30876dfa 444
Kojto 107:4f6c30876dfa 445 /** @brief Report the UART mask to apply to retrieve the received data
Kojto 107:4f6c30876dfa 446 * according to the word length and to the parity bits activation.
Kojto 107:4f6c30876dfa 447 * @note If PCE = 1, the parity bit is not included in the data extracted
Kojto 107:4f6c30876dfa 448 * by the reception API().
Kojto 107:4f6c30876dfa 449 * This masking operation is not carried out in the case of
Kojto 107:4f6c30876dfa 450 * DMA transfers.
Kojto 107:4f6c30876dfa 451 * @param __HANDLE__: specifies the UART Handle.
Kojto 107:4f6c30876dfa 452 * @retval None, the mask to apply to UART RDR register is stored in (__HANDLE__)->Mask field.
Kojto 107:4f6c30876dfa 453 */
Kojto 107:4f6c30876dfa 454 #define UART_MASK_COMPUTATION(__HANDLE__) \
Kojto 107:4f6c30876dfa 455 do { \
Kojto 107:4f6c30876dfa 456 if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_9B) \
Kojto 107:4f6c30876dfa 457 { \
Kojto 107:4f6c30876dfa 458 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
Kojto 107:4f6c30876dfa 459 { \
Kojto 107:4f6c30876dfa 460 (__HANDLE__)->Mask = 0x01FF ; \
Kojto 107:4f6c30876dfa 461 } \
Kojto 107:4f6c30876dfa 462 else \
Kojto 107:4f6c30876dfa 463 { \
Kojto 107:4f6c30876dfa 464 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 107:4f6c30876dfa 465 } \
Kojto 107:4f6c30876dfa 466 } \
Kojto 107:4f6c30876dfa 467 else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_8B) \
Kojto 107:4f6c30876dfa 468 { \
Kojto 107:4f6c30876dfa 469 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
Kojto 107:4f6c30876dfa 470 { \
Kojto 107:4f6c30876dfa 471 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 107:4f6c30876dfa 472 } \
Kojto 107:4f6c30876dfa 473 else \
Kojto 107:4f6c30876dfa 474 { \
Kojto 107:4f6c30876dfa 475 (__HANDLE__)->Mask = 0x007F ; \
Kojto 107:4f6c30876dfa 476 } \
Kojto 107:4f6c30876dfa 477 } \
Kojto 107:4f6c30876dfa 478 else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_7B) \
Kojto 107:4f6c30876dfa 479 { \
Kojto 107:4f6c30876dfa 480 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
Kojto 107:4f6c30876dfa 481 { \
Kojto 107:4f6c30876dfa 482 (__HANDLE__)->Mask = 0x007F ; \
Kojto 107:4f6c30876dfa 483 } \
Kojto 107:4f6c30876dfa 484 else \
Kojto 107:4f6c30876dfa 485 { \
Kojto 107:4f6c30876dfa 486 (__HANDLE__)->Mask = 0x003F ; \
Kojto 107:4f6c30876dfa 487 } \
Kojto 107:4f6c30876dfa 488 } \
Kojto 107:4f6c30876dfa 489 } while(0)
Kojto 107:4f6c30876dfa 490
Kojto 107:4f6c30876dfa 491
Kojto 107:4f6c30876dfa 492 /**
Kojto 107:4f6c30876dfa 493 * @brief Ensure that UART frame length is valid.
Kojto 107:4f6c30876dfa 494 * @param __LENGTH__: UART frame length.
Kojto 107:4f6c30876dfa 495 * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid)
Kojto 107:4f6c30876dfa 496 */
Kojto 107:4f6c30876dfa 497 #define IS_UART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == UART_WORDLENGTH_7B) || \
Kojto 107:4f6c30876dfa 498 ((__LENGTH__) == UART_WORDLENGTH_8B) || \
Kojto 107:4f6c30876dfa 499 ((__LENGTH__) == UART_WORDLENGTH_9B))
Kojto 107:4f6c30876dfa 500
Kojto 107:4f6c30876dfa 501 /**
Kojto 107:4f6c30876dfa 502 * @brief Ensure that UART wake-up address length is valid.
Kojto 107:4f6c30876dfa 503 * @param __ADDRESS__: UART wake-up address length.
Kojto 107:4f6c30876dfa 504 * @retval SET (__ADDRESS__ is valid) or RESET (__ADDRESS__ is invalid)
Kojto 107:4f6c30876dfa 505 */
Kojto 107:4f6c30876dfa 506 #define IS_UART_ADDRESSLENGTH_DETECT(__ADDRESS__) (((__ADDRESS__) == UART_ADDRESS_DETECT_4B) || \
Kojto 107:4f6c30876dfa 507 ((__ADDRESS__) == UART_ADDRESS_DETECT_7B))
Kojto 107:4f6c30876dfa 508
Kojto 107:4f6c30876dfa 509 /**
Kojto 107:4f6c30876dfa 510 * @}
Kojto 107:4f6c30876dfa 511 */
Kojto 107:4f6c30876dfa 512
Kojto 107:4f6c30876dfa 513 /* Private functions ---------------------------------------------------------*/
Kojto 107:4f6c30876dfa 514
Kojto 107:4f6c30876dfa 515 /**
Kojto 107:4f6c30876dfa 516 * @}
Kojto 107:4f6c30876dfa 517 */
Kojto 107:4f6c30876dfa 518
Kojto 107:4f6c30876dfa 519 /**
Kojto 107:4f6c30876dfa 520 * @}
Kojto 107:4f6c30876dfa 521 */
Kojto 107:4f6c30876dfa 522
Kojto 107:4f6c30876dfa 523 #ifdef __cplusplus
Kojto 107:4f6c30876dfa 524 }
Kojto 107:4f6c30876dfa 525 #endif
Kojto 107:4f6c30876dfa 526
Kojto 107:4f6c30876dfa 527 #endif /* __STM32L4xx_HAL_UART_EX_H */
Kojto 107:4f6c30876dfa 528
Kojto 107:4f6c30876dfa 529 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/