M4521_BSP V3.02.000
The Board Support Package for M4521
scuart.h
Go to the documentation of this file.
1/**************************************************************************/
12#ifndef __SCUART_H__
13#define __SCUART_H__
14
15#ifdef __cplusplus
16extern "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 SCUART_EXPORTED_CONSTANTS */
47
48extern int32_t g_SCUART_i32ErrCode;
49
54/* TX Macros */
63#define SCUART_WRITE(sc, u8Data) ((sc)-> DAT = (u8Data))
64
75#define SCUART_GET_TX_EMPTY(sc) ((sc)->STATUS & SC_STATUS_TXEMPTY_Msk)
76
85#define SCUART_GET_TX_FULL(sc) ((sc)->STATUS & SC_STATUS_TXFULL_Msk)
86
95#define SCUART_WAIT_TX_EMPTY(sc) while((sc)->STATUS & SC_STATUS_TXACT_Msk)
96
106#define SCUART_IS_TX_FULL(sc) ((sc)->STATUS & SC_STATUS_TXFULL_Msk ? 1 : 0)
107
116#define SCUART_IS_TX_EMPTY(sc) ((sc)->STATUS & SC_STATUS_TXACT_Msk ? 0 : 1)
117
118
119/* RX Macros */
120
128#define SCUART_READ(sc) ((sc)->DAT)
129
139#define SCUART_GET_RX_EMPTY(sc) ((sc)->STATUS & SC_STATUS_RXEMPTY_Msk)
140
141
150#define SCUART_GET_RX_FULL(sc) ((sc)->STATUS & SC_STATUS_RXFULL_Msk)
151
161#define SCUART_IS_RX_READY(sc) ((sc)->INTSTS & SC_INTSTS_RDAIF_Msk ? 1 : 0)
162
171#define SCUART_IS_RX_FULL(sc) ((sc)->STATUS & SC_STATUS_RXFULL_Msk ? 1 : 0)
172
173/* Interrupt Macros */
174
188#define SCUART_ENABLE_INT(sc, u32Mask) ((sc)->INTEN |= (u32Mask))
189
203#define SCUART_DISABLE_INT(sc, u32Mask) ((sc)->INTEN &= ~(u32Mask))
204
220#define SCUART_GET_INT_FLAG(sc, u32Type) ((sc)->INTSTS & (u32Type) ? 1 : 0)
221
234#define SCUART_CLR_INT_FLAG(sc, u32Type) ((sc)->INTSTS = (u32Type))
235
247#define SCUART_GET_ERR_FLAG(sc) ((sc)->STATUS & (SC_STATUS_PEF_Msk | SC_STATUS_FEF_Msk | SC_STATUS_BEF_Msk))
248
261#define SCUART_CLR_ERR_FLAG(sc, u32Mask) ((sc)->STATUS = (u32Mask))
262
263void SCUART_Close(SC_T* sc);
264uint32_t SCUART_Open(SC_T* sc, uint32_t u32baudrate);
265uint32_t SCUART_Read(SC_T* sc, uint8_t *pu8RxBuf, uint32_t u32ReadBytes);
266uint32_t SCUART_SetLineConfig(SC_T* sc, uint32_t u32Baudrate, uint32_t u32DataWidth, uint32_t u32Parity, uint32_t u32StopBits);
267void SCUART_SetTimeoutCnt(SC_T* sc, uint32_t u32TOC);
268uint32_t SCUART_Write(SC_T* sc, uint8_t *pu8TxBuf, uint32_t u32WriteBytes);
269 /* end of group SCUART_EXPORTED_FUNCTIONS */
271 /* end of group SCUART_Driver */
273 /* end of group Standard_Driver */
275
276#ifdef __cplusplus
277}
278#endif
279
280#endif //__SCUART_H__
281
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:203
uint32_t SCUART_Read(SC_T *sc, uint8_t *pu8RxBuf, uint32_t u32ReadBytes)
Read data from smartcard UART interface.
Definition: scuart.c:136
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:171
uint32_t SCUART_Open(SC_T *sc, uint32_t u32baudrate)
Enable smartcard uart interface.
Definition: scuart.c:113
uint32_t SCUART_Write(SC_T *sc, uint8_t *pu8TxBuf, uint32_t u32WriteBytes)
Write data to smartcard UART interface.
Definition: scuart.c:218
void SCUART_Close(SC_T *sc)
Disable smartcard uart interface.
Definition: scuart.c:34
Definition: M4521.h:7895