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