![]() |
|
|||
File indexing completed on 2025-05-11 08:23:38
0001 /** 0002 ****************************************************************************** 0003 * @file stm32h7xx_ll_usart.h 0004 * @author MCD Application Team 0005 * @brief Header file of USART LL module. 0006 ****************************************************************************** 0007 * @attention 0008 * 0009 * Copyright (c) 2017 STMicroelectronics. 0010 * All rights reserved. 0011 * 0012 * This software is licensed under terms that can be found in the LICENSE file 0013 * in the root directory of this software component. 0014 * If no LICENSE file comes with this software, it is provided AS-IS. 0015 * 0016 ****************************************************************************** 0017 */ 0018 0019 /* Define to prevent recursive inclusion -------------------------------------*/ 0020 #ifndef STM32H7xx_LL_USART_H 0021 #define STM32H7xx_LL_USART_H 0022 0023 #ifdef __cplusplus 0024 extern "C" { 0025 #endif 0026 0027 /* Includes ------------------------------------------------------------------*/ 0028 #include "stm32h7xx.h" 0029 0030 /** @addtogroup STM32H7xx_LL_Driver 0031 * @{ 0032 */ 0033 0034 #if defined(USART1) || defined(USART2) || defined(USART3) || defined(USART6) \ 0035 || defined(UART4) || defined(UART5) || defined(UART7) || defined(UART8) || defined(UART9) || defined(USART10) 0036 0037 /** @defgroup USART_LL USART 0038 * @ingroup RTEMSBSPsARMSTM32H7 0039 * @{ 0040 */ 0041 0042 /* Private types -------------------------------------------------------------*/ 0043 /* Private variables ---------------------------------------------------------*/ 0044 /** @defgroup USART_LL_Private_Variables USART Private Variables 0045 * @ingroup RTEMSBSPsARMSTM32H7 0046 * @{ 0047 */ 0048 /* Array used to get the USART prescaler division decimal values versus @ref USART_LL_EC_PRESCALER values */ 0049 static const uint32_t USART_PRESCALER_TAB[] = 0050 { 0051 1UL, 0052 2UL, 0053 4UL, 0054 6UL, 0055 8UL, 0056 10UL, 0057 12UL, 0058 16UL, 0059 32UL, 0060 64UL, 0061 128UL, 0062 256UL 0063 }; 0064 /** 0065 * @} 0066 */ 0067 0068 /* Private constants ---------------------------------------------------------*/ 0069 /** @defgroup USART_LL_Private_Constants USART Private Constants 0070 * @ingroup RTEMSBSPsARMSTM32H7 0071 * @{ 0072 */ 0073 /** 0074 * @} 0075 */ 0076 /* Private macros ------------------------------------------------------------*/ 0077 #if defined(USE_FULL_LL_DRIVER) || defined(__rtems__) 0078 /** @defgroup USART_LL_Private_Macros USART Private Macros 0079 * @ingroup RTEMSBSPsARMSTM32H7 0080 * @{ 0081 */ 0082 /** 0083 * @} 0084 */ 0085 #endif /*USE_FULL_LL_DRIVER*/ 0086 0087 /* Exported types ------------------------------------------------------------*/ 0088 #if defined(USE_FULL_LL_DRIVER) || defined(__rtems__) 0089 /** @defgroup USART_LL_ES_INIT USART Exported Init structures 0090 * @ingroup RTEMSBSPsARMSTM32H7 0091 * @{ 0092 */ 0093 0094 /** 0095 * @brief LL USART Init Structure definition 0096 */ 0097 typedef struct 0098 { 0099 uint32_t PrescalerValue; /*!< Specifies the Prescaler to compute the communication baud rate. 0100 This parameter can be a value of @ref USART_LL_EC_PRESCALER. 0101 0102 This feature can be modified afterwards using unitary 0103 function @ref LL_USART_SetPrescaler().*/ 0104 0105 uint32_t BaudRate; /*!< This field defines expected Usart communication baud rate. 0106 0107 This feature can be modified afterwards using unitary 0108 function @ref LL_USART_SetBaudRate().*/ 0109 0110 uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame. 0111 This parameter can be a value of @ref USART_LL_EC_DATAWIDTH. 0112 0113 This feature can be modified afterwards using unitary 0114 function @ref LL_USART_SetDataWidth().*/ 0115 0116 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted. 0117 This parameter can be a value of @ref USART_LL_EC_STOPBITS. 0118 0119 This feature can be modified afterwards using unitary 0120 function @ref LL_USART_SetStopBitsLength().*/ 0121 0122 uint32_t Parity; /*!< Specifies the parity mode. 0123 This parameter can be a value of @ref USART_LL_EC_PARITY. 0124 0125 This feature can be modified afterwards using unitary 0126 function @ref LL_USART_SetParity().*/ 0127 0128 uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled. 0129 This parameter can be a value of @ref USART_LL_EC_DIRECTION. 0130 0131 This feature can be modified afterwards using unitary 0132 function @ref LL_USART_SetTransferDirection().*/ 0133 0134 uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled. 0135 This parameter can be a value of @ref USART_LL_EC_HWCONTROL. 0136 0137 This feature can be modified afterwards using unitary 0138 function @ref LL_USART_SetHWFlowCtrl().*/ 0139 0140 uint32_t OverSampling; /*!< Specifies whether USART oversampling mode is 16 or 8. 0141 This parameter can be a value of @ref USART_LL_EC_OVERSAMPLING. 0142 0143 This feature can be modified afterwards using unitary 0144 function @ref LL_USART_SetOverSampling().*/ 0145 0146 } LL_USART_InitTypeDef; 0147 0148 /** 0149 * @brief LL USART Clock Init Structure definition 0150 */ 0151 typedef struct 0152 { 0153 uint32_t ClockOutput; /*!< Specifies whether the USART clock is enabled or disabled. 0154 This parameter can be a value of @ref USART_LL_EC_CLOCK. 0155 0156 USART HW configuration can be modified afterwards using unitary functions 0157 @ref LL_USART_EnableSCLKOutput() or @ref LL_USART_DisableSCLKOutput(). 0158 For more details, refer to description of this function. */ 0159 0160 uint32_t ClockPolarity; /*!< Specifies the steady state of the serial clock. 0161 This parameter can be a value of @ref USART_LL_EC_POLARITY. 0162 0163 USART HW configuration can be modified afterwards using unitary 0164 functions @ref LL_USART_SetClockPolarity(). 0165 For more details, refer to description of this function. */ 0166 0167 uint32_t ClockPhase; /*!< Specifies the clock transition on which the bit capture is made. 0168 This parameter can be a value of @ref USART_LL_EC_PHASE. 0169 0170 USART HW configuration can be modified afterwards using unitary 0171 functions @ref LL_USART_SetClockPhase(). 0172 For more details, refer to description of this function. */ 0173 0174 uint32_t LastBitClockPulse; /*!< Specifies whether the clock pulse corresponding to the last transmitted 0175 data bit (MSB) has to be output on the SCLK pin in synchronous mode. 0176 This parameter can be a value of @ref USART_LL_EC_LASTCLKPULSE. 0177 0178 USART HW configuration can be modified afterwards using unitary 0179 functions @ref LL_USART_SetLastClkPulseOutput(). 0180 For more details, refer to description of this function. */ 0181 0182 } LL_USART_ClockInitTypeDef; 0183 0184 /** 0185 * @} 0186 */ 0187 #endif /* USE_FULL_LL_DRIVER */ 0188 0189 /* Exported constants --------------------------------------------------------*/ 0190 /** @defgroup USART_LL_Exported_Constants USART Exported Constants 0191 * @ingroup RTEMSBSPsARMSTM32H7 0192 * @{ 0193 */ 0194 0195 /** @defgroup USART_LL_EC_CLEAR_FLAG Clear Flags Defines 0196 * @ingroup RTEMSBSPsARMSTM32H7 0197 * @brief Flags defines which can be used with LL_USART_WriteReg function 0198 * @{ 0199 */ 0200 #define LL_USART_ICR_PECF USART_ICR_PECF /*!< Parity error clear flag */ 0201 #define LL_USART_ICR_FECF USART_ICR_FECF /*!< Framing error clear flag */ 0202 #define LL_USART_ICR_NECF USART_ICR_NECF /*!< Noise error detected clear flag */ 0203 #define LL_USART_ICR_ORECF USART_ICR_ORECF /*!< Overrun error clear flag */ 0204 #define LL_USART_ICR_IDLECF USART_ICR_IDLECF /*!< Idle line detected clear flag */ 0205 #define LL_USART_ICR_TXFECF USART_ICR_TXFECF /*!< TX FIFO Empty clear flag */ 0206 #define LL_USART_ICR_TCCF USART_ICR_TCCF /*!< Transmission complete clear flag */ 0207 #define LL_USART_ICR_TCBGTCF USART_ICR_TCBGTCF /*!< Transmission completed before guard time clear flag */ 0208 #define LL_USART_ICR_LBDCF USART_ICR_LBDCF /*!< LIN break detection clear flag */ 0209 #define LL_USART_ICR_CTSCF USART_ICR_CTSCF /*!< CTS clear flag */ 0210 #define LL_USART_ICR_RTOCF USART_ICR_RTOCF /*!< Receiver timeout clear flag */ 0211 #define LL_USART_ICR_EOBCF USART_ICR_EOBCF /*!< End of block clear flag */ 0212 #define LL_USART_ICR_UDRCF USART_ICR_UDRCF /*!< SPI Slave Underrun clear flag */ 0213 #define LL_USART_ICR_CMCF USART_ICR_CMCF /*!< Character match clear flag */ 0214 #define LL_USART_ICR_WUCF USART_ICR_WUCF /*!< Wakeup from Stop mode clear flag */ 0215 /** 0216 * @} 0217 */ 0218 0219 /** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines 0220 * @ingroup RTEMSBSPsARMSTM32H7 0221 * @brief Flags defines which can be used with LL_USART_ReadReg function 0222 * @{ 0223 */ 0224 #define LL_USART_ISR_PE USART_ISR_PE /*!< Parity error flag */ 0225 #define LL_USART_ISR_FE USART_ISR_FE /*!< Framing error flag */ 0226 #define LL_USART_ISR_NE USART_ISR_NE /*!< Noise detected flag */ 0227 #define LL_USART_ISR_ORE USART_ISR_ORE /*!< Overrun error flag */ 0228 #define LL_USART_ISR_IDLE USART_ISR_IDLE /*!< Idle line detected flag */ 0229 #define LL_USART_ISR_RXNE_RXFNE USART_ISR_RXNE_RXFNE /*!< Read data register or RX FIFO not empty flag */ 0230 #define LL_USART_ISR_TC USART_ISR_TC /*!< Transmission complete flag */ 0231 #define LL_USART_ISR_TXE_TXFNF USART_ISR_TXE_TXFNF /*!< Transmit data register empty or TX FIFO Not Full flag*/ 0232 #define LL_USART_ISR_LBDF USART_ISR_LBDF /*!< LIN break detection flag */ 0233 #define LL_USART_ISR_CTSIF USART_ISR_CTSIF /*!< CTS interrupt flag */ 0234 #define LL_USART_ISR_CTS USART_ISR_CTS /*!< CTS flag */ 0235 #define LL_USART_ISR_RTOF USART_ISR_RTOF /*!< Receiver timeout flag */ 0236 #define LL_USART_ISR_EOBF USART_ISR_EOBF /*!< End of block flag */ 0237 #define LL_USART_ISR_UDR USART_ISR_UDR /*!< SPI Slave underrun error flag */ 0238 #define LL_USART_ISR_ABRE USART_ISR_ABRE /*!< Auto baud rate error flag */ 0239 #define LL_USART_ISR_ABRF USART_ISR_ABRF /*!< Auto baud rate flag */ 0240 #define LL_USART_ISR_BUSY USART_ISR_BUSY /*!< Busy flag */ 0241 #define LL_USART_ISR_CMF USART_ISR_CMF /*!< Character match flag */ 0242 #define LL_USART_ISR_SBKF USART_ISR_SBKF /*!< Send break flag */ 0243 #define LL_USART_ISR_RWU USART_ISR_RWU /*!< Receiver wakeup from Mute mode flag */ 0244 #define LL_USART_ISR_WUF USART_ISR_WUF /*!< Wakeup from Stop mode flag */ 0245 #define LL_USART_ISR_TEACK USART_ISR_TEACK /*!< Transmit enable acknowledge flag */ 0246 #define LL_USART_ISR_REACK USART_ISR_REACK /*!< Receive enable acknowledge flag */ 0247 #define LL_USART_ISR_TXFE USART_ISR_TXFE /*!< TX FIFO empty flag */ 0248 #define LL_USART_ISR_RXFF USART_ISR_RXFF /*!< RX FIFO full flag */ 0249 #define LL_USART_ISR_TCBGT USART_ISR_TCBGT /*!< Transmission complete before guard time completion flag */ 0250 #define LL_USART_ISR_RXFT USART_ISR_RXFT /*!< RX FIFO threshold flag */ 0251 #define LL_USART_ISR_TXFT USART_ISR_TXFT /*!< TX FIFO threshold flag */ 0252 /** 0253 * @} 0254 */ 0255 0256 /** @defgroup USART_LL_EC_IT IT Defines 0257 * @ingroup RTEMSBSPsARMSTM32H7 0258 * @brief IT defines which can be used with LL_USART_ReadReg and LL_USART_WriteReg functions 0259 * @{ 0260 */ 0261 #define LL_USART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */ 0262 #define LL_USART_CR1_RXNEIE_RXFNEIE USART_CR1_RXNEIE_RXFNEIE /*!< Read data register and RXFIFO not empty interrupt enable */ 0263 #define LL_USART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */ 0264 #define LL_USART_CR1_TXEIE_TXFNFIE USART_CR1_TXEIE_TXFNFIE /*!< Transmit data register empty and TX FIFO not full interrupt enable */ 0265 #define LL_USART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */ 0266 #define LL_USART_CR1_CMIE USART_CR1_CMIE /*!< Character match interrupt enable */ 0267 #define LL_USART_CR1_RTOIE USART_CR1_RTOIE /*!< Receiver timeout interrupt enable */ 0268 #define LL_USART_CR1_EOBIE USART_CR1_EOBIE /*!< End of Block interrupt enable */ 0269 #define LL_USART_CR1_TXFEIE USART_CR1_TXFEIE /*!< TX FIFO empty interrupt enable */ 0270 #define LL_USART_CR1_RXFFIE USART_CR1_RXFFIE /*!< RX FIFO full interrupt enable */ 0271 #define LL_USART_CR2_LBDIE USART_CR2_LBDIE /*!< LIN break detection interrupt enable */ 0272 #define LL_USART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */ 0273 #define LL_USART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */ 0274 #define LL_USART_CR3_WUFIE USART_CR3_WUFIE /*!< Wakeup from Stop mode interrupt enable */ 0275 #define LL_USART_CR3_TXFTIE USART_CR3_TXFTIE /*!< TX FIFO threshold interrupt enable */ 0276 #define LL_USART_CR3_TCBGTIE USART_CR3_TCBGTIE /*!< Transmission complete before guard time interrupt enable */ 0277 #define LL_USART_CR3_RXFTIE USART_CR3_RXFTIE /*!< RX FIFO threshold interrupt enable */ 0278 /** 0279 * @} 0280 */ 0281 0282 /** @defgroup USART_LL_EC_FIFOTHRESHOLD FIFO Threshold 0283 * @ingroup RTEMSBSPsARMSTM32H7 0284 * @{ 0285 */ 0286 #define LL_USART_FIFOTHRESHOLD_1_8 0x00000000U /*!< FIFO reaches 1/8 of its depth */ 0287 #define LL_USART_FIFOTHRESHOLD_1_4 0x00000001U /*!< FIFO reaches 1/4 of its depth */ 0288 #define LL_USART_FIFOTHRESHOLD_1_2 0x00000002U /*!< FIFO reaches 1/2 of its depth */ 0289 #define LL_USART_FIFOTHRESHOLD_3_4 0x00000003U /*!< FIFO reaches 3/4 of its depth */ 0290 #define LL_USART_FIFOTHRESHOLD_7_8 0x00000004U /*!< FIFO reaches 7/8 of its depth */ 0291 #define LL_USART_FIFOTHRESHOLD_8_8 0x00000005U /*!< FIFO becomes empty for TX and full for RX */ 0292 /** 0293 * @} 0294 */ 0295 0296 /** @defgroup USART_LL_EC_DIRECTION Communication Direction 0297 * @ingroup RTEMSBSPsARMSTM32H7 0298 * @{ 0299 */ 0300 #define LL_USART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */ 0301 #define LL_USART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */ 0302 #define LL_USART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */ 0303 #define LL_USART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */ 0304 /** 0305 * @} 0306 */ 0307 0308 /** @defgroup USART_LL_EC_PARITY Parity Control 0309 * @ingroup RTEMSBSPsARMSTM32H7 0310 * @{ 0311 */ 0312 #define LL_USART_PARITY_NONE 0x00000000U /*!< Parity control disabled */ 0313 #define LL_USART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */ 0314 #define LL_USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */ 0315 /** 0316 * @} 0317 */ 0318 0319 /** @defgroup USART_LL_EC_WAKEUP Wakeup 0320 * @ingroup RTEMSBSPsARMSTM32H7 0321 * @{ 0322 */ 0323 #define LL_USART_WAKEUP_IDLELINE 0x00000000U /*!< USART wake up from Mute mode on Idle Line */ 0324 #define LL_USART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< USART wake up from Mute mode on Address Mark */ 0325 /** 0326 * @} 0327 */ 0328 0329 /** @defgroup USART_LL_EC_DATAWIDTH Datawidth 0330 * @ingroup RTEMSBSPsARMSTM32H7 0331 * @{ 0332 */ 0333 #define LL_USART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */ 0334 #define LL_USART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */ 0335 #define LL_USART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */ 0336 /** 0337 * @} 0338 */ 0339 0340 /** @defgroup USART_LL_EC_OVERSAMPLING Oversampling 0341 * @ingroup RTEMSBSPsARMSTM32H7 0342 * @{ 0343 */ 0344 #define LL_USART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */ 0345 #define LL_USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */ 0346 /** 0347 * @} 0348 */ 0349 0350 #if defined(USE_FULL_LL_DRIVER) || defined(__rtems__) 0351 /** @defgroup USART_LL_EC_CLOCK Clock Signal 0352 * @ingroup RTEMSBSPsARMSTM32H7 0353 * @{ 0354 */ 0355 0356 #define LL_USART_CLOCK_DISABLE 0x00000000U /*!< Clock signal not provided */ 0357 #define LL_USART_CLOCK_ENABLE USART_CR2_CLKEN /*!< Clock signal provided */ 0358 /** 0359 * @} 0360 */ 0361 #endif /*USE_FULL_LL_DRIVER*/ 0362 0363 /** @defgroup USART_LL_EC_LASTCLKPULSE Last Clock Pulse 0364 * @ingroup RTEMSBSPsARMSTM32H7 0365 * @{ 0366 */ 0367 #define LL_USART_LASTCLKPULSE_NO_OUTPUT 0x00000000U /*!< The clock pulse of the last data bit is not output to the SCLK pin */ 0368 #define LL_USART_LASTCLKPULSE_OUTPUT USART_CR2_LBCL /*!< The clock pulse of the last data bit is output to the SCLK pin */ 0369 /** 0370 * @} 0371 */ 0372 0373 /** @defgroup USART_LL_EC_PHASE Clock Phase 0374 * @ingroup RTEMSBSPsARMSTM32H7 0375 * @{ 0376 */ 0377 #define LL_USART_PHASE_1EDGE 0x00000000U /*!< The first clock transition is the first data capture edge */ 0378 #define LL_USART_PHASE_2EDGE USART_CR2_CPHA /*!< The second clock transition is the first data capture edge */ 0379 /** 0380 * @} 0381 */ 0382 0383 /** @defgroup USART_LL_EC_POLARITY Clock Polarity 0384 * @ingroup RTEMSBSPsARMSTM32H7 0385 * @{ 0386 */ 0387 #define LL_USART_POLARITY_LOW 0x00000000U /*!< Steady low value on SCLK pin outside transmission window*/ 0388 #define LL_USART_POLARITY_HIGH USART_CR2_CPOL /*!< Steady high value on SCLK pin outside transmission window */ 0389 /** 0390 * @} 0391 */ 0392 0393 /** @defgroup USART_LL_EC_PRESCALER Clock Source Prescaler 0394 * @ingroup RTEMSBSPsARMSTM32H7 0395 * @{ 0396 */ 0397 #define LL_USART_PRESCALER_DIV1 0x00000000U /*!< Input clock not divided */ 0398 #define LL_USART_PRESCALER_DIV2 (USART_PRESC_PRESCALER_0) /*!< Input clock divided by 2 */ 0399 #define LL_USART_PRESCALER_DIV4 (USART_PRESC_PRESCALER_1) /*!< Input clock divided by 4 */ 0400 #define LL_USART_PRESCALER_DIV6 (USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 6 */ 0401 #define LL_USART_PRESCALER_DIV8 (USART_PRESC_PRESCALER_2) /*!< Input clock divided by 8 */ 0402 #define LL_USART_PRESCALER_DIV10 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 10 */ 0403 #define LL_USART_PRESCALER_DIV12 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_1) /*!< Input clock divided by 12 */ 0404 #define LL_USART_PRESCALER_DIV16 (USART_PRESC_PRESCALER_2 | USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 16 */ 0405 #define LL_USART_PRESCALER_DIV32 (USART_PRESC_PRESCALER_3) /*!< Input clock divided by 32 */ 0406 #define LL_USART_PRESCALER_DIV64 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 64 */ 0407 #define LL_USART_PRESCALER_DIV128 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_1) /*!< Input clock divided by 128 */ 0408 #define LL_USART_PRESCALER_DIV256 (USART_PRESC_PRESCALER_3 | USART_PRESC_PRESCALER_1 | USART_PRESC_PRESCALER_0) /*!< Input clock divided by 256 */ 0409 /** 0410 * @} 0411 */ 0412 0413 /** @defgroup USART_LL_EC_STOPBITS Stop Bits 0414 * @ingroup RTEMSBSPsARMSTM32H7 0415 * @{ 0416 */ 0417 #define LL_USART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< 0.5 stop bit */ 0418 #define LL_USART_STOPBITS_1 0x00000000U /*!< 1 stop bit */ 0419 #define LL_USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< 1.5 stop bits */ 0420 #define LL_USART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */ 0421 /** 0422 * @} 0423 */ 0424 0425 /** @defgroup USART_LL_EC_TXRX TX RX Pins Swap 0426 * @ingroup RTEMSBSPsARMSTM32H7 0427 * @{ 0428 */ 0429 #define LL_USART_TXRX_STANDARD 0x00000000U /*!< TX/RX pins are used as defined in standard pinout */ 0430 #define LL_USART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */ 0431 /** 0432 * @} 0433 */ 0434 0435 /** @defgroup USART_LL_EC_RXPIN_LEVEL RX Pin Active Level Inversion 0436 * @ingroup RTEMSBSPsARMSTM32H7 0437 * @{ 0438 */ 0439 #define LL_USART_RXPIN_LEVEL_STANDARD 0x00000000U /*!< RX pin signal works using the standard logic levels */ 0440 #define LL_USART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */ 0441 /** 0442 * @} 0443 */ 0444 0445 /** @defgroup USART_LL_EC_TXPIN_LEVEL TX Pin Active Level Inversion 0446 * @ingroup RTEMSBSPsARMSTM32H7 0447 * @{ 0448 */ 0449 #define LL_USART_TXPIN_LEVEL_STANDARD 0x00000000U /*!< TX pin signal works using the standard logic levels */ 0450 #define LL_USART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */ 0451 /** 0452 * @} 0453 */ 0454 0455 /** @defgroup USART_LL_EC_BINARY_LOGIC Binary Data Inversion 0456 * @ingroup RTEMSBSPsARMSTM32H7 0457 * @{ 0458 */ 0459 #define LL_USART_BINARY_LOGIC_POSITIVE 0x00000000U /*!< Logical data from the data register are send/received in positive/direct logic. (1=H, 0=L) */ 0460 #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. */ 0461 /** 0462 * @} 0463 */ 0464 0465 /** @defgroup USART_LL_EC_BITORDER Bit Order 0466 * @ingroup RTEMSBSPsARMSTM32H7 0467 * @{ 0468 */ 0469 #define LL_USART_BITORDER_LSBFIRST 0x00000000U /*!< data is transmitted/received with data bit 0 first, following the start bit */ 0470 #define LL_USART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first, following the start bit */ 0471 /** 0472 * @} 0473 */ 0474 0475 /** @defgroup USART_LL_EC_AUTOBAUD_DETECT_ON Autobaud Detection 0476 * @ingroup RTEMSBSPsARMSTM32H7 0477 * @{ 0478 */ 0479 #define LL_USART_AUTOBAUD_DETECT_ON_STARTBIT 0x00000000U /*!< Measurement of the start bit is used to detect the baud rate */ 0480 #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 */ 0481 #define LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME USART_CR2_ABRMODE_1 /*!< 0x7F frame detection */ 0482 #define LL_USART_AUTOBAUD_DETECT_ON_55_FRAME (USART_CR2_ABRMODE_1 | USART_CR2_ABRMODE_0) /*!< 0x55 frame detection */ 0483 /** 0484 * @} 0485 */ 0486 0487 /** @defgroup USART_LL_EC_ADDRESS_DETECT Address Length Detection 0488 * @ingroup RTEMSBSPsARMSTM32H7 0489 * @{ 0490 */ 0491 #define LL_USART_ADDRESS_DETECT_4B 0x00000000U /*!< 4-bit address detection method selected */ 0492 #define LL_USART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */ 0493 /** 0494 * @} 0495 */ 0496 0497 /** @defgroup USART_LL_EC_HWCONTROL Hardware Control 0498 * @ingroup RTEMSBSPsARMSTM32H7 0499 * @{ 0500 */ 0501 #define LL_USART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */ 0502 #define LL_USART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */ 0503 #define LL_USART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */ 0504 #define LL_USART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */ 0505 /** 0506 * @} 0507 */ 0508 0509 /** @defgroup USART_LL_EC_WAKEUP_ON Wakeup Activation 0510 * @ingroup RTEMSBSPsARMSTM32H7 0511 * @{ 0512 */ 0513 #define LL_USART_WAKEUP_ON_ADDRESS 0x00000000U /*!< Wake up active on address match */ 0514 #define LL_USART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wake up active on Start bit detection */ 0515 #define LL_USART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wake up active on RXNE */ 0516 /** 0517 * @} 0518 */ 0519 0520 /** @defgroup USART_LL_EC_IRDA_POWER IrDA Power 0521 * @ingroup RTEMSBSPsARMSTM32H7 0522 * @{ 0523 */ 0524 #define LL_USART_IRDA_POWER_NORMAL 0x00000000U /*!< IrDA normal power mode */ 0525 #define LL_USART_IRDA_POWER_LOW USART_CR3_IRLP /*!< IrDA low power mode */ 0526 /** 0527 * @} 0528 */ 0529 0530 /** @defgroup USART_LL_EC_LINBREAK_DETECT LIN Break Detection Length 0531 * @ingroup RTEMSBSPsARMSTM32H7 0532 * @{ 0533 */ 0534 #define LL_USART_LINBREAK_DETECT_10B 0x00000000U /*!< 10-bit break detection method selected */ 0535 #define LL_USART_LINBREAK_DETECT_11B USART_CR2_LBDL /*!< 11-bit break detection method selected */ 0536 /** 0537 * @} 0538 */ 0539 0540 /** @defgroup USART_LL_EC_DE_POLARITY Driver Enable Polarity 0541 * @ingroup RTEMSBSPsARMSTM32H7 0542 * @{ 0543 */ 0544 #define LL_USART_DE_POLARITY_HIGH 0x00000000U /*!< DE signal is active high */ 0545 #define LL_USART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */ 0546 /** 0547 * @} 0548 */ 0549 0550 /** @defgroup USART_LL_EC_DMA_REG_DATA DMA Register Data 0551 * @ingroup RTEMSBSPsARMSTM32H7 0552 * @{ 0553 */ 0554 #define LL_USART_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */ 0555 #define LL_USART_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */ 0556 /** 0557 * @} 0558 */ 0559 0560 /** 0561 * @} 0562 */ 0563 0564 /* Exported macro ------------------------------------------------------------*/ 0565 /** @defgroup USART_LL_Exported_Macros USART Exported Macros 0566 * @ingroup RTEMSBSPsARMSTM32H7 0567 * @{ 0568 */ 0569 0570 /** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros 0571 * @ingroup RTEMSBSPsARMSTM32H7 0572 * @{ 0573 */ 0574 0575 /** 0576 * @brief Write a value in USART register 0577 * @param __INSTANCE__ USART Instance 0578 * @param __REG__ Register to be written 0579 * @param __VALUE__ Value to be written in the register 0580 * @retval None 0581 */ 0582 #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 0583 0584 /** 0585 * @brief Read a value in USART register 0586 * @param __INSTANCE__ USART Instance 0587 * @param __REG__ Register to be read 0588 * @retval Register value 0589 */ 0590 #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 0591 /** 0592 * @} 0593 */ 0594 0595 /** @defgroup USART_LL_EM_Exported_Macros_Helper Exported_Macros_Helper 0596 * @ingroup RTEMSBSPsARMSTM32H7 0597 * @{ 0598 */ 0599 0600 /** 0601 * @brief Compute USARTDIV value according to Peripheral Clock and 0602 * expected Baud Rate in 8 bits sampling mode (32 bits value of USARTDIV is returned) 0603 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance 0604 * @param __PRESCALER__ This parameter can be one of the following values: 0605 * @arg @ref LL_USART_PRESCALER_DIV1 0606 * @arg @ref LL_USART_PRESCALER_DIV2 0607 * @arg @ref LL_USART_PRESCALER_DIV4 0608 * @arg @ref LL_USART_PRESCALER_DIV6 0609 * @arg @ref LL_USART_PRESCALER_DIV8 0610 * @arg @ref LL_USART_PRESCALER_DIV10 0611 * @arg @ref LL_USART_PRESCALER_DIV12 0612 * @arg @ref LL_USART_PRESCALER_DIV16 0613 * @arg @ref LL_USART_PRESCALER_DIV32 0614 * @arg @ref LL_USART_PRESCALER_DIV64 0615 * @arg @ref LL_USART_PRESCALER_DIV128 0616 * @arg @ref LL_USART_PRESCALER_DIV256 0617 * @param __BAUDRATE__ Baud rate value to achieve 0618 * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case 0619 */ 0620 #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __PRESCALER__, __BAUDRATE__) \ 0621 (((((__PERIPHCLK__)/(USART_PRESCALER_TAB[(__PRESCALER__)]))*2U)\ 0622 + ((__BAUDRATE__)/2U))/(__BAUDRATE__)) 0623 0624 /** 0625 * @brief Compute USARTDIV value according to Peripheral Clock and 0626 * expected Baud Rate in 16 bits sampling mode (32 bits value of USARTDIV is returned) 0627 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance 0628 * @param __PRESCALER__ This parameter can be one of the following values: 0629 * @arg @ref LL_USART_PRESCALER_DIV1 0630 * @arg @ref LL_USART_PRESCALER_DIV2 0631 * @arg @ref LL_USART_PRESCALER_DIV4 0632 * @arg @ref LL_USART_PRESCALER_DIV6 0633 * @arg @ref LL_USART_PRESCALER_DIV8 0634 * @arg @ref LL_USART_PRESCALER_DIV10 0635 * @arg @ref LL_USART_PRESCALER_DIV12 0636 * @arg @ref LL_USART_PRESCALER_DIV16 0637 * @arg @ref LL_USART_PRESCALER_DIV32 0638 * @arg @ref LL_USART_PRESCALER_DIV64 0639 * @arg @ref LL_USART_PRESCALER_DIV128 0640 * @arg @ref LL_USART_PRESCALER_DIV256 0641 * @param __BAUDRATE__ Baud rate value to achieve 0642 * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case 0643 */ 0644 #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __PRESCALER__, __BAUDRATE__) \ 0645 ((((__PERIPHCLK__)/(USART_PRESCALER_TAB[(__PRESCALER__)]))\ 0646 + ((__BAUDRATE__)/2U))/(__BAUDRATE__)) 0647 0648 /** 0649 * @} 0650 */ 0651 0652 /** 0653 * @} 0654 */ 0655 0656 /* Exported functions --------------------------------------------------------*/ 0657 0658 /** @defgroup USART_LL_Exported_Functions USART Exported Functions 0659 * @ingroup RTEMSBSPsARMSTM32H7 0660 * @{ 0661 */ 0662 0663 /** @defgroup USART_LL_EF_Configuration Configuration functions 0664 * @ingroup RTEMSBSPsARMSTM32H7 0665 * @{ 0666 */ 0667 0668 /** 0669 * @brief USART Enable 0670 * @rmtoll CR1 UE LL_USART_Enable 0671 * @param USARTx USART Instance 0672 * @retval None 0673 */ 0674 __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx) 0675 { 0676 SET_BIT(USARTx->CR1, USART_CR1_UE); 0677 } 0678 0679 /** 0680 * @brief USART Disable (all USART prescalers and outputs are disabled) 0681 * @note When USART is disabled, USART prescalers and outputs are stopped immediately, 0682 * and current operations are discarded. The configuration of the USART is kept, but all the status 0683 * flags, in the USARTx_ISR are set to their default values. 0684 * @rmtoll CR1 UE LL_USART_Disable 0685 * @param USARTx USART Instance 0686 * @retval None 0687 */ 0688 __STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx) 0689 { 0690 CLEAR_BIT(USARTx->CR1, USART_CR1_UE); 0691 } 0692 0693 /** 0694 * @brief Indicate if USART is enabled 0695 * @rmtoll CR1 UE LL_USART_IsEnabled 0696 * @param USARTx USART Instance 0697 * @retval State of bit (1 or 0). 0698 */ 0699 __STATIC_INLINE uint32_t LL_USART_IsEnabled(const USART_TypeDef *USARTx) 0700 { 0701 return ((READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE)) ? 1UL : 0UL); 0702 } 0703 0704 /** 0705 * @brief FIFO Mode Enable 0706 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 0707 * FIFO mode feature is supported by the USARTx instance. 0708 * @rmtoll CR1 FIFOEN LL_USART_EnableFIFO 0709 * @param USARTx USART Instance 0710 * @retval None 0711 */ 0712 __STATIC_INLINE void LL_USART_EnableFIFO(USART_TypeDef *USARTx) 0713 { 0714 SET_BIT(USARTx->CR1, USART_CR1_FIFOEN); 0715 } 0716 0717 /** 0718 * @brief FIFO Mode Disable 0719 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 0720 * FIFO mode feature is supported by the USARTx instance. 0721 * @rmtoll CR1 FIFOEN LL_USART_DisableFIFO 0722 * @param USARTx USART Instance 0723 * @retval None 0724 */ 0725 __STATIC_INLINE void LL_USART_DisableFIFO(USART_TypeDef *USARTx) 0726 { 0727 CLEAR_BIT(USARTx->CR1, USART_CR1_FIFOEN); 0728 } 0729 0730 /** 0731 * @brief Indicate if FIFO Mode is enabled 0732 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 0733 * FIFO mode feature is supported by the USARTx instance. 0734 * @rmtoll CR1 FIFOEN LL_USART_IsEnabledFIFO 0735 * @param USARTx USART Instance 0736 * @retval State of bit (1 or 0). 0737 */ 0738 __STATIC_INLINE uint32_t LL_USART_IsEnabledFIFO(const USART_TypeDef *USARTx) 0739 { 0740 return ((READ_BIT(USARTx->CR1, USART_CR1_FIFOEN) == (USART_CR1_FIFOEN)) ? 1UL : 0UL); 0741 } 0742 0743 /** 0744 * @brief Configure TX FIFO Threshold 0745 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 0746 * FIFO mode feature is supported by the USARTx instance. 0747 * @rmtoll CR3 TXFTCFG LL_USART_SetTXFIFOThreshold 0748 * @param USARTx USART Instance 0749 * @param Threshold This parameter can be one of the following values: 0750 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8 0751 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4 0752 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2 0753 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4 0754 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8 0755 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8 0756 * @retval None 0757 */ 0758 __STATIC_INLINE void LL_USART_SetTXFIFOThreshold(USART_TypeDef *USARTx, uint32_t Threshold) 0759 { 0760 ATOMIC_MODIFY_REG(USARTx->CR3, USART_CR3_TXFTCFG, Threshold << USART_CR3_TXFTCFG_Pos); 0761 } 0762 0763 /** 0764 * @brief Return TX FIFO Threshold Configuration 0765 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 0766 * FIFO mode feature is supported by the USARTx instance. 0767 * @rmtoll CR3 TXFTCFG LL_USART_GetTXFIFOThreshold 0768 * @param USARTx USART Instance 0769 * @retval Returned value can be one of the following values: 0770 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8 0771 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4 0772 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2 0773 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4 0774 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8 0775 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8 0776 */ 0777 __STATIC_INLINE uint32_t LL_USART_GetTXFIFOThreshold(const USART_TypeDef *USARTx) 0778 { 0779 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_TXFTCFG) >> USART_CR3_TXFTCFG_Pos); 0780 } 0781 0782 /** 0783 * @brief Configure RX FIFO Threshold 0784 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 0785 * FIFO mode feature is supported by the USARTx instance. 0786 * @rmtoll CR3 RXFTCFG LL_USART_SetRXFIFOThreshold 0787 * @param USARTx USART Instance 0788 * @param Threshold This parameter can be one of the following values: 0789 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8 0790 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4 0791 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2 0792 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4 0793 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8 0794 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8 0795 * @retval None 0796 */ 0797 __STATIC_INLINE void LL_USART_SetRXFIFOThreshold(USART_TypeDef *USARTx, uint32_t Threshold) 0798 { 0799 ATOMIC_MODIFY_REG(USARTx->CR3, USART_CR3_RXFTCFG, Threshold << USART_CR3_RXFTCFG_Pos); 0800 } 0801 0802 /** 0803 * @brief Return RX FIFO Threshold Configuration 0804 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 0805 * FIFO mode feature is supported by the USARTx instance. 0806 * @rmtoll CR3 RXFTCFG LL_USART_GetRXFIFOThreshold 0807 * @param USARTx USART Instance 0808 * @retval Returned value can be one of the following values: 0809 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8 0810 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4 0811 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2 0812 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4 0813 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8 0814 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8 0815 */ 0816 __STATIC_INLINE uint32_t LL_USART_GetRXFIFOThreshold(const USART_TypeDef *USARTx) 0817 { 0818 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RXFTCFG) >> USART_CR3_RXFTCFG_Pos); 0819 } 0820 0821 /** 0822 * @brief Configure TX and RX FIFOs Threshold 0823 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 0824 * FIFO mode feature is supported by the USARTx instance. 0825 * @rmtoll CR3 TXFTCFG LL_USART_ConfigFIFOsThreshold\n 0826 * CR3 RXFTCFG LL_USART_ConfigFIFOsThreshold 0827 * @param USARTx USART Instance 0828 * @param TXThreshold This parameter can be one of the following values: 0829 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8 0830 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4 0831 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2 0832 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4 0833 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8 0834 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8 0835 * @param RXThreshold This parameter can be one of the following values: 0836 * @arg @ref LL_USART_FIFOTHRESHOLD_1_8 0837 * @arg @ref LL_USART_FIFOTHRESHOLD_1_4 0838 * @arg @ref LL_USART_FIFOTHRESHOLD_1_2 0839 * @arg @ref LL_USART_FIFOTHRESHOLD_3_4 0840 * @arg @ref LL_USART_FIFOTHRESHOLD_7_8 0841 * @arg @ref LL_USART_FIFOTHRESHOLD_8_8 0842 * @retval None 0843 */ 0844 __STATIC_INLINE void LL_USART_ConfigFIFOsThreshold(USART_TypeDef *USARTx, uint32_t TXThreshold, uint32_t RXThreshold) 0845 { 0846 ATOMIC_MODIFY_REG(USARTx->CR3, USART_CR3_TXFTCFG | USART_CR3_RXFTCFG, (TXThreshold << USART_CR3_TXFTCFG_Pos) | 0847 (RXThreshold << USART_CR3_RXFTCFG_Pos)); 0848 } 0849 0850 /** 0851 * @brief USART enabled in STOP Mode. 0852 * @note When this function is enabled, USART is able to wake up the MCU from Stop mode, provided that 0853 * USART clock selection is HSI or LSE in RCC. 0854 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 0855 * Wake-up from Stop mode feature is supported by the USARTx instance. 0856 * @rmtoll CR1 UESM LL_USART_EnableInStopMode 0857 * @param USARTx USART Instance 0858 * @retval None 0859 */ 0860 __STATIC_INLINE void LL_USART_EnableInStopMode(USART_TypeDef *USARTx) 0861 { 0862 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_UESM); 0863 } 0864 0865 /** 0866 * @brief USART disabled in STOP Mode. 0867 * @note When this function is disabled, USART is not able to wake up the MCU from Stop mode 0868 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 0869 * Wake-up from Stop mode feature is supported by the USARTx instance. 0870 * @rmtoll CR1 UESM LL_USART_DisableInStopMode 0871 * @param USARTx USART Instance 0872 * @retval None 0873 */ 0874 __STATIC_INLINE void LL_USART_DisableInStopMode(USART_TypeDef *USARTx) 0875 { 0876 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_UESM); 0877 } 0878 0879 /** 0880 * @brief Indicate if USART is enabled in STOP Mode (able to wake up MCU from Stop mode or not) 0881 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 0882 * Wake-up from Stop mode feature is supported by the USARTx instance. 0883 * @rmtoll CR1 UESM LL_USART_IsEnabledInStopMode 0884 * @param USARTx USART Instance 0885 * @retval State of bit (1 or 0). 0886 */ 0887 __STATIC_INLINE uint32_t LL_USART_IsEnabledInStopMode(const USART_TypeDef *USARTx) 0888 { 0889 return ((READ_BIT(USARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM)) ? 1UL : 0UL); 0890 } 0891 0892 /** 0893 * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit) 0894 * @rmtoll CR1 RE LL_USART_EnableDirectionRx 0895 * @param USARTx USART Instance 0896 * @retval None 0897 */ 0898 __STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx) 0899 { 0900 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_RE); 0901 } 0902 0903 /** 0904 * @brief Receiver Disable 0905 * @rmtoll CR1 RE LL_USART_DisableDirectionRx 0906 * @param USARTx USART Instance 0907 * @retval None 0908 */ 0909 __STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx) 0910 { 0911 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_RE); 0912 } 0913 0914 /** 0915 * @brief Transmitter Enable 0916 * @rmtoll CR1 TE LL_USART_EnableDirectionTx 0917 * @param USARTx USART Instance 0918 * @retval None 0919 */ 0920 __STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx) 0921 { 0922 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_TE); 0923 } 0924 0925 /** 0926 * @brief Transmitter Disable 0927 * @rmtoll CR1 TE LL_USART_DisableDirectionTx 0928 * @param USARTx USART Instance 0929 * @retval None 0930 */ 0931 __STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx) 0932 { 0933 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_TE); 0934 } 0935 0936 /** 0937 * @brief Configure simultaneously enabled/disabled states 0938 * of Transmitter and Receiver 0939 * @rmtoll CR1 RE LL_USART_SetTransferDirection\n 0940 * CR1 TE LL_USART_SetTransferDirection 0941 * @param USARTx USART Instance 0942 * @param TransferDirection This parameter can be one of the following values: 0943 * @arg @ref LL_USART_DIRECTION_NONE 0944 * @arg @ref LL_USART_DIRECTION_RX 0945 * @arg @ref LL_USART_DIRECTION_TX 0946 * @arg @ref LL_USART_DIRECTION_TX_RX 0947 * @retval None 0948 */ 0949 __STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t TransferDirection) 0950 { 0951 ATOMIC_MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection); 0952 } 0953 0954 /** 0955 * @brief Return enabled/disabled states of Transmitter and Receiver 0956 * @rmtoll CR1 RE LL_USART_GetTransferDirection\n 0957 * CR1 TE LL_USART_GetTransferDirection 0958 * @param USARTx USART Instance 0959 * @retval Returned value can be one of the following values: 0960 * @arg @ref LL_USART_DIRECTION_NONE 0961 * @arg @ref LL_USART_DIRECTION_RX 0962 * @arg @ref LL_USART_DIRECTION_TX 0963 * @arg @ref LL_USART_DIRECTION_TX_RX 0964 */ 0965 __STATIC_INLINE uint32_t LL_USART_GetTransferDirection(const USART_TypeDef *USARTx) 0966 { 0967 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE)); 0968 } 0969 0970 /** 0971 * @brief Configure Parity (enabled/disabled and parity mode if enabled). 0972 * @note This function selects if hardware parity control (generation and detection) is enabled or disabled. 0973 * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position 0974 * (9th or 8th bit depending on data width) and parity is checked on the received data. 0975 * @rmtoll CR1 PS LL_USART_SetParity\n 0976 * CR1 PCE LL_USART_SetParity 0977 * @param USARTx USART Instance 0978 * @param Parity This parameter can be one of the following values: 0979 * @arg @ref LL_USART_PARITY_NONE 0980 * @arg @ref LL_USART_PARITY_EVEN 0981 * @arg @ref LL_USART_PARITY_ODD 0982 * @retval None 0983 */ 0984 __STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t Parity) 0985 { 0986 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity); 0987 } 0988 0989 /** 0990 * @brief Return Parity configuration (enabled/disabled and parity mode if enabled) 0991 * @rmtoll CR1 PS LL_USART_GetParity\n 0992 * CR1 PCE LL_USART_GetParity 0993 * @param USARTx USART Instance 0994 * @retval Returned value can be one of the following values: 0995 * @arg @ref LL_USART_PARITY_NONE 0996 * @arg @ref LL_USART_PARITY_EVEN 0997 * @arg @ref LL_USART_PARITY_ODD 0998 */ 0999 __STATIC_INLINE uint32_t LL_USART_GetParity(const USART_TypeDef *USARTx) 1000 { 1001 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE)); 1002 } 1003 1004 /** 1005 * @brief Set Receiver Wake Up method from Mute mode. 1006 * @rmtoll CR1 WAKE LL_USART_SetWakeUpMethod 1007 * @param USARTx USART Instance 1008 * @param Method This parameter can be one of the following values: 1009 * @arg @ref LL_USART_WAKEUP_IDLELINE 1010 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK 1011 * @retval None 1012 */ 1013 __STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method) 1014 { 1015 MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method); 1016 } 1017 1018 /** 1019 * @brief Return Receiver Wake Up method from Mute mode 1020 * @rmtoll CR1 WAKE LL_USART_GetWakeUpMethod 1021 * @param USARTx USART Instance 1022 * @retval Returned value can be one of the following values: 1023 * @arg @ref LL_USART_WAKEUP_IDLELINE 1024 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK 1025 */ 1026 __STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(const USART_TypeDef *USARTx) 1027 { 1028 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE)); 1029 } 1030 1031 /** 1032 * @brief Set Word length (i.e. nb of data bits, excluding start and stop bits) 1033 * @rmtoll CR1 M0 LL_USART_SetDataWidth\n 1034 * CR1 M1 LL_USART_SetDataWidth 1035 * @param USARTx USART Instance 1036 * @param DataWidth This parameter can be one of the following values: 1037 * @arg @ref LL_USART_DATAWIDTH_7B 1038 * @arg @ref LL_USART_DATAWIDTH_8B 1039 * @arg @ref LL_USART_DATAWIDTH_9B 1040 * @retval None 1041 */ 1042 __STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth) 1043 { 1044 MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth); 1045 } 1046 1047 /** 1048 * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits) 1049 * @rmtoll CR1 M0 LL_USART_GetDataWidth\n 1050 * CR1 M1 LL_USART_GetDataWidth 1051 * @param USARTx USART Instance 1052 * @retval Returned value can be one of the following values: 1053 * @arg @ref LL_USART_DATAWIDTH_7B 1054 * @arg @ref LL_USART_DATAWIDTH_8B 1055 * @arg @ref LL_USART_DATAWIDTH_9B 1056 */ 1057 __STATIC_INLINE uint32_t LL_USART_GetDataWidth(const USART_TypeDef *USARTx) 1058 { 1059 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M)); 1060 } 1061 1062 /** 1063 * @brief Allow switch between Mute Mode and Active mode 1064 * @rmtoll CR1 MME LL_USART_EnableMuteMode 1065 * @param USARTx USART Instance 1066 * @retval None 1067 */ 1068 __STATIC_INLINE void LL_USART_EnableMuteMode(USART_TypeDef *USARTx) 1069 { 1070 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_MME); 1071 } 1072 1073 /** 1074 * @brief Prevent Mute Mode use. Set Receiver in active mode permanently. 1075 * @rmtoll CR1 MME LL_USART_DisableMuteMode 1076 * @param USARTx USART Instance 1077 * @retval None 1078 */ 1079 __STATIC_INLINE void LL_USART_DisableMuteMode(USART_TypeDef *USARTx) 1080 { 1081 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_MME); 1082 } 1083 1084 /** 1085 * @brief Indicate if switch between Mute Mode and Active mode is allowed 1086 * @rmtoll CR1 MME LL_USART_IsEnabledMuteMode 1087 * @param USARTx USART Instance 1088 * @retval State of bit (1 or 0). 1089 */ 1090 __STATIC_INLINE uint32_t LL_USART_IsEnabledMuteMode(const USART_TypeDef *USARTx) 1091 { 1092 return ((READ_BIT(USARTx->CR1, USART_CR1_MME) == (USART_CR1_MME)) ? 1UL : 0UL); 1093 } 1094 1095 /** 1096 * @brief Set Oversampling to 8-bit or 16-bit mode 1097 * @rmtoll CR1 OVER8 LL_USART_SetOverSampling 1098 * @param USARTx USART Instance 1099 * @param OverSampling This parameter can be one of the following values: 1100 * @arg @ref LL_USART_OVERSAMPLING_16 1101 * @arg @ref LL_USART_OVERSAMPLING_8 1102 * @retval None 1103 */ 1104 __STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling) 1105 { 1106 MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling); 1107 } 1108 1109 /** 1110 * @brief Return Oversampling mode 1111 * @rmtoll CR1 OVER8 LL_USART_GetOverSampling 1112 * @param USARTx USART Instance 1113 * @retval Returned value can be one of the following values: 1114 * @arg @ref LL_USART_OVERSAMPLING_16 1115 * @arg @ref LL_USART_OVERSAMPLING_8 1116 */ 1117 __STATIC_INLINE uint32_t LL_USART_GetOverSampling(const USART_TypeDef *USARTx) 1118 { 1119 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8)); 1120 } 1121 1122 /** 1123 * @brief Configure if Clock pulse of the last data bit is output to the SCLK pin or not 1124 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 1125 * Synchronous mode is supported by the USARTx instance. 1126 * @rmtoll CR2 LBCL LL_USART_SetLastClkPulseOutput 1127 * @param USARTx USART Instance 1128 * @param LastBitClockPulse This parameter can be one of the following values: 1129 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT 1130 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT 1131 * @retval None 1132 */ 1133 __STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LastBitClockPulse) 1134 { 1135 MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LastBitClockPulse); 1136 } 1137 1138 /** 1139 * @brief Retrieve Clock pulse of the last data bit output configuration 1140 * (Last bit Clock pulse output to the SCLK pin or not) 1141 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 1142 * Synchronous mode is supported by the USARTx instance. 1143 * @rmtoll CR2 LBCL LL_USART_GetLastClkPulseOutput 1144 * @param USARTx USART Instance 1145 * @retval Returned value can be one of the following values: 1146 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT 1147 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT 1148 */ 1149 __STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(const USART_TypeDef *USARTx) 1150 { 1151 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL)); 1152 } 1153 1154 /** 1155 * @brief Select the phase of the clock output on the SCLK pin in synchronous mode 1156 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 1157 * Synchronous mode is supported by the USARTx instance. 1158 * @rmtoll CR2 CPHA LL_USART_SetClockPhase 1159 * @param USARTx USART Instance 1160 * @param ClockPhase This parameter can be one of the following values: 1161 * @arg @ref LL_USART_PHASE_1EDGE 1162 * @arg @ref LL_USART_PHASE_2EDGE 1163 * @retval None 1164 */ 1165 __STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t ClockPhase) 1166 { 1167 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, ClockPhase); 1168 } 1169 1170 /** 1171 * @brief Return phase of the clock output on the SCLK pin in synchronous mode 1172 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 1173 * Synchronous mode is supported by the USARTx instance. 1174 * @rmtoll CR2 CPHA LL_USART_GetClockPhase 1175 * @param USARTx USART Instance 1176 * @retval Returned value can be one of the following values: 1177 * @arg @ref LL_USART_PHASE_1EDGE 1178 * @arg @ref LL_USART_PHASE_2EDGE 1179 */ 1180 __STATIC_INLINE uint32_t LL_USART_GetClockPhase(const USART_TypeDef *USARTx) 1181 { 1182 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA)); 1183 } 1184 1185 /** 1186 * @brief Select the polarity of the clock output on the SCLK pin in synchronous mode 1187 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 1188 * Synchronous mode is supported by the USARTx instance. 1189 * @rmtoll CR2 CPOL LL_USART_SetClockPolarity 1190 * @param USARTx USART Instance 1191 * @param ClockPolarity This parameter can be one of the following values: 1192 * @arg @ref LL_USART_POLARITY_LOW 1193 * @arg @ref LL_USART_POLARITY_HIGH 1194 * @retval None 1195 */ 1196 __STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t ClockPolarity) 1197 { 1198 MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, ClockPolarity); 1199 } 1200 1201 /** 1202 * @brief Return polarity of the clock output on the SCLK pin in synchronous mode 1203 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 1204 * Synchronous mode is supported by the USARTx instance. 1205 * @rmtoll CR2 CPOL LL_USART_GetClockPolarity 1206 * @param USARTx USART Instance 1207 * @retval Returned value can be one of the following values: 1208 * @arg @ref LL_USART_POLARITY_LOW 1209 * @arg @ref LL_USART_POLARITY_HIGH 1210 */ 1211 __STATIC_INLINE uint32_t LL_USART_GetClockPolarity(const USART_TypeDef *USARTx) 1212 { 1213 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL)); 1214 } 1215 1216 /** 1217 * @brief Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse) 1218 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 1219 * Synchronous mode is supported by the USARTx instance. 1220 * @note Call of this function is equivalent to following function call sequence : 1221 * - Clock Phase configuration using @ref LL_USART_SetClockPhase() function 1222 * - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function 1223 * - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function 1224 * @rmtoll CR2 CPHA LL_USART_ConfigClock\n 1225 * CR2 CPOL LL_USART_ConfigClock\n 1226 * CR2 LBCL LL_USART_ConfigClock 1227 * @param USARTx USART Instance 1228 * @param Phase This parameter can be one of the following values: 1229 * @arg @ref LL_USART_PHASE_1EDGE 1230 * @arg @ref LL_USART_PHASE_2EDGE 1231 * @param Polarity This parameter can be one of the following values: 1232 * @arg @ref LL_USART_POLARITY_LOW 1233 * @arg @ref LL_USART_POLARITY_HIGH 1234 * @param LBCPOutput This parameter can be one of the following values: 1235 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT 1236 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT 1237 * @retval None 1238 */ 1239 __STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput) 1240 { 1241 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput); 1242 } 1243 1244 /** 1245 * @brief Configure Clock source prescaler for baudrate generator and oversampling 1246 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 1247 * FIFO mode feature is supported by the USARTx instance. 1248 * @rmtoll PRESC PRESCALER LL_USART_SetPrescaler 1249 * @param USARTx USART Instance 1250 * @param PrescalerValue This parameter can be one of the following values: 1251 * @arg @ref LL_USART_PRESCALER_DIV1 1252 * @arg @ref LL_USART_PRESCALER_DIV2 1253 * @arg @ref LL_USART_PRESCALER_DIV4 1254 * @arg @ref LL_USART_PRESCALER_DIV6 1255 * @arg @ref LL_USART_PRESCALER_DIV8 1256 * @arg @ref LL_USART_PRESCALER_DIV10 1257 * @arg @ref LL_USART_PRESCALER_DIV12 1258 * @arg @ref LL_USART_PRESCALER_DIV16 1259 * @arg @ref LL_USART_PRESCALER_DIV32 1260 * @arg @ref LL_USART_PRESCALER_DIV64 1261 * @arg @ref LL_USART_PRESCALER_DIV128 1262 * @arg @ref LL_USART_PRESCALER_DIV256 1263 * @retval None 1264 */ 1265 __STATIC_INLINE void LL_USART_SetPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) 1266 { 1267 MODIFY_REG(USARTx->PRESC, USART_PRESC_PRESCALER, (uint16_t)PrescalerValue); 1268 } 1269 1270 /** 1271 * @brief Retrieve the Clock source prescaler for baudrate generator and oversampling 1272 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 1273 * FIFO mode feature is supported by the USARTx instance. 1274 * @rmtoll PRESC PRESCALER LL_USART_GetPrescaler 1275 * @param USARTx USART Instance 1276 * @retval Returned value can be one of the following values: 1277 * @arg @ref LL_USART_PRESCALER_DIV1 1278 * @arg @ref LL_USART_PRESCALER_DIV2 1279 * @arg @ref LL_USART_PRESCALER_DIV4 1280 * @arg @ref LL_USART_PRESCALER_DIV6 1281 * @arg @ref LL_USART_PRESCALER_DIV8 1282 * @arg @ref LL_USART_PRESCALER_DIV10 1283 * @arg @ref LL_USART_PRESCALER_DIV12 1284 * @arg @ref LL_USART_PRESCALER_DIV16 1285 * @arg @ref LL_USART_PRESCALER_DIV32 1286 * @arg @ref LL_USART_PRESCALER_DIV64 1287 * @arg @ref LL_USART_PRESCALER_DIV128 1288 * @arg @ref LL_USART_PRESCALER_DIV256 1289 */ 1290 __STATIC_INLINE uint32_t LL_USART_GetPrescaler(const USART_TypeDef *USARTx) 1291 { 1292 return (uint32_t)(READ_BIT(USARTx->PRESC, USART_PRESC_PRESCALER)); 1293 } 1294 1295 /** 1296 * @brief Enable Clock output on SCLK pin 1297 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 1298 * Synchronous mode is supported by the USARTx instance. 1299 * @rmtoll CR2 CLKEN LL_USART_EnableSCLKOutput 1300 * @param USARTx USART Instance 1301 * @retval None 1302 */ 1303 __STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx) 1304 { 1305 SET_BIT(USARTx->CR2, USART_CR2_CLKEN); 1306 } 1307 1308 /** 1309 * @brief Disable Clock output on SCLK pin 1310 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 1311 * Synchronous mode is supported by the USARTx instance. 1312 * @rmtoll CR2 CLKEN LL_USART_DisableSCLKOutput 1313 * @param USARTx USART Instance 1314 * @retval None 1315 */ 1316 __STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx) 1317 { 1318 CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN); 1319 } 1320 1321 /** 1322 * @brief Indicate if Clock output on SCLK pin is enabled 1323 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 1324 * Synchronous mode is supported by the USARTx instance. 1325 * @rmtoll CR2 CLKEN LL_USART_IsEnabledSCLKOutput 1326 * @param USARTx USART Instance 1327 * @retval State of bit (1 or 0). 1328 */ 1329 __STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(const USART_TypeDef *USARTx) 1330 { 1331 return ((READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN)) ? 1UL : 0UL); 1332 } 1333 1334 /** 1335 * @brief Set the length of the stop bits 1336 * @rmtoll CR2 STOP LL_USART_SetStopBitsLength 1337 * @param USARTx USART Instance 1338 * @param StopBits This parameter can be one of the following values: 1339 * @arg @ref LL_USART_STOPBITS_0_5 1340 * @arg @ref LL_USART_STOPBITS_1 1341 * @arg @ref LL_USART_STOPBITS_1_5 1342 * @arg @ref LL_USART_STOPBITS_2 1343 * @retval None 1344 */ 1345 __STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits) 1346 { 1347 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits); 1348 } 1349 1350 /** 1351 * @brief Retrieve the length of the stop bits 1352 * @rmtoll CR2 STOP LL_USART_GetStopBitsLength 1353 * @param USARTx USART Instance 1354 * @retval Returned value can be one of the following values: 1355 * @arg @ref LL_USART_STOPBITS_0_5 1356 * @arg @ref LL_USART_STOPBITS_1 1357 * @arg @ref LL_USART_STOPBITS_1_5 1358 * @arg @ref LL_USART_STOPBITS_2 1359 */ 1360 __STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(const USART_TypeDef *USARTx) 1361 { 1362 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP)); 1363 } 1364 1365 /** 1366 * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits) 1367 * @note Call of this function is equivalent to following function call sequence : 1368 * - Data Width configuration using @ref LL_USART_SetDataWidth() function 1369 * - Parity Control and mode configuration using @ref LL_USART_SetParity() function 1370 * - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function 1371 * @rmtoll CR1 PS LL_USART_ConfigCharacter\n 1372 * CR1 PCE LL_USART_ConfigCharacter\n 1373 * CR1 M0 LL_USART_ConfigCharacter\n 1374 * CR1 M1 LL_USART_ConfigCharacter\n 1375 * CR2 STOP LL_USART_ConfigCharacter 1376 * @param USARTx USART Instance 1377 * @param DataWidth This parameter can be one of the following values: 1378 * @arg @ref LL_USART_DATAWIDTH_7B 1379 * @arg @ref LL_USART_DATAWIDTH_8B 1380 * @arg @ref LL_USART_DATAWIDTH_9B 1381 * @param Parity This parameter can be one of the following values: 1382 * @arg @ref LL_USART_PARITY_NONE 1383 * @arg @ref LL_USART_PARITY_EVEN 1384 * @arg @ref LL_USART_PARITY_ODD 1385 * @param StopBits This parameter can be one of the following values: 1386 * @arg @ref LL_USART_STOPBITS_0_5 1387 * @arg @ref LL_USART_STOPBITS_1 1388 * @arg @ref LL_USART_STOPBITS_1_5 1389 * @arg @ref LL_USART_STOPBITS_2 1390 * @retval None 1391 */ 1392 __STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t Parity, 1393 uint32_t StopBits) 1394 { 1395 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth); 1396 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits); 1397 } 1398 1399 /** 1400 * @brief Configure TX/RX pins swapping setting. 1401 * @rmtoll CR2 SWAP LL_USART_SetTXRXSwap 1402 * @param USARTx USART Instance 1403 * @param SwapConfig This parameter can be one of the following values: 1404 * @arg @ref LL_USART_TXRX_STANDARD 1405 * @arg @ref LL_USART_TXRX_SWAPPED 1406 * @retval None 1407 */ 1408 __STATIC_INLINE void LL_USART_SetTXRXSwap(USART_TypeDef *USARTx, uint32_t SwapConfig) 1409 { 1410 MODIFY_REG(USARTx->CR2, USART_CR2_SWAP, SwapConfig); 1411 } 1412 1413 /** 1414 * @brief Retrieve TX/RX pins swapping configuration. 1415 * @rmtoll CR2 SWAP LL_USART_GetTXRXSwap 1416 * @param USARTx USART Instance 1417 * @retval Returned value can be one of the following values: 1418 * @arg @ref LL_USART_TXRX_STANDARD 1419 * @arg @ref LL_USART_TXRX_SWAPPED 1420 */ 1421 __STATIC_INLINE uint32_t LL_USART_GetTXRXSwap(const USART_TypeDef *USARTx) 1422 { 1423 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_SWAP)); 1424 } 1425 1426 /** 1427 * @brief Configure RX pin active level logic 1428 * @rmtoll CR2 RXINV LL_USART_SetRXPinLevel 1429 * @param USARTx USART Instance 1430 * @param PinInvMethod This parameter can be one of the following values: 1431 * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD 1432 * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED 1433 * @retval None 1434 */ 1435 __STATIC_INLINE void LL_USART_SetRXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod) 1436 { 1437 MODIFY_REG(USARTx->CR2, USART_CR2_RXINV, PinInvMethod); 1438 } 1439 1440 /** 1441 * @brief Retrieve RX pin active level logic configuration 1442 * @rmtoll CR2 RXINV LL_USART_GetRXPinLevel 1443 * @param USARTx USART Instance 1444 * @retval Returned value can be one of the following values: 1445 * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD 1446 * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED 1447 */ 1448 __STATIC_INLINE uint32_t LL_USART_GetRXPinLevel(const USART_TypeDef *USARTx) 1449 { 1450 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_RXINV)); 1451 } 1452 1453 /** 1454 * @brief Configure TX pin active level logic 1455 * @rmtoll CR2 TXINV LL_USART_SetTXPinLevel 1456 * @param USARTx USART Instance 1457 * @param PinInvMethod This parameter can be one of the following values: 1458 * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD 1459 * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED 1460 * @retval None 1461 */ 1462 __STATIC_INLINE void LL_USART_SetTXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod) 1463 { 1464 MODIFY_REG(USARTx->CR2, USART_CR2_TXINV, PinInvMethod); 1465 } 1466 1467 /** 1468 * @brief Retrieve TX pin active level logic configuration 1469 * @rmtoll CR2 TXINV LL_USART_GetTXPinLevel 1470 * @param USARTx USART Instance 1471 * @retval Returned value can be one of the following values: 1472 * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD 1473 * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED 1474 */ 1475 __STATIC_INLINE uint32_t LL_USART_GetTXPinLevel(const USART_TypeDef *USARTx) 1476 { 1477 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_TXINV)); 1478 } 1479 1480 /** 1481 * @brief Configure Binary data logic. 1482 * @note Allow to define how Logical data from the data register are send/received : 1483 * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H) 1484 * @rmtoll CR2 DATAINV LL_USART_SetBinaryDataLogic 1485 * @param USARTx USART Instance 1486 * @param DataLogic This parameter can be one of the following values: 1487 * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE 1488 * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE 1489 * @retval None 1490 */ 1491 __STATIC_INLINE void LL_USART_SetBinaryDataLogic(USART_TypeDef *USARTx, uint32_t DataLogic) 1492 { 1493 MODIFY_REG(USARTx->CR2, USART_CR2_DATAINV, DataLogic); 1494 } 1495 1496 /** 1497 * @brief Retrieve Binary data configuration 1498 * @rmtoll CR2 DATAINV LL_USART_GetBinaryDataLogic 1499 * @param USARTx USART Instance 1500 * @retval Returned value can be one of the following values: 1501 * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE 1502 * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE 1503 */ 1504 __STATIC_INLINE uint32_t LL_USART_GetBinaryDataLogic(const USART_TypeDef *USARTx) 1505 { 1506 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_DATAINV)); 1507 } 1508 1509 /** 1510 * @brief Configure transfer bit order (either Less or Most Significant Bit First) 1511 * @note MSB First means data is transmitted/received with the MSB first, following the start bit. 1512 * LSB First means data is transmitted/received with data bit 0 first, following the start bit. 1513 * @rmtoll CR2 MSBFIRST LL_USART_SetTransferBitOrder 1514 * @param USARTx USART Instance 1515 * @param BitOrder This parameter can be one of the following values: 1516 * @arg @ref LL_USART_BITORDER_LSBFIRST 1517 * @arg @ref LL_USART_BITORDER_MSBFIRST 1518 * @retval None 1519 */ 1520 __STATIC_INLINE void LL_USART_SetTransferBitOrder(USART_TypeDef *USARTx, uint32_t BitOrder) 1521 { 1522 MODIFY_REG(USARTx->CR2, USART_CR2_MSBFIRST, BitOrder); 1523 } 1524 1525 /** 1526 * @brief Return transfer bit order (either Less or Most Significant Bit First) 1527 * @note MSB First means data is transmitted/received with the MSB first, following the start bit. 1528 * LSB First means data is transmitted/received with data bit 0 first, following the start bit. 1529 * @rmtoll CR2 MSBFIRST LL_USART_GetTransferBitOrder 1530 * @param USARTx USART Instance 1531 * @retval Returned value can be one of the following values: 1532 * @arg @ref LL_USART_BITORDER_LSBFIRST 1533 * @arg @ref LL_USART_BITORDER_MSBFIRST 1534 */ 1535 __STATIC_INLINE uint32_t LL_USART_GetTransferBitOrder(const USART_TypeDef *USARTx) 1536 { 1537 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_MSBFIRST)); 1538 } 1539 1540 /** 1541 * @brief Enable Auto Baud-Rate Detection 1542 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 1543 * Auto Baud Rate detection feature is supported by the USARTx instance. 1544 * @rmtoll CR2 ABREN LL_USART_EnableAutoBaudRate 1545 * @param USARTx USART Instance 1546 * @retval None 1547 */ 1548 __STATIC_INLINE void LL_USART_EnableAutoBaudRate(USART_TypeDef *USARTx) 1549 { 1550 SET_BIT(USARTx->CR2, USART_CR2_ABREN); 1551 } 1552 1553 /** 1554 * @brief Disable Auto Baud-Rate Detection 1555 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 1556 * Auto Baud Rate detection feature is supported by the USARTx instance. 1557 * @rmtoll CR2 ABREN LL_USART_DisableAutoBaudRate 1558 * @param USARTx USART Instance 1559 * @retval None 1560 */ 1561 __STATIC_INLINE void LL_USART_DisableAutoBaudRate(USART_TypeDef *USARTx) 1562 { 1563 CLEAR_BIT(USARTx->CR2, USART_CR2_ABREN); 1564 } 1565 1566 /** 1567 * @brief Indicate if Auto Baud-Rate Detection mechanism is enabled 1568 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 1569 * Auto Baud Rate detection feature is supported by the USARTx instance. 1570 * @rmtoll CR2 ABREN LL_USART_IsEnabledAutoBaud 1571 * @param USARTx USART Instance 1572 * @retval State of bit (1 or 0). 1573 */ 1574 __STATIC_INLINE uint32_t LL_USART_IsEnabledAutoBaud(const USART_TypeDef *USARTx) 1575 { 1576 return ((READ_BIT(USARTx->CR2, USART_CR2_ABREN) == (USART_CR2_ABREN)) ? 1UL : 0UL); 1577 } 1578 1579 /** 1580 * @brief Set Auto Baud-Rate mode bits 1581 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 1582 * Auto Baud Rate detection feature is supported by the USARTx instance. 1583 * @rmtoll CR2 ABRMODE LL_USART_SetAutoBaudRateMode 1584 * @param USARTx USART Instance 1585 * @param AutoBaudRateMode This parameter can be one of the following values: 1586 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT 1587 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE 1588 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME 1589 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME 1590 * @retval None 1591 */ 1592 __STATIC_INLINE void LL_USART_SetAutoBaudRateMode(USART_TypeDef *USARTx, uint32_t AutoBaudRateMode) 1593 { 1594 MODIFY_REG(USARTx->CR2, USART_CR2_ABRMODE, AutoBaudRateMode); 1595 } 1596 1597 /** 1598 * @brief Return Auto Baud-Rate mode 1599 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 1600 * Auto Baud Rate detection feature is supported by the USARTx instance. 1601 * @rmtoll CR2 ABRMODE LL_USART_GetAutoBaudRateMode 1602 * @param USARTx USART Instance 1603 * @retval Returned value can be one of the following values: 1604 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT 1605 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE 1606 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME 1607 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME 1608 */ 1609 __STATIC_INLINE uint32_t LL_USART_GetAutoBaudRateMode(const USART_TypeDef *USARTx) 1610 { 1611 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ABRMODE)); 1612 } 1613 1614 /** 1615 * @brief Enable Receiver Timeout 1616 * @rmtoll CR2 RTOEN LL_USART_EnableRxTimeout 1617 * @param USARTx USART Instance 1618 * @retval None 1619 */ 1620 __STATIC_INLINE void LL_USART_EnableRxTimeout(USART_TypeDef *USARTx) 1621 { 1622 SET_BIT(USARTx->CR2, USART_CR2_RTOEN); 1623 } 1624 1625 /** 1626 * @brief Disable Receiver Timeout 1627 * @rmtoll CR2 RTOEN LL_USART_DisableRxTimeout 1628 * @param USARTx USART Instance 1629 * @retval None 1630 */ 1631 __STATIC_INLINE void LL_USART_DisableRxTimeout(USART_TypeDef *USARTx) 1632 { 1633 CLEAR_BIT(USARTx->CR2, USART_CR2_RTOEN); 1634 } 1635 1636 /** 1637 * @brief Indicate if Receiver Timeout feature is enabled 1638 * @rmtoll CR2 RTOEN LL_USART_IsEnabledRxTimeout 1639 * @param USARTx USART Instance 1640 * @retval State of bit (1 or 0). 1641 */ 1642 __STATIC_INLINE uint32_t LL_USART_IsEnabledRxTimeout(const USART_TypeDef *USARTx) 1643 { 1644 return ((READ_BIT(USARTx->CR2, USART_CR2_RTOEN) == (USART_CR2_RTOEN)) ? 1UL : 0UL); 1645 } 1646 1647 /** 1648 * @brief Set Address of the USART node. 1649 * @note This is used in multiprocessor communication during Mute mode or Stop mode, 1650 * for wake up with address mark detection. 1651 * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7. 1652 * (b7-b4 should be set to 0) 1653 * 8bits address node is used when 7-bit Address Detection is selected in ADDM7. 1654 * (This is used in multiprocessor communication during Mute mode or Stop mode, 1655 * for wake up with 7-bit address mark detection. 1656 * The MSB of the character sent by the transmitter should be equal to 1. 1657 * It may also be used for character detection during normal reception, 1658 * Mute mode inactive (for example, end of block detection in ModBus protocol). 1659 * In this case, the whole received character (8-bit) is compared to the ADD[7:0] 1660 * value and CMF flag is set on match) 1661 * @rmtoll CR2 ADD LL_USART_ConfigNodeAddress\n 1662 * CR2 ADDM7 LL_USART_ConfigNodeAddress 1663 * @param USARTx USART Instance 1664 * @param AddressLen This parameter can be one of the following values: 1665 * @arg @ref LL_USART_ADDRESS_DETECT_4B 1666 * @arg @ref LL_USART_ADDRESS_DETECT_7B 1667 * @param NodeAddress 4 or 7 bit Address of the USART node. 1668 * @retval None 1669 */ 1670 __STATIC_INLINE void LL_USART_ConfigNodeAddress(USART_TypeDef *USARTx, uint32_t AddressLen, uint32_t NodeAddress) 1671 { 1672 MODIFY_REG(USARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7, 1673 (uint32_t)(AddressLen | (NodeAddress << USART_CR2_ADD_Pos))); 1674 } 1675 1676 /** 1677 * @brief Return 8 bit Address of the USART node as set in ADD field of CR2. 1678 * @note If 4-bit Address Detection is selected in ADDM7, 1679 * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant) 1680 * If 7-bit Address Detection is selected in ADDM7, 1681 * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant) 1682 * @rmtoll CR2 ADD LL_USART_GetNodeAddress 1683 * @param USARTx USART Instance 1684 * @retval Address of the USART node (Value between Min_Data=0 and Max_Data=255) 1685 */ 1686 __STATIC_INLINE uint32_t LL_USART_GetNodeAddress(const USART_TypeDef *USARTx) 1687 { 1688 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD) >> USART_CR2_ADD_Pos); 1689 } 1690 1691 /** 1692 * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit) 1693 * @rmtoll CR2 ADDM7 LL_USART_GetNodeAddressLen 1694 * @param USARTx USART Instance 1695 * @retval Returned value can be one of the following values: 1696 * @arg @ref LL_USART_ADDRESS_DETECT_4B 1697 * @arg @ref LL_USART_ADDRESS_DETECT_7B 1698 */ 1699 __STATIC_INLINE uint32_t LL_USART_GetNodeAddressLen(const USART_TypeDef *USARTx) 1700 { 1701 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADDM7)); 1702 } 1703 1704 /** 1705 * @brief Enable RTS HW Flow Control 1706 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 1707 * Hardware Flow control feature is supported by the USARTx instance. 1708 * @rmtoll CR3 RTSE LL_USART_EnableRTSHWFlowCtrl 1709 * @param USARTx USART Instance 1710 * @retval None 1711 */ 1712 __STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx) 1713 { 1714 SET_BIT(USARTx->CR3, USART_CR3_RTSE); 1715 } 1716 1717 /** 1718 * @brief Disable RTS HW Flow Control 1719 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 1720 * Hardware Flow control feature is supported by the USARTx instance. 1721 * @rmtoll CR3 RTSE LL_USART_DisableRTSHWFlowCtrl 1722 * @param USARTx USART Instance 1723 * @retval None 1724 */ 1725 __STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx) 1726 { 1727 CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE); 1728 } 1729 1730 /** 1731 * @brief Enable CTS HW Flow Control 1732 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 1733 * Hardware Flow control feature is supported by the USARTx instance. 1734 * @rmtoll CR3 CTSE LL_USART_EnableCTSHWFlowCtrl 1735 * @param USARTx USART Instance 1736 * @retval None 1737 */ 1738 __STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx) 1739 { 1740 SET_BIT(USARTx->CR3, USART_CR3_CTSE); 1741 } 1742 1743 /** 1744 * @brief Disable CTS HW Flow Control 1745 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 1746 * Hardware Flow control feature is supported by the USARTx instance. 1747 * @rmtoll CR3 CTSE LL_USART_DisableCTSHWFlowCtrl 1748 * @param USARTx USART Instance 1749 * @retval None 1750 */ 1751 __STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx) 1752 { 1753 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE); 1754 } 1755 1756 /** 1757 * @brief Configure HW Flow Control mode (both CTS and RTS) 1758 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 1759 * Hardware Flow control feature is supported by the USARTx instance. 1760 * @rmtoll CR3 RTSE LL_USART_SetHWFlowCtrl\n 1761 * CR3 CTSE LL_USART_SetHWFlowCtrl 1762 * @param USARTx USART Instance 1763 * @param HardwareFlowControl This parameter can be one of the following values: 1764 * @arg @ref LL_USART_HWCONTROL_NONE 1765 * @arg @ref LL_USART_HWCONTROL_RTS 1766 * @arg @ref LL_USART_HWCONTROL_CTS 1767 * @arg @ref LL_USART_HWCONTROL_RTS_CTS 1768 * @retval None 1769 */ 1770 __STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HardwareFlowControl) 1771 { 1772 MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl); 1773 } 1774 1775 /** 1776 * @brief Return HW Flow Control configuration (both CTS and RTS) 1777 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 1778 * Hardware Flow control feature is supported by the USARTx instance. 1779 * @rmtoll CR3 RTSE LL_USART_GetHWFlowCtrl\n 1780 * CR3 CTSE LL_USART_GetHWFlowCtrl 1781 * @param USARTx USART Instance 1782 * @retval Returned value can be one of the following values: 1783 * @arg @ref LL_USART_HWCONTROL_NONE 1784 * @arg @ref LL_USART_HWCONTROL_RTS 1785 * @arg @ref LL_USART_HWCONTROL_CTS 1786 * @arg @ref LL_USART_HWCONTROL_RTS_CTS 1787 */ 1788 __STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(const USART_TypeDef *USARTx) 1789 { 1790 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE)); 1791 } 1792 1793 /** 1794 * @brief Enable One bit sampling method 1795 * @rmtoll CR3 ONEBIT LL_USART_EnableOneBitSamp 1796 * @param USARTx USART Instance 1797 * @retval None 1798 */ 1799 __STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx) 1800 { 1801 SET_BIT(USARTx->CR3, USART_CR3_ONEBIT); 1802 } 1803 1804 /** 1805 * @brief Disable One bit sampling method 1806 * @rmtoll CR3 ONEBIT LL_USART_DisableOneBitSamp 1807 * @param USARTx USART Instance 1808 * @retval None 1809 */ 1810 __STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx) 1811 { 1812 CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT); 1813 } 1814 1815 /** 1816 * @brief Indicate if One bit sampling method is enabled 1817 * @rmtoll CR3 ONEBIT LL_USART_IsEnabledOneBitSamp 1818 * @param USARTx USART Instance 1819 * @retval State of bit (1 or 0). 1820 */ 1821 __STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(const USART_TypeDef *USARTx) 1822 { 1823 return ((READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT)) ? 1UL : 0UL); 1824 } 1825 1826 /** 1827 * @brief Enable Overrun detection 1828 * @rmtoll CR3 OVRDIS LL_USART_EnableOverrunDetect 1829 * @param USARTx USART Instance 1830 * @retval None 1831 */ 1832 __STATIC_INLINE void LL_USART_EnableOverrunDetect(USART_TypeDef *USARTx) 1833 { 1834 CLEAR_BIT(USARTx->CR3, USART_CR3_OVRDIS); 1835 } 1836 1837 /** 1838 * @brief Disable Overrun detection 1839 * @rmtoll CR3 OVRDIS LL_USART_DisableOverrunDetect 1840 * @param USARTx USART Instance 1841 * @retval None 1842 */ 1843 __STATIC_INLINE void LL_USART_DisableOverrunDetect(USART_TypeDef *USARTx) 1844 { 1845 SET_BIT(USARTx->CR3, USART_CR3_OVRDIS); 1846 } 1847 1848 /** 1849 * @brief Indicate if Overrun detection is enabled 1850 * @rmtoll CR3 OVRDIS LL_USART_IsEnabledOverrunDetect 1851 * @param USARTx USART Instance 1852 * @retval State of bit (1 or 0). 1853 */ 1854 __STATIC_INLINE uint32_t LL_USART_IsEnabledOverrunDetect(const USART_TypeDef *USARTx) 1855 { 1856 return ((READ_BIT(USARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS) ? 1UL : 0UL); 1857 } 1858 1859 /** 1860 * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits) 1861 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 1862 * Wake-up from Stop mode feature is supported by the USARTx instance. 1863 * @rmtoll CR3 WUS LL_USART_SetWKUPType 1864 * @param USARTx USART Instance 1865 * @param Type This parameter can be one of the following values: 1866 * @arg @ref LL_USART_WAKEUP_ON_ADDRESS 1867 * @arg @ref LL_USART_WAKEUP_ON_STARTBIT 1868 * @arg @ref LL_USART_WAKEUP_ON_RXNE 1869 * @retval None 1870 */ 1871 __STATIC_INLINE void LL_USART_SetWKUPType(USART_TypeDef *USARTx, uint32_t Type) 1872 { 1873 MODIFY_REG(USARTx->CR3, USART_CR3_WUS, Type); 1874 } 1875 1876 /** 1877 * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits) 1878 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 1879 * Wake-up from Stop mode feature is supported by the USARTx instance. 1880 * @rmtoll CR3 WUS LL_USART_GetWKUPType 1881 * @param USARTx USART Instance 1882 * @retval Returned value can be one of the following values: 1883 * @arg @ref LL_USART_WAKEUP_ON_ADDRESS 1884 * @arg @ref LL_USART_WAKEUP_ON_STARTBIT 1885 * @arg @ref LL_USART_WAKEUP_ON_RXNE 1886 */ 1887 __STATIC_INLINE uint32_t LL_USART_GetWKUPType(const USART_TypeDef *USARTx) 1888 { 1889 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_WUS)); 1890 } 1891 1892 /** 1893 * @brief Configure USART BRR register for achieving expected Baud Rate value. 1894 * @note Compute and set USARTDIV value in BRR Register (full BRR content) 1895 * according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values 1896 * @note Peripheral clock and Baud rate values provided as function parameters should be valid 1897 * (Baud rate value != 0) 1898 * @note In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d. 1899 * @rmtoll BRR BRR LL_USART_SetBaudRate 1900 * @param USARTx USART Instance 1901 * @param PeriphClk Peripheral Clock 1902 * @param PrescalerValue This parameter can be one of the following values: 1903 * @arg @ref LL_USART_PRESCALER_DIV1 1904 * @arg @ref LL_USART_PRESCALER_DIV2 1905 * @arg @ref LL_USART_PRESCALER_DIV4 1906 * @arg @ref LL_USART_PRESCALER_DIV6 1907 * @arg @ref LL_USART_PRESCALER_DIV8 1908 * @arg @ref LL_USART_PRESCALER_DIV10 1909 * @arg @ref LL_USART_PRESCALER_DIV12 1910 * @arg @ref LL_USART_PRESCALER_DIV16 1911 * @arg @ref LL_USART_PRESCALER_DIV32 1912 * @arg @ref LL_USART_PRESCALER_DIV64 1913 * @arg @ref LL_USART_PRESCALER_DIV128 1914 * @arg @ref LL_USART_PRESCALER_DIV256 1915 * @param OverSampling This parameter can be one of the following values: 1916 * @arg @ref LL_USART_OVERSAMPLING_16 1917 * @arg @ref LL_USART_OVERSAMPLING_8 1918 * @param BaudRate Baud Rate 1919 * @retval None 1920 */ 1921 __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t PrescalerValue, 1922 uint32_t OverSampling, 1923 uint32_t BaudRate) 1924 { 1925 uint32_t usartdiv; 1926 uint32_t brrtemp; 1927 1928 if (PrescalerValue > LL_USART_PRESCALER_DIV256) 1929 { 1930 /* Do not overstep the size of USART_PRESCALER_TAB */ 1931 } 1932 else if (BaudRate == 0U) 1933 { 1934 /* Can Not divide per 0 */ 1935 } 1936 else if (OverSampling == LL_USART_OVERSAMPLING_8) 1937 { 1938 usartdiv = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, (uint8_t)PrescalerValue, BaudRate)); 1939 brrtemp = usartdiv & 0xFFF0U; 1940 brrtemp |= (uint16_t)((usartdiv & (uint16_t)0x000FU) >> 1U); 1941 USARTx->BRR = brrtemp; 1942 } 1943 else 1944 { 1945 USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, (uint8_t)PrescalerValue, BaudRate)); 1946 } 1947 } 1948 1949 /** 1950 * @brief Return current Baud Rate value, according to USARTDIV present in BRR register 1951 * (full BRR content), and to used Peripheral Clock and Oversampling mode values 1952 * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned. 1953 * @note In case of oversampling by 16 and 8, BRR content must be greater than or equal to 16d. 1954 * @rmtoll BRR BRR LL_USART_GetBaudRate 1955 * @param USARTx USART Instance 1956 * @param PeriphClk Peripheral Clock 1957 * @param PrescalerValue This parameter can be one of the following values: 1958 * @arg @ref LL_USART_PRESCALER_DIV1 1959 * @arg @ref LL_USART_PRESCALER_DIV2 1960 * @arg @ref LL_USART_PRESCALER_DIV4 1961 * @arg @ref LL_USART_PRESCALER_DIV6 1962 * @arg @ref LL_USART_PRESCALER_DIV8 1963 * @arg @ref LL_USART_PRESCALER_DIV10 1964 * @arg @ref LL_USART_PRESCALER_DIV12 1965 * @arg @ref LL_USART_PRESCALER_DIV16 1966 * @arg @ref LL_USART_PRESCALER_DIV32 1967 * @arg @ref LL_USART_PRESCALER_DIV64 1968 * @arg @ref LL_USART_PRESCALER_DIV128 1969 * @arg @ref LL_USART_PRESCALER_DIV256 1970 * @param OverSampling This parameter can be one of the following values: 1971 * @arg @ref LL_USART_OVERSAMPLING_16 1972 * @arg @ref LL_USART_OVERSAMPLING_8 1973 * @retval Baud Rate 1974 */ 1975 __STATIC_INLINE uint32_t LL_USART_GetBaudRate(const USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t PrescalerValue, 1976 uint32_t OverSampling) 1977 { 1978 uint32_t usartdiv; 1979 uint32_t brrresult = 0x0U; 1980 uint32_t periphclkpresc = (uint32_t)(PeriphClk / (USART_PRESCALER_TAB[(uint8_t)PrescalerValue])); 1981 1982 usartdiv = USARTx->BRR; 1983 1984 if (usartdiv == 0U) 1985 { 1986 /* Do not perform a division by 0 */ 1987 } 1988 else if (OverSampling == LL_USART_OVERSAMPLING_8) 1989 { 1990 usartdiv = (uint16_t)((usartdiv & 0xFFF0U) | ((usartdiv & 0x0007U) << 1U)) ; 1991 if (usartdiv != 0U) 1992 { 1993 brrresult = (periphclkpresc * 2U) / usartdiv; 1994 } 1995 } 1996 else 1997 { 1998 if ((usartdiv & 0xFFFFU) != 0U) 1999 { 2000 brrresult = periphclkpresc / usartdiv; 2001 } 2002 } 2003 return (brrresult); 2004 } 2005 2006 /** 2007 * @brief Set Receiver Time Out Value (expressed in nb of bits duration) 2008 * @rmtoll RTOR RTO LL_USART_SetRxTimeout 2009 * @param USARTx USART Instance 2010 * @param Timeout Value between Min_Data=0x00 and Max_Data=0x00FFFFFF 2011 * @retval None 2012 */ 2013 __STATIC_INLINE void LL_USART_SetRxTimeout(USART_TypeDef *USARTx, uint32_t Timeout) 2014 { 2015 MODIFY_REG(USARTx->RTOR, USART_RTOR_RTO, Timeout); 2016 } 2017 2018 /** 2019 * @brief Get Receiver Time Out Value (expressed in nb of bits duration) 2020 * @rmtoll RTOR RTO LL_USART_GetRxTimeout 2021 * @param USARTx USART Instance 2022 * @retval Value between Min_Data=0x00 and Max_Data=0x00FFFFFF 2023 */ 2024 __STATIC_INLINE uint32_t LL_USART_GetRxTimeout(const USART_TypeDef *USARTx) 2025 { 2026 return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_RTO)); 2027 } 2028 2029 /** 2030 * @brief Set Block Length value in reception 2031 * @rmtoll RTOR BLEN LL_USART_SetBlockLength 2032 * @param USARTx USART Instance 2033 * @param BlockLength Value between Min_Data=0x00 and Max_Data=0xFF 2034 * @retval None 2035 */ 2036 __STATIC_INLINE void LL_USART_SetBlockLength(USART_TypeDef *USARTx, uint32_t BlockLength) 2037 { 2038 MODIFY_REG(USARTx->RTOR, USART_RTOR_BLEN, BlockLength << USART_RTOR_BLEN_Pos); 2039 } 2040 2041 /** 2042 * @brief Get Block Length value in reception 2043 * @rmtoll RTOR BLEN LL_USART_GetBlockLength 2044 * @param USARTx USART Instance 2045 * @retval Value between Min_Data=0x00 and Max_Data=0xFF 2046 */ 2047 __STATIC_INLINE uint32_t LL_USART_GetBlockLength(const USART_TypeDef *USARTx) 2048 { 2049 return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_BLEN) >> USART_RTOR_BLEN_Pos); 2050 } 2051 2052 /** 2053 * @} 2054 */ 2055 2056 /** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature 2057 * @ingroup RTEMSBSPsARMSTM32H7 2058 * @{ 2059 */ 2060 2061 /** 2062 * @brief Enable IrDA mode 2063 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 2064 * IrDA feature is supported by the USARTx instance. 2065 * @rmtoll CR3 IREN LL_USART_EnableIrda 2066 * @param USARTx USART Instance 2067 * @retval None 2068 */ 2069 __STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx) 2070 { 2071 SET_BIT(USARTx->CR3, USART_CR3_IREN); 2072 } 2073 2074 /** 2075 * @brief Disable IrDA mode 2076 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 2077 * IrDA feature is supported by the USARTx instance. 2078 * @rmtoll CR3 IREN LL_USART_DisableIrda 2079 * @param USARTx USART Instance 2080 * @retval None 2081 */ 2082 __STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx) 2083 { 2084 CLEAR_BIT(USARTx->CR3, USART_CR3_IREN); 2085 } 2086 2087 /** 2088 * @brief Indicate if IrDA mode is enabled 2089 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 2090 * IrDA feature is supported by the USARTx instance. 2091 * @rmtoll CR3 IREN LL_USART_IsEnabledIrda 2092 * @param USARTx USART Instance 2093 * @retval State of bit (1 or 0). 2094 */ 2095 __STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(const USART_TypeDef *USARTx) 2096 { 2097 return ((READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN)) ? 1UL : 0UL); 2098 } 2099 2100 /** 2101 * @brief Configure IrDA Power Mode (Normal or Low Power) 2102 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 2103 * IrDA feature is supported by the USARTx instance. 2104 * @rmtoll CR3 IRLP LL_USART_SetIrdaPowerMode 2105 * @param USARTx USART Instance 2106 * @param PowerMode This parameter can be one of the following values: 2107 * @arg @ref LL_USART_IRDA_POWER_NORMAL 2108 * @arg @ref LL_USART_IRDA_POWER_LOW 2109 * @retval None 2110 */ 2111 __STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode) 2112 { 2113 MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode); 2114 } 2115 2116 /** 2117 * @brief Retrieve IrDA Power Mode configuration (Normal or Low Power) 2118 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 2119 * IrDA feature is supported by the USARTx instance. 2120 * @rmtoll CR3 IRLP LL_USART_GetIrdaPowerMode 2121 * @param USARTx USART Instance 2122 * @retval Returned value can be one of the following values: 2123 * @arg @ref LL_USART_IRDA_POWER_NORMAL 2124 * @arg @ref LL_USART_PHASE_2EDGE 2125 */ 2126 __STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(const USART_TypeDef *USARTx) 2127 { 2128 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP)); 2129 } 2130 2131 /** 2132 * @brief Set Irda prescaler value, used for dividing the USART clock source 2133 * to achieve the Irda Low Power frequency (8 bits value) 2134 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 2135 * IrDA feature is supported by the USARTx instance. 2136 * @rmtoll GTPR PSC LL_USART_SetIrdaPrescaler 2137 * @param USARTx USART Instance 2138 * @param PrescalerValue Value between Min_Data=0x00 and Max_Data=0xFF 2139 * @retval None 2140 */ 2141 __STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) 2142 { 2143 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, (uint16_t)PrescalerValue); 2144 } 2145 2146 /** 2147 * @brief Return Irda prescaler value, used for dividing the USART clock source 2148 * to achieve the Irda Low Power frequency (8 bits value) 2149 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 2150 * IrDA feature is supported by the USARTx instance. 2151 * @rmtoll GTPR PSC LL_USART_GetIrdaPrescaler 2152 * @param USARTx USART Instance 2153 * @retval Irda prescaler value (Value between Min_Data=0x00 and Max_Data=0xFF) 2154 */ 2155 __STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(const USART_TypeDef *USARTx) 2156 { 2157 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC)); 2158 } 2159 2160 /** 2161 * @} 2162 */ 2163 2164 /** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature 2165 * @ingroup RTEMSBSPsARMSTM32H7 2166 * @{ 2167 */ 2168 2169 /** 2170 * @brief Enable Smartcard NACK transmission 2171 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 2172 * Smartcard feature is supported by the USARTx instance. 2173 * @rmtoll CR3 NACK LL_USART_EnableSmartcardNACK 2174 * @param USARTx USART Instance 2175 * @retval None 2176 */ 2177 __STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx) 2178 { 2179 SET_BIT(USARTx->CR3, USART_CR3_NACK); 2180 } 2181 2182 /** 2183 * @brief Disable Smartcard NACK transmission 2184 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 2185 * Smartcard feature is supported by the USARTx instance. 2186 * @rmtoll CR3 NACK LL_USART_DisableSmartcardNACK 2187 * @param USARTx USART Instance 2188 * @retval None 2189 */ 2190 __STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx) 2191 { 2192 CLEAR_BIT(USARTx->CR3, USART_CR3_NACK); 2193 } 2194 2195 /** 2196 * @brief Indicate if Smartcard NACK transmission is enabled 2197 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 2198 * Smartcard feature is supported by the USARTx instance. 2199 * @rmtoll CR3 NACK LL_USART_IsEnabledSmartcardNACK 2200 * @param USARTx USART Instance 2201 * @retval State of bit (1 or 0). 2202 */ 2203 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(const USART_TypeDef *USARTx) 2204 { 2205 return ((READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK)) ? 1UL : 0UL); 2206 } 2207 2208 /** 2209 * @brief Enable Smartcard mode 2210 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 2211 * Smartcard feature is supported by the USARTx instance. 2212 * @rmtoll CR3 SCEN LL_USART_EnableSmartcard 2213 * @param USARTx USART Instance 2214 * @retval None 2215 */ 2216 __STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx) 2217 { 2218 SET_BIT(USARTx->CR3, USART_CR3_SCEN); 2219 } 2220 2221 /** 2222 * @brief Disable Smartcard mode 2223 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 2224 * Smartcard feature is supported by the USARTx instance. 2225 * @rmtoll CR3 SCEN LL_USART_DisableSmartcard 2226 * @param USARTx USART Instance 2227 * @retval None 2228 */ 2229 __STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx) 2230 { 2231 CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN); 2232 } 2233 2234 /** 2235 * @brief Indicate if Smartcard mode is enabled 2236 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 2237 * Smartcard feature is supported by the USARTx instance. 2238 * @rmtoll CR3 SCEN LL_USART_IsEnabledSmartcard 2239 * @param USARTx USART Instance 2240 * @retval State of bit (1 or 0). 2241 */ 2242 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(const USART_TypeDef *USARTx) 2243 { 2244 return ((READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN)) ? 1UL : 0UL); 2245 } 2246 2247 /** 2248 * @brief Set Smartcard Auto-Retry Count value (SCARCNT[2:0] bits) 2249 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 2250 * Smartcard feature is supported by the USARTx instance. 2251 * @note This bit-field specifies the number of retries in transmit and receive, in Smartcard mode. 2252 * In transmission mode, it specifies the number of automatic retransmission retries, before 2253 * generating a transmission error (FE bit set). 2254 * In reception mode, it specifies the number or erroneous reception trials, before generating a 2255 * reception error (RXNE and PE bits set) 2256 * @rmtoll CR3 SCARCNT LL_USART_SetSmartcardAutoRetryCount 2257 * @param USARTx USART Instance 2258 * @param AutoRetryCount Value between Min_Data=0 and Max_Data=7 2259 * @retval None 2260 */ 2261 __STATIC_INLINE void LL_USART_SetSmartcardAutoRetryCount(USART_TypeDef *USARTx, uint32_t AutoRetryCount) 2262 { 2263 MODIFY_REG(USARTx->CR3, USART_CR3_SCARCNT, AutoRetryCount << USART_CR3_SCARCNT_Pos); 2264 } 2265 2266 /** 2267 * @brief Return Smartcard Auto-Retry Count value (SCARCNT[2:0] bits) 2268 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 2269 * Smartcard feature is supported by the USARTx instance. 2270 * @rmtoll CR3 SCARCNT LL_USART_GetSmartcardAutoRetryCount 2271 * @param USARTx USART Instance 2272 * @retval Smartcard Auto-Retry Count value (Value between Min_Data=0 and Max_Data=7) 2273 */ 2274 __STATIC_INLINE uint32_t LL_USART_GetSmartcardAutoRetryCount(const USART_TypeDef *USARTx) 2275 { 2276 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_SCARCNT) >> USART_CR3_SCARCNT_Pos); 2277 } 2278 2279 /** 2280 * @brief Set Smartcard prescaler value, used for dividing the USART clock 2281 * source to provide the SMARTCARD Clock (5 bits value) 2282 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 2283 * Smartcard feature is supported by the USARTx instance. 2284 * @rmtoll GTPR PSC LL_USART_SetSmartcardPrescaler 2285 * @param USARTx USART Instance 2286 * @param PrescalerValue Value between Min_Data=0 and Max_Data=31 2287 * @retval None 2288 */ 2289 __STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) 2290 { 2291 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, (uint16_t)PrescalerValue); 2292 } 2293 2294 /** 2295 * @brief Return Smartcard prescaler value, used for dividing the USART clock 2296 * source to provide the SMARTCARD Clock (5 bits value) 2297 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 2298 * Smartcard feature is supported by the USARTx instance. 2299 * @rmtoll GTPR PSC LL_USART_GetSmartcardPrescaler 2300 * @param USARTx USART Instance 2301 * @retval Smartcard prescaler value (Value between Min_Data=0 and Max_Data=31) 2302 */ 2303 __STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(const USART_TypeDef *USARTx) 2304 { 2305 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC)); 2306 } 2307 2308 /** 2309 * @brief Set Smartcard Guard time value, expressed in nb of baud clocks periods 2310 * (GT[7:0] bits : Guard time value) 2311 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 2312 * Smartcard feature is supported by the USARTx instance. 2313 * @rmtoll GTPR GT LL_USART_SetSmartcardGuardTime 2314 * @param USARTx USART Instance 2315 * @param GuardTime Value between Min_Data=0x00 and Max_Data=0xFF 2316 * @retval None 2317 */ 2318 __STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime) 2319 { 2320 MODIFY_REG(USARTx->GTPR, USART_GTPR_GT, (uint16_t)(GuardTime << USART_GTPR_GT_Pos)); 2321 } 2322 2323 /** 2324 * @brief Return Smartcard Guard time value, expressed in nb of baud clocks periods 2325 * (GT[7:0] bits : Guard time value) 2326 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 2327 * Smartcard feature is supported by the USARTx instance. 2328 * @rmtoll GTPR GT LL_USART_GetSmartcardGuardTime 2329 * @param USARTx USART Instance 2330 * @retval Smartcard Guard time value (Value between Min_Data=0x00 and Max_Data=0xFF) 2331 */ 2332 __STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(const USART_TypeDef *USARTx) 2333 { 2334 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_GTPR_GT_Pos); 2335 } 2336 2337 /** 2338 * @} 2339 */ 2340 2341 /** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature 2342 * @ingroup RTEMSBSPsARMSTM32H7 2343 * @{ 2344 */ 2345 2346 /** 2347 * @brief Enable Single Wire Half-Duplex mode 2348 * @note Macro IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not 2349 * Half-Duplex mode is supported by the USARTx instance. 2350 * @rmtoll CR3 HDSEL LL_USART_EnableHalfDuplex 2351 * @param USARTx USART Instance 2352 * @retval None 2353 */ 2354 __STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx) 2355 { 2356 SET_BIT(USARTx->CR3, USART_CR3_HDSEL); 2357 } 2358 2359 /** 2360 * @brief Disable Single Wire Half-Duplex mode 2361 * @note Macro IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not 2362 * Half-Duplex mode is supported by the USARTx instance. 2363 * @rmtoll CR3 HDSEL LL_USART_DisableHalfDuplex 2364 * @param USARTx USART Instance 2365 * @retval None 2366 */ 2367 __STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx) 2368 { 2369 CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL); 2370 } 2371 2372 /** 2373 * @brief Indicate if Single Wire Half-Duplex mode is enabled 2374 * @note Macro IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not 2375 * Half-Duplex mode is supported by the USARTx instance. 2376 * @rmtoll CR3 HDSEL LL_USART_IsEnabledHalfDuplex 2377 * @param USARTx USART Instance 2378 * @retval State of bit (1 or 0). 2379 */ 2380 __STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(const USART_TypeDef *USARTx) 2381 { 2382 return ((READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL)) ? 1UL : 0UL); 2383 } 2384 2385 /** 2386 * @} 2387 */ 2388 2389 /** @defgroup USART_LL_EF_Configuration_SPI_SLAVE Configuration functions related to SPI Slave feature 2390 * @ingroup RTEMSBSPsARMSTM32H7 2391 * @{ 2392 */ 2393 /** 2394 * @brief Enable SPI Synchronous Slave mode 2395 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 2396 * SPI Slave mode feature is supported by the USARTx instance. 2397 * @rmtoll CR2 SLVEN LL_USART_EnableSPISlave 2398 * @param USARTx USART Instance 2399 * @retval None 2400 */ 2401 __STATIC_INLINE void LL_USART_EnableSPISlave(USART_TypeDef *USARTx) 2402 { 2403 SET_BIT(USARTx->CR2, USART_CR2_SLVEN); 2404 } 2405 2406 /** 2407 * @brief Disable SPI Synchronous Slave mode 2408 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 2409 * SPI Slave mode feature is supported by the USARTx instance. 2410 * @rmtoll CR2 SLVEN LL_USART_DisableSPISlave 2411 * @param USARTx USART Instance 2412 * @retval None 2413 */ 2414 __STATIC_INLINE void LL_USART_DisableSPISlave(USART_TypeDef *USARTx) 2415 { 2416 CLEAR_BIT(USARTx->CR2, USART_CR2_SLVEN); 2417 } 2418 2419 /** 2420 * @brief Indicate if SPI Synchronous Slave mode is enabled 2421 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 2422 * SPI Slave mode feature is supported by the USARTx instance. 2423 * @rmtoll CR2 SLVEN LL_USART_IsEnabledSPISlave 2424 * @param USARTx USART Instance 2425 * @retval State of bit (1 or 0). 2426 */ 2427 __STATIC_INLINE uint32_t LL_USART_IsEnabledSPISlave(const USART_TypeDef *USARTx) 2428 { 2429 return ((READ_BIT(USARTx->CR2, USART_CR2_SLVEN) == (USART_CR2_SLVEN)) ? 1UL : 0UL); 2430 } 2431 2432 /** 2433 * @brief Enable SPI Slave Selection using NSS input pin 2434 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 2435 * SPI Slave mode feature is supported by the USARTx instance. 2436 * @note SPI Slave Selection depends on NSS input pin 2437 * (The slave is selected when NSS is low and deselected when NSS is high). 2438 * @rmtoll CR2 DIS_NSS LL_USART_EnableSPISlaveSelect 2439 * @param USARTx USART Instance 2440 * @retval None 2441 */ 2442 __STATIC_INLINE void LL_USART_EnableSPISlaveSelect(USART_TypeDef *USARTx) 2443 { 2444 CLEAR_BIT(USARTx->CR2, USART_CR2_DIS_NSS); 2445 } 2446 2447 /** 2448 * @brief Disable SPI Slave Selection using NSS input pin 2449 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 2450 * SPI Slave mode feature is supported by the USARTx instance. 2451 * @note SPI Slave will be always selected and NSS input pin will be ignored. 2452 * @rmtoll CR2 DIS_NSS LL_USART_DisableSPISlaveSelect 2453 * @param USARTx USART Instance 2454 * @retval None 2455 */ 2456 __STATIC_INLINE void LL_USART_DisableSPISlaveSelect(USART_TypeDef *USARTx) 2457 { 2458 SET_BIT(USARTx->CR2, USART_CR2_DIS_NSS); 2459 } 2460 2461 /** 2462 * @brief Indicate if SPI Slave Selection depends on NSS input pin 2463 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 2464 * SPI Slave mode feature is supported by the USARTx instance. 2465 * @rmtoll CR2 DIS_NSS LL_USART_IsEnabledSPISlaveSelect 2466 * @param USARTx USART Instance 2467 * @retval State of bit (1 or 0). 2468 */ 2469 __STATIC_INLINE uint32_t LL_USART_IsEnabledSPISlaveSelect(const USART_TypeDef *USARTx) 2470 { 2471 return ((READ_BIT(USARTx->CR2, USART_CR2_DIS_NSS) != (USART_CR2_DIS_NSS)) ? 1UL : 0UL); 2472 } 2473 2474 /** 2475 * @} 2476 */ 2477 2478 /** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature 2479 * @ingroup RTEMSBSPsARMSTM32H7 2480 * @{ 2481 */ 2482 2483 /** 2484 * @brief Set LIN Break Detection Length 2485 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 2486 * LIN feature is supported by the USARTx instance. 2487 * @rmtoll CR2 LBDL LL_USART_SetLINBrkDetectionLen 2488 * @param USARTx USART Instance 2489 * @param LINBDLength This parameter can be one of the following values: 2490 * @arg @ref LL_USART_LINBREAK_DETECT_10B 2491 * @arg @ref LL_USART_LINBREAK_DETECT_11B 2492 * @retval None 2493 */ 2494 __STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength) 2495 { 2496 MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength); 2497 } 2498 2499 /** 2500 * @brief Return LIN Break Detection Length 2501 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 2502 * LIN feature is supported by the USARTx instance. 2503 * @rmtoll CR2 LBDL LL_USART_GetLINBrkDetectionLen 2504 * @param USARTx USART Instance 2505 * @retval Returned value can be one of the following values: 2506 * @arg @ref LL_USART_LINBREAK_DETECT_10B 2507 * @arg @ref LL_USART_LINBREAK_DETECT_11B 2508 */ 2509 __STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(const USART_TypeDef *USARTx) 2510 { 2511 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL)); 2512 } 2513 2514 /** 2515 * @brief Enable LIN mode 2516 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 2517 * LIN feature is supported by the USARTx instance. 2518 * @rmtoll CR2 LINEN LL_USART_EnableLIN 2519 * @param USARTx USART Instance 2520 * @retval None 2521 */ 2522 __STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx) 2523 { 2524 SET_BIT(USARTx->CR2, USART_CR2_LINEN); 2525 } 2526 2527 /** 2528 * @brief Disable LIN mode 2529 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 2530 * LIN feature is supported by the USARTx instance. 2531 * @rmtoll CR2 LINEN LL_USART_DisableLIN 2532 * @param USARTx USART Instance 2533 * @retval None 2534 */ 2535 __STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx) 2536 { 2537 CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN); 2538 } 2539 2540 /** 2541 * @brief Indicate if LIN mode is enabled 2542 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 2543 * LIN feature is supported by the USARTx instance. 2544 * @rmtoll CR2 LINEN LL_USART_IsEnabledLIN 2545 * @param USARTx USART Instance 2546 * @retval State of bit (1 or 0). 2547 */ 2548 __STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(const USART_TypeDef *USARTx) 2549 { 2550 return ((READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN)) ? 1UL : 0UL); 2551 } 2552 2553 /** 2554 * @} 2555 */ 2556 2557 /** @defgroup USART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature 2558 * @ingroup RTEMSBSPsARMSTM32H7 2559 * @{ 2560 */ 2561 2562 /** 2563 * @brief Set DEDT (Driver Enable De-Assertion Time), Time value expressed on 5 bits ([4:0] bits). 2564 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 2565 * Driver Enable feature is supported by the USARTx instance. 2566 * @rmtoll CR1 DEDT LL_USART_SetDEDeassertionTime 2567 * @param USARTx USART Instance 2568 * @param Time Value between Min_Data=0 and Max_Data=31 2569 * @retval None 2570 */ 2571 __STATIC_INLINE void LL_USART_SetDEDeassertionTime(USART_TypeDef *USARTx, uint32_t Time) 2572 { 2573 MODIFY_REG(USARTx->CR1, USART_CR1_DEDT, Time << USART_CR1_DEDT_Pos); 2574 } 2575 2576 /** 2577 * @brief Return DEDT (Driver Enable De-Assertion Time) 2578 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 2579 * Driver Enable feature is supported by the USARTx instance. 2580 * @rmtoll CR1 DEDT LL_USART_GetDEDeassertionTime 2581 * @param USARTx USART Instance 2582 * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31 2583 */ 2584 __STATIC_INLINE uint32_t LL_USART_GetDEDeassertionTime(const USART_TypeDef *USARTx) 2585 { 2586 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEDT) >> USART_CR1_DEDT_Pos); 2587 } 2588 2589 /** 2590 * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits). 2591 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 2592 * Driver Enable feature is supported by the USARTx instance. 2593 * @rmtoll CR1 DEAT LL_USART_SetDEAssertionTime 2594 * @param USARTx USART Instance 2595 * @param Time Value between Min_Data=0 and Max_Data=31 2596 * @retval None 2597 */ 2598 __STATIC_INLINE void LL_USART_SetDEAssertionTime(USART_TypeDef *USARTx, uint32_t Time) 2599 { 2600 MODIFY_REG(USARTx->CR1, USART_CR1_DEAT, Time << USART_CR1_DEAT_Pos); 2601 } 2602 2603 /** 2604 * @brief Return DEAT (Driver Enable Assertion Time) 2605 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 2606 * Driver Enable feature is supported by the USARTx instance. 2607 * @rmtoll CR1 DEAT LL_USART_GetDEAssertionTime 2608 * @param USARTx USART Instance 2609 * @retval Time value expressed on 5 bits ([4:0] bits) : Value between Min_Data=0 and Max_Data=31 2610 */ 2611 __STATIC_INLINE uint32_t LL_USART_GetDEAssertionTime(const USART_TypeDef *USARTx) 2612 { 2613 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEAT) >> USART_CR1_DEAT_Pos); 2614 } 2615 2616 /** 2617 * @brief Enable Driver Enable (DE) Mode 2618 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 2619 * Driver Enable feature is supported by the USARTx instance. 2620 * @rmtoll CR3 DEM LL_USART_EnableDEMode 2621 * @param USARTx USART Instance 2622 * @retval None 2623 */ 2624 __STATIC_INLINE void LL_USART_EnableDEMode(USART_TypeDef *USARTx) 2625 { 2626 SET_BIT(USARTx->CR3, USART_CR3_DEM); 2627 } 2628 2629 /** 2630 * @brief Disable Driver Enable (DE) Mode 2631 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 2632 * Driver Enable feature is supported by the USARTx instance. 2633 * @rmtoll CR3 DEM LL_USART_DisableDEMode 2634 * @param USARTx USART Instance 2635 * @retval None 2636 */ 2637 __STATIC_INLINE void LL_USART_DisableDEMode(USART_TypeDef *USARTx) 2638 { 2639 CLEAR_BIT(USARTx->CR3, USART_CR3_DEM); 2640 } 2641 2642 /** 2643 * @brief Indicate if Driver Enable (DE) Mode is enabled 2644 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 2645 * Driver Enable feature is supported by the USARTx instance. 2646 * @rmtoll CR3 DEM LL_USART_IsEnabledDEMode 2647 * @param USARTx USART Instance 2648 * @retval State of bit (1 or 0). 2649 */ 2650 __STATIC_INLINE uint32_t LL_USART_IsEnabledDEMode(const USART_TypeDef *USARTx) 2651 { 2652 return ((READ_BIT(USARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM)) ? 1UL : 0UL); 2653 } 2654 2655 /** 2656 * @brief Select Driver Enable Polarity 2657 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 2658 * Driver Enable feature is supported by the USARTx instance. 2659 * @rmtoll CR3 DEP LL_USART_SetDESignalPolarity 2660 * @param USARTx USART Instance 2661 * @param Polarity This parameter can be one of the following values: 2662 * @arg @ref LL_USART_DE_POLARITY_HIGH 2663 * @arg @ref LL_USART_DE_POLARITY_LOW 2664 * @retval None 2665 */ 2666 __STATIC_INLINE void LL_USART_SetDESignalPolarity(USART_TypeDef *USARTx, uint32_t Polarity) 2667 { 2668 MODIFY_REG(USARTx->CR3, USART_CR3_DEP, Polarity); 2669 } 2670 2671 /** 2672 * @brief Return Driver Enable Polarity 2673 * @note Macro IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 2674 * Driver Enable feature is supported by the USARTx instance. 2675 * @rmtoll CR3 DEP LL_USART_GetDESignalPolarity 2676 * @param USARTx USART Instance 2677 * @retval Returned value can be one of the following values: 2678 * @arg @ref LL_USART_DE_POLARITY_HIGH 2679 * @arg @ref LL_USART_DE_POLARITY_LOW 2680 */ 2681 __STATIC_INLINE uint32_t LL_USART_GetDESignalPolarity(const USART_TypeDef *USARTx) 2682 { 2683 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_DEP)); 2684 } 2685 2686 /** 2687 * @} 2688 */ 2689 2690 /** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services 2691 * @ingroup RTEMSBSPsARMSTM32H7 2692 * @{ 2693 */ 2694 2695 /** 2696 * @brief Perform basic configuration of USART for enabling use in Asynchronous Mode (UART) 2697 * @note In UART mode, the following bits must be kept cleared: 2698 * - LINEN bit in the USART_CR2 register, 2699 * - CLKEN bit in the USART_CR2 register, 2700 * - SCEN bit in the USART_CR3 register, 2701 * - IREN bit in the USART_CR3 register, 2702 * - HDSEL bit in the USART_CR3 register. 2703 * @note Call of this function is equivalent to following function call sequence : 2704 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 2705 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 2706 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 2707 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 2708 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 2709 * @note Other remaining configurations items related to Asynchronous Mode 2710 * (as Baud Rate, Word length, Parity, ...) should be set using 2711 * dedicated functions 2712 * @rmtoll CR2 LINEN LL_USART_ConfigAsyncMode\n 2713 * CR2 CLKEN LL_USART_ConfigAsyncMode\n 2714 * CR3 SCEN LL_USART_ConfigAsyncMode\n 2715 * CR3 IREN LL_USART_ConfigAsyncMode\n 2716 * CR3 HDSEL LL_USART_ConfigAsyncMode 2717 * @param USARTx USART Instance 2718 * @retval None 2719 */ 2720 __STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx) 2721 { 2722 /* In Asynchronous mode, the following bits must be kept cleared: 2723 - LINEN, CLKEN bits in the USART_CR2 register, 2724 - SCEN, IREN and HDSEL bits in the USART_CR3 register. 2725 */ 2726 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); 2727 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL)); 2728 } 2729 2730 /** 2731 * @brief Perform basic configuration of USART for enabling use in Synchronous Mode 2732 * @note In Synchronous mode, the following bits must be kept cleared: 2733 * - LINEN bit in the USART_CR2 register, 2734 * - SCEN bit in the USART_CR3 register, 2735 * - IREN bit in the USART_CR3 register, 2736 * - HDSEL bit in the USART_CR3 register. 2737 * This function also sets the USART in Synchronous mode. 2738 * @note Macro IS_USART_INSTANCE(USARTx) can be used to check whether or not 2739 * Synchronous mode is supported by the USARTx instance. 2740 * @note Call of this function is equivalent to following function call sequence : 2741 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 2742 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 2743 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 2744 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 2745 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function 2746 * @note Other remaining configurations items related to Synchronous Mode 2747 * (as Baud Rate, Word length, Parity, Clock Polarity, ...) should be set using 2748 * dedicated functions 2749 * @rmtoll CR2 LINEN LL_USART_ConfigSyncMode\n 2750 * CR2 CLKEN LL_USART_ConfigSyncMode\n 2751 * CR3 SCEN LL_USART_ConfigSyncMode\n 2752 * CR3 IREN LL_USART_ConfigSyncMode\n 2753 * CR3 HDSEL LL_USART_ConfigSyncMode 2754 * @param USARTx USART Instance 2755 * @retval None 2756 */ 2757 __STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx) 2758 { 2759 /* In Synchronous mode, the following bits must be kept cleared: 2760 - LINEN bit in the USART_CR2 register, 2761 - SCEN, IREN and HDSEL bits in the USART_CR3 register. 2762 */ 2763 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN)); 2764 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL)); 2765 /* set the UART/USART in Synchronous mode */ 2766 SET_BIT(USARTx->CR2, USART_CR2_CLKEN); 2767 } 2768 2769 /** 2770 * @brief Perform basic configuration of USART for enabling use in LIN Mode 2771 * @note In LIN mode, the following bits must be kept cleared: 2772 * - STOP and CLKEN bits in the USART_CR2 register, 2773 * - SCEN bit in the USART_CR3 register, 2774 * - IREN bit in the USART_CR3 register, 2775 * - HDSEL bit in the USART_CR3 register. 2776 * This function also set the UART/USART in LIN mode. 2777 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 2778 * LIN feature is supported by the USARTx instance. 2779 * @note Call of this function is equivalent to following function call sequence : 2780 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 2781 * - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function 2782 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 2783 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 2784 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 2785 * - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function 2786 * @note Other remaining configurations items related to LIN Mode 2787 * (as Baud Rate, Word length, LIN Break Detection Length, ...) should be set using 2788 * dedicated functions 2789 * @rmtoll CR2 CLKEN LL_USART_ConfigLINMode\n 2790 * CR2 STOP LL_USART_ConfigLINMode\n 2791 * CR2 LINEN LL_USART_ConfigLINMode\n 2792 * CR3 IREN LL_USART_ConfigLINMode\n 2793 * CR3 SCEN LL_USART_ConfigLINMode\n 2794 * CR3 HDSEL LL_USART_ConfigLINMode 2795 * @param USARTx USART Instance 2796 * @retval None 2797 */ 2798 __STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx) 2799 { 2800 /* In LIN mode, the following bits must be kept cleared: 2801 - STOP and CLKEN bits in the USART_CR2 register, 2802 - IREN, SCEN and HDSEL bits in the USART_CR3 register. 2803 */ 2804 CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP)); 2805 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL)); 2806 /* Set the UART/USART in LIN mode */ 2807 SET_BIT(USARTx->CR2, USART_CR2_LINEN); 2808 } 2809 2810 /** 2811 * @brief Perform basic configuration of USART for enabling use in Half Duplex Mode 2812 * @note In Half Duplex mode, the following bits must be kept cleared: 2813 * - LINEN bit in the USART_CR2 register, 2814 * - CLKEN bit in the USART_CR2 register, 2815 * - SCEN bit in the USART_CR3 register, 2816 * - IREN bit in the USART_CR3 register, 2817 * This function also sets the UART/USART in Half Duplex mode. 2818 * @note Macro IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not 2819 * Half-Duplex mode is supported by the USARTx instance. 2820 * @note Call of this function is equivalent to following function call sequence : 2821 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 2822 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 2823 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 2824 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 2825 * - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function 2826 * @note Other remaining configurations items related to Half Duplex Mode 2827 * (as Baud Rate, Word length, Parity, ...) should be set using 2828 * dedicated functions 2829 * @rmtoll CR2 LINEN LL_USART_ConfigHalfDuplexMode\n 2830 * CR2 CLKEN LL_USART_ConfigHalfDuplexMode\n 2831 * CR3 HDSEL LL_USART_ConfigHalfDuplexMode\n 2832 * CR3 SCEN LL_USART_ConfigHalfDuplexMode\n 2833 * CR3 IREN LL_USART_ConfigHalfDuplexMode 2834 * @param USARTx USART Instance 2835 * @retval None 2836 */ 2837 __STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx) 2838 { 2839 /* In Half Duplex mode, the following bits must be kept cleared: 2840 - LINEN and CLKEN bits in the USART_CR2 register, 2841 - SCEN and IREN bits in the USART_CR3 register. 2842 */ 2843 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); 2844 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN)); 2845 /* set the UART/USART in Half Duplex mode */ 2846 SET_BIT(USARTx->CR3, USART_CR3_HDSEL); 2847 } 2848 2849 /** 2850 * @brief Perform basic configuration of USART for enabling use in Smartcard Mode 2851 * @note In Smartcard mode, the following bits must be kept cleared: 2852 * - LINEN bit in the USART_CR2 register, 2853 * - IREN bit in the USART_CR3 register, 2854 * - HDSEL bit in the USART_CR3 register. 2855 * This function also configures Stop bits to 1.5 bits and 2856 * sets the USART in Smartcard mode (SCEN bit). 2857 * Clock Output is also enabled (CLKEN). 2858 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 2859 * Smartcard feature is supported by the USARTx instance. 2860 * @note Call of this function is equivalent to following function call sequence : 2861 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 2862 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 2863 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 2864 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function 2865 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function 2866 * - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function 2867 * @note Other remaining configurations items related to Smartcard Mode 2868 * (as Baud Rate, Word length, Parity, ...) should be set using 2869 * dedicated functions 2870 * @rmtoll CR2 LINEN LL_USART_ConfigSmartcardMode\n 2871 * CR2 STOP LL_USART_ConfigSmartcardMode\n 2872 * CR2 CLKEN LL_USART_ConfigSmartcardMode\n 2873 * CR3 HDSEL LL_USART_ConfigSmartcardMode\n 2874 * CR3 SCEN LL_USART_ConfigSmartcardMode 2875 * @param USARTx USART Instance 2876 * @retval None 2877 */ 2878 __STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx) 2879 { 2880 /* In Smartcard mode, the following bits must be kept cleared: 2881 - LINEN bit in the USART_CR2 register, 2882 - IREN and HDSEL bits in the USART_CR3 register. 2883 */ 2884 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN)); 2885 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL)); 2886 /* Configure Stop bits to 1.5 bits */ 2887 /* Synchronous mode is activated by default */ 2888 SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN)); 2889 /* set the UART/USART in Smartcard mode */ 2890 SET_BIT(USARTx->CR3, USART_CR3_SCEN); 2891 } 2892 2893 /** 2894 * @brief Perform basic configuration of USART for enabling use in Irda Mode 2895 * @note In IRDA mode, the following bits must be kept cleared: 2896 * - LINEN bit in the USART_CR2 register, 2897 * - STOP and CLKEN bits in the USART_CR2 register, 2898 * - SCEN bit in the USART_CR3 register, 2899 * - HDSEL bit in the USART_CR3 register. 2900 * This function also sets the UART/USART in IRDA mode (IREN bit). 2901 * @note Macro IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 2902 * IrDA feature is supported by the USARTx instance. 2903 * @note Call of this function is equivalent to following function call sequence : 2904 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 2905 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 2906 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 2907 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 2908 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function 2909 * - Set IREN in CR3 using @ref LL_USART_EnableIrda() function 2910 * @note Other remaining configurations items related to Irda Mode 2911 * (as Baud Rate, Word length, Power mode, ...) should be set using 2912 * dedicated functions 2913 * @rmtoll CR2 LINEN LL_USART_ConfigIrdaMode\n 2914 * CR2 CLKEN LL_USART_ConfigIrdaMode\n 2915 * CR2 STOP LL_USART_ConfigIrdaMode\n 2916 * CR3 SCEN LL_USART_ConfigIrdaMode\n 2917 * CR3 HDSEL LL_USART_ConfigIrdaMode\n 2918 * CR3 IREN LL_USART_ConfigIrdaMode 2919 * @param USARTx USART Instance 2920 * @retval None 2921 */ 2922 __STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx) 2923 { 2924 /* In IRDA mode, the following bits must be kept cleared: 2925 - LINEN, STOP and CLKEN bits in the USART_CR2 register, 2926 - SCEN and HDSEL bits in the USART_CR3 register. 2927 */ 2928 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP)); 2929 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL)); 2930 /* set the UART/USART in IRDA mode */ 2931 SET_BIT(USARTx->CR3, USART_CR3_IREN); 2932 } 2933 2934 /** 2935 * @brief Perform basic configuration of USART for enabling use in Multi processor Mode 2936 * (several USARTs connected in a network, one of the USARTs can be the master, 2937 * its TX output connected to the RX inputs of the other slaves USARTs). 2938 * @note In MultiProcessor mode, the following bits must be kept cleared: 2939 * - LINEN bit in the USART_CR2 register, 2940 * - CLKEN bit in the USART_CR2 register, 2941 * - SCEN bit in the USART_CR3 register, 2942 * - IREN bit in the USART_CR3 register, 2943 * - HDSEL bit in the USART_CR3 register. 2944 * @note Call of this function is equivalent to following function call sequence : 2945 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 2946 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 2947 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 2948 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 2949 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 2950 * @note Other remaining configurations items related to Multi processor Mode 2951 * (as Baud Rate, Wake Up Method, Node address, ...) should be set using 2952 * dedicated functions 2953 * @rmtoll CR2 LINEN LL_USART_ConfigMultiProcessMode\n 2954 * CR2 CLKEN LL_USART_ConfigMultiProcessMode\n 2955 * CR3 SCEN LL_USART_ConfigMultiProcessMode\n 2956 * CR3 HDSEL LL_USART_ConfigMultiProcessMode\n 2957 * CR3 IREN LL_USART_ConfigMultiProcessMode 2958 * @param USARTx USART Instance 2959 * @retval None 2960 */ 2961 __STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx) 2962 { 2963 /* In Multi Processor mode, the following bits must be kept cleared: 2964 - LINEN and CLKEN bits in the USART_CR2 register, 2965 - IREN, SCEN and HDSEL bits in the USART_CR3 register. 2966 */ 2967 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); 2968 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN)); 2969 } 2970 2971 /** 2972 * @} 2973 */ 2974 2975 /** @defgroup USART_LL_EF_FLAG_Management FLAG_Management 2976 * @ingroup RTEMSBSPsARMSTM32H7 2977 * @{ 2978 */ 2979 2980 /** 2981 * @brief Check if the USART Parity Error Flag is set or not 2982 * @rmtoll ISR PE LL_USART_IsActiveFlag_PE 2983 * @param USARTx USART Instance 2984 * @retval State of bit (1 or 0). 2985 */ 2986 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(const USART_TypeDef *USARTx) 2987 { 2988 return ((READ_BIT(USARTx->ISR, USART_ISR_PE) == (USART_ISR_PE)) ? 1UL : 0UL); 2989 } 2990 2991 /** 2992 * @brief Check if the USART Framing Error Flag is set or not 2993 * @rmtoll ISR FE LL_USART_IsActiveFlag_FE 2994 * @param USARTx USART Instance 2995 * @retval State of bit (1 or 0). 2996 */ 2997 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(const USART_TypeDef *USARTx) 2998 { 2999 return ((READ_BIT(USARTx->ISR, USART_ISR_FE) == (USART_ISR_FE)) ? 1UL : 0UL); 3000 } 3001 3002 /** 3003 * @brief Check if the USART Noise error detected Flag is set or not 3004 * @rmtoll ISR NE LL_USART_IsActiveFlag_NE 3005 * @param USARTx USART Instance 3006 * @retval State of bit (1 or 0). 3007 */ 3008 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(const USART_TypeDef *USARTx) 3009 { 3010 return ((READ_BIT(USARTx->ISR, USART_ISR_NE) == (USART_ISR_NE)) ? 1UL : 0UL); 3011 } 3012 3013 /** 3014 * @brief Check if the USART OverRun Error Flag is set or not 3015 * @rmtoll ISR ORE LL_USART_IsActiveFlag_ORE 3016 * @param USARTx USART Instance 3017 * @retval State of bit (1 or 0). 3018 */ 3019 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(const USART_TypeDef *USARTx) 3020 { 3021 return ((READ_BIT(USARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE)) ? 1UL : 0UL); 3022 } 3023 3024 /** 3025 * @brief Check if the USART IDLE line detected Flag is set or not 3026 * @rmtoll ISR IDLE LL_USART_IsActiveFlag_IDLE 3027 * @param USARTx USART Instance 3028 * @retval State of bit (1 or 0). 3029 */ 3030 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(const USART_TypeDef *USARTx) 3031 { 3032 return ((READ_BIT(USARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE)) ? 1UL : 0UL); 3033 } 3034 3035 #define LL_USART_IsActiveFlag_RXNE LL_USART_IsActiveFlag_RXNE_RXFNE /* Redefinition for legacy purpose */ 3036 3037 /** 3038 * @brief Check if the USART Read Data Register or USART RX FIFO Not Empty Flag is set or not 3039 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3040 * FIFO mode feature is supported by the USARTx instance. 3041 * @rmtoll ISR RXNE_RXFNE LL_USART_IsActiveFlag_RXNE_RXFNE 3042 * @param USARTx USART Instance 3043 * @retval State of bit (1 or 0). 3044 */ 3045 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE_RXFNE(const USART_TypeDef *USARTx) 3046 { 3047 return ((READ_BIT(USARTx->ISR, USART_ISR_RXNE_RXFNE) == (USART_ISR_RXNE_RXFNE)) ? 1UL : 0UL); 3048 } 3049 3050 /** 3051 * @brief Check if the USART Transmission Complete Flag is set or not 3052 * @rmtoll ISR TC LL_USART_IsActiveFlag_TC 3053 * @param USARTx USART Instance 3054 * @retval State of bit (1 or 0). 3055 */ 3056 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(const USART_TypeDef *USARTx) 3057 { 3058 return ((READ_BIT(USARTx->ISR, USART_ISR_TC) == (USART_ISR_TC)) ? 1UL : 0UL); 3059 } 3060 3061 #define LL_USART_IsActiveFlag_TXE LL_USART_IsActiveFlag_TXE_TXFNF /* Redefinition for legacy purpose */ 3062 3063 /** 3064 * @brief Check if the USART Transmit Data Register Empty or USART TX FIFO Not Full Flag is set or not 3065 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3066 * FIFO mode feature is supported by the USARTx instance. 3067 * @rmtoll ISR TXE_TXFNF LL_USART_IsActiveFlag_TXE_TXFNF 3068 * @param USARTx USART Instance 3069 * @retval State of bit (1 or 0). 3070 */ 3071 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE_TXFNF(const USART_TypeDef *USARTx) 3072 { 3073 return ((READ_BIT(USARTx->ISR, USART_ISR_TXE_TXFNF) == (USART_ISR_TXE_TXFNF)) ? 1UL : 0UL); 3074 } 3075 3076 /** 3077 * @brief Check if the USART LIN Break Detection Flag is set or not 3078 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 3079 * LIN feature is supported by the USARTx instance. 3080 * @rmtoll ISR LBDF LL_USART_IsActiveFlag_LBD 3081 * @param USARTx USART Instance 3082 * @retval State of bit (1 or 0). 3083 */ 3084 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(const USART_TypeDef *USARTx) 3085 { 3086 return ((READ_BIT(USARTx->ISR, USART_ISR_LBDF) == (USART_ISR_LBDF)) ? 1UL : 0UL); 3087 } 3088 3089 /** 3090 * @brief Check if the USART CTS interrupt Flag is set or not 3091 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 3092 * Hardware Flow control feature is supported by the USARTx instance. 3093 * @rmtoll ISR CTSIF LL_USART_IsActiveFlag_nCTS 3094 * @param USARTx USART Instance 3095 * @retval State of bit (1 or 0). 3096 */ 3097 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(const USART_TypeDef *USARTx) 3098 { 3099 return ((READ_BIT(USARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF)) ? 1UL : 0UL); 3100 } 3101 3102 /** 3103 * @brief Check if the USART CTS Flag is set or not 3104 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 3105 * Hardware Flow control feature is supported by the USARTx instance. 3106 * @rmtoll ISR CTS LL_USART_IsActiveFlag_CTS 3107 * @param USARTx USART Instance 3108 * @retval State of bit (1 or 0). 3109 */ 3110 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CTS(const USART_TypeDef *USARTx) 3111 { 3112 return ((READ_BIT(USARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS)) ? 1UL : 0UL); 3113 } 3114 3115 /** 3116 * @brief Check if the USART Receiver Time Out Flag is set or not 3117 * @rmtoll ISR RTOF LL_USART_IsActiveFlag_RTO 3118 * @param USARTx USART Instance 3119 * @retval State of bit (1 or 0). 3120 */ 3121 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RTO(const USART_TypeDef *USARTx) 3122 { 3123 return ((READ_BIT(USARTx->ISR, USART_ISR_RTOF) == (USART_ISR_RTOF)) ? 1UL : 0UL); 3124 } 3125 3126 /** 3127 * @brief Check if the USART End Of Block Flag is set or not 3128 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 3129 * Smartcard feature is supported by the USARTx instance. 3130 * @rmtoll ISR EOBF LL_USART_IsActiveFlag_EOB 3131 * @param USARTx USART Instance 3132 * @retval State of bit (1 or 0). 3133 */ 3134 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_EOB(const USART_TypeDef *USARTx) 3135 { 3136 return ((READ_BIT(USARTx->ISR, USART_ISR_EOBF) == (USART_ISR_EOBF)) ? 1UL : 0UL); 3137 } 3138 3139 /** 3140 * @brief Check if the SPI Slave Underrun error flag is set or not 3141 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 3142 * SPI Slave mode feature is supported by the USARTx instance. 3143 * @rmtoll ISR UDR LL_USART_IsActiveFlag_UDR 3144 * @param USARTx USART Instance 3145 * @retval State of bit (1 or 0). 3146 */ 3147 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_UDR(const USART_TypeDef *USARTx) 3148 { 3149 return ((READ_BIT(USARTx->ISR, USART_ISR_UDR) == (USART_ISR_UDR)) ? 1UL : 0UL); 3150 } 3151 3152 /** 3153 * @brief Check if the USART Auto-Baud Rate Error Flag is set or not 3154 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 3155 * Auto Baud Rate detection feature is supported by the USARTx instance. 3156 * @rmtoll ISR ABRE LL_USART_IsActiveFlag_ABRE 3157 * @param USARTx USART Instance 3158 * @retval State of bit (1 or 0). 3159 */ 3160 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABRE(const USART_TypeDef *USARTx) 3161 { 3162 return ((READ_BIT(USARTx->ISR, USART_ISR_ABRE) == (USART_ISR_ABRE)) ? 1UL : 0UL); 3163 } 3164 3165 /** 3166 * @brief Check if the USART Auto-Baud Rate Flag is set or not 3167 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 3168 * Auto Baud Rate detection feature is supported by the USARTx instance. 3169 * @rmtoll ISR ABRF LL_USART_IsActiveFlag_ABR 3170 * @param USARTx USART Instance 3171 * @retval State of bit (1 or 0). 3172 */ 3173 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABR(const USART_TypeDef *USARTx) 3174 { 3175 return ((READ_BIT(USARTx->ISR, USART_ISR_ABRF) == (USART_ISR_ABRF)) ? 1UL : 0UL); 3176 } 3177 3178 /** 3179 * @brief Check if the USART Busy Flag is set or not 3180 * @rmtoll ISR BUSY LL_USART_IsActiveFlag_BUSY 3181 * @param USARTx USART Instance 3182 * @retval State of bit (1 or 0). 3183 */ 3184 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_BUSY(const USART_TypeDef *USARTx) 3185 { 3186 return ((READ_BIT(USARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY)) ? 1UL : 0UL); 3187 } 3188 3189 /** 3190 * @brief Check if the USART Character Match Flag is set or not 3191 * @rmtoll ISR CMF LL_USART_IsActiveFlag_CM 3192 * @param USARTx USART Instance 3193 * @retval State of bit (1 or 0). 3194 */ 3195 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CM(const USART_TypeDef *USARTx) 3196 { 3197 return ((READ_BIT(USARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF)) ? 1UL : 0UL); 3198 } 3199 3200 /** 3201 * @brief Check if the USART Send Break Flag is set or not 3202 * @rmtoll ISR SBKF LL_USART_IsActiveFlag_SBK 3203 * @param USARTx USART Instance 3204 * @retval State of bit (1 or 0). 3205 */ 3206 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(const USART_TypeDef *USARTx) 3207 { 3208 return ((READ_BIT(USARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF)) ? 1UL : 0UL); 3209 } 3210 3211 /** 3212 * @brief Check if the USART Receive Wake Up from mute mode Flag is set or not 3213 * @rmtoll ISR RWU LL_USART_IsActiveFlag_RWU 3214 * @param USARTx USART Instance 3215 * @retval State of bit (1 or 0). 3216 */ 3217 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(const USART_TypeDef *USARTx) 3218 { 3219 return ((READ_BIT(USARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU)) ? 1UL : 0UL); 3220 } 3221 3222 /** 3223 * @brief Check if the USART Wake Up from stop mode Flag is set or not 3224 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 3225 * Wake-up from Stop mode feature is supported by the USARTx instance. 3226 * @rmtoll ISR WUF LL_USART_IsActiveFlag_WKUP 3227 * @param USARTx USART Instance 3228 * @retval State of bit (1 or 0). 3229 */ 3230 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_WKUP(const USART_TypeDef *USARTx) 3231 { 3232 return ((READ_BIT(USARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF)) ? 1UL : 0UL); 3233 } 3234 3235 /** 3236 * @brief Check if the USART Transmit Enable Acknowledge Flag is set or not 3237 * @rmtoll ISR TEACK LL_USART_IsActiveFlag_TEACK 3238 * @param USARTx USART Instance 3239 * @retval State of bit (1 or 0). 3240 */ 3241 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TEACK(const USART_TypeDef *USARTx) 3242 { 3243 return ((READ_BIT(USARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK)) ? 1UL : 0UL); 3244 } 3245 3246 /** 3247 * @brief Check if the USART Receive Enable Acknowledge Flag is set or not 3248 * @rmtoll ISR REACK LL_USART_IsActiveFlag_REACK 3249 * @param USARTx USART Instance 3250 * @retval State of bit (1 or 0). 3251 */ 3252 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_REACK(const USART_TypeDef *USARTx) 3253 { 3254 return ((READ_BIT(USARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK)) ? 1UL : 0UL); 3255 } 3256 3257 /** 3258 * @brief Check if the USART TX FIFO Empty Flag is set or not 3259 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3260 * FIFO mode feature is supported by the USARTx instance. 3261 * @rmtoll ISR TXFE LL_USART_IsActiveFlag_TXFE 3262 * @param USARTx USART Instance 3263 * @retval State of bit (1 or 0). 3264 */ 3265 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXFE(const USART_TypeDef *USARTx) 3266 { 3267 return ((READ_BIT(USARTx->ISR, USART_ISR_TXFE) == (USART_ISR_TXFE)) ? 1UL : 0UL); 3268 } 3269 3270 /** 3271 * @brief Check if the USART RX FIFO Full Flag is set or not 3272 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3273 * FIFO mode feature is supported by the USARTx instance. 3274 * @rmtoll ISR RXFF LL_USART_IsActiveFlag_RXFF 3275 * @param USARTx USART Instance 3276 * @retval State of bit (1 or 0). 3277 */ 3278 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXFF(const USART_TypeDef *USARTx) 3279 { 3280 return ((READ_BIT(USARTx->ISR, USART_ISR_RXFF) == (USART_ISR_RXFF)) ? 1UL : 0UL); 3281 } 3282 3283 /** 3284 * @brief Check if the Smartcard Transmission Complete Before Guard Time Flag is set or not 3285 * @rmtoll ISR TCBGT LL_USART_IsActiveFlag_TCBGT 3286 * @param USARTx USART Instance 3287 * @retval State of bit (1 or 0). 3288 */ 3289 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TCBGT(const USART_TypeDef *USARTx) 3290 { 3291 return ((READ_BIT(USARTx->ISR, USART_ISR_TCBGT) == (USART_ISR_TCBGT)) ? 1UL : 0UL); 3292 } 3293 3294 /** 3295 * @brief Check if the USART TX FIFO Threshold Flag is set or not 3296 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3297 * FIFO mode feature is supported by the USARTx instance. 3298 * @rmtoll ISR TXFT LL_USART_IsActiveFlag_TXFT 3299 * @param USARTx USART Instance 3300 * @retval State of bit (1 or 0). 3301 */ 3302 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXFT(const USART_TypeDef *USARTx) 3303 { 3304 return ((READ_BIT(USARTx->ISR, USART_ISR_TXFT) == (USART_ISR_TXFT)) ? 1UL : 0UL); 3305 } 3306 3307 /** 3308 * @brief Check if the USART RX FIFO Threshold Flag is set or not 3309 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3310 * FIFO mode feature is supported by the USARTx instance. 3311 * @rmtoll ISR RXFT LL_USART_IsActiveFlag_RXFT 3312 * @param USARTx USART Instance 3313 * @retval State of bit (1 or 0). 3314 */ 3315 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXFT(const USART_TypeDef *USARTx) 3316 { 3317 return ((READ_BIT(USARTx->ISR, USART_ISR_RXFT) == (USART_ISR_RXFT)) ? 1UL : 0UL); 3318 } 3319 3320 /** 3321 * @brief Clear Parity Error Flag 3322 * @rmtoll ICR PECF LL_USART_ClearFlag_PE 3323 * @param USARTx USART Instance 3324 * @retval None 3325 */ 3326 __STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx) 3327 { 3328 WRITE_REG(USARTx->ICR, USART_ICR_PECF); 3329 } 3330 3331 /** 3332 * @brief Clear Framing Error Flag 3333 * @rmtoll ICR FECF LL_USART_ClearFlag_FE 3334 * @param USARTx USART Instance 3335 * @retval None 3336 */ 3337 __STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx) 3338 { 3339 WRITE_REG(USARTx->ICR, USART_ICR_FECF); 3340 } 3341 3342 /** 3343 * @brief Clear Noise Error detected Flag 3344 * @rmtoll ICR NECF LL_USART_ClearFlag_NE 3345 * @param USARTx USART Instance 3346 * @retval None 3347 */ 3348 __STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx) 3349 { 3350 WRITE_REG(USARTx->ICR, USART_ICR_NECF); 3351 } 3352 3353 /** 3354 * @brief Clear OverRun Error Flag 3355 * @rmtoll ICR ORECF LL_USART_ClearFlag_ORE 3356 * @param USARTx USART Instance 3357 * @retval None 3358 */ 3359 __STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx) 3360 { 3361 WRITE_REG(USARTx->ICR, USART_ICR_ORECF); 3362 } 3363 3364 /** 3365 * @brief Clear IDLE line detected Flag 3366 * @rmtoll ICR IDLECF LL_USART_ClearFlag_IDLE 3367 * @param USARTx USART Instance 3368 * @retval None 3369 */ 3370 __STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx) 3371 { 3372 WRITE_REG(USARTx->ICR, USART_ICR_IDLECF); 3373 } 3374 3375 /** 3376 * @brief Clear TX FIFO Empty Flag 3377 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3378 * FIFO mode feature is supported by the USARTx instance. 3379 * @rmtoll ICR TXFECF LL_USART_ClearFlag_TXFE 3380 * @param USARTx USART Instance 3381 * @retval None 3382 */ 3383 __STATIC_INLINE void LL_USART_ClearFlag_TXFE(USART_TypeDef *USARTx) 3384 { 3385 WRITE_REG(USARTx->ICR, USART_ICR_TXFECF); 3386 } 3387 3388 /** 3389 * @brief Clear Transmission Complete Flag 3390 * @rmtoll ICR TCCF LL_USART_ClearFlag_TC 3391 * @param USARTx USART Instance 3392 * @retval None 3393 */ 3394 __STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx) 3395 { 3396 WRITE_REG(USARTx->ICR, USART_ICR_TCCF); 3397 } 3398 3399 /** 3400 * @brief Clear Smartcard Transmission Complete Before Guard Time Flag 3401 * @rmtoll ICR TCBGTCF LL_USART_ClearFlag_TCBGT 3402 * @param USARTx USART Instance 3403 * @retval None 3404 */ 3405 __STATIC_INLINE void LL_USART_ClearFlag_TCBGT(USART_TypeDef *USARTx) 3406 { 3407 WRITE_REG(USARTx->ICR, USART_ICR_TCBGTCF); 3408 } 3409 3410 /** 3411 * @brief Clear LIN Break Detection Flag 3412 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 3413 * LIN feature is supported by the USARTx instance. 3414 * @rmtoll ICR LBDCF LL_USART_ClearFlag_LBD 3415 * @param USARTx USART Instance 3416 * @retval None 3417 */ 3418 __STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx) 3419 { 3420 WRITE_REG(USARTx->ICR, USART_ICR_LBDCF); 3421 } 3422 3423 /** 3424 * @brief Clear CTS Interrupt Flag 3425 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 3426 * Hardware Flow control feature is supported by the USARTx instance. 3427 * @rmtoll ICR CTSCF LL_USART_ClearFlag_nCTS 3428 * @param USARTx USART Instance 3429 * @retval None 3430 */ 3431 __STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx) 3432 { 3433 WRITE_REG(USARTx->ICR, USART_ICR_CTSCF); 3434 } 3435 3436 /** 3437 * @brief Clear Receiver Time Out Flag 3438 * @rmtoll ICR RTOCF LL_USART_ClearFlag_RTO 3439 * @param USARTx USART Instance 3440 * @retval None 3441 */ 3442 __STATIC_INLINE void LL_USART_ClearFlag_RTO(USART_TypeDef *USARTx) 3443 { 3444 WRITE_REG(USARTx->ICR, USART_ICR_RTOCF); 3445 } 3446 3447 /** 3448 * @brief Clear End Of Block Flag 3449 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 3450 * Smartcard feature is supported by the USARTx instance. 3451 * @rmtoll ICR EOBCF LL_USART_ClearFlag_EOB 3452 * @param USARTx USART Instance 3453 * @retval None 3454 */ 3455 __STATIC_INLINE void LL_USART_ClearFlag_EOB(USART_TypeDef *USARTx) 3456 { 3457 WRITE_REG(USARTx->ICR, USART_ICR_EOBCF); 3458 } 3459 3460 /** 3461 * @brief Clear SPI Slave Underrun Flag 3462 * @note Macro IS_UART_SPI_SLAVE_INSTANCE(USARTx) can be used to check whether or not 3463 * SPI Slave mode feature is supported by the USARTx instance. 3464 * @rmtoll ICR UDRCF LL_USART_ClearFlag_UDR 3465 * @param USARTx USART Instance 3466 * @retval None 3467 */ 3468 __STATIC_INLINE void LL_USART_ClearFlag_UDR(USART_TypeDef *USARTx) 3469 { 3470 WRITE_REG(USARTx->ICR, USART_ICR_UDRCF); 3471 } 3472 3473 /** 3474 * @brief Clear Character Match Flag 3475 * @rmtoll ICR CMCF LL_USART_ClearFlag_CM 3476 * @param USARTx USART Instance 3477 * @retval None 3478 */ 3479 __STATIC_INLINE void LL_USART_ClearFlag_CM(USART_TypeDef *USARTx) 3480 { 3481 WRITE_REG(USARTx->ICR, USART_ICR_CMCF); 3482 } 3483 3484 /** 3485 * @brief Clear Wake Up from stop mode Flag 3486 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 3487 * Wake-up from Stop mode feature is supported by the USARTx instance. 3488 * @rmtoll ICR WUCF LL_USART_ClearFlag_WKUP 3489 * @param USARTx USART Instance 3490 * @retval None 3491 */ 3492 __STATIC_INLINE void LL_USART_ClearFlag_WKUP(USART_TypeDef *USARTx) 3493 { 3494 WRITE_REG(USARTx->ICR, USART_ICR_WUCF); 3495 } 3496 3497 /** 3498 * @} 3499 */ 3500 3501 /** @defgroup USART_LL_EF_IT_Management IT_Management 3502 * @ingroup RTEMSBSPsARMSTM32H7 3503 * @{ 3504 */ 3505 3506 /** 3507 * @brief Enable IDLE Interrupt 3508 * @rmtoll CR1 IDLEIE LL_USART_EnableIT_IDLE 3509 * @param USARTx USART Instance 3510 * @retval None 3511 */ 3512 __STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx) 3513 { 3514 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_IDLEIE); 3515 } 3516 3517 #define LL_USART_EnableIT_RXNE LL_USART_EnableIT_RXNE_RXFNE /* Redefinition for legacy purpose */ 3518 3519 /** 3520 * @brief Enable RX Not Empty and RX FIFO Not Empty Interrupt 3521 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3522 * FIFO mode feature is supported by the USARTx instance. 3523 * @rmtoll CR1 RXNEIE_RXFNEIE LL_USART_EnableIT_RXNE_RXFNE 3524 * @param USARTx USART Instance 3525 * @retval None 3526 */ 3527 __STATIC_INLINE void LL_USART_EnableIT_RXNE_RXFNE(USART_TypeDef *USARTx) 3528 { 3529 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_RXNEIE_RXFNEIE); 3530 } 3531 3532 /** 3533 * @brief Enable Transmission Complete Interrupt 3534 * @rmtoll CR1 TCIE LL_USART_EnableIT_TC 3535 * @param USARTx USART Instance 3536 * @retval None 3537 */ 3538 __STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx) 3539 { 3540 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_TCIE); 3541 } 3542 3543 #define LL_USART_EnableIT_TXE LL_USART_EnableIT_TXE_TXFNF /* Redefinition for legacy purpose */ 3544 3545 /** 3546 * @brief Enable TX Empty and TX FIFO Not Full Interrupt 3547 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3548 * FIFO mode feature is supported by the USARTx instance. 3549 * @rmtoll CR1 TXEIE_TXFNFIE LL_USART_EnableIT_TXE_TXFNF 3550 * @param USARTx USART Instance 3551 * @retval None 3552 */ 3553 __STATIC_INLINE void LL_USART_EnableIT_TXE_TXFNF(USART_TypeDef *USARTx) 3554 { 3555 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_TXEIE_TXFNFIE); 3556 } 3557 3558 /** 3559 * @brief Enable Parity Error Interrupt 3560 * @rmtoll CR1 PEIE LL_USART_EnableIT_PE 3561 * @param USARTx USART Instance 3562 * @retval None 3563 */ 3564 __STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx) 3565 { 3566 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_PEIE); 3567 } 3568 3569 /** 3570 * @brief Enable Character Match Interrupt 3571 * @rmtoll CR1 CMIE LL_USART_EnableIT_CM 3572 * @param USARTx USART Instance 3573 * @retval None 3574 */ 3575 __STATIC_INLINE void LL_USART_EnableIT_CM(USART_TypeDef *USARTx) 3576 { 3577 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_CMIE); 3578 } 3579 3580 /** 3581 * @brief Enable Receiver Timeout Interrupt 3582 * @rmtoll CR1 RTOIE LL_USART_EnableIT_RTO 3583 * @param USARTx USART Instance 3584 * @retval None 3585 */ 3586 __STATIC_INLINE void LL_USART_EnableIT_RTO(USART_TypeDef *USARTx) 3587 { 3588 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_RTOIE); 3589 } 3590 3591 /** 3592 * @brief Enable End Of Block Interrupt 3593 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 3594 * Smartcard feature is supported by the USARTx instance. 3595 * @rmtoll CR1 EOBIE LL_USART_EnableIT_EOB 3596 * @param USARTx USART Instance 3597 * @retval None 3598 */ 3599 __STATIC_INLINE void LL_USART_EnableIT_EOB(USART_TypeDef *USARTx) 3600 { 3601 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_EOBIE); 3602 } 3603 3604 /** 3605 * @brief Enable TX FIFO Empty Interrupt 3606 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3607 * FIFO mode feature is supported by the USARTx instance. 3608 * @rmtoll CR1 TXFEIE LL_USART_EnableIT_TXFE 3609 * @param USARTx USART Instance 3610 * @retval None 3611 */ 3612 __STATIC_INLINE void LL_USART_EnableIT_TXFE(USART_TypeDef *USARTx) 3613 { 3614 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_TXFEIE); 3615 } 3616 3617 /** 3618 * @brief Enable RX FIFO Full Interrupt 3619 * @rmtoll CR1 RXFFIE LL_USART_EnableIT_RXFF 3620 * @param USARTx USART Instance 3621 * @retval None 3622 */ 3623 __STATIC_INLINE void LL_USART_EnableIT_RXFF(USART_TypeDef *USARTx) 3624 { 3625 ATOMIC_SET_BIT(USARTx->CR1, USART_CR1_RXFFIE); 3626 } 3627 3628 /** 3629 * @brief Enable LIN Break Detection Interrupt 3630 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 3631 * LIN feature is supported by the USARTx instance. 3632 * @rmtoll CR2 LBDIE LL_USART_EnableIT_LBD 3633 * @param USARTx USART Instance 3634 * @retval None 3635 */ 3636 __STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx) 3637 { 3638 SET_BIT(USARTx->CR2, USART_CR2_LBDIE); 3639 } 3640 3641 /** 3642 * @brief Enable Error Interrupt 3643 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing 3644 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register). 3645 * 0: Interrupt is inhibited 3646 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register. 3647 * @rmtoll CR3 EIE LL_USART_EnableIT_ERROR 3648 * @param USARTx USART Instance 3649 * @retval None 3650 */ 3651 __STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx) 3652 { 3653 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_EIE); 3654 } 3655 3656 /** 3657 * @brief Enable CTS Interrupt 3658 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 3659 * Hardware Flow control feature is supported by the USARTx instance. 3660 * @rmtoll CR3 CTSIE LL_USART_EnableIT_CTS 3661 * @param USARTx USART Instance 3662 * @retval None 3663 */ 3664 __STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx) 3665 { 3666 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_CTSIE); 3667 } 3668 3669 /** 3670 * @brief Enable Wake Up from Stop Mode Interrupt 3671 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 3672 * Wake-up from Stop mode feature is supported by the USARTx instance. 3673 * @rmtoll CR3 WUFIE LL_USART_EnableIT_WKUP 3674 * @param USARTx USART Instance 3675 * @retval None 3676 */ 3677 __STATIC_INLINE void LL_USART_EnableIT_WKUP(USART_TypeDef *USARTx) 3678 { 3679 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_WUFIE); 3680 } 3681 3682 /** 3683 * @brief Enable TX FIFO Threshold Interrupt 3684 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3685 * FIFO mode feature is supported by the USARTx instance. 3686 * @rmtoll CR3 TXFTIE LL_USART_EnableIT_TXFT 3687 * @param USARTx USART Instance 3688 * @retval None 3689 */ 3690 __STATIC_INLINE void LL_USART_EnableIT_TXFT(USART_TypeDef *USARTx) 3691 { 3692 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_TXFTIE); 3693 } 3694 3695 /** 3696 * @brief Enable Smartcard Transmission Complete Before Guard Time Interrupt 3697 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 3698 * Smartcard feature is supported by the USARTx instance. 3699 * @rmtoll CR3 TCBGTIE LL_USART_EnableIT_TCBGT 3700 * @param USARTx USART Instance 3701 * @retval None 3702 */ 3703 __STATIC_INLINE void LL_USART_EnableIT_TCBGT(USART_TypeDef *USARTx) 3704 { 3705 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_TCBGTIE); 3706 } 3707 3708 /** 3709 * @brief Enable RX FIFO Threshold Interrupt 3710 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3711 * FIFO mode feature is supported by the USARTx instance. 3712 * @rmtoll CR3 RXFTIE LL_USART_EnableIT_RXFT 3713 * @param USARTx USART Instance 3714 * @retval None 3715 */ 3716 __STATIC_INLINE void LL_USART_EnableIT_RXFT(USART_TypeDef *USARTx) 3717 { 3718 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_RXFTIE); 3719 } 3720 3721 /** 3722 * @brief Disable IDLE Interrupt 3723 * @rmtoll CR1 IDLEIE LL_USART_DisableIT_IDLE 3724 * @param USARTx USART Instance 3725 * @retval None 3726 */ 3727 __STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx) 3728 { 3729 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE); 3730 } 3731 3732 #define LL_USART_DisableIT_RXNE LL_USART_DisableIT_RXNE_RXFNE /* Redefinition for legacy purpose */ 3733 3734 /** 3735 * @brief Disable RX Not Empty and RX FIFO Not Empty Interrupt 3736 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3737 * FIFO mode feature is supported by the USARTx instance. 3738 * @rmtoll CR1 RXNEIE_RXFNEIE LL_USART_DisableIT_RXNE_RXFNE 3739 * @param USARTx USART Instance 3740 * @retval None 3741 */ 3742 __STATIC_INLINE void LL_USART_DisableIT_RXNE_RXFNE(USART_TypeDef *USARTx) 3743 { 3744 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE_RXFNEIE); 3745 } 3746 3747 /** 3748 * @brief Disable Transmission Complete Interrupt 3749 * @rmtoll CR1 TCIE LL_USART_DisableIT_TC 3750 * @param USARTx USART Instance 3751 * @retval None 3752 */ 3753 __STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx) 3754 { 3755 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE); 3756 } 3757 3758 #define LL_USART_DisableIT_TXE LL_USART_DisableIT_TXE_TXFNF /* Redefinition for legacy purpose */ 3759 3760 /** 3761 * @brief Disable TX Empty and TX FIFO Not Full Interrupt 3762 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3763 * FIFO mode feature is supported by the USARTx instance. 3764 * @rmtoll CR1 TXEIE_TXFNFIE LL_USART_DisableIT_TXE_TXFNF 3765 * @param USARTx USART Instance 3766 * @retval None 3767 */ 3768 __STATIC_INLINE void LL_USART_DisableIT_TXE_TXFNF(USART_TypeDef *USARTx) 3769 { 3770 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE_TXFNFIE); 3771 } 3772 3773 /** 3774 * @brief Disable Parity Error Interrupt 3775 * @rmtoll CR1 PEIE LL_USART_DisableIT_PE 3776 * @param USARTx USART Instance 3777 * @retval None 3778 */ 3779 __STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx) 3780 { 3781 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE); 3782 } 3783 3784 /** 3785 * @brief Disable Character Match Interrupt 3786 * @rmtoll CR1 CMIE LL_USART_DisableIT_CM 3787 * @param USARTx USART Instance 3788 * @retval None 3789 */ 3790 __STATIC_INLINE void LL_USART_DisableIT_CM(USART_TypeDef *USARTx) 3791 { 3792 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_CMIE); 3793 } 3794 3795 /** 3796 * @brief Disable Receiver Timeout Interrupt 3797 * @rmtoll CR1 RTOIE LL_USART_DisableIT_RTO 3798 * @param USARTx USART Instance 3799 * @retval None 3800 */ 3801 __STATIC_INLINE void LL_USART_DisableIT_RTO(USART_TypeDef *USARTx) 3802 { 3803 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_RTOIE); 3804 } 3805 3806 /** 3807 * @brief Disable End Of Block Interrupt 3808 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 3809 * Smartcard feature is supported by the USARTx instance. 3810 * @rmtoll CR1 EOBIE LL_USART_DisableIT_EOB 3811 * @param USARTx USART Instance 3812 * @retval None 3813 */ 3814 __STATIC_INLINE void LL_USART_DisableIT_EOB(USART_TypeDef *USARTx) 3815 { 3816 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_EOBIE); 3817 } 3818 3819 /** 3820 * @brief Disable TX FIFO Empty Interrupt 3821 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3822 * FIFO mode feature is supported by the USARTx instance. 3823 * @rmtoll CR1 TXFEIE LL_USART_DisableIT_TXFE 3824 * @param USARTx USART Instance 3825 * @retval None 3826 */ 3827 __STATIC_INLINE void LL_USART_DisableIT_TXFE(USART_TypeDef *USARTx) 3828 { 3829 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_TXFEIE); 3830 } 3831 3832 /** 3833 * @brief Disable RX FIFO Full Interrupt 3834 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3835 * FIFO mode feature is supported by the USARTx instance. 3836 * @rmtoll CR1 RXFFIE LL_USART_DisableIT_RXFF 3837 * @param USARTx USART Instance 3838 * @retval None 3839 */ 3840 __STATIC_INLINE void LL_USART_DisableIT_RXFF(USART_TypeDef *USARTx) 3841 { 3842 ATOMIC_CLEAR_BIT(USARTx->CR1, USART_CR1_RXFFIE); 3843 } 3844 3845 /** 3846 * @brief Disable LIN Break Detection Interrupt 3847 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 3848 * LIN feature is supported by the USARTx instance. 3849 * @rmtoll CR2 LBDIE LL_USART_DisableIT_LBD 3850 * @param USARTx USART Instance 3851 * @retval None 3852 */ 3853 __STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx) 3854 { 3855 CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE); 3856 } 3857 3858 /** 3859 * @brief Disable Error Interrupt 3860 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing 3861 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register). 3862 * 0: Interrupt is inhibited 3863 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register. 3864 * @rmtoll CR3 EIE LL_USART_DisableIT_ERROR 3865 * @param USARTx USART Instance 3866 * @retval None 3867 */ 3868 __STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx) 3869 { 3870 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_EIE); 3871 } 3872 3873 /** 3874 * @brief Disable CTS Interrupt 3875 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 3876 * Hardware Flow control feature is supported by the USARTx instance. 3877 * @rmtoll CR3 CTSIE LL_USART_DisableIT_CTS 3878 * @param USARTx USART Instance 3879 * @retval None 3880 */ 3881 __STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx) 3882 { 3883 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE); 3884 } 3885 3886 /** 3887 * @brief Disable Wake Up from Stop Mode Interrupt 3888 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 3889 * Wake-up from Stop mode feature is supported by the USARTx instance. 3890 * @rmtoll CR3 WUFIE LL_USART_DisableIT_WKUP 3891 * @param USARTx USART Instance 3892 * @retval None 3893 */ 3894 __STATIC_INLINE void LL_USART_DisableIT_WKUP(USART_TypeDef *USARTx) 3895 { 3896 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_WUFIE); 3897 } 3898 3899 /** 3900 * @brief Disable TX FIFO Threshold Interrupt 3901 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3902 * FIFO mode feature is supported by the USARTx instance. 3903 * @rmtoll CR3 TXFTIE LL_USART_DisableIT_TXFT 3904 * @param USARTx USART Instance 3905 * @retval None 3906 */ 3907 __STATIC_INLINE void LL_USART_DisableIT_TXFT(USART_TypeDef *USARTx) 3908 { 3909 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_TXFTIE); 3910 } 3911 3912 /** 3913 * @brief Disable Smartcard Transmission Complete Before Guard Time Interrupt 3914 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 3915 * Smartcard feature is supported by the USARTx instance. 3916 * @rmtoll CR3 TCBGTIE LL_USART_DisableIT_TCBGT 3917 * @param USARTx USART Instance 3918 * @retval None 3919 */ 3920 __STATIC_INLINE void LL_USART_DisableIT_TCBGT(USART_TypeDef *USARTx) 3921 { 3922 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_TCBGTIE); 3923 } 3924 3925 /** 3926 * @brief Disable RX FIFO Threshold Interrupt 3927 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3928 * FIFO mode feature is supported by the USARTx instance. 3929 * @rmtoll CR3 RXFTIE LL_USART_DisableIT_RXFT 3930 * @param USARTx USART Instance 3931 * @retval None 3932 */ 3933 __STATIC_INLINE void LL_USART_DisableIT_RXFT(USART_TypeDef *USARTx) 3934 { 3935 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_RXFTIE); 3936 } 3937 3938 /** 3939 * @brief Check if the USART IDLE Interrupt source is enabled or disabled. 3940 * @rmtoll CR1 IDLEIE LL_USART_IsEnabledIT_IDLE 3941 * @param USARTx USART Instance 3942 * @retval State of bit (1 or 0). 3943 */ 3944 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(const USART_TypeDef *USARTx) 3945 { 3946 return ((READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE)) ? 1UL : 0UL); 3947 } 3948 3949 #define LL_USART_IsEnabledIT_RXNE LL_USART_IsEnabledIT_RXNE_RXFNE /* Redefinition for legacy purpose */ 3950 3951 /** 3952 * @brief Check if the USART RX Not Empty and USART RX FIFO Not Empty Interrupt is enabled or disabled. 3953 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3954 * FIFO mode feature is supported by the USARTx instance. 3955 * @rmtoll CR1 RXNEIE_RXFNEIE LL_USART_IsEnabledIT_RXNE_RXFNE 3956 * @param USARTx USART Instance 3957 * @retval State of bit (1 or 0). 3958 */ 3959 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE_RXFNE(const USART_TypeDef *USARTx) 3960 { 3961 return ((READ_BIT(USARTx->CR1, USART_CR1_RXNEIE_RXFNEIE) == (USART_CR1_RXNEIE_RXFNEIE)) ? 1UL : 0UL); 3962 } 3963 3964 /** 3965 * @brief Check if the USART Transmission Complete Interrupt is enabled or disabled. 3966 * @rmtoll CR1 TCIE LL_USART_IsEnabledIT_TC 3967 * @param USARTx USART Instance 3968 * @retval State of bit (1 or 0). 3969 */ 3970 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(const USART_TypeDef *USARTx) 3971 { 3972 return ((READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE)) ? 1UL : 0UL); 3973 } 3974 3975 #define LL_USART_IsEnabledIT_TXE LL_USART_IsEnabledIT_TXE_TXFNF /* Redefinition for legacy purpose */ 3976 3977 /** 3978 * @brief Check if the USART TX Empty and USART TX FIFO Not Full Interrupt is enabled or disabled 3979 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 3980 * FIFO mode feature is supported by the USARTx instance. 3981 * @rmtoll CR1 TXEIE_TXFNFIE LL_USART_IsEnabledIT_TXE_TXFNF 3982 * @param USARTx USART Instance 3983 * @retval State of bit (1 or 0). 3984 */ 3985 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE_TXFNF(const USART_TypeDef *USARTx) 3986 { 3987 return ((READ_BIT(USARTx->CR1, USART_CR1_TXEIE_TXFNFIE) == (USART_CR1_TXEIE_TXFNFIE)) ? 1UL : 0UL); 3988 } 3989 3990 /** 3991 * @brief Check if the USART Parity Error Interrupt is enabled or disabled. 3992 * @rmtoll CR1 PEIE LL_USART_IsEnabledIT_PE 3993 * @param USARTx USART Instance 3994 * @retval State of bit (1 or 0). 3995 */ 3996 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(const USART_TypeDef *USARTx) 3997 { 3998 return ((READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE)) ? 1UL : 0UL); 3999 } 4000 4001 /** 4002 * @brief Check if the USART Character Match Interrupt is enabled or disabled. 4003 * @rmtoll CR1 CMIE LL_USART_IsEnabledIT_CM 4004 * @param USARTx USART Instance 4005 * @retval State of bit (1 or 0). 4006 */ 4007 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CM(const USART_TypeDef *USARTx) 4008 { 4009 return ((READ_BIT(USARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE)) ? 1UL : 0UL); 4010 } 4011 4012 /** 4013 * @brief Check if the USART Receiver Timeout Interrupt is enabled or disabled. 4014 * @rmtoll CR1 RTOIE LL_USART_IsEnabledIT_RTO 4015 * @param USARTx USART Instance 4016 * @retval State of bit (1 or 0). 4017 */ 4018 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RTO(const USART_TypeDef *USARTx) 4019 { 4020 return ((READ_BIT(USARTx->CR1, USART_CR1_RTOIE) == (USART_CR1_RTOIE)) ? 1UL : 0UL); 4021 } 4022 4023 /** 4024 * @brief Check if the USART End Of Block Interrupt is enabled or disabled. 4025 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 4026 * Smartcard feature is supported by the USARTx instance. 4027 * @rmtoll CR1 EOBIE LL_USART_IsEnabledIT_EOB 4028 * @param USARTx USART Instance 4029 * @retval State of bit (1 or 0). 4030 */ 4031 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_EOB(const USART_TypeDef *USARTx) 4032 { 4033 return ((READ_BIT(USARTx->CR1, USART_CR1_EOBIE) == (USART_CR1_EOBIE)) ? 1UL : 0UL); 4034 } 4035 4036 /** 4037 * @brief Check if the USART TX FIFO Empty Interrupt is enabled or disabled 4038 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 4039 * FIFO mode feature is supported by the USARTx instance. 4040 * @rmtoll CR1 TXFEIE LL_USART_IsEnabledIT_TXFE 4041 * @param USARTx USART Instance 4042 * @retval State of bit (1 or 0). 4043 */ 4044 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXFE(const USART_TypeDef *USARTx) 4045 { 4046 return ((READ_BIT(USARTx->CR1, USART_CR1_TXFEIE) == (USART_CR1_TXFEIE)) ? 1UL : 0UL); 4047 } 4048 4049 /** 4050 * @brief Check if the USART RX FIFO Full Interrupt is enabled or disabled 4051 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 4052 * FIFO mode feature is supported by the USARTx instance. 4053 * @rmtoll CR1 RXFFIE LL_USART_IsEnabledIT_RXFF 4054 * @param USARTx USART Instance 4055 * @retval State of bit (1 or 0). 4056 */ 4057 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXFF(const USART_TypeDef *USARTx) 4058 { 4059 return ((READ_BIT(USARTx->CR1, USART_CR1_RXFFIE) == (USART_CR1_RXFFIE)) ? 1UL : 0UL); 4060 } 4061 4062 /** 4063 * @brief Check if the USART LIN Break Detection Interrupt is enabled or disabled. 4064 * @note Macro IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 4065 * LIN feature is supported by the USARTx instance. 4066 * @rmtoll CR2 LBDIE LL_USART_IsEnabledIT_LBD 4067 * @param USARTx USART Instance 4068 * @retval State of bit (1 or 0). 4069 */ 4070 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(const USART_TypeDef *USARTx) 4071 { 4072 return ((READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE)) ? 1UL : 0UL); 4073 } 4074 4075 /** 4076 * @brief Check if the USART Error Interrupt is enabled or disabled. 4077 * @rmtoll CR3 EIE LL_USART_IsEnabledIT_ERROR 4078 * @param USARTx USART Instance 4079 * @retval State of bit (1 or 0). 4080 */ 4081 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(const USART_TypeDef *USARTx) 4082 { 4083 return ((READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE)) ? 1UL : 0UL); 4084 } 4085 4086 /** 4087 * @brief Check if the USART CTS Interrupt is enabled or disabled. 4088 * @note Macro IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 4089 * Hardware Flow control feature is supported by the USARTx instance. 4090 * @rmtoll CR3 CTSIE LL_USART_IsEnabledIT_CTS 4091 * @param USARTx USART Instance 4092 * @retval State of bit (1 or 0). 4093 */ 4094 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(const USART_TypeDef *USARTx) 4095 { 4096 return ((READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE)) ? 1UL : 0UL); 4097 } 4098 4099 /** 4100 * @brief Check if the USART Wake Up from Stop Mode Interrupt is enabled or disabled. 4101 * @note Macro IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 4102 * Wake-up from Stop mode feature is supported by the USARTx instance. 4103 * @rmtoll CR3 WUFIE LL_USART_IsEnabledIT_WKUP 4104 * @param USARTx USART Instance 4105 * @retval State of bit (1 or 0). 4106 */ 4107 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_WKUP(const USART_TypeDef *USARTx) 4108 { 4109 return ((READ_BIT(USARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE)) ? 1UL : 0UL); 4110 } 4111 4112 /** 4113 * @brief Check if USART TX FIFO Threshold Interrupt is enabled or disabled 4114 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 4115 * FIFO mode feature is supported by the USARTx instance. 4116 * @rmtoll CR3 TXFTIE LL_USART_IsEnabledIT_TXFT 4117 * @param USARTx USART Instance 4118 * @retval State of bit (1 or 0). 4119 */ 4120 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXFT(const USART_TypeDef *USARTx) 4121 { 4122 return ((READ_BIT(USARTx->CR3, USART_CR3_TXFTIE) == (USART_CR3_TXFTIE)) ? 1UL : 0UL); 4123 } 4124 4125 /** 4126 * @brief Check if the Smartcard Transmission Complete Before Guard Time Interrupt is enabled or disabled. 4127 * @note Macro IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 4128 * Smartcard feature is supported by the USARTx instance. 4129 * @rmtoll CR3 TCBGTIE LL_USART_IsEnabledIT_TCBGT 4130 * @param USARTx USART Instance 4131 * @retval State of bit (1 or 0). 4132 */ 4133 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TCBGT(const USART_TypeDef *USARTx) 4134 { 4135 return ((READ_BIT(USARTx->CR3, USART_CR3_TCBGTIE) == (USART_CR3_TCBGTIE)) ? 1UL : 0UL); 4136 } 4137 4138 /** 4139 * @brief Check if USART RX FIFO Threshold Interrupt is enabled or disabled 4140 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 4141 * FIFO mode feature is supported by the USARTx instance. 4142 * @rmtoll CR3 RXFTIE LL_USART_IsEnabledIT_RXFT 4143 * @param USARTx USART Instance 4144 * @retval State of bit (1 or 0). 4145 */ 4146 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXFT(const USART_TypeDef *USARTx) 4147 { 4148 return ((READ_BIT(USARTx->CR3, USART_CR3_RXFTIE) == (USART_CR3_RXFTIE)) ? 1UL : 0UL); 4149 } 4150 4151 /** 4152 * @} 4153 */ 4154 4155 /** @defgroup USART_LL_EF_DMA_Management DMA_Management 4156 * @ingroup RTEMSBSPsARMSTM32H7 4157 * @{ 4158 */ 4159 4160 /** 4161 * @brief Enable DMA Mode for reception 4162 * @rmtoll CR3 DMAR LL_USART_EnableDMAReq_RX 4163 * @param USARTx USART Instance 4164 * @retval None 4165 */ 4166 __STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx) 4167 { 4168 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_DMAR); 4169 } 4170 4171 /** 4172 * @brief Disable DMA Mode for reception 4173 * @rmtoll CR3 DMAR LL_USART_DisableDMAReq_RX 4174 * @param USARTx USART Instance 4175 * @retval None 4176 */ 4177 __STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx) 4178 { 4179 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR); 4180 } 4181 4182 /** 4183 * @brief Check if DMA Mode is enabled for reception 4184 * @rmtoll CR3 DMAR LL_USART_IsEnabledDMAReq_RX 4185 * @param USARTx USART Instance 4186 * @retval State of bit (1 or 0). 4187 */ 4188 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(const USART_TypeDef *USARTx) 4189 { 4190 return ((READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR)) ? 1UL : 0UL); 4191 } 4192 4193 /** 4194 * @brief Enable DMA Mode for transmission 4195 * @rmtoll CR3 DMAT LL_USART_EnableDMAReq_TX 4196 * @param USARTx USART Instance 4197 * @retval None 4198 */ 4199 __STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx) 4200 { 4201 ATOMIC_SET_BIT(USARTx->CR3, USART_CR3_DMAT); 4202 } 4203 4204 /** 4205 * @brief Disable DMA Mode for transmission 4206 * @rmtoll CR3 DMAT LL_USART_DisableDMAReq_TX 4207 * @param USARTx USART Instance 4208 * @retval None 4209 */ 4210 __STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx) 4211 { 4212 ATOMIC_CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT); 4213 } 4214 4215 /** 4216 * @brief Check if DMA Mode is enabled for transmission 4217 * @rmtoll CR3 DMAT LL_USART_IsEnabledDMAReq_TX 4218 * @param USARTx USART Instance 4219 * @retval State of bit (1 or 0). 4220 */ 4221 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(const USART_TypeDef *USARTx) 4222 { 4223 return ((READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT)) ? 1UL : 0UL); 4224 } 4225 4226 /** 4227 * @brief Enable DMA Disabling on Reception Error 4228 * @rmtoll CR3 DDRE LL_USART_EnableDMADeactOnRxErr 4229 * @param USARTx USART Instance 4230 * @retval None 4231 */ 4232 __STATIC_INLINE void LL_USART_EnableDMADeactOnRxErr(USART_TypeDef *USARTx) 4233 { 4234 SET_BIT(USARTx->CR3, USART_CR3_DDRE); 4235 } 4236 4237 /** 4238 * @brief Disable DMA Disabling on Reception Error 4239 * @rmtoll CR3 DDRE LL_USART_DisableDMADeactOnRxErr 4240 * @param USARTx USART Instance 4241 * @retval None 4242 */ 4243 __STATIC_INLINE void LL_USART_DisableDMADeactOnRxErr(USART_TypeDef *USARTx) 4244 { 4245 CLEAR_BIT(USARTx->CR3, USART_CR3_DDRE); 4246 } 4247 4248 /** 4249 * @brief Indicate if DMA Disabling on Reception Error is disabled 4250 * @rmtoll CR3 DDRE LL_USART_IsEnabledDMADeactOnRxErr 4251 * @param USARTx USART Instance 4252 * @retval State of bit (1 or 0). 4253 */ 4254 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMADeactOnRxErr(const USART_TypeDef *USARTx) 4255 { 4256 return ((READ_BIT(USARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE)) ? 1UL : 0UL); 4257 } 4258 4259 /** 4260 * @brief Get the data register address used for DMA transfer 4261 * @rmtoll RDR RDR LL_USART_DMA_GetRegAddr\n 4262 * @rmtoll TDR TDR LL_USART_DMA_GetRegAddr 4263 * @param USARTx USART Instance 4264 * @param Direction This parameter can be one of the following values: 4265 * @arg @ref LL_USART_DMA_REG_DATA_TRANSMIT 4266 * @arg @ref LL_USART_DMA_REG_DATA_RECEIVE 4267 * @retval Address of data register 4268 */ 4269 __STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(const USART_TypeDef *USARTx, uint32_t Direction) 4270 { 4271 uint32_t data_reg_addr; 4272 4273 if (Direction == LL_USART_DMA_REG_DATA_TRANSMIT) 4274 { 4275 /* return address of TDR register */ 4276 data_reg_addr = (uint32_t) &(USARTx->TDR); 4277 } 4278 else 4279 { 4280 /* return address of RDR register */ 4281 data_reg_addr = (uint32_t) &(USARTx->RDR); 4282 } 4283 4284 return data_reg_addr; 4285 } 4286 4287 /** 4288 * @} 4289 */ 4290 4291 /** @defgroup USART_LL_EF_Data_Management Data_Management 4292 * @ingroup RTEMSBSPsARMSTM32H7 4293 * @{ 4294 */ 4295 4296 /** 4297 * @brief Read Receiver Data register (Receive Data value, 8 bits) 4298 * @rmtoll RDR RDR LL_USART_ReceiveData8 4299 * @param USARTx USART Instance 4300 * @retval Value between Min_Data=0x00 and Max_Data=0xFF 4301 */ 4302 __STATIC_INLINE uint8_t LL_USART_ReceiveData8(const USART_TypeDef *USARTx) 4303 { 4304 return (uint8_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR) & 0xFFU); 4305 } 4306 4307 /** 4308 * @brief Read Receiver Data register (Receive Data value, 9 bits) 4309 * @rmtoll RDR RDR LL_USART_ReceiveData9 4310 * @param USARTx USART Instance 4311 * @retval Value between Min_Data=0x00 and Max_Data=0x1FF 4312 */ 4313 __STATIC_INLINE uint16_t LL_USART_ReceiveData9(const USART_TypeDef *USARTx) 4314 { 4315 return (uint16_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR)); 4316 } 4317 4318 /** 4319 * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits) 4320 * @rmtoll TDR TDR LL_USART_TransmitData8 4321 * @param USARTx USART Instance 4322 * @param Value between Min_Data=0x00 and Max_Data=0xFF 4323 * @retval None 4324 */ 4325 __STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value) 4326 { 4327 USARTx->TDR = Value; 4328 } 4329 4330 /** 4331 * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits) 4332 * @rmtoll TDR TDR LL_USART_TransmitData9 4333 * @param USARTx USART Instance 4334 * @param Value between Min_Data=0x00 and Max_Data=0x1FF 4335 * @retval None 4336 */ 4337 __STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value) 4338 { 4339 USARTx->TDR = (uint16_t)(Value & 0x1FFUL); 4340 } 4341 4342 /** 4343 * @} 4344 */ 4345 4346 /** @defgroup USART_LL_EF_Execution Execution 4347 * @ingroup RTEMSBSPsARMSTM32H7 4348 * @{ 4349 */ 4350 4351 /** 4352 * @brief Request an Automatic Baud Rate measurement on next received data frame 4353 * @note Macro IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 4354 * Auto Baud Rate detection feature is supported by the USARTx instance. 4355 * @rmtoll RQR ABRRQ LL_USART_RequestAutoBaudRate 4356 * @param USARTx USART Instance 4357 * @retval None 4358 */ 4359 __STATIC_INLINE void LL_USART_RequestAutoBaudRate(USART_TypeDef *USARTx) 4360 { 4361 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_ABRRQ); 4362 } 4363 4364 /** 4365 * @brief Request Break sending 4366 * @rmtoll RQR SBKRQ LL_USART_RequestBreakSending 4367 * @param USARTx USART Instance 4368 * @retval None 4369 */ 4370 __STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx) 4371 { 4372 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_SBKRQ); 4373 } 4374 4375 /** 4376 * @brief Put USART in mute mode and set the RWU flag 4377 * @rmtoll RQR MMRQ LL_USART_RequestEnterMuteMode 4378 * @param USARTx USART Instance 4379 * @retval None 4380 */ 4381 __STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx) 4382 { 4383 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_MMRQ); 4384 } 4385 4386 /** 4387 * @brief Request a Receive Data and FIFO flush 4388 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 4389 * FIFO mode feature is supported by the USARTx instance. 4390 * @note Allows to discard the received data without reading them, and avoid an overrun 4391 * condition. 4392 * @rmtoll RQR RXFRQ LL_USART_RequestRxDataFlush 4393 * @param USARTx USART Instance 4394 * @retval None 4395 */ 4396 __STATIC_INLINE void LL_USART_RequestRxDataFlush(USART_TypeDef *USARTx) 4397 { 4398 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_RXFRQ); 4399 } 4400 4401 /** 4402 * @brief Request a Transmit data and FIFO flush 4403 * @note Macro IS_UART_FIFO_INSTANCE(USARTx) can be used to check whether or not 4404 * FIFO mode feature is supported by the USARTx instance. 4405 * @rmtoll RQR TXFRQ LL_USART_RequestTxDataFlush 4406 * @param USARTx USART Instance 4407 * @retval None 4408 */ 4409 __STATIC_INLINE void LL_USART_RequestTxDataFlush(USART_TypeDef *USARTx) 4410 { 4411 SET_BIT(USARTx->RQR, (uint16_t)USART_RQR_TXFRQ); 4412 } 4413 4414 /** 4415 * @} 4416 */ 4417 4418 #if defined(USE_FULL_LL_DRIVER) || defined(__rtems__) 4419 /** @defgroup USART_LL_EF_Init Initialization and de-initialization functions 4420 * @ingroup RTEMSBSPsARMSTM32H7 4421 * @{ 4422 */ 4423 ErrorStatus LL_USART_DeInit(const USART_TypeDef *USARTx); 4424 ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, const LL_USART_InitTypeDef *USART_InitStruct); 4425 void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct); 4426 ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, const LL_USART_ClockInitTypeDef *USART_ClockInitStruct); 4427 void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct); 4428 /** 4429 * @} 4430 */ 4431 #endif /* USE_FULL_LL_DRIVER */ 4432 4433 /** 4434 * @} 4435 */ 4436 4437 /** 4438 * @} 4439 */ 4440 4441 #endif /* USART1 || USART2 || USART3 || USART6 || UART4 || UART5 || UART7 || UART8 || UART9 || USART10 */ 4442 4443 /** 4444 * @} 4445 */ 4446 4447 #ifdef __cplusplus 4448 } 4449 #endif 4450 4451 #endif /* STM32H7xx_LL_USART_H */ 4452
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |