FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: USB Keyboard Host on VNCII  (Read 854 times)

tomekkicaj700

  • Newbie
  • *
  • Posts: 3
    • View Profile
USB Keyboard Host on VNCII
« on: March 31, 2020, 10:32:55 AM »

I have been using VNCII 32L for many years as USB flash drive host but now I'd like to use it as a host for hid keyboard or barcode reader.  I would like to  use USB1 interface as  flash drive host and  as HID host on USB2. I haven't found  any software example of USB  HID host on FTDI website, has anyone used the  VNCII chip that way?

Best regards
Tom
Logged

FTDI Community

  • Administrator
  • Sr. Member
  • *****
  • Posts: 469
    • View Profile
Re: USB Keyboard Host on VNCII
« Reply #1 on: April 01, 2020, 04:47:50 PM »

Hello,

There are plenty of examples available with the IDE.

Take a look at V2DAP:

C:\Users\Username\Documents\FTDI\Firmware\Samples\V2.0.2-SP2\VNC1L\V2DAP

This would allow a BOMs class device on Port 2 and HID class device on Port1.
You could customise the firmware to meet your needs or create your own custom firmware.

Also refer to the following documents:

Vinculum Firmware User Manual
AN_176 - Vinculum Comparison of VDAP and V2DAP

There may be other users on the forum who could help you further.

Best Regards,
FTDI Community
Logged

tomekkicaj700

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: USB Keyboard Host on VNCII
« Reply #2 on: April 02, 2020, 11:45:18 AM »

Hi!
Great, many thanks for this, I've also found AN_185 Vinculum-II UART to USB HID Class and got it to run on my VNC2 board and was able to read data from low speed usb keyboard. I'm getting data on each keypress and sent them to uart.
However, when I attached a Full-speed usb Barcode reader it didn't enumerate.  Below are the device descriptors for the barcode reader:
Code: [Select]
Connection Status Device connected
Current Configuration 1
Speed Full (12 Mbit/s)
Device Address 18
Number Of Open Pipes 3

Device Descriptor HID Keyboard
Offset Field Size Value Description
0 bLength 1 12h 
1 bDescriptorType 1 01h Device
2 bcdUSB 2 0200h USB Spec 2.0
4 bDeviceClass 1 00h Class info in Ifc Descriptors
5 bDeviceSubClass 1 00h 
6 bDeviceProtocol 1 00h 
7 bMaxPacketSize0 1 40h 64 bytes
8 idVendor 2 0111h 
10 idProduct 2 0111h 
12 bcdDevice 2 7008h 70.08
14 iManufacturer 1 01h " "
15 iProduct 1 02h "HID Keyboard"
16 iSerialNumber 1 03h "1.000"
17 bNumConfigurations 1 01h 

Configuration Descriptor 1
Offset Field Size Value Description
0 bLength 1 09h 
1 bDescriptorType 1 02h Configuration
2 wTotalLength 2 0042h 
4 bNumInterfaces 1 02h 
5 bConfigurationValue 1 01h 
6 iConfiguration 1 00h 
7 bmAttributes 1 C0h Self Powered
 4..0: Reserved  ...00000   
 5: Remote Wakeup  ..0.....  No
 6: Self Powered  .1......  Yes
 7: Reserved (set to one)
(bus-powered for 1.0)  1.......   
8 bMaxPower 1 32h 100 mA

Interface Descriptor 0/0 HID, 2 Endpoints
Offset Field Size Value Description
0 bLength 1 09h 
1 bDescriptorType 1 04h Interface
2 bInterfaceNumber 1 00h 
3 bAlternateSetting 1 00h 
4 bNumEndpoints 1 02h 
5 bInterfaceClass 1 03h HID
6 bInterfaceSubClass 1 01h Boot Interface
7 bInterfaceProtocol 1 01h Keyboard
8 iInterface 1 00h 

HID Descriptor
Offset Field Size Value Description
0 bLength 1 09h 
1 bDescriptorType 1 21h HID
2 bcdHID 2 0100h 1.00
4 bCountryCode 1 00h 
5 bNumDescriptors 1 01h 
6 bDescriptorType 1 22h Report
7 wDescriptorLength 2 0041h 65 bytes

Endpoint Descriptor 81 1 In, Interrupt, 5 ms
Offset Field Size Value Description
0 bLength 1 07h 
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 81h 1 In
3 bmAttributes 1 03h Interrupt
 1..0: Transfer Type  ......11  Interrupt
 7..2: Reserved  000000..   
4 wMaxPacketSize 2 0008h 8 bytes
6 bInterval 1 05h 5 ms

Endpoint Descriptor 01 1 Out, Interrupt, 5 ms
Offset Field Size Value Description
0 bLength 1 07h 
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 01h 1 Out
3 bmAttributes 1 03h Interrupt
 1..0: Transfer Type  ......11  Interrupt
 7..2: Reserved  000000..   
4 wMaxPacketSize 2 0008h 8 bytes
6 bInterval 1 05h 5 ms

Interface Descriptor 1/0 HID, 1 Endpoint
Offset Field Size Value Description
0 bLength 1 09h 
1 bDescriptorType 1 04h Interface
2 bInterfaceNumber 1 01h 
3 bAlternateSetting 1 00h 
4 bNumEndpoints 1 01h 
5 bInterfaceClass 1 03h HID
6 bInterfaceSubClass 1 00h 
7 bInterfaceProtocol 1 00h 
8 iInterface 1 00h 

HID Descriptor
Offset Field Size Value Description
0 bLength 1 09h 
1 bDescriptorType 1 21h HID
2 bcdHID 2 0110h 1.10
4 bCountryCode 1 00h 
5 bNumDescriptors 1 01h 
6 bDescriptorType 1 22h Report
7 wDescriptorLength 2 002Fh 47 bytes

Endpoint Descriptor 82 2 In, Interrupt, 5 ms
Offset Field Size Value Description
0 bLength 1 07h 
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 82h 2 In
3 bmAttributes 1 03h Interrupt
 1..0: Transfer Type  ......11  Interrupt
 7..2: Reserved  000000..   
4 wMaxPacketSize 2 0008h 8 bytes
6 bInterval 1 05h 5 ms


The reader works fine as HID Keyboard with my PC but VNC2 fails at the enumeration:

Code: [Select]
      // find first HID on USB Port 1
      hc_ioctlClass.dev_class = USB_CLASS_HID; //USB_CLASS_HID;
      hc_ioctlClass.dev_subclass = USB_SUBCLASS_ANY; //USB_CLASS_HID; //USB_SUBCLASS_ANY;
      hc_ioctlClass.dev_protocol = USB_PROTOCOL_ANY;

      // user ioctl to find first hub device

     
      hc_iocb.ioctl_code = VOS_IOCTL_USBHOST_DEVICE_FIND_HANDLE_BY_CLASS;
      hc_iocb.handle.dif = NULL;
      hc_iocb.set = &hc_ioctlClass;
      hc_iocb.get = &ifDev;

      printmsg("VNCLII: ioctl to find first hub device ");
      status = vos_dev_ioctl(hUSBHOST_1, &hc_iocb);

      if (status != USBHOST_OK)
      {
         printmsg("fail. Error:");
         
         itoa(status,buffer,10);    //  FAILS! status=1  (USBHOST_NOT_FOUND)
         
         printmsg(buffer); printmsg("\r\n");   
         
         continue;
      }
      else {
         
          printmsg("OK!\r\n");
         //continue;         
         
         
      }

The USB host configuration:

Code: [Select]
// Initialise USB Host
usbhostContext.if_count = 8;
usbhostContext.ep_count = 16;
usbhostContext.xfer_count = 2;
usbhostContext.iso_xfer_count = 2;
usbhost_init(VOS_DEV_USBHOST_1, -1, &usbhostContext);

Could it be that VNC2 may have a problem with Full speed HID device? 

This is a descriptor of my low speed keyboard:

Code: [Select]
Connection Status Device connected
Current Configuration 1
Speed Low (1.5 Mbit/s)
Device Address 1
Number Of Open Pipes 2

Device Descriptor USB Keyboard
Offset Field Size Value Description
0 bLength 1 12h 
1 bDescriptorType 1 01h Device
2 bcdUSB 2 0110h USB Spec 1.1
4 bDeviceClass 1 00h Class info in Ifc Descriptors
5 bDeviceSubClass 1 00h 
6 bDeviceProtocol 1 00h 
7 bMaxPacketSize0 1 08h 8 bytes
8 idVendor 2 1A2Ch 
10 idProduct 2 0B23h 
12 bcdDevice 2 0110h 1.10
14 iManufacturer 1 01h "USB"
15 iProduct 1 02h "USB Keyboard"
16 iSerialNumber 1 00h 
17 bNumConfigurations 1 01h 

Configuration Descriptor 1 Bus Powered, 100 mA
Offset Field Size Value Description
0 bLength 1 09h 
1 bDescriptorType 1 02h Configuration
2 wTotalLength 2 003Bh 
4 bNumInterfaces 1 02h 
5 bConfigurationValue 1 01h 
6 iConfiguration 1 00h 
7 bmAttributes 1 A0h Bus Powered, Remote Wakeup
 4..0: Reserved  ...00000   
 5: Remote Wakeup  ..1.....  Yes
 6: Self Powered  .0......  No, Bus Powered
 7: Reserved (set to one)
(bus-powered for 1.0)  1.......   
8 bMaxPower 1 32h 100 mA

Interface Descriptor 0/0 HID, 1 Endpoint
Offset Field Size Value Description
0 bLength 1 09h 
1 bDescriptorType 1 04h Interface
2 bInterfaceNumber 1 00h 
3 bAlternateSetting 1 00h 
4 bNumEndpoints 1 01h 
5 bInterfaceClass 1 03h HID
6 bInterfaceSubClass 1 01h Boot Interface
7 bInterfaceProtocol 1 01h Keyboard
8 iInterface 1 00h 

HID Descriptor
Offset Field Size Value Description
0 bLength 1 09h 
1 bDescriptorType 1 21h HID
2 bcdHID 2 0110h 1.10
4 bCountryCode 1 00h 
5 bNumDescriptors 1 01h 
6 bDescriptorType 1 22h Report
7 wDescriptorLength 2 0036h 54 bytes

Endpoint Descriptor 81 1 In, Interrupt, 10 ms
Offset Field Size Value Description
0 bLength 1 07h 
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 81h 1 In
3 bmAttributes 1 03h Interrupt
 1..0: Transfer Type  ......11  Interrupt
 7..2: Reserved  000000..   
4 wMaxPacketSize 2 0008h 8 bytes
6 bInterval 1 0Ah 10 ms

Interface Descriptor 1/0 HID, 1 Endpoint
Offset Field Size Value Description
0 bLength 1 09h 
1 bDescriptorType 1 04h Interface
2 bInterfaceNumber 1 01h 
3 bAlternateSetting 1 00h 
4 bNumEndpoints 1 01h 
5 bInterfaceClass 1 03h HID
6 bInterfaceSubClass 1 01h Boot Interface
7 bInterfaceProtocol 1 02h Mouse
8 iInterface 1 00h 

HID Descriptor
Offset Field Size Value Description
0 bLength 1 09h 
1 bDescriptorType 1 21h HID
2 bcdHID 2 0110h 1.10
4 bCountryCode 1 00h 
5 bNumDescriptors 1 01h 
6 bDescriptorType 1 22h Report
7 wDescriptorLength 2 006Ch 108 bytes

Endpoint Descriptor 82 2 In, Interrupt, 10 ms
Offset Field Size Value Description
0 bLength 1 07h 
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 82h 2 In
3 bmAttributes 1 03h Interrupt
 1..0: Transfer Type  ......11  Interrupt
 7..2: Reserved  000000..   
4 wMaxPacketSize 2 0005h 5 bytes
6 bInterval 1 0Ah 10 ms


Major difference is the speed and packet size (bMaxPacketSize0: 64B with the reader) but it shouldn't matter for VNC2?

best regards
Tom




Logged

FTDI Community

  • Administrator
  • Sr. Member
  • *****
  • Posts: 469
    • View Profile
Re: USB Keyboard Host on VNCII
« Reply #3 on: April 03, 2020, 04:33:52 PM »

Hello,

Vinculum and Vinculum-II are quite old solutions and it don’t seem to work with a lot of newer devices due to changing designs. Note that is only a Full Speed (12Mbits/second) controller.
These mature products have not had any development for years and have been superseded by FT9xx.

The best option would be to use the FT90x MCU, however note that this only includes 1 x USB Host and 1 x USB Device controller.
This uses a USB 2.0 Hi-Speed (480Mb/s) controller.

You could take a look at the following examples to host HID class devices:

AN_360 FT9xx Example Applications

There are significant benefits of FT90x over VNC2:

-Eclipse based IDE
-Source code for API drivers is provided
-Significant performance improvement
-Actively in development by R&D
-Improved documentation and software examples

We provide FT9xx Development Modules and a free FT9xx Toolchain for custom application development.

Best Regards,
FTDI Community
Logged

tomekkicaj700

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: USB Keyboard Host on VNCII
« Reply #4 on: April 04, 2020, 05:46:22 PM »

Hi!

Thank you for your response.
Would the FT90x work  with a USB hub? If not, what is the best way to multiplex the D+/- pins of the FT90x? I will always have the barcode reader connected  and usb flash  drive will be connected  occasionally. I will have 2 separate USB connectors on the PCB, one for  the reader and another for the flash drive.
Do you think the attached schematic would work?

When the flash drive needs to be used I could reset the FT90 and change it's configuration in software to switch from HID to MSC Host. When flash drive is removed I reset the FT90 again, switch it to HID Host so that it enumerates again the keyboard/barcode reader.

Best regards
Tom
« Last Edit: April 04, 2020, 08:53:28 PM by tomekkicaj700 »
Logged

FTDI Community

  • Administrator
  • Sr. Member
  • *****
  • Posts: 469
    • View Profile
Re: USB Keyboard Host on VNCII
« Reply #5 on: April 07, 2020, 04:33:44 PM »

Hello,

Yes the FT90x can be used with an external HUB allowing for BOMs and HID class hosting.

Best Regards,
FTDI Community
Logged

kaspro

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: USB Keyboard Host on VNCII
« Reply #6 on: April 15, 2020, 05:42:29 AM »

Just a heads up, I've been working on hardware for the Nintendo Switch, which requires bMaxPacketSize0 to be 64.

Once I change that value from 8 to 64 though, the VNC2 fails. I'm about to make a separate forum post about this, but I've invested a lot of time into this project so far and would really like to know if the VNC2 is just not capable of doing bMaxPacketSize0 = 64.
Logged

FTDI Community

  • Administrator
  • Sr. Member
  • *****
  • Posts: 469
    • View Profile
Re: USB Keyboard Host on VNCII
« Reply #7 on: April 16, 2020, 04:37:22 PM »

Hello Kaspro,

The FT90x will handle this better than VNC2.

You are also in contact with our support team on this issue via email.
Feel free to post any resolution or information from the email support to help other forum users.

Best Regards,
FTDI Community
Logged