
7
• DetectUsbReset – This routine initializes USB interface
service and SPI ports. Then, the normal_mode variable
is compared; if normal_mode is equal to ‘0’ then this
routine will invoke the calibration_operation routine to
enter the calibration loop. If the normal_mode variable
flag is equal to ‘1’ then Read_LP_CFG_REG is called to
load the calibrated LP_CFG0 and LP_CFG1 register
value. Subsequently, the ADNS-6090 sensor is reset
and the AdjustLaser routine is invoked to write the LP_
CFG0 and LP_CFG1 value to the sensor register. Then,
the SetShuttherMode routine is called to enable the
VCSEL in shutter mode and laser output is enabled.
• Default_state – This function is used to set the default
service routing.
• SPI_init – This function involves the initialization of SPI.
• Read_LP_CFG_REG – This function reads the calibrated
laser power configuration register from EEPROM.
• sample_mouse – 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.
• ReadDeltaX – Reads the ADNS-6090 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-6090 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 newY motion
information is added to the [yCount] variable.
• DetectKeyLoop – This function is used to detect the left,
right and middle button changes.
• check_mouse_data –This function is used to determine
whether the buttons, X, Y or Z-wheel data needs to be
sent to the host.
• reset_ands6000 – This function is responsible for resetting
the hardware and loading the SROM (Shadow ROM)
firmware into the ADNS-6090 optical sensor. The IDs
from the device and program are compared. If the IDs
are not the same, then the program is trapped in the
dead loop, i.e. the device is unusable.
• Report_mouse_data – This function is used to send button,
X, Y and Z-wheel data to the computer.
• judge_mode – This function is used to check for normal
mouse or calibration mode.
• detect_key_change – This function is used to detect left,
right or middle button changes.
• ReadMotionReg – Reads the ADNS-6090 Motion register.
The data returned from this register will be used to
determine if any motion has occurred or if any fault
condition exists.
• AdjustLaser –AdjustLaser is used to read the values from
the EEPROM and then store them into the ADNS-6090
sensor. When the mouse is first plugged into the USB
port the mouse will do a calibration.. However if the
mouse left button is not pressed, the value of calibration
is already stored in the EEPROM and calibration is not
needed.
• Calibration operation –The calibration mode is different
from the AdjustLaser as the calibration mode happens
when the left button is pressed whereas the AdjustLaser
is used to read the EEPROM values and put them into
the ADNS-6090 sensor. This means in the Normal mouse
mode, the AdjustLaser is done even in the normal mouse
mode. Actually when the mouse enters the calibration
mode, it cannot come back to the normal mouse mode
without unplugging the USB plug.
USB Functions
• Main_loop –This function spins in an infinite loop waiting
for an event that needs servicing; sample_mouse and
report_mouse_data are the functions which 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 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.