I am having trouble getting a descriptor for Bulk-Out Endpoint 1. I too get -22 returned from writing to this endpoint.
In usbconfig.h I have:
Code: Select all
#define USB_CFG_DESCR_PROPS_CONFIGURATION USB_PROP_IS_DYNAMIC
In main.c I have this for the descriptor:
Code: Select all
PROGMEM char configDescriptor[] = { /* USB configuration descriptor */
9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */
USBDESCR_CONFIG, /* descriptor type */
25, /* total length of data returned (including inlined descriptors) */
0,
1, /* number of interfaces in this configuration */
1, /* index of this configuration */
0, /* configuration name string index */
#if USB_CFG_IS_SELF_POWERED
USBATTR_SELFPOWER, /* attributes */
#else
USBATTR_BUSPOWER, /* attributes */
#endif
USB_CFG_MAX_BUS_POWER/2, /* max USB current in 2mA units */
/* interface descriptor follows inline: */
9, /* sizeof(usbDescrInterface): length of descriptor in bytes */
USBDESCR_INTERFACE, /* descriptor type */
0, /* index of this interface */
0, /* alternate setting for this interface */
1, /* endpoints excl 0: number of endpoint descriptors to follow */
USB_CFG_INTERFACE_CLASS,
USB_CFG_INTERFACE_SUBCLASS,
USB_CFG_INTERFACE_PROTOCOL,
0, /* string index for interface */
/* endpoint descriptor for endpoint 1 out */
7, /* sizeof(usbDescrEndpoint) */
USBDESCR_ENDPOINT, /* descriptor type = endpoint */
0x01, /* Out endpoint number 1 */
0x02, /* attrib: Bulk endpoint */
8, 0, /* maximum packet size */
USB_CFG_INTR_POLL_INTERVAL+25 /* in ms */
};
uchar usbFunctionDescriptor( struct usbRequest *rq ) {
uchar *p = NULL, len = 0;
if(rq->wValue.bytes[1] == USBDESCR_CONFIG){
p = (uchar *)configDescriptor;
len = sizeof(configDescriptor);
}
usbMsgPtr = p;
return len;
}
libusb shows this about my device:
Code: Select all
wTotalLength: 18
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: 80h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 0
bInterfaceClass: 0
bInterfaceSubClass: 0
bInterfaceProtocol: 0
iInterface: 0
Any help would be appreciated. Thanks in advance.
EDIT: I got it to work. Oddly enough I had removed the symbol to oddebug.o from the Makefile and I added it back to try and debug the device. After adding the symbol it worked.