add usbh_hcd to hold common structure/typedef for usbh and hcd

This commit is contained in:
hathach 2013-02-04 13:51:20 +07:00
parent a5b29c5d33
commit 94486f55ec
7 changed files with 136 additions and 52 deletions

View File

@ -178,12 +178,10 @@ void test_enum_task_connect(void)
{
pipe_handle_t pipe_addr0 = 12;
osal_queue_receive_StubWithCallback(queue_recv_stub);
hcd_port_connect_status_ExpectAndReturn(enum_connect.core_id, true);
hcd_port_speed_ExpectAndReturn(enum_connect.core_id, TUSB_SPEED_FULL);
hcd_pipe_addr0_open_ExpectAndReturn(enum_connect.core_id, TUSB_SPEED_FULL, 0, 0, pipe_addr0);
hcd_pipe_addr0_open_IgnoreAndReturn(pipe_addr0);
hcd_pipe_control_xfer_StubWithCallback(pipe_control_stub);
// hcd_pipe_control_open_ExpectAnd(1, );

View File

@ -55,6 +55,7 @@
extern "C" {
#endif
#include "common/common.h"
#include "host/usbh.h"
#include "hid.h"

View File

@ -72,7 +72,6 @@
#include "errors.h"
//------------- TUSB Header -------------//
//#include "hal/hal.h"
#include "core/tusb_types.h"
#include "core/std_descriptors.h"
#include "core/std_request.h"

View File

@ -56,19 +56,23 @@
#endif
#include "common/common.h"
//#include "usbh.h"
#include "usbh_hcd.h"
typedef uint32_t pipe_handle_t;
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
//--------------------------------------------------------------------+
// USBH-HCD API
//--------------------------------------------------------------------+
tusb_error_t hcd_init(uint8_t hostid) ATTR_WARN_UNUSED_RESULT;
//--------------------------------------------------------------------+
// PIPE API
//--------------------------------------------------------------------+
//pipe_handle_t hcd_pipe_addr0_open(usbh_device_addr0_t const * dev_addr0);
pipe_handle_t hcd_pipe_addr0_open(uint8_t core_id, tusb_speed_t speed, uint8_t hub_addr, uint8_t hub_port);
pipe_handle_t hcd_pipe_addr0_open(usbh_device_addr0_t const * dev_addr0);
pipe_handle_t hcd_pipe_control_open(uint8_t dev_addr, uint8_t max_packet_size);
tusb_error_t hcd_pipe_control_xfer(pipe_handle_t pipe_hdl, tusb_std_request_t const * p_request, uint8_t data[]);
pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * endpoint_desc);

View File

@ -105,7 +105,7 @@ void usbh_enumeration_task(void)
.wLength = 8
};
device_addr0.speed = hcd_port_speed(device_addr0.enum_entry.core_id);
// pipe_handle_t pipe_addr0 = hcd_pipe_addr0_open(&device_addr0);
pipe_handle_t pipe_addr0 = hcd_pipe_addr0_open(&device_addr0);
// hcd_pipe_control_xfer(pipe_addr0, &request_dev_desc)
}else // device connect via a hub

View File

@ -59,6 +59,7 @@
// INCLUDE
//--------------------------------------------------------------------+
#include "common/common.h"
#include "usbh_hcd.h"
#include "hcd.h"
//--------------------------------------------------------------------+
@ -101,60 +102,22 @@ enum {
/// Device Status
enum {
TUSB_DEVICE_STATUS_UNPLUG = 0,
TUSB_DEVICE_STATUS_READY = BIT_(0),
TUSB_DEVICE_STATUS_UNPLUG = 0,
TUSB_DEVICE_STATUS_READY = BIT_(0),
TUSB_DEVICE_STATUS_REMOVING = BIT_(2),
TUSB_DEVICE_STATUS_REMOVING = BIT_(2),
TUSB_DEVICE_STATUS_SAFE_REMOVE = BIT_(3),
};
typedef uint8_t tusbh_device_status_t;
typedef uint32_t tusbh_flag_class_t;
typedef struct { // TODO internal structure, re-order members
uint8_t core_id;
tusb_speed_t speed;
uint8_t hub_addr;
uint8_t hub_port;
uint16_t vendor_id;
uint16_t product_id;
uint8_t configure_count;
tusbh_device_status_t status;
pipe_handle_t pipe_control;
tusb_std_request_t request_control;
#if 0 // TODO allow configure for vendor/product
struct {
uint8_t interface_count;
uint8_t attributes;
} configuration;
#endif
} usbh_device_info_t;
typedef enum {
PIPE_STATUS_AVAILABLE = 0,
PIPE_STATUS_BUSY,
PIPE_STATUS_COMPLETE
} pipe_status_t;
typedef uint32_t tusbh_flag_class_t;
typedef uint32_t tusb_handle_device_t;
typedef struct ATTR_ALIGNED(4){
uint8_t core_id;
uint8_t hub_addr;
uint8_t hub_port;
uint8_t connect_status;
} usbh_enumerate_t;
typedef struct {
usbh_enumerate_t enum_entry;
tusb_speed_t speed;
tusb_std_request_t request_packet; // needed to be on USB RAM
} usbh_device_addr0_t;
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+

119
tinyusb/host/usbh_hcd.h Normal file
View File

@ -0,0 +1,119 @@
/*
* usbh_hcd.h
*
* Created on: Feb 4, 2013
* Author: hathach
*/
/*
* Software License Agreement (BSD License)
* Copyright (c) 2012, hathach (tinyusb.net)
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 tiny usb stack.
*/
/** \file
* \brief TBD
*
* \note TBD
*/
/** \ingroup TBD
* \defgroup TBD
* \brief TBD
*
* @{
*/
#ifndef _TUSB_USBH_HCD_H_
#define _TUSB_USBH_HCD_H_
#ifdef __cplusplus
extern "C" {
#endif
//--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+
#include "common/common.h"
//--------------------------------------------------------------------+
// USBH
//--------------------------------------------------------------------+
typedef uint8_t tusbh_device_status_t;
typedef uint32_t pipe_handle_t;
typedef struct ATTR_ALIGNED(4){
uint8_t core_id;
uint8_t hub_addr;
uint8_t hub_port;
uint8_t connect_status;
} usbh_enumerate_t;
typedef struct {
usbh_enumerate_t enum_entry;
tusb_speed_t speed;
tusb_std_request_t request_packet; // needed to be on USB RAM
} usbh_device_addr0_t;
typedef struct { // TODO internal structure, re-order members
uint8_t core_id;
tusb_speed_t speed;
uint8_t hub_addr;
uint8_t hub_port;
uint16_t vendor_id;
uint16_t product_id;
uint8_t configure_count;
tusbh_device_status_t status;
pipe_handle_t pipe_control;
tusb_std_request_t request_control;
#if 0 // TODO allow configure for vendor/product
struct {
uint8_t interface_count;
uint8_t attributes;
} configuration;
#endif
} usbh_device_info_t;
//--------------------------------------------------------------------+
// HCD
//--------------------------------------------------------------------+
//--------------------------------------------------------------------+
// IMPLEMENTATION
//--------------------------------------------------------------------+
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_USBH_HCD_H_ */
/** @} */