TUKS MCU Introductory course / TUKS-COURSE-2-LED
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers stm32l4xx_ll_usart.h Source File

stm32l4xx_ll_usart.h

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