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