diff options
| author | hathach <[email protected]> | 2013-03-05 14:26:36 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-03-05 14:26:36 +0700 |
| commit | 3ed29f5f3c3a66b58b3a7ba87d2b5cc175861013 (patch) | |
| tree | b7125b5f21125ade3f0c13d43c8d2c5b0a53ce55 /tinyusb | |
| parent | 2c8596edebaedd0ceae46a56385c71c83dda531c (diff) | |
add test & code for hcd_pipe_control_open
Diffstat (limited to 'tinyusb')
| -rw-r--r-- | tinyusb/host/ehci/ehci.c | 65 | ||||
| -rw-r--r-- | tinyusb/host/ehci/ehci.h | 16 | ||||
| -rw-r--r-- | tinyusb/host/hcd.h | 2 | ||||
| -rw-r--r-- | tinyusb/host/usbh.c | 2 | ||||
| -rw-r--r-- | tinyusb/host/usbh_hcd.h | 3 |
5 files changed, 77 insertions, 11 deletions
diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index b2d6268f3..714cc14a0 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -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 diff --git a/tinyusb/host/ehci/ehci.h b/tinyusb/host/ehci/ehci.h index 4b8ec1f17..7b41bdc66 100644 --- a/tinyusb/host/ehci/ehci.h +++ b/tinyusb/host/ehci/ehci.h @@ -175,7 +175,7 @@ typedef struct { uint32_t smask : 8 ; ///< This field is used for all endpoint speeds. Software should set this field to a zero when the queue head is on the asynchronous schedule. A non-zero value in this field indicates an interrupt endpoint uint32_t cmask : 8 ; ///< This field is ignored by the host controller unless the EPSfield indicates this device is a low- or full-speed device and this queue head is in the periodic list. This field (along with the Activeand SplitX-statefields) is used to determine during which micro-frames the host controller should execute a complete-split transaction uint32_t hub_address : 7 ; ///< This field is ignored by the host controller unless the EPSfield indicates a full- or low-speed device. The value is the USB device address of the USB 2.0 Hub below which the full- or low-speed device associated with this endpoint is attached. This field is used in the split-transaction protocol. See Section 4.12. - uint32_t port_number : 7 ; ///< This field is ignored by the host controller unless the EPSfield indicates a full- or low-speed device. The value is the port number identifier on the USB 2.0 Hub (for hub at device address Hub Addrbelow), below which the full- or low-speed device associated with this endpoint is attached. This information is used in the split-transaction protocol. See Section 4.12. + uint32_t hub_port : 7 ; ///< This field is ignored by the host controller unless the EPSfield indicates a full- or low-speed device. The value is the port number identifier on the USB 2.0 Hub (for hub at device address Hub Addrbelow), below which the full- or low-speed device associated with this endpoint is attached. This information is used in the split-transaction protocol. See Section 4.12. uint32_t mult : 2 ; ///< This field is a multiplier used to key the host controller as the number of successive packets the host controller may submit to the endpoint in the current execution. 00b=Reserved 01b,10b,11b= 1 (2, 3) Transaction for this endpoint/micro frame uint32_t : 0 ; // padding to the end of current storage unit // End of Word 2 @@ -186,15 +186,15 @@ typedef struct { /// Word 4-11: Transfer Overlay volatile ehci_qtd_t qtd_overlay; - /// Due to the fact QHD is 32 bytes algined but occupies 48 bytes thus there are 16 bytes padding free that we can make use of. - uint32_t used : 1; - uint32_t direction : 2; - uint32_t interval : 5; - uint32_t list_index : 20; /* not support full period list */ - uint32_t : 0; /* Force next member on next storage unit */ + /// 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 list_index; + uint8_t reserved[2]; + + 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) volatile uint32_t status; // TODO will remove volatile after remove all HcdQHD function - uint32_t FirstQtd; /* used as TD head to clean up TD chain when transfer done */ uint16_t *pActualTransferCount; /* total transferred bytes of a usb request */ }ATTR_ALIGNED(32) ehci_qhd_t; diff --git a/tinyusb/host/hcd.h b/tinyusb/host/hcd.h index b046a0e64..c6c511e09 100644 --- a/tinyusb/host/hcd.h +++ b/tinyusb/host/hcd.h @@ -66,7 +66,7 @@ typedef uint32_t pipe_handle_t; //--------------------------------------------------------------------+ // USBH-HCD API //--------------------------------------------------------------------+ -tusb_error_t hcd_init() ATTR_WARN_UNUSED_RESULT; +tusb_error_t hcd_init(void) ATTR_WARN_UNUSED_RESULT; void hcd_isr(uint8_t hostid); //--------------------------------------------------------------------+ diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index 08adecf15..794074f86 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -56,7 +56,7 @@ //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ -STATIC_ usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; // including zero-address +usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; // including zero-address //------------- Enumeration Task Data -------------// OSAL_TASK_DEF(enum_task, usbh_enumeration_task, 128, OSAL_PRIO_HIGH); diff --git a/tinyusb/host/usbh_hcd.h b/tinyusb/host/usbh_hcd.h index 28bb7e1fe..f36586dbf 100644 --- a/tinyusb/host/usbh_hcd.h +++ b/tinyusb/host/usbh_hcd.h @@ -85,7 +85,7 @@ typedef struct { // TODO internal structure, re-order members //------------- configuration descriptor info -------------// uint8_t interface_count; // bNumInterfaces alias - tusbh_device_status_t status; + uint8_t status; // value from enum tusbh_device_status_ // pipe_handle_t pipe_control; NOTE: use device address/handle instead tusb_std_request_t request_control; @@ -101,6 +101,7 @@ typedef struct { // TODO internal structure, re-order members } usbh_device_info_t; +extern usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; // including zero-address //--------------------------------------------------------------------+ // ADDRESS 0 API //--------------------------------------------------------------------+ |
