summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2022-02-26 01:00:07 +0700
committerGitHub <[email protected]>2022-02-26 01:00:07 +0700
commit5b7a01ba79f7a048ddea3b5dedf187746cd21225 (patch)
treef2ae941108ea7c3c610c92de4fe95431be149176 /src/host
parent13a4582ce25cd47e346f317c9eb412af7a2c17a2 (diff)
parent1482a415240171b7ff2bd2ee0f123635dd15f9a4 (diff)
Merge pull request #1350 from hathach/enhance-multipl-ports
Enhance rhports management
Diffstat (limited to 'src/host')
-rw-r--r--src/host/hcd.h3
-rw-r--r--src/host/hcd_attr.h105
-rw-r--r--src/host/hub.c2
-rw-r--r--src/host/usbh.c17
-rw-r--r--src/host/usbh_classdriver.h2
-rw-r--r--src/host/usbh_control.c2
6 files changed, 20 insertions, 111 deletions
diff --git a/src/host/hcd.h b/src/host/hcd.h
index eb53d2e80..80500f048 100644
--- a/src/host/hcd.h
+++ b/src/host/hcd.h
@@ -30,7 +30,6 @@
#include "common/tusb_common.h"
#include "osal/osal.h"
#include "common/tusb_fifo.h"
-#include "hcd_attr.h"
#ifdef __cplusplus
extern "C" {
@@ -82,7 +81,7 @@ typedef struct
} hcd_event_t;
-#if TUSB_OPT_HOST_ENABLED
+#if CFG_TUH_ENABLED
// Max number of endpoints per device
enum {
// TODO better computation
diff --git a/src/host/hcd_attr.h b/src/host/hcd_attr.h
deleted file mode 100644
index 06011c63c..000000000
--- a/src/host/hcd_attr.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2021, Ha Thach (tinyusb.org)
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * This file is part of the TinyUSB stack.
- */
-
-#ifndef TUSB_HCD_ATTR_H_
-#define TUSB_HCD_ATTR_H_
-
-#include "tusb_option.h"
-
-// Attribute includes
-// - ENDPOINT_MAX: max (logical) number of endpoint
-// - PORT_HIGHSPEED: mask to indicate which port support highspeed mode, bit0 for port0 and so on.
-
-//------------- NXP -------------//
-#if TU_CHECK_MCU(OPT_MCU_LPC175X_6X, OPT_MCU_LPC177X_8X, OPT_MCU_LPC40XX)
- #define HCD_ATTR_OHCI
-
-#elif TU_CHECK_MCU(OPT_MCU_LPC18XX, OPT_MCU_LPC43XX)
- #define HCD_ATTR_EHCI_TRANSDIMENSION
-
-#elif TU_CHECK_MCU(OPT_MCU_LPC54XXX)
- // #define HCD_ATTR_EHCI_NXP_PTD
-
-#elif TU_CHECK_MCU(OPT_MCU_LPC55XX)
- // #define HCD_ATTR_EHCI_NXP_PTD
-
-#elif TU_CHECK_MCU(OPT_MCU_MIMXRT10XX)
- #define HCD_ATTR_EHCI_TRANSDIMENSION
-
-#elif TU_CHECK_MCU(OPT_MCU_MKL25ZXX)
-
-//------------- Microchip -------------//
-#elif TU_CHECK_MCU(OPT_MCU_SAMD21, OPT_MCU_SAMD51, OPT_MCU_SAME5X) || \
- TU_CHECK_MCU(OPT_MCU_SAMD11, OPT_MCU_SAML21, OPT_MCU_SAML22)
-
-#elif TU_CHECK_MCU(OPT_MCU_SAMG)
-
-#elif TU_CHECK_MCU(OPT_MCU_SAMX7X)
-
-//------------- ST -------------//
-#elif TU_CHECK_MCU(OPT_MCU_STM32F0, OPT_MCU_STM32F1, OPT_MCU_STM32F3) || \
- TU_CHECK_MCU(OPT_MCU_STM32L0, OPT_MCU_STM32L1, OPT_MCU_STM32L4)
-
-#elif TU_CHECK_MCU(OPT_MCU_STM32F2, OPT_MCU_STM32F3, OPT_MCU_STM32F4)
-
-#elif TU_CHECK_MCU(OPT_MCU_STM32F7)
-
-#elif TU_CHECK_MCU(OPT_MCU_STM32H7)
-
-//------------- Sony -------------//
-#elif TU_CHECK_MCU(OPT_MCU_CXD56)
-
-//------------- Nuvoton -------------//
-#elif TU_CHECK_MCU(OPT_MCU_NUC505)
-
-//------------- Espressif -------------//
-#elif TU_CHECK_MCU(OPT_MCU_ESP32S2, OPT_MCU_ESP32S3)
-
-//------------- Raspberry Pi -------------//
-#elif TU_CHECK_MCU(OPT_MCU_RP2040)
-
-//------------- Silabs -------------//
-#elif TU_CHECK_MCU(OPT_MCU_EFM32GG)
-
-//------------- Renesas -------------//
-#elif TU_CHECK_MCU(OPT_MCU_RX63X, OPT_MCU_RX65X, OPT_MCU_RX72N)
-
-//#elif TU_CHECK_MCU(OPT_MCU_MM32F327X)
-// #define DCD_ATTR_ENDPOINT_MAX not known yet
-
-//------------- GigaDevice -------------//
-#elif TU_CHECK_MCU(OPT_MCU_GD32VF103)
-
-#else
-// #warning "DCD_ATTR_ENDPOINT_MAX is not defined for this MCU, default to 8"
-#endif
-
-// Default to fullspeed if not defined
-//#ifndef PORT_HIGHSPEED
-// #define DCD_ATTR_PORT_HIGHSPEED 0x00
-//#endif
-
-#endif
diff --git a/src/host/hub.c b/src/host/hub.c
index fd4dbd04a..53eb1d521 100644
--- a/src/host/hub.c
+++ b/src/host/hub.c
@@ -26,7 +26,7 @@
#include "tusb_option.h"
-#if (TUSB_OPT_HOST_ENABLED && CFG_TUH_HUB)
+#if (CFG_TUH_ENABLED && CFG_TUH_HUB)
#include "usbh.h"
#include "usbh_classdriver.h"
diff --git a/src/host/usbh.c b/src/host/usbh.c
index b8439addc..ce0ccc3cb 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -26,7 +26,7 @@
#include "tusb_option.h"
-#if TUSB_OPT_HOST_ENABLED
+#if CFG_TUH_ENABLED
#include "tusb.h"
#include "host/usbh.h"
@@ -215,7 +215,7 @@ CFG_TUSB_MEM_SECTION usbh_device_t _usbh_devices[CFG_TUH_DEVICE_MAX + CFG_TUH_HU
// Event queue
// role device/host is used by OS NONE for mutex (disable usb isr)
-OSAL_QUEUE_DEF(OPT_MODE_HOST, _usbh_qdef, CFG_TUH_TASK_QUEUE_SZ, hcd_event_t);
+OSAL_QUEUE_DEF(usbh_int_set, _usbh_qdef, CFG_TUH_TASK_QUEUE_SZ, hcd_event_t);
static osal_queue_t _usbh_q;
CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN static uint8_t _usbh_ctrl_buf[CFG_TUH_ENUMERATION_BUFSIZE];
@@ -434,6 +434,18 @@ uint8_t* usbh_get_enum_buf(void)
return _usbh_ctrl_buf;
}
+void usbh_int_set(bool enabled)
+{
+ // TODO all host controller
+ if (enabled)
+ {
+ hcd_int_enable(TUH_OPT_RHPORT);
+ }else
+ {
+ hcd_int_disable(TUH_OPT_RHPORT);
+ }
+}
+
//--------------------------------------------------------------------+
// HCD Event Handler
//--------------------------------------------------------------------+
@@ -697,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/host/usbh_classdriver.h b/src/host/usbh_classdriver.h
index 8bc2622aa..2f9957cc6 100644
--- a/src/host/usbh_classdriver.h
+++ b/src/host/usbh_classdriver.h
@@ -57,6 +57,8 @@ uint8_t usbh_get_rhport(uint8_t dev_addr);
uint8_t* usbh_get_enum_buf(void);
+void usbh_int_set(bool enabled);
+
//--------------------------------------------------------------------+
// USBH Endpoint API
//--------------------------------------------------------------------+
diff --git a/src/host/usbh_control.c b/src/host/usbh_control.c
index 9204576ac..d034eec7f 100644
--- a/src/host/usbh_control.c
+++ b/src/host/usbh_control.c
@@ -26,7 +26,7 @@
#include "tusb_option.h"
-#if TUSB_OPT_HOST_ENABLED
+#if CFG_TUH_ENABLED
#include "tusb.h"
#include "usbh_classdriver.h"