mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
108:34e6b704fe68
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

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