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:
93:e188a91d3eaa
First reale BlueNRG module for nucleo 401 board

Who changed what in which revision?

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