The PS2 Mouse Interface.docx

上传人:b****4 文档编号:6345356 上传时间:2023-05-09 格式:DOCX 页数:16 大小:22.14KB
下载 相关 举报
The PS2 Mouse Interface.docx_第1页
第1页 / 共16页
The PS2 Mouse Interface.docx_第2页
第2页 / 共16页
The PS2 Mouse Interface.docx_第3页
第3页 / 共16页
The PS2 Mouse Interface.docx_第4页
第4页 / 共16页
The PS2 Mouse Interface.docx_第5页
第5页 / 共16页
The PS2 Mouse Interface.docx_第6页
第6页 / 共16页
The PS2 Mouse Interface.docx_第7页
第7页 / 共16页
The PS2 Mouse Interface.docx_第8页
第8页 / 共16页
The PS2 Mouse Interface.docx_第9页
第9页 / 共16页
The PS2 Mouse Interface.docx_第10页
第10页 / 共16页
The PS2 Mouse Interface.docx_第11页
第11页 / 共16页
The PS2 Mouse Interface.docx_第12页
第12页 / 共16页
The PS2 Mouse Interface.docx_第13页
第13页 / 共16页
The PS2 Mouse Interface.docx_第14页
第14页 / 共16页
The PS2 Mouse Interface.docx_第15页
第15页 / 共16页
The PS2 Mouse Interface.docx_第16页
第16页 / 共16页
亲,该文档总共16页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

The PS2 Mouse Interface.docx

《The PS2 Mouse Interface.docx》由会员分享,可在线阅读,更多相关《The PS2 Mouse Interface.docx(16页珍藏版)》请在冰点文库上搜索。

The PS2 Mouse Interface.docx

ThePS2MouseInterface

ThePS/2MouseInterface

Source:

http:

//www.Computer-Engineering.org

Author:

AdamChapweske

LastUpdated:

04/01/03

LegalInformation:

Allinformationwithinthisarticleisprovided"asis"andwithoutanyexpressorimpliedwarranties,including,withoutlimitation,theimpliedwarrantiesofmerchantibilityandfitnessforaparticularpurpose. 

Thisarticleisprotectedundercopyrightlaw. Thisdocumentmaybecopiedonlyifthesource,author,date,andlegalinformationisincluded.

Abstract:

ThisarticleattemptstoexplaineveryaspectofthePS/2mouseinterfaceincludingthephysicalandelectricalinterface,low-levelprotocol,modesofoperation,commands,andextensions. AllcodesamplesinvolvingthemouseencoderarewritteninassemblyforMicrochip'sPICmicrocontrollers. Allcodesamplesrelatedtotheauxiliarydevicecontroller(keyboardcontroller)arewritteninx86assembly

GeneralDescription:

TherearemanytypesofpointingdevicesavailableformodernPCs,includingmice,trackballs,touchpads,electronicwhiteboards,etc. Virtuallyallofthesepointingdevicescommunicatewithacomputerusingoneoftwointerfaces:

UniversalSerialBus(USB)orthePS/2MouseInterface. Seethefollowingtableforacomparison:

USB(v1.1)

 PS/2MouseInterface

NumberofDevicesSupported

Upto127

One

MaximumDataRate

12Mbps

40kbps

Power(max)

5V@500mA

5V@100mA

Hot-Pluggable?

Yes

No

Documentation

Well-documented:

http:

//www.usb.org

Out-of-print

(IBMTechReference)

OlderpointingdeviceinterfacesincludetheAppleDesktopBus(ADB),RS-232serialport,andthebusmouseinterface. Theseareobsoleteandarenotcoveredinthisarticle.

ThePS/2mouseinterfaceoriginallyappearedinIBM's"PersonalSystem/2"computersinthelate80's. Itstillremainsawidely-supportedinterfaceforthesakeofconstantlymaintainingbackwardcompatibility. However,USBhasquicklycaughtontheselastfewyearsandwilleventuallyreplacethePS/2mouseinterfaceentirely.

ThePS/2mouseinterfaceusesabidirectionalserialprotocoltotransmitmovementandbutton-positiondatatothecomputer'sauxiliarydevicecontroller(keyboardcontroller). Thecomputer,inturn,maysendanumberofcommandstothemousetosetthereportrate,resolution,resetthemouse,disablethemouse,etc. Thecomputeralsoprovidesthemousewithanoverload-protected5Vpowersupply.

ElectricalInterface/Protocol:

ThePS/2mouseusesthesameprotocolasthePS/2keyboard(akaATkeyboard). Clickherefordetailedinformationonthisprotocol.

Inputs,Resolution,andScaling:

ThestandardPS/2mouseinterfacesupportsthefollowinginputs:

X(right/left)movement,Y(up/down)movement,leftbutton,middlebutton,andrightbutton.Themousereadstheseinputsataregularfreqencyandupdatesvariouscountersandflagstoreflectmovementandbuttonstates. TherearemanyPS/2pointingdevicesthathaveadditionalinputsandmayreportdatadifferentlythandescribedinthisdocument. OnepopularextensionIcoverlaterinthisdocumentistheMicrosoftIntellimouse,whichincludessupportforthestandardinputsaswellasascrollingwheelandtwoadditionalbuttons.

Thestandardmousehastwocountersthatkeeptrackofmovement:

theX-movementcounterandtheY-movementcounter. These are9-bit2'scomplementvaluesandeachhasanassociatedoverflowflag. Theircontents,alongwiththestateofthethreemousebuttons,aresenttothehostintheformofa3-bytemovementdatapacket(asdescribedinthenextsection.) Themovementcountersrepresenttheamountofmovementthathasoccurredsincethelastmovmentdatapacketwassenttothehost(ie,theydonotrepresentabsolutepositions.)

Whenthemousereadsitsinputs,itrecordsthecurrentstateofitsbuttonsandchecksformovement.Ifmovementhasoccurreditincrements(for+Xor+Ymovement)ordecrements(for-Xor-Ymovement)itsXand/orYmovementcounters.Ifeitherofthecountershasoverflowed,itsetstheappropriateoverflowflag.

Theparameterthatdeterminestheamountbywhichthemovementcountersareincremented/decrementedistheresolution.Thedefaultresolutionis4counts/mmandthehostmaychangethatvalueusingthe"SetResolution"(0xE8)command.

Thereisaparameterthatdoesnoteffectthemovementcounters,butdoeseffectthereported

(1)valueofthesecounters. Thisparameterisscaling. Bydefault,themouseuses1:

1scaling,whichhasnoeffectonthereportedmousemovement. However,thehostmayselect2:

1scalingbysendingthe"SetScaling2:

1"(0xE7)command. If2:

1scalingisenabled,themousewillapplythefollowingalgorithmtothecountersbeforesendingtheircontentstothehost:

MovementCounter

ReportedMovement

0

0

1

1

2

1

3

3

4

6

5

9

N>5

2*N

MovementDataPacket:

ThestandardPS/2mousesendsmovement/buttoninformationtothehostusingthefollowing3-bytepacket(4):

 

Byte1 

Bit7

Bit6

Bit5

Bit4

Bit3

Bit2

Bit1

Bit0

Yoverflow

Xoverflow

Ysignbit

Xsignbit

Always1

MiddleBtn

RightBtn

LeftBtn

Byte2

XMovement

Byte3 

YMovement

Themovementcountersare9-bit2'scomplementintegers,wherethemostsignificantbitappearsasasignbitinByte1ofthemovementdatapacket.Thesecountersareupdatedwhenthemousereadsitsinputandfindsmovementhasoccurred.Theirvalueistheamountofmovementthathasoccurredsincethelastmovementdatapacketwassenttothehost(ie,afterapacketissenttothehost,themovementcountersarereset.)Therangeofvaluesthatcanbeexpressedbythemovementcountersis-255to+255.Ifthisrangeisexceeded,theappropriateoverflowbitisset.

AsImentionedearlier,themovementcountersareresetwheneveramovementdatapacketissuccessfullysenttothehost.Theyarealsoresetafterthemousereceivesanycommandfromthehostotherthanthe"Resend"(0xFE)command.

ModesofOperation:

Datareportingishandledaccordingtothemodeinwhichthemouseisoperating. Therearefourstandardmodesofoperation:

 

∙Reset-ThemouseentersResetmodeatpower-uporafterreceivingthe"Reset"(0xFF)command. 

∙Stream-Thisisthedefaultmode(afterResetfinishesexecuting)andisthemodeinwhichmostsoftwareusesthemouse. IfthehosthaspreviouslysetthemousetoRemotemode,itmayre-enterStreammodebysendingthe"SetStreamMode"(0xEA)commandtothemouse. 

∙Remote-Remotemodeisusefulinsomesituationsandmaybeenteredbysendingthe"SetRemoteMode"(0xF0)commandtothemouse. 

∙Wrap-Thismodeisn'tparticularlyusefulexceptfortestingtheconnectionbetweenthemouseanditshost. Wrapmodemaybeenteredbysendingthe"SetWrapMode"(0xEE)commandtothemouse. ToexitWrapmode,thehostmustissuethe"Reset"(0xFF)commandor"ResetWrapMode"(0xEC)command. Ifthe"Reset"(0xFF)commandisrecieved,themousewillenterResetmode. Ifthe"ResetWrapMode"(0xEC)commandisreceived,themousewillenterthemodeitwasinpriortoWrapMode.

(Note:

Themousemayalsoenter"extended"modesofoperation,asdescribedlaterinthisdocument. However,thisisnotafeatureofthestandardPS/2mouse.)

ResetMode:

Themouseentersresetmodeatpower-onorinresponsetothe"Reset"(0xFF)command.Afterentringthismode,themouseperformsadiagnosticself-testreferredtoasBAT(BasicAssuranceTest)andsetsthefollowingdefaultvalues:

∙SampleRate=100samples/sec

∙Resolution=4counts/mm

∙Scaling=1:

1

∙DataReportingDisabled

ItthensendsaBATcompletioncodeofeitherAAh(BATsuccessful)orFCh(Error).Thehost'sresponsetoacompletioncodeotherthanAAhisundefined.

FollowingtheBATcompletioncode(AAhorFCh),themousesendsitsdeviceIDof00h.Thisdistinguishesitfromakeyboard,oramouseinanextendedmode.IhavereaddocumentssaythingthehostisnotsupposedtotransmitanydatauntilitreceivesadeviceID. HoweverI'vefoundthatsomeBIOS'swillsendthe"Reset"commandimmediatelyfollowingthe0xAAreceivedafterapower-onreset.

AfterthemousehassentitsdeviceIDtothehost,itwillenterStreamMode. Notethatoneofthedefaultvaluessetbythemouseis"DataReportingDisabled". Thismeansthemousewillnotissueanymovementdatapacketsuntilitreceivesthe"EnableDataReporting"command.

StreamMode:

Instreammode,themousesendsmovementdatawhenitdetectsmovementorachangeinstateofoneormoremousebuttons.Themaximumrateatwhichthisdatareportingmayoccurisknownasthesamplerate. Thisparameterrangesfrom10samples/secto200samples/sec.Itsdefaultvalueis100samples/secandthehostmaychangethatvaluebyusingthe"SetSampleRate"command. Streammodeisthedefaultmodeofoperationfollowingreset.

RemoteMode:

Inthismodethemousereadsitsinputsandupdatesitscounters/flagsatthecurrentsamplerate,butitdoesnotautomaticallyissuedatapacketswhenmovementhasoccured. Instead,thehostmustpollthemouseusingthe"ReadData"command. Uponreceivingthiscommandthemousewillsendasinglemovementdatapacketandresetitsmovementcounters.

WrapMode:

Thisisan"echoing"modeinwhicheverybytereceivedbythemouseissentbacktothehost.Evenifthebyterepresentsavalidcommand,themousewillnotrespondtothatcommand--itwillonlyechothatbytebacktothehost.Therearetwoexceptionstothis:

the"Reset"commandand"ResetWrapMode"command.Themousetreatstheseasvalidcommandsanddoesnotechothembacktothehost.

IntellimouseExtensions:

Apopularextensiontot

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 考试认证 > 交规考试

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2