mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Tue Jun 24 14:45:08 2014 +0100
Revision:
237:f3da66175598
Synchronized with git revision 8ef659bca81f12dfc896b5a7af7c2abbd1a1b8b7

Full URL: https://github.com/mbedmicro/mbed/commit/8ef659bca81f12dfc896b5a7af7c2abbd1a1b8b7/

[NUCLEO_F334R8] Add platform files

Who changed what in which revision?

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