11
PS/2 Firmware Description
A function call map for PS/2 operation is shown in Figure
7. The following are descriptions of the functions in
Adns-
3080.asm
PS/2 Functions
PS2Main
– Initializes the PS/2 related parameter to their
default state, enables the serial interface and sends a
BAT code (AAh followed by 00h) to the host. After the
initialization, the program goes into the infi nite
PS2Task-
Loop
loop.
PS2TaskLoop
– This function spins in an infi nite loop waiting
for an event that needs servicing. The
ProcessButtons
and
ReadProcessOptics
functions are called within this loop to
retrieve any new motion or button information. The data
received from these functions will be loaded into the
endpoint 1 buff er to be sent to the host.
PS2BAT
– delays for 500 milliseconds, then sends the AAh
followed by 00h initialization string to the host for the
PS/2 Basic Assurance Test.
PS2SendResponseByte
– Sends a response byte (ACK, ERROR,
RESEND) to the host.
PS2Send
– This routine sends a byte to the host according
to the standard PS/2 protocol. This routine calls
send_0
and
send_1
routines that shift the bits out serially over
the PS/2 interface.
PS2Receive
– This routine receives a byte from the host ac-
cording to the standard PS/2 protocol. This routine calls
the
GetBit
function to clocks each bit in.
PS2Resend
– A copy of the last transmission is always left
intact in the message buff er. To re-send it, this routine
simply resets the message length.
PS2SetDefault
– This routine is called in response to a SET
DEFAULT command from the host. It then sets the mouse
parameters to the default settings.
PS2DisableMouse
– Disables the mouse.
PS2EnableMouse
– Enables the mouse.
PS2SetSampleRate
– This routine is called in response to a
SET SAMPLE RATE command from the host. It then veri-
fi es that the requested sample rate is valid and sets the
sample rate for the mouse. Valid sample rates are defi ned
in the PS/2 Mouse specifi cation.
PS2ReadDeviceType
– This routine is called in response to a
READ DEVICE TYPE request from the host. This mouse
always sends a 0x00 in response to this request.
PS2SetRemoteMode
– This routine is called in response to a
SET REMOTE MODE command from the host. The PS/2
mode is then set to remote mode.
PS2SetWrapMode
– This routine is called in response to a SET
WRAP MODE command from the host. It then sets the
mouse mode to wrap mode. See the PS/2 specifi cation
for more details on wrap mode.
PS2ResetWrapMode
- This routine is called in response to a
RESET WRAP MODE command from the host. The mode
is then reset to the previous mode. According to the IBM
PS/2 specifi cation, if stream mode is enabled, the mouse
is disabled when the wrap mode is reset.
PS2ReadData
– This routine is called in response to a READ
DATA command from the host. This routine then sends a
mouse packet in response to the command.
PS2SetStreamMode
– This routine is called in response to
a SET STREAM MODE command from the host. Stream
mode is then enabled. See the PS/2 specifi cation for more
information about stream mode.
PS2StatusRequest
– This routine is called in response to a
STATUS REQUEST command from the host. A three byte
report is sent to the host in response to this request. See
the PS/2 mouse specifi cation for more details.
PS2SetResolution
– This routine is called in response to a SET
RESOLUTION command from the host. Set Resolution is
a two byte command; the 2nd byte being the resolution
itself. This routine is called after reception of the fi rst byte,
and so does nothing by itself.
PS2SetScaling
– This routine is called in response to a SET
SCALING command from the host. Scaling then changes
to 2:1.
PS2ResetScaling
– This routine is called in response to a
RESET SCALING command from the host. The scaling is
then reset back to 1:1.
PS2GetHostByte(void)
– This routine checks to see if the host
is requesting to send data, and if so, it clocks in a data
byte from the host. The function returns the received
byte in the accumulator and implicitly clears the carry to
0 if the reception occurred without errors.
PS2DoCommand
– This routine dispatches the received PS/2
command byte to the proper handler.
LoadMousePacket
– This routine formats a mouse packet
according to the PS/2 Mouse specifi cation and loads it
to the buff er.
PS2SendNextByte
– This routine sends the next byte in buff er
to the host.
ResetMouseReportInterval
– This routine resets the mouse
report interval to the value last sent by the host. The
report interval is counted down in the main loop to
provide a time base for sending mouse data packets.