The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Fri May 26 12:30:20 2017 +0100
Revision:
143:86740a56073b
Parent:
134:ad3be0349dc5
Release 143 of the mbed library.

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_usart.h
bogdanm 85:024bf7f99721 4 * @author MCD Application Team
<> 134:ad3be0349dc5 5 * @version V1.5.0
<> 134:ad3be0349dc5 6 * @date 04-November-2016
bogdanm 85:024bf7f99721 7 * @brief Header file of USART HAL module.
bogdanm 85:024bf7f99721 8 ******************************************************************************
bogdanm 85:024bf7f99721 9 * @attention
bogdanm 85:024bf7f99721 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 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 *
Kojto 108:34e6b704fe68 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_USART_H
bogdanm 85:024bf7f99721 40 #define __STM32F0xx_HAL_USART_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 USART
bogdanm 85:024bf7f99721 54 * @{
Kojto 108:34e6b704fe68 55 */
bogdanm 85:024bf7f99721 56
<> 134:ad3be0349dc5 57 /* Exported types ------------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 58 /** @defgroup USART_Exported_Types USART Exported Types
bogdanm 92:4fc01daae5a5 59 * @{
Kojto 108:34e6b704fe68 60 */
bogdanm 85:024bf7f99721 61
Kojto 108:34e6b704fe68 62 /**
Kojto 108:34e6b704fe68 63 * @brief USART Init Structure definition
Kojto 108:34e6b704fe68 64 */
bogdanm 85:024bf7f99721 65 typedef struct
bogdanm 85:024bf7f99721 66 {
bogdanm 85:024bf7f99721 67 uint32_t BaudRate; /*!< This member configures the Usart communication baud rate.
bogdanm 85:024bf7f99721 68 The baud rate is computed using the following formula:
Kojto 108:34e6b704fe68 69 Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate))). */
bogdanm 85:024bf7f99721 70
bogdanm 85:024bf7f99721 71 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
Kojto 108:34e6b704fe68 72 This parameter can be a value of @ref USARTEx_Word_Length. */
bogdanm 85:024bf7f99721 73
bogdanm 92:4fc01daae5a5 74 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
Kojto 108:34e6b704fe68 75 This parameter can be a value of @ref USART_Stop_Bits. */
bogdanm 85:024bf7f99721 76
bogdanm 92:4fc01daae5a5 77 uint32_t Parity; /*!< Specifies the parity mode.
bogdanm 85:024bf7f99721 78 This parameter can be a value of @ref USART_Parity
bogdanm 85:024bf7f99721 79 @note When parity is enabled, the computed parity is inserted
bogdanm 85:024bf7f99721 80 at the MSB position of the transmitted data (9th bit when
bogdanm 85:024bf7f99721 81 the word length is set to 9 data bits; 8th bit when the
bogdanm 85:024bf7f99721 82 word length is set to 8 data bits). */
Kojto 108:34e6b704fe68 83
bogdanm 92:4fc01daae5a5 84 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
Kojto 108:34e6b704fe68 85 This parameter can be a value of @ref USART_Mode. */
bogdanm 85:024bf7f99721 86
bogdanm 92:4fc01daae5a5 87 uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock.
Kojto 108:34e6b704fe68 88 This parameter can be a value of @ref USART_Clock_Polarity. */
bogdanm 85:024bf7f99721 89
bogdanm 92:4fc01daae5a5 90 uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made.
Kojto 108:34e6b704fe68 91 This parameter can be a value of @ref USART_Clock_Phase. */
bogdanm 85:024bf7f99721 92
bogdanm 92:4fc01daae5a5 93 uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
bogdanm 85:024bf7f99721 94 data bit (MSB) has to be output on the SCLK pin in synchronous mode.
Kojto 108:34e6b704fe68 95 This parameter can be a value of @ref USART_Last_Bit. */
bogdanm 85:024bf7f99721 96 }USART_InitTypeDef;
bogdanm 85:024bf7f99721 97
Kojto 108:34e6b704fe68 98 /**
Kojto 108:34e6b704fe68 99 * @brief HAL USART State structures definition
Kojto 108:34e6b704fe68 100 */
bogdanm 85:024bf7f99721 101 typedef enum
bogdanm 85:024bf7f99721 102 {
<> 134:ad3be0349dc5 103 HAL_USART_STATE_RESET = 0x00U, /*!< Peripheral is not initialized */
<> 134:ad3be0349dc5 104 HAL_USART_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
<> 134:ad3be0349dc5 105 HAL_USART_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */
<> 134:ad3be0349dc5 106 HAL_USART_STATE_BUSY_TX = 0x12U, /*!< Data Transmission process is ongoing */
<> 134:ad3be0349dc5 107 HAL_USART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */
<> 134:ad3be0349dc5 108 HAL_USART_STATE_BUSY_TX_RX = 0x32U, /*!< Data Transmission Reception process is ongoing */
<> 134:ad3be0349dc5 109 HAL_USART_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
<> 134:ad3be0349dc5 110 HAL_USART_STATE_ERROR = 0x04U /*!< Error */
bogdanm 85:024bf7f99721 111 }HAL_USART_StateTypeDef;
bogdanm 85:024bf7f99721 112
Kojto 108:34e6b704fe68 113 /**
bogdanm 85:024bf7f99721 114 * @brief USART clock sources definitions
bogdanm 85:024bf7f99721 115 */
bogdanm 85:024bf7f99721 116 typedef enum
bogdanm 85:024bf7f99721 117 {
<> 134:ad3be0349dc5 118 USART_CLOCKSOURCE_PCLK1 = 0x00U, /*!< PCLK1 clock source */
<> 134:ad3be0349dc5 119 USART_CLOCKSOURCE_HSI = 0x02U, /*!< HSI clock source */
<> 134:ad3be0349dc5 120 USART_CLOCKSOURCE_SYSCLK = 0x04U, /*!< SYSCLK clock source */
<> 134:ad3be0349dc5 121 USART_CLOCKSOURCE_LSE = 0x08U, /*!< LSE clock source */
<> 134:ad3be0349dc5 122 USART_CLOCKSOURCE_UNDEFINED = 0x10U /*!< Undefined clock source */
bogdanm 85:024bf7f99721 123 }USART_ClockSourceTypeDef;
bogdanm 85:024bf7f99721 124
Kojto 108:34e6b704fe68 125
Kojto 108:34e6b704fe68 126 /**
Kojto 108:34e6b704fe68 127 * @brief USART handle Structure definition
Kojto 108:34e6b704fe68 128 */
bogdanm 85:024bf7f99721 129 typedef struct
bogdanm 85:024bf7f99721 130 {
bogdanm 92:4fc01daae5a5 131 USART_TypeDef *Instance; /*!< USART registers base address */
Kojto 108:34e6b704fe68 132
bogdanm 92:4fc01daae5a5 133 USART_InitTypeDef Init; /*!< USART communication parameters */
Kojto 108:34e6b704fe68 134
bogdanm 92:4fc01daae5a5 135 uint8_t *pTxBuffPtr; /*!< Pointer to USART Tx transfer Buffer */
Kojto 108:34e6b704fe68 136
bogdanm 92:4fc01daae5a5 137 uint16_t TxXferSize; /*!< USART Tx Transfer size */
Kojto 108:34e6b704fe68 138
<> 134:ad3be0349dc5 139 __IO uint16_t TxXferCount; /*!< USART Tx Transfer Counter */
Kojto 108:34e6b704fe68 140
bogdanm 92:4fc01daae5a5 141 uint8_t *pRxBuffPtr; /*!< Pointer to USART Rx transfer Buffer */
Kojto 108:34e6b704fe68 142
bogdanm 92:4fc01daae5a5 143 uint16_t RxXferSize; /*!< USART Rx Transfer size */
Kojto 108:34e6b704fe68 144
<> 134:ad3be0349dc5 145 __IO uint16_t RxXferCount; /*!< USART Rx Transfer Counter */
Kojto 108:34e6b704fe68 146
bogdanm 92:4fc01daae5a5 147 uint16_t Mask; /*!< USART Rx RDR register mask */
Kojto 108:34e6b704fe68 148
bogdanm 92:4fc01daae5a5 149 DMA_HandleTypeDef *hdmatx; /*!< USART Tx DMA Handle parameters */
Kojto 108:34e6b704fe68 150
bogdanm 92:4fc01daae5a5 151 DMA_HandleTypeDef *hdmarx; /*!< USART Rx DMA Handle parameters */
Kojto 108:34e6b704fe68 152
Kojto 108:34e6b704fe68 153 HAL_LockTypeDef Lock; /*!< Locking object */
Kojto 108:34e6b704fe68 154
<> 134:ad3be0349dc5 155 __IO HAL_USART_StateTypeDef State; /*!< USART communication state */
Kojto 108:34e6b704fe68 156
<> 134:ad3be0349dc5 157 __IO uint32_t ErrorCode; /*!< USART Error code */
Kojto 108:34e6b704fe68 158
bogdanm 85:024bf7f99721 159 }USART_HandleTypeDef;
bogdanm 85:024bf7f99721 160
bogdanm 92:4fc01daae5a5 161 /**
bogdanm 92:4fc01daae5a5 162 * @}
bogdanm 92:4fc01daae5a5 163 */
bogdanm 85:024bf7f99721 164
bogdanm 85:024bf7f99721 165 /* Exported constants --------------------------------------------------------*/
Kojto 108:34e6b704fe68 166 /** @defgroup USART_Exported_Constants USART Exported Constants
bogdanm 85:024bf7f99721 167 * @{
bogdanm 85:024bf7f99721 168 */
bogdanm 85:024bf7f99721 169
Kojto 93:e188a91d3eaa 170 /** @defgroup USART_Error USART Error
Kojto 93:e188a91d3eaa 171 * @{
Kojto 93:e188a91d3eaa 172 */
<> 134:ad3be0349dc5 173 #define HAL_USART_ERROR_NONE (0x00000000U) /*!< No error */
<> 134:ad3be0349dc5 174 #define HAL_USART_ERROR_PE (0x00000001U) /*!< Parity error */
<> 134:ad3be0349dc5 175 #define HAL_USART_ERROR_NE (0x00000002U) /*!< Noise error */
<> 134:ad3be0349dc5 176 #define HAL_USART_ERROR_FE (0x00000004U) /*!< frame error */
<> 134:ad3be0349dc5 177 #define HAL_USART_ERROR_ORE (0x00000008U) /*!< Overrun error */
<> 134:ad3be0349dc5 178 #define HAL_USART_ERROR_DMA (0x00000010U) /*!< DMA transfer error */
Kojto 93:e188a91d3eaa 179 /**
Kojto 93:e188a91d3eaa 180 * @}
Kojto 93:e188a91d3eaa 181 */
Kojto 93:e188a91d3eaa 182
bogdanm 85:024bf7f99721 183 /** @defgroup USART_Stop_Bits USART Number of Stop Bits
bogdanm 85:024bf7f99721 184 * @{
bogdanm 85:024bf7f99721 185 */
Kojto 122:f9eeca106725 186 #ifdef USART_SMARTCARD_SUPPORT
<> 134:ad3be0349dc5 187 #define USART_STOPBITS_0_5 ((uint32_t)USART_CR2_STOP_0) /*!< USART frame with 0.5 stop bit */
<> 134:ad3be0349dc5 188 #define USART_STOPBITS_1 (0x00000000U) /*!< USART frame with 1 stop bit */
<> 134:ad3be0349dc5 189 #define USART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) /*!< USART frame with 1.5 stop bits */
<> 134:ad3be0349dc5 190 #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) /*!< USART frame with 2 stop bits */
Kojto 122:f9eeca106725 191 #else
<> 134:ad3be0349dc5 192 #define USART_STOPBITS_1 (0x00000000U) /*!< USART frame with 1 stop bit */
<> 134:ad3be0349dc5 193 #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) /*!< USART frame with 2 stop bits */
Kojto 122:f9eeca106725 194 #endif
bogdanm 85:024bf7f99721 195 /**
bogdanm 85:024bf7f99721 196 * @}
Kojto 122:f9eeca106725 197 */
bogdanm 85:024bf7f99721 198
bogdanm 85:024bf7f99721 199 /** @defgroup USART_Parity USART Parity
bogdanm 85:024bf7f99721 200 * @{
Kojto 108:34e6b704fe68 201 */
<> 134:ad3be0349dc5 202 #define USART_PARITY_NONE (0x00000000U) /*!< No parity */
Kojto 108:34e6b704fe68 203 #define USART_PARITY_EVEN ((uint32_t)USART_CR1_PCE) /*!< Even parity */
Kojto 108:34e6b704fe68 204 #define USART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) /*!< Odd parity */
bogdanm 85:024bf7f99721 205 /**
bogdanm 85:024bf7f99721 206 * @}
Kojto 108:34e6b704fe68 207 */
bogdanm 85:024bf7f99721 208
bogdanm 85:024bf7f99721 209 /** @defgroup USART_Mode USART Mode
bogdanm 85:024bf7f99721 210 * @{
Kojto 108:34e6b704fe68 211 */
<> 134:ad3be0349dc5 212 #define USART_MODE_RX ((uint32_t)USART_CR1_RE) /*!< RX mode */
Kojto 108:34e6b704fe68 213 #define USART_MODE_TX ((uint32_t)USART_CR1_TE) /*!< TX mode */
Kojto 108:34e6b704fe68 214 #define USART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) /*!< RX and TX mode */
bogdanm 85:024bf7f99721 215 /**
bogdanm 85:024bf7f99721 216 * @}
bogdanm 85:024bf7f99721 217 */
Kojto 108:34e6b704fe68 218
bogdanm 85:024bf7f99721 219 /** @defgroup USART_Clock USART Clock
bogdanm 85:024bf7f99721 220 * @{
Kojto 108:34e6b704fe68 221 */
<> 134:ad3be0349dc5 222 #define USART_CLOCK_DISABLE (0x00000000U) /*!< USART clock disable */
Kojto 108:34e6b704fe68 223 #define USART_CLOCK_ENABLE ((uint32_t)USART_CR2_CLKEN) /*!< USART clock enable */
bogdanm 85:024bf7f99721 224 /**
bogdanm 85:024bf7f99721 225 * @}
Kojto 108:34e6b704fe68 226 */
bogdanm 85:024bf7f99721 227
bogdanm 85:024bf7f99721 228 /** @defgroup USART_Clock_Polarity USART Clock Polarity
bogdanm 85:024bf7f99721 229 * @{
bogdanm 85:024bf7f99721 230 */
<> 134:ad3be0349dc5 231 #define USART_POLARITY_LOW (0x00000000U) /*!< USART Clock signal is steady Low */
<> 134:ad3be0349dc5 232 #define USART_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL) /*!< USART Clock signal is steady High */
bogdanm 85:024bf7f99721 233 /**
bogdanm 85:024bf7f99721 234 * @}
Kojto 108:34e6b704fe68 235 */
bogdanm 85:024bf7f99721 236
bogdanm 85:024bf7f99721 237 /** @defgroup USART_Clock_Phase USART Clock Phase
bogdanm 85:024bf7f99721 238 * @{
bogdanm 85:024bf7f99721 239 */
<> 134:ad3be0349dc5 240 #define USART_PHASE_1EDGE (0x00000000U) /*!< USART frame phase on first clock transition */
Kojto 108:34e6b704fe68 241 #define USART_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA) /*!< USART frame phase on second clock transition */
bogdanm 85:024bf7f99721 242 /**
bogdanm 85:024bf7f99721 243 * @}
bogdanm 85:024bf7f99721 244 */
bogdanm 85:024bf7f99721 245
bogdanm 85:024bf7f99721 246 /** @defgroup USART_Last_Bit USART Last Bit
bogdanm 85:024bf7f99721 247 * @{
bogdanm 85:024bf7f99721 248 */
<> 134:ad3be0349dc5 249 #define USART_LASTBIT_DISABLE (0x00000000U) /*!< USART frame last data bit clock pulse not output to SCLK pin */
Kojto 108:34e6b704fe68 250 #define USART_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL) /*!< USART frame last data bit clock pulse output to SCLK pin */
bogdanm 85:024bf7f99721 251 /**
bogdanm 85:024bf7f99721 252 * @}
bogdanm 85:024bf7f99721 253 */
bogdanm 85:024bf7f99721 254
bogdanm 85:024bf7f99721 255 /** @defgroup USART_Interrupt_definition USART Interrupts Definition
bogdanm 85:024bf7f99721 256 * Elements values convention: 0000ZZZZ0XXYYYYYb
bogdanm 85:024bf7f99721 257 * - YYYYY : Interrupt source position in the XX register (5bits)
bogdanm 85:024bf7f99721 258 * - XX : Interrupt source register (2bits)
bogdanm 85:024bf7f99721 259 * - 01: CR1 register
bogdanm 85:024bf7f99721 260 * - 10: CR2 register
bogdanm 85:024bf7f99721 261 * - 11: CR3 register
bogdanm 85:024bf7f99721 262 * - ZZZZ : Flag position in the ISR register(4bits)
bogdanm 85:024bf7f99721 263 * @{
bogdanm 85:024bf7f99721 264 */
bogdanm 85:024bf7f99721 265
<> 134:ad3be0349dc5 266 #define USART_IT_PE ((uint16_t)0x0028U) /*!< USART parity error interruption */
<> 134:ad3be0349dc5 267 #define USART_IT_TXE ((uint16_t)0x0727U) /*!< USART transmit data register empty interruption */
<> 134:ad3be0349dc5 268 #define USART_IT_TC ((uint16_t)0x0626U) /*!< USART transmission complete interruption */
<> 134:ad3be0349dc5 269 #define USART_IT_RXNE ((uint16_t)0x0525U) /*!< USART read data register not empty interruption */
<> 134:ad3be0349dc5 270 #define USART_IT_IDLE ((uint16_t)0x0424U) /*!< USART idle interruption */
<> 134:ad3be0349dc5 271 #define USART_IT_ERR ((uint16_t)0x0060U) /*!< USART error interruption */
<> 134:ad3be0349dc5 272 #define USART_IT_ORE ((uint16_t)0x0300U) /*!< USART overrun error interruption */
<> 134:ad3be0349dc5 273 #define USART_IT_NE ((uint16_t)0x0200U) /*!< USART noise error interruption */
<> 134:ad3be0349dc5 274 #define USART_IT_FE ((uint16_t)0x0100U) /*!< USART frame error interruption */
bogdanm 85:024bf7f99721 275 /**
bogdanm 85:024bf7f99721 276 * @}
bogdanm 85:024bf7f99721 277 */
bogdanm 85:024bf7f99721 278
bogdanm 85:024bf7f99721 279 /** @defgroup USART_IT_CLEAR_Flags USART Interruption Clear Flags
bogdanm 85:024bf7f99721 280 * @{
bogdanm 85:024bf7f99721 281 */
Kojto 108:34e6b704fe68 282 #define USART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
Kojto 108:34e6b704fe68 283 #define USART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
Kojto 108:34e6b704fe68 284 #define USART_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
Kojto 108:34e6b704fe68 285 #define USART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
Kojto 108:34e6b704fe68 286 #define USART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */
Kojto 108:34e6b704fe68 287 #define USART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
Kojto 108:34e6b704fe68 288 #define USART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */
bogdanm 85:024bf7f99721 289 /**
bogdanm 85:024bf7f99721 290 * @}
bogdanm 85:024bf7f99721 291 */
bogdanm 85:024bf7f99721 292
Kojto 108:34e6b704fe68 293 /** @defgroup USART_Interruption_Mask USART Interruption Flags Mask
bogdanm 85:024bf7f99721 294 * @{
Kojto 108:34e6b704fe68 295 */
<> 134:ad3be0349dc5 296 #define USART_IT_MASK ((uint16_t)0x001FU) /*!< USART interruptions flags mask */
bogdanm 85:024bf7f99721 297 /**
bogdanm 85:024bf7f99721 298 * @}
bogdanm 85:024bf7f99721 299 */
bogdanm 85:024bf7f99721 300
bogdanm 85:024bf7f99721 301 /**
bogdanm 85:024bf7f99721 302 * @}
bogdanm 85:024bf7f99721 303 */
Kojto 108:34e6b704fe68 304
Kojto 108:34e6b704fe68 305 /* Exported macros -----------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 306 /** @defgroup USART_Exported_Macros USART Exported Macros
bogdanm 85:024bf7f99721 307 * @{
Kojto 108:34e6b704fe68 308 */
bogdanm 85:024bf7f99721 309
Kojto 108:34e6b704fe68 310 /** @brief Reset USART handle state.
bogdanm 85:024bf7f99721 311 * @param __HANDLE__: USART handle.
bogdanm 85:024bf7f99721 312 * @retval None
bogdanm 85:024bf7f99721 313 */
Kojto 108:34e6b704fe68 314 #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET)
bogdanm 85:024bf7f99721 315
Kojto 108:34e6b704fe68 316 /** @brief Check whether the specified USART flag is set or not.
bogdanm 92:4fc01daae5a5 317 * @param __HANDLE__: specifies the USART Handle
bogdanm 85:024bf7f99721 318 * @param __FLAG__: specifies the flag to check.
bogdanm 85:024bf7f99721 319 * This parameter can be one of the following values:
<> 134:ad3be0349dc5 320 @if STM32F030x6
<> 134:ad3be0349dc5 321 @elseif STM32F030x8
<> 134:ad3be0349dc5 322 @elseif STM32F030xC
<> 134:ad3be0349dc5 323 @elseif STM32F070x6
<> 134:ad3be0349dc5 324 @elseif STM32F070xB
<> 134:ad3be0349dc5 325 @else
<> 134:ad3be0349dc5 326 * @arg @ref USART_FLAG_REACK Receive enable acknowledge flag
<> 134:ad3be0349dc5 327 @endif
<> 134:ad3be0349dc5 328 * @arg @ref USART_FLAG_TEACK Transmit enable acknowledge flag
<> 134:ad3be0349dc5 329 * @arg @ref USART_FLAG_BUSY Busy flag
<> 134:ad3be0349dc5 330 * @arg @ref USART_FLAG_CTS CTS Change flag
<> 134:ad3be0349dc5 331 * @arg @ref USART_FLAG_TXE Transmit data register empty flag
<> 134:ad3be0349dc5 332 * @arg @ref USART_FLAG_TC Transmission Complete flag
<> 134:ad3be0349dc5 333 * @arg @ref USART_FLAG_RXNE Receive data register not empty flag
<> 134:ad3be0349dc5 334 * @arg @ref USART_FLAG_IDLE Idle Line detection flag
<> 134:ad3be0349dc5 335 * @arg @ref USART_FLAG_ORE OverRun Error flag
<> 134:ad3be0349dc5 336 * @arg @ref USART_FLAG_NE Noise Error flag
<> 134:ad3be0349dc5 337 * @arg @ref USART_FLAG_FE Framing Error flag
<> 134:ad3be0349dc5 338 * @arg @ref USART_FLAG_PE Parity Error flag
bogdanm 85:024bf7f99721 339 * @retval The new state of __FLAG__ (TRUE or FALSE).
bogdanm 85:024bf7f99721 340 */
bogdanm 85:024bf7f99721 341 #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
bogdanm 85:024bf7f99721 342
Kojto 108:34e6b704fe68 343 /** @brief Clear the specified USART pending flag.
Kojto 108:34e6b704fe68 344 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 345 * @param __FLAG__: specifies the flag to check.
Kojto 108:34e6b704fe68 346 * This parameter can be any combination of the following values:
<> 134:ad3be0349dc5 347 * @arg @ref USART_CLEAR_PEF
<> 134:ad3be0349dc5 348 * @arg @ref USART_CLEAR_FEF
<> 134:ad3be0349dc5 349 * @arg @ref USART_CLEAR_NEF
<> 134:ad3be0349dc5 350 * @arg @ref USART_CLEAR_OREF
<> 134:ad3be0349dc5 351 * @arg @ref USART_CLEAR_IDLEF
<> 134:ad3be0349dc5 352 * @arg @ref USART_CLEAR_TCF
<> 134:ad3be0349dc5 353 * @arg @ref USART_CLEAR_CTSF
Kojto 108:34e6b704fe68 354 * @retval None
Kojto 108:34e6b704fe68 355 */
Kojto 108:34e6b704fe68 356 #define __HAL_USART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
bogdanm 85:024bf7f99721 357
Kojto 108:34e6b704fe68 358 /** @brief Clear the USART PE pending flag.
Kojto 108:34e6b704fe68 359 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 360 * @retval None
Kojto 108:34e6b704fe68 361 */
Kojto 108:34e6b704fe68 362 #define __HAL_USART_CLEAR_PEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_PEF)
Kojto 108:34e6b704fe68 363
Kojto 108:34e6b704fe68 364 /** @brief Clear the USART FE pending flag.
Kojto 108:34e6b704fe68 365 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 366 * @retval None
Kojto 108:34e6b704fe68 367 */
Kojto 108:34e6b704fe68 368 #define __HAL_USART_CLEAR_FEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_FEF)
Kojto 108:34e6b704fe68 369
Kojto 108:34e6b704fe68 370 /** @brief Clear the USART NE pending flag.
Kojto 108:34e6b704fe68 371 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 372 * @retval None
Kojto 108:34e6b704fe68 373 */
Kojto 108:34e6b704fe68 374 #define __HAL_USART_CLEAR_NEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_NEF)
Kojto 108:34e6b704fe68 375
Kojto 108:34e6b704fe68 376 /** @brief Clear the USART ORE pending flag.
Kojto 108:34e6b704fe68 377 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 378 * @retval None
Kojto 108:34e6b704fe68 379 */
Kojto 108:34e6b704fe68 380 #define __HAL_USART_CLEAR_OREFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_OREF)
Kojto 108:34e6b704fe68 381
Kojto 108:34e6b704fe68 382 /** @brief Clear the USART IDLE pending flag.
Kojto 108:34e6b704fe68 383 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 384 * @retval None
Kojto 108:34e6b704fe68 385 */
Kojto 108:34e6b704fe68 386 #define __HAL_USART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_IDLEF)
Kojto 108:34e6b704fe68 387
Kojto 108:34e6b704fe68 388 /** @brief Enable the specified USART interrupt.
Kojto 108:34e6b704fe68 389 * @param __HANDLE__: specifies the USART Handle.
bogdanm 85:024bf7f99721 390 * @param __INTERRUPT__: specifies the USART interrupt source to enable.
bogdanm 85:024bf7f99721 391 * This parameter can be one of the following values:
<> 134:ad3be0349dc5 392 * @arg @ref USART_IT_TXE Transmit Data Register empty interrupt
<> 134:ad3be0349dc5 393 * @arg @ref USART_IT_TC Transmission complete interrupt
<> 134:ad3be0349dc5 394 * @arg @ref USART_IT_RXNE Receive Data register not empty interrupt
<> 134:ad3be0349dc5 395 * @arg @ref USART_IT_IDLE Idle line detection interrupt
<> 134:ad3be0349dc5 396 * @arg @ref USART_IT_PE Parity Error interrupt
<> 134:ad3be0349dc5 397 * @arg @ref USART_IT_ERR Error interrupt(Frame error, noise error, overrun error)
bogdanm 85:024bf7f99721 398 * @retval None
bogdanm 85:024bf7f99721 399 */
<> 134:ad3be0349dc5 400 #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
<> 134:ad3be0349dc5 401 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
bogdanm 85:024bf7f99721 402 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))))
bogdanm 85:024bf7f99721 403
Kojto 108:34e6b704fe68 404 /** @brief Disable the specified USART interrupt.
bogdanm 85:024bf7f99721 405 * @param __HANDLE__: specifies the USART Handle.
bogdanm 85:024bf7f99721 406 * @param __INTERRUPT__: specifies the USART interrupt source to disable.
bogdanm 85:024bf7f99721 407 * This parameter can be one of the following values:
<> 134:ad3be0349dc5 408 * @arg @ref USART_IT_TXE Transmit Data Register empty interrupt
<> 134:ad3be0349dc5 409 * @arg @ref USART_IT_TC Transmission complete interrupt
<> 134:ad3be0349dc5 410 * @arg @ref USART_IT_RXNE Receive Data register not empty interrupt
<> 134:ad3be0349dc5 411 * @arg @ref USART_IT_IDLE Idle line detection interrupt
<> 134:ad3be0349dc5 412 * @arg @ref USART_IT_PE Parity Error interrupt
<> 134:ad3be0349dc5 413 * @arg @ref USART_IT_ERR Error interrupt(Frame error, noise error, overrun error)
bogdanm 85:024bf7f99721 414 * @retval None
bogdanm 85:024bf7f99721 415 */
<> 134:ad3be0349dc5 416 #define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
<> 134:ad3be0349dc5 417 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
bogdanm 85:024bf7f99721 418 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))))
bogdanm 85:024bf7f99721 419
Kojto 108:34e6b704fe68 420
Kojto 108:34e6b704fe68 421 /** @brief Check whether the specified USART interrupt has occurred or not.
Kojto 108:34e6b704fe68 422 * @param __HANDLE__: specifies the USART Handle.
bogdanm 85:024bf7f99721 423 * @param __IT__: specifies the USART interrupt source to check.
bogdanm 85:024bf7f99721 424 * This parameter can be one of the following values:
<> 134:ad3be0349dc5 425 * @arg @ref USART_IT_TXE Transmit Data Register empty interrupt
<> 134:ad3be0349dc5 426 * @arg @ref USART_IT_TC Transmission complete interrupt
<> 134:ad3be0349dc5 427 * @arg @ref USART_IT_RXNE Receive Data register not empty interrupt
<> 134:ad3be0349dc5 428 * @arg @ref USART_IT_IDLE Idle line detection interrupt
<> 134:ad3be0349dc5 429 * @arg @ref USART_IT_ORE OverRun Error interrupt
<> 134:ad3be0349dc5 430 * @arg @ref USART_IT_NE Noise Error interrupt
<> 134:ad3be0349dc5 431 * @arg @ref USART_IT_FE Framing Error interrupt
<> 134:ad3be0349dc5 432 * @arg @ref USART_IT_PE Parity Error interrupt
bogdanm 85:024bf7f99721 433 * @retval The new state of __IT__ (TRUE or FALSE).
bogdanm 85:024bf7f99721 434 */
<> 134:ad3be0349dc5 435 #define __HAL_USART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & (1U << ((__IT__)>> 0x08U)))
bogdanm 85:024bf7f99721 436
Kojto 108:34e6b704fe68 437 /** @brief Check whether the specified USART interrupt source is enabled or not.
bogdanm 85:024bf7f99721 438 * @param __HANDLE__: specifies the USART Handle.
bogdanm 85:024bf7f99721 439 * @param __IT__: specifies the USART interrupt source to check.
bogdanm 85:024bf7f99721 440 * This parameter can be one of the following values:
<> 134:ad3be0349dc5 441 * @arg @ref USART_IT_TXE Transmit Data Register empty interrupt
<> 134:ad3be0349dc5 442 * @arg @ref USART_IT_TC Transmission complete interrupt
<> 134:ad3be0349dc5 443 * @arg @ref USART_IT_RXNE Receive Data register not empty interrupt
<> 134:ad3be0349dc5 444 * @arg @ref USART_IT_IDLE Idle line detection interrupt
<> 134:ad3be0349dc5 445 * @arg @ref USART_IT_ORE OverRun Error interrupt
<> 134:ad3be0349dc5 446 * @arg @ref USART_IT_NE Noise Error interrupt
<> 134:ad3be0349dc5 447 * @arg @ref USART_IT_FE Framing Error interrupt
<> 134:ad3be0349dc5 448 * @arg @ref USART_IT_PE Parity Error interrupt
bogdanm 85:024bf7f99721 449 * @retval The new state of __IT__ (TRUE or FALSE).
bogdanm 85:024bf7f99721 450 */
<> 134:ad3be0349dc5 451 #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1U)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5U) == 2U)? \
<> 134:ad3be0349dc5 452 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (1U << \
bogdanm 85:024bf7f99721 453 (((uint16_t)(__IT__)) & USART_IT_MASK)))
bogdanm 85:024bf7f99721 454
bogdanm 85:024bf7f99721 455
Kojto 108:34e6b704fe68 456 /** @brief Clear the specified USART ISR flag, in setting the proper ICR register flag.
bogdanm 85:024bf7f99721 457 * @param __HANDLE__: specifies the USART Handle.
bogdanm 85:024bf7f99721 458 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
Kojto 108:34e6b704fe68 459 * to clear the corresponding interrupt.
bogdanm 85:024bf7f99721 460 * This parameter can be one of the following values:
<> 134:ad3be0349dc5 461 * @arg @ref USART_CLEAR_PEF Parity Error Clear Flag
<> 134:ad3be0349dc5 462 * @arg @ref USART_CLEAR_FEF Framing Error Clear Flag
<> 134:ad3be0349dc5 463 * @arg @ref USART_CLEAR_NEF Noise detected Clear Flag
<> 134:ad3be0349dc5 464 * @arg @ref USART_CLEAR_OREF OverRun Error Clear Flag
<> 134:ad3be0349dc5 465 * @arg @ref USART_CLEAR_IDLEF IDLE line detected Clear Flag
<> 134:ad3be0349dc5 466 * @arg @ref USART_CLEAR_TCF Transmission Complete Clear Flag
<> 134:ad3be0349dc5 467 * @arg @ref USART_CLEAR_CTSF CTS Interrupt Clear Flag
bogdanm 85:024bf7f99721 468 * @retval None
bogdanm 85:024bf7f99721 469 */
Kojto 108:34e6b704fe68 470 #define __HAL_USART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
bogdanm 85:024bf7f99721 471
bogdanm 85:024bf7f99721 472 /** @brief Set a specific USART request flag.
bogdanm 85:024bf7f99721 473 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 474 * @param __REQ__: specifies the request flag to set.
bogdanm 85:024bf7f99721 475 * This parameter can be one of the following values:
<> 134:ad3be0349dc5 476 * @arg @ref USART_RXDATA_FLUSH_REQUEST Receive Data flush Request
<> 134:ad3be0349dc5 477 @if STM32F030x6
<> 134:ad3be0349dc5 478 @elseif STM32F030x8
<> 134:ad3be0349dc5 479 @elseif STM32F030xC
<> 134:ad3be0349dc5 480 @elseif STM32F070x6
<> 134:ad3be0349dc5 481 @elseif STM32F070xB
<> 134:ad3be0349dc5 482 @else
<> 134:ad3be0349dc5 483 * @arg @ref USART_TXDATA_FLUSH_REQUEST Transmit data flush Request
<> 134:ad3be0349dc5 484 @endif
bogdanm 85:024bf7f99721 485 *
bogdanm 85:024bf7f99721 486 * @retval None
Kojto 108:34e6b704fe68 487 */
Kojto 108:34e6b704fe68 488 #define __HAL_USART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (__REQ__))
bogdanm 85:024bf7f99721 489
Kojto 108:34e6b704fe68 490 /** @brief Enable the USART one bit sample method.
Kojto 108:34e6b704fe68 491 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 492 * @retval None
<> 134:ad3be0349dc5 493 */
Kojto 108:34e6b704fe68 494 #define __HAL_USART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
Kojto 108:34e6b704fe68 495
Kojto 108:34e6b704fe68 496 /** @brief Disable the USART one bit sample method.
Kojto 108:34e6b704fe68 497 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 498 * @retval None
<> 134:ad3be0349dc5 499 */
Kojto 108:34e6b704fe68 500 #define __HAL_USART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
Kojto 108:34e6b704fe68 501
Kojto 108:34e6b704fe68 502 /** @brief Enable USART.
bogdanm 85:024bf7f99721 503 * @param __HANDLE__: specifies the USART Handle.
bogdanm 85:024bf7f99721 504 * @retval None
Kojto 108:34e6b704fe68 505 */
Kojto 108:34e6b704fe68 506 #define __HAL_USART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
bogdanm 85:024bf7f99721 507
Kojto 108:34e6b704fe68 508 /** @brief Disable USART.
bogdanm 85:024bf7f99721 509 * @param __HANDLE__: specifies the USART Handle.
bogdanm 85:024bf7f99721 510 * @retval None
Kojto 108:34e6b704fe68 511 */
Kojto 108:34e6b704fe68 512 #define __HAL_USART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
bogdanm 92:4fc01daae5a5 513
bogdanm 92:4fc01daae5a5 514 /**
bogdanm 92:4fc01daae5a5 515 * @}
Kojto 108:34e6b704fe68 516 */
bogdanm 92:4fc01daae5a5 517
bogdanm 92:4fc01daae5a5 518 /* Private macros --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 519 /** @defgroup USART_Private_Macros USART Private Macros
bogdanm 92:4fc01daae5a5 520 * @{
bogdanm 92:4fc01daae5a5 521 */
bogdanm 85:024bf7f99721 522
<> 134:ad3be0349dc5 523 /** @brief Check USART Baud rate.
Kojto 108:34e6b704fe68 524 * @param __BAUDRATE__: Baudrate specified by the user.
Kojto 122:f9eeca106725 525 * The maximum Baud Rate is derived from the maximum clock on F0 (i.e. 48 MHz)
Kojto 108:34e6b704fe68 526 * divided by the smallest oversampling used on the USART (i.e. 8)
Kojto 108:34e6b704fe68 527 * @retval Test result (TRUE or FALSE).
Kojto 122:f9eeca106725 528 */
<> 134:ad3be0349dc5 529 #define IS_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 6000001U)
Kojto 108:34e6b704fe68 530
bogdanm 85:024bf7f99721 531 /**
Kojto 108:34e6b704fe68 532 * @brief Ensure that USART frame number of stop bits is valid.
Kojto 108:34e6b704fe68 533 * @param __STOPBITS__: USART frame number of stop bits.
Kojto 108:34e6b704fe68 534 * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
bogdanm 85:024bf7f99721 535 */
Kojto 122:f9eeca106725 536 #ifdef USART_SMARTCARD_SUPPORT
Kojto 122:f9eeca106725 537 #define IS_USART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == USART_STOPBITS_0_5) || \
Kojto 122:f9eeca106725 538 ((__STOPBITS__) == USART_STOPBITS_1) || \
Kojto 108:34e6b704fe68 539 ((__STOPBITS__) == USART_STOPBITS_1_5) || \
Kojto 108:34e6b704fe68 540 ((__STOPBITS__) == USART_STOPBITS_2))
Kojto 122:f9eeca106725 541 #else
Kojto 122:f9eeca106725 542 #define IS_USART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == USART_STOPBITS_1) || \
Kojto 122:f9eeca106725 543 ((__STOPBITS__) == USART_STOPBITS_2))
Kojto 122:f9eeca106725 544 #endif
Kojto 108:34e6b704fe68 545
Kojto 108:34e6b704fe68 546 /**
Kojto 108:34e6b704fe68 547 * @brief Ensure that USART frame parity is valid.
Kojto 108:34e6b704fe68 548 * @param __PARITY__: USART frame parity.
Kojto 108:34e6b704fe68 549 * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
Kojto 108:34e6b704fe68 550 */
Kojto 108:34e6b704fe68 551 #define IS_USART_PARITY(__PARITY__) (((__PARITY__) == USART_PARITY_NONE) || \
Kojto 108:34e6b704fe68 552 ((__PARITY__) == USART_PARITY_EVEN) || \
Kojto 108:34e6b704fe68 553 ((__PARITY__) == USART_PARITY_ODD))
bogdanm 85:024bf7f99721 554
Kojto 108:34e6b704fe68 555 /**
Kojto 108:34e6b704fe68 556 * @brief Ensure that USART communication mode is valid.
Kojto 108:34e6b704fe68 557 * @param __MODE__: USART communication mode.
Kojto 108:34e6b704fe68 558 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 108:34e6b704fe68 559 */
<> 134:ad3be0349dc5 560 #define IS_USART_MODE(__MODE__) ((((__MODE__) & 0xFFFFFFF3U) == 0x00U) && ((__MODE__) != 0x00U))
Kojto 108:34e6b704fe68 561
Kojto 108:34e6b704fe68 562 /**
Kojto 108:34e6b704fe68 563 * @brief Ensure that USART clock state is valid.
Kojto 108:34e6b704fe68 564 * @param __CLOCK__: USART clock state.
Kojto 108:34e6b704fe68 565 * @retval SET (__CLOCK__ is valid) or RESET (__CLOCK__ is invalid)
Kojto 108:34e6b704fe68 566 */
Kojto 108:34e6b704fe68 567 #define IS_USART_CLOCK(__CLOCK__) (((__CLOCK__) == USART_CLOCK_DISABLE) || \
Kojto 108:34e6b704fe68 568 ((__CLOCK__) == USART_CLOCK_ENABLE))
Kojto 108:34e6b704fe68 569
Kojto 108:34e6b704fe68 570 /**
Kojto 108:34e6b704fe68 571 * @brief Ensure that USART frame polarity is valid.
Kojto 108:34e6b704fe68 572 * @param __CPOL__: USART frame polarity.
Kojto 108:34e6b704fe68 573 * @retval SET (__CPOL__ is valid) or RESET (__CPOL__ is invalid)
Kojto 108:34e6b704fe68 574 */
Kojto 108:34e6b704fe68 575 #define IS_USART_POLARITY(__CPOL__) (((__CPOL__) == USART_POLARITY_LOW) || ((__CPOL__) == USART_POLARITY_HIGH))
Kojto 108:34e6b704fe68 576
Kojto 108:34e6b704fe68 577 /**
Kojto 108:34e6b704fe68 578 * @brief Ensure that USART frame phase is valid.
Kojto 108:34e6b704fe68 579 * @param __CPHA__: USART frame phase.
Kojto 108:34e6b704fe68 580 * @retval SET (__CPHA__ is valid) or RESET (__CPHA__ is invalid)
bogdanm 92:4fc01daae5a5 581 */
Kojto 108:34e6b704fe68 582 #define IS_USART_PHASE(__CPHA__) (((__CPHA__) == USART_PHASE_1EDGE) || ((__CPHA__) == USART_PHASE_2EDGE))
bogdanm 92:4fc01daae5a5 583
Kojto 108:34e6b704fe68 584 /**
Kojto 108:34e6b704fe68 585 * @brief Ensure that USART frame last bit clock pulse setting is valid.
Kojto 108:34e6b704fe68 586 * @param __LASTBIT__: USART frame last bit clock pulse setting.
Kojto 108:34e6b704fe68 587 * @retval SET (__LASTBIT__ is valid) or RESET (__LASTBIT__ is invalid)
Kojto 108:34e6b704fe68 588 */
Kojto 108:34e6b704fe68 589 #define IS_USART_LASTBIT(__LASTBIT__) (((__LASTBIT__) == USART_LASTBIT_DISABLE) || \
Kojto 108:34e6b704fe68 590 ((__LASTBIT__) == USART_LASTBIT_ENABLE))
bogdanm 92:4fc01daae5a5 591
bogdanm 92:4fc01daae5a5 592 /**
bogdanm 92:4fc01daae5a5 593 * @}
bogdanm 92:4fc01daae5a5 594 */
bogdanm 92:4fc01daae5a5 595
<> 134:ad3be0349dc5 596 /* Include USART HAL Extended module */
Kojto 108:34e6b704fe68 597 #include "stm32f0xx_hal_usart_ex.h"
Kojto 108:34e6b704fe68 598
Kojto 108:34e6b704fe68 599 /* Exported functions --------------------------------------------------------*/
Kojto 108:34e6b704fe68 600 /** @addtogroup USART_Exported_Functions USART Exported Functions
Kojto 108:34e6b704fe68 601 * @{
Kojto 108:34e6b704fe68 602 */
Kojto 108:34e6b704fe68 603
Kojto 108:34e6b704fe68 604 /** @addtogroup USART_Exported_Functions_Group1 Initialization and de-initialization functions
bogdanm 92:4fc01daae5a5 605 * @{
bogdanm 92:4fc01daae5a5 606 */
bogdanm 92:4fc01daae5a5 607
Kojto 108:34e6b704fe68 608 /* Initialization and de-initialization functions ****************************/
Kojto 108:34e6b704fe68 609 HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart);
Kojto 108:34e6b704fe68 610 HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart);
Kojto 108:34e6b704fe68 611 void HAL_USART_MspInit(USART_HandleTypeDef *husart);
Kojto 108:34e6b704fe68 612 void HAL_USART_MspDeInit(USART_HandleTypeDef *husart);
Kojto 108:34e6b704fe68 613
Kojto 108:34e6b704fe68 614 /**
Kojto 108:34e6b704fe68 615 * @}
Kojto 108:34e6b704fe68 616 */
Kojto 108:34e6b704fe68 617
Kojto 108:34e6b704fe68 618 /** @addtogroup USART_Exported_Functions_Group2 IO operation functions
Kojto 108:34e6b704fe68 619 * @{
Kojto 108:34e6b704fe68 620 */
Kojto 108:34e6b704fe68 621
Kojto 108:34e6b704fe68 622 /* IO operation functions *****************************************************/
bogdanm 85:024bf7f99721 623 HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout);
bogdanm 85:024bf7f99721 624 HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
bogdanm 85:024bf7f99721 625 HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
bogdanm 85:024bf7f99721 626 HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
bogdanm 85:024bf7f99721 627 HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
bogdanm 85:024bf7f99721 628 HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
bogdanm 85:024bf7f99721 629 HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
bogdanm 85:024bf7f99721 630 HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
bogdanm 85:024bf7f99721 631 HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
bogdanm 85:024bf7f99721 632 HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart);
bogdanm 85:024bf7f99721 633 HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart);
bogdanm 85:024bf7f99721 634 HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart);
<> 134:ad3be0349dc5 635 /* Transfer Abort functions */
<> 134:ad3be0349dc5 636 HAL_StatusTypeDef HAL_USART_Abort(USART_HandleTypeDef *husart);
<> 134:ad3be0349dc5 637 HAL_StatusTypeDef HAL_USART_Abort_IT(USART_HandleTypeDef *husart);
<> 134:ad3be0349dc5 638
bogdanm 85:024bf7f99721 639 void HAL_USART_IRQHandler(USART_HandleTypeDef *husart);
bogdanm 85:024bf7f99721 640 void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart);
bogdanm 85:024bf7f99721 641 void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart);
bogdanm 85:024bf7f99721 642 void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart);
bogdanm 85:024bf7f99721 643 void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart);
bogdanm 85:024bf7f99721 644 void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart);
bogdanm 85:024bf7f99721 645 void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart);
<> 134:ad3be0349dc5 646 void HAL_USART_AbortCpltCallback (USART_HandleTypeDef *husart);
bogdanm 85:024bf7f99721 647
bogdanm 92:4fc01daae5a5 648 /**
bogdanm 92:4fc01daae5a5 649 * @}
bogdanm 92:4fc01daae5a5 650 */
bogdanm 92:4fc01daae5a5 651
bogdanm 85:024bf7f99721 652 /* Peripheral Control functions ***********************************************/
bogdanm 85:024bf7f99721 653
Kojto 122:f9eeca106725 654 /** @addtogroup USART_Exported_Functions_Group3 Peripheral State and Error functions
bogdanm 92:4fc01daae5a5 655 * @{
bogdanm 92:4fc01daae5a5 656 */
bogdanm 92:4fc01daae5a5 657
bogdanm 85:024bf7f99721 658 /* Peripheral State and Error functions ***************************************/
bogdanm 85:024bf7f99721 659 HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart);
Kojto 108:34e6b704fe68 660 uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart);
bogdanm 85:024bf7f99721 661
bogdanm 85:024bf7f99721 662 /**
bogdanm 85:024bf7f99721 663 * @}
bogdanm 85:024bf7f99721 664 */
Kojto 108:34e6b704fe68 665
bogdanm 92:4fc01daae5a5 666 /**
bogdanm 92:4fc01daae5a5 667 * @}
Kojto 108:34e6b704fe68 668 */
Kojto 108:34e6b704fe68 669
Kojto 108:34e6b704fe68 670 /**
Kojto 108:34e6b704fe68 671 * @}
Kojto 108:34e6b704fe68 672 */
bogdanm 92:4fc01daae5a5 673
bogdanm 92:4fc01daae5a5 674 /**
bogdanm 92:4fc01daae5a5 675 * @}
bogdanm 92:4fc01daae5a5 676 */
bogdanm 92:4fc01daae5a5 677
bogdanm 85:024bf7f99721 678 #ifdef __cplusplus
bogdanm 85:024bf7f99721 679 }
bogdanm 85:024bf7f99721 680 #endif
bogdanm 85:024bf7f99721 681
bogdanm 85:024bf7f99721 682 #endif /* __STM32F0xx_HAL_USART_H */
bogdanm 85:024bf7f99721 683
bogdanm 85:024bf7f99721 684 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
bogdanm 92:4fc01daae5a5 685