summaryrefslogtreecommitdiff
path: root/tinyusb/host
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-10-16 11:05:33 +0700
committerhathach <[email protected]>2013-10-16 11:05:33 +0700
commitde7e21dc662acc316e21aba865f52d446c231ae4 (patch)
tree271b3dc49cce5af95deb9714510ee49b9c5f0669 /tinyusb/host
parent3d13516106f4408f39dbccfd73ec0913c597ea21 (diff)
refractor hub api
fix all test build errors
Diffstat (limited to 'tinyusb/host')
-rw-r--r--tinyusb/host/ehci/ehci.c4
-rw-r--r--tinyusb/host/hcd.h11
-rw-r--r--tinyusb/host/hub.c5
-rw-r--r--tinyusb/host/hub.h5
-rw-r--r--tinyusb/host/usbh.c18
-rw-r--r--tinyusb/host/usbh_hcd.h2
-rw-r--r--tinyusb/host/usbh_hub.h68
7 files changed, 98 insertions, 15 deletions
diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c
index 815c865d0..378e5f736 100644
--- a/tinyusb/host/ehci/ehci.c
+++ b/tinyusb/host/ehci/ehci.c
@@ -564,7 +564,7 @@ static void port_connect_status_change_isr(uint8_t hostid)
// NOTE There is an sequence plug->unplug->…..-> plug if device is powering with pre-plugged device
if (regs->portsc_bit.current_connect_status)
{
- usbh_hcd_rhport_plugged_isr(hostid, 0, 0);
+ usbh_hcd_rhport_plugged_isr(hostid);
}else // device unplugged
{
usbh_hcd_rhport_unplugged_isr(hostid);
@@ -573,7 +573,7 @@ static void port_connect_status_change_isr(uint8_t hostid)
}
// TODO refractor abtract later
-void hcd_hub_advance_asyn(uint8_t hostid)
+void hcd_port_unplug(uint8_t hostid)
{
ehci_registers_t* const regs = get_operational_register(hostid);
regs->usb_cmd_bit.advacne_async = 1; // Async doorbell check EHCI 4.8.2 for operational details
diff --git a/tinyusb/host/hcd.h b/tinyusb/host/hcd.h
index 903e0e65e..816afd3a3 100644
--- a/tinyusb/host/hcd.h
+++ b/tinyusb/host/hcd.h
@@ -99,11 +99,11 @@ tusb_error_t hcd_pipe_queue_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint
tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete) ATTR_WARN_UNUSED_RESULT;
tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl) /*ATTR_WARN_UNUSED_RESULT*/;
-bool hcd_pipe_is_busy(pipe_handle_t pipe_hdl);
-bool hcd_pipe_is_error(pipe_handle_t pipe_hdl);
-bool hcd_pipe_is_stalled(pipe_handle_t pipe_hdl); // stalled also counted as error
-bool hcd_pipe_is_idle(pipe_handle_t pipe_hdl);
-uint8_t hcd_pipe_get_endpoint_addr(pipe_handle_t pipe_hdl);
+bool hcd_pipe_is_busy(pipe_handle_t pipe_hdl) ATTR_PURE;
+bool hcd_pipe_is_error(pipe_handle_t pipe_hdl) ATTR_PURE;
+bool hcd_pipe_is_stalled(pipe_handle_t pipe_hdl) ATTR_PURE; // stalled also counted as error
+bool hcd_pipe_is_idle(pipe_handle_t pipe_hdl) ATTR_PURE;
+uint8_t hcd_pipe_get_endpoint_addr(pipe_handle_t pipe_hdl) ATTR_PURE;
tusb_error_t hcd_pipe_clear_stall(pipe_handle_t pipe_hdl);
#if 0
@@ -117,6 +117,7 @@ tusb_error_t hcd_pipe_cancel()ATTR_WARN_UNUSED_RESULT;
bool hcd_port_connect_status(uint8_t hostid) ATTR_PURE ATTR_WARN_UNUSED_RESULT; // TODO make inline if possible
void hcd_port_reset(uint8_t hostid);
tusb_speed_t hcd_port_speed_get(uint8_t hostid) ATTR_PURE ATTR_WARN_UNUSED_RESULT; // TODO make inline if possible
+void hcd_port_unplug(uint8_t hostid); // called by usbh to instruct hcd that it can execute unplug procedure
#ifdef __cplusplus
}
diff --git a/tinyusb/host/hub.c b/tinyusb/host/hub.c
index e72a0ac5a..99cebc292 100644
--- a/tinyusb/host/hub.c
+++ b/tinyusb/host/hub.c
@@ -46,7 +46,7 @@
// INCLUDE
//--------------------------------------------------------------------+
#include "hub.h"
-#include "usbh_hcd.h"
+#include "usbh_hub.h"
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
@@ -209,8 +209,7 @@ void hub_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes)
{ // TODO HUB ignore bit0 hub_status_change
if ( BIT_TEST_(p_hub->status_change, port) )
{
- // TODO HUB connection/disconnection will be determined in enum task --> connect change
- usbh_hcd_rhport_plugged_isr(usbh_devices[pipe_hdl.dev_addr].core_id, pipe_hdl.dev_addr, port);
+ usbh_hub_port_plugged_isr(pipe_hdl.dev_addr, port);
}
}
diff --git a/tinyusb/host/hub.h b/tinyusb/host/hub.h
index 274359659..15e831a10 100644
--- a/tinyusb/host/hub.h
+++ b/tinyusb/host/hub.h
@@ -182,6 +182,11 @@ typedef struct {
STATIC_ASSERT( sizeof(hub_port_status_response_t) == 4, "size is not correct");
+tusb_error_t hub_port_reset_subtask(uint8_t hub_addr, uint8_t hub_port);
+tusb_error_t hub_port_clear_feature_subtask(uint8_t hub_addr, uint8_t hub_port, uint8_t feature);
+tusb_speed_t hub_port_get_speed(void);
+tusb_error_t hub_status_pipe_queue(uint8_t dev_addr);
+
//--------------------------------------------------------------------+
// USBH-CLASS DRIVER API
//--------------------------------------------------------------------+
diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c
index f36c279a4..c7618d238 100644
--- a/tinyusb/host/usbh.c
+++ b/tinyusb/host/usbh.c
@@ -273,19 +273,29 @@ void usbh_xfer_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_event_t even
}
}
-void usbh_hcd_rhport_plugged_isr(uint8_t hostid, uint8_t hub_addr, uint8_t hub_port)
+void usbh_hub_port_plugged_isr(uint8_t hub_addr, uint8_t hub_port)
{
osal_queue_send(enum_queue_hdl,
&(usbh_enumerate_t){
- .core_id = hostid,
+ .core_id = usbh_devices[hub_addr].core_id,
.hub_addr = hub_addr,
.hub_port = hub_port}
);
}
+void usbh_hcd_rhport_plugged_isr(uint8_t hostid)
+{
+ osal_queue_send(enum_queue_hdl,
+ &(usbh_enumerate_t){
+ .core_id = hostid,
+ .hub_addr = 0,
+ .hub_port = 0}
+ );
+}
+
// a device unplugged on hostid, hub_addr, hub_port
// return true if found and unmounted device, false if cannot find
-void usbh_device_unplugged(uint8_t hostid, uint8_t hub_addr, uint8_t hub_port)
+static void usbh_device_unplugged(uint8_t hostid, uint8_t hub_addr, uint8_t hub_port)
{
bool is_found = false;
//------------- find the all devices (star-network) under port that is unplugged -------------//
@@ -316,7 +326,7 @@ void usbh_device_unplugged(uint8_t hostid, uint8_t hub_addr, uint8_t hub_port)
}
}
- if (is_found) hcd_hub_advance_asyn(usbh_devices[0].core_id); // TODO hack
+ if (is_found) hcd_port_unplug(usbh_devices[0].core_id); // TODO hack
}
diff --git a/tinyusb/host/usbh_hcd.h b/tinyusb/host/usbh_hcd.h
index f4e7c7a8c..305b0eb42 100644
--- a/tinyusb/host/usbh_hcd.h
+++ b/tinyusb/host/usbh_hcd.h
@@ -115,7 +115,7 @@ extern usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; // including
// callback from HCD ISR
//--------------------------------------------------------------------+
void usbh_xfer_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_event_t event, uint32_t xferred_bytes);
-void usbh_hcd_rhport_plugged_isr(uint8_t hostid, uint8_t hub_addr, uint8_t hub_port);
+void usbh_hcd_rhport_plugged_isr(uint8_t hostid);
void usbh_hcd_rhport_unplugged_isr(uint8_t hostid);
#ifdef __cplusplus
diff --git a/tinyusb/host/usbh_hub.h b/tinyusb/host/usbh_hub.h
new file mode 100644
index 000000000..c1337f928
--- /dev/null
+++ b/tinyusb/host/usbh_hub.h
@@ -0,0 +1,68 @@
+/**************************************************************************/
+/*!
+ @file usbh_hub.h
+ @author hathach (tinyusb.org)
+
+ @section LICENSE
+
+ Software License Agreement (BSD License)
+
+ Copyright (c) 2013, hathach (tinyusb.org)
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holders nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This file is part of the tinyusb stack.
+*/
+/**************************************************************************/
+
+/** \ingroup TBD
+ * \defgroup TBD
+ * \brief TBD
+ *
+ * @{
+ */
+
+#ifndef _TUSB_USBH_HUB_H_
+#define _TUSB_USBH_HUB_H_
+
+//--------------------------------------------------------------------+
+// INCLUDE
+//--------------------------------------------------------------------+
+#include "common/common.h"
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+
+void usbh_hub_port_plugged_isr(uint8_t hub_addr, uint8_t hub_port);
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* _TUSB_USBH_HUB_H_ */
+
+/** @} */