1 /**************************************************************************//**
2  * @file     UART.h
3  * @version  V3.00
4  * @brief    M2351 series UART Interface Controller (UART) driver header file
5  *
6  * @copyright SPDX-License-Identifier: Apache-2.0
7  * @copyright Copyright (C) 2016-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 
96 
97 /*---------------------------------------------------------------------------------------------------------*/
98 /* UART_LINCTL constants definitions                                                                       */
99 /*---------------------------------------------------------------------------------------------------------*/
100 #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 */
101 #define UART_LINCTL_BSL(x)      (((x)-1UL) << UART_LINCTL_BSL_Pos)    /*!< UART_LINCTL setting to set LIN Break/Sync Delimiter Length, x = 1 ~ 4 */
102 #define UART_LINCTL_HSEL_BREAK             (0x0UL << UART_LINCTL_HSEL_Pos)    /*!< UART_LINCTL setting to set LIN Header Select to break field */
103 #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 */
104 #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*/
105 #define UART_LINCTL_PID(x)      ((x) << UART_LINCTL_PID_Pos)       /*!< UART_LINCTL setting to set LIN PID value */
106 
107 
108 /*---------------------------------------------------------------------------------------------------------*/
109 /* UART BAUDRATE MODE constants definitions                                                                */
110 /*---------------------------------------------------------------------------------------------------------*/
111 #define UART_BAUD_MODE0     (0UL) /*!< Set UART Baudrate Mode is Mode0 */
112 #define UART_BAUD_MODE2     (UART_BAUD_BAUDM1_Msk | UART_BAUD_BAUDM0_Msk) /*!< Set UART Baudrate Mode is Mode2 */
113 
114 
115 
116 /*@}*/ /* end of group UART_EXPORTED_CONSTANTS */
117 
118 
119 /** @addtogroup UART_EXPORTED_FUNCTIONS UART Exported Functions
120   @{
121 */
122 
123 
124 /**
125  *    @brief        Calculate UART baudrate mode0 divider
126  *
127  *    @param[in]    u32SrcFreq      UART clock frequency
128  *    @param[in]    u32BaudRate     Baudrate of UART module
129  *
130  *    @return       UART baudrate mode0 divider
131  *
132  *    @details      This macro calculate UART baudrate mode0 divider.
133  */
134 #define UART_BAUD_MODE0_DIVIDER(u32SrcFreq, u32BaudRate)    ((((u32SrcFreq) + ((u32BaudRate)*8ul)) / (u32BaudRate) >> 4ul)-2ul)
135 
136 
137 /**
138  *    @brief        Calculate UART baudrate mode2 divider
139  *
140  *    @param[in]    u32SrcFreq      UART clock frequency
141  *    @param[in]    u32BaudRate     Baudrate of UART module
142  *
143  *    @return       UART baudrate mode2 divider
144  *
145  *    @details      This macro calculate UART baudrate mode2 divider.
146  */
147 #define UART_BAUD_MODE2_DIVIDER(u32SrcFreq, u32BaudRate)    ((((u32SrcFreq) + ((u32BaudRate)/2ul)) / (u32BaudRate))-2ul)
148 
149 
150 /**
151  *    @brief        Write UART data
152  *
153  *    @param[in]    uart    The pointer of the specified UART module
154  *    @param[in]    u8Data  Data byte to transmit.
155  *
156  *    @return       None
157  *
158  *    @details      This macro write Data to Tx data register.
159  */
160 #define UART_WRITE(uart, u8Data)    ((uart)->DAT = (u8Data))
161 
162 
163 /**
164  *    @brief        Read UART data
165  *
166  *    @param[in]    uart    The pointer of the specified UART module
167  *
168  *    @return       The oldest data byte in RX FIFO.
169  *
170  *    @details      This macro read Rx data register.
171  */
172 #define UART_READ(uart)    ((uart)->DAT)
173 
174 
175 /**
176  *    @brief        Get Tx empty
177  *
178  *    @param[in]    uart    The pointer of the specified UART module
179  *
180  *    @retval       0   Tx FIFO is not empty
181  *    @retval       >=1 Tx FIFO is empty
182  *
183  *    @details      This macro get Transmitter FIFO empty register value.
184  */
185 #define UART_GET_TX_EMPTY(uart)    ((uart)->FIFOSTS & UART_FIFOSTS_TXEMPTY_Msk)
186 
187 
188 /**
189  *    @brief        Get Rx empty
190  *
191  *    @param[in]    uart    The pointer of the specified UART module
192  *
193  *    @retval       0   Rx FIFO is not empty
194  *    @retval       >=1 Rx FIFO is empty
195  *
196  *    @details      This macro get Receiver FIFO empty register value.
197  */
198 #define UART_GET_RX_EMPTY(uart)    ((uart)->FIFOSTS & UART_FIFOSTS_RXEMPTY_Msk)
199 
200 
201 /**
202  *    @brief        Check specified uart port transmission is over.
203  *
204  *    @param[in]    uart    The pointer of the specified UART module
205  *
206  *    @retval       0 Tx transmission is not over
207  *    @retval       1 Tx transmission is over
208  *
209  *    @details      This macro return Transmitter Empty Flag register bit value.
210  *                  It indicates if specified uart port transmission is over nor not.
211  */
212 #define UART_IS_TX_EMPTY(uart)    (((uart)->FIFOSTS & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos)
213 
214 
215 /**
216  *    @brief        Wait specified uart port transmission is over
217  *
218  *    @param[in]    uart    The pointer of the specified UART module
219  *
220  *    @return       None
221  *
222  *    @details      This macro wait specified uart port transmission is over.
223  */
224 #define UART_WAIT_TX_EMPTY(uart)    while(!((((uart)->FIFOSTS) & UART_FIFOSTS_TXEMPTYF_Msk) >> UART_FIFOSTS_TXEMPTYF_Pos))
225 
226 
227 /**
228  *    @brief        Check RX is ready or not
229  *
230  *    @param[in]    uart    The pointer of the specified UART module
231  *
232  *    @retval       0 The number of bytes in the RX FIFO is less than the RFITL
233  *    @retval       1 The number of bytes in the RX FIFO equals or larger than RFITL
234  *
235  *    @details      This macro check receive data available interrupt flag is set or not.
236  */
237 #define UART_IS_RX_READY(uart)    (((uart)->INTSTS & UART_INTSTS_RDAIF_Msk)>>UART_INTSTS_RDAIF_Pos)
238 
239 
240 /**
241  *    @brief        Check TX FIFO is full or not
242  *
243  *    @param[in]    uart    The pointer of the specified UART module
244  *
245  *    @retval       1 TX FIFO is full
246  *    @retval       0 TX FIFO is not full
247  *
248  *    @details      This macro check TX FIFO is full or not.
249  */
250 #define UART_IS_TX_FULL(uart)    (((uart)->FIFOSTS & UART_FIFOSTS_TXFULL_Msk)>>UART_FIFOSTS_TXFULL_Pos)
251 
252 
253 /**
254  *    @brief        Check RX FIFO is full or not
255  *
256  *    @param[in]    uart    The pointer of the specified UART module
257  *
258  *    @retval       1 RX FIFO is full
259  *    @retval       0 RX FIFO is not full
260  *
261  *    @details      This macro check RX FIFO is full or not.
262  */
263 #define UART_IS_RX_FULL(uart)    (((uart)->FIFOSTS & UART_FIFOSTS_RXFULL_Msk)>>UART_FIFOSTS_RXFULL_Pos)
264 
265 
266 /**
267  *    @brief        Get Tx full register value
268  *
269  *    @param[in]    uart    The pointer of the specified UART module
270  *
271  *    @retval       0   Tx FIFO is not full.
272  *    @retval       >=1 Tx FIFO is full.
273  *
274  *    @details      This macro get Tx full register value.
275  */
276 #define UART_GET_TX_FULL(uart)    ((uart)->FIFOSTS & UART_FIFOSTS_TXFULL_Msk)
277 
278 
279 /**
280  *    @brief        Get Rx full register value
281  *
282  *    @param[in]    uart    The pointer of the specified UART module
283  *
284  *    @retval       0   Rx FIFO is not full.
285  *    @retval       >=1 Rx FIFO is full.
286  *
287  *    @details      This macro get Rx full register value.
288  */
289 #define UART_GET_RX_FULL(uart)    ((uart)->FIFOSTS & UART_FIFOSTS_RXFULL_Msk)
290 
291 
292 /**
293  *    @brief        Enable specified UART interrupt
294  *
295  *    @param[in]    uart        The pointer of the specified UART module
296  *    @param[in]    u32eIntSel  Interrupt type select
297  *                              - \ref UART_INTEN_TXENDIEN_Msk   : Transmitter empty interrupt
298  *                              - \ref UART_INTEN_ABRIEN_Msk     : Auto baud rate interrupt
299  *                              - \ref UART_INTEN_LINIEN_Msk     : Lin bus interrupt
300  *                              - \ref UART_INTEN_WKIEN_Msk      : Wake-up interrupt
301  *                              - \ref UART_INTEN_BUFERRIEN_Msk  : Buffer Error interrupt
302  *                              - \ref UART_INTEN_RXTOIEN_Msk    : Rx time-out interrupt
303  *                              - \ref UART_INTEN_MODEMIEN_Msk   : Modem interrupt
304  *                              - \ref UART_INTEN_RLSIEN_Msk     : Rx Line status interrupt
305  *                              - \ref UART_INTEN_THREIEN_Msk    : Tx empty interrupt
306  *                              - \ref UART_INTEN_RDAIEN_Msk     : Rx ready interrupt
307  *
308  *    @return       None
309  *
310  *    @details      This macro enable specified UART interrupt.
311  */
312 #define UART_ENABLE_INT(uart, u32eIntSel)    ((uart)->INTEN |= (u32eIntSel))
313 
314 
315 /**
316  *    @brief        Disable specified UART interrupt
317  *
318  *    @param[in]    uart        The pointer of the specified UART module
319  *    @param[in]    u32eIntSel  Interrupt type select
320  *                              - \ref UART_INTEN_TXENDIEN_Msk   : Transmitter Empty Interrupt
321  *                              - \ref UART_INTEN_ABRIEN_Msk     : Auto-baud Rate Interrupt
322  *                              - \ref UART_INTEN_LINIEN_Msk     : Lin Bus interrupt
323  *                              - \ref UART_INTEN_WKIEN_Msk      : Wake-up interrupt
324  *                              - \ref UART_INTEN_BUFERRIEN_Msk  : Buffer Error interrupt
325  *                              - \ref UART_INTEN_RXTOIEN_Msk    : Rx Time-out Interrupt
326  *                              - \ref UART_INTEN_MODEMIEN_Msk   : MODEM Status Interrupt
327  *                              - \ref UART_INTEN_RLSIEN_Msk     : Receive Line Status Interrupt
328  *                              - \ref UART_INTEN_THREIEN_Msk    : Transmit Holding Register Empty Interrupt
329  *                              - \ref UART_INTEN_RDAIEN_Msk     : Receive Data Available Interrupt
330  *
331  *    @return       None
332  *
333  *    @details      This macro enable specified UART interrupt.
334  */
335 #define UART_DISABLE_INT(uart, u32eIntSel)    ((uart)->INTEN &= ~ (u32eIntSel))
336 
337 
338 /**
339  *    @brief        Get specified interrupt flag/status
340  *
341  *    @param[in]    uart            The pointer of the specified UART module
342  *    @param[in]    u32eIntTypeFlag Interrupt Type Flag, should be
343  *                                  - \ref UART_INTSTS_HWBUFEINT_Msk : PDMA Mode Buffer Error Interrupt Indicator
344  *                                  - \ref UART_INTSTS_HWTOINT_Msk   : PDMA Mode Rx Time-out Interrupt Indicator
345  *                                  - \ref UART_INTSTS_HWMODINT_Msk  : PDMA Mode MODEM Status Interrupt Indicator
346  *                                  - \ref UART_INTSTS_HWRLSINT_Msk  : PDMA Mode Receive Line Status Interrupt Indicator
347  *                                  - \ref UART_INTSTS_HWBUFEIF_Msk  : PDMA Mode Buffer Error Interrupt Flag
348  *                                  - \ref UART_INTSTS_HWTOIF_Msk    : PDMA Mode Time-out Interrupt Flag
349  *                                  - \ref UART_INTSTS_HWMODIF_Msk   : PDMA Mode MODEM Status Interrupt Flag
350  *                                  - \ref UART_INTSTS_HWRLSIF_Msk   : PDMA Mode Receive Line Status Flag
351  *                                  - \ref UART_INTSTS_ABRINT_Msk    : Auto-baud Rate Interrupt Indicator
352  *                                  - \ref UART_INTSTS_TXENDINT_Msk  : Transmitter Empty Interrupt Indicator
353  *                                  - \ref UART_INTSTS_LININT_Msk    : LIN Bus Interrupt Indicator
354  *                                  - \ref UART_INTSTS_WKINT_Msk     : Wake-up Interrupt Indicator
355  *                                  - \ref UART_INTSTS_BUFERRINT_Msk : Buffer Error Interrupt Indicator
356  *                                  - \ref UART_INTSTS_RXTOINT_Msk   : Rx Time-out Interrupt Indicator
357  *                                  - \ref UART_INTSTS_MODEMINT_Msk  : Modem Status Interrupt Indicator
358  *                                  - \ref UART_INTSTS_RLSINT_Msk    : Receive Line Status Interrupt Indicator
359  *                                  - \ref UART_INTSTS_THREINT_Msk   : Transmit Holding Register Empty Interrupt Indicator
360  *                                  - \ref UART_INTSTS_RDAINT_Msk    : Receive Data Available Interrupt Indicator
361  *                                  - \ref UART_INTSTS_TXENDIF_Msk   : Transmitter Empty Interrupt Flag
362  *                                  - \ref UART_INTSTS_LINIF_Msk     : LIN Bus Interrupt Flag
363  *                                  - \ref UART_INTSTS_WKIF_Msk      : Wake-up Interrupt Flag
364  *                                  - \ref UART_INTSTS_BUFERRIF_Msk  : Buffer Error Interrupt Flag
365  *                                  - \ref UART_INTSTS_RXTOIF_Msk    : Rx Time-out Interrupt Flag
366  *                                  - \ref UART_INTSTS_MODEMIF_Msk   : MODEM Status Interrupt Flag
367  *                                  - \ref UART_INTSTS_RLSIF_Msk     : Receive Line Status Interrupt Flag
368  *                                  - \ref UART_INTSTS_THREIF_Msk    : Transmit Holding Register Empty Interrupt Flag
369  *                                  - \ref UART_INTSTS_RDAIF_Msk     : Receive Data Available Interrupt Flag
370  *
371  *    @retval       0 The specified interrupt is not happened.
372  *                  1 The specified interrupt is happened.
373  *
374  *    @details      This macro get specified interrupt flag or interrupt indicator status.
375  */
376 #define UART_GET_INT_FLAG(uart,u32eIntTypeFlag)    (((uart)->INTSTS & (u32eIntTypeFlag))?1:0)
377 
378 /*---------------------------------------------------------------------------------------------------------*/
379 /* static inline functions                                                                                 */
380 /*---------------------------------------------------------------------------------------------------------*/
381 /* Declare these inline functions here to avoid MISRA C 2004 rule 8.1 error */
382 static __INLINE void UART_CLEAR_RTS(UART_T* uart);
383 static __INLINE void UART_SET_RTS(UART_T* uart);
384 
385 
386 /**
387  *    @brief        Set RTS pin to low
388  *
389  *    @param[in]    uart    The pointer of the specified UART module
390  *
391  *    @return       None
392  *
393  *    @details      This macro set RTS pin to low.
394  */
UART_CLEAR_RTS(UART_T * uart)395 __STATIC_INLINE void UART_CLEAR_RTS(UART_T* uart)
396 {
397     uart->MODEM |= UART_MODEM_RTSACTLV_Msk;
398     uart->MODEM &= ~UART_MODEM_RTS_Msk;
399 }
400 
401 
402 /**
403  *    @brief        Set RTS pin to high
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 high.
410  */
UART_SET_RTS(UART_T * uart)411 __STATIC_INLINE void UART_SET_RTS(UART_T* uart)
412 {
413     uart->MODEM |= UART_MODEM_RTSACTLV_Msk | UART_MODEM_RTS_Msk;
414 }
415 
416 
417 /**
418  *    @brief        Clear RS-485 Address Byte Detection Flag
419  *
420  *    @param[in]    uart    The pointer of the specified UART module
421  *
422  *    @return       None
423  *
424  *    @details      This macro clear RS-485 address byte detection flag.
425  */
426 #define UART_RS485_CLEAR_ADDR_FLAG(uart)    ((uart)->FIFOSTS = UART_FIFOSTS_ADDRDETF_Msk)
427 
428 
429 /**
430  *    @brief        Get RS-485 Address Byte Detection Flag
431  *
432  *    @param[in]    uart    The pointer of the specified UART module
433  *
434  *    @retval       0 Receiver detects a data that is not an address bit.
435  *    @retval       1 Receiver detects a data that is an address bit.
436  *
437  *    @details      This macro get RS-485 address byte detection flag.
438  */
439 #define UART_RS485_GET_ADDR_FLAG(uart)    (((uart)->FIFOSTS  & UART_FIFOSTS_ADDRDETF_Msk) >> UART_FIFOSTS_ADDRDETF_Pos)
440 
441 
442 /**
443  *    @brief        Enable specified UART PDMA function
444  *
445  *    @param[in]    uart        The pointer of the specified UART module
446  *    @param[in]    u32FuncSel  Combination of following functions
447  *                             - \ref UART_INTEN_TXPDMAEN_Msk
448  *                             - \ref UART_INTEN_RXPDMAEN_Msk
449  *
450  *    @return       None
451  *
452  *    @details      This macro enable specified UART PDMA function.
453  */
454 #define UART_PDMA_ENABLE(uart, u32FuncSel)    ((uart)->INTEN |= (u32FuncSel))
455 
456 
457 /**
458  *    @brief        Disable specified UART PDMA function
459  *
460  *    @param[in]    uart        The pointer of the specified UART module
461  *    @param[in]    u32FuncSel  Combination of following functions
462  *                             - \ref UART_INTEN_TXPDMAEN_Msk
463  *                             - \ref UART_INTEN_RXPDMAEN_Msk
464  *
465  *    @return       None
466  *
467  *    @details      This macro disable specified UART PDMA function.
468  */
469 #define UART_PDMA_DISABLE(uart, u32FuncSel)    ((uart)->INTEN &= ~(u32FuncSel))
470 
471 
472 void UART_ClearIntFlag(UART_T* uart, uint32_t u32InterruptFlag);
473 void UART_Close(UART_T* uart);
474 void UART_DisableFlowCtrl(UART_T* uart);
475 void UART_DisableInt(UART_T*  uart, uint32_t u32InterruptFlag);
476 void UART_EnableFlowCtrl(UART_T* uart);
477 void UART_EnableInt(UART_T*  uart, uint32_t u32InterruptFlag);
478 void UART_Open(UART_T* uart, uint32_t u32baudrate);
479 uint32_t UART_Read(UART_T* uart, uint8_t pu8RxBuf[], uint32_t u32ReadBytes);
480 void UART_SetLineConfig(UART_T* uart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t  u32stop_bits);
481 void UART_SetTimeoutCnt(UART_T* uart, uint32_t u32TOC);
482 void UART_SelectIrDAMode(UART_T* uart, uint32_t u32Buadrate, uint32_t u32Direction);
483 void UART_SelectRS485Mode(UART_T* uart, uint32_t u32Mode, uint32_t u32Addr);
484 void UART_SelectLINMode(UART_T* uart, uint32_t u32Mode, uint32_t u32BreakLength);
485 uint32_t UART_Write(UART_T* uart, uint8_t pu8TxBuf[], uint32_t u32WriteBytes);
486 
487 
488 /*@}*/ /* end of group UART_EXPORTED_FUNCTIONS */
489 
490 /*@}*/ /* end of group UART_Driver */
491 
492 /*@}*/ /* end of group Standard_Driver */
493 
494 #ifdef __cplusplus
495 }
496 #endif
497 
498 #endif /* __UART_H__ */
499 
500