8
USB Firmware Description
A function call map for USB operation is shown in Figure
6. The following are descriptions of the functions in
SPCP825A _A6000.asm.
IO_initial
– This function is use to set the Sunplus micro-
controller as input or output.
Port A(PA) is set as input while both Port B(PB) and Port
C(PC) are set as output. This function also includes setting
and enabling of pull-up resistor for left, right and middle
keys.
clear_ram
– This function clears the internal ram of the
microcontroller.
Usb_initial
– This function is used to enable the USB
mode. This is done by enabling the watchdog and LVR and
the low speed is selected. The USB reset event interrupt as
well as the set up event interrupt are enabled.
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 cali-
bration loop. If normal_mode variable fl ag 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-6000 sensor is reset and AdjustLaser routine
is invoked to write the LP_CFG0 and LP_CFG1 value to
the sensor register. Then, SetShuttherMode routine is
called to enable 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 confi guration 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 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.
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.
DetectKeyLoop
– This function is used to detect the left,
right and middle buttons changes.
check_mouse_data
–This function is used to determine
whether the buttons, X, Y or Z-wheel data need to be sent
to the host.
reset_adns6000
– This function is responsible for
resetting the hardware, loading the SROM (Shadow ROM)
fi rmware into the ADNS-6000 optical sensor. The ID from
the device and program are compared. If the ID is 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
buttons, 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-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.
AdjustLaser
– the AdjustLaser is used to read the value
from the EEPROM and then store them into the ADNS-
6000 sensor. The mouse will do calibration when the left
button is pressed when the mouse is fi rst plugged into the
USB port. However if the mouse left button is not pressed,
the value of calibration is already stored in the EEPROM
i.e. there is no need of calibration.
Calibration operation
- The calibration mode is diff erent
from the AdjustLaser as the calibration mode happens
when the left button is pressed whereas the AdjustLa-
ser is used to read the EEPROM values and put them into
the ADNS-6000 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.