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:
Wed Jul 01 09:45:11 2015 +0100
Revision:
579:53297373a894
Parent:
441:d2c15dda23c1
Child:
630:825f75ca301e
Synchronized with git revision d5b4d2ab9c47edb4dc5776e7177b0c2263459081

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

Initial version of drivers for SAMR21

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