my fork

Dependents:   Nucleo_blueNRG

Fork of mbed by mbed official

Committer:
filartrix
Date:
Wed Apr 08 14:12:53 2015 +0000
Revision:
97:4298809c7c9e
Parent:
90:cb3d968589d8
First reale BlueNRG module for nucleo 401 board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 90:cb3d968589d8 1 /**
Kojto 90:cb3d968589d8 2 ******************************************************************************
Kojto 90:cb3d968589d8 3 * @file stm32f3xx_hal_uart_ex.h
Kojto 90:cb3d968589d8 4 * @author MCD Application Team
Kojto 90:cb3d968589d8 5 * @version V1.1.0
Kojto 90:cb3d968589d8 6 * @date 12-Sept-2014
Kojto 90:cb3d968589d8 7 * @brief Header file of UART HAL Extended module.
Kojto 90:cb3d968589d8 8 ******************************************************************************
Kojto 90:cb3d968589d8 9 * @attention
Kojto 90:cb3d968589d8 10 *
Kojto 90:cb3d968589d8 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
Kojto 90:cb3d968589d8 12 *
Kojto 90:cb3d968589d8 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 90:cb3d968589d8 14 * are permitted provided that the following conditions are met:
Kojto 90:cb3d968589d8 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 90:cb3d968589d8 16 * this list of conditions and the following disclaimer.
Kojto 90:cb3d968589d8 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 90:cb3d968589d8 18 * this list of conditions and the following disclaimer in the documentation
Kojto 90:cb3d968589d8 19 * and/or other materials provided with the distribution.
Kojto 90:cb3d968589d8 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 90:cb3d968589d8 21 * may be used to endorse or promote products derived from this software
Kojto 90:cb3d968589d8 22 * without specific prior written permission.
Kojto 90:cb3d968589d8 23 *
Kojto 90:cb3d968589d8 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 90:cb3d968589d8 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 90:cb3d968589d8 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 90:cb3d968589d8 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 90:cb3d968589d8 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 90:cb3d968589d8 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 90:cb3d968589d8 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 90:cb3d968589d8 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 90:cb3d968589d8 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 90:cb3d968589d8 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 90:cb3d968589d8 34 *
Kojto 90:cb3d968589d8 35 ******************************************************************************
Kojto 90:cb3d968589d8 36 */
Kojto 90:cb3d968589d8 37
Kojto 90:cb3d968589d8 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 90:cb3d968589d8 39 #ifndef __STM32F3xx_HAL_UART_EX_H
Kojto 90:cb3d968589d8 40 #define __STM32F3xx_HAL_UART_EX_H
Kojto 90:cb3d968589d8 41
Kojto 90:cb3d968589d8 42 #ifdef __cplusplus
Kojto 90:cb3d968589d8 43 extern "C" {
Kojto 90:cb3d968589d8 44 #endif
Kojto 90:cb3d968589d8 45
Kojto 90:cb3d968589d8 46 /* Includes ------------------------------------------------------------------*/
Kojto 90:cb3d968589d8 47 #include "stm32f3xx_hal_def.h"
Kojto 90:cb3d968589d8 48
Kojto 90:cb3d968589d8 49 /** @addtogroup STM32F3xx_HAL_Driver
Kojto 90:cb3d968589d8 50 * @{
Kojto 90:cb3d968589d8 51 */
Kojto 90:cb3d968589d8 52
Kojto 90:cb3d968589d8 53 /** @addtogroup UARTEx
Kojto 90:cb3d968589d8 54 * @{
Kojto 90:cb3d968589d8 55 */
Kojto 90:cb3d968589d8 56
Kojto 90:cb3d968589d8 57 /* Exported types ------------------------------------------------------------*/
Kojto 90:cb3d968589d8 58 /* Exported constants --------------------------------------------------------*/
Kojto 90:cb3d968589d8 59 /** @defgroup UARTEx_Exported_Constants UART Extented Exported Constants
Kojto 90:cb3d968589d8 60 * @{
Kojto 90:cb3d968589d8 61 */
Kojto 90:cb3d968589d8 62
Kojto 90:cb3d968589d8 63 /** @defgroup UARTEx_Word_Length UART Extended Word Length
Kojto 90:cb3d968589d8 64 * @{
Kojto 90:cb3d968589d8 65 */
Kojto 90:cb3d968589d8 66 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
Kojto 90:cb3d968589d8 67 defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
Kojto 90:cb3d968589d8 68 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
Kojto 90:cb3d968589d8 69 #define UART_WORDLENGTH_7B ((uint32_t)USART_CR1_M1)
Kojto 90:cb3d968589d8 70 #define UART_WORDLENGTH_8B ((uint32_t)0x00000000)
Kojto 90:cb3d968589d8 71 #define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M0)
Kojto 90:cb3d968589d8 72 #define IS_UART_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_7B) || \
Kojto 90:cb3d968589d8 73 ((LENGTH) == UART_WORDLENGTH_8B) || \
Kojto 90:cb3d968589d8 74 ((LENGTH) == UART_WORDLENGTH_9B))
Kojto 90:cb3d968589d8 75 #else
Kojto 90:cb3d968589d8 76 #define UART_WORDLENGTH_8B ((uint32_t)0x00000000)
Kojto 90:cb3d968589d8 77 #define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
Kojto 90:cb3d968589d8 78 #define IS_UART_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B) || \
Kojto 90:cb3d968589d8 79 ((LENGTH) == UART_WORDLENGTH_9B))
Kojto 90:cb3d968589d8 80 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
Kojto 90:cb3d968589d8 81 /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
Kojto 90:cb3d968589d8 82 /* STM32F301x8 || STM32F302x8 || STM32F318xx */
Kojto 90:cb3d968589d8 83 /**
Kojto 90:cb3d968589d8 84 * @}
Kojto 90:cb3d968589d8 85 */
Kojto 90:cb3d968589d8 86
Kojto 90:cb3d968589d8 87
Kojto 90:cb3d968589d8 88 /** @defgroup UART_WakeUp_Address_Length UART WakeUp Address Length
Kojto 90:cb3d968589d8 89 * @{
Kojto 90:cb3d968589d8 90 */
Kojto 90:cb3d968589d8 91 #define UART_ADDRESS_DETECT_4B ((uint32_t)0x00000000)
Kojto 90:cb3d968589d8 92 #define UART_ADDRESS_DETECT_7B ((uint32_t)USART_CR2_ADDM7)
Kojto 90:cb3d968589d8 93 #define IS_UART_ADDRESSLENGTH_DETECT(ADDRESS) (((ADDRESS) == UART_ADDRESS_DETECT_4B) || \
Kojto 90:cb3d968589d8 94 ((ADDRESS) == UART_ADDRESS_DETECT_7B))
Kojto 90:cb3d968589d8 95 /**
Kojto 90:cb3d968589d8 96 * @}
Kojto 90:cb3d968589d8 97 */
Kojto 90:cb3d968589d8 98
Kojto 90:cb3d968589d8 99
Kojto 90:cb3d968589d8 100 /**
Kojto 90:cb3d968589d8 101 * @}
Kojto 90:cb3d968589d8 102 */
Kojto 90:cb3d968589d8 103
Kojto 90:cb3d968589d8 104 /* Exported macro ------------------------------------------------------------*/
Kojto 90:cb3d968589d8 105
Kojto 90:cb3d968589d8 106 /** @defgroup UARTEx_Exported_Macros UART Extended Exported Macros
Kojto 90:cb3d968589d8 107 * @{
Kojto 90:cb3d968589d8 108 */
Kojto 90:cb3d968589d8 109
Kojto 90:cb3d968589d8 110 /** @brief Reports the UART clock source.
Kojto 90:cb3d968589d8 111 * @param __HANDLE__: specifies the UART Handle
Kojto 90:cb3d968589d8 112 * @param __CLOCKSOURCE__ : output variable
Kojto 90:cb3d968589d8 113 * @retval UART clocking source, written in __CLOCKSOURCE__.
Kojto 90:cb3d968589d8 114 */
Kojto 90:cb3d968589d8 115 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
Kojto 90:cb3d968589d8 116 defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx)
Kojto 90:cb3d968589d8 117 #define __HAL_UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 90:cb3d968589d8 118 do { \
Kojto 90:cb3d968589d8 119 if((__HANDLE__)->Instance == USART1) \
Kojto 90:cb3d968589d8 120 { \
Kojto 90:cb3d968589d8 121 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 90:cb3d968589d8 122 { \
Kojto 90:cb3d968589d8 123 case RCC_USART1CLKSOURCE_PCLK2: \
Kojto 90:cb3d968589d8 124 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK2; \
Kojto 90:cb3d968589d8 125 break; \
Kojto 90:cb3d968589d8 126 case RCC_USART1CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 127 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 128 break; \
Kojto 90:cb3d968589d8 129 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 130 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 131 break; \
Kojto 90:cb3d968589d8 132 case RCC_USART1CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 133 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 134 break; \
Kojto 90:cb3d968589d8 135 } \
Kojto 90:cb3d968589d8 136 } \
Kojto 90:cb3d968589d8 137 else if((__HANDLE__)->Instance == USART2) \
Kojto 90:cb3d968589d8 138 { \
Kojto 90:cb3d968589d8 139 switch(__HAL_RCC_GET_USART2_SOURCE()) \
Kojto 90:cb3d968589d8 140 { \
Kojto 90:cb3d968589d8 141 case RCC_USART2CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 142 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 143 break; \
Kojto 90:cb3d968589d8 144 case RCC_USART2CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 145 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 146 break; \
Kojto 90:cb3d968589d8 147 case RCC_USART2CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 148 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 149 break; \
Kojto 90:cb3d968589d8 150 case RCC_USART2CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 151 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 152 break; \
Kojto 90:cb3d968589d8 153 } \
Kojto 90:cb3d968589d8 154 } \
Kojto 90:cb3d968589d8 155 else if((__HANDLE__)->Instance == USART3) \
Kojto 90:cb3d968589d8 156 { \
Kojto 90:cb3d968589d8 157 switch(__HAL_RCC_GET_USART3_SOURCE()) \
Kojto 90:cb3d968589d8 158 { \
Kojto 90:cb3d968589d8 159 case RCC_USART3CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 160 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 161 break; \
Kojto 90:cb3d968589d8 162 case RCC_USART3CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 163 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 164 break; \
Kojto 90:cb3d968589d8 165 case RCC_USART3CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 166 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 167 break; \
Kojto 90:cb3d968589d8 168 case RCC_USART3CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 169 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 170 break; \
Kojto 90:cb3d968589d8 171 } \
Kojto 90:cb3d968589d8 172 } \
Kojto 90:cb3d968589d8 173 else if((__HANDLE__)->Instance == UART4) \
Kojto 90:cb3d968589d8 174 { \
Kojto 90:cb3d968589d8 175 switch(__HAL_RCC_GET_UART4_SOURCE()) \
Kojto 90:cb3d968589d8 176 { \
Kojto 90:cb3d968589d8 177 case RCC_UART4CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 178 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 179 break; \
Kojto 90:cb3d968589d8 180 case RCC_UART4CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 181 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 182 break; \
Kojto 90:cb3d968589d8 183 case RCC_UART4CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 184 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 185 break; \
Kojto 90:cb3d968589d8 186 case RCC_UART4CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 187 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 188 break; \
Kojto 90:cb3d968589d8 189 } \
Kojto 90:cb3d968589d8 190 } \
Kojto 90:cb3d968589d8 191 else if ((__HANDLE__)->Instance == UART5) \
Kojto 90:cb3d968589d8 192 { \
Kojto 90:cb3d968589d8 193 switch(__HAL_RCC_GET_UART5_SOURCE()) \
Kojto 90:cb3d968589d8 194 { \
Kojto 90:cb3d968589d8 195 case RCC_UART5CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 196 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 197 break; \
Kojto 90:cb3d968589d8 198 case RCC_UART5CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 199 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 200 break; \
Kojto 90:cb3d968589d8 201 case RCC_UART5CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 202 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 203 break; \
Kojto 90:cb3d968589d8 204 case RCC_UART5CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 205 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 206 break; \
Kojto 90:cb3d968589d8 207 } \
Kojto 90:cb3d968589d8 208 } \
Kojto 90:cb3d968589d8 209 } while(0)
Kojto 90:cb3d968589d8 210 #elif defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
Kojto 90:cb3d968589d8 211 #define __HAL_UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 90:cb3d968589d8 212 do { \
Kojto 90:cb3d968589d8 213 if((__HANDLE__)->Instance == USART1) \
Kojto 90:cb3d968589d8 214 { \
Kojto 90:cb3d968589d8 215 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 90:cb3d968589d8 216 { \
Kojto 90:cb3d968589d8 217 case RCC_USART1CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 218 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 219 break; \
Kojto 90:cb3d968589d8 220 case RCC_USART1CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 221 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 222 break; \
Kojto 90:cb3d968589d8 223 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 224 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 225 break; \
Kojto 90:cb3d968589d8 226 case RCC_USART1CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 227 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 228 break; \
Kojto 90:cb3d968589d8 229 } \
Kojto 90:cb3d968589d8 230 } \
Kojto 90:cb3d968589d8 231 else if((__HANDLE__)->Instance == USART2) \
Kojto 90:cb3d968589d8 232 { \
Kojto 90:cb3d968589d8 233 switch(__HAL_RCC_GET_USART2_SOURCE()) \
Kojto 90:cb3d968589d8 234 { \
Kojto 90:cb3d968589d8 235 case RCC_USART2CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 236 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 237 break; \
Kojto 90:cb3d968589d8 238 case RCC_USART2CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 239 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 240 break; \
Kojto 90:cb3d968589d8 241 case RCC_USART2CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 242 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 243 break; \
Kojto 90:cb3d968589d8 244 case RCC_USART2CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 245 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 246 break; \
Kojto 90:cb3d968589d8 247 } \
Kojto 90:cb3d968589d8 248 } \
Kojto 90:cb3d968589d8 249 else if((__HANDLE__)->Instance == USART3) \
Kojto 90:cb3d968589d8 250 { \
Kojto 90:cb3d968589d8 251 switch(__HAL_RCC_GET_USART3_SOURCE()) \
Kojto 90:cb3d968589d8 252 { \
Kojto 90:cb3d968589d8 253 case RCC_USART3CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 254 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 255 break; \
Kojto 90:cb3d968589d8 256 case RCC_USART3CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 257 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 258 break; \
Kojto 90:cb3d968589d8 259 case RCC_USART3CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 260 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 261 break; \
Kojto 90:cb3d968589d8 262 case RCC_USART3CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 263 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 264 break; \
Kojto 90:cb3d968589d8 265 } \
Kojto 90:cb3d968589d8 266 } \
Kojto 90:cb3d968589d8 267 } while(0)
Kojto 90:cb3d968589d8 268 #else
Kojto 90:cb3d968589d8 269 #define __HAL_UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 90:cb3d968589d8 270 do { \
Kojto 90:cb3d968589d8 271 if((__HANDLE__)->Instance == USART1) \
Kojto 90:cb3d968589d8 272 { \
Kojto 90:cb3d968589d8 273 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 90:cb3d968589d8 274 { \
Kojto 90:cb3d968589d8 275 case RCC_USART1CLKSOURCE_PCLK2: \
Kojto 90:cb3d968589d8 276 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK2; \
Kojto 90:cb3d968589d8 277 break; \
Kojto 90:cb3d968589d8 278 case RCC_USART1CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 279 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 280 break; \
Kojto 90:cb3d968589d8 281 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 282 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 283 break; \
Kojto 90:cb3d968589d8 284 case RCC_USART1CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 285 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 286 break; \
Kojto 90:cb3d968589d8 287 } \
Kojto 90:cb3d968589d8 288 } \
Kojto 90:cb3d968589d8 289 else if((__HANDLE__)->Instance == USART2) \
Kojto 90:cb3d968589d8 290 { \
Kojto 90:cb3d968589d8 291 switch(__HAL_RCC_GET_USART2_SOURCE()) \
Kojto 90:cb3d968589d8 292 { \
Kojto 90:cb3d968589d8 293 case RCC_USART2CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 294 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 295 break; \
Kojto 90:cb3d968589d8 296 case RCC_USART2CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 297 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 298 break; \
Kojto 90:cb3d968589d8 299 case RCC_USART2CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 300 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 301 break; \
Kojto 90:cb3d968589d8 302 case RCC_USART2CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 303 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 304 break; \
Kojto 90:cb3d968589d8 305 } \
Kojto 90:cb3d968589d8 306 } \
Kojto 90:cb3d968589d8 307 else if((__HANDLE__)->Instance == USART3) \
Kojto 90:cb3d968589d8 308 { \
Kojto 90:cb3d968589d8 309 switch(__HAL_RCC_GET_USART3_SOURCE()) \
Kojto 90:cb3d968589d8 310 { \
Kojto 90:cb3d968589d8 311 case RCC_USART3CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 312 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 313 break; \
Kojto 90:cb3d968589d8 314 case RCC_USART3CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 315 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 316 break; \
Kojto 90:cb3d968589d8 317 case RCC_USART3CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 318 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 319 break; \
Kojto 90:cb3d968589d8 320 case RCC_USART3CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 321 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 322 break; \
Kojto 90:cb3d968589d8 323 } \
Kojto 90:cb3d968589d8 324 } \
Kojto 90:cb3d968589d8 325 } while(0)
Kojto 90:cb3d968589d8 326 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
Kojto 90:cb3d968589d8 327 /* STM32F302xC || STM32F303xC || STM32F358xx */
Kojto 90:cb3d968589d8 328
Kojto 90:cb3d968589d8 329
Kojto 90:cb3d968589d8 330 /** @brief Computes the UART mask to apply to retrieve the received data
Kojto 90:cb3d968589d8 331 * according to the word length and to the parity bits activation.
Kojto 90:cb3d968589d8 332 * If PCE = 1, the parity bit is not included in the data extracted
Kojto 90:cb3d968589d8 333 * by the reception API().
Kojto 90:cb3d968589d8 334 * This masking operation is not carried out in the case of
Kojto 90:cb3d968589d8 335 * DMA transfers.
Kojto 90:cb3d968589d8 336 * @param __HANDLE__: specifies the UART Handle
Kojto 90:cb3d968589d8 337 * @retval none
Kojto 90:cb3d968589d8 338 */
Kojto 90:cb3d968589d8 339 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
Kojto 90:cb3d968589d8 340 defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
Kojto 90:cb3d968589d8 341 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
Kojto 90:cb3d968589d8 342 #define __HAL_UART_MASK_COMPUTATION(__HANDLE__) \
Kojto 90:cb3d968589d8 343 do { \
Kojto 90:cb3d968589d8 344 if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_9B) \
Kojto 90:cb3d968589d8 345 { \
Kojto 90:cb3d968589d8 346 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
Kojto 90:cb3d968589d8 347 { \
Kojto 90:cb3d968589d8 348 (__HANDLE__)->Mask = 0x01FF ; \
Kojto 90:cb3d968589d8 349 } \
Kojto 90:cb3d968589d8 350 else \
Kojto 90:cb3d968589d8 351 { \
Kojto 90:cb3d968589d8 352 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 90:cb3d968589d8 353 } \
Kojto 90:cb3d968589d8 354 } \
Kojto 90:cb3d968589d8 355 else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_8B) \
Kojto 90:cb3d968589d8 356 { \
Kojto 90:cb3d968589d8 357 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
Kojto 90:cb3d968589d8 358 { \
Kojto 90:cb3d968589d8 359 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 90:cb3d968589d8 360 } \
Kojto 90:cb3d968589d8 361 else \
Kojto 90:cb3d968589d8 362 { \
Kojto 90:cb3d968589d8 363 (__HANDLE__)->Mask = 0x007F ; \
Kojto 90:cb3d968589d8 364 } \
Kojto 90:cb3d968589d8 365 } \
Kojto 90:cb3d968589d8 366 else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_7B) \
Kojto 90:cb3d968589d8 367 { \
Kojto 90:cb3d968589d8 368 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
Kojto 90:cb3d968589d8 369 { \
Kojto 90:cb3d968589d8 370 (__HANDLE__)->Mask = 0x007F ; \
Kojto 90:cb3d968589d8 371 } \
Kojto 90:cb3d968589d8 372 else \
Kojto 90:cb3d968589d8 373 { \
Kojto 90:cb3d968589d8 374 (__HANDLE__)->Mask = 0x003F ; \
Kojto 90:cb3d968589d8 375 } \
Kojto 90:cb3d968589d8 376 } \
Kojto 90:cb3d968589d8 377 } while(0)
Kojto 90:cb3d968589d8 378 #else
Kojto 90:cb3d968589d8 379 #define __HAL_UART_MASK_COMPUTATION(__HANDLE__) \
Kojto 90:cb3d968589d8 380 do { \
Kojto 90:cb3d968589d8 381 if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_9B) \
Kojto 90:cb3d968589d8 382 { \
Kojto 90:cb3d968589d8 383 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
Kojto 90:cb3d968589d8 384 { \
Kojto 90:cb3d968589d8 385 (__HANDLE__)->Mask = 0x01FF ; \
Kojto 90:cb3d968589d8 386 } \
Kojto 90:cb3d968589d8 387 else \
Kojto 90:cb3d968589d8 388 { \
Kojto 90:cb3d968589d8 389 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 90:cb3d968589d8 390 } \
Kojto 90:cb3d968589d8 391 } \
Kojto 90:cb3d968589d8 392 else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_8B) \
Kojto 90:cb3d968589d8 393 { \
Kojto 90:cb3d968589d8 394 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
Kojto 90:cb3d968589d8 395 { \
Kojto 90:cb3d968589d8 396 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 90:cb3d968589d8 397 } \
Kojto 90:cb3d968589d8 398 else \
Kojto 90:cb3d968589d8 399 { \
Kojto 90:cb3d968589d8 400 (__HANDLE__)->Mask = 0x007F ; \
Kojto 90:cb3d968589d8 401 } \
Kojto 90:cb3d968589d8 402 } \
Kojto 90:cb3d968589d8 403 } while(0)
Kojto 90:cb3d968589d8 404 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
Kojto 90:cb3d968589d8 405 /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
Kojto 90:cb3d968589d8 406 /* STM32F301x8 || STM32F302x8 || STM32F318xx */
Kojto 90:cb3d968589d8 407 /**
Kojto 90:cb3d968589d8 408 * @}
Kojto 90:cb3d968589d8 409 */
Kojto 90:cb3d968589d8 410
Kojto 90:cb3d968589d8 411 /* Exported functions --------------------------------------------------------*/
Kojto 90:cb3d968589d8 412 /** @defgroup UARTEx_Exported_Functions UART Extended Exported Functions
Kojto 90:cb3d968589d8 413 * @{
Kojto 90:cb3d968589d8 414 */
Kojto 90:cb3d968589d8 415
Kojto 90:cb3d968589d8 416 /** @defgroup UARTEx_Exported_Functions_Group1 Extended Initialization and de-initialization functions
Kojto 90:cb3d968589d8 417 * @brief Extended Initialization and Configuration Functions
Kojto 90:cb3d968589d8 418 * @{
Kojto 90:cb3d968589d8 419 */
Kojto 90:cb3d968589d8 420 /* Initialization and de-initialization functions ****************************/
Kojto 90:cb3d968589d8 421 HAL_StatusTypeDef HAL_RS485Ex_Init(UART_HandleTypeDef *huart, uint32_t UART_DEPolarity, uint32_t UART_DEAssertionTime, uint32_t UART_DEDeassertionTime);
Kojto 90:cb3d968589d8 422 /**
Kojto 90:cb3d968589d8 423 * @}
Kojto 90:cb3d968589d8 424 */
Kojto 90:cb3d968589d8 425
Kojto 90:cb3d968589d8 426 /** @defgroup UARTEx_Exported_Functions_Group2 Extended Peripheral Control functions
Kojto 90:cb3d968589d8 427 * @brief Extended Peripheral Control functions
Kojto 90:cb3d968589d8 428 * @{
Kojto 90:cb3d968589d8 429 */
Kojto 90:cb3d968589d8 430 /* Peripheral Control functions ***********************************************/
Kojto 90:cb3d968589d8 431 HAL_StatusTypeDef HAL_UARTEx_StopModeWakeUpSourceConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection);
Kojto 90:cb3d968589d8 432 HAL_StatusTypeDef HAL_UARTEx_EnableStopMode(UART_HandleTypeDef *huart);
Kojto 90:cb3d968589d8 433 HAL_StatusTypeDef HAL_UARTEx_DisableStopMode(UART_HandleTypeDef *huart);
Kojto 90:cb3d968589d8 434 HAL_StatusTypeDef HAL_MultiProcessorEx_AddressLength_Set(UART_HandleTypeDef *huart, uint32_t AddressLength);
Kojto 90:cb3d968589d8 435 /**
Kojto 90:cb3d968589d8 436 * @}
Kojto 90:cb3d968589d8 437 */
Kojto 90:cb3d968589d8 438
Kojto 90:cb3d968589d8 439 /**
Kojto 90:cb3d968589d8 440 * @}
Kojto 90:cb3d968589d8 441 */
Kojto 90:cb3d968589d8 442
Kojto 90:cb3d968589d8 443
Kojto 90:cb3d968589d8 444 /**
Kojto 90:cb3d968589d8 445 * @}
Kojto 90:cb3d968589d8 446 */
Kojto 90:cb3d968589d8 447
Kojto 90:cb3d968589d8 448 /**
Kojto 90:cb3d968589d8 449 * @}
Kojto 90:cb3d968589d8 450 */
Kojto 90:cb3d968589d8 451
Kojto 90:cb3d968589d8 452 #ifdef __cplusplus
Kojto 90:cb3d968589d8 453 }
Kojto 90:cb3d968589d8 454 #endif
Kojto 90:cb3d968589d8 455
Kojto 90:cb3d968589d8 456 #endif /* __STM32F3xx_HAL_UART_EX_H */
Kojto 90:cb3d968589d8 457
Kojto 90:cb3d968589d8 458 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/