Hal Drivers for L4

Dependents:   BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo

Fork of STM32L4xx_HAL_Driver by Senior Design: Sound Monitor

Committer:
EricLew
Date:
Wed Nov 25 17:30:43 2015 +0000
Revision:
2:7aef7655b0a8
Parent:
0:80ee8f3b695e
commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
EricLew 0:80ee8f3b695e 1 /**
EricLew 0:80ee8f3b695e 2 ******************************************************************************
EricLew 0:80ee8f3b695e 3 * @file stm32l4xx_ll_usart.h
EricLew 0:80ee8f3b695e 4 * @author MCD Application Team
EricLew 0:80ee8f3b695e 5 * @version V1.1.0
EricLew 0:80ee8f3b695e 6 * @date 16-September-2015
EricLew 0:80ee8f3b695e 7 * @brief Header file of USART LL module.
EricLew 0:80ee8f3b695e 8 ******************************************************************************
EricLew 0:80ee8f3b695e 9 * @attention
EricLew 0:80ee8f3b695e 10 *
EricLew 0:80ee8f3b695e 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
EricLew 0:80ee8f3b695e 12 *
EricLew 0:80ee8f3b695e 13 * Redistribution and use in source and binary forms, with or without modification,
EricLew 0:80ee8f3b695e 14 * are permitted provided that the following conditions are met:
EricLew 0:80ee8f3b695e 15 * 1. Redistributions of source code must retain the above copyright notice,
EricLew 0:80ee8f3b695e 16 * this list of conditions and the following disclaimer.
EricLew 0:80ee8f3b695e 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
EricLew 0:80ee8f3b695e 18 * this list of conditions and the following disclaimer in the documentation
EricLew 0:80ee8f3b695e 19 * and/or other materials provided with the distribution.
EricLew 0:80ee8f3b695e 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
EricLew 0:80ee8f3b695e 21 * may be used to endorse or promote products derived from this software
EricLew 0:80ee8f3b695e 22 * without specific prior written permission.
EricLew 0:80ee8f3b695e 23 *
EricLew 0:80ee8f3b695e 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
EricLew 0:80ee8f3b695e 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
EricLew 0:80ee8f3b695e 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
EricLew 0:80ee8f3b695e 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
EricLew 0:80ee8f3b695e 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
EricLew 0:80ee8f3b695e 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
EricLew 0:80ee8f3b695e 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
EricLew 0:80ee8f3b695e 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
EricLew 0:80ee8f3b695e 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
EricLew 0:80ee8f3b695e 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EricLew 0:80ee8f3b695e 34 *
EricLew 0:80ee8f3b695e 35 ******************************************************************************
EricLew 0:80ee8f3b695e 36 */
EricLew 0:80ee8f3b695e 37
EricLew 0:80ee8f3b695e 38 /* Define to prevent recursive inclusion -------------------------------------*/
EricLew 0:80ee8f3b695e 39 #ifndef __STM32L4xx_LL_USART_H
EricLew 0:80ee8f3b695e 40 #define __STM32L4xx_LL_USART_H
EricLew 0:80ee8f3b695e 41
EricLew 0:80ee8f3b695e 42 #ifdef __cplusplus
EricLew 0:80ee8f3b695e 43 extern "C" {
EricLew 0:80ee8f3b695e 44 #endif
EricLew 0:80ee8f3b695e 45
EricLew 0:80ee8f3b695e 46 /* Includes ------------------------------------------------------------------*/
EricLew 0:80ee8f3b695e 47 #include "stm32l4xx.h"
EricLew 0:80ee8f3b695e 48
EricLew 0:80ee8f3b695e 49 /** @addtogroup STM32L4xx_LL_Driver
EricLew 0:80ee8f3b695e 50 * @{
EricLew 0:80ee8f3b695e 51 */
EricLew 0:80ee8f3b695e 52
EricLew 0:80ee8f3b695e 53 #if defined (USART1) || defined (USART2) || defined (USART3) || defined (UART4) || defined (UART5)
EricLew 0:80ee8f3b695e 54
EricLew 0:80ee8f3b695e 55 /** @defgroup USART_LL USART
EricLew 0:80ee8f3b695e 56 * @{
EricLew 0:80ee8f3b695e 57 */
EricLew 0:80ee8f3b695e 58
EricLew 0:80ee8f3b695e 59 /* Private types -------------------------------------------------------------*/
EricLew 0:80ee8f3b695e 60 /* Private variables ---------------------------------------------------------*/
EricLew 0:80ee8f3b695e 61
EricLew 0:80ee8f3b695e 62 /* Private constants ---------------------------------------------------------*/
EricLew 0:80ee8f3b695e 63 /** @defgroup USART_LL_Private_Constants USART Private Constants
EricLew 0:80ee8f3b695e 64 * @{
EricLew 0:80ee8f3b695e 65 */
EricLew 0:80ee8f3b695e 66 /* Defines used for the bit position in the register and perform offsets*/
EricLew 0:80ee8f3b695e 67 #define USART_POSITION_CR1_DEDT (uint32_t)POSITION_VAL(USART_CR1_DEDT)
EricLew 0:80ee8f3b695e 68 #define USART_POSITION_CR1_DEAT (uint32_t)POSITION_VAL(USART_CR1_DEAT)
EricLew 0:80ee8f3b695e 69 #define USART_POSITION_CR2_ADD (uint32_t)POSITION_VAL(USART_CR2_ADD)
EricLew 0:80ee8f3b695e 70 #define USART_POSITION_CR3_SCARCNT (uint32_t)POSITION_VAL(USART_CR3_SCARCNT)
EricLew 0:80ee8f3b695e 71 #define USART_POSITION_RTOR_BLEN (uint32_t)POSITION_VAL(USART_RTOR_BLEN)
EricLew 0:80ee8f3b695e 72 #define USART_POSITION_GTPR_GT (uint32_t)POSITION_VAL(USART_GTPR_GT)
EricLew 0:80ee8f3b695e 73 /**
EricLew 0:80ee8f3b695e 74 * @}
EricLew 0:80ee8f3b695e 75 */
EricLew 0:80ee8f3b695e 76
EricLew 0:80ee8f3b695e 77
EricLew 0:80ee8f3b695e 78 /* Private macros ------------------------------------------------------------*/
EricLew 0:80ee8f3b695e 79
EricLew 0:80ee8f3b695e 80 /* Exported types ------------------------------------------------------------*/
EricLew 0:80ee8f3b695e 81 /* Exported constants --------------------------------------------------------*/
EricLew 0:80ee8f3b695e 82 /** @defgroup USART_LL_Exported_Constants USART Exported Constants
EricLew 0:80ee8f3b695e 83 * @{
EricLew 0:80ee8f3b695e 84 */
EricLew 0:80ee8f3b695e 85
EricLew 0:80ee8f3b695e 86 /** @defgroup USART_LL_EC_CLEAR_FLAG Clear Flags Defines
EricLew 0:80ee8f3b695e 87 * @brief Flags defines which can be used with LL_USART_WriteReg function
EricLew 0:80ee8f3b695e 88 * @{
EricLew 0:80ee8f3b695e 89 */
EricLew 0:80ee8f3b695e 90 #define LL_USART_ICR_PECF USART_ICR_PECF
EricLew 0:80ee8f3b695e 91 #define LL_USART_ICR_FECF USART_ICR_FECF
EricLew 0:80ee8f3b695e 92 #define LL_USART_ICR_NCF USART_ICR_NCF
EricLew 0:80ee8f3b695e 93 #define LL_USART_ICR_ORECF USART_ICR_ORECF
EricLew 0:80ee8f3b695e 94 #define LL_USART_ICR_IDLECF USART_ICR_IDLECF
EricLew 0:80ee8f3b695e 95 #define LL_USART_ICR_TCCF USART_ICR_TCCF
EricLew 0:80ee8f3b695e 96 #define LL_USART_ICR_LBDCF USART_ICR_LBDCF
EricLew 0:80ee8f3b695e 97 #define LL_USART_ICR_CTSCF USART_ICR_CTSCF
EricLew 0:80ee8f3b695e 98 #define LL_USART_ICR_RTOCF USART_ICR_RTOCF
EricLew 0:80ee8f3b695e 99 #define LL_USART_ICR_EOBCF USART_ICR_EOBCF
EricLew 0:80ee8f3b695e 100 #define LL_USART_ICR_CMCF USART_ICR_CMCF
EricLew 0:80ee8f3b695e 101 #define LL_USART_ICR_WUCF USART_ICR_WUCF
EricLew 0:80ee8f3b695e 102 /**
EricLew 0:80ee8f3b695e 103 * @}
EricLew 0:80ee8f3b695e 104 */
EricLew 0:80ee8f3b695e 105
EricLew 0:80ee8f3b695e 106 /** @defgroup USART_LL_EC_GET_FLAG Get Flags Defines
EricLew 0:80ee8f3b695e 107 * @brief Flags defines which can be used with LL_USART_ReadReg function
EricLew 0:80ee8f3b695e 108 * @{
EricLew 0:80ee8f3b695e 109 */
EricLew 0:80ee8f3b695e 110 #define LL_USART_ISR_PE USART_ISR_PE
EricLew 0:80ee8f3b695e 111 #define LL_USART_ISR_FE USART_ISR_FE
EricLew 0:80ee8f3b695e 112 #define LL_USART_ISR_NE USART_ISR_NE
EricLew 0:80ee8f3b695e 113 #define LL_USART_ISR_ORE USART_ISR_ORE
EricLew 0:80ee8f3b695e 114 #define LL_USART_ISR_IDLE USART_ISR_IDLE
EricLew 0:80ee8f3b695e 115 #define LL_USART_ISR_RXNE USART_ISR_RXNE
EricLew 0:80ee8f3b695e 116 #define LL_USART_ISR_TC USART_ISR_TC
EricLew 0:80ee8f3b695e 117 #define LL_USART_ISR_TXE USART_ISR_TXE
EricLew 0:80ee8f3b695e 118 #define LL_USART_ISR_LBDF USART_ISR_LBDF
EricLew 0:80ee8f3b695e 119 #define LL_USART_ISR_CTSIF USART_ISR_CTSIF
EricLew 0:80ee8f3b695e 120 #define LL_USART_ISR_CTS USART_ISR_CTS
EricLew 0:80ee8f3b695e 121 #define LL_USART_ISR_RTOF USART_ISR_RTOF
EricLew 0:80ee8f3b695e 122 #define LL_USART_ISR_EOBF USART_ISR_EOBF
EricLew 0:80ee8f3b695e 123 #define LL_USART_ISR_ABRE USART_ISR_ABRE
EricLew 0:80ee8f3b695e 124 #define LL_USART_ISR_ABRF USART_ISR_ABRF
EricLew 0:80ee8f3b695e 125 #define LL_USART_ISR_BUSY USART_ISR_BUSY
EricLew 0:80ee8f3b695e 126 #define LL_USART_ISR_CMF USART_ISR_CMF
EricLew 0:80ee8f3b695e 127 #define LL_USART_ISR_SBKF USART_ISR_SBKF
EricLew 0:80ee8f3b695e 128 #define LL_USART_ISR_RWU USART_ISR_RWU
EricLew 0:80ee8f3b695e 129 #define LL_USART_ISR_WUF USART_ISR_WUF
EricLew 0:80ee8f3b695e 130 #define LL_USART_ISR_TEACK USART_ISR_TEACK
EricLew 0:80ee8f3b695e 131 #define LL_USART_ISR_REACK USART_ISR_REACK
EricLew 0:80ee8f3b695e 132 /**
EricLew 0:80ee8f3b695e 133 * @}
EricLew 0:80ee8f3b695e 134 */
EricLew 0:80ee8f3b695e 135
EricLew 0:80ee8f3b695e 136 /** @defgroup USART_LL_EC_IT IT Defines
EricLew 0:80ee8f3b695e 137 * @brief IT defines which can be used with LL_USART_ReadReg and LL_USART_WriteReg functions
EricLew 0:80ee8f3b695e 138 * @{
EricLew 0:80ee8f3b695e 139 */
EricLew 0:80ee8f3b695e 140 #define LL_USART_CR1_IDLEIE USART_CR1_IDLEIE
EricLew 0:80ee8f3b695e 141 #define LL_USART_CR1_RXNEIE USART_CR1_RXNEIE
EricLew 0:80ee8f3b695e 142 #define LL_USART_CR1_TCIE USART_CR1_TCIE
EricLew 0:80ee8f3b695e 143 #define LL_USART_CR1_TXEIE USART_CR1_TXEIE
EricLew 0:80ee8f3b695e 144 #define LL_USART_CR1_PEIE USART_CR1_PEIE
EricLew 0:80ee8f3b695e 145 #define LL_USART_CR1_CMIE USART_CR1_CMIE
EricLew 0:80ee8f3b695e 146 #define LL_USART_CR1_RTOIE USART_CR1_RTOIE
EricLew 0:80ee8f3b695e 147 #define LL_USART_CR1_EOBIE USART_CR1_EOBIE
EricLew 0:80ee8f3b695e 148 #define LL_USART_CR2_LBDIE USART_CR2_LBDIE
EricLew 0:80ee8f3b695e 149 #define LL_USART_CR3_EIE USART_CR3_EIE
EricLew 0:80ee8f3b695e 150 #define LL_USART_CR3_CTSIE USART_CR3_CTSIE
EricLew 0:80ee8f3b695e 151 #define LL_USART_CR3_WUFIE USART_CR3_WUFIE
EricLew 0:80ee8f3b695e 152 /**
EricLew 0:80ee8f3b695e 153 * @}
EricLew 0:80ee8f3b695e 154 */
EricLew 0:80ee8f3b695e 155
EricLew 0:80ee8f3b695e 156 /** @defgroup USART_LL_EC_DIRECTION DIRECTION
EricLew 0:80ee8f3b695e 157 * @{
EricLew 0:80ee8f3b695e 158 */
EricLew 0:80ee8f3b695e 159 #define LL_USART_DIRECTION_NONE (uint32_t)0x00000000 /*!< Transmitter and Receiver are disabled */
EricLew 0:80ee8f3b695e 160 #define LL_USART_DIRECTION_RX USART_CR1_RE /*!< Transmitter is disabled and Receiver is enabled */
EricLew 0:80ee8f3b695e 161 #define LL_USART_DIRECTION_TX USART_CR1_TE /*!< Transmitter is enabled and Receiver is disabled */
EricLew 0:80ee8f3b695e 162 #define LL_USART_DIRECTION_TX_RX (USART_CR1_TE |USART_CR1_RE) /*!< Transmitter and Receiver are enabled */
EricLew 0:80ee8f3b695e 163 /**
EricLew 0:80ee8f3b695e 164 * @}
EricLew 0:80ee8f3b695e 165 */
EricLew 0:80ee8f3b695e 166
EricLew 0:80ee8f3b695e 167 /** @defgroup USART_LL_EC_PARITY PARITY
EricLew 0:80ee8f3b695e 168 * @{
EricLew 0:80ee8f3b695e 169 */
EricLew 0:80ee8f3b695e 170 #define LL_USART_PARITY_NONE (uint32_t)0x00000000 /*!< Parity control disabled */
EricLew 0:80ee8f3b695e 171 #define LL_USART_PARITY_EVEN USART_CR1_PCE /*!< Parity control enabled and Even Parity is selected */
EricLew 0:80ee8f3b695e 172 #define LL_USART_PARITY_ODD (USART_CR1_PCE | USART_CR1_PS) /*!< Parity control enabled and Odd Parity is selected */
EricLew 0:80ee8f3b695e 173 /**
EricLew 0:80ee8f3b695e 174 * @}
EricLew 0:80ee8f3b695e 175 */
EricLew 0:80ee8f3b695e 176
EricLew 0:80ee8f3b695e 177 /** @defgroup USART_LL_EC_WAKEUP WAKEUP
EricLew 0:80ee8f3b695e 178 * @{
EricLew 0:80ee8f3b695e 179 */
EricLew 0:80ee8f3b695e 180 #define LL_USART_WAKEUP_IDLELINE (uint32_t)0x00000000 /*!< USART wakeup from Mute mode on Idle Line */
EricLew 0:80ee8f3b695e 181 #define LL_USART_WAKEUP_ADDRESSMARK USART_CR1_WAKE /*!< USART wakeup from Mute mode on Address Mark */
EricLew 0:80ee8f3b695e 182 /**
EricLew 0:80ee8f3b695e 183 * @}
EricLew 0:80ee8f3b695e 184 */
EricLew 0:80ee8f3b695e 185
EricLew 0:80ee8f3b695e 186 /** @defgroup USART_LL_EC_DATAWIDTH DATAWIDTH
EricLew 0:80ee8f3b695e 187 * @{
EricLew 0:80ee8f3b695e 188 */
EricLew 0:80ee8f3b695e 189 #define LL_USART_DATAWIDTH_7B USART_CR1_M1 /*!< 7 bits word length : Start bit, 7 data bits, n stop bits */
EricLew 0:80ee8f3b695e 190 #define LL_USART_DATAWIDTH_8B (uint32_t)0x00000000 /*!< 8 bits word length : Start bit, 8 data bits, n stop bits */
EricLew 0:80ee8f3b695e 191 #define LL_USART_DATAWIDTH_9B USART_CR1_M0 /*!< 9 bits word length : Start bit, 9 data bits, n stop bits */
EricLew 0:80ee8f3b695e 192 /**
EricLew 0:80ee8f3b695e 193 * @}
EricLew 0:80ee8f3b695e 194 */
EricLew 0:80ee8f3b695e 195
EricLew 0:80ee8f3b695e 196 /** @defgroup USART_LL_EC_OVERSAMPLING OVERSAMPLING
EricLew 0:80ee8f3b695e 197 * @{
EricLew 0:80ee8f3b695e 198 */
EricLew 0:80ee8f3b695e 199 #define LL_USART_OVERSAMPLING_16 (uint32_t)0x00000000 /*!< Oversampling by 16 */
EricLew 0:80ee8f3b695e 200 #define LL_USART_OVERSAMPLING_8 USART_CR1_OVER8 /*!< Oversampling by 8 */
EricLew 0:80ee8f3b695e 201 /**
EricLew 0:80ee8f3b695e 202 * @}
EricLew 0:80ee8f3b695e 203 */
EricLew 0:80ee8f3b695e 204
EricLew 0:80ee8f3b695e 205 /** @defgroup USART_LL_EC_LASTCLKPULSE LASTCLKPULSE
EricLew 0:80ee8f3b695e 206 * @{
EricLew 0:80ee8f3b695e 207 */
EricLew 0:80ee8f3b695e 208 #define LL_USART_LASTCLKPULSE_NO_OUTPUT (uint32_t)0x00000000 /*!< The clock pulse of the last data bit is not output to the SCLK pin */
EricLew 0:80ee8f3b695e 209 #define LL_USART_LASTCLKPULSE_OUTPUT USART_CR2_LBCL /*!< The clock pulse of the last data bit is output to the SCLK pin */
EricLew 0:80ee8f3b695e 210 /**
EricLew 0:80ee8f3b695e 211 * @}
EricLew 0:80ee8f3b695e 212 */
EricLew 0:80ee8f3b695e 213
EricLew 0:80ee8f3b695e 214 /** @defgroup USART_LL_EC_PHASE PHASE
EricLew 0:80ee8f3b695e 215 * @{
EricLew 0:80ee8f3b695e 216 */
EricLew 0:80ee8f3b695e 217 #define LL_USART_PHASE_1EDGE (uint32_t)0x00000000 /*!< The first clock transition is the first data capture edge */
EricLew 0:80ee8f3b695e 218 #define LL_USART_PHASE_2EDGE USART_CR2_CPHA /*!< The second clock transition is the first data capture edge */
EricLew 0:80ee8f3b695e 219 /**
EricLew 0:80ee8f3b695e 220 * @}
EricLew 0:80ee8f3b695e 221 */
EricLew 0:80ee8f3b695e 222
EricLew 0:80ee8f3b695e 223 /** @defgroup USART_LL_EC_POLARITY POLARITY
EricLew 0:80ee8f3b695e 224 * @{
EricLew 0:80ee8f3b695e 225 */
EricLew 0:80ee8f3b695e 226 #define LL_USART_POLARITY_LOW (uint32_t)0x00000000 /*!< Steady low value on SCLK pin outside transmission window*/
EricLew 0:80ee8f3b695e 227 #define LL_USART_POLARITY_HIGH USART_CR2_CPOL /*!< Steady high value on SCLK pin outside transmission window */
EricLew 0:80ee8f3b695e 228 /**
EricLew 0:80ee8f3b695e 229 * @}
EricLew 0:80ee8f3b695e 230 */
EricLew 0:80ee8f3b695e 231
EricLew 0:80ee8f3b695e 232 /** @defgroup USART_LL_EC_STOPBITS STOPBITS
EricLew 0:80ee8f3b695e 233 * @{
EricLew 0:80ee8f3b695e 234 */
EricLew 0:80ee8f3b695e 235 #define LL_USART_STOPBITS_1 (uint32_t)0x00000000 /*!< 1 stop bit */
EricLew 0:80ee8f3b695e 236 #define LL_USART_STOPBITS_1_5 (USART_CR2_STOP_0 | USART_CR2_STOP_1) /*!< 1.5 stop bits */
EricLew 0:80ee8f3b695e 237 #define LL_USART_STOPBITS_2 USART_CR2_STOP_1 /*!< 2 stop bits */
EricLew 0:80ee8f3b695e 238 /**
EricLew 0:80ee8f3b695e 239 * @}
EricLew 0:80ee8f3b695e 240 */
EricLew 0:80ee8f3b695e 241
EricLew 0:80ee8f3b695e 242 /** @defgroup USART_LL_EC_TXRX TXRX
EricLew 0:80ee8f3b695e 243 * @{
EricLew 0:80ee8f3b695e 244 */
EricLew 0:80ee8f3b695e 245 #define LL_USART_TXRX_STANDARD (uint32_t)0x00000000 /*!< TX/RX pins are used as defined in standard pinout */
EricLew 0:80ee8f3b695e 246 #define LL_USART_TXRX_SWAPPED (USART_CR2_SWAP) /*!< TX and RX pins functions are swapped. */
EricLew 0:80ee8f3b695e 247 /**
EricLew 0:80ee8f3b695e 248 * @}
EricLew 0:80ee8f3b695e 249 */
EricLew 0:80ee8f3b695e 250
EricLew 0:80ee8f3b695e 251 /** @defgroup USART_LL_EC_RXPIN_LEVEL RXPIN LEVEL
EricLew 0:80ee8f3b695e 252 * @{
EricLew 0:80ee8f3b695e 253 */
EricLew 0:80ee8f3b695e 254 #define LL_USART_RXPIN_LEVEL_STANDARD (uint32_t)0x00000000 /*!< RX pin signal works using the standard logic levels */
EricLew 0:80ee8f3b695e 255 #define LL_USART_RXPIN_LEVEL_INVERTED (USART_CR2_RXINV) /*!< RX pin signal values are inverted. */
EricLew 0:80ee8f3b695e 256 /**
EricLew 0:80ee8f3b695e 257 * @}
EricLew 0:80ee8f3b695e 258 */
EricLew 0:80ee8f3b695e 259
EricLew 0:80ee8f3b695e 260 /** @defgroup USART_LL_EC_TXPIN_LEVEL TXPIN LEVEL
EricLew 0:80ee8f3b695e 261 * @{
EricLew 0:80ee8f3b695e 262 */
EricLew 0:80ee8f3b695e 263 #define LL_USART_TXPIN_LEVEL_STANDARD (uint32_t)0x00000000 /*!< TX pin signal works using the standard logic levels */
EricLew 0:80ee8f3b695e 264 #define LL_USART_TXPIN_LEVEL_INVERTED (USART_CR2_TXINV) /*!< TX pin signal values are inverted. */
EricLew 0:80ee8f3b695e 265 /**
EricLew 0:80ee8f3b695e 266 * @}
EricLew 0:80ee8f3b695e 267 */
EricLew 0:80ee8f3b695e 268
EricLew 0:80ee8f3b695e 269 /** @defgroup USART_LL_EC_BINARY_LOGIC BINARY LOGIC
EricLew 0:80ee8f3b695e 270 * @{
EricLew 0:80ee8f3b695e 271 */
EricLew 0:80ee8f3b695e 272 #define LL_USART_BINARY_LOGIC_POSITIVE (uint32_t)0x00000000 /*!< Logical data from the data register are send/received in positive/direct logic. (1=H, 0=L) */
EricLew 0:80ee8f3b695e 273 #define LL_USART_BINARY_LOGIC_NEGATIVE USART_CR2_DATAINV /*!< Logical data from the data register are send/received in negative/inverse logic. (1=L, 0=H). The parity bit is also inverted. */
EricLew 0:80ee8f3b695e 274 /**
EricLew 0:80ee8f3b695e 275 * @}
EricLew 0:80ee8f3b695e 276 */
EricLew 0:80ee8f3b695e 277
EricLew 0:80ee8f3b695e 278 /** @defgroup USART_LL_EC_BITORDER BITORDER
EricLew 0:80ee8f3b695e 279 * @{
EricLew 0:80ee8f3b695e 280 */
EricLew 0:80ee8f3b695e 281 #define LL_USART_BITORDER_LSBFIRST (uint32_t)0x00000000 /*!< data is transmitted/received with data bit 0 first, following the start bit */
EricLew 0:80ee8f3b695e 282 #define LL_USART_BITORDER_MSBFIRST USART_CR2_MSBFIRST /*!< data is transmitted/received with the MSB first, following the start bit */
EricLew 0:80ee8f3b695e 283 /**
EricLew 0:80ee8f3b695e 284 * @}
EricLew 0:80ee8f3b695e 285 */
EricLew 0:80ee8f3b695e 286
EricLew 0:80ee8f3b695e 287 /** @defgroup USART_LL_EC_AUTOBAUD_DETECT_ON AUTOBAUD DETECT ON
EricLew 0:80ee8f3b695e 288 * @{
EricLew 0:80ee8f3b695e 289 */
EricLew 0:80ee8f3b695e 290 #define LL_USART_AUTOBAUD_DETECT_ON_STARTBIT (uint32_t)0x00000000 /*!< Measurement of the start bit is used to detect the baud rate */
EricLew 0:80ee8f3b695e 291 #define LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE USART_CR2_ABRMODE_0 /*!< Falling edge to falling edge measurement. Received frame must start with a single bit = 1 -> Frame = Start10xxxxxx */
EricLew 0:80ee8f3b695e 292 #define LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME USART_CR2_ABRMODE_1 /*!< 0x7F frame detection */
EricLew 0:80ee8f3b695e 293 #define LL_USART_AUTOBAUD_DETECT_ON_55_FRAME (USART_CR2_ABRMODE_1 | USART_CR2_ABRMODE_0) /*!< 0x55 frame detection */
EricLew 0:80ee8f3b695e 294 /**
EricLew 0:80ee8f3b695e 295 * @}
EricLew 0:80ee8f3b695e 296 */
EricLew 0:80ee8f3b695e 297
EricLew 0:80ee8f3b695e 298 /** @defgroup USART_LL_EC_ADDRESS_DETECT ADDRESS DETECT
EricLew 0:80ee8f3b695e 299 * @{
EricLew 0:80ee8f3b695e 300 */
EricLew 0:80ee8f3b695e 301 #define LL_USART_ADDRESS_DETECT_4B (uint32_t)0x00000000 /*!< 4-bit address detection method selected */
EricLew 0:80ee8f3b695e 302 #define LL_USART_ADDRESS_DETECT_7B USART_CR2_ADDM7 /*!< 7-bit address detection (in 8-bit data mode) method selected */
EricLew 0:80ee8f3b695e 303 /**
EricLew 0:80ee8f3b695e 304 * @}
EricLew 0:80ee8f3b695e 305 */
EricLew 0:80ee8f3b695e 306
EricLew 0:80ee8f3b695e 307 /** @defgroup USART_LL_EC_HWCONTROL HWCONTROL
EricLew 0:80ee8f3b695e 308 * @{
EricLew 0:80ee8f3b695e 309 */
EricLew 0:80ee8f3b695e 310 #define LL_USART_HWCONTROL_NONE (uint32_t)0x00000000 /*!< CTS and RTS hardware flow control disabled */
EricLew 0:80ee8f3b695e 311 #define LL_USART_HWCONTROL_RTS USART_CR3_RTSE /*!< RTS output enabled, data is only requested when there is space in the receive buffer */
EricLew 0:80ee8f3b695e 312 #define LL_USART_HWCONTROL_CTS USART_CR3_CTSE /*!< CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0) */
EricLew 0:80ee8f3b695e 313 #define LL_USART_HWCONTROL_RTS_CTS (USART_CR3_RTSE | USART_CR3_CTSE) /*!< CTS and RTS hardware flow control enabled */
EricLew 0:80ee8f3b695e 314 /**
EricLew 0:80ee8f3b695e 315 * @}
EricLew 0:80ee8f3b695e 316 */
EricLew 0:80ee8f3b695e 317
EricLew 0:80ee8f3b695e 318 /** @defgroup USART_LL_EC_WAKEUP_ON WAKEUP ON
EricLew 0:80ee8f3b695e 319 * @{
EricLew 0:80ee8f3b695e 320 */
EricLew 0:80ee8f3b695e 321 #define LL_USART_WAKEUP_ON_ADDRESS (uint32_t)0x00000000 /*!< Wakeup active on address match */
EricLew 0:80ee8f3b695e 322 #define LL_USART_WAKEUP_ON_STARTBIT USART_CR3_WUS_1 /*!< Wakeup active on Start bit detection */
EricLew 0:80ee8f3b695e 323 #define LL_USART_WAKEUP_ON_RXNE (USART_CR3_WUS_0 | USART_CR3_WUS_1) /*!< Wakeup active on RXNE */
EricLew 0:80ee8f3b695e 324 /**
EricLew 0:80ee8f3b695e 325 * @}
EricLew 0:80ee8f3b695e 326 */
EricLew 0:80ee8f3b695e 327
EricLew 0:80ee8f3b695e 328 /** @defgroup USART_LL_EC_IRDA_POWER IRDA POWER
EricLew 0:80ee8f3b695e 329 * @{
EricLew 0:80ee8f3b695e 330 */
EricLew 0:80ee8f3b695e 331 #define LL_USART_IRDA_POWER_NORMAL (uint32_t)0x00000000 /*!< IrDA normal power mode */
EricLew 0:80ee8f3b695e 332 #define LL_USART_IRDA_POWER_LOW USART_CR3_IRLP /*!< IrDA low power mode */
EricLew 0:80ee8f3b695e 333 /**
EricLew 0:80ee8f3b695e 334 * @}
EricLew 0:80ee8f3b695e 335 */
EricLew 0:80ee8f3b695e 336
EricLew 0:80ee8f3b695e 337 /** @defgroup USART_LL_EC_LINBREAK_DETECT LINBREAK DETECT
EricLew 0:80ee8f3b695e 338 * @{
EricLew 0:80ee8f3b695e 339 */
EricLew 0:80ee8f3b695e 340 #define LL_USART_LINBREAK_DETECT_10B (uint32_t)0x00000000 /*!< 10-bit break detection method selected */
EricLew 0:80ee8f3b695e 341 #define LL_USART_LINBREAK_DETECT_11B USART_CR2_LBDL /*!< 11-bit break detection method selected */
EricLew 0:80ee8f3b695e 342 /**
EricLew 0:80ee8f3b695e 343 * @}
EricLew 0:80ee8f3b695e 344 */
EricLew 0:80ee8f3b695e 345
EricLew 0:80ee8f3b695e 346 /** @defgroup USART_LL_EC_DE_POLARITY DE POLARITY
EricLew 0:80ee8f3b695e 347 * @{
EricLew 0:80ee8f3b695e 348 */
EricLew 0:80ee8f3b695e 349 #define LL_USART_DE_POLARITY_HIGH (uint32_t)0x00000000 /*!< DE signal is active high */
EricLew 0:80ee8f3b695e 350 #define LL_USART_DE_POLARITY_LOW USART_CR3_DEP /*!< DE signal is active low */
EricLew 0:80ee8f3b695e 351 /**
EricLew 0:80ee8f3b695e 352 * @}
EricLew 0:80ee8f3b695e 353 */
EricLew 0:80ee8f3b695e 354
EricLew 0:80ee8f3b695e 355 /** @defgroup USART_LL_EC_DMA_REG_DATA DMA register data
EricLew 0:80ee8f3b695e 356 * @{
EricLew 0:80ee8f3b695e 357 */
EricLew 0:80ee8f3b695e 358 #define LL_USART_DMA_REG_DATA_TRANSMIT (uint32_t)0 /*!< Get address of data register used for transmission */
EricLew 0:80ee8f3b695e 359 #define LL_USART_DMA_REG_DATA_RECEIVE (uint32_t)1 /*!< Get address of data register used for reception */
EricLew 0:80ee8f3b695e 360 /**
EricLew 0:80ee8f3b695e 361 * @}
EricLew 0:80ee8f3b695e 362 */
EricLew 0:80ee8f3b695e 363
EricLew 0:80ee8f3b695e 364 /**
EricLew 0:80ee8f3b695e 365 * @}
EricLew 0:80ee8f3b695e 366 */
EricLew 0:80ee8f3b695e 367
EricLew 0:80ee8f3b695e 368 /* Exported macro ------------------------------------------------------------*/
EricLew 0:80ee8f3b695e 369 /** @defgroup USART_LL_Exported_Macros USART Exported Macros
EricLew 0:80ee8f3b695e 370 * @{
EricLew 0:80ee8f3b695e 371 */
EricLew 0:80ee8f3b695e 372
EricLew 0:80ee8f3b695e 373 /** @defgroup USART_LL_EM_WRITE_READ Common Write and read registers Macros
EricLew 0:80ee8f3b695e 374 * @{
EricLew 0:80ee8f3b695e 375 */
EricLew 0:80ee8f3b695e 376
EricLew 0:80ee8f3b695e 377 /**
EricLew 0:80ee8f3b695e 378 * @brief Write a value in USART register
EricLew 0:80ee8f3b695e 379 * @param __INSTANCE__ USART Instance
EricLew 0:80ee8f3b695e 380 * @param __REG__ Register to be written
EricLew 0:80ee8f3b695e 381 * @param __VALUE__ Value to be written in the register
EricLew 0:80ee8f3b695e 382 * @retval None
EricLew 0:80ee8f3b695e 383 */
EricLew 0:80ee8f3b695e 384 #define LL_USART_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
EricLew 0:80ee8f3b695e 385
EricLew 0:80ee8f3b695e 386 /**
EricLew 0:80ee8f3b695e 387 * @brief Read a value in USART register
EricLew 0:80ee8f3b695e 388 * @param __INSTANCE__ USART Instance
EricLew 0:80ee8f3b695e 389 * @param __REG__ Register to be read
EricLew 0:80ee8f3b695e 390 * @retval Register value
EricLew 0:80ee8f3b695e 391 */
EricLew 0:80ee8f3b695e 392 #define LL_USART_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
EricLew 0:80ee8f3b695e 393 /**
EricLew 0:80ee8f3b695e 394 * @}
EricLew 0:80ee8f3b695e 395 */
EricLew 0:80ee8f3b695e 396
EricLew 0:80ee8f3b695e 397 /** @defgroup USART_LL_EM_Helper Helper Macros
EricLew 0:80ee8f3b695e 398 * @{
EricLew 0:80ee8f3b695e 399 */
EricLew 0:80ee8f3b695e 400 /**
EricLew 0:80ee8f3b695e 401 * @brief Compute USARTDIV value according to Peripheral Clock and
EricLew 0:80ee8f3b695e 402 * expected Baudrate in 8 bits sampling mode (32 bits value of USARTDIV is returned)
EricLew 0:80ee8f3b695e 403 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance
EricLew 0:80ee8f3b695e 404 * @param __BAUDRATE__ Baudrate value to achieve
EricLew 0:80ee8f3b695e 405 * @retval USARTDIV value to be used for BRR register filling in OverSampling_8 case
EricLew 0:80ee8f3b695e 406 */
EricLew 0:80ee8f3b695e 407 #define __LL_USART_DIV_SAMPLING8(__PERIPHCLK__, __BAUDRATE__) (((__PERIPHCLK__)*2)/(__BAUDRATE__))
EricLew 0:80ee8f3b695e 408
EricLew 0:80ee8f3b695e 409 /**
EricLew 0:80ee8f3b695e 410 * @brief Compute USARTDIV value according to Peripheral Clock and
EricLew 0:80ee8f3b695e 411 * expected Baudrate in 16 bits sampling mode (32 bits value of USARTDIV is returned)
EricLew 0:80ee8f3b695e 412 * @param __PERIPHCLK__ Peripheral Clock frequency used for USART instance
EricLew 0:80ee8f3b695e 413 * @param __BAUDRATE__ Baudrate value to achieve
EricLew 0:80ee8f3b695e 414 * @retval USARTDIV value to be used for BRR register filling in OverSampling_16 case
EricLew 0:80ee8f3b695e 415 */
EricLew 0:80ee8f3b695e 416 #define __LL_USART_DIV_SAMPLING16(__PERIPHCLK__, __BAUDRATE__) ((__PERIPHCLK__)/(__BAUDRATE__))
EricLew 0:80ee8f3b695e 417
EricLew 0:80ee8f3b695e 418 /**
EricLew 0:80ee8f3b695e 419 * @}
EricLew 0:80ee8f3b695e 420 */
EricLew 0:80ee8f3b695e 421
EricLew 0:80ee8f3b695e 422 /**
EricLew 0:80ee8f3b695e 423 * @}
EricLew 0:80ee8f3b695e 424 */
EricLew 0:80ee8f3b695e 425
EricLew 0:80ee8f3b695e 426 /* Exported functions --------------------------------------------------------*/
EricLew 0:80ee8f3b695e 427 /** @defgroup USART_LL_Exported_Functions USART Exported Functions
EricLew 0:80ee8f3b695e 428 * @{
EricLew 0:80ee8f3b695e 429 */
EricLew 0:80ee8f3b695e 430
EricLew 0:80ee8f3b695e 431 /** @defgroup USART_LL_EF_Configuration Configuration functions
EricLew 0:80ee8f3b695e 432 * @{
EricLew 0:80ee8f3b695e 433 */
EricLew 0:80ee8f3b695e 434
EricLew 0:80ee8f3b695e 435 /**
EricLew 0:80ee8f3b695e 436 * @brief USART Enable
EricLew 0:80ee8f3b695e 437 * @rmtoll CR1 UE LL_USART_Enable
EricLew 0:80ee8f3b695e 438 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 439 * @retval None
EricLew 0:80ee8f3b695e 440 */
EricLew 0:80ee8f3b695e 441 __STATIC_INLINE void LL_USART_Enable(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 442 {
EricLew 0:80ee8f3b695e 443 SET_BIT(USARTx->CR1, USART_CR1_UE);
EricLew 0:80ee8f3b695e 444 }
EricLew 0:80ee8f3b695e 445
EricLew 0:80ee8f3b695e 446 /**
EricLew 0:80ee8f3b695e 447 * @brief USART Disable (all USART prescalers and outputs are disabled)
EricLew 0:80ee8f3b695e 448 * @note When USART is disabled, USART prescalers and outputs are stopped immediately,
EricLew 0:80ee8f3b695e 449 * and current operations are discarded. The configuration of the USART is kept, but all the status
EricLew 0:80ee8f3b695e 450 * flags, in the USARTx_ISR are set to their default values.
EricLew 0:80ee8f3b695e 451 * @rmtoll CR1 UE LL_USART_Disable
EricLew 0:80ee8f3b695e 452 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 453 * @retval None
EricLew 0:80ee8f3b695e 454 */
EricLew 0:80ee8f3b695e 455 __STATIC_INLINE void LL_USART_Disable(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 456 {
EricLew 0:80ee8f3b695e 457 CLEAR_BIT(USARTx->CR1, USART_CR1_UE);
EricLew 0:80ee8f3b695e 458 }
EricLew 0:80ee8f3b695e 459
EricLew 0:80ee8f3b695e 460 /**
EricLew 0:80ee8f3b695e 461 * @brief Indicate if USART is enabled
EricLew 0:80ee8f3b695e 462 * @rmtoll CR1 UE LL_USART_IsEnabled
EricLew 0:80ee8f3b695e 463 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 464 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 465 */
EricLew 0:80ee8f3b695e 466 __STATIC_INLINE uint32_t LL_USART_IsEnabled(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 467 {
EricLew 0:80ee8f3b695e 468 return (READ_BIT(USARTx->CR1, USART_CR1_UE) == (USART_CR1_UE));
EricLew 0:80ee8f3b695e 469 }
EricLew 0:80ee8f3b695e 470
EricLew 0:80ee8f3b695e 471 /**
EricLew 0:80ee8f3b695e 472 * @brief USART enabled in STOP Mode.
EricLew 0:80ee8f3b695e 473 * @note When this function is enabled, USART is able to wake up the MCU from Stop mode, provided that
EricLew 0:80ee8f3b695e 474 * USART clock selection is HSI or LSE in RCC.
EricLew 0:80ee8f3b695e 475 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 476 * Wake-up from Stop mode feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 477 * @rmtoll CR1 UESM LL_USART_EnableInStopMode
EricLew 0:80ee8f3b695e 478 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 479 * @retval None
EricLew 0:80ee8f3b695e 480 */
EricLew 0:80ee8f3b695e 481 __STATIC_INLINE void LL_USART_EnableInStopMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 482 {
EricLew 0:80ee8f3b695e 483 SET_BIT(USARTx->CR1, USART_CR1_UESM);
EricLew 0:80ee8f3b695e 484 }
EricLew 0:80ee8f3b695e 485
EricLew 0:80ee8f3b695e 486 /**
EricLew 0:80ee8f3b695e 487 * @brief USART disabled in STOP Mode.
EricLew 0:80ee8f3b695e 488 * @note When this function is disabled, USART is not able to wake up the MCU from Stop mode
EricLew 0:80ee8f3b695e 489 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 490 * Wake-up from Stop mode feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 491 * @rmtoll CR1 UESM LL_USART_DisableInStopMode
EricLew 0:80ee8f3b695e 492 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 493 * @retval None
EricLew 0:80ee8f3b695e 494 */
EricLew 0:80ee8f3b695e 495 __STATIC_INLINE void LL_USART_DisableInStopMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 496 {
EricLew 0:80ee8f3b695e 497 CLEAR_BIT(USARTx->CR1, USART_CR1_UESM);
EricLew 0:80ee8f3b695e 498 }
EricLew 0:80ee8f3b695e 499
EricLew 0:80ee8f3b695e 500 /**
EricLew 0:80ee8f3b695e 501 * @brief Indicate if USART is enabled in STOP Mode (able to wake up MCU from Stop mode or not)
EricLew 0:80ee8f3b695e 502 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 503 * Wake-up from Stop mode feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 504 * @rmtoll CR1 UESM LL_USART_IsEnabledInStopMode
EricLew 0:80ee8f3b695e 505 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 506 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 507 */
EricLew 0:80ee8f3b695e 508 __STATIC_INLINE uint32_t LL_USART_IsEnabledInStopMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 509 {
EricLew 0:80ee8f3b695e 510 return (READ_BIT(USARTx->CR1, USART_CR1_UESM) == (USART_CR1_UESM));
EricLew 0:80ee8f3b695e 511 }
EricLew 0:80ee8f3b695e 512
EricLew 0:80ee8f3b695e 513 /**
EricLew 0:80ee8f3b695e 514 * @brief Receiver Enable (Receiver is enabled and begins searching for a start bit)
EricLew 0:80ee8f3b695e 515 * @rmtoll CR1 RE LL_USART_EnableDirectionRx
EricLew 0:80ee8f3b695e 516 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 517 * @retval None
EricLew 0:80ee8f3b695e 518 */
EricLew 0:80ee8f3b695e 519 __STATIC_INLINE void LL_USART_EnableDirectionRx(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 520 {
EricLew 0:80ee8f3b695e 521 SET_BIT(USARTx->CR1, USART_CR1_RE);
EricLew 0:80ee8f3b695e 522 }
EricLew 0:80ee8f3b695e 523
EricLew 0:80ee8f3b695e 524 /**
EricLew 0:80ee8f3b695e 525 * @brief Receiver Disable
EricLew 0:80ee8f3b695e 526 * @rmtoll CR1 RE LL_USART_DisableDirectionRx
EricLew 0:80ee8f3b695e 527 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 528 * @retval None
EricLew 0:80ee8f3b695e 529 */
EricLew 0:80ee8f3b695e 530 __STATIC_INLINE void LL_USART_DisableDirectionRx(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 531 {
EricLew 0:80ee8f3b695e 532 CLEAR_BIT(USARTx->CR1, USART_CR1_RE);
EricLew 0:80ee8f3b695e 533 }
EricLew 0:80ee8f3b695e 534
EricLew 0:80ee8f3b695e 535 /**
EricLew 0:80ee8f3b695e 536 * @brief Transmitter Enable
EricLew 0:80ee8f3b695e 537 * @rmtoll CR1 TE LL_USART_EnableDirectionTx
EricLew 0:80ee8f3b695e 538 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 539 * @retval None
EricLew 0:80ee8f3b695e 540 */
EricLew 0:80ee8f3b695e 541 __STATIC_INLINE void LL_USART_EnableDirectionTx(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 542 {
EricLew 0:80ee8f3b695e 543 SET_BIT(USARTx->CR1, USART_CR1_TE);
EricLew 0:80ee8f3b695e 544 }
EricLew 0:80ee8f3b695e 545
EricLew 0:80ee8f3b695e 546 /**
EricLew 0:80ee8f3b695e 547 * @brief Transmitter Disable
EricLew 0:80ee8f3b695e 548 * @rmtoll CR1 TE LL_USART_DisableDirectionTx
EricLew 0:80ee8f3b695e 549 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 550 * @retval None
EricLew 0:80ee8f3b695e 551 */
EricLew 0:80ee8f3b695e 552 __STATIC_INLINE void LL_USART_DisableDirectionTx(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 553 {
EricLew 0:80ee8f3b695e 554 CLEAR_BIT(USARTx->CR1, USART_CR1_TE);
EricLew 0:80ee8f3b695e 555 }
EricLew 0:80ee8f3b695e 556
EricLew 0:80ee8f3b695e 557 /**
EricLew 0:80ee8f3b695e 558 * @brief Configure simultaneously enabled/disabled states
EricLew 0:80ee8f3b695e 559 * of Transmitter and Receiver
EricLew 0:80ee8f3b695e 560 * @rmtoll CR1 RE LL_USART_SetTransferDirection\n
EricLew 0:80ee8f3b695e 561 * CR1 TE LL_USART_SetTransferDirection
EricLew 0:80ee8f3b695e 562 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 563 * @param Direction This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 564 * @arg @ref LL_USART_DIRECTION_NONE
EricLew 0:80ee8f3b695e 565 * @arg @ref LL_USART_DIRECTION_RX
EricLew 0:80ee8f3b695e 566 * @arg @ref LL_USART_DIRECTION_TX
EricLew 0:80ee8f3b695e 567 * @arg @ref LL_USART_DIRECTION_TX_RX
EricLew 0:80ee8f3b695e 568 * @retval None
EricLew 0:80ee8f3b695e 569 */
EricLew 0:80ee8f3b695e 570 __STATIC_INLINE void LL_USART_SetTransferDirection(USART_TypeDef *USARTx, uint32_t Direction)
EricLew 0:80ee8f3b695e 571 {
EricLew 0:80ee8f3b695e 572 MODIFY_REG(USARTx->CR1, USART_CR1_RE | USART_CR1_TE, Direction);
EricLew 0:80ee8f3b695e 573 }
EricLew 0:80ee8f3b695e 574
EricLew 0:80ee8f3b695e 575 /**
EricLew 0:80ee8f3b695e 576 * @brief Return enabled/disabled states of Transmitter and Receiver
EricLew 0:80ee8f3b695e 577 * @rmtoll CR1 RE LL_USART_GetTransferDirection\n
EricLew 0:80ee8f3b695e 578 * CR1 TE LL_USART_GetTransferDirection
EricLew 0:80ee8f3b695e 579 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 580 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 581 * @arg @ref LL_USART_DIRECTION_NONE
EricLew 0:80ee8f3b695e 582 * @arg @ref LL_USART_DIRECTION_RX
EricLew 0:80ee8f3b695e 583 * @arg @ref LL_USART_DIRECTION_TX
EricLew 0:80ee8f3b695e 584 * @arg @ref LL_USART_DIRECTION_TX_RX
EricLew 0:80ee8f3b695e 585 */
EricLew 0:80ee8f3b695e 586 __STATIC_INLINE uint32_t LL_USART_GetTransferDirection(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 587 {
EricLew 0:80ee8f3b695e 588 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_RE | USART_CR1_TE));
EricLew 0:80ee8f3b695e 589 }
EricLew 0:80ee8f3b695e 590
EricLew 0:80ee8f3b695e 591 /**
EricLew 0:80ee8f3b695e 592 * @brief Configure Parity (enabled/disabled and parity mode if enabled).
EricLew 0:80ee8f3b695e 593 * @note This function selects if hardware parity control (generation and detection) is enabled or disabled.
EricLew 0:80ee8f3b695e 594 * When the parity control is enabled (Odd or Even), computed parity bit is inserted at the MSB position
EricLew 0:80ee8f3b695e 595 * (9th or 8th bit depending on data width) and parity is checked on the received data.
EricLew 0:80ee8f3b695e 596 * @rmtoll CR1 PS LL_USART_SetParity\n
EricLew 0:80ee8f3b695e 597 * CR1 PCE LL_USART_SetParity
EricLew 0:80ee8f3b695e 598 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 599 * @param ParityMode This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 600 * @arg @ref LL_USART_PARITY_NONE
EricLew 0:80ee8f3b695e 601 * @arg @ref LL_USART_PARITY_EVEN
EricLew 0:80ee8f3b695e 602 * @arg @ref LL_USART_PARITY_ODD
EricLew 0:80ee8f3b695e 603 * @retval None
EricLew 0:80ee8f3b695e 604 */
EricLew 0:80ee8f3b695e 605 __STATIC_INLINE void LL_USART_SetParity(USART_TypeDef *USARTx, uint32_t ParityMode)
EricLew 0:80ee8f3b695e 606 {
EricLew 0:80ee8f3b695e 607 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE, ParityMode);
EricLew 0:80ee8f3b695e 608 }
EricLew 0:80ee8f3b695e 609
EricLew 0:80ee8f3b695e 610 /**
EricLew 0:80ee8f3b695e 611 * @brief Return Parity configuration (enabled/disabled and parity mode if enabled)
EricLew 0:80ee8f3b695e 612 * @rmtoll CR1 PS LL_USART_GetParity\n
EricLew 0:80ee8f3b695e 613 * CR1 PCE LL_USART_GetParity
EricLew 0:80ee8f3b695e 614 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 615 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 616 * @arg @ref LL_USART_PARITY_NONE
EricLew 0:80ee8f3b695e 617 * @arg @ref LL_USART_PARITY_EVEN
EricLew 0:80ee8f3b695e 618 * @arg @ref LL_USART_PARITY_ODD
EricLew 0:80ee8f3b695e 619 */
EricLew 0:80ee8f3b695e 620 __STATIC_INLINE uint32_t LL_USART_GetParity(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 621 {
EricLew 0:80ee8f3b695e 622 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE));
EricLew 0:80ee8f3b695e 623 }
EricLew 0:80ee8f3b695e 624
EricLew 0:80ee8f3b695e 625 /**
EricLew 0:80ee8f3b695e 626 * @brief Set Receiver Wakeup method from Mute mode.
EricLew 0:80ee8f3b695e 627 * @rmtoll CR1 WAKE LL_USART_SetWakeUpMethod
EricLew 0:80ee8f3b695e 628 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 629 * @param Method This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 630 * @arg @ref LL_USART_WAKEUP_IDLELINE
EricLew 0:80ee8f3b695e 631 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK
EricLew 0:80ee8f3b695e 632 * @retval None
EricLew 0:80ee8f3b695e 633 */
EricLew 0:80ee8f3b695e 634 __STATIC_INLINE void LL_USART_SetWakeUpMethod(USART_TypeDef *USARTx, uint32_t Method)
EricLew 0:80ee8f3b695e 635 {
EricLew 0:80ee8f3b695e 636 MODIFY_REG(USARTx->CR1, USART_CR1_WAKE, Method);
EricLew 0:80ee8f3b695e 637 }
EricLew 0:80ee8f3b695e 638
EricLew 0:80ee8f3b695e 639 /**
EricLew 0:80ee8f3b695e 640 * @brief Return Receiver Wakeup method from Mute mode
EricLew 0:80ee8f3b695e 641 * @rmtoll CR1 WAKE LL_USART_GetWakeUpMethod
EricLew 0:80ee8f3b695e 642 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 643 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 644 * @arg @ref LL_USART_WAKEUP_IDLELINE
EricLew 0:80ee8f3b695e 645 * @arg @ref LL_USART_WAKEUP_ADDRESSMARK
EricLew 0:80ee8f3b695e 646 */
EricLew 0:80ee8f3b695e 647 __STATIC_INLINE uint32_t LL_USART_GetWakeUpMethod(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 648 {
EricLew 0:80ee8f3b695e 649 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_WAKE));
EricLew 0:80ee8f3b695e 650 }
EricLew 0:80ee8f3b695e 651
EricLew 0:80ee8f3b695e 652 /**
EricLew 0:80ee8f3b695e 653 * @brief Set Word length (i.e. nb of data bits, excluding start and stop bits)
EricLew 0:80ee8f3b695e 654 * @rmtoll CR1 M LL_USART_SetDataWidth
EricLew 0:80ee8f3b695e 655 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 656 * @param DataWidth This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 657 * @arg @ref LL_USART_DATAWIDTH_7B
EricLew 0:80ee8f3b695e 658 * @arg @ref LL_USART_DATAWIDTH_8B
EricLew 0:80ee8f3b695e 659 * @arg @ref LL_USART_DATAWIDTH_9B
EricLew 0:80ee8f3b695e 660 * @retval None
EricLew 0:80ee8f3b695e 661 */
EricLew 0:80ee8f3b695e 662 __STATIC_INLINE void LL_USART_SetDataWidth(USART_TypeDef *USARTx, uint32_t DataWidth)
EricLew 0:80ee8f3b695e 663 {
EricLew 0:80ee8f3b695e 664 MODIFY_REG(USARTx->CR1, USART_CR1_M, DataWidth);
EricLew 0:80ee8f3b695e 665 }
EricLew 0:80ee8f3b695e 666
EricLew 0:80ee8f3b695e 667 /**
EricLew 0:80ee8f3b695e 668 * @brief Return Word length (i.e. nb of data bits, excluding start and stop bits)
EricLew 0:80ee8f3b695e 669 * @rmtoll CR1 M LL_USART_GetDataWidth
EricLew 0:80ee8f3b695e 670 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 671 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 672 * @arg @ref LL_USART_DATAWIDTH_7B
EricLew 0:80ee8f3b695e 673 * @arg @ref LL_USART_DATAWIDTH_8B
EricLew 0:80ee8f3b695e 674 * @arg @ref LL_USART_DATAWIDTH_9B
EricLew 0:80ee8f3b695e 675 */
EricLew 0:80ee8f3b695e 676 __STATIC_INLINE uint32_t LL_USART_GetDataWidth(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 677 {
EricLew 0:80ee8f3b695e 678 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_M));
EricLew 0:80ee8f3b695e 679 }
EricLew 0:80ee8f3b695e 680
EricLew 0:80ee8f3b695e 681 /**
EricLew 0:80ee8f3b695e 682 * @brief Allow switch between Mute Mode and Active mode
EricLew 0:80ee8f3b695e 683 * @rmtoll CR1 MME LL_USART_EnableMuteMode
EricLew 0:80ee8f3b695e 684 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 685 * @retval None
EricLew 0:80ee8f3b695e 686 */
EricLew 0:80ee8f3b695e 687 __STATIC_INLINE void LL_USART_EnableMuteMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 688 {
EricLew 0:80ee8f3b695e 689 SET_BIT(USARTx->CR1, USART_CR1_MME);
EricLew 0:80ee8f3b695e 690 }
EricLew 0:80ee8f3b695e 691
EricLew 0:80ee8f3b695e 692 /**
EricLew 0:80ee8f3b695e 693 * @brief Prevent Mute Mode use. Set Receiver in active mode permanently.
EricLew 0:80ee8f3b695e 694 * @rmtoll CR1 MME LL_USART_DisableMuteMode
EricLew 0:80ee8f3b695e 695 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 696 * @retval None
EricLew 0:80ee8f3b695e 697 */
EricLew 0:80ee8f3b695e 698 __STATIC_INLINE void LL_USART_DisableMuteMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 699 {
EricLew 0:80ee8f3b695e 700 CLEAR_BIT(USARTx->CR1, USART_CR1_MME);
EricLew 0:80ee8f3b695e 701 }
EricLew 0:80ee8f3b695e 702
EricLew 0:80ee8f3b695e 703 /**
EricLew 0:80ee8f3b695e 704 * @brief Indicate if switch between Mute Mode and Active mode is allowed
EricLew 0:80ee8f3b695e 705 * @rmtoll CR1 MME LL_USART_IsEnabledMuteMode
EricLew 0:80ee8f3b695e 706 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 707 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 708 */
EricLew 0:80ee8f3b695e 709 __STATIC_INLINE uint32_t LL_USART_IsEnabledMuteMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 710 {
EricLew 0:80ee8f3b695e 711 return (READ_BIT(USARTx->CR1, USART_CR1_MME) == (USART_CR1_MME));
EricLew 0:80ee8f3b695e 712 }
EricLew 0:80ee8f3b695e 713
EricLew 0:80ee8f3b695e 714 /**
EricLew 0:80ee8f3b695e 715 * @brief Set Oversampling to 8-bit or 16-bit mode
EricLew 0:80ee8f3b695e 716 * @rmtoll CR1 OVER8 LL_USART_SetOverSampling
EricLew 0:80ee8f3b695e 717 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 718 * @param OverSampling This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 719 * @arg @ref LL_USART_OVERSAMPLING_16
EricLew 0:80ee8f3b695e 720 * @arg @ref LL_USART_OVERSAMPLING_8
EricLew 0:80ee8f3b695e 721 * @retval None
EricLew 0:80ee8f3b695e 722 */
EricLew 0:80ee8f3b695e 723 __STATIC_INLINE void LL_USART_SetOverSampling(USART_TypeDef *USARTx, uint32_t OverSampling)
EricLew 0:80ee8f3b695e 724 {
EricLew 0:80ee8f3b695e 725 MODIFY_REG(USARTx->CR1, USART_CR1_OVER8, OverSampling);
EricLew 0:80ee8f3b695e 726 }
EricLew 0:80ee8f3b695e 727
EricLew 0:80ee8f3b695e 728 /**
EricLew 0:80ee8f3b695e 729 * @brief Return Oversampling mode
EricLew 0:80ee8f3b695e 730 * @rmtoll CR1 OVER8 LL_USART_GetOverSampling
EricLew 0:80ee8f3b695e 731 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 732 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 733 * @arg @ref LL_USART_OVERSAMPLING_16
EricLew 0:80ee8f3b695e 734 * @arg @ref LL_USART_OVERSAMPLING_8
EricLew 0:80ee8f3b695e 735 */
EricLew 0:80ee8f3b695e 736 __STATIC_INLINE uint32_t LL_USART_GetOverSampling(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 737 {
EricLew 0:80ee8f3b695e 738 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_OVER8));
EricLew 0:80ee8f3b695e 739 }
EricLew 0:80ee8f3b695e 740
EricLew 0:80ee8f3b695e 741 /**
EricLew 0:80ee8f3b695e 742 * @brief Configure if Clock pulse of the last data bit is output to the SCLK pin or not
EricLew 0:80ee8f3b695e 743 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 744 * Synchronous mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 745 * @rmtoll CR2 LBCL LL_USART_SetLastClkPulseOutput
EricLew 0:80ee8f3b695e 746 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 747 * @param LBCPOutput This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 748 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
EricLew 0:80ee8f3b695e 749 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
EricLew 0:80ee8f3b695e 750 * @retval None
EricLew 0:80ee8f3b695e 751 */
EricLew 0:80ee8f3b695e 752 __STATIC_INLINE void LL_USART_SetLastClkPulseOutput(USART_TypeDef *USARTx, uint32_t LBCPOutput)
EricLew 0:80ee8f3b695e 753 {
EricLew 0:80ee8f3b695e 754 MODIFY_REG(USARTx->CR2, USART_CR2_LBCL, LBCPOutput);
EricLew 0:80ee8f3b695e 755 }
EricLew 0:80ee8f3b695e 756
EricLew 0:80ee8f3b695e 757 /**
EricLew 0:80ee8f3b695e 758 * @brief Retrieve Clock pulse of the last data bit output configuration
EricLew 0:80ee8f3b695e 759 * (Last bit Clock pulse output to the SCLK pin or not)
EricLew 0:80ee8f3b695e 760 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 761 * Synchronous mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 762 * @rmtoll CR2 LBCL LL_USART_GetLastClkPulseOutput
EricLew 0:80ee8f3b695e 763 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 764 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 765 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
EricLew 0:80ee8f3b695e 766 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
EricLew 0:80ee8f3b695e 767 */
EricLew 0:80ee8f3b695e 768 __STATIC_INLINE uint32_t LL_USART_GetLastClkPulseOutput(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 769 {
EricLew 0:80ee8f3b695e 770 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBCL));
EricLew 0:80ee8f3b695e 771 }
EricLew 0:80ee8f3b695e 772
EricLew 0:80ee8f3b695e 773 /**
EricLew 0:80ee8f3b695e 774 * @brief Select the phase of the clock output on the SCLK pin in synchronous mode
EricLew 0:80ee8f3b695e 775 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 776 * Synchronous mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 777 * @rmtoll CR2 CPHA LL_USART_SetClockPhase
EricLew 0:80ee8f3b695e 778 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 779 * @param Phase This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 780 * @arg @ref LL_USART_PHASE_1EDGE
EricLew 0:80ee8f3b695e 781 * @arg @ref LL_USART_PHASE_2EDGE
EricLew 0:80ee8f3b695e 782 * @retval None
EricLew 0:80ee8f3b695e 783 */
EricLew 0:80ee8f3b695e 784 __STATIC_INLINE void LL_USART_SetClockPhase(USART_TypeDef *USARTx, uint32_t Phase)
EricLew 0:80ee8f3b695e 785 {
EricLew 0:80ee8f3b695e 786 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA, Phase);
EricLew 0:80ee8f3b695e 787 }
EricLew 0:80ee8f3b695e 788
EricLew 0:80ee8f3b695e 789 /**
EricLew 0:80ee8f3b695e 790 * @brief Return phase of the clock output on the SCLK pin in synchronous mode
EricLew 0:80ee8f3b695e 791 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 792 * Synchronous mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 793 * @rmtoll CR2 CPHA LL_USART_GetClockPhase
EricLew 0:80ee8f3b695e 794 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 795 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 796 * @arg @ref LL_USART_PHASE_1EDGE
EricLew 0:80ee8f3b695e 797 * @arg @ref LL_USART_PHASE_2EDGE
EricLew 0:80ee8f3b695e 798 */
EricLew 0:80ee8f3b695e 799 __STATIC_INLINE uint32_t LL_USART_GetClockPhase(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 800 {
EricLew 0:80ee8f3b695e 801 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPHA));
EricLew 0:80ee8f3b695e 802 }
EricLew 0:80ee8f3b695e 803
EricLew 0:80ee8f3b695e 804 /**
EricLew 0:80ee8f3b695e 805 * @brief Select the polarity of the clock output on the SCLK pin in synchronous mode
EricLew 0:80ee8f3b695e 806 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 807 * Synchronous mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 808 * @rmtoll CR2 CPOL LL_USART_SetClockPolarity
EricLew 0:80ee8f3b695e 809 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 810 * @param Polarity This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 811 * @arg @ref LL_USART_POLARITY_LOW
EricLew 0:80ee8f3b695e 812 * @arg @ref LL_USART_POLARITY_HIGH
EricLew 0:80ee8f3b695e 813 * @retval None
EricLew 0:80ee8f3b695e 814 */
EricLew 0:80ee8f3b695e 815 __STATIC_INLINE void LL_USART_SetClockPolarity(USART_TypeDef *USARTx, uint32_t Polarity)
EricLew 0:80ee8f3b695e 816 {
EricLew 0:80ee8f3b695e 817 MODIFY_REG(USARTx->CR2, USART_CR2_CPOL, Polarity);
EricLew 0:80ee8f3b695e 818 }
EricLew 0:80ee8f3b695e 819
EricLew 0:80ee8f3b695e 820 /**
EricLew 0:80ee8f3b695e 821 * @brief Return polarity of the clock output on the SCLK pin in synchronous mode
EricLew 0:80ee8f3b695e 822 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 823 * Synchronous mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 824 * @rmtoll CR2 CPOL LL_USART_GetClockPolarity
EricLew 0:80ee8f3b695e 825 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 826 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 827 * @arg @ref LL_USART_POLARITY_LOW
EricLew 0:80ee8f3b695e 828 * @arg @ref LL_USART_POLARITY_HIGH
EricLew 0:80ee8f3b695e 829 */
EricLew 0:80ee8f3b695e 830 __STATIC_INLINE uint32_t LL_USART_GetClockPolarity(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 831 {
EricLew 0:80ee8f3b695e 832 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_CPOL));
EricLew 0:80ee8f3b695e 833 }
EricLew 0:80ee8f3b695e 834
EricLew 0:80ee8f3b695e 835 /**
EricLew 0:80ee8f3b695e 836 * @brief Configure Clock signal format (Phase Polarity and choice about output of last bit clock pulse)
EricLew 0:80ee8f3b695e 837 * @note Call of this function is equivalent to following function call sequence :
EricLew 0:80ee8f3b695e 838 * - Clock Phase configuration using @ref LL_USART_SetClockPhase() function
EricLew 0:80ee8f3b695e 839 * - Clock Polarity configuration using @ref LL_USART_SetClockPolarity() function
EricLew 0:80ee8f3b695e 840 * - Output of Last bit Clock pulse configuration using @ref LL_USART_SetLastClkPulseOutput() function
EricLew 0:80ee8f3b695e 841 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 842 * Synchronous mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 843 * @rmtoll CR2 CPHA LL_USART_ConfigClock\n
EricLew 0:80ee8f3b695e 844 * CR2 CPOL LL_USART_ConfigClock\n
EricLew 0:80ee8f3b695e 845 * CR2 LBCL LL_USART_ConfigClock
EricLew 0:80ee8f3b695e 846 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 847 * @param Phase This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 848 * @arg @ref LL_USART_PHASE_1EDGE
EricLew 0:80ee8f3b695e 849 * @arg @ref LL_USART_PHASE_2EDGE
EricLew 0:80ee8f3b695e 850 * @param Polarity This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 851 * @arg @ref LL_USART_POLARITY_LOW
EricLew 0:80ee8f3b695e 852 * @arg @ref LL_USART_POLARITY_HIGH
EricLew 0:80ee8f3b695e 853 * @param LBCPOutput This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 854 * @arg @ref LL_USART_LASTCLKPULSE_NO_OUTPUT
EricLew 0:80ee8f3b695e 855 * @arg @ref LL_USART_LASTCLKPULSE_OUTPUT
EricLew 0:80ee8f3b695e 856 * @retval None
EricLew 0:80ee8f3b695e 857 */
EricLew 0:80ee8f3b695e 858 __STATIC_INLINE void LL_USART_ConfigClock(USART_TypeDef *USARTx, uint32_t Phase, uint32_t Polarity, uint32_t LBCPOutput)
EricLew 0:80ee8f3b695e 859 {
EricLew 0:80ee8f3b695e 860 MODIFY_REG(USARTx->CR2, USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL, Phase | Polarity | LBCPOutput);
EricLew 0:80ee8f3b695e 861 }
EricLew 0:80ee8f3b695e 862
EricLew 0:80ee8f3b695e 863 /**
EricLew 0:80ee8f3b695e 864 * @brief Enable Clock output on SCLK pin
EricLew 0:80ee8f3b695e 865 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 866 * Synchronous mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 867 * @rmtoll CR2 CLKEN LL_USART_EnableSCLKOutput
EricLew 0:80ee8f3b695e 868 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 869 * @retval None
EricLew 0:80ee8f3b695e 870 */
EricLew 0:80ee8f3b695e 871 __STATIC_INLINE void LL_USART_EnableSCLKOutput(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 872 {
EricLew 0:80ee8f3b695e 873 SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
EricLew 0:80ee8f3b695e 874 }
EricLew 0:80ee8f3b695e 875
EricLew 0:80ee8f3b695e 876 /**
EricLew 0:80ee8f3b695e 877 * @brief Disable Clock output on SCLK pin
EricLew 0:80ee8f3b695e 878 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 879 * Synchronous mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 880 * @rmtoll CR2 CLKEN LL_USART_DisableSCLKOutput
EricLew 0:80ee8f3b695e 881 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 882 * @retval None
EricLew 0:80ee8f3b695e 883 */
EricLew 0:80ee8f3b695e 884 __STATIC_INLINE void LL_USART_DisableSCLKOutput(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 885 {
EricLew 0:80ee8f3b695e 886 CLEAR_BIT(USARTx->CR2, USART_CR2_CLKEN);
EricLew 0:80ee8f3b695e 887 }
EricLew 0:80ee8f3b695e 888
EricLew 0:80ee8f3b695e 889 /**
EricLew 0:80ee8f3b695e 890 * @brief Indicate if Clock output on SCLK pin is enabled
EricLew 0:80ee8f3b695e 891 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 892 * Synchronous mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 893 * @rmtoll CR2 CLKEN LL_USART_IsEnabledSCLKOutput
EricLew 0:80ee8f3b695e 894 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 895 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 896 */
EricLew 0:80ee8f3b695e 897 __STATIC_INLINE uint32_t LL_USART_IsEnabledSCLKOutput(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 898 {
EricLew 0:80ee8f3b695e 899 return (READ_BIT(USARTx->CR2, USART_CR2_CLKEN) == (USART_CR2_CLKEN));
EricLew 0:80ee8f3b695e 900 }
EricLew 0:80ee8f3b695e 901
EricLew 0:80ee8f3b695e 902 /**
EricLew 0:80ee8f3b695e 903 * @brief Set the length of the stop bits
EricLew 0:80ee8f3b695e 904 * @rmtoll CR2 STOP LL_USART_SetStopBitsLength
EricLew 0:80ee8f3b695e 905 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 906 * @param StopBits This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 907 * @arg @ref LL_USART_STOPBITS_1
EricLew 0:80ee8f3b695e 908 * @arg @ref LL_USART_STOPBITS_1_5
EricLew 0:80ee8f3b695e 909 * @arg @ref LL_USART_STOPBITS_2
EricLew 0:80ee8f3b695e 910 * @retval None
EricLew 0:80ee8f3b695e 911 */
EricLew 0:80ee8f3b695e 912 __STATIC_INLINE void LL_USART_SetStopBitsLength(USART_TypeDef *USARTx, uint32_t StopBits)
EricLew 0:80ee8f3b695e 913 {
EricLew 0:80ee8f3b695e 914 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
EricLew 0:80ee8f3b695e 915 }
EricLew 0:80ee8f3b695e 916
EricLew 0:80ee8f3b695e 917 /**
EricLew 0:80ee8f3b695e 918 * @brief Retrieve the length of the stop bits
EricLew 0:80ee8f3b695e 919 * @rmtoll CR2 STOP LL_USART_GetStopBitsLength
EricLew 0:80ee8f3b695e 920 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 921 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 922 * @arg @ref LL_USART_STOPBITS_1
EricLew 0:80ee8f3b695e 923 * @arg @ref LL_USART_STOPBITS_1_5
EricLew 0:80ee8f3b695e 924 * @arg @ref LL_USART_STOPBITS_2
EricLew 0:80ee8f3b695e 925 */
EricLew 0:80ee8f3b695e 926 __STATIC_INLINE uint32_t LL_USART_GetStopBitsLength(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 927 {
EricLew 0:80ee8f3b695e 928 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_STOP));
EricLew 0:80ee8f3b695e 929 }
EricLew 0:80ee8f3b695e 930
EricLew 0:80ee8f3b695e 931 /**
EricLew 0:80ee8f3b695e 932 * @brief Configure Character frame format (Datawidth, Parity control, Stop Bits)
EricLew 0:80ee8f3b695e 933 * @note Call of this function is equivalent to following function call sequence :
EricLew 0:80ee8f3b695e 934 * - Data Width configuration using @ref LL_USART_SetDataWidth() function
EricLew 0:80ee8f3b695e 935 * - Parity Control and mode configuration using @ref LL_USART_SetParity() function
EricLew 0:80ee8f3b695e 936 * - Stop bits configuration using @ref LL_USART_SetStopBitsLength() function
EricLew 0:80ee8f3b695e 937 * @rmtoll CR1 PS LL_USART_ConfigCharacter\n
EricLew 0:80ee8f3b695e 938 * CR1 PCE LL_USART_ConfigCharacter\n
EricLew 0:80ee8f3b695e 939 * CR1 M LL_USART_ConfigCharacter\n
EricLew 0:80ee8f3b695e 940 * CR2 STOP LL_USART_ConfigCharacter
EricLew 0:80ee8f3b695e 941 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 942 * @param DataWidth This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 943 * @arg @ref LL_USART_DATAWIDTH_7B
EricLew 0:80ee8f3b695e 944 * @arg @ref LL_USART_DATAWIDTH_8B
EricLew 0:80ee8f3b695e 945 * @arg @ref LL_USART_DATAWIDTH_9B
EricLew 0:80ee8f3b695e 946 * @param ParityMode This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 947 * @arg @ref LL_USART_PARITY_NONE
EricLew 0:80ee8f3b695e 948 * @arg @ref LL_USART_PARITY_EVEN
EricLew 0:80ee8f3b695e 949 * @arg @ref LL_USART_PARITY_ODD
EricLew 0:80ee8f3b695e 950 * @param StopBits This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 951 * @arg @ref LL_USART_STOPBITS_1
EricLew 0:80ee8f3b695e 952 * @arg @ref LL_USART_STOPBITS_2
EricLew 0:80ee8f3b695e 953 * @arg @ref LL_USART_STOPBITS_1_5
EricLew 0:80ee8f3b695e 954 * @retval None
EricLew 0:80ee8f3b695e 955 */
EricLew 0:80ee8f3b695e 956 __STATIC_INLINE void LL_USART_ConfigCharacter(USART_TypeDef *USARTx, uint32_t DataWidth, uint32_t ParityMode,
EricLew 0:80ee8f3b695e 957 uint32_t StopBits)
EricLew 0:80ee8f3b695e 958 {
EricLew 0:80ee8f3b695e 959 MODIFY_REG(USARTx->CR1, USART_CR1_PS | USART_CR1_PCE | USART_CR1_M, ParityMode | DataWidth);
EricLew 0:80ee8f3b695e 960 MODIFY_REG(USARTx->CR2, USART_CR2_STOP, StopBits);
EricLew 0:80ee8f3b695e 961 }
EricLew 0:80ee8f3b695e 962
EricLew 0:80ee8f3b695e 963 /**
EricLew 0:80ee8f3b695e 964 * @brief Configure TX/RX pins swapping setting.
EricLew 0:80ee8f3b695e 965 * @rmtoll CR2 SWAP LL_USART_SetTXRXSwap
EricLew 0:80ee8f3b695e 966 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 967 * @param SwapConfig This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 968 * @arg @ref LL_USART_TXRX_STANDARD
EricLew 0:80ee8f3b695e 969 * @arg @ref LL_USART_TXRX_SWAPPED
EricLew 0:80ee8f3b695e 970 * @retval None
EricLew 0:80ee8f3b695e 971 */
EricLew 0:80ee8f3b695e 972 __STATIC_INLINE void LL_USART_SetTXRXSwap(USART_TypeDef *USARTx, uint32_t SwapConfig)
EricLew 0:80ee8f3b695e 973 {
EricLew 0:80ee8f3b695e 974 MODIFY_REG(USARTx->CR2, USART_CR2_SWAP, SwapConfig);
EricLew 0:80ee8f3b695e 975 }
EricLew 0:80ee8f3b695e 976
EricLew 0:80ee8f3b695e 977 /**
EricLew 0:80ee8f3b695e 978 * @brief Retrieve TX/RX pins swapping configuration.
EricLew 0:80ee8f3b695e 979 * @rmtoll CR2 SWAP LL_USART_GetTXRXSwap
EricLew 0:80ee8f3b695e 980 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 981 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 982 * @arg @ref LL_USART_TXRX_STANDARD
EricLew 0:80ee8f3b695e 983 * @arg @ref LL_USART_TXRX_SWAPPED
EricLew 0:80ee8f3b695e 984 */
EricLew 0:80ee8f3b695e 985 __STATIC_INLINE uint32_t LL_USART_GetTXRXSwap(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 986 {
EricLew 0:80ee8f3b695e 987 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_SWAP));
EricLew 0:80ee8f3b695e 988 }
EricLew 0:80ee8f3b695e 989
EricLew 0:80ee8f3b695e 990 /**
EricLew 0:80ee8f3b695e 991 * @brief Configure RX pin active level logic
EricLew 0:80ee8f3b695e 992 * @rmtoll CR2 RXINV LL_USART_SetRXPinLevel
EricLew 0:80ee8f3b695e 993 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 994 * @param PinInvMethod This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 995 * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD
EricLew 0:80ee8f3b695e 996 * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED
EricLew 0:80ee8f3b695e 997 * @retval None
EricLew 0:80ee8f3b695e 998 */
EricLew 0:80ee8f3b695e 999 __STATIC_INLINE void LL_USART_SetRXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod)
EricLew 0:80ee8f3b695e 1000 {
EricLew 0:80ee8f3b695e 1001 MODIFY_REG(USARTx->CR2, USART_CR2_RXINV, PinInvMethod);
EricLew 0:80ee8f3b695e 1002 }
EricLew 0:80ee8f3b695e 1003
EricLew 0:80ee8f3b695e 1004 /**
EricLew 0:80ee8f3b695e 1005 * @brief Retrieve RX pin active level logic configuration
EricLew 0:80ee8f3b695e 1006 * @rmtoll CR2 RXINV LL_USART_GetRXPinLevel
EricLew 0:80ee8f3b695e 1007 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1008 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 1009 * @arg @ref LL_USART_RXPIN_LEVEL_STANDARD
EricLew 0:80ee8f3b695e 1010 * @arg @ref LL_USART_RXPIN_LEVEL_INVERTED
EricLew 0:80ee8f3b695e 1011 */
EricLew 0:80ee8f3b695e 1012 __STATIC_INLINE uint32_t LL_USART_GetRXPinLevel(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1013 {
EricLew 0:80ee8f3b695e 1014 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_RXINV));
EricLew 0:80ee8f3b695e 1015 }
EricLew 0:80ee8f3b695e 1016
EricLew 0:80ee8f3b695e 1017 /**
EricLew 0:80ee8f3b695e 1018 * @brief Configure TX pin active level logic
EricLew 0:80ee8f3b695e 1019 * @rmtoll CR2 TXINV LL_USART_SetTXPinLevel
EricLew 0:80ee8f3b695e 1020 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1021 * @param PinInvMethod This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 1022 * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD
EricLew 0:80ee8f3b695e 1023 * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED
EricLew 0:80ee8f3b695e 1024 * @retval None
EricLew 0:80ee8f3b695e 1025 */
EricLew 0:80ee8f3b695e 1026 __STATIC_INLINE void LL_USART_SetTXPinLevel(USART_TypeDef *USARTx, uint32_t PinInvMethod)
EricLew 0:80ee8f3b695e 1027 {
EricLew 0:80ee8f3b695e 1028 MODIFY_REG(USARTx->CR2, USART_CR2_TXINV, PinInvMethod);
EricLew 0:80ee8f3b695e 1029 }
EricLew 0:80ee8f3b695e 1030
EricLew 0:80ee8f3b695e 1031 /**
EricLew 0:80ee8f3b695e 1032 * @brief Retrieve TX pin active level logic configuration
EricLew 0:80ee8f3b695e 1033 * @rmtoll CR2 TXINV LL_USART_GetTXPinLevel
EricLew 0:80ee8f3b695e 1034 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1035 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 1036 * @arg @ref LL_USART_TXPIN_LEVEL_STANDARD
EricLew 0:80ee8f3b695e 1037 * @arg @ref LL_USART_TXPIN_LEVEL_INVERTED
EricLew 0:80ee8f3b695e 1038 */
EricLew 0:80ee8f3b695e 1039 __STATIC_INLINE uint32_t LL_USART_GetTXPinLevel(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1040 {
EricLew 0:80ee8f3b695e 1041 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_TXINV));
EricLew 0:80ee8f3b695e 1042 }
EricLew 0:80ee8f3b695e 1043
EricLew 0:80ee8f3b695e 1044 /**
EricLew 0:80ee8f3b695e 1045 * @brief Configure Binary data logic.
EricLew 0:80ee8f3b695e 1046 * @note Allow to define how Logical data from the data register are send/received :
EricLew 0:80ee8f3b695e 1047 * either in positive/direct logic (1=H, 0=L) or in negative/inverse logic (1=L, 0=H)
EricLew 0:80ee8f3b695e 1048 * @rmtoll CR2 DATAINV LL_USART_SetBinaryDataLogic
EricLew 0:80ee8f3b695e 1049 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1050 * @param DataLogic This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 1051 * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE
EricLew 0:80ee8f3b695e 1052 * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE
EricLew 0:80ee8f3b695e 1053 * @retval None
EricLew 0:80ee8f3b695e 1054 */
EricLew 0:80ee8f3b695e 1055 __STATIC_INLINE void LL_USART_SetBinaryDataLogic(USART_TypeDef *USARTx, uint32_t DataLogic)
EricLew 0:80ee8f3b695e 1056 {
EricLew 0:80ee8f3b695e 1057 MODIFY_REG(USARTx->CR2, USART_CR2_DATAINV, DataLogic);
EricLew 0:80ee8f3b695e 1058 }
EricLew 0:80ee8f3b695e 1059
EricLew 0:80ee8f3b695e 1060 /**
EricLew 0:80ee8f3b695e 1061 * @brief Retrieve Binary data configuration
EricLew 0:80ee8f3b695e 1062 * @rmtoll CR2 DATAINV LL_USART_GetBinaryDataLogic
EricLew 0:80ee8f3b695e 1063 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1064 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 1065 * @arg @ref LL_USART_BINARY_LOGIC_POSITIVE
EricLew 0:80ee8f3b695e 1066 * @arg @ref LL_USART_BINARY_LOGIC_NEGATIVE
EricLew 0:80ee8f3b695e 1067 */
EricLew 0:80ee8f3b695e 1068 __STATIC_INLINE uint32_t LL_USART_GetBinaryDataLogic(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1069 {
EricLew 0:80ee8f3b695e 1070 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_DATAINV));
EricLew 0:80ee8f3b695e 1071 }
EricLew 0:80ee8f3b695e 1072
EricLew 0:80ee8f3b695e 1073 /**
EricLew 0:80ee8f3b695e 1074 * @brief Configure transfer bit order (either Less or Most Significant Bit First)
EricLew 0:80ee8f3b695e 1075 * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
EricLew 0:80ee8f3b695e 1076 * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
EricLew 0:80ee8f3b695e 1077 * @rmtoll CR2 MSBFIRST LL_USART_SetTransferBitOrder
EricLew 0:80ee8f3b695e 1078 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1079 * @param BitOrder This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 1080 * @arg @ref LL_USART_BITORDER_LSBFIRST
EricLew 0:80ee8f3b695e 1081 * @arg @ref LL_USART_BITORDER_MSBFIRST
EricLew 0:80ee8f3b695e 1082 * @retval None
EricLew 0:80ee8f3b695e 1083 */
EricLew 0:80ee8f3b695e 1084 __STATIC_INLINE void LL_USART_SetTransferBitOrder(USART_TypeDef *USARTx, uint32_t BitOrder)
EricLew 0:80ee8f3b695e 1085 {
EricLew 0:80ee8f3b695e 1086 MODIFY_REG(USARTx->CR2, USART_CR2_MSBFIRST, BitOrder);
EricLew 0:80ee8f3b695e 1087 }
EricLew 0:80ee8f3b695e 1088
EricLew 0:80ee8f3b695e 1089 /**
EricLew 0:80ee8f3b695e 1090 * @brief Return transfer bit order (either Less or Most Significant Bit First)
EricLew 0:80ee8f3b695e 1091 * @note MSB First means data is transmitted/received with the MSB first, following the start bit.
EricLew 0:80ee8f3b695e 1092 * LSB First means data is transmitted/received with data bit 0 first, following the start bit.
EricLew 0:80ee8f3b695e 1093 * @rmtoll CR2 MSBFIRST LL_USART_GetTransferBitOrder
EricLew 0:80ee8f3b695e 1094 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1095 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 1096 * @arg @ref LL_USART_BITORDER_LSBFIRST
EricLew 0:80ee8f3b695e 1097 * @arg @ref LL_USART_BITORDER_MSBFIRST
EricLew 0:80ee8f3b695e 1098 */
EricLew 0:80ee8f3b695e 1099 __STATIC_INLINE uint32_t LL_USART_GetTransferBitOrder(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1100 {
EricLew 0:80ee8f3b695e 1101 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_MSBFIRST));
EricLew 0:80ee8f3b695e 1102 }
EricLew 0:80ee8f3b695e 1103
EricLew 0:80ee8f3b695e 1104 /**
EricLew 0:80ee8f3b695e 1105 * @brief Enable Auto Baud-Rate Detection
EricLew 0:80ee8f3b695e 1106 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1107 * Auto Baud Rate detection feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1108 * @rmtoll CR2 ABREN LL_USART_EnableAutoBaudRate
EricLew 0:80ee8f3b695e 1109 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1110 * @retval None
EricLew 0:80ee8f3b695e 1111 */
EricLew 0:80ee8f3b695e 1112 __STATIC_INLINE void LL_USART_EnableAutoBaudRate(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1113 {
EricLew 0:80ee8f3b695e 1114 SET_BIT(USARTx->CR2, USART_CR2_ABREN);
EricLew 0:80ee8f3b695e 1115 }
EricLew 0:80ee8f3b695e 1116
EricLew 0:80ee8f3b695e 1117 /**
EricLew 0:80ee8f3b695e 1118 * @brief Disable Auto Baud-Rate Detection
EricLew 0:80ee8f3b695e 1119 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1120 * Auto Baud Rate detection feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1121 * @rmtoll CR2 ABREN LL_USART_DisableAutoBaudRate
EricLew 0:80ee8f3b695e 1122 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1123 * @retval None
EricLew 0:80ee8f3b695e 1124 */
EricLew 0:80ee8f3b695e 1125 __STATIC_INLINE void LL_USART_DisableAutoBaudRate(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1126 {
EricLew 0:80ee8f3b695e 1127 CLEAR_BIT(USARTx->CR2, USART_CR2_ABREN);
EricLew 0:80ee8f3b695e 1128 }
EricLew 0:80ee8f3b695e 1129
EricLew 0:80ee8f3b695e 1130 /**
EricLew 0:80ee8f3b695e 1131 * @brief Indicate if Auto Baud-Rate Detection mechanism is enabled
EricLew 0:80ee8f3b695e 1132 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1133 * Auto Baud Rate detection feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1134 * @rmtoll CR2 ABREN LL_USART_IsEnabledAutoBaud
EricLew 0:80ee8f3b695e 1135 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1136 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 1137 */
EricLew 0:80ee8f3b695e 1138 __STATIC_INLINE uint32_t LL_USART_IsEnabledAutoBaud(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1139 {
EricLew 0:80ee8f3b695e 1140 return (READ_BIT(USARTx->CR2, USART_CR2_ABREN) == (USART_CR2_ABREN));
EricLew 0:80ee8f3b695e 1141 }
EricLew 0:80ee8f3b695e 1142
EricLew 0:80ee8f3b695e 1143 /**
EricLew 0:80ee8f3b695e 1144 * @brief Set Auto Baud-Rate mode bits
EricLew 0:80ee8f3b695e 1145 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1146 * Auto Baud Rate detection feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1147 * @rmtoll CR2 ABRMODE LL_USART_SetAutoBaudRateMode
EricLew 0:80ee8f3b695e 1148 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1149 * @param AutoBaudRateMode This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 1150 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT
EricLew 0:80ee8f3b695e 1151 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE
EricLew 0:80ee8f3b695e 1152 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME
EricLew 0:80ee8f3b695e 1153 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME
EricLew 0:80ee8f3b695e 1154 * @retval None
EricLew 0:80ee8f3b695e 1155 */
EricLew 0:80ee8f3b695e 1156 __STATIC_INLINE void LL_USART_SetAutoBaudRateMode(USART_TypeDef *USARTx, uint32_t AutoBaudRateMode)
EricLew 0:80ee8f3b695e 1157 {
EricLew 0:80ee8f3b695e 1158 MODIFY_REG(USARTx->CR2, USART_CR2_ABRMODE, AutoBaudRateMode);
EricLew 0:80ee8f3b695e 1159 }
EricLew 0:80ee8f3b695e 1160
EricLew 0:80ee8f3b695e 1161 /**
EricLew 0:80ee8f3b695e 1162 * @brief Return Auto Baud-Rate mode
EricLew 0:80ee8f3b695e 1163 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1164 * Auto Baud Rate detection feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1165 * @rmtoll CR2 ABRMODE LL_USART_GetAutoBaudRateMode
EricLew 0:80ee8f3b695e 1166 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1167 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 1168 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_STARTBIT
EricLew 0:80ee8f3b695e 1169 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE
EricLew 0:80ee8f3b695e 1170 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_7F_FRAME
EricLew 0:80ee8f3b695e 1171 * @arg @ref LL_USART_AUTOBAUD_DETECT_ON_55_FRAME
EricLew 0:80ee8f3b695e 1172 */
EricLew 0:80ee8f3b695e 1173 __STATIC_INLINE uint32_t LL_USART_GetAutoBaudRateMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1174 {
EricLew 0:80ee8f3b695e 1175 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ABRMODE));
EricLew 0:80ee8f3b695e 1176 }
EricLew 0:80ee8f3b695e 1177
EricLew 0:80ee8f3b695e 1178 /**
EricLew 0:80ee8f3b695e 1179 * @brief Enable Receiver Timeout
EricLew 0:80ee8f3b695e 1180 * @rmtoll CR2 RTOEN LL_USART_EnableRxTimeout
EricLew 0:80ee8f3b695e 1181 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1182 * @retval None
EricLew 0:80ee8f3b695e 1183 */
EricLew 0:80ee8f3b695e 1184 __STATIC_INLINE void LL_USART_EnableRxTimeout(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1185 {
EricLew 0:80ee8f3b695e 1186 SET_BIT(USARTx->CR2, USART_CR2_RTOEN);
EricLew 0:80ee8f3b695e 1187 }
EricLew 0:80ee8f3b695e 1188
EricLew 0:80ee8f3b695e 1189 /**
EricLew 0:80ee8f3b695e 1190 * @brief Disable Receiver Timeout
EricLew 0:80ee8f3b695e 1191 * @rmtoll CR2 RTOEN LL_USART_DisableRxTimeout
EricLew 0:80ee8f3b695e 1192 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1193 * @retval None
EricLew 0:80ee8f3b695e 1194 */
EricLew 0:80ee8f3b695e 1195 __STATIC_INLINE void LL_USART_DisableRxTimeout(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1196 {
EricLew 0:80ee8f3b695e 1197 CLEAR_BIT(USARTx->CR2, USART_CR2_RTOEN);
EricLew 0:80ee8f3b695e 1198 }
EricLew 0:80ee8f3b695e 1199
EricLew 0:80ee8f3b695e 1200 /**
EricLew 0:80ee8f3b695e 1201 * @brief Indicate if Receiver Timeout feature is enabled
EricLew 0:80ee8f3b695e 1202 * @rmtoll CR2 RTOEN LL_USART_IsEnabledRxTimeout
EricLew 0:80ee8f3b695e 1203 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1204 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 1205 */
EricLew 0:80ee8f3b695e 1206 __STATIC_INLINE uint32_t LL_USART_IsEnabledRxTimeout(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1207 {
EricLew 0:80ee8f3b695e 1208 return (READ_BIT(USARTx->CR2, USART_CR2_RTOEN) == (USART_CR2_RTOEN));
EricLew 0:80ee8f3b695e 1209 }
EricLew 0:80ee8f3b695e 1210
EricLew 0:80ee8f3b695e 1211 /**
EricLew 0:80ee8f3b695e 1212 * @brief Set Address of the USART node.
EricLew 0:80ee8f3b695e 1213 * @note This is used in multiprocessor communication during Mute mode or Stop mode,
EricLew 0:80ee8f3b695e 1214 * for wakeup with address mark detection.
EricLew 0:80ee8f3b695e 1215 * @note 4bits address node is used when 4-bit Address Detection is selected in ADDM7.
EricLew 0:80ee8f3b695e 1216 * (b7-b4 should be set to 0)
EricLew 0:80ee8f3b695e 1217 * 8bits address node is used when 7-bit Address Detection is selected in ADDM7.
EricLew 0:80ee8f3b695e 1218 * (This is used in multiprocessor communication during Mute mode or Stop mode,
EricLew 0:80ee8f3b695e 1219 * for wakeup with 7-bit address mark detection.
EricLew 0:80ee8f3b695e 1220 * The MSB of the character sent by the transmitter should be equal to 1.
EricLew 0:80ee8f3b695e 1221 * It may also be used for character detection during normal reception,
EricLew 0:80ee8f3b695e 1222 * Mute mode inactive (for example, end of block detection in ModBus protocol).
EricLew 0:80ee8f3b695e 1223 * In this case, the whole received character (8-bit) is compared to the ADD[7:0]
EricLew 0:80ee8f3b695e 1224 * value and CMF flag is set on match)
EricLew 0:80ee8f3b695e 1225 * @rmtoll CR2 ADD LL_USART_ConfigNodeAddress\n
EricLew 0:80ee8f3b695e 1226 * CR2 ADDM7 LL_USART_ConfigNodeAddress
EricLew 0:80ee8f3b695e 1227 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1228 * @param AddressLen This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 1229 * @arg @ref LL_USART_ADDRESS_DETECT_4B
EricLew 0:80ee8f3b695e 1230 * @arg @ref LL_USART_ADDRESS_DETECT_7B
EricLew 0:80ee8f3b695e 1231 * @param NodeAddress 4 or 7 bit Address of the USART node.
EricLew 0:80ee8f3b695e 1232 * @retval None
EricLew 0:80ee8f3b695e 1233 */
EricLew 0:80ee8f3b695e 1234 __STATIC_INLINE void LL_USART_ConfigNodeAddress(USART_TypeDef *USARTx, uint32_t AddressLen, uint32_t NodeAddress)
EricLew 0:80ee8f3b695e 1235 {
EricLew 0:80ee8f3b695e 1236 MODIFY_REG(USARTx->CR2, USART_CR2_ADD | USART_CR2_ADDM7,
EricLew 0:80ee8f3b695e 1237 (uint32_t)(AddressLen | (NodeAddress << USART_POSITION_CR2_ADD)));
EricLew 0:80ee8f3b695e 1238 }
EricLew 0:80ee8f3b695e 1239
EricLew 0:80ee8f3b695e 1240 /**
EricLew 0:80ee8f3b695e 1241 * @brief Return 8 bit Address of the USART node as set in ADD field of CR2.
EricLew 0:80ee8f3b695e 1242 * @note If 4-bit Address Detection is selected in ADDM7,
EricLew 0:80ee8f3b695e 1243 * only 4bits (b3-b0) of returned value are relevant (b31-b4 are not relevant)
EricLew 0:80ee8f3b695e 1244 * If 7-bit Address Detection is selected in ADDM7,
EricLew 0:80ee8f3b695e 1245 * only 8bits (b7-b0) of returned value are relevant (b31-b8 are not relevant)
EricLew 0:80ee8f3b695e 1246 * @rmtoll CR2 ADD LL_USART_GetNodeAddress
EricLew 0:80ee8f3b695e 1247 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1248 * @retval Address of the USART node (0..255)
EricLew 0:80ee8f3b695e 1249 */
EricLew 0:80ee8f3b695e 1250 __STATIC_INLINE uint32_t LL_USART_GetNodeAddress(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1251 {
EricLew 0:80ee8f3b695e 1252 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADD) >> USART_POSITION_CR2_ADD);
EricLew 0:80ee8f3b695e 1253 }
EricLew 0:80ee8f3b695e 1254
EricLew 0:80ee8f3b695e 1255 /**
EricLew 0:80ee8f3b695e 1256 * @brief Return Length of Node Address used in Address Detection mode (7-bit or 4-bit)
EricLew 0:80ee8f3b695e 1257 * @rmtoll CR2 ADDM7 LL_USART_GetNodeAddressLen
EricLew 0:80ee8f3b695e 1258 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1259 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 1260 * @arg @ref LL_USART_ADDRESS_DETECT_4B
EricLew 0:80ee8f3b695e 1261 * @arg @ref LL_USART_ADDRESS_DETECT_7B
EricLew 0:80ee8f3b695e 1262 */
EricLew 0:80ee8f3b695e 1263 __STATIC_INLINE uint32_t LL_USART_GetNodeAddressLen(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1264 {
EricLew 0:80ee8f3b695e 1265 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_ADDM7));
EricLew 0:80ee8f3b695e 1266 }
EricLew 0:80ee8f3b695e 1267
EricLew 0:80ee8f3b695e 1268 /**
EricLew 0:80ee8f3b695e 1269 * @brief Enable RTS HW Flow Control
EricLew 0:80ee8f3b695e 1270 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1271 * Hardware Flow control feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1272 * @rmtoll CR3 RTSE LL_USART_EnableRTSHWFlowCtrl
EricLew 0:80ee8f3b695e 1273 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1274 * @retval None
EricLew 0:80ee8f3b695e 1275 */
EricLew 0:80ee8f3b695e 1276 __STATIC_INLINE void LL_USART_EnableRTSHWFlowCtrl(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1277 {
EricLew 0:80ee8f3b695e 1278 SET_BIT(USARTx->CR3, USART_CR3_RTSE);
EricLew 0:80ee8f3b695e 1279 }
EricLew 0:80ee8f3b695e 1280
EricLew 0:80ee8f3b695e 1281 /**
EricLew 0:80ee8f3b695e 1282 * @brief Disable RTS HW Flow Control
EricLew 0:80ee8f3b695e 1283 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1284 * Hardware Flow control feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1285 * @rmtoll CR3 RTSE LL_USART_DisableRTSHWFlowCtrl
EricLew 0:80ee8f3b695e 1286 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1287 * @retval None
EricLew 0:80ee8f3b695e 1288 */
EricLew 0:80ee8f3b695e 1289 __STATIC_INLINE void LL_USART_DisableRTSHWFlowCtrl(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1290 {
EricLew 0:80ee8f3b695e 1291 CLEAR_BIT(USARTx->CR3, USART_CR3_RTSE);
EricLew 0:80ee8f3b695e 1292 }
EricLew 0:80ee8f3b695e 1293
EricLew 0:80ee8f3b695e 1294 /**
EricLew 0:80ee8f3b695e 1295 * @brief Enable CTS HW Flow Control
EricLew 0:80ee8f3b695e 1296 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1297 * Hardware Flow control feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1298 * @rmtoll CR3 CTSE LL_USART_EnableCTSHWFlowCtrl
EricLew 0:80ee8f3b695e 1299 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1300 * @retval None
EricLew 0:80ee8f3b695e 1301 */
EricLew 0:80ee8f3b695e 1302 __STATIC_INLINE void LL_USART_EnableCTSHWFlowCtrl(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1303 {
EricLew 0:80ee8f3b695e 1304 SET_BIT(USARTx->CR3, USART_CR3_CTSE);
EricLew 0:80ee8f3b695e 1305 }
EricLew 0:80ee8f3b695e 1306
EricLew 0:80ee8f3b695e 1307 /**
EricLew 0:80ee8f3b695e 1308 * @brief Disable CTS HW Flow Control
EricLew 0:80ee8f3b695e 1309 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1310 * Hardware Flow control feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1311 * @rmtoll CR3 CTSE LL_USART_DisableCTSHWFlowCtrl
EricLew 0:80ee8f3b695e 1312 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1313 * @retval None
EricLew 0:80ee8f3b695e 1314 */
EricLew 0:80ee8f3b695e 1315 __STATIC_INLINE void LL_USART_DisableCTSHWFlowCtrl(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1316 {
EricLew 0:80ee8f3b695e 1317 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSE);
EricLew 0:80ee8f3b695e 1318 }
EricLew 0:80ee8f3b695e 1319
EricLew 0:80ee8f3b695e 1320 /**
EricLew 0:80ee8f3b695e 1321 * @brief Configure HW Flow Control mode (both CTS and RTS)
EricLew 0:80ee8f3b695e 1322 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1323 * Hardware Flow control feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1324 * @rmtoll CR3 RTSE LL_USART_SetHWFlowCtrl\n
EricLew 0:80ee8f3b695e 1325 * CR3 CTSE LL_USART_SetHWFlowCtrl
EricLew 0:80ee8f3b695e 1326 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1327 * @param HWFlowCtrlMode This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 1328 * @arg @ref LL_USART_HWCONTROL_NONE
EricLew 0:80ee8f3b695e 1329 * @arg @ref LL_USART_HWCONTROL_RTS
EricLew 0:80ee8f3b695e 1330 * @arg @ref LL_USART_HWCONTROL_CTS
EricLew 0:80ee8f3b695e 1331 * @arg @ref LL_USART_HWCONTROL_RTS_CTS
EricLew 0:80ee8f3b695e 1332 * @retval None
EricLew 0:80ee8f3b695e 1333 */
EricLew 0:80ee8f3b695e 1334 __STATIC_INLINE void LL_USART_SetHWFlowCtrl(USART_TypeDef *USARTx, uint32_t HWFlowCtrlMode)
EricLew 0:80ee8f3b695e 1335 {
EricLew 0:80ee8f3b695e 1336 MODIFY_REG(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE, HWFlowCtrlMode);
EricLew 0:80ee8f3b695e 1337 }
EricLew 0:80ee8f3b695e 1338
EricLew 0:80ee8f3b695e 1339 /**
EricLew 0:80ee8f3b695e 1340 * @brief Return HW Flow Control configuration (both CTS and RTS)
EricLew 0:80ee8f3b695e 1341 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1342 * Hardware Flow control feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1343 * @rmtoll CR3 RTSE LL_USART_GetHWFlowCtrl\n
EricLew 0:80ee8f3b695e 1344 * CR3 CTSE LL_USART_GetHWFlowCtrl
EricLew 0:80ee8f3b695e 1345 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1346 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 1347 * @arg @ref LL_USART_HWCONTROL_NONE
EricLew 0:80ee8f3b695e 1348 * @arg @ref LL_USART_HWCONTROL_RTS
EricLew 0:80ee8f3b695e 1349 * @arg @ref LL_USART_HWCONTROL_CTS
EricLew 0:80ee8f3b695e 1350 * @arg @ref LL_USART_HWCONTROL_RTS_CTS
EricLew 0:80ee8f3b695e 1351 */
EricLew 0:80ee8f3b695e 1352 __STATIC_INLINE uint32_t LL_USART_GetHWFlowCtrl(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1353 {
EricLew 0:80ee8f3b695e 1354 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_RTSE | USART_CR3_CTSE));
EricLew 0:80ee8f3b695e 1355 }
EricLew 0:80ee8f3b695e 1356
EricLew 0:80ee8f3b695e 1357 /**
EricLew 0:80ee8f3b695e 1358 * @brief Enable One bit sampling method
EricLew 0:80ee8f3b695e 1359 * @rmtoll CR3 ONEBIT LL_USART_EnableOneBitSamp
EricLew 0:80ee8f3b695e 1360 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1361 * @retval None
EricLew 0:80ee8f3b695e 1362 */
EricLew 0:80ee8f3b695e 1363 __STATIC_INLINE void LL_USART_EnableOneBitSamp(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1364 {
EricLew 0:80ee8f3b695e 1365 SET_BIT(USARTx->CR3, USART_CR3_ONEBIT);
EricLew 0:80ee8f3b695e 1366 }
EricLew 0:80ee8f3b695e 1367
EricLew 0:80ee8f3b695e 1368 /**
EricLew 0:80ee8f3b695e 1369 * @brief Disable One bit sampling method
EricLew 0:80ee8f3b695e 1370 * @rmtoll CR3 ONEBIT LL_USART_DisableOneBitSamp
EricLew 0:80ee8f3b695e 1371 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1372 * @retval None
EricLew 0:80ee8f3b695e 1373 */
EricLew 0:80ee8f3b695e 1374 __STATIC_INLINE void LL_USART_DisableOneBitSamp(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1375 {
EricLew 0:80ee8f3b695e 1376 CLEAR_BIT(USARTx->CR3, USART_CR3_ONEBIT);
EricLew 0:80ee8f3b695e 1377 }
EricLew 0:80ee8f3b695e 1378
EricLew 0:80ee8f3b695e 1379 /**
EricLew 0:80ee8f3b695e 1380 * @brief Indicate if One bit sampling method is enabled
EricLew 0:80ee8f3b695e 1381 * @rmtoll CR3 ONEBIT LL_USART_IsEnabledOneBitSamp
EricLew 0:80ee8f3b695e 1382 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1383 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 1384 */
EricLew 0:80ee8f3b695e 1385 __STATIC_INLINE uint32_t LL_USART_IsEnabledOneBitSamp(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1386 {
EricLew 0:80ee8f3b695e 1387 return (READ_BIT(USARTx->CR3, USART_CR3_ONEBIT) == (USART_CR3_ONEBIT));
EricLew 0:80ee8f3b695e 1388 }
EricLew 0:80ee8f3b695e 1389
EricLew 0:80ee8f3b695e 1390 /**
EricLew 0:80ee8f3b695e 1391 * @brief Enable Overrun detection
EricLew 0:80ee8f3b695e 1392 * @rmtoll CR3 OVRDIS LL_USART_EnableOverrunDetect
EricLew 0:80ee8f3b695e 1393 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1394 * @retval None
EricLew 0:80ee8f3b695e 1395 */
EricLew 0:80ee8f3b695e 1396 __STATIC_INLINE void LL_USART_EnableOverrunDetect(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1397 {
EricLew 0:80ee8f3b695e 1398 CLEAR_BIT(USARTx->CR3, USART_CR3_OVRDIS);
EricLew 0:80ee8f3b695e 1399 }
EricLew 0:80ee8f3b695e 1400
EricLew 0:80ee8f3b695e 1401 /**
EricLew 0:80ee8f3b695e 1402 * @brief Disable Overrun detection
EricLew 0:80ee8f3b695e 1403 * @rmtoll CR3 OVRDIS LL_USART_DisableOverrunDetect
EricLew 0:80ee8f3b695e 1404 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1405 * @retval None
EricLew 0:80ee8f3b695e 1406 */
EricLew 0:80ee8f3b695e 1407 __STATIC_INLINE void LL_USART_DisableOverrunDetect(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1408 {
EricLew 0:80ee8f3b695e 1409 SET_BIT(USARTx->CR3, USART_CR3_OVRDIS);
EricLew 0:80ee8f3b695e 1410 }
EricLew 0:80ee8f3b695e 1411
EricLew 0:80ee8f3b695e 1412 /**
EricLew 0:80ee8f3b695e 1413 * @brief Indicate if Overrun detection is enabled
EricLew 0:80ee8f3b695e 1414 * @rmtoll CR3 OVRDIS LL_USART_IsEnabledOverrunDetect
EricLew 0:80ee8f3b695e 1415 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1416 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 1417 */
EricLew 0:80ee8f3b695e 1418 __STATIC_INLINE uint32_t LL_USART_IsEnabledOverrunDetect(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1419 {
EricLew 0:80ee8f3b695e 1420 return (READ_BIT(USARTx->CR3, USART_CR3_OVRDIS) != USART_CR3_OVRDIS);
EricLew 0:80ee8f3b695e 1421 }
EricLew 0:80ee8f3b695e 1422
EricLew 0:80ee8f3b695e 1423 /**
EricLew 0:80ee8f3b695e 1424 * @brief Select event type for Wake UP Interrupt Flag (WUS[1:0] bits)
EricLew 0:80ee8f3b695e 1425 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1426 * Wake-up from Stop mode feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1427 * @rmtoll CR3 WUS LL_USART_SetWKUPType
EricLew 0:80ee8f3b695e 1428 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1429 * @param Type This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 1430 * @arg @ref LL_USART_WAKEUP_ON_ADDRESS
EricLew 0:80ee8f3b695e 1431 * @arg @ref LL_USART_WAKEUP_ON_STARTBIT
EricLew 0:80ee8f3b695e 1432 * @arg @ref LL_USART_WAKEUP_ON_RXNE
EricLew 0:80ee8f3b695e 1433 * @retval None
EricLew 0:80ee8f3b695e 1434 */
EricLew 0:80ee8f3b695e 1435 __STATIC_INLINE void LL_USART_SetWKUPType(USART_TypeDef *USARTx, uint32_t Type)
EricLew 0:80ee8f3b695e 1436 {
EricLew 0:80ee8f3b695e 1437 MODIFY_REG(USARTx->CR3, USART_CR3_WUS, Type);
EricLew 0:80ee8f3b695e 1438 }
EricLew 0:80ee8f3b695e 1439
EricLew 0:80ee8f3b695e 1440 /**
EricLew 0:80ee8f3b695e 1441 * @brief Return event type for Wake UP Interrupt Flag (WUS[1:0] bits)
EricLew 0:80ee8f3b695e 1442 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1443 * Wake-up from Stop mode feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1444 * @rmtoll CR3 WUS LL_USART_GetWKUPType
EricLew 0:80ee8f3b695e 1445 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1446 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 1447 * @arg @ref LL_USART_WAKEUP_ON_ADDRESS
EricLew 0:80ee8f3b695e 1448 * @arg @ref LL_USART_WAKEUP_ON_STARTBIT
EricLew 0:80ee8f3b695e 1449 * @arg @ref LL_USART_WAKEUP_ON_RXNE
EricLew 0:80ee8f3b695e 1450 */
EricLew 0:80ee8f3b695e 1451 __STATIC_INLINE uint32_t LL_USART_GetWKUPType(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1452 {
EricLew 0:80ee8f3b695e 1453 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_WUS));
EricLew 0:80ee8f3b695e 1454 }
EricLew 0:80ee8f3b695e 1455
EricLew 0:80ee8f3b695e 1456 /**
EricLew 0:80ee8f3b695e 1457 * @brief Configure USART BRR register for achieving expected Baudrate value.
EricLew 0:80ee8f3b695e 1458 * @note Compute and set USARTDIV value in BRR Register (full BRR content)
EricLew 0:80ee8f3b695e 1459 * according to used Peripheral Clock, Oversampling mode, and expected BaudRate values
EricLew 0:80ee8f3b695e 1460 * @rmtoll BRR BRR LL_USART_SetBaudRate
EricLew 0:80ee8f3b695e 1461 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1462 * @param PeriphClk Peripheral Clock
EricLew 0:80ee8f3b695e 1463 * @param OverSampling This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 1464 * @arg @ref LL_USART_OVERSAMPLING_16
EricLew 0:80ee8f3b695e 1465 * @arg @ref LL_USART_OVERSAMPLING_8
EricLew 0:80ee8f3b695e 1466 * @param BaudRate Baudrate
EricLew 0:80ee8f3b695e 1467 * @retval None
EricLew 0:80ee8f3b695e 1468 */
EricLew 0:80ee8f3b695e 1469 __STATIC_INLINE void LL_USART_SetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling,
EricLew 0:80ee8f3b695e 1470 uint32_t BaudRate)
EricLew 0:80ee8f3b695e 1471 {
EricLew 0:80ee8f3b695e 1472 register uint32_t usartdiv = 0x0;
EricLew 0:80ee8f3b695e 1473 register uint32_t brrtemp = 0x0;
EricLew 0:80ee8f3b695e 1474
EricLew 0:80ee8f3b695e 1475 if (OverSampling == LL_USART_OVERSAMPLING_8)
EricLew 0:80ee8f3b695e 1476 {
EricLew 0:80ee8f3b695e 1477 usartdiv = (uint16_t)(__LL_USART_DIV_SAMPLING8(PeriphClk, BaudRate));
EricLew 0:80ee8f3b695e 1478 brrtemp = usartdiv & 0xFFF0;
EricLew 0:80ee8f3b695e 1479 brrtemp |= (uint16_t)((usartdiv & (uint16_t)0x000F) >> 1U);
EricLew 0:80ee8f3b695e 1480 USARTx->BRR = brrtemp;
EricLew 0:80ee8f3b695e 1481 }
EricLew 0:80ee8f3b695e 1482 else
EricLew 0:80ee8f3b695e 1483 {
EricLew 0:80ee8f3b695e 1484 USARTx->BRR = (uint16_t)(__LL_USART_DIV_SAMPLING16(PeriphClk, BaudRate));
EricLew 0:80ee8f3b695e 1485 }
EricLew 0:80ee8f3b695e 1486 }
EricLew 0:80ee8f3b695e 1487
EricLew 0:80ee8f3b695e 1488 /**
EricLew 0:80ee8f3b695e 1489 * @brief Return current Baudrate value, according to USARTDIV present in BRR register
EricLew 0:80ee8f3b695e 1490 * (full BRR content), and to used Peripheral Clock and Oversampling mode values
EricLew 0:80ee8f3b695e 1491 * @rmtoll BRR BRR LL_USART_GetBaudRate
EricLew 0:80ee8f3b695e 1492 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1493 * @param PeriphClk Peripheral Clock
EricLew 0:80ee8f3b695e 1494 * @param OverSampling This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 1495 * @arg @ref LL_USART_OVERSAMPLING_16
EricLew 0:80ee8f3b695e 1496 * @arg @ref LL_USART_OVERSAMPLING_8
EricLew 0:80ee8f3b695e 1497 * @retval Baudrate
EricLew 0:80ee8f3b695e 1498 */
EricLew 0:80ee8f3b695e 1499 __STATIC_INLINE uint32_t LL_USART_GetBaudRate(USART_TypeDef *USARTx, uint32_t PeriphClk, uint32_t OverSampling)
EricLew 0:80ee8f3b695e 1500 {
EricLew 0:80ee8f3b695e 1501 register uint32_t usartdiv = 0x0;
EricLew 0:80ee8f3b695e 1502 register uint32_t brrtemp = 0x0;
EricLew 0:80ee8f3b695e 1503
EricLew 0:80ee8f3b695e 1504 if (OverSampling == LL_USART_OVERSAMPLING_8)
EricLew 0:80ee8f3b695e 1505 {
EricLew 0:80ee8f3b695e 1506 brrtemp = USARTx->BRR;
EricLew 0:80ee8f3b695e 1507 usartdiv = (uint16_t)((brrtemp & 0xFFF0) | ((brrtemp & 0x0007) << 1U)) ;
EricLew 0:80ee8f3b695e 1508 brrtemp = (PeriphClk * 2) / usartdiv;
EricLew 0:80ee8f3b695e 1509 }
EricLew 0:80ee8f3b695e 1510 else
EricLew 0:80ee8f3b695e 1511 {
EricLew 0:80ee8f3b695e 1512 brrtemp = PeriphClk / USARTx->BRR;
EricLew 0:80ee8f3b695e 1513 }
EricLew 0:80ee8f3b695e 1514 return (brrtemp);
EricLew 0:80ee8f3b695e 1515 }
EricLew 0:80ee8f3b695e 1516
EricLew 0:80ee8f3b695e 1517 /**
EricLew 0:80ee8f3b695e 1518 * @brief Set Receiver Time Out Value (expressed in nb of bits duration)
EricLew 0:80ee8f3b695e 1519 * @rmtoll RTOR RTO LL_USART_SetRxTimeout
EricLew 0:80ee8f3b695e 1520 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1521 * @param Timeout 0..0x00FFFFFF
EricLew 0:80ee8f3b695e 1522 * @retval None
EricLew 0:80ee8f3b695e 1523 */
EricLew 0:80ee8f3b695e 1524 __STATIC_INLINE void LL_USART_SetRxTimeout(USART_TypeDef *USARTx, uint32_t Timeout)
EricLew 0:80ee8f3b695e 1525 {
EricLew 0:80ee8f3b695e 1526 MODIFY_REG(USARTx->RTOR, USART_RTOR_RTO, Timeout);
EricLew 0:80ee8f3b695e 1527 }
EricLew 0:80ee8f3b695e 1528
EricLew 0:80ee8f3b695e 1529 /**
EricLew 0:80ee8f3b695e 1530 * @brief Get Receiver Time Out Value (expressed in nb of bits duration)
EricLew 0:80ee8f3b695e 1531 * @rmtoll RTOR RTO LL_USART_GetRxTimeout
EricLew 0:80ee8f3b695e 1532 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1533 * @retval 0..0x00FFFFFF
EricLew 0:80ee8f3b695e 1534 */
EricLew 0:80ee8f3b695e 1535 __STATIC_INLINE uint32_t LL_USART_GetRxTimeout(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1536 {
EricLew 0:80ee8f3b695e 1537 return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_RTO));
EricLew 0:80ee8f3b695e 1538 }
EricLew 0:80ee8f3b695e 1539
EricLew 0:80ee8f3b695e 1540 /**
EricLew 0:80ee8f3b695e 1541 * @brief Set Block Length value in reception
EricLew 0:80ee8f3b695e 1542 * @rmtoll RTOR BLEN LL_USART_SetBlockLength
EricLew 0:80ee8f3b695e 1543 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1544 * @param BlockLength 0..0xFF
EricLew 0:80ee8f3b695e 1545 * @retval None
EricLew 0:80ee8f3b695e 1546 */
EricLew 0:80ee8f3b695e 1547 __STATIC_INLINE void LL_USART_SetBlockLength(USART_TypeDef *USARTx, uint32_t BlockLength)
EricLew 0:80ee8f3b695e 1548 {
EricLew 0:80ee8f3b695e 1549 MODIFY_REG(USARTx->RTOR, USART_RTOR_BLEN, BlockLength << USART_POSITION_RTOR_BLEN);
EricLew 0:80ee8f3b695e 1550 }
EricLew 0:80ee8f3b695e 1551
EricLew 0:80ee8f3b695e 1552 /**
EricLew 0:80ee8f3b695e 1553 * @brief Get Block Length value in reception
EricLew 0:80ee8f3b695e 1554 * @rmtoll RTOR BLEN LL_USART_GetBlockLength
EricLew 0:80ee8f3b695e 1555 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1556 * @retval 0..0xFF
EricLew 0:80ee8f3b695e 1557 */
EricLew 0:80ee8f3b695e 1558 __STATIC_INLINE uint32_t LL_USART_GetBlockLength(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1559 {
EricLew 0:80ee8f3b695e 1560 return (uint32_t)(READ_BIT(USARTx->RTOR, USART_RTOR_BLEN) >> USART_POSITION_RTOR_BLEN);
EricLew 0:80ee8f3b695e 1561 }
EricLew 0:80ee8f3b695e 1562
EricLew 0:80ee8f3b695e 1563 /**
EricLew 0:80ee8f3b695e 1564 * @}
EricLew 0:80ee8f3b695e 1565 */
EricLew 0:80ee8f3b695e 1566
EricLew 0:80ee8f3b695e 1567 /** @defgroup USART_LL_EF_Configuration_IRDA Configuration functions related to Irda feature
EricLew 0:80ee8f3b695e 1568 * @{
EricLew 0:80ee8f3b695e 1569 */
EricLew 0:80ee8f3b695e 1570
EricLew 0:80ee8f3b695e 1571 /**
EricLew 0:80ee8f3b695e 1572 * @brief Enable IrDA mode
EricLew 0:80ee8f3b695e 1573 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1574 * IrDA feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1575 * @rmtoll CR3 IREN LL_USART_EnableIrda
EricLew 0:80ee8f3b695e 1576 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1577 * @retval None
EricLew 0:80ee8f3b695e 1578 */
EricLew 0:80ee8f3b695e 1579 __STATIC_INLINE void LL_USART_EnableIrda(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1580 {
EricLew 0:80ee8f3b695e 1581 SET_BIT(USARTx->CR3, USART_CR3_IREN);
EricLew 0:80ee8f3b695e 1582 }
EricLew 0:80ee8f3b695e 1583
EricLew 0:80ee8f3b695e 1584 /**
EricLew 0:80ee8f3b695e 1585 * @brief Disable IrDA mode
EricLew 0:80ee8f3b695e 1586 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1587 * IrDA feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1588 * @rmtoll CR3 IREN LL_USART_DisableIrda
EricLew 0:80ee8f3b695e 1589 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1590 * @retval None
EricLew 0:80ee8f3b695e 1591 */
EricLew 0:80ee8f3b695e 1592 __STATIC_INLINE void LL_USART_DisableIrda(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1593 {
EricLew 0:80ee8f3b695e 1594 CLEAR_BIT(USARTx->CR3, USART_CR3_IREN);
EricLew 0:80ee8f3b695e 1595 }
EricLew 0:80ee8f3b695e 1596
EricLew 0:80ee8f3b695e 1597 /**
EricLew 0:80ee8f3b695e 1598 * @brief Indicate if IrDA mode is enabled
EricLew 0:80ee8f3b695e 1599 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1600 * IrDA feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1601 * @rmtoll CR3 IREN LL_USART_IsEnabledIrda
EricLew 0:80ee8f3b695e 1602 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1603 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 1604 */
EricLew 0:80ee8f3b695e 1605 __STATIC_INLINE uint32_t LL_USART_IsEnabledIrda(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1606 {
EricLew 0:80ee8f3b695e 1607 return (READ_BIT(USARTx->CR3, USART_CR3_IREN) == (USART_CR3_IREN));
EricLew 0:80ee8f3b695e 1608 }
EricLew 0:80ee8f3b695e 1609
EricLew 0:80ee8f3b695e 1610 /**
EricLew 0:80ee8f3b695e 1611 * @brief Configure IrDA Power Mode (Normal or Low Power)
EricLew 0:80ee8f3b695e 1612 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1613 * IrDA feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1614 * @rmtoll CR3 IRLP LL_USART_SetIrdaPowerMode
EricLew 0:80ee8f3b695e 1615 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1616 * @param PowerMode This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 1617 * @arg @ref LL_USART_IRDA_POWER_NORMAL
EricLew 0:80ee8f3b695e 1618 * @arg @ref LL_USART_IRDA_POWER_LOW
EricLew 0:80ee8f3b695e 1619 * @retval None
EricLew 0:80ee8f3b695e 1620 */
EricLew 0:80ee8f3b695e 1621 __STATIC_INLINE void LL_USART_SetIrdaPowerMode(USART_TypeDef *USARTx, uint32_t PowerMode)
EricLew 0:80ee8f3b695e 1622 {
EricLew 0:80ee8f3b695e 1623 MODIFY_REG(USARTx->CR3, USART_CR3_IRLP, PowerMode);
EricLew 0:80ee8f3b695e 1624 }
EricLew 0:80ee8f3b695e 1625
EricLew 0:80ee8f3b695e 1626 /**
EricLew 0:80ee8f3b695e 1627 * @brief Retrieve IrDA Power Mode configuration (Normal or Low Power)
EricLew 0:80ee8f3b695e 1628 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1629 * IrDA feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1630 * @rmtoll CR3 IRLP LL_USART_GetIrdaPowerMode
EricLew 0:80ee8f3b695e 1631 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1632 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 1633 * @arg @ref LL_USART_IRDA_POWER_NORMAL
EricLew 0:80ee8f3b695e 1634 * @arg @ref LL_USART_PHASE_2EDGE
EricLew 0:80ee8f3b695e 1635 */
EricLew 0:80ee8f3b695e 1636 __STATIC_INLINE uint32_t LL_USART_GetIrdaPowerMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1637 {
EricLew 0:80ee8f3b695e 1638 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_IRLP));
EricLew 0:80ee8f3b695e 1639 }
EricLew 0:80ee8f3b695e 1640
EricLew 0:80ee8f3b695e 1641 /**
EricLew 0:80ee8f3b695e 1642 * @brief Set Irda prescaler value, used for dividing the USART clock source
EricLew 0:80ee8f3b695e 1643 * to achieve the Irda Low Power frequency (8 bits value)
EricLew 0:80ee8f3b695e 1644 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1645 * IrDA feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1646 * @rmtoll GTPR PSC LL_USART_SetIrdaPrescaler
EricLew 0:80ee8f3b695e 1647 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1648 * @param PrescalerValue 0..0xFF
EricLew 0:80ee8f3b695e 1649 * @retval None
EricLew 0:80ee8f3b695e 1650 */
EricLew 0:80ee8f3b695e 1651 __STATIC_INLINE void LL_USART_SetIrdaPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
EricLew 0:80ee8f3b695e 1652 {
EricLew 0:80ee8f3b695e 1653 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue);
EricLew 0:80ee8f3b695e 1654 }
EricLew 0:80ee8f3b695e 1655
EricLew 0:80ee8f3b695e 1656 /**
EricLew 0:80ee8f3b695e 1657 * @brief Return Irda prescaler value, used for dividing the USART clock source
EricLew 0:80ee8f3b695e 1658 * to achieve the Irda Low Power frequency (8 bits value)
EricLew 0:80ee8f3b695e 1659 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1660 * IrDA feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1661 * @rmtoll GTPR PSC LL_USART_GetIrdaPrescaler
EricLew 0:80ee8f3b695e 1662 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1663 * @retval Irda prescaler value (0..0xFF)
EricLew 0:80ee8f3b695e 1664 */
EricLew 0:80ee8f3b695e 1665 __STATIC_INLINE uint32_t LL_USART_GetIrdaPrescaler(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1666 {
EricLew 0:80ee8f3b695e 1667 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
EricLew 0:80ee8f3b695e 1668 }
EricLew 0:80ee8f3b695e 1669
EricLew 0:80ee8f3b695e 1670 /**
EricLew 0:80ee8f3b695e 1671 * @}
EricLew 0:80ee8f3b695e 1672 */
EricLew 0:80ee8f3b695e 1673
EricLew 0:80ee8f3b695e 1674 /** @defgroup USART_LL_EF_Configuration_Smartcard Configuration functions related to Smartcard feature
EricLew 0:80ee8f3b695e 1675 * @{
EricLew 0:80ee8f3b695e 1676 */
EricLew 0:80ee8f3b695e 1677
EricLew 0:80ee8f3b695e 1678 /**
EricLew 0:80ee8f3b695e 1679 * @brief Enable Smartcard NACK transmission
EricLew 0:80ee8f3b695e 1680 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1681 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1682 * @rmtoll CR3 NACK LL_USART_EnableSmartcardNACK
EricLew 0:80ee8f3b695e 1683 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1684 * @retval None
EricLew 0:80ee8f3b695e 1685 */
EricLew 0:80ee8f3b695e 1686 __STATIC_INLINE void LL_USART_EnableSmartcardNACK(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1687 {
EricLew 0:80ee8f3b695e 1688 SET_BIT(USARTx->CR3, USART_CR3_NACK);
EricLew 0:80ee8f3b695e 1689 }
EricLew 0:80ee8f3b695e 1690
EricLew 0:80ee8f3b695e 1691 /**
EricLew 0:80ee8f3b695e 1692 * @brief Disable Smartcard NACK transmission
EricLew 0:80ee8f3b695e 1693 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1694 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1695 * @rmtoll CR3 NACK LL_USART_DisableSmartcardNACK
EricLew 0:80ee8f3b695e 1696 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1697 * @retval None
EricLew 0:80ee8f3b695e 1698 */
EricLew 0:80ee8f3b695e 1699 __STATIC_INLINE void LL_USART_DisableSmartcardNACK(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1700 {
EricLew 0:80ee8f3b695e 1701 CLEAR_BIT(USARTx->CR3, USART_CR3_NACK);
EricLew 0:80ee8f3b695e 1702 }
EricLew 0:80ee8f3b695e 1703
EricLew 0:80ee8f3b695e 1704 /**
EricLew 0:80ee8f3b695e 1705 * @brief Indicate if Smartcard NACK transmission is enabled
EricLew 0:80ee8f3b695e 1706 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1707 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1708 * @rmtoll CR3 NACK LL_USART_IsEnabledSmartcardNACK
EricLew 0:80ee8f3b695e 1709 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1710 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 1711 */
EricLew 0:80ee8f3b695e 1712 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcardNACK(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1713 {
EricLew 0:80ee8f3b695e 1714 return (READ_BIT(USARTx->CR3, USART_CR3_NACK) == (USART_CR3_NACK));
EricLew 0:80ee8f3b695e 1715 }
EricLew 0:80ee8f3b695e 1716
EricLew 0:80ee8f3b695e 1717 /**
EricLew 0:80ee8f3b695e 1718 * @brief Enable Smartcard mode
EricLew 0:80ee8f3b695e 1719 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1720 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1721 * @rmtoll CR3 SCEN LL_USART_EnableSmartcard
EricLew 0:80ee8f3b695e 1722 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1723 * @retval None
EricLew 0:80ee8f3b695e 1724 */
EricLew 0:80ee8f3b695e 1725 __STATIC_INLINE void LL_USART_EnableSmartcard(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1726 {
EricLew 0:80ee8f3b695e 1727 SET_BIT(USARTx->CR3, USART_CR3_SCEN);
EricLew 0:80ee8f3b695e 1728 }
EricLew 0:80ee8f3b695e 1729
EricLew 0:80ee8f3b695e 1730 /**
EricLew 0:80ee8f3b695e 1731 * @brief Disable Smartcard mode
EricLew 0:80ee8f3b695e 1732 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1733 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1734 * @rmtoll CR3 SCEN LL_USART_DisableSmartcard
EricLew 0:80ee8f3b695e 1735 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1736 * @retval None
EricLew 0:80ee8f3b695e 1737 */
EricLew 0:80ee8f3b695e 1738 __STATIC_INLINE void LL_USART_DisableSmartcard(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1739 {
EricLew 0:80ee8f3b695e 1740 CLEAR_BIT(USARTx->CR3, USART_CR3_SCEN);
EricLew 0:80ee8f3b695e 1741 }
EricLew 0:80ee8f3b695e 1742
EricLew 0:80ee8f3b695e 1743 /**
EricLew 0:80ee8f3b695e 1744 * @brief Indicate if Smartcard mode is enabled
EricLew 0:80ee8f3b695e 1745 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1746 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1747 * @rmtoll CR3 SCEN LL_USART_IsEnabledSmartcard
EricLew 0:80ee8f3b695e 1748 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1749 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 1750 */
EricLew 0:80ee8f3b695e 1751 __STATIC_INLINE uint32_t LL_USART_IsEnabledSmartcard(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1752 {
EricLew 0:80ee8f3b695e 1753 return (READ_BIT(USARTx->CR3, USART_CR3_SCEN) == (USART_CR3_SCEN));
EricLew 0:80ee8f3b695e 1754 }
EricLew 0:80ee8f3b695e 1755
EricLew 0:80ee8f3b695e 1756 /**
EricLew 0:80ee8f3b695e 1757 * @brief Set Smartcard Auto-Retry Count value (SCARCNT[2:0] bits)
EricLew 0:80ee8f3b695e 1758 * @note This bit-field specifies the number of retries in transmit and receive, in Smartcard mode.
EricLew 0:80ee8f3b695e 1759 * In transmission mode, it specifies the number of automatic retransmission retries, before
EricLew 0:80ee8f3b695e 1760 * generating a transmission error (FE bit set).
EricLew 0:80ee8f3b695e 1761 * In reception mode, it specifies the number or erroneous reception trials, before generating a
EricLew 0:80ee8f3b695e 1762 * reception error (RXNE and PE bits set)
EricLew 0:80ee8f3b695e 1763 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1764 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1765 * @rmtoll CR3 SCARCNT LL_USART_SetSmartcardAutoRetryCount
EricLew 0:80ee8f3b695e 1766 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1767 * @param AutoRetryCount 0..7
EricLew 0:80ee8f3b695e 1768 * @retval None
EricLew 0:80ee8f3b695e 1769 */
EricLew 0:80ee8f3b695e 1770 __STATIC_INLINE void LL_USART_SetSmartcardAutoRetryCount(USART_TypeDef *USARTx, uint32_t AutoRetryCount)
EricLew 0:80ee8f3b695e 1771 {
EricLew 0:80ee8f3b695e 1772 MODIFY_REG(USARTx->CR3, USART_CR3_SCARCNT, AutoRetryCount << USART_POSITION_CR3_SCARCNT);
EricLew 0:80ee8f3b695e 1773 }
EricLew 0:80ee8f3b695e 1774
EricLew 0:80ee8f3b695e 1775 /**
EricLew 0:80ee8f3b695e 1776 * @brief Return Smartcard Auto-Retry Count value (SCARCNT[2:0] bits)
EricLew 0:80ee8f3b695e 1777 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1778 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1779 * @rmtoll CR3 SCARCNT LL_USART_GetSmartcardAutoRetryCount
EricLew 0:80ee8f3b695e 1780 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1781 * @retval Smartcard Auto-Retry Count value (0..7)
EricLew 0:80ee8f3b695e 1782 */
EricLew 0:80ee8f3b695e 1783 __STATIC_INLINE uint32_t LL_USART_GetSmartcardAutoRetryCount(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1784 {
EricLew 0:80ee8f3b695e 1785 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_SCARCNT) >> USART_POSITION_CR3_SCARCNT);
EricLew 0:80ee8f3b695e 1786 }
EricLew 0:80ee8f3b695e 1787
EricLew 0:80ee8f3b695e 1788 /**
EricLew 0:80ee8f3b695e 1789 * @brief Set Smartcard prescaler value, used for dividing the USART clock
EricLew 0:80ee8f3b695e 1790 * source to provide the SMARTCARD Clock (5 bits value)
EricLew 0:80ee8f3b695e 1791 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1792 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1793 * @rmtoll GTPR PSC LL_USART_SetSmartcardPrescaler
EricLew 0:80ee8f3b695e 1794 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1795 * @param PrescalerValue 0..31
EricLew 0:80ee8f3b695e 1796 * @retval None
EricLew 0:80ee8f3b695e 1797 */
EricLew 0:80ee8f3b695e 1798 __STATIC_INLINE void LL_USART_SetSmartcardPrescaler(USART_TypeDef *USARTx, uint32_t PrescalerValue)
EricLew 0:80ee8f3b695e 1799 {
EricLew 0:80ee8f3b695e 1800 MODIFY_REG(USARTx->GTPR, USART_GTPR_PSC, PrescalerValue);
EricLew 0:80ee8f3b695e 1801 }
EricLew 0:80ee8f3b695e 1802
EricLew 0:80ee8f3b695e 1803 /**
EricLew 0:80ee8f3b695e 1804 * @brief Return Smartcard prescaler value, used for dividing the USART clock
EricLew 0:80ee8f3b695e 1805 * source to provide the SMARTCARD Clock (5 bits value)
EricLew 0:80ee8f3b695e 1806 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1807 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1808 * @rmtoll GTPR PSC LL_USART_GetSmartcardPrescaler
EricLew 0:80ee8f3b695e 1809 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1810 * @retval Smartcard prescaler value (0..31)
EricLew 0:80ee8f3b695e 1811 */
EricLew 0:80ee8f3b695e 1812 __STATIC_INLINE uint32_t LL_USART_GetSmartcardPrescaler(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1813 {
EricLew 0:80ee8f3b695e 1814 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_PSC));
EricLew 0:80ee8f3b695e 1815 }
EricLew 0:80ee8f3b695e 1816
EricLew 0:80ee8f3b695e 1817 /**
EricLew 0:80ee8f3b695e 1818 * @brief Set Smartcard Guard time value, expressed in nb of baud clocks periods
EricLew 0:80ee8f3b695e 1819 * (GT[7:0] bits : Guard time value)
EricLew 0:80ee8f3b695e 1820 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1821 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1822 * @rmtoll GTPR GT LL_USART_SetSmartcardGuardTime
EricLew 0:80ee8f3b695e 1823 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1824 * @param GuardTime 0..0xFF
EricLew 0:80ee8f3b695e 1825 * @retval None
EricLew 0:80ee8f3b695e 1826 */
EricLew 0:80ee8f3b695e 1827 __STATIC_INLINE void LL_USART_SetSmartcardGuardTime(USART_TypeDef *USARTx, uint32_t GuardTime)
EricLew 0:80ee8f3b695e 1828 {
EricLew 0:80ee8f3b695e 1829 MODIFY_REG(USARTx->GTPR, USART_GTPR_GT, GuardTime << USART_POSITION_GTPR_GT);
EricLew 0:80ee8f3b695e 1830 }
EricLew 0:80ee8f3b695e 1831
EricLew 0:80ee8f3b695e 1832 /**
EricLew 0:80ee8f3b695e 1833 * @brief Return Smartcard Guard time value, expressed in nb of baud clocks periods
EricLew 0:80ee8f3b695e 1834 * (GT[7:0] bits : Guard time value)
EricLew 0:80ee8f3b695e 1835 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1836 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1837 * @rmtoll GTPR GT LL_USART_GetSmartcardGuardTime
EricLew 0:80ee8f3b695e 1838 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1839 * @retval Smartcard Guard time value (0..0xFF)
EricLew 0:80ee8f3b695e 1840 */
EricLew 0:80ee8f3b695e 1841 __STATIC_INLINE uint32_t LL_USART_GetSmartcardGuardTime(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1842 {
EricLew 0:80ee8f3b695e 1843 return (uint32_t)(READ_BIT(USARTx->GTPR, USART_GTPR_GT) >> USART_POSITION_GTPR_GT);
EricLew 0:80ee8f3b695e 1844 }
EricLew 0:80ee8f3b695e 1845
EricLew 0:80ee8f3b695e 1846 /**
EricLew 0:80ee8f3b695e 1847 * @}
EricLew 0:80ee8f3b695e 1848 */
EricLew 0:80ee8f3b695e 1849
EricLew 0:80ee8f3b695e 1850 /** @defgroup USART_LL_EF_Configuration_HalfDuplex Configuration functions related to Half Duplex feature
EricLew 0:80ee8f3b695e 1851 * @{
EricLew 0:80ee8f3b695e 1852 */
EricLew 0:80ee8f3b695e 1853
EricLew 0:80ee8f3b695e 1854 /**
EricLew 0:80ee8f3b695e 1855 * @brief Enable Single Wire Half-Duplex mode
EricLew 0:80ee8f3b695e 1856 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1857 * Half-Duplex mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1858 * @rmtoll CR3 HDSEL LL_USART_EnableHalfDuplex
EricLew 0:80ee8f3b695e 1859 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1860 * @retval None
EricLew 0:80ee8f3b695e 1861 */
EricLew 0:80ee8f3b695e 1862 __STATIC_INLINE void LL_USART_EnableHalfDuplex(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1863 {
EricLew 0:80ee8f3b695e 1864 SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
EricLew 0:80ee8f3b695e 1865 }
EricLew 0:80ee8f3b695e 1866
EricLew 0:80ee8f3b695e 1867 /**
EricLew 0:80ee8f3b695e 1868 * @brief Disable Single Wire Half-Duplex mode
EricLew 0:80ee8f3b695e 1869 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1870 * Half-Duplex mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1871 * @rmtoll CR3 HDSEL LL_USART_DisableHalfDuplex
EricLew 0:80ee8f3b695e 1872 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1873 * @retval None
EricLew 0:80ee8f3b695e 1874 */
EricLew 0:80ee8f3b695e 1875 __STATIC_INLINE void LL_USART_DisableHalfDuplex(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1876 {
EricLew 0:80ee8f3b695e 1877 CLEAR_BIT(USARTx->CR3, USART_CR3_HDSEL);
EricLew 0:80ee8f3b695e 1878 }
EricLew 0:80ee8f3b695e 1879
EricLew 0:80ee8f3b695e 1880 /**
EricLew 0:80ee8f3b695e 1881 * @brief Indicate if Single Wire Half-Duplex mode is enabled
EricLew 0:80ee8f3b695e 1882 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1883 * Half-Duplex mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1884 * @rmtoll CR3 HDSEL LL_USART_IsEnabledHalfDuplex
EricLew 0:80ee8f3b695e 1885 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1886 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 1887 */
EricLew 0:80ee8f3b695e 1888 __STATIC_INLINE uint32_t LL_USART_IsEnabledHalfDuplex(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1889 {
EricLew 0:80ee8f3b695e 1890 return (READ_BIT(USARTx->CR3, USART_CR3_HDSEL) == (USART_CR3_HDSEL));
EricLew 0:80ee8f3b695e 1891 }
EricLew 0:80ee8f3b695e 1892
EricLew 0:80ee8f3b695e 1893 /**
EricLew 0:80ee8f3b695e 1894 * @}
EricLew 0:80ee8f3b695e 1895 */
EricLew 0:80ee8f3b695e 1896
EricLew 0:80ee8f3b695e 1897 /** @defgroup USART_LL_EF_Configuration_LIN Configuration functions related to LIN feature
EricLew 0:80ee8f3b695e 1898 * @{
EricLew 0:80ee8f3b695e 1899 */
EricLew 0:80ee8f3b695e 1900
EricLew 0:80ee8f3b695e 1901 /**
EricLew 0:80ee8f3b695e 1902 * @brief Set LIN Break Detection Length
EricLew 0:80ee8f3b695e 1903 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1904 * LIN feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1905 * @rmtoll CR2 LBDL LL_USART_SetLINBrkDetectionLen
EricLew 0:80ee8f3b695e 1906 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1907 * @param LINBDLength This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 1908 * @arg @ref LL_USART_LINBREAK_DETECT_10B
EricLew 0:80ee8f3b695e 1909 * @arg @ref LL_USART_LINBREAK_DETECT_11B
EricLew 0:80ee8f3b695e 1910 * @retval None
EricLew 0:80ee8f3b695e 1911 */
EricLew 0:80ee8f3b695e 1912 __STATIC_INLINE void LL_USART_SetLINBrkDetectionLen(USART_TypeDef *USARTx, uint32_t LINBDLength)
EricLew 0:80ee8f3b695e 1913 {
EricLew 0:80ee8f3b695e 1914 MODIFY_REG(USARTx->CR2, USART_CR2_LBDL, LINBDLength);
EricLew 0:80ee8f3b695e 1915 }
EricLew 0:80ee8f3b695e 1916
EricLew 0:80ee8f3b695e 1917 /**
EricLew 0:80ee8f3b695e 1918 * @brief Return LIN Break Detection Length
EricLew 0:80ee8f3b695e 1919 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1920 * LIN feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1921 * @rmtoll CR2 LBDL LL_USART_GetLINBrkDetectionLen
EricLew 0:80ee8f3b695e 1922 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1923 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 1924 * @arg @ref LL_USART_LINBREAK_DETECT_10B
EricLew 0:80ee8f3b695e 1925 * @arg @ref LL_USART_LINBREAK_DETECT_11B
EricLew 0:80ee8f3b695e 1926 */
EricLew 0:80ee8f3b695e 1927 __STATIC_INLINE uint32_t LL_USART_GetLINBrkDetectionLen(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1928 {
EricLew 0:80ee8f3b695e 1929 return (uint32_t)(READ_BIT(USARTx->CR2, USART_CR2_LBDL));
EricLew 0:80ee8f3b695e 1930 }
EricLew 0:80ee8f3b695e 1931
EricLew 0:80ee8f3b695e 1932 /**
EricLew 0:80ee8f3b695e 1933 * @brief Enable LIN mode
EricLew 0:80ee8f3b695e 1934 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1935 * LIN feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1936 * @rmtoll CR2 LINEN LL_USART_EnableLIN
EricLew 0:80ee8f3b695e 1937 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1938 * @retval None
EricLew 0:80ee8f3b695e 1939 */
EricLew 0:80ee8f3b695e 1940 __STATIC_INLINE void LL_USART_EnableLIN(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1941 {
EricLew 0:80ee8f3b695e 1942 SET_BIT(USARTx->CR2, USART_CR2_LINEN);
EricLew 0:80ee8f3b695e 1943 }
EricLew 0:80ee8f3b695e 1944
EricLew 0:80ee8f3b695e 1945 /**
EricLew 0:80ee8f3b695e 1946 * @brief Disable LIN mode
EricLew 0:80ee8f3b695e 1947 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1948 * LIN feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1949 * @rmtoll CR2 LINEN LL_USART_DisableLIN
EricLew 0:80ee8f3b695e 1950 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1951 * @retval None
EricLew 0:80ee8f3b695e 1952 */
EricLew 0:80ee8f3b695e 1953 __STATIC_INLINE void LL_USART_DisableLIN(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1954 {
EricLew 0:80ee8f3b695e 1955 CLEAR_BIT(USARTx->CR2, USART_CR2_LINEN);
EricLew 0:80ee8f3b695e 1956 }
EricLew 0:80ee8f3b695e 1957
EricLew 0:80ee8f3b695e 1958 /**
EricLew 0:80ee8f3b695e 1959 * @brief Indicate if LIN mode is enabled
EricLew 0:80ee8f3b695e 1960 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1961 * LIN feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1962 * @rmtoll CR2 LINEN LL_USART_IsEnabledLIN
EricLew 0:80ee8f3b695e 1963 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1964 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 1965 */
EricLew 0:80ee8f3b695e 1966 __STATIC_INLINE uint32_t LL_USART_IsEnabledLIN(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 1967 {
EricLew 0:80ee8f3b695e 1968 return (READ_BIT(USARTx->CR2, USART_CR2_LINEN) == (USART_CR2_LINEN));
EricLew 0:80ee8f3b695e 1969 }
EricLew 0:80ee8f3b695e 1970
EricLew 0:80ee8f3b695e 1971 /**
EricLew 0:80ee8f3b695e 1972 * @}
EricLew 0:80ee8f3b695e 1973 */
EricLew 0:80ee8f3b695e 1974
EricLew 0:80ee8f3b695e 1975 /** @defgroup USART_LL_EF_Configuration_DE Configuration functions related to Driver Enable feature
EricLew 0:80ee8f3b695e 1976 * @{
EricLew 0:80ee8f3b695e 1977 */
EricLew 0:80ee8f3b695e 1978
EricLew 0:80ee8f3b695e 1979 /**
EricLew 0:80ee8f3b695e 1980 * @brief Set DEDT (Driver Enable Deassertion Time), Time value expressed on 5 bits ([4:0] bits).
EricLew 0:80ee8f3b695e 1981 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1982 * Driver Enable feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1983 * @rmtoll CR1 DEDT LL_USART_SetDEDeassertionTime
EricLew 0:80ee8f3b695e 1984 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1985 * @param Time 0..31
EricLew 0:80ee8f3b695e 1986 * @retval None
EricLew 0:80ee8f3b695e 1987 */
EricLew 0:80ee8f3b695e 1988 __STATIC_INLINE void LL_USART_SetDEDeassertionTime(USART_TypeDef *USARTx, uint32_t Time)
EricLew 0:80ee8f3b695e 1989 {
EricLew 0:80ee8f3b695e 1990 MODIFY_REG(USARTx->CR1, USART_CR1_DEDT, Time << USART_POSITION_CR1_DEDT);
EricLew 0:80ee8f3b695e 1991 }
EricLew 0:80ee8f3b695e 1992
EricLew 0:80ee8f3b695e 1993 /**
EricLew 0:80ee8f3b695e 1994 * @brief Return DEDT (Driver Enable Deassertion Time)
EricLew 0:80ee8f3b695e 1995 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 1996 * Driver Enable feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 1997 * @rmtoll CR1 DEDT LL_USART_GetDEDeassertionTime
EricLew 0:80ee8f3b695e 1998 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 1999 * @retval Time value expressed on 5 bits ([4:0] bits) : 0..31
EricLew 0:80ee8f3b695e 2000 */
EricLew 0:80ee8f3b695e 2001 __STATIC_INLINE uint32_t LL_USART_GetDEDeassertionTime(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2002 {
EricLew 0:80ee8f3b695e 2003 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEDT) >> USART_POSITION_CR1_DEDT);
EricLew 0:80ee8f3b695e 2004 }
EricLew 0:80ee8f3b695e 2005
EricLew 0:80ee8f3b695e 2006 /**
EricLew 0:80ee8f3b695e 2007 * @brief Set DEAT (Driver Enable Assertion Time), Time value expressed on 5 bits ([4:0] bits).
EricLew 0:80ee8f3b695e 2008 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2009 * Driver Enable feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2010 * @rmtoll CR1 DEAT LL_USART_SetDEAssertionTime
EricLew 0:80ee8f3b695e 2011 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2012 * @param Time 0..31
EricLew 0:80ee8f3b695e 2013 * @retval None
EricLew 0:80ee8f3b695e 2014 */
EricLew 0:80ee8f3b695e 2015 __STATIC_INLINE void LL_USART_SetDEAssertionTime(USART_TypeDef *USARTx, uint32_t Time)
EricLew 0:80ee8f3b695e 2016 {
EricLew 0:80ee8f3b695e 2017 MODIFY_REG(USARTx->CR1, USART_CR1_DEAT, Time << USART_POSITION_CR1_DEAT);
EricLew 0:80ee8f3b695e 2018 }
EricLew 0:80ee8f3b695e 2019
EricLew 0:80ee8f3b695e 2020 /**
EricLew 0:80ee8f3b695e 2021 * @brief Return DEAT (Driver Enable Assertion Time)
EricLew 0:80ee8f3b695e 2022 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2023 * Driver Enable feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2024 * @rmtoll CR1 DEAT LL_USART_GetDEAssertionTime
EricLew 0:80ee8f3b695e 2025 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2026 * @retval Time value expressed on 5 bits ([4:0] bits) : 0..31
EricLew 0:80ee8f3b695e 2027 */
EricLew 0:80ee8f3b695e 2028 __STATIC_INLINE uint32_t LL_USART_GetDEAssertionTime(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2029 {
EricLew 0:80ee8f3b695e 2030 return (uint32_t)(READ_BIT(USARTx->CR1, USART_CR1_DEAT) >> USART_POSITION_CR1_DEAT);
EricLew 0:80ee8f3b695e 2031 }
EricLew 0:80ee8f3b695e 2032
EricLew 0:80ee8f3b695e 2033 /**
EricLew 0:80ee8f3b695e 2034 * @brief Enable Driver Enable (DE) Mode
EricLew 0:80ee8f3b695e 2035 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2036 * Driver Enable feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2037 * @rmtoll CR3 DEM LL_USART_EnableDEMode
EricLew 0:80ee8f3b695e 2038 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2039 * @retval None
EricLew 0:80ee8f3b695e 2040 */
EricLew 0:80ee8f3b695e 2041 __STATIC_INLINE void LL_USART_EnableDEMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2042 {
EricLew 0:80ee8f3b695e 2043 SET_BIT(USARTx->CR3, USART_CR3_DEM);
EricLew 0:80ee8f3b695e 2044 }
EricLew 0:80ee8f3b695e 2045
EricLew 0:80ee8f3b695e 2046 /**
EricLew 0:80ee8f3b695e 2047 * @brief Disable Driver Enable (DE) Mode
EricLew 0:80ee8f3b695e 2048 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2049 * Driver Enable feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2050 * @rmtoll CR3 DEM LL_USART_DisableDEMode
EricLew 0:80ee8f3b695e 2051 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2052 * @retval None
EricLew 0:80ee8f3b695e 2053 */
EricLew 0:80ee8f3b695e 2054 __STATIC_INLINE void LL_USART_DisableDEMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2055 {
EricLew 0:80ee8f3b695e 2056 CLEAR_BIT(USARTx->CR3, USART_CR3_DEM);
EricLew 0:80ee8f3b695e 2057 }
EricLew 0:80ee8f3b695e 2058
EricLew 0:80ee8f3b695e 2059 /**
EricLew 0:80ee8f3b695e 2060 * @brief Indicate if Driver Enable (DE) Mode is enabled
EricLew 0:80ee8f3b695e 2061 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2062 * Driver Enable feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2063 * @rmtoll CR3 DEM LL_USART_IsEnabledDEMode
EricLew 0:80ee8f3b695e 2064 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2065 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2066 */
EricLew 0:80ee8f3b695e 2067 __STATIC_INLINE uint32_t LL_USART_IsEnabledDEMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2068 {
EricLew 0:80ee8f3b695e 2069 return (READ_BIT(USARTx->CR3, USART_CR3_DEM) == (USART_CR3_DEM));
EricLew 0:80ee8f3b695e 2070 }
EricLew 0:80ee8f3b695e 2071
EricLew 0:80ee8f3b695e 2072 /**
EricLew 0:80ee8f3b695e 2073 * @brief Select Driver Enable Polarity
EricLew 0:80ee8f3b695e 2074 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2075 * Driver Enable feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2076 * @rmtoll CR3 DEP LL_USART_SetDESignalPolarity
EricLew 0:80ee8f3b695e 2077 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2078 * @param Polarity This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 2079 * @arg @ref LL_USART_DE_POLARITY_HIGH
EricLew 0:80ee8f3b695e 2080 * @arg @ref LL_USART_DE_POLARITY_LOW
EricLew 0:80ee8f3b695e 2081 * @retval None
EricLew 0:80ee8f3b695e 2082 */
EricLew 0:80ee8f3b695e 2083 __STATIC_INLINE void LL_USART_SetDESignalPolarity(USART_TypeDef *USARTx, uint32_t Polarity)
EricLew 0:80ee8f3b695e 2084 {
EricLew 0:80ee8f3b695e 2085 MODIFY_REG(USARTx->CR3, USART_CR3_DEP, Polarity);
EricLew 0:80ee8f3b695e 2086 }
EricLew 0:80ee8f3b695e 2087
EricLew 0:80ee8f3b695e 2088 /**
EricLew 0:80ee8f3b695e 2089 * @brief Return Driver Enable Polarity
EricLew 0:80ee8f3b695e 2090 * @note Macro @ref IS_UART_DRIVER_ENABLE_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2091 * Driver Enable feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2092 * @rmtoll CR3 DEP LL_USART_GetDESignalPolarity
EricLew 0:80ee8f3b695e 2093 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2094 * @retval Returned value can be one of the following values:
EricLew 0:80ee8f3b695e 2095 * @arg @ref LL_USART_DE_POLARITY_HIGH
EricLew 0:80ee8f3b695e 2096 * @arg @ref LL_USART_DE_POLARITY_LOW
EricLew 0:80ee8f3b695e 2097 */
EricLew 0:80ee8f3b695e 2098 __STATIC_INLINE uint32_t LL_USART_GetDESignalPolarity(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2099 {
EricLew 0:80ee8f3b695e 2100 return (uint32_t)(READ_BIT(USARTx->CR3, USART_CR3_DEP));
EricLew 0:80ee8f3b695e 2101 }
EricLew 0:80ee8f3b695e 2102
EricLew 0:80ee8f3b695e 2103 /**
EricLew 0:80ee8f3b695e 2104 * @}
EricLew 0:80ee8f3b695e 2105 */
EricLew 0:80ee8f3b695e 2106
EricLew 0:80ee8f3b695e 2107 /** @defgroup USART_LL_EF_AdvancedConfiguration Advanced Configurations services
EricLew 0:80ee8f3b695e 2108 * @{
EricLew 0:80ee8f3b695e 2109 */
EricLew 0:80ee8f3b695e 2110
EricLew 0:80ee8f3b695e 2111 /**
EricLew 0:80ee8f3b695e 2112 * @brief Perform basic configuration of USART for enabling use in Asynchronous Mode (UART)
EricLew 0:80ee8f3b695e 2113 * @note In UART mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2114 * LINEN, and CLKEN bits in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2115 * SCEN, IREN and HDSEL bits in the USART_CR3 register.
EricLew 0:80ee8f3b695e 2116 * @note Call of this function is equivalent to following function call sequence :
EricLew 0:80ee8f3b695e 2117 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
EricLew 0:80ee8f3b695e 2118 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
EricLew 0:80ee8f3b695e 2119 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
EricLew 0:80ee8f3b695e 2120 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
EricLew 0:80ee8f3b695e 2121 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
EricLew 0:80ee8f3b695e 2122 * @note Other remaining configurations items related to Asynchronous Mode
EricLew 0:80ee8f3b695e 2123 * (as Baudrate, Word length, Parity, ...) should be set using
EricLew 0:80ee8f3b695e 2124 * dedicated functions
EricLew 0:80ee8f3b695e 2125 * @rmtoll CR2 LINEN LL_USART_ConfigAsyncMode\n
EricLew 0:80ee8f3b695e 2126 * CR2 CLKEN LL_USART_ConfigAsyncMode\n
EricLew 0:80ee8f3b695e 2127 * CR3 SCEN LL_USART_ConfigAsyncMode\n
EricLew 0:80ee8f3b695e 2128 * CR3 IREN LL_USART_ConfigAsyncMode\n
EricLew 0:80ee8f3b695e 2129 * CR3 HDSEL LL_USART_ConfigAsyncMode
EricLew 0:80ee8f3b695e 2130 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2131 * @retval None
EricLew 0:80ee8f3b695e 2132 */
EricLew 0:80ee8f3b695e 2133 __STATIC_INLINE void LL_USART_ConfigAsyncMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2134 {
EricLew 0:80ee8f3b695e 2135 /* In Asynchronous mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2136 - LINEN, STOP and CLKEN bits in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2137 - SCEN and HDSEL bits in the USART_CR3 register.*/
EricLew 0:80ee8f3b695e 2138 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
EricLew 0:80ee8f3b695e 2139 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
EricLew 0:80ee8f3b695e 2140 }
EricLew 0:80ee8f3b695e 2141
EricLew 0:80ee8f3b695e 2142 /**
EricLew 0:80ee8f3b695e 2143 * @brief Perform basic configuration of USART for enabling use in Synchronous Mode
EricLew 0:80ee8f3b695e 2144 * @note In Synchronous mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2145 * LINEN bit in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2146 * SCEN, IREN and HDSEL bits in the USART_CR3 register.
EricLew 0:80ee8f3b695e 2147 * This function also sets the USART in Synchronous mode.
EricLew 0:80ee8f3b695e 2148 * @note Call of this function is equivalent to following function call sequence :
EricLew 0:80ee8f3b695e 2149 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
EricLew 0:80ee8f3b695e 2150 * - Clear IREN in CR3 using @ref LL_USART_DisableSmartcard() function
EricLew 0:80ee8f3b695e 2151 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
EricLew 0:80ee8f3b695e 2152 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
EricLew 0:80ee8f3b695e 2153 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
EricLew 0:80ee8f3b695e 2154 * @note Other remaining configurations items related to Synchronous Mode
EricLew 0:80ee8f3b695e 2155 * (as Baudrate, Word length, Parity, Clock Polarity, ...) should be set using
EricLew 0:80ee8f3b695e 2156 * dedicated functions
EricLew 0:80ee8f3b695e 2157 * @note Macro @ref IS_USART_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2158 * Synchronous mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2159 * @rmtoll CR2 LINEN LL_USART_ConfigSyncMode\n
EricLew 0:80ee8f3b695e 2160 * CR2 CLKEN LL_USART_ConfigSyncMode\n
EricLew 0:80ee8f3b695e 2161 * CR3 SCEN LL_USART_ConfigSyncMode\n
EricLew 0:80ee8f3b695e 2162 * CR3 IREN LL_USART_ConfigSyncMode\n
EricLew 0:80ee8f3b695e 2163 * CR3 HDSEL LL_USART_ConfigSyncMode
EricLew 0:80ee8f3b695e 2164 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2165 * @retval None
EricLew 0:80ee8f3b695e 2166 */
EricLew 0:80ee8f3b695e 2167 __STATIC_INLINE void LL_USART_ConfigSyncMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2168 {
EricLew 0:80ee8f3b695e 2169 /* In Synchronous mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2170 - LINEN bit in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2171 - SCEN, IREN and HDSEL bits in the USART_CR3 register.*/
EricLew 0:80ee8f3b695e 2172 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
EricLew 0:80ee8f3b695e 2173 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN | USART_CR3_HDSEL));
EricLew 0:80ee8f3b695e 2174 /* set the UART/USART in Synchronous mode */
EricLew 0:80ee8f3b695e 2175 SET_BIT(USARTx->CR2, USART_CR2_CLKEN);
EricLew 0:80ee8f3b695e 2176 }
EricLew 0:80ee8f3b695e 2177
EricLew 0:80ee8f3b695e 2178 /**
EricLew 0:80ee8f3b695e 2179 * @brief Perform basic configuration of USART for enabling use in LIN Mode
EricLew 0:80ee8f3b695e 2180 * @note In LIN mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2181 * STOP and CLKEN bits in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2182 * IREN, SCEN and HDSEL bits in the USART_CR3 register.
EricLew 0:80ee8f3b695e 2183 * This function also set the UART/USART in LIN mode.
EricLew 0:80ee8f3b695e 2184 * @note Call of this function is equivalent to following function call sequence :
EricLew 0:80ee8f3b695e 2185 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
EricLew 0:80ee8f3b695e 2186 * - Clear STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
EricLew 0:80ee8f3b695e 2187 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
EricLew 0:80ee8f3b695e 2188 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
EricLew 0:80ee8f3b695e 2189 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
EricLew 0:80ee8f3b695e 2190 * - Set LINEN in CR2 using @ref LL_USART_EnableLIN() function
EricLew 0:80ee8f3b695e 2191 * @note Other remaining configurations items related to LIN Mode
EricLew 0:80ee8f3b695e 2192 * (as Baudrate, Word length, LIN Break Detection Length, ...) should be set using
EricLew 0:80ee8f3b695e 2193 * dedicated functions
EricLew 0:80ee8f3b695e 2194 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2195 * LIN feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2196 * @rmtoll CR2 CLKEN LL_USART_ConfigLINMode\n
EricLew 0:80ee8f3b695e 2197 * CR2 STOP LL_USART_ConfigLINMode\n
EricLew 0:80ee8f3b695e 2198 * CR2 LINEN LL_USART_ConfigLINMode\n
EricLew 0:80ee8f3b695e 2199 * CR3 IREN LL_USART_ConfigLINMode\n
EricLew 0:80ee8f3b695e 2200 * CR3 SCEN LL_USART_ConfigLINMode\n
EricLew 0:80ee8f3b695e 2201 * CR3 HDSEL LL_USART_ConfigLINMode
EricLew 0:80ee8f3b695e 2202 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2203 * @retval None
EricLew 0:80ee8f3b695e 2204 */
EricLew 0:80ee8f3b695e 2205 __STATIC_INLINE void LL_USART_ConfigLINMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2206 {
EricLew 0:80ee8f3b695e 2207 /* In LIN mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2208 - STOP and CLKEN bits in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2209 - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/
EricLew 0:80ee8f3b695e 2210 CLEAR_BIT(USARTx->CR2, (USART_CR2_CLKEN | USART_CR2_STOP));
EricLew 0:80ee8f3b695e 2211 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_SCEN | USART_CR3_HDSEL));
EricLew 0:80ee8f3b695e 2212 /* Set the UART/USART in LIN mode */
EricLew 0:80ee8f3b695e 2213 SET_BIT(USARTx->CR2, USART_CR2_LINEN);
EricLew 0:80ee8f3b695e 2214 }
EricLew 0:80ee8f3b695e 2215
EricLew 0:80ee8f3b695e 2216 /**
EricLew 0:80ee8f3b695e 2217 * @brief Perform basic configuration of USART for enabling use in Half Duplex Mode
EricLew 0:80ee8f3b695e 2218 * @note In Half Duplex mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2219 * LINEN, and CLKEN bits in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2220 * SCEN and IREN bits in the USART_CR3 register.
EricLew 0:80ee8f3b695e 2221 * This function also sets the UART/USART in Half Duplex mode.
EricLew 0:80ee8f3b695e 2222 * @note Call of this function is equivalent to following function call sequence :
EricLew 0:80ee8f3b695e 2223 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
EricLew 0:80ee8f3b695e 2224 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
EricLew 0:80ee8f3b695e 2225 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
EricLew 0:80ee8f3b695e 2226 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
EricLew 0:80ee8f3b695e 2227 * - Set HDSEL in CR3 using @ref LL_USART_EnableHalfDuplex() function
EricLew 0:80ee8f3b695e 2228 * @note Other remaining configurations items related to Half Duplex Mode
EricLew 0:80ee8f3b695e 2229 * (as Baudrate, Word length, Parity, ...) should be set using
EricLew 0:80ee8f3b695e 2230 * dedicated functions
EricLew 0:80ee8f3b695e 2231 * @note Macro @ref IS_UART_HALFDUPLEX_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2232 * Half-Duplex mode is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2233 * @rmtoll CR2 LINEN LL_USART_ConfigHalfDuplexMode\n
EricLew 0:80ee8f3b695e 2234 * CR2 CLKEN LL_USART_ConfigHalfDuplexMode\n
EricLew 0:80ee8f3b695e 2235 * CR3 HDSEL LL_USART_ConfigHalfDuplexMode\n
EricLew 0:80ee8f3b695e 2236 * CR3 SCEN LL_USART_ConfigHalfDuplexMode\n
EricLew 0:80ee8f3b695e 2237 * CR3 IREN LL_USART_ConfigHalfDuplexMode
EricLew 0:80ee8f3b695e 2238 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2239 * @retval None
EricLew 0:80ee8f3b695e 2240 */
EricLew 0:80ee8f3b695e 2241 __STATIC_INLINE void LL_USART_ConfigHalfDuplexMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2242 {
EricLew 0:80ee8f3b695e 2243 /* In Half Duplex mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2244 - LINEN, and CLKEN bits in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2245 - SCEN and IREN bits in the USART_CR3 register.*/
EricLew 0:80ee8f3b695e 2246 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
EricLew 0:80ee8f3b695e 2247 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_IREN));
EricLew 0:80ee8f3b695e 2248 /* set the UART/USART in Half Duplex mode */
EricLew 0:80ee8f3b695e 2249 SET_BIT(USARTx->CR3, USART_CR3_HDSEL);
EricLew 0:80ee8f3b695e 2250 }
EricLew 0:80ee8f3b695e 2251
EricLew 0:80ee8f3b695e 2252 /**
EricLew 0:80ee8f3b695e 2253 * @brief Perform basic configuration of USART for enabling use in Smartcard Mode
EricLew 0:80ee8f3b695e 2254 * @note In Smartcard mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2255 * LINEN bit in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2256 * IREN and HDSEL bits in the USART_CR3 register.
EricLew 0:80ee8f3b695e 2257 * This function also configures Stop bits to 1.5 bits and
EricLew 0:80ee8f3b695e 2258 * sets the USART in Smartcard mode (SCEN bit).
EricLew 0:80ee8f3b695e 2259 * Clock Output is also enabled (CLKEN).
EricLew 0:80ee8f3b695e 2260 * @note Call of this function is equivalent to following function call sequence :
EricLew 0:80ee8f3b695e 2261 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
EricLew 0:80ee8f3b695e 2262 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
EricLew 0:80ee8f3b695e 2263 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
EricLew 0:80ee8f3b695e 2264 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
EricLew 0:80ee8f3b695e 2265 * - Set CLKEN in CR2 using @ref LL_USART_EnableSCLKOutput() function
EricLew 0:80ee8f3b695e 2266 * - Set SCEN in CR3 using @ref LL_USART_EnableSmartcard() function
EricLew 0:80ee8f3b695e 2267 * @note Other remaining configurations items related to Smartcard Mode
EricLew 0:80ee8f3b695e 2268 * (as Baudrate, Word length, Parity, ...) should be set using
EricLew 0:80ee8f3b695e 2269 * dedicated functions
EricLew 0:80ee8f3b695e 2270 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2271 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2272 * @rmtoll CR2 LINEN LL_USART_ConfigSmartcardMode\n
EricLew 0:80ee8f3b695e 2273 * CR2 STOP LL_USART_ConfigSmartcardMode\n
EricLew 0:80ee8f3b695e 2274 * CR2 CLKEN LL_USART_ConfigSmartcardMode\n
EricLew 0:80ee8f3b695e 2275 * CR3 HDSEL LL_USART_ConfigSmartcardMode\n
EricLew 0:80ee8f3b695e 2276 * CR3 SCEN LL_USART_ConfigSmartcardMode
EricLew 0:80ee8f3b695e 2277 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2278 * @retval None
EricLew 0:80ee8f3b695e 2279 */
EricLew 0:80ee8f3b695e 2280 __STATIC_INLINE void LL_USART_ConfigSmartcardMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2281 {
EricLew 0:80ee8f3b695e 2282 /* In Smartcard mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2283 - LINEN bit in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2284 - IREN and HDSEL bits in the USART_CR3 register.*/
EricLew 0:80ee8f3b695e 2285 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN));
EricLew 0:80ee8f3b695e 2286 CLEAR_BIT(USARTx->CR3, (USART_CR3_IREN | USART_CR3_HDSEL));
EricLew 0:80ee8f3b695e 2287 /* Configure Stop bits to 1.5 bits */
EricLew 0:80ee8f3b695e 2288 /* Synchronous mode is activated by default */
EricLew 0:80ee8f3b695e 2289 SET_BIT(USARTx->CR2, (USART_CR2_STOP_0 | USART_CR2_STOP_1 | USART_CR2_CLKEN));
EricLew 0:80ee8f3b695e 2290 /* set the UART/USART in Smartcard mode */
EricLew 0:80ee8f3b695e 2291 SET_BIT(USARTx->CR3, USART_CR3_SCEN);
EricLew 0:80ee8f3b695e 2292 }
EricLew 0:80ee8f3b695e 2293
EricLew 0:80ee8f3b695e 2294 /**
EricLew 0:80ee8f3b695e 2295 * @brief Perform basic configuration of USART for enabling use in Irda Mode
EricLew 0:80ee8f3b695e 2296 * @note In IRDA mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2297 * LINEN, STOP and CLKEN bits in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2298 * SCEN and HDSEL bits in the USART_CR3 register.
EricLew 0:80ee8f3b695e 2299 * This function also sets the UART/USART in IRDA mode (IREN bit).
EricLew 0:80ee8f3b695e 2300 * @note Call of this function is equivalent to following function call sequence :
EricLew 0:80ee8f3b695e 2301 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
EricLew 0:80ee8f3b695e 2302 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
EricLew 0:80ee8f3b695e 2303 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
EricLew 0:80ee8f3b695e 2304 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
EricLew 0:80ee8f3b695e 2305 * - Configure STOP in CR2 using @ref LL_USART_SetStopBitsLength() function
EricLew 0:80ee8f3b695e 2306 * - Set IREN in CR3 using @ref LL_USART_EnableIrda() function
EricLew 0:80ee8f3b695e 2307 * @note Other remaining configurations items related to Irda Mode
EricLew 0:80ee8f3b695e 2308 * (as Baudrate, Word length, Power mode, ...) should be set using
EricLew 0:80ee8f3b695e 2309 * dedicated functions
EricLew 0:80ee8f3b695e 2310 * @note Macro @ref IS_IRDA_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2311 * IrDA feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2312 * @rmtoll CR2 LINEN LL_USART_ConfigIrdaMode\n
EricLew 0:80ee8f3b695e 2313 * CR2 CLKEN LL_USART_ConfigIrdaMode\n
EricLew 0:80ee8f3b695e 2314 * CR2 STOP LL_USART_ConfigIrdaMode\n
EricLew 0:80ee8f3b695e 2315 * CR3 SCEN LL_USART_ConfigIrdaMode\n
EricLew 0:80ee8f3b695e 2316 * CR3 HDSEL LL_USART_ConfigIrdaMode\n
EricLew 0:80ee8f3b695e 2317 * CR3 IREN LL_USART_ConfigIrdaMode
EricLew 0:80ee8f3b695e 2318 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2319 * @retval None
EricLew 0:80ee8f3b695e 2320 */
EricLew 0:80ee8f3b695e 2321 __STATIC_INLINE void LL_USART_ConfigIrdaMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2322 {
EricLew 0:80ee8f3b695e 2323 /* In IRDA mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2324 - LINEN, STOP and CLKEN bits in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2325 - SCEN and HDSEL bits in the USART_CR3 register.*/
EricLew 0:80ee8f3b695e 2326 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN | USART_CR2_STOP));
EricLew 0:80ee8f3b695e 2327 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL));
EricLew 0:80ee8f3b695e 2328 /* set the UART/USART in IRDA mode */
EricLew 0:80ee8f3b695e 2329 SET_BIT(USARTx->CR3, USART_CR3_IREN);
EricLew 0:80ee8f3b695e 2330 }
EricLew 0:80ee8f3b695e 2331
EricLew 0:80ee8f3b695e 2332 /**
EricLew 0:80ee8f3b695e 2333 * @brief Perform basic configuration of USART for enabling use in Multi processor Mode
EricLew 0:80ee8f3b695e 2334 * (several USARTs connected in a network, one of the USARTs can be the master,
EricLew 0:80ee8f3b695e 2335 * its TX output connected to the RX inputs of the other slaves USARTs).
EricLew 0:80ee8f3b695e 2336 * @note In MultiProcessor mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2337 * LINEN, CLKEN bits in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2338 * IREN, SCEN and HDSEL bits in the USART_CR3 register.
EricLew 0:80ee8f3b695e 2339 * @note Call of this function is equivalent to following function call sequence :
EricLew 0:80ee8f3b695e 2340 * - Clear LINEN in CR2 using @ref LL_USART_DisableLIN() function
EricLew 0:80ee8f3b695e 2341 * - Clear CLKEN in CR2 using @ref LL_USART_DisableSCLKOutput() function
EricLew 0:80ee8f3b695e 2342 * - Clear SCEN in CR3 using @ref LL_USART_DisableSmartcard() function
EricLew 0:80ee8f3b695e 2343 * - Clear IREN in CR3 using @ref LL_USART_DisableIrda() function
EricLew 0:80ee8f3b695e 2344 * - Clear HDSEL in CR3 using @ref LL_USART_DisableHalfDuplex() function
EricLew 0:80ee8f3b695e 2345 * @note Other remaining configurations items related to Multi processor Mode
EricLew 0:80ee8f3b695e 2346 * (as Baudrate, Wake Up Method, Node address, ...) should be set using
EricLew 0:80ee8f3b695e 2347 * dedicated functions
EricLew 0:80ee8f3b695e 2348 * @rmtoll CR2 LINEN LL_USART_ConfigMultiProcessMode\n
EricLew 0:80ee8f3b695e 2349 * CR2 CLKEN LL_USART_ConfigMultiProcessMode\n
EricLew 0:80ee8f3b695e 2350 * CR3 SCEN LL_USART_ConfigMultiProcessMode\n
EricLew 0:80ee8f3b695e 2351 * CR3 HDSEL LL_USART_ConfigMultiProcessMode\n
EricLew 0:80ee8f3b695e 2352 * CR3 IREN LL_USART_ConfigMultiProcessMode
EricLew 0:80ee8f3b695e 2353 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2354 * @retval None
EricLew 0:80ee8f3b695e 2355 */
EricLew 0:80ee8f3b695e 2356 __STATIC_INLINE void LL_USART_ConfigMultiProcessMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2357 {
EricLew 0:80ee8f3b695e 2358 /* In Multi Processor mode, the following bits must be kept cleared:
EricLew 0:80ee8f3b695e 2359 - LINEN and CLKEN bits in the USART_CR2 register,
EricLew 0:80ee8f3b695e 2360 - IREN, SCEN and HDSEL bits in the USART_CR3 register.*/
EricLew 0:80ee8f3b695e 2361 CLEAR_BIT(USARTx->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
EricLew 0:80ee8f3b695e 2362 CLEAR_BIT(USARTx->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN));
EricLew 0:80ee8f3b695e 2363 }
EricLew 0:80ee8f3b695e 2364
EricLew 0:80ee8f3b695e 2365 /**
EricLew 0:80ee8f3b695e 2366 * @}
EricLew 0:80ee8f3b695e 2367 */
EricLew 0:80ee8f3b695e 2368
EricLew 0:80ee8f3b695e 2369 /** @defgroup USART_LL_EF_FLAG_Management FLAG_Management
EricLew 0:80ee8f3b695e 2370 * @{
EricLew 0:80ee8f3b695e 2371 */
EricLew 0:80ee8f3b695e 2372
EricLew 0:80ee8f3b695e 2373 /**
EricLew 0:80ee8f3b695e 2374 * @brief Check if the USART Parity Error Flag is set or not
EricLew 0:80ee8f3b695e 2375 * @rmtoll ISR PE LL_USART_IsActiveFlag_PE
EricLew 0:80ee8f3b695e 2376 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2377 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2378 */
EricLew 0:80ee8f3b695e 2379 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_PE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2380 {
EricLew 0:80ee8f3b695e 2381 return (READ_BIT(USARTx->ISR, USART_ISR_PE) == (USART_ISR_PE));
EricLew 0:80ee8f3b695e 2382 }
EricLew 0:80ee8f3b695e 2383
EricLew 0:80ee8f3b695e 2384 /**
EricLew 0:80ee8f3b695e 2385 * @brief Check if the USART Framing Error Flag is set or not
EricLew 0:80ee8f3b695e 2386 * @rmtoll ISR FE LL_USART_IsActiveFlag_FE
EricLew 0:80ee8f3b695e 2387 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2388 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2389 */
EricLew 0:80ee8f3b695e 2390 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_FE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2391 {
EricLew 0:80ee8f3b695e 2392 return (READ_BIT(USARTx->ISR, USART_ISR_FE) == (USART_ISR_FE));
EricLew 0:80ee8f3b695e 2393 }
EricLew 0:80ee8f3b695e 2394
EricLew 0:80ee8f3b695e 2395 /**
EricLew 0:80ee8f3b695e 2396 * @brief Check if the USART Noise detected Flag is set or not
EricLew 0:80ee8f3b695e 2397 * @rmtoll ISR NE LL_USART_IsActiveFlag_NE
EricLew 0:80ee8f3b695e 2398 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2399 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2400 */
EricLew 0:80ee8f3b695e 2401 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_NE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2402 {
EricLew 0:80ee8f3b695e 2403 return (READ_BIT(USARTx->ISR, USART_ISR_NE) == (USART_ISR_NE));
EricLew 0:80ee8f3b695e 2404 }
EricLew 0:80ee8f3b695e 2405
EricLew 0:80ee8f3b695e 2406 /**
EricLew 0:80ee8f3b695e 2407 * @brief Check if the USART OverRun Error Flag is set or not
EricLew 0:80ee8f3b695e 2408 * @rmtoll ISR ORE LL_USART_IsActiveFlag_ORE
EricLew 0:80ee8f3b695e 2409 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2410 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2411 */
EricLew 0:80ee8f3b695e 2412 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ORE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2413 {
EricLew 0:80ee8f3b695e 2414 return (READ_BIT(USARTx->ISR, USART_ISR_ORE) == (USART_ISR_ORE));
EricLew 0:80ee8f3b695e 2415 }
EricLew 0:80ee8f3b695e 2416
EricLew 0:80ee8f3b695e 2417 /**
EricLew 0:80ee8f3b695e 2418 * @brief Check if the USART IDLE line detected Flag is set or not
EricLew 0:80ee8f3b695e 2419 * @rmtoll ISR IDLE LL_USART_IsActiveFlag_IDLE
EricLew 0:80ee8f3b695e 2420 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2421 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2422 */
EricLew 0:80ee8f3b695e 2423 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_IDLE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2424 {
EricLew 0:80ee8f3b695e 2425 return (READ_BIT(USARTx->ISR, USART_ISR_IDLE) == (USART_ISR_IDLE));
EricLew 0:80ee8f3b695e 2426 }
EricLew 0:80ee8f3b695e 2427
EricLew 0:80ee8f3b695e 2428 /**
EricLew 0:80ee8f3b695e 2429 * @brief Check if the USART Read Data Register Not Empty Flag is set or not
EricLew 0:80ee8f3b695e 2430 * @rmtoll ISR RXNE LL_USART_IsActiveFlag_RXNE
EricLew 0:80ee8f3b695e 2431 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2432 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2433 */
EricLew 0:80ee8f3b695e 2434 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RXNE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2435 {
EricLew 0:80ee8f3b695e 2436 return (READ_BIT(USARTx->ISR, USART_ISR_RXNE) == (USART_ISR_RXNE));
EricLew 0:80ee8f3b695e 2437 }
EricLew 0:80ee8f3b695e 2438
EricLew 0:80ee8f3b695e 2439 /**
EricLew 0:80ee8f3b695e 2440 * @brief Check if the USART Transmission Complete Flag is set or not
EricLew 0:80ee8f3b695e 2441 * @rmtoll ISR TC LL_USART_IsActiveFlag_TC
EricLew 0:80ee8f3b695e 2442 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2443 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2444 */
EricLew 0:80ee8f3b695e 2445 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TC(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2446 {
EricLew 0:80ee8f3b695e 2447 return (READ_BIT(USARTx->ISR, USART_ISR_TC) == (USART_ISR_TC));
EricLew 0:80ee8f3b695e 2448 }
EricLew 0:80ee8f3b695e 2449
EricLew 0:80ee8f3b695e 2450 /**
EricLew 0:80ee8f3b695e 2451 * @brief Check if the USART Transmit Data Register Empty Flag is set or not
EricLew 0:80ee8f3b695e 2452 * @rmtoll ISR TXE LL_USART_IsActiveFlag_TXE
EricLew 0:80ee8f3b695e 2453 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2454 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2455 */
EricLew 0:80ee8f3b695e 2456 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TXE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2457 {
EricLew 0:80ee8f3b695e 2458 return (READ_BIT(USARTx->ISR, USART_ISR_TXE) == (USART_ISR_TXE));
EricLew 0:80ee8f3b695e 2459 }
EricLew 0:80ee8f3b695e 2460
EricLew 0:80ee8f3b695e 2461 /**
EricLew 0:80ee8f3b695e 2462 * @brief Check if the USART LIN Break Detection Flag is set or not
EricLew 0:80ee8f3b695e 2463 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2464 * LIN feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2465 * @rmtoll ISR LBDF LL_USART_IsActiveFlag_LBD
EricLew 0:80ee8f3b695e 2466 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2467 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2468 */
EricLew 0:80ee8f3b695e 2469 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_LBD(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2470 {
EricLew 0:80ee8f3b695e 2471 return (READ_BIT(USARTx->ISR, USART_ISR_LBDF) == (USART_ISR_LBDF));
EricLew 0:80ee8f3b695e 2472 }
EricLew 0:80ee8f3b695e 2473
EricLew 0:80ee8f3b695e 2474 /**
EricLew 0:80ee8f3b695e 2475 * @brief Check if the USART CTS interrupt Flag is set or not
EricLew 0:80ee8f3b695e 2476 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2477 * Hardware Flow control feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2478 * @rmtoll ISR CTSIF LL_USART_IsActiveFlag_nCTS
EricLew 0:80ee8f3b695e 2479 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2480 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2481 */
EricLew 0:80ee8f3b695e 2482 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_nCTS(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2483 {
EricLew 0:80ee8f3b695e 2484 return (READ_BIT(USARTx->ISR, USART_ISR_CTSIF) == (USART_ISR_CTSIF));
EricLew 0:80ee8f3b695e 2485 }
EricLew 0:80ee8f3b695e 2486
EricLew 0:80ee8f3b695e 2487 /**
EricLew 0:80ee8f3b695e 2488 * @brief Check if the USART CTS Flag is set or not
EricLew 0:80ee8f3b695e 2489 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2490 * Hardware Flow control feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2491 * @rmtoll ISR CTS LL_USART_IsActiveFlag_CTS
EricLew 0:80ee8f3b695e 2492 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2493 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2494 */
EricLew 0:80ee8f3b695e 2495 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CTS(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2496 {
EricLew 0:80ee8f3b695e 2497 return (READ_BIT(USARTx->ISR, USART_ISR_CTS) == (USART_ISR_CTS));
EricLew 0:80ee8f3b695e 2498 }
EricLew 0:80ee8f3b695e 2499
EricLew 0:80ee8f3b695e 2500 /**
EricLew 0:80ee8f3b695e 2501 * @brief Check if the USART Receiver Time Out Flag is set or not
EricLew 0:80ee8f3b695e 2502 * @rmtoll ISR RTOF LL_USART_IsActiveFlag_RTO
EricLew 0:80ee8f3b695e 2503 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2504 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2505 */
EricLew 0:80ee8f3b695e 2506 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RTO(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2507 {
EricLew 0:80ee8f3b695e 2508 return (READ_BIT(USARTx->ISR, USART_ISR_RTOF) == (USART_ISR_RTOF));
EricLew 0:80ee8f3b695e 2509 }
EricLew 0:80ee8f3b695e 2510
EricLew 0:80ee8f3b695e 2511 /**
EricLew 0:80ee8f3b695e 2512 * @brief Check if the USART End Of Block Flag is set or not
EricLew 0:80ee8f3b695e 2513 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2514 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2515 * @rmtoll ISR EOBF LL_USART_IsActiveFlag_EOB
EricLew 0:80ee8f3b695e 2516 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2517 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2518 */
EricLew 0:80ee8f3b695e 2519 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_EOB(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2520 {
EricLew 0:80ee8f3b695e 2521 return (READ_BIT(USARTx->ISR, USART_ISR_EOBF) == (USART_ISR_EOBF));
EricLew 0:80ee8f3b695e 2522 }
EricLew 0:80ee8f3b695e 2523
EricLew 0:80ee8f3b695e 2524 /**
EricLew 0:80ee8f3b695e 2525 * @brief Check if the USART Auto-Baud Rate Error Flag is set or not
EricLew 0:80ee8f3b695e 2526 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2527 * Auto Baud Rate detection feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2528 * @rmtoll ISR ABRE LL_USART_IsActiveFlag_ABRE
EricLew 0:80ee8f3b695e 2529 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2530 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2531 */
EricLew 0:80ee8f3b695e 2532 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABRE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2533 {
EricLew 0:80ee8f3b695e 2534 return (READ_BIT(USARTx->ISR, USART_ISR_ABRE) == (USART_ISR_ABRE));
EricLew 0:80ee8f3b695e 2535 }
EricLew 0:80ee8f3b695e 2536
EricLew 0:80ee8f3b695e 2537 /**
EricLew 0:80ee8f3b695e 2538 * @brief Check if the USART Auto-Baud Rate Flag is set or not
EricLew 0:80ee8f3b695e 2539 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2540 * Auto Baud Rate detection feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2541 * @rmtoll ISR ABRF LL_USART_IsActiveFlag_ABR
EricLew 0:80ee8f3b695e 2542 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2543 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2544 */
EricLew 0:80ee8f3b695e 2545 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_ABR(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2546 {
EricLew 0:80ee8f3b695e 2547 return (READ_BIT(USARTx->ISR, USART_ISR_ABRF) == (USART_ISR_ABRF));
EricLew 0:80ee8f3b695e 2548 }
EricLew 0:80ee8f3b695e 2549
EricLew 0:80ee8f3b695e 2550 /**
EricLew 0:80ee8f3b695e 2551 * @brief Check if the USART Busy Flag is set or not
EricLew 0:80ee8f3b695e 2552 * @rmtoll ISR BUSY LL_USART_IsActiveFlag_BUSY
EricLew 0:80ee8f3b695e 2553 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2554 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2555 */
EricLew 0:80ee8f3b695e 2556 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_BUSY(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2557 {
EricLew 0:80ee8f3b695e 2558 return (READ_BIT(USARTx->ISR, USART_ISR_BUSY) == (USART_ISR_BUSY));
EricLew 0:80ee8f3b695e 2559 }
EricLew 0:80ee8f3b695e 2560
EricLew 0:80ee8f3b695e 2561 /**
EricLew 0:80ee8f3b695e 2562 * @brief Check if the USART Character Match Flag is set or not
EricLew 0:80ee8f3b695e 2563 * @rmtoll ISR CMF LL_USART_IsActiveFlag_CM
EricLew 0:80ee8f3b695e 2564 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2565 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2566 */
EricLew 0:80ee8f3b695e 2567 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_CM(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2568 {
EricLew 0:80ee8f3b695e 2569 return (READ_BIT(USARTx->ISR, USART_ISR_CMF) == (USART_ISR_CMF));
EricLew 0:80ee8f3b695e 2570 }
EricLew 0:80ee8f3b695e 2571
EricLew 0:80ee8f3b695e 2572 /**
EricLew 0:80ee8f3b695e 2573 * @brief Check if the USART Send Break Flag is set or not
EricLew 0:80ee8f3b695e 2574 * @rmtoll ISR SBKF LL_USART_IsActiveFlag_SBK
EricLew 0:80ee8f3b695e 2575 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2576 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2577 */
EricLew 0:80ee8f3b695e 2578 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_SBK(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2579 {
EricLew 0:80ee8f3b695e 2580 return (READ_BIT(USARTx->ISR, USART_ISR_SBKF) == (USART_ISR_SBKF));
EricLew 0:80ee8f3b695e 2581 }
EricLew 0:80ee8f3b695e 2582
EricLew 0:80ee8f3b695e 2583 /**
EricLew 0:80ee8f3b695e 2584 * @brief Check if the USART Receive Wake Up from mute mode Flag is set or not
EricLew 0:80ee8f3b695e 2585 * @rmtoll ISR RWU LL_USART_IsActiveFlag_RWU
EricLew 0:80ee8f3b695e 2586 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2587 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2588 */
EricLew 0:80ee8f3b695e 2589 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_RWU(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2590 {
EricLew 0:80ee8f3b695e 2591 return (READ_BIT(USARTx->ISR, USART_ISR_RWU) == (USART_ISR_RWU));
EricLew 0:80ee8f3b695e 2592 }
EricLew 0:80ee8f3b695e 2593
EricLew 0:80ee8f3b695e 2594 /**
EricLew 0:80ee8f3b695e 2595 * @brief Check if the USART Wake Up from stop mode Flag is set or not
EricLew 0:80ee8f3b695e 2596 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2597 * Wake-up from Stop mode feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2598 * @rmtoll ISR WUF LL_USART_IsActiveFlag_WKUP
EricLew 0:80ee8f3b695e 2599 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2600 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2601 */
EricLew 0:80ee8f3b695e 2602 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_WKUP(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2603 {
EricLew 0:80ee8f3b695e 2604 return (READ_BIT(USARTx->ISR, USART_ISR_WUF) == (USART_ISR_WUF));
EricLew 0:80ee8f3b695e 2605 }
EricLew 0:80ee8f3b695e 2606
EricLew 0:80ee8f3b695e 2607 /**
EricLew 0:80ee8f3b695e 2608 * @brief Check if the USART Transmit Enable Acknowledge Flag is set or not
EricLew 0:80ee8f3b695e 2609 * @rmtoll ISR TEACK LL_USART_IsActiveFlag_TEACK
EricLew 0:80ee8f3b695e 2610 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2611 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2612 */
EricLew 0:80ee8f3b695e 2613 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_TEACK(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2614 {
EricLew 0:80ee8f3b695e 2615 return (READ_BIT(USARTx->ISR, USART_ISR_TEACK) == (USART_ISR_TEACK));
EricLew 0:80ee8f3b695e 2616 }
EricLew 0:80ee8f3b695e 2617
EricLew 0:80ee8f3b695e 2618 /**
EricLew 0:80ee8f3b695e 2619 * @brief Check if the USART Receive Enable Acknowledge Flag is set or not
EricLew 0:80ee8f3b695e 2620 * @rmtoll ISR REACK LL_USART_IsActiveFlag_REACK
EricLew 0:80ee8f3b695e 2621 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2622 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 2623 */
EricLew 0:80ee8f3b695e 2624 __STATIC_INLINE uint32_t LL_USART_IsActiveFlag_REACK(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2625 {
EricLew 0:80ee8f3b695e 2626 return (READ_BIT(USARTx->ISR, USART_ISR_REACK) == (USART_ISR_REACK));
EricLew 0:80ee8f3b695e 2627 }
EricLew 0:80ee8f3b695e 2628
EricLew 0:80ee8f3b695e 2629 /**
EricLew 0:80ee8f3b695e 2630 * @brief Clear Parity Error Flag
EricLew 0:80ee8f3b695e 2631 * @rmtoll ICR PECF LL_USART_ClearFlag_PE
EricLew 0:80ee8f3b695e 2632 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2633 * @retval None
EricLew 0:80ee8f3b695e 2634 */
EricLew 0:80ee8f3b695e 2635 __STATIC_INLINE void LL_USART_ClearFlag_PE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2636 {
EricLew 0:80ee8f3b695e 2637 WRITE_REG(USARTx->ICR, USART_ICR_PECF);
EricLew 0:80ee8f3b695e 2638 }
EricLew 0:80ee8f3b695e 2639
EricLew 0:80ee8f3b695e 2640 /**
EricLew 0:80ee8f3b695e 2641 * @brief Clear Framing Error Flag
EricLew 0:80ee8f3b695e 2642 * @rmtoll ICR FECF LL_USART_ClearFlag_FE
EricLew 0:80ee8f3b695e 2643 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2644 * @retval None
EricLew 0:80ee8f3b695e 2645 */
EricLew 0:80ee8f3b695e 2646 __STATIC_INLINE void LL_USART_ClearFlag_FE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2647 {
EricLew 0:80ee8f3b695e 2648 WRITE_REG(USARTx->ICR, USART_ICR_FECF);
EricLew 0:80ee8f3b695e 2649 }
EricLew 0:80ee8f3b695e 2650
EricLew 0:80ee8f3b695e 2651 /**
EricLew 0:80ee8f3b695e 2652 * @brief Clear Noise detected Flag
EricLew 0:80ee8f3b695e 2653 * @rmtoll ICR NCF LL_USART_ClearFlag_NE
EricLew 0:80ee8f3b695e 2654 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2655 * @retval None
EricLew 0:80ee8f3b695e 2656 */
EricLew 0:80ee8f3b695e 2657 __STATIC_INLINE void LL_USART_ClearFlag_NE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2658 {
EricLew 0:80ee8f3b695e 2659 WRITE_REG(USARTx->ICR, USART_ICR_NCF);
EricLew 0:80ee8f3b695e 2660 }
EricLew 0:80ee8f3b695e 2661
EricLew 0:80ee8f3b695e 2662 /**
EricLew 0:80ee8f3b695e 2663 * @brief Clear OverRun Error Flag
EricLew 0:80ee8f3b695e 2664 * @rmtoll ICR ORECF LL_USART_ClearFlag_ORE
EricLew 0:80ee8f3b695e 2665 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2666 * @retval None
EricLew 0:80ee8f3b695e 2667 */
EricLew 0:80ee8f3b695e 2668 __STATIC_INLINE void LL_USART_ClearFlag_ORE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2669 {
EricLew 0:80ee8f3b695e 2670 WRITE_REG(USARTx->ICR, USART_ICR_ORECF);
EricLew 0:80ee8f3b695e 2671 }
EricLew 0:80ee8f3b695e 2672
EricLew 0:80ee8f3b695e 2673 /**
EricLew 0:80ee8f3b695e 2674 * @brief Clear IDLE line detected Flag
EricLew 0:80ee8f3b695e 2675 * @rmtoll ICR IDLECF LL_USART_ClearFlag_IDLE
EricLew 0:80ee8f3b695e 2676 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2677 * @retval None
EricLew 0:80ee8f3b695e 2678 */
EricLew 0:80ee8f3b695e 2679 __STATIC_INLINE void LL_USART_ClearFlag_IDLE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2680 {
EricLew 0:80ee8f3b695e 2681 WRITE_REG(USARTx->ICR, USART_ICR_IDLECF);
EricLew 0:80ee8f3b695e 2682 }
EricLew 0:80ee8f3b695e 2683
EricLew 0:80ee8f3b695e 2684 /**
EricLew 0:80ee8f3b695e 2685 * @brief Clear Transmission Complete Flag
EricLew 0:80ee8f3b695e 2686 * @rmtoll ICR TCCF LL_USART_ClearFlag_TC
EricLew 0:80ee8f3b695e 2687 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2688 * @retval None
EricLew 0:80ee8f3b695e 2689 */
EricLew 0:80ee8f3b695e 2690 __STATIC_INLINE void LL_USART_ClearFlag_TC(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2691 {
EricLew 0:80ee8f3b695e 2692 WRITE_REG(USARTx->ICR, USART_ICR_TCCF);
EricLew 0:80ee8f3b695e 2693 }
EricLew 0:80ee8f3b695e 2694
EricLew 0:80ee8f3b695e 2695 /**
EricLew 0:80ee8f3b695e 2696 * @brief Clear LIN Break Detection Flag
EricLew 0:80ee8f3b695e 2697 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2698 * LIN feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2699 * @rmtoll ICR LBDCF LL_USART_ClearFlag_LBD
EricLew 0:80ee8f3b695e 2700 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2701 * @retval None
EricLew 0:80ee8f3b695e 2702 */
EricLew 0:80ee8f3b695e 2703 __STATIC_INLINE void LL_USART_ClearFlag_LBD(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2704 {
EricLew 0:80ee8f3b695e 2705 WRITE_REG(USARTx->ICR, USART_ICR_LBDCF);
EricLew 0:80ee8f3b695e 2706 }
EricLew 0:80ee8f3b695e 2707
EricLew 0:80ee8f3b695e 2708 /**
EricLew 0:80ee8f3b695e 2709 * @brief Clear CTS Interrupt Flag
EricLew 0:80ee8f3b695e 2710 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2711 * Hardware Flow control feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2712 * @rmtoll ICR CTSCF LL_USART_ClearFlag_nCTS
EricLew 0:80ee8f3b695e 2713 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2714 * @retval None
EricLew 0:80ee8f3b695e 2715 */
EricLew 0:80ee8f3b695e 2716 __STATIC_INLINE void LL_USART_ClearFlag_nCTS(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2717 {
EricLew 0:80ee8f3b695e 2718 WRITE_REG(USARTx->ICR, USART_ICR_CTSCF);
EricLew 0:80ee8f3b695e 2719 }
EricLew 0:80ee8f3b695e 2720
EricLew 0:80ee8f3b695e 2721 /**
EricLew 0:80ee8f3b695e 2722 * @brief Clear Receiver Time Out Flag
EricLew 0:80ee8f3b695e 2723 * @rmtoll ICR RTOCF LL_USART_ClearFlag_RTO
EricLew 0:80ee8f3b695e 2724 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2725 * @retval None
EricLew 0:80ee8f3b695e 2726 */
EricLew 0:80ee8f3b695e 2727 __STATIC_INLINE void LL_USART_ClearFlag_RTO(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2728 {
EricLew 0:80ee8f3b695e 2729 WRITE_REG(USARTx->ICR, USART_ICR_RTOCF);
EricLew 0:80ee8f3b695e 2730 }
EricLew 0:80ee8f3b695e 2731
EricLew 0:80ee8f3b695e 2732 /**
EricLew 0:80ee8f3b695e 2733 * @brief Clear End Of Block Flag
EricLew 0:80ee8f3b695e 2734 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2735 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2736 * @rmtoll ICR EOBCF LL_USART_ClearFlag_EOB
EricLew 0:80ee8f3b695e 2737 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2738 * @retval None
EricLew 0:80ee8f3b695e 2739 */
EricLew 0:80ee8f3b695e 2740 __STATIC_INLINE void LL_USART_ClearFlag_EOB(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2741 {
EricLew 0:80ee8f3b695e 2742 WRITE_REG(USARTx->ICR, USART_ICR_EOBCF);
EricLew 0:80ee8f3b695e 2743 }
EricLew 0:80ee8f3b695e 2744
EricLew 0:80ee8f3b695e 2745 /**
EricLew 0:80ee8f3b695e 2746 * @brief Clear Character Match Flag
EricLew 0:80ee8f3b695e 2747 * @rmtoll ICR CMCF LL_USART_ClearFlag_CM
EricLew 0:80ee8f3b695e 2748 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2749 * @retval None
EricLew 0:80ee8f3b695e 2750 */
EricLew 0:80ee8f3b695e 2751 __STATIC_INLINE void LL_USART_ClearFlag_CM(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2752 {
EricLew 0:80ee8f3b695e 2753 WRITE_REG(USARTx->ICR, USART_ICR_CMCF);
EricLew 0:80ee8f3b695e 2754 }
EricLew 0:80ee8f3b695e 2755
EricLew 0:80ee8f3b695e 2756 /**
EricLew 0:80ee8f3b695e 2757 * @brief Clear Wake Up from stop mode Flag
EricLew 0:80ee8f3b695e 2758 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2759 * Wake-up from Stop mode feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2760 * @rmtoll ICR WUCF LL_USART_ClearFlag_WKUP
EricLew 0:80ee8f3b695e 2761 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2762 * @retval None
EricLew 0:80ee8f3b695e 2763 */
EricLew 0:80ee8f3b695e 2764 __STATIC_INLINE void LL_USART_ClearFlag_WKUP(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2765 {
EricLew 0:80ee8f3b695e 2766 WRITE_REG(USARTx->ICR, USART_ICR_WUCF);
EricLew 0:80ee8f3b695e 2767 }
EricLew 0:80ee8f3b695e 2768
EricLew 0:80ee8f3b695e 2769 /**
EricLew 0:80ee8f3b695e 2770 * @}
EricLew 0:80ee8f3b695e 2771 */
EricLew 0:80ee8f3b695e 2772
EricLew 0:80ee8f3b695e 2773 /** @defgroup USART_LL_EF_IT_Management IT_Management
EricLew 0:80ee8f3b695e 2774 * @{
EricLew 0:80ee8f3b695e 2775 */
EricLew 0:80ee8f3b695e 2776
EricLew 0:80ee8f3b695e 2777 /**
EricLew 0:80ee8f3b695e 2778 * @brief Enable IDLE Interrupt
EricLew 0:80ee8f3b695e 2779 * @rmtoll CR1 IDLEIE LL_USART_EnableIT_IDLE
EricLew 0:80ee8f3b695e 2780 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2781 * @retval None
EricLew 0:80ee8f3b695e 2782 */
EricLew 0:80ee8f3b695e 2783 __STATIC_INLINE void LL_USART_EnableIT_IDLE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2784 {
EricLew 0:80ee8f3b695e 2785 SET_BIT(USARTx->CR1, USART_CR1_IDLEIE);
EricLew 0:80ee8f3b695e 2786 }
EricLew 0:80ee8f3b695e 2787
EricLew 0:80ee8f3b695e 2788 /**
EricLew 0:80ee8f3b695e 2789 * @brief Enable RX Not Empty Interrupt
EricLew 0:80ee8f3b695e 2790 * @rmtoll CR1 RXNEIE LL_USART_EnableIT_RXNE
EricLew 0:80ee8f3b695e 2791 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2792 * @retval None
EricLew 0:80ee8f3b695e 2793 */
EricLew 0:80ee8f3b695e 2794 __STATIC_INLINE void LL_USART_EnableIT_RXNE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2795 {
EricLew 0:80ee8f3b695e 2796 SET_BIT(USARTx->CR1, USART_CR1_RXNEIE);
EricLew 0:80ee8f3b695e 2797 }
EricLew 0:80ee8f3b695e 2798
EricLew 0:80ee8f3b695e 2799 /**
EricLew 0:80ee8f3b695e 2800 * @brief Enable Transmission Complete Interrupt
EricLew 0:80ee8f3b695e 2801 * @rmtoll CR1 TCIE LL_USART_EnableIT_TC
EricLew 0:80ee8f3b695e 2802 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2803 * @retval None
EricLew 0:80ee8f3b695e 2804 */
EricLew 0:80ee8f3b695e 2805 __STATIC_INLINE void LL_USART_EnableIT_TC(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2806 {
EricLew 0:80ee8f3b695e 2807 SET_BIT(USARTx->CR1, USART_CR1_TCIE);
EricLew 0:80ee8f3b695e 2808 }
EricLew 0:80ee8f3b695e 2809
EricLew 0:80ee8f3b695e 2810 /**
EricLew 0:80ee8f3b695e 2811 * @brief Enable TX Empty Interrupt
EricLew 0:80ee8f3b695e 2812 * @rmtoll CR1 TXEIE LL_USART_EnableIT_TXE
EricLew 0:80ee8f3b695e 2813 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2814 * @retval None
EricLew 0:80ee8f3b695e 2815 */
EricLew 0:80ee8f3b695e 2816 __STATIC_INLINE void LL_USART_EnableIT_TXE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2817 {
EricLew 0:80ee8f3b695e 2818 SET_BIT(USARTx->CR1, USART_CR1_TXEIE);
EricLew 0:80ee8f3b695e 2819 }
EricLew 0:80ee8f3b695e 2820
EricLew 0:80ee8f3b695e 2821 /**
EricLew 0:80ee8f3b695e 2822 * @brief Enable Parity Error Interrupt
EricLew 0:80ee8f3b695e 2823 * @rmtoll CR1 PEIE LL_USART_EnableIT_PE
EricLew 0:80ee8f3b695e 2824 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2825 * @retval None
EricLew 0:80ee8f3b695e 2826 */
EricLew 0:80ee8f3b695e 2827 __STATIC_INLINE void LL_USART_EnableIT_PE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2828 {
EricLew 0:80ee8f3b695e 2829 SET_BIT(USARTx->CR1, USART_CR1_PEIE);
EricLew 0:80ee8f3b695e 2830 }
EricLew 0:80ee8f3b695e 2831
EricLew 0:80ee8f3b695e 2832 /**
EricLew 0:80ee8f3b695e 2833 * @brief Enable Character Match Interrupt
EricLew 0:80ee8f3b695e 2834 * @rmtoll CR1 CMIE LL_USART_EnableIT_CM
EricLew 0:80ee8f3b695e 2835 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2836 * @retval None
EricLew 0:80ee8f3b695e 2837 */
EricLew 0:80ee8f3b695e 2838 __STATIC_INLINE void LL_USART_EnableIT_CM(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2839 {
EricLew 0:80ee8f3b695e 2840 SET_BIT(USARTx->CR1, USART_CR1_CMIE);
EricLew 0:80ee8f3b695e 2841 }
EricLew 0:80ee8f3b695e 2842
EricLew 0:80ee8f3b695e 2843 /**
EricLew 0:80ee8f3b695e 2844 * @brief Enable Receiver Timeout Interrupt
EricLew 0:80ee8f3b695e 2845 * @rmtoll CR1 RTOIE LL_USART_EnableIT_RTO
EricLew 0:80ee8f3b695e 2846 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2847 * @retval None
EricLew 0:80ee8f3b695e 2848 */
EricLew 0:80ee8f3b695e 2849 __STATIC_INLINE void LL_USART_EnableIT_RTO(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2850 {
EricLew 0:80ee8f3b695e 2851 SET_BIT(USARTx->CR1, USART_CR1_RTOIE);
EricLew 0:80ee8f3b695e 2852 }
EricLew 0:80ee8f3b695e 2853
EricLew 0:80ee8f3b695e 2854 /**
EricLew 0:80ee8f3b695e 2855 * @brief Enable End Of Block Interrupt
EricLew 0:80ee8f3b695e 2856 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2857 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2858 * @rmtoll CR1 EOBIE LL_USART_EnableIT_EOB
EricLew 0:80ee8f3b695e 2859 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2860 * @retval None
EricLew 0:80ee8f3b695e 2861 */
EricLew 0:80ee8f3b695e 2862 __STATIC_INLINE void LL_USART_EnableIT_EOB(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2863 {
EricLew 0:80ee8f3b695e 2864 SET_BIT(USARTx->CR1, USART_CR1_EOBIE);
EricLew 0:80ee8f3b695e 2865 }
EricLew 0:80ee8f3b695e 2866
EricLew 0:80ee8f3b695e 2867 /**
EricLew 0:80ee8f3b695e 2868 * @brief Enable LIN Break Detection Interrupt
EricLew 0:80ee8f3b695e 2869 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2870 * LIN feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2871 * @rmtoll CR2 LBDIE LL_USART_EnableIT_LBD
EricLew 0:80ee8f3b695e 2872 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2873 * @retval None
EricLew 0:80ee8f3b695e 2874 */
EricLew 0:80ee8f3b695e 2875 __STATIC_INLINE void LL_USART_EnableIT_LBD(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2876 {
EricLew 0:80ee8f3b695e 2877 SET_BIT(USARTx->CR2, USART_CR2_LBDIE);
EricLew 0:80ee8f3b695e 2878 }
EricLew 0:80ee8f3b695e 2879
EricLew 0:80ee8f3b695e 2880 /**
EricLew 0:80ee8f3b695e 2881 * @brief Enable Error Interrupt
EricLew 0:80ee8f3b695e 2882 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
EricLew 0:80ee8f3b695e 2883 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register).
EricLew 0:80ee8f3b695e 2884 * 0: Interrupt is inhibited
EricLew 0:80ee8f3b695e 2885 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register.
EricLew 0:80ee8f3b695e 2886 * @rmtoll CR3 EIE LL_USART_EnableIT_ERROR
EricLew 0:80ee8f3b695e 2887 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2888 * @retval None
EricLew 0:80ee8f3b695e 2889 */
EricLew 0:80ee8f3b695e 2890 __STATIC_INLINE void LL_USART_EnableIT_ERROR(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2891 {
EricLew 0:80ee8f3b695e 2892 SET_BIT(USARTx->CR3, USART_CR3_EIE);
EricLew 0:80ee8f3b695e 2893 }
EricLew 0:80ee8f3b695e 2894
EricLew 0:80ee8f3b695e 2895 /**
EricLew 0:80ee8f3b695e 2896 * @brief Enable CTS Interrupt
EricLew 0:80ee8f3b695e 2897 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2898 * Hardware Flow control feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2899 * @rmtoll CR3 CTSIE LL_USART_EnableIT_CTS
EricLew 0:80ee8f3b695e 2900 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2901 * @retval None
EricLew 0:80ee8f3b695e 2902 */
EricLew 0:80ee8f3b695e 2903 __STATIC_INLINE void LL_USART_EnableIT_CTS(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2904 {
EricLew 0:80ee8f3b695e 2905 SET_BIT(USARTx->CR3, USART_CR3_CTSIE);
EricLew 0:80ee8f3b695e 2906 }
EricLew 0:80ee8f3b695e 2907
EricLew 0:80ee8f3b695e 2908 /**
EricLew 0:80ee8f3b695e 2909 * @brief Enable WakeUp from Stop Mode Interrupt
EricLew 0:80ee8f3b695e 2910 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 2911 * Wake-up from Stop mode feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 2912 * @rmtoll CR3 WUFIE LL_USART_EnableIT_WKUP
EricLew 0:80ee8f3b695e 2913 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2914 * @retval None
EricLew 0:80ee8f3b695e 2915 */
EricLew 0:80ee8f3b695e 2916 __STATIC_INLINE void LL_USART_EnableIT_WKUP(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2917 {
EricLew 0:80ee8f3b695e 2918 SET_BIT(USARTx->CR3, USART_CR3_WUFIE);
EricLew 0:80ee8f3b695e 2919 }
EricLew 0:80ee8f3b695e 2920
EricLew 0:80ee8f3b695e 2921 /**
EricLew 0:80ee8f3b695e 2922 * @brief Disable IDLE Interrupt
EricLew 0:80ee8f3b695e 2923 * @rmtoll CR1 IDLEIE LL_USART_DisableIT_IDLE
EricLew 0:80ee8f3b695e 2924 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2925 * @retval None
EricLew 0:80ee8f3b695e 2926 */
EricLew 0:80ee8f3b695e 2927 __STATIC_INLINE void LL_USART_DisableIT_IDLE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2928 {
EricLew 0:80ee8f3b695e 2929 CLEAR_BIT(USARTx->CR1, USART_CR1_IDLEIE);
EricLew 0:80ee8f3b695e 2930 }
EricLew 0:80ee8f3b695e 2931
EricLew 0:80ee8f3b695e 2932 /**
EricLew 0:80ee8f3b695e 2933 * @brief Disable RX Not Empty Interrupt
EricLew 0:80ee8f3b695e 2934 * @rmtoll CR1 RXNEIE LL_USART_DisableIT_RXNE
EricLew 0:80ee8f3b695e 2935 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2936 * @retval None
EricLew 0:80ee8f3b695e 2937 */
EricLew 0:80ee8f3b695e 2938 __STATIC_INLINE void LL_USART_DisableIT_RXNE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2939 {
EricLew 0:80ee8f3b695e 2940 CLEAR_BIT(USARTx->CR1, USART_CR1_RXNEIE);
EricLew 0:80ee8f3b695e 2941 }
EricLew 0:80ee8f3b695e 2942
EricLew 0:80ee8f3b695e 2943 /**
EricLew 0:80ee8f3b695e 2944 * @brief Disable Transmission Complete Interrupt
EricLew 0:80ee8f3b695e 2945 * @rmtoll CR1 TCIE LL_USART_DisableIT_TC
EricLew 0:80ee8f3b695e 2946 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2947 * @retval None
EricLew 0:80ee8f3b695e 2948 */
EricLew 0:80ee8f3b695e 2949 __STATIC_INLINE void LL_USART_DisableIT_TC(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2950 {
EricLew 0:80ee8f3b695e 2951 CLEAR_BIT(USARTx->CR1, USART_CR1_TCIE);
EricLew 0:80ee8f3b695e 2952 }
EricLew 0:80ee8f3b695e 2953
EricLew 0:80ee8f3b695e 2954 /**
EricLew 0:80ee8f3b695e 2955 * @brief Disable TX Empty Interrupt
EricLew 0:80ee8f3b695e 2956 * @rmtoll CR1 TXEIE LL_USART_DisableIT_TXE
EricLew 0:80ee8f3b695e 2957 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2958 * @retval None
EricLew 0:80ee8f3b695e 2959 */
EricLew 0:80ee8f3b695e 2960 __STATIC_INLINE void LL_USART_DisableIT_TXE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2961 {
EricLew 0:80ee8f3b695e 2962 CLEAR_BIT(USARTx->CR1, USART_CR1_TXEIE);
EricLew 0:80ee8f3b695e 2963 }
EricLew 0:80ee8f3b695e 2964
EricLew 0:80ee8f3b695e 2965 /**
EricLew 0:80ee8f3b695e 2966 * @brief Disable Parity Error Interrupt
EricLew 0:80ee8f3b695e 2967 * @rmtoll CR1 PEIE LL_USART_DisableIT_PE
EricLew 0:80ee8f3b695e 2968 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2969 * @retval None
EricLew 0:80ee8f3b695e 2970 */
EricLew 0:80ee8f3b695e 2971 __STATIC_INLINE void LL_USART_DisableIT_PE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2972 {
EricLew 0:80ee8f3b695e 2973 CLEAR_BIT(USARTx->CR1, USART_CR1_PEIE);
EricLew 0:80ee8f3b695e 2974 }
EricLew 0:80ee8f3b695e 2975
EricLew 0:80ee8f3b695e 2976 /**
EricLew 0:80ee8f3b695e 2977 * @brief Disable Character Match Interrupt
EricLew 0:80ee8f3b695e 2978 * @rmtoll CR1 CMIE LL_USART_DisableIT_CM
EricLew 0:80ee8f3b695e 2979 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2980 * @retval None
EricLew 0:80ee8f3b695e 2981 */
EricLew 0:80ee8f3b695e 2982 __STATIC_INLINE void LL_USART_DisableIT_CM(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2983 {
EricLew 0:80ee8f3b695e 2984 CLEAR_BIT(USARTx->CR1, USART_CR1_CMIE);
EricLew 0:80ee8f3b695e 2985 }
EricLew 0:80ee8f3b695e 2986
EricLew 0:80ee8f3b695e 2987 /**
EricLew 0:80ee8f3b695e 2988 * @brief Disable Receiver Timeout Interrupt
EricLew 0:80ee8f3b695e 2989 * @rmtoll CR1 RTOIE LL_USART_DisableIT_RTO
EricLew 0:80ee8f3b695e 2990 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 2991 * @retval None
EricLew 0:80ee8f3b695e 2992 */
EricLew 0:80ee8f3b695e 2993 __STATIC_INLINE void LL_USART_DisableIT_RTO(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 2994 {
EricLew 0:80ee8f3b695e 2995 CLEAR_BIT(USARTx->CR1, USART_CR1_RTOIE);
EricLew 0:80ee8f3b695e 2996 }
EricLew 0:80ee8f3b695e 2997
EricLew 0:80ee8f3b695e 2998 /**
EricLew 0:80ee8f3b695e 2999 * @brief Disable End Of Block Interrupt
EricLew 0:80ee8f3b695e 3000 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 3001 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 3002 * @rmtoll CR1 EOBIE LL_USART_DisableIT_EOB
EricLew 0:80ee8f3b695e 3003 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3004 * @retval None
EricLew 0:80ee8f3b695e 3005 */
EricLew 0:80ee8f3b695e 3006 __STATIC_INLINE void LL_USART_DisableIT_EOB(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3007 {
EricLew 0:80ee8f3b695e 3008 CLEAR_BIT(USARTx->CR1, USART_CR1_EOBIE);
EricLew 0:80ee8f3b695e 3009 }
EricLew 0:80ee8f3b695e 3010
EricLew 0:80ee8f3b695e 3011 /**
EricLew 0:80ee8f3b695e 3012 * @brief Disable LIN Break Detection Interrupt
EricLew 0:80ee8f3b695e 3013 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 3014 * LIN feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 3015 * @rmtoll CR2 LBDIE LL_USART_DisableIT_LBD
EricLew 0:80ee8f3b695e 3016 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3017 * @retval None
EricLew 0:80ee8f3b695e 3018 */
EricLew 0:80ee8f3b695e 3019 __STATIC_INLINE void LL_USART_DisableIT_LBD(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3020 {
EricLew 0:80ee8f3b695e 3021 CLEAR_BIT(USARTx->CR2, USART_CR2_LBDIE);
EricLew 0:80ee8f3b695e 3022 }
EricLew 0:80ee8f3b695e 3023
EricLew 0:80ee8f3b695e 3024 /**
EricLew 0:80ee8f3b695e 3025 * @brief Disable Error Interrupt
EricLew 0:80ee8f3b695e 3026 * @note When set, Error Interrupt Enable Bit is enabling interrupt generation in case of a framing
EricLew 0:80ee8f3b695e 3027 * error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the USARTx_ISR register).
EricLew 0:80ee8f3b695e 3028 * 0: Interrupt is inhibited
EricLew 0:80ee8f3b695e 3029 * 1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the USARTx_ISR register.
EricLew 0:80ee8f3b695e 3030 * @rmtoll CR3 EIE LL_USART_DisableIT_ERROR
EricLew 0:80ee8f3b695e 3031 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3032 * @retval None
EricLew 0:80ee8f3b695e 3033 */
EricLew 0:80ee8f3b695e 3034 __STATIC_INLINE void LL_USART_DisableIT_ERROR(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3035 {
EricLew 0:80ee8f3b695e 3036 CLEAR_BIT(USARTx->CR3, USART_CR3_EIE);
EricLew 0:80ee8f3b695e 3037 }
EricLew 0:80ee8f3b695e 3038
EricLew 0:80ee8f3b695e 3039 /**
EricLew 0:80ee8f3b695e 3040 * @brief Disable CTS Interrupt
EricLew 0:80ee8f3b695e 3041 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 3042 * Hardware Flow control feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 3043 * @rmtoll CR3 CTSIE LL_USART_DisableIT_CTS
EricLew 0:80ee8f3b695e 3044 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3045 * @retval None
EricLew 0:80ee8f3b695e 3046 */
EricLew 0:80ee8f3b695e 3047 __STATIC_INLINE void LL_USART_DisableIT_CTS(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3048 {
EricLew 0:80ee8f3b695e 3049 CLEAR_BIT(USARTx->CR3, USART_CR3_CTSIE);
EricLew 0:80ee8f3b695e 3050 }
EricLew 0:80ee8f3b695e 3051
EricLew 0:80ee8f3b695e 3052 /**
EricLew 0:80ee8f3b695e 3053 * @brief Disable WakeUp from Stop Mode Interrupt
EricLew 0:80ee8f3b695e 3054 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 3055 * Wake-up from Stop mode feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 3056 * @rmtoll CR3 WUFIE LL_USART_DisableIT_WKUP
EricLew 0:80ee8f3b695e 3057 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3058 * @retval None
EricLew 0:80ee8f3b695e 3059 */
EricLew 0:80ee8f3b695e 3060 __STATIC_INLINE void LL_USART_DisableIT_WKUP(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3061 {
EricLew 0:80ee8f3b695e 3062 CLEAR_BIT(USARTx->CR3, USART_CR3_WUFIE);
EricLew 0:80ee8f3b695e 3063 }
EricLew 0:80ee8f3b695e 3064
EricLew 0:80ee8f3b695e 3065 /**
EricLew 0:80ee8f3b695e 3066 * @brief Check if the USART IDLE Interrupt source is enabled or disabled.
EricLew 0:80ee8f3b695e 3067 * @rmtoll CR1 IDLEIE LL_USART_IsEnabledIT_IDLE
EricLew 0:80ee8f3b695e 3068 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3069 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3070 */
EricLew 0:80ee8f3b695e 3071 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_IDLE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3072 {
EricLew 0:80ee8f3b695e 3073 return (READ_BIT(USARTx->CR1, USART_CR1_IDLEIE) == (USART_CR1_IDLEIE));
EricLew 0:80ee8f3b695e 3074 }
EricLew 0:80ee8f3b695e 3075
EricLew 0:80ee8f3b695e 3076 /**
EricLew 0:80ee8f3b695e 3077 * @brief Check if the USART RX Not Empty Interrupt is enabled or disabled.
EricLew 0:80ee8f3b695e 3078 * @rmtoll CR1 RXNEIE LL_USART_IsEnabledIT_RXNE
EricLew 0:80ee8f3b695e 3079 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3080 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3081 */
EricLew 0:80ee8f3b695e 3082 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RXNE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3083 {
EricLew 0:80ee8f3b695e 3084 return (READ_BIT(USARTx->CR1, USART_CR1_RXNEIE) == (USART_CR1_RXNEIE));
EricLew 0:80ee8f3b695e 3085 }
EricLew 0:80ee8f3b695e 3086
EricLew 0:80ee8f3b695e 3087 /**
EricLew 0:80ee8f3b695e 3088 * @brief Check if the USART Transmission Complete Interrupt is enabled or disabled.
EricLew 0:80ee8f3b695e 3089 * @rmtoll CR1 TCIE LL_USART_IsEnabledIT_TC
EricLew 0:80ee8f3b695e 3090 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3091 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3092 */
EricLew 0:80ee8f3b695e 3093 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TC(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3094 {
EricLew 0:80ee8f3b695e 3095 return (READ_BIT(USARTx->CR1, USART_CR1_TCIE) == (USART_CR1_TCIE));
EricLew 0:80ee8f3b695e 3096 }
EricLew 0:80ee8f3b695e 3097
EricLew 0:80ee8f3b695e 3098 /**
EricLew 0:80ee8f3b695e 3099 * @brief Check if the USART TX Empty Interrupt is enabled or disabled.
EricLew 0:80ee8f3b695e 3100 * @rmtoll CR1 TXEIE LL_USART_IsEnabledIT_TXE
EricLew 0:80ee8f3b695e 3101 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3102 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3103 */
EricLew 0:80ee8f3b695e 3104 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_TXE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3105 {
EricLew 0:80ee8f3b695e 3106 return (READ_BIT(USARTx->CR1, USART_CR1_TXEIE) == (USART_CR1_TXEIE));
EricLew 0:80ee8f3b695e 3107 }
EricLew 0:80ee8f3b695e 3108
EricLew 0:80ee8f3b695e 3109 /**
EricLew 0:80ee8f3b695e 3110 * @brief Check if the USART Parity Error Interrupt is enabled or disabled.
EricLew 0:80ee8f3b695e 3111 * @rmtoll CR1 PEIE LL_USART_IsEnabledIT_PE
EricLew 0:80ee8f3b695e 3112 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3113 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3114 */
EricLew 0:80ee8f3b695e 3115 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_PE(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3116 {
EricLew 0:80ee8f3b695e 3117 return (READ_BIT(USARTx->CR1, USART_CR1_PEIE) == (USART_CR1_PEIE));
EricLew 0:80ee8f3b695e 3118 }
EricLew 0:80ee8f3b695e 3119
EricLew 0:80ee8f3b695e 3120 /**
EricLew 0:80ee8f3b695e 3121 * @brief Check if the USART Character Match Interrupt is enabled or disabled.
EricLew 0:80ee8f3b695e 3122 * @rmtoll CR1 CMIE LL_USART_IsEnabledIT_CM
EricLew 0:80ee8f3b695e 3123 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3124 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3125 */
EricLew 0:80ee8f3b695e 3126 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CM(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3127 {
EricLew 0:80ee8f3b695e 3128 return (READ_BIT(USARTx->CR1, USART_CR1_CMIE) == (USART_CR1_CMIE));
EricLew 0:80ee8f3b695e 3129 }
EricLew 0:80ee8f3b695e 3130
EricLew 0:80ee8f3b695e 3131 /**
EricLew 0:80ee8f3b695e 3132 * @brief Check if the USART Receiver Timeout Interrupt is enabled or disabled.
EricLew 0:80ee8f3b695e 3133 * @rmtoll CR1 RTOIE LL_USART_IsEnabledIT_RTO
EricLew 0:80ee8f3b695e 3134 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3135 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3136 */
EricLew 0:80ee8f3b695e 3137 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_RTO(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3138 {
EricLew 0:80ee8f3b695e 3139 return (READ_BIT(USARTx->CR1, USART_CR1_RTOIE) == (USART_CR1_RTOIE));
EricLew 0:80ee8f3b695e 3140 }
EricLew 0:80ee8f3b695e 3141
EricLew 0:80ee8f3b695e 3142 /**
EricLew 0:80ee8f3b695e 3143 * @brief Check if the USART End Of Block Interrupt is enabled or disabled.
EricLew 0:80ee8f3b695e 3144 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 3145 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 3146 * @rmtoll CR1 EOBIE LL_USART_IsEnabledIT_EOB
EricLew 0:80ee8f3b695e 3147 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3148 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3149 */
EricLew 0:80ee8f3b695e 3150 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_EOB(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3151 {
EricLew 0:80ee8f3b695e 3152 return (READ_BIT(USARTx->CR1, USART_CR1_EOBIE) == (USART_CR1_EOBIE));
EricLew 0:80ee8f3b695e 3153 }
EricLew 0:80ee8f3b695e 3154
EricLew 0:80ee8f3b695e 3155 /**
EricLew 0:80ee8f3b695e 3156 * @brief Check if the USART LIN Break Detection Interrupt is enabled or disabled.
EricLew 0:80ee8f3b695e 3157 * @note Macro @ref IS_UART_LIN_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 3158 * LIN feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 3159 * @rmtoll CR2 LBDIE LL_USART_IsEnabledIT_LBD
EricLew 0:80ee8f3b695e 3160 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3161 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3162 */
EricLew 0:80ee8f3b695e 3163 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_LBD(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3164 {
EricLew 0:80ee8f3b695e 3165 return (READ_BIT(USARTx->CR2, USART_CR2_LBDIE) == (USART_CR2_LBDIE));
EricLew 0:80ee8f3b695e 3166 }
EricLew 0:80ee8f3b695e 3167
EricLew 0:80ee8f3b695e 3168 /**
EricLew 0:80ee8f3b695e 3169 * @brief Check if the USART Error Interrupt is enabled or disabled.
EricLew 0:80ee8f3b695e 3170 * @rmtoll CR3 EIE LL_USART_IsEnabledIT_ERROR
EricLew 0:80ee8f3b695e 3171 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3172 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3173 */
EricLew 0:80ee8f3b695e 3174 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_ERROR(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3175 {
EricLew 0:80ee8f3b695e 3176 return (READ_BIT(USARTx->CR3, USART_CR3_EIE) == (USART_CR3_EIE));
EricLew 0:80ee8f3b695e 3177 }
EricLew 0:80ee8f3b695e 3178
EricLew 0:80ee8f3b695e 3179 /**
EricLew 0:80ee8f3b695e 3180 * @brief Check if the USART CTS Interrupt is enabled or disabled.
EricLew 0:80ee8f3b695e 3181 * @note Macro @ref IS_UART_HWFLOW_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 3182 * Hardware Flow control feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 3183 * @rmtoll CR3 CTSIE LL_USART_IsEnabledIT_CTS
EricLew 0:80ee8f3b695e 3184 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3185 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3186 */
EricLew 0:80ee8f3b695e 3187 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_CTS(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3188 {
EricLew 0:80ee8f3b695e 3189 return (READ_BIT(USARTx->CR3, USART_CR3_CTSIE) == (USART_CR3_CTSIE));
EricLew 0:80ee8f3b695e 3190 }
EricLew 0:80ee8f3b695e 3191
EricLew 0:80ee8f3b695e 3192 /**
EricLew 0:80ee8f3b695e 3193 * @brief Check if the USART WakeUp from Stop Mode Interrupt is enabled or disabled.
EricLew 0:80ee8f3b695e 3194 * @note Macro @ref IS_UART_WAKEUP_FROMSTOP_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 3195 * Wake-up from Stop mode feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 3196 * @rmtoll CR3 WUFIE LL_USART_IsEnabledIT_WKUP
EricLew 0:80ee8f3b695e 3197 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3198 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3199 */
EricLew 0:80ee8f3b695e 3200 __STATIC_INLINE uint32_t LL_USART_IsEnabledIT_WKUP(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3201 {
EricLew 0:80ee8f3b695e 3202 return (READ_BIT(USARTx->CR3, USART_CR3_WUFIE) == (USART_CR3_WUFIE));
EricLew 0:80ee8f3b695e 3203 }
EricLew 0:80ee8f3b695e 3204
EricLew 0:80ee8f3b695e 3205 /**
EricLew 0:80ee8f3b695e 3206 * @}
EricLew 0:80ee8f3b695e 3207 */
EricLew 0:80ee8f3b695e 3208
EricLew 0:80ee8f3b695e 3209 /** @defgroup USART_LL_EF_DMA_Management DMA_Management
EricLew 0:80ee8f3b695e 3210 * @{
EricLew 0:80ee8f3b695e 3211 */
EricLew 0:80ee8f3b695e 3212
EricLew 0:80ee8f3b695e 3213 /**
EricLew 0:80ee8f3b695e 3214 * @brief Enable DMA Mode for reception
EricLew 0:80ee8f3b695e 3215 * @rmtoll CR3 DMAR LL_USART_EnableDMAReq_RX
EricLew 0:80ee8f3b695e 3216 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3217 * @retval None
EricLew 0:80ee8f3b695e 3218 */
EricLew 0:80ee8f3b695e 3219 __STATIC_INLINE void LL_USART_EnableDMAReq_RX(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3220 {
EricLew 0:80ee8f3b695e 3221 SET_BIT(USARTx->CR3, USART_CR3_DMAR);
EricLew 0:80ee8f3b695e 3222 }
EricLew 0:80ee8f3b695e 3223
EricLew 0:80ee8f3b695e 3224 /**
EricLew 0:80ee8f3b695e 3225 * @brief Disable DMA Mode for reception
EricLew 0:80ee8f3b695e 3226 * @rmtoll CR3 DMAR LL_USART_DisableDMAReq_RX
EricLew 0:80ee8f3b695e 3227 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3228 * @retval None
EricLew 0:80ee8f3b695e 3229 */
EricLew 0:80ee8f3b695e 3230 __STATIC_INLINE void LL_USART_DisableDMAReq_RX(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3231 {
EricLew 0:80ee8f3b695e 3232 CLEAR_BIT(USARTx->CR3, USART_CR3_DMAR);
EricLew 0:80ee8f3b695e 3233 }
EricLew 0:80ee8f3b695e 3234
EricLew 0:80ee8f3b695e 3235 /**
EricLew 0:80ee8f3b695e 3236 * @brief Check if DMA Mode is enabled for reception
EricLew 0:80ee8f3b695e 3237 * @rmtoll CR3 DMAR LL_USART_IsEnabledDMAReq_RX
EricLew 0:80ee8f3b695e 3238 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3239 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3240 */
EricLew 0:80ee8f3b695e 3241 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_RX(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3242 {
EricLew 0:80ee8f3b695e 3243 return (READ_BIT(USARTx->CR3, USART_CR3_DMAR) == (USART_CR3_DMAR));
EricLew 0:80ee8f3b695e 3244 }
EricLew 0:80ee8f3b695e 3245
EricLew 0:80ee8f3b695e 3246 /**
EricLew 0:80ee8f3b695e 3247 * @brief Enable DMA Mode for transmission
EricLew 0:80ee8f3b695e 3248 * @rmtoll CR3 DMAT LL_USART_EnableDMAReq_TX
EricLew 0:80ee8f3b695e 3249 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3250 * @retval None
EricLew 0:80ee8f3b695e 3251 */
EricLew 0:80ee8f3b695e 3252 __STATIC_INLINE void LL_USART_EnableDMAReq_TX(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3253 {
EricLew 0:80ee8f3b695e 3254 SET_BIT(USARTx->CR3, USART_CR3_DMAT);
EricLew 0:80ee8f3b695e 3255 }
EricLew 0:80ee8f3b695e 3256
EricLew 0:80ee8f3b695e 3257 /**
EricLew 0:80ee8f3b695e 3258 * @brief Disable DMA Mode for transmission
EricLew 0:80ee8f3b695e 3259 * @rmtoll CR3 DMAT LL_USART_DisableDMAReq_TX
EricLew 0:80ee8f3b695e 3260 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3261 * @retval None
EricLew 0:80ee8f3b695e 3262 */
EricLew 0:80ee8f3b695e 3263 __STATIC_INLINE void LL_USART_DisableDMAReq_TX(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3264 {
EricLew 0:80ee8f3b695e 3265 CLEAR_BIT(USARTx->CR3, USART_CR3_DMAT);
EricLew 0:80ee8f3b695e 3266 }
EricLew 0:80ee8f3b695e 3267
EricLew 0:80ee8f3b695e 3268 /**
EricLew 0:80ee8f3b695e 3269 * @brief Check if DMA Mode is enabled for transmission
EricLew 0:80ee8f3b695e 3270 * @rmtoll CR3 DMAT LL_USART_IsEnabledDMAReq_TX
EricLew 0:80ee8f3b695e 3271 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3272 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3273 */
EricLew 0:80ee8f3b695e 3274 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMAReq_TX(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3275 {
EricLew 0:80ee8f3b695e 3276 return (READ_BIT(USARTx->CR3, USART_CR3_DMAT) == (USART_CR3_DMAT));
EricLew 0:80ee8f3b695e 3277 }
EricLew 0:80ee8f3b695e 3278
EricLew 0:80ee8f3b695e 3279 /**
EricLew 0:80ee8f3b695e 3280 * @brief Enable DMA Disabling on Reception Error
EricLew 0:80ee8f3b695e 3281 * @rmtoll CR3 DDRE LL_USART_EnableDMADeactOnRxErr
EricLew 0:80ee8f3b695e 3282 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3283 * @retval None
EricLew 0:80ee8f3b695e 3284 */
EricLew 0:80ee8f3b695e 3285 __STATIC_INLINE void LL_USART_EnableDMADeactOnRxErr(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3286 {
EricLew 0:80ee8f3b695e 3287 SET_BIT(USARTx->CR3, USART_CR3_DDRE);
EricLew 0:80ee8f3b695e 3288 }
EricLew 0:80ee8f3b695e 3289
EricLew 0:80ee8f3b695e 3290 /**
EricLew 0:80ee8f3b695e 3291 * @brief Disable DMA Disabling on Reception Error
EricLew 0:80ee8f3b695e 3292 * @rmtoll CR3 DDRE LL_USART_DisableDMADeactOnRxErr
EricLew 0:80ee8f3b695e 3293 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3294 * @retval None
EricLew 0:80ee8f3b695e 3295 */
EricLew 0:80ee8f3b695e 3296 __STATIC_INLINE void LL_USART_DisableDMADeactOnRxErr(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3297 {
EricLew 0:80ee8f3b695e 3298 CLEAR_BIT(USARTx->CR3, USART_CR3_DDRE);
EricLew 0:80ee8f3b695e 3299 }
EricLew 0:80ee8f3b695e 3300
EricLew 0:80ee8f3b695e 3301 /**
EricLew 0:80ee8f3b695e 3302 * @brief Indicate if DMA Disabling on Reception Error is disabled
EricLew 0:80ee8f3b695e 3303 * @rmtoll CR3 DDRE LL_USART_IsEnabledDMADeactOnRxErr
EricLew 0:80ee8f3b695e 3304 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3305 * @retval State of bit (1 or 0).
EricLew 0:80ee8f3b695e 3306 */
EricLew 0:80ee8f3b695e 3307 __STATIC_INLINE uint32_t LL_USART_IsEnabledDMADeactOnRxErr(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3308 {
EricLew 0:80ee8f3b695e 3309 return (READ_BIT(USARTx->CR3, USART_CR3_DDRE) == (USART_CR3_DDRE));
EricLew 0:80ee8f3b695e 3310 }
EricLew 0:80ee8f3b695e 3311
EricLew 0:80ee8f3b695e 3312 /**
EricLew 0:80ee8f3b695e 3313 * @brief Get the data register address used for DMA transfer
EricLew 0:80ee8f3b695e 3314 * @rmtoll RDR RDR LL_USART_DMA_GetRegAddr\n
EricLew 0:80ee8f3b695e 3315 * @rmtoll TDR TDR LL_USART_DMA_GetRegAddr
EricLew 0:80ee8f3b695e 3316 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3317 * @param Direction This parameter can be one of the following values:
EricLew 0:80ee8f3b695e 3318 * @arg @ref LL_USART_DMA_REG_DATA_TRANSMIT
EricLew 0:80ee8f3b695e 3319 * @arg @ref LL_USART_DMA_REG_DATA_RECEIVE
EricLew 0:80ee8f3b695e 3320 * @retval Address of data register
EricLew 0:80ee8f3b695e 3321 */
EricLew 0:80ee8f3b695e 3322 __STATIC_INLINE uint32_t LL_USART_DMA_GetRegAddr(USART_TypeDef *USARTx, uint32_t Direction)
EricLew 0:80ee8f3b695e 3323 {
EricLew 0:80ee8f3b695e 3324 register uint32_t data_reg_addr = 0;
EricLew 0:80ee8f3b695e 3325
EricLew 0:80ee8f3b695e 3326 if (Direction == LL_USART_DMA_REG_DATA_TRANSMIT)
EricLew 0:80ee8f3b695e 3327 {
EricLew 0:80ee8f3b695e 3328 /* return address of TDR register */
EricLew 0:80ee8f3b695e 3329 data_reg_addr = (uint32_t)&(USARTx->TDR);
EricLew 0:80ee8f3b695e 3330 }
EricLew 0:80ee8f3b695e 3331 else
EricLew 0:80ee8f3b695e 3332 {
EricLew 0:80ee8f3b695e 3333 /* return address of RDR register */
EricLew 0:80ee8f3b695e 3334 data_reg_addr = (uint32_t)&(USARTx->RDR);
EricLew 0:80ee8f3b695e 3335 }
EricLew 0:80ee8f3b695e 3336
EricLew 0:80ee8f3b695e 3337 return data_reg_addr;
EricLew 0:80ee8f3b695e 3338 }
EricLew 0:80ee8f3b695e 3339 /**
EricLew 0:80ee8f3b695e 3340 * @}
EricLew 0:80ee8f3b695e 3341 */
EricLew 0:80ee8f3b695e 3342
EricLew 0:80ee8f3b695e 3343 /** @defgroup USART_LL_EF_Data_Management Data_Management
EricLew 0:80ee8f3b695e 3344 * @{
EricLew 0:80ee8f3b695e 3345 */
EricLew 0:80ee8f3b695e 3346
EricLew 0:80ee8f3b695e 3347 /**
EricLew 0:80ee8f3b695e 3348 * @brief Read Receiver Data register (Receive Data value, 8 bits)
EricLew 0:80ee8f3b695e 3349 * @rmtoll RDR RDR LL_USART_ReceiveData8
EricLew 0:80ee8f3b695e 3350 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3351 * @retval 0..0xFF
EricLew 0:80ee8f3b695e 3352 */
EricLew 0:80ee8f3b695e 3353 __STATIC_INLINE uint8_t LL_USART_ReceiveData8(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3354 {
EricLew 0:80ee8f3b695e 3355 return (uint8_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR));
EricLew 0:80ee8f3b695e 3356 }
EricLew 0:80ee8f3b695e 3357
EricLew 0:80ee8f3b695e 3358 /**
EricLew 0:80ee8f3b695e 3359 * @brief Read Receiver Data register (Receive Data value, 9 bits)
EricLew 0:80ee8f3b695e 3360 * @rmtoll RDR RDR LL_USART_ReceiveData9
EricLew 0:80ee8f3b695e 3361 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3362 * @retval 0..0x1FF
EricLew 0:80ee8f3b695e 3363 */
EricLew 0:80ee8f3b695e 3364 __STATIC_INLINE uint16_t LL_USART_ReceiveData9(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3365 {
EricLew 0:80ee8f3b695e 3366 return (uint16_t)(READ_BIT(USARTx->RDR, USART_RDR_RDR));
EricLew 0:80ee8f3b695e 3367 }
EricLew 0:80ee8f3b695e 3368
EricLew 0:80ee8f3b695e 3369 /**
EricLew 0:80ee8f3b695e 3370 * @brief Write in Transmitter Data Register (Transmit Data value, 8 bits)
EricLew 0:80ee8f3b695e 3371 * @rmtoll TDR TDR LL_USART_TransmitData8
EricLew 0:80ee8f3b695e 3372 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3373 * @param Value 0..0xFF
EricLew 0:80ee8f3b695e 3374 * @retval None
EricLew 0:80ee8f3b695e 3375 */
EricLew 0:80ee8f3b695e 3376 __STATIC_INLINE void LL_USART_TransmitData8(USART_TypeDef *USARTx, uint8_t Value)
EricLew 0:80ee8f3b695e 3377 {
EricLew 0:80ee8f3b695e 3378 USARTx->TDR = Value;
EricLew 0:80ee8f3b695e 3379 }
EricLew 0:80ee8f3b695e 3380
EricLew 0:80ee8f3b695e 3381 /**
EricLew 0:80ee8f3b695e 3382 * @brief Write in Transmitter Data Register (Transmit Data value, 9 bits)
EricLew 0:80ee8f3b695e 3383 * @rmtoll TDR TDR LL_USART_TransmitData9
EricLew 0:80ee8f3b695e 3384 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3385 * @param Value 0..0x1FF
EricLew 0:80ee8f3b695e 3386 * @retval None
EricLew 0:80ee8f3b695e 3387 */
EricLew 0:80ee8f3b695e 3388 __STATIC_INLINE void LL_USART_TransmitData9(USART_TypeDef *USARTx, uint16_t Value)
EricLew 0:80ee8f3b695e 3389 {
EricLew 0:80ee8f3b695e 3390 USARTx->TDR = Value & 0x1FF;
EricLew 0:80ee8f3b695e 3391 }
EricLew 0:80ee8f3b695e 3392
EricLew 0:80ee8f3b695e 3393 /**
EricLew 0:80ee8f3b695e 3394 * @}
EricLew 0:80ee8f3b695e 3395 */
EricLew 0:80ee8f3b695e 3396
EricLew 0:80ee8f3b695e 3397 /** @defgroup USART_LL_EF_Execution Execution
EricLew 0:80ee8f3b695e 3398 * @{
EricLew 0:80ee8f3b695e 3399 */
EricLew 0:80ee8f3b695e 3400
EricLew 0:80ee8f3b695e 3401 /**
EricLew 0:80ee8f3b695e 3402 * @brief Request an Automatic Baud Rate measurement on next received data frame
EricLew 0:80ee8f3b695e 3403 * @note Macro @ref IS_USART_AUTOBAUDRATE_DETECTION_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 3404 * Auto Baud Rate detection feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 3405 * @rmtoll RQR ABRRQ LL_USART_RequestAutoBaudRate
EricLew 0:80ee8f3b695e 3406 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3407 * @retval None
EricLew 0:80ee8f3b695e 3408 */
EricLew 0:80ee8f3b695e 3409 __STATIC_INLINE void LL_USART_RequestAutoBaudRate(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3410 {
EricLew 0:80ee8f3b695e 3411 SET_BIT(USARTx->RQR, USART_RQR_ABRRQ);
EricLew 0:80ee8f3b695e 3412 }
EricLew 0:80ee8f3b695e 3413
EricLew 0:80ee8f3b695e 3414 /**
EricLew 0:80ee8f3b695e 3415 * @brief Request Break sending
EricLew 0:80ee8f3b695e 3416 * @rmtoll RQR SBKRQ LL_USART_RequestBreakSending
EricLew 0:80ee8f3b695e 3417 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3418 * @retval None
EricLew 0:80ee8f3b695e 3419 */
EricLew 0:80ee8f3b695e 3420 __STATIC_INLINE void LL_USART_RequestBreakSending(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3421 {
EricLew 0:80ee8f3b695e 3422 SET_BIT(USARTx->RQR, USART_RQR_SBKRQ);
EricLew 0:80ee8f3b695e 3423 }
EricLew 0:80ee8f3b695e 3424
EricLew 0:80ee8f3b695e 3425 /**
EricLew 0:80ee8f3b695e 3426 * @brief Put USART in mute mode and set the RWU flag
EricLew 0:80ee8f3b695e 3427 * @rmtoll RQR MMRQ LL_USART_RequestEnterMuteMode
EricLew 0:80ee8f3b695e 3428 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3429 * @retval None
EricLew 0:80ee8f3b695e 3430 */
EricLew 0:80ee8f3b695e 3431 __STATIC_INLINE void LL_USART_RequestEnterMuteMode(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3432 {
EricLew 0:80ee8f3b695e 3433 SET_BIT(USARTx->RQR, USART_RQR_MMRQ);
EricLew 0:80ee8f3b695e 3434 }
EricLew 0:80ee8f3b695e 3435
EricLew 0:80ee8f3b695e 3436 /**
EricLew 0:80ee8f3b695e 3437 * @brief Request a Receive Data flush
EricLew 0:80ee8f3b695e 3438 * @rmtoll RQR RXFRQ LL_USART_RequestRxDataFlush
EricLew 0:80ee8f3b695e 3439 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3440 * @retval None
EricLew 0:80ee8f3b695e 3441 */
EricLew 0:80ee8f3b695e 3442 __STATIC_INLINE void LL_USART_RequestRxDataFlush(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3443 {
EricLew 0:80ee8f3b695e 3444 SET_BIT(USARTx->RQR, USART_RQR_RXFRQ);
EricLew 0:80ee8f3b695e 3445 }
EricLew 0:80ee8f3b695e 3446
EricLew 0:80ee8f3b695e 3447 /**
EricLew 0:80ee8f3b695e 3448 * @brief Request a Transmit data flush
EricLew 0:80ee8f3b695e 3449 * @note Macro @ref IS_SMARTCARD_INSTANCE(USARTx) can be used to check whether or not
EricLew 0:80ee8f3b695e 3450 * Smartcard feature is supported by the USARTx instance.
EricLew 0:80ee8f3b695e 3451 * @rmtoll RQR TXFRQ LL_USART_RequestTxDataFlush
EricLew 0:80ee8f3b695e 3452 * @param USARTx USART Instance
EricLew 0:80ee8f3b695e 3453 * @retval None
EricLew 0:80ee8f3b695e 3454 */
EricLew 0:80ee8f3b695e 3455 __STATIC_INLINE void LL_USART_RequestTxDataFlush(USART_TypeDef *USARTx)
EricLew 0:80ee8f3b695e 3456 {
EricLew 0:80ee8f3b695e 3457 SET_BIT(USARTx->RQR, USART_RQR_TXFRQ);
EricLew 0:80ee8f3b695e 3458 }
EricLew 0:80ee8f3b695e 3459
EricLew 0:80ee8f3b695e 3460 /**
EricLew 0:80ee8f3b695e 3461 * @}
EricLew 0:80ee8f3b695e 3462 */
EricLew 0:80ee8f3b695e 3463
EricLew 0:80ee8f3b695e 3464 /**
EricLew 0:80ee8f3b695e 3465 * @}
EricLew 0:80ee8f3b695e 3466 */
EricLew 0:80ee8f3b695e 3467
EricLew 0:80ee8f3b695e 3468 /**
EricLew 0:80ee8f3b695e 3469 * @}
EricLew 0:80ee8f3b695e 3470 */
EricLew 0:80ee8f3b695e 3471
EricLew 0:80ee8f3b695e 3472 #endif /* USART1 || USART2 || USART3 || UART4 || UART5 */
EricLew 0:80ee8f3b695e 3473
EricLew 0:80ee8f3b695e 3474 /**
EricLew 0:80ee8f3b695e 3475 * @}
EricLew 0:80ee8f3b695e 3476 */
EricLew 0:80ee8f3b695e 3477
EricLew 0:80ee8f3b695e 3478 #ifdef __cplusplus
EricLew 0:80ee8f3b695e 3479 }
EricLew 0:80ee8f3b695e 3480 #endif
EricLew 0:80ee8f3b695e 3481
EricLew 0:80ee8f3b695e 3482 #endif /* __STM32L4xx_LL_USART_H */
EricLew 0:80ee8f3b695e 3483
EricLew 0:80ee8f3b695e 3484 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
EricLew 0:80ee8f3b695e 3485