AN249 Silicon_Laboratories, AN249 Datasheet - Page 33

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
8. HID Blinky Firmware and Software Example
This example shows a system where device-side firmware and host-side software transfer data between each
other using both the Interrupt and Control data pipes. Like the first example, this one takes advantage of the
switches, LEDs, and the potentiometer on Silicon Laboratories target boards.
8.1. Overview
The data transfers in this example are written to exercise every data path between the device and the host. Data
travels through the IN and OUT endpoints, and travels in both directions through the control endpoint. This
example also shows how multiple reports can be employed to optimize data transfer.
This example exercises the following data paths:
LED brightness adjustment and command acknowledgement transmitted between device and host in Feature
reports across the control endpoint
The HID Blinky Example's firmware was created by performing the following steps:
1. Modify descriptors so that the microcontroller appears as a device of some vendor-defined purpose.
2. Write code that controls LED lighting patterns.
3. Create a Report Descriptor that defines 5 Reports of different sizes and types.
4. Initialize ADC, Timer 2, and Timer 0 peripherals.
5. Write Report Handlers for each of the reports.
6. Modify main(void) to poll for changes in data and initiate transfers when necessary.
8.2. Firmware System
The firmware system blinks LEDs according to patterns received from the host application. It also saves
measurements concerning these patterns that can be retrieved by the host. The C8051F320/1 and C8051F34x
builds alter LED brightness by adjusting pulse width modulation signals connected to the LEDs.
8.2.1. Descriptors
Each of the following subsections describes modifications that need to be made to the firmware template’s
descriptors.
8.2.1.1. Device Descriptor
The device descriptor for this example looks as follows:
{
18,
0x01,
0x1001,
0x00,
0x00,
0x00,
EP0_PACKET_SIZE, // bMaxPacketSize0
LED blinking patterns transmitted to the device in OUT reports across the Interrupt OUT endpoint
Potentiometer position, used to choose from a list of blinking patterns, transmitted to the host in IN reports
across the Interrupt IN endpoint
LED blinking rate configuration transmitted to the device in OUT reports across the control endpoint
LED blinking enable/disable command transmitted to the device in OUT reports across the control endpoint
Runtime-calculated statistical information transmitted to the host in IN reports across the control endpoint
// bLength
// bDescriptorType
// bcdUSB
// bDeviceClass
// bDeviceSubClass
// bDeviceProtocol
Rev. 0.2
AN249
33

Related parts for AN249