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

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
92:4fc01daae5a5
Child:
123:b0220dba8be7
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
bogdanm 86:04dd9b1680ae 1 /**
bogdanm 86:04dd9b1680ae 2 ******************************************************************************
bogdanm 86:04dd9b1680ae 3 * @file stm32f3xx_hal_usart_ex.h
bogdanm 86:04dd9b1680ae 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.2.1
Kojto 122:f9eeca106725 6 * @date 29-April-2015
Kojto 122:f9eeca106725 7 * @brief Header file of USART HAL Extension module.
bogdanm 86:04dd9b1680ae 8 ******************************************************************************
bogdanm 86:04dd9b1680ae 9 * @attention
Kojto 122:f9eeca106725 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
bogdanm 86:04dd9b1680ae 12 *
bogdanm 86:04dd9b1680ae 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 86:04dd9b1680ae 14 * are permitted provided that the following conditions are met:
bogdanm 86:04dd9b1680ae 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 86:04dd9b1680ae 16 * this list of conditions and the following disclaimer.
bogdanm 86:04dd9b1680ae 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 86:04dd9b1680ae 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 86:04dd9b1680ae 19 * and/or other materials provided with the distribution.
bogdanm 86:04dd9b1680ae 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 86:04dd9b1680ae 21 * may be used to endorse or promote products derived from this software
bogdanm 86:04dd9b1680ae 22 * without specific prior written permission.
bogdanm 86:04dd9b1680ae 23 *
bogdanm 86:04dd9b1680ae 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 86:04dd9b1680ae 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 86:04dd9b1680ae 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 86:04dd9b1680ae 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 86:04dd9b1680ae 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 86:04dd9b1680ae 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 86:04dd9b1680ae 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 86:04dd9b1680ae 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 86:04dd9b1680ae 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 86:04dd9b1680ae 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 86:04dd9b1680ae 34 *
Kojto 122:f9eeca106725 35 ******************************************************************************
bogdanm 86:04dd9b1680ae 36 */
bogdanm 86:04dd9b1680ae 37
bogdanm 86:04dd9b1680ae 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 86:04dd9b1680ae 39 #ifndef __STM32F3xx_HAL_USART_EX_H
bogdanm 86:04dd9b1680ae 40 #define __STM32F3xx_HAL_USART_EX_H
bogdanm 86:04dd9b1680ae 41
bogdanm 86:04dd9b1680ae 42 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 43 extern "C" {
bogdanm 86:04dd9b1680ae 44 #endif
bogdanm 86:04dd9b1680ae 45
bogdanm 86:04dd9b1680ae 46 /* Includes ------------------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 47 #include "stm32f3xx_hal_def.h"
bogdanm 86:04dd9b1680ae 48
bogdanm 86:04dd9b1680ae 49 /** @addtogroup STM32F3xx_HAL_Driver
bogdanm 86:04dd9b1680ae 50 * @{
bogdanm 86:04dd9b1680ae 51 */
bogdanm 86:04dd9b1680ae 52
Kojto 122:f9eeca106725 53 /** @defgroup USARTEx USARTEx
bogdanm 86:04dd9b1680ae 54 * @{
bogdanm 86:04dd9b1680ae 55 */
bogdanm 86:04dd9b1680ae 56
bogdanm 86:04dd9b1680ae 57 /* Exported types ------------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 58 /* Exported constants --------------------------------------------------------*/
Kojto 122:f9eeca106725 59 /** @defgroup USARTEx_Exported_Constants USARTEx Exported Constants
bogdanm 86:04dd9b1680ae 60 * @{
bogdanm 86:04dd9b1680ae 61 */
Kojto 122:f9eeca106725 62
Kojto 122:f9eeca106725 63 /** @defgroup USARTEx_Word_Length USARTEx Word Length
bogdanm 86:04dd9b1680ae 64 * @{
bogdanm 86:04dd9b1680ae 65 */
bogdanm 92:4fc01daae5a5 66 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
bogdanm 92:4fc01daae5a5 67 defined(STM32F334x8) || \
bogdanm 92:4fc01daae5a5 68 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
Kojto 122:f9eeca106725 69 #define USART_WORDLENGTH_7B ((uint32_t)USART_CR1_M1) /*!< 7-bit long USART frame */
Kojto 122:f9eeca106725 70 #define USART_WORDLENGTH_8B ((uint32_t)0x00000000) /*!< 8-bit long USART frame */
Kojto 122:f9eeca106725 71 #define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M0) /*!< 9-bit long USART frame */
bogdanm 86:04dd9b1680ae 72 #else
Kojto 122:f9eeca106725 73 #define USART_WORDLENGTH_8B ((uint32_t)0x00000000) /*!< 8-bit long USART frame */
Kojto 122:f9eeca106725 74 #define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M) /*!< 9-bit long USART frame */
bogdanm 92:4fc01daae5a5 75 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
bogdanm 92:4fc01daae5a5 76 /* STM32F334x8 || */
bogdanm 92:4fc01daae5a5 77 /* STM32F301x8 || STM32F302x8 || STM32F318xx */
bogdanm 86:04dd9b1680ae 78 /**
bogdanm 86:04dd9b1680ae 79 * @}
bogdanm 86:04dd9b1680ae 80 */
bogdanm 86:04dd9b1680ae 81
bogdanm 86:04dd9b1680ae 82
bogdanm 86:04dd9b1680ae 83 /**
bogdanm 86:04dd9b1680ae 84 * @}
Kojto 122:f9eeca106725 85 */
bogdanm 86:04dd9b1680ae 86
Kojto 122:f9eeca106725 87 /* Private macros ------------------------------------------------------------*/
Kojto 122:f9eeca106725 88 /** @defgroup USARTEx_Private_Macros USARTEx Private Macros
bogdanm 86:04dd9b1680ae 89 * @{
bogdanm 86:04dd9b1680ae 90 */
Kojto 122:f9eeca106725 91
bogdanm 86:04dd9b1680ae 92 /** @brief Reports the USART clock source.
bogdanm 86:04dd9b1680ae 93 * @param __HANDLE__: specifies the USART Handle
bogdanm 86:04dd9b1680ae 94 * @param __CLOCKSOURCE__ : output variable
bogdanm 86:04dd9b1680ae 95 * @retval the USART clocking source, written in __CLOCKSOURCE__.
bogdanm 86:04dd9b1680ae 96 */
Kojto 122:f9eeca106725 97 #if defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
Kojto 122:f9eeca106725 98 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
Kojto 122:f9eeca106725 99 #define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
bogdanm 86:04dd9b1680ae 100 do { \
bogdanm 86:04dd9b1680ae 101 if((__HANDLE__)->Instance == USART1) \
bogdanm 86:04dd9b1680ae 102 { \
bogdanm 86:04dd9b1680ae 103 switch(__HAL_RCC_GET_USART1_SOURCE()) \
bogdanm 86:04dd9b1680ae 104 { \
bogdanm 86:04dd9b1680ae 105 case RCC_USART1CLKSOURCE_PCLK1: \
bogdanm 86:04dd9b1680ae 106 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
bogdanm 86:04dd9b1680ae 107 break; \
bogdanm 86:04dd9b1680ae 108 case RCC_USART1CLKSOURCE_HSI: \
bogdanm 86:04dd9b1680ae 109 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
bogdanm 86:04dd9b1680ae 110 break; \
bogdanm 86:04dd9b1680ae 111 case RCC_USART1CLKSOURCE_SYSCLK: \
bogdanm 86:04dd9b1680ae 112 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
bogdanm 86:04dd9b1680ae 113 break; \
bogdanm 86:04dd9b1680ae 114 case RCC_USART1CLKSOURCE_LSE: \
bogdanm 86:04dd9b1680ae 115 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
bogdanm 86:04dd9b1680ae 116 break; \
Kojto 122:f9eeca106725 117 default: \
Kojto 122:f9eeca106725 118 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 119 break; \
Kojto 122:f9eeca106725 120 } \
Kojto 122:f9eeca106725 121 } \
Kojto 122:f9eeca106725 122 else if((__HANDLE__)->Instance == USART2) \
Kojto 122:f9eeca106725 123 { \
Kojto 122:f9eeca106725 124 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 122:f9eeca106725 125 } \
Kojto 122:f9eeca106725 126 else if((__HANDLE__)->Instance == USART3) \
Kojto 122:f9eeca106725 127 { \
Kojto 122:f9eeca106725 128 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
Kojto 122:f9eeca106725 129 } \
Kojto 122:f9eeca106725 130 else \
Kojto 122:f9eeca106725 131 { \
Kojto 122:f9eeca106725 132 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 133 } \
Kojto 122:f9eeca106725 134 } while(0)
Kojto 122:f9eeca106725 135 #else
Kojto 122:f9eeca106725 136 #define USART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 122:f9eeca106725 137 do { \
Kojto 122:f9eeca106725 138 if((__HANDLE__)->Instance == USART1) \
Kojto 122:f9eeca106725 139 { \
Kojto 122:f9eeca106725 140 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 122:f9eeca106725 141 { \
Kojto 122:f9eeca106725 142 case RCC_USART1CLKSOURCE_PCLK2: \
Kojto 122:f9eeca106725 143 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK2; \
Kojto 122:f9eeca106725 144 break; \
Kojto 122:f9eeca106725 145 case RCC_USART1CLKSOURCE_HSI: \
Kojto 122:f9eeca106725 146 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
Kojto 122:f9eeca106725 147 break; \
Kojto 122:f9eeca106725 148 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 122:f9eeca106725 149 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
Kojto 122:f9eeca106725 150 break; \
Kojto 122:f9eeca106725 151 case RCC_USART1CLKSOURCE_LSE: \
Kojto 122:f9eeca106725 152 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
Kojto 122:f9eeca106725 153 break; \
Kojto 122:f9eeca106725 154 default: \
Kojto 122:f9eeca106725 155 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 156 break; \
bogdanm 86:04dd9b1680ae 157 } \
bogdanm 86:04dd9b1680ae 158 } \
bogdanm 86:04dd9b1680ae 159 else if((__HANDLE__)->Instance == USART2) \
bogdanm 86:04dd9b1680ae 160 { \
bogdanm 86:04dd9b1680ae 161 switch(__HAL_RCC_GET_USART2_SOURCE()) \
bogdanm 86:04dd9b1680ae 162 { \
bogdanm 86:04dd9b1680ae 163 case RCC_USART2CLKSOURCE_PCLK1: \
bogdanm 86:04dd9b1680ae 164 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
bogdanm 86:04dd9b1680ae 165 break; \
bogdanm 86:04dd9b1680ae 166 case RCC_USART2CLKSOURCE_HSI: \
bogdanm 86:04dd9b1680ae 167 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
bogdanm 86:04dd9b1680ae 168 break; \
bogdanm 86:04dd9b1680ae 169 case RCC_USART2CLKSOURCE_SYSCLK: \
bogdanm 86:04dd9b1680ae 170 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
bogdanm 86:04dd9b1680ae 171 break; \
bogdanm 86:04dd9b1680ae 172 case RCC_USART2CLKSOURCE_LSE: \
bogdanm 86:04dd9b1680ae 173 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
bogdanm 86:04dd9b1680ae 174 break; \
Kojto 122:f9eeca106725 175 default: \
Kojto 122:f9eeca106725 176 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
bogdanm 86:04dd9b1680ae 177 break; \
bogdanm 86:04dd9b1680ae 178 } \
bogdanm 86:04dd9b1680ae 179 } \
bogdanm 86:04dd9b1680ae 180 else if((__HANDLE__)->Instance == USART3) \
bogdanm 86:04dd9b1680ae 181 { \
bogdanm 86:04dd9b1680ae 182 switch(__HAL_RCC_GET_USART3_SOURCE()) \
bogdanm 86:04dd9b1680ae 183 { \
bogdanm 86:04dd9b1680ae 184 case RCC_USART3CLKSOURCE_PCLK1: \
bogdanm 86:04dd9b1680ae 185 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
bogdanm 86:04dd9b1680ae 186 break; \
bogdanm 86:04dd9b1680ae 187 case RCC_USART3CLKSOURCE_HSI: \
bogdanm 86:04dd9b1680ae 188 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
bogdanm 86:04dd9b1680ae 189 break; \
bogdanm 86:04dd9b1680ae 190 case RCC_USART3CLKSOURCE_SYSCLK: \
bogdanm 86:04dd9b1680ae 191 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
bogdanm 86:04dd9b1680ae 192 break; \
bogdanm 86:04dd9b1680ae 193 case RCC_USART3CLKSOURCE_LSE: \
bogdanm 86:04dd9b1680ae 194 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
bogdanm 86:04dd9b1680ae 195 break; \
Kojto 122:f9eeca106725 196 default: \
Kojto 122:f9eeca106725 197 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 198 break; \
bogdanm 86:04dd9b1680ae 199 } \
bogdanm 86:04dd9b1680ae 200 } \
Kojto 122:f9eeca106725 201 else \
Kojto 122:f9eeca106725 202 { \
Kojto 122:f9eeca106725 203 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_UNDEFINED; \
Kojto 122:f9eeca106725 204 } \
bogdanm 86:04dd9b1680ae 205 } while(0)
bogdanm 92:4fc01daae5a5 206 #endif /* STM32F303x8 || STM32F334x8 || STM32F328xx */
bogdanm 86:04dd9b1680ae 207
Kojto 122:f9eeca106725 208 /** @brief Compute the USART mask to apply to retrieve the received data
bogdanm 86:04dd9b1680ae 209 * according to the word length and to the parity bits activation.
Kojto 122:f9eeca106725 210 * @note If PCE = 1, the parity bit is not included in the data extracted
bogdanm 86:04dd9b1680ae 211 * by the reception API().
bogdanm 86:04dd9b1680ae 212 * This masking operation is not carried out in the case of
Kojto 122:f9eeca106725 213 * DMA transfers.
Kojto 122:f9eeca106725 214 * @param __HANDLE__: specifies the USART Handle.
Kojto 122:f9eeca106725 215 * @retval None, the mask to apply to USART RDR register is stored in (__HANDLE__)->Mask field.
Kojto 122:f9eeca106725 216 */
bogdanm 92:4fc01daae5a5 217 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
bogdanm 92:4fc01daae5a5 218 defined(STM32F334x8) || \
bogdanm 92:4fc01daae5a5 219 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
Kojto 122:f9eeca106725 220 #define USART_MASK_COMPUTATION(__HANDLE__) \
bogdanm 86:04dd9b1680ae 221 do { \
bogdanm 86:04dd9b1680ae 222 if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_9B) \
bogdanm 86:04dd9b1680ae 223 { \
bogdanm 86:04dd9b1680ae 224 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
bogdanm 86:04dd9b1680ae 225 { \
bogdanm 86:04dd9b1680ae 226 (__HANDLE__)->Mask = 0x01FF ; \
bogdanm 86:04dd9b1680ae 227 } \
bogdanm 86:04dd9b1680ae 228 else \
bogdanm 86:04dd9b1680ae 229 { \
bogdanm 86:04dd9b1680ae 230 (__HANDLE__)->Mask = 0x00FF ; \
bogdanm 86:04dd9b1680ae 231 } \
bogdanm 86:04dd9b1680ae 232 } \
bogdanm 86:04dd9b1680ae 233 else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_8B) \
bogdanm 86:04dd9b1680ae 234 { \
bogdanm 86:04dd9b1680ae 235 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
bogdanm 86:04dd9b1680ae 236 { \
bogdanm 86:04dd9b1680ae 237 (__HANDLE__)->Mask = 0x00FF ; \
bogdanm 86:04dd9b1680ae 238 } \
bogdanm 86:04dd9b1680ae 239 else \
bogdanm 86:04dd9b1680ae 240 { \
bogdanm 86:04dd9b1680ae 241 (__HANDLE__)->Mask = 0x007F ; \
bogdanm 86:04dd9b1680ae 242 } \
bogdanm 86:04dd9b1680ae 243 } \
bogdanm 86:04dd9b1680ae 244 else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_7B) \
bogdanm 86:04dd9b1680ae 245 { \
bogdanm 86:04dd9b1680ae 246 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
bogdanm 86:04dd9b1680ae 247 { \
bogdanm 86:04dd9b1680ae 248 (__HANDLE__)->Mask = 0x007F ; \
bogdanm 86:04dd9b1680ae 249 } \
bogdanm 86:04dd9b1680ae 250 else \
bogdanm 86:04dd9b1680ae 251 { \
bogdanm 86:04dd9b1680ae 252 (__HANDLE__)->Mask = 0x003F ; \
bogdanm 86:04dd9b1680ae 253 } \
bogdanm 86:04dd9b1680ae 254 } \
Kojto 122:f9eeca106725 255 } while(0)
bogdanm 86:04dd9b1680ae 256 #else
Kojto 122:f9eeca106725 257 #define USART_MASK_COMPUTATION(__HANDLE__) \
bogdanm 86:04dd9b1680ae 258 do { \
bogdanm 86:04dd9b1680ae 259 if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_9B) \
bogdanm 86:04dd9b1680ae 260 { \
bogdanm 86:04dd9b1680ae 261 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
bogdanm 86:04dd9b1680ae 262 { \
bogdanm 86:04dd9b1680ae 263 (__HANDLE__)->Mask = 0x01FF ; \
bogdanm 86:04dd9b1680ae 264 } \
bogdanm 86:04dd9b1680ae 265 else \
bogdanm 86:04dd9b1680ae 266 { \
bogdanm 86:04dd9b1680ae 267 (__HANDLE__)->Mask = 0x00FF ; \
bogdanm 86:04dd9b1680ae 268 } \
bogdanm 86:04dd9b1680ae 269 } \
bogdanm 86:04dd9b1680ae 270 else if ((__HANDLE__)->Init.WordLength == USART_WORDLENGTH_8B) \
bogdanm 86:04dd9b1680ae 271 { \
bogdanm 86:04dd9b1680ae 272 if ((__HANDLE__)->Init.Parity == USART_PARITY_NONE) \
bogdanm 86:04dd9b1680ae 273 { \
bogdanm 86:04dd9b1680ae 274 (__HANDLE__)->Mask = 0x00FF ; \
bogdanm 86:04dd9b1680ae 275 } \
bogdanm 86:04dd9b1680ae 276 else \
bogdanm 86:04dd9b1680ae 277 { \
bogdanm 86:04dd9b1680ae 278 (__HANDLE__)->Mask = 0x007F ; \
bogdanm 86:04dd9b1680ae 279 } \
bogdanm 86:04dd9b1680ae 280 } \
Kojto 122:f9eeca106725 281 } while(0)
Kojto 122:f9eeca106725 282 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
Kojto 122:f9eeca106725 283 /* STM32F334x8 || */
Kojto 122:f9eeca106725 284 /* STM32F301x8 || STM32F302x8 || STM32F318xx */
Kojto 122:f9eeca106725 285
Kojto 122:f9eeca106725 286
Kojto 122:f9eeca106725 287 /**
Kojto 122:f9eeca106725 288 * @brief Ensure that USART frame length is valid.
Kojto 122:f9eeca106725 289 * @param __LENGTH__: USART frame length.
Kojto 122:f9eeca106725 290 * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid)
Kojto 122:f9eeca106725 291 */
Kojto 122:f9eeca106725 292 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
Kojto 122:f9eeca106725 293 defined(STM32F334x8) || \
Kojto 122:f9eeca106725 294 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
Kojto 122:f9eeca106725 295 #define IS_USART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == USART_WORDLENGTH_7B) || \
Kojto 122:f9eeca106725 296 ((__LENGTH__) == USART_WORDLENGTH_8B) || \
Kojto 122:f9eeca106725 297 ((__LENGTH__) == USART_WORDLENGTH_9B))
Kojto 122:f9eeca106725 298 #else
Kojto 122:f9eeca106725 299 #define IS_USART_WORD_LENGTH(__LENGTH__) (((__LENGTH__) == USART_WORDLENGTH_8B) || \
Kojto 122:f9eeca106725 300 ((__LENGTH__) == USART_WORDLENGTH_9B))
bogdanm 92:4fc01daae5a5 301 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
bogdanm 92:4fc01daae5a5 302 /* STM32F334x8 || */
bogdanm 92:4fc01daae5a5 303 /* STM32F301x8 || STM32F302x8 || STM32F318xx */
bogdanm 86:04dd9b1680ae 304 /**
bogdanm 86:04dd9b1680ae 305 * @}
bogdanm 86:04dd9b1680ae 306 */
bogdanm 86:04dd9b1680ae 307
bogdanm 86:04dd9b1680ae 308 /* Exported functions --------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 309 /* Initialization and de-initialization functions ****************************/
bogdanm 86:04dd9b1680ae 310 /* IO operation functions *****************************************************/
bogdanm 86:04dd9b1680ae 311 /* Peripheral Control functions ***********************************************/
bogdanm 86:04dd9b1680ae 312 /* Peripheral State and Error functions ***************************************/
bogdanm 86:04dd9b1680ae 313
bogdanm 86:04dd9b1680ae 314
bogdanm 86:04dd9b1680ae 315 /**
bogdanm 86:04dd9b1680ae 316 * @}
Kojto 122:f9eeca106725 317 */
bogdanm 86:04dd9b1680ae 318
bogdanm 86:04dd9b1680ae 319 /**
bogdanm 86:04dd9b1680ae 320 * @}
Kojto 122:f9eeca106725 321 */
Kojto 122:f9eeca106725 322
bogdanm 86:04dd9b1680ae 323 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 324 }
bogdanm 86:04dd9b1680ae 325 #endif
bogdanm 86:04dd9b1680ae 326
bogdanm 86:04dd9b1680ae 327 #endif /* __STM32F3xx_HAL_USART_EX_H */
bogdanm 86:04dd9b1680ae 328
bogdanm 86:04dd9b1680ae 329 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Kojto 122:f9eeca106725 330