add test & code for hcd_pipe_control_open

This commit is contained in:
hathach
2013-03-05 14:26:36 +07:00
parent 2c8596edeb
commit 3ed29f5f3c
9 changed files with 283 additions and 19 deletions

View File

@@ -44,6 +44,9 @@
#include "hal/hal.h"
#include "osal/osal.h"
#include "common/timeout_timer.h"
#include "../hcd.h"
#include "../usbh_hcd.h"
#include "ehci.h"
//--------------------------------------------------------------------+
@@ -219,6 +222,7 @@ tusb_error_t hcd_controller_stop(uint8_t hostid)
return timeout_expired(&timeout) ? TUSB_ERROR_OSAL_TIMEOUT : TUSB_ERROR_NONE;
}
//TODO host/device mode must be set immediately after a reset
tusb_error_t hcd_controller_reset(uint8_t hostid) ATTR_WARN_UNUSED_RESULT;
tusb_error_t hcd_controller_reset(uint8_t hostid)
{
@@ -246,5 +250,66 @@ tusb_error_t hcd_controller_reset(uint8_t hostid)
//--------------------------------------------------------------------+
// PIPE API
//--------------------------------------------------------------------+
tusb_error_t hcd_pipe_control_open(uint8_t dev_addr, uint8_t max_packet_size)
{
ehci_qhd_t *p_qhd;
if (dev_addr == 0)
{
// async head of selected controller is used as Addr0 Endpoint --> horizontal link have to be preserved
p_qhd = get_async_head( usbh_device_info_pool[dev_addr].core_id );
p_qhd->head_list_flag = 1; // make sure it is still head of list
}else
{
p_qhd = &ehci_data.device[dev_addr].control.qhd;
p_qhd->head_list_flag = 0; // make sure it is still head of list
}
p_qhd->device_address = dev_addr;
p_qhd->inactive_next_xact = 0;
p_qhd->endpoint_number = 0;
p_qhd->endpoint_speed = usbh_device_info_pool[dev_addr].speed;
p_qhd->data_toggle_control = 1;
p_qhd->max_package_size = max_packet_size;
p_qhd->non_hs_control_endpoint = (usbh_device_info_pool[dev_addr].speed != TUSB_SPEED_HIGH) ? 1 : 0;
p_qhd->nak_count_reload = 0;
p_qhd->smask = 0;
p_qhd->cmask = 0;
p_qhd->hub_address = usbh_device_info_pool[dev_addr].hub_addr;
p_qhd->hub_port = usbh_device_info_pool[dev_addr].hub_port;
p_qhd->mult = 1; // TODO not use high bandwidth/park mode yet
//------------- inactive when just opened -------------//
p_qhd->qtd_overlay.next.terminate = 1;
p_qhd->qtd_overlay.alternate.terminate = 1;
p_qhd->qtd_overlay.halted = 1;
//------------- HCD Management Data -------------//
p_qhd->used = 1;
p_qhd->p_qtd_list = NULL;
//------------- insert to async list -------------//
// TODO disable async list first if got error
if (dev_addr != 0)
{
ehci_qhd_t * const async_head = get_async_head(usbh_device_info_pool[dev_addr].core_id);
p_qhd->next = async_head->next;
async_head->next.address = (uint32_t) p_qhd;
async_head->next.type = EHCI_QUEUE_ELEMENT_QHD;
}
return TUSB_ERROR_NONE;
}
//
//tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_std_request_t const * p_request, uint8_t data[])
//{
// return TUSB_ERROR_NONE;
//}
//
//pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * endpoint_desc)
//{
// return TUSB_ERROR_NONE;
//}
#endif