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:
Thu Oct 09 08:15:07 2014 +0100
Revision:
340:28d1f895c6fe
Synchronized with git revision b5a4c8e80393336b2656fb29ab46d405d3068602

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

HAL: nrf51822 - Few fixes for PWM and Serial

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