| M480 BSP V3.05.001 The Board Support Package for M480 Series

usci_uart.h
Go to the documentation of this file.
1 /**************************************************************************/
9 #ifndef __USCI_UART_H__
10 #define __USCI_UART_H__
11
12
13 #ifdef __cplusplus
14 extern "C"
15 {
16 #endif
17
18
31 /*---------------------------------------------------------------------------------------------------------*/
32 /* UUART_LINECTL constants definitions */
33 /*---------------------------------------------------------------------------------------------------------*/
34 #define UUART_WORD_LEN_6 (6ul << UUART_LINECTL_DWIDTH_Pos)
35 #define UUART_WORD_LEN_7 (7ul << UUART_LINECTL_DWIDTH_Pos)
36 #define UUART_WORD_LEN_8 (8ul << UUART_LINECTL_DWIDTH_Pos)
37 #define UUART_WORD_LEN_9 (9ul << UUART_LINECTL_DWIDTH_Pos)
39 /*---------------------------------------------------------------------------------------------------------*/
40 /* UUART_PROTCTL constants definitions */
41 /*---------------------------------------------------------------------------------------------------------*/
42 #define UUART_PARITY_NONE (0x0ul << UUART_PROTCTL_PARITYEN_Pos)
43 #define UUART_PARITY_ODD (0x1ul << UUART_PROTCTL_PARITYEN_Pos)
44 #define UUART_PARITY_EVEN (0x3ul << UUART_PROTCTL_PARITYEN_Pos)
46 #define UUART_STOP_BIT_1 (0x0ul)
47 #define UUART_STOP_BIT_2 (0x1ul)
49 /*---------------------------------------------------------------------------------------------------------*/
50 /* USCI UART interrupt mask definitions */
51 /*---------------------------------------------------------------------------------------------------------*/
52 #define UUART_ABR_INT_MASK (0x002ul)
53 #define UUART_RLS_INT_MASK (0x004ul)
54 #define UUART_BUF_RXOV_INT_MASK (0x008ul)
55 #define UUART_TXST_INT_MASK (0x010ul)
56 #define UUART_TXEND_INT_MASK (0x020ul)
57 #define UUART_RXST_INT_MASK (0x040ul)
58 #define UUART_RXEND_INT_MASK (0x080ul)
61 /* end of group USCI_UART_EXPORTED_CONSTANTS */
62
63
80 #define UUART_WRITE(uuart, u8Data) ((uuart)->TXDAT = (u8Data))
81
82
93 #define UUART_READ(uuart) ((uuart)->RXDAT)
94
95
107 #define UUART_GET_TX_EMPTY(uuart) ((uuart)->BUFSTS & UUART_BUFSTS_TXEMPTY_Msk)
108
109
121 #define UUART_GET_RX_EMPTY(uuart) ((uuart)->BUFSTS & UUART_BUFSTS_RXEMPTY_Msk)
122
123
136 #define UUART_IS_TX_EMPTY(uuart) (((uuart)->BUFSTS & UUART_BUFSTS_TXEMPTY_Msk) >> UUART_BUFSTS_TXEMPTY_Pos)
137
138
151 #define UUART_IS_RX_EMPTY(uuart) (((uuart)->BUFSTS & UUART_BUFSTS_RXEMPTY_Msk) >> UUART_BUFSTS_RXEMPTY_Pos)
152
153
164 #define UUART_WAIT_TX_EMPTY(uuart) while(!((((uuart)->BUFSTS) & UUART_BUFSTS_TXEMPTY_Msk) >> UUART_BUFSTS_TXEMPTY_Pos))
165
166
178 #define UUART_IS_TX_FULL(uuart) (((uuart)->BUFSTS & UUART_BUFSTS_TXFULL_Msk)>>UUART_BUFSTS_TXFULL_Pos)
179
180
192 #define UUART_IS_RX_FULL(uuart) (((uuart)->BUFSTS & UUART_BUFSTS_RXFULL_Msk)>>UUART_BUFSTS_RXFULL_Pos)
193
194
206 #define UUART_GET_TX_FULL(uuart) ((uuart)->BUFSTS & UUART_BUFSTS_TXFULL_Msk)
207
208
220 #define UUART_GET_RX_FULL(uuart) ((uuart)->BUFSTS & UUART_BUFSTS_RXFULL_Msk)
221
222
236 #define UUART_ENABLE_PROT_INT(uuart, u32IntSel) ((uuart)->PROTIEN |= (u32IntSel))
237
238
252 #define UUART_DISABLE_PROT_INT(uuart, u32IntSel) ((uuart)->PROTIEN &= ~(u32IntSel))
253
254
267 #define UUART_ENABLE_BUF_INT(uuart, u32IntSel) ((uuart)->BUFCTL |= (u32IntSel))
268
269
282 #define UUART_DISABLE_BUF_INT(uuart, u32IntSel) ((uuart)->BUFCTL &= ~ (u32IntSel))
283
284
300 #define UUART_ENABLE_TRANS_INT(uuart, u32IntSel) ((uuart)->INTEN |= (u32IntSel))
301
302
318 #define UUART_DISABLE_TRANS_INT(uuart, u32IntSel) ((uuart)->INTEN &= ~(u32IntSel))
319
320
331 #define UUART_GET_PROT_STATUS(uuart) ((uuart)->PROTSTS)
332
333
354 #define UUART_CLR_PROT_INT_FLAG(uuart,u32IntTypeFlag) ((uuart)->PROTSTS = (u32IntTypeFlag))
355
356
367 #define UUART_GET_BUF_STATUS(uuart) ((uuart)->BUFSTS)
368
369
382 #define UUART_CLR_BUF_INT_FLAG(uuart,u32IntTypeFlag) ((uuart)->BUFSTS = (u32IntTypeFlag))
383
384
396 #define UUART_GET_WAKEUP_FLAG(uuart) ((uuart)->WKSTS & UUART_WKSTS_WKF_Msk ? 1: 0 )
397
398
409 #define UUART_CLR_WAKEUP_FLAG(uuart) ((uuart)->WKSTS = UUART_WKSTS_WKF_Msk)
410
421 #define UUART_TRIGGER_RX_PDMA(uuart) ((uuart)->PDMACTL |= UUART_PDMACTL_RXPDMAEN_Msk|UUART_PDMACTL_PDMAEN_Msk)
422
433 #define UUART_TRIGGER_TX_PDMA(uuart) ((uuart)->PDMACTL |= UUART_PDMACTL_TXPDMAEN_Msk|UUART_PDMACTL_PDMAEN_Msk)
434
445 #define UUART_DISABLE_RX_PDMA(uuart) ( (uuart)->PDMACTL &= ~UUART_PDMACTL_RXPDMAEN_Msk )
446
457 #define UUART_DISABLE_TX_PDMA(uuart) ( (uuart)->PDMACTL &= ~UUART_PDMACTL_TXPDMAEN_Msk )
458
459
473 #define UUART_PDMA_ENABLE(uuart, u32FuncSel) ((uuart)->PDMACTL |= (u32FuncSel))
474
488 #define UUART_PDMA_DISABLE(uuart, u32FuncSel) ((uuart)->PDMACTL &= ~(u32FuncSel))
489
490
491
492
493 void UUART_ClearIntFlag(UUART_T* uuart, uint32_t u32Mask);
494 uint32_t UUART_GetIntFlag(UUART_T* uuart, uint32_t u32Mask);
495 void UUART_Close(UUART_T* uuart);
496 void UUART_DisableInt(UUART_T* uuart, uint32_t u32Mask);
497 void UUART_EnableInt(UUART_T* uuart, uint32_t u32Mask);
498 uint32_t UUART_Open(UUART_T* uuart, uint32_t u32baudrate);
499 uint32_t UUART_Read(UUART_T* uuart, uint8_t pu8RxBuf[], uint32_t u32ReadBytes);
500 uint32_t UUART_SetLine_Config(UUART_T* uuart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t u32stop_bits);
501 uint32_t UUART_Write(UUART_T* uuart, uint8_t pu8TxBuf[], uint32_t u32WriteBytes);
502 void UUART_EnableWakeup(UUART_T* uuart, uint32_t u32WakeupMode);
503 void UUART_DisableWakeup(UUART_T* uuart);
504 void UUART_EnableFlowCtrl(UUART_T* uuart);
505 void UUART_DisableFlowCtrl(UUART_T* uuart);
506
507 /* end of group USCI_UART_EXPORTED_FUNCTIONS */
509 /* end of group USCI_UART_Driver */
511 /* end of group Standard_Driver */
513
514 #ifdef __cplusplus
515 }
516 #endif
517
518 #endif /* __USCI_UART_H__ */
519
520 /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
UUART_Read
uint32_t UUART_Read(UUART_T *uuart, uint8_t pu8RxBuf[], uint32_t u32ReadBytes)
Read USCI_UART data.
Definition: usci_uart.c:432
UUART_DisableFlowCtrl
void UUART_DisableFlowCtrl(UUART_T *uuart)
Disable USCI_UART auto flow control.
Definition: usci_uart.c:686
UUART_T
Definition: uuart_reg.h:26
UUART_DisableInt
void UUART_DisableInt(UUART_T *uuart, uint32_t u32Mask)
Disable interrupt function.
Definition: usci_uart.c:205
UUART_Close
void UUART_Close(UUART_T *uuart)
Disable USCI_UART function mode.
Definition: usci_uart.c:180
UUART_EnableWakeup
void UUART_EnableWakeup(UUART_T *uuart, uint32_t u32WakeupMode)
Enable USCI_UART Wake-up Function.
Definition: usci_uart.c:634
UUART_Open
uint32_t UUART_Open(UUART_T *uuart, uint32_t u32baudrate)
Open and set USCI_UART function.
Definition: usci_uart.c:327
UUART_EnableInt
void UUART_EnableInt(UUART_T *uuart, uint32_t u32Mask)
Enable interrupt function.
Definition: usci_uart.c:271
UUART_GetIntFlag
uint32_t UUART_GetIntFlag(UUART_T *uuart, uint32_t u32Mask)
Get USCI_UART specified interrupt flag.
Definition: usci_uart.c:105
UUART_DisableWakeup
void UUART_DisableWakeup(UUART_T *uuart)
Disable USCI_UART Wake-up Function.
Definition: usci_uart.c:650
UUART_SetLine_Config
uint32_t UUART_SetLine_Config(UUART_T *uuart, uint32_t u32baudrate, uint32_t u32data_width, uint32_t u32parity, uint32_t u32stop_bits)
Set USCI_UART line configuration.
Definition: usci_uart.c:485
UUART_Write
uint32_t UUART_Write(UUART_T *uuart, uint8_t pu8TxBuf[], uint32_t u32WriteBytes)
Write USCI_UART data.
Definition: usci_uart.c:593
UUART_ClearIntFlag
void UUART_ClearIntFlag(UUART_T *uuart, uint32_t u32Mask)
Clear USCI_UART specified interrupt flag.
Definition: usci_uart.c:45
UUART_EnableFlowCtrl
void UUART_EnableFlowCtrl(UUART_T *uuart)
Enable USCI_UART auto flow control.
Definition: usci_uart.c:665