The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
Kojto
Date:
Tue Feb 14 11:24:20 2017 +0000
Revision:
136:ef9c61f8c49f
Parent:
135:176b8275d35d
Release 136 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3432: Target STM USBHOST support https://github.com/ARMmbed/mbed-os/pull/3432
3181: NUCLEO_F207ZG extending PeripheralPins.c: all available alternate functions can be used now https://github.com/ARMmbed/mbed-os/pull/3181
3626: NUCLEO_F412ZG : Add USB Device +Host https://github.com/ARMmbed/mbed-os/pull/3626
3628: Fix warnings https://github.com/ARMmbed/mbed-os/pull/3628
3629: STM32: L0 LL layer https://github.com/ARMmbed/mbed-os/pull/3629
3632: IDE Export support for platform VK_RZ_A1H https://github.com/ARMmbed/mbed-os/pull/3632
3642: Missing IRQ pin fix for platform VK_RZ_A1H https://github.com/ARMmbed/mbed-os/pull/3642
3664: Fix ncs36510 sleep definitions https://github.com/ARMmbed/mbed-os/pull/3664
3655: [STM32F4] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3655
3657: [STM32L4] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3657
3658: [STM32F3] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3658
3685: STM32: I2C: reset state machine https://github.com/ARMmbed/mbed-os/pull/3685
3692: uVisor: Standardize available legacy heap and stack https://github.com/ARMmbed/mbed-os/pull/3692
3621: Fix for #2884, LPC824: export to LPCXpresso, target running with wron https://github.com/ARMmbed/mbed-os/pull/3621
3649: [STM32F7] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3649
3695: Enforce device_name is valid in targets.json https://github.com/ARMmbed/mbed-os/pull/3695
3723: NCS36510: spi_format function bug fix https://github.com/ARMmbed/mbed-os/pull/3723

Who changed what in which revision?

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