2 ******************************************************************************
3 * @file stm32f7xx_hal_usart.h
4 * @author MCD Application Team
7 * @brief Header file of USART HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F7xx_HAL_USART_H
40 #define __STM32F7xx_HAL_USART_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f7xx_hal_def.h"
49 /** @addtogroup STM32F7xx_HAL_Driver
57 /* Exported types ------------------------------------------------------------*/
58 /** @defgroup USART_Exported_Types USART Exported Types
63 * @brief USART Init Structure definition
67 uint32_t BaudRate
; /*!< This member configures the Usart communication baud rate.
68 The baud rate is computed using the following formula:
69 Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate))) */
71 uint32_t WordLength
; /*!< Specifies the number of data bits transmitted or received in a frame.
72 This parameter can be a value of @ref USARTEx_Word_Length */
74 uint32_t StopBits
; /*!< Specifies the number of stop bits transmitted.
75 This parameter can be a value of @ref USART_Stop_Bits */
77 uint32_t Parity
; /*!< Specifies the parity mode.
78 This parameter can be a value of @ref USART_Parity
79 @note When parity is enabled, the computed parity is inserted
80 at the MSB position of the transmitted data (9th bit when
81 the word length is set to 9 data bits; 8th bit when the
82 word length is set to 8 data bits). */
84 uint32_t Mode
; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
85 This parameter can be a value of @ref USART_Mode */
87 uint32_t OverSampling
; /*!< Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to fPCLK/8).
88 This parameter can be a value of @ref USART_Over_Sampling */
90 uint32_t CLKPolarity
; /*!< Specifies the steady state of the serial clock.
91 This parameter can be a value of @ref USART_Clock_Polarity */
93 uint32_t CLKPhase
; /*!< Specifies the clock transition on which the bit capture is made.
94 This parameter can be a value of @ref USART_Clock_Phase */
96 uint32_t CLKLastBit
; /*!< Specifies whether the clock pulse corresponding to the last transmitted
97 data bit (MSB) has to be output on the SCLK pin in synchronous mode.
98 This parameter can be a value of @ref USART_Last_Bit */
102 * @brief HAL USART State structures definition
106 HAL_USART_STATE_RESET
= 0x00U
, /*!< Peripheral is not initialized */
107 HAL_USART_STATE_READY
= 0x01U
, /*!< Peripheral Initialized and ready for use */
108 HAL_USART_STATE_BUSY
= 0x02U
, /*!< an internal process is ongoing */
109 HAL_USART_STATE_BUSY_TX
= 0x12U
, /*!< Data Transmission process is ongoing */
110 HAL_USART_STATE_BUSY_RX
= 0x22U
, /*!< Data Reception process is ongoing */
111 HAL_USART_STATE_BUSY_TX_RX
= 0x32U
, /*!< Data Transmission Reception process is ongoing */
112 HAL_USART_STATE_TIMEOUT
= 0x03U
, /*!< Timeout state */
113 HAL_USART_STATE_ERROR
= 0x04U
/*!< Error */
114 }HAL_USART_StateTypeDef
;
118 * @brief USART clock sources definitions
122 USART_CLOCKSOURCE_PCLK1
= 0x00U
, /*!< PCLK1 clock source */
123 USART_CLOCKSOURCE_PCLK2
= 0x01U
, /*!< PCLK2 clock source */
124 USART_CLOCKSOURCE_HSI
= 0x02U
, /*!< HSI clock source */
125 USART_CLOCKSOURCE_SYSCLK
= 0x04U
, /*!< SYSCLK clock source */
126 USART_CLOCKSOURCE_LSE
= 0x08U
, /*!< LSE clock source */
127 USART_CLOCKSOURCE_UNDEFINED
= 0x10U
/*!< Undefined clock source */
128 }USART_ClockSourceTypeDef
;
132 * @brief USART handle Structure definition
136 USART_TypeDef
*Instance
; /*!< USART registers base address */
138 USART_InitTypeDef Init
; /*!< USART communication parameters */
140 uint8_t *pTxBuffPtr
; /*!< Pointer to USART Tx transfer Buffer */
142 uint16_t TxXferSize
; /*!< USART Tx Transfer size */
144 __IO
uint16_t TxXferCount
; /*!< USART Tx Transfer Counter */
146 uint8_t *pRxBuffPtr
; /*!< Pointer to USART Rx transfer Buffer */
148 uint16_t RxXferSize
; /*!< USART Rx Transfer size */
150 __IO
uint16_t RxXferCount
; /*!< USART Rx Transfer Counter */
152 uint16_t Mask
; /*!< USART Rx RDR register mask */
154 DMA_HandleTypeDef
*hdmatx
; /*!< USART Tx DMA Handle parameters */
156 DMA_HandleTypeDef
*hdmarx
; /*!< USART Rx DMA Handle parameters */
158 HAL_LockTypeDef Lock
; /*!< Locking object */
160 HAL_USART_StateTypeDef State
; /*!< USART communication state */
162 __IO
uint32_t ErrorCode
; /*!< USART Error code */
164 }USART_HandleTypeDef
;
169 /* Exported constants --------------------------------------------------------*/
170 /** @defgroup USART_Exported_Constants USART Exported Constants
174 /** @defgroup USART_Error_Code USART Error Code
175 * @brief USART Error Code
178 #define HAL_USART_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */
179 #define HAL_USART_ERROR_PE ((uint32_t)0x00000001U) /*!< Parity error */
180 #define HAL_USART_ERROR_NE ((uint32_t)0x00000002U) /*!< Noise error */
181 #define HAL_USART_ERROR_FE ((uint32_t)0x00000004U) /*!< Frame error */
182 #define HAL_USART_ERROR_ORE ((uint32_t)0x00000008U) /*!< Overrun error */
183 #define HAL_USART_ERROR_DMA ((uint32_t)0x00000010U) /*!< DMA transfer error */
188 /** @defgroup USART_Stop_Bits USART Number of Stop Bits
191 #define USART_STOPBITS_1 ((uint32_t)0x0000U)
192 #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1)
193 #define USART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1))
198 /** @defgroup USART_Parity USART Parity
201 #define USART_PARITY_NONE ((uint32_t)0x0000U)
202 #define USART_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
203 #define USART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
208 /** @defgroup USART_Mode USART Mode
211 #define USART_MODE_RX ((uint32_t)USART_CR1_RE)
212 #define USART_MODE_TX ((uint32_t)USART_CR1_TE)
213 #define USART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
218 /** @defgroup USART_Over_Sampling USART Over Sampling
221 #define USART_OVERSAMPLING_16 ((uint32_t)0x0000U)
222 #define USART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8)
226 /** @defgroup USART_Clock USART Clock
229 #define USART_CLOCK_DISABLE ((uint32_t)0x0000U)
230 #define USART_CLOCK_ENABLE ((uint32_t)USART_CR2_CLKEN)
235 /** @defgroup USART_Clock_Polarity USART Clock Polarity
238 #define USART_POLARITY_LOW ((uint32_t)0x0000U)
239 #define USART_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL)
244 /** @defgroup USART_Clock_Phase USART Clock Phase
247 #define USART_PHASE_1EDGE ((uint32_t)0x0000U)
248 #define USART_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA)
253 /** @defgroup USART_Last_Bit USART Last Bit
256 #define USART_LASTBIT_DISABLE ((uint32_t)0x0000U)
257 #define USART_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL)
262 /** @defgroup USART_Request_Parameters USART Request Parameters
265 #define USART_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
266 #define USART_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
271 /** @defgroup USART_Flags USART Flags
272 * Elements values convention: 0xXXXX
273 * - 0xXXXX : Flag mask in the ISR register
276 #define USART_FLAG_REACK ((uint32_t)0x00400000U)
277 #define USART_FLAG_TEACK ((uint32_t)0x00200000U)
278 #define USART_FLAG_BUSY ((uint32_t)0x00010000U)
279 #define USART_FLAG_CTS ((uint32_t)0x00000400U)
280 #define USART_FLAG_CTSIF ((uint32_t)0x00000200U)
281 #define USART_FLAG_LBDF ((uint32_t)0x00000100U)
282 #define USART_FLAG_TXE ((uint32_t)0x00000080U)
283 #define USART_FLAG_TC ((uint32_t)0x00000040U)
284 #define USART_FLAG_RXNE ((uint32_t)0x00000020U)
285 #define USART_FLAG_IDLE ((uint32_t)0x00000010U)
286 #define USART_FLAG_ORE ((uint32_t)0x00000008U)
287 #define USART_FLAG_NE ((uint32_t)0x00000004U)
288 #define USART_FLAG_FE ((uint32_t)0x00000002U)
289 #define USART_FLAG_PE ((uint32_t)0x00000001U)
294 /** @defgroup USART_Interrupt_definition USART Interrupts Definition
295 * Elements values convention: 0000ZZZZ0XXYYYYYb
296 * - YYYYY : Interrupt source position in the XX register (5bits)
297 * - XX : Interrupt source register (2bits)
301 * - ZZZZ : Flag position in the ISR register(4bits)
305 #define USART_IT_PE ((uint16_t)0x0028U)
306 #define USART_IT_TXE ((uint16_t)0x0727U)
307 #define USART_IT_TC ((uint16_t)0x0626U)
308 #define USART_IT_RXNE ((uint16_t)0x0525U)
309 #define USART_IT_IDLE ((uint16_t)0x0424U)
310 #define USART_IT_ERR ((uint16_t)0x0060U)
312 #define USART_IT_ORE ((uint16_t)0x0300U)
313 #define USART_IT_NE ((uint16_t)0x0200U)
314 #define USART_IT_FE ((uint16_t)0x0100U)
319 /** @defgroup USART_IT_CLEAR_Flags USART Interruption Clear Flags
322 #define USART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
323 #define USART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
324 #define USART_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
325 #define USART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
326 #define USART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */
327 #define USART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
328 #define USART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */
337 /* Exported macros -----------------------------------------------------------*/
338 /** @defgroup USART_Exported_Macros USART Exported Macros
342 /** @brief Reset USART handle state
343 * @param __HANDLE__: USART handle.
346 #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET)
348 /** @brief Checks whether the specified USART flag is set or not.
349 * @param __HANDLE__: specifies the USART Handle
350 * @param __FLAG__: specifies the flag to check.
351 * This parameter can be one of the following values:
352 * @arg USART_FLAG_REACK: Receive enable acknowledge flag
353 * @arg USART_FLAG_TEACK: Transmit enable acknowledge flag
354 * @arg USART_FLAG_BUSY: Busy flag
355 * @arg USART_FLAG_CTS: CTS Change flag
356 * @arg USART_FLAG_TXE: Transmit data register empty flag
357 * @arg USART_FLAG_TC: Transmission Complete flag
358 * @arg USART_FLAG_RXNE: Receive data register not empty flag
359 * @arg USART_FLAG_IDLE: Idle Line detection flag
360 * @arg USART_FLAG_ORE: OverRun Error flag
361 * @arg USART_FLAG_NE: Noise Error flag
362 * @arg USART_FLAG_FE: Framing Error flag
363 * @arg USART_FLAG_PE: Parity Error flag
364 * @retval The new state of __FLAG__ (TRUE or FALSE).
366 #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
369 /** @brief Enables the specified USART interrupt.
370 * @param __HANDLE__: specifies the USART Handle
371 * @param __INTERRUPT__: specifies the USART interrupt source to enable.
372 * This parameter can be one of the following values:
373 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
374 * @arg USART_IT_TC: Transmission complete interrupt
375 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
376 * @arg USART_IT_IDLE: Idle line detection interrupt
377 * @arg USART_IT_PE: Parity Error interrupt
378 * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
381 #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
382 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
383 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))))
385 /** @brief Disables the specified USART interrupt.
386 * @param __HANDLE__: specifies the USART Handle.
387 * @param __INTERRUPT__: specifies the USART interrupt source to disable.
388 * This parameter can be one of the following values:
389 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
390 * @arg USART_IT_TC: Transmission complete interrupt
391 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
392 * @arg USART_IT_IDLE: Idle line detection interrupt
393 * @arg USART_IT_PE: Parity Error interrupt
394 * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
397 #define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
398 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
399 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))))
402 /** @brief Checks whether the specified USART interrupt has occurred or not.
403 * @param __HANDLE__: specifies the USART Handle
404 * @param __IT__: specifies the USART interrupt source to check.
405 * This parameter can be one of the following values:
406 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
407 * @arg USART_IT_TC: Transmission complete interrupt
408 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
409 * @arg USART_IT_IDLE: Idle line detection interrupt
410 * @arg USART_IT_ORE: OverRun Error interrupt
411 * @arg USART_IT_NE: Noise Error interrupt
412 * @arg USART_IT_FE: Framing Error interrupt
413 * @arg USART_IT_PE: Parity Error interrupt
414 * @retval The new state of __IT__ (TRUE or FALSE).
416 #define __HAL_USART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
418 /** @brief Checks whether the specified USART interrupt source is enabled.
419 * @param __HANDLE__: specifies the USART Handle.
420 * @param __IT__: specifies the USART interrupt source to check.
421 * This parameter can be one of the following values:
422 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
423 * @arg USART_IT_TC: Transmission complete interrupt
424 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
425 * @arg USART_IT_IDLE: Idle line detection interrupt
426 * @arg USART_IT_ORE: OverRun Error interrupt
427 * @arg USART_IT_NE: Noise Error interrupt
428 * @arg USART_IT_FE: Framing Error interrupt
429 * @arg USART_IT_PE: Parity Error interrupt
430 * @retval The new state of __IT__ (TRUE or FALSE).
432 #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5) == 2)? \
433 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << \
434 (((uint16_t)(__IT__)) & USART_IT_MASK)))
437 /** @brief Clears the specified USART ISR flag, in setting the proper ICR register flag.
438 * @param __HANDLE__: specifies the USART Handle.
439 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
440 * to clear the corresponding interrupt
441 * This parameter can be one of the following values:
442 * @arg USART_CLEAR_PEF: Parity Error Clear Flag
443 * @arg USART_CLEAR_FEF: Framing Error Clear Flag
444 * @arg USART_CLEAR_NEF: Noise detected Clear Flag
445 * @arg USART_CLEAR_OREF: OverRun Error Clear Flag
446 * @arg USART_CLEAR_IDLEF: IDLE line detected Clear Flag
447 * @arg USART_CLEAR_TCF: Transmission Complete Clear Flag
448 * @arg USART_CLEAR_CTSF: CTS Interrupt Clear Flag
451 #define __HAL_USART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
453 /** @brief Set a specific USART request flag.
454 * @param __HANDLE__: specifies the USART Handle.
455 * @param __REQ__: specifies the request flag to set
456 * This parameter can be one of the following values:
457 * @arg USART_RXDATA_FLUSH_REQUEST: Receive Data flush Request
458 * @arg USART_TXDATA_FLUSH_REQUEST: Transmit data flush Request
462 #define __HAL_USART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__))
464 /** @brief Enable USART
465 * @param __HANDLE__: specifies the USART Handle.
468 #define __HAL_USART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
470 /** @brief Disable USART
471 * @param __HANDLE__: specifies the USART Handle.
474 #define __HAL_USART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
479 /* Include UART HAL Extension module */
480 #include "stm32f7xx_hal_usart_ex.h"
482 /* Exported functions --------------------------------------------------------*/
483 /** @addtogroup USART_Exported_Functions
487 /** @addtogroup USART_Exported_Functions_Group1
490 /* Initialization/de-initialization functions **********************************/
491 HAL_StatusTypeDef
HAL_USART_Init(USART_HandleTypeDef
*husart
);
492 HAL_StatusTypeDef
HAL_USART_DeInit(USART_HandleTypeDef
*husart
);
493 void HAL_USART_MspInit(USART_HandleTypeDef
*husart
);
494 void HAL_USART_MspDeInit(USART_HandleTypeDef
*husart
);
495 HAL_StatusTypeDef
HAL_USART_CheckIdleState(USART_HandleTypeDef
*husart
);
500 /** @addtogroup USART_Exported_Functions_Group2
503 /* IO operation functions *******************************************************/
504 HAL_StatusTypeDef
HAL_USART_Transmit(USART_HandleTypeDef
*husart
, uint8_t *pTxData
, uint16_t Size
, uint32_t Timeout
);
505 HAL_StatusTypeDef
HAL_USART_Receive(USART_HandleTypeDef
*husart
, uint8_t *pRxData
, uint16_t Size
, uint32_t Timeout
);
506 HAL_StatusTypeDef
HAL_USART_TransmitReceive(USART_HandleTypeDef
*husart
, uint8_t *pTxData
, uint8_t *pRxData
, uint16_t Size
, uint32_t Timeout
);
507 HAL_StatusTypeDef
HAL_USART_Transmit_IT(USART_HandleTypeDef
*husart
, uint8_t *pTxData
, uint16_t Size
);
508 HAL_StatusTypeDef
HAL_USART_Receive_IT(USART_HandleTypeDef
*husart
, uint8_t *pRxData
, uint16_t Size
);
509 HAL_StatusTypeDef
HAL_USART_TransmitReceive_IT(USART_HandleTypeDef
*husart
, uint8_t *pTxData
, uint8_t *pRxData
, uint16_t Size
);
510 HAL_StatusTypeDef
HAL_USART_Transmit_DMA(USART_HandleTypeDef
*husart
, uint8_t *pTxData
, uint16_t Size
);
511 HAL_StatusTypeDef
HAL_USART_Receive_DMA(USART_HandleTypeDef
*husart
, uint8_t *pRxData
, uint16_t Size
);
512 HAL_StatusTypeDef
HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef
*husart
, uint8_t *pTxData
, uint8_t *pRxData
, uint16_t Size
);
513 HAL_StatusTypeDef
HAL_USART_DMAPause(USART_HandleTypeDef
*husart
);
514 HAL_StatusTypeDef
HAL_USART_DMAResume(USART_HandleTypeDef
*husart
);
515 HAL_StatusTypeDef
HAL_USART_DMAStop(USART_HandleTypeDef
*husart
);
516 void HAL_USART_IRQHandler(USART_HandleTypeDef
*husart
);
517 void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef
*husart
);
518 void HAL_USART_TxCpltCallback(USART_HandleTypeDef
*husart
);
519 void HAL_USART_RxCpltCallback(USART_HandleTypeDef
*husart
);
520 void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef
*husart
);
521 void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef
*husart
);
522 void HAL_USART_ErrorCallback(USART_HandleTypeDef
*husart
);
528 /** @addtogroup USART_Exported_Functions_Group3
531 /* Peripheral State functions ************************************************/
532 HAL_USART_StateTypeDef
HAL_USART_GetState(USART_HandleTypeDef
*husart
);
533 uint32_t HAL_USART_GetError(USART_HandleTypeDef
*husart
);
542 /* Private types -------------------------------------------------------------*/
543 /* Private variables ---------------------------------------------------------*/
544 /* Private constants ---------------------------------------------------------*/
545 /** @defgroup USART_Private_Constants USART Private Constants
548 /** @brief USART interruptions flag mask
551 #define USART_IT_MASK ((uint16_t)0x001FU)
556 /* Private macros ------------------------------------------------------------*/
557 /** @defgroup USART_Private_Macros USART Private Macros
560 /** @brief Reports the USART clock source.
561 * @param __HANDLE__: specifies the USART Handle
562 * @param __CLOCKSOURCE__ : output variable
563 * @retval the USART clocking source, written in __CLOCKSOURCE__.
565 #define USART_GETCLOCKSOURCE(__HANDLE__, __CLOCKSOURCE__)\
567 if((__HANDLE__)->Instance == USART1) \
569 switch(__HAL_RCC_GET_USART1_SOURCE()) \
571 case RCC_USART1CLKSOURCE_PCLK2: \
572 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK2; \
574 case RCC_USART1CLKSOURCE_HSI: \
575 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
577 case RCC_USART1CLKSOURCE_SYSCLK: \
578 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
580 case RCC_USART1CLKSOURCE_LSE: \
581 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
587 else if((__HANDLE__)->Instance == USART2) \
589 switch(__HAL_RCC_GET_USART2_SOURCE()) \
591 case RCC_USART2CLKSOURCE_PCLK1: \
592 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
594 case RCC_USART2CLKSOURCE_HSI: \
595 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
597 case RCC_USART2CLKSOURCE_SYSCLK: \
598 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
600 case RCC_USART2CLKSOURCE_LSE: \
601 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
607 else if((__HANDLE__)->Instance == USART3) \
609 switch(__HAL_RCC_GET_USART3_SOURCE()) \
611 case RCC_USART3CLKSOURCE_PCLK1: \
612 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK1; \
614 case RCC_USART3CLKSOURCE_HSI: \
615 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
617 case RCC_USART3CLKSOURCE_SYSCLK: \
618 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
620 case RCC_USART3CLKSOURCE_LSE: \
621 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
627 else if((__HANDLE__)->Instance == USART6) \
629 switch(__HAL_RCC_GET_USART6_SOURCE()) \
631 case RCC_USART6CLKSOURCE_PCLK2: \
632 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_PCLK2; \
634 case RCC_USART6CLKSOURCE_HSI: \
635 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_HSI; \
637 case RCC_USART6CLKSOURCE_SYSCLK: \
638 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_SYSCLK; \
640 case RCC_USART6CLKSOURCE_LSE: \
641 (__CLOCKSOURCE__) = USART_CLOCKSOURCE_LSE; \
650 #define IS_USART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == USART_STOPBITS_1) || \
651 ((__STOPBITS__) == USART_STOPBITS_1_5) || \
652 ((__STOPBITS__) == USART_STOPBITS_2))
653 #define IS_USART_PARITY(__PARITY__) (((__PARITY__) == USART_PARITY_NONE) || \
654 ((__PARITY__) == USART_PARITY_EVEN) || \
655 ((__PARITY__) == USART_PARITY_ODD))
656 #define IS_USART_MODE(__MODE__) ((((__MODE__) & (uint32_t)0xFFFFFFF3U) == 0x00U) && ((__MODE__) != (uint32_t)0x00U))
657 #define IS_USART_OVERSAMPLING(__SAMPLING__) (((__SAMPLING__) == USART_OVERSAMPLING_16) || \
658 ((__SAMPLING__) == USART_OVERSAMPLING_8))
659 #define IS_USART_CLOCK(__CLOCK__) (((__CLOCK__)== USART_CLOCK_DISABLE) || \
660 ((__CLOCK__)== USART_CLOCK_ENABLE))
661 #define IS_USART_POLARITY(__CPOL__) (((__CPOL__) == USART_POLARITY_LOW) || ((__CPOL__) == USART_POLARITY_HIGH))
662 #define IS_USART_PHASE(__CPHA__) (((__CPHA__) == USART_PHASE_1EDGE) || ((__CPHA__) == USART_PHASE_2EDGE))
663 #define IS_USART_LASTBIT(__LASTBIT__) (((__LASTBIT__) == USART_LASTBIT_DISABLE) || \
664 ((__LASTBIT__) == USART_LASTBIT_ENABLE))
665 #define IS_USART_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == USART_RXDATA_FLUSH_REQUEST) || \
666 ((__PARAM__) == USART_TXDATA_FLUSH_REQUEST))
667 #define IS_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 9000001)
673 /* Private functions ---------------------------------------------------------*/
674 /** @defgroup USART_Private_Functions USART Private Functions
694 #endif /* __STM32F7xx_HAL_USART_H */
696 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/