STM32H735xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32h7xx_ll_lpuart.h 00004 * @author MCD Application Team 00005 * @brief Header file of LPUART LL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * Copyright (c) 2017 STMicroelectronics. 00010 * All rights reserved. 00011 * 00012 * This software is licensed under terms that can be found in the LICENSE file 00013 * in the root directory of this software component. 00014 * If no LICENSE file comes with this software, it is provided AS-IS. 00015 * 00016 ****************************************************************************** 00017 */ 00018 00019 /* Define to prevent recursive inclusion -------------------------------------*/ 00020 #ifndef STM32H7xx_LL_LPUART_H 00021 #define STM32H7xx_LL_LPUART_H 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /* Includes ------------------------------------------------------------------*/ 00028 #include "stm32h7xx.h" 00029 00030 /** @addtogroup STM32H7xx_LL_Driver 00031 * @{ 00032 */ 00033 00034 #if defined (LPUART1) 00035 00036 /** @defgroup LPUART_LL LPUART 00037 * @{ 00038 */ 00039 00040 /* Private types -------------------------------------------------------------*/ 00041 /* Private variables ---------------------------------------------------------*/ 00042 /** @defgroup LPUART_LL_Private_Variables LPUART Private Variables 00043 * @{ 00044 */ 00045 /* Array used to get the LPUART prescaler division decimal values versus @ref LPUART_LL_EC_PRESCALER values */ 00046 static const uint16_t LPUART_PRESCALER_TAB[] = 00047 { 00048 (uint16_t)1, 00049 (uint16_t)2, 00050 (uint16_t)4, 00051 (uint16_t)6, 00052 (uint16_t)8, 00053 (uint16_t)10, 00054 (uint16_t)12, 00055 (uint16_t)16, 00056 (uint16_t)32, 00057 (uint16_t)64, 00058 (uint16_t)128, 00059 (uint16_t)256 00060 }; 00061 /** 00062 * @} 00063 */ 00064 00065 /* Private constants ---------------------------------------------------------*/ 00066 /** @defgroup LPUART_LL_Private_Constants LPUART Private Constants 00067 * @{ 00068 */ 00069 /* Defines used in Baud Rate related macros and corresponding register setting computation */ 00070 #define LPUART_LPUARTDIV_FREQ_MUL 256U 00071 #define LPUART_BRR_MASK 0x000FFFFFU 00072 #define LPUART_BRR_MIN_VALUE 0x00000300U 00073 /** 00074 * @} 00075 */ 00076 00077 00078 /* Private macros ------------------------------------------------------------*/ 00079 #if defined(USE_FULL_LL_DRIVER) 00080 /** @defgroup LPUART_LL_Private_Macros LPUART Private Macros 00081 * @{ 00082 */ 00083 /** 00084 * @} 00085 */ 00086 #endif /*USE_FULL_LL_DRIVER*/ 00087 00088 /* Exported types ------------------------------------------------------------*/ 00089 #if defined(USE_FULL_LL_DRIVER) 00090 /** @defgroup LPUART_LL_ES_INIT LPUART Exported Init structures 00091 * @{ 00092 */ 00093 00094 /** 00095 * @brief LL LPUART Init Structure definition 00096 */ 00097 typedef struct 00098 { 00099 uint32_t PrescalerValue; /*!< Specifies the Prescaler to compute the communication baud rate. 00100 This parameter can be a value of @ref LPUART_LL_EC_PRESCALER. 00101 00102 This feature can be modified afterwards using unitary 00103 function @ref LL_LPUART_SetPrescaler().*/ 00104 00105 uint32_t BaudRate; /*!< This field defines expected LPUART communication baud rate. 00106 00107 This feature can be modified afterwards using unitary 00108 function @ref LL_LPUART_SetBaudRate().*/ 00109 00110 uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame. 00111 This parameter can be a value of @ref LPUART_LL_EC_DATAWIDTH. 00112 00113 This feature can be modified afterwards using unitary 00114 function @ref LL_LPUART_SetDataWidth().*/ 00115 00116 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. 00117 This parameter can be a value of @ref LPUART_LL_EC_STOPBITS. 00118 00119 This feature can be modified afterwards using unitary 00120 function @ref LL_LPUART_SetStopBitsLength().*/ 00121 00122 uint32_t Parity; /*!< Specifies the parity mode. 00123 This parameter can be a value of @ref LPUART_LL_EC_PARITY. 00124 00125 This feature can be modified afterwards using unitary 00126 function @ref LL_LPUART_SetParity().*/ 00127 00128 uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled. 00129 This parameter can be a value of @ref LPUART_LL_EC_DIRECTION. 00130 00131 This feature can be modified afterwards using unitary 00132 function @ref LL_LPUART_SetTransferDirection().*/ 00133 00134 uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled. 00135 This parameter can be a value of @ref LPUART_LL_EC_HWCONTROL. 00136 00137 This feature can be modified afterwards using unitary 00138 function @ref LL_LPUART_SetHWFlowCtrl().*/ 00139 00140 } LL_LPUART_InitTypeDef; 00141 00142 /** 00143 * @} 00144 */ 00145 #endif /* USE_FULL_LL_DRIVER */ 00146 00147 /* Exported constants --------------------------------------------------------*/ 00148 /** @defgroup LPUART_LL_Exported_Constants LPUART Exported Constants 00149 * @{ 00150 */ 00151 00152 /** @defgroup LPUART_LL_EC_CLEAR_FLAG Clear Flags Defines 00153 * @brief Flags defines which can be used with LL_LPUART_WriteReg function 00154 * @{ 00155 */ 00156 #define LL_LPUART_ICR_PECF USART_ICR_PECF /*!< Parity error clear flag */ 00157 #define LL_LPUART_ICR_FECF USART_ICR_FECF /*!< Framing error clear flag */ 00158 #define LL_LPUART_ICR_NCF USART_ICR_NECF /*!< Noise error detected clear flag */ 00159 #define LL_LPUART_ICR_ORECF USART_ICR_ORECF /*!< Overrun error clear flag */ 00160 #define LL_LPUART_ICR_IDLECF USART_ICR_IDLECF /*!< Idle line detected clear flag */ 00161 #define LL_LPUART_ICR_TCCF USART_ICR_TCCF /*!< Transmission complete clear flag */ 00162 #define LL_LPUART_ICR_CTSCF USART_ICR_CTSCF /*!< CTS clear flag */ 00163 #define LL_LPUART_ICR_CMCF USART_ICR_CMCF /*!< Character match clear flag */ 00164 #define LL_LPUART_ICR_WUCF USART_ICR_WUCF /*!< Wakeup from Stop mode clear flag */ 00165 /** 00166 * @} 00167 */ 00168 00169 /** @defgroup LPUART_LL_EC_GET_FLAG Get Flags Defines 00170 * @brief Flags defines which can be used with LL_LPUART_ReadReg function 00171 * @{ 00172 */ 00173 #define LL_LPUART_ISR_PE USART_ISR_PE /*!< Parity error flag */ 00174 #define LL_LPUART_ISR_FE USART_ISR_FE /*!< Framing error flag */ 00175 #define LL_LPUART_ISR_NE USART_ISR_NE /*!< Noise detected flag */ 00176 #define LL_LPUART_ISR_ORE USART_ISR_ORE /*!< Overrun error flag */ 00177 #define LL_LPUART_ISR_IDLE USART_ISR_IDLE /*!< Idle line detected flag */ 00178 #define LL_LPUART_ISR_RXNE_RXFNE USART_ISR_RXNE_RXFNE /*!< Read data register or RX FIFO not empty flag */ 00179 #define LL_LPUART_ISR_TC USART_ISR_TC /*!< Transmission complete flag */ 00180 #define LL_LPUART_ISR_TXE_TXFNF USART_ISR_TXE_TXFNF /*!< Transmit data register empty or TX FIFO Not Full flag*/ 00181 #define LL_LPUART_ISR_CTSIF USART_ISR_CTSIF /*!< CTS interrupt flag */ 00182 #define LL_LPUART_ISR_CTS USART_ISR_CTS /*!< CTS flag */ 00183 #define LL_LPUART_ISR_BUSY USART_ISR_BUSY /*!< Busy flag */ 00184 #define LL_LPUART_ISR_CMF USART_ISR_CMF /*!< Character match flag */ 00185 #define LL_LPUART_ISR_SBKF USART_ISR_SBKF /*!< Send break flag */ 00186 #define LL_LPUART_ISR_RWU USART_ISR_RWU /*!< Receiver wakeup from Mute mode flag */ 00187 #define LL_LPUART_ISR_WUF USART_ISR_WUF /*!< Wakeup from Stop mode flag */ 00188 #define LL_LPUART_ISR_TEACK USART_ISR_TEACK /*!< Transmit enable acknowledge flag */ 00189 #define LL_LPUART_ISR_REACK USART_ISR_REACK /*!< Receive enable acknowledge flag */ 00190 #define LL_LPUART_ISR_TXFE USART_ISR_TXFE /*!< TX FIFO empty flag */ 00191 #define LL_LPUART_ISR_RXFF USART_ISR_RXFF /*!< RX FIFO full flag */ 00192 #define LL_LPUART_ISR_RXFT USART_ISR_RXFT /*!< RX FIFO threshold flag */ 00193 #define LL_LPUART_ISR_TXFT USART_ISR_TXFT /*!< TX FIFO threshold flag */ 00194 /** 00195 * @} 00196 */ 00197 00198 /** @defgroup LPUART_LL_EC_IT IT Defines 00199 * @brief IT defines which can be used with LL_LPUART_ReadReg and LL_LPUART_WriteReg functions 00200 * @{ 00201 */ 00202 #define LL_LPUART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */ 00203 #define LL_LPUART_CR1_RXNEIE_RXFNEIE USART_CR1_RXNEIE_RXFNEIE /*!< Read data register and RXFIFO not empty 00204 interrupt enable */ 00205 #define LL_LPUART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */ 00206 #define LL_LPUART_CR1_TXEIE_TXFNFIE USART_CR1_TXEIE_TXFNFIE /*!< Transmit data register empty and TX FIFO 00207 not full interrupt enable */ 00208 #define LL_LPUART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */ 00209 #define LL_LPUART_CR1_CMIE USART_CR1_CMIE /*!< Character match interrupt enable */ 00210 #define LL_LPUART_CR1_TXFEIE USART_CR1_TXFEIE /*!< TX FIFO empty interrupt enable */ 00211 #define LL_LPUART_CR1_RXFFIE USART_CR1_RXFFIE /*!< RX FIFO full interrupt enable */ 00212 #define LL_LPUART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */ 00213 #define LL_LPUART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */ 00214 #define LL_LPUART_CR3_WUFIE USART_CR3_WUFIE /*!< Wakeup from Stop mode interrupt enable */ 00215 #define LL_LPUART_CR3_TXFTIE USART_CR3_TXFTIE /*!< TX FIFO threshold interrupt enable */ 00216 #define LL_LPUART_CR3_RXFTIE USART_CR3_RXFTIE /*!< RX FIFO threshold interrupt enable */ 00217 /** 00218 * @} 00219 */ 00220 00221 /** @defgroup LPUART_LL_EC_FIFOTHRESHOLD FIFO Threshold 00222 * @{ 00223 */ 00224 #define LL_LPUART_FIFOTHRESHOLD_1_8 0x00000000U /*!< FIFO reaches 1/8 of its depth */ 00225 #define LL_LPUART_FIFOTHRESHOLD_1_4 0x00000001U /*!< FIFO reaches 1/4 of its depth */ 00226 #define LL_LPUART_FIFOTHRESHOLD_1_2 0x00000002U /*!< FIFO reaches 1/2 of its depth */ 00227 #define LL_LPUART_FIFOTHRESHOLD_3_4 0x00000003U /*!< FIFO reaches 3/4 of its depth */ 00228 #define LL_LPUART_FIFOTHRESHOLD_7_8 0x00000004U /*!< FIFO reaches 7/8 of its depth */ 00229 #define LL_LPUART_FIFOTHRESHOLD_8_8 0x00000005U /*!< FIFO becomes empty for TX and full for RX */ 00230 /** 00231 * @} 00232 */ 00233 00234 /** @defgroup LPUART_LL_EC_DIRECTION Direction 00235 * @{ 00236 */ 00237 #define LL_LPUART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */ 00238 #define LL_LPUART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */ 00239 #define LL_LPUART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */ 00240 #define LL_LPUART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */ 00241 /** 00242 * @} 00243 */ 00244 00245 /** @defgroup LPUART_LL_EC_PARITY Parity Control 00246 * @{ 00247 */ 00248 #define LL_LPUART_PARITY_NONE 0x00000000U /*!< Parity control disabled */ 00249 #define LL_LPUART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */ 00250 #define LL_LPUART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */ 00251 /** 00252 * @} 00253 */ 00254 00255 /** @defgroup LPUART_LL_EC_WAKEUP Wakeup 00256 * @{ 00257 */ 00258 #define LL_LPUART_WAKEUP_IDLELINE 0x00000000U /*!< LPUART wake up from Mute mode on Idle Line */ 00259 #define LL_LPUART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< LPUART wake up from Mute mode on Address Mark */ 00260 /** 00261 * @} 00262 */ 00263 00264 /** @defgroup LPUART_LL_EC_DATAWIDTH Datawidth 00265 * @{ 00266 */ 00267 #define LL_LPUART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */ 00268 #define LL_LPUART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */ 00269 #define LL_LPUART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */ 00270 /** 00271 * @} 00272 */ 00273 00274 /** @defgroup LPUART_LL_EC_PRESCALER Clock Source Prescaler 00275 * @{ 00276 */ 00277 #define LL_LPUART_PRESCALER_DIV1 0x00000000U /*!< Input clock not divided */ 00278 #define LL_LPUART_PRESCALER_DIV2 (USART_PRESC_PRESCALER_0) /*!< Input clock divided by 2 */ 00279 #define LL_LPUART_PRESCALER_DIV4 (USART_PRESC_PRESCALER_1) /*!< Input clock divided by 4 */ 00280 #define LL_LPUART_PRESCALER_DIV6 (USART_PRESC_PRESCALER_1 |\ 00281 USART_PRESC_PRESCALER_0) /*!< Input clock divided by 6 */ 00282 #define LL_LPUART_PRESCALER_DIV8 (USART_PRESC_PRESCALER_2) /*!< Input clock divided by 8 */ 00283 #define LL_LPUART_PRESCALER_DIV10 (USART_PRESC_PRESCALER_2 |\ 00284 USART_PRESC_PRESCALER_0) /*!< Input clock divided by 10 */ 00285 #define LL_LPUART_PRESCALER_DIV12 (USART_PRESC_PRESCALER_2 |\ 00286 USART_PRESC_PRESCALER_1) /*!< Input clock divided by 12 */ 00287 #define LL_LPUART_PRESCALER_DIV16 (USART_PRESC_PRESCALER_2 |\ 00288 USART_PRESC_PRESCALER_1 |\ 00289 USART_PRESC_PRESCALER_0) /*!< Input clock divided by 16 */ 00290 #define LL_LPUART_PRESCALER_DIV32 (USART_PRESC_PRESCALER_3) /*!< Input clock divided by 32 */ 00291 #define LL_LPUART_PRESCALER_DIV64 (USART_PRESC_PRESCALER_3 |\ 00292 USART_PRESC_PRESCALER_0) /*!< Input clock divided by 64 */ 00293 #define LL_LPUART_PRESCALER_DIV128 (USART_PRESC_PRESCALER_3 |\ 00294 USART_PRESC_PRESCALER_1) /*!< Input clock divided by 128 */ 00295 #define LL_LPUART_PRESCALER_DIV256 (USART_PRESC_PRESCALER_3 |\ 00296 USART_PRESC_PRESCALER_1 |\ 00297 USART_PRESC_PRESCALER_0) /*!< Input clock divided by 256 */ 00298 /** 00299 * @} 00300 */ 00301 00302 /** @defgroup LPUART_LL_EC_STOPBITS Stop Bits 00303 * @{ 00304 */ 00305 #define LL_LPUART_STOPBITS_1 0x00000000U /*!< 1 stop bit */ 00306 #define LL_LPUART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */ 00307 /** 00308 * @} 00309 */ 00310 00311 /** @defgroup LPUART_LL_EC_TXRX TX RX Pins Swap 00312 * @{ 00313 */ 00314 #define LL_LPUART_TXRX_STANDARD 0x00000000U /*!< TX/RX pins are used as defined in standard pinout */ 00315 #define LL_LPUART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */ 00316 /** 00317 * @} 00318 */ 00319 00320 /** @defgroup LPUART_LL_EC_RXPIN_LEVEL RX Pin Active Level Inversion 00321 * @{ 00322 */ 00323 #define LL_LPUART_RXPIN_LEVEL_STANDARD 0x00000000U /*!< RX pin signal works using the standard logic levels */ 00324 #define LL_LPUART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */ 00325 /** 00326 * @} 00327 */ 00328 00329 /** @defgroup LPUART_LL_EC_TXPIN_LEVEL TX Pin Active Level Inversion 00330 * @{ 00331 */ 00332 #define LL_LPUART_TXPIN_LEVEL_STANDARD 0x00000000U /*!< TX pin signal works using the standard logic levels */ 00333 #define LL_LPUART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */ 00334 /** 00335 * @} 00336 */ 00337 00338 /** @defgroup LPUART_LL_EC_BINARY_LOGIC Binary Data Inversion 00339 * @{ 00340 */ 00341 #define LL_LPUART_BINARY_LOGIC_POSITIVE 0x00000000U /*!< Logical data from the data register are send/received 00342 in positive/direct logic. (1=H, 0=L) */ 00343 #define LL_LPUART_BINARY_LOGIC_NEGATIVE USART_CR2_DATAINV /*!< Logical data from the data register are send/received 00344 in negative/inverse logic. (1=L, 0=H). 00345 The parity bit is also inverted. */ 00346 /** 00347 * @} 00348 */ 00349 00350 /** @defgroup LPUART_LL_EC_BITORDER Bit Order 00351 * @{ 00352 */ 00353 #define LL_LPUART_BITORDER_LSBFIRST 0x00000000U /*!< data is transmitted/received with data bit 0 first, 00354 following the start bit */ 00355 #define LL_LPUART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first, 00356 following the start bit */ 00357 /** 00358 * @} 00359 */ 00360 00361 /** @defgroup LPUART_LL_EC_ADDRESS_DETECT Address Length Detection 00362 * @{ 00363 */ 00364 #define LL_LPUART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit address detection method selected */ 00365 #define LL_LPUART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */ 00366 /** 00367 * @} 00368 */ 00369 00370 /** @defgroup LPUART_LL_EC_HWCONTROL Hardware Control 00371 * @{ 00372 */ 00373 #define LL_LPUART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */ 00374 #define LL_LPUART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested 00375 when there is space in the receive buffer */ 00376 #define LL_LPUART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted 00377 when the nCTS input is asserted (tied to 0)*/ 00378 #define LL_LPUART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */ 00379 /** 00380 * @} 00381 */ 00382 00383 /** @defgroup LPUART_LL_EC_WAKEUP_ON Wakeup Activation 00384 * @{ 00385 */ 00386 #define LL_LPUART_WAKEUP_ON_ADDRESS 0x00000000U /*!< Wake up active on address match */ 00387 #define LL_LPUART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wake up active on Start bit detection */ 00388 #define LL_LPUART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wake up active on RXNE */ 00389 /** 00390 * @} 00391 */ 00392 00393 /** @defgroup LPUART_LL_EC_DE_POLARITY Driver Enable Polarity 00394 * @{ 00395 */ 00396 #define LL_LPUART_DE_POLARITY_HIGH 0x00000000U /*!< DE signal is active high */ 00397 #define LL_LPUART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */ 00398 /** 00399 * @} 00400 */ 00401 00402 /** @defgroup LPUART_LL_EC_DMA_REG_DATA DMA Register Data 00403 * @{ 00404 */ 00405 #define LL_LPUART_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */ 00406 #define LL_LPUART_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */ 00407 /** 00408 * @} 00409 */ 00410 00411 /** 00412 * @} 00413 */ 00414 00415 /* Exported macro ------------------------------------------------------------*/ 00416 /** @defgroup LPUART_LL_Exported_Macros LPUART Exported Macros 00417 * @{ 00418 */ 00419 00420 /** @defgroup LPUART_LL_EM_WRITE_READ Common Write and read registers Macros 00421 * @{ 00422 */ 00423 00424 /** 00425 * @brief Write a value in LPUART register 00426 * @param __INSTANCE__ LPUART Instance 00427 * @param __REG__ Register to be written 00428 * @param __VALUE__ Value to be written in the register 00429 * @retval None 00430 */ 00431 #define LL_LPUART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 00432 00433 /** 00434 * @brief Read a value in LPUART register 00435 * @param __INSTANCE__ LPUART Instance 00436 * @param __REG__ Register to be read 00437 * @retval Register value 00438 */ 00439 #define LL_LPUART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 00440 /** 00441 * @} 00442 */ 00443 00444 /** @defgroup LPUART_LL_EM_Exported_Macros_Helper Helper Macros 00445 * @{ 00446 */ 00447 00448 /** 00449 * @brief Compute LPUARTDIV value according to Peripheral Clock and 00450 * expected Baud Rate (20-bit value of LPUARTDIV is returned) 00451 * @param __PERIPHCLK__ Peripheral Clock frequency used for LPUART Instance 00452 * @param __PRESCALER__ This parameter can be one of the following values: 00453 * @arg @ref LL_LPUART_PRESCALER_DIV1 00454 * @arg @ref LL_LPUART_PRESCALER_DIV2 00455 * @arg @ref LL_LPUART_PRESCALER_DIV4 00456 * @arg @ref LL_LPUART_PRESCALER_DIV6 00457 * @arg @ref LL_LPUART_PRESCALER_DIV8 00458 * @arg @ref LL_LPUART_PRESCALER_DIV10 00459 * @arg @ref LL_LPUART_PRESCALER_DIV12 00460 * @arg @ref LL_LPUART_PRESCALER_DIV16 00461 * @arg @ref LL_LPUART_PRESCALER_DIV32 00462 * @arg @ref LL_LPUART_PRESCALER_DIV64 00463 * @arg @ref LL_LPUART_PRESCALER_DIV128 00464 * @arg @ref LL_LPUART_PRESCALER_DIV256 00465 * @param __BAUDRATE__ Baud Rate value to achieve 00466 * @retval LPUARTDIV value to be used for BRR register filling 00467 */ 00468 #define __LL_LPUART_DIV(__PERIPHCLK__, __PRESCALER__, __BAUDRATE__) (uint32_t)\ 00469 ((((((uint64_t)(__PERIPHCLK__)/(uint64_t)(LPUART_PRESCALER_TAB[(uint16_t)(__PRESCALER__)]))\ 00470 * LPUART_LPUARTDIV_FREQ_MUL) + (uint32_t)((__BAUDRATE__)/2U))/(__BAUDRATE__)) & LPUART_BRR_MASK) 00471 00472 /** 00473 * @} 00474 */ 00475 00476 /** 00477 * @} 00478 */ 00479 00480 /* Exported functions --------------------------------------------------------*/ 00481 /** @defgroup LPUART_LL_Exported_Functions LPUART Exported Functions 00482 * @{ 00483 */ 00484 00485 /** @defgroup LPUART_LL_EF_Configuration Configuration functions 00486 * @{ 00487 */ 00488 00489 /** 00490 * @brief LPUART Enable 00491 * @rmtoll CR1 UE LL_LPUART_Enable 00492 * @param LPUARTx LPUART Instance 00493 * @retval None 00494 */ 00495 __STATIC_INLINE void LL_LPUART_Enable(USART_TypeDef *LPUARTx) 00496 { 00497 SET_BIT(LPUARTx->CR1, USART_CR1_UE); 00498 } 00499 00500 /** 00501 * @brief LPUART Disable 00502 * @note When LPUART is disabled, LPUART prescalers and outputs are stopped immediately, 00503 * and current operations are discarded. The configuration of the LPUART is kept, but all the status 00504 * flags, in the LPUARTx_ISR are set to their default values. 00505 * @note In order to go into low-power mode without generating errors on the line, 00506 * the TE bit must be reset before and the software must wait 00507 * for the TC bit in the LPUART_ISR to be set before resetting the UE bit. 00508 * The DMA requests are also reset when UE = 0 so the DMA channel must 00509 * be disabled before resetting the UE bit. 00510 * @rmtoll CR1 UE LL_LPUART_Disable 00511 * @param LPUARTx LPUART Instance 00512 * @retval None 00513 */ 00514 __STATIC_INLINE void LL_LPUART_Disable(USART_TypeDef *LPUARTx) 00515 { 00516 CLEAR_BIT(LPUARTx->CR1, USART_CR1_UE); 00517 } 00518 00519 /** 00520 * @brief Indicate if LPUART is enabled 00521 * @rmtoll CR1 UE LL_LPUART_IsEnabled 00522 * @param LPUARTx LPUART Instance 00523 * @retval State of bit (1 or 0). 00524 */ 00525 __STATIC_INLINE uint32_t LL_LPUART_IsEnabled(USART_TypeDef *LPUARTx) 00526 { 00527 return ((READ_BIT(LPUARTx->CR1, USART_CR1_UE) == (USART_CR1_UE)) ? 1UL : 0UL); 00528 } 00529 00530 /** 00531 * @brief FIFO Mode Enable 00532 * @rmtoll CR1 FIFOEN LL_LPUART_EnableFIFO 00533 * @param LPUARTx LPUART Instance 00534 * @retval None 00535 */ 00536 __STATIC_INLINE void LL_LPUART_EnableFIFO(USART_TypeDef *LPUARTx) 00537 { 00538 SET_BIT(LPUARTx->CR1, USART_CR1_FIFOEN); 00539 } 00540 00541 /** 00542 * @brief FIFO Mode Disable 00543 * @rmtoll CR1 FIFOEN LL_LPUART_DisableFIFO 00544 * @param LPUARTx LPUART Instance 00545 * @retval None 00546 */ 00547 __STATIC_INLINE void LL_LPUART_DisableFIFO(USART_TypeDef *LPUARTx) 00548 { 00549 CLEAR_BIT(LPUARTx->CR1, USART_CR1_FIFOEN); 00550 } 00551 00552 /** 00553 * @brief Indicate if FIFO Mode is enabled 00554 * @rmtoll CR1 FIFOEN LL_LPUART_IsEnabledFIFO 00555 * @param LPUARTx LPUART Instance 00556 * @retval State of bit (1 or 0). 00557 */ 00558 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledFIFO(USART_TypeDef *LPUARTx) 00559 { 00560 return ((READ_BIT(LPUARTx->CR1, USART_CR1_FIFOEN) == (USART_CR1_FIFOEN)) ? 1UL : 0UL); 00561 } 00562 00563 /** 00564 * @brief Configure TX FIFO Threshold 00565 * @rmtoll CR3 TXFTCFG LL_LPUART_SetTXFIFOThreshold 00566 * @param LPUARTx LPUART Instance 00567 * @param Threshold This parameter can be one of the following values: 00568 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8 00569 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4 00570 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2 00571 * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4 00572 * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8 00573 * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8 00574 * @retval None 00575 */ 00576 __STATIC_INLINE void LL_LPUART_SetTXFIFOThreshold(USART_TypeDef *LPUARTx, uint32_t Threshold) 00577 { 00578 ATOMIC_MODIFY_REG(LPUARTx->CR3, USART_CR3_TXFTCFG, Threshold << USART_CR3_TXFTCFG_Pos); 00579 } 00580 00581 /** 00582 * @brief Return TX FIFO Threshold Configuration 00583 * @rmtoll CR3 TXFTCFG LL_LPUART_GetTXFIFOThreshold 00584 * @param LPUARTx LPUART Instance 00585 * @retval Returned value can be one of the following values: 00586 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8 00587 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4 00588 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2 00589 * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4 00590 * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8 00591 * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8 00592 */ 00593 __STATIC_INLINE uint32_t LL_LPUART_GetTXFIFOThreshold(USART_TypeDef *LPUARTx) 00594 { 00595 return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_TXFTCFG) >> USART_CR3_TXFTCFG_Pos); 00596 } 00597 00598 /** 00599 * @brief Configure RX FIFO Threshold 00600 * @rmtoll CR3 RXFTCFG LL_LPUART_SetRXFIFOThreshold 00601 * @param LPUARTx LPUART Instance 00602 * @param Threshold This parameter can be one of the following values: 00603 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8 00604 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4 00605 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2 00606 * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4 00607 * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8 00608 * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8 00609 * @retval None 00610 */ 00611 __STATIC_INLINE void LL_LPUART_SetRXFIFOThreshold(USART_TypeDef *LPUARTx, uint32_t Threshold) 00612 { 00613 ATOMIC_MODIFY_REG(LPUARTx->CR3, USART_CR3_RXFTCFG, Threshold << USART_CR3_RXFTCFG_Pos); 00614 } 00615 00616 /** 00617 * @brief Return RX FIFO Threshold Configuration 00618 * @rmtoll CR3 RXFTCFG LL_LPUART_GetRXFIFOThreshold 00619 * @param LPUARTx LPUART Instance 00620 * @retval Returned value can be one of the following values: 00621 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8 00622 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4 00623 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2 00624 * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4 00625 * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8 00626 * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8 00627 */ 00628 __STATIC_INLINE uint32_t LL_LPUART_GetRXFIFOThreshold(USART_TypeDef *LPUARTx) 00629 { 00630 return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_RXFTCFG) >> USART_CR3_RXFTCFG_Pos); 00631 } 00632 00633 /** 00634 * @brief Configure TX and RX FIFOs Threshold 00635 * @rmtoll CR3 TXFTCFG LL_LPUART_ConfigFIFOsThreshold\n 00636 * CR3 RXFTCFG LL_LPUART_ConfigFIFOsThreshold 00637 * @param LPUARTx LPUART Instance 00638 * @param TXThreshold This parameter can be one of the following values: 00639 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8 00640 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4 00641 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2 00642 * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4 00643 * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8 00644 * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8 00645 * @param RXThreshold This parameter can be one of the following values: 00646 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_8 00647 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_4 00648 * @arg @ref LL_LPUART_FIFOTHRESHOLD_1_2 00649 * @arg @ref LL_LPUART_FIFOTHRESHOLD_3_4 00650 * @arg @ref LL_LPUART_FIFOTHRESHOLD_7_8 00651 * @arg @ref LL_LPUART_FIFOTHRESHOLD_8_8 00652 * @retval None 00653 */ 00654 __STATIC_INLINE void LL_LPUART_ConfigFIFOsThreshold(USART_TypeDef *LPUARTx, uint32_t TXThreshold, uint32_t RXThreshold) 00655 { 00656 ATOMIC_MODIFY_REG(LPUARTx->CR3, USART_CR3_TXFTCFG | USART_CR3_RXFTCFG, (TXThreshold << USART_CR3_TXFTCFG_Pos) | \ 00657 (RXThreshold << USART_CR3_RXFTCFG_Pos)); 00658 } 00659 00660 /** 00661 * @brief LPUART enabled in STOP Mode 00662 * @note When this function is enabled, LPUART is able to wake up the MCU from Stop mode, provided that 00663 * LPUART clock selection is HSI or LSE in RCC. 00664 * @rmtoll CR1 UESM LL_LPUART_EnableInStopMode 00665 * @param LPUARTx LPUART Instance 00666 * @retval None 00667 */ 00668 __STATIC_INLINE void LL_LPUART_EnableInStopMode(USART_TypeDef *LPUARTx) 00669 { 00670 ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_UESM); 00671 } 00672 00673 /** 00674 * @brief LPUART disabled in STOP Mode 00675 * @note When this function is disabled, LPUART is not able to wake up the MCU from Stop mode 00676 * @rmtoll CR1 UESM LL_LPUART_DisableInStopMode 00677 * @param LPUARTx LPUART Instance 00678 * @retval None 00679 */ 00680 __STATIC_INLINE void LL_LPUART_DisableInStopMode(USART_TypeDef *LPUARTx) 00681 { 00682 ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_UESM); 00683 } 00684 00685 /** 00686 * @brief Indicate if LPUART is enabled in STOP Mode 00687 * (able to wake up MCU from Stop mode or not) 00688 * @rmtoll CR1 UESM LL_LPUART_IsEnabledInStopMode 00689 * @param LPUARTx LPUART Instance 00690 * @retval State of bit (1 or 0). 00691 */ 00692 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledInStopMode(USART_TypeDef *LPUARTx) 00693 { 00694 return ((READ_BIT(LPUARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM)) ? 1UL : 0UL); 00695 } 00696 00697 /** 00698 * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit) 00699 * @rmtoll CR1 RE LL_LPUART_EnableDirectionRx 00700 * @param LPUARTx LPUART Instance 00701 * @retval None 00702 */ 00703 __STATIC_INLINE void LL_LPUART_EnableDirectionRx(USART_TypeDef *LPUARTx) 00704 { 00705 ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_RE); 00706 } 00707 00708 /** 00709 * @brief Receiver Disable 00710 * @rmtoll CR1 RE LL_LPUART_DisableDirectionRx 00711 * @param LPUARTx LPUART Instance 00712 * @retval None 00713 */ 00714 __STATIC_INLINE void LL_LPUART_DisableDirectionRx(USART_TypeDef *LPUARTx) 00715 { 00716 ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_RE); 00717 } 00718 00719 /** 00720 * @brief Transmitter Enable 00721 * @rmtoll CR1 TE LL_LPUART_EnableDirectionTx 00722 * @param LPUARTx LPUART Instance 00723 * @retval None 00724 */ 00725 __STATIC_INLINE void LL_LPUART_EnableDirectionTx(USART_TypeDef *LPUARTx) 00726 { 00727 ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_TE); 00728 } 00729 00730 /** 00731 * @brief Transmitter Disable 00732 * @rmtoll CR1 TE LL_LPUART_DisableDirectionTx 00733 * @param LPUARTx LPUART Instance 00734 * @retval None 00735 */ 00736 __STATIC_INLINE void LL_LPUART_DisableDirectionTx(USART_TypeDef *LPUARTx) 00737 { 00738 ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_TE); 00739 } 00740 00741 /** 00742 * @brief Configure simultaneously enabled/disabled states 00743 * of Transmitter and Receiver 00744 * @rmtoll CR1 RE LL_LPUART_SetTransferDirection\n 00745 * CR1 TE LL_LPUART_SetTransferDirection 00746 * @param LPUARTx LPUART Instance 00747 * @param TransferDirection This parameter can be one of the following values: 00748 * @arg @ref LL_LPUART_DIRECTION_NONE 00749 * @arg @ref LL_LPUART_DIRECTION_RX 00750 * @arg @ref LL_LPUART_DIRECTION_TX 00751 * @arg @ref LL_LPUART_DIRECTION_TX_RX 00752 * @retval None 00753 */ 00754 __STATIC_INLINE void LL_LPUART_SetTransferDirection(USART_TypeDef *LPUARTx, uint32_t TransferDirection) 00755 { 00756 ATOMIC_MODIFY_REG(LPUARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection); 00757 } 00758 00759 /** 00760 * @brief Return enabled/disabled states of Transmitter and Receiver 00761 * @rmtoll CR1 RE LL_LPUART_GetTransferDirection\n 00762 * CR1 TE LL_LPUART_GetTransferDirection 00763 * @param LPUARTx LPUART Instance 00764 * @retval Returned value can be one of the following values: 00765 * @arg @ref LL_LPUART_DIRECTION_NONE 00766 * @arg @ref LL_LPUART_DIRECTION_RX 00767 * @arg @ref LL_LPUART_DIRECTION_TX 00768 * @arg @ref LL_LPUART_DIRECTION_TX_RX 00769 */ 00770 __STATIC_INLINE uint32_t LL_LPUART_GetTransferDirection(USART_TypeDef *LPUARTx) 00771 { 00772 return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_RE | USART_CR1_TE)); 00773 } 00774 00775 /** 00776 * @brief Configure Parity (enabled/disabled and parity mode if enabled) 00777 * @note This function selects if hardware parity control (generation and detection) is enabled or disabled. 00778 * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position 00779 * (depending on data width) and parity is checked on the received data. 00780 * @rmtoll CR1 PS LL_LPUART_SetParity\n 00781 * CR1 PCE LL_LPUART_SetParity 00782 * @param LPUARTx LPUART Instance 00783 * @param Parity This parameter can be one of the following values: 00784 * @arg @ref LL_LPUART_PARITY_NONE 00785 * @arg @ref LL_LPUART_PARITY_EVEN 00786 * @arg @ref LL_LPUART_PARITY_ODD 00787 * @retval None 00788 */ 00789 __STATIC_INLINE void LL_LPUART_SetParity(USART_TypeDef *LPUARTx, uint32_t Parity) 00790 { 00791 MODIFY_REG(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity); 00792 } 00793 00794 /** 00795 * @brief Return Parity configuration (enabled/disabled and parity mode if enabled) 00796 * @rmtoll CR1 PS LL_LPUART_GetParity\n 00797 * CR1 PCE LL_LPUART_GetParity 00798 * @param LPUARTx LPUART Instance 00799 * @retval Returned value can be one of the following values: 00800 * @arg @ref LL_LPUART_PARITY_NONE 00801 * @arg @ref LL_LPUART_PARITY_EVEN 00802 * @arg @ref LL_LPUART_PARITY_ODD 00803 */ 00804 __STATIC_INLINE uint32_t LL_LPUART_GetParity(USART_TypeDef *LPUARTx) 00805 { 00806 return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE)); 00807 } 00808 00809 /** 00810 * @brief Set Receiver Wake Up method from Mute mode. 00811 * @rmtoll CR1 WAKE LL_LPUART_SetWakeUpMethod 00812 * @param LPUARTx LPUART Instance 00813 * @param Method This parameter can be one of the following values: 00814 * @arg @ref LL_LPUART_WAKEUP_IDLELINE 00815 * @arg @ref LL_LPUART_WAKEUP_ADDRESSMARK 00816 * @retval None 00817 */ 00818 __STATIC_INLINE void LL_LPUART_SetWakeUpMethod(USART_TypeDef *LPUARTx, uint32_t Method) 00819 { 00820 MODIFY_REG(LPUARTx->CR1, USART_CR1_WAKE, Method); 00821 } 00822 00823 /** 00824 * @brief Return Receiver Wake Up method from Mute mode 00825 * @rmtoll CR1 WAKE LL_LPUART_GetWakeUpMethod 00826 * @param LPUARTx LPUART Instance 00827 * @retval Returned value can be one of the following values: 00828 * @arg @ref LL_LPUART_WAKEUP_IDLELINE 00829 * @arg @ref LL_LPUART_WAKEUP_ADDRESSMARK 00830 */ 00831 __STATIC_INLINE uint32_t LL_LPUART_GetWakeUpMethod(USART_TypeDef *LPUARTx) 00832 { 00833 return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_WAKE)); 00834 } 00835 00836 /** 00837 * @brief Set Word length (nb of data bits, excluding start and stop bits) 00838 * @rmtoll CR1 M LL_LPUART_SetDataWidth 00839 * @param LPUARTx LPUART Instance 00840 * @param DataWidth This parameter can be one of the following values: 00841 * @arg @ref LL_LPUART_DATAWIDTH_7B 00842 * @arg @ref LL_LPUART_DATAWIDTH_8B 00843 * @arg @ref LL_LPUART_DATAWIDTH_9B 00844 * @retval None 00845 */ 00846 __STATIC_INLINE void LL_LPUART_SetDataWidth(USART_TypeDef *LPUARTx, uint32_t DataWidth) 00847 { 00848 MODIFY_REG(LPUARTx->CR1, USART_CR1_M, DataWidth); 00849 } 00850 00851 /** 00852 * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits) 00853 * @rmtoll CR1 M LL_LPUART_GetDataWidth 00854 * @param LPUARTx LPUART Instance 00855 * @retval Returned value can be one of the following values: 00856 * @arg @ref LL_LPUART_DATAWIDTH_7B 00857 * @arg @ref LL_LPUART_DATAWIDTH_8B 00858 * @arg @ref LL_LPUART_DATAWIDTH_9B 00859 */ 00860 __STATIC_INLINE uint32_t LL_LPUART_GetDataWidth(USART_TypeDef *LPUARTx) 00861 { 00862 return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_M)); 00863 } 00864 00865 /** 00866 * @brief Allow switch between Mute Mode and Active mode 00867 * @rmtoll CR1 MME LL_LPUART_EnableMuteMode 00868 * @param LPUARTx LPUART Instance 00869 * @retval None 00870 */ 00871 __STATIC_INLINE void LL_LPUART_EnableMuteMode(USART_TypeDef *LPUARTx) 00872 { 00873 ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_MME); 00874 } 00875 00876 /** 00877 * @brief Prevent Mute Mode use. Set Receiver in active mode permanently. 00878 * @rmtoll CR1 MME LL_LPUART_DisableMuteMode 00879 * @param LPUARTx LPUART Instance 00880 * @retval None 00881 */ 00882 __STATIC_INLINE void LL_LPUART_DisableMuteMode(USART_TypeDef *LPUARTx) 00883 { 00884 ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_MME); 00885 } 00886 00887 /** 00888 * @brief Indicate if switch between Mute Mode and Active mode is allowed 00889 * @rmtoll CR1 MME LL_LPUART_IsEnabledMuteMode 00890 * @param LPUARTx LPUART Instance 00891 * @retval State of bit (1 or 0). 00892 */ 00893 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledMuteMode(USART_TypeDef *LPUARTx) 00894 { 00895 return ((READ_BIT(LPUARTx->CR1, USART_CR1_MME) == (USART_CR1_MME)) ? 1UL : 0UL); 00896 } 00897 00898 /** 00899 * @brief Configure Clock source prescaler for baudrate generator and oversampling 00900 * @rmtoll PRESC PRESCALER LL_LPUART_SetPrescaler 00901 * @param LPUARTx LPUART Instance 00902 * @param PrescalerValue This parameter can be one of the following values: 00903 * @arg @ref LL_LPUART_PRESCALER_DIV1 00904 * @arg @ref LL_LPUART_PRESCALER_DIV2 00905 * @arg @ref LL_LPUART_PRESCALER_DIV4 00906 * @arg @ref LL_LPUART_PRESCALER_DIV6 00907 * @arg @ref LL_LPUART_PRESCALER_DIV8 00908 * @arg @ref LL_LPUART_PRESCALER_DIV10 00909 * @arg @ref LL_LPUART_PRESCALER_DIV12 00910 * @arg @ref LL_LPUART_PRESCALER_DIV16 00911 * @arg @ref LL_LPUART_PRESCALER_DIV32 00912 * @arg @ref LL_LPUART_PRESCALER_DIV64 00913 * @arg @ref LL_LPUART_PRESCALER_DIV128 00914 * @arg @ref LL_LPUART_PRESCALER_DIV256 00915 * @retval None 00916 */ 00917 __STATIC_INLINE void LL_LPUART_SetPrescaler(USART_TypeDef *LPUARTx, uint32_t PrescalerValue) 00918 { 00919 MODIFY_REG(LPUARTx->PRESC, USART_PRESC_PRESCALER, (uint16_t)PrescalerValue); 00920 } 00921 00922 /** 00923 * @brief Retrieve the Clock source prescaler for baudrate generator and oversampling 00924 * @rmtoll PRESC PRESCALER LL_LPUART_GetPrescaler 00925 * @param LPUARTx LPUART Instance 00926 * @retval Returned value can be one of the following values: 00927 * @arg @ref LL_LPUART_PRESCALER_DIV1 00928 * @arg @ref LL_LPUART_PRESCALER_DIV2 00929 * @arg @ref LL_LPUART_PRESCALER_DIV4 00930 * @arg @ref LL_LPUART_PRESCALER_DIV6 00931 * @arg @ref LL_LPUART_PRESCALER_DIV8 00932 * @arg @ref LL_LPUART_PRESCALER_DIV10 00933 * @arg @ref LL_LPUART_PRESCALER_DIV12 00934 * @arg @ref LL_LPUART_PRESCALER_DIV16 00935 * @arg @ref LL_LPUART_PRESCALER_DIV32 00936 * @arg @ref LL_LPUART_PRESCALER_DIV64 00937 * @arg @ref LL_LPUART_PRESCALER_DIV128 00938 * @arg @ref LL_LPUART_PRESCALER_DIV256 00939 */ 00940 __STATIC_INLINE uint32_t LL_LPUART_GetPrescaler(USART_TypeDef *LPUARTx) 00941 { 00942 return (uint32_t)(READ_BIT(LPUARTx->PRESC, USART_PRESC_PRESCALER)); 00943 } 00944 00945 /** 00946 * @brief Set the length of the stop bits 00947 * @rmtoll CR2 STOP LL_LPUART_SetStopBitsLength 00948 * @param LPUARTx LPUART Instance 00949 * @param StopBits This parameter can be one of the following values: 00950 * @arg @ref LL_LPUART_STOPBITS_1 00951 * @arg @ref LL_LPUART_STOPBITS_2 00952 * @retval None 00953 */ 00954 __STATIC_INLINE void LL_LPUART_SetStopBitsLength(USART_TypeDef *LPUARTx, uint32_t StopBits) 00955 { 00956 MODIFY_REG(LPUARTx->CR2, USART_CR2_STOP, StopBits); 00957 } 00958 00959 /** 00960 * @brief Retrieve the length of the stop bits 00961 * @rmtoll CR2 STOP LL_LPUART_GetStopBitsLength 00962 * @param LPUARTx LPUART Instance 00963 * @retval Returned value can be one of the following values: 00964 * @arg @ref LL_LPUART_STOPBITS_1 00965 * @arg @ref LL_LPUART_STOPBITS_2 00966 */ 00967 __STATIC_INLINE uint32_t LL_LPUART_GetStopBitsLength(USART_TypeDef *LPUARTx) 00968 { 00969 return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_STOP)); 00970 } 00971 00972 /** 00973 * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits) 00974 * @note Call of this function is equivalent to following function call sequence : 00975 * - Data Width configuration using @ref LL_LPUART_SetDataWidth() function 00976 * - Parity Control and mode configuration using @ref LL_LPUART_SetParity() function 00977 * - Stop bits configuration using @ref LL_LPUART_SetStopBitsLength() function 00978 * @rmtoll CR1 PS LL_LPUART_ConfigCharacter\n 00979 * CR1 PCE LL_LPUART_ConfigCharacter\n 00980 * CR1 M LL_LPUART_ConfigCharacter\n 00981 * CR2 STOP LL_LPUART_ConfigCharacter 00982 * @param LPUARTx LPUART Instance 00983 * @param DataWidth This parameter can be one of the following values: 00984 * @arg @ref LL_LPUART_DATAWIDTH_7B 00985 * @arg @ref LL_LPUART_DATAWIDTH_8B 00986 * @arg @ref LL_LPUART_DATAWIDTH_9B 00987 * @param Parity This parameter can be one of the following values: 00988 * @arg @ref LL_LPUART_PARITY_NONE 00989 * @arg @ref LL_LPUART_PARITY_EVEN 00990 * @arg @ref LL_LPUART_PARITY_ODD 00991 * @param StopBits This parameter can be one of the following values: 00992 * @arg @ref LL_LPUART_STOPBITS_1 00993 * @arg @ref LL_LPUART_STOPBITS_2 00994 * @retval None 00995 */ 00996 __STATIC_INLINE void LL_LPUART_ConfigCharacter(USART_TypeDef *LPUARTx, uint32_t DataWidth, uint32_t Parity, 00997 uint32_t StopBits) 00998 { 00999 MODIFY_REG(LPUARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth); 01000 MODIFY_REG(LPUARTx->CR2, USART_CR2_STOP, StopBits); 01001 } 01002 01003 /** 01004 * @brief Configure TX/RX pins swapping setting. 01005 * @rmtoll CR2 SWAP LL_LPUART_SetTXRXSwap 01006 * @param LPUARTx LPUART Instance 01007 * @param SwapConfig This parameter can be one of the following values: 01008 * @arg @ref LL_LPUART_TXRX_STANDARD 01009 * @arg @ref LL_LPUART_TXRX_SWAPPED 01010 * @retval None 01011 */ 01012 __STATIC_INLINE void LL_LPUART_SetTXRXSwap(USART_TypeDef *LPUARTx, uint32_t SwapConfig) 01013 { 01014 MODIFY_REG(LPUARTx->CR2, USART_CR2_SWAP, SwapConfig); 01015 } 01016 01017 /** 01018 * @brief Retrieve TX/RX pins swapping configuration. 01019 * @rmtoll CR2 SWAP LL_LPUART_GetTXRXSwap 01020 * @param LPUARTx LPUART Instance 01021 * @retval Returned value can be one of the following values: 01022 * @arg @ref LL_LPUART_TXRX_STANDARD 01023 * @arg @ref LL_LPUART_TXRX_SWAPPED 01024 */ 01025 __STATIC_INLINE uint32_t LL_LPUART_GetTXRXSwap(USART_TypeDef *LPUARTx) 01026 { 01027 return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_SWAP)); 01028 } 01029 01030 /** 01031 * @brief Configure RX pin active level logic 01032 * @rmtoll CR2 RXINV LL_LPUART_SetRXPinLevel 01033 * @param LPUARTx LPUART Instance 01034 * @param PinInvMethod This parameter can be one of the following values: 01035 * @arg @ref LL_LPUART_RXPIN_LEVEL_STANDARD 01036 * @arg @ref LL_LPUART_RXPIN_LEVEL_INVERTED 01037 * @retval None 01038 */ 01039 __STATIC_INLINE void LL_LPUART_SetRXPinLevel(USART_TypeDef *LPUARTx, uint32_t PinInvMethod) 01040 { 01041 MODIFY_REG(LPUARTx->CR2, USART_CR2_RXINV, PinInvMethod); 01042 } 01043 01044 /** 01045 * @brief Retrieve RX pin active level logic configuration 01046 * @rmtoll CR2 RXINV LL_LPUART_GetRXPinLevel 01047 * @param LPUARTx LPUART Instance 01048 * @retval Returned value can be one of the following values: 01049 * @arg @ref LL_LPUART_RXPIN_LEVEL_STANDARD 01050 * @arg @ref LL_LPUART_RXPIN_LEVEL_INVERTED 01051 */ 01052 __STATIC_INLINE uint32_t LL_LPUART_GetRXPinLevel(USART_TypeDef *LPUARTx) 01053 { 01054 return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_RXINV)); 01055 } 01056 01057 /** 01058 * @brief Configure TX pin active level logic 01059 * @rmtoll CR2 TXINV LL_LPUART_SetTXPinLevel 01060 * @param LPUARTx LPUART Instance 01061 * @param PinInvMethod This parameter can be one of the following values: 01062 * @arg @ref LL_LPUART_TXPIN_LEVEL_STANDARD 01063 * @arg @ref LL_LPUART_TXPIN_LEVEL_INVERTED 01064 * @retval None 01065 */ 01066 __STATIC_INLINE void LL_LPUART_SetTXPinLevel(USART_TypeDef *LPUARTx, uint32_t PinInvMethod) 01067 { 01068 MODIFY_REG(LPUARTx->CR2, USART_CR2_TXINV, PinInvMethod); 01069 } 01070 01071 /** 01072 * @brief Retrieve TX pin active level logic configuration 01073 * @rmtoll CR2 TXINV LL_LPUART_GetTXPinLevel 01074 * @param LPUARTx LPUART Instance 01075 * @retval Returned value can be one of the following values: 01076 * @arg @ref LL_LPUART_TXPIN_LEVEL_STANDARD 01077 * @arg @ref LL_LPUART_TXPIN_LEVEL_INVERTED 01078 */ 01079 __STATIC_INLINE uint32_t LL_LPUART_GetTXPinLevel(USART_TypeDef *LPUARTx) 01080 { 01081 return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_TXINV)); 01082 } 01083 01084 /** 01085 * @brief Configure Binary data logic. 01086 * 01087 * @note Allow to define how Logical data from the data register are send/received : 01088 * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H) 01089 * @rmtoll CR2 DATAINV LL_LPUART_SetBinaryDataLogic 01090 * @param LPUARTx LPUART Instance 01091 * @param DataLogic This parameter can be one of the following values: 01092 * @arg @ref LL_LPUART_BINARY_LOGIC_POSITIVE 01093 * @arg @ref LL_LPUART_BINARY_LOGIC_NEGATIVE 01094 * @retval None 01095 */ 01096 __STATIC_INLINE void LL_LPUART_SetBinaryDataLogic(USART_TypeDef *LPUARTx, uint32_t DataLogic) 01097 { 01098 MODIFY_REG(LPUARTx->CR2, USART_CR2_DATAINV, DataLogic); 01099 } 01100 01101 /** 01102 * @brief Retrieve Binary data configuration 01103 * @rmtoll CR2 DATAINV LL_LPUART_GetBinaryDataLogic 01104 * @param LPUARTx LPUART Instance 01105 * @retval Returned value can be one of the following values: 01106 * @arg @ref LL_LPUART_BINARY_LOGIC_POSITIVE 01107 * @arg @ref LL_LPUART_BINARY_LOGIC_NEGATIVE 01108 */ 01109 __STATIC_INLINE uint32_t LL_LPUART_GetBinaryDataLogic(USART_TypeDef *LPUARTx) 01110 { 01111 return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_DATAINV)); 01112 } 01113 01114 /** 01115 * @brief Configure transfer bit order (either Less or Most Significant Bit First) 01116 * @note MSB First means data is transmitted/received with the MSB first, following the start bit. 01117 * LSB First means data is transmitted/received with data bit 0 first, following the start bit. 01118 * @rmtoll CR2 MSBFIRST LL_LPUART_SetTransferBitOrder 01119 * @param LPUARTx LPUART Instance 01120 * @param BitOrder This parameter can be one of the following values: 01121 * @arg @ref LL_LPUART_BITORDER_LSBFIRST 01122 * @arg @ref LL_LPUART_BITORDER_MSBFIRST 01123 * @retval None 01124 */ 01125 __STATIC_INLINE void LL_LPUART_SetTransferBitOrder(USART_TypeDef *LPUARTx, uint32_t BitOrder) 01126 { 01127 MODIFY_REG(LPUARTx->CR2, USART_CR2_MSBFIRST, BitOrder); 01128 } 01129 01130 /** 01131 * @brief Return transfer bit order (either Less or Most Significant Bit First) 01132 * @note MSB First means data is transmitted/received with the MSB first, following the start bit. 01133 * LSB First means data is transmitted/received with data bit 0 first, following the start bit. 01134 * @rmtoll CR2 MSBFIRST LL_LPUART_GetTransferBitOrder 01135 * @param LPUARTx LPUART Instance 01136 * @retval Returned value can be one of the following values: 01137 * @arg @ref LL_LPUART_BITORDER_LSBFIRST 01138 * @arg @ref LL_LPUART_BITORDER_MSBFIRST 01139 */ 01140 __STATIC_INLINE uint32_t LL_LPUART_GetTransferBitOrder(USART_TypeDef *LPUARTx) 01141 { 01142 return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_MSBFIRST)); 01143 } 01144 01145 /** 01146 * @brief Set Address of the LPUART node. 01147 * @note This is used in multiprocessor communication during Mute mode or Stop mode, 01148 * for wake up with address mark detection. 01149 * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7. 01150 * (b7-b4 should be set to 0) 01151 * 8bits address node is used when 7-bit Address Detection is selected in ADDM7. 01152 * (This is used in multiprocessor communication during Mute mode or Stop mode, 01153 * for wake up with 7-bit address mark detection. 01154 * The MSB of the character sent by the transmitter should be equal to 1. 01155 * It may also be used for character detection during normal reception, 01156 * Mute mode inactive (for example, end of block detection in ModBus protocol). 01157 * In this case, the whole received character (8-bit) is compared to the ADD[7:0] 01158 * value and CMF flag is set on match) 01159 * @rmtoll CR2 ADD LL_LPUART_ConfigNodeAddress\n 01160 * CR2 ADDM7 LL_LPUART_ConfigNodeAddress 01161 * @param LPUARTx LPUART Instance 01162 * @param AddressLen This parameter can be one of the following values: 01163 * @arg @ref LL_LPUART_ADDRESS_DETECT_4B 01164 * @arg @ref LL_LPUART_ADDRESS_DETECT_7B 01165 * @param NodeAddress 4 or 7 bit Address of the LPUART node. 01166 * @retval None 01167 */ 01168 __STATIC_INLINE void LL_LPUART_ConfigNodeAddress(USART_TypeDef *LPUARTx, uint32_t AddressLen, uint32_t NodeAddress) 01169 { 01170 MODIFY_REG(LPUARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7, 01171 (uint32_t)(AddressLen | (NodeAddress << USART_CR2_ADD_Pos))); 01172 } 01173 01174 /** 01175 * @brief Return 8 bit Address of the LPUART node as set in ADD field of CR2. 01176 * @note If 4-bit Address Detection is selected in ADDM7, 01177 * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant) 01178 * If 7-bit Address Detection is selected in ADDM7, 01179 * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant) 01180 * @rmtoll CR2 ADD LL_LPUART_GetNodeAddress 01181 * @param LPUARTx LPUART Instance 01182 * @retval Address of the LPUART node (Value between Min_Data=0 and Max_Data=255) 01183 */ 01184 __STATIC_INLINE uint32_t LL_LPUART_GetNodeAddress(USART_TypeDef *LPUARTx) 01185 { 01186 return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_ADD) >> USART_CR2_ADD_Pos); 01187 } 01188 01189 /** 01190 * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit) 01191 * @rmtoll CR2 ADDM7 LL_LPUART_GetNodeAddressLen 01192 * @param LPUARTx LPUART Instance 01193 * @retval Returned value can be one of the following values: 01194 * @arg @ref LL_LPUART_ADDRESS_DETECT_4B 01195 * @arg @ref LL_LPUART_ADDRESS_DETECT_7B 01196 */ 01197 __STATIC_INLINE uint32_t LL_LPUART_GetNodeAddressLen(USART_TypeDef *LPUARTx) 01198 { 01199 return (uint32_t)(READ_BIT(LPUARTx->CR2, USART_CR2_ADDM7)); 01200 } 01201 01202 /** 01203 * @brief Enable RTS HW Flow Control 01204 * @rmtoll CR3 RTSE LL_LPUART_EnableRTSHWFlowCtrl 01205 * @param LPUARTx LPUART Instance 01206 * @retval None 01207 */ 01208 __STATIC_INLINE void LL_LPUART_EnableRTSHWFlowCtrl(USART_TypeDef *LPUARTx) 01209 { 01210 SET_BIT(LPUARTx->CR3, USART_CR3_RTSE); 01211 } 01212 01213 /** 01214 * @brief Disable RTS HW Flow Control 01215 * @rmtoll CR3 RTSE LL_LPUART_DisableRTSHWFlowCtrl 01216 * @param LPUARTx LPUART Instance 01217 * @retval None 01218 */ 01219 __STATIC_INLINE void LL_LPUART_DisableRTSHWFlowCtrl(USART_TypeDef *LPUARTx) 01220 { 01221 CLEAR_BIT(LPUARTx->CR3, USART_CR3_RTSE); 01222 } 01223 01224 /** 01225 * @brief Enable CTS HW Flow Control 01226 * @rmtoll CR3 CTSE LL_LPUART_EnableCTSHWFlowCtrl 01227 * @param LPUARTx LPUART Instance 01228 * @retval None 01229 */ 01230 __STATIC_INLINE void LL_LPUART_EnableCTSHWFlowCtrl(USART_TypeDef *LPUARTx) 01231 { 01232 SET_BIT(LPUARTx->CR3, USART_CR3_CTSE); 01233 } 01234 01235 /** 01236 * @brief Disable CTS HW Flow Control 01237 * @rmtoll CR3 CTSE LL_LPUART_DisableCTSHWFlowCtrl 01238 * @param LPUARTx LPUART Instance 01239 * @retval None 01240 */ 01241 __STATIC_INLINE void LL_LPUART_DisableCTSHWFlowCtrl(USART_TypeDef *LPUARTx) 01242 { 01243 CLEAR_BIT(LPUARTx->CR3, USART_CR3_CTSE); 01244 } 01245 01246 /** 01247 * @brief Configure HW Flow Control mode (both CTS and RTS) 01248 * @rmtoll CR3 RTSE LL_LPUART_SetHWFlowCtrl\n 01249 * CR3 CTSE LL_LPUART_SetHWFlowCtrl 01250 * @param LPUARTx LPUART Instance 01251 * @param HardwareFlowControl This parameter can be one of the following values: 01252 * @arg @ref LL_LPUART_HWCONTROL_NONE 01253 * @arg @ref LL_LPUART_HWCONTROL_RTS 01254 * @arg @ref LL_LPUART_HWCONTROL_CTS 01255 * @arg @ref LL_LPUART_HWCONTROL_RTS_CTS 01256 * @retval None 01257 */ 01258 __STATIC_INLINE void LL_LPUART_SetHWFlowCtrl(USART_TypeDef *LPUARTx, uint32_t HardwareFlowControl) 01259 { 01260 MODIFY_REG(LPUARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl); 01261 } 01262 01263 /** 01264 * @brief Return HW Flow Control configuration (both CTS and RTS) 01265 * @rmtoll CR3 RTSE LL_LPUART_GetHWFlowCtrl\n 01266 * CR3 CTSE LL_LPUART_GetHWFlowCtrl 01267 * @param LPUARTx LPUART Instance 01268 * @retval Returned value can be one of the following values: 01269 * @arg @ref LL_LPUART_HWCONTROL_NONE 01270 * @arg @ref LL_LPUART_HWCONTROL_RTS 01271 * @arg @ref LL_LPUART_HWCONTROL_CTS 01272 * @arg @ref LL_LPUART_HWCONTROL_RTS_CTS 01273 */ 01274 __STATIC_INLINE uint32_t LL_LPUART_GetHWFlowCtrl(USART_TypeDef *LPUARTx) 01275 { 01276 return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE)); 01277 } 01278 01279 /** 01280 * @brief Enable Overrun detection 01281 * @rmtoll CR3 OVRDIS LL_LPUART_EnableOverrunDetect 01282 * @param LPUARTx LPUART Instance 01283 * @retval None 01284 */ 01285 __STATIC_INLINE void LL_LPUART_EnableOverrunDetect(USART_TypeDef *LPUARTx) 01286 { 01287 CLEAR_BIT(LPUARTx->CR3, USART_CR3_OVRDIS); 01288 } 01289 01290 /** 01291 * @brief Disable Overrun detection 01292 * @rmtoll CR3 OVRDIS LL_LPUART_DisableOverrunDetect 01293 * @param LPUARTx LPUART Instance 01294 * @retval None 01295 */ 01296 __STATIC_INLINE void LL_LPUART_DisableOverrunDetect(USART_TypeDef *LPUARTx) 01297 { 01298 SET_BIT(LPUARTx->CR3, USART_CR3_OVRDIS); 01299 } 01300 01301 /** 01302 * @brief Indicate if Overrun detection is enabled 01303 * @rmtoll CR3 OVRDIS LL_LPUART_IsEnabledOverrunDetect 01304 * @param LPUARTx LPUART Instance 01305 * @retval State of bit (1 or 0). 01306 */ 01307 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledOverrunDetect(USART_TypeDef *LPUARTx) 01308 { 01309 return ((READ_BIT(LPUARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS) ? 1UL : 0UL); 01310 } 01311 01312 /** 01313 * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits) 01314 * @rmtoll CR3 WUS LL_LPUART_SetWKUPType 01315 * @param LPUARTx LPUART Instance 01316 * @param Type This parameter can be one of the following values: 01317 * @arg @ref LL_LPUART_WAKEUP_ON_ADDRESS 01318 * @arg @ref LL_LPUART_WAKEUP_ON_STARTBIT 01319 * @arg @ref LL_LPUART_WAKEUP_ON_RXNE 01320 * @retval None 01321 */ 01322 __STATIC_INLINE void LL_LPUART_SetWKUPType(USART_TypeDef *LPUARTx, uint32_t Type) 01323 { 01324 MODIFY_REG(LPUARTx->CR3, USART_CR3_WUS, Type); 01325 } 01326 01327 /** 01328 * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits) 01329 * @rmtoll CR3 WUS LL_LPUART_GetWKUPType 01330 * @param LPUARTx LPUART Instance 01331 * @retval Returned value can be one of the following values: 01332 * @arg @ref LL_LPUART_WAKEUP_ON_ADDRESS 01333 * @arg @ref LL_LPUART_WAKEUP_ON_STARTBIT 01334 * @arg @ref LL_LPUART_WAKEUP_ON_RXNE 01335 */ 01336 __STATIC_INLINE uint32_t LL_LPUART_GetWKUPType(USART_TypeDef *LPUARTx) 01337 { 01338 return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_WUS)); 01339 } 01340 01341 /** 01342 * @brief Configure LPUART BRR register for achieving expected Baud Rate value. 01343 * 01344 * @note Compute and set LPUARTDIV value in BRR Register (full BRR content) 01345 * according to used Peripheral Clock and expected Baud Rate values 01346 * @note Peripheral clock and Baud Rate values provided as function parameters should be valid 01347 * (Baud rate value != 0). 01348 * @note Provided that LPUARTx_BRR must be > = 0x300 and LPUART_BRR is 20-bit, 01349 * a care should be taken when generating high baud rates using high PeriphClk 01350 * values. PeriphClk must be in the range [3 x BaudRate, 4096 x BaudRate]. 01351 * @rmtoll BRR BRR LL_LPUART_SetBaudRate 01352 * @param LPUARTx LPUART Instance 01353 * @param PeriphClk Peripheral Clock 01354 * @param PrescalerValue This parameter can be one of the following values: 01355 * @arg @ref LL_LPUART_PRESCALER_DIV1 01356 * @arg @ref LL_LPUART_PRESCALER_DIV2 01357 * @arg @ref LL_LPUART_PRESCALER_DIV4 01358 * @arg @ref LL_LPUART_PRESCALER_DIV6 01359 * @arg @ref LL_LPUART_PRESCALER_DIV8 01360 * @arg @ref LL_LPUART_PRESCALER_DIV10 01361 * @arg @ref LL_LPUART_PRESCALER_DIV12 01362 * @arg @ref LL_LPUART_PRESCALER_DIV16 01363 * @arg @ref LL_LPUART_PRESCALER_DIV32 01364 * @arg @ref LL_LPUART_PRESCALER_DIV64 01365 * @arg @ref LL_LPUART_PRESCALER_DIV128 01366 * @arg @ref LL_LPUART_PRESCALER_DIV256 01367 * @param BaudRate Baud Rate 01368 * @retval None 01369 */ 01370 __STATIC_INLINE void LL_LPUART_SetBaudRate(USART_TypeDef *LPUARTx, uint32_t PeriphClk, uint32_t PrescalerValue, 01371 uint32_t BaudRate) 01372 { 01373 if (BaudRate != 0U) 01374 { 01375 LPUARTx->BRR = __LL_LPUART_DIV(PeriphClk, PrescalerValue, BaudRate); 01376 } 01377 } 01378 01379 /** 01380 * @brief Return current Baud Rate value, according to LPUARTDIV present in BRR register 01381 * (full BRR content), and to used Peripheral Clock values 01382 * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned. 01383 * @rmtoll BRR BRR LL_LPUART_GetBaudRate 01384 * @param LPUARTx LPUART Instance 01385 * @param PeriphClk Peripheral Clock 01386 * @param PrescalerValue This parameter can be one of the following values: 01387 * @arg @ref LL_LPUART_PRESCALER_DIV1 01388 * @arg @ref LL_LPUART_PRESCALER_DIV2 01389 * @arg @ref LL_LPUART_PRESCALER_DIV4 01390 * @arg @ref LL_LPUART_PRESCALER_DIV6 01391 * @arg @ref LL_LPUART_PRESCALER_DIV8 01392 * @arg @ref LL_LPUART_PRESCALER_DIV10 01393 * @arg @ref LL_LPUART_PRESCALER_DIV12 01394 * @arg @ref LL_LPUART_PRESCALER_DIV16 01395 * @arg @ref LL_LPUART_PRESCALER_DIV32 01396 * @arg @ref LL_LPUART_PRESCALER_DIV64 01397 * @arg @ref LL_LPUART_PRESCALER_DIV128 01398 * @arg @ref LL_LPUART_PRESCALER_DIV256 01399 * @retval Baud Rate 01400 */ 01401 __STATIC_INLINE uint32_t LL_LPUART_GetBaudRate(USART_TypeDef *LPUARTx, uint32_t PeriphClk, uint32_t PrescalerValue) 01402 { 01403 uint32_t lpuartdiv; 01404 uint32_t brrresult; 01405 uint32_t periphclkpresc = (uint32_t)(PeriphClk / (LPUART_PRESCALER_TAB[(uint16_t)PrescalerValue])); 01406 01407 lpuartdiv = LPUARTx->BRR & LPUART_BRR_MASK; 01408 01409 if (lpuartdiv >= LPUART_BRR_MIN_VALUE) 01410 { 01411 brrresult = (uint32_t)(((uint64_t)(periphclkpresc) * LPUART_LPUARTDIV_FREQ_MUL) / lpuartdiv); 01412 } 01413 else 01414 { 01415 brrresult = 0x0UL; 01416 } 01417 01418 return (brrresult); 01419 } 01420 01421 /** 01422 * @} 01423 */ 01424 01425 /** @defgroup LPUART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature 01426 * @{ 01427 */ 01428 01429 /** 01430 * @brief Enable Single Wire Half-Duplex mode 01431 * @rmtoll CR3 HDSEL LL_LPUART_EnableHalfDuplex 01432 * @param LPUARTx LPUART Instance 01433 * @retval None 01434 */ 01435 __STATIC_INLINE void LL_LPUART_EnableHalfDuplex(USART_TypeDef *LPUARTx) 01436 { 01437 SET_BIT(LPUARTx->CR3, USART_CR3_HDSEL); 01438 } 01439 01440 /** 01441 * @brief Disable Single Wire Half-Duplex mode 01442 * @rmtoll CR3 HDSEL LL_LPUART_DisableHalfDuplex 01443 * @param LPUARTx LPUART Instance 01444 * @retval None 01445 */ 01446 __STATIC_INLINE void LL_LPUART_DisableHalfDuplex(USART_TypeDef *LPUARTx) 01447 { 01448 CLEAR_BIT(LPUARTx->CR3, USART_CR3_HDSEL); 01449 } 01450 01451 /** 01452 * @brief Indicate if Single Wire Half-Duplex mode is enabled 01453 * @rmtoll CR3 HDSEL LL_LPUART_IsEnabledHalfDuplex 01454 * @param LPUARTx LPUART Instance 01455 * @retval State of bit (1 or 0). 01456 */ 01457 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledHalfDuplex(USART_TypeDef *LPUARTx) 01458 { 01459 return ((READ_BIT(LPUARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL)) ? 1UL : 0UL); 01460 } 01461 01462 /** 01463 * @} 01464 */ 01465 01466 /** @defgroup LPUART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature 01467 * @{ 01468 */ 01469 01470 /** 01471 * @brief Set DEDT (Driver Enable De-Assertion Time), Time value expressed on 5 bits ([4:0] bits). 01472 * @rmtoll CR1 DEDT LL_LPUART_SetDEDeassertionTime 01473 * @param LPUARTx LPUART Instance 01474 * @param Time Value between Min_Data=0 and Max_Data=31 01475 * @retval None 01476 */ 01477 __STATIC_INLINE void LL_LPUART_SetDEDeassertionTime(USART_TypeDef *LPUARTx, uint32_t Time) 01478 { 01479 MODIFY_REG(LPUARTx->CR1, USART_CR1_DEDT, Time << USART_CR1_DEDT_Pos); 01480 } 01481 01482 /** 01483 * @brief Return DEDT (Driver Enable De-Assertion Time) 01484 * @rmtoll CR1 DEDT LL_LPUART_GetDEDeassertionTime 01485 * @param LPUARTx LPUART Instance 01486 * @retval Time value expressed on 5 bits ([4:0] bits) : c 01487 */ 01488 __STATIC_INLINE uint32_t LL_LPUART_GetDEDeassertionTime(USART_TypeDef *LPUARTx) 01489 { 01490 return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_DEDT) >> USART_CR1_DEDT_Pos); 01491 } 01492 01493 /** 01494 * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits). 01495 * @rmtoll CR1 DEAT LL_LPUART_SetDEAssertionTime 01496 * @param LPUARTx LPUART Instance 01497 * @param Time Value between Min_Data=0 and Max_Data=31 01498 * @retval None 01499 */ 01500 __STATIC_INLINE void LL_LPUART_SetDEAssertionTime(USART_TypeDef *LPUARTx, uint32_t Time) 01501 { 01502 MODIFY_REG(LPUARTx->CR1, USART_CR1_DEAT, Time << USART_CR1_DEAT_Pos); 01503 } 01504 01505 /** 01506 * @brief Return DEAT (Driver Enable Assertion Time) 01507 * @rmtoll CR1 DEAT LL_LPUART_GetDEAssertionTime 01508 * @param LPUARTx LPUART Instance 01509 * @retval Time value expressed on 5 bits ([4:0] bits) : Time Value between Min_Data=0 and Max_Data=31 01510 */ 01511 __STATIC_INLINE uint32_t LL_LPUART_GetDEAssertionTime(USART_TypeDef *LPUARTx) 01512 { 01513 return (uint32_t)(READ_BIT(LPUARTx->CR1, USART_CR1_DEAT) >> USART_CR1_DEAT_Pos); 01514 } 01515 01516 /** 01517 * @brief Enable Driver Enable (DE) Mode 01518 * @rmtoll CR3 DEM LL_LPUART_EnableDEMode 01519 * @param LPUARTx LPUART Instance 01520 * @retval None 01521 */ 01522 __STATIC_INLINE void LL_LPUART_EnableDEMode(USART_TypeDef *LPUARTx) 01523 { 01524 SET_BIT(LPUARTx->CR3, USART_CR3_DEM); 01525 } 01526 01527 /** 01528 * @brief Disable Driver Enable (DE) Mode 01529 * @rmtoll CR3 DEM LL_LPUART_DisableDEMode 01530 * @param LPUARTx LPUART Instance 01531 * @retval None 01532 */ 01533 __STATIC_INLINE void LL_LPUART_DisableDEMode(USART_TypeDef *LPUARTx) 01534 { 01535 CLEAR_BIT(LPUARTx->CR3, USART_CR3_DEM); 01536 } 01537 01538 /** 01539 * @brief Indicate if Driver Enable (DE) Mode is enabled 01540 * @rmtoll CR3 DEM LL_LPUART_IsEnabledDEMode 01541 * @param LPUARTx LPUART Instance 01542 * @retval State of bit (1 or 0). 01543 */ 01544 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDEMode(USART_TypeDef *LPUARTx) 01545 { 01546 return ((READ_BIT(LPUARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM)) ? 1UL : 0UL); 01547 } 01548 01549 /** 01550 * @brief Select Driver Enable Polarity 01551 * @rmtoll CR3 DEP LL_LPUART_SetDESignalPolarity 01552 * @param LPUARTx LPUART Instance 01553 * @param Polarity This parameter can be one of the following values: 01554 * @arg @ref LL_LPUART_DE_POLARITY_HIGH 01555 * @arg @ref LL_LPUART_DE_POLARITY_LOW 01556 * @retval None 01557 */ 01558 __STATIC_INLINE void LL_LPUART_SetDESignalPolarity(USART_TypeDef *LPUARTx, uint32_t Polarity) 01559 { 01560 MODIFY_REG(LPUARTx->CR3, USART_CR3_DEP, Polarity); 01561 } 01562 01563 /** 01564 * @brief Return Driver Enable Polarity 01565 * @rmtoll CR3 DEP LL_LPUART_GetDESignalPolarity 01566 * @param LPUARTx LPUART Instance 01567 * @retval Returned value can be one of the following values: 01568 * @arg @ref LL_LPUART_DE_POLARITY_HIGH 01569 * @arg @ref LL_LPUART_DE_POLARITY_LOW 01570 */ 01571 __STATIC_INLINE uint32_t LL_LPUART_GetDESignalPolarity(USART_TypeDef *LPUARTx) 01572 { 01573 return (uint32_t)(READ_BIT(LPUARTx->CR3, USART_CR3_DEP)); 01574 } 01575 01576 /** 01577 * @} 01578 */ 01579 01580 /** @defgroup LPUART_LL_EF_FLAG_Management FLAG_Management 01581 * @{ 01582 */ 01583 01584 /** 01585 * @brief Check if the LPUART Parity Error Flag is set or not 01586 * @rmtoll ISR PE LL_LPUART_IsActiveFlag_PE 01587 * @param LPUARTx LPUART Instance 01588 * @retval State of bit (1 or 0). 01589 */ 01590 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_PE(USART_TypeDef *LPUARTx) 01591 { 01592 return ((READ_BIT(LPUARTx->ISR, USART_ISR_PE) == (USART_ISR_PE)) ? 1UL : 0UL); 01593 } 01594 01595 /** 01596 * @brief Check if the LPUART Framing Error Flag is set or not 01597 * @rmtoll ISR FE LL_LPUART_IsActiveFlag_FE 01598 * @param LPUARTx LPUART Instance 01599 * @retval State of bit (1 or 0). 01600 */ 01601 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_FE(USART_TypeDef *LPUARTx) 01602 { 01603 return ((READ_BIT(LPUARTx->ISR, USART_ISR_FE) == (USART_ISR_FE)) ? 1UL : 0UL); 01604 } 01605 01606 /** 01607 * @brief Check if the LPUART Noise error detected Flag is set or not 01608 * @rmtoll ISR NE LL_LPUART_IsActiveFlag_NE 01609 * @param LPUARTx LPUART Instance 01610 * @retval State of bit (1 or 0). 01611 */ 01612 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_NE(USART_TypeDef *LPUARTx) 01613 { 01614 return ((READ_BIT(LPUARTx->ISR, USART_ISR_NE) == (USART_ISR_NE)) ? 1UL : 0UL); 01615 } 01616 01617 /** 01618 * @brief Check if the LPUART OverRun Error Flag is set or not 01619 * @rmtoll ISR ORE LL_LPUART_IsActiveFlag_ORE 01620 * @param LPUARTx LPUART Instance 01621 * @retval State of bit (1 or 0). 01622 */ 01623 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_ORE(USART_TypeDef *LPUARTx) 01624 { 01625 return ((READ_BIT(LPUARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE)) ? 1UL : 0UL); 01626 } 01627 01628 /** 01629 * @brief Check if the LPUART IDLE line detected Flag is set or not 01630 * @rmtoll ISR IDLE LL_LPUART_IsActiveFlag_IDLE 01631 * @param LPUARTx LPUART Instance 01632 * @retval State of bit (1 or 0). 01633 */ 01634 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_IDLE(USART_TypeDef *LPUARTx) 01635 { 01636 return ((READ_BIT(LPUARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE)) ? 1UL : 0UL); 01637 } 01638 01639 /* Legacy define */ 01640 #define LL_LPUART_IsActiveFlag_RXNE LL_LPUART_IsActiveFlag_RXNE_RXFNE 01641 01642 /** 01643 * @brief Check if the LPUART Read Data Register or LPUART RX FIFO Not Empty Flag is set or not 01644 * @rmtoll ISR RXNE_RXFNE LL_LPUART_IsActiveFlag_RXNE_RXFNE 01645 * @param LPUARTx LPUART Instance 01646 * @retval State of bit (1 or 0). 01647 */ 01648 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXNE_RXFNE(USART_TypeDef *LPUARTx) 01649 { 01650 return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXNE_RXFNE) == (USART_ISR_RXNE_RXFNE)) ? 1UL : 0UL); 01651 } 01652 01653 /** 01654 * @brief Check if the LPUART Transmission Complete Flag is set or not 01655 * @rmtoll ISR TC LL_LPUART_IsActiveFlag_TC 01656 * @param LPUARTx LPUART Instance 01657 * @retval State of bit (1 or 0). 01658 */ 01659 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TC(USART_TypeDef *LPUARTx) 01660 { 01661 return ((READ_BIT(LPUARTx->ISR, USART_ISR_TC) == (USART_ISR_TC)) ? 1UL : 0UL); 01662 } 01663 01664 /* Legacy define */ 01665 #define LL_LPUART_IsActiveFlag_TXE LL_LPUART_IsActiveFlag_TXE_TXFNF 01666 01667 /** 01668 * @brief Check if the LPUART Transmit Data Register Empty or LPUART TX FIFO Not Full Flag is set or not 01669 * @rmtoll ISR TXE_TXFNF LL_LPUART_IsActiveFlag_TXE_TXFNF 01670 * @param LPUARTx LPUART Instance 01671 * @retval State of bit (1 or 0). 01672 */ 01673 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXE_TXFNF(USART_TypeDef *LPUARTx) 01674 { 01675 return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXE_TXFNF) == (USART_ISR_TXE_TXFNF)) ? 1UL : 0UL); 01676 } 01677 01678 /** 01679 * @brief Check if the LPUART CTS interrupt Flag is set or not 01680 * @rmtoll ISR CTSIF LL_LPUART_IsActiveFlag_nCTS 01681 * @param LPUARTx LPUART Instance 01682 * @retval State of bit (1 or 0). 01683 */ 01684 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_nCTS(USART_TypeDef *LPUARTx) 01685 { 01686 return ((READ_BIT(LPUARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF)) ? 1UL : 0UL); 01687 } 01688 01689 /** 01690 * @brief Check if the LPUART CTS Flag is set or not 01691 * @rmtoll ISR CTS LL_LPUART_IsActiveFlag_CTS 01692 * @param LPUARTx LPUART Instance 01693 * @retval State of bit (1 or 0). 01694 */ 01695 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_CTS(USART_TypeDef *LPUARTx) 01696 { 01697 return ((READ_BIT(LPUARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS)) ? 1UL : 0UL); 01698 } 01699 01700 /** 01701 * @brief Check if the LPUART Busy Flag is set or not 01702 * @rmtoll ISR BUSY LL_LPUART_IsActiveFlag_BUSY 01703 * @param LPUARTx LPUART Instance 01704 * @retval State of bit (1 or 0). 01705 */ 01706 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_BUSY(USART_TypeDef *LPUARTx) 01707 { 01708 return ((READ_BIT(LPUARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY)) ? 1UL : 0UL); 01709 } 01710 01711 /** 01712 * @brief Check if the LPUART Character Match Flag is set or not 01713 * @rmtoll ISR CMF LL_LPUART_IsActiveFlag_CM 01714 * @param LPUARTx LPUART Instance 01715 * @retval State of bit (1 or 0). 01716 */ 01717 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_CM(USART_TypeDef *LPUARTx) 01718 { 01719 return ((READ_BIT(LPUARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF)) ? 1UL : 0UL); 01720 } 01721 01722 /** 01723 * @brief Check if the LPUART Send Break Flag is set or not 01724 * @rmtoll ISR SBKF LL_LPUART_IsActiveFlag_SBK 01725 * @param LPUARTx LPUART Instance 01726 * @retval State of bit (1 or 0). 01727 */ 01728 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_SBK(USART_TypeDef *LPUARTx) 01729 { 01730 return ((READ_BIT(LPUARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF)) ? 1UL : 0UL); 01731 } 01732 01733 /** 01734 * @brief Check if the LPUART Receive Wake Up from mute mode Flag is set or not 01735 * @rmtoll ISR RWU LL_LPUART_IsActiveFlag_RWU 01736 * @param LPUARTx LPUART Instance 01737 * @retval State of bit (1 or 0). 01738 */ 01739 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RWU(USART_TypeDef *LPUARTx) 01740 { 01741 return ((READ_BIT(LPUARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU)) ? 1UL : 0UL); 01742 } 01743 01744 /** 01745 * @brief Check if the LPUART Wake Up from stop mode Flag is set or not 01746 * @rmtoll ISR WUF LL_LPUART_IsActiveFlag_WKUP 01747 * @param LPUARTx LPUART Instance 01748 * @retval State of bit (1 or 0). 01749 */ 01750 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_WKUP(USART_TypeDef *LPUARTx) 01751 { 01752 return ((READ_BIT(LPUARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF)) ? 1UL : 0UL); 01753 } 01754 01755 /** 01756 * @brief Check if the LPUART Transmit Enable Acknowledge Flag is set or not 01757 * @rmtoll ISR TEACK LL_LPUART_IsActiveFlag_TEACK 01758 * @param LPUARTx LPUART Instance 01759 * @retval State of bit (1 or 0). 01760 */ 01761 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TEACK(USART_TypeDef *LPUARTx) 01762 { 01763 return ((READ_BIT(LPUARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK)) ? 1UL : 0UL); 01764 } 01765 01766 /** 01767 * @brief Check if the LPUART Receive Enable Acknowledge Flag is set or not 01768 * @rmtoll ISR REACK LL_LPUART_IsActiveFlag_REACK 01769 * @param LPUARTx LPUART Instance 01770 * @retval State of bit (1 or 0). 01771 */ 01772 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_REACK(USART_TypeDef *LPUARTx) 01773 { 01774 return ((READ_BIT(LPUARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK)) ? 1UL : 0UL); 01775 } 01776 01777 /** 01778 * @brief Check if the LPUART TX FIFO Empty Flag is set or not 01779 * @rmtoll ISR TXFE LL_LPUART_IsActiveFlag_TXFE 01780 * @param LPUARTx LPUART Instance 01781 * @retval State of bit (1 or 0). 01782 */ 01783 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXFE(USART_TypeDef *LPUARTx) 01784 { 01785 return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXFE) == (USART_ISR_TXFE)) ? 1UL : 0UL); 01786 } 01787 01788 /** 01789 * @brief Check if the LPUART RX FIFO Full Flag is set or not 01790 * @rmtoll ISR RXFF LL_LPUART_IsActiveFlag_RXFF 01791 * @param LPUARTx LPUART Instance 01792 * @retval State of bit (1 or 0). 01793 */ 01794 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXFF(USART_TypeDef *LPUARTx) 01795 { 01796 return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXFF) == (USART_ISR_RXFF)) ? 1UL : 0UL); 01797 } 01798 01799 /** 01800 * @brief Check if the LPUART TX FIFO Threshold Flag is set or not 01801 * @rmtoll ISR TXFT LL_LPUART_IsActiveFlag_TXFT 01802 * @param LPUARTx LPUART Instance 01803 * @retval State of bit (1 or 0). 01804 */ 01805 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_TXFT(USART_TypeDef *LPUARTx) 01806 { 01807 return ((READ_BIT(LPUARTx->ISR, USART_ISR_TXFT) == (USART_ISR_TXFT)) ? 1UL : 0UL); 01808 } 01809 01810 /** 01811 * @brief Check if the LPUART RX FIFO Threshold Flag is set or not 01812 * @rmtoll ISR RXFT LL_LPUART_IsActiveFlag_RXFT 01813 * @param LPUARTx LPUART Instance 01814 * @retval State of bit (1 or 0). 01815 */ 01816 __STATIC_INLINE uint32_t LL_LPUART_IsActiveFlag_RXFT(USART_TypeDef *LPUARTx) 01817 { 01818 return ((READ_BIT(LPUARTx->ISR, USART_ISR_RXFT) == (USART_ISR_RXFT)) ? 1UL : 0UL); 01819 } 01820 01821 /** 01822 * @brief Clear Parity Error Flag 01823 * @rmtoll ICR PECF LL_LPUART_ClearFlag_PE 01824 * @param LPUARTx LPUART Instance 01825 * @retval None 01826 */ 01827 __STATIC_INLINE void LL_LPUART_ClearFlag_PE(USART_TypeDef *LPUARTx) 01828 { 01829 WRITE_REG(LPUARTx->ICR, USART_ICR_PECF); 01830 } 01831 01832 /** 01833 * @brief Clear Framing Error Flag 01834 * @rmtoll ICR FECF LL_LPUART_ClearFlag_FE 01835 * @param LPUARTx LPUART Instance 01836 * @retval None 01837 */ 01838 __STATIC_INLINE void LL_LPUART_ClearFlag_FE(USART_TypeDef *LPUARTx) 01839 { 01840 WRITE_REG(LPUARTx->ICR, USART_ICR_FECF); 01841 } 01842 01843 /** 01844 * @brief Clear Noise detected Flag 01845 * @rmtoll ICR NECF LL_LPUART_ClearFlag_NE 01846 * @param LPUARTx LPUART Instance 01847 * @retval None 01848 */ 01849 __STATIC_INLINE void LL_LPUART_ClearFlag_NE(USART_TypeDef *LPUARTx) 01850 { 01851 WRITE_REG(LPUARTx->ICR, USART_ICR_NECF); 01852 } 01853 01854 /** 01855 * @brief Clear OverRun Error Flag 01856 * @rmtoll ICR ORECF LL_LPUART_ClearFlag_ORE 01857 * @param LPUARTx LPUART Instance 01858 * @retval None 01859 */ 01860 __STATIC_INLINE void LL_LPUART_ClearFlag_ORE(USART_TypeDef *LPUARTx) 01861 { 01862 WRITE_REG(LPUARTx->ICR, USART_ICR_ORECF); 01863 } 01864 01865 /** 01866 * @brief Clear IDLE line detected Flag 01867 * @rmtoll ICR IDLECF LL_LPUART_ClearFlag_IDLE 01868 * @param LPUARTx LPUART Instance 01869 * @retval None 01870 */ 01871 __STATIC_INLINE void LL_LPUART_ClearFlag_IDLE(USART_TypeDef *LPUARTx) 01872 { 01873 WRITE_REG(LPUARTx->ICR, USART_ICR_IDLECF); 01874 } 01875 01876 /** 01877 * @brief Clear Transmission Complete Flag 01878 * @rmtoll ICR TCCF LL_LPUART_ClearFlag_TC 01879 * @param LPUARTx LPUART Instance 01880 * @retval None 01881 */ 01882 __STATIC_INLINE void LL_LPUART_ClearFlag_TC(USART_TypeDef *LPUARTx) 01883 { 01884 WRITE_REG(LPUARTx->ICR, USART_ICR_TCCF); 01885 } 01886 01887 /** 01888 * @brief Clear CTS Interrupt Flag 01889 * @rmtoll ICR CTSCF LL_LPUART_ClearFlag_nCTS 01890 * @param LPUARTx LPUART Instance 01891 * @retval None 01892 */ 01893 __STATIC_INLINE void LL_LPUART_ClearFlag_nCTS(USART_TypeDef *LPUARTx) 01894 { 01895 WRITE_REG(LPUARTx->ICR, USART_ICR_CTSCF); 01896 } 01897 01898 /** 01899 * @brief Clear Character Match Flag 01900 * @rmtoll ICR CMCF LL_LPUART_ClearFlag_CM 01901 * @param LPUARTx LPUART Instance 01902 * @retval None 01903 */ 01904 __STATIC_INLINE void LL_LPUART_ClearFlag_CM(USART_TypeDef *LPUARTx) 01905 { 01906 WRITE_REG(LPUARTx->ICR, USART_ICR_CMCF); 01907 } 01908 01909 /** 01910 * @brief Clear Wake Up from stop mode Flag 01911 * @rmtoll ICR WUCF LL_LPUART_ClearFlag_WKUP 01912 * @param LPUARTx LPUART Instance 01913 * @retval None 01914 */ 01915 __STATIC_INLINE void LL_LPUART_ClearFlag_WKUP(USART_TypeDef *LPUARTx) 01916 { 01917 WRITE_REG(LPUARTx->ICR, USART_ICR_WUCF); 01918 } 01919 01920 /** 01921 * @} 01922 */ 01923 01924 /** @defgroup LPUART_LL_EF_IT_Management IT_Management 01925 * @{ 01926 */ 01927 01928 /** 01929 * @brief Enable IDLE Interrupt 01930 * @rmtoll CR1 IDLEIE LL_LPUART_EnableIT_IDLE 01931 * @param LPUARTx LPUART Instance 01932 * @retval None 01933 */ 01934 __STATIC_INLINE void LL_LPUART_EnableIT_IDLE(USART_TypeDef *LPUARTx) 01935 { 01936 ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_IDLEIE); 01937 } 01938 01939 /* Legacy define */ 01940 #define LL_LPUART_EnableIT_RXNE LL_LPUART_EnableIT_RXNE_RXFNE 01941 01942 /** 01943 * @brief Enable RX Not Empty and RX FIFO Not Empty Interrupt 01944 * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_EnableIT_RXNE_RXFNE 01945 * @param LPUARTx LPUART Instance 01946 * @retval None 01947 */ 01948 __STATIC_INLINE void LL_LPUART_EnableIT_RXNE_RXFNE(USART_TypeDef *LPUARTx) 01949 { 01950 ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE); 01951 } 01952 01953 /** 01954 * @brief Enable Transmission Complete Interrupt 01955 * @rmtoll CR1 TCIE LL_LPUART_EnableIT_TC 01956 * @param LPUARTx LPUART Instance 01957 * @retval None 01958 */ 01959 __STATIC_INLINE void LL_LPUART_EnableIT_TC(USART_TypeDef *LPUARTx) 01960 { 01961 ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_TCIE); 01962 } 01963 01964 /* Legacy define */ 01965 #define LL_LPUART_EnableIT_TXE LL_LPUART_EnableIT_TXE_TXFNF 01966 01967 /** 01968 * @brief Enable TX Empty and TX FIFO Not Full Interrupt 01969 * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_EnableIT_TXE_TXFNF 01970 * @param LPUARTx LPUART Instance 01971 * @retval None 01972 */ 01973 __STATIC_INLINE void LL_LPUART_EnableIT_TXE_TXFNF(USART_TypeDef *LPUARTx) 01974 { 01975 ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE); 01976 } 01977 01978 /** 01979 * @brief Enable Parity Error Interrupt 01980 * @rmtoll CR1 PEIE LL_LPUART_EnableIT_PE 01981 * @param LPUARTx LPUART Instance 01982 * @retval None 01983 */ 01984 __STATIC_INLINE void LL_LPUART_EnableIT_PE(USART_TypeDef *LPUARTx) 01985 { 01986 ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_PEIE); 01987 } 01988 01989 /** 01990 * @brief Enable Character Match Interrupt 01991 * @rmtoll CR1 CMIE LL_LPUART_EnableIT_CM 01992 * @param LPUARTx LPUART Instance 01993 * @retval None 01994 */ 01995 __STATIC_INLINE void LL_LPUART_EnableIT_CM(USART_TypeDef *LPUARTx) 01996 { 01997 ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_CMIE); 01998 } 01999 02000 /** 02001 * @brief Enable TX FIFO Empty Interrupt 02002 * @rmtoll CR1 TXFEIE LL_LPUART_EnableIT_TXFE 02003 * @param LPUARTx LPUART Instance 02004 * @retval None 02005 */ 02006 __STATIC_INLINE void LL_LPUART_EnableIT_TXFE(USART_TypeDef *LPUARTx) 02007 { 02008 ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_TXFEIE); 02009 } 02010 02011 /** 02012 * @brief Enable RX FIFO Full Interrupt 02013 * @rmtoll CR1 RXFFIE LL_LPUART_EnableIT_RXFF 02014 * @param LPUARTx LPUART Instance 02015 * @retval None 02016 */ 02017 __STATIC_INLINE void LL_LPUART_EnableIT_RXFF(USART_TypeDef *LPUARTx) 02018 { 02019 ATOMIC_SET_BIT(LPUARTx->CR1, USART_CR1_RXFFIE); 02020 } 02021 02022 /** 02023 * @brief Enable Error Interrupt 02024 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing 02025 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register). 02026 * - 0: Interrupt is inhibited 02027 * - 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register. 02028 * @rmtoll CR3 EIE LL_LPUART_EnableIT_ERROR 02029 * @param LPUARTx LPUART Instance 02030 * @retval None 02031 */ 02032 __STATIC_INLINE void LL_LPUART_EnableIT_ERROR(USART_TypeDef *LPUARTx) 02033 { 02034 ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_EIE); 02035 } 02036 02037 /** 02038 * @brief Enable CTS Interrupt 02039 * @rmtoll CR3 CTSIE LL_LPUART_EnableIT_CTS 02040 * @param LPUARTx LPUART Instance 02041 * @retval None 02042 */ 02043 __STATIC_INLINE void LL_LPUART_EnableIT_CTS(USART_TypeDef *LPUARTx) 02044 { 02045 ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_CTSIE); 02046 } 02047 02048 /** 02049 * @brief Enable Wake Up from Stop Mode Interrupt 02050 * @rmtoll CR3 WUFIE LL_LPUART_EnableIT_WKUP 02051 * @param LPUARTx LPUART Instance 02052 * @retval None 02053 */ 02054 __STATIC_INLINE void LL_LPUART_EnableIT_WKUP(USART_TypeDef *LPUARTx) 02055 { 02056 ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_WUFIE); 02057 } 02058 02059 /** 02060 * @brief Enable TX FIFO Threshold Interrupt 02061 * @rmtoll CR3 TXFTIE LL_LPUART_EnableIT_TXFT 02062 * @param LPUARTx LPUART Instance 02063 * @retval None 02064 */ 02065 __STATIC_INLINE void LL_LPUART_EnableIT_TXFT(USART_TypeDef *LPUARTx) 02066 { 02067 ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_TXFTIE); 02068 } 02069 02070 /** 02071 * @brief Enable RX FIFO Threshold Interrupt 02072 * @rmtoll CR3 RXFTIE LL_LPUART_EnableIT_RXFT 02073 * @param LPUARTx LPUART Instance 02074 * @retval None 02075 */ 02076 __STATIC_INLINE void LL_LPUART_EnableIT_RXFT(USART_TypeDef *LPUARTx) 02077 { 02078 ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_RXFTIE); 02079 } 02080 02081 /** 02082 * @brief Disable IDLE Interrupt 02083 * @rmtoll CR1 IDLEIE LL_LPUART_DisableIT_IDLE 02084 * @param LPUARTx LPUART Instance 02085 * @retval None 02086 */ 02087 __STATIC_INLINE void LL_LPUART_DisableIT_IDLE(USART_TypeDef *LPUARTx) 02088 { 02089 ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_IDLEIE); 02090 } 02091 02092 /* Legacy define */ 02093 #define LL_LPUART_DisableIT_RXNE LL_LPUART_DisableIT_RXNE_RXFNE 02094 02095 /** 02096 * @brief Disable RX Not Empty and RX FIFO Not Empty Interrupt 02097 * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_DisableIT_RXNE_RXFNE 02098 * @param LPUARTx LPUART Instance 02099 * @retval None 02100 */ 02101 __STATIC_INLINE void LL_LPUART_DisableIT_RXNE_RXFNE(USART_TypeDef *LPUARTx) 02102 { 02103 ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE); 02104 } 02105 02106 /** 02107 * @brief Disable Transmission Complete Interrupt 02108 * @rmtoll CR1 TCIE LL_LPUART_DisableIT_TC 02109 * @param LPUARTx LPUART Instance 02110 * @retval None 02111 */ 02112 __STATIC_INLINE void LL_LPUART_DisableIT_TC(USART_TypeDef *LPUARTx) 02113 { 02114 ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_TCIE); 02115 } 02116 02117 /* Legacy define */ 02118 #define LL_LPUART_DisableIT_TXE LL_LPUART_DisableIT_TXE_TXFNF 02119 02120 /** 02121 * @brief Disable TX Empty and TX FIFO Not Full Interrupt 02122 * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_DisableIT_TXE_TXFNF 02123 * @param LPUARTx LPUART Instance 02124 * @retval None 02125 */ 02126 __STATIC_INLINE void LL_LPUART_DisableIT_TXE_TXFNF(USART_TypeDef *LPUARTx) 02127 { 02128 ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE); 02129 } 02130 02131 /** 02132 * @brief Disable Parity Error Interrupt 02133 * @rmtoll CR1 PEIE LL_LPUART_DisableIT_PE 02134 * @param LPUARTx LPUART Instance 02135 * @retval None 02136 */ 02137 __STATIC_INLINE void LL_LPUART_DisableIT_PE(USART_TypeDef *LPUARTx) 02138 { 02139 ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_PEIE); 02140 } 02141 02142 /** 02143 * @brief Disable Character Match Interrupt 02144 * @rmtoll CR1 CMIE LL_LPUART_DisableIT_CM 02145 * @param LPUARTx LPUART Instance 02146 * @retval None 02147 */ 02148 __STATIC_INLINE void LL_LPUART_DisableIT_CM(USART_TypeDef *LPUARTx) 02149 { 02150 ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_CMIE); 02151 } 02152 02153 /** 02154 * @brief Disable TX FIFO Empty Interrupt 02155 * @rmtoll CR1 TXFEIE LL_LPUART_DisableIT_TXFE 02156 * @param LPUARTx LPUART Instance 02157 * @retval None 02158 */ 02159 __STATIC_INLINE void LL_LPUART_DisableIT_TXFE(USART_TypeDef *LPUARTx) 02160 { 02161 ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_TXFEIE); 02162 } 02163 02164 /** 02165 * @brief Disable RX FIFO Full Interrupt 02166 * @rmtoll CR1 RXFFIE LL_LPUART_DisableIT_RXFF 02167 * @param LPUARTx LPUART Instance 02168 * @retval None 02169 */ 02170 __STATIC_INLINE void LL_LPUART_DisableIT_RXFF(USART_TypeDef *LPUARTx) 02171 { 02172 ATOMIC_CLEAR_BIT(LPUARTx->CR1, USART_CR1_RXFFIE); 02173 } 02174 02175 /** 02176 * @brief Disable Error Interrupt 02177 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing 02178 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register). 02179 * - 0: Interrupt is inhibited 02180 * - 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the LPUARTx_ISR register. 02181 * @rmtoll CR3 EIE LL_LPUART_DisableIT_ERROR 02182 * @param LPUARTx LPUART Instance 02183 * @retval None 02184 */ 02185 __STATIC_INLINE void LL_LPUART_DisableIT_ERROR(USART_TypeDef *LPUARTx) 02186 { 02187 ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_EIE); 02188 } 02189 02190 /** 02191 * @brief Disable CTS Interrupt 02192 * @rmtoll CR3 CTSIE LL_LPUART_DisableIT_CTS 02193 * @param LPUARTx LPUART Instance 02194 * @retval None 02195 */ 02196 __STATIC_INLINE void LL_LPUART_DisableIT_CTS(USART_TypeDef *LPUARTx) 02197 { 02198 ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_CTSIE); 02199 } 02200 02201 /** 02202 * @brief Disable Wake Up from Stop Mode Interrupt 02203 * @rmtoll CR3 WUFIE LL_LPUART_DisableIT_WKUP 02204 * @param LPUARTx LPUART Instance 02205 * @retval None 02206 */ 02207 __STATIC_INLINE void LL_LPUART_DisableIT_WKUP(USART_TypeDef *LPUARTx) 02208 { 02209 ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_WUFIE); 02210 } 02211 02212 /** 02213 * @brief Disable TX FIFO Threshold Interrupt 02214 * @rmtoll CR3 TXFTIE LL_LPUART_DisableIT_TXFT 02215 * @param LPUARTx LPUART Instance 02216 * @retval None 02217 */ 02218 __STATIC_INLINE void LL_LPUART_DisableIT_TXFT(USART_TypeDef *LPUARTx) 02219 { 02220 ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_TXFTIE); 02221 } 02222 02223 /** 02224 * @brief Disable RX FIFO Threshold Interrupt 02225 * @rmtoll CR3 RXFTIE LL_LPUART_DisableIT_RXFT 02226 * @param LPUARTx LPUART Instance 02227 * @retval None 02228 */ 02229 __STATIC_INLINE void LL_LPUART_DisableIT_RXFT(USART_TypeDef *LPUARTx) 02230 { 02231 ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_RXFTIE); 02232 } 02233 02234 /** 02235 * @brief Check if the LPUART IDLE Interrupt source is enabled or disabled. 02236 * @rmtoll CR1 IDLEIE LL_LPUART_IsEnabledIT_IDLE 02237 * @param LPUARTx LPUART Instance 02238 * @retval State of bit (1 or 0). 02239 */ 02240 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_IDLE(USART_TypeDef *LPUARTx) 02241 { 02242 return ((READ_BIT(LPUARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE)) ? 1UL : 0UL); 02243 } 02244 02245 /* Legacy define */ 02246 #define LL_LPUART_IsEnabledIT_RXNE LL_LPUART_IsEnabledIT_RXNE_RXFNE 02247 02248 /** 02249 * @brief Check if the LPUART RX Not Empty and LPUART RX FIFO Not Empty Interrupt is enabled or disabled. 02250 * @rmtoll CR1 RXNEIE_RXFNEIE LL_LPUART_IsEnabledIT_RXNE_RXFNE 02251 * @param LPUARTx LPUART Instance 02252 * @retval State of bit (1 or 0). 02253 */ 02254 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXNE_RXFNE(USART_TypeDef *LPUARTx) 02255 { 02256 return ((READ_BIT(LPUARTx->CR1, USART_CR1_RXNEIE_RXFNEIE) == (USART_CR1_RXNEIE_RXFNEIE)) ? 1UL : 0UL); 02257 } 02258 02259 /** 02260 * @brief Check if the LPUART Transmission Complete Interrupt is enabled or disabled. 02261 * @rmtoll CR1 TCIE LL_LPUART_IsEnabledIT_TC 02262 * @param LPUARTx LPUART Instance 02263 * @retval State of bit (1 or 0). 02264 */ 02265 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TC(USART_TypeDef *LPUARTx) 02266 { 02267 return ((READ_BIT(LPUARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE)) ? 1UL : 0UL); 02268 } 02269 02270 /* Legacy define */ 02271 #define LL_LPUART_IsEnabledIT_TXE LL_LPUART_IsEnabledIT_TXE_TXFNF 02272 02273 /** 02274 * @brief Check if the LPUART TX Empty and LPUART TX FIFO Not Full Interrupt is enabled or disabled 02275 * @rmtoll CR1 TXEIE_TXFNFIE LL_LPUART_IsEnabledIT_TXE_TXFNF 02276 * @param LPUARTx LPUART Instance 02277 * @retval State of bit (1 or 0). 02278 */ 02279 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXE_TXFNF(USART_TypeDef *LPUARTx) 02280 { 02281 return ((READ_BIT(LPUARTx->CR1, USART_CR1_TXEIE_TXFNFIE) == (USART_CR1_TXEIE_TXFNFIE)) ? 1UL : 0UL); 02282 } 02283 02284 /** 02285 * @brief Check if the LPUART Parity Error Interrupt is enabled or disabled. 02286 * @rmtoll CR1 PEIE LL_LPUART_IsEnabledIT_PE 02287 * @param LPUARTx LPUART Instance 02288 * @retval State of bit (1 or 0). 02289 */ 02290 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_PE(USART_TypeDef *LPUARTx) 02291 { 02292 return ((READ_BIT(LPUARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE)) ? 1UL : 0UL); 02293 } 02294 02295 /** 02296 * @brief Check if the LPUART Character Match Interrupt is enabled or disabled. 02297 * @rmtoll CR1 CMIE LL_LPUART_IsEnabledIT_CM 02298 * @param LPUARTx LPUART Instance 02299 * @retval State of bit (1 or 0). 02300 */ 02301 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_CM(USART_TypeDef *LPUARTx) 02302 { 02303 return ((READ_BIT(LPUARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE)) ? 1UL : 0UL); 02304 } 02305 02306 /** 02307 * @brief Check if the LPUART TX FIFO Empty Interrupt is enabled or disabled 02308 * @rmtoll CR1 TXFEIE LL_LPUART_IsEnabledIT_TXFE 02309 * @param LPUARTx LPUART Instance 02310 * @retval State of bit (1 or 0). 02311 */ 02312 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXFE(USART_TypeDef *LPUARTx) 02313 { 02314 return ((READ_BIT(LPUARTx->CR1, USART_CR1_TXFEIE) == (USART_CR1_TXFEIE)) ? 1UL : 0UL); 02315 } 02316 02317 /** 02318 * @brief Check if the LPUART RX FIFO Full Interrupt is enabled or disabled 02319 * @rmtoll CR1 RXFFIE LL_LPUART_IsEnabledIT_RXFF 02320 * @param LPUARTx LPUART Instance 02321 * @retval State of bit (1 or 0). 02322 */ 02323 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXFF(USART_TypeDef *LPUARTx) 02324 { 02325 return ((READ_BIT(LPUARTx->CR1, USART_CR1_RXFFIE) == (USART_CR1_RXFFIE)) ? 1UL : 0UL); 02326 } 02327 02328 /** 02329 * @brief Check if the LPUART Error Interrupt is enabled or disabled. 02330 * @rmtoll CR3 EIE LL_LPUART_IsEnabledIT_ERROR 02331 * @param LPUARTx LPUART Instance 02332 * @retval State of bit (1 or 0). 02333 */ 02334 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_ERROR(USART_TypeDef *LPUARTx) 02335 { 02336 return ((READ_BIT(LPUARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE)) ? 1UL : 0UL); 02337 } 02338 02339 /** 02340 * @brief Check if the LPUART CTS Interrupt is enabled or disabled. 02341 * @rmtoll CR3 CTSIE LL_LPUART_IsEnabledIT_CTS 02342 * @param LPUARTx LPUART Instance 02343 * @retval State of bit (1 or 0). 02344 */ 02345 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_CTS(USART_TypeDef *LPUARTx) 02346 { 02347 return ((READ_BIT(LPUARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE)) ? 1UL : 0UL); 02348 } 02349 02350 /** 02351 * @brief Check if the LPUART Wake Up from Stop Mode Interrupt is enabled or disabled. 02352 * @rmtoll CR3 WUFIE LL_LPUART_IsEnabledIT_WKUP 02353 * @param LPUARTx LPUART Instance 02354 * @retval State of bit (1 or 0). 02355 */ 02356 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_WKUP(USART_TypeDef *LPUARTx) 02357 { 02358 return ((READ_BIT(LPUARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE)) ? 1UL : 0UL); 02359 } 02360 02361 /** 02362 * @brief Check if LPUART TX FIFO Threshold Interrupt is enabled or disabled 02363 * @rmtoll CR3 TXFTIE LL_LPUART_IsEnabledIT_TXFT 02364 * @param LPUARTx LPUART Instance 02365 * @retval State of bit (1 or 0). 02366 */ 02367 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_TXFT(USART_TypeDef *LPUARTx) 02368 { 02369 return ((READ_BIT(LPUARTx->CR3, USART_CR3_TXFTIE) == (USART_CR3_TXFTIE)) ? 1UL : 0UL); 02370 } 02371 02372 /** 02373 * @brief Check if LPUART RX FIFO Threshold Interrupt is enabled or disabled 02374 * @rmtoll CR3 RXFTIE LL_LPUART_IsEnabledIT_RXFT 02375 * @param LPUARTx LPUART Instance 02376 * @retval State of bit (1 or 0). 02377 */ 02378 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledIT_RXFT(USART_TypeDef *LPUARTx) 02379 { 02380 return ((READ_BIT(LPUARTx->CR3, USART_CR3_RXFTIE) == (USART_CR3_RXFTIE)) ? 1UL : 0UL); 02381 } 02382 02383 /** 02384 * @} 02385 */ 02386 02387 /** @defgroup LPUART_LL_EF_DMA_Management DMA_Management 02388 * @{ 02389 */ 02390 02391 /** 02392 * @brief Enable DMA Mode for reception 02393 * @rmtoll CR3 DMAR LL_LPUART_EnableDMAReq_RX 02394 * @param LPUARTx LPUART Instance 02395 * @retval None 02396 */ 02397 __STATIC_INLINE void LL_LPUART_EnableDMAReq_RX(USART_TypeDef *LPUARTx) 02398 { 02399 ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_DMAR); 02400 } 02401 02402 /** 02403 * @brief Disable DMA Mode for reception 02404 * @rmtoll CR3 DMAR LL_LPUART_DisableDMAReq_RX 02405 * @param LPUARTx LPUART Instance 02406 * @retval None 02407 */ 02408 __STATIC_INLINE void LL_LPUART_DisableDMAReq_RX(USART_TypeDef *LPUARTx) 02409 { 02410 ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_DMAR); 02411 } 02412 02413 /** 02414 * @brief Check if DMA Mode is enabled for reception 02415 * @rmtoll CR3 DMAR LL_LPUART_IsEnabledDMAReq_RX 02416 * @param LPUARTx LPUART Instance 02417 * @retval State of bit (1 or 0). 02418 */ 02419 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMAReq_RX(USART_TypeDef *LPUARTx) 02420 { 02421 return ((READ_BIT(LPUARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR)) ? 1UL : 0UL); 02422 } 02423 02424 /** 02425 * @brief Enable DMA Mode for transmission 02426 * @rmtoll CR3 DMAT LL_LPUART_EnableDMAReq_TX 02427 * @param LPUARTx LPUART Instance 02428 * @retval None 02429 */ 02430 __STATIC_INLINE void LL_LPUART_EnableDMAReq_TX(USART_TypeDef *LPUARTx) 02431 { 02432 ATOMIC_SET_BIT(LPUARTx->CR3, USART_CR3_DMAT); 02433 } 02434 02435 /** 02436 * @brief Disable DMA Mode for transmission 02437 * @rmtoll CR3 DMAT LL_LPUART_DisableDMAReq_TX 02438 * @param LPUARTx LPUART Instance 02439 * @retval None 02440 */ 02441 __STATIC_INLINE void LL_LPUART_DisableDMAReq_TX(USART_TypeDef *LPUARTx) 02442 { 02443 ATOMIC_CLEAR_BIT(LPUARTx->CR3, USART_CR3_DMAT); 02444 } 02445 02446 /** 02447 * @brief Check if DMA Mode is enabled for transmission 02448 * @rmtoll CR3 DMAT LL_LPUART_IsEnabledDMAReq_TX 02449 * @param LPUARTx LPUART Instance 02450 * @retval State of bit (1 or 0). 02451 */ 02452 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMAReq_TX(USART_TypeDef *LPUARTx) 02453 { 02454 return ((READ_BIT(LPUARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT)) ? 1UL : 0UL); 02455 } 02456 02457 /** 02458 * @brief Enable DMA Disabling on Reception Error 02459 * @rmtoll CR3 DDRE LL_LPUART_EnableDMADeactOnRxErr 02460 * @param LPUARTx LPUART Instance 02461 * @retval None 02462 */ 02463 __STATIC_INLINE void LL_LPUART_EnableDMADeactOnRxErr(USART_TypeDef *LPUARTx) 02464 { 02465 SET_BIT(LPUARTx->CR3, USART_CR3_DDRE); 02466 } 02467 02468 /** 02469 * @brief Disable DMA Disabling on Reception Error 02470 * @rmtoll CR3 DDRE LL_LPUART_DisableDMADeactOnRxErr 02471 * @param LPUARTx LPUART Instance 02472 * @retval None 02473 */ 02474 __STATIC_INLINE void LL_LPUART_DisableDMADeactOnRxErr(USART_TypeDef *LPUARTx) 02475 { 02476 CLEAR_BIT(LPUARTx->CR3, USART_CR3_DDRE); 02477 } 02478 02479 /** 02480 * @brief Indicate if DMA Disabling on Reception Error is disabled 02481 * @rmtoll CR3 DDRE LL_LPUART_IsEnabledDMADeactOnRxErr 02482 * @param LPUARTx LPUART Instance 02483 * @retval State of bit (1 or 0). 02484 */ 02485 __STATIC_INLINE uint32_t LL_LPUART_IsEnabledDMADeactOnRxErr(USART_TypeDef *LPUARTx) 02486 { 02487 return ((READ_BIT(LPUARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE)) ? 1UL : 0UL); 02488 } 02489 02490 /** 02491 * @brief Get the LPUART data register address used for DMA transfer 02492 * @rmtoll RDR RDR LL_LPUART_DMA_GetRegAddr\n 02493 * @rmtoll TDR TDR LL_LPUART_DMA_GetRegAddr 02494 * @param LPUARTx LPUART Instance 02495 * @param Direction This parameter can be one of the following values: 02496 * @arg @ref LL_LPUART_DMA_REG_DATA_TRANSMIT 02497 * @arg @ref LL_LPUART_DMA_REG_DATA_RECEIVE 02498 * @retval Address of data register 02499 */ 02500 __STATIC_INLINE uint32_t LL_LPUART_DMA_GetRegAddr(USART_TypeDef *LPUARTx, uint32_t Direction) 02501 { 02502 uint32_t data_reg_addr; 02503 02504 if (Direction == LL_LPUART_DMA_REG_DATA_TRANSMIT) 02505 { 02506 /* return address of TDR register */ 02507 data_reg_addr = (uint32_t) &(LPUARTx->TDR); 02508 } 02509 else 02510 { 02511 /* return address of RDR register */ 02512 data_reg_addr = (uint32_t) &(LPUARTx->RDR); 02513 } 02514 02515 return data_reg_addr; 02516 } 02517 02518 /** 02519 * @} 02520 */ 02521 02522 /** @defgroup LPUART_LL_EF_Data_Management Data_Management 02523 * @{ 02524 */ 02525 02526 /** 02527 * @brief Read Receiver Data register (Receive Data value, 8 bits) 02528 * @rmtoll RDR RDR LL_LPUART_ReceiveData8 02529 * @param LPUARTx LPUART Instance 02530 * @retval Time Value between Min_Data=0x00 and Max_Data=0xFF 02531 */ 02532 __STATIC_INLINE uint8_t LL_LPUART_ReceiveData8(USART_TypeDef *LPUARTx) 02533 { 02534 return (uint8_t)(READ_BIT(LPUARTx->RDR, USART_RDR_RDR) & 0xFFU); 02535 } 02536 02537 /** 02538 * @brief Read Receiver Data register (Receive Data value, 9 bits) 02539 * @rmtoll RDR RDR LL_LPUART_ReceiveData9 02540 * @param LPUARTx LPUART Instance 02541 * @retval Time Value between Min_Data=0x00 and Max_Data=0x1FF 02542 */ 02543 __STATIC_INLINE uint16_t LL_LPUART_ReceiveData9(USART_TypeDef *LPUARTx) 02544 { 02545 return (uint16_t)(READ_BIT(LPUARTx->RDR, USART_RDR_RDR)); 02546 } 02547 02548 /** 02549 * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits) 02550 * @rmtoll TDR TDR LL_LPUART_TransmitData8 02551 * @param LPUARTx LPUART Instance 02552 * @param Value between Min_Data=0x00 and Max_Data=0xFF 02553 * @retval None 02554 */ 02555 __STATIC_INLINE void LL_LPUART_TransmitData8(USART_TypeDef *LPUARTx, uint8_t Value) 02556 { 02557 LPUARTx->TDR = Value; 02558 } 02559 02560 /** 02561 * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits) 02562 * @rmtoll TDR TDR LL_LPUART_TransmitData9 02563 * @param LPUARTx LPUART Instance 02564 * @param Value between Min_Data=0x00 and Max_Data=0x1FF 02565 * @retval None 02566 */ 02567 __STATIC_INLINE void LL_LPUART_TransmitData9(USART_TypeDef *LPUARTx, uint16_t Value) 02568 { 02569 LPUARTx->TDR = Value & 0x1FFUL; 02570 } 02571 02572 /** 02573 * @} 02574 */ 02575 02576 /** @defgroup LPUART_LL_EF_Execution Execution 02577 * @{ 02578 */ 02579 02580 /** 02581 * @brief Request Break sending 02582 * @rmtoll RQR SBKRQ LL_LPUART_RequestBreakSending 02583 * @param LPUARTx LPUART Instance 02584 * @retval None 02585 */ 02586 __STATIC_INLINE void LL_LPUART_RequestBreakSending(USART_TypeDef *LPUARTx) 02587 { 02588 SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_SBKRQ); 02589 } 02590 02591 /** 02592 * @brief Put LPUART in mute mode and set the RWU flag 02593 * @rmtoll RQR MMRQ LL_LPUART_RequestEnterMuteMode 02594 * @param LPUARTx LPUART Instance 02595 * @retval None 02596 */ 02597 __STATIC_INLINE void LL_LPUART_RequestEnterMuteMode(USART_TypeDef *LPUARTx) 02598 { 02599 SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_MMRQ); 02600 } 02601 02602 /** 02603 * @brief Request a Receive Data and FIFO flush 02604 * @note Allows to discard the received data without reading them, and avoid an overrun 02605 * condition. 02606 * @rmtoll RQR RXFRQ LL_LPUART_RequestRxDataFlush 02607 * @param LPUARTx LPUART Instance 02608 * @retval None 02609 */ 02610 __STATIC_INLINE void LL_LPUART_RequestRxDataFlush(USART_TypeDef *LPUARTx) 02611 { 02612 SET_BIT(LPUARTx->RQR, (uint16_t)USART_RQR_RXFRQ); 02613 } 02614 02615 /** 02616 * @} 02617 */ 02618 02619 #if defined(USE_FULL_LL_DRIVER) 02620 /** @defgroup LPUART_LL_EF_Init Initialization and de-initialization functions 02621 * @{ 02622 */ 02623 ErrorStatus LL_LPUART_DeInit(USART_TypeDef *LPUARTx); 02624 ErrorStatus LL_LPUART_Init(USART_TypeDef *LPUARTx, LL_LPUART_InitTypeDef *LPUART_InitStruct); 02625 void LL_LPUART_StructInit(LL_LPUART_InitTypeDef *LPUART_InitStruct); 02626 /** 02627 * @} 02628 */ 02629 #endif /* USE_FULL_LL_DRIVER */ 02630 02631 /** 02632 * @} 02633 */ 02634 02635 /** 02636 * @} 02637 */ 02638 02639 #endif /* LPUART1 */ 02640 02641 /** 02642 * @} 02643 */ 02644 02645 #ifdef __cplusplus 02646 } 02647 #endif 02648 02649 #endif /* STM32H7xx_LL_LPUART_H */ 02650