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