my fork

Dependents:   Nucleo_blueNRG

Fork of mbed by mbed official

Committer:
filartrix
Date:
Wed Apr 08 14:12:53 2015 +0000
Revision:
97:4298809c7c9e
Parent:
93:e188a91d3eaa
First reale BlueNRG module for nucleo 401 board

Who changed what in which revision?

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