AN249 Silicon_Laboratories, AN249 Datasheet - Page 26

no-image

AN249

Manufacturer Part Number
AN249
Description
Human Interface Device Tutorial
Manufacturer
Silicon_Laboratories
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
AN2490NFHP
Manufacturer:
PANASONIC/松下
Quantity:
20 000
Part Number:
AN2491NFHP
Manufacturer:
PANASON
Quantity:
5 510
Part Number:
AN2491NFHP
Manufacturer:
MAXIM
Quantity:
5 510
AN249
7. USB Mouse Example
This section examines the steps taken to emulate a USB Mouse using the Silicon Laboratories target board. This
example touches on all necessary firmware modifications that need to be made for HID-class device designs
derived from the firmware template. The USB Mouse Example needs no host-side application to operate correctly.
For an example of host-side application software, read the next section, titled “HID Blinky Device And Host
Firmware Example.”
7.1. Overview
This example contains two versions of low-level mouse emulation code. Code running on a C8051F320/1 or a
C8051F34x microcontroller emulates mouse movement by measuring the potentiometer’s position. The axis of
moment (whether motion on the potentiometer translates to up-down motion or left-right motion) is controlled by
one of the switches found on the target board. Every press of the button switchies between X-axis movement and
Y-axis movement. The other switch on the target board acts as the left mouse button. Code running on a
C8051F326/7 emulates movement by setting mouse vector values in a predefined pattern.
The USB Mouse example was created by taking the following steps:
1. Configure all descriptors so that the host recognizes the attached device as a USB mouse.
2. Initialize Timer 2 and (for the C8051F320/1 and C8051F34x device builds) ADC peripherals.
3. Format captured data into a report structure defined in the Report Descriptor.
4. Add the report handler to transmit these reports to the host.
7.2. Descriptors
This section describes how each descriptor located in the firmware template file USB_Descriptor.c has been
modified to create a device that appears to the host to be a USB mouse. This subsection describes only items in
descriptors that have been modified from their default firmware template values.
7.2.1. Device Descriptor
The device descriptor for this example looks as follows. Changes from the firmware template are highlighted in
bold.
{
26
18,
0x01,
0x1001,
0x00,
0x00,
0x00,
EP0_PACKET_SIZE, // bMaxPacketSize0
0xC410,
0x0000,
0x0000,
0x01,
0x02,
0x00,
0x01
// bLength
// bDescriptorType
// bcdUSB
// bDeviceClass
// bDeviceSubClass
// bDeviceProtocol
// idVendor
// idProduct
// bcdDevice
// iManufacturer
// iProduct
// iSerialNumber
// bNumConfigurations
Rev. 0.2

Related parts for AN249