summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-03-07 19:54:00 +0700
committerhathach <[email protected]>2013-03-07 19:54:00 +0700
commitb146730306ff9f5e3d8dea520a62a5a25d33f92b (patch)
treeba484fffe0e06a330092d47ffde6e019fde4bcd2 /tinyusb
parent644f0d39329e634c7a3191dd657c866458dd793b (diff)
add test code & hcd_pipe_xfer for bulk transfer
- test cross 4k boundary test for bulk transfer rename p_qtd_list to p_qtd_list_head
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/host/ehci/ehci.c40
-rw-r--r--tinyusb/host/ehci/ehci.h7
-rw-r--r--tinyusb/host/hcd.h2
3 files changed, 37 insertions, 12 deletions
diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c
index 8d15d2516..d3cf5b6a8 100644
--- a/tinyusb/host/ehci/ehci.c
+++ b/tinyusb/host/ehci/ehci.c
@@ -289,6 +289,9 @@ static void queue_td_init(ehci_qtd_t* p_qtd, uint32_t data_ptr, uint16_t total_b
{
memclr_(p_qtd, sizeof(ehci_qtd_t));
+ p_qtd->used = 1;
+
+ p_qtd->next.terminate = 1; // init to null
p_qtd->alternate.terminate = 1; // not used, always set to terminated
p_qtd->active = 1;
p_qtd->cerr = 3; // TODO 3 consecutive errors tolerance
@@ -297,6 +300,11 @@ static void queue_td_init(ehci_qtd_t* p_qtd, uint32_t data_ptr, uint16_t total_b
p_qtd->buffer[0] = data_ptr;
+ uint8_t i;
+ for(i=1; i<5; i++)
+ {
+ p_qtd->buffer[i] |= align4k( p_qtd->buffer[i-1] ) + 4096;
+ }
}
tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_std_request_t const * p_request, uint8_t data[])
@@ -335,7 +343,7 @@ tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_std_request_t const *
p_status->next.terminate = 1;
//------------- hook TD List to Queue Head -------------//
- p_qhd->p_qtd_list = p_setup;
+ p_qhd->p_qtd_list_head = p_setup;
p_qhd->qtd_overlay.next.address = (uint32_t) p_setup;
return TUSB_ERROR_NONE;
@@ -392,15 +400,29 @@ pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const *
return (pipe_handle_t) { .dev_addr = dev_addr, .xfer_type = p_endpoint_desc->bmAttributes.xfer, .index = index};
}
-tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_byte)
+tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes)
{
+ //------------- pipe handle validate -------------//
+
//------------- find a free qtd -------------//
-// uint8_t index=0;
-// while( index<EHCI_MAX_QTD && ehci_data.device[dev_addr].qtd[index].used )
-// {
-// index++;
-// }
-// ASSERT( index < EHCI_MAX_QHD, TUSB_ERROR_EHCI_NOT_ENOUGH_QTD);
+ uint8_t index=0;
+ while( index<EHCI_MAX_QTD && ehci_data.device[pipe_hdl.dev_addr].qtd[index].used )
+ {
+ index++;
+ }
+ ASSERT( index < EHCI_MAX_QTD, TUSB_ERROR_EHCI_NOT_ENOUGH_QTD);
+
+ //------------- set up QTD -------------//
+ ehci_qhd_t *p_qhd = &ehci_data.device[pipe_hdl.dev_addr].qhd[index];
+
+ ehci_qtd_t *p_qtd = &ehci_data.device[pipe_hdl.dev_addr].qtd[index];
+ queue_td_init(p_qtd, (uint32_t) buffer, total_bytes);
+ p_qtd->pid = p_qhd->pid_non_control;
+ p_qtd->int_on_complete = 1;
+
+
+ p_qhd->p_qtd_list_head = p_qtd;
+ p_qhd->qtd_overlay.next.address = (uint32_t) p_qtd;
return TUSB_ERROR_NONE;
}
@@ -461,7 +483,7 @@ static void queue_head_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_pa
//------------- HCD Management Data -------------//
p_qhd->used = 1;
- p_qhd->p_qtd_list = NULL;
+ p_qhd->p_qtd_list_head = NULL;
p_qhd->pid_non_control = (endpoint_addr & 0x80) ? EHCI_PID_IN : EHCI_PID_OUT; // PID for TD under this endpoint
}
diff --git a/tinyusb/host/ehci/ehci.h b/tinyusb/host/ehci/ehci.h
index c77ebdc37..cfd37c494 100644
--- a/tinyusb/host/ehci/ehci.h
+++ b/tinyusb/host/ehci/ehci.h
@@ -191,14 +191,17 @@ typedef struct {
/// Word 4-11: Transfer Overlay
volatile ehci_qtd_t qtd_overlay;
- /// Due to the fact QHD is 32 bytes aligned but occupies only 48 bytes
+ //--------------------------------------------------------------------+
+ /// Due to the fact QHD is 32 bytes aligned but occupies only 48 bytes
/// thus there are 16 bytes padding free that we can make use of.
+ //--------------------------------------------------------------------+
uint8_t used;
uint8_t pid_non_control;
+
uint8_t list_index;
uint8_t reserved;
- ehci_qtd_t *p_qtd_list; /* used as TD head to clean up TD chain when transfer done */ // TODO consider using ehci_link_t (terminate bit)
+ ehci_qtd_t *p_qtd_list_head; // head of the TD list scheduled
volatile uint32_t status; // TODO will remove volatile after remove all HcdQHD function
uint16_t *pActualTransferCount; /* total transferred bytes of a usb request */
diff --git a/tinyusb/host/hcd.h b/tinyusb/host/hcd.h
index 14b8941fa..af79d6f9d 100644
--- a/tinyusb/host/hcd.h
+++ b/tinyusb/host/hcd.h
@@ -80,7 +80,7 @@ tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_std_request_t const *
tusb_error_t hcd_pipe_control_close(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * endpoint_desc) ATTR_WARN_UNUSED_RESULT;
-tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_byte) ATTR_WARN_UNUSED_RESULT;
+tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes) ATTR_WARN_UNUSED_RESULT;
tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl) ATTR_WARN_UNUSED_RESULT;
#if 0