| NANO100_BSP V3.05.000 The Board Support Package for Nano100BN Series

scuart.h
Go to the documentation of this file.
1/**************************************************************************/
12#ifndef __SCUART_H__
13#define __SCUART_H__
14
15#ifdef __cplusplus
16 extern "C"
17{
18#endif
19
20
32#define SCUART_CHAR_LEN_5 (0x3ul << SC_UACTL_DATA_LEN_Pos)
33#define SCUART_CHAR_LEN_6 (0x2ul << SC_UACTL_DATA_LEN_Pos)
34#define SCUART_CHAR_LEN_7 (0x1ul << SC_UACTL_DATA_LEN_Pos)
35#define SCUART_CHAR_LEN_8 (0)
37#define SCUART_PARITY_NONE (SC_UACTL_PBDIS_Msk)
38#define SCUART_PARITY_ODD (SC_UACTL_OPE_Msk)
39#define SCUART_PARITY_EVEN (0)
41#define SCUART_STOP_BIT_1 (SC_CTL_SLEN_Msk)
42#define SCUART_STOP_BIT_2 (0) /* end of group NANO100_SCUART_EXPORTED_CONSTANTS */
46
47
52/* TX Macros */
60#define SCUART_WRITE(sc, u8Data) ((sc)->THR = (u8Data))
61
70#define SCUART_GET_TX_EMPTY(sc) ((sc)->TRSR & SC_TRSR_TX_EMPTY_F_Msk)
71
80#define SCUART_GET_TX_FULL(sc) ((sc)->TRSR & SC_TRSR_TX_FULL_F_Msk)
81
89#define SCUART_WAIT_TX_EMPTY(sc) while((sc)->TRSR & SC_TRSR_TX_ATV_Msk)
90
99#define SCUART_IS_TX_FULL(sc) ((sc)->TRSR & SC_TRSR_TX_FULL_F_Msk ? 1 : 0)
100
109#define SCUART_IS_TX_EMPTY(sc) ((sc)->TRSR & SC_TRSR_TX_ATV_Msk ? 0 : 1)
110
111
112/* RX Macros */
113
120#define SCUART_READ(sc) ((sc)->RBR)
121
130#define SCUART_GET_RX_EMPTY(sc) ((sc)->TRSR & SC_TRSR_RX_EMPTY_F_Msk)
131
132
141#define SCUART_GET_RX_FULL(sc) ((sc)->TRSR & SC_TRSR_RX_FULL_F_Msk)
142
152#define SCUART_IS_RX_READY(sc) ((sc)->ISR & SC_ISR_RDA_IS_Msk ? 1 : 0)
153
162#define SCUART_IS_RX_FULL(sc) ((sc)->TRSR & SC_TRSR_RX_FULL_F_Msk ? 1 : 0)
163
164/* Interrupt Macros */
165
177#define SCUART_ENABLE_INT(sc, u32Mask) ((sc)->IER |= (u32Mask))
178
190#define SCUART_DISABLE_INT(sc, u32Mask) ((sc)->IER &= ~(u32Mask))
191
205#define SCUART_GET_INT_FLAG(sc, u32Type) ((sc)->ISR & u32Type ? 1 : 0)
206
217#define SCUART_CLR_INT_FLAG(sc, u32Type) ((sc)->ISR = u32Type)
218
228#define SCUART_GET_ERR_FLAG(sc) ((sc)->TRSR & (SC_TRSR_RX_EPA_F_Msk | SC_TRSR_RX_EFR_F_Msk | SC_TRSR_RX_EBR_F_Msk))
229
240#define SCUART_CLR_ERR_FLAG(sc, u32Mask) ((sc)->TRSR = u32Mask)
241
242 void SCUART_Close(SC_T* sc);
243uint32_t SCUART_Open(SC_T* sc, uint32_t u32baudrate);
244uint32_t SCUART_Read(SC_T* sc, uint8_t *pu8RxBuf, uint32_t u32ReadBytes);
245uint32_t SCUART_SetLineConfig(SC_T* sc, uint32_t u32Baudrate, uint32_t u32DataWidth, uint32_t u32Parity, uint32_t u32StopBits);
246 void SCUART_SetTimeoutCnt(SC_T* sc, uint32_t u32TOC);
247 void SCUART_Write(SC_T* sc,uint8_t *pu8TxBuf, uint32_t u32WriteBytes);
248 /* end of group NANO100_SCUART_EXPORTED_FUNCTIONS */
250 /* end of group NANO100_SCUART_Driver */
252 /* end of group NANO100_Device_Driver */
254
255#ifdef __cplusplus
256}
257#endif
258
259#endif //__SCUART_H__
260
261/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
SCUART_SetTimeoutCnt
void SCUART_SetTimeoutCnt(SC_T *sc, uint32_t u32TOC)
This function use to set receive timeout count.
Definition: scuart.c:179
SCUART_Read
uint32_t SCUART_Read(SC_T *sc, uint8_t *pu8RxBuf, uint32_t u32ReadBytes)
The function is used to read Rx data from RX FIFO.
Definition: scuart.c:107
SCUART_Write
void SCUART_Write(SC_T *sc, uint8_t *pu8TxBuf, uint32_t u32WriteBytes)
This function is to write data into transmit FIFO to send data out.
Definition: scuart.c:193
SCUART_SetLineConfig
uint32_t SCUART_SetLineConfig(SC_T *sc, uint32_t u32Baudrate, uint32_t u32DataWidth, uint32_t u32Parity, uint32_t u32StopBits)
This function use to config smartcard UART mode line setting.
Definition: scuart.c:147
SCUART_Open
uint32_t SCUART_Open(SC_T *sc, uint32_t u32baudrate)
This function use to enable smartcard module UART mode and set baudrate.
Definition: scuart.c:85
SCUART_Close
void SCUART_Close(SC_T *sc)
The function is used to disable smartcard interface UART mode.
Definition: scuart.c:32
SC_T
Definition: Nano100Series.h:8274