Hal Drivers for L4
Dependents: BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo
Fork of STM32L4xx_HAL_Driver by
stm32l4xx_ll_usart.h
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_ll_usart.h 00004 * @author MCD Application Team 00005 * @version V1.1.0 00006 * @date 16-September-2015 00007 * @brief Header file of USART LL module. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 /* Define to prevent recursive inclusion -------------------------------------*/ 00039 #ifndef __STM32L4xx_LL_USART_H 00040 #define __STM32L4xx_LL_USART_H 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 /* Includes ------------------------------------------------------------------*/ 00047 #include "stm32l4xx.h" 00048 00049 /** @addtogroup STM32L4xx_LL_Driver 00050 * @{ 00051 */ 00052 00053 #if defined (USART1) || defined (USART2) || defined (USART3) || defined (UART4) || defined (UART5) 00054 00055 /** @defgroup USART_LL USART 00056 * @{ 00057 */ 00058 00059 /* Private types -------------------------------------------------------------*/ 00060 /* Private variables ---------------------------------------------------------*/ 00061 00062 /* Private constants ---------------------------------------------------------*/ 00063 /** @defgroup USART_LL_Private_Constants USART Private Constants 00064 * @{ 00065 */ 00066 /* Defines used for the bit position in the register and perform offsets*/ 00067 #define USART_POSITION_CR1_DEDT (uint32_t)POSITION_VAL(USART_CR1_DEDT) 00068 #define USART_POSITION_CR1_DEAT (uint32_t)POSITION_VAL(USART_CR1_DEAT) 00069 #define USART_POSITION_CR2_ADD (uint32_t)POSITION_VAL(USART_CR2_ADD) 00070 #define USART_POSITION_CR3_SCARCNT (uint32_t)POSITION_VAL(USART_CR3_SCARCNT) 00071 #define USART_POSITION_RTOR_BLEN (uint32_t)POSITION_VAL(USART_RTOR_BLEN) 00072 #define USART_POSITION_GTPR_GT (uint32_t)POSITION_VAL(USART_GTPR_GT) 00073 /** 00074 * @} 00075 */ 00076 00077 00078 /* Private macros ------------------------------------------------------------*/ 00079 00080 /* Exported types ------------------------------------------------------------*/ 00081 /* Exported constants --------------------------------------------------------*/ 00082 /** @defgroup USART_LL_Exported_Constants USART Exported Constants 00083 * @{ 00084 */ 00085 00086 /** @defgroup USART_LL_EC_CLEAR_FLAG Clear Flags Defines 00087 * @brief Flags defines which can be used with LL_USART_WriteReg function 00088 * @{ 00089 */ 00090 #define LL_USART_ICR_PECF USART_ICR_PECF 00091 #define LL_USART_ICR_FECF USART_ICR_FECF 00092 #define LL_USART_ICR_NCF USART_ICR_NCF 00093 #define LL_USART_ICR_ORECF USART_ICR_ORECF 00094 #define LL_USART_ICR_IDLECF USART_ICR_IDLECF 00095 #define LL_USART_ICR_TCCF USART_ICR_TCCF 00096 #define LL_USART_ICR_LBDCF USART_ICR_LBDCF 00097 #define LL_USART_ICR_CTSCF USART_ICR_CTSCF 00098 #define LL_USART_ICR_RTOCF USART_ICR_RTOCF 00099 #define LL_USART_ICR_EOBCF USART_ICR_EOBCF 00100 #define LL_USART_ICR_CMCF USART_ICR_CMCF 00101 #define LL_USART_ICR_WUCF USART_ICR_WUCF 00102 /** 00103 * @} 00104 */ 00105 00106 /** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines 00107 * @brief Flags defines which can be used with LL_USART_ReadReg function 00108 * @{ 00109 */ 00110 #define LL_USART_ISR_PE USART_ISR_PE 00111 #define LL_USART_ISR_FE USART_ISR_FE 00112 #define LL_USART_ISR_NE USART_ISR_NE 00113 #define LL_USART_ISR_ORE USART_ISR_ORE 00114 #define LL_USART_ISR_IDLE USART_ISR_IDLE 00115 #define LL_USART_ISR_RXNE USART_ISR_RXNE 00116 #define LL_USART_ISR_TC USART_ISR_TC 00117 #define LL_USART_ISR_TXE USART_ISR_TXE 00118 #define LL_USART_ISR_LBDF USART_ISR_LBDF 00119 #define LL_USART_ISR_CTSIF USART_ISR_CTSIF 00120 #define LL_USART_ISR_CTS USART_ISR_CTS 00121 #define LL_USART_ISR_RTOF USART_ISR_RTOF 00122 #define LL_USART_ISR_EOBF USART_ISR_EOBF 00123 #define LL_USART_ISR_ABRE USART_ISR_ABRE 00124 #define LL_USART_ISR_ABRF USART_ISR_ABRF 00125 #define LL_USART_ISR_BUSY USART_ISR_BUSY 00126 #define LL_USART_ISR_CMF USART_ISR_CMF 00127 #define LL_USART_ISR_SBKF USART_ISR_SBKF 00128 #define LL_USART_ISR_RWU USART_ISR_RWU 00129 #define LL_USART_ISR_WUF USART_ISR_WUF 00130 #define LL_USART_ISR_TEACK USART_ISR_TEACK 00131 #define LL_USART_ISR_REACK USART_ISR_REACK 00132 /** 00133 * @} 00134 */ 00135 00136 /** @defgroup USART_LL_EC_IT IT Defines 00137 * @brief IT defines which can be used with LL_USART_ReadReg and LL_USART_WriteReg functions 00138 * @{ 00139 */ 00140 #define LL_USART_CR1_IDLEIE USART_CR1_IDLEIE 00141 #define LL_USART_CR1_RXNEIE USART_CR1_RXNEIE 00142 #define LL_USART_CR1_TCIE USART_CR1_TCIE 00143 #define LL_USART_CR1_TXEIE USART_CR1_TXEIE 00144 #define LL_USART_CR1_PEIE USART_CR1_PEIE 00145 #define LL_USART_CR1_CMIE USART_CR1_CMIE 00146 #define LL_USART_CR1_RTOIE USART_CR1_RTOIE 00147 #define LL_USART_CR1_EOBIE USART_CR1_EOBIE 00148 #define LL_USART_CR2_LBDIE USART_CR2_LBDIE 00149 #define LL_USART_CR3_EIE USART_CR3_EIE 00150 #define LL_USART_CR3_CTSIE USART_CR3_CTSIE 00151 #define LL_USART_CR3_WUFIE USART_CR3_WUFIE 00152 /** 00153 * @} 00154 */ 00155 00156 /** @defgroup USART_LL_EC_DIRECTION DIRECTION 00157 * @{ 00158 */ 00159 #define LL_USART_DIRECTION_NONE (uint32_t)0x00000000 /*!< Transmitter and Receiver are disabled */ 00160 #define LL_USART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */ 00161 #define LL_USART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */ 00162 #define LL_USART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */ 00163 /** 00164 * @} 00165 */ 00166 00167 /** @defgroup USART_LL_EC_PARITY PARITY 00168 * @{ 00169 */ 00170 #define LL_USART_PARITY_NONE (uint32_t)0x00000000 /*!< Parity control disabled */ 00171 #define LL_USART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */ 00172 #define LL_USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */ 00173 /** 00174 * @} 00175 */ 00176 00177 /** @defgroup USART_LL_EC_WAKEUP WAKEUP 00178 * @{ 00179 */ 00180 #define LL_USART_WAKEUP_IDLELINE (uint32_t)0x00000000 /*!< USART wakeup from Mute mode on Idle Line */ 00181 #define LL_USART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< USART wakeup from Mute mode on Address Mark */ 00182 /** 00183 * @} 00184 */ 00185 00186 /** @defgroup USART_LL_EC_DATAWIDTH DATAWIDTH 00187 * @{ 00188 */ 00189 #define LL_USART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */ 00190 #define LL_USART_DATAWIDTH_8B (uint32_t)0x00000000 /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */ 00191 #define LL_USART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */ 00192 /** 00193 * @} 00194 */ 00195 00196 /** @defgroup USART_LL_EC_OVERSAMPLING OVERSAMPLING 00197 * @{ 00198 */ 00199 #define LL_USART_OVERSAMPLING_16 (uint32_t)0x00000000 /*!< Oversampling by 16 */ 00200 #define LL_USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */ 00201 /** 00202 * @} 00203 */ 00204 00205 /** @defgroup USART_LL_EC_LASTCLKPULSE LASTCLKPULSE 00206 * @{ 00207 */ 00208 #define LL_USART_LASTCLKPULSE_NO_OUTPUT (uint32_t)0x00000000 /*!< The clock pulse of the last data bit is not output to the SCLK pin */ 00209 #define LL_USART_LASTCLKPULSE_OUTPUT USART_CR2_LBCL /*!< The clock pulse of the last data bit is output to the SCLK pin */ 00210 /** 00211 * @} 00212 */ 00213 00214 /** @defgroup USART_LL_EC_PHASE PHASE 00215 * @{ 00216 */ 00217 #define LL_USART_PHASE_1EDGE (uint32_t)0x00000000 /*!< The first clock transition is the first data capture edge */ 00218 #define LL_USART_PHASE_2EDGE USART_CR2_CPHA /*!< The second clock transition is the first data capture edge */ 00219 /** 00220 * @} 00221 */ 00222 00223 /** @defgroup USART_LL_EC_POLARITY POLARITY 00224 * @{ 00225 */ 00226 #define LL_USART_POLARITY_LOW (uint32_t)0x00000000 /*!< Steady low value on SCLK pin outside transmission window*/ 00227 #define LL_USART_POLARITY_HIGH USART_CR2_CPOL /*!< Steady high value on SCLK pin outside transmission window */ 00228 /** 00229 * @} 00230 */ 00231 00232 /** @defgroup USART_LL_EC_STOPBITS STOPBITS 00233 * @{ 00234 */ 00235 #define LL_USART_STOPBITS_1 (uint32_t)0x00000000 /*!< 1 stop bit */ 00236 #define LL_USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< 1.5 stop bits */ 00237 #define LL_USART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */ 00238 /** 00239 * @} 00240 */ 00241 00242 /** @defgroup USART_LL_EC_TXRX TXRX 00243 * @{ 00244 */ 00245 #define LL_USART_TXRX_STANDARD (uint32_t)0x00000000 /*!< TX/RX pins are used as defined in standard pinout */ 00246 #define LL_USART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */ 00247 /** 00248 * @} 00249 */ 00250 00251 /** @defgroup USART_LL_EC_RXPIN_LEVEL RXPIN LEVEL 00252 * @{ 00253 */ 00254 #define LL_USART_RXPIN_LEVEL_STANDARD (uint32_t)0x00000000 /*!< RX pin signal works using the standard logic levels */ 00255 #define LL_USART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */ 00256 /** 00257 * @} 00258 */ 00259 00260 /** @defgroup USART_LL_EC_TXPIN_LEVEL TXPIN LEVEL 00261 * @{ 00262 */ 00263 #define LL_USART_TXPIN_LEVEL_STANDARD (uint32_t)0x00000000 /*!< TX pin signal works using the standard logic levels */ 00264 #define LL_USART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */ 00265 /** 00266 * @} 00267 */ 00268 00269 /** @defgroup USART_LL_EC_BINARY_LOGIC BINARY LOGIC 00270 * @{ 00271 */ 00272 #define LL_USART_BINARY_LOGIC_POSITIVE (uint32_t)0x00000000 /*!< Logical data from the data register are send/received in positive/direct logic. (1=H, 0=L) */ 00273 #define LL_USART_BINARY_LOGIC_NEGATIVE USART_CR2_DATAINV /*!< Logical data from the data register are send/received in negative/inverse logic. (1=L, 0=H). The parity bit is also inverted. */ 00274 /** 00275 * @} 00276 */ 00277 00278 /** @defgroup USART_LL_EC_BITORDER BITORDER 00279 * @{ 00280 */ 00281 #define LL_USART_BITORDER_LSBFIRST (uint32_t)0x00000000 /*!< data is transmitted/received with data bit 0 first, following the start bit */ 00282 #define LL_USART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first, following the start bit */ 00283 /** 00284 * @} 00285 */ 00286 00287 /** @defgroup USART_LL_EC_AUTOBAUD_DETECT_ON AUTOBAUD DETECT ON 00288 * @{ 00289 */ 00290 #define LL_USART_AUTOBAUD_DETECT_ON_STARTBIT (uint32_t)0x00000000 /*!< Measurement of the start bit is used to detect the baud rate */ 00291 #define LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE USART_CR2_ABRMODE_0 /*!< Falling edge to falling edge measurement. Received frame must start with a single bit = 1 -> Frame = Start10xxxxxx */ 00292 #define LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME USART_CR2_ABRMODE_1 /*!< 0x7F frame detection */ 00293 #define LL_USART_AUTOBAUD_DETECT_ON_55_FRAME (USART_CR2_ABRMODE_1 | USART_CR2_ABRMODE_0) /*!< 0x55 frame detection */ 00294 /** 00295 * @} 00296 */ 00297 00298 /** @defgroup USART_LL_EC_ADDRESS_DETECT ADDRESS DETECT 00299 * @{ 00300 */ 00301 #define LL_USART_ADDRESS_DETECT_4B (uint32_t)0x00000000 /*!< 4-bit address detection method selected */ 00302 #define LL_USART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */ 00303 /** 00304 * @} 00305 */ 00306 00307 /** @defgroup USART_LL_EC_HWCONTROL HWCONTROL 00308 * @{ 00309 */ 00310 #define LL_USART_HWCONTROL_NONE (uint32_t)0x00000000 /*!< CTS and RTS hardware flow control disabled */ 00311 #define LL_USART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */ 00312 #define LL_USART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */ 00313 #define LL_USART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */ 00314 /** 00315 * @} 00316 */ 00317 00318 /** @defgroup USART_LL_EC_WAKEUP_ON WAKEUP ON 00319 * @{ 00320 */ 00321 #define LL_USART_WAKEUP_ON_ADDRESS (uint32_t)0x00000000 /*!< Wakeup active on address match */ 00322 #define LL_USART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wakeup active on Start bit detection */ 00323 #define LL_USART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wakeup active on RXNE */ 00324 /** 00325 * @} 00326 */ 00327 00328 /** @defgroup USART_LL_EC_IRDA_POWER IRDA POWER 00329 * @{ 00330 */ 00331 #define LL_USART_IRDA_POWER_NORMAL (uint32_t)0x00000000 /*!< IrDA normal power mode */ 00332 #define LL_USART_IRDA_POWER_LOW USART_CR3_IRLP /*!< IrDA low power mode */ 00333 /** 00334 * @} 00335 */ 00336 00337 /** @defgroup USART_LL_EC_LINBREAK_DETECT LINBREAK DETECT 00338 * @{ 00339 */ 00340 #define LL_USART_LINBREAK_DETECT_10B (uint32_t)0x00000000 /*!< 10-bit break detection method selected */ 00341 #define LL_USART_LINBREAK_DETECT_11B USART_CR2_LBDL /*!< 11-bit break detection method selected */ 00342 /** 00343 * @} 00344 */ 00345 00346 /** @defgroup USART_LL_EC_DE_POLARITY DE POLARITY 00347 * @{ 00348 */ 00349 #define LL_USART_DE_POLARITY_HIGH (uint32_t)0x00000000 /*!< DE signal is active high */ 00350 #define LL_USART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */ 00351 /** 00352 * @} 00353 */ 00354 00355 /** @defgroup USART_LL_EC_DMA_REG_DATA DMA register data 00356 * @{ 00357 */ 00358 #define LL_USART_DMA_REG_DATA_TRANSMIT (uint32_t)0 /*!< Get address of data register used for transmission */ 00359 #define LL_USART_DMA_REG_DATA_RECEIVE (uint32_t)1 /*!< Get address of data register used for reception */ 00360 /** 00361 * @} 00362 */ 00363 00364 /** 00365 * @} 00366 */ 00367 00368 /* Exported macro ------------------------------------------------------------*/ 00369 /** @defgroup USART_LL_Exported_Macros USART Exported Macros 00370 * @{ 00371 */ 00372 00373 /** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros 00374 * @{ 00375 */ 00376 00377 /** 00378 * @brief Write a value in USART register 00379 * @param __INSTANCE__ USART Instance 00380 * @param __REG__ Register to be written 00381 * @param __VALUE__ Value to be written in the register 00382 * @retval None 00383 */ 00384 #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 00385 00386 /** 00387 * @brief Read a value in USART register 00388 * @param __INSTANCE__ USART Instance 00389 * @param __REG__ Register to be read 00390 * @retval Register value 00391 */ 00392 #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 00393 /** 00394 * @} 00395 */ 00396 00397 /** @defgroup USART_LL_EM_Helper Helper Macros 00398 * @{ 00399 */ 00400 /** 00401 * @brief Compute USARTDIV value according to Peripheral Clock and 00402 * expected Baudrate in 8 bits sampling mode (32 bits value of USARTDIV is returned) 00403 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance 00404 * @param __BAUDRATE__ Baudrate value to achieve 00405 * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case 00406 */ 00407 #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__)*2)/(__BAUDRATE__)) 00408 00409 /** 00410 * @brief Compute USARTDIV value according to Peripheral Clock and 00411 * expected Baudrate in 16 bits sampling mode (32 bits value of USARTDIV is returned) 00412 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance 00413 * @param __BAUDRATE__ Baudrate value to achieve 00414 * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case 00415 */ 00416 #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) ((__PERIPHCLK__)/(__BAUDRATE__)) 00417 00418 /** 00419 * @} 00420 */ 00421 00422 /** 00423 * @} 00424 */ 00425 00426 /* Exported functions --------------------------------------------------------*/ 00427 /** @defgroup USART_LL_Exported_Functions USART Exported Functions 00428 * @{ 00429 */ 00430 00431 /** @defgroup USART_LL_EF_Configuration Configuration functions 00432 * @{ 00433 */ 00434 00435 /** 00436 * @brief USART Enable 00437 * @rmtoll CR1 UE LL_USART_Enable 00438 * @param USARTx USART Instance 00439 * @retval None 00440 */ 00441 __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx) 00442 { 00443 SET_BIT(USARTx->CR1, USART_CR1_UE); 00444 } 00445 00446 /** 00447 * @brief USART Disable (all USART prescalers and outputs are disabled) 00448 * @note When USART is disabled, USART prescalers and outputs are stopped immediately, 00449 * and current operations are discarded. The configuration of the USART is kept, but all the status 00450 * flags, in the USARTx_ISR are set to their default values. 00451 * @rmtoll CR1 UE LL_USART_Disable 00452 * @param USARTx USART Instance 00453 * @retval None 00454 */ 00455 __STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx) 00456 { 00457 CLEAR_BIT(USARTx->CR1, USART_CR1_UE); 00458 } 00459 00460 /** 00461 * @brief Indicate if USART is enabled 00462 * @rmtoll CR1 UE LL_USART_IsEnabled 00463 * @param USARTx USART Instance 00464 * @retval State of bit (1 or 0). 00465 */ 00466 __STATIC_INLINE uint32_t LL_USART_IsEnabled(USART_TypeDef *USARTx) 00467 { 00468 return (READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE)); 00469 } 00470 00471 /** 00472 * @brief USART enabled in STOP Mode. 00473 * @note When this function is enabled, USART is able to wake up the MCU from Stop mode, provided that 00474 * USART clock selection is HSI or LSE in RCC. 00475 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 00476 * Wake-up from Stop mode feature is supported by the USARTx instance. 00477 * @rmtoll CR1 UESM LL_USART_EnableInStopMode 00478 * @param USARTx USART Instance 00479 * @retval None 00480 */ 00481 __STATIC_INLINE void LL_USART_EnableInStopMode(USART_TypeDef *USARTx) 00482 { 00483 SET_BIT(USARTx->CR1, USART_CR1_UESM); 00484 } 00485 00486 /** 00487 * @brief USART disabled in STOP Mode. 00488 * @note When this function is disabled, USART is not able to wake up the MCU from Stop mode 00489 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 00490 * Wake-up from Stop mode feature is supported by the USARTx instance. 00491 * @rmtoll CR1 UESM LL_USART_DisableInStopMode 00492 * @param USARTx USART Instance 00493 * @retval None 00494 */ 00495 __STATIC_INLINE void LL_USART_DisableInStopMode(USART_TypeDef *USARTx) 00496 { 00497 CLEAR_BIT(USARTx->CR1, USART_CR1_UESM); 00498 } 00499 00500 /** 00501 * @brief Indicate if USART is enabled in STOP Mode (able to wake up MCU from Stop mode or not) 00502 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 00503 * Wake-up from Stop mode feature is supported by the USARTx instance. 00504 * @rmtoll CR1 UESM LL_USART_IsEnabledInStopMode 00505 * @param USARTx USART Instance 00506 * @retval State of bit (1 or 0). 00507 */ 00508 __STATIC_INLINE uint32_t LL_USART_IsEnabledInStopMode(USART_TypeDef *USARTx) 00509 { 00510 return (READ_BIT(USARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM)); 00511 } 00512 00513 /** 00514 * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit) 00515 * @rmtoll CR1 RE LL_USART_EnableDirectionRx 00516 * @param USARTx USART Instance 00517 * @retval None 00518 */ 00519 __STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx) 00520 { 00521 SET_BIT(USARTx->CR1, USART_CR1_RE); 00522 } 00523 00524 /** 00525 * @brief Receiver Disable 00526 * @rmtoll CR1 RE LL_USART_DisableDirectionRx 00527 * @param USARTx USART Instance 00528 * @retval None 00529 */ 00530 __STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx) 00531 { 00532 CLEAR_BIT(USARTx->CR1, USART_CR1_RE); 00533 } 00534 00535 /** 00536 * @brief Transmitter Enable 00537 * @rmtoll CR1 TE LL_USART_EnableDirectionTx 00538 * @param USARTx USART Instance 00539 * @retval None 00540 */ 00541 __STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx) 00542 { 00543 SET_BIT(USARTx->CR1, USART_CR1_TE); 00544 } 00545 00546 /** 00547 * @brief Transmitter Disable 00548 * @rmtoll CR1 TE LL_USART_DisableDirectionTx 00549 * @param USARTx USART Instance 00550 * @retval None 00551 */ 00552 __STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx) 00553 { 00554 CLEAR_BIT(USARTx->CR1, USART_CR1_TE); 00555 } 00556 00557 /** 00558 * @brief Configure simultaneously enabled/disabled states 00559 * of Transmitter and Receiver 00560 * @rmtoll CR1 RE LL_USART_SetTransferDirection\n 00561 * CR1 TE LL_USART_SetTransferDirection 00562 * @param USARTx USART Instance 00563 * @param Direction This parameter can be one of the following values: 00564 * @arg @ref LL_USART_DIRECTION_NONE 00565 * @arg @ref LL_USART_DIRECTION_RX 00566 * @arg @ref LL_USART_DIRECTION_TX 00567 * @arg @ref LL_USART_DIRECTION_TX_RX 00568 * @retval None 00569 */ 00570 __STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t Direction) 00571 { 00572 MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, Direction); 00573 } 00574 00575 /** 00576 * @brief Return enabled/disabled states of Transmitter and Receiver 00577 * @rmtoll CR1 RE LL_USART_GetTransferDirection\n 00578 * CR1 TE LL_USART_GetTransferDirection 00579 * @param USARTx USART Instance 00580 * @retval Returned value can be one of the following values: 00581 * @arg @ref LL_USART_DIRECTION_NONE 00582 * @arg @ref LL_USART_DIRECTION_RX 00583 * @arg @ref LL_USART_DIRECTION_TX 00584 * @arg @ref LL_USART_DIRECTION_TX_RX 00585 */ 00586 __STATIC_INLINE uint32_t LL_USART_GetTransferDirection(USART_TypeDef *USARTx) 00587 { 00588 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE)); 00589 } 00590 00591 /** 00592 * @brief Configure Parity (enabled/disabled and parity mode if enabled). 00593 * @note This function selects if hardware parity control (generation and detection) is enabled or disabled. 00594 * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position 00595 * (9th or 8th bit depending on data width) and parity is checked on the received data. 00596 * @rmtoll CR1 PS LL_USART_SetParity\n 00597 * CR1 PCE LL_USART_SetParity 00598 * @param USARTx USART Instance 00599 * @param ParityMode This parameter can be one of the following values: 00600 * @arg @ref LL_USART_PARITY_NONE 00601 * @arg @ref LL_USART_PARITY_EVEN 00602 * @arg @ref LL_USART_PARITY_ODD 00603 * @retval None 00604 */ 00605 __STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t ParityMode) 00606 { 00607 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, ParityMode); 00608 } 00609 00610 /** 00611 * @brief Return Parity configuration (enabled/disabled and parity mode if enabled) 00612 * @rmtoll CR1 PS LL_USART_GetParity\n 00613 * CR1 PCE LL_USART_GetParity 00614 * @param USARTx USART Instance 00615 * @retval Returned value can be one of the following values: 00616 * @arg @ref LL_USART_PARITY_NONE 00617 * @arg @ref LL_USART_PARITY_EVEN 00618 * @arg @ref LL_USART_PARITY_ODD 00619 */ 00620 __STATIC_INLINE uint32_t LL_USART_GetParity(USART_TypeDef *USARTx) 00621 { 00622 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE)); 00623 } 00624 00625 /** 00626 * @brief Set Receiver Wakeup method from Mute mode. 00627 * @rmtoll CR1 WAKE LL_USART_SetWakeUpMethod 00628 * @param USARTx USART Instance 00629 * @param Method This parameter can be one of the following values: 00630 * @arg @ref LL_USART_WAKEUP_IDLELINE 00631 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK 00632 * @retval None 00633 */ 00634 __STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method) 00635 { 00636 MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method); 00637 } 00638 00639 /** 00640 * @brief Return Receiver Wakeup method from Mute mode 00641 * @rmtoll CR1 WAKE LL_USART_GetWakeUpMethod 00642 * @param USARTx USART Instance 00643 * @retval Returned value can be one of the following values: 00644 * @arg @ref LL_USART_WAKEUP_IDLELINE 00645 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK 00646 */ 00647 __STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(USART_TypeDef *USARTx) 00648 { 00649 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE)); 00650 } 00651 00652 /** 00653 * @brief Set Word length (i.e. nb of data bits, excluding start and stop bits) 00654 * @rmtoll CR1 M LL_USART_SetDataWidth 00655 * @param USARTx USART Instance 00656 * @param DataWidth This parameter can be one of the following values: 00657 * @arg @ref LL_USART_DATAWIDTH_7B 00658 * @arg @ref LL_USART_DATAWIDTH_8B 00659 * @arg @ref LL_USART_DATAWIDTH_9B 00660 * @retval None 00661 */ 00662 __STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth) 00663 { 00664 MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth); 00665 } 00666 00667 /** 00668 * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits) 00669 * @rmtoll CR1 M LL_USART_GetDataWidth 00670 * @param USARTx USART Instance 00671 * @retval Returned value can be one of the following values: 00672 * @arg @ref LL_USART_DATAWIDTH_7B 00673 * @arg @ref LL_USART_DATAWIDTH_8B 00674 * @arg @ref LL_USART_DATAWIDTH_9B 00675 */ 00676 __STATIC_INLINE uint32_t LL_USART_GetDataWidth(USART_TypeDef *USARTx) 00677 { 00678 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M)); 00679 } 00680 00681 /** 00682 * @brief Allow switch between Mute Mode and Active mode 00683 * @rmtoll CR1 MME LL_USART_EnableMuteMode 00684 * @param USARTx USART Instance 00685 * @retval None 00686 */ 00687 __STATIC_INLINE void LL_USART_EnableMuteMode(USART_TypeDef *USARTx) 00688 { 00689 SET_BIT(USARTx->CR1, USART_CR1_MME); 00690 } 00691 00692 /** 00693 * @brief Prevent Mute Mode use. Set Receiver in active mode permanently. 00694 * @rmtoll CR1 MME LL_USART_DisableMuteMode 00695 * @param USARTx USART Instance 00696 * @retval None 00697 */ 00698 __STATIC_INLINE void LL_USART_DisableMuteMode(USART_TypeDef *USARTx) 00699 { 00700 CLEAR_BIT(USARTx->CR1, USART_CR1_MME); 00701 } 00702 00703 /** 00704 * @brief Indicate if switch between Mute Mode and Active mode is allowed 00705 * @rmtoll CR1 MME LL_USART_IsEnabledMuteMode 00706 * @param USARTx USART Instance 00707 * @retval State of bit (1 or 0). 00708 */ 00709 __STATIC_INLINE uint32_t LL_USART_IsEnabledMuteMode(USART_TypeDef *USARTx) 00710 { 00711 return (READ_BIT(USARTx->CR1, USART_CR1_MME) == (USART_CR1_MME)); 00712 } 00713 00714 /** 00715 * @brief Set Oversampling to 8-bit or 16-bit mode 00716 * @rmtoll CR1 OVER8 LL_USART_SetOverSampling 00717 * @param USARTx USART Instance 00718 * @param OverSampling This parameter can be one of the following values: 00719 * @arg @ref LL_USART_OVERSAMPLING_16 00720 * @arg @ref LL_USART_OVERSAMPLING_8 00721 * @retval None 00722 */ 00723 __STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling) 00724 { 00725 MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling); 00726 } 00727 00728 /** 00729 * @brief Return Oversampling mode 00730 * @rmtoll CR1 OVER8 LL_USART_GetOverSampling 00731 * @param USARTx USART Instance 00732 * @retval Returned value can be one of the following values: 00733 * @arg @ref LL_USART_OVERSAMPLING_16 00734 * @arg @ref LL_USART_OVERSAMPLING_8 00735 */ 00736 __STATIC_INLINE uint32_t LL_USART_GetOverSampling(USART_TypeDef *USARTx) 00737 { 00738 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8)); 00739 } 00740 00741 /** 00742 * @brief Configure if Clock pulse of the last data bit is output to the SCLK pin or not 00743 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not 00744 * Synchronous mode is supported by the USARTx instance. 00745 * @rmtoll CR2 LBCL LL_USART_SetLastClkPulseOutput 00746 * @param USARTx USART Instance 00747 * @param LBCPOutput This parameter can be one of the following values: 00748 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT 00749 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT 00750 * @retval None 00751 */ 00752 __STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LBCPOutput) 00753 { 00754 MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LBCPOutput); 00755 } 00756 00757 /** 00758 * @brief Retrieve Clock pulse of the last data bit output configuration 00759 * (Last bit Clock pulse output to the SCLK pin or not) 00760 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not 00761 * Synchronous mode is supported by the USARTx instance. 00762 * @rmtoll CR2 LBCL LL_USART_GetLastClkPulseOutput 00763 * @param USARTx USART Instance 00764 * @retval Returned value can be one of the following values: 00765 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT 00766 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT 00767 */ 00768 __STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(USART_TypeDef *USARTx) 00769 { 00770 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL)); 00771 } 00772 00773 /** 00774 * @brief Select the phase of the clock output on the SCLK pin in synchronous mode 00775 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not 00776 * Synchronous mode is supported by the USARTx instance. 00777 * @rmtoll CR2 CPHA LL_USART_SetClockPhase 00778 * @param USARTx USART Instance 00779 * @param Phase This parameter can be one of the following values: 00780 * @arg @ref LL_USART_PHASE_1EDGE 00781 * @arg @ref LL_USART_PHASE_2EDGE 00782 * @retval None 00783 */ 00784 __STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t Phase) 00785 { 00786 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, Phase); 00787 } 00788 00789 /** 00790 * @brief Return phase of the clock output on the SCLK pin in synchronous mode 00791 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not 00792 * Synchronous mode is supported by the USARTx instance. 00793 * @rmtoll CR2 CPHA LL_USART_GetClockPhase 00794 * @param USARTx USART Instance 00795 * @retval Returned value can be one of the following values: 00796 * @arg @ref LL_USART_PHASE_1EDGE 00797 * @arg @ref LL_USART_PHASE_2EDGE 00798 */ 00799 __STATIC_INLINE uint32_t LL_USART_GetClockPhase(USART_TypeDef *USARTx) 00800 { 00801 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA)); 00802 } 00803 00804 /** 00805 * @brief Select the polarity of the clock output on the SCLK pin in synchronous mode 00806 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not 00807 * Synchronous mode is supported by the USARTx instance. 00808 * @rmtoll CR2 CPOL LL_USART_SetClockPolarity 00809 * @param USARTx USART Instance 00810 * @param Polarity This parameter can be one of the following values: 00811 * @arg @ref LL_USART_POLARITY_LOW 00812 * @arg @ref LL_USART_POLARITY_HIGH 00813 * @retval None 00814 */ 00815 __STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t Polarity) 00816 { 00817 MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, Polarity); 00818 } 00819 00820 /** 00821 * @brief Return polarity of the clock output on the SCLK pin in synchronous mode 00822 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not 00823 * Synchronous mode is supported by the USARTx instance. 00824 * @rmtoll CR2 CPOL LL_USART_GetClockPolarity 00825 * @param USARTx USART Instance 00826 * @retval Returned value can be one of the following values: 00827 * @arg @ref LL_USART_POLARITY_LOW 00828 * @arg @ref LL_USART_POLARITY_HIGH 00829 */ 00830 __STATIC_INLINE uint32_t LL_USART_GetClockPolarity(USART_TypeDef *USARTx) 00831 { 00832 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL)); 00833 } 00834 00835 /** 00836 * @brief Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse) 00837 * @note Call of this function is equivalent to following function call sequence : 00838 * - Clock Phase configuration using @ref LL_USART_SetClockPhase() function 00839 * - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function 00840 * - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function 00841 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not 00842 * Synchronous mode is supported by the USARTx instance. 00843 * @rmtoll CR2 CPHA LL_USART_ConfigClock\n 00844 * CR2 CPOL LL_USART_ConfigClock\n 00845 * CR2 LBCL LL_USART_ConfigClock 00846 * @param USARTx USART Instance 00847 * @param Phase This parameter can be one of the following values: 00848 * @arg @ref LL_USART_PHASE_1EDGE 00849 * @arg @ref LL_USART_PHASE_2EDGE 00850 * @param Polarity This parameter can be one of the following values: 00851 * @arg @ref LL_USART_POLARITY_LOW 00852 * @arg @ref LL_USART_POLARITY_HIGH 00853 * @param LBCPOutput This parameter can be one of the following values: 00854 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT 00855 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT 00856 * @retval None 00857 */ 00858 __STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput) 00859 { 00860 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput); 00861 } 00862 00863 /** 00864 * @brief Enable Clock output on SCLK pin 00865 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not 00866 * Synchronous mode is supported by the USARTx instance. 00867 * @rmtoll CR2 CLKEN LL_USART_EnableSCLKOutput 00868 * @param USARTx USART Instance 00869 * @retval None 00870 */ 00871 __STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx) 00872 { 00873 SET_BIT(USARTx->CR2, USART_CR2_CLKEN); 00874 } 00875 00876 /** 00877 * @brief Disable Clock output on SCLK pin 00878 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not 00879 * Synchronous mode is supported by the USARTx instance. 00880 * @rmtoll CR2 CLKEN LL_USART_DisableSCLKOutput 00881 * @param USARTx USART Instance 00882 * @retval None 00883 */ 00884 __STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx) 00885 { 00886 CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN); 00887 } 00888 00889 /** 00890 * @brief Indicate if Clock output on SCLK pin is enabled 00891 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not 00892 * Synchronous mode is supported by the USARTx instance. 00893 * @rmtoll CR2 CLKEN LL_USART_IsEnabledSCLKOutput 00894 * @param USARTx USART Instance 00895 * @retval State of bit (1 or 0). 00896 */ 00897 __STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(USART_TypeDef *USARTx) 00898 { 00899 return (READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN)); 00900 } 00901 00902 /** 00903 * @brief Set the length of the stop bits 00904 * @rmtoll CR2 STOP LL_USART_SetStopBitsLength 00905 * @param USARTx USART Instance 00906 * @param StopBits This parameter can be one of the following values: 00907 * @arg @ref LL_USART_STOPBITS_1 00908 * @arg @ref LL_USART_STOPBITS_1_5 00909 * @arg @ref LL_USART_STOPBITS_2 00910 * @retval None 00911 */ 00912 __STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits) 00913 { 00914 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits); 00915 } 00916 00917 /** 00918 * @brief Retrieve the length of the stop bits 00919 * @rmtoll CR2 STOP LL_USART_GetStopBitsLength 00920 * @param USARTx USART Instance 00921 * @retval Returned value can be one of the following values: 00922 * @arg @ref LL_USART_STOPBITS_1 00923 * @arg @ref LL_USART_STOPBITS_1_5 00924 * @arg @ref LL_USART_STOPBITS_2 00925 */ 00926 __STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(USART_TypeDef *USARTx) 00927 { 00928 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP)); 00929 } 00930 00931 /** 00932 * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits) 00933 * @note Call of this function is equivalent to following function call sequence : 00934 * - Data Width configuration using @ref LL_USART_SetDataWidth() function 00935 * - Parity Control and mode configuration using @ref LL_USART_SetParity() function 00936 * - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function 00937 * @rmtoll CR1 PS LL_USART_ConfigCharacter\n 00938 * CR1 PCE LL_USART_ConfigCharacter\n 00939 * CR1 M LL_USART_ConfigCharacter\n 00940 * CR2 STOP LL_USART_ConfigCharacter 00941 * @param USARTx USART Instance 00942 * @param DataWidth This parameter can be one of the following values: 00943 * @arg @ref LL_USART_DATAWIDTH_7B 00944 * @arg @ref LL_USART_DATAWIDTH_8B 00945 * @arg @ref LL_USART_DATAWIDTH_9B 00946 * @param ParityMode This parameter can be one of the following values: 00947 * @arg @ref LL_USART_PARITY_NONE 00948 * @arg @ref LL_USART_PARITY_EVEN 00949 * @arg @ref LL_USART_PARITY_ODD 00950 * @param StopBits This parameter can be one of the following values: 00951 * @arg @ref LL_USART_STOPBITS_1 00952 * @arg @ref LL_USART_STOPBITS_2 00953 * @arg @ref LL_USART_STOPBITS_1_5 00954 * @retval None 00955 */ 00956 __STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t ParityMode, 00957 uint32_t StopBits) 00958 { 00959 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, ParityMode | DataWidth); 00960 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits); 00961 } 00962 00963 /** 00964 * @brief Configure TX/RX pins swapping setting. 00965 * @rmtoll CR2 SWAP LL_USART_SetTXRXSwap 00966 * @param USARTx USART Instance 00967 * @param SwapConfig This parameter can be one of the following values: 00968 * @arg @ref LL_USART_TXRX_STANDARD 00969 * @arg @ref LL_USART_TXRX_SWAPPED 00970 * @retval None 00971 */ 00972 __STATIC_INLINE void LL_USART_SetTXRXSwap(USART_TypeDef *USARTx, uint32_t SwapConfig) 00973 { 00974 MODIFY_REG(USARTx->CR2, USART_CR2_SWAP, SwapConfig); 00975 } 00976 00977 /** 00978 * @brief Retrieve TX/RX pins swapping configuration. 00979 * @rmtoll CR2 SWAP LL_USART_GetTXRXSwap 00980 * @param USARTx USART Instance 00981 * @retval Returned value can be one of the following values: 00982 * @arg @ref LL_USART_TXRX_STANDARD 00983 * @arg @ref LL_USART_TXRX_SWAPPED 00984 */ 00985 __STATIC_INLINE uint32_t LL_USART_GetTXRXSwap(USART_TypeDef *USARTx) 00986 { 00987 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_SWAP)); 00988 } 00989 00990 /** 00991 * @brief Configure RX pin active level logic 00992 * @rmtoll CR2 RXINV LL_USART_SetRXPinLevel 00993 * @param USARTx USART Instance 00994 * @param PinInvMethod This parameter can be one of the following values: 00995 * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD 00996 * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED 00997 * @retval None 00998 */ 00999 __STATIC_INLINE void LL_USART_SetRXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod) 01000 { 01001 MODIFY_REG(USARTx->CR2, USART_CR2_RXINV, PinInvMethod); 01002 } 01003 01004 /** 01005 * @brief Retrieve RX pin active level logic configuration 01006 * @rmtoll CR2 RXINV LL_USART_GetRXPinLevel 01007 * @param USARTx USART Instance 01008 * @retval Returned value can be one of the following values: 01009 * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD 01010 * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED 01011 */ 01012 __STATIC_INLINE uint32_t LL_USART_GetRXPinLevel(USART_TypeDef *USARTx) 01013 { 01014 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_RXINV)); 01015 } 01016 01017 /** 01018 * @brief Configure TX pin active level logic 01019 * @rmtoll CR2 TXINV LL_USART_SetTXPinLevel 01020 * @param USARTx USART Instance 01021 * @param PinInvMethod This parameter can be one of the following values: 01022 * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD 01023 * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED 01024 * @retval None 01025 */ 01026 __STATIC_INLINE void LL_USART_SetTXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod) 01027 { 01028 MODIFY_REG(USARTx->CR2, USART_CR2_TXINV, PinInvMethod); 01029 } 01030 01031 /** 01032 * @brief Retrieve TX pin active level logic configuration 01033 * @rmtoll CR2 TXINV LL_USART_GetTXPinLevel 01034 * @param USARTx USART Instance 01035 * @retval Returned value can be one of the following values: 01036 * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD 01037 * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED 01038 */ 01039 __STATIC_INLINE uint32_t LL_USART_GetTXPinLevel(USART_TypeDef *USARTx) 01040 { 01041 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_TXINV)); 01042 } 01043 01044 /** 01045 * @brief Configure Binary data logic. 01046 * @note Allow to define how Logical data from the data register are send/received : 01047 * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H) 01048 * @rmtoll CR2 DATAINV LL_USART_SetBinaryDataLogic 01049 * @param USARTx USART Instance 01050 * @param DataLogic This parameter can be one of the following values: 01051 * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE 01052 * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE 01053 * @retval None 01054 */ 01055 __STATIC_INLINE void LL_USART_SetBinaryDataLogic(USART_TypeDef *USARTx, uint32_t DataLogic) 01056 { 01057 MODIFY_REG(USARTx->CR2, USART_CR2_DATAINV, DataLogic); 01058 } 01059 01060 /** 01061 * @brief Retrieve Binary data configuration 01062 * @rmtoll CR2 DATAINV LL_USART_GetBinaryDataLogic 01063 * @param USARTx USART Instance 01064 * @retval Returned value can be one of the following values: 01065 * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE 01066 * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE 01067 */ 01068 __STATIC_INLINE uint32_t LL_USART_GetBinaryDataLogic(USART_TypeDef *USARTx) 01069 { 01070 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_DATAINV)); 01071 } 01072 01073 /** 01074 * @brief Configure transfer bit order (either Less or Most Significant Bit First) 01075 * @note MSB First means data is transmitted/received with the MSB first, following the start bit. 01076 * LSB First means data is transmitted/received with data bit 0 first, following the start bit. 01077 * @rmtoll CR2 MSBFIRST LL_USART_SetTransferBitOrder 01078 * @param USARTx USART Instance 01079 * @param BitOrder This parameter can be one of the following values: 01080 * @arg @ref LL_USART_BITORDER_LSBFIRST 01081 * @arg @ref LL_USART_BITORDER_MSBFIRST 01082 * @retval None 01083 */ 01084 __STATIC_INLINE void LL_USART_SetTransferBitOrder(USART_TypeDef *USARTx, uint32_t BitOrder) 01085 { 01086 MODIFY_REG(USARTx->CR2, USART_CR2_MSBFIRST, BitOrder); 01087 } 01088 01089 /** 01090 * @brief Return transfer bit order (either Less or Most Significant Bit First) 01091 * @note MSB First means data is transmitted/received with the MSB first, following the start bit. 01092 * LSB First means data is transmitted/received with data bit 0 first, following the start bit. 01093 * @rmtoll CR2 MSBFIRST LL_USART_GetTransferBitOrder 01094 * @param USARTx USART Instance 01095 * @retval Returned value can be one of the following values: 01096 * @arg @ref LL_USART_BITORDER_LSBFIRST 01097 * @arg @ref LL_USART_BITORDER_MSBFIRST 01098 */ 01099 __STATIC_INLINE uint32_t LL_USART_GetTransferBitOrder(USART_TypeDef *USARTx) 01100 { 01101 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_MSBFIRST)); 01102 } 01103 01104 /** 01105 * @brief Enable Auto Baud-Rate Detection 01106 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 01107 * Auto Baud Rate detection feature is supported by the USARTx instance. 01108 * @rmtoll CR2 ABREN LL_USART_EnableAutoBaudRate 01109 * @param USARTx USART Instance 01110 * @retval None 01111 */ 01112 __STATIC_INLINE void LL_USART_EnableAutoBaudRate(USART_TypeDef *USARTx) 01113 { 01114 SET_BIT(USARTx->CR2, USART_CR2_ABREN); 01115 } 01116 01117 /** 01118 * @brief Disable Auto Baud-Rate Detection 01119 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 01120 * Auto Baud Rate detection feature is supported by the USARTx instance. 01121 * @rmtoll CR2 ABREN LL_USART_DisableAutoBaudRate 01122 * @param USARTx USART Instance 01123 * @retval None 01124 */ 01125 __STATIC_INLINE void LL_USART_DisableAutoBaudRate(USART_TypeDef *USARTx) 01126 { 01127 CLEAR_BIT(USARTx->CR2, USART_CR2_ABREN); 01128 } 01129 01130 /** 01131 * @brief Indicate if Auto Baud-Rate Detection mechanism is enabled 01132 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 01133 * Auto Baud Rate detection feature is supported by the USARTx instance. 01134 * @rmtoll CR2 ABREN LL_USART_IsEnabledAutoBaud 01135 * @param USARTx USART Instance 01136 * @retval State of bit (1 or 0). 01137 */ 01138 __STATIC_INLINE uint32_t LL_USART_IsEnabledAutoBaud(USART_TypeDef *USARTx) 01139 { 01140 return (READ_BIT(USARTx->CR2, USART_CR2_ABREN) == (USART_CR2_ABREN)); 01141 } 01142 01143 /** 01144 * @brief Set Auto Baud-Rate mode bits 01145 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 01146 * Auto Baud Rate detection feature is supported by the USARTx instance. 01147 * @rmtoll CR2 ABRMODE LL_USART_SetAutoBaudRateMode 01148 * @param USARTx USART Instance 01149 * @param AutoBaudRateMode This parameter can be one of the following values: 01150 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT 01151 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE 01152 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME 01153 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME 01154 * @retval None 01155 */ 01156 __STATIC_INLINE void LL_USART_SetAutoBaudRateMode(USART_TypeDef *USARTx, uint32_t AutoBaudRateMode) 01157 { 01158 MODIFY_REG(USARTx->CR2, USART_CR2_ABRMODE, AutoBaudRateMode); 01159 } 01160 01161 /** 01162 * @brief Return Auto Baud-Rate mode 01163 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 01164 * Auto Baud Rate detection feature is supported by the USARTx instance. 01165 * @rmtoll CR2 ABRMODE LL_USART_GetAutoBaudRateMode 01166 * @param USARTx USART Instance 01167 * @retval Returned value can be one of the following values: 01168 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT 01169 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE 01170 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME 01171 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME 01172 */ 01173 __STATIC_INLINE uint32_t LL_USART_GetAutoBaudRateMode(USART_TypeDef *USARTx) 01174 { 01175 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ABRMODE)); 01176 } 01177 01178 /** 01179 * @brief Enable Receiver Timeout 01180 * @rmtoll CR2 RTOEN LL_USART_EnableRxTimeout 01181 * @param USARTx USART Instance 01182 * @retval None 01183 */ 01184 __STATIC_INLINE void LL_USART_EnableRxTimeout(USART_TypeDef *USARTx) 01185 { 01186 SET_BIT(USARTx->CR2, USART_CR2_RTOEN); 01187 } 01188 01189 /** 01190 * @brief Disable Receiver Timeout 01191 * @rmtoll CR2 RTOEN LL_USART_DisableRxTimeout 01192 * @param USARTx USART Instance 01193 * @retval None 01194 */ 01195 __STATIC_INLINE void LL_USART_DisableRxTimeout(USART_TypeDef *USARTx) 01196 { 01197 CLEAR_BIT(USARTx->CR2, USART_CR2_RTOEN); 01198 } 01199 01200 /** 01201 * @brief Indicate if Receiver Timeout feature is enabled 01202 * @rmtoll CR2 RTOEN LL_USART_IsEnabledRxTimeout 01203 * @param USARTx USART Instance 01204 * @retval State of bit (1 or 0). 01205 */ 01206 __STATIC_INLINE uint32_t LL_USART_IsEnabledRxTimeout(USART_TypeDef *USARTx) 01207 { 01208 return (READ_BIT(USARTx->CR2, USART_CR2_RTOEN) == (USART_CR2_RTOEN)); 01209 } 01210 01211 /** 01212 * @brief Set Address of the USART node. 01213 * @note This is used in multiprocessor communication during Mute mode or Stop mode, 01214 * for wakeup with address mark detection. 01215 * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7. 01216 * (b7-b4 should be set to 0) 01217 * 8bits address node is used when 7-bit Address Detection is selected in ADDM7. 01218 * (This is used in multiprocessor communication during Mute mode or Stop mode, 01219 * for wakeup with 7-bit address mark detection. 01220 * The MSB of the character sent by the transmitter should be equal to 1. 01221 * It may also be used for character detection during normal reception, 01222 * Mute mode inactive (for example, end of block detection in ModBus protocol). 01223 * In this case, the whole received character (8-bit) is compared to the ADD[7:0] 01224 * value and CMF flag is set on match) 01225 * @rmtoll CR2 ADD LL_USART_ConfigNodeAddress\n 01226 * CR2 ADDM7 LL_USART_ConfigNodeAddress 01227 * @param USARTx USART Instance 01228 * @param AddressLen This parameter can be one of the following values: 01229 * @arg @ref LL_USART_ADDRESS_DETECT_4B 01230 * @arg @ref LL_USART_ADDRESS_DETECT_7B 01231 * @param NodeAddress 4 or 7 bit Address of the USART node. 01232 * @retval None 01233 */ 01234 __STATIC_INLINE void LL_USART_ConfigNodeAddress(USART_TypeDef *USARTx, uint32_t AddressLen, uint32_t NodeAddress) 01235 { 01236 MODIFY_REG(USARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7, 01237 (uint32_t)(AddressLen | (NodeAddress << USART_POSITION_CR2_ADD))); 01238 } 01239 01240 /** 01241 * @brief Return 8 bit Address of the USART node as set in ADD field of CR2. 01242 * @note If 4-bit Address Detection is selected in ADDM7, 01243 * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant) 01244 * If 7-bit Address Detection is selected in ADDM7, 01245 * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant) 01246 * @rmtoll CR2 ADD LL_USART_GetNodeAddress 01247 * @param USARTx USART Instance 01248 * @retval Address of the USART node (0..255) 01249 */ 01250 __STATIC_INLINE uint32_t LL_USART_GetNodeAddress(USART_TypeDef *USARTx) 01251 { 01252 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD) >> USART_POSITION_CR2_ADD); 01253 } 01254 01255 /** 01256 * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit) 01257 * @rmtoll CR2 ADDM7 LL_USART_GetNodeAddressLen 01258 * @param USARTx USART Instance 01259 * @retval Returned value can be one of the following values: 01260 * @arg @ref LL_USART_ADDRESS_DETECT_4B 01261 * @arg @ref LL_USART_ADDRESS_DETECT_7B 01262 */ 01263 __STATIC_INLINE uint32_t LL_USART_GetNodeAddressLen(USART_TypeDef *USARTx) 01264 { 01265 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADDM7)); 01266 } 01267 01268 /** 01269 * @brief Enable RTS HW Flow Control 01270 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 01271 * Hardware Flow control feature is supported by the USARTx instance. 01272 * @rmtoll CR3 RTSE LL_USART_EnableRTSHWFlowCtrl 01273 * @param USARTx USART Instance 01274 * @retval None 01275 */ 01276 __STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx) 01277 { 01278 SET_BIT(USARTx->CR3, USART_CR3_RTSE); 01279 } 01280 01281 /** 01282 * @brief Disable RTS HW Flow Control 01283 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 01284 * Hardware Flow control feature is supported by the USARTx instance. 01285 * @rmtoll CR3 RTSE LL_USART_DisableRTSHWFlowCtrl 01286 * @param USARTx USART Instance 01287 * @retval None 01288 */ 01289 __STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx) 01290 { 01291 CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE); 01292 } 01293 01294 /** 01295 * @brief Enable CTS HW Flow Control 01296 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 01297 * Hardware Flow control feature is supported by the USARTx instance. 01298 * @rmtoll CR3 CTSE LL_USART_EnableCTSHWFlowCtrl 01299 * @param USARTx USART Instance 01300 * @retval None 01301 */ 01302 __STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx) 01303 { 01304 SET_BIT(USARTx->CR3, USART_CR3_CTSE); 01305 } 01306 01307 /** 01308 * @brief Disable CTS HW Flow Control 01309 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 01310 * Hardware Flow control feature is supported by the USARTx instance. 01311 * @rmtoll CR3 CTSE LL_USART_DisableCTSHWFlowCtrl 01312 * @param USARTx USART Instance 01313 * @retval None 01314 */ 01315 __STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx) 01316 { 01317 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE); 01318 } 01319 01320 /** 01321 * @brief Configure HW Flow Control mode (both CTS and RTS) 01322 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 01323 * Hardware Flow control feature is supported by the USARTx instance. 01324 * @rmtoll CR3 RTSE LL_USART_SetHWFlowCtrl\n 01325 * CR3 CTSE LL_USART_SetHWFlowCtrl 01326 * @param USARTx USART Instance 01327 * @param HWFlowCtrlMode This parameter can be one of the following values: 01328 * @arg @ref LL_USART_HWCONTROL_NONE 01329 * @arg @ref LL_USART_HWCONTROL_RTS 01330 * @arg @ref LL_USART_HWCONTROL_CTS 01331 * @arg @ref LL_USART_HWCONTROL_RTS_CTS 01332 * @retval None 01333 */ 01334 __STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HWFlowCtrlMode) 01335 { 01336 MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HWFlowCtrlMode); 01337 } 01338 01339 /** 01340 * @brief Return HW Flow Control configuration (both CTS and RTS) 01341 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 01342 * Hardware Flow control feature is supported by the USARTx instance. 01343 * @rmtoll CR3 RTSE LL_USART_GetHWFlowCtrl\n 01344 * CR3 CTSE LL_USART_GetHWFlowCtrl 01345 * @param USARTx USART Instance 01346 * @retval Returned value can be one of the following values: 01347 * @arg @ref LL_USART_HWCONTROL_NONE 01348 * @arg @ref LL_USART_HWCONTROL_RTS 01349 * @arg @ref LL_USART_HWCONTROL_CTS 01350 * @arg @ref LL_USART_HWCONTROL_RTS_CTS 01351 */ 01352 __STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(USART_TypeDef *USARTx) 01353 { 01354 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE)); 01355 } 01356 01357 /** 01358 * @brief Enable One bit sampling method 01359 * @rmtoll CR3 ONEBIT LL_USART_EnableOneBitSamp 01360 * @param USARTx USART Instance 01361 * @retval None 01362 */ 01363 __STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx) 01364 { 01365 SET_BIT(USARTx->CR3, USART_CR3_ONEBIT); 01366 } 01367 01368 /** 01369 * @brief Disable One bit sampling method 01370 * @rmtoll CR3 ONEBIT LL_USART_DisableOneBitSamp 01371 * @param USARTx USART Instance 01372 * @retval None 01373 */ 01374 __STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx) 01375 { 01376 CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT); 01377 } 01378 01379 /** 01380 * @brief Indicate if One bit sampling method is enabled 01381 * @rmtoll CR3 ONEBIT LL_USART_IsEnabledOneBitSamp 01382 * @param USARTx USART Instance 01383 * @retval State of bit (1 or 0). 01384 */ 01385 __STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(USART_TypeDef *USARTx) 01386 { 01387 return (READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT)); 01388 } 01389 01390 /** 01391 * @brief Enable Overrun detection 01392 * @rmtoll CR3 OVRDIS LL_USART_EnableOverrunDetect 01393 * @param USARTx USART Instance 01394 * @retval None 01395 */ 01396 __STATIC_INLINE void LL_USART_EnableOverrunDetect(USART_TypeDef *USARTx) 01397 { 01398 CLEAR_BIT(USARTx->CR3, USART_CR3_OVRDIS); 01399 } 01400 01401 /** 01402 * @brief Disable Overrun detection 01403 * @rmtoll CR3 OVRDIS LL_USART_DisableOverrunDetect 01404 * @param USARTx USART Instance 01405 * @retval None 01406 */ 01407 __STATIC_INLINE void LL_USART_DisableOverrunDetect(USART_TypeDef *USARTx) 01408 { 01409 SET_BIT(USARTx->CR3, USART_CR3_OVRDIS); 01410 } 01411 01412 /** 01413 * @brief Indicate if Overrun detection is enabled 01414 * @rmtoll CR3 OVRDIS LL_USART_IsEnabledOverrunDetect 01415 * @param USARTx USART Instance 01416 * @retval State of bit (1 or 0). 01417 */ 01418 __STATIC_INLINE uint32_t LL_USART_IsEnabledOverrunDetect(USART_TypeDef *USARTx) 01419 { 01420 return (READ_BIT(USARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS); 01421 } 01422 01423 /** 01424 * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits) 01425 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 01426 * Wake-up from Stop mode feature is supported by the USARTx instance. 01427 * @rmtoll CR3 WUS LL_USART_SetWKUPType 01428 * @param USARTx USART Instance 01429 * @param Type This parameter can be one of the following values: 01430 * @arg @ref LL_USART_WAKEUP_ON_ADDRESS 01431 * @arg @ref LL_USART_WAKEUP_ON_STARTBIT 01432 * @arg @ref LL_USART_WAKEUP_ON_RXNE 01433 * @retval None 01434 */ 01435 __STATIC_INLINE void LL_USART_SetWKUPType(USART_TypeDef *USARTx, uint32_t Type) 01436 { 01437 MODIFY_REG(USARTx->CR3, USART_CR3_WUS, Type); 01438 } 01439 01440 /** 01441 * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits) 01442 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 01443 * Wake-up from Stop mode feature is supported by the USARTx instance. 01444 * @rmtoll CR3 WUS LL_USART_GetWKUPType 01445 * @param USARTx USART Instance 01446 * @retval Returned value can be one of the following values: 01447 * @arg @ref LL_USART_WAKEUP_ON_ADDRESS 01448 * @arg @ref LL_USART_WAKEUP_ON_STARTBIT 01449 * @arg @ref LL_USART_WAKEUP_ON_RXNE 01450 */ 01451 __STATIC_INLINE uint32_t LL_USART_GetWKUPType(USART_TypeDef *USARTx) 01452 { 01453 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_WUS)); 01454 } 01455 01456 /** 01457 * @brief Configure USART BRR register for achieving expected Baudrate value. 01458 * @note Compute and set USARTDIV value in BRR Register (full BRR content) 01459 * according to used Peripheral Clock, Oversampling mode, and expected BaudRate values 01460 * @rmtoll BRR BRR LL_USART_SetBaudRate 01461 * @param USARTx USART Instance 01462 * @param PeriphClk Peripheral Clock 01463 * @param OverSampling This parameter can be one of the following values: 01464 * @arg @ref LL_USART_OVERSAMPLING_16 01465 * @arg @ref LL_USART_OVERSAMPLING_8 01466 * @param BaudRate Baudrate 01467 * @retval None 01468 */ 01469 __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling, 01470 uint32_t BaudRate) 01471 { 01472 register uint32_t usartdiv = 0x0; 01473 register uint32_t brrtemp = 0x0; 01474 01475 if (OverSampling == LL_USART_OVERSAMPLING_8) 01476 { 01477 usartdiv = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, BaudRate)); 01478 brrtemp = usartdiv & 0xFFF0; 01479 brrtemp |= (uint16_t)((usartdiv & (uint16_t)0x000F) >> 1U); 01480 USARTx->BRR = brrtemp; 01481 } 01482 else 01483 { 01484 USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate)); 01485 } 01486 } 01487 01488 /** 01489 * @brief Return current Baudrate value, according to USARTDIV present in BRR register 01490 * (full BRR content), and to used Peripheral Clock and Oversampling mode values 01491 * @rmtoll BRR BRR LL_USART_GetBaudRate 01492 * @param USARTx USART Instance 01493 * @param PeriphClk Peripheral Clock 01494 * @param OverSampling This parameter can be one of the following values: 01495 * @arg @ref LL_USART_OVERSAMPLING_16 01496 * @arg @ref LL_USART_OVERSAMPLING_8 01497 * @retval Baudrate 01498 */ 01499 __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling) 01500 { 01501 register uint32_t usartdiv = 0x0; 01502 register uint32_t brrtemp = 0x0; 01503 01504 if (OverSampling == LL_USART_OVERSAMPLING_8) 01505 { 01506 brrtemp = USARTx->BRR; 01507 usartdiv = (uint16_t)((brrtemp & 0xFFF0) | ((brrtemp & 0x0007) << 1U)) ; 01508 brrtemp = (PeriphClk * 2) / usartdiv; 01509 } 01510 else 01511 { 01512 brrtemp = PeriphClk / USARTx->BRR; 01513 } 01514 return (brrtemp); 01515 } 01516 01517 /** 01518 * @brief Set Receiver Time Out Value (expressed in nb of bits duration) 01519 * @rmtoll RTOR RTO LL_USART_SetRxTimeout 01520 * @param USARTx USART Instance 01521 * @param Timeout 0..0x00FFFFFF 01522 * @retval None 01523 */ 01524 __STATIC_INLINE void LL_USART_SetRxTimeout(USART_TypeDef *USARTx, uint32_t Timeout) 01525 { 01526 MODIFY_REG(USARTx->RTOR, USART_RTOR_RTO, Timeout); 01527 } 01528 01529 /** 01530 * @brief Get Receiver Time Out Value (expressed in nb of bits duration) 01531 * @rmtoll RTOR RTO LL_USART_GetRxTimeout 01532 * @param USARTx USART Instance 01533 * @retval 0..0x00FFFFFF 01534 */ 01535 __STATIC_INLINE uint32_t LL_USART_GetRxTimeout(USART_TypeDef *USARTx) 01536 { 01537 return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_RTO)); 01538 } 01539 01540 /** 01541 * @brief Set Block Length value in reception 01542 * @rmtoll RTOR BLEN LL_USART_SetBlockLength 01543 * @param USARTx USART Instance 01544 * @param BlockLength 0..0xFF 01545 * @retval None 01546 */ 01547 __STATIC_INLINE void LL_USART_SetBlockLength(USART_TypeDef *USARTx, uint32_t BlockLength) 01548 { 01549 MODIFY_REG(USARTx->RTOR, USART_RTOR_BLEN, BlockLength << USART_POSITION_RTOR_BLEN); 01550 } 01551 01552 /** 01553 * @brief Get Block Length value in reception 01554 * @rmtoll RTOR BLEN LL_USART_GetBlockLength 01555 * @param USARTx USART Instance 01556 * @retval 0..0xFF 01557 */ 01558 __STATIC_INLINE uint32_t LL_USART_GetBlockLength(USART_TypeDef *USARTx) 01559 { 01560 return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_BLEN) >> USART_POSITION_RTOR_BLEN); 01561 } 01562 01563 /** 01564 * @} 01565 */ 01566 01567 /** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature 01568 * @{ 01569 */ 01570 01571 /** 01572 * @brief Enable IrDA mode 01573 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 01574 * IrDA feature is supported by the USARTx instance. 01575 * @rmtoll CR3 IREN LL_USART_EnableIrda 01576 * @param USARTx USART Instance 01577 * @retval None 01578 */ 01579 __STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx) 01580 { 01581 SET_BIT(USARTx->CR3, USART_CR3_IREN); 01582 } 01583 01584 /** 01585 * @brief Disable IrDA mode 01586 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 01587 * IrDA feature is supported by the USARTx instance. 01588 * @rmtoll CR3 IREN LL_USART_DisableIrda 01589 * @param USARTx USART Instance 01590 * @retval None 01591 */ 01592 __STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx) 01593 { 01594 CLEAR_BIT(USARTx->CR3, USART_CR3_IREN); 01595 } 01596 01597 /** 01598 * @brief Indicate if IrDA mode is enabled 01599 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 01600 * IrDA feature is supported by the USARTx instance. 01601 * @rmtoll CR3 IREN LL_USART_IsEnabledIrda 01602 * @param USARTx USART Instance 01603 * @retval State of bit (1 or 0). 01604 */ 01605 __STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(USART_TypeDef *USARTx) 01606 { 01607 return (READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN)); 01608 } 01609 01610 /** 01611 * @brief Configure IrDA Power Mode (Normal or Low Power) 01612 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 01613 * IrDA feature is supported by the USARTx instance. 01614 * @rmtoll CR3 IRLP LL_USART_SetIrdaPowerMode 01615 * @param USARTx USART Instance 01616 * @param PowerMode This parameter can be one of the following values: 01617 * @arg @ref LL_USART_IRDA_POWER_NORMAL 01618 * @arg @ref LL_USART_IRDA_POWER_LOW 01619 * @retval None 01620 */ 01621 __STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode) 01622 { 01623 MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode); 01624 } 01625 01626 /** 01627 * @brief Retrieve IrDA Power Mode configuration (Normal or Low Power) 01628 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 01629 * IrDA feature is supported by the USARTx instance. 01630 * @rmtoll CR3 IRLP LL_USART_GetIrdaPowerMode 01631 * @param USARTx USART Instance 01632 * @retval Returned value can be one of the following values: 01633 * @arg @ref LL_USART_IRDA_POWER_NORMAL 01634 * @arg @ref LL_USART_PHASE_2EDGE 01635 */ 01636 __STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(USART_TypeDef *USARTx) 01637 { 01638 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP)); 01639 } 01640 01641 /** 01642 * @brief Set Irda prescaler value, used for dividing the USART clock source 01643 * to achieve the Irda Low Power frequency (8 bits value) 01644 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 01645 * IrDA feature is supported by the USARTx instance. 01646 * @rmtoll GTPR PSC LL_USART_SetIrdaPrescaler 01647 * @param USARTx USART Instance 01648 * @param PrescalerValue 0..0xFF 01649 * @retval None 01650 */ 01651 __STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) 01652 { 01653 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue); 01654 } 01655 01656 /** 01657 * @brief Return Irda prescaler value, used for dividing the USART clock source 01658 * to achieve the Irda Low Power frequency (8 bits value) 01659 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 01660 * IrDA feature is supported by the USARTx instance. 01661 * @rmtoll GTPR PSC LL_USART_GetIrdaPrescaler 01662 * @param USARTx USART Instance 01663 * @retval Irda prescaler value (0..0xFF) 01664 */ 01665 __STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(USART_TypeDef *USARTx) 01666 { 01667 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC)); 01668 } 01669 01670 /** 01671 * @} 01672 */ 01673 01674 /** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature 01675 * @{ 01676 */ 01677 01678 /** 01679 * @brief Enable Smartcard NACK transmission 01680 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 01681 * Smartcard feature is supported by the USARTx instance. 01682 * @rmtoll CR3 NACK LL_USART_EnableSmartcardNACK 01683 * @param USARTx USART Instance 01684 * @retval None 01685 */ 01686 __STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx) 01687 { 01688 SET_BIT(USARTx->CR3, USART_CR3_NACK); 01689 } 01690 01691 /** 01692 * @brief Disable Smartcard NACK transmission 01693 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 01694 * Smartcard feature is supported by the USARTx instance. 01695 * @rmtoll CR3 NACK LL_USART_DisableSmartcardNACK 01696 * @param USARTx USART Instance 01697 * @retval None 01698 */ 01699 __STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx) 01700 { 01701 CLEAR_BIT(USARTx->CR3, USART_CR3_NACK); 01702 } 01703 01704 /** 01705 * @brief Indicate if Smartcard NACK transmission is enabled 01706 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 01707 * Smartcard feature is supported by the USARTx instance. 01708 * @rmtoll CR3 NACK LL_USART_IsEnabledSmartcardNACK 01709 * @param USARTx USART Instance 01710 * @retval State of bit (1 or 0). 01711 */ 01712 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(USART_TypeDef *USARTx) 01713 { 01714 return (READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK)); 01715 } 01716 01717 /** 01718 * @brief Enable Smartcard mode 01719 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 01720 * Smartcard feature is supported by the USARTx instance. 01721 * @rmtoll CR3 SCEN LL_USART_EnableSmartcard 01722 * @param USARTx USART Instance 01723 * @retval None 01724 */ 01725 __STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx) 01726 { 01727 SET_BIT(USARTx->CR3, USART_CR3_SCEN); 01728 } 01729 01730 /** 01731 * @brief Disable Smartcard mode 01732 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 01733 * Smartcard feature is supported by the USARTx instance. 01734 * @rmtoll CR3 SCEN LL_USART_DisableSmartcard 01735 * @param USARTx USART Instance 01736 * @retval None 01737 */ 01738 __STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx) 01739 { 01740 CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN); 01741 } 01742 01743 /** 01744 * @brief Indicate if Smartcard mode is enabled 01745 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 01746 * Smartcard feature is supported by the USARTx instance. 01747 * @rmtoll CR3 SCEN LL_USART_IsEnabledSmartcard 01748 * @param USARTx USART Instance 01749 * @retval State of bit (1 or 0). 01750 */ 01751 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(USART_TypeDef *USARTx) 01752 { 01753 return (READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN)); 01754 } 01755 01756 /** 01757 * @brief Set Smartcard Auto-Retry Count value (SCARCNT[2:0] bits) 01758 * @note This bit-field specifies the number of retries in transmit and receive, in Smartcard mode. 01759 * In transmission mode, it specifies the number of automatic retransmission retries, before 01760 * generating a transmission error (FE bit set). 01761 * In reception mode, it specifies the number or erroneous reception trials, before generating a 01762 * reception error (RXNE and PE bits set) 01763 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 01764 * Smartcard feature is supported by the USARTx instance. 01765 * @rmtoll CR3 SCARCNT LL_USART_SetSmartcardAutoRetryCount 01766 * @param USARTx USART Instance 01767 * @param AutoRetryCount 0..7 01768 * @retval None 01769 */ 01770 __STATIC_INLINE void LL_USART_SetSmartcardAutoRetryCount(USART_TypeDef *USARTx, uint32_t AutoRetryCount) 01771 { 01772 MODIFY_REG(USARTx->CR3, USART_CR3_SCARCNT, AutoRetryCount << USART_POSITION_CR3_SCARCNT); 01773 } 01774 01775 /** 01776 * @brief Return Smartcard Auto-Retry Count value (SCARCNT[2:0] bits) 01777 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 01778 * Smartcard feature is supported by the USARTx instance. 01779 * @rmtoll CR3 SCARCNT LL_USART_GetSmartcardAutoRetryCount 01780 * @param USARTx USART Instance 01781 * @retval Smartcard Auto-Retry Count value (0..7) 01782 */ 01783 __STATIC_INLINE uint32_t LL_USART_GetSmartcardAutoRetryCount(USART_TypeDef *USARTx) 01784 { 01785 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_SCARCNT) >> USART_POSITION_CR3_SCARCNT); 01786 } 01787 01788 /** 01789 * @brief Set Smartcard prescaler value, used for dividing the USART clock 01790 * source to provide the SMARTCARD Clock (5 bits value) 01791 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 01792 * Smartcard feature is supported by the USARTx instance. 01793 * @rmtoll GTPR PSC LL_USART_SetSmartcardPrescaler 01794 * @param USARTx USART Instance 01795 * @param PrescalerValue 0..31 01796 * @retval None 01797 */ 01798 __STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue) 01799 { 01800 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue); 01801 } 01802 01803 /** 01804 * @brief Return Smartcard prescaler value, used for dividing the USART clock 01805 * source to provide the SMARTCARD Clock (5 bits value) 01806 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 01807 * Smartcard feature is supported by the USARTx instance. 01808 * @rmtoll GTPR PSC LL_USART_GetSmartcardPrescaler 01809 * @param USARTx USART Instance 01810 * @retval Smartcard prescaler value (0..31) 01811 */ 01812 __STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(USART_TypeDef *USARTx) 01813 { 01814 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC)); 01815 } 01816 01817 /** 01818 * @brief Set Smartcard Guard time value, expressed in nb of baud clocks periods 01819 * (GT[7:0] bits : Guard time value) 01820 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 01821 * Smartcard feature is supported by the USARTx instance. 01822 * @rmtoll GTPR GT LL_USART_SetSmartcardGuardTime 01823 * @param USARTx USART Instance 01824 * @param GuardTime 0..0xFF 01825 * @retval None 01826 */ 01827 __STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime) 01828 { 01829 MODIFY_REG(USARTx->GTPR, USART_GTPR_GT, GuardTime << USART_POSITION_GTPR_GT); 01830 } 01831 01832 /** 01833 * @brief Return Smartcard Guard time value, expressed in nb of baud clocks periods 01834 * (GT[7:0] bits : Guard time value) 01835 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 01836 * Smartcard feature is supported by the USARTx instance. 01837 * @rmtoll GTPR GT LL_USART_GetSmartcardGuardTime 01838 * @param USARTx USART Instance 01839 * @retval Smartcard Guard time value (0..0xFF) 01840 */ 01841 __STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(USART_TypeDef *USARTx) 01842 { 01843 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_POSITION_GTPR_GT); 01844 } 01845 01846 /** 01847 * @} 01848 */ 01849 01850 /** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature 01851 * @{ 01852 */ 01853 01854 /** 01855 * @brief Enable Single Wire Half-Duplex mode 01856 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not 01857 * Half-Duplex mode is supported by the USARTx instance. 01858 * @rmtoll CR3 HDSEL LL_USART_EnableHalfDuplex 01859 * @param USARTx USART Instance 01860 * @retval None 01861 */ 01862 __STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx) 01863 { 01864 SET_BIT(USARTx->CR3, USART_CR3_HDSEL); 01865 } 01866 01867 /** 01868 * @brief Disable Single Wire Half-Duplex mode 01869 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not 01870 * Half-Duplex mode is supported by the USARTx instance. 01871 * @rmtoll CR3 HDSEL LL_USART_DisableHalfDuplex 01872 * @param USARTx USART Instance 01873 * @retval None 01874 */ 01875 __STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx) 01876 { 01877 CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL); 01878 } 01879 01880 /** 01881 * @brief Indicate if Single Wire Half-Duplex mode is enabled 01882 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not 01883 * Half-Duplex mode is supported by the USARTx instance. 01884 * @rmtoll CR3 HDSEL LL_USART_IsEnabledHalfDuplex 01885 * @param USARTx USART Instance 01886 * @retval State of bit (1 or 0). 01887 */ 01888 __STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(USART_TypeDef *USARTx) 01889 { 01890 return (READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL)); 01891 } 01892 01893 /** 01894 * @} 01895 */ 01896 01897 /** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature 01898 * @{ 01899 */ 01900 01901 /** 01902 * @brief Set LIN Break Detection Length 01903 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 01904 * LIN feature is supported by the USARTx instance. 01905 * @rmtoll CR2 LBDL LL_USART_SetLINBrkDetectionLen 01906 * @param USARTx USART Instance 01907 * @param LINBDLength This parameter can be one of the following values: 01908 * @arg @ref LL_USART_LINBREAK_DETECT_10B 01909 * @arg @ref LL_USART_LINBREAK_DETECT_11B 01910 * @retval None 01911 */ 01912 __STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength) 01913 { 01914 MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength); 01915 } 01916 01917 /** 01918 * @brief Return LIN Break Detection Length 01919 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 01920 * LIN feature is supported by the USARTx instance. 01921 * @rmtoll CR2 LBDL LL_USART_GetLINBrkDetectionLen 01922 * @param USARTx USART Instance 01923 * @retval Returned value can be one of the following values: 01924 * @arg @ref LL_USART_LINBREAK_DETECT_10B 01925 * @arg @ref LL_USART_LINBREAK_DETECT_11B 01926 */ 01927 __STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(USART_TypeDef *USARTx) 01928 { 01929 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL)); 01930 } 01931 01932 /** 01933 * @brief Enable LIN mode 01934 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 01935 * LIN feature is supported by the USARTx instance. 01936 * @rmtoll CR2 LINEN LL_USART_EnableLIN 01937 * @param USARTx USART Instance 01938 * @retval None 01939 */ 01940 __STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx) 01941 { 01942 SET_BIT(USARTx->CR2, USART_CR2_LINEN); 01943 } 01944 01945 /** 01946 * @brief Disable LIN mode 01947 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 01948 * LIN feature is supported by the USARTx instance. 01949 * @rmtoll CR2 LINEN LL_USART_DisableLIN 01950 * @param USARTx USART Instance 01951 * @retval None 01952 */ 01953 __STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx) 01954 { 01955 CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN); 01956 } 01957 01958 /** 01959 * @brief Indicate if LIN mode is enabled 01960 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 01961 * LIN feature is supported by the USARTx instance. 01962 * @rmtoll CR2 LINEN LL_USART_IsEnabledLIN 01963 * @param USARTx USART Instance 01964 * @retval State of bit (1 or 0). 01965 */ 01966 __STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(USART_TypeDef *USARTx) 01967 { 01968 return (READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN)); 01969 } 01970 01971 /** 01972 * @} 01973 */ 01974 01975 /** @defgroup USART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature 01976 * @{ 01977 */ 01978 01979 /** 01980 * @brief Set DEDT (Driver Enable Deassertion Time), Time value expressed on 5 bits ([4:0] bits). 01981 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 01982 * Driver Enable feature is supported by the USARTx instance. 01983 * @rmtoll CR1 DEDT LL_USART_SetDEDeassertionTime 01984 * @param USARTx USART Instance 01985 * @param Time 0..31 01986 * @retval None 01987 */ 01988 __STATIC_INLINE void LL_USART_SetDEDeassertionTime(USART_TypeDef *USARTx, uint32_t Time) 01989 { 01990 MODIFY_REG(USARTx->CR1, USART_CR1_DEDT, Time << USART_POSITION_CR1_DEDT); 01991 } 01992 01993 /** 01994 * @brief Return DEDT (Driver Enable Deassertion Time) 01995 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 01996 * Driver Enable feature is supported by the USARTx instance. 01997 * @rmtoll CR1 DEDT LL_USART_GetDEDeassertionTime 01998 * @param USARTx USART Instance 01999 * @retval Time value expressed on 5 bits ([4:0] bits) : 0..31 02000 */ 02001 __STATIC_INLINE uint32_t LL_USART_GetDEDeassertionTime(USART_TypeDef *USARTx) 02002 { 02003 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEDT) >> USART_POSITION_CR1_DEDT); 02004 } 02005 02006 /** 02007 * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits). 02008 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02009 * Driver Enable feature is supported by the USARTx instance. 02010 * @rmtoll CR1 DEAT LL_USART_SetDEAssertionTime 02011 * @param USARTx USART Instance 02012 * @param Time 0..31 02013 * @retval None 02014 */ 02015 __STATIC_INLINE void LL_USART_SetDEAssertionTime(USART_TypeDef *USARTx, uint32_t Time) 02016 { 02017 MODIFY_REG(USARTx->CR1, USART_CR1_DEAT, Time << USART_POSITION_CR1_DEAT); 02018 } 02019 02020 /** 02021 * @brief Return DEAT (Driver Enable Assertion Time) 02022 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02023 * Driver Enable feature is supported by the USARTx instance. 02024 * @rmtoll CR1 DEAT LL_USART_GetDEAssertionTime 02025 * @param USARTx USART Instance 02026 * @retval Time value expressed on 5 bits ([4:0] bits) : 0..31 02027 */ 02028 __STATIC_INLINE uint32_t LL_USART_GetDEAssertionTime(USART_TypeDef *USARTx) 02029 { 02030 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEAT) >> USART_POSITION_CR1_DEAT); 02031 } 02032 02033 /** 02034 * @brief Enable Driver Enable (DE) Mode 02035 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02036 * Driver Enable feature is supported by the USARTx instance. 02037 * @rmtoll CR3 DEM LL_USART_EnableDEMode 02038 * @param USARTx USART Instance 02039 * @retval None 02040 */ 02041 __STATIC_INLINE void LL_USART_EnableDEMode(USART_TypeDef *USARTx) 02042 { 02043 SET_BIT(USARTx->CR3, USART_CR3_DEM); 02044 } 02045 02046 /** 02047 * @brief Disable Driver Enable (DE) Mode 02048 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02049 * Driver Enable feature is supported by the USARTx instance. 02050 * @rmtoll CR3 DEM LL_USART_DisableDEMode 02051 * @param USARTx USART Instance 02052 * @retval None 02053 */ 02054 __STATIC_INLINE void LL_USART_DisableDEMode(USART_TypeDef *USARTx) 02055 { 02056 CLEAR_BIT(USARTx->CR3, USART_CR3_DEM); 02057 } 02058 02059 /** 02060 * @brief Indicate if Driver Enable (DE) Mode is enabled 02061 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02062 * Driver Enable feature is supported by the USARTx instance. 02063 * @rmtoll CR3 DEM LL_USART_IsEnabledDEMode 02064 * @param USARTx USART Instance 02065 * @retval State of bit (1 or 0). 02066 */ 02067 __STATIC_INLINE uint32_t LL_USART_IsEnabledDEMode(USART_TypeDef *USARTx) 02068 { 02069 return (READ_BIT(USARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM)); 02070 } 02071 02072 /** 02073 * @brief Select Driver Enable Polarity 02074 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02075 * Driver Enable feature is supported by the USARTx instance. 02076 * @rmtoll CR3 DEP LL_USART_SetDESignalPolarity 02077 * @param USARTx USART Instance 02078 * @param Polarity This parameter can be one of the following values: 02079 * @arg @ref LL_USART_DE_POLARITY_HIGH 02080 * @arg @ref LL_USART_DE_POLARITY_LOW 02081 * @retval None 02082 */ 02083 __STATIC_INLINE void LL_USART_SetDESignalPolarity(USART_TypeDef *USARTx, uint32_t Polarity) 02084 { 02085 MODIFY_REG(USARTx->CR3, USART_CR3_DEP, Polarity); 02086 } 02087 02088 /** 02089 * @brief Return Driver Enable Polarity 02090 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not 02091 * Driver Enable feature is supported by the USARTx instance. 02092 * @rmtoll CR3 DEP LL_USART_GetDESignalPolarity 02093 * @param USARTx USART Instance 02094 * @retval Returned value can be one of the following values: 02095 * @arg @ref LL_USART_DE_POLARITY_HIGH 02096 * @arg @ref LL_USART_DE_POLARITY_LOW 02097 */ 02098 __STATIC_INLINE uint32_t LL_USART_GetDESignalPolarity(USART_TypeDef *USARTx) 02099 { 02100 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_DEP)); 02101 } 02102 02103 /** 02104 * @} 02105 */ 02106 02107 /** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services 02108 * @{ 02109 */ 02110 02111 /** 02112 * @brief Perform basic configuration of USART for enabling use in Asynchronous Mode (UART) 02113 * @note In UART mode, the following bits must be kept cleared: 02114 * LINEN, and CLKEN bits in the USART_CR2 register, 02115 * SCEN, IREN and HDSEL bits in the USART_CR3 register. 02116 * @note Call of this function is equivalent to following function call sequence : 02117 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 02118 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 02119 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 02120 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 02121 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 02122 * @note Other remaining configurations items related to Asynchronous Mode 02123 * (as Baudrate, Word length, Parity, ...) should be set using 02124 * dedicated functions 02125 * @rmtoll CR2 LINEN LL_USART_ConfigAsyncMode\n 02126 * CR2 CLKEN LL_USART_ConfigAsyncMode\n 02127 * CR3 SCEN LL_USART_ConfigAsyncMode\n 02128 * CR3 IREN LL_USART_ConfigAsyncMode\n 02129 * CR3 HDSEL LL_USART_ConfigAsyncMode 02130 * @param USARTx USART Instance 02131 * @retval None 02132 */ 02133 __STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx) 02134 { 02135 /* In Asynchronous mode, the following bits must be kept cleared: 02136 - LINEN, STOP and CLKEN bits in the USART_CR2 register, 02137 - SCEN and HDSEL bits in the USART_CR3 register.*/ 02138 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); 02139 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL)); 02140 } 02141 02142 /** 02143 * @brief Perform basic configuration of USART for enabling use in Synchronous Mode 02144 * @note In Synchronous mode, the following bits must be kept cleared: 02145 * LINEN bit in the USART_CR2 register, 02146 * SCEN, IREN and HDSEL bits in the USART_CR3 register. 02147 * This function also sets the USART in Synchronous mode. 02148 * @note Call of this function is equivalent to following function call sequence : 02149 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 02150 * - Clear IREN in CR3 using @ref LL_USART_DisableSmartcard() function 02151 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 02152 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 02153 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function 02154 * @note Other remaining configurations items related to Synchronous Mode 02155 * (as Baudrate, Word length, Parity, Clock Polarity, ...) should be set using 02156 * dedicated functions 02157 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not 02158 * Synchronous mode is supported by the USARTx instance. 02159 * @rmtoll CR2 LINEN LL_USART_ConfigSyncMode\n 02160 * CR2 CLKEN LL_USART_ConfigSyncMode\n 02161 * CR3 SCEN LL_USART_ConfigSyncMode\n 02162 * CR3 IREN LL_USART_ConfigSyncMode\n 02163 * CR3 HDSEL LL_USART_ConfigSyncMode 02164 * @param USARTx USART Instance 02165 * @retval None 02166 */ 02167 __STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx) 02168 { 02169 /* In Synchronous mode, the following bits must be kept cleared: 02170 - LINEN bit in the USART_CR2 register, 02171 - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/ 02172 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN)); 02173 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL)); 02174 /* set the UART/USART in Synchronous mode */ 02175 SET_BIT(USARTx->CR2, USART_CR2_CLKEN); 02176 } 02177 02178 /** 02179 * @brief Perform basic configuration of USART for enabling use in LIN Mode 02180 * @note In LIN mode, the following bits must be kept cleared: 02181 * STOP and CLKEN bits in the USART_CR2 register, 02182 * IREN, SCEN and HDSEL bits in the USART_CR3 register. 02183 * This function also set the UART/USART in LIN mode. 02184 * @note Call of this function is equivalent to following function call sequence : 02185 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 02186 * - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function 02187 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 02188 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 02189 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 02190 * - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function 02191 * @note Other remaining configurations items related to LIN Mode 02192 * (as Baudrate, Word length, LIN Break Detection Length, ...) should be set using 02193 * dedicated functions 02194 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 02195 * LIN feature is supported by the USARTx instance. 02196 * @rmtoll CR2 CLKEN LL_USART_ConfigLINMode\n 02197 * CR2 STOP LL_USART_ConfigLINMode\n 02198 * CR2 LINEN LL_USART_ConfigLINMode\n 02199 * CR3 IREN LL_USART_ConfigLINMode\n 02200 * CR3 SCEN LL_USART_ConfigLINMode\n 02201 * CR3 HDSEL LL_USART_ConfigLINMode 02202 * @param USARTx USART Instance 02203 * @retval None 02204 */ 02205 __STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx) 02206 { 02207 /* In LIN mode, the following bits must be kept cleared: 02208 - STOP and CLKEN bits in the USART_CR2 register, 02209 - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/ 02210 CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP)); 02211 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL)); 02212 /* Set the UART/USART in LIN mode */ 02213 SET_BIT(USARTx->CR2, USART_CR2_LINEN); 02214 } 02215 02216 /** 02217 * @brief Perform basic configuration of USART for enabling use in Half Duplex Mode 02218 * @note In Half Duplex mode, the following bits must be kept cleared: 02219 * LINEN, and CLKEN bits in the USART_CR2 register, 02220 * SCEN and IREN bits in the USART_CR3 register. 02221 * This function also sets the UART/USART in Half Duplex mode. 02222 * @note Call of this function is equivalent to following function call sequence : 02223 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 02224 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 02225 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 02226 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 02227 * - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function 02228 * @note Other remaining configurations items related to Half Duplex Mode 02229 * (as Baudrate, Word length, Parity, ...) should be set using 02230 * dedicated functions 02231 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not 02232 * Half-Duplex mode is supported by the USARTx instance. 02233 * @rmtoll CR2 LINEN LL_USART_ConfigHalfDuplexMode\n 02234 * CR2 CLKEN LL_USART_ConfigHalfDuplexMode\n 02235 * CR3 HDSEL LL_USART_ConfigHalfDuplexMode\n 02236 * CR3 SCEN LL_USART_ConfigHalfDuplexMode\n 02237 * CR3 IREN LL_USART_ConfigHalfDuplexMode 02238 * @param USARTx USART Instance 02239 * @retval None 02240 */ 02241 __STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx) 02242 { 02243 /* In Half Duplex mode, the following bits must be kept cleared: 02244 - LINEN, and CLKEN bits in the USART_CR2 register, 02245 - SCEN and IREN bits in the USART_CR3 register.*/ 02246 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); 02247 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN)); 02248 /* set the UART/USART in Half Duplex mode */ 02249 SET_BIT(USARTx->CR3, USART_CR3_HDSEL); 02250 } 02251 02252 /** 02253 * @brief Perform basic configuration of USART for enabling use in Smartcard Mode 02254 * @note In Smartcard mode, the following bits must be kept cleared: 02255 * LINEN bit in the USART_CR2 register, 02256 * IREN and HDSEL bits in the USART_CR3 register. 02257 * This function also configures Stop bits to 1.5 bits and 02258 * sets the USART in Smartcard mode (SCEN bit). 02259 * Clock Output is also enabled (CLKEN). 02260 * @note Call of this function is equivalent to following function call sequence : 02261 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 02262 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 02263 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 02264 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function 02265 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function 02266 * - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function 02267 * @note Other remaining configurations items related to Smartcard Mode 02268 * (as Baudrate, Word length, Parity, ...) should be set using 02269 * dedicated functions 02270 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02271 * Smartcard feature is supported by the USARTx instance. 02272 * @rmtoll CR2 LINEN LL_USART_ConfigSmartcardMode\n 02273 * CR2 STOP LL_USART_ConfigSmartcardMode\n 02274 * CR2 CLKEN LL_USART_ConfigSmartcardMode\n 02275 * CR3 HDSEL LL_USART_ConfigSmartcardMode\n 02276 * CR3 SCEN LL_USART_ConfigSmartcardMode 02277 * @param USARTx USART Instance 02278 * @retval None 02279 */ 02280 __STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx) 02281 { 02282 /* In Smartcard mode, the following bits must be kept cleared: 02283 - LINEN bit in the USART_CR2 register, 02284 - IREN and HDSEL bits in the USART_CR3 register.*/ 02285 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN)); 02286 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL)); 02287 /* Configure Stop bits to 1.5 bits */ 02288 /* Synchronous mode is activated by default */ 02289 SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN)); 02290 /* set the UART/USART in Smartcard mode */ 02291 SET_BIT(USARTx->CR3, USART_CR3_SCEN); 02292 } 02293 02294 /** 02295 * @brief Perform basic configuration of USART for enabling use in Irda Mode 02296 * @note In IRDA mode, the following bits must be kept cleared: 02297 * LINEN, STOP and CLKEN bits in the USART_CR2 register, 02298 * SCEN and HDSEL bits in the USART_CR3 register. 02299 * This function also sets the UART/USART in IRDA mode (IREN bit). 02300 * @note Call of this function is equivalent to following function call sequence : 02301 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 02302 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 02303 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 02304 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 02305 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function 02306 * - Set IREN in CR3 using @ref LL_USART_EnableIrda() function 02307 * @note Other remaining configurations items related to Irda Mode 02308 * (as Baudrate, Word length, Power mode, ...) should be set using 02309 * dedicated functions 02310 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not 02311 * IrDA feature is supported by the USARTx instance. 02312 * @rmtoll CR2 LINEN LL_USART_ConfigIrdaMode\n 02313 * CR2 CLKEN LL_USART_ConfigIrdaMode\n 02314 * CR2 STOP LL_USART_ConfigIrdaMode\n 02315 * CR3 SCEN LL_USART_ConfigIrdaMode\n 02316 * CR3 HDSEL LL_USART_ConfigIrdaMode\n 02317 * CR3 IREN LL_USART_ConfigIrdaMode 02318 * @param USARTx USART Instance 02319 * @retval None 02320 */ 02321 __STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx) 02322 { 02323 /* In IRDA mode, the following bits must be kept cleared: 02324 - LINEN, STOP and CLKEN bits in the USART_CR2 register, 02325 - SCEN and HDSEL bits in the USART_CR3 register.*/ 02326 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP)); 02327 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL)); 02328 /* set the UART/USART in IRDA mode */ 02329 SET_BIT(USARTx->CR3, USART_CR3_IREN); 02330 } 02331 02332 /** 02333 * @brief Perform basic configuration of USART for enabling use in Multi processor Mode 02334 * (several USARTs connected in a network, one of the USARTs can be the master, 02335 * its TX output connected to the RX inputs of the other slaves USARTs). 02336 * @note In MultiProcessor mode, the following bits must be kept cleared: 02337 * LINEN, CLKEN bits in the USART_CR2 register, 02338 * IREN, SCEN and HDSEL bits in the USART_CR3 register. 02339 * @note Call of this function is equivalent to following function call sequence : 02340 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function 02341 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function 02342 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function 02343 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function 02344 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function 02345 * @note Other remaining configurations items related to Multi processor Mode 02346 * (as Baudrate, Wake Up Method, Node address, ...) should be set using 02347 * dedicated functions 02348 * @rmtoll CR2 LINEN LL_USART_ConfigMultiProcessMode\n 02349 * CR2 CLKEN LL_USART_ConfigMultiProcessMode\n 02350 * CR3 SCEN LL_USART_ConfigMultiProcessMode\n 02351 * CR3 HDSEL LL_USART_ConfigMultiProcessMode\n 02352 * CR3 IREN LL_USART_ConfigMultiProcessMode 02353 * @param USARTx USART Instance 02354 * @retval None 02355 */ 02356 __STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx) 02357 { 02358 /* In Multi Processor mode, the following bits must be kept cleared: 02359 - LINEN and CLKEN bits in the USART_CR2 register, 02360 - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/ 02361 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN)); 02362 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN)); 02363 } 02364 02365 /** 02366 * @} 02367 */ 02368 02369 /** @defgroup USART_LL_EF_FLAG_Management FLAG_Management 02370 * @{ 02371 */ 02372 02373 /** 02374 * @brief Check if the USART Parity Error Flag is set or not 02375 * @rmtoll ISR PE LL_USART_IsActiveFlag_PE 02376 * @param USARTx USART Instance 02377 * @retval State of bit (1 or 0). 02378 */ 02379 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(USART_TypeDef *USARTx) 02380 { 02381 return (READ_BIT(USARTx->ISR, USART_ISR_PE) == (USART_ISR_PE)); 02382 } 02383 02384 /** 02385 * @brief Check if the USART Framing Error Flag is set or not 02386 * @rmtoll ISR FE LL_USART_IsActiveFlag_FE 02387 * @param USARTx USART Instance 02388 * @retval State of bit (1 or 0). 02389 */ 02390 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(USART_TypeDef *USARTx) 02391 { 02392 return (READ_BIT(USARTx->ISR, USART_ISR_FE) == (USART_ISR_FE)); 02393 } 02394 02395 /** 02396 * @brief Check if the USART Noise detected Flag is set or not 02397 * @rmtoll ISR NE LL_USART_IsActiveFlag_NE 02398 * @param USARTx USART Instance 02399 * @retval State of bit (1 or 0). 02400 */ 02401 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(USART_TypeDef *USARTx) 02402 { 02403 return (READ_BIT(USARTx->ISR, USART_ISR_NE) == (USART_ISR_NE)); 02404 } 02405 02406 /** 02407 * @brief Check if the USART OverRun Error Flag is set or not 02408 * @rmtoll ISR ORE LL_USART_IsActiveFlag_ORE 02409 * @param USARTx USART Instance 02410 * @retval State of bit (1 or 0). 02411 */ 02412 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(USART_TypeDef *USARTx) 02413 { 02414 return (READ_BIT(USARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE)); 02415 } 02416 02417 /** 02418 * @brief Check if the USART IDLE line detected Flag is set or not 02419 * @rmtoll ISR IDLE LL_USART_IsActiveFlag_IDLE 02420 * @param USARTx USART Instance 02421 * @retval State of bit (1 or 0). 02422 */ 02423 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(USART_TypeDef *USARTx) 02424 { 02425 return (READ_BIT(USARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE)); 02426 } 02427 02428 /** 02429 * @brief Check if the USART Read Data Register Not Empty Flag is set or not 02430 * @rmtoll ISR RXNE LL_USART_IsActiveFlag_RXNE 02431 * @param USARTx USART Instance 02432 * @retval State of bit (1 or 0). 02433 */ 02434 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE(USART_TypeDef *USARTx) 02435 { 02436 return (READ_BIT(USARTx->ISR, USART_ISR_RXNE) == (USART_ISR_RXNE)); 02437 } 02438 02439 /** 02440 * @brief Check if the USART Transmission Complete Flag is set or not 02441 * @rmtoll ISR TC LL_USART_IsActiveFlag_TC 02442 * @param USARTx USART Instance 02443 * @retval State of bit (1 or 0). 02444 */ 02445 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(USART_TypeDef *USARTx) 02446 { 02447 return (READ_BIT(USARTx->ISR, USART_ISR_TC) == (USART_ISR_TC)); 02448 } 02449 02450 /** 02451 * @brief Check if the USART Transmit Data Register Empty Flag is set or not 02452 * @rmtoll ISR TXE LL_USART_IsActiveFlag_TXE 02453 * @param USARTx USART Instance 02454 * @retval State of bit (1 or 0). 02455 */ 02456 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE(USART_TypeDef *USARTx) 02457 { 02458 return (READ_BIT(USARTx->ISR, USART_ISR_TXE) == (USART_ISR_TXE)); 02459 } 02460 02461 /** 02462 * @brief Check if the USART LIN Break Detection Flag is set or not 02463 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 02464 * LIN feature is supported by the USARTx instance. 02465 * @rmtoll ISR LBDF LL_USART_IsActiveFlag_LBD 02466 * @param USARTx USART Instance 02467 * @retval State of bit (1 or 0). 02468 */ 02469 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(USART_TypeDef *USARTx) 02470 { 02471 return (READ_BIT(USARTx->ISR, USART_ISR_LBDF) == (USART_ISR_LBDF)); 02472 } 02473 02474 /** 02475 * @brief Check if the USART CTS interrupt Flag is set or not 02476 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 02477 * Hardware Flow control feature is supported by the USARTx instance. 02478 * @rmtoll ISR CTSIF LL_USART_IsActiveFlag_nCTS 02479 * @param USARTx USART Instance 02480 * @retval State of bit (1 or 0). 02481 */ 02482 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(USART_TypeDef *USARTx) 02483 { 02484 return (READ_BIT(USARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF)); 02485 } 02486 02487 /** 02488 * @brief Check if the USART CTS Flag is set or not 02489 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 02490 * Hardware Flow control feature is supported by the USARTx instance. 02491 * @rmtoll ISR CTS LL_USART_IsActiveFlag_CTS 02492 * @param USARTx USART Instance 02493 * @retval State of bit (1 or 0). 02494 */ 02495 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CTS(USART_TypeDef *USARTx) 02496 { 02497 return (READ_BIT(USARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS)); 02498 } 02499 02500 /** 02501 * @brief Check if the USART Receiver Time Out Flag is set or not 02502 * @rmtoll ISR RTOF LL_USART_IsActiveFlag_RTO 02503 * @param USARTx USART Instance 02504 * @retval State of bit (1 or 0). 02505 */ 02506 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RTO(USART_TypeDef *USARTx) 02507 { 02508 return (READ_BIT(USARTx->ISR, USART_ISR_RTOF) == (USART_ISR_RTOF)); 02509 } 02510 02511 /** 02512 * @brief Check if the USART End Of Block Flag is set or not 02513 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02514 * Smartcard feature is supported by the USARTx instance. 02515 * @rmtoll ISR EOBF LL_USART_IsActiveFlag_EOB 02516 * @param USARTx USART Instance 02517 * @retval State of bit (1 or 0). 02518 */ 02519 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_EOB(USART_TypeDef *USARTx) 02520 { 02521 return (READ_BIT(USARTx->ISR, USART_ISR_EOBF) == (USART_ISR_EOBF)); 02522 } 02523 02524 /** 02525 * @brief Check if the USART Auto-Baud Rate Error Flag is set or not 02526 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 02527 * Auto Baud Rate detection feature is supported by the USARTx instance. 02528 * @rmtoll ISR ABRE LL_USART_IsActiveFlag_ABRE 02529 * @param USARTx USART Instance 02530 * @retval State of bit (1 or 0). 02531 */ 02532 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABRE(USART_TypeDef *USARTx) 02533 { 02534 return (READ_BIT(USARTx->ISR, USART_ISR_ABRE) == (USART_ISR_ABRE)); 02535 } 02536 02537 /** 02538 * @brief Check if the USART Auto-Baud Rate Flag is set or not 02539 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 02540 * Auto Baud Rate detection feature is supported by the USARTx instance. 02541 * @rmtoll ISR ABRF LL_USART_IsActiveFlag_ABR 02542 * @param USARTx USART Instance 02543 * @retval State of bit (1 or 0). 02544 */ 02545 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABR(USART_TypeDef *USARTx) 02546 { 02547 return (READ_BIT(USARTx->ISR, USART_ISR_ABRF) == (USART_ISR_ABRF)); 02548 } 02549 02550 /** 02551 * @brief Check if the USART Busy Flag is set or not 02552 * @rmtoll ISR BUSY LL_USART_IsActiveFlag_BUSY 02553 * @param USARTx USART Instance 02554 * @retval State of bit (1 or 0). 02555 */ 02556 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_BUSY(USART_TypeDef *USARTx) 02557 { 02558 return (READ_BIT(USARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY)); 02559 } 02560 02561 /** 02562 * @brief Check if the USART Character Match Flag is set or not 02563 * @rmtoll ISR CMF LL_USART_IsActiveFlag_CM 02564 * @param USARTx USART Instance 02565 * @retval State of bit (1 or 0). 02566 */ 02567 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CM(USART_TypeDef *USARTx) 02568 { 02569 return (READ_BIT(USARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF)); 02570 } 02571 02572 /** 02573 * @brief Check if the USART Send Break Flag is set or not 02574 * @rmtoll ISR SBKF LL_USART_IsActiveFlag_SBK 02575 * @param USARTx USART Instance 02576 * @retval State of bit (1 or 0). 02577 */ 02578 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(USART_TypeDef *USARTx) 02579 { 02580 return (READ_BIT(USARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF)); 02581 } 02582 02583 /** 02584 * @brief Check if the USART Receive Wake Up from mute mode Flag is set or not 02585 * @rmtoll ISR RWU LL_USART_IsActiveFlag_RWU 02586 * @param USARTx USART Instance 02587 * @retval State of bit (1 or 0). 02588 */ 02589 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(USART_TypeDef *USARTx) 02590 { 02591 return (READ_BIT(USARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU)); 02592 } 02593 02594 /** 02595 * @brief Check if the USART Wake Up from stop mode Flag is set or not 02596 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 02597 * Wake-up from Stop mode feature is supported by the USARTx instance. 02598 * @rmtoll ISR WUF LL_USART_IsActiveFlag_WKUP 02599 * @param USARTx USART Instance 02600 * @retval State of bit (1 or 0). 02601 */ 02602 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_WKUP(USART_TypeDef *USARTx) 02603 { 02604 return (READ_BIT(USARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF)); 02605 } 02606 02607 /** 02608 * @brief Check if the USART Transmit Enable Acknowledge Flag is set or not 02609 * @rmtoll ISR TEACK LL_USART_IsActiveFlag_TEACK 02610 * @param USARTx USART Instance 02611 * @retval State of bit (1 or 0). 02612 */ 02613 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TEACK(USART_TypeDef *USARTx) 02614 { 02615 return (READ_BIT(USARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK)); 02616 } 02617 02618 /** 02619 * @brief Check if the USART Receive Enable Acknowledge Flag is set or not 02620 * @rmtoll ISR REACK LL_USART_IsActiveFlag_REACK 02621 * @param USARTx USART Instance 02622 * @retval State of bit (1 or 0). 02623 */ 02624 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_REACK(USART_TypeDef *USARTx) 02625 { 02626 return (READ_BIT(USARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK)); 02627 } 02628 02629 /** 02630 * @brief Clear Parity Error Flag 02631 * @rmtoll ICR PECF LL_USART_ClearFlag_PE 02632 * @param USARTx USART Instance 02633 * @retval None 02634 */ 02635 __STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx) 02636 { 02637 WRITE_REG(USARTx->ICR, USART_ICR_PECF); 02638 } 02639 02640 /** 02641 * @brief Clear Framing Error Flag 02642 * @rmtoll ICR FECF LL_USART_ClearFlag_FE 02643 * @param USARTx USART Instance 02644 * @retval None 02645 */ 02646 __STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx) 02647 { 02648 WRITE_REG(USARTx->ICR, USART_ICR_FECF); 02649 } 02650 02651 /** 02652 * @brief Clear Noise detected Flag 02653 * @rmtoll ICR NCF LL_USART_ClearFlag_NE 02654 * @param USARTx USART Instance 02655 * @retval None 02656 */ 02657 __STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx) 02658 { 02659 WRITE_REG(USARTx->ICR, USART_ICR_NCF); 02660 } 02661 02662 /** 02663 * @brief Clear OverRun Error Flag 02664 * @rmtoll ICR ORECF LL_USART_ClearFlag_ORE 02665 * @param USARTx USART Instance 02666 * @retval None 02667 */ 02668 __STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx) 02669 { 02670 WRITE_REG(USARTx->ICR, USART_ICR_ORECF); 02671 } 02672 02673 /** 02674 * @brief Clear IDLE line detected Flag 02675 * @rmtoll ICR IDLECF LL_USART_ClearFlag_IDLE 02676 * @param USARTx USART Instance 02677 * @retval None 02678 */ 02679 __STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx) 02680 { 02681 WRITE_REG(USARTx->ICR, USART_ICR_IDLECF); 02682 } 02683 02684 /** 02685 * @brief Clear Transmission Complete Flag 02686 * @rmtoll ICR TCCF LL_USART_ClearFlag_TC 02687 * @param USARTx USART Instance 02688 * @retval None 02689 */ 02690 __STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx) 02691 { 02692 WRITE_REG(USARTx->ICR, USART_ICR_TCCF); 02693 } 02694 02695 /** 02696 * @brief Clear LIN Break Detection Flag 02697 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 02698 * LIN feature is supported by the USARTx instance. 02699 * @rmtoll ICR LBDCF LL_USART_ClearFlag_LBD 02700 * @param USARTx USART Instance 02701 * @retval None 02702 */ 02703 __STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx) 02704 { 02705 WRITE_REG(USARTx->ICR, USART_ICR_LBDCF); 02706 } 02707 02708 /** 02709 * @brief Clear CTS Interrupt Flag 02710 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 02711 * Hardware Flow control feature is supported by the USARTx instance. 02712 * @rmtoll ICR CTSCF LL_USART_ClearFlag_nCTS 02713 * @param USARTx USART Instance 02714 * @retval None 02715 */ 02716 __STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx) 02717 { 02718 WRITE_REG(USARTx->ICR, USART_ICR_CTSCF); 02719 } 02720 02721 /** 02722 * @brief Clear Receiver Time Out Flag 02723 * @rmtoll ICR RTOCF LL_USART_ClearFlag_RTO 02724 * @param USARTx USART Instance 02725 * @retval None 02726 */ 02727 __STATIC_INLINE void LL_USART_ClearFlag_RTO(USART_TypeDef *USARTx) 02728 { 02729 WRITE_REG(USARTx->ICR, USART_ICR_RTOCF); 02730 } 02731 02732 /** 02733 * @brief Clear End Of Block Flag 02734 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02735 * Smartcard feature is supported by the USARTx instance. 02736 * @rmtoll ICR EOBCF LL_USART_ClearFlag_EOB 02737 * @param USARTx USART Instance 02738 * @retval None 02739 */ 02740 __STATIC_INLINE void LL_USART_ClearFlag_EOB(USART_TypeDef *USARTx) 02741 { 02742 WRITE_REG(USARTx->ICR, USART_ICR_EOBCF); 02743 } 02744 02745 /** 02746 * @brief Clear Character Match Flag 02747 * @rmtoll ICR CMCF LL_USART_ClearFlag_CM 02748 * @param USARTx USART Instance 02749 * @retval None 02750 */ 02751 __STATIC_INLINE void LL_USART_ClearFlag_CM(USART_TypeDef *USARTx) 02752 { 02753 WRITE_REG(USARTx->ICR, USART_ICR_CMCF); 02754 } 02755 02756 /** 02757 * @brief Clear Wake Up from stop mode Flag 02758 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 02759 * Wake-up from Stop mode feature is supported by the USARTx instance. 02760 * @rmtoll ICR WUCF LL_USART_ClearFlag_WKUP 02761 * @param USARTx USART Instance 02762 * @retval None 02763 */ 02764 __STATIC_INLINE void LL_USART_ClearFlag_WKUP(USART_TypeDef *USARTx) 02765 { 02766 WRITE_REG(USARTx->ICR, USART_ICR_WUCF); 02767 } 02768 02769 /** 02770 * @} 02771 */ 02772 02773 /** @defgroup USART_LL_EF_IT_Management IT_Management 02774 * @{ 02775 */ 02776 02777 /** 02778 * @brief Enable IDLE Interrupt 02779 * @rmtoll CR1 IDLEIE LL_USART_EnableIT_IDLE 02780 * @param USARTx USART Instance 02781 * @retval None 02782 */ 02783 __STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx) 02784 { 02785 SET_BIT(USARTx->CR1, USART_CR1_IDLEIE); 02786 } 02787 02788 /** 02789 * @brief Enable RX Not Empty Interrupt 02790 * @rmtoll CR1 RXNEIE LL_USART_EnableIT_RXNE 02791 * @param USARTx USART Instance 02792 * @retval None 02793 */ 02794 __STATIC_INLINE void LL_USART_EnableIT_RXNE(USART_TypeDef *USARTx) 02795 { 02796 SET_BIT(USARTx->CR1, USART_CR1_RXNEIE); 02797 } 02798 02799 /** 02800 * @brief Enable Transmission Complete Interrupt 02801 * @rmtoll CR1 TCIE LL_USART_EnableIT_TC 02802 * @param USARTx USART Instance 02803 * @retval None 02804 */ 02805 __STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx) 02806 { 02807 SET_BIT(USARTx->CR1, USART_CR1_TCIE); 02808 } 02809 02810 /** 02811 * @brief Enable TX Empty Interrupt 02812 * @rmtoll CR1 TXEIE LL_USART_EnableIT_TXE 02813 * @param USARTx USART Instance 02814 * @retval None 02815 */ 02816 __STATIC_INLINE void LL_USART_EnableIT_TXE(USART_TypeDef *USARTx) 02817 { 02818 SET_BIT(USARTx->CR1, USART_CR1_TXEIE); 02819 } 02820 02821 /** 02822 * @brief Enable Parity Error Interrupt 02823 * @rmtoll CR1 PEIE LL_USART_EnableIT_PE 02824 * @param USARTx USART Instance 02825 * @retval None 02826 */ 02827 __STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx) 02828 { 02829 SET_BIT(USARTx->CR1, USART_CR1_PEIE); 02830 } 02831 02832 /** 02833 * @brief Enable Character Match Interrupt 02834 * @rmtoll CR1 CMIE LL_USART_EnableIT_CM 02835 * @param USARTx USART Instance 02836 * @retval None 02837 */ 02838 __STATIC_INLINE void LL_USART_EnableIT_CM(USART_TypeDef *USARTx) 02839 { 02840 SET_BIT(USARTx->CR1, USART_CR1_CMIE); 02841 } 02842 02843 /** 02844 * @brief Enable Receiver Timeout Interrupt 02845 * @rmtoll CR1 RTOIE LL_USART_EnableIT_RTO 02846 * @param USARTx USART Instance 02847 * @retval None 02848 */ 02849 __STATIC_INLINE void LL_USART_EnableIT_RTO(USART_TypeDef *USARTx) 02850 { 02851 SET_BIT(USARTx->CR1, USART_CR1_RTOIE); 02852 } 02853 02854 /** 02855 * @brief Enable End Of Block Interrupt 02856 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 02857 * Smartcard feature is supported by the USARTx instance. 02858 * @rmtoll CR1 EOBIE LL_USART_EnableIT_EOB 02859 * @param USARTx USART Instance 02860 * @retval None 02861 */ 02862 __STATIC_INLINE void LL_USART_EnableIT_EOB(USART_TypeDef *USARTx) 02863 { 02864 SET_BIT(USARTx->CR1, USART_CR1_EOBIE); 02865 } 02866 02867 /** 02868 * @brief Enable LIN Break Detection Interrupt 02869 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 02870 * LIN feature is supported by the USARTx instance. 02871 * @rmtoll CR2 LBDIE LL_USART_EnableIT_LBD 02872 * @param USARTx USART Instance 02873 * @retval None 02874 */ 02875 __STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx) 02876 { 02877 SET_BIT(USARTx->CR2, USART_CR2_LBDIE); 02878 } 02879 02880 /** 02881 * @brief Enable Error Interrupt 02882 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing 02883 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register). 02884 * 0: Interrupt is inhibited 02885 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register. 02886 * @rmtoll CR3 EIE LL_USART_EnableIT_ERROR 02887 * @param USARTx USART Instance 02888 * @retval None 02889 */ 02890 __STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx) 02891 { 02892 SET_BIT(USARTx->CR3, USART_CR3_EIE); 02893 } 02894 02895 /** 02896 * @brief Enable CTS Interrupt 02897 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 02898 * Hardware Flow control feature is supported by the USARTx instance. 02899 * @rmtoll CR3 CTSIE LL_USART_EnableIT_CTS 02900 * @param USARTx USART Instance 02901 * @retval None 02902 */ 02903 __STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx) 02904 { 02905 SET_BIT(USARTx->CR3, USART_CR3_CTSIE); 02906 } 02907 02908 /** 02909 * @brief Enable WakeUp from Stop Mode Interrupt 02910 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 02911 * Wake-up from Stop mode feature is supported by the USARTx instance. 02912 * @rmtoll CR3 WUFIE LL_USART_EnableIT_WKUP 02913 * @param USARTx USART Instance 02914 * @retval None 02915 */ 02916 __STATIC_INLINE void LL_USART_EnableIT_WKUP(USART_TypeDef *USARTx) 02917 { 02918 SET_BIT(USARTx->CR3, USART_CR3_WUFIE); 02919 } 02920 02921 /** 02922 * @brief Disable IDLE Interrupt 02923 * @rmtoll CR1 IDLEIE LL_USART_DisableIT_IDLE 02924 * @param USARTx USART Instance 02925 * @retval None 02926 */ 02927 __STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx) 02928 { 02929 CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE); 02930 } 02931 02932 /** 02933 * @brief Disable RX Not Empty Interrupt 02934 * @rmtoll CR1 RXNEIE LL_USART_DisableIT_RXNE 02935 * @param USARTx USART Instance 02936 * @retval None 02937 */ 02938 __STATIC_INLINE void LL_USART_DisableIT_RXNE(USART_TypeDef *USARTx) 02939 { 02940 CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE); 02941 } 02942 02943 /** 02944 * @brief Disable Transmission Complete Interrupt 02945 * @rmtoll CR1 TCIE LL_USART_DisableIT_TC 02946 * @param USARTx USART Instance 02947 * @retval None 02948 */ 02949 __STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx) 02950 { 02951 CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE); 02952 } 02953 02954 /** 02955 * @brief Disable TX Empty Interrupt 02956 * @rmtoll CR1 TXEIE LL_USART_DisableIT_TXE 02957 * @param USARTx USART Instance 02958 * @retval None 02959 */ 02960 __STATIC_INLINE void LL_USART_DisableIT_TXE(USART_TypeDef *USARTx) 02961 { 02962 CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE); 02963 } 02964 02965 /** 02966 * @brief Disable Parity Error Interrupt 02967 * @rmtoll CR1 PEIE LL_USART_DisableIT_PE 02968 * @param USARTx USART Instance 02969 * @retval None 02970 */ 02971 __STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx) 02972 { 02973 CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE); 02974 } 02975 02976 /** 02977 * @brief Disable Character Match Interrupt 02978 * @rmtoll CR1 CMIE LL_USART_DisableIT_CM 02979 * @param USARTx USART Instance 02980 * @retval None 02981 */ 02982 __STATIC_INLINE void LL_USART_DisableIT_CM(USART_TypeDef *USARTx) 02983 { 02984 CLEAR_BIT(USARTx->CR1, USART_CR1_CMIE); 02985 } 02986 02987 /** 02988 * @brief Disable Receiver Timeout Interrupt 02989 * @rmtoll CR1 RTOIE LL_USART_DisableIT_RTO 02990 * @param USARTx USART Instance 02991 * @retval None 02992 */ 02993 __STATIC_INLINE void LL_USART_DisableIT_RTO(USART_TypeDef *USARTx) 02994 { 02995 CLEAR_BIT(USARTx->CR1, USART_CR1_RTOIE); 02996 } 02997 02998 /** 02999 * @brief Disable End Of Block Interrupt 03000 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 03001 * Smartcard feature is supported by the USARTx instance. 03002 * @rmtoll CR1 EOBIE LL_USART_DisableIT_EOB 03003 * @param USARTx USART Instance 03004 * @retval None 03005 */ 03006 __STATIC_INLINE void LL_USART_DisableIT_EOB(USART_TypeDef *USARTx) 03007 { 03008 CLEAR_BIT(USARTx->CR1, USART_CR1_EOBIE); 03009 } 03010 03011 /** 03012 * @brief Disable LIN Break Detection Interrupt 03013 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 03014 * LIN feature is supported by the USARTx instance. 03015 * @rmtoll CR2 LBDIE LL_USART_DisableIT_LBD 03016 * @param USARTx USART Instance 03017 * @retval None 03018 */ 03019 __STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx) 03020 { 03021 CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE); 03022 } 03023 03024 /** 03025 * @brief Disable Error Interrupt 03026 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing 03027 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register). 03028 * 0: Interrupt is inhibited 03029 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register. 03030 * @rmtoll CR3 EIE LL_USART_DisableIT_ERROR 03031 * @param USARTx USART Instance 03032 * @retval None 03033 */ 03034 __STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx) 03035 { 03036 CLEAR_BIT(USARTx->CR3, USART_CR3_EIE); 03037 } 03038 03039 /** 03040 * @brief Disable CTS Interrupt 03041 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 03042 * Hardware Flow control feature is supported by the USARTx instance. 03043 * @rmtoll CR3 CTSIE LL_USART_DisableIT_CTS 03044 * @param USARTx USART Instance 03045 * @retval None 03046 */ 03047 __STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx) 03048 { 03049 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE); 03050 } 03051 03052 /** 03053 * @brief Disable WakeUp from Stop Mode Interrupt 03054 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 03055 * Wake-up from Stop mode feature is supported by the USARTx instance. 03056 * @rmtoll CR3 WUFIE LL_USART_DisableIT_WKUP 03057 * @param USARTx USART Instance 03058 * @retval None 03059 */ 03060 __STATIC_INLINE void LL_USART_DisableIT_WKUP(USART_TypeDef *USARTx) 03061 { 03062 CLEAR_BIT(USARTx->CR3, USART_CR3_WUFIE); 03063 } 03064 03065 /** 03066 * @brief Check if the USART IDLE Interrupt source is enabled or disabled. 03067 * @rmtoll CR1 IDLEIE LL_USART_IsEnabledIT_IDLE 03068 * @param USARTx USART Instance 03069 * @retval State of bit (1 or 0). 03070 */ 03071 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(USART_TypeDef *USARTx) 03072 { 03073 return (READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE)); 03074 } 03075 03076 /** 03077 * @brief Check if the USART RX Not Empty Interrupt is enabled or disabled. 03078 * @rmtoll CR1 RXNEIE LL_USART_IsEnabledIT_RXNE 03079 * @param USARTx USART Instance 03080 * @retval State of bit (1 or 0). 03081 */ 03082 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE(USART_TypeDef *USARTx) 03083 { 03084 return (READ_BIT(USARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE)); 03085 } 03086 03087 /** 03088 * @brief Check if the USART Transmission Complete Interrupt is enabled or disabled. 03089 * @rmtoll CR1 TCIE LL_USART_IsEnabledIT_TC 03090 * @param USARTx USART Instance 03091 * @retval State of bit (1 or 0). 03092 */ 03093 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(USART_TypeDef *USARTx) 03094 { 03095 return (READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE)); 03096 } 03097 03098 /** 03099 * @brief Check if the USART TX Empty Interrupt is enabled or disabled. 03100 * @rmtoll CR1 TXEIE LL_USART_IsEnabledIT_TXE 03101 * @param USARTx USART Instance 03102 * @retval State of bit (1 or 0). 03103 */ 03104 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE(USART_TypeDef *USARTx) 03105 { 03106 return (READ_BIT(USARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE)); 03107 } 03108 03109 /** 03110 * @brief Check if the USART Parity Error Interrupt is enabled or disabled. 03111 * @rmtoll CR1 PEIE LL_USART_IsEnabledIT_PE 03112 * @param USARTx USART Instance 03113 * @retval State of bit (1 or 0). 03114 */ 03115 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(USART_TypeDef *USARTx) 03116 { 03117 return (READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE)); 03118 } 03119 03120 /** 03121 * @brief Check if the USART Character Match Interrupt is enabled or disabled. 03122 * @rmtoll CR1 CMIE LL_USART_IsEnabledIT_CM 03123 * @param USARTx USART Instance 03124 * @retval State of bit (1 or 0). 03125 */ 03126 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CM(USART_TypeDef *USARTx) 03127 { 03128 return (READ_BIT(USARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE)); 03129 } 03130 03131 /** 03132 * @brief Check if the USART Receiver Timeout Interrupt is enabled or disabled. 03133 * @rmtoll CR1 RTOIE LL_USART_IsEnabledIT_RTO 03134 * @param USARTx USART Instance 03135 * @retval State of bit (1 or 0). 03136 */ 03137 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RTO(USART_TypeDef *USARTx) 03138 { 03139 return (READ_BIT(USARTx->CR1, USART_CR1_RTOIE) == (USART_CR1_RTOIE)); 03140 } 03141 03142 /** 03143 * @brief Check if the USART End Of Block Interrupt is enabled or disabled. 03144 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 03145 * Smartcard feature is supported by the USARTx instance. 03146 * @rmtoll CR1 EOBIE LL_USART_IsEnabledIT_EOB 03147 * @param USARTx USART Instance 03148 * @retval State of bit (1 or 0). 03149 */ 03150 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_EOB(USART_TypeDef *USARTx) 03151 { 03152 return (READ_BIT(USARTx->CR1, USART_CR1_EOBIE) == (USART_CR1_EOBIE)); 03153 } 03154 03155 /** 03156 * @brief Check if the USART LIN Break Detection Interrupt is enabled or disabled. 03157 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not 03158 * LIN feature is supported by the USARTx instance. 03159 * @rmtoll CR2 LBDIE LL_USART_IsEnabledIT_LBD 03160 * @param USARTx USART Instance 03161 * @retval State of bit (1 or 0). 03162 */ 03163 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(USART_TypeDef *USARTx) 03164 { 03165 return (READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE)); 03166 } 03167 03168 /** 03169 * @brief Check if the USART Error Interrupt is enabled or disabled. 03170 * @rmtoll CR3 EIE LL_USART_IsEnabledIT_ERROR 03171 * @param USARTx USART Instance 03172 * @retval State of bit (1 or 0). 03173 */ 03174 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(USART_TypeDef *USARTx) 03175 { 03176 return (READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE)); 03177 } 03178 03179 /** 03180 * @brief Check if the USART CTS Interrupt is enabled or disabled. 03181 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not 03182 * Hardware Flow control feature is supported by the USARTx instance. 03183 * @rmtoll CR3 CTSIE LL_USART_IsEnabledIT_CTS 03184 * @param USARTx USART Instance 03185 * @retval State of bit (1 or 0). 03186 */ 03187 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(USART_TypeDef *USARTx) 03188 { 03189 return (READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE)); 03190 } 03191 03192 /** 03193 * @brief Check if the USART WakeUp from Stop Mode Interrupt is enabled or disabled. 03194 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not 03195 * Wake-up from Stop mode feature is supported by the USARTx instance. 03196 * @rmtoll CR3 WUFIE LL_USART_IsEnabledIT_WKUP 03197 * @param USARTx USART Instance 03198 * @retval State of bit (1 or 0). 03199 */ 03200 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_WKUP(USART_TypeDef *USARTx) 03201 { 03202 return (READ_BIT(USARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE)); 03203 } 03204 03205 /** 03206 * @} 03207 */ 03208 03209 /** @defgroup USART_LL_EF_DMA_Management DMA_Management 03210 * @{ 03211 */ 03212 03213 /** 03214 * @brief Enable DMA Mode for reception 03215 * @rmtoll CR3 DMAR LL_USART_EnableDMAReq_RX 03216 * @param USARTx USART Instance 03217 * @retval None 03218 */ 03219 __STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx) 03220 { 03221 SET_BIT(USARTx->CR3, USART_CR3_DMAR); 03222 } 03223 03224 /** 03225 * @brief Disable DMA Mode for reception 03226 * @rmtoll CR3 DMAR LL_USART_DisableDMAReq_RX 03227 * @param USARTx USART Instance 03228 * @retval None 03229 */ 03230 __STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx) 03231 { 03232 CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR); 03233 } 03234 03235 /** 03236 * @brief Check if DMA Mode is enabled for reception 03237 * @rmtoll CR3 DMAR LL_USART_IsEnabledDMAReq_RX 03238 * @param USARTx USART Instance 03239 * @retval State of bit (1 or 0). 03240 */ 03241 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(USART_TypeDef *USARTx) 03242 { 03243 return (READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR)); 03244 } 03245 03246 /** 03247 * @brief Enable DMA Mode for transmission 03248 * @rmtoll CR3 DMAT LL_USART_EnableDMAReq_TX 03249 * @param USARTx USART Instance 03250 * @retval None 03251 */ 03252 __STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx) 03253 { 03254 SET_BIT(USARTx->CR3, USART_CR3_DMAT); 03255 } 03256 03257 /** 03258 * @brief Disable DMA Mode for transmission 03259 * @rmtoll CR3 DMAT LL_USART_DisableDMAReq_TX 03260 * @param USARTx USART Instance 03261 * @retval None 03262 */ 03263 __STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx) 03264 { 03265 CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT); 03266 } 03267 03268 /** 03269 * @brief Check if DMA Mode is enabled for transmission 03270 * @rmtoll CR3 DMAT LL_USART_IsEnabledDMAReq_TX 03271 * @param USARTx USART Instance 03272 * @retval State of bit (1 or 0). 03273 */ 03274 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(USART_TypeDef *USARTx) 03275 { 03276 return (READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT)); 03277 } 03278 03279 /** 03280 * @brief Enable DMA Disabling on Reception Error 03281 * @rmtoll CR3 DDRE LL_USART_EnableDMADeactOnRxErr 03282 * @param USARTx USART Instance 03283 * @retval None 03284 */ 03285 __STATIC_INLINE void LL_USART_EnableDMADeactOnRxErr(USART_TypeDef *USARTx) 03286 { 03287 SET_BIT(USARTx->CR3, USART_CR3_DDRE); 03288 } 03289 03290 /** 03291 * @brief Disable DMA Disabling on Reception Error 03292 * @rmtoll CR3 DDRE LL_USART_DisableDMADeactOnRxErr 03293 * @param USARTx USART Instance 03294 * @retval None 03295 */ 03296 __STATIC_INLINE void LL_USART_DisableDMADeactOnRxErr(USART_TypeDef *USARTx) 03297 { 03298 CLEAR_BIT(USARTx->CR3, USART_CR3_DDRE); 03299 } 03300 03301 /** 03302 * @brief Indicate if DMA Disabling on Reception Error is disabled 03303 * @rmtoll CR3 DDRE LL_USART_IsEnabledDMADeactOnRxErr 03304 * @param USARTx USART Instance 03305 * @retval State of bit (1 or 0). 03306 */ 03307 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMADeactOnRxErr(USART_TypeDef *USARTx) 03308 { 03309 return (READ_BIT(USARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE)); 03310 } 03311 03312 /** 03313 * @brief Get the data register address used for DMA transfer 03314 * @rmtoll RDR RDR LL_USART_DMA_GetRegAddr\n 03315 * @rmtoll TDR TDR LL_USART_DMA_GetRegAddr 03316 * @param USARTx USART Instance 03317 * @param Direction This parameter can be one of the following values: 03318 * @arg @ref LL_USART_DMA_REG_DATA_TRANSMIT 03319 * @arg @ref LL_USART_DMA_REG_DATA_RECEIVE 03320 * @retval Address of data register 03321 */ 03322 __STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(USART_TypeDef *USARTx, uint32_t Direction) 03323 { 03324 register uint32_t data_reg_addr = 0; 03325 03326 if (Direction == LL_USART_DMA_REG_DATA_TRANSMIT) 03327 { 03328 /* return address of TDR register */ 03329 data_reg_addr = (uint32_t)&(USARTx->TDR); 03330 } 03331 else 03332 { 03333 /* return address of RDR register */ 03334 data_reg_addr = (uint32_t)&(USARTx->RDR); 03335 } 03336 03337 return data_reg_addr; 03338 } 03339 /** 03340 * @} 03341 */ 03342 03343 /** @defgroup USART_LL_EF_Data_Management Data_Management 03344 * @{ 03345 */ 03346 03347 /** 03348 * @brief Read Receiver Data register (Receive Data value, 8 bits) 03349 * @rmtoll RDR RDR LL_USART_ReceiveData8 03350 * @param USARTx USART Instance 03351 * @retval 0..0xFF 03352 */ 03353 __STATIC_INLINE uint8_t LL_USART_ReceiveData8(USART_TypeDef *USARTx) 03354 { 03355 return (uint8_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR)); 03356 } 03357 03358 /** 03359 * @brief Read Receiver Data register (Receive Data value, 9 bits) 03360 * @rmtoll RDR RDR LL_USART_ReceiveData9 03361 * @param USARTx USART Instance 03362 * @retval 0..0x1FF 03363 */ 03364 __STATIC_INLINE uint16_t LL_USART_ReceiveData9(USART_TypeDef *USARTx) 03365 { 03366 return (uint16_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR)); 03367 } 03368 03369 /** 03370 * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits) 03371 * @rmtoll TDR TDR LL_USART_TransmitData8 03372 * @param USARTx USART Instance 03373 * @param Value 0..0xFF 03374 * @retval None 03375 */ 03376 __STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value) 03377 { 03378 USARTx->TDR = Value; 03379 } 03380 03381 /** 03382 * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits) 03383 * @rmtoll TDR TDR LL_USART_TransmitData9 03384 * @param USARTx USART Instance 03385 * @param Value 0..0x1FF 03386 * @retval None 03387 */ 03388 __STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value) 03389 { 03390 USARTx->TDR = Value & 0x1FF; 03391 } 03392 03393 /** 03394 * @} 03395 */ 03396 03397 /** @defgroup USART_LL_EF_Execution Execution 03398 * @{ 03399 */ 03400 03401 /** 03402 * @brief Request an Automatic Baud Rate measurement on next received data frame 03403 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not 03404 * Auto Baud Rate detection feature is supported by the USARTx instance. 03405 * @rmtoll RQR ABRRQ LL_USART_RequestAutoBaudRate 03406 * @param USARTx USART Instance 03407 * @retval None 03408 */ 03409 __STATIC_INLINE void LL_USART_RequestAutoBaudRate(USART_TypeDef *USARTx) 03410 { 03411 SET_BIT(USARTx->RQR, USART_RQR_ABRRQ); 03412 } 03413 03414 /** 03415 * @brief Request Break sending 03416 * @rmtoll RQR SBKRQ LL_USART_RequestBreakSending 03417 * @param USARTx USART Instance 03418 * @retval None 03419 */ 03420 __STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx) 03421 { 03422 SET_BIT(USARTx->RQR, USART_RQR_SBKRQ); 03423 } 03424 03425 /** 03426 * @brief Put USART in mute mode and set the RWU flag 03427 * @rmtoll RQR MMRQ LL_USART_RequestEnterMuteMode 03428 * @param USARTx USART Instance 03429 * @retval None 03430 */ 03431 __STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx) 03432 { 03433 SET_BIT(USARTx->RQR, USART_RQR_MMRQ); 03434 } 03435 03436 /** 03437 * @brief Request a Receive Data flush 03438 * @rmtoll RQR RXFRQ LL_USART_RequestRxDataFlush 03439 * @param USARTx USART Instance 03440 * @retval None 03441 */ 03442 __STATIC_INLINE void LL_USART_RequestRxDataFlush(USART_TypeDef *USARTx) 03443 { 03444 SET_BIT(USARTx->RQR, USART_RQR_RXFRQ); 03445 } 03446 03447 /** 03448 * @brief Request a Transmit data flush 03449 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not 03450 * Smartcard feature is supported by the USARTx instance. 03451 * @rmtoll RQR TXFRQ LL_USART_RequestTxDataFlush 03452 * @param USARTx USART Instance 03453 * @retval None 03454 */ 03455 __STATIC_INLINE void LL_USART_RequestTxDataFlush(USART_TypeDef *USARTx) 03456 { 03457 SET_BIT(USARTx->RQR, USART_RQR_TXFRQ); 03458 } 03459 03460 /** 03461 * @} 03462 */ 03463 03464 /** 03465 * @} 03466 */ 03467 03468 /** 03469 * @} 03470 */ 03471 03472 #endif /* USART1 || USART2 || USART3 || UART4 || UART5 */ 03473 03474 /** 03475 * @} 03476 */ 03477 03478 #ifdef __cplusplus 03479 } 03480 #endif 03481 03482 #endif /* __STM32L4xx_LL_USART_H */ 03483 03484 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 03485
Generated on Tue Jul 12 2022 11:35:17 by
