AnsweredAssumed Answered

USB HOST HID problems to attach multi-interface USB keyboard device on FRDM-KL25Z

Question asked by Tom Kim on Oct 2, 2013

Hello! I try to make USB host using FRDM-KL25Z but it has some

problem to attach multi-interface USB keyboard.

I installed USB Stack v4.1.1 and CWv10.4.

I have gaming keyboard and multimedia keyboard which have two

interface in a single usb device. If I connect it to the PC, it install two keyboards.

 

Anyway I programmed USB host on the FRDM-KL25Z like below in a ProcessorExpert.C.

Made two keyboard tasks.

 

...

_usb_event_init(&USB_Keyboard1_Event); 
_usb_event_init(&USB_Keyboard2_Event); 
...
  for(;;){
      if(keyboard1_hid_device.DEV_STATE != USB_DEVICE_IDLE) {
            Keyboard1_Task();
       }
      if(keyboard2_hid_device.DEV_STATE != USB_DEVICE_IDLE) {
            Keyboard2_Task();
      }

      Poll();  

   }

...

 

In a Device_driver.info.c

const USB_HOST_DRIVER_INFO DriverInfoTable[] =
{
{ // Keyboard1
   {0x00,0x00},     /* Vendor ID per USB-IF    */
   {0x00,0x00},     /* Product ID per manufacturer  */
   USB_CLASS_HID,    /* Class code      */
   USB_SUBCLASS_HID_BOOT,  /* Sub-Class code     */
   USB_PROTOCOL_HID_KEYBOARD, /* Protocol       */
   0,       /* Reserved       */
   usb_host_hid_keyboard1_event /* Application call back function */
   },
   { // Keyboard2
   {0x00,0x00},     /* Vendor ID per USB-IF    */
   {0x00,0x00},     /* Product ID per manufacturer  */
   USB_CLASS_HID,    /* Class code      */
   USB_SUBCLASS_HID_BOOT,  /* Sub-Class code     */
   USB_PROTOCOL_HID_KEYBOARD, /* Protocol       */
   0,       /* Reserved       */
   usb_host_hid_keyboard2_event /* Application call back function */
   },
   {
   {0x00,0x00},     /* All-zero entry terminates  */
   {0x00,0x00},     /* driver info list.    */
   0,
   0,
   0,
   0,
   NULL
   }
};

 

But it does not working properly, for gaming keyboard, Only Keyboard2_Task() working properly. When i press more than 6 keys at the same time KL25Z does not working any more until reset the MCU.

 

I think the usb host stack may some problems to initiate multi-interface USB device.

Below is the logo message when attach the 2-interface keyboard usb device to KL25Z usb host.

 

===========================================

USB HID Keyboard Waiting for attached...

[KBD1] ----- Attach Event -----

[KBD1] State = 0  Class = 3  SubClass = 1  Protocol = 1

[KBD2] ----- Attach Event -----

[KBD2] State = 0  Class = 3  SubClass = 1  Protocol = 1

[KBD1] ----- Attach Event -----

[KBD1] State = 1  Class = 3  SubClass = 1  Protocol = 1

[KBD1] HID device already attached

[KBD2] ----- Attach Event -----

[KBD2] State = 1  Class = 3  SubClass = 1  Protocol = 1

[KBD2] HID device already attached

[KBD1] ----- Interfaced Event -----

[KBD2] ----- Interfaced Event -----

[KBD1] ----- Interfaced Event -----

[KBD2] ----- Interfaced Event -----

[KBD1] Keyboard device interfaced, setting protocol...

[KBD1] Error in usb_class_hid_set_protocol! STATUS 0xca

[KBD2] Keyboard device interfaced, setting protocol...

[KBD2] Keyboard device ready, try to press the keyboard

===========================================

How can I solve this issue?

Outcomes