Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
elijahorr
Date:
Thu Apr 14 07:28:54 2016 +0000
Revision:
121:672067c3ada4
Parent:
108:34e6b704fe68
.

Who changed what in which revision?

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