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

ps2.h
Go to the documentation of this file.
1/**************************************************************************/
12#ifndef __PS2_H__
13#define __PS2_H__
14
15/*---------------------------------------------------------------------------------------------------------*/
16/* Include related headers */
17/*---------------------------------------------------------------------------------------------------------*/
18#include "NUC472_442.h"
19
20#ifdef __cplusplus
21 extern "C"
22{
23#endif
24
25
48#define PS2_SET_TX_BYTE_CNT(u32Count) (PS2->CTL = (PS2->CTL & ~PS2_CTL_TXFDEPTH_Msk) \
49 | ((u32Count-1) << PS2_CTL_TXFDEPTH_Pos))
50
59#define PS2_GET_STATUS() (PS2->STATUS)
60
69#define PS2_CLR_STATUS(u32Mask) (PS2D->PS2STATUS = u32Mask)
70
79__STATIC_INLINE void PS2_CLEAR_TX_FIFO(void)
80{
81 PS2->CTL |= PS2_CTL_CLRFIFO_Msk;
82 PS2->CTL &= ~PS2_CTL_CLRFIFO_Msk;
83}
84
93#define PS2_CLR_RX_INT_FLAG() (PS2->INTSTS = PS2_INTSTS_RXIF_Msk)
94
103#define PS2_CLR_TX_INT_FLAG() (PS2->INTSTS = PS2_INTSTS_TXIF_Msk)
104
114#define PS2_GET_INT_FLAG(u32IntFlag) ((PS2->INTSTS & u32IntFlag)?1:0)
115
124#define PS2_DISABLE_OVERRIDE() (PS2->CTL &= ~PS2_CTL_PS2EN_Msk)
125
134#define PS2_ENABLE_OVERRIDE() (PS2->CTL |= PS2_CTL_PS2EN_Msk)
135
144#define PS2_GET_TX_BYTE_INDEX() ((PS2->STATUS & PS2_STATUS_BYTEIDX_Msk) >> PS2_STATUS_BYTEIDX_Pos)
145
154#define PS2_SET_DATA_LOW() (PS2->CTL &= ~PS2_CTL_FPS2DAT_Msk)
155
164#define PS2_SET_DATA_HIGH() (PS2->CTL |= PS2_CTL_FPS2DAT_Msk)
165
174#define PS2_SET_CLK_LOW() (PS2->CTL &= ~PS2_CTL_FPS2CLK_Msk)
175
184#define PS2_SET_CLK_HIGH() (PS2->CTL |= PS2_CTL_FPS2CLK_Msk)
185
194#define PS2_DISABLE_ACK_ALWAYS() (PS2->CTL |= PS2_CTL_ACK_Msk)
195
204#define PS2_ENABLE_ACK_ALWAYS() (PS2->CTL &= ~PS2_CTL_ACK_Msk)
205
206
207/*---------------------------------------------------------------------------------------------------------*/
208/* Define Function Prototypes */
209/*---------------------------------------------------------------------------------------------------------*/
210
211 void PS2_Open(void);
212 void PS2_Close(void);
213uint8_t PS2_Read(void);
214int32_t PS2_Write(uint32_t *pu32Buf, uint32_t u32ByteCount);
215 void PS2_EnableInt(uint32_t u32Mask);
216 void PS2_DisableInt(uint32_t u32Mask);
217
218 /* end of group NUC472_442_PS2_EXPORTED_FUNCTIONS */
220 /* end of group NUC472_442_PS2_Driver */
222 /* end of group NUC472_442_Device_Driver */
224
225#ifdef __cplusplus
226}
227#endif
228
229#endif //__PS2_H__
230
231/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
232
NUC472_442.h
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
PS2_CTL_CLRFIFO_Msk
#define PS2_CTL_CLRFIFO_Msk
Definition: NUC472_442.h:18973
PS2
#define PS2
Definition: NUC472_442.h:28872
PS2_Write
int32_t PS2_Write(uint32_t *pu32Buf, uint32_t u32ByteCount)
This function use to transmit PS2 data.
Definition: ps2.c:122
PS2_Close
void PS2_Close(void)
This function use to disable PS2 function.
Definition: ps2.c:95
PS2_DisableInt
void PS2_DisableInt(uint32_t u32Mask)
The function is used to disable PS2 specified interrupt.
Definition: ps2.c:59
PS2_EnableInt
void PS2_EnableInt(uint32_t u32Mask)
The function is used to enable PS2 specified interrupt.
Definition: ps2.c:45
PS2_Open
void PS2_Open(void)
This function use to enable PS2 function and set one byte per trnasfer.
Definition: ps2.c:71
PS2_Read
uint8_t PS2_Read(void)
This function use to read PS2 Rx data.
Definition: ps2.c:108
PS2_CLEAR_TX_FIFO
__STATIC_INLINE void PS2_CLEAR_TX_FIFO(void)
This function use to clear PS2 Tx FIFO.
Definition: ps2.h:79