AN249 Silicon_Laboratories, AN249 Datasheet - Page 38

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
The file defines the IN and OUT Vector Tables as follows:
The IN Vector table contains the following elements:
The OUT Vector Table contains the following elements:
The F3xx_Blink_Control.h header file must be included for the compiler to recognize the Report IDs listed in these
tables.
The function bodies for each Handler mostly perform simple data transfer, either from a Global Variable and into an
input buffer, or from an Output Buffer to some global variable.
Since this example uses Output Reports, the firmware needs a body for the function Setup_OUT_Buffer. This
function is called before data is retrieved from a buffer storing data transferred during either a Control OUT transfer
or an OUT Endpoint transaction. The body of the function only needs to set the OUT_Buffer.Ptr struct to a data
buffer and to save the size of this buffer in the struct element Length.
This example configures the Setup_OUT_Buffer as follows:
8.2.4. Alterations to main(void)
Only a few modifications need to be made to the main(void) function of the firmware template. Blink_Init()
must be called to initialize the timer used for blink rate measurement. Inside the while(1) loop, the global
variable defined in F3xx_USB0_Main.c named Blink_SelectionUpdate is polled. If this variable is set, the
potentiometer value has changed, and the main(void) function initiates a transmission of a report containing
potentiometer information by calling the function SendPacket().
8.3. Host-side PC Application
The host-side software application uses the CHIDDevice class to communicate with the HID Blinky device. The
following sub-sections describe how the application connects to the device, and how data is transferred using the
CHIDDevice class.
8.3.1. Project Overview
The application was created using dialog-based MFC classes in Visual C++. All application functionality is
contained within the HID_BlinkyDlg dialog. Controls and communication are contained in HID_BlinkyDlg.cpp.
All low-level HID communication is handled by the CHIDDevice, which is defined in HIDDevice.cpp and
HIDDevice.h.
8.3.2. HID Device Initialization
The dialog class's header file, called HID_BlinkyDlg.h, includes the file HIDDevice.h, which declares all member
functions and variables for the CHIDDevice class. The CHID_BlinkyDlg definition in HID_BlinkyDlg.h contains
the following line:
38
#define IN_VectorTableSize 3
#define OUT_VectorTableSize 4
IN_Blink_SelectorID, IN_Blink_Selector,
IN_Blink_StatsID, IN_Blink_Stats
FEATURE_Blink_DimmerID, FEATURE_Blink_Dimmer_Input
OUT_Blink_EnableID, OUT_Blink_Enable,
OUT_Blink_PatternID, OUT_Blink_Pattern,
OUT_Blink_RateID, OUT_Blink_Rate
FEATURE_Blink_DimmerID, FEATURE_Blink_Dimmer_Output
OUT_Buffer.Ptr = OUT_PACKET;
OUT_Buffer.Length = 10;
Rev. 0.2

Related parts for AN249