STM32L443xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_ll_usart.h 00004 * @author MCD Application Team 00005 * @brief Header file of USART 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 STM32L4xx_LL_USART_H 00021 #define STM32L4xx_LL_USART_H 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /* Includes ------------------------------------------------------------------*/ 00028 #include "stm32l4xx.h" 00029 00030 /** @addtogroup STM32L4xx_LL_Driver 00031 * @{ 00032 */ 00033 00034 #if defined (USART1) || defined (USART2) || defined (USART3) || defined (UART4) || defined (UART5) 00035 00036 /** @defgroup USART_LL USART 00037 * @{ 00038 */ 00039 00040 /* Private types -------------------------------------------------------------*/ 00041 /* Private variables ---------------------------------------------------------*/ 00042 #if defined(USART_PRESC_PRESCALER) 00043 /** @defgroup USART_LL_Private_Variables USART Private Variables 00044 * @{ 00045 */ 00046 /* Array used to get the USART prescaler division decimal values versus @ref USART_LL_EC_PRESCALER values */ 00047 static const uint32_t USART_PRESCALER_TAB[] = 00048 { 00049 1UL, 00050 2UL, 00051 4UL, 00052 6UL, 00053 8UL, 00054 10UL, 00055 12UL, 00056 16UL, 00057 32UL, 00058 64UL, 00059 128UL, 00060 256UL 00061 }; 00062 /** 00063 * @} 00064 */ 00065 #endif /* USART_PRESC_PRESCALER */ 00066 00067 /* Private constants ---------------------------------------------------------*/ 00068 /* Private macros ------------------------------------------------------------*/ 00069 #if defined(USE_FULL_LL_DRIVER) 00070 /** @defgroup USART_LL_Private_Macros USART Private Macros 00071 * @{ 00072 */ 00073 /** 00074 * @} 00075 */ 00076 #endif /*USE_FULL_LL_DRIVER*/ 00077 00078 /* Exported types ------------------------------------------------------------*/ 00079 #if defined(USE_FULL_LL_DRIVER) 00080 /** @defgroup USART_LL_ES_INIT USART Exported Init structures 00081 * @{ 00082 */ 00083 00084 /** 00085 * @brief LL USART Init Structure definition 00086 */ 00087 typedef struct 00088 { 00089 #if defined(USART_PRESC_PRESCALER) 00090 uint32_t PrescalerValue; /*!< Specifies the Prescaler to compute the communication baud rate. 00091 This parameter can be a value of @ref USART_LL_EC_PRESCALER. 00092 00093 This feature can be modified afterwards using unitary 00094 function @ref LL_USART_SetPrescaler().*/ 00095 #endif /* USART_PRESC_PRESCALER */ 00096 00097 uint32_t BaudRate; /*!< This field defines expected Usart communication baud rate. 00098 00099 This feature can be modified afterwards using unitary 00100 function @ref LL_USART_SetBaudRate().*/ 00101 00102 uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame. 00103 This parameter can be a value of @ref USART_LL_EC_DATAWIDTH. 00104 00105 This feature can be modified afterwards using unitary 00106 function @ref LL_USART_SetDataWidth().*/ 00107 00108 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. 00109 This parameter can be a value of @ref USART_LL_EC_STOPBITS. 00110 00111 This feature can be modified afterwards using unitary 00112 function @ref LL_USART_SetStopBitsLength().*/ 00113 00114 uint32_t Parity; /*!< Specifies the parity mode. 00115 This parameter can be a value of @ref USART_LL_EC_PARITY. 00116 00117 This feature can be modified afterwards using unitary 00118 function @ref LL_USART_SetParity().*/ 00119 00120 uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled. 00121 This parameter can be a value of @ref USART_LL_EC_DIRECTION. 00122 00123 This feature can be modified afterwards using unitary 00124 function @ref LL_USART_SetTransferDirection().*/ 00125 00126 uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled. 00127 This parameter can be a value of @ref USART_LL_EC_HWCONTROL. 00128 00129 This feature can be modified afterwards using unitary 00130 function @ref LL_USART_SetHWFlowCtrl().*/ 00131 00132 uint32_t OverSampling; /*!< Specifies whether USART oversampling mode is 16 or 8. 00133 This parameter can be a value of @ref USART_LL_EC_OVERSAMPLING. 00134 00135 This feature can be modified afterwards using unitary 00136 function @ref LL_USART_SetOverSampling().*/ 00137 00138 } LL_USART_InitTypeDef; 00139 00140 /** 00141 * @brief LL USART Clock Init Structure definition 00142 */ 00143 typedef struct 00144 { 00145 uint32_t ClockOutput; /*!< Specifies whether the USART clock is enabled or disabled. 00146 This parameter can be a value of @ref USART_LL_EC_CLOCK. 00147 00148 USART HW configuration can be modified afterwards using unitary functions 00149 @ref LL_USART_EnableSCLKOutput() or @ref LL_USART_DisableSCLKOutput(). 00150 For more details, refer to description of this function. */ 00151 00152 uint32_t ClockPolarity; /*!< Specifies the steady state of the serial clock. 00153 This parameter can be a value of @ref USART_LL_EC_POLARITY. 00154 00155 USART HW configuration can be modified afterwards using unitary 00156 functions @ref LL_USART_SetClockPolarity(). 00157 For more details, refer to description of this function. */ 00158 00159 uint32_t ClockPhase; /*!< Specifies the clock transition on which the bit capture is made. 00160 This parameter can be a value of @ref USART_LL_EC_PHASE. 00161 00162 USART HW configuration can be modified afterwards using unitary 00163 functions @ref LL_USART_SetClockPhase(). 00164 For more details, refer to description of this function. */ 00165 00166 uint32_t LastBitClockPulse; /*!< Specifies whether the clock pulse corresponding to the last transmitted 00167 data bit (MSB) has to be output on the SCLK pin in synchronous mode. 00168 This parameter can be a value of @ref USART_LL_EC_LASTCLKPULSE. 00169 00170 USART HW configuration can be modified afterwards using unitary 00171 functions @ref LL_USART_SetLastClkPulseOutput(). 00172 For more details, refer to description of this function. */ 00173 00174 } LL_USART_ClockInitTypeDef; 00175 00176 /** 00177 * @} 00178 */ 00179 #endif /* USE_FULL_LL_DRIVER */ 00180 00181 /* Exported constants --------------------------------------------------------*/ 00182 /** @defgroup USART_LL_Exported_Constants USART Exported Constants 00183 * @{ 00184 */ 00185 00186 /** @defgroup USART_LL_EC_CLEAR_FLAG Clear Flags Defines 00187 * @brief Flags defines which can be used with LL_USART_WriteReg function 00188 * @{ 00189 */ 00190 #define LL_USART_ICR_PECF USART_ICR_PECF /*!< Parity error clear flag */ 00191 #define LL_USART_ICR_FECF USART_ICR_FECF /*!< Framing error clear flag */ 00192 #define LL_USART_ICR_NECF USART_ICR_NECF /*!< Noise error detected clear flag */ 00193 #define LL_USART_ICR_ORECF USART_ICR_ORECF /*!< Overrun error clear flag */ 00194 #define LL_USART_ICR_IDLECF USART_ICR_IDLECF /*!< Idle line detected clear flag */ 00195 #if defined(USART_CR1_FIFOEN) 00196 #define LL_USART_ICR_TXFECF USART_ICR_TXFECF /*!< TX FIFO Empty clear flag */ 00197 #endif /* USART_CR1_FIFOEN */ 00198 #define LL_USART_ICR_TCCF USART_ICR_TCCF /*!< Transmission complete clear flag */ 00199 #if defined(USART_TCBGT_SUPPORT) 00200 #define LL_USART_ICR_TCBGTCF USART_ICR_TCBGTCF /*!< Transmission completed before guard time clear flag */ 00201 #endif /* USART_TCBGT_SUPPORT */ 00202 #define LL_USART_ICR_LBDCF USART_ICR_LBDCF /*!< LIN break detection clear flag */ 00203 #define LL_USART_ICR_CTSCF USART_ICR_CTSCF /*!< CTS clear flag */ 00204 #define LL_USART_ICR_RTOCF USART_ICR_RTOCF /*!< Receiver timeout clear flag */ 00205 #define LL_USART_ICR_EOBCF USART_ICR_EOBCF /*!< End of block clear flag */ 00206 #if defined(USART_CR2_SLVEN) 00207 #define LL_USART_ICR_UDRCF USART_ICR_UDRCF /*!< SPI Slave Underrun clear flag */ 00208 #endif /* USART_CR2_SLVEN */ 00209 #define LL_USART_ICR_CMCF USART_ICR_CMCF /*!< Character match clear flag */ 00210 #define LL_USART_ICR_WUCF USART_ICR_WUCF /*!< Wakeup from Stop mode clear flag */ 00211 /** 00212 * @} 00213 */ 00214 00215 /** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines 00216 * @brief Flags defines which can be used with LL_USART_ReadReg function 00217 * @{ 00218 */ 00219 #define LL_USART_ISR_PE USART_ISR_PE /*!< Parity error flag */ 00220 #define LL_USART_ISR_FE USART_ISR_FE /*!< Framing error flag */ 00221 #define LL_USART_ISR_NE USART_ISR_NE /*!< Noise detected flag */ 00222 #define LL_USART_ISR_ORE USART_ISR_ORE /*!< Overrun error flag */ 00223 #define LL_USART_ISR_IDLE USART_ISR_IDLE /*!< Idle line detected flag */ 00224 #if defined(USART_CR1_FIFOEN) 00225 #define LL_USART_ISR_RXNE_RXFNE USART_ISR_RXNE_RXFNE /*!< Read data register or RX FIFO not empty flag */ 00226 #else 00227 #define LL_USART_ISR_RXNE USART_ISR_RXNE /*!< Read data register not empty flag */ 00228 #endif /* USART_CR1_FIFOEN */ 00229 #define LL_USART_ISR_TC USART_ISR_TC /*!< Transmission complete flag */ 00230 #if defined(USART_CR1_FIFOEN) 00231 #define LL_USART_ISR_TXE_TXFNF USART_ISR_TXE_TXFNF /*!< Transmit data register empty or TX FIFO Not Full flag*/ 00232 #else 00233 #define LL_USART_ISR_TXE USART_ISR_TXE /*!< Transmit data register empty flag */ 00234 #endif /* USART_CR1_FIFOEN */ 00235 #define LL_USART_ISR_LBDF USART_ISR_LBDF /*!< LIN break detection flag */ 00236 #define LL_USART_ISR_CTSIF USART_ISR_CTSIF /*!< CTS interrupt flag */ 00237 #define LL_USART_ISR_CTS USART_ISR_CTS /*!< CTS flag */ 00238 #define LL_USART_ISR_RTOF USART_ISR_RTOF /*!< Receiver timeout flag */ 00239 #define LL_USART_ISR_EOBF USART_ISR_EOBF /*!< End of block flag */ 00240 #if defined(USART_CR2_SLVEN) 00241 #define LL_USART_ISR_UDR USART_ISR_UDR /*!< SPI Slave underrun error flag */ 00242 #endif /* USART_CR2_SLVEN */ 00243 #define LL_USART_ISR_ABRE USART_ISR_ABRE /*!< Auto baud rate error flag */ 00244 #define LL_USART_ISR_ABRF USART_ISR_ABRF /*!< Auto baud rate flag */ 00245 #define LL_USART_ISR_BUSY USART_ISR_BUSY /*!< Busy flag */ 00246 #define LL_USART_ISR_CMF USART_ISR_CMF /*!< Character match flag */ 00247 #define LL_USART_ISR_SBKF USART_ISR_SBKF /*!< Send break flag */ 00248 #define LL_USART_ISR_RWU USART_ISR_RWU /*!< Receiver wakeup from Mute mode flag */ 00249 #define LL_USART_ISR_WUF USART_ISR_WUF /*!< Wakeup from Stop mode flag */ 00250 #define LL_USART_ISR_TEACK USART_ISR_TEACK /*!< Transmit enable acknowledge flag */ 00251 #define LL_USART_ISR_REACK USART_ISR_REACK /*!< Receive enable acknowledge flag */ 00252 #if defined(USART_CR1_FIFOEN) 00253 #define LL_USART_ISR_TXFE USART_ISR_TXFE /*!< TX FIFO empty flag */ 00254 #define LL_USART_ISR_RXFF USART_ISR_RXFF /*!< RX FIFO full flag */ 00255 #endif /* USART_CR1_FIFOEN */ 00256 #if defined(USART_TCBGT_SUPPORT) 00257 #define LL_USART_ISR_TCBGT USART_ISR_TCBGT /*!< Transmission complete before guard time completion flag */ 00258 #endif /* USART_TCBGT_SUPPORT */ 00259 #if defined(USART_CR1_FIFOEN) 00260 #define LL_USART_ISR_RXFT USART_ISR_RXFT /*!< RX FIFO threshold flag */ 00261 #define LL_USART_ISR_TXFT USART_ISR_TXFT /*!< TX FIFO threshold flag */ 00262 #endif /* USART_CR1_FIFOEN */ 00263 /** 00264 * @} 00265 */ 00266 00267 /** @defgroup USART_LL_EC_IT IT Defines 00268 * @brief IT defines which can be used with LL_USART_ReadReg and LL_USART_WriteReg functions 00269 * @{ 00270 */ 00271 #define LL_USART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */ 00272 #if defined(USART_CR1_FIFOEN) 00273 #define LL_USART_CR1_RXNEIE_RXFNEIE USART_CR1_RXNEIE_RXFNEIE /*!< Read data register and RXFIFO not empty interrupt enable */ 00274 #else 00275 #define LL_USART_CR1_RXNEIE USART_CR1_RXNEIE /*!< Read data register not empty interrupt enable */ 00276 #endif /* USART_CR1_FIFOEN */ 00277 #define LL_USART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */ 00278 #if defined(USART_CR1_FIFOEN) 00279 #define LL_USART_CR1_TXEIE_TXFNFIE USART_CR1_TXEIE_TXFNFIE /*!< Transmit data register empty and TX FIFO not full interrupt enable */ 00280 #else 00281 #define LL_USART_CR1_TXEIE USART_CR1_TXEIE /*!< Transmit data register empty interrupt enable */ 00282 #endif /* USART_CR1_FIFOEN */ 00283 #define LL_USART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */ 00284 #define LL_USART_CR1_CMIE USART_CR1_CMIE /*!< Character match interrupt enable */ 00285 #define LL_USART_CR1_RTOIE USART_CR1_RTOIE /*!< Receiver timeout interrupt enable */ 00286 #define LL_USART_CR1_EOBIE USART_CR1_EOBIE /*!< End of Block interrupt enable */ 00287 #if defined(USART_CR1_FIFOEN) 00288 #define LL_USART_CR1_TXFEIE USART_CR1_TXFEIE /*!< TX FIFO empty interrupt enable */ 00289 #define LL_USART_CR1_RXFFIE USART_CR1_RXFFIE /*!< RX FIFO full interrupt enable */ 00290 #endif /* USART_CR1_FIFOEN */ 00291 #define LL_USART_CR2_LBDIE USART_CR2_LBDIE /*!< LIN break detection interrupt enable */ 00292 #define LL_USART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */ 00293 #define LL_USART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */ 00294 #define LL_USART_CR3_WUFIE USART_CR3_WUFIE /*!< Wakeup from Stop mode interrupt enable */ 00295 #if defined(USART_CR1_FIFOEN) 00296 #define LL_USART_CR3_TXFTIE USART_CR3_TXFTIE /*!< TX FIFO threshold interrupt enable */ 00297 #endif /* USART_CR1_FIFOEN */ 00298 #if defined(USART_TCBGT_SUPPORT) 00299 #define LL_USART_CR3_TCBGTIE USART_CR3_TCBGTIE /*!< Transmission complete before guard time interrupt enable */ 00300 #endif /* USART_TCBGT_SUPPORT */ 00301 #if defined(USART_CR1_FIFOEN) 00302 #define LL_USART_CR3_RXFTIE USART_CR3_RXFTIE /*!< RX FIFO threshold interrupt enable */ 00303 #endif /* USART_CR1_FIFOEN */ 00304 /** 00305 * @} 00306 */ 00307 00308 #if defined(USART_CR1_FIFOEN) 00309 /** @defgroup USART_LL_EC_FIFOTHRESHOLD FIFO Threshold 00310 * @{ 00311 */ 00312 #define LL_USART_FIFOTHRESHOLD_1_8 0x00000000U /*!< FIFO reaches 1/8 of its depth */ 00313 #define LL_USART_FIFOTHRESHOLD_1_4 0x00000001U /*!< FIFO reaches 1/4 of its depth */ 00314 #define LL_USART_FIFOTHRESHOLD_1_2 0x00000002U /*!< FIFO reaches 1/2 of its depth */ 00315 #define LL_USART_FIFOTHRESHOLD_3_4 0x00000003U /*!< FIFO reaches 3/4 of its depth */ 00316 #define LL_USART_FIFOTHRESHOLD_7_8 0x00000004U /*!< FIFO reaches 7/8 of its depth */ 00317 #define LL_USART_FIFOTHRESHOLD_8_8 0x00000005U /*!< FIFO becomes empty for TX and full for RX */ 00318 /** 00319 * @} 00320 */ 00321 00322 #endif /* USART_CR1_FIFOEN */ 00323 /** @defgroup USART_LL_EC_DIRECTION Communication Direction 00324 * @{ 00325 */ 00326 #define LL_USART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */ 00327 #define LL_USART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */ 00328 #define LL_USART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */ 00329 #define LL_USART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */ 00330 /** 00331 * @} 00332 */ 00333 00334 /** @defgroup USART_LL_EC_PARITY Parity Control 00335 * @{ 00336 */ 00337 #define LL_USART_PARITY_NONE 0x00000000U /*!< Parity control disabled */ 00338 #define LL_USART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */ 00339 #define LL_USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */ 00340 /** 00341 * @} 00342 */ 00343 00344 /** @defgroup USART_LL_EC_WAKEUP Wakeup 00345 * @{ 00346 */ 00347 #define LL_USART_WAKEUP_IDLELINE 0x00000000U /*!< USART wake up from Mute mode on Idle Line */ 00348 #define LL_USART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< USART wake up from Mute mode on Address Mark */ 00349 /** 00350 * @} 00351 */ 00352 00353 /** @defgroup USART_LL_EC_DATAWIDTH Datawidth 00354 * @{ 00355 */ 00356 #define LL_USART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */ 00357 #define LL_USART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */ 00358 #define LL_USART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */ 00359 /** 00360 * @} 00361 */ 00362 00363 /** @defgroup USART_LL_EC_OVERSAMPLING Oversampling 00364 * @{ 00365 */ 00366 #define LL_USART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */ 00367 #define LL_USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */ 00368 /** 00369 * @} 00370 */ 00371 00372 #if defined(USE_FULL_LL_DRIVER) 00373 /** @defgroup USART_LL_EC_CLOCK Clock Signal 00374 * @{ 00375 */ 00376 00377 #define LL_USART_CLOCK_DISABLE 0x00000000U /*!< Clock signal not provided */ 00378 #define LL_USART_CLOCK_ENABLE USART_CR2_CLKEN /*!< Clock signal provided */ 00379 /** 00380 * @} 00381 */ 00382 #endif /*USE_FULL_LL_DRIVER*/ 00383 00384 /** @defgroup USART_LL_EC_LASTCLKPULSE Last Clock Pulse 00385 * @{ 00386 */ 00387 #define LL_USART_LASTCLKPULSE_NO_OUTPUT 0x00000000U /*!< The clock pulse of the last data bit is not output to the SCLK pin */ 00388 #define LL_USART_LASTCLKPULSE_OUTPUT USART_CR2_LBCL /*!< The clock pulse of the last data bit is output to the SCLK pin */ 00389 /** 00390 * @} 00391 */ 00392 00393 /** @defgroup USART_LL_EC_PHASE Clock Phase 00394 * @{ 00395 */ 00396 #define LL_USART_PHASE_1EDGE 0x00000000U /*!< The first clock transition is the first data capture edge */ 00397 #define LL_USART_PHASE_2EDGE USART_CR2_CPHA /*!< The second clock transition is the first data capture edge */ 00398 /** 00399 * @} 00400 */ 00401 00402 /** @defgroup USART_LL_EC_POLARITY Clock Polarity 00403 * @{ 00404 */ 00405 #define LL_USART_POLARITY_LOW 0x00000000U /*!< Steady low value on SCLK pin outside transmission window*/ 00406 #define LL_USART_POLARITY_HIGH USART_CR2_CPOL /*!< Steady high value on SCLK pin outside transmission window */ 00407 /** 00408 * @} 00409 */ 00410 00411 #if defined(USART_PRESC_PRESCALER) 00412 /** @defgroup USART_LL_EC_PRESCALER Clock Source Prescaler 00413 * @{ 00414 */ 00415 #define LL_USART_PRESCALER_DIV1 0x00000000U /*!< Input clock not divided */ 00416 #define LL_USART_PRESCALER_DIV2 (USART_PRESC_PRESCALER_0) /*!< Input clock divided by 2 */ 00417 #define LL_USART_PRESCALER_DIV4 (USART_PRESC_PRESCALER_1) /*!< Input clock divided by 4 */ 00418 #define LL_USART_PRESCALER_DIV6 (USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 6 */ 00419 #define LL_USART_PRESCALER_DIV8 (USART_PRESC_PRESCALER_2) /*!< Input clock divided by 8 */ 00420 #define LL_USART_PRESCALER_DIV10 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 10 */ 00421 #define LL_USART_PRESCALER_DIV12 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_1) /*!< Input clock divided by 12 */ 00422 #define LL_USART_PRESCALER_DIV16 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 16 */ 00423 #define LL_USART_PRESCALER_DIV32 (USART_PRESC_PRESCALER_3) /*!< Input clock divided by 32 */ 00424 #define LL_USART_PRESCALER_DIV64 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 64 */ 00425 #define LL_USART_PRESCALER_DIV128 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_1) /*!< Input clock divided by 128 */ 00426 #define LL_USART_PRESCALER_DIV256 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 256 */ 00427 /** 00428 * @} 00429 */ 00430 00431 #endif /* USART_PRESC_PRESCALER */ 00432 /** @defgroup USART_LL_EC_STOPBITS Stop Bits 00433 * @{ 00434 */ 00435 #define LL_USART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< 0.5 stop bit */ 00436 #define LL_USART_STOPBITS_1 0x00000000U /*!< 1 stop bit */ 00437 #define LL_USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< 1.5 stop bits */ 00438 #define LL_USART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */ 00439 /** 00440 * @} 00441 */ 00442 00443 /** @defgroup USART_LL_EC_TXRX TX RX Pins Swap 00444 * @{ 00445 */ 00446 #define LL_USART_TXRX_STANDARD 0x00000000U /*!< TX/RX pins are used as defined in standard pinout */ 00447 #define LL_USART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */ 00448 /** 00449 * @} 00450 */ 00451 00452 /** @defgroup USART_LL_EC_RXPIN_LEVEL RX Pin Active Level Inversion 00453 * @{ 00454 */ 00455 #define LL_USART_RXPIN_LEVEL_STANDARD 0x00000000U /*!< RX pin signal works using the standard logic levels */ 00456 #define LL_USART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */ 00457 /** 00458 * @} 00459 */ 00460 00461 /** @defgroup USART_LL_EC_TXPIN_LEVEL TX Pin Active Level Inversion 00462 * @{ 00463 */ 00464 #define LL_USART_TXPIN_LEVEL_STANDARD 0x00000000U /*!< TX pin signal works using the standard logic levels */ 00465 #define LL_USART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */ 00466 /** 00467 * @} 00468 */ 00469 00470 /** @defgroup USART_LL_EC_BINARY_LOGIC Binary Data Inversion 00471 * @{ 00472 */ 00473 #define LL_USART_BINARY_LOGIC_POSITIVE 0x00000000U /*!< Logical data from the data register are send/received in positive/direct logic. (1=H, 0=L) */ 00474 #define LL_USART_BINARY_LOGIC_NEGATIVE USART_CR2_DATAINV /*!< Logical data from the data register are send/received in negative/inverse logic. (1=L, 0=H). The parity bit is also inverted. */ 00475 /** 00476 * @} 00477 */ 00478 00479 /** @defgroup USART_LL_EC_BITORDER Bit Order 00480 * @{ 00481 */ 00482 #define LL_USART_BITORDER_LSBFIRST 0x00000000U /*!< data is transmitted/received with data bit 0 first, following the start bit */ 00483 #define LL_USART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first, following the start bit */ 00484 /** 00485 * @} 00486 */ 00487 00488 /** @defgroup USART_LL_EC_AUTOBAUD_DETECT_ON Autobaud Detection 00489 * @{ 00490 */ 00491 #define LL_USART_AUTOBAUD_DETECT_ON_STARTBIT 0x00000000U /*!< Measurement of the start bit is used to detect the baud rate */ 00492 #define LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE USART_CR2_ABRMODE_0 /*!< Falling edge to falling edge measurement. Received frame must start with a single bit = 1 -> Frame = Start10xxxxxx */ 00493 #define LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME USART_CR2_ABRMODE_1 /*!< 0x7F frame detection */ 00494 #define LL_USART_AUTOBAUD_DETECT_ON_55_FRAME (USART_CR2_ABRMODE_1 | USART_CR2_ABRMODE_0) /*!< 0x55 frame detection */ 00495 /** 00496 * @} 00497 */ 00498 00499 /** @defgroup USART_LL_EC_ADDRESS_DETECT Address Length Detection 00500 * @{ 00501 */ 00502 #define LL_USART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit address detection method selected */ 00503 #define LL_USART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */ 00504 /** 00505 * @} 00506 */ 00507 00508 /** @defgroup USART_LL_EC_HWCONTROL Hardware Control 00509 * @{ 00510 */ 00511 #define LL_USART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */ 00512 #define LL_USART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */ 00513 #define LL_USART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */ 00514 #define LL_USART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */ 00515 /** 00516 * @} 00517 */ 00518 00519 /** @defgroup USART_LL_EC_WAKEUP_ON Wakeup Activation 00520 * @{ 00521 */ 00522 #define LL_USART_WAKEUP_ON_ADDRESS 0x00000000U /*!< Wake up active on address match */ 00523 #define LL_USART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wake up active on Start bit detection */ 00524 #define LL_USART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wake up active on RXNE */ 00525 /** 00526 * @} 00527 */ 00528 00529 /** @defgroup USART_LL_EC_IRDA_POWER IrDA Power 00530 * @{ 00531 */ 00532 #define LL_USART_IRDA_POWER_NORMAL 0x00000000U /*!< IrDA normal power mode */ 00533 #define LL_USART_IRDA_POWER_LOW USART_CR3_IRLP /*!< IrDA low power mode */ 00534 /** 00535 * @} 00536 */ 00537 00538 /** @defgroup USART_LL_EC_LINBREAK_DETECT LIN Break Detection Length 00539 * @{ 00540 */ 00541 #define LL_USART_LINBREAK_DETECT_10B 0x00000000U /*!< 10-bit break detection method selected */ 00542 #define LL_USART_LINBREAK_DETECT_11B USART_CR2_LBDL /*!< 11-bit break detection method selected */ 00543 /** 00544 * @} 00545 */ 00546 00547 /** @defgroup USART_LL_EC_DE_POLARITY Driver Enable Polarity 00548 * @{ 00549 */ 00550 #define LL_USART_DE_POLARITY_HIGH 0x00000000U /*!< DE signal is active high */ 00551 #define LL_USART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */ 00552 /** 00553 * @} 00554 */ 00555 00556 /** @defgroup USART_LL_EC_DMA_REG_DATA DMA Register Data 00557 * @{ 00558 */ 00559 #define LL_USART_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */ 00560 #define LL_USART_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */ 00561 /** 00562 * @} 00563 */ 00564 00565 /** 00566 * @} 00567 */ 00568 00569 /* Exported macro ------------------------------------------------------------*/ 00570 /** @defgroup USART_LL_Exported_Macros USART Exported Macros 00571 * @{ 00572 */ 00573 00574 /** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros 00575 * @{ 00576 */ 00577 00578 /** 00579 * @brief Write a value in USART register 00580 * @param __INSTANCE__ USART Instance 00581 * @param __REG__ Register to be written 00582 * @param __VALUE__ Value to be written in the register 00583 * @retval None 00584 */ 00585 #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 00586 00587 /** 00588 * @brief Read a value in USART register 00589 * @param __INSTANCE__ USART Instance 00590 * @param __REG__ Register to be read 00591 * @retval Register value 00592 */ 00593 #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 00594 /** 00595 * @} 00596 */ 00597 00598 /** @defgroup USART_LL_EM_Exported_Macros_Helper Exported_Macros_Helper 00599 * @{ 00600 */ 00601 00602 /** 00603 * @brief Compute USARTDIV value according to Peripheral Clock and 00604 * expected Baud Rate in 8 bits sampling mode (32 bits value of USARTDIV is returned) 00605 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance 00606 @if USART_PRESC_PRESCALER 00607 * @param __PRESCALER__ This parameter can be one of the following values: 00608 * @arg @ref LL_USART_PRESCALER_DIV1 00609 * @arg @ref LL_USART_PRESCALER_DIV2 00610 * @arg @ref LL_USART_PRESCALER_DIV4 00611 * @arg @ref LL_USART_PRESCALER_DIV6 00612 * @arg @ref LL_USART_PRESCALER_DIV8 00613 * @arg @ref LL_USART_PRESCALER_DIV10 00614 * @arg @ref LL_USART_PRESCALER_DIV12 00615 * @arg @ref LL_USART_PRESCALER_DIV16 00616 * @arg @ref LL_USART_PRESCALER_DIV32 00617 * @arg @ref LL_USART_PRESCALER_DIV64 00618 * @arg @ref LL_USART_PRESCALER_DIV128 00619 * @arg @ref LL_USART_PRESCALER_DIV256 00620 @endif 00621 * @param __BAUDRATE__ Baud rate value to achieve 00622 * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case 00623 */ 00624 #if defined(USART_PRESC_PRESCALER) 00625 #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __PRESCALER__, __BAUDRATE__) \ 00626 (((((__PERIPHCLK__)/(USART_PRESCALER_TAB[(__PRESCALER__)]))*2U)\ 00627 + ((__BAUDRATE__)/2U))/(__BAUDRATE__)) 00628 #else 00629 #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) ((((__PERIPHCLK__)*2U)\ 00630 + ((__BAUDRATE__)/2U))/(__BAUDRATE__)) 00631 #endif /* USART_PRESC_PRESCALER */ 00632 00633 /** 00634 * @brief Compute USARTDIV value according to Peripheral Clock and 00635 * expected Baud Rate in 16 bits sampling mode (32 bits value of USARTDIV is returned) 00636 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance 00637 @if USART_PRESC_PRESCALER 00638 * @param __PRESCALER__ This parameter can be one of the following values: 00639 * @arg @ref LL_USART_PRESCALER_DIV1 00640 * @arg @ref LL_USART_PRESCALER_DIV2 00641 * @arg @ref LL_USART_PRESCALER_DIV4 00642 * @arg @ref LL_USART_PRESCALER_DIV6 00643 * @arg @ref LL_USART_PRESCALER_DIV8 00644 * @arg @ref LL_USART_PRESCALER_DIV10 00645 * @arg @ref LL_USART_PRESCALER_DIV12 00646 * @arg @ref LL_USART_PRESCALER_DIV16 00647 * @arg @ref LL_USART_PRESCALER_DIV32 00648 * @arg @ref LL_USART_PRESCALER_DIV64 00649 * @arg @ref LL_USART_PRESCALER_DIV128 00650 * @arg @ref LL_USART_PRESCALER_DIV256 00651 @endif 00652 * @param __BAUDRATE__ Baud rate value to achieve 00653 * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case 00654 */ 00655 #if defined(USART_PRESC_PRESCALER) 00656 #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __PRESCALER__, __BAUDRATE__) \ 00657 ((((__PERIPHCLK__)/(USART_PRESCALER_TAB[(__PRESCALER__)]))\ 00658 + ((__BAUDRATE__)/2U))/(__BAUDRATE__)) 00659 #else 00660 #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__) + ((__BAUDRATE__)/2U))/(__BAUDRATE__)) 00661 #endif /* USART_PRESC_PRESCALER */ 00662 00663 /** 00664 * @} 00665 */ 00666 00667 /** 00668 * @} 00669 */ 00670 00671 /* Exported functions --------------------------------------------------------*/ 00672 00673 /** @defgroup USART_LL_Exported_Functions USART Exported Functions 00674 * @{ 00675 */ 00676 00677 /** @defgroup USART_LL_EF_Configuration Configuration functions 00678 * @{ 00679 */ 00680 00681 /** 00682 * @brief USART Enable 00683 * @rmtoll CR1 UE LL_USART_Enable 00684 * @param USARTx USART Instance 00685 * @retval None 00686 */ 00687 __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx) 00688 { 00689 SET_BIT(USARTx->CR1, USART_CR1_UE); 00690 } 00691 00692 /** 00693 * @brief USART Disable (all USART prescalers and outputs are disabled) 00694 * @note When USART is disabled, USART prescalers and outputs are stopped immediately, 00695 * and current operations are discarded. The configuration of the USART is kept, but all the status 00696 * flags, in the USARTx_ISR are set to their default values. 00697 * @rmtoll CR1 UE LL_USART_Disable 00698 * @param USARTx USART Instance 00699 * @retval None 00700 */ 00701 __STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx) 00702 { 00703 CLEAR_BIT(USARTx->CR1, USART_CR1_UE); 00704 } 00705 00706 /** 00707 * @brief Indicate if USART is enabled 00708 * @rmtoll CR1 UE LL_USART_IsEnabled 00709 * @param USARTx USART Instance 00710 * @retval State of bit (1 or 0). 00711 */ 00712 __STATIC_INLINE uint32_t LL_USART_IsEnabled(USART_TypeDef *USARTx) 00713 { 00714 return ((READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE)) ? 1UL : 0UL); 00715 } 00716 00717 #if defined(USART_CR1_FIFOEN) 00718 /** 00719 * @brief FIFO Mode Enable 00720 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 00721 * FIFO mode feature is supported by the USARTx instance. 00722 * @rmtoll CR1 FIFOEN LL_USART_EnableFIFO 00723 * @param USARTx USART Instance 00724 * @retval None 00725 */ 00726 __STATIC_INLINE void LL_USART_EnableFIFO(USART_TypeDef *USARTx) 00727 { 00728 SET_BIT(USARTx->CR1, USART_CR1_FIFOEN); 00729 } 00730 00731 /** 00732 * @brief FIFO Mode Disable 00733 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 00734 * FIFO mode feature is supported by the USARTx instance. 00735 * @rmtoll CR1 FIFOEN LL_USART_DisableFIFO 00736 * @param USARTx USART Instance 00737 * @retval None 00738 */ 00739 __STATIC_INLINE void LL_USART_DisableFIFO(USART_TypeDef *USARTx) 00740 { 00741 CLEAR_BIT(USARTx->CR1, USART_CR1_FIFOEN); 00742 } 00743 00744 /** 00745 * @brief Indicate if FIFO Mode is enabled 00746 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 00747 * FIFO mode feature is supported by the USARTx instance. 00748 * @rmtoll CR1 FIFOEN LL_USART_IsEnabledFIFO 00749 * @param USARTx USART Instance 00750 * @retval State of bit (1 or 0). 00751 */ 00752 __STATIC_INLINE uint32_t LL_USART_IsEnabledFIFO(USART_TypeDef *USARTx) 00753 { 00754 return ((READ_BIT(USARTx->CR1, USART_CR1_FIFOEN) == (USART_CR1_FIFOEN)) ? 1UL : 0UL); 00755 } 00756 00757 /** 00758 * @brief Configure TX FIFO Threshold 00759 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 00760 * FIFO mode feature is supported by the USARTx instance. 00761 * @rmtoll CR3 TXFTCFG LL_USART_SetTXFIFOThreshold 00762 * @param USARTx USART Instance 00763 * @param Threshold This parameter can be one of the following values: 00764 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8 00765 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4 00766 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2 00767 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4 00768 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8 00769 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8 00770 * @retval None 00771 */ 00772 __STATIC_INLINE void LL_USART_SetTXFIFOThreshold(USART_TypeDef *USARTx, uint32_t Threshold) 00773 { 00774 ATOMIC_MODIFY_REG(USARTx->CR3, USART_CR3_TXFTCFG, Threshold << USART_CR3_TXFTCFG_Pos); 00775 } 00776 00777 /** 00778 * @brief Return TX FIFO Threshold Configuration 00779 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 00780 * FIFO mode feature is supported by the USARTx instance. 00781 * @rmtoll CR3 TXFTCFG LL_USART_GetTXFIFOThreshold 00782 * @param USARTx USART Instance 00783 * @retval Returned value can be one of the following values: 00784 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8 00785 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4 00786 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2 00787 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4 00788 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8 00789 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8 00790 */ 00791 __STATIC_INLINE uint32_t LL_USART_GetTXFIFOThreshold(USART_TypeDef *USARTx) 00792 { 00793 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_TXFTCFG) >> USART_CR3_TXFTCFG_Pos); 00794 } 00795 00796 /** 00797 * @brief Configure RX FIFO Threshold 00798 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 00799 * FIFO mode feature is supported by the USARTx instance. 00800 * @rmtoll CR3 RXFTCFG LL_USART_SetRXFIFOThreshold 00801 * @param USARTx USART Instance 00802 * @param Threshold This parameter can be one of the following values: 00803 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8 00804 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4 00805 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2 00806 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4 00807 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8 00808 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8 00809 * @retval None 00810 */ 00811 __STATIC_INLINE void LL_USART_SetRXFIFOThreshold(USART_TypeDef *USARTx, uint32_t Threshold) 00812 { 00813 ATOMIC_MODIFY_REG(USARTx->CR3, USART_CR3_RXFTCFG, Threshold << USART_CR3_RXFTCFG_Pos); 00814 } 00815 00816 /** 00817 * @brief Return RX FIFO Threshold Configuration 00818 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 00819 * FIFO mode feature is supported by the USARTx instance. 00820 * @rmtoll CR3 RXFTCFG LL_USART_GetRXFIFOThreshold 00821 * @param USARTx USART Instance 00822 * @retval Returned value can be one of the following values: 00823 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8 00824 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4 00825 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2 00826 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4 00827 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8 00828 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8 00829 */ 00830 __STATIC_INLINE uint32_t LL_USART_GetRXFIFOThreshold(USART_TypeDef *USARTx) 00831 { 00832 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RXFTCFG) >> USART_CR3_RXFTCFG_Pos); 00833 } 00834 00835 /** 00836 * @brief Configure TX and RX FIFOs Threshold 00837 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 00838 * FIFO mode feature is supported by the USARTx instance. 00839 * @rmtoll CR3 TXFTCFG LL_USART_ConfigFIFOsThreshold\n 00840 * CR3 RXFTCFG LL_USART_ConfigFIFOsThreshold 00841 * @param USARTx USART Instance 00842 * @param TXThreshold This parameter can be one of the following values: 00843 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8 00844 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4 00845 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2 00846 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4 00847 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8 00848 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8 00849 * @param RXThreshold This parameter can be one of the following values: 00850 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8 00851 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4 00852 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2 00853 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4 00854 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8 00855 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8 00856 * @retval None 00857 */ 00858 __STATIC_INLINE void LL_USART_ConfigFIFOsThreshold(USART_TypeDef *USARTx, uint32_t TXThreshold, uint32_t RXThreshold) 00859 { 00860 ATOMIC_MODIFY_REG(USARTx->CR3, USART_CR3_TXFTCFG | USART_CR3_RXFTCFG, (TXThreshold << USART_CR3_TXFTCFG_Pos) | 00861 (RXThreshold << USART_CR3_RXFTCFG_Pos)); 00862 } 00863 00864 #endif /* USART_CR1_FIFOEN */ 00865 /** 00866 * @brief USART enabled in STOP Mode. 00867 * @note When this function is enabled, USART is able to wake up the MCU from Stop mode, provided that 00868 * USART clock selection is HSI or LSE in RCC. 00869 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 00870 * Wake-up from Stop mode feature is supported by the USARTx instance. 00871 * @rmtoll CR1 UESM LL_USART_EnableInStopMode 00872 * @param USARTx USART Instance 00873 * @retval None 00874 */ 00875 __STATIC_INLINE void LL_USART_EnableInStopMode(USART_TypeDef *USARTx) 00876 { 00877 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_UESM); 00878 } 00879 00880 /** 00881 * @brief USART disabled in STOP Mode. 00882 * @note When this function is disabled, USART is not able to wake up the MCU from Stop mode 00883 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 00884 * Wake-up from Stop mode feature is supported by the USARTx instance. 00885 * @rmtoll CR1 UESM LL_USART_DisableInStopMode 00886 * @param USARTx USART Instance 00887 * @retval None 00888 */ 00889 __STATIC_INLINE void LL_USART_DisableInStopMode(USART_TypeDef *USARTx) 00890 { 00891 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_UESM); 00892 } 00893 00894 /** 00895 * @brief Indicate if USART is enabled in STOP Mode (able to wake up MCU from Stop mode or not) 00896 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 00897 * Wake-up from Stop mode feature is supported by the USARTx instance. 00898 * @rmtoll CR1 UESM LL_USART_IsEnabledInStopMode 00899 * @param USARTx USART Instance 00900 * @retval State of bit (1 or 0). 00901 */ 00902 __STATIC_INLINE uint32_t LL_USART_IsEnabledInStopMode(USART_TypeDef *USARTx) 00903 { 00904 return ((READ_BIT(USARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM)) ? 1UL : 0UL); 00905 } 00906 00907 #if defined(USART_CR3_UCESM) 00908 /** 00909 * @brief USART Clock enabled in STOP Mode 00910 * @note When this function is called, USART Clock is enabled while in STOP mode 00911 * @rmtoll CR3 UCESM LL_USART_EnableClockInStopMode 00912 * @param USARTx USART Instance 00913 * @retval None 00914 */ 00915 __STATIC_INLINE void LL_USART_EnableClockInStopMode(USART_TypeDef *USARTx) 00916 { 00917 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_UCESM); 00918 } 00919 00920 /** 00921 * @brief USART clock disabled in STOP Mode 00922 * @note When this function is called, USART Clock is disabled while in STOP mode 00923 * @rmtoll CR3 UCESM LL_USART_DisableClockInStopMode 00924 * @param USARTx USART Instance 00925 * @retval None 00926 */ 00927 __STATIC_INLINE void LL_USART_DisableClockInStopMode(USART_TypeDef *USARTx) 00928 { 00929 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_UCESM); 00930 } 00931 00932 /** 00933 * @brief Indicate if USART clock is enabled in STOP Mode 00934 * @rmtoll CR3 UCESM LL_USART_IsClockEnabledInStopMode 00935 * @param USARTx USART Instance 00936 * @retval State of bit (1 or 0). 00937 */ 00938 __STATIC_INLINE uint32_t LL_USART_IsClockEnabledInStopMode(USART_TypeDef *USARTx) 00939 { 00940 return (READ_BIT(USARTx->CR3, USART_CR3_UCESM) == (USART_CR3_UCESM)); 00941 } 00942 00943 #endif /* USART_CR3_UCESM */ 00944 /** 00945 * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit) 00946 * @rmtoll CR1 RE LL_USART_EnableDirectionRx 00947 * @param USARTx USART Instance 00948 * @retval None 00949 */ 00950 __STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx) 00951 { 00952 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_RE); 00953 } 00954 00955 /** 00956 * @brief Receiver Disable 00957 * @rmtoll CR1 RE LL_USART_DisableDirectionRx 00958 * @param USARTx USART Instance 00959 * @retval None 00960 */ 00961 __STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx) 00962 { 00963 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_RE); 00964 } 00965 00966 /** 00967 * @brief Transmitter Enable 00968 * @rmtoll CR1 TE LL_USART_EnableDirectionTx 00969 * @param USARTx USART Instance 00970 * @retval None 00971 */ 00972 __STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx) 00973 { 00974 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_TE); 00975 } 00976 00977 /** 00978 * @brief Transmitter Disable 00979 * @rmtoll CR1 TE LL_USART_DisableDirectionTx 00980 * @param USARTx USART Instance 00981 * @retval None 00982 */ 00983 __STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx) 00984 { 00985 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_TE); 00986 } 00987 00988 /** 00989 * @brief Configure simultaneously enabled/disabled states 00990 * of Transmitter and Receiver 00991 * @rmtoll CR1 RE LL_USART_SetTransferDirection\n 00992 * CR1 TE LL_USART_SetTransferDirection 00993 * @param USARTx USART Instance 00994 * @param TransferDirection This parameter can be one of the following values: 00995 * @arg @ref LL_USART_DIRECTION_NONE 00996 * @arg @ref LL_USART_DIRECTION_RX 00997 * @arg @ref LL_USART_DIRECTION_TX 00998 * @arg @ref LL_USART_DIRECTION_TX_RX 00999 * @retval None 01000 */ 01001 __STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t TransferDirection) 01002 { 01003 ATOMIC_MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection); 01004 } 01005 01006 /** 01007 * @brief Return enabled/disabled states of Transmitter and Receiver 01008 * @rmtoll CR1 RE LL_USART_GetTransferDirection\n 01009 * CR1 TE LL_USART_GetTransferDirection 01010 * @param USARTx USART Instance 01011 * @retval Returned value can be one of the following values: 01012 * @arg @ref LL_USART_DIRECTION_NONE 01013 * @arg @ref LL_USART_DIRECTION_RX 01014 * @arg @ref LL_USART_DIRECTION_TX 01015 * @arg @ref LL_USART_DIRECTION_TX_RX 01016 */ 01017 __STATIC_INLINE uint32_t LL_USART_GetTransferDirection(USART_TypeDef *USARTx) 01018 { 01019 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE)); 01020 } 01021 01022 /** 01023 * @brief Configure Parity (enabled/disabled and parity mode if enabled). 01024 * @note This function selects if hardware parity control (generation and detection) is enabled or disabled. 01025 * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position 01026 * (9th or 8th bit depending on data width) and parity is checked on the received data. 01027 * @rmtoll CR1 PS LL_USART_SetParity\n 01028 * CR1 PCE LL_USART_SetParity 01029 * @param USARTx USART Instance 01030 * @param Parity This parameter can be one of the following values: 01031 * @arg @ref LL_USART_PARITY_NONE 01032 * @arg @ref LL_USART_PARITY_EVEN 01033 * @arg @ref LL_USART_PARITY_ODD 01034 * @retval None 01035 */ 01036 __STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t Parity) 01037 { 01038 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity); 01039 } 01040 01041 /** 01042 * @brief Return Parity configuration (enabled/disabled and parity mode if enabled) 01043 * @rmtoll CR1 PS LL_USART_GetParity\n 01044 * CR1 PCE LL_USART_GetParity 01045 * @param USARTx USART Instance 01046 * @retval Returned value can be one of the following values: 01047 * @arg @ref LL_USART_PARITY_NONE 01048 * @arg @ref LL_USART_PARITY_EVEN 01049 * @arg @ref LL_USART_PARITY_ODD 01050 */ 01051 __STATIC_INLINE uint32_t LL_USART_GetParity(USART_TypeDef *USARTx) 01052 { 01053 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE)); 01054 } 01055 01056 /** 01057 * @brief Set Receiver Wake Up method from Mute mode. 01058 * @rmtoll CR1 WAKE LL_USART_SetWakeUpMethod 01059 * @param USARTx USART Instance 01060 * @param Method This parameter can be one of the following values: 01061 * @arg @ref LL_USART_WAKEUP_IDLELINE 01062 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK 01063 * @retval None 01064 */ 01065 __STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method) 01066 { 01067 MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method); 01068 } 01069 01070 /** 01071 * @brief Return Receiver Wake Up method from Mute mode 01072 * @rmtoll CR1 WAKE LL_USART_GetWakeUpMethod 01073 * @param USARTx USART Instance 01074 * @retval Returned value can be one of the following values: 01075 * @arg @ref LL_USART_WAKEUP_IDLELINE 01076 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK 01077 */ 01078 __STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(USART_TypeDef *USARTx) 01079 { 01080 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE)); 01081 } 01082 01083 /** 01084 * @brief Set Word length (i.e. nb of data bits, excluding start and stop bits) 01085 * @rmtoll CR1 M0 LL_USART_SetDataWidth\n 01086 * CR1 M1 LL_USART_SetDataWidth 01087 * @param USARTx USART Instance 01088 * @param DataWidth This parameter can be one of the following values: 01089 * @arg @ref LL_USART_DATAWIDTH_7B 01090 * @arg @ref LL_USART_DATAWIDTH_8B 01091 * @arg @ref LL_USART_DATAWIDTH_9B 01092 * @retval None 01093 */ 01094 __STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth) 01095 { 01096 MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth); 01097 } 01098 01099 /** 01100 * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits) 01101 * @rmtoll CR1 M0 LL_USART_GetDataWidth\n 01102 * CR1 M1 LL_USART_GetDataWidth 01103 * @param USARTx USART Instance 01104 * @retval Returned value can be one of the following values: 01105 * @arg @ref LL_USART_DATAWIDTH_7B 01106 * @arg @ref LL_USART_DATAWIDTH_8B 01107 * @arg @ref LL_USART_DATAWIDTH_9B 01108 */ 01109 __STATIC_INLINE uint32_t LL_USART_GetDataWidth(USART_TypeDef *USARTx) 01110 { 01111 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M)); 01112 } 01113 01114 /** 01115 * @brief Allow switch between Mute Mode and Active mode 01116 * @rmtoll CR1 MME LL_USART_EnableMuteMode 01117 * @param USARTx USART Instance 01118 * @retval None 01119 */ 01120 __STATIC_INLINE void LL_USART_EnableMuteMode(USART_TypeDef *USARTx) 01121 { 01122 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_MME); 01123 } 01124 01125 /** 01126 * @brief Prevent Mute Mode use. Set Receiver in active mode permanently. 01127 * @rmtoll CR1 MME LL_USART_DisableMuteMode 01128 * @param USARTx USART Instance 01129 * @retval None 01130 */ 01131 __STATIC_INLINE void LL_USART_DisableMuteMode(USART_TypeDef *USARTx) 01132 { 01133 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_MME); 01134 } 01135 01136 /** 01137 * @brief Indicate if switch between Mute Mode and Active mode is allowed 01138 * @rmtoll CR1 MME LL_USART_IsEnabledMuteMode 01139 * @param USARTx USART Instance 01140 * @retval State of bit (1 or 0). 01141 */ 01142 __STATIC_INLINE uint32_t LL_USART_IsEnabledMuteMode(USART_TypeDef *USARTx) 01143 { 01144 return ((READ_BIT(USARTx->CR1, USART_CR1_MME) == (USART_CR1_MME)) ? 1UL : 0UL); 01145 } 01146 01147 /** 01148 * @brief Set Oversampling to 8-bit or 16-bit mode 01149 * @rmtoll CR1 OVER8 LL_USART_SetOverSampling 01150 * @param USARTx USART Instance 01151 * @param OverSampling This parameter can be one of the following values: 01152 * @arg @ref LL_USART_OVERSAMPLING_16 01153 * @arg @ref LL_USART_OVERSAMPLING_8 01154 * @retval None 01155 */ 01156 __STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling) 01157 { 01158 MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling); 01159 } 01160 01161 /** 01162 * @brief Return Oversampling mode 01163 * @rmtoll CR1 OVER8 LL_USART_GetOverSampling 01164 * @param USARTx USART Instance 01165 * @retval Returned value can be one of the following values: 01166 * @arg @ref LL_USART_OVERSAMPLING_16 01167 * @arg @ref LL_USART_OVERSAMPLING_8 01168 */ 01169 __STATIC_INLINE uint32_t LL_USART_GetOverSampling(USART_TypeDef *USARTx) 01170 { 01171 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8)); 01172 } 01173 01174 /** 01175 * @brief Configure if Clock pulse of the last data bit is output to the SCLK pin or not 01176 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 01177 * Synchronous mode is supported by the USARTx instance. 01178 * @rmtoll CR2 LBCL LL_USART_SetLastClkPulseOutput 01179 * @param USARTx USART Instance 01180 * @param LastBitClockPulse This parameter can be one of the following values: 01181 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT 01182 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT 01183 * @retval None 01184 */ 01185 __STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LastBitClockPulse) 01186 { 01187 MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LastBitClockPulse); 01188 } 01189 01190 /** 01191 * @brief Retrieve Clock pulse of the last data bit output configuration 01192 * (Last bit Clock pulse output to the SCLK pin or not) 01193 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 01194 * Synchronous mode is supported by the USARTx instance. 01195 * @rmtoll CR2 LBCL LL_USART_GetLastClkPulseOutput 01196 * @param USARTx USART Instance 01197 * @retval Returned value can be one of the following values: 01198 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT 01199 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT 01200 */ 01201 __STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(USART_TypeDef *USARTx) 01202 { 01203 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL)); 01204 } 01205 01206 /** 01207 * @brief Select the phase of the clock output on the SCLK pin in synchronous mode 01208 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 01209 * Synchronous mode is supported by the USARTx instance. 01210 * @rmtoll CR2 CPHA LL_USART_SetClockPhase 01211 * @param USARTx USART Instance 01212 * @param ClockPhase This parameter can be one of the following values: 01213 * @arg @ref LL_USART_PHASE_1EDGE 01214 * @arg @ref LL_USART_PHASE_2EDGE 01215 * @retval None 01216 */ 01217 __STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t ClockPhase) 01218 { 01219 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, ClockPhase); 01220 } 01221 01222 /** 01223 * @brief Return phase of the clock output on the SCLK pin in synchronous mode 01224 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 01225 * Synchronous mode is supported by the USARTx instance. 01226 * @rmtoll CR2 CPHA LL_USART_GetClockPhase 01227 * @param USARTx USART Instance 01228 * @retval Returned value can be one of the following values: 01229 * @arg @ref LL_USART_PHASE_1EDGE 01230 * @arg @ref LL_USART_PHASE_2EDGE 01231 */ 01232 __STATIC_INLINE uint32_t LL_USART_GetClockPhase(USART_TypeDef *USARTx) 01233 { 01234 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA)); 01235 } 01236 01237 /** 01238 * @brief Select the polarity of the clock output on the SCLK pin in synchronous mode 01239 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 01240 * Synchronous mode is supported by the USARTx instance. 01241 * @rmtoll CR2 CPOL LL_USART_SetClockPolarity 01242 * @param USARTx USART Instance 01243 * @param ClockPolarity This parameter can be one of the following values: 01244 * @arg @ref LL_USART_POLARITY_LOW 01245 * @arg @ref LL_USART_POLARITY_HIGH 01246 * @retval None 01247 */ 01248 __STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t ClockPolarity) 01249 { 01250 MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, ClockPolarity); 01251 } 01252 01253 /** 01254 * @brief Return polarity of the clock output on the SCLK pin in synchronous mode 01255 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 01256 * Synchronous mode is supported by the USARTx instance. 01257 * @rmtoll CR2 CPOL LL_USART_GetClockPolarity 01258 * @param USARTx USART Instance 01259 * @retval Returned value can be one of the following values: 01260 * @arg @ref LL_USART_POLARITY_LOW 01261 * @arg @ref LL_USART_POLARITY_HIGH 01262 */ 01263 __STATIC_INLINE uint32_t LL_USART_GetClockPolarity(USART_TypeDef *USARTx) 01264 { 01265 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL)); 01266 } 01267 01268 /** 01269 * @brief Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse) 01270 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 01271 * Synchronous mode is supported by the USARTx instance. 01272 * @note Call of this function is equivalent to following function call sequence : 01273 * - Clock Phase configuration using @ref LL_USART_SetClockPhase() function 01274 * - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function 01275 * - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function 01276 * @rmtoll CR2 CPHA LL_USART_ConfigClock\n 01277 * CR2 CPOL LL_USART_ConfigClock\n 01278 * CR2 LBCL LL_USART_ConfigClock 01279 * @param USARTx USART Instance 01280 * @param Phase This parameter can be one of the following values: 01281 * @arg @ref LL_USART_PHASE_1EDGE 01282 * @arg @ref LL_USART_PHASE_2EDGE 01283 * @param Polarity This parameter can be one of the following values: 01284 * @arg @ref LL_USART_POLARITY_LOW 01285 * @arg @ref LL_USART_POLARITY_HIGH 01286 * @param LBCPOutput This parameter can be one of the following values: 01287 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT 01288 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT 01289 * @retval None 01290 */ 01291 __STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput) 01292 { 01293 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput); 01294 } 01295 01296 #if defined(USART_PRESC_PRESCALER) 01297 /** 01298 * @brief Configure Clock source prescaler for baudrate generator and oversampling 01299 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 01300 * FIFO mode feature is supported by the USARTx instance. 01301 * @rmtoll PRESC PRESCALER LL_USART_SetPrescaler 01302 * @param USARTx USART Instance 01303 * @param PrescalerValue This parameter can be one of the following values: 01304 * @arg @ref LL_USART_PRESCALER_DIV1 01305 * @arg @ref LL_USART_PRESCALER_DIV2 01306 * @arg @ref LL_USART_PRESCALER_DIV4 01307 * @arg @ref LL_USART_PRESCALER_DIV6 01308 * @arg @ref LL_USART_PRESCALER_DIV8 01309 * @arg @ref LL_USART_PRESCALER_DIV10 01310 * @arg @ref LL_USART_PRESCALER_DIV12 01311 * @arg @ref LL_USART_PRESCALER_DIV16 01312 * @arg @ref LL_USART_PRESCALER_DIV32 01313 * @arg @ref LL_USART_PRESCALER_DIV64 01314 * @arg @ref LL_USART_PRESCALER_DIV128 01315 * @arg @ref LL_USART_PRESCALER_DIV256 01316 * @retval None 01317 */ 01318 __STATIC_INLINE void LL_USART_SetPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) 01319 { 01320 MODIFY_REG(USARTx->PRESC, USART_PRESC_PRESCALER, (uint16_t)PrescalerValue); 01321 } 01322 01323 /** 01324 * @brief Retrieve the Clock source prescaler for baudrate generator and oversampling 01325 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 01326 * FIFO mode feature is supported by the USARTx instance. 01327 * @rmtoll PRESC PRESCALER LL_USART_GetPrescaler 01328 * @param USARTx USART Instance 01329 * @retval Returned value can be one of the following values: 01330 * @arg @ref LL_USART_PRESCALER_DIV1 01331 * @arg @ref LL_USART_PRESCALER_DIV2 01332 * @arg @ref LL_USART_PRESCALER_DIV4 01333 * @arg @ref LL_USART_PRESCALER_DIV6 01334 * @arg @ref LL_USART_PRESCALER_DIV8 01335 * @arg @ref LL_USART_PRESCALER_DIV10 01336 * @arg @ref LL_USART_PRESCALER_DIV12 01337 * @arg @ref LL_USART_PRESCALER_DIV16 01338 * @arg @ref LL_USART_PRESCALER_DIV32 01339 * @arg @ref LL_USART_PRESCALER_DIV64 01340 * @arg @ref LL_USART_PRESCALER_DIV128 01341 * @arg @ref LL_USART_PRESCALER_DIV256 01342 */ 01343 __STATIC_INLINE uint32_t LL_USART_GetPrescaler(USART_TypeDef *USARTx) 01344 { 01345 return (uint32_t)(READ_BIT(USARTx->PRESC, USART_PRESC_PRESCALER)); 01346 } 01347 01348 #endif /* USART_PRESC_PRESCALER */ 01349 /** 01350 * @brief Enable Clock output on SCLK pin 01351 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 01352 * Synchronous mode is supported by the USARTx instance. 01353 * @rmtoll CR2 CLKEN LL_USART_EnableSCLKOutput 01354 * @param USARTx USART Instance 01355 * @retval None 01356 */ 01357 __STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx) 01358 { 01359 SET_BIT(USARTx->CR2, USART_CR2_CLKEN); 01360 } 01361 01362 /** 01363 * @brief Disable Clock output on SCLK pin 01364 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 01365 * Synchronous mode is supported by the USARTx instance. 01366 * @rmtoll CR2 CLKEN LL_USART_DisableSCLKOutput 01367 * @param USARTx USART Instance 01368 * @retval None 01369 */ 01370 __STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx) 01371 { 01372 CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN); 01373 } 01374 01375 /** 01376 * @brief Indicate if Clock output on SCLK pin is enabled 01377 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 01378 * Synchronous mode is supported by the USARTx instance. 01379 * @rmtoll CR2 CLKEN LL_USART_IsEnabledSCLKOutput 01380 * @param USARTx USART Instance 01381 * @retval State of bit (1 or 0). 01382 */ 01383 __STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(USART_TypeDef *USARTx) 01384 { 01385 return ((READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN)) ? 1UL : 0UL); 01386 } 01387 01388 /** 01389 * @brief Set the length of the stop bits 01390 * @rmtoll CR2 STOP LL_USART_SetStopBitsLength 01391 * @param USARTx USART Instance 01392 * @param StopBits This parameter can be one of the following values: 01393 * @arg @ref LL_USART_STOPBITS_0_5 01394 * @arg @ref LL_USART_STOPBITS_1 01395 * @arg @ref LL_USART_STOPBITS_1_5 01396 * @arg @ref LL_USART_STOPBITS_2 01397 * @retval None 01398 */ 01399 __STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits) 01400 { 01401 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits); 01402 } 01403 01404 /** 01405 * @brief Retrieve the length of the stop bits 01406 * @rmtoll CR2 STOP LL_USART_GetStopBitsLength 01407 * @param USARTx USART Instance 01408 * @retval Returned value can be one of the following values: 01409 * @arg @ref LL_USART_STOPBITS_0_5 01410 * @arg @ref LL_USART_STOPBITS_1 01411 * @arg @ref LL_USART_STOPBITS_1_5 01412 * @arg @ref LL_USART_STOPBITS_2 01413 */ 01414 __STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(USART_TypeDef *USARTx) 01415 { 01416 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP)); 01417 } 01418 01419 /** 01420 * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits) 01421 * @note Call of this function is equivalent to following function call sequence : 01422 * - Data Width configuration using @ref LL_USART_SetDataWidth() function 01423 * - Parity Control and mode configuration using @ref LL_USART_SetParity() function 01424 * - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function 01425 * @rmtoll CR1 PS LL_USART_ConfigCharacter\n 01426 * CR1 PCE LL_USART_ConfigCharacter\n 01427 * CR1 M0 LL_USART_ConfigCharacter\n 01428 * CR1 M1 LL_USART_ConfigCharacter\n 01429 * CR2 STOP LL_USART_ConfigCharacter 01430 * @param USARTx USART Instance 01431 * @param DataWidth This parameter can be one of the following values: 01432 * @arg @ref LL_USART_DATAWIDTH_7B 01433 * @arg @ref LL_USART_DATAWIDTH_8B 01434 * @arg @ref LL_USART_DATAWIDTH_9B 01435 * @param Parity This parameter can be one of the following values: 01436 * @arg @ref LL_USART_PARITY_NONE 01437 * @arg @ref LL_USART_PARITY_EVEN 01438 * @arg @ref LL_USART_PARITY_ODD 01439 * @param StopBits This parameter can be one of the following values: 01440 * @arg @ref LL_USART_STOPBITS_0_5 01441 * @arg @ref LL_USART_STOPBITS_1 01442 * @arg @ref LL_USART_STOPBITS_1_5 01443 * @arg @ref LL_USART_STOPBITS_2 01444 * @retval None 01445 */ 01446 __STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t Parity, 01447 uint32_t StopBits) 01448 { 01449 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth); 01450 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits); 01451 } 01452 01453 /** 01454 * @brief Configure TX/RX pins swapping setting. 01455 * @rmtoll CR2 SWAP LL_USART_SetTXRXSwap 01456 * @param USARTx USART Instance 01457 * @param SwapConfig This parameter can be one of the following values: 01458 * @arg @ref LL_USART_TXRX_STANDARD 01459 * @arg @ref LL_USART_TXRX_SWAPPED 01460 * @retval None 01461 */ 01462 __STATIC_INLINE void LL_USART_SetTXRXSwap(USART_TypeDef *USARTx, uint32_t SwapConfig) 01463 { 01464 MODIFY_REG(USARTx->CR2, USART_CR2_SWAP, SwapConfig); 01465 } 01466 01467 /** 01468 * @brief Retrieve TX/RX pins swapping configuration. 01469 * @rmtoll CR2 SWAP LL_USART_GetTXRXSwap 01470 * @param USARTx USART Instance 01471 * @retval Returned value can be one of the following values: 01472 * @arg @ref LL_USART_TXRX_STANDARD 01473 * @arg @ref LL_USART_TXRX_SWAPPED 01474 */ 01475 __STATIC_INLINE uint32_t LL_USART_GetTXRXSwap(USART_TypeDef *USARTx) 01476 { 01477 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_SWAP)); 01478 } 01479 01480 /** 01481 * @brief Configure RX pin active level logic 01482 * @rmtoll CR2 RXINV LL_USART_SetRXPinLevel 01483 * @param USARTx USART Instance 01484 * @param PinInvMethod This parameter can be one of the following values: 01485 * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD 01486 * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED 01487 * @retval None 01488 */ 01489 __STATIC_INLINE void LL_USART_SetRXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod) 01490 { 01491 MODIFY_REG(USARTx->CR2, USART_CR2_RXINV, PinInvMethod); 01492 } 01493 01494 /** 01495 * @brief Retrieve RX pin active level logic configuration 01496 * @rmtoll CR2 RXINV LL_USART_GetRXPinLevel 01497 * @param USARTx USART Instance 01498 * @retval Returned value can be one of the following values: 01499 * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD 01500 * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED 01501 */ 01502 __STATIC_INLINE uint32_t LL_USART_GetRXPinLevel(USART_TypeDef *USARTx) 01503 { 01504 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_RXINV)); 01505 } 01506 01507 /** 01508 * @brief Configure TX pin active level logic 01509 * @rmtoll CR2 TXINV LL_USART_SetTXPinLevel 01510 * @param USARTx USART Instance 01511 * @param PinInvMethod This parameter can be one of the following values: 01512 * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD 01513 * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED 01514 * @retval None 01515 */ 01516 __STATIC_INLINE void LL_USART_SetTXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod) 01517 { 01518 MODIFY_REG(USARTx->CR2, USART_CR2_TXINV, PinInvMethod); 01519 } 01520 01521 /** 01522 * @brief Retrieve TX pin active level logic configuration 01523 * @rmtoll CR2 TXINV LL_USART_GetTXPinLevel 01524 * @param USARTx USART Instance 01525 * @retval Returned value can be one of the following values: 01526 * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD 01527 * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED 01528 */ 01529 __STATIC_INLINE uint32_t LL_USART_GetTXPinLevel(USART_TypeDef *USARTx) 01530 { 01531 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_TXINV)); 01532 } 01533 01534 /** 01535 * @brief Configure Binary data logic. 01536 * @note Allow to define how Logical data from the data register are send/received : 01537 * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H) 01538 * @rmtoll CR2 DATAINV LL_USART_SetBinaryDataLogic 01539 * @param USARTx USART Instance 01540 * @param DataLogic This parameter can be one of the following values: 01541 * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE 01542 * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE 01543 * @retval None 01544 */ 01545 __STATIC_INLINE void LL_USART_SetBinaryDataLogic(USART_TypeDef *USARTx, uint32_t DataLogic) 01546 { 01547 MODIFY_REG(USARTx->CR2, USART_CR2_DATAINV, DataLogic); 01548 } 01549 01550 /** 01551 * @brief Retrieve Binary data configuration 01552 * @rmtoll CR2 DATAINV LL_USART_GetBinaryDataLogic 01553 * @param USARTx USART Instance 01554 * @retval Returned value can be one of the following values: 01555 * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE 01556 * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE 01557 */ 01558 __STATIC_INLINE uint32_t LL_USART_GetBinaryDataLogic(USART_TypeDef *USARTx) 01559 { 01560 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_DATAINV)); 01561 } 01562 01563 /** 01564 * @brief Configure transfer bit order (either Less or Most Significant Bit First) 01565 * @note MSB First means data is transmitted/received with the MSB first, following the start bit. 01566 * LSB First means data is transmitted/received with data bit 0 first, following the start bit. 01567 * @rmtoll CR2 MSBFIRST LL_USART_SetTransferBitOrder 01568 * @param USARTx USART Instance 01569 * @param BitOrder This parameter can be one of the following values: 01570 * @arg @ref LL_USART_BITORDER_LSBFIRST 01571 * @arg @ref LL_USART_BITORDER_MSBFIRST 01572 * @retval None 01573 */ 01574 __STATIC_INLINE void LL_USART_SetTransferBitOrder(USART_TypeDef *USARTx, uint32_t BitOrder) 01575 { 01576 MODIFY_REG(USARTx->CR2, USART_CR2_MSBFIRST, BitOrder); 01577 } 01578 01579 /** 01580 * @brief Return transfer bit order (either Less or Most Significant Bit First) 01581 * @note MSB First means data is transmitted/received with the MSB first, following the start bit. 01582 * LSB First means data is transmitted/received with data bit 0 first, following the start bit. 01583 * @rmtoll CR2 MSBFIRST LL_USART_GetTransferBitOrder 01584 * @param USARTx USART Instance 01585 * @retval Returned value can be one of the following values: 01586 * @arg @ref LL_USART_BITORDER_LSBFIRST 01587 * @arg @ref LL_USART_BITORDER_MSBFIRST 01588 */ 01589 __STATIC_INLINE uint32_t LL_USART_GetTransferBitOrder(USART_TypeDef *USARTx) 01590 { 01591 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_MSBFIRST)); 01592 } 01593 01594 /** 01595 * @brief Enable Auto Baud-Rate Detection 01596 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 01597 * Auto Baud Rate detection feature is supported by the USARTx instance. 01598 * @rmtoll CR2 ABREN LL_USART_EnableAutoBaudRate 01599 * @param USARTx USART Instance 01600 * @retval None 01601 */ 01602 __STATIC_INLINE void LL_USART_EnableAutoBaudRate(USART_TypeDef *USARTx) 01603 { 01604 SET_BIT(USARTx->CR2, USART_CR2_ABREN); 01605 } 01606 01607 /** 01608 * @brief Disable Auto Baud-Rate Detection 01609 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 01610 * Auto Baud Rate detection feature is supported by the USARTx instance. 01611 * @rmtoll CR2 ABREN LL_USART_DisableAutoBaudRate 01612 * @param USARTx USART Instance 01613 * @retval None 01614 */ 01615 __STATIC_INLINE void LL_USART_DisableAutoBaudRate(USART_TypeDef *USARTx) 01616 { 01617 CLEAR_BIT(USARTx->CR2, USART_CR2_ABREN); 01618 } 01619 01620 /** 01621 * @brief Indicate if Auto Baud-Rate Detection mechanism is enabled 01622 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 01623 * Auto Baud Rate detection feature is supported by the USARTx instance. 01624 * @rmtoll CR2 ABREN LL_USART_IsEnabledAutoBaud 01625 * @param USARTx USART Instance 01626 * @retval State of bit (1 or 0). 01627 */ 01628 __STATIC_INLINE uint32_t LL_USART_IsEnabledAutoBaud(USART_TypeDef *USARTx) 01629 { 01630 return ((READ_BIT(USARTx->CR2, USART_CR2_ABREN) == (USART_CR2_ABREN)) ? 1UL : 0UL); 01631 } 01632 01633 /** 01634 * @brief Set Auto Baud-Rate mode bits 01635 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 01636 * Auto Baud Rate detection feature is supported by the USARTx instance. 01637 * @rmtoll CR2 ABRMODE LL_USART_SetAutoBaudRateMode 01638 * @param USARTx USART Instance 01639 * @param AutoBaudRateMode This parameter can be one of the following values: 01640 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT 01641 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE 01642 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME 01643 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME 01644 * @retval None 01645 */ 01646 __STATIC_INLINE void LL_USART_SetAutoBaudRateMode(USART_TypeDef *USARTx, uint32_t AutoBaudRateMode) 01647 { 01648 MODIFY_REG(USARTx->CR2, USART_CR2_ABRMODE, AutoBaudRateMode); 01649 } 01650 01651 /** 01652 * @brief Return Auto Baud-Rate mode 01653 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 01654 * Auto Baud Rate detection feature is supported by the USARTx instance. 01655 * @rmtoll CR2 ABRMODE LL_USART_GetAutoBaudRateMode 01656 * @param USARTx USART Instance 01657 * @retval Returned value can be one of the following values: 01658 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT 01659 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE 01660 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME 01661 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME 01662 */ 01663 __STATIC_INLINE uint32_t LL_USART_GetAutoBaudRateMode(USART_TypeDef *USARTx) 01664 { 01665 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ABRMODE)); 01666 } 01667 01668 /** 01669 * @brief Enable Receiver Timeout 01670 * @rmtoll CR2 RTOEN LL_USART_EnableRxTimeout 01671 * @param USARTx USART Instance 01672 * @retval None 01673 */ 01674 __STATIC_INLINE void LL_USART_EnableRxTimeout(USART_TypeDef *USARTx) 01675 { 01676 SET_BIT(USARTx->CR2, USART_CR2_RTOEN); 01677 } 01678 01679 /** 01680 * @brief Disable Receiver Timeout 01681 * @rmtoll CR2 RTOEN LL_USART_DisableRxTimeout 01682 * @param USARTx USART Instance 01683 * @retval None 01684 */ 01685 __STATIC_INLINE void LL_USART_DisableRxTimeout(USART_TypeDef *USARTx) 01686 { 01687 CLEAR_BIT(USARTx->CR2, USART_CR2_RTOEN); 01688 } 01689 01690 /** 01691 * @brief Indicate if Receiver Timeout feature is enabled 01692 * @rmtoll CR2 RTOEN LL_USART_IsEnabledRxTimeout 01693 * @param USARTx USART Instance 01694 * @retval State of bit (1 or 0). 01695 */ 01696 __STATIC_INLINE uint32_t LL_USART_IsEnabledRxTimeout(USART_TypeDef *USARTx) 01697 { 01698 return ((READ_BIT(USARTx->CR2, USART_CR2_RTOEN) == (USART_CR2_RTOEN)) ? 1UL : 0UL); 01699 } 01700 01701 /** 01702 * @brief Set Address of the USART node. 01703 * @note This is used in multiprocessor communication during Mute mode or Stop mode, 01704 * for wake up with address mark detection. 01705 * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7. 01706 * (b7-b4 should be set to 0) 01707 * 8bits address node is used when 7-bit Address Detection is selected in ADDM7. 01708 * (This is used in multiprocessor communication during Mute mode or Stop mode, 01709 * for wake up with 7-bit address mark detection. 01710 * The MSB of the character sent by the transmitter should be equal to 1. 01711 * It may also be used for character detection during normal reception, 01712 * Mute mode inactive (for example, end of block detection in ModBus protocol). 01713 * In this case, the whole received character (8-bit) is compared to the ADD[7:0] 01714 * value and CMF flag is set on match) 01715 * @rmtoll CR2 ADD LL_USART_ConfigNodeAddress\n 01716 * CR2 ADDM7 LL_USART_ConfigNodeAddress 01717 * @param USARTx USART Instance 01718 * @param AddressLen This parameter can be one of the following values: 01719 * @arg @ref LL_USART_ADDRESS_DETECT_4B 01720 * @arg @ref LL_USART_ADDRESS_DETECT_7B 01721 * @param NodeAddress 4 or 7 bit Address of the USART node. 01722 * @retval None 01723 */ 01724 __STATIC_INLINE void LL_USART_ConfigNodeAddress(USART_TypeDef *USARTx, uint32_t AddressLen, uint32_t NodeAddress) 01725 { 01726 MODIFY_REG(USARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7, 01727 (uint32_t)(AddressLen | (NodeAddress << USART_CR2_ADD_Pos))); 01728 } 01729 01730 /** 01731 * @brief Return 8 bit Address of the USART node as set in ADD field of CR2. 01732 * @note If 4-bit Address Detection is selected in ADDM7, 01733 * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant) 01734 * If 7-bit Address Detection is selected in ADDM7, 01735 * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant) 01736 * @rmtoll CR2 ADD LL_USART_GetNodeAddress 01737 * @param USARTx USART Instance 01738 * @retval Address of the USART node (Value between Min_Data=0 and Max_Data=255) 01739 */ 01740 __STATIC_INLINE uint32_t LL_USART_GetNodeAddress(USART_TypeDef *USARTx) 01741 { 01742 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD) >> USART_CR2_ADD_Pos); 01743 } 01744 01745 /** 01746 * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit) 01747 * @rmtoll CR2 ADDM7 LL_USART_GetNodeAddressLen 01748 * @param USARTx USART Instance 01749 * @retval Returned value can be one of the following values: 01750 * @arg @ref LL_USART_ADDRESS_DETECT_4B 01751 * @arg @ref LL_USART_ADDRESS_DETECT_7B 01752 */ 01753 __STATIC_INLINE uint32_t LL_USART_GetNodeAddressLen(USART_TypeDef *USARTx) 01754 { 01755 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADDM7)); 01756 } 01757 01758 /** 01759 * @brief Enable RTS HW Flow Control 01760 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 01761 * Hardware Flow control feature is supported by the USARTx instance. 01762 * @rmtoll CR3 RTSE LL_USART_EnableRTSHWFlowCtrl 01763 * @param USARTx USART Instance 01764 * @retval None 01765 */ 01766 __STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx) 01767 { 01768 SET_BIT(USARTx->CR3, USART_CR3_RTSE); 01769 } 01770 01771 /** 01772 * @brief Disable RTS HW Flow Control 01773 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 01774 * Hardware Flow control feature is supported by the USARTx instance. 01775 * @rmtoll CR3 RTSE LL_USART_DisableRTSHWFlowCtrl 01776 * @param USARTx USART Instance 01777 * @retval None 01778 */ 01779 __STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx) 01780 { 01781 CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE); 01782 } 01783 01784 /** 01785 * @brief Enable CTS HW Flow Control 01786 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 01787 * Hardware Flow control feature is supported by the USARTx instance. 01788 * @rmtoll CR3 CTSE LL_USART_EnableCTSHWFlowCtrl 01789 * @param USARTx USART Instance 01790 * @retval None 01791 */ 01792 __STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx) 01793 { 01794 SET_BIT(USARTx->CR3, USART_CR3_CTSE); 01795 } 01796 01797 /** 01798 * @brief Disable CTS HW Flow Control 01799 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 01800 * Hardware Flow control feature is supported by the USARTx instance. 01801 * @rmtoll CR3 CTSE LL_USART_DisableCTSHWFlowCtrl 01802 * @param USARTx USART Instance 01803 * @retval None 01804 */ 01805 __STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx) 01806 { 01807 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE); 01808 } 01809 01810 /** 01811 * @brief Configure HW Flow Control mode (both CTS and RTS) 01812 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 01813 * Hardware Flow control feature is supported by the USARTx instance. 01814 * @rmtoll CR3 RTSE LL_USART_SetHWFlowCtrl\n 01815 * CR3 CTSE LL_USART_SetHWFlowCtrl 01816 * @param USARTx USART Instance 01817 * @param HardwareFlowControl This parameter can be one of the following values: 01818 * @arg @ref LL_USART_HWCONTROL_NONE 01819 * @arg @ref LL_USART_HWCONTROL_RTS 01820 * @arg @ref LL_USART_HWCONTROL_CTS 01821 * @arg @ref LL_USART_HWCONTROL_RTS_CTS 01822 * @retval None 01823 */ 01824 __STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HardwareFlowControl) 01825 { 01826 MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl); 01827 } 01828 01829 /** 01830 * @brief Return HW Flow Control configuration (both CTS and RTS) 01831 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 01832 * Hardware Flow control feature is supported by the USARTx instance. 01833 * @rmtoll CR3 RTSE LL_USART_GetHWFlowCtrl\n 01834 * CR3 CTSE LL_USART_GetHWFlowCtrl 01835 * @param USARTx USART Instance 01836 * @retval Returned value can be one of the following values: 01837 * @arg @ref LL_USART_HWCONTROL_NONE 01838 * @arg @ref LL_USART_HWCONTROL_RTS 01839 * @arg @ref LL_USART_HWCONTROL_CTS 01840 * @arg @ref LL_USART_HWCONTROL_RTS_CTS 01841 */ 01842 __STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(USART_TypeDef *USARTx) 01843 { 01844 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE)); 01845 } 01846 01847 /** 01848 * @brief Enable One bit sampling method 01849 * @rmtoll CR3 ONEBIT LL_USART_EnableOneBitSamp 01850 * @param USARTx USART Instance 01851 * @retval None 01852 */ 01853 __STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx) 01854 { 01855 SET_BIT(USARTx->CR3, USART_CR3_ONEBIT); 01856 } 01857 01858 /** 01859 * @brief Disable One bit sampling method 01860 * @rmtoll CR3 ONEBIT LL_USART_DisableOneBitSamp 01861 * @param USARTx USART Instance 01862 * @retval None 01863 */ 01864 __STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx) 01865 { 01866 CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT); 01867 } 01868 01869 /** 01870 * @brief Indicate if One bit sampling method is enabled 01871 * @rmtoll CR3 ONEBIT LL_USART_IsEnabledOneBitSamp 01872 * @param USARTx USART Instance 01873 * @retval State of bit (1 or 0). 01874 */ 01875 __STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(USART_TypeDef *USARTx) 01876 { 01877 return ((READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT)) ? 1UL : 0UL); 01878 } 01879 01880 /** 01881 * @brief Enable Overrun detection 01882 * @rmtoll CR3 OVRDIS LL_USART_EnableOverrunDetect 01883 * @param USARTx USART Instance 01884 * @retval None 01885 */ 01886 __STATIC_INLINE void LL_USART_EnableOverrunDetect(USART_TypeDef *USARTx) 01887 { 01888 CLEAR_BIT(USARTx->CR3, USART_CR3_OVRDIS); 01889 } 01890 01891 /** 01892 * @brief Disable Overrun detection 01893 * @rmtoll CR3 OVRDIS LL_USART_DisableOverrunDetect 01894 * @param USARTx USART Instance 01895 * @retval None 01896 */ 01897 __STATIC_INLINE void LL_USART_DisableOverrunDetect(USART_TypeDef *USARTx) 01898 { 01899 SET_BIT(USARTx->CR3, USART_CR3_OVRDIS); 01900 } 01901 01902 /** 01903 * @brief Indicate if Overrun detection is enabled 01904 * @rmtoll CR3 OVRDIS LL_USART_IsEnabledOverrunDetect 01905 * @param USARTx USART Instance 01906 * @retval State of bit (1 or 0). 01907 */ 01908 __STATIC_INLINE uint32_t LL_USART_IsEnabledOverrunDetect(USART_TypeDef *USARTx) 01909 { 01910 return ((READ_BIT(USARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS) ? 1UL : 0UL); 01911 } 01912 01913 /** 01914 * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits) 01915 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 01916 * Wake-up from Stop mode feature is supported by the USARTx instance. 01917 * @rmtoll CR3 WUS LL_USART_SetWKUPType 01918 * @param USARTx USART Instance 01919 * @param Type This parameter can be one of the following values: 01920 * @arg @ref LL_USART_WAKEUP_ON_ADDRESS 01921 * @arg @ref LL_USART_WAKEUP_ON_STARTBIT 01922 * @arg @ref LL_USART_WAKEUP_ON_RXNE 01923 * @retval None 01924 */ 01925 __STATIC_INLINE void LL_USART_SetWKUPType(USART_TypeDef *USARTx, uint32_t Type) 01926 { 01927 MODIFY_REG(USARTx->CR3, USART_CR3_WUS, Type); 01928 } 01929 01930 /** 01931 * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits) 01932 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 01933 * Wake-up from Stop mode feature is supported by the USARTx instance. 01934 * @rmtoll CR3 WUS LL_USART_GetWKUPType 01935 * @param USARTx USART Instance 01936 * @retval Returned value can be one of the following values: 01937 * @arg @ref LL_USART_WAKEUP_ON_ADDRESS 01938 * @arg @ref LL_USART_WAKEUP_ON_STARTBIT 01939 * @arg @ref LL_USART_WAKEUP_ON_RXNE 01940 */ 01941 __STATIC_INLINE uint32_t LL_USART_GetWKUPType(USART_TypeDef *USARTx) 01942 { 01943 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_WUS)); 01944 } 01945 01946 /** 01947 * @brief Configure USART BRR register for achieving expected Baud Rate value. 01948 * @note Compute and set USARTDIV value in BRR Register (full BRR content) 01949 * according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values 01950 * @note Peripheral clock and Baud rate values provided as function parameters should be valid 01951 * (Baud rate value != 0) 01952 * @note In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d. 01953 * @rmtoll BRR BRR LL_USART_SetBaudRate 01954 * @param USARTx USART Instance 01955 * @param PeriphClk Peripheral Clock 01956 @if USART_PRESC_PRESCALER 01957 * @param PrescalerValue This parameter can be one of the following values: 01958 * @arg @ref LL_USART_PRESCALER_DIV1 01959 * @arg @ref LL_USART_PRESCALER_DIV2 01960 * @arg @ref LL_USART_PRESCALER_DIV4 01961 * @arg @ref LL_USART_PRESCALER_DIV6 01962 * @arg @ref LL_USART_PRESCALER_DIV8 01963 * @arg @ref LL_USART_PRESCALER_DIV10 01964 * @arg @ref LL_USART_PRESCALER_DIV12 01965 * @arg @ref LL_USART_PRESCALER_DIV16 01966 * @arg @ref LL_USART_PRESCALER_DIV32 01967 * @arg @ref LL_USART_PRESCALER_DIV64 01968 * @arg @ref LL_USART_PRESCALER_DIV128 01969 * @arg @ref LL_USART_PRESCALER_DIV256 01970 @endif 01971 * @param OverSampling This parameter can be one of the following values: 01972 * @arg @ref LL_USART_OVERSAMPLING_16 01973 * @arg @ref LL_USART_OVERSAMPLING_8 01974 * @param BaudRate Baud Rate 01975 * @retval None 01976 */ 01977 #if defined(USART_PRESC_PRESCALER) 01978 __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t PrescalerValue, 01979 uint32_t OverSampling, 01980 uint32_t BaudRate) 01981 #else 01982 __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling, 01983 uint32_t BaudRate) 01984 #endif /* USART_PRESC_PRESCALER */ 01985 { 01986 uint32_t usartdiv; 01987 uint32_t brrtemp; 01988 01989 #if defined(USART_PRESC_PRESCALER) 01990 if (PrescalerValue > LL_USART_PRESCALER_DIV256) 01991 { 01992 /* Do not overstep the size of USART_PRESCALER_TAB */ 01993 } 01994 else if (BaudRate == 0U) 01995 { 01996 /* Can Not divide per 0 */ 01997 } 01998 else if (OverSampling == LL_USART_OVERSAMPLING_8) 01999 #else 02000 if (OverSampling == LL_USART_OVERSAMPLING_8) 02001 #endif /* USART_PRESC_PRESCALER */ 02002 { 02003 #if defined(USART_PRESC_PRESCALER) 02004 usartdiv = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, (uint8_t)PrescalerValue, BaudRate)); 02005 #else 02006 usartdiv = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, BaudRate)); 02007 #endif /* USART_PRESC_PRESCALER */ 02008 brrtemp = usartdiv & 0xFFF0U; 02009 brrtemp |= (uint16_t)((usartdiv & (uint16_t)0x000FU) >> 1U); 02010 USARTx->BRR = brrtemp; 02011 } 02012 else 02013 { 02014 #if defined(USART_PRESC_PRESCALER) 02015 USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, (uint8_t)PrescalerValue, BaudRate)); 02016 #else 02017 USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate)); 02018 #endif /* USART_PRESC_PRESCALER */ 02019 } 02020 } 02021 02022 /** 02023 * @brief Return current Baud Rate value, according to USARTDIV present in BRR register 02024 * (full BRR content), and to used Peripheral Clock and Oversampling mode values 02025 * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned. 02026 * @note In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d. 02027 * @rmtoll BRR BRR LL_USART_GetBaudRate 02028 * @param USARTx USART Instance 02029 * @param PeriphClk Peripheral Clock 02030 @if USART_PRESC_PRESCALER 02031 * @param PrescalerValue This parameter can be one of the following values: 02032 * @arg @ref LL_USART_PRESCALER_DIV1 02033 * @arg @ref LL_USART_PRESCALER_DIV2 02034 * @arg @ref LL_USART_PRESCALER_DIV4 02035 * @arg @ref LL_USART_PRESCALER_DIV6 02036 * @arg @ref LL_USART_PRESCALER_DIV8 02037 * @arg @ref LL_USART_PRESCALER_DIV10 02038 * @arg @ref LL_USART_PRESCALER_DIV12 02039 * @arg @ref LL_USART_PRESCALER_DIV16 02040 * @arg @ref LL_USART_PRESCALER_DIV32 02041 * @arg @ref LL_USART_PRESCALER_DIV64 02042 * @arg @ref LL_USART_PRESCALER_DIV128 02043 * @arg @ref LL_USART_PRESCALER_DIV256 02044 @endif 02045 * @param OverSampling This parameter can be one of the following values: 02046 * @arg @ref LL_USART_OVERSAMPLING_16 02047 * @arg @ref LL_USART_OVERSAMPLING_8 02048 * @retval Baud Rate 02049 */ 02050 #if defined(USART_PRESC_PRESCALER) 02051 __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t PrescalerValue, 02052 uint32_t OverSampling) 02053 #else 02054 __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling) 02055 #endif /* USART_PRESC_PRESCALER */ 02056 { 02057 uint32_t usartdiv; 02058 uint32_t brrresult = 0x0U; 02059 #if defined(USART_PRESC_PRESCALER) 02060 uint32_t periphclkpresc = (uint32_t)(PeriphClk / (USART_PRESCALER_TAB[(uint8_t)PrescalerValue])); 02061 #endif /* USART_PRESC_PRESCALER */ 02062 02063 usartdiv = USARTx->BRR; 02064 02065 if (usartdiv == 0U) 02066 { 02067 /* Do not perform a division by 0 */ 02068 } 02069 else if (OverSampling == LL_USART_OVERSAMPLING_8) 02070 { 02071 usartdiv = (uint16_t)((usartdiv & 0xFFF0U) | ((usartdiv & 0x0007U) << 1U)) ; 02072 if (usartdiv != 0U) 02073 { 02074 #if defined(USART_PRESC_PRESCALER) 02075 brrresult = (periphclkpresc * 2U) / usartdiv; 02076 #else 02077 brrresult = (PeriphClk * 2U) / usartdiv; 02078 #endif /* USART_PRESC_PRESCALER */ 02079 } 02080 } 02081 else 02082 { 02083 if ((usartdiv & 0xFFFFU) != 0U) 02084 { 02085 #if defined(USART_PRESC_PRESCALER) 02086 brrresult = periphclkpresc / usartdiv; 02087 #else 02088 brrresult = PeriphClk / usartdiv; 02089 #endif /* USART_PRESC_PRESCALER */ 02090 } 02091 } 02092 return (brrresult); 02093 } 02094 02095 /** 02096 * @brief Set Receiver Time Out Value (expressed in nb of bits duration) 02097 * @rmtoll RTOR RTO LL_USART_SetRxTimeout 02098 * @param USARTx USART Instance 02099 * @param Timeout Value between Min_Data=0x00 and Max_Data=0x00FFFFFF 02100 * @retval None 02101 */ 02102 __STATIC_INLINE void LL_USART_SetRxTimeout(USART_TypeDef *USARTx, uint32_t Timeout) 02103 { 02104 MODIFY_REG(USARTx->RTOR, USART_RTOR_RTO, Timeout); 02105 } 02106 02107 /** 02108 * @brief Get Receiver Time Out Value (expressed in nb of bits duration) 02109 * @rmtoll RTOR RTO LL_USART_GetRxTimeout 02110 * @param USARTx USART Instance 02111 * @retval Value between Min_Data=0x00 and Max_Data=0x00FFFFFF 02112 */ 02113 __STATIC_INLINE uint32_t LL_USART_GetRxTimeout(USART_TypeDef *USARTx) 02114 { 02115 return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_RTO)); 02116 } 02117 02118 /** 02119 * @brief Set Block Length value in reception 02120 * @rmtoll RTOR BLEN LL_USART_SetBlockLength 02121 * @param USARTx USART Instance 02122 * @param BlockLength Value between Min_Data=0x00 and Max_Data=0xFF 02123 * @retval None 02124 */ 02125 __STATIC_INLINE void LL_USART_SetBlockLength(USART_TypeDef *USARTx, uint32_t BlockLength) 02126 { 02127 MODIFY_REG(USARTx->RTOR, USART_RTOR_BLEN, BlockLength << USART_RTOR_BLEN_Pos); 02128 } 02129 02130 /** 02131 * @brief Get Block Length value in reception 02132 * @rmtoll RTOR BLEN LL_USART_GetBlockLength 02133 * @param USARTx USART Instance 02134 * @retval Value between Min_Data=0x00 and Max_Data=0xFF 02135 */ 02136 __STATIC_INLINE uint32_t LL_USART_GetBlockLength(USART_TypeDef *USARTx) 02137 { 02138 return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_BLEN) >> USART_RTOR_BLEN_Pos); 02139 } 02140 02141 /** 02142 * @} 02143 */ 02144 02145 /** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature 02146 * @{ 02147 */ 02148 02149 /** 02150 * @brief Enable IrDA mode 02151 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 02152 * IrDA feature is supported by the USARTx instance. 02153 * @rmtoll CR3 IREN LL_USART_EnableIrda 02154 * @param USARTx USART Instance 02155 * @retval None 02156 */ 02157 __STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx) 02158 { 02159 SET_BIT(USARTx->CR3, USART_CR3_IREN); 02160 } 02161 02162 /** 02163 * @brief Disable IrDA mode 02164 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 02165 * IrDA feature is supported by the USARTx instance. 02166 * @rmtoll CR3 IREN LL_USART_DisableIrda 02167 * @param USARTx USART Instance 02168 * @retval None 02169 */ 02170 __STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx) 02171 { 02172 CLEAR_BIT(USARTx->CR3, USART_CR3_IREN); 02173 } 02174 02175 /** 02176 * @brief Indicate if IrDA mode is enabled 02177 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 02178 * IrDA feature is supported by the USARTx instance. 02179 * @rmtoll CR3 IREN LL_USART_IsEnabledIrda 02180 * @param USARTx USART Instance 02181 * @retval State of bit (1 or 0). 02182 */ 02183 __STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(USART_TypeDef *USARTx) 02184 { 02185 return ((READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN)) ? 1UL : 0UL); 02186 } 02187 02188 /** 02189 * @brief Configure IrDA Power Mode (Normal or Low Power) 02190 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 02191 * IrDA feature is supported by the USARTx instance. 02192 * @rmtoll CR3 IRLP LL_USART_SetIrdaPowerMode 02193 * @param USARTx USART Instance 02194 * @param PowerMode This parameter can be one of the following values: 02195 * @arg @ref LL_USART_IRDA_POWER_NORMAL 02196 * @arg @ref LL_USART_IRDA_POWER_LOW 02197 * @retval None 02198 */ 02199 __STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode) 02200 { 02201 MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode); 02202 } 02203 02204 /** 02205 * @brief Retrieve IrDA Power Mode configuration (Normal or Low Power) 02206 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 02207 * IrDA feature is supported by the USARTx instance. 02208 * @rmtoll CR3 IRLP LL_USART_GetIrdaPowerMode 02209 * @param USARTx USART Instance 02210 * @retval Returned value can be one of the following values: 02211 * @arg @ref LL_USART_IRDA_POWER_NORMAL 02212 * @arg @ref LL_USART_PHASE_2EDGE 02213 */ 02214 __STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(USART_TypeDef *USARTx) 02215 { 02216 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP)); 02217 } 02218 02219 /** 02220 * @brief Set Irda prescaler value, used for dividing the USART clock source 02221 * to achieve the Irda Low Power frequency (8 bits value) 02222 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 02223 * IrDA feature is supported by the USARTx instance. 02224 * @rmtoll GTPR PSC LL_USART_SetIrdaPrescaler 02225 * @param USARTx USART Instance 02226 * @param PrescalerValue Value between Min_Data=0x00 and Max_Data=0xFF 02227 * @retval None 02228 */ 02229 __STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) 02230 { 02231 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, (uint16_t)PrescalerValue); 02232 } 02233 02234 /** 02235 * @brief Return Irda prescaler value, used for dividing the USART clock source 02236 * to achieve the Irda Low Power frequency (8 bits value) 02237 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 02238 * IrDA feature is supported by the USARTx instance. 02239 * @rmtoll GTPR PSC LL_USART_GetIrdaPrescaler 02240 * @param USARTx USART Instance 02241 * @retval Irda prescaler value (Value between Min_Data=0x00 and Max_Data=0xFF) 02242 */ 02243 __STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(USART_TypeDef *USARTx) 02244 { 02245 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC)); 02246 } 02247 02248 /** 02249 * @} 02250 */ 02251 02252 /** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature 02253 * @{ 02254 */ 02255 02256 /** 02257 * @brief Enable Smartcard NACK transmission 02258 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02259 * Smartcard feature is supported by the USARTx instance. 02260 * @rmtoll CR3 NACK LL_USART_EnableSmartcardNACK 02261 * @param USARTx USART Instance 02262 * @retval None 02263 */ 02264 __STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx) 02265 { 02266 SET_BIT(USARTx->CR3, USART_CR3_NACK); 02267 } 02268 02269 /** 02270 * @brief Disable Smartcard NACK transmission 02271 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02272 * Smartcard feature is supported by the USARTx instance. 02273 * @rmtoll CR3 NACK LL_USART_DisableSmartcardNACK 02274 * @param USARTx USART Instance 02275 * @retval None 02276 */ 02277 __STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx) 02278 { 02279 CLEAR_BIT(USARTx->CR3, USART_CR3_NACK); 02280 } 02281 02282 /** 02283 * @brief Indicate if Smartcard NACK transmission is enabled 02284 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02285 * Smartcard feature is supported by the USARTx instance. 02286 * @rmtoll CR3 NACK LL_USART_IsEnabledSmartcardNACK 02287 * @param USARTx USART Instance 02288 * @retval State of bit (1 or 0). 02289 */ 02290 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(USART_TypeDef *USARTx) 02291 { 02292 return ((READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK)) ? 1UL : 0UL); 02293 } 02294 02295 /** 02296 * @brief Enable Smartcard mode 02297 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02298 * Smartcard feature is supported by the USARTx instance. 02299 * @rmtoll CR3 SCEN LL_USART_EnableSmartcard 02300 * @param USARTx USART Instance 02301 * @retval None 02302 */ 02303 __STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx) 02304 { 02305 SET_BIT(USARTx->CR3, USART_CR3_SCEN); 02306 } 02307 02308 /** 02309 * @brief Disable Smartcard mode 02310 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02311 * Smartcard feature is supported by the USARTx instance. 02312 * @rmtoll CR3 SCEN LL_USART_DisableSmartcard 02313 * @param USARTx USART Instance 02314 * @retval None 02315 */ 02316 __STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx) 02317 { 02318 CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN); 02319 } 02320 02321 /** 02322 * @brief Indicate if Smartcard mode is enabled 02323 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02324 * Smartcard feature is supported by the USARTx instance. 02325 * @rmtoll CR3 SCEN LL_USART_IsEnabledSmartcard 02326 * @param USARTx USART Instance 02327 * @retval State of bit (1 or 0). 02328 */ 02329 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(USART_TypeDef *USARTx) 02330 { 02331 return ((READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN)) ? 1UL : 0UL); 02332 } 02333 02334 /** 02335 * @brief Set Smartcard Auto-Retry Count value (SCARCNT[2:0] bits) 02336 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02337 * Smartcard feature is supported by the USARTx instance. 02338 * @note This bit-field specifies the number of retries in transmit and receive, in Smartcard mode. 02339 * In transmission mode, it specifies the number of automatic retransmission retries, before 02340 * generating a transmission error (FE bit set). 02341 * In reception mode, it specifies the number or erroneous reception trials, before generating a 02342 * reception error (RXNE and PE bits set) 02343 * @rmtoll CR3 SCARCNT LL_USART_SetSmartcardAutoRetryCount 02344 * @param USARTx USART Instance 02345 * @param AutoRetryCount Value between Min_Data=0 and Max_Data=7 02346 * @retval None 02347 */ 02348 __STATIC_INLINE void LL_USART_SetSmartcardAutoRetryCount(USART_TypeDef *USARTx, uint32_t AutoRetryCount) 02349 { 02350 MODIFY_REG(USARTx->CR3, USART_CR3_SCARCNT, AutoRetryCount << USART_CR3_SCARCNT_Pos); 02351 } 02352 02353 /** 02354 * @brief Return Smartcard Auto-Retry Count value (SCARCNT[2:0] bits) 02355 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02356 * Smartcard feature is supported by the USARTx instance. 02357 * @rmtoll CR3 SCARCNT LL_USART_GetSmartcardAutoRetryCount 02358 * @param USARTx USART Instance 02359 * @retval Smartcard Auto-Retry Count value (Value between Min_Data=0 and Max_Data=7) 02360 */ 02361 __STATIC_INLINE uint32_t LL_USART_GetSmartcardAutoRetryCount(USART_TypeDef *USARTx) 02362 { 02363 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_SCARCNT) >> USART_CR3_SCARCNT_Pos); 02364 } 02365 02366 /** 02367 * @brief Set Smartcard prescaler value, used for dividing the USART clock 02368 * source to provide the SMARTCARD Clock (5 bits value) 02369 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02370 * Smartcard feature is supported by the USARTx instance. 02371 * @rmtoll GTPR PSC LL_USART_SetSmartcardPrescaler 02372 * @param USARTx USART Instance 02373 * @param PrescalerValue Value between Min_Data=0 and Max_Data=31 02374 * @retval None 02375 */ 02376 __STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) 02377 { 02378 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, (uint16_t)PrescalerValue); 02379 } 02380 02381 /** 02382 * @brief Return Smartcard prescaler value, used for dividing the USART clock 02383 * source to provide the SMARTCARD Clock (5 bits value) 02384 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02385 * Smartcard feature is supported by the USARTx instance. 02386 * @rmtoll GTPR PSC LL_USART_GetSmartcardPrescaler 02387 * @param USARTx USART Instance 02388 * @retval Smartcard prescaler value (Value between Min_Data=0 and Max_Data=31) 02389 */ 02390 __STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(USART_TypeDef *USARTx) 02391 { 02392 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC)); 02393 } 02394 02395 /** 02396 * @brief Set Smartcard Guard time value, expressed in nb of baud clocks periods 02397 * (GT[7:0] bits : Guard time value) 02398 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02399 * Smartcard feature is supported by the USARTx instance. 02400 * @rmtoll GTPR GT LL_USART_SetSmartcardGuardTime 02401 * @param USARTx USART Instance 02402 * @param GuardTime Value between Min_Data=0x00 and Max_Data=0xFF 02403 * @retval None 02404 */ 02405 __STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime) 02406 { 02407 MODIFY_REG(USARTx->GTPR, USART_GTPR_GT, (uint16_t)(GuardTime << USART_GTPR_GT_Pos)); 02408 } 02409 02410 /** 02411 * @brief Return Smartcard Guard time value, expressed in nb of baud clocks periods 02412 * (GT[7:0] bits : Guard time value) 02413 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02414 * Smartcard feature is supported by the USARTx instance. 02415 * @rmtoll GTPR GT LL_USART_GetSmartcardGuardTime 02416 * @param USARTx USART Instance 02417 * @retval Smartcard Guard time value (Value between Min_Data=0x00 and Max_Data=0xFF) 02418 */ 02419 __STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(USART_TypeDef *USARTx) 02420 { 02421 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_GTPR_GT_Pos); 02422 } 02423 02424 /** 02425 * @} 02426 */ 02427 02428 /** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature 02429 * @{ 02430 */ 02431 02432 /** 02433 * @brief Enable Single Wire Half-Duplex mode 02434 * @note Macro IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not 02435 * Half-Duplex mode is supported by the USARTx instance. 02436 * @rmtoll CR3 HDSEL LL_USART_EnableHalfDuplex 02437 * @param USARTx USART Instance 02438 * @retval None 02439 */ 02440 __STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx) 02441 { 02442 SET_BIT(USARTx->CR3, USART_CR3_HDSEL); 02443 } 02444 02445 /** 02446 * @brief Disable Single Wire Half-Duplex mode 02447 * @note Macro IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not 02448 * Half-Duplex mode is supported by the USARTx instance. 02449 * @rmtoll CR3 HDSEL LL_USART_DisableHalfDuplex 02450 * @param USARTx USART Instance 02451 * @retval None 02452 */ 02453 __STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx) 02454 { 02455 CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL); 02456 } 02457 02458 /** 02459 * @brief Indicate if Single Wire Half-Duplex mode is enabled 02460 * @note Macro IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not 02461 * Half-Duplex mode is supported by the USARTx instance. 02462 * @rmtoll CR3 HDSEL LL_USART_IsEnabledHalfDuplex 02463 * @param USARTx USART Instance 02464 * @retval State of bit (1 or 0). 02465 */ 02466 __STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(USART_TypeDef *USARTx) 02467 { 02468 return ((READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL)) ? 1UL : 0UL); 02469 } 02470 02471 /** 02472 * @} 02473 */ 02474 02475 #if defined(USART_CR2_SLVEN) 02476 /** @defgroup USART_LL_EF_Configuration_SPI_SLAVE Configuration functions related to SPI Slave feature 02477 * @{ 02478 */ 02479 /** 02480 * @brief Enable SPI Synchronous Slave mode 02481 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 02482 * SPI Slave mode feature is supported by the USARTx instance. 02483 * @rmtoll CR2 SLVEN LL_USART_EnableSPISlave 02484 * @param USARTx USART Instance 02485 * @retval None 02486 */ 02487 __STATIC_INLINE void LL_USART_EnableSPISlave(USART_TypeDef *USARTx) 02488 { 02489 SET_BIT(USARTx->CR2, USART_CR2_SLVEN); 02490 } 02491 02492 /** 02493 * @brief Disable SPI Synchronous Slave mode 02494 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 02495 * SPI Slave mode feature is supported by the USARTx instance. 02496 * @rmtoll CR2 SLVEN LL_USART_DisableSPISlave 02497 * @param USARTx USART Instance 02498 * @retval None 02499 */ 02500 __STATIC_INLINE void LL_USART_DisableSPISlave(USART_TypeDef *USARTx) 02501 { 02502 CLEAR_BIT(USARTx->CR2, USART_CR2_SLVEN); 02503 } 02504 02505 /** 02506 * @brief Indicate if SPI Synchronous Slave mode is enabled 02507 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 02508 * SPI Slave mode feature is supported by the USARTx instance. 02509 * @rmtoll CR2 SLVEN LL_USART_IsEnabledSPISlave 02510 * @param USARTx USART Instance 02511 * @retval State of bit (1 or 0). 02512 */ 02513 __STATIC_INLINE uint32_t LL_USART_IsEnabledSPISlave(USART_TypeDef *USARTx) 02514 { 02515 return ((READ_BIT(USARTx->CR2, USART_CR2_SLVEN) == (USART_CR2_SLVEN)) ? 1UL : 0UL); 02516 } 02517 02518 /** 02519 * @brief Enable SPI Slave Selection using NSS input pin 02520 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 02521 * SPI Slave mode feature is supported by the USARTx instance. 02522 * @note SPI Slave Selection depends on NSS input pin 02523 * (The slave is selected when NSS is low and deselected when NSS is high). 02524 * @rmtoll CR2 DIS_NSS LL_USART_EnableSPISlaveSelect 02525 * @param USARTx USART Instance 02526 * @retval None 02527 */ 02528 __STATIC_INLINE void LL_USART_EnableSPISlaveSelect(USART_TypeDef *USARTx) 02529 { 02530 CLEAR_BIT(USARTx->CR2, USART_CR2_DIS_NSS); 02531 } 02532 02533 /** 02534 * @brief Disable SPI Slave Selection using NSS input pin 02535 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 02536 * SPI Slave mode feature is supported by the USARTx instance. 02537 * @note SPI Slave will be always selected and NSS input pin will be ignored. 02538 * @rmtoll CR2 DIS_NSS LL_USART_DisableSPISlaveSelect 02539 * @param USARTx USART Instance 02540 * @retval None 02541 */ 02542 __STATIC_INLINE void LL_USART_DisableSPISlaveSelect(USART_TypeDef *USARTx) 02543 { 02544 SET_BIT(USARTx->CR2, USART_CR2_DIS_NSS); 02545 } 02546 02547 /** 02548 * @brief Indicate if SPI Slave Selection depends on NSS input pin 02549 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 02550 * SPI Slave mode feature is supported by the USARTx instance. 02551 * @rmtoll CR2 DIS_NSS LL_USART_IsEnabledSPISlaveSelect 02552 * @param USARTx USART Instance 02553 * @retval State of bit (1 or 0). 02554 */ 02555 __STATIC_INLINE uint32_t LL_USART_IsEnabledSPISlaveSelect(USART_TypeDef *USARTx) 02556 { 02557 return ((READ_BIT(USARTx->CR2, USART_CR2_DIS_NSS) != (USART_CR2_DIS_NSS)) ? 1UL : 0UL); 02558 } 02559 02560 /** 02561 * @} 02562 */ 02563 02564 #endif /* USART_CR2_SLVEN */ 02565 /** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature 02566 * @{ 02567 */ 02568 02569 /** 02570 * @brief Set LIN Break Detection Length 02571 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 02572 * LIN feature is supported by the USARTx instance. 02573 * @rmtoll CR2 LBDL LL_USART_SetLINBrkDetectionLen 02574 * @param USARTx USART Instance 02575 * @param LINBDLength This parameter can be one of the following values: 02576 * @arg @ref LL_USART_LINBREAK_DETECT_10B 02577 * @arg @ref LL_USART_LINBREAK_DETECT_11B 02578 * @retval None 02579 */ 02580 __STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength) 02581 { 02582 MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength); 02583 } 02584 02585 /** 02586 * @brief Return LIN Break Detection Length 02587 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 02588 * LIN feature is supported by the USARTx instance. 02589 * @rmtoll CR2 LBDL LL_USART_GetLINBrkDetectionLen 02590 * @param USARTx USART Instance 02591 * @retval Returned value can be one of the following values: 02592 * @arg @ref LL_USART_LINBREAK_DETECT_10B 02593 * @arg @ref LL_USART_LINBREAK_DETECT_11B 02594 */ 02595 __STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(USART_TypeDef *USARTx) 02596 { 02597 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL)); 02598 } 02599 02600 /** 02601 * @brief Enable LIN mode 02602 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 02603 * LIN feature is supported by the USARTx instance. 02604 * @rmtoll CR2 LINEN LL_USART_EnableLIN 02605 * @param USARTx USART Instance 02606 * @retval None 02607 */ 02608 __STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx) 02609 { 02610 SET_BIT(USARTx->CR2, USART_CR2_LINEN); 02611 } 02612 02613 /** 02614 * @brief Disable LIN mode 02615 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 02616 * LIN feature is supported by the USARTx instance. 02617 * @rmtoll CR2 LINEN LL_USART_DisableLIN 02618 * @param USARTx USART Instance 02619 * @retval None 02620 */ 02621 __STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx) 02622 { 02623 CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN); 02624 } 02625 02626 /** 02627 * @brief Indicate if LIN mode is enabled 02628 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 02629 * LIN feature is supported by the USARTx instance. 02630 * @rmtoll CR2 LINEN LL_USART_IsEnabledLIN 02631 * @param USARTx USART Instance 02632 * @retval State of bit (1 or 0). 02633 */ 02634 __STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(USART_TypeDef *USARTx) 02635 { 02636 return ((READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN)) ? 1UL : 0UL); 02637 } 02638 02639 /** 02640 * @} 02641 */ 02642 02643 /** @defgroup USART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature 02644 * @{ 02645 */ 02646 02647 /** 02648 * @brief Set DEDT (Driver Enable De-Assertion Time), Time value expressed on 5 bits ([4:0] bits). 02649 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02650 * Driver Enable feature is supported by the USARTx instance. 02651 * @rmtoll CR1 DEDT LL_USART_SetDEDeassertionTime 02652 * @param USARTx USART Instance 02653 * @param Time Value between Min_Data=0 and Max_Data=31 02654 * @retval None 02655 */ 02656 __STATIC_INLINE void LL_USART_SetDEDeassertionTime(USART_TypeDef *USARTx, uint32_t Time) 02657 { 02658 MODIFY_REG(USARTx->CR1, USART_CR1_DEDT, Time << USART_CR1_DEDT_Pos); 02659 } 02660 02661 /** 02662 * @brief Return DEDT (Driver Enable De-Assertion Time) 02663 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02664 * Driver Enable feature is supported by the USARTx instance. 02665 * @rmtoll CR1 DEDT LL_USART_GetDEDeassertionTime 02666 * @param USARTx USART Instance 02667 * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31 02668 */ 02669 __STATIC_INLINE uint32_t LL_USART_GetDEDeassertionTime(USART_TypeDef *USARTx) 02670 { 02671 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEDT) >> USART_CR1_DEDT_Pos); 02672 } 02673 02674 /** 02675 * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits). 02676 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02677 * Driver Enable feature is supported by the USARTx instance. 02678 * @rmtoll CR1 DEAT LL_USART_SetDEAssertionTime 02679 * @param USARTx USART Instance 02680 * @param Time Value between Min_Data=0 and Max_Data=31 02681 * @retval None 02682 */ 02683 __STATIC_INLINE void LL_USART_SetDEAssertionTime(USART_TypeDef *USARTx, uint32_t Time) 02684 { 02685 MODIFY_REG(USARTx->CR1, USART_CR1_DEAT, Time << USART_CR1_DEAT_Pos); 02686 } 02687 02688 /** 02689 * @brief Return DEAT (Driver Enable Assertion Time) 02690 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02691 * Driver Enable feature is supported by the USARTx instance. 02692 * @rmtoll CR1 DEAT LL_USART_GetDEAssertionTime 02693 * @param USARTx USART Instance 02694 * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31 02695 */ 02696 __STATIC_INLINE uint32_t LL_USART_GetDEAssertionTime(USART_TypeDef *USARTx) 02697 { 02698 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEAT) >> USART_CR1_DEAT_Pos); 02699 } 02700 02701 /** 02702 * @brief Enable Driver Enable (DE) Mode 02703 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02704 * Driver Enable feature is supported by the USARTx instance. 02705 * @rmtoll CR3 DEM LL_USART_EnableDEMode 02706 * @param USARTx USART Instance 02707 * @retval None 02708 */ 02709 __STATIC_INLINE void LL_USART_EnableDEMode(USART_TypeDef *USARTx) 02710 { 02711 SET_BIT(USARTx->CR3, USART_CR3_DEM); 02712 } 02713 02714 /** 02715 * @brief Disable Driver Enable (DE) Mode 02716 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02717 * Driver Enable feature is supported by the USARTx instance. 02718 * @rmtoll CR3 DEM LL_USART_DisableDEMode 02719 * @param USARTx USART Instance 02720 * @retval None 02721 */ 02722 __STATIC_INLINE void LL_USART_DisableDEMode(USART_TypeDef *USARTx) 02723 { 02724 CLEAR_BIT(USARTx->CR3, USART_CR3_DEM); 02725 } 02726 02727 /** 02728 * @brief Indicate if Driver Enable (DE) Mode is enabled 02729 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02730 * Driver Enable feature is supported by the USARTx instance. 02731 * @rmtoll CR3 DEM LL_USART_IsEnabledDEMode 02732 * @param USARTx USART Instance 02733 * @retval State of bit (1 or 0). 02734 */ 02735 __STATIC_INLINE uint32_t LL_USART_IsEnabledDEMode(USART_TypeDef *USARTx) 02736 { 02737 return ((READ_BIT(USARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM)) ? 1UL : 0UL); 02738 } 02739 02740 /** 02741 * @brief Select Driver Enable Polarity 02742 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02743 * Driver Enable feature is supported by the USARTx instance. 02744 * @rmtoll CR3 DEP LL_USART_SetDESignalPolarity 02745 * @param USARTx USART Instance 02746 * @param Polarity This parameter can be one of the following values: 02747 * @arg @ref LL_USART_DE_POLARITY_HIGH 02748 * @arg @ref LL_USART_DE_POLARITY_LOW 02749 * @retval None 02750 */ 02751 __STATIC_INLINE void LL_USART_SetDESignalPolarity(USART_TypeDef *USARTx, uint32_t Polarity) 02752 { 02753 MODIFY_REG(USARTx->CR3, USART_CR3_DEP, Polarity); 02754 } 02755 02756 /** 02757 * @brief Return Driver Enable Polarity 02758 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02759 * Driver Enable feature is supported by the USARTx instance. 02760 * @rmtoll CR3 DEP LL_USART_GetDESignalPolarity 02761 * @param USARTx USART Instance 02762 * @retval Returned value can be one of the following values: 02763 * @arg @ref LL_USART_DE_POLARITY_HIGH 02764 * @arg @ref LL_USART_DE_POLARITY_LOW 02765 */ 02766 __STATIC_INLINE uint32_t LL_USART_GetDESignalPolarity(USART_TypeDef *USARTx) 02767 { 02768 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_DEP)); 02769 } 02770 02771 /** 02772 * @} 02773 */ 02774 02775 /** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services 02776 * @{ 02777 */ 02778 02779 /** 02780 * @brief Perform basic configuration of USART for enabling use in Asynchronous Mode (UART) 02781 * @note In UART mode, the following bits must be kept cleared: 02782 * - LINEN bit in the USART_CR2 register, 02783 * - CLKEN bit in the USART_CR2 register, 02784 * - SCEN bit in the USART_CR3 register, 02785 * - IREN bit in the USART_CR3 register, 02786 * - HDSEL bit in the USART_CR3 register. 02787 * @note Call of this function is equivalent to following function call sequence : 02788 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 02789 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 02790 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 02791 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 02792 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 02793 * @note Other remaining configurations items related to Asynchronous Mode 02794 * (as Baud Rate, Word length, Parity, ...) should be set using 02795 * dedicated functions 02796 * @rmtoll CR2 LINEN LL_USART_ConfigAsyncMode\n 02797 * CR2 CLKEN LL_USART_ConfigAsyncMode\n 02798 * CR3 SCEN LL_USART_ConfigAsyncMode\n 02799 * CR3 IREN LL_USART_ConfigAsyncMode\n 02800 * CR3 HDSEL LL_USART_ConfigAsyncMode 02801 * @param USARTx USART Instance 02802 * @retval None 02803 */ 02804 __STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx) 02805 { 02806 /* In Asynchronous mode, the following bits must be kept cleared: 02807 - LINEN, CLKEN bits in the USART_CR2 register, 02808 - SCEN, IREN and HDSEL bits in the USART_CR3 register. 02809 */ 02810 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); 02811 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL)); 02812 } 02813 02814 /** 02815 * @brief Perform basic configuration of USART for enabling use in Synchronous Mode 02816 * @note In Synchronous mode, the following bits must be kept cleared: 02817 * - LINEN bit in the USART_CR2 register, 02818 * - SCEN bit in the USART_CR3 register, 02819 * - IREN bit in the USART_CR3 register, 02820 * - HDSEL bit in the USART_CR3 register. 02821 * This function also sets the USART in Synchronous mode. 02822 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 02823 * Synchronous mode is supported by the USARTx instance. 02824 * @note Call of this function is equivalent to following function call sequence : 02825 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 02826 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 02827 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 02828 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 02829 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function 02830 * @note Other remaining configurations items related to Synchronous Mode 02831 * (as Baud Rate, Word length, Parity, Clock Polarity, ...) should be set using 02832 * dedicated functions 02833 * @rmtoll CR2 LINEN LL_USART_ConfigSyncMode\n 02834 * CR2 CLKEN LL_USART_ConfigSyncMode\n 02835 * CR3 SCEN LL_USART_ConfigSyncMode\n 02836 * CR3 IREN LL_USART_ConfigSyncMode\n 02837 * CR3 HDSEL LL_USART_ConfigSyncMode 02838 * @param USARTx USART Instance 02839 * @retval None 02840 */ 02841 __STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx) 02842 { 02843 /* In Synchronous mode, the following bits must be kept cleared: 02844 - LINEN bit in the USART_CR2 register, 02845 - SCEN, IREN and HDSEL bits in the USART_CR3 register. 02846 */ 02847 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN)); 02848 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL)); 02849 /* set the UART/USART in Synchronous mode */ 02850 SET_BIT(USARTx->CR2, USART_CR2_CLKEN); 02851 } 02852 02853 /** 02854 * @brief Perform basic configuration of USART for enabling use in LIN Mode 02855 * @note In LIN mode, the following bits must be kept cleared: 02856 * - STOP and CLKEN bits in the USART_CR2 register, 02857 * - SCEN bit in the USART_CR3 register, 02858 * - IREN bit in the USART_CR3 register, 02859 * - HDSEL bit in the USART_CR3 register. 02860 * This function also set the UART/USART in LIN mode. 02861 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 02862 * LIN feature is supported by the USARTx instance. 02863 * @note Call of this function is equivalent to following function call sequence : 02864 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 02865 * - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function 02866 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 02867 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 02868 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 02869 * - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function 02870 * @note Other remaining configurations items related to LIN Mode 02871 * (as Baud Rate, Word length, LIN Break Detection Length, ...) should be set using 02872 * dedicated functions 02873 * @rmtoll CR2 CLKEN LL_USART_ConfigLINMode\n 02874 * CR2 STOP LL_USART_ConfigLINMode\n 02875 * CR2 LINEN LL_USART_ConfigLINMode\n 02876 * CR3 IREN LL_USART_ConfigLINMode\n 02877 * CR3 SCEN LL_USART_ConfigLINMode\n 02878 * CR3 HDSEL LL_USART_ConfigLINMode 02879 * @param USARTx USART Instance 02880 * @retval None 02881 */ 02882 __STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx) 02883 { 02884 /* In LIN mode, the following bits must be kept cleared: 02885 - STOP and CLKEN bits in the USART_CR2 register, 02886 - IREN, SCEN and HDSEL bits in the USART_CR3 register. 02887 */ 02888 CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP)); 02889 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL)); 02890 /* Set the UART/USART in LIN mode */ 02891 SET_BIT(USARTx->CR2, USART_CR2_LINEN); 02892 } 02893 02894 /** 02895 * @brief Perform basic configuration of USART for enabling use in Half Duplex Mode 02896 * @note In Half Duplex mode, the following bits must be kept cleared: 02897 * - LINEN bit in the USART_CR2 register, 02898 * - CLKEN bit in the USART_CR2 register, 02899 * - SCEN bit in the USART_CR3 register, 02900 * - IREN bit in the USART_CR3 register, 02901 * This function also sets the UART/USART in Half Duplex mode. 02902 * @note Macro IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not 02903 * Half-Duplex mode is supported by the USARTx instance. 02904 * @note Call of this function is equivalent to following function call sequence : 02905 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 02906 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 02907 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 02908 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 02909 * - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function 02910 * @note Other remaining configurations items related to Half Duplex Mode 02911 * (as Baud Rate, Word length, Parity, ...) should be set using 02912 * dedicated functions 02913 * @rmtoll CR2 LINEN LL_USART_ConfigHalfDuplexMode\n 02914 * CR2 CLKEN LL_USART_ConfigHalfDuplexMode\n 02915 * CR3 HDSEL LL_USART_ConfigHalfDuplexMode\n 02916 * CR3 SCEN LL_USART_ConfigHalfDuplexMode\n 02917 * CR3 IREN LL_USART_ConfigHalfDuplexMode 02918 * @param USARTx USART Instance 02919 * @retval None 02920 */ 02921 __STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx) 02922 { 02923 /* In Half Duplex mode, the following bits must be kept cleared: 02924 - LINEN and CLKEN bits in the USART_CR2 register, 02925 - SCEN and IREN bits in the USART_CR3 register. 02926 */ 02927 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); 02928 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN)); 02929 /* set the UART/USART in Half Duplex mode */ 02930 SET_BIT(USARTx->CR3, USART_CR3_HDSEL); 02931 } 02932 02933 /** 02934 * @brief Perform basic configuration of USART for enabling use in Smartcard Mode 02935 * @note In Smartcard mode, the following bits must be kept cleared: 02936 * - LINEN bit in the USART_CR2 register, 02937 * - IREN bit in the USART_CR3 register, 02938 * - HDSEL bit in the USART_CR3 register. 02939 * This function also configures Stop bits to 1.5 bits and 02940 * sets the USART in Smartcard mode (SCEN bit). 02941 * Clock Output is also enabled (CLKEN). 02942 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02943 * Smartcard feature is supported by the USARTx instance. 02944 * @note Call of this function is equivalent to following function call sequence : 02945 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 02946 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 02947 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 02948 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function 02949 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function 02950 * - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function 02951 * @note Other remaining configurations items related to Smartcard Mode 02952 * (as Baud Rate, Word length, Parity, ...) should be set using 02953 * dedicated functions 02954 * @rmtoll CR2 LINEN LL_USART_ConfigSmartcardMode\n 02955 * CR2 STOP LL_USART_ConfigSmartcardMode\n 02956 * CR2 CLKEN LL_USART_ConfigSmartcardMode\n 02957 * CR3 HDSEL LL_USART_ConfigSmartcardMode\n 02958 * CR3 SCEN LL_USART_ConfigSmartcardMode 02959 * @param USARTx USART Instance 02960 * @retval None 02961 */ 02962 __STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx) 02963 { 02964 /* In Smartcard mode, the following bits must be kept cleared: 02965 - LINEN bit in the USART_CR2 register, 02966 - IREN and HDSEL bits in the USART_CR3 register. 02967 */ 02968 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN)); 02969 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL)); 02970 /* Configure Stop bits to 1.5 bits */ 02971 /* Synchronous mode is activated by default */ 02972 SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN)); 02973 /* set the UART/USART in Smartcard mode */ 02974 SET_BIT(USARTx->CR3, USART_CR3_SCEN); 02975 } 02976 02977 /** 02978 * @brief Perform basic configuration of USART for enabling use in Irda Mode 02979 * @note In IRDA mode, the following bits must be kept cleared: 02980 * - LINEN bit in the USART_CR2 register, 02981 * - STOP and CLKEN bits in the USART_CR2 register, 02982 * - SCEN bit in the USART_CR3 register, 02983 * - HDSEL bit in the USART_CR3 register. 02984 * This function also sets the UART/USART in IRDA mode (IREN bit). 02985 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 02986 * IrDA feature is supported by the USARTx instance. 02987 * @note Call of this function is equivalent to following function call sequence : 02988 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 02989 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 02990 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 02991 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 02992 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function 02993 * - Set IREN in CR3 using @ref LL_USART_EnableIrda() function 02994 * @note Other remaining configurations items related to Irda Mode 02995 * (as Baud Rate, Word length, Power mode, ...) should be set using 02996 * dedicated functions 02997 * @rmtoll CR2 LINEN LL_USART_ConfigIrdaMode\n 02998 * CR2 CLKEN LL_USART_ConfigIrdaMode\n 02999 * CR2 STOP LL_USART_ConfigIrdaMode\n 03000 * CR3 SCEN LL_USART_ConfigIrdaMode\n 03001 * CR3 HDSEL LL_USART_ConfigIrdaMode\n 03002 * CR3 IREN LL_USART_ConfigIrdaMode 03003 * @param USARTx USART Instance 03004 * @retval None 03005 */ 03006 __STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx) 03007 { 03008 /* In IRDA mode, the following bits must be kept cleared: 03009 - LINEN, STOP and CLKEN bits in the USART_CR2 register, 03010 - SCEN and HDSEL bits in the USART_CR3 register. 03011 */ 03012 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP)); 03013 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL)); 03014 /* set the UART/USART in IRDA mode */ 03015 SET_BIT(USARTx->CR3, USART_CR3_IREN); 03016 } 03017 03018 /** 03019 * @brief Perform basic configuration of USART for enabling use in Multi processor Mode 03020 * (several USARTs connected in a network, one of the USARTs can be the master, 03021 * its TX output connected to the RX inputs of the other slaves USARTs). 03022 * @note In MultiProcessor mode, the following bits must be kept cleared: 03023 * - LINEN bit in the USART_CR2 register, 03024 * - CLKEN bit in the USART_CR2 register, 03025 * - SCEN bit in the USART_CR3 register, 03026 * - IREN bit in the USART_CR3 register, 03027 * - HDSEL bit in the USART_CR3 register. 03028 * @note Call of this function is equivalent to following function call sequence : 03029 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 03030 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 03031 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 03032 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 03033 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 03034 * @note Other remaining configurations items related to Multi processor Mode 03035 * (as Baud Rate, Wake Up Method, Node address, ...) should be set using 03036 * dedicated functions 03037 * @rmtoll CR2 LINEN LL_USART_ConfigMultiProcessMode\n 03038 * CR2 CLKEN LL_USART_ConfigMultiProcessMode\n 03039 * CR3 SCEN LL_USART_ConfigMultiProcessMode\n 03040 * CR3 HDSEL LL_USART_ConfigMultiProcessMode\n 03041 * CR3 IREN LL_USART_ConfigMultiProcessMode 03042 * @param USARTx USART Instance 03043 * @retval None 03044 */ 03045 __STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx) 03046 { 03047 /* In Multi Processor mode, the following bits must be kept cleared: 03048 - LINEN and CLKEN bits in the USART_CR2 register, 03049 - IREN, SCEN and HDSEL bits in the USART_CR3 register. 03050 */ 03051 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); 03052 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN)); 03053 } 03054 03055 /** 03056 * @} 03057 */ 03058 03059 /** @defgroup USART_LL_EF_FLAG_Management FLAG_Management 03060 * @{ 03061 */ 03062 03063 /** 03064 * @brief Check if the USART Parity Error Flag is set or not 03065 * @rmtoll ISR PE LL_USART_IsActiveFlag_PE 03066 * @param USARTx USART Instance 03067 * @retval State of bit (1 or 0). 03068 */ 03069 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(USART_TypeDef *USARTx) 03070 { 03071 return ((READ_BIT(USARTx->ISR, USART_ISR_PE) == (USART_ISR_PE)) ? 1UL : 0UL); 03072 } 03073 03074 /** 03075 * @brief Check if the USART Framing Error Flag is set or not 03076 * @rmtoll ISR FE LL_USART_IsActiveFlag_FE 03077 * @param USARTx USART Instance 03078 * @retval State of bit (1 or 0). 03079 */ 03080 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(USART_TypeDef *USARTx) 03081 { 03082 return ((READ_BIT(USARTx->ISR, USART_ISR_FE) == (USART_ISR_FE)) ? 1UL : 0UL); 03083 } 03084 03085 /** 03086 * @brief Check if the USART Noise error detected Flag is set or not 03087 * @rmtoll ISR NE LL_USART_IsActiveFlag_NE 03088 * @param USARTx USART Instance 03089 * @retval State of bit (1 or 0). 03090 */ 03091 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(USART_TypeDef *USARTx) 03092 { 03093 return ((READ_BIT(USARTx->ISR, USART_ISR_NE) == (USART_ISR_NE)) ? 1UL : 0UL); 03094 } 03095 03096 /** 03097 * @brief Check if the USART OverRun Error Flag is set or not 03098 * @rmtoll ISR ORE LL_USART_IsActiveFlag_ORE 03099 * @param USARTx USART Instance 03100 * @retval State of bit (1 or 0). 03101 */ 03102 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(USART_TypeDef *USARTx) 03103 { 03104 return ((READ_BIT(USARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE)) ? 1UL : 0UL); 03105 } 03106 03107 /** 03108 * @brief Check if the USART IDLE line detected Flag is set or not 03109 * @rmtoll ISR IDLE LL_USART_IsActiveFlag_IDLE 03110 * @param USARTx USART Instance 03111 * @retval State of bit (1 or 0). 03112 */ 03113 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(USART_TypeDef *USARTx) 03114 { 03115 return ((READ_BIT(USARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE)) ? 1UL : 0UL); 03116 } 03117 03118 #if defined(USART_CR1_FIFOEN) 03119 /* Legacy define */ 03120 #define LL_USART_IsActiveFlag_RXNE LL_USART_IsActiveFlag_RXNE_RXFNE 03121 03122 /** 03123 * @brief Check if the USART Read Data Register or USART RX FIFO Not Empty Flag is set or not 03124 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03125 * FIFO mode feature is supported by the USARTx instance. 03126 * @rmtoll ISR RXNE_RXFNE LL_USART_IsActiveFlag_RXNE_RXFNE 03127 * @param USARTx USART Instance 03128 * @retval State of bit (1 or 0). 03129 */ 03130 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE_RXFNE(USART_TypeDef *USARTx) 03131 { 03132 return ((READ_BIT(USARTx->ISR, USART_ISR_RXNE_RXFNE) == (USART_ISR_RXNE_RXFNE)) ? 1UL : 0UL); 03133 } 03134 03135 #else 03136 /** 03137 * @brief Check if the USART Read Data Register Not Empty Flag is set or not 03138 * @rmtoll ISR RXNE LL_USART_IsActiveFlag_RXNE 03139 * @param USARTx USART Instance 03140 * @retval State of bit (1 or 0). 03141 */ 03142 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE(USART_TypeDef *USARTx) 03143 { 03144 return ((READ_BIT(USARTx->ISR, USART_ISR_RXNE) == (USART_ISR_RXNE)) ? 1UL : 0UL); 03145 } 03146 03147 #endif /* USART_CR1_FIFOEN */ 03148 /** 03149 * @brief Check if the USART Transmission Complete Flag is set or not 03150 * @rmtoll ISR TC LL_USART_IsActiveFlag_TC 03151 * @param USARTx USART Instance 03152 * @retval State of bit (1 or 0). 03153 */ 03154 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(USART_TypeDef *USARTx) 03155 { 03156 return ((READ_BIT(USARTx->ISR, USART_ISR_TC) == (USART_ISR_TC)) ? 1UL : 0UL); 03157 } 03158 03159 #if defined(USART_CR1_FIFOEN) 03160 /* Legacy define */ 03161 #define LL_USART_IsActiveFlag_TXE LL_USART_IsActiveFlag_TXE_TXFNF 03162 03163 /** 03164 * @brief Check if the USART Transmit Data Register Empty or USART TX FIFO Not Full Flag is set or not 03165 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03166 * FIFO mode feature is supported by the USARTx instance. 03167 * @rmtoll ISR TXE_TXFNF LL_USART_IsActiveFlag_TXE_TXFNF 03168 * @param USARTx USART Instance 03169 * @retval State of bit (1 or 0). 03170 */ 03171 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE_TXFNF(USART_TypeDef *USARTx) 03172 { 03173 return ((READ_BIT(USARTx->ISR, USART_ISR_TXE_TXFNF) == (USART_ISR_TXE_TXFNF)) ? 1UL : 0UL); 03174 } 03175 03176 #else 03177 /** 03178 * @brief Check if the USART Transmit Data Register Empty Flag is set or not 03179 * @rmtoll ISR TXE LL_USART_IsActiveFlag_TXE 03180 * @param USARTx USART Instance 03181 * @retval State of bit (1 or 0). 03182 */ 03183 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE(USART_TypeDef *USARTx) 03184 { 03185 return ((READ_BIT(USARTx->ISR, USART_ISR_TXE) == (USART_ISR_TXE)) ? 1UL : 0UL); 03186 } 03187 03188 #endif /* USART_CR1_FIFOEN */ 03189 /** 03190 * @brief Check if the USART LIN Break Detection Flag is set or not 03191 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 03192 * LIN feature is supported by the USARTx instance. 03193 * @rmtoll ISR LBDF LL_USART_IsActiveFlag_LBD 03194 * @param USARTx USART Instance 03195 * @retval State of bit (1 or 0). 03196 */ 03197 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(USART_TypeDef *USARTx) 03198 { 03199 return ((READ_BIT(USARTx->ISR, USART_ISR_LBDF) == (USART_ISR_LBDF)) ? 1UL : 0UL); 03200 } 03201 03202 /** 03203 * @brief Check if the USART CTS interrupt Flag is set or not 03204 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 03205 * Hardware Flow control feature is supported by the USARTx instance. 03206 * @rmtoll ISR CTSIF LL_USART_IsActiveFlag_nCTS 03207 * @param USARTx USART Instance 03208 * @retval State of bit (1 or 0). 03209 */ 03210 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(USART_TypeDef *USARTx) 03211 { 03212 return ((READ_BIT(USARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF)) ? 1UL : 0UL); 03213 } 03214 03215 /** 03216 * @brief Check if the USART CTS Flag is set or not 03217 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 03218 * Hardware Flow control feature is supported by the USARTx instance. 03219 * @rmtoll ISR CTS LL_USART_IsActiveFlag_CTS 03220 * @param USARTx USART Instance 03221 * @retval State of bit (1 or 0). 03222 */ 03223 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CTS(USART_TypeDef *USARTx) 03224 { 03225 return ((READ_BIT(USARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS)) ? 1UL : 0UL); 03226 } 03227 03228 /** 03229 * @brief Check if the USART Receiver Time Out Flag is set or not 03230 * @rmtoll ISR RTOF LL_USART_IsActiveFlag_RTO 03231 * @param USARTx USART Instance 03232 * @retval State of bit (1 or 0). 03233 */ 03234 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RTO(USART_TypeDef *USARTx) 03235 { 03236 return ((READ_BIT(USARTx->ISR, USART_ISR_RTOF) == (USART_ISR_RTOF)) ? 1UL : 0UL); 03237 } 03238 03239 /** 03240 * @brief Check if the USART End Of Block Flag is set or not 03241 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 03242 * Smartcard feature is supported by the USARTx instance. 03243 * @rmtoll ISR EOBF LL_USART_IsActiveFlag_EOB 03244 * @param USARTx USART Instance 03245 * @retval State of bit (1 or 0). 03246 */ 03247 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_EOB(USART_TypeDef *USARTx) 03248 { 03249 return ((READ_BIT(USARTx->ISR, USART_ISR_EOBF) == (USART_ISR_EOBF)) ? 1UL : 0UL); 03250 } 03251 03252 #if defined(USART_CR2_SLVEN) 03253 /** 03254 * @brief Check if the SPI Slave Underrun error flag is set or not 03255 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 03256 * SPI Slave mode feature is supported by the USARTx instance. 03257 * @rmtoll ISR UDR LL_USART_IsActiveFlag_UDR 03258 * @param USARTx USART Instance 03259 * @retval State of bit (1 or 0). 03260 */ 03261 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_UDR(USART_TypeDef *USARTx) 03262 { 03263 return ((READ_BIT(USARTx->ISR, USART_ISR_UDR) == (USART_ISR_UDR)) ? 1UL : 0UL); 03264 } 03265 03266 #endif /* USART_CR2_SLVEN */ 03267 /** 03268 * @brief Check if the USART Auto-Baud Rate Error Flag is set or not 03269 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 03270 * Auto Baud Rate detection feature is supported by the USARTx instance. 03271 * @rmtoll ISR ABRE LL_USART_IsActiveFlag_ABRE 03272 * @param USARTx USART Instance 03273 * @retval State of bit (1 or 0). 03274 */ 03275 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABRE(USART_TypeDef *USARTx) 03276 { 03277 return ((READ_BIT(USARTx->ISR, USART_ISR_ABRE) == (USART_ISR_ABRE)) ? 1UL : 0UL); 03278 } 03279 03280 /** 03281 * @brief Check if the USART Auto-Baud Rate Flag is set or not 03282 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 03283 * Auto Baud Rate detection feature is supported by the USARTx instance. 03284 * @rmtoll ISR ABRF LL_USART_IsActiveFlag_ABR 03285 * @param USARTx USART Instance 03286 * @retval State of bit (1 or 0). 03287 */ 03288 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABR(USART_TypeDef *USARTx) 03289 { 03290 return ((READ_BIT(USARTx->ISR, USART_ISR_ABRF) == (USART_ISR_ABRF)) ? 1UL : 0UL); 03291 } 03292 03293 /** 03294 * @brief Check if the USART Busy Flag is set or not 03295 * @rmtoll ISR BUSY LL_USART_IsActiveFlag_BUSY 03296 * @param USARTx USART Instance 03297 * @retval State of bit (1 or 0). 03298 */ 03299 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_BUSY(USART_TypeDef *USARTx) 03300 { 03301 return ((READ_BIT(USARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY)) ? 1UL : 0UL); 03302 } 03303 03304 /** 03305 * @brief Check if the USART Character Match Flag is set or not 03306 * @rmtoll ISR CMF LL_USART_IsActiveFlag_CM 03307 * @param USARTx USART Instance 03308 * @retval State of bit (1 or 0). 03309 */ 03310 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CM(USART_TypeDef *USARTx) 03311 { 03312 return ((READ_BIT(USARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF)) ? 1UL : 0UL); 03313 } 03314 03315 /** 03316 * @brief Check if the USART Send Break Flag is set or not 03317 * @rmtoll ISR SBKF LL_USART_IsActiveFlag_SBK 03318 * @param USARTx USART Instance 03319 * @retval State of bit (1 or 0). 03320 */ 03321 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(USART_TypeDef *USARTx) 03322 { 03323 return ((READ_BIT(USARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF)) ? 1UL : 0UL); 03324 } 03325 03326 /** 03327 * @brief Check if the USART Receive Wake Up from mute mode Flag is set or not 03328 * @rmtoll ISR RWU LL_USART_IsActiveFlag_RWU 03329 * @param USARTx USART Instance 03330 * @retval State of bit (1 or 0). 03331 */ 03332 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(USART_TypeDef *USARTx) 03333 { 03334 return ((READ_BIT(USARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU)) ? 1UL : 0UL); 03335 } 03336 03337 /** 03338 * @brief Check if the USART Wake Up from stop mode Flag is set or not 03339 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 03340 * Wake-up from Stop mode feature is supported by the USARTx instance. 03341 * @rmtoll ISR WUF LL_USART_IsActiveFlag_WKUP 03342 * @param USARTx USART Instance 03343 * @retval State of bit (1 or 0). 03344 */ 03345 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_WKUP(USART_TypeDef *USARTx) 03346 { 03347 return ((READ_BIT(USARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF)) ? 1UL : 0UL); 03348 } 03349 03350 /** 03351 * @brief Check if the USART Transmit Enable Acknowledge Flag is set or not 03352 * @rmtoll ISR TEACK LL_USART_IsActiveFlag_TEACK 03353 * @param USARTx USART Instance 03354 * @retval State of bit (1 or 0). 03355 */ 03356 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TEACK(USART_TypeDef *USARTx) 03357 { 03358 return ((READ_BIT(USARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK)) ? 1UL : 0UL); 03359 } 03360 03361 /** 03362 * @brief Check if the USART Receive Enable Acknowledge Flag is set or not 03363 * @rmtoll ISR REACK LL_USART_IsActiveFlag_REACK 03364 * @param USARTx USART Instance 03365 * @retval State of bit (1 or 0). 03366 */ 03367 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_REACK(USART_TypeDef *USARTx) 03368 { 03369 return ((READ_BIT(USARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK)) ? 1UL : 0UL); 03370 } 03371 03372 #if defined(USART_CR1_FIFOEN) 03373 /** 03374 * @brief Check if the USART TX FIFO Empty Flag is set or not 03375 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03376 * FIFO mode feature is supported by the USARTx instance. 03377 * @rmtoll ISR TXFE LL_USART_IsActiveFlag_TXFE 03378 * @param USARTx USART Instance 03379 * @retval State of bit (1 or 0). 03380 */ 03381 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXFE(USART_TypeDef *USARTx) 03382 { 03383 return ((READ_BIT(USARTx->ISR, USART_ISR_TXFE) == (USART_ISR_TXFE)) ? 1UL : 0UL); 03384 } 03385 03386 /** 03387 * @brief Check if the USART RX FIFO Full Flag is set or not 03388 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03389 * FIFO mode feature is supported by the USARTx instance. 03390 * @rmtoll ISR RXFF LL_USART_IsActiveFlag_RXFF 03391 * @param USARTx USART Instance 03392 * @retval State of bit (1 or 0). 03393 */ 03394 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXFF(USART_TypeDef *USARTx) 03395 { 03396 return ((READ_BIT(USARTx->ISR, USART_ISR_RXFF) == (USART_ISR_RXFF)) ? 1UL : 0UL); 03397 } 03398 03399 #endif /* USART_CR1_FIFOEN */ 03400 #if defined(USART_TCBGT_SUPPORT) 03401 /* Function available only on devices supporting Transmit Complete before Guard Time feature */ 03402 /** 03403 * @brief Check if the Smartcard Transmission Complete Before Guard Time Flag is set or not 03404 * @rmtoll ISR TCBGT LL_USART_IsActiveFlag_TCBGT 03405 * @param USARTx USART Instance 03406 * @retval State of bit (1 or 0). 03407 */ 03408 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TCBGT(USART_TypeDef *USARTx) 03409 { 03410 return ((READ_BIT(USARTx->ISR, USART_ISR_TCBGT) == (USART_ISR_TCBGT)) ? 1UL : 0UL); 03411 } 03412 03413 #endif /* USART_TCBGT_SUPPORT */ 03414 #if defined(USART_CR1_FIFOEN) 03415 /** 03416 * @brief Check if the USART TX FIFO Threshold Flag is set or not 03417 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03418 * FIFO mode feature is supported by the USARTx instance. 03419 * @rmtoll ISR TXFT LL_USART_IsActiveFlag_TXFT 03420 * @param USARTx USART Instance 03421 * @retval State of bit (1 or 0). 03422 */ 03423 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXFT(USART_TypeDef *USARTx) 03424 { 03425 return ((READ_BIT(USARTx->ISR, USART_ISR_TXFT) == (USART_ISR_TXFT)) ? 1UL : 0UL); 03426 } 03427 03428 /** 03429 * @brief Check if the USART RX FIFO Threshold Flag is set or not 03430 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03431 * FIFO mode feature is supported by the USARTx instance. 03432 * @rmtoll ISR RXFT LL_USART_IsActiveFlag_RXFT 03433 * @param USARTx USART Instance 03434 * @retval State of bit (1 or 0). 03435 */ 03436 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXFT(USART_TypeDef *USARTx) 03437 { 03438 return ((READ_BIT(USARTx->ISR, USART_ISR_RXFT) == (USART_ISR_RXFT)) ? 1UL : 0UL); 03439 } 03440 03441 #endif /* USART_CR1_FIFOEN */ 03442 /** 03443 * @brief Clear Parity Error Flag 03444 * @rmtoll ICR PECF LL_USART_ClearFlag_PE 03445 * @param USARTx USART Instance 03446 * @retval None 03447 */ 03448 __STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx) 03449 { 03450 WRITE_REG(USARTx->ICR, USART_ICR_PECF); 03451 } 03452 03453 /** 03454 * @brief Clear Framing Error Flag 03455 * @rmtoll ICR FECF LL_USART_ClearFlag_FE 03456 * @param USARTx USART Instance 03457 * @retval None 03458 */ 03459 __STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx) 03460 { 03461 WRITE_REG(USARTx->ICR, USART_ICR_FECF); 03462 } 03463 03464 /** 03465 * @brief Clear Noise Error detected Flag 03466 * @rmtoll ICR NECF LL_USART_ClearFlag_NE 03467 * @param USARTx USART Instance 03468 * @retval None 03469 */ 03470 __STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx) 03471 { 03472 WRITE_REG(USARTx->ICR, USART_ICR_NECF); 03473 } 03474 03475 /** 03476 * @brief Clear OverRun Error Flag 03477 * @rmtoll ICR ORECF LL_USART_ClearFlag_ORE 03478 * @param USARTx USART Instance 03479 * @retval None 03480 */ 03481 __STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx) 03482 { 03483 WRITE_REG(USARTx->ICR, USART_ICR_ORECF); 03484 } 03485 03486 /** 03487 * @brief Clear IDLE line detected Flag 03488 * @rmtoll ICR IDLECF LL_USART_ClearFlag_IDLE 03489 * @param USARTx USART Instance 03490 * @retval None 03491 */ 03492 __STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx) 03493 { 03494 WRITE_REG(USARTx->ICR, USART_ICR_IDLECF); 03495 } 03496 03497 #if defined(USART_CR1_FIFOEN) 03498 /** 03499 * @brief Clear TX FIFO Empty Flag 03500 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03501 * FIFO mode feature is supported by the USARTx instance. 03502 * @rmtoll ICR TXFECF LL_USART_ClearFlag_TXFE 03503 * @param USARTx USART Instance 03504 * @retval None 03505 */ 03506 __STATIC_INLINE void LL_USART_ClearFlag_TXFE(USART_TypeDef *USARTx) 03507 { 03508 WRITE_REG(USARTx->ICR, USART_ICR_TXFECF); 03509 } 03510 03511 #endif /* USART_CR1_FIFOEN */ 03512 /** 03513 * @brief Clear Transmission Complete Flag 03514 * @rmtoll ICR TCCF LL_USART_ClearFlag_TC 03515 * @param USARTx USART Instance 03516 * @retval None 03517 */ 03518 __STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx) 03519 { 03520 WRITE_REG(USARTx->ICR, USART_ICR_TCCF); 03521 } 03522 03523 #if defined(USART_TCBGT_SUPPORT) 03524 /* Function available only on devices supporting Transmit Complete before Guard Time feature */ 03525 /** 03526 * @brief Clear Smartcard Transmission Complete Before Guard Time Flag 03527 * @rmtoll ICR TCBGTCF LL_USART_ClearFlag_TCBGT 03528 * @param USARTx USART Instance 03529 * @retval None 03530 */ 03531 __STATIC_INLINE void LL_USART_ClearFlag_TCBGT(USART_TypeDef *USARTx) 03532 { 03533 WRITE_REG(USARTx->ICR, USART_ICR_TCBGTCF); 03534 } 03535 #endif /* USART_TCBGT_SUPPORT */ 03536 03537 /** 03538 * @brief Clear LIN Break Detection Flag 03539 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 03540 * LIN feature is supported by the USARTx instance. 03541 * @rmtoll ICR LBDCF LL_USART_ClearFlag_LBD 03542 * @param USARTx USART Instance 03543 * @retval None 03544 */ 03545 __STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx) 03546 { 03547 WRITE_REG(USARTx->ICR, USART_ICR_LBDCF); 03548 } 03549 03550 /** 03551 * @brief Clear CTS Interrupt Flag 03552 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 03553 * Hardware Flow control feature is supported by the USARTx instance. 03554 * @rmtoll ICR CTSCF LL_USART_ClearFlag_nCTS 03555 * @param USARTx USART Instance 03556 * @retval None 03557 */ 03558 __STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx) 03559 { 03560 WRITE_REG(USARTx->ICR, USART_ICR_CTSCF); 03561 } 03562 03563 /** 03564 * @brief Clear Receiver Time Out Flag 03565 * @rmtoll ICR RTOCF LL_USART_ClearFlag_RTO 03566 * @param USARTx USART Instance 03567 * @retval None 03568 */ 03569 __STATIC_INLINE void LL_USART_ClearFlag_RTO(USART_TypeDef *USARTx) 03570 { 03571 WRITE_REG(USARTx->ICR, USART_ICR_RTOCF); 03572 } 03573 03574 /** 03575 * @brief Clear End Of Block Flag 03576 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 03577 * Smartcard feature is supported by the USARTx instance. 03578 * @rmtoll ICR EOBCF LL_USART_ClearFlag_EOB 03579 * @param USARTx USART Instance 03580 * @retval None 03581 */ 03582 __STATIC_INLINE void LL_USART_ClearFlag_EOB(USART_TypeDef *USARTx) 03583 { 03584 WRITE_REG(USARTx->ICR, USART_ICR_EOBCF); 03585 } 03586 03587 #if defined(USART_CR2_SLVEN) 03588 /** 03589 * @brief Clear SPI Slave Underrun Flag 03590 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 03591 * SPI Slave mode feature is supported by the USARTx instance. 03592 * @rmtoll ICR UDRCF LL_USART_ClearFlag_UDR 03593 * @param USARTx USART Instance 03594 * @retval None 03595 */ 03596 __STATIC_INLINE void LL_USART_ClearFlag_UDR(USART_TypeDef *USARTx) 03597 { 03598 WRITE_REG(USARTx->ICR, USART_ICR_UDRCF); 03599 } 03600 03601 #endif /* USART_CR2_SLVEN */ 03602 /** 03603 * @brief Clear Character Match Flag 03604 * @rmtoll ICR CMCF LL_USART_ClearFlag_CM 03605 * @param USARTx USART Instance 03606 * @retval None 03607 */ 03608 __STATIC_INLINE void LL_USART_ClearFlag_CM(USART_TypeDef *USARTx) 03609 { 03610 WRITE_REG(USARTx->ICR, USART_ICR_CMCF); 03611 } 03612 03613 /** 03614 * @brief Clear Wake Up from stop mode Flag 03615 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 03616 * Wake-up from Stop mode feature is supported by the USARTx instance. 03617 * @rmtoll ICR WUCF LL_USART_ClearFlag_WKUP 03618 * @param USARTx USART Instance 03619 * @retval None 03620 */ 03621 __STATIC_INLINE void LL_USART_ClearFlag_WKUP(USART_TypeDef *USARTx) 03622 { 03623 WRITE_REG(USARTx->ICR, USART_ICR_WUCF); 03624 } 03625 03626 /** 03627 * @} 03628 */ 03629 03630 /** @defgroup USART_LL_EF_IT_Management IT_Management 03631 * @{ 03632 */ 03633 03634 /** 03635 * @brief Enable IDLE Interrupt 03636 * @rmtoll CR1 IDLEIE LL_USART_EnableIT_IDLE 03637 * @param USARTx USART Instance 03638 * @retval None 03639 */ 03640 __STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx) 03641 { 03642 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_IDLEIE); 03643 } 03644 03645 #if defined(USART_CR1_FIFOEN) 03646 /* Legacy define */ 03647 #define LL_USART_EnableIT_RXNE LL_USART_EnableIT_RXNE_RXFNE 03648 03649 /** 03650 * @brief Enable RX Not Empty and RX FIFO Not Empty Interrupt 03651 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03652 * FIFO mode feature is supported by the USARTx instance. 03653 * @rmtoll CR1 RXNEIE_RXFNEIE LL_USART_EnableIT_RXNE_RXFNE 03654 * @param USARTx USART Instance 03655 * @retval None 03656 */ 03657 __STATIC_INLINE void LL_USART_EnableIT_RXNE_RXFNE(USART_TypeDef *USARTx) 03658 { 03659 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_RXNEIE_RXFNEIE); 03660 } 03661 03662 #else 03663 /** 03664 * @brief Enable RX Not Empty Interrupt 03665 * @rmtoll CR1 RXNEIE LL_USART_EnableIT_RXNE 03666 * @param USARTx USART Instance 03667 * @retval None 03668 */ 03669 __STATIC_INLINE void LL_USART_EnableIT_RXNE(USART_TypeDef *USARTx) 03670 { 03671 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_RXNEIE); 03672 } 03673 03674 #endif /* USART_CR1_FIFOEN */ 03675 /** 03676 * @brief Enable Transmission Complete Interrupt 03677 * @rmtoll CR1 TCIE LL_USART_EnableIT_TC 03678 * @param USARTx USART Instance 03679 * @retval None 03680 */ 03681 __STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx) 03682 { 03683 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_TCIE); 03684 } 03685 03686 #if defined(USART_CR1_FIFOEN) 03687 /* Legacy define */ 03688 #define LL_USART_EnableIT_TXE LL_USART_EnableIT_TXE_TXFNF 03689 03690 /** 03691 * @brief Enable TX Empty and TX FIFO Not Full Interrupt 03692 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03693 * FIFO mode feature is supported by the USARTx instance. 03694 * @rmtoll CR1 TXEIE_TXFNFIE LL_USART_EnableIT_TXE_TXFNF 03695 * @param USARTx USART Instance 03696 * @retval None 03697 */ 03698 __STATIC_INLINE void LL_USART_EnableIT_TXE_TXFNF(USART_TypeDef *USARTx) 03699 { 03700 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_TXEIE_TXFNFIE); 03701 } 03702 03703 #else 03704 /** 03705 * @brief Enable TX Empty Interrupt 03706 * @rmtoll CR1 TXEIE LL_USART_EnableIT_TXE 03707 * @param USARTx USART Instance 03708 * @retval None 03709 */ 03710 __STATIC_INLINE void LL_USART_EnableIT_TXE(USART_TypeDef *USARTx) 03711 { 03712 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_TXEIE); 03713 } 03714 03715 #endif /* USART_CR1_FIFOEN */ 03716 /** 03717 * @brief Enable Parity Error Interrupt 03718 * @rmtoll CR1 PEIE LL_USART_EnableIT_PE 03719 * @param USARTx USART Instance 03720 * @retval None 03721 */ 03722 __STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx) 03723 { 03724 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_PEIE); 03725 } 03726 03727 /** 03728 * @brief Enable Character Match Interrupt 03729 * @rmtoll CR1 CMIE LL_USART_EnableIT_CM 03730 * @param USARTx USART Instance 03731 * @retval None 03732 */ 03733 __STATIC_INLINE void LL_USART_EnableIT_CM(USART_TypeDef *USARTx) 03734 { 03735 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_CMIE); 03736 } 03737 03738 /** 03739 * @brief Enable Receiver Timeout Interrupt 03740 * @rmtoll CR1 RTOIE LL_USART_EnableIT_RTO 03741 * @param USARTx USART Instance 03742 * @retval None 03743 */ 03744 __STATIC_INLINE void LL_USART_EnableIT_RTO(USART_TypeDef *USARTx) 03745 { 03746 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_RTOIE); 03747 } 03748 03749 /** 03750 * @brief Enable End Of Block Interrupt 03751 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 03752 * Smartcard feature is supported by the USARTx instance. 03753 * @rmtoll CR1 EOBIE LL_USART_EnableIT_EOB 03754 * @param USARTx USART Instance 03755 * @retval None 03756 */ 03757 __STATIC_INLINE void LL_USART_EnableIT_EOB(USART_TypeDef *USARTx) 03758 { 03759 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_EOBIE); 03760 } 03761 03762 #if defined(USART_CR1_FIFOEN) 03763 /** 03764 * @brief Enable TX FIFO Empty Interrupt 03765 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03766 * FIFO mode feature is supported by the USARTx instance. 03767 * @rmtoll CR1 TXFEIE LL_USART_EnableIT_TXFE 03768 * @param USARTx USART Instance 03769 * @retval None 03770 */ 03771 __STATIC_INLINE void LL_USART_EnableIT_TXFE(USART_TypeDef *USARTx) 03772 { 03773 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_TXFEIE); 03774 } 03775 03776 /** 03777 * @brief Enable RX FIFO Full Interrupt 03778 * @rmtoll CR1 RXFFIE LL_USART_EnableIT_RXFF 03779 * @param USARTx USART Instance 03780 * @retval None 03781 */ 03782 __STATIC_INLINE void LL_USART_EnableIT_RXFF(USART_TypeDef *USARTx) 03783 { 03784 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_RXFFIE); 03785 } 03786 03787 #endif /* USART_CR1_FIFOEN */ 03788 /** 03789 * @brief Enable LIN Break Detection Interrupt 03790 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 03791 * LIN feature is supported by the USARTx instance. 03792 * @rmtoll CR2 LBDIE LL_USART_EnableIT_LBD 03793 * @param USARTx USART Instance 03794 * @retval None 03795 */ 03796 __STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx) 03797 { 03798 SET_BIT(USARTx->CR2, USART_CR2_LBDIE); 03799 } 03800 03801 /** 03802 * @brief Enable Error Interrupt 03803 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing 03804 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register). 03805 * 0: Interrupt is inhibited 03806 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register. 03807 * @rmtoll CR3 EIE LL_USART_EnableIT_ERROR 03808 * @param USARTx USART Instance 03809 * @retval None 03810 */ 03811 __STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx) 03812 { 03813 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_EIE); 03814 } 03815 03816 /** 03817 * @brief Enable CTS Interrupt 03818 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 03819 * Hardware Flow control feature is supported by the USARTx instance. 03820 * @rmtoll CR3 CTSIE LL_USART_EnableIT_CTS 03821 * @param USARTx USART Instance 03822 * @retval None 03823 */ 03824 __STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx) 03825 { 03826 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_CTSIE); 03827 } 03828 03829 /** 03830 * @brief Enable Wake Up from Stop Mode Interrupt 03831 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 03832 * Wake-up from Stop mode feature is supported by the USARTx instance. 03833 * @rmtoll CR3 WUFIE LL_USART_EnableIT_WKUP 03834 * @param USARTx USART Instance 03835 * @retval None 03836 */ 03837 __STATIC_INLINE void LL_USART_EnableIT_WKUP(USART_TypeDef *USARTx) 03838 { 03839 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_WUFIE); 03840 } 03841 03842 #if defined(USART_CR1_FIFOEN) 03843 /** 03844 * @brief Enable TX FIFO Threshold Interrupt 03845 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03846 * FIFO mode feature is supported by the USARTx instance. 03847 * @rmtoll CR3 TXFTIE LL_USART_EnableIT_TXFT 03848 * @param USARTx USART Instance 03849 * @retval None 03850 */ 03851 __STATIC_INLINE void LL_USART_EnableIT_TXFT(USART_TypeDef *USARTx) 03852 { 03853 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_TXFTIE); 03854 } 03855 03856 #endif /* USART_CR1_FIFOEN */ 03857 #if defined(USART_TCBGT_SUPPORT) 03858 /* Function available only on devices supporting Transmit Complete before Guard Time feature */ 03859 /** 03860 * @brief Enable Smartcard Transmission Complete Before Guard Time Interrupt 03861 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 03862 * Smartcard feature is supported by the USARTx instance. 03863 * @rmtoll CR3 TCBGTIE LL_USART_EnableIT_TCBGT 03864 * @param USARTx USART Instance 03865 * @retval None 03866 */ 03867 __STATIC_INLINE void LL_USART_EnableIT_TCBGT(USART_TypeDef *USARTx) 03868 { 03869 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_TCBGTIE); 03870 } 03871 #endif /* USART_TCBGT_SUPPORT */ 03872 03873 #if defined(USART_CR1_FIFOEN) 03874 /** 03875 * @brief Enable RX FIFO Threshold Interrupt 03876 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03877 * FIFO mode feature is supported by the USARTx instance. 03878 * @rmtoll CR3 RXFTIE LL_USART_EnableIT_RXFT 03879 * @param USARTx USART Instance 03880 * @retval None 03881 */ 03882 __STATIC_INLINE void LL_USART_EnableIT_RXFT(USART_TypeDef *USARTx) 03883 { 03884 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_RXFTIE); 03885 } 03886 03887 #endif /* USART_CR1_FIFOEN */ 03888 /** 03889 * @brief Disable IDLE Interrupt 03890 * @rmtoll CR1 IDLEIE LL_USART_DisableIT_IDLE 03891 * @param USARTx USART Instance 03892 * @retval None 03893 */ 03894 __STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx) 03895 { 03896 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE); 03897 } 03898 03899 #if defined(USART_CR1_FIFOEN) 03900 /* Legacy define */ 03901 #define LL_USART_DisableIT_RXNE LL_USART_DisableIT_RXNE_RXFNE 03902 03903 /** 03904 * @brief Disable RX Not Empty and RX FIFO Not Empty Interrupt 03905 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03906 * FIFO mode feature is supported by the USARTx instance. 03907 * @rmtoll CR1 RXNEIE_RXFNEIE LL_USART_DisableIT_RXNE_RXFNE 03908 * @param USARTx USART Instance 03909 * @retval None 03910 */ 03911 __STATIC_INLINE void LL_USART_DisableIT_RXNE_RXFNE(USART_TypeDef *USARTx) 03912 { 03913 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE_RXFNEIE); 03914 } 03915 03916 #else 03917 /** 03918 * @brief Disable RX Not Empty Interrupt 03919 * @rmtoll CR1 RXNEIE LL_USART_DisableIT_RXNE 03920 * @param USARTx USART Instance 03921 * @retval None 03922 */ 03923 __STATIC_INLINE void LL_USART_DisableIT_RXNE(USART_TypeDef *USARTx) 03924 { 03925 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE); 03926 } 03927 03928 #endif /* USART_CR1_FIFOEN */ 03929 /** 03930 * @brief Disable Transmission Complete Interrupt 03931 * @rmtoll CR1 TCIE LL_USART_DisableIT_TC 03932 * @param USARTx USART Instance 03933 * @retval None 03934 */ 03935 __STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx) 03936 { 03937 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE); 03938 } 03939 03940 #if defined(USART_CR1_FIFOEN) 03941 /* Legacy define */ 03942 #define LL_USART_DisableIT_TXE LL_USART_DisableIT_TXE_TXFNF 03943 03944 /** 03945 * @brief Disable TX Empty and TX FIFO Not Full Interrupt 03946 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 03947 * FIFO mode feature is supported by the USARTx instance. 03948 * @rmtoll CR1 TXEIE_TXFNFIE LL_USART_DisableIT_TXE_TXFNF 03949 * @param USARTx USART Instance 03950 * @retval None 03951 */ 03952 __STATIC_INLINE void LL_USART_DisableIT_TXE_TXFNF(USART_TypeDef *USARTx) 03953 { 03954 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE_TXFNFIE); 03955 } 03956 03957 #else 03958 /** 03959 * @brief Disable TX Empty Interrupt 03960 * @rmtoll CR1 TXEIE LL_USART_DisableIT_TXE 03961 * @param USARTx USART Instance 03962 * @retval None 03963 */ 03964 __STATIC_INLINE void LL_USART_DisableIT_TXE(USART_TypeDef *USARTx) 03965 { 03966 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE); 03967 } 03968 03969 #endif /* USART_CR1_FIFOEN */ 03970 /** 03971 * @brief Disable Parity Error Interrupt 03972 * @rmtoll CR1 PEIE LL_USART_DisableIT_PE 03973 * @param USARTx USART Instance 03974 * @retval None 03975 */ 03976 __STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx) 03977 { 03978 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE); 03979 } 03980 03981 /** 03982 * @brief Disable Character Match Interrupt 03983 * @rmtoll CR1 CMIE LL_USART_DisableIT_CM 03984 * @param USARTx USART Instance 03985 * @retval None 03986 */ 03987 __STATIC_INLINE void LL_USART_DisableIT_CM(USART_TypeDef *USARTx) 03988 { 03989 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_CMIE); 03990 } 03991 03992 /** 03993 * @brief Disable Receiver Timeout Interrupt 03994 * @rmtoll CR1 RTOIE LL_USART_DisableIT_RTO 03995 * @param USARTx USART Instance 03996 * @retval None 03997 */ 03998 __STATIC_INLINE void LL_USART_DisableIT_RTO(USART_TypeDef *USARTx) 03999 { 04000 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_RTOIE); 04001 } 04002 04003 /** 04004 * @brief Disable End Of Block Interrupt 04005 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 04006 * Smartcard feature is supported by the USARTx instance. 04007 * @rmtoll CR1 EOBIE LL_USART_DisableIT_EOB 04008 * @param USARTx USART Instance 04009 * @retval None 04010 */ 04011 __STATIC_INLINE void LL_USART_DisableIT_EOB(USART_TypeDef *USARTx) 04012 { 04013 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_EOBIE); 04014 } 04015 04016 #if defined(USART_CR1_FIFOEN) 04017 /** 04018 * @brief Disable TX FIFO Empty Interrupt 04019 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 04020 * FIFO mode feature is supported by the USARTx instance. 04021 * @rmtoll CR1 TXFEIE LL_USART_DisableIT_TXFE 04022 * @param USARTx USART Instance 04023 * @retval None 04024 */ 04025 __STATIC_INLINE void LL_USART_DisableIT_TXFE(USART_TypeDef *USARTx) 04026 { 04027 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_TXFEIE); 04028 } 04029 04030 /** 04031 * @brief Disable RX FIFO Full Interrupt 04032 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 04033 * FIFO mode feature is supported by the USARTx instance. 04034 * @rmtoll CR1 RXFFIE LL_USART_DisableIT_RXFF 04035 * @param USARTx USART Instance 04036 * @retval None 04037 */ 04038 __STATIC_INLINE void LL_USART_DisableIT_RXFF(USART_TypeDef *USARTx) 04039 { 04040 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_RXFFIE); 04041 } 04042 04043 #endif /* USART_CR1_FIFOEN */ 04044 /** 04045 * @brief Disable LIN Break Detection Interrupt 04046 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 04047 * LIN feature is supported by the USARTx instance. 04048 * @rmtoll CR2 LBDIE LL_USART_DisableIT_LBD 04049 * @param USARTx USART Instance 04050 * @retval None 04051 */ 04052 __STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx) 04053 { 04054 CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE); 04055 } 04056 04057 /** 04058 * @brief Disable Error Interrupt 04059 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing 04060 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register). 04061 * 0: Interrupt is inhibited 04062 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register. 04063 * @rmtoll CR3 EIE LL_USART_DisableIT_ERROR 04064 * @param USARTx USART Instance 04065 * @retval None 04066 */ 04067 __STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx) 04068 { 04069 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_EIE); 04070 } 04071 04072 /** 04073 * @brief Disable CTS Interrupt 04074 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 04075 * Hardware Flow control feature is supported by the USARTx instance. 04076 * @rmtoll CR3 CTSIE LL_USART_DisableIT_CTS 04077 * @param USARTx USART Instance 04078 * @retval None 04079 */ 04080 __STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx) 04081 { 04082 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE); 04083 } 04084 04085 /** 04086 * @brief Disable Wake Up from Stop Mode Interrupt 04087 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 04088 * Wake-up from Stop mode feature is supported by the USARTx instance. 04089 * @rmtoll CR3 WUFIE LL_USART_DisableIT_WKUP 04090 * @param USARTx USART Instance 04091 * @retval None 04092 */ 04093 __STATIC_INLINE void LL_USART_DisableIT_WKUP(USART_TypeDef *USARTx) 04094 { 04095 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_WUFIE); 04096 } 04097 04098 #if defined(USART_CR1_FIFOEN) 04099 /** 04100 * @brief Disable TX FIFO Threshold Interrupt 04101 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 04102 * FIFO mode feature is supported by the USARTx instance. 04103 * @rmtoll CR3 TXFTIE LL_USART_DisableIT_TXFT 04104 * @param USARTx USART Instance 04105 * @retval None 04106 */ 04107 __STATIC_INLINE void LL_USART_DisableIT_TXFT(USART_TypeDef *USARTx) 04108 { 04109 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_TXFTIE); 04110 } 04111 04112 #endif /* USART_CR1_FIFOEN */ 04113 #if defined(USART_TCBGT_SUPPORT) 04114 /* Function available only on devices supporting Transmit Complete before Guard Time feature */ 04115 /** 04116 * @brief Disable Smartcard Transmission Complete Before Guard Time Interrupt 04117 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 04118 * Smartcard feature is supported by the USARTx instance. 04119 * @rmtoll CR3 TCBGTIE LL_USART_DisableIT_TCBGT 04120 * @param USARTx USART Instance 04121 * @retval None 04122 */ 04123 __STATIC_INLINE void LL_USART_DisableIT_TCBGT(USART_TypeDef *USARTx) 04124 { 04125 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_TCBGTIE); 04126 } 04127 #endif /* USART_TCBGT_SUPPORT */ 04128 04129 #if defined(USART_CR1_FIFOEN) 04130 /** 04131 * @brief Disable RX FIFO Threshold Interrupt 04132 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 04133 * FIFO mode feature is supported by the USARTx instance. 04134 * @rmtoll CR3 RXFTIE LL_USART_DisableIT_RXFT 04135 * @param USARTx USART Instance 04136 * @retval None 04137 */ 04138 __STATIC_INLINE void LL_USART_DisableIT_RXFT(USART_TypeDef *USARTx) 04139 { 04140 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_RXFTIE); 04141 } 04142 04143 #endif /* USART_CR1_FIFOEN */ 04144 /** 04145 * @brief Check if the USART IDLE Interrupt source is enabled or disabled. 04146 * @rmtoll CR1 IDLEIE LL_USART_IsEnabledIT_IDLE 04147 * @param USARTx USART Instance 04148 * @retval State of bit (1 or 0). 04149 */ 04150 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(USART_TypeDef *USARTx) 04151 { 04152 return ((READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE)) ? 1UL : 0UL); 04153 } 04154 04155 #if defined(USART_CR1_FIFOEN) 04156 /* Legacy define */ 04157 #define LL_USART_IsEnabledIT_RXNE LL_USART_IsEnabledIT_RXNE_RXFNE 04158 04159 /** 04160 * @brief Check if the USART RX Not Empty and USART RX FIFO Not Empty Interrupt is enabled or disabled. 04161 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 04162 * FIFO mode feature is supported by the USARTx instance. 04163 * @rmtoll CR1 RXNEIE_RXFNEIE LL_USART_IsEnabledIT_RXNE_RXFNE 04164 * @param USARTx USART Instance 04165 * @retval State of bit (1 or 0). 04166 */ 04167 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE_RXFNE(USART_TypeDef *USARTx) 04168 { 04169 return ((READ_BIT(USARTx->CR1, USART_CR1_RXNEIE_RXFNEIE) == (USART_CR1_RXNEIE_RXFNEIE)) ? 1UL : 0UL); 04170 } 04171 04172 #else 04173 /** 04174 * @brief Check if the USART RX Not Empty Interrupt is enabled or disabled. 04175 * @rmtoll CR1 RXNEIE LL_USART_IsEnabledIT_RXNE 04176 * @param USARTx USART Instance 04177 * @retval State of bit (1 or 0). 04178 */ 04179 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE(USART_TypeDef *USARTx) 04180 { 04181 return ((READ_BIT(USARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE)) ? 1U : 0U); 04182 } 04183 04184 #endif /* USART_CR1_FIFOEN */ 04185 /** 04186 * @brief Check if the USART Transmission Complete Interrupt is enabled or disabled. 04187 * @rmtoll CR1 TCIE LL_USART_IsEnabledIT_TC 04188 * @param USARTx USART Instance 04189 * @retval State of bit (1 or 0). 04190 */ 04191 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(USART_TypeDef *USARTx) 04192 { 04193 return ((READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE)) ? 1UL : 0UL); 04194 } 04195 04196 #if defined(USART_CR1_FIFOEN) 04197 /* Legacy define */ 04198 #define LL_USART_IsEnabledIT_TXE LL_USART_IsEnabledIT_TXE_TXFNF 04199 04200 /** 04201 * @brief Check if the USART TX Empty and USART TX FIFO Not Full Interrupt is enabled or disabled 04202 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 04203 * FIFO mode feature is supported by the USARTx instance. 04204 * @rmtoll CR1 TXEIE_TXFNFIE LL_USART_IsEnabledIT_TXE_TXFNF 04205 * @param USARTx USART Instance 04206 * @retval State of bit (1 or 0). 04207 */ 04208 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE_TXFNF(USART_TypeDef *USARTx) 04209 { 04210 return ((READ_BIT(USARTx->CR1, USART_CR1_TXEIE_TXFNFIE) == (USART_CR1_TXEIE_TXFNFIE)) ? 1UL : 0UL); 04211 } 04212 04213 #else 04214 /** 04215 * @brief Check if the USART TX Empty Interrupt is enabled or disabled. 04216 * @rmtoll CR1 TXEIE LL_USART_IsEnabledIT_TXE 04217 * @param USARTx USART Instance 04218 * @retval State of bit (1 or 0). 04219 */ 04220 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE(USART_TypeDef *USARTx) 04221 { 04222 return ((READ_BIT(USARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE)) ? 1U : 0U); 04223 } 04224 04225 #endif /* USART_CR1_FIFOEN */ 04226 /** 04227 * @brief Check if the USART Parity Error Interrupt is enabled or disabled. 04228 * @rmtoll CR1 PEIE LL_USART_IsEnabledIT_PE 04229 * @param USARTx USART Instance 04230 * @retval State of bit (1 or 0). 04231 */ 04232 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(USART_TypeDef *USARTx) 04233 { 04234 return ((READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE)) ? 1UL : 0UL); 04235 } 04236 04237 /** 04238 * @brief Check if the USART Character Match Interrupt is enabled or disabled. 04239 * @rmtoll CR1 CMIE LL_USART_IsEnabledIT_CM 04240 * @param USARTx USART Instance 04241 * @retval State of bit (1 or 0). 04242 */ 04243 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CM(USART_TypeDef *USARTx) 04244 { 04245 return ((READ_BIT(USARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE)) ? 1UL : 0UL); 04246 } 04247 04248 /** 04249 * @brief Check if the USART Receiver Timeout Interrupt is enabled or disabled. 04250 * @rmtoll CR1 RTOIE LL_USART_IsEnabledIT_RTO 04251 * @param USARTx USART Instance 04252 * @retval State of bit (1 or 0). 04253 */ 04254 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RTO(USART_TypeDef *USARTx) 04255 { 04256 return ((READ_BIT(USARTx->CR1, USART_CR1_RTOIE) == (USART_CR1_RTOIE)) ? 1UL : 0UL); 04257 } 04258 04259 /** 04260 * @brief Check if the USART End Of Block Interrupt is enabled or disabled. 04261 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 04262 * Smartcard feature is supported by the USARTx instance. 04263 * @rmtoll CR1 EOBIE LL_USART_IsEnabledIT_EOB 04264 * @param USARTx USART Instance 04265 * @retval State of bit (1 or 0). 04266 */ 04267 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_EOB(USART_TypeDef *USARTx) 04268 { 04269 return ((READ_BIT(USARTx->CR1, USART_CR1_EOBIE) == (USART_CR1_EOBIE)) ? 1UL : 0UL); 04270 } 04271 04272 #if defined(USART_CR1_FIFOEN) 04273 /** 04274 * @brief Check if the USART TX FIFO Empty Interrupt is enabled or disabled 04275 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 04276 * FIFO mode feature is supported by the USARTx instance. 04277 * @rmtoll CR1 TXFEIE LL_USART_IsEnabledIT_TXFE 04278 * @param USARTx USART Instance 04279 * @retval State of bit (1 or 0). 04280 */ 04281 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXFE(USART_TypeDef *USARTx) 04282 { 04283 return ((READ_BIT(USARTx->CR1, USART_CR1_TXFEIE) == (USART_CR1_TXFEIE)) ? 1UL : 0UL); 04284 } 04285 04286 /** 04287 * @brief Check if the USART RX FIFO Full Interrupt is enabled or disabled 04288 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 04289 * FIFO mode feature is supported by the USARTx instance. 04290 * @rmtoll CR1 RXFFIE LL_USART_IsEnabledIT_RXFF 04291 * @param USARTx USART Instance 04292 * @retval State of bit (1 or 0). 04293 */ 04294 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXFF(USART_TypeDef *USARTx) 04295 { 04296 return ((READ_BIT(USARTx->CR1, USART_CR1_RXFFIE) == (USART_CR1_RXFFIE)) ? 1UL : 0UL); 04297 } 04298 04299 #endif /* USART_CR1_FIFOEN */ 04300 /** 04301 * @brief Check if the USART LIN Break Detection Interrupt is enabled or disabled. 04302 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 04303 * LIN feature is supported by the USARTx instance. 04304 * @rmtoll CR2 LBDIE LL_USART_IsEnabledIT_LBD 04305 * @param USARTx USART Instance 04306 * @retval State of bit (1 or 0). 04307 */ 04308 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(USART_TypeDef *USARTx) 04309 { 04310 return ((READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE)) ? 1UL : 0UL); 04311 } 04312 04313 /** 04314 * @brief Check if the USART Error Interrupt is enabled or disabled. 04315 * @rmtoll CR3 EIE LL_USART_IsEnabledIT_ERROR 04316 * @param USARTx USART Instance 04317 * @retval State of bit (1 or 0). 04318 */ 04319 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(USART_TypeDef *USARTx) 04320 { 04321 return ((READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE)) ? 1UL : 0UL); 04322 } 04323 04324 /** 04325 * @brief Check if the USART CTS Interrupt is enabled or disabled. 04326 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 04327 * Hardware Flow control feature is supported by the USARTx instance. 04328 * @rmtoll CR3 CTSIE LL_USART_IsEnabledIT_CTS 04329 * @param USARTx USART Instance 04330 * @retval State of bit (1 or 0). 04331 */ 04332 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(USART_TypeDef *USARTx) 04333 { 04334 return ((READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE)) ? 1UL : 0UL); 04335 } 04336 04337 /** 04338 * @brief Check if the USART Wake Up from Stop Mode Interrupt is enabled or disabled. 04339 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 04340 * Wake-up from Stop mode feature is supported by the USARTx instance. 04341 * @rmtoll CR3 WUFIE LL_USART_IsEnabledIT_WKUP 04342 * @param USARTx USART Instance 04343 * @retval State of bit (1 or 0). 04344 */ 04345 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_WKUP(USART_TypeDef *USARTx) 04346 { 04347 return ((READ_BIT(USARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE)) ? 1UL : 0UL); 04348 } 04349 04350 #if defined(USART_CR1_FIFOEN) 04351 /** 04352 * @brief Check if USART TX FIFO Threshold Interrupt is enabled or disabled 04353 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 04354 * FIFO mode feature is supported by the USARTx instance. 04355 * @rmtoll CR3 TXFTIE LL_USART_IsEnabledIT_TXFT 04356 * @param USARTx USART Instance 04357 * @retval State of bit (1 or 0). 04358 */ 04359 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXFT(USART_TypeDef *USARTx) 04360 { 04361 return ((READ_BIT(USARTx->CR3, USART_CR3_TXFTIE) == (USART_CR3_TXFTIE)) ? 1UL : 0UL); 04362 } 04363 04364 #endif /* USART_CR1_FIFOEN */ 04365 #if defined(USART_TCBGT_SUPPORT) 04366 /* Function available only on devices supporting Transmit Complete before Guard Time feature */ 04367 /** 04368 * @brief Check if the Smartcard Transmission Complete Before Guard Time Interrupt is enabled or disabled. 04369 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 04370 * Smartcard feature is supported by the USARTx instance. 04371 * @rmtoll CR3 TCBGTIE LL_USART_IsEnabledIT_TCBGT 04372 * @param USARTx USART Instance 04373 * @retval State of bit (1 or 0). 04374 */ 04375 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TCBGT(USART_TypeDef *USARTx) 04376 { 04377 return ((READ_BIT(USARTx->CR3, USART_CR3_TCBGTIE) == (USART_CR3_TCBGTIE)) ? 1UL : 0UL); 04378 } 04379 #endif /* USART_TCBGT_SUPPORT */ 04380 04381 #if defined(USART_CR1_FIFOEN) 04382 /** 04383 * @brief Check if USART RX FIFO Threshold Interrupt is enabled or disabled 04384 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 04385 * FIFO mode feature is supported by the USARTx instance. 04386 * @rmtoll CR3 RXFTIE LL_USART_IsEnabledIT_RXFT 04387 * @param USARTx USART Instance 04388 * @retval State of bit (1 or 0). 04389 */ 04390 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXFT(USART_TypeDef *USARTx) 04391 { 04392 return ((READ_BIT(USARTx->CR3, USART_CR3_RXFTIE) == (USART_CR3_RXFTIE)) ? 1UL : 0UL); 04393 } 04394 04395 #endif /* USART_CR1_FIFOEN */ 04396 /** 04397 * @} 04398 */ 04399 04400 /** @defgroup USART_LL_EF_DMA_Management DMA_Management 04401 * @{ 04402 */ 04403 04404 /** 04405 * @brief Enable DMA Mode for reception 04406 * @rmtoll CR3 DMAR LL_USART_EnableDMAReq_RX 04407 * @param USARTx USART Instance 04408 * @retval None 04409 */ 04410 __STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx) 04411 { 04412 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_DMAR); 04413 } 04414 04415 /** 04416 * @brief Disable DMA Mode for reception 04417 * @rmtoll CR3 DMAR LL_USART_DisableDMAReq_RX 04418 * @param USARTx USART Instance 04419 * @retval None 04420 */ 04421 __STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx) 04422 { 04423 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR); 04424 } 04425 04426 /** 04427 * @brief Check if DMA Mode is enabled for reception 04428 * @rmtoll CR3 DMAR LL_USART_IsEnabledDMAReq_RX 04429 * @param USARTx USART Instance 04430 * @retval State of bit (1 or 0). 04431 */ 04432 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(USART_TypeDef *USARTx) 04433 { 04434 return ((READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR)) ? 1UL : 0UL); 04435 } 04436 04437 /** 04438 * @brief Enable DMA Mode for transmission 04439 * @rmtoll CR3 DMAT LL_USART_EnableDMAReq_TX 04440 * @param USARTx USART Instance 04441 * @retval None 04442 */ 04443 __STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx) 04444 { 04445 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_DMAT); 04446 } 04447 04448 /** 04449 * @brief Disable DMA Mode for transmission 04450 * @rmtoll CR3 DMAT LL_USART_DisableDMAReq_TX 04451 * @param USARTx USART Instance 04452 * @retval None 04453 */ 04454 __STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx) 04455 { 04456 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT); 04457 } 04458 04459 /** 04460 * @brief Check if DMA Mode is enabled for transmission 04461 * @rmtoll CR3 DMAT LL_USART_IsEnabledDMAReq_TX 04462 * @param USARTx USART Instance 04463 * @retval State of bit (1 or 0). 04464 */ 04465 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(USART_TypeDef *USARTx) 04466 { 04467 return ((READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT)) ? 1UL : 0UL); 04468 } 04469 04470 /** 04471 * @brief Enable DMA Disabling on Reception Error 04472 * @rmtoll CR3 DDRE LL_USART_EnableDMADeactOnRxErr 04473 * @param USARTx USART Instance 04474 * @retval None 04475 */ 04476 __STATIC_INLINE void LL_USART_EnableDMADeactOnRxErr(USART_TypeDef *USARTx) 04477 { 04478 SET_BIT(USARTx->CR3, USART_CR3_DDRE); 04479 } 04480 04481 /** 04482 * @brief Disable DMA Disabling on Reception Error 04483 * @rmtoll CR3 DDRE LL_USART_DisableDMADeactOnRxErr 04484 * @param USARTx USART Instance 04485 * @retval None 04486 */ 04487 __STATIC_INLINE void LL_USART_DisableDMADeactOnRxErr(USART_TypeDef *USARTx) 04488 { 04489 CLEAR_BIT(USARTx->CR3, USART_CR3_DDRE); 04490 } 04491 04492 /** 04493 * @brief Indicate if DMA Disabling on Reception Error is disabled 04494 * @rmtoll CR3 DDRE LL_USART_IsEnabledDMADeactOnRxErr 04495 * @param USARTx USART Instance 04496 * @retval State of bit (1 or 0). 04497 */ 04498 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMADeactOnRxErr(USART_TypeDef *USARTx) 04499 { 04500 return ((READ_BIT(USARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE)) ? 1UL : 0UL); 04501 } 04502 04503 /** 04504 * @brief Get the data register address used for DMA transfer 04505 * @rmtoll RDR RDR LL_USART_DMA_GetRegAddr\n 04506 * @rmtoll TDR TDR LL_USART_DMA_GetRegAddr 04507 * @param USARTx USART Instance 04508 * @param Direction This parameter can be one of the following values: 04509 * @arg @ref LL_USART_DMA_REG_DATA_TRANSMIT 04510 * @arg @ref LL_USART_DMA_REG_DATA_RECEIVE 04511 * @retval Address of data register 04512 */ 04513 __STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(USART_TypeDef *USARTx, uint32_t Direction) 04514 { 04515 uint32_t data_reg_addr; 04516 04517 if (Direction == LL_USART_DMA_REG_DATA_TRANSMIT) 04518 { 04519 /* return address of TDR register */ 04520 data_reg_addr = (uint32_t) &(USARTx->TDR); 04521 } 04522 else 04523 { 04524 /* return address of RDR register */ 04525 data_reg_addr = (uint32_t) &(USARTx->RDR); 04526 } 04527 04528 return data_reg_addr; 04529 } 04530 04531 /** 04532 * @} 04533 */ 04534 04535 /** @defgroup USART_LL_EF_Data_Management Data_Management 04536 * @{ 04537 */ 04538 04539 /** 04540 * @brief Read Receiver Data register (Receive Data value, 8 bits) 04541 * @rmtoll RDR RDR LL_USART_ReceiveData8 04542 * @param USARTx USART Instance 04543 * @retval Value between Min_Data=0x00 and Max_Data=0xFF 04544 */ 04545 __STATIC_INLINE uint8_t LL_USART_ReceiveData8(USART_TypeDef *USARTx) 04546 { 04547 return (uint8_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR) & 0xFFU); 04548 } 04549 04550 /** 04551 * @brief Read Receiver Data register (Receive Data value, 9 bits) 04552 * @rmtoll RDR RDR LL_USART_ReceiveData9 04553 * @param USARTx USART Instance 04554 * @retval Value between Min_Data=0x00 and Max_Data=0x1FF 04555 */ 04556 __STATIC_INLINE uint16_t LL_USART_ReceiveData9(USART_TypeDef *USARTx) 04557 { 04558 return (uint16_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR)); 04559 } 04560 04561 /** 04562 * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits) 04563 * @rmtoll TDR TDR LL_USART_TransmitData8 04564 * @param USARTx USART Instance 04565 * @param Value between Min_Data=0x00 and Max_Data=0xFF 04566 * @retval None 04567 */ 04568 __STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value) 04569 { 04570 USARTx->TDR = Value; 04571 } 04572 04573 /** 04574 * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits) 04575 * @rmtoll TDR TDR LL_USART_TransmitData9 04576 * @param USARTx USART Instance 04577 * @param Value between Min_Data=0x00 and Max_Data=0x1FF 04578 * @retval None 04579 */ 04580 __STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value) 04581 { 04582 USARTx->TDR = (uint16_t)(Value & 0x1FFUL); 04583 } 04584 04585 /** 04586 * @} 04587 */ 04588 04589 /** @defgroup USART_LL_EF_Execution Execution 04590 * @{ 04591 */ 04592 04593 /** 04594 * @brief Request an Automatic Baud Rate measurement on next received data frame 04595 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 04596 * Auto Baud Rate detection feature is supported by the USARTx instance. 04597 * @rmtoll RQR ABRRQ LL_USART_RequestAutoBaudRate 04598 * @param USARTx USART Instance 04599 * @retval None 04600 */ 04601 __STATIC_INLINE void LL_USART_RequestAutoBaudRate(USART_TypeDef *USARTx) 04602 { 04603 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_ABRRQ); 04604 } 04605 04606 /** 04607 * @brief Request Break sending 04608 * @rmtoll RQR SBKRQ LL_USART_RequestBreakSending 04609 * @param USARTx USART Instance 04610 * @retval None 04611 */ 04612 __STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx) 04613 { 04614 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_SBKRQ); 04615 } 04616 04617 /** 04618 * @brief Put USART in mute mode and set the RWU flag 04619 * @rmtoll RQR MMRQ LL_USART_RequestEnterMuteMode 04620 * @param USARTx USART Instance 04621 * @retval None 04622 */ 04623 __STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx) 04624 { 04625 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_MMRQ); 04626 } 04627 04628 /** 04629 @if USART_CR1_FIFOEN 04630 * @brief Request a Receive Data and FIFO flush 04631 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 04632 * FIFO mode feature is supported by the USARTx instance. 04633 * @note Allows to discard the received data without reading them, and avoid an overrun 04634 * condition. 04635 @else 04636 * @brief Request a Receive Data flush 04637 @endif 04638 * @rmtoll RQR RXFRQ LL_USART_RequestRxDataFlush 04639 * @param USARTx USART Instance 04640 * @retval None 04641 */ 04642 __STATIC_INLINE void LL_USART_RequestRxDataFlush(USART_TypeDef *USARTx) 04643 { 04644 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_RXFRQ); 04645 } 04646 04647 /** 04648 @if USART_CR1_FIFOEN 04649 * @brief Request a Transmit data and FIFO flush 04650 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 04651 * FIFO mode feature is supported by the USARTx instance. 04652 @else 04653 * @brief Request a Transmit data flush 04654 @endif 04655 * @rmtoll RQR TXFRQ LL_USART_RequestTxDataFlush 04656 * @param USARTx USART Instance 04657 * @retval None 04658 */ 04659 __STATIC_INLINE void LL_USART_RequestTxDataFlush(USART_TypeDef *USARTx) 04660 { 04661 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_TXFRQ); 04662 } 04663 04664 /** 04665 * @} 04666 */ 04667 04668 #if defined(USE_FULL_LL_DRIVER) 04669 /** @defgroup USART_LL_EF_Init Initialization and de-initialization functions 04670 * @{ 04671 */ 04672 ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx); 04673 ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct); 04674 void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct); 04675 ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct); 04676 void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct); 04677 /** 04678 * @} 04679 */ 04680 #endif /* USE_FULL_LL_DRIVER */ 04681 04682 /** 04683 * @} 04684 */ 04685 04686 /** 04687 * @} 04688 */ 04689 04690 #endif /* USART1 || USART2 || USART3 || UART4 || UART5 */ 04691 04692 /** 04693 * @} 04694 */ 04695 04696 #ifdef __cplusplus 04697 } 04698 #endif 04699 04700 #endif /* STM32L4xx_LL_USART_H */ 04701