This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SMT32 usb two HIDs

Hi,

working with the SMT32 processor, I've some troubles with the usb interface. I want to install two HID interface descriptors (each has one endpoint - endpoint1 and endpoint4).

In the device manager of my computer, I get two usb HID interfaces - which sounds good; but there's only a communication with the endpoint1 not with the endpoint4!

void USB_EndPoint3 (DWORD event) {
}

This function will be never called!

I tried to debug the code and I found out that at the beginning I get a Set-Address command with the addr 0x86 (which sounds good for these two endpoints); after that the host reads the usb device descriptor and the string descriptors; after that dataoutstage function is called, but the EP0Data.pData is 0x00...

void USB_DataOutStage (void) {
  DWORD cnt;

  cnt = USB_ReadEP(0x00, EP0Data.pData);
  EP0Data.pData += cnt;
  EP0Data.Count -= cnt;
}

After that an reset event occured; I don't know why...

And the whole process will start from the beginning; except that the endpoint4 won't be configurated again; that means Set-Address command includes only the first endpoint1 but not the endpoint4!

At the moment I've no idea where the problem could be!

void USB_Configure_Event (void)
{
  unsigned char InReportKeyboard[5];
  unsigned char InReportTouch[6];

        //es werden nur demo packets an die inputs geschickt keien richtigen daten
        memset( &InReportKeyboard[0], 0, sizeof(InReportKeyboard) );
        memset( &InReportTouch[0], 0, sizeof(InReportTouch) );


  if (USB_Configuration)
  {                  /* Check if USB is configured */

        USB_WriteEP(0x81, InReportKeyboard, sizeof(InReportKeyboard));
        USB_WriteEP(0x84, InReportTouch, sizeof(InReportTouch));
  }
}

Do someone know if this function is correct with these two USB_WriteEP calls?

These are my descriptors:

const BYTE USB_ConfigDescriptor[] = {
/* Configuration 1 */
  USB_CONFIGUARTION_DESC_SIZE,       /* bLength */
  USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
  WBVAL(                             /* wTotalLength */
    USB_CONFIGUARTION_DESC_SIZE +
    USB_INTERFACE_DESC_SIZE     +
    HID_DESC_SIZE               +
    USB_ENDPOINT_DESC_SIZE              +
        /* interface two: descriptor length */
        USB_INTERFACE_DESC_SIZE         +
        HID_DESC_SIZE                           +
        USB_ENDPOINT_DESC_SIZE

  ),
  0x02,                              /* bNumInterfaces */
  0x01,                              /* bConfigurationValue */
  0x00,                              /* iConfiguration */
  USB_CONFIG_SELF_POWERED //USB_CONFIG_BUS_POWERED /*|*/       /* bmAttributes */
/*USB_CONFIG_REMOTE_WAKEUP*/,
  USB_CONFIG_POWER_MA(0), //USB_CONFIG_POWER_MA(100),          /* bMaxPower */

USB_INTERFACE_DESC_SIZE,           /* bLength */
  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
  0x00,                              /* bInterfaceNumber */
  0x00,                              /* bAlternateSetting */
  0x01,                              /* bNumEndpoints */
  USB_DEVICE_CLASS_HUMAN_INTERFACE,  /* bInterfaceClass */
  HID_SUBCLASS_NONE,                 /* bInterfaceSubClass */
  HID_PROTOCOL_NONE,                 /* bInterfaceProtocol */
  0x5E,

HID_DESC_SIZE,                     /* bLength */
  HID_HID_DESCRIPTOR_TYPE,           /* bDescriptorType */
  WBVAL(0x0100), /* 1.00 */          /* bcdHID */
  0x00,                              /* bCountryCode */
  0x01,                              /* bNumDescriptors */
  HID_REPORT_DESCRIPTOR_TYPE,        /* bDescriptorType */
  WBVAL(HID_REPORT_DESC_SIZE),

USB_ENDPOINT_DESC_SIZE,            /* bLength */
  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
  USB_ENDPOINT_IN(1),                /* bEndpointAddress */
  USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */
  WBVAL(0x0008),                                         /* wMaxPacketSize (muss so groß sein, dass das kompl. pkt reinpasst an daten */
  0x25,

USB_INTERFACE_DESC_SIZE,           /* bLength */
  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
  0x01,                                  /* bInterfaceNumber -> zweites interface im configuration descriptor  */
  0x00,                              /* bAlternateSetting */
  0x01,                              /* bNumEndpoints -> wieviele endpoints besitzt dieses interface */
  USB_DEVICE_CLASS_HUMAN_INTERFACE,  /* bInterfaceClass */
  HID_SUBCLASS_NONE,                 /* bInterfaceSubClass */
  HID_PROTOCOL_NONE,                 /* bInterfaceProtocol */
  0x00,

HID_DESC_SIZE,                     /* bLength */
  HID_HID_DESCRIPTOR_TYPE,           /* bDescriptorType */
  WBVAL(0x0100), /* 1.00 */          /* bcdHID */
  0x00,                              /* bCountryCode */
  0x01,                              /* bNumDescriptors */
  HID_REPORT_DESCRIPTOR_TYPE,        /* bDescriptorType */
  WBVAL(HID_REPORT_DESC_SIZE_2),

USB_ENDPOINT_DESC_SIZE,            /* bLength */
  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
  USB_ENDPOINT_IN(4),                /* bEndpointAddress */
  USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */
  WBVAL(0x0008),                      /* wMaxPacketSize (muss so groß sein, dass das kompl. pkt (report descriptor) reinpasst an daten */
  0x20,

/* Terminator */
  0                                  /* bLength */

best regards
Jan