meh

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Oct 28 16:40:41 2014 +0000
Revision:
90:cb3d968589d8
Child:
93:e188a91d3eaa
Release 90 of the mbed library

Changes:

- Freescale KSDK update (v1.0)
- K22 - new target addition
- KL43Z - new target addition
- Nucleo F091RC - new target addition
- Nucleo L152RE - STM32Cube driver
- Nordic - Softdevice v7.1.0
- Nvic files - BSD License
- LPC824 - various HAL fixes
- Nucleo F411RE - CMSIS - IAR files

Who changed what in which revision?

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