mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

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