summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2022-02-25 22:26:35 +0700
committerhathach <[email protected]>2022-02-25 22:26:35 +0700
commit309540473bc2985d83212b9da0527c7500ba2a66 (patch)
treeb45ab451447a0d33075db62310603501ea94e6f5 /src
parent99ad3ae2ca9d4db79b2ac92a6991ebdc3dfb94a3 (diff)
minor house keeping
Diffstat (limited to 'src')
-rw-r--r--src/class/msc/msc_host.c2
-rw-r--r--src/common/tusb_error.h2
-rw-r--r--src/device/usbd.c4
-rw-r--r--src/host/usbh.c1
-rw-r--r--src/tusb.c2
-rw-r--r--src/tusb_option.h15
6 files changed, 20 insertions, 6 deletions
diff --git a/src/class/msc/msc_host.c b/src/class/msc/msc_host.c
index a49a10522..e4239e375 100644
--- a/src/class/msc/msc_host.c
+++ b/src/class/msc/msc_host.c
@@ -26,7 +26,7 @@
#include "tusb_option.h"
-#if CFG_TUH_ENABLED & CFG_TUH_MSC
+#if CFG_TUH_ENABLED && CFG_TUH_MSC
#include "host/usbh.h"
#include "host/usbh_classdriver.h"
diff --git a/src/common/tusb_error.h b/src/common/tusb_error.h
index d7ad8c318..42541acd6 100644
--- a/src/common/tusb_error.h
+++ b/src/common/tusb_error.h
@@ -64,6 +64,8 @@ typedef enum
#if CFG_TUSB_DEBUG
/// Enum to String for debugging purposes. Only available if \ref CFG_TUSB_DEBUG > 0
extern char const* const tusb_strerr[TUSB_ERROR_COUNT];
+extern char const* const tusb_speed_str[];
+
#endif
#ifdef __cplusplus
diff --git a/src/device/usbd.c b/src/device/usbd.c
index e6861ee0a..c20bab76b 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -332,8 +332,6 @@ static char const* const _tusb_std_request_str[] =
"Synch Frame"
};
-static char const* const _tusb_speed_str[] = { "Full", "Low", "High" };
-
// for usbd_control to print the name of control complete driver
void usbd_driver_print_control_complete_name(usbd_control_xfer_cb_t callback)
{
@@ -509,7 +507,7 @@ void tud_task (void)
switch ( event.event_id )
{
case DCD_EVENT_BUS_RESET:
- TU_LOG2(": %s Speed\r\n", _tusb_speed_str[event.bus_reset.speed]);
+ TU_LOG2(": %s Speed\r\n", tusb_speed_str[event.bus_reset.speed]);
usbd_reset(event.rhport);
_usbd_dev.speed = event.bus_reset.speed;
break;
diff --git a/src/host/usbh.c b/src/host/usbh.c
index e29ce1e54..ce0ccc3cb 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -709,6 +709,7 @@ static bool enum_new_device(hcd_event_t* event)
if ( !hcd_port_connect_status(_dev0.rhport) ) return true;
_dev0.speed = hcd_port_speed_get(_dev0.rhport );
+ TU_LOG2("%s Speed\r\n", tusb_speed_str[_dev0.speed]);
enum_request_addr0_device_desc();
}
diff --git a/src/tusb.c b/src/tusb.c
index 03fe43104..a30221059 100644
--- a/src/tusb.c
+++ b/src/tusb.c
@@ -163,6 +163,8 @@ uint16_t tu_desc_get_interface_total_len(tusb_desc_interface_t const* desc_itf,
char const* const tusb_strerr[TUSB_ERROR_COUNT] = { ERROR_TABLE(ERROR_STRING) };
+char const* const tusb_speed_str[] = { "Full", "Low", "High" };
+
static void dump_str_line(uint8_t const* buf, uint16_t count)
{
tu_printf(" |");
diff --git a/src/tusb_option.h b/src/tusb_option.h
index 6a3638461..5bf336438 100644
--- a/src/tusb_option.h
+++ b/src/tusb_option.h
@@ -223,8 +223,19 @@
// CFG_TUD_SPEED OPT_MODE_HIGH_SPEED
//------------- Roothub as Host -------------//
-#define TUH_OPT_RHPORT ( ((CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HOST) ? 0 : (((CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HOST) ? 1 : -1) )
-#define CFG_TUH_ENABLED ( TUH_OPT_RHPORT >= 0 )
+
+#if (CFG_TUSB_RHPORT0_MODE) & OPT_MODE_HOST
+ #define TUH_RHPORT_MODE (CFG_TUSB_RHPORT0_MODE)
+ #define TUH_OPT_RHPORT 0
+#elif (CFG_TUSB_RHPORT1_MODE) & OPT_MODE_HOST
+ #define TUH_RHPORT_MODE (CFG_TUSB_RHPORT1_MODE)
+ #define TUH_OPT_RHPORT 1
+#else
+ #define TUH_RHPORT_MODE OPT_MODE_NONE
+ #define TUH_OPT_RHPORT -1
+#endif
+
+#define CFG_TUH_ENABLED ( TUH_RHPORT_MODE & OPT_MODE_HOST )
// For backward compatible
#define TUSB_OPT_DEVICE_ENABLED CFG_TUD_ENABLED