STM32F103xB HAL User Manual
stm32f1xx_ll_usart.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f1xx_ll_usart.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of USART LL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
00010   * All rights reserved.</center></h2>
00011   *
00012   * This software component is licensed by ST under BSD 3-Clause license,
00013   * the "License"; You may not use this file except in compliance with the
00014   * License. You may obtain a copy of the License at:
00015   *                        opensource.org/licenses/BSD-3-Clause
00016   *
00017   ******************************************************************************
00018   */
00019 
00020 /* Define to prevent recursive inclusion -------------------------------------*/
00021 #ifndef __STM32F1xx_LL_USART_H
00022 #define __STM32F1xx_LL_USART_H
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm32f1xx.h"
00030 
00031 /** @addtogroup STM32F1xx_LL_Driver
00032   * @{
00033   */
00034 
00035 #if defined (USART1) || defined (USART2) || defined (USART3) || defined (UART4) || defined (UART5)
00036 
00037 /** @defgroup USART_LL USART
00038   * @{
00039   */
00040 
00041 /* Private types -------------------------------------------------------------*/
00042 /* Private variables ---------------------------------------------------------*/
00043 
00044 /* Private constants ---------------------------------------------------------*/
00045 /** @defgroup USART_LL_Private_Constants USART Private Constants
00046   * @{
00047   */
00048 
00049 /* Defines used for the bit position in the register and perform offsets*/
00050 #define USART_POSITION_GTPR_GT                  USART_GTPR_GT_Pos
00051 /**
00052   * @}
00053   */
00054 
00055 /* Private macros ------------------------------------------------------------*/
00056 #if defined(USE_FULL_LL_DRIVER)
00057 /** @defgroup USART_LL_Private_Macros USART Private Macros
00058   * @{
00059   */
00060 /**
00061   * @}
00062   */
00063 #endif /*USE_FULL_LL_DRIVER*/
00064 
00065 /* Exported types ------------------------------------------------------------*/
00066 #if defined(USE_FULL_LL_DRIVER)
00067 /** @defgroup USART_LL_ES_INIT USART Exported Init structures
00068   * @{
00069   */
00070 
00071 /**
00072   * @brief LL USART Init Structure definition
00073   */
00074 typedef struct
00075 {
00076   uint32_t BaudRate;                  /*!< This field defines expected Usart communication baud rate.
00077 
00078                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetBaudRate().*/
00079 
00080   uint32_t DataWidth;                 /*!< Specifies the number of data bits transmitted or received in a frame.
00081                                            This parameter can be a value of @ref USART_LL_EC_DATAWIDTH.
00082 
00083                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetDataWidth().*/
00084 
00085   uint32_t StopBits;                  /*!< Specifies the number of stop bits transmitted.
00086                                            This parameter can be a value of @ref USART_LL_EC_STOPBITS.
00087 
00088                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetStopBitsLength().*/
00089 
00090   uint32_t Parity;                    /*!< Specifies the parity mode.
00091                                            This parameter can be a value of @ref USART_LL_EC_PARITY.
00092 
00093                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetParity().*/
00094 
00095   uint32_t TransferDirection;         /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled.
00096                                            This parameter can be a value of @ref USART_LL_EC_DIRECTION.
00097 
00098                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetTransferDirection().*/
00099 
00100   uint32_t HardwareFlowControl;       /*!< Specifies whether the hardware flow control mode is enabled or disabled.
00101                                            This parameter can be a value of @ref USART_LL_EC_HWCONTROL.
00102 
00103                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetHWFlowCtrl().*/
00104 
00105   uint32_t OverSampling;              /*!< Specifies whether USART oversampling mode is 16 or 8.
00106                                            This parameter can be a value of @ref USART_LL_EC_OVERSAMPLING.
00107 
00108                                            This feature can be modified afterwards using unitary function @ref LL_USART_SetOverSampling().*/
00109 
00110 } LL_USART_InitTypeDef;
00111 
00112 /**
00113   * @brief LL USART Clock Init Structure definition
00114   */
00115 typedef struct
00116 {
00117   uint32_t ClockOutput;               /*!< Specifies whether the USART clock is enabled or disabled.
00118                                            This parameter can be a value of @ref USART_LL_EC_CLOCK.
00119 
00120                                            USART HW configuration can be modified afterwards using unitary functions
00121                                            @ref LL_USART_EnableSCLKOutput() or @ref LL_USART_DisableSCLKOutput().
00122                                            For more details, refer to description of this function. */
00123 
00124   uint32_t ClockPolarity;             /*!< Specifies the steady state of the serial clock.
00125                                            This parameter can be a value of @ref USART_LL_EC_POLARITY.
00126 
00127                                            USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPolarity().
00128                                            For more details, refer to description of this function. */
00129 
00130   uint32_t ClockPhase;                /*!< Specifies the clock transition on which the bit capture is made.
00131                                            This parameter can be a value of @ref USART_LL_EC_PHASE.
00132 
00133                                            USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPhase().
00134                                            For more details, refer to description of this function. */
00135 
00136   uint32_t LastBitClockPulse;         /*!< Specifies whether the clock pulse corresponding to the last transmitted
00137                                            data bit (MSB) has to be output on the SCLK pin in synchronous mode.
00138                                            This parameter can be a value of @ref USART_LL_EC_LASTCLKPULSE.
00139 
00140                                            USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetLastClkPulseOutput().
00141                                            For more details, refer to description of this function. */
00142 
00143 } LL_USART_ClockInitTypeDef;
00144 
00145 /**
00146   * @}
00147   */
00148 #endif /* USE_FULL_LL_DRIVER */
00149 
00150 /* Exported constants --------------------------------------------------------*/
00151 /** @defgroup USART_LL_Exported_Constants USART Exported Constants
00152   * @{
00153   */
00154 
00155 /** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines
00156   * @brief    Flags defines which can be used with LL_USART_ReadReg function
00157   * @{
00158   */
00159 #define LL_USART_SR_PE                          USART_SR_PE                   /*!< Parity error flag */
00160 #define LL_USART_SR_FE                          USART_SR_FE                   /*!< Framing error flag */
00161 #define LL_USART_SR_NE                          USART_SR_NE                   /*!< Noise detected flag */
00162 #define LL_USART_SR_ORE                         USART_SR_ORE                  /*!< Overrun error flag */
00163 #define LL_USART_SR_IDLE                        USART_SR_IDLE                 /*!< Idle line detected flag */
00164 #define LL_USART_SR_RXNE                        USART_SR_RXNE                 /*!< Read data register not empty flag */
00165 #define LL_USART_SR_TC                          USART_SR_TC                   /*!< Transmission complete flag */
00166 #define LL_USART_SR_TXE                         USART_SR_TXE                  /*!< Transmit data register empty flag */
00167 #define LL_USART_SR_LBD                         USART_SR_LBD                  /*!< LIN break detection flag */
00168 #define LL_USART_SR_CTS                         USART_SR_CTS                  /*!< CTS flag */
00169 /**
00170   * @}
00171   */
00172 
00173 /** @defgroup USART_LL_EC_IT IT Defines
00174   * @brief    IT defines which can be used with LL_USART_ReadReg and  LL_USART_WriteReg functions
00175   * @{
00176   */
00177 #define LL_USART_CR1_IDLEIE                     USART_CR1_IDLEIE              /*!< IDLE interrupt enable */
00178 #define LL_USART_CR1_RXNEIE                     USART_CR1_RXNEIE              /*!< Read data register not empty interrupt enable */
00179 #define LL_USART_CR1_TCIE                       USART_CR1_TCIE                /*!< Transmission complete interrupt enable */
00180 #define LL_USART_CR1_TXEIE                      USART_CR1_TXEIE               /*!< Transmit data register empty interrupt enable */
00181 #define LL_USART_CR1_PEIE                       USART_CR1_PEIE                /*!< Parity error */
00182 #define LL_USART_CR2_LBDIE                      USART_CR2_LBDIE               /*!< LIN break detection interrupt enable */
00183 #define LL_USART_CR3_EIE                        USART_CR3_EIE                 /*!< Error interrupt enable */
00184 #define LL_USART_CR3_CTSIE                      USART_CR3_CTSIE               /*!< CTS interrupt enable */
00185 /**
00186   * @}
00187   */
00188 
00189 /** @defgroup USART_LL_EC_DIRECTION Communication Direction
00190   * @{
00191   */
00192 #define LL_USART_DIRECTION_NONE                 0x00000000U                        /*!< Transmitter and Receiver are disabled */
00193 #define LL_USART_DIRECTION_RX                   USART_CR1_RE                       /*!< Transmitter is disabled and Receiver is enabled */
00194 #define LL_USART_DIRECTION_TX                   USART_CR1_TE                       /*!< Transmitter is enabled and Receiver is disabled */
00195 #define LL_USART_DIRECTION_TX_RX                (USART_CR1_TE |USART_CR1_RE)       /*!< Transmitter and Receiver are enabled */
00196 /**
00197   * @}
00198   */
00199 
00200 /** @defgroup USART_LL_EC_PARITY Parity Control
00201   * @{
00202   */
00203 #define LL_USART_PARITY_NONE                    0x00000000U                          /*!< Parity control disabled */
00204 #define LL_USART_PARITY_EVEN                    USART_CR1_PCE                        /*!< Parity control enabled and Even Parity is selected */
00205 #define LL_USART_PARITY_ODD                     (USART_CR1_PCE | USART_CR1_PS)       /*!< Parity control enabled and Odd Parity is selected */
00206 /**
00207   * @}
00208   */
00209 
00210 /** @defgroup USART_LL_EC_WAKEUP Wakeup
00211   * @{
00212   */
00213 #define LL_USART_WAKEUP_IDLELINE                0x00000000U           /*!<  USART wake up from Mute mode on Idle Line */
00214 #define LL_USART_WAKEUP_ADDRESSMARK             USART_CR1_WAKE        /*!<  USART wake up from Mute mode on Address Mark */
00215 /**
00216   * @}
00217   */
00218 
00219 /** @defgroup USART_LL_EC_DATAWIDTH Datawidth
00220   * @{
00221   */
00222 #define LL_USART_DATAWIDTH_8B                   0x00000000U             /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
00223 #define LL_USART_DATAWIDTH_9B                   USART_CR1_M             /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
00224 /**
00225   * @}
00226   */
00227 
00228 /** @defgroup USART_LL_EC_OVERSAMPLING Oversampling
00229   * @{
00230   */
00231 #define LL_USART_OVERSAMPLING_16                0x00000000U            /*!< Oversampling by 16 */
00232 #if  defined(USART_CR1_OVER8)
00233 #define LL_USART_OVERSAMPLING_8                 USART_CR1_OVER8        /*!< Oversampling by 8 */
00234 #endif /* USART_OverSampling_Feature */
00235 /**
00236   * @}
00237   */
00238 
00239 #if defined(USE_FULL_LL_DRIVER)
00240 /** @defgroup USART_LL_EC_CLOCK Clock Signal
00241   * @{
00242   */
00243 
00244 #define LL_USART_CLOCK_DISABLE                  0x00000000U            /*!< Clock signal not provided */
00245 #define LL_USART_CLOCK_ENABLE                   USART_CR2_CLKEN        /*!< Clock signal provided */
00246 /**
00247   * @}
00248   */
00249 #endif /*USE_FULL_LL_DRIVER*/
00250 
00251 /** @defgroup USART_LL_EC_LASTCLKPULSE Last Clock Pulse
00252   * @{
00253   */
00254 #define LL_USART_LASTCLKPULSE_NO_OUTPUT         0x00000000U           /*!< The clock pulse of the last data bit is not output to the SCLK pin */
00255 #define LL_USART_LASTCLKPULSE_OUTPUT            USART_CR2_LBCL        /*!< The clock pulse of the last data bit is output to the SCLK pin */
00256 /**
00257   * @}
00258   */
00259 
00260 /** @defgroup USART_LL_EC_PHASE Clock Phase
00261   * @{
00262   */
00263 #define LL_USART_PHASE_1EDGE                    0x00000000U           /*!< The first clock transition is the first data capture edge */
00264 #define LL_USART_PHASE_2EDGE                    USART_CR2_CPHA        /*!< The second clock transition is the first data capture edge */
00265 /**
00266   * @}
00267   */
00268 
00269 /** @defgroup USART_LL_EC_POLARITY Clock Polarity
00270   * @{
00271   */
00272 #define LL_USART_POLARITY_LOW                   0x00000000U           /*!< Steady low value on SCLK pin outside transmission window*/
00273 #define LL_USART_POLARITY_HIGH                  USART_CR2_CPOL        /*!< Steady high value on SCLK pin outside transmission window */
00274 /**
00275   * @}
00276   */
00277 
00278 /** @defgroup USART_LL_EC_STOPBITS Stop Bits
00279   * @{
00280   */
00281 #define LL_USART_STOPBITS_0_5                   USART_CR2_STOP_0                           /*!< 0.5 stop bit */
00282 #define LL_USART_STOPBITS_1                     0x00000000U                                /*!< 1 stop bit */
00283 #define LL_USART_STOPBITS_1_5                   (USART_CR2_STOP_0 | USART_CR2_STOP_1)      /*!< 1.5 stop bits */
00284 #define LL_USART_STOPBITS_2                     USART_CR2_STOP_1                           /*!< 2 stop bits */
00285 /**
00286   * @}
00287   */
00288 
00289 /** @defgroup USART_LL_EC_HWCONTROL Hardware Control
00290   * @{
00291   */
00292 #define LL_USART_HWCONTROL_NONE                 0x00000000U                          /*!< CTS and RTS hardware flow control disabled */
00293 #define LL_USART_HWCONTROL_RTS                  USART_CR3_RTSE                       /*!< RTS output enabled, data is only requested when there is space in the receive buffer */
00294 #define LL_USART_HWCONTROL_CTS                  USART_CR3_CTSE                       /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */
00295 #define LL_USART_HWCONTROL_RTS_CTS              (USART_CR3_RTSE | USART_CR3_CTSE)    /*!< CTS and RTS hardware flow control enabled */
00296 /**
00297   * @}
00298   */
00299 
00300 /** @defgroup USART_LL_EC_IRDA_POWER IrDA Power
00301   * @{
00302   */
00303 #define LL_USART_IRDA_POWER_NORMAL              0x00000000U           /*!< IrDA normal power mode */
00304 #define LL_USART_IRDA_POWER_LOW                 USART_CR3_IRLP        /*!< IrDA low power mode */
00305 /**
00306   * @}
00307   */
00308 
00309 /** @defgroup USART_LL_EC_LINBREAK_DETECT LIN Break Detection Length
00310   * @{
00311   */
00312 #define LL_USART_LINBREAK_DETECT_10B            0x00000000U           /*!< 10-bit break detection method selected */
00313 #define LL_USART_LINBREAK_DETECT_11B            USART_CR2_LBDL        /*!< 11-bit break detection method selected */
00314 /**
00315   * @}
00316   */
00317 
00318 /**
00319   * @}
00320   */
00321 
00322 /* Exported macro ------------------------------------------------------------*/
00323 /** @defgroup USART_LL_Exported_Macros USART Exported Macros
00324   * @{
00325   */
00326 
00327 /** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros
00328   * @{
00329   */
00330 
00331 /**
00332   * @brief  Write a value in USART register
00333   * @param  __INSTANCE__ USART Instance
00334   * @param  __REG__ Register to be written
00335   * @param  __VALUE__ Value to be written in the register
00336   * @retval None
00337   */
00338 #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
00339 
00340 /**
00341   * @brief  Read a value in USART register
00342   * @param  __INSTANCE__ USART Instance
00343   * @param  __REG__ Register to be read
00344   * @retval Register value
00345   */
00346 #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
00347 /**
00348   * @}
00349   */
00350 
00351 /** @defgroup USART_LL_EM_Exported_Macros_Helper Exported_Macros_Helper
00352   * @{
00353   */
00354 
00355 /**
00356   * @brief  Compute USARTDIV value according to Peripheral Clock and
00357   *         expected Baud Rate in 8 bits sampling mode (32 bits value of USARTDIV is returned)
00358   * @param  __PERIPHCLK__ Peripheral Clock frequency used for USART instance
00359   * @param  __BAUDRATE__ Baud rate value to achieve
00360   * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case
00361   */
00362 #define __LL_USART_DIV_SAMPLING8_100(__PERIPHCLK__, __BAUDRATE__)      (((__PERIPHCLK__)*25)/(2*(__BAUDRATE__)))
00363 #define __LL_USART_DIVMANT_SAMPLING8(__PERIPHCLK__, __BAUDRATE__)      (__LL_USART_DIV_SAMPLING8_100((__PERIPHCLK__), (__BAUDRATE__))/100)
00364 #define __LL_USART_DIVFRAQ_SAMPLING8(__PERIPHCLK__, __BAUDRATE__)      (((__LL_USART_DIV_SAMPLING8_100((__PERIPHCLK__), (__BAUDRATE__)) - (__LL_USART_DIVMANT_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) * 100)) * 8 + 50) / 100)
00365 /* UART BRR = mantissa + overflow + fraction
00366             = (UART DIVMANT << 4) + ((UART DIVFRAQ & 0xF8) << 1) + (UART DIVFRAQ & 0x07) */
00367 #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __BAUDRATE__)             (((__LL_USART_DIVMANT_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) << 4) + \
00368                                                                            ((__LL_USART_DIVFRAQ_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) & 0xF8) << 1)) + \
00369                                                                            (__LL_USART_DIVFRAQ_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) & 0x07))
00370 
00371 /**
00372   * @brief  Compute USARTDIV value according to Peripheral Clock and
00373   *         expected Baud Rate in 16 bits sampling mode (32 bits value of USARTDIV is returned)
00374   * @param  __PERIPHCLK__ Peripheral Clock frequency used for USART instance
00375   * @param  __BAUDRATE__ Baud rate value to achieve
00376   * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case
00377   */
00378 #define __LL_USART_DIV_SAMPLING16_100(__PERIPHCLK__, __BAUDRATE__)     (((__PERIPHCLK__)*25)/(4*(__BAUDRATE__)))
00379 #define __LL_USART_DIVMANT_SAMPLING16(__PERIPHCLK__, __BAUDRATE__)     (__LL_USART_DIV_SAMPLING16_100((__PERIPHCLK__), (__BAUDRATE__))/100)
00380 #define __LL_USART_DIVFRAQ_SAMPLING16(__PERIPHCLK__, __BAUDRATE__)     ((((__LL_USART_DIV_SAMPLING16_100((__PERIPHCLK__), (__BAUDRATE__)) - (__LL_USART_DIVMANT_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) * 100)) * 16) + 50) / 100)
00381 /* USART BRR = mantissa + overflow + fraction
00382             = (USART DIVMANT << 4) + (USART DIVFRAQ & 0xF0) + (USART DIVFRAQ & 0x0F) */
00383 #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __BAUDRATE__)            (((__LL_USART_DIVMANT_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) << 4) + \
00384                                                                            (__LL_USART_DIVFRAQ_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) & 0xF0)) + \
00385                                                                            (__LL_USART_DIVFRAQ_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) & 0x0F))
00386 
00387 /**
00388   * @}
00389   */
00390 
00391 /**
00392   * @}
00393   */
00394 
00395 /* Exported functions --------------------------------------------------------*/
00396 
00397 /** @defgroup USART_LL_Exported_Functions USART Exported Functions
00398   * @{
00399   */
00400 
00401 /** @defgroup USART_LL_EF_Configuration Configuration functions
00402   * @{
00403   */
00404 
00405 /**
00406   * @brief  USART Enable
00407   * @rmtoll CR1          UE            LL_USART_Enable
00408   * @param  USARTx USART Instance
00409   * @retval None
00410   */
00411 __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx)
00412 {
00413   SET_BIT(USARTx->CR1, USART_CR1_UE);
00414 }
00415 
00416 /**
00417   * @brief  USART Disable (all USART prescalers and outputs are disabled)
00418   * @note   When USART is disabled, USART prescalers and outputs are stopped immediately,
00419   *         and current operations are discarded. The configuration of the USART is kept, but all the status
00420   *         flags, in the USARTx_SR are set to their default values.
00421   * @rmtoll CR1          UE            LL_USART_Disable
00422   * @param  USARTx USART Instance
00423   * @retval None
00424   */
00425 __STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx)
00426 {
00427   CLEAR_BIT(USARTx->CR1, USART_CR1_UE);
00428 }
00429 
00430 /**
00431   * @brief  Indicate if USART is enabled
00432   * @rmtoll CR1          UE            LL_USART_IsEnabled
00433   * @param  USARTx USART Instance
00434   * @retval State of bit (1 or 0).
00435   */
00436 __STATIC_INLINE uint32_t LL_USART_IsEnabled(USART_TypeDef *USARTx)
00437 {
00438   return (READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE));
00439 }
00440 
00441 /**
00442   * @brief  Receiver Enable (Receiver is enabled and begins searching for a start bit)
00443   * @rmtoll CR1          RE            LL_USART_EnableDirectionRx
00444   * @param  USARTx USART Instance
00445   * @retval None
00446   */
00447 __STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx)
00448 {
00449   SET_BIT(USARTx->CR1, USART_CR1_RE);
00450 }
00451 
00452 /**
00453   * @brief  Receiver Disable
00454   * @rmtoll CR1          RE            LL_USART_DisableDirectionRx
00455   * @param  USARTx USART Instance
00456   * @retval None
00457   */
00458 __STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx)
00459 {
00460   CLEAR_BIT(USARTx->CR1, USART_CR1_RE);
00461 }
00462 
00463 /**
00464   * @brief  Transmitter Enable
00465   * @rmtoll CR1          TE            LL_USART_EnableDirectionTx
00466   * @param  USARTx USART Instance
00467   * @retval None
00468   */
00469 __STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx)
00470 {
00471   SET_BIT(USARTx->CR1, USART_CR1_TE);
00472 }
00473 
00474 /**
00475   * @brief  Transmitter Disable
00476   * @rmtoll CR1          TE            LL_USART_DisableDirectionTx
00477   * @param  USARTx USART Instance
00478   * @retval None
00479   */
00480 __STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx)
00481 {
00482   CLEAR_BIT(USARTx->CR1, USART_CR1_TE);
00483 }
00484 
00485 /**
00486   * @brief  Configure simultaneously enabled/disabled states
00487   *         of Transmitter and Receiver
00488   * @rmtoll CR1          RE            LL_USART_SetTransferDirection\n
00489   *         CR1          TE            LL_USART_SetTransferDirection
00490   * @param  USARTx USART Instance
00491   * @param  TransferDirection This parameter can be one of the following values:
00492   *         @arg @ref LL_USART_DIRECTION_NONE
00493   *         @arg @ref LL_USART_DIRECTION_RX
00494   *         @arg @ref LL_USART_DIRECTION_TX
00495   *         @arg @ref LL_USART_DIRECTION_TX_RX
00496   * @retval None
00497   */
00498 __STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t TransferDirection)
00499 {
00500   MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection);
00501 }
00502 
00503 /**
00504   * @brief  Return enabled/disabled states of Transmitter and Receiver
00505   * @rmtoll CR1          RE            LL_USART_GetTransferDirection\n
00506   *         CR1          TE            LL_USART_GetTransferDirection
00507   * @param  USARTx USART Instance
00508   * @retval Returned value can be one of the following values:
00509   *         @arg @ref LL_USART_DIRECTION_NONE
00510   *         @arg @ref LL_USART_DIRECTION_RX
00511   *         @arg @ref LL_USART_DIRECTION_TX
00512   *         @arg @ref LL_USART_DIRECTION_TX_RX
00513   */
00514 __STATIC_INLINE uint32_t LL_USART_GetTransferDirection(USART_TypeDef *USARTx)
00515 {
00516   return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE));
00517 }
00518 
00519 /**
00520   * @brief  Configure Parity (enabled/disabled and parity mode if enabled).
00521   * @note   This function selects if hardware parity control (generation and detection) is enabled or disabled.
00522   *         When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position
00523   *         (9th or 8th bit depending on data width) and parity is checked on the received data.
00524   * @rmtoll CR1          PS            LL_USART_SetParity\n
00525   *         CR1          PCE           LL_USART_SetParity
00526   * @param  USARTx USART Instance
00527   * @param  Parity This parameter can be one of the following values:
00528   *         @arg @ref LL_USART_PARITY_NONE
00529   *         @arg @ref LL_USART_PARITY_EVEN
00530   *         @arg @ref LL_USART_PARITY_ODD
00531   * @retval None
00532   */
00533 __STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t Parity)
00534 {
00535   MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity);
00536 }
00537 
00538 /**
00539   * @brief  Return Parity configuration (enabled/disabled and parity mode if enabled)
00540   * @rmtoll CR1          PS            LL_USART_GetParity\n
00541   *         CR1          PCE           LL_USART_GetParity
00542   * @param  USARTx USART Instance
00543   * @retval Returned value can be one of the following values:
00544   *         @arg @ref LL_USART_PARITY_NONE
00545   *         @arg @ref LL_USART_PARITY_EVEN
00546   *         @arg @ref LL_USART_PARITY_ODD
00547   */
00548 __STATIC_INLINE uint32_t LL_USART_GetParity(USART_TypeDef *USARTx)
00549 {
00550   return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE));
00551 }
00552 
00553 /**
00554   * @brief  Set Receiver Wake Up method from Mute mode.
00555   * @rmtoll CR1          WAKE          LL_USART_SetWakeUpMethod
00556   * @param  USARTx USART Instance
00557   * @param  Method This parameter can be one of the following values:
00558   *         @arg @ref LL_USART_WAKEUP_IDLELINE
00559   *         @arg @ref LL_USART_WAKEUP_ADDRESSMARK
00560   * @retval None
00561   */
00562 __STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method)
00563 {
00564   MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method);
00565 }
00566 
00567 /**
00568   * @brief  Return Receiver Wake Up method from Mute mode
00569   * @rmtoll CR1          WAKE          LL_USART_GetWakeUpMethod
00570   * @param  USARTx USART Instance
00571   * @retval Returned value can be one of the following values:
00572   *         @arg @ref LL_USART_WAKEUP_IDLELINE
00573   *         @arg @ref LL_USART_WAKEUP_ADDRESSMARK
00574   */
00575 __STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(USART_TypeDef *USARTx)
00576 {
00577   return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE));
00578 }
00579 
00580 /**
00581   * @brief  Set Word length (i.e. nb of data bits, excluding start and stop bits)
00582   * @rmtoll CR1          M             LL_USART_SetDataWidth
00583   * @param  USARTx USART Instance
00584   * @param  DataWidth This parameter can be one of the following values:
00585   *         @arg @ref LL_USART_DATAWIDTH_8B
00586   *         @arg @ref LL_USART_DATAWIDTH_9B
00587   * @retval None
00588   */
00589 __STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth)
00590 {
00591   MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth);
00592 }
00593 
00594 /**
00595   * @brief  Return Word length (i.e. nb of data bits, excluding start and stop bits)
00596   * @rmtoll CR1          M             LL_USART_GetDataWidth
00597   * @param  USARTx USART Instance
00598   * @retval Returned value can be one of the following values:
00599   *         @arg @ref LL_USART_DATAWIDTH_8B
00600   *         @arg @ref LL_USART_DATAWIDTH_9B
00601   */
00602 __STATIC_INLINE uint32_t LL_USART_GetDataWidth(USART_TypeDef *USARTx)
00603 {
00604   return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M));
00605 }
00606 
00607 #if defined(USART_CR1_OVER8)
00608 /**
00609   * @brief  Set Oversampling to 8-bit or 16-bit mode
00610   * @rmtoll CR1          OVER8         LL_USART_SetOverSampling
00611   * @param  USARTx USART Instance
00612   * @param  OverSampling This parameter can be one of the following values:
00613   *         @arg @ref LL_USART_OVERSAMPLING_16
00614   *         @arg @ref LL_USART_OVERSAMPLING_8
00615   * @retval None
00616   */
00617 __STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling)
00618 {
00619   MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling);
00620 }
00621 
00622 /**
00623   * @brief  Return Oversampling mode
00624   * @rmtoll CR1          OVER8         LL_USART_GetOverSampling
00625   * @param  USARTx USART Instance
00626   * @retval Returned value can be one of the following values:
00627   *         @arg @ref LL_USART_OVERSAMPLING_16
00628   *         @arg @ref LL_USART_OVERSAMPLING_8
00629   */
00630 __STATIC_INLINE uint32_t LL_USART_GetOverSampling(USART_TypeDef *USARTx)
00631 {
00632   return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8));
00633 }
00634 
00635 #endif /* USART_OverSampling_Feature */
00636 /**
00637   * @brief  Configure if Clock pulse of the last data bit is output to the SCLK pin or not
00638   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
00639   *         Synchronous mode is supported by the USARTx instance.
00640   * @rmtoll CR2          LBCL          LL_USART_SetLastClkPulseOutput
00641   * @param  USARTx USART Instance
00642   * @param  LastBitClockPulse This parameter can be one of the following values:
00643   *         @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
00644   *         @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
00645   * @retval None
00646   */
00647 __STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LastBitClockPulse)
00648 {
00649   MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LastBitClockPulse);
00650 }
00651 
00652 /**
00653   * @brief  Retrieve Clock pulse of the last data bit output configuration
00654   *         (Last bit Clock pulse output to the SCLK pin or not)
00655   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
00656   *         Synchronous mode is supported by the USARTx instance.
00657   * @rmtoll CR2          LBCL          LL_USART_GetLastClkPulseOutput
00658   * @param  USARTx USART Instance
00659   * @retval Returned value can be one of the following values:
00660   *         @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
00661   *         @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
00662   */
00663 __STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(USART_TypeDef *USARTx)
00664 {
00665   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL));
00666 }
00667 
00668 /**
00669   * @brief  Select the phase of the clock output on the SCLK pin in synchronous mode
00670   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
00671   *         Synchronous mode is supported by the USARTx instance.
00672   * @rmtoll CR2          CPHA          LL_USART_SetClockPhase
00673   * @param  USARTx USART Instance
00674   * @param  ClockPhase This parameter can be one of the following values:
00675   *         @arg @ref LL_USART_PHASE_1EDGE
00676   *         @arg @ref LL_USART_PHASE_2EDGE
00677   * @retval None
00678   */
00679 __STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t ClockPhase)
00680 {
00681   MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, ClockPhase);
00682 }
00683 
00684 /**
00685   * @brief  Return phase of the clock output on the SCLK pin in synchronous mode
00686   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
00687   *         Synchronous mode is supported by the USARTx instance.
00688   * @rmtoll CR2          CPHA          LL_USART_GetClockPhase
00689   * @param  USARTx USART Instance
00690   * @retval Returned value can be one of the following values:
00691   *         @arg @ref LL_USART_PHASE_1EDGE
00692   *         @arg @ref LL_USART_PHASE_2EDGE
00693   */
00694 __STATIC_INLINE uint32_t LL_USART_GetClockPhase(USART_TypeDef *USARTx)
00695 {
00696   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA));
00697 }
00698 
00699 /**
00700   * @brief  Select the polarity of the clock output on the SCLK pin in synchronous mode
00701   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
00702   *         Synchronous mode is supported by the USARTx instance.
00703   * @rmtoll CR2          CPOL          LL_USART_SetClockPolarity
00704   * @param  USARTx USART Instance
00705   * @param  ClockPolarity This parameter can be one of the following values:
00706   *         @arg @ref LL_USART_POLARITY_LOW
00707   *         @arg @ref LL_USART_POLARITY_HIGH
00708   * @retval None
00709   */
00710 __STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t ClockPolarity)
00711 {
00712   MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, ClockPolarity);
00713 }
00714 
00715 /**
00716   * @brief  Return polarity of the clock output on the SCLK pin in synchronous mode
00717   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
00718   *         Synchronous mode is supported by the USARTx instance.
00719   * @rmtoll CR2          CPOL          LL_USART_GetClockPolarity
00720   * @param  USARTx USART Instance
00721   * @retval Returned value can be one of the following values:
00722   *         @arg @ref LL_USART_POLARITY_LOW
00723   *         @arg @ref LL_USART_POLARITY_HIGH
00724   */
00725 __STATIC_INLINE uint32_t LL_USART_GetClockPolarity(USART_TypeDef *USARTx)
00726 {
00727   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL));
00728 }
00729 
00730 /**
00731   * @brief  Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse)
00732   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
00733   *         Synchronous mode is supported by the USARTx instance.
00734   * @note   Call of this function is equivalent to following function call sequence :
00735   *         - Clock Phase configuration using @ref LL_USART_SetClockPhase() function
00736   *         - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function
00737   *         - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function
00738   * @rmtoll CR2          CPHA          LL_USART_ConfigClock\n
00739   *         CR2          CPOL          LL_USART_ConfigClock\n
00740   *         CR2          LBCL          LL_USART_ConfigClock
00741   * @param  USARTx USART Instance
00742   * @param  Phase This parameter can be one of the following values:
00743   *         @arg @ref LL_USART_PHASE_1EDGE
00744   *         @arg @ref LL_USART_PHASE_2EDGE
00745   * @param  Polarity This parameter can be one of the following values:
00746   *         @arg @ref LL_USART_POLARITY_LOW
00747   *         @arg @ref LL_USART_POLARITY_HIGH
00748   * @param  LBCPOutput This parameter can be one of the following values:
00749   *         @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
00750   *         @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
00751   * @retval None
00752   */
00753 __STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput)
00754 {
00755   MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput);
00756 }
00757 
00758 /**
00759   * @brief  Enable Clock output on SCLK pin
00760   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
00761   *         Synchronous mode is supported by the USARTx instance.
00762   * @rmtoll CR2          CLKEN         LL_USART_EnableSCLKOutput
00763   * @param  USARTx USART Instance
00764   * @retval None
00765   */
00766 __STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx)
00767 {
00768   SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
00769 }
00770 
00771 /**
00772   * @brief  Disable Clock output on SCLK pin
00773   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
00774   *         Synchronous mode is supported by the USARTx instance.
00775   * @rmtoll CR2          CLKEN         LL_USART_DisableSCLKOutput
00776   * @param  USARTx USART Instance
00777   * @retval None
00778   */
00779 __STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx)
00780 {
00781   CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN);
00782 }
00783 
00784 /**
00785   * @brief  Indicate if Clock output on SCLK pin is enabled
00786   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
00787   *         Synchronous mode is supported by the USARTx instance.
00788   * @rmtoll CR2          CLKEN         LL_USART_IsEnabledSCLKOutput
00789   * @param  USARTx USART Instance
00790   * @retval State of bit (1 or 0).
00791   */
00792 __STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(USART_TypeDef *USARTx)
00793 {
00794   return (READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN));
00795 }
00796 
00797 /**
00798   * @brief  Set the length of the stop bits
00799   * @rmtoll CR2          STOP          LL_USART_SetStopBitsLength
00800   * @param  USARTx USART Instance
00801   * @param  StopBits This parameter can be one of the following values:
00802   *         @arg @ref LL_USART_STOPBITS_0_5
00803   *         @arg @ref LL_USART_STOPBITS_1
00804   *         @arg @ref LL_USART_STOPBITS_1_5
00805   *         @arg @ref LL_USART_STOPBITS_2
00806   * @retval None
00807   */
00808 __STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits)
00809 {
00810   MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
00811 }
00812 
00813 /**
00814   * @brief  Retrieve the length of the stop bits
00815   * @rmtoll CR2          STOP          LL_USART_GetStopBitsLength
00816   * @param  USARTx USART Instance
00817   * @retval Returned value can be one of the following values:
00818   *         @arg @ref LL_USART_STOPBITS_0_5
00819   *         @arg @ref LL_USART_STOPBITS_1
00820   *         @arg @ref LL_USART_STOPBITS_1_5
00821   *         @arg @ref LL_USART_STOPBITS_2
00822   */
00823 __STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(USART_TypeDef *USARTx)
00824 {
00825   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP));
00826 }
00827 
00828 /**
00829   * @brief  Configure Character frame format (Datawidth, Parity control, Stop Bits)
00830   * @note   Call of this function is equivalent to following function call sequence :
00831   *         - Data Width configuration using @ref LL_USART_SetDataWidth() function
00832   *         - Parity Control and mode configuration using @ref LL_USART_SetParity() function
00833   *         - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function
00834   * @rmtoll CR1          PS            LL_USART_ConfigCharacter\n
00835   *         CR1          PCE           LL_USART_ConfigCharacter\n
00836   *         CR1          M             LL_USART_ConfigCharacter\n
00837   *         CR2          STOP          LL_USART_ConfigCharacter
00838   * @param  USARTx USART Instance
00839   * @param  DataWidth This parameter can be one of the following values:
00840   *         @arg @ref LL_USART_DATAWIDTH_8B
00841   *         @arg @ref LL_USART_DATAWIDTH_9B
00842   * @param  Parity This parameter can be one of the following values:
00843   *         @arg @ref LL_USART_PARITY_NONE
00844   *         @arg @ref LL_USART_PARITY_EVEN
00845   *         @arg @ref LL_USART_PARITY_ODD
00846   * @param  StopBits This parameter can be one of the following values:
00847   *         @arg @ref LL_USART_STOPBITS_0_5
00848   *         @arg @ref LL_USART_STOPBITS_1
00849   *         @arg @ref LL_USART_STOPBITS_1_5
00850   *         @arg @ref LL_USART_STOPBITS_2
00851   * @retval None
00852   */
00853 __STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t Parity,
00854                                               uint32_t StopBits)
00855 {
00856   MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth);
00857   MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
00858 }
00859 
00860 /**
00861   * @brief  Set Address of the USART node.
00862   * @note   This is used in multiprocessor communication during Mute mode or Stop mode,
00863   *         for wake up with address mark detection.
00864   * @rmtoll CR2          ADD           LL_USART_SetNodeAddress
00865   * @param  USARTx USART Instance
00866   * @param  NodeAddress 4 bit Address of the USART node.
00867   * @retval None
00868   */
00869 __STATIC_INLINE void LL_USART_SetNodeAddress(USART_TypeDef *USARTx, uint32_t NodeAddress)
00870 {
00871   MODIFY_REG(USARTx->CR2, USART_CR2_ADD, (NodeAddress & USART_CR2_ADD));
00872 }
00873 
00874 /**
00875   * @brief  Return 4 bit Address of the USART node as set in ADD field of CR2.
00876   * @note   only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant)
00877   * @rmtoll CR2          ADD           LL_USART_GetNodeAddress
00878   * @param  USARTx USART Instance
00879   * @retval Address of the USART node (Value between Min_Data=0 and Max_Data=255)
00880   */
00881 __STATIC_INLINE uint32_t LL_USART_GetNodeAddress(USART_TypeDef *USARTx)
00882 {
00883   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD));
00884 }
00885 
00886 /**
00887   * @brief  Enable RTS HW Flow Control
00888   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
00889   *         Hardware Flow control feature is supported by the USARTx instance.
00890   * @rmtoll CR3          RTSE          LL_USART_EnableRTSHWFlowCtrl
00891   * @param  USARTx USART Instance
00892   * @retval None
00893   */
00894 __STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx)
00895 {
00896   SET_BIT(USARTx->CR3, USART_CR3_RTSE);
00897 }
00898 
00899 /**
00900   * @brief  Disable RTS HW Flow Control
00901   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
00902   *         Hardware Flow control feature is supported by the USARTx instance.
00903   * @rmtoll CR3          RTSE          LL_USART_DisableRTSHWFlowCtrl
00904   * @param  USARTx USART Instance
00905   * @retval None
00906   */
00907 __STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx)
00908 {
00909   CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE);
00910 }
00911 
00912 /**
00913   * @brief  Enable CTS HW Flow Control
00914   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
00915   *         Hardware Flow control feature is supported by the USARTx instance.
00916   * @rmtoll CR3          CTSE          LL_USART_EnableCTSHWFlowCtrl
00917   * @param  USARTx USART Instance
00918   * @retval None
00919   */
00920 __STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx)
00921 {
00922   SET_BIT(USARTx->CR3, USART_CR3_CTSE);
00923 }
00924 
00925 /**
00926   * @brief  Disable CTS HW Flow Control
00927   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
00928   *         Hardware Flow control feature is supported by the USARTx instance.
00929   * @rmtoll CR3          CTSE          LL_USART_DisableCTSHWFlowCtrl
00930   * @param  USARTx USART Instance
00931   * @retval None
00932   */
00933 __STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx)
00934 {
00935   CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE);
00936 }
00937 
00938 /**
00939   * @brief  Configure HW Flow Control mode (both CTS and RTS)
00940   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
00941   *         Hardware Flow control feature is supported by the USARTx instance.
00942   * @rmtoll CR3          RTSE          LL_USART_SetHWFlowCtrl\n
00943   *         CR3          CTSE          LL_USART_SetHWFlowCtrl
00944   * @param  USARTx USART Instance
00945   * @param  HardwareFlowControl This parameter can be one of the following values:
00946   *         @arg @ref LL_USART_HWCONTROL_NONE
00947   *         @arg @ref LL_USART_HWCONTROL_RTS
00948   *         @arg @ref LL_USART_HWCONTROL_CTS
00949   *         @arg @ref LL_USART_HWCONTROL_RTS_CTS
00950   * @retval None
00951   */
00952 __STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HardwareFlowControl)
00953 {
00954   MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl);
00955 }
00956 
00957 /**
00958   * @brief  Return HW Flow Control configuration (both CTS and RTS)
00959   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
00960   *         Hardware Flow control feature is supported by the USARTx instance.
00961   * @rmtoll CR3          RTSE          LL_USART_GetHWFlowCtrl\n
00962   *         CR3          CTSE          LL_USART_GetHWFlowCtrl
00963   * @param  USARTx USART Instance
00964   * @retval Returned value can be one of the following values:
00965   *         @arg @ref LL_USART_HWCONTROL_NONE
00966   *         @arg @ref LL_USART_HWCONTROL_RTS
00967   *         @arg @ref LL_USART_HWCONTROL_CTS
00968   *         @arg @ref LL_USART_HWCONTROL_RTS_CTS
00969   */
00970 __STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(USART_TypeDef *USARTx)
00971 {
00972   return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE));
00973 }
00974 
00975 #if defined(USART_CR3_ONEBIT)
00976 /**
00977   * @brief  Enable One bit sampling method
00978   * @rmtoll CR3          ONEBIT        LL_USART_EnableOneBitSamp
00979   * @param  USARTx USART Instance
00980   * @retval None
00981   */
00982 __STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx)
00983 {
00984   SET_BIT(USARTx->CR3, USART_CR3_ONEBIT);
00985 }
00986 
00987 /**
00988   * @brief  Disable One bit sampling method
00989   * @rmtoll CR3          ONEBIT        LL_USART_DisableOneBitSamp
00990   * @param  USARTx USART Instance
00991   * @retval None
00992   */
00993 __STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx)
00994 {
00995   CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT);
00996 }
00997 
00998 /**
00999   * @brief  Indicate if One bit sampling method is enabled
01000   * @rmtoll CR3          ONEBIT        LL_USART_IsEnabledOneBitSamp
01001   * @param  USARTx USART Instance
01002   * @retval State of bit (1 or 0).
01003   */
01004 __STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(USART_TypeDef *USARTx)
01005 {
01006   return (READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT));
01007 }
01008 #endif /* USART_OneBitSampling_Feature */
01009 
01010 #if defined(USART_CR1_OVER8)
01011 /**
01012   * @brief  Configure USART BRR register for achieving expected Baud Rate value.
01013   * @note   Compute and set USARTDIV value in BRR Register (full BRR content)
01014   *         according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values
01015   * @note   Peripheral clock and Baud rate values provided as function parameters should be valid
01016   *         (Baud rate value != 0)
01017   * @rmtoll BRR          BRR           LL_USART_SetBaudRate
01018   * @param  USARTx USART Instance
01019   * @param  PeriphClk Peripheral Clock
01020   * @param  OverSampling This parameter can be one of the following values:
01021   *         @arg @ref LL_USART_OVERSAMPLING_16
01022   *         @arg @ref LL_USART_OVERSAMPLING_8
01023   * @param  BaudRate Baud Rate
01024   * @retval None
01025   */
01026 __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling,
01027                                           uint32_t BaudRate)
01028 {
01029   if (OverSampling == LL_USART_OVERSAMPLING_8)
01030   {
01031     USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, BaudRate));
01032   }
01033   else
01034   {
01035     USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate));
01036   }
01037 }
01038 
01039 /**
01040   * @brief  Return current Baud Rate value, according to USARTDIV present in BRR register
01041   *         (full BRR content), and to used Peripheral Clock and Oversampling mode values
01042   * @note   In case of non-initialized or invalid value stored in BRR register, value 0 will be returned.
01043   * @rmtoll BRR          BRR           LL_USART_GetBaudRate
01044   * @param  USARTx USART Instance
01045   * @param  PeriphClk Peripheral Clock
01046   * @param  OverSampling This parameter can be one of the following values:
01047   *         @arg @ref LL_USART_OVERSAMPLING_16
01048   *         @arg @ref LL_USART_OVERSAMPLING_8
01049   * @retval Baud Rate
01050   */
01051 __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling)
01052 {
01053   uint32_t usartdiv = 0x0U;
01054   uint32_t brrresult = 0x0U;
01055 
01056   usartdiv = USARTx->BRR;
01057 
01058   if (OverSampling == LL_USART_OVERSAMPLING_8)
01059   {
01060     if ((usartdiv & 0xFFF7U) != 0U)
01061     {
01062       usartdiv = (uint16_t)((usartdiv & 0xFFF0U) | ((usartdiv & 0x0007U) << 1U)) ;
01063       brrresult = (PeriphClk * 2U) / usartdiv;
01064     }
01065   }
01066   else
01067   {
01068     if ((usartdiv & 0xFFFFU) != 0U)
01069     {
01070       brrresult = PeriphClk / usartdiv;
01071     }
01072   }
01073   return (brrresult);
01074 }
01075 #else
01076 /**
01077   * @brief  Configure USART BRR register for achieving expected Baud Rate value.
01078   * @note   Compute and set USARTDIV value in BRR Register (full BRR content)
01079   *         according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values
01080   * @note   Peripheral clock and Baud rate values provided as function parameters should be valid
01081   *         (Baud rate value != 0)
01082   * @rmtoll BRR          BRR           LL_USART_SetBaudRate
01083   * @param  USARTx USART Instance
01084   * @param  PeriphClk Peripheral Clock
01085   * @param  BaudRate Baud Rate
01086   * @retval None
01087   */
01088 __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t BaudRate)
01089 {
01090   USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate));
01091 }
01092 
01093 /**
01094   * @brief  Return current Baud Rate value, according to USARTDIV present in BRR register
01095   *         (full BRR content), and to used Peripheral Clock and Oversampling mode values
01096   * @note   In case of non-initialized or invalid value stored in BRR register, value 0 will be returned.
01097   * @rmtoll BRR          BRR           LL_USART_GetBaudRate
01098   * @param  USARTx USART Instance
01099   * @param  PeriphClk Peripheral Clock
01100   * @retval Baud Rate
01101   */
01102 __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk)
01103 {
01104   uint32_t usartdiv = 0x0U;
01105   uint32_t brrresult = 0x0U;
01106 
01107   usartdiv = USARTx->BRR;
01108 
01109   if ((usartdiv & 0xFFFFU) != 0U)
01110   {
01111     brrresult = PeriphClk / usartdiv;
01112   }
01113   return (brrresult);
01114 }
01115 #endif /* USART_OverSampling_Feature */
01116 
01117 /**
01118   * @}
01119   */
01120 
01121 /** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature
01122   * @{
01123   */
01124 
01125 /**
01126   * @brief  Enable IrDA mode
01127   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
01128   *         IrDA feature is supported by the USARTx instance.
01129   * @rmtoll CR3          IREN          LL_USART_EnableIrda
01130   * @param  USARTx USART Instance
01131   * @retval None
01132   */
01133 __STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx)
01134 {
01135   SET_BIT(USARTx->CR3, USART_CR3_IREN);
01136 }
01137 
01138 /**
01139   * @brief  Disable IrDA mode
01140   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
01141   *         IrDA feature is supported by the USARTx instance.
01142   * @rmtoll CR3          IREN          LL_USART_DisableIrda
01143   * @param  USARTx USART Instance
01144   * @retval None
01145   */
01146 __STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx)
01147 {
01148   CLEAR_BIT(USARTx->CR3, USART_CR3_IREN);
01149 }
01150 
01151 /**
01152   * @brief  Indicate if IrDA mode is enabled
01153   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
01154   *         IrDA feature is supported by the USARTx instance.
01155   * @rmtoll CR3          IREN          LL_USART_IsEnabledIrda
01156   * @param  USARTx USART Instance
01157   * @retval State of bit (1 or 0).
01158   */
01159 __STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(USART_TypeDef *USARTx)
01160 {
01161   return (READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN));
01162 }
01163 
01164 /**
01165   * @brief  Configure IrDA Power Mode (Normal or Low Power)
01166   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
01167   *         IrDA feature is supported by the USARTx instance.
01168   * @rmtoll CR3          IRLP          LL_USART_SetIrdaPowerMode
01169   * @param  USARTx USART Instance
01170   * @param  PowerMode This parameter can be one of the following values:
01171   *         @arg @ref LL_USART_IRDA_POWER_NORMAL
01172   *         @arg @ref LL_USART_IRDA_POWER_LOW
01173   * @retval None
01174   */
01175 __STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode)
01176 {
01177   MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode);
01178 }
01179 
01180 /**
01181   * @brief  Retrieve IrDA Power Mode configuration (Normal or Low Power)
01182   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
01183   *         IrDA feature is supported by the USARTx instance.
01184   * @rmtoll CR3          IRLP          LL_USART_GetIrdaPowerMode
01185   * @param  USARTx USART Instance
01186   * @retval Returned value can be one of the following values:
01187   *         @arg @ref LL_USART_IRDA_POWER_NORMAL
01188   *         @arg @ref LL_USART_PHASE_2EDGE
01189   */
01190 __STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(USART_TypeDef *USARTx)
01191 {
01192   return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP));
01193 }
01194 
01195 /**
01196   * @brief  Set Irda prescaler value, used for dividing the USART clock source
01197   *         to achieve the Irda Low Power frequency (8 bits value)
01198   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
01199   *         IrDA feature is supported by the USARTx instance.
01200   * @rmtoll GTPR         PSC           LL_USART_SetIrdaPrescaler
01201   * @param  USARTx USART Instance
01202   * @param  PrescalerValue Value between Min_Data=0x00 and Max_Data=0xFF
01203   * @retval None
01204   */
01205 __STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
01206 {
01207   MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue);
01208 }
01209 
01210 /**
01211   * @brief  Return Irda prescaler value, used for dividing the USART clock source
01212   *         to achieve the Irda Low Power frequency (8 bits value)
01213   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
01214   *         IrDA feature is supported by the USARTx instance.
01215   * @rmtoll GTPR         PSC           LL_USART_GetIrdaPrescaler
01216   * @param  USARTx USART Instance
01217   * @retval Irda prescaler value (Value between Min_Data=0x00 and Max_Data=0xFF)
01218   */
01219 __STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(USART_TypeDef *USARTx)
01220 {
01221   return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
01222 }
01223 
01224 /**
01225   * @}
01226   */
01227 
01228 /** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature
01229   * @{
01230   */
01231 
01232 /**
01233   * @brief  Enable Smartcard NACK transmission
01234   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
01235   *         Smartcard feature is supported by the USARTx instance.
01236   * @rmtoll CR3          NACK          LL_USART_EnableSmartcardNACK
01237   * @param  USARTx USART Instance
01238   * @retval None
01239   */
01240 __STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx)
01241 {
01242   SET_BIT(USARTx->CR3, USART_CR3_NACK);
01243 }
01244 
01245 /**
01246   * @brief  Disable Smartcard NACK transmission
01247   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
01248   *         Smartcard feature is supported by the USARTx instance.
01249   * @rmtoll CR3          NACK          LL_USART_DisableSmartcardNACK
01250   * @param  USARTx USART Instance
01251   * @retval None
01252   */
01253 __STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx)
01254 {
01255   CLEAR_BIT(USARTx->CR3, USART_CR3_NACK);
01256 }
01257 
01258 /**
01259   * @brief  Indicate if Smartcard NACK transmission is enabled
01260   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
01261   *         Smartcard feature is supported by the USARTx instance.
01262   * @rmtoll CR3          NACK          LL_USART_IsEnabledSmartcardNACK
01263   * @param  USARTx USART Instance
01264   * @retval State of bit (1 or 0).
01265   */
01266 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(USART_TypeDef *USARTx)
01267 {
01268   return (READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK));
01269 }
01270 
01271 /**
01272   * @brief  Enable Smartcard mode
01273   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
01274   *         Smartcard feature is supported by the USARTx instance.
01275   * @rmtoll CR3          SCEN          LL_USART_EnableSmartcard
01276   * @param  USARTx USART Instance
01277   * @retval None
01278   */
01279 __STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx)
01280 {
01281   SET_BIT(USARTx->CR3, USART_CR3_SCEN);
01282 }
01283 
01284 /**
01285   * @brief  Disable Smartcard mode
01286   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
01287   *         Smartcard feature is supported by the USARTx instance.
01288   * @rmtoll CR3          SCEN          LL_USART_DisableSmartcard
01289   * @param  USARTx USART Instance
01290   * @retval None
01291   */
01292 __STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx)
01293 {
01294   CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN);
01295 }
01296 
01297 /**
01298   * @brief  Indicate if Smartcard mode is enabled
01299   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
01300   *         Smartcard feature is supported by the USARTx instance.
01301   * @rmtoll CR3          SCEN          LL_USART_IsEnabledSmartcard
01302   * @param  USARTx USART Instance
01303   * @retval State of bit (1 or 0).
01304   */
01305 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(USART_TypeDef *USARTx)
01306 {
01307   return (READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN));
01308 }
01309 
01310 /**
01311   * @brief  Set Smartcard prescaler value, used for dividing the USART clock
01312   *         source to provide the SMARTCARD Clock (5 bits value)
01313   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
01314   *         Smartcard feature is supported by the USARTx instance.
01315   * @rmtoll GTPR         PSC           LL_USART_SetSmartcardPrescaler
01316   * @param  USARTx USART Instance
01317   * @param  PrescalerValue Value between Min_Data=0 and Max_Data=31
01318   * @retval None
01319   */
01320 __STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
01321 {
01322   MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue);
01323 }
01324 
01325 /**
01326   * @brief  Return Smartcard prescaler value, used for dividing the USART clock
01327   *         source to provide the SMARTCARD Clock (5 bits value)
01328   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
01329   *         Smartcard feature is supported by the USARTx instance.
01330   * @rmtoll GTPR         PSC           LL_USART_GetSmartcardPrescaler
01331   * @param  USARTx USART Instance
01332   * @retval Smartcard prescaler value (Value between Min_Data=0 and Max_Data=31)
01333   */
01334 __STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(USART_TypeDef *USARTx)
01335 {
01336   return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
01337 }
01338 
01339 /**
01340   * @brief  Set Smartcard Guard time value, expressed in nb of baud clocks periods
01341   *         (GT[7:0] bits : Guard time value)
01342   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
01343   *         Smartcard feature is supported by the USARTx instance.
01344   * @rmtoll GTPR         GT            LL_USART_SetSmartcardGuardTime
01345   * @param  USARTx USART Instance
01346   * @param  GuardTime Value between Min_Data=0x00 and Max_Data=0xFF
01347   * @retval None
01348   */
01349 __STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime)
01350 {
01351   MODIFY_REG(USARTx->GTPR, USART_GTPR_GT, GuardTime << USART_POSITION_GTPR_GT);
01352 }
01353 
01354 /**
01355   * @brief  Return Smartcard Guard time value, expressed in nb of baud clocks periods
01356   *         (GT[7:0] bits : Guard time value)
01357   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
01358   *         Smartcard feature is supported by the USARTx instance.
01359   * @rmtoll GTPR         GT            LL_USART_GetSmartcardGuardTime
01360   * @param  USARTx USART Instance
01361   * @retval Smartcard Guard time value (Value between Min_Data=0x00 and Max_Data=0xFF)
01362   */
01363 __STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(USART_TypeDef *USARTx)
01364 {
01365   return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_POSITION_GTPR_GT);
01366 }
01367 
01368 /**
01369   * @}
01370   */
01371 
01372 /** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature
01373   * @{
01374   */
01375 
01376 /**
01377   * @brief  Enable Single Wire Half-Duplex mode
01378   * @note   Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
01379   *         Half-Duplex mode is supported by the USARTx instance.
01380   * @rmtoll CR3          HDSEL         LL_USART_EnableHalfDuplex
01381   * @param  USARTx USART Instance
01382   * @retval None
01383   */
01384 __STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx)
01385 {
01386   SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
01387 }
01388 
01389 /**
01390   * @brief  Disable Single Wire Half-Duplex mode
01391   * @note   Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
01392   *         Half-Duplex mode is supported by the USARTx instance.
01393   * @rmtoll CR3          HDSEL         LL_USART_DisableHalfDuplex
01394   * @param  USARTx USART Instance
01395   * @retval None
01396   */
01397 __STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx)
01398 {
01399   CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL);
01400 }
01401 
01402 /**
01403   * @brief  Indicate if Single Wire Half-Duplex mode is enabled
01404   * @note   Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
01405   *         Half-Duplex mode is supported by the USARTx instance.
01406   * @rmtoll CR3          HDSEL         LL_USART_IsEnabledHalfDuplex
01407   * @param  USARTx USART Instance
01408   * @retval State of bit (1 or 0).
01409   */
01410 __STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(USART_TypeDef *USARTx)
01411 {
01412   return (READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL));
01413 }
01414 
01415 /**
01416   * @}
01417   */
01418 
01419 /** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature
01420   * @{
01421   */
01422 
01423 /**
01424   * @brief  Set LIN Break Detection Length
01425   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
01426   *         LIN feature is supported by the USARTx instance.
01427   * @rmtoll CR2          LBDL          LL_USART_SetLINBrkDetectionLen
01428   * @param  USARTx USART Instance
01429   * @param  LINBDLength This parameter can be one of the following values:
01430   *         @arg @ref LL_USART_LINBREAK_DETECT_10B
01431   *         @arg @ref LL_USART_LINBREAK_DETECT_11B
01432   * @retval None
01433   */
01434 __STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength)
01435 {
01436   MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength);
01437 }
01438 
01439 /**
01440   * @brief  Return LIN Break Detection Length
01441   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
01442   *         LIN feature is supported by the USARTx instance.
01443   * @rmtoll CR2          LBDL          LL_USART_GetLINBrkDetectionLen
01444   * @param  USARTx USART Instance
01445   * @retval Returned value can be one of the following values:
01446   *         @arg @ref LL_USART_LINBREAK_DETECT_10B
01447   *         @arg @ref LL_USART_LINBREAK_DETECT_11B
01448   */
01449 __STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(USART_TypeDef *USARTx)
01450 {
01451   return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL));
01452 }
01453 
01454 /**
01455   * @brief  Enable LIN mode
01456   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
01457   *         LIN feature is supported by the USARTx instance.
01458   * @rmtoll CR2          LINEN         LL_USART_EnableLIN
01459   * @param  USARTx USART Instance
01460   * @retval None
01461   */
01462 __STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx)
01463 {
01464   SET_BIT(USARTx->CR2, USART_CR2_LINEN);
01465 }
01466 
01467 /**
01468   * @brief  Disable LIN mode
01469   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
01470   *         LIN feature is supported by the USARTx instance.
01471   * @rmtoll CR2          LINEN         LL_USART_DisableLIN
01472   * @param  USARTx USART Instance
01473   * @retval None
01474   */
01475 __STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx)
01476 {
01477   CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN);
01478 }
01479 
01480 /**
01481   * @brief  Indicate if LIN mode is enabled
01482   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
01483   *         LIN feature is supported by the USARTx instance.
01484   * @rmtoll CR2          LINEN         LL_USART_IsEnabledLIN
01485   * @param  USARTx USART Instance
01486   * @retval State of bit (1 or 0).
01487   */
01488 __STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(USART_TypeDef *USARTx)
01489 {
01490   return (READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN));
01491 }
01492 
01493 /**
01494   * @}
01495   */
01496 
01497 /** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services
01498   * @{
01499   */
01500 
01501 /**
01502   * @brief  Perform basic configuration of USART for enabling use in Asynchronous Mode (UART)
01503   * @note   In UART mode, the following bits must be kept cleared:
01504   *           - LINEN bit in the USART_CR2 register,
01505   *           - CLKEN bit in the USART_CR2 register,
01506   *           - SCEN bit in the USART_CR3 register,
01507   *           - IREN bit in the USART_CR3 register,
01508   *           - HDSEL bit in the USART_CR3 register.
01509   * @note   Call of this function is equivalent to following function call sequence :
01510   *         - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
01511   *         - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
01512   *         - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
01513   *         - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
01514   *         - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
01515   * @note   Other remaining configurations items related to Asynchronous Mode
01516   *         (as Baud Rate, Word length, Parity, ...) should be set using
01517   *         dedicated functions
01518   * @rmtoll CR2          LINEN         LL_USART_ConfigAsyncMode\n
01519   *         CR2          CLKEN         LL_USART_ConfigAsyncMode\n
01520   *         CR3          SCEN          LL_USART_ConfigAsyncMode\n
01521   *         CR3          IREN          LL_USART_ConfigAsyncMode\n
01522   *         CR3          HDSEL         LL_USART_ConfigAsyncMode
01523   * @param  USARTx USART Instance
01524   * @retval None
01525   */
01526 __STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx)
01527 {
01528   /* In Asynchronous mode, the following bits must be kept cleared:
01529   - LINEN, CLKEN bits in the USART_CR2 register,
01530   - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/
01531   CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
01532   CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
01533 }
01534 
01535 /**
01536   * @brief  Perform basic configuration of USART for enabling use in Synchronous Mode
01537   * @note   In Synchronous mode, the following bits must be kept cleared:
01538   *           - LINEN bit in the USART_CR2 register,
01539   *           - SCEN bit in the USART_CR3 register,
01540   *           - IREN bit in the USART_CR3 register,
01541   *           - HDSEL bit in the USART_CR3 register.
01542   *         This function also sets the USART in Synchronous mode.
01543   * @note   Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
01544   *         Synchronous mode is supported by the USARTx instance.
01545   * @note   Call of this function is equivalent to following function call sequence :
01546   *         - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
01547   *         - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
01548   *         - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
01549   *         - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
01550   *         - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
01551   * @note   Other remaining configurations items related to Synchronous Mode
01552   *         (as Baud Rate, Word length, Parity, Clock Polarity, ...) should be set using
01553   *         dedicated functions
01554   * @rmtoll CR2          LINEN         LL_USART_ConfigSyncMode\n
01555   *         CR2          CLKEN         LL_USART_ConfigSyncMode\n
01556   *         CR3          SCEN          LL_USART_ConfigSyncMode\n
01557   *         CR3          IREN          LL_USART_ConfigSyncMode\n
01558   *         CR3          HDSEL         LL_USART_ConfigSyncMode
01559   * @param  USARTx USART Instance
01560   * @retval None
01561   */
01562 __STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx)
01563 {
01564   /* In Synchronous mode, the following bits must be kept cleared:
01565   - LINEN bit in the USART_CR2 register,
01566   - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/
01567   CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
01568   CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
01569   /* set the UART/USART in Synchronous mode */
01570   SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
01571 }
01572 
01573 /**
01574   * @brief  Perform basic configuration of USART for enabling use in LIN Mode
01575   * @note   In LIN mode, the following bits must be kept cleared:
01576   *           - STOP and CLKEN bits in the USART_CR2 register,
01577   *           - SCEN bit in the USART_CR3 register,
01578   *           - IREN bit in the USART_CR3 register,
01579   *           - HDSEL bit in the USART_CR3 register.
01580   *         This function also set the UART/USART in LIN mode.
01581   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
01582   *         LIN feature is supported by the USARTx instance.
01583   * @note   Call of this function is equivalent to following function call sequence :
01584   *         - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
01585   *         - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
01586   *         - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
01587   *         - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
01588   *         - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
01589   *         - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function
01590   * @note   Other remaining configurations items related to LIN Mode
01591   *         (as Baud Rate, Word length, LIN Break Detection Length, ...) should be set using
01592   *         dedicated functions
01593   * @rmtoll CR2          CLKEN         LL_USART_ConfigLINMode\n
01594   *         CR2          STOP          LL_USART_ConfigLINMode\n
01595   *         CR2          LINEN         LL_USART_ConfigLINMode\n
01596   *         CR3          IREN          LL_USART_ConfigLINMode\n
01597   *         CR3          SCEN          LL_USART_ConfigLINMode\n
01598   *         CR3          HDSEL         LL_USART_ConfigLINMode
01599   * @param  USARTx USART Instance
01600   * @retval None
01601   */
01602 __STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx)
01603 {
01604   /* In LIN mode, the following bits must be kept cleared:
01605   - STOP and CLKEN bits in the USART_CR2 register,
01606   - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/
01607   CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP));
01608   CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL));
01609   /* Set the UART/USART in LIN mode */
01610   SET_BIT(USARTx->CR2, USART_CR2_LINEN);
01611 }
01612 
01613 /**
01614   * @brief  Perform basic configuration of USART for enabling use in Half Duplex Mode
01615   * @note   In Half Duplex mode, the following bits must be kept cleared:
01616   *           - LINEN bit in the USART_CR2 register,
01617   *           - CLKEN bit in the USART_CR2 register,
01618   *           - SCEN bit in the USART_CR3 register,
01619   *           - IREN bit in the USART_CR3 register,
01620   *         This function also sets the UART/USART in Half Duplex mode.
01621   * @note   Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
01622   *         Half-Duplex mode is supported by the USARTx instance.
01623   * @note   Call of this function is equivalent to following function call sequence :
01624   *         - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
01625   *         - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
01626   *         - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
01627   *         - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
01628   *         - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function
01629   * @note   Other remaining configurations items related to Half Duplex Mode
01630   *         (as Baud Rate, Word length, Parity, ...) should be set using
01631   *         dedicated functions
01632   * @rmtoll CR2          LINEN         LL_USART_ConfigHalfDuplexMode\n
01633   *         CR2          CLKEN         LL_USART_ConfigHalfDuplexMode\n
01634   *         CR3          HDSEL         LL_USART_ConfigHalfDuplexMode\n
01635   *         CR3          SCEN          LL_USART_ConfigHalfDuplexMode\n
01636   *         CR3          IREN          LL_USART_ConfigHalfDuplexMode
01637   * @param  USARTx USART Instance
01638   * @retval None
01639   */
01640 __STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx)
01641 {
01642   /* In Half Duplex mode, the following bits must be kept cleared:
01643   - LINEN and CLKEN bits in the USART_CR2 register,
01644   - SCEN and IREN bits in the USART_CR3 register.*/
01645   CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
01646   CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN));
01647   /* set the UART/USART in Half Duplex mode */
01648   SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
01649 }
01650 
01651 /**
01652   * @brief  Perform basic configuration of USART for enabling use in Smartcard Mode
01653   * @note   In Smartcard mode, the following bits must be kept cleared:
01654   *           - LINEN bit in the USART_CR2 register,
01655   *           - IREN bit in the USART_CR3 register,
01656   *           - HDSEL bit in the USART_CR3 register.
01657   *         This function also configures Stop bits to 1.5 bits and
01658   *         sets the USART in Smartcard mode (SCEN bit).
01659   *         Clock Output is also enabled (CLKEN).
01660   * @note   Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
01661   *         Smartcard feature is supported by the USARTx instance.
01662   * @note   Call of this function is equivalent to following function call sequence :
01663   *         - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
01664   *         - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
01665   *         - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
01666   *         - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
01667   *         - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
01668   *         - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function
01669   * @note   Other remaining configurations items related to Smartcard Mode
01670   *         (as Baud Rate, Word length, Parity, ...) should be set using
01671   *         dedicated functions
01672   * @rmtoll CR2          LINEN         LL_USART_ConfigSmartcardMode\n
01673   *         CR2          STOP          LL_USART_ConfigSmartcardMode\n
01674   *         CR2          CLKEN         LL_USART_ConfigSmartcardMode\n
01675   *         CR3          HDSEL         LL_USART_ConfigSmartcardMode\n
01676   *         CR3          SCEN          LL_USART_ConfigSmartcardMode
01677   * @param  USARTx USART Instance
01678   * @retval None
01679   */
01680 __STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx)
01681 {
01682   /* In Smartcard mode, the following bits must be kept cleared:
01683   - LINEN bit in the USART_CR2 register,
01684   - IREN and HDSEL bits in the USART_CR3 register.*/
01685   CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
01686   CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL));
01687   /* Configure Stop bits to 1.5 bits */
01688   /* Synchronous mode is activated by default */
01689   SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN));
01690   /* set the UART/USART in Smartcard mode */
01691   SET_BIT(USARTx->CR3, USART_CR3_SCEN);
01692 }
01693 
01694 /**
01695   * @brief  Perform basic configuration of USART for enabling use in Irda Mode
01696   * @note   In IRDA mode, the following bits must be kept cleared:
01697   *           - LINEN bit in the USART_CR2 register,
01698   *           - STOP and CLKEN bits in the USART_CR2 register,
01699   *           - SCEN bit in the USART_CR3 register,
01700   *           - HDSEL bit in the USART_CR3 register.
01701   *         This function also sets the UART/USART in IRDA mode (IREN bit).
01702   * @note   Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
01703   *         IrDA feature is supported by the USARTx instance.
01704   * @note   Call of this function is equivalent to following function call sequence :
01705   *         - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
01706   *         - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
01707   *         - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
01708   *         - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
01709   *         - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
01710   *         - Set IREN in CR3 using @ref LL_USART_EnableIrda() function
01711   * @note   Other remaining configurations items related to Irda Mode
01712   *         (as Baud Rate, Word length, Power mode, ...) should be set using
01713   *         dedicated functions
01714   * @rmtoll CR2          LINEN         LL_USART_ConfigIrdaMode\n
01715   *         CR2          CLKEN         LL_USART_ConfigIrdaMode\n
01716   *         CR2          STOP          LL_USART_ConfigIrdaMode\n
01717   *         CR3          SCEN          LL_USART_ConfigIrdaMode\n
01718   *         CR3          HDSEL         LL_USART_ConfigIrdaMode\n
01719   *         CR3          IREN          LL_USART_ConfigIrdaMode
01720   * @param  USARTx USART Instance
01721   * @retval None
01722   */
01723 __STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx)
01724 {
01725   /* In IRDA mode, the following bits must be kept cleared:
01726   - LINEN, STOP and CLKEN bits in the USART_CR2 register,
01727   - SCEN and HDSEL bits in the USART_CR3 register.*/
01728   CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP));
01729   CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
01730   /* set the UART/USART in IRDA mode */
01731   SET_BIT(USARTx->CR3, USART_CR3_IREN);
01732 }
01733 
01734 /**
01735   * @brief  Perform basic configuration of USART for enabling use in Multi processor Mode
01736   *         (several USARTs connected in a network, one of the USARTs can be the master,
01737   *         its TX output connected to the RX inputs of the other slaves USARTs).
01738   * @note   In MultiProcessor mode, the following bits must be kept cleared:
01739   *           - LINEN bit in the USART_CR2 register,
01740   *           - CLKEN bit in the USART_CR2 register,
01741   *           - SCEN bit in the USART_CR3 register,
01742   *           - IREN bit in the USART_CR3 register,
01743   *           - HDSEL bit in the USART_CR3 register.
01744   * @note   Call of this function is equivalent to following function call sequence :
01745   *         - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
01746   *         - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
01747   *         - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
01748   *         - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
01749   *         - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
01750   * @note   Other remaining configurations items related to Multi processor Mode
01751   *         (as Baud Rate, Wake Up Method, Node address, ...) should be set using
01752   *         dedicated functions
01753   * @rmtoll CR2          LINEN         LL_USART_ConfigMultiProcessMode\n
01754   *         CR2          CLKEN         LL_USART_ConfigMultiProcessMode\n
01755   *         CR3          SCEN          LL_USART_ConfigMultiProcessMode\n
01756   *         CR3          HDSEL         LL_USART_ConfigMultiProcessMode\n
01757   *         CR3          IREN          LL_USART_ConfigMultiProcessMode
01758   * @param  USARTx USART Instance
01759   * @retval None
01760   */
01761 __STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx)
01762 {
01763   /* In Multi Processor mode, the following bits must be kept cleared:
01764   - LINEN and CLKEN bits in the USART_CR2 register,
01765   - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/
01766   CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
01767   CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN));
01768 }
01769 
01770 /**
01771   * @}
01772   */
01773 
01774 /** @defgroup USART_LL_EF_FLAG_Management FLAG_Management
01775   * @{
01776   */
01777 
01778 /**
01779   * @brief  Check if the USART Parity Error Flag is set or not
01780   * @rmtoll SR           PE            LL_USART_IsActiveFlag_PE
01781   * @param  USARTx USART Instance
01782   * @retval State of bit (1 or 0).
01783   */
01784 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(USART_TypeDef *USARTx)
01785 {
01786   return (READ_BIT(USARTx->SR, USART_SR_PE) == (USART_SR_PE));
01787 }
01788 
01789 /**
01790   * @brief  Check if the USART Framing Error Flag is set or not
01791   * @rmtoll SR           FE            LL_USART_IsActiveFlag_FE
01792   * @param  USARTx USART Instance
01793   * @retval State of bit (1 or 0).
01794   */
01795 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(USART_TypeDef *USARTx)
01796 {
01797   return (READ_BIT(USARTx->SR, USART_SR_FE) == (USART_SR_FE));
01798 }
01799 
01800 /**
01801   * @brief  Check if the USART Noise error detected Flag is set or not
01802   * @rmtoll SR           NF            LL_USART_IsActiveFlag_NE
01803   * @param  USARTx USART Instance
01804   * @retval State of bit (1 or 0).
01805   */
01806 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(USART_TypeDef *USARTx)
01807 {
01808   return (READ_BIT(USARTx->SR, USART_SR_NE) == (USART_SR_NE));
01809 }
01810 
01811 /**
01812   * @brief  Check if the USART OverRun Error Flag is set or not
01813   * @rmtoll SR           ORE           LL_USART_IsActiveFlag_ORE
01814   * @param  USARTx USART Instance
01815   * @retval State of bit (1 or 0).
01816   */
01817 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(USART_TypeDef *USARTx)
01818 {
01819   return (READ_BIT(USARTx->SR, USART_SR_ORE) == (USART_SR_ORE));
01820 }
01821 
01822 /**
01823   * @brief  Check if the USART IDLE line detected Flag is set or not
01824   * @rmtoll SR           IDLE          LL_USART_IsActiveFlag_IDLE
01825   * @param  USARTx USART Instance
01826   * @retval State of bit (1 or 0).
01827   */
01828 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(USART_TypeDef *USARTx)
01829 {
01830   return (READ_BIT(USARTx->SR, USART_SR_IDLE) == (USART_SR_IDLE));
01831 }
01832 
01833 /**
01834   * @brief  Check if the USART Read Data Register Not Empty Flag is set or not
01835   * @rmtoll SR           RXNE          LL_USART_IsActiveFlag_RXNE
01836   * @param  USARTx USART Instance
01837   * @retval State of bit (1 or 0).
01838   */
01839 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE(USART_TypeDef *USARTx)
01840 {
01841   return (READ_BIT(USARTx->SR, USART_SR_RXNE) == (USART_SR_RXNE));
01842 }
01843 
01844 /**
01845   * @brief  Check if the USART Transmission Complete Flag is set or not
01846   * @rmtoll SR           TC            LL_USART_IsActiveFlag_TC
01847   * @param  USARTx USART Instance
01848   * @retval State of bit (1 or 0).
01849   */
01850 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(USART_TypeDef *USARTx)
01851 {
01852   return (READ_BIT(USARTx->SR, USART_SR_TC) == (USART_SR_TC));
01853 }
01854 
01855 /**
01856   * @brief  Check if the USART Transmit Data Register Empty Flag is set or not
01857   * @rmtoll SR           TXE           LL_USART_IsActiveFlag_TXE
01858   * @param  USARTx USART Instance
01859   * @retval State of bit (1 or 0).
01860   */
01861 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE(USART_TypeDef *USARTx)
01862 {
01863   return (READ_BIT(USARTx->SR, USART_SR_TXE) == (USART_SR_TXE));
01864 }
01865 
01866 /**
01867   * @brief  Check if the USART LIN Break Detection Flag is set or not
01868   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
01869   *         LIN feature is supported by the USARTx instance.
01870   * @rmtoll SR           LBD           LL_USART_IsActiveFlag_LBD
01871   * @param  USARTx USART Instance
01872   * @retval State of bit (1 or 0).
01873   */
01874 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(USART_TypeDef *USARTx)
01875 {
01876   return (READ_BIT(USARTx->SR, USART_SR_LBD) == (USART_SR_LBD));
01877 }
01878 
01879 /**
01880   * @brief  Check if the USART CTS Flag is set or not
01881   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
01882   *         Hardware Flow control feature is supported by the USARTx instance.
01883   * @rmtoll SR           CTS           LL_USART_IsActiveFlag_nCTS
01884   * @param  USARTx USART Instance
01885   * @retval State of bit (1 or 0).
01886   */
01887 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(USART_TypeDef *USARTx)
01888 {
01889   return (READ_BIT(USARTx->SR, USART_SR_CTS) == (USART_SR_CTS));
01890 }
01891 
01892 /**
01893   * @brief  Check if the USART Send Break Flag is set or not
01894   * @rmtoll CR1          SBK           LL_USART_IsActiveFlag_SBK
01895   * @param  USARTx USART Instance
01896   * @retval State of bit (1 or 0).
01897   */
01898 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(USART_TypeDef *USARTx)
01899 {
01900   return (READ_BIT(USARTx->CR1, USART_CR1_SBK) == (USART_CR1_SBK));
01901 }
01902 
01903 /**
01904   * @brief  Check if the USART Receive Wake Up from mute mode Flag is set or not
01905   * @rmtoll CR1          RWU           LL_USART_IsActiveFlag_RWU
01906   * @param  USARTx USART Instance
01907   * @retval State of bit (1 or 0).
01908   */
01909 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(USART_TypeDef *USARTx)
01910 {
01911   return (READ_BIT(USARTx->CR1, USART_CR1_RWU) == (USART_CR1_RWU));
01912 }
01913 
01914 /**
01915   * @brief  Clear Parity Error Flag
01916   * @note   Clearing this flag is done by a read access to the USARTx_SR
01917   *         register followed by a read access to the USARTx_DR register.
01918   * @note   Please also consider that when clearing this flag, other flags as
01919   *         NE, FE, ORE, IDLE would also be cleared.
01920   * @rmtoll SR           PE            LL_USART_ClearFlag_PE
01921   * @param  USARTx USART Instance
01922   * @retval None
01923   */
01924 __STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx)
01925 {
01926   __IO uint32_t tmpreg;
01927   tmpreg = USARTx->SR;
01928   (void) tmpreg;
01929   tmpreg = USARTx->DR;
01930   (void) tmpreg;
01931 }
01932 
01933 /**
01934   * @brief  Clear Framing Error Flag
01935   * @note   Clearing this flag is done by a read access to the USARTx_SR
01936   *         register followed by a read access to the USARTx_DR register.
01937   * @note   Please also consider that when clearing this flag, other flags as
01938   *         PE, NE, ORE, IDLE would also be cleared.
01939   * @rmtoll SR           FE            LL_USART_ClearFlag_FE
01940   * @param  USARTx USART Instance
01941   * @retval None
01942   */
01943 __STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx)
01944 {
01945   __IO uint32_t tmpreg;
01946   tmpreg = USARTx->SR;
01947   (void) tmpreg;
01948   tmpreg = USARTx->DR;
01949   (void) tmpreg;
01950 }
01951 
01952 /**
01953   * @brief  Clear Noise detected Flag
01954   * @note   Clearing this flag is done by a read access to the USARTx_SR
01955   *         register followed by a read access to the USARTx_DR register.
01956   * @note   Please also consider that when clearing this flag, other flags as
01957   *         PE, FE, ORE, IDLE would also be cleared.
01958   * @rmtoll SR           NF            LL_USART_ClearFlag_NE
01959   * @param  USARTx USART Instance
01960   * @retval None
01961   */
01962 __STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx)
01963 {
01964   __IO uint32_t tmpreg;
01965   tmpreg = USARTx->SR;
01966   (void) tmpreg;
01967   tmpreg = USARTx->DR;
01968   (void) tmpreg;
01969 }
01970 
01971 /**
01972   * @brief  Clear OverRun Error Flag
01973   * @note   Clearing this flag is done by a read access to the USARTx_SR
01974   *         register followed by a read access to the USARTx_DR register.
01975   * @note   Please also consider that when clearing this flag, other flags as
01976   *         PE, NE, FE, IDLE would also be cleared.
01977   * @rmtoll SR           ORE           LL_USART_ClearFlag_ORE
01978   * @param  USARTx USART Instance
01979   * @retval None
01980   */
01981 __STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx)
01982 {
01983   __IO uint32_t tmpreg;
01984   tmpreg = USARTx->SR;
01985   (void) tmpreg;
01986   tmpreg = USARTx->DR;
01987   (void) tmpreg;
01988 }
01989 
01990 /**
01991   * @brief  Clear IDLE line detected Flag
01992   * @note   Clearing this flag is done by a read access to the USARTx_SR
01993   *         register followed by a read access to the USARTx_DR register.
01994   * @note   Please also consider that when clearing this flag, other flags as
01995   *         PE, NE, FE, ORE would also be cleared.
01996   * @rmtoll SR           IDLE          LL_USART_ClearFlag_IDLE
01997   * @param  USARTx USART Instance
01998   * @retval None
01999   */
02000 __STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx)
02001 {
02002   __IO uint32_t tmpreg;
02003   tmpreg = USARTx->SR;
02004   (void) tmpreg;
02005   tmpreg = USARTx->DR;
02006   (void) tmpreg;
02007 }
02008 
02009 /**
02010   * @brief  Clear Transmission Complete Flag
02011   * @rmtoll SR           TC            LL_USART_ClearFlag_TC
02012   * @param  USARTx USART Instance
02013   * @retval None
02014   */
02015 __STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx)
02016 {
02017   WRITE_REG(USARTx->SR, ~(USART_SR_TC));
02018 }
02019 
02020 /**
02021   * @brief  Clear RX Not Empty Flag
02022   * @rmtoll SR           RXNE          LL_USART_ClearFlag_RXNE
02023   * @param  USARTx USART Instance
02024   * @retval None
02025   */
02026 __STATIC_INLINE void LL_USART_ClearFlag_RXNE(USART_TypeDef *USARTx)
02027 {
02028   WRITE_REG(USARTx->SR, ~(USART_SR_RXNE));
02029 }
02030 
02031 /**
02032   * @brief  Clear LIN Break Detection Flag
02033   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
02034   *         LIN feature is supported by the USARTx instance.
02035   * @rmtoll SR           LBD           LL_USART_ClearFlag_LBD
02036   * @param  USARTx USART Instance
02037   * @retval None
02038   */
02039 __STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx)
02040 {
02041   WRITE_REG(USARTx->SR, ~(USART_SR_LBD));
02042 }
02043 
02044 /**
02045   * @brief  Clear CTS Interrupt Flag
02046   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
02047   *         Hardware Flow control feature is supported by the USARTx instance.
02048   * @rmtoll SR           CTS           LL_USART_ClearFlag_nCTS
02049   * @param  USARTx USART Instance
02050   * @retval None
02051   */
02052 __STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx)
02053 {
02054   WRITE_REG(USARTx->SR, ~(USART_SR_CTS));
02055 }
02056 
02057 /**
02058   * @}
02059   */
02060 
02061 /** @defgroup USART_LL_EF_IT_Management IT_Management
02062   * @{
02063   */
02064 
02065 /**
02066   * @brief  Enable IDLE Interrupt
02067   * @rmtoll CR1          IDLEIE        LL_USART_EnableIT_IDLE
02068   * @param  USARTx USART Instance
02069   * @retval None
02070   */
02071 __STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx)
02072 {
02073   SET_BIT(USARTx->CR1, USART_CR1_IDLEIE);
02074 }
02075 
02076 /**
02077   * @brief  Enable RX Not Empty Interrupt
02078   * @rmtoll CR1          RXNEIE        LL_USART_EnableIT_RXNE
02079   * @param  USARTx USART Instance
02080   * @retval None
02081   */
02082 __STATIC_INLINE void LL_USART_EnableIT_RXNE(USART_TypeDef *USARTx)
02083 {
02084   SET_BIT(USARTx->CR1, USART_CR1_RXNEIE);
02085 }
02086 
02087 /**
02088   * @brief  Enable Transmission Complete Interrupt
02089   * @rmtoll CR1          TCIE          LL_USART_EnableIT_TC
02090   * @param  USARTx USART Instance
02091   * @retval None
02092   */
02093 __STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx)
02094 {
02095   SET_BIT(USARTx->CR1, USART_CR1_TCIE);
02096 }
02097 
02098 /**
02099   * @brief  Enable TX Empty Interrupt
02100   * @rmtoll CR1          TXEIE         LL_USART_EnableIT_TXE
02101   * @param  USARTx USART Instance
02102   * @retval None
02103   */
02104 __STATIC_INLINE void LL_USART_EnableIT_TXE(USART_TypeDef *USARTx)
02105 {
02106   SET_BIT(USARTx->CR1, USART_CR1_TXEIE);
02107 }
02108 
02109 /**
02110   * @brief  Enable Parity Error Interrupt
02111   * @rmtoll CR1          PEIE          LL_USART_EnableIT_PE
02112   * @param  USARTx USART Instance
02113   * @retval None
02114   */
02115 __STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx)
02116 {
02117   SET_BIT(USARTx->CR1, USART_CR1_PEIE);
02118 }
02119 
02120 /**
02121   * @brief  Enable LIN Break Detection Interrupt
02122   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
02123   *         LIN feature is supported by the USARTx instance.
02124   * @rmtoll CR2          LBDIE         LL_USART_EnableIT_LBD
02125   * @param  USARTx USART Instance
02126   * @retval None
02127   */
02128 __STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx)
02129 {
02130   SET_BIT(USARTx->CR2, USART_CR2_LBDIE);
02131 }
02132 
02133 /**
02134   * @brief  Enable Error Interrupt
02135   * @note   When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
02136   *         error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_SR register).
02137   *           0: Interrupt is inhibited
02138   *           1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_SR register.
02139   * @rmtoll CR3          EIE           LL_USART_EnableIT_ERROR
02140   * @param  USARTx USART Instance
02141   * @retval None
02142   */
02143 __STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx)
02144 {
02145   SET_BIT(USARTx->CR3, USART_CR3_EIE);
02146 }
02147 
02148 /**
02149   * @brief  Enable CTS Interrupt
02150   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
02151   *         Hardware Flow control feature is supported by the USARTx instance.
02152   * @rmtoll CR3          CTSIE         LL_USART_EnableIT_CTS
02153   * @param  USARTx USART Instance
02154   * @retval None
02155   */
02156 __STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx)
02157 {
02158   SET_BIT(USARTx->CR3, USART_CR3_CTSIE);
02159 }
02160 
02161 /**
02162   * @brief  Disable IDLE Interrupt
02163   * @rmtoll CR1          IDLEIE        LL_USART_DisableIT_IDLE
02164   * @param  USARTx USART Instance
02165   * @retval None
02166   */
02167 __STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx)
02168 {
02169   CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE);
02170 }
02171 
02172 /**
02173   * @brief  Disable RX Not Empty Interrupt
02174   * @rmtoll CR1          RXNEIE        LL_USART_DisableIT_RXNE
02175   * @param  USARTx USART Instance
02176   * @retval None
02177   */
02178 __STATIC_INLINE void LL_USART_DisableIT_RXNE(USART_TypeDef *USARTx)
02179 {
02180   CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE);
02181 }
02182 
02183 /**
02184   * @brief  Disable Transmission Complete Interrupt
02185   * @rmtoll CR1          TCIE          LL_USART_DisableIT_TC
02186   * @param  USARTx USART Instance
02187   * @retval None
02188   */
02189 __STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx)
02190 {
02191   CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE);
02192 }
02193 
02194 /**
02195   * @brief  Disable TX Empty Interrupt
02196   * @rmtoll CR1          TXEIE         LL_USART_DisableIT_TXE
02197   * @param  USARTx USART Instance
02198   * @retval None
02199   */
02200 __STATIC_INLINE void LL_USART_DisableIT_TXE(USART_TypeDef *USARTx)
02201 {
02202   CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE);
02203 }
02204 
02205 /**
02206   * @brief  Disable Parity Error Interrupt
02207   * @rmtoll CR1          PEIE          LL_USART_DisableIT_PE
02208   * @param  USARTx USART Instance
02209   * @retval None
02210   */
02211 __STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx)
02212 {
02213   CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE);
02214 }
02215 
02216 /**
02217   * @brief  Disable LIN Break Detection Interrupt
02218   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
02219   *         LIN feature is supported by the USARTx instance.
02220   * @rmtoll CR2          LBDIE         LL_USART_DisableIT_LBD
02221   * @param  USARTx USART Instance
02222   * @retval None
02223   */
02224 __STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx)
02225 {
02226   CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE);
02227 }
02228 
02229 /**
02230   * @brief  Disable Error Interrupt
02231   * @note   When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
02232   *         error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_SR register).
02233   *           0: Interrupt is inhibited
02234   *           1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_SR register.
02235   * @rmtoll CR3          EIE           LL_USART_DisableIT_ERROR
02236   * @param  USARTx USART Instance
02237   * @retval None
02238   */
02239 __STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx)
02240 {
02241   CLEAR_BIT(USARTx->CR3, USART_CR3_EIE);
02242 }
02243 
02244 /**
02245   * @brief  Disable CTS Interrupt
02246   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
02247   *         Hardware Flow control feature is supported by the USARTx instance.
02248   * @rmtoll CR3          CTSIE         LL_USART_DisableIT_CTS
02249   * @param  USARTx USART Instance
02250   * @retval None
02251   */
02252 __STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx)
02253 {
02254   CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE);
02255 }
02256 
02257 /**
02258   * @brief  Check if the USART IDLE Interrupt  source is enabled or disabled.
02259   * @rmtoll CR1          IDLEIE        LL_USART_IsEnabledIT_IDLE
02260   * @param  USARTx USART Instance
02261   * @retval State of bit (1 or 0).
02262   */
02263 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(USART_TypeDef *USARTx)
02264 {
02265   return (READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE));
02266 }
02267 
02268 /**
02269   * @brief  Check if the USART RX Not Empty Interrupt is enabled or disabled.
02270   * @rmtoll CR1          RXNEIE        LL_USART_IsEnabledIT_RXNE
02271   * @param  USARTx USART Instance
02272   * @retval State of bit (1 or 0).
02273   */
02274 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE(USART_TypeDef *USARTx)
02275 {
02276   return (READ_BIT(USARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE));
02277 }
02278 
02279 /**
02280   * @brief  Check if the USART Transmission Complete Interrupt is enabled or disabled.
02281   * @rmtoll CR1          TCIE          LL_USART_IsEnabledIT_TC
02282   * @param  USARTx USART Instance
02283   * @retval State of bit (1 or 0).
02284   */
02285 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(USART_TypeDef *USARTx)
02286 {
02287   return (READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE));
02288 }
02289 
02290 /**
02291   * @brief  Check if the USART TX Empty Interrupt is enabled or disabled.
02292   * @rmtoll CR1          TXEIE         LL_USART_IsEnabledIT_TXE
02293   * @param  USARTx USART Instance
02294   * @retval State of bit (1 or 0).
02295   */
02296 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE(USART_TypeDef *USARTx)
02297 {
02298   return (READ_BIT(USARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE));
02299 }
02300 
02301 /**
02302   * @brief  Check if the USART Parity Error Interrupt is enabled or disabled.
02303   * @rmtoll CR1          PEIE          LL_USART_IsEnabledIT_PE
02304   * @param  USARTx USART Instance
02305   * @retval State of bit (1 or 0).
02306   */
02307 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(USART_TypeDef *USARTx)
02308 {
02309   return (READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE));
02310 }
02311 
02312 /**
02313   * @brief  Check if the USART LIN Break Detection Interrupt is enabled or disabled.
02314   * @note   Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
02315   *         LIN feature is supported by the USARTx instance.
02316   * @rmtoll CR2          LBDIE         LL_USART_IsEnabledIT_LBD
02317   * @param  USARTx USART Instance
02318   * @retval State of bit (1 or 0).
02319   */
02320 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(USART_TypeDef *USARTx)
02321 {
02322   return (READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE));
02323 }
02324 
02325 /**
02326   * @brief  Check if the USART Error Interrupt is enabled or disabled.
02327   * @rmtoll CR3          EIE           LL_USART_IsEnabledIT_ERROR
02328   * @param  USARTx USART Instance
02329   * @retval State of bit (1 or 0).
02330   */
02331 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(USART_TypeDef *USARTx)
02332 {
02333   return (READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE));
02334 }
02335 
02336 /**
02337   * @brief  Check if the USART CTS Interrupt is enabled or disabled.
02338   * @note   Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
02339   *         Hardware Flow control feature is supported by the USARTx instance.
02340   * @rmtoll CR3          CTSIE         LL_USART_IsEnabledIT_CTS
02341   * @param  USARTx USART Instance
02342   * @retval State of bit (1 or 0).
02343   */
02344 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(USART_TypeDef *USARTx)
02345 {
02346   return (READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE));
02347 }
02348 
02349 /**
02350   * @}
02351   */
02352 
02353 /** @defgroup USART_LL_EF_DMA_Management DMA_Management
02354   * @{
02355   */
02356 
02357 /**
02358   * @brief  Enable DMA Mode for reception
02359   * @rmtoll CR3          DMAR          LL_USART_EnableDMAReq_RX
02360   * @param  USARTx USART Instance
02361   * @retval None
02362   */
02363 __STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx)
02364 {
02365   SET_BIT(USARTx->CR3, USART_CR3_DMAR);
02366 }
02367 
02368 /**
02369   * @brief  Disable DMA Mode for reception
02370   * @rmtoll CR3          DMAR          LL_USART_DisableDMAReq_RX
02371   * @param  USARTx USART Instance
02372   * @retval None
02373   */
02374 __STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx)
02375 {
02376   CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR);
02377 }
02378 
02379 /**
02380   * @brief  Check if DMA Mode is enabled for reception
02381   * @rmtoll CR3          DMAR          LL_USART_IsEnabledDMAReq_RX
02382   * @param  USARTx USART Instance
02383   * @retval State of bit (1 or 0).
02384   */
02385 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(USART_TypeDef *USARTx)
02386 {
02387   return (READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR));
02388 }
02389 
02390 /**
02391   * @brief  Enable DMA Mode for transmission
02392   * @rmtoll CR3          DMAT          LL_USART_EnableDMAReq_TX
02393   * @param  USARTx USART Instance
02394   * @retval None
02395   */
02396 __STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx)
02397 {
02398   SET_BIT(USARTx->CR3, USART_CR3_DMAT);
02399 }
02400 
02401 /**
02402   * @brief  Disable DMA Mode for transmission
02403   * @rmtoll CR3          DMAT          LL_USART_DisableDMAReq_TX
02404   * @param  USARTx USART Instance
02405   * @retval None
02406   */
02407 __STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx)
02408 {
02409   CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT);
02410 }
02411 
02412 /**
02413   * @brief  Check if DMA Mode is enabled for transmission
02414   * @rmtoll CR3          DMAT          LL_USART_IsEnabledDMAReq_TX
02415   * @param  USARTx USART Instance
02416   * @retval State of bit (1 or 0).
02417   */
02418 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(USART_TypeDef *USARTx)
02419 {
02420   return (READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT));
02421 }
02422 
02423 /**
02424   * @brief  Get the data register address used for DMA transfer
02425   * @rmtoll DR           DR            LL_USART_DMA_GetRegAddr
02426   * @note   Address of Data Register is valid for both Transmit and Receive transfers.
02427   * @param  USARTx USART Instance
02428   * @retval Address of data register
02429   */
02430 __STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(USART_TypeDef *USARTx)
02431 {
02432   /* return address of DR register */
02433   return ((uint32_t) & (USARTx->DR));
02434 }
02435 
02436 /**
02437   * @}
02438   */
02439 
02440 /** @defgroup USART_LL_EF_Data_Management Data_Management
02441   * @{
02442   */
02443 
02444 /**
02445   * @brief  Read Receiver Data register (Receive Data value, 8 bits)
02446   * @rmtoll DR           DR            LL_USART_ReceiveData8
02447   * @param  USARTx USART Instance
02448   * @retval Value between Min_Data=0x00 and Max_Data=0xFF
02449   */
02450 __STATIC_INLINE uint8_t LL_USART_ReceiveData8(USART_TypeDef *USARTx)
02451 {
02452   return (uint8_t)(READ_BIT(USARTx->DR, USART_DR_DR));
02453 }
02454 
02455 /**
02456   * @brief  Read Receiver Data register (Receive Data value, 9 bits)
02457   * @rmtoll DR           DR            LL_USART_ReceiveData9
02458   * @param  USARTx USART Instance
02459   * @retval Value between Min_Data=0x00 and Max_Data=0x1FF
02460   */
02461 __STATIC_INLINE uint16_t LL_USART_ReceiveData9(USART_TypeDef *USARTx)
02462 {
02463   return (uint16_t)(READ_BIT(USARTx->DR, USART_DR_DR));
02464 }
02465 
02466 /**
02467   * @brief  Write in Transmitter Data Register (Transmit Data value, 8 bits)
02468   * @rmtoll DR           DR            LL_USART_TransmitData8
02469   * @param  USARTx USART Instance
02470   * @param  Value between Min_Data=0x00 and Max_Data=0xFF
02471   * @retval None
02472   */
02473 __STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value)
02474 {
02475   USARTx->DR = Value;
02476 }
02477 
02478 /**
02479   * @brief  Write in Transmitter Data Register (Transmit Data value, 9 bits)
02480   * @rmtoll DR           DR            LL_USART_TransmitData9
02481   * @param  USARTx USART Instance
02482   * @param  Value between Min_Data=0x00 and Max_Data=0x1FF
02483   * @retval None
02484   */
02485 __STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value)
02486 {
02487   USARTx->DR = Value & 0x1FFU;
02488 }
02489 
02490 /**
02491   * @}
02492   */
02493 
02494 /** @defgroup USART_LL_EF_Execution Execution
02495   * @{
02496   */
02497 
02498 /**
02499   * @brief  Request Break sending
02500   * @rmtoll CR1          SBK           LL_USART_RequestBreakSending
02501   * @param  USARTx USART Instance
02502   * @retval None
02503   */
02504 __STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx)
02505 {
02506   SET_BIT(USARTx->CR1, USART_CR1_SBK);
02507 }
02508 
02509 /**
02510   * @brief  Put USART in Mute mode
02511   * @rmtoll CR1          RWU           LL_USART_RequestEnterMuteMode
02512   * @param  USARTx USART Instance
02513   * @retval None
02514   */
02515 __STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx)
02516 {
02517   SET_BIT(USARTx->CR1, USART_CR1_RWU);
02518 }
02519 
02520 /**
02521   * @brief  Put USART in Active mode
02522   * @rmtoll CR1          RWU           LL_USART_RequestExitMuteMode
02523   * @param  USARTx USART Instance
02524   * @retval None
02525   */
02526 __STATIC_INLINE void LL_USART_RequestExitMuteMode(USART_TypeDef *USARTx)
02527 {
02528   CLEAR_BIT(USARTx->CR1, USART_CR1_RWU);
02529 }
02530 
02531 /**
02532   * @}
02533   */
02534 
02535 #if defined(USE_FULL_LL_DRIVER)
02536 /** @defgroup USART_LL_EF_Init Initialization and de-initialization functions
02537   * @{
02538   */
02539 ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx);
02540 ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct);
02541 void        LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct);
02542 ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
02543 void        LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
02544 /**
02545   * @}
02546   */
02547 #endif /* USE_FULL_LL_DRIVER */
02548 
02549 /**
02550   * @}
02551   */
02552 
02553 /**
02554   * @}
02555   */
02556 
02557 #endif /* USART1 || USART2 || USART3 || UART4 || UART5 */
02558 
02559 /**
02560   * @}
02561   */
02562 
02563 #ifdef __cplusplus
02564 }
02565 #endif
02566 
02567 #endif /* __STM32F1xx_LL_USART_H */
02568 
02569 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/