mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Mon Sep 28 10:45:10 2015 +0100
Revision:
630:825f75ca301e
Parent:
441:d2c15dda23c1
Synchronized with git revision 54fbe4144faf309c37205a5d39fa665daa919f10

Full URL: https://github.com/mbedmicro/mbed/commit/54fbe4144faf309c37205a5d39fa665daa919f10/

NUCLEO_F031K6 : Add new target

Who changed what in which revision?

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