diff options
| author | hathach <[email protected]> | 2013-09-23 00:24:51 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-09-23 00:24:51 +0700 |
| commit | 85f3ad9d3becf277400ec6c865281ada43ae19a4 (patch) | |
| tree | 2bb4161fc85688d954ad538663f5aa249017bdc3 /tinyusb/host | |
| parent | a8a10e86502617313ced924691a014d94bd54c82 (diff) | |
refractor hcd API to allow queue xfer without actually transferring data
Diffstat (limited to 'tinyusb/host')
| -rw-r--r-- | tinyusb/host/ehci/ehci.c | 19 | ||||
| -rw-r--r-- | tinyusb/host/hcd.h | 1 |
2 files changed, 17 insertions, 3 deletions
diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index 0597c1e07..b2948e0db 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -402,7 +402,7 @@ 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 = qhd_get_index(p_qhd) }; } -tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete) +tusb_error_t hcd_pipe_queue_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes) { //------------- TODO pipe handle validate -------------// @@ -414,7 +414,6 @@ tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t t qtd_init(p_qtd, (uint32_t) buffer, total_bytes); p_qtd->pid = p_qhd->pid_non_control; - p_qtd->int_on_complete = int_on_complete ? 1 : 0; //------------- insert TD to TD list -------------// qtd_insert_to_qhd(p_qhd, p_qtd); @@ -422,6 +421,21 @@ tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t t return TUSB_ERROR_NONE; } +tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete) +{ + hcd_pipe_queue_xfer(pipe_hdl, buffer, total_bytes); + + ehci_qhd_t *p_qhd = qhd_get_from_pipe_handle(pipe_hdl); + + if ( int_on_complete ) + { // the just added qtd is pointed by list_tail + p_qhd->p_qtd_list_tail->int_on_complete = 1; + } + p_qhd->qtd_overlay.next.address = (uint32_t) p_qhd->p_qtd_list_head; // attach to queue head to start transferring + + return TUSB_ERROR_NONE; +} + /// pipe_close should only be called as a part of unmount/safe-remove process tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl) { @@ -882,7 +896,6 @@ static inline void qtd_insert_to_qhd(ehci_qhd_t *p_qhd, ehci_qtd_t *p_qtd_new) if (p_qhd->p_qtd_list_head == NULL) // empty list { p_qhd->p_qtd_list_head = p_qhd->p_qtd_list_tail = p_qtd_new; - p_qhd->qtd_overlay.next.address = (uint32_t) p_qtd_new; }else { p_qhd->p_qtd_list_tail->next.address = (uint32_t) p_qtd_new; diff --git a/tinyusb/host/hcd.h b/tinyusb/host/hcd.h index b37378ac7..61642d95b 100644 --- a/tinyusb/host/hcd.h +++ b/tinyusb/host/hcd.h @@ -95,6 +95,7 @@ tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_control_request_t con 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, uint8_t class_code) ATTR_WARN_UNUSED_RESULT; +tusb_error_t hcd_pipe_queue_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes) ATTR_WARN_UNUSED_RESULT; // only queue, not transferring yet 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_idle(pipe_handle_t pipe_hdl); |
