pl050port.hpp
来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· HPP 代码 · 共 186 行
HPP
186 行
/* -*-C-*-
*
* $Revision: 1.3 $
* $Author: kwelton $
* $Date: 2000/06/14 03:38:22 $
*
* pl050kbd:
*
* Keyboard driver for PrimeCell Keyboard PS/2 port as implemented on
* an Integrator board. This is heavily based upon (i.e. has the same
* public class interface as) the Microsoft driver from the HARP code
* drop.
*
* 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
* Copyright (c) 2000 ARM Limited
* All Rights Reserved
*/
#ifndef integrator_pl050port_hpp
#define integrator_pl050port_hpp
#include <windows.h>
#include "ringbuf.hpp"
extern "C"
{
void SetLock(bool *lock);
bool ClearLock(bool *lock);
}
typedef enum
{
pl050PortNone,
pl050PortKbd,
pl050PortMouse
} pl050PortType;
typedef unsigned int pl050ISRUpcall(bool timedout, unsigned int scancode);
class pl050Port
{
unsigned int portbase;
unsigned int portintr;
pl050PortType porttype;
int nLocks;
bool intelliMouseFound;
bool irqsenabled;
RingBuf commands;
bool awaitingACK;
bool parityfailed;
bool commandslocked;
pl050ISRUpcall *portupcall;
inline unsigned char pl050read(unsigned int base)
{
return (unsigned char)(*((volatile unsigned int *)base) & 0xff);
}
inline void pl050write(unsigned int base, unsigned int value)
{
*((volatile unsigned int *)base) = value;
return;
}
inline unsigned char readCR(void)
{
return pl050read(portbase + 0x00);
}
inline unsigned char readSTAT(void)
{
return pl050read(portbase + 0x04);
}
inline unsigned char readDATA(void)
{
return pl050read(portbase + 0x08);
}
inline unsigned char readCLKDIV(void)
{
return pl050read(portbase + 0x0c);
}
inline unsigned char readIIR(void)
{
return pl050read(portbase + 0x10);
}
inline void writeCR(unsigned int value)
{
pl050write(portbase + 0x00, value);
}
inline void writeSTAT(unsigned int value)
{
pl050write(portbase + 0x04, value);
}
inline void writeDATA(unsigned int value)
{
pl050write(portbase + 0x08, value);
}
inline void writeCLKDIV(unsigned int value)
{
pl050write(portbase + 0x0c, value);
}
unsigned int selfTest(void);
int readPort(void);
bool writePort(unsigned int value);
bool pollACKCommand(unsigned int cmd);
bool pollOneShotCommand(unsigned int cmd);
bool irqACKCommand(unsigned int cmd);
bool irqOneShotCommand(unsigned int cmd);
void autodetect(void);
bool interruptEnable(void);
void setModeIntelliMouse(void);
unsigned char mouseId(void);
public:
bool Initialise(unsigned int baseaddr, unsigned int sysintr);
void OpenPort(void);
void ClosePort(void);
inline bool KbdFound(void)
{
return porttype == pl050PortKbd;
}
inline bool MouseFound(void)
{
return porttype == pl050PortMouse;
}
inline bool IntelliMouseFound(void)
{
return intelliMouseFound;
}
bool KeyboardReset(void);
void KeyboardLights(unsigned int fLights);
void KeyboardMode(unsigned int mode);
bool DataRead(UINT8 *pui8Data);
inline void SetISRUpcall(pl050ISRUpcall *upcall)
{
portupcall = upcall;
}
void ISRLoop(unsigned int timeout);
inline bool ACKCommand(unsigned int cmd)
{
return irqsenabled ? irqACKCommand(cmd) : pollACKCommand(cmd);
}
inline bool OneShotCommand(unsigned int cmd)
{
return irqsenabled ? irqOneShotCommand(cmd) : pollOneShotCommand(cmd);
}
};
#endif /* ndef integrator_pl050port_hpp */
/* EOF pl050port.hpp */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?