summaryrefslogtreecommitdiff
path: root/examples/device/usbtmc
diff options
context:
space:
mode:
authorhathach <[email protected]>2020-08-07 12:13:13 +0700
committerhathach <[email protected]>2020-08-07 12:13:13 +0700
commit9df8057702fcbc8086b223c164e1734db7beca25 (patch)
tree5faef86eca48cc7664ae0b29db3e885edba75bdb /examples/device/usbtmc
parentc14c0cfc9fec9101b63df682c5fa5ac0576de0f8 (diff)
parentc682c30fa6a99a91d02496de39a752b5c96a4634 (diff)
Merge branch 'master' into add-app-driver
Diffstat (limited to 'examples/device/usbtmc')
-rw-r--r--examples/device/usbtmc/src/tusb_config.h38
-rw-r--r--examples/device/usbtmc/src/usb_descriptors.c4
2 files changed, 32 insertions, 10 deletions
diff --git a/examples/device/usbtmc/src/tusb_config.h b/examples/device/usbtmc/src/tusb_config.h
index 1022125bb..603e67453 100644
--- a/examples/device/usbtmc/src/tusb_config.h
+++ b/examples/device/usbtmc/src/tusb_config.h
@@ -16,18 +16,38 @@
// COMMON CONFIGURATION
//--------------------------------------------------------------------
-// defined by compiler flags for flexibility
+// defined by board.mk
#ifndef CFG_TUSB_MCU
#error CFG_TUSB_MCU must be defined
#endif
-#if CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || \
- CFG_TUSB_MCU == OPT_MCU_NUC505 || CFG_TUSB_MCU == OPT_MCU_CXD56
- #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED)
+// RHPort number used for device can be defined by board.mk, default to port 0
+#ifndef BOARD_DEVICE_RHPORT_NUM
+ #define BOARD_DEVICE_RHPORT_NUM 0
+#endif
+
+// RHPort max operational speed can defined by board.mk
+// Default to Highspeed for MCU with internal HighSpeed PHY (can be port specific), otherwise FullSpeed
+#ifndef BOARD_DEVICE_RHPORT_SPEED
+ #if (CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || \
+ CFG_TUSB_MCU == OPT_MCU_NUC505 || CFG_TUSB_MCU == OPT_MCU_CXD56)
+ #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_HIGH_SPEED
+ #else
+ #define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED
+ #endif
+#endif
+
+// Device mode with rhport and speed defined by board.mk
+#if BOARD_DEVICE_RHPORT_NUM == 0
+ #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED)
+#elif BOARD_DEVICE_RHPORT_NUM == 1
+ #define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED)
#else
- #define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
+ #error "Incorrect RHPort configuration"
#endif
-#define CFG_TUSB_OS OPT_OS_NONE
+
+// This example doesn't use an RTOS
+#define CFG_TUSB_OS OPT_OS_NONE
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
// #define CFG_TUSB_DEBUG 0
@@ -57,9 +77,9 @@
//------------- CLASS -------------//
-#define CFG_TUD_USBTMC 1
-#define CFG_TUD_USBTMC_ENABLE_INT_EP 1
-#define CFG_TUD_USBTMC_ENABLE_488 1
+#define CFG_TUD_USBTMC 1
+#define CFG_TUD_USBTMC_ENABLE_INT_EP 1
+#define CFG_TUD_USBTMC_ENABLE_488 1
#ifdef __cplusplus
}
diff --git a/examples/device/usbtmc/src/usb_descriptors.c b/examples/device/usbtmc/src/usb_descriptors.c
index 86d78e1cd..505456769 100644
--- a/examples/device/usbtmc/src/usb_descriptors.c
+++ b/examples/device/usbtmc/src/usb_descriptors.c
@@ -166,7 +166,8 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
}
else
{
- // Convert ASCII string into UTF-16
+ // Note: the 0xEE index string is a Microsoft OS 1.0 Descriptors.
+ // https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors
if ( !(index < sizeof(string_desc_arr)/sizeof(string_desc_arr[0])) ) return NULL;
@@ -178,6 +179,7 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
chr_count = 31;
}
+ // Convert ASCII string into UTF-16
for(uint8_t i=0; i<chr_count; i++)
{
_desc_str[1+i] = str[i];