stm32l4xx_hal_usart.h 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_usart.h
  4. * @author MCD Application Team
  5. * @brief Header file of USART HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32L4xx_HAL_USART_H
  37. #define __STM32L4xx_HAL_USART_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32l4xx_hal_def.h"
  43. /** @addtogroup STM32L4xx_HAL_Driver
  44. * @{
  45. */
  46. /** @addtogroup USART
  47. * @{
  48. */
  49. /* Exported types ------------------------------------------------------------*/
  50. /** @defgroup USART_Exported_Types USART Exported Types
  51. * @{
  52. */
  53. /**
  54. * @brief USART Init Structure definition
  55. */
  56. typedef struct
  57. {
  58. uint32_t BaudRate; /*!< This member configures the Usart communication baud rate.
  59. The baud rate is computed using the following formula:
  60. Baud Rate Register[15:4] = ((2 * fclk_pres) / ((huart->Init.BaudRate)))[15:4]
  61. Baud Rate Register[3] = 0
  62. Baud Rate Register[2:0] = (((2 * fclk_pres) / ((huart->Init.BaudRate)))[3:0]) >> 1
  63. where fclk_pres is the USART input clock frequency (fclk) divided by a prescaler.
  64. @note Oversampling by 8 is systematically applied to achieve high baud rates. */
  65. uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
  66. This parameter can be a value of @ref USARTEx_Word_Length. */
  67. uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
  68. This parameter can be a value of @ref USART_Stop_Bits. */
  69. uint32_t Parity; /*!< Specifies the parity mode.
  70. This parameter can be a value of @ref USART_Parity
  71. @note When parity is enabled, the computed parity is inserted
  72. at the MSB position of the transmitted data (9th bit when
  73. the word length is set to 9 data bits; 8th bit when the
  74. word length is set to 8 data bits). */
  75. uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
  76. This parameter can be a value of @ref USART_Mode. */
  77. uint32_t CLKPolarity; /*!< Specifies the steady state of the serial clock.
  78. This parameter can be a value of @ref USART_Clock_Polarity. */
  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. uint32_t CLKLastBit; /*!< Specifies whether the clock pulse corresponding to the last transmitted
  82. data bit (MSB) has to be output on the SCLK pin in synchronous mode.
  83. This parameter can be a value of @ref USART_Last_Bit. */
  84. #if defined(USART_PRESC_PRESCALER)
  85. uint32_t ClockPrescaler; /*!< Specifies the prescaler value used to divide the USART clock source.
  86. This parameter can be a value of @ref USART_ClockPrescaler. */
  87. #endif
  88. }USART_InitTypeDef;
  89. /**
  90. * @brief HAL USART State structures definition
  91. */
  92. typedef enum
  93. {
  94. HAL_USART_STATE_RESET = 0x00U, /*!< Peripheral is not initialized */
  95. HAL_USART_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
  96. HAL_USART_STATE_BUSY = 0x02U, /*!< an internal process is ongoing */
  97. HAL_USART_STATE_BUSY_TX = 0x12U, /*!< Data Transmission process is ongoing */
  98. HAL_USART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */
  99. HAL_USART_STATE_BUSY_TX_RX = 0x32U, /*!< Data Transmission Reception process is ongoing */
  100. HAL_USART_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
  101. HAL_USART_STATE_ERROR = 0x04U /*!< Error */
  102. }HAL_USART_StateTypeDef;
  103. /**
  104. * @brief HAL USART Error Code structure definition
  105. */
  106. typedef enum
  107. {
  108. HAL_USART_ERROR_NONE = 0x00U, /*!< No error */
  109. HAL_USART_ERROR_PE = 0x01U, /*!< Parity error */
  110. HAL_USART_ERROR_NE = 0x02U, /*!< Noise error */
  111. HAL_USART_ERROR_FE = 0x04U, /*!< frame error */
  112. HAL_USART_ERROR_ORE = 0x08U, /*!< Overrun error */
  113. HAL_USART_ERROR_DMA = 0x10U, /*!< DMA transfer error */
  114. HAL_USART_ERROR_UDR = 0x20U /*!< SPI slave underrun error */
  115. }HAL_USART_ErrorTypeDef;
  116. /**
  117. * @brief USART clock sources definitions
  118. */
  119. typedef enum
  120. {
  121. USART_CLOCKSOURCE_PCLK1 = 0x00U, /*!< PCLK1 clock source */
  122. USART_CLOCKSOURCE_PCLK2 = 0x01U, /*!< PCLK2 clock source */
  123. USART_CLOCKSOURCE_HSI = 0x02U, /*!< HSI clock source */
  124. USART_CLOCKSOURCE_SYSCLK = 0x04U, /*!< SYSCLK clock source */
  125. USART_CLOCKSOURCE_LSE = 0x08U, /*!< LSE clock source */
  126. USART_CLOCKSOURCE_UNDEFINED = 0x10U /*!< Undefined clock source */
  127. }USART_ClockSourceTypeDef;
  128. /**
  129. * @brief USART handle Structure definition
  130. */
  131. typedef struct __USART_HandleTypeDef
  132. {
  133. USART_TypeDef *Instance; /*!< USART registers base address */
  134. USART_InitTypeDef Init; /*!< USART communication parameters */
  135. uint8_t *pTxBuffPtr; /*!< Pointer to USART Tx transfer Buffer */
  136. uint16_t TxXferSize; /*!< USART Tx Transfer size */
  137. __IO uint16_t TxXferCount; /*!< USART Tx Transfer Counter */
  138. uint8_t *pRxBuffPtr; /*!< Pointer to USART Rx transfer Buffer */
  139. uint16_t RxXferSize; /*!< USART Rx Transfer size */
  140. __IO uint16_t RxXferCount; /*!< USART Rx Transfer Counter */
  141. uint16_t Mask; /*!< USART Rx RDR register mask */
  142. #if defined(USART_CR1_FIFOEN)
  143. uint16_t NbRxDataToProcess; /*!< Number of data to process during RX ISR execution */
  144. uint16_t NbTxDataToProcess; /*!< Number of data to process during TX ISR execution */
  145. uint32_t FifoMode; /*!< Specifies if the FIFO mode is being used.
  146. This parameter can be a value of @ref USARTEx_FIFO_mode. */
  147. #endif
  148. #if defined(USART_CR2_SLVEN)
  149. uint32_t SlaveMode; /*!< Specifies if the UART SPI Slave mode is being used.
  150. This parameter can be a value of @ref USARTEx_Slave_Mode. */
  151. #endif
  152. void (*RxISR)(struct __USART_HandleTypeDef *husart); /*!< Function pointer on Rx IRQ handler */
  153. void (*TxISR)(struct __USART_HandleTypeDef *husart); /*!< Function pointer on Tx IRQ handler */
  154. DMA_HandleTypeDef *hdmatx; /*!< USART Tx DMA Handle parameters */
  155. DMA_HandleTypeDef *hdmarx; /*!< USART Rx DMA Handle parameters */
  156. HAL_LockTypeDef Lock; /*!< Locking object */
  157. __IO HAL_USART_StateTypeDef State; /*!< USART communication state */
  158. __IO uint32_t ErrorCode; /*!< USART Error code */
  159. }USART_HandleTypeDef;
  160. /**
  161. * @}
  162. */
  163. /* Exported constants --------------------------------------------------------*/
  164. /** @defgroup USART_Exported_Constants USART Exported Constants
  165. * @{
  166. */
  167. /** @defgroup USART_Stop_Bits USART Number of Stop Bits
  168. * @{
  169. */
  170. #define USART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< USART frame with 0.5 stop bit */
  171. #define USART_STOPBITS_1 0x00000000U /*!< USART frame with 1 stop bit */
  172. #define USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< USART frame with 1.5 stop bits */
  173. #define USART_STOPBITS_2 USART_CR2_STOP_1 /*!< USART frame with 2 stop bits */
  174. /**
  175. * @}
  176. */
  177. /** @defgroup USART_Parity USART Parity
  178. * @{
  179. */
  180. #define USART_PARITY_NONE 0x00000000U /*!< No parity */
  181. #define USART_PARITY_EVEN USART_CR1_PCE /*!< Even parity */
  182. #define USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Odd parity */
  183. /**
  184. * @}
  185. */
  186. /** @defgroup USART_Mode USART Mode
  187. * @{
  188. */
  189. #define USART_MODE_RX USART_CR1_RE /*!< RX mode */
  190. #define USART_MODE_TX USART_CR1_TE /*!< TX mode */
  191. #define USART_MODE_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< RX and TX mode */
  192. /**
  193. * @}
  194. */
  195. /** @defgroup USART_Over_Sampling USART Over Sampling
  196. * @{
  197. */
  198. #define USART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */
  199. #define USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */
  200. /**
  201. * @}
  202. */
  203. /** @defgroup USART_Clock USART Clock
  204. * @{
  205. */
  206. #define USART_CLOCK_DISABLE 0x00000000U /*!< USART clock disable */
  207. #define USART_CLOCK_ENABLE USART_CR2_CLKEN /*!< USART clock enable */
  208. /**
  209. * @}
  210. */
  211. /** @defgroup USART_Clock_Polarity USART Clock Polarity
  212. * @{
  213. */
  214. #define USART_POLARITY_LOW 0x00000000U /*!< Driver enable signal is active high */
  215. #define USART_POLARITY_HIGH USART_CR2_CPOL /*!< Driver enable signal is active low */
  216. /**
  217. * @}
  218. */
  219. /** @defgroup USART_Clock_Phase USART Clock Phase
  220. * @{
  221. */
  222. #define USART_PHASE_1EDGE 0x00000000U /*!< USART frame phase on first clock transition */
  223. #define USART_PHASE_2EDGE USART_CR2_CPHA /*!< USART frame phase on second clock transition */
  224. /**
  225. * @}
  226. */
  227. /** @defgroup USART_Last_Bit USART Last Bit
  228. * @{
  229. */
  230. #define USART_LASTBIT_DISABLE 0x00000000U /*!< USART frame last data bit clock pulse not output to SCLK pin */
  231. #define USART_LASTBIT_ENABLE USART_CR2_LBCL /*!< USART frame last data bit clock pulse output to SCLK pin */
  232. /**
  233. * @}
  234. */
  235. #if defined(USART_PRESC_PRESCALER)
  236. /** @defgroup USART_ClockPrescaler USART Clock Prescaler
  237. * @{
  238. */
  239. #define USART_PRESCALER_DIV1 0x00000000U /*!< fclk_pres = fclk */
  240. #define USART_PRESCALER_DIV2 0x00000001U /*!< fclk_pres = fclk/2 */
  241. #define USART_PRESCALER_DIV4 0x00000002U /*!< fclk_pres = fclk/4 */
  242. #define USART_PRESCALER_DIV6 0x00000003U /*!< fclk_pres = fclk/6 */
  243. #define USART_PRESCALER_DIV8 0x00000004U /*!< fclk_pres = fclk/8 */
  244. #define USART_PRESCALER_DIV10 0x00000005U /*!< fclk_pres = fclk/10 */
  245. #define USART_PRESCALER_DIV12 0x00000006U /*!< fclk_pres = fclk/12 */
  246. #define USART_PRESCALER_DIV16 0x00000007U /*!< fclk_pres = fclk/16 */
  247. #define USART_PRESCALER_DIV32 0x00000008U /*!< fclk_pres = fclk/32 */
  248. #define USART_PRESCALER_DIV64 0x00000009U /*!< fclk_pres = fclk/64 */
  249. #define USART_PRESCALER_DIV128 0x0000000AU /*!< fclk_pres = fclk/128 */
  250. #define USART_PRESCALER_DIV256 0x0000000BU /*!< fclk_pres = fclk/256 */
  251. /**
  252. * @}
  253. */
  254. #endif
  255. /** @defgroup USART_Request_Parameters USART Request Parameters
  256. * @{
  257. */
  258. #define USART_RXDATA_FLUSH_REQUEST USART_RQR_RXFRQ /*!< Receive Data flush Request */
  259. #define USART_TXDATA_FLUSH_REQUEST USART_RQR_TXFRQ /*!< Transmit data flush Request */
  260. /**
  261. * @}
  262. */
  263. /** @defgroup USART_Flags USART Flags
  264. * Elements values convention: 0xXXXX
  265. * - 0xXXXX : Flag mask in the ISR register
  266. * @{
  267. */
  268. #if defined(USART_CR1_FIFOEN)
  269. #define USART_FLAG_TXFT USART_ISR_TXFT /*!< USART TXFIFO threshold flag */
  270. #define USART_FLAG_RXFT USART_ISR_RXFT /*!< USART RXFIFO threshold flag */
  271. #define USART_FLAG_RXFF USART_ISR_RXFF /*!< USART RXFIFO Full flag */
  272. #define USART_FLAG_TXFE USART_ISR_TXFE /*!< USART TXFIFO Empty flag */
  273. #define USART_FLAG_TXE USART_ISR_TXE_TXFNF /*!< USART transmit data register empty */
  274. #define USART_FLAG_TXFNF USART_ISR_TXE_TXFNF /*!< USART TXFIFO not full */
  275. #define USART_FLAG_RXNE USART_ISR_RXNE_RXFNE /*!< USART read data register not empty */
  276. #define USART_FLAG_RXFNE USART_ISR_RXNE_RXFNE /*!< USART RXFIFO not empty */
  277. #else
  278. #define USART_FLAG_TXE USART_ISR_TXE /*!< USART transmit data register empty */
  279. #define USART_FLAG_RXNE USART_ISR_RXNE /*!< USART read data register not empty */
  280. #endif
  281. #define USART_FLAG_REACK USART_ISR_REACK /*!< USART receive enable acknowledge flag */
  282. #define USART_FLAG_TEACK USART_ISR_TEACK /*!< USART transmit enable acknowledge flag */
  283. #define USART_FLAG_BUSY USART_ISR_BUSY /*!< USART busy flag */
  284. #define USART_FLAG_TC USART_ISR_TC /*!< USART transmission complete */
  285. #define USART_FLAG_IDLE USART_ISR_IDLE /*!< USART idle flag */
  286. #define USART_FLAG_ORE USART_ISR_ORE /*!< USART overrun error */
  287. #define USART_FLAG_NE USART_ISR_NE /*!< USART noise error */
  288. #define USART_FLAG_FE USART_ISR_FE /*!< USART frame error */
  289. #define USART_FLAG_PE USART_ISR_PE /*!< USART parity error */
  290. #if defined(USART_CR2_SLVEN)
  291. #define USART_FLAG_UDR USART_ISR_UDR /*!< SPI slave underrun error flag */
  292. #endif
  293. /**
  294. * @}
  295. */
  296. /** @defgroup USART_Interrupt_definition USART Interrupts Definition
  297. * Elements values convention: 0000ZZZZ0XXYYYYYb
  298. * - YYYYY : Interrupt source position in the XX register (5bits)
  299. * - XX : Interrupt source register (2bits)
  300. * - 01: CR1 register
  301. * - 10: CR2 register
  302. * - 11: CR3 register
  303. * - ZZZZ : Flag position in the ISR register(4bits)
  304. * @{
  305. */
  306. #define USART_IT_PE 0x0028U /*!< USART parity error interruption */
  307. #if defined(USART_CR1_FIFOEN)
  308. #define USART_IT_TXFNF 0x0727U /*!< USART TX FIFO not full interruption */
  309. #define USART_IT_RXFNE 0x0525U /*!< USART RXFIFO not empty interruption */
  310. #define USART_IT_RXFF 0x183FU /*!< USART RXFIFO full interruption */
  311. #define USART_IT_TXFE 0x173EU /*!< USART TXFIFO empty interruption */
  312. #define USART_IT_RXFT 0x1A7CU /*!< USART RXFIFO threshold reached interruption */
  313. #define USART_IT_TXFT 0x1B77U /*!< USART TXFIFO threshold reached interruption */
  314. #endif
  315. #define USART_IT_TXE 0x0727U /*!< USART transmit data register empty interruption */
  316. #define USART_IT_TC 0x0626U /*!< USART transmission complete interruption */
  317. #define USART_IT_RXNE 0x0525U /*!< USART read data register not empty interruption */
  318. #define USART_IT_IDLE 0x0424U /*!< USART idle interruption */
  319. #define USART_IT_ERR 0x0060U /*!< USART error interruption */
  320. #define USART_IT_ORE 0x0300U /*!< USART overrun error interruption */
  321. #define USART_IT_NE 0x0200U /*!< USART noise error interruption */
  322. #define USART_IT_FE 0x0100U /*!< USART frame error interruption */
  323. /**
  324. * @}
  325. */
  326. /** @defgroup USART_IT_CLEAR_Flags USART Interruption Clear Flags
  327. * @{
  328. */
  329. #define USART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
  330. #define USART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
  331. #define USART_CLEAR_NEF USART_ICR_NECF /*!< Noise detected Clear Flag */
  332. #define USART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
  333. #define USART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */
  334. #define USART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
  335. #if defined(USART_CR1_FIFOEN)
  336. #define USART_CLEAR_TXFECF USART_ICR_TXFECF /*!< TXFIFO Empty Clear Flag */
  337. #endif
  338. #if defined(USART_CR2_SLVEN)
  339. #define USART_CLEAR_UDRF USART_ICR_UDRCF /*!< SPI slave underrun error Clear Flag */
  340. #endif
  341. /**
  342. * @}
  343. */
  344. /** @defgroup USART_Interruption_Mask USART Interruption Flags Mask
  345. * @{
  346. */
  347. #define USART_IT_MASK 0x001FU /*!< USART interruptions flags mask */
  348. /**
  349. * @}
  350. */
  351. /**
  352. * @}
  353. */
  354. /* Exported macros -----------------------------------------------------------*/
  355. /** @defgroup USART_Exported_Macros USART Exported Macros
  356. * @{
  357. */
  358. /** @brief Reset USART handle state.
  359. * @param __HANDLE__ USART handle.
  360. * @retval None
  361. */
  362. #define __HAL_USART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_USART_STATE_RESET)
  363. /** @brief Check whether the specified USART flag is set or not.
  364. * @param __HANDLE__ specifies the USART Handle
  365. * @param __FLAG__ specifies the flag to check.
  366. * This parameter can be one of the following values:
  367. * @arg @ref USART_FLAG_TXFT TXFIFO threshold flag
  368. * @arg @ref USART_FLAG_RXFT RXFIFO threshold flag
  369. * @arg @ref USART_FLAG_RXFF RXFIFO Full flag
  370. * @arg @ref USART_FLAG_TXFE TXFIFO Empty flag
  371. * @arg @ref USART_FLAG_REACK Receive enable acknowledge flag
  372. * @arg @ref USART_FLAG_TEACK Transmit enable acknowledge flag
  373. * @arg @ref USART_FLAG_BUSY Busy flag
  374. * @arg @ref USART_FLAG_UDR SPI slave underrun error flag
  375. * @arg @ref USART_FLAG_TXE Transmit data register empty flag
  376. * @arg @ref USART_FLAG_TXFNF TXFIFO not full flag
  377. * @arg @ref USART_FLAG_TC Transmission Complete flag
  378. * @arg @ref USART_FLAG_RXNE Receive data register not empty flag
  379. * @arg @ref USART_FLAG_RXFNE RXFIFO not empty flag
  380. * @arg @ref USART_FLAG_IDLE Idle Line detection flag
  381. * @arg @ref USART_FLAG_ORE OverRun Error flag
  382. * @arg @ref USART_FLAG_NE Noise Error flag
  383. * @arg @ref USART_FLAG_FE Framing Error flag
  384. * @arg @ref USART_FLAG_PE Parity Error flag
  385. * @retval The new state of __FLAG__ (TRUE or FALSE).
  386. */
  387. #define __HAL_USART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
  388. /** @brief Clear the specified USART pending flag.
  389. * @param __HANDLE__ specifies the USART Handle.
  390. * @param __FLAG__ specifies the flag to check.
  391. * This parameter can be any combination of the following values:
  392. * @arg @ref USART_CLEAR_PEF Parity Error Clear Flag
  393. * @arg @ref USART_CLEAR_FEF Framing Error Clear Flag
  394. * @arg @ref USART_CLEAR_NEF Noise detected Clear Flag
  395. * @arg @ref USART_CLEAR_OREF Overrun Error Clear Flag
  396. * @arg @ref USART_CLEAR_IDLEF IDLE line detected Clear Flag
  397. * @arg @ref USART_CLEAR_TXFECF TXFIFO empty clear Flag
  398. * @arg @ref USART_CLEAR_TCF Transmission Complete Clear Flag
  399. * @arg @ref USART_CLEAR_UDRF SPI slave underrun error Clear Flag
  400. * @retval None
  401. */
  402. #define __HAL_USART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
  403. /** @brief Clear the USART PE pending flag.
  404. * @param __HANDLE__ specifies the USART Handle.
  405. * @retval None
  406. */
  407. #define __HAL_USART_CLEAR_PEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_PEF)
  408. /** @brief Clear the USART FE pending flag.
  409. * @param __HANDLE__ specifies the USART Handle.
  410. * @retval None
  411. */
  412. #define __HAL_USART_CLEAR_FEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_FEF)
  413. /** @brief Clear the USART NE pending flag.
  414. * @param __HANDLE__ specifies the USART Handle.
  415. * @retval None
  416. */
  417. #define __HAL_USART_CLEAR_NEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_NEF)
  418. /** @brief Clear the USART ORE pending flag.
  419. * @param __HANDLE__ specifies the USART Handle.
  420. * @retval None
  421. */
  422. #define __HAL_USART_CLEAR_OREFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_OREF)
  423. /** @brief Clear the USART IDLE pending flag.
  424. * @param __HANDLE__ specifies the USART Handle.
  425. * @retval None
  426. */
  427. #define __HAL_USART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_IDLEF)
  428. #if defined(USART_CR1_FIFOEN)
  429. /** @brief Clear the USART TX FIFO empty clear flag.
  430. * @param __HANDLE__ specifies the USART Handle.
  431. * @retval None
  432. */
  433. #define __HAL_USART_CLEAR_TXFECF(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_TXFECF)
  434. #endif
  435. #if defined(USART_CR2_SLVEN)
  436. /** @brief Clear SPI slave underrun error flag.
  437. * @param __HANDLE__ specifies the USART Handle.
  438. * @retval None
  439. */
  440. #define __HAL_USART_CLEAR_UDRFLAG(__HANDLE__) __HAL_USART_CLEAR_FLAG((__HANDLE__), USART_CLEAR_UDRF)
  441. #endif
  442. /** @brief Enable the specified USART interrupt.
  443. * @param __HANDLE__ specifies the USART Handle.
  444. * @param __INTERRUPT__ specifies the USART interrupt source to enable.
  445. * This parameter can be one of the following values:
  446. * @arg @ref USART_IT_RXFF RXFIFO Full interrupt
  447. * @arg @ref USART_IT_TXFE TXFIFO Empty interrupt
  448. * @arg @ref USART_IT_RXFT RXFIFO threshold interrupt
  449. * @arg @ref USART_IT_TXFT TXFIFO threshold interrupt
  450. * @arg @ref USART_IT_TXE Transmit Data Register empty interrupt
  451. * @arg @ref USART_IT_TXFNF TX FIFO not full interrupt
  452. * @arg @ref USART_IT_TC Transmission complete interrupt
  453. * @arg @ref USART_IT_RXNE Receive Data register not empty interrupt
  454. * @arg @ref USART_IT_RXFNE RXFIFO not empty interrupt
  455. * @arg @ref USART_IT_IDLE Idle line detection interrupt
  456. * @arg @ref USART_IT_PE Parity Error interrupt
  457. * @arg @ref USART_IT_ERR Error interrupt(Frame error, noise error, overrun error)
  458. * @retval None
  459. */
  460. #define __HAL_USART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
  461. ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
  462. ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & USART_IT_MASK))))
  463. /** @brief Disable the specified USART interrupt.
  464. * @param __HANDLE__ specifies the USART Handle.
  465. * @param __INTERRUPT__ specifies the USART interrupt source to disable.
  466. * This parameter can be one of the following values:
  467. * @arg @ref USART_IT_RXFF RXFIFO Full interrupt
  468. * @arg @ref USART_IT_TXFE TXFIFO Empty interrupt
  469. * @arg @ref USART_IT_RXFT RXFIFO threshold interrupt
  470. * @arg @ref USART_IT_TXFT TXFIFO threshold interrupt
  471. * @arg @ref USART_IT_TXE Transmit Data Register empty interrupt
  472. * @arg @ref USART_IT_TXFNF TX FIFO not full 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_RXFNE RXFIFO 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_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
  482. ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))): \
  483. ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & USART_IT_MASK))))
  484. /** @brief Check whether the specified USART interrupt has occurred or not.
  485. * @param __HANDLE__ specifies the USART Handle.
  486. * @param __INTERRUPT__ specifies the USART interrupt source to check.
  487. * This parameter can be one of the following values:
  488. * @arg @ref USART_IT_RXFF RXFIFO Full interrupt
  489. * @arg @ref USART_IT_TXFE TXFIFO Empty interrupt
  490. * @arg @ref USART_IT_RXFT RXFIFO threshold interrupt
  491. * @arg @ref USART_IT_TXFT TXFIFO threshold interrupt
  492. * @arg @ref USART_IT_TXE Transmit Data Register empty interrupt
  493. * @arg @ref USART_IT_TXFNF TX FIFO not full interrupt
  494. * @arg @ref USART_IT_TC Transmission complete interrupt
  495. * @arg @ref USART_IT_RXNE Receive Data register not empty interrupt
  496. * @arg @ref USART_IT_RXFNE RXFIFO not empty interrupt
  497. * @arg @ref USART_IT_IDLE Idle line detection interrupt
  498. * @arg @ref USART_IT_ORE OverRun Error interrupt
  499. * @arg @ref USART_IT_NE Noise Error interrupt
  500. * @arg @ref USART_IT_FE Framing Error interrupt
  501. * @arg @ref USART_IT_PE Parity Error interrupt
  502. * @retval The new state of __INTERRUPT__ (SET or RESET).
  503. */
  504. #define __HAL_USART_GET_IT(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__INTERRUPT__)>> 0x08))) != RESET) ? SET : RESET)
  505. /** @brief Check whether the specified USART interrupt source is enabled or not.
  506. * @param __HANDLE__ specifies the USART Handle.
  507. * @param __INTERRUPT__ specifies the USART interrupt source to check.
  508. * This parameter can be one of the following values:
  509. * @arg @ref USART_IT_RXFF RXFIFO Full interrupt
  510. * @arg @ref USART_IT_TXFE TXFIFO Empty interrupt
  511. * @arg @ref USART_IT_RXFT RXFIFO threshold interrupt
  512. * @arg @ref USART_IT_TXFT TXFIFO threshold interrupt
  513. * @arg @ref USART_IT_TXE Transmit Data Register empty interrupt
  514. * @arg @ref USART_IT_TXFNF TX FIFO not full interrupt
  515. * @arg @ref USART_IT_TC Transmission complete interrupt
  516. * @arg @ref USART_IT_RXNE Receive Data register not empty interrupt
  517. * @arg @ref USART_IT_RXFNE RXFIFO not empty interrupt
  518. * @arg @ref USART_IT_IDLE Idle line detection interrupt
  519. * @arg @ref USART_IT_ORE OverRun Error interrupt
  520. * @arg @ref USART_IT_NE Noise Error interrupt
  521. * @arg @ref USART_IT_FE Framing Error interrupt
  522. * @arg @ref USART_IT_PE Parity Error interrupt
  523. * @retval The new state of __INTERRUPT__ (SET or RESET).
  524. */
  525. #define __HAL_USART_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((((((uint8_t)(__INTERRUPT__)) >> 0x05U) == 0x01U) ? (__HANDLE__)->Instance->CR1 : \
  526. (((((uint8_t)(__INTERRUPT__)) >> 0x05U) == 0x02U) ? (__HANDLE__)->Instance->CR2 : \
  527. (__HANDLE__)->Instance->CR3)) & (0x01U << (((uint16_t)(__INTERRUPT__)) & USART_IT_MASK))) != RESET) ? SET : RESET)
  528. /** @brief Clear the specified USART ISR flag, in setting the proper ICR register flag.
  529. * @param __HANDLE__ specifies the USART Handle.
  530. * @param __IT_CLEAR__ specifies the interrupt clear register flag that needs to be set
  531. * to clear the corresponding interrupt.
  532. * This parameter can be one of the following values:
  533. * @arg @ref USART_CLEAR_PEF Parity Error Clear Flag
  534. * @arg @ref USART_CLEAR_FEF Framing Error Clear Flag
  535. * @arg @ref USART_CLEAR_NEF Noise detected Clear Flag
  536. * @arg @ref USART_CLEAR_OREF Overrun Error Clear Flag
  537. * @arg @ref USART_CLEAR_IDLEF IDLE line detected Clear Flag
  538. * @arg @ref USART_CLEAR_TXFECF TXFIFO empty clear Flag
  539. * @arg @ref USART_CLEAR_TCF Transmission Complete Clear Flag
  540. * @retval None
  541. */
  542. #define __HAL_USART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
  543. /** @brief Set a specific USART request flag.
  544. * @param __HANDLE__ specifies the USART Handle.
  545. * @param __REQ__ specifies the request flag to set.
  546. * This parameter can be one of the following values:
  547. * @arg @ref USART_RXDATA_FLUSH_REQUEST Receive Data flush Request
  548. * @arg @ref USART_TXDATA_FLUSH_REQUEST Transmit data flush Request
  549. *
  550. * @retval None
  551. */
  552. #define __HAL_USART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (__REQ__))
  553. /** @brief Enable the USART one bit sample method.
  554. * @param __HANDLE__ specifies the USART Handle.
  555. * @retval None
  556. */
  557. #define __HAL_USART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
  558. /** @brief Disable the USART one bit sample method.
  559. * @param __HANDLE__ specifies the USART Handle.
  560. * @retval None
  561. */
  562. #define __HAL_USART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= ~USART_CR3_ONEBIT)
  563. /** @brief Enable USART.
  564. * @param __HANDLE__ specifies the USART Handle.
  565. * @retval None
  566. */
  567. #define __HAL_USART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
  568. /** @brief Disable USART.
  569. * @param __HANDLE__ specifies the USART Handle.
  570. * @retval None
  571. */
  572. #define __HAL_USART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
  573. /**
  574. * @}
  575. */
  576. /* Private variables -----------------------------------------------------*/
  577. #if defined(USART_PRESC_PRESCALER)
  578. /** @defgroup USART_Private_Variables USART Private Variables
  579. * @{
  580. */
  581. static const uint16_t USARTPrescTable[12] = {1, 2, 4, 6, 8, 10, 12, 16, 32, 64, 128, 256};
  582. /**
  583. * @}
  584. */
  585. #endif
  586. /* Private macros --------------------------------------------------------*/
  587. /** @defgroup USART_Private_Macros USART Private Macros
  588. * @{
  589. */
  590. #if defined(USART_PRESC_PRESCALER)
  591. /** @brief BRR division operation to set BRR register in 8-bit oversampling mode.
  592. * @param __PCLK__ USART clock.
  593. * @param __BAUD__ Baud rate set by the user.
  594. * @param __CLOCKPRESCALER__ UART prescaler value.
  595. * @retval Division result
  596. */
  597. #define USART_DIV_SAMPLING8(__PCLK__, __BAUD__, __CLOCKPRESCALER__) (((((__PCLK__)/USARTPrescTable[(__CLOCKPRESCALER__)])*2) + ((__BAUD__)/2)) / (__BAUD__))
  598. #else
  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__)*2) + ((__BAUD__)/2)) / (__BAUD__))
  605. #endif
  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 L4
  609. * divided by the smallest oversampling used on the USART (i.e. 8)
  610. * (i.e. 120 MHz on STM32L4Rx/L4Sx, 80 Mhz otherwise)
  611. * @retval SET (__BAUDRATE__ is valid) or RESET (__BAUDRATE__ is invalid) */
  612. #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  613. #define IS_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 15000001U)
  614. #else
  615. #define IS_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 10000001U)
  616. #endif
  617. /**
  618. * @brief Ensure that USART frame number of stop bits is valid.
  619. * @param __STOPBITS__ USART frame number of stop bits.
  620. * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
  621. */
  622. #define IS_USART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == USART_STOPBITS_0_5) || \
  623. ((__STOPBITS__) == USART_STOPBITS_1) || \
  624. ((__STOPBITS__) == USART_STOPBITS_1_5) || \
  625. ((__STOPBITS__) == USART_STOPBITS_2))
  626. /**
  627. * @brief Ensure that USART frame parity is valid.
  628. * @param __PARITY__ USART frame parity.
  629. * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
  630. */
  631. #define IS_USART_PARITY(__PARITY__) (((__PARITY__) == USART_PARITY_NONE) || \
  632. ((__PARITY__) == USART_PARITY_EVEN) || \
  633. ((__PARITY__) == USART_PARITY_ODD))
  634. /**
  635. * @brief Ensure that USART communication mode is valid.
  636. * @param __MODE__ USART communication mode.
  637. * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
  638. */
  639. #define IS_USART_MODE(__MODE__) ((((__MODE__) & (uint32_t)0xFFFFFFF3U) == 0x00U) && ((__MODE__) != (uint32_t)0x00U))
  640. /**
  641. * @brief Ensure that USART oversampling is valid.
  642. * @param __SAMPLING__ USART oversampling.
  643. * @retval SET (__SAMPLING__ is valid) or RESET (__SAMPLING__ is invalid)
  644. */
  645. #define IS_USART_OVERSAMPLING(__SAMPLING__) (((__SAMPLING__) == USART_OVERSAMPLING_16) || \
  646. ((__SAMPLING__) == USART_OVERSAMPLING_8))
  647. /**
  648. * @brief Ensure that USART clock state is valid.
  649. * @param __CLOCK__ USART clock state.
  650. * @retval SET (__CLOCK__ is valid) or RESET (__CLOCK__ is invalid)
  651. */
  652. #define IS_USART_CLOCK(__CLOCK__) (((__CLOCK__) == USART_CLOCK_DISABLE) || \
  653. ((__CLOCK__) == USART_CLOCK_ENABLE))
  654. /**
  655. * @brief Ensure that USART frame polarity is valid.
  656. * @param __CPOL__ USART frame polarity.
  657. * @retval SET (__CPOL__ is valid) or RESET (__CPOL__ is invalid)
  658. */
  659. #define IS_USART_POLARITY(__CPOL__) (((__CPOL__) == USART_POLARITY_LOW) || ((__CPOL__) == USART_POLARITY_HIGH))
  660. /**
  661. * @brief Ensure that USART frame phase is valid.
  662. * @param __CPHA__ USART frame phase.
  663. * @retval SET (__CPHA__ is valid) or RESET (__CPHA__ is invalid)
  664. */
  665. #define IS_USART_PHASE(__CPHA__) (((__CPHA__) == USART_PHASE_1EDGE) || ((__CPHA__) == USART_PHASE_2EDGE))
  666. /**
  667. * @brief Ensure that USART frame last bit clock pulse setting is valid.
  668. * @param __LASTBIT__ USART frame last bit clock pulse setting.
  669. * @retval SET (__LASTBIT__ is valid) or RESET (__LASTBIT__ is invalid)
  670. */
  671. #define IS_USART_LASTBIT(__LASTBIT__) (((__LASTBIT__) == USART_LASTBIT_DISABLE) || \
  672. ((__LASTBIT__) == USART_LASTBIT_ENABLE))
  673. /**
  674. * @brief Ensure that USART request parameter is valid.
  675. * @param __PARAM__ USART request parameter.
  676. * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid)
  677. */
  678. #define IS_USART_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == USART_RXDATA_FLUSH_REQUEST) || \
  679. ((__PARAM__) == USART_TXDATA_FLUSH_REQUEST))
  680. #if defined(USART_PRESC_PRESCALER)
  681. /**
  682. * @brief Ensure that USART Prescaler is valid.
  683. * @param __CLOCKPRESCALER__ USART Prescaler value.
  684. * @retval SET (__CLOCKPRESCALER__ is valid) or RESET (__CLOCKPRESCALER__ is invalid)
  685. */
  686. #define IS_USART_PRESCALER(__CLOCKPRESCALER__) (((__CLOCKPRESCALER__) == USART_PRESCALER_DIV1) || \
  687. ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV2) || \
  688. ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV4) || \
  689. ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV6) || \
  690. ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV8) || \
  691. ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV10) || \
  692. ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV12) || \
  693. ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV16) || \
  694. ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV32) || \
  695. ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV64) || \
  696. ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV128) || \
  697. ((__CLOCKPRESCALER__) == USART_PRESCALER_DIV256))
  698. #endif
  699. /**
  700. * @}
  701. */
  702. /* Include USART HAL Extended module */
  703. #include "stm32l4xx_hal_usart_ex.h"
  704. /* Exported functions --------------------------------------------------------*/
  705. /** @addtogroup USART_Exported_Functions USART Exported Functions
  706. * @{
  707. */
  708. /** @addtogroup USART_Exported_Functions_Group1 Initialization and de-initialization functions
  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. * @}
  718. */
  719. /** @addtogroup USART_Exported_Functions_Group2 IO operation functions
  720. * @{
  721. */
  722. /* IO operation functions *****************************************************/
  723. HAL_StatusTypeDef HAL_USART_Transmit(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size, uint32_t Timeout);
  724. HAL_StatusTypeDef HAL_USART_Receive(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
  725. HAL_StatusTypeDef HAL_USART_TransmitReceive(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout);
  726. HAL_StatusTypeDef HAL_USART_Transmit_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
  727. HAL_StatusTypeDef HAL_USART_Receive_IT(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
  728. HAL_StatusTypeDef HAL_USART_TransmitReceive_IT(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
  729. HAL_StatusTypeDef HAL_USART_Transmit_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint16_t Size);
  730. HAL_StatusTypeDef HAL_USART_Receive_DMA(USART_HandleTypeDef *husart, uint8_t *pRxData, uint16_t Size);
  731. HAL_StatusTypeDef HAL_USART_TransmitReceive_DMA(USART_HandleTypeDef *husart, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size);
  732. HAL_StatusTypeDef HAL_USART_DMAPause(USART_HandleTypeDef *husart);
  733. HAL_StatusTypeDef HAL_USART_DMAResume(USART_HandleTypeDef *husart);
  734. HAL_StatusTypeDef HAL_USART_DMAStop(USART_HandleTypeDef *husart);
  735. /* Transfer Abort functions */
  736. HAL_StatusTypeDef HAL_USART_Abort(USART_HandleTypeDef *husart);
  737. HAL_StatusTypeDef HAL_USART_Abort_IT(USART_HandleTypeDef *husart);
  738. void HAL_USART_IRQHandler(USART_HandleTypeDef *husart);
  739. void HAL_USART_TxHalfCpltCallback(USART_HandleTypeDef *husart);
  740. void HAL_USART_TxCpltCallback(USART_HandleTypeDef *husart);
  741. void HAL_USART_RxCpltCallback(USART_HandleTypeDef *husart);
  742. void HAL_USART_RxHalfCpltCallback(USART_HandleTypeDef *husart);
  743. void HAL_USART_TxRxCpltCallback(USART_HandleTypeDef *husart);
  744. void HAL_USART_ErrorCallback(USART_HandleTypeDef *husart);
  745. void HAL_USART_AbortCpltCallback(USART_HandleTypeDef *husart);
  746. /**
  747. * @}
  748. */
  749. /** @addtogroup USART_Exported_Functions_Group4 Peripheral State and Error functions
  750. * @{
  751. */
  752. /* Peripheral State and Error functions ***************************************/
  753. HAL_USART_StateTypeDef HAL_USART_GetState(USART_HandleTypeDef *husart);
  754. uint32_t HAL_USART_GetError(USART_HandleTypeDef *husart);
  755. /**
  756. * @}
  757. */
  758. /**
  759. * @}
  760. */
  761. /**
  762. * @}
  763. */
  764. /**
  765. * @}
  766. */
  767. #ifdef __cplusplus
  768. }
  769. #endif
  770. #endif /* __STM32L4xx_HAL_USART_H */
  771. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/