9
Figure 6. USB Operation Function Call Map
System
Initialization
Normal Mouse
Mode
Judge Mode
Load SROM
Adjust Laser
Main Loop
Sample Mouse
ReadDeltaX
ReadDeltaY
Read Z Wheel
Send Data
USB Initialization
Detect Key
Change
Calibration
Operation
Calibration Loop
Calibration Mode
Process
Command
Write EEPROM
Reset Sensor
Finish Command
Echo
Read Sensor
Write Sensor
Read EEPROM
Test Sensor
USB Functions
Main_loop
–This function spins in an infi nite 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 in-
formation. The data received from these functions will be
loaded into the endpoint 1 buff er 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.
setDeviceConfi guration
– 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 fl ag is set to indicate that a new
address was just received. The code that handles IN trans-
actions will recognize this and set the address properly.
setInterfaceIdle
– This routine is entered whenever a
SET IDLE request is received. See the HID specifi cation
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.
getDeviceConfi guration
– This routine is entered
whenever a GET CONFIGURATION Request is received.
This function then starts a control read transaction that
sends the confi guration, interface, endpoint, and HID de-
scriptors to the host.
requestNotSupported
– Unsupported or invalid descrip-
tor requests will cause this fi rmware to STALL these trans-
actions.