STM32H735xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32h7xx_hal_uart.h 00004 * @author MCD Application Team 00005 * @brief Header file of UART HAL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * Copyright (c) 2017 STMicroelectronics. 00010 * All rights reserved. 00011 * 00012 * This software is licensed under terms that can be found in the LICENSE file 00013 * in the root directory of this software component. 00014 * If no LICENSE file comes with this software, it is provided AS-IS. 00015 * 00016 ****************************************************************************** 00017 */ 00018 00019 /* Define to prevent recursive inclusion -------------------------------------*/ 00020 #ifndef STM32H7xx_HAL_UART_H 00021 #define STM32H7xx_HAL_UART_H 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /* Includes ------------------------------------------------------------------*/ 00028 #include "stm32h7xx_hal_def.h" 00029 00030 /** @addtogroup STM32H7xx_HAL_Driver 00031 * @{ 00032 */ 00033 00034 /** @addtogroup UART 00035 * @{ 00036 */ 00037 00038 /* Exported types ------------------------------------------------------------*/ 00039 /** @defgroup UART_Exported_Types UART Exported Types 00040 * @{ 00041 */ 00042 00043 /** 00044 * @brief UART Init Structure definition 00045 */ 00046 typedef struct 00047 { 00048 uint32_t BaudRate; /*!< This member configures the UART communication baud rate. 00049 The baud rate register is computed using the following formula: 00050 LPUART: 00051 ======= 00052 Baud Rate Register = ((256 * lpuart_ker_ckpres) / ((huart->Init.BaudRate))) 00053 where lpuart_ker_ck_pres is the UART input clock divided by a prescaler 00054 UART: 00055 ===== 00056 - If oversampling is 16 or in LIN mode, 00057 Baud Rate Register = ((uart_ker_ckpres) / ((huart->Init.BaudRate))) 00058 - If oversampling is 8, 00059 Baud Rate Register[15:4] = ((2 * uart_ker_ckpres) / 00060 ((huart->Init.BaudRate)))[15:4] 00061 Baud Rate Register[3] = 0 00062 Baud Rate Register[2:0] = (((2 * uart_ker_ckpres) / 00063 ((huart->Init.BaudRate)))[3:0]) >> 1 00064 where uart_ker_ck_pres is the UART input clock divided by a prescaler */ 00065 00066 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. 00067 This parameter can be a value of @ref UARTEx_Word_Length. */ 00068 00069 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. 00070 This parameter can be a value of @ref UART_Stop_Bits. */ 00071 00072 uint32_t Parity; /*!< Specifies the parity mode. 00073 This parameter can be a value of @ref UART_Parity 00074 @note When parity is enabled, the computed parity is inserted 00075 at the MSB position of the transmitted data (9th bit when 00076 the word length is set to 9 data bits; 8th bit when the 00077 word length is set to 8 data bits). */ 00078 00079 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled. 00080 This parameter can be a value of @ref UART_Mode. */ 00081 00082 uint32_t HwFlowCtl; /*!< Specifies whether the hardware flow control mode is enabled 00083 or disabled. 00084 This parameter can be a value of @ref UART_Hardware_Flow_Control. */ 00085 00086 uint32_t OverSampling; /*!< Specifies whether the Over sampling 8 is enabled or disabled, 00087 to achieve higher speed (up to f_PCLK/8). 00088 This parameter can be a value of @ref UART_Over_Sampling. */ 00089 00090 uint32_t OneBitSampling; /*!< Specifies whether a single sample or three samples' majority vote is selected. 00091 Selecting the single sample method increases the receiver tolerance to clock 00092 deviations. This parameter can be a value of @ref UART_OneBit_Sampling. */ 00093 00094 uint32_t ClockPrescaler; /*!< Specifies the prescaler value used to divide the UART clock source. 00095 This parameter can be a value of @ref UART_ClockPrescaler. */ 00096 00097 } UART_InitTypeDef; 00098 00099 /** 00100 * @brief UART Advanced Features initialization structure definition 00101 */ 00102 typedef struct 00103 { 00104 uint32_t AdvFeatureInit; /*!< Specifies which advanced UART features is initialized. Several 00105 Advanced Features may be initialized at the same time . 00106 This parameter can be a value of 00107 @ref UART_Advanced_Features_Initialization_Type. */ 00108 00109 uint32_t TxPinLevelInvert; /*!< Specifies whether the TX pin active level is inverted. 00110 This parameter can be a value of @ref UART_Tx_Inv. */ 00111 00112 uint32_t RxPinLevelInvert; /*!< Specifies whether the RX pin active level is inverted. 00113 This parameter can be a value of @ref UART_Rx_Inv. */ 00114 00115 uint32_t DataInvert; /*!< Specifies whether data are inverted (positive/direct logic 00116 vs negative/inverted logic). 00117 This parameter can be a value of @ref UART_Data_Inv. */ 00118 00119 uint32_t Swap; /*!< Specifies whether TX and RX pins are swapped. 00120 This parameter can be a value of @ref UART_Rx_Tx_Swap. */ 00121 00122 uint32_t OverrunDisable; /*!< Specifies whether the reception overrun detection is disabled. 00123 This parameter can be a value of @ref UART_Overrun_Disable. */ 00124 00125 uint32_t DMADisableonRxError; /*!< Specifies whether the DMA is disabled in case of reception error. 00126 This parameter can be a value of @ref UART_DMA_Disable_on_Rx_Error. */ 00127 00128 uint32_t AutoBaudRateEnable; /*!< Specifies whether auto Baud rate detection is enabled. 00129 This parameter can be a value of @ref UART_AutoBaudRate_Enable. */ 00130 00131 uint32_t AutoBaudRateMode; /*!< If auto Baud rate detection is enabled, specifies how the rate 00132 detection is carried out. 00133 This parameter can be a value of @ref UART_AutoBaud_Rate_Mode. */ 00134 00135 uint32_t MSBFirst; /*!< Specifies whether MSB is sent first on UART line. 00136 This parameter can be a value of @ref UART_MSB_First. */ 00137 } UART_AdvFeatureInitTypeDef; 00138 00139 /** 00140 * @brief HAL UART State definition 00141 * @note HAL UART State value is a combination of 2 different substates: 00142 * gState and RxState (see @ref UART_State_Definition). 00143 * - gState contains UART state information related to global Handle management 00144 * and also information related to Tx operations. 00145 * gState value coding follow below described bitmap : 00146 * b7-b6 Error information 00147 * 00 : No Error 00148 * 01 : (Not Used) 00149 * 10 : Timeout 00150 * 11 : Error 00151 * b5 Peripheral initialization status 00152 * 0 : Reset (Peripheral not initialized) 00153 * 1 : Init done (Peripheral initialized. HAL UART Init function already called) 00154 * b4-b3 (not used) 00155 * xx : Should be set to 00 00156 * b2 Intrinsic process state 00157 * 0 : Ready 00158 * 1 : Busy (Peripheral busy with some configuration or internal operations) 00159 * b1 (not used) 00160 * x : Should be set to 0 00161 * b0 Tx state 00162 * 0 : Ready (no Tx operation ongoing) 00163 * 1 : Busy (Tx operation ongoing) 00164 * - RxState contains information related to Rx operations. 00165 * RxState value coding follow below described bitmap : 00166 * b7-b6 (not used) 00167 * xx : Should be set to 00 00168 * b5 Peripheral initialization status 00169 * 0 : Reset (Peripheral not initialized) 00170 * 1 : Init done (Peripheral initialized) 00171 * b4-b2 (not used) 00172 * xxx : Should be set to 000 00173 * b1 Rx state 00174 * 0 : Ready (no Rx operation ongoing) 00175 * 1 : Busy (Rx operation ongoing) 00176 * b0 (not used) 00177 * x : Should be set to 0. 00178 */ 00179 typedef uint32_t HAL_UART_StateTypeDef; 00180 00181 /** 00182 * @brief UART clock sources definition 00183 */ 00184 typedef enum 00185 { 00186 UART_CLOCKSOURCE_D2PCLK1 = 0x00U, /*!< Domain2 PCLK1 clock source */ 00187 UART_CLOCKSOURCE_D2PCLK2 = 0x01U, /*!< Domain2 PCLK2 clock source */ 00188 UART_CLOCKSOURCE_D3PCLK1 = 0x02U, /*!< Domain3 PCLK1 clock source */ 00189 UART_CLOCKSOURCE_PLL2 = 0x04U, /*!< PLL2Q clock source */ 00190 UART_CLOCKSOURCE_PLL3 = 0x08U, /*!< PLL3Q clock source */ 00191 UART_CLOCKSOURCE_HSI = 0x10U, /*!< HSI clock source */ 00192 UART_CLOCKSOURCE_CSI = 0x20U, /*!< CSI clock source */ 00193 UART_CLOCKSOURCE_LSE = 0x40U, /*!< LSE clock source */ 00194 UART_CLOCKSOURCE_UNDEFINED = 0x80U /*!< Undefined clock source */ 00195 } UART_ClockSourceTypeDef; 00196 00197 /** 00198 * @brief HAL UART Reception type definition 00199 * @note HAL UART Reception type value aims to identify which type of Reception is ongoing. 00200 * It is expected to admit following values : 00201 * HAL_UART_RECEPTION_STANDARD = 0x00U, 00202 * HAL_UART_RECEPTION_TOIDLE = 0x01U, 00203 * HAL_UART_RECEPTION_TORTO = 0x02U, 00204 * HAL_UART_RECEPTION_TOCHARMATCH = 0x03U, 00205 */ 00206 typedef uint32_t HAL_UART_RxTypeTypeDef; 00207 00208 /** 00209 * @brief UART handle Structure definition 00210 */ 00211 typedef struct __UART_HandleTypeDef 00212 { 00213 USART_TypeDef *Instance; /*!< UART registers base address */ 00214 00215 UART_InitTypeDef Init; /*!< UART communication parameters */ 00216 00217 UART_AdvFeatureInitTypeDef AdvancedInit; /*!< UART Advanced Features initialization parameters */ 00218 00219 const uint8_t *pTxBuffPtr; /*!< Pointer to UART Tx transfer Buffer */ 00220 00221 uint16_t TxXferSize; /*!< UART Tx Transfer size */ 00222 00223 __IO uint16_t TxXferCount; /*!< UART Tx Transfer Counter */ 00224 00225 uint8_t *pRxBuffPtr; /*!< Pointer to UART Rx transfer Buffer */ 00226 00227 uint16_t RxXferSize; /*!< UART Rx Transfer size */ 00228 00229 __IO uint16_t RxXferCount; /*!< UART Rx Transfer Counter */ 00230 00231 uint16_t Mask; /*!< UART Rx RDR register mask */ 00232 00233 uint32_t FifoMode; /*!< Specifies if the FIFO mode is being used. 00234 This parameter can be a value of @ref UARTEx_FIFO_mode. */ 00235 00236 uint16_t NbRxDataToProcess; /*!< Number of data to process during RX ISR execution */ 00237 00238 uint16_t NbTxDataToProcess; /*!< Number of data to process during TX ISR execution */ 00239 00240 __IO HAL_UART_RxTypeTypeDef ReceptionType; /*!< Type of ongoing reception */ 00241 00242 void (*RxISR)(struct __UART_HandleTypeDef *huart); /*!< Function pointer on Rx IRQ handler */ 00243 00244 void (*TxISR)(struct __UART_HandleTypeDef *huart); /*!< Function pointer on Tx IRQ handler */ 00245 00246 DMA_HandleTypeDef *hdmatx; /*!< UART Tx DMA Handle parameters */ 00247 00248 DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */ 00249 00250 HAL_LockTypeDef Lock; /*!< Locking object */ 00251 00252 __IO HAL_UART_StateTypeDef gState; /*!< UART state information related to global Handle management 00253 and also related to Tx operations. This parameter 00254 can be a value of @ref HAL_UART_StateTypeDef */ 00255 00256 __IO HAL_UART_StateTypeDef RxState; /*!< UART state information related to Rx operations. This 00257 parameter can be a value of @ref HAL_UART_StateTypeDef */ 00258 00259 __IO uint32_t ErrorCode; /*!< UART Error code */ 00260 00261 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) 00262 void (* TxHalfCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Tx Half Complete Callback */ 00263 void (* TxCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Tx Complete Callback */ 00264 void (* RxHalfCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Rx Half Complete Callback */ 00265 void (* RxCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Rx Complete Callback */ 00266 void (* ErrorCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Error Callback */ 00267 void (* AbortCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Abort Complete Callback */ 00268 void (* AbortTransmitCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Abort Transmit Complete Callback */ 00269 void (* AbortReceiveCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Abort Receive Complete Callback */ 00270 void (* WakeupCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Wakeup Callback */ 00271 void (* RxFifoFullCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Rx Fifo Full Callback */ 00272 void (* TxFifoEmptyCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Tx Fifo Empty Callback */ 00273 void (* RxEventCallback)(struct __UART_HandleTypeDef *huart, uint16_t Pos); /*!< UART Reception Event Callback */ 00274 00275 void (* MspInitCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Msp Init callback */ 00276 void (* MspDeInitCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Msp DeInit callback */ 00277 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */ 00278 00279 } UART_HandleTypeDef; 00280 00281 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) 00282 /** 00283 * @brief HAL UART Callback ID enumeration definition 00284 */ 00285 typedef enum 00286 { 00287 HAL_UART_TX_HALFCOMPLETE_CB_ID = 0x00U, /*!< UART Tx Half Complete Callback ID */ 00288 HAL_UART_TX_COMPLETE_CB_ID = 0x01U, /*!< UART Tx Complete Callback ID */ 00289 HAL_UART_RX_HALFCOMPLETE_CB_ID = 0x02U, /*!< UART Rx Half Complete Callback ID */ 00290 HAL_UART_RX_COMPLETE_CB_ID = 0x03U, /*!< UART Rx Complete Callback ID */ 00291 HAL_UART_ERROR_CB_ID = 0x04U, /*!< UART Error Callback ID */ 00292 HAL_UART_ABORT_COMPLETE_CB_ID = 0x05U, /*!< UART Abort Complete Callback ID */ 00293 HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x06U, /*!< UART Abort Transmit Complete Callback ID */ 00294 HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID = 0x07U, /*!< UART Abort Receive Complete Callback ID */ 00295 HAL_UART_WAKEUP_CB_ID = 0x08U, /*!< UART Wakeup Callback ID */ 00296 HAL_UART_RX_FIFO_FULL_CB_ID = 0x09U, /*!< UART Rx Fifo Full Callback ID */ 00297 HAL_UART_TX_FIFO_EMPTY_CB_ID = 0x0AU, /*!< UART Tx Fifo Empty Callback ID */ 00298 00299 HAL_UART_MSPINIT_CB_ID = 0x0BU, /*!< UART MspInit callback ID */ 00300 HAL_UART_MSPDEINIT_CB_ID = 0x0CU /*!< UART MspDeInit callback ID */ 00301 00302 } HAL_UART_CallbackIDTypeDef; 00303 00304 /** 00305 * @brief HAL UART Callback pointer definition 00306 */ 00307 typedef void (*pUART_CallbackTypeDef)(UART_HandleTypeDef *huart); /*!< pointer to an UART callback function */ 00308 typedef void (*pUART_RxEventCallbackTypeDef) 00309 (struct __UART_HandleTypeDef *huart, uint16_t Pos); /*!< pointer to a UART Rx Event specific callback function */ 00310 00311 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */ 00312 00313 /** 00314 * @} 00315 */ 00316 00317 /* Exported constants --------------------------------------------------------*/ 00318 /** @defgroup UART_Exported_Constants UART Exported Constants 00319 * @{ 00320 */ 00321 00322 /** @defgroup UART_State_Definition UART State Code Definition 00323 * @{ 00324 */ 00325 #define HAL_UART_STATE_RESET 0x00000000U /*!< Peripheral is not initialized 00326 Value is allowed for gState and RxState */ 00327 #define HAL_UART_STATE_READY 0x00000020U /*!< Peripheral Initialized and ready for use 00328 Value is allowed for gState and RxState */ 00329 #define HAL_UART_STATE_BUSY 0x00000024U /*!< an internal process is ongoing 00330 Value is allowed for gState only */ 00331 #define HAL_UART_STATE_BUSY_TX 0x00000021U /*!< Data Transmission process is ongoing 00332 Value is allowed for gState only */ 00333 #define HAL_UART_STATE_BUSY_RX 0x00000022U /*!< Data Reception process is ongoing 00334 Value is allowed for RxState only */ 00335 #define HAL_UART_STATE_BUSY_TX_RX 0x00000023U /*!< Data Transmission and Reception process is ongoing 00336 Not to be used for neither gState nor RxState.Value is result 00337 of combination (Or) between gState and RxState values */ 00338 #define HAL_UART_STATE_TIMEOUT 0x000000A0U /*!< Timeout state 00339 Value is allowed for gState only */ 00340 #define HAL_UART_STATE_ERROR 0x000000E0U /*!< Error 00341 Value is allowed for gState only */ 00342 /** 00343 * @} 00344 */ 00345 00346 /** @defgroup UART_Error_Definition UART Error Definition 00347 * @{ 00348 */ 00349 #define HAL_UART_ERROR_NONE (0x00000000U) /*!< No error */ 00350 #define HAL_UART_ERROR_PE (0x00000001U) /*!< Parity error */ 00351 #define HAL_UART_ERROR_NE (0x00000002U) /*!< Noise error */ 00352 #define HAL_UART_ERROR_FE (0x00000004U) /*!< Frame error */ 00353 #define HAL_UART_ERROR_ORE (0x00000008U) /*!< Overrun error */ 00354 #define HAL_UART_ERROR_DMA (0x00000010U) /*!< DMA transfer error */ 00355 #define HAL_UART_ERROR_RTO (0x00000020U) /*!< Receiver Timeout error */ 00356 00357 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) 00358 #define HAL_UART_ERROR_INVALID_CALLBACK (0x00000040U) /*!< Invalid Callback error */ 00359 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */ 00360 /** 00361 * @} 00362 */ 00363 00364 /** @defgroup UART_Stop_Bits UART Number of Stop Bits 00365 * @{ 00366 */ 00367 #define UART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< UART frame with 0.5 stop bit */ 00368 #define UART_STOPBITS_1 0x00000000U /*!< UART frame with 1 stop bit */ 00369 #define UART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< UART frame with 1.5 stop bits */ 00370 #define UART_STOPBITS_2 USART_CR2_STOP_1 /*!< UART frame with 2 stop bits */ 00371 /** 00372 * @} 00373 */ 00374 00375 /** @defgroup UART_Parity UART Parity 00376 * @{ 00377 */ 00378 #define UART_PARITY_NONE 0x00000000U /*!< No parity */ 00379 #define UART_PARITY_EVEN USART_CR1_PCE /*!< Even parity */ 00380 #define UART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Odd parity */ 00381 /** 00382 * @} 00383 */ 00384 00385 /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control 00386 * @{ 00387 */ 00388 #define UART_HWCONTROL_NONE 0x00000000U /*!< No hardware control */ 00389 #define UART_HWCONTROL_RTS USART_CR3_RTSE /*!< Request To Send */ 00390 #define UART_HWCONTROL_CTS USART_CR3_CTSE /*!< Clear To Send */ 00391 #define UART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< Request and Clear To Send */ 00392 /** 00393 * @} 00394 */ 00395 00396 /** @defgroup UART_Mode UART Transfer Mode 00397 * @{ 00398 */ 00399 #define UART_MODE_RX USART_CR1_RE /*!< RX mode */ 00400 #define UART_MODE_TX USART_CR1_TE /*!< TX mode */ 00401 #define UART_MODE_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< RX and TX mode */ 00402 /** 00403 * @} 00404 */ 00405 00406 /** @defgroup UART_State UART State 00407 * @{ 00408 */ 00409 #define UART_STATE_DISABLE 0x00000000U /*!< UART disabled */ 00410 #define UART_STATE_ENABLE USART_CR1_UE /*!< UART enabled */ 00411 /** 00412 * @} 00413 */ 00414 00415 /** @defgroup UART_Over_Sampling UART Over Sampling 00416 * @{ 00417 */ 00418 #define UART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */ 00419 #define UART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */ 00420 /** 00421 * @} 00422 */ 00423 00424 /** @defgroup UART_OneBit_Sampling UART One Bit Sampling Method 00425 * @{ 00426 */ 00427 #define UART_ONE_BIT_SAMPLE_DISABLE 0x00000000U /*!< One-bit sampling disable */ 00428 #define UART_ONE_BIT_SAMPLE_ENABLE USART_CR3_ONEBIT /*!< One-bit sampling enable */ 00429 /** 00430 * @} 00431 */ 00432 00433 /** @defgroup UART_ClockPrescaler UART Clock Prescaler 00434 * @{ 00435 */ 00436 #define UART_PRESCALER_DIV1 0x00000000U /*!< fclk_pres = fclk */ 00437 #define UART_PRESCALER_DIV2 0x00000001U /*!< fclk_pres = fclk/2 */ 00438 #define UART_PRESCALER_DIV4 0x00000002U /*!< fclk_pres = fclk/4 */ 00439 #define UART_PRESCALER_DIV6 0x00000003U /*!< fclk_pres = fclk/6 */ 00440 #define UART_PRESCALER_DIV8 0x00000004U /*!< fclk_pres = fclk/8 */ 00441 #define UART_PRESCALER_DIV10 0x00000005U /*!< fclk_pres = fclk/10 */ 00442 #define UART_PRESCALER_DIV12 0x00000006U /*!< fclk_pres = fclk/12 */ 00443 #define UART_PRESCALER_DIV16 0x00000007U /*!< fclk_pres = fclk/16 */ 00444 #define UART_PRESCALER_DIV32 0x00000008U /*!< fclk_pres = fclk/32 */ 00445 #define UART_PRESCALER_DIV64 0x00000009U /*!< fclk_pres = fclk/64 */ 00446 #define UART_PRESCALER_DIV128 0x0000000AU /*!< fclk_pres = fclk/128 */ 00447 #define UART_PRESCALER_DIV256 0x0000000BU /*!< fclk_pres = fclk/256 */ 00448 /** 00449 * @} 00450 */ 00451 00452 /** @defgroup UART_AutoBaud_Rate_Mode UART Advanced Feature AutoBaud Rate Mode 00453 * @{ 00454 */ 00455 #define UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT 0x00000000U /*!< Auto Baud rate detection 00456 on start bit */ 00457 #define UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE USART_CR2_ABRMODE_0 /*!< Auto Baud rate detection 00458 on falling edge */ 00459 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME USART_CR2_ABRMODE_1 /*!< Auto Baud rate detection 00460 on 0x7F frame detection */ 00461 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME USART_CR2_ABRMODE /*!< Auto Baud rate detection 00462 on 0x55 frame detection */ 00463 /** 00464 * @} 00465 */ 00466 00467 /** @defgroup UART_Receiver_Timeout UART Receiver Timeout 00468 * @{ 00469 */ 00470 #define UART_RECEIVER_TIMEOUT_DISABLE 0x00000000U /*!< UART Receiver Timeout disable */ 00471 #define UART_RECEIVER_TIMEOUT_ENABLE USART_CR2_RTOEN /*!< UART Receiver Timeout enable */ 00472 /** 00473 * @} 00474 */ 00475 00476 /** @defgroup UART_LIN UART Local Interconnection Network mode 00477 * @{ 00478 */ 00479 #define UART_LIN_DISABLE 0x00000000U /*!< Local Interconnect Network disable */ 00480 #define UART_LIN_ENABLE USART_CR2_LINEN /*!< Local Interconnect Network enable */ 00481 /** 00482 * @} 00483 */ 00484 00485 /** @defgroup UART_LIN_Break_Detection UART LIN Break Detection 00486 * @{ 00487 */ 00488 #define UART_LINBREAKDETECTLENGTH_10B 0x00000000U /*!< LIN 10-bit break detection length */ 00489 #define UART_LINBREAKDETECTLENGTH_11B USART_CR2_LBDL /*!< LIN 11-bit break detection length */ 00490 /** 00491 * @} 00492 */ 00493 00494 /** @defgroup UART_DMA_Tx UART DMA Tx 00495 * @{ 00496 */ 00497 #define UART_DMA_TX_DISABLE 0x00000000U /*!< UART DMA TX disabled */ 00498 #define UART_DMA_TX_ENABLE USART_CR3_DMAT /*!< UART DMA TX enabled */ 00499 /** 00500 * @} 00501 */ 00502 00503 /** @defgroup UART_DMA_Rx UART DMA Rx 00504 * @{ 00505 */ 00506 #define UART_DMA_RX_DISABLE 0x00000000U /*!< UART DMA RX disabled */ 00507 #define UART_DMA_RX_ENABLE USART_CR3_DMAR /*!< UART DMA RX enabled */ 00508 /** 00509 * @} 00510 */ 00511 00512 /** @defgroup UART_Half_Duplex_Selection UART Half Duplex Selection 00513 * @{ 00514 */ 00515 #define UART_HALF_DUPLEX_DISABLE 0x00000000U /*!< UART half-duplex disabled */ 00516 #define UART_HALF_DUPLEX_ENABLE USART_CR3_HDSEL /*!< UART half-duplex enabled */ 00517 /** 00518 * @} 00519 */ 00520 00521 /** @defgroup UART_WakeUp_Methods UART WakeUp Methods 00522 * @{ 00523 */ 00524 #define UART_WAKEUPMETHOD_IDLELINE 0x00000000U /*!< UART wake-up on idle line */ 00525 #define UART_WAKEUPMETHOD_ADDRESSMARK USART_CR1_WAKE /*!< UART wake-up on address mark */ 00526 /** 00527 * @} 00528 */ 00529 00530 /** @defgroup UART_Request_Parameters UART Request Parameters 00531 * @{ 00532 */ 00533 #define UART_AUTOBAUD_REQUEST USART_RQR_ABRRQ /*!< Auto-Baud Rate Request */ 00534 #define UART_SENDBREAK_REQUEST USART_RQR_SBKRQ /*!< Send Break Request */ 00535 #define UART_MUTE_MODE_REQUEST USART_RQR_MMRQ /*!< Mute Mode Request */ 00536 #define UART_RXDATA_FLUSH_REQUEST USART_RQR_RXFRQ /*!< Receive Data flush Request */ 00537 #define UART_TXDATA_FLUSH_REQUEST USART_RQR_TXFRQ /*!< Transmit data flush Request */ 00538 /** 00539 * @} 00540 */ 00541 00542 /** @defgroup UART_Advanced_Features_Initialization_Type UART Advanced Feature Initialization Type 00543 * @{ 00544 */ 00545 #define UART_ADVFEATURE_NO_INIT 0x00000000U /*!< No advanced feature initialization */ 00546 #define UART_ADVFEATURE_TXINVERT_INIT 0x00000001U /*!< TX pin active level inversion */ 00547 #define UART_ADVFEATURE_RXINVERT_INIT 0x00000002U /*!< RX pin active level inversion */ 00548 #define UART_ADVFEATURE_DATAINVERT_INIT 0x00000004U /*!< Binary data inversion */ 00549 #define UART_ADVFEATURE_SWAP_INIT 0x00000008U /*!< TX/RX pins swap */ 00550 #define UART_ADVFEATURE_RXOVERRUNDISABLE_INIT 0x00000010U /*!< RX overrun disable */ 00551 #define UART_ADVFEATURE_DMADISABLEONERROR_INIT 0x00000020U /*!< DMA disable on Reception Error */ 00552 #define UART_ADVFEATURE_AUTOBAUDRATE_INIT 0x00000040U /*!< Auto Baud rate detection initialization */ 00553 #define UART_ADVFEATURE_MSBFIRST_INIT 0x00000080U /*!< Most significant bit sent/received first */ 00554 /** 00555 * @} 00556 */ 00557 00558 /** @defgroup UART_Tx_Inv UART Advanced Feature TX Pin Active Level Inversion 00559 * @{ 00560 */ 00561 #define UART_ADVFEATURE_TXINV_DISABLE 0x00000000U /*!< TX pin active level inversion disable */ 00562 #define UART_ADVFEATURE_TXINV_ENABLE USART_CR2_TXINV /*!< TX pin active level inversion enable */ 00563 /** 00564 * @} 00565 */ 00566 00567 /** @defgroup UART_Rx_Inv UART Advanced Feature RX Pin Active Level Inversion 00568 * @{ 00569 */ 00570 #define UART_ADVFEATURE_RXINV_DISABLE 0x00000000U /*!< RX pin active level inversion disable */ 00571 #define UART_ADVFEATURE_RXINV_ENABLE USART_CR2_RXINV /*!< RX pin active level inversion enable */ 00572 /** 00573 * @} 00574 */ 00575 00576 /** @defgroup UART_Data_Inv UART Advanced Feature Binary Data Inversion 00577 * @{ 00578 */ 00579 #define UART_ADVFEATURE_DATAINV_DISABLE 0x00000000U /*!< Binary data inversion disable */ 00580 #define UART_ADVFEATURE_DATAINV_ENABLE USART_CR2_DATAINV /*!< Binary data inversion enable */ 00581 /** 00582 * @} 00583 */ 00584 00585 /** @defgroup UART_Rx_Tx_Swap UART Advanced Feature RX TX Pins Swap 00586 * @{ 00587 */ 00588 #define UART_ADVFEATURE_SWAP_DISABLE 0x00000000U /*!< TX/RX pins swap disable */ 00589 #define UART_ADVFEATURE_SWAP_ENABLE USART_CR2_SWAP /*!< TX/RX pins swap enable */ 00590 /** 00591 * @} 00592 */ 00593 00594 /** @defgroup UART_Overrun_Disable UART Advanced Feature Overrun Disable 00595 * @{ 00596 */ 00597 #define UART_ADVFEATURE_OVERRUN_ENABLE 0x00000000U /*!< RX overrun enable */ 00598 #define UART_ADVFEATURE_OVERRUN_DISABLE USART_CR3_OVRDIS /*!< RX overrun disable */ 00599 /** 00600 * @} 00601 */ 00602 00603 /** @defgroup UART_AutoBaudRate_Enable UART Advanced Feature Auto BaudRate Enable 00604 * @{ 00605 */ 00606 #define UART_ADVFEATURE_AUTOBAUDRATE_DISABLE 0x00000000U /*!< RX Auto Baud rate detection enable */ 00607 #define UART_ADVFEATURE_AUTOBAUDRATE_ENABLE USART_CR2_ABREN /*!< RX Auto Baud rate detection disable */ 00608 /** 00609 * @} 00610 */ 00611 00612 /** @defgroup UART_DMA_Disable_on_Rx_Error UART Advanced Feature DMA Disable On Rx Error 00613 * @{ 00614 */ 00615 #define UART_ADVFEATURE_DMA_ENABLEONRXERROR 0x00000000U /*!< DMA enable on Reception Error */ 00616 #define UART_ADVFEATURE_DMA_DISABLEONRXERROR USART_CR3_DDRE /*!< DMA disable on Reception Error */ 00617 /** 00618 * @} 00619 */ 00620 00621 /** @defgroup UART_MSB_First UART Advanced Feature MSB First 00622 * @{ 00623 */ 00624 #define UART_ADVFEATURE_MSBFIRST_DISABLE 0x00000000U /*!< Most significant bit sent/received 00625 first disable */ 00626 #define UART_ADVFEATURE_MSBFIRST_ENABLE USART_CR2_MSBFIRST /*!< Most significant bit sent/received 00627 first enable */ 00628 /** 00629 * @} 00630 */ 00631 00632 /** @defgroup UART_Stop_Mode_Enable UART Advanced Feature Stop Mode Enable 00633 * @{ 00634 */ 00635 #define UART_ADVFEATURE_STOPMODE_DISABLE 0x00000000U /*!< UART stop mode disable */ 00636 #define UART_ADVFEATURE_STOPMODE_ENABLE USART_CR1_UESM /*!< UART stop mode enable */ 00637 /** 00638 * @} 00639 */ 00640 00641 /** @defgroup UART_Mute_Mode UART Advanced Feature Mute Mode Enable 00642 * @{ 00643 */ 00644 #define UART_ADVFEATURE_MUTEMODE_DISABLE 0x00000000U /*!< UART mute mode disable */ 00645 #define UART_ADVFEATURE_MUTEMODE_ENABLE USART_CR1_MME /*!< UART mute mode enable */ 00646 /** 00647 * @} 00648 */ 00649 00650 /** @defgroup UART_CR2_ADDRESS_LSB_POS UART Address-matching LSB Position In CR2 Register 00651 * @{ 00652 */ 00653 #define UART_CR2_ADDRESS_LSB_POS 24U /*!< UART address-matching LSB position in CR2 register */ 00654 /** 00655 * @} 00656 */ 00657 00658 /** @defgroup UART_WakeUp_from_Stop_Selection UART WakeUp From Stop Selection 00659 * @{ 00660 */ 00661 #define UART_WAKEUP_ON_ADDRESS 0x00000000U /*!< UART wake-up on address */ 00662 #define UART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< UART wake-up on start bit */ 00663 #define UART_WAKEUP_ON_READDATA_NONEMPTY USART_CR3_WUS /*!< UART wake-up on receive data register 00664 not empty or RXFIFO is not empty */ 00665 /** 00666 * @} 00667 */ 00668 00669 /** @defgroup UART_DriverEnable_Polarity UART DriverEnable Polarity 00670 * @{ 00671 */ 00672 #define UART_DE_POLARITY_HIGH 0x00000000U /*!< Driver enable signal is active high */ 00673 #define UART_DE_POLARITY_LOW USART_CR3_DEP /*!< Driver enable signal is active low */ 00674 /** 00675 * @} 00676 */ 00677 00678 /** @defgroup UART_CR1_DEAT_ADDRESS_LSB_POS UART Driver Enable Assertion Time LSB Position In CR1 Register 00679 * @{ 00680 */ 00681 #define UART_CR1_DEAT_ADDRESS_LSB_POS 21U /*!< UART Driver Enable assertion time LSB 00682 position in CR1 register */ 00683 /** 00684 * @} 00685 */ 00686 00687 /** @defgroup UART_CR1_DEDT_ADDRESS_LSB_POS UART Driver Enable DeAssertion Time LSB Position In CR1 Register 00688 * @{ 00689 */ 00690 #define UART_CR1_DEDT_ADDRESS_LSB_POS 16U /*!< UART Driver Enable de-assertion time LSB 00691 position in CR1 register */ 00692 /** 00693 * @} 00694 */ 00695 00696 /** @defgroup UART_Interruption_Mask UART Interruptions Flag Mask 00697 * @{ 00698 */ 00699 #define UART_IT_MASK 0x001FU /*!< UART interruptions flags mask */ 00700 /** 00701 * @} 00702 */ 00703 00704 /** @defgroup UART_TimeOut_Value UART polling-based communications time-out value 00705 * @{ 00706 */ 00707 #define HAL_UART_TIMEOUT_VALUE 0x1FFFFFFU /*!< UART polling-based communications time-out value */ 00708 /** 00709 * @} 00710 */ 00711 00712 /** @defgroup UART_Flags UART Status Flags 00713 * Elements values convention: 0xXXXX 00714 * - 0xXXXX : Flag mask in the ISR register 00715 * @{ 00716 */ 00717 #define UART_FLAG_TXFT USART_ISR_TXFT /*!< UART TXFIFO threshold flag */ 00718 #define UART_FLAG_RXFT USART_ISR_RXFT /*!< UART RXFIFO threshold flag */ 00719 #define UART_FLAG_RXFF USART_ISR_RXFF /*!< UART RXFIFO Full flag */ 00720 #define UART_FLAG_TXFE USART_ISR_TXFE /*!< UART TXFIFO Empty flag */ 00721 #define UART_FLAG_REACK USART_ISR_REACK /*!< UART receive enable acknowledge flag */ 00722 #define UART_FLAG_TEACK USART_ISR_TEACK /*!< UART transmit enable acknowledge flag */ 00723 #define UART_FLAG_WUF USART_ISR_WUF /*!< UART wake-up from stop mode flag */ 00724 #define UART_FLAG_RWU USART_ISR_RWU /*!< UART receiver wake-up from mute mode flag */ 00725 #define UART_FLAG_SBKF USART_ISR_SBKF /*!< UART send break flag */ 00726 #define UART_FLAG_CMF USART_ISR_CMF /*!< UART character match flag */ 00727 #define UART_FLAG_BUSY USART_ISR_BUSY /*!< UART busy flag */ 00728 #define UART_FLAG_ABRF USART_ISR_ABRF /*!< UART auto Baud rate flag */ 00729 #define UART_FLAG_ABRE USART_ISR_ABRE /*!< UART auto Baud rate error */ 00730 #define UART_FLAG_RTOF USART_ISR_RTOF /*!< UART receiver timeout flag */ 00731 #define UART_FLAG_CTS USART_ISR_CTS /*!< UART clear to send flag */ 00732 #define UART_FLAG_CTSIF USART_ISR_CTSIF /*!< UART clear to send interrupt flag */ 00733 #define UART_FLAG_LBDF USART_ISR_LBDF /*!< UART LIN break detection flag */ 00734 #define UART_FLAG_TXE USART_ISR_TXE_TXFNF /*!< UART transmit data register empty */ 00735 #define UART_FLAG_TXFNF USART_ISR_TXE_TXFNF /*!< UART TXFIFO not full */ 00736 #define UART_FLAG_TC USART_ISR_TC /*!< UART transmission complete */ 00737 #define UART_FLAG_RXNE USART_ISR_RXNE_RXFNE /*!< UART read data register not empty */ 00738 #define UART_FLAG_RXFNE USART_ISR_RXNE_RXFNE /*!< UART RXFIFO not empty */ 00739 #define UART_FLAG_IDLE USART_ISR_IDLE /*!< UART idle flag */ 00740 #define UART_FLAG_ORE USART_ISR_ORE /*!< UART overrun error */ 00741 #define UART_FLAG_NE USART_ISR_NE /*!< UART noise error */ 00742 #define UART_FLAG_FE USART_ISR_FE /*!< UART frame error */ 00743 #define UART_FLAG_PE USART_ISR_PE /*!< UART parity error */ 00744 /** 00745 * @} 00746 */ 00747 00748 /** @defgroup UART_Interrupt_definition UART Interrupts Definition 00749 * Elements values convention: 000ZZZZZ0XXYYYYYb 00750 * - YYYYY : Interrupt source position in the XX register (5bits) 00751 * - XX : Interrupt source register (2bits) 00752 * - 01: CR1 register 00753 * - 10: CR2 register 00754 * - 11: CR3 register 00755 * - ZZZZZ : Flag position in the ISR register(5bits) 00756 * Elements values convention: 000000000XXYYYYYb 00757 * - YYYYY : Interrupt source position in the XX register (5bits) 00758 * - XX : Interrupt source register (2bits) 00759 * - 01: CR1 register 00760 * - 10: CR2 register 00761 * - 11: CR3 register 00762 * Elements values convention: 0000ZZZZ00000000b 00763 * - ZZZZ : Flag position in the ISR register(4bits) 00764 * @{ 00765 */ 00766 #define UART_IT_PE 0x0028U /*!< UART parity error interruption */ 00767 #define UART_IT_TXE 0x0727U /*!< UART transmit data register empty interruption */ 00768 #define UART_IT_TXFNF 0x0727U /*!< UART TX FIFO not full interruption */ 00769 #define UART_IT_TC 0x0626U /*!< UART transmission complete interruption */ 00770 #define UART_IT_RXNE 0x0525U /*!< UART read data register not empty interruption */ 00771 #define UART_IT_RXFNE 0x0525U /*!< UART RXFIFO not empty interruption */ 00772 #define UART_IT_IDLE 0x0424U /*!< UART idle interruption */ 00773 #define UART_IT_LBD 0x0846U /*!< UART LIN break detection interruption */ 00774 #define UART_IT_CTS 0x096AU /*!< UART CTS interruption */ 00775 #define UART_IT_CM 0x112EU /*!< UART character match interruption */ 00776 #define UART_IT_WUF 0x1476U /*!< UART wake-up from stop mode interruption */ 00777 #define UART_IT_RXFF 0x183FU /*!< UART RXFIFO full interruption */ 00778 #define UART_IT_TXFE 0x173EU /*!< UART TXFIFO empty interruption */ 00779 #define UART_IT_RXFT 0x1A7CU /*!< UART RXFIFO threshold reached interruption */ 00780 #define UART_IT_TXFT 0x1B77U /*!< UART TXFIFO threshold reached interruption */ 00781 #define UART_IT_RTO 0x0B3AU /*!< UART receiver timeout interruption */ 00782 00783 #define UART_IT_ERR 0x0060U /*!< UART error interruption */ 00784 00785 #define UART_IT_ORE 0x0300U /*!< UART overrun error interruption */ 00786 #define UART_IT_NE 0x0200U /*!< UART noise error interruption */ 00787 #define UART_IT_FE 0x0100U /*!< UART frame error interruption */ 00788 /** 00789 * @} 00790 */ 00791 00792 /** @defgroup UART_IT_CLEAR_Flags UART Interruption Clear Flags 00793 * @{ 00794 */ 00795 #define UART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */ 00796 #define UART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */ 00797 #define UART_CLEAR_NEF USART_ICR_NECF /*!< Noise Error detected Clear Flag */ 00798 #define UART_CLEAR_OREF USART_ICR_ORECF /*!< Overrun Error Clear Flag */ 00799 #define UART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */ 00800 #define UART_CLEAR_TXFECF USART_ICR_TXFECF /*!< TXFIFO empty clear flag */ 00801 #define UART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */ 00802 #define UART_CLEAR_LBDF USART_ICR_LBDCF /*!< LIN Break Detection Clear Flag */ 00803 #define UART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */ 00804 #define UART_CLEAR_CMF USART_ICR_CMCF /*!< Character Match Clear Flag */ 00805 #define UART_CLEAR_WUF USART_ICR_WUCF /*!< Wake Up from stop mode Clear Flag */ 00806 #define UART_CLEAR_RTOF USART_ICR_RTOCF /*!< UART receiver timeout clear flag */ 00807 /** 00808 * @} 00809 */ 00810 00811 /** @defgroup UART_RECEPTION_TYPE_Values UART Reception type values 00812 * @{ 00813 */ 00814 #define HAL_UART_RECEPTION_STANDARD (0x00000000U) /*!< Standard reception */ 00815 #define HAL_UART_RECEPTION_TOIDLE (0x00000001U) /*!< Reception till completion or IDLE event */ 00816 #define HAL_UART_RECEPTION_TORTO (0x00000002U) /*!< Reception till completion or RTO event */ 00817 #define HAL_UART_RECEPTION_TOCHARMATCH (0x00000003U) /*!< Reception till completion or CM event */ 00818 /** 00819 * @} 00820 */ 00821 00822 /** 00823 * @} 00824 */ 00825 00826 /* Exported macros -----------------------------------------------------------*/ 00827 /** @defgroup UART_Exported_Macros UART Exported Macros 00828 * @{ 00829 */ 00830 00831 /** @brief Reset UART handle states. 00832 * @param __HANDLE__ UART handle. 00833 * @retval None 00834 */ 00835 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) 00836 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \ 00837 (__HANDLE__)->gState = HAL_UART_STATE_RESET; \ 00838 (__HANDLE__)->RxState = HAL_UART_STATE_RESET; \ 00839 (__HANDLE__)->MspInitCallback = NULL; \ 00840 (__HANDLE__)->MspDeInitCallback = NULL; \ 00841 } while(0U) 00842 #else 00843 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \ 00844 (__HANDLE__)->gState = HAL_UART_STATE_RESET; \ 00845 (__HANDLE__)->RxState = HAL_UART_STATE_RESET; \ 00846 } while(0U) 00847 #endif /*USE_HAL_UART_REGISTER_CALLBACKS */ 00848 00849 /** @brief Flush the UART Data registers. 00850 * @param __HANDLE__ specifies the UART Handle. 00851 * @retval None 00852 */ 00853 #define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) \ 00854 do{ \ 00855 SET_BIT((__HANDLE__)->Instance->RQR, UART_RXDATA_FLUSH_REQUEST); \ 00856 SET_BIT((__HANDLE__)->Instance->RQR, UART_TXDATA_FLUSH_REQUEST); \ 00857 } while(0U) 00858 00859 /** @brief Clear the specified UART pending flag. 00860 * @param __HANDLE__ specifies the UART Handle. 00861 * @param __FLAG__ specifies the flag to check. 00862 * This parameter can be any combination of the following values: 00863 * @arg @ref UART_CLEAR_PEF Parity Error Clear Flag 00864 * @arg @ref UART_CLEAR_FEF Framing Error Clear Flag 00865 * @arg @ref UART_CLEAR_NEF Noise detected Clear Flag 00866 * @arg @ref UART_CLEAR_OREF Overrun Error Clear Flag 00867 * @arg @ref UART_CLEAR_IDLEF IDLE line detected Clear Flag 00868 * @arg @ref UART_CLEAR_TXFECF TXFIFO empty clear Flag 00869 * @arg @ref UART_CLEAR_TCF Transmission Complete Clear Flag 00870 * @arg @ref UART_CLEAR_RTOF Receiver Timeout clear flag 00871 * @arg @ref UART_CLEAR_LBDF LIN Break Detection Clear Flag 00872 * @arg @ref UART_CLEAR_CTSF CTS Interrupt Clear Flag 00873 * @arg @ref UART_CLEAR_CMF Character Match Clear Flag 00874 * @arg @ref UART_CLEAR_WUF Wake Up from stop mode Clear Flag 00875 * @retval None 00876 */ 00877 #define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) 00878 00879 /** @brief Clear the UART PE pending flag. 00880 * @param __HANDLE__ specifies the UART Handle. 00881 * @retval None 00882 */ 00883 #define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_PEF) 00884 00885 /** @brief Clear the UART FE pending flag. 00886 * @param __HANDLE__ specifies the UART Handle. 00887 * @retval None 00888 */ 00889 #define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_FEF) 00890 00891 /** @brief Clear the UART NE pending flag. 00892 * @param __HANDLE__ specifies the UART Handle. 00893 * @retval None 00894 */ 00895 #define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_NEF) 00896 00897 /** @brief Clear the UART ORE pending flag. 00898 * @param __HANDLE__ specifies the UART Handle. 00899 * @retval None 00900 */ 00901 #define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_OREF) 00902 00903 /** @brief Clear the UART IDLE pending flag. 00904 * @param __HANDLE__ specifies the UART Handle. 00905 * @retval None 00906 */ 00907 #define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_IDLEF) 00908 00909 /** @brief Clear the UART TX FIFO empty clear flag. 00910 * @param __HANDLE__ specifies the UART Handle. 00911 * @retval None 00912 */ 00913 #define __HAL_UART_CLEAR_TXFECF(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_TXFECF) 00914 00915 /** @brief Check whether the specified UART flag is set or not. 00916 * @param __HANDLE__ specifies the UART Handle. 00917 * @param __FLAG__ specifies the flag to check. 00918 * This parameter can be one of the following values: 00919 * @arg @ref UART_FLAG_TXFT TXFIFO threshold flag 00920 * @arg @ref UART_FLAG_RXFT RXFIFO threshold flag 00921 * @arg @ref UART_FLAG_RXFF RXFIFO Full flag 00922 * @arg @ref UART_FLAG_TXFE TXFIFO Empty flag 00923 * @arg @ref UART_FLAG_REACK Receive enable acknowledge flag 00924 * @arg @ref UART_FLAG_TEACK Transmit enable acknowledge flag 00925 * @arg @ref UART_FLAG_WUF Wake up from stop mode flag 00926 * @arg @ref UART_FLAG_RWU Receiver wake up flag (if the UART in mute mode) 00927 * @arg @ref UART_FLAG_SBKF Send Break flag 00928 * @arg @ref UART_FLAG_CMF Character match flag 00929 * @arg @ref UART_FLAG_BUSY Busy flag 00930 * @arg @ref UART_FLAG_ABRF Auto Baud rate detection flag 00931 * @arg @ref UART_FLAG_ABRE Auto Baud rate detection error flag 00932 * @arg @ref UART_FLAG_CTS CTS Change flag 00933 * @arg @ref UART_FLAG_LBDF LIN Break detection flag 00934 * @arg @ref UART_FLAG_TXE Transmit data register empty flag 00935 * @arg @ref UART_FLAG_TXFNF UART TXFIFO not full flag 00936 * @arg @ref UART_FLAG_TC Transmission Complete flag 00937 * @arg @ref UART_FLAG_RXNE Receive data register not empty flag 00938 * @arg @ref UART_FLAG_RXFNE UART RXFIFO not empty flag 00939 * @arg @ref UART_FLAG_RTOF Receiver Timeout flag 00940 * @arg @ref UART_FLAG_IDLE Idle Line detection flag 00941 * @arg @ref UART_FLAG_ORE Overrun Error flag 00942 * @arg @ref UART_FLAG_NE Noise Error flag 00943 * @arg @ref UART_FLAG_FE Framing Error flag 00944 * @arg @ref UART_FLAG_PE Parity Error flag 00945 * @retval The new state of __FLAG__ (TRUE or FALSE). 00946 */ 00947 #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__)) 00948 00949 /** @brief Enable the specified UART interrupt. 00950 * @param __HANDLE__ specifies the UART Handle. 00951 * @param __INTERRUPT__ specifies the UART interrupt source to enable. 00952 * This parameter can be one of the following values: 00953 * @arg @ref UART_IT_RXFF RXFIFO Full interrupt 00954 * @arg @ref UART_IT_TXFE TXFIFO Empty interrupt 00955 * @arg @ref UART_IT_RXFT RXFIFO threshold interrupt 00956 * @arg @ref UART_IT_TXFT TXFIFO threshold interrupt 00957 * @arg @ref UART_IT_WUF Wakeup from stop mode interrupt 00958 * @arg @ref UART_IT_CM Character match interrupt 00959 * @arg @ref UART_IT_CTS CTS change interrupt 00960 * @arg @ref UART_IT_LBD LIN Break detection interrupt 00961 * @arg @ref UART_IT_TXE Transmit Data Register empty interrupt 00962 * @arg @ref UART_IT_TXFNF TX FIFO not full interrupt 00963 * @arg @ref UART_IT_TC Transmission complete interrupt 00964 * @arg @ref UART_IT_RXNE Receive Data register not empty interrupt 00965 * @arg @ref UART_IT_RXFNE RXFIFO not empty interrupt 00966 * @arg @ref UART_IT_RTO Receive Timeout interrupt 00967 * @arg @ref UART_IT_IDLE Idle line detection interrupt 00968 * @arg @ref UART_IT_PE Parity Error interrupt 00969 * @arg @ref UART_IT_ERR Error interrupt (frame error, noise error, overrun error) 00970 * @retval None 00971 */ 00972 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (\ 00973 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)?\ 00974 ((__HANDLE__)->Instance->CR1 |= (1U <<\ 00975 ((__INTERRUPT__) & UART_IT_MASK))): \ 00976 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)?\ 00977 ((__HANDLE__)->Instance->CR2 |= (1U <<\ 00978 ((__INTERRUPT__) & UART_IT_MASK))): \ 00979 ((__HANDLE__)->Instance->CR3 |= (1U <<\ 00980 ((__INTERRUPT__) & UART_IT_MASK)))) 00981 00982 /** @brief Disable the specified UART interrupt. 00983 * @param __HANDLE__ specifies the UART Handle. 00984 * @param __INTERRUPT__ specifies the UART interrupt source to disable. 00985 * This parameter can be one of the following values: 00986 * @arg @ref UART_IT_RXFF RXFIFO Full interrupt 00987 * @arg @ref UART_IT_TXFE TXFIFO Empty interrupt 00988 * @arg @ref UART_IT_RXFT RXFIFO threshold interrupt 00989 * @arg @ref UART_IT_TXFT TXFIFO threshold interrupt 00990 * @arg @ref UART_IT_WUF Wakeup from stop mode interrupt 00991 * @arg @ref UART_IT_CM Character match interrupt 00992 * @arg @ref UART_IT_CTS CTS change interrupt 00993 * @arg @ref UART_IT_LBD LIN Break detection interrupt 00994 * @arg @ref UART_IT_TXE Transmit Data Register empty interrupt 00995 * @arg @ref UART_IT_TXFNF TX FIFO not full interrupt 00996 * @arg @ref UART_IT_TC Transmission complete interrupt 00997 * @arg @ref UART_IT_RXNE Receive Data register not empty interrupt 00998 * @arg @ref UART_IT_RXFNE RXFIFO not empty interrupt 00999 * @arg @ref UART_IT_RTO Receive Timeout interrupt 01000 * @arg @ref UART_IT_IDLE Idle line detection interrupt 01001 * @arg @ref UART_IT_PE Parity Error interrupt 01002 * @arg @ref UART_IT_ERR Error interrupt (Frame error, noise error, overrun error) 01003 * @retval None 01004 */ 01005 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (\ 01006 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)?\ 01007 ((__HANDLE__)->Instance->CR1 &= ~ (1U <<\ 01008 ((__INTERRUPT__) & UART_IT_MASK))): \ 01009 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)?\ 01010 ((__HANDLE__)->Instance->CR2 &= ~ (1U <<\ 01011 ((__INTERRUPT__) & UART_IT_MASK))): \ 01012 ((__HANDLE__)->Instance->CR3 &= ~ (1U <<\ 01013 ((__INTERRUPT__) & UART_IT_MASK)))) 01014 01015 /** @brief Check whether the specified UART interrupt has occurred or not. 01016 * @param __HANDLE__ specifies the UART Handle. 01017 * @param __INTERRUPT__ specifies the UART interrupt to check. 01018 * This parameter can be one of the following values: 01019 * @arg @ref UART_IT_RXFF RXFIFO Full interrupt 01020 * @arg @ref UART_IT_TXFE TXFIFO Empty interrupt 01021 * @arg @ref UART_IT_RXFT RXFIFO threshold interrupt 01022 * @arg @ref UART_IT_TXFT TXFIFO threshold interrupt 01023 * @arg @ref UART_IT_WUF Wakeup from stop mode interrupt 01024 * @arg @ref UART_IT_CM Character match interrupt 01025 * @arg @ref UART_IT_CTS CTS change interrupt 01026 * @arg @ref UART_IT_LBD LIN Break detection interrupt 01027 * @arg @ref UART_IT_TXE Transmit Data Register empty interrupt 01028 * @arg @ref UART_IT_TXFNF TX FIFO not full interrupt 01029 * @arg @ref UART_IT_TC Transmission complete interrupt 01030 * @arg @ref UART_IT_RXNE Receive Data register not empty interrupt 01031 * @arg @ref UART_IT_RXFNE RXFIFO not empty interrupt 01032 * @arg @ref UART_IT_RTO Receive Timeout interrupt 01033 * @arg @ref UART_IT_IDLE Idle line detection interrupt 01034 * @arg @ref UART_IT_PE Parity Error interrupt 01035 * @arg @ref UART_IT_ERR Error interrupt (Frame error, noise error, overrun error) 01036 * @retval The new state of __INTERRUPT__ (SET or RESET). 01037 */ 01038 #define __HAL_UART_GET_IT(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->ISR\ 01039 & (1U << ((__INTERRUPT__)>> 8U))) != RESET) ? SET : RESET) 01040 01041 /** @brief Check whether the specified UART interrupt source is enabled or not. 01042 * @param __HANDLE__ specifies the UART Handle. 01043 * @param __INTERRUPT__ specifies the UART interrupt source to check. 01044 * This parameter can be one of the following values: 01045 * @arg @ref UART_IT_RXFF RXFIFO Full interrupt 01046 * @arg @ref UART_IT_TXFE TXFIFO Empty interrupt 01047 * @arg @ref UART_IT_RXFT RXFIFO threshold interrupt 01048 * @arg @ref UART_IT_TXFT TXFIFO threshold interrupt 01049 * @arg @ref UART_IT_WUF Wakeup from stop mode interrupt 01050 * @arg @ref UART_IT_CM Character match interrupt 01051 * @arg @ref UART_IT_CTS CTS change interrupt 01052 * @arg @ref UART_IT_LBD LIN Break detection interrupt 01053 * @arg @ref UART_IT_TXE Transmit Data Register empty interrupt 01054 * @arg @ref UART_IT_TXFNF TX FIFO not full interrupt 01055 * @arg @ref UART_IT_TC Transmission complete interrupt 01056 * @arg @ref UART_IT_RXNE Receive Data register not empty interrupt 01057 * @arg @ref UART_IT_RXFNE RXFIFO not empty interrupt 01058 * @arg @ref UART_IT_RTO Receive Timeout interrupt 01059 * @arg @ref UART_IT_IDLE Idle line detection interrupt 01060 * @arg @ref UART_IT_PE Parity Error interrupt 01061 * @arg @ref UART_IT_ERR Error interrupt (Frame error, noise error, overrun error) 01062 * @retval The new state of __INTERRUPT__ (SET or RESET). 01063 */ 01064 #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U) ?\ 01065 (__HANDLE__)->Instance->CR1 : \ 01066 (((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U) ?\ 01067 (__HANDLE__)->Instance->CR2 : \ 01068 (__HANDLE__)->Instance->CR3)) & (1U <<\ 01069 (((uint16_t)(__INTERRUPT__)) &\ 01070 UART_IT_MASK))) != RESET) ? SET : RESET) 01071 01072 /** @brief Clear the specified UART ISR flag, in setting the proper ICR register flag. 01073 * @param __HANDLE__ specifies the UART Handle. 01074 * @param __IT_CLEAR__ specifies the interrupt clear register flag that needs to be set 01075 * to clear the corresponding interrupt 01076 * This parameter can be one of the following values: 01077 * @arg @ref UART_CLEAR_PEF Parity Error Clear Flag 01078 * @arg @ref UART_CLEAR_FEF Framing Error Clear Flag 01079 * @arg @ref UART_CLEAR_NEF Noise detected Clear Flag 01080 * @arg @ref UART_CLEAR_OREF Overrun Error Clear Flag 01081 * @arg @ref UART_CLEAR_IDLEF IDLE line detected Clear Flag 01082 * @arg @ref UART_CLEAR_RTOF Receiver timeout clear flag 01083 * @arg @ref UART_CLEAR_TXFECF TXFIFO empty Clear Flag 01084 * @arg @ref UART_CLEAR_TCF Transmission Complete Clear Flag 01085 * @arg @ref UART_CLEAR_LBDF LIN Break Detection Clear Flag 01086 * @arg @ref UART_CLEAR_CTSF CTS Interrupt Clear Flag 01087 * @arg @ref UART_CLEAR_CMF Character Match Clear Flag 01088 * @arg @ref UART_CLEAR_WUF Wake Up from stop mode Clear Flag 01089 * @retval None 01090 */ 01091 #define __HAL_UART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__)) 01092 01093 /** @brief Set a specific UART request flag. 01094 * @param __HANDLE__ specifies the UART Handle. 01095 * @param __REQ__ specifies the request flag to set 01096 * This parameter can be one of the following values: 01097 * @arg @ref UART_AUTOBAUD_REQUEST Auto-Baud Rate Request 01098 * @arg @ref UART_SENDBREAK_REQUEST Send Break Request 01099 * @arg @ref UART_MUTE_MODE_REQUEST Mute Mode Request 01100 * @arg @ref UART_RXDATA_FLUSH_REQUEST Receive Data flush Request 01101 * @arg @ref UART_TXDATA_FLUSH_REQUEST Transmit data flush Request 01102 * @retval None 01103 */ 01104 #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__)) 01105 01106 /** @brief Enable the UART one bit sample method. 01107 * @param __HANDLE__ specifies the UART Handle. 01108 * @retval None 01109 */ 01110 #define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT) 01111 01112 /** @brief Disable the UART one bit sample method. 01113 * @param __HANDLE__ specifies the UART Handle. 01114 * @retval None 01115 */ 01116 #define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= ~USART_CR3_ONEBIT) 01117 01118 /** @brief Enable UART. 01119 * @param __HANDLE__ specifies the UART Handle. 01120 * @retval None 01121 */ 01122 #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) 01123 01124 /** @brief Disable UART. 01125 * @param __HANDLE__ specifies the UART Handle. 01126 * @retval None 01127 */ 01128 #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) 01129 01130 /** @brief Enable CTS flow control. 01131 * @note This macro allows to enable CTS hardware flow control for a given UART instance, 01132 * without need to call HAL_UART_Init() function. 01133 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. 01134 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need 01135 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : 01136 * - UART instance should have already been initialised (through call of HAL_UART_Init() ) 01137 * - macro could only be called when corresponding UART instance is disabled 01138 * (i.e. __HAL_UART_DISABLE(__HANDLE__)) and should be followed by an Enable 01139 * macro (i.e. __HAL_UART_ENABLE(__HANDLE__)). 01140 * @param __HANDLE__ specifies the UART Handle. 01141 * @retval None 01142 */ 01143 #define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \ 01144 do{ \ 01145 ATOMIC_SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \ 01146 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \ 01147 } while(0U) 01148 01149 /** @brief Disable CTS flow control. 01150 * @note This macro allows to disable CTS hardware flow control for a given UART instance, 01151 * without need to call HAL_UART_Init() function. 01152 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. 01153 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need 01154 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : 01155 * - UART instance should have already been initialised (through call of HAL_UART_Init() ) 01156 * - macro could only be called when corresponding UART instance is disabled 01157 * (i.e. __HAL_UART_DISABLE(__HANDLE__)) and should be followed by an Enable 01158 * macro (i.e. __HAL_UART_ENABLE(__HANDLE__)). 01159 * @param __HANDLE__ specifies the UART Handle. 01160 * @retval None 01161 */ 01162 #define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \ 01163 do{ \ 01164 ATOMIC_CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \ 01165 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \ 01166 } while(0U) 01167 01168 /** @brief Enable RTS flow control. 01169 * @note This macro allows to enable RTS hardware flow control for a given UART instance, 01170 * without need to call HAL_UART_Init() function. 01171 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. 01172 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need 01173 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : 01174 * - UART instance should have already been initialised (through call of HAL_UART_Init() ) 01175 * - macro could only be called when corresponding UART instance is disabled 01176 * (i.e. __HAL_UART_DISABLE(__HANDLE__)) and should be followed by an Enable 01177 * macro (i.e. __HAL_UART_ENABLE(__HANDLE__)). 01178 * @param __HANDLE__ specifies the UART Handle. 01179 * @retval None 01180 */ 01181 #define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \ 01182 do{ \ 01183 ATOMIC_SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \ 01184 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \ 01185 } while(0U) 01186 01187 /** @brief Disable RTS flow control. 01188 * @note This macro allows to disable RTS hardware flow control for a given UART instance, 01189 * without need to call HAL_UART_Init() function. 01190 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. 01191 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need 01192 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : 01193 * - UART instance should have already been initialised (through call of HAL_UART_Init() ) 01194 * - macro could only be called when corresponding UART instance is disabled 01195 * (i.e. __HAL_UART_DISABLE(__HANDLE__)) and should be followed by an Enable 01196 * macro (i.e. __HAL_UART_ENABLE(__HANDLE__)). 01197 * @param __HANDLE__ specifies the UART Handle. 01198 * @retval None 01199 */ 01200 #define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \ 01201 do{ \ 01202 ATOMIC_CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\ 01203 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \ 01204 } while(0U) 01205 /** 01206 * @} 01207 */ 01208 01209 /* Private macros --------------------------------------------------------*/ 01210 /** @defgroup UART_Private_Macros UART Private Macros 01211 * @{ 01212 */ 01213 /** @brief Get UART clok division factor from clock prescaler value. 01214 * @param __CLOCKPRESCALER__ UART prescaler value. 01215 * @retval UART clock division factor 01216 */ 01217 #define UART_GET_DIV_FACTOR(__CLOCKPRESCALER__) \ 01218 (((__CLOCKPRESCALER__) == UART_PRESCALER_DIV1) ? 1U : \ 01219 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV2) ? 2U : \ 01220 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV4) ? 4U : \ 01221 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV6) ? 6U : \ 01222 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV8) ? 8U : \ 01223 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV10) ? 10U : \ 01224 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV12) ? 12U : \ 01225 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV16) ? 16U : \ 01226 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV32) ? 32U : \ 01227 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV64) ? 64U : \ 01228 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV128) ? 128U : \ 01229 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV256) ? 256U : 1U) 01230 01231 /** @brief BRR division operation to set BRR register with LPUART. 01232 * @param __PCLK__ LPUART clock. 01233 * @param __BAUD__ Baud rate set by the user. 01234 * @param __CLOCKPRESCALER__ UART prescaler value. 01235 * @retval Division result 01236 */ 01237 #define UART_DIV_LPUART(__PCLK__, __BAUD__, __CLOCKPRESCALER__) \ 01238 ((uint32_t)((((((uint64_t)(__PCLK__))/(UARTPrescTable[(__CLOCKPRESCALER__)]))*256U)+ \ 01239 (uint32_t)((__BAUD__)/2U)) / (__BAUD__)) \ 01240 ) 01241 01242 /** @brief BRR division operation to set BRR register in 8-bit oversampling mode. 01243 * @param __PCLK__ UART clock. 01244 * @param __BAUD__ Baud rate set by the user. 01245 * @param __CLOCKPRESCALER__ UART prescaler value. 01246 * @retval Division result 01247 */ 01248 #define UART_DIV_SAMPLING8(__PCLK__, __BAUD__, __CLOCKPRESCALER__) \ 01249 (((((__PCLK__)/UARTPrescTable[(__CLOCKPRESCALER__)])*2U) + ((__BAUD__)/2U)) / (__BAUD__)) 01250 01251 /** @brief BRR division operation to set BRR register in 16-bit oversampling mode. 01252 * @param __PCLK__ UART clock. 01253 * @param __BAUD__ Baud rate set by the user. 01254 * @param __CLOCKPRESCALER__ UART prescaler value. 01255 * @retval Division result 01256 */ 01257 #define UART_DIV_SAMPLING16(__PCLK__, __BAUD__, __CLOCKPRESCALER__) \ 01258 ((((__PCLK__)/UARTPrescTable[(__CLOCKPRESCALER__)]) + ((__BAUD__)/2U)) / (__BAUD__)) 01259 01260 /** @brief Check whether or not UART instance is Low Power UART. 01261 * @param __HANDLE__ specifies the UART Handle. 01262 * @retval SET (instance is LPUART) or RESET (instance isn't LPUART) 01263 */ 01264 #define UART_INSTANCE_LOWPOWER(__HANDLE__) (IS_LPUART_INSTANCE((__HANDLE__)->Instance)) 01265 01266 /** @brief Check UART Baud rate. 01267 * @param __BAUDRATE__ Baudrate specified by the user. 01268 * The maximum Baud Rate is derived from the maximum clock on H7 (i.e. 100 MHz) 01269 * divided by the smallest oversampling used on the USART (i.e. 8) 01270 * @retval SET (__BAUDRATE__ is valid) or RESET (__BAUDRATE__ is invalid) 01271 */ 01272 #define IS_UART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 12500001U) 01273 01274 /** @brief Check UART assertion time. 01275 * @param __TIME__ 5-bit value assertion time. 01276 * @retval Test result (TRUE or FALSE). 01277 */ 01278 #define IS_UART_ASSERTIONTIME(__TIME__) ((__TIME__) <= 0x1FU) 01279 01280 /** @brief Check UART deassertion time. 01281 * @param __TIME__ 5-bit value deassertion time. 01282 * @retval Test result (TRUE or FALSE). 01283 */ 01284 #define IS_UART_DEASSERTIONTIME(__TIME__) ((__TIME__) <= 0x1FU) 01285 01286 /** 01287 * @brief Ensure that UART frame number of stop bits is valid. 01288 * @param __STOPBITS__ UART frame number of stop bits. 01289 * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid) 01290 */ 01291 #define IS_UART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_0_5) || \ 01292 ((__STOPBITS__) == UART_STOPBITS_1) || \ 01293 ((__STOPBITS__) == UART_STOPBITS_1_5) || \ 01294 ((__STOPBITS__) == UART_STOPBITS_2)) 01295 01296 /** 01297 * @brief Ensure that LPUART frame number of stop bits is valid. 01298 * @param __STOPBITS__ LPUART frame number of stop bits. 01299 * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid) 01300 */ 01301 #define IS_LPUART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_1) || \ 01302 ((__STOPBITS__) == UART_STOPBITS_2)) 01303 01304 /** 01305 * @brief Ensure that UART frame parity is valid. 01306 * @param __PARITY__ UART frame parity. 01307 * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid) 01308 */ 01309 #define IS_UART_PARITY(__PARITY__) (((__PARITY__) == UART_PARITY_NONE) || \ 01310 ((__PARITY__) == UART_PARITY_EVEN) || \ 01311 ((__PARITY__) == UART_PARITY_ODD)) 01312 01313 /** 01314 * @brief Ensure that UART hardware flow control is valid. 01315 * @param __CONTROL__ UART hardware flow control. 01316 * @retval SET (__CONTROL__ is valid) or RESET (__CONTROL__ is invalid) 01317 */ 01318 #define IS_UART_HARDWARE_FLOW_CONTROL(__CONTROL__)\ 01319 (((__CONTROL__) == UART_HWCONTROL_NONE) || \ 01320 ((__CONTROL__) == UART_HWCONTROL_RTS) || \ 01321 ((__CONTROL__) == UART_HWCONTROL_CTS) || \ 01322 ((__CONTROL__) == UART_HWCONTROL_RTS_CTS)) 01323 01324 /** 01325 * @brief Ensure that UART communication mode is valid. 01326 * @param __MODE__ UART communication mode. 01327 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) 01328 */ 01329 #define IS_UART_MODE(__MODE__) ((((__MODE__) & (~((uint32_t)(UART_MODE_TX_RX)))) == 0x00U) && ((__MODE__) != 0x00U)) 01330 01331 /** 01332 * @brief Ensure that UART state is valid. 01333 * @param __STATE__ UART state. 01334 * @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid) 01335 */ 01336 #define IS_UART_STATE(__STATE__) (((__STATE__) == UART_STATE_DISABLE) || \ 01337 ((__STATE__) == UART_STATE_ENABLE)) 01338 01339 /** 01340 * @brief Ensure that UART oversampling is valid. 01341 * @param __SAMPLING__ UART oversampling. 01342 * @retval SET (__SAMPLING__ is valid) or RESET (__SAMPLING__ is invalid) 01343 */ 01344 #define IS_UART_OVERSAMPLING(__SAMPLING__) (((__SAMPLING__) == UART_OVERSAMPLING_16) || \ 01345 ((__SAMPLING__) == UART_OVERSAMPLING_8)) 01346 01347 /** 01348 * @brief Ensure that UART frame sampling is valid. 01349 * @param __ONEBIT__ UART frame sampling. 01350 * @retval SET (__ONEBIT__ is valid) or RESET (__ONEBIT__ is invalid) 01351 */ 01352 #define IS_UART_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == UART_ONE_BIT_SAMPLE_DISABLE) || \ 01353 ((__ONEBIT__) == UART_ONE_BIT_SAMPLE_ENABLE)) 01354 01355 /** 01356 * @brief Ensure that UART auto Baud rate detection mode is valid. 01357 * @param __MODE__ UART auto Baud rate detection mode. 01358 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) 01359 */ 01360 #define IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(__MODE__) (((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT) || \ 01361 ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE) || \ 01362 ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME) || \ 01363 ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME)) 01364 01365 /** 01366 * @brief Ensure that UART receiver timeout setting is valid. 01367 * @param __TIMEOUT__ UART receiver timeout setting. 01368 * @retval SET (__TIMEOUT__ is valid) or RESET (__TIMEOUT__ is invalid) 01369 */ 01370 #define IS_UART_RECEIVER_TIMEOUT(__TIMEOUT__) (((__TIMEOUT__) == UART_RECEIVER_TIMEOUT_DISABLE) || \ 01371 ((__TIMEOUT__) == UART_RECEIVER_TIMEOUT_ENABLE)) 01372 01373 /** @brief Check the receiver timeout value. 01374 * @note The maximum UART receiver timeout value is 0xFFFFFF. 01375 * @param __TIMEOUTVALUE__ receiver timeout value. 01376 * @retval Test result (TRUE or FALSE) 01377 */ 01378 #define IS_UART_RECEIVER_TIMEOUT_VALUE(__TIMEOUTVALUE__) ((__TIMEOUTVALUE__) <= 0xFFFFFFU) 01379 01380 /** 01381 * @brief Ensure that UART LIN state is valid. 01382 * @param __LIN__ UART LIN state. 01383 * @retval SET (__LIN__ is valid) or RESET (__LIN__ is invalid) 01384 */ 01385 #define IS_UART_LIN(__LIN__) (((__LIN__) == UART_LIN_DISABLE) || \ 01386 ((__LIN__) == UART_LIN_ENABLE)) 01387 01388 /** 01389 * @brief Ensure that UART LIN break detection length is valid. 01390 * @param __LENGTH__ UART LIN break detection length. 01391 * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid) 01392 */ 01393 #define IS_UART_LIN_BREAK_DETECT_LENGTH(__LENGTH__) (((__LENGTH__) == UART_LINBREAKDETECTLENGTH_10B) || \ 01394 ((__LENGTH__) == UART_LINBREAKDETECTLENGTH_11B)) 01395 01396 /** 01397 * @brief Ensure that UART DMA TX state is valid. 01398 * @param __DMATX__ UART DMA TX state. 01399 * @retval SET (__DMATX__ is valid) or RESET (__DMATX__ is invalid) 01400 */ 01401 #define IS_UART_DMA_TX(__DMATX__) (((__DMATX__) == UART_DMA_TX_DISABLE) || \ 01402 ((__DMATX__) == UART_DMA_TX_ENABLE)) 01403 01404 /** 01405 * @brief Ensure that UART DMA RX state is valid. 01406 * @param __DMARX__ UART DMA RX state. 01407 * @retval SET (__DMARX__ is valid) or RESET (__DMARX__ is invalid) 01408 */ 01409 #define IS_UART_DMA_RX(__DMARX__) (((__DMARX__) == UART_DMA_RX_DISABLE) || \ 01410 ((__DMARX__) == UART_DMA_RX_ENABLE)) 01411 01412 /** 01413 * @brief Ensure that UART half-duplex state is valid. 01414 * @param __HDSEL__ UART half-duplex state. 01415 * @retval SET (__HDSEL__ is valid) or RESET (__HDSEL__ is invalid) 01416 */ 01417 #define IS_UART_HALF_DUPLEX(__HDSEL__) (((__HDSEL__) == UART_HALF_DUPLEX_DISABLE) || \ 01418 ((__HDSEL__) == UART_HALF_DUPLEX_ENABLE)) 01419 01420 /** 01421 * @brief Ensure that UART wake-up method is valid. 01422 * @param __WAKEUP__ UART wake-up method . 01423 * @retval SET (__WAKEUP__ is valid) or RESET (__WAKEUP__ is invalid) 01424 */ 01425 #define IS_UART_WAKEUPMETHOD(__WAKEUP__) (((__WAKEUP__) == UART_WAKEUPMETHOD_IDLELINE) || \ 01426 ((__WAKEUP__) == UART_WAKEUPMETHOD_ADDRESSMARK)) 01427 01428 /** 01429 * @brief Ensure that UART request parameter is valid. 01430 * @param __PARAM__ UART request parameter. 01431 * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid) 01432 */ 01433 #define IS_UART_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == UART_AUTOBAUD_REQUEST) || \ 01434 ((__PARAM__) == UART_SENDBREAK_REQUEST) || \ 01435 ((__PARAM__) == UART_MUTE_MODE_REQUEST) || \ 01436 ((__PARAM__) == UART_RXDATA_FLUSH_REQUEST) || \ 01437 ((__PARAM__) == UART_TXDATA_FLUSH_REQUEST)) 01438 01439 /** 01440 * @brief Ensure that UART advanced features initialization is valid. 01441 * @param __INIT__ UART advanced features initialization. 01442 * @retval SET (__INIT__ is valid) or RESET (__INIT__ is invalid) 01443 */ 01444 #define IS_UART_ADVFEATURE_INIT(__INIT__) ((__INIT__) <= (UART_ADVFEATURE_NO_INIT | \ 01445 UART_ADVFEATURE_TXINVERT_INIT | \ 01446 UART_ADVFEATURE_RXINVERT_INIT | \ 01447 UART_ADVFEATURE_DATAINVERT_INIT | \ 01448 UART_ADVFEATURE_SWAP_INIT | \ 01449 UART_ADVFEATURE_RXOVERRUNDISABLE_INIT | \ 01450 UART_ADVFEATURE_DMADISABLEONERROR_INIT | \ 01451 UART_ADVFEATURE_AUTOBAUDRATE_INIT | \ 01452 UART_ADVFEATURE_MSBFIRST_INIT)) 01453 01454 /** 01455 * @brief Ensure that UART frame TX inversion setting is valid. 01456 * @param __TXINV__ UART frame TX inversion setting. 01457 * @retval SET (__TXINV__ is valid) or RESET (__TXINV__ is invalid) 01458 */ 01459 #define IS_UART_ADVFEATURE_TXINV(__TXINV__) (((__TXINV__) == UART_ADVFEATURE_TXINV_DISABLE) || \ 01460 ((__TXINV__) == UART_ADVFEATURE_TXINV_ENABLE)) 01461 01462 /** 01463 * @brief Ensure that UART frame RX inversion setting is valid. 01464 * @param __RXINV__ UART frame RX inversion setting. 01465 * @retval SET (__RXINV__ is valid) or RESET (__RXINV__ is invalid) 01466 */ 01467 #define IS_UART_ADVFEATURE_RXINV(__RXINV__) (((__RXINV__) == UART_ADVFEATURE_RXINV_DISABLE) || \ 01468 ((__RXINV__) == UART_ADVFEATURE_RXINV_ENABLE)) 01469 01470 /** 01471 * @brief Ensure that UART frame data inversion setting is valid. 01472 * @param __DATAINV__ UART frame data inversion setting. 01473 * @retval SET (__DATAINV__ is valid) or RESET (__DATAINV__ is invalid) 01474 */ 01475 #define IS_UART_ADVFEATURE_DATAINV(__DATAINV__) (((__DATAINV__) == UART_ADVFEATURE_DATAINV_DISABLE) || \ 01476 ((__DATAINV__) == UART_ADVFEATURE_DATAINV_ENABLE)) 01477 01478 /** 01479 * @brief Ensure that UART frame RX/TX pins swap setting is valid. 01480 * @param __SWAP__ UART frame RX/TX pins swap setting. 01481 * @retval SET (__SWAP__ is valid) or RESET (__SWAP__ is invalid) 01482 */ 01483 #define IS_UART_ADVFEATURE_SWAP(__SWAP__) (((__SWAP__) == UART_ADVFEATURE_SWAP_DISABLE) || \ 01484 ((__SWAP__) == UART_ADVFEATURE_SWAP_ENABLE)) 01485 01486 /** 01487 * @brief Ensure that UART frame overrun setting is valid. 01488 * @param __OVERRUN__ UART frame overrun setting. 01489 * @retval SET (__OVERRUN__ is valid) or RESET (__OVERRUN__ is invalid) 01490 */ 01491 #define IS_UART_OVERRUN(__OVERRUN__) (((__OVERRUN__) == UART_ADVFEATURE_OVERRUN_ENABLE) || \ 01492 ((__OVERRUN__) == UART_ADVFEATURE_OVERRUN_DISABLE)) 01493 01494 /** 01495 * @brief Ensure that UART auto Baud rate state is valid. 01496 * @param __AUTOBAUDRATE__ UART auto Baud rate state. 01497 * @retval SET (__AUTOBAUDRATE__ is valid) or RESET (__AUTOBAUDRATE__ is invalid) 01498 */ 01499 #define IS_UART_ADVFEATURE_AUTOBAUDRATE(__AUTOBAUDRATE__) (((__AUTOBAUDRATE__) == \ 01500 UART_ADVFEATURE_AUTOBAUDRATE_DISABLE) || \ 01501 ((__AUTOBAUDRATE__) == UART_ADVFEATURE_AUTOBAUDRATE_ENABLE)) 01502 01503 /** 01504 * @brief Ensure that UART DMA enabling or disabling on error setting is valid. 01505 * @param __DMA__ UART DMA enabling or disabling on error setting. 01506 * @retval SET (__DMA__ is valid) or RESET (__DMA__ is invalid) 01507 */ 01508 #define IS_UART_ADVFEATURE_DMAONRXERROR(__DMA__) (((__DMA__) == UART_ADVFEATURE_DMA_ENABLEONRXERROR) || \ 01509 ((__DMA__) == UART_ADVFEATURE_DMA_DISABLEONRXERROR)) 01510 01511 /** 01512 * @brief Ensure that UART frame MSB first setting is valid. 01513 * @param __MSBFIRST__ UART frame MSB first setting. 01514 * @retval SET (__MSBFIRST__ is valid) or RESET (__MSBFIRST__ is invalid) 01515 */ 01516 #define IS_UART_ADVFEATURE_MSBFIRST(__MSBFIRST__) (((__MSBFIRST__) == UART_ADVFEATURE_MSBFIRST_DISABLE) || \ 01517 ((__MSBFIRST__) == UART_ADVFEATURE_MSBFIRST_ENABLE)) 01518 01519 /** 01520 * @brief Ensure that UART stop mode state is valid. 01521 * @param __STOPMODE__ UART stop mode state. 01522 * @retval SET (__STOPMODE__ is valid) or RESET (__STOPMODE__ is invalid) 01523 */ 01524 #define IS_UART_ADVFEATURE_STOPMODE(__STOPMODE__) (((__STOPMODE__) == UART_ADVFEATURE_STOPMODE_DISABLE) || \ 01525 ((__STOPMODE__) == UART_ADVFEATURE_STOPMODE_ENABLE)) 01526 01527 /** 01528 * @brief Ensure that UART mute mode state is valid. 01529 * @param __MUTE__ UART mute mode state. 01530 * @retval SET (__MUTE__ is valid) or RESET (__MUTE__ is invalid) 01531 */ 01532 #define IS_UART_MUTE_MODE(__MUTE__) (((__MUTE__) == UART_ADVFEATURE_MUTEMODE_DISABLE) || \ 01533 ((__MUTE__) == UART_ADVFEATURE_MUTEMODE_ENABLE)) 01534 01535 /** 01536 * @brief Ensure that UART wake-up selection is valid. 01537 * @param __WAKE__ UART wake-up selection. 01538 * @retval SET (__WAKE__ is valid) or RESET (__WAKE__ is invalid) 01539 */ 01540 #define IS_UART_WAKEUP_SELECTION(__WAKE__) (((__WAKE__) == UART_WAKEUP_ON_ADDRESS) || \ 01541 ((__WAKE__) == UART_WAKEUP_ON_STARTBIT) || \ 01542 ((__WAKE__) == UART_WAKEUP_ON_READDATA_NONEMPTY)) 01543 01544 /** 01545 * @brief Ensure that UART driver enable polarity is valid. 01546 * @param __POLARITY__ UART driver enable polarity. 01547 * @retval SET (__POLARITY__ is valid) or RESET (__POLARITY__ is invalid) 01548 */ 01549 #define IS_UART_DE_POLARITY(__POLARITY__) (((__POLARITY__) == UART_DE_POLARITY_HIGH) || \ 01550 ((__POLARITY__) == UART_DE_POLARITY_LOW)) 01551 01552 /** 01553 * @brief Ensure that UART Prescaler is valid. 01554 * @param __CLOCKPRESCALER__ UART Prescaler value. 01555 * @retval SET (__CLOCKPRESCALER__ is valid) or RESET (__CLOCKPRESCALER__ is invalid) 01556 */ 01557 #define IS_UART_PRESCALER(__CLOCKPRESCALER__) (((__CLOCKPRESCALER__) == UART_PRESCALER_DIV1) || \ 01558 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV2) || \ 01559 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV4) || \ 01560 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV6) || \ 01561 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV8) || \ 01562 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV10) || \ 01563 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV12) || \ 01564 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV16) || \ 01565 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV32) || \ 01566 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV64) || \ 01567 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV128) || \ 01568 ((__CLOCKPRESCALER__) == UART_PRESCALER_DIV256)) 01569 01570 /** 01571 * @} 01572 */ 01573 01574 /* Include UART HAL Extended module */ 01575 #include "stm32h7xx_hal_uart_ex.h" 01576 01577 /* Exported functions --------------------------------------------------------*/ 01578 /** @addtogroup UART_Exported_Functions UART Exported Functions 01579 * @{ 01580 */ 01581 01582 /** @addtogroup UART_Exported_Functions_Group1 Initialization and de-initialization functions 01583 * @{ 01584 */ 01585 01586 /* Initialization and de-initialization functions ****************************/ 01587 HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart); 01588 HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart); 01589 HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength); 01590 HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod); 01591 HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart); 01592 void HAL_UART_MspInit(UART_HandleTypeDef *huart); 01593 void HAL_UART_MspDeInit(UART_HandleTypeDef *huart); 01594 01595 /* Callbacks Register/UnRegister functions ***********************************/ 01596 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) 01597 HAL_StatusTypeDef HAL_UART_RegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID, 01598 pUART_CallbackTypeDef pCallback); 01599 HAL_StatusTypeDef HAL_UART_UnRegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID); 01600 01601 HAL_StatusTypeDef HAL_UART_RegisterRxEventCallback(UART_HandleTypeDef *huart, pUART_RxEventCallbackTypeDef pCallback); 01602 HAL_StatusTypeDef HAL_UART_UnRegisterRxEventCallback(UART_HandleTypeDef *huart); 01603 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */ 01604 01605 /** 01606 * @} 01607 */ 01608 01609 /** @addtogroup UART_Exported_Functions_Group2 IO operation functions 01610 * @{ 01611 */ 01612 01613 /* IO operation functions *****************************************************/ 01614 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, const uint8_t *pData, uint16_t Size, uint32_t Timeout); 01615 HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout); 01616 HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, const uint8_t *pData, uint16_t Size); 01617 HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size); 01618 HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, const uint8_t *pData, uint16_t Size); 01619 HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size); 01620 HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart); 01621 HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart); 01622 HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart); 01623 /* Transfer Abort functions */ 01624 HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart); 01625 HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart); 01626 HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart); 01627 HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart); 01628 HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart); 01629 HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart); 01630 01631 void HAL_UART_IRQHandler(UART_HandleTypeDef *huart); 01632 void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart); 01633 void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart); 01634 void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart); 01635 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart); 01636 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart); 01637 void HAL_UART_AbortCpltCallback(UART_HandleTypeDef *huart); 01638 void HAL_UART_AbortTransmitCpltCallback(UART_HandleTypeDef *huart); 01639 void HAL_UART_AbortReceiveCpltCallback(UART_HandleTypeDef *huart); 01640 01641 void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size); 01642 01643 /** 01644 * @} 01645 */ 01646 01647 /** @addtogroup UART_Exported_Functions_Group3 Peripheral Control functions 01648 * @{ 01649 */ 01650 01651 /* Peripheral Control functions ************************************************/ 01652 void HAL_UART_ReceiverTimeout_Config(UART_HandleTypeDef *huart, uint32_t TimeoutValue); 01653 HAL_StatusTypeDef HAL_UART_EnableReceiverTimeout(UART_HandleTypeDef *huart); 01654 HAL_StatusTypeDef HAL_UART_DisableReceiverTimeout(UART_HandleTypeDef *huart); 01655 01656 HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart); 01657 HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart); 01658 HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart); 01659 void HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart); 01660 HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart); 01661 HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart); 01662 01663 /** 01664 * @} 01665 */ 01666 01667 /** @addtogroup UART_Exported_Functions_Group4 Peripheral State and Error functions 01668 * @{ 01669 */ 01670 01671 /* Peripheral State and Errors functions **************************************************/ 01672 HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart); 01673 uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart); 01674 01675 /** 01676 * @} 01677 */ 01678 01679 /** 01680 * @} 01681 */ 01682 01683 /* Private functions -----------------------------------------------------------*/ 01684 /** @addtogroup UART_Private_Functions UART Private Functions 01685 * @{ 01686 */ 01687 #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) 01688 void UART_InitCallbacksToDefault(UART_HandleTypeDef *huart); 01689 #endif /* USE_HAL_UART_REGISTER_CALLBACKS */ 01690 HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart); 01691 HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart); 01692 HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, 01693 uint32_t Tickstart, uint32_t Timeout); 01694 void UART_AdvFeatureConfig(UART_HandleTypeDef *huart); 01695 HAL_StatusTypeDef UART_Start_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size); 01696 HAL_StatusTypeDef UART_Start_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size); 01697 01698 /** 01699 * @} 01700 */ 01701 01702 /* Private variables -----------------------------------------------------------*/ 01703 /** @defgroup UART_Private_variables UART Private variables 01704 * @{ 01705 */ 01706 /* Prescaler Table used in BRR computation macros. 01707 Declared as extern here to allow use of private UART macros, outside of HAL UART functions */ 01708 extern const uint16_t UARTPrescTable[12]; 01709 /** 01710 * @} 01711 */ 01712 01713 /** 01714 * @} 01715 */ 01716 01717 /** 01718 * @} 01719 */ 01720 01721 #ifdef __cplusplus 01722 } 01723 #endif 01724 01725 #endif /* STM32H7xx_HAL_UART_H */ 01726