mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
108:34e6b704fe68
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 90:cb3d968589d8 1 /**
Kojto 90:cb3d968589d8 2 ******************************************************************************
Kojto 90:cb3d968589d8 3 * @file stm32f0xx_hal_usart.h
Kojto 90:cb3d968589d8 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.4.0
Kojto 122:f9eeca106725 6 * @date 27-May-2016
Kojto 90:cb3d968589d8 7 * @brief Header file of USART HAL module.
Kojto 90:cb3d968589d8 8 ******************************************************************************
Kojto 90:cb3d968589d8 9 * @attention
Kojto 90:cb3d968589d8 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 90:cb3d968589d8 12 *
Kojto 90:cb3d968589d8 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 90:cb3d968589d8 14 * are permitted provided that the following conditions are met:
Kojto 90:cb3d968589d8 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 90:cb3d968589d8 16 * this list of conditions and the following disclaimer.
Kojto 90:cb3d968589d8 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 90:cb3d968589d8 18 * this list of conditions and the following disclaimer in the documentation
Kojto 90:cb3d968589d8 19 * and/or other materials provided with the distribution.
Kojto 90:cb3d968589d8 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 90:cb3d968589d8 21 * may be used to endorse or promote products derived from this software
Kojto 90:cb3d968589d8 22 * without specific prior written permission.
Kojto 90:cb3d968589d8 23 *
Kojto 90:cb3d968589d8 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 90:cb3d968589d8 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 90:cb3d968589d8 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 90:cb3d968589d8 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 90:cb3d968589d8 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 90:cb3d968589d8 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 90:cb3d968589d8 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 90:cb3d968589d8 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 90:cb3d968589d8 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 90:cb3d968589d8 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 90:cb3d968589d8 34 *
Kojto 108:34e6b704fe68 35 ******************************************************************************
Kojto 90:cb3d968589d8 36 */
Kojto 90:cb3d968589d8 37
Kojto 90:cb3d968589d8 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 90:cb3d968589d8 39 #ifndef __STM32F0xx_HAL_USART_H
Kojto 90:cb3d968589d8 40 #define __STM32F0xx_HAL_USART_H
Kojto 90:cb3d968589d8 41
Kojto 90:cb3d968589d8 42 #ifdef __cplusplus
Kojto 90:cb3d968589d8 43 extern "C" {
Kojto 90:cb3d968589d8 44 #endif
Kojto 90:cb3d968589d8 45
Kojto 90:cb3d968589d8 46 /* Includes ------------------------------------------------------------------*/
Kojto 90:cb3d968589d8 47 #include "stm32f0xx_hal_def.h"
Kojto 90:cb3d968589d8 48
Kojto 90:cb3d968589d8 49 /** @addtogroup STM32F0xx_HAL_Driver
Kojto 90:cb3d968589d8 50 * @{
Kojto 90:cb3d968589d8 51 */
Kojto 90:cb3d968589d8 52
Kojto 90:cb3d968589d8 53 /** @addtogroup USART
Kojto 90:cb3d968589d8 54 * @{
Kojto 108:34e6b704fe68 55 */
Kojto 90:cb3d968589d8 56
Kojto 90:cb3d968589d8 57 /* Exported types ------------------------------------------------------------*/
Kojto 90:cb3d968589d8 58 /** @defgroup USART_Exported_Types USART Exported Types
Kojto 90:cb3d968589d8 59 * @{
Kojto 108:34e6b704fe68 60 */
Kojto 90:cb3d968589d8 61
Kojto 108:34e6b704fe68 62 /**
Kojto 108:34e6b704fe68 63 * @brief USART Init Structure definition
Kojto 108:34e6b704fe68 64 */
Kojto 90:cb3d968589d8 65 typedef struct
Kojto 90:cb3d968589d8 66 {
Kojto 90:cb3d968589d8 67 uint32_t BaudRate; /*!< This member configures the Usart communication baud rate.
Kojto 90:cb3d968589d8 68 The baud rate is computed using the following formula:
Kojto 108:34e6b704fe68 69 Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate))). */
Kojto 90:cb3d968589d8 70
Kojto 90:cb3d968589d8 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. */
Kojto 90:cb3d968589d8 73
Kojto 90:cb3d968589d8 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. */
Kojto 90:cb3d968589d8 76
Kojto 90:cb3d968589d8 77 uint32_t Parity; /*!< Specifies the parity mode.
Kojto 90:cb3d968589d8 78 This parameter can be a value of @ref USART_Parity
Kojto 90:cb3d968589d8 79 @note When parity is enabled, the computed parity is inserted
Kojto 90:cb3d968589d8 80 at the MSB position of the transmitted data (9th bit when
Kojto 90:cb3d968589d8 81 the word length is set to 9 data bits; 8th bit when the
Kojto 90:cb3d968589d8 82 word length is set to 8 data bits). */
Kojto 108:34e6b704fe68 83
Kojto 90:cb3d968589d8 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. */
Kojto 90:cb3d968589d8 86
Kojto 90:cb3d968589d8 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. */
Kojto 90:cb3d968589d8 89
Kojto 90:cb3d968589d8 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. */
Kojto 90:cb3d968589d8 92
Kojto 90:cb3d968589d8 93 uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
Kojto 90:cb3d968589d8 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. */
Kojto 90:cb3d968589d8 96 }USART_InitTypeDef;
Kojto 90:cb3d968589d8 97
Kojto 108:34e6b704fe68 98 /**
Kojto 108:34e6b704fe68 99 * @brief HAL USART State structures definition
Kojto 108:34e6b704fe68 100 */
Kojto 90:cb3d968589d8 101 typedef enum
Kojto 90:cb3d968589d8 102 {
Kojto 108:34e6b704fe68 103 HAL_USART_STATE_RESET = 0x00, /*!< Peripheral is not initialized */
Kojto 108:34e6b704fe68 104 HAL_USART_STATE_READY = 0x01, /*!< Peripheral Initialized and ready for use */
Kojto 108:34e6b704fe68 105 HAL_USART_STATE_BUSY = 0x02, /*!< an internal process is ongoing */
Kojto 108:34e6b704fe68 106 HAL_USART_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
Kojto 108:34e6b704fe68 107 HAL_USART_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
Kojto 90:cb3d968589d8 108 HAL_USART_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission Reception process is ongoing */
Kojto 108:34e6b704fe68 109 HAL_USART_STATE_TIMEOUT = 0x03, /*!< Timeout state */
Kojto 108:34e6b704fe68 110 HAL_USART_STATE_ERROR = 0x04 /*!< Error */
Kojto 90:cb3d968589d8 111 }HAL_USART_StateTypeDef;
Kojto 90:cb3d968589d8 112
Kojto 108:34e6b704fe68 113 /**
Kojto 90:cb3d968589d8 114 * @brief USART clock sources definitions
Kojto 90:cb3d968589d8 115 */
Kojto 90:cb3d968589d8 116 typedef enum
Kojto 90:cb3d968589d8 117 {
Kojto 90:cb3d968589d8 118 USART_CLOCKSOURCE_PCLK1 = 0x00, /*!< PCLK1 clock source */
Kojto 90:cb3d968589d8 119 USART_CLOCKSOURCE_HSI = 0x02, /*!< HSI clock source */
Kojto 90:cb3d968589d8 120 USART_CLOCKSOURCE_SYSCLK = 0x04, /*!< SYSCLK clock source */
Kojto 90:cb3d968589d8 121 USART_CLOCKSOURCE_LSE = 0x08, /*!< LSE clock source */
Kojto 108:34e6b704fe68 122 USART_CLOCKSOURCE_UNDEFINED = 0x10 /*!< undefined clock source */
Kojto 90:cb3d968589d8 123 }USART_ClockSourceTypeDef;
Kojto 90:cb3d968589d8 124
Kojto 108:34e6b704fe68 125
Kojto 108:34e6b704fe68 126 /**
Kojto 108:34e6b704fe68 127 * @brief USART handle Structure definition
Kojto 108:34e6b704fe68 128 */
Kojto 90:cb3d968589d8 129 typedef struct
Kojto 90:cb3d968589d8 130 {
Kojto 90:cb3d968589d8 131 USART_TypeDef *Instance; /*!< USART registers base address */
Kojto 108:34e6b704fe68 132
Kojto 90:cb3d968589d8 133 USART_InitTypeDef Init; /*!< USART communication parameters */
Kojto 108:34e6b704fe68 134
Kojto 90:cb3d968589d8 135 uint8_t *pTxBuffPtr; /*!< Pointer to USART Tx transfer Buffer */
Kojto 108:34e6b704fe68 136
Kojto 90:cb3d968589d8 137 uint16_t TxXferSize; /*!< USART Tx Transfer size */
Kojto 108:34e6b704fe68 138
Kojto 90:cb3d968589d8 139 uint16_t TxXferCount; /*!< USART Tx Transfer Counter */
Kojto 108:34e6b704fe68 140
Kojto 90:cb3d968589d8 141 uint8_t *pRxBuffPtr; /*!< Pointer to USART Rx transfer Buffer */
Kojto 108:34e6b704fe68 142
Kojto 90:cb3d968589d8 143 uint16_t RxXferSize; /*!< USART Rx Transfer size */
Kojto 108:34e6b704fe68 144
Kojto 90:cb3d968589d8 145 uint16_t RxXferCount; /*!< USART Rx Transfer Counter */
Kojto 108:34e6b704fe68 146
Kojto 90:cb3d968589d8 147 uint16_t Mask; /*!< USART Rx RDR register mask */
Kojto 108:34e6b704fe68 148
Kojto 90:cb3d968589d8 149 DMA_HandleTypeDef *hdmatx; /*!< USART Tx DMA Handle parameters */
Kojto 108:34e6b704fe68 150
Kojto 90:cb3d968589d8 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
Kojto 108:34e6b704fe68 155 __IO HAL_USART_StateTypeDef State; /*!< USART communication state */
Kojto 108:34e6b704fe68 156
Kojto 108:34e6b704fe68 157 __IO uint32_t ErrorCode; /*!< USART Error code */
Kojto 108:34e6b704fe68 158
Kojto 90:cb3d968589d8 159 }USART_HandleTypeDef;
Kojto 90:cb3d968589d8 160
Kojto 90:cb3d968589d8 161 /**
Kojto 90:cb3d968589d8 162 * @}
Kojto 90:cb3d968589d8 163 */
Kojto 90:cb3d968589d8 164
Kojto 90:cb3d968589d8 165 /* Exported constants --------------------------------------------------------*/
Kojto 108:34e6b704fe68 166 /** @defgroup USART_Exported_Constants USART Exported Constants
Kojto 90:cb3d968589d8 167 * @{
Kojto 90:cb3d968589d8 168 */
Kojto 90:cb3d968589d8 169
Kojto 93:e188a91d3eaa 170 /** @defgroup USART_Error USART Error
Kojto 93:e188a91d3eaa 171 * @{
Kojto 93:e188a91d3eaa 172 */
Kojto 93:e188a91d3eaa 173 #define HAL_USART_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
Kojto 93:e188a91d3eaa 174 #define HAL_USART_ERROR_PE ((uint32_t)0x00000001) /*!< Parity error */
Kojto 93:e188a91d3eaa 175 #define HAL_USART_ERROR_NE ((uint32_t)0x00000002) /*!< Noise error */
Kojto 93:e188a91d3eaa 176 #define HAL_USART_ERROR_FE ((uint32_t)0x00000004) /*!< frame error */
Kojto 93:e188a91d3eaa 177 #define HAL_USART_ERROR_ORE ((uint32_t)0x00000008) /*!< Overrun error */
Kojto 93:e188a91d3eaa 178 #define HAL_USART_ERROR_DMA ((uint32_t)0x00000010) /*!< DMA transfer error */
Kojto 93:e188a91d3eaa 179 /**
Kojto 93:e188a91d3eaa 180 * @}
Kojto 93:e188a91d3eaa 181 */
Kojto 93:e188a91d3eaa 182
Kojto 90:cb3d968589d8 183 /** @defgroup USART_Stop_Bits USART Number of Stop Bits
Kojto 90:cb3d968589d8 184 * @{
Kojto 90:cb3d968589d8 185 */
Kojto 122:f9eeca106725 186 #ifdef USART_SMARTCARD_SUPPORT
Kojto 122:f9eeca106725 187 #define USART_STOPBITS_0_5 ((uint32_t)USART_CR2_STOP_0) /*!< USART frame with 0.5 stop bit */
Kojto 122:f9eeca106725 188 #define USART_STOPBITS_1 ((uint32_t)0x00000000) /*!< USART frame with 1 stop bit */
Kojto 122:f9eeca106725 189 #define USART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1)) /*!< USART frame with 1.5 stop bits */
Kojto 122:f9eeca106725 190 #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) /*!< USART frame with 2 stop bits */
Kojto 122:f9eeca106725 191 #else
Kojto 122:f9eeca106725 192 #define USART_STOPBITS_1 ((uint32_t)0x00000000) /*!< USART frame with 1 stop bit */
Kojto 122:f9eeca106725 193 #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) /*!< USART frame with 2 stop bits */
Kojto 122:f9eeca106725 194 #endif
Kojto 90:cb3d968589d8 195 /**
Kojto 90:cb3d968589d8 196 * @}
Kojto 122:f9eeca106725 197 */
Kojto 90:cb3d968589d8 198
Kojto 90:cb3d968589d8 199 /** @defgroup USART_Parity USART Parity
Kojto 90:cb3d968589d8 200 * @{
Kojto 108:34e6b704fe68 201 */
Kojto 108:34e6b704fe68 202 #define USART_PARITY_NONE ((uint32_t)0x00000000) /*!< 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 */
Kojto 90:cb3d968589d8 205 /**
Kojto 90:cb3d968589d8 206 * @}
Kojto 108:34e6b704fe68 207 */
Kojto 90:cb3d968589d8 208
Kojto 90:cb3d968589d8 209 /** @defgroup USART_Mode USART Mode
Kojto 90:cb3d968589d8 210 * @{
Kojto 108:34e6b704fe68 211 */
Kojto 108:34e6b704fe68 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 */
Kojto 90:cb3d968589d8 215 /**
Kojto 90:cb3d968589d8 216 * @}
Kojto 90:cb3d968589d8 217 */
Kojto 108:34e6b704fe68 218
Kojto 90:cb3d968589d8 219 /** @defgroup USART_Clock USART Clock
Kojto 90:cb3d968589d8 220 * @{
Kojto 108:34e6b704fe68 221 */
Kojto 108:34e6b704fe68 222 #define USART_CLOCK_DISABLE ((uint32_t)0x00000000) /*!< USART clock disable */
Kojto 108:34e6b704fe68 223 #define USART_CLOCK_ENABLE ((uint32_t)USART_CR2_CLKEN) /*!< USART clock enable */
Kojto 90:cb3d968589d8 224 /**
Kojto 90:cb3d968589d8 225 * @}
Kojto 108:34e6b704fe68 226 */
Kojto 90:cb3d968589d8 227
Kojto 90:cb3d968589d8 228 /** @defgroup USART_Clock_Polarity USART Clock Polarity
Kojto 90:cb3d968589d8 229 * @{
Kojto 90:cb3d968589d8 230 */
Kojto 108:34e6b704fe68 231 #define USART_POLARITY_LOW ((uint32_t)0x00000000) /*!< USART Clock signal is steady Low */
Kojto 108:34e6b704fe68 232 #define USART_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL) /*!< USART Clock signal is steady High */
Kojto 90:cb3d968589d8 233 /**
Kojto 90:cb3d968589d8 234 * @}
Kojto 108:34e6b704fe68 235 */
Kojto 90:cb3d968589d8 236
Kojto 90:cb3d968589d8 237 /** @defgroup USART_Clock_Phase USART Clock Phase
Kojto 90:cb3d968589d8 238 * @{
Kojto 90:cb3d968589d8 239 */
Kojto 108:34e6b704fe68 240 #define USART_PHASE_1EDGE ((uint32_t)0x00000000) /*!< 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 */
Kojto 90:cb3d968589d8 242 /**
Kojto 90:cb3d968589d8 243 * @}
Kojto 90:cb3d968589d8 244 */
Kojto 90:cb3d968589d8 245
Kojto 90:cb3d968589d8 246 /** @defgroup USART_Last_Bit USART Last Bit
Kojto 90:cb3d968589d8 247 * @{
Kojto 90:cb3d968589d8 248 */
Kojto 108:34e6b704fe68 249 #define USART_LASTBIT_DISABLE ((uint32_t)0x00000000) /*!< 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 */
Kojto 90:cb3d968589d8 251 /**
Kojto 90:cb3d968589d8 252 * @}
Kojto 90:cb3d968589d8 253 */
Kojto 90:cb3d968589d8 254
Kojto 90:cb3d968589d8 255 /** @defgroup USART_Interrupt_definition USART Interrupts Definition
Kojto 90:cb3d968589d8 256 * Elements values convention: 0000ZZZZ0XXYYYYYb
Kojto 90:cb3d968589d8 257 * - YYYYY : Interrupt source position in the XX register (5bits)
Kojto 90:cb3d968589d8 258 * - XX : Interrupt source register (2bits)
Kojto 90:cb3d968589d8 259 * - 01: CR1 register
Kojto 90:cb3d968589d8 260 * - 10: CR2 register
Kojto 90:cb3d968589d8 261 * - 11: CR3 register
Kojto 90:cb3d968589d8 262 * - ZZZZ : Flag position in the ISR register(4bits)
Kojto 90:cb3d968589d8 263 * @{
Kojto 90:cb3d968589d8 264 */
Kojto 90:cb3d968589d8 265
Kojto 108:34e6b704fe68 266 #define USART_IT_PE ((uint16_t)0x0028) /*!< USART parity error interruption */
Kojto 108:34e6b704fe68 267 #define USART_IT_TXE ((uint16_t)0x0727) /*!< USART transmit data register empty interruption */
Kojto 108:34e6b704fe68 268 #define USART_IT_TC ((uint16_t)0x0626) /*!< USART transmission complete interruption */
Kojto 108:34e6b704fe68 269 #define USART_IT_RXNE ((uint16_t)0x0525) /*!< USART read data register not empty interruption */
Kojto 108:34e6b704fe68 270 #define USART_IT_IDLE ((uint16_t)0x0424) /*!< USART idle interruption */
Kojto 108:34e6b704fe68 271 #define USART_IT_ERR ((uint16_t)0x0060) /*!< USART error interruption */
Kojto 108:34e6b704fe68 272 #define USART_IT_ORE ((uint16_t)0x0300) /*!< USART overrun error interruption */
Kojto 108:34e6b704fe68 273 #define USART_IT_NE ((uint16_t)0x0200) /*!< USART noise error interruption */
Kojto 108:34e6b704fe68 274 #define USART_IT_FE ((uint16_t)0x0100) /*!< USART frame error interruption */
Kojto 90:cb3d968589d8 275 /**
Kojto 90:cb3d968589d8 276 * @}
Kojto 90:cb3d968589d8 277 */
Kojto 90:cb3d968589d8 278
Kojto 90:cb3d968589d8 279 /** @defgroup USART_IT_CLEAR_Flags USART Interruption Clear Flags
Kojto 90:cb3d968589d8 280 * @{
Kojto 90:cb3d968589d8 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 */
Kojto 90:cb3d968589d8 289 /**
Kojto 90:cb3d968589d8 290 * @}
Kojto 90:cb3d968589d8 291 */
Kojto 90:cb3d968589d8 292
Kojto 108:34e6b704fe68 293 /** @defgroup USART_Interruption_Mask USART Interruption Flags Mask
Kojto 90:cb3d968589d8 294 * @{
Kojto 108:34e6b704fe68 295 */
Kojto 108:34e6b704fe68 296 #define USART_IT_MASK ((uint16_t)0x001F) /*!< USART interruptions flags mask */
Kojto 90:cb3d968589d8 297 /**
Kojto 90:cb3d968589d8 298 * @}
Kojto 90:cb3d968589d8 299 */
Kojto 90:cb3d968589d8 300
Kojto 90:cb3d968589d8 301 /**
Kojto 90:cb3d968589d8 302 * @}
Kojto 90:cb3d968589d8 303 */
Kojto 108:34e6b704fe68 304
Kojto 108:34e6b704fe68 305 /* Exported macros -----------------------------------------------------------*/
Kojto 90:cb3d968589d8 306 /** @defgroup USART_Exported_Macros USART Exported Macros
Kojto 90:cb3d968589d8 307 * @{
Kojto 108:34e6b704fe68 308 */
Kojto 90:cb3d968589d8 309
Kojto 108:34e6b704fe68 310 /** @brief Reset USART handle state.
Kojto 90:cb3d968589d8 311 * @param __HANDLE__: USART handle.
Kojto 90:cb3d968589d8 312 * @retval None
Kojto 90:cb3d968589d8 313 */
Kojto 108:34e6b704fe68 314 #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET)
Kojto 90:cb3d968589d8 315
Kojto 108:34e6b704fe68 316 /** @brief Check whether the specified USART flag is set or not.
Kojto 90:cb3d968589d8 317 * @param __HANDLE__: specifies the USART Handle
Kojto 90:cb3d968589d8 318 * @param __FLAG__: specifies the flag to check.
Kojto 90:cb3d968589d8 319 * This parameter can be one of the following values:
Kojto 108:34e6b704fe68 320 * @arg USART_FLAG_REACK: Receive enable acknowledge flag
Kojto 108:34e6b704fe68 321 * @arg USART_FLAG_TEACK: Transmit enable acknowledge flag
Kojto 108:34e6b704fe68 322 * @arg USART_FLAG_BUSY: Busy flag
Kojto 108:34e6b704fe68 323 * @arg USART_FLAG_CTS: CTS Change flag
Kojto 90:cb3d968589d8 324 * @arg USART_FLAG_TXE: Transmit data register empty flag
Kojto 90:cb3d968589d8 325 * @arg USART_FLAG_TC: Transmission Complete flag
Kojto 90:cb3d968589d8 326 * @arg USART_FLAG_RXNE: Receive data register not empty flag
Kojto 90:cb3d968589d8 327 * @arg USART_FLAG_IDLE: Idle Line detection flag
Kojto 90:cb3d968589d8 328 * @arg USART_FLAG_ORE: OverRun Error flag
Kojto 90:cb3d968589d8 329 * @arg USART_FLAG_NE: Noise Error flag
Kojto 90:cb3d968589d8 330 * @arg USART_FLAG_FE: Framing Error flag
Kojto 90:cb3d968589d8 331 * @arg USART_FLAG_PE: Parity Error flag
Kojto 90:cb3d968589d8 332 * @retval The new state of __FLAG__ (TRUE or FALSE).
Kojto 90:cb3d968589d8 333 */
Kojto 90:cb3d968589d8 334 #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
Kojto 90:cb3d968589d8 335
Kojto 108:34e6b704fe68 336 /** @brief Clear the specified USART pending flag.
Kojto 108:34e6b704fe68 337 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 338 * @param __FLAG__: specifies the flag to check.
Kojto 108:34e6b704fe68 339 * This parameter can be any combination of the following values:
Kojto 108:34e6b704fe68 340 * @arg USART_CLEAR_PEF
Kojto 108:34e6b704fe68 341 * @arg USART_CLEAR_FEF
Kojto 108:34e6b704fe68 342 * @arg USART_CLEAR_NEF
Kojto 108:34e6b704fe68 343 * @arg USART_CLEAR_OREF
Kojto 108:34e6b704fe68 344 * @arg USART_CLEAR_IDLEF
Kojto 108:34e6b704fe68 345 * @arg USART_CLEAR_TCF
Kojto 108:34e6b704fe68 346 * @arg USART_CLEAR_CTSF
Kojto 108:34e6b704fe68 347 * @arg USART_CLEAR_RTOF
Kojto 108:34e6b704fe68 348 * @arg USART_CLEAR_EOBF
Kojto 108:34e6b704fe68 349 * @arg USART_CLEAR_CMF
Kojto 108:34e6b704fe68 350 * @arg USART_CLEAR_WUF
Kojto 108:34e6b704fe68 351 * @retval None
Kojto 108:34e6b704fe68 352 */
Kojto 108:34e6b704fe68 353 #define __HAL_USART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
Kojto 90:cb3d968589d8 354
Kojto 108:34e6b704fe68 355 /** @brief Clear the USART PE pending flag.
Kojto 108:34e6b704fe68 356 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 357 * @retval None
Kojto 108:34e6b704fe68 358 */
Kojto 108:34e6b704fe68 359 #define __HAL_USART_CLEAR_PEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_PEF)
Kojto 108:34e6b704fe68 360
Kojto 108:34e6b704fe68 361 /** @brief Clear the USART FE pending flag.
Kojto 108:34e6b704fe68 362 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 363 * @retval None
Kojto 108:34e6b704fe68 364 */
Kojto 108:34e6b704fe68 365 #define __HAL_USART_CLEAR_FEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_FEF)
Kojto 108:34e6b704fe68 366
Kojto 108:34e6b704fe68 367 /** @brief Clear the USART NE pending flag.
Kojto 108:34e6b704fe68 368 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 369 * @retval None
Kojto 108:34e6b704fe68 370 */
Kojto 108:34e6b704fe68 371 #define __HAL_USART_CLEAR_NEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_NEF)
Kojto 108:34e6b704fe68 372
Kojto 108:34e6b704fe68 373 /** @brief Clear the USART ORE pending flag.
Kojto 108:34e6b704fe68 374 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 375 * @retval None
Kojto 108:34e6b704fe68 376 */
Kojto 108:34e6b704fe68 377 #define __HAL_USART_CLEAR_OREFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_OREF)
Kojto 108:34e6b704fe68 378
Kojto 108:34e6b704fe68 379 /** @brief Clear the USART IDLE pending flag.
Kojto 108:34e6b704fe68 380 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 381 * @retval None
Kojto 108:34e6b704fe68 382 */
Kojto 108:34e6b704fe68 383 #define __HAL_USART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_IDLEF)
Kojto 108:34e6b704fe68 384
Kojto 108:34e6b704fe68 385 /** @brief Enable the specified USART interrupt.
Kojto 108:34e6b704fe68 386 * @param __HANDLE__: specifies the USART Handle.
Kojto 90:cb3d968589d8 387 * @param __INTERRUPT__: specifies the USART interrupt source to enable.
Kojto 90:cb3d968589d8 388 * This parameter can be one of the following values:
Kojto 90:cb3d968589d8 389 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
Kojto 90:cb3d968589d8 390 * @arg USART_IT_TC: Transmission complete interrupt
Kojto 90:cb3d968589d8 391 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
Kojto 90:cb3d968589d8 392 * @arg USART_IT_IDLE: Idle line detection interrupt
Kojto 90:cb3d968589d8 393 * @arg USART_IT_PE: Parity Error interrupt
Kojto 90:cb3d968589d8 394 * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
Kojto 90:cb3d968589d8 395 * @retval None
Kojto 90:cb3d968589d8 396 */
Kojto 90:cb3d968589d8 397 #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
Kojto 90:cb3d968589d8 398 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
Kojto 90:cb3d968589d8 399 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))))
Kojto 90:cb3d968589d8 400
Kojto 108:34e6b704fe68 401 /** @brief Disable the specified USART interrupt.
Kojto 90:cb3d968589d8 402 * @param __HANDLE__: specifies the USART Handle.
Kojto 90:cb3d968589d8 403 * @param __INTERRUPT__: specifies the USART interrupt source to disable.
Kojto 90:cb3d968589d8 404 * This parameter can be one of the following values:
Kojto 90:cb3d968589d8 405 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
Kojto 90:cb3d968589d8 406 * @arg USART_IT_TC: Transmission complete interrupt
Kojto 90:cb3d968589d8 407 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
Kojto 90:cb3d968589d8 408 * @arg USART_IT_IDLE: Idle line detection interrupt
Kojto 90:cb3d968589d8 409 * @arg USART_IT_PE: Parity Error interrupt
Kojto 90:cb3d968589d8 410 * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
Kojto 90:cb3d968589d8 411 * @retval None
Kojto 90:cb3d968589d8 412 */
Kojto 90:cb3d968589d8 413 #define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
Kojto 90:cb3d968589d8 414 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
Kojto 90:cb3d968589d8 415 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))))
Kojto 90:cb3d968589d8 416
Kojto 108:34e6b704fe68 417
Kojto 108:34e6b704fe68 418 /** @brief Check whether the specified USART interrupt has occurred or not.
Kojto 108:34e6b704fe68 419 * @param __HANDLE__: specifies the USART Handle.
Kojto 90:cb3d968589d8 420 * @param __IT__: specifies the USART interrupt source to check.
Kojto 90:cb3d968589d8 421 * This parameter can be one of the following values:
Kojto 90:cb3d968589d8 422 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
Kojto 90:cb3d968589d8 423 * @arg USART_IT_TC: Transmission complete interrupt
Kojto 90:cb3d968589d8 424 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
Kojto 90:cb3d968589d8 425 * @arg USART_IT_IDLE: Idle line detection interrupt
Kojto 90:cb3d968589d8 426 * @arg USART_IT_ORE: OverRun Error interrupt
Kojto 90:cb3d968589d8 427 * @arg USART_IT_NE: Noise Error interrupt
Kojto 90:cb3d968589d8 428 * @arg USART_IT_FE: Framing Error interrupt
Kojto 90:cb3d968589d8 429 * @arg USART_IT_PE: Parity Error interrupt
Kojto 90:cb3d968589d8 430 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 90:cb3d968589d8 431 */
Kojto 108:34e6b704fe68 432 #define __HAL_USART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
Kojto 90:cb3d968589d8 433
Kojto 108:34e6b704fe68 434 /** @brief Check whether the specified USART interrupt source is enabled or not.
Kojto 90:cb3d968589d8 435 * @param __HANDLE__: specifies the USART Handle.
Kojto 90:cb3d968589d8 436 * @param __IT__: specifies the USART interrupt source to check.
Kojto 90:cb3d968589d8 437 * This parameter can be one of the following values:
Kojto 90:cb3d968589d8 438 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
Kojto 90:cb3d968589d8 439 * @arg USART_IT_TC: Transmission complete interrupt
Kojto 90:cb3d968589d8 440 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
Kojto 90:cb3d968589d8 441 * @arg USART_IT_IDLE: Idle line detection interrupt
Kojto 90:cb3d968589d8 442 * @arg USART_IT_ORE: OverRun Error interrupt
Kojto 90:cb3d968589d8 443 * @arg USART_IT_NE: Noise Error interrupt
Kojto 90:cb3d968589d8 444 * @arg USART_IT_FE: Framing Error interrupt
Kojto 90:cb3d968589d8 445 * @arg USART_IT_PE: Parity Error interrupt
Kojto 90:cb3d968589d8 446 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 90:cb3d968589d8 447 */
Kojto 90:cb3d968589d8 448 #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5) == 2)? \
Kojto 90:cb3d968589d8 449 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << \
Kojto 90:cb3d968589d8 450 (((uint16_t)(__IT__)) & USART_IT_MASK)))
Kojto 90:cb3d968589d8 451
Kojto 90:cb3d968589d8 452
Kojto 108:34e6b704fe68 453 /** @brief Clear the specified USART ISR flag, in setting the proper ICR register flag.
Kojto 90:cb3d968589d8 454 * @param __HANDLE__: specifies the USART Handle.
Kojto 90:cb3d968589d8 455 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
Kojto 108:34e6b704fe68 456 * to clear the corresponding interrupt.
Kojto 90:cb3d968589d8 457 * This parameter can be one of the following values:
Kojto 108:34e6b704fe68 458 * @arg USART_CLEAR_PEF: Parity Error Clear Flag
Kojto 108:34e6b704fe68 459 * @arg USART_CLEAR_FEF: Framing Error Clear Flag
Kojto 108:34e6b704fe68 460 * @arg USART_CLEAR_NEF: Noise detected Clear Flag
Kojto 108:34e6b704fe68 461 * @arg USART_CLEAR_OREF: OverRun Error Clear Flag
Kojto 108:34e6b704fe68 462 * @arg USART_CLEAR_IDLEF: IDLE line detected Clear Flag
Kojto 108:34e6b704fe68 463 * @arg USART_CLEAR_TCF: Transmission Complete Clear Flag
Kojto 108:34e6b704fe68 464 * @arg USART_CLEAR_CTSF: CTS Interrupt Clear Flag
Kojto 90:cb3d968589d8 465 * @retval None
Kojto 90:cb3d968589d8 466 */
Kojto 108:34e6b704fe68 467 #define __HAL_USART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
Kojto 90:cb3d968589d8 468
Kojto 90:cb3d968589d8 469 /** @brief Set a specific USART request flag.
Kojto 90:cb3d968589d8 470 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 471 * @param __REQ__: specifies the request flag to set.
Kojto 90:cb3d968589d8 472 * This parameter can be one of the following values:
Kojto 108:34e6b704fe68 473 * @arg USART_RXDATA_FLUSH_REQUEST: Receive Data flush Request
Kojto 108:34e6b704fe68 474 * @arg USART_TXDATA_FLUSH_REQUEST: Transmit data flush Request
Kojto 90:cb3d968589d8 475 *
Kojto 90:cb3d968589d8 476 * @retval None
Kojto 108:34e6b704fe68 477 */
Kojto 108:34e6b704fe68 478 #define __HAL_USART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (__REQ__))
Kojto 90:cb3d968589d8 479
Kojto 108:34e6b704fe68 480 /** @brief Enable the USART one bit sample method.
Kojto 108:34e6b704fe68 481 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 482 * @retval None
Kojto 108:34e6b704fe68 483 */
Kojto 108:34e6b704fe68 484 #define __HAL_USART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
Kojto 108:34e6b704fe68 485
Kojto 108:34e6b704fe68 486 /** @brief Disable the USART one bit sample method.
Kojto 108:34e6b704fe68 487 * @param __HANDLE__: specifies the USART Handle.
Kojto 108:34e6b704fe68 488 * @retval None
Kojto 108:34e6b704fe68 489 */
Kojto 108:34e6b704fe68 490 #define __HAL_USART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
Kojto 108:34e6b704fe68 491
Kojto 108:34e6b704fe68 492 /** @brief Enable USART.
Kojto 90:cb3d968589d8 493 * @param __HANDLE__: specifies the USART Handle.
Kojto 90:cb3d968589d8 494 * @retval None
Kojto 108:34e6b704fe68 495 */
Kojto 108:34e6b704fe68 496 #define __HAL_USART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
Kojto 90:cb3d968589d8 497
Kojto 108:34e6b704fe68 498 /** @brief Disable USART.
Kojto 90:cb3d968589d8 499 * @param __HANDLE__: specifies the USART Handle.
Kojto 90:cb3d968589d8 500 * @retval None
Kojto 108:34e6b704fe68 501 */
Kojto 108:34e6b704fe68 502 #define __HAL_USART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
Kojto 90:cb3d968589d8 503
Kojto 90:cb3d968589d8 504 /**
Kojto 90:cb3d968589d8 505 * @}
Kojto 108:34e6b704fe68 506 */
Kojto 90:cb3d968589d8 507
Kojto 90:cb3d968589d8 508 /* Private macros --------------------------------------------------------*/
Kojto 90:cb3d968589d8 509 /** @defgroup USART_Private_Macros USART Private Macros
Kojto 90:cb3d968589d8 510 * @{
Kojto 90:cb3d968589d8 511 */
Kojto 90:cb3d968589d8 512
Kojto 90:cb3d968589d8 513 /** @brief Check USART Baud rate
Kojto 108:34e6b704fe68 514 * @param __BAUDRATE__: Baudrate specified by the user.
Kojto 122:f9eeca106725 515 * The maximum Baud Rate is derived from the maximum clock on F0 (i.e. 48 MHz)
Kojto 108:34e6b704fe68 516 * divided by the smallest oversampling used on the USART (i.e. 8)
Kojto 108:34e6b704fe68 517 * @retval Test result (TRUE or FALSE).
Kojto 122:f9eeca106725 518 */
Kojto 122:f9eeca106725 519 #define IS_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 6000001)
Kojto 108:34e6b704fe68 520
Kojto 90:cb3d968589d8 521 /**
Kojto 108:34e6b704fe68 522 * @brief Ensure that USART frame number of stop bits is valid.
Kojto 108:34e6b704fe68 523 * @param __STOPBITS__: USART frame number of stop bits.
Kojto 108:34e6b704fe68 524 * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
Kojto 90:cb3d968589d8 525 */
Kojto 122:f9eeca106725 526 #ifdef USART_SMARTCARD_SUPPORT
Kojto 122:f9eeca106725 527 #define IS_USART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == USART_STOPBITS_0_5) || \
Kojto 122:f9eeca106725 528 ((__STOPBITS__) == USART_STOPBITS_1) || \
Kojto 108:34e6b704fe68 529 ((__STOPBITS__) == USART_STOPBITS_1_5) || \
Kojto 108:34e6b704fe68 530 ((__STOPBITS__) == USART_STOPBITS_2))
Kojto 122:f9eeca106725 531 #else
Kojto 122:f9eeca106725 532 #define IS_USART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == USART_STOPBITS_1) || \
Kojto 122:f9eeca106725 533 ((__STOPBITS__) == USART_STOPBITS_2))
Kojto 122:f9eeca106725 534 #endif
Kojto 108:34e6b704fe68 535
Kojto 108:34e6b704fe68 536 /**
Kojto 108:34e6b704fe68 537 * @brief Ensure that USART frame parity is valid.
Kojto 108:34e6b704fe68 538 * @param __PARITY__: USART frame parity.
Kojto 108:34e6b704fe68 539 * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
Kojto 108:34e6b704fe68 540 */
Kojto 108:34e6b704fe68 541 #define IS_USART_PARITY(__PARITY__) (((__PARITY__) == USART_PARITY_NONE) || \
Kojto 108:34e6b704fe68 542 ((__PARITY__) == USART_PARITY_EVEN) || \
Kojto 108:34e6b704fe68 543 ((__PARITY__) == USART_PARITY_ODD))
Kojto 90:cb3d968589d8 544
Kojto 108:34e6b704fe68 545 /**
Kojto 108:34e6b704fe68 546 * @brief Ensure that USART communication mode is valid.
Kojto 108:34e6b704fe68 547 * @param __MODE__: USART communication mode.
Kojto 108:34e6b704fe68 548 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 108:34e6b704fe68 549 */
Kojto 122:f9eeca106725 550 #define IS_USART_MODE(__MODE__) ((((__MODE__) & (uint32_t)0xFFFFFFF3U) == 0x00) && ((__MODE__) != (uint32_t)0x00))
Kojto 108:34e6b704fe68 551
Kojto 108:34e6b704fe68 552 /**
Kojto 108:34e6b704fe68 553 * @brief Ensure that USART clock state is valid.
Kojto 108:34e6b704fe68 554 * @param __CLOCK__: USART clock state.
Kojto 108:34e6b704fe68 555 * @retval SET (__CLOCK__ is valid) or RESET (__CLOCK__ is invalid)
Kojto 108:34e6b704fe68 556 */
Kojto 108:34e6b704fe68 557 #define IS_USART_CLOCK(__CLOCK__) (((__CLOCK__) == USART_CLOCK_DISABLE) || \
Kojto 108:34e6b704fe68 558 ((__CLOCK__) == USART_CLOCK_ENABLE))
Kojto 108:34e6b704fe68 559
Kojto 108:34e6b704fe68 560 /**
Kojto 108:34e6b704fe68 561 * @brief Ensure that USART frame polarity is valid.
Kojto 108:34e6b704fe68 562 * @param __CPOL__: USART frame polarity.
Kojto 108:34e6b704fe68 563 * @retval SET (__CPOL__ is valid) or RESET (__CPOL__ is invalid)
Kojto 108:34e6b704fe68 564 */
Kojto 108:34e6b704fe68 565 #define IS_USART_POLARITY(__CPOL__) (((__CPOL__) == USART_POLARITY_LOW) || ((__CPOL__) == USART_POLARITY_HIGH))
Kojto 108:34e6b704fe68 566
Kojto 108:34e6b704fe68 567 /**
Kojto 108:34e6b704fe68 568 * @brief Ensure that USART frame phase is valid.
Kojto 108:34e6b704fe68 569 * @param __CPHA__: USART frame phase.
Kojto 108:34e6b704fe68 570 * @retval SET (__CPHA__ is valid) or RESET (__CPHA__ is invalid)
Kojto 90:cb3d968589d8 571 */
Kojto 108:34e6b704fe68 572 #define IS_USART_PHASE(__CPHA__) (((__CPHA__) == USART_PHASE_1EDGE) || ((__CPHA__) == USART_PHASE_2EDGE))
Kojto 90:cb3d968589d8 573
Kojto 108:34e6b704fe68 574 /**
Kojto 108:34e6b704fe68 575 * @brief Ensure that USART frame last bit clock pulse setting is valid.
Kojto 108:34e6b704fe68 576 * @param __LASTBIT__: USART frame last bit clock pulse setting.
Kojto 108:34e6b704fe68 577 * @retval SET (__LASTBIT__ is valid) or RESET (__LASTBIT__ is invalid)
Kojto 108:34e6b704fe68 578 */
Kojto 108:34e6b704fe68 579 #define IS_USART_LASTBIT(__LASTBIT__) (((__LASTBIT__) == USART_LASTBIT_DISABLE) || \
Kojto 108:34e6b704fe68 580 ((__LASTBIT__) == USART_LASTBIT_ENABLE))
Kojto 90:cb3d968589d8 581
Kojto 90:cb3d968589d8 582 /**
Kojto 90:cb3d968589d8 583 * @}
Kojto 90:cb3d968589d8 584 */
Kojto 90:cb3d968589d8 585
Kojto 108:34e6b704fe68 586 /* Include USART HAL Extension module */
Kojto 108:34e6b704fe68 587 #include "stm32f0xx_hal_usart_ex.h"
Kojto 108:34e6b704fe68 588
Kojto 108:34e6b704fe68 589 /* Exported functions --------------------------------------------------------*/
Kojto 108:34e6b704fe68 590 /** @addtogroup USART_Exported_Functions USART Exported Functions
Kojto 108:34e6b704fe68 591 * @{
Kojto 108:34e6b704fe68 592 */
Kojto 108:34e6b704fe68 593
Kojto 108:34e6b704fe68 594 /** @addtogroup USART_Exported_Functions_Group1 Initialization and de-initialization functions
Kojto 90:cb3d968589d8 595 * @{
Kojto 90:cb3d968589d8 596 */
Kojto 90:cb3d968589d8 597
Kojto 108:34e6b704fe68 598 /* Initialization and de-initialization functions ****************************/
Kojto 108:34e6b704fe68 599 HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart);
Kojto 108:34e6b704fe68 600 HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart);
Kojto 108:34e6b704fe68 601 void HAL_USART_MspInit(USART_HandleTypeDef *husart);
Kojto 108:34e6b704fe68 602 void HAL_USART_MspDeInit(USART_HandleTypeDef *husart);
Kojto 108:34e6b704fe68 603
Kojto 108:34e6b704fe68 604 /**
Kojto 108:34e6b704fe68 605 * @}
Kojto 108:34e6b704fe68 606 */
Kojto 108:34e6b704fe68 607
Kojto 108:34e6b704fe68 608 /** @addtogroup USART_Exported_Functions_Group2 IO operation functions
Kojto 108:34e6b704fe68 609 * @{
Kojto 108:34e6b704fe68 610 */
Kojto 108:34e6b704fe68 611
Kojto 108:34e6b704fe68 612 /* IO operation functions *****************************************************/
Kojto 90:cb3d968589d8 613 HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout);
Kojto 90:cb3d968589d8 614 HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
Kojto 90:cb3d968589d8 615 HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
Kojto 90:cb3d968589d8 616 HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
Kojto 90:cb3d968589d8 617 HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
Kojto 90:cb3d968589d8 618 HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
Kojto 90:cb3d968589d8 619 HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
Kojto 90:cb3d968589d8 620 HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
Kojto 90:cb3d968589d8 621 HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
Kojto 90:cb3d968589d8 622 HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart);
Kojto 90:cb3d968589d8 623 HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart);
Kojto 90:cb3d968589d8 624 HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart);
Kojto 90:cb3d968589d8 625 void HAL_USART_IRQHandler(USART_HandleTypeDef *husart);
Kojto 90:cb3d968589d8 626 void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart);
Kojto 90:cb3d968589d8 627 void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart);
Kojto 90:cb3d968589d8 628 void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart);
Kojto 90:cb3d968589d8 629 void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart);
Kojto 90:cb3d968589d8 630 void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart);
Kojto 90:cb3d968589d8 631 void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart);
Kojto 90:cb3d968589d8 632
Kojto 90:cb3d968589d8 633 /**
Kojto 90:cb3d968589d8 634 * @}
Kojto 90:cb3d968589d8 635 */
Kojto 90:cb3d968589d8 636
Kojto 90:cb3d968589d8 637 /* Peripheral Control functions ***********************************************/
Kojto 90:cb3d968589d8 638
Kojto 122:f9eeca106725 639 /** @addtogroup USART_Exported_Functions_Group3 Peripheral State and Error functions
Kojto 90:cb3d968589d8 640 * @{
Kojto 90:cb3d968589d8 641 */
Kojto 90:cb3d968589d8 642
Kojto 90:cb3d968589d8 643 /* Peripheral State and Error functions ***************************************/
Kojto 90:cb3d968589d8 644 HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart);
Kojto 108:34e6b704fe68 645 uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart);
Kojto 90:cb3d968589d8 646
Kojto 90:cb3d968589d8 647 /**
Kojto 90:cb3d968589d8 648 * @}
Kojto 90:cb3d968589d8 649 */
Kojto 108:34e6b704fe68 650
Kojto 90:cb3d968589d8 651 /**
Kojto 90:cb3d968589d8 652 * @}
Kojto 108:34e6b704fe68 653 */
Kojto 108:34e6b704fe68 654
Kojto 108:34e6b704fe68 655 /**
Kojto 108:34e6b704fe68 656 * @}
Kojto 108:34e6b704fe68 657 */
Kojto 90:cb3d968589d8 658
Kojto 90:cb3d968589d8 659 /**
Kojto 90:cb3d968589d8 660 * @}
Kojto 90:cb3d968589d8 661 */
Kojto 90:cb3d968589d8 662
Kojto 90:cb3d968589d8 663 #ifdef __cplusplus
Kojto 90:cb3d968589d8 664 }
Kojto 90:cb3d968589d8 665 #endif
Kojto 90:cb3d968589d8 666
Kojto 90:cb3d968589d8 667 #endif /* __STM32F0xx_HAL_USART_H */
Kojto 90:cb3d968589d8 668
Kojto 90:cb3d968589d8 669 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Kojto 90:cb3d968589d8 670