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