Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lypinator 0:bb348c97df44 1 /**
lypinator 0:bb348c97df44 2 ******************************************************************************
lypinator 0:bb348c97df44 3 * @file stm32f4xx_hal_usart.h
lypinator 0:bb348c97df44 4 * @author MCD Application Team
lypinator 0:bb348c97df44 5 * @brief Header file of USART HAL module.
lypinator 0:bb348c97df44 6 ******************************************************************************
lypinator 0:bb348c97df44 7 * @attention
lypinator 0:bb348c97df44 8 *
lypinator 0:bb348c97df44 9 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
lypinator 0:bb348c97df44 10 *
lypinator 0:bb348c97df44 11 * Redistribution and use in source and binary forms, with or without modification,
lypinator 0:bb348c97df44 12 * are permitted provided that the following conditions are met:
lypinator 0:bb348c97df44 13 * 1. Redistributions of source code must retain the above copyright notice,
lypinator 0:bb348c97df44 14 * this list of conditions and the following disclaimer.
lypinator 0:bb348c97df44 15 * 2. Redistributions in binary form must reproduce the above copyright notice,
lypinator 0:bb348c97df44 16 * this list of conditions and the following disclaimer in the documentation
lypinator 0:bb348c97df44 17 * and/or other materials provided with the distribution.
lypinator 0:bb348c97df44 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
lypinator 0:bb348c97df44 19 * may be used to endorse or promote products derived from this software
lypinator 0:bb348c97df44 20 * without specific prior written permission.
lypinator 0:bb348c97df44 21 *
lypinator 0:bb348c97df44 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
lypinator 0:bb348c97df44 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
lypinator 0:bb348c97df44 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
lypinator 0:bb348c97df44 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
lypinator 0:bb348c97df44 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
lypinator 0:bb348c97df44 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
lypinator 0:bb348c97df44 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
lypinator 0:bb348c97df44 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
lypinator 0:bb348c97df44 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
lypinator 0:bb348c97df44 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
lypinator 0:bb348c97df44 32 *
lypinator 0:bb348c97df44 33 ******************************************************************************
lypinator 0:bb348c97df44 34 */
lypinator 0:bb348c97df44 35
lypinator 0:bb348c97df44 36 /* Define to prevent recursive inclusion -------------------------------------*/
lypinator 0:bb348c97df44 37 #ifndef __STM32F4xx_HAL_USART_H
lypinator 0:bb348c97df44 38 #define __STM32F4xx_HAL_USART_H
lypinator 0:bb348c97df44 39
lypinator 0:bb348c97df44 40 #ifdef __cplusplus
lypinator 0:bb348c97df44 41 extern "C" {
lypinator 0:bb348c97df44 42 #endif
lypinator 0:bb348c97df44 43
lypinator 0:bb348c97df44 44 /* Includes ------------------------------------------------------------------*/
lypinator 0:bb348c97df44 45 #include "stm32f4xx_hal_def.h"
lypinator 0:bb348c97df44 46
lypinator 0:bb348c97df44 47 /** @addtogroup STM32F4xx_HAL_Driver
lypinator 0:bb348c97df44 48 * @{
lypinator 0:bb348c97df44 49 */
lypinator 0:bb348c97df44 50
lypinator 0:bb348c97df44 51 /** @addtogroup USART
lypinator 0:bb348c97df44 52 * @{
lypinator 0:bb348c97df44 53 */
lypinator 0:bb348c97df44 54
lypinator 0:bb348c97df44 55 /* Exported types ------------------------------------------------------------*/
lypinator 0:bb348c97df44 56 /** @defgroup USART_Exported_Types USART Exported Types
lypinator 0:bb348c97df44 57 * @{
lypinator 0:bb348c97df44 58 */
lypinator 0:bb348c97df44 59
lypinator 0:bb348c97df44 60 /**
lypinator 0:bb348c97df44 61 * @brief USART Init Structure definition
lypinator 0:bb348c97df44 62 */
lypinator 0:bb348c97df44 63 typedef struct
lypinator 0:bb348c97df44 64 {
lypinator 0:bb348c97df44 65 uint32_t BaudRate; /*!< This member configures the Usart communication baud rate.
lypinator 0:bb348c97df44 66 The baud rate is computed using the following formula:
lypinator 0:bb348c97df44 67 - IntegerDivider = ((PCLKx) / (8 * (husart->Init.BaudRate)))
lypinator 0:bb348c97df44 68 - FractionalDivider = ((IntegerDivider - ((uint32_t) IntegerDivider)) * 8) + 0.5 */
lypinator 0:bb348c97df44 69
lypinator 0:bb348c97df44 70 uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
lypinator 0:bb348c97df44 71 This parameter can be a value of @ref USART_Word_Length */
lypinator 0:bb348c97df44 72
lypinator 0:bb348c97df44 73 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
lypinator 0:bb348c97df44 74 This parameter can be a value of @ref USART_Stop_Bits */
lypinator 0:bb348c97df44 75
lypinator 0:bb348c97df44 76 uint32_t Parity; /*!< Specifies the parity mode.
lypinator 0:bb348c97df44 77 This parameter can be a value of @ref USART_Parity
lypinator 0:bb348c97df44 78 @note When parity is enabled, the computed parity is inserted
lypinator 0:bb348c97df44 79 at the MSB position of the transmitted data (9th bit when
lypinator 0:bb348c97df44 80 the word length is set to 9 data bits; 8th bit when the
lypinator 0:bb348c97df44 81 word length is set to 8 data bits). */
lypinator 0:bb348c97df44 82
lypinator 0:bb348c97df44 83 uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
lypinator 0:bb348c97df44 84 This parameter can be a value of @ref USART_Mode */
lypinator 0:bb348c97df44 85
lypinator 0:bb348c97df44 86 uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock.
lypinator 0:bb348c97df44 87 This parameter can be a value of @ref USART_Clock_Polarity */
lypinator 0:bb348c97df44 88
lypinator 0:bb348c97df44 89 uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made.
lypinator 0:bb348c97df44 90 This parameter can be a value of @ref USART_Clock_Phase */
lypinator 0:bb348c97df44 91
lypinator 0:bb348c97df44 92 uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
lypinator 0:bb348c97df44 93 data bit (MSB) has to be output on the SCLK pin in synchronous mode.
lypinator 0:bb348c97df44 94 This parameter can be a value of @ref USART_Last_Bit */
lypinator 0:bb348c97df44 95 }USART_InitTypeDef;
lypinator 0:bb348c97df44 96
lypinator 0:bb348c97df44 97 /**
lypinator 0:bb348c97df44 98 * @brief HAL State structures definition
lypinator 0:bb348c97df44 99 */
lypinator 0:bb348c97df44 100 typedef enum
lypinator 0:bb348c97df44 101 {
lypinator 0:bb348c97df44 102 HAL_USART_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */
lypinator 0:bb348c97df44 103 HAL_USART_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
lypinator 0:bb348c97df44 104 HAL_USART_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */
lypinator 0:bb348c97df44 105 HAL_USART_STATE_BUSY_TX = 0x12U, /*!< Data Transmission process is ongoing */
lypinator 0:bb348c97df44 106 HAL_USART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */
lypinator 0:bb348c97df44 107 HAL_USART_STATE_BUSY_TX_RX = 0x32U, /*!< Data Transmission Reception process is ongoing */
lypinator 0:bb348c97df44 108 HAL_USART_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
lypinator 0:bb348c97df44 109 HAL_USART_STATE_ERROR = 0x04U /*!< Error */
lypinator 0:bb348c97df44 110 }HAL_USART_StateTypeDef;
lypinator 0:bb348c97df44 111
lypinator 0:bb348c97df44 112 /**
lypinator 0:bb348c97df44 113 * @brief USART handle Structure definition
lypinator 0:bb348c97df44 114 */
lypinator 0:bb348c97df44 115 typedef struct
lypinator 0:bb348c97df44 116 {
lypinator 0:bb348c97df44 117 USART_TypeDef *Instance; /* USART registers base address */
lypinator 0:bb348c97df44 118
lypinator 0:bb348c97df44 119 USART_InitTypeDef Init; /* Usart communication parameters */
lypinator 0:bb348c97df44 120
lypinator 0:bb348c97df44 121 uint8_t *pTxBuffPtr; /* Pointer to Usart Tx transfer Buffer */
lypinator 0:bb348c97df44 122
lypinator 0:bb348c97df44 123 uint16_t TxXferSize; /* Usart Tx Transfer size */
lypinator 0:bb348c97df44 124
lypinator 0:bb348c97df44 125 __IO uint16_t TxXferCount; /* Usart Tx Transfer Counter */
lypinator 0:bb348c97df44 126
lypinator 0:bb348c97df44 127 uint8_t *pRxBuffPtr; /* Pointer to Usart Rx transfer Buffer */
lypinator 0:bb348c97df44 128
lypinator 0:bb348c97df44 129 uint16_t RxXferSize; /* Usart Rx Transfer size */
lypinator 0:bb348c97df44 130
lypinator 0:bb348c97df44 131 __IO uint16_t RxXferCount; /* Usart Rx Transfer Counter */
lypinator 0:bb348c97df44 132
lypinator 0:bb348c97df44 133 DMA_HandleTypeDef *hdmatx; /* Usart Tx DMA Handle parameters */
lypinator 0:bb348c97df44 134
lypinator 0:bb348c97df44 135 DMA_HandleTypeDef *hdmarx; /* Usart Rx DMA Handle parameters */
lypinator 0:bb348c97df44 136
lypinator 0:bb348c97df44 137 HAL_LockTypeDef Lock; /* Locking object */
lypinator 0:bb348c97df44 138
lypinator 0:bb348c97df44 139 __IO HAL_USART_StateTypeDef State; /* Usart communication state */
lypinator 0:bb348c97df44 140
lypinator 0:bb348c97df44 141 __IO uint32_t ErrorCode; /* USART Error code */
lypinator 0:bb348c97df44 142
lypinator 0:bb348c97df44 143 }USART_HandleTypeDef;
lypinator 0:bb348c97df44 144 /**
lypinator 0:bb348c97df44 145 * @}
lypinator 0:bb348c97df44 146 */
lypinator 0:bb348c97df44 147
lypinator 0:bb348c97df44 148 /* Exported constants --------------------------------------------------------*/
lypinator 0:bb348c97df44 149 /** @defgroup USART_Exported_Constants USART Exported Constants
lypinator 0:bb348c97df44 150 * @{
lypinator 0:bb348c97df44 151 */
lypinator 0:bb348c97df44 152
lypinator 0:bb348c97df44 153 /** @defgroup USART_Error_Code USART Error Code
lypinator 0:bb348c97df44 154 * @brief USART Error Code
lypinator 0:bb348c97df44 155 * @{
lypinator 0:bb348c97df44 156 */
lypinator 0:bb348c97df44 157 #define HAL_USART_ERROR_NONE 0x00000000U /*!< No error */
lypinator 0:bb348c97df44 158 #define HAL_USART_ERROR_PE 0x00000001U /*!< Parity error */
lypinator 0:bb348c97df44 159 #define HAL_USART_ERROR_NE 0x00000002U /*!< Noise error */
lypinator 0:bb348c97df44 160 #define HAL_USART_ERROR_FE 0x00000004U /*!< Frame error */
lypinator 0:bb348c97df44 161 #define HAL_USART_ERROR_ORE 0x00000008U /*!< Overrun error */
lypinator 0:bb348c97df44 162 #define HAL_USART_ERROR_DMA 0x00000010U /*!< DMA transfer error */
lypinator 0:bb348c97df44 163 /**
lypinator 0:bb348c97df44 164 * @}
lypinator 0:bb348c97df44 165 */
lypinator 0:bb348c97df44 166
lypinator 0:bb348c97df44 167 /** @defgroup USART_Word_Length USART Word Length
lypinator 0:bb348c97df44 168 * @{
lypinator 0:bb348c97df44 169 */
lypinator 0:bb348c97df44 170 #define USART_WORDLENGTH_8B 0x00000000U
lypinator 0:bb348c97df44 171 #define USART_WORDLENGTH_9B ((uint32_t)USART_CR1_M)
lypinator 0:bb348c97df44 172 /**
lypinator 0:bb348c97df44 173 * @}
lypinator 0:bb348c97df44 174 */
lypinator 0:bb348c97df44 175
lypinator 0:bb348c97df44 176 /** @defgroup USART_Stop_Bits USART Number of Stop Bits
lypinator 0:bb348c97df44 177 * @{
lypinator 0:bb348c97df44 178 */
lypinator 0:bb348c97df44 179 #define USART_STOPBITS_1 0x00000000U
lypinator 0:bb348c97df44 180 #define USART_STOPBITS_0_5 ((uint32_t)USART_CR2_STOP_0)
lypinator 0:bb348c97df44 181 #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1)
lypinator 0:bb348c97df44 182 #define USART_STOPBITS_1_5 ((uint32_t)(USART_CR2_STOP_0 | USART_CR2_STOP_1))
lypinator 0:bb348c97df44 183 /**
lypinator 0:bb348c97df44 184 * @}
lypinator 0:bb348c97df44 185 */
lypinator 0:bb348c97df44 186
lypinator 0:bb348c97df44 187 /** @defgroup USART_Parity USART Parity
lypinator 0:bb348c97df44 188 * @{
lypinator 0:bb348c97df44 189 */
lypinator 0:bb348c97df44 190 #define USART_PARITY_NONE 0x00000000U
lypinator 0:bb348c97df44 191 #define USART_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
lypinator 0:bb348c97df44 192 #define USART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
lypinator 0:bb348c97df44 193 /**
lypinator 0:bb348c97df44 194 * @}
lypinator 0:bb348c97df44 195 */
lypinator 0:bb348c97df44 196
lypinator 0:bb348c97df44 197 /** @defgroup USART_Mode USART Mode
lypinator 0:bb348c97df44 198 * @{
lypinator 0:bb348c97df44 199 */
lypinator 0:bb348c97df44 200 #define USART_MODE_RX ((uint32_t)USART_CR1_RE)
lypinator 0:bb348c97df44 201 #define USART_MODE_TX ((uint32_t)USART_CR1_TE)
lypinator 0:bb348c97df44 202 #define USART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
lypinator 0:bb348c97df44 203 /**
lypinator 0:bb348c97df44 204 * @}
lypinator 0:bb348c97df44 205 */
lypinator 0:bb348c97df44 206
lypinator 0:bb348c97df44 207 /** @defgroup USART_Clock USART Clock
lypinator 0:bb348c97df44 208 * @{
lypinator 0:bb348c97df44 209 */
lypinator 0:bb348c97df44 210 #define USART_CLOCK_DISABLE 0x00000000U
lypinator 0:bb348c97df44 211 #define USART_CLOCK_ENABLE ((uint32_t)USART_CR2_CLKEN)
lypinator 0:bb348c97df44 212 /**
lypinator 0:bb348c97df44 213 * @}
lypinator 0:bb348c97df44 214 */
lypinator 0:bb348c97df44 215
lypinator 0:bb348c97df44 216 /** @defgroup USART_Clock_Polarity USART Clock Polarity
lypinator 0:bb348c97df44 217 * @{
lypinator 0:bb348c97df44 218 */
lypinator 0:bb348c97df44 219 #define USART_POLARITY_LOW 0x00000000U
lypinator 0:bb348c97df44 220 #define USART_POLARITY_HIGH ((uint32_t)USART_CR2_CPOL)
lypinator 0:bb348c97df44 221 /**
lypinator 0:bb348c97df44 222 * @}
lypinator 0:bb348c97df44 223 */
lypinator 0:bb348c97df44 224
lypinator 0:bb348c97df44 225 /** @defgroup USART_Clock_Phase USART Clock Phase
lypinator 0:bb348c97df44 226 * @{
lypinator 0:bb348c97df44 227 */
lypinator 0:bb348c97df44 228 #define USART_PHASE_1EDGE 0x00000000U
lypinator 0:bb348c97df44 229 #define USART_PHASE_2EDGE ((uint32_t)USART_CR2_CPHA)
lypinator 0:bb348c97df44 230 /**
lypinator 0:bb348c97df44 231 * @}
lypinator 0:bb348c97df44 232 */
lypinator 0:bb348c97df44 233
lypinator 0:bb348c97df44 234 /** @defgroup USART_Last_Bit USART Last Bit
lypinator 0:bb348c97df44 235 * @{
lypinator 0:bb348c97df44 236 */
lypinator 0:bb348c97df44 237 #define USART_LASTBIT_DISABLE 0x00000000U
lypinator 0:bb348c97df44 238 #define USART_LASTBIT_ENABLE ((uint32_t)USART_CR2_LBCL)
lypinator 0:bb348c97df44 239 /**
lypinator 0:bb348c97df44 240 * @}
lypinator 0:bb348c97df44 241 */
lypinator 0:bb348c97df44 242
lypinator 0:bb348c97df44 243 /** @defgroup USART_NACK_State USART NACK State
lypinator 0:bb348c97df44 244 * @{
lypinator 0:bb348c97df44 245 */
lypinator 0:bb348c97df44 246 #define USART_NACK_ENABLE ((uint32_t)USART_CR3_NACK)
lypinator 0:bb348c97df44 247 #define USART_NACK_DISABLE 0x00000000U
lypinator 0:bb348c97df44 248 /**
lypinator 0:bb348c97df44 249 * @}
lypinator 0:bb348c97df44 250 */
lypinator 0:bb348c97df44 251
lypinator 0:bb348c97df44 252 /** @defgroup USART_Flags USART Flags
lypinator 0:bb348c97df44 253 * Elements values convention: 0xXXXX
lypinator 0:bb348c97df44 254 * - 0xXXXX : Flag mask in the SR register
lypinator 0:bb348c97df44 255 * @{
lypinator 0:bb348c97df44 256 */
lypinator 0:bb348c97df44 257 #define USART_FLAG_TXE 0x00000080U
lypinator 0:bb348c97df44 258 #define USART_FLAG_TC 0x00000040U
lypinator 0:bb348c97df44 259 #define USART_FLAG_RXNE 0x00000020U
lypinator 0:bb348c97df44 260 #define USART_FLAG_IDLE 0x00000010U
lypinator 0:bb348c97df44 261 #define USART_FLAG_ORE 0x00000008U
lypinator 0:bb348c97df44 262 #define USART_FLAG_NE 0x00000004U
lypinator 0:bb348c97df44 263 #define USART_FLAG_FE 0x00000002U
lypinator 0:bb348c97df44 264 #define USART_FLAG_PE 0x00000001U
lypinator 0:bb348c97df44 265 /**
lypinator 0:bb348c97df44 266 * @}
lypinator 0:bb348c97df44 267 */
lypinator 0:bb348c97df44 268
lypinator 0:bb348c97df44 269 /** @defgroup USART_Interrupt_definition USART Interrupts Definition
lypinator 0:bb348c97df44 270 * Elements values convention: 0xY000XXXX
lypinator 0:bb348c97df44 271 * - XXXX : Interrupt mask in the XX register
lypinator 0:bb348c97df44 272 * - Y : Interrupt source register (2bits)
lypinator 0:bb348c97df44 273 * - 01: CR1 register
lypinator 0:bb348c97df44 274 * - 10: CR2 register
lypinator 0:bb348c97df44 275 * - 11: CR3 register
lypinator 0:bb348c97df44 276 *
lypinator 0:bb348c97df44 277 * @{
lypinator 0:bb348c97df44 278 */
lypinator 0:bb348c97df44 279 #define USART_IT_PE ((uint32_t)(USART_CR1_REG_INDEX << 28U | USART_CR1_PEIE))
lypinator 0:bb348c97df44 280 #define USART_IT_TXE ((uint32_t)(USART_CR1_REG_INDEX << 28U | USART_CR1_TXEIE))
lypinator 0:bb348c97df44 281 #define USART_IT_TC ((uint32_t)(USART_CR1_REG_INDEX << 28U | USART_CR1_TCIE))
lypinator 0:bb348c97df44 282 #define USART_IT_RXNE ((uint32_t)(USART_CR1_REG_INDEX << 28U | USART_CR1_RXNEIE))
lypinator 0:bb348c97df44 283 #define USART_IT_IDLE ((uint32_t)(USART_CR1_REG_INDEX << 28U | USART_CR1_IDLEIE))
lypinator 0:bb348c97df44 284
lypinator 0:bb348c97df44 285 #define USART_IT_LBD ((uint32_t)(USART_CR2_REG_INDEX << 28U | USART_CR2_LBDIE))
lypinator 0:bb348c97df44 286
lypinator 0:bb348c97df44 287 #define USART_IT_CTS ((uint32_t)(USART_CR3_REG_INDEX << 28U | USART_CR3_CTSIE))
lypinator 0:bb348c97df44 288 #define USART_IT_ERR ((uint32_t)(USART_CR3_REG_INDEX << 28U | USART_CR3_EIE))
lypinator 0:bb348c97df44 289 /**
lypinator 0:bb348c97df44 290 * @}
lypinator 0:bb348c97df44 291 */
lypinator 0:bb348c97df44 292
lypinator 0:bb348c97df44 293 /**
lypinator 0:bb348c97df44 294 * @}
lypinator 0:bb348c97df44 295 */
lypinator 0:bb348c97df44 296
lypinator 0:bb348c97df44 297 /* Exported macro ------------------------------------------------------------*/
lypinator 0:bb348c97df44 298 /** @defgroup USART_Exported_Macros USART Exported Macros
lypinator 0:bb348c97df44 299 * @{
lypinator 0:bb348c97df44 300 */
lypinator 0:bb348c97df44 301
lypinator 0:bb348c97df44 302 /** @brief Reset USART handle state
lypinator 0:bb348c97df44 303 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 304 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
lypinator 0:bb348c97df44 305 * @retval None
lypinator 0:bb348c97df44 306 */
lypinator 0:bb348c97df44 307 #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET)
lypinator 0:bb348c97df44 308
lypinator 0:bb348c97df44 309 /** @brief Checks whether the specified Smartcard flag is set or not.
lypinator 0:bb348c97df44 310 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 311 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
lypinator 0:bb348c97df44 312 * @param __FLAG__ specifies the flag to check.
lypinator 0:bb348c97df44 313 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 314 * @arg USART_FLAG_TXE: Transmit data register empty flag
lypinator 0:bb348c97df44 315 * @arg USART_FLAG_TC: Transmission Complete flag
lypinator 0:bb348c97df44 316 * @arg USART_FLAG_RXNE: Receive data register not empty flag
lypinator 0:bb348c97df44 317 * @arg USART_FLAG_IDLE: Idle Line detection flag
lypinator 0:bb348c97df44 318 * @arg USART_FLAG_ORE: Overrun Error flag
lypinator 0:bb348c97df44 319 * @arg USART_FLAG_NE: Noise Error flag
lypinator 0:bb348c97df44 320 * @arg USART_FLAG_FE: Framing Error flag
lypinator 0:bb348c97df44 321 * @arg USART_FLAG_PE: Parity Error flag
lypinator 0:bb348c97df44 322 * @retval The new state of __FLAG__ (TRUE or FALSE).
lypinator 0:bb348c97df44 323 */
lypinator 0:bb348c97df44 324 #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
lypinator 0:bb348c97df44 325
lypinator 0:bb348c97df44 326 /** @brief Clears the specified Smartcard pending flags.
lypinator 0:bb348c97df44 327 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 328 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
lypinator 0:bb348c97df44 329 * @param __FLAG__ specifies the flag to check.
lypinator 0:bb348c97df44 330 * This parameter can be any combination of the following values:
lypinator 0:bb348c97df44 331 * @arg USART_FLAG_TC: Transmission Complete flag.
lypinator 0:bb348c97df44 332 * @arg USART_FLAG_RXNE: Receive data register not empty flag.
lypinator 0:bb348c97df44 333 *
lypinator 0:bb348c97df44 334 * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (Overrun
lypinator 0:bb348c97df44 335 * error) and IDLE (Idle line detected) flags are cleared by software
lypinator 0:bb348c97df44 336 * sequence: a read operation to USART_SR register followed by a read
lypinator 0:bb348c97df44 337 * operation to USART_DR register.
lypinator 0:bb348c97df44 338 * @note RXNE flag can be also cleared by a read to the USART_DR register.
lypinator 0:bb348c97df44 339 * @note TC flag can be also cleared by software sequence: a read operation to
lypinator 0:bb348c97df44 340 * USART_SR register followed by a write operation to USART_DR register.
lypinator 0:bb348c97df44 341 * @note TXE flag is cleared only by a write to the USART_DR register.
lypinator 0:bb348c97df44 342 *
lypinator 0:bb348c97df44 343 * @retval None
lypinator 0:bb348c97df44 344 */
lypinator 0:bb348c97df44 345 #define __HAL_USART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__))
lypinator 0:bb348c97df44 346
lypinator 0:bb348c97df44 347 /** @brief Clear the USART PE pending flag.
lypinator 0:bb348c97df44 348 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 349 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
lypinator 0:bb348c97df44 350 * @retval None
lypinator 0:bb348c97df44 351 */
lypinator 0:bb348c97df44 352 #define __HAL_USART_CLEAR_PEFLAG(__HANDLE__) \
lypinator 0:bb348c97df44 353 do{ \
lypinator 0:bb348c97df44 354 __IO uint32_t tmpreg = 0x00U; \
lypinator 0:bb348c97df44 355 tmpreg = (__HANDLE__)->Instance->SR; \
lypinator 0:bb348c97df44 356 tmpreg = (__HANDLE__)->Instance->DR; \
lypinator 0:bb348c97df44 357 UNUSED(tmpreg); \
lypinator 0:bb348c97df44 358 } while(0U)
lypinator 0:bb348c97df44 359
lypinator 0:bb348c97df44 360 /** @brief Clear the USART FE pending flag.
lypinator 0:bb348c97df44 361 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 362 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
lypinator 0:bb348c97df44 363 * @retval None
lypinator 0:bb348c97df44 364 */
lypinator 0:bb348c97df44 365 #define __HAL_USART_CLEAR_FEFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__)
lypinator 0:bb348c97df44 366
lypinator 0:bb348c97df44 367 /** @brief Clear the USART NE pending flag.
lypinator 0:bb348c97df44 368 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 369 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
lypinator 0:bb348c97df44 370 * @retval None
lypinator 0:bb348c97df44 371 */
lypinator 0:bb348c97df44 372 #define __HAL_USART_CLEAR_NEFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__)
lypinator 0:bb348c97df44 373
lypinator 0:bb348c97df44 374 /** @brief Clear the UART ORE pending flag.
lypinator 0:bb348c97df44 375 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 376 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
lypinator 0:bb348c97df44 377 * @retval None
lypinator 0:bb348c97df44 378 */
lypinator 0:bb348c97df44 379 #define __HAL_USART_CLEAR_OREFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__)
lypinator 0:bb348c97df44 380
lypinator 0:bb348c97df44 381 /** @brief Clear the USART IDLE pending flag.
lypinator 0:bb348c97df44 382 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 383 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
lypinator 0:bb348c97df44 384 * @retval None
lypinator 0:bb348c97df44 385 */
lypinator 0:bb348c97df44 386 #define __HAL_USART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_USART_CLEAR_PEFLAG(__HANDLE__)
lypinator 0:bb348c97df44 387
lypinator 0:bb348c97df44 388 /** @brief Enables or disables the specified USART interrupts.
lypinator 0:bb348c97df44 389 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 390 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
lypinator 0:bb348c97df44 391 * @param __INTERRUPT__ specifies the USART interrupt source to check.
lypinator 0:bb348c97df44 392 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 393 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
lypinator 0:bb348c97df44 394 * @arg USART_IT_TC: Transmission complete interrupt
lypinator 0:bb348c97df44 395 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
lypinator 0:bb348c97df44 396 * @arg USART_IT_IDLE: Idle line detection interrupt
lypinator 0:bb348c97df44 397 * @arg USART_IT_PE: Parity Error interrupt
lypinator 0:bb348c97df44 398 * @arg USART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
lypinator 0:bb348c97df44 399 * This parameter can be: ENABLE or DISABLE.
lypinator 0:bb348c97df44 400 * @retval None
lypinator 0:bb348c97df44 401 */
lypinator 0:bb348c97df44 402 #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & USART_IT_MASK)): \
lypinator 0:bb348c97df44 403 (((__INTERRUPT__) >> 28U) == 2U)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & USART_IT_MASK)): \
lypinator 0:bb348c97df44 404 ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & USART_IT_MASK)))
lypinator 0:bb348c97df44 405 #define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & USART_IT_MASK)): \
lypinator 0:bb348c97df44 406 (((__INTERRUPT__) >> 28U) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & USART_IT_MASK)): \
lypinator 0:bb348c97df44 407 ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & USART_IT_MASK)))
lypinator 0:bb348c97df44 408
lypinator 0:bb348c97df44 409 /** @brief Checks whether the specified USART interrupt has occurred or not.
lypinator 0:bb348c97df44 410 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 411 * This parameter can be USARTx where x: 1, 2, 3 or 6 to select the USART peripheral.
lypinator 0:bb348c97df44 412 * @param __IT__ specifies the USART interrupt source to check.
lypinator 0:bb348c97df44 413 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 414 * @arg USART_IT_TXE: Transmit Data Register empty interrupt
lypinator 0:bb348c97df44 415 * @arg USART_IT_TC: Transmission complete interrupt
lypinator 0:bb348c97df44 416 * @arg USART_IT_RXNE: Receive Data register not empty interrupt
lypinator 0:bb348c97df44 417 * @arg USART_IT_IDLE: Idle line detection interrupt
lypinator 0:bb348c97df44 418 * @arg USART_IT_ERR: Error interrupt
lypinator 0:bb348c97df44 419 * @arg USART_IT_PE: Parity Error interrupt
lypinator 0:bb348c97df44 420 * @retval The new state of __IT__ (TRUE or FALSE).
lypinator 0:bb348c97df44 421 */
lypinator 0:bb348c97df44 422 #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == 1U)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == 2U)? \
lypinator 0:bb348c97df44 423 (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & USART_IT_MASK))
lypinator 0:bb348c97df44 424
lypinator 0:bb348c97df44 425 /** @brief Macro to enable the USART's one bit sample method
lypinator 0:bb348c97df44 426 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 427 * @retval None
lypinator 0:bb348c97df44 428 */
lypinator 0:bb348c97df44 429 #define __HAL_USART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
lypinator 0:bb348c97df44 430
lypinator 0:bb348c97df44 431 /** @brief Macro to disable the USART's one bit sample method
lypinator 0:bb348c97df44 432 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 433 * @retval None
lypinator 0:bb348c97df44 434 */
lypinator 0:bb348c97df44 435 #define __HAL_USART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT))
lypinator 0:bb348c97df44 436
lypinator 0:bb348c97df44 437 /** @brief Enable USART
lypinator 0:bb348c97df44 438 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 439 * USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
lypinator 0:bb348c97df44 440 * @retval None
lypinator 0:bb348c97df44 441 */
lypinator 0:bb348c97df44 442 #define __HAL_USART_ENABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
lypinator 0:bb348c97df44 443
lypinator 0:bb348c97df44 444 /** @brief Disable USART
lypinator 0:bb348c97df44 445 * @param __HANDLE__ specifies the USART Handle.
lypinator 0:bb348c97df44 446 * USART Handle selects the USARTx peripheral (USART availability and x value depending on device).
lypinator 0:bb348c97df44 447 * @retval None
lypinator 0:bb348c97df44 448 */
lypinator 0:bb348c97df44 449 #define __HAL_USART_DISABLE(__HANDLE__) ( (__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
lypinator 0:bb348c97df44 450
lypinator 0:bb348c97df44 451 /**
lypinator 0:bb348c97df44 452 * @}
lypinator 0:bb348c97df44 453 */
lypinator 0:bb348c97df44 454 /* Exported functions --------------------------------------------------------*/
lypinator 0:bb348c97df44 455 /** @addtogroup USART_Exported_Functions
lypinator 0:bb348c97df44 456 * @{
lypinator 0:bb348c97df44 457 */
lypinator 0:bb348c97df44 458
lypinator 0:bb348c97df44 459 /** @addtogroup USART_Exported_Functions_Group1
lypinator 0:bb348c97df44 460 * @{
lypinator 0:bb348c97df44 461 */
lypinator 0:bb348c97df44 462 /* Initialization/de-initialization functions **********************************/
lypinator 0:bb348c97df44 463 HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 464 HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 465 void HAL_USART_MspInit(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 466 void HAL_USART_MspDeInit(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 467 /**
lypinator 0:bb348c97df44 468 * @}
lypinator 0:bb348c97df44 469 */
lypinator 0:bb348c97df44 470
lypinator 0:bb348c97df44 471 /** @addtogroup USART_Exported_Functions_Group2
lypinator 0:bb348c97df44 472 * @{
lypinator 0:bb348c97df44 473 */
lypinator 0:bb348c97df44 474 /* IO operation functions *******************************************************/
lypinator 0:bb348c97df44 475 HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout);
lypinator 0:bb348c97df44 476 HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
lypinator 0:bb348c97df44 477 HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
lypinator 0:bb348c97df44 478 HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
lypinator 0:bb348c97df44 479 HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
lypinator 0:bb348c97df44 480 HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
lypinator 0:bb348c97df44 481 HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
lypinator 0:bb348c97df44 482 HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
lypinator 0:bb348c97df44 483 HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
lypinator 0:bb348c97df44 484 HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 485 HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 486 HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 487 /* Transfer Abort functions */
lypinator 0:bb348c97df44 488 HAL_StatusTypeDef HAL_USART_Abort(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 489 HAL_StatusTypeDef HAL_USART_Abort_IT(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 490
lypinator 0:bb348c97df44 491 void HAL_USART_IRQHandler(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 492 void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 493 void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 494 void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 495 void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 496 void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 497 void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 498 void HAL_USART_AbortCpltCallback (USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 499 /**
lypinator 0:bb348c97df44 500 * @}
lypinator 0:bb348c97df44 501 */
lypinator 0:bb348c97df44 502
lypinator 0:bb348c97df44 503 /** @addtogroup USART_Exported_Functions_Group3
lypinator 0:bb348c97df44 504 * @{
lypinator 0:bb348c97df44 505 */
lypinator 0:bb348c97df44 506 /* Peripheral State functions ************************************************/
lypinator 0:bb348c97df44 507 HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 508 uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart);
lypinator 0:bb348c97df44 509 /**
lypinator 0:bb348c97df44 510 * @}
lypinator 0:bb348c97df44 511 */
lypinator 0:bb348c97df44 512
lypinator 0:bb348c97df44 513 /**
lypinator 0:bb348c97df44 514 * @}
lypinator 0:bb348c97df44 515 */
lypinator 0:bb348c97df44 516 /* Private types -------------------------------------------------------------*/
lypinator 0:bb348c97df44 517 /* Private variables ---------------------------------------------------------*/
lypinator 0:bb348c97df44 518 /* Private constants ---------------------------------------------------------*/
lypinator 0:bb348c97df44 519 /** @defgroup USART_Private_Constants USART Private Constants
lypinator 0:bb348c97df44 520 * @{
lypinator 0:bb348c97df44 521 */
lypinator 0:bb348c97df44 522 /** @brief USART interruptions flag mask
lypinator 0:bb348c97df44 523 *
lypinator 0:bb348c97df44 524 */
lypinator 0:bb348c97df44 525 #define USART_IT_MASK ((uint32_t) USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE | USART_CR1_RXNEIE | \
lypinator 0:bb348c97df44 526 USART_CR1_IDLEIE | USART_CR2_LBDIE | USART_CR3_CTSIE | USART_CR3_EIE )
lypinator 0:bb348c97df44 527
lypinator 0:bb348c97df44 528 #define USART_CR1_REG_INDEX 1U
lypinator 0:bb348c97df44 529 #define USART_CR2_REG_INDEX 2U
lypinator 0:bb348c97df44 530 #define USART_CR3_REG_INDEX 3U
lypinator 0:bb348c97df44 531 /**
lypinator 0:bb348c97df44 532 * @}
lypinator 0:bb348c97df44 533 */
lypinator 0:bb348c97df44 534
lypinator 0:bb348c97df44 535 /* Private macros ------------------------------------------------------------*/
lypinator 0:bb348c97df44 536 /** @defgroup USART_Private_Macros USART Private Macros
lypinator 0:bb348c97df44 537 * @{
lypinator 0:bb348c97df44 538 */
lypinator 0:bb348c97df44 539 #define IS_USART_NACK_STATE(NACK) (((NACK) == USART_NACK_ENABLE) || \
lypinator 0:bb348c97df44 540 ((NACK) == USART_NACK_DISABLE))
lypinator 0:bb348c97df44 541 #define IS_USART_LASTBIT(LASTBIT) (((LASTBIT) == USART_LASTBIT_DISABLE) || \
lypinator 0:bb348c97df44 542 ((LASTBIT) == USART_LASTBIT_ENABLE))
lypinator 0:bb348c97df44 543 #define IS_USART_PHASE(CPHA) (((CPHA) == USART_PHASE_1EDGE) || ((CPHA) == USART_PHASE_2EDGE))
lypinator 0:bb348c97df44 544 #define IS_USART_POLARITY(CPOL) (((CPOL) == USART_POLARITY_LOW) || ((CPOL) == USART_POLARITY_HIGH))
lypinator 0:bb348c97df44 545 #define IS_USART_CLOCK(CLOCK) (((CLOCK) == USART_CLOCK_DISABLE) || \
lypinator 0:bb348c97df44 546 ((CLOCK) == USART_CLOCK_ENABLE))
lypinator 0:bb348c97df44 547 #define IS_USART_WORD_LENGTH(LENGTH) (((LENGTH) == USART_WORDLENGTH_8B) || \
lypinator 0:bb348c97df44 548 ((LENGTH) == USART_WORDLENGTH_9B))
lypinator 0:bb348c97df44 549 #define IS_USART_STOPBITS(STOPBITS) (((STOPBITS) == USART_STOPBITS_1) || \
lypinator 0:bb348c97df44 550 ((STOPBITS) == USART_STOPBITS_0_5) || \
lypinator 0:bb348c97df44 551 ((STOPBITS) == USART_STOPBITS_1_5) || \
lypinator 0:bb348c97df44 552 ((STOPBITS) == USART_STOPBITS_2))
lypinator 0:bb348c97df44 553 #define IS_USART_PARITY(PARITY) (((PARITY) == USART_PARITY_NONE) || \
lypinator 0:bb348c97df44 554 ((PARITY) == USART_PARITY_EVEN) || \
lypinator 0:bb348c97df44 555 ((PARITY) == USART_PARITY_ODD))
lypinator 0:bb348c97df44 556 #define IS_USART_MODE(MODE) ((((MODE) & 0xFFF3U) == 0x00U) && ((MODE) != 0x00U))
lypinator 0:bb348c97df44 557 #define IS_USART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 10500001U)
lypinator 0:bb348c97df44 558
lypinator 0:bb348c97df44 559 #define USART_DIV(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(2U*(_BAUD_)))
lypinator 0:bb348c97df44 560 #define USART_DIVMANT(_PCLK_, _BAUD_) (USART_DIV((_PCLK_), (_BAUD_))/100U)
lypinator 0:bb348c97df44 561 #define USART_DIVFRAQ(_PCLK_, _BAUD_) (((USART_DIV((_PCLK_), (_BAUD_)) - (USART_DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U + 50U) / 100U)
lypinator 0:bb348c97df44 562 #define USART_BRR(_PCLK_, _BAUD_) ((USART_DIVMANT((_PCLK_), (_BAUD_)) << 4U)|(USART_DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU))
lypinator 0:bb348c97df44 563 /**
lypinator 0:bb348c97df44 564 * @}
lypinator 0:bb348c97df44 565 */
lypinator 0:bb348c97df44 566
lypinator 0:bb348c97df44 567 /* Private functions ---------------------------------------------------------*/
lypinator 0:bb348c97df44 568 /** @defgroup USART_Private_Functions USART Private Functions
lypinator 0:bb348c97df44 569 * @{
lypinator 0:bb348c97df44 570 */
lypinator 0:bb348c97df44 571
lypinator 0:bb348c97df44 572 /**
lypinator 0:bb348c97df44 573 * @}
lypinator 0:bb348c97df44 574 */
lypinator 0:bb348c97df44 575
lypinator 0:bb348c97df44 576 /**
lypinator 0:bb348c97df44 577 * @}
lypinator 0:bb348c97df44 578 */
lypinator 0:bb348c97df44 579
lypinator 0:bb348c97df44 580 /**
lypinator 0:bb348c97df44 581 * @}
lypinator 0:bb348c97df44 582 */
lypinator 0:bb348c97df44 583
lypinator 0:bb348c97df44 584 #ifdef __cplusplus
lypinator 0:bb348c97df44 585 }
lypinator 0:bb348c97df44 586 #endif
lypinator 0:bb348c97df44 587
lypinator 0:bb348c97df44 588 #endif /* __STM32F4xx_HAL_USART_H */
lypinator 0:bb348c97df44 589
lypinator 0:bb348c97df44 590 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/