8
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.
Mice_USB_Loop
– This routine initializes the USB related
parameters and then loads the SROM fi rmware into the
ADNS-6010 sensor before proceeding to AdjustLaser. The
program then goes to the main_loop.
main_loop
– This function spins in an infi nite loop waiting
for an event that needs servicing. The sample_mouse
function is called within this loop to retrieve any new
motion or button information. The data received from
this function 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.
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 confi gured for boot or report protocol. 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.
Figure 6. USB Operation Function Call Map
System
Initialization
USB Intialization
Calibration
Load SROM
AdjustLaser
Main_loop
Sample_mouse
Detect_key_change
ReadDeltaX
ReadDeltaY
Read Z Wheel
Load new mouse
packet to EP 1
buffer & enable
EP 1