Skip to content

[teensy4] Why are the same USB endpoints used for both RX & TX #769

@forderud

Description

@forderud

The teensy4 usb_desc.h contain a mix of configurations where the same USB endpoint number is used for both transmit & receive for a given interface, and configurations where different endpoint numbers are used. The former puzzles me, since I though USB data endpoints were supposed to be unidirectional.

Some examples of same endpoint numbers:

  • USB_DUAL_SERIAL defines both CDC_RX_ENDPOINT and CDC_TX_ENDPOINT to 3.
  • USB_DUAL_SERIAL defines both CDC2_RX_ENDPOINT and CDC2_TX_ENDPOINT to 5.
  • USB_KEYBOARDONLY defines both SEREMU_TX_ENDPOINT and SEREMU_RX_ENDPOINT to 2.
  • USB_MIDI defines both SEREMU_TX_ENDPOINT and SEREMU_RX_ENDPOINT to 2.
  • USB_MIDI defines both MIDI_TX_ENDPOINT and MIDI_RX_ENDPOINT to 3.
  • USB_FLIGHTSIM defines both FLIGHTSIM_TX_ENDPOINT and FLIGHTSIM_RX_ENDPOINT to 3.

It seems endpoint number reuse is enabled by a bEndpointAddress =| 0x80 in the USB configuration descriptor, which increases the actual endpoint number by 128.

Some examples of different endpoint numbers:

  • USB_SERIAL defines CDC_RX_ENDPOINT to 3 and CDC_TX_ENDPOINT to 4.
  • USB_RAWHID defines RAWHID_TX_ENDPOINT to 3 and RAWHID_RX_ENDPOINT to 4.
  • USB_EVERYTHING contains a commented-out MTP_TX_ENDPOINT define to 11 and MTP_RX_ENDPOINT define to 3.

Could it make sense to either always use the same endpoint number for TX & RX, or always use different numbers?

some exam

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions