Updated and Validated
[betaflight.git] / lib / main / STM32F3 / Drivers / STM32F3xx_HAL_Driver / Inc / stm32f3xx_hal_uart.h
blobc63fbb49ea24e6ed22ef61b0db7dd121cc5e5a9e
1 /**
2 ******************************************************************************
3 * @file stm32f3xx_hal_uart.h
4 * @author MCD Application Team
5 * @brief Header file of UART HAL module.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ******************************************************************************
36 /* Define to prevent recursive inclusion -------------------------------------*/
37 #ifndef __STM32F3xx_HAL_UART_H
38 #define __STM32F3xx_HAL_UART_H
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
44 /* Includes ------------------------------------------------------------------*/
45 #include "stm32f3xx_hal_def.h"
47 /** @addtogroup STM32F3xx_HAL_Driver
48 * @{
51 /** @addtogroup UART
52 * @{
55 /* Exported types ------------------------------------------------------------*/
56 /** @defgroup UART_Exported_Types UART Exported Types
57 * @{
60 /**
61 * @brief UART Init Structure definition
63 typedef struct
65 uint32_t BaudRate; /*!< This member configures the UART communication baud rate.
66 The baud rate register is computed using the following formula:
67 - If oversampling is 16 or in LIN mode,
68 Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate)))
69 - If oversampling is 8U,
70 Baud Rate Register[15:4] = ((2U * PCLKx) / ((huart->Init.BaudRate)))[15:4]
71 Baud Rate Register[3] = 0
72 Baud Rate Register[2:0] = (((2U * PCLKx) / ((huart->Init.BaudRate)))[3:0]) >> 1 */
74 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
75 This parameter can be a value of @ref UARTEx_Word_Length. */
77 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
78 This parameter can be a value of @ref UART_Stop_Bits. */
80 uint32_t Parity; /*!< Specifies the parity mode.
81 This parameter can be a value of @ref UART_Parity
82 @note When parity is enabled, the computed parity is inserted
83 at the MSB position of the transmitted data (9th bit when
84 the word length is set to 9 data bits; 8th bit when the
85 word length is set to 8 data bits). */
87 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
88 This parameter can be a value of @ref UART_Mode. */
90 uint32_t HwFlowCtl; /*!< Specifies whether the hardware flow control mode is enabled
91 or disabled.
92 This parameter can be a value of @ref UART_Hardware_Flow_Control. */
94 uint32_t OverSampling; /*!< Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to f_PCLK/8U).
95 This parameter can be a value of @ref UART_Over_Sampling. */
97 uint32_t OneBitSampling; /*!< Specifies whether a single sample or three samples' majority vote is selected.
98 Selecting the single sample method increases the receiver tolerance to clock
99 deviations. This parameter can be a value of @ref UART_OneBit_Sampling. */
100 }UART_InitTypeDef;
103 * @brief UART Advanced Features initalization structure definition
105 typedef struct
107 uint32_t AdvFeatureInit; /*!< Specifies which advanced UART features is initialized. Several
108 Advanced Features may be initialized at the same time .
109 This parameter can be a value of @ref UART_Advanced_Features_Initialization_Type. */
111 uint32_t TxPinLevelInvert; /*!< Specifies whether the TX pin active level is inverted.
112 This parameter can be a value of @ref UART_Tx_Inv. */
114 uint32_t RxPinLevelInvert; /*!< Specifies whether the RX pin active level is inverted.
115 This parameter can be a value of @ref UART_Rx_Inv. */
117 uint32_t DataInvert; /*!< Specifies whether data are inverted (positive/direct logic
118 vs negative/inverted logic).
119 This parameter can be a value of @ref UART_Data_Inv. */
121 uint32_t Swap; /*!< Specifies whether TX and RX pins are swapped.
122 This parameter can be a value of @ref UART_Rx_Tx_Swap. */
124 uint32_t OverrunDisable; /*!< Specifies whether the reception overrun detection is disabled.
125 This parameter can be a value of @ref UART_Overrun_Disable. */
127 uint32_t DMADisableonRxError; /*!< Specifies whether the DMA is disabled in case of reception error.
128 This parameter can be a value of @ref UART_DMA_Disable_on_Rx_Error. */
130 uint32_t AutoBaudRateEnable; /*!< Specifies whether auto Baud rate detection is enabled.
131 This parameter can be a value of @ref UART_AutoBaudRate_Enable */
133 uint32_t AutoBaudRateMode; /*!< If auto Baud rate detection is enabled, specifies how the rate
134 detection is carried out.
135 This parameter can be a value of @ref UART_AutoBaud_Rate_Mode. */
137 uint32_t MSBFirst; /*!< Specifies whether MSB is sent first on UART line.
138 This parameter can be a value of @ref UART_MSB_First. */
139 } UART_AdvFeatureInitTypeDef;
142 * @brief UART wake up from stop mode parameters
144 typedef struct
146 uint32_t WakeUpEvent; /*!< Specifies which event will activat the Wakeup from Stop mode flag (WUF).
147 This parameter can be a value of @ref UART_WakeUp_from_Stop_Selection.
148 If set to UART_WAKEUP_ON_ADDRESS, the two other fields below must
149 be filled up. */
151 uint16_t AddressLength; /*!< Specifies whether the address is 4 or 7-bit long.
152 This parameter can be a value of @ref UART_WakeUp_Address_Length. */
154 uint8_t Address; /*!< UART/USART node address (7-bit long max). */
155 } UART_WakeUpTypeDef;
158 * @brief HAL UART State structures definition
159 * @note HAL UART State value is a combination of 2 different substates: gState and RxState.
160 * - gState contains UART state information related to global Handle management
161 * and also information related to Tx operations.
162 * gState value coding follow below described bitmap :
163 * b7-b6 Error information
164 * 00 : No Error
165 * 01 : (Not Used)
166 * 10 : Timeout
167 * 11 : Error
168 * b5 IP initilisation status
169 * 0 : Reset (IP not initialized)
170 * 1 : Init done (IP not initialized. HAL UART Init function already called)
171 * b4-b3 (not used)
172 * xx : Should be set to 00
173 * b2 Intrinsic process state
174 * 0 : Ready
175 * 1 : Busy (IP busy with some configuration or internal operations)
176 * b1 (not used)
177 * x : Should be set to 0
178 * b0 Tx state
179 * 0 : Ready (no Tx operation ongoing)
180 * 1 : Busy (Tx operation ongoing)
181 * - RxState contains information related to Rx operations.
182 * RxState value coding follow below described bitmap :
183 * b7-b6 (not used)
184 * xx : Should be set to 00
185 * b5 IP initilisation status
186 * 0 : Reset (IP not initialized)
187 * 1 : Init done (IP not initialized)
188 * b4-b2 (not used)
189 * xxx : Should be set to 000
190 * b1 Rx state
191 * 0 : Ready (no Rx operation ongoing)
192 * 1 : Busy (Rx operation ongoing)
193 * b0 (not used)
194 * x : Should be set to 0.
196 typedef enum
198 HAL_UART_STATE_RESET = 0x00U, /*!< Peripheral is not initialized
199 Value is allowed for gState and RxState */
200 HAL_UART_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use
201 Value is allowed for gState and RxState */
202 HAL_UART_STATE_BUSY = 0x24U, /*!< an internal process is ongoing
203 Value is allowed for gState only */
204 HAL_UART_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing
205 Value is allowed for gState only */
206 HAL_UART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing
207 Value is allowed for RxState only */
208 HAL_UART_STATE_BUSY_TX_RX = 0x23U, /*!< Data Transmission and Reception process is ongoing
209 Not to be used for neither gState nor RxState.
210 Value is result of combination (Or) between gState and RxState values */
211 HAL_UART_STATE_TIMEOUT = 0xA0U, /*!< Timeout state
212 Value is allowed for gState only */
213 HAL_UART_STATE_ERROR = 0xE0U /*!< Error
214 Value is allowed for gState only */
215 }HAL_UART_StateTypeDef;
218 * @brief UART clock sources definition
220 typedef enum
222 UART_CLOCKSOURCE_PCLK1 = 0x00U, /*!< PCLK1 clock source */
223 UART_CLOCKSOURCE_PCLK2 = 0x01U, /*!< PCLK2 clock source */
224 UART_CLOCKSOURCE_HSI = 0x02U, /*!< HSI clock source */
225 UART_CLOCKSOURCE_SYSCLK = 0x04U, /*!< SYSCLK clock source */
226 UART_CLOCKSOURCE_LSE = 0x08U, /*!< LSE clock source */
227 UART_CLOCKSOURCE_UNDEFINED = 0x10U /*!< Undefined clock source */
228 }UART_ClockSourceTypeDef;
231 * @brief UART handle Structure definition
233 typedef struct
235 USART_TypeDef *Instance; /*!< UART registers base address */
237 UART_InitTypeDef Init; /*!< UART communication parameters */
239 UART_AdvFeatureInitTypeDef AdvancedInit; /*!< UART Advanced Features initialization parameters */
241 uint8_t *pTxBuffPtr; /*!< Pointer to UART Tx transfer Buffer */
243 uint16_t TxXferSize; /*!< UART Tx Transfer size */
245 __IO uint16_t TxXferCount; /*!< UART Tx Transfer Counter */
247 uint8_t *pRxBuffPtr; /*!< Pointer to UART Rx transfer Buffer */
249 uint16_t RxXferSize; /*!< UART Rx Transfer size */
251 __IO uint16_t RxXferCount; /*!< UART Rx Transfer Counter */
253 uint16_t Mask; /*!< UART Rx RDR register mask */
255 DMA_HandleTypeDef *hdmatx; /*!< UART Tx DMA Handle parameters */
257 DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */
259 HAL_LockTypeDef Lock; /*!< Locking object */
261 __IO HAL_UART_StateTypeDef gState; /*!< UART state information related to global Handle management
262 and also related to Tx operations.
263 This parameter can be a value of @ref HAL_UART_StateTypeDef */
265 __IO HAL_UART_StateTypeDef RxState; /*!< UART state information related to Rx operations.
266 This parameter can be a value of @ref HAL_UART_StateTypeDef */
268 __IO uint32_t ErrorCode; /*!< UART Error code */
270 }UART_HandleTypeDef;
273 * @}
276 /* Exported constants --------------------------------------------------------*/
277 /** @defgroup UART_Exported_Constants UART Exported Constants
278 * @{
281 /** @defgroup UART_Error UART Error
282 * @{
284 #define HAL_UART_ERROR_NONE (0x00000000U) /*!< No error */
285 #define HAL_UART_ERROR_PE (0x00000001U) /*!< Parity error */
286 #define HAL_UART_ERROR_NE (0x00000002U) /*!< Noise error */
287 #define HAL_UART_ERROR_FE (0x00000004U) /*!< frame error */
288 #define HAL_UART_ERROR_ORE (0x00000008U) /*!< Overrun error */
289 #define HAL_UART_ERROR_DMA (0x00000010U) /*!< DMA transfer error */
290 #define HAL_UART_ERROR_BUSY (0x00000020U) /*!< Busy Error */
292 * @}
295 /** @defgroup UART_Stop_Bits UART Number of Stop Bits
296 * @{
298 #define UART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< UART frame with 0.5 stop bit */
299 #define UART_STOPBITS_1 (0x00000000U) /*!< UART frame with 1 stop bit */
300 #define UART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) /*!< UART frame with 1.5 stop bits */
301 #define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) /*!< UART frame with 2 stop bits */
303 * @}
306 /** @defgroup UART_Parity UART Parity
307 * @{
309 #define UART_PARITY_NONE (0x00000000U) /*!< No parity */
310 #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE) /*!< Even parity */
311 #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) /*!< Odd parity */
313 * @}
316 /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
317 * @{
319 #define UART_HWCONTROL_NONE (0x00000000U) /*!< No hardware control */
320 #define UART_HWCONTROL_RTS ((uint32_t)USART_CR3_RTSE) /*!< Request To Send */
321 #define UART_HWCONTROL_CTS ((uint32_t)USART_CR3_CTSE) /*!< Clear To Send */
322 #define UART_HWCONTROL_RTS_CTS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE)) /*!< Request and Clear To Send */
324 * @}
327 /** @defgroup UART_Mode UART Transfer Mode
328 * @{
330 #define UART_MODE_RX ((uint32_t)USART_CR1_RE) /*!< RX mode */
331 #define UART_MODE_TX ((uint32_t)USART_CR1_TE) /*!< TX mode */
332 #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) /*!< RX and TX mode */
334 * @}
337 /** @defgroup UART_State UART State
338 * @{
340 #define UART_STATE_DISABLE (0x00000000U) /*!< UART disabled */
341 #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE) /*!< UART enabled */
343 * @}
346 /** @defgroup UART_Over_Sampling UART Over Sampling
347 * @{
349 #define UART_OVERSAMPLING_16 (0x00000000U) /*!< Oversampling by 16U */
350 #define UART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8) /*!< Oversampling by 8 */
352 * @}
355 /** @defgroup UART_OneBit_Sampling UART One Bit Sampling Method
356 * @{
358 #define UART_ONE_BIT_SAMPLE_DISABLE (0x00000000U) /*!< One-bit sampling disable */
359 #define UART_ONE_BIT_SAMPLE_ENABLE ((uint32_t)USART_CR3_ONEBIT) /*!< One-bit sampling enable */
361 * @}
364 /** @defgroup UART_AutoBaud_Rate_Mode UART Advanced Feature AutoBaud Rate Mode
365 * @{
367 #define UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT (0x00000000U) /*!< Auto Baud rate detection on start bit */
368 #define UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE ((uint32_t)USART_CR2_ABRMODE_0) /*!< Auto Baud rate detection on falling edge */
369 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME ((uint32_t)USART_CR2_ABRMODE_1) /*!< Auto Baud rate detection on 0x7F frame detection */
370 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME ((uint32_t)USART_CR2_ABRMODE) /*!< Auto Baud rate detection on 0x55 frame detection */
372 * @}
375 /** @defgroup UART_Receiver_TimeOut UART Receiver TimeOut
376 * @{
378 #define UART_RECEIVER_TIMEOUT_DISABLE (0x00000000U) /*!< UART receiver timeout disable */
379 #define UART_RECEIVER_TIMEOUT_ENABLE ((uint32_t)USART_CR2_RTOEN) /*!< UART receiver timeout enable */
381 * @}
384 /** @defgroup UART_LIN UART Local Interconnection Network mode
385 * @{
387 #define UART_LIN_DISABLE (0x00000000U) /*!< Local Interconnect Network disable */
388 #define UART_LIN_ENABLE ((uint32_t)USART_CR2_LINEN) /*!< Local Interconnect Network enable */
390 * @}
393 /** @defgroup UART_LIN_Break_Detection UART LIN Break Detection
394 * @{
396 #define UART_LINBREAKDETECTLENGTH_10B (0x00000000U) /*!< LIN 10-bit break detection length */
397 #define UART_LINBREAKDETECTLENGTH_11B ((uint32_t)USART_CR2_LBDL) /*!< LIN 11-bit break detection length */
399 * @}
402 /** @defgroup UART_DMA_Tx UART DMA Tx
403 * @{
405 #define UART_DMA_TX_DISABLE (0x00000000U) /*!< UART DMA TX disabled */
406 #define UART_DMA_TX_ENABLE ((uint32_t)USART_CR3_DMAT) /*!< UART DMA TX enabled */
408 * @}
411 /** @defgroup UART_DMA_Rx UART DMA Rx
412 * @{
414 #define UART_DMA_RX_DISABLE (0x00000000U) /*!< UART DMA RX disabled */
415 #define UART_DMA_RX_ENABLE ((uint32_t)USART_CR3_DMAR) /*!< UART DMA RX enabled */
417 * @}
420 /** @defgroup UART_Half_Duplex_Selection UART Half Duplex Selection
421 * @{
423 #define UART_HALF_DUPLEX_DISABLE (0x00000000U) /*!< UART half-duplex disabled */
424 #define UART_HALF_DUPLEX_ENABLE ((uint32_t)USART_CR3_HDSEL) /*!< UART half-duplex enabled */
426 * @}
429 /** @defgroup UART_WakeUp_Address_Length UART WakeUp Address Length
430 * @{
432 #define UART_ADDRESS_DETECT_4B (0x00000000U) /*!< 4-bit long wake-up address */
433 #define UART_ADDRESS_DETECT_7B ((uint32_t)USART_CR2_ADDM7) /*!< 7-bit long wake-up address */
435 * @}
438 /** @defgroup UART_WakeUp_Methods UART WakeUp Methods
439 * @{
441 #define UART_WAKEUPMETHOD_IDLELINE (0x00000000U) /*!< UART wake-up on idle line */
442 #define UART_WAKEUPMETHOD_ADDRESSMARK ((uint32_t)USART_CR1_WAKE) /*!< UART wake-up on address mark */
444 * @}
447 /** @defgroup UART_Flags UART Status Flags
448 * Elements values convention: 0xXXXX
449 * - 0xXXXX : Flag mask in the ISR register
450 * @{
452 #define UART_FLAG_REACK (0x00400000U) /*!< UART receive enable acknowledge flag */
453 #define UART_FLAG_TEACK (0x00200000U) /*!< UART transmit enable acknowledge flag */
454 #define UART_FLAG_WUF (0x00100000U) /*!< UART wake-up from stop mode flag */
455 #define UART_FLAG_RWU (0x00080000U) /*!< UART receiver wake-up from mute mode flag */
456 #define UART_FLAG_SBKF (0x00040000U) /*!< UART send break flag */
457 #define UART_FLAG_CMF (0x00020000U) /*!< UART character match flag */
458 #define UART_FLAG_BUSY (0x00010000U) /*!< UART busy flag */
459 #define UART_FLAG_ABRF (0x00008000U) /*!< UART auto Baud rate flag */
460 #define UART_FLAG_ABRE (0x00004000U) /*!< UART auto Baud rate error */
461 #define UART_FLAG_EOBF (0x00001000U) /*!< UART end of block flag */
462 #define UART_FLAG_RTOF (0x00000800U) /*!< UART receiver timeout flag */
463 #define UART_FLAG_CTS (0x00000400U) /*!< UART clear to send flag */
464 #define UART_FLAG_CTSIF (0x00000200U) /*!< UART clear to send interrupt flag */
465 #define UART_FLAG_LBDF (0x00000100U) /*!< UART LIN break detection flag */
466 #define UART_FLAG_TXE (0x00000080U) /*!< UART transmit data register empty */
467 #define UART_FLAG_TC (0x00000040U) /*!< UART transmission complete */
468 #define UART_FLAG_RXNE (0x00000020U) /*!< UART read data register not empty */
469 #define UART_FLAG_IDLE (0x00000010U) /*!< UART idle flag */
470 #define UART_FLAG_ORE (0x00000008U) /*!< UART overrun error */
471 #define UART_FLAG_NE (0x00000004U) /*!< UART noise error */
472 #define UART_FLAG_FE (0x00000002U) /*!< UART frame error */
473 #define UART_FLAG_PE (0x00000001U) /*!< UART parity error */
475 * @}
478 /** @defgroup UART_Interrupt_definition UART Interrupts Definition
479 * Elements values convention: 000ZZZZZ0XXYYYYYb
480 * - YYYYY : Interrupt source position in the XX register (5bits)
481 * - XX : Interrupt source register (2bits)
482 * - 01: CR1 register
483 * - 10: CR2 register
484 * - 11: CR3 register
485 * - ZZZZZ : Flag position in the ISR register(5bits)
486 * @{
488 #define UART_IT_PE (0x0028U) /*!< UART parity error interruption */
489 #define UART_IT_TXE (0x0727U) /*!< UART transmit data register empty interruption */
490 #define UART_IT_TC (0x0626U) /*!< UART transmission complete interruption */
491 #define UART_IT_RXNE (0x0525U) /*!< UART read data register not empty interruption */
492 #define UART_IT_IDLE (0x0424U) /*!< UART idle interruption */
493 #define UART_IT_LBD (0x0846U) /*!< UART LIN break detection interruption */
494 #define UART_IT_CTS (0x096AU) /*!< UART CTS interruption */
495 #define UART_IT_CM (0x112EU) /*!< UART character match interruption */
496 #define UART_IT_WUF (0x1476U) /*!< UART wake-up from stop mode interruption */
497 #define UART_IT_ERR (0x0060U) /*!< UART error interruption */
498 #define UART_IT_ORE (0x0300U) /*!< UART overrun error interruption */
499 #define UART_IT_NE (0x0200U) /*!< UART noise error interruption */
500 #define UART_IT_FE (0x0100U) /*!< UART frame error interruption */
502 * @}
505 /** @defgroup UART_IT_CLEAR_Flags UART Interruption Clear Flags
506 * @{
508 #define UART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
509 #define UART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
510 #define UART_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
511 #define UART_CLEAR_OREF USART_ICR_ORECF /*!< Overrun Error Clear Flag */
512 #define UART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */
513 #define UART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
514 #define UART_CLEAR_LBDF USART_ICR_LBDCF /*!< LIN Break Detection Clear Flag */
515 #define UART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */
516 #define UART_CLEAR_RTOF USART_ICR_RTOCF /*!< Receiver Time Out Clear Flag */
517 #define UART_CLEAR_EOBF USART_ICR_EOBCF /*!< End Of Block Clear Flag */
518 #define UART_CLEAR_CMF USART_ICR_CMCF /*!< Character Match Clear Flag */
519 #define UART_CLEAR_WUF USART_ICR_WUCF /*!< Wake Up from stop mode Clear Flag */
521 * @}
524 /** @defgroup UART_Request_Parameters UART Request Parameters
525 * @{
527 #define UART_AUTOBAUD_REQUEST ((uint32_t)USART_RQR_ABRRQ) /*!< Auto-Baud Rate Request */
528 #define UART_SENDBREAK_REQUEST ((uint32_t)USART_RQR_SBKRQ) /*!< Send Break Request */
529 #define UART_MUTE_MODE_REQUEST ((uint32_t)USART_RQR_MMRQ) /*!< Mute Mode Request */
530 #define UART_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
531 #define UART_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
533 * @}
536 /** @defgroup UART_Advanced_Features_Initialization_Type UART Advanced Feature Initialization Type
537 * @{
539 #define UART_ADVFEATURE_NO_INIT (0x00000000U) /*!< No advanced feature initialization */
540 #define UART_ADVFEATURE_TXINVERT_INIT (0x00000001U) /*!< TX pin active level inversion */
541 #define UART_ADVFEATURE_RXINVERT_INIT (0x00000002U) /*!< RX pin active level inversion */
542 #define UART_ADVFEATURE_DATAINVERT_INIT (0x00000004U) /*!< Binary data inversion */
543 #define UART_ADVFEATURE_SWAP_INIT (0x00000008U) /*!< TX/RX pins swap */
544 #define UART_ADVFEATURE_RXOVERRUNDISABLE_INIT (0x00000010U) /*!< RX overrun disable */
545 #define UART_ADVFEATURE_DMADISABLEONERROR_INIT (0x00000020U) /*!< DMA disable on Reception Error */
546 #define UART_ADVFEATURE_AUTOBAUDRATE_INIT (0x00000040U) /*!< Auto Baud rate detection initialization */
547 #define UART_ADVFEATURE_MSBFIRST_INIT (0x00000080U) /*!< Most significant bit sent/received first */
549 * @}
552 /** @defgroup UART_Tx_Inv UART Advanced Feature TX Pin Active Level Inversion
553 * @{
555 #define UART_ADVFEATURE_TXINV_DISABLE (0x00000000U) /*!< TX pin active level inversion disable */
556 #define UART_ADVFEATURE_TXINV_ENABLE ((uint32_t)USART_CR2_TXINV) /*!< TX pin active level inversion enable */
558 * @}
561 /** @defgroup UART_Rx_Inv UART Advanced Feature RX Pin Active Level Inversion
562 * @{
564 #define UART_ADVFEATURE_RXINV_DISABLE (0x00000000U) /*!< RX pin active level inversion disable */
565 #define UART_ADVFEATURE_RXINV_ENABLE ((uint32_t)USART_CR2_RXINV) /*!< RX pin active level inversion enable */
567 * @}
570 /** @defgroup UART_Data_Inv UART Advanced Feature Binary Data Inversion
571 * @{
573 #define UART_ADVFEATURE_DATAINV_DISABLE (0x00000000U) /*!< Binary data inversion disable */
574 #define UART_ADVFEATURE_DATAINV_ENABLE ((uint32_t)USART_CR2_DATAINV) /*!< Binary data inversion enable */
576 * @}
579 /** @defgroup UART_Rx_Tx_Swap UART Advanced Feature RX TX Pins Swap
580 * @{
582 #define UART_ADVFEATURE_SWAP_DISABLE (0x00000000U) /*!< TX/RX pins swap disable */
583 #define UART_ADVFEATURE_SWAP_ENABLE ((uint32_t)USART_CR2_SWAP) /*!< TX/RX pins swap enable */
585 * @}
588 /** @defgroup UART_Overrun_Disable UART Advanced Feature Overrun Disable
589 * @{
591 #define UART_ADVFEATURE_OVERRUN_ENABLE (0x00000000U) /*!< RX overrun enable */
592 #define UART_ADVFEATURE_OVERRUN_DISABLE ((uint32_t)USART_CR3_OVRDIS) /*!< RX overrun disable */
594 * @}
597 /** @defgroup UART_AutoBaudRate_Enable UART Advanced Feature Auto BaudRate Enable
598 * @{
600 #define UART_ADVFEATURE_AUTOBAUDRATE_DISABLE (0x00000000U) /*!< RX Auto Baud rate detection enable */
601 #define UART_ADVFEATURE_AUTOBAUDRATE_ENABLE ((uint32_t)USART_CR2_ABREN) /*!< RX Auto Baud rate detection disable */
603 * @}
606 /** @defgroup UART_DMA_Disable_on_Rx_Error UART Advanced Feature DMA Disable On Rx Error
607 * @{
609 #define UART_ADVFEATURE_DMA_ENABLEONRXERROR (0x00000000U) /*!< DMA enable on Reception Error */
610 #define UART_ADVFEATURE_DMA_DISABLEONRXERROR ((uint32_t)USART_CR3_DDRE) /*!< DMA disable on Reception Error */
612 * @}
615 /** @defgroup UART_MSB_First UART Advanced Feature MSB First
616 * @{
618 #define UART_ADVFEATURE_MSBFIRST_DISABLE (0x00000000U) /*!< Most significant bit sent/received first disable */
619 #define UART_ADVFEATURE_MSBFIRST_ENABLE ((uint32_t)USART_CR2_MSBFIRST) /*!< Most significant bit sent/received first enable */
621 * @}
624 /** @defgroup UART_Stop_Mode_Enable UART Advanced Feature Stop Mode Enable
625 * @{
627 #define UART_ADVFEATURE_STOPMODE_DISABLE (0x00000000U) /*!< UART stop mode disable */
628 #define UART_ADVFEATURE_STOPMODE_ENABLE ((uint32_t)USART_CR1_UESM) /*!< UART stop mode enable */
630 * @}
633 /** @defgroup UART_Mute_Mode UART Advanced Feature Mute Mode Enable
634 * @{
636 #define UART_ADVFEATURE_MUTEMODE_DISABLE (0x00000000U) /*!< UART mute mode disable */
637 #define UART_ADVFEATURE_MUTEMODE_ENABLE ((uint32_t)USART_CR1_MME) /*!< UART mute mode enable */
639 * @}
642 /** @defgroup UART_CR2_ADDRESS_LSB_POS UART Address-matching LSB Position In CR2 Register
643 * @{
645 #define UART_CR2_ADDRESS_LSB_POS ( 24U) /*!< UART address-matching LSB position in CR2 register */
647 * @}
650 /** @defgroup UART_WakeUp_from_Stop_Selection UART WakeUp From Stop Selection
651 * @{
653 #define UART_WAKEUP_ON_ADDRESS (0x00000000U) /*!< UART wake-up on address */
654 #define UART_WAKEUP_ON_STARTBIT ((uint32_t)USART_CR3_WUS_1) /*!< UART wake-up on start bit */
655 #define UART_WAKEUP_ON_READDATA_NONEMPTY ((uint32_t)USART_CR3_WUS) /*!< UART wake-up on receive data register not empty */
657 * @}
660 /** @defgroup UART_DriverEnable_Polarity UART DriverEnable Polarity
661 * @{
663 #define UART_DE_POLARITY_HIGH (0x00000000U) /*!< Driver enable signal is active high */
664 #define UART_DE_POLARITY_LOW ((uint32_t)USART_CR3_DEP) /*!< Driver enable signal is active low */
666 * @}
669 /** @defgroup UART_CR1_DEAT_ADDRESS_LSB_POS UART Driver Enable Assertion Time LSB Position In CR1 Register
670 * @{
672 #define UART_CR1_DEAT_ADDRESS_LSB_POS ( 21U) /*!< UART Driver Enable assertion time LSB position in CR1 register */
674 * @}
677 /** @defgroup UART_CR1_DEDT_ADDRESS_LSB_POS UART Driver Enable DeAssertion Time LSB Position In CR1 Register
678 * @{
680 #define UART_CR1_DEDT_ADDRESS_LSB_POS ( 16U) /*!< UART Driver Enable de-assertion time LSB position in CR1 register */
682 * @}
685 /** @defgroup UART_Interruption_Mask UART Interruptions Flag Mask
686 * @{
688 #define UART_IT_MASK (0x001FU) /*!< UART interruptions flags mask */
690 * @}
693 /** @defgroup UART_TimeOut_Value UART polling-based communications time-out value
694 * @{
696 #define HAL_UART_TIMEOUT_VALUE 0x1FFFFFF /*!< UART polling-based communications time-out value */
698 * @}
702 * @}
705 /* Exported macros -----------------------------------------------------------*/
706 /** @defgroup UART_Exported_Macros UART Exported Macros
707 * @{
710 /** @brief Reset UART handle states.
711 * @param __HANDLE__ UART handle.
712 * @retval None
714 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \
715 (__HANDLE__)->gState = HAL_UART_STATE_RESET; \
716 (__HANDLE__)->RxState = HAL_UART_STATE_RESET; \
717 } while(0U)
718 /** @brief Flush the UART Data registers.
719 * @param __HANDLE__ specifies the UART Handle.
720 * @retval None
722 #define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) \
723 do{ \
724 SET_BIT((__HANDLE__)->Instance->RQR, UART_RXDATA_FLUSH_REQUEST); \
725 SET_BIT((__HANDLE__)->Instance->RQR, UART_TXDATA_FLUSH_REQUEST); \
726 } while(0U)
728 /** @brief Clear the specified UART pending flag.
729 * @param __HANDLE__ specifies the UART Handle.
730 * @param __FLAG__ specifies the flag to check.
731 * This parameter can be any combination of the following values:
732 * @arg @ref UART_CLEAR_PEF Parity Error Clear Flag
733 * @arg @ref UART_CLEAR_FEF Framing Error Clear Flag
734 * @arg @ref UART_CLEAR_NEF Noise detected Clear Flag
735 * @arg @ref UART_CLEAR_OREF Overrun Error Clear Flag
736 * @arg @ref UART_CLEAR_IDLEF IDLE line detected Clear Flag
737 * @arg @ref UART_CLEAR_TCF Transmission Complete Clear Flag
738 * @arg @ref UART_CLEAR_LBDF LIN Break Detection Clear Flag (not available on all devices)
739 * @arg @ref UART_CLEAR_CTSF CTS Interrupt Clear Flag
740 * @arg @ref UART_CLEAR_RTOF Receiver Time Out Clear Flag
741 * @arg @ref UART_CLEAR_EOBF End Of Block Clear Flag (not available on all devices)
742 * @arg @ref UART_CLEAR_CMF Character Match Clear Flag
743 * @arg @ref UART_CLEAR_WUF Wake Up from stop mode Clear Flag (not available on all devices)
744 * @retval None
746 #define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
748 /** @brief Clear the UART PE pending flag.
749 * @param __HANDLE__ specifies the UART Handle.
750 * @retval None
752 #define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_PEF)
754 /** @brief Clear the UART FE pending flag.
755 * @param __HANDLE__ specifies the UART Handle.
756 * @retval None
758 #define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_FEF)
760 /** @brief Clear the UART NE pending flag.
761 * @param __HANDLE__ specifies the UART Handle.
762 * @retval None
764 #define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_NEF)
766 /** @brief Clear the UART ORE pending flag.
767 * @param __HANDLE__ specifies the UART Handle.
768 * @retval None
770 #define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_OREF)
772 /** @brief Clear the UART IDLE pending flag.
773 * @param __HANDLE__ specifies the UART Handle.
774 * @retval None
776 #define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_IDLEF)
778 /** @brief Check whether the specified UART flag is set or not.
779 * @param __HANDLE__ specifies the UART Handle.
780 * @param __FLAG__ specifies the flag to check.
781 * This parameter can be one of the following values:
782 * @arg @ref UART_FLAG_REACK Receive enable acknowledge flag
783 * @arg @ref UART_FLAG_TEACK Transmit enable acknowledge flag
784 * @arg @ref UART_FLAG_WUF Wake up from stop mode flag
785 * @arg @ref UART_FLAG_RWU Receiver wake up flag
786 * @arg @ref UART_FLAG_SBKF Send Break flag
787 * @arg @ref UART_FLAG_CMF Character match flag
788 * @arg @ref UART_FLAG_BUSY Busy flag
789 * @arg @ref UART_FLAG_ABRF Auto Baud rate detection flag
790 * @arg @ref UART_FLAG_ABRE Auto Baud rate detection error flag
791 * @arg @ref UART_FLAG_EOBF End of block flag
792 * @arg @ref UART_FLAG_RTOF Receiver timeout flag
793 * @arg @ref UART_FLAG_CTS CTS Change flag (not available for UART4 and UART5)
794 * @arg @ref UART_FLAG_LBDF LIN Break detection flag
795 * @arg @ref UART_FLAG_TXE Transmit data register empty flag
796 * @arg @ref UART_FLAG_TC Transmission Complete flag
797 * @arg @ref UART_FLAG_RXNE Receive data register not empty flag
798 * @arg @ref UART_FLAG_IDLE Idle Line detection flag
799 * @arg @ref UART_FLAG_ORE Overrun Error flag
800 * @arg @ref UART_FLAG_NE Noise Error flag
801 * @arg @ref UART_FLAG_FE Framing Error flag
802 * @arg @ref UART_FLAG_PE Parity Error flag
803 * @retval The new state of __FLAG__ (TRUE or FALSE).
805 #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
807 /** @brief Enable the specified UART interrupt.
808 * @param __HANDLE__ specifies the UART Handle.
809 * @param __INTERRUPT__ specifies the UART interrupt source to enable.
810 * This parameter can be one of the following values:
811 * @arg @ref UART_IT_WUF Wakeup from stop mode interrupt
812 * @arg @ref UART_IT_CM Character match interrupt
813 * @arg @ref UART_IT_CTS CTS change interrupt
814 * @arg @ref UART_IT_LBD LIN Break detection interrupt
815 * @arg @ref UART_IT_TXE Transmit Data Register empty interrupt
816 * @arg @ref UART_IT_TC Transmission complete interrupt
817 * @arg @ref UART_IT_RXNE Receive Data register not empty interrupt
818 * @arg @ref UART_IT_IDLE Idle line detection interrupt
819 * @arg @ref UART_IT_PE Parity Error interrupt
820 * @arg @ref UART_IT_ERR Error interrupt (Frame error, noise error, overrun error)
821 * @retval None
823 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
824 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
825 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))))
828 /** @brief Disable the specified UART interrupt.
829 * @param __HANDLE__ specifies the UART Handle.
830 * @param __INTERRUPT__ specifies the UART interrupt source to disable.
831 * This parameter can be one of the following values:
832 * @arg @ref UART_IT_WUF Wakeup from stop mode interrupt
833 * @arg @ref UART_IT_CM Character match interrupt
834 * @arg @ref UART_IT_CTS CTS change interrupt
835 * @arg @ref UART_IT_LBD LIN Break detection interrupt
836 * @arg @ref UART_IT_TXE Transmit Data Register empty interrupt
837 * @arg @ref UART_IT_TC Transmission complete interrupt
838 * @arg @ref UART_IT_RXNE Receive Data register not empty interrupt
839 * @arg @ref UART_IT_IDLE Idle line detection interrupt
840 * @arg @ref UART_IT_PE Parity Error interrupt
841 * @arg @ref UART_IT_ERR Error interrupt (Frame error, noise error, overrun error)
842 * @retval None
844 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
845 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
846 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))))
848 /** @brief Check whether the specified UART interrupt has occurred or not.
849 * @param __HANDLE__ specifies the UART Handle.
850 * @param __IT__ specifies the UART interrupt to check.
851 * This parameter can be one of the following values:
852 * @arg @ref UART_IT_WUF Wakeup from stop mode interrupt
853 * @arg @ref UART_IT_CM Character match interrupt
854 * @arg @ref UART_IT_CTS CTS change interrupt (not available for UART4 and UART5)
855 * @arg @ref UART_IT_LBD LIN Break detection interrupt
856 * @arg @ref UART_IT_TXE Transmit Data Register empty interrupt
857 * @arg @ref UART_IT_TC Transmission complete interrupt
858 * @arg @ref UART_IT_RXNE Receive Data register not empty interrupt
859 * @arg @ref UART_IT_IDLE Idle line detection interrupt
860 * @arg @ref UART_IT_ORE Overrun Error interrupt
861 * @arg @ref UART_IT_NE Noise Error interrupt
862 * @arg @ref UART_IT_FE Framing Error interrupt
863 * @arg @ref UART_IT_PE Parity Error interrupt
864 * @retval The new state of __IT__ (TRUE or FALSE).
866 #define __HAL_UART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & (1U << ((__IT__)>> 0x08U)))
868 /** @brief Check whether the specified UART interrupt source is enabled or not.
869 * @param __HANDLE__ specifies the UART Handle.
870 * @param __IT__ specifies the UART interrupt source to check.
871 * This parameter can be one of the following values:
872 * @arg @ref UART_IT_WUF Wakeup from stop mode interrupt
873 * @arg @ref UART_IT_CM Character match interrupt
874 * @arg @ref UART_IT_CTS CTS change interrupt (not available for UART4 and UART5)
875 * @arg @ref UART_IT_LBD LIN Break detection interrupt
876 * @arg @ref UART_IT_TXE Transmit Data Register empty interrupt
877 * @arg @ref UART_IT_TC Transmission complete interrupt
878 * @arg @ref UART_IT_RXNE Receive Data register not empty interrupt
879 * @arg @ref UART_IT_IDLE Idle line detection interrupt
880 * @arg @ref UART_IT_ERR Error interrupt (Frame error, noise error, overrun error)
881 * @arg @ref UART_IT_PE Parity Error interrupt
882 * @retval The new state of __IT__ (TRUE or FALSE).
884 #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1U)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5U) == 2U)? \
885 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (1U << (((uint16_t)(__IT__)) & UART_IT_MASK)))
887 /** @brief Clear the specified UART ISR flag, in setting the proper ICR register flag.
888 * @param __HANDLE__ specifies the UART Handle.
889 * @param __IT_CLEAR__ specifies the interrupt clear register flag that needs to be set
890 * to clear the corresponding interrupt
891 * This parameter can be one of the following values:
892 * @arg @ref UART_CLEAR_PEF Parity Error Clear Flag
893 * @arg @ref UART_CLEAR_FEF Framing Error Clear Flag
894 * @arg @ref UART_CLEAR_NEF Noise detected Clear Flag
895 * @arg @ref UART_CLEAR_OREF Overrun Error Clear Flag
896 * @arg @ref UART_CLEAR_IDLEF IDLE line detected Clear Flag
897 * @arg @ref UART_CLEAR_TCF Transmission Complete Clear Flag
898 * @arg @ref UART_CLEAR_LBDF LIN Break Detection Clear Flag
899 * @arg @ref UART_CLEAR_CTSF CTS Interrupt Clear Flag
900 * @arg @ref UART_CLEAR_RTOF Receiver Time Out Clear Flag
901 * @arg @ref UART_CLEAR_EOBF End Of Block Clear Flag
902 * @arg @ref UART_CLEAR_CMF Character Match Clear Flag
903 * @arg @ref UART_CLEAR_WUF Wake Up from stop mode Clear Flag
904 * @retval None
906 #define __HAL_UART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
908 /** @brief Set a specific UART request flag.
909 * @param __HANDLE__ specifies the UART Handle.
910 * @param __REQ__ specifies the request flag to set
911 * This parameter can be one of the following values:
912 * @arg @ref UART_AUTOBAUD_REQUEST Auto-Baud Rate Request
913 * @arg @ref UART_SENDBREAK_REQUEST Send Break Request
914 * @arg @ref UART_MUTE_MODE_REQUEST Mute Mode Request
915 * @arg @ref UART_RXDATA_FLUSH_REQUEST Receive Data flush Request
916 * @arg @ref UART_TXDATA_FLUSH_REQUEST Transmit data flush Request
917 * @retval None
919 #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint32_t)(__REQ__))
921 /** @brief Enable the UART one bit sample method.
922 * @param __HANDLE__ specifies the UART Handle.
923 * @retval None
925 #define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
927 /** @brief Disable the UART one bit sample method.
928 * @param __HANDLE__ specifies the UART Handle.
929 * @retval None
931 #define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
933 /** @brief Enable UART.
934 * @param __HANDLE__ specifies the UART Handle.
935 * @retval None
937 #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
939 /** @brief Disable UART.
940 * @param __HANDLE__ specifies the UART Handle.
941 * @retval None
943 #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
945 /** @brief Enable CTS flow control.
946 * @note This macro allows to enable CTS hardware flow control for a given UART instance,
947 * without need to call HAL_UART_Init() function.
948 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
949 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
950 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
951 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
952 * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
953 * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
954 * @param __HANDLE__ specifies the UART Handle.
955 * @retval None
957 #define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \
958 do{ \
959 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
960 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \
961 } while(0U)
963 /** @brief Disable CTS flow control.
964 * @note This macro allows to disable CTS hardware flow control for a given UART instance,
965 * without need to call HAL_UART_Init() function.
966 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
967 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
968 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
969 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
970 * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
971 * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
972 * @param __HANDLE__ specifies the UART Handle.
973 * @retval None
975 #define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \
976 do{ \
977 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
978 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \
979 } while(0U)
981 /** @brief Enable RTS flow control.
982 * @note This macro allows to enable RTS hardware flow control for a given UART instance,
983 * without need to call HAL_UART_Init() function.
984 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
985 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
986 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
987 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
988 * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
989 * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
990 * @param __HANDLE__ specifies the UART Handle.
991 * @retval None
993 #define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \
994 do{ \
995 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \
996 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \
997 } while(0U)
999 /** @brief Disable RTS flow control.
1000 * @note This macro allows to disable RTS hardware flow control for a given UART instance,
1001 * without need to call HAL_UART_Init() function.
1002 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
1003 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
1004 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
1005 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
1006 * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
1007 * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
1008 * @param __HANDLE__ specifies the UART Handle.
1009 * @retval None
1011 #define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \
1012 do{ \
1013 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\
1014 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \
1015 } while(0U)
1018 * @}
1021 /* Private macros --------------------------------------------------------*/
1022 /** @defgroup UART_Private_Macros UART Private Macros
1023 * @{
1025 /** @brief BRR division operation to set BRR register in 8-bit oversampling mode.
1026 * @param __PCLK__ UART clock.
1027 * @param __BAUD__ Baud rate set by the user.
1028 * @retval Division result
1030 #define UART_DIV_SAMPLING8(__PCLK__, __BAUD__) ((((__PCLK__)*2U) + ((__BAUD__)/2U)) / (__BAUD__))
1032 /** @brief BRR division operation to set BRR register in 16-bit oversampling mode.
1033 * @param __PCLK__ UART clock.
1034 * @param __BAUD__ Baud rate set by the user.
1035 * @retval Division result
1037 #define UART_DIV_SAMPLING16(__PCLK__, __BAUD__) (((__PCLK__) + ((__BAUD__)/2U)) / (__BAUD__))
1039 /** @brief Check UART Baud rate.
1040 * @param __BAUDRATE__ Baudrate specified by the user.
1041 * The maximum Baud Rate is derived from the maximum clock on F3 (i.e. 72 MHz)
1042 * divided by the smallest oversampling used on the USART (i.e. 8)
1043 * @retval SET (__BAUDRATE__ is valid) or RESET (__BAUDRATE__ is invalid)
1045 #define IS_UART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 9000001U)
1047 /** @brief Check UART assertion time.
1048 * @param __TIME__ 5-bit value assertion time.
1049 * @retval Test result (TRUE or FALSE).
1051 #define IS_UART_ASSERTIONTIME(__TIME__) ((__TIME__) <= 0x1FU)
1053 /** @brief Check UART deassertion time.
1054 * @param __TIME__ 5-bit value deassertion time.
1055 * @retval Test result (TRUE or FALSE).
1057 #define IS_UART_DEASSERTIONTIME(__TIME__) ((__TIME__) <= 0x1FU)
1060 * @brief Ensure that UART frame number of stop bits is valid.
1061 * @param __STOPBITS__ UART frame number of stop bits.
1062 * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
1064 #define IS_UART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_0_5) || \
1065 ((__STOPBITS__) == UART_STOPBITS_1) || \
1066 ((__STOPBITS__) == UART_STOPBITS_1_5) || \
1067 ((__STOPBITS__) == UART_STOPBITS_2))
1070 * @brief Ensure that UART frame parity is valid.
1071 * @param __PARITY__ UART frame parity.
1072 * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
1074 #define IS_UART_PARITY(__PARITY__) (((__PARITY__) == UART_PARITY_NONE) || \
1075 ((__PARITY__) == UART_PARITY_EVEN) || \
1076 ((__PARITY__) == UART_PARITY_ODD))
1079 * @brief Ensure that UART hardware flow control is valid.
1080 * @param __CONTROL__ UART hardware flow control.
1081 * @retval SET (__CONTROL__ is valid) or RESET (__CONTROL__ is invalid)
1083 #define IS_UART_HARDWARE_FLOW_CONTROL(__CONTROL__)\
1084 (((__CONTROL__) == UART_HWCONTROL_NONE) || \
1085 ((__CONTROL__) == UART_HWCONTROL_RTS) || \
1086 ((__CONTROL__) == UART_HWCONTROL_CTS) || \
1087 ((__CONTROL__) == UART_HWCONTROL_RTS_CTS))
1090 * @brief Ensure that UART communication mode is valid.
1091 * @param __MODE__ UART communication mode.
1092 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
1094 #define IS_UART_MODE(__MODE__) ((((__MODE__) & (~((uint32_t)(UART_MODE_TX_RX)))) == 0x00U) && ((__MODE__) != 0x00U))
1097 * @brief Ensure that UART state is valid.
1098 * @param __STATE__ UART state.
1099 * @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid)
1101 #define IS_UART_STATE(__STATE__) (((__STATE__) == UART_STATE_DISABLE) || \
1102 ((__STATE__) == UART_STATE_ENABLE))
1105 * @brief Ensure that UART oversampling is valid.
1106 * @param __SAMPLING__ UART oversampling.
1107 * @retval SET (__SAMPLING__ is valid) or RESET (__SAMPLING__ is invalid)
1109 #define IS_UART_OVERSAMPLING(__SAMPLING__) (((__SAMPLING__) == UART_OVERSAMPLING_16) || \
1110 ((__SAMPLING__) == UART_OVERSAMPLING_8))
1113 * @brief Ensure that UART frame sampling is valid.
1114 * @param __ONEBIT__ UART frame sampling.
1115 * @retval SET (__ONEBIT__ is valid) or RESET (__ONEBIT__ is invalid)
1117 #define IS_UART_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == UART_ONE_BIT_SAMPLE_DISABLE) || \
1118 ((__ONEBIT__) == UART_ONE_BIT_SAMPLE_ENABLE))
1121 * @brief Ensure that Address Length detection parameter is valid.
1122 * @param __ADDRESS__ UART Adress length value.
1123 * @retval SET (__ADDRESS__ is valid) or RESET (__ADDRESS__ is invalid)
1125 #define IS_UART_ADDRESSLENGTH_DETECT(__ADDRESS__) (((__ADDRESS__) == UART_ADDRESS_DETECT_4B) || \
1126 ((__ADDRESS__) == UART_ADDRESS_DETECT_7B))
1129 * @brief Ensure that UART auto Baud rate detection mode is valid.
1130 * @param __MODE__ UART auto Baud rate detection mode.
1131 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
1133 #define IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(__MODE__) (((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT) || \
1134 ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE) || \
1135 ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME) || \
1136 ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME))
1139 * @brief Ensure that UART receiver timeout setting is valid.
1140 * @param __TIMEOUT__ UART receiver timeout setting.
1141 * @retval SET (__TIMEOUT__ is valid) or RESET (__TIMEOUT__ is invalid)
1143 #define IS_UART_RECEIVER_TIMEOUT(__TIMEOUT__) (((__TIMEOUT__) == UART_RECEIVER_TIMEOUT_DISABLE) || \
1144 ((__TIMEOUT__) == UART_RECEIVER_TIMEOUT_ENABLE))
1147 * @brief Ensure that UART LIN state is valid.
1148 * @param __LIN__ UART LIN state.
1149 * @retval SET (__LIN__ is valid) or RESET (__LIN__ is invalid)
1151 #define IS_UART_LIN(__LIN__) (((__LIN__) == UART_LIN_DISABLE) || \
1152 ((__LIN__) == UART_LIN_ENABLE))
1155 * @brief Ensure that UART LIN break detection length is valid.
1156 * @param __LENGTH__ UART LIN break detection length.
1157 * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid)
1159 #define IS_UART_LIN_BREAK_DETECT_LENGTH(__LENGTH__) (((__LENGTH__) == UART_LINBREAKDETECTLENGTH_10B) || \
1160 ((__LENGTH__) == UART_LINBREAKDETECTLENGTH_11B))
1163 * @brief Ensure that UART DMA TX state is valid.
1164 * @param __DMATX__ UART DMA TX state.
1165 * @retval SET (__DMATX__ is valid) or RESET (__DMATX__ is invalid)
1167 #define IS_UART_DMA_TX(__DMATX__) (((__DMATX__) == UART_DMA_TX_DISABLE) || \
1168 ((__DMATX__) == UART_DMA_TX_ENABLE))
1171 * @brief Ensure that UART DMA RX state is valid.
1172 * @param __DMARX__ UART DMA RX state.
1173 * @retval SET (__DMARX__ is valid) or RESET (__DMARX__ is invalid)
1175 #define IS_UART_DMA_RX(__DMARX__) (((__DMARX__) == UART_DMA_RX_DISABLE) || \
1176 ((__DMARX__) == UART_DMA_RX_ENABLE))
1179 * @brief Ensure that UART half-duplex state is valid.
1180 * @param __HDSEL__ UART half-duplex state.
1181 * @retval SET (__HDSEL__ is valid) or RESET (__HDSEL__ is invalid)
1183 #define IS_UART_HALF_DUPLEX(__HDSEL__) (((__HDSEL__) == UART_HALF_DUPLEX_DISABLE) || \
1184 ((__HDSEL__) == UART_HALF_DUPLEX_ENABLE))
1187 * @brief Ensure that UART wake-up method is valid.
1188 * @param __WAKEUP__ UART wake-up method .
1189 * @retval SET (__WAKEUP__ is valid) or RESET (__WAKEUP__ is invalid)
1191 #define IS_UART_WAKEUPMETHOD(__WAKEUP__) (((__WAKEUP__) == UART_WAKEUPMETHOD_IDLELINE) || \
1192 ((__WAKEUP__) == UART_WAKEUPMETHOD_ADDRESSMARK))
1195 * @brief Ensure that UART advanced features initialization is valid.
1196 * @param __INIT__ UART advanced features initialization.
1197 * @retval SET (__INIT__ is valid) or RESET (__INIT__ is invalid)
1199 #define IS_UART_ADVFEATURE_INIT(__INIT__) ((__INIT__) <= (UART_ADVFEATURE_NO_INIT | \
1200 UART_ADVFEATURE_TXINVERT_INIT | \
1201 UART_ADVFEATURE_RXINVERT_INIT | \
1202 UART_ADVFEATURE_DATAINVERT_INIT | \
1203 UART_ADVFEATURE_SWAP_INIT | \
1204 UART_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
1205 UART_ADVFEATURE_DMADISABLEONERROR_INIT | \
1206 UART_ADVFEATURE_AUTOBAUDRATE_INIT | \
1207 UART_ADVFEATURE_MSBFIRST_INIT))
1210 * @brief Ensure that UART frame TX inversion setting is valid.
1211 * @param __TXINV__ UART frame TX inversion setting.
1212 * @retval SET (__TXINV__ is valid) or RESET (__TXINV__ is invalid)
1214 #define IS_UART_ADVFEATURE_TXINV(__TXINV__) (((__TXINV__) == UART_ADVFEATURE_TXINV_DISABLE) || \
1215 ((__TXINV__) == UART_ADVFEATURE_TXINV_ENABLE))
1218 * @brief Ensure that UART frame RX inversion setting is valid.
1219 * @param __RXINV__ UART frame RX inversion setting.
1220 * @retval SET (__RXINV__ is valid) or RESET (__RXINV__ is invalid)
1222 #define IS_UART_ADVFEATURE_RXINV(__RXINV__) (((__RXINV__) == UART_ADVFEATURE_RXINV_DISABLE) || \
1223 ((__RXINV__) == UART_ADVFEATURE_RXINV_ENABLE))
1226 * @brief Ensure that UART frame data inversion setting is valid.
1227 * @param __DATAINV__ UART frame data inversion setting.
1228 * @retval SET (__DATAINV__ is valid) or RESET (__DATAINV__ is invalid)
1230 #define IS_UART_ADVFEATURE_DATAINV(__DATAINV__) (((__DATAINV__) == UART_ADVFEATURE_DATAINV_DISABLE) || \
1231 ((__DATAINV__) == UART_ADVFEATURE_DATAINV_ENABLE))
1234 * @brief Ensure that UART frame RX/TX pins swap setting is valid.
1235 * @param __SWAP__ UART frame RX/TX pins swap setting.
1236 * @retval SET (__SWAP__ is valid) or RESET (__SWAP__ is invalid)
1238 #define IS_UART_ADVFEATURE_SWAP(__SWAP__) (((__SWAP__) == UART_ADVFEATURE_SWAP_DISABLE) || \
1239 ((__SWAP__) == UART_ADVFEATURE_SWAP_ENABLE))
1242 * @brief Ensure that UART frame overrun setting is valid.
1243 * @param __OVERRUN__ UART frame overrun setting.
1244 * @retval SET (__OVERRUN__ is valid) or RESET (__OVERRUN__ is invalid)
1246 #define IS_UART_OVERRUN(__OVERRUN__) (((__OVERRUN__) == UART_ADVFEATURE_OVERRUN_ENABLE) || \
1247 ((__OVERRUN__) == UART_ADVFEATURE_OVERRUN_DISABLE))
1250 * @brief Ensure that UART auto Baud rate state is valid.
1251 * @param __AUTOBAUDRATE__ UART auto Baud rate state.
1252 * @retval SET (__AUTOBAUDRATE__ is valid) or RESET (__AUTOBAUDRATE__ is invalid)
1254 #define IS_UART_ADVFEATURE_AUTOBAUDRATE(__AUTOBAUDRATE__) (((__AUTOBAUDRATE__) == UART_ADVFEATURE_AUTOBAUDRATE_DISABLE) || \
1255 ((__AUTOBAUDRATE__) == UART_ADVFEATURE_AUTOBAUDRATE_ENABLE))
1258 * @brief Ensure that UART DMA enabling or disabling on error setting is valid.
1259 * @param __DMA__ UART DMA enabling or disabling on error setting.
1260 * @retval SET (__DMA__ is valid) or RESET (__DMA__ is invalid)
1262 #define IS_UART_ADVFEATURE_DMAONRXERROR(__DMA__) (((__DMA__) == UART_ADVFEATURE_DMA_ENABLEONRXERROR) || \
1263 ((__DMA__) == UART_ADVFEATURE_DMA_DISABLEONRXERROR))
1266 * @brief Ensure that UART frame MSB first setting is valid.
1267 * @param __MSBFIRST__ UART frame MSB first setting.
1268 * @retval SET (__MSBFIRST__ is valid) or RESET (__MSBFIRST__ is invalid)
1270 #define IS_UART_ADVFEATURE_MSBFIRST(__MSBFIRST__) (((__MSBFIRST__) == UART_ADVFEATURE_MSBFIRST_DISABLE) || \
1271 ((__MSBFIRST__) == UART_ADVFEATURE_MSBFIRST_ENABLE))
1274 * @brief Ensure that UART stop mode state is valid.
1275 * @param __STOPMODE__ UART stop mode state.
1276 * @retval SET (__STOPMODE__ is valid) or RESET (__STOPMODE__ is invalid)
1278 #define IS_UART_ADVFEATURE_STOPMODE(__STOPMODE__) (((__STOPMODE__) == UART_ADVFEATURE_STOPMODE_DISABLE) || \
1279 ((__STOPMODE__) == UART_ADVFEATURE_STOPMODE_ENABLE))
1282 * @brief Ensure that UART mute mode state is valid.
1283 * @param __MUTE__ UART mute mode state.
1284 * @retval SET (__MUTE__ is valid) or RESET (__MUTE__ is invalid)
1286 #define IS_UART_MUTE_MODE(__MUTE__) (((__MUTE__) == UART_ADVFEATURE_MUTEMODE_DISABLE) || \
1287 ((__MUTE__) == UART_ADVFEATURE_MUTEMODE_ENABLE))
1290 * @brief Ensure that UART wake-up selection is valid.
1291 * @param __WAKE__ UART wake-up selection.
1292 * @retval SET (__WAKE__ is valid) or RESET (__WAKE__ is invalid)
1294 #define IS_UART_WAKEUP_SELECTION(__WAKE__) (((__WAKE__) == UART_WAKEUP_ON_ADDRESS) || \
1295 ((__WAKE__) == UART_WAKEUP_ON_STARTBIT) || \
1296 ((__WAKE__) == UART_WAKEUP_ON_READDATA_NONEMPTY))
1299 * @brief Ensure that UART driver enable polarity is valid.
1300 * @param __POLARITY__ UART driver enable polarity.
1301 * @retval SET (__POLARITY__ is valid) or RESET (__POLARITY__ is invalid)
1303 #define IS_UART_DE_POLARITY(__POLARITY__) (((__POLARITY__) == UART_DE_POLARITY_HIGH) || \
1304 ((__POLARITY__) == UART_DE_POLARITY_LOW))
1307 * @brief Ensure that UART request parameter is valid.
1308 * @param __PARAM__ UART request parameter.
1309 * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid)
1311 #define IS_UART_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == UART_AUTOBAUD_REQUEST) || \
1312 ((__PARAM__) == UART_SENDBREAK_REQUEST) || \
1313 ((__PARAM__) == UART_MUTE_MODE_REQUEST) || \
1314 ((__PARAM__) == UART_RXDATA_FLUSH_REQUEST) || \
1315 ((__PARAM__) == UART_TXDATA_FLUSH_REQUEST))
1318 * @}
1321 /* Include UART HAL Extended module */
1322 #include "stm32f3xx_hal_uart_ex.h"
1324 /* Exported functions --------------------------------------------------------*/
1325 /** @addtogroup UART_Exported_Functions UART Exported Functions
1326 * @{
1329 /** @addtogroup UART_Exported_Functions_Group1 Initialization and de-initialization functions
1330 * @{
1333 /* Initialization and de-initialization functions ****************************/
1334 HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
1335 HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);
1336 HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength);
1337 HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod);
1338 HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart);
1339 void HAL_UART_MspInit(UART_HandleTypeDef *huart);
1340 void HAL_UART_MspDeInit(UART_HandleTypeDef *huart);
1343 * @}
1346 /** @addtogroup UART_Exported_Functions_Group2 IO operation functions
1347 * @{
1350 /* IO operation functions *****************************************************/
1351 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
1352 HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
1353 HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
1354 HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
1355 HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
1356 HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
1357 HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
1358 HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
1359 HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
1360 /* Transfer Abort functions */
1361 HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart);
1362 HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart);
1363 HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart);
1364 HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart);
1365 HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart);
1366 HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart);
1368 void HAL_UART_IRQHandler(UART_HandleTypeDef *huart);
1369 void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
1370 void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart);
1371 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
1372 void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart);
1373 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
1374 void HAL_UART_AbortCpltCallback (UART_HandleTypeDef *huart);
1375 void HAL_UART_AbortTransmitCpltCallback (UART_HandleTypeDef *huart);
1376 void HAL_UART_AbortReceiveCpltCallback (UART_HandleTypeDef *huart);
1379 * @}
1382 /** @addtogroup UART_Exported_Functions_Group3 Peripheral Control functions
1383 * @{
1386 /* Peripheral Control functions ************************************************/
1387 HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart);
1388 HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart);
1389 void HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
1390 HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart);
1391 HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart);
1392 HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart);
1395 * @}
1398 /** @addtogroup UART_Exported_Functions_Group4 Peripheral State and Error functions
1399 * @{
1402 /* Peripheral State and Errors functions **************************************************/
1403 HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart);
1404 uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart);
1407 * @}
1411 * @}
1414 /* Private functions -----------------------------------------------------------*/
1415 /** @addtogroup UART_Private_Functions UART Private Functions
1416 * @{
1418 HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart);
1419 void UART_AdvFeatureConfig(UART_HandleTypeDef *huart);
1420 HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart);
1421 HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout);
1422 HAL_StatusTypeDef UART_Transmit_IT(UART_HandleTypeDef *huart);
1423 HAL_StatusTypeDef UART_EndTransmit_IT(UART_HandleTypeDef *huart);
1424 HAL_StatusTypeDef UART_Receive_IT(UART_HandleTypeDef *huart);
1425 void UART_Wakeup_AddressConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection);
1428 * @}
1432 * @}
1436 * @}
1439 #ifdef __cplusplus
1441 #endif
1443 #endif /* __STM32F3xx_HAL_UART_H */
1445 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/