stm32h7xx_hal_uart.h 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633
  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_uart.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 21-April-2017
  7. * @brief Header file of UART HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32H7xx_HAL_UART_H
  39. #define __STM32H7xx_HAL_UART_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32h7xx_hal_def.h"
  45. /** @addtogroup STM32H7xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup UART
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup UART_Exported_Types UART Exported Types
  53. * @{
  54. */
  55. /**
  56. * @brief UART Init Structure definition
  57. */
  58. typedef struct
  59. {
  60. uint32_t BaudRate; /*!< This member configures the UART communication baud rate.
  61. The baud rate register is computed using the following formula:
  62. - If oversampling is 16 or in LIN mode,
  63. Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate)))
  64. - If oversampling is 8,
  65. Baud Rate Register[15:4] = ((2 * PCLKx) / ((huart->Init.BaudRate)))[15:4]
  66. Baud Rate Register[3] = 0
  67. Baud Rate Register[2:0] = (((2 * PCLKx) / ((huart->Init.BaudRate)))[3:0]) >> 1 */
  68. uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
  69. This parameter can be a value of @ref UARTEx_Word_Length. */
  70. uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
  71. This parameter can be a value of @ref UART_Stop_Bits. */
  72. uint32_t Parity; /*!< Specifies the parity mode.
  73. This parameter can be a value of @ref UART_Parity
  74. @note When parity is enabled, the computed parity is inserted
  75. at the MSB position of the transmitted data (9th bit when
  76. the word length is set to 9 data bits; 8th bit when the
  77. word length is set to 8 data bits). */
  78. uint32_t Mode; /*!< Specifies whether the Receive or Transmit mode is enabled or disabled.
  79. This parameter can be a value of @ref UART_Mode. */
  80. uint32_t HwFlowCtl; /*!< Specifies whether the hardware flow control mode is enabled
  81. or disabled.
  82. This parameter can be a value of @ref UART_Hardware_Flow_Control. */
  83. uint32_t OverSampling; /*!< Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to f_PCLK/8).
  84. This parameter can be a value of @ref UART_Over_Sampling. */
  85. uint32_t OneBitSampling; /*!< Specifies whether a single sample or three samples' majority vote is selected.
  86. Selecting the single sample method increases the receiver tolerance to clock
  87. deviations. This parameter can be a value of @ref UART_OneBit_Sampling. */
  88. uint32_t Prescaler; /*!< Specifies the prescaler value used to divide the UART clock source.
  89. This parameter can be a value of @ref UART_Prescaler. */
  90. uint32_t FIFOMode; /*!< Specifies if the FIFO mode will be used. This parameter can be a value
  91. of @ref UART_FIFO_mode. */
  92. uint32_t TXFIFOThreshold; /*!< Specifies the TXFIFO threshold level.
  93. This parameter can be a value of @ref UART_TXFIFO_threshold_level. */
  94. uint32_t RXFIFOThreshold; /*!< Specifies the RXFIFO threshold level.
  95. This parameter can be a value of @ref UART_RXFIFO_threshold_level. */
  96. }UART_InitTypeDef;
  97. /**
  98. * @brief UART Advanced Features initalization structure definition
  99. */
  100. typedef struct
  101. {
  102. uint32_t AdvFeatureInit; /*!< Specifies which advanced UART features is initialized. Several
  103. Advanced Features may be initialized at the same time .
  104. This parameter can be a value of @ref UART_Advanced_Features_Initialization_Type. */
  105. uint32_t TxPinLevelInvert; /*!< Specifies whether the TX pin active level is inverted.
  106. This parameter can be a value of @ref UART_Tx_Inv. */
  107. uint32_t RxPinLevelInvert; /*!< Specifies whether the RX pin active level is inverted.
  108. This parameter can be a value of @ref UART_Rx_Inv. */
  109. uint32_t DataInvert; /*!< Specifies whether data are inverted (positive/direct logic
  110. vs negative/inverted logic).
  111. This parameter can be a value of @ref UART_Data_Inv. */
  112. uint32_t Swap; /*!< Specifies whether TX and RX pins are swapped.
  113. This parameter can be a value of @ref UART_Rx_Tx_Swap. */
  114. uint32_t OverrunDisable; /*!< Specifies whether the reception overrun detection is disabled.
  115. This parameter can be a value of @ref UART_Overrun_Disable. */
  116. uint32_t DMADisableonRxError; /*!< Specifies whether the DMA is disabled in case of reception error.
  117. This parameter can be a value of @ref UART_DMA_Disable_on_Rx_Error. */
  118. uint32_t AutoBaudRateEnable; /*!< Specifies whether auto Baud rate detection is enabled.
  119. This parameter can be a value of @ref UART_AutoBaudRate_Enable */
  120. uint32_t AutoBaudRateMode; /*!< If auto Baud rate detection is enabled, specifies how the rate
  121. detection is carried out.
  122. This parameter can be a value of @ref UART_AutoBaud_Rate_Mode. */
  123. uint32_t MSBFirst; /*!< Specifies whether MSB is sent first on UART line.
  124. This parameter can be a value of @ref UART_MSB_First. */
  125. } UART_AdvFeatureInitTypeDef;
  126. /**
  127. * @brief HAL UART State structures definition
  128. * @note HAL UART State value is a combination of 2 different substates: gState and RxState.
  129. * - gState contains UART state information related to global Handle management
  130. * and also information related to Tx operations.
  131. * gState value coding follow below described bitmap :
  132. * b7-b6 Error information
  133. * 00 : No Error
  134. * 01 : (Not Used)
  135. * 10 : Timeout
  136. * 11 : Error
  137. * b5 IP initilisation status
  138. * 0 : Reset (IP not initialized)
  139. * 1 : Init done (IP not initialized. HAL UART Init function already called)
  140. * b4-b3 (not used)
  141. * xx : Should be set to 00
  142. * b2 Intrinsic process state
  143. * 0 : Ready
  144. * 1 : Busy (IP busy with some configuration or internal operations)
  145. * b1 (not used)
  146. * x : Should be set to 0
  147. * b0 Tx state
  148. * 0 : Ready (no Tx operation ongoing)
  149. * 1 : Busy (Tx operation ongoing)
  150. * - RxState contains information related to Rx operations.
  151. * RxState value coding follow below described bitmap :
  152. * b7-b6 (not used)
  153. * xx : Should be set to 00
  154. * b5 IP initilisation status
  155. * 0 : Reset (IP not initialized)
  156. * 1 : Init done (IP not initialized)
  157. * b4-b2 (not used)
  158. * xxx : Should be set to 000
  159. * b1 Rx state
  160. * 0 : Ready (no Rx operation ongoing)
  161. * 1 : Busy (Rx operation ongoing)
  162. * b0 (not used)
  163. * x : Should be set to 0.
  164. */
  165. typedef enum
  166. {
  167. HAL_UART_STATE_RESET = 0x00U, /*!< Peripheral is not initialized
  168. Value is allowed for gState and RxState */
  169. HAL_UART_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use
  170. Value is allowed for gState and RxState */
  171. HAL_UART_STATE_BUSY = 0x24U, /*!< an internal process is ongoing
  172. Value is allowed for gState only */
  173. HAL_UART_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing
  174. Value is allowed for gState only */
  175. HAL_UART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing
  176. Value is allowed for RxState only */
  177. HAL_UART_STATE_BUSY_TX_RX = 0x23U, /*!< Data Transmission and Reception process is ongoing
  178. Not to be used for neither gState nor RxState.
  179. Value is result of combination (Or) between gState and RxState values */
  180. HAL_UART_STATE_TIMEOUT = 0xA0U, /*!< Timeout state
  181. Value is allowed for gState only */
  182. HAL_UART_STATE_ERROR = 0xE0U /*!< Error
  183. Value is allowed for gState only */
  184. }HAL_UART_StateTypeDef;
  185. /**
  186. * @brief HAL UART Error Code structure definition
  187. */
  188. typedef enum
  189. {
  190. HAL_UART_ERROR_NONE = 0x00U, /*!< No error */
  191. HAL_UART_ERROR_PE = 0x01U, /*!< Parity error */
  192. HAL_UART_ERROR_NE = 0x02U, /*!< Noise error */
  193. HAL_UART_ERROR_FE = 0x04U, /*!< frame error */
  194. HAL_UART_ERROR_ORE = 0x08U, /*!< Overrun error */
  195. HAL_UART_ERROR_DMA = 0x10U /*!< DMA transfer error */
  196. }HAL_UART_ErrorTypeDef;
  197. /**
  198. * @brief UART clock sources definition
  199. */
  200. typedef enum
  201. {
  202. UART_CLOCKSOURCE_D2PCLK1 = 0x00U, /*!< Domain2 PCLK1 clock source */
  203. UART_CLOCKSOURCE_D2PCLK2 = 0x01U, /*!< Domain2 PCLK2 clock source */
  204. UART_CLOCKSOURCE_D3PCLK1 = 0x02U, /*!< Domain3 PCLK1 clock source */
  205. UART_CLOCKSOURCE_PLL2 = 0x04U, /*!< PLL2Q clock source */
  206. UART_CLOCKSOURCE_HSI = 0x08U, /*!< HSI clock source */
  207. UART_CLOCKSOURCE_CSI = 0x10U, /*!< CSI clock source */
  208. UART_CLOCKSOURCE_LSE = 0x20U, /*!< LSE clock source */
  209. UART_CLOCKSOURCE_PLL3 = 0x40U, /*!< PLL3Q clock source */
  210. UART_CLOCKSOURCE_UNDEFINED = 0x80U /*!< Undefined clock source */
  211. }UART_ClockSourceTypeDef;
  212. /**
  213. * @brief UART handle Structure definition
  214. */
  215. typedef struct
  216. {
  217. USART_TypeDef *Instance; /*!< UART registers base address */
  218. UART_InitTypeDef Init; /*!< UART communication parameters */
  219. UART_AdvFeatureInitTypeDef AdvancedInit; /*!< UART Advanced Features initialization parameters */
  220. uint8_t *pTxBuffPtr; /*!< Pointer to UART Tx transfer Buffer */
  221. uint16_t TxXferSize; /*!< UART Tx Transfer size */
  222. __IO uint16_t TxXferCount; /*!< UART Tx Transfer Counter */
  223. uint8_t *pRxBuffPtr; /*!< Pointer to UART Rx transfer Buffer */
  224. uint16_t RxXferSize; /*!< UART Rx Transfer size */
  225. __IO uint16_t RxXferCount; /*!< UART Rx Transfer Counter */
  226. uint16_t Mask; /*!< UART Rx RDR register mask */
  227. DMA_HandleTypeDef *hdmatx; /*!< UART Tx DMA Handle parameters */
  228. DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */
  229. HAL_LockTypeDef Lock; /*!< Locking object */
  230. __IO HAL_UART_StateTypeDef gState; /*!< UART state information related to global Handle management
  231. and also related to Tx operations.
  232. This parameter can be a value of @ref HAL_UART_StateTypeDef */
  233. __IO HAL_UART_StateTypeDef RxState; /*!< UART state information related to Rx operations.
  234. This parameter can be a value of @ref HAL_UART_StateTypeDef */
  235. __IO uint32_t ErrorCode; /*!< UART Error code */
  236. }UART_HandleTypeDef;
  237. /**
  238. * @}
  239. */
  240. /* Exported constants --------------------------------------------------------*/
  241. /** @defgroup UART_Exported_Constants UART Exported Constants
  242. * @{
  243. */
  244. /** @defgroup UART_Stop_Bits UART Number of Stop Bits
  245. * @{
  246. */
  247. #define UART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< UART frame with 0.5 stop bit */
  248. #define UART_STOPBITS_1 ((uint32_t)0x00000000U) /*!< UART frame with 1 stop bit */
  249. #define UART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< UART frame with 1.5 stop bits */
  250. #define UART_STOPBITS_2 USART_CR2_STOP_1 /*!< UART frame with 2 stop bits */
  251. /**
  252. * @}
  253. */
  254. /** @defgroup UART_Parity UART Parity
  255. * @{
  256. */
  257. #define UART_PARITY_NONE ((uint32_t)0x00000000U) /*!< No parity */
  258. #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE) /*!< Even parity */
  259. #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) /*!< Odd parity */
  260. /**
  261. * @}
  262. */
  263. /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control
  264. * @{
  265. */
  266. #define UART_HWCONTROL_NONE ((uint32_t)0x00000000U) /*!< No hardware control */
  267. #define UART_HWCONTROL_RTS ((uint32_t)USART_CR3_RTSE) /*!< Request To Send */
  268. #define UART_HWCONTROL_CTS ((uint32_t)USART_CR3_CTSE) /*!< Clear To Send */
  269. #define UART_HWCONTROL_RTS_CTS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE)) /*!< Request and Clear To Send */
  270. /**
  271. * @}
  272. */
  273. /** @defgroup UART_Mode UART Transfer Mode
  274. * @{
  275. */
  276. #define UART_MODE_RX ((uint32_t)USART_CR1_RE) /*!< RX mode */
  277. #define UART_MODE_TX ((uint32_t)USART_CR1_TE) /*!< TX mode */
  278. #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) /*!< RX and TX mode */
  279. /**
  280. * @}
  281. */
  282. /** @defgroup UART_State UART State
  283. * @{
  284. */
  285. #define UART_STATE_DISABLE ((uint32_t)0x00000000U) /*!< UART disabled */
  286. #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE) /*!< UART enabled */
  287. /**
  288. * @}
  289. */
  290. /** @defgroup UART_Over_Sampling UART Over Sampling
  291. * @{
  292. */
  293. #define UART_OVERSAMPLING_16 ((uint32_t)0x00000000U) /*!< Oversampling by 16 */
  294. #define UART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8) /*!< Oversampling by 8 */
  295. /**
  296. * @}
  297. */
  298. /** @defgroup UART_OneBit_Sampling UART One Bit Sampling Method
  299. * @{
  300. */
  301. #define UART_ONE_BIT_SAMPLE_DISABLE ((uint32_t)0x00000000U) /*!< One-bit sampling disable */
  302. #define UART_ONE_BIT_SAMPLE_ENABLE ((uint32_t)USART_CR3_ONEBIT) /*!< One-bit sampling enable */
  303. /**
  304. * @}
  305. */
  306. /** @defgroup UART_Prescaler UART Prescaler
  307. * @{
  308. */
  309. #define UART_PRESCALER_DIV1 ((uint32_t)0x00000000U) /*!< UART clock /1 */
  310. #define UART_PRESCALER_DIV2 ((uint32_t)0x00000001U) /*!< UART clock /2 */
  311. #define UART_PRESCALER_DIV4 ((uint32_t)0x00000002U) /*!< UART clock /4 */
  312. #define UART_PRESCALER_DIV6 ((uint32_t)0x00000003U) /*!< UART clock /6 */
  313. #define UART_PRESCALER_DIV8 ((uint32_t)0x00000004U) /*!< UART clock /8 */
  314. #define UART_PRESCALER_DIV10 ((uint32_t)0x00000005U) /*!< UART clock /10 */
  315. #define UART_PRESCALER_DIV12 ((uint32_t)0x00000006U) /*!< UART clock /12 */
  316. #define UART_PRESCALER_DIV16 ((uint32_t)0x00000007U) /*!< UART clock /16 */
  317. #define UART_PRESCALER_DIV32 ((uint32_t)0x00000008U) /*!< UART clock /32 */
  318. #define UART_PRESCALER_DIV64 ((uint32_t)0x00000009U) /*!< UART clock /64 */
  319. #define UART_PRESCALER_DIV128 ((uint32_t)0x0000000AU) /*!< UART clock /128 */
  320. #define UART_PRESCALER_DIV256 ((uint32_t)0x0000000BU) /*!< UART clock /256 */
  321. /**
  322. * @}
  323. */
  324. /** @defgroup UART_FIFO_mode UART FIFO mode
  325. * @brief UART FIFO mode
  326. * @{
  327. */
  328. #define UART_FIFOMODE_DISABLE ((uint32_t)0x00000000U) /*!< FIFO mode disable */
  329. #define UART_FIFOMODE_ENABLE ((uint32_t)USART_CR1_FIFOEN) /*!< FIFO mode enable */
  330. /**
  331. * @}
  332. */
  333. /** @defgroup UART_TXFIFO_threshold_level UART TXFIFO threshold level
  334. * @brief UART TXFIFO level
  335. * @{
  336. */
  337. #define UART_TXFIFO_THRESHOLD_1_8 ((uint32_t)0x00000000U) /*!< TXFIFO reaches 1/8 of its depth */
  338. #define UART_TXFIFO_THRESHOLD_1_4 ((uint32_t)USART_CR3_TXFTCFG_0) /*!< TXFIFO reaches 1/4 of its depth */
  339. #define UART_TXFIFO_THRESHOLD_1_2 ((uint32_t)USART_CR3_TXFTCFG_1) /*!< TXFIFO reaches 1/2 of its depth */
  340. #define UART_TXFIFO_THRESHOLD_3_4 ((uint32_t)(USART_CR3_TXFTCFG_0|USART_CR3_TXFTCFG_1)) /*!< TXFIFO reaches 3/4 of its depth */
  341. #define UART_TXFIFO_THRESHOLD_7_8 ((uint32_t)USART_CR3_TXFTCFG_2) /*!< TXFIFO reaches 7/8 of its depth */
  342. #define UART_TXFIFO_THRESHOLD_8_8 ((uint32_t)(USART_CR3_TXFTCFG_2|USART_CR3_TXFTCFG_0)) /*!< TXFIFO becomes empty */
  343. /**
  344. * @}
  345. */
  346. /** @defgroup UART_RXFIFO_threshold_level UART RXFIFO threshold level
  347. * @brief UART RXFIFO level
  348. * @{
  349. */
  350. #define UART_RXFIFO_THRESHOLD_1_8 ((uint32_t)0x00000000U) /*!< RXFIFO reaches 1/8 of its depth */
  351. #define UART_RXFIFO_THRESHOLD_1_4 ((uint32_t)USART_CR3_RXFTCFG_0) /*!< RXFIFO reaches 1/4 of its depth */
  352. #define UART_RXFIFO_THRESHOLD_1_2 ((uint32_t)USART_CR3_RXFTCFG_1) /*!< RXFIFO reaches 1/2 of its depth */
  353. #define UART_RXFIFO_THRESHOLD_3_4 ((uint32_t)(USART_CR3_RXFTCFG_0|USART_CR3_RXFTCFG_1)) /*!< RXFIFO reaches 3/4 of its depth */
  354. #define UART_RXFIFO_THRESHOLD_7_8 ((uint32_t)USART_CR3_RXFTCFG_2) /*!< RXFIFO reaches 7/8 of its depth */
  355. #define UART_RXFIFO_THRESHOLD_8_8 ((uint32_t)(USART_CR3_RXFTCFG_2|USART_CR3_RXFTCFG_0)) /*!< RXFIFO becomes full */
  356. /**
  357. * @}
  358. */
  359. /** @defgroup UART_AutoBaud_Rate_Mode UART Advanced Feature AutoBaud Rate Mode
  360. * @{
  361. */
  362. #define UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT ((uint32_t)0x00000000U) /*!< Auto Baud rate detection on start bit */
  363. #define UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE ((uint32_t)USART_CR2_ABRMODE_0) /*!< Auto Baud rate detection on falling edge */
  364. #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME ((uint32_t)USART_CR2_ABRMODE_1) /*!< Auto Baud rate detection on 0x7F frame detection */
  365. #define UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME ((uint32_t)USART_CR2_ABRMODE) /*!< Auto Baud rate detection on 0x55 frame detection */
  366. /**
  367. * @}
  368. */
  369. /** @defgroup UART_Receiver_TimeOut UART Receiver TimeOut
  370. * @{
  371. */
  372. #define UART_RECEIVER_TIMEOUT_DISABLE ((uint32_t)0x00000000U) /*!< UART receiver timeout disable */
  373. #define UART_RECEIVER_TIMEOUT_ENABLE ((uint32_t)USART_CR2_RTOEN) /*!< UART receiver timeout enable */
  374. /**
  375. * @}
  376. */
  377. /** @defgroup UART_LIN UART Local Interconnection Network mode
  378. * @{
  379. */
  380. #define UART_LIN_DISABLE ((uint32_t)0x00000000U) /*!< Local Interconnect Network disable */
  381. #define UART_LIN_ENABLE ((uint32_t)USART_CR2_LINEN) /*!< Local Interconnect Network enable */
  382. /**
  383. * @}
  384. */
  385. /** @defgroup UART_LIN_Break_Detection UART LIN Break Detection
  386. * @{
  387. */
  388. #define UART_LINBREAKDETECTLENGTH_10B ((uint32_t)0x00000000U) /*!< LIN 10-bit break detection length */
  389. #define UART_LINBREAKDETECTLENGTH_11B ((uint32_t)USART_CR2_LBDL) /*!< LIN 11-bit break detection length */
  390. /**
  391. * @}
  392. */
  393. /** @defgroup UART_DMA_Tx UART DMA Tx
  394. * @{
  395. */
  396. #define UART_DMA_TX_DISABLE ((uint32_t)0x00000000U) /*!< UART DMA TX disabled */
  397. #define UART_DMA_TX_ENABLE ((uint32_t)USART_CR3_DMAT) /*!< UART DMA TX enabled */
  398. /**
  399. * @}
  400. */
  401. /** @defgroup UART_DMA_Rx UART DMA Rx
  402. * @{
  403. */
  404. #define UART_DMA_RX_DISABLE ((uint32_t)0x00000000U) /*!< UART DMA RX disabled */
  405. #define UART_DMA_RX_ENABLE ((uint32_t)USART_CR3_DMAR) /*!< UART DMA RX enabled */
  406. /**
  407. * @}
  408. */
  409. /** @defgroup UART_Half_Duplex_Selection UART Half Duplex Selection
  410. * @{
  411. */
  412. #define UART_HALF_DUPLEX_DISABLE ((uint32_t)0x00000000U) /*!< UART half-duplex disabled */
  413. #define UART_HALF_DUPLEX_ENABLE ((uint32_t)USART_CR3_HDSEL) /*!< UART half-duplex enabled */
  414. /**
  415. * @}
  416. */
  417. /** @defgroup UART_WakeUp_Methods UART WakeUp Methods
  418. * @{
  419. */
  420. #define UART_WAKEUPMETHOD_IDLELINE ((uint32_t)0x00000000U) /*!< UART wake-up on idle line */
  421. #define UART_WAKEUPMETHOD_ADDRESSMARK ((uint32_t)USART_CR1_WAKE) /*!< UART wake-up on address mark */
  422. /**
  423. * @}
  424. */
  425. /** @defgroup UART_Request_Parameters UART Request Parameters
  426. * @{
  427. */
  428. #define UART_AUTOBAUD_REQUEST ((uint32_t)USART_RQR_ABRRQ) /*!< Auto-Baud Rate Request */
  429. #define UART_SENDBREAK_REQUEST ((uint32_t)USART_RQR_SBKRQ) /*!< Send Break Request */
  430. #define UART_MUTE_MODE_REQUEST ((uint32_t)USART_RQR_MMRQ) /*!< Mute Mode Request */
  431. #define UART_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
  432. #define UART_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
  433. /**
  434. * @}
  435. */
  436. /** @defgroup UART_Advanced_Features_Initialization_Type UART Advanced Feature Initialization Type
  437. * @{
  438. */
  439. #define UART_ADVFEATURE_NO_INIT ((uint32_t)0x00000000U) /*!< No advanced feature initialization */
  440. #define UART_ADVFEATURE_TXINVERT_INIT ((uint32_t)0x00000001U) /*!< TX pin active level inversion */
  441. #define UART_ADVFEATURE_RXINVERT_INIT ((uint32_t)0x00000002U) /*!< RX pin active level inversion */
  442. #define UART_ADVFEATURE_DATAINVERT_INIT ((uint32_t)0x00000004U) /*!< Binary data inversion */
  443. #define UART_ADVFEATURE_SWAP_INIT ((uint32_t)0x00000008U) /*!< TX/RX pins swap */
  444. #define UART_ADVFEATURE_RXOVERRUNDISABLE_INIT ((uint32_t)0x00000010U) /*!< RX overrun disable */
  445. #define UART_ADVFEATURE_DMADISABLEONERROR_INIT ((uint32_t)0x00000020U) /*!< DMA disable on Reception Error */
  446. #define UART_ADVFEATURE_AUTOBAUDRATE_INIT ((uint32_t)0x00000040U) /*!< Auto Baud rate detection initialization */
  447. #define UART_ADVFEATURE_MSBFIRST_INIT ((uint32_t)0x00000080U) /*!< Most significant bit sent/received first */
  448. /**
  449. * @}
  450. */
  451. /** @defgroup UART_Tx_Inv UART Advanced Feature TX Pin Active Level Inversion
  452. * @{
  453. */
  454. #define UART_ADVFEATURE_TXINV_DISABLE ((uint32_t)0x00000000U) /*!< TX pin active level inversion disable */
  455. #define UART_ADVFEATURE_TXINV_ENABLE ((uint32_t)USART_CR2_TXINV) /*!< TX pin active level inversion enable */
  456. /**
  457. * @}
  458. */
  459. /** @defgroup UART_Rx_Inv UART Advanced Feature RX Pin Active Level Inversion
  460. * @{
  461. */
  462. #define UART_ADVFEATURE_RXINV_DISABLE ((uint32_t)0x00000000U) /*!< RX pin active level inversion disable */
  463. #define UART_ADVFEATURE_RXINV_ENABLE ((uint32_t)USART_CR2_RXINV) /*!< RX pin active level inversion enable */
  464. /**
  465. * @}
  466. */
  467. /** @defgroup UART_Data_Inv UART Advanced Feature Binary Data Inversion
  468. * @{
  469. */
  470. #define UART_ADVFEATURE_DATAINV_DISABLE ((uint32_t)0x00000000U) /*!< Binary data inversion disable */
  471. #define UART_ADVFEATURE_DATAINV_ENABLE ((uint32_t)USART_CR2_DATAINV) /*!< Binary data inversion enable */
  472. /**
  473. * @}
  474. */
  475. /** @defgroup UART_Rx_Tx_Swap UART Advanced Feature RX TX Pins Swap
  476. * @{
  477. */
  478. #define UART_ADVFEATURE_SWAP_DISABLE ((uint32_t)0x00000000U) /*!< TX/RX pins swap disable */
  479. #define UART_ADVFEATURE_SWAP_ENABLE ((uint32_t)USART_CR2_SWAP) /*!< TX/RX pins swap enable */
  480. /**
  481. * @}
  482. */
  483. /** @defgroup UART_Overrun_Disable UART Advanced Feature Overrun Disable
  484. * @{
  485. */
  486. #define UART_ADVFEATURE_OVERRUN_ENABLE ((uint32_t)0x00000000U) /*!< RX overrun enable */
  487. #define UART_ADVFEATURE_OVERRUN_DISABLE ((uint32_t)USART_CR3_OVRDIS) /*!< RX overrun disable */
  488. /**
  489. * @}
  490. */
  491. /** @defgroup UART_AutoBaudRate_Enable UART Advanced Feature Auto BaudRate Enable
  492. * @{
  493. */
  494. #define UART_ADVFEATURE_AUTOBAUDRATE_DISABLE ((uint32_t)0x00000000U) /*!< RX Auto Baud rate detection enable */
  495. #define UART_ADVFEATURE_AUTOBAUDRATE_ENABLE ((uint32_t)USART_CR2_ABREN) /*!< RX Auto Baud rate detection disable */
  496. /**
  497. * @}
  498. */
  499. /** @defgroup UART_DMA_Disable_on_Rx_Error UART Advanced Feature DMA Disable On Rx Error
  500. * @{
  501. */
  502. #define UART_ADVFEATURE_DMA_ENABLEONRXERROR ((uint32_t)0x00000000U) /*!< DMA enable on Reception Error */
  503. #define UART_ADVFEATURE_DMA_DISABLEONRXERROR ((uint32_t)USART_CR3_DDRE) /*!< DMA disable on Reception Error */
  504. /**
  505. * @}
  506. */
  507. /** @defgroup UART_MSB_First UART Advanced Feature MSB First
  508. * @{
  509. */
  510. #define UART_ADVFEATURE_MSBFIRST_DISABLE ((uint32_t)0x00000000U) /*!< Most significant bit sent/received first disable */
  511. #define UART_ADVFEATURE_MSBFIRST_ENABLE ((uint32_t)USART_CR2_MSBFIRST) /*!< Most significant bit sent/received first enable */
  512. /**
  513. * @}
  514. */
  515. /** @defgroup UART_Stop_Mode_Enable UART Advanced Feature Stop Mode Enable
  516. * @{
  517. */
  518. #define UART_ADVFEATURE_STOPMODE_DISABLE ((uint32_t)0x00000000U) /*!< UART stop mode disable */
  519. #define UART_ADVFEATURE_STOPMODE_ENABLE ((uint32_t)USART_CR1_UESM) /*!< UART stop mode enable */
  520. /**
  521. * @}
  522. */
  523. /** @defgroup UART_Mute_Mode UART Advanced Feature Mute Mode Enable
  524. * @{
  525. */
  526. #define UART_ADVFEATURE_MUTEMODE_DISABLE ((uint32_t)0x00000000U) /*!< UART mute mode disable */
  527. #define UART_ADVFEATURE_MUTEMODE_ENABLE ((uint32_t)USART_CR1_MME) /*!< UART mute mode enable */
  528. /**
  529. * @}
  530. */
  531. /** @defgroup UART_CR2_ADDRESS_LSB_POS UART Address-matching LSB Position In CR2 Register
  532. * @{
  533. */
  534. #define UART_CR2_ADDRESS_LSB_POS ((uint32_t) 24U) /*!< UART address-matching LSB position in CR2 register */
  535. /**
  536. * @}
  537. */
  538. /** @defgroup UART_WakeUp_from_Stop_Selection UART WakeUp From Stop Selection
  539. * @{
  540. */
  541. #define UART_WAKEUP_ON_ADDRESS ((uint32_t)0x00000000U) /*!< UART wake-up on address */
  542. #define UART_WAKEUP_ON_STARTBIT ((uint32_t)USART_CR3_WUS_1) /*!< UART wake-up on start bit */
  543. #define UART_WAKEUP_ON_READDATA_NONEMPTY ((uint32_t)USART_CR3_WUS) /*!< UART wake-up on receive data register not empty */
  544. #define UART_WAKEUP_ON_RXFIFO_THRESHOLD ((uint32_t)USART_CR3_RXFTIE) /*!< UART wake-up when the RXFIFO reaches threshold */
  545. #define UART_WAKEUP_ON_RXFIFO_FULL ((uint32_t)USART_CR1_RXFFIE) /*!< UART wake-up when the RXFIFO is full */
  546. #define UART_WAKEUP_ON_TXFIFO_THRESHOLD ((uint32_t)USART_CR3_TXFTIE) /*!< UART wake-up when the TXFIFO reaches threshold */
  547. #define UART_WAKEUP_ON_TXFIFO_EMPTY ((uint32_t)USART_CR1_TXFEIE) /*!< UART wake-up when the TXFIFO is empty */
  548. /**
  549. * @}
  550. */
  551. /** @defgroup UART_DriverEnable_Polarity UART DriverEnable Polarity
  552. * @{
  553. */
  554. #define UART_DE_POLARITY_HIGH ((uint32_t)0x00000000U) /*!< Driver enable signal is active high */
  555. #define UART_DE_POLARITY_LOW ((uint32_t)USART_CR3_DEP) /*!< Driver enable signal is active low */
  556. /**
  557. * @}
  558. */
  559. /** @defgroup UART_CR1_DEAT_ADDRESS_LSB_POS UART Driver Enable Assertion Time LSB Position In CR1 Register
  560. * @{
  561. */
  562. #define UART_CR1_DEAT_ADDRESS_LSB_POS ((uint32_t) 21U) /*!< UART Driver Enable assertion time LSB position in CR1 register */
  563. /**
  564. * @}
  565. */
  566. /** @defgroup UART_CR1_DEDT_ADDRESS_LSB_POS UART Driver Enable DeAssertion Time LSB Position In CR1 Register
  567. * @{
  568. */
  569. #define UART_CR1_DEDT_ADDRESS_LSB_POS ((uint32_t) 16U) /*!< UART Driver Enable de-assertion time LSB position in CR1 register */
  570. /**
  571. * @}
  572. */
  573. /** @defgroup UART_Interruption_Mask UART Interruptions Flag Mask
  574. * @{
  575. */
  576. #define UART_IT_MASK ((uint32_t)0x001FU) /*!< UART interruptions flags mask */
  577. /**
  578. * @}
  579. */
  580. /** @defgroup UART_TimeOut_Value UART polling-based communications time-out value
  581. * @{
  582. */
  583. #define HAL_UART_TIMEOUT_VALUE 0x1FFFFFFU /*!< UART polling-based communications time-out value */
  584. /**
  585. * @}
  586. */
  587. /** @defgroup UART_Flags UART Status Flags
  588. * Elements values convention: 0xXXXX
  589. * - 0xXXXX : Flag mask in the ISR register
  590. * @{
  591. */
  592. #define UART_FLAG_TXFT USART_ISR_TXFT /*!< UART TXFIFO threshold flag */
  593. #define UART_FLAG_RXFT USART_ISR_RXFT /*!< UART RXFIFO threshold flag */
  594. #define UART_FLAG_RXFF USART_ISR_RXFF /*!< UART RXFIFO Full flag */
  595. #define UART_FLAG_TXFE USART_ISR_TXFE /*!< UART TXFIFO Empty flag */
  596. #define UART_FLAG_REACK USART_ISR_REACK /*!< UART receive enable acknowledge flag */
  597. #define UART_FLAG_TEACK USART_ISR_TEACK /*!< UART transmit enable acknowledge flag */
  598. #define UART_FLAG_WUF USART_ISR_WUF /*!< UART wake-up from stop mode flag */
  599. #define UART_FLAG_RWU USART_ISR_RWU /*!< UART receiver wake-up from mute mode flag */
  600. #define UART_FLAG_SBKF USART_ISR_SBKF /*!< UART send break flag */
  601. #define UART_FLAG_CMF USART_ISR_CMF /*!< UART character match flag */
  602. #define UART_FLAG_BUSY USART_ISR_BUSY /*!< UART busy flag */
  603. #define UART_FLAG_ABRF USART_ISR_ABRF /*!< UART auto Baud rate flag */
  604. #define UART_FLAG_ABRE USART_ISR_ABRE /*!< UART uto Baud rate error */
  605. #define UART_FLAG_RTOF USART_ISR_RTOF /*!< UART receiver timeout flag */
  606. #define UART_FLAG_CTS USART_ISR_CTS /*!< UART clear to send flag */
  607. #define UART_FLAG_CTSIF USART_ISR_CTSIF /*!< UART clear to send interrupt flag */
  608. #define UART_FLAG_LBDF USART_ISR_LBDF /*!< UART LIN break detection flag */
  609. #define UART_FLAG_TXE USART_ISR_TXE /*!< UART transmit data register empty */
  610. #define UART_FLAG_TXFNF USART_ISR_TXE /*!< UART TXFIFO not full */
  611. #define UART_FLAG_TC USART_ISR_TC /*!< UART transmission complete */
  612. #define UART_FLAG_RXNE USART_ISR_RXNE /*!< UART read data register not empty */
  613. #define UART_FLAG_RXFNE USART_ISR_RXNE /*!< UART RXFIFO not empty */
  614. #define UART_FLAG_IDLE USART_ISR_IDLE /*!< UART idle flag */
  615. #define UART_FLAG_ORE USART_ISR_ORE /*!< UART overrun error */
  616. #define UART_FLAG_NE USART_ISR_NE /*!< UART noise error */
  617. #define UART_FLAG_FE USART_ISR_FE /*!< UART frame error */
  618. #define UART_FLAG_PE USART_ISR_PE /*!< UART parity error */
  619. /**
  620. * @}
  621. */
  622. /** @defgroup UART_Interrupt_definition UART Interrupts Definition
  623. * Elements values convention: 000ZZZZZ0XXYYYYYb
  624. * - YYYYY : Interrupt source position in the XX register (5bits)
  625. * - XX : Interrupt source register (2bits)
  626. * - 01: CR1 register
  627. * - 10: CR2 register
  628. * - 11: CR3 register
  629. * - ZZZZZ : Flag position in the ISR register(5bits)
  630. * @{
  631. */
  632. #define UART_IT_PE ((uint32_t)0x0028U) /*!< UART parity error interruption */
  633. #define UART_IT_TXE ((uint32_t)0x0727U) /*!< UART transmit data register empty interruption */
  634. #define UART_IT_TC ((uint32_t)0x0626U) /*!< UART transmission complete interruption */
  635. #define UART_IT_RXNE ((uint32_t)0x0525U) /*!< UART read data register not empty interruption */
  636. #define UART_IT_IDLE ((uint32_t)0x0424U) /*!< UART idle interruption */
  637. #define UART_IT_LBD ((uint32_t)0x0846U) /*!< UART LIN break detection interruption */
  638. #define UART_IT_CTS ((uint32_t)0x096AU) /*!< UART CTS interruption */
  639. #define UART_IT_CM ((uint32_t)0x112EU) /*!< UART character match interruption */
  640. #define UART_IT_WUF ((uint32_t)0x1476U) /*!< UART wake-up from stop mode interruption */
  641. #define UART_IT_RXFF ((uint16_t)0x183FU)
  642. #define UART_IT_TXFE ((uint16_t)0x173EU)
  643. #define UART_IT_RXFT ((uint16_t)0x1A7CU)
  644. #define UART_IT_TXFT ((uint16_t)0x1B77U)
  645. /** Elements values convention: 000000000XXYYYYYb
  646. * - YYYYY : Interrupt source position in the XX register (5bits)
  647. * - XX : Interrupt source register (2bits)
  648. * - 01: CR1 register
  649. * - 10: CR2 register
  650. * - 11: CR3 register
  651. */
  652. #define UART_IT_ERR ((uint32_t)0x0060U) /*!< UART error interruption */
  653. /** Elements values convention: 0000ZZZZ00000000b
  654. * - ZZZZ : Flag position in the ISR register(4bits)
  655. */
  656. #define UART_IT_ORE ((uint32_t)0x0300U) /*!< UART overrun error interruption */
  657. #define UART_IT_NE ((uint32_t)0x0200U) /*!< UART noise error interruption */
  658. #define UART_IT_FE ((uint32_t)0x0100U) /*!< UART frame error interruption */
  659. /**
  660. * @}
  661. */
  662. /** @defgroup UART_IT_CLEAR_Flags UART Interruption Clear Flags
  663. * @{
  664. */
  665. #define UART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
  666. #define UART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
  667. #define UART_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
  668. #define UART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
  669. #define UART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */
  670. #define UART_CLEAR_TXFECF USART_ICR_TXFECF /*!< TXFIFO empty clear flag */
  671. #define UART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
  672. #define UART_CLEAR_LBDF USART_ICR_LBDCF /*!< LIN Break Detection Clear Flag */
  673. #define UART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */
  674. #define UART_CLEAR_RTOF USART_ICR_RTOCF /*!< Receiver Time Out Clear Flag */
  675. #define UART_CLEAR_CMF USART_ICR_CMCF /*!< Character Match Clear Flag */
  676. #define UART_CLEAR_WUF USART_ICR_WUCF /*!< Wake Up from stop mode Clear Flag */
  677. /**
  678. * @}
  679. */
  680. /**
  681. * @}
  682. */
  683. /* Exported macros -----------------------------------------------------------*/
  684. /** @defgroup UART_Exported_Macros UART Exported Macros
  685. * @{
  686. */
  687. /** @brief Reset UART handle states.
  688. * @param __HANDLE__: UART handle.
  689. * @retval None
  690. */
  691. #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \
  692. (__HANDLE__)->gState = HAL_UART_STATE_RESET; \
  693. (__HANDLE__)->RxState = HAL_UART_STATE_RESET; \
  694. } while(0)
  695. /** @brief Flush the UART Data registers.
  696. * @param __HANDLE__: specifies the UART Handle.
  697. * @retval None
  698. */
  699. #define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) \
  700. do{ \
  701. SET_BIT((__HANDLE__)->Instance->RQR, UART_RXDATA_FLUSH_REQUEST); \
  702. SET_BIT((__HANDLE__)->Instance->RQR, UART_TXDATA_FLUSH_REQUEST); \
  703. } while(0)
  704. /** @brief Clear the specified UART pending flag.
  705. * @param __HANDLE__: specifies the UART Handle.
  706. * @param __FLAG__: specifies the flag to check.
  707. * This parameter can be any combination of the following values:
  708. * @arg UART_FLAG_WUF: Wake up from stop mode flag
  709. * @arg UART_FLAG_CMF: Character match flag
  710. * @arg UART_FLAG_RTOF: Receiver timeout flag
  711. * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5)
  712. * @arg UART_FLAG_LBD: LIN Break detection flag
  713. * @arg UART_FLAG_TC: Transmission Complete flag
  714. * @arg UART_FLAG_TXFE: TXFIFO Empty flag
  715. * @arg UART_FLAG_IDLE: Idle Line detection flag
  716. * @arg UART_FLAG_ORE: OverRun Error flag
  717. * @arg UART_FLAG_NE: Noise Error flag
  718. * @arg UART_FLAG_FE: Framing Error flag
  719. * @arg UART_FLAG_PE: Parity Error flag
  720. * @retval The new state of __FLAG__ (TRUE or FALSE).
  721. */
  722. #define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
  723. /** @brief Clear the UART PE pending flag.
  724. * @param __HANDLE__: specifies the UART Handle.
  725. * @retval None
  726. */
  727. #define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_PEF)
  728. /** @brief Clear the UART FE pending flag.
  729. * @param __HANDLE__: specifies the UART Handle.
  730. * @retval None
  731. */
  732. #define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_FEF)
  733. /** @brief Clear the UART NE pending flag.
  734. * @param __HANDLE__: specifies the UART Handle.
  735. * @retval None
  736. */
  737. #define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_NEF)
  738. /** @brief Clear the UART ORE pending flag.
  739. * @param __HANDLE__: specifies the UART Handle.
  740. * @retval None
  741. */
  742. #define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_OREF)
  743. /** @brief Clear the UART IDLE pending flag.
  744. * @param __HANDLE__: specifies the UART Handle.
  745. * @retval None
  746. */
  747. #define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_IDLEF)
  748. /** @brief Clear the UART TX FIFO empty clear flag.
  749. * @param __HANDLE__: specifies the UART Handle.
  750. * @retval None
  751. */
  752. #define __HAL_UART_CLEAR_TXFECF(__HANDLE__) __HAL_UART_CLEAR_FLAG((__HANDLE__), UART_CLEAR_TXFECF)
  753. /** @brief Check whether the specified UART flag is set or not.
  754. * @param __HANDLE__: specifies the UART Handle.
  755. * @param __FLAG__: specifies the flag to check.
  756. * This parameter can be one of the following values:
  757. * @arg UART_FLAG_TXFT: TXFIFO threshold flag
  758. * @arg UART_FLAG_RXFT: RXFIFO threshold flag
  759. * @arg UART_FLAG_RXFF: RXFIFO Full flag
  760. * @arg UART_FLAG_TXFE: TXFIFO Empty flag
  761. * @arg UART_FLAG_REACK: Receive enable acknowledge flag
  762. * @arg UART_FLAG_TEACK: Transmit enable acknowledge flag
  763. * @arg UART_FLAG_WUF: Wake up from stop mode flag
  764. * @arg UART_FLAG_RWU: Receiver wake up flag (if the UART in mute mode)
  765. * @arg UART_FLAG_SBKF: Send Break flag
  766. * @arg UART_FLAG_CMF: Character match flag
  767. * @arg UART_FLAG_BUSY: Busy flag
  768. * @arg UART_FLAG_ABRF: Auto Baud rate detection flag
  769. * @arg UART_FLAG_ABRE: Auto Baud rate detection error flag
  770. * @arg UART_FLAG_RTOF: Receiver timeout flag
  771. * @arg UART_FLAG_CTS: CTS Change flag
  772. * @arg UART_FLAG_LBD: LIN Break detection flag
  773. * @arg UART_FLAG_TXE: Transmit data register empty flag
  774. * @arg UART_FLAG_TC: Transmission Complete flag
  775. * @arg UART_FLAG_RXNE: Receive data register not empty flag
  776. * @arg UART_FLAG_IDLE: Idle Line detection flag
  777. * @arg UART_FLAG_ORE: OverRun Error flag
  778. * @arg.UART_FLAG_NE: Noise Error flag
  779. * @arg UART_FLAG_FE: Framing Error flag
  780. * @arg UART_FLAG_PE: Parity Error flag
  781. * @retval The new state of __FLAG__ (TRUE or FALSE).
  782. */
  783. #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
  784. /** @brief Enable the specified UART interrupt.
  785. * @param __HANDLE__: specifies the UART Handle.
  786. * @param __INTERRUPT__: specifies the UART interrupt source to enable.
  787. * This parameter can be one of the following values:
  788. * @arg UART_IT_RXFF : RXFIFO Full interrupt
  789. * @arg UART_IT_TXFE : TXFIFO Empty interrupt
  790. * @arg.UART_IT_RXFT : RXFIFO threshold interrupt
  791. * @arg UART_IT_TXFT : TXFIFO threshold interrupt
  792. * @arg UART_IT_WUF: Wakeup from stop mode interrupt
  793. * @arg UART_IT_CM: Character match interrupt
  794. * @arg UART_IT_CTS: CTS change interrupt
  795. * @arg UART_IT_LBD: LIN Break detection interrupt
  796. * @arg UART_IT_TXE: Transmit Data Register empty interrupt
  797. * @arg UART_IT_TC: Transmission complete interrupt
  798. * @arg UART_IT_RXNE: Receive Data register not empty interrupt
  799. * @arg UART_IT_IDLE: Idle line detection interrupt
  800. * @arg.UART_IT_PE: Parity Error interrupt
  801. * @arg UART_IT_ERR: Error interrupt (Frame error, noise error, overrun error)
  802. * @retval None
  803. */
  804. #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
  805. ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
  806. ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))))
  807. /** @brief Disable the specified UART interrupt.
  808. * @param __HANDLE__: specifies the UART Handle.
  809. * @param __INTERRUPT__: specifies the UART interrupt source to disable.
  810. * This parameter can be one of the following values:
  811. * @arg.UART_IT_RXFF : RXFIFO Full interrupt
  812. * @arg UART_IT_TXFE : TXFIFO Empty interrupt
  813. * @arg UART_IT_RXFT : RXFIFO threshold interrupt
  814. * @arg UART_IT_TXFT : TXFIFO threshold interrupt
  815. * @arg UART_IT_WUF: Wakeup from stop mode interrupt
  816. * @arg UART_IT_CM: Character match interrupt
  817. * @arg UART_IT_CTS: CTS change interrupt
  818. * @arg UART_IT_LBD: LIN Break detection interrupt
  819. * @arg UART_IT_TXE: Transmit Data Register empty interrupt
  820. * @arg UART_IT_TC: Transmission complete interrupt
  821. * @arg UART_IT_RXNE: Receive Data register not empty interrupt
  822. * @arg UART_IT_IDLE: Idle line detection interrupt
  823. * @arg UART_IT_PE: Parity Error interrupt
  824. * @arg UART_IT_ERR: Error interrupt (Frame error, noise error, overrun error)
  825. * @retval None
  826. */
  827. #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1)? ((__HANDLE__)->Instance->CR1 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
  828. ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2)? ((__HANDLE__)->Instance->CR2 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
  829. ((__HANDLE__)->Instance->CR3 &= ~ (1U << ((__INTERRUPT__) & UART_IT_MASK))))
  830. /** @brief Check whether the specified UART interrupt has occurred or not.
  831. * @param __HANDLE__: specifies the UART Handle.
  832. * @param __IT__: specifies the UART interrupt to check.
  833. * This parameter can be one of the following values:
  834. * @arg UART_IT_RXFF : RXFIFO Full interrupt
  835. * @arg UART_IT_TXFE : TXFIFO Empty interrupt
  836. * @arg UART_IT_RXFT : RXFIFO threshold interrupt
  837. * @arg UART_IT_TXFT : TXFIFO threshold interrupt
  838. * @arg UART_IT_WUF: Wakeup from stop mode interrupt
  839. * @arg UART_IT_CM: Character match interrupt
  840. * @arg UART_IT_CTS: CTS change interrupt
  841. * @arg UART_IT_LBD: LIN Break detection interrupt
  842. * @arg UART_IT_TXE: Transmit Data Register empty interrupt
  843. * @arg UART_IT_TC: Transmission complete interrupt
  844. * @arg UART_IT_RXNE: Receive Data register not empty interrupt
  845. * @arg UART_IT_IDLE: Idle line detection interrupt
  846. * @arg UART_IT_ORE: OverRun Error interrupt
  847. * @arg UART_IT_NE: Noise Error interrupt
  848. * @arg UART_IT_FE: Framing Error interrupt
  849. * @arg UART_IT_PE: Parity Error interrupt
  850. * @retval The new state of __IT__ (TRUE or FALSE).
  851. */
  852. #define __HAL_UART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1 << ((__IT__)>> 0x08)))
  853. /** @brief Check whether the specified UART interrupt source is enabled or not.
  854. * @param __HANDLE__: specifies the UART Handle.
  855. * @param __IT__: specifies the UART interrupt source to check.
  856. * This parameter can be one of the following values:
  857. * @arg UART_IT_RXFF : RXFIFO Full interrupt
  858. * @arg UART_IT_TXFE : TXFIFO Empty interrupt
  859. * @arg UART_IT_RXFT : RXFIFO threshold interrupt
  860. * @arg UART_IT_TXFT : TXFIFO threshold interrupt
  861. * @arg UART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
  862. * @arg UART_IT_LBD: LIN Break detection interrupt
  863. * @arg UART_IT_TXE: Transmit Data Register empty interrupt
  864. * @arg UART_IT_TC: Transmission complete interrupt
  865. * @arg UART_IT_RXNE: Receive Data register not empty interrupt
  866. * @arg UART_IT_IDLE: Idle line detection interrupt
  867. * @arg UART_IT_ORE: OverRun Error interrupt
  868. * @arg UART_IT_NE: Noise Error interrupt
  869. * @arg UART_IT_FE: Framing Error interrupt
  870. * @arg UART_IT_PE: Parity Error interrupt
  871. * @retval The new state of __IT__ (TRUE or FALSE).
  872. */
  873. #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5U) == 2)? \
  874. (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1 << (((uint16_t)(__IT__)) & UART_IT_MASK)))
  875. /** @brief Clear the specified UART ISR flag, in setting the proper ICR register flag.
  876. * @param __HANDLE__: specifies the UART Handle.
  877. * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
  878. * to clear the corresponding interrupt
  879. * This parameter can be one of the following values:
  880. * @arg UART_CLEAR_PEF: Parity Error Clear Flag
  881. * @arg UART_CLEAR_FEF: Framing Error Clear Flag
  882. * @arg UART_CLEAR_NEF: Noise detected Clear Flag
  883. * @arg UART_CLEAR_OREF: OverRun Error Clear Flag
  884. * @arg UART_CLEAR_IDLEF: IDLE line detected Clear Flag
  885. * @arg UART_CLEAR_TCF: Transmission Complete Clear Flag
  886. * @arg UART_CLEAR_LBDF: LIN Break Detection Clear Flag
  887. * @arg UART_CLEAR_CTSF: CTS Interrupt Clear Flag
  888. * @arg UART_CLEAR_RTOF: Receiver Time Out Clear Flag
  889. * @arg UART_CLEAR_CMF: Character Match Clear Flag
  890. * @arg.UART_CLEAR_WUF: Wake Up from stop mode Clear Flag
  891. * @arg UART_CLEAR_TXFECF: TXFIFO empty Clear Flag
  892. * @retval None
  893. */
  894. #define __HAL_UART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
  895. /** @brief Set a specific UART request flag.
  896. * @param __HANDLE__: specifies the UART Handle.
  897. * @param __REQ__: specifies the request flag to set
  898. * This parameter can be one of the following values:
  899. * @arg UART_AUTOBAUD_REQUEST: Auto-Baud Rate Request
  900. * @arg UART_SENDBREAK_REQUEST: Send Break Request
  901. * @arg UART_MUTE_MODE_REQUEST: Mute Mode Request
  902. * @arg UART_RXDATA_FLUSH_REQUEST: Receive Data flush Request
  903. * @arg UART_TXDATA_FLUSH_REQUEST: Transmit data flush Request
  904. * @retval None
  905. */
  906. #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint32_t)(__REQ__))
  907. /** @brief Enable the UART one bit sample method.
  908. * @param __HANDLE__: specifies the UART Handle.
  909. * @retval None
  910. */
  911. #define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
  912. /** @brief Disable the UART one bit sample method.
  913. * @param __HANDLE__: specifies the UART Handle.
  914. * @retval None
  915. */
  916. #define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
  917. /** @brief Enable UART.
  918. * @param __HANDLE__: specifies the UART Handle.
  919. * @retval None
  920. */
  921. #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
  922. /** @brief Disable UART.
  923. * @param __HANDLE__: specifies the UART Handle.
  924. * @retval None
  925. */
  926. #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
  927. /** @brief Enable CTS flow control.
  928. * @note This macro allows to enable CTS hardware flow control for a given UART instance,
  929. * without need to call HAL_UART_Init() function.
  930. * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
  931. * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
  932. * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
  933. * - UART instance should have already been initialised (through call of HAL_UART_Init() )
  934. * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
  935. * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
  936. * @param __HANDLE__: specifies the UART Handle.
  937. * @retval None
  938. */
  939. #define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \
  940. do{ \
  941. SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
  942. (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \
  943. } while(0)
  944. /** @brief Disable CTS flow control.
  945. * @note This macro allows to disable CTS hardware flow control for a given UART instance,
  946. * without need to call HAL_UART_Init() function.
  947. * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
  948. * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
  949. * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
  950. * - UART instance should have already been initialised (through call of HAL_UART_Init() )
  951. * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
  952. * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
  953. * @param __HANDLE__: specifies the UART Handle.
  954. * @retval None
  955. */
  956. #define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \
  957. do{ \
  958. CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
  959. (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \
  960. } while(0)
  961. /** @brief Enable RTS flow control.
  962. * @note This macro allows to enable RTS hardware flow control for a given UART instance,
  963. * without need to call HAL_UART_Init() function.
  964. * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
  965. * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
  966. * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
  967. * - UART instance should have already been initialised (through call of HAL_UART_Init() )
  968. * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
  969. * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
  970. * @param __HANDLE__: specifies the UART Handle.
  971. * @retval None
  972. */
  973. #define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \
  974. do{ \
  975. SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \
  976. (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \
  977. } while(0)
  978. /** @brief Disable RTS flow control.
  979. * @note This macro allows to disable RTS hardware flow control for a given UART instance,
  980. * without need to call HAL_UART_Init() function.
  981. * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
  982. * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
  983. * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
  984. * - UART instance should have already been initialised (through call of HAL_UART_Init() )
  985. * - macro could only be called when corresponding UART instance is disabled (i.e. __HAL_UART_DISABLE(__HANDLE__))
  986. * and should be followed by an Enable macro (i.e. __HAL_UART_ENABLE(__HANDLE__)).
  987. * @param __HANDLE__: specifies the UART Handle.
  988. * @retval None
  989. */
  990. #define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \
  991. do{ \
  992. CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\
  993. (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \
  994. } while(0)
  995. /**
  996. * @}
  997. */
  998. /* Private variables -----------------------------------------------------*/
  999. /** @defgroup UART_Private_Variables UART Private Variables
  1000. * @{
  1001. */
  1002. static const uint16_t UARTPrescTable[12] = {1, 2, 4, 6, 8, 10, 12, 16, 32, 64, 128, 256};
  1003. /**
  1004. * @}
  1005. */
  1006. /* Private macros --------------------------------------------------------*/
  1007. /** @defgroup UART_Private_Macros UART Private Macros
  1008. * @{
  1009. */
  1010. /** @brief BRR division operation to set BRR register with LPUART.
  1011. * @param __PCLK__: LPUART clock.
  1012. * @param __BAUD__: Baud rate set by the user.
  1013. * @param __PRESCALER__: UART prescaler value.
  1014. * @retval Division result
  1015. */
  1016. #define UART_DIV_LPUART(__PCLK__, __BAUD__, __PRESCALER__) ((((((uint64_t)(__PCLK__)/UARTPrescTable[(__PRESCALER__)])*256)) + ((__BAUD__)/2)) / (__BAUD__))
  1017. /** @brief BRR division operation to set BRR register in 8-bit oversampling mode.
  1018. * @param __PCLK__: UART clock.
  1019. * @param __BAUD__: Baud rate set by the user.
  1020. * @param __PRESCALER__: UART prescaler value.
  1021. * @retval Division result
  1022. */
  1023. #define UART_DIV_SAMPLING8(__PCLK__, __BAUD__, __PRESCALER__) (((((__PCLK__)/UARTPrescTable[(__PRESCALER__)])*2) + ((__BAUD__)/2)) / (__BAUD__))
  1024. /** @brief BRR division operation to set BRR register in 16-bit oversampling mode.
  1025. * @param __PCLK__: UART clock.
  1026. * @param __BAUD__: Baud rate set by the user.
  1027. * @param __PRESCALER__: UART prescaler value.
  1028. * @retval Division result
  1029. */
  1030. #define UART_DIV_SAMPLING16(__PCLK__, __BAUD__, __PRESCALER__) ((((__PCLK__)/UARTPrescTable[(__PRESCALER__)]) + ((__BAUD__)/2)) / (__BAUD__))
  1031. /** @brief Check whether or not UART instance is Low Power UART.
  1032. * @param __HANDLE__: specifies the UART Handle.
  1033. * @retval SET (instance is LPUART) or RESET (instance isn't LPUART)
  1034. */
  1035. #define UART_INSTANCE_LOWPOWER(__HANDLE__) (((__HANDLE__)->Instance == LPUART1) ? SET : RESET )
  1036. /** @brief Check UART Baud rate.
  1037. * @param __BAUDRATE__: Baudrate specified by the user.
  1038. * The maximum Baud Rate is derived from the maximum clock on H7 (i.e. 100 MHz)
  1039. * divided by the smallest oversampling used on the USART (i.e. 8)
  1040. * @retval SET (__BAUDRATE__ is valid) or RESET (__BAUDRATE__ is invalid)
  1041. */
  1042. #define IS_UART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) < 12500001U)
  1043. /** @brief Check UART assertion time.
  1044. * @param __TIME__: 5-bit value assertion time.
  1045. * @retval Test result (TRUE or FALSE).
  1046. */
  1047. #define IS_UART_ASSERTIONTIME(__TIME__) ((__TIME__) <= 0x1FU)
  1048. /** @brief Check UART deassertion time.
  1049. * @param __TIME__: 5-bit value deassertion time.
  1050. * @retval Test result (TRUE or FALSE).
  1051. */
  1052. #define IS_UART_DEASSERTIONTIME(__TIME__) ((__TIME__) <= 0x1FU)
  1053. /**
  1054. * @brief Ensure that UART frame number of stop bits is valid.
  1055. * @param __STOPBITS__: UART frame number of stop bits.
  1056. * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
  1057. */
  1058. #define IS_UART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_0_5) || \
  1059. ((__STOPBITS__) == UART_STOPBITS_1) || \
  1060. ((__STOPBITS__) == UART_STOPBITS_1_5) || \
  1061. ((__STOPBITS__) == UART_STOPBITS_2))
  1062. /**
  1063. * @brief Ensure that LPUART frame number of stop bits is valid.
  1064. * @param __STOPBITS__: LPUART frame number of stop bits.
  1065. * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
  1066. */
  1067. #define IS_LPUART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_1) || \
  1068. ((__STOPBITS__) == UART_STOPBITS_2))
  1069. /**
  1070. * @brief Ensure that UART frame parity is valid.
  1071. * @param __PARITY__: UART frame parity.
  1072. * @retval SET (__PARITY__ is valid) or RESET (__PARITY__ is invalid)
  1073. */
  1074. #define IS_UART_PARITY(__PARITY__) (((__PARITY__) == UART_PARITY_NONE) || \
  1075. ((__PARITY__) == UART_PARITY_EVEN) || \
  1076. ((__PARITY__) == UART_PARITY_ODD))
  1077. /**
  1078. * @brief Ensure that UART hardware flow control is valid.
  1079. * @param __CONTROL__: UART hardware flow control.
  1080. * @retval SET (__CONTROL__ is valid) or RESET (__CONTROL__ is invalid)
  1081. */
  1082. #define IS_UART_HARDWARE_FLOW_CONTROL(__CONTROL__)\
  1083. (((__CONTROL__) == UART_HWCONTROL_NONE) || \
  1084. ((__CONTROL__) == UART_HWCONTROL_RTS) || \
  1085. ((__CONTROL__) == UART_HWCONTROL_CTS) || \
  1086. ((__CONTROL__) == UART_HWCONTROL_RTS_CTS))
  1087. /**
  1088. * @brief Ensure that UART communication mode is valid.
  1089. * @param __MODE__: UART communication mode.
  1090. * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
  1091. */
  1092. #define IS_UART_MODE(__MODE__) ((((__MODE__) & (~((uint32_t)(UART_MODE_TX_RX)))) == (uint32_t)0x00) && ((__MODE__) != (uint32_t)0x00))
  1093. /**
  1094. * @brief Ensure that UART state is valid.
  1095. * @param __STATE__: UART state.
  1096. * @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid)
  1097. */
  1098. #define IS_UART_STATE(__STATE__) (((__STATE__) == UART_STATE_DISABLE) || \
  1099. ((__STATE__) == UART_STATE_ENABLE))
  1100. /**
  1101. * @brief Ensure that UART oversampling is valid.
  1102. * @param __SAMPLING__: UART oversampling.
  1103. * @retval SET (__SAMPLING__ is valid) or RESET (__SAMPLING__ is invalid)
  1104. */
  1105. #define IS_UART_OVERSAMPLING(__SAMPLING__) (((__SAMPLING__) == UART_OVERSAMPLING_16) || \
  1106. ((__SAMPLING__) == UART_OVERSAMPLING_8))
  1107. /**
  1108. * @brief Ensure that UART frame sampling is valid.
  1109. * @param __ONEBIT__: UART frame sampling.
  1110. * @retval SET (__ONEBIT__ is valid) or RESET (__ONEBIT__ is invalid)
  1111. */
  1112. #define IS_UART_ONE_BIT_SAMPLE(__ONEBIT__) (((__ONEBIT__) == UART_ONE_BIT_SAMPLE_DISABLE) || \
  1113. ((__ONEBIT__) == UART_ONE_BIT_SAMPLE_ENABLE))
  1114. /**
  1115. * @brief Ensure that UART auto Baud rate detection mode is valid.
  1116. * @param __MODE__: UART auto Baud rate detection mode.
  1117. * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
  1118. */
  1119. #define IS_UART_ADVFEATURE_AUTOBAUDRATEMODE(__MODE__) (((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ONSTARTBIT) || \
  1120. ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ONFALLINGEDGE) || \
  1121. ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X7FFRAME) || \
  1122. ((__MODE__) == UART_ADVFEATURE_AUTOBAUDRATE_ON0X55FRAME))
  1123. /**
  1124. * @brief Ensure that UART receiver timeout setting is valid.
  1125. * @param __TIMEOUT__: UART receiver timeout setting.
  1126. * @retval SET (__TIMEOUT__ is valid) or RESET (__TIMEOUT__ is invalid)
  1127. */
  1128. #define IS_UART_RECEIVER_TIMEOUT(__TIMEOUT__) (((__TIMEOUT__) == UART_RECEIVER_TIMEOUT_DISABLE) || \
  1129. ((__TIMEOUT__) == UART_RECEIVER_TIMEOUT_ENABLE))
  1130. /**
  1131. * @brief Ensure that UART LIN state is valid.
  1132. * @param __LIN__: UART LIN state.
  1133. * @retval SET (__LIN__ is valid) or RESET (__LIN__ is invalid)
  1134. */
  1135. #define IS_UART_LIN(__LIN__) (((__LIN__) == UART_LIN_DISABLE) || \
  1136. ((__LIN__) == UART_LIN_ENABLE))
  1137. /**
  1138. * @brief Ensure that UART LIN break detection length is valid.
  1139. * @param __LENGTH__: UART LIN break detection length.
  1140. * @retval SET (__LENGTH__ is valid) or RESET (__LENGTH__ is invalid)
  1141. */
  1142. #define IS_UART_LIN_BREAK_DETECT_LENGTH(__LENGTH__) (((__LENGTH__) == UART_LINBREAKDETECTLENGTH_10B) || \
  1143. ((__LENGTH__) == UART_LINBREAKDETECTLENGTH_11B))
  1144. /**
  1145. * @brief Ensure that UART DMA TX state is valid.
  1146. * @param __DMATX__: UART DMA TX state.
  1147. * @retval SET (__DMATX__ is valid) or RESET (__DMATX__ is invalid)
  1148. */
  1149. #define IS_UART_DMA_TX(__DMATX__) (((__DMATX__) == UART_DMA_TX_DISABLE) || \
  1150. ((__DMATX__) == UART_DMA_TX_ENABLE))
  1151. /**
  1152. * @brief Ensure that UART DMA RX state is valid.
  1153. * @param __DMARX__: UART DMA RX state.
  1154. * @retval SET (__DMARX__ is valid) or RESET (__DMARX__ is invalid)
  1155. */
  1156. #define IS_UART_DMA_RX(__DMARX__) (((__DMARX__) == UART_DMA_RX_DISABLE) || \
  1157. ((__DMARX__) == UART_DMA_RX_ENABLE))
  1158. /**
  1159. * @brief Ensure that UART half-duplex state is valid.
  1160. * @param __HDSEL__: UART half-duplex state.
  1161. * @retval SET (__HDSEL__ is valid) or RESET (__HDSEL__ is invalid)
  1162. */
  1163. #define IS_UART_HALF_DUPLEX(__HDSEL__) (((__HDSEL__) == UART_HALF_DUPLEX_DISABLE) || \
  1164. ((__HDSEL__) == UART_HALF_DUPLEX_ENABLE))
  1165. /**
  1166. * @brief Ensure that UART wake-up method is valid.
  1167. * @param __WAKEUP__: UART wake-up method .
  1168. * @retval SET (__WAKEUP__ is valid) or RESET (__WAKEUP__ is invalid)
  1169. */
  1170. #define IS_UART_WAKEUPMETHOD(__WAKEUP__) (((__WAKEUP__) == UART_WAKEUPMETHOD_IDLELINE) || \
  1171. ((__WAKEUP__) == UART_WAKEUPMETHOD_ADDRESSMARK))
  1172. /**
  1173. * @brief Ensure that UART request parameter is valid.
  1174. * @param __PARAM__: UART request parameter.
  1175. * @retval SET (__PARAM__ is valid) or RESET (__PARAM__ is invalid)
  1176. */
  1177. #define IS_UART_REQUEST_PARAMETER(__PARAM__) (((__PARAM__) == UART_AUTOBAUD_REQUEST) || \
  1178. ((__PARAM__) == UART_SENDBREAK_REQUEST) || \
  1179. ((__PARAM__) == UART_MUTE_MODE_REQUEST) || \
  1180. ((__PARAM__) == UART_RXDATA_FLUSH_REQUEST) || \
  1181. ((__PARAM__) == UART_TXDATA_FLUSH_REQUEST))
  1182. /**
  1183. * @brief Ensure that UART advanced features initialization is valid.
  1184. * @param __INIT__: UART advanced features initialization.
  1185. * @retval SET (__INIT__ is valid) or RESET (__INIT__ is invalid)
  1186. */
  1187. #define IS_UART_ADVFEATURE_INIT(__INIT__) ((__INIT__) <= (UART_ADVFEATURE_NO_INIT | \
  1188. UART_ADVFEATURE_TXINVERT_INIT | \
  1189. UART_ADVFEATURE_RXINVERT_INIT | \
  1190. UART_ADVFEATURE_DATAINVERT_INIT | \
  1191. UART_ADVFEATURE_SWAP_INIT | \
  1192. UART_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
  1193. UART_ADVFEATURE_DMADISABLEONERROR_INIT | \
  1194. UART_ADVFEATURE_AUTOBAUDRATE_INIT | \
  1195. UART_ADVFEATURE_MSBFIRST_INIT))
  1196. /**
  1197. * @brief Ensure that UART frame TX inversion setting is valid.
  1198. * @param __TXINV__: UART frame TX inversion setting.
  1199. * @retval SET (__TXINV__ is valid) or RESET (__TXINV__ is invalid)
  1200. */
  1201. #define IS_UART_ADVFEATURE_TXINV(__TXINV__) (((__TXINV__) == UART_ADVFEATURE_TXINV_DISABLE) || \
  1202. ((__TXINV__) == UART_ADVFEATURE_TXINV_ENABLE))
  1203. /**
  1204. * @brief Ensure that UART frame RX inversion setting is valid.
  1205. * @param __RXINV__: UART frame RX inversion setting.
  1206. * @retval SET (__RXINV__ is valid) or RESET (__RXINV__ is invalid)
  1207. */
  1208. #define IS_UART_ADVFEATURE_RXINV(__RXINV__) (((__RXINV__) == UART_ADVFEATURE_RXINV_DISABLE) || \
  1209. ((__RXINV__) == UART_ADVFEATURE_RXINV_ENABLE))
  1210. /**
  1211. * @brief Ensure that UART frame data inversion setting is valid.
  1212. * @param __DATAINV__: UART frame data inversion setting.
  1213. * @retval SET (__DATAINV__ is valid) or RESET (__DATAINV__ is invalid)
  1214. */
  1215. #define IS_UART_ADVFEATURE_DATAINV(__DATAINV__) (((__DATAINV__) == UART_ADVFEATURE_DATAINV_DISABLE) || \
  1216. ((__DATAINV__) == UART_ADVFEATURE_DATAINV_ENABLE))
  1217. /**
  1218. * @brief Ensure that UART frame RX/TX pins swap setting is valid.
  1219. * @param __SWAP__: UART frame RX/TX pins swap setting.
  1220. * @retval SET (__SWAP__ is valid) or RESET (__SWAP__ is invalid)
  1221. */
  1222. #define IS_UART_ADVFEATURE_SWAP(__SWAP__) (((__SWAP__) == UART_ADVFEATURE_SWAP_DISABLE) || \
  1223. ((__SWAP__) == UART_ADVFEATURE_SWAP_ENABLE))
  1224. /**
  1225. * @brief Ensure that UART frame overrun setting is valid.
  1226. * @param __OVERRUN__: UART frame overrun setting.
  1227. * @retval SET (__OVERRUN__ is valid) or RESET (__OVERRUN__ is invalid)
  1228. */
  1229. #define IS_UART_OVERRUN(__OVERRUN__) (((__OVERRUN__) == UART_ADVFEATURE_OVERRUN_ENABLE) || \
  1230. ((__OVERRUN__) == UART_ADVFEATURE_OVERRUN_DISABLE))
  1231. /**
  1232. * @brief Ensure that UART auto Baud rate state is valid.
  1233. * @param __AUTOBAUDRATE__: UART auto Baud rate state.
  1234. * @retval SET (__AUTOBAUDRATE__ is valid) or RESET (__AUTOBAUDRATE__ is invalid)
  1235. */
  1236. #define IS_UART_ADVFEATURE_AUTOBAUDRATE(__AUTOBAUDRATE__) (((__AUTOBAUDRATE__) == UART_ADVFEATURE_AUTOBAUDRATE_DISABLE) || \
  1237. ((__AUTOBAUDRATE__) == UART_ADVFEATURE_AUTOBAUDRATE_ENABLE))
  1238. /**
  1239. * @brief Ensure that UART DMA enabling or disabling on error setting is valid.
  1240. * @param __DMA__: UART DMA enabling or disabling on error setting.
  1241. * @retval SET (__DMA__ is valid) or RESET (__DMA__ is invalid)
  1242. */
  1243. #define IS_UART_ADVFEATURE_DMAONRXERROR(__DMA__) (((__DMA__) == UART_ADVFEATURE_DMA_ENABLEONRXERROR) || \
  1244. ((__DMA__) == UART_ADVFEATURE_DMA_DISABLEONRXERROR))
  1245. /**
  1246. * @brief Ensure that UART frame MSB first setting is valid.
  1247. * @param __MSBFIRST__: UART frame MSB first setting.
  1248. * @retval SET (__MSBFIRST__ is valid) or RESET (__MSBFIRST__ is invalid)
  1249. */
  1250. #define IS_UART_ADVFEATURE_MSBFIRST(__MSBFIRST__) (((__MSBFIRST__) == UART_ADVFEATURE_MSBFIRST_DISABLE) || \
  1251. ((__MSBFIRST__) == UART_ADVFEATURE_MSBFIRST_ENABLE))
  1252. /**
  1253. * @brief Ensure that UART stop mode state is valid.
  1254. * @param __STOPMODE__: UART stop mode state.
  1255. * @retval SET (__STOPMODE__ is valid) or RESET (__STOPMODE__ is invalid)
  1256. */
  1257. #define IS_UART_ADVFEATURE_STOPMODE(__STOPMODE__) (((__STOPMODE__) == UART_ADVFEATURE_STOPMODE_DISABLE) || \
  1258. ((__STOPMODE__) == UART_ADVFEATURE_STOPMODE_ENABLE))
  1259. /**
  1260. * @brief Ensure that UART mute mode state is valid.
  1261. * @param __MUTE__: UART mute mode state.
  1262. * @retval SET (__MUTE__ is valid) or RESET (__MUTE__ is invalid)
  1263. */
  1264. #define IS_UART_MUTE_MODE(__MUTE__) (((__MUTE__) == UART_ADVFEATURE_MUTEMODE_DISABLE) || \
  1265. ((__MUTE__) == UART_ADVFEATURE_MUTEMODE_ENABLE))
  1266. /**
  1267. * @brief Ensure that UART wake-up selection is valid.
  1268. * @param __WAKE__: UART wake-up selection.
  1269. * @retval SET (__WAKE__ is valid) or RESET (__WAKE__ is invalid)
  1270. */
  1271. #define IS_UART_WAKEUP_SELECTION(__WAKE__) (((__WAKE__) == UART_WAKEUP_ON_ADDRESS ) || \
  1272. ((__WAKE__) == UART_WAKEUP_ON_STARTBIT ) || \
  1273. ((__WAKE__) == UART_WAKEUP_ON_READDATA_NONEMPTY ) || \
  1274. ((__WAKE__) == UART_WAKEUP_ON_RXFIFO_THRESHOLD ) || \
  1275. ((__WAKE__) == UART_WAKEUP_ON_RXFIFO_FULL ) || \
  1276. ((__WAKE__) == UART_WAKEUP_ON_TXFIFO_THRESHOLD ) || \
  1277. ((__WAKE__) == UART_WAKEUP_ON_TXFIFO_EMPTY ))
  1278. /**
  1279. * @brief Ensure that UART driver enable polarity is valid.
  1280. * @param __POLARITY__: UART driver enable polarity.
  1281. * @retval SET (__POLARITY__ is valid) or RESET (__POLARITY__ is invalid)
  1282. */
  1283. #define IS_UART_DE_POLARITY(__POLARITY__) (((__POLARITY__) == UART_DE_POLARITY_HIGH) || \
  1284. ((__POLARITY__) == UART_DE_POLARITY_LOW))
  1285. /**
  1286. * @brief Ensure that LPUART frame number of stop bits is valid.
  1287. * @param __STOPBITS__: LPUART frame number of stop bits.
  1288. * @retval SET (__STOPBITS__ is valid) or RESET (__STOPBITS__ is invalid)
  1289. */
  1290. #define IS_LPUART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_1) || \
  1291. ((__STOPBITS__) == UART_STOPBITS_2))
  1292. /**
  1293. * @brief Ensure that UART Prescaler is valid.
  1294. * @param __PRESCALER__: UART Prescaler value.
  1295. * @retval SET (__PRESCALER__ is valid) or RESET (__PRESCALER__ is invalid)
  1296. */
  1297. #define IS_UART_PRESCALER(__PRESCALER__) (((__PRESCALER__) == UART_PRESCALER_DIV1) || \
  1298. ((__PRESCALER__) == UART_PRESCALER_DIV2) || \
  1299. ((__PRESCALER__) == UART_PRESCALER_DIV4) || \
  1300. ((__PRESCALER__) == UART_PRESCALER_DIV6) || \
  1301. ((__PRESCALER__) == UART_PRESCALER_DIV8) || \
  1302. ((__PRESCALER__) == UART_PRESCALER_DIV10) || \
  1303. ((__PRESCALER__) == UART_PRESCALER_DIV12) || \
  1304. ((__PRESCALER__) == UART_PRESCALER_DIV16) || \
  1305. ((__PRESCALER__) == UART_PRESCALER_DIV32) || \
  1306. ((__PRESCALER__) == UART_PRESCALER_DIV64) || \
  1307. ((__PRESCALER__) == UART_PRESCALER_DIV128) || \
  1308. ((__PRESCALER__) == UART_PRESCALER_DIV256))
  1309. /**
  1310. * @brief Ensure that UART FIFO mode is valid.
  1311. * @param __STATE__: UART FIFO mode.
  1312. * @retval SET (__STATE__ is valid) or RESET (__STATE__ is invalid)
  1313. */
  1314. #define IS_UART_FIFO_MODE_STATE(__STATE__) (((__STATE__) == UART_FIFOMODE_DISABLE ) || \
  1315. ((__STATE__) == UART_FIFOMODE_ENABLE))
  1316. /**
  1317. * @brief Ensure that UART TXFIFO threshold level is valid.
  1318. * @param __THRESHOLD__: UART TXFIFO threshold level.
  1319. * @retval SET (__THRESHOLD__ is valid) or RESET (__THRESHOLD__ is invalid)
  1320. */
  1321. #define IS_UART_TXFIFO_THRESHOLD(__THRESHOLD__) ((((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_1_8 ) || \
  1322. ((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_1_4 ) || \
  1323. ((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_1_2) || \
  1324. ((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_3_4) || \
  1325. ((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_7_8)) || \
  1326. ((__THRESHOLD__) == UART_TXFIFO_THRESHOLD_8_8))
  1327. /**
  1328. * @brief Ensure that UART RXFIFO threshold level is valid.
  1329. * @param __THRESHOLD__: UART RXFIFO threshold level.
  1330. * @retval SET (__THRESHOLD__ is valid) or RESET (__THRESHOLD__ is invalid)
  1331. */
  1332. #define IS_UART_RXFIFO_THRESHOLD(__THRESHOLD__) ((((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_1_8 ) || \
  1333. ((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_1_4 ) || \
  1334. ((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_1_2) || \
  1335. ((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_3_4) || \
  1336. ((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_7_8)) || \
  1337. ((__THRESHOLD__) == UART_RXFIFO_THRESHOLD_8_8))
  1338. /**
  1339. * @}
  1340. */
  1341. /* Include UART HAL Extended module */
  1342. #include "stm32h7xx_hal_uart_ex.h"
  1343. /* Exported functions --------------------------------------------------------*/
  1344. /** @addtogroup UART_Exported_Functions UART Exported Functions
  1345. * @{
  1346. */
  1347. /** @addtogroup UART_Exported_Functions_Group1 Initialization and de-initialization functions
  1348. * @{
  1349. */
  1350. /* Initialization and de-initialization functions ****************************/
  1351. HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
  1352. HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);
  1353. HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength);
  1354. HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod);
  1355. HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart);
  1356. void HAL_UART_MspInit(UART_HandleTypeDef *huart);
  1357. void HAL_UART_MspDeInit(UART_HandleTypeDef *huart);
  1358. /**
  1359. * @}
  1360. */
  1361. /** @addtogroup UART_Exported_Functions_Group2 IO operation functions
  1362. * @{
  1363. */
  1364. /* IO operation functions *****************************************************/
  1365. HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  1366. HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  1367. HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
  1368. HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
  1369. HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
  1370. HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
  1371. HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
  1372. HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
  1373. HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
  1374. /* Transfer Abort functions */
  1375. HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart);
  1376. HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart);
  1377. HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart);
  1378. HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart);
  1379. HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart);
  1380. HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart);
  1381. void HAL_UART_IRQHandler(UART_HandleTypeDef *huart);
  1382. void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart);
  1383. void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
  1384. void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart);
  1385. void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
  1386. void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
  1387. void HAL_UART_AbortCpltCallback (UART_HandleTypeDef *huart);
  1388. void HAL_UART_AbortTransmitCpltCallback (UART_HandleTypeDef *huart);
  1389. void HAL_UART_AbortReceiveCpltCallback (UART_HandleTypeDef *huart);
  1390. /**
  1391. * @}
  1392. */
  1393. /** @addtogroup UART_Exported_Functions_Group3 Peripheral Control functions
  1394. * @{
  1395. */
  1396. /* Peripheral Control functions ************************************************/
  1397. HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart);
  1398. HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart);
  1399. HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart);
  1400. void HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
  1401. HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart);
  1402. HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart);
  1403. /**
  1404. * @}
  1405. */
  1406. /** @addtogroup UART_Exported_Functions_Group4 Peripheral State and Error functions
  1407. * @{
  1408. */
  1409. /* Peripheral State and Errors functions **************************************************/
  1410. HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart);
  1411. uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart);
  1412. /**
  1413. * @}
  1414. */
  1415. /**
  1416. * @}
  1417. */
  1418. /* Private functions -----------------------------------------------------------*/
  1419. /** @addtogroup UART_Private_Functions UART Private Functions
  1420. * @{
  1421. */
  1422. HAL_StatusTypeDef UART_SetConfig(UART_HandleTypeDef *huart);
  1423. HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart);
  1424. HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout);
  1425. void UART_AdvFeatureConfig(UART_HandleTypeDef *huart);
  1426. /**
  1427. * @}
  1428. */
  1429. /**
  1430. * @}
  1431. */
  1432. /**
  1433. * @}
  1434. */
  1435. #ifdef __cplusplus
  1436. }
  1437. #endif
  1438. #endif /* __STM32H7xx_HAL_UART_H */
  1439. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/