SPKT

Dependencies:   F746_GUI SD_PlayerSkeleton F746_SAI_IO

Committer:
phungductung
Date:
Tue Jun 04 21:37:21 2019 +0000
Revision:
0:8ede47d38d10
SPKT

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phungductung 0:8ede47d38d10 1 /**
phungductung 0:8ede47d38d10 2 ******************************************************************************
phungductung 0:8ede47d38d10 3 * @file stm32f7xx_hal_uart.h
phungductung 0:8ede47d38d10 4 * @author MCD Application Team
phungductung 0:8ede47d38d10 5 * @version V1.0.4
phungductung 0:8ede47d38d10 6 * @date 09-December-2015
phungductung 0:8ede47d38d10 7 * @brief Header file of UART HAL module.
phungductung 0:8ede47d38d10 8 ******************************************************************************
phungductung 0:8ede47d38d10 9 * @attention
phungductung 0:8ede47d38d10 10 *
phungductung 0:8ede47d38d10 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
phungductung 0:8ede47d38d10 12 *
phungductung 0:8ede47d38d10 13 * Redistribution and use in source and binary forms, with or without modification,
phungductung 0:8ede47d38d10 14 * are permitted provided that the following conditions are met:
phungductung 0:8ede47d38d10 15 * 1. Redistributions of source code must retain the above copyright notice,
phungductung 0:8ede47d38d10 16 * this list of conditions and the following disclaimer.
phungductung 0:8ede47d38d10 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
phungductung 0:8ede47d38d10 18 * this list of conditions and the following disclaimer in the documentation
phungductung 0:8ede47d38d10 19 * and/or other materials provided with the distribution.
phungductung 0:8ede47d38d10 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
phungductung 0:8ede47d38d10 21 * may be used to endorse or promote products derived from this software
phungductung 0:8ede47d38d10 22 * without specific prior written permission.
phungductung 0:8ede47d38d10 23 *
phungductung 0:8ede47d38d10 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
phungductung 0:8ede47d38d10 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
phungductung 0:8ede47d38d10 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
phungductung 0:8ede47d38d10 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
phungductung 0:8ede47d38d10 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
phungductung 0:8ede47d38d10 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
phungductung 0:8ede47d38d10 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
phungductung 0:8ede47d38d10 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
phungductung 0:8ede47d38d10 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
phungductung 0:8ede47d38d10 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
phungductung 0:8ede47d38d10 34 *
phungductung 0:8ede47d38d10 35 ******************************************************************************
phungductung 0:8ede47d38d10 36 */
phungductung 0:8ede47d38d10 37
phungductung 0:8ede47d38d10 38 /* Define to prevent recursive inclusion -------------------------------------*/
phungductung 0:8ede47d38d10 39 #ifndef __STM32F7xx_HAL_UART_H
phungductung 0:8ede47d38d10 40 #define __STM32F7xx_HAL_UART_H
phungductung 0:8ede47d38d10 41
phungductung 0:8ede47d38d10 42 #ifdef __cplusplus
phungductung 0:8ede47d38d10 43 extern "C" {
phungductung 0:8ede47d38d10 44 #endif
phungductung 0:8ede47d38d10 45
phungductung 0:8ede47d38d10 46 /* Includes ------------------------------------------------------------------*/
phungductung 0:8ede47d38d10 47 #include "stm32f7xx_hal_def.h"
phungductung 0:8ede47d38d10 48
phungductung 0:8ede47d38d10 49 /** @addtogroup STM32F7xx_HAL_Driver
phungductung 0:8ede47d38d10 50 * @{
phungductung 0:8ede47d38d10 51 */
phungductung 0:8ede47d38d10 52
phungductung 0:8ede47d38d10 53 /** @addtogroup UART
phungductung 0:8ede47d38d10 54 * @{
phungductung 0:8ede47d38d10 55 */
phungductung 0:8ede47d38d10 56
phungductung 0:8ede47d38d10 57 /* Exported types ------------------------------------------------------------*/
phungductung 0:8ede47d38d10 58 /** @defgroup UART_Exported_Types UART Exported Types
phungductung 0:8ede47d38d10 59 * @{
phungductung 0:8ede47d38d10 60 */
phungductung 0:8ede47d38d10 61
phungductung 0:8ede47d38d10 62 /**
phungductung 0:8ede47d38d10 63 * @brief UART Init Structure definition
phungductung 0:8ede47d38d10 64 */
phungductung 0:8ede47d38d10 65 typedef struct
phungductung 0:8ede47d38d10 66 {
phungductung 0:8ede47d38d10 67 uint32_t BaudRate; /*!< This member configures the UART communication baud rate.
phungductung 0:8ede47d38d10 68 The baud rate register is computed using the following formula:
phungductung 0:8ede47d38d10 69 - If oversampling is 16 or in LIN mode,
phungductung 0:8ede47d38d10 70 Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate)))
phungductung 0:8ede47d38d10 71 - If oversampling is 8,
phungductung 0:8ede47d38d10 72 Baud Rate Register[15:4] = ((2 * PCLKx) / ((huart->Init.BaudRate)))[15:4]
phungductung 0:8ede47d38d10 73 Baud Rate Register[3] = 0
phungductung 0:8ede47d38d10 74 Baud Rate Register[2:0] = (((2 * PCLKx) / ((huart->Init.BaudRate)))[3:0]) >> 1 */
phungductung 0:8ede47d38d10 75
phungductung 0:8ede47d38d10 76 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
phungductung 0:8ede47d38d10 77 This parameter can be a value of @ref UARTEx_Word_Length */
phungductung 0:8ede47d38d10 78
phungductung 0:8ede47d38d10 79 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
phungductung 0:8ede47d38d10 80 This parameter can be a value of @ref UART_Stop_Bits */
phungductung 0:8ede47d38d10 81
phungductung 0:8ede47d38d10 82 uint32_t Parity; /*!< Specifies the parity mode.
phungductung 0:8ede47d38d10 83 This parameter can be a value of @ref UART_Parity
phungductung 0:8ede47d38d10 84 @note When parity is enabled, the computed parity is inserted
phungductung 0:8ede47d38d10 85 at the MSB position of the transmitted data (9th bit when
phungductung 0:8ede47d38d10 86 the word length is set to 9 data bits; 8th bit when the
phungductung 0:8ede47d38d10 87 word length is set to 8 data bits). */
phungductung 0:8ede47d38d10 88
phungductung 0:8ede47d38d10 89 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
phungductung 0:8ede47d38d10 90 This parameter can be a value of @ref UART_Mode */
phungductung 0:8ede47d38d10 91
phungductung 0:8ede47d38d10 92 uint32_t HwFlowCtl; /*!< Specifies whether the hardware flow control mode is enabled
phungductung 0:8ede47d38d10 93 or disabled.
phungductung 0:8ede47d38d10 94 This parameter can be a value of @ref UART_Hardware_Flow_Control */
phungductung 0:8ede47d38d10 95
phungductung 0:8ede47d38d10 96 uint32_t OverSampling; /*!< Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to fPCLK/8).
phungductung 0:8ede47d38d10 97 This parameter can be a value of @ref UART_Over_Sampling */
phungductung 0:8ede47d38d10 98
phungductung 0:8ede47d38d10 99 uint32_t OneBitSampling; /*!< Specifies whether a single sample or three samples' majority vote is selected.
phungductung 0:8ede47d38d10 100 Selecting the single sample method increases the receiver tolerance to clock
phungductung 0:8ede47d38d10 101 deviations. This parameter can be a value of @ref UART_OneBit_Sampling */
phungductung 0:8ede47d38d10 102 }UART_InitTypeDef;
phungductung 0:8ede47d38d10 103
phungductung 0:8ede47d38d10 104 /**
phungductung 0:8ede47d38d10 105 * @brief UART Advanced Features initialization structure definition
phungductung 0:8ede47d38d10 106 */
phungductung 0:8ede47d38d10 107 typedef struct
phungductung 0:8ede47d38d10 108 {
phungductung 0:8ede47d38d10 109 uint32_t AdvFeatureInit; /*!< Specifies which advanced UART features is initialized. Several
phungductung 0:8ede47d38d10 110 Advanced Features may be initialized at the same time .
phungductung 0:8ede47d38d10 111 This parameter can be a value of @ref UART_Advanced_Features_Initialization_Type */
phungductung 0:8ede47d38d10 112
phungductung 0:8ede47d38d10 113 uint32_t TxPinLevelInvert; /*!< Specifies whether the TX pin active level is inverted.
phungductung 0:8ede47d38d10 114 This parameter can be a value of @ref UART_Tx_Inv */
phungductung 0:8ede47d38d10 115
phungductung 0:8ede47d38d10 116 uint32_t RxPinLevelInvert; /*!< Specifies whether the RX pin active level is inverted.
phungductung 0:8ede47d38d10 117 This parameter can be a value of @ref UART_Rx_Inv */
phungductung 0:8ede47d38d10 118
phungductung 0:8ede47d38d10 119 uint32_t DataInvert; /*!< Specifies whether data are inverted (positive/direct logic
phungductung 0:8ede47d38d10 120 vs negative/inverted logic).
phungductung 0:8ede47d38d10 121 This parameter can be a value of @ref UART_Data_Inv */
phungductung 0:8ede47d38d10 122
phungductung 0:8ede47d38d10 123 uint32_t Swap; /*!< Specifies whether TX and RX pins are swapped.
phungductung 0:8ede47d38d10 124 This parameter can be a value of @ref UART_Rx_Tx_Swap */
phungductung 0:8ede47d38d10 125
phungductung 0:8ede47d38d10 126 uint32_t OverrunDisable; /*!< Specifies whether the reception overrun detection is disabled.
phungductung 0:8ede47d38d10 127 This parameter can be a value of @ref UART_Overrun_Disable */
phungductung 0:8ede47d38d10 128
phungductung 0:8ede47d38d10 129 uint32_t DMADisableonRxError; /*!< Specifies whether the DMA is disabled in case of reception error.
phungductung 0:8ede47d38d10 130 This parameter can be a value of @ref UART_DMA_Disable_on_Rx_Error */
phungductung 0:8ede47d38d10 131
phungductung 0:8ede47d38d10 132 uint32_t AutoBaudRateEnable; /*!< Specifies whether auto Baud rate detection is enabled.
phungductung 0:8ede47d38d10 133 This parameter can be a value of @ref UART_AutoBaudRate_Enable */
phungductung 0:8ede47d38d10 134
phungductung 0:8ede47d38d10 135 uint32_t AutoBaudRateMode; /*!< If auto Baud rate detection is enabled, specifies how the rate
phungductung 0:8ede47d38d10 136 detection is carried out.
phungductung 0:8ede47d38d10 137 This parameter can be a value of @ref UART_AutoBaud_Rate_Mode */
phungductung 0:8ede47d38d10 138
phungductung 0:8ede47d38d10 139 uint32_t MSBFirst; /*!< Specifies whether MSB is sent first on UART line.
phungductung 0:8ede47d38d10 140 This parameter can be a value of @ref UART_MSB_First */
phungductung 0:8ede47d38d10 141 } UART_AdvFeatureInitTypeDef;
phungductung 0:8ede47d38d10 142
phungductung 0:8ede47d38d10 143
phungductung 0:8ede47d38d10 144
phungductung 0:8ede47d38d10 145 /**
phungductung 0:8ede47d38d10 146 * @brief HAL UART State structures definition
phungductung 0:8ede47d38d10 147 */
phungductung 0:8ede47d38d10 148 typedef enum
phungductung 0:8ede47d38d10 149 {
phungductung 0:8ede47d38d10 150 HAL_UART_STATE_RESET = 0x00, /*!< Peripheral is not initialized */
phungductung 0:8ede47d38d10 151 HAL_UART_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
phungductung 0:8ede47d38d10 152 HAL_UART_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
phungductung 0:8ede47d38d10 153 HAL_UART_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
phungductung 0:8ede47d38d10 154 HAL_UART_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
phungductung 0:8ede47d38d10 155 HAL_UART_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */
phungductung 0:8ede47d38d10 156 HAL_UART_STATE_TIMEOUT = 0x03, /*!< Timeout state */
phungductung 0:8ede47d38d10 157 HAL_UART_STATE_ERROR = 0x04 /*!< Error */
phungductung 0:8ede47d38d10 158 }HAL_UART_StateTypeDef;
phungductung 0:8ede47d38d10 159
phungductung 0:8ede47d38d10 160 /**
phungductung 0:8ede47d38d10 161 * @brief UART clock sources definition
phungductung 0:8ede47d38d10 162 */
phungductung 0:8ede47d38d10 163 typedef enum
phungductung 0:8ede47d38d10 164 {
phungductung 0:8ede47d38d10 165 UART_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */
phungductung 0:8ede47d38d10 166 UART_CLOCKSOURCE_PCLK2 = 0x01, /*!< PCLK2 clock source */
phungductung 0:8ede47d38d10 167 UART_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */
phungductung 0:8ede47d38d10 168 UART_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */
phungductung 0:8ede47d38d10 169 UART_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */
phungductung 0:8ede47d38d10 170 UART_CLOCKSOURCE_UNDEFINED = 0x10 /*!< Undefined clock source */
phungductung 0:8ede47d38d10 171 }UART_ClockSourceTypeDef;
phungductung 0:8ede47d38d10 172
phungductung 0:8ede47d38d10 173 /**
phungductung 0:8ede47d38d10 174 * @brief UART handle Structure definition
phungductung 0:8ede47d38d10 175 */
phungductung 0:8ede47d38d10 176 typedef struct
phungductung 0:8ede47d38d10 177 {
phungductung 0:8ede47d38d10 178 USART_TypeDef *Instance; /*!< UART registers base address */
phungductung 0:8ede47d38d10 179
phungductung 0:8ede47d38d10 180 UART_InitTypeDef Init; /*!< UART communication parameters */
phungductung 0:8ede47d38d10 181
phungductung 0:8ede47d38d10 182 UART_AdvFeatureInitTypeDef AdvancedInit; /*!< UART Advanced Features initialization parameters */
phungductung 0:8ede47d38d10 183
phungductung 0:8ede47d38d10 184 uint8_t *pTxBuffPtr; /*!< Pointer to UART Tx transfer Buffer */
phungductung 0:8ede47d38d10 185
phungductung 0:8ede47d38d10 186 uint16_t TxXferSize; /*!< UART Tx Transfer size */
phungductung 0:8ede47d38d10 187
phungductung 0:8ede47d38d10 188 uint16_t TxXferCount; /*!< UART Tx Transfer Counter */
phungductung 0:8ede47d38d10 189
phungductung 0:8ede47d38d10 190 uint8_t *pRxBuffPtr; /*!< Pointer to UART Rx transfer Buffer */
phungductung 0:8ede47d38d10 191
phungductung 0:8ede47d38d10 192 uint16_t RxXferSize; /*!< UART Rx Transfer size */
phungductung 0:8ede47d38d10 193
phungductung 0:8ede47d38d10 194 uint16_t RxXferCount; /*!< UART Rx Transfer Counter */
phungductung 0:8ede47d38d10 195
phungductung 0:8ede47d38d10 196 uint16_t Mask; /*!< UART Rx RDR register mask */
phungductung 0:8ede47d38d10 197
phungductung 0:8ede47d38d10 198 DMA_HandleTypeDef *hdmatx; /*!< UART Tx DMA Handle parameters */
phungductung 0:8ede47d38d10 199
phungductung 0:8ede47d38d10 200 DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */
phungductung 0:8ede47d38d10 201
phungductung 0:8ede47d38d10 202 HAL_LockTypeDef Lock; /*!< Locking object */
phungductung 0:8ede47d38d10 203
phungductung 0:8ede47d38d10 204 __IO HAL_UART_StateTypeDef State; /*!< UART communication state */
phungductung 0:8ede47d38d10 205
phungductung 0:8ede47d38d10 206 __IO uint32_t ErrorCode; /*!< UART Error code */
phungductung 0:8ede47d38d10 207
phungductung 0:8ede47d38d10 208 }UART_HandleTypeDef;
phungductung 0:8ede47d38d10 209
phungductung 0:8ede47d38d10 210 /**
phungductung 0:8ede47d38d10 211 * @}
phungductung 0:8ede47d38d10 212 */
phungductung 0:8ede47d38d10 213
phungductung 0:8ede47d38d10 214 /* Exported constants --------------------------------------------------------*/
phungductung 0:8ede47d38d10 215 /** @defgroup UART_Exported_Constants UART Exported Constants
phungductung 0:8ede47d38d10 216 * @{
phungductung 0:8ede47d38d10 217 */
phungductung 0:8ede47d38d10 218 /** @defgroup UART_Error_Definition UART Error Definition
phungductung 0:8ede47d38d10 219 * @{
phungductung 0:8ede47d38d10 220 */
phungductung 0:8ede47d38d10 221 #define HAL_UART_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
phungductung 0:8ede47d38d10 222 #define HAL_UART_ERROR_PE ((uint32_t)0x00000001) /*!< Parity error */
phungductung 0:8ede47d38d10 223 #define HAL_UART_ERROR_NE ((uint32_t)0x00000002) /*!< Noise error */
phungductung 0:8ede47d38d10 224 #define HAL_UART_ERROR_FE ((uint32_t)0x00000004) /*!< frame error */
phungductung 0:8ede47d38d10 225 #define HAL_UART_ERROR_ORE ((uint32_t)0x00000008) /*!< Overrun error */
phungductung 0:8ede47d38d10 226 #define HAL_UART_ERROR_DMA ((uint32_t)0x00000010) /*!< DMA transfer error */
phungductung 0:8ede47d38d10 227 /**
phungductung 0:8ede47d38d10 228 * @}
phungductung 0:8ede47d38d10 229 */
phungductung 0:8ede47d38d10 230 /** @defgroup UART_Stop_Bits UART Number of Stop Bits
phungductung 0:8ede47d38d10 231 * @{
phungductung 0:8ede47d38d10 232 */
phungductung 0:8ede47d38d10 233 #define UART_STOPBITS_1 ((uint32_t)0x0000)
phungductung 0:8ede47d38d10 234 #define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1)
phungductung 0:8ede47d38d10 235 /**
phungductung 0:8ede47d38d10 236 * @}
phungductung 0:8ede47d38d10 237 */
phungductung 0:8ede47d38d10 238
phungductung 0:8ede47d38d10 239 /** @defgroup UART_Parity UART Parity
phungductung 0:8ede47d38d10 240 * @{
phungductung 0:8ede47d38d10 241 */
phungductung 0:8ede47d38d10 242 #define UART_PARITY_NONE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 243 #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
phungductung 0:8ede47d38d10 244 #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
phungductung 0:8ede47d38d10 245 /**
phungductung 0:8ede47d38d10 246 * @}
phungductung 0:8ede47d38d10 247 */
phungductung 0:8ede47d38d10 248
phungductung 0:8ede47d38d10 249 /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
phungductung 0:8ede47d38d10 250 * @{
phungductung 0:8ede47d38d10 251 */
phungductung 0:8ede47d38d10 252 #define UART_HWCONTROL_NONE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 253 #define UART_HWCONTROL_RTS ((uint32_t)USART_CR3_RTSE)
phungductung 0:8ede47d38d10 254 #define UART_HWCONTROL_CTS ((uint32_t)USART_CR3_CTSE)
phungductung 0:8ede47d38d10 255 #define UART_HWCONTROL_RTS_CTS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE))
phungductung 0:8ede47d38d10 256 /**
phungductung 0:8ede47d38d10 257 * @}
phungductung 0:8ede47d38d10 258 */
phungductung 0:8ede47d38d10 259
phungductung 0:8ede47d38d10 260 /** @defgroup UART_Mode UART Transfer Mode
phungductung 0:8ede47d38d10 261 * @{
phungductung 0:8ede47d38d10 262 */
phungductung 0:8ede47d38d10 263 #define UART_MODE_RX ((uint32_t)USART_CR1_RE)
phungductung 0:8ede47d38d10 264 #define UART_MODE_TX ((uint32_t)USART_CR1_TE)
phungductung 0:8ede47d38d10 265 #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
phungductung 0:8ede47d38d10 266 /**
phungductung 0:8ede47d38d10 267 * @}
phungductung 0:8ede47d38d10 268 */
phungductung 0:8ede47d38d10 269
phungductung 0:8ede47d38d10 270 /** @defgroup UART_State UART State
phungductung 0:8ede47d38d10 271 * @{
phungductung 0:8ede47d38d10 272 */
phungductung 0:8ede47d38d10 273 #define UART_STATE_DISABLE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 274 #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE)
phungductung 0:8ede47d38d10 275 /**
phungductung 0:8ede47d38d10 276 * @}
phungductung 0:8ede47d38d10 277 */
phungductung 0:8ede47d38d10 278
phungductung 0:8ede47d38d10 279 /** @defgroup UART_Over_Sampling UART Over Sampling
phungductung 0:8ede47d38d10 280 * @{
phungductung 0:8ede47d38d10 281 */
phungductung 0:8ede47d38d10 282 #define UART_OVERSAMPLING_16 ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 283 #define UART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8)
phungductung 0:8ede47d38d10 284 /**
phungductung 0:8ede47d38d10 285 * @}
phungductung 0:8ede47d38d10 286 */
phungductung 0:8ede47d38d10 287
phungductung 0:8ede47d38d10 288 /** @defgroup UART_OneBit_Sampling UART One Bit Sampling Method
phungductung 0:8ede47d38d10 289 * @{
phungductung 0:8ede47d38d10 290 */
phungductung 0:8ede47d38d10 291 #define UART_ONE_BIT_SAMPLE_DISABLE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 292 #define UART_ONE_BIT_SAMPLE_ENABLE ((uint32_t)USART_CR3_ONEBIT)
phungductung 0:8ede47d38d10 293 /**
phungductung 0:8ede47d38d10 294 * @}
phungductung 0:8ede47d38d10 295 */
phungductung 0:8ede47d38d10 296
phungductung 0:8ede47d38d10 297 /** @defgroup UART_AutoBaud_Rate_Mode UART Advanced Feature AutoBaud Rate Mode
phungductung 0:8ede47d38d10 298 * @{
phungductung 0:8ede47d38d10 299 */
phungductung 0:8ede47d38d10 300 #define UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT ((uint32_t)0x0000)
phungductung 0:8ede47d38d10 301 #define UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE ((uint32_t)USART_CR2_ABRMODE_0)
phungductung 0:8ede47d38d10 302 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME ((uint32_t)USART_CR2_ABRMODE_1)
phungductung 0:8ede47d38d10 303 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME ((uint32_t)USART_CR2_ABRMODE)
phungductung 0:8ede47d38d10 304 /**
phungductung 0:8ede47d38d10 305 * @}
phungductung 0:8ede47d38d10 306 */
phungductung 0:8ede47d38d10 307
phungductung 0:8ede47d38d10 308 /** @defgroup UART_Receiver_TimeOut UART Receiver TimeOut
phungductung 0:8ede47d38d10 309 * @{
phungductung 0:8ede47d38d10 310 */
phungductung 0:8ede47d38d10 311 #define UART_RECEIVER_TIMEOUT_DISABLE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 312 #define UART_RECEIVER_TIMEOUT_ENABLE ((uint32_t)USART_CR2_RTOEN)
phungductung 0:8ede47d38d10 313 /**
phungductung 0:8ede47d38d10 314 * @}
phungductung 0:8ede47d38d10 315 */
phungductung 0:8ede47d38d10 316
phungductung 0:8ede47d38d10 317 /** @defgroup UART_LIN UART Local Interconnection Network mode
phungductung 0:8ede47d38d10 318 * @{
phungductung 0:8ede47d38d10 319 */
phungductung 0:8ede47d38d10 320 #define UART_LIN_DISABLE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 321 #define UART_LIN_ENABLE ((uint32_t)USART_CR2_LINEN)
phungductung 0:8ede47d38d10 322 /**
phungductung 0:8ede47d38d10 323 * @}
phungductung 0:8ede47d38d10 324 */
phungductung 0:8ede47d38d10 325
phungductung 0:8ede47d38d10 326 /** @defgroup UART_LIN_Break_Detection UART LIN Break Detection
phungductung 0:8ede47d38d10 327 * @{
phungductung 0:8ede47d38d10 328 */
phungductung 0:8ede47d38d10 329 #define UART_LINBREAKDETECTLENGTH_10B ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 330 #define UART_LINBREAKDETECTLENGTH_11B ((uint32_t)USART_CR2_LBDL)
phungductung 0:8ede47d38d10 331 /**
phungductung 0:8ede47d38d10 332 * @}
phungductung 0:8ede47d38d10 333 */
phungductung 0:8ede47d38d10 334
phungductung 0:8ede47d38d10 335 /** @defgroup UART_DMA_Tx UART DMA Tx
phungductung 0:8ede47d38d10 336 * @{
phungductung 0:8ede47d38d10 337 */
phungductung 0:8ede47d38d10 338 #define UART_DMA_TX_DISABLE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 339 #define UART_DMA_TX_ENABLE ((uint32_t)USART_CR3_DMAT)
phungductung 0:8ede47d38d10 340 /**
phungductung 0:8ede47d38d10 341 * @}
phungductung 0:8ede47d38d10 342 */
phungductung 0:8ede47d38d10 343
phungductung 0:8ede47d38d10 344 /** @defgroup UART_DMA_Rx UART DMA Rx
phungductung 0:8ede47d38d10 345 * @{
phungductung 0:8ede47d38d10 346 */
phungductung 0:8ede47d38d10 347 #define UART_DMA_RX_DISABLE ((uint32_t)0x0000)
phungductung 0:8ede47d38d10 348 #define UART_DMA_RX_ENABLE ((uint32_t)USART_CR3_DMAR)
phungductung 0:8ede47d38d10 349 /**
phungductung 0:8ede47d38d10 350 * @}
phungductung 0:8ede47d38d10 351 */
phungductung 0:8ede47d38d10 352
phungductung 0:8ede47d38d10 353 /** @defgroup UART_Half_Duplex_Selection UART Half Duplex Selection
phungductung 0:8ede47d38d10 354 * @{
phungductung 0:8ede47d38d10 355 */
phungductung 0:8ede47d38d10 356 #define UART_HALF_DUPLEX_DISABLE ((uint32_t)0x0000)
phungductung 0:8ede47d38d10 357 #define UART_HALF_DUPLEX_ENABLE ((uint32_t)USART_CR3_HDSEL)
phungductung 0:8ede47d38d10 358 /**
phungductung 0:8ede47d38d10 359 * @}
phungductung 0:8ede47d38d10 360 */
phungductung 0:8ede47d38d10 361
phungductung 0:8ede47d38d10 362 /** @defgroup UART_WakeUp_Methods UART WakeUp Methods
phungductung 0:8ede47d38d10 363 * @{
phungductung 0:8ede47d38d10 364 */
phungductung 0:8ede47d38d10 365 #define UART_WAKEUPMETHOD_IDLELINE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 366 #define UART_WAKEUPMETHOD_ADDRESSMARK ((uint32_t)USART_CR1_WAKE)
phungductung 0:8ede47d38d10 367 /**
phungductung 0:8ede47d38d10 368 * @}
phungductung 0:8ede47d38d10 369 */
phungductung 0:8ede47d38d10 370
phungductung 0:8ede47d38d10 371 /** @defgroup UART_Request_Parameters UART Request Parameters
phungductung 0:8ede47d38d10 372 * @{
phungductung 0:8ede47d38d10 373 */
phungductung 0:8ede47d38d10 374 #define UART_AUTOBAUD_REQUEST ((uint32_t)USART_RQR_ABRRQ) /*!< Auto-Baud Rate Request */
phungductung 0:8ede47d38d10 375 #define UART_SENDBREAK_REQUEST ((uint32_t)USART_RQR_SBKRQ) /*!< Send Break Request */
phungductung 0:8ede47d38d10 376 #define UART_MUTE_MODE_REQUEST ((uint32_t)USART_RQR_MMRQ) /*!< Mute Mode Request */
phungductung 0:8ede47d38d10 377 #define UART_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
phungductung 0:8ede47d38d10 378 #define UART_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
phungductung 0:8ede47d38d10 379 /**
phungductung 0:8ede47d38d10 380 * @}
phungductung 0:8ede47d38d10 381 */
phungductung 0:8ede47d38d10 382
phungductung 0:8ede47d38d10 383 /** @defgroup UART_Advanced_Features_Initialization_Type UART Advanced Feature Initialization Type
phungductung 0:8ede47d38d10 384 * @{
phungductung 0:8ede47d38d10 385 */
phungductung 0:8ede47d38d10 386 #define UART_ADVFEATURE_NO_INIT ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 387 #define UART_ADVFEATURE_TXINVERT_INIT ((uint32_t)0x00000001)
phungductung 0:8ede47d38d10 388 #define UART_ADVFEATURE_RXINVERT_INIT ((uint32_t)0x00000002)
phungductung 0:8ede47d38d10 389 #define UART_ADVFEATURE_DATAINVERT_INIT ((uint32_t)0x00000004)
phungductung 0:8ede47d38d10 390 #define UART_ADVFEATURE_SWAP_INIT ((uint32_t)0x00000008)
phungductung 0:8ede47d38d10 391 #define UART_ADVFEATURE_RXOVERRUNDISABLE_INIT ((uint32_t)0x00000010)
phungductung 0:8ede47d38d10 392 #define UART_ADVFEATURE_DMADISABLEONERROR_INIT ((uint32_t)0x00000020)
phungductung 0:8ede47d38d10 393 #define UART_ADVFEATURE_AUTOBAUDRATE_INIT ((uint32_t)0x00000040)
phungductung 0:8ede47d38d10 394 #define UART_ADVFEATURE_MSBFIRST_INIT ((uint32_t)0x00000080)
phungductung 0:8ede47d38d10 395 /**
phungductung 0:8ede47d38d10 396 * @}
phungductung 0:8ede47d38d10 397 */
phungductung 0:8ede47d38d10 398
phungductung 0:8ede47d38d10 399 /** @defgroup UART_Tx_Inv UART Advanced Feature TX Pin Active Level Inversion
phungductung 0:8ede47d38d10 400 * @{
phungductung 0:8ede47d38d10 401 */
phungductung 0:8ede47d38d10 402 #define UART_ADVFEATURE_TXINV_DISABLE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 403 #define UART_ADVFEATURE_TXINV_ENABLE ((uint32_t)USART_CR2_TXINV)
phungductung 0:8ede47d38d10 404 /**
phungductung 0:8ede47d38d10 405 * @}
phungductung 0:8ede47d38d10 406 */
phungductung 0:8ede47d38d10 407
phungductung 0:8ede47d38d10 408 /** @defgroup UART_Rx_Inv UART Advanced Feature RX Pin Active Level Inversion
phungductung 0:8ede47d38d10 409 * @{
phungductung 0:8ede47d38d10 410 */
phungductung 0:8ede47d38d10 411 #define UART_ADVFEATURE_RXINV_DISABLE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 412 #define UART_ADVFEATURE_RXINV_ENABLE ((uint32_t)USART_CR2_RXINV)
phungductung 0:8ede47d38d10 413 /**
phungductung 0:8ede47d38d10 414 * @}
phungductung 0:8ede47d38d10 415 */
phungductung 0:8ede47d38d10 416
phungductung 0:8ede47d38d10 417 /** @defgroup UART_Data_Inv UART Advanced Feature Binary Data Inversion
phungductung 0:8ede47d38d10 418 * @{
phungductung 0:8ede47d38d10 419 */
phungductung 0:8ede47d38d10 420 #define UART_ADVFEATURE_DATAINV_DISABLE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 421 #define UART_ADVFEATURE_DATAINV_ENABLE ((uint32_t)USART_CR2_DATAINV)
phungductung 0:8ede47d38d10 422 /**
phungductung 0:8ede47d38d10 423 * @}
phungductung 0:8ede47d38d10 424 */
phungductung 0:8ede47d38d10 425
phungductung 0:8ede47d38d10 426 /** @defgroup UART_Rx_Tx_Swap UART Advanced Feature RX TX Pins Swap
phungductung 0:8ede47d38d10 427 * @{
phungductung 0:8ede47d38d10 428 */
phungductung 0:8ede47d38d10 429 #define UART_ADVFEATURE_SWAP_DISABLE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 430 #define UART_ADVFEATURE_SWAP_ENABLE ((uint32_t)USART_CR2_SWAP)
phungductung 0:8ede47d38d10 431 /**
phungductung 0:8ede47d38d10 432 * @}
phungductung 0:8ede47d38d10 433 */
phungductung 0:8ede47d38d10 434
phungductung 0:8ede47d38d10 435 /** @defgroup UART_Overrun_Disable UART Advanced Feature Overrun Disable
phungductung 0:8ede47d38d10 436 * @{
phungductung 0:8ede47d38d10 437 */
phungductung 0:8ede47d38d10 438 #define UART_ADVFEATURE_OVERRUN_ENABLE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 439 #define UART_ADVFEATURE_OVERRUN_DISABLE ((uint32_t)USART_CR3_OVRDIS)
phungductung 0:8ede47d38d10 440 /**
phungductung 0:8ede47d38d10 441 * @}
phungductung 0:8ede47d38d10 442 */
phungductung 0:8ede47d38d10 443
phungductung 0:8ede47d38d10 444 /** @defgroup UART_AutoBaudRate_Enable UART Advanced Feature Auto BaudRate Enable
phungductung 0:8ede47d38d10 445 * @{
phungductung 0:8ede47d38d10 446 */
phungductung 0:8ede47d38d10 447 #define UART_ADVFEATURE_AUTOBAUDRATE_DISABLE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 448 #define UART_ADVFEATURE_AUTOBAUDRATE_ENABLE ((uint32_t)USART_CR2_ABREN)
phungductung 0:8ede47d38d10 449 /**
phungductung 0:8ede47d38d10 450 * @}
phungductung 0:8ede47d38d10 451 */
phungductung 0:8ede47d38d10 452
phungductung 0:8ede47d38d10 453 /** @defgroup UART_DMA_Disable_on_Rx_Error UART Advanced Feature DMA Disable On Rx Error
phungductung 0:8ede47d38d10 454 * @{
phungductung 0:8ede47d38d10 455 */
phungductung 0:8ede47d38d10 456 #define UART_ADVFEATURE_DMA_ENABLEONRXERROR ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 457 #define UART_ADVFEATURE_DMA_DISABLEONRXERROR ((uint32_t)USART_CR3_DDRE)
phungductung 0:8ede47d38d10 458 /**
phungductung 0:8ede47d38d10 459 * @}
phungductung 0:8ede47d38d10 460 */
phungductung 0:8ede47d38d10 461
phungductung 0:8ede47d38d10 462 /** @defgroup UART_MSB_First UART Advanced Feature MSB First
phungductung 0:8ede47d38d10 463 * @{
phungductung 0:8ede47d38d10 464 */
phungductung 0:8ede47d38d10 465 #define UART_ADVFEATURE_MSBFIRST_DISABLE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 466 #define UART_ADVFEATURE_MSBFIRST_ENABLE ((uint32_t)USART_CR2_MSBFIRST)
phungductung 0:8ede47d38d10 467 /**
phungductung 0:8ede47d38d10 468 * @}
phungductung 0:8ede47d38d10 469 */
phungductung 0:8ede47d38d10 470
phungductung 0:8ede47d38d10 471 /** @defgroup UART_Mute_Mode UART Advanced Feature Mute Mode Enable
phungductung 0:8ede47d38d10 472 * @{
phungductung 0:8ede47d38d10 473 */
phungductung 0:8ede47d38d10 474 #define UART_ADVFEATURE_MUTEMODE_DISABLE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 475 #define UART_ADVFEATURE_MUTEMODE_ENABLE ((uint32_t)USART_CR1_MME)
phungductung 0:8ede47d38d10 476 /**
phungductung 0:8ede47d38d10 477 * @}
phungductung 0:8ede47d38d10 478 */
phungductung 0:8ede47d38d10 479
phungductung 0:8ede47d38d10 480 /** @defgroup UART_CR2_ADDRESS_LSB_POS UART Address-matching LSB Position In CR2 Register
phungductung 0:8ede47d38d10 481 * @{
phungductung 0:8ede47d38d10 482 */
phungductung 0:8ede47d38d10 483 #define UART_CR2_ADDRESS_LSB_POS ((uint32_t) 24)
phungductung 0:8ede47d38d10 484 /**
phungductung 0:8ede47d38d10 485 * @}
phungductung 0:8ede47d38d10 486 */
phungductung 0:8ede47d38d10 487
phungductung 0:8ede47d38d10 488 /** @defgroup UART_DriverEnable_Polarity UART DriverEnable Polarity
phungductung 0:8ede47d38d10 489 * @{
phungductung 0:8ede47d38d10 490 */
phungductung 0:8ede47d38d10 491 #define UART_DE_POLARITY_HIGH ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 492 #define UART_DE_POLARITY_LOW ((uint32_t)USART_CR3_DEP)
phungductung 0:8ede47d38d10 493 /**
phungductung 0:8ede47d38d10 494 * @}
phungductung 0:8ede47d38d10 495 */
phungductung 0:8ede47d38d10 496
phungductung 0:8ede47d38d10 497 /** @defgroup UART_CR1_DEAT_ADDRESS_LSB_POS UART Driver Enable Assertion Time LSB Position In CR1 Register
phungductung 0:8ede47d38d10 498 * @{
phungductung 0:8ede47d38d10 499 */
phungductung 0:8ede47d38d10 500 #define UART_CR1_DEAT_ADDRESS_LSB_POS ((uint32_t) 21)
phungductung 0:8ede47d38d10 501 /**
phungductung 0:8ede47d38d10 502 * @}
phungductung 0:8ede47d38d10 503 */
phungductung 0:8ede47d38d10 504
phungductung 0:8ede47d38d10 505 /** @defgroup UART_CR1_DEDT_ADDRESS_LSB_POS UART Driver Enable DeAssertion Time LSB Position In CR1 Register
phungductung 0:8ede47d38d10 506 * @{
phungductung 0:8ede47d38d10 507 */
phungductung 0:8ede47d38d10 508 #define UART_CR1_DEDT_ADDRESS_LSB_POS ((uint32_t) 16)
phungductung 0:8ede47d38d10 509 /**
phungductung 0:8ede47d38d10 510 * @}
phungductung 0:8ede47d38d10 511 */
phungductung 0:8ede47d38d10 512
phungductung 0:8ede47d38d10 513 /** @defgroup UART_Interruption_Mask UART Interruptions Flag Mask
phungductung 0:8ede47d38d10 514 * @{
phungductung 0:8ede47d38d10 515 */
phungductung 0:8ede47d38d10 516 #define UART_IT_MASK ((uint32_t)0x001F)
phungductung 0:8ede47d38d10 517 /**
phungductung 0:8ede47d38d10 518 * @}
phungductung 0:8ede47d38d10 519 */
phungductung 0:8ede47d38d10 520
phungductung 0:8ede47d38d10 521 /** @defgroup UART_TimeOut_Value UART polling-based communications time-out value
phungductung 0:8ede47d38d10 522 * @{
phungductung 0:8ede47d38d10 523 */
phungductung 0:8ede47d38d10 524 #define HAL_UART_TIMEOUT_VALUE 0x1FFFFFF
phungductung 0:8ede47d38d10 525 /**
phungductung 0:8ede47d38d10 526 * @}
phungductung 0:8ede47d38d10 527 */
phungductung 0:8ede47d38d10 528
phungductung 0:8ede47d38d10 529 /** @defgroup UART_Flags UART Status Flags
phungductung 0:8ede47d38d10 530 * Elements values convention: 0xXXXX
phungductung 0:8ede47d38d10 531 * - 0xXXXX : Flag mask in the ISR register
phungductung 0:8ede47d38d10 532 * @{
phungductung 0:8ede47d38d10 533 */
phungductung 0:8ede47d38d10 534 #define UART_FLAG_TEACK ((uint32_t)0x00200000)
phungductung 0:8ede47d38d10 535 #define UART_FLAG_SBKF ((uint32_t)0x00040000)
phungductung 0:8ede47d38d10 536 #define UART_FLAG_CMF ((uint32_t)0x00020000)
phungductung 0:8ede47d38d10 537 #define UART_FLAG_BUSY ((uint32_t)0x00010000)
phungductung 0:8ede47d38d10 538 #define UART_FLAG_ABRF ((uint32_t)0x00008000)
phungductung 0:8ede47d38d10 539 #define UART_FLAG_ABRE ((uint32_t)0x00004000)
phungductung 0:8ede47d38d10 540 #define UART_FLAG_EOBF ((uint32_t)0x00001000)
phungductung 0:8ede47d38d10 541 #define UART_FLAG_RTOF ((uint32_t)0x00000800)
phungductung 0:8ede47d38d10 542 #define UART_FLAG_CTS ((uint32_t)0x00000400)
phungductung 0:8ede47d38d10 543 #define UART_FLAG_CTSIF ((uint32_t)0x00000200)
phungductung 0:8ede47d38d10 544 #define UART_FLAG_LBDF ((uint32_t)0x00000100)
phungductung 0:8ede47d38d10 545 #define UART_FLAG_TXE ((uint32_t)0x00000080)
phungductung 0:8ede47d38d10 546 #define UART_FLAG_TC ((uint32_t)0x00000040)
phungductung 0:8ede47d38d10 547 #define UART_FLAG_RXNE ((uint32_t)0x00000020)
phungductung 0:8ede47d38d10 548 #define UART_FLAG_IDLE ((uint32_t)0x00000010)
phungductung 0:8ede47d38d10 549 #define UART_FLAG_ORE ((uint32_t)0x00000008)
phungductung 0:8ede47d38d10 550 #define UART_FLAG_NE ((uint32_t)0x00000004)
phungductung 0:8ede47d38d10 551 #define UART_FLAG_FE ((uint32_t)0x00000002)
phungductung 0:8ede47d38d10 552 #define UART_FLAG_PE ((uint32_t)0x00000001)
phungductung 0:8ede47d38d10 553 /**
phungductung 0:8ede47d38d10 554 * @}
phungductung 0:8ede47d38d10 555 */
phungductung 0:8ede47d38d10 556
phungductung 0:8ede47d38d10 557 /** @defgroup UART_Interrupt_definition UART Interrupts Definition
phungductung 0:8ede47d38d10 558 * Elements values convention: 0000ZZZZ0XXYYYYYb
phungductung 0:8ede47d38d10 559 * - YYYYY : Interrupt source position in the XX register (5bits)
phungductung 0:8ede47d38d10 560 * - XX : Interrupt source register (2bits)
phungductung 0:8ede47d38d10 561 * - 01: CR1 register
phungductung 0:8ede47d38d10 562 * - 10: CR2 register
phungductung 0:8ede47d38d10 563 * - 11: CR3 register
phungductung 0:8ede47d38d10 564 * - ZZZZ : Flag position in the ISR register(4bits)
phungductung 0:8ede47d38d10 565 * @{
phungductung 0:8ede47d38d10 566 */
phungductung 0:8ede47d38d10 567 #define UART_IT_PE ((uint32_t)0x0028)
phungductung 0:8ede47d38d10 568 #define UART_IT_TXE ((uint32_t)0x0727)
phungductung 0:8ede47d38d10 569 #define UART_IT_TC ((uint32_t)0x0626)
phungductung 0:8ede47d38d10 570 #define UART_IT_RXNE ((uint32_t)0x0525)
phungductung 0:8ede47d38d10 571 #define UART_IT_IDLE ((uint32_t)0x0424)
phungductung 0:8ede47d38d10 572 #define UART_IT_LBD ((uint32_t)0x0846)
phungductung 0:8ede47d38d10 573 #define UART_IT_CTS ((uint32_t)0x096A)
phungductung 0:8ede47d38d10 574 #define UART_IT_CM ((uint32_t)0x112E)
phungductung 0:8ede47d38d10 575
phungductung 0:8ede47d38d10 576 /** Elements values convention: 000000000XXYYYYYb
phungductung 0:8ede47d38d10 577 * - YYYYY : Interrupt source position in the XX register (5bits)
phungductung 0:8ede47d38d10 578 * - XX : Interrupt source register (2bits)
phungductung 0:8ede47d38d10 579 * - 01: CR1 register
phungductung 0:8ede47d38d10 580 * - 10: CR2 register
phungductung 0:8ede47d38d10 581 * - 11: CR3 register
phungductung 0:8ede47d38d10 582 */
phungductung 0:8ede47d38d10 583 #define UART_IT_ERR ((uint32_t)0x0060)
phungductung 0:8ede47d38d10 584
phungductung 0:8ede47d38d10 585 /** Elements values convention: 0000ZZZZ00000000b
phungductung 0:8ede47d38d10 586 * - ZZZZ : Flag position in the ISR register(4bits)
phungductung 0:8ede47d38d10 587 */
phungductung 0:8ede47d38d10 588 #define UART_IT_ORE ((uint32_t)0x0300)
phungductung 0:8ede47d38d10 589 #define UART_IT_NE ((uint32_t)0x0200)
phungductung 0:8ede47d38d10 590 #define UART_IT_FE ((uint32_t)0x0100)
phungductung 0:8ede47d38d10 591 /**
phungductung 0:8ede47d38d10 592 * @}
phungductung 0:8ede47d38d10 593 */
phungductung 0:8ede47d38d10 594
phungductung 0:8ede47d38d10 595 /** @defgroup UART_IT_CLEAR_Flags UART Interruption Clear Flags
phungductung 0:8ede47d38d10 596 * @{
phungductung 0:8ede47d38d10 597 */
phungductung 0:8ede47d38d10 598 #define UART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
phungductung 0:8ede47d38d10 599 #define UART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
phungductung 0:8ede47d38d10 600 #define UART_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
phungductung 0:8ede47d38d10 601 #define UART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
phungductung 0:8ede47d38d10 602 #define UART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */
phungductung 0:8ede47d38d10 603 #define UART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
phungductung 0:8ede47d38d10 604 #define UART_CLEAR_LBDF USART_ICR_LBDCF /*!< LIN Break Detection Clear Flag */
phungductung 0:8ede47d38d10 605 #define UART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */
phungductung 0:8ede47d38d10 606 #define UART_CLEAR_RTOF USART_ICR_RTOCF /*!< Receiver Time Out Clear Flag */
phungductung 0:8ede47d38d10 607 #define UART_CLEAR_EOBF USART_ICR_EOBCF /*!< End Of Block Clear Flag */
phungductung 0:8ede47d38d10 608 #define UART_CLEAR_CMF USART_ICR_CMCF /*!< Character Match Clear Flag */
phungductung 0:8ede47d38d10 609 /**
phungductung 0:8ede47d38d10 610 * @}
phungductung 0:8ede47d38d10 611 */
phungductung 0:8ede47d38d10 612
phungductung 0:8ede47d38d10 613
phungductung 0:8ede47d38d10 614 /**
phungductung 0:8ede47d38d10 615 * @}
phungductung 0:8ede47d38d10 616 */
phungductung 0:8ede47d38d10 617
phungductung 0:8ede47d38d10 618 /* Exported macros -----------------------------------------------------------*/
phungductung 0:8ede47d38d10 619 /** @defgroup UART_Exported_Macros UART Exported Macros
phungductung 0:8ede47d38d10 620 * @{
phungductung 0:8ede47d38d10 621 */
phungductung 0:8ede47d38d10 622
phungductung 0:8ede47d38d10 623 /** @brief Reset UART handle state
phungductung 0:8ede47d38d10 624 * @param __HANDLE__: UART handle.
phungductung 0:8ede47d38d10 625 * @retval None
phungductung 0:8ede47d38d10 626 */
phungductung 0:8ede47d38d10 627 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_UART_STATE_RESET)
phungductung 0:8ede47d38d10 628
phungductung 0:8ede47d38d10 629 /** @brief Flush the UART Data registers
phungductung 0:8ede47d38d10 630 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 631 */
phungductung 0:8ede47d38d10 632 #define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) \
phungductung 0:8ede47d38d10 633 do{ \
phungductung 0:8ede47d38d10 634 SET_BIT((__HANDLE__)->Instance->RQR, UART_RXDATA_FLUSH_REQUEST); \
phungductung 0:8ede47d38d10 635 SET_BIT((__HANDLE__)->Instance->RQR, UART_TXDATA_FLUSH_REQUEST); \
phungductung 0:8ede47d38d10 636 } while(0)
phungductung 0:8ede47d38d10 637
phungductung 0:8ede47d38d10 638 /** @brief Clears the specified UART ISR flag, in setting the proper ICR register flag.
phungductung 0:8ede47d38d10 639 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 640 * @param __FLAG__: specifies the interrupt clear register flag that needs to be set
phungductung 0:8ede47d38d10 641 * to clear the corresponding interrupt
phungductung 0:8ede47d38d10 642 * This parameter can be one of the following values:
phungductung 0:8ede47d38d10 643 * @arg UART_CLEAR_PEF: Parity Error Clear Flag
phungductung 0:8ede47d38d10 644 * @arg UART_CLEAR_FEF: Framing Error Clear Flag
phungductung 0:8ede47d38d10 645 * @arg UART_CLEAR_NEF: Noise detected Clear Flag
phungductung 0:8ede47d38d10 646 * @arg UART_CLEAR_OREF: OverRun Error Clear Flag
phungductung 0:8ede47d38d10 647 * @arg UART_CLEAR_IDLEF: IDLE line detected Clear Flag
phungductung 0:8ede47d38d10 648 * @arg UART_CLEAR_TCF: Transmission Complete Clear Flag
phungductung 0:8ede47d38d10 649 * @arg UART_CLEAR_LBDF: LIN Break Detection Clear Flag
phungductung 0:8ede47d38d10 650 * @arg UART_CLEAR_CTSF: CTS Interrupt Clear Flag
phungductung 0:8ede47d38d10 651 * @arg UART_CLEAR_RTOF: Receiver Time Out Clear Flag
phungductung 0:8ede47d38d10 652 * @arg UART_CLEAR_EOBF: End Of Block Clear Flag
phungductung 0:8ede47d38d10 653 * @arg UART_CLEAR_CMF: Character Match Clear Flag
phungductung 0:8ede47d38d10 654 * @retval None
phungductung 0:8ede47d38d10 655 */
phungductung 0:8ede47d38d10 656 #define __HAL_UART_CLEAR_IT(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__FLAG__))
phungductung 0:8ede47d38d10 657
phungductung 0:8ede47d38d10 658 /** @brief Clear the UART PE pending flag.
phungductung 0:8ede47d38d10 659 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 660 * @retval None
phungductung 0:8ede47d38d10 661 */
phungductung 0:8ede47d38d10 662 #define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) __HAL_UART_CLEAR_IT((__HANDLE__),UART_CLEAR_PEF)
phungductung 0:8ede47d38d10 663
phungductung 0:8ede47d38d10 664 /** @brief Clear the UART FE pending flag.
phungductung 0:8ede47d38d10 665 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 666 * @retval None
phungductung 0:8ede47d38d10 667 */
phungductung 0:8ede47d38d10 668 #define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_IT((__HANDLE__),UART_CLEAR_FEF)
phungductung 0:8ede47d38d10 669
phungductung 0:8ede47d38d10 670 /** @brief Clear the UART NE pending flag.
phungductung 0:8ede47d38d10 671 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 672 * @retval None
phungductung 0:8ede47d38d10 673 */
phungductung 0:8ede47d38d10 674 #define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_IT((__HANDLE__),UART_CLEAR_NEF)
phungductung 0:8ede47d38d10 675
phungductung 0:8ede47d38d10 676 /** @brief Clear the UART ORE pending flag.
phungductung 0:8ede47d38d10 677 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 678 * @retval None
phungductung 0:8ede47d38d10 679 */
phungductung 0:8ede47d38d10 680 #define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_IT((__HANDLE__),UART_CLEAR_OREF)
phungductung 0:8ede47d38d10 681
phungductung 0:8ede47d38d10 682 /** @brief Clear the UART IDLE pending flag.
phungductung 0:8ede47d38d10 683 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 684 * @retval None
phungductung 0:8ede47d38d10 685 */
phungductung 0:8ede47d38d10 686 #define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_IT((__HANDLE__),UART_CLEAR_IDLEF)
phungductung 0:8ede47d38d10 687
phungductung 0:8ede47d38d10 688 /** @brief Checks whether the specified UART flag is set or not.
phungductung 0:8ede47d38d10 689 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 690 * @param __FLAG__: specifies the flag to check.
phungductung 0:8ede47d38d10 691 * This parameter can be one of the following values:
phungductung 0:8ede47d38d10 692 * @arg UART_FLAG_REACK: Receive enable acknowledge flag
phungductung 0:8ede47d38d10 693 * @arg UART_FLAG_TEACK: Transmit enable acknowledge flag
phungductung 0:8ede47d38d10 694 * @arg UART_FLAG_WUF: Wake up from stop mode flag
phungductung 0:8ede47d38d10 695 * @arg UART_FLAG_RWU: Receiver wake up flag (is the UART in mute mode)
phungductung 0:8ede47d38d10 696 * @arg UART_FLAG_SBKF: Send Break flag
phungductung 0:8ede47d38d10 697 * @arg UART_FLAG_CMF: Character match flag
phungductung 0:8ede47d38d10 698 * @arg UART_FLAG_BUSY: Busy flag
phungductung 0:8ede47d38d10 699 * @arg UART_FLAG_ABRF: Auto Baud rate detection flag
phungductung 0:8ede47d38d10 700 * @arg UART_FLAG_ABRE: Auto Baud rate detection error flag
phungductung 0:8ede47d38d10 701 * @arg UART_FLAG_EOBF: End of block flag
phungductung 0:8ede47d38d10 702 * @arg UART_FLAG_RTOF: Receiver timeout flag
phungductung 0:8ede47d38d10 703 * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5)
phungductung 0:8ede47d38d10 704 * @arg UART_FLAG_LBD: LIN Break detection flag
phungductung 0:8ede47d38d10 705 * @arg UART_FLAG_TXE: Transmit data register empty flag
phungductung 0:8ede47d38d10 706 * @arg UART_FLAG_TC: Transmission Complete flag
phungductung 0:8ede47d38d10 707 * @arg UART_FLAG_RXNE: Receive data register not empty flag
phungductung 0:8ede47d38d10 708 * @arg UART_FLAG_IDLE: Idle Line detection flag
phungductung 0:8ede47d38d10 709 * @arg UART_FLAG_ORE: OverRun Error flag
phungductung 0:8ede47d38d10 710 * @arg UART_FLAG_NE: Noise Error flag
phungductung 0:8ede47d38d10 711 * @arg UART_FLAG_FE: Framing Error flag
phungductung 0:8ede47d38d10 712 * @arg UART_FLAG_PE: Parity Error flag
phungductung 0:8ede47d38d10 713 * @retval The new state of __FLAG__ (TRUE or FALSE).
phungductung 0:8ede47d38d10 714 */
phungductung 0:8ede47d38d10 715 #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
phungductung 0:8ede47d38d10 716
phungductung 0:8ede47d38d10 717 /** @brief Enables the specified UART interrupt.
phungductung 0:8ede47d38d10 718 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 719 * @param __INTERRUPT__: specifies the UART interrupt source to enable.
phungductung 0:8ede47d38d10 720 * This parameter can be one of the following values:
phungductung 0:8ede47d38d10 721 * @arg UART_IT_WUF: Wakeup from stop mode interrupt
phungductung 0:8ede47d38d10 722 * @arg UART_IT_CM: Character match interrupt
phungductung 0:8ede47d38d10 723 * @arg UART_IT_CTS: CTS change interrupt
phungductung 0:8ede47d38d10 724 * @arg UART_IT_LBD: LIN Break detection interrupt
phungductung 0:8ede47d38d10 725 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
phungductung 0:8ede47d38d10 726 * @arg UART_IT_TC: Transmission complete interrupt
phungductung 0:8ede47d38d10 727 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
phungductung 0:8ede47d38d10 728 * @arg UART_IT_IDLE: Idle line detection interrupt
phungductung 0:8ede47d38d10 729 * @arg UART_IT_PE: Parity Error interrupt
phungductung 0:8ede47d38d10 730 * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
phungductung 0:8ede47d38d10 731 * @retval None
phungductung 0:8ede47d38d10 732 */
phungductung 0:8ede47d38d10 733 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
phungductung 0:8ede47d38d10 734 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
phungductung 0:8ede47d38d10 735 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))))
phungductung 0:8ede47d38d10 736
phungductung 0:8ede47d38d10 737
phungductung 0:8ede47d38d10 738 /** @brief Disables the specified UART interrupt.
phungductung 0:8ede47d38d10 739 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 740 * @param __INTERRUPT__: specifies the UART interrupt source to disable.
phungductung 0:8ede47d38d10 741 * This parameter can be one of the following values:
phungductung 0:8ede47d38d10 742 * @arg UART_IT_CM: Character match interrupt
phungductung 0:8ede47d38d10 743 * @arg UART_IT_CTS: CTS change interrupt
phungductung 0:8ede47d38d10 744 * @arg UART_IT_LBD: LIN Break detection interrupt
phungductung 0:8ede47d38d10 745 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
phungductung 0:8ede47d38d10 746 * @arg UART_IT_TC: Transmission complete interrupt
phungductung 0:8ede47d38d10 747 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
phungductung 0:8ede47d38d10 748 * @arg UART_IT_IDLE: Idle line detection interrupt
phungductung 0:8ede47d38d10 749 * @arg UART_IT_PE: Parity Error interrupt
phungductung 0:8ede47d38d10 750 * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
phungductung 0:8ede47d38d10 751 * @retval None
phungductung 0:8ede47d38d10 752 */
phungductung 0:8ede47d38d10 753 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
phungductung 0:8ede47d38d10 754 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
phungductung 0:8ede47d38d10 755 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))))
phungductung 0:8ede47d38d10 756
phungductung 0:8ede47d38d10 757 /** @brief Checks whether the specified UART interrupt has occurred or not.
phungductung 0:8ede47d38d10 758 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 759 * @param __IT__: specifies the UART interrupt to check.
phungductung 0:8ede47d38d10 760 * This parameter can be one of the following values:
phungductung 0:8ede47d38d10 761 * @arg UART_IT_CM: Character match interrupt
phungductung 0:8ede47d38d10 762 * @arg UART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
phungductung 0:8ede47d38d10 763 * @arg UART_IT_LBD: LIN Break detection interrupt
phungductung 0:8ede47d38d10 764 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
phungductung 0:8ede47d38d10 765 * @arg UART_IT_TC: Transmission complete interrupt
phungductung 0:8ede47d38d10 766 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
phungductung 0:8ede47d38d10 767 * @arg UART_IT_IDLE: Idle line detection interrupt
phungductung 0:8ede47d38d10 768 * @arg UART_IT_ORE: OverRun Error interrupt
phungductung 0:8ede47d38d10 769 * @arg UART_IT_NE: Noise Error interrupt
phungductung 0:8ede47d38d10 770 * @arg UART_IT_FE: Framing Error interrupt
phungductung 0:8ede47d38d10 771 * @arg UART_IT_PE: Parity Error interrupt
phungductung 0:8ede47d38d10 772 * @retval The new state of __IT__ (TRUE or FALSE).
phungductung 0:8ede47d38d10 773 */
phungductung 0:8ede47d38d10 774 #define __HAL_UART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
phungductung 0:8ede47d38d10 775
phungductung 0:8ede47d38d10 776 /** @brief Checks whether the specified UART interrupt source is enabled.
phungductung 0:8ede47d38d10 777 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 778 * @param __IT__: specifies the UART interrupt source to check.
phungductung 0:8ede47d38d10 779 * This parameter can be one of the following values:
phungductung 0:8ede47d38d10 780 * @arg UART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
phungductung 0:8ede47d38d10 781 * @arg UART_IT_LBD: LIN Break detection interrupt
phungductung 0:8ede47d38d10 782 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
phungductung 0:8ede47d38d10 783 * @arg UART_IT_TC: Transmission complete interrupt
phungductung 0:8ede47d38d10 784 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
phungductung 0:8ede47d38d10 785 * @arg UART_IT_IDLE: Idle line detection interrupt
phungductung 0:8ede47d38d10 786 * @arg UART_IT_ORE: OverRun Error interrupt
phungductung 0:8ede47d38d10 787 * @arg UART_IT_NE: Noise Error interrupt
phungductung 0:8ede47d38d10 788 * @arg UART_IT_FE: Framing Error interrupt
phungductung 0:8ede47d38d10 789 * @arg UART_IT_PE: Parity Error interrupt
phungductung 0:8ede47d38d10 790 * @retval The new state of __IT__ (TRUE or FALSE).
phungductung 0:8ede47d38d10 791 */
phungductung 0:8ede47d38d10 792 #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5U) == 2)? \
phungductung 0:8ede47d38d10 793 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << (((uint16_t)(__IT__)) & UART_IT_MASK)))
phungductung 0:8ede47d38d10 794
phungductung 0:8ede47d38d10 795 /** @brief Set a specific UART request flag.
phungductung 0:8ede47d38d10 796 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 797 * @param __REQ__: specifies the request flag to set
phungductung 0:8ede47d38d10 798 * This parameter can be one of the following values:
phungductung 0:8ede47d38d10 799 * @arg UART_AUTOBAUD_REQUEST: Auto-Baud Rate Request
phungductung 0:8ede47d38d10 800 * @arg UART_SENDBREAK_REQUEST: Send Break Request
phungductung 0:8ede47d38d10 801 * @arg UART_MUTE_MODE_REQUEST: Mute Mode Request
phungductung 0:8ede47d38d10 802 * @arg UART_RXDATA_FLUSH_REQUEST: Receive Data flush Request
phungductung 0:8ede47d38d10 803 * @arg UART_TXDATA_FLUSH_REQUEST: Transmit data flush Request
phungductung 0:8ede47d38d10 804 * @retval None
phungductung 0:8ede47d38d10 805 */
phungductung 0:8ede47d38d10 806 #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint32_t)(__REQ__))
phungductung 0:8ede47d38d10 807
phungductung 0:8ede47d38d10 808 /** @brief Enables the UART one bit sample method
phungductung 0:8ede47d38d10 809 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 810 * @retval None
phungductung 0:8ede47d38d10 811 */
phungductung 0:8ede47d38d10 812 #define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
phungductung 0:8ede47d38d10 813
phungductung 0:8ede47d38d10 814 /** @brief Disables the UART one bit sample method
phungductung 0:8ede47d38d10 815 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 816 * @retval None
phungductung 0:8ede47d38d10 817 */
phungductung 0:8ede47d38d10 818 #define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
phungductung 0:8ede47d38d10 819
phungductung 0:8ede47d38d10 820 /** @brief Enable UART
phungductung 0:8ede47d38d10 821 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 822 * @retval None
phungductung 0:8ede47d38d10 823 */
phungductung 0:8ede47d38d10 824 #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
phungductung 0:8ede47d38d10 825
phungductung 0:8ede47d38d10 826 /** @brief Disable UART
phungductung 0:8ede47d38d10 827 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 828 * @retval None
phungductung 0:8ede47d38d10 829 */
phungductung 0:8ede47d38d10 830 #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
phungductung 0:8ede47d38d10 831
phungductung 0:8ede47d38d10 832 /** @brief Enable CTS flow control
phungductung 0:8ede47d38d10 833 * This macro allows to enable CTS hardware flow control for a given UART instance,
phungductung 0:8ede47d38d10 834 * without need to call HAL_UART_Init() function.
phungductung 0:8ede47d38d10 835 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
phungductung 0:8ede47d38d10 836 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
phungductung 0:8ede47d38d10 837 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
phungductung 0:8ede47d38d10 838 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
phungductung 0:8ede47d38d10 839 * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
phungductung 0:8ede47d38d10 840 * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
phungductung 0:8ede47d38d10 841 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 842 * The Handle Instance can be USART1, USART2 or LPUART.
phungductung 0:8ede47d38d10 843 * @retval None
phungductung 0:8ede47d38d10 844 */
phungductung 0:8ede47d38d10 845 #define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \
phungductung 0:8ede47d38d10 846 do{ \
phungductung 0:8ede47d38d10 847 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
phungductung 0:8ede47d38d10 848 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \
phungductung 0:8ede47d38d10 849 } while(0)
phungductung 0:8ede47d38d10 850
phungductung 0:8ede47d38d10 851 /** @brief Disable CTS flow control
phungductung 0:8ede47d38d10 852 * This macro allows to disable CTS hardware flow control for a given UART instance,
phungductung 0:8ede47d38d10 853 * without need to call HAL_UART_Init() function.
phungductung 0:8ede47d38d10 854 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
phungductung 0:8ede47d38d10 855 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
phungductung 0:8ede47d38d10 856 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
phungductung 0:8ede47d38d10 857 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
phungductung 0:8ede47d38d10 858 * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
phungductung 0:8ede47d38d10 859 * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
phungductung 0:8ede47d38d10 860 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 861 * The Handle Instance can be USART1, USART2 or LPUART.
phungductung 0:8ede47d38d10 862 * @retval None
phungductung 0:8ede47d38d10 863 */
phungductung 0:8ede47d38d10 864 #define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \
phungductung 0:8ede47d38d10 865 do{ \
phungductung 0:8ede47d38d10 866 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
phungductung 0:8ede47d38d10 867 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \
phungductung 0:8ede47d38d10 868 } while(0)
phungductung 0:8ede47d38d10 869
phungductung 0:8ede47d38d10 870 /** @brief Enable RTS flow control
phungductung 0:8ede47d38d10 871 * This macro allows to enable RTS hardware flow control for a given UART instance,
phungductung 0:8ede47d38d10 872 * without need to call HAL_UART_Init() function.
phungductung 0:8ede47d38d10 873 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
phungductung 0:8ede47d38d10 874 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
phungductung 0:8ede47d38d10 875 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
phungductung 0:8ede47d38d10 876 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
phungductung 0:8ede47d38d10 877 * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
phungductung 0:8ede47d38d10 878 * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
phungductung 0:8ede47d38d10 879 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 880 * The Handle Instance can be USART1, USART2 or LPUART.
phungductung 0:8ede47d38d10 881 * @retval None
phungductung 0:8ede47d38d10 882 */
phungductung 0:8ede47d38d10 883 #define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \
phungductung 0:8ede47d38d10 884 do{ \
phungductung 0:8ede47d38d10 885 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \
phungductung 0:8ede47d38d10 886 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \
phungductung 0:8ede47d38d10 887 } while(0)
phungductung 0:8ede47d38d10 888
phungductung 0:8ede47d38d10 889 /** @brief Disable RTS flow control
phungductung 0:8ede47d38d10 890 * This macro allows to disable RTS hardware flow control for a given UART instance,
phungductung 0:8ede47d38d10 891 * without need to call HAL_UART_Init() function.
phungductung 0:8ede47d38d10 892 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
phungductung 0:8ede47d38d10 893 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
phungductung 0:8ede47d38d10 894 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
phungductung 0:8ede47d38d10 895 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
phungductung 0:8ede47d38d10 896 * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
phungductung 0:8ede47d38d10 897 * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
phungductung 0:8ede47d38d10 898 * @param __HANDLE__: specifies the UART Handle.
phungductung 0:8ede47d38d10 899 * The Handle Instance can be USART1, USART2 or LPUART.
phungductung 0:8ede47d38d10 900 * @retval None
phungductung 0:8ede47d38d10 901 */
phungductung 0:8ede47d38d10 902 #define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \
phungductung 0:8ede47d38d10 903 do{ \
phungductung 0:8ede47d38d10 904 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\
phungductung 0:8ede47d38d10 905 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \
phungductung 0:8ede47d38d10 906 } while(0)
phungductung 0:8ede47d38d10 907
phungductung 0:8ede47d38d10 908 /**
phungductung 0:8ede47d38d10 909 * @}
phungductung 0:8ede47d38d10 910 */
phungductung 0:8ede47d38d10 911
phungductung 0:8ede47d38d10 912 /* Private macros --------------------------------------------------------*/
phungductung 0:8ede47d38d10 913 /** @defgroup UART_Private_Macros UART Private Macros
phungductung 0:8ede47d38d10 914 * @{
phungductung 0:8ede47d38d10 915 */
phungductung 0:8ede47d38d10 916 /** @brief BRR division operation to set BRR register with LPUART
phungductung 0:8ede47d38d10 917 * @param _PCLK_: LPUART clock
phungductung 0:8ede47d38d10 918 * @param _BAUD_: Baud rate set by the user
phungductung 0:8ede47d38d10 919 * @retval Division result
phungductung 0:8ede47d38d10 920 */
phungductung 0:8ede47d38d10 921 #define UART_DIV_LPUART(_PCLK_, _BAUD_) (((_PCLK_)*256)/((_BAUD_)))
phungductung 0:8ede47d38d10 922
phungductung 0:8ede47d38d10 923 /** @brief BRR division operation to set BRR register in 8-bit oversampling mode
phungductung 0:8ede47d38d10 924 * @param _PCLK_: UART clock
phungductung 0:8ede47d38d10 925 * @param _BAUD_: Baud rate set by the user
phungductung 0:8ede47d38d10 926 * @retval Division result
phungductung 0:8ede47d38d10 927 */
phungductung 0:8ede47d38d10 928 #define UART_DIV_SAMPLING8(_PCLK_, _BAUD_) (((_PCLK_)*2)/((_BAUD_)))
phungductung 0:8ede47d38d10 929
phungductung 0:8ede47d38d10 930 /** @brief BRR division operation to set BRR register in 16-bit oversampling mode
phungductung 0:8ede47d38d10 931 * @param _PCLK_: UART clock
phungductung 0:8ede47d38d10 932 * @param _BAUD_: Baud rate set by the user
phungductung 0:8ede47d38d10 933 * @retval Division result
phungductung 0:8ede47d38d10 934 */
phungductung 0:8ede47d38d10 935 #define UART_DIV_SAMPLING16(_PCLK_, _BAUD_) (((_PCLK_))/((_BAUD_)))
phungductung 0:8ede47d38d10 936
phungductung 0:8ede47d38d10 937 /** @brief Check UART Baud rate
phungductung 0:8ede47d38d10 938 * @param BAUDRATE: Baudrate specified by the user
phungductung 0:8ede47d38d10 939 * The maximum Baud Rate is derived from the maximum clock on F7 (i.e. 216 MHz)
phungductung 0:8ede47d38d10 940 * divided by the smallest oversampling used on the USART (i.e. 8)
phungductung 0:8ede47d38d10 941 * @retval Test result (TRUE or FALSE).
phungductung 0:8ede47d38d10 942 */
phungductung 0:8ede47d38d10 943 #define IS_UART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 9000001)
phungductung 0:8ede47d38d10 944
phungductung 0:8ede47d38d10 945 /** @brief Check UART assertion time
phungductung 0:8ede47d38d10 946 * @param TIME: 5-bit value assertion time
phungductung 0:8ede47d38d10 947 * @retval Test result (TRUE or FALSE).
phungductung 0:8ede47d38d10 948 */
phungductung 0:8ede47d38d10 949 #define IS_UART_ASSERTIONTIME(TIME) ((TIME) <= 0x1F)
phungductung 0:8ede47d38d10 950
phungductung 0:8ede47d38d10 951 /** @brief Check UART deassertion time
phungductung 0:8ede47d38d10 952 * @param TIME: 5-bit value deassertion time
phungductung 0:8ede47d38d10 953 * @retval Test result (TRUE or FALSE).
phungductung 0:8ede47d38d10 954 */
phungductung 0:8ede47d38d10 955 #define IS_UART_DEASSERTIONTIME(TIME) ((TIME) <= 0x1F)
phungductung 0:8ede47d38d10 956
phungductung 0:8ede47d38d10 957 #define IS_UART_STOPBITS(STOPBITS) (((STOPBITS) == UART_STOPBITS_1) || \
phungductung 0:8ede47d38d10 958 ((STOPBITS) == UART_STOPBITS_2))
phungductung 0:8ede47d38d10 959
phungductung 0:8ede47d38d10 960 #define IS_UART_PARITY(PARITY) (((PARITY) == UART_PARITY_NONE) || \
phungductung 0:8ede47d38d10 961 ((PARITY) == UART_PARITY_EVEN) || \
phungductung 0:8ede47d38d10 962 ((PARITY) == UART_PARITY_ODD))
phungductung 0:8ede47d38d10 963
phungductung 0:8ede47d38d10 964 #define IS_UART_HARDWARE_FLOW_CONTROL(CONTROL)\
phungductung 0:8ede47d38d10 965 (((CONTROL) == UART_HWCONTROL_NONE) || \
phungductung 0:8ede47d38d10 966 ((CONTROL) == UART_HWCONTROL_RTS) || \
phungductung 0:8ede47d38d10 967 ((CONTROL) == UART_HWCONTROL_CTS) || \
phungductung 0:8ede47d38d10 968 ((CONTROL) == UART_HWCONTROL_RTS_CTS))
phungductung 0:8ede47d38d10 969
phungductung 0:8ede47d38d10 970 #define IS_UART_MODE(MODE) ((((MODE) & (~((uint32_t)(UART_MODE_TX_RX)))) == (uint32_t)0x00) && ((MODE) != (uint32_t)0x00))
phungductung 0:8ede47d38d10 971
phungductung 0:8ede47d38d10 972 #define IS_UART_STATE(STATE) (((STATE) == UART_STATE_DISABLE) || \
phungductung 0:8ede47d38d10 973 ((STATE) == UART_STATE_ENABLE))
phungductung 0:8ede47d38d10 974
phungductung 0:8ede47d38d10 975 #define IS_UART_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16) || \
phungductung 0:8ede47d38d10 976 ((SAMPLING) == UART_OVERSAMPLING_8))
phungductung 0:8ede47d38d10 977
phungductung 0:8ede47d38d10 978 #define IS_UART_ONE_BIT_SAMPLE(ONEBIT) (((ONEBIT) == UART_ONE_BIT_SAMPLE_DISABLE) || \
phungductung 0:8ede47d38d10 979 ((ONEBIT) == UART_ONE_BIT_SAMPLE_ENABLE))
phungductung 0:8ede47d38d10 980
phungductung 0:8ede47d38d10 981 #define IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(MODE) (((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT) || \
phungductung 0:8ede47d38d10 982 ((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE) || \
phungductung 0:8ede47d38d10 983 ((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME) || \
phungductung 0:8ede47d38d10 984 ((MODE) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME))
phungductung 0:8ede47d38d10 985
phungductung 0:8ede47d38d10 986 #define IS_UART_RECEIVER_TIMEOUT(TIMEOUT) (((TIMEOUT) == UART_RECEIVER_TIMEOUT_DISABLE) || \
phungductung 0:8ede47d38d10 987 ((TIMEOUT) == UART_RECEIVER_TIMEOUT_ENABLE))
phungductung 0:8ede47d38d10 988
phungductung 0:8ede47d38d10 989 #define IS_UART_LIN(LIN) (((LIN) == UART_LIN_DISABLE) || \
phungductung 0:8ede47d38d10 990 ((LIN) == UART_LIN_ENABLE))
phungductung 0:8ede47d38d10 991
phungductung 0:8ede47d38d10 992 #define IS_UART_WAKEUPMETHOD(WAKEUP) (((WAKEUP) == UART_WAKEUPMETHOD_IDLELINE) || \
phungductung 0:8ede47d38d10 993 ((WAKEUP) == UART_WAKEUPMETHOD_ADDRESSMARK))
phungductung 0:8ede47d38d10 994
phungductung 0:8ede47d38d10 995 #define IS_UART_LIN_BREAK_DETECT_LENGTH(LENGTH) (((LENGTH) == UART_LINBREAKDETECTLENGTH_10B) || \
phungductung 0:8ede47d38d10 996 ((LENGTH) == UART_LINBREAKDETECTLENGTH_11B))
phungductung 0:8ede47d38d10 997
phungductung 0:8ede47d38d10 998 #define IS_UART_DMA_TX(DMATX) (((DMATX) == UART_DMA_TX_DISABLE) || \
phungductung 0:8ede47d38d10 999 ((DMATX) == UART_DMA_TX_ENABLE))
phungductung 0:8ede47d38d10 1000
phungductung 0:8ede47d38d10 1001 #define IS_UART_DMA_RX(DMARX) (((DMARX) == UART_DMA_RX_DISABLE) || \
phungductung 0:8ede47d38d10 1002 ((DMARX) == UART_DMA_RX_ENABLE))
phungductung 0:8ede47d38d10 1003
phungductung 0:8ede47d38d10 1004 #define IS_UART_HALF_DUPLEX(HDSEL) (((HDSEL) == UART_HALF_DUPLEX_DISABLE) || \
phungductung 0:8ede47d38d10 1005 ((HDSEL) == UART_HALF_DUPLEX_ENABLE))
phungductung 0:8ede47d38d10 1006
phungductung 0:8ede47d38d10 1007 #define IS_UART_REQUEST_PARAMETER(PARAM) (((PARAM) == UART_AUTOBAUD_REQUEST) || \
phungductung 0:8ede47d38d10 1008 ((PARAM) == UART_SENDBREAK_REQUEST) || \
phungductung 0:8ede47d38d10 1009 ((PARAM) == UART_MUTE_MODE_REQUEST) || \
phungductung 0:8ede47d38d10 1010 ((PARAM) == UART_RXDATA_FLUSH_REQUEST) || \
phungductung 0:8ede47d38d10 1011 ((PARAM) == UART_TXDATA_FLUSH_REQUEST))
phungductung 0:8ede47d38d10 1012
phungductung 0:8ede47d38d10 1013 #define IS_UART_ADVFEATURE_INIT(INIT) ((INIT) <= (UART_ADVFEATURE_NO_INIT | \
phungductung 0:8ede47d38d10 1014 UART_ADVFEATURE_TXINVERT_INIT | \
phungductung 0:8ede47d38d10 1015 UART_ADVFEATURE_RXINVERT_INIT | \
phungductung 0:8ede47d38d10 1016 UART_ADVFEATURE_DATAINVERT_INIT | \
phungductung 0:8ede47d38d10 1017 UART_ADVFEATURE_SWAP_INIT | \
phungductung 0:8ede47d38d10 1018 UART_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
phungductung 0:8ede47d38d10 1019 UART_ADVFEATURE_DMADISABLEONERROR_INIT | \
phungductung 0:8ede47d38d10 1020 UART_ADVFEATURE_AUTOBAUDRATE_INIT | \
phungductung 0:8ede47d38d10 1021 UART_ADVFEATURE_MSBFIRST_INIT))
phungductung 0:8ede47d38d10 1022
phungductung 0:8ede47d38d10 1023 #define IS_UART_ADVFEATURE_TXINV(TXINV) (((TXINV) == UART_ADVFEATURE_TXINV_DISABLE) || \
phungductung 0:8ede47d38d10 1024 ((TXINV) == UART_ADVFEATURE_TXINV_ENABLE))
phungductung 0:8ede47d38d10 1025
phungductung 0:8ede47d38d10 1026 #define IS_UART_ADVFEATURE_RXINV(RXINV) (((RXINV) == UART_ADVFEATURE_RXINV_DISABLE) || \
phungductung 0:8ede47d38d10 1027 ((RXINV) == UART_ADVFEATURE_RXINV_ENABLE))
phungductung 0:8ede47d38d10 1028
phungductung 0:8ede47d38d10 1029 #define IS_UART_ADVFEATURE_DATAINV(DATAINV) (((DATAINV) == UART_ADVFEATURE_DATAINV_DISABLE) || \
phungductung 0:8ede47d38d10 1030 ((DATAINV) == UART_ADVFEATURE_DATAINV_ENABLE))
phungductung 0:8ede47d38d10 1031
phungductung 0:8ede47d38d10 1032 #define IS_UART_ADVFEATURE_SWAP(SWAP) (((SWAP) == UART_ADVFEATURE_SWAP_DISABLE) || \
phungductung 0:8ede47d38d10 1033 ((SWAP) == UART_ADVFEATURE_SWAP_ENABLE))
phungductung 0:8ede47d38d10 1034
phungductung 0:8ede47d38d10 1035 #define IS_UART_OVERRUN(OVERRUN) (((OVERRUN) == UART_ADVFEATURE_OVERRUN_ENABLE) || \
phungductung 0:8ede47d38d10 1036 ((OVERRUN) == UART_ADVFEATURE_OVERRUN_DISABLE))
phungductung 0:8ede47d38d10 1037
phungductung 0:8ede47d38d10 1038 #define IS_UART_ADVFEATURE_AUTOBAUDRATE(AUTOBAUDRATE) (((AUTOBAUDRATE) == UART_ADVFEATURE_AUTOBAUDRATE_DISABLE) || \
phungductung 0:8ede47d38d10 1039 ((AUTOBAUDRATE) == UART_ADVFEATURE_AUTOBAUDRATE_ENABLE))
phungductung 0:8ede47d38d10 1040
phungductung 0:8ede47d38d10 1041 #define IS_UART_ADVFEATURE_DMAONRXERROR(DMA) (((DMA) == UART_ADVFEATURE_DMA_ENABLEONRXERROR) || \
phungductung 0:8ede47d38d10 1042 ((DMA) == UART_ADVFEATURE_DMA_DISABLEONRXERROR))
phungductung 0:8ede47d38d10 1043
phungductung 0:8ede47d38d10 1044 #define IS_UART_ADVFEATURE_MSBFIRST(MSBFIRST) (((MSBFIRST) == UART_ADVFEATURE_MSBFIRST_DISABLE) || \
phungductung 0:8ede47d38d10 1045 ((MSBFIRST) == UART_ADVFEATURE_MSBFIRST_ENABLE))
phungductung 0:8ede47d38d10 1046
phungductung 0:8ede47d38d10 1047 #define IS_UART_MUTE_MODE(MUTE) (((MUTE) == UART_ADVFEATURE_MUTEMODE_DISABLE) || \
phungductung 0:8ede47d38d10 1048 ((MUTE) == UART_ADVFEATURE_MUTEMODE_ENABLE))
phungductung 0:8ede47d38d10 1049
phungductung 0:8ede47d38d10 1050 #define IS_UART_DE_POLARITY(POLARITY) (((POLARITY) == UART_DE_POLARITY_HIGH) || \
phungductung 0:8ede47d38d10 1051 ((POLARITY) == UART_DE_POLARITY_LOW))
phungductung 0:8ede47d38d10 1052
phungductung 0:8ede47d38d10 1053 /**
phungductung 0:8ede47d38d10 1054 * @}
phungductung 0:8ede47d38d10 1055 */
phungductung 0:8ede47d38d10 1056 /* Include UART HAL Extension module */
phungductung 0:8ede47d38d10 1057 #include "stm32f7xx_hal_uart_ex.h"
phungductung 0:8ede47d38d10 1058 /* Exported functions --------------------------------------------------------*/
phungductung 0:8ede47d38d10 1059 /** @addtogroup UART_Exported_Functions UART Exported Functions
phungductung 0:8ede47d38d10 1060 * @{
phungductung 0:8ede47d38d10 1061 */
phungductung 0:8ede47d38d10 1062
phungductung 0:8ede47d38d10 1063 /** @addtogroup UART_Exported_Functions_Group1 Initialization and de-initialization functions
phungductung 0:8ede47d38d10 1064 * @{
phungductung 0:8ede47d38d10 1065 */
phungductung 0:8ede47d38d10 1066
phungductung 0:8ede47d38d10 1067 /* Initialization and de-initialization functions ****************************/
phungductung 0:8ede47d38d10 1068 HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1069 HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1070 HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength);
phungductung 0:8ede47d38d10 1071 HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod);
phungductung 0:8ede47d38d10 1072 HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1073 void HAL_UART_MspInit(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1074 void HAL_UART_MspDeInit(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1075
phungductung 0:8ede47d38d10 1076 /**
phungductung 0:8ede47d38d10 1077 * @}
phungductung 0:8ede47d38d10 1078 */
phungductung 0:8ede47d38d10 1079
phungductung 0:8ede47d38d10 1080 /** @addtogroup UART_Exported_Functions_Group2 IO operation functions
phungductung 0:8ede47d38d10 1081 * @{
phungductung 0:8ede47d38d10 1082 */
phungductung 0:8ede47d38d10 1083
phungductung 0:8ede47d38d10 1084 /* IO operation functions *****************************************************/
phungductung 0:8ede47d38d10 1085 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
phungductung 0:8ede47d38d10 1086 HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
phungductung 0:8ede47d38d10 1087 HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
phungductung 0:8ede47d38d10 1088 HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
phungductung 0:8ede47d38d10 1089 HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
phungductung 0:8ede47d38d10 1090 HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
phungductung 0:8ede47d38d10 1091 HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1092 HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1093 HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1094 void HAL_UART_IRQHandler(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1095 void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1096 void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1097 void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1098 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1099 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1100
phungductung 0:8ede47d38d10 1101 /**
phungductung 0:8ede47d38d10 1102 * @}
phungductung 0:8ede47d38d10 1103 */
phungductung 0:8ede47d38d10 1104
phungductung 0:8ede47d38d10 1105 /** @addtogroup UART_Exported_Functions_Group3 Peripheral Control functions
phungductung 0:8ede47d38d10 1106 * @{
phungductung 0:8ede47d38d10 1107 */
phungductung 0:8ede47d38d10 1108
phungductung 0:8ede47d38d10 1109 /* Peripheral Control functions ************************************************/
phungductung 0:8ede47d38d10 1110 HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1111 HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1112 HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1113 void HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1114 HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1115 HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1116
phungductung 0:8ede47d38d10 1117 /**
phungductung 0:8ede47d38d10 1118 * @}
phungductung 0:8ede47d38d10 1119 */
phungductung 0:8ede47d38d10 1120
phungductung 0:8ede47d38d10 1121 /** @addtogroup UART_Exported_Functions_Group4 Peripheral State and Error functions
phungductung 0:8ede47d38d10 1122 * @{
phungductung 0:8ede47d38d10 1123 */
phungductung 0:8ede47d38d10 1124
phungductung 0:8ede47d38d10 1125 /* Peripheral State and Errors functions **************************************************/
phungductung 0:8ede47d38d10 1126 HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1127 uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1128
phungductung 0:8ede47d38d10 1129 /**
phungductung 0:8ede47d38d10 1130 * @}
phungductung 0:8ede47d38d10 1131 */
phungductung 0:8ede47d38d10 1132
phungductung 0:8ede47d38d10 1133 /**
phungductung 0:8ede47d38d10 1134 * @}
phungductung 0:8ede47d38d10 1135 */
phungductung 0:8ede47d38d10 1136
phungductung 0:8ede47d38d10 1137 /* Private functions -----------------------------------------------------------*/
phungductung 0:8ede47d38d10 1138 /** @addtogroup UART_Private_Functions UART Private Functions
phungductung 0:8ede47d38d10 1139 * @{
phungductung 0:8ede47d38d10 1140 */
phungductung 0:8ede47d38d10 1141
phungductung 0:8ede47d38d10 1142 HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1143 HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1144 HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Timeout);
phungductung 0:8ede47d38d10 1145 void UART_AdvFeatureConfig(UART_HandleTypeDef *huart);
phungductung 0:8ede47d38d10 1146
phungductung 0:8ede47d38d10 1147 /**
phungductung 0:8ede47d38d10 1148 * @}
phungductung 0:8ede47d38d10 1149 */
phungductung 0:8ede47d38d10 1150
phungductung 0:8ede47d38d10 1151 /**
phungductung 0:8ede47d38d10 1152 * @}
phungductung 0:8ede47d38d10 1153 */
phungductung 0:8ede47d38d10 1154
phungductung 0:8ede47d38d10 1155 /**
phungductung 0:8ede47d38d10 1156 * @}
phungductung 0:8ede47d38d10 1157 */
phungductung 0:8ede47d38d10 1158
phungductung 0:8ede47d38d10 1159 #ifdef __cplusplus
phungductung 0:8ede47d38d10 1160 }
phungductung 0:8ede47d38d10 1161 #endif
phungductung 0:8ede47d38d10 1162
phungductung 0:8ede47d38d10 1163 #endif /* __STM32F7xx_HAL_UART_H */
phungductung 0:8ede47d38d10 1164
phungductung 0:8ede47d38d10 1165 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/