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