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