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
Kojto 90:cb3d968589d8 1 /**
Kojto 90:cb3d968589d8 2 ******************************************************************************
Kojto 90:cb3d968589d8 3 * @file stm32f0xx_hal_uart_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 UART 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_UART_EX_H
Kojto 90:cb3d968589d8 40 #define __STM32F0xx_HAL_UART_EX_H
Kojto 90:cb3d968589d8 41
Kojto 90:cb3d968589d8 42 #ifdef __cplusplus
Kojto 90:cb3d968589d8 43 extern "C" {
Kojto 90:cb3d968589d8 44 #endif
Kojto 90:cb3d968589d8 45
Kojto 90:cb3d968589d8 46 /* Includes ------------------------------------------------------------------*/
Kojto 90:cb3d968589d8 47 #include "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 /** @addtogroup UARTEx
Kojto 90:cb3d968589d8 54 * @{
Kojto 90:cb3d968589d8 55 */
Kojto 90:cb3d968589d8 56
Kojto 90:cb3d968589d8 57 /* Exported types ------------------------------------------------------------*/
Kojto 93:e188a91d3eaa 58 #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
Kojto 93:e188a91d3eaa 59 /** @defgroup UARTEx_Exported_Types UARTEx Exported Types
Kojto 93:e188a91d3eaa 60 * @{
Kojto 93:e188a91d3eaa 61 */
Kojto 93:e188a91d3eaa 62
Kojto 93:e188a91d3eaa 63 /**
Kojto 93:e188a91d3eaa 64 * @brief UART wake up from stop mode parameters
Kojto 93:e188a91d3eaa 65 */
Kojto 93:e188a91d3eaa 66 typedef struct
Kojto 93:e188a91d3eaa 67 {
Kojto 93:e188a91d3eaa 68 uint32_t WakeUpEvent; /*!< Specifies which event will activat the Wakeup from Stop mode flag (WUF).
Kojto 93:e188a91d3eaa 69 This parameter can be a value of @ref UART_WakeUp_from_Stop_Selection.
Kojto 93:e188a91d3eaa 70 If set to UART_WAKEUP_ON_ADDRESS, the two other fields below must
Kojto 93:e188a91d3eaa 71 be filled up. */
Kojto 93:e188a91d3eaa 72
Kojto 93:e188a91d3eaa 73 uint16_t AddressLength; /*!< Specifies whether the address is 4 or 7-bit long.
Kojto 93:e188a91d3eaa 74 This parameter can be a value of @ref UART_WakeUp_Address_Length */
Kojto 93:e188a91d3eaa 75
Kojto 93:e188a91d3eaa 76 uint8_t Address; /*!< UART/USART node address (7-bit long max) */
Kojto 93:e188a91d3eaa 77 } UART_WakeUpTypeDef;
Kojto 93:e188a91d3eaa 78 /**
Kojto 93:e188a91d3eaa 79 * @}
Kojto 93:e188a91d3eaa 80 */
Kojto 93:e188a91d3eaa 81 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
Kojto 93:e188a91d3eaa 82
Kojto 90:cb3d968589d8 83 /* Exported constants --------------------------------------------------------*/
Kojto 90:cb3d968589d8 84 /** @defgroup UARTEx_Exported_Constants UARTEx Exported Constants
Kojto 90:cb3d968589d8 85 * @{
Kojto 90:cb3d968589d8 86 */
Kojto 90:cb3d968589d8 87
Kojto 90:cb3d968589d8 88 /** @defgroup UARTEx_Word_Length UARTEx Word Length
Kojto 90:cb3d968589d8 89 * @{
Kojto 90:cb3d968589d8 90 */
Kojto 93:e188a91d3eaa 91 #if defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \
Kojto 93:e188a91d3eaa 92 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \
Kojto 93:e188a91d3eaa 93 defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC)
Kojto 90:cb3d968589d8 94 #define UART_WORDLENGTH_7B ((uint32_t)USART_CR1_M1)
Kojto 90:cb3d968589d8 95 #define UART_WORDLENGTH_8B ((uint32_t)0x00000000)
Kojto 90:cb3d968589d8 96 #define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M0)
Kojto 90:cb3d968589d8 97 #define IS_UART_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_7B) || \
Kojto 90:cb3d968589d8 98 ((LENGTH) == UART_WORDLENGTH_8B) || \
Kojto 90:cb3d968589d8 99 ((LENGTH) == UART_WORDLENGTH_9B))
Kojto 90:cb3d968589d8 100 #else
Kojto 90:cb3d968589d8 101 #define UART_WORDLENGTH_8B ((uint32_t)0x00000000)
Kojto 90:cb3d968589d8 102 #define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
Kojto 90:cb3d968589d8 103 #define IS_UART_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B) || \
Kojto 90:cb3d968589d8 104 ((LENGTH) == UART_WORDLENGTH_9B))
Kojto 93:e188a91d3eaa 105 #endif /* defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \
Kojto 93:e188a91d3eaa 106 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \
Kojto 93:e188a91d3eaa 107 defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) */
Kojto 90:cb3d968589d8 108 /**
Kojto 90:cb3d968589d8 109 * @}
Kojto 90:cb3d968589d8 110 */
Kojto 90:cb3d968589d8 111
Kojto 90:cb3d968589d8 112 /** @defgroup UARTEx_AutoBaud_Rate_Mode UARTEx Advanced Feature AutoBaud Rate Mode
Kojto 90:cb3d968589d8 113 * @{
Kojto 90:cb3d968589d8 114 */
Kojto 93:e188a91d3eaa 115 #if defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \
Kojto 93:e188a91d3eaa 116 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \
Kojto 93:e188a91d3eaa 117 defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC)
Kojto 90:cb3d968589d8 118 #define UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT ((uint32_t)0x0000)
Kojto 90:cb3d968589d8 119 #define UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE ((uint32_t)USART_CR2_ABRMODE_0)
Kojto 90:cb3d968589d8 120 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME ((uint32_t)USART_CR2_ABRMODE_1)
Kojto 90:cb3d968589d8 121 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME ((uint32_t)USART_CR2_ABRMODE)
Kojto 90:cb3d968589d8 122 #define IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(MODE) (((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT) || \
Kojto 90:cb3d968589d8 123 ((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE) || \
Kojto 90:cb3d968589d8 124 ((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME) || \
Kojto 90:cb3d968589d8 125 ((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME))
Kojto 90:cb3d968589d8 126 #else
Kojto 90:cb3d968589d8 127 #define UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT ((uint32_t)0x0000)
Kojto 90:cb3d968589d8 128 #define UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE ((uint32_t)USART_CR2_ABRMODE_0)
Kojto 90:cb3d968589d8 129 #define IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(MODE) (((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT) || \
Kojto 90:cb3d968589d8 130 ((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE))
Kojto 93:e188a91d3eaa 131 #endif /* defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \
Kojto 93:e188a91d3eaa 132 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \
Kojto 93:e188a91d3eaa 133 defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) */
Kojto 90:cb3d968589d8 134 /**
Kojto 90:cb3d968589d8 135 * @}
Kojto 90:cb3d968589d8 136 */
Kojto 90:cb3d968589d8 137
Kojto 90:cb3d968589d8 138
Kojto 93:e188a91d3eaa 139 #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
Kojto 90:cb3d968589d8 140 /** @defgroup UARTEx_LIN UARTEx Local Interconnection Network mode
Kojto 90:cb3d968589d8 141 * @{
Kojto 90:cb3d968589d8 142 */
Kojto 90:cb3d968589d8 143 #define UART_LIN_DISABLE ((uint32_t)0x00000000)
Kojto 90:cb3d968589d8 144 #define UART_LIN_ENABLE ((uint32_t)USART_CR2_LINEN)
Kojto 90:cb3d968589d8 145 #define IS_UART_LIN(LIN) (((LIN) == UART_LIN_DISABLE) || \
Kojto 90:cb3d968589d8 146 ((LIN) == UART_LIN_ENABLE))
Kojto 90:cb3d968589d8 147 /**
Kojto 90:cb3d968589d8 148 * @}
Kojto 90:cb3d968589d8 149 */
Kojto 90:cb3d968589d8 150
Kojto 90:cb3d968589d8 151 /** @defgroup UARTEx_LIN_Break_Detection UARTEx LIN Break Detection
Kojto 90:cb3d968589d8 152 * @{
Kojto 90:cb3d968589d8 153 */
Kojto 90:cb3d968589d8 154 #define UART_LINBREAKDETECTLENGTH_10B ((uint32_t)0x00000000)
Kojto 90:cb3d968589d8 155 #define UART_LINBREAKDETECTLENGTH_11B ((uint32_t)USART_CR2_LBDL)
Kojto 90:cb3d968589d8 156 #define IS_UART_LIN_BREAK_DETECT_LENGTH(LENGTH) (((LENGTH) == UART_LINBREAKDETECTLENGTH_10B) || \
Kojto 90:cb3d968589d8 157 ((LENGTH) == UART_LINBREAKDETECTLENGTH_11B))
Kojto 90:cb3d968589d8 158 /**
Kojto 90:cb3d968589d8 159 * @}
Kojto 90:cb3d968589d8 160 */
Kojto 93:e188a91d3eaa 161 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
Kojto 90:cb3d968589d8 162
Kojto 90:cb3d968589d8 163 /** @defgroup UART_Flags UARTEx Status Flags
Kojto 90:cb3d968589d8 164 * Elements values convention: 0xXXXX
Kojto 90:cb3d968589d8 165 * - 0xXXXX : Flag mask in the ISR register
Kojto 90:cb3d968589d8 166 * @{
Kojto 90:cb3d968589d8 167 */
Kojto 90:cb3d968589d8 168 #define UART_FLAG_REACK ((uint32_t)0x00400000)
Kojto 90:cb3d968589d8 169 #define UART_FLAG_TEACK ((uint32_t)0x00200000)
Kojto 93:e188a91d3eaa 170 #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
Kojto 90:cb3d968589d8 171 #define UART_FLAG_WUF ((uint32_t)0x00100000)
Kojto 93:e188a91d3eaa 172 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
Kojto 90:cb3d968589d8 173 #define UART_FLAG_RWU ((uint32_t)0x00080000)
Kojto 90:cb3d968589d8 174 #define UART_FLAG_SBKF ((uint32_t)0x00040000
Kojto 90:cb3d968589d8 175 #define UART_FLAG_CMF ((uint32_t)0x00020000)
Kojto 90:cb3d968589d8 176 #define UART_FLAG_BUSY ((uint32_t)0x00010000)
Kojto 90:cb3d968589d8 177 #define UART_FLAG_ABRF ((uint32_t)0x00008000)
Kojto 90:cb3d968589d8 178 #define UART_FLAG_ABRE ((uint32_t)0x00004000)
Kojto 93:e188a91d3eaa 179 #if !defined(STM32F030x6) && !defined(STM32F030x8)
Kojto 90:cb3d968589d8 180 #define UART_FLAG_EOBF ((uint32_t)0x00001000)
Kojto 90:cb3d968589d8 181 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) */
Kojto 90:cb3d968589d8 182 #define UART_FLAG_RTOF ((uint32_t)0x00000800)
Kojto 90:cb3d968589d8 183 #define UART_FLAG_CTS ((uint32_t)0x00000400)
Kojto 90:cb3d968589d8 184 #define UART_FLAG_CTSIF ((uint32_t)0x00000200)
Kojto 93:e188a91d3eaa 185 #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
Kojto 90:cb3d968589d8 186 #define UART_FLAG_LBDF ((uint32_t)0x00000100)
Kojto 93:e188a91d3eaa 187 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
Kojto 90:cb3d968589d8 188 #define UART_FLAG_TXE ((uint32_t)0x00000080)
Kojto 90:cb3d968589d8 189 #define UART_FLAG_TC ((uint32_t)0x00000040)
Kojto 90:cb3d968589d8 190 #define UART_FLAG_RXNE ((uint32_t)0x00000020)
Kojto 90:cb3d968589d8 191 #define UART_FLAG_IDLE ((uint32_t)0x00000010)
Kojto 90:cb3d968589d8 192 #define UART_FLAG_ORE ((uint32_t)0x00000008)
Kojto 90:cb3d968589d8 193 #define UART_FLAG_NE ((uint32_t)0x00000004)
Kojto 90:cb3d968589d8 194 #define UART_FLAG_FE ((uint32_t)0x00000002)
Kojto 90:cb3d968589d8 195 #define UART_FLAG_PE ((uint32_t)0x00000001)
Kojto 90:cb3d968589d8 196 /**
Kojto 90:cb3d968589d8 197 * @}
Kojto 90:cb3d968589d8 198 */
Kojto 90:cb3d968589d8 199
Kojto 90:cb3d968589d8 200 /** @defgroup UART_Interrupt_definition UARTEx Interrupts Definition
Kojto 93:e188a91d3eaa 201 * Elements values convention: 0000ZZZZZ0XXYYYYYb
Kojto 90:cb3d968589d8 202 * - YYYYY : Interrupt source position in the XX register (5bits)
Kojto 90:cb3d968589d8 203 * - XX : Interrupt source register (2bits)
Kojto 90:cb3d968589d8 204 * - 01: CR1 register
Kojto 90:cb3d968589d8 205 * - 10: CR2 register
Kojto 90:cb3d968589d8 206 * - 11: CR3 register
Kojto 93:e188a91d3eaa 207 * - ZZZZZ : Flag position in the ISR register(5bits)
Kojto 90:cb3d968589d8 208 * @{
Kojto 90:cb3d968589d8 209 */
Kojto 90:cb3d968589d8 210 #define UART_IT_PE ((uint16_t)0x0028)
Kojto 90:cb3d968589d8 211 #define UART_IT_TXE ((uint16_t)0x0727)
Kojto 90:cb3d968589d8 212 #define UART_IT_TC ((uint16_t)0x0626)
Kojto 90:cb3d968589d8 213 #define UART_IT_RXNE ((uint16_t)0x0525)
Kojto 90:cb3d968589d8 214 #define UART_IT_IDLE ((uint16_t)0x0424)
Kojto 93:e188a91d3eaa 215 #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
Kojto 90:cb3d968589d8 216 #define UART_IT_LBD ((uint16_t)0x0846)
Kojto 93:e188a91d3eaa 217 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
Kojto 90:cb3d968589d8 218 #define UART_IT_CTS ((uint16_t)0x096A)
Kojto 93:e188a91d3eaa 219 #define UART_IT_CM ((uint16_t)0x112E)
Kojto 93:e188a91d3eaa 220 #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
Kojto 90:cb3d968589d8 221 #define UART_IT_WUF ((uint16_t)0x1476)
Kojto 93:e188a91d3eaa 222 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
Kojto 90:cb3d968589d8 223 /**
Kojto 90:cb3d968589d8 224 * @}
Kojto 90:cb3d968589d8 225 */
Kojto 90:cb3d968589d8 226
Kojto 90:cb3d968589d8 227
Kojto 90:cb3d968589d8 228 /** @defgroup UART_IT_CLEAR_Flags UARTEx Interruption Clear Flags
Kojto 90:cb3d968589d8 229 * @{
Kojto 90:cb3d968589d8 230 */
Kojto 90:cb3d968589d8 231 #define UART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
Kojto 90:cb3d968589d8 232 #define UART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
Kojto 90:cb3d968589d8 233 #define UART_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
Kojto 90:cb3d968589d8 234 #define UART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
Kojto 90:cb3d968589d8 235 #define UART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */
Kojto 90:cb3d968589d8 236 #define UART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
Kojto 93:e188a91d3eaa 237 #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
Kojto 90:cb3d968589d8 238 #define UART_CLEAR_LBDF USART_ICR_LBDCF /*!< LIN Break Detection Clear Flag (not available on F030xx devices)*/
Kojto 93:e188a91d3eaa 239 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
Kojto 90:cb3d968589d8 240 #define UART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */
Kojto 90:cb3d968589d8 241 #define UART_CLEAR_RTOF USART_ICR_RTOCF /*!< Receiver Time Out Clear Flag */
Kojto 90:cb3d968589d8 242 #define UART_CLEAR_EOBF USART_ICR_EOBCF /*!< End Of Block Clear Flag */
Kojto 90:cb3d968589d8 243 #define UART_CLEAR_CMF USART_ICR_CMCF /*!< Character Match Clear Flag */
Kojto 93:e188a91d3eaa 244 #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
Kojto 90:cb3d968589d8 245 #define UART_CLEAR_WUF USART_ICR_WUCF /*!< Wake Up from stop mode Clear Flag */
Kojto 93:e188a91d3eaa 246 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
Kojto 90:cb3d968589d8 247 /**
Kojto 90:cb3d968589d8 248 * @}
Kojto 90:cb3d968589d8 249 */
Kojto 90:cb3d968589d8 250
Kojto 90:cb3d968589d8 251 /** @defgroup UART_Request_Parameters UARTEx Request Parameters
Kojto 90:cb3d968589d8 252 * @{
Kojto 90:cb3d968589d8 253 */
Kojto 90:cb3d968589d8 254 #define UART_AUTOBAUD_REQUEST ((uint32_t)USART_RQR_ABRRQ) /*!< Auto-Baud Rate Request */
Kojto 90:cb3d968589d8 255 #define UART_SENDBREAK_REQUEST ((uint32_t)USART_RQR_SBKRQ) /*!< Send Break Request */
Kojto 90:cb3d968589d8 256 #define UART_MUTE_MODE_REQUEST ((uint32_t)USART_RQR_MMRQ) /*!< Mute Mode Request */
Kojto 90:cb3d968589d8 257 #define UART_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
Kojto 90:cb3d968589d8 258 #if !defined(STM32F030x6) && !defined(STM32F030x8)
Kojto 90:cb3d968589d8 259 #define UART_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
Kojto 90:cb3d968589d8 260 #define IS_UART_REQUEST_PARAMETER(PARAM) (((PARAM) == UART_AUTOBAUD_REQUEST) || \
Kojto 90:cb3d968589d8 261 ((PARAM) == UART_SENDBREAK_REQUEST) || \
Kojto 90:cb3d968589d8 262 ((PARAM) == UART_MUTE_MODE_REQUEST) || \
Kojto 90:cb3d968589d8 263 ((PARAM) == UART_RXDATA_FLUSH_REQUEST) || \
Kojto 90:cb3d968589d8 264 ((PARAM) == UART_TXDATA_FLUSH_REQUEST))
Kojto 90:cb3d968589d8 265 #else
Kojto 90:cb3d968589d8 266 #define IS_UART_REQUEST_PARAMETER(PARAM) (((PARAM) == UART_AUTOBAUD_REQUEST) || \
Kojto 90:cb3d968589d8 267 ((PARAM) == UART_SENDBREAK_REQUEST) || \
Kojto 90:cb3d968589d8 268 ((PARAM) == UART_MUTE_MODE_REQUEST) || \
Kojto 90:cb3d968589d8 269 ((PARAM) == UART_RXDATA_FLUSH_REQUEST))
Kojto 90:cb3d968589d8 270 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) */
Kojto 90:cb3d968589d8 271 /**
Kojto 90:cb3d968589d8 272 * @}
Kojto 90:cb3d968589d8 273 */
Kojto 90:cb3d968589d8 274
Kojto 93:e188a91d3eaa 275 #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
Kojto 90:cb3d968589d8 276 /** @defgroup UART_Stop_Mode_Enable UARTEx Advanced Feature Stop Mode Enable
Kojto 90:cb3d968589d8 277 * @{
Kojto 90:cb3d968589d8 278 */
Kojto 90:cb3d968589d8 279 #define UART_ADVFEATURE_STOPMODE_DISABLE ((uint32_t)0x00000000)
Kojto 90:cb3d968589d8 280 #define UART_ADVFEATURE_STOPMODE_ENABLE ((uint32_t)USART_CR1_UESM)
Kojto 90:cb3d968589d8 281 #define IS_UART_ADVFEATURE_STOPMODE(STOPMODE) (((STOPMODE) == UART_ADVFEATURE_STOPMODE_DISABLE) || \
Kojto 90:cb3d968589d8 282 ((STOPMODE) == UART_ADVFEATURE_STOPMODE_ENABLE))
Kojto 90:cb3d968589d8 283 /**
Kojto 90:cb3d968589d8 284 * @}
Kojto 90:cb3d968589d8 285 */
Kojto 90:cb3d968589d8 286
Kojto 90:cb3d968589d8 287 /** @defgroup UART_WakeUp_from_Stop_Selection UART WakeUp From Stop Selection
Kojto 90:cb3d968589d8 288 * @{
Kojto 90:cb3d968589d8 289 */
Kojto 90:cb3d968589d8 290 #define UART_WAKEUP_ON_ADDRESS ((uint32_t)0x0000)
Kojto 90:cb3d968589d8 291 #define UART_WAKEUP_ON_STARTBIT ((uint32_t)USART_CR3_WUS_1)
Kojto 90:cb3d968589d8 292 #define UART_WAKEUP_ON_READDATA_NONEMPTY ((uint32_t)USART_CR3_WUS)
Kojto 90:cb3d968589d8 293 #define IS_UART_WAKEUP_SELECTION(WAKE) (((WAKE) == UART_WAKEUP_ON_ADDRESS) || \
Kojto 90:cb3d968589d8 294 ((WAKE) == UART_WAKEUP_ON_STARTBIT) || \
Kojto 90:cb3d968589d8 295 ((WAKE) == UART_WAKEUP_ON_READDATA_NONEMPTY))
Kojto 90:cb3d968589d8 296 /**
Kojto 90:cb3d968589d8 297 * @}
Kojto 90:cb3d968589d8 298 */
Kojto 93:e188a91d3eaa 299 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
Kojto 90:cb3d968589d8 300
Kojto 90:cb3d968589d8 301 /**
Kojto 90:cb3d968589d8 302 * @}
Kojto 90:cb3d968589d8 303 */
Kojto 90:cb3d968589d8 304
Kojto 90:cb3d968589d8 305 /* Exported macro ------------------------------------------------------------*/
Kojto 90:cb3d968589d8 306
Kojto 90:cb3d968589d8 307 /** @defgroup UARTEx_Exported_Macros UARTEx Exported Macros
Kojto 90:cb3d968589d8 308 * @{
Kojto 90:cb3d968589d8 309 */
Kojto 90:cb3d968589d8 310
Kojto 90:cb3d968589d8 311 /** @brief Reports the UART clock source.
Kojto 90:cb3d968589d8 312 * @param __HANDLE__: specifies the UART Handle
Kojto 90:cb3d968589d8 313 * @param __CLOCKSOURCE__ : output variable
Kojto 90:cb3d968589d8 314 * @retval UART clocking source, written in __CLOCKSOURCE__.
Kojto 90:cb3d968589d8 315 */
Kojto 90:cb3d968589d8 316
Kojto 90:cb3d968589d8 317
Kojto 90:cb3d968589d8 318 #if defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F038xx)
Kojto 90:cb3d968589d8 319 #define __HAL_UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 90:cb3d968589d8 320 do { \
Kojto 90:cb3d968589d8 321 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 90:cb3d968589d8 322 { \
Kojto 90:cb3d968589d8 323 case RCC_USART1CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 324 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 325 break; \
Kojto 90:cb3d968589d8 326 case RCC_USART1CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 327 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 328 break; \
Kojto 90:cb3d968589d8 329 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 330 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 331 break; \
Kojto 90:cb3d968589d8 332 case RCC_USART1CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 333 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 334 break; \
Kojto 90:cb3d968589d8 335 default: \
Kojto 90:cb3d968589d8 336 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 337 break; \
Kojto 90:cb3d968589d8 338 } \
Kojto 90:cb3d968589d8 339 } while(0)
Kojto 93:e188a91d3eaa 340 #elif defined (STM32F030x8) || defined (STM32F070x6) || \
Kojto 90:cb3d968589d8 341 defined (STM32F042x6) || defined (STM32F048xx) || \
Kojto 90:cb3d968589d8 342 defined (STM32F051x8) || defined (STM32F058xx)
Kojto 90:cb3d968589d8 343 #define __HAL_UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 90:cb3d968589d8 344 do { \
Kojto 90:cb3d968589d8 345 if((__HANDLE__)->Instance == USART1) \
Kojto 90:cb3d968589d8 346 { \
Kojto 90:cb3d968589d8 347 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 90:cb3d968589d8 348 { \
Kojto 90:cb3d968589d8 349 case RCC_USART1CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 350 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 351 break; \
Kojto 90:cb3d968589d8 352 case RCC_USART1CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 353 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 354 break; \
Kojto 90:cb3d968589d8 355 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 356 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 357 break; \
Kojto 90:cb3d968589d8 358 case RCC_USART1CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 359 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 360 break; \
Kojto 90:cb3d968589d8 361 default: \
Kojto 90:cb3d968589d8 362 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 363 break; \
Kojto 90:cb3d968589d8 364 } \
Kojto 90:cb3d968589d8 365 } \
Kojto 90:cb3d968589d8 366 else if((__HANDLE__)->Instance == USART2) \
Kojto 90:cb3d968589d8 367 { \
Kojto 90:cb3d968589d8 368 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 369 } \
Kojto 90:cb3d968589d8 370 else \
Kojto 90:cb3d968589d8 371 { \
Kojto 90:cb3d968589d8 372 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 373 } \
Kojto 90:cb3d968589d8 374 } while(0)
Kojto 93:e188a91d3eaa 375 #elif defined(STM32F070xB)
Kojto 93:e188a91d3eaa 376 #define __HAL_UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 93:e188a91d3eaa 377 do { \
Kojto 93:e188a91d3eaa 378 if((__HANDLE__)->Instance == USART1) \
Kojto 93:e188a91d3eaa 379 { \
Kojto 93:e188a91d3eaa 380 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 93:e188a91d3eaa 381 { \
Kojto 93:e188a91d3eaa 382 case RCC_USART1CLKSOURCE_PCLK1: \
Kojto 93:e188a91d3eaa 383 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 93:e188a91d3eaa 384 break; \
Kojto 93:e188a91d3eaa 385 case RCC_USART1CLKSOURCE_HSI: \
Kojto 93:e188a91d3eaa 386 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 93:e188a91d3eaa 387 break; \
Kojto 93:e188a91d3eaa 388 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 93:e188a91d3eaa 389 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 93:e188a91d3eaa 390 break; \
Kojto 93:e188a91d3eaa 391 case RCC_USART1CLKSOURCE_LSE: \
Kojto 93:e188a91d3eaa 392 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 93:e188a91d3eaa 393 break; \
Kojto 93:e188a91d3eaa 394 default: \
Kojto 93:e188a91d3eaa 395 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 93:e188a91d3eaa 396 break; \
Kojto 93:e188a91d3eaa 397 } \
Kojto 93:e188a91d3eaa 398 } \
Kojto 93:e188a91d3eaa 399 else if((__HANDLE__)->Instance == USART2) \
Kojto 93:e188a91d3eaa 400 { \
Kojto 93:e188a91d3eaa 401 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 93:e188a91d3eaa 402 } \
Kojto 93:e188a91d3eaa 403 else if((__HANDLE__)->Instance == USART3) \
Kojto 93:e188a91d3eaa 404 { \
Kojto 93:e188a91d3eaa 405 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 93:e188a91d3eaa 406 } \
Kojto 93:e188a91d3eaa 407 else if((__HANDLE__)->Instance == USART4) \
Kojto 93:e188a91d3eaa 408 { \
Kojto 93:e188a91d3eaa 409 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 93:e188a91d3eaa 410 } \
Kojto 93:e188a91d3eaa 411 else \
Kojto 93:e188a91d3eaa 412 { \
Kojto 93:e188a91d3eaa 413 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 93:e188a91d3eaa 414 } \
Kojto 93:e188a91d3eaa 415 } while(0)
Kojto 90:cb3d968589d8 416 #elif defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)
Kojto 90:cb3d968589d8 417 #define __HAL_UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 90:cb3d968589d8 418 do { \
Kojto 90:cb3d968589d8 419 if((__HANDLE__)->Instance == USART1) \
Kojto 90:cb3d968589d8 420 { \
Kojto 90:cb3d968589d8 421 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 90:cb3d968589d8 422 { \
Kojto 90:cb3d968589d8 423 case RCC_USART1CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 424 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 425 break; \
Kojto 90:cb3d968589d8 426 case RCC_USART1CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 427 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 428 break; \
Kojto 90:cb3d968589d8 429 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 430 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 431 break; \
Kojto 90:cb3d968589d8 432 case RCC_USART1CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 433 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 434 break; \
Kojto 90:cb3d968589d8 435 default: \
Kojto 90:cb3d968589d8 436 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 437 break; \
Kojto 90:cb3d968589d8 438 } \
Kojto 90:cb3d968589d8 439 } \
Kojto 90:cb3d968589d8 440 else if((__HANDLE__)->Instance == USART2) \
Kojto 90:cb3d968589d8 441 { \
Kojto 90:cb3d968589d8 442 switch(__HAL_RCC_GET_USART2_SOURCE()) \
Kojto 90:cb3d968589d8 443 { \
Kojto 90:cb3d968589d8 444 case RCC_USART2CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 445 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 446 break; \
Kojto 90:cb3d968589d8 447 case RCC_USART2CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 448 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 449 break; \
Kojto 90:cb3d968589d8 450 case RCC_USART2CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 451 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 452 break; \
Kojto 90:cb3d968589d8 453 case RCC_USART2CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 454 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 455 break; \
Kojto 90:cb3d968589d8 456 default: \
Kojto 90:cb3d968589d8 457 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 458 break; \
Kojto 90:cb3d968589d8 459 } \
Kojto 90:cb3d968589d8 460 } \
Kojto 90:cb3d968589d8 461 else if((__HANDLE__)->Instance == USART3) \
Kojto 90:cb3d968589d8 462 { \
Kojto 90:cb3d968589d8 463 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 464 } \
Kojto 90:cb3d968589d8 465 else if((__HANDLE__)->Instance == USART4) \
Kojto 90:cb3d968589d8 466 { \
Kojto 90:cb3d968589d8 467 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 468 } \
Kojto 90:cb3d968589d8 469 else \
Kojto 90:cb3d968589d8 470 { \
Kojto 90:cb3d968589d8 471 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 472 } \
Kojto 90:cb3d968589d8 473 } while(0)
Kojto 90:cb3d968589d8 474 #elif defined(STM32F091xC) || defined (STM32F098xx)
Kojto 90:cb3d968589d8 475 #define __HAL_UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 90:cb3d968589d8 476 do { \
Kojto 90:cb3d968589d8 477 if((__HANDLE__)->Instance == USART1) \
Kojto 90:cb3d968589d8 478 { \
Kojto 90:cb3d968589d8 479 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 90:cb3d968589d8 480 { \
Kojto 90:cb3d968589d8 481 case RCC_USART1CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 482 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 483 break; \
Kojto 90:cb3d968589d8 484 case RCC_USART1CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 485 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 486 break; \
Kojto 90:cb3d968589d8 487 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 488 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 489 break; \
Kojto 90:cb3d968589d8 490 case RCC_USART1CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 491 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 492 break; \
Kojto 90:cb3d968589d8 493 default: \
Kojto 90:cb3d968589d8 494 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 495 break; \
Kojto 90:cb3d968589d8 496 } \
Kojto 90:cb3d968589d8 497 } \
Kojto 90:cb3d968589d8 498 else if((__HANDLE__)->Instance == USART2) \
Kojto 90:cb3d968589d8 499 { \
Kojto 90:cb3d968589d8 500 switch(__HAL_RCC_GET_USART2_SOURCE()) \
Kojto 90:cb3d968589d8 501 { \
Kojto 90:cb3d968589d8 502 case RCC_USART2CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 503 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 504 break; \
Kojto 90:cb3d968589d8 505 case RCC_USART2CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 506 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 507 break; \
Kojto 90:cb3d968589d8 508 case RCC_USART2CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 509 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 510 break; \
Kojto 90:cb3d968589d8 511 case RCC_USART2CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 512 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 513 break; \
Kojto 90:cb3d968589d8 514 default: \
Kojto 90:cb3d968589d8 515 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 516 break; \
Kojto 90:cb3d968589d8 517 } \
Kojto 90:cb3d968589d8 518 } \
Kojto 90:cb3d968589d8 519 else if((__HANDLE__)->Instance == USART3) \
Kojto 90:cb3d968589d8 520 { \
Kojto 90:cb3d968589d8 521 switch(__HAL_RCC_GET_USART3_SOURCE()) \
Kojto 90:cb3d968589d8 522 { \
Kojto 90:cb3d968589d8 523 case RCC_USART3CLKSOURCE_PCLK1: \
Kojto 90:cb3d968589d8 524 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 525 break; \
Kojto 90:cb3d968589d8 526 case RCC_USART3CLKSOURCE_HSI: \
Kojto 90:cb3d968589d8 527 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 90:cb3d968589d8 528 break; \
Kojto 90:cb3d968589d8 529 case RCC_USART3CLKSOURCE_SYSCLK: \
Kojto 90:cb3d968589d8 530 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 90:cb3d968589d8 531 break; \
Kojto 90:cb3d968589d8 532 case RCC_USART3CLKSOURCE_LSE: \
Kojto 90:cb3d968589d8 533 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 90:cb3d968589d8 534 break; \
Kojto 90:cb3d968589d8 535 default: \
Kojto 90:cb3d968589d8 536 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 537 break; \
Kojto 90:cb3d968589d8 538 } \
Kojto 90:cb3d968589d8 539 } \
Kojto 90:cb3d968589d8 540 else if((__HANDLE__)->Instance == USART4) \
Kojto 90:cb3d968589d8 541 { \
Kojto 90:cb3d968589d8 542 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 543 } \
Kojto 90:cb3d968589d8 544 else if((__HANDLE__)->Instance == USART5) \
Kojto 90:cb3d968589d8 545 { \
Kojto 90:cb3d968589d8 546 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 547 } \
Kojto 90:cb3d968589d8 548 else if((__HANDLE__)->Instance == USART6) \
Kojto 90:cb3d968589d8 549 { \
Kojto 90:cb3d968589d8 550 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 551 } \
Kojto 90:cb3d968589d8 552 else if((__HANDLE__)->Instance == USART7) \
Kojto 90:cb3d968589d8 553 { \
Kojto 90:cb3d968589d8 554 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 555 } \
Kojto 90:cb3d968589d8 556 else if((__HANDLE__)->Instance == USART8) \
Kojto 90:cb3d968589d8 557 { \
Kojto 90:cb3d968589d8 558 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 90:cb3d968589d8 559 } \
Kojto 90:cb3d968589d8 560 else \
Kojto 90:cb3d968589d8 561 { \
Kojto 90:cb3d968589d8 562 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 90:cb3d968589d8 563 } \
Kojto 90:cb3d968589d8 564 } while(0)
Kojto 93:e188a91d3eaa 565 #elif defined(STM32F030xC)
Kojto 93:e188a91d3eaa 566 #define __HAL_UART_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
Kojto 93:e188a91d3eaa 567 do { \
Kojto 93:e188a91d3eaa 568 if((__HANDLE__)->Instance == USART1) \
Kojto 93:e188a91d3eaa 569 { \
Kojto 93:e188a91d3eaa 570 switch(__HAL_RCC_GET_USART1_SOURCE()) \
Kojto 93:e188a91d3eaa 571 { \
Kojto 93:e188a91d3eaa 572 case RCC_USART1CLKSOURCE_PCLK1: \
Kojto 93:e188a91d3eaa 573 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 93:e188a91d3eaa 574 break; \
Kojto 93:e188a91d3eaa 575 case RCC_USART1CLKSOURCE_HSI: \
Kojto 93:e188a91d3eaa 576 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_HSI; \
Kojto 93:e188a91d3eaa 577 break; \
Kojto 93:e188a91d3eaa 578 case RCC_USART1CLKSOURCE_SYSCLK: \
Kojto 93:e188a91d3eaa 579 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_SYSCLK; \
Kojto 93:e188a91d3eaa 580 break; \
Kojto 93:e188a91d3eaa 581 case RCC_USART1CLKSOURCE_LSE: \
Kojto 93:e188a91d3eaa 582 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_LSE; \
Kojto 93:e188a91d3eaa 583 break; \
Kojto 93:e188a91d3eaa 584 default: \
Kojto 93:e188a91d3eaa 585 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 93:e188a91d3eaa 586 break; \
Kojto 93:e188a91d3eaa 587 } \
Kojto 93:e188a91d3eaa 588 } \
Kojto 93:e188a91d3eaa 589 else if((__HANDLE__)->Instance == USART2) \
Kojto 93:e188a91d3eaa 590 { \
Kojto 93:e188a91d3eaa 591 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 93:e188a91d3eaa 592 } \
Kojto 93:e188a91d3eaa 593 else if((__HANDLE__)->Instance == USART3) \
Kojto 93:e188a91d3eaa 594 { \
Kojto 93:e188a91d3eaa 595 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 93:e188a91d3eaa 596 } \
Kojto 93:e188a91d3eaa 597 else if((__HANDLE__)->Instance == USART4) \
Kojto 93:e188a91d3eaa 598 { \
Kojto 93:e188a91d3eaa 599 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 93:e188a91d3eaa 600 } \
Kojto 93:e188a91d3eaa 601 else if((__HANDLE__)->Instance == USART5) \
Kojto 93:e188a91d3eaa 602 { \
Kojto 93:e188a91d3eaa 603 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 93:e188a91d3eaa 604 } \
Kojto 93:e188a91d3eaa 605 else if((__HANDLE__)->Instance == USART6) \
Kojto 93:e188a91d3eaa 606 { \
Kojto 93:e188a91d3eaa 607 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_PCLK1; \
Kojto 93:e188a91d3eaa 608 } \
Kojto 93:e188a91d3eaa 609 else \
Kojto 93:e188a91d3eaa 610 { \
Kojto 93:e188a91d3eaa 611 (__CLOCKSOURCE__) = UART_CLOCKSOURCE_UNDEFINED; \
Kojto 93:e188a91d3eaa 612 } \
Kojto 93:e188a91d3eaa 613 } while(0)
Kojto 90:cb3d968589d8 614
Kojto 90:cb3d968589d8 615 #endif /* defined(STM32F030x6) || defined(STM32F031x6) || defined(STM32F038xx) */
Kojto 90:cb3d968589d8 616
Kojto 90:cb3d968589d8 617
Kojto 90:cb3d968589d8 618 /** @brief Computes the UART mask to apply to retrieve the received data
Kojto 90:cb3d968589d8 619 * according to the word length and to the parity bits activation.
Kojto 90:cb3d968589d8 620 * If PCE = 1, the parity bit is not included in the data extracted
Kojto 90:cb3d968589d8 621 * by the reception API().
Kojto 90:cb3d968589d8 622 * This masking operation is not carried out in the case of
Kojto 90:cb3d968589d8 623 * DMA transfers.
Kojto 90:cb3d968589d8 624 * @param __HANDLE__: specifies the UART Handle
Kojto 90:cb3d968589d8 625 * @retval none
Kojto 90:cb3d968589d8 626 */
Kojto 93:e188a91d3eaa 627 #if defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \
Kojto 93:e188a91d3eaa 628 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \
Kojto 93:e188a91d3eaa 629 defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC)
Kojto 90:cb3d968589d8 630 #define __HAL_UART_MASK_COMPUTATION(__HANDLE__) \
Kojto 90:cb3d968589d8 631 do { \
Kojto 90:cb3d968589d8 632 if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_9B) \
Kojto 90:cb3d968589d8 633 { \
Kojto 90:cb3d968589d8 634 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
Kojto 90:cb3d968589d8 635 { \
Kojto 90:cb3d968589d8 636 (__HANDLE__)->Mask = 0x01FF ; \
Kojto 90:cb3d968589d8 637 } \
Kojto 90:cb3d968589d8 638 else \
Kojto 90:cb3d968589d8 639 { \
Kojto 90:cb3d968589d8 640 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 90:cb3d968589d8 641 } \
Kojto 90:cb3d968589d8 642 } \
Kojto 90:cb3d968589d8 643 else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_8B) \
Kojto 90:cb3d968589d8 644 { \
Kojto 90:cb3d968589d8 645 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
Kojto 90:cb3d968589d8 646 { \
Kojto 90:cb3d968589d8 647 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 90:cb3d968589d8 648 } \
Kojto 90:cb3d968589d8 649 else \
Kojto 90:cb3d968589d8 650 { \
Kojto 90:cb3d968589d8 651 (__HANDLE__)->Mask = 0x007F ; \
Kojto 90:cb3d968589d8 652 } \
Kojto 90:cb3d968589d8 653 } \
Kojto 90:cb3d968589d8 654 else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_7B) \
Kojto 90:cb3d968589d8 655 { \
Kojto 90:cb3d968589d8 656 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
Kojto 90:cb3d968589d8 657 { \
Kojto 90:cb3d968589d8 658 (__HANDLE__)->Mask = 0x007F ; \
Kojto 90:cb3d968589d8 659 } \
Kojto 90:cb3d968589d8 660 else \
Kojto 90:cb3d968589d8 661 { \
Kojto 90:cb3d968589d8 662 (__HANDLE__)->Mask = 0x003F ; \
Kojto 90:cb3d968589d8 663 } \
Kojto 90:cb3d968589d8 664 } \
Kojto 90:cb3d968589d8 665 } while(0)
Kojto 90:cb3d968589d8 666 #else
Kojto 90:cb3d968589d8 667 #define __HAL_UART_MASK_COMPUTATION(__HANDLE__) \
Kojto 90:cb3d968589d8 668 do { \
Kojto 90:cb3d968589d8 669 if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_9B) \
Kojto 90:cb3d968589d8 670 { \
Kojto 90:cb3d968589d8 671 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
Kojto 90:cb3d968589d8 672 { \
Kojto 90:cb3d968589d8 673 (__HANDLE__)->Mask = 0x01FF ; \
Kojto 90:cb3d968589d8 674 } \
Kojto 90:cb3d968589d8 675 else \
Kojto 90:cb3d968589d8 676 { \
Kojto 90:cb3d968589d8 677 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 90:cb3d968589d8 678 } \
Kojto 90:cb3d968589d8 679 } \
Kojto 90:cb3d968589d8 680 else if ((__HANDLE__)->Init.WordLength == UART_WORDLENGTH_8B) \
Kojto 90:cb3d968589d8 681 { \
Kojto 90:cb3d968589d8 682 if ((__HANDLE__)->Init.Parity == UART_PARITY_NONE) \
Kojto 90:cb3d968589d8 683 { \
Kojto 90:cb3d968589d8 684 (__HANDLE__)->Mask = 0x00FF ; \
Kojto 90:cb3d968589d8 685 } \
Kojto 90:cb3d968589d8 686 else \
Kojto 90:cb3d968589d8 687 { \
Kojto 90:cb3d968589d8 688 (__HANDLE__)->Mask = 0x007F ; \
Kojto 90:cb3d968589d8 689 } \
Kojto 90:cb3d968589d8 690 } \
Kojto 90:cb3d968589d8 691 } while(0)
Kojto 93:e188a91d3eaa 692 #endif /* defined (STM32F042x6) || defined (STM32F048xx) || defined (STM32F070x6) || \
Kojto 93:e188a91d3eaa 693 defined (STM32F071xB) || defined (STM32F072xB) || defined (STM32F078xx) || defined (STM32F070xB) || \
Kojto 93:e188a91d3eaa 694 defined (STM32F091xC) || defined (STM32F098xx) || defined (STM32F030xC) */
Kojto 90:cb3d968589d8 695 /**
Kojto 90:cb3d968589d8 696 * @}
Kojto 90:cb3d968589d8 697 */
Kojto 90:cb3d968589d8 698
Kojto 90:cb3d968589d8 699 /* Exported functions --------------------------------------------------------*/
Kojto 90:cb3d968589d8 700 /** @addtogroup UARTEx_Exported_Functions
Kojto 90:cb3d968589d8 701 * @{
Kojto 90:cb3d968589d8 702 */
Kojto 90:cb3d968589d8 703
Kojto 90:cb3d968589d8 704 /** @addtogroup UARTEx_Exported_Functions_Group1
Kojto 90:cb3d968589d8 705 * @brief Extended Initialization and Configuration Functions
Kojto 90:cb3d968589d8 706 * @{
Kojto 90:cb3d968589d8 707 */
Kojto 90:cb3d968589d8 708 /* Initialization and de-initialization functions ****************************/
Kojto 93:e188a91d3eaa 709 #if !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC)
Kojto 90:cb3d968589d8 710 HAL_StatusTypeDef HAL_RS485Ex_Init(UART_HandleTypeDef *huart, uint32_t UART_DEPolarity, uint32_t UART_DEAssertionTime, uint32_t UART_DEDeassertionTime);
Kojto 90:cb3d968589d8 711 HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength);
Kojto 93:e188a91d3eaa 712 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC) */
Kojto 90:cb3d968589d8 713 /**
Kojto 90:cb3d968589d8 714 * @}
Kojto 90:cb3d968589d8 715 */
Kojto 90:cb3d968589d8 716
Kojto 90:cb3d968589d8 717 /** @addtogroup UARTEx_Exported_Functions_Group2
Kojto 93:e188a91d3eaa 718 * @brief Extended UART Interrupt handling function
Kojto 90:cb3d968589d8 719 * @{
Kojto 90:cb3d968589d8 720 */
Kojto 90:cb3d968589d8 721
Kojto 93:e188a91d3eaa 722 /* IO operation functions ***************************************************/
Kojto 90:cb3d968589d8 723 void HAL_UART_IRQHandler(UART_HandleTypeDef *huart);
Kojto 93:e188a91d3eaa 724
Kojto 93:e188a91d3eaa 725 #if !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC)
Kojto 90:cb3d968589d8 726 void HAL_UART_WakeupCallback(UART_HandleTypeDef *huart);
Kojto 93:e188a91d3eaa 727 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC) */
Kojto 90:cb3d968589d8 728 /**
Kojto 90:cb3d968589d8 729 * @}
Kojto 90:cb3d968589d8 730 */
Kojto 90:cb3d968589d8 731
Kojto 90:cb3d968589d8 732 /** @addtogroup UARTEx_Exported_Functions_Group3
Kojto 90:cb3d968589d8 733 * @brief Extended Peripheral Control functions
Kojto 90:cb3d968589d8 734 * @{
Kojto 90:cb3d968589d8 735 */
Kojto 90:cb3d968589d8 736
Kojto 90:cb3d968589d8 737 /* Peripheral Control functions **********************************************/
Kojto 90:cb3d968589d8 738 HAL_StatusTypeDef HAL_MultiProcessorEx_AddressLength_Set(UART_HandleTypeDef *huart, uint32_t AddressLength);
Kojto 93:e188a91d3eaa 739 #if !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6) && !defined(STM32F030xC)
Kojto 93:e188a91d3eaa 740 HAL_StatusTypeDef HAL_UARTEx_StopModeWakeUpSourceConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection);
Kojto 93:e188a91d3eaa 741 HAL_StatusTypeDef HAL_UARTEx_EnableStopMode(UART_HandleTypeDef *huart);
Kojto 93:e188a91d3eaa 742 HAL_StatusTypeDef HAL_UARTEx_DisableStopMode(UART_HandleTypeDef *huart);
Kojto 90:cb3d968589d8 743 HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart);
Kojto 93:e188a91d3eaa 744 #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070xB)&& !defined(STM32F070x6)&& !defined(STM32F030xC) */
Kojto 90:cb3d968589d8 745 /**
Kojto 90:cb3d968589d8 746 * @}
Kojto 90:cb3d968589d8 747 */
Kojto 90:cb3d968589d8 748 /* Peripheral State functions ************************************************/
Kojto 90:cb3d968589d8 749
Kojto 90:cb3d968589d8 750 /**
Kojto 90:cb3d968589d8 751 * @}
Kojto 90:cb3d968589d8 752 */
Kojto 90:cb3d968589d8 753
Kojto 90:cb3d968589d8 754
Kojto 90:cb3d968589d8 755 /**
Kojto 90:cb3d968589d8 756 * @}
Kojto 90:cb3d968589d8 757 */
Kojto 90:cb3d968589d8 758
Kojto 90:cb3d968589d8 759 /**
Kojto 90:cb3d968589d8 760 * @}
Kojto 90:cb3d968589d8 761 */
Kojto 90:cb3d968589d8 762
Kojto 90:cb3d968589d8 763 #ifdef __cplusplus
Kojto 90:cb3d968589d8 764 }
Kojto 90:cb3d968589d8 765 #endif
Kojto 90:cb3d968589d8 766
Kojto 90:cb3d968589d8 767 #endif /* __STM32F0xx_HAL_UART_EX_H */
Kojto 90:cb3d968589d8 768
Kojto 90:cb3d968589d8 769 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Kojto 90:cb3d968589d8 770