stm32l0xx_hal_uart.h 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277
  1. /**
  2. ******************************************************************************
  3. * @file stm32l0xx_hal_uart.h
  4. * @author MCD Application Team
  5. * @version V1.7.0
  6. * @date 31-May-2016
  7. * @brief Header file of UART HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2016 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 __STM32L0xx_HAL_UART_H
  39. #define __STM32L0xx_HAL_UART_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32l0xx_hal_def.h"
  45. /** @addtogroup STM32L0xx_HAL_Driver
  46. * @{
  47. */
  48. /** @defgroup UART UART
  49. * @{
  50. */
  51. /******************************************************************************/
  52. /* Exported types ------------------------------------------------------------*/
  53. /******************************************************************************/
  54. /** @defgroup UART_Exported_Types UART Exported Types
  55. * @{
  56. */
  57. /** @defgroup UART_Init_Configuration UART initialization configuration structure
  58. * @{
  59. */
  60. /**
  61. * @brief UART Init Structure definition
  62. */
  63. typedef struct
  64. {
  65. uint32_t BaudRate; /*!< This member configures the UART communication baud rate.
  66. The baud rate register is computed using the following formula:
  67. - If oversampling is 16 or in LIN mode,
  68. Baud Rate Register = ((PCLKx) / ((huart->Init.BaudRate)))
  69. - If oversampling is 8,
  70. Baud Rate Register[15:4] = ((2 * PCLKx) / ((huart->Init.BaudRate)))[15:4]
  71. Baud Rate Register[3] = 0
  72. Baud Rate Register[2:0] = (((2 * PCLKx) / ((huart->Init.BaudRate)))[3:0]) >> 1 */
  73. uint32_t WordLength; /*!< Specifies the number of data bits transmitted or received in a frame.
  74. This parameter can be a value of @ref UARTEx_Word_Length */
  75. uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
  76. This parameter can be a value of @ref UART_Stop_Bits */
  77. uint32_t Parity; /*!< Specifies the parity mode.
  78. This parameter can be a value of @ref UART_Parity
  79. @note When parity is enabled, the computed parity is inserted
  80. at the MSB position of the transmitted data (9th bit when
  81. the word length is set to 9 data bits; 8th bit when the
  82. word length is set to 8 data bits). */
  83. uint32_t Mode; /*!< Specifies wether the Receive or Transmit mode is enabled or disabled.
  84. This parameter can be a value of @ref UART_Mode */
  85. uint32_t HwFlowCtl; /*!< Specifies wether the hardware flow control mode is enabled
  86. or disabled.
  87. This parameter can be a value of @ref UART_Hardware_Flow_Control */
  88. uint32_t OverSampling; /*!< Specifies wether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to fPCLK/8).
  89. This parameter can be a value of @ref UART_Over_Sampling */
  90. uint32_t OneBitSampling; /*!< Specifies wether a single sample or three samples' majority vote is selected.
  91. Selecting the single sample method increases the receiver tolerance to clock
  92. deviations. This parameter can be a value of @ref UART_One_Bit */
  93. }UART_InitTypeDef;
  94. /**
  95. * @}
  96. */
  97. /** @defgroup UART_Advanced_Feature UART advanced feature structure
  98. * @{
  99. */
  100. /**
  101. * @brief UART Advanced Features initalization structure definition
  102. */
  103. typedef struct
  104. {
  105. uint32_t AdvFeatureInit; /*!< Specifies which advanced UART features is initialized. Several
  106. Advanced Features may be initialized at the same time .
  107. This parameter can be a value of @ref UART_Advanced_Features_Initialization_Type */
  108. uint32_t TxPinLevelInvert; /*!< Specifies whether the TX pin active level is inverted.
  109. This parameter can be a value of @ref UART_Tx_Inv */
  110. uint32_t RxPinLevelInvert; /*!< Specifies whether the RX pin active level is inverted.
  111. This parameter can be a value of @ref UART_Rx_Inv */
  112. uint32_t DataInvert; /*!< Specifies whether data are inverted (positive/direct logic
  113. vs negative/inverted logic).
  114. This parameter can be a value of @ref UART_Data_Inv */
  115. uint32_t Swap; /*!< Specifies whether TX and RX pins are swapped.
  116. This parameter can be a value of @ref UART_Rx_Tx_Swap */
  117. uint32_t OverrunDisable; /*!< Specifies whether the reception overrun detection is disabled.
  118. This parameter can be a value of @ref UART_Overrun_Disable */
  119. uint32_t DMADisableonRxError; /*!< Specifies whether the DMA is disabled in case of reception error.
  120. This parameter can be a value of @ref UART_DMA_Disable_on_Rx_Error */
  121. uint32_t AutoBaudRateEnable; /*!< Specifies whether auto Baud rate detection is enabled.
  122. This parameter can be a value of @ref UART_AutoBaudRate_Enable */
  123. uint32_t AutoBaudRateMode; /*!< If auto Baud rate detection is enabled, specifies how the rate
  124. detection is carried out.
  125. This parameter can be a value of @ref UARTEx_AutoBaud_Rate_Mode */
  126. uint32_t MSBFirst; /*!< Specifies whether MSB is sent first on UART line.
  127. This parameter can be a value of @ref UART_MSB_First */
  128. } UART_AdvFeatureInitTypeDef;
  129. /**
  130. * @}
  131. */
  132. /** @defgroup UART_State_Definition UART state definition
  133. * @{
  134. */
  135. /**
  136. * @brief HAL UART State structures definition
  137. * @note HAL UART State value is a combination of 2 different substates: gState and RxState.
  138. * - gState contains UART state information related to global Handle management
  139. * and also information related to Tx operations.
  140. * gState value coding follow below described bitmap :
  141. * b7-b6 Error information
  142. * 00 : No Error
  143. * 01 : (Not Used)
  144. * 10 : Timeout
  145. * 11 : Error
  146. * b5 IP initilisation status
  147. * 0 : Reset (IP not initialized)
  148. * 1 : Init done (IP not initialized. HAL UART Init function already called)
  149. * b4-b3 (not used)
  150. * xx : Should be set to 00
  151. * b2 Intrinsic process state
  152. * 0 : Ready
  153. * 1 : Busy (IP busy with some configuration or internal operations)
  154. * b1 (not used)
  155. * x : Should be set to 0
  156. * b0 Tx state
  157. * 0 : Ready (no Tx operation ongoing)
  158. * 1 : Busy (Tx operation ongoing)
  159. * - RxState contains information related to Rx operations.
  160. * RxState value coding follow below described bitmap :
  161. * b7-b6 (not used)
  162. * xx : Should be set to 00
  163. * b5 IP initilisation status
  164. * 0 : Reset (IP not initialized)
  165. * 1 : Init done (IP not initialized)
  166. * b4-b2 (not used)
  167. * xxx : Should be set to 000
  168. * b1 Rx state
  169. * 0 : Ready (no Rx operation ongoing)
  170. * 1 : Busy (Rx operation ongoing)
  171. * b0 (not used)
  172. * x : Should be set to 0.
  173. */
  174. typedef enum
  175. {
  176. HAL_UART_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized
  177. Value is allowed for gState and RxState */
  178. HAL_UART_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use
  179. Value is allowed for gState and RxState */
  180. HAL_UART_STATE_BUSY = 0x24U, /*!< an internal process is ongoing
  181. Value is allowed for gState only */
  182. HAL_UART_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing
  183. Value is allowed for gState only */
  184. HAL_UART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing
  185. Value is allowed for RxState only */
  186. HAL_UART_STATE_BUSY_TX_RX = 0x23U, /*!< Data Transmission and Reception process is ongoing
  187. Not to be used for neither gState nor RxState.
  188. Value is result of combination (Or) between gState and RxState values */
  189. HAL_UART_STATE_TIMEOUT = 0xA0U, /*!< Timeout state
  190. Value is allowed for gState only */
  191. HAL_UART_STATE_ERROR = 0xE0U /*!< Error
  192. Value is allowed for gState only */
  193. }HAL_UART_StateTypeDef;
  194. /**
  195. * @}
  196. */
  197. /** @defgroup UART_Error_Definition UART error definition
  198. * @{
  199. */
  200. /**
  201. * @brief HAL UART Error Code definition
  202. */
  203. #define HAL_UART_ERROR_NONE ((uint32_t)0x00U) /*!< No error */
  204. #define HAL_UART_ERROR_PE ((uint32_t)0x01U) /*!< Parity error */
  205. #define HAL_UART_ERROR_NE ((uint32_t)0x02U) /*!< Noise error */
  206. #define HAL_UART_ERROR_FE ((uint32_t)0x04U) /*!< frame error */
  207. #define HAL_UART_ERROR_ORE ((uint32_t)0x08U) /*!< Overrun error */
  208. #define HAL_UART_ERROR_DMA ((uint32_t)0x10U) /*!< DMA transfer error */
  209. /**
  210. * @}
  211. */
  212. /** @defgroup UART_Clock_SourceDefinition UART clock source definition
  213. * @{
  214. */
  215. /**
  216. * @brief UART clock sources definition
  217. */
  218. typedef enum
  219. {
  220. UART_CLOCKSOURCE_PCLK1 = 0x00U, /*!< PCLK1 clock source */
  221. UART_CLOCKSOURCE_PCLK2 = 0x01U, /*!< PCLK2 clock source */
  222. UART_CLOCKSOURCE_HSI = 0x02U, /*!< HSI clock source */
  223. UART_CLOCKSOURCE_SYSCLK = 0x04U, /*!< SYSCLK clock source */
  224. UART_CLOCKSOURCE_LSE = 0x08U /*!< LSE clock source */
  225. }UART_ClockSourceTypeDef;
  226. /**
  227. * @}
  228. */
  229. /** @defgroup UART_handle_Definition Handle structure definition
  230. * @{
  231. */
  232. /**
  233. * @brief UART handle Structure definition
  234. */
  235. typedef struct
  236. {
  237. USART_TypeDef *Instance; /*!< UART registers base address */
  238. UART_InitTypeDef Init; /*!< UART communication parameters */
  239. UART_AdvFeatureInitTypeDef AdvancedInit; /*!< UART Advanced Features initialization parameters */
  240. uint8_t *pTxBuffPtr; /*!< Pointer to UART Tx transfer Buffer */
  241. uint16_t TxXferSize; /*!< UART Tx Transfer size */
  242. uint16_t TxXferCount; /*!< UART Tx Transfer Counter */
  243. uint8_t *pRxBuffPtr; /*!< Pointer to UART Rx transfer Buffer */
  244. uint16_t RxXferSize; /*!< UART Rx Transfer size */
  245. uint16_t RxXferCount; /*!< UART Rx Transfer Counter */
  246. uint16_t Mask; /*!< UART Rx RDR register mask */
  247. DMA_HandleTypeDef *hdmatx; /*!< UART Tx DMA Handle parameters */
  248. DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */
  249. HAL_LockTypeDef Lock; /*!< Locking object */
  250. __IO HAL_UART_StateTypeDef gState; /*!< UART state information related to global Handle management
  251. and also related to Tx operations.
  252. This parameter can be a value of @ref HAL_UART_StateTypeDef */
  253. __IO HAL_UART_StateTypeDef RxState; /*!< UART state information related to Rx operations.
  254. This parameter can be a value of @ref HAL_UART_StateTypeDef */
  255. __IO uint32_t ErrorCode; /*!< UART Error code */
  256. }UART_HandleTypeDef;
  257. /**
  258. * @}
  259. */
  260. /**
  261. * @}
  262. */
  263. /* Exported constants --------------------------------------------------------*/
  264. /** @defgroup UART_Exported_Constants UART Exported Constants
  265. * @{
  266. */
  267. /** @defgroup UART_Stop_Bits UART stop bit definition
  268. * @{
  269. */
  270. #define UART_STOPBITS_1 ((uint32_t)0x0000U) /*!< USART frame with 1 stop bit */
  271. #define UART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< USART frame with 1.5 stop bits */
  272. #define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) /*!< USART frame with 2 stop bits */
  273. #define IS_UART_STOPBITS(STOPBITS) (((STOPBITS) == UART_STOPBITS_1) || \
  274. ((STOPBITS) == UART_STOPBITS_1_5) || \
  275. ((STOPBITS) == UART_STOPBITS_2))
  276. #define IS_LPUART_STOPBITS(__STOPBITS__) (((__STOPBITS__) == UART_STOPBITS_1) || \
  277. ((__STOPBITS__) == UART_STOPBITS_2))
  278. /**
  279. * @}
  280. */
  281. /** @defgroup UART_Parity UART parity definition
  282. * @{
  283. */
  284. #define UART_PARITY_NONE ((uint32_t)0x0000U)
  285. #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE)
  286. #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS))
  287. #define IS_UART_PARITY(PARITY) (((PARITY) == UART_PARITY_NONE) || \
  288. ((PARITY) == UART_PARITY_EVEN) || \
  289. ((PARITY) == UART_PARITY_ODD))
  290. /**
  291. * @}
  292. */
  293. /** @defgroup UART_Hardware_Flow_Control UART hardware flow control definition
  294. * @{
  295. */
  296. #define UART_HWCONTROL_NONE ((uint32_t)0x0000U)
  297. #define UART_HWCONTROL_RTS ((uint32_t)USART_CR3_RTSE)
  298. #define UART_HWCONTROL_CTS ((uint32_t)USART_CR3_CTSE)
  299. #define UART_HWCONTROL_RTS_CTS ((uint32_t)(USART_CR3_RTSE | USART_CR3_CTSE))
  300. #define IS_UART_HARDWARE_FLOW_CONTROL(CONTROL)\
  301. (((CONTROL) == UART_HWCONTROL_NONE) || \
  302. ((CONTROL) == UART_HWCONTROL_RTS) || \
  303. ((CONTROL) == UART_HWCONTROL_CTS) || \
  304. ((CONTROL) == UART_HWCONTROL_RTS_CTS))
  305. /**
  306. * @}
  307. */
  308. /** @defgroup UART_Mode UART mode definition
  309. * @{
  310. */
  311. #define UART_MODE_RX ((uint32_t)USART_CR1_RE)
  312. #define UART_MODE_TX ((uint32_t)USART_CR1_TE)
  313. #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE))
  314. #define IS_UART_MODE(MODE) ((((MODE) & (~((uint32_t)(UART_MODE_TX_RX)))) == (uint32_t)0x00U) && ((MODE) != (uint32_t)0x00U))
  315. /**
  316. * @}
  317. */
  318. /** @defgroup UART_State UART state enable and disable definition
  319. * @{
  320. */
  321. #define UART_STATE_DISABLE ((uint32_t)0x0000U)
  322. #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE)
  323. #define IS_UART_STATE(STATE) (((STATE) == UART_STATE_DISABLE) || \
  324. ((STATE) == UART_STATE_ENABLE))
  325. /**
  326. * @}
  327. */
  328. /** @defgroup UART_Over_Sampling UART over sampling definition
  329. * @{
  330. */
  331. #define UART_OVERSAMPLING_16 ((uint32_t)0x0000U)
  332. #define UART_OVERSAMPLING_8 ((uint32_t)USART_CR1_OVER8)
  333. #define IS_UART_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16) || \
  334. ((SAMPLING) == UART_OVERSAMPLING_8))
  335. /**
  336. * @}
  337. */
  338. /** @defgroup UART_Receiver_TimeOut UART receiver timeOut definition
  339. * @{
  340. */
  341. #define UART_RECEIVER_TIMEOUT_DISABLE ((uint32_t)0x00000000U)
  342. #define UART_RECEIVER_TIMEOUT_ENABLE ((uint32_t)USART_CR2_RTOEN)
  343. #define IS_UART_RECEIVER_TIMEOUT(TIMEOUT) (((TIMEOUT) == UART_RECEIVER_TIMEOUT_DISABLE) || \
  344. ((TIMEOUT) == UART_RECEIVER_TIMEOUT_ENABLE))
  345. /**
  346. * @}
  347. */
  348. /** @defgroup UART_LIN UART LIN enable and disable definition
  349. * @{
  350. */
  351. #define UART_LIN_DISABLE ((uint32_t)0x00000000U)
  352. #define UART_LIN_ENABLE ((uint32_t)USART_CR2_LINEN)
  353. #define IS_UART_LIN(LIN) (((LIN) == UART_LIN_DISABLE) || \
  354. ((LIN) == UART_LIN_ENABLE))
  355. /**
  356. * @}
  357. */
  358. /** @defgroup UART_LIN_Break_Detection UART LIN break detection definition
  359. * @{
  360. */
  361. #define UART_LINBREAKDETECTLENGTH_10B ((uint32_t)0x00000000U)
  362. #define UART_LINBREAKDETECTLENGTH_11B ((uint32_t)USART_CR2_LBDL)
  363. #define IS_UART_LIN_BREAK_DETECT_LENGTH(LENGTH) (((LENGTH) == UART_LINBREAKDETECTLENGTH_10B) || \
  364. ((LENGTH) == UART_LINBREAKDETECTLENGTH_11B))
  365. /**
  366. * @}
  367. */
  368. /** @defgroup UART_One_Bit UART one bit definition
  369. * @{
  370. */
  371. #define UART_ONE_BIT_SAMPLE_DISABLE ((uint32_t)0x00000000U)
  372. #define UART_ONE_BIT_SAMPLE_ENABLE ((uint32_t)USART_CR3_ONEBIT)
  373. #define IS_UART_ONE_BIT_SAMPLE(ONEBIT) (((ONEBIT) == UART_ONE_BIT_SAMPLE_DISABLE) || \
  374. ((ONEBIT) == UART_ONE_BIT_SAMPLE_ENABLE))
  375. /**
  376. * @}
  377. */
  378. /** @defgroup UART_DMA_Tx UART DMA Tx definition
  379. * @{
  380. */
  381. #define UART_DMA_TX_DISABLE ((uint32_t)0x00000000U)
  382. #define UART_DMA_TX_ENABLE ((uint32_t)USART_CR3_DMAT)
  383. #define IS_UART_DMA_TX(DMATX) (((DMATX) == UART_DMA_TX_DISABLE) || \
  384. ((DMATX) == UART_DMA_TX_ENABLE))
  385. /**
  386. * @}
  387. */
  388. /** @defgroup UART_DMA_Rx UART DMA Rx definition
  389. * @{
  390. */
  391. #define UART_DMA_RX_DISABLE ((uint32_t)0x0000U)
  392. #define UART_DMA_RX_ENABLE ((uint32_t)USART_CR3_DMAR)
  393. #define IS_UART_DMA_RX(DMARX) (((DMARX) == UART_DMA_RX_DISABLE) || \
  394. ((DMARX) == UART_DMA_RX_ENABLE))
  395. /**
  396. * @}
  397. */
  398. /** @defgroup UART_Half_Duplex_Selection UART half duplex selection definition
  399. * @{
  400. */
  401. #define UART_HALF_DUPLEX_DISABLE ((uint32_t)0x0000U)
  402. #define UART_HALF_DUPLEX_ENABLE ((uint32_t)USART_CR3_HDSEL)
  403. #define IS_UART_HALF_DUPLEX(HDSEL) (((HDSEL) == UART_HALF_DUPLEX_DISABLE) || \
  404. ((HDSEL) == UART_HALF_DUPLEX_ENABLE))
  405. /**
  406. * @}
  407. */
  408. /** @defgroup UART_Flags UART flags definition
  409. * Elements values convention: 0xXXXX
  410. * - 0xXXXX : Flag mask in the ISR register
  411. * @{
  412. */
  413. #define UART_FLAG_REACK USART_ISR_REACK /*!< Receive Enable Acknowledge Flag */
  414. #define UART_FLAG_TEACK USART_ISR_TEACK /*!< Transmit Enable Acknowledge Flag */
  415. #define UART_FLAG_WUF USART_ISR_WUF /*!< Wake Up from stop mode Flag */
  416. #define UART_FLAG_RWU USART_ISR_RWU /*!< Receive Wake Up from mute mode Flag */
  417. #define UART_FLAG_SBKF USART_ISR_SBKF /*!< Send Break Flag */
  418. #define UART_FLAG_CMF USART_ISR_CMF /*!< Character Match Flag */
  419. #define UART_FLAG_BUSY USART_ISR_BUSY /*!< Busy Flag */
  420. #define UART_FLAG_ABRF USART_ISR_ABRF /*!< Auto-Baud Rate Flag */
  421. #define UART_FLAG_ABRE USART_ISR_ABRE /*!< Auto-Baud Rate Error */
  422. #define UART_FLAG_EOBF USART_ISR_EOBF /*!< End Of Block Flag */
  423. #define UART_FLAG_RTOF USART_ISR_RTOF /*!< Receiver Time Out */
  424. #define UART_FLAG_CTS USART_ISR_CTS /*!< CTS flag */
  425. #define UART_FLAG_CTSIF USART_ISR_CTSIF /*!< CTS interrupt flag */
  426. #define UART_FLAG_LBDF USART_ISR_LBDF /*!< LIN Break Detection Flag */
  427. #define UART_FLAG_TXE USART_ISR_TXE /*!< Transmit Data Register Empty */
  428. #define UART_FLAG_TC USART_ISR_TC /*!< Transmission Complete */
  429. #define UART_FLAG_RXNE USART_ISR_RXNE /*!< Read Data Register Not Empty */
  430. #define UART_FLAG_IDLE USART_ISR_IDLE /*!< IDLE line detected */
  431. #define UART_FLAG_ORE USART_ISR_ORE /*!< OverRun Error */
  432. #define UART_FLAG_NE USART_ISR_NE /*!< Noise detected Flag */
  433. #define UART_FLAG_FE USART_ISR_FE /*!< Framing Error */
  434. #define UART_FLAG_PE USART_ISR_PE /*!< Parity Error */
  435. /**
  436. * @}
  437. */
  438. /** @defgroup UART_Interrupt_definition UART interrupt definition
  439. * Elements values convention: 000ZZZZZ0XXYYYYYb
  440. * - YYYYY : Interrupt source position in the XX register (5bits)
  441. * - XX : Interrupt source register (2bits)
  442. * - 01: CR1 register
  443. * - 10: CR2 register
  444. * - 11: CR3 register
  445. * - ZZZZZ : Flag position in the ISR register(5bits)
  446. * @{
  447. */
  448. #define UART_IT_PE ((uint32_t)0x0028U)
  449. #define UART_IT_TXE ((uint32_t)0x0727U)
  450. #define UART_IT_TC ((uint32_t)0x0626U)
  451. #define UART_IT_RXNE ((uint32_t)0x0525U)
  452. #define UART_IT_IDLE ((uint32_t)0x0424U)
  453. #define UART_IT_LBD ((uint32_t)0x0846U)
  454. #define UART_IT_CTS ((uint32_t)0x096AU)
  455. #define UART_IT_CM ((uint32_t)0x112EU)
  456. #define UART_IT_WUF ((uint32_t)0x1476U)
  457. /** Elements values convention: 000000000XXYYYYYb
  458. * - YYYYY : Interrupt source position in the XX register (5bits)
  459. * - XX : Interrupt source register (2bits)
  460. * - 01: CR1 register
  461. * - 10: CR2 register
  462. * - 11: CR3 register
  463. */
  464. #define UART_IT_ERR ((uint32_t)0x0060U)
  465. /** Elements values convention: 0000ZZZZ00000000b
  466. * - ZZZZ : Flag position in the ISR register(4bits)
  467. */
  468. #define UART_IT_ORE ((uint32_t)0x0300U)
  469. #define UART_IT_NE ((uint32_t)0x0200U)
  470. #define UART_IT_FE ((uint32_t)0x0100U)
  471. /**
  472. * @}
  473. */
  474. /** @defgroup UART_IT_CLEAR_Flags UART interrupt clear flags definition
  475. * @{
  476. */
  477. #define UART_CLEAR_PEF USART_ICR_PECF /*!< Parity Error Clear Flag */
  478. #define UART_CLEAR_FEF USART_ICR_FECF /*!< Framing Error Clear Flag */
  479. #define UART_CLEAR_NEF USART_ICR_NCF /*!< Noise detected Clear Flag */
  480. #define UART_CLEAR_OREF USART_ICR_ORECF /*!< OverRun Error Clear Flag */
  481. #define UART_CLEAR_IDLEF USART_ICR_IDLECF /*!< IDLE line detected Clear Flag */
  482. #define UART_CLEAR_TCF USART_ICR_TCCF /*!< Transmission Complete Clear Flag */
  483. #define UART_CLEAR_LBDF USART_ICR_LBDCF /*!< LIN Break Detection Clear Flag */
  484. #define UART_CLEAR_CTSF USART_ICR_CTSCF /*!< CTS Interrupt Clear Flag */
  485. #define UART_CLEAR_RTOF USART_ICR_RTOCF /*!< Receiver Time Out Clear Flag */
  486. #define UART_CLEAR_EOBF USART_ICR_EOBCF /*!< End Of Block Clear Flag */
  487. #define UART_CLEAR_CMF USART_ICR_CMCF /*!< Character Match Clear Flag */
  488. #define UART_CLEAR_WUF USART_ICR_WUCF /*!< Wake Up from stop mode Clear Flag */
  489. /**
  490. * @}
  491. */
  492. /** @defgroup UART_Request_Parameters UART request parameter definition
  493. * @{
  494. */
  495. #define UART_AUTOBAUD_REQUEST ((uint32_t)USART_RQR_ABRRQ) /*!< Auto-Baud Rate Request */
  496. #define UART_SENDBREAK_REQUEST ((uint32_t)USART_RQR_SBKRQ) /*!< Send Break Request */
  497. #define UART_MUTE_MODE_REQUEST ((uint32_t)USART_RQR_MMRQ) /*!< Mute Mode Request */
  498. #define UART_RXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_RXFRQ) /*!< Receive Data flush Request */
  499. #define UART_TXDATA_FLUSH_REQUEST ((uint32_t)USART_RQR_TXFRQ) /*!< Transmit data flush Request */
  500. #define IS_UART_REQUEST_PARAMETER(PARAM) (((PARAM) == UART_AUTOBAUD_REQUEST) || \
  501. ((PARAM) == UART_SENDBREAK_REQUEST) || \
  502. ((PARAM) == UART_MUTE_MODE_REQUEST) || \
  503. ((PARAM) == UART_RXDATA_FLUSH_REQUEST) || \
  504. ((PARAM) == UART_TXDATA_FLUSH_REQUEST))
  505. /**
  506. * @}
  507. */
  508. /** @defgroup UART_Advanced_Features_Initialization_Type UART advanced features initialization type definition
  509. * @{
  510. */
  511. #define UART_ADVFEATURE_NO_INIT ((uint32_t)0x00000000U)
  512. #define UART_ADVFEATURE_TXINVERT_INIT ((uint32_t)0x00000001U)
  513. #define UART_ADVFEATURE_RXINVERT_INIT ((uint32_t)0x00000002U)
  514. #define UART_ADVFEATURE_DATAINVERT_INIT ((uint32_t)0x00000004U)
  515. #define UART_ADVFEATURE_SWAP_INIT ((uint32_t)0x00000008U)
  516. #define UART_ADVFEATURE_RXOVERRUNDISABLE_INIT ((uint32_t)0x00000010U)
  517. #define UART_ADVFEATURE_DMADISABLEONERROR_INIT ((uint32_t)0x00000020U)
  518. #define UART_ADVFEATURE_AUTOBAUDRATE_INIT ((uint32_t)0x00000040U)
  519. #define UART_ADVFEATURE_MSBFIRST_INIT ((uint32_t)0x00000080U)
  520. #define IS_UART_ADVFEATURE_INIT(INIT) ((INIT) <= (UART_ADVFEATURE_NO_INIT | \
  521. UART_ADVFEATURE_TXINVERT_INIT | \
  522. UART_ADVFEATURE_RXINVERT_INIT | \
  523. UART_ADVFEATURE_DATAINVERT_INIT | \
  524. UART_ADVFEATURE_SWAP_INIT | \
  525. UART_ADVFEATURE_RXOVERRUNDISABLE_INIT | \
  526. UART_ADVFEATURE_DMADISABLEONERROR_INIT | \
  527. UART_ADVFEATURE_AUTOBAUDRATE_INIT | \
  528. UART_ADVFEATURE_MSBFIRST_INIT))
  529. /**
  530. * @}
  531. */
  532. /** @defgroup UART_Tx_Inv UART advanced Tx inv activation definition
  533. * @{
  534. */
  535. #define UART_ADVFEATURE_TXINV_DISABLE ((uint32_t)0x00000000U)
  536. #define UART_ADVFEATURE_TXINV_ENABLE ((uint32_t)USART_CR2_TXINV)
  537. #define IS_UART_ADVFEATURE_TXINV(TXINV) (((TXINV) == UART_ADVFEATURE_TXINV_DISABLE) || \
  538. ((TXINV) == UART_ADVFEATURE_TXINV_ENABLE))
  539. /**
  540. * @}
  541. */
  542. /** @defgroup UART_Rx_Inv UART advanced Rx inv activation definition
  543. * @{
  544. */
  545. #define UART_ADVFEATURE_RXINV_DISABLE ((uint32_t)0x00000000U)
  546. #define UART_ADVFEATURE_RXINV_ENABLE ((uint32_t)USART_CR2_RXINV)
  547. #define IS_UART_ADVFEATURE_RXINV(RXINV) (((RXINV) == UART_ADVFEATURE_RXINV_DISABLE) || \
  548. ((RXINV) == UART_ADVFEATURE_RXINV_ENABLE))
  549. /**
  550. * @}
  551. */
  552. /** @defgroup UART_Data_Inv UART advanced data inv activation definition
  553. * @{
  554. */
  555. #define UART_ADVFEATURE_DATAINV_DISABLE ((uint32_t)0x00000000U)
  556. #define UART_ADVFEATURE_DATAINV_ENABLE ((uint32_t)USART_CR2_DATAINV)
  557. #define IS_UART_ADVFEATURE_DATAINV(DATAINV) (((DATAINV) == UART_ADVFEATURE_DATAINV_DISABLE) || \
  558. ((DATAINV) == UART_ADVFEATURE_DATAINV_ENABLE))
  559. /**
  560. * @}
  561. */
  562. /** @defgroup UART_Rx_Tx_Swap UART advanced swap activation definition
  563. * @{
  564. */
  565. #define UART_ADVFEATURE_SWAP_DISABLE ((uint32_t)0x00000000U)
  566. #define UART_ADVFEATURE_SWAP_ENABLE ((uint32_t)USART_CR2_SWAP)
  567. #define IS_UART_ADVFEATURE_SWAP(SWAP) (((SWAP) == UART_ADVFEATURE_SWAP_DISABLE) || \
  568. ((SWAP) == UART_ADVFEATURE_SWAP_ENABLE))
  569. /**
  570. * @}
  571. */
  572. /** @defgroup UART_Overrun_Disable UART advanced overrun activation definition
  573. * @{
  574. */
  575. #define UART_ADVFEATURE_OVERRUN_ENABLE ((uint32_t)0x00000000U)
  576. #define UART_ADVFEATURE_OVERRUN_DISABLE ((uint32_t)USART_CR3_OVRDIS)
  577. #define IS_UART_OVERRUN(OVERRUN) (((OVERRUN) == UART_ADVFEATURE_OVERRUN_ENABLE) || \
  578. ((OVERRUN) == UART_ADVFEATURE_OVERRUN_DISABLE))
  579. /**
  580. * @}
  581. */
  582. /** @defgroup UART_AutoBaudRate_Enable UART advanced auto baud rate activation definition
  583. * @{
  584. */
  585. #define UART_ADVFEATURE_AUTOBAUDRATE_DISABLE ((uint32_t)0x00000000U)
  586. #define UART_ADVFEATURE_AUTOBAUDRATE_ENABLE ((uint32_t)USART_CR2_ABREN)
  587. #define IS_UART_ADVFEATURE_AUTOBAUDRATE(AUTOBAUDRATE) (((AUTOBAUDRATE) == UART_ADVFEATURE_AUTOBAUDRATE_DISABLE) || \
  588. ((AUTOBAUDRATE) == UART_ADVFEATURE_AUTOBAUDRATE_ENABLE))
  589. /**
  590. * @}
  591. */
  592. /** @defgroup UART_DMA_Disable_on_Rx_Error UART advanced DMA on Rx error activation definition
  593. * @{
  594. */
  595. #define UART_ADVFEATURE_DMA_ENABLEONRXERROR ((uint32_t)0x00000000U)
  596. #define UART_ADVFEATURE_DMA_DISABLEONRXERROR ((uint32_t)USART_CR3_DDRE)
  597. #define IS_UART_ADVFEATURE_DMAONRXERROR(DMA) (((DMA) == UART_ADVFEATURE_DMA_ENABLEONRXERROR) || \
  598. ((DMA) == UART_ADVFEATURE_DMA_DISABLEONRXERROR))
  599. /**
  600. * @}
  601. */
  602. /** @defgroup UART_MSB_First UART advanced MSB first activation definition
  603. * @{
  604. */
  605. #define UART_ADVFEATURE_MSBFIRST_DISABLE ((uint32_t)0x00000000U)
  606. #define UART_ADVFEATURE_MSBFIRST_ENABLE ((uint32_t)USART_CR2_MSBFIRST)
  607. #define IS_UART_ADVFEATURE_MSBFIRST(MSBFIRST) (((MSBFIRST) == UART_ADVFEATURE_MSBFIRST_DISABLE) || \
  608. ((MSBFIRST) == UART_ADVFEATURE_MSBFIRST_ENABLE))
  609. /**
  610. * @}
  611. */
  612. /** @defgroup UART_Stop_Mode_Enable UART advanced stop mode activation definition
  613. * @{
  614. */
  615. #define UART_ADVFEATURE_STOPMODE_DISABLE ((uint32_t)0x00000000U)
  616. #define UART_ADVFEATURE_STOPMODE_ENABLE ((uint32_t)USART_CR1_UESM)
  617. #define IS_UART_ADVFEATURE_STOPMODE(STOPMODE) (((STOPMODE) == UART_ADVFEATURE_STOPMODE_DISABLE) || \
  618. ((STOPMODE) == UART_ADVFEATURE_STOPMODE_ENABLE))
  619. /**
  620. * @}
  621. */
  622. /** @defgroup UART_Mute_Mode UART advanced mute mode activation definition
  623. * @{
  624. */
  625. #define UART_ADVFEATURE_MUTEMODE_DISABLE ((uint32_t)0x00000000U)
  626. #define UART_ADVFEATURE_MUTEMODE_ENABLE ((uint32_t)USART_CR1_MME)
  627. #define IS_UART_MUTE_MODE(MUTE) (((MUTE) == UART_ADVFEATURE_MUTEMODE_DISABLE) || \
  628. ((MUTE) == UART_ADVFEATURE_MUTEMODE_ENABLE))
  629. /**
  630. * @}
  631. */
  632. /** @defgroup UART_CR2_ADDRESS_LSBPOS UART CR2 address lsb position definition
  633. * @{
  634. */
  635. #define UART_CR2_ADDRESS_LSB_POS ((uint32_t) 24U)
  636. /**
  637. * @}
  638. */
  639. /** @defgroup UART_WakeUp_from_Stop_Selection UART wake up mode selection definition
  640. * @{
  641. */
  642. #define UART_WAKEUP_ON_ADDRESS ((uint32_t)0x0000U)
  643. #define UART_WAKEUP_ON_STARTBIT ((uint32_t)USART_CR3_WUS_1)
  644. #define UART_WAKEUP_ON_READDATA_NONEMPTY ((uint32_t)USART_CR3_WUS)
  645. #define IS_UART_WAKEUP_SELECTION(WAKE) (((WAKE) == UART_WAKEUP_ON_ADDRESS) || \
  646. ((WAKE) == UART_WAKEUP_ON_STARTBIT) || \
  647. ((WAKE) == UART_WAKEUP_ON_READDATA_NONEMPTY))
  648. /**
  649. * @}
  650. */
  651. /** @defgroup UART_DriverEnable_Polarity UART driver polarity level definition
  652. * @{
  653. */
  654. #define UART_DE_POLARITY_HIGH ((uint32_t)0x00000000U)
  655. #define UART_DE_POLARITY_LOW ((uint32_t)USART_CR3_DEP)
  656. #define IS_UART_DE_POLARITY(POLARITY) (((POLARITY) == UART_DE_POLARITY_HIGH) || \
  657. ((POLARITY) == UART_DE_POLARITY_LOW))
  658. /**
  659. * @}
  660. */
  661. /** @defgroup UART_CR1_DEAT_ADDRESS_LSBPOS UART CR1 DEAT address lsb position definition
  662. * @{
  663. */
  664. #define UART_CR1_DEAT_ADDRESS_LSB_POS ((uint32_t) 21U)
  665. /**
  666. * @}
  667. */
  668. /** @defgroup UART_CR1_DEDT_ADDRESS_LSBPOS UART CR1 DEDT address lsb position definition
  669. * @{
  670. */
  671. #define UART_CR1_DEDT_ADDRESS_LSB_POS ((uint32_t) 16U)
  672. /**
  673. * @}
  674. */
  675. /** @defgroup UART_Interruption_Mask UART interruption mask definition
  676. * @{
  677. */
  678. #define UART_IT_MASK ((uint32_t)0x001FU)
  679. /**
  680. * @}
  681. */
  682. /**
  683. * @}
  684. */
  685. /* Exported macro ------------------------------------------------------------*/
  686. /** @defgroup UART_Exported_Macros UART Exported Macros
  687. * @{
  688. */
  689. /** @brief Reset UART handle state
  690. * @param __HANDLE__: specifies the UART Handle.
  691. * The Handle Instance which can be USART1, USART2 or LPUART.
  692. * @retval None
  693. */
  694. #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_UART_STATE_RESET)
  695. /** @brief Flush the UART Data registers
  696. * @param __HANDLE__: specifies the UART Handle.
  697. */
  698. #define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) \
  699. do{ \
  700. SET_BIT((__HANDLE__)->Instance->RQR, UART_RXDATA_FLUSH_REQUEST); \
  701. SET_BIT((__HANDLE__)->Instance->RQR, UART_TXDATA_FLUSH_REQUEST); \
  702. } while(0)
  703. /** @brief Clears the specified UART pending flag.
  704. * @param __HANDLE__: specifies the UART Handle.
  705. * @param __FLAG__: specifies the flag to check.
  706. * This parameter can be any combination of the following values:
  707. * @arg UART_CLEAR_PEF
  708. * @arg UART_CLEAR_FEF
  709. * @arg UART_CLEAR_NEF
  710. * @arg UART_CLEAR_OREF
  711. * @arg UART_CLEAR_IDLEF
  712. * @arg UART_CLEAR_TCF
  713. * @arg UART_CLEAR_LBDF
  714. * @arg UART_CLEAR_CTSF
  715. * @arg UART_CLEAR_RTOF
  716. * @arg UART_CLEAR_EOBF
  717. * @arg UART_CLEAR_CMF
  718. * @arg UART_CLEAR_WUF
  719. * @retval None
  720. */
  721. #define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
  722. /** @brief Clear the UART PE pending flag.
  723. * @param __HANDLE__: specifies the UART Handle.
  724. * @retval None
  725. */
  726. #define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG(__HANDLE__,UART_CLEAR_PEF)
  727. /** @brief Clear the UART FE pending flag.
  728. * @param __HANDLE__: specifies the UART Handle.
  729. * @retval None
  730. */
  731. #define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG(__HANDLE__,UART_CLEAR_FEF)
  732. /** @brief Clear the UART NE pending flag.
  733. * @param __HANDLE__: specifies the UART Handle.
  734. * @retval None
  735. */
  736. #define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG(__HANDLE__,UART_CLEAR_NEF)
  737. /** @brief Clear the UART ORE pending flag.
  738. * @param __HANDLE__: specifies the UART Handle.
  739. * @retval None
  740. */
  741. #define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG(__HANDLE__,UART_CLEAR_OREF)
  742. /** @brief Clear the UART IDLE pending flag.
  743. * @param __HANDLE__: specifies the UART Handle.
  744. * @retval None
  745. */
  746. #define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_FLAG(__HANDLE__,UART_CLEAR_IDLEF)
  747. /** @brief Checks whether the specified UART flag is set or not.
  748. * @param __HANDLE__: specifies the UART Handle.
  749. * This parameter can be USART1, USART2 or LPUART.
  750. * @param __FLAG__: specifies the flag to check.
  751. * This parameter can be one of the following values:
  752. * @arg UART_FLAG_REACK: Receive enable ackowledge flag
  753. * @arg UART_FLAG_TEACK: Transmit enable ackowledge flag
  754. * @arg UART_FLAG_WUF: Wake up from stop mode flag
  755. * @arg UART_FLAG_RWU: Receiver wake up flag (is the UART in mute mode)
  756. * @arg UART_FLAG_SBKF: Send Break flag
  757. * @arg UART_FLAG_CMF: Character match flag
  758. * @arg UART_FLAG_BUSY: Busy flag
  759. * @arg UART_FLAG_ABRF: Auto Baud rate detection flag
  760. * @arg UART_FLAG_ABRE: Auto Baud rate detection error flag
  761. * @arg UART_FLAG_EOBF: End of block flag
  762. * @arg UART_FLAG_RTOF: Receiver timeout flag
  763. * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5)
  764. * @arg UART_FLAG_LBD: LIN Break detection flag
  765. * @arg UART_FLAG_TXE: Transmit data register empty flag
  766. * @arg UART_FLAG_TC: Transmission Complete flag
  767. * @arg UART_FLAG_RXNE: Receive data register not empty flag
  768. * @arg UART_FLAG_IDLE: Idle Line detection flag
  769. * @arg UART_FLAG_ORE: OverRun Error flag
  770. * @arg UART_FLAG_NE: Noise Error flag
  771. * @arg UART_FLAG_FE: Framing Error flag
  772. * @arg UART_FLAG_PE: Parity Error flag
  773. * @retval The new state of __FLAG__ (TRUE or FALSE).
  774. */
  775. #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR & (__FLAG__)) == (__FLAG__))
  776. /** @brief Enables the specified UART interrupt.
  777. * @param __HANDLE__: specifies the UART Handle.
  778. * This parameter can be USART1, USART2 or LPUART.
  779. * @param __INTERRUPT__: specifies the UART interrupt source to enable.
  780. * This parameter can be one of the following values:
  781. * @arg UART_IT_WUF: Wakeup from stop mode interrupt
  782. * @arg UART_IT_CM: Character match interrupt
  783. * @arg UART_IT_CTS: CTS change interrupt
  784. * @arg UART_IT_LBD: LIN Break detection interrupt
  785. * @arg UART_IT_TXE: Transmit Data Register empty interrupt
  786. * @arg UART_IT_TC: Transmission complete interrupt
  787. * @arg UART_IT_RXNE: Receive Data register not empty interrupt
  788. * @arg UART_IT_IDLE: Idle line detection interrupt
  789. * @arg UART_IT_PE: Parity Error interrupt
  790. * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
  791. * @retval None
  792. */
  793. #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)? ((__HANDLE__)->Instance->CR1 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
  794. ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)? ((__HANDLE__)->Instance->CR2 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))): \
  795. ((__HANDLE__)->Instance->CR3 |= (1U << ((__INTERRUPT__) & UART_IT_MASK))))
  796. /** @brief Disables the specified UART interrupt.
  797. * @param __HANDLE__: specifies the UART Handle.
  798. * This parameter can be USART1, USART2 or LPUART.
  799. * @param __INTERRUPT__: specifies the UART interrupt source to disable.
  800. * This parameter can be one of the following values:
  801. * @arg UART_IT_WUF: Wakeup from stop mode interrupt
  802. * @arg UART_IT_CM: Character match interrupt
  803. * @arg UART_IT_CTS: CTS change interrupt
  804. * @arg UART_IT_LBD: LIN Break detection interrupt
  805. * @arg UART_IT_TXE: Transmit Data Register empty interrupt
  806. * @arg UART_IT_TC: Transmission complete interrupt
  807. * @arg UART_IT_RXNE: Receive Data register not empty interrupt
  808. * @arg UART_IT_IDLE: Idle line detection interrupt
  809. * @arg UART_IT_PE: Parity Error interrupt
  810. * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error)
  811. * @retval None
  812. */
  813. #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((((uint8_t)(__INTERRUPT__)) >> 5U) == 1U)? ((__HANDLE__)->Instance->CR1 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & UART_IT_MASK))): \
  814. ((((uint8_t)(__INTERRUPT__)) >> 5U) == 2U)? ((__HANDLE__)->Instance->CR2 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & UART_IT_MASK))): \
  815. ((__HANDLE__)->Instance->CR3 &= ~ ((uint32_t)1U << ((__INTERRUPT__) & UART_IT_MASK))))
  816. /** @brief Checks whether the specified UART interrupt has occurred or not.
  817. * @param __HANDLE__: specifies the UART Handle.
  818. * This parameter can be USART1, USART2 or LPUART.
  819. * @param __IT__: specifies the UART interrupt to check.
  820. * This parameter can be one of the following values:
  821. * @arg UART_IT_WUF: Wakeup from stop mode interrupt
  822. * @arg UART_IT_CM: Character match interrupt
  823. * @arg UART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
  824. * @arg UART_IT_LBD: LIN Break detection interrupt
  825. * @arg UART_IT_TXE: Transmit Data Register empty interrupt
  826. * @arg UART_IT_TC: Transmission complete interrupt
  827. * @arg UART_IT_RXNE: Receive Data register not empty interrupt
  828. * @arg UART_IT_IDLE: Idle line detection interrupt
  829. * @arg UART_IT_ORE: OverRun Error interrupt
  830. * @arg UART_IT_NE: Noise Error interrupt
  831. * @arg UART_IT_FE: Framing Error interrupt
  832. * @arg UART_IT_PE: Parity Error interrupt
  833. * @retval The new state of __IT__ (TRUE or FALSE).
  834. */
  835. #define __HAL_UART_GET_IT(__HANDLE__, __IT__) ((__HANDLE__)->Instance->ISR & ((uint32_t)1U << ((__IT__)>> 0x08U)))
  836. /** @brief Checks whether the specified UART interrupt source is enabled.
  837. * @param __HANDLE__: specifies the UART Handle.
  838. * This parameter can be USART1, USART2 or LPUART.
  839. * @param __IT__: specifies the UART interrupt source to check.
  840. * This parameter can be one of the following values:
  841. * @arg UART_IT_CTS: CTS change interrupt (not available for UART4 and UART5)
  842. * @arg UART_IT_LBD: LIN Break detection interrupt
  843. * @arg UART_IT_TXE: Transmit Data Register empty interrupt
  844. * @arg UART_IT_TC: Transmission complete interrupt
  845. * @arg UART_IT_RXNE: Receive Data register not empty interrupt
  846. * @arg UART_IT_IDLE: Idle line detection interrupt
  847. * @arg UART_IT_ORE: OverRun Error interrupt
  848. * @arg UART_IT_NE: Noise Error interrupt
  849. * @arg UART_IT_FE: Framing Error interrupt
  850. * @arg UART_IT_PE: Parity Error interrupt
  851. * @retval The new state of __IT__ (TRUE or FALSE).
  852. */
  853. #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) ((((((uint8_t)(__IT__)) >> 5U) == 1U)? (__HANDLE__)->Instance->CR1:(((((uint8_t)(__IT__)) >> 5U) == 2U)? \
  854. (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & ((uint32_t)1U << (((uint16_t)(__IT__)) & UART_IT_MASK)))
  855. /** @brief Clears the specified UART ISR flag, in setting the proper ICR register flag.
  856. * @param __HANDLE__: specifies the UART Handle.
  857. * This parameter can be USART1, USART2 or LPUART.
  858. * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
  859. * to clear the corresponding interrupt
  860. * This parameter can be one of the following values:
  861. * @arg UART_CLEAR_PEF: Parity Error Clear Flag
  862. * @arg UART_CLEAR_FEF: Framing Error Clear Flag
  863. * @arg UART_CLEAR_NEF: Noise detected Clear Flag
  864. * @arg UART_CLEAR_OREF: OverRun Error Clear Flag
  865. * @arg UART_CLEAR_IDLEF: IDLE line detected Clear Flag
  866. * @arg UART_CLEAR_TCF: Transmission Complete Clear Flag
  867. * @arg UART_CLEAR_LBDF: LIN Break Detection Clear Flag
  868. * @arg UART_CLEAR_CTSF: CTS Interrupt Clear Flag
  869. * @arg UART_CLEAR_RTOF: Receiver Time Out Clear Flag
  870. * @arg UART_CLEAR_EOBF: End Of Block Clear Flag
  871. * @arg UART_CLEAR_CMF: Character Match Clear Flag
  872. * @arg UART_CLEAR_WUF: Wake Up from stop mode Clear Flag
  873. * @retval None
  874. */
  875. #define __HAL_UART_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->ICR = (uint32_t)(__IT_CLEAR__))
  876. /** @brief Set a specific UART request flag.
  877. * @param __HANDLE__: specifies the UART Handle.
  878. * This parameter can be USART1, USART2 or LPUART.
  879. * @param __REQ__: specifies the request flag to set
  880. * This parameter can be one of the following values:
  881. * @arg UART_AUTOBAUD_REQUEST: Auto-Baud Rate Request
  882. * @arg UART_SENDBREAK_REQUEST: Send Break Request
  883. * @arg UART_MUTE_MODE_REQUEST: Mute Mode Request
  884. * @arg UART_RXDATA_FLUSH_REQUEST: Receive Data flush Request
  885. * @arg UART_TXDATA_FLUSH_REQUEST: Transmit data flush Request
  886. * @retval None
  887. */
  888. #define __HAL_UART_SEND_REQ(__HANDLE__, __REQ__) ((__HANDLE__)->Instance->RQR |= (uint32_t)(__REQ__))
  889. /** @brief Enables the UART one bit sample method
  890. * @param __HANDLE__: specifies the UART Handle.
  891. * @retval None
  892. */
  893. #define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
  894. /** @brief Disables the UART one bit sample method
  895. * @param __HANDLE__: specifies the UART Handle.
  896. * @retval None
  897. */
  898. #define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_ONEBIT))
  899. /** @brief Enable UART
  900. * @param __HANDLE__: specifies the UART Handle.
  901. * The Handle Instance can be USART1, USART2 or LPUART.
  902. * @retval None
  903. */
  904. #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE)
  905. /** @brief Disable UART
  906. * @param __HANDLE__: specifies the UART Handle.
  907. * The Handle Instance can be USART1, USART2 or LPUART.
  908. * @retval None
  909. */
  910. #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE)
  911. /** @brief Enable CTS flow control
  912. * This macro allows to enable CTS hardware flow control for a given UART instance,
  913. * without need to call HAL_UART_Init() function.
  914. * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
  915. * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
  916. * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
  917. * - UART instance should have already been initialised (through call of HAL_UART_Init() )
  918. * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
  919. * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
  920. * @param __HANDLE__: specifies the UART Handle.
  921. * The Handle Instance can be USART1, USART2 or LPUART.
  922. * @retval None
  923. */
  924. #define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \
  925. do{ \
  926. SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
  927. (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \
  928. } while(0)
  929. /** @brief Disable CTS flow control
  930. * This macro allows to disable CTS hardware flow control for a given UART instance,
  931. * without need to call HAL_UART_Init() function.
  932. * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
  933. * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need
  934. * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
  935. * - UART instance should have already been initialised (through call of HAL_UART_Init() )
  936. * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
  937. * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
  938. * @param __HANDLE__: specifies the UART Handle.
  939. * The Handle Instance can be USART1, USART2 or LPUART.
  940. * @retval None
  941. */
  942. #define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \
  943. do{ \
  944. CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \
  945. (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \
  946. } while(0)
  947. /** @brief Enable RTS flow control
  948. * This macro allows to enable RTS hardware flow control for a given UART instance,
  949. * without need to call HAL_UART_Init() function.
  950. * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
  951. * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
  952. * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
  953. * - UART instance should have already been initialised (through call of HAL_UART_Init() )
  954. * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
  955. * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
  956. * @param __HANDLE__: specifies the UART Handle.
  957. * The Handle Instance can be USART1, USART2 or LPUART.
  958. * @retval None
  959. */
  960. #define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \
  961. do{ \
  962. SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \
  963. (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \
  964. } while(0)
  965. /** @brief Disable RTS flow control
  966. * This macro allows to disable RTS hardware flow control for a given UART instance,
  967. * without need to call HAL_UART_Init() function.
  968. * As involving direct access to UART registers, usage of this macro should be fully endorsed by user.
  969. * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need
  970. * for USART instance Deinit/Init, following conditions for macro call should be fulfilled :
  971. * - UART instance should have already been initialised (through call of HAL_UART_Init() )
  972. * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__))
  973. * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)).
  974. * @param __HANDLE__: specifies the UART Handle.
  975. * The Handle Instance can be USART1, USART2 or LPUART.
  976. * @retval None
  977. */
  978. #define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \
  979. do{ \
  980. CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\
  981. (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \
  982. } while(0)
  983. /** @brief macros to enable the UART's one bit sampling method
  984. * @param __HANDLE__: specifies the UART Handle.
  985. * @retval None
  986. */
  987. #define __HAL_UART_ONE_BIT_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT)
  988. /** @brief macros to disable the UART's one bit sampling method
  989. * @param __HANDLE__: specifies the UART Handle.
  990. * @retval None
  991. */
  992. #define __HAL_UART_ONE_BIT_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT))
  993. /** @brief BRR division operation to set BRR register with LPUART
  994. * @param _PCLK_: LPUART clock
  995. * @param _BAUD_: Baud rate set by the user
  996. * @retval Division result
  997. */
  998. #define __DIV_LPUART(_PCLK_, _BAUD_) ((uint32_t)(((((uint64_t)_PCLK_)*256.0) + (((uint64_t)_BAUD_)/2U)) / (((uint64_t)_BAUD_))))
  999. /** @brief BRR division operation to set BRR register in 8-bit oversampling mode
  1000. * @param _PCLK_: UART clock
  1001. * @param _BAUD_: Baud rate set by the user
  1002. * @retval Division result
  1003. */
  1004. #define UART_DIV_SAMPLING8(_PCLK_, _BAUD_) ((((_PCLK_)*2U) + ((_BAUD_)/2U)) / ((_BAUD_)))
  1005. /** @brief BRR division operation to set BRR register in 16-bit oversampling mode
  1006. * @param _PCLK_: UART clock
  1007. * @param _BAUD_: Baud rate set by the user
  1008. * @retval Division result
  1009. */
  1010. #define UART_DIV_SAMPLING16(_PCLK_, _BAUD_) ((((_PCLK_)) + ((_BAUD_)/2U)) / ((_BAUD_)))
  1011. /** @brief Check whether or not UART instance is Low Power UART.
  1012. * @param __HANDLE__: specifies the UART Handle.
  1013. * @retval SET (instance is LPUART) or RESET (instance isn't LPUART)
  1014. */
  1015. #define UART_INSTANCE_LOWPOWER(__HANDLE__) (((__HANDLE__)->Instance == LPUART1) ? SET : RESET )
  1016. /** @brief Check UART Baud rate
  1017. * @param BAUDRATE: Baudrate specified by the user
  1018. * The maximum Baud Rate is derived from the maximum clock on L0 (i.e. 32 MHz)
  1019. * divided by the smallest oversampling used on the USART (i.e. 8)
  1020. * @retval Test result (TRUE or FALSE).
  1021. */
  1022. #define IS_UART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 4000001)
  1023. /** @brief Check UART byte address
  1024. * @param ADDRESS: UART 8-bit address for wake-up process scheme
  1025. * @retval Test result (TRUE or FALSE).
  1026. */
  1027. #define IS_UART_7B_ADDRESS(ADDRESS) ((ADDRESS) <= 0x7F)
  1028. /** @brief Check UART 4-bit address
  1029. * @param ADDRESS: UART 4-bit address for wake-up process scheme
  1030. * @retval Test result (TRUE or FALSE).
  1031. */
  1032. #define IS_UART_4B_ADDRESS(ADDRESS) ((ADDRESS) <= 0xF)
  1033. /** @brief Check UART assertion time
  1034. * @param TIME: 5-bit value assertion time
  1035. * @retval Test result (TRUE or FALSE).
  1036. */
  1037. #define IS_UART_ASSERTIONTIME(TIME) ((TIME) <= 0x1F)
  1038. /** @brief Check UART deassertion time
  1039. * @param TIME: 5-bit value deassertion time
  1040. * @retval Test result (TRUE or FALSE).
  1041. */
  1042. #define IS_UART_DEASSERTIONTIME(TIME) ((TIME) <= 0x1F)
  1043. /**
  1044. * @}
  1045. */
  1046. /* Include UART HAL Extension module */
  1047. #include "stm32l0xx_hal_uart_ex.h"
  1048. /******************************************************************************/
  1049. /* Exported functions --------------------------------------------------------*/
  1050. /******************************************************************************/
  1051. /* Exported functions --------------------------------------------------------*/
  1052. /** @defgroup UART_Exported_Functions UART Exported Functions
  1053. * @{
  1054. */
  1055. /* Initialization/de-initialization functions ********************************/
  1056. /** @defgroup UART_Exported_Functions_Group1 Initialization/de-initialization methods
  1057. * @{
  1058. */
  1059. HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart);
  1060. HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart);
  1061. HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength);
  1062. HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod);
  1063. HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart);
  1064. void HAL_UART_MspInit(UART_HandleTypeDef *huart);
  1065. void HAL_UART_MspDeInit(UART_HandleTypeDef *huart);
  1066. /**
  1067. * @}
  1068. */
  1069. /* IO operation functions *****************************************************/
  1070. /** @defgroup UART_Exported_Functions_Group2 IO operation functions
  1071. * @{
  1072. */
  1073. HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  1074. HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  1075. HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
  1076. HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
  1077. HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
  1078. HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);
  1079. HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart);
  1080. HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart);
  1081. HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart);
  1082. void HAL_UART_IRQHandler(UART_HandleTypeDef *huart);
  1083. void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart);
  1084. void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);
  1085. void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart);
  1086. void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);
  1087. void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart);
  1088. /**
  1089. * @}
  1090. */
  1091. /* Peripheral Control and State functions ************************************/
  1092. /** @defgroup UART_Exported_Functions_Group3 Peripheral Control funtions
  1093. * @{
  1094. */
  1095. HAL_StatusTypeDef HAL_MultiProcessor_EnableMuteMode(UART_HandleTypeDef *huart);
  1096. HAL_StatusTypeDef HAL_MultiProcessor_DisableMuteMode(UART_HandleTypeDef *huart);
  1097. void HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart);
  1098. HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart);
  1099. HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart);
  1100. HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart);
  1101. HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart);
  1102. uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart);
  1103. /**
  1104. * @}
  1105. */
  1106. /**
  1107. * @}
  1108. */
  1109. /** @addtogroup UART_Private
  1110. * @{
  1111. */
  1112. void UART_SetConfig(UART_HandleTypeDef *huart);
  1113. HAL_StatusTypeDef UART_CheckIdleState(UART_HandleTypeDef *huart);
  1114. HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Timeout);
  1115. void UART_AdvFeatureConfig(UART_HandleTypeDef *huart);
  1116. /**
  1117. * @}
  1118. */
  1119. /* Define the private group ***********************************/
  1120. /**************************************************************/
  1121. /** @defgroup UART_Private UART Private
  1122. * @{
  1123. */
  1124. /**
  1125. * @}
  1126. */
  1127. /**************************************************************/
  1128. /**
  1129. * @}
  1130. */
  1131. /**
  1132. * @}
  1133. */
  1134. #ifdef __cplusplus
  1135. }
  1136. #endif
  1137. #endif /* __STM32L0xx_HAL_UART_H */
  1138. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/