| NUC472_NUC442_BSP V3.03.003 The Board Support Package for NUC472/NUC442

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_UARTCTL_WLS_Pos)
33#define SCUART_CHAR_LEN_6 (0x2ul << SC_UARTCTL_WLS_Pos)
34#define SCUART_CHAR_LEN_7 (0x1ul << SC_UARTCTL_WLS_Pos)
35#define SCUART_CHAR_LEN_8 (0)
37#define SCUART_PARITY_NONE (SC_UARTCTL_PBOFF_Msk)
38#define SCUART_PARITY_ODD (SC_UARTCTL_OPE_Msk)
39#define SCUART_PARITY_EVEN (0)
41#define SCUART_STOP_BIT_1 (SC_CTL_NSB_Msk)
42#define SCUART_STOP_BIT_2 (0)
44#define SCUART_TIMEOUT_ERR (-1L) /* end of group NUC472_442_SCUART_EXPORTED_CONSTANTS */
47
48 extern int32_t g_SCUART_i32ErrCode;
49
54/* TX Macros */
62#define SCUART_WRITE(sc, u8Data) ((sc)->DAT = (u8Data))
63
72#define SCUART_GET_TX_EMPTY(sc) ((sc)->STATUS & SC_STATUS_TXEMPTY_Msk)
73
82#define SCUART_GET_TX_FULL(sc) ((sc)->STATUS & SC_STATUS_TXFULL_Msk)
83
91#define SCUART_WAIT_TX_EMPTY(sc) while((sc)->STATUS & SC_STATUS_TXACT_Msk)
92
101#define SCUART_IS_TX_FULL(sc) ((sc)->STATUS & SC_STATUS_TXFULL_Msk ? 1 : 0)
102
111#define SCUART_IS_TX_EMPTY(sc) ((sc)->STATUS & SC_STATUS_TXACT_Msk ? 0 : 1)
112
113
114/* RX Macros */
115
122#define SCUART_READ(sc) ((sc)->DAT)
123
132#define SCUART_GET_RX_EMPTY(sc) ((sc)->STATUS & SC_STATUS_RXEMPTY_Msk)
133
134
143#define SCUART_GET_RX_FULL(sc) ((sc)->STATUS & SC_STATUS_RXFULL_Msk)
144
154#define SCUART_IS_RX_READY(sc) ((sc)->INTSTS & SC_INTSTS_RDAIF_Msk ? 1 : 0)
155
164#define SCUART_IS_RX_FULL(sc) ((sc)->STATUS & SC_STATUS_RXFULL_Msk ? 1 : 0)
165
166/* Interrupt Macros */
167
179#define SCUART_ENABLE_INT(sc, u32Mask) ((sc)->INTEN |= (u32Mask))
180
192#define SCUART_DISABLE_INT(sc, u32Mask) ((sc)->INTEN &= ~(u32Mask))
193
207#define SCUART_GET_INT_FLAG(sc, u32Type) ((sc)->INTSTS & u32Type ? 1 : 0)
208
219#define SCUART_CLR_INT_FLAG(sc, u32Type) ((sc)->INTSTS = u32Type)
220
230#define SCUART_GET_ERR_FLAG(sc) ((sc)->STATUS & (SC_STATUS_PEF_Msk | SC_STATUS_FEF_Msk | SC_STATUS_BEF_Msk))
231
242#define SCUART_CLR_ERR_FLAG(sc, u32Mask) ((sc)->STATUS = u32Mask)
243
244 void SCUART_Close(SC_T* sc);
245uint32_t SCUART_Open(SC_T* sc, uint32_t u32baudrate);
246uint32_t SCUART_Read(SC_T* sc, uint8_t *pu8RxBuf, uint32_t u32ReadBytes);
247uint32_t SCUART_SetLineConfig(SC_T* sc, uint32_t u32Baudrate, uint32_t u32DataWidth, uint32_t u32Parity, uint32_t u32StopBits);
248 void SCUART_SetTimeoutCnt(SC_T* sc, uint32_t u32TOC);
249uint32_t SCUART_Write(SC_T* sc,uint8_t *pu8TxBuf, uint32_t u32WriteBytes);
250 /* end of group NUC472_442_SCUART_EXPORTED_FUNCTIONS */
252 /* end of group NUC472_442_SCUART_Driver */
254 /* end of group NUC472_442_Device_Driver */
256
257#ifdef __cplusplus
258}
259#endif
260
261#endif //__SCUART_H__
262
263/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
g_SCUART_i32ErrCode
int32_t g_SCUART_i32ErrCode
Definition: scuart.c:27
SCUART_SetTimeoutCnt
void SCUART_SetTimeoutCnt(SC_T *sc, uint32_t u32TOC)
This function use to set receive timeout count.
Definition: scuart.c:198
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:126
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:166
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:104
SCUART_Write
uint32_t 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:213
SCUART_Close
void SCUART_Close(SC_T *sc)
The function is used to disable smartcard interface UART mode.
Definition: scuart.c:34
SC_T
Definition: NUC472_442.h:21114