Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 9 | ||
---|---|---|---|
Line 4... | Line 4... | ||
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @brief Header file of UART HAL module. |
5 | * @brief Header file of UART HAL module. |
6 | ****************************************************************************** |
6 | ****************************************************************************** |
7 | * @attention |
7 | * @attention |
8 | * |
8 | * |
9 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
- | 10 | * All rights reserved.</center></h2> |
|
10 | * |
11 | * |
11 | * Redistribution and use in source and binary forms, with or without modification, |
12 | * This software component is licensed by ST under BSD 3-Clause license, |
12 | * are permitted provided that the following conditions are met: |
13 | * the "License"; You may not use this file except in compliance with the |
13 | * 1. Redistributions of source code must retain the above copyright notice, |
- | |
14 | * this list of conditions and the following disclaimer. |
- | |
15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
- | |
16 | * this list of conditions and the following disclaimer in the documentation |
- | |
17 | * and/or other materials provided with the distribution. |
14 | * License. You may obtain a copy of the License at: |
18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
- | |
19 | * may be used to endorse or promote products derived from this software |
15 | * opensource.org/licenses/BSD-3-Clause |
20 | * without specific prior written permission. |
- | |
21 | * |
- | |
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
- | |
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
- | |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
- | |
25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
- | |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
- | |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
- | |
28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
- | |
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
- | |
30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- | |
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- | |
32 | * |
16 | * |
33 | ****************************************************************************** |
17 | ****************************************************************************** |
34 | */ |
18 | */ |
35 | 19 | ||
36 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
37 | #ifndef __STM32F1xx_HAL_UART_H |
21 | #ifndef __STM32F1xx_HAL_UART_H |
38 | #define __STM32F1xx_HAL_UART_H |
22 | #define __STM32F1xx_HAL_UART_H |
39 | 23 | ||
40 | #ifdef __cplusplus |
24 | #ifdef __cplusplus |
41 | extern "C" { |
25 | extern "C" { |
42 | #endif |
26 | #endif |
43 | 27 | ||
44 | /* Includes ------------------------------------------------------------------*/ |
28 | /* Includes ------------------------------------------------------------------*/ |
45 | #include "stm32f1xx_hal_def.h" |
29 | #include "stm32f1xx_hal_def.h" |
46 | 30 | ||
Line 50... | Line 34... | ||
50 | 34 | ||
51 | /** @addtogroup UART |
35 | /** @addtogroup UART |
52 | * @{ |
36 | * @{ |
53 | */ |
37 | */ |
54 | 38 | ||
55 | /* Exported types ------------------------------------------------------------*/ |
39 | /* Exported types ------------------------------------------------------------*/ |
56 | /** @defgroup UART_Exported_Types UART Exported Types |
40 | /** @defgroup UART_Exported_Types UART Exported Types |
57 | * @{ |
41 | * @{ |
58 | */ |
42 | */ |
59 | 43 | ||
60 | /** |
44 | /** |
Line 87... | Line 71... | ||
87 | This parameter can be a value of @ref UART_Hardware_Flow_Control */ |
71 | This parameter can be a value of @ref UART_Hardware_Flow_Control */ |
88 | 72 | ||
89 | uint32_t OverSampling; /*!< Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to fPCLK/8). |
73 | uint32_t OverSampling; /*!< Specifies whether the Over sampling 8 is enabled or disabled, to achieve higher speed (up to fPCLK/8). |
90 | This parameter can be a value of @ref UART_Over_Sampling. This feature is only available |
74 | This parameter can be a value of @ref UART_Over_Sampling. This feature is only available |
91 | on STM32F100xx family, so OverSampling parameter should always be set to 16. */ |
75 | on STM32F100xx family, so OverSampling parameter should always be set to 16. */ |
92 | }UART_InitTypeDef; |
76 | } UART_InitTypeDef; |
93 | 77 | ||
94 | /** |
78 | /** |
95 | * @brief HAL UART State structures definition |
79 | * @brief HAL UART State structures definition |
96 | * @note HAL UART State value is a combination of 2 different substates: gState and RxState. |
80 | * @note HAL UART State value is a combination of 2 different substates: gState and RxState. |
97 | * - gState contains UART state information related to global Handle management |
81 | * - gState contains UART state information related to global Handle management |
98 | * and also information related to Tx operations. |
82 | * and also information related to Tx operations. |
99 | * gState value coding follow below described bitmap : |
83 | * gState value coding follow below described bitmap : |
100 | * b7-b6 Error information |
84 | * b7-b6 Error information |
101 | * 00 : No Error |
85 | * 00 : No Error |
102 | * 01 : (Not Used) |
86 | * 01 : (Not Used) |
103 | * 10 : Timeout |
87 | * 10 : Timeout |
104 | * 11 : Error |
88 | * 11 : Error |
105 | * b5 IP initilisation status |
89 | * b5 Peripheral initialization status |
106 | * 0 : Reset (IP not initialized) |
90 | * 0 : Reset (Peripheral not initialized) |
107 | * 1 : Init done (IP not initialized. HAL UART Init function already called) |
91 | * 1 : Init done (Peripheral not initialized. HAL UART Init function already called) |
108 | * b4-b3 (not used) |
92 | * b4-b3 (not used) |
109 | * xx : Should be set to 00 |
93 | * xx : Should be set to 00 |
110 | * b2 Intrinsic process state |
94 | * b2 Intrinsic process state |
111 | * 0 : Ready |
95 | * 0 : Ready |
112 | * 1 : Busy (IP busy with some configuration or internal operations) |
96 | * 1 : Busy (Peripheral busy with some configuration or internal operations) |
113 | * b1 (not used) |
97 | * b1 (not used) |
114 | * x : Should be set to 0 |
98 | * x : Should be set to 0 |
115 | * b0 Tx state |
99 | * b0 Tx state |
116 | * 0 : Ready (no Tx operation ongoing) |
100 | * 0 : Ready (no Tx operation ongoing) |
117 | * 1 : Busy (Tx operation ongoing) |
101 | * 1 : Busy (Tx operation ongoing) |
118 | * - RxState contains information related to Rx operations. |
102 | * - RxState contains information related to Rx operations. |
119 | * RxState value coding follow below described bitmap : |
103 | * RxState value coding follow below described bitmap : |
120 | * b7-b6 (not used) |
104 | * b7-b6 (not used) |
121 | * xx : Should be set to 00 |
105 | * xx : Should be set to 00 |
122 | * b5 IP initilisation status |
106 | * b5 Peripheral initialization status |
123 | * 0 : Reset (IP not initialized) |
107 | * 0 : Reset (Peripheral not initialized) |
124 | * 1 : Init done (IP not initialized) |
108 | * 1 : Init done (Peripheral not initialized) |
125 | * b4-b2 (not used) |
109 | * b4-b2 (not used) |
126 | * xxx : Should be set to 000 |
110 | * xxx : Should be set to 000 |
127 | * b1 Rx state |
111 | * b1 Rx state |
128 | * 0 : Ready (no Rx operation ongoing) |
112 | * 0 : Ready (no Rx operation ongoing) |
129 | * 1 : Busy (Rx operation ongoing) |
113 | * 1 : Busy (Rx operation ongoing) |
130 | * b0 (not used) |
114 | * b0 (not used) |
131 | * x : Should be set to 0. |
115 | * x : Should be set to 0. |
132 | */ |
116 | */ |
133 | typedef enum |
117 | typedef enum |
134 | { |
118 | { |
135 | HAL_UART_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized |
119 | HAL_UART_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized |
136 | Value is allowed for gState and RxState */ |
120 | Value is allowed for gState and RxState */ |
137 | HAL_UART_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use |
121 | HAL_UART_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use |
138 | Value is allowed for gState and RxState */ |
122 | Value is allowed for gState and RxState */ |
139 | HAL_UART_STATE_BUSY = 0x24U, /*!< an internal process is ongoing |
123 | HAL_UART_STATE_BUSY = 0x24U, /*!< an internal process is ongoing |
140 | Value is allowed for gState only */ |
124 | Value is allowed for gState only */ |
141 | HAL_UART_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing |
125 | HAL_UART_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing |
142 | Value is allowed for gState only */ |
126 | Value is allowed for gState only */ |
143 | HAL_UART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing |
127 | HAL_UART_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing |
144 | Value is allowed for RxState only */ |
128 | Value is allowed for RxState only */ |
145 | HAL_UART_STATE_BUSY_TX_RX = 0x23U, /*!< Data Transmission and Reception process is ongoing |
129 | HAL_UART_STATE_BUSY_TX_RX = 0x23U, /*!< Data Transmission and Reception process is ongoing |
146 | Not to be used for neither gState nor RxState. |
130 | Not to be used for neither gState nor RxState. |
147 | Value is result of combination (Or) between gState and RxState values */ |
131 | Value is result of combination (Or) between gState and RxState values */ |
148 | HAL_UART_STATE_TIMEOUT = 0xA0U, /*!< Timeout state |
132 | HAL_UART_STATE_TIMEOUT = 0xA0U, /*!< Timeout state |
149 | Value is allowed for gState only */ |
133 | Value is allowed for gState only */ |
150 | HAL_UART_STATE_ERROR = 0xE0U /*!< Error |
134 | HAL_UART_STATE_ERROR = 0xE0U /*!< Error |
151 | Value is allowed for gState only */ |
135 | Value is allowed for gState only */ |
152 | }HAL_UART_StateTypeDef; |
136 | } HAL_UART_StateTypeDef; |
153 | 137 | ||
154 | /** |
138 | /** |
155 | * @brief UART handle Structure definition |
139 | * @brief UART handle Structure definition |
156 | */ |
140 | */ |
157 | typedef struct |
141 | typedef struct __UART_HandleTypeDef |
158 | { |
142 | { |
159 | USART_TypeDef *Instance; /*!< UART registers base address */ |
143 | USART_TypeDef *Instance; /*!< UART registers base address */ |
160 | 144 | ||
161 | UART_InitTypeDef Init; /*!< UART communication parameters */ |
145 | UART_InitTypeDef Init; /*!< UART communication parameters */ |
162 | 146 | ||
Line 176... | Line 160... | ||
176 | 160 | ||
177 | DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */ |
161 | DMA_HandleTypeDef *hdmarx; /*!< UART Rx DMA Handle parameters */ |
178 | 162 | ||
179 | HAL_LockTypeDef Lock; /*!< Locking object */ |
163 | HAL_LockTypeDef Lock; /*!< Locking object */ |
180 | 164 | ||
181 | __IO HAL_UART_StateTypeDef gState; /*!< UART state information related to global Handle management |
165 | __IO HAL_UART_StateTypeDef gState; /*!< UART state information related to global Handle management |
182 | and also related to Tx operations. |
166 | and also related to Tx operations. |
183 | This parameter can be a value of @ref HAL_UART_StateTypeDef */ |
167 | This parameter can be a value of @ref HAL_UART_StateTypeDef */ |
184 | 168 | ||
185 | __IO HAL_UART_StateTypeDef RxState; /*!< UART state information related to Rx operations. |
169 | __IO HAL_UART_StateTypeDef RxState; /*!< UART state information related to Rx operations. |
186 | This parameter can be a value of @ref HAL_UART_StateTypeDef */ |
170 | This parameter can be a value of @ref HAL_UART_StateTypeDef */ |
187 | 171 | ||
188 | __IO uint32_t ErrorCode; /*!< UART Error code */ |
172 | __IO uint32_t ErrorCode; /*!< UART Error code */ |
- | 173 | ||
- | 174 | #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) |
|
- | 175 | void (* TxHalfCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Tx Half Complete Callback */ |
|
- | 176 | void (* TxCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Tx Complete Callback */ |
|
- | 177 | void (* RxHalfCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Rx Half Complete Callback */ |
|
- | 178 | void (* RxCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Rx Complete Callback */ |
|
- | 179 | void (* ErrorCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Error Callback */ |
|
- | 180 | void (* AbortCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Abort Complete Callback */ |
|
- | 181 | void (* AbortTransmitCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Abort Transmit Complete Callback */ |
|
- | 182 | void (* AbortReceiveCpltCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Abort Receive Complete Callback */ |
|
- | 183 | void (* WakeupCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Wakeup Callback */ |
|
- | 184 | ||
- | 185 | void (* MspInitCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Msp Init callback */ |
|
- | 186 | void (* MspDeInitCallback)(struct __UART_HandleTypeDef *huart); /*!< UART Msp DeInit callback */ |
|
- | 187 | #endif /* USE_HAL_UART_REGISTER_CALLBACKS */ |
|
- | 188 | ||
189 | }UART_HandleTypeDef; |
189 | } UART_HandleTypeDef; |
- | 190 | ||
- | 191 | #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) |
|
- | 192 | /** |
|
- | 193 | * @brief HAL UART Callback ID enumeration definition |
|
- | 194 | */ |
|
- | 195 | typedef enum |
|
- | 196 | { |
|
- | 197 | HAL_UART_TX_HALFCOMPLETE_CB_ID = 0x00U, /*!< UART Tx Half Complete Callback ID */ |
|
- | 198 | HAL_UART_TX_COMPLETE_CB_ID = 0x01U, /*!< UART Tx Complete Callback ID */ |
|
- | 199 | HAL_UART_RX_HALFCOMPLETE_CB_ID = 0x02U, /*!< UART Rx Half Complete Callback ID */ |
|
- | 200 | HAL_UART_RX_COMPLETE_CB_ID = 0x03U, /*!< UART Rx Complete Callback ID */ |
|
- | 201 | HAL_UART_ERROR_CB_ID = 0x04U, /*!< UART Error Callback ID */ |
|
- | 202 | HAL_UART_ABORT_COMPLETE_CB_ID = 0x05U, /*!< UART Abort Complete Callback ID */ |
|
- | 203 | HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID = 0x06U, /*!< UART Abort Transmit Complete Callback ID */ |
|
- | 204 | HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID = 0x07U, /*!< UART Abort Receive Complete Callback ID */ |
|
- | 205 | HAL_UART_WAKEUP_CB_ID = 0x08U, /*!< UART Wakeup Callback ID */ |
|
- | 206 | ||
- | 207 | HAL_UART_MSPINIT_CB_ID = 0x0BU, /*!< UART MspInit callback ID */ |
|
- | 208 | HAL_UART_MSPDEINIT_CB_ID = 0x0CU /*!< UART MspDeInit callback ID */ |
|
- | 209 | ||
- | 210 | } HAL_UART_CallbackIDTypeDef; |
|
- | 211 | ||
- | 212 | /** |
|
- | 213 | * @brief HAL UART Callback pointer definition |
|
- | 214 | */ |
|
- | 215 | typedef void (*pUART_CallbackTypeDef)(UART_HandleTypeDef *huart); /*!< pointer to an UART callback function */ |
|
- | 216 | ||
- | 217 | #endif /* USE_HAL_UART_REGISTER_CALLBACKS */ |
|
190 | 218 | ||
191 | /** |
219 | /** |
192 | * @} |
220 | * @} |
193 | */ |
221 | */ |
194 | 222 | ||
195 | /* Exported constants --------------------------------------------------------*/ |
223 | /* Exported constants --------------------------------------------------------*/ |
196 | /** @defgroup UART_Exported_Constants UART Exported constants |
224 | /** @defgroup UART_Exported_Constants UART Exported Constants |
197 | * @{ |
225 | * @{ |
198 | */ |
226 | */ |
199 | 227 | ||
200 | /** @defgroup UART_Error_Code UART Error Code |
228 | /** @defgroup UART_Error_Code UART Error Code |
201 | * @{ |
229 | * @{ |
202 | */ |
230 | */ |
203 | #define HAL_UART_ERROR_NONE 0x00000000U /*!< No error */ |
231 | #define HAL_UART_ERROR_NONE 0x00000000U /*!< No error */ |
204 | #define HAL_UART_ERROR_PE 0x00000001U /*!< Parity error */ |
232 | #define HAL_UART_ERROR_PE 0x00000001U /*!< Parity error */ |
205 | #define HAL_UART_ERROR_NE 0x00000002U /*!< Noise error */ |
233 | #define HAL_UART_ERROR_NE 0x00000002U /*!< Noise error */ |
206 | #define HAL_UART_ERROR_FE 0x00000004U /*!< Frame error */ |
234 | #define HAL_UART_ERROR_FE 0x00000004U /*!< Frame error */ |
207 | #define HAL_UART_ERROR_ORE 0x00000008U /*!< Overrun error */ |
235 | #define HAL_UART_ERROR_ORE 0x00000008U /*!< Overrun error */ |
208 | #define HAL_UART_ERROR_DMA 0x00000010U /*!< DMA transfer error */ |
236 | #define HAL_UART_ERROR_DMA 0x00000010U /*!< DMA transfer error */ |
- | 237 | #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) |
|
- | 238 | #define HAL_UART_ERROR_INVALID_CALLBACK 0x00000020U /*!< Invalid Callback error */ |
|
- | 239 | #endif /* USE_HAL_UART_REGISTER_CALLBACKS */ |
|
209 | /** |
240 | /** |
210 | * @} |
241 | * @} |
211 | */ |
242 | */ |
212 | 243 | ||
213 | /** @defgroup UART_Word_Length UART Word Length |
244 | /** @defgroup UART_Word_Length UART Word Length |
Line 217... | Line 248... | ||
217 | #define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M) |
248 | #define UART_WORDLENGTH_9B ((uint32_t)USART_CR1_M) |
218 | /** |
249 | /** |
219 | * @} |
250 | * @} |
220 | */ |
251 | */ |
221 | 252 | ||
222 | /** @defgroup UART_Stop_Bits UART Number of Stop Bits |
253 | /** @defgroup UART_Stop_Bits UART Number of Stop Bits |
223 | * @{ |
254 | * @{ |
224 | */ |
255 | */ |
225 | #define UART_STOPBITS_1 0x00000000U |
256 | #define UART_STOPBITS_1 0x00000000U |
226 | #define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) |
257 | #define UART_STOPBITS_2 ((uint32_t)USART_CR2_STOP_1) |
227 | /** |
258 | /** |
228 | * @} |
259 | * @} |
229 | */ |
260 | */ |
230 | 261 | ||
231 | /** @defgroup UART_Parity UART Parity |
262 | /** @defgroup UART_Parity UART Parity |
232 | * @{ |
263 | * @{ |
233 | */ |
264 | */ |
234 | #define UART_PARITY_NONE 0x00000000U |
265 | #define UART_PARITY_NONE 0x00000000U |
235 | #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE) |
266 | #define UART_PARITY_EVEN ((uint32_t)USART_CR1_PCE) |
236 | #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) |
267 | #define UART_PARITY_ODD ((uint32_t)(USART_CR1_PCE | USART_CR1_PS)) |
237 | /** |
268 | /** |
238 | * @} |
269 | * @} |
239 | */ |
270 | */ |
240 | 271 | ||
241 | /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control |
272 | /** @defgroup UART_Hardware_Flow_Control UART Hardware Flow Control |
Line 249... | Line 280... | ||
249 | * @} |
280 | * @} |
250 | */ |
281 | */ |
251 | 282 | ||
252 | /** @defgroup UART_Mode UART Transfer Mode |
283 | /** @defgroup UART_Mode UART Transfer Mode |
253 | * @{ |
284 | * @{ |
254 | */ |
285 | */ |
255 | #define UART_MODE_RX ((uint32_t)USART_CR1_RE) |
286 | #define UART_MODE_RX ((uint32_t)USART_CR1_RE) |
256 | #define UART_MODE_TX ((uint32_t)USART_CR1_TE) |
287 | #define UART_MODE_TX ((uint32_t)USART_CR1_TE) |
257 | #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE |USART_CR1_RE)) |
288 | #define UART_MODE_TX_RX ((uint32_t)(USART_CR1_TE | USART_CR1_RE)) |
258 | /** |
289 | /** |
259 | * @} |
290 | * @} |
260 | */ |
291 | */ |
261 | 292 | ||
262 | /** @defgroup UART_State UART State |
293 | /** @defgroup UART_State UART State |
263 | * @{ |
294 | * @{ |
264 | */ |
295 | */ |
265 | #define UART_STATE_DISABLE 0x00000000U |
296 | #define UART_STATE_DISABLE 0x00000000U |
266 | #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE) |
297 | #define UART_STATE_ENABLE ((uint32_t)USART_CR1_UE) |
267 | /** |
298 | /** |
268 | * @} |
299 | * @} |
269 | */ |
300 | */ |
270 | 301 | ||
271 | - | ||
272 | /** @defgroup UART_Over_Sampling UART Over Sampling |
302 | /** @defgroup UART_Over_Sampling UART Over Sampling |
273 | * @{ |
303 | * @{ |
274 | */ |
304 | */ |
275 | #define UART_OVERSAMPLING_16 0x00000000U |
305 | #define UART_OVERSAMPLING_16 0x00000000U |
276 | #if defined(USART_CR1_OVER8) |
306 | #if defined(USART_CR1_OVER8) |
Line 278... | Line 308... | ||
278 | #endif /* USART_CR1_OVER8 */ |
308 | #endif /* USART_CR1_OVER8 */ |
279 | /** |
309 | /** |
280 | * @} |
310 | * @} |
281 | */ |
311 | */ |
282 | 312 | ||
283 | - | ||
284 | /** @defgroup UART_LIN_Break_Detection_Length UART LIN Break Detection Length |
313 | /** @defgroup UART_LIN_Break_Detection_Length UART LIN Break Detection Length |
285 | * @{ |
314 | * @{ |
286 | */ |
315 | */ |
287 | #define UART_LINBREAKDETECTLENGTH_10B 0x00000000U |
316 | #define UART_LINBREAKDETECTLENGTH_10B 0x00000000U |
288 | #define UART_LINBREAKDETECTLENGTH_11B ((uint32_t)USART_CR2_LBDL) |
317 | #define UART_LINBREAKDETECTLENGTH_11B ((uint32_t)USART_CR2_LBDL) |
289 | /** |
318 | /** |
290 | * @} |
319 | * @} |
291 | */ |
320 | */ |
- | 321 | ||
292 | /** @defgroup UART_WakeUp_functions UART Wakeup Functions |
322 | /** @defgroup UART_WakeUp_functions UART Wakeup Functions |
293 | * @{ |
323 | * @{ |
294 | */ |
324 | */ |
295 | #define UART_WAKEUPMETHOD_IDLELINE 0x00000000U |
325 | #define UART_WAKEUPMETHOD_IDLELINE 0x00000000U |
296 | #define UART_WAKEUPMETHOD_ADDRESSMARK ((uint32_t)USART_CR1_WAKE) |
326 | #define UART_WAKEUPMETHOD_ADDRESSMARK ((uint32_t)USART_CR1_WAKE) |
Line 319... | Line 349... | ||
319 | 349 | ||
320 | /** @defgroup UART_Interrupt_definition UART Interrupt Definitions |
350 | /** @defgroup UART_Interrupt_definition UART Interrupt Definitions |
321 | * Elements values convention: 0xY000XXXX |
351 | * Elements values convention: 0xY000XXXX |
322 | * - XXXX : Interrupt mask (16 bits) in the Y register |
352 | * - XXXX : Interrupt mask (16 bits) in the Y register |
323 | * - Y : Interrupt source register (2bits) |
353 | * - Y : Interrupt source register (2bits) |
324 | * - 01: CR1 register |
354 | * - 0001: CR1 register |
325 | * - 10: CR2 register |
355 | * - 0010: CR2 register |
326 | * - 11: CR3 register |
356 | * - 0011: CR3 register |
327 | * @{ |
357 | * @{ |
328 | */ |
358 | */ |
329 | 359 | ||
330 | #define UART_IT_PE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_PEIE)) |
360 | #define UART_IT_PE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_PEIE)) |
331 | #define UART_IT_TXE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_TXEIE)) |
361 | #define UART_IT_TXE ((uint32_t)(UART_CR1_REG_INDEX << 28U | USART_CR1_TXEIE)) |
Line 349... | Line 379... | ||
349 | /** @defgroup UART_Exported_Macros UART Exported Macros |
379 | /** @defgroup UART_Exported_Macros UART Exported Macros |
350 | * @{ |
380 | * @{ |
351 | */ |
381 | */ |
352 | 382 | ||
353 | /** @brief Reset UART handle gstate & RxState |
383 | /** @brief Reset UART handle gstate & RxState |
354 | * @param __HANDLE__: specifies the UART Handle. |
384 | * @param __HANDLE__ specifies the UART Handle. |
355 | * UART Handle selects the USARTx or UARTy peripheral |
385 | * UART Handle selects the USARTx or UARTy peripheral |
356 | * (USART,UART availability and x,y values depending on device). |
386 | * (USART,UART availability and x,y values depending on device). |
- | 387 | * @retval None |
|
357 | */ |
388 | */ |
- | 389 | #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) |
|
358 | #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \ |
390 | #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \ |
359 | (__HANDLE__)->gState = HAL_UART_STATE_RESET; \ |
391 | (__HANDLE__)->gState = HAL_UART_STATE_RESET; \ |
360 | (__HANDLE__)->RxState = HAL_UART_STATE_RESET; \ |
392 | (__HANDLE__)->RxState = HAL_UART_STATE_RESET; \ |
- | 393 | (__HANDLE__)->MspInitCallback = NULL; \ |
|
- | 394 | (__HANDLE__)->MspDeInitCallback = NULL; \ |
|
361 | } while(0U) |
395 | } while(0U) |
- | 396 | #else |
|
- | 397 | #define __HAL_UART_RESET_HANDLE_STATE(__HANDLE__) do{ \ |
|
- | 398 | (__HANDLE__)->gState = HAL_UART_STATE_RESET; \ |
|
- | 399 | (__HANDLE__)->RxState = HAL_UART_STATE_RESET; \ |
|
- | 400 | } while(0U) |
|
- | 401 | #endif /*USE_HAL_UART_REGISTER_CALLBACKS */ |
|
362 | 402 | ||
363 | /** @brief Flushs the UART DR register |
403 | /** @brief Flushes the UART DR register |
364 | * @param __HANDLE__: specifies the UART Handle. |
404 | * @param __HANDLE__ specifies the UART Handle. |
365 | * UART Handle selects the USARTx or UARTy peripheral |
405 | * UART Handle selects the USARTx or UARTy peripheral |
366 | * (USART,UART availability and x,y values depending on device). |
406 | * (USART,UART availability and x,y values depending on device). |
367 | */ |
407 | */ |
368 | #define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) |
408 | #define __HAL_UART_FLUSH_DRREGISTER(__HANDLE__) ((__HANDLE__)->Instance->DR) |
369 | 409 | ||
370 | /** @brief Checks whether the specified UART flag is set or not. |
410 | /** @brief Checks whether the specified UART flag is set or not. |
371 | * @param __HANDLE__: specifies the UART Handle. |
411 | * @param __HANDLE__ specifies the UART Handle. |
372 | * This parameter can be UARTx where x: 1, 2, 3, 4 or 5 to select the USART or |
412 | * UART Handle selects the USARTx or UARTy peripheral |
373 | * UART peripheral. |
413 | * (USART,UART availability and x,y values depending on device). |
374 | * @param __FLAG__: specifies the flag to check. |
414 | * @param __FLAG__ specifies the flag to check. |
375 | * This parameter can be one of the following values: |
415 | * This parameter can be one of the following values: |
376 | * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5) |
416 | * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5) |
377 | * @arg UART_FLAG_LBD: LIN Break detection flag |
417 | * @arg UART_FLAG_LBD: LIN Break detection flag |
378 | * @arg UART_FLAG_TXE: Transmit data register empty flag |
418 | * @arg UART_FLAG_TXE: Transmit data register empty flag |
379 | * @arg UART_FLAG_TC: Transmission Complete flag |
419 | * @arg UART_FLAG_TC: Transmission Complete flag |
380 | * @arg UART_FLAG_RXNE: Receive data register not empty flag |
420 | * @arg UART_FLAG_RXNE: Receive data register not empty flag |
381 | * @arg UART_FLAG_IDLE: Idle Line detection flag |
421 | * @arg UART_FLAG_IDLE: Idle Line detection flag |
382 | * @arg UART_FLAG_ORE: OverRun Error flag |
422 | * @arg UART_FLAG_ORE: Overrun Error flag |
383 | * @arg UART_FLAG_NE: Noise Error flag |
423 | * @arg UART_FLAG_NE: Noise Error flag |
384 | * @arg UART_FLAG_FE: Framing Error flag |
424 | * @arg UART_FLAG_FE: Framing Error flag |
385 | * @arg UART_FLAG_PE: Parity Error flag |
425 | * @arg UART_FLAG_PE: Parity Error flag |
386 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
426 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
387 | */ |
427 | */ |
388 | #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) |
428 | #define __HAL_UART_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) |
389 | 429 | ||
390 | /** @brief Clears the specified UART pending flag. |
430 | /** @brief Clears the specified UART pending flag. |
391 | * @param __HANDLE__: specifies the UART Handle. |
431 | * @param __HANDLE__ specifies the UART Handle. |
392 | * UART Handle selects the USARTx or UARTy peripheral |
432 | * UART Handle selects the USARTx or UARTy peripheral |
393 | * (USART,UART availability and x,y values depending on device). |
433 | * (USART,UART availability and x,y values depending on device). |
394 | * @param __FLAG__: specifies the flag to check. |
434 | * @param __FLAG__ specifies the flag to check. |
395 | * This parameter can be any combination of the following values: |
435 | * This parameter can be any combination of the following values: |
396 | * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5). |
436 | * @arg UART_FLAG_CTS: CTS Change flag (not available for UART4 and UART5). |
397 | * @arg UART_FLAG_LBD: LIN Break detection flag. |
437 | * @arg UART_FLAG_LBD: LIN Break detection flag. |
398 | * @arg UART_FLAG_TC: Transmission Complete flag. |
438 | * @arg UART_FLAG_TC: Transmission Complete flag. |
399 | * @arg UART_FLAG_RXNE: Receive data register not empty flag. |
439 | * @arg UART_FLAG_RXNE: Receive data register not empty flag. |
400 | * |
440 | * |
401 | * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (OverRun |
441 | * @note PE (Parity error), FE (Framing error), NE (Noise error), ORE (Overrun |
402 | * error) and IDLE (Idle line detected) flags are cleared by software |
442 | * error) and IDLE (Idle line detected) flags are cleared by software |
403 | * sequence: a read operation to USART_SR register followed by a read |
443 | * sequence: a read operation to USART_SR register followed by a read |
404 | * operation to USART_DR register. |
444 | * operation to USART_DR register. |
405 | * @note RXNE flag can be also cleared by a read to the USART_DR register. |
445 | * @note RXNE flag can be also cleared by a read to the USART_DR register. |
406 | * @note TC flag can be also cleared by software sequence: a read operation to |
446 | * @note TC flag can be also cleared by software sequence: a read operation to |
407 | * USART_SR register followed by a write operation to USART_DR register. |
447 | * USART_SR register followed by a write operation to USART_DR register. |
408 | * @note TXE flag is cleared only by a write to the USART_DR register. |
448 | * @note TXE flag is cleared only by a write to the USART_DR register. |
409 | * |
449 | * |
- | 450 | * @retval None |
|
410 | */ |
451 | */ |
411 | #define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) |
452 | #define __HAL_UART_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR = ~(__FLAG__)) |
412 | 453 | ||
413 | /** @brief Clears the UART PE pending flag. |
454 | /** @brief Clears the UART PE pending flag. |
414 | * @param __HANDLE__: specifies the UART Handle. |
455 | * @param __HANDLE__ specifies the UART Handle. |
415 | * UART Handle selects the USARTx or UARTy peripheral |
456 | * UART Handle selects the USARTx or UARTy peripheral |
416 | * (USART,UART availability and x,y values depending on device). |
457 | * (USART,UART availability and x,y values depending on device). |
- | 458 | * @retval None |
|
417 | */ |
459 | */ |
418 | #define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) \ |
460 | #define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) \ |
419 | do{ \ |
461 | do{ \ |
420 | __IO uint32_t tmpreg = 0x00U; \ |
462 | __IO uint32_t tmpreg = 0x00U; \ |
421 | tmpreg = (__HANDLE__)->Instance->SR; \ |
463 | tmpreg = (__HANDLE__)->Instance->SR; \ |
422 | tmpreg = (__HANDLE__)->Instance->DR; \ |
464 | tmpreg = (__HANDLE__)->Instance->DR; \ |
423 | UNUSED(tmpreg); \ |
465 | UNUSED(tmpreg); \ |
424 | } while(0U) |
466 | } while(0U) |
425 | 467 | ||
426 | /** @brief Clears the UART FE pending flag. |
468 | /** @brief Clears the UART FE pending flag. |
427 | * @param __HANDLE__: specifies the UART Handle. |
469 | * @param __HANDLE__ specifies the UART Handle. |
428 | * UART Handle selects the USARTx or UARTy peripheral |
470 | * UART Handle selects the USARTx or UARTy peripheral |
429 | * (USART,UART availability and x,y values depending on device). |
471 | * (USART,UART availability and x,y values depending on device). |
- | 472 | * @retval None |
|
430 | */ |
473 | */ |
431 | #define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__) |
474 | #define __HAL_UART_CLEAR_FEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__) |
432 | 475 | ||
433 | /** @brief Clears the UART NE pending flag. |
476 | /** @brief Clears the UART NE pending flag. |
434 | * @param __HANDLE__: specifies the UART Handle. |
477 | * @param __HANDLE__ specifies the UART Handle. |
435 | * UART Handle selects the USARTx or UARTy peripheral |
478 | * UART Handle selects the USARTx or UARTy peripheral |
436 | * (USART,UART availability and x,y values depending on device). |
479 | * (USART,UART availability and x,y values depending on device). |
- | 480 | * @retval None |
|
437 | */ |
481 | */ |
438 | #define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__) |
482 | #define __HAL_UART_CLEAR_NEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__) |
439 | 483 | ||
440 | /** @brief Clears the UART ORE pending flag. |
484 | /** @brief Clears the UART ORE pending flag. |
441 | * @param __HANDLE__: specifies the UART Handle. |
485 | * @param __HANDLE__ specifies the UART Handle. |
442 | * UART Handle selects the USARTx or UARTy peripheral |
486 | * UART Handle selects the USARTx or UARTy peripheral |
443 | * (USART,UART availability and x,y values depending on device). |
487 | * (USART,UART availability and x,y values depending on device). |
- | 488 | * @retval None |
|
444 | */ |
489 | */ |
445 | #define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__) |
490 | #define __HAL_UART_CLEAR_OREFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__) |
446 | 491 | ||
447 | /** @brief Clears the UART IDLE pending flag. |
492 | /** @brief Clears the UART IDLE pending flag. |
448 | * @param __HANDLE__: specifies the UART Handle. |
493 | * @param __HANDLE__ specifies the UART Handle. |
449 | * UART Handle selects the USARTx or UARTy peripheral |
494 | * UART Handle selects the USARTx or UARTy peripheral |
450 | * (USART,UART availability and x,y values depending on device). |
495 | * (USART,UART availability and x,y values depending on device). |
- | 496 | * @retval None |
|
451 | */ |
497 | */ |
452 | #define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__) |
498 | #define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__) |
453 | 499 | ||
454 | /** @brief Enable the specified UART interrupt. |
500 | /** @brief Enable the specified UART interrupt. |
455 | * @param __HANDLE__: specifies the UART Handle. |
501 | * @param __HANDLE__ specifies the UART Handle. |
456 | * UART Handle selects the USARTx or UARTy peripheral |
502 | * UART Handle selects the USARTx or UARTy peripheral |
457 | * (USART,UART availability and x,y values depending on device). |
503 | * (USART,UART availability and x,y values depending on device). |
458 | * @param __INTERRUPT__: specifies the UART interrupt source to enable. |
504 | * @param __INTERRUPT__ specifies the UART interrupt source to enable. |
459 | * This parameter can be one of the following values: |
505 | * This parameter can be one of the following values: |
460 | * @arg UART_IT_CTS: CTS change interrupt |
506 | * @arg UART_IT_CTS: CTS change interrupt |
461 | * @arg UART_IT_LBD: LIN Break detection interrupt |
507 | * @arg UART_IT_LBD: LIN Break detection interrupt |
462 | * @arg UART_IT_TXE: Transmit Data Register empty interrupt |
508 | * @arg UART_IT_TXE: Transmit Data Register empty interrupt |
463 | * @arg UART_IT_TC: Transmission complete interrupt |
509 | * @arg UART_IT_TC: Transmission complete interrupt |
464 | * @arg UART_IT_RXNE: Receive Data register not empty interrupt |
510 | * @arg UART_IT_RXNE: Receive Data register not empty interrupt |
465 | * @arg UART_IT_IDLE: Idle line detection interrupt |
511 | * @arg UART_IT_IDLE: Idle line detection interrupt |
466 | * @arg UART_IT_PE: Parity Error interrupt |
512 | * @arg UART_IT_PE: Parity Error interrupt |
467 | * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
513 | * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
- | 514 | * @retval None |
|
468 | */ |
515 | */ |
469 | #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == UART_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & UART_IT_MASK)): \ |
516 | #define __HAL_UART_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == UART_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 |= ((__INTERRUPT__) & UART_IT_MASK)): \ |
470 | (((__INTERRUPT__) >> 28U) == UART_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & UART_IT_MASK)): \ |
517 | (((__INTERRUPT__) >> 28U) == UART_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 |= ((__INTERRUPT__) & UART_IT_MASK)): \ |
471 | ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & UART_IT_MASK))) |
518 | ((__HANDLE__)->Instance->CR3 |= ((__INTERRUPT__) & UART_IT_MASK))) |
472 | 519 | ||
473 | /** @brief Disable the specified UART interrupt. |
520 | /** @brief Disable the specified UART interrupt. |
474 | * @param __HANDLE__: specifies the UART Handle. |
521 | * @param __HANDLE__ specifies the UART Handle. |
475 | * UART Handle selects the USARTx or UARTy peripheral |
522 | * UART Handle selects the USARTx or UARTy peripheral |
476 | * (USART,UART availability and x,y values depending on device). |
523 | * (USART,UART availability and x,y values depending on device). |
477 | * @param __INTERRUPT__: specifies the UART interrupt source to disable. |
524 | * @param __INTERRUPT__ specifies the UART interrupt source to disable. |
478 | * This parameter can be one of the following values: |
525 | * This parameter can be one of the following values: |
479 | * @arg UART_IT_CTS: CTS change interrupt |
526 | * @arg UART_IT_CTS: CTS change interrupt |
480 | * @arg UART_IT_LBD: LIN Break detection interrupt |
527 | * @arg UART_IT_LBD: LIN Break detection interrupt |
481 | * @arg UART_IT_TXE: Transmit Data Register empty interrupt |
528 | * @arg UART_IT_TXE: Transmit Data Register empty interrupt |
482 | * @arg UART_IT_TC: Transmission complete interrupt |
529 | * @arg UART_IT_TC: Transmission complete interrupt |
483 | * @arg UART_IT_RXNE: Receive Data register not empty interrupt |
530 | * @arg UART_IT_RXNE: Receive Data register not empty interrupt |
484 | * @arg UART_IT_IDLE: Idle line detection interrupt |
531 | * @arg UART_IT_IDLE: Idle line detection interrupt |
485 | * @arg UART_IT_PE: Parity Error interrupt |
532 | * @arg UART_IT_PE: Parity Error interrupt |
486 | * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
533 | * @arg UART_IT_ERR: Error interrupt(Frame error, noise error, overrun error) |
- | 534 | * @retval None |
|
487 | */ |
535 | */ |
488 | #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == UART_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & UART_IT_MASK)): \ |
536 | #define __HAL_UART_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((((__INTERRUPT__) >> 28U) == UART_CR1_REG_INDEX)? ((__HANDLE__)->Instance->CR1 &= ~((__INTERRUPT__) & UART_IT_MASK)): \ |
489 | (((__INTERRUPT__) >> 28U) == UART_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & UART_IT_MASK)): \ |
537 | (((__INTERRUPT__) >> 28U) == UART_CR2_REG_INDEX)? ((__HANDLE__)->Instance->CR2 &= ~((__INTERRUPT__) & UART_IT_MASK)): \ |
490 | ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & UART_IT_MASK))) |
538 | ((__HANDLE__)->Instance->CR3 &= ~ ((__INTERRUPT__) & UART_IT_MASK))) |
491 | 539 | ||
492 | /** @brief Checks whether the specified UART interrupt has occurred or not. |
540 | /** @brief Checks whether the specified UART interrupt source is enabled or not. |
493 | * @param __HANDLE__: specifies the UART Handle. |
541 | * @param __HANDLE__ specifies the UART Handle. |
494 | * UART Handle selects the USARTx or UARTy peripheral |
542 | * UART Handle selects the USARTx or UARTy peripheral |
495 | * (USART,UART availability and x,y values depending on device). |
543 | * (USART,UART availability and x,y values depending on device). |
496 | * @param __IT__: specifies the UART interrupt source to check. |
544 | * @param __IT__ specifies the UART interrupt source to check. |
497 | * This parameter can be one of the following values: |
545 | * This parameter can be one of the following values: |
498 | * @arg UART_IT_CTS: CTS change interrupt (not available for UART4 and UART5) |
546 | * @arg UART_IT_CTS: CTS change interrupt (not available for UART4 and UART5) |
499 | * @arg UART_IT_LBD: LIN Break detection interrupt |
547 | * @arg UART_IT_LBD: LIN Break detection interrupt |
500 | * @arg UART_IT_TXE: Transmit Data Register empty interrupt |
548 | * @arg UART_IT_TXE: Transmit Data Register empty interrupt |
501 | * @arg UART_IT_TC: Transmission complete interrupt |
549 | * @arg UART_IT_TC: Transmission complete interrupt |
Line 505... | Line 553... | ||
505 | * @retval The new state of __IT__ (TRUE or FALSE). |
553 | * @retval The new state of __IT__ (TRUE or FALSE). |
506 | */ |
554 | */ |
507 | #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == UART_CR1_REG_INDEX)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == UART_CR2_REG_INDEX)? \ |
555 | #define __HAL_UART_GET_IT_SOURCE(__HANDLE__, __IT__) (((((__IT__) >> 28U) == UART_CR1_REG_INDEX)? (__HANDLE__)->Instance->CR1:(((((uint32_t)(__IT__)) >> 28U) == UART_CR2_REG_INDEX)? \ |
508 | (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & UART_IT_MASK)) |
556 | (__HANDLE__)->Instance->CR2 : (__HANDLE__)->Instance->CR3)) & (((uint32_t)(__IT__)) & UART_IT_MASK)) |
509 | 557 | ||
510 | /** @brief Enable CTS flow control |
558 | /** @brief Enable CTS flow control |
511 | * This macro allows to enable CTS hardware flow control for a given UART instance, |
559 | * @note This macro allows to enable CTS hardware flow control for a given UART instance, |
512 | * without need to call HAL_UART_Init() function. |
560 | * without need to call HAL_UART_Init() function. |
513 | * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. |
561 | * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. |
514 | * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need |
562 | * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need |
515 | * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : |
563 | * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : |
516 | * - UART instance should have already been initialised (through call of HAL_UART_Init() ) |
564 | * - UART instance should have already been initialised (through call of HAL_UART_Init() ) |
517 | * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__)) |
565 | * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__)) |
518 | * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). |
566 | * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). |
519 | * @param __HANDLE__: specifies the UART Handle. |
567 | * @param __HANDLE__ specifies the UART Handle. |
520 | * The Handle Instance can be any USARTx (supporting the HW Flow control feature). |
568 | * The Handle Instance can be any USARTx (supporting the HW Flow control feature). |
521 | * It is used to select the USART peripheral (USART availability and x value depending on device). |
569 | * It is used to select the USART peripheral (USART availability and x value depending on device). |
- | 570 | * @retval None |
|
522 | */ |
571 | */ |
523 | #define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \ |
572 | #define __HAL_UART_HWCONTROL_CTS_ENABLE(__HANDLE__) \ |
524 | do{ \ |
573 | do{ \ |
525 | SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \ |
574 | SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \ |
526 | (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \ |
575 | (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_CTSE; \ |
527 | } while(0U) |
576 | } while(0U) |
528 | 577 | ||
529 | /** @brief Disable CTS flow control |
578 | /** @brief Disable CTS flow control |
530 | * This macro allows to disable CTS hardware flow control for a given UART instance, |
579 | * @note This macro allows to disable CTS hardware flow control for a given UART instance, |
531 | * without need to call HAL_UART_Init() function. |
580 | * without need to call HAL_UART_Init() function. |
532 | * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. |
581 | * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. |
533 | * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need |
582 | * @note As macro is expected to be used for modifying CTS Hw flow control feature activation, without need |
534 | * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : |
583 | * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : |
535 | * - UART instance should have already been initialised (through call of HAL_UART_Init() ) |
584 | * - UART instance should have already been initialised (through call of HAL_UART_Init() ) |
536 | * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__)) |
585 | * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__)) |
537 | * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). |
586 | * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). |
538 | * @param __HANDLE__: specifies the UART Handle. |
587 | * @param __HANDLE__ specifies the UART Handle. |
539 | * The Handle Instance can be any USARTx (supporting the HW Flow control feature). |
588 | * The Handle Instance can be any USARTx (supporting the HW Flow control feature). |
540 | * It is used to select the USART peripheral (USART availability and x value depending on device). |
589 | * It is used to select the USART peripheral (USART availability and x value depending on device). |
- | 590 | * @retval None |
|
541 | */ |
591 | */ |
542 | #define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \ |
592 | #define __HAL_UART_HWCONTROL_CTS_DISABLE(__HANDLE__) \ |
543 | do{ \ |
593 | do{ \ |
544 | CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \ |
594 | CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_CTSE); \ |
545 | (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \ |
595 | (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_CTSE); \ |
546 | } while(0U) |
596 | } while(0U) |
547 | 597 | ||
548 | /** @brief Enable RTS flow control |
598 | /** @brief Enable RTS flow control |
549 | * This macro allows to enable RTS hardware flow control for a given UART instance, |
599 | * This macro allows to enable RTS hardware flow control for a given UART instance, |
550 | * without need to call HAL_UART_Init() function. |
600 | * without need to call HAL_UART_Init() function. |
551 | * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. |
601 | * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. |
552 | * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need |
602 | * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need |
553 | * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : |
603 | * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : |
554 | * - UART instance should have already been initialised (through call of HAL_UART_Init() ) |
604 | * - UART instance should have already been initialised (through call of HAL_UART_Init() ) |
555 | * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__)) |
605 | * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__)) |
556 | * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). |
606 | * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). |
557 | * @param __HANDLE__: specifies the UART Handle. |
607 | * @param __HANDLE__ specifies the UART Handle. |
558 | * The Handle Instance can be any USARTx (supporting the HW Flow control feature). |
608 | * The Handle Instance can be any USARTx (supporting the HW Flow control feature). |
559 | * It is used to select the USART peripheral (USART availability and x value depending on device). |
609 | * It is used to select the USART peripheral (USART availability and x value depending on device). |
- | 610 | * @retval None |
|
560 | */ |
611 | */ |
561 | #define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \ |
612 | #define __HAL_UART_HWCONTROL_RTS_ENABLE(__HANDLE__) \ |
562 | do{ \ |
613 | do{ \ |
563 | SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \ |
614 | SET_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE); \ |
564 | (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \ |
615 | (__HANDLE__)->Init.HwFlowCtl |= USART_CR3_RTSE; \ |
565 | } while(0U) |
616 | } while(0U) |
566 | 617 | ||
567 | /** @brief Disable RTS flow control |
618 | /** @brief Disable RTS flow control |
568 | * This macro allows to disable RTS hardware flow control for a given UART instance, |
619 | * This macro allows to disable RTS hardware flow control for a given UART instance, |
569 | * without need to call HAL_UART_Init() function. |
620 | * without need to call HAL_UART_Init() function. |
570 | * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. |
621 | * As involving direct access to UART registers, usage of this macro should be fully endorsed by user. |
571 | * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need |
622 | * @note As macro is expected to be used for modifying RTS Hw flow control feature activation, without need |
572 | * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : |
623 | * for USART instance Deinit/Init, following conditions for macro call should be fulfilled : |
573 | * - UART instance should have already been initialised (through call of HAL_UART_Init() ) |
624 | * - UART instance should have already been initialised (through call of HAL_UART_Init() ) |
574 | * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__)) |
625 | * - macro could only be called when corresponding UART instance is disabled (i.e __HAL_UART_DISABLE(__HANDLE__)) |
575 | * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). |
626 | * and should be followed by an Enable macro (i.e __HAL_UART_ENABLE(__HANDLE__)). |
576 | * @param __HANDLE__: specifies the UART Handle. |
627 | * @param __HANDLE__ specifies the UART Handle. |
577 | * The Handle Instance can be any USARTx (supporting the HW Flow control feature). |
628 | * The Handle Instance can be any USARTx (supporting the HW Flow control feature). |
578 | * It is used to select the USART peripheral (USART availability and x value depending on device). |
629 | * It is used to select the USART peripheral (USART availability and x value depending on device). |
- | 630 | * @retval None |
|
579 | */ |
631 | */ |
580 | #define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \ |
632 | #define __HAL_UART_HWCONTROL_RTS_DISABLE(__HANDLE__) \ |
581 | do{ \ |
633 | do{ \ |
582 | CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\ |
634 | CLEAR_BIT((__HANDLE__)->Instance->CR3, USART_CR3_RTSE);\ |
583 | (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \ |
635 | (__HANDLE__)->Init.HwFlowCtl &= ~(USART_CR3_RTSE); \ |
584 | } while(0U) |
636 | } while(0U) |
585 | - | ||
586 | #if defined(USART_CR3_ONEBIT) |
637 | #if defined(USART_CR3_ONEBIT) |
- | 638 | ||
587 | /** @brief macros to enables the UART's one bit sample method |
639 | /** @brief Macro to enable the UART's one bit sample method |
588 | * @param __HANDLE__: specifies the UART Handle. |
640 | * @param __HANDLE__ specifies the UART Handle. |
- | 641 | * @retval None |
|
589 | */ |
642 | */ |
590 | #define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT) |
643 | #define __HAL_UART_ONE_BIT_SAMPLE_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3|= USART_CR3_ONEBIT) |
591 | 644 | ||
592 | /** @brief macros to disables the UART's one bit sample method |
645 | /** @brief Macro to disable the UART's one bit sample method |
593 | * @param __HANDLE__: specifies the UART Handle. |
646 | * @param __HANDLE__ specifies the UART Handle. |
594 | * @retval None |
647 | * @retval None |
595 | */ |
648 | */ |
596 | #define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT)) |
649 | #define __HAL_UART_ONE_BIT_SAMPLE_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR3 &= (uint16_t)~((uint16_t)USART_CR3_ONEBIT)) |
597 | #endif /* USART_CR3_ONEBIT */ |
650 | #endif /* UART_ONE_BIT_SAMPLE_Feature */ |
598 | 651 | ||
599 | /** @brief Enable UART |
652 | /** @brief Enable UART |
600 | * @param __HANDLE__: specifies the UART Handle. |
653 | * @param __HANDLE__ specifies the UART Handle. |
- | 654 | * @retval None |
|
601 | */ |
655 | */ |
602 | #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) |
656 | #define __HAL_UART_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= USART_CR1_UE) |
603 | 657 | ||
604 | /** @brief Disable UART |
658 | /** @brief Disable UART |
605 | * @param __HANDLE__: specifies the UART Handle. |
659 | * @param __HANDLE__ specifies the UART Handle. |
- | 660 | * @retval None |
|
606 | */ |
661 | */ |
607 | #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) |
662 | #define __HAL_UART_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~USART_CR1_UE) |
608 | /** |
663 | /** |
609 | * @} |
664 | * @} |
610 | */ |
665 | */ |
- | 666 | ||
611 | /* Exported functions --------------------------------------------------------*/ |
667 | /* Exported functions --------------------------------------------------------*/ |
612 | /** @addtogroup UART_Exported_Functions |
668 | /** @addtogroup UART_Exported_Functions |
613 | * @{ |
669 | * @{ |
614 | */ |
670 | */ |
615 | 671 | ||
616 | /** @addtogroup UART_Exported_Functions_Group1 |
672 | /** @addtogroup UART_Exported_Functions_Group1 Initialization and de-initialization functions |
617 | * @{ |
673 | * @{ |
618 | */ |
674 | */ |
- | 675 | ||
619 | /* Initialization/de-initialization functions **********************************/ |
676 | /* Initialization/de-initialization functions **********************************/ |
620 | HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart); |
677 | HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart); |
621 | HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart); |
678 | HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart); |
622 | HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength); |
679 | HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength); |
623 | HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod); |
680 | HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod); |
624 | HAL_StatusTypeDef HAL_UART_DeInit (UART_HandleTypeDef *huart); |
681 | HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart); |
625 | void HAL_UART_MspInit(UART_HandleTypeDef *huart); |
682 | void HAL_UART_MspInit(UART_HandleTypeDef *huart); |
626 | void HAL_UART_MspDeInit(UART_HandleTypeDef *huart); |
683 | void HAL_UART_MspDeInit(UART_HandleTypeDef *huart); |
- | 684 | ||
- | 685 | /* Callbacks Register/UnRegister functions ***********************************/ |
|
- | 686 | #if (USE_HAL_UART_REGISTER_CALLBACKS == 1) |
|
- | 687 | HAL_StatusTypeDef HAL_UART_RegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID, pUART_CallbackTypeDef pCallback); |
|
- | 688 | HAL_StatusTypeDef HAL_UART_UnRegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID); |
|
- | 689 | #endif /* USE_HAL_UART_REGISTER_CALLBACKS */ |
|
- | 690 | ||
627 | /** |
691 | /** |
628 | * @} |
692 | * @} |
629 | */ |
693 | */ |
630 | 694 | ||
631 | /** @addtogroup UART_Exported_Functions_Group2 |
695 | /** @addtogroup UART_Exported_Functions_Group2 IO operation functions |
632 | * @{ |
696 | * @{ |
633 | */ |
697 | */ |
- | 698 | ||
634 | /* IO operation functions *******************************************************/ |
699 | /* IO operation functions *******************************************************/ |
635 | HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
700 | HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
636 | HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
701 | HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
637 | HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size); |
702 | HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size); |
638 | HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size); |
703 | HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size); |
Line 653... | Line 718... | ||
653 | void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart); |
718 | void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart); |
654 | void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart); |
719 | void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart); |
655 | void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart); |
720 | void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart); |
656 | void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart); |
721 | void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart); |
657 | void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart); |
722 | void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart); |
658 | void HAL_UART_AbortCpltCallback (UART_HandleTypeDef *huart); |
723 | void HAL_UART_AbortCpltCallback(UART_HandleTypeDef *huart); |
659 | void HAL_UART_AbortTransmitCpltCallback (UART_HandleTypeDef *huart); |
724 | void HAL_UART_AbortTransmitCpltCallback(UART_HandleTypeDef *huart); |
660 | void HAL_UART_AbortReceiveCpltCallback (UART_HandleTypeDef *huart); |
725 | void HAL_UART_AbortReceiveCpltCallback(UART_HandleTypeDef *huart); |
- | 726 | ||
661 | /** |
727 | /** |
662 | * @} |
728 | * @} |
663 | */ |
729 | */ |
664 | 730 | ||
665 | /** @addtogroup UART_Exported_Functions_Group3 |
731 | /** @addtogroup UART_Exported_Functions_Group3 |
Line 678... | Line 744... | ||
678 | /** @addtogroup UART_Exported_Functions_Group4 |
744 | /** @addtogroup UART_Exported_Functions_Group4 |
679 | * @{ |
745 | * @{ |
680 | */ |
746 | */ |
681 | /* Peripheral State functions **************************************************/ |
747 | /* Peripheral State functions **************************************************/ |
682 | HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart); |
748 | HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart); |
683 | uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart); |
749 | uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart); |
684 | /** |
750 | /** |
685 | * @} |
751 | * @} |
686 | */ |
752 | */ |
687 | 753 | ||
688 | /** |
754 | /** |
Line 693... | Line 759... | ||
693 | /* Private constants ---------------------------------------------------------*/ |
759 | /* Private constants ---------------------------------------------------------*/ |
694 | /** @defgroup UART_Private_Constants UART Private Constants |
760 | /** @defgroup UART_Private_Constants UART Private Constants |
695 | * @{ |
761 | * @{ |
696 | */ |
762 | */ |
697 | /** @brief UART interruptions flag mask |
763 | /** @brief UART interruptions flag mask |
698 | * |
764 | * |
699 | */ |
765 | */ |
700 | #define UART_IT_MASK 0x0000FFFFU |
766 | #define UART_IT_MASK 0x0000FFFFU |
701 | 767 | ||
702 | #define UART_CR1_REG_INDEX 1U |
768 | #define UART_CR1_REG_INDEX 1U |
703 | #define UART_CR2_REG_INDEX 2U |
769 | #define UART_CR2_REG_INDEX 2U |
Line 733... | Line 799... | ||
733 | #define IS_UART_LIN_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16)) |
799 | #define IS_UART_LIN_OVERSAMPLING(SAMPLING) (((SAMPLING) == UART_OVERSAMPLING_16)) |
734 | #define IS_UART_LIN_BREAK_DETECT_LENGTH(LENGTH) (((LENGTH) == UART_LINBREAKDETECTLENGTH_10B) || \ |
800 | #define IS_UART_LIN_BREAK_DETECT_LENGTH(LENGTH) (((LENGTH) == UART_LINBREAKDETECTLENGTH_10B) || \ |
735 | ((LENGTH) == UART_LINBREAKDETECTLENGTH_11B)) |
801 | ((LENGTH) == UART_LINBREAKDETECTLENGTH_11B)) |
736 | #define IS_UART_WAKEUPMETHOD(WAKEUP) (((WAKEUP) == UART_WAKEUPMETHOD_IDLELINE) || \ |
802 | #define IS_UART_WAKEUPMETHOD(WAKEUP) (((WAKEUP) == UART_WAKEUPMETHOD_IDLELINE) || \ |
737 | ((WAKEUP) == UART_WAKEUPMETHOD_ADDRESSMARK)) |
803 | ((WAKEUP) == UART_WAKEUPMETHOD_ADDRESSMARK)) |
738 | #define IS_UART_BAUDRATE(BAUDRATE) ((BAUDRATE) < 4500001U) |
804 | #define IS_UART_BAUDRATE(BAUDRATE) ((BAUDRATE) <= 4500000U) |
739 | #define IS_UART_ADDRESS(ADDRESS) ((ADDRESS) <= 0x0FU) |
805 | #define IS_UART_ADDRESS(ADDRESS) ((ADDRESS) <= 0x0FU) |
740 | 806 | ||
741 | #define UART_DIV_SAMPLING16(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(4U*(_BAUD_))) |
807 | #define UART_DIV_SAMPLING16(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(4U*(_BAUD_))) |
742 | #define UART_DIVMANT_SAMPLING16(_PCLK_, _BAUD_) (UART_DIV_SAMPLING16((_PCLK_), (_BAUD_))/100U) |
808 | #define UART_DIVMANT_SAMPLING16(_PCLK_, _BAUD_) (UART_DIV_SAMPLING16((_PCLK_), (_BAUD_))/100U) |
743 | #define UART_DIVFRAQ_SAMPLING16(_PCLK_, _BAUD_) (((UART_DIV_SAMPLING16((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) * 100U)) * 16U + 50U) / 100U) |
809 | #define UART_DIVFRAQ_SAMPLING16(_PCLK_, _BAUD_) ((((UART_DIV_SAMPLING16((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) * 100U)) * 16U) + 50U) / 100U) |
744 | /* UART BRR = mantissa + overflow + fraction |
810 | /* UART BRR = mantissa + overflow + fraction |
745 | = (UART DIVMANT << 4) + (UART DIVFRAQ & 0xF0) + (UART DIVFRAQ & 0x0FU) */ |
811 | = (UART DIVMANT << 4) + (UART DIVFRAQ & 0xF0) + (UART DIVFRAQ & 0x0FU) */ |
746 | #define UART_BRR_SAMPLING16(_PCLK_, _BAUD_) (((UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) << 4U) + \ |
812 | #define UART_BRR_SAMPLING16(_PCLK_, _BAUD_) (((UART_DIVMANT_SAMPLING16((_PCLK_), (_BAUD_)) << 4U) + \ |
747 | (UART_DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0xF0U)) + \ |
813 | (UART_DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0xF0U)) + \ |
748 | (UART_DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0x0FU)) |
814 | (UART_DIVFRAQ_SAMPLING16((_PCLK_), (_BAUD_)) & 0x0FU)) |
749 | 815 | ||
750 | #define UART_DIV_SAMPLING8(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(2U*(_BAUD_))) |
816 | #define UART_DIV_SAMPLING8(_PCLK_, _BAUD_) (((_PCLK_)*25U)/(2U*(_BAUD_))) |
751 | #define UART_DIVMANT_SAMPLING8(_PCLK_, _BAUD_) (UART_DIV_SAMPLING8((_PCLK_), (_BAUD_))/100U) |
817 | #define UART_DIVMANT_SAMPLING8(_PCLK_, _BAUD_) (UART_DIV_SAMPLING8((_PCLK_), (_BAUD_))/100U) |
752 | #define UART_DIVFRAQ_SAMPLING8(_PCLK_, _BAUD_) (((UART_DIV_SAMPLING8((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) * 100U)) * 8U + 50U) / 100U) |
818 | #define UART_DIVFRAQ_SAMPLING8(_PCLK_, _BAUD_) ((((UART_DIV_SAMPLING8((_PCLK_), (_BAUD_)) - (UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) * 100U)) * 8U) + 50U) / 100U) |
753 | /* UART BRR = mantissa + overflow + fraction |
819 | /* UART BRR = mantissa + overflow + fraction |
754 | = (UART DIVMANT << 4) + ((UART DIVFRAQ & 0xF8) << 1) + (UART DIVFRAQ & 0x07U) */ |
820 | = (UART DIVMANT << 4) + ((UART DIVFRAQ & 0xF8) << 1) + (UART DIVFRAQ & 0x07U) */ |
755 | #define UART_BRR_SAMPLING8(_PCLK_, _BAUD_) (((UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) << 4U) + \ |
821 | #define UART_BRR_SAMPLING8(_PCLK_, _BAUD_) (((UART_DIVMANT_SAMPLING8((_PCLK_), (_BAUD_)) << 4U) + \ |
756 | ((UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0xF8U) << 1U)) + \ |
822 | ((UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0xF8U) << 1U)) + \ |
757 | (UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0x07U)) |
823 | (UART_DIVFRAQ_SAMPLING8((_PCLK_), (_BAUD_)) & 0x07U)) |
- | 824 | ||
758 | /** |
825 | /** |
759 | * @} |
826 | * @} |
760 | */ |
827 | */ |
761 | 828 | ||
762 | /* Private functions ---------------------------------------------------------*/ |
829 | /* Private functions ---------------------------------------------------------*/ |
Line 768... | Line 835... | ||
768 | * @} |
835 | * @} |
769 | */ |
836 | */ |
770 | 837 | ||
771 | /** |
838 | /** |
772 | * @} |
839 | * @} |
773 | */ |
840 | */ |
774 | 841 | ||
775 | /** |
842 | /** |
776 | * @} |
843 | * @} |
777 | */ |
844 | */ |
778 | 845 |