You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

3820 lines
144 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f0xx_ll_usart.h
  4. * @author MCD Application Team
  5. * @brief Header file of USART LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F0xx_LL_USART_H
  37. #define __STM32F0xx_LL_USART_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f0xx.h"
  43. /** @addtogroup STM32F0xx_LL_Driver
  44. * @{
  45. */
  46. #if defined (USART1) || defined (USART2) || defined (USART3) || defined (USART4) || defined (USART5) || defined (USART6) || defined (USART7) || defined (USART8)
  47. /** @defgroup USART_LL USART
  48. * @{
  49. */
  50. /* Private types -------------------------------------------------------------*/
  51. /* Private variables ---------------------------------------------------------*/
  52. /* Private constants ---------------------------------------------------------*/
  53. /** @defgroup USART_LL_Private_Constants USART Private Constants
  54. * @{
  55. */
  56. /**
  57. * @}
  58. */
  59. /* Private macros ------------------------------------------------------------*/
  60. #if defined(USE_FULL_LL_DRIVER)
  61. /** @defgroup USART_LL_Private_Macros USART Private Macros
  62. * @{
  63. */
  64. /**
  65. * @}
  66. */
  67. #endif /*USE_FULL_LL_DRIVER*/
  68. /* Exported types ------------------------------------------------------------*/
  69. #if defined(USE_FULL_LL_DRIVER)
  70. /** @defgroup USART_LL_ES_INIT USART Exported Init structures
  71. * @{
  72. */
  73. /**
  74. * @brief LL USART Init Structure definition
  75. */
  76. typedef struct
  77. {
  78. uint32_t BaudRate; /*!< This field defines expected Usart communication baud rate.
  79. This feature can be modified afterwards using unitary function @ref LL_USART_SetBaudRate().*/
  80. uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame.
  81. This parameter can be a value of @ref USART_LL_EC_DATAWIDTH.
  82. This feature can be modified afterwards using unitary function @ref LL_USART_SetDataWidth().*/
  83. uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
  84. This parameter can be a value of @ref USART_LL_EC_STOPBITS.
  85. This feature can be modified afterwards using unitary function @ref LL_USART_SetStopBitsLength().*/
  86. uint32_t Parity; /*!< Specifies the parity mode.
  87. This parameter can be a value of @ref USART_LL_EC_PARITY.
  88. This feature can be modified afterwards using unitary function @ref LL_USART_SetParity().*/
  89. uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled.
  90. This parameter can be a value of @ref USART_LL_EC_DIRECTION.
  91. This feature can be modified afterwards using unitary function @ref LL_USART_SetTransferDirection().*/
  92. uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled.
  93. This parameter can be a value of @ref USART_LL_EC_HWCONTROL.
  94. This feature can be modified afterwards using unitary function @ref LL_USART_SetHWFlowCtrl().*/
  95. uint32_t OverSampling; /*!< Specifies whether USART oversampling mode is 16 or 8.
  96. This parameter can be a value of @ref USART_LL_EC_OVERSAMPLING.
  97. This feature can be modified afterwards using unitary function @ref LL_USART_SetOverSampling().*/
  98. } LL_USART_InitTypeDef;
  99. /**
  100. * @brief LL USART Clock Init Structure definition
  101. */
  102. typedef struct
  103. {
  104. uint32_t ClockOutput; /*!< Specifies whether the USART clock is enabled or disabled.
  105. This parameter can be a value of @ref USART_LL_EC_CLOCK.
  106. USART HW configuration can be modified afterwards using unitary functions
  107. @ref LL_USART_EnableSCLKOutput() or @ref LL_USART_DisableSCLKOutput().
  108. For more details, refer to description of this function. */
  109. uint32_t ClockPolarity; /*!< Specifies the steady state of the serial clock.
  110. This parameter can be a value of @ref USART_LL_EC_POLARITY.
  111. USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPolarity().
  112. For more details, refer to description of this function. */
  113. uint32_t ClockPhase; /*!< Specifies the clock transition on which the bit capture is made.
  114. This parameter can be a value of @ref USART_LL_EC_PHASE.
  115. USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPhase().
  116. For more details, refer to description of this function. */
  117. uint32_t LastBitClockPulse; /*!< Specifies whether the clock pulse corresponding to the last transmitted
  118. data bit (MSB) has to be output on the SCLK pin in synchronous mode.
  119. This parameter can be a value of @ref USART_LL_EC_LASTCLKPULSE.
  120. USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetLastClkPulseOutput().
  121. For more details, refer to description of this function. */
  122. } LL_USART_ClockInitTypeDef;
  123. /**
  124. * @}
  125. */
  126. #endif /* USE_FULL_LL_DRIVER */
  127. /* Exported constants --------------------------------------------------------*/
  128. /** @defgroup USART_LL_Exported_Constants USART Exported Constants
  129. * @{
  130. */
  131. /** @defgroup USART_LL_EC_CLEAR_FLAG Clear Flags Defines
  132. * @brief Flags defines which can be used with LL_USART_WriteReg function
  133. * @{
  134. */
  135. #define LL_USART_ICR_PECF USART_ICR_PECF /*!< Parity error flag */
  136. #define LL_USART_ICR_FECF USART_ICR_FECF /*!< Framing error flag */
  137. #define LL_USART_ICR_NCF USART_ICR_NCF /*!< Noise detected flag */
  138. #define LL_USART_ICR_ORECF USART_ICR_ORECF /*!< Overrun error flag */
  139. #define LL_USART_ICR_IDLECF USART_ICR_IDLECF /*!< Idle line detected flag */
  140. #define LL_USART_ICR_TCCF USART_ICR_TCCF /*!< Transmission complete flag */
  141. #if defined(USART_LIN_SUPPORT)
  142. #define LL_USART_ICR_LBDCF USART_ICR_LBDCF /*!< LIN break detection flag */
  143. #endif
  144. #define LL_USART_ICR_CTSCF USART_ICR_CTSCF /*!< CTS flag */
  145. #define LL_USART_ICR_RTOCF USART_ICR_RTOCF /*!< Receiver timeout flag */
  146. #if defined(USART_SMARTCARD_SUPPORT)
  147. #define LL_USART_ICR_EOBCF USART_ICR_EOBCF /*!< End of block flag */
  148. #endif
  149. #define LL_USART_ICR_CMCF USART_ICR_CMCF /*!< Character match flag */
  150. #if defined(USART_WUSM_SUPPORT)
  151. #define LL_USART_ICR_WUCF USART_ICR_WUCF /*!< Wakeup from Stop mode flag */
  152. #endif
  153. /**
  154. * @}
  155. */
  156. /** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines
  157. * @brief Flags defines which can be used with LL_USART_ReadReg function
  158. * @{
  159. */
  160. #define LL_USART_ISR_PE USART_ISR_PE /*!< Parity error flag */
  161. #define LL_USART_ISR_FE USART_ISR_FE /*!< Framing error flag */
  162. #define LL_USART_ISR_NE USART_ISR_NE /*!< Noise detected flag */
  163. #define LL_USART_ISR_ORE USART_ISR_ORE /*!< Overrun error flag */
  164. #define LL_USART_ISR_IDLE USART_ISR_IDLE /*!< Idle line detected flag */
  165. #define LL_USART_ISR_RXNE USART_ISR_RXNE /*!< Read data register not empty flag */
  166. #define LL_USART_ISR_TC USART_ISR_TC /*!< Transmission complete flag */
  167. #define LL_USART_ISR_TXE USART_ISR_TXE /*!< Transmit data register empty flag */
  168. #if defined(USART_LIN_SUPPORT)
  169. #define LL_USART_ISR_LBDF USART_ISR_LBDF /*!< LIN break detection flag */
  170. #endif
  171. #define LL_USART_ISR_CTSIF USART_ISR_CTSIF /*!< CTS interrupt flag */
  172. #define LL_USART_ISR_CTS USART_ISR_CTS /*!< CTS flag */
  173. #define LL_USART_ISR_RTOF USART_ISR_RTOF /*!< Receiver timeout flag */
  174. #if defined(USART_SMARTCARD_SUPPORT)
  175. #define LL_USART_ISR_EOBF USART_ISR_EOBF /*!< End of block flag */
  176. #endif
  177. #define LL_USART_ISR_ABRE USART_ISR_ABRE /*!< Auto baud rate error flag */
  178. #define LL_USART_ISR_ABRF USART_ISR_ABRF /*!< Auto baud rate flag */
  179. #define LL_USART_ISR_BUSY USART_ISR_BUSY /*!< Busy flag */
  180. #define LL_USART_ISR_CMF USART_ISR_CMF /*!< Character match flag */
  181. #define LL_USART_ISR_SBKF USART_ISR_SBKF /*!< Send break flag */
  182. #define LL_USART_ISR_RWU USART_ISR_RWU /*!< Receiver wakeup from Mute mode flag */
  183. #if defined(USART_WUSM_SUPPORT)
  184. #define LL_USART_ISR_WUF USART_ISR_WUF /*!< Wakeup from Stop mode flag */
  185. #define LL_USART_ISR_TEACK USART_ISR_TEACK /*!< Transmit enable acknowledge flag */
  186. #define LL_USART_ISR_REACK USART_ISR_REACK /*!< Receive enable acknowledge flag */
  187. #endif
  188. /**
  189. * @}
  190. */
  191. /** @defgroup USART_LL_EC_IT IT Defines
  192. * @brief IT defines which can be used with LL_USART_ReadReg and LL_USART_WriteReg functions
  193. * @{
  194. */
  195. #define LL_USART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */
  196. #define LL_USART_CR1_RXNEIE USART_CR1_RXNEIE /*!< Read data register not empty interrupt enable */
  197. #define LL_USART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */
  198. #define LL_USART_CR1_TXEIE USART_CR1_TXEIE /*!< Transmit data register empty interrupt enable */
  199. #define LL_USART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */
  200. #define LL_USART_CR1_CMIE USART_CR1_CMIE /*!< Character match interrupt enable */
  201. #define LL_USART_CR1_RTOIE USART_CR1_RTOIE /*!< Receiver timeout interrupt enable */
  202. #if defined(USART_SMARTCARD_SUPPORT)
  203. #define LL_USART_CR1_EOBIE USART_CR1_EOBIE /*!< End of Block interrupt enable */
  204. #endif
  205. #if defined(USART_LIN_SUPPORT)
  206. #define LL_USART_CR2_LBDIE USART_CR2_LBDIE /*!< LIN break detection interrupt enable */
  207. #endif
  208. #define LL_USART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */
  209. #define LL_USART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */
  210. #if defined(USART_WUSM_SUPPORT)
  211. #define LL_USART_CR3_WUFIE USART_CR3_WUFIE /*!< Wakeup from Stop mode interrupt enable */
  212. #endif
  213. /**
  214. * @}
  215. */
  216. /** @defgroup USART_LL_EC_DIRECTION Communication Direction
  217. * @{
  218. */
  219. #define LL_USART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */
  220. #define LL_USART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */
  221. #define LL_USART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */
  222. #define LL_USART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */
  223. /**
  224. * @}
  225. */
  226. /** @defgroup USART_LL_EC_PARITY Parity Control
  227. * @{
  228. */
  229. #define LL_USART_PARITY_NONE 0x00000000U /*!< Parity control disabled */
  230. #define LL_USART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */
  231. #define LL_USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */
  232. /**
  233. * @}
  234. */
  235. /** @defgroup USART_LL_EC_WAKEUP Wakeup
  236. * @{
  237. */
  238. #define LL_USART_WAKEUP_IDLELINE 0x00000000U /*!< USART wake up from Mute mode on Idle Line */
  239. #define LL_USART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< USART wake up from Mute mode on Address Mark */
  240. /**
  241. * @}
  242. */
  243. /** @defgroup USART_LL_EC_DATAWIDTH Datawidth
  244. * @{
  245. */
  246. #if defined(USART_7BITS_SUPPORT)
  247. #define LL_USART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */
  248. #define LL_USART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
  249. #define LL_USART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
  250. #else
  251. #define LL_USART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
  252. #define LL_USART_DATAWIDTH_9B USART_CR1_M /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
  253. #endif
  254. /**
  255. * @}
  256. */
  257. /** @defgroup USART_LL_EC_OVERSAMPLING Oversampling
  258. * @{
  259. */
  260. #define LL_USART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */
  261. #define LL_USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */
  262. /**
  263. * @}
  264. */
  265. #if defined(USE_FULL_LL_DRIVER)
  266. /** @defgroup USART_LL_EC_CLOCK Clock Signal
  267. * @{
  268. */
  269. #define LL_USART_CLOCK_DISABLE 0x00000000U /*!< Clock signal not provided */
  270. #define LL_USART_CLOCK_ENABLE USART_CR2_CLKEN /*!< Clock signal provided */
  271. /**
  272. * @}
  273. */
  274. #endif /*USE_FULL_LL_DRIVER*/
  275. /** @defgroup USART_LL_EC_LASTCLKPULSE Last Clock Pulse
  276. * @{
  277. */
  278. #define LL_USART_LASTCLKPULSE_NO_OUTPUT 0x00000000U /*!< The clock pulse of the last data bit is not output to the SCLK pin */
  279. #define LL_USART_LASTCLKPULSE_OUTPUT USART_CR2_LBCL /*!< The clock pulse of the last data bit is output to the SCLK pin */
  280. /**
  281. * @}
  282. */
  283. /** @defgroup USART_LL_EC_PHASE Clock Phase
  284. * @{
  285. */
  286. #define LL_USART_PHASE_1EDGE 0x00000000U /*!< The first clock transition is the first data capture edge */
  287. #define LL_USART_PHASE_2EDGE USART_CR2_CPHA /*!< The second clock transition is the first data capture edge */
  288. /**
  289. * @}
  290. */
  291. /** @defgroup USART_LL_EC_POLARITY Clock Polarity
  292. * @{
  293. */
  294. #define LL_USART_POLARITY_LOW 0x00000000U /*!< Steady low value on SCLK pin outside transmission window*/
  295. #define LL_USART_POLARITY_HIGH USART_CR2_CPOL /*!< Steady high value on SCLK pin outside transmission window */
  296. /**
  297. * @}
  298. */
  299. /** @defgroup USART_LL_EC_STOPBITS Stop Bits
  300. * @{
  301. */
  302. #if defined(USART_SMARTCARD_SUPPORT)
  303. #define LL_USART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< 0.5 stop bit */
  304. #endif
  305. #define LL_USART_STOPBITS_1 0x00000000U /*!< 1 stop bit */
  306. #if defined(USART_SMARTCARD_SUPPORT)
  307. #define LL_USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< 1.5 stop bits */
  308. #endif
  309. #define LL_USART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */
  310. /**
  311. * @}
  312. */
  313. /** @defgroup USART_LL_EC_TXRX TX RX Pins Swap
  314. * @{
  315. */
  316. #define LL_USART_TXRX_STANDARD 0x00000000U /*!< TX/RX pins are used as defined in standard pinout */
  317. #define LL_USART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */
  318. /**
  319. * @}
  320. */
  321. /** @defgroup USART_LL_EC_RXPIN_LEVEL RX Pin Active Level Inversion
  322. * @{
  323. */
  324. #define LL_USART_RXPIN_LEVEL_STANDARD 0x00000000U /*!< RX pin signal works using the standard logic levels */
  325. #define LL_USART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */
  326. /**
  327. * @}
  328. */
  329. /** @defgroup USART_LL_EC_TXPIN_LEVEL TX Pin Active Level Inversion
  330. * @{
  331. */
  332. #define LL_USART_TXPIN_LEVEL_STANDARD 0x00000000U /*!< TX pin signal works using the standard logic levels */
  333. #define LL_USART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */
  334. /**
  335. * @}
  336. */
  337. /** @defgroup USART_LL_EC_BINARY_LOGIC Binary Data Inversion
  338. * @{
  339. */
  340. #define LL_USART_BINARY_LOGIC_POSITIVE 0x00000000U /*!< Logical data from the data register are send/received in positive/direct logic. (1=H, 0=L) */
  341. #define LL_USART_BINARY_LOGIC_NEGATIVE USART_CR2_DATAINV /*!< Logical data from the data register are send/received in negative/inverse logic. (1=L, 0=H). The parity bit is also inverted. */
  342. /**
  343. * @}
  344. */
  345. /** @defgroup USART_LL_EC_BITORDER Bit Order
  346. * @{
  347. */
  348. #define LL_USART_BITORDER_LSBFIRST 0x00000000U /*!< data is transmitted/received with data bit 0 first, following the start bit */
  349. #define LL_USART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first, following the start bit */
  350. /**
  351. * @}
  352. */
  353. /** @defgroup USART_LL_EC_AUTOBAUD_DETECT_ON Autobaud Detection
  354. * @{
  355. */
  356. #define LL_USART_AUTOBAUD_DETECT_ON_STARTBIT 0x00000000U /*!< Measurement of the start bit is used to detect the baud rate */
  357. #define LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE USART_CR2_ABRMODE_0 /*!< Falling edge to falling edge measurement. Received frame must start with a single bit = 1 -> Frame = Start10xxxxxx */
  358. #if defined(USART_FABR_SUPPORT)
  359. #define LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME USART_CR2_ABRMODE_1 /*!< 0x7F frame detection */
  360. #define LL_USART_AUTOBAUD_DETECT_ON_55_FRAME (USART_CR2_ABRMODE_1 | USART_CR2_ABRMODE_0) /*!< 0x55 frame detection */
  361. #endif
  362. /**
  363. * @}
  364. */
  365. /** @defgroup USART_LL_EC_ADDRESS_DETECT Address Length Detection
  366. * @{
  367. */
  368. #define LL_USART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit address detection method selected */
  369. #define LL_USART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */
  370. /**
  371. * @}
  372. */
  373. /** @defgroup USART_LL_EC_HWCONTROL Hardware Control
  374. * @{
  375. */
  376. #define LL_USART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */
  377. #define LL_USART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */
  378. #define LL_USART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */
  379. #define LL_USART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */
  380. /**
  381. * @}
  382. */
  383. #if defined(USART_WUSM_SUPPORT)
  384. /** @defgroup USART_LL_EC_WAKEUP_ON Wakeup Activation
  385. * @{
  386. */
  387. #define LL_USART_WAKEUP_ON_ADDRESS 0x00000000U /*!< Wake up active on address match */
  388. #define LL_USART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wake up active on Start bit detection */
  389. #define LL_USART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wake up active on RXNE */
  390. /**
  391. * @}
  392. */
  393. #endif
  394. #if defined(USART_IRDA_SUPPORT)
  395. /** @defgroup USART_LL_EC_IRDA_POWER IrDA Power
  396. * @{
  397. */
  398. #define LL_USART_IRDA_POWER_NORMAL 0x00000000U /*!< IrDA normal power mode */
  399. #define LL_USART_IRDA_POWER_LOW USART_CR3_IRLP /*!< IrDA low power mode */
  400. /**
  401. * @}
  402. */
  403. #endif
  404. #if defined(USART_LIN_SUPPORT)
  405. /** @defgroup USART_LL_EC_LINBREAK_DETECT LIN Break Detection Length
  406. * @{
  407. */
  408. #define LL_USART_LINBREAK_DETECT_10B 0x00000000U /*!< 10-bit break detection method selected */
  409. #define LL_USART_LINBREAK_DETECT_11B USART_CR2_LBDL /*!< 11-bit break detection method selected */
  410. /**
  411. * @}
  412. */
  413. #endif
  414. /** @defgroup USART_LL_EC_DE_POLARITY Driver Enable Polarity
  415. * @{
  416. */
  417. #define LL_USART_DE_POLARITY_HIGH 0x00000000U /*!< DE signal is active high */
  418. #define LL_USART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */
  419. /**
  420. * @}
  421. */
  422. /** @defgroup USART_LL_EC_DMA_REG_DATA DMA Register Data
  423. * @{
  424. */
  425. #define LL_USART_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */
  426. #define LL_USART_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */
  427. /**
  428. * @}
  429. */
  430. /**
  431. * @}
  432. */
  433. /* Exported macro ------------------------------------------------------------*/
  434. /** @defgroup USART_LL_Exported_Macros USART Exported Macros
  435. * @{
  436. */
  437. /** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros
  438. * @{
  439. */
  440. /**
  441. * @brief Write a value in USART register
  442. * @param __INSTANCE__ USART Instance
  443. * @param __REG__ Register to be written
  444. * @param __VALUE__ Value to be written in the register
  445. * @retval None
  446. */
  447. #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  448. /**
  449. * @brief Read a value in USART register
  450. * @param __INSTANCE__ USART Instance
  451. * @param __REG__ Register to be read
  452. * @retval Register value
  453. */
  454. #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  455. /**
  456. * @}
  457. */
  458. /** @defgroup USART_LL_EM_Exported_Macros_Helper Exported_Macros_Helper
  459. * @{
  460. */
  461. /**
  462. * @brief Compute USARTDIV value according to Peripheral Clock and
  463. * expected Baud Rate in 8 bits sampling mode (32 bits value of USARTDIV is returned)
  464. * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance
  465. * @param __BAUDRATE__ Baud rate value to achieve
  466. * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case
  467. */
  468. #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) ((((__PERIPHCLK__)*2) + ((__BAUDRATE__)/2))/(__BAUDRATE__))
  469. /**
  470. * @brief Compute USARTDIV value according to Peripheral Clock and
  471. * expected Baud Rate in 16 bits sampling mode (32 bits value of USARTDIV is returned)
  472. * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance
  473. * @param __BAUDRATE__ Baud rate value to achieve
  474. * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case
  475. */
  476. #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__) + ((__BAUDRATE__)/2))/(__BAUDRATE__))
  477. /**
  478. * @}
  479. */
  480. /**
  481. * @}
  482. */
  483. /* Exported functions --------------------------------------------------------*/
  484. /** @defgroup USART_LL_Exported_Functions USART Exported Functions
  485. * @{
  486. */
  487. /** @defgroup USART_LL_EF_Configuration Configuration functions
  488. * @{
  489. */
  490. /**
  491. * @brief USART Enable
  492. * @rmtoll CR1 UE LL_USART_Enable
  493. * @param USARTx USART Instance
  494. * @retval None
  495. */
  496. __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx)
  497. {
  498. SET_BIT(USARTx->CR1, USART_CR1_UE);
  499. }
  500. /**
  501. * @brief USART Disable (all USART prescalers and outputs are disabled)
  502. * @note When USART is disabled, USART prescalers and outputs are stopped immediately,
  503. * and current operations are discarded. The configuration of the USART is kept, but all the status
  504. * flags, in the USARTx_ISR are set to their default values.
  505. * @rmtoll CR1 UE LL_USART_Disable
  506. * @param USARTx USART Instance
  507. * @retval None
  508. */
  509. __STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx)
  510. {
  511. CLEAR_BIT(USARTx->CR1, USART_CR1_UE);
  512. }
  513. /**
  514. * @brief Indicate if USART is enabled
  515. * @rmtoll CR1 UE LL_USART_IsEnabled
  516. * @param USARTx USART Instance
  517. * @retval State of bit (1 or 0).
  518. */
  519. __STATIC_INLINE uint32_t LL_USART_IsEnabled(USART_TypeDef *USARTx)
  520. {
  521. return (READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE));
  522. }
  523. #if defined(USART_WUSM_SUPPORT)
  524. /**
  525. * @brief USART enabled in STOP Mode.
  526. * @note When this function is enabled, USART is able to wake up the MCU from Stop mode, provided that
  527. * USART clock selection is HSI or LSE in RCC.
  528. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  529. * Wake-up from Stop mode feature is supported by the USARTx instance.
  530. * @rmtoll CR1 UESM LL_USART_EnableInStopMode
  531. * @param USARTx USART Instance
  532. * @retval None
  533. */
  534. __STATIC_INLINE void LL_USART_EnableInStopMode(USART_TypeDef *USARTx)
  535. {
  536. SET_BIT(USARTx->CR1, USART_CR1_UESM);
  537. }
  538. /**
  539. * @brief USART disabled in STOP Mode.
  540. * @note When this function is disabled, USART is not able to wake up the MCU from Stop mode
  541. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  542. * Wake-up from Stop mode feature is supported by the USARTx instance.
  543. * @rmtoll CR1 UESM LL_USART_DisableInStopMode
  544. * @param USARTx USART Instance
  545. * @retval None
  546. */
  547. __STATIC_INLINE void LL_USART_DisableInStopMode(USART_TypeDef *USARTx)
  548. {
  549. CLEAR_BIT(USARTx->CR1, USART_CR1_UESM);
  550. }
  551. /**
  552. * @brief Indicate if USART is enabled in STOP Mode (able to wake up MCU from Stop mode or not)
  553. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  554. * Wake-up from Stop mode feature is supported by the USARTx instance.
  555. * @rmtoll CR1 UESM LL_USART_IsEnabledInStopMode
  556. * @param USARTx USART Instance
  557. * @retval State of bit (1 or 0).
  558. */
  559. __STATIC_INLINE uint32_t LL_USART_IsEnabledInStopMode(USART_TypeDef *USARTx)
  560. {
  561. return (READ_BIT(USARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM));
  562. }
  563. #endif
  564. /**
  565. * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit)
  566. * @rmtoll CR1 RE LL_USART_EnableDirectionRx
  567. * @param USARTx USART Instance
  568. * @retval None
  569. */
  570. __STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx)
  571. {
  572. SET_BIT(USARTx->CR1, USART_CR1_RE);
  573. }
  574. /**
  575. * @brief Receiver Disable
  576. * @rmtoll CR1 RE LL_USART_DisableDirectionRx
  577. * @param USARTx USART Instance
  578. * @retval None
  579. */
  580. __STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx)
  581. {
  582. CLEAR_BIT(USARTx->CR1, USART_CR1_RE);
  583. }
  584. /**
  585. * @brief Transmitter Enable
  586. * @rmtoll CR1 TE LL_USART_EnableDirectionTx
  587. * @param USARTx USART Instance
  588. * @retval None
  589. */
  590. __STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx)
  591. {
  592. SET_BIT(USARTx->CR1, USART_CR1_TE);
  593. }
  594. /**
  595. * @brief Transmitter Disable
  596. * @rmtoll CR1 TE LL_USART_DisableDirectionTx
  597. * @param USARTx USART Instance
  598. * @retval None
  599. */
  600. __STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx)
  601. {
  602. CLEAR_BIT(USARTx->CR1, USART_CR1_TE);
  603. }
  604. /**
  605. * @brief Configure simultaneously enabled/disabled states
  606. * of Transmitter and Receiver
  607. * @rmtoll CR1 RE LL_USART_SetTransferDirection\n
  608. * CR1 TE LL_USART_SetTransferDirection
  609. * @param USARTx USART Instance
  610. * @param TransferDirection This parameter can be one of the following values:
  611. * @arg @ref LL_USART_DIRECTION_NONE
  612. * @arg @ref LL_USART_DIRECTION_RX
  613. * @arg @ref LL_USART_DIRECTION_TX
  614. * @arg @ref LL_USART_DIRECTION_TX_RX
  615. * @retval None
  616. */
  617. __STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t TransferDirection)
  618. {
  619. MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection);
  620. }
  621. /**
  622. * @brief Return enabled/disabled states of Transmitter and Receiver
  623. * @rmtoll CR1 RE LL_USART_GetTransferDirection\n
  624. * CR1 TE LL_USART_GetTransferDirection
  625. * @param USARTx USART Instance
  626. * @retval Returned value can be one of the following values:
  627. * @arg @ref LL_USART_DIRECTION_NONE
  628. * @arg @ref LL_USART_DIRECTION_RX
  629. * @arg @ref LL_USART_DIRECTION_TX
  630. * @arg @ref LL_USART_DIRECTION_TX_RX
  631. */
  632. __STATIC_INLINE uint32_t LL_USART_GetTransferDirection(USART_TypeDef *USARTx)
  633. {
  634. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE));
  635. }
  636. /**
  637. * @brief Configure Parity (enabled/disabled and parity mode if enabled).
  638. * @note This function selects if hardware parity control (generation and detection) is enabled or disabled.
  639. * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position
  640. * (9th or 8th bit depending on data width) and parity is checked on the received data.
  641. * @rmtoll CR1 PS LL_USART_SetParity\n
  642. * CR1 PCE LL_USART_SetParity
  643. * @param USARTx USART Instance
  644. * @param Parity This parameter can be one of the following values:
  645. * @arg @ref LL_USART_PARITY_NONE
  646. * @arg @ref LL_USART_PARITY_EVEN
  647. * @arg @ref LL_USART_PARITY_ODD
  648. * @retval None
  649. */
  650. __STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t Parity)
  651. {
  652. MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity);
  653. }
  654. /**
  655. * @brief Return Parity configuration (enabled/disabled and parity mode if enabled)
  656. * @rmtoll CR1 PS LL_USART_GetParity\n
  657. * CR1 PCE LL_USART_GetParity
  658. * @param USARTx USART Instance
  659. * @retval Returned value can be one of the following values:
  660. * @arg @ref LL_USART_PARITY_NONE
  661. * @arg @ref LL_USART_PARITY_EVEN
  662. * @arg @ref LL_USART_PARITY_ODD
  663. */
  664. __STATIC_INLINE uint32_t LL_USART_GetParity(USART_TypeDef *USARTx)
  665. {
  666. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE));
  667. }
  668. /**
  669. * @brief Set Receiver Wake Up method from Mute mode.
  670. * @rmtoll CR1 WAKE LL_USART_SetWakeUpMethod
  671. * @param USARTx USART Instance
  672. * @param Method This parameter can be one of the following values:
  673. * @arg @ref LL_USART_WAKEUP_IDLELINE
  674. * @arg @ref LL_USART_WAKEUP_ADDRESSMARK
  675. * @retval None
  676. */
  677. __STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method)
  678. {
  679. MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method);
  680. }
  681. /**
  682. * @brief Return Receiver Wake Up method from Mute mode
  683. * @rmtoll CR1 WAKE LL_USART_GetWakeUpMethod
  684. * @param USARTx USART Instance
  685. * @retval Returned value can be one of the following values:
  686. * @arg @ref LL_USART_WAKEUP_IDLELINE
  687. * @arg @ref LL_USART_WAKEUP_ADDRESSMARK
  688. */
  689. __STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(USART_TypeDef *USARTx)
  690. {
  691. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE));
  692. }
  693. /**
  694. * @brief Set Word length (i.e. nb of data bits, excluding start and stop bits)
  695. * @rmtoll CR1 M0 LL_USART_SetDataWidth\n
  696. * CR1 M1 LL_USART_SetDataWidth
  697. * @param USARTx USART Instance
  698. * @param DataWidth This parameter can be one of the following values:
  699. * @arg @ref LL_USART_DATAWIDTH_7B (*)
  700. * @arg @ref LL_USART_DATAWIDTH_8B
  701. * @arg @ref LL_USART_DATAWIDTH_9B
  702. *
  703. * (*) Values not available on all devices
  704. * @retval None
  705. */
  706. __STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth)
  707. {
  708. MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth);
  709. }
  710. /**
  711. * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits)
  712. * @rmtoll CR1 M0 LL_USART_GetDataWidth\n
  713. * CR1 M1 LL_USART_GetDataWidth
  714. * @param USARTx USART Instance
  715. * @retval Returned value can be one of the following values:
  716. * @arg @ref LL_USART_DATAWIDTH_7B (*)
  717. * @arg @ref LL_USART_DATAWIDTH_8B
  718. * @arg @ref LL_USART_DATAWIDTH_9B
  719. *
  720. * (*) Values not available on all devices
  721. */
  722. __STATIC_INLINE uint32_t LL_USART_GetDataWidth(USART_TypeDef *USARTx)
  723. {
  724. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M));
  725. }
  726. /**
  727. * @brief Allow switch between Mute Mode and Active mode
  728. * @rmtoll CR1 MME LL_USART_EnableMuteMode
  729. * @param USARTx USART Instance
  730. * @retval None
  731. */
  732. __STATIC_INLINE void LL_USART_EnableMuteMode(USART_TypeDef *USARTx)
  733. {
  734. SET_BIT(USARTx->CR1, USART_CR1_MME);
  735. }
  736. /**
  737. * @brief Prevent Mute Mode use. Set Receiver in active mode permanently.
  738. * @rmtoll CR1 MME LL_USART_DisableMuteMode
  739. * @param USARTx USART Instance
  740. * @retval None
  741. */
  742. __STATIC_INLINE void LL_USART_DisableMuteMode(USART_TypeDef *USARTx)
  743. {
  744. CLEAR_BIT(USARTx->CR1, USART_CR1_MME);
  745. }
  746. /**
  747. * @brief Indicate if switch between Mute Mode and Active mode is allowed
  748. * @rmtoll CR1 MME LL_USART_IsEnabledMuteMode
  749. * @param USARTx USART Instance
  750. * @retval State of bit (1 or 0).
  751. */
  752. __STATIC_INLINE uint32_t LL_USART_IsEnabledMuteMode(USART_TypeDef *USARTx)
  753. {
  754. return (READ_BIT(USARTx->CR1, USART_CR1_MME) == (USART_CR1_MME));
  755. }
  756. /**
  757. * @brief Set Oversampling to 8-bit or 16-bit mode
  758. * @rmtoll CR1 OVER8 LL_USART_SetOverSampling
  759. * @param USARTx USART Instance
  760. * @param OverSampling This parameter can be one of the following values:
  761. * @arg @ref LL_USART_OVERSAMPLING_16
  762. * @arg @ref LL_USART_OVERSAMPLING_8
  763. * @retval None
  764. */
  765. __STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling)
  766. {
  767. MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling);
  768. }
  769. /**
  770. * @brief Return Oversampling mode
  771. * @rmtoll CR1 OVER8 LL_USART_GetOverSampling
  772. * @param USARTx USART Instance
  773. * @retval Returned value can be one of the following values:
  774. * @arg @ref LL_USART_OVERSAMPLING_16
  775. * @arg @ref LL_USART_OVERSAMPLING_8
  776. */
  777. __STATIC_INLINE uint32_t LL_USART_GetOverSampling(USART_TypeDef *USARTx)
  778. {
  779. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8));
  780. }
  781. /**
  782. * @brief Configure if Clock pulse of the last data bit is output to the SCLK pin or not
  783. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  784. * Synchronous mode is supported by the USARTx instance.
  785. * @rmtoll CR2 LBCL LL_USART_SetLastClkPulseOutput
  786. * @param USARTx USART Instance
  787. * @param LastBitClockPulse This parameter can be one of the following values:
  788. * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
  789. * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
  790. * @retval None
  791. */
  792. __STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LastBitClockPulse)
  793. {
  794. MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LastBitClockPulse);
  795. }
  796. /**
  797. * @brief Retrieve Clock pulse of the last data bit output configuration
  798. * (Last bit Clock pulse output to the SCLK pin or not)
  799. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  800. * Synchronous mode is supported by the USARTx instance.
  801. * @rmtoll CR2 LBCL LL_USART_GetLastClkPulseOutput
  802. * @param USARTx USART Instance
  803. * @retval Returned value can be one of the following values:
  804. * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
  805. * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
  806. */
  807. __STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(USART_TypeDef *USARTx)
  808. {
  809. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL));
  810. }
  811. /**
  812. * @brief Select the phase of the clock output on the SCLK pin in synchronous mode
  813. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  814. * Synchronous mode is supported by the USARTx instance.
  815. * @rmtoll CR2 CPHA LL_USART_SetClockPhase
  816. * @param USARTx USART Instance
  817. * @param ClockPhase This parameter can be one of the following values:
  818. * @arg @ref LL_USART_PHASE_1EDGE
  819. * @arg @ref LL_USART_PHASE_2EDGE
  820. * @retval None
  821. */
  822. __STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t ClockPhase)
  823. {
  824. MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, ClockPhase);
  825. }
  826. /**
  827. * @brief Return phase of the clock output on the SCLK pin in synchronous mode
  828. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  829. * Synchronous mode is supported by the USARTx instance.
  830. * @rmtoll CR2 CPHA LL_USART_GetClockPhase
  831. * @param USARTx USART Instance
  832. * @retval Returned value can be one of the following values:
  833. * @arg @ref LL_USART_PHASE_1EDGE
  834. * @arg @ref LL_USART_PHASE_2EDGE
  835. */
  836. __STATIC_INLINE uint32_t LL_USART_GetClockPhase(USART_TypeDef *USARTx)
  837. {
  838. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA));
  839. }
  840. /**
  841. * @brief Select the polarity of the clock output on the SCLK pin in synchronous mode
  842. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  843. * Synchronous mode is supported by the USARTx instance.
  844. * @rmtoll CR2 CPOL LL_USART_SetClockPolarity
  845. * @param USARTx USART Instance
  846. * @param ClockPolarity This parameter can be one of the following values:
  847. * @arg @ref LL_USART_POLARITY_LOW
  848. * @arg @ref LL_USART_POLARITY_HIGH
  849. * @retval None
  850. */
  851. __STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t ClockPolarity)
  852. {
  853. MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, ClockPolarity);
  854. }
  855. /**
  856. * @brief Return polarity of the clock output on the SCLK pin in synchronous mode
  857. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  858. * Synchronous mode is supported by the USARTx instance.
  859. * @rmtoll CR2 CPOL LL_USART_GetClockPolarity
  860. * @param USARTx USART Instance
  861. * @retval Returned value can be one of the following values:
  862. * @arg @ref LL_USART_POLARITY_LOW
  863. * @arg @ref LL_USART_POLARITY_HIGH
  864. */
  865. __STATIC_INLINE uint32_t LL_USART_GetClockPolarity(USART_TypeDef *USARTx)
  866. {
  867. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL));
  868. }
  869. /**
  870. * @brief Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse)
  871. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  872. * Synchronous mode is supported by the USARTx instance.
  873. * @note Call of this function is equivalent to following function call sequence :
  874. * - Clock Phase configuration using @ref LL_USART_SetClockPhase() function
  875. * - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function
  876. * - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function
  877. * @rmtoll CR2 CPHA LL_USART_ConfigClock\n
  878. * CR2 CPOL LL_USART_ConfigClock\n
  879. * CR2 LBCL LL_USART_ConfigClock
  880. * @param USARTx USART Instance
  881. * @param Phase This parameter can be one of the following values:
  882. * @arg @ref LL_USART_PHASE_1EDGE
  883. * @arg @ref LL_USART_PHASE_2EDGE
  884. * @param Polarity This parameter can be one of the following values:
  885. * @arg @ref LL_USART_POLARITY_LOW
  886. * @arg @ref LL_USART_POLARITY_HIGH
  887. * @param LBCPOutput This parameter can be one of the following values:
  888. * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
  889. * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
  890. * @retval None
  891. */
  892. __STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput)
  893. {
  894. MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput);
  895. }
  896. /**
  897. * @brief Enable Clock output on SCLK pin
  898. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  899. * Synchronous mode is supported by the USARTx instance.
  900. * @rmtoll CR2 CLKEN LL_USART_EnableSCLKOutput
  901. * @param USARTx USART Instance
  902. * @retval None
  903. */
  904. __STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx)
  905. {
  906. SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
  907. }
  908. /**
  909. * @brief Disable Clock output on SCLK pin
  910. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  911. * Synchronous mode is supported by the USARTx instance.
  912. * @rmtoll CR2 CLKEN LL_USART_DisableSCLKOutput
  913. * @param USARTx USART Instance
  914. * @retval None
  915. */
  916. __STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx)
  917. {
  918. CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN);
  919. }
  920. /**
  921. * @brief Indicate if Clock output on SCLK pin is enabled
  922. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  923. * Synchronous mode is supported by the USARTx instance.
  924. * @rmtoll CR2 CLKEN LL_USART_IsEnabledSCLKOutput
  925. * @param USARTx USART Instance
  926. * @retval State of bit (1 or 0).
  927. */
  928. __STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(USART_TypeDef *USARTx)
  929. {
  930. return (READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN));
  931. }
  932. /**
  933. * @brief Set the length of the stop bits
  934. * @rmtoll CR2 STOP LL_USART_SetStopBitsLength
  935. * @param USARTx USART Instance
  936. * @param StopBits This parameter can be one of the following values:
  937. * @arg @ref LL_USART_STOPBITS_0_5 (*)
  938. * @arg @ref LL_USART_STOPBITS_1
  939. * @arg @ref LL_USART_STOPBITS_1_5 (*)
  940. * @arg @ref LL_USART_STOPBITS_2
  941. *
  942. * (*) Values not available on all devices
  943. * @retval None
  944. */
  945. __STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits)
  946. {
  947. MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
  948. }
  949. /**
  950. * @brief Retrieve the length of the stop bits
  951. * @rmtoll CR2 STOP LL_USART_GetStopBitsLength
  952. * @param USARTx USART Instance
  953. * @retval Returned value can be one of the following values:
  954. * @arg @ref LL_USART_STOPBITS_0_5 (*)
  955. * @arg @ref LL_USART_STOPBITS_1
  956. * @arg @ref LL_USART_STOPBITS_1_5 (*)
  957. * @arg @ref LL_USART_STOPBITS_2
  958. *
  959. * (*) Values not available on all devices
  960. */
  961. __STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(USART_TypeDef *USARTx)
  962. {
  963. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP));
  964. }
  965. /**
  966. * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits)
  967. * @note Call of this function is equivalent to following function call sequence :
  968. * - Data Width configuration using @ref LL_USART_SetDataWidth() function
  969. * - Parity Control and mode configuration using @ref LL_USART_SetParity() function
  970. * - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function
  971. * @rmtoll CR1 PS LL_USART_ConfigCharacter\n
  972. * CR1 PCE LL_USART_ConfigCharacter\n
  973. * CR1 M0 LL_USART_ConfigCharacter\n
  974. * CR1 M1 LL_USART_ConfigCharacter\n
  975. * CR2 STOP LL_USART_ConfigCharacter
  976. * @param USARTx USART Instance
  977. * @param DataWidth This parameter can be one of the following values:
  978. * @arg @ref LL_USART_DATAWIDTH_7B (*)
  979. * @arg @ref LL_USART_DATAWIDTH_8B
  980. * @arg @ref LL_USART_DATAWIDTH_9B
  981. * @param Parity This parameter can be one of the following values:
  982. * @arg @ref LL_USART_PARITY_NONE
  983. * @arg @ref LL_USART_PARITY_EVEN
  984. * @arg @ref LL_USART_PARITY_ODD
  985. * @param StopBits This parameter can be one of the following values:
  986. * @arg @ref LL_USART_STOPBITS_0_5 (*)
  987. * @arg @ref LL_USART_STOPBITS_1
  988. * @arg @ref LL_USART_STOPBITS_1_5 (*)
  989. * @arg @ref LL_USART_STOPBITS_2
  990. *
  991. * (*) Values not available on all devices
  992. * @retval None
  993. */
  994. __STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t Parity,
  995. uint32_t StopBits)
  996. {
  997. MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth);
  998. MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
  999. }
  1000. /**
  1001. * @brief Configure TX/RX pins swapping setting.
  1002. * @rmtoll CR2 SWAP LL_USART_SetTXRXSwap
  1003. * @param USARTx USART Instance
  1004. * @param SwapConfig This parameter can be one of the following values:
  1005. * @arg @ref LL_USART_TXRX_STANDARD
  1006. * @arg @ref LL_USART_TXRX_SWAPPED
  1007. * @retval None
  1008. */
  1009. __STATIC_INLINE void LL_USART_SetTXRXSwap(USART_TypeDef *USARTx, uint32_t SwapConfig)
  1010. {
  1011. MODIFY_REG(USARTx->CR2, USART_CR2_SWAP, SwapConfig);
  1012. }
  1013. /**
  1014. * @brief Retrieve TX/RX pins swapping configuration.
  1015. * @rmtoll CR2 SWAP LL_USART_GetTXRXSwap
  1016. * @param USARTx USART Instance
  1017. * @retval Returned value can be one of the following values:
  1018. * @arg @ref LL_USART_TXRX_STANDARD
  1019. * @arg @ref LL_USART_TXRX_SWAPPED
  1020. */
  1021. __STATIC_INLINE uint32_t LL_USART_GetTXRXSwap(USART_TypeDef *USARTx)
  1022. {
  1023. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_SWAP));
  1024. }
  1025. /**
  1026. * @brief Configure RX pin active level logic
  1027. * @rmtoll CR2 RXINV LL_USART_SetRXPinLevel
  1028. * @param USARTx USART Instance
  1029. * @param PinInvMethod This parameter can be one of the following values:
  1030. * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD
  1031. * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED
  1032. * @retval None
  1033. */
  1034. __STATIC_INLINE void LL_USART_SetRXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod)
  1035. {
  1036. MODIFY_REG(USARTx->CR2, USART_CR2_RXINV, PinInvMethod);
  1037. }
  1038. /**
  1039. * @brief Retrieve RX pin active level logic configuration
  1040. * @rmtoll CR2 RXINV LL_USART_GetRXPinLevel
  1041. * @param USARTx USART Instance
  1042. * @retval Returned value can be one of the following values:
  1043. * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD
  1044. * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED
  1045. */
  1046. __STATIC_INLINE uint32_t LL_USART_GetRXPinLevel(USART_TypeDef *USARTx)
  1047. {
  1048. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_RXINV));
  1049. }
  1050. /**
  1051. * @brief Configure TX pin active level logic
  1052. * @rmtoll CR2 TXINV LL_USART_SetTXPinLevel
  1053. * @param USARTx USART Instance
  1054. * @param PinInvMethod This parameter can be one of the following values:
  1055. * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD
  1056. * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED
  1057. * @retval None
  1058. */
  1059. __STATIC_INLINE void LL_USART_SetTXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod)
  1060. {
  1061. MODIFY_REG(USARTx->CR2, USART_CR2_TXINV, PinInvMethod);
  1062. }
  1063. /**
  1064. * @brief Retrieve TX pin active level logic configuration
  1065. * @rmtoll CR2 TXINV LL_USART_GetTXPinLevel
  1066. * @param USARTx USART Instance
  1067. * @retval Returned value can be one of the following values:
  1068. * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD
  1069. * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED
  1070. */
  1071. __STATIC_INLINE uint32_t LL_USART_GetTXPinLevel(USART_TypeDef *USARTx)
  1072. {
  1073. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_TXINV));
  1074. }
  1075. /**
  1076. * @brief Configure Binary data logic.
  1077. * @note Allow to define how Logical data from the data register are send/received :
  1078. * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H)
  1079. * @rmtoll CR2 DATAINV LL_USART_SetBinaryDataLogic
  1080. * @param USARTx USART Instance
  1081. * @param DataLogic This parameter can be one of the following values:
  1082. * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE
  1083. * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE
  1084. * @retval None
  1085. */
  1086. __STATIC_INLINE void LL_USART_SetBinaryDataLogic(USART_TypeDef *USARTx, uint32_t DataLogic)
  1087. {
  1088. MODIFY_REG(USARTx->CR2, USART_CR2_DATAINV, DataLogic);
  1089. }
  1090. /**
  1091. * @brief Retrieve Binary data configuration
  1092. * @rmtoll CR2 DATAINV LL_USART_GetBinaryDataLogic
  1093. * @param USARTx USART Instance
  1094. * @retval Returned value can be one of the following values:
  1095. * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE
  1096. * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE
  1097. */
  1098. __STATIC_INLINE uint32_t LL_USART_GetBinaryDataLogic(USART_TypeDef *USARTx)
  1099. {
  1100. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_DATAINV));
  1101. }
  1102. /**
  1103. * @brief Configure transfer bit order (either Less or Most Significant Bit First)
  1104. * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
  1105. * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
  1106. * @rmtoll CR2 MSBFIRST LL_USART_SetTransferBitOrder
  1107. * @param USARTx USART Instance
  1108. * @param BitOrder This parameter can be one of the following values:
  1109. * @arg @ref LL_USART_BITORDER_LSBFIRST
  1110. * @arg @ref LL_USART_BITORDER_MSBFIRST
  1111. * @retval None
  1112. */
  1113. __STATIC_INLINE void LL_USART_SetTransferBitOrder(USART_TypeDef *USARTx, uint32_t BitOrder)
  1114. {
  1115. MODIFY_REG(USARTx->CR2, USART_CR2_MSBFIRST, BitOrder);
  1116. }
  1117. /**
  1118. * @brief Return transfer bit order (either Less or Most Significant Bit First)
  1119. * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
  1120. * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
  1121. * @rmtoll CR2 MSBFIRST LL_USART_GetTransferBitOrder
  1122. * @param USARTx USART Instance
  1123. * @retval Returned value can be one of the following values:
  1124. * @arg @ref LL_USART_BITORDER_LSBFIRST
  1125. * @arg @ref LL_USART_BITORDER_MSBFIRST
  1126. */
  1127. __STATIC_INLINE uint32_t LL_USART_GetTransferBitOrder(USART_TypeDef *USARTx)
  1128. {
  1129. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_MSBFIRST));
  1130. }
  1131. /**
  1132. * @brief Enable Auto Baud-Rate Detection
  1133. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  1134. * Auto Baud Rate detection feature is supported by the USARTx instance.
  1135. * @rmtoll CR2 ABREN LL_USART_EnableAutoBaudRate
  1136. * @param USARTx USART Instance
  1137. * @retval None
  1138. */
  1139. __STATIC_INLINE void LL_USART_EnableAutoBaudRate(USART_TypeDef *USARTx)
  1140. {
  1141. SET_BIT(USARTx->CR2, USART_CR2_ABREN);
  1142. }
  1143. /**
  1144. * @brief Disable Auto Baud-Rate Detection
  1145. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  1146. * Auto Baud Rate detection feature is supported by the USARTx instance.
  1147. * @rmtoll CR2 ABREN LL_USART_DisableAutoBaudRate
  1148. * @param USARTx USART Instance
  1149. * @retval None
  1150. */
  1151. __STATIC_INLINE void LL_USART_DisableAutoBaudRate(USART_TypeDef *USARTx)
  1152. {
  1153. CLEAR_BIT(USARTx->CR2, USART_CR2_ABREN);
  1154. }
  1155. /**
  1156. * @brief Indicate if Auto Baud-Rate Detection mechanism is enabled
  1157. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  1158. * Auto Baud Rate detection feature is supported by the USARTx instance.
  1159. * @rmtoll CR2 ABREN LL_USART_IsEnabledAutoBaud
  1160. * @param USARTx USART Instance
  1161. * @retval State of bit (1 or 0).
  1162. */
  1163. __STATIC_INLINE uint32_t LL_USART_IsEnabledAutoBaud(USART_TypeDef *USARTx)
  1164. {
  1165. return (READ_BIT(USARTx->CR2, USART_CR2_ABREN) == (USART_CR2_ABREN));
  1166. }
  1167. /**
  1168. * @brief Set Auto Baud-Rate mode bits
  1169. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  1170. * Auto Baud Rate detection feature is supported by the USARTx instance.
  1171. * @rmtoll CR2 ABRMODE LL_USART_SetAutoBaudRateMode
  1172. * @param USARTx USART Instance
  1173. * @param AutoBaudRateMode This parameter can be one of the following values:
  1174. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT
  1175. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE
  1176. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME (*)
  1177. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME (*)
  1178. *
  1179. * (*) Values not available on all devices
  1180. * @retval None
  1181. */
  1182. __STATIC_INLINE void LL_USART_SetAutoBaudRateMode(USART_TypeDef *USARTx, uint32_t AutoBaudRateMode)
  1183. {
  1184. MODIFY_REG(USARTx->CR2, USART_CR2_ABRMODE, AutoBaudRateMode);
  1185. }
  1186. /**
  1187. * @brief Return Auto Baud-Rate mode
  1188. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  1189. * Auto Baud Rate detection feature is supported by the USARTx instance.
  1190. * @rmtoll CR2 ABRMODE LL_USART_GetAutoBaudRateMode
  1191. * @param USARTx USART Instance
  1192. * @retval Returned value can be one of the following values:
  1193. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT
  1194. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE
  1195. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME (*)
  1196. * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME (*)
  1197. *
  1198. * (*) Values not available on all devices
  1199. */
  1200. __STATIC_INLINE uint32_t LL_USART_GetAutoBaudRateMode(USART_TypeDef *USARTx)
  1201. {
  1202. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ABRMODE));
  1203. }
  1204. /**
  1205. * @brief Enable Receiver Timeout
  1206. * @rmtoll CR2 RTOEN LL_USART_EnableRxTimeout
  1207. * @param USARTx USART Instance
  1208. * @retval None
  1209. */
  1210. __STATIC_INLINE void LL_USART_EnableRxTimeout(USART_TypeDef *USARTx)
  1211. {
  1212. SET_BIT(USARTx->CR2, USART_CR2_RTOEN);
  1213. }
  1214. /**
  1215. * @brief Disable Receiver Timeout
  1216. * @rmtoll CR2 RTOEN LL_USART_DisableRxTimeout
  1217. * @param USARTx USART Instance
  1218. * @retval None
  1219. */
  1220. __STATIC_INLINE void LL_USART_DisableRxTimeout(USART_TypeDef *USARTx)
  1221. {
  1222. CLEAR_BIT(USARTx->CR2, USART_CR2_RTOEN);
  1223. }
  1224. /**
  1225. * @brief Indicate if Receiver Timeout feature is enabled
  1226. * @rmtoll CR2 RTOEN LL_USART_IsEnabledRxTimeout
  1227. * @param USARTx USART Instance
  1228. * @retval State of bit (1 or 0).
  1229. */
  1230. __STATIC_INLINE uint32_t LL_USART_IsEnabledRxTimeout(USART_TypeDef *USARTx)
  1231. {
  1232. return (READ_BIT(USARTx->CR2, USART_CR2_RTOEN) == (USART_CR2_RTOEN));
  1233. }
  1234. /**
  1235. * @brief Set Address of the USART node.
  1236. * @note This is used in multiprocessor communication during Mute mode or Stop mode,
  1237. * for wake up with address mark detection.
  1238. * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7.
  1239. * (b7-b4 should be set to 0)
  1240. * 8bits address node is used when 7-bit Address Detection is selected in ADDM7.
  1241. * (This is used in multiprocessor communication during Mute mode or Stop mode,
  1242. * for wake up with 7-bit address mark detection.
  1243. * The MSB of the character sent by the transmitter should be equal to 1.
  1244. * It may also be used for character detection during normal reception,
  1245. * Mute mode inactive (for example, end of block detection in ModBus protocol).
  1246. * In this case, the whole received character (8-bit) is compared to the ADD[7:0]
  1247. * value and CMF flag is set on match)
  1248. * @rmtoll CR2 ADD LL_USART_ConfigNodeAddress\n
  1249. * CR2 ADDM7 LL_USART_ConfigNodeAddress
  1250. * @param USARTx USART Instance
  1251. * @param AddressLen This parameter can be one of the following values:
  1252. * @arg @ref LL_USART_ADDRESS_DETECT_4B
  1253. * @arg @ref LL_USART_ADDRESS_DETECT_7B
  1254. * @param NodeAddress 4 or 7 bit Address of the USART node.
  1255. * @retval None
  1256. */
  1257. __STATIC_INLINE void LL_USART_ConfigNodeAddress(USART_TypeDef *USARTx, uint32_t AddressLen, uint32_t NodeAddress)
  1258. {
  1259. MODIFY_REG(USARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7,
  1260. (uint32_t)(AddressLen | (NodeAddress << USART_CR2_ADD_Pos)));
  1261. }
  1262. /**
  1263. * @brief Return 8 bit Address of the USART node as set in ADD field of CR2.
  1264. * @note If 4-bit Address Detection is selected in ADDM7,
  1265. * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant)
  1266. * If 7-bit Address Detection is selected in ADDM7,
  1267. * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant)
  1268. * @rmtoll CR2 ADD LL_USART_GetNodeAddress
  1269. * @param USARTx USART Instance
  1270. * @retval Address of the USART node (Value between Min_Data=0 and Max_Data=255)
  1271. */
  1272. __STATIC_INLINE uint32_t LL_USART_GetNodeAddress(USART_TypeDef *USARTx)
  1273. {
  1274. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD) >> USART_CR2_ADD_Pos);
  1275. }
  1276. /**
  1277. * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit)
  1278. * @rmtoll CR2 ADDM7 LL_USART_GetNodeAddressLen
  1279. * @param USARTx USART Instance
  1280. * @retval Returned value can be one of the following values:
  1281. * @arg @ref LL_USART_ADDRESS_DETECT_4B
  1282. * @arg @ref LL_USART_ADDRESS_DETECT_7B
  1283. */
  1284. __STATIC_INLINE uint32_t LL_USART_GetNodeAddressLen(USART_TypeDef *USARTx)
  1285. {
  1286. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADDM7));
  1287. }
  1288. /**
  1289. * @brief Enable RTS HW Flow Control
  1290. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  1291. * Hardware Flow control feature is supported by the USARTx instance.
  1292. * @rmtoll CR3 RTSE LL_USART_EnableRTSHWFlowCtrl
  1293. * @param USARTx USART Instance
  1294. * @retval None
  1295. */
  1296. __STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx)
  1297. {
  1298. SET_BIT(USARTx->CR3, USART_CR3_RTSE);
  1299. }
  1300. /**
  1301. * @brief Disable RTS HW Flow Control
  1302. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  1303. * Hardware Flow control feature is supported by the USARTx instance.
  1304. * @rmtoll CR3 RTSE LL_USART_DisableRTSHWFlowCtrl
  1305. * @param USARTx USART Instance
  1306. * @retval None
  1307. */
  1308. __STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx)
  1309. {
  1310. CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE);
  1311. }
  1312. /**
  1313. * @brief Enable CTS HW Flow Control
  1314. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  1315. * Hardware Flow control feature is supported by the USARTx instance.
  1316. * @rmtoll CR3 CTSE LL_USART_EnableCTSHWFlowCtrl
  1317. * @param USARTx USART Instance
  1318. * @retval None
  1319. */
  1320. __STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx)
  1321. {
  1322. SET_BIT(USARTx->CR3, USART_CR3_CTSE);
  1323. }
  1324. /**
  1325. * @brief Disable CTS HW Flow Control
  1326. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  1327. * Hardware Flow control feature is supported by the USARTx instance.
  1328. * @rmtoll CR3 CTSE LL_USART_DisableCTSHWFlowCtrl
  1329. * @param USARTx USART Instance
  1330. * @retval None
  1331. */
  1332. __STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx)
  1333. {
  1334. CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE);
  1335. }
  1336. /**
  1337. * @brief Configure HW Flow Control mode (both CTS and RTS)
  1338. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  1339. * Hardware Flow control feature is supported by the USARTx instance.
  1340. * @rmtoll CR3 RTSE LL_USART_SetHWFlowCtrl\n
  1341. * CR3 CTSE LL_USART_SetHWFlowCtrl
  1342. * @param USARTx USART Instance
  1343. * @param HardwareFlowControl This parameter can be one of the following values:
  1344. * @arg @ref LL_USART_HWCONTROL_NONE
  1345. * @arg @ref LL_USART_HWCONTROL_RTS
  1346. * @arg @ref LL_USART_HWCONTROL_CTS
  1347. * @arg @ref LL_USART_HWCONTROL_RTS_CTS
  1348. * @retval None
  1349. */
  1350. __STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HardwareFlowControl)
  1351. {
  1352. MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl);
  1353. }
  1354. /**
  1355. * @brief Return HW Flow Control configuration (both CTS and RTS)
  1356. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  1357. * Hardware Flow control feature is supported by the USARTx instance.
  1358. * @rmtoll CR3 RTSE LL_USART_GetHWFlowCtrl\n
  1359. * CR3 CTSE LL_USART_GetHWFlowCtrl
  1360. * @param USARTx USART Instance
  1361. * @retval Returned value can be one of the following values:
  1362. * @arg @ref LL_USART_HWCONTROL_NONE
  1363. * @arg @ref LL_USART_HWCONTROL_RTS
  1364. * @arg @ref LL_USART_HWCONTROL_CTS
  1365. * @arg @ref LL_USART_HWCONTROL_RTS_CTS
  1366. */
  1367. __STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(USART_TypeDef *USARTx)
  1368. {
  1369. return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE));
  1370. }
  1371. /**
  1372. * @brief Enable One bit sampling method
  1373. * @rmtoll CR3 ONEBIT LL_USART_EnableOneBitSamp
  1374. * @param USARTx USART Instance
  1375. * @retval None
  1376. */
  1377. __STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx)
  1378. {
  1379. SET_BIT(USARTx->CR3, USART_CR3_ONEBIT);
  1380. }
  1381. /**
  1382. * @brief Disable One bit sampling method
  1383. * @rmtoll CR3 ONEBIT LL_USART_DisableOneBitSamp
  1384. * @param USARTx USART Instance
  1385. * @retval None
  1386. */
  1387. __STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx)
  1388. {
  1389. CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT);
  1390. }
  1391. /**
  1392. * @brief Indicate if One bit sampling method is enabled
  1393. * @rmtoll CR3 ONEBIT LL_USART_IsEnabledOneBitSamp
  1394. * @param USARTx USART Instance
  1395. * @retval State of bit (1 or 0).
  1396. */
  1397. __STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(USART_TypeDef *USARTx)
  1398. {
  1399. return (READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT));
  1400. }
  1401. /**
  1402. * @brief Enable Overrun detection
  1403. * @rmtoll CR3 OVRDIS LL_USART_EnableOverrunDetect
  1404. * @param USARTx USART Instance
  1405. * @retval None
  1406. */
  1407. __STATIC_INLINE void LL_USART_EnableOverrunDetect(USART_TypeDef *USARTx)
  1408. {
  1409. CLEAR_BIT(USARTx->CR3, USART_CR3_OVRDIS);
  1410. }
  1411. /**
  1412. * @brief Disable Overrun detection
  1413. * @rmtoll CR3 OVRDIS LL_USART_DisableOverrunDetect
  1414. * @param USARTx USART Instance
  1415. * @retval None
  1416. */
  1417. __STATIC_INLINE void LL_USART_DisableOverrunDetect(USART_TypeDef *USARTx)
  1418. {
  1419. SET_BIT(USARTx->CR3, USART_CR3_OVRDIS);
  1420. }
  1421. /**
  1422. * @brief Indicate if Overrun detection is enabled
  1423. * @rmtoll CR3 OVRDIS LL_USART_IsEnabledOverrunDetect
  1424. * @param USARTx USART Instance
  1425. * @retval State of bit (1 or 0).
  1426. */
  1427. __STATIC_INLINE uint32_t LL_USART_IsEnabledOverrunDetect(USART_TypeDef *USARTx)
  1428. {
  1429. return (READ_BIT(USARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS);
  1430. }
  1431. #if defined(USART_WUSM_SUPPORT)
  1432. /**
  1433. * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits)
  1434. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  1435. * Wake-up from Stop mode feature is supported by the USARTx instance.
  1436. * @rmtoll CR3 WUS LL_USART_SetWKUPType
  1437. * @param USARTx USART Instance
  1438. * @param Type This parameter can be one of the following values:
  1439. * @arg @ref LL_USART_WAKEUP_ON_ADDRESS
  1440. * @arg @ref LL_USART_WAKEUP_ON_STARTBIT
  1441. * @arg @ref LL_USART_WAKEUP_ON_RXNE
  1442. * @retval None
  1443. */
  1444. __STATIC_INLINE void LL_USART_SetWKUPType(USART_TypeDef *USARTx, uint32_t Type)
  1445. {
  1446. MODIFY_REG(USARTx->CR3, USART_CR3_WUS, Type);
  1447. }
  1448. /**
  1449. * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits)
  1450. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  1451. * Wake-up from Stop mode feature is supported by the USARTx instance.
  1452. * @rmtoll CR3 WUS LL_USART_GetWKUPType
  1453. * @param USARTx USART Instance
  1454. * @retval Returned value can be one of the following values:
  1455. * @arg @ref LL_USART_WAKEUP_ON_ADDRESS
  1456. * @arg @ref LL_USART_WAKEUP_ON_STARTBIT
  1457. * @arg @ref LL_USART_WAKEUP_ON_RXNE
  1458. */
  1459. __STATIC_INLINE uint32_t LL_USART_GetWKUPType(USART_TypeDef *USARTx)
  1460. {
  1461. return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_WUS));
  1462. }
  1463. #endif
  1464. /**
  1465. * @brief Configure USART BRR register for achieving expected Baud Rate value.
  1466. * @note Compute and set USARTDIV value in BRR Register (full BRR content)
  1467. * according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values
  1468. * @note Peripheral clock and Baud rate values provided as function parameters should be valid
  1469. * (Baud rate value != 0)
  1470. * @note In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d.
  1471. * @rmtoll BRR BRR LL_USART_SetBaudRate
  1472. * @param USARTx USART Instance
  1473. * @param PeriphClk Peripheral Clock
  1474. * @param OverSampling This parameter can be one of the following values:
  1475. * @arg @ref LL_USART_OVERSAMPLING_16
  1476. * @arg @ref LL_USART_OVERSAMPLING_8
  1477. * @param BaudRate Baud Rate
  1478. * @retval None
  1479. */
  1480. __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling,
  1481. uint32_t BaudRate)
  1482. {
  1483. register uint32_t usartdiv = 0x0U;
  1484. register uint32_t brrtemp = 0x0U;
  1485. if (OverSampling == LL_USART_OVERSAMPLING_8)
  1486. {
  1487. usartdiv = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, BaudRate));
  1488. brrtemp = usartdiv & 0xFFF0U;
  1489. brrtemp |= (uint16_t)((usartdiv & (uint16_t)0x000FU) >> 1U);
  1490. USARTx->BRR = brrtemp;
  1491. }
  1492. else
  1493. {
  1494. USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate));
  1495. }
  1496. }
  1497. /**
  1498. * @brief Return current Baud Rate value, according to USARTDIV present in BRR register
  1499. * (full BRR content), and to used Peripheral Clock and Oversampling mode values
  1500. * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned.
  1501. * @note In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d.
  1502. * @rmtoll BRR BRR LL_USART_GetBaudRate
  1503. * @param USARTx USART Instance
  1504. * @param PeriphClk Peripheral Clock
  1505. * @param OverSampling This parameter can be one of the following values:
  1506. * @arg @ref LL_USART_OVERSAMPLING_16
  1507. * @arg @ref LL_USART_OVERSAMPLING_8
  1508. * @retval Baud Rate
  1509. */
  1510. __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling)
  1511. {
  1512. register uint32_t usartdiv = 0x0U;
  1513. register uint32_t brrresult = 0x0U;
  1514. usartdiv = USARTx->BRR;
  1515. if (OverSampling == LL_USART_OVERSAMPLING_8)
  1516. {
  1517. if ((usartdiv & 0xFFF7U) != 0U)
  1518. {
  1519. usartdiv = (uint16_t)((usartdiv & 0xFFF0U) | ((usartdiv & 0x0007U) << 1U)) ;
  1520. brrresult = (PeriphClk * 2U) / usartdiv;
  1521. }
  1522. }
  1523. else
  1524. {
  1525. if ((usartdiv & 0xFFFFU) != 0U)
  1526. {
  1527. brrresult = PeriphClk / usartdiv;
  1528. }
  1529. }
  1530. return (brrresult);
  1531. }
  1532. /**
  1533. * @brief Set Receiver Time Out Value (expressed in nb of bits duration)
  1534. * @rmtoll RTOR RTO LL_USART_SetRxTimeout
  1535. * @param USARTx USART Instance
  1536. * @param Timeout Value between Min_Data=0x00 and Max_Data=0x00FFFFFF
  1537. * @retval None
  1538. */
  1539. __STATIC_INLINE void LL_USART_SetRxTimeout(USART_TypeDef *USARTx, uint32_t Timeout)
  1540. {
  1541. MODIFY_REG(USARTx->RTOR, USART_RTOR_RTO, Timeout);
  1542. }
  1543. /**
  1544. * @brief Get Receiver Time Out Value (expressed in nb of bits duration)
  1545. * @rmtoll RTOR RTO LL_USART_GetRxTimeout
  1546. * @param USARTx USART Instance
  1547. * @retval Value between Min_Data=0x00 and Max_Data=0x00FFFFFF
  1548. */
  1549. __STATIC_INLINE uint32_t LL_USART_GetRxTimeout(USART_TypeDef *USARTx)
  1550. {
  1551. return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_RTO));
  1552. }
  1553. #if defined(USART_SMARTCARD_SUPPORT)
  1554. /**
  1555. * @brief Set Block Length value in reception
  1556. * @rmtoll RTOR BLEN LL_USART_SetBlockLength
  1557. * @param USARTx USART Instance
  1558. * @param BlockLength Value between Min_Data=0x00 and Max_Data=0xFF
  1559. * @retval None
  1560. */
  1561. __STATIC_INLINE void LL_USART_SetBlockLength(USART_TypeDef *USARTx, uint32_t BlockLength)
  1562. {
  1563. MODIFY_REG(USARTx->RTOR, USART_RTOR_BLEN, BlockLength << USART_RTOR_BLEN_Pos);
  1564. }
  1565. /**
  1566. * @brief Get Block Length value in reception
  1567. * @rmtoll RTOR BLEN LL_USART_GetBlockLength
  1568. * @param USARTx USART Instance
  1569. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  1570. */
  1571. __STATIC_INLINE uint32_t LL_USART_GetBlockLength(USART_TypeDef *USARTx)
  1572. {
  1573. return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_BLEN) >> USART_RTOR_BLEN_Pos);
  1574. }
  1575. #endif
  1576. /**
  1577. * @}
  1578. */
  1579. #if defined(USART_IRDA_SUPPORT)
  1580. /** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature
  1581. * @{
  1582. */
  1583. /**
  1584. * @brief Enable IrDA mode
  1585. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1586. * IrDA feature is supported by the USARTx instance.
  1587. * @rmtoll CR3 IREN LL_USART_EnableIrda
  1588. * @param USARTx USART Instance
  1589. * @retval None
  1590. */
  1591. __STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx)
  1592. {
  1593. SET_BIT(USARTx->CR3, USART_CR3_IREN);
  1594. }
  1595. /**
  1596. * @brief Disable IrDA mode
  1597. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1598. * IrDA feature is supported by the USARTx instance.
  1599. * @rmtoll CR3 IREN LL_USART_DisableIrda
  1600. * @param USARTx USART Instance
  1601. * @retval None
  1602. */
  1603. __STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx)
  1604. {
  1605. CLEAR_BIT(USARTx->CR3, USART_CR3_IREN);
  1606. }
  1607. /**
  1608. * @brief Indicate if IrDA mode is enabled
  1609. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1610. * IrDA feature is supported by the USARTx instance.
  1611. * @rmtoll CR3 IREN LL_USART_IsEnabledIrda
  1612. * @param USARTx USART Instance
  1613. * @retval State of bit (1 or 0).
  1614. */
  1615. __STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(USART_TypeDef *USARTx)
  1616. {
  1617. return (READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN));
  1618. }
  1619. /**
  1620. * @brief Configure IrDA Power Mode (Normal or Low Power)
  1621. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1622. * IrDA feature is supported by the USARTx instance.
  1623. * @rmtoll CR3 IRLP LL_USART_SetIrdaPowerMode
  1624. * @param USARTx USART Instance
  1625. * @param PowerMode This parameter can be one of the following values:
  1626. * @arg @ref LL_USART_IRDA_POWER_NORMAL
  1627. * @arg @ref LL_USART_IRDA_POWER_LOW
  1628. * @retval None
  1629. */
  1630. __STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode)
  1631. {
  1632. MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode);
  1633. }
  1634. /**
  1635. * @brief Retrieve IrDA Power Mode configuration (Normal or Low Power)
  1636. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1637. * IrDA feature is supported by the USARTx instance.
  1638. * @rmtoll CR3 IRLP LL_USART_GetIrdaPowerMode
  1639. * @param USARTx USART Instance
  1640. * @retval Returned value can be one of the following values:
  1641. * @arg @ref LL_USART_IRDA_POWER_NORMAL
  1642. * @arg @ref LL_USART_PHASE_2EDGE
  1643. */
  1644. __STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(USART_TypeDef *USARTx)
  1645. {
  1646. return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP));
  1647. }
  1648. /**
  1649. * @brief Set Irda prescaler value, used for dividing the USART clock source
  1650. * to achieve the Irda Low Power frequency (8 bits value)
  1651. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1652. * IrDA feature is supported by the USARTx instance.
  1653. * @rmtoll GTPR PSC LL_USART_SetIrdaPrescaler
  1654. * @param USARTx USART Instance
  1655. * @param PrescalerValue Value between Min_Data=0x00 and Max_Data=0xFF
  1656. * @retval None
  1657. */
  1658. __STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
  1659. {
  1660. MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue);
  1661. }
  1662. /**
  1663. * @brief Return Irda prescaler value, used for dividing the USART clock source
  1664. * to achieve the Irda Low Power frequency (8 bits value)
  1665. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  1666. * IrDA feature is supported by the USARTx instance.
  1667. * @rmtoll GTPR PSC LL_USART_GetIrdaPrescaler
  1668. * @param USARTx USART Instance
  1669. * @retval Irda prescaler value (Value between Min_Data=0x00 and Max_Data=0xFF)
  1670. */
  1671. __STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(USART_TypeDef *USARTx)
  1672. {
  1673. return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
  1674. }
  1675. /**
  1676. * @}
  1677. */
  1678. #endif
  1679. #if defined(USART_SMARTCARD_SUPPORT)
  1680. /** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature
  1681. * @{
  1682. */
  1683. /**
  1684. * @brief Enable Smartcard NACK transmission
  1685. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1686. * Smartcard feature is supported by the USARTx instance.
  1687. * @rmtoll CR3 NACK LL_USART_EnableSmartcardNACK
  1688. * @param USARTx USART Instance
  1689. * @retval None
  1690. */
  1691. __STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx)
  1692. {
  1693. SET_BIT(USARTx->CR3, USART_CR3_NACK);
  1694. }
  1695. /**
  1696. * @brief Disable Smartcard NACK transmission
  1697. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1698. * Smartcard feature is supported by the USARTx instance.
  1699. * @rmtoll CR3 NACK LL_USART_DisableSmartcardNACK
  1700. * @param USARTx USART Instance
  1701. * @retval None
  1702. */
  1703. __STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx)
  1704. {
  1705. CLEAR_BIT(USARTx->CR3, USART_CR3_NACK);
  1706. }
  1707. /**
  1708. * @brief Indicate if Smartcard NACK transmission is enabled
  1709. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1710. * Smartcard feature is supported by the USARTx instance.
  1711. * @rmtoll CR3 NACK LL_USART_IsEnabledSmartcardNACK
  1712. * @param USARTx USART Instance
  1713. * @retval State of bit (1 or 0).
  1714. */
  1715. __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(USART_TypeDef *USARTx)
  1716. {
  1717. return (READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK));
  1718. }
  1719. /**
  1720. * @brief Enable Smartcard mode
  1721. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1722. * Smartcard feature is supported by the USARTx instance.
  1723. * @rmtoll CR3 SCEN LL_USART_EnableSmartcard
  1724. * @param USARTx USART Instance
  1725. * @retval None
  1726. */
  1727. __STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx)
  1728. {
  1729. SET_BIT(USARTx->CR3, USART_CR3_SCEN);
  1730. }
  1731. /**
  1732. * @brief Disable Smartcard mode
  1733. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1734. * Smartcard feature is supported by the USARTx instance.
  1735. * @rmtoll CR3 SCEN LL_USART_DisableSmartcard
  1736. * @param USARTx USART Instance
  1737. * @retval None
  1738. */
  1739. __STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx)
  1740. {
  1741. CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN);
  1742. }
  1743. /**
  1744. * @brief Indicate if Smartcard mode is enabled
  1745. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1746. * Smartcard feature is supported by the USARTx instance.
  1747. * @rmtoll CR3 SCEN LL_USART_IsEnabledSmartcard
  1748. * @param USARTx USART Instance
  1749. * @retval State of bit (1 or 0).
  1750. */
  1751. __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(USART_TypeDef *USARTx)
  1752. {
  1753. return (READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN));
  1754. }
  1755. /**
  1756. * @brief Set Smartcard Auto-Retry Count value (SCARCNT[2:0] bits)
  1757. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1758. * Smartcard feature is supported by the USARTx instance.
  1759. * @note This bit-field specifies the number of retries in transmit and receive, in Smartcard mode.
  1760. * In transmission mode, it specifies the number of automatic retransmission retries, before
  1761. * generating a transmission error (FE bit set).
  1762. * In reception mode, it specifies the number or erroneous reception trials, before generating a
  1763. * reception error (RXNE and PE bits set)
  1764. * @rmtoll CR3 SCARCNT LL_USART_SetSmartcardAutoRetryCount
  1765. * @param USARTx USART Instance
  1766. * @param AutoRetryCount Value between Min_Data=0 and Max_Data=7
  1767. * @retval None
  1768. */
  1769. __STATIC_INLINE void LL_USART_SetSmartcardAutoRetryCount(USART_TypeDef *USARTx, uint32_t AutoRetryCount)
  1770. {
  1771. MODIFY_REG(USARTx->CR3, USART_CR3_SCARCNT, AutoRetryCount << USART_CR3_SCARCNT_Pos);
  1772. }
  1773. /**
  1774. * @brief Return Smartcard Auto-Retry Count value (SCARCNT[2:0] bits)
  1775. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1776. * Smartcard feature is supported by the USARTx instance.
  1777. * @rmtoll CR3 SCARCNT LL_USART_GetSmartcardAutoRetryCount
  1778. * @param USARTx USART Instance
  1779. * @retval Smartcard Auto-Retry Count value (Value between Min_Data=0 and Max_Data=7)
  1780. */
  1781. __STATIC_INLINE uint32_t LL_USART_GetSmartcardAutoRetryCount(USART_TypeDef *USARTx)
  1782. {
  1783. return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_SCARCNT) >> USART_CR3_SCARCNT_Pos);
  1784. }
  1785. /**
  1786. * @brief Set Smartcard prescaler value, used for dividing the USART clock
  1787. * source to provide the SMARTCARD Clock (5 bits value)
  1788. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1789. * Smartcard feature is supported by the USARTx instance.
  1790. * @rmtoll GTPR PSC LL_USART_SetSmartcardPrescaler
  1791. * @param USARTx USART Instance
  1792. * @param PrescalerValue Value between Min_Data=0 and Max_Data=31
  1793. * @retval None
  1794. */
  1795. __STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
  1796. {
  1797. MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue);
  1798. }
  1799. /**
  1800. * @brief Return Smartcard prescaler value, used for dividing the USART clock
  1801. * source to provide the SMARTCARD Clock (5 bits value)
  1802. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1803. * Smartcard feature is supported by the USARTx instance.
  1804. * @rmtoll GTPR PSC LL_USART_GetSmartcardPrescaler
  1805. * @param USARTx USART Instance
  1806. * @retval Smartcard prescaler value (Value between Min_Data=0 and Max_Data=31)
  1807. */
  1808. __STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(USART_TypeDef *USARTx)
  1809. {
  1810. return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
  1811. }
  1812. /**
  1813. * @brief Set Smartcard Guard time value, expressed in nb of baud clocks periods
  1814. * (GT[7:0] bits : Guard time value)
  1815. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1816. * Smartcard feature is supported by the USARTx instance.
  1817. * @rmtoll GTPR GT LL_USART_SetSmartcardGuardTime
  1818. * @param USARTx USART Instance
  1819. * @param GuardTime Value between Min_Data=0x00 and Max_Data=0xFF
  1820. * @retval None
  1821. */
  1822. __STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime)
  1823. {
  1824. MODIFY_REG(USARTx->GTPR, USART_GTPR_GT, GuardTime << USART_GTPR_GT_Pos);
  1825. }
  1826. /**
  1827. * @brief Return Smartcard Guard time value, expressed in nb of baud clocks periods
  1828. * (GT[7:0] bits : Guard time value)
  1829. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  1830. * Smartcard feature is supported by the USARTx instance.
  1831. * @rmtoll GTPR GT LL_USART_GetSmartcardGuardTime
  1832. * @param USARTx USART Instance
  1833. * @retval Smartcard Guard time value (Value between Min_Data=0x00 and Max_Data=0xFF)
  1834. */
  1835. __STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(USART_TypeDef *USARTx)
  1836. {
  1837. return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_GTPR_GT_Pos);
  1838. }
  1839. /**
  1840. * @}
  1841. */
  1842. #endif
  1843. /** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature
  1844. * @{
  1845. */
  1846. /**
  1847. * @brief Enable Single Wire Half-Duplex mode
  1848. * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
  1849. * Half-Duplex mode is supported by the USARTx instance.
  1850. * @rmtoll CR3 HDSEL LL_USART_EnableHalfDuplex
  1851. * @param USARTx USART Instance
  1852. * @retval None
  1853. */
  1854. __STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx)
  1855. {
  1856. SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
  1857. }
  1858. /**
  1859. * @brief Disable Single Wire Half-Duplex mode
  1860. * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
  1861. * Half-Duplex mode is supported by the USARTx instance.
  1862. * @rmtoll CR3 HDSEL LL_USART_DisableHalfDuplex
  1863. * @param USARTx USART Instance
  1864. * @retval None
  1865. */
  1866. __STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx)
  1867. {
  1868. CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL);
  1869. }
  1870. /**
  1871. * @brief Indicate if Single Wire Half-Duplex mode is enabled
  1872. * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
  1873. * Half-Duplex mode is supported by the USARTx instance.
  1874. * @rmtoll CR3 HDSEL LL_USART_IsEnabledHalfDuplex
  1875. * @param USARTx USART Instance
  1876. * @retval State of bit (1 or 0).
  1877. */
  1878. __STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(USART_TypeDef *USARTx)
  1879. {
  1880. return (READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL));
  1881. }
  1882. /**
  1883. * @}
  1884. */
  1885. #if defined(USART_LIN_SUPPORT)
  1886. /** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature
  1887. * @{
  1888. */
  1889. /**
  1890. * @brief Set LIN Break Detection Length
  1891. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  1892. * LIN feature is supported by the USARTx instance.
  1893. * @rmtoll CR2 LBDL LL_USART_SetLINBrkDetectionLen
  1894. * @param USARTx USART Instance
  1895. * @param LINBDLength This parameter can be one of the following values:
  1896. * @arg @ref LL_USART_LINBREAK_DETECT_10B
  1897. * @arg @ref LL_USART_LINBREAK_DETECT_11B
  1898. * @retval None
  1899. */
  1900. __STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength)
  1901. {
  1902. MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength);
  1903. }
  1904. /**
  1905. * @brief Return LIN Break Detection Length
  1906. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  1907. * LIN feature is supported by the USARTx instance.
  1908. * @rmtoll CR2 LBDL LL_USART_GetLINBrkDetectionLen
  1909. * @param USARTx USART Instance
  1910. * @retval Returned value can be one of the following values:
  1911. * @arg @ref LL_USART_LINBREAK_DETECT_10B
  1912. * @arg @ref LL_USART_LINBREAK_DETECT_11B
  1913. */
  1914. __STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(USART_TypeDef *USARTx)
  1915. {
  1916. return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL));
  1917. }
  1918. /**
  1919. * @brief Enable LIN mode
  1920. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  1921. * LIN feature is supported by the USARTx instance.
  1922. * @rmtoll CR2 LINEN LL_USART_EnableLIN
  1923. * @param USARTx USART Instance
  1924. * @retval None
  1925. */
  1926. __STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx)
  1927. {
  1928. SET_BIT(USARTx->CR2, USART_CR2_LINEN);
  1929. }
  1930. /**
  1931. * @brief Disable LIN mode
  1932. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  1933. * LIN feature is supported by the USARTx instance.
  1934. * @rmtoll CR2 LINEN LL_USART_DisableLIN
  1935. * @param USARTx USART Instance
  1936. * @retval None
  1937. */
  1938. __STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx)
  1939. {
  1940. CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN);
  1941. }
  1942. /**
  1943. * @brief Indicate if LIN mode is enabled
  1944. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  1945. * LIN feature is supported by the USARTx instance.
  1946. * @rmtoll CR2 LINEN LL_USART_IsEnabledLIN
  1947. * @param USARTx USART Instance
  1948. * @retval State of bit (1 or 0).
  1949. */
  1950. __STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(USART_TypeDef *USARTx)
  1951. {
  1952. return (READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN));
  1953. }
  1954. /**
  1955. * @}
  1956. */
  1957. #endif
  1958. /** @defgroup USART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature
  1959. * @{
  1960. */
  1961. /**
  1962. * @brief Set DEDT (Driver Enable De-Assertion Time), Time value expressed on 5 bits ([4:0] bits).
  1963. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  1964. * Driver Enable feature is supported by the USARTx instance.
  1965. * @rmtoll CR1 DEDT LL_USART_SetDEDeassertionTime
  1966. * @param USARTx USART Instance
  1967. * @param Time Value between Min_Data=0 and Max_Data=31
  1968. * @retval None
  1969. */
  1970. __STATIC_INLINE void LL_USART_SetDEDeassertionTime(USART_TypeDef *USARTx, uint32_t Time)
  1971. {
  1972. MODIFY_REG(USARTx->CR1, USART_CR1_DEDT, Time << USART_CR1_DEDT_Pos);
  1973. }
  1974. /**
  1975. * @brief Return DEDT (Driver Enable De-Assertion Time)
  1976. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  1977. * Driver Enable feature is supported by the USARTx instance.
  1978. * @rmtoll CR1 DEDT LL_USART_GetDEDeassertionTime
  1979. * @param USARTx USART Instance
  1980. * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31
  1981. */
  1982. __STATIC_INLINE uint32_t LL_USART_GetDEDeassertionTime(USART_TypeDef *USARTx)
  1983. {
  1984. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEDT) >> USART_CR1_DEDT_Pos);
  1985. }
  1986. /**
  1987. * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits).
  1988. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  1989. * Driver Enable feature is supported by the USARTx instance.
  1990. * @rmtoll CR1 DEAT LL_USART_SetDEAssertionTime
  1991. * @param USARTx USART Instance
  1992. * @param Time Value between Min_Data=0 and Max_Data=31
  1993. * @retval None
  1994. */
  1995. __STATIC_INLINE void LL_USART_SetDEAssertionTime(USART_TypeDef *USARTx, uint32_t Time)
  1996. {
  1997. MODIFY_REG(USARTx->CR1, USART_CR1_DEAT, Time << USART_CR1_DEAT_Pos);
  1998. }
  1999. /**
  2000. * @brief Return DEAT (Driver Enable Assertion Time)
  2001. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  2002. * Driver Enable feature is supported by the USARTx instance.
  2003. * @rmtoll CR1 DEAT LL_USART_GetDEAssertionTime
  2004. * @param USARTx USART Instance
  2005. * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31
  2006. */
  2007. __STATIC_INLINE uint32_t LL_USART_GetDEAssertionTime(USART_TypeDef *USARTx)
  2008. {
  2009. return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEAT) >> USART_CR1_DEAT_Pos);
  2010. }
  2011. /**
  2012. * @brief Enable Driver Enable (DE) Mode
  2013. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  2014. * Driver Enable feature is supported by the USARTx instance.
  2015. * @rmtoll CR3 DEM LL_USART_EnableDEMode
  2016. * @param USARTx USART Instance
  2017. * @retval None
  2018. */
  2019. __STATIC_INLINE void LL_USART_EnableDEMode(USART_TypeDef *USARTx)
  2020. {
  2021. SET_BIT(USARTx->CR3, USART_CR3_DEM);
  2022. }
  2023. /**
  2024. * @brief Disable Driver Enable (DE) Mode
  2025. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  2026. * Driver Enable feature is supported by the USARTx instance.
  2027. * @rmtoll CR3 DEM LL_USART_DisableDEMode
  2028. * @param USARTx USART Instance
  2029. * @retval None
  2030. */
  2031. __STATIC_INLINE void LL_USART_DisableDEMode(USART_TypeDef *USARTx)
  2032. {
  2033. CLEAR_BIT(USARTx->CR3, USART_CR3_DEM);
  2034. }
  2035. /**
  2036. * @brief Indicate if Driver Enable (DE) Mode is enabled
  2037. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  2038. * Driver Enable feature is supported by the USARTx instance.
  2039. * @rmtoll CR3 DEM LL_USART_IsEnabledDEMode
  2040. * @param USARTx USART Instance
  2041. * @retval State of bit (1 or 0).
  2042. */
  2043. __STATIC_INLINE uint32_t LL_USART_IsEnabledDEMode(USART_TypeDef *USARTx)
  2044. {
  2045. return (READ_BIT(USARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM));
  2046. }
  2047. /**
  2048. * @brief Select Driver Enable Polarity
  2049. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  2050. * Driver Enable feature is supported by the USARTx instance.
  2051. * @rmtoll CR3 DEP LL_USART_SetDESignalPolarity
  2052. * @param USARTx USART Instance
  2053. * @param Polarity This parameter can be one of the following values:
  2054. * @arg @ref LL_USART_DE_POLARITY_HIGH
  2055. * @arg @ref LL_USART_DE_POLARITY_LOW
  2056. * @retval None
  2057. */
  2058. __STATIC_INLINE void LL_USART_SetDESignalPolarity(USART_TypeDef *USARTx, uint32_t Polarity)
  2059. {
  2060. MODIFY_REG(USARTx->CR3, USART_CR3_DEP, Polarity);
  2061. }
  2062. /**
  2063. * @brief Return Driver Enable Polarity
  2064. * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
  2065. * Driver Enable feature is supported by the USARTx instance.
  2066. * @rmtoll CR3 DEP LL_USART_GetDESignalPolarity
  2067. * @param USARTx USART Instance
  2068. * @retval Returned value can be one of the following values:
  2069. * @arg @ref LL_USART_DE_POLARITY_HIGH
  2070. * @arg @ref LL_USART_DE_POLARITY_LOW
  2071. */
  2072. __STATIC_INLINE uint32_t LL_USART_GetDESignalPolarity(USART_TypeDef *USARTx)
  2073. {
  2074. return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_DEP));
  2075. }
  2076. /**
  2077. * @}
  2078. */
  2079. /** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services
  2080. * @{
  2081. */
  2082. /**
  2083. * @brief Perform basic configuration of USART for enabling use in Asynchronous Mode (UART)
  2084. * @note In UART mode, the following bits must be kept cleared:
  2085. * - LINEN bit in the USART_CR2 register (if LIN feature is supported),
  2086. * - CLKEN bit in the USART_CR2 register,
  2087. * - SCEN bit in the USART_CR3 register (if Smartcard feature is supported),
  2088. * - IREN bit in the USART_CR3 register (if Irda feature is supported),
  2089. * - HDSEL bit in the USART_CR3 register.
  2090. * @note Call of this function is equivalent to following function call sequence :
  2091. * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function (if LIN feature is supported)
  2092. * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
  2093. * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function (if Smartcard feature is supported)
  2094. * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function (if Irda feature is supported)
  2095. * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
  2096. * @note Other remaining configurations items related to Asynchronous Mode
  2097. * (as Baud Rate, Word length, Parity, ...) should be set using
  2098. * dedicated functions
  2099. * @rmtoll CR2 LINEN LL_USART_ConfigAsyncMode\n
  2100. * CR2 CLKEN LL_USART_ConfigAsyncMode\n
  2101. * CR3 SCEN LL_USART_ConfigAsyncMode\n
  2102. * CR3 IREN LL_USART_ConfigAsyncMode\n
  2103. * CR3 HDSEL LL_USART_ConfigAsyncMode
  2104. * @param USARTx USART Instance
  2105. * @retval None
  2106. */
  2107. __STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx)
  2108. {
  2109. /* In Asynchronous mode, the following bits must be kept cleared:
  2110. - LINEN (if LIN feature is supported), CLKEN bits in the USART_CR2 register,
  2111. - SCEN (if Smartcard feature is supported), IREN (if Irda feature is supported) and HDSEL bits in the USART_CR3 register.*/
  2112. #if defined(USART_LIN_SUPPORT)
  2113. CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
  2114. #else
  2115. CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN);
  2116. #endif
  2117. #if defined(USART_SMARTCARD_SUPPORT)
  2118. #if defined(USART_IRDA_SUPPORT)
  2119. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
  2120. #else
  2121. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
  2122. #endif
  2123. #else
  2124. #if defined(USART_IRDA_SUPPORT)
  2125. CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL));
  2126. #else
  2127. CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL);
  2128. #endif
  2129. #endif
  2130. }
  2131. /**
  2132. * @brief Perform basic configuration of USART for enabling use in Synchronous Mode
  2133. * @note In Synchronous mode, the following bits must be kept cleared:
  2134. * - LINEN bit in the USART_CR2 register (if LIN feature is supported),
  2135. * - SCEN bit in the USART_CR3 register (if Smartcard feature is supported),
  2136. * - IREN bit in the USART_CR3 register (if Irda feature is supported),
  2137. * - HDSEL bit in the USART_CR3 register.
  2138. * This function also sets the USART in Synchronous mode.
  2139. * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
  2140. * Synchronous mode is supported by the USARTx instance.
  2141. * @note Call of this function is equivalent to following function call sequence :
  2142. * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function (if LIN feature is supported)
  2143. * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function (if Irda feature is supported)
  2144. * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function (if Smartcard feature is supported)
  2145. * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
  2146. * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
  2147. * @note Other remaining configurations items related to Synchronous Mode
  2148. * (as Baud Rate, Word length, Parity, Clock Polarity, ...) should be set using
  2149. * dedicated functions
  2150. * @rmtoll CR2 LINEN LL_USART_ConfigSyncMode\n
  2151. * CR2 CLKEN LL_USART_ConfigSyncMode\n
  2152. * CR3 SCEN LL_USART_ConfigSyncMode\n
  2153. * CR3 IREN LL_USART_ConfigSyncMode\n
  2154. * CR3 HDSEL LL_USART_ConfigSyncMode
  2155. * @param USARTx USART Instance
  2156. * @retval None
  2157. */
  2158. __STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx)
  2159. {
  2160. /* In Synchronous mode, the following bits must be kept cleared:
  2161. - LINEN (if LIN feature is supported) bit in the USART_CR2 register,
  2162. - SCEN (if Smartcard feature is supported), IREN (if Irda feature is supported) and HDSEL bits in the USART_CR3 register.*/
  2163. #if defined(USART_LIN_SUPPORT)
  2164. CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
  2165. #endif
  2166. #if defined(USART_SMARTCARD_SUPPORT)
  2167. #if defined(USART_IRDA_SUPPORT)
  2168. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
  2169. #else
  2170. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
  2171. #endif
  2172. #else
  2173. #if defined(USART_IRDA_SUPPORT)
  2174. CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL));
  2175. #else
  2176. CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL);
  2177. #endif
  2178. #endif
  2179. /* set the UART/USART in Synchronous mode */
  2180. SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
  2181. }
  2182. #if defined(USART_LIN_SUPPORT)
  2183. /**
  2184. * @brief Perform basic configuration of USART for enabling use in LIN Mode
  2185. * @note In LIN mode, the following bits must be kept cleared:
  2186. * - STOP and CLKEN bits in the USART_CR2 register,
  2187. * - SCEN bit in the USART_CR3 register (if Smartcard feature is supported),
  2188. * - IREN bit in the USART_CR3 register (if Irda feature is supported),
  2189. * - HDSEL bit in the USART_CR3 register.
  2190. * This function also set the UART/USART in LIN mode.
  2191. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  2192. * LIN feature is supported by the USARTx instance.
  2193. * @note Call of this function is equivalent to following function call sequence :
  2194. * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
  2195. * - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
  2196. * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function (if Smartcard feature is supported)
  2197. * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function (if Irda feature is supported)
  2198. * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
  2199. * - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function
  2200. * @note Other remaining configurations items related to LIN Mode
  2201. * (as Baud Rate, Word length, LIN Break Detection Length, ...) should be set using
  2202. * dedicated functions
  2203. * @rmtoll CR2 CLKEN LL_USART_ConfigLINMode\n
  2204. * CR2 STOP LL_USART_ConfigLINMode\n
  2205. * CR2 LINEN LL_USART_ConfigLINMode\n
  2206. * CR3 IREN LL_USART_ConfigLINMode\n
  2207. * CR3 SCEN LL_USART_ConfigLINMode\n
  2208. * CR3 HDSEL LL_USART_ConfigLINMode
  2209. * @param USARTx USART Instance
  2210. * @retval None
  2211. */
  2212. __STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx)
  2213. {
  2214. /* In LIN mode, the following bits must be kept cleared:
  2215. - STOP and CLKEN bits in the USART_CR2 register,
  2216. - IREN (if Irda feature is supported), SCEN (if Smartcard feature is supported) and HDSEL bits in the USART_CR3 register.*/
  2217. CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP));
  2218. #if defined(USART_SMARTCARD_SUPPORT)
  2219. #if defined(USART_IRDA_SUPPORT)
  2220. CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL));
  2221. #else
  2222. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
  2223. #endif
  2224. #else
  2225. #if defined(USART_IRDA_SUPPORT)
  2226. CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL));
  2227. #else
  2228. CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL);
  2229. #endif
  2230. #endif
  2231. /* Set the UART/USART in LIN mode */
  2232. SET_BIT(USARTx->CR2, USART_CR2_LINEN);
  2233. }
  2234. #endif
  2235. /**
  2236. * @brief Perform basic configuration of USART for enabling use in Half Duplex Mode
  2237. * @note In Half Duplex mode, the following bits must be kept cleared:
  2238. * - LINEN bit in the USART_CR2 register (if LIN feature is supported),
  2239. * - CLKEN bit in the USART_CR2 register,
  2240. * - SCEN bit in the USART_CR3 register (if Smartcard feature is supported),
  2241. * - IREN bit in the USART_CR3 register (if Irda feature is supported),
  2242. * This function also sets the UART/USART in Half Duplex mode.
  2243. * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
  2244. * Half-Duplex mode is supported by the USARTx instance.
  2245. * @note Call of this function is equivalent to following function call sequence :
  2246. * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function (if LIN feature is supported)
  2247. * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
  2248. * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function (if Smartcard feature is supported)
  2249. * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function (if Irda feature is supported)
  2250. * - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function
  2251. * @note Other remaining configurations items related to Half Duplex Mode
  2252. * (as Baud Rate, Word length, Parity, ...) should be set using
  2253. * dedicated functions
  2254. * @rmtoll CR2 LINEN LL_USART_ConfigHalfDuplexMode\n
  2255. * CR2 CLKEN LL_USART_ConfigHalfDuplexMode\n
  2256. * CR3 HDSEL LL_USART_ConfigHalfDuplexMode\n
  2257. * CR3 SCEN LL_USART_ConfigHalfDuplexMode\n
  2258. * CR3 IREN LL_USART_ConfigHalfDuplexMode
  2259. * @param USARTx USART Instance
  2260. * @retval None
  2261. */
  2262. __STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx)
  2263. {
  2264. /* In Half Duplex mode, the following bits must be kept cleared:
  2265. - LINEN (if LIN feature is supported), CLKEN bits in the USART_CR2 register,
  2266. - SCEN (if Smartcard feature is supported) and IREN (if Irda feature is supported) bits in the USART_CR3 register.*/
  2267. #if defined(USART_LIN_SUPPORT)
  2268. CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
  2269. #else
  2270. CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN);
  2271. #endif
  2272. #if defined(USART_SMARTCARD_SUPPORT)
  2273. #if defined(USART_IRDA_SUPPORT)
  2274. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN));
  2275. #else
  2276. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN));
  2277. #endif
  2278. #else
  2279. #if defined(USART_IRDA_SUPPORT)
  2280. CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN));
  2281. #endif
  2282. #endif
  2283. /* set the UART/USART in Half Duplex mode */
  2284. SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
  2285. }
  2286. #if defined(USART_SMARTCARD_SUPPORT)
  2287. /**
  2288. * @brief Perform basic configuration of USART for enabling use in Smartcard Mode
  2289. * @note In Smartcard mode, the following bits must be kept cleared:
  2290. * - LINEN bit in the USART_CR2 register (if LIN feature is supported),
  2291. * - IREN bit in the USART_CR3 register (if Irda feature is supported),
  2292. * - HDSEL bit in the USART_CR3 register.
  2293. * This function also configures Stop bits to 1.5 bits and
  2294. * sets the USART in Smartcard mode (SCEN bit).
  2295. * Clock Output is also enabled (CLKEN).
  2296. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  2297. * Smartcard feature is supported by the USARTx instance.
  2298. * @note Call of this function is equivalent to following function call sequence :
  2299. * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function (if LIN feature is supported)
  2300. * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function (if Irda feature is supported)
  2301. * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
  2302. * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
  2303. * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
  2304. * - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function
  2305. * @note Other remaining configurations items related to Smartcard Mode
  2306. * (as Baud Rate, Word length, Parity, ...) should be set using
  2307. * dedicated functions
  2308. * @rmtoll CR2 LINEN LL_USART_ConfigSmartcardMode\n
  2309. * CR2 STOP LL_USART_ConfigSmartcardMode\n
  2310. * CR2 CLKEN LL_USART_ConfigSmartcardMode\n
  2311. * CR3 HDSEL LL_USART_ConfigSmartcardMode\n
  2312. * CR3 SCEN LL_USART_ConfigSmartcardMode
  2313. * @param USARTx USART Instance
  2314. * @retval None
  2315. */
  2316. __STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx)
  2317. {
  2318. /* In Smartcard mode, the following bits must be kept cleared:
  2319. - LINEN (if LIN feature is supported) bit in the USART_CR2 register,
  2320. - IREN (if Irda feature is supported) and HDSEL bits in the USART_CR3 register.*/
  2321. #if defined(USART_LIN_SUPPORT)
  2322. CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
  2323. #endif
  2324. #if defined(USART_IRDA_SUPPORT)
  2325. CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL));
  2326. #else
  2327. CLEAR_BIT(USARTx->CR3, (USART_CR3_HDSEL));
  2328. #endif
  2329. /* Configure Stop bits to 1.5 bits */
  2330. /* Synchronous mode is activated by default */
  2331. SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN));
  2332. /* set the UART/USART in Smartcard mode */
  2333. SET_BIT(USARTx->CR3, USART_CR3_SCEN);
  2334. }
  2335. #endif
  2336. #if defined(USART_IRDA_SUPPORT)
  2337. /**
  2338. * @brief Perform basic configuration of USART for enabling use in Irda Mode
  2339. * @note In IRDA mode, the following bits must be kept cleared:
  2340. * - LINEN bit in the USART_CR2 register (if LIN feature is supported),
  2341. * - STOP and CLKEN bits in the USART_CR2 register,
  2342. * - SCEN bit in the USART_CR3 register (if Smartcard feature is supported),
  2343. * - HDSEL bit in the USART_CR3 register.
  2344. * This function also sets the UART/USART in IRDA mode (IREN bit).
  2345. * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
  2346. * IrDA feature is supported by the USARTx instance.
  2347. * @note Call of this function is equivalent to following function call sequence :
  2348. * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function (if LIN feature is supported)
  2349. * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
  2350. * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function (if Smartcard feature is supported)
  2351. * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
  2352. * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
  2353. * - Set IREN in CR3 using @ref LL_USART_EnableIrda() function
  2354. * @note Other remaining configurations items related to Irda Mode
  2355. * (as Baud Rate, Word length, Power mode, ...) should be set using
  2356. * dedicated functions
  2357. * @rmtoll CR2 LINEN LL_USART_ConfigIrdaMode\n
  2358. * CR2 CLKEN LL_USART_ConfigIrdaMode\n
  2359. * CR2 STOP LL_USART_ConfigIrdaMode\n
  2360. * CR3 SCEN LL_USART_ConfigIrdaMode\n
  2361. * CR3 HDSEL LL_USART_ConfigIrdaMode\n
  2362. * CR3 IREN LL_USART_ConfigIrdaMode
  2363. * @param USARTx USART Instance
  2364. * @retval None
  2365. */
  2366. __STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx)
  2367. {
  2368. /* In IRDA mode, the following bits must be kept cleared:
  2369. - LINEN (if LIN feature is supported), STOP and CLKEN bits in the USART_CR2 register,
  2370. - SCEN (if Smartcard feature is supported) and HDSEL bits in the USART_CR3 register.*/
  2371. #if defined(USART_LIN_SUPPORT)
  2372. CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP));
  2373. #else
  2374. CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP));
  2375. #endif
  2376. #if defined(USART_SMARTCARD_SUPPORT)
  2377. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
  2378. #else
  2379. CLEAR_BIT(USARTx->CR3, (USART_CR3_HDSEL));
  2380. #endif
  2381. /* set the UART/USART in IRDA mode */
  2382. SET_BIT(USARTx->CR3, USART_CR3_IREN);
  2383. }
  2384. #endif
  2385. /**
  2386. * @brief Perform basic configuration of USART for enabling use in Multi processor Mode
  2387. * (several USARTs connected in a network, one of the USARTs can be the master,
  2388. * its TX output connected to the RX inputs of the other slaves USARTs).
  2389. * @note In MultiProcessor mode, the following bits must be kept cleared:
  2390. * - LINEN bit in the USART_CR2 register (if LIN feature is supported),
  2391. * - CLKEN bit in the USART_CR2 register,
  2392. * - SCEN bit in the USART_CR3 register (if Smartcard feature is supported),
  2393. * - IREN bit in the USART_CR3 register (if Irda feature is supported),
  2394. * - HDSEL bit in the USART_CR3 register.
  2395. * @note Call of this function is equivalent to following function call sequence :
  2396. * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function (if LIN feature is supported)
  2397. * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
  2398. * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function (if Smartcard feature is supported)
  2399. * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function (if Irda feature is supported)
  2400. * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
  2401. * @note Other remaining configurations items related to Multi processor Mode
  2402. * (as Baud Rate, Wake Up Method, Node address, ...) should be set using
  2403. * dedicated functions
  2404. * @rmtoll CR2 LINEN LL_USART_ConfigMultiProcessMode\n
  2405. * CR2 CLKEN LL_USART_ConfigMultiProcessMode\n
  2406. * CR3 SCEN LL_USART_ConfigMultiProcessMode\n
  2407. * CR3 HDSEL LL_USART_ConfigMultiProcessMode\n
  2408. * CR3 IREN LL_USART_ConfigMultiProcessMode
  2409. * @param USARTx USART Instance
  2410. * @retval None
  2411. */
  2412. __STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx)
  2413. {
  2414. /* In Multi Processor mode, the following bits must be kept cleared:
  2415. - LINEN (if LIN feature is supported) and CLKEN bits in the USART_CR2 register,
  2416. - IREN (if Irda feature is supported), SCEN (if Smartcard feature is supported) and HDSEL bits in the USART_CR3 register.*/
  2417. #if defined(USART_LIN_SUPPORT)
  2418. CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
  2419. #else
  2420. CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN);
  2421. #endif
  2422. #if defined(USART_SMARTCARD_SUPPORT)
  2423. #if defined(USART_IRDA_SUPPORT)
  2424. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN));
  2425. #else
  2426. CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
  2427. #endif
  2428. #else
  2429. #if defined(USART_IRDA_SUPPORT)
  2430. CLEAR_BIT(USARTx->CR3, (USART_CR3_HDSEL | USART_CR3_IREN));
  2431. #else
  2432. CLEAR_BIT(USARTx->CR3, (USART_CR3_HDSEL));
  2433. #endif
  2434. #endif
  2435. }
  2436. /**
  2437. * @}
  2438. */
  2439. /** @defgroup USART_LL_EF_FLAG_Management FLAG_Management
  2440. * @{
  2441. */
  2442. /**
  2443. * @brief Check if the USART Parity Error Flag is set or not
  2444. * @rmtoll ISR PE LL_USART_IsActiveFlag_PE
  2445. * @param USARTx USART Instance
  2446. * @retval State of bit (1 or 0).
  2447. */
  2448. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(USART_TypeDef *USARTx)
  2449. {
  2450. return (READ_BIT(USARTx->ISR, USART_ISR_PE) == (USART_ISR_PE));
  2451. }
  2452. /**
  2453. * @brief Check if the USART Framing Error Flag is set or not
  2454. * @rmtoll ISR FE LL_USART_IsActiveFlag_FE
  2455. * @param USARTx USART Instance
  2456. * @retval State of bit (1 or 0).
  2457. */
  2458. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(USART_TypeDef *USARTx)
  2459. {
  2460. return (READ_BIT(USARTx->ISR, USART_ISR_FE) == (USART_ISR_FE));
  2461. }
  2462. /**
  2463. * @brief Check if the USART Noise error detected Flag is set or not
  2464. * @rmtoll ISR NF LL_USART_IsActiveFlag_NE
  2465. * @param USARTx USART Instance
  2466. * @retval State of bit (1 or 0).
  2467. */
  2468. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(USART_TypeDef *USARTx)
  2469. {
  2470. return (READ_BIT(USARTx->ISR, USART_ISR_NE) == (USART_ISR_NE));
  2471. }
  2472. /**
  2473. * @brief Check if the USART OverRun Error Flag is set or not
  2474. * @rmtoll ISR ORE LL_USART_IsActiveFlag_ORE
  2475. * @param USARTx USART Instance
  2476. * @retval State of bit (1 or 0).
  2477. */
  2478. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(USART_TypeDef *USARTx)
  2479. {
  2480. return (READ_BIT(USARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE));
  2481. }
  2482. /**
  2483. * @brief Check if the USART IDLE line detected Flag is set or not
  2484. * @rmtoll ISR IDLE LL_USART_IsActiveFlag_IDLE
  2485. * @param USARTx USART Instance
  2486. * @retval State of bit (1 or 0).
  2487. */
  2488. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(USART_TypeDef *USARTx)
  2489. {
  2490. return (READ_BIT(USARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE));
  2491. }
  2492. /**
  2493. * @brief Check if the USART Read Data Register Not Empty Flag is set or not
  2494. * @rmtoll ISR RXNE LL_USART_IsActiveFlag_RXNE
  2495. * @param USARTx USART Instance
  2496. * @retval State of bit (1 or 0).
  2497. */
  2498. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE(USART_TypeDef *USARTx)
  2499. {
  2500. return (READ_BIT(USARTx->ISR, USART_ISR_RXNE) == (USART_ISR_RXNE));
  2501. }
  2502. /**
  2503. * @brief Check if the USART Transmission Complete Flag is set or not
  2504. * @rmtoll ISR TC LL_USART_IsActiveFlag_TC
  2505. * @param USARTx USART Instance
  2506. * @retval State of bit (1 or 0).
  2507. */
  2508. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(USART_TypeDef *USARTx)
  2509. {
  2510. return (READ_BIT(USARTx->ISR, USART_ISR_TC) == (USART_ISR_TC));
  2511. }
  2512. /**
  2513. * @brief Check if the USART Transmit Data Register Empty Flag is set or not
  2514. * @rmtoll ISR TXE LL_USART_IsActiveFlag_TXE
  2515. * @param USARTx USART Instance
  2516. * @retval State of bit (1 or 0).
  2517. */
  2518. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE(USART_TypeDef *USARTx)
  2519. {
  2520. return (READ_BIT(USARTx->ISR, USART_ISR_TXE) == (USART_ISR_TXE));
  2521. }
  2522. #if defined(USART_LIN_SUPPORT)
  2523. /**
  2524. * @brief Check if the USART LIN Break Detection Flag is set or not
  2525. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  2526. * LIN feature is supported by the USARTx instance.
  2527. * @rmtoll ISR LBDF LL_USART_IsActiveFlag_LBD
  2528. * @param USARTx USART Instance
  2529. * @retval State of bit (1 or 0).
  2530. */
  2531. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(USART_TypeDef *USARTx)
  2532. {
  2533. return (READ_BIT(USARTx->ISR, USART_ISR_LBDF) == (USART_ISR_LBDF));
  2534. }
  2535. #endif
  2536. /**
  2537. * @brief Check if the USART CTS interrupt Flag is set or not
  2538. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  2539. * Hardware Flow control feature is supported by the USARTx instance.
  2540. * @rmtoll ISR CTSIF LL_USART_IsActiveFlag_nCTS
  2541. * @param USARTx USART Instance
  2542. * @retval State of bit (1 or 0).
  2543. */
  2544. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(USART_TypeDef *USARTx)
  2545. {
  2546. return (READ_BIT(USARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF));
  2547. }
  2548. /**
  2549. * @brief Check if the USART CTS Flag is set or not
  2550. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  2551. * Hardware Flow control feature is supported by the USARTx instance.
  2552. * @rmtoll ISR CTS LL_USART_IsActiveFlag_CTS
  2553. * @param USARTx USART Instance
  2554. * @retval State of bit (1 or 0).
  2555. */
  2556. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CTS(USART_TypeDef *USARTx)
  2557. {
  2558. return (READ_BIT(USARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS));
  2559. }
  2560. /**
  2561. * @brief Check if the USART Receiver Time Out Flag is set or not
  2562. * @rmtoll ISR RTOF LL_USART_IsActiveFlag_RTO
  2563. * @param USARTx USART Instance
  2564. * @retval State of bit (1 or 0).
  2565. */
  2566. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RTO(USART_TypeDef *USARTx)
  2567. {
  2568. return (READ_BIT(USARTx->ISR, USART_ISR_RTOF) == (USART_ISR_RTOF));
  2569. }
  2570. #if defined(USART_SMARTCARD_SUPPORT)
  2571. /**
  2572. * @brief Check if the USART End Of Block Flag is set or not
  2573. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  2574. * Smartcard feature is supported by the USARTx instance.
  2575. * @rmtoll ISR EOBF LL_USART_IsActiveFlag_EOB
  2576. * @param USARTx USART Instance
  2577. * @retval State of bit (1 or 0).
  2578. */
  2579. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_EOB(USART_TypeDef *USARTx)
  2580. {
  2581. return (READ_BIT(USARTx->ISR, USART_ISR_EOBF) == (USART_ISR_EOBF));
  2582. }
  2583. #endif
  2584. /**
  2585. * @brief Check if the USART Auto-Baud Rate Error Flag is set or not
  2586. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  2587. * Auto Baud Rate detection feature is supported by the USARTx instance.
  2588. * @rmtoll ISR ABRE LL_USART_IsActiveFlag_ABRE
  2589. * @param USARTx USART Instance
  2590. * @retval State of bit (1 or 0).
  2591. */
  2592. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABRE(USART_TypeDef *USARTx)
  2593. {
  2594. return (READ_BIT(USARTx->ISR, USART_ISR_ABRE) == (USART_ISR_ABRE));
  2595. }
  2596. /**
  2597. * @brief Check if the USART Auto-Baud Rate Flag is set or not
  2598. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  2599. * Auto Baud Rate detection feature is supported by the USARTx instance.
  2600. * @rmtoll ISR ABRF LL_USART_IsActiveFlag_ABR
  2601. * @param USARTx USART Instance
  2602. * @retval State of bit (1 or 0).
  2603. */
  2604. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABR(USART_TypeDef *USARTx)
  2605. {
  2606. return (READ_BIT(USARTx->ISR, USART_ISR_ABRF) == (USART_ISR_ABRF));
  2607. }
  2608. /**
  2609. * @brief Check if the USART Busy Flag is set or not
  2610. * @rmtoll ISR BUSY LL_USART_IsActiveFlag_BUSY
  2611. * @param USARTx USART Instance
  2612. * @retval State of bit (1 or 0).
  2613. */
  2614. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_BUSY(USART_TypeDef *USARTx)
  2615. {
  2616. return (READ_BIT(USARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY));
  2617. }
  2618. /**
  2619. * @brief Check if the USART Character Match Flag is set or not
  2620. * @rmtoll ISR CMF LL_USART_IsActiveFlag_CM
  2621. * @param USARTx USART Instance
  2622. * @retval State of bit (1 or 0).
  2623. */
  2624. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CM(USART_TypeDef *USARTx)
  2625. {
  2626. return (READ_BIT(USARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF));
  2627. }
  2628. /**
  2629. * @brief Check if the USART Send Break Flag is set or not
  2630. * @rmtoll ISR SBKF LL_USART_IsActiveFlag_SBK
  2631. * @param USARTx USART Instance
  2632. * @retval State of bit (1 or 0).
  2633. */
  2634. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(USART_TypeDef *USARTx)
  2635. {
  2636. return (READ_BIT(USARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF));
  2637. }
  2638. /**
  2639. * @brief Check if the USART Receive Wake Up from mute mode Flag is set or not
  2640. * @rmtoll ISR RWU LL_USART_IsActiveFlag_RWU
  2641. * @param USARTx USART Instance
  2642. * @retval State of bit (1 or 0).
  2643. */
  2644. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(USART_TypeDef *USARTx)
  2645. {
  2646. return (READ_BIT(USARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU));
  2647. }
  2648. #if defined(USART_WUSM_SUPPORT)
  2649. /**
  2650. * @brief Check if the USART Wake Up from stop mode Flag is set or not
  2651. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  2652. * Wake-up from Stop mode feature is supported by the USARTx instance.
  2653. * @rmtoll ISR WUF LL_USART_IsActiveFlag_WKUP
  2654. * @param USARTx USART Instance
  2655. * @retval State of bit (1 or 0).
  2656. */
  2657. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_WKUP(USART_TypeDef *USARTx)
  2658. {
  2659. return (READ_BIT(USARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF));
  2660. }
  2661. #endif
  2662. /**
  2663. * @brief Check if the USART Transmit Enable Acknowledge Flag is set or not
  2664. * @rmtoll ISR TEACK LL_USART_IsActiveFlag_TEACK
  2665. * @param USARTx USART Instance
  2666. * @retval State of bit (1 or 0).
  2667. */
  2668. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TEACK(USART_TypeDef *USARTx)
  2669. {
  2670. return (READ_BIT(USARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK));
  2671. }
  2672. /**
  2673. * @brief Check if the USART Receive Enable Acknowledge Flag is set or not
  2674. * @rmtoll ISR REACK LL_USART_IsActiveFlag_REACK
  2675. * @param USARTx USART Instance
  2676. * @retval State of bit (1 or 0).
  2677. */
  2678. __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_REACK(USART_TypeDef *USARTx)
  2679. {
  2680. return (READ_BIT(USARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK));
  2681. }
  2682. /**
  2683. * @brief Clear Parity Error Flag
  2684. * @rmtoll ICR PECF LL_USART_ClearFlag_PE
  2685. * @param USARTx USART Instance
  2686. * @retval None
  2687. */
  2688. __STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx)
  2689. {
  2690. WRITE_REG(USARTx->ICR, USART_ICR_PECF);
  2691. }
  2692. /**
  2693. * @brief Clear Framing Error Flag
  2694. * @rmtoll ICR FECF LL_USART_ClearFlag_FE
  2695. * @param USARTx USART Instance
  2696. * @retval None
  2697. */
  2698. __STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx)
  2699. {
  2700. WRITE_REG(USARTx->ICR, USART_ICR_FECF);
  2701. }
  2702. /**
  2703. * @brief Clear Noise detected Flag
  2704. * @rmtoll ICR NCF LL_USART_ClearFlag_NE
  2705. * @param USARTx USART Instance
  2706. * @retval None
  2707. */
  2708. __STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx)
  2709. {
  2710. WRITE_REG(USARTx->ICR, USART_ICR_NCF);
  2711. }
  2712. /**
  2713. * @brief Clear OverRun Error Flag
  2714. * @rmtoll ICR ORECF LL_USART_ClearFlag_ORE
  2715. * @param USARTx USART Instance
  2716. * @retval None
  2717. */
  2718. __STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx)
  2719. {
  2720. WRITE_REG(USARTx->ICR, USART_ICR_ORECF);
  2721. }
  2722. /**
  2723. * @brief Clear IDLE line detected Flag
  2724. * @rmtoll ICR IDLECF LL_USART_ClearFlag_IDLE
  2725. * @param USARTx USART Instance
  2726. * @retval None
  2727. */
  2728. __STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx)
  2729. {
  2730. WRITE_REG(USARTx->ICR, USART_ICR_IDLECF);
  2731. }
  2732. /**
  2733. * @brief Clear Transmission Complete Flag
  2734. * @rmtoll ICR TCCF LL_USART_ClearFlag_TC
  2735. * @param USARTx USART Instance
  2736. * @retval None
  2737. */
  2738. __STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx)
  2739. {
  2740. WRITE_REG(USARTx->ICR, USART_ICR_TCCF);
  2741. }
  2742. #if defined(USART_LIN_SUPPORT)
  2743. /**
  2744. * @brief Clear LIN Break Detection Flag
  2745. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  2746. * LIN feature is supported by the USARTx instance.
  2747. * @rmtoll ICR LBDCF LL_USART_ClearFlag_LBD
  2748. * @param USARTx USART Instance
  2749. * @retval None
  2750. */
  2751. __STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx)
  2752. {
  2753. WRITE_REG(USARTx->ICR, USART_ICR_LBDCF);
  2754. }
  2755. #endif
  2756. /**
  2757. * @brief Clear CTS Interrupt Flag
  2758. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  2759. * Hardware Flow control feature is supported by the USARTx instance.
  2760. * @rmtoll ICR CTSCF LL_USART_ClearFlag_nCTS
  2761. * @param USARTx USART Instance
  2762. * @retval None
  2763. */
  2764. __STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx)
  2765. {
  2766. WRITE_REG(USARTx->ICR, USART_ICR_CTSCF);
  2767. }
  2768. /**
  2769. * @brief Clear Receiver Time Out Flag
  2770. * @rmtoll ICR RTOCF LL_USART_ClearFlag_RTO
  2771. * @param USARTx USART Instance
  2772. * @retval None
  2773. */
  2774. __STATIC_INLINE void LL_USART_ClearFlag_RTO(USART_TypeDef *USARTx)
  2775. {
  2776. WRITE_REG(USARTx->ICR, USART_ICR_RTOCF);
  2777. }
  2778. #if defined(USART_SMARTCARD_SUPPORT)
  2779. /**
  2780. * @brief Clear End Of Block Flag
  2781. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  2782. * Smartcard feature is supported by the USARTx instance.
  2783. * @rmtoll ICR EOBCF LL_USART_ClearFlag_EOB
  2784. * @param USARTx USART Instance
  2785. * @retval None
  2786. */
  2787. __STATIC_INLINE void LL_USART_ClearFlag_EOB(USART_TypeDef *USARTx)
  2788. {
  2789. WRITE_REG(USARTx->ICR, USART_ICR_EOBCF);
  2790. }
  2791. #endif
  2792. /**
  2793. * @brief Clear Character Match Flag
  2794. * @rmtoll ICR CMCF LL_USART_ClearFlag_CM
  2795. * @param USARTx USART Instance
  2796. * @retval None
  2797. */
  2798. __STATIC_INLINE void LL_USART_ClearFlag_CM(USART_TypeDef *USARTx)
  2799. {
  2800. WRITE_REG(USARTx->ICR, USART_ICR_CMCF);
  2801. }
  2802. #if defined(USART_WUSM_SUPPORT)
  2803. /**
  2804. * @brief Clear Wake Up from stop mode Flag
  2805. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  2806. * Wake-up from Stop mode feature is supported by the USARTx instance.
  2807. * @rmtoll ICR WUCF LL_USART_ClearFlag_WKUP
  2808. * @param USARTx USART Instance
  2809. * @retval None
  2810. */
  2811. __STATIC_INLINE void LL_USART_ClearFlag_WKUP(USART_TypeDef *USARTx)
  2812. {
  2813. WRITE_REG(USARTx->ICR, USART_ICR_WUCF);
  2814. }
  2815. #endif
  2816. /**
  2817. * @}
  2818. */
  2819. /** @defgroup USART_LL_EF_IT_Management IT_Management
  2820. * @{
  2821. */
  2822. /**
  2823. * @brief Enable IDLE Interrupt
  2824. * @rmtoll CR1 IDLEIE LL_USART_EnableIT_IDLE
  2825. * @param USARTx USART Instance
  2826. * @retval None
  2827. */
  2828. __STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx)
  2829. {
  2830. SET_BIT(USARTx->CR1, USART_CR1_IDLEIE);
  2831. }
  2832. /**
  2833. * @brief Enable RX Not Empty Interrupt
  2834. * @rmtoll CR1 RXNEIE LL_USART_EnableIT_RXNE
  2835. * @param USARTx USART Instance
  2836. * @retval None
  2837. */
  2838. __STATIC_INLINE void LL_USART_EnableIT_RXNE(USART_TypeDef *USARTx)
  2839. {
  2840. SET_BIT(USARTx->CR1, USART_CR1_RXNEIE);
  2841. }
  2842. /**
  2843. * @brief Enable Transmission Complete Interrupt
  2844. * @rmtoll CR1 TCIE LL_USART_EnableIT_TC
  2845. * @param USARTx USART Instance
  2846. * @retval None
  2847. */
  2848. __STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx)
  2849. {
  2850. SET_BIT(USARTx->CR1, USART_CR1_TCIE);
  2851. }
  2852. /**
  2853. * @brief Enable TX Empty Interrupt
  2854. * @rmtoll CR1 TXEIE LL_USART_EnableIT_TXE
  2855. * @param USARTx USART Instance
  2856. * @retval None
  2857. */
  2858. __STATIC_INLINE void LL_USART_EnableIT_TXE(USART_TypeDef *USARTx)
  2859. {
  2860. SET_BIT(USARTx->CR1, USART_CR1_TXEIE);
  2861. }
  2862. /**
  2863. * @brief Enable Parity Error Interrupt
  2864. * @rmtoll CR1 PEIE LL_USART_EnableIT_PE
  2865. * @param USARTx USART Instance
  2866. * @retval None
  2867. */
  2868. __STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx)
  2869. {
  2870. SET_BIT(USARTx->CR1, USART_CR1_PEIE);
  2871. }
  2872. /**
  2873. * @brief Enable Character Match Interrupt
  2874. * @rmtoll CR1 CMIE LL_USART_EnableIT_CM
  2875. * @param USARTx USART Instance
  2876. * @retval None
  2877. */
  2878. __STATIC_INLINE void LL_USART_EnableIT_CM(USART_TypeDef *USARTx)
  2879. {
  2880. SET_BIT(USARTx->CR1, USART_CR1_CMIE);
  2881. }
  2882. /**
  2883. * @brief Enable Receiver Timeout Interrupt
  2884. * @rmtoll CR1 RTOIE LL_USART_EnableIT_RTO
  2885. * @param USARTx USART Instance
  2886. * @retval None
  2887. */
  2888. __STATIC_INLINE void LL_USART_EnableIT_RTO(USART_TypeDef *USARTx)
  2889. {
  2890. SET_BIT(USARTx->CR1, USART_CR1_RTOIE);
  2891. }
  2892. #if defined(USART_SMARTCARD_SUPPORT)
  2893. /**
  2894. * @brief Enable End Of Block Interrupt
  2895. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  2896. * Smartcard feature is supported by the USARTx instance.
  2897. * @rmtoll CR1 EOBIE LL_USART_EnableIT_EOB
  2898. * @param USARTx USART Instance
  2899. * @retval None
  2900. */
  2901. __STATIC_INLINE void LL_USART_EnableIT_EOB(USART_TypeDef *USARTx)
  2902. {
  2903. SET_BIT(USARTx->CR1, USART_CR1_EOBIE);
  2904. }
  2905. #endif
  2906. #if defined(USART_LIN_SUPPORT)
  2907. /**
  2908. * @brief Enable LIN Break Detection Interrupt
  2909. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  2910. * LIN feature is supported by the USARTx instance.
  2911. * @rmtoll CR2 LBDIE LL_USART_EnableIT_LBD
  2912. * @param USARTx USART Instance
  2913. * @retval None
  2914. */
  2915. __STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx)
  2916. {
  2917. SET_BIT(USARTx->CR2, USART_CR2_LBDIE);
  2918. }
  2919. #endif
  2920. /**
  2921. * @brief Enable Error Interrupt
  2922. * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
  2923. * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register).
  2924. * 0: Interrupt is inhibited
  2925. * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register.
  2926. * @rmtoll CR3 EIE LL_USART_EnableIT_ERROR
  2927. * @param USARTx USART Instance
  2928. * @retval None
  2929. */
  2930. __STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx)
  2931. {
  2932. SET_BIT(USARTx->CR3, USART_CR3_EIE);
  2933. }
  2934. /**
  2935. * @brief Enable CTS Interrupt
  2936. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  2937. * Hardware Flow control feature is supported by the USARTx instance.
  2938. * @rmtoll CR3 CTSIE LL_USART_EnableIT_CTS
  2939. * @param USARTx USART Instance
  2940. * @retval None
  2941. */
  2942. __STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx)
  2943. {
  2944. SET_BIT(USARTx->CR3, USART_CR3_CTSIE);
  2945. }
  2946. #if defined(USART_WUSM_SUPPORT)
  2947. /**
  2948. * @brief Enable Wake Up from Stop Mode Interrupt
  2949. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  2950. * Wake-up from Stop mode feature is supported by the USARTx instance.
  2951. * @rmtoll CR3 WUFIE LL_USART_EnableIT_WKUP
  2952. * @param USARTx USART Instance
  2953. * @retval None
  2954. */
  2955. __STATIC_INLINE void LL_USART_EnableIT_WKUP(USART_TypeDef *USARTx)
  2956. {
  2957. SET_BIT(USARTx->CR3, USART_CR3_WUFIE);
  2958. }
  2959. #endif
  2960. /**
  2961. * @brief Disable IDLE Interrupt
  2962. * @rmtoll CR1 IDLEIE LL_USART_DisableIT_IDLE
  2963. * @param USARTx USART Instance
  2964. * @retval None
  2965. */
  2966. __STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx)
  2967. {
  2968. CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE);
  2969. }
  2970. /**
  2971. * @brief Disable RX Not Empty Interrupt
  2972. * @rmtoll CR1 RXNEIE LL_USART_DisableIT_RXNE
  2973. * @param USARTx USART Instance
  2974. * @retval None
  2975. */
  2976. __STATIC_INLINE void LL_USART_DisableIT_RXNE(USART_TypeDef *USARTx)
  2977. {
  2978. CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE);
  2979. }
  2980. /**
  2981. * @brief Disable Transmission Complete Interrupt
  2982. * @rmtoll CR1 TCIE LL_USART_DisableIT_TC
  2983. * @param USARTx USART Instance
  2984. * @retval None
  2985. */
  2986. __STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx)
  2987. {
  2988. CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE);
  2989. }
  2990. /**
  2991. * @brief Disable TX Empty Interrupt
  2992. * @rmtoll CR1 TXEIE LL_USART_DisableIT_TXE
  2993. * @param USARTx USART Instance
  2994. * @retval None
  2995. */
  2996. __STATIC_INLINE void LL_USART_DisableIT_TXE(USART_TypeDef *USARTx)
  2997. {
  2998. CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE);
  2999. }
  3000. /**
  3001. * @brief Disable Parity Error Interrupt
  3002. * @rmtoll CR1 PEIE LL_USART_DisableIT_PE
  3003. * @param USARTx USART Instance
  3004. * @retval None
  3005. */
  3006. __STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx)
  3007. {
  3008. CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE);
  3009. }
  3010. /**
  3011. * @brief Disable Character Match Interrupt
  3012. * @rmtoll CR1 CMIE LL_USART_DisableIT_CM
  3013. * @param USARTx USART Instance
  3014. * @retval None
  3015. */
  3016. __STATIC_INLINE void LL_USART_DisableIT_CM(USART_TypeDef *USARTx)
  3017. {
  3018. CLEAR_BIT(USARTx->CR1, USART_CR1_CMIE);
  3019. }
  3020. /**
  3021. * @brief Disable Receiver Timeout Interrupt
  3022. * @rmtoll CR1 RTOIE LL_USART_DisableIT_RTO
  3023. * @param USARTx USART Instance
  3024. * @retval None
  3025. */
  3026. __STATIC_INLINE void LL_USART_DisableIT_RTO(USART_TypeDef *USARTx)
  3027. {
  3028. CLEAR_BIT(USARTx->CR1, USART_CR1_RTOIE);
  3029. }
  3030. #if defined(USART_SMARTCARD_SUPPORT)
  3031. /**
  3032. * @brief Disable End Of Block Interrupt
  3033. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  3034. * Smartcard feature is supported by the USARTx instance.
  3035. * @rmtoll CR1 EOBIE LL_USART_DisableIT_EOB
  3036. * @param USARTx USART Instance
  3037. * @retval None
  3038. */
  3039. __STATIC_INLINE void LL_USART_DisableIT_EOB(USART_TypeDef *USARTx)
  3040. {
  3041. CLEAR_BIT(USARTx->CR1, USART_CR1_EOBIE);
  3042. }
  3043. #endif
  3044. #if defined(USART_LIN_SUPPORT)
  3045. /**
  3046. * @brief Disable LIN Break Detection Interrupt
  3047. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  3048. * LIN feature is supported by the USARTx instance.
  3049. * @rmtoll CR2 LBDIE LL_USART_DisableIT_LBD
  3050. * @param USARTx USART Instance
  3051. * @retval None
  3052. */
  3053. __STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx)
  3054. {
  3055. CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE);
  3056. }
  3057. #endif
  3058. /**
  3059. * @brief Disable Error Interrupt
  3060. * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
  3061. * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register).
  3062. * 0: Interrupt is inhibited
  3063. * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register.
  3064. * @rmtoll CR3 EIE LL_USART_DisableIT_ERROR
  3065. * @param USARTx USART Instance
  3066. * @retval None
  3067. */
  3068. __STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx)
  3069. {
  3070. CLEAR_BIT(USARTx->CR3, USART_CR3_EIE);
  3071. }
  3072. /**
  3073. * @brief Disable CTS Interrupt
  3074. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  3075. * Hardware Flow control feature is supported by the USARTx instance.
  3076. * @rmtoll CR3 CTSIE LL_USART_DisableIT_CTS
  3077. * @param USARTx USART Instance
  3078. * @retval None
  3079. */
  3080. __STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx)
  3081. {
  3082. CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE);
  3083. }
  3084. #if defined(USART_WUSM_SUPPORT)
  3085. /**
  3086. * @brief Disable Wake Up from Stop Mode Interrupt
  3087. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  3088. * Wake-up from Stop mode feature is supported by the USARTx instance.
  3089. * @rmtoll CR3 WUFIE LL_USART_DisableIT_WKUP
  3090. * @param USARTx USART Instance
  3091. * @retval None
  3092. */
  3093. __STATIC_INLINE void LL_USART_DisableIT_WKUP(USART_TypeDef *USARTx)
  3094. {
  3095. CLEAR_BIT(USARTx->CR3, USART_CR3_WUFIE);
  3096. }
  3097. #endif
  3098. /**
  3099. * @brief Check if the USART IDLE Interrupt source is enabled or disabled.
  3100. * @rmtoll CR1 IDLEIE LL_USART_IsEnabledIT_IDLE
  3101. * @param USARTx USART Instance
  3102. * @retval State of bit (1 or 0).
  3103. */
  3104. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(USART_TypeDef *USARTx)
  3105. {
  3106. return (READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE));
  3107. }
  3108. /**
  3109. * @brief Check if the USART RX Not Empty Interrupt is enabled or disabled.
  3110. * @rmtoll CR1 RXNEIE LL_USART_IsEnabledIT_RXNE
  3111. * @param USARTx USART Instance
  3112. * @retval State of bit (1 or 0).
  3113. */
  3114. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE(USART_TypeDef *USARTx)
  3115. {
  3116. return (READ_BIT(USARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE));
  3117. }
  3118. /**
  3119. * @brief Check if the USART Transmission Complete Interrupt is enabled or disabled.
  3120. * @rmtoll CR1 TCIE LL_USART_IsEnabledIT_TC
  3121. * @param USARTx USART Instance
  3122. * @retval State of bit (1 or 0).
  3123. */
  3124. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(USART_TypeDef *USARTx)
  3125. {
  3126. return (READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE));
  3127. }
  3128. /**
  3129. * @brief Check if the USART TX Empty Interrupt is enabled or disabled.
  3130. * @rmtoll CR1 TXEIE LL_USART_IsEnabledIT_TXE
  3131. * @param USARTx USART Instance
  3132. * @retval State of bit (1 or 0).
  3133. */
  3134. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE(USART_TypeDef *USARTx)
  3135. {
  3136. return (READ_BIT(USARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE));
  3137. }
  3138. /**
  3139. * @brief Check if the USART Parity Error Interrupt is enabled or disabled.
  3140. * @rmtoll CR1 PEIE LL_USART_IsEnabledIT_PE
  3141. * @param USARTx USART Instance
  3142. * @retval State of bit (1 or 0).
  3143. */
  3144. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(USART_TypeDef *USARTx)
  3145. {
  3146. return (READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE));
  3147. }
  3148. /**
  3149. * @brief Check if the USART Character Match Interrupt is enabled or disabled.
  3150. * @rmtoll CR1 CMIE LL_USART_IsEnabledIT_CM
  3151. * @param USARTx USART Instance
  3152. * @retval State of bit (1 or 0).
  3153. */
  3154. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CM(USART_TypeDef *USARTx)
  3155. {
  3156. return (READ_BIT(USARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE));
  3157. }
  3158. /**
  3159. * @brief Check if the USART Receiver Timeout Interrupt is enabled or disabled.
  3160. * @rmtoll CR1 RTOIE LL_USART_IsEnabledIT_RTO
  3161. * @param USARTx USART Instance
  3162. * @retval State of bit (1 or 0).
  3163. */
  3164. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RTO(USART_TypeDef *USARTx)
  3165. {
  3166. return (READ_BIT(USARTx->CR1, USART_CR1_RTOIE) == (USART_CR1_RTOIE));
  3167. }
  3168. #if defined(USART_SMARTCARD_SUPPORT)
  3169. /**
  3170. * @brief Check if the USART End Of Block Interrupt is enabled or disabled.
  3171. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  3172. * Smartcard feature is supported by the USARTx instance.
  3173. * @rmtoll CR1 EOBIE LL_USART_IsEnabledIT_EOB
  3174. * @param USARTx USART Instance
  3175. * @retval State of bit (1 or 0).
  3176. */
  3177. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_EOB(USART_TypeDef *USARTx)
  3178. {
  3179. return (READ_BIT(USARTx->CR1, USART_CR1_EOBIE) == (USART_CR1_EOBIE));
  3180. }
  3181. #endif
  3182. #if defined(USART_LIN_SUPPORT)
  3183. /**
  3184. * @brief Check if the USART LIN Break Detection Interrupt is enabled or disabled.
  3185. * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
  3186. * LIN feature is supported by the USARTx instance.
  3187. * @rmtoll CR2 LBDIE LL_USART_IsEnabledIT_LBD
  3188. * @param USARTx USART Instance
  3189. * @retval State of bit (1 or 0).
  3190. */
  3191. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(USART_TypeDef *USARTx)
  3192. {
  3193. return (READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE));
  3194. }
  3195. #endif
  3196. /**
  3197. * @brief Check if the USART Error Interrupt is enabled or disabled.
  3198. * @rmtoll CR3 EIE LL_USART_IsEnabledIT_ERROR
  3199. * @param USARTx USART Instance
  3200. * @retval State of bit (1 or 0).
  3201. */
  3202. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(USART_TypeDef *USARTx)
  3203. {
  3204. return (READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE));
  3205. }
  3206. /**
  3207. * @brief Check if the USART CTS Interrupt is enabled or disabled.
  3208. * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
  3209. * Hardware Flow control feature is supported by the USARTx instance.
  3210. * @rmtoll CR3 CTSIE LL_USART_IsEnabledIT_CTS
  3211. * @param USARTx USART Instance
  3212. * @retval State of bit (1 or 0).
  3213. */
  3214. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(USART_TypeDef *USARTx)
  3215. {
  3216. return (READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE));
  3217. }
  3218. #if defined(USART_WUSM_SUPPORT)
  3219. /**
  3220. * @brief Check if the USART Wake Up from Stop Mode Interrupt is enabled or disabled.
  3221. * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
  3222. * Wake-up from Stop mode feature is supported by the USARTx instance.
  3223. * @rmtoll CR3 WUFIE LL_USART_IsEnabledIT_WKUP
  3224. * @param USARTx USART Instance
  3225. * @retval State of bit (1 or 0).
  3226. */
  3227. __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_WKUP(USART_TypeDef *USARTx)
  3228. {
  3229. return (READ_BIT(USARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE));
  3230. }
  3231. #endif
  3232. /**
  3233. * @}
  3234. */
  3235. /** @defgroup USART_LL_EF_DMA_Management DMA_Management
  3236. * @{
  3237. */
  3238. /**
  3239. * @brief Enable DMA Mode for reception
  3240. * @rmtoll CR3 DMAR LL_USART_EnableDMAReq_RX
  3241. * @param USARTx USART Instance
  3242. * @retval None
  3243. */
  3244. __STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx)
  3245. {
  3246. SET_BIT(USARTx->CR3, USART_CR3_DMAR);
  3247. }
  3248. /**
  3249. * @brief Disable DMA Mode for reception
  3250. * @rmtoll CR3 DMAR LL_USART_DisableDMAReq_RX
  3251. * @param USARTx USART Instance
  3252. * @retval None
  3253. */
  3254. __STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx)
  3255. {
  3256. CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR);
  3257. }
  3258. /**
  3259. * @brief Check if DMA Mode is enabled for reception
  3260. * @rmtoll CR3 DMAR LL_USART_IsEnabledDMAReq_RX
  3261. * @param USARTx USART Instance
  3262. * @retval State of bit (1 or 0).
  3263. */
  3264. __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(USART_TypeDef *USARTx)
  3265. {
  3266. return (READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR));
  3267. }
  3268. /**
  3269. * @brief Enable DMA Mode for transmission
  3270. * @rmtoll CR3 DMAT LL_USART_EnableDMAReq_TX
  3271. * @param USARTx USART Instance
  3272. * @retval None
  3273. */
  3274. __STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx)
  3275. {
  3276. SET_BIT(USARTx->CR3, USART_CR3_DMAT);
  3277. }
  3278. /**
  3279. * @brief Disable DMA Mode for transmission
  3280. * @rmtoll CR3 DMAT LL_USART_DisableDMAReq_TX
  3281. * @param USARTx USART Instance
  3282. * @retval None
  3283. */
  3284. __STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx)
  3285. {
  3286. CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT);
  3287. }
  3288. /**
  3289. * @brief Check if DMA Mode is enabled for transmission
  3290. * @rmtoll CR3 DMAT LL_USART_IsEnabledDMAReq_TX
  3291. * @param USARTx USART Instance
  3292. * @retval State of bit (1 or 0).
  3293. */
  3294. __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(USART_TypeDef *USARTx)
  3295. {
  3296. return (READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT));
  3297. }
  3298. /**
  3299. * @brief Enable DMA Disabling on Reception Error
  3300. * @rmtoll CR3 DDRE LL_USART_EnableDMADeactOnRxErr
  3301. * @param USARTx USART Instance
  3302. * @retval None
  3303. */
  3304. __STATIC_INLINE void LL_USART_EnableDMADeactOnRxErr(USART_TypeDef *USARTx)
  3305. {
  3306. SET_BIT(USARTx->CR3, USART_CR3_DDRE);
  3307. }
  3308. /**
  3309. * @brief Disable DMA Disabling on Reception Error
  3310. * @rmtoll CR3 DDRE LL_USART_DisableDMADeactOnRxErr
  3311. * @param USARTx USART Instance
  3312. * @retval None
  3313. */
  3314. __STATIC_INLINE void LL_USART_DisableDMADeactOnRxErr(USART_TypeDef *USARTx)
  3315. {
  3316. CLEAR_BIT(USARTx->CR3, USART_CR3_DDRE);
  3317. }
  3318. /**
  3319. * @brief Indicate if DMA Disabling on Reception Error is disabled
  3320. * @rmtoll CR3 DDRE LL_USART_IsEnabledDMADeactOnRxErr
  3321. * @param USARTx USART Instance
  3322. * @retval State of bit (1 or 0).
  3323. */
  3324. __STATIC_INLINE uint32_t LL_USART_IsEnabledDMADeactOnRxErr(USART_TypeDef *USARTx)
  3325. {
  3326. return (READ_BIT(USARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE));
  3327. }
  3328. /**
  3329. * @brief Get the data register address used for DMA transfer
  3330. * @rmtoll RDR RDR LL_USART_DMA_GetRegAddr\n
  3331. * @rmtoll TDR TDR LL_USART_DMA_GetRegAddr
  3332. * @param USARTx USART Instance
  3333. * @param Direction This parameter can be one of the following values:
  3334. * @arg @ref LL_USART_DMA_REG_DATA_TRANSMIT
  3335. * @arg @ref LL_USART_DMA_REG_DATA_RECEIVE
  3336. * @retval Address of data register
  3337. */
  3338. __STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(USART_TypeDef *USARTx, uint32_t Direction)
  3339. {
  3340. register uint32_t data_reg_addr = 0U;
  3341. if (Direction == LL_USART_DMA_REG_DATA_TRANSMIT)
  3342. {
  3343. /* return address of TDR register */
  3344. data_reg_addr = (uint32_t) &(USARTx->TDR);
  3345. }
  3346. else
  3347. {
  3348. /* return address of RDR register */
  3349. data_reg_addr = (uint32_t) &(USARTx->RDR);
  3350. }
  3351. return data_reg_addr;
  3352. }
  3353. /**
  3354. * @}
  3355. */
  3356. /** @defgroup USART_LL_EF_Data_Management Data_Management
  3357. * @{
  3358. */
  3359. /**
  3360. * @brief Read Receiver Data register (Receive Data value, 8 bits)
  3361. * @rmtoll RDR RDR LL_USART_ReceiveData8
  3362. * @param USARTx USART Instance
  3363. * @retval Value between Min_Data=0x00 and Max_Data=0xFF
  3364. */
  3365. __STATIC_INLINE uint8_t LL_USART_ReceiveData8(USART_TypeDef *USARTx)
  3366. {
  3367. return (uint8_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR));
  3368. }
  3369. /**
  3370. * @brief Read Receiver Data register (Receive Data value, 9 bits)
  3371. * @rmtoll RDR RDR LL_USART_ReceiveData9
  3372. * @param USARTx USART Instance
  3373. * @retval Value between Min_Data=0x00 and Max_Data=0x1FF
  3374. */
  3375. __STATIC_INLINE uint16_t LL_USART_ReceiveData9(USART_TypeDef *USARTx)
  3376. {
  3377. return (uint16_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR));
  3378. }
  3379. /**
  3380. * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits)
  3381. * @rmtoll TDR TDR LL_USART_TransmitData8
  3382. * @param USARTx USART Instance
  3383. * @param Value between Min_Data=0x00 and Max_Data=0xFF
  3384. * @retval None
  3385. */
  3386. __STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value)
  3387. {
  3388. USARTx->TDR = Value;
  3389. }
  3390. /**
  3391. * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits)
  3392. * @rmtoll TDR TDR LL_USART_TransmitData9
  3393. * @param USARTx USART Instance
  3394. * @param Value between Min_Data=0x00 and Max_Data=0x1FF
  3395. * @retval None
  3396. */
  3397. __STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value)
  3398. {
  3399. USARTx->TDR = Value & 0x1FFU;
  3400. }
  3401. /**
  3402. * @}
  3403. */
  3404. /** @defgroup USART_LL_EF_Execution Execution
  3405. * @{
  3406. */
  3407. /**
  3408. * @brief Request an Automatic Baud Rate measurement on next received data frame
  3409. * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
  3410. * Auto Baud Rate detection feature is supported by the USARTx instance.
  3411. * @rmtoll RQR ABRRQ LL_USART_RequestAutoBaudRate
  3412. * @param USARTx USART Instance
  3413. * @retval None
  3414. */
  3415. __STATIC_INLINE void LL_USART_RequestAutoBaudRate(USART_TypeDef *USARTx)
  3416. {
  3417. SET_BIT(USARTx->RQR, USART_RQR_ABRRQ);
  3418. }
  3419. /**
  3420. * @brief Request Break sending
  3421. * @rmtoll RQR SBKRQ LL_USART_RequestBreakSending
  3422. * @param USARTx USART Instance
  3423. * @retval None
  3424. */
  3425. __STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx)
  3426. {
  3427. SET_BIT(USARTx->RQR, USART_RQR_SBKRQ);
  3428. }
  3429. /**
  3430. * @brief Put USART in mute mode and set the RWU flag
  3431. * @rmtoll RQR MMRQ LL_USART_RequestEnterMuteMode
  3432. * @param USARTx USART Instance
  3433. * @retval None
  3434. */
  3435. __STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx)
  3436. {
  3437. SET_BIT(USARTx->RQR, USART_RQR_MMRQ);
  3438. }
  3439. /**
  3440. * @brief Request a Receive Data flush
  3441. * @rmtoll RQR RXFRQ LL_USART_RequestRxDataFlush
  3442. * @param USARTx USART Instance
  3443. * @retval None
  3444. */
  3445. __STATIC_INLINE void LL_USART_RequestRxDataFlush(USART_TypeDef *USARTx)
  3446. {
  3447. SET_BIT(USARTx->RQR, USART_RQR_RXFRQ);
  3448. }
  3449. #if defined(USART_SMARTCARD_SUPPORT)
  3450. /**
  3451. * @brief Request a Transmit data flush
  3452. * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
  3453. * Smartcard feature is supported by the USARTx instance.
  3454. * @rmtoll RQR TXFRQ LL_USART_RequestTxDataFlush
  3455. * @param USARTx USART Instance
  3456. * @retval None
  3457. */
  3458. __STATIC_INLINE void LL_USART_RequestTxDataFlush(USART_TypeDef *USARTx)
  3459. {
  3460. SET_BIT(USARTx->RQR, USART_RQR_TXFRQ);
  3461. }
  3462. #endif
  3463. /**
  3464. * @}
  3465. */
  3466. #if defined(USE_FULL_LL_DRIVER)
  3467. /** @defgroup USART_LL_EF_Init Initialization and de-initialization functions
  3468. * @{
  3469. */
  3470. ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx);
  3471. ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct);
  3472. void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct);
  3473. ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
  3474. void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
  3475. /**
  3476. * @}
  3477. */
  3478. #endif /* USE_FULL_LL_DRIVER */
  3479. /**
  3480. * @}
  3481. */
  3482. /**
  3483. * @}
  3484. */
  3485. #endif /* USART1 || USART2|| USART3 || USART4 || USART5 || USART6 || USART7 || USART8 */
  3486. /**
  3487. * @}
  3488. */
  3489. #ifdef __cplusplus
  3490. }
  3491. #endif
  3492. #endif /* __STM32F0xx_LL_USART_H */
  3493. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/