/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/adc/fsl_adc_hal.h substitute line 894 extern } by }

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Thu Nov 27 13:33:22 2014 +0000
Revision:
92:4fc01daae5a5
Parent:
85:024bf7f99721
Release 92 of the mbed libray

Main changes:

- nRF51822: fixed pin assignment issues
- ST targets moving to the STM32Cube driver
- LPC1439: fixed serial interrupt issue
- first Cortex-A platform supported in mbed (RZ_A1H)

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