M480 BSP V3.05.006
The Board Support Package for M480 Series
scuart.h
Go to the documentation of this file.
1/**************************************************************************/
9#ifndef __SCUART_H__
10#define __SCUART_H__
11
12#ifdef __cplusplus
13extern "C"
14{
15#endif
16
17
29#define SCUART_CHAR_LEN_5 (0x3ul << SC_UARTCTL_WLS_Pos)
30#define SCUART_CHAR_LEN_6 (0x2ul << SC_UARTCTL_WLS_Pos)
31#define SCUART_CHAR_LEN_7 (0x1ul << SC_UARTCTL_WLS_Pos)
32#define SCUART_CHAR_LEN_8 (0UL)
34#define SCUART_PARITY_NONE (SC_UARTCTL_PBOFF_Msk)
35#define SCUART_PARITY_ODD (SC_UARTCTL_OPE_Msk)
36#define SCUART_PARITY_EVEN (0UL)
38#define SCUART_STOP_BIT_1 (SC_CTL_NSB_Msk)
39#define SCUART_STOP_BIT_2 (0UL)
41#define SCUART_TIMEOUT_ERR (-1L) /* end of group SCUART_EXPORTED_CONSTANTS */
44
45extern int32_t g_SCUART_i32ErrCode;
46
51/* TX Macros */
59#define SCUART_WRITE(sc, u8Data) ((sc)->DAT = (u8Data))
60
69#define SCUART_GET_TX_EMPTY(sc) ((sc)->STATUS & SC_STATUS_TXEMPTY_Msk)
70
79#define SCUART_GET_TX_FULL(sc) ((sc)->STATUS & SC_STATUS_TXFULL_Msk)
80
88#define SCUART_WAIT_TX_EMPTY(sc) while((sc)->STATUS & SC_STATUS_TXACT_Msk)
89
98#define SCUART_IS_TX_FULL(sc) ((sc)->STATUS & SC_STATUS_TXFULL_Msk ? 1 : 0)
99
108#define SCUART_IS_TX_EMPTY(sc) ((sc)->STATUS & SC_STATUS_TXACT_Msk ? 0 : 1)
109
118#define SCUART_IS_TX_ACTIVE(sc) (((sc)->STATUS & SC_STATUS_TXACT_Msk)? 1 : 0)
119
120/* RX Macros */
121
128#define SCUART_READ(sc) ((sc)->DAT)
129
138#define SCUART_GET_RX_EMPTY(sc) ((sc)->STATUS & SC_STATUS_RXEMPTY_Msk)
139
140
149#define SCUART_GET_RX_FULL(sc) ((sc)->STATUS & SC_STATUS_RXFULL_Msk)
150
160#define SCUART_IS_RX_READY(sc) ((sc)->INTSTS & SC_INTSTS_RDAIF_Msk ? 1 : 0)
161
170#define SCUART_IS_RX_FULL(sc) ((sc)->STATUS & SC_STATUS_RXFULL_Msk ? 1 : 0)
171
172/* Interrupt Macros */
173
185#define SCUART_ENABLE_INT(sc, u32Mask) ((sc)->INTEN |= (u32Mask))
186
198#define SCUART_DISABLE_INT(sc, u32Mask) ((sc)->INTEN &= ~(u32Mask))
199
213#define SCUART_GET_INT_FLAG(sc, u32Type) ((sc)->INTSTS & (u32Type) ? 1 : 0)
214
225#define SCUART_CLR_INT_FLAG(sc, u32Type) ((sc)->INTSTS = (u32Type))
226
236#define SCUART_GET_ERR_FLAG(sc) ((sc)->STATUS & (SC_STATUS_PEF_Msk | SC_STATUS_FEF_Msk | SC_STATUS_BEF_Msk))
237
248#define SCUART_CLR_ERR_FLAG(sc, u32Mask) ((sc)->STATUS = (u32Mask))
249
250void SCUART_Close(SC_T* sc);
251uint32_t SCUART_Open(SC_T* sc, uint32_t u32baudrate);
252uint32_t SCUART_Read(SC_T* sc, uint8_t pu8RxBuf[], uint32_t u32ReadBytes);
253uint32_t SCUART_SetLineConfig(SC_T* sc, uint32_t u32Baudrate, uint32_t u32DataWidth, uint32_t u32Parity, uint32_t u32StopBits);
254void SCUART_SetTimeoutCnt(SC_T* sc, uint32_t u32TOC);
255uint32_t SCUART_Write(SC_T* sc,uint8_t pu8TxBuf[], uint32_t u32WriteBytes);
256 /* end of group SCUART_EXPORTED_FUNCTIONS */
258 /* end of group SCUART_Driver */
260 /* end of group Standard_Driver */
262
263#ifdef __cplusplus
264}
265#endif
266
267#endif /* __SCUART_H__ */
int32_t g_SCUART_i32ErrCode
Definition: scuart.c:22
void SCUART_SetTimeoutCnt(SC_T *sc, uint32_t u32TOC)
This function use to set receive timeout count.
Definition: scuart.c:207
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:111
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:135
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:222
uint32_t SCUART_SetLineConfig(SC_T *sc, uint32_t u32Baudrate, uint32_t u32DataWidth, uint32_t u32Parity, uint32_t u32StopBits)
This function use to configure smartcard UART mode line setting.
Definition: scuart.c:174
void SCUART_Close(SC_T *sc)
The function is used to disable smartcard interface UART mode.
Definition: scuart.c:33
Definition: sc_reg.h:27