1 /**
2 *******************************************************************************************************
3 * @file fm33lc0xx_fl_uart.h
4 * @author FMSH Application Team
5 * @brief Head file of UART FL Module
6 *******************************************************************************************************
7 * @attention
8 *
9 * Copyright (c) [2021] [Fudan Microelectronics]
10 * THIS SOFTWARE is licensed under Mulan PSL v2.
11 * You can use this software according to the terms and conditions of the Mulan PSL v2.
12 * You may obtain a copy of Mulan PSL v2 at:
13 * http://license.coscl.org.cn/MulanPSL2
14 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
15 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
16 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
17 * See the Mulan PSL v2 for more details.
18 *
19 *******************************************************************************************************
20 */
21
22
23 /* Define to prevent recursive inclusion---------------------------------------------------------------*/
24 #ifndef __FM33LC0XX_FL_UART_H
25 #define __FM33LC0XX_FL_UART_H
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 /* Includes -------------------------------------------------------------------------------------------*/
31 #include "fm33lc0xx_fl_def.h"
32 /** @addtogroup FM33LC0XX_FL_Driver
33 * @{
34 */
35
36 /** @defgroup UART UART
37 * @brief UART FL driver
38 * @{
39 */
40
41 /* Exported types -------------------------------------------------------------------------------------*/
42 /** @defgroup UART_FL_ES_INIT UART Exported Init structures
43 * @{
44 */
45
46 /**
47 * @brief FL UART Init Sturcture definition
48 */
49 typedef struct
50 {
51 /** 时钟源选择 */
52 uint32_t clockSrc;
53
54 /** 通信波特率 */
55 uint32_t baudRate;
56
57 /** 数据宽度 */
58 uint32_t dataWidth;
59
60 /** 停止位 */
61 uint32_t stopBits;
62
63 /** 奇偶校验位 */
64 uint32_t parity;
65
66 /** 传输反向 */
67 uint32_t transferDirection;
68
69 } FL_UART_InitTypeDef;
70
71 /**
72 * @brief FL UART InfraRed Init Sturcture definition
73 */
74 typedef struct
75 {
76 /** 调制极性默认bit1调制 */
77 uint32_t polarity;
78 /** 红外调制占空比 */
79 uint32_t modulationDuty;
80 /** 红外调制频率*/
81 uint32_t modulationFrequency;
82
83 } FL_UART_InfraRed_InitTypeDef;
84
85 /**
86 * @}
87 */
88 /* Exported constants ---------------------------------------------------------------------------------*/
89 /** @defgroup UART_FL_Exported_Constants UART Exported Constants
90 * @{
91 */
92
93 #define UART_IRCR_IRFLAG_Pos (15U)
94 #define UART_IRCR_IRFLAG_Msk (0x1U << UART_IRCR_IRFLAG_Pos)
95 #define UART_IRCR_IRFLAG UART_IRCR_IRFLAG_Msk
96
97 #define UART_IRCR_TH_Pos (11U)
98 #define UART_IRCR_TH_Msk (0xfU << UART_IRCR_TH_Pos)
99 #define UART_IRCR_TH UART_IRCR_TH_Msk
100
101 #define UART_IRCR_TZBRG_Pos (0U)
102 #define UART_IRCR_TZBRG_Msk (0x7ffU << UART_IRCR_TZBRG_Pos)
103 #define UART_IRCR_TZBRG UART_IRCR_TZBRG_Msk
104
105 #define UART_CSR_BUSY_Pos (21U)
106 #define UART_CSR_BUSY_Msk (0x1U << UART_CSR_BUSY_Pos)
107 #define UART_CSR_BUSY UART_CSR_BUSY_Msk
108
109 #define UART_CSR_TXIREN_Pos (17U)
110 #define UART_CSR_TXIREN_Msk (0x1U << UART_CSR_TXIREN_Pos)
111 #define UART_CSR_TXIREN UART_CSR_TXIREN_Msk
112
113 #define UART_CSR_RXTOEN_Pos (16U)
114 #define UART_CSR_RXTOEN_Msk (0x1U << UART_CSR_RXTOEN_Pos)
115 #define UART_CSR_RXTOEN UART_CSR_RXTOEN_Msk
116
117 #define UART_CSR_IOSWAP_Pos (12U)
118 #define UART_CSR_IOSWAP_Msk (0x1U << UART_CSR_IOSWAP_Pos)
119 #define UART_CSR_IOSWAP UART_CSR_IOSWAP_Msk
120
121 #define UART_CSR_NEWUP_Pos (11U)
122 #define UART_CSR_NEWUP_Msk (0x1U << UART_CSR_NEWUP_Pos)
123 #define UART_CSR_NEWUP UART_CSR_NEWUP_Msk
124
125 #define UART_CSR_DMATXIFCFG_Pos (10U)
126 #define UART_CSR_DMATXIFCFG_Msk (0x1U << UART_CSR_DMATXIFCFG_Pos)
127 #define UART_CSR_DMATXIFCFG UART_CSR_DMATXIFCFG_Msk
128
129 #define UART_CSR_BITORD_Pos (9U)
130 #define UART_CSR_BITORD_Msk (0x1U << UART_CSR_BITORD_Pos)
131 #define UART_CSR_BITORD UART_CSR_BITORD_Msk
132
133 #define UART_CSR_STOPCFG_Pos (8U)
134 #define UART_CSR_STOPCFG_Msk (0x1U << UART_CSR_STOPCFG_Pos)
135 #define UART_CSR_STOPCFG UART_CSR_STOPCFG_Msk
136
137 #define UART_CSR_PDSEL_Pos (6U)
138 #define UART_CSR_PDSEL_Msk (0x3U << UART_CSR_PDSEL_Pos)
139 #define UART_CSR_PDSEL UART_CSR_PDSEL_Msk
140
141 #define UART_CSR_PARITY_Pos (4U)
142 #define UART_CSR_PARITY_Msk (0x3U << UART_CSR_PARITY_Pos)
143 #define UART_CSR_PARITY UART_CSR_PARITY_Msk
144
145 #define UART_CSR_RXPOL_Pos (3U)
146 #define UART_CSR_RXPOL_Msk (0x1U << UART_CSR_RXPOL_Pos)
147 #define UART_CSR_RXPOL UART_CSR_RXPOL_Msk
148
149 #define UART_CSR_TXPOL_Pos (2U)
150 #define UART_CSR_TXPOL_Msk (0x1U << UART_CSR_TXPOL_Pos)
151 #define UART_CSR_TXPOL UART_CSR_TXPOL_Msk
152
153 #define UART_CSR_RXEN_Pos (1U)
154 #define UART_CSR_RXEN_Msk (0x1U << UART_CSR_RXEN_Pos)
155 #define UART_CSR_RXEN UART_CSR_RXEN_Msk
156
157 #define UART_CSR_TXEN_Pos (0U)
158 #define UART_CSR_TXEN_Msk (0x1U << UART_CSR_TXEN_Pos)
159 #define UART_CSR_TXEN UART_CSR_TXEN_Msk
160
161 #define UART_IER_RXTOIE_Pos (11U)
162 #define UART_IER_RXTOIE_Msk (0x1U << UART_IER_RXTOIE_Pos)
163 #define UART_IER_RXTOIE UART_IER_RXTOIE_Msk
164
165 #define UART_IER_RXERRIE_Pos (10U)
166 #define UART_IER_RXERRIE_Msk (0x1U << UART_IER_RXERRIE_Pos)
167 #define UART_IER_RXERRIE UART_IER_RXERRIE_Msk
168
169 #define UART_IER_RXBFIE_Pos (8U)
170 #define UART_IER_RXBFIE_Msk (0x1U << UART_IER_RXBFIE_Pos)
171 #define UART_IER_RXBFIE UART_IER_RXBFIE_Msk
172
173 #define UART_IER_NEWUPIE_Pos (7U)
174 #define UART_IER_NEWUPIE_Msk (0x1U << UART_IER_NEWUPIE_Pos)
175 #define UART_IER_NEWUPIE UART_IER_NEWUPIE_Msk
176
177 #define UART_IER_TXBEIE_Pos (1U)
178 #define UART_IER_TXBEIE_Msk (0x1U << UART_IER_TXBEIE_Pos)
179 #define UART_IER_TXBEIE UART_IER_TXBEIE_Msk
180
181 #define UART_IER_TXSEIE_Pos (0U)
182 #define UART_IER_TXSEIE_Msk (0x1U << UART_IER_TXSEIE_Pos)
183 #define UART_IER_TXSEIE UART_IER_TXSEIE_Msk
184
185 #define UART_ISR_PERR_Pos (18U)
186 #define UART_ISR_PERR_Msk (0x1U << UART_ISR_PERR_Pos)
187 #define UART_ISR_PERR UART_ISR_PERR_Msk
188
189 #define UART_ISR_FERR_Pos (17U)
190 #define UART_ISR_FERR_Msk (0x1U << UART_ISR_FERR_Pos)
191 #define UART_ISR_FERR UART_ISR_FERR_Msk
192
193 #define UART_ISR_OERR_Pos (16U)
194 #define UART_ISR_OERR_Msk (0x1U << UART_ISR_OERR_Pos)
195 #define UART_ISR_OERR UART_ISR_OERR_Msk
196
197 #define UART_ISR_RXTO_Pos (11U)
198 #define UART_ISR_RXTO_Msk (0x1U << UART_ISR_RXTO_Pos)
199 #define UART_ISR_RXTO UART_ISR_RXTO_Msk
200
201 #define UART_ISR_RXBF_Pos (8U)
202 #define UART_ISR_RXBF_Msk (0x1U << UART_ISR_RXBF_Pos)
203 #define UART_ISR_RXBF UART_ISR_RXBF_Msk
204
205 #define UART_ISR_NEWKF_Pos (7U)
206 #define UART_ISR_NEWKF_Msk (0x1U << UART_ISR_NEWKF_Pos)
207 #define UART_ISR_NEWKF UART_ISR_NEWKF_Msk
208
209 #define UART_ISR_TXBE_Pos (1U)
210 #define UART_ISR_TXBE_Msk (0x1U << UART_ISR_TXBE_Pos)
211 #define UART_ISR_TXBE UART_ISR_TXBE_Msk
212
213 #define UART_ISR_TXSE_Pos (0U)
214 #define UART_ISR_TXSE_Msk (0x1U << UART_ISR_TXSE_Pos)
215 #define UART_ISR_TXSE UART_ISR_TXSE_Msk
216
217 #define UART_TODR_TXDLY_LEN_Pos (8U)
218 #define UART_TODR_TXDLY_LEN_Msk (0xffU << UART_TODR_TXDLY_LEN_Pos)
219 #define UART_TODR_TXDLY_LEN UART_TODR_TXDLY_LEN_Msk
220
221 #define UART_TODR_RXTO_LEN_Pos (0U)
222 #define UART_TODR_RXTO_LEN_Msk (0xffU << UART_TODR_RXTO_LEN_Pos)
223 #define UART_TODR_RXTO_LEN UART_TODR_RXTO_LEN_Msk
224
225
226
227 #define FL_UART_INFRARED_POLARITY_NORMAL (0x0U << UART_IRCR_IRFLAG_Pos)
228 #define FL_UART_INFRARED_POLARITY_INVERT (0x1U << UART_IRCR_IRFLAG_Pos)
229
230
231 #define FL_UART_TXIF_MODE_ALWAYS (0x0U << UART_CSR_DMATXIFCFG_Pos)
232 #define FL_UART_TXIF_MODE_AFTER_DMA (0x1U << UART_CSR_DMATXIFCFG_Pos)
233
234
235 #define FL_UART_BIT_ORDER_LSB_FIRST (0x0U << UART_CSR_BITORD_Pos)
236 #define FL_UART_BIT_ORDER_MSB_FIRST (0x1U << UART_CSR_BITORD_Pos)
237
238
239 #define FL_UART_STOP_BIT_WIDTH_1B (0x0U << UART_CSR_STOPCFG_Pos)
240 #define FL_UART_STOP_BIT_WIDTH_2B (0x1U << UART_CSR_STOPCFG_Pos)
241
242
243 #define FL_UART_DATA_WIDTH_7B (0x0U << UART_CSR_PDSEL_Pos)
244 #define FL_UART_DATA_WIDTH_8B (0x1U << UART_CSR_PDSEL_Pos)
245 #define FL_UART_DATA_WIDTH_9B (0x2U << UART_CSR_PDSEL_Pos)
246 #define FL_UART_DATA_WIDTH_6B (0x3U << UART_CSR_PDSEL_Pos)
247
248
249 #define FL_UART_PARITY_NONE (0x0U << UART_CSR_PARITY_Pos)
250 #define FL_UART_PARITY_EVEN (0x1U << UART_CSR_PARITY_Pos)
251 #define FL_UART_PARITY_ODD (0x2U << UART_CSR_PARITY_Pos)
252
253
254 #define FL_UART_RX_POLARITY_NORMAL (0x0U << UART_CSR_RXPOL_Pos)
255 #define FL_UART_RX_POLARITY_INVERT (0x1U << UART_CSR_RXPOL_Pos)
256
257
258 #define FL_UART_TX_POLARITY_NORMAL (0x0U << UART_CSR_TXPOL_Pos)
259 #define FL_UART_TX_POLARITY_INVERT (0x1U << UART_CSR_TXPOL_Pos)
260
261
262 #define FL_UART_DIRECTION_NONE 0x00000000U
263 #define FL_UART_DIRECTION_RX UART_CSR_RXEN
264 #define FL_UART_DIRECTION_TX UART_CSR_TXEN
265 #define FL_UART_DIRECTION_TX_RX (UART_CSR_RXEN | UART_CSR_TXEN)
266
267 /**
268 * @}
269 */
270 /* Exported functions ---------------------------------------------------------------------------------*/
271 /** @defgroup UART_FL_Exported_Functions UART Exported Functions
272 * @{
273 */
274
275 /**
276 * @brief Set Infrared Polarity
277 * @rmtoll IRCR IRFLAG FL_UART_SetIRPolarity
278 * @param UARTx UART instance
279 * @param polarity This parameter can be one of the following values:
280 * @arg @ref FL_UART_INFRARED_POLARITY_NORMAL
281 * @arg @ref FL_UART_INFRARED_POLARITY_INVERT
282 * @retval None
283 */
FL_UART_SetIRPolarity(UART_COMMON_Type * UARTx,uint32_t polarity)284 __STATIC_INLINE void FL_UART_SetIRPolarity(UART_COMMON_Type *UARTx, uint32_t polarity)
285 {
286 MODIFY_REG(UARTx->IRCR, UART_IRCR_IRFLAG_Msk, polarity);
287 }
288
289 /**
290 * @brief Get Infrared Polarity
291 * @rmtoll IRCR IRFLAG FL_UART_GetIRPolarity
292 * @param UARTx UART instance
293 * @retval Returned value can be one of the following values:
294 * @arg @ref FL_UART_INFRARED_POLARITY_NORMAL
295 * @arg @ref FL_UART_INFRARED_POLARITY_INVERT
296 */
FL_UART_GetIRPolarity(UART_COMMON_Type * UARTx)297 __STATIC_INLINE uint32_t FL_UART_GetIRPolarity(UART_COMMON_Type *UARTx)
298 {
299 return (uint32_t)(READ_BIT(UARTx->IRCR, UART_IRCR_IRFLAG_Msk));
300 }
301
302 /**
303 * @brief Set Infrared Modulation Duty
304 * @rmtoll IRCR TH FL_UART_WriteIRModulationDuty
305 * @param UARTx UART instance
306 * @param duty
307 * @retval None
308 */
FL_UART_WriteIRModulationDuty(UART_COMMON_Type * UARTx,uint32_t duty)309 __STATIC_INLINE void FL_UART_WriteIRModulationDuty(UART_COMMON_Type *UARTx, uint32_t duty)
310 {
311 MODIFY_REG(UARTx->IRCR, (0xfU << 11U), (duty << 11U));
312 }
313
314 /**
315 * @brief Get Infrared Modulation Duty
316 * @rmtoll IRCR TH FL_UART_ReadIRModulationDuty
317 * @param UARTx UART instance
318 * @retval
319 */
FL_UART_ReadIRModulationDuty(UART_COMMON_Type * UARTx)320 __STATIC_INLINE uint32_t FL_UART_ReadIRModulationDuty(UART_COMMON_Type *UARTx)
321 {
322 return (uint32_t)(READ_BIT(UARTx->IRCR, (0xfU << 11U)) >> 11U);
323 }
324
325 /**
326 * @brief Set Infrared Modulation Frequency
327 * @rmtoll IRCR TZBRG FL_UART_WriteIRModulationFrequency
328 * @param UARTx UART instance
329 * @param freq
330 * @retval None
331 */
FL_UART_WriteIRModulationFrequency(UART_COMMON_Type * UARTx,uint32_t freq)332 __STATIC_INLINE void FL_UART_WriteIRModulationFrequency(UART_COMMON_Type *UARTx, uint32_t freq)
333 {
334 MODIFY_REG(UARTx->IRCR, (0x7ffU << 0U), (freq << 0U));
335 }
336
337 /**
338 * @brief Get Infrared Modulation Frequency
339 * @rmtoll IRCR TZBRG FL_UART_ReadIRModulationFrequency
340 * @param UARTx UART instance
341 * @retval
342 */
FL_UART_ReadIRModulationFrequency(UART_COMMON_Type * UARTx)343 __STATIC_INLINE uint32_t FL_UART_ReadIRModulationFrequency(UART_COMMON_Type *UARTx)
344 {
345 return (uint32_t)(READ_BIT(UARTx->IRCR, (0x7ffU << 0U)) >> 0U);
346 }
347
348 /**
349 * @brief Get UART Busy Flag
350 * @rmtoll CSR BUSY FL_UART_IsActiveFlag_Busy
351 * @param UARTx UART instance
352 * @retval State of bit (1 or 0).
353 */
FL_UART_IsActiveFlag_Busy(UART_Type * UARTx)354 __STATIC_INLINE uint32_t FL_UART_IsActiveFlag_Busy(UART_Type *UARTx)
355 {
356 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_BUSY_Msk) == (UART_CSR_BUSY_Msk));
357 }
358
359 /**
360 * @brief Enable UART Infrared Modulation
361 * @rmtoll CSR TXIREN FL_UART_EnableIRModulation
362 * @param UARTx UART instance
363 * @retval None
364 */
FL_UART_EnableIRModulation(UART_Type * UARTx)365 __STATIC_INLINE void FL_UART_EnableIRModulation(UART_Type *UARTx)
366 {
367 SET_BIT(UARTx->CSR, UART_CSR_TXIREN_Msk);
368 }
369
370 /**
371 * @brief Disable UART Infrared Modulation
372 * @rmtoll CSR TXIREN FL_UART_DisableIRModulation
373 * @param UARTx UART instance
374 * @retval None
375 */
FL_UART_DisableIRModulation(UART_Type * UARTx)376 __STATIC_INLINE void FL_UART_DisableIRModulation(UART_Type *UARTx)
377 {
378 CLEAR_BIT(UARTx->CSR, UART_CSR_TXIREN_Msk);
379 }
380
381 /**
382 * @brief Get UART Infrared Modulation Enable Status
383 * @rmtoll CSR TXIREN FL_UART_IsEnabledIRModulation
384 * @param UARTx UART instance
385 * @retval State of bit (1 or 0).
386 */
FL_UART_IsEnabledIRModulation(UART_Type * UARTx)387 __STATIC_INLINE uint32_t FL_UART_IsEnabledIRModulation(UART_Type *UARTx)
388 {
389 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_TXIREN_Msk) == UART_CSR_TXIREN_Msk);
390 }
391
392 /**
393 * @brief Enable UART Receive Time-Out Function
394 * @rmtoll CSR RXTOEN FL_UART_EnableRXTimeout
395 * @param UARTx UART instance
396 * @retval None
397 */
FL_UART_EnableRXTimeout(UART_Type * UARTx)398 __STATIC_INLINE void FL_UART_EnableRXTimeout(UART_Type *UARTx)
399 {
400 SET_BIT(UARTx->CSR, UART_CSR_RXTOEN_Msk);
401 }
402
403 /**
404 * @brief Disable UART Receive Time-Out Function
405 * @rmtoll CSR RXTOEN FL_UART_DisableRXTimeout
406 * @param UARTx UART instance
407 * @retval None
408 */
FL_UART_DisableRXTimeout(UART_Type * UARTx)409 __STATIC_INLINE void FL_UART_DisableRXTimeout(UART_Type *UARTx)
410 {
411 CLEAR_BIT(UARTx->CSR, UART_CSR_RXTOEN_Msk);
412 }
413
414 /**
415 * @brief Get UART Receive Time-Out Function Enable Status
416 * @rmtoll CSR RXTOEN FL_UART_IsEnabledRXTimeout
417 * @param UARTx UART instance
418 * @retval State of bit (1 or 0).
419 */
FL_UART_IsEnabledRXTimeout(UART_Type * UARTx)420 __STATIC_INLINE uint32_t FL_UART_IsEnabledRXTimeout(UART_Type *UARTx)
421 {
422 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_RXTOEN_Msk) == UART_CSR_RXTOEN_Msk);
423 }
424
425 /**
426 * @brief Enable UART Pin Swap Between UART TX Pin and RX Pin
427 * @rmtoll CSR IOSWAP FL_UART_EnablePinSwap
428 * @param UARTx UART instance
429 * @retval None
430 */
FL_UART_EnablePinSwap(UART_Type * UARTx)431 __STATIC_INLINE void FL_UART_EnablePinSwap(UART_Type *UARTx)
432 {
433 SET_BIT(UARTx->CSR, UART_CSR_IOSWAP_Msk);
434 }
435
436 /**
437 * @brief Disable UART Pin Swap Between UART TX Pin and RX Pin
438 * @rmtoll CSR IOSWAP FL_UART_DisablePinSwap
439 * @param UARTx UART instance
440 * @retval None
441 */
FL_UART_DisablePinSwap(UART_Type * UARTx)442 __STATIC_INLINE void FL_UART_DisablePinSwap(UART_Type *UARTx)
443 {
444 CLEAR_BIT(UARTx->CSR, UART_CSR_IOSWAP_Msk);
445 }
446
447 /**
448 * @brief Get UART Pin Swap Enable Status Between UART TX Pin and RX Pin
449 * @rmtoll CSR IOSWAP FL_UART_IsEnabledPinSwap
450 * @param UARTx UART instance
451 * @retval State of bit (1 or 0).
452 */
FL_UART_IsEnabledPinSwap(UART_Type * UARTx)453 __STATIC_INLINE uint32_t FL_UART_IsEnabledPinSwap(UART_Type *UARTx)
454 {
455 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_IOSWAP_Msk) == UART_CSR_IOSWAP_Msk);
456 }
457
458 /**
459 * @brief Enable UART Negtive Edge Wakeup Function
460 * @note Only UART0 and UART1 Available
461 * @rmtoll CSR NEWUP FL_UART_EnableFallingEdgeWakeup
462 * @param UARTx UART instance
463 * @retval None
464 */
FL_UART_EnableFallingEdgeWakeup(UART_Type * UARTx)465 __STATIC_INLINE void FL_UART_EnableFallingEdgeWakeup(UART_Type *UARTx)
466 {
467 SET_BIT(UARTx->CSR, UART_CSR_NEWUP_Msk);
468 }
469
470 /**
471 * @brief Disable UART Negtive Edge Wakeup Function
472 * @rmtoll CSR NEWUP FL_UART_DisableFallingEdgeWakeup
473 * @param UARTx UART instance
474 * @retval None
475 */
FL_UART_DisableFallingEdgeWakeup(UART_Type * UARTx)476 __STATIC_INLINE void FL_UART_DisableFallingEdgeWakeup(UART_Type *UARTx)
477 {
478 CLEAR_BIT(UARTx->CSR, UART_CSR_NEWUP_Msk);
479 }
480
481 /**
482 * @brief Get UART Negtive Edge Wakeup Function Enable Status
483 * @rmtoll CSR NEWUP FL_UART_IsEnabledFallingEdgeWakeup
484 * @param UARTx UART instance
485 * @retval State of bit (1 or 0).
486 */
FL_UART_IsEnabledFallingEdgeWakeup(UART_Type * UARTx)487 __STATIC_INLINE uint32_t FL_UART_IsEnabledFallingEdgeWakeup(UART_Type *UARTx)
488 {
489 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_NEWUP_Msk) == UART_CSR_NEWUP_Msk);
490 }
491
492 /**
493 * @brief Set UART DMA Transmit Finish Interrupt
494 * @note Only DMA Mode Available
495 * @rmtoll CSR DMATXIFCFG FL_UART_SetTXIFMode
496 * @param UARTx UART instance
497 * @param mode This parameter can be one of the following values:
498 * @arg @ref FL_UART_TXIF_MODE_ALWAYS
499 * @arg @ref FL_UART_TXIF_MODE_AFTER_DMA
500 * @retval None
501 */
FL_UART_SetTXIFMode(UART_Type * UARTx,uint32_t mode)502 __STATIC_INLINE void FL_UART_SetTXIFMode(UART_Type *UARTx, uint32_t mode)
503 {
504 MODIFY_REG(UARTx->CSR, UART_CSR_DMATXIFCFG_Msk, mode);
505 }
506
507 /**
508 * @brief Get UART DMA Transmit Finish Interrupt
509 * @rmtoll CSR DMATXIFCFG FL_UART_GetTXIFMode
510 * @param UARTx UART instance
511 * @retval Returned value can be one of the following values:
512 * @arg @ref FL_UART_TXIF_MODE_ALWAYS
513 * @arg @ref FL_UART_TXIF_MODE_AFTER_DMA
514 */
FL_UART_GetTXIFMode(UART_Type * UARTx)515 __STATIC_INLINE uint32_t FL_UART_GetTXIFMode(UART_Type *UARTx)
516 {
517 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_DMATXIFCFG_Msk));
518 }
519
520 /**
521 * @brief Set UART Transfer Bit Order
522 * @rmtoll CSR BITORD FL_UART_SetBitOrder
523 * @param UARTx UART instance
524 * @param order This parameter can be one of the following values:
525 * @arg @ref FL_UART_BIT_ORDER_LSB_FIRST
526 * @arg @ref FL_UART_BIT_ORDER_MSB_FIRST
527 * @retval None
528 */
FL_UART_SetBitOrder(UART_Type * UARTx,uint32_t order)529 __STATIC_INLINE void FL_UART_SetBitOrder(UART_Type *UARTx, uint32_t order)
530 {
531 MODIFY_REG(UARTx->CSR, UART_CSR_BITORD_Msk, order);
532 }
533
534 /**
535 * @brief Get UART Transfer Bit Order
536 * @rmtoll CSR BITORD FL_UART_GetBitOrder
537 * @param UARTx UART instance
538 * @retval Returned value can be one of the following values:
539 * @arg @ref FL_UART_BIT_ORDER_LSB_FIRST
540 * @arg @ref FL_UART_BIT_ORDER_MSB_FIRST
541 */
FL_UART_GetBitOrder(UART_Type * UARTx)542 __STATIC_INLINE uint32_t FL_UART_GetBitOrder(UART_Type *UARTx)
543 {
544 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_BITORD_Msk));
545 }
546
547 /**
548 * @brief Set UART Stop Bits Length
549 * @rmtoll CSR STOPCFG FL_UART_SetStopBitsWidth
550 * @param UARTx UART instance
551 * @param length This parameter can be one of the following values:
552 * @arg @ref FL_UART_STOP_BIT_WIDTH_1B
553 * @arg @ref FL_UART_STOP_BIT_WIDTH_2B
554 * @retval None
555 */
FL_UART_SetStopBitsWidth(UART_Type * UARTx,uint32_t length)556 __STATIC_INLINE void FL_UART_SetStopBitsWidth(UART_Type *UARTx, uint32_t length)
557 {
558 MODIFY_REG(UARTx->CSR, UART_CSR_STOPCFG_Msk, length);
559 }
560
561 /**
562 * @brief Get UART Stop Bits Length
563 * @rmtoll CSR STOPCFG FL_UART_GetStopBitsWidth
564 * @param UARTx UART instance
565 * @retval Returned value can be one of the following values:
566 * @arg @ref FL_UART_STOP_BIT_WIDTH_1B
567 * @arg @ref FL_UART_STOP_BIT_WIDTH_2B
568 */
FL_UART_GetStopBitsWidth(UART_Type * UARTx)569 __STATIC_INLINE uint32_t FL_UART_GetStopBitsWidth(UART_Type *UARTx)
570 {
571 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_STOPCFG_Msk));
572 }
573
574 /**
575 * @brief Set UART Data Width
576 * @rmtoll CSR PDSEL FL_UART_SetDataWidth
577 * @param UARTx UART instance
578 * @param dataWidth This parameter can be one of the following values:
579 * @arg @ref FL_UART_DATA_WIDTH_7B
580 * @arg @ref FL_UART_DATA_WIDTH_8B
581 * @arg @ref FL_UART_DATA_WIDTH_9B
582 * @arg @ref FL_UART_DATA_WIDTH_6B
583 * @retval None
584 */
FL_UART_SetDataWidth(UART_Type * UARTx,uint32_t dataWidth)585 __STATIC_INLINE void FL_UART_SetDataWidth(UART_Type *UARTx, uint32_t dataWidth)
586 {
587 MODIFY_REG(UARTx->CSR, UART_CSR_PDSEL_Msk, dataWidth);
588 }
589
590 /**
591 * @brief Get UART Data Width
592 * @rmtoll CSR PDSEL FL_UART_GetDataWidth
593 * @param UARTx UART instance
594 * @retval Returned value can be one of the following values:
595 * @arg @ref FL_UART_DATA_WIDTH_7B
596 * @arg @ref FL_UART_DATA_WIDTH_8B
597 * @arg @ref FL_UART_DATA_WIDTH_9B
598 * @arg @ref FL_UART_DATA_WIDTH_6B
599 */
FL_UART_GetDataWidth(UART_Type * UARTx)600 __STATIC_INLINE uint32_t FL_UART_GetDataWidth(UART_Type *UARTx)
601 {
602 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_PDSEL_Msk));
603 }
604
605 /**
606 * @brief Set UART Parity
607 * @rmtoll CSR PARITY FL_UART_SetParity
608 * @param UARTx UART instance
609 * @param parity This parameter can be one of the following values:
610 * @arg @ref FL_UART_PARITY_NONE
611 * @arg @ref FL_UART_PARITY_EVEN
612 * @arg @ref FL_UART_PARITY_ODD
613 * @retval None
614 */
FL_UART_SetParity(UART_Type * UARTx,uint32_t parity)615 __STATIC_INLINE void FL_UART_SetParity(UART_Type *UARTx, uint32_t parity)
616 {
617 MODIFY_REG(UARTx->CSR, UART_CSR_PARITY_Msk, parity);
618 }
619
620 /**
621 * @brief Get UART Parity
622 * @rmtoll CSR PARITY FL_UART_GetParity
623 * @param UARTx UART instance
624 * @retval Returned value can be one of the following values:
625 * @arg @ref FL_UART_PARITY_NONE
626 * @arg @ref FL_UART_PARITY_EVEN
627 * @arg @ref FL_UART_PARITY_ODD
628 */
FL_UART_GetParity(UART_Type * UARTx)629 __STATIC_INLINE uint32_t FL_UART_GetParity(UART_Type *UARTx)
630 {
631 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_PARITY_Msk));
632 }
633
634 /**
635 * @brief Set UART Receive Polarity
636 * @rmtoll CSR RXPOL FL_UART_SetRXPolarity
637 * @param UARTx UART instance
638 * @param polarity This parameter can be one of the following values:
639 * @arg @ref FL_UART_RX_POLARITY_NORMAL
640 * @arg @ref FL_UART_RX_POLARITY_INVERT
641 * @retval None
642 */
FL_UART_SetRXPolarity(UART_Type * UARTx,uint32_t polarity)643 __STATIC_INLINE void FL_UART_SetRXPolarity(UART_Type *UARTx, uint32_t polarity)
644 {
645 MODIFY_REG(UARTx->CSR, UART_CSR_RXPOL_Msk, polarity);
646 }
647
648 /**
649 * @brief Get UART Receive Polarity
650 * @rmtoll CSR RXPOL FL_UART_GetRXPolarity
651 * @param UARTx UART instance
652 * @retval Returned value can be one of the following values:
653 * @arg @ref FL_UART_RX_POLARITY_NORMAL
654 * @arg @ref FL_UART_RX_POLARITY_INVERT
655 */
FL_UART_GetRXPolarity(UART_Type * UARTx)656 __STATIC_INLINE uint32_t FL_UART_GetRXPolarity(UART_Type *UARTx)
657 {
658 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_RXPOL_Msk));
659 }
660
661 /**
662 * @brief Set UART Transmit Polarity
663 * @rmtoll CSR TXPOL FL_UART_SetTXPolarity
664 * @param UARTx UART instance
665 * @param polarity This parameter can be one of the following values:
666 * @arg @ref FL_UART_TX_POLARITY_NORMAL
667 * @arg @ref FL_UART_TX_POLARITY_INVERT
668 * @retval None
669 */
FL_UART_SetTXPolarity(UART_Type * UARTx,uint32_t polarity)670 __STATIC_INLINE void FL_UART_SetTXPolarity(UART_Type *UARTx, uint32_t polarity)
671 {
672 MODIFY_REG(UARTx->CSR, UART_CSR_TXPOL_Msk, polarity);
673 }
674
675 /**
676 * @brief Get UART Transmit Polarity
677 * @rmtoll CSR TXPOL FL_UART_GetTXPolarity
678 * @param UARTx UART instance
679 * @retval Returned value can be one of the following values:
680 * @arg @ref FL_UART_TX_POLARITY_NORMAL
681 * @arg @ref FL_UART_TX_POLARITY_INVERT
682 */
FL_UART_GetTXPolarity(UART_Type * UARTx)683 __STATIC_INLINE uint32_t FL_UART_GetTXPolarity(UART_Type *UARTx)
684 {
685 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_TXPOL_Msk));
686 }
687
688 /**
689 * @brief Enable UART Receive
690 * @rmtoll CSR RXEN FL_UART_EnableRX
691 * @param UARTx UART instance
692 * @retval None
693 */
FL_UART_EnableRX(UART_Type * UARTx)694 __STATIC_INLINE void FL_UART_EnableRX(UART_Type *UARTx)
695 {
696 SET_BIT(UARTx->CSR, UART_CSR_RXEN_Msk);
697 }
698
699 /**
700 * @brief Disable UART Receive
701 * @rmtoll CSR RXEN FL_UART_DisableRX
702 * @param UARTx UART instance
703 * @retval None
704 */
FL_UART_DisableRX(UART_Type * UARTx)705 __STATIC_INLINE void FL_UART_DisableRX(UART_Type *UARTx)
706 {
707 CLEAR_BIT(UARTx->CSR, UART_CSR_RXEN_Msk);
708 }
709
710 /**
711 * @brief Get UART Receive Enable Status
712 * @rmtoll CSR RXEN FL_UART_IsEnabledRX
713 * @param UARTx UART instance
714 * @retval State of bit (1 or 0).
715 */
FL_UART_IsEnabledRX(UART_Type * UARTx)716 __STATIC_INLINE uint32_t FL_UART_IsEnabledRX(UART_Type *UARTx)
717 {
718 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_RXEN_Msk) == UART_CSR_RXEN_Msk);
719 }
720
721 /**
722 * @brief Enable UART Transmit
723 * @rmtoll CSR TXEN FL_UART_EnableTX
724 * @param UARTx UART instance
725 * @retval None
726 */
FL_UART_EnableTX(UART_Type * UARTx)727 __STATIC_INLINE void FL_UART_EnableTX(UART_Type *UARTx)
728 {
729 SET_BIT(UARTx->CSR, UART_CSR_TXEN_Msk);
730 }
731
732 /**
733 * @brief Disable UART Receive
734 * @rmtoll CSR TXEN FL_UART_DisableTX
735 * @param UARTx UART instance
736 * @retval None
737 */
FL_UART_DisableTX(UART_Type * UARTx)738 __STATIC_INLINE void FL_UART_DisableTX(UART_Type *UARTx)
739 {
740 CLEAR_BIT(UARTx->CSR, UART_CSR_TXEN_Msk);
741 }
742
743 /**
744 * @brief Get UART Receive Enable Status
745 * @rmtoll CSR TXEN FL_UART_IsEnabledTX
746 * @param UARTx UART instance
747 * @retval State of bit (1 or 0).
748 */
FL_UART_IsEnabledTX(UART_Type * UARTx)749 __STATIC_INLINE uint32_t FL_UART_IsEnabledTX(UART_Type *UARTx)
750 {
751 return (uint32_t)(READ_BIT(UARTx->CSR, UART_CSR_TXEN_Msk) == UART_CSR_TXEN_Msk);
752 }
753
754 /**
755 * @brief Enable UART Receive Time-Out Interrupt
756 * @rmtoll IER RXTOIE FL_UART_EnableIT_RXTimeout
757 * @param UARTx UART instance
758 * @retval None
759 */
FL_UART_EnableIT_RXTimeout(UART_Type * UARTx)760 __STATIC_INLINE void FL_UART_EnableIT_RXTimeout(UART_Type *UARTx)
761 {
762 SET_BIT(UARTx->IER, UART_IER_RXTOIE_Msk);
763 }
764
765 /**
766 * @brief Disable UART Receive Time-Out Interrupt
767 * @rmtoll IER RXTOIE FL_UART_DisableIT_RXTimeout
768 * @param UARTx UART instance
769 * @retval None
770 */
FL_UART_DisableIT_RXTimeout(UART_Type * UARTx)771 __STATIC_INLINE void FL_UART_DisableIT_RXTimeout(UART_Type *UARTx)
772 {
773 CLEAR_BIT(UARTx->IER, UART_IER_RXTOIE_Msk);
774 }
775
776 /**
777 * @brief Get UART Receive Time-Out Interrupt Enable Status
778 * @rmtoll IER RXTOIE FL_UART_IsEnabledIT_RXTimeout
779 * @param UARTx UART instance
780 * @retval State of bit (1 or 0).
781 */
FL_UART_IsEnabledIT_RXTimeout(UART_Type * UARTx)782 __STATIC_INLINE uint32_t FL_UART_IsEnabledIT_RXTimeout(UART_Type *UARTx)
783 {
784 return (uint32_t)(READ_BIT(UARTx->IER, UART_IER_RXTOIE_Msk) == UART_IER_RXTOIE_Msk);
785 }
786
787 /**
788 * @brief Enable UART Receive Error Interrupt
789 * @rmtoll IER RXERRIE FL_UART_EnableIT_RXError
790 * @param UARTx UART instance
791 * @retval None
792 */
FL_UART_EnableIT_RXError(UART_Type * UARTx)793 __STATIC_INLINE void FL_UART_EnableIT_RXError(UART_Type *UARTx)
794 {
795 SET_BIT(UARTx->IER, UART_IER_RXERRIE_Msk);
796 }
797
798 /**
799 * @brief Disable UART Receive Error Interrupt
800 * @rmtoll IER RXERRIE FL_UART_DisableIT_RXError
801 * @param UARTx UART instance
802 * @retval None
803 */
FL_UART_DisableIT_RXError(UART_Type * UARTx)804 __STATIC_INLINE void FL_UART_DisableIT_RXError(UART_Type *UARTx)
805 {
806 CLEAR_BIT(UARTx->IER, UART_IER_RXERRIE_Msk);
807 }
808
809 /**
810 * @brief Get UART Receive Error Interrupt Enable Status
811 * @rmtoll IER RXERRIE FL_UART_IsEnabledIT_RXError
812 * @param UARTx UART instance
813 * @retval State of bit (1 or 0).
814 */
FL_UART_IsEnabledIT_RXError(UART_Type * UARTx)815 __STATIC_INLINE uint32_t FL_UART_IsEnabledIT_RXError(UART_Type *UARTx)
816 {
817 return (uint32_t)(READ_BIT(UARTx->IER, UART_IER_RXERRIE_Msk) == UART_IER_RXERRIE_Msk);
818 }
819
820 /**
821 * @brief Enable UART Receive Buffer Full Interrupt
822 * @rmtoll IER RXBFIE FL_UART_EnableIT_RXBuffFull
823 * @param UARTx UART instance
824 * @retval None
825 */
FL_UART_EnableIT_RXBuffFull(UART_Type * UARTx)826 __STATIC_INLINE void FL_UART_EnableIT_RXBuffFull(UART_Type *UARTx)
827 {
828 SET_BIT(UARTx->IER, UART_IER_RXBFIE_Msk);
829 }
830
831 /**
832 * @brief Disable UART Receive Buffer Full Interrupt
833 * @rmtoll IER RXBFIE FL_UART_DisableIT_RXBuffFull
834 * @param UARTx UART instance
835 * @retval None
836 */
FL_UART_DisableIT_RXBuffFull(UART_Type * UARTx)837 __STATIC_INLINE void FL_UART_DisableIT_RXBuffFull(UART_Type *UARTx)
838 {
839 CLEAR_BIT(UARTx->IER, UART_IER_RXBFIE_Msk);
840 }
841
842 /**
843 * @brief Get UART Receive Buffer Full Interrupt Enable Status
844 * @rmtoll IER RXBFIE FL_UART_IsEnabledIT_RXBuffFull
845 * @param UARTx UART instance
846 * @retval State of bit (1 or 0).
847 */
FL_UART_IsEnabledIT_RXBuffFull(UART_Type * UARTx)848 __STATIC_INLINE uint32_t FL_UART_IsEnabledIT_RXBuffFull(UART_Type *UARTx)
849 {
850 return (uint32_t)(READ_BIT(UARTx->IER, UART_IER_RXBFIE_Msk) == UART_IER_RXBFIE_Msk);
851 }
852
853 /**
854 * @brief Enable UART Negedge Wakeup Interrupt
855 * @rmtoll IER NEWUPIE FL_UART_EnableIT_FallingEdgeWakeup
856 * @param UARTx UART instance
857 * @retval None
858 */
FL_UART_EnableIT_FallingEdgeWakeup(UART_Type * UARTx)859 __STATIC_INLINE void FL_UART_EnableIT_FallingEdgeWakeup(UART_Type *UARTx)
860 {
861 SET_BIT(UARTx->IER, UART_IER_NEWUPIE_Msk);
862 }
863
864 /**
865 * @brief Disable UART Negedge Wakeup Interrupt
866 * @rmtoll IER NEWUPIE FL_UART_DisableIT_FallingEdgeWakeup
867 * @param UARTx UART instance
868 * @retval None
869 */
FL_UART_DisableIT_FallingEdgeWakeup(UART_Type * UARTx)870 __STATIC_INLINE void FL_UART_DisableIT_FallingEdgeWakeup(UART_Type *UARTx)
871 {
872 CLEAR_BIT(UARTx->IER, UART_IER_NEWUPIE_Msk);
873 }
874
875 /**
876 * @brief Get UART Negedge Wakeup Interrupt Enable Status
877 * @rmtoll IER NEWUPIE FL_UART_IsEnabledIT_FallingEdgeWakeup
878 * @param UARTx UART instance
879 * @retval State of bit (1 or 0).
880 */
FL_UART_IsEnabledIT_FallingEdgeWakeup(UART_Type * UARTx)881 __STATIC_INLINE uint32_t FL_UART_IsEnabledIT_FallingEdgeWakeup(UART_Type *UARTx)
882 {
883 return (uint32_t)(READ_BIT(UARTx->IER, UART_IER_NEWUPIE_Msk) == UART_IER_NEWUPIE_Msk);
884 }
885
886 /**
887 * @brief Enable UART Transmit Buffer Empty Interrupt
888 * @rmtoll IER TXBEIE FL_UART_EnableIT_TXBuffEmpty
889 * @param UARTx UART instance
890 * @retval None
891 */
FL_UART_EnableIT_TXBuffEmpty(UART_Type * UARTx)892 __STATIC_INLINE void FL_UART_EnableIT_TXBuffEmpty(UART_Type *UARTx)
893 {
894 SET_BIT(UARTx->IER, UART_IER_TXBEIE_Msk);
895 }
896
897 /**
898 * @brief Disable UART Transmit Buffer Empty Interrupt
899 * @rmtoll IER TXBEIE FL_UART_DisableIT_TXBuffEmpty
900 * @param UARTx UART instance
901 * @retval None
902 */
FL_UART_DisableIT_TXBuffEmpty(UART_Type * UARTx)903 __STATIC_INLINE void FL_UART_DisableIT_TXBuffEmpty(UART_Type *UARTx)
904 {
905 CLEAR_BIT(UARTx->IER, UART_IER_TXBEIE_Msk);
906 }
907
908 /**
909 * @brief Get UART Transmit Buffer Empty Interrupt Enable Status
910 * @rmtoll IER TXBEIE FL_UART_IsEnabledIT_TXBuffEmpty
911 * @param UARTx UART instance
912 * @retval State of bit (1 or 0).
913 */
FL_UART_IsEnabledIT_TXBuffEmpty(UART_Type * UARTx)914 __STATIC_INLINE uint32_t FL_UART_IsEnabledIT_TXBuffEmpty(UART_Type *UARTx)
915 {
916 return (uint32_t)(READ_BIT(UARTx->IER, UART_IER_TXBEIE_Msk) == UART_IER_TXBEIE_Msk);
917 }
918
919 /**
920 * @brief Enable UART Transmit Shift Register Empty Interrupt
921 * @rmtoll IER TXSEIE FL_UART_EnableIT_TXShiftBuffEmpty
922 * @param UARTx UART instance
923 * @retval None
924 */
FL_UART_EnableIT_TXShiftBuffEmpty(UART_Type * UARTx)925 __STATIC_INLINE void FL_UART_EnableIT_TXShiftBuffEmpty(UART_Type *UARTx)
926 {
927 SET_BIT(UARTx->IER, UART_IER_TXSEIE_Msk);
928 }
929
930 /**
931 * @brief Disable UART Transmit Shift Register Empty Interrupt
932 * @rmtoll IER TXSEIE FL_UART_DisableIT_TXShiftBuffEmpty
933 * @param UARTx UART instance
934 * @retval None
935 */
FL_UART_DisableIT_TXShiftBuffEmpty(UART_Type * UARTx)936 __STATIC_INLINE void FL_UART_DisableIT_TXShiftBuffEmpty(UART_Type *UARTx)
937 {
938 CLEAR_BIT(UARTx->IER, UART_IER_TXSEIE_Msk);
939 }
940
941 /**
942 * @brief Get UART Transmit Shift Register Empty Interrupt Enable Status
943 * @rmtoll IER TXSEIE FL_UART_IsEnabledIT_TXShiftBuffEmpty
944 * @param UARTx UART instance
945 * @retval State of bit (1 or 0).
946 */
FL_UART_IsEnabledIT_TXShiftBuffEmpty(UART_Type * UARTx)947 __STATIC_INLINE uint32_t FL_UART_IsEnabledIT_TXShiftBuffEmpty(UART_Type *UARTx)
948 {
949 return (uint32_t)(READ_BIT(UARTx->IER, UART_IER_TXSEIE_Msk) == UART_IER_TXSEIE_Msk);
950 }
951
952 /**
953 * @brief Get UART Parity Error Flag
954 * @rmtoll ISR PERR FL_UART_IsActiveFlag_ParityError
955 * @param UARTx UART instance
956 * @retval State of bit (1 or 0).
957 */
FL_UART_IsActiveFlag_ParityError(UART_Type * UARTx)958 __STATIC_INLINE uint32_t FL_UART_IsActiveFlag_ParityError(UART_Type *UARTx)
959 {
960 return (uint32_t)(READ_BIT(UARTx->ISR, UART_ISR_PERR_Msk) == (UART_ISR_PERR_Msk));
961 }
962
963 /**
964 * @brief Clear UART Parity Error Flag
965 * @rmtoll ISR PERR FL_UART_ClearFlag_ParityError
966 * @param UARTx UART instance
967 * @retval None
968 */
FL_UART_ClearFlag_ParityError(UART_Type * UARTx)969 __STATIC_INLINE void FL_UART_ClearFlag_ParityError(UART_Type *UARTx)
970 {
971 WRITE_REG(UARTx->ISR, UART_ISR_PERR_Msk);
972 }
973
974 /**
975 * @brief Get UART Frame Error Flag
976 * @rmtoll ISR FERR FL_UART_IsActiveFlag_FrameError
977 * @param UARTx UART instance
978 * @retval State of bit (1 or 0).
979 */
FL_UART_IsActiveFlag_FrameError(UART_Type * UARTx)980 __STATIC_INLINE uint32_t FL_UART_IsActiveFlag_FrameError(UART_Type *UARTx)
981 {
982 return (uint32_t)(READ_BIT(UARTx->ISR, UART_ISR_FERR_Msk) == (UART_ISR_FERR_Msk));
983 }
984
985 /**
986 * @brief Clear UART Frame Error Flag
987 * @rmtoll ISR FERR FL_UART_ClearFlag_FrameError
988 * @param UARTx UART instance
989 * @retval None
990 */
FL_UART_ClearFlag_FrameError(UART_Type * UARTx)991 __STATIC_INLINE void FL_UART_ClearFlag_FrameError(UART_Type *UARTx)
992 {
993 WRITE_REG(UARTx->ISR, UART_ISR_FERR_Msk);
994 }
995
996 /**
997 * @brief Get UART RX buffer Overflow Error Flag
998 * @rmtoll ISR OERR FL_UART_IsActiveFlag_RXBuffOverflowError
999 * @param UARTx UART instance
1000 * @retval State of bit (1 or 0).
1001 */
FL_UART_IsActiveFlag_RXBuffOverflowError(UART_Type * UARTx)1002 __STATIC_INLINE uint32_t FL_UART_IsActiveFlag_RXBuffOverflowError(UART_Type *UARTx)
1003 {
1004 return (uint32_t)(READ_BIT(UARTx->ISR, UART_ISR_OERR_Msk) == (UART_ISR_OERR_Msk));
1005 }
1006
1007 /**
1008 * @brief Clear UART RX buffer Overflow Error Flag
1009 * @rmtoll ISR OERR FL_UART_ClearFlag_RXBuffOverflowError
1010 * @param UARTx UART instance
1011 * @retval None
1012 */
FL_UART_ClearFlag_RXBuffOverflowError(UART_Type * UARTx)1013 __STATIC_INLINE void FL_UART_ClearFlag_RXBuffOverflowError(UART_Type *UARTx)
1014 {
1015 WRITE_REG(UARTx->ISR, UART_ISR_OERR_Msk);
1016 }
1017
1018 /**
1019 * @brief Get UART Receive Time-Out Flag
1020 * @rmtoll ISR RXTO FL_UART_IsActiveFlag_RXBuffTimeout
1021 * @param UARTx UART instance
1022 * @retval State of bit (1 or 0).
1023 */
FL_UART_IsActiveFlag_RXBuffTimeout(UART_Type * UARTx)1024 __STATIC_INLINE uint32_t FL_UART_IsActiveFlag_RXBuffTimeout(UART_Type *UARTx)
1025 {
1026 return (uint32_t)(READ_BIT(UARTx->ISR, UART_ISR_RXTO_Msk) == (UART_ISR_RXTO_Msk));
1027 }
1028
1029 /**
1030 * @brief Clear UART Receive Time-Out Flag
1031 * @rmtoll ISR RXTO FL_UART_ClearFlag_RXBuffTimeout
1032 * @param UARTx UART instance
1033 * @retval None
1034 */
FL_UART_ClearFlag_RXBuffTimeout(UART_Type * UARTx)1035 __STATIC_INLINE void FL_UART_ClearFlag_RXBuffTimeout(UART_Type *UARTx)
1036 {
1037 WRITE_REG(UARTx->ISR, UART_ISR_RXTO_Msk);
1038 }
1039
1040 /**
1041 * @brief Get UART Receive Buffer Full Flag
1042 * @rmtoll ISR RXBF FL_UART_IsActiveFlag_RXBuffFull
1043 * @param UARTx UART instance
1044 * @retval State of bit (1 or 0).
1045 */
FL_UART_IsActiveFlag_RXBuffFull(UART_Type * UARTx)1046 __STATIC_INLINE uint32_t FL_UART_IsActiveFlag_RXBuffFull(UART_Type *UARTx)
1047 {
1048 return (uint32_t)(READ_BIT(UARTx->ISR, UART_ISR_RXBF_Msk) == (UART_ISR_RXBF_Msk));
1049 }
1050
1051 /**
1052 * @brief Clear UART Receive Buffer Full Flag
1053 * @rmtoll ISR RXBF FL_UART_ClearFlag_RXBuffFull
1054 * @param UARTx UART instance
1055 * @retval None
1056 */
FL_UART_ClearFlag_RXBuffFull(UART_Type * UARTx)1057 __STATIC_INLINE void FL_UART_ClearFlag_RXBuffFull(UART_Type *UARTx)
1058 {
1059 WRITE_REG(UARTx->ISR, UART_ISR_RXBF_Msk);
1060 }
1061
1062 /**
1063 * @brief Get UART Negedge Wakeup Flag
1064 * @rmtoll ISR NEWKF FL_UART_IsActiveFlag_FallingEdgeWakeup
1065 * @param UARTx UART instance
1066 * @retval State of bit (1 or 0).
1067 */
FL_UART_IsActiveFlag_FallingEdgeWakeup(UART_Type * UARTx)1068 __STATIC_INLINE uint32_t FL_UART_IsActiveFlag_FallingEdgeWakeup(UART_Type *UARTx)
1069 {
1070 return (uint32_t)(READ_BIT(UARTx->ISR, UART_ISR_NEWKF_Msk) == (UART_ISR_NEWKF_Msk));
1071 }
1072
1073 /**
1074 * @brief Clear UART Negedge Wakeup Flag
1075 * @rmtoll ISR NEWKF FL_UART_ClearFlag_FallingEdgeWakeup
1076 * @param UARTx UART instance
1077 * @retval None
1078 */
FL_UART_ClearFlag_FallingEdgeWakeup(UART_Type * UARTx)1079 __STATIC_INLINE void FL_UART_ClearFlag_FallingEdgeWakeup(UART_Type *UARTx)
1080 {
1081 WRITE_REG(UARTx->ISR, UART_ISR_NEWKF_Msk);
1082 }
1083
1084 /**
1085 * @brief Get UART Transmit Buffer Empty Flag
1086 * @rmtoll ISR TXBE FL_UART_IsActiveFlag_TXBuffEmpty
1087 * @param UARTx UART instance
1088 * @retval State of bit (1 or 0).
1089 */
FL_UART_IsActiveFlag_TXBuffEmpty(UART_Type * UARTx)1090 __STATIC_INLINE uint32_t FL_UART_IsActiveFlag_TXBuffEmpty(UART_Type *UARTx)
1091 {
1092 return (uint32_t)(READ_BIT(UARTx->ISR, UART_ISR_TXBE_Msk) == (UART_ISR_TXBE_Msk));
1093 }
1094
1095 /**
1096 * @brief Clear UART Transmit Buffer Empty Flag
1097 * @rmtoll ISR TXBE FL_UART_ClearFlag_TXBuffEmpty
1098 * @param UARTx UART instance
1099 * @retval None
1100 */
FL_UART_ClearFlag_TXBuffEmpty(UART_Type * UARTx)1101 __STATIC_INLINE void FL_UART_ClearFlag_TXBuffEmpty(UART_Type *UARTx)
1102 {
1103 WRITE_REG(UARTx->ISR, UART_ISR_TXBE_Msk);
1104 }
1105
1106 /**
1107 * @brief Get UART Transmit Shift register Empty Flag
1108 * @rmtoll ISR TXSE FL_UART_IsActiveFlag_TXShiftBuffEmpty
1109 * @param UARTx UART instance
1110 * @retval State of bit (1 or 0).
1111 */
FL_UART_IsActiveFlag_TXShiftBuffEmpty(UART_Type * UARTx)1112 __STATIC_INLINE uint32_t FL_UART_IsActiveFlag_TXShiftBuffEmpty(UART_Type *UARTx)
1113 {
1114 return (uint32_t)(READ_BIT(UARTx->ISR, UART_ISR_TXSE_Msk) == (UART_ISR_TXSE_Msk));
1115 }
1116
1117 /**
1118 * @brief Clear UART Transmit Shift register Empty Flag
1119 * @rmtoll ISR TXSE FL_UART_ClearFlag_TXShiftBuffEmpty
1120 * @param UARTx UART instance
1121 * @retval None
1122 */
FL_UART_ClearFlag_TXShiftBuffEmpty(UART_Type * UARTx)1123 __STATIC_INLINE void FL_UART_ClearFlag_TXShiftBuffEmpty(UART_Type *UARTx)
1124 {
1125 WRITE_REG(UARTx->ISR, UART_ISR_TXSE_Msk);
1126 }
1127
1128 /**
1129 * @brief Set UART Transmit Delay Length
1130 * @rmtoll TODR TXDLY_LEN FL_UART_WriteTXDelay
1131 * @param UARTx UART instance
1132 * @param time
1133 * @retval None
1134 */
FL_UART_WriteTXDelay(UART_Type * UARTx,uint32_t time)1135 __STATIC_INLINE void FL_UART_WriteTXDelay(UART_Type *UARTx, uint32_t time)
1136 {
1137 MODIFY_REG(UARTx->TODR, (0xffU << 8U), (time << 8U));
1138 }
1139
1140 /**
1141 * @brief Get UART Transmit Delay Length
1142 * @rmtoll TODR TXDLY_LEN FL_UART_ReadTXDelay
1143 * @param UARTx UART instance
1144 * @retval
1145 */
FL_UART_ReadTXDelay(UART_Type * UARTx)1146 __STATIC_INLINE uint32_t FL_UART_ReadTXDelay(UART_Type *UARTx)
1147 {
1148 return (uint32_t)(READ_BIT(UARTx->TODR, (0xffU << 8U)) >> 8U);
1149 }
1150
1151 /**
1152 * @brief Set UART Receive Time-Out Length
1153 * @rmtoll TODR RXTO_LEN FL_UART_WriteRXTimeout
1154 * @param UARTx UART instance
1155 * @param time
1156 * @retval None
1157 */
FL_UART_WriteRXTimeout(UART_Type * UARTx,uint32_t time)1158 __STATIC_INLINE void FL_UART_WriteRXTimeout(UART_Type *UARTx, uint32_t time)
1159 {
1160 MODIFY_REG(UARTx->TODR, (0xffU << 0U), (time << 0U));
1161 }
1162
1163 /**
1164 * @brief Get UART Receive Time-Out Length
1165 * @rmtoll TODR RXTO_LEN FL_UART_ReadRXTimeout
1166 * @param UARTx UART instance
1167 * @retval
1168 */
FL_UART_ReadRXTimeout(UART_Type * UARTx)1169 __STATIC_INLINE uint32_t FL_UART_ReadRXTimeout(UART_Type *UARTx)
1170 {
1171 return (uint32_t)(READ_BIT(UARTx->TODR, (0xffU << 0U)) >> 0U);
1172 }
1173
1174 /**
1175 * @brief UART Receive 1 byte of data
1176 * @rmtoll RXBUF FL_UART_ReadRXBuff
1177 * @param UARTx UART instance
1178 * @retval
1179 */
FL_UART_ReadRXBuff(UART_Type * UARTx)1180 __STATIC_INLINE uint32_t FL_UART_ReadRXBuff(UART_Type *UARTx)
1181 {
1182 return (uint32_t)(READ_BIT(UARTx->RXBUF, 0x1ffU));
1183 }
1184
1185 /**
1186 * @brief UART Transmit 1 byte of data
1187 * @rmtoll TXBUF FL_UART_WriteTXBuff
1188 * @param UARTx UART instance
1189 * @param data
1190 * @retval None
1191 */
FL_UART_WriteTXBuff(UART_Type * UARTx,uint32_t data)1192 __STATIC_INLINE void FL_UART_WriteTXBuff(UART_Type *UARTx, uint32_t data)
1193 {
1194 MODIFY_REG(UARTx->TXBUF, 0x1ffU, data);
1195 }
1196
1197 /**
1198 * @brief Set UART BaudRate
1199 * @rmtoll BGR FL_UART_WriteBaudRate
1200 * @param UARTx UART instance
1201 * @param baudRate
1202 * @retval None
1203 */
FL_UART_WriteBaudRate(UART_Type * UARTx,uint32_t baudRate)1204 __STATIC_INLINE void FL_UART_WriteBaudRate(UART_Type *UARTx, uint32_t baudRate)
1205 {
1206 MODIFY_REG(UARTx->BGR, (0xffffU << 0U), (baudRate << 0U));
1207 }
1208
1209 /**
1210 * @brief Get UART BaudRate
1211 * @rmtoll BGR FL_UART_ReadBaudRate
1212 * @param UARTx UART instance
1213 * @retval
1214 */
FL_UART_ReadBaudRate(UART_Type * UARTx)1215 __STATIC_INLINE uint32_t FL_UART_ReadBaudRate(UART_Type *UARTx)
1216 {
1217 return (uint32_t)(READ_BIT(UARTx->BGR, (0xffffU << 0U)) >> 0U);
1218 }
1219
1220 /**
1221 * @}
1222 */
1223
1224 /** @defgroup UART_FL_EF_Init Initialization and de-initialization functions
1225 * @{
1226 */
1227 FL_ErrorStatus FL_UART_DeInit(UART_Type *UARTx);
1228 FL_ErrorStatus FL_UART_Init(UART_Type *UARTx, FL_UART_InitTypeDef *initStruct);
1229 FL_ErrorStatus FL_UART_InfraRed_Init(UART_Type *UARTx, FL_UART_InfraRed_InitTypeDef *initStruct);
1230 void FL_UART_InfraRed_StructInit(FL_UART_InfraRed_InitTypeDef *initStruct);
1231 void FL_UART_StructInit(FL_UART_InitTypeDef *initStruct);
1232
1233
1234 /**
1235 * @}
1236 */
1237
1238 /**
1239 * @}
1240 */
1241
1242 /**
1243 * @}
1244 */
1245
1246 #ifdef __cplusplus
1247 }
1248 #endif
1249
1250 #endif /* __FM33LC0XX_FL_UART_H*/
1251
1252 /*************************Py_Code_Generator Version: 0.1-0.11-0.2 @ 2020-09-27*************************/
1253 /********************** (C) COPYRIGHT Fudan Microelectronics **** END OF FILE ***********************/
1254