The official mbed C/C SDK provides the software platform and libraries to build your applications.

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Feb 03 15:31:20 2015 +0000
Revision:
93:e188a91d3eaa
Parent:
90:cb3d968589d8
Release 93 of the mbed library

Main changes:

- Renesas RZ_A1H bugfixes - i2c, ticker
- new targets - Nucleo F303RE, Nucleo F070RB, BLE SMURFS,
Dragonfly 411RE,
- BusXXX - is connected method, plus operators addition
- LPC8xx - I2c fixes
- timestamp_t reverted to uint32_t
- RTX - fixes regarding stack (alignment, magic word)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 90:cb3d968589d8 1 /**
Kojto 90:cb3d968589d8 2 ******************************************************************************
Kojto 90:cb3d968589d8 3 * @file stm32f0xx_hal_usart_ex.h
Kojto 90:cb3d968589d8 4 * @author MCD Application Team
Kojto 93:e188a91d3eaa 5 * @version V1.2.0
Kojto 93:e188a91d3eaa 6 * @date 11-December-2014
Kojto 90:cb3d968589d8 7 * @brief Header file of USART HAL Extension 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 __STM32F0xx_HAL_USART_EX_H
Kojto 90:cb3d968589d8 40 #define __STM32F0xx_HAL_USART_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 "stm32f0xx_hal_def.h"
Kojto 90:cb3d968589d8 48
Kojto 90:cb3d968589d8 49 /** @addtogroup STM32F0xx_HAL_Driver
Kojto 90:cb3d968589d8 50 * @{
Kojto 90:cb3d968589d8 51 */
Kojto 90:cb3d968589d8 52
Kojto 90:cb3d968589d8 53 /** @defgroup USARTEx USARTEx Extended HAL module driver
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 USARTEx_Exported_Constants USARTEx Exported Constants
Kojto 90:cb3d968589d8 60 * @{
Kojto 90:cb3d968589d8 61 */
Kojto 90:cb3d968589d8 62
Kojto 90:cb3d968589d8 63 /** @defgroup USARTEx_Word_Length USARTEx Word Length
Kojto 90:cb3d968589d8 64 * @{
Kojto 90:cb3d968589d8 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)
Kojto 90:cb3d968589d8 69 #define USART_WORDLENGTH_7B ((uint32_t)USART_CR1_M1)
Kojto 90:cb3d968589d8 70 #define USART_WORDLENGTH_8B ((uint32_t)0x00000000)
Kojto 90:cb3d968589d8 71 #define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M0)
Kojto 90:cb3d968589d8 72 #define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WORDLENGTH_7B) || \
Kojto 90:cb3d968589d8 73 ((LENGTH) == USART_WORDLENGTH_8B) || \
Kojto 90:cb3d968589d8 74 ((LENGTH) == USART_WORDLENGTH_9B))
Kojto 90:cb3d968589d8 75 #else
Kojto 90:cb3d968589d8 76 #define USART_WORDLENGTH_8B ((uint32_t)0x00000000)
Kojto 90:cb3d968589d8 77 #define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
Kojto 90:cb3d968589d8 78 #define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WORDLENGTH_8B) || \
Kojto 90:cb3d968589d8 79 ((LENGTH) == USART_WORDLENGTH_9B))
Kojto 93:e188a91d3eaa 80 #endif /* defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || defined (STM32F070xB) || \
Kojto 90:cb3d968589d8 81 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || \
Kojto 93:e188a91d3eaa 82 defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) */
Kojto 90:cb3d968589d8 83 /**
Kojto 90:cb3d968589d8 84 * @}
Kojto 90:cb3d968589d8 85 */
Kojto 90:cb3d968589d8 86
Kojto 90:cb3d968589d8 87 /**
Kojto 90:cb3d968589d8 88 * @}
Kojto 90:cb3d968589d8 89 */
Kojto 90:cb3d968589d8 90
Kojto 90:cb3d968589d8 91 /* Exported macro ------------------------------------------------------------*/
Kojto 90:cb3d968589d8 92
Kojto 90:cb3d968589d8 93 /** @defgroup USARTEx_Exported_Macros USARTEx Exported Macros
Kojto 90:cb3d968589d8 94 * @{
Kojto 90:cb3d968589d8 95 */
Kojto 90:cb3d968589d8 96
Kojto 90:cb3d968589d8 97 /** @brief Reports the USART clock source.
Kojto 90:cb3d968589d8 98 * @param __HANDLE__: specifies the USART Handle
Kojto 90:cb3d968589d8 99 * @param __CLOCKSOURCE__ : output variable
Kojto 90:cb3d968589d8 100 * @retval the USART clocking source, written in __CLOCKSOURCE__.
Kojto 90:cb3d968589d8 101 */
Kojto 90:cb3d968589d8 102 #if defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F038xx)
Kojto 90:cb3d968589d8 103 #define __HAL_USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 90:cb3d968589d8 104 do { \
Kojto 90:cb3d968589d8 105 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 90:cb3d968589d8 106 { \
Kojto 90:cb3d968589d8 107 case RCC_USART1CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 108 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 109 break; \
Kojto 90:cb3d968589d8 110 case RCC_USART1CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 111 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 112 break; \
Kojto 90:cb3d968589d8 113 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 114 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 115 break; \
Kojto 90:cb3d968589d8 116 case RCC_USART1CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 117 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 118 break; \
Kojto 90:cb3d968589d8 119 default: \
Kojto 90:cb3d968589d8 120 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 121 break; \
Kojto 90:cb3d968589d8 122 } \
Kojto 90:cb3d968589d8 123 } while(0)
Kojto 93:e188a91d3eaa 124 #elif defined (STM32F030x8) || defined (STM32F070x6) || \
Kojto 90:cb3d968589d8 125 defined (STM32F042x6) || defined (STM32F048xx) || \
Kojto 90:cb3d968589d8 126 defined (STM32F051x8) || defined (STM32F058xx)
Kojto 90:cb3d968589d8 127 #define __HAL_USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 90:cb3d968589d8 128 do { \
Kojto 90:cb3d968589d8 129 if((__HANDLE__)->Instance == USART1) \
Kojto 90:cb3d968589d8 130 { \
Kojto 90:cb3d968589d8 131 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 90:cb3d968589d8 132 { \
Kojto 90:cb3d968589d8 133 case RCC_USART1CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 134 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 135 break; \
Kojto 90:cb3d968589d8 136 case RCC_USART1CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 137 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 138 break; \
Kojto 90:cb3d968589d8 139 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 140 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 141 break; \
Kojto 90:cb3d968589d8 142 case RCC_USART1CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 143 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 144 break; \
Kojto 90:cb3d968589d8 145 default: \
Kojto 90:cb3d968589d8 146 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 147 break; \
Kojto 90:cb3d968589d8 148 } \
Kojto 90:cb3d968589d8 149 } \
Kojto 90:cb3d968589d8 150 else if((__HANDLE__)->Instance == USART2) \
Kojto 90:cb3d968589d8 151 { \
Kojto 90:cb3d968589d8 152 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 153 } \
Kojto 90:cb3d968589d8 154 else \
Kojto 90:cb3d968589d8 155 { \
Kojto 90:cb3d968589d8 156 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 157 } \
Kojto 90:cb3d968589d8 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)
Kojto 90:cb3d968589d8 200 #elif defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)
Kojto 90:cb3d968589d8 201 #define __HAL_USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 90:cb3d968589d8 202 do { \
Kojto 90:cb3d968589d8 203 if((__HANDLE__)->Instance == USART1) \
Kojto 90:cb3d968589d8 204 { \
Kojto 90:cb3d968589d8 205 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 90:cb3d968589d8 206 { \
Kojto 90:cb3d968589d8 207 case RCC_USART1CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 208 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 209 break; \
Kojto 90:cb3d968589d8 210 case RCC_USART1CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 211 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 212 break; \
Kojto 90:cb3d968589d8 213 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 214 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 215 break; \
Kojto 90:cb3d968589d8 216 case RCC_USART1CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 217 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 218 break; \
Kojto 90:cb3d968589d8 219 default: \
Kojto 90:cb3d968589d8 220 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 221 break; \
Kojto 90:cb3d968589d8 222 } \
Kojto 90:cb3d968589d8 223 } \
Kojto 90:cb3d968589d8 224 else if((__HANDLE__)->Instance == USART2) \
Kojto 90:cb3d968589d8 225 { \
Kojto 90:cb3d968589d8 226 switch(__HAL_RCC_GET_USART2_SOURCE()) \
Kojto 90:cb3d968589d8 227 { \
Kojto 90:cb3d968589d8 228 case RCC_USART2CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 229 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 230 break; \
Kojto 90:cb3d968589d8 231 case RCC_USART2CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 232 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 233 break; \
Kojto 90:cb3d968589d8 234 case RCC_USART2CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 235 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 236 break; \
Kojto 90:cb3d968589d8 237 case RCC_USART2CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 238 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 239 break; \
Kojto 90:cb3d968589d8 240 default: \
Kojto 90:cb3d968589d8 241 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 242 break; \
Kojto 90:cb3d968589d8 243 } \
Kojto 90:cb3d968589d8 244 } \
Kojto 90:cb3d968589d8 245 else if((__HANDLE__)->Instance == USART3) \
Kojto 90:cb3d968589d8 246 { \
Kojto 90:cb3d968589d8 247 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 248 } \
Kojto 90:cb3d968589d8 249 else if((__HANDLE__)->Instance == USART4) \
Kojto 90:cb3d968589d8 250 { \
Kojto 90:cb3d968589d8 251 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 252 } \
Kojto 90:cb3d968589d8 253 else \
Kojto 90:cb3d968589d8 254 { \
Kojto 90:cb3d968589d8 255 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 256 } \
Kojto 90:cb3d968589d8 257 } while(0)
Kojto 90:cb3d968589d8 258 #elif defined(STM32F091xC) || defined (STM32F098xx)
Kojto 90:cb3d968589d8 259 #define __HAL_USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 90:cb3d968589d8 260 do { \
Kojto 90:cb3d968589d8 261 if((__HANDLE__)->Instance == USART1) \
Kojto 90:cb3d968589d8 262 { \
Kojto 90:cb3d968589d8 263 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 90:cb3d968589d8 264 { \
Kojto 90:cb3d968589d8 265 case RCC_USART1CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 266 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 267 break; \
Kojto 90:cb3d968589d8 268 case RCC_USART1CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 269 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 270 break; \
Kojto 90:cb3d968589d8 271 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 272 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 273 break; \
Kojto 90:cb3d968589d8 274 case RCC_USART1CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 275 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 276 break; \
Kojto 90:cb3d968589d8 277 default: \
Kojto 90:cb3d968589d8 278 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 279 break; \
Kojto 90:cb3d968589d8 280 } \
Kojto 90:cb3d968589d8 281 } \
Kojto 90:cb3d968589d8 282 else if((__HANDLE__)->Instance == USART2) \
Kojto 90:cb3d968589d8 283 { \
Kojto 90:cb3d968589d8 284 switch(__HAL_RCC_GET_USART2_SOURCE()) \
Kojto 90:cb3d968589d8 285 { \
Kojto 90:cb3d968589d8 286 case RCC_USART2CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 287 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 288 break; \
Kojto 90:cb3d968589d8 289 case RCC_USART2CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 290 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 291 break; \
Kojto 90:cb3d968589d8 292 case RCC_USART2CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 293 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 294 break; \
Kojto 90:cb3d968589d8 295 case RCC_USART2CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 296 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 297 break; \
Kojto 90:cb3d968589d8 298 default: \
Kojto 90:cb3d968589d8 299 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 300 break; \
Kojto 90:cb3d968589d8 301 } \
Kojto 90:cb3d968589d8 302 } \
Kojto 90:cb3d968589d8 303 else if((__HANDLE__)->Instance == USART3) \
Kojto 90:cb3d968589d8 304 { \
Kojto 90:cb3d968589d8 305 switch(__HAL_RCC_GET_USART3_SOURCE()) \
Kojto 90:cb3d968589d8 306 { \
Kojto 90:cb3d968589d8 307 case RCC_USART3CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 308 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 309 break; \
Kojto 90:cb3d968589d8 310 case RCC_USART3CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 311 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 312 break; \
Kojto 90:cb3d968589d8 313 case RCC_USART3CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 314 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 315 break; \
Kojto 90:cb3d968589d8 316 case RCC_USART3CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 317 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 318 break; \
Kojto 90:cb3d968589d8 319 default: \
Kojto 90:cb3d968589d8 320 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 321 break; \
Kojto 90:cb3d968589d8 322 } \
Kojto 90:cb3d968589d8 323 } \
Kojto 90:cb3d968589d8 324 else if((__HANDLE__)->Instance == USART4) \
Kojto 90:cb3d968589d8 325 { \
Kojto 90:cb3d968589d8 326 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 327 } \
Kojto 90:cb3d968589d8 328 else if((__HANDLE__)->Instance == USART5) \
Kojto 90:cb3d968589d8 329 { \
Kojto 90:cb3d968589d8 330 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 331 } \
Kojto 90:cb3d968589d8 332 else if((__HANDLE__)->Instance == USART6) \
Kojto 90:cb3d968589d8 333 { \
Kojto 90:cb3d968589d8 334 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 335 } \
Kojto 90:cb3d968589d8 336 else if((__HANDLE__)->Instance == USART7) \
Kojto 90:cb3d968589d8 337 { \
Kojto 90:cb3d968589d8 338 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 339 } \
Kojto 90:cb3d968589d8 340 else if((__HANDLE__)->Instance == USART8) \
Kojto 90:cb3d968589d8 341 { \
Kojto 90:cb3d968589d8 342 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 343 } \
Kojto 90:cb3d968589d8 344 else \
Kojto 90:cb3d968589d8 345 { \
Kojto 90:cb3d968589d8 346 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 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)
Kojto 90:cb3d968589d8 398 #endif /* defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F038xx) */
Kojto 90:cb3d968589d8 399
Kojto 90:cb3d968589d8 400
Kojto 90:cb3d968589d8 401 /** @brief Reports the USART mask to apply to retrieve the received data
Kojto 90:cb3d968589d8 402 * according to the word length and to the parity bits activation.
Kojto 90:cb3d968589d8 403 * If PCE = 1, the parity bit is not included in the data extracted
Kojto 90:cb3d968589d8 404 * by the reception API().
Kojto 90:cb3d968589d8 405 * This masking operation is not carried out in the case of
Kojto 90:cb3d968589d8 406 * DMA transfers.
Kojto 90:cb3d968589d8 407 * @param __HANDLE__: specifies the USART Handle
Kojto 90:cb3d968589d8 408 * @retval none
Kojto 90:cb3d968589d8 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)
Kojto 90:cb3d968589d8 413 #define __HAL_USART_MASK_COMPUTATION(__HANDLE__) \
Kojto 90:cb3d968589d8 414 do { \
Kojto 90:cb3d968589d8 415 if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_9B) \
Kojto 90:cb3d968589d8 416 { \
Kojto 90:cb3d968589d8 417 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
Kojto 90:cb3d968589d8 418 { \
Kojto 90:cb3d968589d8 419 (__HANDLE__)->Mask = 0x01FF ; \
Kojto 90:cb3d968589d8 420 } \
Kojto 90:cb3d968589d8 421 else \
Kojto 90:cb3d968589d8 422 { \
Kojto 90:cb3d968589d8 423 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 90:cb3d968589d8 424 } \
Kojto 90:cb3d968589d8 425 } \
Kojto 90:cb3d968589d8 426 else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_8B) \
Kojto 90:cb3d968589d8 427 { \
Kojto 90:cb3d968589d8 428 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
Kojto 90:cb3d968589d8 429 { \
Kojto 90:cb3d968589d8 430 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 90:cb3d968589d8 431 } \
Kojto 90:cb3d968589d8 432 else \
Kojto 90:cb3d968589d8 433 { \
Kojto 90:cb3d968589d8 434 (__HANDLE__)->Mask = 0x007F ; \
Kojto 90:cb3d968589d8 435 } \
Kojto 90:cb3d968589d8 436 } \
Kojto 90:cb3d968589d8 437 else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_7B) \
Kojto 90:cb3d968589d8 438 { \
Kojto 90:cb3d968589d8 439 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
Kojto 90:cb3d968589d8 440 { \
Kojto 90:cb3d968589d8 441 (__HANDLE__)->Mask = 0x007F ; \
Kojto 90:cb3d968589d8 442 } \
Kojto 90:cb3d968589d8 443 else \
Kojto 90:cb3d968589d8 444 { \
Kojto 90:cb3d968589d8 445 (__HANDLE__)->Mask = 0x003F ; \
Kojto 90:cb3d968589d8 446 } \
Kojto 90:cb3d968589d8 447 } \
Kojto 90:cb3d968589d8 448 } while(0)
Kojto 90:cb3d968589d8 449 #else
Kojto 90:cb3d968589d8 450 #define __HAL_USART_MASK_COMPUTATION(__HANDLE__) \
Kojto 90:cb3d968589d8 451 do { \
Kojto 90:cb3d968589d8 452 if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_9B) \
Kojto 90:cb3d968589d8 453 { \
Kojto 90:cb3d968589d8 454 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
Kojto 90:cb3d968589d8 455 { \
Kojto 90:cb3d968589d8 456 (__HANDLE__)->Mask = 0x01FF ; \
Kojto 90:cb3d968589d8 457 } \
Kojto 90:cb3d968589d8 458 else \
Kojto 90:cb3d968589d8 459 { \
Kojto 90:cb3d968589d8 460 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 90:cb3d968589d8 461 } \
Kojto 90:cb3d968589d8 462 } \
Kojto 90:cb3d968589d8 463 else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_8B) \
Kojto 90:cb3d968589d8 464 { \
Kojto 90:cb3d968589d8 465 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
Kojto 90:cb3d968589d8 466 { \
Kojto 90:cb3d968589d8 467 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 90:cb3d968589d8 468 } \
Kojto 90:cb3d968589d8 469 else \
Kojto 90:cb3d968589d8 470 { \
Kojto 90:cb3d968589d8 471 (__HANDLE__)->Mask = 0x007F ; \
Kojto 90:cb3d968589d8 472 } \
Kojto 90:cb3d968589d8 473 } \
Kojto 90:cb3d968589d8 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) */
Kojto 90:cb3d968589d8 478 /**
Kojto 90:cb3d968589d8 479 * @}
Kojto 90:cb3d968589d8 480 */
Kojto 90:cb3d968589d8 481
Kojto 90:cb3d968589d8 482 /* Exported functions --------------------------------------------------------*/
Kojto 90:cb3d968589d8 483 /* Initialization and de-initialization functions ****************************/
Kojto 90:cb3d968589d8 484 /* I/O operation functions ***************************************************/
Kojto 90:cb3d968589d8 485 /* Peripheral Control functions **********************************************/
Kojto 90:cb3d968589d8 486 /* Peripheral State functions ************************************************/
Kojto 90:cb3d968589d8 487
Kojto 90:cb3d968589d8 488 /**
Kojto 90:cb3d968589d8 489 * @}
Kojto 90:cb3d968589d8 490 */
Kojto 90:cb3d968589d8 491
Kojto 90:cb3d968589d8 492 /**
Kojto 90:cb3d968589d8 493 * @}
Kojto 90:cb3d968589d8 494 */
Kojto 90:cb3d968589d8 495
Kojto 90:cb3d968589d8 496 #ifdef __cplusplus
Kojto 90:cb3d968589d8 497 }
Kojto 90:cb3d968589d8 498 #endif
Kojto 90:cb3d968589d8 499
Kojto 90:cb3d968589d8 500 #endif /* __STM32F0xx_HAL_USART_EX_H */
Kojto 90:cb3d968589d8 501
Kojto 90:cb3d968589d8 502 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Kojto 90:cb3d968589d8 503