AN249 Silicon_Laboratories, AN249 Datasheet - Page 39

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
CHIDDevice HID_Blinky;
This line defines HID_Blinky, which is the variable that the application uses to communicate with the HID Blinky
device.
8.3.3. Device Connection/Removal Detection
The application recognizes three different device connection states:
Device detection is handled using three notification routines. These routines enable the software to monitor the
USB for devices, and react anytime a device is connected or disconnected. The routines operate as follows:
RegisterNotification() is called when the dialog box is created, and UnregisterNotification() is
called whenever the dialog box closes. OnDeviceChange() contains a switch statement on nEventType that
recognizes two different notification event types:
8.3.4. Opening A Communication Link With A Device
A communication link is established with a connected device by pressing the "Activate" control button calls
GetConnectedDeviceNum() to check that the device is connected t o the bus, then calls the CHIDDevice
member function IsOpened() to check that a communications link has not already been established with this
device. If no link exists, Open() is called to establish one.
A link is terminated by pressing the "Deactivate" button. Link termination is accomplished by first checking that a
link exists using IsOpened(). If a link exists, the software calls Close() to terminate the link.
8.3.5. Controls and Reports
Operating
(OnBnClickedDisconnect(), OnBnClickedRate (), etc.). These functions then call routines with names
beginning "Update_..." that modify variables and communicate with the attached HID device. The Update_...
routines operate as follows:
The application receives input reports across the interrupt pipe by creating a thread that constantly attempts to
Disconnected - device not detected on the USB
Connected, Idle - device detected, but the application has not opened a communications link
Connected, Active - application has established a communications link with the device
RegisterNotification() - creates a notification handle that is signaled whenever a device is connected to
or disconnected from the USB.
OnDeviceChange() - called whenever a device is attached or removed from the bus; connect/disconnect
event notification is stored in the function parameter nEventType.
UnregisterNotification() - tells the system to no longer send notification of device
connection/disconnection
DBT_DEVICEARRIVAL - this case verifies that a HID Blinky device was connected by calling CHIDDevice
member function GetConnectedDeviceNum() to search for a device with a VID and a PID that match HID
Blinky's VID and PID.
DBT_DEVICEREMOVECOMPLETE - this case verifies that the HID Blinky device was disconnected by calling
GetConnectedDeviceNum() to check that no device is attached to the bus with HID Blinky's VID and PID.
Update_BlinkPattern() - transmits a BlinkPattern output report and transmits it by calling
SetReport_Interrupt().
Update_BlinkEnable() - transmits a Blink_Enable output report by calling SetReport_Control().
Update_BlinkRate() - transmits a BlinkRate output report by calling SetReport_Control().
Update_Stats() - receives a Blink_Stats input report by creating a buffer, setting the first element of that
buffer to the Blink_Stats report ID, and calling GetReport_Control()
Update_Dimmer() - transmits a Blink_Slider feature report by calling SetFeatureReport() and then
calls GetFeatureReport() to receive an acknowledge from the device
the
buttons,
check
boxes,
and
sliders
Rev. 0.2
call
routines
with
names
that
begin
AN249
"On…"
39

Related parts for AN249