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