1 /**************************************************************************//**
2 * @file uart.h
3 * @version V3.00
4 * @brief M2354 series UART Interface Controller (UART) driver header file
5 *
6 * @copyright SPDX-License-Identifier: Apache-2.0
7 * @copyright Copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
8 *****************************************************************************/
9 #ifndef __UART_H__
10 #define __UART_H__
11
12
13 #ifdef __cplusplus
14 extern "C"
15 {
16 #endif
17
18
19 /** @addtogroup Standard_Driver Standard Driver
20 @{
21 */
22
23 /** @addtogroup UART_Driver UART Driver
24 @{
25 */
26
27 /** @addtogroup UART_EXPORTED_CONSTANTS UART Exported Constants
28 @{
29 */
30
31 /*---------------------------------------------------------------------------------------------------------*/
32 /* UART FIFO size constants definitions */
33 /*---------------------------------------------------------------------------------------------------------*/
34 #define UART0_FIFO_SIZE 16UL /*!< UART0 supports separated receive/transmit 16/16 bytes entry FIFO */
35 #define UART1_FIFO_SIZE 16UL /*!< UART1 supports separated receive/transmit 16/16 bytes entry FIFO */
36 #define UART2_FIFO_SIZE 16UL /*!< UART2 supports separated receive/transmit 16/16 bytes entry FIFO */
37 #define UART3_FIFO_SIZE 16UL /*!< UART3 supports separated receive/transmit 16/16 bytes entry FIFO */
38 #define UART4_FIFO_SIZE 16UL /*!< UART4 supports separated receive/transmit 16/16 bytes entry FIFO */
39 #define UART5_FIFO_SIZE 16UL /*!< UART5 supports separated receive/transmit 16/16 bytes entry FIFO */
40
41
42 /*---------------------------------------------------------------------------------------------------------*/
43 /* UART_FIFO constants definitions */
44 /*---------------------------------------------------------------------------------------------------------*/
45 #define UART_FIFO_RFITL_1BYTE (0x0UL << UART_FIFO_RFITL_Pos) /*!< UART_FIFO setting to set RX FIFO Trigger Level to 1 byte */
46 #define UART_FIFO_RFITL_4BYTES (0x1UL << UART_FIFO_RFITL_Pos) /*!< UART_FIFO setting to set RX FIFO Trigger Level to 4 bytes */
47 #define UART_FIFO_RFITL_8BYTES (0x2UL << UART_FIFO_RFITL_Pos) /*!< UART_FIFO setting to set RX FIFO Trigger Level to 8 bytes */
48 #define UART_FIFO_RFITL_14BYTES (0x3UL << UART_FIFO_RFITL_Pos) /*!< UART_FIFO setting to set RX FIFO Trigger Level to 14 bytes */
49
50 #define UART_FIFO_RTSTRGLV_1BYTE (0x0UL << UART_FIFO_RTSTRGLV_Pos) /*!< UART_FIFO setting to set RTS Trigger Level to 1 byte */
51 #define UART_FIFO_RTSTRGLV_4BYTES (0x1UL << UART_FIFO_RTSTRGLV_Pos) /*!< UART_FIFO setting to set RTS Trigger Level to 4 bytes */
52 #define UART_FIFO_RTSTRGLV_8BYTES (0x2UL << UART_FIFO_RTSTRGLV_Pos) /*!< UART_FIFO setting to set RTS Trigger Level to 8 bytes */
53 #define UART_FIFO_RTSTRGLV_14BYTES (0x3UL << UART_FIFO_RTSTRGLV_Pos) /*!< UART_FIFO setting to set RTS Trigger Level to 14 bytes */
54
55 /*---------------------------------------------------------------------------------------------------------*/
56 /* UART_LINE constants definitions */
57 /*---------------------------------------------------------------------------------------------------------*/
58 #define UART_WORD_LEN_5 (0UL) /*!< UART_LINE setting to set UART word length to 5 bits */
59 #define UART_WORD_LEN_6 (1UL) /*!< UART_LINE setting to set UART word length to 6 bits */
60 #define UART_WORD_LEN_7 (2UL) /*!< UART_LINE setting to set UART word length to 7 bits */
61 #define UART_WORD_LEN_8 (3UL) /*!< UART_LINE setting to set UART word length to 8 bits */
62
63 #define UART_PARITY_NONE (0x0UL << UART_LINE_PBE_Pos) /*!< UART_LINE setting to set UART as no parity */
64 #define UART_PARITY_ODD (0x1UL << UART_LINE_PBE_Pos) /*!< UART_LINE setting to set UART as odd parity */
65 #define UART_PARITY_EVEN (0x3UL << UART_LINE_PBE_Pos) /*!< UART_LINE setting to set UART as even parity */
66 #define UART_PARITY_MARK (0x5UL << UART_LINE_PBE_Pos) /*!< UART_LINE setting to keep parity bit as '1' */
67 #define UART_PARITY_SPACE (0x7UL << UART_LINE_PBE_Pos) /*!< UART_LINE setting to keep parity bit as '0' */
68
69 #define UART_STOP_BIT_1 (0x0UL << UART_LINE_NSB_Pos) /*!< UART_LINE setting for one stop bit */
70 #define UART_STOP_BIT_1_5 (0x1UL << UART_LINE_NSB_Pos) /*!< UART_LINE setting for 1.5 stop bit when 5-bit word length */
71 #define UART_STOP_BIT_2 (0x1UL << UART_LINE_NSB_Pos) /*!< UART_LINE setting for two stop bit when 6, 7, 8-bit word length */
72
73
74 /*---------------------------------------------------------------------------------------------------------*/
75 /* UART RTS ACTIVE LEVEL constants definitions */
76 /*---------------------------------------------------------------------------------------------------------*/
77 #define UART_RTS_IS_LOW_LEV_ACTIVE (0x1UL << UART_MODEM_RTSACTLV_Pos) /*!< Set RTS is Low Level Active */
78 #define UART_RTS_IS_HIGH_LEV_ACTIVE (0x0UL << UART_MODEM_RTSACTLV_Pos) /*!< Set RTS is High Level Active */
79
80
81 /*---------------------------------------------------------------------------------------------------------*/
82 /* UART_IRDA constants definitions */
83 /*---------------------------------------------------------------------------------------------------------*/
84 #define UART_IRDA_TXEN (0x1UL << UART_IRDA_TXEN_Pos) /*!< Set IrDA function Tx mode */
85 #define UART_IRDA_RXEN (0x0UL << UART_IRDA_TXEN_Pos) /*!< Set IrDA function Rx mode */
86
87
88 /*---------------------------------------------------------------------------------------------------------*/
89 /* UART_FUNCSEL constants definitions */
90 /*---------------------------------------------------------------------------------------------------------*/
91 #define UART_FUNCSEL_UART (0x0UL << UART_FUNCSEL_FUNCSEL_Pos) /*!< UART_FUNCSEL setting to set UART Function (Default) */
92 #define UART_FUNCSEL_LIN (0x1UL << UART_FUNCSEL_FUNCSEL_Pos) /*!< UART_FUNCSEL setting to set LIN Function */
93 #define UART_FUNCSEL_IrDA (0x2UL << UART_FUNCSEL_FUNCSEL_Pos) /*!< UART_FUNCSEL setting to set IrDA Function */
94 #define UART_FUNCSEL_RS485 (0x3UL << UART_FUNCSEL_FUNCSEL_Pos) /*!< UART_FUNCSEL setting to set RS485 Function */
95 #define UART_FUNCSEL_SINGLE_WIRE (0x4ul << UART_FUNCSEL_FUNCSEL_Pos) /*!< UART_FUNCSEL setting to set Single Wire Function */
96
97
98 /*---------------------------------------------------------------------------------------------------------*/
99 /* UART_LINCTL constants definitions */
100 /*---------------------------------------------------------------------------------------------------------*/
101 #define UART_LINCTL_BRKFL(x) (((x)-1UL) << UART_LINCTL_BRKFL_Pos) /*!< UART_LINCTL setting to set LIN Break Field Length, x = 10 ~ 15, default value is 12 */
102 #define UART_LINCTL_BSL(x) (((x)-1UL) << UART_LINCTL_BSL_Pos) /*!< UART_LINCTL setting to set LIN Break/Sync Delimiter Length, x = 1 ~ 4 */
103 #define UART_LINCTL_HSEL_BREAK (0x0UL << UART_LINCTL_HSEL_Pos) /*!< UART_LINCTL setting to set LIN Header Select to break field */
104 #define UART_LINCTL_HSEL_BREAK_SYNC (0x1UL << UART_LINCTL_HSEL_Pos) /*!< UART_LINCTL setting to set LIN Header Select to break field and sync field */
105 #define UART_LINCTL_HSEL_BREAK_SYNC_ID (0x2UL << UART_LINCTL_HSEL_Pos) /*!< UART_LINCTL setting to set LIN Header Select to break field, sync field and ID field*/
106 #define UART_LINCTL_PID(x) ((x) << UART_LINCTL_PID_Pos) /*!< UART_LINCTL setting to set LIN PID value */
107
108
109 /*---------------------------------------------------------------------------------------------------------*/
110 /* UART BAUDRATE MODE constants definitions */
111 /*---------------------------------------------------------------------------------------------------------*/
112 #define UART_BAUD_MODE0 (0UL) /*!< Set UART Baudrate Mode is Mode0 */
113 #define UART_BAUD_MODE2 (UART_BAUD_BAUDM1_Msk | UART_BAUD_BAUDM0_Msk) /*!< Set UART Baudrate Mode is Mode2 */
114
115
116
117 /**@}*/ /* end of group UART_EXPORTED_CONSTANTS */
118
119
120 /** @addtogroup UART_EXPORTED_FUNCTIONS UART Exported Functions
121 @{
122 */
123
124
125 /**
126 * @brief Calculate UART baudrate mode0 divider
127 *
128 * @param[in] u32SrcFreq UART clock frequency
129 * @param[in] u32BaudRate Baudrate of UART module
130 *
131 * @return UART baudrate mode0 divider
132 *
133 * @details This macro calculate UART baudrate mode0 divider.
134 */
135 #define UART_BAUD_MODE0_DIVIDER(u32SrcFreq, u32BaudRate) ((((u32SrcFreq) + ((u32BaudRate)*8ul)) / (u32BaudRate) >> 4ul)-2ul)
136
137
138 /**
139 * @brief Calculate UART baudrate mode2 divider
140 *
141 * @param[in] u32SrcFreq UART clock frequency
142 * @param[in] u32BaudRate Baudrate of UART module
143 *
144 * @return UART baudrate mode2 divider
145 *
146 * @details This macro calculate UART baudrate mode2 divider.
147 */
148 #define UART_BAUD_MODE2_DIVIDER(u32SrcFreq, u32BaudRate) ((((u32SrcFreq) + ((u32BaudRate)/2ul)) / (u32BaudRate))-2ul)
149
150
151 /**
152 * @brief Write UART data
153 *
154 * @param[in] uart The pointer of the specified UART module
155 * @param[in] u8Data Data byte to transmit.
156 *
157 * @return None
158 *
159 * @details This macro write Data to Tx data register.
160 */
161 #define UART_WRITE(uart, u8Data) ((uart)->DAT = (u8Data))
162
163
164 /**
165 * @brief Read UART data
166 *
167 * @param[in] uart The pointer of the specified UART module
168 *
169 * @return The oldest data byte in RX FIFO.
170 *
171 * @details This macro read Rx data register.
172 */
173 #define UART_READ(uart) ((uart)->DAT)
174
175
176 /**
177 * @brief Get Tx empty
178 *
179 * @param[in] uart The pointer of the specified UART module
180 *
181 * @retval 0 Tx FIFO is not empty
182 * @retval >=1 Tx FIFO is empty
183 *
184 * @details This macro get Transmitter FIFO empty register value.
185 */
186 #define UART_GET_TX_EMPTY(uart) ((uart)->FIFOSTS & UART_FIFOSTS_TXEMPTY_Msk)
187
188
189 /**
190 * @brief Get Rx empty
191 *
192 * @param[in] uart The pointer of the specified UART module
193 *
194 * @retval 0 Rx FIFO is not empty
195 * @retval >=1 Rx FIFO is empty
196 *
197 * @details This macro get Receiver FIFO empty register value.
198 */
199 #define UART_GET_RX_EMPTY(uart) ((uart)->FIFOSTS & UART_FIFOSTS_RXEMPTY_Msk)
200
201
202 /**
203 * @brief Check specified uart port transmission is over.
204 *
205 * @param[in] uart The pointer of the specified UART module
206 *
207 * @retval 0 Tx transmission is not over
208 * @retval 1 Tx transmission is over
209 *
210 * @details This macro return Transmitter Empty Flag register bit value.
211 * It indicates if specified uart port transmission is over nor not.
212 */
213 #define UART_IS_TX_EMPTY(uart) (((uart)->FIFOSTS & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos)
214
215
216 /**
217 * @brief Wait specified uart port transmission is over
218 *
219 * @param[in] uart The pointer of the specified UART module
220 *
221 * @return None
222 *
223 * @details This macro wait specified uart port transmission is over.
224 */
225 #define UART_WAIT_TX_EMPTY(uart) while(!((((uart)->FIFOSTS) & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos))
226
227
228 /**
229 * @brief Check RX is ready or not
230 *
231 * @param[in] uart The pointer of the specified UART module
232 *
233 * @retval 0 The number of bytes in the RX FIFO is less than the RFITL
234 * @retval 1 The number of bytes in the RX FIFO equals or larger than RFITL
235 *
236 * @details This macro check receive data available interrupt flag is set or not.
237 */
238 #define UART_IS_RX_READY(uart) (((uart)->INTSTS & UART_INTSTS_RDAIF_Msk)>>UART_INTSTS_RDAIF_Pos)
239
240
241 /**
242 * @brief Check TX FIFO is full or not
243 *
244 * @param[in] uart The pointer of the specified UART module
245 *
246 * @retval 1 TX FIFO is full
247 * @retval 0 TX FIFO is not full
248 *
249 * @details This macro check TX FIFO is full or not.
250 */
251 #define UART_IS_TX_FULL(uart) (((uart)->FIFOSTS & UART_FIFOSTS_TXFULL_Msk)>>UART_FIFOSTS_TXFULL_Pos)
252
253
254 /**
255 * @brief Check RX FIFO is full or not
256 *
257 * @param[in] uart The pointer of the specified UART module
258 *
259 * @retval 1 RX FIFO is full
260 * @retval 0 RX FIFO is not full
261 *
262 * @details This macro check RX FIFO is full or not.
263 */
264 #define UART_IS_RX_FULL(uart) (((uart)->FIFOSTS & UART_FIFOSTS_RXFULL_Msk)>>UART_FIFOSTS_RXFULL_Pos)
265
266
267 /**
268 * @brief Get Tx full register value
269 *
270 * @param[in] uart The pointer of the specified UART module
271 *
272 * @retval 0 Tx FIFO is not full.
273 * @retval >=1 Tx FIFO is full.
274 *
275 * @details This macro get Tx full register value.
276 */
277 #define UART_GET_TX_FULL(uart) ((uart)->FIFOSTS & UART_FIFOSTS_TXFULL_Msk)
278
279
280 /**
281 * @brief Get Rx full register value
282 *
283 * @param[in] uart The pointer of the specified UART module
284 *
285 * @retval 0 Rx FIFO is not full.
286 * @retval >=1 Rx FIFO is full.
287 *
288 * @details This macro get Rx full register value.
289 */
290 #define UART_GET_RX_FULL(uart) ((uart)->FIFOSTS & UART_FIFOSTS_RXFULL_Msk)
291
292 /**
293 * @brief Rx Idle Status register value
294 *
295 * @param[in] uart The pointer of the specified UART module
296 *
297 * @retval 0 Rx is busy.
298 * @retval 1 Rx is Idle(Default)
299 *
300 * @details This macro get Rx Idle Status register value.
301 * \hideinitializer
302 */
303 #define UART_RX_IDLE(uart) (((uart)->FIFOSTS & UART_FIFOSTS_RXIDLE_Msk )>> UART_FIFOSTS_RXIDLE_Pos)
304
305
306 /**
307 * @brief Enable specified UART interrupt
308 *
309 * @param[in] uart The pointer of the specified UART module
310 * @param[in] u32eIntSel Interrupt type select
311 * - \ref UART_INTEN_TXENDIEN_Msk : Transmitter empty interrupt
312 * - \ref UART_INTEN_ABRIEN_Msk : Auto baud rate interrupt
313 * - \ref UART_INTEN_LINIEN_Msk : Lin bus interrupt
314 * - \ref UART_INTEN_WKIEN_Msk : Wake-up interrupt
315 * - \ref UART_INTEN_BUFERRIEN_Msk : Buffer Error interrupt
316 * - \ref UART_INTEN_RXTOIEN_Msk : Rx time-out interrupt
317 * - \ref UART_INTEN_MODEMIEN_Msk : Modem interrupt
318 * - \ref UART_INTEN_RLSIEN_Msk : Rx Line status interrupt
319 * - \ref UART_INTEN_THREIEN_Msk : Tx empty interrupt
320 * - \ref UART_INTEN_RDAIEN_Msk : Rx ready interrupt
321 *
322 * @return None
323 *
324 * @details This macro enable specified UART interrupt.
325 */
326 #define UART_ENABLE_INT(uart, u32eIntSel) ((uart)->INTEN |= (u32eIntSel))
327
328
329 /**
330 * @brief Disable specified UART interrupt
331 *
332 * @param[in] uart The pointer of the specified UART module
333 * @param[in] u32eIntSel Interrupt type select
334 * - \ref UART_INTEN_TXENDIEN_Msk : Transmitter Empty Interrupt
335 * - \ref UART_INTEN_ABRIEN_Msk : Auto-baud Rate Interrupt
336 * - \ref UART_INTEN_LINIEN_Msk : Lin Bus interrupt
337 * - \ref UART_INTEN_WKIEN_Msk : Wake-up interrupt
338 * - \ref UART_INTEN_BUFERRIEN_Msk : Buffer Error interrupt
339 * - \ref UART_INTEN_RXTOIEN_Msk : Rx Time-out Interrupt
340 * - \ref UART_INTEN_MODEMIEN_Msk : MODEM Status Interrupt
341 * - \ref UART_INTEN_RLSIEN_Msk : Receive Line Status Interrupt
342 * - \ref UART_INTEN_THREIEN_Msk : Transmit Holding Register Empty Interrupt
343 * - \ref UART_INTEN_RDAIEN_Msk : Receive Data Available Interrupt
344 *
345 * @return None
346 *
347 * @details This macro enable specified UART interrupt.
348 */
349 #define UART_DISABLE_INT(uart, u32eIntSel) ((uart)->INTEN &= ~ (u32eIntSel))
350
351
352 /**
353 * @brief Get specified interrupt flag/status
354 *
355 * @param[in] uart The pointer of the specified UART module
356 * @param[in] u32eIntTypeFlag Interrupt Type Flag, should be
357 * - \ref UART_INTSTS_ABRINT_Msk : Auto-baud Rate Interrupt Indicator
358 * - \ref UART_INTSTS_HWBUFEINT_Msk : PDMA Mode Buffer Error Interrupt Indicator
359 * - \ref UART_INTSTS_HWTOINT_Msk : PDMA Mode Rx Time-out Interrupt Indicator
360 * - \ref UART_INTSTS_HWMODINT_Msk : PDMA Mode MODEM Status Interrupt Indicator
361 * - \ref UART_INTSTS_HWRLSINT_Msk : PDMA Mode Receive Line Status Interrupt Indicator
362 * - \ref UART_INTSTS_SWBEINT_Msk : Single-wire Bit Error Detect Interrupt Indicator
363 * - \ref UART_INTSTS_HWBUFEIF_Msk : PDMA Mode Buffer Error Interrupt Flag
364 * - \ref UART_INTSTS_HWTOIF_Msk : PDMA Mode Time-out Interrupt Flag
365 * - \ref UART_INTSTS_HWMODIF_Msk : PDMA Mode MODEM Status Interrupt Flag
366 * - \ref UART_INTSTS_HWRLSIF_Msk : PDMA Mode Receive Line Status Flag
367 * - \ref UART_INTSTS_SWBEIF_Msk : Single-wire Bit Error Detect Interrupt Flag
368 * - \ref UART_INTSTS_TXENDINT_Msk : Transmitter Empty Interrupt Indicator
369 * - \ref UART_INTSTS_LININT_Msk : LIN Bus Interrupt Indicator
370 * - \ref UART_INTSTS_WKINT_Msk : Wake-up Interrupt Indicator
371 * - \ref UART_INTSTS_BUFERRINT_Msk : Buffer Error Interrupt Indicator
372 * - \ref UART_INTSTS_RXTOINT_Msk : Rx Time-out Interrupt Indicator
373 * - \ref UART_INTSTS_MODEMINT_Msk : Modem Status Interrupt Indicator
374 * - \ref UART_INTSTS_RLSINT_Msk : Receive Line Status Interrupt Indicator
375 * - \ref UART_INTSTS_THREINT_Msk : Transmit Holding Register Empty Interrupt Indicator
376 * - \ref UART_INTSTS_RDAINT_Msk : Receive Data Available Interrupt Indicator
377 * - \ref UART_INTSTS_TXENDIF_Msk : Transmitter Empty Interrupt Flag
378 * - \ref UART_INTSTS_LINIF_Msk : LIN Bus Interrupt Flag
379 * - \ref UART_INTSTS_WKIF_Msk : Wake-up Interrupt Flag
380 * - \ref UART_INTSTS_BUFERRIF_Msk : Buffer Error Interrupt Flag
381 * - \ref UART_INTSTS_RXTOIF_Msk : Rx Time-out Interrupt Flag
382 * - \ref UART_INTSTS_MODEMIF_Msk : MODEM Status Interrupt Flag
383 * - \ref UART_INTSTS_RLSIF_Msk : Receive Line Status Interrupt Flag
384 * - \ref UART_INTSTS_THREIF_Msk : Transmit Holding Register Empty Interrupt Flag
385 * - \ref UART_INTSTS_RDAIF_Msk : Receive Data Available Interrupt Flag
386 *
387 * @retval 0 The specified interrupt is not happened.
388 * 1 The specified interrupt is happened.
389 *
390 * @details This macro get specified interrupt flag or interrupt indicator status.
391 */
392 #define UART_GET_INT_FLAG(uart,u32eIntTypeFlag) (((uart)->INTSTS & (u32eIntTypeFlag))?1:0)
393
394 /*---------------------------------------------------------------------------------------------------------*/
395 /* static inline functions */
396 /*---------------------------------------------------------------------------------------------------------*/
397 /* Declare these inline functions here to avoid MISRA C 2004 rule 8.1 error */
398 static __INLINE void UART_CLEAR_RTS(UART_T* uart);
399 static __INLINE void UART_SET_RTS(UART_T* uart);
400
401
402 /**
403 * @brief Set RTS pin to low
404 *
405 * @param[in] uart The pointer of the specified UART module
406 *
407 * @return None
408 *
409 * @details This macro set RTS pin to low.
410 */
UART_CLEAR_RTS(UART_T * uart)411 __STATIC_INLINE void UART_CLEAR_RTS(UART_T* uart)
412 {
413 uart->MODEM |= UART_MODEM_RTSACTLV_Msk;
414 uart->MODEM &= ~UART_MODEM_RTS_Msk;
415 }
416
417
418 /**
419 * @brief Set RTS pin to high
420 *
421 * @param[in] uart The pointer of the specified UART module
422 *
423 * @return None
424 *
425 * @details This macro set RTS pin to high.
426 */
UART_SET_RTS(UART_T * uart)427 __STATIC_INLINE void UART_SET_RTS(UART_T* uart)
428 {
429 uart->MODEM |= UART_MODEM_RTSACTLV_Msk | UART_MODEM_RTS_Msk;
430 }
431
432
433 /**
434 * @brief Clear RS-485 Address Byte Detection Flag
435 *
436 * @param[in] uart The pointer of the specified UART module
437 *
438 * @return None
439 *
440 * @details This macro clear RS-485 address byte detection flag.
441 */
442 #define UART_RS485_CLEAR_ADDR_FLAG(uart) ((uart)->FIFOSTS = UART_FIFOSTS_ADDRDETF_Msk)
443
444
445 /**
446 * @brief Get RS-485 Address Byte Detection Flag
447 *
448 * @param[in] uart The pointer of the specified UART module
449 *
450 * @retval 0 Receiver detects a data that is not an address bit.
451 * @retval 1 Receiver detects a data that is an address bit.
452 *
453 * @details This macro get RS-485 address byte detection flag.
454 */
455 #define UART_RS485_GET_ADDR_FLAG(uart) (((uart)->FIFOSTS & UART_FIFOSTS_ADDRDETF_Msk) >> UART_FIFOSTS_ADDRDETF_Pos)
456
457
458 /**
459 * @brief Enable specified UART PDMA function
460 *
461 * @param[in] uart The pointer of the specified UART module
462 * @param[in] u32FuncSel Combination of following functions
463 * - \ref UART_INTEN_TXPDMAEN_Msk
464 * - \ref UART_INTEN_RXPDMAEN_Msk
465 *
466 * @return None
467 *
468 * @details This macro enable specified UART PDMA function.
469 */
470 #define UART_PDMA_ENABLE(uart, u32FuncSel) ((uart)->INTEN |= (u32FuncSel))
471
472
473 /**
474 * @brief Disable specified UART PDMA function
475 *
476 * @param[in] uart The pointer of the specified UART module
477 * @param[in] u32FuncSel Combination of following functions
478 * - \ref UART_INTEN_TXPDMAEN_Msk
479 * - \ref UART_INTEN_RXPDMAEN_Msk
480 *
481 * @return None
482 *
483 * @details This macro disable specified UART PDMA function.
484 */
485 #define UART_PDMA_DISABLE(uart, u32FuncSel) ((uart)->INTEN &= ~(u32FuncSel))
486
487
488 void UART_ClearIntFlag(UART_T* uart, uint32_t u32InterruptFlag);
489 void UART_Close(UART_T* uart);
490 void UART_DisableFlowCtrl(UART_T* uart);
491 void UART_DisableInt(UART_T* uart, uint32_t u32InterruptFlag);
492 void UART_EnableFlowCtrl(UART_T* uart);
493 void UART_EnableInt(UART_T* uart, uint32_t u32InterruptFlag);
494 void UART_Open(UART_T* uart, uint32_t u32baudrate);
495 uint32_t UART_Read(UART_T* uart, uint8_t pu8RxBuf[], uint32_t u32ReadBytes);
496 void UART_SetLineConfig(UART_T* uart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t u32stop_bits);
497 void UART_SetTimeoutCnt(UART_T* uart, uint32_t u32TOC);
498 void UART_SelectIrDAMode(UART_T* uart, uint32_t u32Buadrate, uint32_t u32Direction);
499 void UART_SelectRS485Mode(UART_T* uart, uint32_t u32Mode, uint32_t u32Addr);
500 void UART_SelectLINMode(UART_T* uart, uint32_t u32Mode, uint32_t u32BreakLength);
501 uint32_t UART_Write(UART_T* uart, uint8_t pu8TxBuf[], uint32_t u32WriteBytes);
502 void UART_SelectSingleWireMode(UART_T *uart);
503
504
505 /**@}*/ /* end of group UART_EXPORTED_FUNCTIONS */
506
507 /**@}*/ /* end of group UART_Driver */
508
509 /**@}*/ /* end of group Standard_Driver */
510
511 #ifdef __cplusplus
512 }
513 #endif
514
515 #endif /* __UART_H__ */
516