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.
 
 
 

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