inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
NYX 0:85b3fd62ea1a 1 /**
NYX 0:85b3fd62ea1a 2 ******************************************************************************
NYX 0:85b3fd62ea1a 3 * @file stm32f4xx_ll_usart.h
NYX 0:85b3fd62ea1a 4 * @author MCD Application Team
NYX 0:85b3fd62ea1a 5 * @version V1.7.1
NYX 0:85b3fd62ea1a 6 * @date 14-April-2017
NYX 0:85b3fd62ea1a 7 * @brief Header file of USART LL module.
NYX 0:85b3fd62ea1a 8 ******************************************************************************
NYX 0:85b3fd62ea1a 9 * @attention
NYX 0:85b3fd62ea1a 10 *
NYX 0:85b3fd62ea1a 11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
NYX 0:85b3fd62ea1a 12 *
NYX 0:85b3fd62ea1a 13 * Redistribution and use in source and binary forms, with or without modification,
NYX 0:85b3fd62ea1a 14 * are permitted provided that the following conditions are met:
NYX 0:85b3fd62ea1a 15 * 1. Redistributions of source code must retain the above copyright notice,
NYX 0:85b3fd62ea1a 16 * this list of conditions and the following disclaimer.
NYX 0:85b3fd62ea1a 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
NYX 0:85b3fd62ea1a 18 * this list of conditions and the following disclaimer in the documentation
NYX 0:85b3fd62ea1a 19 * and/or other materials provided with the distribution.
NYX 0:85b3fd62ea1a 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
NYX 0:85b3fd62ea1a 21 * may be used to endorse or promote products derived from this software
NYX 0:85b3fd62ea1a 22 * without specific prior written permission.
NYX 0:85b3fd62ea1a 23 *
NYX 0:85b3fd62ea1a 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
NYX 0:85b3fd62ea1a 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
NYX 0:85b3fd62ea1a 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
NYX 0:85b3fd62ea1a 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
NYX 0:85b3fd62ea1a 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
NYX 0:85b3fd62ea1a 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
NYX 0:85b3fd62ea1a 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
NYX 0:85b3fd62ea1a 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
NYX 0:85b3fd62ea1a 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
NYX 0:85b3fd62ea1a 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NYX 0:85b3fd62ea1a 34 *
NYX 0:85b3fd62ea1a 35 ******************************************************************************
NYX 0:85b3fd62ea1a 36 */
NYX 0:85b3fd62ea1a 37
NYX 0:85b3fd62ea1a 38 /* Define to prevent recursive inclusion -------------------------------------*/
NYX 0:85b3fd62ea1a 39 #ifndef __STM32F4xx_LL_USART_H
NYX 0:85b3fd62ea1a 40 #define __STM32F4xx_LL_USART_H
NYX 0:85b3fd62ea1a 41
NYX 0:85b3fd62ea1a 42 #ifdef __cplusplus
NYX 0:85b3fd62ea1a 43 extern "C" {
NYX 0:85b3fd62ea1a 44 #endif
NYX 0:85b3fd62ea1a 45
NYX 0:85b3fd62ea1a 46 /* Includes ------------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 47 #include "stm32f4xx.h"
NYX 0:85b3fd62ea1a 48
NYX 0:85b3fd62ea1a 49 /** @addtogroup STM32F4xx_LL_Driver
NYX 0:85b3fd62ea1a 50 * @{
NYX 0:85b3fd62ea1a 51 */
NYX 0:85b3fd62ea1a 52
NYX 0:85b3fd62ea1a 53 #if defined (USART1) || defined (USART2) || defined (USART3) || defined (USART6) || defined (UART4) || defined (UART5) || defined (UART7) || defined (UART8) || defined (UART9) || defined (UART10)
NYX 0:85b3fd62ea1a 54
NYX 0:85b3fd62ea1a 55 /** @defgroup USART_LL USART
NYX 0:85b3fd62ea1a 56 * @{
NYX 0:85b3fd62ea1a 57 */
NYX 0:85b3fd62ea1a 58
NYX 0:85b3fd62ea1a 59 /* Private types -------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 60 /* Private variables ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 61
NYX 0:85b3fd62ea1a 62 /* Private constants ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 63 /** @defgroup USART_LL_Private_Constants USART Private Constants
NYX 0:85b3fd62ea1a 64 * @{
NYX 0:85b3fd62ea1a 65 */
NYX 0:85b3fd62ea1a 66
NYX 0:85b3fd62ea1a 67 /* Defines used for the bit position in the register and perform offsets*/
NYX 0:85b3fd62ea1a 68 #define USART_POSITION_GTPR_GT USART_GTPR_GT_Pos
NYX 0:85b3fd62ea1a 69 /**
NYX 0:85b3fd62ea1a 70 * @}
NYX 0:85b3fd62ea1a 71 */
NYX 0:85b3fd62ea1a 72
NYX 0:85b3fd62ea1a 73 /* Private macros ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 74 #if defined(USE_FULL_LL_DRIVER)
NYX 0:85b3fd62ea1a 75 /** @defgroup USART_LL_Private_Macros USART Private Macros
NYX 0:85b3fd62ea1a 76 * @{
NYX 0:85b3fd62ea1a 77 */
NYX 0:85b3fd62ea1a 78 /**
NYX 0:85b3fd62ea1a 79 * @}
NYX 0:85b3fd62ea1a 80 */
NYX 0:85b3fd62ea1a 81 #endif /*USE_FULL_LL_DRIVER*/
NYX 0:85b3fd62ea1a 82
NYX 0:85b3fd62ea1a 83 /* Exported types ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 84 #if defined(USE_FULL_LL_DRIVER)
NYX 0:85b3fd62ea1a 85 /** @defgroup USART_LL_ES_INIT USART Exported Init structures
NYX 0:85b3fd62ea1a 86 * @{
NYX 0:85b3fd62ea1a 87 */
NYX 0:85b3fd62ea1a 88
NYX 0:85b3fd62ea1a 89 /**
NYX 0:85b3fd62ea1a 90 * @brief LL USART Init Structure definition
NYX 0:85b3fd62ea1a 91 */
NYX 0:85b3fd62ea1a 92 typedef struct
NYX 0:85b3fd62ea1a 93 {
NYX 0:85b3fd62ea1a 94 uint32_t BaudRate; /*!< This field defines expected Usart communication baud rate.
NYX 0:85b3fd62ea1a 95
NYX 0:85b3fd62ea1a 96 This feature can be modified afterwards using unitary function @ref LL_USART_SetBaudRate().*/
NYX 0:85b3fd62ea1a 97
NYX 0:85b3fd62ea1a 98 uint32_t DataWidth; /*!< Specifies the number of data bits transmitted or received in a frame.
NYX 0:85b3fd62ea1a 99 This parameter can be a value of @ref USART_LL_EC_DATAWIDTH.
NYX 0:85b3fd62ea1a 100
NYX 0:85b3fd62ea1a 101 This feature can be modified afterwards using unitary function @ref LL_USART_SetDataWidth().*/
NYX 0:85b3fd62ea1a 102
NYX 0:85b3fd62ea1a 103 uint32_t StopBits; /*!< Specifies the number of stop bits transmitted.
NYX 0:85b3fd62ea1a 104 This parameter can be a value of @ref USART_LL_EC_STOPBITS.
NYX 0:85b3fd62ea1a 105
NYX 0:85b3fd62ea1a 106 This feature can be modified afterwards using unitary function @ref LL_USART_SetStopBitsLength().*/
NYX 0:85b3fd62ea1a 107
NYX 0:85b3fd62ea1a 108 uint32_t Parity; /*!< Specifies the parity mode.
NYX 0:85b3fd62ea1a 109 This parameter can be a value of @ref USART_LL_EC_PARITY.
NYX 0:85b3fd62ea1a 110
NYX 0:85b3fd62ea1a 111 This feature can be modified afterwards using unitary function @ref LL_USART_SetParity().*/
NYX 0:85b3fd62ea1a 112
NYX 0:85b3fd62ea1a 113 uint32_t TransferDirection; /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled.
NYX 0:85b3fd62ea1a 114 This parameter can be a value of @ref USART_LL_EC_DIRECTION.
NYX 0:85b3fd62ea1a 115
NYX 0:85b3fd62ea1a 116 This feature can be modified afterwards using unitary function @ref LL_USART_SetTransferDirection().*/
NYX 0:85b3fd62ea1a 117
NYX 0:85b3fd62ea1a 118 uint32_t HardwareFlowControl; /*!< Specifies whether the hardware flow control mode is enabled or disabled.
NYX 0:85b3fd62ea1a 119 This parameter can be a value of @ref USART_LL_EC_HWCONTROL.
NYX 0:85b3fd62ea1a 120
NYX 0:85b3fd62ea1a 121 This feature can be modified afterwards using unitary function @ref LL_USART_SetHWFlowCtrl().*/
NYX 0:85b3fd62ea1a 122
NYX 0:85b3fd62ea1a 123 uint32_t OverSampling; /*!< Specifies whether USART oversampling mode is 16 or 8.
NYX 0:85b3fd62ea1a 124 This parameter can be a value of @ref USART_LL_EC_OVERSAMPLING.
NYX 0:85b3fd62ea1a 125
NYX 0:85b3fd62ea1a 126 This feature can be modified afterwards using unitary function @ref LL_USART_SetOverSampling().*/
NYX 0:85b3fd62ea1a 127
NYX 0:85b3fd62ea1a 128 } LL_USART_InitTypeDef;
NYX 0:85b3fd62ea1a 129
NYX 0:85b3fd62ea1a 130 /**
NYX 0:85b3fd62ea1a 131 * @brief LL USART Clock Init Structure definition
NYX 0:85b3fd62ea1a 132 */
NYX 0:85b3fd62ea1a 133 typedef struct
NYX 0:85b3fd62ea1a 134 {
NYX 0:85b3fd62ea1a 135 uint32_t ClockOutput; /*!< Specifies whether the USART clock is enabled or disabled.
NYX 0:85b3fd62ea1a 136 This parameter can be a value of @ref USART_LL_EC_CLOCK.
NYX 0:85b3fd62ea1a 137
NYX 0:85b3fd62ea1a 138 USART HW configuration can be modified afterwards using unitary functions
NYX 0:85b3fd62ea1a 139 @ref LL_USART_EnableSCLKOutput() or @ref LL_USART_DisableSCLKOutput().
NYX 0:85b3fd62ea1a 140 For more details, refer to description of this function. */
NYX 0:85b3fd62ea1a 141
NYX 0:85b3fd62ea1a 142 uint32_t ClockPolarity; /*!< Specifies the steady state of the serial clock.
NYX 0:85b3fd62ea1a 143 This parameter can be a value of @ref USART_LL_EC_POLARITY.
NYX 0:85b3fd62ea1a 144
NYX 0:85b3fd62ea1a 145 USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPolarity().
NYX 0:85b3fd62ea1a 146 For more details, refer to description of this function. */
NYX 0:85b3fd62ea1a 147
NYX 0:85b3fd62ea1a 148 uint32_t ClockPhase; /*!< Specifies the clock transition on which the bit capture is made.
NYX 0:85b3fd62ea1a 149 This parameter can be a value of @ref USART_LL_EC_PHASE.
NYX 0:85b3fd62ea1a 150
NYX 0:85b3fd62ea1a 151 USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetClockPhase().
NYX 0:85b3fd62ea1a 152 For more details, refer to description of this function. */
NYX 0:85b3fd62ea1a 153
NYX 0:85b3fd62ea1a 154 uint32_t LastBitClockPulse; /*!< Specifies whether the clock pulse corresponding to the last transmitted
NYX 0:85b3fd62ea1a 155 data bit (MSB) has to be output on the SCLK pin in synchronous mode.
NYX 0:85b3fd62ea1a 156 This parameter can be a value of @ref USART_LL_EC_LASTCLKPULSE.
NYX 0:85b3fd62ea1a 157
NYX 0:85b3fd62ea1a 158 USART HW configuration can be modified afterwards using unitary functions @ref LL_USART_SetLastClkPulseOutput().
NYX 0:85b3fd62ea1a 159 For more details, refer to description of this function. */
NYX 0:85b3fd62ea1a 160
NYX 0:85b3fd62ea1a 161 } LL_USART_ClockInitTypeDef;
NYX 0:85b3fd62ea1a 162
NYX 0:85b3fd62ea1a 163 /**
NYX 0:85b3fd62ea1a 164 * @}
NYX 0:85b3fd62ea1a 165 */
NYX 0:85b3fd62ea1a 166 #endif /* USE_FULL_LL_DRIVER */
NYX 0:85b3fd62ea1a 167
NYX 0:85b3fd62ea1a 168 /* Exported constants --------------------------------------------------------*/
NYX 0:85b3fd62ea1a 169 /** @defgroup USART_LL_Exported_Constants USART Exported Constants
NYX 0:85b3fd62ea1a 170 * @{
NYX 0:85b3fd62ea1a 171 */
NYX 0:85b3fd62ea1a 172
NYX 0:85b3fd62ea1a 173 /** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines
NYX 0:85b3fd62ea1a 174 * @brief Flags defines which can be used with LL_USART_ReadReg function
NYX 0:85b3fd62ea1a 175 * @{
NYX 0:85b3fd62ea1a 176 */
NYX 0:85b3fd62ea1a 177 #define LL_USART_SR_PE USART_SR_PE /*!< Parity error flag */
NYX 0:85b3fd62ea1a 178 #define LL_USART_SR_FE USART_SR_FE /*!< Framing error flag */
NYX 0:85b3fd62ea1a 179 #define LL_USART_SR_NE USART_SR_NE /*!< Noise detected flag */
NYX 0:85b3fd62ea1a 180 #define LL_USART_SR_ORE USART_SR_ORE /*!< Overrun error flag */
NYX 0:85b3fd62ea1a 181 #define LL_USART_SR_IDLE USART_SR_IDLE /*!< Idle line detected flag */
NYX 0:85b3fd62ea1a 182 #define LL_USART_SR_RXNE USART_SR_RXNE /*!< Read data register not empty flag */
NYX 0:85b3fd62ea1a 183 #define LL_USART_SR_TC USART_SR_TC /*!< Transmission complete flag */
NYX 0:85b3fd62ea1a 184 #define LL_USART_SR_TXE USART_SR_TXE /*!< Transmit data register empty flag */
NYX 0:85b3fd62ea1a 185 #define LL_USART_SR_LBD USART_SR_LBD /*!< LIN break detection flag */
NYX 0:85b3fd62ea1a 186 #define LL_USART_SR_CTS USART_SR_CTS /*!< CTS flag */
NYX 0:85b3fd62ea1a 187 /**
NYX 0:85b3fd62ea1a 188 * @}
NYX 0:85b3fd62ea1a 189 */
NYX 0:85b3fd62ea1a 190
NYX 0:85b3fd62ea1a 191 /** @defgroup USART_LL_EC_IT IT Defines
NYX 0:85b3fd62ea1a 192 * @brief IT defines which can be used with LL_USART_ReadReg and LL_USART_WriteReg functions
NYX 0:85b3fd62ea1a 193 * @{
NYX 0:85b3fd62ea1a 194 */
NYX 0:85b3fd62ea1a 195 #define LL_USART_CR1_IDLEIE USART_CR1_IDLEIE /*!< IDLE interrupt enable */
NYX 0:85b3fd62ea1a 196 #define LL_USART_CR1_RXNEIE USART_CR1_RXNEIE /*!< Read data register not empty interrupt enable */
NYX 0:85b3fd62ea1a 197 #define LL_USART_CR1_TCIE USART_CR1_TCIE /*!< Transmission complete interrupt enable */
NYX 0:85b3fd62ea1a 198 #define LL_USART_CR1_TXEIE USART_CR1_TXEIE /*!< Transmit data register empty interrupt enable */
NYX 0:85b3fd62ea1a 199 #define LL_USART_CR1_PEIE USART_CR1_PEIE /*!< Parity error */
NYX 0:85b3fd62ea1a 200 #define LL_USART_CR2_LBDIE USART_CR2_LBDIE /*!< LIN break detection interrupt enable */
NYX 0:85b3fd62ea1a 201 #define LL_USART_CR3_EIE USART_CR3_EIE /*!< Error interrupt enable */
NYX 0:85b3fd62ea1a 202 #define LL_USART_CR3_CTSIE USART_CR3_CTSIE /*!< CTS interrupt enable */
NYX 0:85b3fd62ea1a 203 /**
NYX 0:85b3fd62ea1a 204 * @}
NYX 0:85b3fd62ea1a 205 */
NYX 0:85b3fd62ea1a 206
NYX 0:85b3fd62ea1a 207 /** @defgroup USART_LL_EC_DIRECTION Communication Direction
NYX 0:85b3fd62ea1a 208 * @{
NYX 0:85b3fd62ea1a 209 */
NYX 0:85b3fd62ea1a 210 #define LL_USART_DIRECTION_NONE 0x00000000U /*!< Transmitter and Receiver are disabled */
NYX 0:85b3fd62ea1a 211 #define LL_USART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */
NYX 0:85b3fd62ea1a 212 #define LL_USART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */
NYX 0:85b3fd62ea1a 213 #define LL_USART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */
NYX 0:85b3fd62ea1a 214 /**
NYX 0:85b3fd62ea1a 215 * @}
NYX 0:85b3fd62ea1a 216 */
NYX 0:85b3fd62ea1a 217
NYX 0:85b3fd62ea1a 218 /** @defgroup USART_LL_EC_PARITY Parity Control
NYX 0:85b3fd62ea1a 219 * @{
NYX 0:85b3fd62ea1a 220 */
NYX 0:85b3fd62ea1a 221 #define LL_USART_PARITY_NONE 0x00000000U /*!< Parity control disabled */
NYX 0:85b3fd62ea1a 222 #define LL_USART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */
NYX 0:85b3fd62ea1a 223 #define LL_USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */
NYX 0:85b3fd62ea1a 224 /**
NYX 0:85b3fd62ea1a 225 * @}
NYX 0:85b3fd62ea1a 226 */
NYX 0:85b3fd62ea1a 227
NYX 0:85b3fd62ea1a 228 /** @defgroup USART_LL_EC_WAKEUP Wakeup
NYX 0:85b3fd62ea1a 229 * @{
NYX 0:85b3fd62ea1a 230 */
NYX 0:85b3fd62ea1a 231 #define LL_USART_WAKEUP_IDLELINE 0x00000000U /*!< USART wake up from Mute mode on Idle Line */
NYX 0:85b3fd62ea1a 232 #define LL_USART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< USART wake up from Mute mode on Address Mark */
NYX 0:85b3fd62ea1a 233 /**
NYX 0:85b3fd62ea1a 234 * @}
NYX 0:85b3fd62ea1a 235 */
NYX 0:85b3fd62ea1a 236
NYX 0:85b3fd62ea1a 237 /** @defgroup USART_LL_EC_DATAWIDTH Datawidth
NYX 0:85b3fd62ea1a 238 * @{
NYX 0:85b3fd62ea1a 239 */
NYX 0:85b3fd62ea1a 240 #define LL_USART_DATAWIDTH_8B 0x00000000U /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
NYX 0:85b3fd62ea1a 241 #define LL_USART_DATAWIDTH_9B USART_CR1_M /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
NYX 0:85b3fd62ea1a 242 /**
NYX 0:85b3fd62ea1a 243 * @}
NYX 0:85b3fd62ea1a 244 */
NYX 0:85b3fd62ea1a 245
NYX 0:85b3fd62ea1a 246 /** @defgroup USART_LL_EC_OVERSAMPLING Oversampling
NYX 0:85b3fd62ea1a 247 * @{
NYX 0:85b3fd62ea1a 248 */
NYX 0:85b3fd62ea1a 249 #define LL_USART_OVERSAMPLING_16 0x00000000U /*!< Oversampling by 16 */
NYX 0:85b3fd62ea1a 250 #define LL_USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */
NYX 0:85b3fd62ea1a 251 /**
NYX 0:85b3fd62ea1a 252 * @}
NYX 0:85b3fd62ea1a 253 */
NYX 0:85b3fd62ea1a 254
NYX 0:85b3fd62ea1a 255 #if defined(USE_FULL_LL_DRIVER)
NYX 0:85b3fd62ea1a 256 /** @defgroup USART_LL_EC_CLOCK Clock Signal
NYX 0:85b3fd62ea1a 257 * @{
NYX 0:85b3fd62ea1a 258 */
NYX 0:85b3fd62ea1a 259
NYX 0:85b3fd62ea1a 260 #define LL_USART_CLOCK_DISABLE 0x00000000U /*!< Clock signal not provided */
NYX 0:85b3fd62ea1a 261 #define LL_USART_CLOCK_ENABLE USART_CR2_CLKEN /*!< Clock signal provided */
NYX 0:85b3fd62ea1a 262 /**
NYX 0:85b3fd62ea1a 263 * @}
NYX 0:85b3fd62ea1a 264 */
NYX 0:85b3fd62ea1a 265 #endif /*USE_FULL_LL_DRIVER*/
NYX 0:85b3fd62ea1a 266
NYX 0:85b3fd62ea1a 267 /** @defgroup USART_LL_EC_LASTCLKPULSE Last Clock Pulse
NYX 0:85b3fd62ea1a 268 * @{
NYX 0:85b3fd62ea1a 269 */
NYX 0:85b3fd62ea1a 270 #define LL_USART_LASTCLKPULSE_NO_OUTPUT 0x00000000U /*!< The clock pulse of the last data bit is not output to the SCLK pin */
NYX 0:85b3fd62ea1a 271 #define LL_USART_LASTCLKPULSE_OUTPUT USART_CR2_LBCL /*!< The clock pulse of the last data bit is output to the SCLK pin */
NYX 0:85b3fd62ea1a 272 /**
NYX 0:85b3fd62ea1a 273 * @}
NYX 0:85b3fd62ea1a 274 */
NYX 0:85b3fd62ea1a 275
NYX 0:85b3fd62ea1a 276 /** @defgroup USART_LL_EC_PHASE Clock Phase
NYX 0:85b3fd62ea1a 277 * @{
NYX 0:85b3fd62ea1a 278 */
NYX 0:85b3fd62ea1a 279 #define LL_USART_PHASE_1EDGE 0x00000000U /*!< The first clock transition is the first data capture edge */
NYX 0:85b3fd62ea1a 280 #define LL_USART_PHASE_2EDGE USART_CR2_CPHA /*!< The second clock transition is the first data capture edge */
NYX 0:85b3fd62ea1a 281 /**
NYX 0:85b3fd62ea1a 282 * @}
NYX 0:85b3fd62ea1a 283 */
NYX 0:85b3fd62ea1a 284
NYX 0:85b3fd62ea1a 285 /** @defgroup USART_LL_EC_POLARITY Clock Polarity
NYX 0:85b3fd62ea1a 286 * @{
NYX 0:85b3fd62ea1a 287 */
NYX 0:85b3fd62ea1a 288 #define LL_USART_POLARITY_LOW 0x00000000U /*!< Steady low value on SCLK pin outside transmission window*/
NYX 0:85b3fd62ea1a 289 #define LL_USART_POLARITY_HIGH USART_CR2_CPOL /*!< Steady high value on SCLK pin outside transmission window */
NYX 0:85b3fd62ea1a 290 /**
NYX 0:85b3fd62ea1a 291 * @}
NYX 0:85b3fd62ea1a 292 */
NYX 0:85b3fd62ea1a 293
NYX 0:85b3fd62ea1a 294 /** @defgroup USART_LL_EC_STOPBITS Stop Bits
NYX 0:85b3fd62ea1a 295 * @{
NYX 0:85b3fd62ea1a 296 */
NYX 0:85b3fd62ea1a 297 #define LL_USART_STOPBITS_0_5 USART_CR2_STOP_0 /*!< 0.5 stop bit */
NYX 0:85b3fd62ea1a 298 #define LL_USART_STOPBITS_1 0x00000000U /*!< 1 stop bit */
NYX 0:85b3fd62ea1a 299 #define LL_USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< 1.5 stop bits */
NYX 0:85b3fd62ea1a 300 #define LL_USART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */
NYX 0:85b3fd62ea1a 301 /**
NYX 0:85b3fd62ea1a 302 * @}
NYX 0:85b3fd62ea1a 303 */
NYX 0:85b3fd62ea1a 304
NYX 0:85b3fd62ea1a 305 /** @defgroup USART_LL_EC_HWCONTROL Hardware Control
NYX 0:85b3fd62ea1a 306 * @{
NYX 0:85b3fd62ea1a 307 */
NYX 0:85b3fd62ea1a 308 #define LL_USART_HWCONTROL_NONE 0x00000000U /*!< CTS and RTS hardware flow control disabled */
NYX 0:85b3fd62ea1a 309 #define LL_USART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */
NYX 0:85b3fd62ea1a 310 #define LL_USART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */
NYX 0:85b3fd62ea1a 311 #define LL_USART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */
NYX 0:85b3fd62ea1a 312 /**
NYX 0:85b3fd62ea1a 313 * @}
NYX 0:85b3fd62ea1a 314 */
NYX 0:85b3fd62ea1a 315
NYX 0:85b3fd62ea1a 316 /** @defgroup USART_LL_EC_IRDA_POWER IrDA Power
NYX 0:85b3fd62ea1a 317 * @{
NYX 0:85b3fd62ea1a 318 */
NYX 0:85b3fd62ea1a 319 #define LL_USART_IRDA_POWER_NORMAL 0x00000000U /*!< IrDA normal power mode */
NYX 0:85b3fd62ea1a 320 #define LL_USART_IRDA_POWER_LOW USART_CR3_IRLP /*!< IrDA low power mode */
NYX 0:85b3fd62ea1a 321 /**
NYX 0:85b3fd62ea1a 322 * @}
NYX 0:85b3fd62ea1a 323 */
NYX 0:85b3fd62ea1a 324
NYX 0:85b3fd62ea1a 325 /** @defgroup USART_LL_EC_LINBREAK_DETECT LIN Break Detection Length
NYX 0:85b3fd62ea1a 326 * @{
NYX 0:85b3fd62ea1a 327 */
NYX 0:85b3fd62ea1a 328 #define LL_USART_LINBREAK_DETECT_10B 0x00000000U /*!< 10-bit break detection method selected */
NYX 0:85b3fd62ea1a 329 #define LL_USART_LINBREAK_DETECT_11B USART_CR2_LBDL /*!< 11-bit break detection method selected */
NYX 0:85b3fd62ea1a 330 /**
NYX 0:85b3fd62ea1a 331 * @}
NYX 0:85b3fd62ea1a 332 */
NYX 0:85b3fd62ea1a 333
NYX 0:85b3fd62ea1a 334 /**
NYX 0:85b3fd62ea1a 335 * @}
NYX 0:85b3fd62ea1a 336 */
NYX 0:85b3fd62ea1a 337
NYX 0:85b3fd62ea1a 338 /* Exported macro ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 339 /** @defgroup USART_LL_Exported_Macros USART Exported Macros
NYX 0:85b3fd62ea1a 340 * @{
NYX 0:85b3fd62ea1a 341 */
NYX 0:85b3fd62ea1a 342
NYX 0:85b3fd62ea1a 343 /** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros
NYX 0:85b3fd62ea1a 344 * @{
NYX 0:85b3fd62ea1a 345 */
NYX 0:85b3fd62ea1a 346
NYX 0:85b3fd62ea1a 347 /**
NYX 0:85b3fd62ea1a 348 * @brief Write a value in USART register
NYX 0:85b3fd62ea1a 349 * @param __INSTANCE__ USART Instance
NYX 0:85b3fd62ea1a 350 * @param __REG__ Register to be written
NYX 0:85b3fd62ea1a 351 * @param __VALUE__ Value to be written in the register
NYX 0:85b3fd62ea1a 352 * @retval None
NYX 0:85b3fd62ea1a 353 */
NYX 0:85b3fd62ea1a 354 #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
NYX 0:85b3fd62ea1a 355
NYX 0:85b3fd62ea1a 356 /**
NYX 0:85b3fd62ea1a 357 * @brief Read a value in USART register
NYX 0:85b3fd62ea1a 358 * @param __INSTANCE__ USART Instance
NYX 0:85b3fd62ea1a 359 * @param __REG__ Register to be read
NYX 0:85b3fd62ea1a 360 * @retval Register value
NYX 0:85b3fd62ea1a 361 */
NYX 0:85b3fd62ea1a 362 #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
NYX 0:85b3fd62ea1a 363 /**
NYX 0:85b3fd62ea1a 364 * @}
NYX 0:85b3fd62ea1a 365 */
NYX 0:85b3fd62ea1a 366
NYX 0:85b3fd62ea1a 367 /** @defgroup USART_LL_EM_Exported_Macros_Helper Exported_Macros_Helper
NYX 0:85b3fd62ea1a 368 * @{
NYX 0:85b3fd62ea1a 369 */
NYX 0:85b3fd62ea1a 370
NYX 0:85b3fd62ea1a 371 /**
NYX 0:85b3fd62ea1a 372 * @brief Compute USARTDIV value according to Peripheral Clock and
NYX 0:85b3fd62ea1a 373 * expected Baud Rate in 8 bits sampling mode (32 bits value of USARTDIV is returned)
NYX 0:85b3fd62ea1a 374 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance
NYX 0:85b3fd62ea1a 375 * @param __BAUDRATE__ Baud rate value to achieve
NYX 0:85b3fd62ea1a 376 * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case
NYX 0:85b3fd62ea1a 377 */
NYX 0:85b3fd62ea1a 378 #define __LL_USART_DIV_SAMPLING8_100(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__)*25)/(2*(__BAUDRATE__)))
NYX 0:85b3fd62ea1a 379 #define __LL_USART_DIVMANT_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (__LL_USART_DIV_SAMPLING8_100((__PERIPHCLK__), (__BAUDRATE__))/100)
NYX 0:85b3fd62ea1a 380 #define __LL_USART_DIVFRAQ_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIV_SAMPLING8_100((__PERIPHCLK__), (__BAUDRATE__)) - (__LL_USART_DIVMANT_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) * 100)) * 8 + 50) / 100)
NYX 0:85b3fd62ea1a 381 /* UART BRR = mantissa + overflow + fraction
NYX 0:85b3fd62ea1a 382 = (UART DIVMANT << 4) + ((UART DIVFRAQ & 0xF8) << 1) + (UART DIVFRAQ & 0x07) */
NYX 0:85b3fd62ea1a 383 #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIVMANT_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) << 4) + \
NYX 0:85b3fd62ea1a 384 ((__LL_USART_DIVFRAQ_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) & 0xF8) << 1)) + \
NYX 0:85b3fd62ea1a 385 (__LL_USART_DIVFRAQ_SAMPLING8((__PERIPHCLK__), (__BAUDRATE__)) & 0x07))
NYX 0:85b3fd62ea1a 386
NYX 0:85b3fd62ea1a 387 /**
NYX 0:85b3fd62ea1a 388 * @brief Compute USARTDIV value according to Peripheral Clock and
NYX 0:85b3fd62ea1a 389 * expected Baud Rate in 16 bits sampling mode (32 bits value of USARTDIV is returned)
NYX 0:85b3fd62ea1a 390 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance
NYX 0:85b3fd62ea1a 391 * @param __BAUDRATE__ Baud rate value to achieve
NYX 0:85b3fd62ea1a 392 * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case
NYX 0:85b3fd62ea1a 393 */
NYX 0:85b3fd62ea1a 394 #define __LL_USART_DIV_SAMPLING16_100(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__)*25)/(4*(__BAUDRATE__)))
NYX 0:85b3fd62ea1a 395 #define __LL_USART_DIVMANT_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (__LL_USART_DIV_SAMPLING16_100((__PERIPHCLK__), (__BAUDRATE__))/100)
NYX 0:85b3fd62ea1a 396 #define __LL_USART_DIVFRAQ_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIV_SAMPLING16_100((__PERIPHCLK__), (__BAUDRATE__)) - (__LL_USART_DIVMANT_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) * 100)) * 16 + 50) / 100)
NYX 0:85b3fd62ea1a 397 /* USART BRR = mantissa + overflow + fraction
NYX 0:85b3fd62ea1a 398 = (USART DIVMANT << 4) + (USART DIVFRAQ & 0xF0) + (USART DIVFRAQ & 0x0F) */
NYX 0:85b3fd62ea1a 399 #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) (((__LL_USART_DIVMANT_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) << 4) + \
NYX 0:85b3fd62ea1a 400 (__LL_USART_DIVFRAQ_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) & 0xF0)) + \
NYX 0:85b3fd62ea1a 401 (__LL_USART_DIVFRAQ_SAMPLING16((__PERIPHCLK__), (__BAUDRATE__)) & 0x0F))
NYX 0:85b3fd62ea1a 402
NYX 0:85b3fd62ea1a 403 /**
NYX 0:85b3fd62ea1a 404 * @}
NYX 0:85b3fd62ea1a 405 */
NYX 0:85b3fd62ea1a 406
NYX 0:85b3fd62ea1a 407 /**
NYX 0:85b3fd62ea1a 408 * @}
NYX 0:85b3fd62ea1a 409 */
NYX 0:85b3fd62ea1a 410
NYX 0:85b3fd62ea1a 411 /* Exported functions --------------------------------------------------------*/
NYX 0:85b3fd62ea1a 412
NYX 0:85b3fd62ea1a 413 /** @defgroup USART_LL_Exported_Functions USART Exported Functions
NYX 0:85b3fd62ea1a 414 * @{
NYX 0:85b3fd62ea1a 415 */
NYX 0:85b3fd62ea1a 416
NYX 0:85b3fd62ea1a 417 /** @defgroup USART_LL_EF_Configuration Configuration functions
NYX 0:85b3fd62ea1a 418 * @{
NYX 0:85b3fd62ea1a 419 */
NYX 0:85b3fd62ea1a 420
NYX 0:85b3fd62ea1a 421 /**
NYX 0:85b3fd62ea1a 422 * @brief USART Enable
NYX 0:85b3fd62ea1a 423 * @rmtoll CR1 UE LL_USART_Enable
NYX 0:85b3fd62ea1a 424 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 425 * @retval None
NYX 0:85b3fd62ea1a 426 */
NYX 0:85b3fd62ea1a 427 __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 428 {
NYX 0:85b3fd62ea1a 429 SET_BIT(USARTx->CR1, USART_CR1_UE);
NYX 0:85b3fd62ea1a 430 }
NYX 0:85b3fd62ea1a 431
NYX 0:85b3fd62ea1a 432 /**
NYX 0:85b3fd62ea1a 433 * @brief USART Disable (all USART prescalers and outputs are disabled)
NYX 0:85b3fd62ea1a 434 * @note When USART is disabled, USART prescalers and outputs are stopped immediately,
NYX 0:85b3fd62ea1a 435 * and current operations are discarded. The configuration of the USART is kept, but all the status
NYX 0:85b3fd62ea1a 436 * flags, in the USARTx_SR are set to their default values.
NYX 0:85b3fd62ea1a 437 * @rmtoll CR1 UE LL_USART_Disable
NYX 0:85b3fd62ea1a 438 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 439 * @retval None
NYX 0:85b3fd62ea1a 440 */
NYX 0:85b3fd62ea1a 441 __STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 442 {
NYX 0:85b3fd62ea1a 443 CLEAR_BIT(USARTx->CR1, USART_CR1_UE);
NYX 0:85b3fd62ea1a 444 }
NYX 0:85b3fd62ea1a 445
NYX 0:85b3fd62ea1a 446 /**
NYX 0:85b3fd62ea1a 447 * @brief Indicate if USART is enabled
NYX 0:85b3fd62ea1a 448 * @rmtoll CR1 UE LL_USART_IsEnabled
NYX 0:85b3fd62ea1a 449 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 450 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 451 */
NYX 0:85b3fd62ea1a 452 __STATIC_INLINE uint32_t LL_USART_IsEnabled(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 453 {
NYX 0:85b3fd62ea1a 454 return (READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE));
NYX 0:85b3fd62ea1a 455 }
NYX 0:85b3fd62ea1a 456
NYX 0:85b3fd62ea1a 457 /**
NYX 0:85b3fd62ea1a 458 * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit)
NYX 0:85b3fd62ea1a 459 * @rmtoll CR1 RE LL_USART_EnableDirectionRx
NYX 0:85b3fd62ea1a 460 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 461 * @retval None
NYX 0:85b3fd62ea1a 462 */
NYX 0:85b3fd62ea1a 463 __STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 464 {
NYX 0:85b3fd62ea1a 465 SET_BIT(USARTx->CR1, USART_CR1_RE);
NYX 0:85b3fd62ea1a 466 }
NYX 0:85b3fd62ea1a 467
NYX 0:85b3fd62ea1a 468 /**
NYX 0:85b3fd62ea1a 469 * @brief Receiver Disable
NYX 0:85b3fd62ea1a 470 * @rmtoll CR1 RE LL_USART_DisableDirectionRx
NYX 0:85b3fd62ea1a 471 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 472 * @retval None
NYX 0:85b3fd62ea1a 473 */
NYX 0:85b3fd62ea1a 474 __STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 475 {
NYX 0:85b3fd62ea1a 476 CLEAR_BIT(USARTx->CR1, USART_CR1_RE);
NYX 0:85b3fd62ea1a 477 }
NYX 0:85b3fd62ea1a 478
NYX 0:85b3fd62ea1a 479 /**
NYX 0:85b3fd62ea1a 480 * @brief Transmitter Enable
NYX 0:85b3fd62ea1a 481 * @rmtoll CR1 TE LL_USART_EnableDirectionTx
NYX 0:85b3fd62ea1a 482 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 483 * @retval None
NYX 0:85b3fd62ea1a 484 */
NYX 0:85b3fd62ea1a 485 __STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 486 {
NYX 0:85b3fd62ea1a 487 SET_BIT(USARTx->CR1, USART_CR1_TE);
NYX 0:85b3fd62ea1a 488 }
NYX 0:85b3fd62ea1a 489
NYX 0:85b3fd62ea1a 490 /**
NYX 0:85b3fd62ea1a 491 * @brief Transmitter Disable
NYX 0:85b3fd62ea1a 492 * @rmtoll CR1 TE LL_USART_DisableDirectionTx
NYX 0:85b3fd62ea1a 493 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 494 * @retval None
NYX 0:85b3fd62ea1a 495 */
NYX 0:85b3fd62ea1a 496 __STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 497 {
NYX 0:85b3fd62ea1a 498 CLEAR_BIT(USARTx->CR1, USART_CR1_TE);
NYX 0:85b3fd62ea1a 499 }
NYX 0:85b3fd62ea1a 500
NYX 0:85b3fd62ea1a 501 /**
NYX 0:85b3fd62ea1a 502 * @brief Configure simultaneously enabled/disabled states
NYX 0:85b3fd62ea1a 503 * of Transmitter and Receiver
NYX 0:85b3fd62ea1a 504 * @rmtoll CR1 RE LL_USART_SetTransferDirection\n
NYX 0:85b3fd62ea1a 505 * CR1 TE LL_USART_SetTransferDirection
NYX 0:85b3fd62ea1a 506 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 507 * @param TransferDirection This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 508 * @arg @ref LL_USART_DIRECTION_NONE
NYX 0:85b3fd62ea1a 509 * @arg @ref LL_USART_DIRECTION_RX
NYX 0:85b3fd62ea1a 510 * @arg @ref LL_USART_DIRECTION_TX
NYX 0:85b3fd62ea1a 511 * @arg @ref LL_USART_DIRECTION_TX_RX
NYX 0:85b3fd62ea1a 512 * @retval None
NYX 0:85b3fd62ea1a 513 */
NYX 0:85b3fd62ea1a 514 __STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t TransferDirection)
NYX 0:85b3fd62ea1a 515 {
NYX 0:85b3fd62ea1a 516 MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, TransferDirection);
NYX 0:85b3fd62ea1a 517 }
NYX 0:85b3fd62ea1a 518
NYX 0:85b3fd62ea1a 519 /**
NYX 0:85b3fd62ea1a 520 * @brief Return enabled/disabled states of Transmitter and Receiver
NYX 0:85b3fd62ea1a 521 * @rmtoll CR1 RE LL_USART_GetTransferDirection\n
NYX 0:85b3fd62ea1a 522 * CR1 TE LL_USART_GetTransferDirection
NYX 0:85b3fd62ea1a 523 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 524 * @retval Returned value can be one of the following values:
NYX 0:85b3fd62ea1a 525 * @arg @ref LL_USART_DIRECTION_NONE
NYX 0:85b3fd62ea1a 526 * @arg @ref LL_USART_DIRECTION_RX
NYX 0:85b3fd62ea1a 527 * @arg @ref LL_USART_DIRECTION_TX
NYX 0:85b3fd62ea1a 528 * @arg @ref LL_USART_DIRECTION_TX_RX
NYX 0:85b3fd62ea1a 529 */
NYX 0:85b3fd62ea1a 530 __STATIC_INLINE uint32_t LL_USART_GetTransferDirection(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 531 {
NYX 0:85b3fd62ea1a 532 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE));
NYX 0:85b3fd62ea1a 533 }
NYX 0:85b3fd62ea1a 534
NYX 0:85b3fd62ea1a 535 /**
NYX 0:85b3fd62ea1a 536 * @brief Configure Parity (enabled/disabled and parity mode if enabled).
NYX 0:85b3fd62ea1a 537 * @note This function selects if hardware parity control (generation and detection) is enabled or disabled.
NYX 0:85b3fd62ea1a 538 * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position
NYX 0:85b3fd62ea1a 539 * (9th or 8th bit depending on data width) and parity is checked on the received data.
NYX 0:85b3fd62ea1a 540 * @rmtoll CR1 PS LL_USART_SetParity\n
NYX 0:85b3fd62ea1a 541 * CR1 PCE LL_USART_SetParity
NYX 0:85b3fd62ea1a 542 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 543 * @param Parity This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 544 * @arg @ref LL_USART_PARITY_NONE
NYX 0:85b3fd62ea1a 545 * @arg @ref LL_USART_PARITY_EVEN
NYX 0:85b3fd62ea1a 546 * @arg @ref LL_USART_PARITY_ODD
NYX 0:85b3fd62ea1a 547 * @retval None
NYX 0:85b3fd62ea1a 548 */
NYX 0:85b3fd62ea1a 549 __STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t Parity)
NYX 0:85b3fd62ea1a 550 {
NYX 0:85b3fd62ea1a 551 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, Parity);
NYX 0:85b3fd62ea1a 552 }
NYX 0:85b3fd62ea1a 553
NYX 0:85b3fd62ea1a 554 /**
NYX 0:85b3fd62ea1a 555 * @brief Return Parity configuration (enabled/disabled and parity mode if enabled)
NYX 0:85b3fd62ea1a 556 * @rmtoll CR1 PS LL_USART_GetParity\n
NYX 0:85b3fd62ea1a 557 * CR1 PCE LL_USART_GetParity
NYX 0:85b3fd62ea1a 558 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 559 * @retval Returned value can be one of the following values:
NYX 0:85b3fd62ea1a 560 * @arg @ref LL_USART_PARITY_NONE
NYX 0:85b3fd62ea1a 561 * @arg @ref LL_USART_PARITY_EVEN
NYX 0:85b3fd62ea1a 562 * @arg @ref LL_USART_PARITY_ODD
NYX 0:85b3fd62ea1a 563 */
NYX 0:85b3fd62ea1a 564 __STATIC_INLINE uint32_t LL_USART_GetParity(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 565 {
NYX 0:85b3fd62ea1a 566 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE));
NYX 0:85b3fd62ea1a 567 }
NYX 0:85b3fd62ea1a 568
NYX 0:85b3fd62ea1a 569 /**
NYX 0:85b3fd62ea1a 570 * @brief Set Receiver Wake Up method from Mute mode.
NYX 0:85b3fd62ea1a 571 * @rmtoll CR1 WAKE LL_USART_SetWakeUpMethod
NYX 0:85b3fd62ea1a 572 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 573 * @param Method This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 574 * @arg @ref LL_USART_WAKEUP_IDLELINE
NYX 0:85b3fd62ea1a 575 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK
NYX 0:85b3fd62ea1a 576 * @retval None
NYX 0:85b3fd62ea1a 577 */
NYX 0:85b3fd62ea1a 578 __STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method)
NYX 0:85b3fd62ea1a 579 {
NYX 0:85b3fd62ea1a 580 MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method);
NYX 0:85b3fd62ea1a 581 }
NYX 0:85b3fd62ea1a 582
NYX 0:85b3fd62ea1a 583 /**
NYX 0:85b3fd62ea1a 584 * @brief Return Receiver Wake Up method from Mute mode
NYX 0:85b3fd62ea1a 585 * @rmtoll CR1 WAKE LL_USART_GetWakeUpMethod
NYX 0:85b3fd62ea1a 586 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 587 * @retval Returned value can be one of the following values:
NYX 0:85b3fd62ea1a 588 * @arg @ref LL_USART_WAKEUP_IDLELINE
NYX 0:85b3fd62ea1a 589 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK
NYX 0:85b3fd62ea1a 590 */
NYX 0:85b3fd62ea1a 591 __STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 592 {
NYX 0:85b3fd62ea1a 593 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE));
NYX 0:85b3fd62ea1a 594 }
NYX 0:85b3fd62ea1a 595
NYX 0:85b3fd62ea1a 596 /**
NYX 0:85b3fd62ea1a 597 * @brief Set Word length (i.e. nb of data bits, excluding start and stop bits)
NYX 0:85b3fd62ea1a 598 * @rmtoll CR1 M LL_USART_SetDataWidth
NYX 0:85b3fd62ea1a 599 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 600 * @param DataWidth This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 601 * @arg @ref LL_USART_DATAWIDTH_8B
NYX 0:85b3fd62ea1a 602 * @arg @ref LL_USART_DATAWIDTH_9B
NYX 0:85b3fd62ea1a 603 * @retval None
NYX 0:85b3fd62ea1a 604 */
NYX 0:85b3fd62ea1a 605 __STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth)
NYX 0:85b3fd62ea1a 606 {
NYX 0:85b3fd62ea1a 607 MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth);
NYX 0:85b3fd62ea1a 608 }
NYX 0:85b3fd62ea1a 609
NYX 0:85b3fd62ea1a 610 /**
NYX 0:85b3fd62ea1a 611 * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits)
NYX 0:85b3fd62ea1a 612 * @rmtoll CR1 M LL_USART_GetDataWidth
NYX 0:85b3fd62ea1a 613 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 614 * @retval Returned value can be one of the following values:
NYX 0:85b3fd62ea1a 615 * @arg @ref LL_USART_DATAWIDTH_8B
NYX 0:85b3fd62ea1a 616 * @arg @ref LL_USART_DATAWIDTH_9B
NYX 0:85b3fd62ea1a 617 */
NYX 0:85b3fd62ea1a 618 __STATIC_INLINE uint32_t LL_USART_GetDataWidth(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 619 {
NYX 0:85b3fd62ea1a 620 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M));
NYX 0:85b3fd62ea1a 621 }
NYX 0:85b3fd62ea1a 622
NYX 0:85b3fd62ea1a 623 /**
NYX 0:85b3fd62ea1a 624 * @brief Set Oversampling to 8-bit or 16-bit mode
NYX 0:85b3fd62ea1a 625 * @rmtoll CR1 OVER8 LL_USART_SetOverSampling
NYX 0:85b3fd62ea1a 626 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 627 * @param OverSampling This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 628 * @arg @ref LL_USART_OVERSAMPLING_16
NYX 0:85b3fd62ea1a 629 * @arg @ref LL_USART_OVERSAMPLING_8
NYX 0:85b3fd62ea1a 630 * @retval None
NYX 0:85b3fd62ea1a 631 */
NYX 0:85b3fd62ea1a 632 __STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling)
NYX 0:85b3fd62ea1a 633 {
NYX 0:85b3fd62ea1a 634 MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling);
NYX 0:85b3fd62ea1a 635 }
NYX 0:85b3fd62ea1a 636
NYX 0:85b3fd62ea1a 637 /**
NYX 0:85b3fd62ea1a 638 * @brief Return Oversampling mode
NYX 0:85b3fd62ea1a 639 * @rmtoll CR1 OVER8 LL_USART_GetOverSampling
NYX 0:85b3fd62ea1a 640 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 641 * @retval Returned value can be one of the following values:
NYX 0:85b3fd62ea1a 642 * @arg @ref LL_USART_OVERSAMPLING_16
NYX 0:85b3fd62ea1a 643 * @arg @ref LL_USART_OVERSAMPLING_8
NYX 0:85b3fd62ea1a 644 */
NYX 0:85b3fd62ea1a 645 __STATIC_INLINE uint32_t LL_USART_GetOverSampling(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 646 {
NYX 0:85b3fd62ea1a 647 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8));
NYX 0:85b3fd62ea1a 648 }
NYX 0:85b3fd62ea1a 649
NYX 0:85b3fd62ea1a 650 /**
NYX 0:85b3fd62ea1a 651 * @brief Configure if Clock pulse of the last data bit is output to the SCLK pin or not
NYX 0:85b3fd62ea1a 652 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 653 * Synchronous mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 654 * @rmtoll CR2 LBCL LL_USART_SetLastClkPulseOutput
NYX 0:85b3fd62ea1a 655 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 656 * @param LastBitClockPulse This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 657 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
NYX 0:85b3fd62ea1a 658 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
NYX 0:85b3fd62ea1a 659 * @retval None
NYX 0:85b3fd62ea1a 660 */
NYX 0:85b3fd62ea1a 661 __STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LastBitClockPulse)
NYX 0:85b3fd62ea1a 662 {
NYX 0:85b3fd62ea1a 663 MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LastBitClockPulse);
NYX 0:85b3fd62ea1a 664 }
NYX 0:85b3fd62ea1a 665
NYX 0:85b3fd62ea1a 666 /**
NYX 0:85b3fd62ea1a 667 * @brief Retrieve Clock pulse of the last data bit output configuration
NYX 0:85b3fd62ea1a 668 * (Last bit Clock pulse output to the SCLK pin or not)
NYX 0:85b3fd62ea1a 669 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 670 * Synchronous mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 671 * @rmtoll CR2 LBCL LL_USART_GetLastClkPulseOutput
NYX 0:85b3fd62ea1a 672 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 673 * @retval Returned value can be one of the following values:
NYX 0:85b3fd62ea1a 674 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
NYX 0:85b3fd62ea1a 675 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
NYX 0:85b3fd62ea1a 676 */
NYX 0:85b3fd62ea1a 677 __STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 678 {
NYX 0:85b3fd62ea1a 679 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL));
NYX 0:85b3fd62ea1a 680 }
NYX 0:85b3fd62ea1a 681
NYX 0:85b3fd62ea1a 682 /**
NYX 0:85b3fd62ea1a 683 * @brief Select the phase of the clock output on the SCLK pin in synchronous mode
NYX 0:85b3fd62ea1a 684 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 685 * Synchronous mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 686 * @rmtoll CR2 CPHA LL_USART_SetClockPhase
NYX 0:85b3fd62ea1a 687 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 688 * @param ClockPhase This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 689 * @arg @ref LL_USART_PHASE_1EDGE
NYX 0:85b3fd62ea1a 690 * @arg @ref LL_USART_PHASE_2EDGE
NYX 0:85b3fd62ea1a 691 * @retval None
NYX 0:85b3fd62ea1a 692 */
NYX 0:85b3fd62ea1a 693 __STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t ClockPhase)
NYX 0:85b3fd62ea1a 694 {
NYX 0:85b3fd62ea1a 695 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, ClockPhase);
NYX 0:85b3fd62ea1a 696 }
NYX 0:85b3fd62ea1a 697
NYX 0:85b3fd62ea1a 698 /**
NYX 0:85b3fd62ea1a 699 * @brief Return phase of the clock output on the SCLK pin in synchronous mode
NYX 0:85b3fd62ea1a 700 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 701 * Synchronous mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 702 * @rmtoll CR2 CPHA LL_USART_GetClockPhase
NYX 0:85b3fd62ea1a 703 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 704 * @retval Returned value can be one of the following values:
NYX 0:85b3fd62ea1a 705 * @arg @ref LL_USART_PHASE_1EDGE
NYX 0:85b3fd62ea1a 706 * @arg @ref LL_USART_PHASE_2EDGE
NYX 0:85b3fd62ea1a 707 */
NYX 0:85b3fd62ea1a 708 __STATIC_INLINE uint32_t LL_USART_GetClockPhase(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 709 {
NYX 0:85b3fd62ea1a 710 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA));
NYX 0:85b3fd62ea1a 711 }
NYX 0:85b3fd62ea1a 712
NYX 0:85b3fd62ea1a 713 /**
NYX 0:85b3fd62ea1a 714 * @brief Select the polarity of the clock output on the SCLK pin in synchronous mode
NYX 0:85b3fd62ea1a 715 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 716 * Synchronous mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 717 * @rmtoll CR2 CPOL LL_USART_SetClockPolarity
NYX 0:85b3fd62ea1a 718 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 719 * @param ClockPolarity This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 720 * @arg @ref LL_USART_POLARITY_LOW
NYX 0:85b3fd62ea1a 721 * @arg @ref LL_USART_POLARITY_HIGH
NYX 0:85b3fd62ea1a 722 * @retval None
NYX 0:85b3fd62ea1a 723 */
NYX 0:85b3fd62ea1a 724 __STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t ClockPolarity)
NYX 0:85b3fd62ea1a 725 {
NYX 0:85b3fd62ea1a 726 MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, ClockPolarity);
NYX 0:85b3fd62ea1a 727 }
NYX 0:85b3fd62ea1a 728
NYX 0:85b3fd62ea1a 729 /**
NYX 0:85b3fd62ea1a 730 * @brief Return polarity of the clock output on the SCLK pin in synchronous mode
NYX 0:85b3fd62ea1a 731 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 732 * Synchronous mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 733 * @rmtoll CR2 CPOL LL_USART_GetClockPolarity
NYX 0:85b3fd62ea1a 734 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 735 * @retval Returned value can be one of the following values:
NYX 0:85b3fd62ea1a 736 * @arg @ref LL_USART_POLARITY_LOW
NYX 0:85b3fd62ea1a 737 * @arg @ref LL_USART_POLARITY_HIGH
NYX 0:85b3fd62ea1a 738 */
NYX 0:85b3fd62ea1a 739 __STATIC_INLINE uint32_t LL_USART_GetClockPolarity(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 740 {
NYX 0:85b3fd62ea1a 741 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL));
NYX 0:85b3fd62ea1a 742 }
NYX 0:85b3fd62ea1a 743
NYX 0:85b3fd62ea1a 744 /**
NYX 0:85b3fd62ea1a 745 * @brief Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse)
NYX 0:85b3fd62ea1a 746 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 747 * Synchronous mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 748 * @note Call of this function is equivalent to following function call sequence :
NYX 0:85b3fd62ea1a 749 * - Clock Phase configuration using @ref LL_USART_SetClockPhase() function
NYX 0:85b3fd62ea1a 750 * - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function
NYX 0:85b3fd62ea1a 751 * - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function
NYX 0:85b3fd62ea1a 752 * @rmtoll CR2 CPHA LL_USART_ConfigClock\n
NYX 0:85b3fd62ea1a 753 * CR2 CPOL LL_USART_ConfigClock\n
NYX 0:85b3fd62ea1a 754 * CR2 LBCL LL_USART_ConfigClock
NYX 0:85b3fd62ea1a 755 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 756 * @param Phase This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 757 * @arg @ref LL_USART_PHASE_1EDGE
NYX 0:85b3fd62ea1a 758 * @arg @ref LL_USART_PHASE_2EDGE
NYX 0:85b3fd62ea1a 759 * @param Polarity This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 760 * @arg @ref LL_USART_POLARITY_LOW
NYX 0:85b3fd62ea1a 761 * @arg @ref LL_USART_POLARITY_HIGH
NYX 0:85b3fd62ea1a 762 * @param LBCPOutput This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 763 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
NYX 0:85b3fd62ea1a 764 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
NYX 0:85b3fd62ea1a 765 * @retval None
NYX 0:85b3fd62ea1a 766 */
NYX 0:85b3fd62ea1a 767 __STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput)
NYX 0:85b3fd62ea1a 768 {
NYX 0:85b3fd62ea1a 769 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput);
NYX 0:85b3fd62ea1a 770 }
NYX 0:85b3fd62ea1a 771
NYX 0:85b3fd62ea1a 772 /**
NYX 0:85b3fd62ea1a 773 * @brief Enable Clock output on SCLK pin
NYX 0:85b3fd62ea1a 774 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 775 * Synchronous mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 776 * @rmtoll CR2 CLKEN LL_USART_EnableSCLKOutput
NYX 0:85b3fd62ea1a 777 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 778 * @retval None
NYX 0:85b3fd62ea1a 779 */
NYX 0:85b3fd62ea1a 780 __STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 781 {
NYX 0:85b3fd62ea1a 782 SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
NYX 0:85b3fd62ea1a 783 }
NYX 0:85b3fd62ea1a 784
NYX 0:85b3fd62ea1a 785 /**
NYX 0:85b3fd62ea1a 786 * @brief Disable Clock output on SCLK pin
NYX 0:85b3fd62ea1a 787 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 788 * Synchronous mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 789 * @rmtoll CR2 CLKEN LL_USART_DisableSCLKOutput
NYX 0:85b3fd62ea1a 790 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 791 * @retval None
NYX 0:85b3fd62ea1a 792 */
NYX 0:85b3fd62ea1a 793 __STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 794 {
NYX 0:85b3fd62ea1a 795 CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN);
NYX 0:85b3fd62ea1a 796 }
NYX 0:85b3fd62ea1a 797
NYX 0:85b3fd62ea1a 798 /**
NYX 0:85b3fd62ea1a 799 * @brief Indicate if Clock output on SCLK pin is enabled
NYX 0:85b3fd62ea1a 800 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 801 * Synchronous mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 802 * @rmtoll CR2 CLKEN LL_USART_IsEnabledSCLKOutput
NYX 0:85b3fd62ea1a 803 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 804 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 805 */
NYX 0:85b3fd62ea1a 806 __STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 807 {
NYX 0:85b3fd62ea1a 808 return (READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN));
NYX 0:85b3fd62ea1a 809 }
NYX 0:85b3fd62ea1a 810
NYX 0:85b3fd62ea1a 811 /**
NYX 0:85b3fd62ea1a 812 * @brief Set the length of the stop bits
NYX 0:85b3fd62ea1a 813 * @rmtoll CR2 STOP LL_USART_SetStopBitsLength
NYX 0:85b3fd62ea1a 814 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 815 * @param StopBits This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 816 * @arg @ref LL_USART_STOPBITS_0_5
NYX 0:85b3fd62ea1a 817 * @arg @ref LL_USART_STOPBITS_1
NYX 0:85b3fd62ea1a 818 * @arg @ref LL_USART_STOPBITS_1_5
NYX 0:85b3fd62ea1a 819 * @arg @ref LL_USART_STOPBITS_2
NYX 0:85b3fd62ea1a 820 * @retval None
NYX 0:85b3fd62ea1a 821 */
NYX 0:85b3fd62ea1a 822 __STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits)
NYX 0:85b3fd62ea1a 823 {
NYX 0:85b3fd62ea1a 824 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
NYX 0:85b3fd62ea1a 825 }
NYX 0:85b3fd62ea1a 826
NYX 0:85b3fd62ea1a 827 /**
NYX 0:85b3fd62ea1a 828 * @brief Retrieve the length of the stop bits
NYX 0:85b3fd62ea1a 829 * @rmtoll CR2 STOP LL_USART_GetStopBitsLength
NYX 0:85b3fd62ea1a 830 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 831 * @retval Returned value can be one of the following values:
NYX 0:85b3fd62ea1a 832 * @arg @ref LL_USART_STOPBITS_0_5
NYX 0:85b3fd62ea1a 833 * @arg @ref LL_USART_STOPBITS_1
NYX 0:85b3fd62ea1a 834 * @arg @ref LL_USART_STOPBITS_1_5
NYX 0:85b3fd62ea1a 835 * @arg @ref LL_USART_STOPBITS_2
NYX 0:85b3fd62ea1a 836 */
NYX 0:85b3fd62ea1a 837 __STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 838 {
NYX 0:85b3fd62ea1a 839 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP));
NYX 0:85b3fd62ea1a 840 }
NYX 0:85b3fd62ea1a 841
NYX 0:85b3fd62ea1a 842 /**
NYX 0:85b3fd62ea1a 843 * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits)
NYX 0:85b3fd62ea1a 844 * @note Call of this function is equivalent to following function call sequence :
NYX 0:85b3fd62ea1a 845 * - Data Width configuration using @ref LL_USART_SetDataWidth() function
NYX 0:85b3fd62ea1a 846 * - Parity Control and mode configuration using @ref LL_USART_SetParity() function
NYX 0:85b3fd62ea1a 847 * - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function
NYX 0:85b3fd62ea1a 848 * @rmtoll CR1 PS LL_USART_ConfigCharacter\n
NYX 0:85b3fd62ea1a 849 * CR1 PCE LL_USART_ConfigCharacter\n
NYX 0:85b3fd62ea1a 850 * CR1 M LL_USART_ConfigCharacter\n
NYX 0:85b3fd62ea1a 851 * CR2 STOP LL_USART_ConfigCharacter
NYX 0:85b3fd62ea1a 852 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 853 * @param DataWidth This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 854 * @arg @ref LL_USART_DATAWIDTH_8B
NYX 0:85b3fd62ea1a 855 * @arg @ref LL_USART_DATAWIDTH_9B
NYX 0:85b3fd62ea1a 856 * @param Parity This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 857 * @arg @ref LL_USART_PARITY_NONE
NYX 0:85b3fd62ea1a 858 * @arg @ref LL_USART_PARITY_EVEN
NYX 0:85b3fd62ea1a 859 * @arg @ref LL_USART_PARITY_ODD
NYX 0:85b3fd62ea1a 860 * @param StopBits This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 861 * @arg @ref LL_USART_STOPBITS_0_5
NYX 0:85b3fd62ea1a 862 * @arg @ref LL_USART_STOPBITS_1
NYX 0:85b3fd62ea1a 863 * @arg @ref LL_USART_STOPBITS_1_5
NYX 0:85b3fd62ea1a 864 * @arg @ref LL_USART_STOPBITS_2
NYX 0:85b3fd62ea1a 865 * @retval None
NYX 0:85b3fd62ea1a 866 */
NYX 0:85b3fd62ea1a 867 __STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t Parity,
NYX 0:85b3fd62ea1a 868 uint32_t StopBits)
NYX 0:85b3fd62ea1a 869 {
NYX 0:85b3fd62ea1a 870 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, Parity | DataWidth);
NYX 0:85b3fd62ea1a 871 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
NYX 0:85b3fd62ea1a 872 }
NYX 0:85b3fd62ea1a 873
NYX 0:85b3fd62ea1a 874 /**
NYX 0:85b3fd62ea1a 875 * @brief Set Address of the USART node.
NYX 0:85b3fd62ea1a 876 * @note This is used in multiprocessor communication during Mute mode or Stop mode,
NYX 0:85b3fd62ea1a 877 * for wake up with address mark detection.
NYX 0:85b3fd62ea1a 878 * @rmtoll CR2 ADD LL_USART_SetNodeAddress
NYX 0:85b3fd62ea1a 879 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 880 * @param NodeAddress 4 bit Address of the USART node.
NYX 0:85b3fd62ea1a 881 * @retval None
NYX 0:85b3fd62ea1a 882 */
NYX 0:85b3fd62ea1a 883 __STATIC_INLINE void LL_USART_SetNodeAddress(USART_TypeDef *USARTx, uint32_t NodeAddress)
NYX 0:85b3fd62ea1a 884 {
NYX 0:85b3fd62ea1a 885 MODIFY_REG(USARTx->CR2, USART_CR2_ADD, (NodeAddress & USART_CR2_ADD));
NYX 0:85b3fd62ea1a 886 }
NYX 0:85b3fd62ea1a 887
NYX 0:85b3fd62ea1a 888 /**
NYX 0:85b3fd62ea1a 889 * @brief Return 4 bit Address of the USART node as set in ADD field of CR2.
NYX 0:85b3fd62ea1a 890 * @note only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant)
NYX 0:85b3fd62ea1a 891 * @rmtoll CR2 ADD LL_USART_GetNodeAddress
NYX 0:85b3fd62ea1a 892 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 893 * @retval Address of the USART node (Value between Min_Data=0 and Max_Data=255)
NYX 0:85b3fd62ea1a 894 */
NYX 0:85b3fd62ea1a 895 __STATIC_INLINE uint32_t LL_USART_GetNodeAddress(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 896 {
NYX 0:85b3fd62ea1a 897 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD));
NYX 0:85b3fd62ea1a 898 }
NYX 0:85b3fd62ea1a 899
NYX 0:85b3fd62ea1a 900 /**
NYX 0:85b3fd62ea1a 901 * @brief Enable RTS HW Flow Control
NYX 0:85b3fd62ea1a 902 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 903 * Hardware Flow control feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 904 * @rmtoll CR3 RTSE LL_USART_EnableRTSHWFlowCtrl
NYX 0:85b3fd62ea1a 905 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 906 * @retval None
NYX 0:85b3fd62ea1a 907 */
NYX 0:85b3fd62ea1a 908 __STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 909 {
NYX 0:85b3fd62ea1a 910 SET_BIT(USARTx->CR3, USART_CR3_RTSE);
NYX 0:85b3fd62ea1a 911 }
NYX 0:85b3fd62ea1a 912
NYX 0:85b3fd62ea1a 913 /**
NYX 0:85b3fd62ea1a 914 * @brief Disable RTS HW Flow Control
NYX 0:85b3fd62ea1a 915 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 916 * Hardware Flow control feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 917 * @rmtoll CR3 RTSE LL_USART_DisableRTSHWFlowCtrl
NYX 0:85b3fd62ea1a 918 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 919 * @retval None
NYX 0:85b3fd62ea1a 920 */
NYX 0:85b3fd62ea1a 921 __STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 922 {
NYX 0:85b3fd62ea1a 923 CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE);
NYX 0:85b3fd62ea1a 924 }
NYX 0:85b3fd62ea1a 925
NYX 0:85b3fd62ea1a 926 /**
NYX 0:85b3fd62ea1a 927 * @brief Enable CTS HW Flow Control
NYX 0:85b3fd62ea1a 928 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 929 * Hardware Flow control feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 930 * @rmtoll CR3 CTSE LL_USART_EnableCTSHWFlowCtrl
NYX 0:85b3fd62ea1a 931 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 932 * @retval None
NYX 0:85b3fd62ea1a 933 */
NYX 0:85b3fd62ea1a 934 __STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 935 {
NYX 0:85b3fd62ea1a 936 SET_BIT(USARTx->CR3, USART_CR3_CTSE);
NYX 0:85b3fd62ea1a 937 }
NYX 0:85b3fd62ea1a 938
NYX 0:85b3fd62ea1a 939 /**
NYX 0:85b3fd62ea1a 940 * @brief Disable CTS HW Flow Control
NYX 0:85b3fd62ea1a 941 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 942 * Hardware Flow control feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 943 * @rmtoll CR3 CTSE LL_USART_DisableCTSHWFlowCtrl
NYX 0:85b3fd62ea1a 944 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 945 * @retval None
NYX 0:85b3fd62ea1a 946 */
NYX 0:85b3fd62ea1a 947 __STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 948 {
NYX 0:85b3fd62ea1a 949 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE);
NYX 0:85b3fd62ea1a 950 }
NYX 0:85b3fd62ea1a 951
NYX 0:85b3fd62ea1a 952 /**
NYX 0:85b3fd62ea1a 953 * @brief Configure HW Flow Control mode (both CTS and RTS)
NYX 0:85b3fd62ea1a 954 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 955 * Hardware Flow control feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 956 * @rmtoll CR3 RTSE LL_USART_SetHWFlowCtrl\n
NYX 0:85b3fd62ea1a 957 * CR3 CTSE LL_USART_SetHWFlowCtrl
NYX 0:85b3fd62ea1a 958 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 959 * @param HardwareFlowControl This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 960 * @arg @ref LL_USART_HWCONTROL_NONE
NYX 0:85b3fd62ea1a 961 * @arg @ref LL_USART_HWCONTROL_RTS
NYX 0:85b3fd62ea1a 962 * @arg @ref LL_USART_HWCONTROL_CTS
NYX 0:85b3fd62ea1a 963 * @arg @ref LL_USART_HWCONTROL_RTS_CTS
NYX 0:85b3fd62ea1a 964 * @retval None
NYX 0:85b3fd62ea1a 965 */
NYX 0:85b3fd62ea1a 966 __STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HardwareFlowControl)
NYX 0:85b3fd62ea1a 967 {
NYX 0:85b3fd62ea1a 968 MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HardwareFlowControl);
NYX 0:85b3fd62ea1a 969 }
NYX 0:85b3fd62ea1a 970
NYX 0:85b3fd62ea1a 971 /**
NYX 0:85b3fd62ea1a 972 * @brief Return HW Flow Control configuration (both CTS and RTS)
NYX 0:85b3fd62ea1a 973 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 974 * Hardware Flow control feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 975 * @rmtoll CR3 RTSE LL_USART_GetHWFlowCtrl\n
NYX 0:85b3fd62ea1a 976 * CR3 CTSE LL_USART_GetHWFlowCtrl
NYX 0:85b3fd62ea1a 977 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 978 * @retval Returned value can be one of the following values:
NYX 0:85b3fd62ea1a 979 * @arg @ref LL_USART_HWCONTROL_NONE
NYX 0:85b3fd62ea1a 980 * @arg @ref LL_USART_HWCONTROL_RTS
NYX 0:85b3fd62ea1a 981 * @arg @ref LL_USART_HWCONTROL_CTS
NYX 0:85b3fd62ea1a 982 * @arg @ref LL_USART_HWCONTROL_RTS_CTS
NYX 0:85b3fd62ea1a 983 */
NYX 0:85b3fd62ea1a 984 __STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 985 {
NYX 0:85b3fd62ea1a 986 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE));
NYX 0:85b3fd62ea1a 987 }
NYX 0:85b3fd62ea1a 988
NYX 0:85b3fd62ea1a 989 /**
NYX 0:85b3fd62ea1a 990 * @brief Enable One bit sampling method
NYX 0:85b3fd62ea1a 991 * @rmtoll CR3 ONEBIT LL_USART_EnableOneBitSamp
NYX 0:85b3fd62ea1a 992 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 993 * @retval None
NYX 0:85b3fd62ea1a 994 */
NYX 0:85b3fd62ea1a 995 __STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 996 {
NYX 0:85b3fd62ea1a 997 SET_BIT(USARTx->CR3, USART_CR3_ONEBIT);
NYX 0:85b3fd62ea1a 998 }
NYX 0:85b3fd62ea1a 999
NYX 0:85b3fd62ea1a 1000 /**
NYX 0:85b3fd62ea1a 1001 * @brief Disable One bit sampling method
NYX 0:85b3fd62ea1a 1002 * @rmtoll CR3 ONEBIT LL_USART_DisableOneBitSamp
NYX 0:85b3fd62ea1a 1003 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1004 * @retval None
NYX 0:85b3fd62ea1a 1005 */
NYX 0:85b3fd62ea1a 1006 __STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1007 {
NYX 0:85b3fd62ea1a 1008 CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT);
NYX 0:85b3fd62ea1a 1009 }
NYX 0:85b3fd62ea1a 1010
NYX 0:85b3fd62ea1a 1011 /**
NYX 0:85b3fd62ea1a 1012 * @brief Indicate if One bit sampling method is enabled
NYX 0:85b3fd62ea1a 1013 * @rmtoll CR3 ONEBIT LL_USART_IsEnabledOneBitSamp
NYX 0:85b3fd62ea1a 1014 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1015 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1016 */
NYX 0:85b3fd62ea1a 1017 __STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1018 {
NYX 0:85b3fd62ea1a 1019 return (READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT));
NYX 0:85b3fd62ea1a 1020 }
NYX 0:85b3fd62ea1a 1021
NYX 0:85b3fd62ea1a 1022 /**
NYX 0:85b3fd62ea1a 1023 * @brief Configure USART BRR register for achieving expected Baud Rate value.
NYX 0:85b3fd62ea1a 1024 * @note Compute and set USARTDIV value in BRR Register (full BRR content)
NYX 0:85b3fd62ea1a 1025 * according to used Peripheral Clock, Oversampling mode, and expected Baud Rate values
NYX 0:85b3fd62ea1a 1026 * @note Peripheral clock and Baud rate values provided as function parameters should be valid
NYX 0:85b3fd62ea1a 1027 * (Baud rate value != 0)
NYX 0:85b3fd62ea1a 1028 * @rmtoll BRR BRR LL_USART_SetBaudRate
NYX 0:85b3fd62ea1a 1029 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1030 * @param PeriphClk Peripheral Clock
NYX 0:85b3fd62ea1a 1031 * @param OverSampling This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1032 * @arg @ref LL_USART_OVERSAMPLING_16
NYX 0:85b3fd62ea1a 1033 * @arg @ref LL_USART_OVERSAMPLING_8
NYX 0:85b3fd62ea1a 1034 * @param BaudRate Baud Rate
NYX 0:85b3fd62ea1a 1035 * @retval None
NYX 0:85b3fd62ea1a 1036 */
NYX 0:85b3fd62ea1a 1037 __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling,
NYX 0:85b3fd62ea1a 1038 uint32_t BaudRate)
NYX 0:85b3fd62ea1a 1039 {
NYX 0:85b3fd62ea1a 1040 if (OverSampling == LL_USART_OVERSAMPLING_8)
NYX 0:85b3fd62ea1a 1041 {
NYX 0:85b3fd62ea1a 1042 USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, BaudRate));
NYX 0:85b3fd62ea1a 1043 }
NYX 0:85b3fd62ea1a 1044 else
NYX 0:85b3fd62ea1a 1045 {
NYX 0:85b3fd62ea1a 1046 USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate));
NYX 0:85b3fd62ea1a 1047 }
NYX 0:85b3fd62ea1a 1048 }
NYX 0:85b3fd62ea1a 1049
NYX 0:85b3fd62ea1a 1050 /**
NYX 0:85b3fd62ea1a 1051 * @brief Return current Baud Rate value, according to USARTDIV present in BRR register
NYX 0:85b3fd62ea1a 1052 * (full BRR content), and to used Peripheral Clock and Oversampling mode values
NYX 0:85b3fd62ea1a 1053 * @note In case of non-initialized or invalid value stored in BRR register, value 0 will be returned.
NYX 0:85b3fd62ea1a 1054 * @rmtoll BRR BRR LL_USART_GetBaudRate
NYX 0:85b3fd62ea1a 1055 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1056 * @param PeriphClk Peripheral Clock
NYX 0:85b3fd62ea1a 1057 * @param OverSampling This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1058 * @arg @ref LL_USART_OVERSAMPLING_16
NYX 0:85b3fd62ea1a 1059 * @arg @ref LL_USART_OVERSAMPLING_8
NYX 0:85b3fd62ea1a 1060 * @retval Baud Rate
NYX 0:85b3fd62ea1a 1061 */
NYX 0:85b3fd62ea1a 1062 __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling)
NYX 0:85b3fd62ea1a 1063 {
NYX 0:85b3fd62ea1a 1064 register uint32_t usartdiv = 0x0U;
NYX 0:85b3fd62ea1a 1065 register uint32_t brrresult = 0x0U;
NYX 0:85b3fd62ea1a 1066
NYX 0:85b3fd62ea1a 1067 usartdiv = USARTx->BRR;
NYX 0:85b3fd62ea1a 1068
NYX 0:85b3fd62ea1a 1069 if (OverSampling == LL_USART_OVERSAMPLING_8)
NYX 0:85b3fd62ea1a 1070 {
NYX 0:85b3fd62ea1a 1071 if ((usartdiv & 0xFFF7U) != 0U)
NYX 0:85b3fd62ea1a 1072 {
NYX 0:85b3fd62ea1a 1073 usartdiv = (uint16_t)((usartdiv & 0xFFF0U) | ((usartdiv & 0x0007U) << 1U)) ;
NYX 0:85b3fd62ea1a 1074 brrresult = (PeriphClk * 2U) / usartdiv;
NYX 0:85b3fd62ea1a 1075 }
NYX 0:85b3fd62ea1a 1076 }
NYX 0:85b3fd62ea1a 1077 else
NYX 0:85b3fd62ea1a 1078 {
NYX 0:85b3fd62ea1a 1079 if ((usartdiv & 0xFFFFU) != 0U)
NYX 0:85b3fd62ea1a 1080 {
NYX 0:85b3fd62ea1a 1081 brrresult = PeriphClk / usartdiv;
NYX 0:85b3fd62ea1a 1082 }
NYX 0:85b3fd62ea1a 1083 }
NYX 0:85b3fd62ea1a 1084 return (brrresult);
NYX 0:85b3fd62ea1a 1085 }
NYX 0:85b3fd62ea1a 1086
NYX 0:85b3fd62ea1a 1087 /**
NYX 0:85b3fd62ea1a 1088 * @}
NYX 0:85b3fd62ea1a 1089 */
NYX 0:85b3fd62ea1a 1090
NYX 0:85b3fd62ea1a 1091 /** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature
NYX 0:85b3fd62ea1a 1092 * @{
NYX 0:85b3fd62ea1a 1093 */
NYX 0:85b3fd62ea1a 1094
NYX 0:85b3fd62ea1a 1095 /**
NYX 0:85b3fd62ea1a 1096 * @brief Enable IrDA mode
NYX 0:85b3fd62ea1a 1097 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1098 * IrDA feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1099 * @rmtoll CR3 IREN LL_USART_EnableIrda
NYX 0:85b3fd62ea1a 1100 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1101 * @retval None
NYX 0:85b3fd62ea1a 1102 */
NYX 0:85b3fd62ea1a 1103 __STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1104 {
NYX 0:85b3fd62ea1a 1105 SET_BIT(USARTx->CR3, USART_CR3_IREN);
NYX 0:85b3fd62ea1a 1106 }
NYX 0:85b3fd62ea1a 1107
NYX 0:85b3fd62ea1a 1108 /**
NYX 0:85b3fd62ea1a 1109 * @brief Disable IrDA mode
NYX 0:85b3fd62ea1a 1110 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1111 * IrDA feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1112 * @rmtoll CR3 IREN LL_USART_DisableIrda
NYX 0:85b3fd62ea1a 1113 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1114 * @retval None
NYX 0:85b3fd62ea1a 1115 */
NYX 0:85b3fd62ea1a 1116 __STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1117 {
NYX 0:85b3fd62ea1a 1118 CLEAR_BIT(USARTx->CR3, USART_CR3_IREN);
NYX 0:85b3fd62ea1a 1119 }
NYX 0:85b3fd62ea1a 1120
NYX 0:85b3fd62ea1a 1121 /**
NYX 0:85b3fd62ea1a 1122 * @brief Indicate if IrDA mode is enabled
NYX 0:85b3fd62ea1a 1123 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1124 * IrDA feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1125 * @rmtoll CR3 IREN LL_USART_IsEnabledIrda
NYX 0:85b3fd62ea1a 1126 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1127 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1128 */
NYX 0:85b3fd62ea1a 1129 __STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1130 {
NYX 0:85b3fd62ea1a 1131 return (READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN));
NYX 0:85b3fd62ea1a 1132 }
NYX 0:85b3fd62ea1a 1133
NYX 0:85b3fd62ea1a 1134 /**
NYX 0:85b3fd62ea1a 1135 * @brief Configure IrDA Power Mode (Normal or Low Power)
NYX 0:85b3fd62ea1a 1136 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1137 * IrDA feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1138 * @rmtoll CR3 IRLP LL_USART_SetIrdaPowerMode
NYX 0:85b3fd62ea1a 1139 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1140 * @param PowerMode This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1141 * @arg @ref LL_USART_IRDA_POWER_NORMAL
NYX 0:85b3fd62ea1a 1142 * @arg @ref LL_USART_IRDA_POWER_LOW
NYX 0:85b3fd62ea1a 1143 * @retval None
NYX 0:85b3fd62ea1a 1144 */
NYX 0:85b3fd62ea1a 1145 __STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode)
NYX 0:85b3fd62ea1a 1146 {
NYX 0:85b3fd62ea1a 1147 MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode);
NYX 0:85b3fd62ea1a 1148 }
NYX 0:85b3fd62ea1a 1149
NYX 0:85b3fd62ea1a 1150 /**
NYX 0:85b3fd62ea1a 1151 * @brief Retrieve IrDA Power Mode configuration (Normal or Low Power)
NYX 0:85b3fd62ea1a 1152 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1153 * IrDA feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1154 * @rmtoll CR3 IRLP LL_USART_GetIrdaPowerMode
NYX 0:85b3fd62ea1a 1155 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1156 * @retval Returned value can be one of the following values:
NYX 0:85b3fd62ea1a 1157 * @arg @ref LL_USART_IRDA_POWER_NORMAL
NYX 0:85b3fd62ea1a 1158 * @arg @ref LL_USART_PHASE_2EDGE
NYX 0:85b3fd62ea1a 1159 */
NYX 0:85b3fd62ea1a 1160 __STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1161 {
NYX 0:85b3fd62ea1a 1162 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP));
NYX 0:85b3fd62ea1a 1163 }
NYX 0:85b3fd62ea1a 1164
NYX 0:85b3fd62ea1a 1165 /**
NYX 0:85b3fd62ea1a 1166 * @brief Set Irda prescaler value, used for dividing the USART clock source
NYX 0:85b3fd62ea1a 1167 * to achieve the Irda Low Power frequency (8 bits value)
NYX 0:85b3fd62ea1a 1168 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1169 * IrDA feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1170 * @rmtoll GTPR PSC LL_USART_SetIrdaPrescaler
NYX 0:85b3fd62ea1a 1171 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1172 * @param PrescalerValue Value between Min_Data=0x00 and Max_Data=0xFF
NYX 0:85b3fd62ea1a 1173 * @retval None
NYX 0:85b3fd62ea1a 1174 */
NYX 0:85b3fd62ea1a 1175 __STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
NYX 0:85b3fd62ea1a 1176 {
NYX 0:85b3fd62ea1a 1177 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue);
NYX 0:85b3fd62ea1a 1178 }
NYX 0:85b3fd62ea1a 1179
NYX 0:85b3fd62ea1a 1180 /**
NYX 0:85b3fd62ea1a 1181 * @brief Return Irda prescaler value, used for dividing the USART clock source
NYX 0:85b3fd62ea1a 1182 * to achieve the Irda Low Power frequency (8 bits value)
NYX 0:85b3fd62ea1a 1183 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1184 * IrDA feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1185 * @rmtoll GTPR PSC LL_USART_GetIrdaPrescaler
NYX 0:85b3fd62ea1a 1186 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1187 * @retval Irda prescaler value (Value between Min_Data=0x00 and Max_Data=0xFF)
NYX 0:85b3fd62ea1a 1188 */
NYX 0:85b3fd62ea1a 1189 __STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1190 {
NYX 0:85b3fd62ea1a 1191 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
NYX 0:85b3fd62ea1a 1192 }
NYX 0:85b3fd62ea1a 1193
NYX 0:85b3fd62ea1a 1194 /**
NYX 0:85b3fd62ea1a 1195 * @}
NYX 0:85b3fd62ea1a 1196 */
NYX 0:85b3fd62ea1a 1197
NYX 0:85b3fd62ea1a 1198 /** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature
NYX 0:85b3fd62ea1a 1199 * @{
NYX 0:85b3fd62ea1a 1200 */
NYX 0:85b3fd62ea1a 1201
NYX 0:85b3fd62ea1a 1202 /**
NYX 0:85b3fd62ea1a 1203 * @brief Enable Smartcard NACK transmission
NYX 0:85b3fd62ea1a 1204 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1205 * Smartcard feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1206 * @rmtoll CR3 NACK LL_USART_EnableSmartcardNACK
NYX 0:85b3fd62ea1a 1207 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1208 * @retval None
NYX 0:85b3fd62ea1a 1209 */
NYX 0:85b3fd62ea1a 1210 __STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1211 {
NYX 0:85b3fd62ea1a 1212 SET_BIT(USARTx->CR3, USART_CR3_NACK);
NYX 0:85b3fd62ea1a 1213 }
NYX 0:85b3fd62ea1a 1214
NYX 0:85b3fd62ea1a 1215 /**
NYX 0:85b3fd62ea1a 1216 * @brief Disable Smartcard NACK transmission
NYX 0:85b3fd62ea1a 1217 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1218 * Smartcard feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1219 * @rmtoll CR3 NACK LL_USART_DisableSmartcardNACK
NYX 0:85b3fd62ea1a 1220 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1221 * @retval None
NYX 0:85b3fd62ea1a 1222 */
NYX 0:85b3fd62ea1a 1223 __STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1224 {
NYX 0:85b3fd62ea1a 1225 CLEAR_BIT(USARTx->CR3, USART_CR3_NACK);
NYX 0:85b3fd62ea1a 1226 }
NYX 0:85b3fd62ea1a 1227
NYX 0:85b3fd62ea1a 1228 /**
NYX 0:85b3fd62ea1a 1229 * @brief Indicate if Smartcard NACK transmission is enabled
NYX 0:85b3fd62ea1a 1230 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1231 * Smartcard feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1232 * @rmtoll CR3 NACK LL_USART_IsEnabledSmartcardNACK
NYX 0:85b3fd62ea1a 1233 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1234 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1235 */
NYX 0:85b3fd62ea1a 1236 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1237 {
NYX 0:85b3fd62ea1a 1238 return (READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK));
NYX 0:85b3fd62ea1a 1239 }
NYX 0:85b3fd62ea1a 1240
NYX 0:85b3fd62ea1a 1241 /**
NYX 0:85b3fd62ea1a 1242 * @brief Enable Smartcard mode
NYX 0:85b3fd62ea1a 1243 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1244 * Smartcard feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1245 * @rmtoll CR3 SCEN LL_USART_EnableSmartcard
NYX 0:85b3fd62ea1a 1246 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1247 * @retval None
NYX 0:85b3fd62ea1a 1248 */
NYX 0:85b3fd62ea1a 1249 __STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1250 {
NYX 0:85b3fd62ea1a 1251 SET_BIT(USARTx->CR3, USART_CR3_SCEN);
NYX 0:85b3fd62ea1a 1252 }
NYX 0:85b3fd62ea1a 1253
NYX 0:85b3fd62ea1a 1254 /**
NYX 0:85b3fd62ea1a 1255 * @brief Disable Smartcard mode
NYX 0:85b3fd62ea1a 1256 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1257 * Smartcard feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1258 * @rmtoll CR3 SCEN LL_USART_DisableSmartcard
NYX 0:85b3fd62ea1a 1259 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1260 * @retval None
NYX 0:85b3fd62ea1a 1261 */
NYX 0:85b3fd62ea1a 1262 __STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1263 {
NYX 0:85b3fd62ea1a 1264 CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN);
NYX 0:85b3fd62ea1a 1265 }
NYX 0:85b3fd62ea1a 1266
NYX 0:85b3fd62ea1a 1267 /**
NYX 0:85b3fd62ea1a 1268 * @brief Indicate if Smartcard mode is enabled
NYX 0:85b3fd62ea1a 1269 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1270 * Smartcard feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1271 * @rmtoll CR3 SCEN LL_USART_IsEnabledSmartcard
NYX 0:85b3fd62ea1a 1272 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1273 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1274 */
NYX 0:85b3fd62ea1a 1275 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1276 {
NYX 0:85b3fd62ea1a 1277 return (READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN));
NYX 0:85b3fd62ea1a 1278 }
NYX 0:85b3fd62ea1a 1279
NYX 0:85b3fd62ea1a 1280 /**
NYX 0:85b3fd62ea1a 1281 * @brief Set Smartcard prescaler value, used for dividing the USART clock
NYX 0:85b3fd62ea1a 1282 * source to provide the SMARTCARD Clock (5 bits value)
NYX 0:85b3fd62ea1a 1283 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1284 * Smartcard feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1285 * @rmtoll GTPR PSC LL_USART_SetSmartcardPrescaler
NYX 0:85b3fd62ea1a 1286 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1287 * @param PrescalerValue Value between Min_Data=0 and Max_Data=31
NYX 0:85b3fd62ea1a 1288 * @retval None
NYX 0:85b3fd62ea1a 1289 */
NYX 0:85b3fd62ea1a 1290 __STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
NYX 0:85b3fd62ea1a 1291 {
NYX 0:85b3fd62ea1a 1292 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue);
NYX 0:85b3fd62ea1a 1293 }
NYX 0:85b3fd62ea1a 1294
NYX 0:85b3fd62ea1a 1295 /**
NYX 0:85b3fd62ea1a 1296 * @brief Return Smartcard prescaler value, used for dividing the USART clock
NYX 0:85b3fd62ea1a 1297 * source to provide the SMARTCARD Clock (5 bits value)
NYX 0:85b3fd62ea1a 1298 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1299 * Smartcard feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1300 * @rmtoll GTPR PSC LL_USART_GetSmartcardPrescaler
NYX 0:85b3fd62ea1a 1301 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1302 * @retval Smartcard prescaler value (Value between Min_Data=0 and Max_Data=31)
NYX 0:85b3fd62ea1a 1303 */
NYX 0:85b3fd62ea1a 1304 __STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1305 {
NYX 0:85b3fd62ea1a 1306 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
NYX 0:85b3fd62ea1a 1307 }
NYX 0:85b3fd62ea1a 1308
NYX 0:85b3fd62ea1a 1309 /**
NYX 0:85b3fd62ea1a 1310 * @brief Set Smartcard Guard time value, expressed in nb of baud clocks periods
NYX 0:85b3fd62ea1a 1311 * (GT[7:0] bits : Guard time value)
NYX 0:85b3fd62ea1a 1312 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1313 * Smartcard feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1314 * @rmtoll GTPR GT LL_USART_SetSmartcardGuardTime
NYX 0:85b3fd62ea1a 1315 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1316 * @param GuardTime Value between Min_Data=0x00 and Max_Data=0xFF
NYX 0:85b3fd62ea1a 1317 * @retval None
NYX 0:85b3fd62ea1a 1318 */
NYX 0:85b3fd62ea1a 1319 __STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime)
NYX 0:85b3fd62ea1a 1320 {
NYX 0:85b3fd62ea1a 1321 MODIFY_REG(USARTx->GTPR, USART_GTPR_GT, GuardTime << USART_POSITION_GTPR_GT);
NYX 0:85b3fd62ea1a 1322 }
NYX 0:85b3fd62ea1a 1323
NYX 0:85b3fd62ea1a 1324 /**
NYX 0:85b3fd62ea1a 1325 * @brief Return Smartcard Guard time value, expressed in nb of baud clocks periods
NYX 0:85b3fd62ea1a 1326 * (GT[7:0] bits : Guard time value)
NYX 0:85b3fd62ea1a 1327 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1328 * Smartcard feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1329 * @rmtoll GTPR GT LL_USART_GetSmartcardGuardTime
NYX 0:85b3fd62ea1a 1330 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1331 * @retval Smartcard Guard time value (Value between Min_Data=0x00 and Max_Data=0xFF)
NYX 0:85b3fd62ea1a 1332 */
NYX 0:85b3fd62ea1a 1333 __STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1334 {
NYX 0:85b3fd62ea1a 1335 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_POSITION_GTPR_GT);
NYX 0:85b3fd62ea1a 1336 }
NYX 0:85b3fd62ea1a 1337
NYX 0:85b3fd62ea1a 1338 /**
NYX 0:85b3fd62ea1a 1339 * @}
NYX 0:85b3fd62ea1a 1340 */
NYX 0:85b3fd62ea1a 1341
NYX 0:85b3fd62ea1a 1342 /** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature
NYX 0:85b3fd62ea1a 1343 * @{
NYX 0:85b3fd62ea1a 1344 */
NYX 0:85b3fd62ea1a 1345
NYX 0:85b3fd62ea1a 1346 /**
NYX 0:85b3fd62ea1a 1347 * @brief Enable Single Wire Half-Duplex mode
NYX 0:85b3fd62ea1a 1348 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1349 * Half-Duplex mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1350 * @rmtoll CR3 HDSEL LL_USART_EnableHalfDuplex
NYX 0:85b3fd62ea1a 1351 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1352 * @retval None
NYX 0:85b3fd62ea1a 1353 */
NYX 0:85b3fd62ea1a 1354 __STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1355 {
NYX 0:85b3fd62ea1a 1356 SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
NYX 0:85b3fd62ea1a 1357 }
NYX 0:85b3fd62ea1a 1358
NYX 0:85b3fd62ea1a 1359 /**
NYX 0:85b3fd62ea1a 1360 * @brief Disable Single Wire Half-Duplex mode
NYX 0:85b3fd62ea1a 1361 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1362 * Half-Duplex mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1363 * @rmtoll CR3 HDSEL LL_USART_DisableHalfDuplex
NYX 0:85b3fd62ea1a 1364 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1365 * @retval None
NYX 0:85b3fd62ea1a 1366 */
NYX 0:85b3fd62ea1a 1367 __STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1368 {
NYX 0:85b3fd62ea1a 1369 CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL);
NYX 0:85b3fd62ea1a 1370 }
NYX 0:85b3fd62ea1a 1371
NYX 0:85b3fd62ea1a 1372 /**
NYX 0:85b3fd62ea1a 1373 * @brief Indicate if Single Wire Half-Duplex mode is enabled
NYX 0:85b3fd62ea1a 1374 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1375 * Half-Duplex mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1376 * @rmtoll CR3 HDSEL LL_USART_IsEnabledHalfDuplex
NYX 0:85b3fd62ea1a 1377 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1378 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1379 */
NYX 0:85b3fd62ea1a 1380 __STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1381 {
NYX 0:85b3fd62ea1a 1382 return (READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL));
NYX 0:85b3fd62ea1a 1383 }
NYX 0:85b3fd62ea1a 1384
NYX 0:85b3fd62ea1a 1385 /**
NYX 0:85b3fd62ea1a 1386 * @}
NYX 0:85b3fd62ea1a 1387 */
NYX 0:85b3fd62ea1a 1388
NYX 0:85b3fd62ea1a 1389 /** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature
NYX 0:85b3fd62ea1a 1390 * @{
NYX 0:85b3fd62ea1a 1391 */
NYX 0:85b3fd62ea1a 1392
NYX 0:85b3fd62ea1a 1393 /**
NYX 0:85b3fd62ea1a 1394 * @brief Set LIN Break Detection Length
NYX 0:85b3fd62ea1a 1395 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1396 * LIN feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1397 * @rmtoll CR2 LBDL LL_USART_SetLINBrkDetectionLen
NYX 0:85b3fd62ea1a 1398 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1399 * @param LINBDLength This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1400 * @arg @ref LL_USART_LINBREAK_DETECT_10B
NYX 0:85b3fd62ea1a 1401 * @arg @ref LL_USART_LINBREAK_DETECT_11B
NYX 0:85b3fd62ea1a 1402 * @retval None
NYX 0:85b3fd62ea1a 1403 */
NYX 0:85b3fd62ea1a 1404 __STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength)
NYX 0:85b3fd62ea1a 1405 {
NYX 0:85b3fd62ea1a 1406 MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength);
NYX 0:85b3fd62ea1a 1407 }
NYX 0:85b3fd62ea1a 1408
NYX 0:85b3fd62ea1a 1409 /**
NYX 0:85b3fd62ea1a 1410 * @brief Return LIN Break Detection Length
NYX 0:85b3fd62ea1a 1411 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1412 * LIN feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1413 * @rmtoll CR2 LBDL LL_USART_GetLINBrkDetectionLen
NYX 0:85b3fd62ea1a 1414 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1415 * @retval Returned value can be one of the following values:
NYX 0:85b3fd62ea1a 1416 * @arg @ref LL_USART_LINBREAK_DETECT_10B
NYX 0:85b3fd62ea1a 1417 * @arg @ref LL_USART_LINBREAK_DETECT_11B
NYX 0:85b3fd62ea1a 1418 */
NYX 0:85b3fd62ea1a 1419 __STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1420 {
NYX 0:85b3fd62ea1a 1421 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL));
NYX 0:85b3fd62ea1a 1422 }
NYX 0:85b3fd62ea1a 1423
NYX 0:85b3fd62ea1a 1424 /**
NYX 0:85b3fd62ea1a 1425 * @brief Enable LIN mode
NYX 0:85b3fd62ea1a 1426 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1427 * LIN feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1428 * @rmtoll CR2 LINEN LL_USART_EnableLIN
NYX 0:85b3fd62ea1a 1429 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1430 * @retval None
NYX 0:85b3fd62ea1a 1431 */
NYX 0:85b3fd62ea1a 1432 __STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1433 {
NYX 0:85b3fd62ea1a 1434 SET_BIT(USARTx->CR2, USART_CR2_LINEN);
NYX 0:85b3fd62ea1a 1435 }
NYX 0:85b3fd62ea1a 1436
NYX 0:85b3fd62ea1a 1437 /**
NYX 0:85b3fd62ea1a 1438 * @brief Disable LIN mode
NYX 0:85b3fd62ea1a 1439 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1440 * LIN feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1441 * @rmtoll CR2 LINEN LL_USART_DisableLIN
NYX 0:85b3fd62ea1a 1442 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1443 * @retval None
NYX 0:85b3fd62ea1a 1444 */
NYX 0:85b3fd62ea1a 1445 __STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1446 {
NYX 0:85b3fd62ea1a 1447 CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN);
NYX 0:85b3fd62ea1a 1448 }
NYX 0:85b3fd62ea1a 1449
NYX 0:85b3fd62ea1a 1450 /**
NYX 0:85b3fd62ea1a 1451 * @brief Indicate if LIN mode is enabled
NYX 0:85b3fd62ea1a 1452 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1453 * LIN feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1454 * @rmtoll CR2 LINEN LL_USART_IsEnabledLIN
NYX 0:85b3fd62ea1a 1455 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1456 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1457 */
NYX 0:85b3fd62ea1a 1458 __STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1459 {
NYX 0:85b3fd62ea1a 1460 return (READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN));
NYX 0:85b3fd62ea1a 1461 }
NYX 0:85b3fd62ea1a 1462
NYX 0:85b3fd62ea1a 1463 /**
NYX 0:85b3fd62ea1a 1464 * @}
NYX 0:85b3fd62ea1a 1465 */
NYX 0:85b3fd62ea1a 1466
NYX 0:85b3fd62ea1a 1467 /** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services
NYX 0:85b3fd62ea1a 1468 * @{
NYX 0:85b3fd62ea1a 1469 */
NYX 0:85b3fd62ea1a 1470
NYX 0:85b3fd62ea1a 1471 /**
NYX 0:85b3fd62ea1a 1472 * @brief Perform basic configuration of USART for enabling use in Asynchronous Mode (UART)
NYX 0:85b3fd62ea1a 1473 * @note In UART mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1474 * - LINEN bit in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1475 * - CLKEN bit in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1476 * - SCEN bit in the USART_CR3 register,
NYX 0:85b3fd62ea1a 1477 * - IREN bit in the USART_CR3 register,
NYX 0:85b3fd62ea1a 1478 * - HDSEL bit in the USART_CR3 register.
NYX 0:85b3fd62ea1a 1479 * @note Call of this function is equivalent to following function call sequence :
NYX 0:85b3fd62ea1a 1480 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
NYX 0:85b3fd62ea1a 1481 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
NYX 0:85b3fd62ea1a 1482 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
NYX 0:85b3fd62ea1a 1483 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
NYX 0:85b3fd62ea1a 1484 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
NYX 0:85b3fd62ea1a 1485 * @note Other remaining configurations items related to Asynchronous Mode
NYX 0:85b3fd62ea1a 1486 * (as Baud Rate, Word length, Parity, ...) should be set using
NYX 0:85b3fd62ea1a 1487 * dedicated functions
NYX 0:85b3fd62ea1a 1488 * @rmtoll CR2 LINEN LL_USART_ConfigAsyncMode\n
NYX 0:85b3fd62ea1a 1489 * CR2 CLKEN LL_USART_ConfigAsyncMode\n
NYX 0:85b3fd62ea1a 1490 * CR3 SCEN LL_USART_ConfigAsyncMode\n
NYX 0:85b3fd62ea1a 1491 * CR3 IREN LL_USART_ConfigAsyncMode\n
NYX 0:85b3fd62ea1a 1492 * CR3 HDSEL LL_USART_ConfigAsyncMode
NYX 0:85b3fd62ea1a 1493 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1494 * @retval None
NYX 0:85b3fd62ea1a 1495 */
NYX 0:85b3fd62ea1a 1496 __STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1497 {
NYX 0:85b3fd62ea1a 1498 /* In Asynchronous mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1499 - LINEN, CLKEN bits in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1500 - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/
NYX 0:85b3fd62ea1a 1501 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
NYX 0:85b3fd62ea1a 1502 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
NYX 0:85b3fd62ea1a 1503 }
NYX 0:85b3fd62ea1a 1504
NYX 0:85b3fd62ea1a 1505 /**
NYX 0:85b3fd62ea1a 1506 * @brief Perform basic configuration of USART for enabling use in Synchronous Mode
NYX 0:85b3fd62ea1a 1507 * @note In Synchronous mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1508 * - LINEN bit in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1509 * - SCEN bit in the USART_CR3 register,
NYX 0:85b3fd62ea1a 1510 * - IREN bit in the USART_CR3 register,
NYX 0:85b3fd62ea1a 1511 * - HDSEL bit in the USART_CR3 register.
NYX 0:85b3fd62ea1a 1512 * This function also sets the USART in Synchronous mode.
NYX 0:85b3fd62ea1a 1513 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1514 * Synchronous mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1515 * @note Call of this function is equivalent to following function call sequence :
NYX 0:85b3fd62ea1a 1516 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
NYX 0:85b3fd62ea1a 1517 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
NYX 0:85b3fd62ea1a 1518 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
NYX 0:85b3fd62ea1a 1519 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
NYX 0:85b3fd62ea1a 1520 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
NYX 0:85b3fd62ea1a 1521 * @note Other remaining configurations items related to Synchronous Mode
NYX 0:85b3fd62ea1a 1522 * (as Baud Rate, Word length, Parity, Clock Polarity, ...) should be set using
NYX 0:85b3fd62ea1a 1523 * dedicated functions
NYX 0:85b3fd62ea1a 1524 * @rmtoll CR2 LINEN LL_USART_ConfigSyncMode\n
NYX 0:85b3fd62ea1a 1525 * CR2 CLKEN LL_USART_ConfigSyncMode\n
NYX 0:85b3fd62ea1a 1526 * CR3 SCEN LL_USART_ConfigSyncMode\n
NYX 0:85b3fd62ea1a 1527 * CR3 IREN LL_USART_ConfigSyncMode\n
NYX 0:85b3fd62ea1a 1528 * CR3 HDSEL LL_USART_ConfigSyncMode
NYX 0:85b3fd62ea1a 1529 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1530 * @retval None
NYX 0:85b3fd62ea1a 1531 */
NYX 0:85b3fd62ea1a 1532 __STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1533 {
NYX 0:85b3fd62ea1a 1534 /* In Synchronous mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1535 - LINEN bit in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1536 - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/
NYX 0:85b3fd62ea1a 1537 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
NYX 0:85b3fd62ea1a 1538 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
NYX 0:85b3fd62ea1a 1539 /* set the UART/USART in Synchronous mode */
NYX 0:85b3fd62ea1a 1540 SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
NYX 0:85b3fd62ea1a 1541 }
NYX 0:85b3fd62ea1a 1542
NYX 0:85b3fd62ea1a 1543 /**
NYX 0:85b3fd62ea1a 1544 * @brief Perform basic configuration of USART for enabling use in LIN Mode
NYX 0:85b3fd62ea1a 1545 * @note In LIN mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1546 * - STOP and CLKEN bits in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1547 * - SCEN bit in the USART_CR3 register,
NYX 0:85b3fd62ea1a 1548 * - IREN bit in the USART_CR3 register,
NYX 0:85b3fd62ea1a 1549 * - HDSEL bit in the USART_CR3 register.
NYX 0:85b3fd62ea1a 1550 * This function also set the UART/USART in LIN mode.
NYX 0:85b3fd62ea1a 1551 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1552 * LIN feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1553 * @note Call of this function is equivalent to following function call sequence :
NYX 0:85b3fd62ea1a 1554 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
NYX 0:85b3fd62ea1a 1555 * - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
NYX 0:85b3fd62ea1a 1556 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
NYX 0:85b3fd62ea1a 1557 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
NYX 0:85b3fd62ea1a 1558 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
NYX 0:85b3fd62ea1a 1559 * - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function
NYX 0:85b3fd62ea1a 1560 * @note Other remaining configurations items related to LIN Mode
NYX 0:85b3fd62ea1a 1561 * (as Baud Rate, Word length, LIN Break Detection Length, ...) should be set using
NYX 0:85b3fd62ea1a 1562 * dedicated functions
NYX 0:85b3fd62ea1a 1563 * @rmtoll CR2 CLKEN LL_USART_ConfigLINMode\n
NYX 0:85b3fd62ea1a 1564 * CR2 STOP LL_USART_ConfigLINMode\n
NYX 0:85b3fd62ea1a 1565 * CR2 LINEN LL_USART_ConfigLINMode\n
NYX 0:85b3fd62ea1a 1566 * CR3 IREN LL_USART_ConfigLINMode\n
NYX 0:85b3fd62ea1a 1567 * CR3 SCEN LL_USART_ConfigLINMode\n
NYX 0:85b3fd62ea1a 1568 * CR3 HDSEL LL_USART_ConfigLINMode
NYX 0:85b3fd62ea1a 1569 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1570 * @retval None
NYX 0:85b3fd62ea1a 1571 */
NYX 0:85b3fd62ea1a 1572 __STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1573 {
NYX 0:85b3fd62ea1a 1574 /* In LIN mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1575 - STOP and CLKEN bits in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1576 - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/
NYX 0:85b3fd62ea1a 1577 CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP));
NYX 0:85b3fd62ea1a 1578 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL));
NYX 0:85b3fd62ea1a 1579 /* Set the UART/USART in LIN mode */
NYX 0:85b3fd62ea1a 1580 SET_BIT(USARTx->CR2, USART_CR2_LINEN);
NYX 0:85b3fd62ea1a 1581 }
NYX 0:85b3fd62ea1a 1582
NYX 0:85b3fd62ea1a 1583 /**
NYX 0:85b3fd62ea1a 1584 * @brief Perform basic configuration of USART for enabling use in Half Duplex Mode
NYX 0:85b3fd62ea1a 1585 * @note In Half Duplex mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1586 * - LINEN bit in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1587 * - CLKEN bit in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1588 * - SCEN bit in the USART_CR3 register,
NYX 0:85b3fd62ea1a 1589 * - IREN bit in the USART_CR3 register,
NYX 0:85b3fd62ea1a 1590 * This function also sets the UART/USART in Half Duplex mode.
NYX 0:85b3fd62ea1a 1591 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1592 * Half-Duplex mode is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1593 * @note Call of this function is equivalent to following function call sequence :
NYX 0:85b3fd62ea1a 1594 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
NYX 0:85b3fd62ea1a 1595 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
NYX 0:85b3fd62ea1a 1596 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
NYX 0:85b3fd62ea1a 1597 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
NYX 0:85b3fd62ea1a 1598 * - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function
NYX 0:85b3fd62ea1a 1599 * @note Other remaining configurations items related to Half Duplex Mode
NYX 0:85b3fd62ea1a 1600 * (as Baud Rate, Word length, Parity, ...) should be set using
NYX 0:85b3fd62ea1a 1601 * dedicated functions
NYX 0:85b3fd62ea1a 1602 * @rmtoll CR2 LINEN LL_USART_ConfigHalfDuplexMode\n
NYX 0:85b3fd62ea1a 1603 * CR2 CLKEN LL_USART_ConfigHalfDuplexMode\n
NYX 0:85b3fd62ea1a 1604 * CR3 HDSEL LL_USART_ConfigHalfDuplexMode\n
NYX 0:85b3fd62ea1a 1605 * CR3 SCEN LL_USART_ConfigHalfDuplexMode\n
NYX 0:85b3fd62ea1a 1606 * CR3 IREN LL_USART_ConfigHalfDuplexMode
NYX 0:85b3fd62ea1a 1607 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1608 * @retval None
NYX 0:85b3fd62ea1a 1609 */
NYX 0:85b3fd62ea1a 1610 __STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1611 {
NYX 0:85b3fd62ea1a 1612 /* In Half Duplex mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1613 - LINEN and CLKEN bits in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1614 - SCEN and IREN bits in the USART_CR3 register.*/
NYX 0:85b3fd62ea1a 1615 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
NYX 0:85b3fd62ea1a 1616 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN));
NYX 0:85b3fd62ea1a 1617 /* set the UART/USART in Half Duplex mode */
NYX 0:85b3fd62ea1a 1618 SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
NYX 0:85b3fd62ea1a 1619 }
NYX 0:85b3fd62ea1a 1620
NYX 0:85b3fd62ea1a 1621 /**
NYX 0:85b3fd62ea1a 1622 * @brief Perform basic configuration of USART for enabling use in Smartcard Mode
NYX 0:85b3fd62ea1a 1623 * @note In Smartcard mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1624 * - LINEN bit in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1625 * - IREN bit in the USART_CR3 register,
NYX 0:85b3fd62ea1a 1626 * - HDSEL bit in the USART_CR3 register.
NYX 0:85b3fd62ea1a 1627 * This function also configures Stop bits to 1.5 bits and
NYX 0:85b3fd62ea1a 1628 * sets the USART in Smartcard mode (SCEN bit).
NYX 0:85b3fd62ea1a 1629 * Clock Output is also enabled (CLKEN).
NYX 0:85b3fd62ea1a 1630 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1631 * Smartcard feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1632 * @note Call of this function is equivalent to following function call sequence :
NYX 0:85b3fd62ea1a 1633 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
NYX 0:85b3fd62ea1a 1634 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
NYX 0:85b3fd62ea1a 1635 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
NYX 0:85b3fd62ea1a 1636 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
NYX 0:85b3fd62ea1a 1637 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
NYX 0:85b3fd62ea1a 1638 * - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function
NYX 0:85b3fd62ea1a 1639 * @note Other remaining configurations items related to Smartcard Mode
NYX 0:85b3fd62ea1a 1640 * (as Baud Rate, Word length, Parity, ...) should be set using
NYX 0:85b3fd62ea1a 1641 * dedicated functions
NYX 0:85b3fd62ea1a 1642 * @rmtoll CR2 LINEN LL_USART_ConfigSmartcardMode\n
NYX 0:85b3fd62ea1a 1643 * CR2 STOP LL_USART_ConfigSmartcardMode\n
NYX 0:85b3fd62ea1a 1644 * CR2 CLKEN LL_USART_ConfigSmartcardMode\n
NYX 0:85b3fd62ea1a 1645 * CR3 HDSEL LL_USART_ConfigSmartcardMode\n
NYX 0:85b3fd62ea1a 1646 * CR3 SCEN LL_USART_ConfigSmartcardMode
NYX 0:85b3fd62ea1a 1647 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1648 * @retval None
NYX 0:85b3fd62ea1a 1649 */
NYX 0:85b3fd62ea1a 1650 __STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1651 {
NYX 0:85b3fd62ea1a 1652 /* In Smartcard mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1653 - LINEN bit in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1654 - IREN and HDSEL bits in the USART_CR3 register.*/
NYX 0:85b3fd62ea1a 1655 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
NYX 0:85b3fd62ea1a 1656 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL));
NYX 0:85b3fd62ea1a 1657 /* Configure Stop bits to 1.5 bits */
NYX 0:85b3fd62ea1a 1658 /* Synchronous mode is activated by default */
NYX 0:85b3fd62ea1a 1659 SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN));
NYX 0:85b3fd62ea1a 1660 /* set the UART/USART in Smartcard mode */
NYX 0:85b3fd62ea1a 1661 SET_BIT(USARTx->CR3, USART_CR3_SCEN);
NYX 0:85b3fd62ea1a 1662 }
NYX 0:85b3fd62ea1a 1663
NYX 0:85b3fd62ea1a 1664 /**
NYX 0:85b3fd62ea1a 1665 * @brief Perform basic configuration of USART for enabling use in Irda Mode
NYX 0:85b3fd62ea1a 1666 * @note In IRDA mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1667 * - LINEN bit in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1668 * - STOP and CLKEN bits in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1669 * - SCEN bit in the USART_CR3 register,
NYX 0:85b3fd62ea1a 1670 * - HDSEL bit in the USART_CR3 register.
NYX 0:85b3fd62ea1a 1671 * This function also sets the UART/USART in IRDA mode (IREN bit).
NYX 0:85b3fd62ea1a 1672 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1673 * IrDA feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1674 * @note Call of this function is equivalent to following function call sequence :
NYX 0:85b3fd62ea1a 1675 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
NYX 0:85b3fd62ea1a 1676 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
NYX 0:85b3fd62ea1a 1677 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
NYX 0:85b3fd62ea1a 1678 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
NYX 0:85b3fd62ea1a 1679 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
NYX 0:85b3fd62ea1a 1680 * - Set IREN in CR3 using @ref LL_USART_EnableIrda() function
NYX 0:85b3fd62ea1a 1681 * @note Other remaining configurations items related to Irda Mode
NYX 0:85b3fd62ea1a 1682 * (as Baud Rate, Word length, Power mode, ...) should be set using
NYX 0:85b3fd62ea1a 1683 * dedicated functions
NYX 0:85b3fd62ea1a 1684 * @rmtoll CR2 LINEN LL_USART_ConfigIrdaMode\n
NYX 0:85b3fd62ea1a 1685 * CR2 CLKEN LL_USART_ConfigIrdaMode\n
NYX 0:85b3fd62ea1a 1686 * CR2 STOP LL_USART_ConfigIrdaMode\n
NYX 0:85b3fd62ea1a 1687 * CR3 SCEN LL_USART_ConfigIrdaMode\n
NYX 0:85b3fd62ea1a 1688 * CR3 HDSEL LL_USART_ConfigIrdaMode\n
NYX 0:85b3fd62ea1a 1689 * CR3 IREN LL_USART_ConfigIrdaMode
NYX 0:85b3fd62ea1a 1690 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1691 * @retval None
NYX 0:85b3fd62ea1a 1692 */
NYX 0:85b3fd62ea1a 1693 __STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1694 {
NYX 0:85b3fd62ea1a 1695 /* In IRDA mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1696 - LINEN, STOP and CLKEN bits in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1697 - SCEN and HDSEL bits in the USART_CR3 register.*/
NYX 0:85b3fd62ea1a 1698 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP));
NYX 0:85b3fd62ea1a 1699 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
NYX 0:85b3fd62ea1a 1700 /* set the UART/USART in IRDA mode */
NYX 0:85b3fd62ea1a 1701 SET_BIT(USARTx->CR3, USART_CR3_IREN);
NYX 0:85b3fd62ea1a 1702 }
NYX 0:85b3fd62ea1a 1703
NYX 0:85b3fd62ea1a 1704 /**
NYX 0:85b3fd62ea1a 1705 * @brief Perform basic configuration of USART for enabling use in Multi processor Mode
NYX 0:85b3fd62ea1a 1706 * (several USARTs connected in a network, one of the USARTs can be the master,
NYX 0:85b3fd62ea1a 1707 * its TX output connected to the RX inputs of the other slaves USARTs).
NYX 0:85b3fd62ea1a 1708 * @note In MultiProcessor mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1709 * - LINEN bit in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1710 * - CLKEN bit in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1711 * - SCEN bit in the USART_CR3 register,
NYX 0:85b3fd62ea1a 1712 * - IREN bit in the USART_CR3 register,
NYX 0:85b3fd62ea1a 1713 * - HDSEL bit in the USART_CR3 register.
NYX 0:85b3fd62ea1a 1714 * @note Call of this function is equivalent to following function call sequence :
NYX 0:85b3fd62ea1a 1715 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
NYX 0:85b3fd62ea1a 1716 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
NYX 0:85b3fd62ea1a 1717 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
NYX 0:85b3fd62ea1a 1718 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
NYX 0:85b3fd62ea1a 1719 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
NYX 0:85b3fd62ea1a 1720 * @note Other remaining configurations items related to Multi processor Mode
NYX 0:85b3fd62ea1a 1721 * (as Baud Rate, Wake Up Method, Node address, ...) should be set using
NYX 0:85b3fd62ea1a 1722 * dedicated functions
NYX 0:85b3fd62ea1a 1723 * @rmtoll CR2 LINEN LL_USART_ConfigMultiProcessMode\n
NYX 0:85b3fd62ea1a 1724 * CR2 CLKEN LL_USART_ConfigMultiProcessMode\n
NYX 0:85b3fd62ea1a 1725 * CR3 SCEN LL_USART_ConfigMultiProcessMode\n
NYX 0:85b3fd62ea1a 1726 * CR3 HDSEL LL_USART_ConfigMultiProcessMode\n
NYX 0:85b3fd62ea1a 1727 * CR3 IREN LL_USART_ConfigMultiProcessMode
NYX 0:85b3fd62ea1a 1728 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1729 * @retval None
NYX 0:85b3fd62ea1a 1730 */
NYX 0:85b3fd62ea1a 1731 __STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1732 {
NYX 0:85b3fd62ea1a 1733 /* In Multi Processor mode, the following bits must be kept cleared:
NYX 0:85b3fd62ea1a 1734 - LINEN and CLKEN bits in the USART_CR2 register,
NYX 0:85b3fd62ea1a 1735 - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/
NYX 0:85b3fd62ea1a 1736 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
NYX 0:85b3fd62ea1a 1737 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN));
NYX 0:85b3fd62ea1a 1738 }
NYX 0:85b3fd62ea1a 1739
NYX 0:85b3fd62ea1a 1740 /**
NYX 0:85b3fd62ea1a 1741 * @}
NYX 0:85b3fd62ea1a 1742 */
NYX 0:85b3fd62ea1a 1743
NYX 0:85b3fd62ea1a 1744 /** @defgroup USART_LL_EF_FLAG_Management FLAG_Management
NYX 0:85b3fd62ea1a 1745 * @{
NYX 0:85b3fd62ea1a 1746 */
NYX 0:85b3fd62ea1a 1747
NYX 0:85b3fd62ea1a 1748 /**
NYX 0:85b3fd62ea1a 1749 * @brief Check if the USART Parity Error Flag is set or not
NYX 0:85b3fd62ea1a 1750 * @rmtoll SR PE LL_USART_IsActiveFlag_PE
NYX 0:85b3fd62ea1a 1751 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1752 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1753 */
NYX 0:85b3fd62ea1a 1754 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1755 {
NYX 0:85b3fd62ea1a 1756 return (READ_BIT(USARTx->SR, USART_SR_PE) == (USART_SR_PE));
NYX 0:85b3fd62ea1a 1757 }
NYX 0:85b3fd62ea1a 1758
NYX 0:85b3fd62ea1a 1759 /**
NYX 0:85b3fd62ea1a 1760 * @brief Check if the USART Framing Error Flag is set or not
NYX 0:85b3fd62ea1a 1761 * @rmtoll SR FE LL_USART_IsActiveFlag_FE
NYX 0:85b3fd62ea1a 1762 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1763 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1764 */
NYX 0:85b3fd62ea1a 1765 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1766 {
NYX 0:85b3fd62ea1a 1767 return (READ_BIT(USARTx->SR, USART_SR_FE) == (USART_SR_FE));
NYX 0:85b3fd62ea1a 1768 }
NYX 0:85b3fd62ea1a 1769
NYX 0:85b3fd62ea1a 1770 /**
NYX 0:85b3fd62ea1a 1771 * @brief Check if the USART Noise error detected Flag is set or not
NYX 0:85b3fd62ea1a 1772 * @rmtoll SR NF LL_USART_IsActiveFlag_NE
NYX 0:85b3fd62ea1a 1773 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1774 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1775 */
NYX 0:85b3fd62ea1a 1776 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1777 {
NYX 0:85b3fd62ea1a 1778 return (READ_BIT(USARTx->SR, USART_SR_NE) == (USART_SR_NE));
NYX 0:85b3fd62ea1a 1779 }
NYX 0:85b3fd62ea1a 1780
NYX 0:85b3fd62ea1a 1781 /**
NYX 0:85b3fd62ea1a 1782 * @brief Check if the USART OverRun Error Flag is set or not
NYX 0:85b3fd62ea1a 1783 * @rmtoll SR ORE LL_USART_IsActiveFlag_ORE
NYX 0:85b3fd62ea1a 1784 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1785 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1786 */
NYX 0:85b3fd62ea1a 1787 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1788 {
NYX 0:85b3fd62ea1a 1789 return (READ_BIT(USARTx->SR, USART_SR_ORE) == (USART_SR_ORE));
NYX 0:85b3fd62ea1a 1790 }
NYX 0:85b3fd62ea1a 1791
NYX 0:85b3fd62ea1a 1792 /**
NYX 0:85b3fd62ea1a 1793 * @brief Check if the USART IDLE line detected Flag is set or not
NYX 0:85b3fd62ea1a 1794 * @rmtoll SR IDLE LL_USART_IsActiveFlag_IDLE
NYX 0:85b3fd62ea1a 1795 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1796 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1797 */
NYX 0:85b3fd62ea1a 1798 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1799 {
NYX 0:85b3fd62ea1a 1800 return (READ_BIT(USARTx->SR, USART_SR_IDLE) == (USART_SR_IDLE));
NYX 0:85b3fd62ea1a 1801 }
NYX 0:85b3fd62ea1a 1802
NYX 0:85b3fd62ea1a 1803 /**
NYX 0:85b3fd62ea1a 1804 * @brief Check if the USART Read Data Register Not Empty Flag is set or not
NYX 0:85b3fd62ea1a 1805 * @rmtoll SR RXNE LL_USART_IsActiveFlag_RXNE
NYX 0:85b3fd62ea1a 1806 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1807 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1808 */
NYX 0:85b3fd62ea1a 1809 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1810 {
NYX 0:85b3fd62ea1a 1811 return (READ_BIT(USARTx->SR, USART_SR_RXNE) == (USART_SR_RXNE));
NYX 0:85b3fd62ea1a 1812 }
NYX 0:85b3fd62ea1a 1813
NYX 0:85b3fd62ea1a 1814 /**
NYX 0:85b3fd62ea1a 1815 * @brief Check if the USART Transmission Complete Flag is set or not
NYX 0:85b3fd62ea1a 1816 * @rmtoll SR TC LL_USART_IsActiveFlag_TC
NYX 0:85b3fd62ea1a 1817 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1818 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1819 */
NYX 0:85b3fd62ea1a 1820 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1821 {
NYX 0:85b3fd62ea1a 1822 return (READ_BIT(USARTx->SR, USART_SR_TC) == (USART_SR_TC));
NYX 0:85b3fd62ea1a 1823 }
NYX 0:85b3fd62ea1a 1824
NYX 0:85b3fd62ea1a 1825 /**
NYX 0:85b3fd62ea1a 1826 * @brief Check if the USART Transmit Data Register Empty Flag is set or not
NYX 0:85b3fd62ea1a 1827 * @rmtoll SR TXE LL_USART_IsActiveFlag_TXE
NYX 0:85b3fd62ea1a 1828 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1829 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1830 */
NYX 0:85b3fd62ea1a 1831 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1832 {
NYX 0:85b3fd62ea1a 1833 return (READ_BIT(USARTx->SR, USART_SR_TXE) == (USART_SR_TXE));
NYX 0:85b3fd62ea1a 1834 }
NYX 0:85b3fd62ea1a 1835
NYX 0:85b3fd62ea1a 1836 /**
NYX 0:85b3fd62ea1a 1837 * @brief Check if the USART LIN Break Detection Flag is set or not
NYX 0:85b3fd62ea1a 1838 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1839 * LIN feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1840 * @rmtoll SR LBD LL_USART_IsActiveFlag_LBD
NYX 0:85b3fd62ea1a 1841 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1842 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1843 */
NYX 0:85b3fd62ea1a 1844 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1845 {
NYX 0:85b3fd62ea1a 1846 return (READ_BIT(USARTx->SR, USART_SR_LBD) == (USART_SR_LBD));
NYX 0:85b3fd62ea1a 1847 }
NYX 0:85b3fd62ea1a 1848
NYX 0:85b3fd62ea1a 1849 /**
NYX 0:85b3fd62ea1a 1850 * @brief Check if the USART CTS Flag is set or not
NYX 0:85b3fd62ea1a 1851 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 1852 * Hardware Flow control feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 1853 * @rmtoll SR CTS LL_USART_IsActiveFlag_nCTS
NYX 0:85b3fd62ea1a 1854 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1855 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1856 */
NYX 0:85b3fd62ea1a 1857 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1858 {
NYX 0:85b3fd62ea1a 1859 return (READ_BIT(USARTx->SR, USART_SR_CTS) == (USART_SR_CTS));
NYX 0:85b3fd62ea1a 1860 }
NYX 0:85b3fd62ea1a 1861
NYX 0:85b3fd62ea1a 1862 /**
NYX 0:85b3fd62ea1a 1863 * @brief Check if the USART Send Break Flag is set or not
NYX 0:85b3fd62ea1a 1864 * @rmtoll CR1 SBK LL_USART_IsActiveFlag_SBK
NYX 0:85b3fd62ea1a 1865 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1866 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1867 */
NYX 0:85b3fd62ea1a 1868 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1869 {
NYX 0:85b3fd62ea1a 1870 return (READ_BIT(USARTx->CR1, USART_CR1_SBK) == (USART_CR1_SBK));
NYX 0:85b3fd62ea1a 1871 }
NYX 0:85b3fd62ea1a 1872
NYX 0:85b3fd62ea1a 1873 /**
NYX 0:85b3fd62ea1a 1874 * @brief Check if the USART Receive Wake Up from mute mode Flag is set or not
NYX 0:85b3fd62ea1a 1875 * @rmtoll CR1 RWU LL_USART_IsActiveFlag_RWU
NYX 0:85b3fd62ea1a 1876 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1877 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 1878 */
NYX 0:85b3fd62ea1a 1879 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1880 {
NYX 0:85b3fd62ea1a 1881 return (READ_BIT(USARTx->CR1, USART_CR1_RWU) == (USART_CR1_RWU));
NYX 0:85b3fd62ea1a 1882 }
NYX 0:85b3fd62ea1a 1883
NYX 0:85b3fd62ea1a 1884 /**
NYX 0:85b3fd62ea1a 1885 * @brief Clear Parity Error Flag
NYX 0:85b3fd62ea1a 1886 * @note Clearing this flag is done by a read access to the USARTx_SR
NYX 0:85b3fd62ea1a 1887 * register followed by a read access to the USARTx_DR register.
NYX 0:85b3fd62ea1a 1888 * @note Please also consider that when clearing this flag, other flags as
NYX 0:85b3fd62ea1a 1889 * NE, FE, ORE, IDLE would also be cleared.
NYX 0:85b3fd62ea1a 1890 * @rmtoll SR PE LL_USART_ClearFlag_PE
NYX 0:85b3fd62ea1a 1891 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1892 * @retval None
NYX 0:85b3fd62ea1a 1893 */
NYX 0:85b3fd62ea1a 1894 __STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1895 {
NYX 0:85b3fd62ea1a 1896 __IO uint32_t tmpreg;
NYX 0:85b3fd62ea1a 1897 tmpreg = USARTx->SR;
NYX 0:85b3fd62ea1a 1898 (void) tmpreg;
NYX 0:85b3fd62ea1a 1899 tmpreg = USARTx->DR;
NYX 0:85b3fd62ea1a 1900 (void) tmpreg;
NYX 0:85b3fd62ea1a 1901 }
NYX 0:85b3fd62ea1a 1902
NYX 0:85b3fd62ea1a 1903 /**
NYX 0:85b3fd62ea1a 1904 * @brief Clear Framing Error Flag
NYX 0:85b3fd62ea1a 1905 * @note Clearing this flag is done by a read access to the USARTx_SR
NYX 0:85b3fd62ea1a 1906 * register followed by a read access to the USARTx_DR register.
NYX 0:85b3fd62ea1a 1907 * @note Please also consider that when clearing this flag, other flags as
NYX 0:85b3fd62ea1a 1908 * PE, NE, ORE, IDLE would also be cleared.
NYX 0:85b3fd62ea1a 1909 * @rmtoll SR FE LL_USART_ClearFlag_FE
NYX 0:85b3fd62ea1a 1910 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1911 * @retval None
NYX 0:85b3fd62ea1a 1912 */
NYX 0:85b3fd62ea1a 1913 __STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1914 {
NYX 0:85b3fd62ea1a 1915 __IO uint32_t tmpreg;
NYX 0:85b3fd62ea1a 1916 tmpreg = USARTx->SR;
NYX 0:85b3fd62ea1a 1917 (void) tmpreg;
NYX 0:85b3fd62ea1a 1918 tmpreg = USARTx->DR;
NYX 0:85b3fd62ea1a 1919 (void) tmpreg;
NYX 0:85b3fd62ea1a 1920 }
NYX 0:85b3fd62ea1a 1921
NYX 0:85b3fd62ea1a 1922 /**
NYX 0:85b3fd62ea1a 1923 * @brief Clear Noise detected Flag
NYX 0:85b3fd62ea1a 1924 * @note Clearing this flag is done by a read access to the USARTx_SR
NYX 0:85b3fd62ea1a 1925 * register followed by a read access to the USARTx_DR register.
NYX 0:85b3fd62ea1a 1926 * @note Please also consider that when clearing this flag, other flags as
NYX 0:85b3fd62ea1a 1927 * PE, FE, ORE, IDLE would also be cleared.
NYX 0:85b3fd62ea1a 1928 * @rmtoll SR NF LL_USART_ClearFlag_NE
NYX 0:85b3fd62ea1a 1929 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1930 * @retval None
NYX 0:85b3fd62ea1a 1931 */
NYX 0:85b3fd62ea1a 1932 __STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1933 {
NYX 0:85b3fd62ea1a 1934 __IO uint32_t tmpreg;
NYX 0:85b3fd62ea1a 1935 tmpreg = USARTx->SR;
NYX 0:85b3fd62ea1a 1936 (void) tmpreg;
NYX 0:85b3fd62ea1a 1937 tmpreg = USARTx->DR;
NYX 0:85b3fd62ea1a 1938 (void) tmpreg;
NYX 0:85b3fd62ea1a 1939 }
NYX 0:85b3fd62ea1a 1940
NYX 0:85b3fd62ea1a 1941 /**
NYX 0:85b3fd62ea1a 1942 * @brief Clear OverRun Error Flag
NYX 0:85b3fd62ea1a 1943 * @note Clearing this flag is done by a read access to the USARTx_SR
NYX 0:85b3fd62ea1a 1944 * register followed by a read access to the USARTx_DR register.
NYX 0:85b3fd62ea1a 1945 * @note Please also consider that when clearing this flag, other flags as
NYX 0:85b3fd62ea1a 1946 * PE, NE, FE, IDLE would also be cleared.
NYX 0:85b3fd62ea1a 1947 * @rmtoll SR ORE LL_USART_ClearFlag_ORE
NYX 0:85b3fd62ea1a 1948 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1949 * @retval None
NYX 0:85b3fd62ea1a 1950 */
NYX 0:85b3fd62ea1a 1951 __STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1952 {
NYX 0:85b3fd62ea1a 1953 __IO uint32_t tmpreg;
NYX 0:85b3fd62ea1a 1954 tmpreg = USARTx->SR;
NYX 0:85b3fd62ea1a 1955 (void) tmpreg;
NYX 0:85b3fd62ea1a 1956 tmpreg = USARTx->DR;
NYX 0:85b3fd62ea1a 1957 (void) tmpreg;
NYX 0:85b3fd62ea1a 1958 }
NYX 0:85b3fd62ea1a 1959
NYX 0:85b3fd62ea1a 1960 /**
NYX 0:85b3fd62ea1a 1961 * @brief Clear IDLE line detected Flag
NYX 0:85b3fd62ea1a 1962 * @note Clearing this flag is done by a read access to the USARTx_SR
NYX 0:85b3fd62ea1a 1963 * register followed by a read access to the USARTx_DR register.
NYX 0:85b3fd62ea1a 1964 * @note Please also consider that when clearing this flag, other flags as
NYX 0:85b3fd62ea1a 1965 * PE, NE, FE, ORE would also be cleared.
NYX 0:85b3fd62ea1a 1966 * @rmtoll SR IDLE LL_USART_ClearFlag_IDLE
NYX 0:85b3fd62ea1a 1967 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1968 * @retval None
NYX 0:85b3fd62ea1a 1969 */
NYX 0:85b3fd62ea1a 1970 __STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1971 {
NYX 0:85b3fd62ea1a 1972 __IO uint32_t tmpreg;
NYX 0:85b3fd62ea1a 1973 tmpreg = USARTx->SR;
NYX 0:85b3fd62ea1a 1974 (void) tmpreg;
NYX 0:85b3fd62ea1a 1975 tmpreg = USARTx->DR;
NYX 0:85b3fd62ea1a 1976 (void) tmpreg;
NYX 0:85b3fd62ea1a 1977 }
NYX 0:85b3fd62ea1a 1978
NYX 0:85b3fd62ea1a 1979 /**
NYX 0:85b3fd62ea1a 1980 * @brief Clear Transmission Complete Flag
NYX 0:85b3fd62ea1a 1981 * @rmtoll SR TC LL_USART_ClearFlag_TC
NYX 0:85b3fd62ea1a 1982 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1983 * @retval None
NYX 0:85b3fd62ea1a 1984 */
NYX 0:85b3fd62ea1a 1985 __STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1986 {
NYX 0:85b3fd62ea1a 1987 WRITE_REG(USARTx->SR , ~(USART_SR_TC));
NYX 0:85b3fd62ea1a 1988 }
NYX 0:85b3fd62ea1a 1989
NYX 0:85b3fd62ea1a 1990 /**
NYX 0:85b3fd62ea1a 1991 * @brief Clear RX Not Empty Flag
NYX 0:85b3fd62ea1a 1992 * @rmtoll SR RXNE LL_USART_ClearFlag_RXNE
NYX 0:85b3fd62ea1a 1993 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 1994 * @retval None
NYX 0:85b3fd62ea1a 1995 */
NYX 0:85b3fd62ea1a 1996 __STATIC_INLINE void LL_USART_ClearFlag_RXNE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 1997 {
NYX 0:85b3fd62ea1a 1998 WRITE_REG(USARTx->SR , ~(USART_SR_RXNE));
NYX 0:85b3fd62ea1a 1999 }
NYX 0:85b3fd62ea1a 2000
NYX 0:85b3fd62ea1a 2001 /**
NYX 0:85b3fd62ea1a 2002 * @brief Clear LIN Break Detection Flag
NYX 0:85b3fd62ea1a 2003 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 2004 * LIN feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 2005 * @rmtoll SR LBD LL_USART_ClearFlag_LBD
NYX 0:85b3fd62ea1a 2006 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2007 * @retval None
NYX 0:85b3fd62ea1a 2008 */
NYX 0:85b3fd62ea1a 2009 __STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2010 {
NYX 0:85b3fd62ea1a 2011 WRITE_REG(USARTx->SR , ~(USART_SR_LBD));
NYX 0:85b3fd62ea1a 2012 }
NYX 0:85b3fd62ea1a 2013
NYX 0:85b3fd62ea1a 2014 /**
NYX 0:85b3fd62ea1a 2015 * @brief Clear CTS Interrupt Flag
NYX 0:85b3fd62ea1a 2016 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 2017 * Hardware Flow control feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 2018 * @rmtoll SR CTS LL_USART_ClearFlag_nCTS
NYX 0:85b3fd62ea1a 2019 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2020 * @retval None
NYX 0:85b3fd62ea1a 2021 */
NYX 0:85b3fd62ea1a 2022 __STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2023 {
NYX 0:85b3fd62ea1a 2024 WRITE_REG(USARTx->SR , ~(USART_SR_CTS));
NYX 0:85b3fd62ea1a 2025 }
NYX 0:85b3fd62ea1a 2026
NYX 0:85b3fd62ea1a 2027 /**
NYX 0:85b3fd62ea1a 2028 * @}
NYX 0:85b3fd62ea1a 2029 */
NYX 0:85b3fd62ea1a 2030
NYX 0:85b3fd62ea1a 2031 /** @defgroup USART_LL_EF_IT_Management IT_Management
NYX 0:85b3fd62ea1a 2032 * @{
NYX 0:85b3fd62ea1a 2033 */
NYX 0:85b3fd62ea1a 2034
NYX 0:85b3fd62ea1a 2035 /**
NYX 0:85b3fd62ea1a 2036 * @brief Enable IDLE Interrupt
NYX 0:85b3fd62ea1a 2037 * @rmtoll CR1 IDLEIE LL_USART_EnableIT_IDLE
NYX 0:85b3fd62ea1a 2038 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2039 * @retval None
NYX 0:85b3fd62ea1a 2040 */
NYX 0:85b3fd62ea1a 2041 __STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2042 {
NYX 0:85b3fd62ea1a 2043 SET_BIT(USARTx->CR1, USART_CR1_IDLEIE);
NYX 0:85b3fd62ea1a 2044 }
NYX 0:85b3fd62ea1a 2045
NYX 0:85b3fd62ea1a 2046 /**
NYX 0:85b3fd62ea1a 2047 * @brief Enable RX Not Empty Interrupt
NYX 0:85b3fd62ea1a 2048 * @rmtoll CR1 RXNEIE LL_USART_EnableIT_RXNE
NYX 0:85b3fd62ea1a 2049 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2050 * @retval None
NYX 0:85b3fd62ea1a 2051 */
NYX 0:85b3fd62ea1a 2052 __STATIC_INLINE void LL_USART_EnableIT_RXNE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2053 {
NYX 0:85b3fd62ea1a 2054 SET_BIT(USARTx->CR1, USART_CR1_RXNEIE);
NYX 0:85b3fd62ea1a 2055 }
NYX 0:85b3fd62ea1a 2056
NYX 0:85b3fd62ea1a 2057 /**
NYX 0:85b3fd62ea1a 2058 * @brief Enable Transmission Complete Interrupt
NYX 0:85b3fd62ea1a 2059 * @rmtoll CR1 TCIE LL_USART_EnableIT_TC
NYX 0:85b3fd62ea1a 2060 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2061 * @retval None
NYX 0:85b3fd62ea1a 2062 */
NYX 0:85b3fd62ea1a 2063 __STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2064 {
NYX 0:85b3fd62ea1a 2065 SET_BIT(USARTx->CR1, USART_CR1_TCIE);
NYX 0:85b3fd62ea1a 2066 }
NYX 0:85b3fd62ea1a 2067
NYX 0:85b3fd62ea1a 2068 /**
NYX 0:85b3fd62ea1a 2069 * @brief Enable TX Empty Interrupt
NYX 0:85b3fd62ea1a 2070 * @rmtoll CR1 TXEIE LL_USART_EnableIT_TXE
NYX 0:85b3fd62ea1a 2071 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2072 * @retval None
NYX 0:85b3fd62ea1a 2073 */
NYX 0:85b3fd62ea1a 2074 __STATIC_INLINE void LL_USART_EnableIT_TXE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2075 {
NYX 0:85b3fd62ea1a 2076 SET_BIT(USARTx->CR1, USART_CR1_TXEIE);
NYX 0:85b3fd62ea1a 2077 }
NYX 0:85b3fd62ea1a 2078
NYX 0:85b3fd62ea1a 2079 /**
NYX 0:85b3fd62ea1a 2080 * @brief Enable Parity Error Interrupt
NYX 0:85b3fd62ea1a 2081 * @rmtoll CR1 PEIE LL_USART_EnableIT_PE
NYX 0:85b3fd62ea1a 2082 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2083 * @retval None
NYX 0:85b3fd62ea1a 2084 */
NYX 0:85b3fd62ea1a 2085 __STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2086 {
NYX 0:85b3fd62ea1a 2087 SET_BIT(USARTx->CR1, USART_CR1_PEIE);
NYX 0:85b3fd62ea1a 2088 }
NYX 0:85b3fd62ea1a 2089
NYX 0:85b3fd62ea1a 2090 /**
NYX 0:85b3fd62ea1a 2091 * @brief Enable LIN Break Detection Interrupt
NYX 0:85b3fd62ea1a 2092 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 2093 * LIN feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 2094 * @rmtoll CR2 LBDIE LL_USART_EnableIT_LBD
NYX 0:85b3fd62ea1a 2095 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2096 * @retval None
NYX 0:85b3fd62ea1a 2097 */
NYX 0:85b3fd62ea1a 2098 __STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2099 {
NYX 0:85b3fd62ea1a 2100 SET_BIT(USARTx->CR2, USART_CR2_LBDIE);
NYX 0:85b3fd62ea1a 2101 }
NYX 0:85b3fd62ea1a 2102
NYX 0:85b3fd62ea1a 2103 /**
NYX 0:85b3fd62ea1a 2104 * @brief Enable Error Interrupt
NYX 0:85b3fd62ea1a 2105 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
NYX 0:85b3fd62ea1a 2106 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_SR register).
NYX 0:85b3fd62ea1a 2107 * 0: Interrupt is inhibited
NYX 0:85b3fd62ea1a 2108 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_SR register.
NYX 0:85b3fd62ea1a 2109 * @rmtoll CR3 EIE LL_USART_EnableIT_ERROR
NYX 0:85b3fd62ea1a 2110 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2111 * @retval None
NYX 0:85b3fd62ea1a 2112 */
NYX 0:85b3fd62ea1a 2113 __STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2114 {
NYX 0:85b3fd62ea1a 2115 SET_BIT(USARTx->CR3, USART_CR3_EIE);
NYX 0:85b3fd62ea1a 2116 }
NYX 0:85b3fd62ea1a 2117
NYX 0:85b3fd62ea1a 2118 /**
NYX 0:85b3fd62ea1a 2119 * @brief Enable CTS Interrupt
NYX 0:85b3fd62ea1a 2120 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 2121 * Hardware Flow control feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 2122 * @rmtoll CR3 CTSIE LL_USART_EnableIT_CTS
NYX 0:85b3fd62ea1a 2123 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2124 * @retval None
NYX 0:85b3fd62ea1a 2125 */
NYX 0:85b3fd62ea1a 2126 __STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2127 {
NYX 0:85b3fd62ea1a 2128 SET_BIT(USARTx->CR3, USART_CR3_CTSIE);
NYX 0:85b3fd62ea1a 2129 }
NYX 0:85b3fd62ea1a 2130
NYX 0:85b3fd62ea1a 2131 /**
NYX 0:85b3fd62ea1a 2132 * @brief Disable IDLE Interrupt
NYX 0:85b3fd62ea1a 2133 * @rmtoll CR1 IDLEIE LL_USART_DisableIT_IDLE
NYX 0:85b3fd62ea1a 2134 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2135 * @retval None
NYX 0:85b3fd62ea1a 2136 */
NYX 0:85b3fd62ea1a 2137 __STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2138 {
NYX 0:85b3fd62ea1a 2139 CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE);
NYX 0:85b3fd62ea1a 2140 }
NYX 0:85b3fd62ea1a 2141
NYX 0:85b3fd62ea1a 2142 /**
NYX 0:85b3fd62ea1a 2143 * @brief Disable RX Not Empty Interrupt
NYX 0:85b3fd62ea1a 2144 * @rmtoll CR1 RXNEIE LL_USART_DisableIT_RXNE
NYX 0:85b3fd62ea1a 2145 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2146 * @retval None
NYX 0:85b3fd62ea1a 2147 */
NYX 0:85b3fd62ea1a 2148 __STATIC_INLINE void LL_USART_DisableIT_RXNE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2149 {
NYX 0:85b3fd62ea1a 2150 CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE);
NYX 0:85b3fd62ea1a 2151 }
NYX 0:85b3fd62ea1a 2152
NYX 0:85b3fd62ea1a 2153 /**
NYX 0:85b3fd62ea1a 2154 * @brief Disable Transmission Complete Interrupt
NYX 0:85b3fd62ea1a 2155 * @rmtoll CR1 TCIE LL_USART_DisableIT_TC
NYX 0:85b3fd62ea1a 2156 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2157 * @retval None
NYX 0:85b3fd62ea1a 2158 */
NYX 0:85b3fd62ea1a 2159 __STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2160 {
NYX 0:85b3fd62ea1a 2161 CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE);
NYX 0:85b3fd62ea1a 2162 }
NYX 0:85b3fd62ea1a 2163
NYX 0:85b3fd62ea1a 2164 /**
NYX 0:85b3fd62ea1a 2165 * @brief Disable TX Empty Interrupt
NYX 0:85b3fd62ea1a 2166 * @rmtoll CR1 TXEIE LL_USART_DisableIT_TXE
NYX 0:85b3fd62ea1a 2167 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2168 * @retval None
NYX 0:85b3fd62ea1a 2169 */
NYX 0:85b3fd62ea1a 2170 __STATIC_INLINE void LL_USART_DisableIT_TXE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2171 {
NYX 0:85b3fd62ea1a 2172 CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE);
NYX 0:85b3fd62ea1a 2173 }
NYX 0:85b3fd62ea1a 2174
NYX 0:85b3fd62ea1a 2175 /**
NYX 0:85b3fd62ea1a 2176 * @brief Disable Parity Error Interrupt
NYX 0:85b3fd62ea1a 2177 * @rmtoll CR1 PEIE LL_USART_DisableIT_PE
NYX 0:85b3fd62ea1a 2178 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2179 * @retval None
NYX 0:85b3fd62ea1a 2180 */
NYX 0:85b3fd62ea1a 2181 __STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2182 {
NYX 0:85b3fd62ea1a 2183 CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE);
NYX 0:85b3fd62ea1a 2184 }
NYX 0:85b3fd62ea1a 2185
NYX 0:85b3fd62ea1a 2186 /**
NYX 0:85b3fd62ea1a 2187 * @brief Disable LIN Break Detection Interrupt
NYX 0:85b3fd62ea1a 2188 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 2189 * LIN feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 2190 * @rmtoll CR2 LBDIE LL_USART_DisableIT_LBD
NYX 0:85b3fd62ea1a 2191 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2192 * @retval None
NYX 0:85b3fd62ea1a 2193 */
NYX 0:85b3fd62ea1a 2194 __STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2195 {
NYX 0:85b3fd62ea1a 2196 CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE);
NYX 0:85b3fd62ea1a 2197 }
NYX 0:85b3fd62ea1a 2198
NYX 0:85b3fd62ea1a 2199 /**
NYX 0:85b3fd62ea1a 2200 * @brief Disable Error Interrupt
NYX 0:85b3fd62ea1a 2201 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
NYX 0:85b3fd62ea1a 2202 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_SR register).
NYX 0:85b3fd62ea1a 2203 * 0: Interrupt is inhibited
NYX 0:85b3fd62ea1a 2204 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_SR register.
NYX 0:85b3fd62ea1a 2205 * @rmtoll CR3 EIE LL_USART_DisableIT_ERROR
NYX 0:85b3fd62ea1a 2206 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2207 * @retval None
NYX 0:85b3fd62ea1a 2208 */
NYX 0:85b3fd62ea1a 2209 __STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2210 {
NYX 0:85b3fd62ea1a 2211 CLEAR_BIT(USARTx->CR3, USART_CR3_EIE);
NYX 0:85b3fd62ea1a 2212 }
NYX 0:85b3fd62ea1a 2213
NYX 0:85b3fd62ea1a 2214 /**
NYX 0:85b3fd62ea1a 2215 * @brief Disable CTS Interrupt
NYX 0:85b3fd62ea1a 2216 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 2217 * Hardware Flow control feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 2218 * @rmtoll CR3 CTSIE LL_USART_DisableIT_CTS
NYX 0:85b3fd62ea1a 2219 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2220 * @retval None
NYX 0:85b3fd62ea1a 2221 */
NYX 0:85b3fd62ea1a 2222 __STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2223 {
NYX 0:85b3fd62ea1a 2224 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE);
NYX 0:85b3fd62ea1a 2225 }
NYX 0:85b3fd62ea1a 2226
NYX 0:85b3fd62ea1a 2227 /**
NYX 0:85b3fd62ea1a 2228 * @brief Check if the USART IDLE Interrupt source is enabled or disabled.
NYX 0:85b3fd62ea1a 2229 * @rmtoll CR1 IDLEIE LL_USART_IsEnabledIT_IDLE
NYX 0:85b3fd62ea1a 2230 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2231 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 2232 */
NYX 0:85b3fd62ea1a 2233 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2234 {
NYX 0:85b3fd62ea1a 2235 return (READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE));
NYX 0:85b3fd62ea1a 2236 }
NYX 0:85b3fd62ea1a 2237
NYX 0:85b3fd62ea1a 2238 /**
NYX 0:85b3fd62ea1a 2239 * @brief Check if the USART RX Not Empty Interrupt is enabled or disabled.
NYX 0:85b3fd62ea1a 2240 * @rmtoll CR1 RXNEIE LL_USART_IsEnabledIT_RXNE
NYX 0:85b3fd62ea1a 2241 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2242 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 2243 */
NYX 0:85b3fd62ea1a 2244 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2245 {
NYX 0:85b3fd62ea1a 2246 return (READ_BIT(USARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE));
NYX 0:85b3fd62ea1a 2247 }
NYX 0:85b3fd62ea1a 2248
NYX 0:85b3fd62ea1a 2249 /**
NYX 0:85b3fd62ea1a 2250 * @brief Check if the USART Transmission Complete Interrupt is enabled or disabled.
NYX 0:85b3fd62ea1a 2251 * @rmtoll CR1 TCIE LL_USART_IsEnabledIT_TC
NYX 0:85b3fd62ea1a 2252 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2253 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 2254 */
NYX 0:85b3fd62ea1a 2255 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2256 {
NYX 0:85b3fd62ea1a 2257 return (READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE));
NYX 0:85b3fd62ea1a 2258 }
NYX 0:85b3fd62ea1a 2259
NYX 0:85b3fd62ea1a 2260 /**
NYX 0:85b3fd62ea1a 2261 * @brief Check if the USART TX Empty Interrupt is enabled or disabled.
NYX 0:85b3fd62ea1a 2262 * @rmtoll CR1 TXEIE LL_USART_IsEnabledIT_TXE
NYX 0:85b3fd62ea1a 2263 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2264 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 2265 */
NYX 0:85b3fd62ea1a 2266 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2267 {
NYX 0:85b3fd62ea1a 2268 return (READ_BIT(USARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE));
NYX 0:85b3fd62ea1a 2269 }
NYX 0:85b3fd62ea1a 2270
NYX 0:85b3fd62ea1a 2271 /**
NYX 0:85b3fd62ea1a 2272 * @brief Check if the USART Parity Error Interrupt is enabled or disabled.
NYX 0:85b3fd62ea1a 2273 * @rmtoll CR1 PEIE LL_USART_IsEnabledIT_PE
NYX 0:85b3fd62ea1a 2274 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2275 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 2276 */
NYX 0:85b3fd62ea1a 2277 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2278 {
NYX 0:85b3fd62ea1a 2279 return (READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE));
NYX 0:85b3fd62ea1a 2280 }
NYX 0:85b3fd62ea1a 2281
NYX 0:85b3fd62ea1a 2282 /**
NYX 0:85b3fd62ea1a 2283 * @brief Check if the USART LIN Break Detection Interrupt is enabled or disabled.
NYX 0:85b3fd62ea1a 2284 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 2285 * LIN feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 2286 * @rmtoll CR2 LBDIE LL_USART_IsEnabledIT_LBD
NYX 0:85b3fd62ea1a 2287 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2288 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 2289 */
NYX 0:85b3fd62ea1a 2290 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2291 {
NYX 0:85b3fd62ea1a 2292 return (READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE));
NYX 0:85b3fd62ea1a 2293 }
NYX 0:85b3fd62ea1a 2294
NYX 0:85b3fd62ea1a 2295 /**
NYX 0:85b3fd62ea1a 2296 * @brief Check if the USART Error Interrupt is enabled or disabled.
NYX 0:85b3fd62ea1a 2297 * @rmtoll CR3 EIE LL_USART_IsEnabledIT_ERROR
NYX 0:85b3fd62ea1a 2298 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2299 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 2300 */
NYX 0:85b3fd62ea1a 2301 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2302 {
NYX 0:85b3fd62ea1a 2303 return (READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE));
NYX 0:85b3fd62ea1a 2304 }
NYX 0:85b3fd62ea1a 2305
NYX 0:85b3fd62ea1a 2306 /**
NYX 0:85b3fd62ea1a 2307 * @brief Check if the USART CTS Interrupt is enabled or disabled.
NYX 0:85b3fd62ea1a 2308 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
NYX 0:85b3fd62ea1a 2309 * Hardware Flow control feature is supported by the USARTx instance.
NYX 0:85b3fd62ea1a 2310 * @rmtoll CR3 CTSIE LL_USART_IsEnabledIT_CTS
NYX 0:85b3fd62ea1a 2311 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2312 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 2313 */
NYX 0:85b3fd62ea1a 2314 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2315 {
NYX 0:85b3fd62ea1a 2316 return (READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE));
NYX 0:85b3fd62ea1a 2317 }
NYX 0:85b3fd62ea1a 2318
NYX 0:85b3fd62ea1a 2319 /**
NYX 0:85b3fd62ea1a 2320 * @}
NYX 0:85b3fd62ea1a 2321 */
NYX 0:85b3fd62ea1a 2322
NYX 0:85b3fd62ea1a 2323 /** @defgroup USART_LL_EF_DMA_Management DMA_Management
NYX 0:85b3fd62ea1a 2324 * @{
NYX 0:85b3fd62ea1a 2325 */
NYX 0:85b3fd62ea1a 2326
NYX 0:85b3fd62ea1a 2327 /**
NYX 0:85b3fd62ea1a 2328 * @brief Enable DMA Mode for reception
NYX 0:85b3fd62ea1a 2329 * @rmtoll CR3 DMAR LL_USART_EnableDMAReq_RX
NYX 0:85b3fd62ea1a 2330 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2331 * @retval None
NYX 0:85b3fd62ea1a 2332 */
NYX 0:85b3fd62ea1a 2333 __STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2334 {
NYX 0:85b3fd62ea1a 2335 SET_BIT(USARTx->CR3, USART_CR3_DMAR);
NYX 0:85b3fd62ea1a 2336 }
NYX 0:85b3fd62ea1a 2337
NYX 0:85b3fd62ea1a 2338 /**
NYX 0:85b3fd62ea1a 2339 * @brief Disable DMA Mode for reception
NYX 0:85b3fd62ea1a 2340 * @rmtoll CR3 DMAR LL_USART_DisableDMAReq_RX
NYX 0:85b3fd62ea1a 2341 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2342 * @retval None
NYX 0:85b3fd62ea1a 2343 */
NYX 0:85b3fd62ea1a 2344 __STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2345 {
NYX 0:85b3fd62ea1a 2346 CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR);
NYX 0:85b3fd62ea1a 2347 }
NYX 0:85b3fd62ea1a 2348
NYX 0:85b3fd62ea1a 2349 /**
NYX 0:85b3fd62ea1a 2350 * @brief Check if DMA Mode is enabled for reception
NYX 0:85b3fd62ea1a 2351 * @rmtoll CR3 DMAR LL_USART_IsEnabledDMAReq_RX
NYX 0:85b3fd62ea1a 2352 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2353 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 2354 */
NYX 0:85b3fd62ea1a 2355 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2356 {
NYX 0:85b3fd62ea1a 2357 return (READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR));
NYX 0:85b3fd62ea1a 2358 }
NYX 0:85b3fd62ea1a 2359
NYX 0:85b3fd62ea1a 2360 /**
NYX 0:85b3fd62ea1a 2361 * @brief Enable DMA Mode for transmission
NYX 0:85b3fd62ea1a 2362 * @rmtoll CR3 DMAT LL_USART_EnableDMAReq_TX
NYX 0:85b3fd62ea1a 2363 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2364 * @retval None
NYX 0:85b3fd62ea1a 2365 */
NYX 0:85b3fd62ea1a 2366 __STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2367 {
NYX 0:85b3fd62ea1a 2368 SET_BIT(USARTx->CR3, USART_CR3_DMAT);
NYX 0:85b3fd62ea1a 2369 }
NYX 0:85b3fd62ea1a 2370
NYX 0:85b3fd62ea1a 2371 /**
NYX 0:85b3fd62ea1a 2372 * @brief Disable DMA Mode for transmission
NYX 0:85b3fd62ea1a 2373 * @rmtoll CR3 DMAT LL_USART_DisableDMAReq_TX
NYX 0:85b3fd62ea1a 2374 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2375 * @retval None
NYX 0:85b3fd62ea1a 2376 */
NYX 0:85b3fd62ea1a 2377 __STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2378 {
NYX 0:85b3fd62ea1a 2379 CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT);
NYX 0:85b3fd62ea1a 2380 }
NYX 0:85b3fd62ea1a 2381
NYX 0:85b3fd62ea1a 2382 /**
NYX 0:85b3fd62ea1a 2383 * @brief Check if DMA Mode is enabled for transmission
NYX 0:85b3fd62ea1a 2384 * @rmtoll CR3 DMAT LL_USART_IsEnabledDMAReq_TX
NYX 0:85b3fd62ea1a 2385 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2386 * @retval State of bit (1 or 0).
NYX 0:85b3fd62ea1a 2387 */
NYX 0:85b3fd62ea1a 2388 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2389 {
NYX 0:85b3fd62ea1a 2390 return (READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT));
NYX 0:85b3fd62ea1a 2391 }
NYX 0:85b3fd62ea1a 2392
NYX 0:85b3fd62ea1a 2393 /**
NYX 0:85b3fd62ea1a 2394 * @brief Get the data register address used for DMA transfer
NYX 0:85b3fd62ea1a 2395 * @rmtoll DR DR LL_USART_DMA_GetRegAddr
NYX 0:85b3fd62ea1a 2396 * @note Address of Data Register is valid for both Transmit and Receive transfers.
NYX 0:85b3fd62ea1a 2397 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2398 * @retval Address of data register
NYX 0:85b3fd62ea1a 2399 */
NYX 0:85b3fd62ea1a 2400 __STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2401 {
NYX 0:85b3fd62ea1a 2402 /* return address of DR register */
NYX 0:85b3fd62ea1a 2403 return ((uint32_t) &(USARTx->DR));
NYX 0:85b3fd62ea1a 2404 }
NYX 0:85b3fd62ea1a 2405
NYX 0:85b3fd62ea1a 2406 /**
NYX 0:85b3fd62ea1a 2407 * @}
NYX 0:85b3fd62ea1a 2408 */
NYX 0:85b3fd62ea1a 2409
NYX 0:85b3fd62ea1a 2410 /** @defgroup USART_LL_EF_Data_Management Data_Management
NYX 0:85b3fd62ea1a 2411 * @{
NYX 0:85b3fd62ea1a 2412 */
NYX 0:85b3fd62ea1a 2413
NYX 0:85b3fd62ea1a 2414 /**
NYX 0:85b3fd62ea1a 2415 * @brief Read Receiver Data register (Receive Data value, 8 bits)
NYX 0:85b3fd62ea1a 2416 * @rmtoll DR DR LL_USART_ReceiveData8
NYX 0:85b3fd62ea1a 2417 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2418 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
NYX 0:85b3fd62ea1a 2419 */
NYX 0:85b3fd62ea1a 2420 __STATIC_INLINE uint8_t LL_USART_ReceiveData8(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2421 {
NYX 0:85b3fd62ea1a 2422 return (uint8_t)(READ_BIT(USARTx->DR, USART_DR_DR));
NYX 0:85b3fd62ea1a 2423 }
NYX 0:85b3fd62ea1a 2424
NYX 0:85b3fd62ea1a 2425 /**
NYX 0:85b3fd62ea1a 2426 * @brief Read Receiver Data register (Receive Data value, 9 bits)
NYX 0:85b3fd62ea1a 2427 * @rmtoll DR DR LL_USART_ReceiveData9
NYX 0:85b3fd62ea1a 2428 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2429 * @retval Value between Min_Data=0x00 and Max_Data=0x1FF
NYX 0:85b3fd62ea1a 2430 */
NYX 0:85b3fd62ea1a 2431 __STATIC_INLINE uint16_t LL_USART_ReceiveData9(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2432 {
NYX 0:85b3fd62ea1a 2433 return (uint16_t)(READ_BIT(USARTx->DR, USART_DR_DR));
NYX 0:85b3fd62ea1a 2434 }
NYX 0:85b3fd62ea1a 2435
NYX 0:85b3fd62ea1a 2436 /**
NYX 0:85b3fd62ea1a 2437 * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits)
NYX 0:85b3fd62ea1a 2438 * @rmtoll DR DR LL_USART_TransmitData8
NYX 0:85b3fd62ea1a 2439 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2440 * @param Value between Min_Data=0x00 and Max_Data=0xFF
NYX 0:85b3fd62ea1a 2441 * @retval None
NYX 0:85b3fd62ea1a 2442 */
NYX 0:85b3fd62ea1a 2443 __STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value)
NYX 0:85b3fd62ea1a 2444 {
NYX 0:85b3fd62ea1a 2445 USARTx->DR = Value;
NYX 0:85b3fd62ea1a 2446 }
NYX 0:85b3fd62ea1a 2447
NYX 0:85b3fd62ea1a 2448 /**
NYX 0:85b3fd62ea1a 2449 * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits)
NYX 0:85b3fd62ea1a 2450 * @rmtoll DR DR LL_USART_TransmitData9
NYX 0:85b3fd62ea1a 2451 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2452 * @param Value between Min_Data=0x00 and Max_Data=0x1FF
NYX 0:85b3fd62ea1a 2453 * @retval None
NYX 0:85b3fd62ea1a 2454 */
NYX 0:85b3fd62ea1a 2455 __STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value)
NYX 0:85b3fd62ea1a 2456 {
NYX 0:85b3fd62ea1a 2457 USARTx->DR = Value & 0x1FFU;
NYX 0:85b3fd62ea1a 2458 }
NYX 0:85b3fd62ea1a 2459
NYX 0:85b3fd62ea1a 2460 /**
NYX 0:85b3fd62ea1a 2461 * @}
NYX 0:85b3fd62ea1a 2462 */
NYX 0:85b3fd62ea1a 2463
NYX 0:85b3fd62ea1a 2464 /** @defgroup USART_LL_EF_Execution Execution
NYX 0:85b3fd62ea1a 2465 * @{
NYX 0:85b3fd62ea1a 2466 */
NYX 0:85b3fd62ea1a 2467
NYX 0:85b3fd62ea1a 2468 /**
NYX 0:85b3fd62ea1a 2469 * @brief Request Break sending
NYX 0:85b3fd62ea1a 2470 * @rmtoll CR1 SBK LL_USART_RequestBreakSending
NYX 0:85b3fd62ea1a 2471 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2472 * @retval None
NYX 0:85b3fd62ea1a 2473 */
NYX 0:85b3fd62ea1a 2474 __STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2475 {
NYX 0:85b3fd62ea1a 2476 SET_BIT(USARTx->CR1, USART_CR1_SBK);
NYX 0:85b3fd62ea1a 2477 }
NYX 0:85b3fd62ea1a 2478
NYX 0:85b3fd62ea1a 2479 /**
NYX 0:85b3fd62ea1a 2480 * @brief Put USART in Mute mode
NYX 0:85b3fd62ea1a 2481 * @rmtoll CR1 RWU LL_USART_RequestEnterMuteMode
NYX 0:85b3fd62ea1a 2482 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2483 * @retval None
NYX 0:85b3fd62ea1a 2484 */
NYX 0:85b3fd62ea1a 2485 __STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2486 {
NYX 0:85b3fd62ea1a 2487 SET_BIT(USARTx->CR1, USART_CR1_RWU);
NYX 0:85b3fd62ea1a 2488 }
NYX 0:85b3fd62ea1a 2489
NYX 0:85b3fd62ea1a 2490 /**
NYX 0:85b3fd62ea1a 2491 * @brief Put USART in Active mode
NYX 0:85b3fd62ea1a 2492 * @rmtoll CR1 RWU LL_USART_RequestExitMuteMode
NYX 0:85b3fd62ea1a 2493 * @param USARTx USART Instance
NYX 0:85b3fd62ea1a 2494 * @retval None
NYX 0:85b3fd62ea1a 2495 */
NYX 0:85b3fd62ea1a 2496 __STATIC_INLINE void LL_USART_RequestExitMuteMode(USART_TypeDef *USARTx)
NYX 0:85b3fd62ea1a 2497 {
NYX 0:85b3fd62ea1a 2498 CLEAR_BIT(USARTx->CR1, USART_CR1_RWU);
NYX 0:85b3fd62ea1a 2499 }
NYX 0:85b3fd62ea1a 2500
NYX 0:85b3fd62ea1a 2501 /**
NYX 0:85b3fd62ea1a 2502 * @}
NYX 0:85b3fd62ea1a 2503 */
NYX 0:85b3fd62ea1a 2504
NYX 0:85b3fd62ea1a 2505 #if defined(USE_FULL_LL_DRIVER)
NYX 0:85b3fd62ea1a 2506 /** @defgroup USART_LL_EF_Init Initialization and de-initialization functions
NYX 0:85b3fd62ea1a 2507 * @{
NYX 0:85b3fd62ea1a 2508 */
NYX 0:85b3fd62ea1a 2509 ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx);
NYX 0:85b3fd62ea1a 2510 ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct);
NYX 0:85b3fd62ea1a 2511 void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct);
NYX 0:85b3fd62ea1a 2512 ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
NYX 0:85b3fd62ea1a 2513 void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct);
NYX 0:85b3fd62ea1a 2514 /**
NYX 0:85b3fd62ea1a 2515 * @}
NYX 0:85b3fd62ea1a 2516 */
NYX 0:85b3fd62ea1a 2517 #endif /* USE_FULL_LL_DRIVER */
NYX 0:85b3fd62ea1a 2518
NYX 0:85b3fd62ea1a 2519 /**
NYX 0:85b3fd62ea1a 2520 * @}
NYX 0:85b3fd62ea1a 2521 */
NYX 0:85b3fd62ea1a 2522
NYX 0:85b3fd62ea1a 2523 /**
NYX 0:85b3fd62ea1a 2524 * @}
NYX 0:85b3fd62ea1a 2525 */
NYX 0:85b3fd62ea1a 2526
NYX 0:85b3fd62ea1a 2527 #endif /* USART1 || USART2 || USART3 || USART6 || UART4 || UART5 || UART7 || UART8 || UART9 || UART10 */
NYX 0:85b3fd62ea1a 2528
NYX 0:85b3fd62ea1a 2529 /**
NYX 0:85b3fd62ea1a 2530 * @}
NYX 0:85b3fd62ea1a 2531 */
NYX 0:85b3fd62ea1a 2532
NYX 0:85b3fd62ea1a 2533 #ifdef __cplusplus
NYX 0:85b3fd62ea1a 2534 }
NYX 0:85b3fd62ea1a 2535 #endif
NYX 0:85b3fd62ea1a 2536
NYX 0:85b3fd62ea1a 2537 #endif /* __STM32F4xx_LL_USART_H */
NYX 0:85b3fd62ea1a 2538
NYX 0:85b3fd62ea1a 2539 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/