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

Thread: Teensy 4 USB incompatibilities with Teensy 3 - SEREMU and ep1

  1. #1
    Junior Member
    Join Date
    Jun 2016
    Location
    Melbourne Australia
    Posts
    12

    Teensy 4 USB incompatibilities with Teensy 3 - SEREMU and ep1

    In porting a project from Teensy 3.2 to Teensy 4.0 I have come across a couple of small RAWHID incompatibilities.

    The first one is that (at least with the Teensyduino 1.55) I can't compile without a SEREMU_INTERFACE.

    i.e. something like this in usb_desc.h:

    Code:
    #if defined(USB_CUSTOMRAWHID)
    
      #define VENDOR_ID         0x16C0
      #define PRODUCT_ID        0x1234
    
      #define RAWHID_USAGE_PAGE 0xFFAB  // recommended: 0xFF00 to 0xFFFF
      #define RAWHID_USAGE      0x0200  // recommended: 0x0100 to 0xFFFF
    
      #define MANUFACTURER_NAME {'a','b','c','d'}
      #define MANUFACTURER_NAME_LEN 4
      #define PRODUCT_NAME      {'a','b','c','d'}
      #define PRODUCT_NAME_LEN  4
    
      #define EP0_SIZE      64
      #define NUM_ENDPOINTS     2
    
      #define NUM_INTERFACE     1
    
      #define RAWHID_INTERFACE      0 
      #define RAWHID_TX_ENDPOINT    2
      #define RAWHID_TX_SIZE        64
      #define RAWHID_TX_INTERVAL    1
      #define RAWHID_RX_ENDPOINT    2
      #define RAWHID_RX_SIZE        64
      #define RAWHID_RX_INTERVAL    1
      #define ENDPOINT2_CONFIG  ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_INTERRUPT
    
    #elif ...
    results in the following errors:
    Code:
    yield.cpp:60:7: error: 'Serial' was not declared in this scope
       if (Serial.available()) serialEvent();
           ^
    yield.cpp:60:39: error: 'serialEvent' was not declared in this scope
       if (Serial.available()) serialEvent();
    Applying the following change to yield.cpp:

    Code:
    #if defined(SEREMU_INTERFACE) || defined(USB_SERIAL) || defined(USB_DUAL_SERIAL) || defined(USB_TRIPLE_SERIAL)
        // USB Serail - Add hack to minimize impact...
        if (yield_active_check_flags & YIELD_CHECK_USB_SERIAL) {
            if (Serial.available()) serialEvent();
            if (_serialEvent_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIAL;
        }
    #endif
    appears to fix the error, but does leave two warnings.

    The other issue is that it seem that with the current Teensy 4 code it's not possible to use end point 1. Given that the hardware
    only supports 8 end points and 0 is reserved for the control channel, it seems a pity to waste one.

    I made the necessary changes to usb.c to allow for end point 1, i.e. adding
    Code:
    #if defined(ENDPOINT1_CONFIG)
    USB1_ENDPTCTRL1 = ENDPOINT1_CONFIG;
    #endif
    to endpoint0_setup(), modifying usb_config_rx(), usb_config_tx() etc. to return on ep < 1 rather than ep < 2,
    as well as usb_transmit() and usb_receive(), and end point 1 then appeared to be usable.

    Is there a reason ep 1 is not available ?

    (I note that the USB_EVERYTHING config. uses ep 1 as well as up to ep 15, so would be unlikely to work on a Teensy 4 ?)

  2. #2
    Senior Member
    Join Date
    Apr 2020
    Location
    DFW area in Texas
    Posts
    292
    Quote Originally Posted by Graeme Gill View Post
    Is there a reason ep 1 is not available ?

    (I note that the USB_EVERYTHING config. uses ep 1 as well as up to ep 15, so would be unlikely to work on a Teensy 4 ?)
    @Graeme:

    I don't know the entire technical reason(s) that endpoint 1 is not to be used, but there's a comment <here> by @Paul Stoffregen on another thread where he indicates that endpoint 1 is reserved for T4.x.

    Hope that helps . . .

    Mark J Culross
    KD5RXT

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,038
    Quote Originally Posted by Graeme Gill View Post
    Is there a reason ep 1 is not available ?
    Yes, there is a reason. Endpoint 1 is reserved for a future feature, which I'm not prepared to discuss at this time.


    (I note that the USB_EVERYTHING config. uses ep 1 as well as up to ep 15, so would be unlikely to work on a Teensy 4 ?)
    Indeed, the everything option needs far too many endpoints to work on Teensy 4.x, even if endpoint 1 were available.

  4. #4
    Junior Member
    Join Date
    Jun 2016
    Location
    Melbourne Australia
    Posts
    12
    Quote Originally Posted by PaulStoffregen View Post
    Yes, there is a reason. Endpoint 1 is reserved for a future feature, which I'm not prepared to discuss at this time.
    I guess it doesn't make much difference for HID, but I can imagine attempting to use a Teensy to emulate other non-HID devices where there is no choice but to use ep 1. I guess that's not a common usage though, since it means writing a non-HID USB driver for it.

Posting Permissions

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