Avago ADNK-6003 Guide

ADNK-6003
Optical Mouse Designer’s Kit
Design Guide
Introduction
The Universal Serial Bus (USB) is an industry standard serial
interface between a computer and peripherals such as
a mouse, joystick, keyboard, UPS, etc. This design guide
describes how a cost-eective USB-PS/2 optical mouse can
be built using the Cypress Semiconductor CY7C63743-PXC
USB microcontroller and the Avago ADNS-6000 optical
sensor. The document starts with the basic operations of a
computer mouse peripheral followed by an introduction
to the CY7C63743-PXC USB microcontroller and the Avago
Technologies ADNS-6000 Optical Navigation Sensor. A
schematic of the CY7C63743-PXC USB microcontroller to
the ADNS-6000 optical sensor and buttons of a standard
mouse can be found in Appendix A. The software section
of this application note describes the architecture of the
rmware required to implement the USB and PS/2 mouse
functions. The CY7C63743-PXC data sheet is available from
the Cypress web site at www.cypress.com . The ADNS-6000
data sheet is available from the Avago web site at www.
semiconductor.Avago.com. USB documentation can be
found at the USB Implementers Forum web site at www.
usb.org.
ADNB-6001 laser mouse bundle set is the world’s rst
laser-illuminated navigation system. With laser navigation
technology, the mouse can operate on many surfaces that
prove dicult for traditional LED-based optical navigation.
Its high-performance architecture is capable of sensing
high-speed mouse motion — velocities up to 20 inches
per second and accelerations up to 8g.
The ADNS-6000 sensor along with the ADNS-6120 lens,
ADNS-6220 clip and ADNV-6330 laser diode form a
complete and compact laser mouse tracking system. There
are no moving parts, which means high reliability and
less maintenance for the end user. In addition, precision
optical alignment is not required, facilitating high volume
assembly.
Optical Mouse Basics
The optical mouse measures changes in position by
optically acquiring sequential surface images (frames), and
mathematically determining the direction and magnitude
of movement. The Z-wheel movement is done in the
traditional method by decoding the quadrature signal
generated by optical sensors. This design guide shows
how to connect to and manage a standard conguration
of mouse hardware, as well as handle the USB and PS/2
protocols. Each of these protocols provides a standard
way of reporting mouse movement and button presses
to the PC.
Downloaded from Elcodis.com electronic components distributor

2
Figure 1. CY7C63743-PXC –ADNS-6000 Optical Mouse Hardware Block Diagram
Left Button
Agilent ADNS-6000
optical mouse sensor
Wheel Button
Right Button
Z Optics
Cypress
CY7C63743-PXC
enCoRe
USB Controller
USB/PS2 Interface
MISO
MOSI
SCLK
NCS
D+/D-
SCLK/SDATA
VREG
1.3 k Ohm
Introduction to the CY7C63743-PXC
The CY7C63743-PXC is an 8-bit RISC microcontroller with
an integrated USB Serial Interface Engine (SIE). The archi-
tecture executes general-purpose instructions that are
optimized for USB applications. The CY7C63743-PXC has a
built-in clock oscillator and timers as well as programmable
drive strength and pull-up resistors on each I/O line. High
performance, low-cost human interface type computer pe-
ripherals can be implemented with a minimum of external
components and rmware eort.
Serial Peripheral Interface (SPI)
The CY7C63743-PXC provides a SPI compatible interface.
The SPI circuit supports byte serial transfer in either
Master or Slave mode. The integrated SPI circuit allows
the CY7C63743-PXC to communicate with external SPI
compatible hardware, in this case the ADNS-6000.
Hardware Implementation
The standard hardware to implement a mouse is shown in
Figure 1. For X and Y movement, the optical sensor is used.
The Z- wheel movement is detected by a set of optical
sensors that output quadrature signals. For each button
there is a switch that is pulled up internally by the built in
pull up resistors. The D - line is pulled up via a 1.3k ohm
resistor connected to the VREG pin.
Firmware Congurable GPIO
The reference rmware is congured to use the GPIO pins
as shown on the schematic in Appendix A. However, it
may be more optimal to use a dierent I/O conguration
to meet the mechanical constraints of PCB design. The
reference rmware is designed to be easily congured
to another set of pin connections. This is accomplished
through changes in the I/O denitions at the beginning
of the adns-6000.asm listing. The following statements are
the pin denitions as they exist today. The rmware will
use these denitions to read and congure the GPIO pins,
without any other modications.
Communications between the CY7C63743-PXC and the
ADNS-6000 are done through the integrated SPI interface.
The serial port cannot be activated while the chip is in
power down mode (NPD low) or reset (RESET high). When
the SPI is enabled thru P0.4 (NCS), the P0.7 (SCLK), P0.6
(MISO), and P0.5 (MOSI) GPIO pins serve special functions
to enable the SPI interface to talk with external hardware.
During normal operation, the CY7C63743-PXC SPI is always
congured as a Master to output the serial clock on P0.7.
Therefore, the USB microcontroller always initiates com-
munication. Data sent by the ADNS-6000 optical sensor is
received on the P0.6 (MISO), and data is shifted out to the
ADNS-6000 through the P0.5 (MOSI). See the schematic in
Appendix A. When writing to the ADNS-6000, the micro-
controller drive both the SCLK and the MOSI lines. When
reading from the ADNS-6000, the microcontroller drives
both the SCLK and MOSI lines initially. After tSRAD delay,
the ADNS-6000 will drive the data via MISO. The microcon-
troller is only driving the SCLK line (outputs SCLK for the
serial interface).
Optical Sensor
Avago’s ADNS-6000 optical sensor is used in this reference
design as the primary navigation engine. This Optical Navi-
gation Technology contains an Image Acquisition System, a
Digital Signal Processor, a two channel quadrature output,
and a four-wire serial port. The CY7C63743-PXC periodi-
cally reads the ADNS-6000’s Delta_X and Delta_Y registers
to obtain any horizontal and vertical motion information
happening as a result of the mouse being moved. The
output of the ADNS-6000 optical sensor is 4-wire serial
port.
Downloaded from Elcodis.com electronic components distributor

3
This motion information will be reported to the PC to
update the position of the cursor. The advantages of using
ADNS-6000 optical sensor are the best tracking accuracy,
exibility of programming the optical sensor via the SPI
port, and the automatic frame rate feature (1000fps to
6400fps). Besides, ADNS-6000 optical sensor performs
excellent tracking on dicult surfaces which conventional
Led based technology is unable to track such as glossy and
smooth surfaces. In addition, Burst mode is another special
serial port operation mode that may be used to reduce the
serial transaction time for three predened operations:
motion read and SROM download and frame capture.
The speed improvement is achieved by continuous data
clocking to or from multiple registers.
Motion Read is activated by reading the Motion_Burst
register. The ADNS-6000 will respond with the contents
of the Motion, Delta_X, Delta_Y, SQUAL, Shutter_Upper,
Shutter_Lower and Maximum_Pixel registers in that order.
SROM download uses Burst Mode to load the Avago-
supplied rmware le contents into the ADNS-6000. The
rmware le is an ASCII text le with each 2-character byte
on a single line. Frame Capture is a fast way to download a
full array of pixel values from a single frame.
To learn more about sensor’s technical information, please
visit the Avago web site at:
http://www.semiconductor.Avago.com
Mouse Optics
The motion of Z-wheel is detected using the traditional
method by decoding the quadrature signal generated by
optical sensors. Two phototransistors are connected in
a source-follower conguration. An infrared LED shines,
causing the phototransistors to turn on. In between the
phototransistors and LED is a pinwheel that turns on the
mouse ball rollers. The fan of this pinwheel is mechanically
designed to block the infrared light such that the photo-
transistors are turned on and o in a quadrature output
pattern. Every change in the phototransistor outputs rep-
resents a count of mouse movement. Comparing the last
state of the optics to the current state derives direction
information. As shown in Figure 2 below, traveling along
the quadrature signal to the right produces a unique set of
state transitions, and traveling to the left produces another
set of unique state transitions. In this reference design, only
the motion at the Z-wheel is detected using this method.
Mouse Buttons
Mouse buttons are connected as standard switches. These
switches are pulled up by the pull up resistors inside the
microcontroller. When the user presses a button, the switch
will be closed and the pin will be pulled LOW to GND. A
LOW state at the pin is interpreted as the button being
pressed. A HIGH state is interpreted as the button has been
released or the button is not being pressed. Normally the
switches are debounced in rmware for 15-20ms. In this
reference design there are three switches: left, Z-wheel,
and right.
USB and PS/2 Connection
The CY7C63743-PXC has a conguration register that
switches control from the SIE to manual control on the
D+ and D- pins. This allows the rmware to dynamically
congure itself to operate as a USB or PS/2 mouse allowing
signaling lines to be shared without using extra GPIO pins
for PS/2 operation. The rmware for this reference design
will automatically detect the host topology (USB or PS/2)
at plug-in and will congure itself for operation on that
bus. If a USB host connection is detected then the rmware
will enable the VREG pin, such that the 1.3k ohm resistor
connected to the D- line can be pulled up to 3.3V. It is this
action that causes the host to recognize that there is a
low-speed USB peripheral attached. The connections for
the connectors are shown in Figure 3 below.
Figure 2. Optics Quadrature Signal Generation
Some details on ADNK-6003
The ADNK-6003 reference design mouse unit allows users
to evaluate the performance of the Optical Tracking Engine
(sensor, lens, LASER assembly clip, LASER) over both a USB
or PS/2 connection, using a Cypress enCoRe USB Control-
ler. This kit also enables users to understand the recom-
mended mechanical assembly. (See Appendix C and D)
System Requirements
PCs using Windows95/ Windows98/ WindowsNT/
Windows2000 with PS/2 port and standard 3-button
USB mouse driver loaded.
Downloaded from Elcodis.com electronic components distributor

4
Figure 3. USB and PS/2 peripheral connectors
Functionality
3-button, scroll wheel mouse.
Operating (For PS/2 Mode)
1. Turn o the PC.
2. Plug the mouse unit’s PS/2 connector into the PC’s
PS/2 port.
3. Turn on the PC. All of the mouse buttons and scroll
wheel will function exactly like a standard PS/2 mouse.
Operating (For USB Mode)
Hot pluggable with USB port. The PC does not need to be
powered o when plugging or unplugging the evaluation
mouse.
To Disassemble the ADNK-6003 Unit
The ADNK-6003 comprises of the plastic mouse casing,
printed circuit board (PCB), lens, buttons, and USB cable.
(See Figure 4.) Unscrewing the one screw located at the
base of the unit can open the ADNK-6003 unit. Lifting and
pulling the PCB out of the base plate can further disas-
semble the mouse unit.
Caution: The lens is not permanently attached to the sensor and will
drop out of the assembly.
Figure 4. Exploded view drawing of optical tracking engine with ADNS-6000 optical mouse sensor.
ADNS-6000 (sensor)
Customer Supplied PCB
ADNS-6120 (lens)*
Customer Supplied Base Plate
With Recommended Features
Per IGES Drawing
Customer Supplied VCSEL PCB
ADNV-6330 (VCSEL)
ADNS-6230-001 (clip)
*or ADNS-6130-001 for trim lens
Downloaded from Elcodis.com electronic components distributor

5
Figure 5. Distance from lens reference plane to surface
While reassembling the components, please make sure
that the Z height (Distance from lens reference plane to
surface) is valid. Refer to Figure 5.
Sensor
Sensor PCB
Lens Surface
VCSEL PCB VCSEL
VCSEL Clip
2.40
0.094
Eye Safety
The ADNS-6000 and the associated components in the
schematic of Figure A1 are intended to comply with
Class 1 Eye Safety Requirements of IEC 60825-1. Avago
Technologies suggests that manufacturers perform
testing to verify eye safety on each mouse. It is also rec-
ommended to review possible single fault mechanisms
beyond those described below in the section “Single
Fault Detection”.
Under normal conditions, the ADNS-6000 generates the
drive current for the laser diode (ADNV-6330). In order
to stay below the Class 1 power requirements, resistor
Rbin must be set at least as high as the value in the bin
table, based on the bin number of the laser diode and
LP_CFG0 and LP_CFG1 must be programmed to ap-
propriate values. Avago recommends using the exact
Rbin value specied in the bin table to ensure sucient
laser power for navigation. The system comprised of the
ADNS-6000 and ADNV-6330 is designed to maintain the
output beam power within Class 1 requirements over
component manufacturing tolerances and the recom-
mended temperature range when adjusted per the
procedure below and when implemented as shown in
the recommended application circuit of Figure A1. For
more information, please refer to Eye Safety Application
Note 5088.
Enabling the SROM
The ADNS-6000 must operate from the externally loaded
programming. This architecture enables immediate
adoption of new features and improved performance al-
gorithms. The external program is supplied by Avago as a
le which may be burned into a programmable device. A
microcontroller with sucient memory may be used. On
power-up and reset, the ADNS-6000 program is download-
ed into volatile memory using the burst-mode procedure
described in the Synchronous Serial Port section. The
program size is 1986 x 8 bits.
For more information, please refer to the ADNS-6000
datasheet.
Regulatory Requirements
Passes FCC B and worldwide analogous emission lim-
its when assembled into a mouse with shielded cable
and following Avago recommendations.
Passes IEC-1000-4-3 radiated susceptibility level when
assembled into a mouse with shielded cable and fol-
lowing Avago recommendations.
Passes EN61000-4-4/IEC801-4 EFT tests when assem-
bled into a mouse with shielded cable and following
Avago recommendations.
UL ammability level UL94 V-0.
Provides sucient ESD creepage/clearance distance
to avoid discharge up to 15kV when assembled into a
mouse according to usage instructions above.
Downloaded from Elcodis.com electronic components distributor

6
LASER Power Adjustment Procedure
1. The ambient temperature should be 25C +/- 5C.
2. Set VDD3 to its permanent value.
3. Ensure that the laser drive is at 100% duty cycle by set-
ting bit 6 of register 0x0A to 0.
4. Program the LP_CFG0 and LP_CFG1 registers to
achieve an output power as close to 506uW as pos-
sible without exceeding it.
Good engineering practices should be used to guarantee
performance, reliability and safety for the product
design.
LASER Output Power
The laser beam output power as measured at the naviga-
tion surface plane is specied below. The following condi-
tions apply:
1. The system is adjusted according to the above proce-
dure.
2. The system is operated within the recommended op-
erating temperature range.
3. The VDD3 value is no greater than 50mV above its
value at the time of adjustment.
4. No allowance for optical power meter accuracy is as-
sumed.
Below is the summary of the components contained in the
ADNK-6003 Designer’s Kit.
Sensor
The sensor technical information is contained in the ADNS-
6000 Data Sheet.
USB Controller
Technical information on the Cypress encore USB control-
ler is contained in the CY7C63743-PXC Data Sheet. The
enclosed“Cypress Lab”CD-ROM contains the development
tools for the CY7C63743-PXC. These tools will allow the
designer to make changes and recompile the source code.
To perform In-Circuit Emulation for easier debugging of
new code development, contact Cypress to purchase the
CY3654 Development Kit and the CY3654-P05 Personality
Board.
Programming support and programmer adaptors for the
Cypress CY7C63743-PXC can be found through Cypress
(CY3649-xxxV + CY3083-SC28 + CY3083-08) or through
most 3rd party programming companies. For further
information on this product, please contact Cypress Semi-
conductor.
Lens
The lens technical information is contained in the ADNS-
6120 Data Sheet. The ange on the standard ADNS-6120
lens is for ESD protection.
LASER Assembly Clip
The information on the assembly clip is contained in the
ADNS-6220 Data Sheet.
LASER
The LASER technical information is contained in the ADNV-
6330 Data Sheet and Application Note AN-5088. Additional
application notes regarding Eye Safety Requirements are
also available at Avago’s website.
Base Plate Feature – IGES File
The IGES file on the CD-ROM provides recommended
base plate molding features to ensure optical alignment.
This includes PCB assembly diagrams like solder xture in
assembly and exploded view, as well as solder plate. See
Appendix D for details.
Reference Design Documentation – Gerber File
The Gerber File presents detailed schematics used in ADNK-
6003 in PCB layout form. See Appendix C for more details.
Overall circuit
A schematic of the overall circuit is shown in Appendix A of
this document. Appendix B lists the bill of materials.
Firmware Implementation
The rmware for this reference design is written in the
Cypress assembly language. The following les are required
to compile the mouse rmware 637xx.inc – the CY7C63743-
PXC I/O registers denition.
adns-6000.asm – main mouse rmware
macros.inc – general macros used with this design
ps2.inc – PS/2 interface constants
usb.inc – USB interface constants
adns-6000_srom_25.inc – SROM rmware
At power up, the rmware examines the host interface and
automatically determines if the mouse is plugged into a
USB or a PS/2 host connection. After the interface type
has been determined, the host rmware congures itself
to operate on the detected interface.
Downloaded from Elcodis.com electronic components distributor

7
USB Interface
All USB Human Interface Device (HID) class applications
follow the same USB start-up procedure. The procedure is
as follows
1. Device Plug-in
When a USB device is rst connected to the bus, it is
powered and running rmware, but communications on
the USB remain non-functional until the host has issued
a USB bus reset.
2. Bus Reset
The pull-up resistor on D– noties the hub that a low
speed (1.5 Mbps) device has just been connected. The
host recognizes the presence of a new USB device and
initiates a bus reset to that device.
3. Enumeration
The host initiates SETUP transactions that reveal general
and device specic information about the mouse. When
the description is received, the host assigns a new and
unique USB address to the mouse. The mouse begins
responding to communication with the newly assigned
address, while the host continues to ask for information
about the device description, conguration descrip-
tion and HID report description. Using the information
returned from the mouse, the host now knows the
number of data endpoints supported by the mouse (2).
At this point, the process of enumeration is completed.
Notes:
1. idVendor should be changed to the value as supplied by the USB-IF
2. idProduct should be assigned for specic product.
3. MaxPower value should be changed as per specic circuit’s current
draw.
4. Post Enumeration Operation
Once communication between the host and mouse is
established, the peripheral now has the task of sending
and receiving data on the control and data endpoints.
In this case, when the host congures endpoint 1, the
mouse starts to transmit button and motion data back
to the host when there is data to send. At any time the
peripheral may be reset or recongured by the host.
USB Requests – Endpoint 0
Endpoint 0 acts as the control endpoint for the host. On
power-up endpoint 0 is the default communication channel
for all USB devices. The host initiates Control- Read and
Control-Write (see Chapter 8 of the USB specication) to
determine the device type and how to congure com-
munications with the device. In this particular design,
only Control-Read transactions are required to enumerate
a mouse. For a list of valid requests see Chapter 9 of the
USBG specication. In addition to the standard “Chapter
9” requests, a mouse must also support all valid HID class
requests for a mouse.
USB Requests – Endpoint 1
Endpoint 1 is the data transfer communications channel for
mouse button, wheel, and movement information. Requests
to this endpoint are not recognized until the host congures
endpoint 1. Once this endpoint is enabled, then interrupt
IN requests are sent from the host to the mouse to gather
mouse data. When the mouse is left idle (i.e. no movement,
no new button presses, no wheel movement) the rmware
will NAK requests to this endpoint. Data is only reported
when there is a status change with the mouse.
Two HID report formats are used in this design. The boot
protocol, as dened by the HID specication, is the default
report protocol that all USB enabled systems understands.
The boot protocol has a three-byte format, and so does not
report wheel information. The HID report descriptor denes
the report protocol format. This format is four bytes and is
the same as the report format with the exception of the
fourth byte, which is the wheel information. Appendix F of
this document lists the USB Data Reporting Format.
PS/2 Interface
The host driver determines the PS/2 mouse start up
sequence. However, a few standard commands must be
sent in order to enable all PS/2 mice. The mouse is the clock
master on this bus. The host must request the mouse to
clock data into itself.
1. Device Plug-in
When a PS/2 mouse is rst connected to the bus, it is
powered and is running rmware. PS/2 communications
generally begin with the host sending a RESET command
to the mouse. The mouse will not report button, wheel, or
movement back to the host until the ENABLE command
is sent. Depending on the particular operating system the
mouse is used with, the start up sequence will vary.
Downloaded from Elcodis.com electronic components distributor

8
2. Device Conguration
During this time the host will set the standard PS/2 pa-
rameters such as scaling, resolution, stream mode, and
eventually enabling stream mode for data reports. For a
list of the valid PS/2 commands that this mouse recognizes
see Appendix G.
3. Wheel Enable (optional)
Since the wheel is not part of the standard PS/2 specica-
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 to
indicate that 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.
The following are descriptions of the functions in adns-6000.
asm.
Dual USB and PS2 Functions
GetMouseType – called in dualMain when the mouse is rst
plugged into the PC. This routine returns the interface of
the mouse. The following sequences are performed by
the microcontroller 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 10us. 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 500uS. Poll the SCLK and SDATA lines
indenitely 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 100uS. 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 congured
as a Master to drive the serial clock on P0.7. The clock is set
to HIGH in idle state, and the SCLK frequency is set to send
a bit rate of 1Mbit/s.
SensorReset – This routine resets the serial interface and the
ADND-6000 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-6000 optical
sensor. It should be called after SensorReset.
AdjustLASER - called to calibrate the laser to the required
506uW. This will ensure that the LASER meets Class 1 eye
safety. Customer must ensure that the correct LP_CFG0
and LP_CFG1 register values are written into the registers
for proper LASER operation.
ProcessButtons – This routine is called within the innite us-
bTaskLoop and ps2TaskLoop loops. The state of the buttons
are 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 change of the buttons
remains until the expiration of debounce timer (15ms), the
new button state is conrmed. 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.
Downloaded from Elcodis.com electronic components distributor

9
ReadMotionReg – Reads the ADNS-6000 Motion register. The
data returned from this register will be used to determine if
any motion has occurred or if any fault condition exists.
ReadDeltaX – Reads the ADNS-6000 Delta_X register for the
X movement. Calls the ReadSPI routine to enable the SPI
interface and perform reading operations through the
two wire serial interface. Any new X motion information is
added to the [xCount] variable.
ReadDeltaY – Reads the ADNS-6000 Delta_Y register for the
Y movement. Calls the ReadSPI routine to enable the SPI
interface and perform reading operations through the
two wire serial interface. Any new Y motion information is
added to the [yCount] variable.
WriteSPI – Writes to the ADNS-6000 register. A write
operation consists of two bytes. The rst byte contains
the address (7 bits) and has“1” as its MSB. The second byte
contains data. The microcontroller to drive both the SCLK
and the MOSI lines. SPIWriteRoutine is called to carry the
write operation.
ReadSPI – Reads the desired ADNS-6000 registers. A read
operation is composed of two parts. First, the microcon-
troller performs a write to the ADNS-6000, sending the
address of the target register to be read. The microcon-
troller drives both the SCLK and MOSI lines. After tSRAD
delay, the ADNS-6000 will drive the data via MISO. The
microcontroller is only driving the SCLK line (outputs SCLK
for the serial interface). SPIWriteRoutine is called to carry
the write operation.
SPIWriteRoutine – Writes the data to be transmitted onto the
SPI pins.
CheckProductID – This function checks the product ID of the
sensor chip being used. The ID returned should match with
the ADNS-6000’s ID.
GetButtons – Returns the current state of the buttons.
USB Functions
usbMain – This routine initializes the USB related parameters
and enables VREG to signal the host that the mouse has
been connected. The program then goes to the usbTask-
Loop .
usbTaskLoop – This function spins in an innite 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 buer to be sent to the host.
ep0SetupReceived – This routine is entered whenever a SETUP
packet is received in on endpoint 0. It parses the packet
and calls the appropriate routine to handle the packet.
ep0InReceived – This routine is entered whenever an IN
packet is received on endpoint 0.
ep0OutReceived – This routine is entered whenever an OUT
packet is received on endpoint 0.
setDeviceConguration – This routine is entered when a SET
CONFIGURATION request has been received from the
host.
setDeviceAddress – This routine is entered whenever a SET
ADDRESS request has been received. The device address
change cannot actually take place until after the status
stage of this no-data control transaction, so the address is
saved and a ag is set to indicate that a new address was
just received. The code that handles IN transactions will
recognize this and set the address properly.
getDescriptor – This routine is entered when a GET DESCRIP-
TOR request is received from the host. This function
decodes the descriptor request and sends the proper
descriptor.
setInterfaceIdle – This routine is entered whenever a SET
IDLE request is received. See the HID specication for the
rules on setting idle periods. This function sets the HID idle
time. See the HID documentation for details on handling
the idle timer.
setInterfaceProtocol – This routine is entered whenever a SET
PROTOCOL request is received. This no-data control trans-
action enables boot or report protocol.
getInterfaceReport – This routine is entered whenever a GET
REPORT request is received.
getInterfaceIdle – This routine is entered whenever a GET IDLE
request is received. This function then initiates a control-
read transaction that returns the idle time. See the HID
class documentation for more details.
getInterfaceProtocol – This routine is entered whenever a GET
PROTOCOL request is received. This request initiates a
control-read transaction that tells the host if the mouse is
congured for boot or report protocol. See the HID class
documentation for more details.
getDeviceConguration – This routine is entered whenever a
GET CONFIGURATION Request is received. This function
then starts a control read transaction that sends the con-
guration, interface, endpoint, and HID descriptors to the
host.
requestNotSupported – Unsupported or invalid descriptor
requests will cause this rmware to STALL these transac-
tions.
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-
6000.asm
Downloaded from Elcodis.com electronic components distributor

10
DualMain
GetMouseType
USB Main PS2 Interface
System
Initialization
USB Initialization
USBTaskLoop
ProcessButtons
ProcessOptics
ReadMotionReg
ReadDeltaX
ReadDeltaY
Read Z Wheel
Load new mouse
packet to EP1
buffer & enable
EP1
Load SROM
AdjustLASER
Figure 6. USB Operation Function Call Map
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 initializa-
tion, the program goes into the innite PS2TaskLoop loop.
PS2TaskLoop – This function spins in an innite 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 buer 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.
Downloaded from Elcodis.com electronic components distributor

11
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
according 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 buer. 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 veries that
the requested sample rate is valid and sets the sample rate
for the mouse. Valid sample rates are dened in the PS/2
Mouse specication.
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 specication 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 specication, 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 specication for more informa-
tion 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 specication 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 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 specication and loads it to
the buer.
PS2SendNextByte – This routine sends the next byte in buer
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.
CheckWheel – This function checks whether the proper
sequence of commands have been issued by the host
to enable the wheel of the mouse. The sequence is three
consecutive setting rate commands of 200, 100 and 80
reports/second.
ApplyResolution(void) – This routine scales the mouse output
by right-shifting the mouse counts to achieve a /2 for each
resolution factor.
void ApplyScaling(void) – This routine scales the mouse output
according to the following to the PS/2 mouse specication,
when scaling is enabled by the host.
send_1 – sends a PS/2 1 bit
send_0 – sends a PS/2 0 bit
GetBit – receives a PS/2 bit from the host
Downloaded from Elcodis.com electronic components distributor

12
ps2Main
PS2 Initialization
ps2TaskLoop
PS2BAT
SetDefault
ps2SendNextByte ProcessOptics PS2DoCommand ProcessButtons GetHostByte LoadMousePacket
HostRequestToSend
PS2Receive
GetBit
send0
ReadMotionReg PS2SendResponseByte
PS2Send
Send_1
Send_0
ResetInterval
PS2SetScaling
SetWrapMode
SetDefault
PS2StatusRequest
SetRemoteMode
CheckWheel
Resend
PS2SetStreamMode
ReadDeviceType
Reset
Enable
ResetWrapMode
Disable
PS2ResetScaling
ReadDeltaX
ReadDeltaY
Read Z Wheel
HostRequestToSend
PS2HostINhibit
PS2Send
Send_1
Send_0
Figure 7. PS/2 Operation Function Call Map
Downloaded from Elcodis.com electronic components distributor

13
SET RESOLUTION Command
The SET RESOLUTION command is conditionally enabled
by the statement“#dene ENABLE_RESOLUTION”. On most
systems this command is not supported. If you wish to
disable this command in the rmware, comment out the
aforementioned statement.
SET SCALING Command
The SET SCALING command is conditionally enabled
by the statement “#dene ENABLE_SCALING”. On most
systems this command is not supported. If you wish to
disable this command in the rmware, comment out the
aforementioned statement.
Interrupt Service Routines (ISR)
The CY7C63743-PXC features 12 dierent sources of inter-
rupts. There are only four ISRs implemented in this applica-
tion. If an interrupt is enabled and the conditions for the
interrupts are met, the microcontroller will generate an
interrupt. Upon servicing the interrupt, the hardware will
rst disable all interrupts by clearing the Global Interrupt
Enable bit. This is followed by an automatic CALL instruc-
tion to the ROM address of the interrupt being serviced
in the Interrupt Vector. The instruction in the Interrupt
Vector is typically a JMP instruction to the Interrupt Service
Routine (ISR). A RETI or RET instruction at the end of the ISR
brings the program counter (PC) back to the location prior
to the interrupt (POR and USB Bus Reset are exceptions).
DualMain – When power is rst applied to the CY7C63743-
PXC, a Power On Reset (POR) occurs; the microcontroller
starts executing code from address 0x00. This is a JMP
instruction to the DualMain routine. This routine initial-
izes the program stack pointer (PSP), data stack pointer
(DSP), ram variables, and the GPIO pins. This routine calls
GetMouseType which returns the interface of the mouse.
If a USB interface is detected, the program jumps to the
usbMain loop. Otherwise, the program goes to the ps2Main
loop.
DualUsbBusReset_ps2Error – The USB-PS2 Interrupt Mode bit
in the USB Status and Control Register is defaulted to
“0”, or USB mode. This indicates that the USB Bus Reset
interrupt will be generated if the SE0 condition (D+ and
D- are both LOW) exists for 256us. This ISR enables the USB
Device Address, sets up the endpoint modes and jumps to
usbMain for the USB initialization.
Dual1msTimer – This ISR reads the current status of the
buttons. Therefore, every one millisecond the button
state is updated; the button status information will be
used by the ProcessButtons function at a later time. This
ISR maintains the dualInterface1ms counter variable
which is used as a 1ms timing reference in other parts of
the program. This routine also handles the entrance/exit
from suspend. The mouse will prepare to enter a suspend
(low power) state if there is no bus activity in 3ms. If the
mouse is congured for remote wakeup, the Bus Reset and
wakeup interrupts are enabled prior to suspending the
chip. The program then enters a suspended state, and will
wake at least as often as the wakeup timer interrupts or as
a result of the USB Bus Reset interrupt. Each time the chip
wakes up due to the wake up timer interrupt, the state of
the buttons is examined by the GetButtons function. If a
change in the button state has occurred, the mouse will
generate a resume signal to the host and exit the ISR. If
the device is not enabled for remote wakeup, only the USB
bus reset interrupt is enabled, and the part is suspended.
Only a Bus Reset can wake up the chip. If the resume was
due to bus activity, the rmware returns to the main loop.
If the resume was due to a button press, a K state is driven
upstream for 14 milliseconds prior to returning to the main
loop. Moving the mouse will not wake the suspended
system.
DualUsbEndpoint0_ps2Error – This ISR is entered upon receiving
an Endpoint 0 interrupt. Endpoint 0 interrupts occur during
the Setup, data, and status phases of a control transfer. This
ISR handler jumps to the proper routine to handle one of
these phases.
DualUsbEndpoint1_ps2Error – This ISR is entered upon receiving
an Endpoint 1 interrupt. If the ACK bit is set, indicating
that a mouse packet was just transmitted to the host suc-
cessfully, the SIE automatically sets the endpoint mode
to NAK_IN mode, and the data toggle bit is ipped for
the next transaction. The data toggle bit should never be
toggled if the interrupt was a result of a NAK transaction.
Downloaded from Elcodis.com electronic components distributor

14
Manufacturer String*1
A request for the manufacturer string will return the following string.
“Avago Reference Design Mouse”
Product String*2
A request for the product string will return the following string.
“ADNS-6000 Mouse”
Conguration String
A request for the conguration string will return the following string.
“HID-Compliant Mouse”
Endpoint 1 String
A request for the endpoint string will return the following string.
“Endpoint 1 Interrupt Pipe”
Note 1: The Manufacturer String should be changed to the name of your company.
Note 2: The Product String should be changed to your product’s name.
Downloaded from Elcodis.com electronic components distributor

15
Appendix A: Schematic Diagram of the Overall Circuit
Figure A1. Circuit-level block diagram for ADNK-6003 designer’s kit optical mouse using the Avago ADNS-6000 optical mouse sensor and Cypress CY7C63743-
PXC enCoRe USB Controller.
CYPRESS
CY7C63743-PXC
14
5
Vcc
9
GND
16
15
Vreg
11
19
17
GND
12
13 XTALOUT
20
* Outputs configured as open drain
D1
VCSEL
P0.5 *
P0.4 *
P0.7 *
P0.6
P1.4
P0.2
P0.0
P0.3
P1.5
VPP
R4 20K
Vcc
P1.0
P1.1
P1.2
P1.3
P1.6
P1.7
P0.1
R3 20K
ADNS-6000
Vcc
QA
QB
Rbin
Selected
to match
laser
RBIN
24
MOSI
23
SCLK
21
MISO
22
R2
20K
NCS
3RESET
NPD
4
R1
20K
R9
10 K
R10
10 K
24
MHz
OSC_OUT
OSC_IN
GUARD
X1
REFC
REFB
C9
0.1
C8
2.2
LASER_NEN
XY_LASER
Q2
2N3906
C2
0.1
C3
0.1
GND
GND
VDD3
VDD3
Vout Vin
Gnd
+3.3V
C7
4.7
C4
0.1
C6
4.7
1
2
3
Vcc
U4 LP2950ACZ-3.3
3.3V Regulator
Vcc
3
SW4
ALPS
EC10E
Scroll wheel encoder
__
CS
SCLK
SI
S0
VCC
___
WP
____
HLD
GND
U1 25LC160A
1
6
5
2
8
3
7
4
R7 100K
C5
0.1
N/C
N/C
D-/SDAT
D+/SCLK
XTALIN/P2.1
6
8
1
2
3
4
Vcc
VBUS
D+
D-
USB Port
R5
1.30K
C1
0.1
Buttons SW2
SW1
SW3
middle
right
left
16 KBit EEPROM (optional)
7
18
1
2
10
1
2
USB
microcontroller
R6 2.7K
C10
470pF
Murata
CSALS24MOX53-B0
Optional
Ground
Plane
6
9
13
7
15
4
1
5
19
12
11
20
3
2
10
14
8
17
16 18
Downloaded from Elcodis.com electronic components distributor

16
Appendix B: Bill of Materials for Components Shown on schematic
Comment Footprint Quantity
Cer. Cap 0.1uF (104) 0805_CUS 5
Cer. Cap 470pF 50V 0805_CUS 1
Chip RES. 10K 1% 0.125W 0805_CUS 2
Chip RES. 1K3 1% 0.125W 0805_CUS 1
Chip RES 2K7 1% 0.125W 0805_CUS 1
Chip RES 20K 1% 0.125W 0805_CUS 2
Chip RES 22K 1% 0.125W 0805_CUS 2
Chip RES 240R 1% 0.125W 0805_CUS 1
Resistor 18K7 1% 0.25W AXIAL0.4 1
Resonator 24MHz RAD0.2B 1
MMBT3906 SOT-23 1
E.Cap 2.2uF 50V CODE A 1
E. Cap 4.7uF 50V CODE A 2
ADNS-6000 sensor * DIP1x2MM 1
CY7C63743 * DIP24 1
IC socket 24-pin DIP24 1
LP2950ACZ-3.3 TO92C 1
MOLEX-5P HEADER CON5-MACH2-PWR 1
Mouse switch SW-SPDT-ZIPPY 3
VCSEL* LED 1
VCSEL socket pins VCSEL-2P 2
WIRES 2
Z-ENCODER ZDET 1
Z-LED ZLED 1
Downloaded from Elcodis.com electronic components distributor

20
Appendix F: USB data reporting format
The USB report has two formats, depending on if boot or report protocol is enabled. The following format is the boot
protocol and is understood by a USB aware BIOS.
Bit 7 Bit 0
Byte 0 0 0 0 0 0 Middle Right Left
Byte 1 X X X X X X X X
Byte 2 Y Y Y Y Y Y Y Y
Bit 7 Bit 0
Byte 0 0 0 0 0 0 Middle Right Left
Byte 1 X X X X X X X X
Byte 2 Y Y Y Y Y Y Y Y
Byte 3 R R R R R R R F/R
The following is the USB report protocol format and allows the additional wheel movement information in the fourth
byte. When the wheel is moved forward the fourth byte reports a 0x01, and when moved backward the fourth byte
reports 0xFF. When the wheel is idle, then this byte is assigned 0x00.
Downloaded from Elcodis.com electronic components distributor
Table of contents
Other Avago Microcontroller manuals