Subversion Repositories canSerial

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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