Dynamic HID Report

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
mega_mozg_13
Posts: 12
Joined: Tue Dec 11, 2012 4:33 pm

Dynamic HID Report

Post by mega_mozg_13 » Tue Dec 11, 2012 4:44 pm

Hi, I try to make device with fully dynamical HID Report.

1) In "usbconfig.h"
#define USB_CFG_DESCR_PROPS_HID_REPORT (USB_PROP_IS_DYNAMIC)


2) In "main.c"
PROGMEM char usbHidReportDescriptor[200] = { /* USB report descriptor, size must match usbconfig.h */
0x06, 0x00, 0xff, // USAGE_PAGE (Generic Desktop)
0x09, 0x01, // USAGE (Vendor Usage 1)
0xa1, 0x01, // COLLECTION (Application)
0x85, 0x04, // REPORT_ID (1)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x06, // REPORT_COUNT (6)
0x09, 0x00, // USAGE (Undefined)
0xb2, 0x02, 0x01, // FEATURE (Data,Var,Abs,Buf)
0xc0 // END_COLLECTION
};

uchar usbFunctionDescriptor(struct usbRequest *rq)
{
if ((rq->bmRequestType & USBRQ_TYPE_MASK) != USBRQ_TYPE_STANDARD) return 0;

if (rq->bRequest == USBRQ_GET_DESCRIPTOR)
{
switch (rq->wValue.bytes[1])
{
case USBDESCR_HID_REPORT: usbMsgPtr = (void *)usbHidReportDescriptor; return (24);
}
}

return 0;
}

And it working great!!!
3) Now I make a non "PROGMEM" array
static char dynamical_usbHidReportDescriptor[200] = { /* USB report descriptor, size must match usbconfig.h */
0x06, 0x00, 0xff, // USAGE_PAGE (Generic Desktop)
0x09, 0x01, // USAGE (Vendor Usage 1)
0xa1, 0x01, // COLLECTION (Application)
0x85, 0x04, // REPORT_ID (1)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x06, // REPORT_COUNT (6)
0x09, 0x00, // USAGE (Undefined)
0xb2, 0x02, 0x01, // FEATURE (Data,Var,Abs,Buf)
0xc0 // END_COLLECTION
};

uchar usbFunctionDescriptor(struct usbRequest *rq)
{
if ((rq->bmRequestType & USBRQ_TYPE_MASK) != USBRQ_TYPE_STANDARD) return 0;

if (rq->bRequest == USBRQ_GET_DESCRIPTOR)
{
switch (rq->wValue.bytes[1])
{
case USBDESCR_HID_REPORT: usbMsgPtr = (void *)dynamical_usbHidReportDescriptor; return (24);
}
}

return 0;
}


And it NOT working.
If it possible anyware? What do wrong?

PS: sorry for my very bad english.

Post Reply