Last active
August 5, 2016 16:21
-
-
Save jhgorse/68b07f3c20d70548a9621f58345bc80f to your computer and use it in GitHub Desktop.
smart sensor descriptors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define HID_REPORT_DESCRIPTOR_SIZE 0x0044 | |
typedef unsigned char hid_report_descriptor[HID_REPORT_DESCRIPTOR_SIZE]; | |
code const device_descriptor DEVICEDESC = | |
{ | |
18, // bLength | |
0x01, // bDescriptorType | |
0x1001, // bcdUSB | |
0x00, // bDeviceClass | |
0x00, // bDeviceSubClass | |
0x00, // bDeviceProtocol | |
EP0_PACKET_SIZE, // bMaxPacketSize0 | |
0xAA10, // idVendor //NEED TO ASSIGN PID/VID | |
0xAA63, // idProduct | |
0x0000, // bcdDevice | |
0x01, // iManufacturer | |
0x02, // iProduct | |
0x00, // iSerialNumber | |
0x01 // bNumConfigurations | |
}; //end of DEVICEDESC | |
// From "USB Device Class Definition for Human Interface Devices (HID)". | |
// Section 7.1: | |
// "When a Get_Descriptor(Configuration) request is issued, | |
// it returns the Configuration descriptor, all Interface descriptors, | |
// all Endpoint descriptors, and the HID descriptor for each interface." | |
code const hid_configuration_descriptor HIDCONFIGDESC = | |
{ | |
{ // configuration_descriptor hid_configuration_descriptor | |
0x09, // Length | |
0x02, // Type | |
0x2900, // Totallength (= 9+9+9+7+7) | |
0x01, // NumInterfaces | |
0x01, // bConfigurationValue | |
0x00, // iConfiguration | |
0x80, // bmAttributes | |
0xfa // MaxPower (in 2mA units) | |
}, | |
{ // interface_descriptor hid_interface_descriptor | |
0x09, // bLength | |
0x04, // bDescriptorType | |
0x00, // bInterfaceNumber | |
0x00, // bAlternateSetting | |
0x02, // bNumEndpoints | |
0x03, // bInterfaceClass (3 = HID) | |
0x00, // bInterfaceSubClass | |
0x00, // bInterfaceProcotol | |
0x00 // iInterface | |
}, | |
{ // class_descriptor hid_descriptor - looks good | |
0x09, // bLength | |
0x21, // bDescriptorType | |
0x0101, // bcdHID | |
0x00, // bCountryCode | |
0x01, // bNumDescriptors | |
0x22, // bDescriptorType | |
HID_REPORT_DESCRIPTOR_SIZE_LE // wItemLength (tot. len. of report, 0x44, 68 | |
// descriptor) | |
}, | |
// IN endpoint (mandatory for HID) | |
{ // endpoint_descriptor hid_endpoint_in_descriptor | |
0x07, // bLength | |
0x05, // bDescriptorType | |
0x81, // bEndpointAddress | |
0x03, // bmAttributes | |
EP1_PACKET_SIZE_LE, // MaxPacketSize (LITTLE ENDIAN) | |
1 // bInterval | |
}, | |
// OUT endpoint (optional for HID) | |
{ // endpoint_descriptor hid_endpoint_out_descriptor | |
0x07, // bLength | |
0x05, // bDescriptorType | |
0x01, // bEndpointAddress | |
0x03, // bmAttributes | |
EP2_PACKET_SIZE_LE, // MaxPacketSize (LITTLE ENDIAN) | |
1 // bInterval | |
} | |
}; | |
code const hid_report_descriptor HIDREPORTDESC = | |
{ | |
0x06, 0x00, 0xff, // USAGE_PAGE (Vendor Defined Page 1) | |
0x09, 0x01, // USAGE (Vendor Usage 1) | |
0xa1, 0x01, // COLLECTION (Application) | |
//#define IN_CONTROL 0xFE | |
//#define IN_CONTROL_SIZE 8 | |
0x85, IN_CONTROL, // Report ID | |
0x95, IN_CONTROL_SIZE, // REPORT_COUNT () | |
0x75, 0x08, // REPORT_SIZE (8) | |
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) | |
0x15, 0x00, // LOGICAL_MINIMUM (0) | |
0x09, 0x01, // USAGE (Vendor Usage 1) | |
0x81, 0x02, // INPUT (Data,Var,Abs) | |
//#define OUT_CONTROL 0xFD | |
//#define OUT_CONTROL_SIZE 8 | |
0x85, OUT_CONTROL, // Report ID | |
0x95, OUT_CONTROL_SIZE, // REPORT_COUNT () | |
0x75, 0x08, // REPORT_SIZE (8) | |
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) | |
0x15, 0x00, // LOGICAL_MINIMUM (0) | |
0x09, 0x01, // USAGE (Vendor Usage 1) | |
0x91, 0x02, // OUTPUT (Data,Var,Abs) | |
//#define IN_DATA 0x01 | |
//#define IN_DATA_SIZE 60 | |
0x85, IN_DATA, // Report ID | |
0x95, IN_DATA_SIZE, // REPORT_COUNT () | |
0x75, 0x08, // REPORT_SIZE (8) | |
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) | |
0x15, 0x00, // LOGICAL_MINIMUM (0) | |
0x09, 0x01, // USAGE (Vendor Usage 1) | |
0x81, 0x02, // INPUT (Data,Var,Abs) | |
//#define OUT_DATA 0x02 | |
//#define OUT_DATA_SIZE 60 | |
0x85, OUT_DATA, // Report ID | |
0x95, OUT_DATA_SIZE, // REPORT_COUNT () | |
0x75, 0x08, // REPORT_SIZE (8) | |
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) | |
0x15, 0x00, // LOGICAL_MINIMUM (0) | |
0x09, 0x01, // USAGE (Vendor Usage 1) | |
0x91, 0x02, // OUTPUT (Data,Var,Abs) | |
0xC0 // end Application Collection | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment