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.
 
 
 

2635 lines
93 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32wbxx_ll_lpuart.h
  4. * @author MCD Application Team
  5. * @brief Header file of LPUART LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32WBxx_LL_LPUART_H
  21. #define STM32WBxx_LL_LPUART_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32wbxx.h"
  27. /** @addtogroup STM32WBxx_LL_Driver
  28. * @{
  29. */
  30. #if defined (LPUART1)
  31. /** @defgroup LPUART_LL LPUART
  32. * @{
  33. */
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /** @defgroup LPUART_LL_Private_Variables LPUART Private Variables
  37. * @{
  38. */
  39. /* Array used to get the LPUART prescaler division decimal values versus @ref LPUART_LL_EC_PRESCALER values */
  40. static const uint16_t LPUART_PRESCALER_TAB[] =
  41. {
  42. (uint16_t)1,
  43. (uint16_t)2,
  44. (uint16_t)4,
  45. (uint16_t)6,
  46. (uint16_t)8,
  47. (uint16_t)10,
  48. (uint16_t)12,
  49. (uint16_t)16,
  50. (uint16_t)32,
  51. (uint16_t)64,
  52. (uint16_t)128,
  53. (uint16_t)256
  54. };
  55. /**
  56. * @}
  57. */
  58. /* Private constants ---------------------------------------------------------*/
  59. /** @defgroup LPUART_LL_Private_Constants LPUART Private Constants
  60. * @{
  61. */
  62. /* Defines used in Baud Rate related macros and corresponding register setting computation */
  63. #define LPUART_LPUARTDIV_FREQ_MUL 256U
  64. #define LPUART_BRR_MASK 0x000FFFFFU
  65. #define LPUART_BRR_MIN_VALUE 0x00000300U
  66. /**
  67. * @}
  68. */
  69. /* Private macros ------------------------------------------------------------*/
  70. #if defined(USE_FULL_LL_DRIVER)
  71. /** @defgroup LPUART_LL_Private_Macros LPUART Private Macros
  72. * @{
  73. */
  74. /**
  75. * @}
  76. */
  77. #endif /*USE_FULL_LL_DRIVER*/
  78. /* Exported types ------------------------------------------------------------*/
  79. #if defined(USE_FULL_LL_DRIVER)
  80. /** @defgroup LPUART_LL_ES_INIT LPUART Exported Init structures
  81. * @{
  82. */
  83. /**
  84. * @brief LL LPUART Init Structure definition
  85. */
  86. typedef struct
  87. {
  88. uint32_t PrescalerValue; /*!< Specifies the Prescaler to compute the communication baud rate.
  89. This parameter can be a value of @ref LPUART_LL_EC_PRESCALER.
  90. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetPrescaler().*/
  91. uint32_t BaudRate; /*!< This field defines expected LPUART communication baud rate.
  92. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetBaudRate().*/
  93. uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame.
  94. This parameter can be a value of @ref LPUART_LL_EC_DATAWIDTH.
  95. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetDataWidth().*/
  96. uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
  97. This parameter can be a value of @ref LPUART_LL_EC_STOPBITS.
  98. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetStopBitsLength().*/
  99. uint32_t Parity; /*!< Specifies the parity mode.
  100. This parameter can be a value of @ref LPUART_LL_EC_PARITY.
  101. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetParity().*/
  102. uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled.
  103. This parameter can be a value of @ref LPUART_LL_EC_DIRECTION.
  104. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetTransferDirection().*/
  105. uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled.
  106. This parameter can be a value of @ref LPUART_LL_EC_HWCONTROL.
  107. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetHWFlowCtrl().*/
  108. } LL_LPUART_InitTypeDef;
  109. /**
  110. * @}
  111. */
  112. #endif /* USE_FULL_LL_DRIVER */
  113. /* Exported constants --------------------------------------------------------*/
  114. /** @defgroup LPUART_LL_Exported_Constants LPUART Exported Constants
  115. * @{
  116. */
  117. /** @defgroup LPUART_LL_EC_CLEAR_FLAG Clear Flags Defines
  118. * @brief Flags defines which can be used with LL_LPUART_WriteReg function
  119. * @{
  120. */
  121. #define LL_LPUART_ICR_PECF USART_ICR_PECF /*!< Parity error flag */
  122. #define LL_LPUART_ICR_FECF USART_ICR_FECF /*!< Framing error flag */
  123. #define LL_LPUART_ICR_NCF USART_ICR_NECF /*!< Noise error detected flag */
  124. #define LL_LPUART_ICR_ORECF USART_ICR_ORECF /*!< Overrun error flag */
  125. #define LL_LPUART_ICR_IDLECF USART_ICR_IDLECF /*!< Idle line detected flag */
  126. #define LL_LPUART_ICR_TXFECF USART_ICR_TXFECF /*!< TX FIFO Empty Clear flag */
  127. #define LL_LPUART_ICR_TCCF USART_ICR_TCCF /*!< Transmission complete flag */
  128. #define LL_LPUART_ICR_CTSCF USART_ICR_CTSCF /*!< CTS flag */
  129. #define LL_LPUART_ICR_CMCF USART_ICR_CMCF /*!< Character match flag */
  130. #define LL_LPUART_ICR_WUCF USART_ICR_WUCF /*!< Wakeup from Stop mode flag */
  131. /**
  132. * @}
  133. */
  134. /** @defgroup LPUART_LL_EC_GET_FLAG Get Flags Defines
  135. * @brief Flags defines which can be used with LL_LPUART_ReadReg function
  136. * @{
  137. */
  138. #define LL_LPUART_ISR_PE USART_ISR_PE /*!< Parity error flag */
  139. #define LL_LPUART_ISR_FE USART_ISR_FE /*!< Framing error flag */
  140. #define LL_LPUART_ISR_NE USART_ISR_NE /*!< Noise detected flag */
  141. #define LL_LPUART_ISR_ORE USART_ISR_ORE /*!< Overrun error flag */
  142. #define LL_LPUART_ISR_IDLE USART_ISR_IDLE /*!< Idle line detected flag */
  143. #define LL_LPUART_ISR_RXNE_RXFNE USART_ISR_RXNE_RXFNE /*!< Read data register or RX FIFO not empty flag */
  144. #define LL_LPUART_ISR_TC USART_ISR_TC /*!< Transmission complete flag */
  145. #define LL_LPUART_ISR_TXE_TXFNF USART_ISR_TXE_TXFNF /*!< Transmit data register empty or TX FIFO Not Full flag*/
  146. #define LL_LPUART_ISR_CTSIF USART_ISR_CTSIF /*!< CTS interrupt flag */
  147. #define LL_LPUART_ISR_CTS USART_ISR_CTS /*!< CTS flag */
  148. #define LL_LPUART_ISR_BUSY USART_ISR_BUSY /*!< Busy flag */
  149. #define LL_LPUART_ISR_CMF USART_ISR_CMF /*!< Character match flag */
  150. #define LL_LPUART_ISR_SBKF USART_ISR_SBKF /*!< Send break flag */
  151. #define LL_LPUART_ISR_RWU USART_ISR_RWU /*!< Receiver wakeup from Mute mode flag */
  152. #define LL_LPUART_ISR_WUF USART_ISR_WUF /*!< Wakeup from Stop mode flag */
  153. #define LL_LPUART_ISR_TEACK USART_ISR_TEACK /*!< Transmit enable acknowledge flag */
  154. #define LL_LPUART_ISR_REACK USART_ISR_REACK /*!< Receive enable acknowledge flag */
  155. #define LL_LPUART_ISR_TXFE USART_ISR_TXFE /*!< TX FIFO empty flag */
  156. #define LL_LPUART_ISR_RXFF USART_ISR_RXFF /*!< RX FIFO full flag */
  157. #define LL_LPUART_ISR_RXFT USART_ISR_RXFT /*!< RX FIFO threshold flag */
  158. #define LL_LPUART_ISR_TXFT USART_ISR_TXFT /*!< TX FIFO threshold flag */
  159. /**
  160. * @}
  161. */
  162. /** @defgroup LPUART_LL_EC_IT IT Defines
  163. * @brief IT defines which can be used with LL_LPUART_ReadReg and LL_LPUART_WriteReg functions
  164. * @{
  165. */
  166. #define LL_LPUART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */
  167. #define LL_LPUART_CR1_RXNEIE_RXFNEIE USART_CR1_RXNEIE_RXFNEIE /*!< Read data register and RXFIFO not empty interrupt enable */
  168. #define LL_LPUART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */
  169. #define LL_LPUART_CR1_TXEIE_TXFNFIE USART_CR1_TXEIE_TXFNFIE /*!< Transmit data register empty and TX FIFO not full interrupt enable */
  170. #define LL_LPUART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */
  171. #define LL_LPUART_CR1_CMIE USART_CR1_CMIE /*!< Character match interrupt enable */
  172. #define LL_LPUART_CR1_TXFEIE USART_CR1_TXFEIE /*!< TX FIFO empty interrupt enable */
  173. #define LL_LPUART_CR1_RXFFIE USART_CR1_RXFFIE /*!< RX FIFO full interrupt enable */
  174. #define LL_LPUART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */
  175. #define LL_LPUART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */
  176. #define LL_LPUART_CR3_WUFIE USART_CR3_WUFIE /*!< Wakeup from Stop mode interrupt enable */
  177. #define LL_LPUART_CR3_TXFTIE USART_CR3_TXFTIE /*!< TX FIFO threshold interrupt enable */
  178. #define LL_LPUART_CR3_RXFTIE USART_CR3_RXFTIE /*!< RX FIFO threshold interrupt enable */
  179. /**
  180. * @}
  181. */
  182. /** @defgroup LPUART_LL_EC_FIFOTHRESHOLD FIFO Threshold
  183. * @{
  184. */
  185. #define LL_LPUART_FIFOTHRESHOLD_1_8 0x00000000U /*!< FIFO reaches 1/8 of its depth */
  186. #define LL_LPUART_FIFOTHRESHOLD_1_4 0x00000001U /*!< FIFO reaches 1/4 of its depth */
  187. #define LL_LPUART_FIFOTHRESHOLD_1_2 0x00000002U /*!< FIFO reaches 1/2 of its depth */
  188. #define LL_LPUART_FIFOTHRESHOLD_3_4 0x00000003U /*!< FIFO reaches 3/4 of its depth */
  189. #define LL_LPUART_FIFOTHRESHOLD_7_8 0x00000004U /*!< FIFO reaches 7/8 of its depth */
  190. #define LL_LPUART_FIFOTHRESHOLD_8_8 0x00000005U /*!< FIFO becomes empty for TX and full for RX */
  191. /**
  192. * @}
  193. */
  194. /** @defgroup LPUART_LL_EC_DIRECTION Direction
  195. * @{
  196. */
  197. #define LL_LPUART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */
  198. #define LL_LPUART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */
  199. #define LL_LPUART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */
  200. #define LL_LPUART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */
  201. /**
  202. * @}
  203. */
  204. /** @defgroup LPUART_LL_EC_PARITY Parity Control
  205. * @{
  206. */
  207. #define LL_LPUART_PARITY_NONE 0x00000000U /*!< Parity control disabled */
  208. #define LL_LPUART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */
  209. #define LL_LPUART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */
  210. /**
  211. * @}
  212. */
  213. /** @defgroup LPUART_LL_EC_WAKEUP Wakeup
  214. * @{
  215. */
  216. #define LL_LPUART_WAKEUP_IDLELINE 0x00000000U /*!< LPUART wake up from Mute mode on Idle Line */
  217. #define LL_LPUART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< LPUART wake up from Mute mode on Address Mark */
  218. /**
  219. * @}
  220. */
  221. /** @defgroup LPUART_LL_EC_DATAWIDTH Datawidth
  222. * @{
  223. */
  224. #define LL_LPUART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */
  225. #define LL_LPUART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
  226. #define LL_LPUART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
  227. /**
  228. * @}
  229. */
  230. /** @defgroup LPUART_LL_EC_PRESCALER Clock Source Prescaler
  231. * @{
  232. */
  233. #define LL_LPUART_PRESCALER_DIV1 0x00000000U /*!< Input clock not devided */
  234. #define LL_LPUART_PRESCALER_DIV2 (USART_PRESC_PRESCALER_0) /*!< Input clock devided by 2 */
  235. #define LL_LPUART_PRESCALER_DIV4 (USART_PRESC_PRESCALER_1) /*!< Input clock devided by 4 */
  236. #define LL_LPUART_PRESCALER_DIV6 (USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock devided by 6 */
  237. #define LL_LPUART_PRESCALER_DIV8 (USART_PRESC_PRESCALER_2) /*!< Input clock devided by 8 */
  238. #define LL_LPUART_PRESCALER_DIV10 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_0) /*!< Input clock devided by 10 */
  239. #define LL_LPUART_PRESCALER_DIV12 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_1) /*!< Input clock devided by 12 */
  240. #define LL_LPUART_PRESCALER_DIV16 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock devided by 16 */
  241. #define LL_LPUART_PRESCALER_DIV32 (USART_PRESC_PRESCALER_3) /*!< Input clock devided by 32 */
  242. #define LL_LPUART_PRESCALER_DIV64 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_0) /*!< Input clock devided by 64 */
  243. #define LL_LPUART_PRESCALER_DIV128 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_1) /*!< Input clock devided by 128 */
  244. #define LL_LPUART_PRESCALER_DIV256 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock devided by 256 */
  245. /**
  246. * @}
  247. */
  248. /** @defgroup LPUART_LL_EC_STOPBITS Stop Bits
  249. * @{
  250. */
  251. #define LL_LPUART_STOPBITS_1 0x00000000U /*!< 1 stop bit */
  252. #define LL_LPUART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */
  253. /**
  254. * @}
  255. */
  256. /** @defgroup LPUART_LL_EC_TXRX TX RX Pins Swap
  257. * @{
  258. */
  259. #define LL_LPUART_TXRX_STANDARD 0x00000000U /*!< TX/RX pins are used as defined in standard pinout */
  260. #define LL_LPUART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */
  261. /**
  262. * @}
  263. */
  264. /** @defgroup LPUART_LL_EC_RXPIN_LEVEL RX Pin Active Level Inversion
  265. * @{
  266. */
  267. #define LL_LPUART_RXPIN_LEVEL_STANDARD 0x00000000U /*!< RX pin signal works using the standard logic levels */
  268. #define LL_LPUART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */
  269. /**
  270. * @}
  271. */
  272. /** @defgroup LPUART_LL_EC_TXPIN_LEVEL TX Pin Active Level Inversion
  273. * @{
  274. */
  275. #define LL_LPUART_TXPIN_LEVEL_STANDARD 0x00000000U /*!< TX pin signal works using the standard logic levels */
  276. #define LL_LPUART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */
  277. /**
  278. * @}
  279. */
  280. /** @defgroup LPUART_LL_EC_BINARY_LOGIC Binary Data Inversion
  281. * @{
  282. */
  283. #define LL_LPUART_BINARY_LOGIC_POSITIVE 0x00000000U /*!< Logical data from the data register are send/received in positive/direct logic. (1=H, 0=L) */
  284. #define LL_LPUART_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. */
  285. /**
  286. * @}
  287. */
  288. /** @defgroup LPUART_LL_EC_BITORDER Bit Order
  289. * @{
  290. */
  291. #define LL_LPUART_BITORDER_LSBFIRST 0x00000000U /*!< data is transmitted/received with data bit 0 first, following the start bit */
  292. #define LL_LPUART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first, following the start bit */
  293. /**
  294. * @}
  295. */
  296. /** @defgroup LPUART_LL_EC_ADDRESS_DETECT Address Length Detection
  297. * @{
  298. */
  299. #define LL_LPUART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit address detection method selected */
  300. #define LL_LPUART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */
  301. /**
  302. * @}
  303. */
  304. /** @defgroup LPUART_LL_EC_HWCONTROL Hardware Control
  305. * @{
  306. */
  307. #define LL_LPUART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */
  308. #define LL_LPUART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */
  309. #define LL_LPUART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */
  310. #define LL_LPUART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */
  311. /**
  312. * @}
  313. */
  314. /** @defgroup LPUART_LL_EC_WAKEUP_ON Wakeup Activation
  315. * @{
  316. */
  317. #define LL_LPUART_WAKEUP_ON_ADDRESS 0x00000000U /*!< Wake up active on address match */
  318. #define LL_LPUART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wake up active on Start bit detection */
  319. #define LL_LPUART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wake up active on RXNE */
  320. /**
  321. * @}
  322. */
  323. /** @defgroup LPUART_LL_EC_DE_POLARITY Driver Enable Polarity
  324. * @{
  325. */
  326. #define LL_LPUART_DE_POLARITY_HIGH 0x00000000U /*!< DE signal is active high */
  327. #define LL_LPUART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */
  328. /**
  329. * @}
  330. */
  331. /** @defgroup LPUART_LL_EC_DMA_REG_DATA DMA Register Data
  332. * @{
  333. */
  334. #define LL_LPUART_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */
  335. #define LL_LPUART_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */
  336. /**
  337. * @}
  338. */
  339. /**
  340. * @}
  341. */
  342. /* Exported macro ------------------------------------------------------------*/
  343. /** @defgroup LPUART_LL_Exported_Macros LPUART Exported Macros
  344. * @{
  345. */
  346. /** @defgroup LPUART_LL_EM_WRITE_READ Common Write and read registers Macros
  347. * @{
  348. */
  349. /**
  350. * @brief Write a value in LPUART register
  351. * @param __INSTANCE__ LPUART Instance
  352. * @param __REG__ Register to be written
  353. * @param __VALUE__ Value to be written in the register
  354. * @retval None
  355. */
  356. #define LL_LPUART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  357. /**
  358. * @brief Read a value in LPUART register
  359. * @param __INSTANCE__ LPUART Instance
  360. * @param __REG__ Register to be read
  361. * @retval Register value
  362. */
  363. #define LL_LPUART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  364. /**
  365. * @}
  366. */
  367. /** @defgroup LPUART_LL_EM_Exported_Macros_Helper Helper Macros
  368. * @{
  369. */
  370. /**
  371. * @brief Compute LPUARTDIV value according to Peripheral Clock and
  372. * expected Baud Rate (20-bit value of LPUARTDIV is returned)
  373. * @param __PERIPHCLK__ Peripheral Clock frequency used for LPUART Instance
  374. * @param __PRESCALER__ This parameter can be one of the following values:
  375. * @arg @ref LL_LPUART_PRESCALER_DIV1
  376. * @arg @ref LL_LPUART_PRESCALER_DIV2
  377. * @arg @ref LL_LPUART_PRESCALER_DIV4
  378. * @arg @ref LL_LPUART_PRESCALER_DIV6
  379. * @arg @ref LL_LPUART_PRESCALER_DIV8
  380. * @arg @ref LL_LPUART_PRESCALER_DIV10
  381. * @arg @ref LL_LPUART_PRESCALER_DIV12
  382. * @arg @ref LL_LPUART_PRESCALER_DIV16
  383. * @arg @ref LL_LPUART_PRESCALER_DIV32
  384. * @arg @ref LL_LPUART_PRESCALER_DIV64
  385. * @arg @ref LL_LPUART_PRESCALER_DIV128
  386. * @arg @ref LL_LPUART_PRESCALER_DIV256
  387. * @param __BAUDRATE__ Baud Rate value to achieve
  388. * @retval LPUARTDIV value to be used for BRR register filling
  389. */
  390. #define __LL_LPUART_DIV(__PERIPHCLK__, __PRESCALER__, __BAUDRATE__) (uint32_t)((((((uint64_t)(__PERIPHCLK__)/(uint64_t)(LPUART_PRESCALER_TAB[(uint16_t)(__PRESCALER__)])) * LPUART_LPUARTDIV_FREQ_MUL)\
  391. + (uint32_t)((__BAUDRATE__)/2U))/(__BAUDRATE__)) & LPUART_BRR_MASK)
  392. /**
  393. * @}
  394. */
  395. /**
  396. * @}
  397. */
  398. /* Exported functions --------------------------------------------------------*/
  399. /** @defgroup LPUART_LL_Exported_Functions LPUART Exported Functions
  400. * @{
  401. */
  402. /** @defgroup LPUART_LL_EF_Configuration Configuration functions
  403. * @{
  404. */
  405. /**
  406. * @brief LPUART Enable
  407. * @rmtoll CR1 UE LL_LPUART_Enable
  408. * @param LPUARTx LPUART Instance
  409. * @retval None
  410. */
  411. __STATIC_INLINE void LL_LPUART_Enable(USART_TypeDef *LPUARTx)
  412. {
  413. SET_BIT(LPUARTx->CR1, USART_CR1_UE);
  414. }
  415. /**
  416. * @brief LPUART Disable
  417. * @note When LPUART is disabled, LPUART prescalers and outputs are stopped immediately,
  418. * and current operations are discarded. The configuration of the LPUART is kept, but all the status
  419. * flags, in the LPUARTx_ISR are set to their default values.
  420. * @note In order to go into low-power mode without generating errors on the line,
  421. * the TE bit must be reset before and the software must wait
  422. * for the TC bit in the LPUART_ISR to be set before resetting the UE bit.
  423. * The DMA requests are also reset when UE = 0 so the DMA channel must
  424. * be disabled before resetting the UE bit.
  425. * @rmtoll CR1 UE LL_LPUART_Disable
  426. * @param LPUARTx LPUART Instance
  427. * @retval None
  428. */
  429. __STATIC_INLINE void LL_LPUART_Disable(USART_TypeDef *LPUARTx)
  430. {
  431. CLEAR_BIT(LPUARTx->CR1, USART_CR1_UE);
  432. }
  433. /**
  434. * @brief Indicate if LPUART is enabled
  435. * @rmtoll CR1 UE LL_LPUART_IsEnabled
  436. * @param LPUARTx LPUART Instance
  437. * @retval State of bit (1 or 0).
  438. */
  439. __STATIC_INLINE uint32_t LL_LPUART_IsEnabled(USART_TypeDef *LPUARTx)
  440. {
  441. return ((READ_BIT(LPUARTx->CR1, USART_CR1_UE) == (USART_CR1_UE)) ? 1UL : 0UL);
  442. }
  443. /**
  444. * @brief FIFO Mode Enable
  445. * @rmtoll CR1 FIFOEN LL_LPUART_EnableFIFO
  446. * @param LPUARTx LPUART Instance
  447. * @retval None
  448. */
  449. __STATIC_INLINE void LL_LPUART_EnableFIFO(USART_TypeDef *LPUARTx)
  450. {
  451. SET_BIT(LPUARTx->CR1, USART_CR1_FIFOEN);
  452. }
  453. /**
  454. * @brief FIFO Mode Disable
  455. * @rmtoll CR1 FIFOEN LL_LPUART_DisableFIFO
  456. * @param LPUARTx LPUART Instance
  457. * @retval None
  458. */
  459. __STATIC_INLINE void LL_LPUART_DisableFIFO(USART_TypeDef *LPUARTx)
  460. {
  461. CLEAR_BIT(LPUARTx->CR1, USART_CR1_FIFOEN);
  462. }
  463. /**
  464. * @brief Indicate if FIFO Mode is enabled
  465. * @rmtoll CR1 FIFOEN LL_LPUART_IsEnabledFIFO
  466. * @param LPUARTx LPUART Instance
  467. * @retval State of bit (1 or 0).
  468. */
  469. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledFIFO(USART_TypeDef *LPUARTx)
  470. {
  471. return ((READ_BIT(LPUARTx->CR1, USART_CR1_FIFOEN) == (USART_CR1_FIFOEN)) ? 1UL : 0UL);
  472. }
  473. /**
  474. * @brief Configure TX FIFO Threshold
  475. * @rmtoll CR3 TXFTCFG LL_LPUART_SetTXFIFOThreshold
  476. * @param LPUARTx LPUART Instance
  477. * @param Threshold This parameter can be one of the following values:
  478. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  479. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  480. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  481. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  482. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  483. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  484. * @retval None
  485. */
  486. __STATIC_INLINE void LL_LPUART_SetTXFIFOThreshold(USART_TypeDef *LPUARTx, uint32_t Threshold)
  487. {
  488. MODIFY_REG(LPUARTx->CR3, USART_CR3_TXFTCFG, Threshold << USART_CR3_TXFTCFG_Pos);
  489. }
  490. /**
  491. * @brief Return TX FIFO Threshold Configuration
  492. * @rmtoll CR3 TXFTCFG LL_LPUART_GetTXFIFOThreshold
  493. * @param LPUARTx LPUART Instance
  494. * @retval Returned value can be one of the following values:
  495. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  496. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  497. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  498. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  499. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  500. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  501. */
  502. __STATIC_INLINE uint32_t LL_LPUART_GetTXFIFOThreshold(USART_TypeDef *LPUARTx)
  503. {
  504. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_TXFTCFG) >> USART_CR3_TXFTCFG_Pos);
  505. }
  506. /**
  507. * @brief Configure RX FIFO Threshold
  508. * @rmtoll CR3 RXFTCFG LL_LPUART_SetRXFIFOThreshold
  509. * @param LPUARTx LPUART Instance
  510. * @param Threshold This parameter can be one of the following values:
  511. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  512. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  513. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  514. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  515. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  516. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  517. * @retval None
  518. */
  519. __STATIC_INLINE void LL_LPUART_SetRXFIFOThreshold(USART_TypeDef *LPUARTx, uint32_t Threshold)
  520. {
  521. MODIFY_REG(LPUARTx->CR3, USART_CR3_RXFTCFG, Threshold << USART_CR3_RXFTCFG_Pos);
  522. }
  523. /**
  524. * @brief Return RX FIFO Threshold Configuration
  525. * @rmtoll CR3 RXFTCFG LL_LPUART_GetRXFIFOThreshold
  526. * @param LPUARTx LPUART Instance
  527. * @retval Returned value can be one of the following values:
  528. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  529. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  530. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  531. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  532. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  533. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  534. */
  535. __STATIC_INLINE uint32_t LL_LPUART_GetRXFIFOThreshold(USART_TypeDef *LPUARTx)
  536. {
  537. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_RXFTCFG) >> USART_CR3_RXFTCFG_Pos);
  538. }
  539. /**
  540. * @brief Configure TX and RX FIFOs Threshold
  541. * @rmtoll CR3 TXFTCFG LL_LPUART_ConfigFIFOsThreshold\n
  542. * CR3 RXFTCFG LL_LPUART_ConfigFIFOsThreshold
  543. * @param LPUARTx LPUART Instance
  544. * @param TXThreshold This parameter can be one of the following values:
  545. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  546. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  547. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  548. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  549. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  550. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  551. * @param RXThreshold This parameter can be one of the following values:
  552. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8
  553. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4
  554. * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2
  555. * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4
  556. * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8
  557. * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8
  558. * @retval None
  559. */
  560. __STATIC_INLINE void LL_LPUART_ConfigFIFOsThreshold(USART_TypeDef *LPUARTx, uint32_t TXThreshold, uint32_t RXThreshold)
  561. {
  562. MODIFY_REG(LPUARTx->CR3, USART_CR3_TXFTCFG | USART_CR3_RXFTCFG, (TXThreshold << USART_CR3_TXFTCFG_Pos) | (RXThreshold << USART_CR3_RXFTCFG_Pos));
  563. }
  564. /**
  565. * @brief LPUART enabled in STOP Mode
  566. * @note When this function is enabled, LPUART is able to wake up the MCU from Stop mode, provided that
  567. * LPUART clock selection is HSI or LSE in RCC.
  568. * @rmtoll CR1 UESM LL_LPUART_EnableInStopMode
  569. * @param LPUARTx LPUART Instance
  570. * @retval None
  571. */
  572. __STATIC_INLINE void LL_LPUART_EnableInStopMode(USART_TypeDef *LPUARTx)
  573. {
  574. SET_BIT(LPUARTx->CR1, USART_CR1_UESM);
  575. }
  576. /**
  577. * @brief LPUART disabled in STOP Mode
  578. * @note When this function is disabled, LPUART is not able to wake up the MCU from Stop mode
  579. * @rmtoll CR1 UESM LL_LPUART_DisableInStopMode
  580. * @param LPUARTx LPUART Instance
  581. * @retval None
  582. */
  583. __STATIC_INLINE void LL_LPUART_DisableInStopMode(USART_TypeDef *LPUARTx)
  584. {
  585. CLEAR_BIT(LPUARTx->CR1, USART_CR1_UESM);
  586. }
  587. /**
  588. * @brief Indicate if LPUART is enabled in STOP Mode
  589. * (able to wake up MCU from Stop mode or not)
  590. * @rmtoll CR1 UESM LL_LPUART_IsEnabledInStopMode
  591. * @param LPUARTx LPUART Instance
  592. * @retval State of bit (1 or 0).
  593. */
  594. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledInStopMode(USART_TypeDef *LPUARTx)
  595. {
  596. return ((READ_BIT(LPUARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM)) ? 1UL : 0UL);
  597. }
  598. /**
  599. * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit)
  600. * @rmtoll CR1 RE LL_LPUART_EnableDirectionRx
  601. * @param LPUARTx LPUART Instance
  602. * @retval None
  603. */
  604. __STATIC_INLINE void LL_LPUART_EnableDirectionRx(USART_TypeDef *LPUARTx)
  605. {
  606. SET_BIT(LPUARTx->CR1, USART_CR1_RE);
  607. }
  608. /**
  609. * @brief Receiver Disable
  610. * @rmtoll CR1 RE LL_LPUART_DisableDirectionRx
  611. * @param LPUARTx LPUART Instance
  612. * @retval None
  613. */
  614. __STATIC_INLINE void LL_LPUART_DisableDirectionRx(USART_TypeDef *LPUARTx)
  615. {
  616. CLEAR_BIT(LPUARTx->CR1, USART_CR1_RE);
  617. }
  618. /**
  619. * @brief Transmitter Enable
  620. * @rmtoll CR1 TE LL_LPUART_EnableDirectionTx
  621. * @param LPUARTx LPUART Instance
  622. * @retval None
  623. */
  624. __STATIC_INLINE void LL_LPUART_EnableDirectionTx(USART_TypeDef *LPUARTx)
  625. {
  626. SET_BIT(LPUARTx->CR1, USART_CR1_TE);
  627. }
  628. /**
  629. * @brief Transmitter Disable
  630. * @rmtoll CR1 TE LL_LPUART_DisableDirectionTx
  631. * @param LPUARTx LPUART Instance
  632. * @retval None
  633. */
  634. __STATIC_INLINE void LL_LPUART_DisableDirectionTx(USART_TypeDef *LPUARTx)
  635. {
  636. CLEAR_BIT(LPUARTx->CR1, USART_CR1_TE);
  637. }
  638. /**
  639. * @brief Configure simultaneously enabled/disabled states
  640. * of Transmitter and Receiver
  641. * @rmtoll CR1 RE LL_LPUART_SetTransferDirection\n
  642. * CR1 TE LL_LPUART_SetTransferDirection
  643. * @param LPUARTx LPUART Instance
  644. * @param TransferDirection This parameter can be one of the following values:
  645. * @arg @ref LL_LPUART_DIRECTION_NONE
  646. * @arg @ref LL_LPUART_DIRECTION_RX
  647. * @arg @ref LL_LPUART_DIRECTION_TX
  648. * @arg @ref LL_LPUART_DIRECTION_TX_RX
  649. * @retval None
  650. */
  651. __STATIC_INLINE void LL_LPUART_SetTransferDirection(USART_TypeDef *LPUARTx, uint32_t TransferDirection)
  652. {
  653. MODIFY_REG(LPUARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection);
  654. }
  655. /**
  656. * @brief Return enabled/disabled states of Transmitter and Receiver
  657. * @rmtoll CR1 RE LL_LPUART_GetTransferDirection\n
  658. * CR1 TE LL_LPUART_GetTransferDirection
  659. * @param LPUARTx LPUART Instance
  660. * @retval Returned value can be one of the following values:
  661. * @arg @ref LL_LPUART_DIRECTION_NONE
  662. * @arg @ref LL_LPUART_DIRECTION_RX
  663. * @arg @ref LL_LPUART_DIRECTION_TX
  664. * @arg @ref LL_LPUART_DIRECTION_TX_RX
  665. */
  666. __STATIC_INLINE uint32_t LL_LPUART_GetTransferDirection(USART_TypeDef *LPUARTx)
  667. {
  668. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_RE | USART_CR1_TE));
  669. }
  670. /**
  671. * @brief Configure Parity (enabled/disabled and parity mode if enabled)
  672. * @note This function selects if hardware parity control (generation and detection) is enabled or disabled.
  673. * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position
  674. * (depending on data width) and parity is checked on the received data.
  675. * @rmtoll CR1 PS LL_LPUART_SetParity\n
  676. * CR1 PCE LL_LPUART_SetParity
  677. * @param LPUARTx LPUART Instance
  678. * @param Parity This parameter can be one of the following values:
  679. * @arg @ref LL_LPUART_PARITY_NONE
  680. * @arg @ref LL_LPUART_PARITY_EVEN
  681. * @arg @ref LL_LPUART_PARITY_ODD
  682. * @retval None
  683. */
  684. __STATIC_INLINE void LL_LPUART_SetParity(USART_TypeDef *LPUARTx, uint32_t Parity)
  685. {
  686. MODIFY_REG(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity);
  687. }
  688. /**
  689. * @brief Return Parity configuration (enabled/disabled and parity mode if enabled)
  690. * @rmtoll CR1 PS LL_LPUART_GetParity\n
  691. * CR1 PCE LL_LPUART_GetParity
  692. * @param LPUARTx LPUART Instance
  693. * @retval Returned value can be one of the following values:
  694. * @arg @ref LL_LPUART_PARITY_NONE
  695. * @arg @ref LL_LPUART_PARITY_EVEN
  696. * @arg @ref LL_LPUART_PARITY_ODD
  697. */
  698. __STATIC_INLINE uint32_t LL_LPUART_GetParity(USART_TypeDef *LPUARTx)
  699. {
  700. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE));
  701. }
  702. /**
  703. * @brief Set Receiver Wake Up method from Mute mode.
  704. * @rmtoll CR1 WAKE LL_LPUART_SetWakeUpMethod
  705. * @param LPUARTx LPUART Instance
  706. * @param Method This parameter can be one of the following values:
  707. * @arg @ref LL_LPUART_WAKEUP_IDLELINE
  708. * @arg @ref LL_LPUART_WAKEUP_ADDRESSMARK
  709. * @retval None
  710. */
  711. __STATIC_INLINE void LL_LPUART_SetWakeUpMethod(USART_TypeDef *LPUARTx, uint32_t Method)
  712. {
  713. MODIFY_REG(LPUARTx->CR1, USART_CR1_WAKE, Method);
  714. }
  715. /**
  716. * @brief Return Receiver Wake Up method from Mute mode
  717. * @rmtoll CR1 WAKE LL_LPUART_GetWakeUpMethod
  718. * @param LPUARTx LPUART Instance
  719. * @retval Returned value can be one of the following values:
  720. * @arg @ref LL_LPUART_WAKEUP_IDLELINE
  721. * @arg @ref LL_LPUART_WAKEUP_ADDRESSMARK
  722. */
  723. __STATIC_INLINE uint32_t LL_LPUART_GetWakeUpMethod(USART_TypeDef *LPUARTx)
  724. {
  725. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_WAKE));
  726. }
  727. /**
  728. * @brief Set Word length (nb of data bits, excluding start and stop bits)
  729. * @rmtoll CR1 M LL_LPUART_SetDataWidth
  730. * @param LPUARTx LPUART Instance
  731. * @param DataWidth This parameter can be one of the following values:
  732. * @arg @ref LL_LPUART_DATAWIDTH_7B
  733. * @arg @ref LL_LPUART_DATAWIDTH_8B
  734. * @arg @ref LL_LPUART_DATAWIDTH_9B
  735. * @retval None
  736. */
  737. __STATIC_INLINE void LL_LPUART_SetDataWidth(USART_TypeDef *LPUARTx, uint32_t DataWidth)
  738. {
  739. MODIFY_REG(LPUARTx->CR1, USART_CR1_M, DataWidth);
  740. }
  741. /**
  742. * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits)
  743. * @rmtoll CR1 M LL_LPUART_GetDataWidth
  744. * @param LPUARTx LPUART Instance
  745. * @retval Returned value can be one of the following values:
  746. * @arg @ref LL_LPUART_DATAWIDTH_7B
  747. * @arg @ref LL_LPUART_DATAWIDTH_8B
  748. * @arg @ref LL_LPUART_DATAWIDTH_9B
  749. */
  750. __STATIC_INLINE uint32_t LL_LPUART_GetDataWidth(USART_TypeDef *LPUARTx)
  751. {
  752. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_M));
  753. }
  754. /**
  755. * @brief Allow switch between Mute Mode and Active mode
  756. * @rmtoll CR1 MME LL_LPUART_EnableMuteMode
  757. * @param LPUARTx LPUART Instance
  758. * @retval None
  759. */
  760. __STATIC_INLINE void LL_LPUART_EnableMuteMode(USART_TypeDef *LPUARTx)
  761. {
  762. SET_BIT(LPUARTx->CR1, USART_CR1_MME);
  763. }
  764. /**
  765. * @brief Prevent Mute Mode use. Set Receiver in active mode permanently.
  766. * @rmtoll CR1 MME LL_LPUART_DisableMuteMode
  767. * @param LPUARTx LPUART Instance
  768. * @retval None
  769. */
  770. __STATIC_INLINE void LL_LPUART_DisableMuteMode(USART_TypeDef *LPUARTx)
  771. {
  772. CLEAR_BIT(LPUARTx->CR1, USART_CR1_MME);
  773. }
  774. /**
  775. * @brief Indicate if switch between Mute Mode and Active mode is allowed
  776. * @rmtoll CR1 MME LL_LPUART_IsEnabledMuteMode
  777. * @param LPUARTx LPUART Instance
  778. * @retval State of bit (1 or 0).
  779. */
  780. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledMuteMode(USART_TypeDef *LPUARTx)
  781. {
  782. return ((READ_BIT(LPUARTx->CR1, USART_CR1_MME) == (USART_CR1_MME)) ? 1UL : 0UL);
  783. }
  784. /**
  785. * @brief Configure Clock source prescaler for baudrate generator and oversampling
  786. * @rmtoll PRESC PRESCALER LL_LPUART_SetPrescaler
  787. * @param LPUARTx LPUART Instance
  788. * @param PrescalerValue This parameter can be one of the following values:
  789. * @arg @ref LL_LPUART_PRESCALER_DIV1
  790. * @arg @ref LL_LPUART_PRESCALER_DIV2
  791. * @arg @ref LL_LPUART_PRESCALER_DIV4
  792. * @arg @ref LL_LPUART_PRESCALER_DIV6
  793. * @arg @ref LL_LPUART_PRESCALER_DIV8
  794. * @arg @ref LL_LPUART_PRESCALER_DIV10
  795. * @arg @ref LL_LPUART_PRESCALER_DIV12
  796. * @arg @ref LL_LPUART_PRESCALER_DIV16
  797. * @arg @ref LL_LPUART_PRESCALER_DIV32
  798. * @arg @ref LL_LPUART_PRESCALER_DIV64
  799. * @arg @ref LL_LPUART_PRESCALER_DIV128
  800. * @arg @ref LL_LPUART_PRESCALER_DIV256
  801. * @retval None
  802. */
  803. __STATIC_INLINE void LL_LPUART_SetPrescaler(USART_TypeDef *LPUARTx, uint32_t PrescalerValue)
  804. {
  805. MODIFY_REG(LPUARTx->PRESC, USART_PRESC_PRESCALER, (uint16_t)PrescalerValue);
  806. }
  807. /**
  808. * @brief Retrieve the Clock source prescaler for baudrate generator and oversampling
  809. * @rmtoll PRESC PRESCALER LL_LPUART_GetPrescaler
  810. * @param LPUARTx LPUART Instance
  811. * @retval Returned value can be one of the following values:
  812. * @arg @ref LL_LPUART_PRESCALER_DIV1
  813. * @arg @ref LL_LPUART_PRESCALER_DIV2
  814. * @arg @ref LL_LPUART_PRESCALER_DIV4
  815. * @arg @ref LL_LPUART_PRESCALER_DIV6
  816. * @arg @ref LL_LPUART_PRESCALER_DIV8
  817. * @arg @ref LL_LPUART_PRESCALER_DIV10
  818. * @arg @ref LL_LPUART_PRESCALER_DIV12
  819. * @arg @ref LL_LPUART_PRESCALER_DIV16
  820. * @arg @ref LL_LPUART_PRESCALER_DIV32
  821. * @arg @ref LL_LPUART_PRESCALER_DIV64
  822. * @arg @ref LL_LPUART_PRESCALER_DIV128
  823. * @arg @ref LL_LPUART_PRESCALER_DIV256
  824. */
  825. __STATIC_INLINE uint32_t LL_LPUART_GetPrescaler(USART_TypeDef *LPUARTx)
  826. {
  827. return (uint32_t)(READ_BIT(LPUARTx->PRESC, USART_PRESC_PRESCALER));
  828. }
  829. /**
  830. * @brief Set the length of the stop bits
  831. * @rmtoll CR2 STOP LL_LPUART_SetStopBitsLength
  832. * @param LPUARTx LPUART Instance
  833. * @param StopBits This parameter can be one of the following values:
  834. * @arg @ref LL_LPUART_STOPBITS_1
  835. * @arg @ref LL_LPUART_STOPBITS_2
  836. * @retval None
  837. */
  838. __STATIC_INLINE void LL_LPUART_SetStopBitsLength(USART_TypeDef *LPUARTx, uint32_t StopBits)
  839. {
  840. MODIFY_REG(LPUARTx->CR2, USART_CR2_STOP, StopBits);
  841. }
  842. /**
  843. * @brief Retrieve the length of the stop bits
  844. * @rmtoll CR2 STOP LL_LPUART_GetStopBitsLength
  845. * @param LPUARTx LPUART Instance
  846. * @retval Returned value can be one of the following values:
  847. * @arg @ref LL_LPUART_STOPBITS_1
  848. * @arg @ref LL_LPUART_STOPBITS_2
  849. */
  850. __STATIC_INLINE uint32_t LL_LPUART_GetStopBitsLength(USART_TypeDef *LPUARTx)
  851. {
  852. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_STOP));
  853. }
  854. /**
  855. * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits)
  856. * @note Call of this function is equivalent to following function call sequence :
  857. * - Data Width configuration using @ref LL_LPUART_SetDataWidth() function
  858. * - Parity Control and mode configuration using @ref LL_LPUART_SetParity() function
  859. * - Stop bits configuration using @ref LL_LPUART_SetStopBitsLength() function
  860. * @rmtoll CR1 PS LL_LPUART_ConfigCharacter\n
  861. * CR1 PCE LL_LPUART_ConfigCharacter\n
  862. * CR1 M LL_LPUART_ConfigCharacter\n
  863. * CR2 STOP LL_LPUART_ConfigCharacter
  864. * @param LPUARTx LPUART Instance
  865. * @param DataWidth This parameter can be one of the following values:
  866. * @arg @ref LL_LPUART_DATAWIDTH_7B
  867. * @arg @ref LL_LPUART_DATAWIDTH_8B
  868. * @arg @ref LL_LPUART_DATAWIDTH_9B
  869. * @param Parity This parameter can be one of the following values:
  870. * @arg @ref LL_LPUART_PARITY_NONE
  871. * @arg @ref LL_LPUART_PARITY_EVEN
  872. * @arg @ref LL_LPUART_PARITY_ODD
  873. * @param StopBits This parameter can be one of the following values:
  874. * @arg @ref LL_LPUART_STOPBITS_1
  875. * @arg @ref LL_LPUART_STOPBITS_2
  876. * @retval None
  877. */
  878. __STATIC_INLINE void LL_LPUART_ConfigCharacter(USART_TypeDef *LPUARTx, uint32_t DataWidth, uint32_t Parity,
  879. uint32_t StopBits)
  880. {
  881. MODIFY_REG(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth);
  882. MODIFY_REG(LPUARTx->CR2, USART_CR2_STOP, StopBits);
  883. }
  884. /**
  885. * @brief Configure TX/RX pins swapping setting.
  886. * @rmtoll CR2 SWAP LL_LPUART_SetTXRXSwap
  887. * @param LPUARTx LPUART Instance
  888. * @param SwapConfig This parameter can be one of the following values:
  889. * @arg @ref LL_LPUART_TXRX_STANDARD
  890. * @arg @ref LL_LPUART_TXRX_SWAPPED
  891. * @retval None
  892. */
  893. __STATIC_INLINE void LL_LPUART_SetTXRXSwap(USART_TypeDef *LPUARTx, uint32_t SwapConfig)
  894. {
  895. MODIFY_REG(LPUARTx->CR2, USART_CR2_SWAP, SwapConfig);
  896. }
  897. /**
  898. * @brief Retrieve TX/RX pins swapping configuration.
  899. * @rmtoll CR2 SWAP LL_LPUART_GetTXRXSwap
  900. * @param LPUARTx LPUART Instance
  901. * @retval Returned value can be one of the following values:
  902. * @arg @ref LL_LPUART_TXRX_STANDARD
  903. * @arg @ref LL_LPUART_TXRX_SWAPPED
  904. */
  905. __STATIC_INLINE uint32_t LL_LPUART_GetTXRXSwap(USART_TypeDef *LPUARTx)
  906. {
  907. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_SWAP));
  908. }
  909. /**
  910. * @brief Configure RX pin active level logic
  911. * @rmtoll CR2 RXINV LL_LPUART_SetRXPinLevel
  912. * @param LPUARTx LPUART Instance
  913. * @param PinInvMethod This parameter can be one of the following values:
  914. * @arg @ref LL_LPUART_RXPIN_LEVEL_STANDARD
  915. * @arg @ref LL_LPUART_RXPIN_LEVEL_INVERTED
  916. * @retval None
  917. */
  918. __STATIC_INLINE void LL_LPUART_SetRXPinLevel(USART_TypeDef *LPUARTx, uint32_t PinInvMethod)
  919. {
  920. MODIFY_REG(LPUARTx->CR2, USART_CR2_RXINV, PinInvMethod);
  921. }
  922. /**
  923. * @brief Retrieve RX pin active level logic configuration
  924. * @rmtoll CR2 RXINV LL_LPUART_GetRXPinLevel
  925. * @param LPUARTx LPUART Instance
  926. * @retval Returned value can be one of the following values:
  927. * @arg @ref LL_LPUART_RXPIN_LEVEL_STANDARD
  928. * @arg @ref LL_LPUART_RXPIN_LEVEL_INVERTED
  929. */
  930. __STATIC_INLINE uint32_t LL_LPUART_GetRXPinLevel(USART_TypeDef *LPUARTx)
  931. {
  932. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_RXINV));
  933. }
  934. /**
  935. * @brief Configure TX pin active level logic
  936. * @rmtoll CR2 TXINV LL_LPUART_SetTXPinLevel
  937. * @param LPUARTx LPUART Instance
  938. * @param PinInvMethod This parameter can be one of the following values:
  939. * @arg @ref LL_LPUART_TXPIN_LEVEL_STANDARD
  940. * @arg @ref LL_LPUART_TXPIN_LEVEL_INVERTED
  941. * @retval None
  942. */
  943. __STATIC_INLINE void LL_LPUART_SetTXPinLevel(USART_TypeDef *LPUARTx, uint32_t PinInvMethod)
  944. {
  945. MODIFY_REG(LPUARTx->CR2, USART_CR2_TXINV, PinInvMethod);
  946. }
  947. /**
  948. * @brief Retrieve TX pin active level logic configuration
  949. * @rmtoll CR2 TXINV LL_LPUART_GetTXPinLevel
  950. * @param LPUARTx LPUART Instance
  951. * @retval Returned value can be one of the following values:
  952. * @arg @ref LL_LPUART_TXPIN_LEVEL_STANDARD
  953. * @arg @ref LL_LPUART_TXPIN_LEVEL_INVERTED
  954. */
  955. __STATIC_INLINE uint32_t LL_LPUART_GetTXPinLevel(USART_TypeDef *LPUARTx)
  956. {
  957. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_TXINV));
  958. }
  959. /**
  960. * @brief Configure Binary data logic.
  961. *
  962. * @note Allow to define how Logical data from the data register are send/received :
  963. * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H)
  964. * @rmtoll CR2 DATAINV LL_LPUART_SetBinaryDataLogic
  965. * @param LPUARTx LPUART Instance
  966. * @param DataLogic This parameter can be one of the following values:
  967. * @arg @ref LL_LPUART_BINARY_LOGIC_POSITIVE
  968. * @arg @ref LL_LPUART_BINARY_LOGIC_NEGATIVE
  969. * @retval None
  970. */
  971. __STATIC_INLINE void LL_LPUART_SetBinaryDataLogic(USART_TypeDef *LPUARTx, uint32_t DataLogic)
  972. {
  973. MODIFY_REG(LPUARTx->CR2, USART_CR2_DATAINV, DataLogic);
  974. }
  975. /**
  976. * @brief Retrieve Binary data configuration
  977. * @rmtoll CR2 DATAINV LL_LPUART_GetBinaryDataLogic
  978. * @param LPUARTx LPUART Instance
  979. * @retval Returned value can be one of the following values:
  980. * @arg @ref LL_LPUART_BINARY_LOGIC_POSITIVE
  981. * @arg @ref LL_LPUART_BINARY_LOGIC_NEGATIVE
  982. */
  983. __STATIC_INLINE uint32_t LL_LPUART_GetBinaryDataLogic(USART_TypeDef *LPUARTx)
  984. {
  985. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_DATAINV));
  986. }
  987. /**
  988. * @brief Configure transfer bit order (either Less or Most Significant Bit First)
  989. * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
  990. * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
  991. * @rmtoll CR2 MSBFIRST LL_LPUART_SetTransferBitOrder
  992. * @param LPUARTx LPUART Instance
  993. * @param BitOrder This parameter can be one of the following values:
  994. * @arg @ref LL_LPUART_BITORDER_LSBFIRST
  995. * @arg @ref LL_LPUART_BITORDER_MSBFIRST
  996. * @retval None
  997. */
  998. __STATIC_INLINE void LL_LPUART_SetTransferBitOrder(USART_TypeDef *LPUARTx, uint32_t BitOrder)
  999. {
  1000. MODIFY_REG(LPUARTx->CR2, USART_CR2_MSBFIRST, BitOrder);
  1001. }
  1002. /**
  1003. * @brief Return transfer bit order (either Less or Most Significant Bit First)
  1004. * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
  1005. * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
  1006. * @rmtoll CR2 MSBFIRST LL_LPUART_GetTransferBitOrder
  1007. * @param LPUARTx LPUART Instance
  1008. * @retval Returned value can be one of the following values:
  1009. * @arg @ref LL_LPUART_BITORDER_LSBFIRST
  1010. * @arg @ref LL_LPUART_BITORDER_MSBFIRST
  1011. */
  1012. __STATIC_INLINE uint32_t LL_LPUART_GetTransferBitOrder(USART_TypeDef *LPUARTx)
  1013. {
  1014. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_MSBFIRST));
  1015. }
  1016. /**
  1017. * @brief Set Address of the LPUART node.
  1018. * @note This is used in multiprocessor communication during Mute mode or Stop mode,
  1019. * for wake up with address mark detection.
  1020. * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7.
  1021. * (b7-b4 should be set to 0)
  1022. * 8bits address node is used when 7-bit Address Detection is selected in ADDM7.
  1023. * (This is used in multiprocessor communication during Mute mode or Stop mode,
  1024. * for wake up with 7-bit address mark detection.
  1025. * The MSB of the character sent by the transmitter should be equal to 1.
  1026. * It may also be used for character detection during normal reception,
  1027. * Mute mode inactive (for example, end of block detection in ModBus protocol).
  1028. * In this case, the whole received character (8-bit) is compared to the ADD[7:0]
  1029. * value and CMF flag is set on match)
  1030. * @rmtoll CR2 ADD LL_LPUART_ConfigNodeAddress\n
  1031. * CR2 ADDM7 LL_LPUART_ConfigNodeAddress
  1032. * @param LPUARTx LPUART Instance
  1033. * @param AddressLen This parameter can be one of the following values:
  1034. * @arg @ref LL_LPUART_ADDRESS_DETECT_4B
  1035. * @arg @ref LL_LPUART_ADDRESS_DETECT_7B
  1036. * @param NodeAddress 4 or 7 bit Address of the LPUART node.
  1037. * @retval None
  1038. */
  1039. __STATIC_INLINE void LL_LPUART_ConfigNodeAddress(USART_TypeDef *LPUARTx, uint32_t AddressLen, uint32_t NodeAddress)
  1040. {
  1041. MODIFY_REG(LPUARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7,
  1042. (uint32_t)(AddressLen | (NodeAddress << USART_CR2_ADD_Pos)));
  1043. }
  1044. /**
  1045. * @brief Return 8 bit Address of the LPUART node as set in ADD field of CR2.
  1046. * @note If 4-bit Address Detection is selected in ADDM7,
  1047. * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant)
  1048. * If 7-bit Address Detection is selected in ADDM7,
  1049. * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant)
  1050. * @rmtoll CR2 ADD LL_LPUART_GetNodeAddress
  1051. * @param LPUARTx LPUART Instance
  1052. * @retval Address of the LPUART node (Value between Min_Data=0 and Max_Data=255)
  1053. */
  1054. __STATIC_INLINE uint32_t LL_LPUART_GetNodeAddress(USART_TypeDef *LPUARTx)
  1055. {
  1056. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_ADD) >> USART_CR2_ADD_Pos);
  1057. }
  1058. /**
  1059. * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit)
  1060. * @rmtoll CR2 ADDM7 LL_LPUART_GetNodeAddressLen
  1061. * @param LPUARTx LPUART Instance
  1062. * @retval Returned value can be one of the following values:
  1063. * @arg @ref LL_LPUART_ADDRESS_DETECT_4B
  1064. * @arg @ref LL_LPUART_ADDRESS_DETECT_7B
  1065. */
  1066. __STATIC_INLINE uint32_t LL_LPUART_GetNodeAddressLen(USART_TypeDef *LPUARTx)
  1067. {
  1068. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_ADDM7));
  1069. }
  1070. /**
  1071. * @brief Enable RTS HW Flow Control
  1072. * @rmtoll CR3 RTSE LL_LPUART_EnableRTSHWFlowCtrl
  1073. * @param LPUARTx LPUART Instance
  1074. * @retval None
  1075. */
  1076. __STATIC_INLINE void LL_LPUART_EnableRTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  1077. {
  1078. SET_BIT(LPUARTx->CR3, USART_CR3_RTSE);
  1079. }
  1080. /**
  1081. * @brief Disable RTS HW Flow Control
  1082. * @rmtoll CR3 RTSE LL_LPUART_DisableRTSHWFlowCtrl
  1083. * @param LPUARTx LPUART Instance
  1084. * @retval None
  1085. */
  1086. __STATIC_INLINE void LL_LPUART_DisableRTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  1087. {
  1088. CLEAR_BIT(LPUARTx->CR3, USART_CR3_RTSE);
  1089. }
  1090. /**
  1091. * @brief Enable CTS HW Flow Control
  1092. * @rmtoll CR3 CTSE LL_LPUART_EnableCTSHWFlowCtrl
  1093. * @param LPUARTx LPUART Instance
  1094. * @retval None
  1095. */
  1096. __STATIC_INLINE void LL_LPUART_EnableCTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  1097. {
  1098. SET_BIT(LPUARTx->CR3, USART_CR3_CTSE);
  1099. }
  1100. /**
  1101. * @brief Disable CTS HW Flow Control
  1102. * @rmtoll CR3 CTSE LL_LPUART_DisableCTSHWFlowCtrl
  1103. * @param LPUARTx LPUART Instance
  1104. * @retval None
  1105. */
  1106. __STATIC_INLINE void LL_LPUART_DisableCTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  1107. {
  1108. CLEAR_BIT(LPUARTx->CR3, USART_CR3_CTSE);
  1109. }
  1110. /**
  1111. * @brief Configure HW Flow Control mode (both CTS and RTS)
  1112. * @rmtoll CR3 RTSE LL_LPUART_SetHWFlowCtrl\n
  1113. * CR3 CTSE LL_LPUART_SetHWFlowCtrl
  1114. * @param LPUARTx LPUART Instance
  1115. * @param HardwareFlowControl This parameter can be one of the following values:
  1116. * @arg @ref LL_LPUART_HWCONTROL_NONE
  1117. * @arg @ref LL_LPUART_HWCONTROL_RTS
  1118. * @arg @ref LL_LPUART_HWCONTROL_CTS
  1119. * @arg @ref LL_LPUART_HWCONTROL_RTS_CTS
  1120. * @retval None
  1121. */
  1122. __STATIC_INLINE void LL_LPUART_SetHWFlowCtrl(USART_TypeDef *LPUARTx, uint32_t HardwareFlowControl)
  1123. {
  1124. MODIFY_REG(LPUARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl);
  1125. }
  1126. /**
  1127. * @brief Return HW Flow Control configuration (both CTS and RTS)
  1128. * @rmtoll CR3 RTSE LL_LPUART_GetHWFlowCtrl\n
  1129. * CR3 CTSE LL_LPUART_GetHWFlowCtrl
  1130. * @param LPUARTx LPUART Instance
  1131. * @retval Returned value can be one of the following values:
  1132. * @arg @ref LL_LPUART_HWCONTROL_NONE
  1133. * @arg @ref LL_LPUART_HWCONTROL_RTS
  1134. * @arg @ref LL_LPUART_HWCONTROL_CTS
  1135. * @arg @ref LL_LPUART_HWCONTROL_RTS_CTS
  1136. */
  1137. __STATIC_INLINE uint32_t LL_LPUART_GetHWFlowCtrl(USART_TypeDef *LPUARTx)
  1138. {
  1139. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE));
  1140. }
  1141. /**
  1142. * @brief Enable Overrun detection
  1143. * @rmtoll CR3 OVRDIS LL_LPUART_EnableOverrunDetect
  1144. * @param LPUARTx LPUART Instance
  1145. * @retval None
  1146. */
  1147. __STATIC_INLINE void LL_LPUART_EnableOverrunDetect(USART_TypeDef *LPUARTx)
  1148. {
  1149. CLEAR_BIT(LPUARTx->CR3, USART_CR3_OVRDIS);
  1150. }
  1151. /**
  1152. * @brief Disable Overrun detection
  1153. * @rmtoll CR3 OVRDIS LL_LPUART_DisableOverrunDetect
  1154. * @param LPUARTx LPUART Instance
  1155. * @retval None
  1156. */
  1157. __STATIC_INLINE void LL_LPUART_DisableOverrunDetect(USART_TypeDef *LPUARTx)
  1158. {
  1159. SET_BIT(LPUARTx->CR3, USART_CR3_OVRDIS);
  1160. }
  1161. /**
  1162. * @brief Indicate if Overrun detection is enabled
  1163. * @rmtoll CR3 OVRDIS LL_LPUART_IsEnabledOverrunDetect
  1164. * @param LPUARTx LPUART Instance
  1165. * @retval State of bit (1 or 0).
  1166. */
  1167. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledOverrunDetect(USART_TypeDef *LPUARTx)
  1168. {
  1169. return ((READ_BIT(LPUARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS) ? 1UL : 0UL);
  1170. }
  1171. /**
  1172. * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits)
  1173. * @rmtoll CR3 WUS LL_LPUART_SetWKUPType
  1174. * @param LPUARTx LPUART Instance
  1175. * @param Type This parameter can be one of the following values:
  1176. * @arg @ref LL_LPUART_WAKEUP_ON_ADDRESS
  1177. * @arg @ref LL_LPUART_WAKEUP_ON_STARTBIT
  1178. * @arg @ref LL_LPUART_WAKEUP_ON_RXNE
  1179. * @retval None
  1180. */
  1181. __STATIC_INLINE void LL_LPUART_SetWKUPType(USART_TypeDef *LPUARTx, uint32_t Type)
  1182. {
  1183. MODIFY_REG(LPUARTx->CR3, USART_CR3_WUS, Type);
  1184. }
  1185. /**
  1186. * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits)
  1187. * @rmtoll CR3 WUS LL_LPUART_GetWKUPType
  1188. * @param LPUARTx LPUART Instance
  1189. * @retval Returned value can be one of the following values:
  1190. * @arg @ref LL_LPUART_WAKEUP_ON_ADDRESS
  1191. * @arg @ref LL_LPUART_WAKEUP_ON_STARTBIT
  1192. * @arg @ref LL_LPUART_WAKEUP_ON_RXNE
  1193. */
  1194. __STATIC_INLINE uint32_t LL_LPUART_GetWKUPType(USART_TypeDef *LPUARTx)
  1195. {
  1196. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_WUS));
  1197. }
  1198. /**
  1199. * @brief Configure LPUART BRR register for achieving expected Baud Rate value.
  1200. *
  1201. * @note Compute and set LPUARTDIV value in BRR Register (full BRR content)
  1202. * according to used Peripheral Clock and expected Baud Rate values
  1203. * @note Peripheral clock and Baud Rate values provided as function parameters should be valid
  1204. * (Baud rate value != 0).
  1205. * @note Provided that LPUARTx_BRR must be > = 0x300 and LPUART_BRR is 20-bit,
  1206. * a care should be taken when generating high baud rates using high PeriphClk
  1207. * values. PeriphClk must be in the range [3 x BaudRate, 4096 x BaudRate].
  1208. * @rmtoll BRR BRR LL_LPUART_SetBaudRate
  1209. * @param LPUARTx LPUART Instance
  1210. * @param PeriphClk Peripheral Clock
  1211. * @param PrescalerValue This parameter can be one of the following values:
  1212. * @arg @ref LL_LPUART_PRESCALER_DIV1
  1213. * @arg @ref LL_LPUART_PRESCALER_DIV2
  1214. * @arg @ref LL_LPUART_PRESCALER_DIV4
  1215. * @arg @ref LL_LPUART_PRESCALER_DIV6
  1216. * @arg @ref LL_LPUART_PRESCALER_DIV8
  1217. * @arg @ref LL_LPUART_PRESCALER_DIV10
  1218. * @arg @ref LL_LPUART_PRESCALER_DIV12
  1219. * @arg @ref LL_LPUART_PRESCALER_DIV16
  1220. * @arg @ref LL_LPUART_PRESCALER_DIV32
  1221. * @arg @ref LL_LPUART_PRESCALER_DIV64
  1222. * @arg @ref LL_LPUART_PRESCALER_DIV128
  1223. * @arg @ref LL_LPUART_PRESCALER_DIV256
  1224. * @param BaudRate Baud Rate
  1225. * @retval None
  1226. */
  1227. __STATIC_INLINE void LL_LPUART_SetBaudRate(USART_TypeDef *LPUARTx, uint32_t PeriphClk, uint32_t PrescalerValue,
  1228. uint32_t BaudRate)
  1229. {
  1230. LPUARTx->BRR = __LL_LPUART_DIV(PeriphClk, PrescalerValue, BaudRate);
  1231. }
  1232. /**
  1233. * @brief Return current Baud Rate value, according to LPUARTDIV present in BRR register
  1234. * (full BRR content), and to used Peripheral Clock values
  1235. * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned.
  1236. * @rmtoll BRR BRR LL_LPUART_GetBaudRate
  1237. * @param LPUARTx LPUART Instance
  1238. * @param PeriphClk Peripheral Clock
  1239. * @param PrescalerValue This parameter can be one of the following values:
  1240. * @arg @ref LL_LPUART_PRESCALER_DIV1
  1241. * @arg @ref LL_LPUART_PRESCALER_DIV2
  1242. * @arg @ref LL_LPUART_PRESCALER_DIV4
  1243. * @arg @ref LL_LPUART_PRESCALER_DIV6
  1244. * @arg @ref LL_LPUART_PRESCALER_DIV8
  1245. * @arg @ref LL_LPUART_PRESCALER_DIV10
  1246. * @arg @ref LL_LPUART_PRESCALER_DIV12
  1247. * @arg @ref LL_LPUART_PRESCALER_DIV16
  1248. * @arg @ref LL_LPUART_PRESCALER_DIV32
  1249. * @arg @ref LL_LPUART_PRESCALER_DIV64
  1250. * @arg @ref LL_LPUART_PRESCALER_DIV128
  1251. * @arg @ref LL_LPUART_PRESCALER_DIV256
  1252. * @retval Baud Rate
  1253. */
  1254. __STATIC_INLINE uint32_t LL_LPUART_GetBaudRate(USART_TypeDef *LPUARTx, uint32_t PeriphClk, uint32_t PrescalerValue)
  1255. {
  1256. uint32_t lpuartdiv;
  1257. uint32_t brrresult;
  1258. uint32_t periphclkpresc = (uint32_t)(PeriphClk / (LPUART_PRESCALER_TAB[(uint16_t)PrescalerValue]));
  1259. lpuartdiv = LPUARTx->BRR & LPUART_BRR_MASK;
  1260. if (lpuartdiv >= LPUART_BRR_MIN_VALUE)
  1261. {
  1262. brrresult = (uint32_t)(((uint64_t)(periphclkpresc) * LPUART_LPUARTDIV_FREQ_MUL) / lpuartdiv);
  1263. }
  1264. else
  1265. {
  1266. brrresult = 0x0UL;
  1267. }
  1268. return (brrresult);
  1269. }
  1270. /**
  1271. * @}
  1272. */
  1273. /** @defgroup LPUART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature
  1274. * @{
  1275. */
  1276. /**
  1277. * @brief Enable Single Wire Half-Duplex mode
  1278. * @rmtoll CR3 HDSEL LL_LPUART_EnableHalfDuplex
  1279. * @param LPUARTx LPUART Instance
  1280. * @retval None
  1281. */
  1282. __STATIC_INLINE void LL_LPUART_EnableHalfDuplex(USART_TypeDef *LPUARTx)
  1283. {
  1284. SET_BIT(LPUARTx->CR3, USART_CR3_HDSEL);
  1285. }
  1286. /**
  1287. * @brief Disable Single Wire Half-Duplex mode
  1288. * @rmtoll CR3 HDSEL LL_LPUART_DisableHalfDuplex
  1289. * @param LPUARTx LPUART Instance
  1290. * @retval None
  1291. */
  1292. __STATIC_INLINE void LL_LPUART_DisableHalfDuplex(USART_TypeDef *LPUARTx)
  1293. {
  1294. CLEAR_BIT(LPUARTx->CR3, USART_CR3_HDSEL);
  1295. }
  1296. /**
  1297. * @brief Indicate if Single Wire Half-Duplex mode is enabled
  1298. * @rmtoll CR3 HDSEL LL_LPUART_IsEnabledHalfDuplex
  1299. * @param LPUARTx LPUART Instance
  1300. * @retval State of bit (1 or 0).
  1301. */
  1302. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledHalfDuplex(USART_TypeDef *LPUARTx)
  1303. {
  1304. return ((READ_BIT(LPUARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL)) ? 1UL : 0UL);
  1305. }
  1306. /**
  1307. * @}
  1308. */
  1309. /** @defgroup LPUART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature
  1310. * @{
  1311. */
  1312. /**
  1313. * @brief Set DEDT (Driver Enable De-Assertion Time), Time value expressed on 5 bits ([4:0] bits).
  1314. * @rmtoll CR1 DEDT LL_LPUART_SetDEDeassertionTime
  1315. * @param LPUARTx LPUART Instance
  1316. * @param Time Value between Min_Data=0 and Max_Data=31
  1317. * @retval None
  1318. */
  1319. __STATIC_INLINE void LL_LPUART_SetDEDeassertionTime(USART_TypeDef *LPUARTx, uint32_t Time)
  1320. {
  1321. MODIFY_REG(LPUARTx->CR1, USART_CR1_DEDT, Time << USART_CR1_DEDT_Pos);
  1322. }
  1323. /**
  1324. * @brief Return DEDT (Driver Enable De-Assertion Time)
  1325. * @rmtoll CR1 DEDT LL_LPUART_GetDEDeassertionTime
  1326. * @param LPUARTx LPUART Instance
  1327. * @retval Time value expressed on 5 bits ([4:0] bits) : c
  1328. */
  1329. __STATIC_INLINE uint32_t LL_LPUART_GetDEDeassertionTime(USART_TypeDef *LPUARTx)
  1330. {
  1331. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_DEDT) >> USART_CR1_DEDT_Pos);
  1332. }
  1333. /**
  1334. * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits).
  1335. * @rmtoll CR1 DEAT LL_LPUART_SetDEAssertionTime
  1336. * @param LPUARTx LPUART Instance
  1337. * @param Time Value between Min_Data=0 and Max_Data=31
  1338. * @retval None
  1339. */
  1340. __STATIC_INLINE void LL_LPUART_SetDEAssertionTime(USART_TypeDef *LPUARTx, uint32_t Time)
  1341. {
  1342. MODIFY_REG(LPUARTx->CR1, USART_CR1_DEAT, Time << USART_CR1_DEAT_Pos);
  1343. }
  1344. /**
  1345. * @brief Return DEAT (Driver Enable Assertion Time)
  1346. * @rmtoll CR1 DEAT LL_LPUART_GetDEAssertionTime
  1347. * @param LPUARTx LPUART Instance
  1348. * @retval Time value expressed on 5 bits ([4:0] bits) : Time Value between Min_Data=0 and Max_Data=31
  1349. */
  1350. __STATIC_INLINE uint32_t LL_LPUART_GetDEAssertionTime(USART_TypeDef *LPUARTx)
  1351. {
  1352. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_DEAT) >> USART_CR1_DEAT_Pos);
  1353. }
  1354. /**
  1355. * @brief Enable Driver Enable (DE) Mode
  1356. * @rmtoll CR3 DEM LL_LPUART_EnableDEMode
  1357. * @param LPUARTx LPUART Instance
  1358. * @retval None
  1359. */
  1360. __STATIC_INLINE void LL_LPUART_EnableDEMode(USART_TypeDef *LPUARTx)
  1361. {
  1362. SET_BIT(LPUARTx->CR3, USART_CR3_DEM);
  1363. }
  1364. /**
  1365. * @brief Disable Driver Enable (DE) Mode
  1366. * @rmtoll CR3 DEM LL_LPUART_DisableDEMode
  1367. * @param LPUARTx LPUART Instance
  1368. * @retval None
  1369. */
  1370. __STATIC_INLINE void LL_LPUART_DisableDEMode(USART_TypeDef *LPUARTx)
  1371. {
  1372. CLEAR_BIT(LPUARTx->CR3, USART_CR3_DEM);
  1373. }
  1374. /**
  1375. * @brief Indicate if Driver Enable (DE) Mode is enabled
  1376. * @rmtoll CR3 DEM LL_LPUART_IsEnabledDEMode
  1377. * @param LPUARTx LPUART Instance
  1378. * @retval State of bit (1 or 0).
  1379. */
  1380. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDEMode(USART_TypeDef *LPUARTx)
  1381. {
  1382. return ((READ_BIT(LPUARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM)) ? 1UL : 0UL);
  1383. }
  1384. /**
  1385. * @brief Select Driver Enable Polarity
  1386. * @rmtoll CR3 DEP LL_LPUART_SetDESignalPolarity
  1387. * @param LPUARTx LPUART Instance
  1388. * @param Polarity This parameter can be one of the following values:
  1389. * @arg @ref LL_LPUART_DE_POLARITY_HIGH
  1390. * @arg @ref LL_LPUART_DE_POLARITY_LOW
  1391. * @retval None
  1392. */
  1393. __STATIC_INLINE void LL_LPUART_SetDESignalPolarity(USART_TypeDef *LPUARTx, uint32_t Polarity)
  1394. {
  1395. MODIFY_REG(LPUARTx->CR3, USART_CR3_DEP, Polarity);
  1396. }
  1397. /**
  1398. * @brief Return Driver Enable Polarity
  1399. * @rmtoll CR3 DEP LL_LPUART_GetDESignalPolarity
  1400. * @param LPUARTx LPUART Instance
  1401. * @retval Returned value can be one of the following values:
  1402. * @arg @ref LL_LPUART_DE_POLARITY_HIGH
  1403. * @arg @ref LL_LPUART_DE_POLARITY_LOW
  1404. */
  1405. __STATIC_INLINE uint32_t LL_LPUART_GetDESignalPolarity(USART_TypeDef *LPUARTx)
  1406. {
  1407. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_DEP));
  1408. }
  1409. /**
  1410. * @}
  1411. */
  1412. /** @defgroup LPUART_LL_EF_FLAG_Management FLAG_Management
  1413. * @{
  1414. */
  1415. /**
  1416. * @brief Check if the LPUART Parity Error Flag is set or not
  1417. * @rmtoll ISR PE LL_LPUART_IsActiveFlag_PE
  1418. * @param LPUARTx LPUART Instance
  1419. * @retval State of bit (1 or 0).
  1420. */
  1421. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_PE(USART_TypeDef *LPUARTx)
  1422. {
  1423. return ((READ_BIT(LPUARTx->ISR, USART_ISR_PE) == (USART_ISR_PE)) ? 1UL : 0UL);
  1424. }
  1425. /**
  1426. * @brief Check if the LPUART Framing Error Flag is set or not
  1427. * @rmtoll ISR FE LL_LPUART_IsActiveFlag_FE
  1428. * @param LPUARTx LPUART Instance
  1429. * @retval State of bit (1 or 0).
  1430. */
  1431. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_FE(USART_TypeDef *LPUARTx)
  1432. {
  1433. return ((READ_BIT(LPUARTx->ISR, USART_ISR_FE) == (USART_ISR_FE)) ? 1UL : 0UL);
  1434. }
  1435. /**
  1436. * @brief Check if the LPUART Noise error detected Flag is set or not
  1437. * @rmtoll ISR NE LL_LPUART_IsActiveFlag_NE
  1438. * @param LPUARTx LPUART Instance
  1439. * @retval State of bit (1 or 0).
  1440. */
  1441. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_NE(USART_TypeDef *LPUARTx)
  1442. {
  1443. return ((READ_BIT(LPUARTx->ISR, USART_ISR_NE) == (USART_ISR_NE)) ? 1UL : 0UL);
  1444. }
  1445. /**
  1446. * @brief Check if the LPUART OverRun Error Flag is set or not
  1447. * @rmtoll ISR ORE LL_LPUART_IsActiveFlag_ORE
  1448. * @param LPUARTx LPUART Instance
  1449. * @retval State of bit (1 or 0).
  1450. */
  1451. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_ORE(USART_TypeDef *LPUARTx)
  1452. {
  1453. return ((READ_BIT(LPUARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE)) ? 1UL : 0UL);
  1454. }
  1455. /**
  1456. * @brief Check if the LPUART IDLE line detected Flag is set or not
  1457. * @rmtoll ISR IDLE LL_LPUART_IsActiveFlag_IDLE
  1458. * @param LPUARTx LPUART Instance
  1459. * @retval State of bit (1 or 0).
  1460. */
  1461. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_IDLE(USART_TypeDef *LPUARTx)
  1462. {
  1463. return ((READ_BIT(LPUARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE)) ? 1UL : 0UL);
  1464. }
  1465. /* Legacy define */
  1466. #define LL_LPUART_IsActiveFlag_RXNE LL_LPUART_IsActiveFlag_RXNE_RXFNE
  1467. /**
  1468. * @brief Check if the LPUART Read Data Register or LPUART RX FIFO Not Empty Flag is set or not
  1469. * @rmtoll ISR RXNE_RXFNE LL_LPUART_IsActiveFlag_RXNE_RXFNE
  1470. * @param LPUARTx LPUART Instance
  1471. * @retval State of bit (1 or 0).
  1472. */
  1473. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXNE_RXFNE(USART_TypeDef *LPUARTx)
  1474. {
  1475. return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXNE_RXFNE) == (USART_ISR_RXNE_RXFNE)) ? 1UL : 0UL);
  1476. }
  1477. /**
  1478. * @brief Check if the LPUART Transmission Complete Flag is set or not
  1479. * @rmtoll ISR TC LL_LPUART_IsActiveFlag_TC
  1480. * @param LPUARTx LPUART Instance
  1481. * @retval State of bit (1 or 0).
  1482. */
  1483. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TC(USART_TypeDef *LPUARTx)
  1484. {
  1485. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TC) == (USART_ISR_TC)) ? 1UL : 0UL);
  1486. }
  1487. /* Legacy define */
  1488. #define LL_LPUART_IsActiveFlag_TXE LL_LPUART_IsActiveFlag_TXE_TXFNF
  1489. /**
  1490. * @brief Check if the LPUART Transmit Data Register Empty or LPUART TX FIFO Not Full Flag is set or not
  1491. * @rmtoll ISR TXE_TXFNF LL_LPUART_IsActiveFlag_TXE_TXFNF
  1492. * @param LPUARTx LPUART Instance
  1493. * @retval State of bit (1 or 0).
  1494. */
  1495. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXE_TXFNF(USART_TypeDef *LPUARTx)
  1496. {
  1497. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXE_TXFNF) == (USART_ISR_TXE_TXFNF)) ? 1UL : 0UL);
  1498. }
  1499. /**
  1500. * @brief Check if the LPUART CTS interrupt Flag is set or not
  1501. * @rmtoll ISR CTSIF LL_LPUART_IsActiveFlag_nCTS
  1502. * @param LPUARTx LPUART Instance
  1503. * @retval State of bit (1 or 0).
  1504. */
  1505. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_nCTS(USART_TypeDef *LPUARTx)
  1506. {
  1507. return ((READ_BIT(LPUARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF)) ? 1UL : 0UL);
  1508. }
  1509. /**
  1510. * @brief Check if the LPUART CTS Flag is set or not
  1511. * @rmtoll ISR CTS LL_LPUART_IsActiveFlag_CTS
  1512. * @param LPUARTx LPUART Instance
  1513. * @retval State of bit (1 or 0).
  1514. */
  1515. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_CTS(USART_TypeDef *LPUARTx)
  1516. {
  1517. return ((READ_BIT(LPUARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS)) ? 1UL : 0UL);
  1518. }
  1519. /**
  1520. * @brief Check if the LPUART Busy Flag is set or not
  1521. * @rmtoll ISR BUSY LL_LPUART_IsActiveFlag_BUSY
  1522. * @param LPUARTx LPUART Instance
  1523. * @retval State of bit (1 or 0).
  1524. */
  1525. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_BUSY(USART_TypeDef *LPUARTx)
  1526. {
  1527. return ((READ_BIT(LPUARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY)) ? 1UL : 0UL);
  1528. }
  1529. /**
  1530. * @brief Check if the LPUART Character Match Flag is set or not
  1531. * @rmtoll ISR CMF LL_LPUART_IsActiveFlag_CM
  1532. * @param LPUARTx LPUART Instance
  1533. * @retval State of bit (1 or 0).
  1534. */
  1535. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_CM(USART_TypeDef *LPUARTx)
  1536. {
  1537. return ((READ_BIT(LPUARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF)) ? 1UL : 0UL);
  1538. }
  1539. /**
  1540. * @brief Check if the LPUART Send Break Flag is set or not
  1541. * @rmtoll ISR SBKF LL_LPUART_IsActiveFlag_SBK
  1542. * @param LPUARTx LPUART Instance
  1543. * @retval State of bit (1 or 0).
  1544. */
  1545. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_SBK(USART_TypeDef *LPUARTx)
  1546. {
  1547. return ((READ_BIT(LPUARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF)) ? 1UL : 0UL);
  1548. }
  1549. /**
  1550. * @brief Check if the LPUART Receive Wake Up from mute mode Flag is set or not
  1551. * @rmtoll ISR RWU LL_LPUART_IsActiveFlag_RWU
  1552. * @param LPUARTx LPUART Instance
  1553. * @retval State of bit (1 or 0).
  1554. */
  1555. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RWU(USART_TypeDef *LPUARTx)
  1556. {
  1557. return ((READ_BIT(LPUARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU)) ? 1UL : 0UL);
  1558. }
  1559. /**
  1560. * @brief Check if the LPUART Wake Up from stop mode Flag is set or not
  1561. * @rmtoll ISR WUF LL_LPUART_IsActiveFlag_WKUP
  1562. * @param LPUARTx LPUART Instance
  1563. * @retval State of bit (1 or 0).
  1564. */
  1565. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_WKUP(USART_TypeDef *LPUARTx)
  1566. {
  1567. return ((READ_BIT(LPUARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF)) ? 1UL : 0UL);
  1568. }
  1569. /**
  1570. * @brief Check if the LPUART Transmit Enable Acknowledge Flag is set or not
  1571. * @rmtoll ISR TEACK LL_LPUART_IsActiveFlag_TEACK
  1572. * @param LPUARTx LPUART Instance
  1573. * @retval State of bit (1 or 0).
  1574. */
  1575. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TEACK(USART_TypeDef *LPUARTx)
  1576. {
  1577. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK)) ? 1UL : 0UL);
  1578. }
  1579. /**
  1580. * @brief Check if the LPUART Receive Enable Acknowledge Flag is set or not
  1581. * @rmtoll ISR REACK LL_LPUART_IsActiveFlag_REACK
  1582. * @param LPUARTx LPUART Instance
  1583. * @retval State of bit (1 or 0).
  1584. */
  1585. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_REACK(USART_TypeDef *LPUARTx)
  1586. {
  1587. return ((READ_BIT(LPUARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK)) ? 1UL : 0UL);
  1588. }
  1589. /**
  1590. * @brief Check if the LPUART TX FIFO Empty Flag is set or not
  1591. * @rmtoll ISR TXFE LL_LPUART_IsActiveFlag_TXFE
  1592. * @param LPUARTx LPUART Instance
  1593. * @retval State of bit (1 or 0).
  1594. */
  1595. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXFE(USART_TypeDef *LPUARTx)
  1596. {
  1597. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXFE) == (USART_ISR_TXFE)) ? 1UL : 0UL);
  1598. }
  1599. /**
  1600. * @brief Check if the LPUART RX FIFO Full Flag is set or not
  1601. * @rmtoll ISR RXFF LL_LPUART_IsActiveFlag_RXFF
  1602. * @param LPUARTx LPUART Instance
  1603. * @retval State of bit (1 or 0).
  1604. */
  1605. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXFF(USART_TypeDef *LPUARTx)
  1606. {
  1607. return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXFF) == (USART_ISR_RXFF)) ? 1UL : 0UL);
  1608. }
  1609. /**
  1610. * @brief Check if the LPUART TX FIFO Threshold Flag is set or not
  1611. * @rmtoll ISR TXFT LL_LPUART_IsActiveFlag_TXFT
  1612. * @param LPUARTx LPUART Instance
  1613. * @retval State of bit (1 or 0).
  1614. */
  1615. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXFT(USART_TypeDef *LPUARTx)
  1616. {
  1617. return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXFT) == (USART_ISR_TXFT)) ? 1UL : 0UL);
  1618. }
  1619. /**
  1620. * @brief Check if the LPUART RX FIFO Threshold Flag is set or not
  1621. * @rmtoll ISR RXFT LL_LPUART_IsActiveFlag_RXFT
  1622. * @param LPUARTx LPUART Instance
  1623. * @retval State of bit (1 or 0).
  1624. */
  1625. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXFT(USART_TypeDef *LPUARTx)
  1626. {
  1627. return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXFT) == (USART_ISR_RXFT)) ? 1UL : 0UL);
  1628. }
  1629. /**
  1630. * @brief Clear Parity Error Flag
  1631. * @rmtoll ICR PECF LL_LPUART_ClearFlag_PE
  1632. * @param LPUARTx LPUART Instance
  1633. * @retval None
  1634. */
  1635. __STATIC_INLINE void LL_LPUART_ClearFlag_PE(USART_TypeDef *LPUARTx)
  1636. {
  1637. WRITE_REG(LPUARTx->ICR, USART_ICR_PECF);
  1638. }
  1639. /**
  1640. * @brief Clear Framing Error Flag
  1641. * @rmtoll ICR FECF LL_LPUART_ClearFlag_FE
  1642. * @param LPUARTx LPUART Instance
  1643. * @retval None
  1644. */
  1645. __STATIC_INLINE void LL_LPUART_ClearFlag_FE(USART_TypeDef *LPUARTx)
  1646. {
  1647. WRITE_REG(LPUARTx->ICR, USART_ICR_FECF);
  1648. }
  1649. /**
  1650. * @brief Clear Noise detected Flag
  1651. * @rmtoll ICR NECF LL_LPUART_ClearFlag_NE
  1652. * @param LPUARTx LPUART Instance
  1653. * @retval None
  1654. */
  1655. __STATIC_INLINE void LL_LPUART_ClearFlag_NE(USART_TypeDef *LPUARTx)
  1656. {
  1657. WRITE_REG(LPUARTx->ICR, USART_ICR_NECF);
  1658. }
  1659. /**
  1660. * @brief Clear OverRun Error Flag
  1661. * @rmtoll ICR ORECF LL_LPUART_ClearFlag_ORE
  1662. * @param LPUARTx LPUART Instance
  1663. * @retval None
  1664. */
  1665. __STATIC_INLINE void LL_LPUART_ClearFlag_ORE(USART_TypeDef *LPUARTx)
  1666. {
  1667. WRITE_REG(LPUARTx->ICR, USART_ICR_ORECF);
  1668. }
  1669. /**
  1670. * @brief Clear IDLE line detected Flag
  1671. * @rmtoll ICR IDLECF LL_LPUART_ClearFlag_IDLE
  1672. * @param LPUARTx LPUART Instance
  1673. * @retval None
  1674. */
  1675. __STATIC_INLINE void LL_LPUART_ClearFlag_IDLE(USART_TypeDef *LPUARTx)
  1676. {
  1677. WRITE_REG(LPUARTx->ICR, USART_ICR_IDLECF);
  1678. }
  1679. /**
  1680. * @brief Clear TX FIFO Empty Flag
  1681. * @rmtoll ICR TXFECF LL_LPUART_ClearFlag_TXFE
  1682. * @param LPUARTx LPUART Instance
  1683. * @retval None
  1684. */
  1685. __STATIC_INLINE void LL_LPUART_ClearFlag_TXFE(USART_TypeDef *LPUARTx)
  1686. {
  1687. WRITE_REG(LPUARTx->ICR, USART_ICR_TXFECF);
  1688. }
  1689. /**
  1690. * @brief Clear Transmission Complete Flag
  1691. * @rmtoll ICR TCCF LL_LPUART_ClearFlag_TC
  1692. * @param LPUARTx LPUART Instance
  1693. * @retval None
  1694. */
  1695. __STATIC_INLINE void LL_LPUART_ClearFlag_TC(USART_TypeDef *LPUARTx)
  1696. {
  1697. WRITE_REG(LPUARTx->ICR, USART_ICR_TCCF);
  1698. }
  1699. /**
  1700. * @brief Clear CTS Interrupt Flag
  1701. * @rmtoll ICR CTSCF LL_LPUART_ClearFlag_nCTS
  1702. * @param LPUARTx LPUART Instance
  1703. * @retval None
  1704. */
  1705. __STATIC_INLINE void LL_LPUART_ClearFlag_nCTS(USART_TypeDef *LPUARTx)
  1706. {
  1707. WRITE_REG(LPUARTx->ICR, USART_ICR_CTSCF);
  1708. }
  1709. /**
  1710. * @brief Clear Character Match Flag
  1711. * @rmtoll ICR CMCF LL_LPUART_ClearFlag_CM
  1712. * @param LPUARTx LPUART Instance
  1713. * @retval None
  1714. */
  1715. __STATIC_INLINE void LL_LPUART_ClearFlag_CM(USART_TypeDef *LPUARTx)
  1716. {
  1717. WRITE_REG(LPUARTx->ICR, USART_ICR_CMCF);
  1718. }
  1719. /**
  1720. * @brief Clear Wake Up from stop mode Flag
  1721. * @rmtoll ICR WUCF LL_LPUART_ClearFlag_WKUP
  1722. * @param LPUARTx LPUART Instance
  1723. * @retval None
  1724. */
  1725. __STATIC_INLINE void LL_LPUART_ClearFlag_WKUP(USART_TypeDef *LPUARTx)
  1726. {
  1727. WRITE_REG(LPUARTx->ICR, USART_ICR_WUCF);
  1728. }
  1729. /**
  1730. * @}
  1731. */
  1732. /** @defgroup LPUART_LL_EF_IT_Management IT_Management
  1733. * @{
  1734. */
  1735. /**
  1736. * @brief Enable IDLE Interrupt
  1737. * @rmtoll CR1 IDLEIE LL_LPUART_EnableIT_IDLE
  1738. * @param LPUARTx LPUART Instance
  1739. * @retval None
  1740. */
  1741. __STATIC_INLINE void LL_LPUART_EnableIT_IDLE(USART_TypeDef *LPUARTx)
  1742. {
  1743. SET_BIT(LPUARTx->CR1, USART_CR1_IDLEIE);
  1744. }
  1745. /* Legacy define */
  1746. #define LL_LPUART_EnableIT_RXNE LL_LPUART_EnableIT_RXNE_RXFNE
  1747. /**
  1748. * @brief Enable RX Not Empty and RX FIFO Not Empty Interrupt
  1749. * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_EnableIT_RXNE_RXFNE
  1750. * @param LPUARTx LPUART Instance
  1751. * @retval None
  1752. */
  1753. __STATIC_INLINE void LL_LPUART_EnableIT_RXNE_RXFNE(USART_TypeDef *LPUARTx)
  1754. {
  1755. SET_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE);
  1756. }
  1757. /**
  1758. * @brief Enable Transmission Complete Interrupt
  1759. * @rmtoll CR1 TCIE LL_LPUART_EnableIT_TC
  1760. * @param LPUARTx LPUART Instance
  1761. * @retval None
  1762. */
  1763. __STATIC_INLINE void LL_LPUART_EnableIT_TC(USART_TypeDef *LPUARTx)
  1764. {
  1765. SET_BIT(LPUARTx->CR1, USART_CR1_TCIE);
  1766. }
  1767. /* Legacy define */
  1768. #define LL_LPUART_EnableIT_TXE LL_LPUART_EnableIT_TXE_TXFNF
  1769. /**
  1770. * @brief Enable TX Empty and TX FIFO Not Full Interrupt
  1771. * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_EnableIT_TXE_TXFNF
  1772. * @param LPUARTx LPUART Instance
  1773. * @retval None
  1774. */
  1775. __STATIC_INLINE void LL_LPUART_EnableIT_TXE_TXFNF(USART_TypeDef *LPUARTx)
  1776. {
  1777. SET_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE);
  1778. }
  1779. /**
  1780. * @brief Enable Parity Error Interrupt
  1781. * @rmtoll CR1 PEIE LL_LPUART_EnableIT_PE
  1782. * @param LPUARTx LPUART Instance
  1783. * @retval None
  1784. */
  1785. __STATIC_INLINE void LL_LPUART_EnableIT_PE(USART_TypeDef *LPUARTx)
  1786. {
  1787. SET_BIT(LPUARTx->CR1, USART_CR1_PEIE);
  1788. }
  1789. /**
  1790. * @brief Enable Character Match Interrupt
  1791. * @rmtoll CR1 CMIE LL_LPUART_EnableIT_CM
  1792. * @param LPUARTx LPUART Instance
  1793. * @retval None
  1794. */
  1795. __STATIC_INLINE void LL_LPUART_EnableIT_CM(USART_TypeDef *LPUARTx)
  1796. {
  1797. SET_BIT(LPUARTx->CR1, USART_CR1_CMIE);
  1798. }
  1799. /**
  1800. * @brief Enable TX FIFO Empty Interrupt
  1801. * @rmtoll CR1 TXFEIE LL_LPUART_EnableIT_TXFE
  1802. * @param LPUARTx LPUART Instance
  1803. * @retval None
  1804. */
  1805. __STATIC_INLINE void LL_LPUART_EnableIT_TXFE(USART_TypeDef *LPUARTx)
  1806. {
  1807. SET_BIT(LPUARTx->CR1, USART_CR1_TXFEIE);
  1808. }
  1809. /**
  1810. * @brief Enable RX FIFO Full Interrupt
  1811. * @rmtoll CR1 RXFFIE LL_LPUART_EnableIT_RXFF
  1812. * @param LPUARTx LPUART Instance
  1813. * @retval None
  1814. */
  1815. __STATIC_INLINE void LL_LPUART_EnableIT_RXFF(USART_TypeDef *LPUARTx)
  1816. {
  1817. SET_BIT(LPUARTx->CR1, USART_CR1_RXFFIE);
  1818. }
  1819. /**
  1820. * @brief Enable Error Interrupt
  1821. * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
  1822. * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register).
  1823. * - 0: Interrupt is inhibited
  1824. * - 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register.
  1825. * @rmtoll CR3 EIE LL_LPUART_EnableIT_ERROR
  1826. * @param LPUARTx LPUART Instance
  1827. * @retval None
  1828. */
  1829. __STATIC_INLINE void LL_LPUART_EnableIT_ERROR(USART_TypeDef *LPUARTx)
  1830. {
  1831. SET_BIT(LPUARTx->CR3, USART_CR3_EIE);
  1832. }
  1833. /**
  1834. * @brief Enable CTS Interrupt
  1835. * @rmtoll CR3 CTSIE LL_LPUART_EnableIT_CTS
  1836. * @param LPUARTx LPUART Instance
  1837. * @retval None
  1838. */
  1839. __STATIC_INLINE void LL_LPUART_EnableIT_CTS(USART_TypeDef *LPUARTx)
  1840. {
  1841. SET_BIT(LPUARTx->CR3, USART_CR3_CTSIE);
  1842. }
  1843. /**
  1844. * @brief Enable Wake Up from Stop Mode Interrupt
  1845. * @rmtoll CR3 WUFIE LL_LPUART_EnableIT_WKUP
  1846. * @param LPUARTx LPUART Instance
  1847. * @retval None
  1848. */
  1849. __STATIC_INLINE void LL_LPUART_EnableIT_WKUP(USART_TypeDef *LPUARTx)
  1850. {
  1851. SET_BIT(LPUARTx->CR3, USART_CR3_WUFIE);
  1852. }
  1853. /**
  1854. * @brief Enable TX FIFO Threshold Interrupt
  1855. * @rmtoll CR3 TXFTIE LL_LPUART_EnableIT_TXFT
  1856. * @param LPUARTx LPUART Instance
  1857. * @retval None
  1858. */
  1859. __STATIC_INLINE void LL_LPUART_EnableIT_TXFT(USART_TypeDef *LPUARTx)
  1860. {
  1861. SET_BIT(LPUARTx->CR3, USART_CR3_TXFTIE);
  1862. }
  1863. /**
  1864. * @brief Enable RX FIFO Threshold Interrupt
  1865. * @rmtoll CR3 RXFTIE LL_LPUART_EnableIT_RXFT
  1866. * @param LPUARTx LPUART Instance
  1867. * @retval None
  1868. */
  1869. __STATIC_INLINE void LL_LPUART_EnableIT_RXFT(USART_TypeDef *LPUARTx)
  1870. {
  1871. SET_BIT(LPUARTx->CR3, USART_CR3_RXFTIE);
  1872. }
  1873. /**
  1874. * @brief Disable IDLE Interrupt
  1875. * @rmtoll CR1 IDLEIE LL_LPUART_DisableIT_IDLE
  1876. * @param LPUARTx LPUART Instance
  1877. * @retval None
  1878. */
  1879. __STATIC_INLINE void LL_LPUART_DisableIT_IDLE(USART_TypeDef *LPUARTx)
  1880. {
  1881. CLEAR_BIT(LPUARTx->CR1, USART_CR1_IDLEIE);
  1882. }
  1883. /* Legacy define */
  1884. #define LL_LPUART_DisableIT_RXNE LL_LPUART_DisableIT_RXNE_RXFNE
  1885. /**
  1886. * @brief Disable RX Not Empty and RX FIFO Not Empty Interrupt
  1887. * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_DisableIT_RXNE_RXFNE
  1888. * @param LPUARTx LPUART Instance
  1889. * @retval None
  1890. */
  1891. __STATIC_INLINE void LL_LPUART_DisableIT_RXNE_RXFNE(USART_TypeDef *LPUARTx)
  1892. {
  1893. CLEAR_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE);
  1894. }
  1895. /**
  1896. * @brief Disable Transmission Complete Interrupt
  1897. * @rmtoll CR1 TCIE LL_LPUART_DisableIT_TC
  1898. * @param LPUARTx LPUART Instance
  1899. * @retval None
  1900. */
  1901. __STATIC_INLINE void LL_LPUART_DisableIT_TC(USART_TypeDef *LPUARTx)
  1902. {
  1903. CLEAR_BIT(LPUARTx->CR1, USART_CR1_TCIE);
  1904. }
  1905. /* Legacy define */
  1906. #define LL_LPUART_DisableIT_TXE LL_LPUART_DisableIT_TXE_TXFNF
  1907. /**
  1908. * @brief Disable TX Empty and TX FIFO Not Full Interrupt
  1909. * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_DisableIT_TXE_TXFNF
  1910. * @param LPUARTx LPUART Instance
  1911. * @retval None
  1912. */
  1913. __STATIC_INLINE void LL_LPUART_DisableIT_TXE_TXFNF(USART_TypeDef *LPUARTx)
  1914. {
  1915. CLEAR_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE);
  1916. }
  1917. /**
  1918. * @brief Disable Parity Error Interrupt
  1919. * @rmtoll CR1 PEIE LL_LPUART_DisableIT_PE
  1920. * @param LPUARTx LPUART Instance
  1921. * @retval None
  1922. */
  1923. __STATIC_INLINE void LL_LPUART_DisableIT_PE(USART_TypeDef *LPUARTx)
  1924. {
  1925. CLEAR_BIT(LPUARTx->CR1, USART_CR1_PEIE);
  1926. }
  1927. /**
  1928. * @brief Disable Character Match Interrupt
  1929. * @rmtoll CR1 CMIE LL_LPUART_DisableIT_CM
  1930. * @param LPUARTx LPUART Instance
  1931. * @retval None
  1932. */
  1933. __STATIC_INLINE void LL_LPUART_DisableIT_CM(USART_TypeDef *LPUARTx)
  1934. {
  1935. CLEAR_BIT(LPUARTx->CR1, USART_CR1_CMIE);
  1936. }
  1937. /**
  1938. * @brief Disable TX FIFO Empty Interrupt
  1939. * @rmtoll CR1 TXFEIE LL_LPUART_DisableIT_TXFE
  1940. * @param LPUARTx LPUART Instance
  1941. * @retval None
  1942. */
  1943. __STATIC_INLINE void LL_LPUART_DisableIT_TXFE(USART_TypeDef *LPUARTx)
  1944. {
  1945. CLEAR_BIT(LPUARTx->CR1, USART_CR1_TXFEIE);
  1946. }
  1947. /**
  1948. * @brief Disable RX FIFO Full Interrupt
  1949. * @rmtoll CR1 RXFFIE LL_LPUART_DisableIT_RXFF
  1950. * @param LPUARTx LPUART Instance
  1951. * @retval None
  1952. */
  1953. __STATIC_INLINE void LL_LPUART_DisableIT_RXFF(USART_TypeDef *LPUARTx)
  1954. {
  1955. CLEAR_BIT(LPUARTx->CR1, USART_CR1_RXFFIE);
  1956. }
  1957. /**
  1958. * @brief Disable Error Interrupt
  1959. * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
  1960. * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register).
  1961. * - 0: Interrupt is inhibited
  1962. * - 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register.
  1963. * @rmtoll CR3 EIE LL_LPUART_DisableIT_ERROR
  1964. * @param LPUARTx LPUART Instance
  1965. * @retval None
  1966. */
  1967. __STATIC_INLINE void LL_LPUART_DisableIT_ERROR(USART_TypeDef *LPUARTx)
  1968. {
  1969. CLEAR_BIT(LPUARTx->CR3, USART_CR3_EIE);
  1970. }
  1971. /**
  1972. * @brief Disable CTS Interrupt
  1973. * @rmtoll CR3 CTSIE LL_LPUART_DisableIT_CTS
  1974. * @param LPUARTx LPUART Instance
  1975. * @retval None
  1976. */
  1977. __STATIC_INLINE void LL_LPUART_DisableIT_CTS(USART_TypeDef *LPUARTx)
  1978. {
  1979. CLEAR_BIT(LPUARTx->CR3, USART_CR3_CTSIE);
  1980. }
  1981. /**
  1982. * @brief Disable Wake Up from Stop Mode Interrupt
  1983. * @rmtoll CR3 WUFIE LL_LPUART_DisableIT_WKUP
  1984. * @param LPUARTx LPUART Instance
  1985. * @retval None
  1986. */
  1987. __STATIC_INLINE void LL_LPUART_DisableIT_WKUP(USART_TypeDef *LPUARTx)
  1988. {
  1989. CLEAR_BIT(LPUARTx->CR3, USART_CR3_WUFIE);
  1990. }
  1991. /**
  1992. * @brief Disable TX FIFO Threshold Interrupt
  1993. * @rmtoll CR3 TXFTIE LL_LPUART_DisableIT_TXFT
  1994. * @param LPUARTx LPUART Instance
  1995. * @retval None
  1996. */
  1997. __STATIC_INLINE void LL_LPUART_DisableIT_TXFT(USART_TypeDef *LPUARTx)
  1998. {
  1999. CLEAR_BIT(LPUARTx->CR3, USART_CR3_TXFTIE);
  2000. }
  2001. /**
  2002. * @brief Disable RX FIFO Threshold Interrupt
  2003. * @rmtoll CR3 RXFTIE LL_LPUART_DisableIT_RXFT
  2004. * @param LPUARTx LPUART Instance
  2005. * @retval None
  2006. */
  2007. __STATIC_INLINE void LL_LPUART_DisableIT_RXFT(USART_TypeDef *LPUARTx)
  2008. {
  2009. CLEAR_BIT(LPUARTx->CR3, USART_CR3_RXFTIE);
  2010. }
  2011. /**
  2012. * @brief Check if the LPUART IDLE Interrupt source is enabled or disabled.
  2013. * @rmtoll CR1 IDLEIE LL_LPUART_IsEnabledIT_IDLE
  2014. * @param LPUARTx LPUART Instance
  2015. * @retval State of bit (1 or 0).
  2016. */
  2017. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_IDLE(USART_TypeDef *LPUARTx)
  2018. {
  2019. return ((READ_BIT(LPUARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE)) ? 1UL : 0UL);
  2020. }
  2021. /* Legacy define */
  2022. #define LL_LPUART_IsEnabledIT_RXNE LL_LPUART_IsEnabledIT_RXNE_RXFNE
  2023. /**
  2024. * @brief Check if the LPUART RX Not Empty and LPUART RX FIFO Not Empty Interrupt is enabled or disabled.
  2025. * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_IsEnabledIT_RXNE_RXFNE
  2026. * @param LPUARTx LPUART Instance
  2027. * @retval State of bit (1 or 0).
  2028. */
  2029. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXNE_RXFNE(USART_TypeDef *LPUARTx)
  2030. {
  2031. return ((READ_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE) == (USART_CR1_RXNEIE_RXFNEIE)) ? 1UL : 0UL);
  2032. }
  2033. /**
  2034. * @brief Check if the LPUART Transmission Complete Interrupt is enabled or disabled.
  2035. * @rmtoll CR1 TCIE LL_LPUART_IsEnabledIT_TC
  2036. * @param LPUARTx LPUART Instance
  2037. * @retval State of bit (1 or 0).
  2038. */
  2039. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TC(USART_TypeDef *LPUARTx)
  2040. {
  2041. return ((READ_BIT(LPUARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE)) ? 1UL : 0UL);
  2042. }
  2043. /* Legacy define */
  2044. #define LL_LPUART_IsEnabledIT_TXE LL_LPUART_IsEnabledIT_TXE_TXFNF
  2045. /**
  2046. * @brief Check if the LPUART TX Empty and LPUART TX FIFO Not Full Interrupt is enabled or disabled
  2047. * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_IsEnabledIT_TXE_TXFNF
  2048. * @param LPUARTx LPUART Instance
  2049. * @retval State of bit (1 or 0).
  2050. */
  2051. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXE_TXFNF(USART_TypeDef *LPUARTx)
  2052. {
  2053. return ((READ_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE) == (USART_CR1_TXEIE_TXFNFIE)) ? 1UL : 0UL);
  2054. }
  2055. /**
  2056. * @brief Check if the LPUART Parity Error Interrupt is enabled or disabled.
  2057. * @rmtoll CR1 PEIE LL_LPUART_IsEnabledIT_PE
  2058. * @param LPUARTx LPUART Instance
  2059. * @retval State of bit (1 or 0).
  2060. */
  2061. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_PE(USART_TypeDef *LPUARTx)
  2062. {
  2063. return ((READ_BIT(LPUARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE)) ? 1UL : 0UL);
  2064. }
  2065. /**
  2066. * @brief Check if the LPUART Character Match Interrupt is enabled or disabled.
  2067. * @rmtoll CR1 CMIE LL_LPUART_IsEnabledIT_CM
  2068. * @param LPUARTx LPUART Instance
  2069. * @retval State of bit (1 or 0).
  2070. */
  2071. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_CM(USART_TypeDef *LPUARTx)
  2072. {
  2073. return ((READ_BIT(LPUARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE)) ? 1UL : 0UL);
  2074. }
  2075. /**
  2076. * @brief Check if the LPUART TX FIFO Empty Interrupt is enabled or disabled
  2077. * @rmtoll CR1 TXFEIE LL_LPUART_IsEnabledIT_TXFE
  2078. * @param LPUARTx LPUART Instance
  2079. * @retval State of bit (1 or 0).
  2080. */
  2081. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXFE(USART_TypeDef *LPUARTx)
  2082. {
  2083. return ((READ_BIT(LPUARTx->CR1, USART_CR1_TXFEIE) == (USART_CR1_TXFEIE)) ? 1UL : 0UL);
  2084. }
  2085. /**
  2086. * @brief Check if the LPUART RX FIFO Full Interrupt is enabled or disabled
  2087. * @rmtoll CR1 RXFFIE LL_LPUART_IsEnabledIT_RXFF
  2088. * @param LPUARTx LPUART Instance
  2089. * @retval State of bit (1 or 0).
  2090. */
  2091. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXFF(USART_TypeDef *LPUARTx)
  2092. {
  2093. return ((READ_BIT(LPUARTx->CR1, USART_CR1_RXFFIE) == (USART_CR1_RXFFIE)) ? 1UL : 0UL);
  2094. }
  2095. /**
  2096. * @brief Check if the LPUART Error Interrupt is enabled or disabled.
  2097. * @rmtoll CR3 EIE LL_LPUART_IsEnabledIT_ERROR
  2098. * @param LPUARTx LPUART Instance
  2099. * @retval State of bit (1 or 0).
  2100. */
  2101. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_ERROR(USART_TypeDef *LPUARTx)
  2102. {
  2103. return ((READ_BIT(LPUARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE)) ? 1UL : 0UL);
  2104. }
  2105. /**
  2106. * @brief Check if the LPUART CTS Interrupt is enabled or disabled.
  2107. * @rmtoll CR3 CTSIE LL_LPUART_IsEnabledIT_CTS
  2108. * @param LPUARTx LPUART Instance
  2109. * @retval State of bit (1 or 0).
  2110. */
  2111. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_CTS(USART_TypeDef *LPUARTx)
  2112. {
  2113. return ((READ_BIT(LPUARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE)) ? 1UL : 0UL);
  2114. }
  2115. /**
  2116. * @brief Check if the LPUART Wake Up from Stop Mode Interrupt is enabled or disabled.
  2117. * @rmtoll CR3 WUFIE LL_LPUART_IsEnabledIT_WKUP
  2118. * @param LPUARTx LPUART Instance
  2119. * @retval State of bit (1 or 0).
  2120. */
  2121. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_WKUP(USART_TypeDef *LPUARTx)
  2122. {
  2123. return ((READ_BIT(LPUARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE)) ? 1UL : 0UL);
  2124. }
  2125. /**
  2126. * @brief Check if LPUART TX FIFO Threshold Interrupt is enabled or disabled
  2127. * @rmtoll CR3 TXFTIE LL_LPUART_IsEnabledIT_TXFT
  2128. * @param LPUARTx LPUART Instance
  2129. * @retval State of bit (1 or 0).
  2130. */
  2131. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXFT(USART_TypeDef *LPUARTx)
  2132. {
  2133. return ((READ_BIT(LPUARTx->CR3, USART_CR3_TXFTIE) == (USART_CR3_TXFTIE)) ? 1UL : 0UL);
  2134. }
  2135. /**
  2136. * @brief Check if LPUART RX FIFO Threshold Interrupt is enabled or disabled
  2137. * @rmtoll CR3 RXFTIE LL_LPUART_IsEnabledIT_RXFT
  2138. * @param LPUARTx LPUART Instance
  2139. * @retval State of bit (1 or 0).
  2140. */
  2141. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXFT(USART_TypeDef *LPUARTx)
  2142. {
  2143. return ((READ_BIT(LPUARTx->CR3, USART_CR3_RXFTIE) == (USART_CR3_RXFTIE)) ? 1UL : 0UL);
  2144. }
  2145. /**
  2146. * @}
  2147. */
  2148. /** @defgroup LPUART_LL_EF_DMA_Management DMA_Management
  2149. * @{
  2150. */
  2151. /**
  2152. * @brief Enable DMA Mode for reception
  2153. * @rmtoll CR3 DMAR LL_LPUART_EnableDMAReq_RX
  2154. * @param LPUARTx LPUART Instance
  2155. * @retval None
  2156. */
  2157. __STATIC_INLINE void LL_LPUART_EnableDMAReq_RX(USART_TypeDef *LPUARTx)
  2158. {
  2159. SET_BIT(LPUARTx->CR3, USART_CR3_DMAR);
  2160. }
  2161. /**
  2162. * @brief Disable DMA Mode for reception
  2163. * @rmtoll CR3 DMAR LL_LPUART_DisableDMAReq_RX
  2164. * @param LPUARTx LPUART Instance
  2165. * @retval None
  2166. */
  2167. __STATIC_INLINE void LL_LPUART_DisableDMAReq_RX(USART_TypeDef *LPUARTx)
  2168. {
  2169. CLEAR_BIT(LPUARTx->CR3, USART_CR3_DMAR);
  2170. }
  2171. /**
  2172. * @brief Check if DMA Mode is enabled for reception
  2173. * @rmtoll CR3 DMAR LL_LPUART_IsEnabledDMAReq_RX
  2174. * @param LPUARTx LPUART Instance
  2175. * @retval State of bit (1 or 0).
  2176. */
  2177. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMAReq_RX(USART_TypeDef *LPUARTx)
  2178. {
  2179. return ((READ_BIT(LPUARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR)) ? 1UL : 0UL);
  2180. }
  2181. /**
  2182. * @brief Enable DMA Mode for transmission
  2183. * @rmtoll CR3 DMAT LL_LPUART_EnableDMAReq_TX
  2184. * @param LPUARTx LPUART Instance
  2185. * @retval None
  2186. */
  2187. __STATIC_INLINE void LL_LPUART_EnableDMAReq_TX(USART_TypeDef *LPUARTx)
  2188. {
  2189. SET_BIT(LPUARTx->CR3, USART_CR3_DMAT);
  2190. }
  2191. /**
  2192. * @brief Disable DMA Mode for transmission
  2193. * @rmtoll CR3 DMAT LL_LPUART_DisableDMAReq_TX
  2194. * @param LPUARTx LPUART Instance
  2195. * @retval None
  2196. */
  2197. __STATIC_INLINE void LL_LPUART_DisableDMAReq_TX(USART_TypeDef *LPUARTx)
  2198. {
  2199. CLEAR_BIT(LPUARTx->CR3, USART_CR3_DMAT);
  2200. }
  2201. /**
  2202. * @brief Check if DMA Mode is enabled for transmission
  2203. * @rmtoll CR3 DMAT LL_LPUART_IsEnabledDMAReq_TX
  2204. * @param LPUARTx LPUART Instance
  2205. * @retval State of bit (1 or 0).
  2206. */
  2207. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMAReq_TX(USART_TypeDef *LPUARTx)
  2208. {
  2209. return ((READ_BIT(LPUARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT)) ? 1UL : 0UL);
  2210. }
  2211. /**
  2212. * @brief Enable DMA Disabling on Reception Error
  2213. * @rmtoll CR3 DDRE LL_LPUART_EnableDMADeactOnRxErr
  2214. * @param LPUARTx LPUART Instance
  2215. * @retval None
  2216. */
  2217. __STATIC_INLINE void LL_LPUART_EnableDMADeactOnRxErr(USART_TypeDef *LPUARTx)
  2218. {
  2219. SET_BIT(LPUARTx->CR3, USART_CR3_DDRE);
  2220. }
  2221. /**
  2222. * @brief Disable DMA Disabling on Reception Error
  2223. * @rmtoll CR3 DDRE LL_LPUART_DisableDMADeactOnRxErr
  2224. * @param LPUARTx LPUART Instance
  2225. * @retval None
  2226. */
  2227. __STATIC_INLINE void LL_LPUART_DisableDMADeactOnRxErr(USART_TypeDef *LPUARTx)
  2228. {
  2229. CLEAR_BIT(LPUARTx->CR3, USART_CR3_DDRE);
  2230. }
  2231. /**
  2232. * @brief Indicate if DMA Disabling on Reception Error is disabled
  2233. * @rmtoll CR3 DDRE LL_LPUART_IsEnabledDMADeactOnRxErr
  2234. * @param LPUARTx LPUART Instance
  2235. * @retval State of bit (1 or 0).
  2236. */
  2237. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMADeactOnRxErr(USART_TypeDef *LPUARTx)
  2238. {
  2239. return ((READ_BIT(LPUARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE)) ? 1UL : 0UL);
  2240. }
  2241. /**
  2242. * @brief Get the LPUART data register address used for DMA transfer
  2243. * @rmtoll RDR RDR LL_LPUART_DMA_GetRegAddr\n
  2244. * @rmtoll TDR TDR LL_LPUART_DMA_GetRegAddr
  2245. * @param LPUARTx LPUART Instance
  2246. * @param Direction This parameter can be one of the following values:
  2247. * @arg @ref LL_LPUART_DMA_REG_DATA_TRANSMIT
  2248. * @arg @ref LL_LPUART_DMA_REG_DATA_RECEIVE
  2249. * @retval Address of data register
  2250. */
  2251. __STATIC_INLINE uint32_t LL_LPUART_DMA_GetRegAddr(USART_TypeDef *LPUARTx, uint32_t Direction)
  2252. {
  2253. uint32_t data_reg_addr;
  2254. if (Direction == LL_LPUART_DMA_REG_DATA_TRANSMIT)
  2255. {
  2256. /* return address of TDR register */
  2257. data_reg_addr = (uint32_t) &(LPUARTx->TDR);
  2258. }
  2259. else
  2260. {
  2261. /* return address of RDR register */
  2262. data_reg_addr = (uint32_t) &(LPUARTx->RDR);
  2263. }
  2264. return data_reg_addr;
  2265. }
  2266. /**
  2267. * @}
  2268. */
  2269. /** @defgroup LPUART_LL_EF_Data_Management Data_Management
  2270. * @{
  2271. */
  2272. /**
  2273. * @brief Read Receiver Data register (Receive Data value, 8 bits)
  2274. * @rmtoll RDR RDR LL_LPUART_ReceiveData8
  2275. * @param LPUARTx LPUART Instance
  2276. * @retval Time Value between Min_Data=0x00 and Max_Data=0xFF
  2277. */
  2278. __STATIC_INLINE uint8_t LL_LPUART_ReceiveData8(USART_TypeDef *LPUARTx)
  2279. {
  2280. return (uint8_t)(READ_BIT(LPUARTx->RDR, USART_RDR_RDR) & 0xFFU);
  2281. }
  2282. /**
  2283. * @brief Read Receiver Data register (Receive Data value, 9 bits)
  2284. * @rmtoll RDR RDR LL_LPUART_ReceiveData9
  2285. * @param LPUARTx LPUART Instance
  2286. * @retval Time Value between Min_Data=0x00 and Max_Data=0x1FF
  2287. */
  2288. __STATIC_INLINE uint16_t LL_LPUART_ReceiveData9(USART_TypeDef *LPUARTx)
  2289. {
  2290. return (uint16_t)(READ_BIT(LPUARTx->RDR, USART_RDR_RDR));
  2291. }
  2292. /**
  2293. * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits)
  2294. * @rmtoll TDR TDR LL_LPUART_TransmitData8
  2295. * @param LPUARTx LPUART Instance
  2296. * @param Value between Min_Data=0x00 and Max_Data=0xFF
  2297. * @retval None
  2298. */
  2299. __STATIC_INLINE void LL_LPUART_TransmitData8(USART_TypeDef *LPUARTx, uint8_t Value)
  2300. {
  2301. LPUARTx->TDR = Value;
  2302. }
  2303. /**
  2304. * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits)
  2305. * @rmtoll TDR TDR LL_LPUART_TransmitData9
  2306. * @param LPUARTx LPUART Instance
  2307. * @param Value between Min_Data=0x00 and Max_Data=0x1FF
  2308. * @retval None
  2309. */
  2310. __STATIC_INLINE void LL_LPUART_TransmitData9(USART_TypeDef *LPUARTx, uint16_t Value)
  2311. {
  2312. LPUARTx->TDR = Value & 0x1FFUL;
  2313. }
  2314. /**
  2315. * @}
  2316. */
  2317. /** @defgroup LPUART_LL_EF_Execution Execution
  2318. * @{
  2319. */
  2320. /**
  2321. * @brief Request Break sending
  2322. * @rmtoll RQR SBKRQ LL_LPUART_RequestBreakSending
  2323. * @param LPUARTx LPUART Instance
  2324. * @retval None
  2325. */
  2326. __STATIC_INLINE void LL_LPUART_RequestBreakSending(USART_TypeDef *LPUARTx)
  2327. {
  2328. SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_SBKRQ);
  2329. }
  2330. /**
  2331. * @brief Put LPUART in mute mode and set the RWU flag
  2332. * @rmtoll RQR MMRQ LL_LPUART_RequestEnterMuteMode
  2333. * @param LPUARTx LPUART Instance
  2334. * @retval None
  2335. */
  2336. __STATIC_INLINE void LL_LPUART_RequestEnterMuteMode(USART_TypeDef *LPUARTx)
  2337. {
  2338. SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_MMRQ);
  2339. }
  2340. /**
  2341. * @brief Request a Receive Data and FIFO flush
  2342. * @note Allows to discard the received data without reading them, and avoid an overrun
  2343. * condition.
  2344. * @rmtoll RQR RXFRQ LL_LPUART_RequestRxDataFlush
  2345. * @param LPUARTx LPUART Instance
  2346. * @retval None
  2347. */
  2348. __STATIC_INLINE void LL_LPUART_RequestRxDataFlush(USART_TypeDef *LPUARTx)
  2349. {
  2350. SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_RXFRQ);
  2351. }
  2352. /**
  2353. * @}
  2354. */
  2355. #if defined(USE_FULL_LL_DRIVER)
  2356. /** @defgroup LPUART_LL_EF_Init Initialization and de-initialization functions
  2357. * @{
  2358. */
  2359. ErrorStatus LL_LPUART_DeInit(USART_TypeDef *LPUARTx);
  2360. ErrorStatus LL_LPUART_Init(USART_TypeDef *LPUARTx, LL_LPUART_InitTypeDef *LPUART_InitStruct);
  2361. void LL_LPUART_StructInit(LL_LPUART_InitTypeDef *LPUART_InitStruct);
  2362. /**
  2363. * @}
  2364. */
  2365. #endif /* USE_FULL_LL_DRIVER */
  2366. /**
  2367. * @}
  2368. */
  2369. /**
  2370. * @}
  2371. */
  2372. #endif /* LPUART1 */
  2373. /**
  2374. * @}
  2375. */
  2376. #ifdef __cplusplus
  2377. }
  2378. #endif
  2379. #endif /* STM32WBxx_LL_LPUART_H */
  2380. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/