mbed w/ spi bug fig

Dependents:   display-puck

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Thu May 22 20:00:09 2014 +0100
Revision:
205:c41fc65bcfb4
Child:
218:44081b78fdc2
Synchronized with git revision ea4b6f76efab17a3f7d7777b0cc1ef05fec6d1cb

Full URL: https://github.com/mbedmicro/mbed/commit/ea4b6f76efab17a3f7d7777b0cc1ef05fec6d1cb/

[NUCLEO_F072RB] cmsis files

Who changed what in which revision?

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