8
2. Device Confi guration
During this time the host will set the standard PS/2 param-
eters such as scaling, resolution, stream mode; enabling
stream mode for data reports. For a list of valid PS/2 com-
mands the mouse recognizes, see Appendix G.
3. Wheel Enable (optional)
Since the wheel is not part of the standard PS/2 specifi ca-
tion, there is a sequence of commands that enable the
wheel. Wheel-aware drivers, such as those for Microsoft
and Linux operating systems will initiate this special
sequence.
After the following sequence of commands, the wheel
report format is enabled.
0xF3, 0xC8 Set Sampling Rate 200 per second
0xF3, 0x64 Set Sampling Rate 100 per second
0xF3, 0x32 Set Sampling Rate 50 per second
0xF2, 0x03 Read Device Type returns a value of 0x03
After the Read Device Type command returns 0x03,
indicating this is a Microsoft compatible three button
wheel mouse, the wheel report format is enabled. See
Appendix G for information on PS/2 standard and wheel
reporting formats.
4. Post Start Up Operation
After the streaming mode is set and data reports are
enabled, the mouse will send button, movement, and
optionally, wheel reports back to the host. Whenever the
mouse has new data to send it will initiate a transfer to
the host.
USB Firmware Description
A function call map for USB operation is shown in Figure
6. Following are descriptions of the functions in
adns-
3080.asm.
Dual USB and PS2 Functions
GetMouseType
– called in dualMain when the mouse is fi rst
plugged into the PC. This routine returns the interface of
the mouse. The following sequences are performed by
the micro-controller to determine the mouse type.
- Delay 50mS.
- Initialize the PS2 BAT delay counter.
- For a period of 2ms, poll the SCLK and SDATA lines
every 10μs. If we get 4 samples in a row with non-
zero data on either line, detect a PS2 interface. If 2mS
expires, enable the USB pull up resistor and delay
500μS.
- Poll the SCLK and SDATA lines indefi nitely until a non-
zero condition exists on either line. During this polling
period, we begin to count down the PS2 BAT delay.
- If SCLK(D+) is sampled high, detect a PS2 interface.
If SDATA(D-) sampled high, disable the USB connect
resistor and Delay 100μS.
- If D+ and D- are both 0, detect a USB interface, else
detect a PS2 interface.
SPIInit
– This routine is called in the
try_download
to
enable the SPI interface. The CY7C63743-PXC is always
confi gured as a Master to drive the serial clock on P0.7.
The clock is set to HIGH in idle state, and the SCLK fre-
quency is set to send a bit rate of 1Mbit/s.
SensorReset
– This routine resets the serial interface and
the ADNS-3080 internal registers by generating a pulse
on the RESET pin.
LoadSROM
–
called in
try_download
after the initialization of
the SPI interface. This routine is used to load the SROM
(Shadow ROM) firmware into the ADNS-3080 optical
sensor. It should be called after
SensorReset
.
ProcessButtons
– This routine is called within the infi nite
loop of
usbTaskLoop
and
ps2TaskLoop
. The state of the
buttons is updated every one ms in the
Dual1msTimer
Interrupt Service Routine (ISR). This routine compares the
current state of the buttons with their last state to detect
any changes in the status. If the status of these buttons
remains until the expiration of debounce timer (15ms),
the new button state is confi rmed. This routine will record
the new button state in the
[buttonValue]
variable which
will be reported to the host in the main loop.
ReadProcessOptics
– This routine returns any updates in the
X, Y and Z-wheel motion information. The motion of the
Z-wheel is detected using the traditional method by
decoding the quadrature signal generated by the pho-
totransistors. The X and Y directions of the movement
are obtained by calling the
ReadDeltaX
and
ReadDeltaY
routines. The X, Y, and Z-wheel movement is stored in
the
[xCount], [yCount],
and
[zCount]
variables which will
be sent to the host in the main routine. The 1600cpi is
activated in this routine by writing to the Confi guration
Register 0x0a with LED_MODE_1600.
ReadMotionReg
– Reads the ADNS-3080 Motion register.
The data returned from this register will be used to deter-
mine if any motion has occurred or if any fault condition
exists.
ReadDeltaX
– Reads the ADNS-3080 Delta_X register for the
X movement. Calls the
ReadSPI
routine to enable the SPI
interface and perform reading operations through the
four-wire serial interface. Any new X motion information
is added to the
[xCount]
variable.