inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
NYX 0:85b3fd62ea1a 1 /**
NYX 0:85b3fd62ea1a 2 ******************************************************************************
NYX 0:85b3fd62ea1a 3 * @file stm32f4xx_hal_uart.h
NYX 0:85b3fd62ea1a 4 * @author MCD Application Team
NYX 0:85b3fd62ea1a 5 * @version V1.7.1
NYX 0:85b3fd62ea1a 6 * @date 14-April-2017
NYX 0:85b3fd62ea1a 7 * @brief Header file of UART HAL module.
NYX 0:85b3fd62ea1a 8 ******************************************************************************
NYX 0:85b3fd62ea1a 9 * @attention
NYX 0:85b3fd62ea1a 10 *
NYX 0:85b3fd62ea1a 11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
NYX 0:85b3fd62ea1a 12 *
NYX 0:85b3fd62ea1a 13 * Redistribution and use in source and binary forms, with or without modification,
NYX 0:85b3fd62ea1a 14 * are permitted provided that the following conditions are met:
NYX 0:85b3fd62ea1a 15 * 1. Redistributions of source code must retain the above copyright notice,
NYX 0:85b3fd62ea1a 16 * this list of conditions and the following disclaimer.
NYX 0:85b3fd62ea1a 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
NYX 0:85b3fd62ea1a 18 * this list of conditions and the following disclaimer in the documentation
NYX 0:85b3fd62ea1a 19 * and/or other materials provided with the distribution.
NYX 0:85b3fd62ea1a 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
NYX 0:85b3fd62ea1a 21 * may be used to endorse or promote products derived from this software
NYX 0:85b3fd62ea1a 22 * without specific prior written permission.
NYX 0:85b3fd62ea1a 23 *
NYX 0:85b3fd62ea1a 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
NYX 0:85b3fd62ea1a 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
NYX 0:85b3fd62ea1a 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
NYX 0:85b3fd62ea1a 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
NYX 0:85b3fd62ea1a 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
NYX 0:85b3fd62ea1a 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
NYX 0:85b3fd62ea1a 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
NYX 0:85b3fd62ea1a 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
NYX 0:85b3fd62ea1a 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
NYX 0:85b3fd62ea1a 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NYX 0:85b3fd62ea1a 34 *
NYX 0:85b3fd62ea1a 35 ******************************************************************************
NYX 0:85b3fd62ea1a 36 */
NYX 0:85b3fd62ea1a 37
NYX 0:85b3fd62ea1a 38 /* Define to prevent recursive inclusion -------------------------------------*/
NYX 0:85b3fd62ea1a 39 #ifndef __STM32F4xx_HAL_UART_H
NYX 0:85b3fd62ea1a 40 #define __STM32F4xx_HAL_UART_H
NYX 0:85b3fd62ea1a 41
NYX 0:85b3fd62ea1a 42 #ifdef __cplusplus
NYX 0:85b3fd62ea1a 43 extern "C" {
NYX 0:85b3fd62ea1a 44 #endif
NYX 0:85b3fd62ea1a 45
NYX 0:85b3fd62ea1a 46 /* Includes ------------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 47 #include "stm32f4xx_hal_def.h"
NYX 0:85b3fd62ea1a 48
NYX 0:85b3fd62ea1a 49 /** @addtogroup STM32F4xx_HAL_Driver
NYX 0:85b3fd62ea1a 50 * @{
NYX 0:85b3fd62ea1a 51 */
NYX 0:85b3fd62ea1a 52
NYX 0:85b3fd62ea1a 53 /** @addtogroup UART
NYX 0:85b3fd62ea1a 54 * @{
NYX 0:85b3fd62ea1a 55 */
NYX 0:85b3fd62ea1a 56
NYX 0:85b3fd62ea1a 57 /* Exported types ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 58 /** @defgroup UART_Exported_Types UART Exported Types
NYX 0:85b3fd62ea1a 59 * @{
NYX 0:85b3fd62ea1a 60 */
NYX 0:85b3fd62ea1a 61
NYX 0:85b3fd62ea1a 62 /**
NYX 0:85b3fd62ea1a 63 * @brief UART Init Structure definition
NYX 0:85b3fd62ea1a 64 */
NYX 0:85b3fd62ea1a 65 typedef struct
NYX 0:85b3fd62ea1a 66 {
NYX 0:85b3fd62ea1a 67 uint32_t BaudRate; /*!< This member configures the UART communication baud rate.
NYX 0:85b3fd62ea1a 68 The baud rate is computed using the following formula:
NYX 0:85b3fd62ea1a 69 - IntegerDivider = ((PCLKx) / (8 * (OVR8+1) * (huart->Init.BaudRate)))
NYX 0:85b3fd62ea1a 70 - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8 * (OVR8+1)) + 0.5
NYX 0:85b3fd62ea1a 71 Where OVR8 is the "oversampling by 8 mode" configuration bit in the CR1 register. */
NYX 0:85b3fd62ea1a 72
NYX 0:85b3fd62ea1a 73 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
NYX 0:85b3fd62ea1a 74 This parameter can be a value of @ref UART_Word_Length */
NYX 0:85b3fd62ea1a 75
NYX 0:85b3fd62ea1a 76 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
NYX 0:85b3fd62ea1a 77 This parameter can be a value of @ref UART_Stop_Bits */
NYX 0:85b3fd62ea1a 78
NYX 0:85b3fd62ea1a 79 uint32_t Parity; /*!< Specifies the parity mode.
NYX 0:85b3fd62ea1a 80 This parameter can be a value of @ref UART_Parity
NYX 0:85b3fd62ea1a 81 @note When parity is enabled, the computed parity is inserted
NYX 0:85b3fd62ea1a 82 at the MSB position of the transmitted data (9th bit when
NYX 0:85b3fd62ea1a 83 the word length is set to 9 data bits; 8th bit when the
NYX 0:85b3fd62ea1a 84 word length is set to 8 data bits). */
NYX 0:85b3fd62ea1a 85
NYX 0:85b3fd62ea1a 86 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
NYX 0:85b3fd62ea1a 87 This parameter can be a value of @ref UART_Mode */
NYX 0:85b3fd62ea1a 88
NYX 0:85b3fd62ea1a 89 uint32_t HwFlowCtl; /*!< Specifies whether the hardware flow control mode is enabled
NYX 0:85b3fd62ea1a 90 or disabled.
NYX 0:85b3fd62ea1a 91 This parameter can be a value of @ref UART_Hardware_Flow_Control */
NYX 0:85b3fd62ea1a 92
NYX 0:85b3fd62ea1a 93 uint32_t OverSampling; /*!< Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to fPCLK/8).
NYX 0:85b3fd62ea1a 94 This parameter can be a value of @ref UART_Over_Sampling */
NYX 0:85b3fd62ea1a 95 }UART_InitTypeDef;
NYX 0:85b3fd62ea1a 96
NYX 0:85b3fd62ea1a 97 /**
NYX 0:85b3fd62ea1a 98 * @brief HAL UART State structures definition
NYX 0:85b3fd62ea1a 99 * @note HAL UART State value is a combination of 2 different substates: gState and RxState.
NYX 0:85b3fd62ea1a 100 * - gState contains UART state information related to global Handle management
NYX 0:85b3fd62ea1a 101 * and also information related to Tx operations.
NYX 0:85b3fd62ea1a 102 * gState value coding follow below described bitmap :
NYX 0:85b3fd62ea1a 103 * b7-b6 Error information
NYX 0:85b3fd62ea1a 104 * 00 : No Error
NYX 0:85b3fd62ea1a 105 * 01 : (Not Used)
NYX 0:85b3fd62ea1a 106 * 10 : Timeout
NYX 0:85b3fd62ea1a 107 * 11 : Error
NYX 0:85b3fd62ea1a 108 * b5 IP initilisation status
NYX 0:85b3fd62ea1a 109 * 0 : Reset (IP not initialized)
NYX 0:85b3fd62ea1a 110 * 1 : Init done (IP not initialized. HAL UART Init function already called)
NYX 0:85b3fd62ea1a 111 * b4-b3 (not used)
NYX 0:85b3fd62ea1a 112 * xx : Should be set to 00
NYX 0:85b3fd62ea1a 113 * b2 Intrinsic process state
NYX 0:85b3fd62ea1a 114 * 0 : Ready
NYX 0:85b3fd62ea1a 115 * 1 : Busy (IP busy with some configuration or internal operations)
NYX 0:85b3fd62ea1a 116 * b1 (not used)
NYX 0:85b3fd62ea1a 117 * x : Should be set to 0
NYX 0:85b3fd62ea1a 118 * b0 Tx state
NYX 0:85b3fd62ea1a 119 * 0 : Ready (no Tx operation ongoing)
NYX 0:85b3fd62ea1a 120 * 1 : Busy (Tx operation ongoing)
NYX 0:85b3fd62ea1a 121 * - RxState contains information related to Rx operations.
NYX 0:85b3fd62ea1a 122 * RxState value coding follow below described bitmap :
NYX 0:85b3fd62ea1a 123 * b7-b6 (not used)
NYX 0:85b3fd62ea1a 124 * xx : Should be set to 00
NYX 0:85b3fd62ea1a 125 * b5 IP initilisation status
NYX 0:85b3fd62ea1a 126 * 0 : Reset (IP not initialized)
NYX 0:85b3fd62ea1a 127 * 1 : Init done (IP not initialized)
NYX 0:85b3fd62ea1a 128 * b4-b2 (not used)
NYX 0:85b3fd62ea1a 129 * xxx : Should be set to 000
NYX 0:85b3fd62ea1a 130 * b1 Rx state
NYX 0:85b3fd62ea1a 131 * 0 : Ready (no Rx operation ongoing)
NYX 0:85b3fd62ea1a 132 * 1 : Busy (Rx operation ongoing)
NYX 0:85b3fd62ea1a 133 * b0 (not used)
NYX 0:85b3fd62ea1a 134 * x : Should be set to 0.
NYX 0:85b3fd62ea1a 135 */
NYX 0:85b3fd62ea1a 136 typedef enum
NYX 0:85b3fd62ea1a 137 {
NYX 0:85b3fd62ea1a 138 HAL_UART_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized
NYX 0:85b3fd62ea1a 139 Value is allowed for gState and RxState */
NYX 0:85b3fd62ea1a 140 HAL_UART_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use
NYX 0:85b3fd62ea1a 141 Value is allowed for gState and RxState */
NYX 0:85b3fd62ea1a 142 HAL_UART_STATE_BUSY = 0x24U, /*!< an internal process is ongoing
NYX 0:85b3fd62ea1a 143 Value is allowed for gState only */
NYX 0:85b3fd62ea1a 144 HAL_UART_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing
NYX 0:85b3fd62ea1a 145 Value is allowed for gState only */
NYX 0:85b3fd62ea1a 146 HAL_UART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing
NYX 0:85b3fd62ea1a 147 Value is allowed for RxState only */
NYX 0:85b3fd62ea1a 148 HAL_UART_STATE_BUSY_TX_RX = 0x23U, /*!< Data Transmission and Reception process is ongoing
NYX 0:85b3fd62ea1a 149 Not to be used for neither gState nor RxState.
NYX 0:85b3fd62ea1a 150 Value is result of combination (Or) between gState and RxState values */
NYX 0:85b3fd62ea1a 151 HAL_UART_STATE_TIMEOUT = 0xA0U, /*!< Timeout state
NYX 0:85b3fd62ea1a 152 Value is allowed for gState only */
NYX 0:85b3fd62ea1a 153 HAL_UART_STATE_ERROR = 0xE0U /*!< Error
NYX 0:85b3fd62ea1a 154 Value is allowed for gState only */
NYX 0:85b3fd62ea1a 155 }HAL_UART_StateTypeDef;
NYX 0:85b3fd62ea1a 156
NYX 0:85b3fd62ea1a 157 /**
NYX 0:85b3fd62ea1a 158 * @brief UART handle Structure definition
NYX 0:85b3fd62ea1a 159 */
NYX 0:85b3fd62ea1a 160 typedef struct
NYX 0:85b3fd62ea1a 161 {
NYX 0:85b3fd62ea1a 162 USART_TypeDef *Instance; /*!< UART registers base address */
NYX 0:85b3fd62ea1a 163
NYX 0:85b3fd62ea1a 164 UART_InitTypeDef Init; /*!< UART communication parameters */
NYX 0:85b3fd62ea1a 165
NYX 0:85b3fd62ea1a 166 uint8_t *pTxBuffPtr; /*!< Pointer to UART Tx transfer Buffer */
NYX 0:85b3fd62ea1a 167
NYX 0:85b3fd62ea1a 168 uint16_t TxXferSize; /*!< UART Tx Transfer size */
NYX 0:85b3fd62ea1a 169
NYX 0:85b3fd62ea1a 170 __IO uint16_t TxXferCount; /*!< UART Tx Transfer Counter */
NYX 0:85b3fd62ea1a 171
NYX 0:85b3fd62ea1a 172 uint8_t *pRxBuffPtr; /*!< Pointer to UART Rx transfer Buffer */
NYX 0:85b3fd62ea1a 173
NYX 0:85b3fd62ea1a 174 uint16_t RxXferSize; /*!< UART Rx Transfer size */
NYX 0:85b3fd62ea1a 175
NYX 0:85b3fd62ea1a 176 __IO uint16_t RxXferCount; /*!< UART Rx Transfer Counter */
NYX 0:85b3fd62ea1a 177
NYX 0:85b3fd62ea1a 178 DMA_HandleTypeDef *hdmatx; /*!< UART Tx DMA Handle parameters */
NYX 0:85b3fd62ea1a 179
NYX 0:85b3fd62ea1a 180 DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */
NYX 0:85b3fd62ea1a 181
NYX 0:85b3fd62ea1a 182 HAL_LockTypeDef Lock; /*!< Locking object */
NYX 0:85b3fd62ea1a 183
NYX 0:85b3fd62ea1a 184 __IO HAL_UART_StateTypeDef gState; /*!< UART state information related to global Handle management
NYX 0:85b3fd62ea1a 185 and also related to Tx operations.
NYX 0:85b3fd62ea1a 186 This parameter can be a value of @ref HAL_UART_StateTypeDef */
NYX 0:85b3fd62ea1a 187
NYX 0:85b3fd62ea1a 188 __IO HAL_UART_StateTypeDef RxState; /*!< UART state information related to Rx operations.
NYX 0:85b3fd62ea1a 189 This parameter can be a value of @ref HAL_UART_StateTypeDef */
NYX 0:85b3fd62ea1a 190
NYX 0:85b3fd62ea1a 191 __IO uint32_t ErrorCode; /*!< UART Error code */
NYX 0:85b3fd62ea1a 192
NYX 0:85b3fd62ea1a 193 }UART_HandleTypeDef;
NYX 0:85b3fd62ea1a 194 /**
NYX 0:85b3fd62ea1a 195 * @}
NYX 0:85b3fd62ea1a 196 */
NYX 0:85b3fd62ea1a 197
NYX 0:85b3fd62ea1a 198 /* Exported constants --------------------------------------------------------*/
NYX 0:85b3fd62ea1a 199 /** @defgroup UART_Exported_Constants UART Exported constants
NYX 0:85b3fd62ea1a 200 * @{
NYX 0:85b3fd62ea1a 201 */
NYX 0:85b3fd62ea1a 202
NYX 0:85b3fd62ea1a 203 /** @defgroup UART_Error_Code UART Error Code
NYX 0:85b3fd62ea1a 204 * @brief UART Error Code
NYX 0:85b3fd62ea1a 205 * @{
NYX 0:85b3fd62ea1a 206 */
NYX 0:85b3fd62ea1a 207 #define HAL_UART_ERROR_NONE 0x00000000U /*!< No error */
NYX 0:85b3fd62ea1a 208 #define HAL_UART_ERROR_PE 0x00000001U /*!< Parity error */
NYX 0:85b3fd62ea1a 209 #define HAL_UART_ERROR_NE 0x00000002U /*!< Noise error */
NYX 0:85b3fd62ea1a 210 #define HAL_UART_ERROR_FE 0x00000004U /*!< Frame error */
NYX 0:85b3fd62ea1a 211 #define HAL_UART_ERROR_ORE 0x00000008U /*!< Overrun error */
NYX 0:85b3fd62ea1a 212 #define HAL_UART_ERROR_DMA 0x00000010U /*!< DMA transfer error */
NYX 0:85b3fd62ea1a 213 /**
NYX 0:85b3fd62ea1a 214 * @}
NYX 0:85b3fd62ea1a 215 */
NYX 0:85b3fd62ea1a 216
NYX 0:85b3fd62ea1a 217 /** @defgroup UART_Word_Length UART Word Length
NYX 0:85b3fd62ea1a 218 * @{
NYX 0:85b3fd62ea1a 219 */
NYX 0:85b3fd62ea1a 220 #define UART_WORDLENGTH_8B 0x00000000U
NYX 0:85b3fd62ea1a 221 #define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
NYX 0:85b3fd62ea1a 222 /**
NYX 0:85b3fd62ea1a 223 * @}
NYX 0:85b3fd62ea1a 224 */
NYX 0:85b3fd62ea1a 225
NYX 0:85b3fd62ea1a 226 /** @defgroup UART_Stop_Bits UART Number of Stop Bits
NYX 0:85b3fd62ea1a 227 * @{
NYX 0:85b3fd62ea1a 228 */
NYX 0:85b3fd62ea1a 229 #define UART_STOPBITS_1 0x00000000U
NYX 0:85b3fd62ea1a 230 #define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1)
NYX 0:85b3fd62ea1a 231 /**
NYX 0:85b3fd62ea1a 232 * @}
NYX 0:85b3fd62ea1a 233 */
NYX 0:85b3fd62ea1a 234
NYX 0:85b3fd62ea1a 235 /** @defgroup UART_Parity UART Parity
NYX 0:85b3fd62ea1a 236 * @{
NYX 0:85b3fd62ea1a 237 */
NYX 0:85b3fd62ea1a 238 #define UART_PARITY_NONE 0x00000000U
NYX 0:85b3fd62ea1a 239 #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
NYX 0:85b3fd62ea1a 240 #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
NYX 0:85b3fd62ea1a 241 /**
NYX 0:85b3fd62ea1a 242 * @}
NYX 0:85b3fd62ea1a 243 */
NYX 0:85b3fd62ea1a 244
NYX 0:85b3fd62ea1a 245 /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
NYX 0:85b3fd62ea1a 246 * @{
NYX 0:85b3fd62ea1a 247 */
NYX 0:85b3fd62ea1a 248 #define UART_HWCONTROL_NONE 0x00000000U
NYX 0:85b3fd62ea1a 249 #define UART_HWCONTROL_RTS ((uint32_t)USART_CR3_RTSE)
NYX 0:85b3fd62ea1a 250 #define UART_HWCONTROL_CTS ((uint32_t)USART_CR3_CTSE)
NYX 0:85b3fd62ea1a 251 #define UART_HWCONTROL_RTS_CTS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE))
NYX 0:85b3fd62ea1a 252 /**
NYX 0:85b3fd62ea1a 253 * @}
NYX 0:85b3fd62ea1a 254 */
NYX 0:85b3fd62ea1a 255
NYX 0:85b3fd62ea1a 256 /** @defgroup UART_Mode UART Transfer Mode
NYX 0:85b3fd62ea1a 257 * @{
NYX 0:85b3fd62ea1a 258 */
NYX 0:85b3fd62ea1a 259 #define UART_MODE_RX ((uint32_t)USART_CR1_RE)
NYX 0:85b3fd62ea1a 260 #define UART_MODE_TX ((uint32_t)USART_CR1_TE)
NYX 0:85b3fd62ea1a 261 #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
NYX 0:85b3fd62ea1a 262 /**
NYX 0:85b3fd62ea1a 263 * @}
NYX 0:85b3fd62ea1a 264 */
NYX 0:85b3fd62ea1a 265
NYX 0:85b3fd62ea1a 266 /** @defgroup UART_State UART State
NYX 0:85b3fd62ea1a 267 * @{
NYX 0:85b3fd62ea1a 268 */
NYX 0:85b3fd62ea1a 269 #define UART_STATE_DISABLE 0x00000000U
NYX 0:85b3fd62ea1a 270 #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE)
NYX 0:85b3fd62ea1a 271 /**
NYX 0:85b3fd62ea1a 272 * @}
NYX 0:85b3fd62ea1a 273 */
NYX 0:85b3fd62ea1a 274
NYX 0:85b3fd62ea1a 275 /** @defgroup UART_Over_Sampling UART Over Sampling
NYX 0:85b3fd62ea1a 276 * @{
NYX 0:85b3fd62ea1a 277 */
NYX 0:85b3fd62ea1a 278 #define UART_OVERSAMPLING_16 0x00000000U
NYX 0:85b3fd62ea1a 279 #define UART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8)
NYX 0:85b3fd62ea1a 280 /**
NYX 0:85b3fd62ea1a 281 * @}
NYX 0:85b3fd62ea1a 282 */
NYX 0:85b3fd62ea1a 283
NYX 0:85b3fd62ea1a 284 /** @defgroup UART_LIN_Break_Detection_Length UART LIN Break Detection Length
NYX 0:85b3fd62ea1a 285 * @{
NYX 0:85b3fd62ea1a 286 */
NYX 0:85b3fd62ea1a 287 #define UART_LINBREAKDETECTLENGTH_10B 0x00000000U
NYX 0:85b3fd62ea1a 288 #define UART_LINBREAKDETECTLENGTH_11B 0x00000020U
NYX 0:85b3fd62ea1a 289 /**
NYX 0:85b3fd62ea1a 290 * @}
NYX 0:85b3fd62ea1a 291 */
NYX 0:85b3fd62ea1a 292
NYX 0:85b3fd62ea1a 293 /** @defgroup UART_WakeUp_functions UART Wakeup Functions
NYX 0:85b3fd62ea1a 294 * @{
NYX 0:85b3fd62ea1a 295 */
NYX 0:85b3fd62ea1a 296 #define UART_WAKEUPMETHOD_IDLELINE 0x00000000U
NYX 0:85b3fd62ea1a 297 #define UART_WAKEUPMETHOD_ADDRESSMARK 0x00000800U
NYX 0:85b3fd62ea1a 298 /**
NYX 0:85b3fd62ea1a 299 * @}
NYX 0:85b3fd62ea1a 300 */
NYX 0:85b3fd62ea1a 301
NYX 0:85b3fd62ea1a 302 /** @defgroup UART_Flags UART FLags
NYX 0:85b3fd62ea1a 303 * Elements values convention: 0xXXXX
NYX 0:85b3fd62ea1a 304 * - 0xXXXX : Flag mask in the SR register
NYX 0:85b3fd62ea1a 305 * @{
NYX 0:85b3fd62ea1a 306 */
NYX 0:85b3fd62ea1a 307 #define UART_FLAG_CTS ((uint32_t)USART_SR_CTS)
NYX 0:85b3fd62ea1a 308 #define UART_FLAG_LBD ((uint32_t)USART_SR_LBD)
NYX 0:85b3fd62ea1a 309 #define UART_FLAG_TXE ((uint32_t)USART_SR_TXE)
NYX 0:85b3fd62ea1a 310 #define UART_FLAG_TC ((uint32_t)USART_SR_TC)
NYX 0:85b3fd62ea1a 311 #define UART_FLAG_RXNE ((uint32_t)USART_SR_RXNE)
NYX 0:85b3fd62ea1a 312 #define UART_FLAG_IDLE ((uint32_t)USART_SR_IDLE)
NYX 0:85b3fd62ea1a 313 #define UART_FLAG_ORE ((uint32_t)USART_SR_ORE)
NYX 0:85b3fd62ea1a 314 #define UART_FLAG_NE ((uint32_t)USART_SR_NE)
NYX 0:85b3fd62ea1a 315 #define UART_FLAG_FE ((uint32_t)USART_SR_FE)
NYX 0:85b3fd62ea1a 316 #define UART_FLAG_PE ((uint32_t)USART_SR_PE)
NYX 0:85b3fd62ea1a 317 /**
NYX 0:85b3fd62ea1a 318 * @}
NYX 0:85b3fd62ea1a 319 */
NYX 0:85b3fd62ea1a 320
NYX 0:85b3fd62ea1a 321 /** @defgroup UART_Interrupt_definition UART Interrupt Definitions
NYX 0:85b3fd62ea1a 322 * Elements values convention: 0xY000XXXX
NYX 0:85b3fd62ea1a 323 * - XXXX : Interrupt mask (16 bits) in the Y register
NYX 0:85b3fd62ea1a 324 * - Y : Interrupt source register (2bits)
NYX 0:85b3fd62ea1a 325 * - 0001: CR1 register
NYX 0:85b3fd62ea1a 326 * - 0010: CR2 register
NYX 0:85b3fd62ea1a 327 * - 0011: CR3 register
NYX 0:85b3fd62ea1a 328 *
NYX 0:85b3fd62ea1a 329 * @{
NYX 0:85b3fd62ea1a 330 */
NYX 0:85b3fd62ea1a 331
NYX 0:85b3fd62ea1a 332 #define UART_IT_PE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_PEIE))
NYX 0:85b3fd62ea1a 333 #define UART_IT_TXE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_TXEIE))
NYX 0:85b3fd62ea1a 334 #define UART_IT_TC ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_TCIE))
NYX 0:85b3fd62ea1a 335 #define UART_IT_RXNE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE))
NYX 0:85b3fd62ea1a 336 #define UART_IT_IDLE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE))
NYX 0:85b3fd62ea1a 337
NYX 0:85b3fd62ea1a 338 #define UART_IT_LBD ((uint32_t)(UART_CR2_REG_INDEX << 28U | USART_CR2_LBDIE))
NYX 0:85b3fd62ea1a 339
NYX 0:85b3fd62ea1a 340 #define UART_IT_CTS ((uint32_t)(UART_CR3_REG_INDEX << 28U | USART_CR3_CTSIE))
NYX 0:85b3fd62ea1a 341 #define UART_IT_ERR ((uint32_t)(UART_CR3_REG_INDEX << 28U | USART_CR3_EIE))
NYX 0:85b3fd62ea1a 342 /**
NYX 0:85b3fd62ea1a 343 * @}
NYX 0:85b3fd62ea1a 344 */
NYX 0:85b3fd62ea1a 345
NYX 0:85b3fd62ea1a 346 /**
NYX 0:85b3fd62ea1a 347 * @}
NYX 0:85b3fd62ea1a 348 */
NYX 0:85b3fd62ea1a 349
NYX 0:85b3fd62ea1a 350 /* Exported macro ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 351 /** @defgroup UART_Exported_Macros UART Exported Macros
NYX 0:85b3fd62ea1a 352 * @{
NYX 0:85b3fd62ea1a 353 */
NYX 0:85b3fd62ea1a 354
NYX 0:85b3fd62ea1a 355 /** @brief Reset UART handle gstate & RxState
NYX 0:85b3fd62ea1a 356 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 357 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
NYX 0:85b3fd62ea1a 358 * UART peripheral.
NYX 0:85b3fd62ea1a 359 * @retval None
NYX 0:85b3fd62ea1a 360 */
NYX 0:85b3fd62ea1a 361 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \
NYX 0:85b3fd62ea1a 362 (__HANDLE__)->gState = HAL_UART_STATE_RESET; \
NYX 0:85b3fd62ea1a 363 (__HANDLE__)->RxState = HAL_UART_STATE_RESET; \
NYX 0:85b3fd62ea1a 364 } while(0U)
NYX 0:85b3fd62ea1a 365
NYX 0:85b3fd62ea1a 366 /** @brief Flushes the UART DR register
NYX 0:85b3fd62ea1a 367 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 368 */
NYX 0:85b3fd62ea1a 369 #define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR)
NYX 0:85b3fd62ea1a 370
NYX 0:85b3fd62ea1a 371 /** @brief Checks whether the specified UART flag is set or not.
NYX 0:85b3fd62ea1a 372 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 373 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
NYX 0:85b3fd62ea1a 374 * UART peripheral.
NYX 0:85b3fd62ea1a 375 * @param __FLAG__: specifies the flag to check.
NYX 0:85b3fd62ea1a 376 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 377 * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5)
NYX 0:85b3fd62ea1a 378 * @arg UART_FLAG_LBD: LIN Break detection flag
NYX 0:85b3fd62ea1a 379 * @arg UART_FLAG_TXE: Transmit data register empty flag
NYX 0:85b3fd62ea1a 380 * @arg UART_FLAG_TC: Transmission Complete flag
NYX 0:85b3fd62ea1a 381 * @arg UART_FLAG_RXNE: Receive data register not empty flag
NYX 0:85b3fd62ea1a 382 * @arg UART_FLAG_IDLE: Idle Line detection flag
NYX 0:85b3fd62ea1a 383 * @arg UART_FLAG_ORE: Overrun Error flag
NYX 0:85b3fd62ea1a 384 * @arg UART_FLAG_NE: Noise Error flag
NYX 0:85b3fd62ea1a 385 * @arg UART_FLAG_FE: Framing Error flag
NYX 0:85b3fd62ea1a 386 * @arg UART_FLAG_PE: Parity Error flag
NYX 0:85b3fd62ea1a 387 * @retval The new state of __FLAG__ (TRUE or FALSE).
NYX 0:85b3fd62ea1a 388 */
NYX 0:85b3fd62ea1a 389
NYX 0:85b3fd62ea1a 390 #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
NYX 0:85b3fd62ea1a 391
NYX 0:85b3fd62ea1a 392 /** @brief Clears the specified UART pending flag.
NYX 0:85b3fd62ea1a 393 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 394 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
NYX 0:85b3fd62ea1a 395 * UART peripheral.
NYX 0:85b3fd62ea1a 396 * @param __FLAG__: specifies the flag to check.
NYX 0:85b3fd62ea1a 397 * This parameter can be any combination of the following values:
NYX 0:85b3fd62ea1a 398 * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5).
NYX 0:85b3fd62ea1a 399 * @arg UART_FLAG_LBD: LIN Break detection flag.
NYX 0:85b3fd62ea1a 400 * @arg UART_FLAG_TC: Transmission Complete flag.
NYX 0:85b3fd62ea1a 401 * @arg UART_FLAG_RXNE: Receive data register not empty flag.
NYX 0:85b3fd62ea1a 402 *
NYX 0:85b3fd62ea1a 403 * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (Overrun
NYX 0:85b3fd62ea1a 404 * error) and IDLE (Idle line detected) flags are cleared by software
NYX 0:85b3fd62ea1a 405 * sequence: a read operation to USART_SR register followed by a read
NYX 0:85b3fd62ea1a 406 * operation to USART_DR register.
NYX 0:85b3fd62ea1a 407 * @note RXNE flag can be also cleared by a read to the USART_DR register.
NYX 0:85b3fd62ea1a 408 * @note TC flag can be also cleared by software sequence: a read operation to
NYX 0:85b3fd62ea1a 409 * USART_SR register followed by a write operation to USART_DR register.
NYX 0:85b3fd62ea1a 410 * @note TXE flag is cleared only by a write to the USART_DR register.
NYX 0:85b3fd62ea1a 411 *
NYX 0:85b3fd62ea1a 412 * @retval None
NYX 0:85b3fd62ea1a 413 */
NYX 0:85b3fd62ea1a 414 #define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
NYX 0:85b3fd62ea1a 415
NYX 0:85b3fd62ea1a 416 /** @brief Clear the UART PE pending flag.
NYX 0:85b3fd62ea1a 417 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 418 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
NYX 0:85b3fd62ea1a 419 * UART peripheral.
NYX 0:85b3fd62ea1a 420 * @retval None
NYX 0:85b3fd62ea1a 421 */
NYX 0:85b3fd62ea1a 422 #define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) \
NYX 0:85b3fd62ea1a 423 do{ \
NYX 0:85b3fd62ea1a 424 __IO uint32_t tmpreg = 0x00U; \
NYX 0:85b3fd62ea1a 425 tmpreg = (__HANDLE__)->Instance->SR; \
NYX 0:85b3fd62ea1a 426 tmpreg = (__HANDLE__)->Instance->DR; \
NYX 0:85b3fd62ea1a 427 UNUSED(tmpreg); \
NYX 0:85b3fd62ea1a 428 } while(0U)
NYX 0:85b3fd62ea1a 429
NYX 0:85b3fd62ea1a 430 /** @brief Clear the UART FE pending flag.
NYX 0:85b3fd62ea1a 431 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 432 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
NYX 0:85b3fd62ea1a 433 * UART peripheral.
NYX 0:85b3fd62ea1a 434 * @retval None
NYX 0:85b3fd62ea1a 435 */
NYX 0:85b3fd62ea1a 436 #define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
NYX 0:85b3fd62ea1a 437
NYX 0:85b3fd62ea1a 438 /** @brief Clear the UART NE pending flag.
NYX 0:85b3fd62ea1a 439 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 440 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
NYX 0:85b3fd62ea1a 441 * UART peripheral.
NYX 0:85b3fd62ea1a 442 * @retval None
NYX 0:85b3fd62ea1a 443 */
NYX 0:85b3fd62ea1a 444 #define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
NYX 0:85b3fd62ea1a 445
NYX 0:85b3fd62ea1a 446 /** @brief Clear the UART ORE pending flag.
NYX 0:85b3fd62ea1a 447 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 448 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
NYX 0:85b3fd62ea1a 449 * UART peripheral.
NYX 0:85b3fd62ea1a 450 * @retval None
NYX 0:85b3fd62ea1a 451 */
NYX 0:85b3fd62ea1a 452 #define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
NYX 0:85b3fd62ea1a 453
NYX 0:85b3fd62ea1a 454 /** @brief Clear the UART IDLE pending flag.
NYX 0:85b3fd62ea1a 455 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 456 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
NYX 0:85b3fd62ea1a 457 * UART peripheral.
NYX 0:85b3fd62ea1a 458 * @retval None
NYX 0:85b3fd62ea1a 459 */
NYX 0:85b3fd62ea1a 460 #define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
NYX 0:85b3fd62ea1a 461
NYX 0:85b3fd62ea1a 462 /** @brief Enable the specified UART interrupt.
NYX 0:85b3fd62ea1a 463 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 464 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
NYX 0:85b3fd62ea1a 465 * UART peripheral.
NYX 0:85b3fd62ea1a 466 * @param __INTERRUPT__: specifies the UART interrupt source to enable.
NYX 0:85b3fd62ea1a 467 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 468 * @arg UART_IT_CTS: CTS change interrupt
NYX 0:85b3fd62ea1a 469 * @arg UART_IT_LBD: LIN Break detection interrupt
NYX 0:85b3fd62ea1a 470 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
NYX 0:85b3fd62ea1a 471 * @arg UART_IT_TC: Transmission complete interrupt
NYX 0:85b3fd62ea1a 472 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
NYX 0:85b3fd62ea1a 473 * @arg UART_IT_IDLE: Idle line detection interrupt
NYX 0:85b3fd62ea1a 474 * @arg UART_IT_PE: Parity Error interrupt
NYX 0:85b3fd62ea1a 475 * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
NYX 0:85b3fd62ea1a 476 * @retval None
NYX 0:85b3fd62ea1a 477 */
NYX 0:85b3fd62ea1a 478 #define UART_IT_MASK 0x0000FFFFU
NYX 0:85b3fd62ea1a 479 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & UART_IT_MASK)): \
NYX 0:85b3fd62ea1a 480 (((__INTERRUPT__) >> 28U) == 2U)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & UART_IT_MASK)): \
NYX 0:85b3fd62ea1a 481 ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & UART_IT_MASK)))
NYX 0:85b3fd62ea1a 482 /** @brief Disable the specified UART interrupt.
NYX 0:85b3fd62ea1a 483 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 484 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
NYX 0:85b3fd62ea1a 485 * UART peripheral.
NYX 0:85b3fd62ea1a 486 * @param __INTERRUPT__: specifies the UART interrupt source to disable.
NYX 0:85b3fd62ea1a 487 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 488 * @arg UART_IT_CTS: CTS change interrupt
NYX 0:85b3fd62ea1a 489 * @arg UART_IT_LBD: LIN Break detection interrupt
NYX 0:85b3fd62ea1a 490 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
NYX 0:85b3fd62ea1a 491 * @arg UART_IT_TC: Transmission complete interrupt
NYX 0:85b3fd62ea1a 492 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
NYX 0:85b3fd62ea1a 493 * @arg UART_IT_IDLE: Idle line detection interrupt
NYX 0:85b3fd62ea1a 494 * @arg UART_IT_PE: Parity Error interrupt
NYX 0:85b3fd62ea1a 495 * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
NYX 0:85b3fd62ea1a 496 * @retval None
NYX 0:85b3fd62ea1a 497 */
NYX 0:85b3fd62ea1a 498 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & UART_IT_MASK)): \
NYX 0:85b3fd62ea1a 499 (((__INTERRUPT__) >> 28U) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & UART_IT_MASK)): \
NYX 0:85b3fd62ea1a 500 ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & UART_IT_MASK)))
NYX 0:85b3fd62ea1a 501
NYX 0:85b3fd62ea1a 502 /** @brief Checks whether the specified UART interrupt has occurred or not.
NYX 0:85b3fd62ea1a 503 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 504 * This parameter can be UARTx where x: 1, 2, 3, 4, 5, 6, 7 or 8 to select the USART or
NYX 0:85b3fd62ea1a 505 * UART peripheral.
NYX 0:85b3fd62ea1a 506 * @param __IT__: specifies the UART interrupt source to check.
NYX 0:85b3fd62ea1a 507 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 508 * @arg UART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
NYX 0:85b3fd62ea1a 509 * @arg UART_IT_LBD: LIN Break detection interrupt
NYX 0:85b3fd62ea1a 510 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
NYX 0:85b3fd62ea1a 511 * @arg UART_IT_TC: Transmission complete interrupt
NYX 0:85b3fd62ea1a 512 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
NYX 0:85b3fd62ea1a 513 * @arg UART_IT_IDLE: Idle line detection interrupt
NYX 0:85b3fd62ea1a 514 * @arg USART_IT_ERR: Error interrupt
NYX 0:85b3fd62ea1a 515 * @retval The new state of __IT__ (TRUE or FALSE).
NYX 0:85b3fd62ea1a 516 */
NYX 0:85b3fd62ea1a 517 #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == 1U)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == 2U)? \
NYX 0:85b3fd62ea1a 518 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & UART_IT_MASK))
NYX 0:85b3fd62ea1a 519
NYX 0:85b3fd62ea1a 520 /** @brief Enable CTS flow control
NYX 0:85b3fd62ea1a 521 * This macro allows to enable CTS hardware flow control for a given UART instance,
NYX 0:85b3fd62ea1a 522 * without need to call HAL_UART_Init() function.
NYX 0:85b3fd62ea1a 523 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
NYX 0:85b3fd62ea1a 524 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
NYX 0:85b3fd62ea1a 525 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
NYX 0:85b3fd62ea1a 526 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
NYX 0:85b3fd62ea1a 527 * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
NYX 0:85b3fd62ea1a 528 * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
NYX 0:85b3fd62ea1a 529 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 530 * The Handle Instance can be USART1, USART2 or LPUART.
NYX 0:85b3fd62ea1a 531 * @retval None
NYX 0:85b3fd62ea1a 532 */
NYX 0:85b3fd62ea1a 533 #define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \
NYX 0:85b3fd62ea1a 534 do{ \
NYX 0:85b3fd62ea1a 535 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
NYX 0:85b3fd62ea1a 536 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \
NYX 0:85b3fd62ea1a 537 } while(0U)
NYX 0:85b3fd62ea1a 538
NYX 0:85b3fd62ea1a 539 /** @brief Disable CTS flow control
NYX 0:85b3fd62ea1a 540 * This macro allows to disable CTS hardware flow control for a given UART instance,
NYX 0:85b3fd62ea1a 541 * without need to call HAL_UART_Init() function.
NYX 0:85b3fd62ea1a 542 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
NYX 0:85b3fd62ea1a 543 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
NYX 0:85b3fd62ea1a 544 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
NYX 0:85b3fd62ea1a 545 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
NYX 0:85b3fd62ea1a 546 * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
NYX 0:85b3fd62ea1a 547 * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
NYX 0:85b3fd62ea1a 548 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 549 * The Handle Instance can be USART1, USART2 or LPUART.
NYX 0:85b3fd62ea1a 550 * @retval None
NYX 0:85b3fd62ea1a 551 */
NYX 0:85b3fd62ea1a 552 #define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \
NYX 0:85b3fd62ea1a 553 do{ \
NYX 0:85b3fd62ea1a 554 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
NYX 0:85b3fd62ea1a 555 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \
NYX 0:85b3fd62ea1a 556 } while(0U)
NYX 0:85b3fd62ea1a 557
NYX 0:85b3fd62ea1a 558 /** @brief Enable RTS flow control
NYX 0:85b3fd62ea1a 559 * This macro allows to enable RTS hardware flow control for a given UART instance,
NYX 0:85b3fd62ea1a 560 * without need to call HAL_UART_Init() function.
NYX 0:85b3fd62ea1a 561 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
NYX 0:85b3fd62ea1a 562 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
NYX 0:85b3fd62ea1a 563 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
NYX 0:85b3fd62ea1a 564 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
NYX 0:85b3fd62ea1a 565 * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
NYX 0:85b3fd62ea1a 566 * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
NYX 0:85b3fd62ea1a 567 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 568 * The Handle Instance can be USART1, USART2 or LPUART.
NYX 0:85b3fd62ea1a 569 * @retval None
NYX 0:85b3fd62ea1a 570 */
NYX 0:85b3fd62ea1a 571 #define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \
NYX 0:85b3fd62ea1a 572 do{ \
NYX 0:85b3fd62ea1a 573 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \
NYX 0:85b3fd62ea1a 574 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \
NYX 0:85b3fd62ea1a 575 } while(0U)
NYX 0:85b3fd62ea1a 576
NYX 0:85b3fd62ea1a 577 /** @brief Disable RTS flow control
NYX 0:85b3fd62ea1a 578 * This macro allows to disable RTS hardware flow control for a given UART instance,
NYX 0:85b3fd62ea1a 579 * without need to call HAL_UART_Init() function.
NYX 0:85b3fd62ea1a 580 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
NYX 0:85b3fd62ea1a 581 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
NYX 0:85b3fd62ea1a 582 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
NYX 0:85b3fd62ea1a 583 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
NYX 0:85b3fd62ea1a 584 * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
NYX 0:85b3fd62ea1a 585 * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
NYX 0:85b3fd62ea1a 586 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 587 * The Handle Instance can be USART1, USART2 or LPUART.
NYX 0:85b3fd62ea1a 588 * @retval None
NYX 0:85b3fd62ea1a 589 */
NYX 0:85b3fd62ea1a 590 #define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \
NYX 0:85b3fd62ea1a 591 do{ \
NYX 0:85b3fd62ea1a 592 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\
NYX 0:85b3fd62ea1a 593 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \
NYX 0:85b3fd62ea1a 594 } while(0U)
NYX 0:85b3fd62ea1a 595
NYX 0:85b3fd62ea1a 596 /** @brief macros to enables the UART's one bit sample method
NYX 0:85b3fd62ea1a 597 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 598 * @retval None
NYX 0:85b3fd62ea1a 599 */
NYX 0:85b3fd62ea1a 600 #define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
NYX 0:85b3fd62ea1a 601
NYX 0:85b3fd62ea1a 602 /** @brief macros to disables the UART's one bit sample method
NYX 0:85b3fd62ea1a 603 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 604 * @retval None
NYX 0:85b3fd62ea1a 605 */
NYX 0:85b3fd62ea1a 606 #define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT))
NYX 0:85b3fd62ea1a 607
NYX 0:85b3fd62ea1a 608 /** @brief Enable UART
NYX 0:85b3fd62ea1a 609 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 610 * @retval None
NYX 0:85b3fd62ea1a 611 */
NYX 0:85b3fd62ea1a 612 #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
NYX 0:85b3fd62ea1a 613
NYX 0:85b3fd62ea1a 614 /** @brief Disable UART
NYX 0:85b3fd62ea1a 615 * @param __HANDLE__: specifies the UART Handle.
NYX 0:85b3fd62ea1a 616 * @retval None
NYX 0:85b3fd62ea1a 617 */
NYX 0:85b3fd62ea1a 618 #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
NYX 0:85b3fd62ea1a 619 /**
NYX 0:85b3fd62ea1a 620 * @}
NYX 0:85b3fd62ea1a 621 */
NYX 0:85b3fd62ea1a 622
NYX 0:85b3fd62ea1a 623 /* Exported functions --------------------------------------------------------*/
NYX 0:85b3fd62ea1a 624 /** @addtogroup UART_Exported_Functions
NYX 0:85b3fd62ea1a 625 * @{
NYX 0:85b3fd62ea1a 626 */
NYX 0:85b3fd62ea1a 627
NYX 0:85b3fd62ea1a 628 /** @addtogroup UART_Exported_Functions_Group1
NYX 0:85b3fd62ea1a 629 * @{
NYX 0:85b3fd62ea1a 630 */
NYX 0:85b3fd62ea1a 631 /* Initialization/de-initialization functions **********************************/
NYX 0:85b3fd62ea1a 632 HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 633 HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 634 HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength);
NYX 0:85b3fd62ea1a 635 HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod);
NYX 0:85b3fd62ea1a 636 HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 637 void HAL_UART_MspInit(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 638 void HAL_UART_MspDeInit(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 639 /**
NYX 0:85b3fd62ea1a 640 * @}
NYX 0:85b3fd62ea1a 641 */
NYX 0:85b3fd62ea1a 642
NYX 0:85b3fd62ea1a 643 /** @addtogroup UART_Exported_Functions_Group2
NYX 0:85b3fd62ea1a 644 * @{
NYX 0:85b3fd62ea1a 645 */
NYX 0:85b3fd62ea1a 646 /* IO operation functions *******************************************************/
NYX 0:85b3fd62ea1a 647 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
NYX 0:85b3fd62ea1a 648 HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
NYX 0:85b3fd62ea1a 649 HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 650 HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 651 HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 652 HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 653 HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 654 HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 655 HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 656 /* Transfer Abort functions */
NYX 0:85b3fd62ea1a 657 HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 658 HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 659 HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 660 HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 661 HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 662 HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 663
NYX 0:85b3fd62ea1a 664 void HAL_UART_IRQHandler(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 665 void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 666 void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 667 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 668 void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 669 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 670 void HAL_UART_AbortCpltCallback (UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 671 void HAL_UART_AbortTransmitCpltCallback (UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 672 void HAL_UART_AbortReceiveCpltCallback (UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 673 /**
NYX 0:85b3fd62ea1a 674 * @}
NYX 0:85b3fd62ea1a 675 */
NYX 0:85b3fd62ea1a 676
NYX 0:85b3fd62ea1a 677 /** @addtogroup UART_Exported_Functions_Group3
NYX 0:85b3fd62ea1a 678 * @{
NYX 0:85b3fd62ea1a 679 */
NYX 0:85b3fd62ea1a 680 /* Peripheral Control functions ************************************************/
NYX 0:85b3fd62ea1a 681 HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 682 HAL_StatusTypeDef HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 683 HAL_StatusTypeDef HAL_MultiProcessor_ExitMuteMode(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 684 HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 685 HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 686 /**
NYX 0:85b3fd62ea1a 687 * @}
NYX 0:85b3fd62ea1a 688 */
NYX 0:85b3fd62ea1a 689
NYX 0:85b3fd62ea1a 690 /** @addtogroup UART_Exported_Functions_Group4
NYX 0:85b3fd62ea1a 691 * @{
NYX 0:85b3fd62ea1a 692 */
NYX 0:85b3fd62ea1a 693 /* Peripheral State functions **************************************************/
NYX 0:85b3fd62ea1a 694 HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 695 uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart);
NYX 0:85b3fd62ea1a 696 /**
NYX 0:85b3fd62ea1a 697 * @}
NYX 0:85b3fd62ea1a 698 */
NYX 0:85b3fd62ea1a 699
NYX 0:85b3fd62ea1a 700 /**
NYX 0:85b3fd62ea1a 701 * @}
NYX 0:85b3fd62ea1a 702 */
NYX 0:85b3fd62ea1a 703 /* Private types -------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 704 /* Private variables ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 705 /* Private constants ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 706 /** @defgroup UART_Private_Constants UART Private Constants
NYX 0:85b3fd62ea1a 707 * @{
NYX 0:85b3fd62ea1a 708 */
NYX 0:85b3fd62ea1a 709 /** @brief UART interruptions flag mask
NYX 0:85b3fd62ea1a 710 *
NYX 0:85b3fd62ea1a 711 */
NYX 0:85b3fd62ea1a 712 #define UART_CR1_REG_INDEX 1U
NYX 0:85b3fd62ea1a 713 #define UART_CR2_REG_INDEX 2U
NYX 0:85b3fd62ea1a 714 #define UART_CR3_REG_INDEX 3U
NYX 0:85b3fd62ea1a 715 /**
NYX 0:85b3fd62ea1a 716 * @}
NYX 0:85b3fd62ea1a 717 */
NYX 0:85b3fd62ea1a 718
NYX 0:85b3fd62ea1a 719 /* Private macros ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 720 /** @defgroup UART_Private_Macros UART Private Macros
NYX 0:85b3fd62ea1a 721 * @{
NYX 0:85b3fd62ea1a 722 */
NYX 0:85b3fd62ea1a 723 #define IS_UART_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B) || \
NYX 0:85b3fd62ea1a 724 ((LENGTH) == UART_WORDLENGTH_9B))
NYX 0:85b3fd62ea1a 725 #define IS_UART_LIN_WORD_LENGTH(LENGTH) (((LENGTH) == UART_WORDLENGTH_8B))
NYX 0:85b3fd62ea1a 726 #define IS_UART_STOPBITS(STOPBITS) (((STOPBITS) == UART_STOPBITS_1) || \
NYX 0:85b3fd62ea1a 727 ((STOPBITS) == UART_STOPBITS_2))
NYX 0:85b3fd62ea1a 728 #define IS_UART_PARITY(PARITY) (((PARITY) == UART_PARITY_NONE) || \
NYX 0:85b3fd62ea1a 729 ((PARITY) == UART_PARITY_EVEN) || \
NYX 0:85b3fd62ea1a 730 ((PARITY) == UART_PARITY_ODD))
NYX 0:85b3fd62ea1a 731 #define IS_UART_HARDWARE_FLOW_CONTROL(CONTROL)\
NYX 0:85b3fd62ea1a 732 (((CONTROL) == UART_HWCONTROL_NONE) || \
NYX 0:85b3fd62ea1a 733 ((CONTROL) == UART_HWCONTROL_RTS) || \
NYX 0:85b3fd62ea1a 734 ((CONTROL) == UART_HWCONTROL_CTS) || \
NYX 0:85b3fd62ea1a 735 ((CONTROL) == UART_HWCONTROL_RTS_CTS))
NYX 0:85b3fd62ea1a 736 #define IS_UART_MODE(MODE) ((((MODE) & 0x0000FFF3U) == 0x00U) && ((MODE) != 0x00U))
NYX 0:85b3fd62ea1a 737 #define IS_UART_STATE(STATE) (((STATE) == UART_STATE_DISABLE) || \
NYX 0:85b3fd62ea1a 738 ((STATE) == UART_STATE_ENABLE))
NYX 0:85b3fd62ea1a 739 #define IS_UART_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16) || \
NYX 0:85b3fd62ea1a 740 ((SAMPLING) == UART_OVERSAMPLING_8))
NYX 0:85b3fd62ea1a 741 #define IS_UART_LIN_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16))
NYX 0:85b3fd62ea1a 742 #define IS_UART_LIN_BREAK_DETECT_LENGTH(LENGTH) (((LENGTH) == UART_LINBREAKDETECTLENGTH_10B) || \
NYX 0:85b3fd62ea1a 743 ((LENGTH) == UART_LINBREAKDETECTLENGTH_11B))
NYX 0:85b3fd62ea1a 744 #define IS_UART_WAKEUPMETHOD(WAKEUP) (((WAKEUP) == UART_WAKEUPMETHOD_IDLELINE) || \
NYX 0:85b3fd62ea1a 745 ((WAKEUP) == UART_WAKEUPMETHOD_ADDRESSMARK))
NYX 0:85b3fd62ea1a 746 #define IS_UART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 10500001U)
NYX 0:85b3fd62ea1a 747 #define IS_UART_ADDRESS(ADDRESS) ((ADDRESS) <= 0x0FU)
NYX 0:85b3fd62ea1a 748
NYX 0:85b3fd62ea1a 749 #define UART_DIV_SAMPLING16(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(4U*(_BAUD_)))
NYX 0:85b3fd62ea1a 750 #define UART_DIVMANT_SAMPLING16(_PCLK_, _BAUD_) (UART_DIV_SAMPLING16((_PCLK_), (_BAUD_))/100U)
NYX 0:85b3fd62ea1a 751 #define UART_DIVFRAQ_SAMPLING16(_PCLK_, _BAUD_) (((UART_DIV_SAMPLING16((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) * 100U)) * 16U + 50U) / 100U)
NYX 0:85b3fd62ea1a 752 /* UART BRR = mantissa + overflow + fraction
NYX 0:85b3fd62ea1a 753 = (UART DIVMANT << 4) + (UART DIVFRAQ & 0xF0) + (UART DIVFRAQ & 0x0FU) */
NYX 0:85b3fd62ea1a 754 #define UART_BRR_SAMPLING16(_PCLK_, _BAUD_) (((UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) << 4U) + \
NYX 0:85b3fd62ea1a 755 (UART_DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0xF0U)) + \
NYX 0:85b3fd62ea1a 756 (UART_DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0x0FU))
NYX 0:85b3fd62ea1a 757
NYX 0:85b3fd62ea1a 758 #define UART_DIV_SAMPLING8(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(2U*(_BAUD_)))
NYX 0:85b3fd62ea1a 759 #define UART_DIVMANT_SAMPLING8(_PCLK_, _BAUD_) (UART_DIV_SAMPLING8((_PCLK_), (_BAUD_))/100U)
NYX 0:85b3fd62ea1a 760 #define UART_DIVFRAQ_SAMPLING8(_PCLK_, _BAUD_) (((UART_DIV_SAMPLING8((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) * 100U)) * 8U + 50U) / 100U)
NYX 0:85b3fd62ea1a 761 /* UART BRR = mantissa + overflow + fraction
NYX 0:85b3fd62ea1a 762 = (UART DIVMANT << 4) + ((UART DIVFRAQ & 0xF8) << 1) + (UART DIVFRAQ & 0x07U) */
NYX 0:85b3fd62ea1a 763 #define UART_BRR_SAMPLING8(_PCLK_, _BAUD_) (((UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) << 4U) + \
NYX 0:85b3fd62ea1a 764 ((UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0xF8U) << 1U)) + \
NYX 0:85b3fd62ea1a 765 (UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0x07U))
NYX 0:85b3fd62ea1a 766
NYX 0:85b3fd62ea1a 767 /**
NYX 0:85b3fd62ea1a 768 * @}
NYX 0:85b3fd62ea1a 769 */
NYX 0:85b3fd62ea1a 770
NYX 0:85b3fd62ea1a 771 /* Private functions ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 772 /** @defgroup UART_Private_Functions UART Private Functions
NYX 0:85b3fd62ea1a 773 * @{
NYX 0:85b3fd62ea1a 774 */
NYX 0:85b3fd62ea1a 775
NYX 0:85b3fd62ea1a 776 /**
NYX 0:85b3fd62ea1a 777 * @}
NYX 0:85b3fd62ea1a 778 */
NYX 0:85b3fd62ea1a 779
NYX 0:85b3fd62ea1a 780 /**
NYX 0:85b3fd62ea1a 781 * @}
NYX 0:85b3fd62ea1a 782 */
NYX 0:85b3fd62ea1a 783
NYX 0:85b3fd62ea1a 784 /**
NYX 0:85b3fd62ea1a 785 * @}
NYX 0:85b3fd62ea1a 786 */
NYX 0:85b3fd62ea1a 787
NYX 0:85b3fd62ea1a 788 #ifdef __cplusplus
NYX 0:85b3fd62ea1a 789 }
NYX 0:85b3fd62ea1a 790 #endif
NYX 0:85b3fd62ea1a 791
NYX 0:85b3fd62ea1a 792 #endif /* __STM32F4xx_HAL_UART_H */
NYX 0:85b3fd62ea1a 793
NYX 0:85b3fd62ea1a 794 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/