refractor hub api

fix all test build errors
This commit is contained in:
hathach
2013-10-16 11:05:33 +07:00
parent 3d13516106
commit de7e21dc66
21 changed files with 124 additions and 32 deletions
+2 -2
View File
@@ -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
+6 -5
View File
@@ -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
}
+2 -3
View File
@@ -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);
}
}
+5
View File
@@ -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
//--------------------------------------------------------------------+
+14 -4
View File
@@ -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
}
+1 -1
View File
@@ -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
+68
View File
@@ -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_ */
/** @} */