I2C_EEPROM

Committer:
jhon309
Date:
Thu Aug 13 00:23:16 2015 +0000
Revision:
0:ac8863619623
I2C

Who changed what in which revision?

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