mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
186:707f6e361f3e
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 158:b23ee177fd68 1 /**
Kojto 158:b23ee177fd68 2 ******************************************************************************
Kojto 158:b23ee177fd68 3 * @file stm32l0xx_ll_usart.h
Kojto 158:b23ee177fd68 4 * @author MCD Application Team
Kojto 158:b23ee177fd68 5 * @brief Header file of USART LL module.
Kojto 158:b23ee177fd68 6 ******************************************************************************
Kojto 158:b23ee177fd68 7 * @attention
Kojto 158:b23ee177fd68 8 *
Kojto 158:b23ee177fd68 9 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 158:b23ee177fd68 10 *
Kojto 158:b23ee177fd68 11 * Redistribution and use in source and binary forms, with or without modification,
Kojto 158:b23ee177fd68 12 * are permitted provided that the following conditions are met:
Kojto 158:b23ee177fd68 13 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 158:b23ee177fd68 14 * this list of conditions and the following disclaimer.
Kojto 158:b23ee177fd68 15 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 158:b23ee177fd68 16 * this list of conditions and the following disclaimer in the documentation
Kojto 158:b23ee177fd68 17 * and/or other materials provided with the distribution.
Kojto 158:b23ee177fd68 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 158:b23ee177fd68 19 * may be used to endorse or promote products derived from this software
Kojto 158:b23ee177fd68 20 * without specific prior written permission.
Kojto 158:b23ee177fd68 21 *
Kojto 158:b23ee177fd68 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 158:b23ee177fd68 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 158:b23ee177fd68 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 158:b23ee177fd68 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 158:b23ee177fd68 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 158:b23ee177fd68 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 158:b23ee177fd68 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 158:b23ee177fd68 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 158:b23ee177fd68 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 158:b23ee177fd68 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 158:b23ee177fd68 32 *
Kojto 158:b23ee177fd68 33 ******************************************************************************
Kojto 158:b23ee177fd68 34 */
Kojto 158:b23ee177fd68 35
Kojto 158:b23ee177fd68 36 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 158:b23ee177fd68 37 #ifndef __STM32L0xx_LL_USART_H
Kojto 158:b23ee177fd68 38 #define __STM32L0xx_LL_USART_H
Kojto 158:b23ee177fd68 39
Kojto 158:b23ee177fd68 40 #ifdef __cplusplus
Kojto 158:b23ee177fd68 41 extern "C" {
Kojto 158:b23ee177fd68 42 #endif
Kojto 158:b23ee177fd68 43
Kojto 158:b23ee177fd68 44 /* Includes ------------------------------------------------------------------*/
Kojto 158:b23ee177fd68 45 #include "stm32l0xx.h"
Kojto 158:b23ee177fd68 46
Kojto 158:b23ee177fd68 47 /** @addtogroup STM32L0xx_LL_Driver
Kojto 158:b23ee177fd68 48 * @{
Kojto 158:b23ee177fd68 49 */
Kojto 158:b23ee177fd68 50
Kojto 158:b23ee177fd68 51 #if defined (USART1) || defined (USART2) || defined (USART4) || defined (USART5)
Kojto 158:b23ee177fd68 52
Kojto 158:b23ee177fd68 53 /** @defgroup USART_LL USART
Kojto 158:b23ee177fd68 54 * @{
Kojto 158:b23ee177fd68 55 */
Kojto 158:b23ee177fd68 56
Kojto 158:b23ee177fd68 57 /* Private types -------------------------------------------------------------*/
Kojto 158:b23ee177fd68 58 /* Private variables ---------------------------------------------------------*/
Kojto 158:b23ee177fd68 59
Kojto 158:b23ee177fd68 60 /* Private constants ---------------------------------------------------------*/
Kojto 158:b23ee177fd68 61 /** @defgroup USART_LL_Private_Constants USART Private Constants
Kojto 158:b23ee177fd68 62 * @{
Kojto 158:b23ee177fd68 63 */
Kojto 158:b23ee177fd68 64
Kojto 158:b23ee177fd68 65 /* Defines used for the bit position in the register and perform offsets*/
Kojto 158:b23ee177fd68 66 #define USART_POSITION_CR1_DEDT (uint32_t)16
Kojto 158:b23ee177fd68 67 #define USART_POSITION_CR1_DEAT (uint32_t)21
Kojto 158:b23ee177fd68 68 #define USART_POSITION_CR2_ADD (uint32_t)24
Kojto 158:b23ee177fd68 69 #define USART_POSITION_CR3_SCARCNT (uint32_t)17
Kojto 158:b23ee177fd68 70 #define USART_POSITION_RTOR_BLEN (uint32_t)24
Kojto 158:b23ee177fd68 71 #define USART_POSITION_GTPR_GT (uint32_t)8
Kojto 158:b23ee177fd68 72 /**
Kojto 158:b23ee177fd68 73 * @}
Kojto 158:b23ee177fd68 74 */
Kojto 158:b23ee177fd68 75
Kojto 158:b23ee177fd68 76 /* Private macros ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 77 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 78 /** @defgroup USART_LL_Private_Macros USART Private Macros
Kojto 158:b23ee177fd68 79 * @{
Kojto 158:b23ee177fd68 80 */
Kojto 158:b23ee177fd68 81 /**
Kojto 158:b23ee177fd68 82 * @}
Kojto 158:b23ee177fd68 83 */
Kojto 158:b23ee177fd68 84 #endif /*USE_FULL_LL_DRIVER*/
Kojto 158:b23ee177fd68 85
Kojto 158:b23ee177fd68 86 /* Exported types ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 87 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 88 /** @defgroup USART_LL_ES_INIT USART Exported Init structures
Kojto 158:b23ee177fd68 89 * @{
Kojto 158:b23ee177fd68 90 */
Kojto 158:b23ee177fd68 91
Kojto 158:b23ee177fd68 92 /**
Kojto 158:b23ee177fd68 93 * @brief LL USART Init Structure definition
Kojto 158:b23ee177fd68 94 */
Kojto 158:b23ee177fd68 95 typedef struct
Kojto 158:b23ee177fd68 96 {
Kojto 158:b23ee177fd68 97 uint32_t BaudRate; /*!< This field defines expected Usart communication baud rate.
Kojto 158:b23ee177fd68 98
Kojto 158:b23ee177fd68 99 This feature can be modified afterwards using unitary function @ref LL_USART_SetBaudRate().*/
Kojto 158:b23ee177fd68 100
Kojto 158:b23ee177fd68 101 uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame.
Kojto 158:b23ee177fd68 102 This parameter can be a value of @ref USART_LL_EC_DATAWIDTH.
Kojto 158:b23ee177fd68 103
Kojto 158:b23ee177fd68 104 This feature can be modified afterwards using unitary function @ref LL_USART_SetDataWidth().*/
Kojto 158:b23ee177fd68 105
Kojto 158:b23ee177fd68 106 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
Kojto 158:b23ee177fd68 107 This parameter can be a value of @ref USART_LL_EC_STOPBITS.
Kojto 158:b23ee177fd68 108
Kojto 158:b23ee177fd68 109 This feature can be modified afterwards using unitary function @ref LL_USART_SetStopBitsLength().*/
Kojto 158:b23ee177fd68 110
Kojto 158:b23ee177fd68 111 uint32_t Parity; /*!< Specifies the parity mode.
Kojto 158:b23ee177fd68 112 This parameter can be a value of @ref USART_LL_EC_PARITY.
Kojto 158:b23ee177fd68 113
Kojto 158:b23ee177fd68 114 This feature can be modified afterwards using unitary function @ref LL_USART_SetParity().*/
Kojto 158:b23ee177fd68 115
Kojto 158:b23ee177fd68 116 uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled.
Kojto 158:b23ee177fd68 117 This parameter can be a value of @ref USART_LL_EC_DIRECTION.
Kojto 158:b23ee177fd68 118
Kojto 158:b23ee177fd68 119 This feature can be modified afterwards using unitary function @ref LL_USART_SetTransferDirection().*/
Kojto 158:b23ee177fd68 120
Kojto 158:b23ee177fd68 121 uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled.
Kojto 158:b23ee177fd68 122 This parameter can be a value of @ref USART_LL_EC_HWCONTROL.
Kojto 158:b23ee177fd68 123
Kojto 158:b23ee177fd68 124 This feature can be modified afterwards using unitary function @ref LL_USART_SetHWFlowCtrl().*/
Kojto 158:b23ee177fd68 125
Kojto 158:b23ee177fd68 126 uint32_t OverSampling; /*!< Specifies whether USART oversampling mode is 16 or 8.
Kojto 158:b23ee177fd68 127 This parameter can be a value of @ref USART_LL_EC_OVERSAMPLING.
Kojto 158:b23ee177fd68 128
Kojto 158:b23ee177fd68 129 This feature can be modified afterwards using unitary function @ref LL_USART_SetOverSampling().*/
Kojto 158:b23ee177fd68 130
Kojto 158:b23ee177fd68 131 } LL_USART_InitTypeDef;
Kojto 158:b23ee177fd68 132
Kojto 158:b23ee177fd68 133 /**
Kojto 158:b23ee177fd68 134 * @brief LL USART Clock Init Structure definition
Kojto 158:b23ee177fd68 135 */
Kojto 158:b23ee177fd68 136 typedef struct
Kojto 158:b23ee177fd68 137 {
Kojto 158:b23ee177fd68 138 uint32_t ClockOutput; /*!< Specifies whether the USART clock is enabled or disabled.
Kojto 158:b23ee177fd68 139 This parameter can be a value of @ref USART_LL_EC_CLOCK.
Kojto 158:b23ee177fd68 140
Kojto 158:b23ee177fd68 141 USART HW configuration can be modified afterwards using unitary functions
Kojto 158:b23ee177fd68 142 @ref LL_USART_EnableSCLKOutput() or @ref LL_USART_DisableSCLKOutput().
Kojto 158:b23ee177fd68 143 For more details, refer to description of this function. */
Kojto 158:b23ee177fd68 144
Kojto 158:b23ee177fd68 145 uint32_t ClockPolarity; /*!< Specifies the steady state of the serial clock.
Kojto 158:b23ee177fd68 146 This parameter can be a value of @ref USART_LL_EC_POLARITY.
Kojto 158:b23ee177fd68 147
Kojto 158:b23ee177fd68 148 USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPolarity().
Kojto 158:b23ee177fd68 149 For more details, refer to description of this function. */
Kojto 158:b23ee177fd68 150
Kojto 158:b23ee177fd68 151 uint32_t ClockPhase; /*!< Specifies the clock transition on which the bit capture is made.
Kojto 158:b23ee177fd68 152 This parameter can be a value of @ref USART_LL_EC_PHASE.
Kojto 158:b23ee177fd68 153
Kojto 158:b23ee177fd68 154 USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPhase().
Kojto 158:b23ee177fd68 155 For more details, refer to description of this function. */
Kojto 158:b23ee177fd68 156
Kojto 158:b23ee177fd68 157 uint32_t LastBitClockPulse; /*!< Specifies whether the clock pulse corresponding to the last transmitted
Kojto 158:b23ee177fd68 158 data bit (MSB) has to be output on the SCLK pin in synchronous mode.
Kojto 158:b23ee177fd68 159 This parameter can be a value of @ref USART_LL_EC_LASTCLKPULSE.
Kojto 158:b23ee177fd68 160
Kojto 158:b23ee177fd68 161 USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetLastClkPulseOutput().
Kojto 158:b23ee177fd68 162 For more details, refer to description of this function. */
Kojto 158:b23ee177fd68 163
Kojto 158:b23ee177fd68 164 } LL_USART_ClockInitTypeDef;
Kojto 158:b23ee177fd68 165
Kojto 158:b23ee177fd68 166 /**
Kojto 158:b23ee177fd68 167 * @}
Kojto 158:b23ee177fd68 168 */
Kojto 158:b23ee177fd68 169 #endif /* USE_FULL_LL_DRIVER */
Kojto 158:b23ee177fd68 170
Kojto 158:b23ee177fd68 171 /* Exported constants --------------------------------------------------------*/
Kojto 158:b23ee177fd68 172 /** @defgroup USART_LL_Exported_Constants USART Exported Constants
Kojto 158:b23ee177fd68 173 * @{
Kojto 158:b23ee177fd68 174 */
Kojto 158:b23ee177fd68 175
Kojto 158:b23ee177fd68 176 /** @defgroup USART_LL_EC_CLEAR_FLAG Clear Flags Defines
Kojto 158:b23ee177fd68 177 * @brief Flags defines which can be used with LL_USART_WriteReg function
Kojto 158:b23ee177fd68 178 * @{
Kojto 158:b23ee177fd68 179 */
Kojto 158:b23ee177fd68 180 #define LL_USART_ICR_PECF USART_ICR_PECF /*!< Parity error flag */
Kojto 158:b23ee177fd68 181 #define LL_USART_ICR_FECF USART_ICR_FECF /*!< Framing error flag */
Kojto 158:b23ee177fd68 182 #define LL_USART_ICR_NCF USART_ICR_NCF /*!< Noise detected flag */
Kojto 158:b23ee177fd68 183 #define LL_USART_ICR_ORECF USART_ICR_ORECF /*!< Overrun error flag */
Kojto 158:b23ee177fd68 184 #define LL_USART_ICR_IDLECF USART_ICR_IDLECF /*!< Idle line detected flag */
Kojto 158:b23ee177fd68 185 #define LL_USART_ICR_TCCF USART_ICR_TCCF /*!< Transmission complete flag */
Kojto 158:b23ee177fd68 186 #if defined(USART_TCBGT_SUPPORT)
Kojto 158:b23ee177fd68 187 #define LL_USART_ICR_TCBGTCF USART_ICR_TCBGTCF /*!< Transmission completed before guard time flag */
Kojto 158:b23ee177fd68 188 #endif
Kojto 158:b23ee177fd68 189 #define LL_USART_ICR_LBDCF USART_ICR_LBDCF /*!< LIN break detection flag */
Kojto 158:b23ee177fd68 190 #define LL_USART_ICR_CTSCF USART_ICR_CTSCF /*!< CTS flag */
Kojto 158:b23ee177fd68 191 #define LL_USART_ICR_RTOCF USART_ICR_RTOCF /*!< Receiver timeout flag */
Kojto 158:b23ee177fd68 192 #define LL_USART_ICR_EOBCF USART_ICR_EOBCF /*!< End of block flag */
Kojto 158:b23ee177fd68 193 #define LL_USART_ICR_CMCF USART_ICR_CMCF /*!< Character match flag */
Kojto 158:b23ee177fd68 194 #define LL_USART_ICR_WUCF USART_ICR_WUCF /*!< Wakeup from Stop mode flag */
Kojto 158:b23ee177fd68 195 /**
Kojto 158:b23ee177fd68 196 * @}
Kojto 158:b23ee177fd68 197 */
Kojto 158:b23ee177fd68 198
Kojto 158:b23ee177fd68 199 /** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines
Kojto 158:b23ee177fd68 200 * @brief Flags defines which can be used with LL_USART_ReadReg function
Kojto 158:b23ee177fd68 201 * @{
Kojto 158:b23ee177fd68 202 */
Kojto 158:b23ee177fd68 203 #define LL_USART_ISR_PE USART_ISR_PE /*!< Parity error flag */
Kojto 158:b23ee177fd68 204 #define LL_USART_ISR_FE USART_ISR_FE /*!< Framing error flag */
Kojto 158:b23ee177fd68 205 #define LL_USART_ISR_NE USART_ISR_NE /*!< Noise detected flag */
Kojto 158:b23ee177fd68 206 #define LL_USART_ISR_ORE USART_ISR_ORE /*!< Overrun error flag */
Kojto 158:b23ee177fd68 207 #define LL_USART_ISR_IDLE USART_ISR_IDLE /*!< Idle line detected flag */
Kojto 158:b23ee177fd68 208 #define LL_USART_ISR_RXNE USART_ISR_RXNE /*!< Read data register not empty flag */
Kojto 158:b23ee177fd68 209 #define LL_USART_ISR_TC USART_ISR_TC /*!< Transmission complete flag */
Kojto 158:b23ee177fd68 210 #define LL_USART_ISR_TXE USART_ISR_TXE /*!< Transmit data register empty flag */
Kojto 158:b23ee177fd68 211 #define LL_USART_ISR_LBDF USART_ISR_LBDF /*!< LIN break detection flag */
Kojto 158:b23ee177fd68 212 #define LL_USART_ISR_CTSIF USART_ISR_CTSIF /*!< CTS interrupt flag */
Kojto 158:b23ee177fd68 213 #define LL_USART_ISR_CTS USART_ISR_CTS /*!< CTS flag */
Kojto 158:b23ee177fd68 214 #define LL_USART_ISR_RTOF USART_ISR_RTOF /*!< Receiver timeout flag */
Kojto 158:b23ee177fd68 215 #define LL_USART_ISR_EOBF USART_ISR_EOBF /*!< End of block flag */
Kojto 158:b23ee177fd68 216 #define LL_USART_ISR_ABRE USART_ISR_ABRE /*!< Auto baud rate error flag */
Kojto 158:b23ee177fd68 217 #define LL_USART_ISR_ABRF USART_ISR_ABRF /*!< Auto baud rate flag */
Kojto 158:b23ee177fd68 218 #define LL_USART_ISR_BUSY USART_ISR_BUSY /*!< Busy flag */
Kojto 158:b23ee177fd68 219 #define LL_USART_ISR_CMF USART_ISR_CMF /*!< Character match flag */
Kojto 158:b23ee177fd68 220 #define LL_USART_ISR_SBKF USART_ISR_SBKF /*!< Send break flag */
Kojto 158:b23ee177fd68 221 #define LL_USART_ISR_RWU USART_ISR_RWU /*!< Receiver wakeup from Mute mode flag */
Kojto 158:b23ee177fd68 222 #define LL_USART_ISR_WUF USART_ISR_WUF /*!< Wakeup from Stop mode flag */
Kojto 158:b23ee177fd68 223 #define LL_USART_ISR_TEACK USART_ISR_TEACK /*!< Transmit enable acknowledge flag */
Kojto 158:b23ee177fd68 224 #define LL_USART_ISR_REACK USART_ISR_REACK /*!< Receive enable acknowledge flag */
Kojto 158:b23ee177fd68 225 #if defined(USART_TCBGT_SUPPORT)
Kojto 158:b23ee177fd68 226 #define LL_USART_ISR_TCBGT USART_ISR_TCBGT /*!< Transmission complete before guard time completion flag */
Kojto 158:b23ee177fd68 227 #endif
Kojto 158:b23ee177fd68 228 /**
Kojto 158:b23ee177fd68 229 * @}
Kojto 158:b23ee177fd68 230 */
Kojto 158:b23ee177fd68 231
Kojto 158:b23ee177fd68 232 /** @defgroup USART_LL_EC_IT IT Defines
Kojto 158:b23ee177fd68 233 * @brief IT defines which can be used with LL_USART_ReadReg and LL_USART_WriteReg functions
Kojto 158:b23ee177fd68 234 * @{
Kojto 158:b23ee177fd68 235 */
Kojto 158:b23ee177fd68 236 #define LL_USART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */
Kojto 158:b23ee177fd68 237 #define LL_USART_CR1_RXNEIE USART_CR1_RXNEIE /*!< Read data register not empty interrupt enable */
Kojto 158:b23ee177fd68 238 #define LL_USART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */
Kojto 158:b23ee177fd68 239 #define LL_USART_CR1_TXEIE USART_CR1_TXEIE /*!< Transmit data register empty interrupt enable */
Kojto 158:b23ee177fd68 240 #define LL_USART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */
Kojto 158:b23ee177fd68 241 #define LL_USART_CR1_CMIE USART_CR1_CMIE /*!< Character match interrupt enable */
Kojto 158:b23ee177fd68 242 #define LL_USART_CR1_RTOIE USART_CR1_RTOIE /*!< Receiver timeout interrupt enable */
Kojto 158:b23ee177fd68 243 #define LL_USART_CR1_EOBIE USART_CR1_EOBIE /*!< End of Block interrupt enable */
Kojto 158:b23ee177fd68 244 #define LL_USART_CR2_LBDIE USART_CR2_LBDIE /*!< LIN break detection interrupt enable */
Kojto 158:b23ee177fd68 245 #define LL_USART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */
Kojto 158:b23ee177fd68 246 #define LL_USART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */
Kojto 158:b23ee177fd68 247 #define LL_USART_CR3_WUFIE USART_CR3_WUFIE /*!< Wakeup from Stop mode interrupt enable */
Kojto 158:b23ee177fd68 248 #if defined(USART_TCBGT_SUPPORT)
Kojto 158:b23ee177fd68 249 #define LL_USART_CR3_TCBGTIE USART_CR3_TCBGTIE /*!< Transmission complete before guard time interrupt enable */
Kojto 158:b23ee177fd68 250 #endif
Kojto 158:b23ee177fd68 251 /**
Kojto 158:b23ee177fd68 252 * @}
Kojto 158:b23ee177fd68 253 */
Kojto 158:b23ee177fd68 254
Kojto 158:b23ee177fd68 255 /** @defgroup USART_LL_EC_DIRECTION Communication Direction
Kojto 158:b23ee177fd68 256 * @{
Kojto 158:b23ee177fd68 257 */
Kojto 158:b23ee177fd68 258 #define LL_USART_DIRECTION_NONE (uint32_t)0x00000000U /*!< Transmitter and Receiver are disabled */
Kojto 158:b23ee177fd68 259 #define LL_USART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */
Kojto 158:b23ee177fd68 260 #define LL_USART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */
Kojto 158:b23ee177fd68 261 #define LL_USART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */
Kojto 158:b23ee177fd68 262 /**
Kojto 158:b23ee177fd68 263 * @}
Kojto 158:b23ee177fd68 264 */
Kojto 158:b23ee177fd68 265
Kojto 158:b23ee177fd68 266 /** @defgroup USART_LL_EC_PARITY Parity Control
Kojto 158:b23ee177fd68 267 * @{
Kojto 158:b23ee177fd68 268 */
Kojto 158:b23ee177fd68 269 #define LL_USART_PARITY_NONE (uint32_t)0x00000000U /*!< Parity control disabled */
Kojto 158:b23ee177fd68 270 #define LL_USART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */
Kojto 158:b23ee177fd68 271 #define LL_USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */
Kojto 158:b23ee177fd68 272 /**
Kojto 158:b23ee177fd68 273 * @}
Kojto 158:b23ee177fd68 274 */
Kojto 158:b23ee177fd68 275
Kojto 158:b23ee177fd68 276 /** @defgroup USART_LL_EC_WAKEUP Wakeup
Kojto 158:b23ee177fd68 277 * @{
Kojto 158:b23ee177fd68 278 */
Kojto 158:b23ee177fd68 279 #define LL_USART_WAKEUP_IDLELINE (uint32_t)0x00000000U /*!< USART wake up from Mute mode on Idle Line */
Kojto 158:b23ee177fd68 280 #define LL_USART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< USART wake up from Mute mode on Address Mark */
Kojto 158:b23ee177fd68 281 /**
Kojto 158:b23ee177fd68 282 * @}
Kojto 158:b23ee177fd68 283 */
Kojto 158:b23ee177fd68 284
Kojto 158:b23ee177fd68 285 /** @defgroup USART_LL_EC_DATAWIDTH Datawidth
Kojto 158:b23ee177fd68 286 * @{
Kojto 158:b23ee177fd68 287 */
Kojto 158:b23ee177fd68 288 #define LL_USART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */
Kojto 158:b23ee177fd68 289 #define LL_USART_DATAWIDTH_8B (uint32_t)0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
Kojto 158:b23ee177fd68 290 #define LL_USART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
Kojto 158:b23ee177fd68 291 /**
Kojto 158:b23ee177fd68 292 * @}
Kojto 158:b23ee177fd68 293 */
Kojto 158:b23ee177fd68 294
Kojto 158:b23ee177fd68 295 /** @defgroup USART_LL_EC_OVERSAMPLING Oversampling
Kojto 158:b23ee177fd68 296 * @{
Kojto 158:b23ee177fd68 297 */
Kojto 158:b23ee177fd68 298 #define LL_USART_OVERSAMPLING_16 (uint32_t)0x00000000U /*!< Oversampling by 16 */
Kojto 158:b23ee177fd68 299 #define LL_USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */
Kojto 158:b23ee177fd68 300 /**
Kojto 158:b23ee177fd68 301 * @}
Kojto 158:b23ee177fd68 302 */
Kojto 158:b23ee177fd68 303
Kojto 158:b23ee177fd68 304 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 305 /** @defgroup USART_LL_EC_CLOCK Clock Signal
Kojto 158:b23ee177fd68 306 * @{
Kojto 158:b23ee177fd68 307 */
Kojto 158:b23ee177fd68 308
Kojto 158:b23ee177fd68 309 #define LL_USART_CLOCK_DISABLE (uint32_t)0x00000000U /*!< Clock signal not provided */
Kojto 158:b23ee177fd68 310 #define LL_USART_CLOCK_ENABLE USART_CR2_CLKEN /*!< Clock signal provided */
Kojto 158:b23ee177fd68 311 /**
Kojto 158:b23ee177fd68 312 * @}
Kojto 158:b23ee177fd68 313 */
Kojto 158:b23ee177fd68 314 #endif /*USE_FULL_LL_DRIVER*/
Kojto 158:b23ee177fd68 315
Kojto 158:b23ee177fd68 316 /** @defgroup USART_LL_EC_LASTCLKPULSE Last Clock Pulse
Kojto 158:b23ee177fd68 317 * @{
Kojto 158:b23ee177fd68 318 */
Kojto 158:b23ee177fd68 319 #define LL_USART_LASTCLKPULSE_NO_OUTPUT (uint32_t)0x00000000U /*!< The clock pulse of the last data bit is not output to the SCLK pin */
Kojto 158:b23ee177fd68 320 #define LL_USART_LASTCLKPULSE_OUTPUT USART_CR2_LBCL /*!< The clock pulse of the last data bit is output to the SCLK pin */
Kojto 158:b23ee177fd68 321 /**
Kojto 158:b23ee177fd68 322 * @}
Kojto 158:b23ee177fd68 323 */
Kojto 158:b23ee177fd68 324
Kojto 158:b23ee177fd68 325 /** @defgroup USART_LL_EC_PHASE Clock Phase
Kojto 158:b23ee177fd68 326 * @{
Kojto 158:b23ee177fd68 327 */
Kojto 158:b23ee177fd68 328 #define LL_USART_PHASE_1EDGE (uint32_t)0x00000000U /*!< The first clock transition is the first data capture edge */
Kojto 158:b23ee177fd68 329 #define LL_USART_PHASE_2EDGE USART_CR2_CPHA /*!< The second clock transition is the first data capture edge */
Kojto 158:b23ee177fd68 330 /**
Kojto 158:b23ee177fd68 331 * @}
Kojto 158:b23ee177fd68 332 */
Kojto 158:b23ee177fd68 333
Kojto 158:b23ee177fd68 334 /** @defgroup USART_LL_EC_POLARITY Clock Polarity
Kojto 158:b23ee177fd68 335 * @{
Kojto 158:b23ee177fd68 336 */
Kojto 158:b23ee177fd68 337 #define LL_USART_POLARITY_LOW (uint32_t)0x00000000U /*!< Steady low value on SCLK pin outside transmission window*/
Kojto 158:b23ee177fd68 338 #define LL_USART_POLARITY_HIGH USART_CR2_CPOL /*!< Steady high value on SCLK pin outside transmission window */
Kojto 158:b23ee177fd68 339 /**
Kojto 158:b23ee177fd68 340 * @}
Kojto 158:b23ee177fd68 341 */
Kojto 158:b23ee177fd68 342
Kojto 158:b23ee177fd68 343 /** @defgroup USART_LL_EC_STOPBITS Stop Bits
Kojto 158:b23ee177fd68 344 * @{
Kojto 158:b23ee177fd68 345 */
Kojto 158:b23ee177fd68 346 #define LL_USART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< 0.5 stop bit */
Kojto 158:b23ee177fd68 347 #define LL_USART_STOPBITS_1 (uint32_t)0x00000000U /*!< 1 stop bit */
Kojto 158:b23ee177fd68 348 #define LL_USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< 1.5 stop bits */
Kojto 158:b23ee177fd68 349 #define LL_USART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */
Kojto 158:b23ee177fd68 350 /**
Kojto 158:b23ee177fd68 351 * @}
Kojto 158:b23ee177fd68 352 */
Kojto 158:b23ee177fd68 353
Kojto 158:b23ee177fd68 354 /** @defgroup USART_LL_EC_TXRX TX RX Pins Swap
Kojto 158:b23ee177fd68 355 * @{
Kojto 158:b23ee177fd68 356 */
Kojto 158:b23ee177fd68 357 #define LL_USART_TXRX_STANDARD (uint32_t)0x00000000U /*!< TX/RX pins are used as defined in standard pinout */
Kojto 158:b23ee177fd68 358 #define LL_USART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */
Kojto 158:b23ee177fd68 359 /**
Kojto 158:b23ee177fd68 360 * @}
Kojto 158:b23ee177fd68 361 */
Kojto 158:b23ee177fd68 362
Kojto 158:b23ee177fd68 363 /** @defgroup USART_LL_EC_RXPIN_LEVEL RX Pin Active Level Inversion
Kojto 158:b23ee177fd68 364 * @{
Kojto 158:b23ee177fd68 365 */
Kojto 158:b23ee177fd68 366 #define LL_USART_RXPIN_LEVEL_STANDARD (uint32_t)0x00000000U /*!< RX pin signal works using the standard logic levels */
Kojto 158:b23ee177fd68 367 #define LL_USART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */
Kojto 158:b23ee177fd68 368 /**
Kojto 158:b23ee177fd68 369 * @}
Kojto 158:b23ee177fd68 370 */
Kojto 158:b23ee177fd68 371
Kojto 158:b23ee177fd68 372 /** @defgroup USART_LL_EC_TXPIN_LEVEL TX Pin Active Level Inversion
Kojto 158:b23ee177fd68 373 * @{
Kojto 158:b23ee177fd68 374 */
Kojto 158:b23ee177fd68 375 #define LL_USART_TXPIN_LEVEL_STANDARD (uint32_t)0x00000000U /*!< TX pin signal works using the standard logic levels */
Kojto 158:b23ee177fd68 376 #define LL_USART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */
Kojto 158:b23ee177fd68 377 /**
Kojto 158:b23ee177fd68 378 * @}
Kojto 158:b23ee177fd68 379 */
Kojto 158:b23ee177fd68 380
Kojto 158:b23ee177fd68 381 /** @defgroup USART_LL_EC_BINARY_LOGIC Binary Data Inversion
Kojto 158:b23ee177fd68 382 * @{
Kojto 158:b23ee177fd68 383 */
Kojto 158:b23ee177fd68 384 #define LL_USART_BINARY_LOGIC_POSITIVE (uint32_t)0x00000000U /*!< Logical data from the data register are send/received in positive/direct logic. (1=H, 0=L) */
Kojto 158:b23ee177fd68 385 #define LL_USART_BINARY_LOGIC_NEGATIVE USART_CR2_DATAINV /*!< Logical data from the data register are send/received in negative/inverse logic. (1=L, 0=H). The parity bit is also inverted. */
Kojto 158:b23ee177fd68 386 /**
Kojto 158:b23ee177fd68 387 * @}
Kojto 158:b23ee177fd68 388 */
Kojto 158:b23ee177fd68 389
Kojto 158:b23ee177fd68 390 /** @defgroup USART_LL_EC_BITORDER Bit Order
Kojto 158:b23ee177fd68 391 * @{
Kojto 158:b23ee177fd68 392 */
Kojto 158:b23ee177fd68 393 #define LL_USART_BITORDER_LSBFIRST (uint32_t)0x00000000U /*!< data is transmitted/received with data bit 0 first, following the start bit */
Kojto 158:b23ee177fd68 394 #define LL_USART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first, following the start bit */
Kojto 158:b23ee177fd68 395 /**
Kojto 158:b23ee177fd68 396 * @}
Kojto 158:b23ee177fd68 397 */
Kojto 158:b23ee177fd68 398
Kojto 158:b23ee177fd68 399 /** @defgroup USART_LL_EC_AUTOBAUD_DETECT_ON Autobaud Detection
Kojto 158:b23ee177fd68 400 * @{
Kojto 158:b23ee177fd68 401 */
Kojto 158:b23ee177fd68 402 #define LL_USART_AUTOBAUD_DETECT_ON_STARTBIT (uint32_t)0x00000000U /*!< Measurement of the start bit is used to detect the baud rate */
Kojto 158:b23ee177fd68 403 #define LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE USART_CR2_ABRMODE_0 /*!< Falling edge to falling edge measurement. Received frame must start with a single bit = 1 -> Frame = Start10xxxxxx */
Kojto 158:b23ee177fd68 404 #define LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME USART_CR2_ABRMODE_1 /*!< 0x7F frame detection */
Kojto 158:b23ee177fd68 405 #define LL_USART_AUTOBAUD_DETECT_ON_55_FRAME (USART_CR2_ABRMODE_1 | USART_CR2_ABRMODE_0) /*!< 0x55 frame detection */
Kojto 158:b23ee177fd68 406 /**
Kojto 158:b23ee177fd68 407 * @}
Kojto 158:b23ee177fd68 408 */
Kojto 158:b23ee177fd68 409
Kojto 158:b23ee177fd68 410 /** @defgroup USART_LL_EC_ADDRESS_DETECT Address Length Detection
Kojto 158:b23ee177fd68 411 * @{
Kojto 158:b23ee177fd68 412 */
Kojto 158:b23ee177fd68 413 #define LL_USART_ADDRESS_DETECT_4B (uint32_t)0x00000000U /*!< 4-bit address detection method selected */
Kojto 158:b23ee177fd68 414 #define LL_USART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */
Kojto 158:b23ee177fd68 415 /**
Kojto 158:b23ee177fd68 416 * @}
Kojto 158:b23ee177fd68 417 */
Kojto 158:b23ee177fd68 418
Kojto 158:b23ee177fd68 419 /** @defgroup USART_LL_EC_HWCONTROL Hardware Control
Kojto 158:b23ee177fd68 420 * @{
Kojto 158:b23ee177fd68 421 */
Kojto 158:b23ee177fd68 422 #define LL_USART_HWCONTROL_NONE (uint32_t)0x00000000U /*!< CTS and RTS hardware flow control disabled */
Kojto 158:b23ee177fd68 423 #define LL_USART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */
Kojto 158:b23ee177fd68 424 #define LL_USART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */
Kojto 158:b23ee177fd68 425 #define LL_USART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */
Kojto 158:b23ee177fd68 426 /**
Kojto 158:b23ee177fd68 427 * @}
Kojto 158:b23ee177fd68 428 */
Kojto 158:b23ee177fd68 429
Kojto 158:b23ee177fd68 430 /** @defgroup USART_LL_EC_WAKEUP_ON Wakeup Activation
Kojto 158:b23ee177fd68 431 * @{
Kojto 158:b23ee177fd68 432 */
Kojto 158:b23ee177fd68 433 #define LL_USART_WAKEUP_ON_ADDRESS (uint32_t)0x00000000U /*!< Wake up active on address match */
Kojto 158:b23ee177fd68 434 #define LL_USART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wake up active on Start bit detection */
Kojto 158:b23ee177fd68 435 #define LL_USART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wake up active on RXNE */
Kojto 158:b23ee177fd68 436 /**
Kojto 158:b23ee177fd68 437 * @}
Kojto 158:b23ee177fd68 438 */
Kojto 158:b23ee177fd68 439
Kojto 158:b23ee177fd68 440 /** @defgroup USART_LL_EC_IRDA_POWER IrDA Power
Kojto 158:b23ee177fd68 441 * @{
Kojto 158:b23ee177fd68 442 */
Kojto 158:b23ee177fd68 443 #define LL_USART_IRDA_POWER_NORMAL (uint32_t)0x00000000U /*!< IrDA normal power mode */
Kojto 158:b23ee177fd68 444 #define LL_USART_IRDA_POWER_LOW USART_CR3_IRLP /*!< IrDA low power mode */
Kojto 158:b23ee177fd68 445 /**
Kojto 158:b23ee177fd68 446 * @}
Kojto 158:b23ee177fd68 447 */
Kojto 158:b23ee177fd68 448
Kojto 158:b23ee177fd68 449 /** @defgroup USART_LL_EC_LINBREAK_DETECT LIN Break Detection Length
Kojto 158:b23ee177fd68 450 * @{
Kojto 158:b23ee177fd68 451 */
Kojto 158:b23ee177fd68 452 #define LL_USART_LINBREAK_DETECT_10B (uint32_t)0x00000000U /*!< 10-bit break detection method selected */
Kojto 158:b23ee177fd68 453 #define LL_USART_LINBREAK_DETECT_11B USART_CR2_LBDL /*!< 11-bit break detection method selected */
Kojto 158:b23ee177fd68 454 /**
Kojto 158:b23ee177fd68 455 * @}
Kojto 158:b23ee177fd68 456 */
Kojto 158:b23ee177fd68 457
Kojto 158:b23ee177fd68 458 /** @defgroup USART_LL_EC_DE_POLARITY Driver Enable Polarity
Kojto 158:b23ee177fd68 459 * @{
Kojto 158:b23ee177fd68 460 */
Kojto 158:b23ee177fd68 461 #define LL_USART_DE_POLARITY_HIGH (uint32_t)0x00000000U /*!< DE signal is active high */
Kojto 158:b23ee177fd68 462 #define LL_USART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */
Kojto 158:b23ee177fd68 463 /**
Kojto 158:b23ee177fd68 464 * @}
Kojto 158:b23ee177fd68 465 */
Kojto 158:b23ee177fd68 466
Kojto 158:b23ee177fd68 467 /** @defgroup USART_LL_EC_DMA_REG_DATA DMA Register Data
Kojto 158:b23ee177fd68 468 * @{
Kojto 158:b23ee177fd68 469 */
Kojto 158:b23ee177fd68 470 #define LL_USART_DMA_REG_DATA_TRANSMIT (uint32_t)0U /*!< Get address of data register used for transmission */
Kojto 158:b23ee177fd68 471 #define LL_USART_DMA_REG_DATA_RECEIVE (uint32_t)1U /*!< Get address of data register used for reception */
Kojto 158:b23ee177fd68 472 /**
Kojto 158:b23ee177fd68 473 * @}
Kojto 158:b23ee177fd68 474 */
Kojto 158:b23ee177fd68 475
Kojto 158:b23ee177fd68 476 /**
Kojto 158:b23ee177fd68 477 * @}
Kojto 158:b23ee177fd68 478 */
Kojto 158:b23ee177fd68 479
Kojto 158:b23ee177fd68 480 /* Exported macro ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 481 /** @defgroup USART_LL_Exported_Macros USART Exported Macros
Kojto 158:b23ee177fd68 482 * @{
Kojto 158:b23ee177fd68 483 */
Kojto 158:b23ee177fd68 484
Kojto 158:b23ee177fd68 485 /** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros
Kojto 158:b23ee177fd68 486 * @{
Kojto 158:b23ee177fd68 487 */
Kojto 158:b23ee177fd68 488
Kojto 158:b23ee177fd68 489 /**
Kojto 158:b23ee177fd68 490 * @brief Write a value in USART register
Kojto 158:b23ee177fd68 491 * @param __INSTANCE__ USART Instance
Kojto 158:b23ee177fd68 492 * @param __REG__ Register to be written
Kojto 158:b23ee177fd68 493 * @param __VALUE__ Value to be written in the register
Kojto 158:b23ee177fd68 494 * @retval None
Kojto 158:b23ee177fd68 495 */
Kojto 158:b23ee177fd68 496 #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
Kojto 158:b23ee177fd68 497
Kojto 158:b23ee177fd68 498 /**
Kojto 158:b23ee177fd68 499 * @brief Read a value in USART register
Kojto 158:b23ee177fd68 500 * @param __INSTANCE__ USART Instance
Kojto 158:b23ee177fd68 501 * @param __REG__ Register to be read
Kojto 158:b23ee177fd68 502 * @retval Register value
Kojto 158:b23ee177fd68 503 */
Kojto 158:b23ee177fd68 504 #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
Kojto 158:b23ee177fd68 505 /**
Kojto 158:b23ee177fd68 506 * @}
Kojto 158:b23ee177fd68 507 */
Kojto 158:b23ee177fd68 508
Kojto 158:b23ee177fd68 509 /** @defgroup USART_LL_EM_Exported_Macros_Helper Exported_Macros_Helper
Kojto 158:b23ee177fd68 510 * @{
Kojto 158:b23ee177fd68 511 */
Kojto 158:b23ee177fd68 512
Kojto 158:b23ee177fd68 513 /**
Kojto 158:b23ee177fd68 514 * @brief Compute USARTDIV value according to Peripheral Clock and
Kojto 158:b23ee177fd68 515 * expected Baud Rate in 8 bits sampling mode (32 bits value of USARTDIV is returned)
Kojto 158:b23ee177fd68 516 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance
Kojto 158:b23ee177fd68 517 * @param __BAUDRATE__ Baud rate value to achieve
Kojto 158:b23ee177fd68 518 * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case
Kojto 158:b23ee177fd68 519 */
Kojto 158:b23ee177fd68 520 #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) ((((__PERIPHCLK__)*2) + ((__BAUDRATE__)/2))/(__BAUDRATE__))
Kojto 158:b23ee177fd68 521
Kojto 158:b23ee177fd68 522 /**
Kojto 158:b23ee177fd68 523 * @brief Compute USARTDIV value according to Peripheral Clock and
Kojto 158:b23ee177fd68 524 * expected Baud Rate in 16 bits sampling mode (32 bits value of USARTDIV is returned)
Kojto 158:b23ee177fd68 525 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance
Kojto 158:b23ee177fd68 526 * @param __BAUDRATE__ Baud rate value to achieve
Kojto 158:b23ee177fd68 527 * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case
Kojto 158:b23ee177fd68 528 */
Kojto 158:b23ee177fd68 529 #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__) + ((__BAUDRATE__)/2))/(__BAUDRATE__))
Kojto 158:b23ee177fd68 530
Kojto 158:b23ee177fd68 531 /**
Kojto 158:b23ee177fd68 532 * @}
Kojto 158:b23ee177fd68 533 */
Kojto 158:b23ee177fd68 534
Kojto 158:b23ee177fd68 535 /**
Kojto 158:b23ee177fd68 536 * @}
Kojto 158:b23ee177fd68 537 */
Kojto 158:b23ee177fd68 538
Kojto 158:b23ee177fd68 539 /* Exported functions --------------------------------------------------------*/
Kojto 158:b23ee177fd68 540
Kojto 158:b23ee177fd68 541 /** @defgroup USART_LL_Exported_Functions USART Exported Functions
Kojto 158:b23ee177fd68 542 * @{
Kojto 158:b23ee177fd68 543 */
Kojto 158:b23ee177fd68 544
Kojto 158:b23ee177fd68 545 /** @defgroup USART_LL_EF_Configuration Configuration functions
Kojto 158:b23ee177fd68 546 * @{
Kojto 158:b23ee177fd68 547 */
Kojto 158:b23ee177fd68 548
Kojto 158:b23ee177fd68 549 /**
Kojto 158:b23ee177fd68 550 * @brief USART Enable
Kojto 158:b23ee177fd68 551 * @rmtoll CR1 UE LL_USART_Enable
Kojto 158:b23ee177fd68 552 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 553 * @retval None
Kojto 158:b23ee177fd68 554 */
Kojto 158:b23ee177fd68 555 __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 556 {
Kojto 158:b23ee177fd68 557 SET_BIT(USARTx->CR1, USART_CR1_UE);
Kojto 158:b23ee177fd68 558 }
Kojto 158:b23ee177fd68 559
Kojto 158:b23ee177fd68 560 /**
Kojto 158:b23ee177fd68 561 * @brief USART Disable (all USART prescalers and outputs are disabled)
Kojto 158:b23ee177fd68 562 * @note When USART is disabled, USART prescalers and outputs are stopped immediately,
Kojto 158:b23ee177fd68 563 * and current operations are discarded. The configuration of the USART is kept, but all the status
Kojto 158:b23ee177fd68 564 * flags, in the USARTx_ISR are set to their default values.
Kojto 158:b23ee177fd68 565 * @rmtoll CR1 UE LL_USART_Disable
Kojto 158:b23ee177fd68 566 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 567 * @retval None
Kojto 158:b23ee177fd68 568 */
Kojto 158:b23ee177fd68 569 __STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 570 {
Kojto 158:b23ee177fd68 571 CLEAR_BIT(USARTx->CR1, USART_CR1_UE);
Kojto 158:b23ee177fd68 572 }
Kojto 158:b23ee177fd68 573
Kojto 158:b23ee177fd68 574 /**
Kojto 158:b23ee177fd68 575 * @brief Indicate if USART is enabled
Kojto 158:b23ee177fd68 576 * @rmtoll CR1 UE LL_USART_IsEnabled
Kojto 158:b23ee177fd68 577 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 578 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 579 */
Kojto 158:b23ee177fd68 580 __STATIC_INLINE uint32_t LL_USART_IsEnabled(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 581 {
Kojto 158:b23ee177fd68 582 return (READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE));
Kojto 158:b23ee177fd68 583 }
Kojto 158:b23ee177fd68 584
Kojto 158:b23ee177fd68 585 /**
Kojto 158:b23ee177fd68 586 * @brief USART enabled in STOP Mode.
Kojto 158:b23ee177fd68 587 * @note When this function is enabled, USART is able to wake up the MCU from Stop mode, provided that
Kojto 158:b23ee177fd68 588 * USART clock selection is HSI or LSE in RCC.
Kojto 158:b23ee177fd68 589 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 590 * Wake-up from Stop mode feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 591 * @rmtoll CR1 UESM LL_USART_EnableInStopMode
Kojto 158:b23ee177fd68 592 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 593 * @retval None
Kojto 158:b23ee177fd68 594 */
Kojto 158:b23ee177fd68 595 __STATIC_INLINE void LL_USART_EnableInStopMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 596 {
Kojto 158:b23ee177fd68 597 SET_BIT(USARTx->CR1, USART_CR1_UESM);
Kojto 158:b23ee177fd68 598 }
Kojto 158:b23ee177fd68 599
Kojto 158:b23ee177fd68 600 /**
Kojto 158:b23ee177fd68 601 * @brief USART disabled in STOP Mode.
Kojto 158:b23ee177fd68 602 * @note When this function is disabled, USART is not able to wake up the MCU from Stop mode
Kojto 158:b23ee177fd68 603 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 604 * Wake-up from Stop mode feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 605 * @rmtoll CR1 UESM LL_USART_DisableInStopMode
Kojto 158:b23ee177fd68 606 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 607 * @retval None
Kojto 158:b23ee177fd68 608 */
Kojto 158:b23ee177fd68 609 __STATIC_INLINE void LL_USART_DisableInStopMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 610 {
Kojto 158:b23ee177fd68 611 CLEAR_BIT(USARTx->CR1, USART_CR1_UESM);
Kojto 158:b23ee177fd68 612 }
Kojto 158:b23ee177fd68 613
Kojto 158:b23ee177fd68 614 /**
Kojto 158:b23ee177fd68 615 * @brief Indicate if USART is enabled in STOP Mode (able to wake up MCU from Stop mode or not)
Kojto 158:b23ee177fd68 616 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 617 * Wake-up from Stop mode feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 618 * @rmtoll CR1 UESM LL_USART_IsEnabledInStopMode
Kojto 158:b23ee177fd68 619 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 620 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 621 */
Kojto 158:b23ee177fd68 622 __STATIC_INLINE uint32_t LL_USART_IsEnabledInStopMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 623 {
Kojto 158:b23ee177fd68 624 return (READ_BIT(USARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM));
Kojto 158:b23ee177fd68 625 }
Kojto 158:b23ee177fd68 626
Kojto 158:b23ee177fd68 627 /**
Kojto 158:b23ee177fd68 628 * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit)
Kojto 158:b23ee177fd68 629 * @rmtoll CR1 RE LL_USART_EnableDirectionRx
Kojto 158:b23ee177fd68 630 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 631 * @retval None
Kojto 158:b23ee177fd68 632 */
Kojto 158:b23ee177fd68 633 __STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 634 {
Kojto 158:b23ee177fd68 635 SET_BIT(USARTx->CR1, USART_CR1_RE);
Kojto 158:b23ee177fd68 636 }
Kojto 158:b23ee177fd68 637
Kojto 158:b23ee177fd68 638 /**
Kojto 158:b23ee177fd68 639 * @brief Receiver Disable
Kojto 158:b23ee177fd68 640 * @rmtoll CR1 RE LL_USART_DisableDirectionRx
Kojto 158:b23ee177fd68 641 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 642 * @retval None
Kojto 158:b23ee177fd68 643 */
Kojto 158:b23ee177fd68 644 __STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 645 {
Kojto 158:b23ee177fd68 646 CLEAR_BIT(USARTx->CR1, USART_CR1_RE);
Kojto 158:b23ee177fd68 647 }
Kojto 158:b23ee177fd68 648
Kojto 158:b23ee177fd68 649 /**
Kojto 158:b23ee177fd68 650 * @brief Transmitter Enable
Kojto 158:b23ee177fd68 651 * @rmtoll CR1 TE LL_USART_EnableDirectionTx
Kojto 158:b23ee177fd68 652 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 653 * @retval None
Kojto 158:b23ee177fd68 654 */
Kojto 158:b23ee177fd68 655 __STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 656 {
Kojto 158:b23ee177fd68 657 SET_BIT(USARTx->CR1, USART_CR1_TE);
Kojto 158:b23ee177fd68 658 }
Kojto 158:b23ee177fd68 659
Kojto 158:b23ee177fd68 660 /**
Kojto 158:b23ee177fd68 661 * @brief Transmitter Disable
Kojto 158:b23ee177fd68 662 * @rmtoll CR1 TE LL_USART_DisableDirectionTx
Kojto 158:b23ee177fd68 663 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 664 * @retval None
Kojto 158:b23ee177fd68 665 */
Kojto 158:b23ee177fd68 666 __STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 667 {
Kojto 158:b23ee177fd68 668 CLEAR_BIT(USARTx->CR1, USART_CR1_TE);
Kojto 158:b23ee177fd68 669 }
Kojto 158:b23ee177fd68 670
Kojto 158:b23ee177fd68 671 /**
Kojto 158:b23ee177fd68 672 * @brief Configure simultaneously enabled/disabled states
Kojto 158:b23ee177fd68 673 * of Transmitter and Receiver
Kojto 158:b23ee177fd68 674 * @rmtoll CR1 RE LL_USART_SetTransferDirection\n
Kojto 158:b23ee177fd68 675 * CR1 TE LL_USART_SetTransferDirection
Kojto 158:b23ee177fd68 676 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 677 * @param TransferDirection This parameter can be one of the following values:
Kojto 158:b23ee177fd68 678 * @arg @ref LL_USART_DIRECTION_NONE
Kojto 158:b23ee177fd68 679 * @arg @ref LL_USART_DIRECTION_RX
Kojto 158:b23ee177fd68 680 * @arg @ref LL_USART_DIRECTION_TX
Kojto 158:b23ee177fd68 681 * @arg @ref LL_USART_DIRECTION_TX_RX
Kojto 158:b23ee177fd68 682 * @retval None
Kojto 158:b23ee177fd68 683 */
Kojto 158:b23ee177fd68 684 __STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t TransferDirection)
Kojto 158:b23ee177fd68 685 {
Kojto 158:b23ee177fd68 686 MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection);
Kojto 158:b23ee177fd68 687 }
Kojto 158:b23ee177fd68 688
Kojto 158:b23ee177fd68 689 /**
Kojto 158:b23ee177fd68 690 * @brief Return enabled/disabled states of Transmitter and Receiver
Kojto 158:b23ee177fd68 691 * @rmtoll CR1 RE LL_USART_GetTransferDirection\n
Kojto 158:b23ee177fd68 692 * CR1 TE LL_USART_GetTransferDirection
Kojto 158:b23ee177fd68 693 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 694 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 695 * @arg @ref LL_USART_DIRECTION_NONE
Kojto 158:b23ee177fd68 696 * @arg @ref LL_USART_DIRECTION_RX
Kojto 158:b23ee177fd68 697 * @arg @ref LL_USART_DIRECTION_TX
Kojto 158:b23ee177fd68 698 * @arg @ref LL_USART_DIRECTION_TX_RX
Kojto 158:b23ee177fd68 699 */
Kojto 158:b23ee177fd68 700 __STATIC_INLINE uint32_t LL_USART_GetTransferDirection(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 701 {
Kojto 158:b23ee177fd68 702 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE));
Kojto 158:b23ee177fd68 703 }
Kojto 158:b23ee177fd68 704
Kojto 158:b23ee177fd68 705 /**
Kojto 158:b23ee177fd68 706 * @brief Configure Parity (enabled/disabled and parity mode if enabled).
Kojto 158:b23ee177fd68 707 * @note This function selects if hardware parity control (generation and detection) is enabled or disabled.
Kojto 158:b23ee177fd68 708 * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position
Kojto 158:b23ee177fd68 709 * (9th or 8th bit depending on data width) and parity is checked on the received data.
Kojto 158:b23ee177fd68 710 * @rmtoll CR1 PS LL_USART_SetParity\n
Kojto 158:b23ee177fd68 711 * CR1 PCE LL_USART_SetParity
Kojto 158:b23ee177fd68 712 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 713 * @param Parity This parameter can be one of the following values:
Kojto 158:b23ee177fd68 714 * @arg @ref LL_USART_PARITY_NONE
Kojto 158:b23ee177fd68 715 * @arg @ref LL_USART_PARITY_EVEN
Kojto 158:b23ee177fd68 716 * @arg @ref LL_USART_PARITY_ODD
Kojto 158:b23ee177fd68 717 * @retval None
Kojto 158:b23ee177fd68 718 */
Kojto 158:b23ee177fd68 719 __STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t Parity)
Kojto 158:b23ee177fd68 720 {
Kojto 158:b23ee177fd68 721 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity);
Kojto 158:b23ee177fd68 722 }
Kojto 158:b23ee177fd68 723
Kojto 158:b23ee177fd68 724 /**
Kojto 158:b23ee177fd68 725 * @brief Return Parity configuration (enabled/disabled and parity mode if enabled)
Kojto 158:b23ee177fd68 726 * @rmtoll CR1 PS LL_USART_GetParity\n
Kojto 158:b23ee177fd68 727 * CR1 PCE LL_USART_GetParity
Kojto 158:b23ee177fd68 728 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 729 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 730 * @arg @ref LL_USART_PARITY_NONE
Kojto 158:b23ee177fd68 731 * @arg @ref LL_USART_PARITY_EVEN
Kojto 158:b23ee177fd68 732 * @arg @ref LL_USART_PARITY_ODD
Kojto 158:b23ee177fd68 733 */
Kojto 158:b23ee177fd68 734 __STATIC_INLINE uint32_t LL_USART_GetParity(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 735 {
Kojto 158:b23ee177fd68 736 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE));
Kojto 158:b23ee177fd68 737 }
Kojto 158:b23ee177fd68 738
Kojto 158:b23ee177fd68 739 /**
Kojto 158:b23ee177fd68 740 * @brief Set Receiver Wake Up method from Mute mode.
Kojto 158:b23ee177fd68 741 * @rmtoll CR1 WAKE LL_USART_SetWakeUpMethod
Kojto 158:b23ee177fd68 742 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 743 * @param Method This parameter can be one of the following values:
Kojto 158:b23ee177fd68 744 * @arg @ref LL_USART_WAKEUP_IDLELINE
Kojto 158:b23ee177fd68 745 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK
Kojto 158:b23ee177fd68 746 * @retval None
Kojto 158:b23ee177fd68 747 */
Kojto 158:b23ee177fd68 748 __STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method)
Kojto 158:b23ee177fd68 749 {
Kojto 158:b23ee177fd68 750 MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method);
Kojto 158:b23ee177fd68 751 }
Kojto 158:b23ee177fd68 752
Kojto 158:b23ee177fd68 753 /**
Kojto 158:b23ee177fd68 754 * @brief Return Receiver Wake Up method from Mute mode
Kojto 158:b23ee177fd68 755 * @rmtoll CR1 WAKE LL_USART_GetWakeUpMethod
Kojto 158:b23ee177fd68 756 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 757 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 758 * @arg @ref LL_USART_WAKEUP_IDLELINE
Kojto 158:b23ee177fd68 759 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK
Kojto 158:b23ee177fd68 760 */
Kojto 158:b23ee177fd68 761 __STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 762 {
Kojto 158:b23ee177fd68 763 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE));
Kojto 158:b23ee177fd68 764 }
Kojto 158:b23ee177fd68 765
Kojto 158:b23ee177fd68 766 /**
Kojto 158:b23ee177fd68 767 * @brief Set Word length (i.e. nb of data bits, excluding start and stop bits)
Kojto 158:b23ee177fd68 768 * @rmtoll CR1 M0 LL_USART_SetDataWidth\n
Kojto 158:b23ee177fd68 769 * CR1 M1 LL_USART_SetDataWidth
Kojto 158:b23ee177fd68 770 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 771 * @param DataWidth This parameter can be one of the following values:
Kojto 158:b23ee177fd68 772 * @arg @ref LL_USART_DATAWIDTH_7B
Kojto 158:b23ee177fd68 773 * @arg @ref LL_USART_DATAWIDTH_8B
Kojto 158:b23ee177fd68 774 * @arg @ref LL_USART_DATAWIDTH_9B
Kojto 158:b23ee177fd68 775 * @retval None
Kojto 158:b23ee177fd68 776 */
Kojto 158:b23ee177fd68 777 __STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth)
Kojto 158:b23ee177fd68 778 {
Kojto 158:b23ee177fd68 779 MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth);
Kojto 158:b23ee177fd68 780 }
Kojto 158:b23ee177fd68 781
Kojto 158:b23ee177fd68 782 /**
Kojto 158:b23ee177fd68 783 * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits)
Kojto 158:b23ee177fd68 784 * @rmtoll CR1 M0 LL_USART_GetDataWidth\n
Kojto 158:b23ee177fd68 785 * CR1 M1 LL_USART_GetDataWidth
Kojto 158:b23ee177fd68 786 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 787 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 788 * @arg @ref LL_USART_DATAWIDTH_7B
Kojto 158:b23ee177fd68 789 * @arg @ref LL_USART_DATAWIDTH_8B
Kojto 158:b23ee177fd68 790 * @arg @ref LL_USART_DATAWIDTH_9B
Kojto 158:b23ee177fd68 791 */
Kojto 158:b23ee177fd68 792 __STATIC_INLINE uint32_t LL_USART_GetDataWidth(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 793 {
Kojto 158:b23ee177fd68 794 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M));
Kojto 158:b23ee177fd68 795 }
Kojto 158:b23ee177fd68 796
Kojto 158:b23ee177fd68 797 /**
Kojto 158:b23ee177fd68 798 * @brief Allow switch between Mute Mode and Active mode
Kojto 158:b23ee177fd68 799 * @rmtoll CR1 MME LL_USART_EnableMuteMode
Kojto 158:b23ee177fd68 800 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 801 * @retval None
Kojto 158:b23ee177fd68 802 */
Kojto 158:b23ee177fd68 803 __STATIC_INLINE void LL_USART_EnableMuteMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 804 {
Kojto 158:b23ee177fd68 805 SET_BIT(USARTx->CR1, USART_CR1_MME);
Kojto 158:b23ee177fd68 806 }
Kojto 158:b23ee177fd68 807
Kojto 158:b23ee177fd68 808 /**
Kojto 158:b23ee177fd68 809 * @brief Prevent Mute Mode use. Set Receiver in active mode permanently.
Kojto 158:b23ee177fd68 810 * @rmtoll CR1 MME LL_USART_DisableMuteMode
Kojto 158:b23ee177fd68 811 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 812 * @retval None
Kojto 158:b23ee177fd68 813 */
Kojto 158:b23ee177fd68 814 __STATIC_INLINE void LL_USART_DisableMuteMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 815 {
Kojto 158:b23ee177fd68 816 CLEAR_BIT(USARTx->CR1, USART_CR1_MME);
Kojto 158:b23ee177fd68 817 }
Kojto 158:b23ee177fd68 818
Kojto 158:b23ee177fd68 819 /**
Kojto 158:b23ee177fd68 820 * @brief Indicate if switch between Mute Mode and Active mode is allowed
Kojto 158:b23ee177fd68 821 * @rmtoll CR1 MME LL_USART_IsEnabledMuteMode
Kojto 158:b23ee177fd68 822 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 823 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 824 */
Kojto 158:b23ee177fd68 825 __STATIC_INLINE uint32_t LL_USART_IsEnabledMuteMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 826 {
Kojto 158:b23ee177fd68 827 return (READ_BIT(USARTx->CR1, USART_CR1_MME) == (USART_CR1_MME));
Kojto 158:b23ee177fd68 828 }
Kojto 158:b23ee177fd68 829
Kojto 158:b23ee177fd68 830 /**
Kojto 158:b23ee177fd68 831 * @brief Set Oversampling to 8-bit or 16-bit mode
Kojto 158:b23ee177fd68 832 * @rmtoll CR1 OVER8 LL_USART_SetOverSampling
Kojto 158:b23ee177fd68 833 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 834 * @param OverSampling This parameter can be one of the following values:
Kojto 158:b23ee177fd68 835 * @arg @ref LL_USART_OVERSAMPLING_16
Kojto 158:b23ee177fd68 836 * @arg @ref LL_USART_OVERSAMPLING_8
Kojto 158:b23ee177fd68 837 * @retval None
Kojto 158:b23ee177fd68 838 */
Kojto 158:b23ee177fd68 839 __STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling)
Kojto 158:b23ee177fd68 840 {
Kojto 158:b23ee177fd68 841 MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling);
Kojto 158:b23ee177fd68 842 }
Kojto 158:b23ee177fd68 843
Kojto 158:b23ee177fd68 844 /**
Kojto 158:b23ee177fd68 845 * @brief Return Oversampling mode
Kojto 158:b23ee177fd68 846 * @rmtoll CR1 OVER8 LL_USART_GetOverSampling
Kojto 158:b23ee177fd68 847 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 848 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 849 * @arg @ref LL_USART_OVERSAMPLING_16
Kojto 158:b23ee177fd68 850 * @arg @ref LL_USART_OVERSAMPLING_8
Kojto 158:b23ee177fd68 851 */
Kojto 158:b23ee177fd68 852 __STATIC_INLINE uint32_t LL_USART_GetOverSampling(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 853 {
Kojto 158:b23ee177fd68 854 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8));
Kojto 158:b23ee177fd68 855 }
Kojto 158:b23ee177fd68 856
Kojto 158:b23ee177fd68 857 /**
Kojto 158:b23ee177fd68 858 * @brief Configure if Clock pulse of the last data bit is output to the SCLK pin or not
Kojto 158:b23ee177fd68 859 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 860 * Synchronous mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 861 * @rmtoll CR2 LBCL LL_USART_SetLastClkPulseOutput
Kojto 158:b23ee177fd68 862 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 863 * @param LastBitClockPulse This parameter can be one of the following values:
Kojto 158:b23ee177fd68 864 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
Kojto 158:b23ee177fd68 865 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
Kojto 158:b23ee177fd68 866 * @retval None
Kojto 158:b23ee177fd68 867 */
Kojto 158:b23ee177fd68 868 __STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LastBitClockPulse)
Kojto 158:b23ee177fd68 869 {
Kojto 158:b23ee177fd68 870 MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LastBitClockPulse);
Kojto 158:b23ee177fd68 871 }
Kojto 158:b23ee177fd68 872
Kojto 158:b23ee177fd68 873 /**
Kojto 158:b23ee177fd68 874 * @brief Retrieve Clock pulse of the last data bit output configuration
Kojto 158:b23ee177fd68 875 * (Last bit Clock pulse output to the SCLK pin or not)
Kojto 158:b23ee177fd68 876 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 877 * Synchronous mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 878 * @rmtoll CR2 LBCL LL_USART_GetLastClkPulseOutput
Kojto 158:b23ee177fd68 879 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 880 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 881 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
Kojto 158:b23ee177fd68 882 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
Kojto 158:b23ee177fd68 883 */
Kojto 158:b23ee177fd68 884 __STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 885 {
Kojto 158:b23ee177fd68 886 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL));
Kojto 158:b23ee177fd68 887 }
Kojto 158:b23ee177fd68 888
Kojto 158:b23ee177fd68 889 /**
Kojto 158:b23ee177fd68 890 * @brief Select the phase of the clock output on the SCLK pin in synchronous mode
Kojto 158:b23ee177fd68 891 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 892 * Synchronous mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 893 * @rmtoll CR2 CPHA LL_USART_SetClockPhase
Kojto 158:b23ee177fd68 894 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 895 * @param ClockPhase This parameter can be one of the following values:
Kojto 158:b23ee177fd68 896 * @arg @ref LL_USART_PHASE_1EDGE
Kojto 158:b23ee177fd68 897 * @arg @ref LL_USART_PHASE_2EDGE
Kojto 158:b23ee177fd68 898 * @retval None
Kojto 158:b23ee177fd68 899 */
Kojto 158:b23ee177fd68 900 __STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t ClockPhase)
Kojto 158:b23ee177fd68 901 {
Kojto 158:b23ee177fd68 902 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, ClockPhase);
Kojto 158:b23ee177fd68 903 }
Kojto 158:b23ee177fd68 904
Kojto 158:b23ee177fd68 905 /**
Kojto 158:b23ee177fd68 906 * @brief Return phase of the clock output on the SCLK pin in synchronous mode
Kojto 158:b23ee177fd68 907 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 908 * Synchronous mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 909 * @rmtoll CR2 CPHA LL_USART_GetClockPhase
Kojto 158:b23ee177fd68 910 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 911 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 912 * @arg @ref LL_USART_PHASE_1EDGE
Kojto 158:b23ee177fd68 913 * @arg @ref LL_USART_PHASE_2EDGE
Kojto 158:b23ee177fd68 914 */
Kojto 158:b23ee177fd68 915 __STATIC_INLINE uint32_t LL_USART_GetClockPhase(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 916 {
Kojto 158:b23ee177fd68 917 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA));
Kojto 158:b23ee177fd68 918 }
Kojto 158:b23ee177fd68 919
Kojto 158:b23ee177fd68 920 /**
Kojto 158:b23ee177fd68 921 * @brief Select the polarity of the clock output on the SCLK pin in synchronous mode
Kojto 158:b23ee177fd68 922 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 923 * Synchronous mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 924 * @rmtoll CR2 CPOL LL_USART_SetClockPolarity
Kojto 158:b23ee177fd68 925 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 926 * @param ClockPolarity This parameter can be one of the following values:
Kojto 158:b23ee177fd68 927 * @arg @ref LL_USART_POLARITY_LOW
Kojto 158:b23ee177fd68 928 * @arg @ref LL_USART_POLARITY_HIGH
Kojto 158:b23ee177fd68 929 * @retval None
Kojto 158:b23ee177fd68 930 */
Kojto 158:b23ee177fd68 931 __STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t ClockPolarity)
Kojto 158:b23ee177fd68 932 {
Kojto 158:b23ee177fd68 933 MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, ClockPolarity);
Kojto 158:b23ee177fd68 934 }
Kojto 158:b23ee177fd68 935
Kojto 158:b23ee177fd68 936 /**
Kojto 158:b23ee177fd68 937 * @brief Return polarity of the clock output on the SCLK pin in synchronous mode
Kojto 158:b23ee177fd68 938 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 939 * Synchronous mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 940 * @rmtoll CR2 CPOL LL_USART_GetClockPolarity
Kojto 158:b23ee177fd68 941 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 942 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 943 * @arg @ref LL_USART_POLARITY_LOW
Kojto 158:b23ee177fd68 944 * @arg @ref LL_USART_POLARITY_HIGH
Kojto 158:b23ee177fd68 945 */
Kojto 158:b23ee177fd68 946 __STATIC_INLINE uint32_t LL_USART_GetClockPolarity(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 947 {
Kojto 158:b23ee177fd68 948 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL));
Kojto 158:b23ee177fd68 949 }
Kojto 158:b23ee177fd68 950
Kojto 158:b23ee177fd68 951 /**
Kojto 158:b23ee177fd68 952 * @brief Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse)
Kojto 158:b23ee177fd68 953 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 954 * Synchronous mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 955 * @note Call of this function is equivalent to following function call sequence :
Kojto 158:b23ee177fd68 956 * - Clock Phase configuration using @ref LL_USART_SetClockPhase() function
Kojto 158:b23ee177fd68 957 * - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function
Kojto 158:b23ee177fd68 958 * - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function
Kojto 158:b23ee177fd68 959 * @rmtoll CR2 CPHA LL_USART_ConfigClock\n
Kojto 158:b23ee177fd68 960 * CR2 CPOL LL_USART_ConfigClock\n
Kojto 158:b23ee177fd68 961 * CR2 LBCL LL_USART_ConfigClock
Kojto 158:b23ee177fd68 962 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 963 * @param Phase This parameter can be one of the following values:
Kojto 158:b23ee177fd68 964 * @arg @ref LL_USART_PHASE_1EDGE
Kojto 158:b23ee177fd68 965 * @arg @ref LL_USART_PHASE_2EDGE
Kojto 158:b23ee177fd68 966 * @param Polarity This parameter can be one of the following values:
Kojto 158:b23ee177fd68 967 * @arg @ref LL_USART_POLARITY_LOW
Kojto 158:b23ee177fd68 968 * @arg @ref LL_USART_POLARITY_HIGH
Kojto 158:b23ee177fd68 969 * @param LBCPOutput This parameter can be one of the following values:
Kojto 158:b23ee177fd68 970 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
Kojto 158:b23ee177fd68 971 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
Kojto 158:b23ee177fd68 972 * @retval None
Kojto 158:b23ee177fd68 973 */
Kojto 158:b23ee177fd68 974 __STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput)
Kojto 158:b23ee177fd68 975 {
Kojto 158:b23ee177fd68 976 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput);
Kojto 158:b23ee177fd68 977 }
Kojto 158:b23ee177fd68 978
Kojto 158:b23ee177fd68 979 /**
Kojto 158:b23ee177fd68 980 * @brief Enable Clock output on SCLK pin
Kojto 158:b23ee177fd68 981 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 982 * Synchronous mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 983 * @rmtoll CR2 CLKEN LL_USART_EnableSCLKOutput
Kojto 158:b23ee177fd68 984 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 985 * @retval None
Kojto 158:b23ee177fd68 986 */
Kojto 158:b23ee177fd68 987 __STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 988 {
Kojto 158:b23ee177fd68 989 SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
Kojto 158:b23ee177fd68 990 }
Kojto 158:b23ee177fd68 991
Kojto 158:b23ee177fd68 992 /**
Kojto 158:b23ee177fd68 993 * @brief Disable Clock output on SCLK pin
Kojto 158:b23ee177fd68 994 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 995 * Synchronous mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 996 * @rmtoll CR2 CLKEN LL_USART_DisableSCLKOutput
Kojto 158:b23ee177fd68 997 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 998 * @retval None
Kojto 158:b23ee177fd68 999 */
Kojto 158:b23ee177fd68 1000 __STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1001 {
Kojto 158:b23ee177fd68 1002 CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN);
Kojto 158:b23ee177fd68 1003 }
Kojto 158:b23ee177fd68 1004
Kojto 158:b23ee177fd68 1005 /**
Kojto 158:b23ee177fd68 1006 * @brief Indicate if Clock output on SCLK pin is enabled
Kojto 158:b23ee177fd68 1007 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1008 * Synchronous mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1009 * @rmtoll CR2 CLKEN LL_USART_IsEnabledSCLKOutput
Kojto 158:b23ee177fd68 1010 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1011 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1012 */
Kojto 158:b23ee177fd68 1013 __STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1014 {
Kojto 158:b23ee177fd68 1015 return (READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN));
Kojto 158:b23ee177fd68 1016 }
Kojto 158:b23ee177fd68 1017
Kojto 158:b23ee177fd68 1018 /**
Kojto 158:b23ee177fd68 1019 * @brief Set the length of the stop bits
Kojto 158:b23ee177fd68 1020 * @rmtoll CR2 STOP LL_USART_SetStopBitsLength
Kojto 158:b23ee177fd68 1021 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1022 * @param StopBits This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1023 * @arg @ref LL_USART_STOPBITS_0_5
Kojto 158:b23ee177fd68 1024 * @arg @ref LL_USART_STOPBITS_1
Kojto 158:b23ee177fd68 1025 * @arg @ref LL_USART_STOPBITS_1_5
Kojto 158:b23ee177fd68 1026 * @arg @ref LL_USART_STOPBITS_2
Kojto 158:b23ee177fd68 1027 * @retval None
Kojto 158:b23ee177fd68 1028 */
Kojto 158:b23ee177fd68 1029 __STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits)
Kojto 158:b23ee177fd68 1030 {
Kojto 158:b23ee177fd68 1031 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
Kojto 158:b23ee177fd68 1032 }
Kojto 158:b23ee177fd68 1033
Kojto 158:b23ee177fd68 1034 /**
Kojto 158:b23ee177fd68 1035 * @brief Retrieve the length of the stop bits
Kojto 158:b23ee177fd68 1036 * @rmtoll CR2 STOP LL_USART_GetStopBitsLength
Kojto 158:b23ee177fd68 1037 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1038 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1039 * @arg @ref LL_USART_STOPBITS_0_5
Kojto 158:b23ee177fd68 1040 * @arg @ref LL_USART_STOPBITS_1
Kojto 158:b23ee177fd68 1041 * @arg @ref LL_USART_STOPBITS_1_5
Kojto 158:b23ee177fd68 1042 * @arg @ref LL_USART_STOPBITS_2
Kojto 158:b23ee177fd68 1043 */
Kojto 158:b23ee177fd68 1044 __STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1045 {
Kojto 158:b23ee177fd68 1046 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP));
Kojto 158:b23ee177fd68 1047 }
Kojto 158:b23ee177fd68 1048
Kojto 158:b23ee177fd68 1049 /**
Kojto 158:b23ee177fd68 1050 * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits)
Kojto 158:b23ee177fd68 1051 * @note Call of this function is equivalent to following function call sequence :
Kojto 158:b23ee177fd68 1052 * - Data Width configuration using @ref LL_USART_SetDataWidth() function
Kojto 158:b23ee177fd68 1053 * - Parity Control and mode configuration using @ref LL_USART_SetParity() function
Kojto 158:b23ee177fd68 1054 * - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function
Kojto 158:b23ee177fd68 1055 * @rmtoll CR1 PS LL_USART_ConfigCharacter\n
Kojto 158:b23ee177fd68 1056 * CR1 PCE LL_USART_ConfigCharacter\n
Kojto 158:b23ee177fd68 1057 * CR1 M0 LL_USART_ConfigCharacter\n
Kojto 158:b23ee177fd68 1058 * CR1 M1 LL_USART_ConfigCharacter\n
Kojto 158:b23ee177fd68 1059 * CR2 STOP LL_USART_ConfigCharacter
Kojto 158:b23ee177fd68 1060 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1061 * @param DataWidth This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1062 * @arg @ref LL_USART_DATAWIDTH_7B
Kojto 158:b23ee177fd68 1063 * @arg @ref LL_USART_DATAWIDTH_8B
Kojto 158:b23ee177fd68 1064 * @arg @ref LL_USART_DATAWIDTH_9B
Kojto 158:b23ee177fd68 1065 * @param Parity This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1066 * @arg @ref LL_USART_PARITY_NONE
Kojto 158:b23ee177fd68 1067 * @arg @ref LL_USART_PARITY_EVEN
Kojto 158:b23ee177fd68 1068 * @arg @ref LL_USART_PARITY_ODD
Kojto 158:b23ee177fd68 1069 * @param StopBits This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1070 * @arg @ref LL_USART_STOPBITS_0_5
Kojto 158:b23ee177fd68 1071 * @arg @ref LL_USART_STOPBITS_1
Kojto 158:b23ee177fd68 1072 * @arg @ref LL_USART_STOPBITS_1_5
Kojto 158:b23ee177fd68 1073 * @arg @ref LL_USART_STOPBITS_2
Kojto 158:b23ee177fd68 1074 * @retval None
Kojto 158:b23ee177fd68 1075 */
Kojto 158:b23ee177fd68 1076 __STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t Parity,
Kojto 158:b23ee177fd68 1077 uint32_t StopBits)
Kojto 158:b23ee177fd68 1078 {
Kojto 158:b23ee177fd68 1079 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth);
Kojto 158:b23ee177fd68 1080 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
Kojto 158:b23ee177fd68 1081 }
Kojto 158:b23ee177fd68 1082
Kojto 158:b23ee177fd68 1083 /**
Kojto 158:b23ee177fd68 1084 * @brief Configure TX/RX pins swapping setting.
Kojto 158:b23ee177fd68 1085 * @rmtoll CR2 SWAP LL_USART_SetTXRXSwap
Kojto 158:b23ee177fd68 1086 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1087 * @param SwapConfig This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1088 * @arg @ref LL_USART_TXRX_STANDARD
Kojto 158:b23ee177fd68 1089 * @arg @ref LL_USART_TXRX_SWAPPED
Kojto 158:b23ee177fd68 1090 * @retval None
Kojto 158:b23ee177fd68 1091 */
Kojto 158:b23ee177fd68 1092 __STATIC_INLINE void LL_USART_SetTXRXSwap(USART_TypeDef *USARTx, uint32_t SwapConfig)
Kojto 158:b23ee177fd68 1093 {
Kojto 158:b23ee177fd68 1094 MODIFY_REG(USARTx->CR2, USART_CR2_SWAP, SwapConfig);
Kojto 158:b23ee177fd68 1095 }
Kojto 158:b23ee177fd68 1096
Kojto 158:b23ee177fd68 1097 /**
Kojto 158:b23ee177fd68 1098 * @brief Retrieve TX/RX pins swapping configuration.
Kojto 158:b23ee177fd68 1099 * @rmtoll CR2 SWAP LL_USART_GetTXRXSwap
Kojto 158:b23ee177fd68 1100 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1101 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1102 * @arg @ref LL_USART_TXRX_STANDARD
Kojto 158:b23ee177fd68 1103 * @arg @ref LL_USART_TXRX_SWAPPED
Kojto 158:b23ee177fd68 1104 */
Kojto 158:b23ee177fd68 1105 __STATIC_INLINE uint32_t LL_USART_GetTXRXSwap(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1106 {
Kojto 158:b23ee177fd68 1107 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_SWAP));
Kojto 158:b23ee177fd68 1108 }
Kojto 158:b23ee177fd68 1109
Kojto 158:b23ee177fd68 1110 /**
Kojto 158:b23ee177fd68 1111 * @brief Configure RX pin active level logic
Kojto 158:b23ee177fd68 1112 * @rmtoll CR2 RXINV LL_USART_SetRXPinLevel
Kojto 158:b23ee177fd68 1113 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1114 * @param PinInvMethod This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1115 * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD
Kojto 158:b23ee177fd68 1116 * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED
Kojto 158:b23ee177fd68 1117 * @retval None
Kojto 158:b23ee177fd68 1118 */
Kojto 158:b23ee177fd68 1119 __STATIC_INLINE void LL_USART_SetRXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod)
Kojto 158:b23ee177fd68 1120 {
Kojto 158:b23ee177fd68 1121 MODIFY_REG(USARTx->CR2, USART_CR2_RXINV, PinInvMethod);
Kojto 158:b23ee177fd68 1122 }
Kojto 158:b23ee177fd68 1123
Kojto 158:b23ee177fd68 1124 /**
Kojto 158:b23ee177fd68 1125 * @brief Retrieve RX pin active level logic configuration
Kojto 158:b23ee177fd68 1126 * @rmtoll CR2 RXINV LL_USART_GetRXPinLevel
Kojto 158:b23ee177fd68 1127 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1128 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1129 * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD
Kojto 158:b23ee177fd68 1130 * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED
Kojto 158:b23ee177fd68 1131 */
Kojto 158:b23ee177fd68 1132 __STATIC_INLINE uint32_t LL_USART_GetRXPinLevel(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1133 {
Kojto 158:b23ee177fd68 1134 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_RXINV));
Kojto 158:b23ee177fd68 1135 }
Kojto 158:b23ee177fd68 1136
Kojto 158:b23ee177fd68 1137 /**
Kojto 158:b23ee177fd68 1138 * @brief Configure TX pin active level logic
Kojto 158:b23ee177fd68 1139 * @rmtoll CR2 TXINV LL_USART_SetTXPinLevel
Kojto 158:b23ee177fd68 1140 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1141 * @param PinInvMethod This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1142 * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD
Kojto 158:b23ee177fd68 1143 * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED
Kojto 158:b23ee177fd68 1144 * @retval None
Kojto 158:b23ee177fd68 1145 */
Kojto 158:b23ee177fd68 1146 __STATIC_INLINE void LL_USART_SetTXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod)
Kojto 158:b23ee177fd68 1147 {
Kojto 158:b23ee177fd68 1148 MODIFY_REG(USARTx->CR2, USART_CR2_TXINV, PinInvMethod);
Kojto 158:b23ee177fd68 1149 }
Kojto 158:b23ee177fd68 1150
Kojto 158:b23ee177fd68 1151 /**
Kojto 158:b23ee177fd68 1152 * @brief Retrieve TX pin active level logic configuration
Kojto 158:b23ee177fd68 1153 * @rmtoll CR2 TXINV LL_USART_GetTXPinLevel
Kojto 158:b23ee177fd68 1154 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1155 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1156 * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD
Kojto 158:b23ee177fd68 1157 * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED
Kojto 158:b23ee177fd68 1158 */
Kojto 158:b23ee177fd68 1159 __STATIC_INLINE uint32_t LL_USART_GetTXPinLevel(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1160 {
Kojto 158:b23ee177fd68 1161 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_TXINV));
Kojto 158:b23ee177fd68 1162 }
Kojto 158:b23ee177fd68 1163
Kojto 158:b23ee177fd68 1164 /**
Kojto 158:b23ee177fd68 1165 * @brief Configure Binary data logic.
Kojto 158:b23ee177fd68 1166 * @note Allow to define how Logical data from the data register are send/received :
Kojto 158:b23ee177fd68 1167 * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H)
Kojto 158:b23ee177fd68 1168 * @rmtoll CR2 DATAINV LL_USART_SetBinaryDataLogic
Kojto 158:b23ee177fd68 1169 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1170 * @param DataLogic This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1171 * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE
Kojto 158:b23ee177fd68 1172 * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE
Kojto 158:b23ee177fd68 1173 * @retval None
Kojto 158:b23ee177fd68 1174 */
Kojto 158:b23ee177fd68 1175 __STATIC_INLINE void LL_USART_SetBinaryDataLogic(USART_TypeDef *USARTx, uint32_t DataLogic)
Kojto 158:b23ee177fd68 1176 {
Kojto 158:b23ee177fd68 1177 MODIFY_REG(USARTx->CR2, USART_CR2_DATAINV, DataLogic);
Kojto 158:b23ee177fd68 1178 }
Kojto 158:b23ee177fd68 1179
Kojto 158:b23ee177fd68 1180 /**
Kojto 158:b23ee177fd68 1181 * @brief Retrieve Binary data configuration
Kojto 158:b23ee177fd68 1182 * @rmtoll CR2 DATAINV LL_USART_GetBinaryDataLogic
Kojto 158:b23ee177fd68 1183 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1184 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1185 * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE
Kojto 158:b23ee177fd68 1186 * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE
Kojto 158:b23ee177fd68 1187 */
Kojto 158:b23ee177fd68 1188 __STATIC_INLINE uint32_t LL_USART_GetBinaryDataLogic(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1189 {
Kojto 158:b23ee177fd68 1190 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_DATAINV));
Kojto 158:b23ee177fd68 1191 }
Kojto 158:b23ee177fd68 1192
Kojto 158:b23ee177fd68 1193 /**
Kojto 158:b23ee177fd68 1194 * @brief Configure transfer bit order (either Less or Most Significant Bit First)
Kojto 158:b23ee177fd68 1195 * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
Kojto 158:b23ee177fd68 1196 * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
Kojto 158:b23ee177fd68 1197 * @rmtoll CR2 MSBFIRST LL_USART_SetTransferBitOrder
Kojto 158:b23ee177fd68 1198 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1199 * @param BitOrder This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1200 * @arg @ref LL_USART_BITORDER_LSBFIRST
Kojto 158:b23ee177fd68 1201 * @arg @ref LL_USART_BITORDER_MSBFIRST
Kojto 158:b23ee177fd68 1202 * @retval None
Kojto 158:b23ee177fd68 1203 */
Kojto 158:b23ee177fd68 1204 __STATIC_INLINE void LL_USART_SetTransferBitOrder(USART_TypeDef *USARTx, uint32_t BitOrder)
Kojto 158:b23ee177fd68 1205 {
Kojto 158:b23ee177fd68 1206 MODIFY_REG(USARTx->CR2, USART_CR2_MSBFIRST, BitOrder);
Kojto 158:b23ee177fd68 1207 }
Kojto 158:b23ee177fd68 1208
Kojto 158:b23ee177fd68 1209 /**
Kojto 158:b23ee177fd68 1210 * @brief Return transfer bit order (either Less or Most Significant Bit First)
Kojto 158:b23ee177fd68 1211 * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
Kojto 158:b23ee177fd68 1212 * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
Kojto 158:b23ee177fd68 1213 * @rmtoll CR2 MSBFIRST LL_USART_GetTransferBitOrder
Kojto 158:b23ee177fd68 1214 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1215 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1216 * @arg @ref LL_USART_BITORDER_LSBFIRST
Kojto 158:b23ee177fd68 1217 * @arg @ref LL_USART_BITORDER_MSBFIRST
Kojto 158:b23ee177fd68 1218 */
Kojto 158:b23ee177fd68 1219 __STATIC_INLINE uint32_t LL_USART_GetTransferBitOrder(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1220 {
Kojto 158:b23ee177fd68 1221 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_MSBFIRST));
Kojto 158:b23ee177fd68 1222 }
Kojto 158:b23ee177fd68 1223
Kojto 158:b23ee177fd68 1224 /**
Kojto 158:b23ee177fd68 1225 * @brief Enable Auto Baud-Rate Detection
Kojto 158:b23ee177fd68 1226 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1227 * Auto Baud Rate detection feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1228 * @rmtoll CR2 ABREN LL_USART_EnableAutoBaudRate
Kojto 158:b23ee177fd68 1229 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1230 * @retval None
Kojto 158:b23ee177fd68 1231 */
Kojto 158:b23ee177fd68 1232 __STATIC_INLINE void LL_USART_EnableAutoBaudRate(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1233 {
Kojto 158:b23ee177fd68 1234 SET_BIT(USARTx->CR2, USART_CR2_ABREN);
Kojto 158:b23ee177fd68 1235 }
Kojto 158:b23ee177fd68 1236
Kojto 158:b23ee177fd68 1237 /**
Kojto 158:b23ee177fd68 1238 * @brief Disable Auto Baud-Rate Detection
Kojto 158:b23ee177fd68 1239 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1240 * Auto Baud Rate detection feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1241 * @rmtoll CR2 ABREN LL_USART_DisableAutoBaudRate
Kojto 158:b23ee177fd68 1242 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1243 * @retval None
Kojto 158:b23ee177fd68 1244 */
Kojto 158:b23ee177fd68 1245 __STATIC_INLINE void LL_USART_DisableAutoBaudRate(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1246 {
Kojto 158:b23ee177fd68 1247 CLEAR_BIT(USARTx->CR2, USART_CR2_ABREN);
Kojto 158:b23ee177fd68 1248 }
Kojto 158:b23ee177fd68 1249
Kojto 158:b23ee177fd68 1250 /**
Kojto 158:b23ee177fd68 1251 * @brief Indicate if Auto Baud-Rate Detection mechanism is enabled
Kojto 158:b23ee177fd68 1252 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1253 * Auto Baud Rate detection feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1254 * @rmtoll CR2 ABREN LL_USART_IsEnabledAutoBaud
Kojto 158:b23ee177fd68 1255 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1256 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1257 */
Kojto 158:b23ee177fd68 1258 __STATIC_INLINE uint32_t LL_USART_IsEnabledAutoBaud(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1259 {
Kojto 158:b23ee177fd68 1260 return (READ_BIT(USARTx->CR2, USART_CR2_ABREN) == (USART_CR2_ABREN));
Kojto 158:b23ee177fd68 1261 }
Kojto 158:b23ee177fd68 1262
Kojto 158:b23ee177fd68 1263 /**
Kojto 158:b23ee177fd68 1264 * @brief Set Auto Baud-Rate mode bits
Kojto 158:b23ee177fd68 1265 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1266 * Auto Baud Rate detection feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1267 * @rmtoll CR2 ABRMODE LL_USART_SetAutoBaudRateMode
Kojto 158:b23ee177fd68 1268 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1269 * @param AutoBaudRateMode This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1270 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT
Kojto 158:b23ee177fd68 1271 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE
Kojto 158:b23ee177fd68 1272 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME
Kojto 158:b23ee177fd68 1273 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME
Kojto 158:b23ee177fd68 1274 * @retval None
Kojto 158:b23ee177fd68 1275 */
Kojto 158:b23ee177fd68 1276 __STATIC_INLINE void LL_USART_SetAutoBaudRateMode(USART_TypeDef *USARTx, uint32_t AutoBaudRateMode)
Kojto 158:b23ee177fd68 1277 {
Kojto 158:b23ee177fd68 1278 MODIFY_REG(USARTx->CR2, USART_CR2_ABRMODE, AutoBaudRateMode);
Kojto 158:b23ee177fd68 1279 }
Kojto 158:b23ee177fd68 1280
Kojto 158:b23ee177fd68 1281 /**
Kojto 158:b23ee177fd68 1282 * @brief Return Auto Baud-Rate mode
Kojto 158:b23ee177fd68 1283 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1284 * Auto Baud Rate detection feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1285 * @rmtoll CR2 ABRMODE LL_USART_GetAutoBaudRateMode
Kojto 158:b23ee177fd68 1286 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1287 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1288 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT
Kojto 158:b23ee177fd68 1289 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE
Kojto 158:b23ee177fd68 1290 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME
Kojto 158:b23ee177fd68 1291 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME
Kojto 158:b23ee177fd68 1292 */
Kojto 158:b23ee177fd68 1293 __STATIC_INLINE uint32_t LL_USART_GetAutoBaudRateMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1294 {
Kojto 158:b23ee177fd68 1295 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ABRMODE));
Kojto 158:b23ee177fd68 1296 }
Kojto 158:b23ee177fd68 1297
Kojto 158:b23ee177fd68 1298 /**
Kojto 158:b23ee177fd68 1299 * @brief Enable Receiver Timeout
Kojto 158:b23ee177fd68 1300 * @rmtoll CR2 RTOEN LL_USART_EnableRxTimeout
Kojto 158:b23ee177fd68 1301 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1302 * @retval None
Kojto 158:b23ee177fd68 1303 */
Kojto 158:b23ee177fd68 1304 __STATIC_INLINE void LL_USART_EnableRxTimeout(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1305 {
Kojto 158:b23ee177fd68 1306 SET_BIT(USARTx->CR2, USART_CR2_RTOEN);
Kojto 158:b23ee177fd68 1307 }
Kojto 158:b23ee177fd68 1308
Kojto 158:b23ee177fd68 1309 /**
Kojto 158:b23ee177fd68 1310 * @brief Disable Receiver Timeout
Kojto 158:b23ee177fd68 1311 * @rmtoll CR2 RTOEN LL_USART_DisableRxTimeout
Kojto 158:b23ee177fd68 1312 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1313 * @retval None
Kojto 158:b23ee177fd68 1314 */
Kojto 158:b23ee177fd68 1315 __STATIC_INLINE void LL_USART_DisableRxTimeout(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1316 {
Kojto 158:b23ee177fd68 1317 CLEAR_BIT(USARTx->CR2, USART_CR2_RTOEN);
Kojto 158:b23ee177fd68 1318 }
Kojto 158:b23ee177fd68 1319
Kojto 158:b23ee177fd68 1320 /**
Kojto 158:b23ee177fd68 1321 * @brief Indicate if Receiver Timeout feature is enabled
Kojto 158:b23ee177fd68 1322 * @rmtoll CR2 RTOEN LL_USART_IsEnabledRxTimeout
Kojto 158:b23ee177fd68 1323 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1324 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1325 */
Kojto 158:b23ee177fd68 1326 __STATIC_INLINE uint32_t LL_USART_IsEnabledRxTimeout(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1327 {
Kojto 158:b23ee177fd68 1328 return (READ_BIT(USARTx->CR2, USART_CR2_RTOEN) == (USART_CR2_RTOEN));
Kojto 158:b23ee177fd68 1329 }
Kojto 158:b23ee177fd68 1330
Kojto 158:b23ee177fd68 1331 /**
Kojto 158:b23ee177fd68 1332 * @brief Set Address of the USART node.
Kojto 158:b23ee177fd68 1333 * @note This is used in multiprocessor communication during Mute mode or Stop mode,
Kojto 158:b23ee177fd68 1334 * for wake up with address mark detection.
Kojto 158:b23ee177fd68 1335 * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7.
Kojto 158:b23ee177fd68 1336 * (b7-b4 should be set to 0)
Kojto 158:b23ee177fd68 1337 * 8bits address node is used when 7-bit Address Detection is selected in ADDM7.
Kojto 158:b23ee177fd68 1338 * (This is used in multiprocessor communication during Mute mode or Stop mode,
Kojto 158:b23ee177fd68 1339 * for wake up with 7-bit address mark detection.
Kojto 158:b23ee177fd68 1340 * The MSB of the character sent by the transmitter should be equal to 1.
Kojto 158:b23ee177fd68 1341 * It may also be used for character detection during normal reception,
Kojto 158:b23ee177fd68 1342 * Mute mode inactive (for example, end of block detection in ModBus protocol).
Kojto 158:b23ee177fd68 1343 * In this case, the whole received character (8-bit) is compared to the ADD[7:0]
Kojto 158:b23ee177fd68 1344 * value and CMF flag is set on match)
Kojto 158:b23ee177fd68 1345 * @rmtoll CR2 ADD LL_USART_ConfigNodeAddress\n
Kojto 158:b23ee177fd68 1346 * CR2 ADDM7 LL_USART_ConfigNodeAddress
Kojto 158:b23ee177fd68 1347 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1348 * @param AddressLen This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1349 * @arg @ref LL_USART_ADDRESS_DETECT_4B
Kojto 158:b23ee177fd68 1350 * @arg @ref LL_USART_ADDRESS_DETECT_7B
Kojto 158:b23ee177fd68 1351 * @param NodeAddress 4 or 7 bit Address of the USART node.
Kojto 158:b23ee177fd68 1352 * @retval None
Kojto 158:b23ee177fd68 1353 */
Kojto 158:b23ee177fd68 1354 __STATIC_INLINE void LL_USART_ConfigNodeAddress(USART_TypeDef *USARTx, uint32_t AddressLen, uint32_t NodeAddress)
Kojto 158:b23ee177fd68 1355 {
Kojto 158:b23ee177fd68 1356 MODIFY_REG(USARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7,
Kojto 158:b23ee177fd68 1357 (uint32_t)(AddressLen | (NodeAddress << USART_POSITION_CR2_ADD)));
Kojto 158:b23ee177fd68 1358 }
Kojto 158:b23ee177fd68 1359
Kojto 158:b23ee177fd68 1360 /**
Kojto 158:b23ee177fd68 1361 * @brief Return 8 bit Address of the USART node as set in ADD field of CR2.
Kojto 158:b23ee177fd68 1362 * @note If 4-bit Address Detection is selected in ADDM7,
Kojto 158:b23ee177fd68 1363 * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant)
Kojto 158:b23ee177fd68 1364 * If 7-bit Address Detection is selected in ADDM7,
Kojto 158:b23ee177fd68 1365 * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant)
Kojto 158:b23ee177fd68 1366 * @rmtoll CR2 ADD LL_USART_GetNodeAddress
Kojto 158:b23ee177fd68 1367 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1368 * @retval Address of the USART node (Value between Min_Data=0 and Max_Data=255)
Kojto 158:b23ee177fd68 1369 */
Kojto 158:b23ee177fd68 1370 __STATIC_INLINE uint32_t LL_USART_GetNodeAddress(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1371 {
Kojto 158:b23ee177fd68 1372 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD) >> USART_POSITION_CR2_ADD);
Kojto 158:b23ee177fd68 1373 }
Kojto 158:b23ee177fd68 1374
Kojto 158:b23ee177fd68 1375 /**
Kojto 158:b23ee177fd68 1376 * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit)
Kojto 158:b23ee177fd68 1377 * @rmtoll CR2 ADDM7 LL_USART_GetNodeAddressLen
Kojto 158:b23ee177fd68 1378 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1379 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1380 * @arg @ref LL_USART_ADDRESS_DETECT_4B
Kojto 158:b23ee177fd68 1381 * @arg @ref LL_USART_ADDRESS_DETECT_7B
Kojto 158:b23ee177fd68 1382 */
Kojto 158:b23ee177fd68 1383 __STATIC_INLINE uint32_t LL_USART_GetNodeAddressLen(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1384 {
Kojto 158:b23ee177fd68 1385 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADDM7));
Kojto 158:b23ee177fd68 1386 }
Kojto 158:b23ee177fd68 1387
Kojto 158:b23ee177fd68 1388 /**
Kojto 158:b23ee177fd68 1389 * @brief Enable RTS HW Flow Control
Kojto 158:b23ee177fd68 1390 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1391 * Hardware Flow control feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1392 * @rmtoll CR3 RTSE LL_USART_EnableRTSHWFlowCtrl
Kojto 158:b23ee177fd68 1393 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1394 * @retval None
Kojto 158:b23ee177fd68 1395 */
Kojto 158:b23ee177fd68 1396 __STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1397 {
Kojto 158:b23ee177fd68 1398 SET_BIT(USARTx->CR3, USART_CR3_RTSE);
Kojto 158:b23ee177fd68 1399 }
Kojto 158:b23ee177fd68 1400
Kojto 158:b23ee177fd68 1401 /**
Kojto 158:b23ee177fd68 1402 * @brief Disable RTS HW Flow Control
Kojto 158:b23ee177fd68 1403 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1404 * Hardware Flow control feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1405 * @rmtoll CR3 RTSE LL_USART_DisableRTSHWFlowCtrl
Kojto 158:b23ee177fd68 1406 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1407 * @retval None
Kojto 158:b23ee177fd68 1408 */
Kojto 158:b23ee177fd68 1409 __STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1410 {
Kojto 158:b23ee177fd68 1411 CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE);
Kojto 158:b23ee177fd68 1412 }
Kojto 158:b23ee177fd68 1413
Kojto 158:b23ee177fd68 1414 /**
Kojto 158:b23ee177fd68 1415 * @brief Enable CTS HW Flow Control
Kojto 158:b23ee177fd68 1416 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1417 * Hardware Flow control feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1418 * @rmtoll CR3 CTSE LL_USART_EnableCTSHWFlowCtrl
Kojto 158:b23ee177fd68 1419 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1420 * @retval None
Kojto 158:b23ee177fd68 1421 */
Kojto 158:b23ee177fd68 1422 __STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1423 {
Kojto 158:b23ee177fd68 1424 SET_BIT(USARTx->CR3, USART_CR3_CTSE);
Kojto 158:b23ee177fd68 1425 }
Kojto 158:b23ee177fd68 1426
Kojto 158:b23ee177fd68 1427 /**
Kojto 158:b23ee177fd68 1428 * @brief Disable CTS HW Flow Control
Kojto 158:b23ee177fd68 1429 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1430 * Hardware Flow control feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1431 * @rmtoll CR3 CTSE LL_USART_DisableCTSHWFlowCtrl
Kojto 158:b23ee177fd68 1432 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1433 * @retval None
Kojto 158:b23ee177fd68 1434 */
Kojto 158:b23ee177fd68 1435 __STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1436 {
Kojto 158:b23ee177fd68 1437 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE);
Kojto 158:b23ee177fd68 1438 }
Kojto 158:b23ee177fd68 1439
Kojto 158:b23ee177fd68 1440 /**
Kojto 158:b23ee177fd68 1441 * @brief Configure HW Flow Control mode (both CTS and RTS)
Kojto 158:b23ee177fd68 1442 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1443 * Hardware Flow control feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1444 * @rmtoll CR3 RTSE LL_USART_SetHWFlowCtrl\n
Kojto 158:b23ee177fd68 1445 * CR3 CTSE LL_USART_SetHWFlowCtrl
Kojto 158:b23ee177fd68 1446 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1447 * @param HardwareFlowControl This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1448 * @arg @ref LL_USART_HWCONTROL_NONE
Kojto 158:b23ee177fd68 1449 * @arg @ref LL_USART_HWCONTROL_RTS
Kojto 158:b23ee177fd68 1450 * @arg @ref LL_USART_HWCONTROL_CTS
Kojto 158:b23ee177fd68 1451 * @arg @ref LL_USART_HWCONTROL_RTS_CTS
Kojto 158:b23ee177fd68 1452 * @retval None
Kojto 158:b23ee177fd68 1453 */
Kojto 158:b23ee177fd68 1454 __STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HardwareFlowControl)
Kojto 158:b23ee177fd68 1455 {
Kojto 158:b23ee177fd68 1456 MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl);
Kojto 158:b23ee177fd68 1457 }
Kojto 158:b23ee177fd68 1458
Kojto 158:b23ee177fd68 1459 /**
Kojto 158:b23ee177fd68 1460 * @brief Return HW Flow Control configuration (both CTS and RTS)
Kojto 158:b23ee177fd68 1461 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1462 * Hardware Flow control feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1463 * @rmtoll CR3 RTSE LL_USART_GetHWFlowCtrl\n
Kojto 158:b23ee177fd68 1464 * CR3 CTSE LL_USART_GetHWFlowCtrl
Kojto 158:b23ee177fd68 1465 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1466 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1467 * @arg @ref LL_USART_HWCONTROL_NONE
Kojto 158:b23ee177fd68 1468 * @arg @ref LL_USART_HWCONTROL_RTS
Kojto 158:b23ee177fd68 1469 * @arg @ref LL_USART_HWCONTROL_CTS
Kojto 158:b23ee177fd68 1470 * @arg @ref LL_USART_HWCONTROL_RTS_CTS
Kojto 158:b23ee177fd68 1471 */
Kojto 158:b23ee177fd68 1472 __STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1473 {
Kojto 158:b23ee177fd68 1474 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE));
Kojto 158:b23ee177fd68 1475 }
Kojto 158:b23ee177fd68 1476
Kojto 158:b23ee177fd68 1477 /**
Kojto 158:b23ee177fd68 1478 * @brief Enable One bit sampling method
Kojto 158:b23ee177fd68 1479 * @rmtoll CR3 ONEBIT LL_USART_EnableOneBitSamp
Kojto 158:b23ee177fd68 1480 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1481 * @retval None
Kojto 158:b23ee177fd68 1482 */
Kojto 158:b23ee177fd68 1483 __STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1484 {
Kojto 158:b23ee177fd68 1485 SET_BIT(USARTx->CR3, USART_CR3_ONEBIT);
Kojto 158:b23ee177fd68 1486 }
Kojto 158:b23ee177fd68 1487
Kojto 158:b23ee177fd68 1488 /**
Kojto 158:b23ee177fd68 1489 * @brief Disable One bit sampling method
Kojto 158:b23ee177fd68 1490 * @rmtoll CR3 ONEBIT LL_USART_DisableOneBitSamp
Kojto 158:b23ee177fd68 1491 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1492 * @retval None
Kojto 158:b23ee177fd68 1493 */
Kojto 158:b23ee177fd68 1494 __STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1495 {
Kojto 158:b23ee177fd68 1496 CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT);
Kojto 158:b23ee177fd68 1497 }
Kojto 158:b23ee177fd68 1498
Kojto 158:b23ee177fd68 1499 /**
Kojto 158:b23ee177fd68 1500 * @brief Indicate if One bit sampling method is enabled
Kojto 158:b23ee177fd68 1501 * @rmtoll CR3 ONEBIT LL_USART_IsEnabledOneBitSamp
Kojto 158:b23ee177fd68 1502 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1503 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1504 */
Kojto 158:b23ee177fd68 1505 __STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1506 {
Kojto 158:b23ee177fd68 1507 return (READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT));
Kojto 158:b23ee177fd68 1508 }
Kojto 158:b23ee177fd68 1509
Kojto 158:b23ee177fd68 1510 /**
Kojto 158:b23ee177fd68 1511 * @brief Enable Overrun detection
Kojto 158:b23ee177fd68 1512 * @rmtoll CR3 OVRDIS LL_USART_EnableOverrunDetect
Kojto 158:b23ee177fd68 1513 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1514 * @retval None
Kojto 158:b23ee177fd68 1515 */
Kojto 158:b23ee177fd68 1516 __STATIC_INLINE void LL_USART_EnableOverrunDetect(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1517 {
Kojto 158:b23ee177fd68 1518 CLEAR_BIT(USARTx->CR3, USART_CR3_OVRDIS);
Kojto 158:b23ee177fd68 1519 }
Kojto 158:b23ee177fd68 1520
Kojto 158:b23ee177fd68 1521 /**
Kojto 158:b23ee177fd68 1522 * @brief Disable Overrun detection
Kojto 158:b23ee177fd68 1523 * @rmtoll CR3 OVRDIS LL_USART_DisableOverrunDetect
Kojto 158:b23ee177fd68 1524 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1525 * @retval None
Kojto 158:b23ee177fd68 1526 */
Kojto 158:b23ee177fd68 1527 __STATIC_INLINE void LL_USART_DisableOverrunDetect(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1528 {
Kojto 158:b23ee177fd68 1529 SET_BIT(USARTx->CR3, USART_CR3_OVRDIS);
Kojto 158:b23ee177fd68 1530 }
Kojto 158:b23ee177fd68 1531
Kojto 158:b23ee177fd68 1532 /**
Kojto 158:b23ee177fd68 1533 * @brief Indicate if Overrun detection is enabled
Kojto 158:b23ee177fd68 1534 * @rmtoll CR3 OVRDIS LL_USART_IsEnabledOverrunDetect
Kojto 158:b23ee177fd68 1535 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1536 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1537 */
Kojto 158:b23ee177fd68 1538 __STATIC_INLINE uint32_t LL_USART_IsEnabledOverrunDetect(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1539 {
Kojto 158:b23ee177fd68 1540 return (READ_BIT(USARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS);
Kojto 158:b23ee177fd68 1541 }
Kojto 158:b23ee177fd68 1542
Kojto 158:b23ee177fd68 1543 /**
Kojto 158:b23ee177fd68 1544 * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits)
Kojto 158:b23ee177fd68 1545 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1546 * Wake-up from Stop mode feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1547 * @rmtoll CR3 WUS LL_USART_SetWKUPType
Kojto 158:b23ee177fd68 1548 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1549 * @param Type This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1550 * @arg @ref LL_USART_WAKEUP_ON_ADDRESS
Kojto 158:b23ee177fd68 1551 * @arg @ref LL_USART_WAKEUP_ON_STARTBIT
Kojto 158:b23ee177fd68 1552 * @arg @ref LL_USART_WAKEUP_ON_RXNE
Kojto 158:b23ee177fd68 1553 * @retval None
Kojto 158:b23ee177fd68 1554 */
Kojto 158:b23ee177fd68 1555 __STATIC_INLINE void LL_USART_SetWKUPType(USART_TypeDef *USARTx, uint32_t Type)
Kojto 158:b23ee177fd68 1556 {
Kojto 158:b23ee177fd68 1557 MODIFY_REG(USARTx->CR3, USART_CR3_WUS, Type);
Kojto 158:b23ee177fd68 1558 }
Kojto 158:b23ee177fd68 1559
Kojto 158:b23ee177fd68 1560 /**
Kojto 158:b23ee177fd68 1561 * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits)
Kojto 158:b23ee177fd68 1562 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1563 * Wake-up from Stop mode feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1564 * @rmtoll CR3 WUS LL_USART_GetWKUPType
Kojto 158:b23ee177fd68 1565 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1566 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1567 * @arg @ref LL_USART_WAKEUP_ON_ADDRESS
Kojto 158:b23ee177fd68 1568 * @arg @ref LL_USART_WAKEUP_ON_STARTBIT
Kojto 158:b23ee177fd68 1569 * @arg @ref LL_USART_WAKEUP_ON_RXNE
Kojto 158:b23ee177fd68 1570 */
Kojto 158:b23ee177fd68 1571 __STATIC_INLINE uint32_t LL_USART_GetWKUPType(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1572 {
Kojto 158:b23ee177fd68 1573 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_WUS));
Kojto 158:b23ee177fd68 1574 }
Kojto 158:b23ee177fd68 1575
Kojto 158:b23ee177fd68 1576 /**
Kojto 158:b23ee177fd68 1577 * @brief Configure USART BRR register for achieving expected Baud Rate value.
Kojto 158:b23ee177fd68 1578 * @note Compute and set USARTDIV value in BRR Register (full BRR content)
Kojto 158:b23ee177fd68 1579 * according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values
Kojto 158:b23ee177fd68 1580 * @note Peripheral clock and Baud rate values provided as function parameters should be valid
Kojto 158:b23ee177fd68 1581 * (Baud rate value != 0)
Kojto 158:b23ee177fd68 1582 * @rmtoll BRR BRR LL_USART_SetBaudRate
Kojto 158:b23ee177fd68 1583 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1584 * @param PeriphClk Peripheral Clock
Kojto 158:b23ee177fd68 1585 * @param OverSampling This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1586 * @arg @ref LL_USART_OVERSAMPLING_16
Kojto 158:b23ee177fd68 1587 * @arg @ref LL_USART_OVERSAMPLING_8
Kojto 158:b23ee177fd68 1588 * @param BaudRate Baud Rate
Kojto 158:b23ee177fd68 1589 * @retval None
Kojto 158:b23ee177fd68 1590 */
Kojto 158:b23ee177fd68 1591 __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling,
Kojto 158:b23ee177fd68 1592 uint32_t BaudRate)
Kojto 158:b23ee177fd68 1593 {
Kojto 158:b23ee177fd68 1594 register uint32_t usartdiv = 0x0U;
Kojto 158:b23ee177fd68 1595 register uint32_t brrtemp = 0x0U;
Kojto 158:b23ee177fd68 1596
Kojto 158:b23ee177fd68 1597 if (OverSampling == LL_USART_OVERSAMPLING_8)
Kojto 158:b23ee177fd68 1598 {
Kojto 158:b23ee177fd68 1599 usartdiv = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, BaudRate));
Kojto 158:b23ee177fd68 1600 brrtemp = usartdiv & 0xFFF0U;
Kojto 158:b23ee177fd68 1601 brrtemp |= (uint16_t)((usartdiv & (uint16_t)0x000FU) >> 1U);
Kojto 158:b23ee177fd68 1602 USARTx->BRR = brrtemp;
Kojto 158:b23ee177fd68 1603 }
Kojto 158:b23ee177fd68 1604 else
Kojto 158:b23ee177fd68 1605 {
Kojto 158:b23ee177fd68 1606 USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate));
Kojto 158:b23ee177fd68 1607 }
Kojto 158:b23ee177fd68 1608 }
Kojto 158:b23ee177fd68 1609
Kojto 158:b23ee177fd68 1610 /**
Kojto 158:b23ee177fd68 1611 * @brief Return current Baud Rate value, according to USARTDIV present in BRR register
Kojto 158:b23ee177fd68 1612 * (full BRR content), and to used Peripheral Clock and Oversampling mode values
Kojto 158:b23ee177fd68 1613 * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned.
Kojto 158:b23ee177fd68 1614 * @rmtoll BRR BRR LL_USART_GetBaudRate
Kojto 158:b23ee177fd68 1615 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1616 * @param PeriphClk Peripheral Clock
Kojto 158:b23ee177fd68 1617 * @param OverSampling This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1618 * @arg @ref LL_USART_OVERSAMPLING_16
Kojto 158:b23ee177fd68 1619 * @arg @ref LL_USART_OVERSAMPLING_8
Kojto 158:b23ee177fd68 1620 * @retval Baud Rate
Kojto 158:b23ee177fd68 1621 */
Kojto 158:b23ee177fd68 1622 __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling)
Kojto 158:b23ee177fd68 1623 {
Kojto 158:b23ee177fd68 1624 register uint32_t usartdiv = 0x0U;
Kojto 158:b23ee177fd68 1625 register uint32_t brrresult = 0x0U;
Kojto 158:b23ee177fd68 1626
Kojto 158:b23ee177fd68 1627 usartdiv = USARTx->BRR;
Kojto 158:b23ee177fd68 1628
Kojto 158:b23ee177fd68 1629 if (OverSampling == LL_USART_OVERSAMPLING_8)
Kojto 158:b23ee177fd68 1630 {
Kojto 158:b23ee177fd68 1631 if ((usartdiv & 0xFFF7U) != 0U)
Kojto 158:b23ee177fd68 1632 {
Kojto 158:b23ee177fd68 1633 usartdiv = (uint16_t)((usartdiv & 0xFFF0U) | ((usartdiv & 0x0007U) << 1U)) ;
Kojto 158:b23ee177fd68 1634 brrresult = (PeriphClk * 2U) / usartdiv;
Kojto 158:b23ee177fd68 1635 }
Kojto 158:b23ee177fd68 1636 }
Kojto 158:b23ee177fd68 1637 else
Kojto 158:b23ee177fd68 1638 {
Kojto 158:b23ee177fd68 1639 if ((usartdiv & 0xFFFFU) != 0U)
Kojto 158:b23ee177fd68 1640 {
Kojto 158:b23ee177fd68 1641 brrresult = PeriphClk / usartdiv;
Kojto 158:b23ee177fd68 1642 }
Kojto 158:b23ee177fd68 1643 }
Kojto 158:b23ee177fd68 1644 return (brrresult);
Kojto 158:b23ee177fd68 1645 }
Kojto 158:b23ee177fd68 1646
Kojto 158:b23ee177fd68 1647 /**
Kojto 158:b23ee177fd68 1648 * @brief Set Receiver Time Out Value (expressed in nb of bits duration)
Kojto 158:b23ee177fd68 1649 * @rmtoll RTOR RTO LL_USART_SetRxTimeout
Kojto 158:b23ee177fd68 1650 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1651 * @param Timeout Value between Min_Data=0x00 and Max_Data=0x00FFFFFF
Kojto 158:b23ee177fd68 1652 * @retval None
Kojto 158:b23ee177fd68 1653 */
Kojto 158:b23ee177fd68 1654 __STATIC_INLINE void LL_USART_SetRxTimeout(USART_TypeDef *USARTx, uint32_t Timeout)
Kojto 158:b23ee177fd68 1655 {
Kojto 158:b23ee177fd68 1656 MODIFY_REG(USARTx->RTOR, USART_RTOR_RTO, Timeout);
Kojto 158:b23ee177fd68 1657 }
Kojto 158:b23ee177fd68 1658
Kojto 158:b23ee177fd68 1659 /**
Kojto 158:b23ee177fd68 1660 * @brief Get Receiver Time Out Value (expressed in nb of bits duration)
Kojto 158:b23ee177fd68 1661 * @rmtoll RTOR RTO LL_USART_GetRxTimeout
Kojto 158:b23ee177fd68 1662 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1663 * @retval Value between Min_Data=0x00 and Max_Data=0x00FFFFFF
Kojto 158:b23ee177fd68 1664 */
Kojto 158:b23ee177fd68 1665 __STATIC_INLINE uint32_t LL_USART_GetRxTimeout(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1666 {
Kojto 158:b23ee177fd68 1667 return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_RTO));
Kojto 158:b23ee177fd68 1668 }
Kojto 158:b23ee177fd68 1669
Kojto 158:b23ee177fd68 1670 /**
Kojto 158:b23ee177fd68 1671 * @brief Set Block Length value in reception
Kojto 158:b23ee177fd68 1672 * @rmtoll RTOR BLEN LL_USART_SetBlockLength
Kojto 158:b23ee177fd68 1673 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1674 * @param BlockLength Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 1675 * @retval None
Kojto 158:b23ee177fd68 1676 */
Kojto 158:b23ee177fd68 1677 __STATIC_INLINE void LL_USART_SetBlockLength(USART_TypeDef *USARTx, uint32_t BlockLength)
Kojto 158:b23ee177fd68 1678 {
Kojto 158:b23ee177fd68 1679 MODIFY_REG(USARTx->RTOR, USART_RTOR_BLEN, BlockLength << USART_POSITION_RTOR_BLEN);
Kojto 158:b23ee177fd68 1680 }
Kojto 158:b23ee177fd68 1681
Kojto 158:b23ee177fd68 1682 /**
Kojto 158:b23ee177fd68 1683 * @brief Get Block Length value in reception
Kojto 158:b23ee177fd68 1684 * @rmtoll RTOR BLEN LL_USART_GetBlockLength
Kojto 158:b23ee177fd68 1685 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1686 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 1687 */
Kojto 158:b23ee177fd68 1688 __STATIC_INLINE uint32_t LL_USART_GetBlockLength(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1689 {
Kojto 158:b23ee177fd68 1690 return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_BLEN) >> USART_POSITION_RTOR_BLEN);
Kojto 158:b23ee177fd68 1691 }
Kojto 158:b23ee177fd68 1692
Kojto 158:b23ee177fd68 1693 /**
Kojto 158:b23ee177fd68 1694 * @}
Kojto 158:b23ee177fd68 1695 */
Kojto 158:b23ee177fd68 1696
Kojto 158:b23ee177fd68 1697 /** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature
Kojto 158:b23ee177fd68 1698 * @{
Kojto 158:b23ee177fd68 1699 */
Kojto 158:b23ee177fd68 1700
Kojto 158:b23ee177fd68 1701 /**
Kojto 158:b23ee177fd68 1702 * @brief Enable IrDA mode
Kojto 158:b23ee177fd68 1703 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1704 * IrDA feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1705 * @rmtoll CR3 IREN LL_USART_EnableIrda
Kojto 158:b23ee177fd68 1706 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1707 * @retval None
Kojto 158:b23ee177fd68 1708 */
Kojto 158:b23ee177fd68 1709 __STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1710 {
Kojto 158:b23ee177fd68 1711 SET_BIT(USARTx->CR3, USART_CR3_IREN);
Kojto 158:b23ee177fd68 1712 }
Kojto 158:b23ee177fd68 1713
Kojto 158:b23ee177fd68 1714 /**
Kojto 158:b23ee177fd68 1715 * @brief Disable IrDA mode
Kojto 158:b23ee177fd68 1716 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1717 * IrDA feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1718 * @rmtoll CR3 IREN LL_USART_DisableIrda
Kojto 158:b23ee177fd68 1719 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1720 * @retval None
Kojto 158:b23ee177fd68 1721 */
Kojto 158:b23ee177fd68 1722 __STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1723 {
Kojto 158:b23ee177fd68 1724 CLEAR_BIT(USARTx->CR3, USART_CR3_IREN);
Kojto 158:b23ee177fd68 1725 }
Kojto 158:b23ee177fd68 1726
Kojto 158:b23ee177fd68 1727 /**
Kojto 158:b23ee177fd68 1728 * @brief Indicate if IrDA mode is enabled
Kojto 158:b23ee177fd68 1729 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1730 * IrDA feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1731 * @rmtoll CR3 IREN LL_USART_IsEnabledIrda
Kojto 158:b23ee177fd68 1732 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1733 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1734 */
Kojto 158:b23ee177fd68 1735 __STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1736 {
Kojto 158:b23ee177fd68 1737 return (READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN));
Kojto 158:b23ee177fd68 1738 }
Kojto 158:b23ee177fd68 1739
Kojto 158:b23ee177fd68 1740 /**
Kojto 158:b23ee177fd68 1741 * @brief Configure IrDA Power Mode (Normal or Low Power)
Kojto 158:b23ee177fd68 1742 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1743 * IrDA feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1744 * @rmtoll CR3 IRLP LL_USART_SetIrdaPowerMode
Kojto 158:b23ee177fd68 1745 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1746 * @param PowerMode This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1747 * @arg @ref LL_USART_IRDA_POWER_NORMAL
Kojto 158:b23ee177fd68 1748 * @arg @ref LL_USART_IRDA_POWER_LOW
Kojto 158:b23ee177fd68 1749 * @retval None
Kojto 158:b23ee177fd68 1750 */
Kojto 158:b23ee177fd68 1751 __STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode)
Kojto 158:b23ee177fd68 1752 {
Kojto 158:b23ee177fd68 1753 MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode);
Kojto 158:b23ee177fd68 1754 }
Kojto 158:b23ee177fd68 1755
Kojto 158:b23ee177fd68 1756 /**
Kojto 158:b23ee177fd68 1757 * @brief Retrieve IrDA Power Mode configuration (Normal or Low Power)
Kojto 158:b23ee177fd68 1758 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1759 * IrDA feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1760 * @rmtoll CR3 IRLP LL_USART_GetIrdaPowerMode
Kojto 158:b23ee177fd68 1761 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1762 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1763 * @arg @ref LL_USART_IRDA_POWER_NORMAL
Kojto 158:b23ee177fd68 1764 * @arg @ref LL_USART_PHASE_2EDGE
Kojto 158:b23ee177fd68 1765 */
Kojto 158:b23ee177fd68 1766 __STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1767 {
Kojto 158:b23ee177fd68 1768 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP));
Kojto 158:b23ee177fd68 1769 }
Kojto 158:b23ee177fd68 1770
Kojto 158:b23ee177fd68 1771 /**
Kojto 158:b23ee177fd68 1772 * @brief Set Irda prescaler value, used for dividing the USART clock source
Kojto 158:b23ee177fd68 1773 * to achieve the Irda Low Power frequency (8 bits value)
Kojto 158:b23ee177fd68 1774 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1775 * IrDA feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1776 * @rmtoll GTPR PSC LL_USART_SetIrdaPrescaler
Kojto 158:b23ee177fd68 1777 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1778 * @param PrescalerValue Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 1779 * @retval None
Kojto 158:b23ee177fd68 1780 */
Kojto 158:b23ee177fd68 1781 __STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
Kojto 158:b23ee177fd68 1782 {
Kojto 158:b23ee177fd68 1783 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue);
Kojto 158:b23ee177fd68 1784 }
Kojto 158:b23ee177fd68 1785
Kojto 158:b23ee177fd68 1786 /**
Kojto 158:b23ee177fd68 1787 * @brief Return Irda prescaler value, used for dividing the USART clock source
Kojto 158:b23ee177fd68 1788 * to achieve the Irda Low Power frequency (8 bits value)
Kojto 158:b23ee177fd68 1789 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1790 * IrDA feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1791 * @rmtoll GTPR PSC LL_USART_GetIrdaPrescaler
Kojto 158:b23ee177fd68 1792 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1793 * @retval Irda prescaler value (Value between Min_Data=0x00 and Max_Data=0xFF)
Kojto 158:b23ee177fd68 1794 */
Kojto 158:b23ee177fd68 1795 __STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1796 {
Kojto 158:b23ee177fd68 1797 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
Kojto 158:b23ee177fd68 1798 }
Kojto 158:b23ee177fd68 1799
Kojto 158:b23ee177fd68 1800 /**
Kojto 158:b23ee177fd68 1801 * @}
Kojto 158:b23ee177fd68 1802 */
Kojto 158:b23ee177fd68 1803
Kojto 158:b23ee177fd68 1804 /** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature
Kojto 158:b23ee177fd68 1805 * @{
Kojto 158:b23ee177fd68 1806 */
Kojto 158:b23ee177fd68 1807
Kojto 158:b23ee177fd68 1808 /**
Kojto 158:b23ee177fd68 1809 * @brief Enable Smartcard NACK transmission
Kojto 158:b23ee177fd68 1810 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1811 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1812 * @rmtoll CR3 NACK LL_USART_EnableSmartcardNACK
Kojto 158:b23ee177fd68 1813 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1814 * @retval None
Kojto 158:b23ee177fd68 1815 */
Kojto 158:b23ee177fd68 1816 __STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1817 {
Kojto 158:b23ee177fd68 1818 SET_BIT(USARTx->CR3, USART_CR3_NACK);
Kojto 158:b23ee177fd68 1819 }
Kojto 158:b23ee177fd68 1820
Kojto 158:b23ee177fd68 1821 /**
Kojto 158:b23ee177fd68 1822 * @brief Disable Smartcard NACK transmission
Kojto 158:b23ee177fd68 1823 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1824 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1825 * @rmtoll CR3 NACK LL_USART_DisableSmartcardNACK
Kojto 158:b23ee177fd68 1826 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1827 * @retval None
Kojto 158:b23ee177fd68 1828 */
Kojto 158:b23ee177fd68 1829 __STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1830 {
Kojto 158:b23ee177fd68 1831 CLEAR_BIT(USARTx->CR3, USART_CR3_NACK);
Kojto 158:b23ee177fd68 1832 }
Kojto 158:b23ee177fd68 1833
Kojto 158:b23ee177fd68 1834 /**
Kojto 158:b23ee177fd68 1835 * @brief Indicate if Smartcard NACK transmission is enabled
Kojto 158:b23ee177fd68 1836 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1837 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1838 * @rmtoll CR3 NACK LL_USART_IsEnabledSmartcardNACK
Kojto 158:b23ee177fd68 1839 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1840 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1841 */
Kojto 158:b23ee177fd68 1842 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1843 {
Kojto 158:b23ee177fd68 1844 return (READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK));
Kojto 158:b23ee177fd68 1845 }
Kojto 158:b23ee177fd68 1846
Kojto 158:b23ee177fd68 1847 /**
Kojto 158:b23ee177fd68 1848 * @brief Enable Smartcard mode
Kojto 158:b23ee177fd68 1849 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1850 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1851 * @rmtoll CR3 SCEN LL_USART_EnableSmartcard
Kojto 158:b23ee177fd68 1852 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1853 * @retval None
Kojto 158:b23ee177fd68 1854 */
Kojto 158:b23ee177fd68 1855 __STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1856 {
Kojto 158:b23ee177fd68 1857 SET_BIT(USARTx->CR3, USART_CR3_SCEN);
Kojto 158:b23ee177fd68 1858 }
Kojto 158:b23ee177fd68 1859
Kojto 158:b23ee177fd68 1860 /**
Kojto 158:b23ee177fd68 1861 * @brief Disable Smartcard mode
Kojto 158:b23ee177fd68 1862 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1863 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1864 * @rmtoll CR3 SCEN LL_USART_DisableSmartcard
Kojto 158:b23ee177fd68 1865 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1866 * @retval None
Kojto 158:b23ee177fd68 1867 */
Kojto 158:b23ee177fd68 1868 __STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1869 {
Kojto 158:b23ee177fd68 1870 CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN);
Kojto 158:b23ee177fd68 1871 }
Kojto 158:b23ee177fd68 1872
Kojto 158:b23ee177fd68 1873 /**
Kojto 158:b23ee177fd68 1874 * @brief Indicate if Smartcard mode is enabled
Kojto 158:b23ee177fd68 1875 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1876 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1877 * @rmtoll CR3 SCEN LL_USART_IsEnabledSmartcard
Kojto 158:b23ee177fd68 1878 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1879 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1880 */
Kojto 158:b23ee177fd68 1881 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1882 {
Kojto 158:b23ee177fd68 1883 return (READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN));
Kojto 158:b23ee177fd68 1884 }
Kojto 158:b23ee177fd68 1885
Kojto 158:b23ee177fd68 1886 /**
Kojto 158:b23ee177fd68 1887 * @brief Set Smartcard Auto-Retry Count value (SCARCNT[2:0] bits)
Kojto 158:b23ee177fd68 1888 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1889 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1890 * @note This bit-field specifies the number of retries in transmit and receive, in Smartcard mode.
Kojto 158:b23ee177fd68 1891 * In transmission mode, it specifies the number of automatic retransmission retries, before
Kojto 158:b23ee177fd68 1892 * generating a transmission error (FE bit set).
Kojto 158:b23ee177fd68 1893 * In reception mode, it specifies the number or erroneous reception trials, before generating a
Kojto 158:b23ee177fd68 1894 * reception error (RXNE and PE bits set)
Kojto 158:b23ee177fd68 1895 * @rmtoll CR3 SCARCNT LL_USART_SetSmartcardAutoRetryCount
Kojto 158:b23ee177fd68 1896 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1897 * @param AutoRetryCount Value between Min_Data=0 and Max_Data=7
Kojto 158:b23ee177fd68 1898 * @retval None
Kojto 158:b23ee177fd68 1899 */
Kojto 158:b23ee177fd68 1900 __STATIC_INLINE void LL_USART_SetSmartcardAutoRetryCount(USART_TypeDef *USARTx, uint32_t AutoRetryCount)
Kojto 158:b23ee177fd68 1901 {
Kojto 158:b23ee177fd68 1902 MODIFY_REG(USARTx->CR3, USART_CR3_SCARCNT, AutoRetryCount << USART_POSITION_CR3_SCARCNT);
Kojto 158:b23ee177fd68 1903 }
Kojto 158:b23ee177fd68 1904
Kojto 158:b23ee177fd68 1905 /**
Kojto 158:b23ee177fd68 1906 * @brief Return Smartcard Auto-Retry Count value (SCARCNT[2:0] bits)
Kojto 158:b23ee177fd68 1907 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1908 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1909 * @rmtoll CR3 SCARCNT LL_USART_GetSmartcardAutoRetryCount
Kojto 158:b23ee177fd68 1910 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1911 * @retval Smartcard Auto-Retry Count value (Value between Min_Data=0 and Max_Data=7)
Kojto 158:b23ee177fd68 1912 */
Kojto 158:b23ee177fd68 1913 __STATIC_INLINE uint32_t LL_USART_GetSmartcardAutoRetryCount(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1914 {
Kojto 158:b23ee177fd68 1915 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_SCARCNT) >> USART_POSITION_CR3_SCARCNT);
Kojto 158:b23ee177fd68 1916 }
Kojto 158:b23ee177fd68 1917
Kojto 158:b23ee177fd68 1918 /**
Kojto 158:b23ee177fd68 1919 * @brief Set Smartcard prescaler value, used for dividing the USART clock
Kojto 158:b23ee177fd68 1920 * source to provide the SMARTCARD Clock (5 bits value)
Kojto 158:b23ee177fd68 1921 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1922 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1923 * @rmtoll GTPR PSC LL_USART_SetSmartcardPrescaler
Kojto 158:b23ee177fd68 1924 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1925 * @param PrescalerValue Value between Min_Data=0 and Max_Data=31
Kojto 158:b23ee177fd68 1926 * @retval None
Kojto 158:b23ee177fd68 1927 */
Kojto 158:b23ee177fd68 1928 __STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
Kojto 158:b23ee177fd68 1929 {
Kojto 158:b23ee177fd68 1930 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue);
Kojto 158:b23ee177fd68 1931 }
Kojto 158:b23ee177fd68 1932
Kojto 158:b23ee177fd68 1933 /**
Kojto 158:b23ee177fd68 1934 * @brief Return Smartcard prescaler value, used for dividing the USART clock
Kojto 158:b23ee177fd68 1935 * source to provide the SMARTCARD Clock (5 bits value)
Kojto 158:b23ee177fd68 1936 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1937 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1938 * @rmtoll GTPR PSC LL_USART_GetSmartcardPrescaler
Kojto 158:b23ee177fd68 1939 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1940 * @retval Smartcard prescaler value (Value between Min_Data=0 and Max_Data=31)
Kojto 158:b23ee177fd68 1941 */
Kojto 158:b23ee177fd68 1942 __STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1943 {
Kojto 158:b23ee177fd68 1944 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
Kojto 158:b23ee177fd68 1945 }
Kojto 158:b23ee177fd68 1946
Kojto 158:b23ee177fd68 1947 /**
Kojto 158:b23ee177fd68 1948 * @brief Set Smartcard Guard time value, expressed in nb of baud clocks periods
Kojto 158:b23ee177fd68 1949 * (GT[7:0] bits : Guard time value)
Kojto 158:b23ee177fd68 1950 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1951 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1952 * @rmtoll GTPR GT LL_USART_SetSmartcardGuardTime
Kojto 158:b23ee177fd68 1953 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1954 * @param GuardTime Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 1955 * @retval None
Kojto 158:b23ee177fd68 1956 */
Kojto 158:b23ee177fd68 1957 __STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime)
Kojto 158:b23ee177fd68 1958 {
Kojto 158:b23ee177fd68 1959 MODIFY_REG(USARTx->GTPR, USART_GTPR_GT, GuardTime << USART_POSITION_GTPR_GT);
Kojto 158:b23ee177fd68 1960 }
Kojto 158:b23ee177fd68 1961
Kojto 158:b23ee177fd68 1962 /**
Kojto 158:b23ee177fd68 1963 * @brief Return Smartcard Guard time value, expressed in nb of baud clocks periods
Kojto 158:b23ee177fd68 1964 * (GT[7:0] bits : Guard time value)
Kojto 158:b23ee177fd68 1965 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1966 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1967 * @rmtoll GTPR GT LL_USART_GetSmartcardGuardTime
Kojto 158:b23ee177fd68 1968 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1969 * @retval Smartcard Guard time value (Value between Min_Data=0x00 and Max_Data=0xFF)
Kojto 158:b23ee177fd68 1970 */
Kojto 158:b23ee177fd68 1971 __STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1972 {
Kojto 158:b23ee177fd68 1973 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_POSITION_GTPR_GT);
Kojto 158:b23ee177fd68 1974 }
Kojto 158:b23ee177fd68 1975
Kojto 158:b23ee177fd68 1976 /**
Kojto 158:b23ee177fd68 1977 * @}
Kojto 158:b23ee177fd68 1978 */
Kojto 158:b23ee177fd68 1979
Kojto 158:b23ee177fd68 1980 /** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature
Kojto 158:b23ee177fd68 1981 * @{
Kojto 158:b23ee177fd68 1982 */
Kojto 158:b23ee177fd68 1983
Kojto 158:b23ee177fd68 1984 /**
Kojto 158:b23ee177fd68 1985 * @brief Enable Single Wire Half-Duplex mode
Kojto 158:b23ee177fd68 1986 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 1987 * Half-Duplex mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 1988 * @rmtoll CR3 HDSEL LL_USART_EnableHalfDuplex
Kojto 158:b23ee177fd68 1989 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 1990 * @retval None
Kojto 158:b23ee177fd68 1991 */
Kojto 158:b23ee177fd68 1992 __STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 1993 {
Kojto 158:b23ee177fd68 1994 SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
Kojto 158:b23ee177fd68 1995 }
Kojto 158:b23ee177fd68 1996
Kojto 158:b23ee177fd68 1997 /**
Kojto 158:b23ee177fd68 1998 * @brief Disable Single Wire Half-Duplex mode
Kojto 158:b23ee177fd68 1999 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2000 * Half-Duplex mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2001 * @rmtoll CR3 HDSEL LL_USART_DisableHalfDuplex
Kojto 158:b23ee177fd68 2002 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2003 * @retval None
Kojto 158:b23ee177fd68 2004 */
Kojto 158:b23ee177fd68 2005 __STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2006 {
Kojto 158:b23ee177fd68 2007 CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL);
Kojto 158:b23ee177fd68 2008 }
Kojto 158:b23ee177fd68 2009
Kojto 158:b23ee177fd68 2010 /**
Kojto 158:b23ee177fd68 2011 * @brief Indicate if Single Wire Half-Duplex mode is enabled
Kojto 158:b23ee177fd68 2012 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2013 * Half-Duplex mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2014 * @rmtoll CR3 HDSEL LL_USART_IsEnabledHalfDuplex
Kojto 158:b23ee177fd68 2015 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2016 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2017 */
Kojto 158:b23ee177fd68 2018 __STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2019 {
Kojto 158:b23ee177fd68 2020 return (READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL));
Kojto 158:b23ee177fd68 2021 }
Kojto 158:b23ee177fd68 2022
Kojto 158:b23ee177fd68 2023 /**
Kojto 158:b23ee177fd68 2024 * @}
Kojto 158:b23ee177fd68 2025 */
Kojto 158:b23ee177fd68 2026
Kojto 158:b23ee177fd68 2027 /** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature
Kojto 158:b23ee177fd68 2028 * @{
Kojto 158:b23ee177fd68 2029 */
Kojto 158:b23ee177fd68 2030
Kojto 158:b23ee177fd68 2031 /**
Kojto 158:b23ee177fd68 2032 * @brief Set LIN Break Detection Length
Kojto 158:b23ee177fd68 2033 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2034 * LIN feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2035 * @rmtoll CR2 LBDL LL_USART_SetLINBrkDetectionLen
Kojto 158:b23ee177fd68 2036 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2037 * @param LINBDLength This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2038 * @arg @ref LL_USART_LINBREAK_DETECT_10B
Kojto 158:b23ee177fd68 2039 * @arg @ref LL_USART_LINBREAK_DETECT_11B
Kojto 158:b23ee177fd68 2040 * @retval None
Kojto 158:b23ee177fd68 2041 */
Kojto 158:b23ee177fd68 2042 __STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength)
Kojto 158:b23ee177fd68 2043 {
Kojto 158:b23ee177fd68 2044 MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength);
Kojto 158:b23ee177fd68 2045 }
Kojto 158:b23ee177fd68 2046
Kojto 158:b23ee177fd68 2047 /**
Kojto 158:b23ee177fd68 2048 * @brief Return LIN Break Detection Length
Kojto 158:b23ee177fd68 2049 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2050 * LIN feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2051 * @rmtoll CR2 LBDL LL_USART_GetLINBrkDetectionLen
Kojto 158:b23ee177fd68 2052 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2053 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2054 * @arg @ref LL_USART_LINBREAK_DETECT_10B
Kojto 158:b23ee177fd68 2055 * @arg @ref LL_USART_LINBREAK_DETECT_11B
Kojto 158:b23ee177fd68 2056 */
Kojto 158:b23ee177fd68 2057 __STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2058 {
Kojto 158:b23ee177fd68 2059 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL));
Kojto 158:b23ee177fd68 2060 }
Kojto 158:b23ee177fd68 2061
Kojto 158:b23ee177fd68 2062 /**
Kojto 158:b23ee177fd68 2063 * @brief Enable LIN mode
Kojto 158:b23ee177fd68 2064 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2065 * LIN feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2066 * @rmtoll CR2 LINEN LL_USART_EnableLIN
Kojto 158:b23ee177fd68 2067 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2068 * @retval None
Kojto 158:b23ee177fd68 2069 */
Kojto 158:b23ee177fd68 2070 __STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2071 {
Kojto 158:b23ee177fd68 2072 SET_BIT(USARTx->CR2, USART_CR2_LINEN);
Kojto 158:b23ee177fd68 2073 }
Kojto 158:b23ee177fd68 2074
Kojto 158:b23ee177fd68 2075 /**
Kojto 158:b23ee177fd68 2076 * @brief Disable LIN mode
Kojto 158:b23ee177fd68 2077 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2078 * LIN feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2079 * @rmtoll CR2 LINEN LL_USART_DisableLIN
Kojto 158:b23ee177fd68 2080 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2081 * @retval None
Kojto 158:b23ee177fd68 2082 */
Kojto 158:b23ee177fd68 2083 __STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2084 {
Kojto 158:b23ee177fd68 2085 CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN);
Kojto 158:b23ee177fd68 2086 }
Kojto 158:b23ee177fd68 2087
Kojto 158:b23ee177fd68 2088 /**
Kojto 158:b23ee177fd68 2089 * @brief Indicate if LIN mode is enabled
Kojto 158:b23ee177fd68 2090 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2091 * LIN feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2092 * @rmtoll CR2 LINEN LL_USART_IsEnabledLIN
Kojto 158:b23ee177fd68 2093 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2094 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2095 */
Kojto 158:b23ee177fd68 2096 __STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2097 {
Kojto 158:b23ee177fd68 2098 return (READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN));
Kojto 158:b23ee177fd68 2099 }
Kojto 158:b23ee177fd68 2100
Kojto 158:b23ee177fd68 2101 /**
Kojto 158:b23ee177fd68 2102 * @}
Kojto 158:b23ee177fd68 2103 */
Kojto 158:b23ee177fd68 2104
Kojto 158:b23ee177fd68 2105 /** @defgroup USART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature
Kojto 158:b23ee177fd68 2106 * @{
Kojto 158:b23ee177fd68 2107 */
Kojto 158:b23ee177fd68 2108
Kojto 158:b23ee177fd68 2109 /**
Kojto 158:b23ee177fd68 2110 * @brief Set DEDT (Driver Enable De-Assertion Time), Time value expressed on 5 bits ([4:0] bits).
Kojto 158:b23ee177fd68 2111 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2112 * Driver Enable feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2113 * @rmtoll CR1 DEDT LL_USART_SetDEDeassertionTime
Kojto 158:b23ee177fd68 2114 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2115 * @param Time Value between Min_Data=0 and Max_Data=31
Kojto 158:b23ee177fd68 2116 * @retval None
Kojto 158:b23ee177fd68 2117 */
Kojto 158:b23ee177fd68 2118 __STATIC_INLINE void LL_USART_SetDEDeassertionTime(USART_TypeDef *USARTx, uint32_t Time)
Kojto 158:b23ee177fd68 2119 {
Kojto 158:b23ee177fd68 2120 MODIFY_REG(USARTx->CR1, USART_CR1_DEDT, Time << USART_POSITION_CR1_DEDT);
Kojto 158:b23ee177fd68 2121 }
Kojto 158:b23ee177fd68 2122
Kojto 158:b23ee177fd68 2123 /**
Kojto 158:b23ee177fd68 2124 * @brief Return DEDT (Driver Enable De-Assertion Time)
Kojto 158:b23ee177fd68 2125 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2126 * Driver Enable feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2127 * @rmtoll CR1 DEDT LL_USART_GetDEDeassertionTime
Kojto 158:b23ee177fd68 2128 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2129 * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31
Kojto 158:b23ee177fd68 2130 */
Kojto 158:b23ee177fd68 2131 __STATIC_INLINE uint32_t LL_USART_GetDEDeassertionTime(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2132 {
Kojto 158:b23ee177fd68 2133 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEDT) >> USART_POSITION_CR1_DEDT);
Kojto 158:b23ee177fd68 2134 }
Kojto 158:b23ee177fd68 2135
Kojto 158:b23ee177fd68 2136 /**
Kojto 158:b23ee177fd68 2137 * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits).
Kojto 158:b23ee177fd68 2138 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2139 * Driver Enable feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2140 * @rmtoll CR1 DEAT LL_USART_SetDEAssertionTime
Kojto 158:b23ee177fd68 2141 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2142 * @param Time Value between Min_Data=0 and Max_Data=31
Kojto 158:b23ee177fd68 2143 * @retval None
Kojto 158:b23ee177fd68 2144 */
Kojto 158:b23ee177fd68 2145 __STATIC_INLINE void LL_USART_SetDEAssertionTime(USART_TypeDef *USARTx, uint32_t Time)
Kojto 158:b23ee177fd68 2146 {
Kojto 158:b23ee177fd68 2147 MODIFY_REG(USARTx->CR1, USART_CR1_DEAT, Time << USART_POSITION_CR1_DEAT);
Kojto 158:b23ee177fd68 2148 }
Kojto 158:b23ee177fd68 2149
Kojto 158:b23ee177fd68 2150 /**
Kojto 158:b23ee177fd68 2151 * @brief Return DEAT (Driver Enable Assertion Time)
Kojto 158:b23ee177fd68 2152 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2153 * Driver Enable feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2154 * @rmtoll CR1 DEAT LL_USART_GetDEAssertionTime
Kojto 158:b23ee177fd68 2155 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2156 * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31
Kojto 158:b23ee177fd68 2157 */
Kojto 158:b23ee177fd68 2158 __STATIC_INLINE uint32_t LL_USART_GetDEAssertionTime(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2159 {
Kojto 158:b23ee177fd68 2160 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEAT) >> USART_POSITION_CR1_DEAT);
Kojto 158:b23ee177fd68 2161 }
Kojto 158:b23ee177fd68 2162
Kojto 158:b23ee177fd68 2163 /**
Kojto 158:b23ee177fd68 2164 * @brief Enable Driver Enable (DE) Mode
Kojto 158:b23ee177fd68 2165 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2166 * Driver Enable feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2167 * @rmtoll CR3 DEM LL_USART_EnableDEMode
Kojto 158:b23ee177fd68 2168 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2169 * @retval None
Kojto 158:b23ee177fd68 2170 */
Kojto 158:b23ee177fd68 2171 __STATIC_INLINE void LL_USART_EnableDEMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2172 {
Kojto 158:b23ee177fd68 2173 SET_BIT(USARTx->CR3, USART_CR3_DEM);
Kojto 158:b23ee177fd68 2174 }
Kojto 158:b23ee177fd68 2175
Kojto 158:b23ee177fd68 2176 /**
Kojto 158:b23ee177fd68 2177 * @brief Disable Driver Enable (DE) Mode
Kojto 158:b23ee177fd68 2178 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2179 * Driver Enable feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2180 * @rmtoll CR3 DEM LL_USART_DisableDEMode
Kojto 158:b23ee177fd68 2181 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2182 * @retval None
Kojto 158:b23ee177fd68 2183 */
Kojto 158:b23ee177fd68 2184 __STATIC_INLINE void LL_USART_DisableDEMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2185 {
Kojto 158:b23ee177fd68 2186 CLEAR_BIT(USARTx->CR3, USART_CR3_DEM);
Kojto 158:b23ee177fd68 2187 }
Kojto 158:b23ee177fd68 2188
Kojto 158:b23ee177fd68 2189 /**
Kojto 158:b23ee177fd68 2190 * @brief Indicate if Driver Enable (DE) Mode is enabled
Kojto 158:b23ee177fd68 2191 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2192 * Driver Enable feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2193 * @rmtoll CR3 DEM LL_USART_IsEnabledDEMode
Kojto 158:b23ee177fd68 2194 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2195 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2196 */
Kojto 158:b23ee177fd68 2197 __STATIC_INLINE uint32_t LL_USART_IsEnabledDEMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2198 {
Kojto 158:b23ee177fd68 2199 return (READ_BIT(USARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM));
Kojto 158:b23ee177fd68 2200 }
Kojto 158:b23ee177fd68 2201
Kojto 158:b23ee177fd68 2202 /**
Kojto 158:b23ee177fd68 2203 * @brief Select Driver Enable Polarity
Kojto 158:b23ee177fd68 2204 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2205 * Driver Enable feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2206 * @rmtoll CR3 DEP LL_USART_SetDESignalPolarity
Kojto 158:b23ee177fd68 2207 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2208 * @param Polarity This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2209 * @arg @ref LL_USART_DE_POLARITY_HIGH
Kojto 158:b23ee177fd68 2210 * @arg @ref LL_USART_DE_POLARITY_LOW
Kojto 158:b23ee177fd68 2211 * @retval None
Kojto 158:b23ee177fd68 2212 */
Kojto 158:b23ee177fd68 2213 __STATIC_INLINE void LL_USART_SetDESignalPolarity(USART_TypeDef *USARTx, uint32_t Polarity)
Kojto 158:b23ee177fd68 2214 {
Kojto 158:b23ee177fd68 2215 MODIFY_REG(USARTx->CR3, USART_CR3_DEP, Polarity);
Kojto 158:b23ee177fd68 2216 }
Kojto 158:b23ee177fd68 2217
Kojto 158:b23ee177fd68 2218 /**
Kojto 158:b23ee177fd68 2219 * @brief Return Driver Enable Polarity
Kojto 158:b23ee177fd68 2220 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2221 * Driver Enable feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2222 * @rmtoll CR3 DEP LL_USART_GetDESignalPolarity
Kojto 158:b23ee177fd68 2223 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2224 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2225 * @arg @ref LL_USART_DE_POLARITY_HIGH
Kojto 158:b23ee177fd68 2226 * @arg @ref LL_USART_DE_POLARITY_LOW
Kojto 158:b23ee177fd68 2227 */
Kojto 158:b23ee177fd68 2228 __STATIC_INLINE uint32_t LL_USART_GetDESignalPolarity(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2229 {
Kojto 158:b23ee177fd68 2230 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_DEP));
Kojto 158:b23ee177fd68 2231 }
Kojto 158:b23ee177fd68 2232
Kojto 158:b23ee177fd68 2233 /**
Kojto 158:b23ee177fd68 2234 * @}
Kojto 158:b23ee177fd68 2235 */
Kojto 158:b23ee177fd68 2236
Kojto 158:b23ee177fd68 2237 /** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services
Kojto 158:b23ee177fd68 2238 * @{
Kojto 158:b23ee177fd68 2239 */
Kojto 158:b23ee177fd68 2240
Kojto 158:b23ee177fd68 2241 /**
Kojto 158:b23ee177fd68 2242 * @brief Perform basic configuration of USART for enabling use in Asynchronous Mode (UART)
Kojto 158:b23ee177fd68 2243 * @note In UART mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2244 * - LINEN bit in the USART_CR2 register,
Kojto 158:b23ee177fd68 2245 * - CLKEN bit in the USART_CR2 register,
Kojto 158:b23ee177fd68 2246 * - SCEN bit in the USART_CR3 register,
Kojto 158:b23ee177fd68 2247 * - IREN bit in the USART_CR3 register,
Kojto 158:b23ee177fd68 2248 * - HDSEL bit in the USART_CR3 register.
Kojto 158:b23ee177fd68 2249 * @note Call of this function is equivalent to following function call sequence :
Kojto 158:b23ee177fd68 2250 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
Kojto 158:b23ee177fd68 2251 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
Kojto 158:b23ee177fd68 2252 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
Kojto 158:b23ee177fd68 2253 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
Kojto 158:b23ee177fd68 2254 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
Kojto 158:b23ee177fd68 2255 * @note Other remaining configurations items related to Asynchronous Mode
Kojto 158:b23ee177fd68 2256 * (as Baud Rate, Word length, Parity, ...) should be set using
Kojto 158:b23ee177fd68 2257 * dedicated functions
Kojto 158:b23ee177fd68 2258 * @rmtoll CR2 LINEN LL_USART_ConfigAsyncMode\n
Kojto 158:b23ee177fd68 2259 * CR2 CLKEN LL_USART_ConfigAsyncMode\n
Kojto 158:b23ee177fd68 2260 * CR3 SCEN LL_USART_ConfigAsyncMode\n
Kojto 158:b23ee177fd68 2261 * CR3 IREN LL_USART_ConfigAsyncMode\n
Kojto 158:b23ee177fd68 2262 * CR3 HDSEL LL_USART_ConfigAsyncMode
Kojto 158:b23ee177fd68 2263 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2264 * @retval None
Kojto 158:b23ee177fd68 2265 */
Kojto 158:b23ee177fd68 2266 __STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2267 {
Kojto 158:b23ee177fd68 2268 /* In Asynchronous mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2269 - LINEN, CLKEN bits in the USART_CR2 register,
Kojto 158:b23ee177fd68 2270 - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/
Kojto 158:b23ee177fd68 2271 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
Kojto 158:b23ee177fd68 2272 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
Kojto 158:b23ee177fd68 2273 }
Kojto 158:b23ee177fd68 2274
Kojto 158:b23ee177fd68 2275 /**
Kojto 158:b23ee177fd68 2276 * @brief Perform basic configuration of USART for enabling use in Synchronous Mode
Kojto 158:b23ee177fd68 2277 * @note In Synchronous mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2278 * - LINEN bit in the USART_CR2 register,
Kojto 158:b23ee177fd68 2279 * - SCEN bit in the USART_CR3 register,
Kojto 158:b23ee177fd68 2280 * - IREN bit in the USART_CR3 register,
Kojto 158:b23ee177fd68 2281 * - HDSEL bit in the USART_CR3 register.
Kojto 158:b23ee177fd68 2282 * This function also sets the USART in Synchronous mode.
Kojto 158:b23ee177fd68 2283 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2284 * Synchronous mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2285 * @note Call of this function is equivalent to following function call sequence :
Kojto 158:b23ee177fd68 2286 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
Kojto 158:b23ee177fd68 2287 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
Kojto 158:b23ee177fd68 2288 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
Kojto 158:b23ee177fd68 2289 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
Kojto 158:b23ee177fd68 2290 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
Kojto 158:b23ee177fd68 2291 * @note Other remaining configurations items related to Synchronous Mode
Kojto 158:b23ee177fd68 2292 * (as Baud Rate, Word length, Parity, Clock Polarity, ...) should be set using
Kojto 158:b23ee177fd68 2293 * dedicated functions
Kojto 158:b23ee177fd68 2294 * @rmtoll CR2 LINEN LL_USART_ConfigSyncMode\n
Kojto 158:b23ee177fd68 2295 * CR2 CLKEN LL_USART_ConfigSyncMode\n
Kojto 158:b23ee177fd68 2296 * CR3 SCEN LL_USART_ConfigSyncMode\n
Kojto 158:b23ee177fd68 2297 * CR3 IREN LL_USART_ConfigSyncMode\n
Kojto 158:b23ee177fd68 2298 * CR3 HDSEL LL_USART_ConfigSyncMode
Kojto 158:b23ee177fd68 2299 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2300 * @retval None
Kojto 158:b23ee177fd68 2301 */
Kojto 158:b23ee177fd68 2302 __STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2303 {
Kojto 158:b23ee177fd68 2304 /* In Synchronous mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2305 - LINEN bit in the USART_CR2 register,
Kojto 158:b23ee177fd68 2306 - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/
Kojto 158:b23ee177fd68 2307 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
Kojto 158:b23ee177fd68 2308 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
Kojto 158:b23ee177fd68 2309 /* set the UART/USART in Synchronous mode */
Kojto 158:b23ee177fd68 2310 SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
Kojto 158:b23ee177fd68 2311 }
Kojto 158:b23ee177fd68 2312
Kojto 158:b23ee177fd68 2313 /**
Kojto 158:b23ee177fd68 2314 * @brief Perform basic configuration of USART for enabling use in LIN Mode
Kojto 158:b23ee177fd68 2315 * @note In LIN mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2316 * - STOP and CLKEN bits in the USART_CR2 register,
Kojto 158:b23ee177fd68 2317 * - SCEN bit in the USART_CR3 register,
Kojto 158:b23ee177fd68 2318 * - IREN bit in the USART_CR3 register,
Kojto 158:b23ee177fd68 2319 * - HDSEL bit in the USART_CR3 register.
Kojto 158:b23ee177fd68 2320 * This function also set the UART/USART in LIN mode.
Kojto 158:b23ee177fd68 2321 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2322 * LIN feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2323 * @note Call of this function is equivalent to following function call sequence :
Kojto 158:b23ee177fd68 2324 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
Kojto 158:b23ee177fd68 2325 * - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
Kojto 158:b23ee177fd68 2326 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
Kojto 158:b23ee177fd68 2327 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
Kojto 158:b23ee177fd68 2328 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
Kojto 158:b23ee177fd68 2329 * - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function
Kojto 158:b23ee177fd68 2330 * @note Other remaining configurations items related to LIN Mode
Kojto 158:b23ee177fd68 2331 * (as Baud Rate, Word length, LIN Break Detection Length, ...) should be set using
Kojto 158:b23ee177fd68 2332 * dedicated functions
Kojto 158:b23ee177fd68 2333 * @rmtoll CR2 CLKEN LL_USART_ConfigLINMode\n
Kojto 158:b23ee177fd68 2334 * CR2 STOP LL_USART_ConfigLINMode\n
Kojto 158:b23ee177fd68 2335 * CR2 LINEN LL_USART_ConfigLINMode\n
Kojto 158:b23ee177fd68 2336 * CR3 IREN LL_USART_ConfigLINMode\n
Kojto 158:b23ee177fd68 2337 * CR3 SCEN LL_USART_ConfigLINMode\n
Kojto 158:b23ee177fd68 2338 * CR3 HDSEL LL_USART_ConfigLINMode
Kojto 158:b23ee177fd68 2339 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2340 * @retval None
Kojto 158:b23ee177fd68 2341 */
Kojto 158:b23ee177fd68 2342 __STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2343 {
Kojto 158:b23ee177fd68 2344 /* In LIN mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2345 - STOP and CLKEN bits in the USART_CR2 register,
Kojto 158:b23ee177fd68 2346 - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/
Kojto 158:b23ee177fd68 2347 CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP));
Kojto 158:b23ee177fd68 2348 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL));
Kojto 158:b23ee177fd68 2349 /* Set the UART/USART in LIN mode */
Kojto 158:b23ee177fd68 2350 SET_BIT(USARTx->CR2, USART_CR2_LINEN);
Kojto 158:b23ee177fd68 2351 }
Kojto 158:b23ee177fd68 2352
Kojto 158:b23ee177fd68 2353 /**
Kojto 158:b23ee177fd68 2354 * @brief Perform basic configuration of USART for enabling use in Half Duplex Mode
Kojto 158:b23ee177fd68 2355 * @note In Half Duplex mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2356 * - LINEN bit in the USART_CR2 register,
Kojto 158:b23ee177fd68 2357 * - CLKEN bit in the USART_CR2 register,
Kojto 158:b23ee177fd68 2358 * - SCEN bit in the USART_CR3 register,
Kojto 158:b23ee177fd68 2359 * - IREN bit in the USART_CR3 register,
Kojto 158:b23ee177fd68 2360 * This function also sets the UART/USART in Half Duplex mode.
Kojto 158:b23ee177fd68 2361 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2362 * Half-Duplex mode is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2363 * @note Call of this function is equivalent to following function call sequence :
Kojto 158:b23ee177fd68 2364 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
Kojto 158:b23ee177fd68 2365 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
Kojto 158:b23ee177fd68 2366 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
Kojto 158:b23ee177fd68 2367 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
Kojto 158:b23ee177fd68 2368 * - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function
Kojto 158:b23ee177fd68 2369 * @note Other remaining configurations items related to Half Duplex Mode
Kojto 158:b23ee177fd68 2370 * (as Baud Rate, Word length, Parity, ...) should be set using
Kojto 158:b23ee177fd68 2371 * dedicated functions
Kojto 158:b23ee177fd68 2372 * @rmtoll CR2 LINEN LL_USART_ConfigHalfDuplexMode\n
Kojto 158:b23ee177fd68 2373 * CR2 CLKEN LL_USART_ConfigHalfDuplexMode\n
Kojto 158:b23ee177fd68 2374 * CR3 HDSEL LL_USART_ConfigHalfDuplexMode\n
Kojto 158:b23ee177fd68 2375 * CR3 SCEN LL_USART_ConfigHalfDuplexMode\n
Kojto 158:b23ee177fd68 2376 * CR3 IREN LL_USART_ConfigHalfDuplexMode
Kojto 158:b23ee177fd68 2377 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2378 * @retval None
Kojto 158:b23ee177fd68 2379 */
Kojto 158:b23ee177fd68 2380 __STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2381 {
Kojto 158:b23ee177fd68 2382 /* In Half Duplex mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2383 - LINEN and CLKEN bits in the USART_CR2 register,
Kojto 158:b23ee177fd68 2384 - SCEN and IREN bits in the USART_CR3 register.*/
Kojto 158:b23ee177fd68 2385 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
Kojto 158:b23ee177fd68 2386 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN));
Kojto 158:b23ee177fd68 2387 /* set the UART/USART in Half Duplex mode */
Kojto 158:b23ee177fd68 2388 SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
Kojto 158:b23ee177fd68 2389 }
Kojto 158:b23ee177fd68 2390
Kojto 158:b23ee177fd68 2391 /**
Kojto 158:b23ee177fd68 2392 * @brief Perform basic configuration of USART for enabling use in Smartcard Mode
Kojto 158:b23ee177fd68 2393 * @note In Smartcard mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2394 * - LINEN bit in the USART_CR2 register,
Kojto 158:b23ee177fd68 2395 * - IREN bit in the USART_CR3 register,
Kojto 158:b23ee177fd68 2396 * - HDSEL bit in the USART_CR3 register.
Kojto 158:b23ee177fd68 2397 * This function also configures Stop bits to 1.5 bits and
Kojto 158:b23ee177fd68 2398 * sets the USART in Smartcard mode (SCEN bit).
Kojto 158:b23ee177fd68 2399 * Clock Output is also enabled (CLKEN).
Kojto 158:b23ee177fd68 2400 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2401 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2402 * @note Call of this function is equivalent to following function call sequence :
Kojto 158:b23ee177fd68 2403 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
Kojto 158:b23ee177fd68 2404 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
Kojto 158:b23ee177fd68 2405 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
Kojto 158:b23ee177fd68 2406 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
Kojto 158:b23ee177fd68 2407 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
Kojto 158:b23ee177fd68 2408 * - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function
Kojto 158:b23ee177fd68 2409 * @note Other remaining configurations items related to Smartcard Mode
Kojto 158:b23ee177fd68 2410 * (as Baud Rate, Word length, Parity, ...) should be set using
Kojto 158:b23ee177fd68 2411 * dedicated functions
Kojto 158:b23ee177fd68 2412 * @rmtoll CR2 LINEN LL_USART_ConfigSmartcardMode\n
Kojto 158:b23ee177fd68 2413 * CR2 STOP LL_USART_ConfigSmartcardMode\n
Kojto 158:b23ee177fd68 2414 * CR2 CLKEN LL_USART_ConfigSmartcardMode\n
Kojto 158:b23ee177fd68 2415 * CR3 HDSEL LL_USART_ConfigSmartcardMode\n
Kojto 158:b23ee177fd68 2416 * CR3 SCEN LL_USART_ConfigSmartcardMode
Kojto 158:b23ee177fd68 2417 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2418 * @retval None
Kojto 158:b23ee177fd68 2419 */
Kojto 158:b23ee177fd68 2420 __STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2421 {
Kojto 158:b23ee177fd68 2422 /* In Smartcard mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2423 - LINEN bit in the USART_CR2 register,
Kojto 158:b23ee177fd68 2424 - IREN and HDSEL bits in the USART_CR3 register.*/
Kojto 158:b23ee177fd68 2425 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
Kojto 158:b23ee177fd68 2426 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL));
Kojto 158:b23ee177fd68 2427 /* Configure Stop bits to 1.5 bits */
Kojto 158:b23ee177fd68 2428 /* Synchronous mode is activated by default */
Kojto 158:b23ee177fd68 2429 SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN));
Kojto 158:b23ee177fd68 2430 /* set the UART/USART in Smartcard mode */
Kojto 158:b23ee177fd68 2431 SET_BIT(USARTx->CR3, USART_CR3_SCEN);
Kojto 158:b23ee177fd68 2432 }
Kojto 158:b23ee177fd68 2433
Kojto 158:b23ee177fd68 2434 /**
Kojto 158:b23ee177fd68 2435 * @brief Perform basic configuration of USART for enabling use in Irda Mode
Kojto 158:b23ee177fd68 2436 * @note In IRDA mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2437 * - LINEN bit in the USART_CR2 register,
Kojto 158:b23ee177fd68 2438 * - STOP and CLKEN bits in the USART_CR2 register,
Kojto 158:b23ee177fd68 2439 * - SCEN bit in the USART_CR3 register,
Kojto 158:b23ee177fd68 2440 * - HDSEL bit in the USART_CR3 register.
Kojto 158:b23ee177fd68 2441 * This function also sets the UART/USART in IRDA mode (IREN bit).
Kojto 158:b23ee177fd68 2442 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2443 * IrDA feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2444 * @note Call of this function is equivalent to following function call sequence :
Kojto 158:b23ee177fd68 2445 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
Kojto 158:b23ee177fd68 2446 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
Kojto 158:b23ee177fd68 2447 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
Kojto 158:b23ee177fd68 2448 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
Kojto 158:b23ee177fd68 2449 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
Kojto 158:b23ee177fd68 2450 * - Set IREN in CR3 using @ref LL_USART_EnableIrda() function
Kojto 158:b23ee177fd68 2451 * @note Other remaining configurations items related to Irda Mode
Kojto 158:b23ee177fd68 2452 * (as Baud Rate, Word length, Power mode, ...) should be set using
Kojto 158:b23ee177fd68 2453 * dedicated functions
Kojto 158:b23ee177fd68 2454 * @rmtoll CR2 LINEN LL_USART_ConfigIrdaMode\n
Kojto 158:b23ee177fd68 2455 * CR2 CLKEN LL_USART_ConfigIrdaMode\n
Kojto 158:b23ee177fd68 2456 * CR2 STOP LL_USART_ConfigIrdaMode\n
Kojto 158:b23ee177fd68 2457 * CR3 SCEN LL_USART_ConfigIrdaMode\n
Kojto 158:b23ee177fd68 2458 * CR3 HDSEL LL_USART_ConfigIrdaMode\n
Kojto 158:b23ee177fd68 2459 * CR3 IREN LL_USART_ConfigIrdaMode
Kojto 158:b23ee177fd68 2460 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2461 * @retval None
Kojto 158:b23ee177fd68 2462 */
Kojto 158:b23ee177fd68 2463 __STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2464 {
Kojto 158:b23ee177fd68 2465 /* In IRDA mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2466 - LINEN, STOP and CLKEN bits in the USART_CR2 register,
Kojto 158:b23ee177fd68 2467 - SCEN and HDSEL bits in the USART_CR3 register.*/
Kojto 158:b23ee177fd68 2468 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP));
Kojto 158:b23ee177fd68 2469 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
Kojto 158:b23ee177fd68 2470 /* set the UART/USART in IRDA mode */
Kojto 158:b23ee177fd68 2471 SET_BIT(USARTx->CR3, USART_CR3_IREN);
Kojto 158:b23ee177fd68 2472 }
Kojto 158:b23ee177fd68 2473
Kojto 158:b23ee177fd68 2474 /**
Kojto 158:b23ee177fd68 2475 * @brief Perform basic configuration of USART for enabling use in Multi processor Mode
Kojto 158:b23ee177fd68 2476 * (several USARTs connected in a network, one of the USARTs can be the master,
Kojto 158:b23ee177fd68 2477 * its TX output connected to the RX inputs of the other slaves USARTs).
Kojto 158:b23ee177fd68 2478 * @note In MultiProcessor mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2479 * - LINEN bit in the USART_CR2 register,
Kojto 158:b23ee177fd68 2480 * - CLKEN bit in the USART_CR2 register,
Kojto 158:b23ee177fd68 2481 * - SCEN bit in the USART_CR3 register,
Kojto 158:b23ee177fd68 2482 * - IREN bit in the USART_CR3 register,
Kojto 158:b23ee177fd68 2483 * - HDSEL bit in the USART_CR3 register.
Kojto 158:b23ee177fd68 2484 * @note Call of this function is equivalent to following function call sequence :
Kojto 158:b23ee177fd68 2485 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
Kojto 158:b23ee177fd68 2486 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
Kojto 158:b23ee177fd68 2487 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
Kojto 158:b23ee177fd68 2488 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
Kojto 158:b23ee177fd68 2489 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
Kojto 158:b23ee177fd68 2490 * @note Other remaining configurations items related to Multi processor Mode
Kojto 158:b23ee177fd68 2491 * (as Baud Rate, Wake Up Method, Node address, ...) should be set using
Kojto 158:b23ee177fd68 2492 * dedicated functions
Kojto 158:b23ee177fd68 2493 * @rmtoll CR2 LINEN LL_USART_ConfigMultiProcessMode\n
Kojto 158:b23ee177fd68 2494 * CR2 CLKEN LL_USART_ConfigMultiProcessMode\n
Kojto 158:b23ee177fd68 2495 * CR3 SCEN LL_USART_ConfigMultiProcessMode\n
Kojto 158:b23ee177fd68 2496 * CR3 HDSEL LL_USART_ConfigMultiProcessMode\n
Kojto 158:b23ee177fd68 2497 * CR3 IREN LL_USART_ConfigMultiProcessMode
Kojto 158:b23ee177fd68 2498 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2499 * @retval None
Kojto 158:b23ee177fd68 2500 */
Kojto 158:b23ee177fd68 2501 __STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2502 {
Kojto 158:b23ee177fd68 2503 /* In Multi Processor mode, the following bits must be kept cleared:
Kojto 158:b23ee177fd68 2504 - LINEN and CLKEN bits in the USART_CR2 register,
Kojto 158:b23ee177fd68 2505 - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/
Kojto 158:b23ee177fd68 2506 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
Kojto 158:b23ee177fd68 2507 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN));
Kojto 158:b23ee177fd68 2508 }
Kojto 158:b23ee177fd68 2509
Kojto 158:b23ee177fd68 2510 /**
Kojto 158:b23ee177fd68 2511 * @}
Kojto 158:b23ee177fd68 2512 */
Kojto 158:b23ee177fd68 2513
Kojto 158:b23ee177fd68 2514 /** @defgroup USART_LL_EF_FLAG_Management FLAG_Management
Kojto 158:b23ee177fd68 2515 * @{
Kojto 158:b23ee177fd68 2516 */
Kojto 158:b23ee177fd68 2517
Kojto 158:b23ee177fd68 2518 /**
Kojto 158:b23ee177fd68 2519 * @brief Check if the USART Parity Error Flag is set or not
Kojto 158:b23ee177fd68 2520 * @rmtoll ISR PE LL_USART_IsActiveFlag_PE
Kojto 158:b23ee177fd68 2521 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2522 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2523 */
Kojto 158:b23ee177fd68 2524 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2525 {
Kojto 158:b23ee177fd68 2526 return (READ_BIT(USARTx->ISR, USART_ISR_PE) == (USART_ISR_PE));
Kojto 158:b23ee177fd68 2527 }
Kojto 158:b23ee177fd68 2528
Kojto 158:b23ee177fd68 2529 /**
Kojto 158:b23ee177fd68 2530 * @brief Check if the USART Framing Error Flag is set or not
Kojto 158:b23ee177fd68 2531 * @rmtoll ISR FE LL_USART_IsActiveFlag_FE
Kojto 158:b23ee177fd68 2532 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2533 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2534 */
Kojto 158:b23ee177fd68 2535 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2536 {
Kojto 158:b23ee177fd68 2537 return (READ_BIT(USARTx->ISR, USART_ISR_FE) == (USART_ISR_FE));
Kojto 158:b23ee177fd68 2538 }
Kojto 158:b23ee177fd68 2539
Kojto 158:b23ee177fd68 2540 /**
Kojto 158:b23ee177fd68 2541 * @brief Check if the USART Noise error detected Flag is set or not
Kojto 158:b23ee177fd68 2542 * @rmtoll ISR NF LL_USART_IsActiveFlag_NE
Kojto 158:b23ee177fd68 2543 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2544 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2545 */
Kojto 158:b23ee177fd68 2546 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2547 {
Kojto 158:b23ee177fd68 2548 return (READ_BIT(USARTx->ISR, USART_ISR_NE) == (USART_ISR_NE));
Kojto 158:b23ee177fd68 2549 }
Kojto 158:b23ee177fd68 2550
Kojto 158:b23ee177fd68 2551 /**
Kojto 158:b23ee177fd68 2552 * @brief Check if the USART OverRun Error Flag is set or not
Kojto 158:b23ee177fd68 2553 * @rmtoll ISR ORE LL_USART_IsActiveFlag_ORE
Kojto 158:b23ee177fd68 2554 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2555 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2556 */
Kojto 158:b23ee177fd68 2557 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2558 {
Kojto 158:b23ee177fd68 2559 return (READ_BIT(USARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE));
Kojto 158:b23ee177fd68 2560 }
Kojto 158:b23ee177fd68 2561
Kojto 158:b23ee177fd68 2562 /**
Kojto 158:b23ee177fd68 2563 * @brief Check if the USART IDLE line detected Flag is set or not
Kojto 158:b23ee177fd68 2564 * @rmtoll ISR IDLE LL_USART_IsActiveFlag_IDLE
Kojto 158:b23ee177fd68 2565 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2566 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2567 */
Kojto 158:b23ee177fd68 2568 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2569 {
Kojto 158:b23ee177fd68 2570 return (READ_BIT(USARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE));
Kojto 158:b23ee177fd68 2571 }
Kojto 158:b23ee177fd68 2572
Kojto 158:b23ee177fd68 2573 /**
Kojto 158:b23ee177fd68 2574 * @brief Check if the USART Read Data Register Not Empty Flag is set or not
Kojto 158:b23ee177fd68 2575 * @rmtoll ISR RXNE LL_USART_IsActiveFlag_RXNE
Kojto 158:b23ee177fd68 2576 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2577 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2578 */
Kojto 158:b23ee177fd68 2579 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2580 {
Kojto 158:b23ee177fd68 2581 return (READ_BIT(USARTx->ISR, USART_ISR_RXNE) == (USART_ISR_RXNE));
Kojto 158:b23ee177fd68 2582 }
Kojto 158:b23ee177fd68 2583
Kojto 158:b23ee177fd68 2584 /**
Kojto 158:b23ee177fd68 2585 * @brief Check if the USART Transmission Complete Flag is set or not
Kojto 158:b23ee177fd68 2586 * @rmtoll ISR TC LL_USART_IsActiveFlag_TC
Kojto 158:b23ee177fd68 2587 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2588 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2589 */
Kojto 158:b23ee177fd68 2590 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2591 {
Kojto 158:b23ee177fd68 2592 return (READ_BIT(USARTx->ISR, USART_ISR_TC) == (USART_ISR_TC));
Kojto 158:b23ee177fd68 2593 }
Kojto 158:b23ee177fd68 2594
Kojto 158:b23ee177fd68 2595 /**
Kojto 158:b23ee177fd68 2596 * @brief Check if the USART Transmit Data Register Empty Flag is set or not
Kojto 158:b23ee177fd68 2597 * @rmtoll ISR TXE LL_USART_IsActiveFlag_TXE
Kojto 158:b23ee177fd68 2598 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2599 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2600 */
Kojto 158:b23ee177fd68 2601 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2602 {
Kojto 158:b23ee177fd68 2603 return (READ_BIT(USARTx->ISR, USART_ISR_TXE) == (USART_ISR_TXE));
Kojto 158:b23ee177fd68 2604 }
Kojto 158:b23ee177fd68 2605
Kojto 158:b23ee177fd68 2606 /**
Kojto 158:b23ee177fd68 2607 * @brief Check if the USART LIN Break Detection Flag is set or not
Kojto 158:b23ee177fd68 2608 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2609 * LIN feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2610 * @rmtoll ISR LBDF LL_USART_IsActiveFlag_LBD
Kojto 158:b23ee177fd68 2611 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2612 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2613 */
Kojto 158:b23ee177fd68 2614 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2615 {
Kojto 158:b23ee177fd68 2616 return (READ_BIT(USARTx->ISR, USART_ISR_LBDF) == (USART_ISR_LBDF));
Kojto 158:b23ee177fd68 2617 }
Kojto 158:b23ee177fd68 2618
Kojto 158:b23ee177fd68 2619 /**
Kojto 158:b23ee177fd68 2620 * @brief Check if the USART CTS interrupt Flag is set or not
Kojto 158:b23ee177fd68 2621 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2622 * Hardware Flow control feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2623 * @rmtoll ISR CTSIF LL_USART_IsActiveFlag_nCTS
Kojto 158:b23ee177fd68 2624 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2625 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2626 */
Kojto 158:b23ee177fd68 2627 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2628 {
Kojto 158:b23ee177fd68 2629 return (READ_BIT(USARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF));
Kojto 158:b23ee177fd68 2630 }
Kojto 158:b23ee177fd68 2631
Kojto 158:b23ee177fd68 2632 /**
Kojto 158:b23ee177fd68 2633 * @brief Check if the USART CTS Flag is set or not
Kojto 158:b23ee177fd68 2634 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2635 * Hardware Flow control feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2636 * @rmtoll ISR CTS LL_USART_IsActiveFlag_CTS
Kojto 158:b23ee177fd68 2637 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2638 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2639 */
Kojto 158:b23ee177fd68 2640 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CTS(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2641 {
Kojto 158:b23ee177fd68 2642 return (READ_BIT(USARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS));
Kojto 158:b23ee177fd68 2643 }
Kojto 158:b23ee177fd68 2644
Kojto 158:b23ee177fd68 2645 /**
Kojto 158:b23ee177fd68 2646 * @brief Check if the USART Receiver Time Out Flag is set or not
Kojto 158:b23ee177fd68 2647 * @rmtoll ISR RTOF LL_USART_IsActiveFlag_RTO
Kojto 158:b23ee177fd68 2648 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2649 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2650 */
Kojto 158:b23ee177fd68 2651 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RTO(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2652 {
Kojto 158:b23ee177fd68 2653 return (READ_BIT(USARTx->ISR, USART_ISR_RTOF) == (USART_ISR_RTOF));
Kojto 158:b23ee177fd68 2654 }
Kojto 158:b23ee177fd68 2655
Kojto 158:b23ee177fd68 2656 /**
Kojto 158:b23ee177fd68 2657 * @brief Check if the USART End Of Block Flag is set or not
Kojto 158:b23ee177fd68 2658 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2659 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2660 * @rmtoll ISR EOBF LL_USART_IsActiveFlag_EOB
Kojto 158:b23ee177fd68 2661 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2662 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2663 */
Kojto 158:b23ee177fd68 2664 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_EOB(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2665 {
Kojto 158:b23ee177fd68 2666 return (READ_BIT(USARTx->ISR, USART_ISR_EOBF) == (USART_ISR_EOBF));
Kojto 158:b23ee177fd68 2667 }
Kojto 158:b23ee177fd68 2668
Kojto 158:b23ee177fd68 2669 /**
Kojto 158:b23ee177fd68 2670 * @brief Check if the USART Auto-Baud Rate Error Flag is set or not
Kojto 158:b23ee177fd68 2671 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2672 * Auto Baud Rate detection feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2673 * @rmtoll ISR ABRE LL_USART_IsActiveFlag_ABRE
Kojto 158:b23ee177fd68 2674 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2675 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2676 */
Kojto 158:b23ee177fd68 2677 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABRE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2678 {
Kojto 158:b23ee177fd68 2679 return (READ_BIT(USARTx->ISR, USART_ISR_ABRE) == (USART_ISR_ABRE));
Kojto 158:b23ee177fd68 2680 }
Kojto 158:b23ee177fd68 2681
Kojto 158:b23ee177fd68 2682 /**
Kojto 158:b23ee177fd68 2683 * @brief Check if the USART Auto-Baud Rate Flag is set or not
Kojto 158:b23ee177fd68 2684 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2685 * Auto Baud Rate detection feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2686 * @rmtoll ISR ABRF LL_USART_IsActiveFlag_ABR
Kojto 158:b23ee177fd68 2687 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2688 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2689 */
Kojto 158:b23ee177fd68 2690 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABR(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2691 {
Kojto 158:b23ee177fd68 2692 return (READ_BIT(USARTx->ISR, USART_ISR_ABRF) == (USART_ISR_ABRF));
Kojto 158:b23ee177fd68 2693 }
Kojto 158:b23ee177fd68 2694
Kojto 158:b23ee177fd68 2695 /**
Kojto 158:b23ee177fd68 2696 * @brief Check if the USART Busy Flag is set or not
Kojto 158:b23ee177fd68 2697 * @rmtoll ISR BUSY LL_USART_IsActiveFlag_BUSY
Kojto 158:b23ee177fd68 2698 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2699 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2700 */
Kojto 158:b23ee177fd68 2701 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_BUSY(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2702 {
Kojto 158:b23ee177fd68 2703 return (READ_BIT(USARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY));
Kojto 158:b23ee177fd68 2704 }
Kojto 158:b23ee177fd68 2705
Kojto 158:b23ee177fd68 2706 /**
Kojto 158:b23ee177fd68 2707 * @brief Check if the USART Character Match Flag is set or not
Kojto 158:b23ee177fd68 2708 * @rmtoll ISR CMF LL_USART_IsActiveFlag_CM
Kojto 158:b23ee177fd68 2709 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2710 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2711 */
Kojto 158:b23ee177fd68 2712 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CM(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2713 {
Kojto 158:b23ee177fd68 2714 return (READ_BIT(USARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF));
Kojto 158:b23ee177fd68 2715 }
Kojto 158:b23ee177fd68 2716
Kojto 158:b23ee177fd68 2717 /**
Kojto 158:b23ee177fd68 2718 * @brief Check if the USART Send Break Flag is set or not
Kojto 158:b23ee177fd68 2719 * @rmtoll ISR SBKF LL_USART_IsActiveFlag_SBK
Kojto 158:b23ee177fd68 2720 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2721 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2722 */
Kojto 158:b23ee177fd68 2723 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2724 {
Kojto 158:b23ee177fd68 2725 return (READ_BIT(USARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF));
Kojto 158:b23ee177fd68 2726 }
Kojto 158:b23ee177fd68 2727
Kojto 158:b23ee177fd68 2728 /**
Kojto 158:b23ee177fd68 2729 * @brief Check if the USART Receive Wake Up from mute mode Flag is set or not
Kojto 158:b23ee177fd68 2730 * @rmtoll ISR RWU LL_USART_IsActiveFlag_RWU
Kojto 158:b23ee177fd68 2731 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2732 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2733 */
Kojto 158:b23ee177fd68 2734 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2735 {
Kojto 158:b23ee177fd68 2736 return (READ_BIT(USARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU));
Kojto 158:b23ee177fd68 2737 }
Kojto 158:b23ee177fd68 2738
Kojto 158:b23ee177fd68 2739 /**
Kojto 158:b23ee177fd68 2740 * @brief Check if the USART Wake Up from stop mode Flag is set or not
Kojto 158:b23ee177fd68 2741 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2742 * Wake-up from Stop mode feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2743 * @rmtoll ISR WUF LL_USART_IsActiveFlag_WKUP
Kojto 158:b23ee177fd68 2744 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2745 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2746 */
Kojto 158:b23ee177fd68 2747 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_WKUP(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2748 {
Kojto 158:b23ee177fd68 2749 return (READ_BIT(USARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF));
Kojto 158:b23ee177fd68 2750 }
Kojto 158:b23ee177fd68 2751
Kojto 158:b23ee177fd68 2752 /**
Kojto 158:b23ee177fd68 2753 * @brief Check if the USART Transmit Enable Acknowledge Flag is set or not
Kojto 158:b23ee177fd68 2754 * @rmtoll ISR TEACK LL_USART_IsActiveFlag_TEACK
Kojto 158:b23ee177fd68 2755 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2756 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2757 */
Kojto 158:b23ee177fd68 2758 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TEACK(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2759 {
Kojto 158:b23ee177fd68 2760 return (READ_BIT(USARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK));
Kojto 158:b23ee177fd68 2761 }
Kojto 158:b23ee177fd68 2762
Kojto 158:b23ee177fd68 2763 /**
Kojto 158:b23ee177fd68 2764 * @brief Check if the USART Receive Enable Acknowledge Flag is set or not
Kojto 158:b23ee177fd68 2765 * @rmtoll ISR REACK LL_USART_IsActiveFlag_REACK
Kojto 158:b23ee177fd68 2766 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2767 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2768 */
Kojto 158:b23ee177fd68 2769 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_REACK(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2770 {
Kojto 158:b23ee177fd68 2771 return (READ_BIT(USARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK));
Kojto 158:b23ee177fd68 2772 }
Kojto 158:b23ee177fd68 2773
Kojto 158:b23ee177fd68 2774 #if defined(USART_TCBGT_SUPPORT)
Kojto 158:b23ee177fd68 2775 /* Function available only on devices supporting Transmit Complete before Guard Time feature */
Kojto 158:b23ee177fd68 2776 /**
Kojto 158:b23ee177fd68 2777 * @brief Check if the Smartcard Transmission Complete Before Guard Time Flag is set or not
Kojto 158:b23ee177fd68 2778 * @rmtoll ISR TCBGT LL_USART_IsActiveFlag_TCBGT
Kojto 158:b23ee177fd68 2779 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2780 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2781 */
Kojto 158:b23ee177fd68 2782 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TCBGT(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2783 {
Kojto 158:b23ee177fd68 2784 return (READ_BIT(USARTx->ISR, USART_ISR_TCBGT) == (USART_ISR_TCBGT));
Kojto 158:b23ee177fd68 2785 }
Kojto 158:b23ee177fd68 2786 #endif
Kojto 158:b23ee177fd68 2787
Kojto 158:b23ee177fd68 2788 /**
Kojto 158:b23ee177fd68 2789 * @brief Clear Parity Error Flag
Kojto 158:b23ee177fd68 2790 * @rmtoll ICR PECF LL_USART_ClearFlag_PE
Kojto 158:b23ee177fd68 2791 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2792 * @retval None
Kojto 158:b23ee177fd68 2793 */
Kojto 158:b23ee177fd68 2794 __STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2795 {
Kojto 158:b23ee177fd68 2796 WRITE_REG(USARTx->ICR, USART_ICR_PECF);
Kojto 158:b23ee177fd68 2797 }
Kojto 158:b23ee177fd68 2798
Kojto 158:b23ee177fd68 2799 /**
Kojto 158:b23ee177fd68 2800 * @brief Clear Framing Error Flag
Kojto 158:b23ee177fd68 2801 * @rmtoll ICR FECF LL_USART_ClearFlag_FE
Kojto 158:b23ee177fd68 2802 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2803 * @retval None
Kojto 158:b23ee177fd68 2804 */
Kojto 158:b23ee177fd68 2805 __STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2806 {
Kojto 158:b23ee177fd68 2807 WRITE_REG(USARTx->ICR, USART_ICR_FECF);
Kojto 158:b23ee177fd68 2808 }
Kojto 158:b23ee177fd68 2809
Kojto 158:b23ee177fd68 2810 /**
Kojto 158:b23ee177fd68 2811 * @brief Clear Noise detected Flag
Kojto 158:b23ee177fd68 2812 * @rmtoll ICR NCF LL_USART_ClearFlag_NE
Kojto 158:b23ee177fd68 2813 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2814 * @retval None
Kojto 158:b23ee177fd68 2815 */
Kojto 158:b23ee177fd68 2816 __STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2817 {
Kojto 158:b23ee177fd68 2818 WRITE_REG(USARTx->ICR, USART_ICR_NCF);
Kojto 158:b23ee177fd68 2819 }
Kojto 158:b23ee177fd68 2820
Kojto 158:b23ee177fd68 2821 /**
Kojto 158:b23ee177fd68 2822 * @brief Clear OverRun Error Flag
Kojto 158:b23ee177fd68 2823 * @rmtoll ICR ORECF LL_USART_ClearFlag_ORE
Kojto 158:b23ee177fd68 2824 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2825 * @retval None
Kojto 158:b23ee177fd68 2826 */
Kojto 158:b23ee177fd68 2827 __STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2828 {
Kojto 158:b23ee177fd68 2829 WRITE_REG(USARTx->ICR, USART_ICR_ORECF);
Kojto 158:b23ee177fd68 2830 }
Kojto 158:b23ee177fd68 2831
Kojto 158:b23ee177fd68 2832 /**
Kojto 158:b23ee177fd68 2833 * @brief Clear IDLE line detected Flag
Kojto 158:b23ee177fd68 2834 * @rmtoll ICR IDLECF LL_USART_ClearFlag_IDLE
Kojto 158:b23ee177fd68 2835 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2836 * @retval None
Kojto 158:b23ee177fd68 2837 */
Kojto 158:b23ee177fd68 2838 __STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2839 {
Kojto 158:b23ee177fd68 2840 WRITE_REG(USARTx->ICR, USART_ICR_IDLECF);
Kojto 158:b23ee177fd68 2841 }
Kojto 158:b23ee177fd68 2842
Kojto 158:b23ee177fd68 2843 /**
Kojto 158:b23ee177fd68 2844 * @brief Clear Transmission Complete Flag
Kojto 158:b23ee177fd68 2845 * @rmtoll ICR TCCF LL_USART_ClearFlag_TC
Kojto 158:b23ee177fd68 2846 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2847 * @retval None
Kojto 158:b23ee177fd68 2848 */
Kojto 158:b23ee177fd68 2849 __STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2850 {
Kojto 158:b23ee177fd68 2851 WRITE_REG(USARTx->ICR, USART_ICR_TCCF);
Kojto 158:b23ee177fd68 2852 }
Kojto 158:b23ee177fd68 2853
Kojto 158:b23ee177fd68 2854 #if defined(USART_TCBGT_SUPPORT)
Kojto 158:b23ee177fd68 2855 /* Function available only on devices supporting Transmit Complete before Guard Time feature */
Kojto 158:b23ee177fd68 2856 /**
Kojto 158:b23ee177fd68 2857 * @brief Clear Smartcard Transmission Complete Before Guard Time Flag
Kojto 158:b23ee177fd68 2858 * @rmtoll ICR TCBGTCF LL_USART_ClearFlag_TCBGT
Kojto 158:b23ee177fd68 2859 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2860 * @retval None
Kojto 158:b23ee177fd68 2861 */
Kojto 158:b23ee177fd68 2862 __STATIC_INLINE void LL_USART_ClearFlag_TCBGT(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2863 {
Kojto 158:b23ee177fd68 2864 WRITE_REG(USARTx->ICR, USART_ICR_TCBGTCF);
Kojto 158:b23ee177fd68 2865 }
Kojto 158:b23ee177fd68 2866 #endif
Kojto 158:b23ee177fd68 2867
Kojto 158:b23ee177fd68 2868 /**
Kojto 158:b23ee177fd68 2869 * @brief Clear LIN Break Detection Flag
Kojto 158:b23ee177fd68 2870 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2871 * LIN feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2872 * @rmtoll ICR LBDCF LL_USART_ClearFlag_LBD
Kojto 158:b23ee177fd68 2873 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2874 * @retval None
Kojto 158:b23ee177fd68 2875 */
Kojto 158:b23ee177fd68 2876 __STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2877 {
Kojto 158:b23ee177fd68 2878 WRITE_REG(USARTx->ICR, USART_ICR_LBDCF);
Kojto 158:b23ee177fd68 2879 }
Kojto 158:b23ee177fd68 2880
Kojto 158:b23ee177fd68 2881 /**
Kojto 158:b23ee177fd68 2882 * @brief Clear CTS Interrupt Flag
Kojto 158:b23ee177fd68 2883 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2884 * Hardware Flow control feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2885 * @rmtoll ICR CTSCF LL_USART_ClearFlag_nCTS
Kojto 158:b23ee177fd68 2886 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2887 * @retval None
Kojto 158:b23ee177fd68 2888 */
Kojto 158:b23ee177fd68 2889 __STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2890 {
Kojto 158:b23ee177fd68 2891 WRITE_REG(USARTx->ICR, USART_ICR_CTSCF);
Kojto 158:b23ee177fd68 2892 }
Kojto 158:b23ee177fd68 2893
Kojto 158:b23ee177fd68 2894 /**
Kojto 158:b23ee177fd68 2895 * @brief Clear Receiver Time Out Flag
Kojto 158:b23ee177fd68 2896 * @rmtoll ICR RTOCF LL_USART_ClearFlag_RTO
Kojto 158:b23ee177fd68 2897 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2898 * @retval None
Kojto 158:b23ee177fd68 2899 */
Kojto 158:b23ee177fd68 2900 __STATIC_INLINE void LL_USART_ClearFlag_RTO(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2901 {
Kojto 158:b23ee177fd68 2902 WRITE_REG(USARTx->ICR, USART_ICR_RTOCF);
Kojto 158:b23ee177fd68 2903 }
Kojto 158:b23ee177fd68 2904
Kojto 158:b23ee177fd68 2905 /**
Kojto 158:b23ee177fd68 2906 * @brief Clear End Of Block Flag
Kojto 158:b23ee177fd68 2907 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2908 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2909 * @rmtoll ICR EOBCF LL_USART_ClearFlag_EOB
Kojto 158:b23ee177fd68 2910 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2911 * @retval None
Kojto 158:b23ee177fd68 2912 */
Kojto 158:b23ee177fd68 2913 __STATIC_INLINE void LL_USART_ClearFlag_EOB(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2914 {
Kojto 158:b23ee177fd68 2915 WRITE_REG(USARTx->ICR, USART_ICR_EOBCF);
Kojto 158:b23ee177fd68 2916 }
Kojto 158:b23ee177fd68 2917
Kojto 158:b23ee177fd68 2918 /**
Kojto 158:b23ee177fd68 2919 * @brief Clear Character Match Flag
Kojto 158:b23ee177fd68 2920 * @rmtoll ICR CMCF LL_USART_ClearFlag_CM
Kojto 158:b23ee177fd68 2921 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2922 * @retval None
Kojto 158:b23ee177fd68 2923 */
Kojto 158:b23ee177fd68 2924 __STATIC_INLINE void LL_USART_ClearFlag_CM(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2925 {
Kojto 158:b23ee177fd68 2926 WRITE_REG(USARTx->ICR, USART_ICR_CMCF);
Kojto 158:b23ee177fd68 2927 }
Kojto 158:b23ee177fd68 2928
Kojto 158:b23ee177fd68 2929 /**
Kojto 158:b23ee177fd68 2930 * @brief Clear Wake Up from stop mode Flag
Kojto 158:b23ee177fd68 2931 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 2932 * Wake-up from Stop mode feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 2933 * @rmtoll ICR WUCF LL_USART_ClearFlag_WKUP
Kojto 158:b23ee177fd68 2934 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2935 * @retval None
Kojto 158:b23ee177fd68 2936 */
Kojto 158:b23ee177fd68 2937 __STATIC_INLINE void LL_USART_ClearFlag_WKUP(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2938 {
Kojto 158:b23ee177fd68 2939 WRITE_REG(USARTx->ICR, USART_ICR_WUCF);
Kojto 158:b23ee177fd68 2940 }
Kojto 158:b23ee177fd68 2941
Kojto 158:b23ee177fd68 2942 /**
Kojto 158:b23ee177fd68 2943 * @}
Kojto 158:b23ee177fd68 2944 */
Kojto 158:b23ee177fd68 2945
Kojto 158:b23ee177fd68 2946 /** @defgroup USART_LL_EF_IT_Management IT_Management
Kojto 158:b23ee177fd68 2947 * @{
Kojto 158:b23ee177fd68 2948 */
Kojto 158:b23ee177fd68 2949
Kojto 158:b23ee177fd68 2950 /**
Kojto 158:b23ee177fd68 2951 * @brief Enable IDLE Interrupt
Kojto 158:b23ee177fd68 2952 * @rmtoll CR1 IDLEIE LL_USART_EnableIT_IDLE
Kojto 158:b23ee177fd68 2953 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2954 * @retval None
Kojto 158:b23ee177fd68 2955 */
Kojto 158:b23ee177fd68 2956 __STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2957 {
Kojto 158:b23ee177fd68 2958 SET_BIT(USARTx->CR1, USART_CR1_IDLEIE);
Kojto 158:b23ee177fd68 2959 }
Kojto 158:b23ee177fd68 2960
Kojto 158:b23ee177fd68 2961 /**
Kojto 158:b23ee177fd68 2962 * @brief Enable RX Not Empty Interrupt
Kojto 158:b23ee177fd68 2963 * @rmtoll CR1 RXNEIE LL_USART_EnableIT_RXNE
Kojto 158:b23ee177fd68 2964 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2965 * @retval None
Kojto 158:b23ee177fd68 2966 */
Kojto 158:b23ee177fd68 2967 __STATIC_INLINE void LL_USART_EnableIT_RXNE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2968 {
Kojto 158:b23ee177fd68 2969 SET_BIT(USARTx->CR1, USART_CR1_RXNEIE);
Kojto 158:b23ee177fd68 2970 }
Kojto 158:b23ee177fd68 2971
Kojto 158:b23ee177fd68 2972 /**
Kojto 158:b23ee177fd68 2973 * @brief Enable Transmission Complete Interrupt
Kojto 158:b23ee177fd68 2974 * @rmtoll CR1 TCIE LL_USART_EnableIT_TC
Kojto 158:b23ee177fd68 2975 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2976 * @retval None
Kojto 158:b23ee177fd68 2977 */
Kojto 158:b23ee177fd68 2978 __STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2979 {
Kojto 158:b23ee177fd68 2980 SET_BIT(USARTx->CR1, USART_CR1_TCIE);
Kojto 158:b23ee177fd68 2981 }
Kojto 158:b23ee177fd68 2982
Kojto 158:b23ee177fd68 2983 /**
Kojto 158:b23ee177fd68 2984 * @brief Enable TX Empty Interrupt
Kojto 158:b23ee177fd68 2985 * @rmtoll CR1 TXEIE LL_USART_EnableIT_TXE
Kojto 158:b23ee177fd68 2986 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2987 * @retval None
Kojto 158:b23ee177fd68 2988 */
Kojto 158:b23ee177fd68 2989 __STATIC_INLINE void LL_USART_EnableIT_TXE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 2990 {
Kojto 158:b23ee177fd68 2991 SET_BIT(USARTx->CR1, USART_CR1_TXEIE);
Kojto 158:b23ee177fd68 2992 }
Kojto 158:b23ee177fd68 2993
Kojto 158:b23ee177fd68 2994 /**
Kojto 158:b23ee177fd68 2995 * @brief Enable Parity Error Interrupt
Kojto 158:b23ee177fd68 2996 * @rmtoll CR1 PEIE LL_USART_EnableIT_PE
Kojto 158:b23ee177fd68 2997 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 2998 * @retval None
Kojto 158:b23ee177fd68 2999 */
Kojto 158:b23ee177fd68 3000 __STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3001 {
Kojto 158:b23ee177fd68 3002 SET_BIT(USARTx->CR1, USART_CR1_PEIE);
Kojto 158:b23ee177fd68 3003 }
Kojto 158:b23ee177fd68 3004
Kojto 158:b23ee177fd68 3005 /**
Kojto 158:b23ee177fd68 3006 * @brief Enable Character Match Interrupt
Kojto 158:b23ee177fd68 3007 * @rmtoll CR1 CMIE LL_USART_EnableIT_CM
Kojto 158:b23ee177fd68 3008 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3009 * @retval None
Kojto 158:b23ee177fd68 3010 */
Kojto 158:b23ee177fd68 3011 __STATIC_INLINE void LL_USART_EnableIT_CM(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3012 {
Kojto 158:b23ee177fd68 3013 SET_BIT(USARTx->CR1, USART_CR1_CMIE);
Kojto 158:b23ee177fd68 3014 }
Kojto 158:b23ee177fd68 3015
Kojto 158:b23ee177fd68 3016 /**
Kojto 158:b23ee177fd68 3017 * @brief Enable Receiver Timeout Interrupt
Kojto 158:b23ee177fd68 3018 * @rmtoll CR1 RTOIE LL_USART_EnableIT_RTO
Kojto 158:b23ee177fd68 3019 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3020 * @retval None
Kojto 158:b23ee177fd68 3021 */
Kojto 158:b23ee177fd68 3022 __STATIC_INLINE void LL_USART_EnableIT_RTO(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3023 {
Kojto 158:b23ee177fd68 3024 SET_BIT(USARTx->CR1, USART_CR1_RTOIE);
Kojto 158:b23ee177fd68 3025 }
Kojto 158:b23ee177fd68 3026
Kojto 158:b23ee177fd68 3027 /**
Kojto 158:b23ee177fd68 3028 * @brief Enable End Of Block Interrupt
Kojto 158:b23ee177fd68 3029 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3030 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3031 * @rmtoll CR1 EOBIE LL_USART_EnableIT_EOB
Kojto 158:b23ee177fd68 3032 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3033 * @retval None
Kojto 158:b23ee177fd68 3034 */
Kojto 158:b23ee177fd68 3035 __STATIC_INLINE void LL_USART_EnableIT_EOB(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3036 {
Kojto 158:b23ee177fd68 3037 SET_BIT(USARTx->CR1, USART_CR1_EOBIE);
Kojto 158:b23ee177fd68 3038 }
Kojto 158:b23ee177fd68 3039
Kojto 158:b23ee177fd68 3040 /**
Kojto 158:b23ee177fd68 3041 * @brief Enable LIN Break Detection Interrupt
Kojto 158:b23ee177fd68 3042 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3043 * LIN feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3044 * @rmtoll CR2 LBDIE LL_USART_EnableIT_LBD
Kojto 158:b23ee177fd68 3045 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3046 * @retval None
Kojto 158:b23ee177fd68 3047 */
Kojto 158:b23ee177fd68 3048 __STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3049 {
Kojto 158:b23ee177fd68 3050 SET_BIT(USARTx->CR2, USART_CR2_LBDIE);
Kojto 158:b23ee177fd68 3051 }
Kojto 158:b23ee177fd68 3052
Kojto 158:b23ee177fd68 3053 /**
Kojto 158:b23ee177fd68 3054 * @brief Enable Error Interrupt
Kojto 158:b23ee177fd68 3055 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
Kojto 158:b23ee177fd68 3056 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register).
Kojto 158:b23ee177fd68 3057 * 0: Interrupt is inhibited
Kojto 158:b23ee177fd68 3058 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register.
Kojto 158:b23ee177fd68 3059 * @rmtoll CR3 EIE LL_USART_EnableIT_ERROR
Kojto 158:b23ee177fd68 3060 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3061 * @retval None
Kojto 158:b23ee177fd68 3062 */
Kojto 158:b23ee177fd68 3063 __STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3064 {
Kojto 158:b23ee177fd68 3065 SET_BIT(USARTx->CR3, USART_CR3_EIE);
Kojto 158:b23ee177fd68 3066 }
Kojto 158:b23ee177fd68 3067
Kojto 158:b23ee177fd68 3068 /**
Kojto 158:b23ee177fd68 3069 * @brief Enable CTS Interrupt
Kojto 158:b23ee177fd68 3070 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3071 * Hardware Flow control feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3072 * @rmtoll CR3 CTSIE LL_USART_EnableIT_CTS
Kojto 158:b23ee177fd68 3073 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3074 * @retval None
Kojto 158:b23ee177fd68 3075 */
Kojto 158:b23ee177fd68 3076 __STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3077 {
Kojto 158:b23ee177fd68 3078 SET_BIT(USARTx->CR3, USART_CR3_CTSIE);
Kojto 158:b23ee177fd68 3079 }
Kojto 158:b23ee177fd68 3080
Kojto 158:b23ee177fd68 3081 /**
Kojto 158:b23ee177fd68 3082 * @brief Enable Wake Up from Stop Mode Interrupt
Kojto 158:b23ee177fd68 3083 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3084 * Wake-up from Stop mode feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3085 * @rmtoll CR3 WUFIE LL_USART_EnableIT_WKUP
Kojto 158:b23ee177fd68 3086 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3087 * @retval None
Kojto 158:b23ee177fd68 3088 */
Kojto 158:b23ee177fd68 3089 __STATIC_INLINE void LL_USART_EnableIT_WKUP(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3090 {
Kojto 158:b23ee177fd68 3091 SET_BIT(USARTx->CR3, USART_CR3_WUFIE);
Kojto 158:b23ee177fd68 3092 }
Kojto 158:b23ee177fd68 3093
Kojto 158:b23ee177fd68 3094 #if defined(USART_TCBGT_SUPPORT)
Kojto 158:b23ee177fd68 3095 /* Function available only on devices supporting Transmit Complete before Guard Time feature */
Kojto 158:b23ee177fd68 3096 /**
Kojto 158:b23ee177fd68 3097 * @brief Enable Smartcard Transmission Complete Before Guard Time Interrupt
Kojto 158:b23ee177fd68 3098 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3099 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3100 * @rmtoll CR3 TCBGTIE LL_USART_EnableIT_TCBGT
Kojto 158:b23ee177fd68 3101 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3102 * @retval None
Kojto 158:b23ee177fd68 3103 */
Kojto 158:b23ee177fd68 3104 __STATIC_INLINE void LL_USART_EnableIT_TCBGT(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3105 {
Kojto 158:b23ee177fd68 3106 SET_BIT(USARTx->CR3, USART_CR3_TCBGTIE);
Kojto 158:b23ee177fd68 3107 }
Kojto 158:b23ee177fd68 3108 #endif
Kojto 158:b23ee177fd68 3109
Kojto 158:b23ee177fd68 3110 /**
Kojto 158:b23ee177fd68 3111 * @brief Disable IDLE Interrupt
Kojto 158:b23ee177fd68 3112 * @rmtoll CR1 IDLEIE LL_USART_DisableIT_IDLE
Kojto 158:b23ee177fd68 3113 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3114 * @retval None
Kojto 158:b23ee177fd68 3115 */
Kojto 158:b23ee177fd68 3116 __STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3117 {
Kojto 158:b23ee177fd68 3118 CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE);
Kojto 158:b23ee177fd68 3119 }
Kojto 158:b23ee177fd68 3120
Kojto 158:b23ee177fd68 3121 /**
Kojto 158:b23ee177fd68 3122 * @brief Disable RX Not Empty Interrupt
Kojto 158:b23ee177fd68 3123 * @rmtoll CR1 RXNEIE LL_USART_DisableIT_RXNE
Kojto 158:b23ee177fd68 3124 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3125 * @retval None
Kojto 158:b23ee177fd68 3126 */
Kojto 158:b23ee177fd68 3127 __STATIC_INLINE void LL_USART_DisableIT_RXNE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3128 {
Kojto 158:b23ee177fd68 3129 CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE);
Kojto 158:b23ee177fd68 3130 }
Kojto 158:b23ee177fd68 3131
Kojto 158:b23ee177fd68 3132 /**
Kojto 158:b23ee177fd68 3133 * @brief Disable Transmission Complete Interrupt
Kojto 158:b23ee177fd68 3134 * @rmtoll CR1 TCIE LL_USART_DisableIT_TC
Kojto 158:b23ee177fd68 3135 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3136 * @retval None
Kojto 158:b23ee177fd68 3137 */
Kojto 158:b23ee177fd68 3138 __STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3139 {
Kojto 158:b23ee177fd68 3140 CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE);
Kojto 158:b23ee177fd68 3141 }
Kojto 158:b23ee177fd68 3142
Kojto 158:b23ee177fd68 3143 /**
Kojto 158:b23ee177fd68 3144 * @brief Disable TX Empty Interrupt
Kojto 158:b23ee177fd68 3145 * @rmtoll CR1 TXEIE LL_USART_DisableIT_TXE
Kojto 158:b23ee177fd68 3146 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3147 * @retval None
Kojto 158:b23ee177fd68 3148 */
Kojto 158:b23ee177fd68 3149 __STATIC_INLINE void LL_USART_DisableIT_TXE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3150 {
Kojto 158:b23ee177fd68 3151 CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE);
Kojto 158:b23ee177fd68 3152 }
Kojto 158:b23ee177fd68 3153
Kojto 158:b23ee177fd68 3154 /**
Kojto 158:b23ee177fd68 3155 * @brief Disable Parity Error Interrupt
Kojto 158:b23ee177fd68 3156 * @rmtoll CR1 PEIE LL_USART_DisableIT_PE
Kojto 158:b23ee177fd68 3157 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3158 * @retval None
Kojto 158:b23ee177fd68 3159 */
Kojto 158:b23ee177fd68 3160 __STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3161 {
Kojto 158:b23ee177fd68 3162 CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE);
Kojto 158:b23ee177fd68 3163 }
Kojto 158:b23ee177fd68 3164
Kojto 158:b23ee177fd68 3165 /**
Kojto 158:b23ee177fd68 3166 * @brief Disable Character Match Interrupt
Kojto 158:b23ee177fd68 3167 * @rmtoll CR1 CMIE LL_USART_DisableIT_CM
Kojto 158:b23ee177fd68 3168 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3169 * @retval None
Kojto 158:b23ee177fd68 3170 */
Kojto 158:b23ee177fd68 3171 __STATIC_INLINE void LL_USART_DisableIT_CM(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3172 {
Kojto 158:b23ee177fd68 3173 CLEAR_BIT(USARTx->CR1, USART_CR1_CMIE);
Kojto 158:b23ee177fd68 3174 }
Kojto 158:b23ee177fd68 3175
Kojto 158:b23ee177fd68 3176 /**
Kojto 158:b23ee177fd68 3177 * @brief Disable Receiver Timeout Interrupt
Kojto 158:b23ee177fd68 3178 * @rmtoll CR1 RTOIE LL_USART_DisableIT_RTO
Kojto 158:b23ee177fd68 3179 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3180 * @retval None
Kojto 158:b23ee177fd68 3181 */
Kojto 158:b23ee177fd68 3182 __STATIC_INLINE void LL_USART_DisableIT_RTO(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3183 {
Kojto 158:b23ee177fd68 3184 CLEAR_BIT(USARTx->CR1, USART_CR1_RTOIE);
Kojto 158:b23ee177fd68 3185 }
Kojto 158:b23ee177fd68 3186
Kojto 158:b23ee177fd68 3187 /**
Kojto 158:b23ee177fd68 3188 * @brief Disable End Of Block Interrupt
Kojto 158:b23ee177fd68 3189 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3190 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3191 * @rmtoll CR1 EOBIE LL_USART_DisableIT_EOB
Kojto 158:b23ee177fd68 3192 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3193 * @retval None
Kojto 158:b23ee177fd68 3194 */
Kojto 158:b23ee177fd68 3195 __STATIC_INLINE void LL_USART_DisableIT_EOB(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3196 {
Kojto 158:b23ee177fd68 3197 CLEAR_BIT(USARTx->CR1, USART_CR1_EOBIE);
Kojto 158:b23ee177fd68 3198 }
Kojto 158:b23ee177fd68 3199
Kojto 158:b23ee177fd68 3200 /**
Kojto 158:b23ee177fd68 3201 * @brief Disable LIN Break Detection Interrupt
Kojto 158:b23ee177fd68 3202 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3203 * LIN feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3204 * @rmtoll CR2 LBDIE LL_USART_DisableIT_LBD
Kojto 158:b23ee177fd68 3205 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3206 * @retval None
Kojto 158:b23ee177fd68 3207 */
Kojto 158:b23ee177fd68 3208 __STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3209 {
Kojto 158:b23ee177fd68 3210 CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE);
Kojto 158:b23ee177fd68 3211 }
Kojto 158:b23ee177fd68 3212
Kojto 158:b23ee177fd68 3213 /**
Kojto 158:b23ee177fd68 3214 * @brief Disable Error Interrupt
Kojto 158:b23ee177fd68 3215 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
Kojto 158:b23ee177fd68 3216 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register).
Kojto 158:b23ee177fd68 3217 * 0: Interrupt is inhibited
Kojto 158:b23ee177fd68 3218 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register.
Kojto 158:b23ee177fd68 3219 * @rmtoll CR3 EIE LL_USART_DisableIT_ERROR
Kojto 158:b23ee177fd68 3220 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3221 * @retval None
Kojto 158:b23ee177fd68 3222 */
Kojto 158:b23ee177fd68 3223 __STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3224 {
Kojto 158:b23ee177fd68 3225 CLEAR_BIT(USARTx->CR3, USART_CR3_EIE);
Kojto 158:b23ee177fd68 3226 }
Kojto 158:b23ee177fd68 3227
Kojto 158:b23ee177fd68 3228 /**
Kojto 158:b23ee177fd68 3229 * @brief Disable CTS Interrupt
Kojto 158:b23ee177fd68 3230 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3231 * Hardware Flow control feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3232 * @rmtoll CR3 CTSIE LL_USART_DisableIT_CTS
Kojto 158:b23ee177fd68 3233 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3234 * @retval None
Kojto 158:b23ee177fd68 3235 */
Kojto 158:b23ee177fd68 3236 __STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3237 {
Kojto 158:b23ee177fd68 3238 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE);
Kojto 158:b23ee177fd68 3239 }
Kojto 158:b23ee177fd68 3240
Kojto 158:b23ee177fd68 3241 /**
Kojto 158:b23ee177fd68 3242 * @brief Disable Wake Up from Stop Mode Interrupt
Kojto 158:b23ee177fd68 3243 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3244 * Wake-up from Stop mode feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3245 * @rmtoll CR3 WUFIE LL_USART_DisableIT_WKUP
Kojto 158:b23ee177fd68 3246 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3247 * @retval None
Kojto 158:b23ee177fd68 3248 */
Kojto 158:b23ee177fd68 3249 __STATIC_INLINE void LL_USART_DisableIT_WKUP(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3250 {
Kojto 158:b23ee177fd68 3251 CLEAR_BIT(USARTx->CR3, USART_CR3_WUFIE);
Kojto 158:b23ee177fd68 3252 }
Kojto 158:b23ee177fd68 3253
Kojto 158:b23ee177fd68 3254 #if defined(USART_TCBGT_SUPPORT)
Kojto 158:b23ee177fd68 3255 /* Function available only on devices supporting Transmit Complete before Guard Time feature */
Kojto 158:b23ee177fd68 3256 /**
Kojto 158:b23ee177fd68 3257 * @brief Disable Smartcard Transmission Complete Before Guard Time Interrupt
Kojto 158:b23ee177fd68 3258 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3259 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3260 * @rmtoll CR3 TCBGTIE LL_USART_DisableIT_TCBGT
Kojto 158:b23ee177fd68 3261 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3262 * @retval None
Kojto 158:b23ee177fd68 3263 */
Kojto 158:b23ee177fd68 3264 __STATIC_INLINE void LL_USART_DisableIT_TCBGT(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3265 {
Kojto 158:b23ee177fd68 3266 CLEAR_BIT(USARTx->CR3, USART_CR3_TCBGTIE);
Kojto 158:b23ee177fd68 3267 }
Kojto 158:b23ee177fd68 3268 #endif
Kojto 158:b23ee177fd68 3269
Kojto 158:b23ee177fd68 3270 /**
Kojto 158:b23ee177fd68 3271 * @brief Check if the USART IDLE Interrupt source is enabled or disabled.
Kojto 158:b23ee177fd68 3272 * @rmtoll CR1 IDLEIE LL_USART_IsEnabledIT_IDLE
Kojto 158:b23ee177fd68 3273 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3274 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3275 */
Kojto 158:b23ee177fd68 3276 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3277 {
Kojto 158:b23ee177fd68 3278 return (READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE));
Kojto 158:b23ee177fd68 3279 }
Kojto 158:b23ee177fd68 3280
Kojto 158:b23ee177fd68 3281 /**
Kojto 158:b23ee177fd68 3282 * @brief Check if the USART RX Not Empty Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 3283 * @rmtoll CR1 RXNEIE LL_USART_IsEnabledIT_RXNE
Kojto 158:b23ee177fd68 3284 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3285 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3286 */
Kojto 158:b23ee177fd68 3287 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3288 {
Kojto 158:b23ee177fd68 3289 return (READ_BIT(USARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE));
Kojto 158:b23ee177fd68 3290 }
Kojto 158:b23ee177fd68 3291
Kojto 158:b23ee177fd68 3292 /**
Kojto 158:b23ee177fd68 3293 * @brief Check if the USART Transmission Complete Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 3294 * @rmtoll CR1 TCIE LL_USART_IsEnabledIT_TC
Kojto 158:b23ee177fd68 3295 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3296 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3297 */
Kojto 158:b23ee177fd68 3298 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3299 {
Kojto 158:b23ee177fd68 3300 return (READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE));
Kojto 158:b23ee177fd68 3301 }
Kojto 158:b23ee177fd68 3302
Kojto 158:b23ee177fd68 3303 /**
Kojto 158:b23ee177fd68 3304 * @brief Check if the USART TX Empty Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 3305 * @rmtoll CR1 TXEIE LL_USART_IsEnabledIT_TXE
Kojto 158:b23ee177fd68 3306 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3307 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3308 */
Kojto 158:b23ee177fd68 3309 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3310 {
Kojto 158:b23ee177fd68 3311 return (READ_BIT(USARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE));
Kojto 158:b23ee177fd68 3312 }
Kojto 158:b23ee177fd68 3313
Kojto 158:b23ee177fd68 3314 /**
Kojto 158:b23ee177fd68 3315 * @brief Check if the USART Parity Error Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 3316 * @rmtoll CR1 PEIE LL_USART_IsEnabledIT_PE
Kojto 158:b23ee177fd68 3317 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3318 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3319 */
Kojto 158:b23ee177fd68 3320 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3321 {
Kojto 158:b23ee177fd68 3322 return (READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE));
Kojto 158:b23ee177fd68 3323 }
Kojto 158:b23ee177fd68 3324
Kojto 158:b23ee177fd68 3325 /**
Kojto 158:b23ee177fd68 3326 * @brief Check if the USART Character Match Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 3327 * @rmtoll CR1 CMIE LL_USART_IsEnabledIT_CM
Kojto 158:b23ee177fd68 3328 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3329 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3330 */
Kojto 158:b23ee177fd68 3331 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CM(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3332 {
Kojto 158:b23ee177fd68 3333 return (READ_BIT(USARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE));
Kojto 158:b23ee177fd68 3334 }
Kojto 158:b23ee177fd68 3335
Kojto 158:b23ee177fd68 3336 /**
Kojto 158:b23ee177fd68 3337 * @brief Check if the USART Receiver Timeout Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 3338 * @rmtoll CR1 RTOIE LL_USART_IsEnabledIT_RTO
Kojto 158:b23ee177fd68 3339 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3340 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3341 */
Kojto 158:b23ee177fd68 3342 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RTO(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3343 {
Kojto 158:b23ee177fd68 3344 return (READ_BIT(USARTx->CR1, USART_CR1_RTOIE) == (USART_CR1_RTOIE));
Kojto 158:b23ee177fd68 3345 }
Kojto 158:b23ee177fd68 3346
Kojto 158:b23ee177fd68 3347 /**
Kojto 158:b23ee177fd68 3348 * @brief Check if the USART End Of Block Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 3349 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3350 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3351 * @rmtoll CR1 EOBIE LL_USART_IsEnabledIT_EOB
Kojto 158:b23ee177fd68 3352 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3353 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3354 */
Kojto 158:b23ee177fd68 3355 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_EOB(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3356 {
Kojto 158:b23ee177fd68 3357 return (READ_BIT(USARTx->CR1, USART_CR1_EOBIE) == (USART_CR1_EOBIE));
Kojto 158:b23ee177fd68 3358 }
Kojto 158:b23ee177fd68 3359
Kojto 158:b23ee177fd68 3360 /**
Kojto 158:b23ee177fd68 3361 * @brief Check if the USART LIN Break Detection Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 3362 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3363 * LIN feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3364 * @rmtoll CR2 LBDIE LL_USART_IsEnabledIT_LBD
Kojto 158:b23ee177fd68 3365 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3366 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3367 */
Kojto 158:b23ee177fd68 3368 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3369 {
Kojto 158:b23ee177fd68 3370 return (READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE));
Kojto 158:b23ee177fd68 3371 }
Kojto 158:b23ee177fd68 3372
Kojto 158:b23ee177fd68 3373 /**
Kojto 158:b23ee177fd68 3374 * @brief Check if the USART Error Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 3375 * @rmtoll CR3 EIE LL_USART_IsEnabledIT_ERROR
Kojto 158:b23ee177fd68 3376 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3377 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3378 */
Kojto 158:b23ee177fd68 3379 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3380 {
Kojto 158:b23ee177fd68 3381 return (READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE));
Kojto 158:b23ee177fd68 3382 }
Kojto 158:b23ee177fd68 3383
Kojto 158:b23ee177fd68 3384 /**
Kojto 158:b23ee177fd68 3385 * @brief Check if the USART CTS Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 3386 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3387 * Hardware Flow control feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3388 * @rmtoll CR3 CTSIE LL_USART_IsEnabledIT_CTS
Kojto 158:b23ee177fd68 3389 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3390 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3391 */
Kojto 158:b23ee177fd68 3392 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3393 {
Kojto 158:b23ee177fd68 3394 return (READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE));
Kojto 158:b23ee177fd68 3395 }
Kojto 158:b23ee177fd68 3396
Kojto 158:b23ee177fd68 3397 /**
Kojto 158:b23ee177fd68 3398 * @brief Check if the USART Wake Up from Stop Mode Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 3399 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3400 * Wake-up from Stop mode feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3401 * @rmtoll CR3 WUFIE LL_USART_IsEnabledIT_WKUP
Kojto 158:b23ee177fd68 3402 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3403 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3404 */
Kojto 158:b23ee177fd68 3405 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_WKUP(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3406 {
Kojto 158:b23ee177fd68 3407 return (READ_BIT(USARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE));
Kojto 158:b23ee177fd68 3408 }
Kojto 158:b23ee177fd68 3409
Kojto 158:b23ee177fd68 3410 #if defined(USART_TCBGT_SUPPORT)
Kojto 158:b23ee177fd68 3411 /* Function available only on devices supporting Transmit Complete before Guard Time feature */
Kojto 158:b23ee177fd68 3412 /**
Kojto 158:b23ee177fd68 3413 * @brief Check if the Smartcard Transmission Complete Before Guard Time Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 3414 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3415 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3416 * @rmtoll CR3 TCBGTIE LL_USART_IsEnabledIT_TCBGT
Kojto 158:b23ee177fd68 3417 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3418 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3419 */
Kojto 158:b23ee177fd68 3420 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TCBGT(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3421 {
Kojto 158:b23ee177fd68 3422 return (READ_BIT(USARTx->CR3, USART_CR3_TCBGTIE) == (USART_CR3_TCBGTIE));
Kojto 158:b23ee177fd68 3423 }
Kojto 158:b23ee177fd68 3424 #endif
Kojto 158:b23ee177fd68 3425
Kojto 158:b23ee177fd68 3426 /**
Kojto 158:b23ee177fd68 3427 * @}
Kojto 158:b23ee177fd68 3428 */
Kojto 158:b23ee177fd68 3429
Kojto 158:b23ee177fd68 3430 /** @defgroup USART_LL_EF_DMA_Management DMA_Management
Kojto 158:b23ee177fd68 3431 * @{
Kojto 158:b23ee177fd68 3432 */
Kojto 158:b23ee177fd68 3433
Kojto 158:b23ee177fd68 3434 /**
Kojto 158:b23ee177fd68 3435 * @brief Enable DMA Mode for reception
Kojto 158:b23ee177fd68 3436 * @rmtoll CR3 DMAR LL_USART_EnableDMAReq_RX
Kojto 158:b23ee177fd68 3437 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3438 * @retval None
Kojto 158:b23ee177fd68 3439 */
Kojto 158:b23ee177fd68 3440 __STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3441 {
Kojto 158:b23ee177fd68 3442 SET_BIT(USARTx->CR3, USART_CR3_DMAR);
Kojto 158:b23ee177fd68 3443 }
Kojto 158:b23ee177fd68 3444
Kojto 158:b23ee177fd68 3445 /**
Kojto 158:b23ee177fd68 3446 * @brief Disable DMA Mode for reception
Kojto 158:b23ee177fd68 3447 * @rmtoll CR3 DMAR LL_USART_DisableDMAReq_RX
Kojto 158:b23ee177fd68 3448 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3449 * @retval None
Kojto 158:b23ee177fd68 3450 */
Kojto 158:b23ee177fd68 3451 __STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3452 {
Kojto 158:b23ee177fd68 3453 CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR);
Kojto 158:b23ee177fd68 3454 }
Kojto 158:b23ee177fd68 3455
Kojto 158:b23ee177fd68 3456 /**
Kojto 158:b23ee177fd68 3457 * @brief Check if DMA Mode is enabled for reception
Kojto 158:b23ee177fd68 3458 * @rmtoll CR3 DMAR LL_USART_IsEnabledDMAReq_RX
Kojto 158:b23ee177fd68 3459 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3460 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3461 */
Kojto 158:b23ee177fd68 3462 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3463 {
Kojto 158:b23ee177fd68 3464 return (READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR));
Kojto 158:b23ee177fd68 3465 }
Kojto 158:b23ee177fd68 3466
Kojto 158:b23ee177fd68 3467 /**
Kojto 158:b23ee177fd68 3468 * @brief Enable DMA Mode for transmission
Kojto 158:b23ee177fd68 3469 * @rmtoll CR3 DMAT LL_USART_EnableDMAReq_TX
Kojto 158:b23ee177fd68 3470 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3471 * @retval None
Kojto 158:b23ee177fd68 3472 */
Kojto 158:b23ee177fd68 3473 __STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3474 {
Kojto 158:b23ee177fd68 3475 SET_BIT(USARTx->CR3, USART_CR3_DMAT);
Kojto 158:b23ee177fd68 3476 }
Kojto 158:b23ee177fd68 3477
Kojto 158:b23ee177fd68 3478 /**
Kojto 158:b23ee177fd68 3479 * @brief Disable DMA Mode for transmission
Kojto 158:b23ee177fd68 3480 * @rmtoll CR3 DMAT LL_USART_DisableDMAReq_TX
Kojto 158:b23ee177fd68 3481 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3482 * @retval None
Kojto 158:b23ee177fd68 3483 */
Kojto 158:b23ee177fd68 3484 __STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3485 {
Kojto 158:b23ee177fd68 3486 CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT);
Kojto 158:b23ee177fd68 3487 }
Kojto 158:b23ee177fd68 3488
Kojto 158:b23ee177fd68 3489 /**
Kojto 158:b23ee177fd68 3490 * @brief Check if DMA Mode is enabled for transmission
Kojto 158:b23ee177fd68 3491 * @rmtoll CR3 DMAT LL_USART_IsEnabledDMAReq_TX
Kojto 158:b23ee177fd68 3492 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3493 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3494 */
Kojto 158:b23ee177fd68 3495 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3496 {
Kojto 158:b23ee177fd68 3497 return (READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT));
Kojto 158:b23ee177fd68 3498 }
Kojto 158:b23ee177fd68 3499
Kojto 158:b23ee177fd68 3500 /**
Kojto 158:b23ee177fd68 3501 * @brief Enable DMA Disabling on Reception Error
Kojto 158:b23ee177fd68 3502 * @rmtoll CR3 DDRE LL_USART_EnableDMADeactOnRxErr
Kojto 158:b23ee177fd68 3503 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3504 * @retval None
Kojto 158:b23ee177fd68 3505 */
Kojto 158:b23ee177fd68 3506 __STATIC_INLINE void LL_USART_EnableDMADeactOnRxErr(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3507 {
Kojto 158:b23ee177fd68 3508 SET_BIT(USARTx->CR3, USART_CR3_DDRE);
Kojto 158:b23ee177fd68 3509 }
Kojto 158:b23ee177fd68 3510
Kojto 158:b23ee177fd68 3511 /**
Kojto 158:b23ee177fd68 3512 * @brief Disable DMA Disabling on Reception Error
Kojto 158:b23ee177fd68 3513 * @rmtoll CR3 DDRE LL_USART_DisableDMADeactOnRxErr
Kojto 158:b23ee177fd68 3514 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3515 * @retval None
Kojto 158:b23ee177fd68 3516 */
Kojto 158:b23ee177fd68 3517 __STATIC_INLINE void LL_USART_DisableDMADeactOnRxErr(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3518 {
Kojto 158:b23ee177fd68 3519 CLEAR_BIT(USARTx->CR3, USART_CR3_DDRE);
Kojto 158:b23ee177fd68 3520 }
Kojto 158:b23ee177fd68 3521
Kojto 158:b23ee177fd68 3522 /**
Kojto 158:b23ee177fd68 3523 * @brief Indicate if DMA Disabling on Reception Error is disabled
Kojto 158:b23ee177fd68 3524 * @rmtoll CR3 DDRE LL_USART_IsEnabledDMADeactOnRxErr
Kojto 158:b23ee177fd68 3525 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3526 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 3527 */
Kojto 158:b23ee177fd68 3528 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMADeactOnRxErr(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3529 {
Kojto 158:b23ee177fd68 3530 return (READ_BIT(USARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE));
Kojto 158:b23ee177fd68 3531 }
Kojto 158:b23ee177fd68 3532
Kojto 158:b23ee177fd68 3533 /**
Kojto 158:b23ee177fd68 3534 * @brief Get the data register address used for DMA transfer
Kojto 158:b23ee177fd68 3535 * @rmtoll RDR RDR LL_USART_DMA_GetRegAddr\n
Kojto 158:b23ee177fd68 3536 * @rmtoll TDR TDR LL_USART_DMA_GetRegAddr
Kojto 158:b23ee177fd68 3537 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3538 * @param Direction This parameter can be one of the following values:
Kojto 158:b23ee177fd68 3539 * @arg @ref LL_USART_DMA_REG_DATA_TRANSMIT
Kojto 158:b23ee177fd68 3540 * @arg @ref LL_USART_DMA_REG_DATA_RECEIVE
Kojto 158:b23ee177fd68 3541 * @retval Address of data register
Kojto 158:b23ee177fd68 3542 */
Kojto 158:b23ee177fd68 3543 __STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(USART_TypeDef *USARTx, uint32_t Direction)
Kojto 158:b23ee177fd68 3544 {
Kojto 158:b23ee177fd68 3545 register uint32_t data_reg_addr = 0U;
Kojto 158:b23ee177fd68 3546
Kojto 158:b23ee177fd68 3547 if (Direction == LL_USART_DMA_REG_DATA_TRANSMIT)
Kojto 158:b23ee177fd68 3548 {
Kojto 158:b23ee177fd68 3549 /* return address of TDR register */
Kojto 158:b23ee177fd68 3550 data_reg_addr = (uint32_t) &(USARTx->TDR);
Kojto 158:b23ee177fd68 3551 }
Kojto 158:b23ee177fd68 3552 else
Kojto 158:b23ee177fd68 3553 {
Kojto 158:b23ee177fd68 3554 /* return address of RDR register */
Kojto 158:b23ee177fd68 3555 data_reg_addr = (uint32_t) &(USARTx->RDR);
Kojto 158:b23ee177fd68 3556 }
Kojto 158:b23ee177fd68 3557
Kojto 158:b23ee177fd68 3558 return data_reg_addr;
Kojto 158:b23ee177fd68 3559 }
Kojto 158:b23ee177fd68 3560
Kojto 158:b23ee177fd68 3561 /**
Kojto 158:b23ee177fd68 3562 * @}
Kojto 158:b23ee177fd68 3563 */
Kojto 158:b23ee177fd68 3564
Kojto 158:b23ee177fd68 3565 /** @defgroup USART_LL_EF_Data_Management Data_Management
Kojto 158:b23ee177fd68 3566 * @{
Kojto 158:b23ee177fd68 3567 */
Kojto 158:b23ee177fd68 3568
Kojto 158:b23ee177fd68 3569 /**
Kojto 158:b23ee177fd68 3570 * @brief Read Receiver Data register (Receive Data value, 8 bits)
Kojto 158:b23ee177fd68 3571 * @rmtoll RDR RDR LL_USART_ReceiveData8
Kojto 158:b23ee177fd68 3572 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3573 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 3574 */
Kojto 158:b23ee177fd68 3575 __STATIC_INLINE uint8_t LL_USART_ReceiveData8(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3576 {
Kojto 158:b23ee177fd68 3577 return (uint8_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR));
Kojto 158:b23ee177fd68 3578 }
Kojto 158:b23ee177fd68 3579
Kojto 158:b23ee177fd68 3580 /**
Kojto 158:b23ee177fd68 3581 * @brief Read Receiver Data register (Receive Data value, 9 bits)
Kojto 158:b23ee177fd68 3582 * @rmtoll RDR RDR LL_USART_ReceiveData9
Kojto 158:b23ee177fd68 3583 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3584 * @retval Value between Min_Data=0x00 and Max_Data=0x1FF
Kojto 158:b23ee177fd68 3585 */
Kojto 158:b23ee177fd68 3586 __STATIC_INLINE uint16_t LL_USART_ReceiveData9(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3587 {
Kojto 158:b23ee177fd68 3588 return (uint16_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR));
Kojto 158:b23ee177fd68 3589 }
Kojto 158:b23ee177fd68 3590
Kojto 158:b23ee177fd68 3591 /**
Kojto 158:b23ee177fd68 3592 * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits)
Kojto 158:b23ee177fd68 3593 * @rmtoll TDR TDR LL_USART_TransmitData8
Kojto 158:b23ee177fd68 3594 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3595 * @param Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 3596 * @retval None
Kojto 158:b23ee177fd68 3597 */
Kojto 158:b23ee177fd68 3598 __STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value)
Kojto 158:b23ee177fd68 3599 {
Kojto 158:b23ee177fd68 3600 USARTx->TDR = Value;
Kojto 158:b23ee177fd68 3601 }
Kojto 158:b23ee177fd68 3602
Kojto 158:b23ee177fd68 3603 /**
Kojto 158:b23ee177fd68 3604 * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits)
Kojto 158:b23ee177fd68 3605 * @rmtoll TDR TDR LL_USART_TransmitData9
Kojto 158:b23ee177fd68 3606 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3607 * @param Value between Min_Data=0x00 and Max_Data=0x1FF
Kojto 158:b23ee177fd68 3608 * @retval None
Kojto 158:b23ee177fd68 3609 */
Kojto 158:b23ee177fd68 3610 __STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value)
Kojto 158:b23ee177fd68 3611 {
Kojto 158:b23ee177fd68 3612 USARTx->TDR = Value & 0x1FFU;
Kojto 158:b23ee177fd68 3613 }
Kojto 158:b23ee177fd68 3614
Kojto 158:b23ee177fd68 3615 /**
Kojto 158:b23ee177fd68 3616 * @}
Kojto 158:b23ee177fd68 3617 */
Kojto 158:b23ee177fd68 3618
Kojto 158:b23ee177fd68 3619 /** @defgroup USART_LL_EF_Execution Execution
Kojto 158:b23ee177fd68 3620 * @{
Kojto 158:b23ee177fd68 3621 */
Kojto 158:b23ee177fd68 3622
Kojto 158:b23ee177fd68 3623 /**
Kojto 158:b23ee177fd68 3624 * @brief Request an Automatic Baud Rate measurement on next received data frame
Kojto 158:b23ee177fd68 3625 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3626 * Auto Baud Rate detection feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3627 * @rmtoll RQR ABRRQ LL_USART_RequestAutoBaudRate
Kojto 158:b23ee177fd68 3628 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3629 * @retval None
Kojto 158:b23ee177fd68 3630 */
Kojto 158:b23ee177fd68 3631 __STATIC_INLINE void LL_USART_RequestAutoBaudRate(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3632 {
Kojto 158:b23ee177fd68 3633 SET_BIT(USARTx->RQR, USART_RQR_ABRRQ);
Kojto 158:b23ee177fd68 3634 }
Kojto 158:b23ee177fd68 3635
Kojto 158:b23ee177fd68 3636 /**
Kojto 158:b23ee177fd68 3637 * @brief Request Break sending
Kojto 158:b23ee177fd68 3638 * @rmtoll RQR SBKRQ LL_USART_RequestBreakSending
Kojto 158:b23ee177fd68 3639 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3640 * @retval None
Kojto 158:b23ee177fd68 3641 */
Kojto 158:b23ee177fd68 3642 __STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3643 {
Kojto 158:b23ee177fd68 3644 SET_BIT(USARTx->RQR, USART_RQR_SBKRQ);
Kojto 158:b23ee177fd68 3645 }
Kojto 158:b23ee177fd68 3646
Kojto 158:b23ee177fd68 3647 /**
Kojto 158:b23ee177fd68 3648 * @brief Put USART in mute mode and set the RWU flag
Kojto 158:b23ee177fd68 3649 * @rmtoll RQR MMRQ LL_USART_RequestEnterMuteMode
Kojto 158:b23ee177fd68 3650 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3651 * @retval None
Kojto 158:b23ee177fd68 3652 */
Kojto 158:b23ee177fd68 3653 __STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3654 {
Kojto 158:b23ee177fd68 3655 SET_BIT(USARTx->RQR, USART_RQR_MMRQ);
Kojto 158:b23ee177fd68 3656 }
Kojto 158:b23ee177fd68 3657
Kojto 158:b23ee177fd68 3658 /**
Kojto 158:b23ee177fd68 3659 * @brief Request a Receive Data flush
Kojto 158:b23ee177fd68 3660 * @rmtoll RQR RXFRQ LL_USART_RequestRxDataFlush
Kojto 158:b23ee177fd68 3661 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3662 * @retval None
Kojto 158:b23ee177fd68 3663 */
Kojto 158:b23ee177fd68 3664 __STATIC_INLINE void LL_USART_RequestRxDataFlush(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3665 {
Kojto 158:b23ee177fd68 3666 SET_BIT(USARTx->RQR, USART_RQR_RXFRQ);
Kojto 158:b23ee177fd68 3667 }
Kojto 158:b23ee177fd68 3668
Kojto 158:b23ee177fd68 3669 /**
Kojto 158:b23ee177fd68 3670 * @brief Request a Transmit data flush
Kojto 158:b23ee177fd68 3671 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
Kojto 158:b23ee177fd68 3672 * Smartcard feature is supported by the USARTx instance.
Kojto 158:b23ee177fd68 3673 * @rmtoll RQR TXFRQ LL_USART_RequestTxDataFlush
Kojto 158:b23ee177fd68 3674 * @param USARTx USART Instance
Kojto 158:b23ee177fd68 3675 * @retval None
Kojto 158:b23ee177fd68 3676 */
Kojto 158:b23ee177fd68 3677 __STATIC_INLINE void LL_USART_RequestTxDataFlush(USART_TypeDef *USARTx)
Kojto 158:b23ee177fd68 3678 {
Kojto 158:b23ee177fd68 3679 SET_BIT(USARTx->RQR, USART_RQR_TXFRQ);
Kojto 158:b23ee177fd68 3680 }
Kojto 158:b23ee177fd68 3681
Kojto 158:b23ee177fd68 3682 /**
Kojto 158:b23ee177fd68 3683 * @}
Kojto 158:b23ee177fd68 3684 */
Kojto 158:b23ee177fd68 3685
Kojto 158:b23ee177fd68 3686 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 3687 /** @defgroup USART_LL_EF_Init Initialization and de-initialization functions
Kojto 158:b23ee177fd68 3688 * @{
Kojto 158:b23ee177fd68 3689 */
Kojto 158:b23ee177fd68 3690 ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx);
Kojto 158:b23ee177fd68 3691 ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct);
Kojto 158:b23ee177fd68 3692 void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct);
Kojto 158:b23ee177fd68 3693 ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
Kojto 158:b23ee177fd68 3694 void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
Kojto 158:b23ee177fd68 3695 /**
Kojto 158:b23ee177fd68 3696 * @}
Kojto 158:b23ee177fd68 3697 */
Kojto 158:b23ee177fd68 3698 #endif /* USE_FULL_LL_DRIVER */
Kojto 158:b23ee177fd68 3699
Kojto 158:b23ee177fd68 3700 /**
Kojto 158:b23ee177fd68 3701 * @}
Kojto 158:b23ee177fd68 3702 */
Kojto 158:b23ee177fd68 3703
Kojto 158:b23ee177fd68 3704 /**
Kojto 158:b23ee177fd68 3705 * @}
Kojto 158:b23ee177fd68 3706 */
Kojto 158:b23ee177fd68 3707
Kojto 158:b23ee177fd68 3708 #endif /* USART1 || USART2 || USART4 || USART5 */
Kojto 158:b23ee177fd68 3709
Kojto 158:b23ee177fd68 3710 /**
Kojto 158:b23ee177fd68 3711 * @}
Kojto 158:b23ee177fd68 3712 */
Kojto 158:b23ee177fd68 3713
Kojto 158:b23ee177fd68 3714 #ifdef __cplusplus
Kojto 158:b23ee177fd68 3715 }
Kojto 158:b23ee177fd68 3716 #endif
Kojto 158:b23ee177fd68 3717
Kojto 158:b23ee177fd68 3718 #endif /* __STM32L0xx_LL_USART_H */
Kojto 158:b23ee177fd68 3719
Kojto 158:b23ee177fd68 3720 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/