mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Fri Aug 12 13:04:35 2016 +0200
Revision:
123:b0220dba8be7
Parent:
122:f9eeca106725
Release 123 of the mbed library

Changes:
- new targets: nucleo_f207zg, beetle, nrf51_dk, hexiwear,
nuvoton nuc472, vk rz a1h
- ST - fix timer interrupt handler, sleep api fix
- NXP - lpc15xx us ticker fix
- Nordic - analogin fixes, LF clock init addition, enable i2c async

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 86:04dd9b1680ae 1 /**
bogdanm 86:04dd9b1680ae 2 ******************************************************************************
bogdanm 86:04dd9b1680ae 3 * @file stm32f3xx_hal_usart.h
bogdanm 86:04dd9b1680ae 4 * @author MCD Application Team
Kojto 123:b0220dba8be7 5 * @version V1.3.0
Kojto 123:b0220dba8be7 6 * @date 01-July-2016
bogdanm 86:04dd9b1680ae 7 * @brief Header file of USART HAL module.
bogdanm 86:04dd9b1680ae 8 ******************************************************************************
bogdanm 86:04dd9b1680ae 9 * @attention
bogdanm 86:04dd9b1680ae 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
bogdanm 86:04dd9b1680ae 12 *
bogdanm 86:04dd9b1680ae 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 86:04dd9b1680ae 14 * are permitted provided that the following conditions are met:
bogdanm 86:04dd9b1680ae 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 86:04dd9b1680ae 16 * this list of conditions and the following disclaimer.
bogdanm 86:04dd9b1680ae 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 86:04dd9b1680ae 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 86:04dd9b1680ae 19 * and/or other materials provided with the distribution.
bogdanm 86:04dd9b1680ae 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 86:04dd9b1680ae 21 * may be used to endorse or promote products derived from this software
bogdanm 86:04dd9b1680ae 22 * without specific prior written permission.
bogdanm 86:04dd9b1680ae 23 *
bogdanm 86:04dd9b1680ae 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 86:04dd9b1680ae 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 86:04dd9b1680ae 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 86:04dd9b1680ae 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 86:04dd9b1680ae 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 86:04dd9b1680ae 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 86:04dd9b1680ae 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 86:04dd9b1680ae 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 86:04dd9b1680ae 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 86:04dd9b1680ae 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 86:04dd9b1680ae 34 *
Kojto 122:f9eeca106725 35 ******************************************************************************
bogdanm 86:04dd9b1680ae 36 */
bogdanm 86:04dd9b1680ae 37
bogdanm 86:04dd9b1680ae 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 86:04dd9b1680ae 39 #ifndef __STM32F3xx_HAL_USART_H
bogdanm 86:04dd9b1680ae 40 #define __STM32F3xx_HAL_USART_H
bogdanm 86:04dd9b1680ae 41
bogdanm 86:04dd9b1680ae 42 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 43 extern "C" {
bogdanm 86:04dd9b1680ae 44 #endif
bogdanm 86:04dd9b1680ae 45
bogdanm 86:04dd9b1680ae 46 /* Includes ------------------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 47 #include "stm32f3xx_hal_def.h"
bogdanm 86:04dd9b1680ae 48
bogdanm 86:04dd9b1680ae 49 /** @addtogroup STM32F3xx_HAL_Driver
bogdanm 86:04dd9b1680ae 50 * @{
bogdanm 86:04dd9b1680ae 51 */
bogdanm 86:04dd9b1680ae 52
bogdanm 86:04dd9b1680ae 53 /** @addtogroup USART
bogdanm 86:04dd9b1680ae 54 * @{
Kojto 122:f9eeca106725 55 */
bogdanm 86:04dd9b1680ae 56
Kojto 122:f9eeca106725 57 /* Exported types ------------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 58 /** @defgroup USART_Exported_Types USART Exported Types
bogdanm 92:4fc01daae5a5 59 * @{
bogdanm 92:4fc01daae5a5 60 */
bogdanm 86:04dd9b1680ae 61
Kojto 122:f9eeca106725 62 /**
Kojto 122:f9eeca106725 63 * @brief USART Init Structure definition
Kojto 122:f9eeca106725 64 */
bogdanm 86:04dd9b1680ae 65 typedef struct
bogdanm 86:04dd9b1680ae 66 {
bogdanm 86:04dd9b1680ae 67 uint32_t BaudRate; /*!< This member configures the Usart communication baud rate.
bogdanm 86:04dd9b1680ae 68 The baud rate is computed using the following formula:
Kojto 122:f9eeca106725 69 Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate))). */
bogdanm 86:04dd9b1680ae 70
bogdanm 86:04dd9b1680ae 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. */
bogdanm 86:04dd9b1680ae 73
bogdanm 86:04dd9b1680ae 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. */
bogdanm 86:04dd9b1680ae 76
bogdanm 86:04dd9b1680ae 77 uint32_t Parity; /*!< Specifies the parity mode.
bogdanm 86:04dd9b1680ae 78 This parameter can be a value of @ref USART_Parity
bogdanm 86:04dd9b1680ae 79 @note When parity is enabled, the computed parity is inserted
bogdanm 86:04dd9b1680ae 80 at the MSB position of the transmitted data (9th bit when
bogdanm 86:04dd9b1680ae 81 the word length is set to 9 data bits; 8th bit when the
bogdanm 86:04dd9b1680ae 82 word length is set to 8 data bits). */
Kojto 122:f9eeca106725 83
bogdanm 92:4fc01daae5a5 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
bogdanm 86:04dd9b1680ae 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. */
bogdanm 86:04dd9b1680ae 89
bogdanm 86:04dd9b1680ae 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. */
bogdanm 86:04dd9b1680ae 92
bogdanm 86:04dd9b1680ae 93 uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
bogdanm 86:04dd9b1680ae 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. */
bogdanm 86:04dd9b1680ae 96 }USART_InitTypeDef;
bogdanm 86:04dd9b1680ae 97
Kojto 122:f9eeca106725 98 /**
Kojto 122:f9eeca106725 99 * @brief HAL USART State structures definition
Kojto 122:f9eeca106725 100 */
bogdanm 86:04dd9b1680ae 101 typedef enum
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 111 }HAL_USART_StateTypeDef;
bogdanm 86:04dd9b1680ae 112
Kojto 122:f9eeca106725 113 /**
bogdanm 86:04dd9b1680ae 114 * @brief USART clock sources definitions
bogdanm 86:04dd9b1680ae 115 */
bogdanm 86:04dd9b1680ae 116 typedef enum
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 124 }USART_ClockSourceTypeDef;
bogdanm 86:04dd9b1680ae 125
bogdanm 86:04dd9b1680ae 126
Kojto 122:f9eeca106725 127 /**
Kojto 122:f9eeca106725 128 * @brief USART handle Structure definition
Kojto 122:f9eeca106725 129 */
bogdanm 86:04dd9b1680ae 130 typedef struct
bogdanm 86:04dd9b1680ae 131 {
bogdanm 86:04dd9b1680ae 132 USART_TypeDef *Instance; /*!< USART registers base address */
Kojto 122:f9eeca106725 133
bogdanm 86:04dd9b1680ae 134 USART_InitTypeDef Init; /*!< USART communication parameters */
Kojto 122:f9eeca106725 135
bogdanm 86:04dd9b1680ae 136 uint8_t *pTxBuffPtr; /*!< Pointer to USART Tx transfer Buffer */
Kojto 122:f9eeca106725 137
bogdanm 86:04dd9b1680ae 138 uint16_t TxXferSize; /*!< USART Tx Transfer size */
Kojto 122:f9eeca106725 139
bogdanm 86:04dd9b1680ae 140 uint16_t TxXferCount; /*!< USART Tx Transfer Counter */
Kojto 122:f9eeca106725 141
bogdanm 86:04dd9b1680ae 142 uint8_t *pRxBuffPtr; /*!< Pointer to USART Rx transfer Buffer */
Kojto 122:f9eeca106725 143
bogdanm 86:04dd9b1680ae 144 uint16_t RxXferSize; /*!< USART Rx Transfer size */
Kojto 122:f9eeca106725 145
bogdanm 86:04dd9b1680ae 146 uint16_t RxXferCount; /*!< USART Rx Transfer Counter */
Kojto 122:f9eeca106725 147
bogdanm 86:04dd9b1680ae 148 uint16_t Mask; /*!< USART Rx RDR register mask */
Kojto 122:f9eeca106725 149
bogdanm 86:04dd9b1680ae 150 DMA_HandleTypeDef *hdmatx; /*!< USART Tx DMA Handle parameters */
Kojto 122:f9eeca106725 151
bogdanm 86:04dd9b1680ae 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
bogdanm 86:04dd9b1680ae 160 }USART_HandleTypeDef;
bogdanm 86:04dd9b1680ae 161
bogdanm 92:4fc01daae5a5 162 /**
bogdanm 92:4fc01daae5a5 163 * @}
bogdanm 92:4fc01daae5a5 164 */
bogdanm 86:04dd9b1680ae 165
bogdanm 86:04dd9b1680ae 166 /* Exported constants --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 167 /** @defgroup USART_Exported_Constants USART Exported Constants
bogdanm 86:04dd9b1680ae 168 * @{
bogdanm 86:04dd9b1680ae 169 */
bogdanm 86:04dd9b1680ae 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
bogdanm 86:04dd9b1680ae 184 /** @defgroup USART_Stop_Bits USART Number of Stop Bits
bogdanm 86:04dd9b1680ae 185 * @{
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 191 /**
bogdanm 86:04dd9b1680ae 192 * @}
bogdanm 86:04dd9b1680ae 193 */
bogdanm 86:04dd9b1680ae 194
bogdanm 86:04dd9b1680ae 195 /** @defgroup USART_Parity USART Parity
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 201 /**
bogdanm 86:04dd9b1680ae 202 * @}
Kojto 122:f9eeca106725 203 */
bogdanm 86:04dd9b1680ae 204
bogdanm 86:04dd9b1680ae 205 /** @defgroup USART_Mode USART Mode
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 211 /**
bogdanm 86:04dd9b1680ae 212 * @}
bogdanm 86:04dd9b1680ae 213 */
Kojto 122:f9eeca106725 214
bogdanm 86:04dd9b1680ae 215 /** @defgroup USART_Clock USART Clock
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 220 /**
bogdanm 86:04dd9b1680ae 221 * @}
Kojto 122:f9eeca106725 222 */
bogdanm 86:04dd9b1680ae 223
bogdanm 86:04dd9b1680ae 224 /** @defgroup USART_Clock_Polarity USART Clock Polarity
bogdanm 86:04dd9b1680ae 225 * @{
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 229 /**
bogdanm 86:04dd9b1680ae 230 * @}
Kojto 122:f9eeca106725 231 */
bogdanm 86:04dd9b1680ae 232
bogdanm 86:04dd9b1680ae 233 /** @defgroup USART_Clock_Phase USART Clock Phase
bogdanm 86:04dd9b1680ae 234 * @{
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 238 /**
bogdanm 86:04dd9b1680ae 239 * @}
bogdanm 86:04dd9b1680ae 240 */
bogdanm 86:04dd9b1680ae 241
bogdanm 86:04dd9b1680ae 242 /** @defgroup USART_Last_Bit USART Last Bit
bogdanm 86:04dd9b1680ae 243 * @{
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 247 /**
bogdanm 86:04dd9b1680ae 248 * @}
bogdanm 86:04dd9b1680ae 249 */
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 259
bogdanm 86:04dd9b1680ae 260 /** @defgroup USART_Flags USART Flags
bogdanm 86:04dd9b1680ae 261 * Elements values convention: 0xXXXX
bogdanm 86:04dd9b1680ae 262 * - 0xXXXX : Flag mask in the ISR register
bogdanm 86:04dd9b1680ae 263 * @{
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 278 /**
bogdanm 86:04dd9b1680ae 279 * @}
bogdanm 86:04dd9b1680ae 280 */
bogdanm 86:04dd9b1680ae 281
bogdanm 86:04dd9b1680ae 282 /** @defgroup USART_Interrupt_definition USART Interrupts Definition
bogdanm 86:04dd9b1680ae 283 * Elements values convention: 0000ZZZZ0XXYYYYYb
bogdanm 86:04dd9b1680ae 284 * - YYYYY : Interrupt source position in the XX register (5bits)
bogdanm 86:04dd9b1680ae 285 * - XX : Interrupt source register (2bits)
bogdanm 86:04dd9b1680ae 286 * - 01: CR1 register
bogdanm 86:04dd9b1680ae 287 * - 10: CR2 register
bogdanm 86:04dd9b1680ae 288 * - 11: CR3 register
bogdanm 86:04dd9b1680ae 289 * - ZZZZ : Flag position in the ISR register(4bits)
bogdanm 86:04dd9b1680ae 290 * @{
bogdanm 86:04dd9b1680ae 291 */
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 302 /**
bogdanm 86:04dd9b1680ae 303 * @}
bogdanm 86:04dd9b1680ae 304 */
bogdanm 86:04dd9b1680ae 305
bogdanm 86:04dd9b1680ae 306 /** @defgroup USART_IT_CLEAR_Flags USART Interruption Clear Flags
bogdanm 86:04dd9b1680ae 307 * @{
bogdanm 86:04dd9b1680ae 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 */
bogdanm 86:04dd9b1680ae 316 /**
bogdanm 86:04dd9b1680ae 317 * @}
bogdanm 86:04dd9b1680ae 318 */
bogdanm 86:04dd9b1680ae 319
Kojto 122:f9eeca106725 320 /** @defgroup USART_Interruption_Mask USART Interruption Flags Mask
bogdanm 86:04dd9b1680ae 321 * @{
Kojto 122:f9eeca106725 322 */
Kojto 122:f9eeca106725 323 #define USART_IT_MASK ((uint16_t)0x001F) /*!< USART interruptions flags mask */
bogdanm 86:04dd9b1680ae 324 /**
bogdanm 86:04dd9b1680ae 325 * @}
bogdanm 86:04dd9b1680ae 326 */
bogdanm 86:04dd9b1680ae 327
bogdanm 86:04dd9b1680ae 328 /**
bogdanm 86:04dd9b1680ae 329 * @}
bogdanm 86:04dd9b1680ae 330 */
bogdanm 86:04dd9b1680ae 331
Kojto 122:f9eeca106725 332 /* Exported macros -----------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 333 /** @defgroup USART_Exported_Macros USART Exported Macros
bogdanm 86:04dd9b1680ae 334 * @{
Kojto 122:f9eeca106725 335 */
Kojto 122:f9eeca106725 336
Kojto 122:f9eeca106725 337 /** @brief Reset USART handle state.
bogdanm 86:04dd9b1680ae 338 * @param __HANDLE__: USART handle.
bogdanm 86:04dd9b1680ae 339 * @retval None
bogdanm 86:04dd9b1680ae 340 */
Kojto 122:f9eeca106725 341 #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET)
bogdanm 86:04dd9b1680ae 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)
bogdanm 86:04dd9b1680ae 352
Kojto 122:f9eeca106725 353 /** @brief Check whether the specified USART flag is set or not.
bogdanm 86:04dd9b1680ae 354 * @param __HANDLE__: specifies the USART Handle
bogdanm 86:04dd9b1680ae 355 * @param __FLAG__: specifies the flag to check.
bogdanm 86:04dd9b1680ae 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
bogdanm 86:04dd9b1680ae 361 * @arg USART_FLAG_TXE: Transmit data register empty flag
bogdanm 86:04dd9b1680ae 362 * @arg USART_FLAG_TC: Transmission Complete flag
bogdanm 86:04dd9b1680ae 363 * @arg USART_FLAG_RXNE: Receive data register not empty flag
bogdanm 86:04dd9b1680ae 364 * @arg USART_FLAG_IDLE: Idle Line detection flag
bogdanm 86:04dd9b1680ae 365 * @arg USART_FLAG_ORE: OverRun Error flag
bogdanm 86:04dd9b1680ae 366 * @arg USART_FLAG_NE: Noise Error flag
bogdanm 86:04dd9b1680ae 367 * @arg USART_FLAG_FE: Framing Error flag
bogdanm 86:04dd9b1680ae 368 * @arg USART_FLAG_PE: Parity Error flag
bogdanm 86:04dd9b1680ae 369 * @retval The new state of __FLAG__ (TRUE or FALSE).
bogdanm 86:04dd9b1680ae 370 */
bogdanm 86:04dd9b1680ae 371 #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
bogdanm 86:04dd9b1680ae 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__))
bogdanm 86:04dd9b1680ae 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.
bogdanm 86:04dd9b1680ae 420 * @param __INTERRUPT__: specifies the USART interrupt source to enable.
bogdanm 86:04dd9b1680ae 421 * This parameter can be one of the following values:
bogdanm 86:04dd9b1680ae 422 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
bogdanm 86:04dd9b1680ae 423 * @arg USART_IT_TC: Transmission complete interrupt
bogdanm 86:04dd9b1680ae 424 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
bogdanm 86:04dd9b1680ae 425 * @arg USART_IT_IDLE: Idle line detection interrupt
bogdanm 86:04dd9b1680ae 426 * @arg USART_IT_PE: Parity Error interrupt
bogdanm 86:04dd9b1680ae 427 * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
bogdanm 86:04dd9b1680ae 428 * @retval None
bogdanm 86:04dd9b1680ae 429 */
bogdanm 86:04dd9b1680ae 430 #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
bogdanm 86:04dd9b1680ae 431 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
bogdanm 86:04dd9b1680ae 432 ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))))
bogdanm 86:04dd9b1680ae 433
Kojto 122:f9eeca106725 434 /** @brief Disable the specified USART interrupt.
bogdanm 86:04dd9b1680ae 435 * @param __HANDLE__: specifies the USART Handle.
bogdanm 86:04dd9b1680ae 436 * @param __INTERRUPT__: specifies the USART interrupt source to disable.
bogdanm 86:04dd9b1680ae 437 * This parameter can be one of the following values:
bogdanm 86:04dd9b1680ae 438 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
bogdanm 86:04dd9b1680ae 439 * @arg USART_IT_TC: Transmission complete interrupt
bogdanm 86:04dd9b1680ae 440 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
bogdanm 86:04dd9b1680ae 441 * @arg USART_IT_IDLE: Idle line detection interrupt
bogdanm 86:04dd9b1680ae 442 * @arg USART_IT_PE: Parity Error interrupt
bogdanm 86:04dd9b1680ae 443 * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
bogdanm 86:04dd9b1680ae 444 * @retval None
bogdanm 86:04dd9b1680ae 445 */
bogdanm 86:04dd9b1680ae 446 #define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
bogdanm 86:04dd9b1680ae 447 ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
bogdanm 86:04dd9b1680ae 448 ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))))
bogdanm 86:04dd9b1680ae 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.
bogdanm 86:04dd9b1680ae 453 * @param __IT__: specifies the USART interrupt source to check.
bogdanm 86:04dd9b1680ae 454 * This parameter can be one of the following values:
bogdanm 86:04dd9b1680ae 455 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
bogdanm 86:04dd9b1680ae 456 * @arg USART_IT_TC: Transmission complete interrupt
bogdanm 86:04dd9b1680ae 457 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
bogdanm 86:04dd9b1680ae 458 * @arg USART_IT_IDLE: Idle line detection interrupt
bogdanm 86:04dd9b1680ae 459 * @arg USART_IT_ORE: OverRun Error interrupt
bogdanm 86:04dd9b1680ae 460 * @arg USART_IT_NE: Noise Error interrupt
bogdanm 86:04dd9b1680ae 461 * @arg USART_IT_FE: Framing Error interrupt
bogdanm 86:04dd9b1680ae 462 * @arg USART_IT_PE: Parity Error interrupt
bogdanm 86:04dd9b1680ae 463 * @retval The new state of __IT__ (TRUE or FALSE).
bogdanm 86:04dd9b1680ae 464 */
Kojto 122:f9eeca106725 465 #define __HAL_USART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
bogdanm 86:04dd9b1680ae 466
Kojto 122:f9eeca106725 467 /** @brief Check whether the specified USART interrupt source is enabled or not.
bogdanm 86:04dd9b1680ae 468 * @param __HANDLE__: specifies the USART Handle.
bogdanm 86:04dd9b1680ae 469 * @param __IT__: specifies the USART interrupt source to check.
bogdanm 86:04dd9b1680ae 470 * This parameter can be one of the following values:
bogdanm 86:04dd9b1680ae 471 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
bogdanm 86:04dd9b1680ae 472 * @arg USART_IT_TC: Transmission complete interrupt
bogdanm 86:04dd9b1680ae 473 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
bogdanm 86:04dd9b1680ae 474 * @arg USART_IT_IDLE: Idle line detection interrupt
bogdanm 86:04dd9b1680ae 475 * @arg USART_IT_ORE: OverRun Error interrupt
bogdanm 86:04dd9b1680ae 476 * @arg USART_IT_NE: Noise Error interrupt
bogdanm 86:04dd9b1680ae 477 * @arg USART_IT_FE: Framing Error interrupt
bogdanm 86:04dd9b1680ae 478 * @arg USART_IT_PE: Parity Error interrupt
bogdanm 86:04dd9b1680ae 479 * @retval The new state of __IT__ (TRUE or FALSE).
bogdanm 86:04dd9b1680ae 480 */
bogdanm 86:04dd9b1680ae 481 #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5) == 2)? \
bogdanm 86:04dd9b1680ae 482 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << \
bogdanm 86:04dd9b1680ae 483 (((uint16_t)(__IT__)) & USART_IT_MASK)))
bogdanm 86:04dd9b1680ae 484
bogdanm 86:04dd9b1680ae 485
Kojto 122:f9eeca106725 486 /** @brief Clear the specified USART ISR flag, in setting the proper ICR register flag.
bogdanm 86:04dd9b1680ae 487 * @param __HANDLE__: specifies the USART Handle.
bogdanm 86:04dd9b1680ae 488 * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
Kojto 122:f9eeca106725 489 * to clear the corresponding interrupt.
bogdanm 86:04dd9b1680ae 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
bogdanm 86:04dd9b1680ae 498 * @retval None
bogdanm 86:04dd9b1680ae 499 */
Kojto 122:f9eeca106725 500 #define __HAL_USART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
bogdanm 86:04dd9b1680ae 501
bogdanm 86:04dd9b1680ae 502 /** @brief Set a specific USART request flag.
bogdanm 86:04dd9b1680ae 503 * @param __HANDLE__: specifies the USART Handle.
Kojto 122:f9eeca106725 504 * @param __REQ__: specifies the request flag to set.
bogdanm 86:04dd9b1680ae 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
bogdanm 86:04dd9b1680ae 508 *
bogdanm 86:04dd9b1680ae 509 * @retval None
Kojto 122:f9eeca106725 510 */
Kojto 122:f9eeca106725 511 #define __HAL_USART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (__REQ__))
bogdanm 86:04dd9b1680ae 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.
bogdanm 86:04dd9b1680ae 526 * @param __HANDLE__: specifies the USART Handle.
bogdanm 86:04dd9b1680ae 527 * @retval None
Kojto 122:f9eeca106725 528 */
Kojto 122:f9eeca106725 529 #define __HAL_USART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
bogdanm 86:04dd9b1680ae 530
Kojto 122:f9eeca106725 531 /** @brief Disable USART.
bogdanm 86:04dd9b1680ae 532 * @param __HANDLE__: specifies the USART Handle.
bogdanm 86:04dd9b1680ae 533 * @retval None
Kojto 122:f9eeca106725 534 */
Kojto 122:f9eeca106725 535 #define __HAL_USART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
bogdanm 86:04dd9b1680ae 536
bogdanm 86:04dd9b1680ae 537 /**
bogdanm 86:04dd9b1680ae 538 * @}
bogdanm 86:04dd9b1680ae 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
bogdanm 86:04dd9b1680ae 625 /* Exported functions --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 626 /** @addtogroup USART_Exported_Functions USART Exported Functions
bogdanm 92:4fc01daae5a5 627 * @{
bogdanm 92:4fc01daae5a5 628 */
bogdanm 86:04dd9b1680ae 629
bogdanm 92:4fc01daae5a5 630 /** @addtogroup USART_Exported_Functions_Group1 Initialization and de-initialization functions
bogdanm 92:4fc01daae5a5 631 * @{
bogdanm 92:4fc01daae5a5 632 */
Kojto 122:f9eeca106725 633
bogdanm 86:04dd9b1680ae 634 /* Initialization and de-initialization functions ****************************/
bogdanm 86:04dd9b1680ae 635 HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart);
bogdanm 86:04dd9b1680ae 636 HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart);
bogdanm 86:04dd9b1680ae 637 void HAL_USART_MspInit(USART_HandleTypeDef *husart);
bogdanm 86:04dd9b1680ae 638 void HAL_USART_MspDeInit(USART_HandleTypeDef *husart);
Kojto 122:f9eeca106725 639
bogdanm 92:4fc01daae5a5 640 /**
bogdanm 92:4fc01daae5a5 641 * @}
bogdanm 92:4fc01daae5a5 642 */
bogdanm 92:4fc01daae5a5 643
Kojto 122:f9eeca106725 644 /** @addtogroup USART_Exported_Functions_Group2 IO operation functions
bogdanm 92:4fc01daae5a5 645 * @{
bogdanm 92:4fc01daae5a5 646 */
Kojto 122:f9eeca106725 647
bogdanm 86:04dd9b1680ae 648 /* IO operation functions *****************************************************/
bogdanm 86:04dd9b1680ae 649 HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout);
bogdanm 86:04dd9b1680ae 650 HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
bogdanm 86:04dd9b1680ae 651 HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
bogdanm 86:04dd9b1680ae 652 HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
bogdanm 86:04dd9b1680ae 653 HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
bogdanm 86:04dd9b1680ae 654 HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
bogdanm 86:04dd9b1680ae 655 HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
bogdanm 86:04dd9b1680ae 656 HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
bogdanm 86:04dd9b1680ae 657 HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
bogdanm 86:04dd9b1680ae 658 HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart);
bogdanm 86:04dd9b1680ae 659 HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart);
bogdanm 86:04dd9b1680ae 660 HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart);
bogdanm 86:04dd9b1680ae 661 void HAL_USART_IRQHandler(USART_HandleTypeDef *husart);
bogdanm 86:04dd9b1680ae 662 void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart);
Kojto 122:f9eeca106725 663 void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart);
bogdanm 86:04dd9b1680ae 664 void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart);
bogdanm 86:04dd9b1680ae 665 void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart);
bogdanm 86:04dd9b1680ae 666 void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart);
bogdanm 86:04dd9b1680ae 667 void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart);
Kojto 122:f9eeca106725 668
bogdanm 92:4fc01daae5a5 669 /**
bogdanm 92:4fc01daae5a5 670 * @}
bogdanm 92:4fc01daae5a5 671 */
bogdanm 86:04dd9b1680ae 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
bogdanm 92:4fc01daae5a5 676 * @{
bogdanm 92:4fc01daae5a5 677 */
bogdanm 86:04dd9b1680ae 678
bogdanm 86:04dd9b1680ae 679 /* Peripheral State and Error functions ***************************************/
bogdanm 86:04dd9b1680ae 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
bogdanm 92:4fc01daae5a5 683 /**
bogdanm 92:4fc01daae5a5 684 * @}
bogdanm 92:4fc01daae5a5 685 */
bogdanm 86:04dd9b1680ae 686
bogdanm 86:04dd9b1680ae 687 /**
bogdanm 86:04dd9b1680ae 688 * @}
Kojto 122:f9eeca106725 689 */
bogdanm 86:04dd9b1680ae 690
bogdanm 86:04dd9b1680ae 691 /**
bogdanm 86:04dd9b1680ae 692 * @}
bogdanm 86:04dd9b1680ae 693 */
Kojto 122:f9eeca106725 694
Kojto 122:f9eeca106725 695 /**
Kojto 122:f9eeca106725 696 * @}
Kojto 122:f9eeca106725 697 */
Kojto 122:f9eeca106725 698
bogdanm 86:04dd9b1680ae 699 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 700 }
bogdanm 86:04dd9b1680ae 701 #endif
bogdanm 86:04dd9b1680ae 702
bogdanm 86:04dd9b1680ae 703 #endif /* __STM32F3xx_HAL_USART_H */
bogdanm 86:04dd9b1680ae 704
bogdanm 86:04dd9b1680ae 705 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Kojto 122:f9eeca106725 706