TUKS MCU Introductory course / TUKS-COURSE-THERMOMETER

Fork of TUKS-COURSE-TIMER by TUKS MCU Introductory course

Committer:
elmot
Date:
Fri Feb 24 21:13:56 2017 +0000
Revision:
1:d0dfbce63a89
Ready-to-copy

Who changed what in which revision?

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