summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
Diffstat (limited to 'src/host')
-rw-r--r--src/host/hcd.h4
-rw-r--r--src/host/hcd_attr.h104
-rw-r--r--src/host/hub.c6
-rw-r--r--src/host/usbh.c3
4 files changed, 112 insertions, 5 deletions
diff --git a/src/host/hcd.h b/src/host/hcd.h
index 62ff8b3f2..e1d21bf45 100644
--- a/src/host/hcd.h
+++ b/src/host/hcd.h
@@ -30,6 +30,7 @@
#include "common/tusb_common.h"
#include "osal/osal.h"
#include "common/tusb_fifo.h"
+#include "hcd_attr.h"
#ifdef __cplusplus
extern "C" {
@@ -62,6 +63,7 @@ typedef struct
struct {
uint8_t hub_addr;
uint8_t hub_port;
+ uint8_t speed;
} connection;
// XFER_COMPLETE
@@ -140,7 +142,7 @@ bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t *
bool hcd_edpt_clear_stall(uint8_t dev_addr, uint8_t ep_addr);
//--------------------------------------------------------------------+
-// Event API (implemented by stack)
+// USBH implemented API
//--------------------------------------------------------------------+
// Called by HCD to notify stack
diff --git a/src/host/hcd_attr.h b/src/host/hcd_attr.h
new file mode 100644
index 000000000..d18686587
--- /dev/null
+++ b/src/host/hcd_attr.h
@@ -0,0 +1,104 @@
+/*
+ * 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(LPC175X_6X) || TU_CHECK_MCU(LPC177X_8X) || TU_CHECK_MCU(LPC40XX)
+
+#elif TU_CHECK_MCU(LPC18XX) || TU_CHECK_MCU(LPC43XX)
+ #define HCD_ATTR_EHCI_TRANSDIMENSION
+
+#elif TU_CHECK_MCU(LPC54XXX)
+ // #define HCD_ATTR_EHCI_NXP_PTD
+
+#elif TU_CHECK_MCU(LPC55XX)
+ // #define HCD_ATTR_EHCI_NXP_PTD
+
+#elif TU_CHECK_MCU(MIMXRT10XX)
+ #define HCD_ATTR_EHCI_TRANSDIMENSION
+
+#elif TU_CHECK_MCU(MKL25ZXX)
+
+//------------- Microchip -------------//
+#elif TU_CHECK_MCU(SAMD21) || TU_CHECK_MCU(SAMD51) || TU_CHECK_MCU(SAME5X) || \
+ TU_CHECK_MCU(SAMD11) || TU_CHECK_MCU(SAML21) || TU_CHECK_MCU(SAML22)
+
+#elif TU_CHECK_MCU(SAMG)
+
+#elif TU_CHECK_MCU(SAMX7X)
+
+//------------- ST -------------//
+#elif TU_CHECK_MCU(STM32F0) || TU_CHECK_MCU(STM32F1) || TU_CHECK_MCU(STM32F3) || \
+ TU_CHECK_MCU(STM32L0) || TU_CHECK_MCU(STM32L1) || TU_CHECK_MCU(STM32L4)
+
+#elif TU_CHECK_MCU(STM32F2) || TU_CHECK_MCU(STM32F4) || TU_CHECK_MCU(STM32F3)
+
+#elif TU_CHECK_MCU(STM32F7)
+
+#elif TU_CHECK_MCU(STM32H7)
+
+//------------- Sony -------------//
+#elif TU_CHECK_MCU(CXD56)
+
+//------------- Nuvoton -------------//
+#elif TU_CHECK_MCU(NUC505)
+
+//------------- Espressif -------------//
+#elif TU_CHECK_MCU(ESP32S2) || TU_CHECK_MCU(ESP32S3)
+
+//------------- Raspberry Pi -------------//
+#elif TU_CHECK_MCU(RP2040)
+
+//------------- Silabs -------------//
+#elif TU_CHECK_MCU(EFM32GG) || TU_CHECK_MCU(EFM32GG11) || TU_CHECK_MCU(EFM32GG12)
+
+//------------- Renesas -------------//
+#elif TU_CHECK_MCU(RX63X) || TU_CHECK_MCU(RX65X) || TU_CHECK_MCU(RX72N)
+
+//#elif TU_CHECK_MCU(MM32F327X)
+// #define DCD_ATTR_ENDPOINT_MAX not known yet
+
+//------------- GigaDevice -------------//
+#elif TU_CHECK_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 d685c6529..65e747e41 100644
--- a/src/host/hub.c
+++ b/src/host/hub.c
@@ -45,8 +45,8 @@ typedef struct
hub_port_status_response_t port_status;
} hub_interface_t;
-CFG_TUSB_MEM_SECTION static hub_interface_t hub_data[CFG_TUH_DEVICE_MAX];
-TU_ATTR_ALIGNED(4) CFG_TUSB_MEM_SECTION static uint8_t _hub_buffer[sizeof(descriptor_hub_desc_t)];
+CFG_TUSB_MEM_SECTION static hub_interface_t hub_data[CFG_TUH_HUB];
+CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4) static uint8_t _hub_buffer[sizeof(descriptor_hub_desc_t)];
#if CFG_TUSB_DEBUG
static char const* const _hub_feature_str[] =
@@ -144,7 +144,7 @@ bool hub_port_get_status(uint8_t hub_addr, uint8_t hub_port, void* resp, tuh_con
//--------------------------------------------------------------------+
void hub_init(void)
{
- tu_memclr(hub_data, CFG_TUH_DEVICE_MAX*sizeof(hub_interface_t));
+ tu_memclr(hub_data, sizeof(hub_data));
}
bool hub_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *itf_desc, uint16_t max_len)
diff --git a/src/host/usbh.c b/src/host/usbh.c
index 98132a8c0..76c1ba078 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -128,7 +128,8 @@ enum { CONFIG_NUM = 1 }; // default to use configuration 1
static bool _usbh_initialized = false;
-// including zero-address
+// all devices including hub and zero-address TODO exclude device0 to save space
+// hub address start from CFG_TUH_DEVICE_MAX
CFG_TUSB_MEM_SECTION usbh_device_t _usbh_devices[CFG_TUH_DEVICE_MAX+1];
// Event queue