Ricardo Benitez / mbed

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Mar 15 14:34:00 2016 +0000
Revision:
116:c0f6e94411f5
Release 116 of the mbed library

Changes:
- new targets - NUCLEO_L073RZ
- fixes to IOTSS BEID platform
- LPC824, LPC1549 and LPC11U68 - fix PWMOut SCT bugs
- STM32F7 - Cube driver
- STM32F4 - add RTC LSI macro, defined as 0
- STM32F3 - fix multiple ADC clock initialization
- retarget - binary mode fix for GCC

Who changed what in which revision?

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