mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Fri Aug 12 13:04:35 2016 +0200
Revision:
123:b0220dba8be7
Parent:
122:f9eeca106725
Release 123 of the mbed library

Changes:
- new targets: nucleo_f207zg, beetle, nrf51_dk, hexiwear,
nuvoton nuc472, vk rz a1h
- ST - fix timer interrupt handler, sleep api fix
- NXP - lpc15xx us ticker fix
- Nordic - analogin fixes, LF clock init addition, enable i2c async

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 109:9296ab0bfc11 1 /**
Kojto 109:9296ab0bfc11 2 ******************************************************************************
Kojto 109:9296ab0bfc11 3 * @file stm32f3xx_hal_uart.h
Kojto 109:9296ab0bfc11 4 * @author MCD Application Team
Kojto 123:b0220dba8be7 5 * @version V1.3.0
Kojto 123:b0220dba8be7 6 * @date 01-July-2016
Kojto 109:9296ab0bfc11 7 * @brief Header file of UART HAL module.
Kojto 109:9296ab0bfc11 8 ******************************************************************************
Kojto 109:9296ab0bfc11 9 * @attention
Kojto 109:9296ab0bfc11 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 109:9296ab0bfc11 12 *
Kojto 109:9296ab0bfc11 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 109:9296ab0bfc11 14 * are permitted provided that the following conditions are met:
Kojto 109:9296ab0bfc11 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 109:9296ab0bfc11 16 * this list of conditions and the following disclaimer.
Kojto 109:9296ab0bfc11 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 109:9296ab0bfc11 18 * this list of conditions and the following disclaimer in the documentation
Kojto 109:9296ab0bfc11 19 * and/or other materials provided with the distribution.
Kojto 109:9296ab0bfc11 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 109:9296ab0bfc11 21 * may be used to endorse or promote products derived from this software
Kojto 109:9296ab0bfc11 22 * without specific prior written permission.
Kojto 109:9296ab0bfc11 23 *
Kojto 109:9296ab0bfc11 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 109:9296ab0bfc11 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 109:9296ab0bfc11 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 109:9296ab0bfc11 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 109:9296ab0bfc11 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 109:9296ab0bfc11 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 109:9296ab0bfc11 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 109:9296ab0bfc11 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 109:9296ab0bfc11 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 109:9296ab0bfc11 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 109:9296ab0bfc11 34 *
Kojto 109:9296ab0bfc11 35 ******************************************************************************
Kojto 109:9296ab0bfc11 36 */
Kojto 109:9296ab0bfc11 37
Kojto 109:9296ab0bfc11 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 109:9296ab0bfc11 39 #ifndef __STM32F3xx_HAL_UART_H
Kojto 109:9296ab0bfc11 40 #define __STM32F3xx_HAL_UART_H
Kojto 109:9296ab0bfc11 41
Kojto 109:9296ab0bfc11 42 #ifdef __cplusplus
Kojto 109:9296ab0bfc11 43 extern "C" {
Kojto 109:9296ab0bfc11 44 #endif
Kojto 109:9296ab0bfc11 45
Kojto 109:9296ab0bfc11 46 /* Includes ------------------------------------------------------------------*/
Kojto 109:9296ab0bfc11 47 #include "stm32f3xx_hal_def.h"
Kojto 109:9296ab0bfc11 48
Kojto 109:9296ab0bfc11 49 /** @addtogroup STM32F3xx_HAL_Driver
Kojto 109:9296ab0bfc11 50 * @{
Kojto 109:9296ab0bfc11 51 */
Kojto 109:9296ab0bfc11 52
Kojto 109:9296ab0bfc11 53 /** @addtogroup UART
Kojto 109:9296ab0bfc11 54 * @{
Kojto 122:f9eeca106725 55 */
Kojto 109:9296ab0bfc11 56
Kojto 122:f9eeca106725 57 /* Exported types ------------------------------------------------------------*/
Kojto 109:9296ab0bfc11 58 /** @defgroup UART_Exported_Types UART Exported Types
Kojto 109:9296ab0bfc11 59 * @{
Kojto 109:9296ab0bfc11 60 */
Kojto 109:9296ab0bfc11 61
Kojto 122:f9eeca106725 62 /**
Kojto 122:f9eeca106725 63 * @brief UART Init Structure definition
Kojto 122:f9eeca106725 64 */
Kojto 109:9296ab0bfc11 65 typedef struct
Kojto 109:9296ab0bfc11 66 {
Kojto 109:9296ab0bfc11 67 uint32_t BaudRate; /*!< This member configures the UART communication baud rate.
Kojto 109:9296ab0bfc11 68 The baud rate register is computed using the following formula:
Kojto 109:9296ab0bfc11 69 - If oversampling is 16 or in LIN mode,
Kojto 109:9296ab0bfc11 70 Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate)))
Kojto 109:9296ab0bfc11 71 - If oversampling is 8,
Kojto 122:f9eeca106725 72 Baud Rate Register[15:4] = ((2 * PCLKx) / ((huart->Init.BaudRate)))[15:4]
Kojto 109:9296ab0bfc11 73 Baud Rate Register[3] = 0
Kojto 109:9296ab0bfc11 74 Baud Rate Register[2:0] = (((2 * PCLKx) / ((huart->Init.BaudRate)))[3:0]) >> 1 */
Kojto 109:9296ab0bfc11 75
Kojto 109:9296ab0bfc11 76 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
Kojto 109:9296ab0bfc11 77 This parameter can be a value of @ref UARTEx_Word_Length */
Kojto 109:9296ab0bfc11 78
Kojto 109:9296ab0bfc11 79 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
Kojto 109:9296ab0bfc11 80 This parameter can be a value of @ref UART_Stop_Bits */
Kojto 109:9296ab0bfc11 81
Kojto 109:9296ab0bfc11 82 uint32_t Parity; /*!< Specifies the parity mode.
Kojto 109:9296ab0bfc11 83 This parameter can be a value of @ref UART_Parity
Kojto 109:9296ab0bfc11 84 @note When parity is enabled, the computed parity is inserted
Kojto 109:9296ab0bfc11 85 at the MSB position of the transmitted data (9th bit when
Kojto 109:9296ab0bfc11 86 the word length is set to 9 data bits; 8th bit when the
Kojto 109:9296ab0bfc11 87 word length is set to 8 data bits). */
Kojto 122:f9eeca106725 88
Kojto 109:9296ab0bfc11 89 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
Kojto 109:9296ab0bfc11 90 This parameter can be a value of @ref UART_Mode */
Kojto 109:9296ab0bfc11 91
Kojto 109:9296ab0bfc11 92 uint32_t HwFlowCtl; /*!< Specifies whether the hardware flow control mode is enabled
Kojto 109:9296ab0bfc11 93 or disabled.
Kojto 109:9296ab0bfc11 94 This parameter can be a value of @ref UART_Hardware_Flow_Control */
Kojto 122:f9eeca106725 95
Kojto 122:f9eeca106725 96 uint32_t OverSampling; /*!< Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to f_PCLK/8).
Kojto 122:f9eeca106725 97 This parameter can be a value of @ref UART_Over_Sampling */
Kojto 122:f9eeca106725 98
Kojto 109:9296ab0bfc11 99 uint32_t OneBitSampling; /*!< Specifies whether a single sample or three samples' majority vote is selected.
Kojto 109:9296ab0bfc11 100 Selecting the single sample method increases the receiver tolerance to clock
Kojto 122:f9eeca106725 101 deviations. This parameter can be a value of @ref UART_OneBit_Sampling. */
Kojto 109:9296ab0bfc11 102 }UART_InitTypeDef;
Kojto 109:9296ab0bfc11 103
Kojto 122:f9eeca106725 104 /**
Kojto 122:f9eeca106725 105 * @brief UART Advanced Features initalization structure definition
Kojto 109:9296ab0bfc11 106 */
Kojto 122:f9eeca106725 107 typedef struct
Kojto 109:9296ab0bfc11 108 {
Kojto 109:9296ab0bfc11 109 uint32_t AdvFeatureInit; /*!< Specifies which advanced UART features is initialized. Several
Kojto 109:9296ab0bfc11 110 Advanced Features may be initialized at the same time .
Kojto 109:9296ab0bfc11 111 This parameter can be a value of @ref UART_Advanced_Features_Initialization_Type */
Kojto 122:f9eeca106725 112
Kojto 109:9296ab0bfc11 113 uint32_t TxPinLevelInvert; /*!< Specifies whether the TX pin active level is inverted.
Kojto 109:9296ab0bfc11 114 This parameter can be a value of @ref UART_Tx_Inv */
Kojto 122:f9eeca106725 115
Kojto 109:9296ab0bfc11 116 uint32_t RxPinLevelInvert; /*!< Specifies whether the RX pin active level is inverted.
Kojto 109:9296ab0bfc11 117 This parameter can be a value of @ref UART_Rx_Inv */
Kojto 109:9296ab0bfc11 118
Kojto 109:9296ab0bfc11 119 uint32_t DataInvert; /*!< Specifies whether data are inverted (positive/direct logic
Kojto 109:9296ab0bfc11 120 vs negative/inverted logic).
Kojto 109:9296ab0bfc11 121 This parameter can be a value of @ref UART_Data_Inv */
Kojto 122:f9eeca106725 122
Kojto 122:f9eeca106725 123 uint32_t Swap; /*!< Specifies whether TX and RX pins are swapped.
Kojto 109:9296ab0bfc11 124 This parameter can be a value of @ref UART_Rx_Tx_Swap */
Kojto 122:f9eeca106725 125
Kojto 122:f9eeca106725 126 uint32_t OverrunDisable; /*!< Specifies whether the reception overrun detection is disabled.
Kojto 109:9296ab0bfc11 127 This parameter can be a value of @ref UART_Overrun_Disable */
Kojto 122:f9eeca106725 128
Kojto 122:f9eeca106725 129 uint32_t DMADisableonRxError; /*!< Specifies whether the DMA is disabled in case of reception error.
Kojto 109:9296ab0bfc11 130 This parameter can be a value of @ref UART_DMA_Disable_on_Rx_Error */
Kojto 122:f9eeca106725 131
Kojto 122:f9eeca106725 132 uint32_t AutoBaudRateEnable; /*!< Specifies whether auto Baud rate detection is enabled.
Kojto 122:f9eeca106725 133 This parameter can be a value of @ref UART_AutoBaudRate_Enable */
Kojto 122:f9eeca106725 134
Kojto 122:f9eeca106725 135 uint32_t AutoBaudRateMode; /*!< If auto Baud rate detection is enabled, specifies how the rate
Kojto 122:f9eeca106725 136 detection is carried out.
Kojto 109:9296ab0bfc11 137 This parameter can be a value of @ref UART_AutoBaud_Rate_Mode */
Kojto 122:f9eeca106725 138
Kojto 122:f9eeca106725 139 uint32_t MSBFirst; /*!< Specifies whether MSB is sent first on UART line.
Kojto 109:9296ab0bfc11 140 This parameter can be a value of @ref UART_MSB_First */
Kojto 109:9296ab0bfc11 141 } UART_AdvFeatureInitTypeDef;
Kojto 109:9296ab0bfc11 142
Kojto 122:f9eeca106725 143 /**
Kojto 122:f9eeca106725 144 * @brief UART wake up from stop mode parameters
Kojto 109:9296ab0bfc11 145 */
Kojto 122:f9eeca106725 146 typedef struct
Kojto 109:9296ab0bfc11 147 {
Kojto 109:9296ab0bfc11 148 uint32_t WakeUpEvent; /*!< Specifies which event will activat the Wakeup from Stop mode flag (WUF).
Kojto 109:9296ab0bfc11 149 This parameter can be a value of @ref UART_WakeUp_from_Stop_Selection.
Kojto 109:9296ab0bfc11 150 If set to UART_WAKEUP_ON_ADDRESS, the two other fields below must
Kojto 109:9296ab0bfc11 151 be filled up. */
Kojto 122:f9eeca106725 152
Kojto 109:9296ab0bfc11 153 uint16_t AddressLength; /*!< Specifies whether the address is 4 or 7-bit long.
Kojto 109:9296ab0bfc11 154 This parameter can be a value of @ref UART_WakeUp_Address_Length */
Kojto 122:f9eeca106725 155
Kojto 109:9296ab0bfc11 156 uint8_t Address; /*!< UART/USART node address (7-bit long max) */
Kojto 109:9296ab0bfc11 157 } UART_WakeUpTypeDef;
Kojto 109:9296ab0bfc11 158
Kojto 122:f9eeca106725 159 /**
Kojto 122:f9eeca106725 160 * @brief HAL UART State structures definition
Kojto 122:f9eeca106725 161 * @note HAL UART State value is a combination of 2 different substates: gState and RxState.
Kojto 122:f9eeca106725 162 * - gState contains UART state information related to global Handle management
Kojto 122:f9eeca106725 163 * and also information related to Tx operations.
Kojto 122:f9eeca106725 164 * gState value coding follow below described bitmap :
Kojto 122:f9eeca106725 165 * b7-b6 Error information
Kojto 122:f9eeca106725 166 * 00 : No Error
Kojto 122:f9eeca106725 167 * 01 : (Not Used)
Kojto 122:f9eeca106725 168 * 10 : Timeout
Kojto 122:f9eeca106725 169 * 11 : Error
Kojto 122:f9eeca106725 170 * b5 IP initilisation status
Kojto 122:f9eeca106725 171 * 0 : Reset (IP not initialized)
Kojto 122:f9eeca106725 172 * 1 : Init done (IP not initialized. HAL UART Init function already called)
Kojto 122:f9eeca106725 173 * b4-b3 (not used)
Kojto 122:f9eeca106725 174 * xx : Should be set to 00
Kojto 122:f9eeca106725 175 * b2 Intrinsic process state
Kojto 122:f9eeca106725 176 * 0 : Ready
Kojto 122:f9eeca106725 177 * 1 : Busy (IP busy with some configuration or internal operations)
Kojto 122:f9eeca106725 178 * b1 (not used)
Kojto 122:f9eeca106725 179 * x : Should be set to 0
Kojto 122:f9eeca106725 180 * b0 Tx state
Kojto 122:f9eeca106725 181 * 0 : Ready (no Tx operation ongoing)
Kojto 122:f9eeca106725 182 * 1 : Busy (Tx operation ongoing)
Kojto 122:f9eeca106725 183 * - RxState contains information related to Rx operations.
Kojto 122:f9eeca106725 184 * RxState value coding follow below described bitmap :
Kojto 122:f9eeca106725 185 * b7-b6 (not used)
Kojto 122:f9eeca106725 186 * xx : Should be set to 00
Kojto 122:f9eeca106725 187 * b5 IP initilisation status
Kojto 122:f9eeca106725 188 * 0 : Reset (IP not initialized)
Kojto 122:f9eeca106725 189 * 1 : Init done (IP not initialized)
Kojto 122:f9eeca106725 190 * b4-b2 (not used)
Kojto 122:f9eeca106725 191 * xxx : Should be set to 000
Kojto 122:f9eeca106725 192 * b1 Rx state
Kojto 122:f9eeca106725 193 * 0 : Ready (no Rx operation ongoing)
Kojto 122:f9eeca106725 194 * 1 : Busy (Rx operation ongoing)
Kojto 122:f9eeca106725 195 * b0 (not used)
Kojto 122:f9eeca106725 196 * x : Should be set to 0.
Kojto 122:f9eeca106725 197 */
Kojto 109:9296ab0bfc11 198 typedef enum
Kojto 109:9296ab0bfc11 199 {
Kojto 122:f9eeca106725 200 HAL_UART_STATE_RESET = 0x00U, /*!< Peripheral is not initialized
Kojto 122:f9eeca106725 201 Value is allowed for gState and RxState */
Kojto 122:f9eeca106725 202 HAL_UART_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use
Kojto 122:f9eeca106725 203 Value is allowed for gState and RxState */
Kojto 122:f9eeca106725 204 HAL_UART_STATE_BUSY = 0x24U, /*!< an internal process is ongoing
Kojto 122:f9eeca106725 205 Value is allowed for gState only */
Kojto 122:f9eeca106725 206 HAL_UART_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing
Kojto 122:f9eeca106725 207 Value is allowed for gState only */
Kojto 122:f9eeca106725 208 HAL_UART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing
Kojto 122:f9eeca106725 209 Value is allowed for RxState only */
Kojto 122:f9eeca106725 210 HAL_UART_STATE_BUSY_TX_RX = 0x23U, /*!< Data Transmission and Reception process is ongoing
Kojto 122:f9eeca106725 211 Not to be used for neither gState nor RxState.
Kojto 122:f9eeca106725 212 Value is result of combination (Or) between gState and RxState values */
Kojto 122:f9eeca106725 213 HAL_UART_STATE_TIMEOUT = 0xA0U, /*!< Timeout state
Kojto 122:f9eeca106725 214 Value is allowed for gState only */
Kojto 122:f9eeca106725 215 HAL_UART_STATE_ERROR = 0xE0U /*!< Error
Kojto 122:f9eeca106725 216 Value is allowed for gState only */
Kojto 109:9296ab0bfc11 217 }HAL_UART_StateTypeDef;
Kojto 109:9296ab0bfc11 218
Kojto 109:9296ab0bfc11 219 /**
Kojto 109:9296ab0bfc11 220 * @brief UART clock sources definition
Kojto 109:9296ab0bfc11 221 */
Kojto 109:9296ab0bfc11 222 typedef enum
Kojto 109:9296ab0bfc11 223 {
Kojto 122:f9eeca106725 224 UART_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */
Kojto 122:f9eeca106725 225 UART_CLOCKSOURCE_PCLK2 = 0x01, /*!< PCLK2 clock source */
Kojto 122:f9eeca106725 226 UART_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */
Kojto 122:f9eeca106725 227 UART_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */
Kojto 122:f9eeca106725 228 UART_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */
Kojto 122:f9eeca106725 229 UART_CLOCKSOURCE_UNDEFINED = 0x10 /*!< Undefined clock source */
Kojto 109:9296ab0bfc11 230 }UART_ClockSourceTypeDef;
Kojto 109:9296ab0bfc11 231
Kojto 122:f9eeca106725 232 /**
Kojto 122:f9eeca106725 233 * @brief UART handle Structure definition
Kojto 122:f9eeca106725 234 */
Kojto 109:9296ab0bfc11 235 typedef struct
Kojto 109:9296ab0bfc11 236 {
Kojto 122:f9eeca106725 237 USART_TypeDef *Instance; /*!< UART registers base address */
Kojto 122:f9eeca106725 238
Kojto 122:f9eeca106725 239 UART_InitTypeDef Init; /*!< UART communication parameters */
Kojto 109:9296ab0bfc11 240
Kojto 122:f9eeca106725 241 UART_AdvFeatureInitTypeDef AdvancedInit; /*!< UART Advanced Features initialization parameters */
Kojto 109:9296ab0bfc11 242
Kojto 122:f9eeca106725 243 uint8_t *pTxBuffPtr; /*!< Pointer to UART Tx transfer Buffer */
Kojto 109:9296ab0bfc11 244
Kojto 122:f9eeca106725 245 uint16_t TxXferSize; /*!< UART Tx Transfer size */
Kojto 109:9296ab0bfc11 246
Kojto 122:f9eeca106725 247 uint16_t TxXferCount; /*!< UART Tx Transfer Counter */
Kojto 109:9296ab0bfc11 248
Kojto 122:f9eeca106725 249 uint8_t *pRxBuffPtr; /*!< Pointer to UART Rx transfer Buffer */
Kojto 109:9296ab0bfc11 250
Kojto 122:f9eeca106725 251 uint16_t RxXferSize; /*!< UART Rx Transfer size */
Kojto 122:f9eeca106725 252
Kojto 122:f9eeca106725 253 uint16_t RxXferCount; /*!< UART Rx Transfer Counter */
Kojto 109:9296ab0bfc11 254
Kojto 122:f9eeca106725 255 uint16_t Mask; /*!< UART Rx RDR register mask */
Kojto 109:9296ab0bfc11 256
Kojto 122:f9eeca106725 257 DMA_HandleTypeDef *hdmatx; /*!< UART Tx DMA Handle parameters */
Kojto 109:9296ab0bfc11 258
Kojto 122:f9eeca106725 259 DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */
Kojto 109:9296ab0bfc11 260
Kojto 122:f9eeca106725 261 HAL_LockTypeDef Lock; /*!< Locking object */
Kojto 109:9296ab0bfc11 262
Kojto 122:f9eeca106725 263 __IO HAL_UART_StateTypeDef gState; /*!< UART state information related to global Handle management
Kojto 122:f9eeca106725 264 and also related to Tx operations.
Kojto 122:f9eeca106725 265 This parameter can be a value of @ref HAL_UART_StateTypeDef */
Kojto 109:9296ab0bfc11 266
Kojto 122:f9eeca106725 267 __IO HAL_UART_StateTypeDef RxState; /*!< UART state information related to Rx operations.
Kojto 122:f9eeca106725 268 This parameter can be a value of @ref HAL_UART_StateTypeDef */
Kojto 122:f9eeca106725 269
Kojto 122:f9eeca106725 270 __IO uint32_t ErrorCode; /*!< UART Error code */
Kojto 122:f9eeca106725 271
Kojto 109:9296ab0bfc11 272 }UART_HandleTypeDef;
Kojto 109:9296ab0bfc11 273
Kojto 109:9296ab0bfc11 274 /**
Kojto 109:9296ab0bfc11 275 * @}
Kojto 109:9296ab0bfc11 276 */
Kojto 109:9296ab0bfc11 277
Kojto 109:9296ab0bfc11 278 /* Exported constants --------------------------------------------------------*/
Kojto 109:9296ab0bfc11 279 /** @defgroup UART_Exported_Constants UART Exported Constants
Kojto 109:9296ab0bfc11 280 * @{
Kojto 109:9296ab0bfc11 281 */
Kojto 109:9296ab0bfc11 282
Kojto 122:f9eeca106725 283 /** @defgroup UART_Error UART Error
Kojto 109:9296ab0bfc11 284 * @{
Kojto 109:9296ab0bfc11 285 */
Kojto 122:f9eeca106725 286 #define HAL_UART_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
Kojto 122:f9eeca106725 287 #define HAL_UART_ERROR_PE ((uint32_t)0x00000001) /*!< Parity error */
Kojto 122:f9eeca106725 288 #define HAL_UART_ERROR_NE ((uint32_t)0x00000002) /*!< Noise error */
Kojto 122:f9eeca106725 289 #define HAL_UART_ERROR_FE ((uint32_t)0x00000004) /*!< frame error */
Kojto 122:f9eeca106725 290 #define HAL_UART_ERROR_ORE ((uint32_t)0x00000008) /*!< Overrun error */
Kojto 122:f9eeca106725 291 #define HAL_UART_ERROR_DMA ((uint32_t)0x00000010) /*!< DMA transfer error */
Kojto 109:9296ab0bfc11 292 /**
Kojto 109:9296ab0bfc11 293 * @}
Kojto 109:9296ab0bfc11 294 */
Kojto 109:9296ab0bfc11 295
Kojto 122:f9eeca106725 296 /** @defgroup UART_Stop_Bits UART Number of Stop Bits
Kojto 122:f9eeca106725 297 * @{
Kojto 122:f9eeca106725 298 */
Kojto 122:f9eeca106725 299 #define UART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< UART frame with 0.5 stop bit */
Kojto 122:f9eeca106725 300 #define UART_STOPBITS_1 ((uint32_t)0x00000000) /*!< UART frame with 1 stop bit */
Kojto 122:f9eeca106725 301 #define UART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) /*!< UART frame with 1.5 stop bits */
Kojto 122:f9eeca106725 302 #define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) /*!< UART frame with 2 stop bits */
Kojto 122:f9eeca106725 303 /**
Kojto 122:f9eeca106725 304 * @}
Kojto 122:f9eeca106725 305 */
Kojto 122:f9eeca106725 306
Kojto 109:9296ab0bfc11 307 /** @defgroup UART_Parity UART Parity
Kojto 109:9296ab0bfc11 308 * @{
Kojto 122:f9eeca106725 309 */
Kojto 122:f9eeca106725 310 #define UART_PARITY_NONE ((uint32_t)0x00000000) /*!< No parity */
Kojto 122:f9eeca106725 311 #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE) /*!< Even parity */
Kojto 122:f9eeca106725 312 #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) /*!< Odd parity */
Kojto 109:9296ab0bfc11 313 /**
Kojto 109:9296ab0bfc11 314 * @}
Kojto 122:f9eeca106725 315 */
Kojto 109:9296ab0bfc11 316
Kojto 109:9296ab0bfc11 317 /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
Kojto 109:9296ab0bfc11 318 * @{
Kojto 122:f9eeca106725 319 */
Kojto 122:f9eeca106725 320 #define UART_HWCONTROL_NONE ((uint32_t)0x00000000) /*!< No hardware control */
Kojto 122:f9eeca106725 321 #define UART_HWCONTROL_RTS ((uint32_t)USART_CR3_RTSE) /*!< Request To Send */
Kojto 122:f9eeca106725 322 #define UART_HWCONTROL_CTS ((uint32_t)USART_CR3_CTSE) /*!< Clear To Send */
Kojto 122:f9eeca106725 323 #define UART_HWCONTROL_RTS_CTS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE)) /*!< Request and Clear To Send */
Kojto 109:9296ab0bfc11 324 /**
Kojto 109:9296ab0bfc11 325 * @}
Kojto 109:9296ab0bfc11 326 */
Kojto 109:9296ab0bfc11 327
Kojto 109:9296ab0bfc11 328 /** @defgroup UART_Mode UART Transfer Mode
Kojto 109:9296ab0bfc11 329 * @{
Kojto 122:f9eeca106725 330 */
Kojto 122:f9eeca106725 331 #define UART_MODE_RX ((uint32_t)USART_CR1_RE) /*!< RX mode */
Kojto 122:f9eeca106725 332 #define UART_MODE_TX ((uint32_t)USART_CR1_TE) /*!< TX mode */
Kojto 122:f9eeca106725 333 #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) /*!< RX and TX mode */
Kojto 109:9296ab0bfc11 334 /**
Kojto 109:9296ab0bfc11 335 * @}
Kojto 109:9296ab0bfc11 336 */
Kojto 122:f9eeca106725 337
Kojto 122:f9eeca106725 338 /** @defgroup UART_State UART State
Kojto 109:9296ab0bfc11 339 * @{
Kojto 122:f9eeca106725 340 */
Kojto 122:f9eeca106725 341 #define UART_STATE_DISABLE ((uint32_t)0x00000000) /*!< UART disabled */
Kojto 122:f9eeca106725 342 #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE) /*!< UART enabled */
Kojto 109:9296ab0bfc11 343 /**
Kojto 109:9296ab0bfc11 344 * @}
Kojto 109:9296ab0bfc11 345 */
Kojto 109:9296ab0bfc11 346
Kojto 109:9296ab0bfc11 347 /** @defgroup UART_Over_Sampling UART Over Sampling
Kojto 109:9296ab0bfc11 348 * @{
Kojto 109:9296ab0bfc11 349 */
Kojto 122:f9eeca106725 350 #define UART_OVERSAMPLING_16 ((uint32_t)0x00000000) /*!< Oversampling by 16 */
Kojto 122:f9eeca106725 351 #define UART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8) /*!< Oversampling by 8 */
Kojto 109:9296ab0bfc11 352 /**
Kojto 109:9296ab0bfc11 353 * @}
Kojto 122:f9eeca106725 354 */
Kojto 109:9296ab0bfc11 355
Kojto 109:9296ab0bfc11 356 /** @defgroup UART_OneBit_Sampling UART One Bit Sampling Method
Kojto 109:9296ab0bfc11 357 * @{
Kojto 109:9296ab0bfc11 358 */
Kojto 122:f9eeca106725 359 #define UART_ONE_BIT_SAMPLE_DISABLE ((uint32_t)0x00000000) /*!< One-bit sampling disable */
Kojto 122:f9eeca106725 360 #define UART_ONE_BIT_SAMPLE_ENABLE ((uint32_t)USART_CR3_ONEBIT) /*!< One-bit sampling enable */
Kojto 109:9296ab0bfc11 361 /**
Kojto 109:9296ab0bfc11 362 * @}
Kojto 122:f9eeca106725 363 */
Kojto 109:9296ab0bfc11 364
Kojto 109:9296ab0bfc11 365 /** @defgroup UART_AutoBaud_Rate_Mode UART Advanced Feature AutoBaud Rate Mode
Kojto 109:9296ab0bfc11 366 * @{
Kojto 109:9296ab0bfc11 367 */
Kojto 122:f9eeca106725 368 #define UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT ((uint32_t)0x00000000) /*!< Auto Baud rate detection on start bit */
Kojto 122:f9eeca106725 369 #define UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE ((uint32_t)USART_CR2_ABRMODE_0) /*!< Auto Baud rate detection on falling edge */
Kojto 122:f9eeca106725 370 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME ((uint32_t)USART_CR2_ABRMODE_1) /*!< Auto Baud rate detection on 0x7F frame detection */
Kojto 122:f9eeca106725 371 #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME ((uint32_t)USART_CR2_ABRMODE) /*!< Auto Baud rate detection on 0x55 frame detection */
Kojto 109:9296ab0bfc11 372 /**
Kojto 109:9296ab0bfc11 373 * @}
Kojto 122:f9eeca106725 374 */
Kojto 109:9296ab0bfc11 375
Kojto 122:f9eeca106725 376 /** @defgroup UART_Receiver_TimeOut UART Receiver TimeOut
Kojto 109:9296ab0bfc11 377 * @{
Kojto 109:9296ab0bfc11 378 */
Kojto 122:f9eeca106725 379 #define UART_RECEIVER_TIMEOUT_DISABLE ((uint32_t)0x00000000) /*!< UART receiver timeout disable */
Kojto 122:f9eeca106725 380 #define UART_RECEIVER_TIMEOUT_ENABLE ((uint32_t)USART_CR2_RTOEN) /*!< UART receiver timeout enable */
Kojto 109:9296ab0bfc11 381 /**
Kojto 109:9296ab0bfc11 382 * @}
Kojto 122:f9eeca106725 383 */
Kojto 109:9296ab0bfc11 384
Kojto 109:9296ab0bfc11 385 /** @defgroup UART_LIN UART Local Interconnection Network mode
Kojto 109:9296ab0bfc11 386 * @{
Kojto 109:9296ab0bfc11 387 */
Kojto 122:f9eeca106725 388 #define UART_LIN_DISABLE ((uint32_t)0x00000000) /*!< Local Interconnect Network disable */
Kojto 122:f9eeca106725 389 #define UART_LIN_ENABLE ((uint32_t)USART_CR2_LINEN) /*!< Local Interconnect Network enable */
Kojto 109:9296ab0bfc11 390 /**
Kojto 109:9296ab0bfc11 391 * @}
Kojto 122:f9eeca106725 392 */
Kojto 122:f9eeca106725 393
Kojto 109:9296ab0bfc11 394 /** @defgroup UART_LIN_Break_Detection UART LIN Break Detection
Kojto 109:9296ab0bfc11 395 * @{
Kojto 109:9296ab0bfc11 396 */
Kojto 122:f9eeca106725 397 #define UART_LINBREAKDETECTLENGTH_10B ((uint32_t)0x00000000) /*!< LIN 10-bit break detection length */
Kojto 122:f9eeca106725 398 #define UART_LINBREAKDETECTLENGTH_11B ((uint32_t)USART_CR2_LBDL) /*!< LIN 11-bit break detection length */
Kojto 109:9296ab0bfc11 399 /**
Kojto 109:9296ab0bfc11 400 * @}
Kojto 122:f9eeca106725 401 */
Kojto 109:9296ab0bfc11 402
Kojto 109:9296ab0bfc11 403 /** @defgroup UART_DMA_Tx UART DMA Tx
Kojto 109:9296ab0bfc11 404 * @{
Kojto 109:9296ab0bfc11 405 */
Kojto 122:f9eeca106725 406 #define UART_DMA_TX_DISABLE ((uint32_t)0x00000000) /*!< UART DMA TX disabled */
Kojto 122:f9eeca106725 407 #define UART_DMA_TX_ENABLE ((uint32_t)USART_CR3_DMAT) /*!< UART DMA TX enabled */
Kojto 109:9296ab0bfc11 408 /**
Kojto 109:9296ab0bfc11 409 * @}
Kojto 109:9296ab0bfc11 410 */
Kojto 109:9296ab0bfc11 411
Kojto 109:9296ab0bfc11 412 /** @defgroup UART_DMA_Rx UART DMA Rx
Kojto 109:9296ab0bfc11 413 * @{
Kojto 109:9296ab0bfc11 414 */
Kojto 122:f9eeca106725 415 #define UART_DMA_RX_DISABLE ((uint32_t)0x00000000) /*!< UART DMA RX disabled */
Kojto 122:f9eeca106725 416 #define UART_DMA_RX_ENABLE ((uint32_t)USART_CR3_DMAR) /*!< UART DMA RX enabled */
Kojto 109:9296ab0bfc11 417 /**
Kojto 109:9296ab0bfc11 418 * @}
Kojto 109:9296ab0bfc11 419 */
Kojto 109:9296ab0bfc11 420
Kojto 109:9296ab0bfc11 421 /** @defgroup UART_Half_Duplex_Selection UART Half Duplex Selection
Kojto 109:9296ab0bfc11 422 * @{
Kojto 109:9296ab0bfc11 423 */
Kojto 122:f9eeca106725 424 #define UART_HALF_DUPLEX_DISABLE ((uint32_t)0x00000000) /*!< UART half-duplex disabled */
Kojto 122:f9eeca106725 425 #define UART_HALF_DUPLEX_ENABLE ((uint32_t)USART_CR3_HDSEL) /*!< UART half-duplex enabled */
Kojto 109:9296ab0bfc11 426 /**
Kojto 109:9296ab0bfc11 427 * @}
Kojto 122:f9eeca106725 428 */
Kojto 122:f9eeca106725 429
Kojto 122:f9eeca106725 430 /** @defgroup UART_WakeUp_Address_Length UART WakeUp Address Length
Kojto 122:f9eeca106725 431 * @{
Kojto 122:f9eeca106725 432 */
Kojto 122:f9eeca106725 433 #define UART_ADDRESS_DETECT_4B ((uint32_t)0x00000000) /*!< 4-bit long wake-up address */
Kojto 122:f9eeca106725 434 #define UART_ADDRESS_DETECT_7B ((uint32_t)USART_CR2_ADDM7) /*!< 7-bit long wake-up address */
Kojto 122:f9eeca106725 435 /**
Kojto 122:f9eeca106725 436 * @}
Kojto 122:f9eeca106725 437 */
Kojto 109:9296ab0bfc11 438
Kojto 109:9296ab0bfc11 439 /** @defgroup UART_WakeUp_Methods UART WakeUp Methods
Kojto 109:9296ab0bfc11 440 * @{
Kojto 109:9296ab0bfc11 441 */
Kojto 122:f9eeca106725 442 #define UART_WAKEUPMETHOD_IDLELINE ((uint32_t)0x00000000) /*!< UART wake-up on idle line */
Kojto 122:f9eeca106725 443 #define UART_WAKEUPMETHOD_ADDRESSMARK ((uint32_t)USART_CR1_WAKE) /*!< UART wake-up on address mark */
Kojto 109:9296ab0bfc11 444 /**
Kojto 109:9296ab0bfc11 445 * @}
Kojto 109:9296ab0bfc11 446 */
Kojto 109:9296ab0bfc11 447
Kojto 109:9296ab0bfc11 448 /** @defgroup UART_Flags UART Status Flags
Kojto 109:9296ab0bfc11 449 * Elements values convention: 0xXXXX
Kojto 109:9296ab0bfc11 450 * - 0xXXXX : Flag mask in the ISR register
Kojto 109:9296ab0bfc11 451 * @{
Kojto 109:9296ab0bfc11 452 */
Kojto 109:9296ab0bfc11 453 #define UART_FLAG_REACK ((uint32_t)0x00400000)
Kojto 122:f9eeca106725 454 #define UART_FLAG_TEACK ((uint32_t)0x00200000)
Kojto 109:9296ab0bfc11 455 #define UART_FLAG_WUF ((uint32_t)0x00100000)
Kojto 109:9296ab0bfc11 456 #define UART_FLAG_RWU ((uint32_t)0x00080000)
Kojto 122:f9eeca106725 457 #define UART_FLAG_SBKF ((uint32_t)0x00040000)
Kojto 109:9296ab0bfc11 458 #define UART_FLAG_CMF ((uint32_t)0x00020000)
Kojto 109:9296ab0bfc11 459 #define UART_FLAG_BUSY ((uint32_t)0x00010000)
Kojto 122:f9eeca106725 460 #define UART_FLAG_ABRF ((uint32_t)0x00008000)
Kojto 109:9296ab0bfc11 461 #define UART_FLAG_ABRE ((uint32_t)0x00004000)
Kojto 109:9296ab0bfc11 462 #define UART_FLAG_EOBF ((uint32_t)0x00001000)
Kojto 109:9296ab0bfc11 463 #define UART_FLAG_RTOF ((uint32_t)0x00000800)
Kojto 109:9296ab0bfc11 464 #define UART_FLAG_CTS ((uint32_t)0x00000400)
Kojto 109:9296ab0bfc11 465 #define UART_FLAG_CTSIF ((uint32_t)0x00000200)
Kojto 109:9296ab0bfc11 466 #define UART_FLAG_LBDF ((uint32_t)0x00000100)
Kojto 109:9296ab0bfc11 467 #define UART_FLAG_TXE ((uint32_t)0x00000080)
Kojto 109:9296ab0bfc11 468 #define UART_FLAG_TC ((uint32_t)0x00000040)
Kojto 109:9296ab0bfc11 469 #define UART_FLAG_RXNE ((uint32_t)0x00000020)
Kojto 109:9296ab0bfc11 470 #define UART_FLAG_IDLE ((uint32_t)0x00000010)
Kojto 109:9296ab0bfc11 471 #define UART_FLAG_ORE ((uint32_t)0x00000008)
Kojto 109:9296ab0bfc11 472 #define UART_FLAG_NE ((uint32_t)0x00000004)
Kojto 109:9296ab0bfc11 473 #define UART_FLAG_FE ((uint32_t)0x00000002)
Kojto 109:9296ab0bfc11 474 #define UART_FLAG_PE ((uint32_t)0x00000001)
Kojto 109:9296ab0bfc11 475 /**
Kojto 109:9296ab0bfc11 476 * @}
Kojto 122:f9eeca106725 477 */
Kojto 109:9296ab0bfc11 478
Kojto 109:9296ab0bfc11 479 /** @defgroup UART_Interrupt_definition UART Interrupts Definition
Kojto 122:f9eeca106725 480 * Elements values convention: 000ZZZZZ0XXYYYYYb
Kojto 109:9296ab0bfc11 481 * - YYYYY : Interrupt source position in the XX register (5bits)
Kojto 109:9296ab0bfc11 482 * - XX : Interrupt source register (2bits)
Kojto 109:9296ab0bfc11 483 * - 01: CR1 register
Kojto 109:9296ab0bfc11 484 * - 10: CR2 register
Kojto 109:9296ab0bfc11 485 * - 11: CR3 register
Kojto 122:f9eeca106725 486 * - ZZZZZ : Flag position in the ISR register(5bits)
Kojto 122:f9eeca106725 487 * @{
Kojto 122:f9eeca106725 488 */
Kojto 109:9296ab0bfc11 489 #define UART_IT_PE ((uint16_t)0x0028)
Kojto 109:9296ab0bfc11 490 #define UART_IT_TXE ((uint16_t)0x0727)
Kojto 109:9296ab0bfc11 491 #define UART_IT_TC ((uint16_t)0x0626)
Kojto 109:9296ab0bfc11 492 #define UART_IT_RXNE ((uint16_t)0x0525)
Kojto 109:9296ab0bfc11 493 #define UART_IT_IDLE ((uint16_t)0x0424)
Kojto 109:9296ab0bfc11 494 #define UART_IT_LBD ((uint16_t)0x0846)
Kojto 109:9296ab0bfc11 495 #define UART_IT_CTS ((uint16_t)0x096A)
Kojto 122:f9eeca106725 496 #define UART_IT_CM ((uint16_t)0x112E)
Kojto 109:9296ab0bfc11 497 #define UART_IT_WUF ((uint16_t)0x1476)
Kojto 109:9296ab0bfc11 498
Kojto 109:9296ab0bfc11 499 /** Elements values convention: 000000000XXYYYYYb
Kojto 109:9296ab0bfc11 500 * - YYYYY : Interrupt source position in the XX register (5bits)
Kojto 109:9296ab0bfc11 501 * - XX : Interrupt source register (2bits)
Kojto 109:9296ab0bfc11 502 * - 01: CR1 register
Kojto 109:9296ab0bfc11 503 * - 10: CR2 register
Kojto 109:9296ab0bfc11 504 * - 11: CR3 register
Kojto 109:9296ab0bfc11 505 */
Kojto 109:9296ab0bfc11 506 #define UART_IT_ERR ((uint16_t)0x0060)
Kojto 109:9296ab0bfc11 507
Kojto 109:9296ab0bfc11 508 /** Elements values convention: 0000ZZZZ00000000b
Kojto 109:9296ab0bfc11 509 * - ZZZZ : Flag position in the ISR register(4bits)
Kojto 109:9296ab0bfc11 510 */
Kojto 109:9296ab0bfc11 511 #define UART_IT_ORE ((uint16_t)0x0300)
Kojto 109:9296ab0bfc11 512 #define UART_IT_NE ((uint16_t)0x0200)
Kojto 109:9296ab0bfc11 513 #define UART_IT_FE ((uint16_t)0x0100)
Kojto 109:9296ab0bfc11 514 /**
Kojto 109:9296ab0bfc11 515 * @}
Kojto 109:9296ab0bfc11 516 */
Kojto 122:f9eeca106725 517
Kojto 109:9296ab0bfc11 518 /** @defgroup UART_IT_CLEAR_Flags UART Interruption Clear Flags
Kojto 109:9296ab0bfc11 519 * @{
Kojto 109:9296ab0bfc11 520 */
Kojto 122:f9eeca106725 521 #define UART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
Kojto 122:f9eeca106725 522 #define UART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
Kojto 122:f9eeca106725 523 #define UART_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
Kojto 122:f9eeca106725 524 #define UART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
Kojto 122:f9eeca106725 525 #define UART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */
Kojto 122:f9eeca106725 526 #define UART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
Kojto 122:f9eeca106725 527 #define UART_CLEAR_LBDF USART_ICR_LBDCF /*!< LIN Break Detection Clear Flag */
Kojto 122:f9eeca106725 528 #define UART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */
Kojto 122:f9eeca106725 529 #define UART_CLEAR_RTOF USART_ICR_RTOCF /*!< Receiver Time Out Clear Flag */
Kojto 122:f9eeca106725 530 #define UART_CLEAR_EOBF USART_ICR_EOBCF /*!< End Of Block Clear Flag */
Kojto 122:f9eeca106725 531 #define UART_CLEAR_CMF USART_ICR_CMCF /*!< Character Match Clear Flag */
Kojto 109:9296ab0bfc11 532 #define UART_CLEAR_WUF USART_ICR_WUCF /*!< Wake Up from stop mode Clear Flag */
Kojto 109:9296ab0bfc11 533 /**
Kojto 109:9296ab0bfc11 534 * @}
Kojto 109:9296ab0bfc11 535 */
Kojto 109:9296ab0bfc11 536
Kojto 109:9296ab0bfc11 537 /** @defgroup UART_Request_Parameters UART Request Parameters
Kojto 109:9296ab0bfc11 538 * @{
Kojto 109:9296ab0bfc11 539 */
Kojto 122:f9eeca106725 540 #define UART_AUTOBAUD_REQUEST ((uint32_t)USART_RQR_ABRRQ) /*!< Auto-Baud Rate Request */
Kojto 122:f9eeca106725 541 #define UART_SENDBREAK_REQUEST ((uint32_t)USART_RQR_SBKRQ) /*!< Send Break Request */
Kojto 122:f9eeca106725 542 #define UART_MUTE_MODE_REQUEST ((uint32_t)USART_RQR_MMRQ) /*!< Mute Mode Request */
Kojto 122:f9eeca106725 543 #define UART_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
Kojto 109:9296ab0bfc11 544 #define UART_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
Kojto 109:9296ab0bfc11 545 /**
Kojto 109:9296ab0bfc11 546 * @}
Kojto 109:9296ab0bfc11 547 */
Kojto 109:9296ab0bfc11 548
Kojto 109:9296ab0bfc11 549 /** @defgroup UART_Advanced_Features_Initialization_Type UART Advanced Feature Initialization Type
Kojto 109:9296ab0bfc11 550 * @{
Kojto 109:9296ab0bfc11 551 */
Kojto 122:f9eeca106725 552 #define UART_ADVFEATURE_NO_INIT ((uint32_t)0x00000000) /*!< No advanced feature initialization */
Kojto 122:f9eeca106725 553 #define UART_ADVFEATURE_TXINVERT_INIT ((uint32_t)0x00000001) /*!< TX pin active level inversion */
Kojto 122:f9eeca106725 554 #define UART_ADVFEATURE_RXINVERT_INIT ((uint32_t)0x00000002) /*!< RX pin active level inversion */
Kojto 122:f9eeca106725 555 #define UART_ADVFEATURE_DATAINVERT_INIT ((uint32_t)0x00000004) /*!< Binary data inversion */
Kojto 122:f9eeca106725 556 #define UART_ADVFEATURE_SWAP_INIT ((uint32_t)0x00000008) /*!< TX/RX pins swap */
Kojto 122:f9eeca106725 557 #define UART_ADVFEATURE_RXOVERRUNDISABLE_INIT ((uint32_t)0x00000010) /*!< RX overrun disable */
Kojto 122:f9eeca106725 558 #define UART_ADVFEATURE_DMADISABLEONERROR_INIT ((uint32_t)0x00000020) /*!< DMA disable on Reception Error */
Kojto 122:f9eeca106725 559 #define UART_ADVFEATURE_AUTOBAUDRATE_INIT ((uint32_t)0x00000040) /*!< Auto Baud rate detection initialization */
Kojto 122:f9eeca106725 560 #define UART_ADVFEATURE_MSBFIRST_INIT ((uint32_t)0x00000080) /*!< Most significant bit sent/received first */
Kojto 109:9296ab0bfc11 561 /**
Kojto 109:9296ab0bfc11 562 * @}
Kojto 109:9296ab0bfc11 563 */
Kojto 109:9296ab0bfc11 564
Kojto 109:9296ab0bfc11 565 /** @defgroup UART_Tx_Inv UART Advanced Feature TX Pin Active Level Inversion
Kojto 109:9296ab0bfc11 566 * @{
Kojto 109:9296ab0bfc11 567 */
Kojto 122:f9eeca106725 568 #define UART_ADVFEATURE_TXINV_DISABLE ((uint32_t)0x00000000) /*!< TX pin active level inversion disable */
Kojto 122:f9eeca106725 569 #define UART_ADVFEATURE_TXINV_ENABLE ((uint32_t)USART_CR2_TXINV) /*!< TX pin active level inversion enable */
Kojto 109:9296ab0bfc11 570 /**
Kojto 109:9296ab0bfc11 571 * @}
Kojto 109:9296ab0bfc11 572 */
Kojto 109:9296ab0bfc11 573
Kojto 109:9296ab0bfc11 574 /** @defgroup UART_Rx_Inv UART Advanced Feature RX Pin Active Level Inversion
Kojto 109:9296ab0bfc11 575 * @{
Kojto 109:9296ab0bfc11 576 */
Kojto 122:f9eeca106725 577 #define UART_ADVFEATURE_RXINV_DISABLE ((uint32_t)0x00000000) /*!< RX pin active level inversion disable */
Kojto 122:f9eeca106725 578 #define UART_ADVFEATURE_RXINV_ENABLE ((uint32_t)USART_CR2_RXINV) /*!< RX pin active level inversion enable */
Kojto 109:9296ab0bfc11 579 /**
Kojto 109:9296ab0bfc11 580 * @}
Kojto 109:9296ab0bfc11 581 */
Kojto 109:9296ab0bfc11 582
Kojto 109:9296ab0bfc11 583 /** @defgroup UART_Data_Inv UART Advanced Feature Binary Data Inversion
Kojto 109:9296ab0bfc11 584 * @{
Kojto 109:9296ab0bfc11 585 */
Kojto 122:f9eeca106725 586 #define UART_ADVFEATURE_DATAINV_DISABLE ((uint32_t)0x00000000) /*!< Binary data inversion disable */
Kojto 122:f9eeca106725 587 #define UART_ADVFEATURE_DATAINV_ENABLE ((uint32_t)USART_CR2_DATAINV) /*!< Binary data inversion enable */
Kojto 109:9296ab0bfc11 588 /**
Kojto 109:9296ab0bfc11 589 * @}
Kojto 109:9296ab0bfc11 590 */
Kojto 109:9296ab0bfc11 591
Kojto 109:9296ab0bfc11 592 /** @defgroup UART_Rx_Tx_Swap UART Advanced Feature RX TX Pins Swap
Kojto 109:9296ab0bfc11 593 * @{
Kojto 109:9296ab0bfc11 594 */
Kojto 122:f9eeca106725 595 #define UART_ADVFEATURE_SWAP_DISABLE ((uint32_t)0x00000000) /*!< TX/RX pins swap disable */
Kojto 122:f9eeca106725 596 #define UART_ADVFEATURE_SWAP_ENABLE ((uint32_t)USART_CR2_SWAP) /*!< TX/RX pins swap enable */
Kojto 109:9296ab0bfc11 597 /**
Kojto 109:9296ab0bfc11 598 * @}
Kojto 109:9296ab0bfc11 599 */
Kojto 109:9296ab0bfc11 600
Kojto 109:9296ab0bfc11 601 /** @defgroup UART_Overrun_Disable UART Advanced Feature Overrun Disable
Kojto 109:9296ab0bfc11 602 * @{
Kojto 109:9296ab0bfc11 603 */
Kojto 122:f9eeca106725 604 #define UART_ADVFEATURE_OVERRUN_ENABLE ((uint32_t)0x00000000) /*!< RX overrun enable */
Kojto 122:f9eeca106725 605 #define UART_ADVFEATURE_OVERRUN_DISABLE ((uint32_t)USART_CR3_OVRDIS) /*!< RX overrun disable */
Kojto 109:9296ab0bfc11 606 /**
Kojto 109:9296ab0bfc11 607 * @}
Kojto 109:9296ab0bfc11 608 */
Kojto 109:9296ab0bfc11 609
Kojto 109:9296ab0bfc11 610 /** @defgroup UART_AutoBaudRate_Enable UART Advanced Feature Auto BaudRate Enable
Kojto 109:9296ab0bfc11 611 * @{
Kojto 109:9296ab0bfc11 612 */
Kojto 122:f9eeca106725 613 #define UART_ADVFEATURE_AUTOBAUDRATE_DISABLE ((uint32_t)0x00000000) /*!< RX Auto Baud rate detection enable */
Kojto 122:f9eeca106725 614 #define UART_ADVFEATURE_AUTOBAUDRATE_ENABLE ((uint32_t)USART_CR2_ABREN) /*!< RX Auto Baud rate detection disable */
Kojto 109:9296ab0bfc11 615 /**
Kojto 109:9296ab0bfc11 616 * @}
Kojto 109:9296ab0bfc11 617 */
Kojto 109:9296ab0bfc11 618
Kojto 109:9296ab0bfc11 619 /** @defgroup UART_DMA_Disable_on_Rx_Error UART Advanced Feature DMA Disable On Rx Error
Kojto 109:9296ab0bfc11 620 * @{
Kojto 109:9296ab0bfc11 621 */
Kojto 122:f9eeca106725 622 #define UART_ADVFEATURE_DMA_ENABLEONRXERROR ((uint32_t)0x00000000) /*!< DMA enable on Reception Error */
Kojto 122:f9eeca106725 623 #define UART_ADVFEATURE_DMA_DISABLEONRXERROR ((uint32_t)USART_CR3_DDRE) /*!< DMA disable on Reception Error */
Kojto 109:9296ab0bfc11 624 /**
Kojto 109:9296ab0bfc11 625 * @}
Kojto 109:9296ab0bfc11 626 */
Kojto 109:9296ab0bfc11 627
Kojto 109:9296ab0bfc11 628 /** @defgroup UART_MSB_First UART Advanced Feature MSB First
Kojto 109:9296ab0bfc11 629 * @{
Kojto 109:9296ab0bfc11 630 */
Kojto 122:f9eeca106725 631 #define UART_ADVFEATURE_MSBFIRST_DISABLE ((uint32_t)0x00000000) /*!< Most significant bit sent/received first disable */
Kojto 122:f9eeca106725 632 #define UART_ADVFEATURE_MSBFIRST_ENABLE ((uint32_t)USART_CR2_MSBFIRST) /*!< Most significant bit sent/received first enable */
Kojto 109:9296ab0bfc11 633 /**
Kojto 109:9296ab0bfc11 634 * @}
Kojto 109:9296ab0bfc11 635 */
Kojto 109:9296ab0bfc11 636
Kojto 109:9296ab0bfc11 637 /** @defgroup UART_Stop_Mode_Enable UART Advanced Feature Stop Mode Enable
Kojto 109:9296ab0bfc11 638 * @{
Kojto 109:9296ab0bfc11 639 */
Kojto 122:f9eeca106725 640 #define UART_ADVFEATURE_STOPMODE_DISABLE ((uint32_t)0x00000000) /*!< UART stop mode disable */
Kojto 122:f9eeca106725 641 #define UART_ADVFEATURE_STOPMODE_ENABLE ((uint32_t)USART_CR1_UESM) /*!< UART stop mode enable */
Kojto 109:9296ab0bfc11 642 /**
Kojto 109:9296ab0bfc11 643 * @}
Kojto 109:9296ab0bfc11 644 */
Kojto 109:9296ab0bfc11 645
Kojto 109:9296ab0bfc11 646 /** @defgroup UART_Mute_Mode UART Advanced Feature Mute Mode Enable
Kojto 109:9296ab0bfc11 647 * @{
Kojto 109:9296ab0bfc11 648 */
Kojto 122:f9eeca106725 649 #define UART_ADVFEATURE_MUTEMODE_DISABLE ((uint32_t)0x00000000) /*!< UART mute mode disable */
Kojto 122:f9eeca106725 650 #define UART_ADVFEATURE_MUTEMODE_ENABLE ((uint32_t)USART_CR1_MME) /*!< UART mute mode enable */
Kojto 109:9296ab0bfc11 651 /**
Kojto 109:9296ab0bfc11 652 * @}
Kojto 109:9296ab0bfc11 653 */
Kojto 109:9296ab0bfc11 654
Kojto 109:9296ab0bfc11 655 /** @defgroup UART_CR2_ADDRESS_LSB_POS UART Address-matching LSB Position In CR2 Register
Kojto 109:9296ab0bfc11 656 * @{
Kojto 109:9296ab0bfc11 657 */
Kojto 109:9296ab0bfc11 658 #define UART_CR2_ADDRESS_LSB_POS ((uint32_t) 24)
Kojto 109:9296ab0bfc11 659 /**
Kojto 109:9296ab0bfc11 660 * @}
Kojto 109:9296ab0bfc11 661 */
Kojto 109:9296ab0bfc11 662
Kojto 109:9296ab0bfc11 663 /** @defgroup UART_WakeUp_from_Stop_Selection UART WakeUp From Stop Selection
Kojto 109:9296ab0bfc11 664 * @{
Kojto 109:9296ab0bfc11 665 */
Kojto 109:9296ab0bfc11 666 #define UART_WAKEUP_ON_ADDRESS ((uint32_t)0x0000)
Kojto 109:9296ab0bfc11 667 #define UART_WAKEUP_ON_STARTBIT ((uint32_t)USART_CR3_WUS_1)
Kojto 109:9296ab0bfc11 668 #define UART_WAKEUP_ON_READDATA_NONEMPTY ((uint32_t)USART_CR3_WUS)
Kojto 109:9296ab0bfc11 669 /**
Kojto 109:9296ab0bfc11 670 * @}
Kojto 109:9296ab0bfc11 671 */
Kojto 109:9296ab0bfc11 672
Kojto 109:9296ab0bfc11 673 /** @defgroup UART_DriverEnable_Polarity UART DriverEnable Polarity
Kojto 109:9296ab0bfc11 674 * @{
Kojto 109:9296ab0bfc11 675 */
Kojto 122:f9eeca106725 676 #define UART_DE_POLARITY_HIGH ((uint32_t)0x00000000) /*!< Driver enable signal is active high */
Kojto 122:f9eeca106725 677 #define UART_DE_POLARITY_LOW ((uint32_t)USART_CR3_DEP) /*!< Driver enable signal is active low */
Kojto 109:9296ab0bfc11 678 /**
Kojto 109:9296ab0bfc11 679 * @}
Kojto 109:9296ab0bfc11 680 */
Kojto 109:9296ab0bfc11 681
Kojto 109:9296ab0bfc11 682 /** @defgroup UART_CR1_DEAT_ADDRESS_LSB_POS UART Driver Enable Assertion Time LSB Position In CR1 Register
Kojto 109:9296ab0bfc11 683 * @{
Kojto 109:9296ab0bfc11 684 */
Kojto 122:f9eeca106725 685 #define UART_CR1_DEAT_ADDRESS_LSB_POS ((uint32_t) 21) /*!< UART Driver Enable assertion time LSB position in CR1 register */
Kojto 109:9296ab0bfc11 686 /**
Kojto 109:9296ab0bfc11 687 * @}
Kojto 109:9296ab0bfc11 688 */
Kojto 109:9296ab0bfc11 689
Kojto 109:9296ab0bfc11 690 /** @defgroup UART_CR1_DEDT_ADDRESS_LSB_POS UART Driver Enable DeAssertion Time LSB Position In CR1 Register
Kojto 109:9296ab0bfc11 691 * @{
Kojto 109:9296ab0bfc11 692 */
Kojto 122:f9eeca106725 693 #define UART_CR1_DEDT_ADDRESS_LSB_POS ((uint32_t) 16) /*!< UART Driver Enable de-assertion time LSB position in CR1 register */
Kojto 109:9296ab0bfc11 694 /**
Kojto 109:9296ab0bfc11 695 * @}
Kojto 109:9296ab0bfc11 696 */
Kojto 109:9296ab0bfc11 697
Kojto 109:9296ab0bfc11 698 /** @defgroup UART_Interruption_Mask UART Interruptions Flag Mask
Kojto 109:9296ab0bfc11 699 * @{
Kojto 122:f9eeca106725 700 */
Kojto 122:f9eeca106725 701 #define UART_IT_MASK ((uint32_t)0x001F) /*!< UART interruptions flags mask */
Kojto 109:9296ab0bfc11 702 /**
Kojto 109:9296ab0bfc11 703 * @}
Kojto 109:9296ab0bfc11 704 */
Kojto 122:f9eeca106725 705
Kojto 109:9296ab0bfc11 706 /** @defgroup UART_TimeOut_Value UART polling-based communications time-out value
Kojto 109:9296ab0bfc11 707 * @{
Kojto 122:f9eeca106725 708 */
Kojto 122:f9eeca106725 709 #define HAL_UART_TIMEOUT_VALUE 0x1FFFFFF /*!< UART polling-based communications time-out value */
Kojto 109:9296ab0bfc11 710 /**
Kojto 109:9296ab0bfc11 711 * @}
Kojto 109:9296ab0bfc11 712 */
Kojto 109:9296ab0bfc11 713
Kojto 122:f9eeca106725 714
Kojto 109:9296ab0bfc11 715 /**
Kojto 109:9296ab0bfc11 716 * @}
Kojto 109:9296ab0bfc11 717 */
Kojto 109:9296ab0bfc11 718
Kojto 109:9296ab0bfc11 719 /* Exported macros -----------------------------------------------------------*/
Kojto 109:9296ab0bfc11 720 /** @defgroup UART_Exported_Macros UART Exported Macros
Kojto 109:9296ab0bfc11 721 * @{
Kojto 109:9296ab0bfc11 722 */
Kojto 122:f9eeca106725 723
Kojto 122:f9eeca106725 724 /** @brief Reset UART handle states.
Kojto 122:f9eeca106725 725 * @param __HANDLE__: UART handle.
Kojto 122:f9eeca106725 726 * @retval None
Kojto 122:f9eeca106725 727 */
Kojto 122:f9eeca106725 728 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \
Kojto 122:f9eeca106725 729 (__HANDLE__)->gState = HAL_UART_STATE_RESET; \
Kojto 122:f9eeca106725 730 (__HANDLE__)->RxState = HAL_UART_STATE_RESET; \
Kojto 122:f9eeca106725 731 } while(0)
Kojto 122:f9eeca106725 732 /** @brief Flush the UART Data registers.
Kojto 109:9296ab0bfc11 733 * @param __HANDLE__: UART handle.
Kojto 109:9296ab0bfc11 734 * @retval None
Kojto 109:9296ab0bfc11 735 */
Kojto 122:f9eeca106725 736 #define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) \
Kojto 122:f9eeca106725 737 do{ \
Kojto 122:f9eeca106725 738 SET_BIT((__HANDLE__)->Instance->RQR, UART_RXDATA_FLUSH_REQUEST); \
Kojto 122:f9eeca106725 739 SET_BIT((__HANDLE__)->Instance->RQR, UART_TXDATA_FLUSH_REQUEST); \
Kojto 122:f9eeca106725 740 } while(0)
Kojto 122:f9eeca106725 741
Kojto 122:f9eeca106725 742 /** @brief Clear the specified UART pending flag.
Kojto 122:f9eeca106725 743 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 744 * @param __FLAG__: specifies the flag to check.
Kojto 122:f9eeca106725 745 * This parameter can be any combination of the following values:
Kojto 122:f9eeca106725 746 * @arg UART_CLEAR_PEF, Parity Error Clear Flag
Kojto 122:f9eeca106725 747 * @arg UART_CLEAR_FEF, Framing Error Clear Flag
Kojto 122:f9eeca106725 748 * @arg UART_CLEAR_NEF, Noise detected Clear Flag
Kojto 122:f9eeca106725 749 * @arg UART_CLEAR_OREF, OverRun Error Clear Flag
Kojto 122:f9eeca106725 750 * @arg UART_CLEAR_IDLEF, IDLE line detected Clear Flag
Kojto 122:f9eeca106725 751 * @arg UART_CLEAR_TCF, Transmission Complete Clear Flag
Kojto 122:f9eeca106725 752 * @arg UART_CLEAR_LBDF, LIN Break Detection Clear Flag (not available on all devices)
Kojto 122:f9eeca106725 753 * @arg UART_CLEAR_CTSF, CTS Interrupt Clear Flag
Kojto 122:f9eeca106725 754 * @arg UART_CLEAR_RTOF, Receiver Time Out Clear Flag
Kojto 122:f9eeca106725 755 * @arg UART_CLEAR_EOBF, End Of Block Clear Flag (not available on all devices)
Kojto 122:f9eeca106725 756 * @arg UART_CLEAR_CMF, Character Match Clear Flag
Kojto 122:f9eeca106725 757 * @arg UART_CLEAR_WUF, Wake Up from stop mode Clear Flag (not available on all devices)
Kojto 122:f9eeca106725 758 * @retval None
Kojto 122:f9eeca106725 759 */
Kojto 122:f9eeca106725 760 #define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
Kojto 109:9296ab0bfc11 761
Kojto 122:f9eeca106725 762 /** @brief Clear the UART PE pending flag.
Kojto 122:f9eeca106725 763 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 764 * @retval None
Kojto 122:f9eeca106725 765 */
Kojto 122:f9eeca106725 766 #define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_PEF)
Kojto 122:f9eeca106725 767
Kojto 122:f9eeca106725 768 /** @brief Clear the UART FE pending flag.
Kojto 122:f9eeca106725 769 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 770 * @retval None
Kojto 122:f9eeca106725 771 */
Kojto 122:f9eeca106725 772 #define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_FEF)
Kojto 122:f9eeca106725 773
Kojto 122:f9eeca106725 774 /** @brief Clear the UART NE pending flag.
Kojto 109:9296ab0bfc11 775 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 776 * @retval None
Kojto 122:f9eeca106725 777 */
Kojto 122:f9eeca106725 778 #define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_NEF)
Kojto 122:f9eeca106725 779
Kojto 122:f9eeca106725 780 /** @brief Clear the UART ORE pending flag.
Kojto 122:f9eeca106725 781 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 782 * @retval None
Kojto 122:f9eeca106725 783 */
Kojto 122:f9eeca106725 784 #define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_OREF)
Kojto 122:f9eeca106725 785
Kojto 122:f9eeca106725 786 /** @brief Clear the UART IDLE pending flag.
Kojto 122:f9eeca106725 787 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 788 * @retval None
Kojto 122:f9eeca106725 789 */
Kojto 122:f9eeca106725 790 #define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_IDLEF)
Kojto 122:f9eeca106725 791
Kojto 122:f9eeca106725 792 /** @brief Check whether the specified UART flag is set or not.
Kojto 122:f9eeca106725 793 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 794 * This parameter can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
Kojto 109:9296ab0bfc11 795 * UART peripheral (datasheet: up to five USART/UARTs)
Kojto 109:9296ab0bfc11 796 * @param __FLAG__: specifies the flag to check.
Kojto 109:9296ab0bfc11 797 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 798 * @arg UART_FLAG_REACK: Receive enable acknowledge flag
Kojto 122:f9eeca106725 799 * @arg UART_FLAG_TEACK: Transmit enable acknowledge flag
Kojto 109:9296ab0bfc11 800 * @arg UART_FLAG_WUF: Wake up from stop mode flag
Kojto 122:f9eeca106725 801 * @arg UART_FLAG_RWU: Receiver wake up flag
Kojto 109:9296ab0bfc11 802 * @arg UART_FLAG_SBKF: Send Break flag
Kojto 109:9296ab0bfc11 803 * @arg UART_FLAG_CMF: Character match flag
Kojto 109:9296ab0bfc11 804 * @arg UART_FLAG_BUSY: Busy flag
Kojto 109:9296ab0bfc11 805 * @arg UART_FLAG_ABRF: Auto Baud rate detection flag
Kojto 109:9296ab0bfc11 806 * @arg UART_FLAG_ABRE: Auto Baud rate detection error flag
Kojto 122:f9eeca106725 807 * @arg UART_FLAG_EOBF: End of block flag
Kojto 122:f9eeca106725 808 * @arg UART_FLAG_RTOF: Receiver timeout flag
Kojto 109:9296ab0bfc11 809 * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5)
Kojto 109:9296ab0bfc11 810 * @arg UART_FLAG_LBD: LIN Break detection flag
Kojto 109:9296ab0bfc11 811 * @arg UART_FLAG_TXE: Transmit data register empty flag
Kojto 109:9296ab0bfc11 812 * @arg UART_FLAG_TC: Transmission Complete flag
Kojto 109:9296ab0bfc11 813 * @arg UART_FLAG_RXNE: Receive data register not empty flag
Kojto 109:9296ab0bfc11 814 * @arg UART_FLAG_IDLE: Idle Line detection flag
Kojto 109:9296ab0bfc11 815 * @arg UART_FLAG_ORE: OverRun Error flag
Kojto 109:9296ab0bfc11 816 * @arg UART_FLAG_NE: Noise Error flag
Kojto 109:9296ab0bfc11 817 * @arg UART_FLAG_FE: Framing Error flag
Kojto 109:9296ab0bfc11 818 * @arg UART_FLAG_PE: Parity Error flag
Kojto 109:9296ab0bfc11 819 * @retval The new state of __FLAG__ (TRUE or FALSE).
Kojto 109:9296ab0bfc11 820 */
Kojto 122:f9eeca106725 821 #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
Kojto 109:9296ab0bfc11 822
Kojto 122:f9eeca106725 823 /** @brief Enable the specified UART interrupt.
Kojto 109:9296ab0bfc11 824 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 825 * This parameter can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
Kojto 109:9296ab0bfc11 826 * UART peripheral. (datasheet: up to five USART/UARTs)
Kojto 109:9296ab0bfc11 827 * @param __INTERRUPT__: specifies the UART interrupt source to enable.
Kojto 109:9296ab0bfc11 828 * This parameter can be one of the following values:
Kojto 109:9296ab0bfc11 829 * @arg UART_IT_WUF: Wakeup from stop mode interrupt
Kojto 109:9296ab0bfc11 830 * @arg UART_IT_CM: Character match interrupt
Kojto 109:9296ab0bfc11 831 * @arg UART_IT_CTS: CTS change interrupt
Kojto 109:9296ab0bfc11 832 * @arg UART_IT_LBD: LIN Break detection interrupt
Kojto 109:9296ab0bfc11 833 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
Kojto 109:9296ab0bfc11 834 * @arg UART_IT_TC: Transmission complete interrupt
Kojto 109:9296ab0bfc11 835 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
Kojto 109:9296ab0bfc11 836 * @arg UART_IT_IDLE: Idle line detection interrupt
Kojto 109:9296ab0bfc11 837 * @arg UART_IT_PE: Parity Error interrupt
Kojto 109:9296ab0bfc11 838 * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
Kojto 109:9296ab0bfc11 839 * @retval None
Kojto 109:9296ab0bfc11 840 */
Kojto 109:9296ab0bfc11 841 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
Kojto 109:9296ab0bfc11 842 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
Kojto 109:9296ab0bfc11 843 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))))
Kojto 109:9296ab0bfc11 844
Kojto 109:9296ab0bfc11 845
Kojto 122:f9eeca106725 846 /** @brief Disable the specified UART interrupt.
Kojto 109:9296ab0bfc11 847 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 848 * This parameter can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
Kojto 109:9296ab0bfc11 849 * UART peripheral. (datasheet: up to five USART/UARTs)
Kojto 109:9296ab0bfc11 850 * @param __INTERRUPT__: specifies the UART interrupt source to disable.
Kojto 109:9296ab0bfc11 851 * This parameter can be one of the following values:
Kojto 109:9296ab0bfc11 852 * @arg UART_IT_WUF: Wakeup from stop mode interrupt
Kojto 122:f9eeca106725 853 * @arg UART_IT_CM: Character match interrupt
Kojto 109:9296ab0bfc11 854 * @arg UART_IT_CTS: CTS change interrupt
Kojto 109:9296ab0bfc11 855 * @arg UART_IT_LBD: LIN Break detection interrupt
Kojto 109:9296ab0bfc11 856 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
Kojto 109:9296ab0bfc11 857 * @arg UART_IT_TC: Transmission complete interrupt
Kojto 109:9296ab0bfc11 858 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
Kojto 109:9296ab0bfc11 859 * @arg UART_IT_IDLE: Idle line detection interrupt
Kojto 109:9296ab0bfc11 860 * @arg UART_IT_PE: Parity Error interrupt
Kojto 109:9296ab0bfc11 861 * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
Kojto 109:9296ab0bfc11 862 * @retval None
Kojto 109:9296ab0bfc11 863 */
Kojto 109:9296ab0bfc11 864 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
Kojto 109:9296ab0bfc11 865 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
Kojto 109:9296ab0bfc11 866 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))))
Kojto 109:9296ab0bfc11 867
Kojto 122:f9eeca106725 868 /** @brief Check whether the specified UART interrupt has occurred or not.
Kojto 109:9296ab0bfc11 869 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 870 * This parameter can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
Kojto 109:9296ab0bfc11 871 * UART peripheral. (datasheet: up to five USART/UARTs)
Kojto 109:9296ab0bfc11 872 * @param __IT__: specifies the UART interrupt to check.
Kojto 109:9296ab0bfc11 873 * This parameter can be one of the following values:
Kojto 109:9296ab0bfc11 874 * @arg UART_IT_WUF: Wakeup from stop mode interrupt
Kojto 122:f9eeca106725 875 * @arg UART_IT_CM: Character match interrupt
Kojto 109:9296ab0bfc11 876 * @arg UART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
Kojto 109:9296ab0bfc11 877 * @arg UART_IT_LBD: LIN Break detection interrupt
Kojto 109:9296ab0bfc11 878 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
Kojto 109:9296ab0bfc11 879 * @arg UART_IT_TC: Transmission complete interrupt
Kojto 109:9296ab0bfc11 880 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
Kojto 109:9296ab0bfc11 881 * @arg UART_IT_IDLE: Idle line detection interrupt
Kojto 109:9296ab0bfc11 882 * @arg UART_IT_ORE: OverRun Error interrupt
Kojto 109:9296ab0bfc11 883 * @arg UART_IT_NE: Noise Error interrupt
Kojto 109:9296ab0bfc11 884 * @arg UART_IT_FE: Framing Error interrupt
Kojto 122:f9eeca106725 885 * @arg UART_IT_PE: Parity Error interrupt
Kojto 109:9296ab0bfc11 886 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 109:9296ab0bfc11 887 */
Kojto 122:f9eeca106725 888 #define __HAL_UART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
Kojto 109:9296ab0bfc11 889
Kojto 122:f9eeca106725 890 /** @brief Check whether the specified UART interrupt source is enabled or not.
Kojto 109:9296ab0bfc11 891 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 892 * This parameter can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
Kojto 109:9296ab0bfc11 893 * UART peripheral. (datasheet: up to five USART/UARTs)
Kojto 109:9296ab0bfc11 894 * @param __IT__: specifies the UART interrupt source to check.
Kojto 109:9296ab0bfc11 895 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 896 * @arg UART_IT_WUF: Wakeup from stop mode interrupt
Kojto 122:f9eeca106725 897 * @arg UART_IT_CM: Character match interrupt
Kojto 109:9296ab0bfc11 898 * @arg UART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
Kojto 109:9296ab0bfc11 899 * @arg UART_IT_LBD: LIN Break detection interrupt
Kojto 109:9296ab0bfc11 900 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
Kojto 109:9296ab0bfc11 901 * @arg UART_IT_TC: Transmission complete interrupt
Kojto 109:9296ab0bfc11 902 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
Kojto 109:9296ab0bfc11 903 * @arg UART_IT_IDLE: Idle line detection interrupt
Kojto 109:9296ab0bfc11 904 * @arg UART_IT_ORE: OverRun Error interrupt
Kojto 109:9296ab0bfc11 905 * @arg UART_IT_NE: Noise Error interrupt
Kojto 109:9296ab0bfc11 906 * @arg UART_IT_FE: Framing Error interrupt
Kojto 122:f9eeca106725 907 * @arg UART_IT_PE: Parity Error interrupt
Kojto 109:9296ab0bfc11 908 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 109:9296ab0bfc11 909 */
Kojto 109:9296ab0bfc11 910 #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5U) == 2)? \
Kojto 109:9296ab0bfc11 911 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << (((uint16_t)(__IT__)) & UART_IT_MASK)))
Kojto 109:9296ab0bfc11 912
Kojto 122:f9eeca106725 913 /** @brief Clear the specified UART ISR flag, in setting the proper ICR register flag.
Kojto 109:9296ab0bfc11 914 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 915 * This parameter can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
Kojto 109:9296ab0bfc11 916 * UART peripheral. (datasheet: up to five USART/UARTs)
Kojto 109:9296ab0bfc11 917 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
Kojto 109:9296ab0bfc11 918 * to clear the corresponding interrupt
Kojto 109:9296ab0bfc11 919 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 920 * @arg UART_CLEAR_PEF: Parity Error Clear Flag
Kojto 122:f9eeca106725 921 * @arg UART_CLEAR_FEF: Framing Error Clear Flag
Kojto 122:f9eeca106725 922 * @arg UART_CLEAR_NEF: Noise detected Clear Flag
Kojto 122:f9eeca106725 923 * @arg UART_CLEAR_OREF: OverRun Error Clear Flag
Kojto 122:f9eeca106725 924 * @arg UART_CLEAR_IDLEF: IDLE line detected Clear Flag
Kojto 122:f9eeca106725 925 * @arg UART_CLEAR_TCF: Transmission Complete Clear Flag
Kojto 122:f9eeca106725 926 * @arg UART_CLEAR_LBDF: LIN Break Detection Clear Flag
Kojto 122:f9eeca106725 927 * @arg UART_CLEAR_CTSF: CTS Interrupt Clear Flag
Kojto 122:f9eeca106725 928 * @arg UART_CLEAR_RTOF: Receiver Time Out Clear Flag
Kojto 122:f9eeca106725 929 * @arg UART_CLEAR_EOBF: End Of Block Clear Flag
Kojto 122:f9eeca106725 930 * @arg UART_CLEAR_CMF: Character Match Clear Flag
Kojto 122:f9eeca106725 931 * @arg UART_CLEAR_WUF: Wake Up from stop mode Clear Flag
Kojto 109:9296ab0bfc11 932 * @retval None
Kojto 109:9296ab0bfc11 933 */
Kojto 122:f9eeca106725 934 #define __HAL_UART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
Kojto 109:9296ab0bfc11 935
Kojto 109:9296ab0bfc11 936 /** @brief Set a specific UART request flag.
Kojto 109:9296ab0bfc11 937 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 938 * This parameter can be UARTx where x: 1, 2, 3, 4, 5 to select the USART or
Kojto 109:9296ab0bfc11 939 * UART peripheral. (datasheet: up to five USART/UARTs)
Kojto 109:9296ab0bfc11 940 * @param __REQ__: specifies the request flag to set
Kojto 109:9296ab0bfc11 941 * This parameter can be one of the following values:
Kojto 122:f9eeca106725 942 * @arg UART_AUTOBAUD_REQUEST: Auto-Baud Rate Request
Kojto 122:f9eeca106725 943 * @arg UART_SENDBREAK_REQUEST: Send Break Request
Kojto 122:f9eeca106725 944 * @arg UART_MUTE_MODE_REQUEST: Mute Mode Request
Kojto 122:f9eeca106725 945 * @arg UART_RXDATA_FLUSH_REQUEST: Receive Data flush Request
Kojto 122:f9eeca106725 946 * @arg UART_TXDATA_FLUSH_REQUEST: Transmit data flush Request
Kojto 109:9296ab0bfc11 947 * @retval None
Kojto 109:9296ab0bfc11 948 */
Kojto 122:f9eeca106725 949 #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__))
Kojto 122:f9eeca106725 950
Kojto 122:f9eeca106725 951 /** @brief Enable the UART one bit sample method.
Kojto 122:f9eeca106725 952 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 953 * @retval None
Kojto 122:f9eeca106725 954 */
Kojto 122:f9eeca106725 955 #define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
Kojto 109:9296ab0bfc11 956
Kojto 122:f9eeca106725 957 /** @brief Disable the UART one bit sample method.
Kojto 122:f9eeca106725 958 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 959 * @retval None
Kojto 122:f9eeca106725 960 */
Kojto 122:f9eeca106725 961 #define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
Kojto 122:f9eeca106725 962
Kojto 122:f9eeca106725 963 /** @brief Enable UART.
Kojto 109:9296ab0bfc11 964 * @param __HANDLE__: specifies the UART Handle.
Kojto 109:9296ab0bfc11 965 * The Handle Instance can be UARTx where x: 1, 2, 3, 4 or 5 to select the UART peripheral
Kojto 109:9296ab0bfc11 966 * @retval None
Kojto 122:f9eeca106725 967 */
Kojto 109:9296ab0bfc11 968 #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
Kojto 109:9296ab0bfc11 969
Kojto 109:9296ab0bfc11 970 /** @brief Disable UART
Kojto 109:9296ab0bfc11 971 * @param __HANDLE__: specifies the UART Handle.
Kojto 109:9296ab0bfc11 972 * The Handle Instance can be UARTx where x: 1, 2, 3, 4 or 5 to select the UART peripheral
Kojto 109:9296ab0bfc11 973 * @retval None
Kojto 109:9296ab0bfc11 974 */
Kojto 109:9296ab0bfc11 975 #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
Kojto 109:9296ab0bfc11 976
Kojto 122:f9eeca106725 977 /** @brief Enable CTS flow control.
Kojto 122:f9eeca106725 978 * @note This macro allows to enable CTS hardware flow control for a given UART instance,
Kojto 122:f9eeca106725 979 * without need to call HAL_UART_Init() function.
Kojto 122:f9eeca106725 980 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
Kojto 122:f9eeca106725 981 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
Kojto 122:f9eeca106725 982 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
Kojto 122:f9eeca106725 983 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
Kojto 122:f9eeca106725 984 * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
Kojto 122:f9eeca106725 985 * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
Kojto 122:f9eeca106725 986 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 987 * @retval None
Kojto 109:9296ab0bfc11 988 */
Kojto 122:f9eeca106725 989 #define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \
Kojto 122:f9eeca106725 990 do{ \
Kojto 122:f9eeca106725 991 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
Kojto 122:f9eeca106725 992 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \
Kojto 122:f9eeca106725 993 } while(0)
Kojto 109:9296ab0bfc11 994
Kojto 122:f9eeca106725 995 /** @brief Disable CTS flow control.
Kojto 122:f9eeca106725 996 * @note This macro allows to disable CTS hardware flow control for a given UART instance,
Kojto 122:f9eeca106725 997 * without need to call HAL_UART_Init() function.
Kojto 122:f9eeca106725 998 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
Kojto 122:f9eeca106725 999 * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
Kojto 122:f9eeca106725 1000 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
Kojto 122:f9eeca106725 1001 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
Kojto 122:f9eeca106725 1002 * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
Kojto 122:f9eeca106725 1003 * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
Kojto 122:f9eeca106725 1004 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 1005 * @retval None
Kojto 109:9296ab0bfc11 1006 */
Kojto 122:f9eeca106725 1007 #define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \
Kojto 122:f9eeca106725 1008 do{ \
Kojto 122:f9eeca106725 1009 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
Kojto 122:f9eeca106725 1010 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \
Kojto 122:f9eeca106725 1011 } while(0)
Kojto 109:9296ab0bfc11 1012
Kojto 122:f9eeca106725 1013 /** @brief Enable RTS flow control.
Kojto 122:f9eeca106725 1014 * @note This macro allows to enable RTS hardware flow control for a given UART instance,
Kojto 122:f9eeca106725 1015 * without need to call HAL_UART_Init() function.
Kojto 122:f9eeca106725 1016 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
Kojto 122:f9eeca106725 1017 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
Kojto 122:f9eeca106725 1018 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
Kojto 122:f9eeca106725 1019 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
Kojto 122:f9eeca106725 1020 * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
Kojto 122:f9eeca106725 1021 * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
Kojto 122:f9eeca106725 1022 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 1023 * @retval None
Kojto 109:9296ab0bfc11 1024 */
Kojto 122:f9eeca106725 1025 #define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \
Kojto 122:f9eeca106725 1026 do{ \
Kojto 122:f9eeca106725 1027 SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \
Kojto 122:f9eeca106725 1028 (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \
Kojto 122:f9eeca106725 1029 } while(0)
Kojto 109:9296ab0bfc11 1030
Kojto 122:f9eeca106725 1031 /** @brief Disable RTS flow control.
Kojto 122:f9eeca106725 1032 * @note This macro allows to disable RTS hardware flow control for a given UART instance,
Kojto 122:f9eeca106725 1033 * without need to call HAL_UART_Init() function.
Kojto 122:f9eeca106725 1034 * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
Kojto 122:f9eeca106725 1035 * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
Kojto 122:f9eeca106725 1036 * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
Kojto 122:f9eeca106725 1037 * - UART instance should have already been initialised (through call of HAL_UART_Init() )
Kojto 122:f9eeca106725 1038 * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
Kojto 122:f9eeca106725 1039 * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
Kojto 122:f9eeca106725 1040 * @param __HANDLE__: specifies the UART Handle.
Kojto 122:f9eeca106725 1041 * @retval None
Kojto 109:9296ab0bfc11 1042 */
Kojto 122:f9eeca106725 1043 #define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \
Kojto 122:f9eeca106725 1044 do{ \
Kojto 122:f9eeca106725 1045 CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\
Kojto 122:f9eeca106725 1046 (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \
Kojto 122:f9eeca106725 1047 } while(0)
Kojto 109:9296ab0bfc11 1048
Kojto 109:9296ab0bfc11 1049 /**
Kojto 109:9296ab0bfc11 1050 * @}
Kojto 109:9296ab0bfc11 1051 */
Kojto 109:9296ab0bfc11 1052
Kojto 122:f9eeca106725 1053 /* Private macros --------------------------------------------------------*/
Kojto 122:f9eeca106725 1054 /** @defgroup UART_Private_Macros UART Private Macros
Kojto 122:f9eeca106725 1055 * @{
Kojto 122:f9eeca106725 1056 */
Kojto 122:f9eeca106725 1057
Kojto 122:f9eeca106725 1058 /** @brief BRR division operation to set BRR register in 8-bit oversampling mode.
Kojto 122:f9eeca106725 1059 * @param __PCLK__: UART clock.
Kojto 122:f9eeca106725 1060 * @param __BAUD__: Baud rate set by the user.
Kojto 122:f9eeca106725 1061 * @retval Division result
Kojto 122:f9eeca106725 1062 */
Kojto 122:f9eeca106725 1063 #define UART_DIV_SAMPLING8(__PCLK__, __BAUD__) ((((__PCLK__)*2) + ((__BAUD__)/2)) / (__BAUD__))
Kojto 122:f9eeca106725 1064
Kojto 122:f9eeca106725 1065 /** @brief BRR division operation to set BRR register in 16-bit oversampling mode.
Kojto 122:f9eeca106725 1066 * @param __PCLK__: UART clock.
Kojto 122:f9eeca106725 1067 * @param __BAUD__: Baud rate set by the user.
Kojto 122:f9eeca106725 1068 * @retval Division result
Kojto 122:f9eeca106725 1069 */
Kojto 122:f9eeca106725 1070 #define UART_DIV_SAMPLING16(__PCLK__, __BAUD__) (((__PCLK__) + ((__BAUD__)/2)) / (__BAUD__))
Kojto 122:f9eeca106725 1071
Kojto 122:f9eeca106725 1072 /** @brief Check UART Baud rate
Kojto 122:f9eeca106725 1073 * @param __BAUDRATE__: Baudrate specified by the user.
Kojto 122:f9eeca106725 1074 * The maximum Baud Rate is derived from the maximum clock on F3 (i.e. 72 MHz)
Kojto 122:f9eeca106725 1075 * divided by the smallest oversampling used on the USART (i.e. 8)
Kojto 122:f9eeca106725 1076 * @retval SET (__BAUDRATE__ is valid) or RESET (__BAUDRATE__ is invalid)
Kojto 122:f9eeca106725 1077 */
Kojto 122:f9eeca106725 1078 #define IS_UART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 9000001)
Kojto 122:f9eeca106725 1079
Kojto 122:f9eeca106725 1080 /** @brief Check UART assertion time.
Kojto 122:f9eeca106725 1081 * @param __TIME__: 5-bit value assertion time.
Kojto 122:f9eeca106725 1082 * @retval Test result (TRUE or FALSE).
Kojto 122:f9eeca106725 1083 */
Kojto 122:f9eeca106725 1084 #define IS_UART_ASSERTIONTIME(__TIME__) ((__TIME__) <= 0x1F)
Kojto 122:f9eeca106725 1085
Kojto 122:f9eeca106725 1086 /** @brief Check UART deassertion time.
Kojto 122:f9eeca106725 1087 * @param __TIME__: 5-bit value deassertion time.
Kojto 122:f9eeca106725 1088 * @retval Test result (TRUE or FALSE).
Kojto 122:f9eeca106725 1089 */
Kojto 122:f9eeca106725 1090 #define IS_UART_DEASSERTIONTIME(__TIME__) ((__TIME__) <= 0x1F)
Kojto 122:f9eeca106725 1091
Kojto 122:f9eeca106725 1092 /**
Kojto 122:f9eeca106725 1093 * @brief Ensure that UART frame number of stop bits is valid.
Kojto 122:f9eeca106725 1094 * @param __STOPBITS__: UART frame number of stop bits.
Kojto 122:f9eeca106725 1095 * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
Kojto 122:f9eeca106725 1096 */
Kojto 122:f9eeca106725 1097 #define IS_UART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_0_5) || \
Kojto 122:f9eeca106725 1098 ((__STOPBITS__) == UART_STOPBITS_1) || \
Kojto 122:f9eeca106725 1099 ((__STOPBITS__) == UART_STOPBITS_1_5) || \
Kojto 122:f9eeca106725 1100 ((__STOPBITS__) == UART_STOPBITS_2))
Kojto 122:f9eeca106725 1101
Kojto 122:f9eeca106725 1102 /**
Kojto 122:f9eeca106725 1103 * @brief Ensure that UART frame parity is valid.
Kojto 122:f9eeca106725 1104 * @param __PARITY__: UART frame parity.
Kojto 122:f9eeca106725 1105 * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
Kojto 122:f9eeca106725 1106 */
Kojto 122:f9eeca106725 1107 #define IS_UART_PARITY(__PARITY__) (((__PARITY__) == UART_PARITY_NONE) || \
Kojto 122:f9eeca106725 1108 ((__PARITY__) == UART_PARITY_EVEN) || \
Kojto 122:f9eeca106725 1109 ((__PARITY__) == UART_PARITY_ODD))
Kojto 122:f9eeca106725 1110
Kojto 122:f9eeca106725 1111 /**
Kojto 122:f9eeca106725 1112 * @brief Ensure that UART hardware flow control is valid.
Kojto 122:f9eeca106725 1113 * @param __CONTROL__: UART hardware flow control.
Kojto 122:f9eeca106725 1114 * @retval SET (__CONTROL__ is valid) or RESET (__CONTROL__ is invalid)
Kojto 122:f9eeca106725 1115 */
Kojto 122:f9eeca106725 1116 #define IS_UART_HARDWARE_FLOW_CONTROL(__CONTROL__)\
Kojto 122:f9eeca106725 1117 (((__CONTROL__) == UART_HWCONTROL_NONE) || \
Kojto 122:f9eeca106725 1118 ((__CONTROL__) == UART_HWCONTROL_RTS) || \
Kojto 122:f9eeca106725 1119 ((__CONTROL__) == UART_HWCONTROL_CTS) || \
Kojto 122:f9eeca106725 1120 ((__CONTROL__) == UART_HWCONTROL_RTS_CTS))
Kojto 122:f9eeca106725 1121
Kojto 122:f9eeca106725 1122 /**
Kojto 122:f9eeca106725 1123 * @brief Ensure that UART communication mode is valid.
Kojto 122:f9eeca106725 1124 * @param __MODE__: UART communication mode.
Kojto 122:f9eeca106725 1125 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 122:f9eeca106725 1126 */
Kojto 122:f9eeca106725 1127 #define IS_UART_MODE(__MODE__) ((((__MODE__) & (~((uint32_t)(UART_MODE_TX_RX)))) == (uint32_t)0x00) && ((__MODE__) != (uint32_t)0x00))
Kojto 122:f9eeca106725 1128
Kojto 122:f9eeca106725 1129 /**
Kojto 122:f9eeca106725 1130 * @brief Ensure that UART state is valid.
Kojto 122:f9eeca106725 1131 * @param __STATE__: UART state.
Kojto 122:f9eeca106725 1132 * @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid)
Kojto 122:f9eeca106725 1133 */
Kojto 122:f9eeca106725 1134 #define IS_UART_STATE(__STATE__) (((__STATE__) == UART_STATE_DISABLE) || \
Kojto 122:f9eeca106725 1135 ((__STATE__) == UART_STATE_ENABLE))
Kojto 122:f9eeca106725 1136
Kojto 122:f9eeca106725 1137 /**
Kojto 122:f9eeca106725 1138 * @brief Ensure that UART oversampling is valid.
Kojto 122:f9eeca106725 1139 * @param __SAMPLING__: UART oversampling.
Kojto 122:f9eeca106725 1140 * @retval SET (__SAMPLING__ is valid) or RESET (__SAMPLING__ is invalid)
Kojto 122:f9eeca106725 1141 */
Kojto 122:f9eeca106725 1142 #define IS_UART_OVERSAMPLING(__SAMPLING__) (((__SAMPLING__) == UART_OVERSAMPLING_16) || \
Kojto 122:f9eeca106725 1143 ((__SAMPLING__) == UART_OVERSAMPLING_8))
Kojto 122:f9eeca106725 1144
Kojto 122:f9eeca106725 1145 /**
Kojto 122:f9eeca106725 1146 * @brief Ensure that UART frame sampling is valid.
Kojto 122:f9eeca106725 1147 * @param __ONEBIT__: UART frame sampling.
Kojto 122:f9eeca106725 1148 * @retval SET (__ONEBIT__ is valid) or RESET (__ONEBIT__ is invalid)
Kojto 122:f9eeca106725 1149 */
Kojto 122:f9eeca106725 1150 #define IS_UART_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == UART_ONE_BIT_SAMPLE_DISABLE) || \
Kojto 122:f9eeca106725 1151 ((__ONEBIT__) == UART_ONE_BIT_SAMPLE_ENABLE))
Kojto 122:f9eeca106725 1152
Kojto 122:f9eeca106725 1153 /**
Kojto 122:f9eeca106725 1154 * @brief Ensure that Address Length detection parameter is valid.
Kojto 122:f9eeca106725 1155 * @param __ADDRESS__: UART Adress length value.
Kojto 122:f9eeca106725 1156 * @retval SET (__ADDRESS__ is valid) or RESET (__ADDRESS__ is invalid)
Kojto 122:f9eeca106725 1157 */
Kojto 122:f9eeca106725 1158 #define IS_UART_ADDRESSLENGTH_DETECT(__ADDRESS__) (((__ADDRESS__) == UART_ADDRESS_DETECT_4B) || \
Kojto 122:f9eeca106725 1159 ((__ADDRESS__) == UART_ADDRESS_DETECT_7B))
Kojto 122:f9eeca106725 1160
Kojto 122:f9eeca106725 1161 /**
Kojto 122:f9eeca106725 1162 * @brief Ensure that UART auto Baud rate detection mode is valid.
Kojto 122:f9eeca106725 1163 * @param __MODE__: UART auto Baud rate detection mode.
Kojto 122:f9eeca106725 1164 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 122:f9eeca106725 1165 */
Kojto 122:f9eeca106725 1166 #define IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(__MODE__) (((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT) || \
Kojto 122:f9eeca106725 1167 ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE) || \
Kojto 122:f9eeca106725 1168 ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME) || \
Kojto 122:f9eeca106725 1169 ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME))
Kojto 122:f9eeca106725 1170
Kojto 122:f9eeca106725 1171 /**
Kojto 122:f9eeca106725 1172 * @brief Ensure that UART receiver timeout setting is valid.
Kojto 122:f9eeca106725 1173 * @param __TIMEOUT__: UART receiver timeout setting.
Kojto 122:f9eeca106725 1174 * @retval SET (__TIMEOUT__ is valid) or RESET (__TIMEOUT__ is invalid)
Kojto 122:f9eeca106725 1175 */
Kojto 122:f9eeca106725 1176 #define IS_UART_RECEIVER_TIMEOUT(__TIMEOUT__) (((__TIMEOUT__) == UART_RECEIVER_TIMEOUT_DISABLE) || \
Kojto 122:f9eeca106725 1177 ((__TIMEOUT__) == UART_RECEIVER_TIMEOUT_ENABLE))
Kojto 122:f9eeca106725 1178
Kojto 122:f9eeca106725 1179 /**
Kojto 122:f9eeca106725 1180 * @brief Ensure that UART LIN state is valid.
Kojto 122:f9eeca106725 1181 * @param __LIN__: UART LIN state.
Kojto 122:f9eeca106725 1182 * @retval SET (__LIN__ is valid) or RESET (__LIN__ is invalid)
Kojto 122:f9eeca106725 1183 */
Kojto 122:f9eeca106725 1184 #define IS_UART_LIN(__LIN__) (((__LIN__) == UART_LIN_DISABLE) || \
Kojto 122:f9eeca106725 1185 ((__LIN__) == UART_LIN_ENABLE))
Kojto 122:f9eeca106725 1186
Kojto 122:f9eeca106725 1187 /**
Kojto 122:f9eeca106725 1188 * @brief Ensure that UART LIN break detection length is valid.
Kojto 122:f9eeca106725 1189 * @param __LENGTH__: UART LIN break detection length.
Kojto 122:f9eeca106725 1190 * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid)
Kojto 122:f9eeca106725 1191 */
Kojto 122:f9eeca106725 1192 #define IS_UART_LIN_BREAK_DETECT_LENGTH(__LENGTH__) (((__LENGTH__) == UART_LINBREAKDETECTLENGTH_10B) || \
Kojto 122:f9eeca106725 1193 ((__LENGTH__) == UART_LINBREAKDETECTLENGTH_11B))
Kojto 122:f9eeca106725 1194
Kojto 122:f9eeca106725 1195 /**
Kojto 122:f9eeca106725 1196 * @brief Ensure that UART DMA TX state is valid.
Kojto 122:f9eeca106725 1197 * @param __DMATX__: UART DMA TX state.
Kojto 122:f9eeca106725 1198 * @retval SET (__DMATX__ is valid) or RESET (__DMATX__ is invalid)
Kojto 122:f9eeca106725 1199 */
Kojto 122:f9eeca106725 1200 #define IS_UART_DMA_TX(__DMATX__) (((__DMATX__) == UART_DMA_TX_DISABLE) || \
Kojto 122:f9eeca106725 1201 ((__DMATX__) == UART_DMA_TX_ENABLE))
Kojto 122:f9eeca106725 1202
Kojto 122:f9eeca106725 1203 /**
Kojto 122:f9eeca106725 1204 * @brief Ensure that UART DMA RX state is valid.
Kojto 122:f9eeca106725 1205 * @param __DMARX__: UART DMA RX state.
Kojto 122:f9eeca106725 1206 * @retval SET (__DMARX__ is valid) or RESET (__DMARX__ is invalid)
Kojto 122:f9eeca106725 1207 */
Kojto 122:f9eeca106725 1208 #define IS_UART_DMA_RX(__DMARX__) (((__DMARX__) == UART_DMA_RX_DISABLE) || \
Kojto 122:f9eeca106725 1209 ((__DMARX__) == UART_DMA_RX_ENABLE))
Kojto 122:f9eeca106725 1210
Kojto 122:f9eeca106725 1211 /**
Kojto 122:f9eeca106725 1212 * @brief Ensure that UART half-duplex state is valid.
Kojto 122:f9eeca106725 1213 * @param __HDSEL__: UART half-duplex state.
Kojto 122:f9eeca106725 1214 * @retval SET (__HDSEL__ is valid) or RESET (__HDSEL__ is invalid)
Kojto 122:f9eeca106725 1215 */
Kojto 122:f9eeca106725 1216 #define IS_UART_HALF_DUPLEX(__HDSEL__) (((__HDSEL__) == UART_HALF_DUPLEX_DISABLE) || \
Kojto 122:f9eeca106725 1217 ((__HDSEL__) == UART_HALF_DUPLEX_ENABLE))
Kojto 122:f9eeca106725 1218
Kojto 122:f9eeca106725 1219 /**
Kojto 122:f9eeca106725 1220 * @brief Ensure that UART wake-up method is valid.
Kojto 122:f9eeca106725 1221 * @param __WAKEUP__: UART wake-up method .
Kojto 122:f9eeca106725 1222 * @retval SET (__WAKEUP__ is valid) or RESET (__WAKEUP__ is invalid)
Kojto 122:f9eeca106725 1223 */
Kojto 122:f9eeca106725 1224 #define IS_UART_WAKEUPMETHOD(__WAKEUP__) (((__WAKEUP__) == UART_WAKEUPMETHOD_IDLELINE) || \
Kojto 122:f9eeca106725 1225 ((__WAKEUP__) == UART_WAKEUPMETHOD_ADDRESSMARK))
Kojto 122:f9eeca106725 1226
Kojto 122:f9eeca106725 1227 /**
Kojto 122:f9eeca106725 1228 * @brief Ensure that UART advanced features initialization is valid.
Kojto 122:f9eeca106725 1229 * @param __INIT__: UART advanced features initialization.
Kojto 122:f9eeca106725 1230 * @retval SET (__INIT__ is valid) or RESET (__INIT__ is invalid)
Kojto 122:f9eeca106725 1231 */
Kojto 122:f9eeca106725 1232 #define IS_UART_ADVFEATURE_INIT(__INIT__) ((__INIT__) <= (UART_ADVFEATURE_NO_INIT | \
Kojto 122:f9eeca106725 1233 UART_ADVFEATURE_TXINVERT_INIT | \
Kojto 122:f9eeca106725 1234 UART_ADVFEATURE_RXINVERT_INIT | \
Kojto 122:f9eeca106725 1235 UART_ADVFEATURE_DATAINVERT_INIT | \
Kojto 122:f9eeca106725 1236 UART_ADVFEATURE_SWAP_INIT | \
Kojto 122:f9eeca106725 1237 UART_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
Kojto 122:f9eeca106725 1238 UART_ADVFEATURE_DMADISABLEONERROR_INIT | \
Kojto 122:f9eeca106725 1239 UART_ADVFEATURE_AUTOBAUDRATE_INIT | \
Kojto 122:f9eeca106725 1240 UART_ADVFEATURE_MSBFIRST_INIT))
Kojto 122:f9eeca106725 1241
Kojto 122:f9eeca106725 1242 /**
Kojto 122:f9eeca106725 1243 * @brief Ensure that UART frame TX inversion setting is valid.
Kojto 122:f9eeca106725 1244 * @param __TXINV__: UART frame TX inversion setting.
Kojto 122:f9eeca106725 1245 * @retval SET (__TXINV__ is valid) or RESET (__TXINV__ is invalid)
Kojto 122:f9eeca106725 1246 */
Kojto 122:f9eeca106725 1247 #define IS_UART_ADVFEATURE_TXINV(__TXINV__) (((__TXINV__) == UART_ADVFEATURE_TXINV_DISABLE) || \
Kojto 122:f9eeca106725 1248 ((__TXINV__) == UART_ADVFEATURE_TXINV_ENABLE))
Kojto 122:f9eeca106725 1249
Kojto 122:f9eeca106725 1250 /**
Kojto 122:f9eeca106725 1251 * @brief Ensure that UART frame RX inversion setting is valid.
Kojto 122:f9eeca106725 1252 * @param __RXINV__: UART frame RX inversion setting.
Kojto 122:f9eeca106725 1253 * @retval SET (__RXINV__ is valid) or RESET (__RXINV__ is invalid)
Kojto 122:f9eeca106725 1254 */
Kojto 122:f9eeca106725 1255 #define IS_UART_ADVFEATURE_RXINV(__RXINV__) (((__RXINV__) == UART_ADVFEATURE_RXINV_DISABLE) || \
Kojto 122:f9eeca106725 1256 ((__RXINV__) == UART_ADVFEATURE_RXINV_ENABLE))
Kojto 122:f9eeca106725 1257
Kojto 122:f9eeca106725 1258 /**
Kojto 122:f9eeca106725 1259 * @brief Ensure that UART frame data inversion setting is valid.
Kojto 122:f9eeca106725 1260 * @param __DATAINV__: UART frame data inversion setting.
Kojto 122:f9eeca106725 1261 * @retval SET (__DATAINV__ is valid) or RESET (__DATAINV__ is invalid)
Kojto 122:f9eeca106725 1262 */
Kojto 122:f9eeca106725 1263 #define IS_UART_ADVFEATURE_DATAINV(__DATAINV__) (((__DATAINV__) == UART_ADVFEATURE_DATAINV_DISABLE) || \
Kojto 122:f9eeca106725 1264 ((__DATAINV__) == UART_ADVFEATURE_DATAINV_ENABLE))
Kojto 122:f9eeca106725 1265
Kojto 122:f9eeca106725 1266 /**
Kojto 122:f9eeca106725 1267 * @brief Ensure that UART frame RX/TX pins swap setting is valid.
Kojto 122:f9eeca106725 1268 * @param __SWAP__: UART frame RX/TX pins swap setting.
Kojto 122:f9eeca106725 1269 * @retval SET (__SWAP__ is valid) or RESET (__SWAP__ is invalid)
Kojto 122:f9eeca106725 1270 */
Kojto 122:f9eeca106725 1271 #define IS_UART_ADVFEATURE_SWAP(__SWAP__) (((__SWAP__) == UART_ADVFEATURE_SWAP_DISABLE) || \
Kojto 122:f9eeca106725 1272 ((__SWAP__) == UART_ADVFEATURE_SWAP_ENABLE))
Kojto 122:f9eeca106725 1273
Kojto 122:f9eeca106725 1274 /**
Kojto 122:f9eeca106725 1275 * @brief Ensure that UART frame overrun setting is valid.
Kojto 122:f9eeca106725 1276 * @param __OVERRUN__: UART frame overrun setting.
Kojto 122:f9eeca106725 1277 * @retval SET (__OVERRUN__ is valid) or RESET (__OVERRUN__ is invalid)
Kojto 122:f9eeca106725 1278 */
Kojto 122:f9eeca106725 1279 #define IS_UART_OVERRUN(__OVERRUN__) (((__OVERRUN__) == UART_ADVFEATURE_OVERRUN_ENABLE) || \
Kojto 122:f9eeca106725 1280 ((__OVERRUN__) == UART_ADVFEATURE_OVERRUN_DISABLE))
Kojto 122:f9eeca106725 1281
Kojto 122:f9eeca106725 1282 /**
Kojto 122:f9eeca106725 1283 * @brief Ensure that UART auto Baud rate state is valid.
Kojto 122:f9eeca106725 1284 * @param __AUTOBAUDRATE__: UART auto Baud rate state.
Kojto 122:f9eeca106725 1285 * @retval SET (__AUTOBAUDRATE__ is valid) or RESET (__AUTOBAUDRATE__ is invalid)
Kojto 122:f9eeca106725 1286 */
Kojto 122:f9eeca106725 1287 #define IS_UART_ADVFEATURE_AUTOBAUDRATE(__AUTOBAUDRATE__) (((__AUTOBAUDRATE__) == UART_ADVFEATURE_AUTOBAUDRATE_DISABLE) || \
Kojto 122:f9eeca106725 1288 ((__AUTOBAUDRATE__) == UART_ADVFEATURE_AUTOBAUDRATE_ENABLE))
Kojto 122:f9eeca106725 1289
Kojto 122:f9eeca106725 1290 /**
Kojto 122:f9eeca106725 1291 * @brief Ensure that UART DMA enabling or disabling on error setting is valid.
Kojto 122:f9eeca106725 1292 * @param __DMA__: UART DMA enabling or disabling on error setting.
Kojto 122:f9eeca106725 1293 * @retval SET (__DMA__ is valid) or RESET (__DMA__ is invalid)
Kojto 122:f9eeca106725 1294 */
Kojto 122:f9eeca106725 1295 #define IS_UART_ADVFEATURE_DMAONRXERROR(__DMA__) (((__DMA__) == UART_ADVFEATURE_DMA_ENABLEONRXERROR) || \
Kojto 122:f9eeca106725 1296 ((__DMA__) == UART_ADVFEATURE_DMA_DISABLEONRXERROR))
Kojto 122:f9eeca106725 1297
Kojto 122:f9eeca106725 1298 /**
Kojto 122:f9eeca106725 1299 * @brief Ensure that UART frame MSB first setting is valid.
Kojto 122:f9eeca106725 1300 * @param __MSBFIRST__: UART frame MSB first setting.
Kojto 122:f9eeca106725 1301 * @retval SET (__MSBFIRST__ is valid) or RESET (__MSBFIRST__ is invalid)
Kojto 122:f9eeca106725 1302 */
Kojto 122:f9eeca106725 1303 #define IS_UART_ADVFEATURE_MSBFIRST(__MSBFIRST__) (((__MSBFIRST__) == UART_ADVFEATURE_MSBFIRST_DISABLE) || \
Kojto 122:f9eeca106725 1304 ((__MSBFIRST__) == UART_ADVFEATURE_MSBFIRST_ENABLE))
Kojto 122:f9eeca106725 1305
Kojto 122:f9eeca106725 1306 /**
Kojto 122:f9eeca106725 1307 * @brief Ensure that UART stop mode state is valid.
Kojto 122:f9eeca106725 1308 * @param __STOPMODE__: UART stop mode state.
Kojto 122:f9eeca106725 1309 * @retval SET (__STOPMODE__ is valid) or RESET (__STOPMODE__ is invalid)
Kojto 122:f9eeca106725 1310 */
Kojto 122:f9eeca106725 1311 #define IS_UART_ADVFEATURE_STOPMODE(__STOPMODE__) (((__STOPMODE__) == UART_ADVFEATURE_STOPMODE_DISABLE) || \
Kojto 122:f9eeca106725 1312 ((__STOPMODE__) == UART_ADVFEATURE_STOPMODE_ENABLE))
Kojto 122:f9eeca106725 1313
Kojto 122:f9eeca106725 1314 /**
Kojto 122:f9eeca106725 1315 * @brief Ensure that UART mute mode state is valid.
Kojto 122:f9eeca106725 1316 * @param __MUTE__: UART mute mode state.
Kojto 122:f9eeca106725 1317 * @retval SET (__MUTE__ is valid) or RESET (__MUTE__ is invalid)
Kojto 122:f9eeca106725 1318 */
Kojto 122:f9eeca106725 1319 #define IS_UART_MUTE_MODE(__MUTE__) (((__MUTE__) == UART_ADVFEATURE_MUTEMODE_DISABLE) || \
Kojto 122:f9eeca106725 1320 ((__MUTE__) == UART_ADVFEATURE_MUTEMODE_ENABLE))
Kojto 122:f9eeca106725 1321
Kojto 122:f9eeca106725 1322 /**
Kojto 122:f9eeca106725 1323 * @brief Ensure that UART wake-up selection is valid.
Kojto 122:f9eeca106725 1324 * @param __WAKE__: UART wake-up selection.
Kojto 122:f9eeca106725 1325 * @retval SET (__WAKE__ is valid) or RESET (__WAKE__ is invalid)
Kojto 122:f9eeca106725 1326 */
Kojto 122:f9eeca106725 1327 #define IS_UART_WAKEUP_SELECTION(__WAKE__) (((__WAKE__) == UART_WAKEUP_ON_ADDRESS) || \
Kojto 122:f9eeca106725 1328 ((__WAKE__) == UART_WAKEUP_ON_STARTBIT) || \
Kojto 122:f9eeca106725 1329 ((__WAKE__) == UART_WAKEUP_ON_READDATA_NONEMPTY))
Kojto 122:f9eeca106725 1330
Kojto 122:f9eeca106725 1331 /**
Kojto 122:f9eeca106725 1332 * @brief Ensure that UART driver enable polarity is valid.
Kojto 122:f9eeca106725 1333 * @param __POLARITY__: UART driver enable polarity.
Kojto 122:f9eeca106725 1334 * @retval SET (__POLARITY__ is valid) or RESET (__POLARITY__ is invalid)
Kojto 122:f9eeca106725 1335 */
Kojto 122:f9eeca106725 1336 #define IS_UART_DE_POLARITY(__POLARITY__) (((__POLARITY__) == UART_DE_POLARITY_HIGH) || \
Kojto 122:f9eeca106725 1337 ((__POLARITY__) == UART_DE_POLARITY_LOW))
Kojto 122:f9eeca106725 1338
Kojto 122:f9eeca106725 1339 /**
Kojto 122:f9eeca106725 1340 * @brief Ensure that UART request parameter is valid.
Kojto 122:f9eeca106725 1341 * @param __PARAM__: UART request parameter.
Kojto 122:f9eeca106725 1342 * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid)
Kojto 122:f9eeca106725 1343 */
Kojto 122:f9eeca106725 1344 #define IS_UART_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == UART_AUTOBAUD_REQUEST) || \
Kojto 122:f9eeca106725 1345 ((__PARAM__) == UART_SENDBREAK_REQUEST) || \
Kojto 122:f9eeca106725 1346 ((__PARAM__) == UART_MUTE_MODE_REQUEST) || \
Kojto 122:f9eeca106725 1347 ((__PARAM__) == UART_RXDATA_FLUSH_REQUEST) || \
Kojto 122:f9eeca106725 1348 ((__PARAM__) == UART_TXDATA_FLUSH_REQUEST))
Kojto 122:f9eeca106725 1349 /**
Kojto 122:f9eeca106725 1350 * @}
Kojto 122:f9eeca106725 1351 */
Kojto 122:f9eeca106725 1352
Kojto 122:f9eeca106725 1353 /* Include UART HAL Extension module */
Kojto 122:f9eeca106725 1354 #include "stm32f3xx_hal_uart_ex.h"
Kojto 109:9296ab0bfc11 1355
Kojto 109:9296ab0bfc11 1356 /* Exported functions --------------------------------------------------------*/
Kojto 109:9296ab0bfc11 1357 /** @addtogroup UART_Exported_Functions UART Exported Functions
Kojto 109:9296ab0bfc11 1358 * @{
Kojto 109:9296ab0bfc11 1359 */
Kojto 109:9296ab0bfc11 1360
Kojto 109:9296ab0bfc11 1361 /** @addtogroup UART_Exported_Functions_Group1 Initialization and de-initialization functions
Kojto 109:9296ab0bfc11 1362 * @{
Kojto 109:9296ab0bfc11 1363 */
Kojto 122:f9eeca106725 1364
Kojto 109:9296ab0bfc11 1365 /* Initialization and de-initialization functions ****************************/
Kojto 109:9296ab0bfc11 1366 HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
Kojto 109:9296ab0bfc11 1367 HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);
Kojto 109:9296ab0bfc11 1368 HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength);
Kojto 109:9296ab0bfc11 1369 HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod);
Kojto 109:9296ab0bfc11 1370 HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart);
Kojto 109:9296ab0bfc11 1371 void HAL_UART_MspInit(UART_HandleTypeDef *huart);
Kojto 109:9296ab0bfc11 1372 void HAL_UART_MspDeInit(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1373
Kojto 109:9296ab0bfc11 1374 /**
Kojto 109:9296ab0bfc11 1375 * @}
Kojto 109:9296ab0bfc11 1376 */
Kojto 109:9296ab0bfc11 1377
Kojto 122:f9eeca106725 1378 /** @addtogroup UART_Exported_Functions_Group2 IO operation functions
Kojto 109:9296ab0bfc11 1379 * @{
Kojto 109:9296ab0bfc11 1380 */
Kojto 122:f9eeca106725 1381
Kojto 109:9296ab0bfc11 1382 /* IO operation functions *****************************************************/
Kojto 109:9296ab0bfc11 1383 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 109:9296ab0bfc11 1384 HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 109:9296ab0bfc11 1385 HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
Kojto 109:9296ab0bfc11 1386 HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
Kojto 109:9296ab0bfc11 1387 HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
Kojto 109:9296ab0bfc11 1388 HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
Kojto 109:9296ab0bfc11 1389 HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
Kojto 109:9296ab0bfc11 1390 HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
Kojto 109:9296ab0bfc11 1391 HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
Kojto 109:9296ab0bfc11 1392 void HAL_UART_IRQHandler(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1393 void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
Kojto 109:9296ab0bfc11 1394 void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart);
Kojto 109:9296ab0bfc11 1395 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1396 void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart);
Kojto 109:9296ab0bfc11 1397 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1398
Kojto 122:f9eeca106725 1399 /**
Kojto 122:f9eeca106725 1400 * @}
Kojto 122:f9eeca106725 1401 */
Kojto 122:f9eeca106725 1402
Kojto 122:f9eeca106725 1403 /** @addtogroup UART_Exported_Functions_Group3 Peripheral Control functions
Kojto 122:f9eeca106725 1404 * @{
Kojto 122:f9eeca106725 1405 */
Kojto 109:9296ab0bfc11 1406
Kojto 122:f9eeca106725 1407 /* Peripheral Control functions ************************************************/
Kojto 122:f9eeca106725 1408 HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1409 HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1410 void HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1411 HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1412 HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1413 HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1414
Kojto 109:9296ab0bfc11 1415 /**
Kojto 109:9296ab0bfc11 1416 * @}
Kojto 109:9296ab0bfc11 1417 */
Kojto 109:9296ab0bfc11 1418
Kojto 122:f9eeca106725 1419 /** @addtogroup UART_Exported_Functions_Group4 Peripheral State and Error functions
Kojto 109:9296ab0bfc11 1420 * @{
Kojto 109:9296ab0bfc11 1421 */
Kojto 109:9296ab0bfc11 1422
Kojto 122:f9eeca106725 1423 /* Peripheral State and Errors functions **************************************************/
Kojto 122:f9eeca106725 1424 HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1425 uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1426
Kojto 109:9296ab0bfc11 1427 /**
Kojto 109:9296ab0bfc11 1428 * @}
Kojto 109:9296ab0bfc11 1429 */
Kojto 109:9296ab0bfc11 1430
Kojto 122:f9eeca106725 1431 /**
Kojto 122:f9eeca106725 1432 * @}
Kojto 122:f9eeca106725 1433 */
Kojto 122:f9eeca106725 1434
Kojto 122:f9eeca106725 1435 /* Private functions -----------------------------------------------------------*/
Kojto 122:f9eeca106725 1436 /** @addtogroup UART_Private_Functions UART Private Functions
Kojto 109:9296ab0bfc11 1437 * @{
Kojto 109:9296ab0bfc11 1438 */
Kojto 122:f9eeca106725 1439 HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1440 void UART_AdvFeatureConfig(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1441 HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1442 HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Timeout);
Kojto 122:f9eeca106725 1443 HAL_StatusTypeDef UART_Transmit_IT(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1444 HAL_StatusTypeDef UART_EndTransmit_IT(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1445 HAL_StatusTypeDef UART_Receive_IT(UART_HandleTypeDef *huart);
Kojto 122:f9eeca106725 1446 void UART_Wakeup_AddressConfig(UART_HandleTypeDef *huart, UART_WakeUpTypeDef WakeUpSelection);
Kojto 109:9296ab0bfc11 1447 /**
Kojto 109:9296ab0bfc11 1448 * @}
Kojto 109:9296ab0bfc11 1449 */
Kojto 109:9296ab0bfc11 1450
Kojto 109:9296ab0bfc11 1451 /**
Kojto 109:9296ab0bfc11 1452 * @}
Kojto 109:9296ab0bfc11 1453 */
Kojto 109:9296ab0bfc11 1454
Kojto 109:9296ab0bfc11 1455 /**
Kojto 109:9296ab0bfc11 1456 * @}
Kojto 122:f9eeca106725 1457 */
Kojto 109:9296ab0bfc11 1458
Kojto 109:9296ab0bfc11 1459 #ifdef __cplusplus
Kojto 109:9296ab0bfc11 1460 }
Kojto 109:9296ab0bfc11 1461 #endif
Kojto 109:9296ab0bfc11 1462
Kojto 109:9296ab0bfc11 1463 #endif /* __STM32F3xx_HAL_UART_H */
Kojto 109:9296ab0bfc11 1464
Kojto 109:9296ab0bfc11 1465 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Kojto 122:f9eeca106725 1466