From 8c990885e304079e9e381f3899a53105c824624b Mon Sep 17 00:00:00 2001 From: Jie Feng Date: Sun, 14 Jun 2026 20:25:02 +0800 Subject: Fix one direction endpoint examples --- examples/device/midi2_device/src/usb_descriptors.c | 4 ++++ examples/device/usbtmc/src/usb_descriptors.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/examples/device/midi2_device/src/usb_descriptors.c b/examples/device/midi2_device/src/usb_descriptors.c index 19a43f2d8..f035f9c48 100644 --- a/examples/device/midi2_device/src/usb_descriptors.c +++ b/examples/device/midi2_device/src/usb_descriptors.c @@ -70,7 +70,11 @@ enum { // Endpoint addresses #define EPNUM_MIDI2_OUT 0x01 +#if CFG_TUD_ENDPOINT_ONE_DIRECTION_ONLY +#define EPNUM_MIDI2_IN 0x82 +#else #define EPNUM_MIDI2_IN 0x81 +#endif static uint8_t const desc_fs_configuration[] = { // Config number, interface count, string index, total length, attribute, power in mA diff --git a/examples/device/usbtmc/src/usb_descriptors.c b/examples/device/usbtmc/src/usb_descriptors.c index 16bd176f8..ecdcef834 100644 --- a/examples/device/usbtmc/src/usb_descriptors.c +++ b/examples/device/usbtmc/src/usb_descriptors.c @@ -79,16 +79,26 @@ uint8_t const * tud_descriptor_device_cb(void) #if defined(CFG_TUD_USBTMC) +#if CFG_TUD_ENDPOINT_ONE_DIRECTION_ONLY +# define EPNUM_USBTMC_OUT 0x01 +# define EPNUM_USBTMC_IN 0x82 +# define EPNUM_USBTMC_INT 0x83 +#else +# define EPNUM_USBTMC_OUT 0x01 +# define EPNUM_USBTMC_IN 0x81 +# define EPNUM_USBTMC_INT 0x82 +#endif + # define TUD_USBTMC_DESC_MAIN(_itfnum,_bNumEndpoints, _bulkMaxPacketLength) \ TUD_USBTMC_IF_DESCRIPTOR(_itfnum, _bNumEndpoints, /*_stridx = */ 4u, TUD_USBTMC_PROTOCOL_USB488), \ - TUD_USBTMC_BULK_DESCRIPTORS(/* OUT = */0x01, /* IN = */ 0x81, /* packet size = */_bulkMaxPacketLength) + TUD_USBTMC_BULK_DESCRIPTORS(EPNUM_USBTMC_OUT, EPNUM_USBTMC_IN, /* packet size = */_bulkMaxPacketLength) #if CFG_TUD_USBTMC_ENABLE_INT_EP // USBTMC Interrupt xfer always has length of 2, but we use epMaxSize=8 for // compatibility with mcus that only allow 8, 16, 32 or 64 for FS endpoints # define TUD_USBTMC_DESC(_itfnum, _bulkMaxPacketLength) \ TUD_USBTMC_DESC_MAIN(_itfnum, /* _epCount = */ 3, _bulkMaxPacketLength), \ - TUD_USBTMC_INT_DESCRIPTOR(/* INT ep # */ 0x82, /* epMaxSize = */ 8, /* bInterval = */16u ) + TUD_USBTMC_INT_DESCRIPTOR(EPNUM_USBTMC_INT, /* epMaxSize = */ 8, /* bInterval = */16u ) # define TUD_USBTMC_DESC_LEN (TUD_USBTMC_IF_DESCRIPTOR_LEN + TUD_USBTMC_BULK_DESCRIPTORS_LEN + TUD_USBTMC_INT_DESCRIPTOR_LEN) #else -- cgit v1.3.1