summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorhathach <[email protected]>2020-09-05 20:34:45 +0700
committerhathach <[email protected]>2020-09-05 21:12:43 +0700
commit9a6d7c648e3f41529fad2e2af7e01dc5c56003ac (patch)
treecdd9fac963c0c9ce3dd9ee9c4b6db42ab0a153a9 /src/host
parent828f720207d4ded25ed533ea6c52da49c799b476 (diff)
clean up enum task
Diffstat (limited to 'src/host')
-rw-r--r--src/host/ehci/ehci.c3
-rw-r--r--src/host/usbh.c33
-rw-r--r--src/host/usbh.h2
-rw-r--r--src/host/usbh_hcd.h1
4 files changed, 14 insertions, 25 deletions
diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c
index 13e9b0edc..3c02086c9 100644
--- a/src/host/ehci/ehci.c
+++ b/src/host/ehci/ehci.c
@@ -326,6 +326,9 @@ bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t *
// attach TD
qhd->qtd_overlay.next.address = (uint32_t) qtd;
+ }else
+ {
+ // TODO implement later
}
return true;
diff --git a/src/host/usbh.c b/src/host/usbh.c
index fd0e9ee18..f669cac05 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -122,11 +122,8 @@ static osal_queue_t _usbh_q;
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4) static uint8_t _usbh_ctrl_buf[CFG_TUSB_HOST_ENUM_BUFFER_SIZE];
-//------------- Reporter Task Data -------------//
-
//------------- Helper Function Prototypes -------------//
static inline uint8_t get_new_address(void);
-static inline uint8_t get_configure_number_for_device(tusb_desc_device_t* dev_desc);
//--------------------------------------------------------------------+
// PUBLIC API (Parameter Verification is required)
@@ -557,19 +554,22 @@ bool enum_task(hcd_event_t* event)
TU_ASSERT(usbh_control_xfer(new_addr, &request, _usbh_ctrl_buf));
// update device info TODO alignment issue
- new_dev->vendor_id = ((tusb_desc_device_t*) _usbh_ctrl_buf)->idVendor;
- new_dev->product_id = ((tusb_desc_device_t*) _usbh_ctrl_buf)->idProduct;
- new_dev->configure_count = ((tusb_desc_device_t*) _usbh_ctrl_buf)->bNumConfigurations;
+ tusb_desc_device_t const * desc_device = (tusb_desc_device_t const*) _usbh_ctrl_buf;
+
+ if (tuh_attach_cb) tuh_attach_cb((tusb_desc_device_t*) _usbh_ctrl_buf);
+
+ new_dev->vendor_id = desc_device->idVendor;
+ new_dev->product_id = desc_device->idProduct;
+ TU_ASSERT(desc_device->bNumConfigurations > 0);
- uint8_t const configure_selected = get_configure_number_for_device((tusb_desc_device_t*) _usbh_ctrl_buf);
- TU_ASSERT(configure_selected <= new_dev->configure_count); // TODO notify application when invalid configuration
+ enum { CONFIG_NUM = 1 }; // default to use configuration 1
//------------- Get 9 bytes of configuration descriptor -------------//
TU_LOG2("Get 9 bytes of Configuration Descriptor\r\n");
request = (tusb_control_request_t ) {
.bmRequestType_bit = { .recipient = TUSB_REQ_RCPT_DEVICE, .type = TUSB_REQ_TYPE_STANDARD, .direction = TUSB_DIR_IN },
.bRequest = TUSB_REQ_GET_DESCRIPTOR,
- .wValue = (TUSB_DESC_CONFIGURATION << 8) | (configure_selected - 1),
+ .wValue = (TUSB_DESC_CONFIGURATION << 8) | (CONFIG_NUM - 1),
.wIndex = 0,
.wLength = 9
};
@@ -591,7 +591,7 @@ bool enum_task(hcd_event_t* event)
request = (tusb_control_request_t ) {
.bmRequestType_bit = { .recipient = TUSB_REQ_RCPT_DEVICE, .type = TUSB_REQ_TYPE_STANDARD, .direction = TUSB_DIR_OUT },
.bRequest = TUSB_REQ_SET_CONFIGURATION,
- .wValue = configure_selected,
+ .wValue = CONFIG_NUM,
.wIndex = 0,
.wLength = 0
};
@@ -702,17 +702,4 @@ static inline uint8_t get_new_address(void)
return CFG_TUSB_HOST_DEVICE_MAX+1;
}
-static inline uint8_t get_configure_number_for_device(tusb_desc_device_t* dev_desc)
-{
- uint8_t config_num = 1;
-
- // invoke callback to ask user which configuration to select
- if (tuh_device_attached_cb)
- {
- config_num = tu_min8(1, tuh_device_attached_cb(dev_desc) );
- }
-
- return config_num;
-}
-
#endif
diff --git a/src/host/usbh.h b/src/host/usbh.h
index 56a5ce72f..1774666f1 100644
--- a/src/host/usbh.h
+++ b/src/host/usbh.h
@@ -90,7 +90,7 @@ static inline bool tuh_device_is_configured(uint8_t dev_addr)
//--------------------------------------------------------------------+
// APPLICATION CALLBACK
//--------------------------------------------------------------------+
-TU_ATTR_WEAK uint8_t tuh_device_attached_cb (tusb_desc_device_t const *p_desc_device);
+TU_ATTR_WEAK uint8_t tuh_attach_cb (tusb_desc_device_t const *desc_device);
/** Callback invoked when device is mounted (configured) */
TU_ATTR_WEAK void tuh_mount_cb (uint8_t dev_addr);
diff --git a/src/host/usbh_hcd.h b/src/host/usbh_hcd.h
index 019b9f037..435af96bb 100644
--- a/src/host/usbh_hcd.h
+++ b/src/host/usbh_hcd.h
@@ -53,7 +53,6 @@ typedef struct {
//------------- device descriptor -------------//
uint16_t vendor_id;
uint16_t product_id;
- uint8_t configure_count; // bNumConfigurations alias
//------------- configuration descriptor -------------//
uint8_t interface_count; // bNumInterfaces alias