Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Simultaneous USB Host and Device mode

  1. #1
    Junior Member
    Join Date
    Jun 2019
    Location
    Huntsville
    Posts
    5

    Simultaneous USB Host and Device mode

    Hello all,

    I've seen the question asked several times in the past couple of years on these forums as to the possibility of acting as a USB host. They most recent question asking this specifically that I have seen was in 2017.
    Where I'm interning right now, they love Teensys. Originally the project lead wanted to use a Teensy 3.2 to act as a keyboard passthrough device, simply logging all HID data coming through, first being interpreted by another board, and passing it on. Things didn't work right.
    I've moved on to the Teensy 3.6 because I've seen it has two USB ports. That's much better than what we were using before. My current predicament though:

    Is it possible to use both the USBHost_t36.h library to act as a host to a keyboard on the second USB port, and use the native RAWHid class or the Keyboard class (also available to other Teensys) to be a USB input on the first port at the same time?

    If so, how would I specify which USB port I want to act as a the host and which to show up as device? Or are they hardcoded in so that the second (pin in) USB port acts as the Host always and the mini USB always acts as the device?

    Thank you a lot.
    Also, If there is a spec sheet available on these devices that I've missed, I would love to read it.

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    8,825
    The processor manuals for each Teeny are linked on the PJRC.com - as are the schematics for actual MCU connections to each board.

    The T_3.6 USB device micro USB connector is independent of the internal pins representing the USB Host port. So they may be used independently for whatever functions are offered by the chip and represented in code. The Device port can do RAWHid while the Host port can be programmed for separate function starting with the USBHost_t36.h library.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,171
    Quote Originally Posted by supersquirel500 View Post
    Is it possible to use both the USBHost_t36.h library to act as a host to a keyboard on the second USB port, and use the native RAWHid class or the Keyboard class (also available to other Teensys) to be a USB input on the first port at the same time?
    Yes. The 2 USB ports are independent and can be used simultaneously.


    If so, how would I specify which USB port I want to act as a the host and which to show up as device? Or are they hardcoded in so that the second (pin in) USB port acts as the Host always and the mini USB always acts as the device?
    The main port always acts as a USB device and the 2nd port (5 pin header) always acts as USB host.

    Perhaps in the future there may be code to make the 2nd port run in device mode (allowing communication to 2 different computers), but today only host mode is supported.

    While the hardware can theoretically do it, we're not ever planning to support host mode on the main USB port.


    Also, If there is a spec sheet available on these devices that I've missed, I would love to read it.
    Yes, the K66 reference manual is here:

    https://www.pjrc.com/teensy/datasheets.html

    There are 2 chapters for the 2nd USB port. One covers the controller and the other covers the PHY (analog part). Normally you just turn the PHY on (USBHost_t36 does this) and don't worry about it much. The controller is the main part you use. Even then, you would normally just uses the driver classes USBHost_t36 provides, or if you want to add a driver for a specific device, you'd usually use the 5-function driver API explained in USBHost_t36.h rather than interact directly with the USB hardware.

    But if you *really* want to know the details, in host mode the 2nd port (mostly) follows the EHCI 1.0 spec, which you can get from Intel's website. The K66 manual doesn't cover much of the EHCI info.

    https://www.intel.com/content/www/us...ification.html

    Normally you would only need to read this if you wish to make edits inside ehci.cpp in the USBHost_t36 library. That part is quite complicated. Unless you want to use isochronous endpoints/pipes (which currently aren't implemented), you probably won't need to touch that part. Everything other than isochronous is supported and pretty well tested (by the many driver classes). But the full documentation is available if you really want to know how it works down to the lowest level.

    You'll also need the USB 2.0 spec, which you can get at www.usb.org, but it's buried inside lots of other stuff. Here's a direct link to just the PDF.

    https://www.pjrc.com/teensy/beta/usb20.pdf
    Last edited by PaulStoffregen; 06-25-2019 at 08:58 PM.

  4. #4
    Junior Member
    Join Date
    Jun 2019
    Location
    Huntsville
    Posts
    5
    That answers my question, thank you both!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •