Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | /** |
| 2 | ****************************************************************************** |
||
| 3 | * @file stm32f0xx_hal_usart.h |
||
| 4 | * @author MCD Application Team |
||
| 5 | * @brief Header file of USART HAL module. |
||
| 6 | ****************************************************************************** |
||
| 7 | * @attention |
||
| 8 | * |
||
| 9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
||
| 10 | * All rights reserved.</center></h2> |
||
| 11 | * |
||
| 12 | * This software component is licensed by ST under BSD 3-Clause license, |
||
| 13 | * the "License"; You may not use this file except in compliance with the |
||
| 14 | * License. You may obtain a copy of the License at: |
||
| 15 | * opensource.org/licenses/BSD-3-Clause |
||
| 16 | * |
||
| 17 | ****************************************************************************** |
||
| 18 | */ |
||
| 19 | |||
| 20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
||
| 21 | #ifndef STM32F0xx_HAL_USART_H |
||
| 22 | #define STM32F0xx_HAL_USART_H |
||
| 23 | |||
| 24 | #ifdef __cplusplus |
||
| 25 | extern "C" { |
||
| 26 | #endif |
||
| 27 | |||
| 28 | /* Includes ------------------------------------------------------------------*/ |
||
| 29 | #include "stm32f0xx_hal_def.h" |
||
| 30 | |||
| 31 | /** @addtogroup STM32F0xx_HAL_Driver |
||
| 32 | * @{ |
||
| 33 | */ |
||
| 34 | |||
| 35 | /** @addtogroup USART |
||
| 36 | * @{ |
||
| 37 | */ |
||
| 38 | |||
| 39 | /* Exported types ------------------------------------------------------------*/ |
||
| 40 | /** @defgroup USART_Exported_Types USART Exported Types |
||
| 41 | * @{ |
||
| 42 | */ |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @brief USART Init Structure definition |
||
| 46 | */ |
||
| 47 | typedef struct |
||
| 48 | { |
||
| 49 | uint32_t BaudRate; /*!< This member configures the Usart communication baud rate. |
||
| 50 | The baud rate is computed using the following formula: |
||
| 51 | Baud Rate Register[15:4] = ((2 * fclk_pres) / ((huart->Init.BaudRate)))[15:4] |
||
| 52 | Baud Rate Register[3] = 0 |
||
| 53 | Baud Rate Register[2:0] = (((2 * fclk_pres) / ((huart->Init.BaudRate)))[3:0]) >> 1 |
||
| 54 | where fclk_pres is the USART input clock frequency |
||
| 55 | @note Oversampling by 8 is systematically applied to achieve high baud rates. */ |
||
| 56 | |||
| 57 | uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame. |
||
| 58 | This parameter can be a value of @ref USARTEx_Word_Length. */ |
||
| 59 | |||
| 60 | uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. |
||
| 61 | This parameter can be a value of @ref USART_Stop_Bits. */ |
||
| 62 | |||
| 63 | uint32_t Parity; /*!< Specifies the parity mode. |
||
| 64 | This parameter can be a value of @ref USART_Parity |
||
| 65 | @note When parity is enabled, the computed parity is inserted |
||
| 66 | at the MSB position of the transmitted data (9th bit when |
||
| 67 | the word length is set to 9 data bits; 8th bit when the |
||
| 68 | word length is set to 8 data bits). */ |
||
| 69 | |||
| 70 | uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled. |
||
| 71 | This parameter can be a value of @ref USART_Mode. */ |
||
| 72 | |||
| 73 | uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock. |
||
| 74 | This parameter can be a value of @ref USART_Clock_Polarity. */ |
||
| 75 | |||
| 76 | uint32_t CLKPhase; /*!< Specifies the clock transition on which the bit capture is made. |
||
| 77 | This parameter can be a value of @ref USART_Clock_Phase. */ |
||
| 78 | |||
| 79 | uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted |
||
| 80 | data bit (MSB) has to be output on the SCLK pin in synchronous mode. |
||
| 81 | This parameter can be a value of @ref USART_Last_Bit. */ |
||
| 82 | |||
| 83 | } USART_InitTypeDef; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @brief HAL USART State structures definition |
||
| 87 | */ |
||
| 88 | typedef enum |
||
| 89 | { |
||
| 90 | HAL_USART_STATE_RESET = 0x00U, /*!< Peripheral is not initialized */ |
||
| 91 | HAL_USART_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */ |
||
| 92 | HAL_USART_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */ |
||
| 93 | HAL_USART_STATE_BUSY_TX = 0x12U, /*!< Data Transmission process is ongoing */ |
||
| 94 | HAL_USART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */ |
||
| 95 | HAL_USART_STATE_BUSY_TX_RX = 0x32U, /*!< Data Transmission Reception process is ongoing */ |
||
| 96 | HAL_USART_STATE_TIMEOUT = 0x03U, /*!< Timeout state */ |
||
| 97 | HAL_USART_STATE_ERROR = 0x04U /*!< Error */ |
||
| 98 | } HAL_USART_StateTypeDef; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @brief USART clock sources definitions |
||
| 102 | */ |
||
| 103 | typedef enum |
||
| 104 | { |
||
| 105 | USART_CLOCKSOURCE_PCLK1 = 0x00U, /*!< PCLK1 clock source */ |
||
| 106 | USART_CLOCKSOURCE_HSI = 0x02U, /*!< HSI clock source */ |
||
| 107 | USART_CLOCKSOURCE_SYSCLK = 0x04U, /*!< SYSCLK clock source */ |
||
| 108 | USART_CLOCKSOURCE_LSE = 0x08U, /*!< LSE clock source */ |
||
| 109 | USART_CLOCKSOURCE_UNDEFINED = 0x10U /*!< Undefined clock source */ |
||
| 110 | } USART_ClockSourceTypeDef; |
||
| 111 | |||
| 112 | /** |
||
| 113 | * @brief USART handle Structure definition |
||
| 114 | */ |
||
| 115 | typedef struct __USART_HandleTypeDef |
||
| 116 | { |
||
| 117 | USART_TypeDef *Instance; /*!< USART registers base address */ |
||
| 118 | |||
| 119 | USART_InitTypeDef Init; /*!< USART communication parameters */ |
||
| 120 | |||
| 121 | uint8_t *pTxBuffPtr; /*!< Pointer to USART Tx transfer Buffer */ |
||
| 122 | |||
| 123 | uint16_t TxXferSize; /*!< USART Tx Transfer size */ |
||
| 124 | |||
| 125 | __IO uint16_t TxXferCount; /*!< USART Tx Transfer Counter */ |
||
| 126 | |||
| 127 | uint8_t *pRxBuffPtr; /*!< Pointer to USART Rx transfer Buffer */ |
||
| 128 | |||
| 129 | uint16_t RxXferSize; /*!< USART Rx Transfer size */ |
||
| 130 | |||
| 131 | __IO uint16_t RxXferCount; /*!< USART Rx Transfer Counter */ |
||
| 132 | |||
| 133 | uint16_t Mask; /*!< USART Rx RDR register mask */ |
||
| 134 | |||
| 135 | void (*RxISR)(struct __USART_HandleTypeDef *husart); /*!< Function pointer on Rx IRQ handler */ |
||
| 136 | |||
| 137 | void (*TxISR)(struct __USART_HandleTypeDef *husart); /*!< Function pointer on Tx IRQ handler */ |
||
| 138 | |||
| 139 | DMA_HandleTypeDef *hdmatx; /*!< USART Tx DMA Handle parameters */ |
||
| 140 | |||
| 141 | DMA_HandleTypeDef *hdmarx; /*!< USART Rx DMA Handle parameters */ |
||
| 142 | |||
| 143 | HAL_LockTypeDef Lock; /*!< Locking object */ |
||
| 144 | |||
| 145 | __IO HAL_USART_StateTypeDef State; /*!< USART communication state */ |
||
| 146 | |||
| 147 | __IO uint32_t ErrorCode; /*!< USART Error code */ |
||
| 148 | |||
| 149 | #if (USE_HAL_USART_REGISTER_CALLBACKS == 1) |
||
| 150 | void (* TxHalfCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Tx Half Complete Callback */ |
||
| 151 | void (* TxCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Tx Complete Callback */ |
||
| 152 | void (* RxHalfCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Rx Half Complete Callback */ |
||
| 153 | void (* RxCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Rx Complete Callback */ |
||
| 154 | void (* TxRxCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Tx Rx Complete Callback */ |
||
| 155 | void (* ErrorCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Error Callback */ |
||
| 156 | void (* AbortCpltCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Abort Complete Callback */ |
||
| 157 | |||
| 158 | void (* MspInitCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Msp Init callback */ |
||
| 159 | void (* MspDeInitCallback)(struct __USART_HandleTypeDef *husart); /*!< USART Msp DeInit callback */ |
||
| 160 | #endif /* USE_HAL_USART_REGISTER_CALLBACKS */ |
||
| 161 | |||
| 162 | } USART_HandleTypeDef; |
||
| 163 | |||
| 164 | #if (USE_HAL_USART_REGISTER_CALLBACKS == 1) |
||
| 165 | /** |
||
| 166 | * @brief HAL USART Callback ID enumeration definition |
||
| 167 | */ |
||
| 168 | typedef enum |
||
| 169 | { |
||
| 170 | HAL_USART_TX_HALFCOMPLETE_CB_ID = 0x00U, /*!< USART Tx Half Complete Callback ID */ |
||
| 171 | HAL_USART_TX_COMPLETE_CB_ID = 0x01U, /*!< USART Tx Complete Callback ID */ |
||
| 172 | HAL_USART_RX_HALFCOMPLETE_CB_ID = 0x02U, /*!< USART Rx Half Complete Callback ID */ |
||
| 173 | HAL_USART_RX_COMPLETE_CB_ID = 0x03U, /*!< USART Rx Complete Callback ID */ |
||
| 174 | HAL_USART_TX_RX_COMPLETE_CB_ID = 0x04U, /*!< USART Tx Rx Complete Callback ID */ |
||
| 175 | HAL_USART_ERROR_CB_ID = 0x05U, /*!< USART Error Callback ID */ |
||
| 176 | HAL_USART_ABORT_COMPLETE_CB_ID = 0x06U, /*!< USART Abort Complete Callback ID */ |
||
| 177 | |||
| 178 | HAL_USART_MSPINIT_CB_ID = 0x09U, /*!< USART MspInit callback ID */ |
||
| 179 | HAL_USART_MSPDEINIT_CB_ID = 0x0AU /*!< USART MspDeInit callback ID */ |
||
| 180 | |||
| 181 | } HAL_USART_CallbackIDTypeDef; |
||
| 182 | |||
| 183 | /** |
||
| 184 | * @brief HAL USART Callback pointer definition |
||
| 185 | */ |
||
| 186 | typedef void (*pUSART_CallbackTypeDef)(USART_HandleTypeDef *husart); /*!< pointer to an USART callback function */ |
||
| 187 | |||
| 188 | #endif /* USE_HAL_USART_REGISTER_CALLBACKS */ |
||
| 189 | |||
| 190 | /** |
||
| 191 | * @} |
||
| 192 | */ |
||
| 193 | |||
| 194 | /* Exported constants --------------------------------------------------------*/ |
||
| 195 | /** @defgroup USART_Exported_Constants USART Exported Constants |
||
| 196 | * @{ |
||
| 197 | */ |
||
| 198 | |||
| 199 | /** @defgroup USART_Error_Definition USART Error Definition |
||
| 200 | * @{ |
||
| 201 | */ |
||
| 202 | #define HAL_USART_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */ |
||
| 203 | #define HAL_USART_ERROR_PE ((uint32_t)0x00000001U) /*!< Parity error */ |
||
| 204 | #define HAL_USART_ERROR_NE ((uint32_t)0x00000002U) /*!< Noise error */ |
||
| 205 | #define HAL_USART_ERROR_FE ((uint32_t)0x00000004U) /*!< Frame error */ |
||
| 206 | #define HAL_USART_ERROR_ORE ((uint32_t)0x00000008U) /*!< Overrun error */ |
||
| 207 | #define HAL_USART_ERROR_DMA ((uint32_t)0x00000010U) /*!< DMA transfer error */ |
||
| 208 | #if (USE_HAL_USART_REGISTER_CALLBACKS == 1) |
||
| 209 | #define HAL_USART_ERROR_INVALID_CALLBACK ((uint32_t)0x00000040U) /*!< Invalid Callback error */ |
||
| 210 | #endif /* USE_HAL_USART_REGISTER_CALLBACKS */ |
||
| 211 | /** |
||
| 212 | * @} |
||
| 213 | */ |
||
| 214 | |||
| 215 | /** @defgroup USART_Stop_Bits USART Number of Stop Bits |
||
| 216 | * @{ |
||
| 217 | */ |
||
| 218 | #if defined(USART_SMARTCARD_SUPPORT) |
||
| 219 | #define USART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< USART frame with 0.5 stop bit */ |
||
| 220 | #define USART_STOPBITS_1 0x00000000U /*!< USART frame with 1 stop bit */ |
||
| 221 | #define USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< USART frame with 1.5 stop bits */ |
||
| 222 | #define USART_STOPBITS_2 USART_CR2_STOP_1 /*!< USART frame with 2 stop bits */ |
||
| 223 | #else |
||
| 224 | #define USART_STOPBITS_1 (0x00000000U) /*!< USART frame with 1 stop bit */ |
||
| 225 | #define USART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) /*!< USART frame with 2 stop bits */ |
||
| 226 | #endif /* USART_SMARTCARD_SUPPORT */ |
||
| 227 | /** |
||
| 228 | * @} |
||
| 229 | */ |
||
| 230 | |||
| 231 | /** @defgroup USART_Parity USART Parity |
||
| 232 | * @{ |
||
| 233 | */ |
||
| 234 | #define USART_PARITY_NONE 0x00000000U /*!< No parity */ |
||
| 235 | #define USART_PARITY_EVEN USART_CR1_PCE /*!< Even parity */ |
||
| 236 | #define USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Odd parity */ |
||
| 237 | /** |
||
| 238 | * @} |
||
| 239 | */ |
||
| 240 | |||
| 241 | /** @defgroup USART_Mode USART Mode |
||
| 242 | * @{ |
||
| 243 | */ |
||
| 244 | #define USART_MODE_RX USART_CR1_RE /*!< RX mode */ |
||
| 245 | #define USART_MODE_TX USART_CR1_TE /*!< TX mode */ |
||
| 246 | #define USART_MODE_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< RX and TX mode */ |
||
| 247 | /** |
||
| 248 | * @} |
||
| 249 | */ |
||
| 250 | |||
| 251 | /** @defgroup USART_Over_Sampling USART Over Sampling |
||
| 252 | * @{ |
||
| 253 | */ |
||
| 254 | #define USART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */ |
||
| 255 | #define USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */ |
||
| 256 | /** |
||
| 257 | * @} |
||
| 258 | */ |
||
| 259 | |||
| 260 | /** @defgroup USART_Clock USART Clock |
||
| 261 | * @{ |
||
| 262 | */ |
||
| 263 | #define USART_CLOCK_DISABLE 0x00000000U /*!< USART clock disable */ |
||
| 264 | #define USART_CLOCK_ENABLE USART_CR2_CLKEN /*!< USART clock enable */ |
||
| 265 | /** |
||
| 266 | * @} |
||
| 267 | */ |
||
| 268 | |||
| 269 | /** @defgroup USART_Clock_Polarity USART Clock Polarity |
||
| 270 | * @{ |
||
| 271 | */ |
||
| 272 | #define USART_POLARITY_LOW 0x00000000U /*!< Driver enable signal is active high */ |
||
| 273 | #define USART_POLARITY_HIGH USART_CR2_CPOL /*!< Driver enable signal is active low */ |
||
| 274 | /** |
||
| 275 | * @} |
||
| 276 | */ |
||
| 277 | |||
| 278 | /** @defgroup USART_Clock_Phase USART Clock Phase |
||
| 279 | * @{ |
||
| 280 | */ |
||
| 281 | #define USART_PHASE_1EDGE 0x00000000U /*!< USART frame phase on first clock transition */ |
||
| 282 | #define USART_PHASE_2EDGE USART_CR2_CPHA /*!< USART frame phase on second clock transition */ |
||
| 283 | /** |
||
| 284 | * @} |
||
| 285 | */ |
||
| 286 | |||
| 287 | /** @defgroup USART_Last_Bit USART Last Bit |
||
| 288 | * @{ |
||
| 289 | */ |
||
| 290 | #define USART_LASTBIT_DISABLE 0x00000000U /*!< USART frame last data bit clock pulse not output to SCLK pin */ |
||
| 291 | #define USART_LASTBIT_ENABLE USART_CR2_LBCL /*!< USART frame last data bit clock pulse output to SCLK pin */ |
||
| 292 | /** |
||
| 293 | * @} |
||
| 294 | */ |
||
| 295 | |||
| 296 | |||
| 297 | /** @defgroup USART_Request_Parameters USART Request Parameters |
||
| 298 | * @{ |
||
| 299 | */ |
||
| 300 | #define USART_RXDATA_FLUSH_REQUEST USART_RQR_RXFRQ /*!< Receive Data flush Request */ |
||
| 301 | #if defined(USART_RQR_TXFRQ) |
||
| 302 | #define USART_TXDATA_FLUSH_REQUEST USART_RQR_TXFRQ /*!< Transmit data flush Request */ |
||
| 303 | #endif /* USART_RQR_TXFRQ */ |
||
| 304 | /** |
||
| 305 | * @} |
||
| 306 | */ |
||
| 307 | |||
| 308 | /** @defgroup USART_Flags USART Flags |
||
| 309 | * Elements values convention: 0xXXXX |
||
| 310 | * - 0xXXXX : Flag mask in the ISR register |
||
| 311 | * @{ |
||
| 312 | */ |
||
| 313 | #define USART_FLAG_REACK USART_ISR_REACK /*!< USART receive enable acknowledge flag */ |
||
| 314 | #define USART_FLAG_TEACK USART_ISR_TEACK /*!< USART transmit enable acknowledge flag */ |
||
| 315 | #define USART_FLAG_BUSY USART_ISR_BUSY /*!< USART busy flag */ |
||
| 316 | #define USART_FLAG_TXE USART_ISR_TXE /*!< USART transmit data register empty */ |
||
| 317 | #define USART_FLAG_TC USART_ISR_TC /*!< USART transmission complete */ |
||
| 318 | #define USART_FLAG_RXNE USART_ISR_RXNE /*!< USART read data register not empty */ |
||
| 319 | #define USART_FLAG_IDLE USART_ISR_IDLE /*!< USART idle flag */ |
||
| 320 | #define USART_FLAG_ORE USART_ISR_ORE /*!< USART overrun error */ |
||
| 321 | #define USART_FLAG_NE USART_ISR_NE /*!< USART noise error */ |
||
| 322 | #define USART_FLAG_FE USART_ISR_FE /*!< USART frame error */ |
||
| 323 | #define USART_FLAG_PE USART_ISR_PE /*!< USART parity error */ |
||
| 324 | /** |
||
| 325 | * @} |
||
| 326 | */ |
||
| 327 | |||
| 328 | /** @defgroup USART_Interrupt_definition USART Interrupts Definition |
||
| 329 | * Elements values convention: 0000ZZZZ0XXYYYYYb |
||
| 330 | * - YYYYY : Interrupt source position in the XX register (5bits) |
||
| 331 | * - XX : Interrupt source register (2bits) |
||
| 332 | * - 01: CR1 register |
||
| 333 | * - 10: CR2 register |
||
| 334 | * - 11: CR3 register |
||
| 335 | * - ZZZZ : Flag position in the ISR register(4bits) |
||
| 336 | * @{ |
||
| 337 | */ |
||
| 338 | |||
| 339 | #define USART_IT_PE 0x0028U /*!< USART parity error interruption */ |
||
| 340 | #define USART_IT_TXE 0x0727U /*!< USART transmit data register empty interruption */ |
||
| 341 | #define USART_IT_TC 0x0626U /*!< USART transmission complete interruption */ |
||
| 342 | #define USART_IT_RXNE 0x0525U /*!< USART read data register not empty interruption */ |
||
| 343 | #define USART_IT_IDLE 0x0424U /*!< USART idle interruption */ |
||
| 344 | #define USART_IT_ERR 0x0060U /*!< USART error interruption */ |
||
| 345 | #define USART_IT_ORE 0x0300U /*!< USART overrun error interruption */ |
||
| 346 | #define USART_IT_NE 0x0200U /*!< USART noise error interruption */ |
||
| 347 | #define USART_IT_FE 0x0100U /*!< USART frame error interruption */ |
||
| 348 | |||
| 349 | /** |
||
| 350 | * @} |
||
| 351 | */ |
||
| 352 | |||
| 353 | /** @defgroup USART_IT_CLEAR_Flags USART Interruption Clear Flags |
||
| 354 | * @{ |
||
| 355 | */ |
||
| 356 | #define USART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */ |
||
| 357 | #define USART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */ |
||
| 358 | #define USART_CLEAR_NEF USART_ICR_NCF /*!< Noise Error detected Clear Flag */ |
||
| 359 | #define USART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */ |
||
| 360 | #define USART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */ |
||
| 361 | #define USART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */ |
||
| 362 | #define USART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */ |
||
| 363 | /** |
||
| 364 | * @} |
||
| 365 | */ |
||
| 366 | |||
| 367 | /** @defgroup USART_Interruption_Mask USART Interruption Flags Mask |
||
| 368 | * @{ |
||
| 369 | */ |
||
| 370 | #define USART_IT_MASK 0x001FU /*!< USART interruptions flags mask */ |
||
| 371 | #define USART_CR_MASK 0x00E0U /*!< USART control register mask */ |
||
| 372 | #define USART_CR_POS 5U /*!< USART control register position */ |
||
| 373 | #define USART_ISR_MASK 0x1F00U /*!< USART ISR register mask */ |
||
| 374 | #define USART_ISR_POS 8U /*!< USART ISR register position */ |
||
| 375 | /** |
||
| 376 | * @} |
||
| 377 | */ |
||
| 378 | |||
| 379 | /** |
||
| 380 | * @} |
||
| 381 | */ |
||
| 382 | |||
| 383 | /* Exported macros -----------------------------------------------------------*/ |
||
| 384 | /** @defgroup USART_Exported_Macros USART Exported Macros |
||
| 385 | * @{ |
||
| 386 | */ |
||
| 387 | |||
| 388 | /** @brief Reset USART handle state. |
||
| 389 | * @param __HANDLE__ USART handle. |
||
| 390 | * @retval None |
||
| 391 | */ |
||
| 392 | #if (USE_HAL_USART_REGISTER_CALLBACKS == 1) |
||
| 393 | #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) do{ \ |
||
| 394 | (__HANDLE__)->State = HAL_USART_STATE_RESET; \ |
||
| 395 | (__HANDLE__)->MspInitCallback = NULL; \ |
||
| 396 | (__HANDLE__)->MspDeInitCallback = NULL; \ |
||
| 397 | } while(0U) |
||
| 398 | #else |
||
| 399 | #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET) |
||
| 400 | #endif /* USE_HAL_USART_REGISTER_CALLBACKS */ |
||
| 401 | |||
| 402 | /** @brief Check whether the specified USART flag is set or not. |
||
| 403 | * @param __HANDLE__ specifies the USART Handle |
||
| 404 | * @param __FLAG__ specifies the flag to check. |
||
| 405 | * This parameter can be one of the following values: |
||
| 406 | * @arg @ref USART_FLAG_REACK Receive enable acknowledge flag |
||
| 407 | * @arg @ref USART_FLAG_TEACK Transmit enable acknowledge flag |
||
| 408 | * @arg @ref USART_FLAG_BUSY Busy flag |
||
| 409 | * @arg @ref USART_FLAG_CTS CTS Change flag |
||
| 410 | * @arg @ref USART_FLAG_TXE Transmit data register empty flag |
||
| 411 | * @arg @ref USART_FLAG_TC Transmission Complete flag |
||
| 412 | * @arg @ref USART_FLAG_RXNE Receive data register not empty flag |
||
| 413 | * @arg @ref USART_FLAG_IDLE Idle Line detection flag |
||
| 414 | * @arg @ref USART_FLAG_ORE OverRun Error flag |
||
| 415 | * @arg @ref USART_FLAG_NE Noise Error flag |
||
| 416 | * @arg @ref USART_FLAG_FE Framing Error flag |
||
| 417 | * @arg @ref USART_FLAG_PE Parity Error flag |
||
| 418 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
||
| 419 | */ |
||
| 420 | #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__)) |
||
| 421 | |||
| 422 | /** @brief Clear the specified USART pending flag. |
||
| 423 | * @param __HANDLE__ specifies the USART Handle. |
||
| 424 | * @param __FLAG__ specifies the flag to check. |
||
| 425 | * This parameter can be any combination of the following values: |
||
| 426 | * @arg @ref USART_CLEAR_PEF Parity Error Clear Flag |
||
| 427 | * @arg @ref USART_CLEAR_FEF Framing Error Clear Flag |
||
| 428 | * @arg @ref USART_CLEAR_NEF Noise detected Clear Flag |
||
| 429 | * @arg @ref USART_CLEAR_OREF Overrun Error Clear Flag |
||
| 430 | * @arg @ref USART_CLEAR_IDLEF IDLE line detected Clear Flag |
||
| 431 | * @arg @ref USART_CLEAR_TCF Transmission Complete Clear Flag |
||
| 432 | * @arg @ref USART_CLEAR_CTSF |
||
| 433 | * @retval None |
||
| 434 | */ |
||
| 435 | #define __HAL_USART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) |
||
| 436 | |||
| 437 | /** @brief Clear the USART PE pending flag. |
||
| 438 | * @param __HANDLE__ specifies the USART Handle. |
||
| 439 | * @retval None |
||
| 440 | */ |
||
| 441 | #define __HAL_USART_CLEAR_PEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_PEF) |
||
| 442 | |||
| 443 | /** @brief Clear the USART FE pending flag. |
||
| 444 | * @param __HANDLE__ specifies the USART Handle. |
||
| 445 | * @retval None |
||
| 446 | */ |
||
| 447 | #define __HAL_USART_CLEAR_FEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_FEF) |
||
| 448 | |||
| 449 | /** @brief Clear the USART NE pending flag. |
||
| 450 | * @param __HANDLE__ specifies the USART Handle. |
||
| 451 | * @retval None |
||
| 452 | */ |
||
| 453 | #define __HAL_USART_CLEAR_NEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_NEF) |
||
| 454 | |||
| 455 | /** @brief Clear the USART ORE pending flag. |
||
| 456 | * @param __HANDLE__ specifies the USART Handle. |
||
| 457 | * @retval None |
||
| 458 | */ |
||
| 459 | #define __HAL_USART_CLEAR_OREFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_OREF) |
||
| 460 | |||
| 461 | /** @brief Clear the USART IDLE pending flag. |
||
| 462 | * @param __HANDLE__ specifies the USART Handle. |
||
| 463 | * @retval None |
||
| 464 | */ |
||
| 465 | #define __HAL_USART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_IDLEF) |
||
| 466 | |||
| 467 | |||
| 468 | |||
| 469 | /** @brief Enable the specified USART interrupt. |
||
| 470 | * @param __HANDLE__ specifies the USART Handle. |
||
| 471 | * @param __INTERRUPT__ specifies the USART interrupt source to enable. |
||
| 472 | * This parameter can be one of the following values: |
||
| 473 | * @arg @ref USART_IT_TXE Transmit Data Register empty interrupt |
||
| 474 | * @arg @ref USART_IT_TC Transmission complete interrupt |
||
| 475 | * @arg @ref USART_IT_RXNE Receive Data register not empty interrupt |
||
| 476 | * @arg @ref USART_IT_IDLE Idle line detection interrupt |
||
| 477 | * @arg @ref USART_IT_PE Parity Error interrupt |
||
| 478 | * @arg @ref USART_IT_ERR Error interrupt(Frame error, noise error, overrun error) |
||
| 479 | * @retval None |
||
| 480 | */ |
||
| 481 | #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & USART_CR_MASK) >> USART_CR_POS) == 1U)? ((__HANDLE__)->Instance->CR1 |= ((uint32_t)1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
||
| 482 | ((((__INTERRUPT__) & USART_CR_MASK) >> USART_CR_POS) == 2U)? ((__HANDLE__)->Instance->CR2 |= ((uint32_t)1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
||
| 483 | ((__HANDLE__)->Instance->CR3 |= ((uint32_t)1U << ((__INTERRUPT__) & USART_IT_MASK)))) |
||
| 484 | |||
| 485 | /** @brief Disable the specified USART interrupt. |
||
| 486 | * @param __HANDLE__ specifies the USART Handle. |
||
| 487 | * @param __INTERRUPT__ specifies the USART interrupt source to disable. |
||
| 488 | * This parameter can be one of the following values: |
||
| 489 | * @arg @ref USART_IT_TXE Transmit Data Register empty interrupt |
||
| 490 | * @arg @ref USART_IT_TC Transmission complete interrupt |
||
| 491 | * @arg @ref USART_IT_RXNE Receive Data register not empty interrupt |
||
| 492 | * @arg @ref USART_IT_IDLE Idle line detection interrupt |
||
| 493 | * @arg @ref USART_IT_PE Parity Error interrupt |
||
| 494 | * @arg @ref USART_IT_ERR Error interrupt(Frame error, noise error, overrun error) |
||
| 495 | * @retval None |
||
| 496 | */ |
||
| 497 | #define __HAL_USART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((__INTERRUPT__) & USART_CR_MASK) >> USART_CR_POS) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
||
| 498 | ((((__INTERRUPT__) & USART_CR_MASK) >> USART_CR_POS) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & USART_IT_MASK))): \ |
||
| 499 | ((__HANDLE__)->Instance->CR3 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & USART_IT_MASK)))) |
||
| 500 | |||
| 501 | |||
| 502 | /** @brief Check whether the specified USART interrupt has occurred or not. |
||
| 503 | * @param __HANDLE__ specifies the USART Handle. |
||
| 504 | * @param __INTERRUPT__ specifies the USART interrupt source to check. |
||
| 505 | * This parameter can be one of the following values: |
||
| 506 | * @arg @ref USART_IT_TXE Transmit Data Register empty interrupt |
||
| 507 | * @arg @ref USART_IT_TC Transmission complete interrupt |
||
| 508 | * @arg @ref USART_IT_RXNE Receive Data register not empty interrupt |
||
| 509 | * @arg @ref USART_IT_IDLE Idle line detection interrupt |
||
| 510 | * @arg @ref USART_IT_ORE OverRun Error interrupt |
||
| 511 | * @arg @ref USART_IT_NE Noise Error interrupt |
||
| 512 | * @arg @ref USART_IT_FE Framing Error interrupt |
||
| 513 | * @arg @ref USART_IT_PE Parity Error interrupt |
||
| 514 | * @retval The new state of __INTERRUPT__ (SET or RESET). |
||
| 515 | */ |
||
| 516 | #define __HAL_USART_GET_IT(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->ISR\ |
||
| 517 | & ((uint32_t)0x01U << (((__INTERRUPT__) & USART_ISR_MASK)>> USART_ISR_POS))) != 0U) ? SET : RESET) |
||
| 518 | |||
| 519 | /** @brief Check whether the specified USART interrupt source is enabled or not. |
||
| 520 | * @param __HANDLE__ specifies the USART Handle. |
||
| 521 | * @param __INTERRUPT__ specifies the USART interrupt source to check. |
||
| 522 | * This parameter can be one of the following values: |
||
| 523 | * @arg @ref USART_IT_TXE Transmit Data Register empty interrupt |
||
| 524 | * @arg @ref USART_IT_TC Transmission complete interrupt |
||
| 525 | * @arg @ref USART_IT_RXNE Receive Data register not empty interrupt |
||
| 526 | * @arg @ref USART_IT_IDLE Idle line detection interrupt |
||
| 527 | * @arg @ref USART_IT_ORE OverRun Error interrupt |
||
| 528 | * @arg @ref USART_IT_NE Noise Error interrupt |
||
| 529 | * @arg @ref USART_IT_FE Framing Error interrupt |
||
| 530 | * @arg @ref USART_IT_PE Parity Error interrupt |
||
| 531 | * @retval The new state of __INTERRUPT__ (SET or RESET). |
||
| 532 | */ |
||
| 533 | #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((((uint8_t)(__INTERRUPT__)) >> 0x05U) == 0x01U) ? (__HANDLE__)->Instance->CR1 : \ |
||
| 534 | (((((uint8_t)(__INTERRUPT__)) >> 0x05U) == 0x02U) ? (__HANDLE__)->Instance->CR2 : \ |
||
| 535 | (__HANDLE__)->Instance->CR3)) & (0x01U << (((uint16_t)(__INTERRUPT__)) & USART_IT_MASK))) != 0U) ? SET : RESET) |
||
| 536 | |||
| 537 | |||
| 538 | /** @brief Clear the specified USART ISR flag, in setting the proper ICR register flag. |
||
| 539 | * @param __HANDLE__ specifies the USART Handle. |
||
| 540 | * @param __IT_CLEAR__ specifies the interrupt clear register flag that needs to be set |
||
| 541 | * to clear the corresponding interrupt. |
||
| 542 | * This parameter can be one of the following values: |
||
| 543 | * @arg @ref USART_CLEAR_PEF Parity Error Clear Flag |
||
| 544 | * @arg @ref USART_CLEAR_FEF Framing Error Clear Flag |
||
| 545 | * @arg @ref USART_CLEAR_NEF Noise detected Clear Flag |
||
| 546 | * @arg @ref USART_CLEAR_OREF Overrun Error Clear Flag |
||
| 547 | * @arg @ref USART_CLEAR_IDLEF IDLE line detected Clear Flag |
||
| 548 | * @arg @ref USART_CLEAR_TCF Transmission Complete Clear Flag |
||
| 549 | * @retval None |
||
| 550 | */ |
||
| 551 | #define __HAL_USART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__)) |
||
| 552 | |||
| 553 | /** @brief Set a specific USART request flag. |
||
| 554 | * @param __HANDLE__ specifies the USART Handle. |
||
| 555 | * @param __REQ__ specifies the request flag to set. |
||
| 556 | * This parameter can be one of the following values: |
||
| 557 | * @arg @ref USART_RXDATA_FLUSH_REQUEST Receive Data flush Request |
||
| 558 | #if defined(USART_RQR_TXFRQ) |
||
| 559 | * @arg @ref USART_TXDATA_FLUSH_REQUEST Transmit data flush Request |
||
| 560 | #endif |
||
| 561 | * |
||
| 562 | * @retval None |
||
| 563 | */ |
||
| 564 | #define __HAL_USART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint16_t)(__REQ__)) |
||
| 565 | |||
| 566 | /** @brief Enable the USART one bit sample method. |
||
| 567 | * @param __HANDLE__ specifies the USART Handle. |
||
| 568 | * @retval None |
||
| 569 | */ |
||
| 570 | #define __HAL_USART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT) |
||
| 571 | |||
| 572 | /** @brief Disable the USART one bit sample method. |
||
| 573 | * @param __HANDLE__ specifies the USART Handle. |
||
| 574 | * @retval None |
||
| 575 | */ |
||
| 576 | #define __HAL_USART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= ~USART_CR3_ONEBIT) |
||
| 577 | |||
| 578 | /** @brief Enable USART. |
||
| 579 | * @param __HANDLE__ specifies the USART Handle. |
||
| 580 | * @retval None |
||
| 581 | */ |
||
| 582 | #define __HAL_USART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) |
||
| 583 | |||
| 584 | /** @brief Disable USART. |
||
| 585 | * @param __HANDLE__ specifies the USART Handle. |
||
| 586 | * @retval None |
||
| 587 | */ |
||
| 588 | #define __HAL_USART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) |
||
| 589 | |||
| 590 | /** |
||
| 591 | * @} |
||
| 592 | */ |
||
| 593 | |||
| 594 | /* Private macros --------------------------------------------------------*/ |
||
| 595 | /** @defgroup USART_Private_Macros USART Private Macros |
||
| 596 | * @{ |
||
| 597 | */ |
||
| 598 | |||
| 599 | /** @brief BRR division operation to set BRR register in 8-bit oversampling mode. |
||
| 600 | * @param __PCLK__ USART clock. |
||
| 601 | * @param __BAUD__ Baud rate set by the user. |
||
| 602 | * @retval Division result |
||
| 603 | */ |
||
| 604 | #define USART_DIV_SAMPLING8(__PCLK__, __BAUD__) ((((__PCLK__)*2U) + ((__BAUD__)/2U)) / (__BAUD__)) |
||
| 605 | |||
| 606 | /** @brief Check USART Baud rate. |
||
| 607 | * @param __BAUDRATE__ Baudrate specified by the user. |
||
| 608 | * The maximum Baud Rate is derived from the maximum clock on F0 (i.e. 48 MHz) |
||
| 609 | * divided by the smallest oversampling used on the USART (i.e. 8) |
||
| 610 | * @retval SET (__BAUDRATE__ is valid) or RESET (__BAUDRATE__ is invalid) */ |
||
| 611 | #define IS_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) <= 6000000U) |
||
| 612 | |||
| 613 | /** |
||
| 614 | * @brief Ensure that USART frame number of stop bits is valid. |
||
| 615 | * @param __STOPBITS__ USART frame number of stop bits. |
||
| 616 | * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid) |
||
| 617 | */ |
||
| 618 | #if defined(USART_SMARTCARD_SUPPORT) |
||
| 619 | #define IS_USART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == USART_STOPBITS_0_5) || \ |
||
| 620 | ((__STOPBITS__) == USART_STOPBITS_1) || \ |
||
| 621 | ((__STOPBITS__) == USART_STOPBITS_1_5) || \ |
||
| 622 | ((__STOPBITS__) == USART_STOPBITS_2)) |
||
| 623 | #else |
||
| 624 | #define IS_USART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == USART_STOPBITS_1) || \ |
||
| 625 | ((__STOPBITS__) == USART_STOPBITS_2)) |
||
| 626 | #endif /* USART_SMARTCARD_SUPPORT */ |
||
| 627 | |||
| 628 | /** |
||
| 629 | * @brief Ensure that USART frame parity is valid. |
||
| 630 | * @param __PARITY__ USART frame parity. |
||
| 631 | * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid) |
||
| 632 | */ |
||
| 633 | #define IS_USART_PARITY(__PARITY__) (((__PARITY__) == USART_PARITY_NONE) || \ |
||
| 634 | ((__PARITY__) == USART_PARITY_EVEN) || \ |
||
| 635 | ((__PARITY__) == USART_PARITY_ODD)) |
||
| 636 | |||
| 637 | /** |
||
| 638 | * @brief Ensure that USART communication mode is valid. |
||
| 639 | * @param __MODE__ USART communication mode. |
||
| 640 | * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid) |
||
| 641 | */ |
||
| 642 | #define IS_USART_MODE(__MODE__) ((((__MODE__) & 0xFFFFFFF3U) == 0x00U) && ((__MODE__) != 0x00U)) |
||
| 643 | |||
| 644 | /** |
||
| 645 | * @brief Ensure that USART oversampling is valid. |
||
| 646 | * @param __SAMPLING__ USART oversampling. |
||
| 647 | * @retval SET (__SAMPLING__ is valid) or RESET (__SAMPLING__ is invalid) |
||
| 648 | */ |
||
| 649 | #define IS_USART_OVERSAMPLING(__SAMPLING__) (((__SAMPLING__) == USART_OVERSAMPLING_16) || \ |
||
| 650 | ((__SAMPLING__) == USART_OVERSAMPLING_8)) |
||
| 651 | |||
| 652 | /** |
||
| 653 | * @brief Ensure that USART clock state is valid. |
||
| 654 | * @param __CLOCK__ USART clock state. |
||
| 655 | * @retval SET (__CLOCK__ is valid) or RESET (__CLOCK__ is invalid) |
||
| 656 | */ |
||
| 657 | #define IS_USART_CLOCK(__CLOCK__) (((__CLOCK__) == USART_CLOCK_DISABLE) || \ |
||
| 658 | ((__CLOCK__) == USART_CLOCK_ENABLE)) |
||
| 659 | |||
| 660 | /** |
||
| 661 | * @brief Ensure that USART frame polarity is valid. |
||
| 662 | * @param __CPOL__ USART frame polarity. |
||
| 663 | * @retval SET (__CPOL__ is valid) or RESET (__CPOL__ is invalid) |
||
| 664 | */ |
||
| 665 | #define IS_USART_POLARITY(__CPOL__) (((__CPOL__) == USART_POLARITY_LOW) || ((__CPOL__) == USART_POLARITY_HIGH)) |
||
| 666 | |||
| 667 | /** |
||
| 668 | * @brief Ensure that USART frame phase is valid. |
||
| 669 | * @param __CPHA__ USART frame phase. |
||
| 670 | * @retval SET (__CPHA__ is valid) or RESET (__CPHA__ is invalid) |
||
| 671 | */ |
||
| 672 | #define IS_USART_PHASE(__CPHA__) (((__CPHA__) == USART_PHASE_1EDGE) || ((__CPHA__) == USART_PHASE_2EDGE)) |
||
| 673 | |||
| 674 | /** |
||
| 675 | * @brief Ensure that USART frame last bit clock pulse setting is valid. |
||
| 676 | * @param __LASTBIT__ USART frame last bit clock pulse setting. |
||
| 677 | * @retval SET (__LASTBIT__ is valid) or RESET (__LASTBIT__ is invalid) |
||
| 678 | */ |
||
| 679 | #define IS_USART_LASTBIT(__LASTBIT__) (((__LASTBIT__) == USART_LASTBIT_DISABLE) || \ |
||
| 680 | ((__LASTBIT__) == USART_LASTBIT_ENABLE)) |
||
| 681 | |||
| 682 | /** |
||
| 683 | * @brief Ensure that USART request parameter is valid. |
||
| 684 | * @param __PARAM__ USART request parameter. |
||
| 685 | * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid) |
||
| 686 | */ |
||
| 687 | #if defined(USART_RQR_TXFRQ) |
||
| 688 | #define IS_USART_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == USART_RXDATA_FLUSH_REQUEST) || \ |
||
| 689 | ((__PARAM__) == USART_TXDATA_FLUSH_REQUEST)) |
||
| 690 | #else |
||
| 691 | #define IS_USART_REQUEST_PARAMETER(__PARAM__) ((__PARAM__) == USART_RXDATA_FLUSH_REQUEST) |
||
| 692 | #endif /* USART_RQR_TXFRQ */ |
||
| 693 | |||
| 694 | /** |
||
| 695 | * @} |
||
| 696 | */ |
||
| 697 | |||
| 698 | /* Include USART HAL Extended module */ |
||
| 699 | #include "stm32f0xx_hal_usart_ex.h" |
||
| 700 | |||
| 701 | /* Exported functions --------------------------------------------------------*/ |
||
| 702 | /** @addtogroup USART_Exported_Functions USART Exported Functions |
||
| 703 | * @{ |
||
| 704 | */ |
||
| 705 | |||
| 706 | /** @addtogroup USART_Exported_Functions_Group1 Initialization and de-initialization functions |
||
| 707 | * @{ |
||
| 708 | */ |
||
| 709 | |||
| 710 | /* Initialization and de-initialization functions ****************************/ |
||
| 711 | HAL_StatusTypeDef HAL_USART_Init(USART_HandleTypeDef *husart); |
||
| 712 | HAL_StatusTypeDef HAL_USART_DeInit(USART_HandleTypeDef *husart); |
||
| 713 | void HAL_USART_MspInit(USART_HandleTypeDef *husart); |
||
| 714 | void HAL_USART_MspDeInit(USART_HandleTypeDef *husart); |
||
| 715 | |||
| 716 | /* Callbacks Register/UnRegister functions ***********************************/ |
||
| 717 | #if (USE_HAL_USART_REGISTER_CALLBACKS == 1) |
||
| 718 | HAL_StatusTypeDef HAL_USART_RegisterCallback(USART_HandleTypeDef *husart, HAL_USART_CallbackIDTypeDef CallbackID, |
||
| 719 | pUSART_CallbackTypeDef pCallback); |
||
| 720 | HAL_StatusTypeDef HAL_USART_UnRegisterCallback(USART_HandleTypeDef *husart, HAL_USART_CallbackIDTypeDef CallbackID); |
||
| 721 | #endif /* USE_HAL_USART_REGISTER_CALLBACKS */ |
||
| 722 | |||
| 723 | /** |
||
| 724 | * @} |
||
| 725 | */ |
||
| 726 | |||
| 727 | /** @addtogroup USART_Exported_Functions_Group2 IO operation functions |
||
| 728 | * @{ |
||
| 729 | */ |
||
| 730 | |||
| 731 | /* IO operation functions *****************************************************/ |
||
| 732 | HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout); |
||
| 733 | HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); |
||
| 734 | HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, |
||
| 735 | uint16_t Size, uint32_t Timeout); |
||
| 736 | HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size); |
||
| 737 | HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size); |
||
| 738 | HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, |
||
| 739 | uint16_t Size); |
||
| 740 | HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size); |
||
| 741 | HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size); |
||
| 742 | HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, |
||
| 743 | uint16_t Size); |
||
| 744 | HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart); |
||
| 745 | HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart); |
||
| 746 | HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart); |
||
| 747 | /* Transfer Abort functions */ |
||
| 748 | HAL_StatusTypeDef HAL_USART_Abort(USART_HandleTypeDef *husart); |
||
| 749 | HAL_StatusTypeDef HAL_USART_Abort_IT(USART_HandleTypeDef *husart); |
||
| 750 | |||
| 751 | void HAL_USART_IRQHandler(USART_HandleTypeDef *husart); |
||
| 752 | void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart); |
||
| 753 | void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart); |
||
| 754 | void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart); |
||
| 755 | void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart); |
||
| 756 | void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart); |
||
| 757 | void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart); |
||
| 758 | void HAL_USART_AbortCpltCallback(USART_HandleTypeDef *husart); |
||
| 759 | |||
| 760 | /** |
||
| 761 | * @} |
||
| 762 | */ |
||
| 763 | |||
| 764 | /** @addtogroup USART_Exported_Functions_Group4 Peripheral State and Error functions |
||
| 765 | * @{ |
||
| 766 | */ |
||
| 767 | |||
| 768 | /* Peripheral State and Error functions ***************************************/ |
||
| 769 | HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart); |
||
| 770 | uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart); |
||
| 771 | |||
| 772 | /** |
||
| 773 | * @} |
||
| 774 | */ |
||
| 775 | |||
| 776 | /** |
||
| 777 | * @} |
||
| 778 | */ |
||
| 779 | |||
| 780 | /** |
||
| 781 | * @} |
||
| 782 | */ |
||
| 783 | |||
| 784 | /** |
||
| 785 | * @} |
||
| 786 | */ |
||
| 787 | |||
| 788 | #ifdef __cplusplus |
||
| 789 | } |
||
| 790 | #endif |
||
| 791 | |||
| 792 | #endif /* STM32F0xx_HAL_USART_H */ |
||
| 793 | |||
| 794 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |