Agilent Technologies ADNK-6003 Design Manual


Add to my manuals
24 Pages

advertisement

Agilent Technologies ADNK-6003 Design Manual | Manualzz

Agilent 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-effective

USB-PS/2 optical mouse can be built using the Cypress

Semiconductor CY7C63743-PXC

USB microcontroller and the

Agilent 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 Agilent

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 firmware 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 Agilent web site at www.semiconductor.agilent.com.

USB documentation can be found at the USB

Implementers Forum web site a t www.usb.org.

ADNB-6001 laser mouse bundle set is the world’s first laser-illuminated navigation system. With laser navigation technology, the mouse can operate on many surfaces that prove difficult 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 configuration 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.

Introduction to the CY7C63743-PXC

The CY7C63743-PXC is an 8bit RISC microcontroller with an integrated USB Serial

Interface Engine (SIE). The architecture executes generalpurpose 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 peripherals can be implemented with a minimum of external components and firmware effort.

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 Configurable GPIO

The reference firmware is configured to use the GPIO pins as shown on the schematic in Appendix A.

However, it may be more optimal to use a different I/O configuration to meet the mechanical constraints of PCB design. The reference firmware is designed to be easily configured to another set of pin connections. This is accomplished through changes in the I/O definitions at the beginning of the adns-

6000.asm listing. The following statements are the pin definitions as they exist today.

Agilent ADNS-6000 optical mouse sensor

Z Optics

Left Button

Wheel Button

Right Button

MISO

MOSI

SCLK

NCS

Cypress

CY7C63743-PXC enCoRe

USB Controller

VREG

D+/D-

SCLK/SDATA

1.3 k Ohm

USB/PS2 Interface

Figure 1. CY7C63743-PXC –ADNS-6000 Optical Mouse Hardware Block Diagram

The firmware will use these definitions to read and configure the GPIO pins, without any other modifications.

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 configured as a Master to output the serial clock on

P0.7. Therefore, the USB microcontroller always initiates communication. 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 microcontroller 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 t

SRAD delay, the ADNS-6000 will drive the data via MISO.

The microcontroller is only driving the SCLK line (outputs

SCLK for the serial interface).

Optical Sensor

Agilent’s ADNS-6000 optical sensor is used in this reference design as the primary navigation engine.

This Optical Navigation

Technology contains an Image

Acquisition System, a Digital

Signal Processor, a two channel quadrature output,

2

and a four-wire serial port.

The CY7C63743-PXC periodically 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.

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, flexibility 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 difficult 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 predefined 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

Agilent-supplied firmware file contents into the ADNS-6000.

The firmware file is an ASCII text file 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 Agilent web site at: http://www.semiconductor.agilent.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 configuration. 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 phototransistors are turned on and off in a quadrature output pattern. Every change in the phototransistor outputs represents 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.

Figure 2. Optics Quadrature Signal Generation

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 firmware 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 configuration register that switches control from the SIE to manual control on the D+ and D- pins. This allows the firmware to dynamically configure 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 firmware for this reference design will automatically detect the host topology (USB or PS/

2) at plug-in and will configure itself for operation on that bus. If a USB host connection is detected then the firmware will enable the VREG pin, such that the 1.3k ohm resistor connected to the Dline 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.

3

Figure 3. USB and PS/2 peripheral connectors

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

Controller. This kit also enables users to understand the recommended mechanical assembly. (See Appendix C and D)

System Requirements

PCs using Windows

95/

Windows

98/ Windows

NT/

Windows

2000 with PS/2 port and standard 3-button

USB mouse driver loaded.

Functionality

3-button, scroll wheel mouse.

Operating (For PS/2 Mode)

1. Turn off 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 off 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 disassemble the mouse unit.

Caution: The lens is not permanently attached to the sensor and will drop out of the assembly.

Customer Supplied VCSEL PCB

ADNS-6000 (sensor)

ADNV-6330 (VCSEL)

Customer Supplied PCB

ADNS-6230-001 (clip)

ADNS-6120 (lens)*

*or ADNS-6130-001 for trim lens

Customer Supplied Base Plate

With Recommended Features

Per IGES Drawing

Figure 4. Exploded view drawing of optical tracking engine with ADNS-6000 optical mouse sensor.

4

While reassembling the components, please make sure that the Z height (Distance from lens reference plane to surface) is valid. Refer to

Figure 5.

2.40

0.094

Sensor

Sensor PCB

The ADNS-6000 must operate from the externally loaded programming. This architecture enables immediate adoption of new features and improved performance algorithms. The external program is supplied by Agilent as a file which may be burned into a programmable device.

A microcontroller with sufficient memory may be used. On power-up and reset, the ADNS-6000 program is downloaded 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.

Lens

VCSEL PCB

Figure 5. Distance from lens reference plane to surface

Enabling the SROM

Surface

Passes FCC B and worldwide analogous emission limits when assembled into a mouse with shielded cable and following Agilent recommendations.

Passes IEC-1000-4-3 radiated susceptibility level when assembled into a mouse with shielded cable and following Agilent recommendations.

Passes EN61000-4-4/IEC801-

4 EFT tests when assembled into a mouse with shielded cable and following

Agilent recommendations.

UL flammability level UL94

V-0.

Provides sufficient ESD creepage/clearance distance to avoid discharge up to

15kV when assembled into a mouse according to usage instructions above.

Eye Safety

VCSEL

VCSEL Clip

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. Agilent

Technologies suggests that manufacturers perform testing to verify eye safety on each mouse. It is also recommended to review possible single fault mechanisms beyond those described below in the section

“Single Fault Detection”.

Regulatory Requirements

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 appropriate values. Agilent recommends using the exact Rbin value specified in the bin table to ensure sufficient 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 recommended 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.

5

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 setting 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 possible 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 navigation surface plane is specified below. The following conditions apply:

1. The system is adjusted according to the above procedure.

2. The system is operated within the recommended operating 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 assumed.

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 controller 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

3 rd party programming companies. For further information on this product, please contact Cypress

Semiconductor.

Lens

The lens technical information is contained in the ADNS-6120

Data Sheet. The flange 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 Agilent’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 fixture 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 firmware for this reference design is written in the Cypress assembly language. The following files are required to compile the mouse firmware

637xx.inc – the CY7C63743-

PXC I/O registers definition.

adns-6000.asm – main mouse firmware 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 firmware

At power up, the firmware 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 firmware configures itself to operate on the detected interface.

6

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 first connected to the bus, it is powered and running firmware, 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– notifies 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 specific 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, configuration description 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 specific product.

3. MaxPower value should be changed as per specific 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 configures 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 reconfigured by the host.

mouse is left idle (i.e. no movement, no new button presses, no wheel movement) the firmware 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 defined by the HID specification, is the default report protocol that all USB enabled systems understands.

The boot protocol has a threebyte format, and so does not report wheel information. The

HID report descriptor defines 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.

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 specification) to determine the device type and how to configure communications 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 specification. 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 configures 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

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 first connected to the bus, it is powered and is running firmware. 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.

7

2. Device Configuration

During this time the host will set the standard PS/2 parameters 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 specification, there is a sequence of commands that enable the wheel. Wheelaware 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 first 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 indefinitely 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 configured 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 infinite usbTaskLoop 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 confirmed. 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 phototransistors. 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.

8

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 first 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 microcontroller performs a write to the ADNS-

6000, sending the address of the target register to be read.

The microcontroller drives both the SCLK and MOSI lines. After t

SRAD 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 usbTaskLoop .

usbTaskLoop – This function spins in an infinite 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 buffer 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.

setDeviceConfiguration – 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 flag 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

DESCRIPTOR 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 specification 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 transaction 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

9

configured for boot or report protocol. See the HID class documentation for more details.

getDeviceConfiguration – This routine is entered whenever a

GET CONFIGURATION Request is received. This function then starts a control read transaction that sends the configuration, interface, endpoint, and HID descriptors to the host.

requestNotSupported –

Unsupported or invalid descriptor requests will cause this firmware to STALL these transactions.

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

USB Main

USB Initialization

USBTaskLoop

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 infinite PS2TaskLoop loop.

PS2TaskLoop – This function spins in an infinite 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 buffer 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.

ProcessButtons

ProcessOptics

Load new mouse packet to EP1 buffer & enable

EP1

Figure 6. USB Operation Function Call Map

DualMain

System

Initialization

Load SROM

AdjustLASER

GetMouseType

ReadMotionReg

ReadDeltaX

ReadDeltaY

Read Z Wheel

10

PS2 Interface

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 buffer.

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 verifies that the requested sample rate is valid and sets the sample rate for the mouse.

Valid sample rates are defined in the PS/2 Mouse specification.

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 specification 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 specification, 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 specification 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 specification 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 first 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 specification and loads it to the buffer.

PS2SendNextByte – This routine sends the next byte in buffer 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

11

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 specification, 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 ps2Main

PS2 Initialization ps2TaskLoop

PS2BAT

SetDefault ps2SendNextByte ProcessOptics PS2DoCommand ProcessButtons GetHostByte LoadMousePacket

HostRequestToSend

PS2HostINhibit

PS2Send

ReadMotionReg

ReadDeltaX

ReadDeltaY

Read Z Wheel

Send_1

Send_0

PS2SendResponseByte

PS2Send

Send_1

Send_0

CheckWheel

PS2ResetScaling

PS2SetScaling

PS2StatusRequest

PS2SetStreamMode

ResetInterval

ResetWrapMode

SetWrapMode

SetRemoteMode

ReadDeviceType

Enable

Disable

SetDefault

Resend

Reset

HostRequestToSend

PS2Receive

GetBit send0

Figure 7. PS/2 Operation Function Call Map

12

SET RESOLUTION Command

The SET RESOLUTION command is conditionally enabled by the statement

“#define

ENABLE_RESOLUTION”. On most systems this command is not supported. If you wish to disable this command in the firmware, comment out the aforementioned statement.

SET SCALING Command

The SET SCALING command is conditionally enabled by the statement “#define

ENABLE_SCALING”. On most systems this command is not supported. If you wish to disable this command in the firmware, comment out the aforementioned statement.

Interrupt Service Routines (ISR)

The CY7C63743-PXC features

12 different sources of interrupts. There are only four

ISRs implemented in this application. 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 first disable all interrupts by clearing the Global

Interrupt Enable bit. This is followed by an automatic

CALL instruction 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 first 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 initializes 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 configured 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 firmware 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 successfully, the SIE automatically sets the endpoint mode to NAK_IN mode, and the data toggle bit is flipped for the next transaction. The data toggle bit should never be toggled if the interrupt was a result of a NAK transaction.

13

Manufacturer String*1

A request for the manufacturer string will return the following string.

“Agilent Reference Design

Mouse”

Product String*2

A request for the product string will return the following string.

“ADNS-6000 Mouse”

Configuration String

A request for the configuration 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.

14

Appendix A: Schematic Diagram of the Overall Circuit

USB Port

VBUS

GND

D+

D-

1

2

3

4

Vcc

R5

1.30K

* Outputs configured as open drain

Buttons

SW2

SW1 middle right

SW3 left

Vcc

USB microcontroller

14

Vcc

C1

0.1

16 KBit EEPROM (optional)

R7 100K

1

__

2

CS

6

5

SCLK

SI

S0

U1 25LC160A

VCC

___

WP

____

HLD

GND

7

4

8

3

5

P1.0

20

P1.1

6

P1.2

19

P1.3

8

P1.6

17

P1.7

16

D+/SCLK

15

D-/SDAT

13

XTALOUT

11

Vreg

12

XTALIN/P2.1

9

GND

P0.7 *

21

22

P0.6

P0.5 *

23

24

P0.4 *

3

P0.2

R9

10 K

P0.3

4

R10

10 K

7

P1.4

P1.5

18

P0.0

P0.1

VPP

1

2

10

R3 20K

Vcc

R2

20K

3

Vcc

2

1

QA

QB

SW4

ALPS

EC10E

Scroll wheel encoder

R1

20K

R4 20K

1

3

SCLK

2

MISO

4

MOSI

6

7

NCS

RESET

NPD

5

15

N/C

N/C

13 RBIN

Rbin

Selected to match laser

C5

0.1

16 18

C7

4.7

+3.3V

3.3V Regulator

U4 LP2950ACZ-3.3

1

Vout Vin

3

Gnd

2

C4

0.1

17

GND

GND

19

C2

0.1

REFC

REFB

LASER_NEN

XY_LASER

12

20

14

11

C8

2.2

OSC_IN

8

9

GUARD

OSC_OUT

10

Optional

Ground

Plane

C3

0.1

R6 2.7K

C9

0.1

X1

24

MHz

Vcc

Q2

2N3906

C6

4.7

C10

470pF

D1

VCSEL

Murata

CSALS24MOX53-B0

Figure A1. Circuit-level block diagram for ADNK-6003 designer’s kit optical mouse using the Agilent ADNS-6000 optical mouse sensor and

Cypress CY7C63743-PXC enCoRe USB Controller.

15

Appendix B: Bill of Materials for Components Shown on schematic

Comment

Cer. Cap 0.1uF (104)

Cer. Cap 470pF 50V

Chip RES. 10K 1% 0.125W

Chip RES. 1K3 1% 0.125W

Chip RES 2K7 1% 0.125W

Chip RES 20K 1% 0.125W

Chip RES 22K 1% 0.125W

Chip RES 240R 1% 0.125W

Resistor 18K7 1% 0.25W

Resonator 24MHz

MMBT3906

E.Cap 2.2uF 50V

E. Cap 4.7uF 50V

ADNS-6000 sensor *

CY7C63743 *

IC socket 24-pin

LP2950ACZ-3.3

MOLEX-5P HEADER

Mouse switch

VCSEL*

VCSEL socket pins

WIRES

Z-ENCODER

Z-LED

ZDET

ZLED

Footprint

0805_CUS

0805_CUS

0805_CUS

0805_CUS

0805_CUS

0805_CUS

0805_CUS

0805_CUS

AXIAL0.4

RAD0.2B

SOT-23

CODE A

CODE A

DIP1x2MM

DIP24

DIP24

TO92C

CON5-MACH2-PWR

SW-SPDT-ZIPPY

LED

VCSEL-2P

1

1

3

1

2

2

1

1

1

2

1

1

1

2

1

1

1

1

1

1

2

1

2

Quantity

5

16

Appendix C: PCB Layout

Figure C1. PCB Schematic (Bottom Layer)

Figure C2. PCB Schematic (Top Layer)

17

Figure C3. PCB Schematic (Top Overlay)

Figure C4. PCB Schematic (Bottom Overlay)

18

Appendix D: Base Plate Feature

Figure D1. Overall view of base plate

19

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.

Byte 0

Byte 1

Byte 2

X

Y

Bit 7

0 0

X

Y

0

X

Y

0

X

Y

0

X

Y

Middle

X

Y

Right

X

Y

X

Y

Bit 0

Left

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.

Byte 0

Byte 1

Byte 2

Byte 3

X

Y

Bit 7

0

R

0

X

Y

R

0

X

Y

R

0

X

Y

R

0

X

Y

R

Middle

X

Y

R

Right

X

Y

R

X

Y

Bit 0

Left

F/R

20

Appendix G: PS/2 reporting format

The PS/2 portion of the firmware handles the following requests and commands listed in the table below.

0xE8

0xE7

0xE6

0xAA

0xFA

0xEE

0xEC

0xEB

0xEA

0xE9

0xF4

0xF3

0xF2

0xF0

Hex Code

0xFF

0xFE

0xF6

0xF5

Command

Reset

Resend

Set Default

Disable

Enable

Set Sampling Rate

Read Device Type

Set Remote Mode

Set Wrap Mode

Reset Wrap Mode

Read Data

Set Stream Mode

Status Request

Set Resolution

Set Scaling 2:1

Reset Scaling

Completion Code

Peripheral ACK

Action

Resets mouse to default states

Resends last data to host

Sets mouse to use default parameters

Disables the mouse

Enables the mouse

Set sampling rate to 10,20,40,60,80,100,200/second

Returns 0x00 to host, indicating the device is a mouse

Sets remote mode so data values are only reported after a read data command

Set wrap mode until 0xFF or 0xEC is received

Reset to previous mode of operation.

Responds by sending a mouse report packet to host

Sets stream mode

Returns current mode, en/disabled, scaling, button, resolution, and sampling rate information to the host.

Sets resolution to 1,2,4,8 counts/mm

Sets scaling to 2:1

Resets scaling to 1:1

Command completion code

Sent to acknowledge host requests

The PS/2 specification calls out the following default mouse report format. Byte 0 is the button data (1=pressed, 0=released), X and Y optics sign bits, and X and Y overflow bits. Byte 1 is the X optics data in 2’s complement format. Byte 2 has the Y optics data in 2’s complement format. At reset or power-on the standard PS/2 reporting format is enabled.

Byte 0

Byte 1

Byte 2

Bit 7

Y Overflow X Overflow Y sign

X X X

Y Y Y

X sign

X

Y

Reserved 0 Reserved 0 Right button Left button

X

Y

X

Y

X

Y

Bit 0

X

Y

21

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

Byte 0

Byte 1

Byte 2

Byte 3

Bit 7

Y

Overflow

X

Y

X Overflow Y sign

X

Y

Wheel* Wheel*

X

Y

Wheel*

X sign

X

Y

Always 1 Middle

Button

X X

Y

Wheel* Wheel*

Y

Wheel*

Right button

X

Y

Wheel*

Bit 0

Left button

X

Y

Wheel*

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. After this initialization sequence, the PS/2 wheel reporting format is enabled. The fourth byte represents the wheel data. This byte is assigned 0x01 for forward wheel movement and 0xFF for backward wheel movement. When the wheel is idle, this value is 0x00.

Start Bit

(Always 0)

Data Bit

0

Data Bit

1

Data Bit

2

Data Bit

3

Data Bit

4

Data Bit

5

Data Bit

6

Data Bit

7

Odd Parity

Bit

Stop Bit

(Always 1)

The PS2 data transmission according to the PS/2 Hardware Interface Technical Reference including eleven bits for each byte sent. The bits are sent in the following order with data valid on the falling edge of the clock. See the PS/2 Hardware Interface Technical Reference manual for timing information.

22

Appendix H: Kit Components

The designer’s kit contains components as follows:

Part Number

ADNS-6000

ADNS-6120

ADNS-6130-001

ADNS-6230-001

ADNV-6330

ADNK-6003 CD

Description

Solid-State Optical Mouse Sensor

Round Lens Plate

Trim Lens Plate

LASER Assembly Clip

Single Mode Vertical Cavity Surface Emitting LASER (VCSEL)

Includes Documentation and Support Files for ADNK-6003

Documentation

a. ADNB-6001 and ADNB-6002 Data Sheet

b. AN-5088 LASER Mouse Sensor Eye Safety Calculations

Hardware Support Files

a. ADNK-6003 BOM List

b. ADNK-6003 Schematic

c. IGES Base Plate Feature File

d. Gerber File

Software Support Files

a. Microcontroller Firmware

Name

Sensor

Lens

Lens

LASER Clip

LASER

5

5

5

5

1

Quantity

5

23

www.agilent.com/ semiconductors

For product information and a complete list of distributors, please go to our web site.

For technical assistance call:

Americas/Canada: +1 (800) 235-0312 or (916) 788-6763

Europe: +49 (0) 6441 92460

China: 10800 650 0017

Hong Kong: (+65) 6756 2394

India, Australia, New Zealand: (+65) 6755 1939

Japan: (+81 3) 3335-8152(Domestic/International), or 0120-61-1280(Domestic Only)

Korea: (+65) 6755 1989

Singapore, Malaysia, Vietnam, Thailand,

Philippines, Indonesia: (+65) 6755 2044

Taiwan: (+65) 6755 1843

Data subject to change.

Copyright © 2005 Agilent Technologies, Inc.

July 1, 2005

5989-3119EN

advertisement

Was this manual useful for you? Yes No
Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Related manuals

advertisement