Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Mar 15 14:34:00 2016 +0000
Revision:
116:c0f6e94411f5
Parent:
115:87f2f5183dfb
Release 116 of the mbed library

Changes:
- new targets - NUCLEO_L073RZ
- fixes to IOTSS BEID platform
- LPC824, LPC1549 and LPC11U68 - fix PWMOut SCT bugs
- STM32F7 - Cube driver
- STM32F4 - add RTC LSI macro, defined as 0
- STM32F3 - fix multiple ADC clock initialization
- retarget - binary mode fix for GCC

Who changed what in which revision?

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