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.
 
 
 

2150 lines
74 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_ll_lpuart.h
  4. * @author MCD Application Team
  5. * @version V1.7.2
  6. * @date 16-June-2017
  7. * @brief Header file of LPUART LL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32L4xx_LL_LPUART_H
  39. #define __STM32L4xx_LL_LPUART_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32l4xx.h"
  45. /** @addtogroup STM32L4xx_LL_Driver
  46. * @{
  47. */
  48. #if defined (LPUART1)
  49. /** @defgroup LPUART_LL LPUART
  50. * @{
  51. */
  52. /* Private types -------------------------------------------------------------*/
  53. /* Private variables ---------------------------------------------------------*/
  54. /* Private constants ---------------------------------------------------------*/
  55. /** @defgroup LPUART_LL_Private_Constants LPUART Private Constants
  56. * @{
  57. */
  58. /* Defines used in Baud Rate related macros and corresponding register setting computation */
  59. #define LPUART_LPUARTDIV_FREQ_MUL 256U
  60. #define LPUART_BRR_MASK 0x000FFFFFU
  61. #define LPUART_BRR_MIN_VALUE 0x00000300U
  62. /**
  63. * @}
  64. */
  65. /* Private macros ------------------------------------------------------------*/
  66. #if defined(USE_FULL_LL_DRIVER)
  67. /** @defgroup LPUART_LL_Private_Macros LPUART Private Macros
  68. * @{
  69. */
  70. /**
  71. * @}
  72. */
  73. #endif /*USE_FULL_LL_DRIVER*/
  74. /* Exported types ------------------------------------------------------------*/
  75. #if defined(USE_FULL_LL_DRIVER)
  76. /** @defgroup LPUART_LL_ES_INIT LPUART Exported Init structures
  77. * @{
  78. */
  79. /**
  80. * @brief LL LPUART Init Structure definition
  81. */
  82. typedef struct
  83. {
  84. uint32_t BaudRate; /*!< This field defines expected LPUART communication baud rate.
  85. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetBaudRate().*/
  86. uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame.
  87. This parameter can be a value of @ref LPUART_LL_EC_DATAWIDTH.
  88. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetDataWidth().*/
  89. uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
  90. This parameter can be a value of @ref LPUART_LL_EC_STOPBITS.
  91. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetStopBitsLength().*/
  92. uint32_t Parity; /*!< Specifies the parity mode.
  93. This parameter can be a value of @ref LPUART_LL_EC_PARITY.
  94. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetParity().*/
  95. uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled.
  96. This parameter can be a value of @ref LPUART_LL_EC_DIRECTION.
  97. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetTransferDirection().*/
  98. uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled.
  99. This parameter can be a value of @ref LPUART_LL_EC_HWCONTROL.
  100. This feature can be modified afterwards using unitary function @ref LL_LPUART_SetHWFlowCtrl().*/
  101. } LL_LPUART_InitTypeDef;
  102. /**
  103. * @}
  104. */
  105. #endif /* USE_FULL_LL_DRIVER */
  106. /* Exported constants --------------------------------------------------------*/
  107. /** @defgroup LPUART_LL_Exported_Constants LPUART Exported Constants
  108. * @{
  109. */
  110. /** @defgroup LPUART_LL_EC_CLEAR_FLAG Clear Flags Defines
  111. * @brief Flags defines which can be used with LL_LPUART_WriteReg function
  112. * @{
  113. */
  114. #define LL_LPUART_ICR_PECF USART_ICR_PECF /*!< Parity error flag */
  115. #define LL_LPUART_ICR_FECF USART_ICR_FECF /*!< Framing error flag */
  116. #define LL_LPUART_ICR_NCF USART_ICR_NCF /*!< Noise detected flag */
  117. #define LL_LPUART_ICR_ORECF USART_ICR_ORECF /*!< Overrun error flag */
  118. #define LL_LPUART_ICR_IDLECF USART_ICR_IDLECF /*!< Idle line detected flag */
  119. #define LL_LPUART_ICR_TCCF USART_ICR_TCCF /*!< Transmission complete flag */
  120. #define LL_LPUART_ICR_CTSCF USART_ICR_CTSCF /*!< CTS flag */
  121. #define LL_LPUART_ICR_CMCF USART_ICR_CMCF /*!< Character match flag */
  122. #define LL_LPUART_ICR_WUCF USART_ICR_WUCF /*!< Wakeup from Stop mode flag */
  123. /**
  124. * @}
  125. */
  126. /** @defgroup LPUART_LL_EC_GET_FLAG Get Flags Defines
  127. * @brief Flags defines which can be used with LL_LPUART_ReadReg function
  128. * @{
  129. */
  130. #define LL_LPUART_ISR_PE USART_ISR_PE /*!< Parity error flag */
  131. #define LL_LPUART_ISR_FE USART_ISR_FE /*!< Framing error flag */
  132. #define LL_LPUART_ISR_NE USART_ISR_NE /*!< Noise detected flag */
  133. #define LL_LPUART_ISR_ORE USART_ISR_ORE /*!< Overrun error flag */
  134. #define LL_LPUART_ISR_IDLE USART_ISR_IDLE /*!< Idle line detected flag */
  135. #define LL_LPUART_ISR_RXNE USART_ISR_RXNE /*!< Read data register not empty flag */
  136. #define LL_LPUART_ISR_TC USART_ISR_TC /*!< Transmission complete flag */
  137. #define LL_LPUART_ISR_TXE USART_ISR_TXE /*!< Transmit data register empty flag */
  138. #define LL_LPUART_ISR_CTSIF USART_ISR_CTSIF /*!< CTS interrupt flag */
  139. #define LL_LPUART_ISR_CTS USART_ISR_CTS /*!< CTS flag */
  140. #define LL_LPUART_ISR_BUSY USART_ISR_BUSY /*!< Busy flag */
  141. #define LL_LPUART_ISR_CMF USART_ISR_CMF /*!< Character match flag */
  142. #define LL_LPUART_ISR_SBKF USART_ISR_SBKF /*!< Send break flag */
  143. #define LL_LPUART_ISR_RWU USART_ISR_RWU /*!< Receiver wakeup from Mute mode flag */
  144. #define LL_LPUART_ISR_WUF USART_ISR_WUF /*!< Wakeup from Stop mode flag */
  145. #define LL_LPUART_ISR_TEACK USART_ISR_TEACK /*!< Transmit enable acknowledge flag */
  146. #define LL_LPUART_ISR_REACK USART_ISR_REACK /*!< Receive enable acknowledge flag */
  147. /**
  148. * @}
  149. */
  150. /** @defgroup LPUART_LL_EC_IT IT Defines
  151. * @brief IT defines which can be used with LL_LPUART_ReadReg and LL_LPUART_WriteReg functions
  152. * @{
  153. */
  154. #define LL_LPUART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */
  155. #define LL_LPUART_CR1_RXNEIE USART_CR1_RXNEIE /*!< Read data register not empty interrupt enable */
  156. #define LL_LPUART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */
  157. #define LL_LPUART_CR1_TXEIE USART_CR1_TXEIE /*!< Transmit data register empty interrupt enable */
  158. #define LL_LPUART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */
  159. #define LL_LPUART_CR1_CMIE USART_CR1_CMIE /*!< Character match interrupt enable */
  160. #define LL_LPUART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */
  161. #define LL_LPUART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */
  162. #define LL_LPUART_CR3_WUFIE USART_CR3_WUFIE /*!< Wakeup from Stop mode interrupt enable */
  163. /**
  164. * @}
  165. */
  166. /** @defgroup LPUART_LL_EC_DIRECTION Direction
  167. * @{
  168. */
  169. #define LL_LPUART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */
  170. #define LL_LPUART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */
  171. #define LL_LPUART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */
  172. #define LL_LPUART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */
  173. /**
  174. * @}
  175. */
  176. /** @defgroup LPUART_LL_EC_PARITY Parity Control
  177. * @{
  178. */
  179. #define LL_LPUART_PARITY_NONE 0x00000000U /*!< Parity control disabled */
  180. #define LL_LPUART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */
  181. #define LL_LPUART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */
  182. /**
  183. * @}
  184. */
  185. /** @defgroup LPUART_LL_EC_WAKEUP Wakeup
  186. * @{
  187. */
  188. #define LL_LPUART_WAKEUP_IDLELINE 0x00000000U /*!< LPUART wake up from Mute mode on Idle Line */
  189. #define LL_LPUART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< LPUART wake up from Mute mode on Address Mark */
  190. /**
  191. * @}
  192. */
  193. /** @defgroup LPUART_LL_EC_DATAWIDTH Datawidth
  194. * @{
  195. */
  196. #define LL_LPUART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */
  197. #define LL_LPUART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
  198. #define LL_LPUART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
  199. /**
  200. * @}
  201. */
  202. /** @defgroup LPUART_LL_EC_STOPBITS Stop Bits
  203. * @{
  204. */
  205. #define LL_LPUART_STOPBITS_1 0x00000000U /*!< 1 stop bit */
  206. #define LL_LPUART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */
  207. /**
  208. * @}
  209. */
  210. /** @defgroup LPUART_LL_EC_TXRX TX RX Pins Swap
  211. * @{
  212. */
  213. #define LL_LPUART_TXRX_STANDARD 0x00000000U /*!< TX/RX pins are used as defined in standard pinout */
  214. #define LL_LPUART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */
  215. /**
  216. * @}
  217. */
  218. /** @defgroup LPUART_LL_EC_RXPIN_LEVEL RX Pin Active Level Inversion
  219. * @{
  220. */
  221. #define LL_LPUART_RXPIN_LEVEL_STANDARD 0x00000000U /*!< RX pin signal works using the standard logic levels */
  222. #define LL_LPUART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */
  223. /**
  224. * @}
  225. */
  226. /** @defgroup LPUART_LL_EC_TXPIN_LEVEL TX Pin Active Level Inversion
  227. * @{
  228. */
  229. #define LL_LPUART_TXPIN_LEVEL_STANDARD 0x00000000U /*!< TX pin signal works using the standard logic levels */
  230. #define LL_LPUART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */
  231. /**
  232. * @}
  233. */
  234. /** @defgroup LPUART_LL_EC_BINARY_LOGIC Binary Data Inversion
  235. * @{
  236. */
  237. #define LL_LPUART_BINARY_LOGIC_POSITIVE 0x00000000U /*!< Logical data from the data register are send/received in positive/direct logic. (1=H, 0=L) */
  238. #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. */
  239. /**
  240. * @}
  241. */
  242. /** @defgroup LPUART_LL_EC_BITORDER Bit Order
  243. * @{
  244. */
  245. #define LL_LPUART_BITORDER_LSBFIRST 0x00000000U /*!< data is transmitted/received with data bit 0 first, following the start bit */
  246. #define LL_LPUART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first, following the start bit */
  247. /**
  248. * @}
  249. */
  250. /** @defgroup LPUART_LL_EC_ADDRESS_DETECT Address Length Detection
  251. * @{
  252. */
  253. #define LL_LPUART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit address detection method selected */
  254. #define LL_LPUART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */
  255. /**
  256. * @}
  257. */
  258. /** @defgroup LPUART_LL_EC_HWCONTROL Hardware Control
  259. * @{
  260. */
  261. #define LL_LPUART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */
  262. #define LL_LPUART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */
  263. #define LL_LPUART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */
  264. #define LL_LPUART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */
  265. /**
  266. * @}
  267. */
  268. /** @defgroup LPUART_LL_EC_WAKEUP_ON Wakeup Activation
  269. * @{
  270. */
  271. #define LL_LPUART_WAKEUP_ON_ADDRESS 0x00000000U /*!< Wake up active on address match */
  272. #define LL_LPUART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wake up active on Start bit detection */
  273. #define LL_LPUART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wake up active on RXNE */
  274. /**
  275. * @}
  276. */
  277. /** @defgroup LPUART_LL_EC_DE_POLARITY Driver Enable Polarity
  278. * @{
  279. */
  280. #define LL_LPUART_DE_POLARITY_HIGH 0x00000000U /*!< DE signal is active high */
  281. #define LL_LPUART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */
  282. /**
  283. * @}
  284. */
  285. /** @defgroup LPUART_LL_EC_DMA_REG_DATA DMA Register Data
  286. * @{
  287. */
  288. #define LL_LPUART_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */
  289. #define LL_LPUART_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */
  290. /**
  291. * @}
  292. */
  293. /**
  294. * @}
  295. */
  296. /* Exported macro ------------------------------------------------------------*/
  297. /** @defgroup LPUART_LL_Exported_Macros LPUART Exported Macros
  298. * @{
  299. */
  300. /** @defgroup LPUART_LL_EM_WRITE_READ Common Write and read registers Macros
  301. * @{
  302. */
  303. /**
  304. * @brief Write a value in LPUART register
  305. * @param __INSTANCE__ LPUART Instance
  306. * @param __REG__ Register to be written
  307. * @param __VALUE__ Value to be written in the register
  308. * @retval None
  309. */
  310. #define LL_LPUART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  311. /**
  312. * @brief Read a value in LPUART register
  313. * @param __INSTANCE__ LPUART Instance
  314. * @param __REG__ Register to be read
  315. * @retval Register value
  316. */
  317. #define LL_LPUART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  318. /**
  319. * @}
  320. */
  321. /** @defgroup LPUART_LL_EM_Exported_Macros_Helper Helper Macros
  322. * @{
  323. */
  324. /**
  325. * @brief Compute LPUARTDIV value according to Peripheral Clock and
  326. * expected Baud Rate (20-bit value of LPUARTDIV is returned)
  327. * @param __PERIPHCLK__ Peripheral Clock frequency used for LPUART Instance
  328. * @param __BAUDRATE__ Baud Rate value to achieve
  329. * @retval LPUARTDIV value to be used for BRR register filling
  330. */
  331. #define __LL_LPUART_DIV(__PERIPHCLK__, __BAUDRATE__) (((((uint64_t)(__PERIPHCLK__)*LPUART_LPUARTDIV_FREQ_MUL) + ((__BAUDRATE__)/2))/(__BAUDRATE__)) & LPUART_BRR_MASK)
  332. /**
  333. * @}
  334. */
  335. /**
  336. * @}
  337. */
  338. /* Exported functions --------------------------------------------------------*/
  339. /** @defgroup LPUART_LL_Exported_Functions LPUART Exported Functions
  340. * @{
  341. */
  342. /** @defgroup LPUART_LL_EF_Configuration Configuration functions
  343. * @{
  344. */
  345. /**
  346. * @brief LPUART Enable
  347. * @rmtoll CR1 UE LL_LPUART_Enable
  348. * @param LPUARTx LPUART Instance
  349. * @retval None
  350. */
  351. __STATIC_INLINE void LL_LPUART_Enable(USART_TypeDef *LPUARTx)
  352. {
  353. SET_BIT(LPUARTx->CR1, USART_CR1_UE);
  354. }
  355. /**
  356. * @brief LPUART Disable
  357. * @note When LPUART is disabled, LPUART prescalers and outputs are stopped immediately,
  358. * and current operations are discarded. The configuration of the LPUART is kept, but all the status
  359. * flags, in the LPUARTx_ISR are set to their default values.
  360. * @note In order to go into low-power mode without generating errors on the line,
  361. * the TE bit must be reset before and the software must wait
  362. * for the TC bit in the LPUART_ISR to be set before resetting the UE bit.
  363. * The DMA requests are also reset when UE = 0 so the DMA channel must
  364. * be disabled before resetting the UE bit.
  365. * @rmtoll CR1 UE LL_LPUART_Disable
  366. * @param LPUARTx LPUART Instance
  367. * @retval None
  368. */
  369. __STATIC_INLINE void LL_LPUART_Disable(USART_TypeDef *LPUARTx)
  370. {
  371. CLEAR_BIT(LPUARTx->CR1, USART_CR1_UE);
  372. }
  373. /**
  374. * @brief Indicate if LPUART is enabled
  375. * @rmtoll CR1 UE LL_LPUART_IsEnabled
  376. * @param LPUARTx LPUART Instance
  377. * @retval State of bit (1 or 0).
  378. */
  379. __STATIC_INLINE uint32_t LL_LPUART_IsEnabled(USART_TypeDef *LPUARTx)
  380. {
  381. return (READ_BIT(LPUARTx->CR1, USART_CR1_UE) == (USART_CR1_UE));
  382. }
  383. /**
  384. * @brief LPUART enabled in STOP Mode
  385. * @note When this function is enabled, LPUART is able to wake up the MCU from Stop mode, provided that
  386. * LPUART clock selection is HSI or LSE in RCC.
  387. * @rmtoll CR1 UESM LL_LPUART_EnableInStopMode
  388. * @param LPUARTx LPUART Instance
  389. * @retval None
  390. */
  391. __STATIC_INLINE void LL_LPUART_EnableInStopMode(USART_TypeDef *LPUARTx)
  392. {
  393. SET_BIT(LPUARTx->CR1, USART_CR1_UESM);
  394. }
  395. /**
  396. * @brief LPUART disabled in STOP Mode
  397. * @note When this function is disabled, LPUART is not able to wake up the MCU from Stop mode
  398. * @rmtoll CR1 UESM LL_LPUART_DisableInStopMode
  399. * @param LPUARTx LPUART Instance
  400. * @retval None
  401. */
  402. __STATIC_INLINE void LL_LPUART_DisableInStopMode(USART_TypeDef *LPUARTx)
  403. {
  404. CLEAR_BIT(LPUARTx->CR1, USART_CR1_UESM);
  405. }
  406. /**
  407. * @brief Indicate if LPUART is enabled in STOP Mode
  408. * (able to wake up MCU from Stop mode or not)
  409. * @rmtoll CR1 UESM LL_LPUART_IsEnabledInStopMode
  410. * @param LPUARTx LPUART Instance
  411. * @retval State of bit (1 or 0).
  412. */
  413. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledInStopMode(USART_TypeDef *LPUARTx)
  414. {
  415. return (READ_BIT(LPUARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM));
  416. }
  417. /**
  418. * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit)
  419. * @rmtoll CR1 RE LL_LPUART_EnableDirectionRx
  420. * @param LPUARTx LPUART Instance
  421. * @retval None
  422. */
  423. __STATIC_INLINE void LL_LPUART_EnableDirectionRx(USART_TypeDef *LPUARTx)
  424. {
  425. SET_BIT(LPUARTx->CR1, USART_CR1_RE);
  426. }
  427. /**
  428. * @brief Receiver Disable
  429. * @rmtoll CR1 RE LL_LPUART_DisableDirectionRx
  430. * @param LPUARTx LPUART Instance
  431. * @retval None
  432. */
  433. __STATIC_INLINE void LL_LPUART_DisableDirectionRx(USART_TypeDef *LPUARTx)
  434. {
  435. CLEAR_BIT(LPUARTx->CR1, USART_CR1_RE);
  436. }
  437. /**
  438. * @brief Transmitter Enable
  439. * @rmtoll CR1 TE LL_LPUART_EnableDirectionTx
  440. * @param LPUARTx LPUART Instance
  441. * @retval None
  442. */
  443. __STATIC_INLINE void LL_LPUART_EnableDirectionTx(USART_TypeDef *LPUARTx)
  444. {
  445. SET_BIT(LPUARTx->CR1, USART_CR1_TE);
  446. }
  447. /**
  448. * @brief Transmitter Disable
  449. * @rmtoll CR1 TE LL_LPUART_DisableDirectionTx
  450. * @param LPUARTx LPUART Instance
  451. * @retval None
  452. */
  453. __STATIC_INLINE void LL_LPUART_DisableDirectionTx(USART_TypeDef *LPUARTx)
  454. {
  455. CLEAR_BIT(LPUARTx->CR1, USART_CR1_TE);
  456. }
  457. /**
  458. * @brief Configure simultaneously enabled/disabled states
  459. * of Transmitter and Receiver
  460. * @rmtoll CR1 RE LL_LPUART_SetTransferDirection\n
  461. * CR1 TE LL_LPUART_SetTransferDirection
  462. * @param LPUARTx LPUART Instance
  463. * @param TransferDirection This parameter can be one of the following values:
  464. * @arg @ref LL_LPUART_DIRECTION_NONE
  465. * @arg @ref LL_LPUART_DIRECTION_RX
  466. * @arg @ref LL_LPUART_DIRECTION_TX
  467. * @arg @ref LL_LPUART_DIRECTION_TX_RX
  468. * @retval None
  469. */
  470. __STATIC_INLINE void LL_LPUART_SetTransferDirection(USART_TypeDef *LPUARTx, uint32_t TransferDirection)
  471. {
  472. MODIFY_REG(LPUARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection);
  473. }
  474. /**
  475. * @brief Return enabled/disabled states of Transmitter and Receiver
  476. * @rmtoll CR1 RE LL_LPUART_GetTransferDirection\n
  477. * CR1 TE LL_LPUART_GetTransferDirection
  478. * @param LPUARTx LPUART Instance
  479. * @retval Returned value can be one of the following values:
  480. * @arg @ref LL_LPUART_DIRECTION_NONE
  481. * @arg @ref LL_LPUART_DIRECTION_RX
  482. * @arg @ref LL_LPUART_DIRECTION_TX
  483. * @arg @ref LL_LPUART_DIRECTION_TX_RX
  484. */
  485. __STATIC_INLINE uint32_t LL_LPUART_GetTransferDirection(USART_TypeDef *LPUARTx)
  486. {
  487. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_RE | USART_CR1_TE));
  488. }
  489. /**
  490. * @brief Configure Parity (enabled/disabled and parity mode if enabled)
  491. * @note This function selects if hardware parity control (generation and detection) is enabled or disabled.
  492. * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position
  493. * (depending on data width) and parity is checked on the received data.
  494. * @rmtoll CR1 PS LL_LPUART_SetParity\n
  495. * CR1 PCE LL_LPUART_SetParity
  496. * @param LPUARTx LPUART Instance
  497. * @param Parity This parameter can be one of the following values:
  498. * @arg @ref LL_LPUART_PARITY_NONE
  499. * @arg @ref LL_LPUART_PARITY_EVEN
  500. * @arg @ref LL_LPUART_PARITY_ODD
  501. * @retval None
  502. */
  503. __STATIC_INLINE void LL_LPUART_SetParity(USART_TypeDef *LPUARTx, uint32_t Parity)
  504. {
  505. MODIFY_REG(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity);
  506. }
  507. /**
  508. * @brief Return Parity configuration (enabled/disabled and parity mode if enabled)
  509. * @rmtoll CR1 PS LL_LPUART_GetParity\n
  510. * CR1 PCE LL_LPUART_GetParity
  511. * @param LPUARTx LPUART Instance
  512. * @retval Returned value can be one of the following values:
  513. * @arg @ref LL_LPUART_PARITY_NONE
  514. * @arg @ref LL_LPUART_PARITY_EVEN
  515. * @arg @ref LL_LPUART_PARITY_ODD
  516. */
  517. __STATIC_INLINE uint32_t LL_LPUART_GetParity(USART_TypeDef *LPUARTx)
  518. {
  519. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE));
  520. }
  521. /**
  522. * @brief Set Receiver Wake Up method from Mute mode.
  523. * @rmtoll CR1 WAKE LL_LPUART_SetWakeUpMethod
  524. * @param LPUARTx LPUART Instance
  525. * @param Method This parameter can be one of the following values:
  526. * @arg @ref LL_LPUART_WAKEUP_IDLELINE
  527. * @arg @ref LL_LPUART_WAKEUP_ADDRESSMARK
  528. * @retval None
  529. */
  530. __STATIC_INLINE void LL_LPUART_SetWakeUpMethod(USART_TypeDef *LPUARTx, uint32_t Method)
  531. {
  532. MODIFY_REG(LPUARTx->CR1, USART_CR1_WAKE, Method);
  533. }
  534. /**
  535. * @brief Return Receiver Wake Up method from Mute mode
  536. * @rmtoll CR1 WAKE LL_LPUART_GetWakeUpMethod
  537. * @param LPUARTx LPUART Instance
  538. * @retval Returned value can be one of the following values:
  539. * @arg @ref LL_LPUART_WAKEUP_IDLELINE
  540. * @arg @ref LL_LPUART_WAKEUP_ADDRESSMARK
  541. */
  542. __STATIC_INLINE uint32_t LL_LPUART_GetWakeUpMethod(USART_TypeDef *LPUARTx)
  543. {
  544. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_WAKE));
  545. }
  546. /**
  547. * @brief Set Word length (nb of data bits, excluding start and stop bits)
  548. * @rmtoll CR1 M LL_LPUART_SetDataWidth
  549. * @param LPUARTx LPUART Instance
  550. * @param DataWidth This parameter can be one of the following values:
  551. * @arg @ref LL_LPUART_DATAWIDTH_7B
  552. * @arg @ref LL_LPUART_DATAWIDTH_8B
  553. * @arg @ref LL_LPUART_DATAWIDTH_9B
  554. * @retval None
  555. */
  556. __STATIC_INLINE void LL_LPUART_SetDataWidth(USART_TypeDef *LPUARTx, uint32_t DataWidth)
  557. {
  558. MODIFY_REG(LPUARTx->CR1, USART_CR1_M, DataWidth);
  559. }
  560. /**
  561. * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits)
  562. * @rmtoll CR1 M LL_LPUART_GetDataWidth
  563. * @param LPUARTx LPUART Instance
  564. * @retval Returned value can be one of the following values:
  565. * @arg @ref LL_LPUART_DATAWIDTH_7B
  566. * @arg @ref LL_LPUART_DATAWIDTH_8B
  567. * @arg @ref LL_LPUART_DATAWIDTH_9B
  568. */
  569. __STATIC_INLINE uint32_t LL_LPUART_GetDataWidth(USART_TypeDef *LPUARTx)
  570. {
  571. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_M));
  572. }
  573. /**
  574. * @brief Allow switch between Mute Mode and Active mode
  575. * @rmtoll CR1 MME LL_LPUART_EnableMuteMode
  576. * @param LPUARTx LPUART Instance
  577. * @retval None
  578. */
  579. __STATIC_INLINE void LL_LPUART_EnableMuteMode(USART_TypeDef *LPUARTx)
  580. {
  581. SET_BIT(LPUARTx->CR1, USART_CR1_MME);
  582. }
  583. /**
  584. * @brief Prevent Mute Mode use. Set Receiver in active mode permanently.
  585. * @rmtoll CR1 MME LL_LPUART_DisableMuteMode
  586. * @param LPUARTx LPUART Instance
  587. * @retval None
  588. */
  589. __STATIC_INLINE void LL_LPUART_DisableMuteMode(USART_TypeDef *LPUARTx)
  590. {
  591. CLEAR_BIT(LPUARTx->CR1, USART_CR1_MME);
  592. }
  593. /**
  594. * @brief Indicate if switch between Mute Mode and Active mode is allowed
  595. * @rmtoll CR1 MME LL_LPUART_IsEnabledMuteMode
  596. * @param LPUARTx LPUART Instance
  597. * @retval State of bit (1 or 0).
  598. */
  599. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledMuteMode(USART_TypeDef *LPUARTx)
  600. {
  601. return (READ_BIT(LPUARTx->CR1, USART_CR1_MME) == (USART_CR1_MME));
  602. }
  603. /**
  604. * @brief Set the length of the stop bits
  605. * @rmtoll CR2 STOP LL_LPUART_SetStopBitsLength
  606. * @param LPUARTx LPUART Instance
  607. * @param StopBits This parameter can be one of the following values:
  608. * @arg @ref LL_LPUART_STOPBITS_1
  609. * @arg @ref LL_LPUART_STOPBITS_2
  610. * @retval None
  611. */
  612. __STATIC_INLINE void LL_LPUART_SetStopBitsLength(USART_TypeDef *LPUARTx, uint32_t StopBits)
  613. {
  614. MODIFY_REG(LPUARTx->CR2, USART_CR2_STOP, StopBits);
  615. }
  616. /**
  617. * @brief Retrieve the length of the stop bits
  618. * @rmtoll CR2 STOP LL_LPUART_GetStopBitsLength
  619. * @param LPUARTx LPUART Instance
  620. * @retval Returned value can be one of the following values:
  621. * @arg @ref LL_LPUART_STOPBITS_1
  622. * @arg @ref LL_LPUART_STOPBITS_2
  623. */
  624. __STATIC_INLINE uint32_t LL_LPUART_GetStopBitsLength(USART_TypeDef *LPUARTx)
  625. {
  626. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_STOP));
  627. }
  628. /**
  629. * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits)
  630. * @note Call of this function is equivalent to following function call sequence :
  631. * - Data Width configuration using @ref LL_LPUART_SetDataWidth() function
  632. * - Parity Control and mode configuration using @ref LL_LPUART_SetParity() function
  633. * - Stop bits configuration using @ref LL_LPUART_SetStopBitsLength() function
  634. * @rmtoll CR1 PS LL_LPUART_ConfigCharacter\n
  635. * CR1 PCE LL_LPUART_ConfigCharacter\n
  636. * CR1 M LL_LPUART_ConfigCharacter\n
  637. * CR2 STOP LL_LPUART_ConfigCharacter
  638. * @param LPUARTx LPUART Instance
  639. * @param DataWidth This parameter can be one of the following values:
  640. * @arg @ref LL_LPUART_DATAWIDTH_7B
  641. * @arg @ref LL_LPUART_DATAWIDTH_8B
  642. * @arg @ref LL_LPUART_DATAWIDTH_9B
  643. * @param Parity This parameter can be one of the following values:
  644. * @arg @ref LL_LPUART_PARITY_NONE
  645. * @arg @ref LL_LPUART_PARITY_EVEN
  646. * @arg @ref LL_LPUART_PARITY_ODD
  647. * @param StopBits This parameter can be one of the following values:
  648. * @arg @ref LL_LPUART_STOPBITS_1
  649. * @arg @ref LL_LPUART_STOPBITS_2
  650. * @retval None
  651. */
  652. __STATIC_INLINE void LL_LPUART_ConfigCharacter(USART_TypeDef *LPUARTx, uint32_t DataWidth, uint32_t Parity,
  653. uint32_t StopBits)
  654. {
  655. MODIFY_REG(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth);
  656. MODIFY_REG(LPUARTx->CR2, USART_CR2_STOP, StopBits);
  657. }
  658. /**
  659. * @brief Configure TX/RX pins swapping setting.
  660. * @rmtoll CR2 SWAP LL_LPUART_SetTXRXSwap
  661. * @param LPUARTx LPUART Instance
  662. * @param SwapConfig This parameter can be one of the following values:
  663. * @arg @ref LL_LPUART_TXRX_STANDARD
  664. * @arg @ref LL_LPUART_TXRX_SWAPPED
  665. * @retval None
  666. */
  667. __STATIC_INLINE void LL_LPUART_SetTXRXSwap(USART_TypeDef *LPUARTx, uint32_t SwapConfig)
  668. {
  669. MODIFY_REG(LPUARTx->CR2, USART_CR2_SWAP, SwapConfig);
  670. }
  671. /**
  672. * @brief Retrieve TX/RX pins swapping configuration.
  673. * @rmtoll CR2 SWAP LL_LPUART_GetTXRXSwap
  674. * @param LPUARTx LPUART Instance
  675. * @retval Returned value can be one of the following values:
  676. * @arg @ref LL_LPUART_TXRX_STANDARD
  677. * @arg @ref LL_LPUART_TXRX_SWAPPED
  678. */
  679. __STATIC_INLINE uint32_t LL_LPUART_GetTXRXSwap(USART_TypeDef *LPUARTx)
  680. {
  681. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_SWAP));
  682. }
  683. /**
  684. * @brief Configure RX pin active level logic
  685. * @rmtoll CR2 RXINV LL_LPUART_SetRXPinLevel
  686. * @param LPUARTx LPUART Instance
  687. * @param PinInvMethod This parameter can be one of the following values:
  688. * @arg @ref LL_LPUART_RXPIN_LEVEL_STANDARD
  689. * @arg @ref LL_LPUART_RXPIN_LEVEL_INVERTED
  690. * @retval None
  691. */
  692. __STATIC_INLINE void LL_LPUART_SetRXPinLevel(USART_TypeDef *LPUARTx, uint32_t PinInvMethod)
  693. {
  694. MODIFY_REG(LPUARTx->CR2, USART_CR2_RXINV, PinInvMethod);
  695. }
  696. /**
  697. * @brief Retrieve RX pin active level logic configuration
  698. * @rmtoll CR2 RXINV LL_LPUART_GetRXPinLevel
  699. * @param LPUARTx LPUART Instance
  700. * @retval Returned value can be one of the following values:
  701. * @arg @ref LL_LPUART_RXPIN_LEVEL_STANDARD
  702. * @arg @ref LL_LPUART_RXPIN_LEVEL_INVERTED
  703. */
  704. __STATIC_INLINE uint32_t LL_LPUART_GetRXPinLevel(USART_TypeDef *LPUARTx)
  705. {
  706. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_RXINV));
  707. }
  708. /**
  709. * @brief Configure TX pin active level logic
  710. * @rmtoll CR2 TXINV LL_LPUART_SetTXPinLevel
  711. * @param LPUARTx LPUART Instance
  712. * @param PinInvMethod This parameter can be one of the following values:
  713. * @arg @ref LL_LPUART_TXPIN_LEVEL_STANDARD
  714. * @arg @ref LL_LPUART_TXPIN_LEVEL_INVERTED
  715. * @retval None
  716. */
  717. __STATIC_INLINE void LL_LPUART_SetTXPinLevel(USART_TypeDef *LPUARTx, uint32_t PinInvMethod)
  718. {
  719. MODIFY_REG(LPUARTx->CR2, USART_CR2_TXINV, PinInvMethod);
  720. }
  721. /**
  722. * @brief Retrieve TX pin active level logic configuration
  723. * @rmtoll CR2 TXINV LL_LPUART_GetTXPinLevel
  724. * @param LPUARTx LPUART Instance
  725. * @retval Returned value can be one of the following values:
  726. * @arg @ref LL_LPUART_TXPIN_LEVEL_STANDARD
  727. * @arg @ref LL_LPUART_TXPIN_LEVEL_INVERTED
  728. */
  729. __STATIC_INLINE uint32_t LL_LPUART_GetTXPinLevel(USART_TypeDef *LPUARTx)
  730. {
  731. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_TXINV));
  732. }
  733. /**
  734. * @brief Configure Binary data logic.
  735. *
  736. * @note Allow to define how Logical data from the data register are send/received :
  737. * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H)
  738. * @rmtoll CR2 DATAINV LL_LPUART_SetBinaryDataLogic
  739. * @param LPUARTx LPUART Instance
  740. * @param DataLogic This parameter can be one of the following values:
  741. * @arg @ref LL_LPUART_BINARY_LOGIC_POSITIVE
  742. * @arg @ref LL_LPUART_BINARY_LOGIC_NEGATIVE
  743. * @retval None
  744. */
  745. __STATIC_INLINE void LL_LPUART_SetBinaryDataLogic(USART_TypeDef *LPUARTx, uint32_t DataLogic)
  746. {
  747. MODIFY_REG(LPUARTx->CR2, USART_CR2_DATAINV, DataLogic);
  748. }
  749. /**
  750. * @brief Retrieve Binary data configuration
  751. * @rmtoll CR2 DATAINV LL_LPUART_GetBinaryDataLogic
  752. * @param LPUARTx LPUART Instance
  753. * @retval Returned value can be one of the following values:
  754. * @arg @ref LL_LPUART_BINARY_LOGIC_POSITIVE
  755. * @arg @ref LL_LPUART_BINARY_LOGIC_NEGATIVE
  756. */
  757. __STATIC_INLINE uint32_t LL_LPUART_GetBinaryDataLogic(USART_TypeDef *LPUARTx)
  758. {
  759. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_DATAINV));
  760. }
  761. /**
  762. * @brief Configure transfer bit order (either Less or Most Significant Bit First)
  763. * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
  764. * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
  765. * @rmtoll CR2 MSBFIRST LL_LPUART_SetTransferBitOrder
  766. * @param LPUARTx LPUART Instance
  767. * @param BitOrder This parameter can be one of the following values:
  768. * @arg @ref LL_LPUART_BITORDER_LSBFIRST
  769. * @arg @ref LL_LPUART_BITORDER_MSBFIRST
  770. * @retval None
  771. */
  772. __STATIC_INLINE void LL_LPUART_SetTransferBitOrder(USART_TypeDef *LPUARTx, uint32_t BitOrder)
  773. {
  774. MODIFY_REG(LPUARTx->CR2, USART_CR2_MSBFIRST, BitOrder);
  775. }
  776. /**
  777. * @brief Return transfer bit order (either Less or Most Significant Bit First)
  778. * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
  779. * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
  780. * @rmtoll CR2 MSBFIRST LL_LPUART_GetTransferBitOrder
  781. * @param LPUARTx LPUART Instance
  782. * @retval Returned value can be one of the following values:
  783. * @arg @ref LL_LPUART_BITORDER_LSBFIRST
  784. * @arg @ref LL_LPUART_BITORDER_MSBFIRST
  785. */
  786. __STATIC_INLINE uint32_t LL_LPUART_GetTransferBitOrder(USART_TypeDef *LPUARTx)
  787. {
  788. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_MSBFIRST));
  789. }
  790. /**
  791. * @brief Set Address of the LPUART node.
  792. * @note This is used in multiprocessor communication during Mute mode or Stop mode,
  793. * for wake up with address mark detection.
  794. * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7.
  795. * (b7-b4 should be set to 0)
  796. * 8bits address node is used when 7-bit Address Detection is selected in ADDM7.
  797. * (This is used in multiprocessor communication during Mute mode or Stop mode,
  798. * for wake up with 7-bit address mark detection.
  799. * The MSB of the character sent by the transmitter should be equal to 1.
  800. * It may also be used for character detection during normal reception,
  801. * Mute mode inactive (for example, end of block detection in ModBus protocol).
  802. * In this case, the whole received character (8-bit) is compared to the ADD[7:0]
  803. * value and CMF flag is set on match)
  804. * @rmtoll CR2 ADD LL_LPUART_ConfigNodeAddress\n
  805. * CR2 ADDM7 LL_LPUART_ConfigNodeAddress
  806. * @param LPUARTx LPUART Instance
  807. * @param AddressLen This parameter can be one of the following values:
  808. * @arg @ref LL_LPUART_ADDRESS_DETECT_4B
  809. * @arg @ref LL_LPUART_ADDRESS_DETECT_7B
  810. * @param NodeAddress 4 or 7 bit Address of the LPUART node.
  811. * @retval None
  812. */
  813. __STATIC_INLINE void LL_LPUART_ConfigNodeAddress(USART_TypeDef *LPUARTx, uint32_t AddressLen, uint32_t NodeAddress)
  814. {
  815. MODIFY_REG(LPUARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7,
  816. (uint32_t)(AddressLen | (NodeAddress << USART_CR2_ADD_Pos)));
  817. }
  818. /**
  819. * @brief Return 8 bit Address of the LPUART node as set in ADD field of CR2.
  820. * @note If 4-bit Address Detection is selected in ADDM7,
  821. * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant)
  822. * If 7-bit Address Detection is selected in ADDM7,
  823. * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant)
  824. * @rmtoll CR2 ADD LL_LPUART_GetNodeAddress
  825. * @param LPUARTx LPUART Instance
  826. * @retval Address of the LPUART node (Value between Min_Data=0 and Max_Data=255)
  827. */
  828. __STATIC_INLINE uint32_t LL_LPUART_GetNodeAddress(USART_TypeDef *LPUARTx)
  829. {
  830. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_ADD) >> USART_CR2_ADD_Pos);
  831. }
  832. /**
  833. * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit)
  834. * @rmtoll CR2 ADDM7 LL_LPUART_GetNodeAddressLen
  835. * @param LPUARTx LPUART Instance
  836. * @retval Returned value can be one of the following values:
  837. * @arg @ref LL_LPUART_ADDRESS_DETECT_4B
  838. * @arg @ref LL_LPUART_ADDRESS_DETECT_7B
  839. */
  840. __STATIC_INLINE uint32_t LL_LPUART_GetNodeAddressLen(USART_TypeDef *LPUARTx)
  841. {
  842. return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_ADDM7));
  843. }
  844. /**
  845. * @brief Enable RTS HW Flow Control
  846. * @rmtoll CR3 RTSE LL_LPUART_EnableRTSHWFlowCtrl
  847. * @param LPUARTx LPUART Instance
  848. * @retval None
  849. */
  850. __STATIC_INLINE void LL_LPUART_EnableRTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  851. {
  852. SET_BIT(LPUARTx->CR3, USART_CR3_RTSE);
  853. }
  854. /**
  855. * @brief Disable RTS HW Flow Control
  856. * @rmtoll CR3 RTSE LL_LPUART_DisableRTSHWFlowCtrl
  857. * @param LPUARTx LPUART Instance
  858. * @retval None
  859. */
  860. __STATIC_INLINE void LL_LPUART_DisableRTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  861. {
  862. CLEAR_BIT(LPUARTx->CR3, USART_CR3_RTSE);
  863. }
  864. /**
  865. * @brief Enable CTS HW Flow Control
  866. * @rmtoll CR3 CTSE LL_LPUART_EnableCTSHWFlowCtrl
  867. * @param LPUARTx LPUART Instance
  868. * @retval None
  869. */
  870. __STATIC_INLINE void LL_LPUART_EnableCTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  871. {
  872. SET_BIT(LPUARTx->CR3, USART_CR3_CTSE);
  873. }
  874. /**
  875. * @brief Disable CTS HW Flow Control
  876. * @rmtoll CR3 CTSE LL_LPUART_DisableCTSHWFlowCtrl
  877. * @param LPUARTx LPUART Instance
  878. * @retval None
  879. */
  880. __STATIC_INLINE void LL_LPUART_DisableCTSHWFlowCtrl(USART_TypeDef *LPUARTx)
  881. {
  882. CLEAR_BIT(LPUARTx->CR3, USART_CR3_CTSE);
  883. }
  884. /**
  885. * @brief Configure HW Flow Control mode (both CTS and RTS)
  886. * @rmtoll CR3 RTSE LL_LPUART_SetHWFlowCtrl\n
  887. * CR3 CTSE LL_LPUART_SetHWFlowCtrl
  888. * @param LPUARTx LPUART Instance
  889. * @param HardwareFlowControl This parameter can be one of the following values:
  890. * @arg @ref LL_LPUART_HWCONTROL_NONE
  891. * @arg @ref LL_LPUART_HWCONTROL_RTS
  892. * @arg @ref LL_LPUART_HWCONTROL_CTS
  893. * @arg @ref LL_LPUART_HWCONTROL_RTS_CTS
  894. * @retval None
  895. */
  896. __STATIC_INLINE void LL_LPUART_SetHWFlowCtrl(USART_TypeDef *LPUARTx, uint32_t HardwareFlowControl)
  897. {
  898. MODIFY_REG(LPUARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl);
  899. }
  900. /**
  901. * @brief Return HW Flow Control configuration (both CTS and RTS)
  902. * @rmtoll CR3 RTSE LL_LPUART_GetHWFlowCtrl\n
  903. * CR3 CTSE LL_LPUART_GetHWFlowCtrl
  904. * @param LPUARTx LPUART Instance
  905. * @retval Returned value can be one of the following values:
  906. * @arg @ref LL_LPUART_HWCONTROL_NONE
  907. * @arg @ref LL_LPUART_HWCONTROL_RTS
  908. * @arg @ref LL_LPUART_HWCONTROL_CTS
  909. * @arg @ref LL_LPUART_HWCONTROL_RTS_CTS
  910. */
  911. __STATIC_INLINE uint32_t LL_LPUART_GetHWFlowCtrl(USART_TypeDef *LPUARTx)
  912. {
  913. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE));
  914. }
  915. /**
  916. * @brief Enable Overrun detection
  917. * @rmtoll CR3 OVRDIS LL_LPUART_EnableOverrunDetect
  918. * @param LPUARTx LPUART Instance
  919. * @retval None
  920. */
  921. __STATIC_INLINE void LL_LPUART_EnableOverrunDetect(USART_TypeDef *LPUARTx)
  922. {
  923. CLEAR_BIT(LPUARTx->CR3, USART_CR3_OVRDIS);
  924. }
  925. /**
  926. * @brief Disable Overrun detection
  927. * @rmtoll CR3 OVRDIS LL_LPUART_DisableOverrunDetect
  928. * @param LPUARTx LPUART Instance
  929. * @retval None
  930. */
  931. __STATIC_INLINE void LL_LPUART_DisableOverrunDetect(USART_TypeDef *LPUARTx)
  932. {
  933. SET_BIT(LPUARTx->CR3, USART_CR3_OVRDIS);
  934. }
  935. /**
  936. * @brief Indicate if Overrun detection is enabled
  937. * @rmtoll CR3 OVRDIS LL_LPUART_IsEnabledOverrunDetect
  938. * @param LPUARTx LPUART Instance
  939. * @retval State of bit (1 or 0).
  940. */
  941. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledOverrunDetect(USART_TypeDef *LPUARTx)
  942. {
  943. return (READ_BIT(LPUARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS);
  944. }
  945. /**
  946. * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits)
  947. * @rmtoll CR3 WUS LL_LPUART_SetWKUPType
  948. * @param LPUARTx LPUART Instance
  949. * @param Type This parameter can be one of the following values:
  950. * @arg @ref LL_LPUART_WAKEUP_ON_ADDRESS
  951. * @arg @ref LL_LPUART_WAKEUP_ON_STARTBIT
  952. * @arg @ref LL_LPUART_WAKEUP_ON_RXNE
  953. * @retval None
  954. */
  955. __STATIC_INLINE void LL_LPUART_SetWKUPType(USART_TypeDef *LPUARTx, uint32_t Type)
  956. {
  957. MODIFY_REG(LPUARTx->CR3, USART_CR3_WUS, Type);
  958. }
  959. /**
  960. * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits)
  961. * @rmtoll CR3 WUS LL_LPUART_GetWKUPType
  962. * @param LPUARTx LPUART Instance
  963. * @retval Returned value can be one of the following values:
  964. * @arg @ref LL_LPUART_WAKEUP_ON_ADDRESS
  965. * @arg @ref LL_LPUART_WAKEUP_ON_STARTBIT
  966. * @arg @ref LL_LPUART_WAKEUP_ON_RXNE
  967. */
  968. __STATIC_INLINE uint32_t LL_LPUART_GetWKUPType(USART_TypeDef *LPUARTx)
  969. {
  970. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_WUS));
  971. }
  972. /**
  973. * @brief Configure LPUART BRR register for achieving expected Baud Rate value.
  974. *
  975. * @note Compute and set LPUARTDIV value in BRR Register (full BRR content)
  976. * according to used Peripheral Clock and expected Baud Rate values
  977. * @note Peripheral clock and Baud Rate values provided as function parameters should be valid
  978. * (Baud rate value != 0).
  979. * @note Provided that LPUARTx_BRR must be > = 0x300 and LPUART_BRR is 20-bit,
  980. * a care should be taken when generating high baud rates using high PeriphClk
  981. * values. PeriphClk must be in the range [3 x BaudRate, 4096 x BaudRate].
  982. * @rmtoll BRR BRR LL_LPUART_SetBaudRate
  983. * @param LPUARTx LPUART Instance
  984. * @param PeriphClk Peripheral Clock
  985. * @param BaudRate Baud Rate
  986. * @retval None
  987. */
  988. __STATIC_INLINE void LL_LPUART_SetBaudRate(USART_TypeDef *LPUARTx, uint32_t PeriphClk, uint32_t BaudRate)
  989. {
  990. LPUARTx->BRR = __LL_LPUART_DIV(PeriphClk, BaudRate);
  991. }
  992. /**
  993. * @brief Return current Baud Rate value, according to LPUARTDIV present in BRR register
  994. * (full BRR content), and to used Peripheral Clock values
  995. * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned.
  996. * @rmtoll BRR BRR LL_LPUART_GetBaudRate
  997. * @param LPUARTx LPUART Instance
  998. * @param PeriphClk Peripheral Clock
  999. * @retval Baud Rate
  1000. */
  1001. __STATIC_INLINE uint32_t LL_LPUART_GetBaudRate(USART_TypeDef *LPUARTx, uint32_t PeriphClk)
  1002. {
  1003. register uint32_t lpuartdiv = 0x0U;
  1004. register uint32_t brrresult = 0x0U;
  1005. lpuartdiv = LPUARTx->BRR & LPUART_BRR_MASK;
  1006. if (lpuartdiv >= LPUART_BRR_MIN_VALUE)
  1007. {
  1008. brrresult = (uint32_t)(((uint64_t)(PeriphClk) * LPUART_LPUARTDIV_FREQ_MUL) / lpuartdiv);
  1009. }
  1010. return (brrresult);
  1011. }
  1012. /**
  1013. * @}
  1014. */
  1015. /** @defgroup LPUART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature
  1016. * @{
  1017. */
  1018. /**
  1019. * @brief Enable Single Wire Half-Duplex mode
  1020. * @rmtoll CR3 HDSEL LL_LPUART_EnableHalfDuplex
  1021. * @param LPUARTx LPUART Instance
  1022. * @retval None
  1023. */
  1024. __STATIC_INLINE void LL_LPUART_EnableHalfDuplex(USART_TypeDef *LPUARTx)
  1025. {
  1026. SET_BIT(LPUARTx->CR3, USART_CR3_HDSEL);
  1027. }
  1028. /**
  1029. * @brief Disable Single Wire Half-Duplex mode
  1030. * @rmtoll CR3 HDSEL LL_LPUART_DisableHalfDuplex
  1031. * @param LPUARTx LPUART Instance
  1032. * @retval None
  1033. */
  1034. __STATIC_INLINE void LL_LPUART_DisableHalfDuplex(USART_TypeDef *LPUARTx)
  1035. {
  1036. CLEAR_BIT(LPUARTx->CR3, USART_CR3_HDSEL);
  1037. }
  1038. /**
  1039. * @brief Indicate if Single Wire Half-Duplex mode is enabled
  1040. * @rmtoll CR3 HDSEL LL_LPUART_IsEnabledHalfDuplex
  1041. * @param LPUARTx LPUART Instance
  1042. * @retval State of bit (1 or 0).
  1043. */
  1044. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledHalfDuplex(USART_TypeDef *LPUARTx)
  1045. {
  1046. return (READ_BIT(LPUARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL));
  1047. }
  1048. /**
  1049. * @}
  1050. */
  1051. /** @defgroup LPUART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature
  1052. * @{
  1053. */
  1054. /**
  1055. * @brief Set DEDT (Driver Enable De-Assertion Time), Time value expressed on 5 bits ([4:0] bits).
  1056. * @rmtoll CR1 DEDT LL_LPUART_SetDEDeassertionTime
  1057. * @param LPUARTx LPUART Instance
  1058. * @param Time Value between Min_Data=0 and Max_Data=31
  1059. * @retval None
  1060. */
  1061. __STATIC_INLINE void LL_LPUART_SetDEDeassertionTime(USART_TypeDef *LPUARTx, uint32_t Time)
  1062. {
  1063. MODIFY_REG(LPUARTx->CR1, USART_CR1_DEDT, Time << USART_CR1_DEDT_Pos);
  1064. }
  1065. /**
  1066. * @brief Return DEDT (Driver Enable De-Assertion Time)
  1067. * @rmtoll CR1 DEDT LL_LPUART_GetDEDeassertionTime
  1068. * @param LPUARTx LPUART Instance
  1069. * @retval Time value expressed on 5 bits ([4:0] bits) : c
  1070. */
  1071. __STATIC_INLINE uint32_t LL_LPUART_GetDEDeassertionTime(USART_TypeDef *LPUARTx)
  1072. {
  1073. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_DEDT) >> USART_CR1_DEDT_Pos);
  1074. }
  1075. /**
  1076. * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits).
  1077. * @rmtoll CR1 DEAT LL_LPUART_SetDEAssertionTime
  1078. * @param LPUARTx LPUART Instance
  1079. * @param Time Value between Min_Data=0 and Max_Data=31
  1080. * @retval None
  1081. */
  1082. __STATIC_INLINE void LL_LPUART_SetDEAssertionTime(USART_TypeDef *LPUARTx, uint32_t Time)
  1083. {
  1084. MODIFY_REG(LPUARTx->CR1, USART_CR1_DEAT, Time << USART_CR1_DEAT_Pos);
  1085. }
  1086. /**
  1087. * @brief Return DEAT (Driver Enable Assertion Time)
  1088. * @rmtoll CR1 DEAT LL_LPUART_GetDEAssertionTime
  1089. * @param LPUARTx LPUART Instance
  1090. * @retval Time value expressed on 5 bits ([4:0] bits) : Time Value between Min_Data=0 and Max_Data=31
  1091. */
  1092. __STATIC_INLINE uint32_t LL_LPUART_GetDEAssertionTime(USART_TypeDef *LPUARTx)
  1093. {
  1094. return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_DEAT) >> USART_CR1_DEAT_Pos);
  1095. }
  1096. /**
  1097. * @brief Enable Driver Enable (DE) Mode
  1098. * @rmtoll CR3 DEM LL_LPUART_EnableDEMode
  1099. * @param LPUARTx LPUART Instance
  1100. * @retval None
  1101. */
  1102. __STATIC_INLINE void LL_LPUART_EnableDEMode(USART_TypeDef *LPUARTx)
  1103. {
  1104. SET_BIT(LPUARTx->CR3, USART_CR3_DEM);
  1105. }
  1106. /**
  1107. * @brief Disable Driver Enable (DE) Mode
  1108. * @rmtoll CR3 DEM LL_LPUART_DisableDEMode
  1109. * @param LPUARTx LPUART Instance
  1110. * @retval None
  1111. */
  1112. __STATIC_INLINE void LL_LPUART_DisableDEMode(USART_TypeDef *LPUARTx)
  1113. {
  1114. CLEAR_BIT(LPUARTx->CR3, USART_CR3_DEM);
  1115. }
  1116. /**
  1117. * @brief Indicate if Driver Enable (DE) Mode is enabled
  1118. * @rmtoll CR3 DEM LL_LPUART_IsEnabledDEMode
  1119. * @param LPUARTx LPUART Instance
  1120. * @retval State of bit (1 or 0).
  1121. */
  1122. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDEMode(USART_TypeDef *LPUARTx)
  1123. {
  1124. return (READ_BIT(LPUARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM));
  1125. }
  1126. /**
  1127. * @brief Select Driver Enable Polarity
  1128. * @rmtoll CR3 DEP LL_LPUART_SetDESignalPolarity
  1129. * @param LPUARTx LPUART Instance
  1130. * @param Polarity This parameter can be one of the following values:
  1131. * @arg @ref LL_LPUART_DE_POLARITY_HIGH
  1132. * @arg @ref LL_LPUART_DE_POLARITY_LOW
  1133. * @retval None
  1134. */
  1135. __STATIC_INLINE void LL_LPUART_SetDESignalPolarity(USART_TypeDef *LPUARTx, uint32_t Polarity)
  1136. {
  1137. MODIFY_REG(LPUARTx->CR3, USART_CR3_DEP, Polarity);
  1138. }
  1139. /**
  1140. * @brief Return Driver Enable Polarity
  1141. * @rmtoll CR3 DEP LL_LPUART_GetDESignalPolarity
  1142. * @param LPUARTx LPUART Instance
  1143. * @retval Returned value can be one of the following values:
  1144. * @arg @ref LL_LPUART_DE_POLARITY_HIGH
  1145. * @arg @ref LL_LPUART_DE_POLARITY_LOW
  1146. */
  1147. __STATIC_INLINE uint32_t LL_LPUART_GetDESignalPolarity(USART_TypeDef *LPUARTx)
  1148. {
  1149. return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_DEP));
  1150. }
  1151. /**
  1152. * @}
  1153. */
  1154. /** @defgroup LPUART_LL_EF_FLAG_Management FLAG_Management
  1155. * @{
  1156. */
  1157. /**
  1158. * @brief Check if the LPUART Parity Error Flag is set or not
  1159. * @rmtoll ISR PE LL_LPUART_IsActiveFlag_PE
  1160. * @param LPUARTx LPUART Instance
  1161. * @retval State of bit (1 or 0).
  1162. */
  1163. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_PE(USART_TypeDef *LPUARTx)
  1164. {
  1165. return (READ_BIT(LPUARTx->ISR, USART_ISR_PE) == (USART_ISR_PE));
  1166. }
  1167. /**
  1168. * @brief Check if the LPUART Framing Error Flag is set or not
  1169. * @rmtoll ISR FE LL_LPUART_IsActiveFlag_FE
  1170. * @param LPUARTx LPUART Instance
  1171. * @retval State of bit (1 or 0).
  1172. */
  1173. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_FE(USART_TypeDef *LPUARTx)
  1174. {
  1175. return (READ_BIT(LPUARTx->ISR, USART_ISR_FE) == (USART_ISR_FE));
  1176. }
  1177. /**
  1178. * @brief Check if the LPUART Noise error detected Flag is set or not
  1179. * @rmtoll ISR NE LL_LPUART_IsActiveFlag_NE
  1180. * @param LPUARTx LPUART Instance
  1181. * @retval State of bit (1 or 0).
  1182. */
  1183. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_NE(USART_TypeDef *LPUARTx)
  1184. {
  1185. return (READ_BIT(LPUARTx->ISR, USART_ISR_NE) == (USART_ISR_NE));
  1186. }
  1187. /**
  1188. * @brief Check if the LPUART OverRun Error Flag is set or not
  1189. * @rmtoll ISR ORE LL_LPUART_IsActiveFlag_ORE
  1190. * @param LPUARTx LPUART Instance
  1191. * @retval State of bit (1 or 0).
  1192. */
  1193. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_ORE(USART_TypeDef *LPUARTx)
  1194. {
  1195. return (READ_BIT(LPUARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE));
  1196. }
  1197. /**
  1198. * @brief Check if the LPUART IDLE line detected Flag is set or not
  1199. * @rmtoll ISR IDLE LL_LPUART_IsActiveFlag_IDLE
  1200. * @param LPUARTx LPUART Instance
  1201. * @retval State of bit (1 or 0).
  1202. */
  1203. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_IDLE(USART_TypeDef *LPUARTx)
  1204. {
  1205. return (READ_BIT(LPUARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE));
  1206. }
  1207. /**
  1208. * @brief Check if the LPUART Read Data Register Not Empty Flag is set or not
  1209. * @rmtoll ISR RXNE LL_LPUART_IsActiveFlag_RXNE
  1210. * @param LPUARTx LPUART Instance
  1211. * @retval State of bit (1 or 0).
  1212. */
  1213. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXNE(USART_TypeDef *LPUARTx)
  1214. {
  1215. return (READ_BIT(LPUARTx->ISR, USART_ISR_RXNE) == (USART_ISR_RXNE));
  1216. }
  1217. /**
  1218. * @brief Check if the LPUART Transmission Complete Flag is set or not
  1219. * @rmtoll ISR TC LL_LPUART_IsActiveFlag_TC
  1220. * @param LPUARTx LPUART Instance
  1221. * @retval State of bit (1 or 0).
  1222. */
  1223. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TC(USART_TypeDef *LPUARTx)
  1224. {
  1225. return (READ_BIT(LPUARTx->ISR, USART_ISR_TC) == (USART_ISR_TC));
  1226. }
  1227. /**
  1228. * @brief Check if the LPUART Transmit Data Register Empty Flag is set or not
  1229. * @rmtoll ISR TXE LL_LPUART_IsActiveFlag_TXE
  1230. * @param LPUARTx LPUART Instance
  1231. * @retval State of bit (1 or 0).
  1232. */
  1233. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXE(USART_TypeDef *LPUARTx)
  1234. {
  1235. return (READ_BIT(LPUARTx->ISR, USART_ISR_TXE) == (USART_ISR_TXE));
  1236. }
  1237. /**
  1238. * @brief Check if the LPUART CTS interrupt Flag is set or not
  1239. * @rmtoll ISR CTSIF LL_LPUART_IsActiveFlag_nCTS
  1240. * @param LPUARTx LPUART Instance
  1241. * @retval State of bit (1 or 0).
  1242. */
  1243. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_nCTS(USART_TypeDef *LPUARTx)
  1244. {
  1245. return (READ_BIT(LPUARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF));
  1246. }
  1247. /**
  1248. * @brief Check if the LPUART CTS Flag is set or not
  1249. * @rmtoll ISR CTS LL_LPUART_IsActiveFlag_CTS
  1250. * @param LPUARTx LPUART Instance
  1251. * @retval State of bit (1 or 0).
  1252. */
  1253. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_CTS(USART_TypeDef *LPUARTx)
  1254. {
  1255. return (READ_BIT(LPUARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS));
  1256. }
  1257. /**
  1258. * @brief Check if the LPUART Busy Flag is set or not
  1259. * @rmtoll ISR BUSY LL_LPUART_IsActiveFlag_BUSY
  1260. * @param LPUARTx LPUART Instance
  1261. * @retval State of bit (1 or 0).
  1262. */
  1263. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_BUSY(USART_TypeDef *LPUARTx)
  1264. {
  1265. return (READ_BIT(LPUARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY));
  1266. }
  1267. /**
  1268. * @brief Check if the LPUART Character Match Flag is set or not
  1269. * @rmtoll ISR CMF LL_LPUART_IsActiveFlag_CM
  1270. * @param LPUARTx LPUART Instance
  1271. * @retval State of bit (1 or 0).
  1272. */
  1273. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_CM(USART_TypeDef *LPUARTx)
  1274. {
  1275. return (READ_BIT(LPUARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF));
  1276. }
  1277. /**
  1278. * @brief Check if the LPUART Send Break Flag is set or not
  1279. * @rmtoll ISR SBKF LL_LPUART_IsActiveFlag_SBK
  1280. * @param LPUARTx LPUART Instance
  1281. * @retval State of bit (1 or 0).
  1282. */
  1283. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_SBK(USART_TypeDef *LPUARTx)
  1284. {
  1285. return (READ_BIT(LPUARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF));
  1286. }
  1287. /**
  1288. * @brief Check if the LPUART Receive Wake Up from mute mode Flag is set or not
  1289. * @rmtoll ISR RWU LL_LPUART_IsActiveFlag_RWU
  1290. * @param LPUARTx LPUART Instance
  1291. * @retval State of bit (1 or 0).
  1292. */
  1293. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RWU(USART_TypeDef *LPUARTx)
  1294. {
  1295. return (READ_BIT(LPUARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU));
  1296. }
  1297. /**
  1298. * @brief Check if the LPUART Wake Up from stop mode Flag is set or not
  1299. * @rmtoll ISR WUF LL_LPUART_IsActiveFlag_WKUP
  1300. * @param LPUARTx LPUART Instance
  1301. * @retval State of bit (1 or 0).
  1302. */
  1303. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_WKUP(USART_TypeDef *LPUARTx)
  1304. {
  1305. return (READ_BIT(LPUARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF));
  1306. }
  1307. /**
  1308. * @brief Check if the LPUART Transmit Enable Acknowledge Flag is set or not
  1309. * @rmtoll ISR TEACK LL_LPUART_IsActiveFlag_TEACK
  1310. * @param LPUARTx LPUART Instance
  1311. * @retval State of bit (1 or 0).
  1312. */
  1313. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TEACK(USART_TypeDef *LPUARTx)
  1314. {
  1315. return (READ_BIT(LPUARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK));
  1316. }
  1317. /**
  1318. * @brief Check if the LPUART Receive Enable Acknowledge Flag is set or not
  1319. * @rmtoll ISR REACK LL_LPUART_IsActiveFlag_REACK
  1320. * @param LPUARTx LPUART Instance
  1321. * @retval State of bit (1 or 0).
  1322. */
  1323. __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_REACK(USART_TypeDef *LPUARTx)
  1324. {
  1325. return (READ_BIT(LPUARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK));
  1326. }
  1327. /**
  1328. * @brief Clear Parity Error Flag
  1329. * @rmtoll ICR PECF LL_LPUART_ClearFlag_PE
  1330. * @param LPUARTx LPUART Instance
  1331. * @retval None
  1332. */
  1333. __STATIC_INLINE void LL_LPUART_ClearFlag_PE(USART_TypeDef *LPUARTx)
  1334. {
  1335. WRITE_REG(LPUARTx->ICR, USART_ICR_PECF);
  1336. }
  1337. /**
  1338. * @brief Clear Framing Error Flag
  1339. * @rmtoll ICR FECF LL_LPUART_ClearFlag_FE
  1340. * @param LPUARTx LPUART Instance
  1341. * @retval None
  1342. */
  1343. __STATIC_INLINE void LL_LPUART_ClearFlag_FE(USART_TypeDef *LPUARTx)
  1344. {
  1345. WRITE_REG(LPUARTx->ICR, USART_ICR_FECF);
  1346. }
  1347. /**
  1348. * @brief Clear Noise detected Flag
  1349. * @rmtoll ICR NCF LL_LPUART_ClearFlag_NE
  1350. * @param LPUARTx LPUART Instance
  1351. * @retval None
  1352. */
  1353. __STATIC_INLINE void LL_LPUART_ClearFlag_NE(USART_TypeDef *LPUARTx)
  1354. {
  1355. WRITE_REG(LPUARTx->ICR, USART_ICR_NCF);
  1356. }
  1357. /**
  1358. * @brief Clear OverRun Error Flag
  1359. * @rmtoll ICR ORECF LL_LPUART_ClearFlag_ORE
  1360. * @param LPUARTx LPUART Instance
  1361. * @retval None
  1362. */
  1363. __STATIC_INLINE void LL_LPUART_ClearFlag_ORE(USART_TypeDef *LPUARTx)
  1364. {
  1365. WRITE_REG(LPUARTx->ICR, USART_ICR_ORECF);
  1366. }
  1367. /**
  1368. * @brief Clear IDLE line detected Flag
  1369. * @rmtoll ICR IDLECF LL_LPUART_ClearFlag_IDLE
  1370. * @param LPUARTx LPUART Instance
  1371. * @retval None
  1372. */
  1373. __STATIC_INLINE void LL_LPUART_ClearFlag_IDLE(USART_TypeDef *LPUARTx)
  1374. {
  1375. WRITE_REG(LPUARTx->ICR, USART_ICR_IDLECF);
  1376. }
  1377. /**
  1378. * @brief Clear Transmission Complete Flag
  1379. * @rmtoll ICR TCCF LL_LPUART_ClearFlag_TC
  1380. * @param LPUARTx LPUART Instance
  1381. * @retval None
  1382. */
  1383. __STATIC_INLINE void LL_LPUART_ClearFlag_TC(USART_TypeDef *LPUARTx)
  1384. {
  1385. WRITE_REG(LPUARTx->ICR, USART_ICR_TCCF);
  1386. }
  1387. /**
  1388. * @brief Clear CTS Interrupt Flag
  1389. * @rmtoll ICR CTSCF LL_LPUART_ClearFlag_nCTS
  1390. * @param LPUARTx LPUART Instance
  1391. * @retval None
  1392. */
  1393. __STATIC_INLINE void LL_LPUART_ClearFlag_nCTS(USART_TypeDef *LPUARTx)
  1394. {
  1395. WRITE_REG(LPUARTx->ICR, USART_ICR_CTSCF);
  1396. }
  1397. /**
  1398. * @brief Clear Character Match Flag
  1399. * @rmtoll ICR CMCF LL_LPUART_ClearFlag_CM
  1400. * @param LPUARTx LPUART Instance
  1401. * @retval None
  1402. */
  1403. __STATIC_INLINE void LL_LPUART_ClearFlag_CM(USART_TypeDef *LPUARTx)
  1404. {
  1405. WRITE_REG(LPUARTx->ICR, USART_ICR_CMCF);
  1406. }
  1407. /**
  1408. * @brief Clear Wake Up from stop mode Flag
  1409. * @rmtoll ICR WUCF LL_LPUART_ClearFlag_WKUP
  1410. * @param LPUARTx LPUART Instance
  1411. * @retval None
  1412. */
  1413. __STATIC_INLINE void LL_LPUART_ClearFlag_WKUP(USART_TypeDef *LPUARTx)
  1414. {
  1415. WRITE_REG(LPUARTx->ICR, USART_ICR_WUCF);
  1416. }
  1417. /**
  1418. * @}
  1419. */
  1420. /** @defgroup LPUART_LL_EF_IT_Management IT_Management
  1421. * @{
  1422. */
  1423. /**
  1424. * @brief Enable IDLE Interrupt
  1425. * @rmtoll CR1 IDLEIE LL_LPUART_EnableIT_IDLE
  1426. * @param LPUARTx LPUART Instance
  1427. * @retval None
  1428. */
  1429. __STATIC_INLINE void LL_LPUART_EnableIT_IDLE(USART_TypeDef *LPUARTx)
  1430. {
  1431. SET_BIT(LPUARTx->CR1, USART_CR1_IDLEIE);
  1432. }
  1433. /**
  1434. * @brief Enable RX Not Empty Interrupt
  1435. * @rmtoll CR1 RXNEIE LL_LPUART_EnableIT_RXNE
  1436. * @param LPUARTx LPUART Instance
  1437. * @retval None
  1438. */
  1439. __STATIC_INLINE void LL_LPUART_EnableIT_RXNE(USART_TypeDef *LPUARTx)
  1440. {
  1441. SET_BIT(LPUARTx->CR1, USART_CR1_RXNEIE);
  1442. }
  1443. /**
  1444. * @brief Enable Transmission Complete Interrupt
  1445. * @rmtoll CR1 TCIE LL_LPUART_EnableIT_TC
  1446. * @param LPUARTx LPUART Instance
  1447. * @retval None
  1448. */
  1449. __STATIC_INLINE void LL_LPUART_EnableIT_TC(USART_TypeDef *LPUARTx)
  1450. {
  1451. SET_BIT(LPUARTx->CR1, USART_CR1_TCIE);
  1452. }
  1453. /**
  1454. * @brief Enable TX Empty Interrupt
  1455. * @rmtoll CR1 TXEIE LL_LPUART_EnableIT_TXE
  1456. * @param LPUARTx LPUART Instance
  1457. * @retval None
  1458. */
  1459. __STATIC_INLINE void LL_LPUART_EnableIT_TXE(USART_TypeDef *LPUARTx)
  1460. {
  1461. SET_BIT(LPUARTx->CR1, USART_CR1_TXEIE);
  1462. }
  1463. /**
  1464. * @brief Enable Parity Error Interrupt
  1465. * @rmtoll CR1 PEIE LL_LPUART_EnableIT_PE
  1466. * @param LPUARTx LPUART Instance
  1467. * @retval None
  1468. */
  1469. __STATIC_INLINE void LL_LPUART_EnableIT_PE(USART_TypeDef *LPUARTx)
  1470. {
  1471. SET_BIT(LPUARTx->CR1, USART_CR1_PEIE);
  1472. }
  1473. /**
  1474. * @brief Enable Character Match Interrupt
  1475. * @rmtoll CR1 CMIE LL_LPUART_EnableIT_CM
  1476. * @param LPUARTx LPUART Instance
  1477. * @retval None
  1478. */
  1479. __STATIC_INLINE void LL_LPUART_EnableIT_CM(USART_TypeDef *LPUARTx)
  1480. {
  1481. SET_BIT(LPUARTx->CR1, USART_CR1_CMIE);
  1482. }
  1483. /**
  1484. * @brief Enable Error Interrupt
  1485. * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
  1486. * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register).
  1487. * - 0: Interrupt is inhibited
  1488. * - 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register.
  1489. * @rmtoll CR3 EIE LL_LPUART_EnableIT_ERROR
  1490. * @param LPUARTx LPUART Instance
  1491. * @retval None
  1492. */
  1493. __STATIC_INLINE void LL_LPUART_EnableIT_ERROR(USART_TypeDef *LPUARTx)
  1494. {
  1495. SET_BIT(LPUARTx->CR3, USART_CR3_EIE);
  1496. }
  1497. /**
  1498. * @brief Enable CTS Interrupt
  1499. * @rmtoll CR3 CTSIE LL_LPUART_EnableIT_CTS
  1500. * @param LPUARTx LPUART Instance
  1501. * @retval None
  1502. */
  1503. __STATIC_INLINE void LL_LPUART_EnableIT_CTS(USART_TypeDef *LPUARTx)
  1504. {
  1505. SET_BIT(LPUARTx->CR3, USART_CR3_CTSIE);
  1506. }
  1507. /**
  1508. * @brief Enable Wake Up from Stop Mode Interrupt
  1509. * @rmtoll CR3 WUFIE LL_LPUART_EnableIT_WKUP
  1510. * @param LPUARTx LPUART Instance
  1511. * @retval None
  1512. */
  1513. __STATIC_INLINE void LL_LPUART_EnableIT_WKUP(USART_TypeDef *LPUARTx)
  1514. {
  1515. SET_BIT(LPUARTx->CR3, USART_CR3_WUFIE);
  1516. }
  1517. /**
  1518. * @brief Disable IDLE Interrupt
  1519. * @rmtoll CR1 IDLEIE LL_LPUART_DisableIT_IDLE
  1520. * @param LPUARTx LPUART Instance
  1521. * @retval None
  1522. */
  1523. __STATIC_INLINE void LL_LPUART_DisableIT_IDLE(USART_TypeDef *LPUARTx)
  1524. {
  1525. CLEAR_BIT(LPUARTx->CR1, USART_CR1_IDLEIE);
  1526. }
  1527. /**
  1528. * @brief Disable RX Not Empty Interrupt
  1529. * @rmtoll CR1 RXNEIE LL_LPUART_DisableIT_RXNE
  1530. * @param LPUARTx LPUART Instance
  1531. * @retval None
  1532. */
  1533. __STATIC_INLINE void LL_LPUART_DisableIT_RXNE(USART_TypeDef *LPUARTx)
  1534. {
  1535. CLEAR_BIT(LPUARTx->CR1, USART_CR1_RXNEIE);
  1536. }
  1537. /**
  1538. * @brief Disable Transmission Complete Interrupt
  1539. * @rmtoll CR1 TCIE LL_LPUART_DisableIT_TC
  1540. * @param LPUARTx LPUART Instance
  1541. * @retval None
  1542. */
  1543. __STATIC_INLINE void LL_LPUART_DisableIT_TC(USART_TypeDef *LPUARTx)
  1544. {
  1545. CLEAR_BIT(LPUARTx->CR1, USART_CR1_TCIE);
  1546. }
  1547. /**
  1548. * @brief Disable TX Empty Interrupt
  1549. * @rmtoll CR1 TXEIE LL_LPUART_DisableIT_TXE
  1550. * @param LPUARTx LPUART Instance
  1551. * @retval None
  1552. */
  1553. __STATIC_INLINE void LL_LPUART_DisableIT_TXE(USART_TypeDef *LPUARTx)
  1554. {
  1555. CLEAR_BIT(LPUARTx->CR1, USART_CR1_TXEIE);
  1556. }
  1557. /**
  1558. * @brief Disable Parity Error Interrupt
  1559. * @rmtoll CR1 PEIE LL_LPUART_DisableIT_PE
  1560. * @param LPUARTx LPUART Instance
  1561. * @retval None
  1562. */
  1563. __STATIC_INLINE void LL_LPUART_DisableIT_PE(USART_TypeDef *LPUARTx)
  1564. {
  1565. CLEAR_BIT(LPUARTx->CR1, USART_CR1_PEIE);
  1566. }
  1567. /**
  1568. * @brief Disable Character Match Interrupt
  1569. * @rmtoll CR1 CMIE LL_LPUART_DisableIT_CM
  1570. * @param LPUARTx LPUART Instance
  1571. * @retval None
  1572. */
  1573. __STATIC_INLINE void LL_LPUART_DisableIT_CM(USART_TypeDef *LPUARTx)
  1574. {
  1575. CLEAR_BIT(LPUARTx->CR1, USART_CR1_CMIE);
  1576. }
  1577. /**
  1578. * @brief Disable Error Interrupt
  1579. * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
  1580. * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register).
  1581. * - 0: Interrupt is inhibited
  1582. * - 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register.
  1583. * @rmtoll CR3 EIE LL_LPUART_DisableIT_ERROR
  1584. * @param LPUARTx LPUART Instance
  1585. * @retval None
  1586. */
  1587. __STATIC_INLINE void LL_LPUART_DisableIT_ERROR(USART_TypeDef *LPUARTx)
  1588. {
  1589. CLEAR_BIT(LPUARTx->CR3, USART_CR3_EIE);
  1590. }
  1591. /**
  1592. * @brief Disable CTS Interrupt
  1593. * @rmtoll CR3 CTSIE LL_LPUART_DisableIT_CTS
  1594. * @param LPUARTx LPUART Instance
  1595. * @retval None
  1596. */
  1597. __STATIC_INLINE void LL_LPUART_DisableIT_CTS(USART_TypeDef *LPUARTx)
  1598. {
  1599. CLEAR_BIT(LPUARTx->CR3, USART_CR3_CTSIE);
  1600. }
  1601. /**
  1602. * @brief Disable Wake Up from Stop Mode Interrupt
  1603. * @rmtoll CR3 WUFIE LL_LPUART_DisableIT_WKUP
  1604. * @param LPUARTx LPUART Instance
  1605. * @retval None
  1606. */
  1607. __STATIC_INLINE void LL_LPUART_DisableIT_WKUP(USART_TypeDef *LPUARTx)
  1608. {
  1609. CLEAR_BIT(LPUARTx->CR3, USART_CR3_WUFIE);
  1610. }
  1611. /**
  1612. * @brief Check if the LPUART IDLE Interrupt source is enabled or disabled.
  1613. * @rmtoll CR1 IDLEIE LL_LPUART_IsEnabledIT_IDLE
  1614. * @param LPUARTx LPUART Instance
  1615. * @retval State of bit (1 or 0).
  1616. */
  1617. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_IDLE(USART_TypeDef *LPUARTx)
  1618. {
  1619. return (READ_BIT(LPUARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE));
  1620. }
  1621. /**
  1622. * @brief Check if the LPUART RX Not Empty Interrupt is enabled or disabled.
  1623. * @rmtoll CR1 RXNEIE LL_LPUART_IsEnabledIT_RXNE
  1624. * @param LPUARTx LPUART Instance
  1625. * @retval State of bit (1 or 0).
  1626. */
  1627. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXNE(USART_TypeDef *LPUARTx)
  1628. {
  1629. return (READ_BIT(LPUARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE));
  1630. }
  1631. /**
  1632. * @brief Check if the LPUART Transmission Complete Interrupt is enabled or disabled.
  1633. * @rmtoll CR1 TCIE LL_LPUART_IsEnabledIT_TC
  1634. * @param LPUARTx LPUART Instance
  1635. * @retval State of bit (1 or 0).
  1636. */
  1637. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TC(USART_TypeDef *LPUARTx)
  1638. {
  1639. return (READ_BIT(LPUARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE));
  1640. }
  1641. /**
  1642. * @brief Check if the LPUART TX Empty Interrupt is enabled or disabled.
  1643. * @rmtoll CR1 TXEIE LL_LPUART_IsEnabledIT_TXE
  1644. * @param LPUARTx LPUART Instance
  1645. * @retval State of bit (1 or 0).
  1646. */
  1647. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXE(USART_TypeDef *LPUARTx)
  1648. {
  1649. return (READ_BIT(LPUARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE));
  1650. }
  1651. /**
  1652. * @brief Check if the LPUART Parity Error Interrupt is enabled or disabled.
  1653. * @rmtoll CR1 PEIE LL_LPUART_IsEnabledIT_PE
  1654. * @param LPUARTx LPUART Instance
  1655. * @retval State of bit (1 or 0).
  1656. */
  1657. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_PE(USART_TypeDef *LPUARTx)
  1658. {
  1659. return (READ_BIT(LPUARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE));
  1660. }
  1661. /**
  1662. * @brief Check if the LPUART Character Match Interrupt is enabled or disabled.
  1663. * @rmtoll CR1 CMIE LL_LPUART_IsEnabledIT_CM
  1664. * @param LPUARTx LPUART Instance
  1665. * @retval State of bit (1 or 0).
  1666. */
  1667. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_CM(USART_TypeDef *LPUARTx)
  1668. {
  1669. return (READ_BIT(LPUARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE));
  1670. }
  1671. /**
  1672. * @brief Check if the LPUART Error Interrupt is enabled or disabled.
  1673. * @rmtoll CR3 EIE LL_LPUART_IsEnabledIT_ERROR
  1674. * @param LPUARTx LPUART Instance
  1675. * @retval State of bit (1 or 0).
  1676. */
  1677. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_ERROR(USART_TypeDef *LPUARTx)
  1678. {
  1679. return (READ_BIT(LPUARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE));
  1680. }
  1681. /**
  1682. * @brief Check if the LPUART CTS Interrupt is enabled or disabled.
  1683. * @rmtoll CR3 CTSIE LL_LPUART_IsEnabledIT_CTS
  1684. * @param LPUARTx LPUART Instance
  1685. * @retval State of bit (1 or 0).
  1686. */
  1687. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_CTS(USART_TypeDef *LPUARTx)
  1688. {
  1689. return (READ_BIT(LPUARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE));
  1690. }
  1691. /**
  1692. * @brief Check if the LPUART Wake Up from Stop Mode Interrupt is enabled or disabled.
  1693. * @rmtoll CR3 WUFIE LL_LPUART_IsEnabledIT_WKUP
  1694. * @param LPUARTx LPUART Instance
  1695. * @retval State of bit (1 or 0).
  1696. */
  1697. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_WKUP(USART_TypeDef *LPUARTx)
  1698. {
  1699. return (READ_BIT(LPUARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE));
  1700. }
  1701. /**
  1702. * @}
  1703. */
  1704. /** @defgroup LPUART_LL_EF_DMA_Management DMA_Management
  1705. * @{
  1706. */
  1707. /**
  1708. * @brief Enable DMA Mode for reception
  1709. * @rmtoll CR3 DMAR LL_LPUART_EnableDMAReq_RX
  1710. * @param LPUARTx LPUART Instance
  1711. * @retval None
  1712. */
  1713. __STATIC_INLINE void LL_LPUART_EnableDMAReq_RX(USART_TypeDef *LPUARTx)
  1714. {
  1715. SET_BIT(LPUARTx->CR3, USART_CR3_DMAR);
  1716. }
  1717. /**
  1718. * @brief Disable DMA Mode for reception
  1719. * @rmtoll CR3 DMAR LL_LPUART_DisableDMAReq_RX
  1720. * @param LPUARTx LPUART Instance
  1721. * @retval None
  1722. */
  1723. __STATIC_INLINE void LL_LPUART_DisableDMAReq_RX(USART_TypeDef *LPUARTx)
  1724. {
  1725. CLEAR_BIT(LPUARTx->CR3, USART_CR3_DMAR);
  1726. }
  1727. /**
  1728. * @brief Check if DMA Mode is enabled for reception
  1729. * @rmtoll CR3 DMAR LL_LPUART_IsEnabledDMAReq_RX
  1730. * @param LPUARTx LPUART Instance
  1731. * @retval State of bit (1 or 0).
  1732. */
  1733. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMAReq_RX(USART_TypeDef *LPUARTx)
  1734. {
  1735. return (READ_BIT(LPUARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR));
  1736. }
  1737. /**
  1738. * @brief Enable DMA Mode for transmission
  1739. * @rmtoll CR3 DMAT LL_LPUART_EnableDMAReq_TX
  1740. * @param LPUARTx LPUART Instance
  1741. * @retval None
  1742. */
  1743. __STATIC_INLINE void LL_LPUART_EnableDMAReq_TX(USART_TypeDef *LPUARTx)
  1744. {
  1745. SET_BIT(LPUARTx->CR3, USART_CR3_DMAT);
  1746. }
  1747. /**
  1748. * @brief Disable DMA Mode for transmission
  1749. * @rmtoll CR3 DMAT LL_LPUART_DisableDMAReq_TX
  1750. * @param LPUARTx LPUART Instance
  1751. * @retval None
  1752. */
  1753. __STATIC_INLINE void LL_LPUART_DisableDMAReq_TX(USART_TypeDef *LPUARTx)
  1754. {
  1755. CLEAR_BIT(LPUARTx->CR3, USART_CR3_DMAT);
  1756. }
  1757. /**
  1758. * @brief Check if DMA Mode is enabled for transmission
  1759. * @rmtoll CR3 DMAT LL_LPUART_IsEnabledDMAReq_TX
  1760. * @param LPUARTx LPUART Instance
  1761. * @retval State of bit (1 or 0).
  1762. */
  1763. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMAReq_TX(USART_TypeDef *LPUARTx)
  1764. {
  1765. return (READ_BIT(LPUARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT));
  1766. }
  1767. /**
  1768. * @brief Enable DMA Disabling on Reception Error
  1769. * @rmtoll CR3 DDRE LL_LPUART_EnableDMADeactOnRxErr
  1770. * @param LPUARTx LPUART Instance
  1771. * @retval None
  1772. */
  1773. __STATIC_INLINE void LL_LPUART_EnableDMADeactOnRxErr(USART_TypeDef *LPUARTx)
  1774. {
  1775. SET_BIT(LPUARTx->CR3, USART_CR3_DDRE);
  1776. }
  1777. /**
  1778. * @brief Disable DMA Disabling on Reception Error
  1779. * @rmtoll CR3 DDRE LL_LPUART_DisableDMADeactOnRxErr
  1780. * @param LPUARTx LPUART Instance
  1781. * @retval None
  1782. */
  1783. __STATIC_INLINE void LL_LPUART_DisableDMADeactOnRxErr(USART_TypeDef *LPUARTx)
  1784. {
  1785. CLEAR_BIT(LPUARTx->CR3, USART_CR3_DDRE);
  1786. }
  1787. /**
  1788. * @brief Indicate if DMA Disabling on Reception Error is disabled
  1789. * @rmtoll CR3 DDRE LL_LPUART_IsEnabledDMADeactOnRxErr
  1790. * @param LPUARTx LPUART Instance
  1791. * @retval State of bit (1 or 0).
  1792. */
  1793. __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMADeactOnRxErr(USART_TypeDef *LPUARTx)
  1794. {
  1795. return (READ_BIT(LPUARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE));
  1796. }
  1797. /**
  1798. * @brief Get the LPUART data register address used for DMA transfer
  1799. * @rmtoll RDR RDR LL_LPUART_DMA_GetRegAddr\n
  1800. * @rmtoll TDR TDR LL_LPUART_DMA_GetRegAddr
  1801. * @param LPUARTx LPUART Instance
  1802. * @param Direction This parameter can be one of the following values:
  1803. * @arg @ref LL_LPUART_DMA_REG_DATA_TRANSMIT
  1804. * @arg @ref LL_LPUART_DMA_REG_DATA_RECEIVE
  1805. * @retval Address of data register
  1806. */
  1807. __STATIC_INLINE uint32_t LL_LPUART_DMA_GetRegAddr(USART_TypeDef *LPUARTx, uint32_t Direction)
  1808. {
  1809. register uint32_t data_reg_addr = 0U;
  1810. if (Direction == LL_LPUART_DMA_REG_DATA_TRANSMIT)
  1811. {
  1812. /* return address of TDR register */
  1813. data_reg_addr = (uint32_t) &(LPUARTx->TDR);
  1814. }
  1815. else
  1816. {
  1817. /* return address of RDR register */
  1818. data_reg_addr = (uint32_t) &(LPUARTx->RDR);
  1819. }
  1820. return data_reg_addr;
  1821. }
  1822. /**
  1823. * @}
  1824. */
  1825. /** @defgroup LPUART_LL_EF_Data_Management Data_Management
  1826. * @{
  1827. */
  1828. /**
  1829. * @brief Read Receiver Data register (Receive Data value, 8 bits)
  1830. * @rmtoll RDR RDR LL_LPUART_ReceiveData8
  1831. * @param LPUARTx LPUART Instance
  1832. * @retval Time Value between Min_Data=0x00 and Max_Data=0xFF
  1833. */
  1834. __STATIC_INLINE uint8_t LL_LPUART_ReceiveData8(USART_TypeDef *LPUARTx)
  1835. {
  1836. return (uint8_t)(READ_BIT(LPUARTx->RDR, USART_RDR_RDR));
  1837. }
  1838. /**
  1839. * @brief Read Receiver Data register (Receive Data value, 9 bits)
  1840. * @rmtoll RDR RDR LL_LPUART_ReceiveData9
  1841. * @param LPUARTx LPUART Instance
  1842. * @retval Time Value between Min_Data=0x00 and Max_Data=0x1FF
  1843. */
  1844. __STATIC_INLINE uint16_t LL_LPUART_ReceiveData9(USART_TypeDef *LPUARTx)
  1845. {
  1846. return (uint16_t)(READ_BIT(LPUARTx->RDR, USART_RDR_RDR));
  1847. }
  1848. /**
  1849. * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits)
  1850. * @rmtoll TDR TDR LL_LPUART_TransmitData8
  1851. * @param LPUARTx LPUART Instance
  1852. * @param Value between Min_Data=0x00 and Max_Data=0xFF
  1853. * @retval None
  1854. */
  1855. __STATIC_INLINE void LL_LPUART_TransmitData8(USART_TypeDef *LPUARTx, uint8_t Value)
  1856. {
  1857. LPUARTx->TDR = Value;
  1858. }
  1859. /**
  1860. * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits)
  1861. * @rmtoll TDR TDR LL_LPUART_TransmitData9
  1862. * @param LPUARTx LPUART Instance
  1863. * @param Value between Min_Data=0x00 and Max_Data=0x1FF
  1864. * @retval None
  1865. */
  1866. __STATIC_INLINE void LL_LPUART_TransmitData9(USART_TypeDef *LPUARTx, uint16_t Value)
  1867. {
  1868. LPUARTx->TDR = Value & 0x1FFU;
  1869. }
  1870. /**
  1871. * @}
  1872. */
  1873. /** @defgroup LPUART_LL_EF_Execution Execution
  1874. * @{
  1875. */
  1876. /**
  1877. * @brief Request Break sending
  1878. * @rmtoll RQR SBKRQ LL_LPUART_RequestBreakSending
  1879. * @param LPUARTx LPUART Instance
  1880. * @retval None
  1881. */
  1882. __STATIC_INLINE void LL_LPUART_RequestBreakSending(USART_TypeDef *LPUARTx)
  1883. {
  1884. SET_BIT(LPUARTx->RQR, USART_RQR_SBKRQ);
  1885. }
  1886. /**
  1887. * @brief Put LPUART in mute mode and set the RWU flag
  1888. * @rmtoll RQR MMRQ LL_LPUART_RequestEnterMuteMode
  1889. * @param LPUARTx LPUART Instance
  1890. * @retval None
  1891. */
  1892. __STATIC_INLINE void LL_LPUART_RequestEnterMuteMode(USART_TypeDef *LPUARTx)
  1893. {
  1894. SET_BIT(LPUARTx->RQR, USART_RQR_MMRQ);
  1895. }
  1896. /**
  1897. * @brief Request a Receive Data flush
  1898. * @rmtoll RQR RXFRQ LL_LPUART_RequestRxDataFlush
  1899. * @param LPUARTx LPUART Instance
  1900. * @retval None
  1901. */
  1902. __STATIC_INLINE void LL_LPUART_RequestRxDataFlush(USART_TypeDef *LPUARTx)
  1903. {
  1904. SET_BIT(LPUARTx->RQR, USART_RQR_RXFRQ);
  1905. }
  1906. /**
  1907. * @}
  1908. */
  1909. #if defined(USE_FULL_LL_DRIVER)
  1910. /** @defgroup LPUART_LL_EF_Init Initialization and de-initialization functions
  1911. * @{
  1912. */
  1913. ErrorStatus LL_LPUART_DeInit(USART_TypeDef *LPUARTx);
  1914. ErrorStatus LL_LPUART_Init(USART_TypeDef *LPUARTx, LL_LPUART_InitTypeDef *LPUART_InitStruct);
  1915. void LL_LPUART_StructInit(LL_LPUART_InitTypeDef *LPUART_InitStruct);
  1916. /**
  1917. * @}
  1918. */
  1919. #endif /* USE_FULL_LL_DRIVER */
  1920. /**
  1921. * @}
  1922. */
  1923. /**
  1924. * @}
  1925. */
  1926. #endif /* LPUART1 */
  1927. /**
  1928. * @}
  1929. */
  1930. #ifdef __cplusplus
  1931. }
  1932. #endif
  1933. #endif /* __STM32L4xx_LL_LPUART_H */
  1934. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/