summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-03-09 14:19:40 +0700
committerhathach <[email protected]>2013-03-09 14:19:40 +0700
commit2364b09f80e097580630c556965bebd2013db7b3 (patch)
treef8267ef7905cbbb17ba911654aa5e18fcdb53249
parentb1db85dedf5546bee594a40ba41cf644bf7b3ae0 (diff)
add int_on_complete parameter to hcd_pipe_xfer for TD chain class request
fix control transfer request: remove get_control_request_ptr()
-rw-r--r--tests/test/host/ehci/test_ehci_pipe_bulk_xfer.c6
-rw-r--r--tests/test/host/ehci/test_ehci_pipe_xfer.c7
-rw-r--r--tinyusb/host/ehci/ehci.c18
-rw-r--r--tinyusb/host/hcd.h2
-rw-r--r--tinyusb/host/usbh.c2
5 files changed, 12 insertions, 23 deletions
diff --git a/tests/test/host/ehci/test_ehci_pipe_bulk_xfer.c b/tests/test/host/ehci/test_ehci_pipe_bulk_xfer.c
index 5ee4a04e1..4856fd8a9 100644
--- a/tests/test/host/ehci/test_ehci_pipe_bulk_xfer.c
+++ b/tests/test/host/ehci/test_ehci_pipe_bulk_xfer.c
@@ -146,7 +146,7 @@ void test_bulk_xfer(void)
{
//------------- Code Under Test -------------//
- hcd_pipe_xfer(pipe_hdl_bulk, xfer_data, sizeof(xfer_data));
+ hcd_pipe_xfer(pipe_hdl_bulk, xfer_data, sizeof(xfer_data), true);
ehci_qtd_t* p_qtd = p_qhd_bulk->p_qtd_list_head;
TEST_ASSERT_NOT_NULL(p_qtd);
@@ -162,8 +162,8 @@ void test_bulk_xfer_double(void)
{
//------------- Code Under Test -------------//
- hcd_pipe_xfer(pipe_hdl_bulk, xfer_data, sizeof(xfer_data));
- hcd_pipe_xfer(pipe_hdl_bulk, data2, sizeof(data2));
+ hcd_pipe_xfer(pipe_hdl_bulk, xfer_data, sizeof(xfer_data), false);
+ hcd_pipe_xfer(pipe_hdl_bulk, data2, sizeof(data2), true);
ehci_qtd_t* p_head = p_qhd_bulk->p_qtd_list_head;
ehci_qtd_t* p_tail = p_qhd_bulk->p_qtd_list_head;
diff --git a/tests/test/host/ehci/test_ehci_pipe_xfer.c b/tests/test/host/ehci/test_ehci_pipe_xfer.c
index 08d1d15ad..7f3d37ead 100644
--- a/tests/test/host/ehci/test_ehci_pipe_xfer.c
+++ b/tests/test/host/ehci/test_ehci_pipe_xfer.c
@@ -162,7 +162,7 @@ void test_control_addr0_xfer_get_check_qhd_qtd_mapping(void)
TEST_ASSERT_EQUAL_HEX( p_status , p_data->next.address );
TEST_ASSERT_TRUE( p_status->next.terminate );
- verify_qtd(p_setup, &usbh_device_info_pool[0].control_request, 8);
+ verify_qtd(p_setup, &request_get_dev_desc, 8);
}
@@ -181,10 +181,7 @@ void test_control_xfer_get(void)
TEST_ASSERT_TRUE( p_status->next.terminate );
//------------- SETUP -------------//
- uint8_t* p_request = (uint8_t *) &usbh_device_info_pool[dev_addr].control_request;
- verify_qtd(p_setup, p_request, 8);
-
- TEST_ASSERT_EQUAL_MEMORY(&request_get_dev_desc, p_request, sizeof(tusb_std_request_t));
+ verify_qtd(p_setup, &request_get_dev_desc, 8);
TEST_ASSERT_FALSE(p_setup->int_on_complete);
TEST_ASSERT_FALSE(p_setup->data_toggle);
diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c
index bb12c117e..c107f312c 100644
--- a/tinyusb/host/ehci/ehci.c
+++ b/tinyusb/host/ehci/ehci.c
@@ -252,7 +252,6 @@ static void queue_head_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_pa
static inline ehci_qhd_t* const get_control_qhd(uint8_t dev_addr) ATTR_ALWAYS_INLINE ATTR_PURE ATTR_WARN_UNUSED_RESULT;
static inline ehci_qtd_t* get_control_qtds(uint8_t dev_addr) ATTR_ALWAYS_INLINE ATTR_PURE ATTR_WARN_UNUSED_RESULT;
-static inline tusb_std_request_t* const get_control_request_ptr(uint8_t dev_addr) ATTR_ALWAYS_INLINE ATTR_PURE ATTR_WARN_UNUSED_RESULT;
//--------------------------------------------------------------------+
// CONTROL PIPE API
@@ -316,10 +315,8 @@ tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_std_request_t const *
ehci_qtd_t *p_status = p_setup + 2;
//------------- SETUP Phase -------------//
- *(get_control_request_ptr(dev_addr)) = *p_request; // copy request
-
- queue_td_init(p_setup, (uint32_t) get_control_request_ptr(dev_addr), 8);
- p_setup->pid = EHCI_PID_SETUP;
+ queue_td_init(p_setup, (uint32_t) p_request, 8);
+ p_setup->pid = EHCI_PID_SETUP;
p_setup->next.address = (uint32_t) p_data;
//------------- DATA Phase -------------//
@@ -343,7 +340,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_head = p_setup;
+ p_qhd->p_qtd_list_head = p_setup;
p_qhd->qtd_overlay.next.address = (uint32_t) p_setup;
return TUSB_ERROR_NONE;
@@ -416,7 +413,7 @@ static inline void insert_qtd_to_qhd(ehci_qhd_t *p_qhd, ehci_qtd_t *p_qtd_new)
}
-tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes)
+tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete)
{
//------------- TODO pipe handle validate -------------//
@@ -434,7 +431,7 @@ tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t t
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_qtd->int_on_complete = int_on_complete ? 1 : 0;
//------------- insert TD to TD list -------------//
insert_qtd_to_qhd(p_qhd, p_qtd);
@@ -458,11 +455,6 @@ static inline ehci_qtd_t* get_control_qtds(uint8_t dev_addr)
}
-static inline tusb_std_request_t* const get_control_request_ptr(uint8_t dev_addr)
-{
- return &usbh_device_info_pool[dev_addr].control_request;
-}
-
// TODO subject to pure function
static void queue_head_init(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_size, uint8_t endpoint_addr, uint8_t xfer_type)
{
diff --git a/tinyusb/host/hcd.h b/tinyusb/host/hcd.h
index af79d6f9d..640b217a3 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_bytes) ATTR_WARN_UNUSED_RESULT;
+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;
#if 0
diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c
index 1bef861b3..cf575fecc 100644
--- a/tinyusb/host/usbh.c
+++ b/tinyusb/host/usbh.c
@@ -124,7 +124,7 @@ tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, tusb_std_request_t cons
OSAL_SUBTASK_BEGIN
usbh_device_info_pool[dev_addr].control_request = *p_request;
- (void) hcd_pipe_control_xfer(dev_addr, p_request, data);
+ (void) hcd_pipe_control_xfer(dev_addr, &usbh_device_info_pool[dev_addr].control_request, data);
osal_semaphore_wait(usbh_device_info_pool[dev_addr].sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // careful of local variable without static
SUBTASK_ASSERT_STATUS_WITH_HANDLER(error, tusbh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL) );