meh

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Mar 17 14:27:45 2015 +0000
Revision:
96:487b796308b0
Parent:
92:4fc01daae5a5
Release 96 of the mbed library

Changes:
- IAR support for ble boards, lpc, ethernet stack
- RTC - attach function to redirect time functions
- Nucleo F103RB - cube driver
- k20xx - fixes for teensy and k20 platforms in sleep/deepsleep and usb
- STM32L0, Nucleo/Disco L053 - refactoring

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 84:0b3ab51c8877 1 /**
bogdanm 84:0b3ab51c8877 2 ******************************************************************************
bogdanm 84:0b3ab51c8877 3 * @file stm32l0xx_hal_uart_ex.h
bogdanm 84:0b3ab51c8877 4 * @author MCD Application Team
Kojto 96:487b796308b0 5 * @version V1.2.0
Kojto 96:487b796308b0 6 * @date 06-February-2015
bogdanm 84:0b3ab51c8877 7 * @brief Header file of UART HAL Extension module.
bogdanm 84:0b3ab51c8877 8 ******************************************************************************
bogdanm 84:0b3ab51c8877 9 * @attention
bogdanm 84:0b3ab51c8877 10 *
Kojto 96:487b796308b0 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
bogdanm 84:0b3ab51c8877 12 *
bogdanm 84:0b3ab51c8877 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 84:0b3ab51c8877 14 * are permitted provided that the following conditions are met:
bogdanm 84:0b3ab51c8877 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 84:0b3ab51c8877 16 * this list of conditions and the following disclaimer.
bogdanm 84:0b3ab51c8877 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 84:0b3ab51c8877 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 84:0b3ab51c8877 19 * and/or other materials provided with the distribution.
bogdanm 84:0b3ab51c8877 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 84:0b3ab51c8877 21 * may be used to endorse or promote products derived from this software
bogdanm 84:0b3ab51c8877 22 * without specific prior written permission.
bogdanm 84:0b3ab51c8877 23 *
bogdanm 84:0b3ab51c8877 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 84:0b3ab51c8877 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 84:0b3ab51c8877 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 84:0b3ab51c8877 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 84:0b3ab51c8877 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 84:0b3ab51c8877 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 84:0b3ab51c8877 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 84:0b3ab51c8877 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 84:0b3ab51c8877 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 84:0b3ab51c8877 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 84:0b3ab51c8877 34 *
bogdanm 84:0b3ab51c8877 35 ******************************************************************************
bogdanm 84:0b3ab51c8877 36 */
bogdanm 84:0b3ab51c8877 37
bogdanm 84:0b3ab51c8877 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 84:0b3ab51c8877 39 #ifndef __STM32L0xx_HAL_UART_EX_H
bogdanm 84:0b3ab51c8877 40 #define __STM32L0xx_HAL_UART_EX_H
bogdanm 84:0b3ab51c8877 41
bogdanm 84:0b3ab51c8877 42 #ifdef __cplusplus
bogdanm 84:0b3ab51c8877 43 extern "C" {
bogdanm 84:0b3ab51c8877 44 #endif
bogdanm 84:0b3ab51c8877 45
bogdanm 84:0b3ab51c8877 46 /* Includes ------------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 47 #include "stm32l0xx_hal_def.h"
bogdanm 84:0b3ab51c8877 48
bogdanm 84:0b3ab51c8877 49 /** @addtogroup STM32L0xx_HAL_Driver
bogdanm 84:0b3ab51c8877 50 * @{
bogdanm 84:0b3ab51c8877 51 */
bogdanm 84:0b3ab51c8877 52
Kojto 96:487b796308b0 53 /** @defgroup UARTEx UARTEx Extended HAL module driver
bogdanm 84:0b3ab51c8877 54 * @{
bogdanm 84:0b3ab51c8877 55 */
bogdanm 84:0b3ab51c8877 56
Kojto 96:487b796308b0 57 /******************************************************************************/
bogdanm 84:0b3ab51c8877 58 /* Exported types ------------------------------------------------------------*/
Kojto 96:487b796308b0 59 /******************************************************************************/
Kojto 96:487b796308b0 60
Kojto 96:487b796308b0 61 /** @defgroup UARTEx_Exported_Types UARTEx Exported Types
Kojto 96:487b796308b0 62 * @{
Kojto 96:487b796308b0 63 */
Kojto 96:487b796308b0 64
Kojto 96:487b796308b0 65 /** @defgroup UARTEx_Init_Configuration Extended initialization configuration structure
Kojto 96:487b796308b0 66 * @{
Kojto 96:487b796308b0 67 */
bogdanm 84:0b3ab51c8877 68 /**
bogdanm 84:0b3ab51c8877 69 * @brief UART wake up from stop mode parameters
bogdanm 84:0b3ab51c8877 70 */
bogdanm 84:0b3ab51c8877 71 typedef struct
bogdanm 84:0b3ab51c8877 72 {
bogdanm 84:0b3ab51c8877 73 uint32_t WakeUpEvent; /*!< Specifies which event will activat the Wakeup from Stop mode flag (WUF).
bogdanm 92:4fc01daae5a5 74 This parameter can be a value of @ref UART_WakeUp_from_Stop_Selection.
bogdanm 84:0b3ab51c8877 75 If set to UART_WAKEUP_ON_ADDRESS, the two other fields below must
bogdanm 84:0b3ab51c8877 76 be filled up. */
bogdanm 84:0b3ab51c8877 77
bogdanm 84:0b3ab51c8877 78 uint16_t AddressLength; /*!< Specifies whether the address is 4 or 7-bit long.
bogdanm 84:0b3ab51c8877 79 This parameter can be a value of @ref UARTEx_WakeUp_Address_Length */
bogdanm 84:0b3ab51c8877 80
bogdanm 84:0b3ab51c8877 81 uint8_t Address; /*!< UART/USART node address (7-bit long max) */
bogdanm 84:0b3ab51c8877 82 } UART_WakeUpTypeDef;
bogdanm 84:0b3ab51c8877 83
Kojto 96:487b796308b0 84 /**
Kojto 96:487b796308b0 85 * @}
Kojto 96:487b796308b0 86 */
Kojto 96:487b796308b0 87 /**
Kojto 96:487b796308b0 88 * @}
Kojto 96:487b796308b0 89 */
Kojto 96:487b796308b0 90
bogdanm 84:0b3ab51c8877 91 /* Exported constants --------------------------------------------------------*/
Kojto 96:487b796308b0 92 /** @defgroup UARTEx_Extended_Exported_Constants UARTEx Exported Constants
bogdanm 84:0b3ab51c8877 93 * @{
bogdanm 84:0b3ab51c8877 94 */
bogdanm 84:0b3ab51c8877 95
Kojto 96:487b796308b0 96 /** @defgroup UARTEx_Word_Length Word length definition
bogdanm 84:0b3ab51c8877 97 * @{
bogdanm 84:0b3ab51c8877 98 */
bogdanm 84:0b3ab51c8877 99 #define UART_WORDLENGTH_7B ((uint32_t)USART_CR1_M_1)
bogdanm 84:0b3ab51c8877 100 #define UART_WORDLENGTH_8B ((uint32_t)0x0000)
bogdanm 84:0b3ab51c8877 101 #define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M_0)
bogdanm 84:0b3ab51c8877 102 #define IS_UART_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_7B) || \
bogdanm 84:0b3ab51c8877 103 ((LENGTH) == UART_WORDLENGTH_8B) || \
bogdanm 84:0b3ab51c8877 104 ((LENGTH) == UART_WORDLENGTH_9B))
bogdanm 84:0b3ab51c8877 105 /**
bogdanm 84:0b3ab51c8877 106 * @}
bogdanm 84:0b3ab51c8877 107 */
bogdanm 84:0b3ab51c8877 108
Kojto 96:487b796308b0 109 /** @defgroup UARTEx_AutoBaud_Rate_Mode Auto baud rate mode definition
bogdanm 84:0b3ab51c8877 110 * @{
bogdanm 84:0b3ab51c8877 111 */
bogdanm 84:0b3ab51c8877 112 #define UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT ((uint32_t)0x0000)
bogdanm 84:0b3ab51c8877 113 #define UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE ((uint32_t)USART_CR2_ABRMODE_0)
bogdanm 84:0b3ab51c8877 114 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME ((uint32_t)USART_CR2_ABRMODE_1)
bogdanm 84:0b3ab51c8877 115 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME ((uint32_t)USART_CR2_ABRMODE)
bogdanm 84:0b3ab51c8877 116 #define IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(MODE) (((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT) || \
bogdanm 84:0b3ab51c8877 117 ((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE) || \
bogdanm 84:0b3ab51c8877 118 ((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME) || \
bogdanm 84:0b3ab51c8877 119 ((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME))
bogdanm 84:0b3ab51c8877 120 /**
bogdanm 84:0b3ab51c8877 121 * @}
bogdanm 84:0b3ab51c8877 122 */
bogdanm 84:0b3ab51c8877 123
Kojto 96:487b796308b0 124 /** @defgroup UARTEx_WakeUp_Address_Length WakeUp address length definition
bogdanm 84:0b3ab51c8877 125 * @{
bogdanm 84:0b3ab51c8877 126 */
bogdanm 84:0b3ab51c8877 127 #define UART_ADDRESS_DETECT_4B ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 128 #define UART_ADDRESS_DETECT_7B ((uint32_t)USART_CR2_ADDM7)
bogdanm 84:0b3ab51c8877 129 #define IS_UART_ADDRESSLENGTH_DETECT(ADDRESS) (((ADDRESS) == UART_ADDRESS_DETECT_4B) || \
bogdanm 84:0b3ab51c8877 130 ((ADDRESS) == UART_ADDRESS_DETECT_7B))
bogdanm 84:0b3ab51c8877 131 /**
bogdanm 84:0b3ab51c8877 132 * @}
bogdanm 84:0b3ab51c8877 133 */
bogdanm 84:0b3ab51c8877 134
bogdanm 84:0b3ab51c8877 135
Kojto 96:487b796308b0 136 /** @defgroup UARTEx_WakeUp_Methods Wakeup methods definition
bogdanm 84:0b3ab51c8877 137 * @{
bogdanm 84:0b3ab51c8877 138 */
bogdanm 84:0b3ab51c8877 139 #define UART_WAKEUPMETHOD_IDLELINE ((uint32_t)0x00000000)
bogdanm 84:0b3ab51c8877 140 #define UART_WAKEUPMETHOD_ADDRESSMARK ((uint32_t)USART_CR1_WAKE)
bogdanm 84:0b3ab51c8877 141 #define IS_UART_WAKEUPMETHOD(WAKEUP) (((WAKEUP) == UART_WAKEUPMETHOD_IDLELINE) || \
bogdanm 84:0b3ab51c8877 142 ((WAKEUP) == UART_WAKEUPMETHOD_ADDRESSMARK))
bogdanm 84:0b3ab51c8877 143 /**
bogdanm 84:0b3ab51c8877 144 * @}
bogdanm 84:0b3ab51c8877 145 */
bogdanm 84:0b3ab51c8877 146
bogdanm 84:0b3ab51c8877 147 /**
bogdanm 84:0b3ab51c8877 148 * @}
bogdanm 84:0b3ab51c8877 149 */
bogdanm 84:0b3ab51c8877 150
bogdanm 84:0b3ab51c8877 151 /* Exported macro ------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 152
Kojto 96:487b796308b0 153 /** @defgroup UARTEx_Extended_Exported_Macros UARTEx Exported Macros
bogdanm 84:0b3ab51c8877 154 * @{
bogdanm 84:0b3ab51c8877 155 */
bogdanm 84:0b3ab51c8877 156
bogdanm 84:0b3ab51c8877 157 /** @brief Reports the UART clock source.
bogdanm 84:0b3ab51c8877 158 * @param __HANDLE__: specifies the UART Handle
bogdanm 84:0b3ab51c8877 159 * @param __CLOCKSOURCE__ : output variable
bogdanm 84:0b3ab51c8877 160 * @retval UART clocking source, written in __CLOCKSOURCE__.
bogdanm 84:0b3ab51c8877 161 */
Kojto 96:487b796308b0 162 #if defined (STM32L031xx) || defined (STM32L041xx)
Kojto 96:487b796308b0 163 #define UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 96:487b796308b0 164 do { \
Kojto 96:487b796308b0 165 if((__HANDLE__)->Instance == USART2) \
Kojto 96:487b796308b0 166 { \
Kojto 96:487b796308b0 167 switch(__HAL_RCC_GET_USART2_SOURCE()) \
Kojto 96:487b796308b0 168 { \
Kojto 96:487b796308b0 169 case RCC_USART2CLKSOURCE_PCLK1: \
Kojto 96:487b796308b0 170 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 96:487b796308b0 171 break; \
Kojto 96:487b796308b0 172 case RCC_USART2CLKSOURCE_HSI: \
Kojto 96:487b796308b0 173 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 96:487b796308b0 174 break; \
Kojto 96:487b796308b0 175 case RCC_USART2CLKSOURCE_SYSCLK: \
Kojto 96:487b796308b0 176 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 96:487b796308b0 177 break; \
Kojto 96:487b796308b0 178 case RCC_USART2CLKSOURCE_LSE: \
Kojto 96:487b796308b0 179 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 96:487b796308b0 180 break; \
Kojto 96:487b796308b0 181 default: \
Kojto 96:487b796308b0 182 break; \
Kojto 96:487b796308b0 183 } \
Kojto 96:487b796308b0 184 } \
Kojto 96:487b796308b0 185 else if((__HANDLE__)->Instance == LPUART1) \
Kojto 96:487b796308b0 186 { \
Kojto 96:487b796308b0 187 switch(__HAL_RCC_GET_LPUART1_SOURCE()) \
Kojto 96:487b796308b0 188 { \
Kojto 96:487b796308b0 189 case RCC_LPUART1CLKSOURCE_PCLK1: \
Kojto 96:487b796308b0 190 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 96:487b796308b0 191 break; \
Kojto 96:487b796308b0 192 case RCC_LPUART1CLKSOURCE_HSI: \
Kojto 96:487b796308b0 193 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 96:487b796308b0 194 break; \
Kojto 96:487b796308b0 195 case RCC_LPUART1CLKSOURCE_SYSCLK: \
Kojto 96:487b796308b0 196 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 96:487b796308b0 197 break; \
Kojto 96:487b796308b0 198 case RCC_LPUART1CLKSOURCE_LSE: \
Kojto 96:487b796308b0 199 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 96:487b796308b0 200 break; \
Kojto 96:487b796308b0 201 default: \
Kojto 96:487b796308b0 202 break; \
Kojto 96:487b796308b0 203 } \
Kojto 96:487b796308b0 204 } \
Kojto 96:487b796308b0 205 } while(0)
Kojto 96:487b796308b0 206
Kojto 96:487b796308b0 207 #else /* (STM32L031xx) || defined (STM32L041xx) */
Kojto 96:487b796308b0 208
Kojto 96:487b796308b0 209 #define UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
bogdanm 84:0b3ab51c8877 210 do { \
bogdanm 84:0b3ab51c8877 211 if((__HANDLE__)->Instance == USART1) \
bogdanm 84:0b3ab51c8877 212 { \
bogdanm 84:0b3ab51c8877 213 switch(__HAL_RCC_GET_USART1_SOURCE()) \
bogdanm 84:0b3ab51c8877 214 { \
bogdanm 84:0b3ab51c8877 215 case RCC_USART1CLKSOURCE_PCLK2: \
bogdanm 84:0b3ab51c8877 216 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK2; \
bogdanm 84:0b3ab51c8877 217 break; \
bogdanm 84:0b3ab51c8877 218 case RCC_USART1CLKSOURCE_HSI: \
bogdanm 84:0b3ab51c8877 219 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
bogdanm 84:0b3ab51c8877 220 break; \
bogdanm 84:0b3ab51c8877 221 case RCC_USART1CLKSOURCE_SYSCLK: \
bogdanm 84:0b3ab51c8877 222 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
bogdanm 84:0b3ab51c8877 223 break; \
bogdanm 84:0b3ab51c8877 224 case RCC_USART1CLKSOURCE_LSE: \
bogdanm 84:0b3ab51c8877 225 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
bogdanm 84:0b3ab51c8877 226 break; \
bogdanm 84:0b3ab51c8877 227 default: \
bogdanm 84:0b3ab51c8877 228 break; \
bogdanm 84:0b3ab51c8877 229 } \
bogdanm 84:0b3ab51c8877 230 } \
bogdanm 84:0b3ab51c8877 231 else if((__HANDLE__)->Instance == USART2) \
bogdanm 84:0b3ab51c8877 232 { \
bogdanm 84:0b3ab51c8877 233 switch(__HAL_RCC_GET_USART2_SOURCE()) \
bogdanm 84:0b3ab51c8877 234 { \
bogdanm 84:0b3ab51c8877 235 case RCC_USART2CLKSOURCE_PCLK1: \
bogdanm 84:0b3ab51c8877 236 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
bogdanm 84:0b3ab51c8877 237 break; \
bogdanm 84:0b3ab51c8877 238 case RCC_USART2CLKSOURCE_HSI: \
bogdanm 84:0b3ab51c8877 239 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
bogdanm 84:0b3ab51c8877 240 break; \
bogdanm 84:0b3ab51c8877 241 case RCC_USART2CLKSOURCE_SYSCLK: \
bogdanm 84:0b3ab51c8877 242 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
bogdanm 84:0b3ab51c8877 243 break; \
bogdanm 84:0b3ab51c8877 244 case RCC_USART2CLKSOURCE_LSE: \
bogdanm 84:0b3ab51c8877 245 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
bogdanm 84:0b3ab51c8877 246 break; \
bogdanm 84:0b3ab51c8877 247 default: \
bogdanm 84:0b3ab51c8877 248 break; \
bogdanm 84:0b3ab51c8877 249 } \
bogdanm 84:0b3ab51c8877 250 } \
bogdanm 84:0b3ab51c8877 251 else if((__HANDLE__)->Instance == LPUART1) \
bogdanm 84:0b3ab51c8877 252 { \
bogdanm 84:0b3ab51c8877 253 switch(__HAL_RCC_GET_LPUART1_SOURCE()) \
bogdanm 84:0b3ab51c8877 254 { \
bogdanm 84:0b3ab51c8877 255 case RCC_LPUART1CLKSOURCE_PCLK1: \
bogdanm 84:0b3ab51c8877 256 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
bogdanm 84:0b3ab51c8877 257 break; \
bogdanm 84:0b3ab51c8877 258 case RCC_LPUART1CLKSOURCE_HSI: \
bogdanm 84:0b3ab51c8877 259 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
bogdanm 84:0b3ab51c8877 260 break; \
bogdanm 84:0b3ab51c8877 261 case RCC_LPUART1CLKSOURCE_SYSCLK: \
bogdanm 84:0b3ab51c8877 262 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
bogdanm 84:0b3ab51c8877 263 break; \
bogdanm 84:0b3ab51c8877 264 case RCC_LPUART1CLKSOURCE_LSE: \
bogdanm 84:0b3ab51c8877 265 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
bogdanm 84:0b3ab51c8877 266 break; \
bogdanm 84:0b3ab51c8877 267 default: \
bogdanm 84:0b3ab51c8877 268 break; \
bogdanm 84:0b3ab51c8877 269 } \
bogdanm 84:0b3ab51c8877 270 } \
bogdanm 84:0b3ab51c8877 271 } while(0)
Kojto 96:487b796308b0 272 #endif /* (STM32L031xx) || (STM32L041xx) */
bogdanm 84:0b3ab51c8877 273
bogdanm 84:0b3ab51c8877 274 /** @brief Reports the UART mask to apply to retrieve the received data
bogdanm 84:0b3ab51c8877 275 * according to the word length and to the parity bits activation.
bogdanm 84:0b3ab51c8877 276 * If PCE = 1, the parity bit is not included in the data extracted
bogdanm 84:0b3ab51c8877 277 * by the reception API().
bogdanm 84:0b3ab51c8877 278 * This masking operation is not carried out in the case of
bogdanm 84:0b3ab51c8877 279 * DMA transfers.
bogdanm 84:0b3ab51c8877 280 * @param __HANDLE__: specifies the UART Handle
bogdanm 84:0b3ab51c8877 281 * @retval mask to apply to UART RDR register value.
bogdanm 84:0b3ab51c8877 282 */
Kojto 96:487b796308b0 283 #define UART_MASK_COMPUTATION(__HANDLE__) \
bogdanm 84:0b3ab51c8877 284 do { \
bogdanm 84:0b3ab51c8877 285 if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_9B) \
bogdanm 84:0b3ab51c8877 286 { \
bogdanm 84:0b3ab51c8877 287 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
bogdanm 84:0b3ab51c8877 288 { \
bogdanm 84:0b3ab51c8877 289 (__HANDLE__)->Mask = 0x01FF ; \
bogdanm 84:0b3ab51c8877 290 } \
bogdanm 84:0b3ab51c8877 291 else \
bogdanm 84:0b3ab51c8877 292 { \
bogdanm 84:0b3ab51c8877 293 (__HANDLE__)->Mask = 0x00FF ; \
bogdanm 84:0b3ab51c8877 294 } \
bogdanm 84:0b3ab51c8877 295 } \
bogdanm 84:0b3ab51c8877 296 else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_8B) \
bogdanm 84:0b3ab51c8877 297 { \
bogdanm 84:0b3ab51c8877 298 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
bogdanm 84:0b3ab51c8877 299 { \
bogdanm 84:0b3ab51c8877 300 (__HANDLE__)->Mask = 0x00FF ; \
bogdanm 84:0b3ab51c8877 301 } \
bogdanm 84:0b3ab51c8877 302 else \
bogdanm 84:0b3ab51c8877 303 { \
bogdanm 84:0b3ab51c8877 304 (__HANDLE__)->Mask = 0x007F ; \
bogdanm 84:0b3ab51c8877 305 } \
bogdanm 84:0b3ab51c8877 306 } \
bogdanm 84:0b3ab51c8877 307 else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_7B) \
bogdanm 84:0b3ab51c8877 308 { \
bogdanm 84:0b3ab51c8877 309 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
bogdanm 84:0b3ab51c8877 310 { \
bogdanm 84:0b3ab51c8877 311 (__HANDLE__)->Mask = 0x007F ; \
bogdanm 84:0b3ab51c8877 312 } \
bogdanm 84:0b3ab51c8877 313 else \
bogdanm 84:0b3ab51c8877 314 { \
bogdanm 84:0b3ab51c8877 315 (__HANDLE__)->Mask = 0x003F ; \
bogdanm 84:0b3ab51c8877 316 } \
bogdanm 84:0b3ab51c8877 317 } \
bogdanm 84:0b3ab51c8877 318 } while(0)
bogdanm 84:0b3ab51c8877 319
bogdanm 84:0b3ab51c8877 320 /**
bogdanm 84:0b3ab51c8877 321 * @}
bogdanm 84:0b3ab51c8877 322 */
bogdanm 84:0b3ab51c8877 323
bogdanm 84:0b3ab51c8877 324 /* Exported functions --------------------------------------------------------*/
Kojto 96:487b796308b0 325 /** @defgroup UARTEx_Exported_Functions UARTEx Exported Functions
Kojto 96:487b796308b0 326 * @{
Kojto 96:487b796308b0 327 */
Kojto 96:487b796308b0 328 /* Exported functions --------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 329 /* Initialization/de-initialization functions ********************************/
Kojto 96:487b796308b0 330 /** @defgroup UARTEx_Exported_Functions_Group1 Extended Initialization function
Kojto 96:487b796308b0 331 * @{
Kojto 96:487b796308b0 332 */
bogdanm 84:0b3ab51c8877 333 HAL_StatusTypeDef HAL_RS485Ex_Init(UART_HandleTypeDef *huart, uint32_t Polarity, uint32_t AssertionTime, uint32_t DeassertionTime);
Kojto 96:487b796308b0 334 /**
Kojto 96:487b796308b0 335 * @}
Kojto 96:487b796308b0 336 */
bogdanm 84:0b3ab51c8877 337 /* IO operation functions *****************************************************/
bogdanm 84:0b3ab51c8877 338 /* Peripheral Control functions **********************************************/
Kojto 96:487b796308b0 339 /** @defgroup UARTEx_Exported_Functions_Group2 Peripheral Control functions
Kojto 96:487b796308b0 340 * @{
Kojto 96:487b796308b0 341 */
bogdanm 84:0b3ab51c8877 342 HAL_StatusTypeDef HAL_UARTEx_StopModeWakeUpSourceConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection);
bogdanm 84:0b3ab51c8877 343 HAL_StatusTypeDef HAL_UARTEx_EnableStopMode(UART_HandleTypeDef *huart);
bogdanm 84:0b3ab51c8877 344 HAL_StatusTypeDef HAL_UARTEx_EnableClockStopMode(UART_HandleTypeDef *huart);
bogdanm 84:0b3ab51c8877 345 HAL_StatusTypeDef HAL_UARTEx_DisableStopMode(UART_HandleTypeDef *huart);
bogdanm 84:0b3ab51c8877 346 HAL_StatusTypeDef HAL_UARTEx_DisableClockStopMode(UART_HandleTypeDef *huart);
bogdanm 92:4fc01daae5a5 347 void HAL_UARTEx_WakeupCallback(UART_HandleTypeDef *huart);
bogdanm 84:0b3ab51c8877 348
bogdanm 84:0b3ab51c8877 349 /* Peripheral State functions ************************************************/
bogdanm 84:0b3ab51c8877 350 HAL_StatusTypeDef HAL_MultiProcessorEx_AddressLength_Set(UART_HandleTypeDef *huart, uint32_t AddressLength);
Kojto 96:487b796308b0 351 /**
Kojto 96:487b796308b0 352 * @}
Kojto 96:487b796308b0 353 */
Kojto 96:487b796308b0 354
Kojto 96:487b796308b0 355 /**
Kojto 96:487b796308b0 356 * @}
Kojto 96:487b796308b0 357 */
Kojto 96:487b796308b0 358
Kojto 96:487b796308b0 359 /**
Kojto 96:487b796308b0 360 * @}
Kojto 96:487b796308b0 361 */
bogdanm 84:0b3ab51c8877 362
bogdanm 84:0b3ab51c8877 363 /**
bogdanm 84:0b3ab51c8877 364 * @}
bogdanm 84:0b3ab51c8877 365 */
bogdanm 84:0b3ab51c8877 366
bogdanm 84:0b3ab51c8877 367 /**
bogdanm 84:0b3ab51c8877 368 * @}
bogdanm 84:0b3ab51c8877 369 */
bogdanm 84:0b3ab51c8877 370
bogdanm 84:0b3ab51c8877 371 #ifdef __cplusplus
bogdanm 84:0b3ab51c8877 372 }
bogdanm 84:0b3ab51c8877 373 #endif
bogdanm 84:0b3ab51c8877 374
bogdanm 84:0b3ab51c8877 375 #endif /* __STM32L0xx_HAL_UART_EX_H */
bogdanm 84:0b3ab51c8877 376
bogdanm 84:0b3ab51c8877 377 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Kojto 96:487b796308b0 378