Support for MSP430 launchpad.

Fork of mbed by mbed official

Committer:
atamariya
Date:
Sat Jun 21 09:54:56 2014 +0000
Revision:
86:c662433839e3
Parent:
85:024bf7f99721
Support for MSP430

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
bogdanm 85:024bf7f99721 5 * @version V1.0.0
bogdanm 85:024bf7f99721 6 * @date 28-May-2014
bogdanm 85:024bf7f99721 7 * @brief Header file of UART HAL module.
bogdanm 85:024bf7f99721 8 ******************************************************************************
bogdanm 85:024bf7f99721 9 * @attention
bogdanm 85:024bf7f99721 10 *
bogdanm 85:024bf7f99721 11 * <h2><center>&copy; COPYRIGHT(c) 2014 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 * @{
bogdanm 85:024bf7f99721 55 */
bogdanm 85:024bf7f99721 56
bogdanm 85:024bf7f99721 57 /* Exported types ------------------------------------------------------------*/
bogdanm 85:024bf7f99721 58
bogdanm 85:024bf7f99721 59 /**
bogdanm 85:024bf7f99721 60 * @brief UART Init Structure definition
bogdanm 85:024bf7f99721 61 */
bogdanm 85:024bf7f99721 62 typedef struct
bogdanm 85:024bf7f99721 63 {
bogdanm 85:024bf7f99721 64 uint32_t BaudRate; /*!< This member configures the UART communication baud rate.
bogdanm 85:024bf7f99721 65 The baud rate register is computed using the following formula:
bogdanm 85:024bf7f99721 66 - If oversampling is 16 or in LIN mode (LIN mode not available on F030xx devices),
bogdanm 85:024bf7f99721 67 Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate)))
bogdanm 85:024bf7f99721 68 - If oversampling is 8,
bogdanm 85:024bf7f99721 69 Baud Rate Register[15:4] = ((2 * PCLKx) / ((huart->Init.BaudRate)))[15:4]
bogdanm 85:024bf7f99721 70 Baud Rate Register[3] = 0
bogdanm 85:024bf7f99721 71 Baud Rate Register[2:0] = (((2 * PCLKx) / ((huart->Init.BaudRate)))[3:0]) >> 1 */
bogdanm 85:024bf7f99721 72
bogdanm 85:024bf7f99721 73 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
bogdanm 85:024bf7f99721 74 This parameter can be a value of @ref UARTEx_Word_Length */
bogdanm 85:024bf7f99721 75
bogdanm 85:024bf7f99721 76 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
bogdanm 85:024bf7f99721 77 This parameter can be a value of @ref UART_Stop_Bits */
bogdanm 85:024bf7f99721 78
bogdanm 85:024bf7f99721 79 uint32_t Parity; /*!< Specifies the parity mode.
bogdanm 85:024bf7f99721 80 This parameter can be a value of @ref UART_Parity
bogdanm 85:024bf7f99721 81 @note When parity is enabled, the computed parity is inserted
bogdanm 85:024bf7f99721 82 at the MSB position of the transmitted data (9th bit when
bogdanm 85:024bf7f99721 83 the word length is set to 9 data bits; 8th bit when the
bogdanm 85:024bf7f99721 84 word length is set to 8 data bits). */
bogdanm 85:024bf7f99721 85
bogdanm 85:024bf7f99721 86 uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.
bogdanm 85:024bf7f99721 87 This parameter can be a value of @ref UART_Mode */
bogdanm 85:024bf7f99721 88
bogdanm 85:024bf7f99721 89 uint32_t HwFlowCtl; /*!< Specifies wether the hardware flow control mode is enabled
bogdanm 85:024bf7f99721 90 or disabled.
bogdanm 85:024bf7f99721 91 This parameter can be a value of @ref UART_Hardware_Flow_Control */
bogdanm 85:024bf7f99721 92
bogdanm 85:024bf7f99721 93 uint32_t OverSampling; /*!< Specifies wether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to fPCLK/8).
bogdanm 85:024bf7f99721 94 This parameter can be a value of @ref UART_Over_Sampling */
bogdanm 85:024bf7f99721 95
bogdanm 85:024bf7f99721 96 uint32_t OneBitSampling; /*!< Specifies wether a single sample or three samples' majority vote is selected.
bogdanm 85:024bf7f99721 97 Selecting the single sample method increases the receiver tolerance to clock
bogdanm 85:024bf7f99721 98 deviations. This parameter can be a value of @ref UART_OneBit_Sampling. */
bogdanm 85:024bf7f99721 99 }UART_InitTypeDef;
bogdanm 85:024bf7f99721 100
bogdanm 85:024bf7f99721 101 /**
bogdanm 85:024bf7f99721 102 * @brief UART Advanced Features initalization structure definition
bogdanm 85:024bf7f99721 103 */
bogdanm 85:024bf7f99721 104 typedef struct
bogdanm 85:024bf7f99721 105 {
bogdanm 85:024bf7f99721 106 uint32_t AdvFeatureInit; /*!< Specifies which advanced UART features is initialized. Several
bogdanm 85:024bf7f99721 107 Advanced Features may be initialized at the same time .
bogdanm 85:024bf7f99721 108 This parameter can be a value of @ref UART_Advanced_Features_Initialization_Type */
bogdanm 85:024bf7f99721 109
bogdanm 85:024bf7f99721 110 uint32_t TxPinLevelInvert; /*!< Specifies whether the TX pin active level is inverted.
bogdanm 85:024bf7f99721 111 This parameter can be a value of @ref UART_Tx_Inv */
bogdanm 85:024bf7f99721 112
bogdanm 85:024bf7f99721 113 uint32_t RxPinLevelInvert; /*!< Specifies whether the RX pin active level is inverted.
bogdanm 85:024bf7f99721 114 This parameter can be a value of @ref UART_Rx_Inv */
bogdanm 85:024bf7f99721 115
bogdanm 85:024bf7f99721 116 uint32_t DataInvert; /*!< Specifies whether data are inverted (positive/direct logic
bogdanm 85:024bf7f99721 117 vs negative/inverted logic).
bogdanm 85:024bf7f99721 118 This parameter can be a value of @ref UART_Data_Inv */
bogdanm 85:024bf7f99721 119
bogdanm 85:024bf7f99721 120 uint32_t Swap; /*!< Specifies whether TX and RX pins are swapped.
bogdanm 85:024bf7f99721 121 This parameter can be a value of @ref UART_Rx_Tx_Swap */
bogdanm 85:024bf7f99721 122
bogdanm 85:024bf7f99721 123 uint32_t OverrunDisable; /*!< Specifies whether the reception overrun detection is disabled.
bogdanm 85:024bf7f99721 124 This parameter can be a value of @ref UART_Overrun_Disable */
bogdanm 85:024bf7f99721 125
bogdanm 85:024bf7f99721 126 uint32_t DMADisableonRxError; /*!< Specifies whether the DMA is disabled in case of reception error.
bogdanm 85:024bf7f99721 127 This parameter can be a value of @ref UART_DMA_Disable_on_Rx_Error */
bogdanm 85:024bf7f99721 128
bogdanm 85:024bf7f99721 129 uint32_t AutoBaudRateEnable; /*!< Specifies whether auto Baud rate detection is enabled.
bogdanm 85:024bf7f99721 130 This parameter can be a value of @ref UART_AutoBaudRate_Enable */
bogdanm 85:024bf7f99721 131
bogdanm 85:024bf7f99721 132 uint32_t AutoBaudRateMode; /*!< If auto Baud rate detection is enabled, specifies how the rate
bogdanm 85:024bf7f99721 133 detection is carried out.
bogdanm 85:024bf7f99721 134 This parameter can be a value of @ref UARTEx_AutoBaud_Rate_Mode */
bogdanm 85:024bf7f99721 135
bogdanm 85:024bf7f99721 136 uint32_t MSBFirst; /*!< Specifies whether MSB is sent first on UART line.
bogdanm 85:024bf7f99721 137 This parameter can be a value of @ref UART_MSB_First */
bogdanm 85:024bf7f99721 138 } UART_AdvFeatureInitTypeDef;
bogdanm 85:024bf7f99721 139
bogdanm 85:024bf7f99721 140 /**
bogdanm 85:024bf7f99721 141 * @brief UART wake up from stop mode parameters
bogdanm 85:024bf7f99721 142 */
bogdanm 85:024bf7f99721 143 typedef struct
bogdanm 85:024bf7f99721 144 {
bogdanm 85:024bf7f99721 145 uint32_t WakeUpEvent; /*!< Specifies which event will activat the Wakeup from Stop mode flag (WUF).
bogdanm 85:024bf7f99721 146 This parameter can be a value of @ref UART_WakeUp_from_Stop_Selection.
bogdanm 85:024bf7f99721 147 If set to UART_WAKEUP_ON_ADDRESS, the two other fields below must
bogdanm 85:024bf7f99721 148 be filled up. */
bogdanm 85:024bf7f99721 149
bogdanm 85:024bf7f99721 150 uint16_t AddressLength; /*!< Specifies whether the address is 4 or 7-bit long.
bogdanm 85:024bf7f99721 151 This parameter can be a value of @ref UART_WakeUp_Address_Length */
bogdanm 85:024bf7f99721 152
bogdanm 85:024bf7f99721 153 uint8_t Address; /*!< UART/USART node address (7-bit long max) */
bogdanm 85:024bf7f99721 154 } UART_WakeUpTypeDef;
bogdanm 85:024bf7f99721 155
bogdanm 85:024bf7f99721 156 /**
bogdanm 85:024bf7f99721 157 * @brief HAL UART State structures definition
bogdanm 85:024bf7f99721 158 */
bogdanm 85:024bf7f99721 159 typedef enum
bogdanm 85:024bf7f99721 160 {
bogdanm 85:024bf7f99721 161 HAL_UART_STATE_RESET = 0x00, /*!< Peripheral is not initialized */
bogdanm 85:024bf7f99721 162 HAL_UART_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
bogdanm 85:024bf7f99721 163 HAL_UART_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
bogdanm 85:024bf7f99721 164 HAL_UART_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
bogdanm 85:024bf7f99721 165 HAL_UART_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
bogdanm 85:024bf7f99721 166 HAL_UART_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */
bogdanm 85:024bf7f99721 167 HAL_UART_STATE_TIMEOUT = 0x03, /*!< Timeout state */
bogdanm 85:024bf7f99721 168 HAL_UART_STATE_ERROR = 0x04 /*!< Error */
bogdanm 85:024bf7f99721 169 }HAL_UART_StateTypeDef;
bogdanm 85:024bf7f99721 170
bogdanm 85:024bf7f99721 171 /**
bogdanm 85:024bf7f99721 172 * @brief HAL UART Error Code structure definition
bogdanm 85:024bf7f99721 173 */
bogdanm 85:024bf7f99721 174 typedef enum
bogdanm 85:024bf7f99721 175 {
bogdanm 85:024bf7f99721 176 HAL_UART_ERROR_NONE = 0x00, /*!< No error */
bogdanm 85:024bf7f99721 177 HAL_UART_ERROR_PE = 0x01, /*!< Parity error */
bogdanm 85:024bf7f99721 178 HAL_UART_ERROR_NE = 0x02, /*!< Noise error */
bogdanm 85:024bf7f99721 179 HAL_UART_ERROR_FE = 0x04, /*!< frame error */
bogdanm 85:024bf7f99721 180 HAL_UART_ERROR_ORE = 0x08, /*!< Overrun error */
bogdanm 85:024bf7f99721 181 HAL_UART_ERROR_DMA = 0x10 /*!< DMA transfer error */
bogdanm 85:024bf7f99721 182 }HAL_UART_ErrorTypeDef;
bogdanm 85:024bf7f99721 183
bogdanm 85:024bf7f99721 184 /**
bogdanm 85:024bf7f99721 185 * @brief UART clock sources definition
bogdanm 85:024bf7f99721 186 */
bogdanm 85:024bf7f99721 187 typedef enum
bogdanm 85:024bf7f99721 188 {
bogdanm 85:024bf7f99721 189 UART_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */
bogdanm 85:024bf7f99721 190 UART_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */
bogdanm 85:024bf7f99721 191 UART_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */
bogdanm 85:024bf7f99721 192 UART_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */
bogdanm 85:024bf7f99721 193 UART_CLOCKSOURCE_UNDEFINED = 0x10 /*!< undefined clock source */
bogdanm 85:024bf7f99721 194 }UART_ClockSourceTypeDef;
bogdanm 85:024bf7f99721 195
bogdanm 85:024bf7f99721 196 /**
bogdanm 85:024bf7f99721 197 * @brief UART handle Structure definition
bogdanm 85:024bf7f99721 198 */
bogdanm 85:024bf7f99721 199 typedef struct
bogdanm 85:024bf7f99721 200 {
bogdanm 85:024bf7f99721 201 USART_TypeDef *Instance; /* UART registers base address */
bogdanm 85:024bf7f99721 202
bogdanm 85:024bf7f99721 203 UART_InitTypeDef Init; /* UART communication parameters */
bogdanm 85:024bf7f99721 204
bogdanm 85:024bf7f99721 205 UART_AdvFeatureInitTypeDef AdvancedInit; /* UART Advanced Features initialization parameters */
bogdanm 85:024bf7f99721 206
bogdanm 85:024bf7f99721 207 uint8_t *pTxBuffPtr; /* Pointer to UART Tx transfer Buffer */
bogdanm 85:024bf7f99721 208
bogdanm 85:024bf7f99721 209 uint16_t TxXferSize; /* UART Tx Transfer size */
bogdanm 85:024bf7f99721 210
bogdanm 85:024bf7f99721 211 uint16_t TxXferCount; /* UART Tx Transfer Counter */
bogdanm 85:024bf7f99721 212
bogdanm 85:024bf7f99721 213 uint8_t *pRxBuffPtr; /* Pointer to UART Rx transfer Buffer */
bogdanm 85:024bf7f99721 214
bogdanm 85:024bf7f99721 215 uint16_t RxXferSize; /* UART Rx Transfer size */
bogdanm 85:024bf7f99721 216
bogdanm 85:024bf7f99721 217 uint16_t RxXferCount; /* UART Rx Transfer Counter */
bogdanm 85:024bf7f99721 218
bogdanm 85:024bf7f99721 219 uint16_t Mask; /* UART Rx RDR register mask */
bogdanm 85:024bf7f99721 220
bogdanm 85:024bf7f99721 221 DMA_HandleTypeDef *hdmatx; /* UART Tx DMA Handle parameters */
bogdanm 85:024bf7f99721 222
bogdanm 85:024bf7f99721 223 DMA_HandleTypeDef *hdmarx; /* UART Rx DMA Handle parameters */
bogdanm 85:024bf7f99721 224
bogdanm 85:024bf7f99721 225 HAL_LockTypeDef Lock; /* Locking object */
bogdanm 85:024bf7f99721 226
bogdanm 85:024bf7f99721 227 HAL_UART_StateTypeDef State; /* UART communication state */
bogdanm 85:024bf7f99721 228
bogdanm 85:024bf7f99721 229 HAL_UART_ErrorTypeDef ErrorCode; /* UART Error code */
bogdanm 85:024bf7f99721 230
bogdanm 85:024bf7f99721 231 }UART_HandleTypeDef;
bogdanm 85:024bf7f99721 232
bogdanm 85:024bf7f99721 233
bogdanm 85:024bf7f99721 234 /* Exported constants --------------------------------------------------------*/
bogdanm 85:024bf7f99721 235 /** @defgroup UART_Exported_Constants
bogdanm 85:024bf7f99721 236 * @{
bogdanm 85:024bf7f99721 237 */
bogdanm 85:024bf7f99721 238
bogdanm 85:024bf7f99721 239 /** @defgroup UART_Stop_Bits UART Number of Stop Bits
bogdanm 85:024bf7f99721 240 * @{
bogdanm 85:024bf7f99721 241 */
bogdanm 85:024bf7f99721 242 #define UART_STOPBITS_1 ((uint32_t)0x0000)
bogdanm 85:024bf7f99721 243 #define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1)
bogdanm 85:024bf7f99721 244 #define IS_UART_STOPBITS(STOPBITS) (((STOPBITS) == UART_STOPBITS_1) || \
bogdanm 85:024bf7f99721 245 ((STOPBITS) == UART_STOPBITS_2))
bogdanm 85:024bf7f99721 246 /**
bogdanm 85:024bf7f99721 247 * @}
bogdanm 85:024bf7f99721 248 */
bogdanm 85:024bf7f99721 249
bogdanm 85:024bf7f99721 250 /** @defgroup UART_Parity UART Parity
bogdanm 85:024bf7f99721 251 * @{
bogdanm 85:024bf7f99721 252 */
bogdanm 85:024bf7f99721 253 #define UART_PARITY_NONE ((uint32_t)0x0000)
bogdanm 85:024bf7f99721 254 #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
bogdanm 85:024bf7f99721 255 #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
bogdanm 85:024bf7f99721 256 #define IS_UART_PARITY(PARITY) (((PARITY) == UART_PARITY_NONE) || \
bogdanm 85:024bf7f99721 257 ((PARITY) == UART_PARITY_EVEN) || \
bogdanm 85:024bf7f99721 258 ((PARITY) == UART_PARITY_ODD))
bogdanm 85:024bf7f99721 259 /**
bogdanm 85:024bf7f99721 260 * @}
bogdanm 85:024bf7f99721 261 */
bogdanm 85:024bf7f99721 262
bogdanm 85:024bf7f99721 263 /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
bogdanm 85:024bf7f99721 264 * @{
bogdanm 85:024bf7f99721 265 */
bogdanm 85:024bf7f99721 266 #define UART_HWCONTROL_NONE ((uint32_t)0x0000)
bogdanm 85:024bf7f99721 267 #define UART_HWCONTROL_RTS ((uint32_t)USART_CR3_RTSE)
bogdanm 85:024bf7f99721 268 #define UART_HWCONTROL_CTS ((uint32_t)USART_CR3_CTSE)
bogdanm 85:024bf7f99721 269 #define UART_HWCONTROL_RTS_CTS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE))
bogdanm 85:024bf7f99721 270 #define IS_UART_HARDWARE_FLOW_CONTROL(CONTROL)\
bogdanm 85:024bf7f99721 271 (((CONTROL) == UART_HWCONTROL_NONE) || \
bogdanm 85:024bf7f99721 272 ((CONTROL) == UART_HWCONTROL_RTS) || \
bogdanm 85:024bf7f99721 273 ((CONTROL) == UART_HWCONTROL_CTS) || \
bogdanm 85:024bf7f99721 274 ((CONTROL) == UART_HWCONTROL_RTS_CTS))
bogdanm 85:024bf7f99721 275 /**
bogdanm 85:024bf7f99721 276 * @}
bogdanm 85:024bf7f99721 277 */
bogdanm 85:024bf7f99721 278
bogdanm 85:024bf7f99721 279 /** @defgroup UART_Mode UART Transfer Mode
bogdanm 85:024bf7f99721 280 * @{
bogdanm 85:024bf7f99721 281 */
bogdanm 85:024bf7f99721 282 #define UART_MODE_RX ((uint32_t)USART_CR1_RE)
bogdanm 85:024bf7f99721 283 #define UART_MODE_TX ((uint32_t)USART_CR1_TE)
bogdanm 85:024bf7f99721 284 #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
bogdanm 85:024bf7f99721 285 #define IS_UART_MODE(MODE) ((((MODE) & (~((uint32_t)(UART_MODE_TX_RX)))) == (uint32_t)0x00) && ((MODE) != (uint32_t)0x00))
bogdanm 85:024bf7f99721 286 /**
bogdanm 85:024bf7f99721 287 * @}
bogdanm 85:024bf7f99721 288 */
bogdanm 85:024bf7f99721 289
bogdanm 85:024bf7f99721 290 /** @defgroup UART_State UART State
bogdanm 85:024bf7f99721 291 * @{
bogdanm 85:024bf7f99721 292 */
bogdanm 85:024bf7f99721 293 #define UART_STATE_DISABLE ((uint32_t)0x0000)
bogdanm 85:024bf7f99721 294 #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE)
bogdanm 85:024bf7f99721 295 #define IS_UART_STATE(STATE) (((STATE) == UART_STATE_DISABLE) || \
bogdanm 85:024bf7f99721 296 ((STATE) == UART_STATE_ENABLE))
bogdanm 85:024bf7f99721 297 /**
bogdanm 85:024bf7f99721 298 * @}
bogdanm 85:024bf7f99721 299 */
bogdanm 85:024bf7f99721 300
bogdanm 85:024bf7f99721 301 /** @defgroup UART_Over_Sampling UART Over Sampling
bogdanm 85:024bf7f99721 302 * @{
bogdanm 85:024bf7f99721 303 */
bogdanm 85:024bf7f99721 304 #define UART_OVERSAMPLING_16 ((uint32_t)0x0000)
bogdanm 85:024bf7f99721 305 #define UART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8)
bogdanm 85:024bf7f99721 306 #define IS_UART_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16) || \
bogdanm 85:024bf7f99721 307 ((SAMPLING) == UART_OVERSAMPLING_8))
bogdanm 85:024bf7f99721 308 /**
bogdanm 85:024bf7f99721 309 * @}
bogdanm 85:024bf7f99721 310 */
bogdanm 85:024bf7f99721 311
bogdanm 85:024bf7f99721 312 /** @defgroup UART_OneBit_Sampling UART One Bit Sampling Method
bogdanm 85:024bf7f99721 313 * @{
bogdanm 85:024bf7f99721 314 */
bogdanm 85:024bf7f99721 315 #define UART_ONEBIT_SAMPLING_DISABLED ((uint32_t)0x0000)
bogdanm 85:024bf7f99721 316 #define UART_ONEBIT_SAMPLING_ENABLED ((uint32_t)USART_CR3_ONEBIT)
bogdanm 85:024bf7f99721 317 #define IS_UART_ONEBIT_SAMPLING(ONEBIT) (((ONEBIT) == UART_ONEBIT_SAMPLING_DISABLED) || \
bogdanm 85:024bf7f99721 318 ((ONEBIT) == UART_ONEBIT_SAMPLING_ENABLED))
bogdanm 85:024bf7f99721 319 /**
bogdanm 85:024bf7f99721 320 * @}
bogdanm 85:024bf7f99721 321 */
bogdanm 85:024bf7f99721 322
bogdanm 85:024bf7f99721 323
bogdanm 85:024bf7f99721 324 /** @defgroup UART_Receiver_TimeOut UART Receiver TimeOut
bogdanm 85:024bf7f99721 325 * @{
bogdanm 85:024bf7f99721 326 */
bogdanm 85:024bf7f99721 327 #define UART_RECEIVER_TIMEOUT_DISABLE ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 328 #define UART_RECEIVER_TIMEOUT_ENABLE ((uint32_t)USART_CR2_RTOEN)
bogdanm 85:024bf7f99721 329 #define IS_UART_RECEIVER_TIMEOUT(TIMEOUT) (((TIMEOUT) == UART_RECEIVER_TIMEOUT_DISABLE) || \
bogdanm 85:024bf7f99721 330 ((TIMEOUT) == UART_RECEIVER_TIMEOUT_ENABLE))
bogdanm 85:024bf7f99721 331 /**
bogdanm 85:024bf7f99721 332 * @}
bogdanm 85:024bf7f99721 333 */
bogdanm 85:024bf7f99721 334
bogdanm 85:024bf7f99721 335 /** @defgroup UART_One_Bit UART One Bit sampling
bogdanm 85:024bf7f99721 336 * @{
bogdanm 85:024bf7f99721 337 */
bogdanm 85:024bf7f99721 338 #define UART_ONE_BIT_SAMPLE_DISABLED ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 339 #define UART_ONE_BIT_SAMPLE_ENABLED ((uint32_t)USART_CR3_ONEBIT)
bogdanm 85:024bf7f99721 340 #define IS_UART_ONEBIT_SAMPLE(ONEBIT) (((ONEBIT) == UART_ONE_BIT_SAMPLE_DISABLED) || \
bogdanm 85:024bf7f99721 341 ((ONEBIT) == UART_ONE_BIT_SAMPLE_ENABLED))
bogdanm 85:024bf7f99721 342 /**
bogdanm 85:024bf7f99721 343 * @}
bogdanm 85:024bf7f99721 344 */
bogdanm 85:024bf7f99721 345
bogdanm 85:024bf7f99721 346 /** @defgroup UART_DMA_Tx UART DMA Tx
bogdanm 85:024bf7f99721 347 * @{
bogdanm 85:024bf7f99721 348 */
bogdanm 85:024bf7f99721 349 #define UART_DMA_TX_DISABLE ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 350 #define UART_DMA_TX_ENABLE ((uint32_t)USART_CR3_DMAT)
bogdanm 85:024bf7f99721 351 #define IS_UART_DMA_TX(DMATX) (((DMATX) == UART_DMA_TX_DISABLE) || \
bogdanm 85:024bf7f99721 352 ((DMATX) == UART_DMA_TX_ENABLE))
bogdanm 85:024bf7f99721 353 /**
bogdanm 85:024bf7f99721 354 * @}
bogdanm 85:024bf7f99721 355 */
bogdanm 85:024bf7f99721 356
bogdanm 85:024bf7f99721 357 /** @defgroup UART_DMA_Rx UART DMA Rx
bogdanm 85:024bf7f99721 358 * @{
bogdanm 85:024bf7f99721 359 */
bogdanm 85:024bf7f99721 360 #define UART_DMA_RX_DISABLE ((uint32_t)0x0000)
bogdanm 85:024bf7f99721 361 #define UART_DMA_RX_ENABLE ((uint32_t)USART_CR3_DMAR)
bogdanm 85:024bf7f99721 362 #define IS_UART_DMA_RX(DMARX) (((DMARX) == UART_DMA_RX_DISABLE) || \
bogdanm 85:024bf7f99721 363 ((DMARX) == UART_DMA_RX_ENABLE))
bogdanm 85:024bf7f99721 364 /**
bogdanm 85:024bf7f99721 365 * @}
bogdanm 85:024bf7f99721 366 */
bogdanm 85:024bf7f99721 367
bogdanm 85:024bf7f99721 368 /** @defgroup UART_Half_Duplex_Selection UART Half Duplex Selection
bogdanm 85:024bf7f99721 369 * @{
bogdanm 85:024bf7f99721 370 */
bogdanm 85:024bf7f99721 371 #define UART_HALF_DUPLEX_DISABLE ((uint32_t)0x0000)
bogdanm 85:024bf7f99721 372 #define UART_HALF_DUPLEX_ENABLE ((uint32_t)USART_CR3_HDSEL)
bogdanm 85:024bf7f99721 373 #define IS_UART_HALF_DUPLEX(HDSEL) (((HDSEL) == UART_HALF_DUPLEX_DISABLE) || \
bogdanm 85:024bf7f99721 374 ((HDSEL) == UART_HALF_DUPLEX_ENABLE))
bogdanm 85:024bf7f99721 375 /**
bogdanm 85:024bf7f99721 376 * @}
bogdanm 85:024bf7f99721 377 */
bogdanm 85:024bf7f99721 378
bogdanm 85:024bf7f99721 379 /** @defgroup UART_WakeUp_Address_Length UART WakeUp Address Length
bogdanm 85:024bf7f99721 380 * @{
bogdanm 85:024bf7f99721 381 */
bogdanm 85:024bf7f99721 382 #define UART_ADDRESS_DETECT_4B ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 383 #define UART_ADDRESS_DETECT_7B ((uint32_t)USART_CR2_ADDM7)
bogdanm 85:024bf7f99721 384 #define IS_UART_ADDRESSLENGTH_DETECT(ADDRESS) (((ADDRESS) == UART_ADDRESS_DETECT_4B) || \
bogdanm 85:024bf7f99721 385 ((ADDRESS) == UART_ADDRESS_DETECT_7B))
bogdanm 85:024bf7f99721 386 /**
bogdanm 85:024bf7f99721 387 * @}
bogdanm 85:024bf7f99721 388 */
bogdanm 85:024bf7f99721 389
bogdanm 85:024bf7f99721 390 /** @defgroup UART_WakeUp_Methods UART WakeUp Methods
bogdanm 85:024bf7f99721 391 * @{
bogdanm 85:024bf7f99721 392 */
bogdanm 85:024bf7f99721 393 #define UART_WAKEUPMETHOD_IDLELINE ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 394 #define UART_WAKEUPMETHOD_ADDRESSMARK ((uint32_t)USART_CR1_WAKE)
bogdanm 85:024bf7f99721 395 #define IS_UART_WAKEUPMETHOD(WAKEUP) (((WAKEUP) == UART_WAKEUPMETHOD_IDLELINE) || \
bogdanm 85:024bf7f99721 396 ((WAKEUP) == UART_WAKEUPMETHOD_ADDRESSMARK))
bogdanm 85:024bf7f99721 397 /**
bogdanm 85:024bf7f99721 398 * @}
bogdanm 85:024bf7f99721 399 */
bogdanm 85:024bf7f99721 400
bogdanm 85:024bf7f99721 401 /** Elements values convention: 000000000XXYYYYYb
bogdanm 85:024bf7f99721 402 * - YYYYY : Interrupt source position in the XX register (5bits)
bogdanm 85:024bf7f99721 403 * - XX : Interrupt source register (2bits)
bogdanm 85:024bf7f99721 404 * - 01: CR1 register
bogdanm 85:024bf7f99721 405 * - 10: CR2 register
bogdanm 85:024bf7f99721 406 * - 11: CR3 register
bogdanm 85:024bf7f99721 407 */
bogdanm 85:024bf7f99721 408 #define UART_IT_ERR ((uint16_t)0x0060)
bogdanm 85:024bf7f99721 409
bogdanm 85:024bf7f99721 410 /** Elements values convention: 0000ZZZZ00000000b
bogdanm 85:024bf7f99721 411 * - ZZZZ : Flag position in the ISR register(4bits)
bogdanm 85:024bf7f99721 412 */
bogdanm 85:024bf7f99721 413 #define UART_IT_ORE ((uint16_t)0x0300)
bogdanm 85:024bf7f99721 414 #define UART_IT_NE ((uint16_t)0x0200)
bogdanm 85:024bf7f99721 415 #define UART_IT_FE ((uint16_t)0x0100)
bogdanm 85:024bf7f99721 416
bogdanm 85:024bf7f99721 417 /** @defgroup UART_Advanced_Features_Initialization_Type UART Advanced Feature Initialization Type
bogdanm 85:024bf7f99721 418 * @{
bogdanm 85:024bf7f99721 419 */
bogdanm 85:024bf7f99721 420 #define UART_ADVFEATURE_NO_INIT ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 421 #define UART_ADVFEATURE_TXINVERT_INIT ((uint32_t)0x00000001)
bogdanm 85:024bf7f99721 422 #define UART_ADVFEATURE_RXINVERT_INIT ((uint32_t)0x00000002)
bogdanm 85:024bf7f99721 423 #define UART_ADVFEATURE_DATAINVERT_INIT ((uint32_t)0x00000004)
bogdanm 85:024bf7f99721 424 #define UART_ADVFEATURE_SWAP_INIT ((uint32_t)0x00000008)
bogdanm 85:024bf7f99721 425 #define UART_ADVFEATURE_RXOVERRUNDISABLE_INIT ((uint32_t)0x00000010)
bogdanm 85:024bf7f99721 426 #define UART_ADVFEATURE_DMADISABLEONERROR_INIT ((uint32_t)0x00000020)
bogdanm 85:024bf7f99721 427 #define UART_ADVFEATURE_AUTOBAUDRATE_INIT ((uint32_t)0x00000040)
bogdanm 85:024bf7f99721 428 #define UART_ADVFEATURE_MSBFIRST_INIT ((uint32_t)0x00000080)
bogdanm 85:024bf7f99721 429 #define IS_UART_ADVFEATURE_INIT(INIT) ((INIT) <= (UART_ADVFEATURE_NO_INIT | \
bogdanm 85:024bf7f99721 430 UART_ADVFEATURE_TXINVERT_INIT | \
bogdanm 85:024bf7f99721 431 UART_ADVFEATURE_RXINVERT_INIT | \
bogdanm 85:024bf7f99721 432 UART_ADVFEATURE_DATAINVERT_INIT | \
bogdanm 85:024bf7f99721 433 UART_ADVFEATURE_SWAP_INIT | \
bogdanm 85:024bf7f99721 434 UART_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
bogdanm 85:024bf7f99721 435 UART_ADVFEATURE_DMADISABLEONERROR_INIT | \
bogdanm 85:024bf7f99721 436 UART_ADVFEATURE_AUTOBAUDRATE_INIT | \
bogdanm 85:024bf7f99721 437 UART_ADVFEATURE_MSBFIRST_INIT))
bogdanm 85:024bf7f99721 438 /**
bogdanm 85:024bf7f99721 439 * @}
bogdanm 85:024bf7f99721 440 */
bogdanm 85:024bf7f99721 441
bogdanm 85:024bf7f99721 442 /** @defgroup UART_Tx_Inv UART Advanced Feature TX Pin Active Level Inversion
bogdanm 85:024bf7f99721 443 * @{
bogdanm 85:024bf7f99721 444 */
bogdanm 85:024bf7f99721 445 #define UART_ADVFEATURE_TXINV_DISABLE ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 446 #define UART_ADVFEATURE_TXINV_ENABLE ((uint32_t)USART_CR2_TXINV)
bogdanm 85:024bf7f99721 447 #define IS_UART_ADVFEATURE_TXINV(TXINV) (((TXINV) == UART_ADVFEATURE_TXINV_DISABLE) || \
bogdanm 85:024bf7f99721 448 ((TXINV) == UART_ADVFEATURE_TXINV_ENABLE))
bogdanm 85:024bf7f99721 449 /**
bogdanm 85:024bf7f99721 450 * @}
bogdanm 85:024bf7f99721 451 */
bogdanm 85:024bf7f99721 452
bogdanm 85:024bf7f99721 453 /** @defgroup UART_Rx_Inv UART Advanced Feature RX Pin Active Level Inversion
bogdanm 85:024bf7f99721 454 * @{
bogdanm 85:024bf7f99721 455 */
bogdanm 85:024bf7f99721 456 #define UART_ADVFEATURE_RXINV_DISABLE ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 457 #define UART_ADVFEATURE_RXINV_ENABLE ((uint32_t)USART_CR2_RXINV)
bogdanm 85:024bf7f99721 458 #define IS_UART_ADVFEATURE_RXINV(RXINV) (((RXINV) == UART_ADVFEATURE_RXINV_DISABLE) || \
bogdanm 85:024bf7f99721 459 ((RXINV) == UART_ADVFEATURE_RXINV_ENABLE))
bogdanm 85:024bf7f99721 460 /**
bogdanm 85:024bf7f99721 461 * @}
bogdanm 85:024bf7f99721 462 */
bogdanm 85:024bf7f99721 463
bogdanm 85:024bf7f99721 464 /** @defgroup UART_Data_Inv UART Advanced Feature Binary Data Inversion
bogdanm 85:024bf7f99721 465 * @{
bogdanm 85:024bf7f99721 466 */
bogdanm 85:024bf7f99721 467 #define UART_ADVFEATURE_DATAINV_DISABLE ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 468 #define UART_ADVFEATURE_DATAINV_ENABLE ((uint32_t)USART_CR2_DATAINV)
bogdanm 85:024bf7f99721 469 #define IS_UART_ADVFEATURE_DATAINV(DATAINV) (((DATAINV) == UART_ADVFEATURE_DATAINV_DISABLE) || \
bogdanm 85:024bf7f99721 470 ((DATAINV) == UART_ADVFEATURE_DATAINV_ENABLE))
bogdanm 85:024bf7f99721 471 /**
bogdanm 85:024bf7f99721 472 * @}
bogdanm 85:024bf7f99721 473 */
bogdanm 85:024bf7f99721 474
bogdanm 85:024bf7f99721 475 /** @defgroup UART_Rx_Tx_Swap UART Advanced Feature RX TX Pins Swap
bogdanm 85:024bf7f99721 476 * @{
bogdanm 85:024bf7f99721 477 */
bogdanm 85:024bf7f99721 478 #define UART_ADVFEATURE_SWAP_DISABLE ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 479 #define UART_ADVFEATURE_SWAP_ENABLE ((uint32_t)USART_CR2_SWAP)
bogdanm 85:024bf7f99721 480 #define IS_UART_ADVFEATURE_SWAP(SWAP) (((SWAP) == UART_ADVFEATURE_SWAP_DISABLE) || \
bogdanm 85:024bf7f99721 481 ((SWAP) == UART_ADVFEATURE_SWAP_ENABLE))
bogdanm 85:024bf7f99721 482 /**
bogdanm 85:024bf7f99721 483 * @}
bogdanm 85:024bf7f99721 484 */
bogdanm 85:024bf7f99721 485
bogdanm 85:024bf7f99721 486 /** @defgroup UART_Overrun_Disable UART Advanced Feature Overrun Disable
bogdanm 85:024bf7f99721 487 * @{
bogdanm 85:024bf7f99721 488 */
bogdanm 85:024bf7f99721 489 #define UART_ADVFEATURE_OVERRUN_ENABLE ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 490 #define UART_ADVFEATURE_OVERRUN_DISABLE ((uint32_t)USART_CR3_OVRDIS)
bogdanm 85:024bf7f99721 491 #define IS_UART_OVERRUN(OVERRUN) (((OVERRUN) == UART_ADVFEATURE_OVERRUN_ENABLE) || \
bogdanm 85:024bf7f99721 492 ((OVERRUN) == UART_ADVFEATURE_OVERRUN_DISABLE))
bogdanm 85:024bf7f99721 493 /**
bogdanm 85:024bf7f99721 494 * @}
bogdanm 85:024bf7f99721 495 */
bogdanm 85:024bf7f99721 496
bogdanm 85:024bf7f99721 497 /** @defgroup UART_AutoBaudRate_Enable UART Advanced Feature Auto BaudRate Enable
bogdanm 85:024bf7f99721 498 * @{
bogdanm 85:024bf7f99721 499 */
bogdanm 85:024bf7f99721 500 #define UART_ADVFEATURE_AUTOBAUDRATE_DISABLE ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 501 #define UART_ADVFEATURE_AUTOBAUDRATE_ENABLE ((uint32_t)USART_CR2_ABREN)
bogdanm 85:024bf7f99721 502 #define IS_UART_ADVFEATURE_AUTOBAUDRATE(AUTOBAUDRATE) (((AUTOBAUDRATE) == UART_ADVFEATURE_AUTOBAUDRATE_DISABLE) || \
bogdanm 85:024bf7f99721 503 ((AUTOBAUDRATE) == UART_ADVFEATURE_AUTOBAUDRATE_ENABLE))
bogdanm 85:024bf7f99721 504 /**
bogdanm 85:024bf7f99721 505 * @}
bogdanm 85:024bf7f99721 506 */
bogdanm 85:024bf7f99721 507
bogdanm 85:024bf7f99721 508 /** @defgroup UART_DMA_Disable_on_Rx_Error UART Advanced Feature DMA Disable On Rx Error
bogdanm 85:024bf7f99721 509 * @{
bogdanm 85:024bf7f99721 510 */
bogdanm 85:024bf7f99721 511 #define UART_ADVFEATURE_DMA_ENABLEONRXERROR ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 512 #define UART_ADVFEATURE_DMA_DISABLEONRXERROR ((uint32_t)USART_CR3_DDRE)
bogdanm 85:024bf7f99721 513 #define IS_UART_ADVFEATURE_DMAONRXERROR(DMA) (((DMA) == UART_ADVFEATURE_DMA_ENABLEONRXERROR) || \
bogdanm 85:024bf7f99721 514 ((DMA) == UART_ADVFEATURE_DMA_DISABLEONRXERROR))
bogdanm 85:024bf7f99721 515 /**
bogdanm 85:024bf7f99721 516 * @}
bogdanm 85:024bf7f99721 517 */
bogdanm 85:024bf7f99721 518
bogdanm 85:024bf7f99721 519 /** @defgroup UART_MSB_First UART Advanced Feature MSB First
bogdanm 85:024bf7f99721 520 * @{
bogdanm 85:024bf7f99721 521 */
bogdanm 85:024bf7f99721 522 #define UART_ADVFEATURE_MSBFIRST_DISABLE ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 523 #define UART_ADVFEATURE_MSBFIRST_ENABLE ((uint32_t)USART_CR2_MSBFIRST)
bogdanm 85:024bf7f99721 524 #define IS_UART_ADVFEATURE_MSBFIRST(MSBFIRST) (((MSBFIRST) == UART_ADVFEATURE_MSBFIRST_DISABLE) || \
bogdanm 85:024bf7f99721 525 ((MSBFIRST) == UART_ADVFEATURE_MSBFIRST_ENABLE))
bogdanm 85:024bf7f99721 526 /**
bogdanm 85:024bf7f99721 527 * @}
bogdanm 85:024bf7f99721 528 */
bogdanm 85:024bf7f99721 529
bogdanm 85:024bf7f99721 530 /** @defgroup UART_Mute_Mode UART Advanced Feature Mute Mode Enable
bogdanm 85:024bf7f99721 531 * @{
bogdanm 85:024bf7f99721 532 */
bogdanm 85:024bf7f99721 533 #define UART_ADVFEATURE_MUTEMODE_DISABLE ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 534 #define UART_ADVFEATURE_MUTEMODE_ENABLE ((uint32_t)USART_CR1_MME)
bogdanm 85:024bf7f99721 535 #define IS_UART_MUTE_MODE(MUTE) (((MUTE) == UART_ADVFEATURE_MUTEMODE_DISABLE) || \
bogdanm 85:024bf7f99721 536 ((MUTE) == UART_ADVFEATURE_MUTEMODE_ENABLE))
bogdanm 85:024bf7f99721 537 /**
bogdanm 85:024bf7f99721 538 * @}
bogdanm 85:024bf7f99721 539 */
bogdanm 85:024bf7f99721 540
bogdanm 85:024bf7f99721 541 /** @defgroup UART_CR2_ADDRESS_LSB_POS UART Address-matching LSB Position In CR2 Register
bogdanm 85:024bf7f99721 542 * @{
bogdanm 85:024bf7f99721 543 */
bogdanm 85:024bf7f99721 544 #define UART_CR2_ADDRESS_LSB_POS ((uint32_t) 24)
bogdanm 85:024bf7f99721 545 /**
bogdanm 85:024bf7f99721 546 * @}
bogdanm 85:024bf7f99721 547 */
bogdanm 85:024bf7f99721 548
bogdanm 85:024bf7f99721 549 /** @defgroup UART_DriverEnable_Polarity UART DriverEnable Polarity
bogdanm 85:024bf7f99721 550 * @{
bogdanm 85:024bf7f99721 551 */
bogdanm 85:024bf7f99721 552 #define UART_DE_POLARITY_HIGH ((uint32_t)0x00000000)
bogdanm 85:024bf7f99721 553 #define UART_DE_POLARITY_LOW ((uint32_t)USART_CR3_DEP)
bogdanm 85:024bf7f99721 554 #define IS_UART_DE_POLARITY(POLARITY) (((POLARITY) == UART_DE_POLARITY_HIGH) || \
bogdanm 85:024bf7f99721 555 ((POLARITY) == UART_DE_POLARITY_LOW))
bogdanm 85:024bf7f99721 556 /**
bogdanm 85:024bf7f99721 557 * @}
bogdanm 85:024bf7f99721 558 */
bogdanm 85:024bf7f99721 559
bogdanm 85:024bf7f99721 560 /** @defgroup UART_CR1_DEAT_ADDRESS_LSB_POS UART Driver Enable Assertion Time LSB Position In CR1 Register
bogdanm 85:024bf7f99721 561 * @{
bogdanm 85:024bf7f99721 562 */
bogdanm 85:024bf7f99721 563 #define UART_CR1_DEAT_ADDRESS_LSB_POS ((uint32_t) 21)
bogdanm 85:024bf7f99721 564 /**
bogdanm 85:024bf7f99721 565 * @}
bogdanm 85:024bf7f99721 566 */
bogdanm 85:024bf7f99721 567
bogdanm 85:024bf7f99721 568 /** @defgroup UART_CR1_DEDT_ADDRESS_LSB_POS UART Driver Enable DeAssertion Time LSB Position In CR1 Register
bogdanm 85:024bf7f99721 569 * @{
bogdanm 85:024bf7f99721 570 */
bogdanm 85:024bf7f99721 571 #define UART_CR1_DEDT_ADDRESS_LSB_POS ((uint32_t) 16)
bogdanm 85:024bf7f99721 572 /**
bogdanm 85:024bf7f99721 573 * @}
bogdanm 85:024bf7f99721 574 */
bogdanm 85:024bf7f99721 575
bogdanm 85:024bf7f99721 576 /** @defgroup UART_Interruption_Mask UART Interruptions Flag Mask
bogdanm 85:024bf7f99721 577 * @{
bogdanm 85:024bf7f99721 578 */
bogdanm 85:024bf7f99721 579 #define UART_IT_MASK ((uint32_t)0x001F)
bogdanm 85:024bf7f99721 580 /**
bogdanm 85:024bf7f99721 581 * @}
bogdanm 85:024bf7f99721 582 */
bogdanm 85:024bf7f99721 583
bogdanm 85:024bf7f99721 584 /** @defgroup UART_TimeOut_Value UART polling-based communications time-out value
bogdanm 85:024bf7f99721 585 * @{
bogdanm 85:024bf7f99721 586 */
bogdanm 85:024bf7f99721 587 #define HAL_UART_TIMEOUT_VALUE 0x1FFFFFF
bogdanm 85:024bf7f99721 588 /**
bogdanm 85:024bf7f99721 589 * @}
bogdanm 85:024bf7f99721 590 */
bogdanm 85:024bf7f99721 591
bogdanm 85:024bf7f99721 592 /**
bogdanm 85:024bf7f99721 593 * @}
bogdanm 85:024bf7f99721 594 */
bogdanm 85:024bf7f99721 595
bogdanm 85:024bf7f99721 596 /* Exported macros -----------------------------------------------------------*/
bogdanm 85:024bf7f99721 597 /** @defgroup UART_Exported_Macros
bogdanm 85:024bf7f99721 598 * @{
bogdanm 85:024bf7f99721 599 */
bogdanm 85:024bf7f99721 600
bogdanm 85:024bf7f99721 601 /** @brief Reset UART handle state
bogdanm 85:024bf7f99721 602 * @param __HANDLE__: UART handle.
bogdanm 85:024bf7f99721 603 * @retval None
bogdanm 85:024bf7f99721 604 */
bogdanm 85:024bf7f99721 605 #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_UART_STATE_RESET)
bogdanm 85:024bf7f99721 606
bogdanm 85:024bf7f99721 607 /** @brief Checks whether the specified UART flag is set or not.
bogdanm 85:024bf7f99721 608 * @param __HANDLE__: specifies the UART Handle.
bogdanm 85:024bf7f99721 609 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
bogdanm 85:024bf7f99721 610 * UART peripheral (datasheet: up to four USART/UARTs)
bogdanm 85:024bf7f99721 611 * @param __FLAG__: specifies the flag to check.
bogdanm 85:024bf7f99721 612 * This parameter can be one of the following values:
bogdanm 85:024bf7f99721 613 * @arg UART_FLAG_REACK: Receive enable ackowledge flag
bogdanm 85:024bf7f99721 614 * @arg UART_FLAG_TEACK: Transmit enable ackowledge flag
bogdanm 85:024bf7f99721 615 * @arg UART_FLAG_WUF: Wake up from stop mode flag (not available on F030xx devices)
bogdanm 85:024bf7f99721 616 * @arg UART_FLAG_RWU: Receiver wake up flag (not available on F030xx devices)
bogdanm 85:024bf7f99721 617 * @arg UART_FLAG_SBKF: Send Break flag
bogdanm 85:024bf7f99721 618 * @arg UART_FLAG_CMF: Character match flag
bogdanm 85:024bf7f99721 619 * @arg UART_FLAG_BUSY: Busy flag
bogdanm 85:024bf7f99721 620 * @arg UART_FLAG_ABRF: Auto Baud rate detection flag
bogdanm 85:024bf7f99721 621 * @arg UART_FLAG_ABRE: Auto Baud rate detection error flag
bogdanm 85:024bf7f99721 622 * @arg UART_FLAG_EOBF: End of block flag (not available on F030xx devices)
bogdanm 85:024bf7f99721 623 * @arg UART_FLAG_RTOF: Receiver timeout flag
bogdanm 85:024bf7f99721 624 * @arg UART_FLAG_CTS: CTS Change flag
bogdanm 85:024bf7f99721 625 * @arg UART_FLAG_LBD: LIN Break detection flag (not available on F030xx devices)
bogdanm 85:024bf7f99721 626 * @arg UART_FLAG_TXE: Transmit data register empty flag
bogdanm 85:024bf7f99721 627 * @arg UART_FLAG_TC: Transmission Complete flag
bogdanm 85:024bf7f99721 628 * @arg UART_FLAG_RXNE: Receive data register not empty flag
bogdanm 85:024bf7f99721 629 * @arg UART_FLAG_IDLE: Idle Line detection flag
bogdanm 85:024bf7f99721 630 * @arg UART_FLAG_ORE: OverRun Error flag
bogdanm 85:024bf7f99721 631 * @arg UART_FLAG_NE: Noise Error flag
bogdanm 85:024bf7f99721 632 * @arg UART_FLAG_FE: Framing Error flag
bogdanm 85:024bf7f99721 633 * @arg UART_FLAG_PE: Parity Error flag
bogdanm 85:024bf7f99721 634 * @retval The new state of __FLAG__ (TRUE or FALSE).
bogdanm 85:024bf7f99721 635 */
bogdanm 85:024bf7f99721 636 #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
bogdanm 85:024bf7f99721 637
bogdanm 85:024bf7f99721 638 /** @brief Enables the specified UART interrupt.
bogdanm 85:024bf7f99721 639 * @param __HANDLE__: specifies the UART Handle.
bogdanm 85:024bf7f99721 640 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
bogdanm 85:024bf7f99721 641 * UART peripheral. (datasheet: up to four USART/UARTs)
bogdanm 85:024bf7f99721 642 * @param __INTERRUPT__: specifies the UART interrupt source to enable.
bogdanm 85:024bf7f99721 643 * This parameter can be one of the following values:
bogdanm 85:024bf7f99721 644 * @arg UART_IT_WUF: Wakeup from stop mode interrupt (not available on F030xx devices)
bogdanm 85:024bf7f99721 645 * @arg UART_IT_CM: Character match interrupt
bogdanm 85:024bf7f99721 646 * @arg UART_IT_CTS: CTS change interrupt
bogdanm 85:024bf7f99721 647 * @arg UART_IT_LBD: LIN Break detection interrupt (not available on F030xx devices)
bogdanm 85:024bf7f99721 648 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
bogdanm 85:024bf7f99721 649 * @arg UART_IT_TC: Transmission complete interrupt
bogdanm 85:024bf7f99721 650 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
bogdanm 85:024bf7f99721 651 * @arg UART_IT_IDLE: Idle line detection interrupt
bogdanm 85:024bf7f99721 652 * @arg UART_IT_PE: Parity Error interrupt
bogdanm 85:024bf7f99721 653 * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
bogdanm 85:024bf7f99721 654 * @retval None
bogdanm 85:024bf7f99721 655 */
bogdanm 85:024bf7f99721 656 #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
bogdanm 85:024bf7f99721 657 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
bogdanm 85:024bf7f99721 658 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))))
bogdanm 85:024bf7f99721 659
bogdanm 85:024bf7f99721 660
bogdanm 85:024bf7f99721 661 /** @brief Disables the specified UART interrupt.
bogdanm 85:024bf7f99721 662 * @param __HANDLE__: specifies the UART Handle.
bogdanm 85:024bf7f99721 663 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
bogdanm 85:024bf7f99721 664 * UART peripheral. (datasheet: up to four USART/UARTs)
bogdanm 85:024bf7f99721 665 * @param __INTERRUPT__: specifies the UART interrupt source to disable.
bogdanm 85:024bf7f99721 666 * This parameter can be one of the following values:
bogdanm 85:024bf7f99721 667 * @arg UART_IT_WUF: Wakeup from stop mode interrupt (not available on F030xx devices)
bogdanm 85:024bf7f99721 668 * @arg UART_IT_CM: Character match interrupt
bogdanm 85:024bf7f99721 669 * @arg UART_IT_CTS: CTS change interrupt
bogdanm 85:024bf7f99721 670 * @arg UART_IT_LBD: LIN Break detection interrupt (not available on F030xx devices)
bogdanm 85:024bf7f99721 671 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
bogdanm 85:024bf7f99721 672 * @arg UART_IT_TC: Transmission complete interrupt
bogdanm 85:024bf7f99721 673 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
bogdanm 85:024bf7f99721 674 * @arg UART_IT_IDLE: Idle line detection interrupt
bogdanm 85:024bf7f99721 675 * @arg UART_IT_PE: Parity Error interrupt
bogdanm 85:024bf7f99721 676 * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
bogdanm 85:024bf7f99721 677 * @retval None
bogdanm 85:024bf7f99721 678 */
bogdanm 85:024bf7f99721 679 #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
bogdanm 85:024bf7f99721 680 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
bogdanm 85:024bf7f99721 681 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))))
bogdanm 85:024bf7f99721 682
bogdanm 85:024bf7f99721 683 /** @brief Checks whether the specified UART interrupt has occurred or not.
bogdanm 85:024bf7f99721 684 * @param __HANDLE__: specifies the UART Handle.
bogdanm 85:024bf7f99721 685 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
bogdanm 85:024bf7f99721 686 * UART peripheral. (datasheet: up to four USART/UARTs)
bogdanm 85:024bf7f99721 687 * @param __IT__: specifies the UART interrupt to check.
bogdanm 85:024bf7f99721 688 * This parameter can be one of the following values:
bogdanm 85:024bf7f99721 689 * @arg UART_IT_WUF: Wakeup from stop mode interrupt (not available on F030xx devices)
bogdanm 85:024bf7f99721 690 * @arg UART_IT_CM: Character match interrupt
bogdanm 85:024bf7f99721 691 * @arg UART_IT_CTS: CTS change interrupt
bogdanm 85:024bf7f99721 692 * @arg UART_IT_LBD: LIN Break detection interrupt (not available on F030xx devices)
bogdanm 85:024bf7f99721 693 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
bogdanm 85:024bf7f99721 694 * @arg UART_IT_TC: Transmission complete interrupt
bogdanm 85:024bf7f99721 695 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
bogdanm 85:024bf7f99721 696 * @arg UART_IT_IDLE: Idle line detection interrupt
bogdanm 85:024bf7f99721 697 * @arg UART_IT_ORE: OverRun Error interrupt
bogdanm 85:024bf7f99721 698 * @arg UART_IT_NE: Noise Error interrupt
bogdanm 85:024bf7f99721 699 * @arg UART_IT_FE: Framing Error interrupt
bogdanm 85:024bf7f99721 700 * @arg UART_IT_PE: Parity Error interrupt
bogdanm 85:024bf7f99721 701 * @retval The new state of __IT__ (TRUE or FALSE).
bogdanm 85:024bf7f99721 702 */
bogdanm 85:024bf7f99721 703 #define __HAL_UART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
bogdanm 85:024bf7f99721 704
bogdanm 85:024bf7f99721 705 /** @brief Checks whether the specified UART interrupt source is enabled.
bogdanm 85:024bf7f99721 706 * @param __HANDLE__: specifies the UART Handle.
bogdanm 85:024bf7f99721 707 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
bogdanm 85:024bf7f99721 708 * UART peripheral. (datasheet: up to four USART/UARTs)
bogdanm 85:024bf7f99721 709 * @param __IT__: specifies the UART interrupt source to check.
bogdanm 85:024bf7f99721 710 * This parameter can be one of the following values:
bogdanm 85:024bf7f99721 711 * @arg UART_IT_WUF: Wakeup from stop mode interrupt (not available on F030xx devices)
bogdanm 85:024bf7f99721 712 * @arg UART_IT_CM: Character match interrupt
bogdanm 85:024bf7f99721 713 * @arg UART_IT_CTS: CTS change interrupt
bogdanm 85:024bf7f99721 714 * @arg UART_IT_LBD: LIN Break detection interrupt (not available on F030xx devices)
bogdanm 85:024bf7f99721 715 * @arg UART_IT_TXE: Transmit Data Register empty interrupt
bogdanm 85:024bf7f99721 716 * @arg UART_IT_TC: Transmission complete interrupt
bogdanm 85:024bf7f99721 717 * @arg UART_IT_RXNE: Receive Data register not empty interrupt
bogdanm 85:024bf7f99721 718 * @arg UART_IT_IDLE: Idle line detection interrupt
bogdanm 85:024bf7f99721 719 * @arg UART_IT_ORE: OverRun Error interrupt
bogdanm 85:024bf7f99721 720 * @arg UART_IT_NE: Noise Error interrupt
bogdanm 85:024bf7f99721 721 * @arg UART_IT_FE: Framing Error interrupt
bogdanm 85:024bf7f99721 722 * @arg UART_IT_PE: Parity Error interrupt
bogdanm 85:024bf7f99721 723 * @retval The new state of __IT__ (TRUE or FALSE).
bogdanm 85:024bf7f99721 724 */
bogdanm 85:024bf7f99721 725 #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5U) == 2)? \
bogdanm 85:024bf7f99721 726 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << (((uint16_t)(__IT__)) & UART_IT_MASK)))
bogdanm 85:024bf7f99721 727
bogdanm 85:024bf7f99721 728 /** @brief Clears the specified UART ISR flag, in setting the proper ICR register flag.
bogdanm 85:024bf7f99721 729 * @param __HANDLE__: specifies the UART Handle.
bogdanm 85:024bf7f99721 730 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
bogdanm 85:024bf7f99721 731 * UART peripheral. (datasheet: up to four USART/UARTs)
bogdanm 85:024bf7f99721 732 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
bogdanm 85:024bf7f99721 733 * to clear the corresponding interrupt
bogdanm 85:024bf7f99721 734 * This parameter can be one of the following values:
bogdanm 85:024bf7f99721 735 * @arg UART_CLEAR_PEF: Parity Error Clear Flag
bogdanm 85:024bf7f99721 736 * @arg UART_CLEAR_FEF: Framing Error Clear Flag
bogdanm 85:024bf7f99721 737 * @arg UART_CLEAR_NEF: Noise detected Clear Flag
bogdanm 85:024bf7f99721 738 * @arg UART_CLEAR_OREF: OverRun Error Clear Flag
bogdanm 85:024bf7f99721 739 * @arg UART_CLEAR_IDLEF: IDLE line detected Clear Flag
bogdanm 85:024bf7f99721 740 * @arg UART_CLEAR_TCF: Transmission Complete Clear Flag
bogdanm 85:024bf7f99721 741 * @arg UART_CLEAR_LBDF: LIN Break Detection Clear Flag (not available on F030xx devices)
bogdanm 85:024bf7f99721 742 * @arg UART_CLEAR_CTSF: CTS Interrupt Clear Flag
bogdanm 85:024bf7f99721 743 * @arg UART_CLEAR_RTOF: Receiver Time Out Clear Flag
bogdanm 85:024bf7f99721 744 * @arg UART_CLEAR_EOBF: End Of Block Clear Flag (not available on F030xx devices)
bogdanm 85:024bf7f99721 745 * @arg UART_CLEAR_CMF: Character Match Clear Flag
bogdanm 85:024bf7f99721 746 * @arg UART_CLEAR_WUF: Wake Up from stop mode Clear Flag (not available on F030xx devices)
bogdanm 85:024bf7f99721 747 * @retval None
bogdanm 85:024bf7f99721 748 */
bogdanm 85:024bf7f99721 749 #define __HAL_UART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR |= (uint32_t)(__IT_CLEAR__))
bogdanm 85:024bf7f99721 750
bogdanm 85:024bf7f99721 751 /** @brief Set a specific UART request flag.
bogdanm 85:024bf7f99721 752 * @param __HANDLE__: specifies the UART Handle.
bogdanm 85:024bf7f99721 753 * This parameter can be UARTx where x: 1, 2, 3 or 4 to select the USART or
bogdanm 85:024bf7f99721 754 * UART peripheral. (datasheet: up to four USART/UARTs)
bogdanm 85:024bf7f99721 755 * @param __REQ__: specifies the request flag to set
bogdanm 85:024bf7f99721 756 * This parameter can be one of the following values:
bogdanm 85:024bf7f99721 757 * @arg UART_AUTOBAUD_REQUEST: Auto-Baud Rate Request
bogdanm 85:024bf7f99721 758 * @arg UART_SENDBREAK_REQUEST: Send Break Request
bogdanm 85:024bf7f99721 759 * @arg UART_MUTE_MODE_REQUEST: Mute Mode Request
bogdanm 85:024bf7f99721 760 * @arg UART_RXDATA_FLUSH_REQUEST: Receive Data flush Request
bogdanm 85:024bf7f99721 761 * @arg UART_TXDATA_FLUSH_REQUEST: Transmit data flush Request (not available on F030xx devices)
bogdanm 85:024bf7f99721 762 * @retval None
bogdanm 85:024bf7f99721 763 */
bogdanm 85:024bf7f99721 764 #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint32_t)(__REQ__))
bogdanm 85:024bf7f99721 765
bogdanm 85:024bf7f99721 766 /** @brief Enable UART
bogdanm 85:024bf7f99721 767 * @param __HANDLE__: specifies the UART Handle.
bogdanm 85:024bf7f99721 768 * The Handle Instance can be UARTx where x: 1, 2, 3, 4 or 5 to select the UART peripheral
bogdanm 85:024bf7f99721 769 * @retval None
bogdanm 85:024bf7f99721 770 */
bogdanm 85:024bf7f99721 771 #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
bogdanm 85:024bf7f99721 772
bogdanm 85:024bf7f99721 773 /** @brief Disable UART
bogdanm 85:024bf7f99721 774 * @param __HANDLE__: specifies the UART Handle.
bogdanm 85:024bf7f99721 775 * The Handle Instance can be UARTx where x: 1, 2, 3, 4 or 5 to select the UART peripheral
bogdanm 85:024bf7f99721 776 * @retval None
bogdanm 85:024bf7f99721 777 */
bogdanm 85:024bf7f99721 778 #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
bogdanm 85:024bf7f99721 779
bogdanm 85:024bf7f99721 780 /** @brief BRR division operation to set BRR register in 8-bit oversampling mode
bogdanm 85:024bf7f99721 781 * @param _PCLK_: UART clock
bogdanm 85:024bf7f99721 782 * @param _BAUD_: Baud rate set by the user
bogdanm 85:024bf7f99721 783 * @retval Division result
bogdanm 85:024bf7f99721 784 */
bogdanm 85:024bf7f99721 785 #define __DIV_SAMPLING8(_PCLK_, _BAUD_) (((_PCLK_)*2)/((_BAUD_)))
bogdanm 85:024bf7f99721 786
bogdanm 85:024bf7f99721 787 /** @brief BRR division operation to set BRR register in 16-bit oversampling mode
bogdanm 85:024bf7f99721 788 * @param _PCLK_: UART clock
bogdanm 85:024bf7f99721 789 * @param _BAUD_: Baud rate set by the user
bogdanm 85:024bf7f99721 790 * @retval Division result
bogdanm 85:024bf7f99721 791 */
bogdanm 85:024bf7f99721 792 #define __DIV_SAMPLING16(_PCLK_, _BAUD_) (((_PCLK_))/((_BAUD_)))
bogdanm 85:024bf7f99721 793
bogdanm 85:024bf7f99721 794 /** @brief Check UART Baud rate
bogdanm 85:024bf7f99721 795 * @param BAUDRATE: Baudrate specified by the user
bogdanm 85:024bf7f99721 796 * The maximum Baud Rate is derived from the maximum clock on F0 (i.e. 48 MHz)
bogdanm 85:024bf7f99721 797 * divided by the smallest oversampling used on the USART (i.e. 8)
bogdanm 85:024bf7f99721 798 * @retval Test result (TRUE or FALSE).
bogdanm 85:024bf7f99721 799 */
bogdanm 85:024bf7f99721 800 #define IS_UART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 9000001)
bogdanm 85:024bf7f99721 801
bogdanm 85:024bf7f99721 802 /** @brief Check UART assertion time
bogdanm 85:024bf7f99721 803 * @param TIME: 5-bit value assertion time
bogdanm 85:024bf7f99721 804 * @retval Test result (TRUE or FALSE).
bogdanm 85:024bf7f99721 805 */
bogdanm 85:024bf7f99721 806 #define IS_UART_ASSERTIONTIME(TIME) ((TIME) <= 0x1F)
bogdanm 85:024bf7f99721 807
bogdanm 85:024bf7f99721 808 /** @brief Check UART deassertion time
bogdanm 85:024bf7f99721 809 * @param TIME: 5-bit value deassertion time
bogdanm 85:024bf7f99721 810 * @retval Test result (TRUE or FALSE).
bogdanm 85:024bf7f99721 811 */
bogdanm 85:024bf7f99721 812 #define IS_UART_DEASSERTIONTIME(TIME) ((TIME) <= 0x1F)
bogdanm 85:024bf7f99721 813
bogdanm 85:024bf7f99721 814 /**
bogdanm 85:024bf7f99721 815 * @}
bogdanm 85:024bf7f99721 816 */
bogdanm 85:024bf7f99721 817
bogdanm 85:024bf7f99721 818 /* Include UART HAL Extension module */
bogdanm 85:024bf7f99721 819 #include "stm32f0xx_hal_uart_ex.h"
bogdanm 85:024bf7f99721 820
bogdanm 85:024bf7f99721 821 /* Exported functions --------------------------------------------------------*/
bogdanm 85:024bf7f99721 822 /* Initialization and de-initialization functions ****************************/
bogdanm 85:024bf7f99721 823 HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 824 void UART_AdvFeatureConfig(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 825 HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 826 HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 827 HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 828 HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod);
bogdanm 85:024bf7f99721 829 HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 830 void HAL_UART_MspInit(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 831 void HAL_UART_MspDeInit(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 832 HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 833 HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 834 void HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 835 HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 836 HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 837 HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Timeout);
bogdanm 85:024bf7f99721 838
bogdanm 85:024bf7f99721 839 /* IO operation functions *****************************************************/
bogdanm 85:024bf7f99721 840 HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
bogdanm 85:024bf7f99721 841 HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
bogdanm 85:024bf7f99721 842 HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
bogdanm 85:024bf7f99721 843 HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
bogdanm 85:024bf7f99721 844 HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
bogdanm 85:024bf7f99721 845 HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
bogdanm 85:024bf7f99721 846 HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 847 HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 848 HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 849 void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 850 void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 851 void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 852 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 853 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 854 HAL_StatusTypeDef UART_Transmit_IT(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 855 HAL_StatusTypeDef UART_Receive_IT(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 856
bogdanm 85:024bf7f99721 857 /* Peripheral Control functions ***********************************************/
bogdanm 85:024bf7f99721 858
bogdanm 85:024bf7f99721 859 /* Peripheral State and Error functions ***************************************/
bogdanm 85:024bf7f99721 860 HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 861 uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart);
bogdanm 85:024bf7f99721 862
bogdanm 85:024bf7f99721 863 /**
bogdanm 85:024bf7f99721 864 * @}
bogdanm 85:024bf7f99721 865 */
bogdanm 85:024bf7f99721 866
bogdanm 85:024bf7f99721 867 /**
bogdanm 85:024bf7f99721 868 * @}
bogdanm 85:024bf7f99721 869 */
bogdanm 85:024bf7f99721 870
bogdanm 85:024bf7f99721 871 #ifdef __cplusplus
bogdanm 85:024bf7f99721 872 }
bogdanm 85:024bf7f99721 873 #endif
bogdanm 85:024bf7f99721 874
bogdanm 85:024bf7f99721 875 #endif /* __STM32F0xx_HAL_UART_H */
bogdanm 85:024bf7f99721 876
bogdanm 85:024bf7f99721 877 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/