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