mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

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