Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Feb 03 15:31:20 2015 +0000
Revision:
93:e188a91d3eaa
Child:
108:34e6b704fe68
Release 93 of the mbed library

Main changes:

- Renesas RZ_A1H bugfixes - i2c, ticker
- new targets - Nucleo F303RE, Nucleo F070RB, BLE SMURFS,
Dragonfly 411RE,
- BusXXX - is connected method, plus operators addition
- LPC8xx - I2c fixes
- timestamp_t reverted to uint32_t
- RTX - fixes regarding stack (alignment, magic word)

Who changed what in which revision?

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