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:
elijahorr
Date:
Thu Apr 14 07:28:54 2016 +0000
Revision:
121:672067c3ada4
Parent:
110:165afa46840b
.

Who changed what in which revision?

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