Who can help me with AVR-USB for HID?
Posted: Sun Oct 28, 2007 5:50 am
I'm working with AVR-USB to make a customized Joystick with USB HID device.
Following many codes form Internet, I have made a code that can support only 1 (X/y/Z) axis, with the descriptor below:
When I try to add another axis, it fails(when programmed to Mega8, the USB detecting sound in Windows is quick three notes, and an Unkown Device is Identified):
I think the problem is on the descriptor, but i can't find the error.
I have changed the
Code:
accordingly, and the right data buffer.
Who can tell me how to fix it?
When I changed the descriptor to 2 axes, I found the USB can't send correct data to PC, but why?
I found if i extend the X axis to 16bits ,the code can't workly properly too-- I mean it is indentified as Unknown Device.
Following many codes form Internet, I have made a code that can support only 1 (X/y/Z) axis, with the descriptor below:
Code: Select all
PROGMEM char usbHidReportDescriptor[26] = { /* USB report descriptor */
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x09, 0x04, // USAGE (Joystick)
0xa1, 0x01, // COLLECTION (Application)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x95, 0x01, // REPORT_COUNT (1)
0x75, 0x08, // REPORT_SIZE (8)
0x15, 0x0, // LOGICAL_MINIMUM (-128)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x09, 0x30, // USAGE (X)
// 0x09, 0x31, // USAGE (Y)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
};
When I try to add another axis, it fails(when programmed to Mega8, the USB detecting sound in Windows is quick three notes, and an Unkown Device is Identified):
Code: Select all
PROGMEM char usbHidReportDescriptor[28] = { /* USB report descriptor */
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x04,// USAGE (Joystick)
0xa1, 0x01, // COLLECTION (Application)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
0x15, 0x81, // LOGICAL_MINIMUM (-128)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x02,// REPORT_COUNT (2)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
};
I think the problem is on the descriptor, but i can't find the error.
I have changed the
Code:
Code: Select all
USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH
accordingly, and the right data buffer.
Who can tell me how to fix it?
When I changed the descriptor to 2 axes, I found the USB can't send correct data to PC, but why?
I found if i extend the X axis to 16bits ,the code can't workly properly too-- I mean it is indentified as Unknown Device.
Code: Select all
PROGMEM char usbHidReportDescriptor[29] = {
0x05, 0x01,// USAGE_PAGE (Generic Desktop)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x09, 0x04,// USAGE (Joystick)
0xa1, 0x01,// COLLECTION (Application)
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00,// COLLECTION (Physical)
0x15, 0x0,// LOGICAL_MINIMUM (0)
0x26, 0xff,0x03, // LOGICAL_MAXIMUM (1023)
0x75, 0x10, // REPORT_SIZE (16)
0x95, 0x01, // REPORT_COUNT (1)
0x09, 0x30, // USAGE (X)
0x81, 0x02, // INPUT (Data,Var,Abs)
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
};