⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ps2port.hpp

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 HPP
字号:
/*

THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995-1998  Microsoft Corporation

*/

#ifndef __PS2PORT_HPP_INCLUDED__
#define __PS2PORT_HPP_INCLUDED__


#include <windows.h>
#include <drvlib.h>
#include <vrc4173.h>
#include <vr4122io.h>

typedef volatile BYTE   *PVBYTE;
typedef volatile UINT8  *PVUINT8;
typedef volatile UINT16 *PVUINT16;

#define KeybdPort	0
#define MousePort	0x20 // This is register location offset from KeybdPort.

/*++

Ps2Port:

This is a very simple minded PS/2 interface.

It is intended to provide only basic keyboard and mouse support.


--*/
class Ps2Port
{
	PVBYTE		m_iopBase;
	CRITICAL_SECTION	m_csWrite;

	int					m_cEnterWrites;
	bool				m_bMouseFound;

	UINT8				m_ui8KeybdControlByte;
	UINT8				m_ui8MouseControlByte;

	UINT8
	ui8IopRead(
		unsigned int	reg_adr
		)
	{
	return REG8(pVRC4173+reg_adr);
	}


	UINT8
	ui8StatusRead(
		unsigned int	port
		)
	{
	return ui8IopRead(PS2CH1CTRL + port);
	}


	UINT8
	ui8RxBufRead(
		unsigned int	port
		)
	{
	return ui8IopRead(PS2CH1DATA + port);
	}


	bool
	RxBufIsFull(
		unsigned int	port
		);

	bool RxBufPollForEmpty(  unsigned int port    );

	void
	ControlRegWrite(
		unsigned int	port,
		UINT8	bControl
		)
	{
		REG16(pVRC4173+PS2CH1CTRL + port) = bControl;
		return;
	}

	void
	TxDataWrite(
		unsigned int	port,
		UINT8	bdata
		)
	{
		REG8(pVRC4173+PS2CH1DATA + port) = bdata;
		return;
	}


	bool
	TxBufPollForEmpty(
		unsigned int	port
		);


	bool
	RxBufPollRead(
		unsigned int	port,
		UINT8	*pui8
		);


	bool
	TxCommandPut(
		unsigned int	port,
		UINT8	ui8Data
		);



	bool
	EnterWrite(
		unsigned int	port
		);


	bool
	LeaveWrite(
		unsigned int	port
		);



public:

	bool
	Initialize(
		void
		);


	bool
	KeyboardReset(
		void
		);

	void
	KeyboardLights(
		unsigned int	fLights
		);

	void
	KeybdChangScanToSystem(
		void
		);

	bool
	KeybdPowerSwIntrCheck(
		void
		)
	{
		UINT16	csr;
		csr = REG16(pVRIO+PMUINTREG);
		if(csr & POWERSWINTR)
		{
			REG16(pVRIO+PMUINTREG) = POWERSWINTR;
			return TRUE;
		}
		return FALSE;
	}

	bool
	bMouseFound(
		void
		)
	{
	return m_bMouseFound;
	}

	bool
	DataRead(
		unsigned int	port,
		UINT8	*pui8Data
		);


	void
	InterruptEnable(
		unsigned int	port
		);

	void
	EnablePS2Port(
		void
		)
	{
		// SEL1/SEL2 enable.
		REG16(pVRC4173+SELECTREG) |= 0x0006;
		return;
	}

	void
	EnablePS2Clock(
		void
		)
	{
		REG16(pVRC4173+CMU73CLKMSK) |= (MSKPS2CH1|MSKPS2CH2);
		return;
	}

	bool
	MouseTest(
		void
		);



};



#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -