Merge pull request #3061 from hathach/update-endpoint-open
fix(hcd) hcd_edpt_open() return true if endpoint is already opened.
This commit is contained in:
@@ -124,13 +124,18 @@ void tuh_mount_cb(uint8_t daddr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("Device %u: ID %04x:%04x SN ", daddr, desc.device.idVendor, desc.device.idProduct);
|
printf("Device %u: ID %04x:%04x SN ", daddr, desc.device.idVendor, desc.device.idProduct);
|
||||||
xfer_result = tuh_descriptor_get_serial_string_sync(daddr, LANGUAGE_ID, desc.serial, sizeof(desc.serial));
|
|
||||||
|
xfer_result = XFER_RESULT_FAILED;
|
||||||
|
if (desc.device.iSerialNumber != 0) {
|
||||||
|
xfer_result = tuh_descriptor_get_serial_string_sync(daddr, LANGUAGE_ID, desc.serial, sizeof(desc.serial));
|
||||||
|
}
|
||||||
if (XFER_RESULT_SUCCESS != xfer_result) {
|
if (XFER_RESULT_SUCCESS != xfer_result) {
|
||||||
uint16_t* serial = (uint16_t*)(uintptr_t) desc.serial;
|
uint16_t* serial = (uint16_t*)(uintptr_t) desc.serial;
|
||||||
serial[0] = 'n';
|
serial[0] = (uint16_t) ((TUSB_DESC_STRING << 8) | (2 * 3 + 2));
|
||||||
serial[1] = '/';
|
serial[1] = 'n';
|
||||||
serial[2] = 'a';
|
serial[2] = '/';
|
||||||
serial[3] = 0;
|
serial[3] = 'a';
|
||||||
|
serial[4] = 0;
|
||||||
}
|
}
|
||||||
print_utf16((uint16_t*)(uintptr_t) desc.serial, sizeof(desc.serial)/2);
|
print_utf16((uint16_t*)(uintptr_t) desc.serial, sizeof(desc.serial)/2);
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
@@ -150,16 +155,20 @@ void tuh_mount_cb(uint8_t daddr) {
|
|||||||
// Get String descriptor using Sync API
|
// Get String descriptor using Sync API
|
||||||
|
|
||||||
printf(" iManufacturer %u ", desc.device.iManufacturer);
|
printf(" iManufacturer %u ", desc.device.iManufacturer);
|
||||||
xfer_result = tuh_descriptor_get_manufacturer_string_sync(daddr, LANGUAGE_ID, desc.buf, sizeof(desc.buf));
|
if (desc.device.iManufacturer != 0) {
|
||||||
if (XFER_RESULT_SUCCESS == xfer_result) {
|
xfer_result = tuh_descriptor_get_manufacturer_string_sync(daddr, LANGUAGE_ID, desc.buf, sizeof(desc.buf));
|
||||||
print_utf16((uint16_t*)(uintptr_t) desc.buf, sizeof(desc.buf)/2);
|
if (XFER_RESULT_SUCCESS == xfer_result) {
|
||||||
|
print_utf16((uint16_t*)(uintptr_t) desc.buf, sizeof(desc.buf)/2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
|
|
||||||
printf(" iProduct %u ", desc.device.iProduct);
|
printf(" iProduct %u ", desc.device.iProduct);
|
||||||
xfer_result = tuh_descriptor_get_product_string_sync(daddr, LANGUAGE_ID, desc.buf, sizeof(desc.buf));
|
if (desc.device.iProduct != 0) {
|
||||||
if (XFER_RESULT_SUCCESS == xfer_result) {
|
xfer_result = tuh_descriptor_get_product_string_sync(daddr, LANGUAGE_ID, desc.buf, sizeof(desc.buf));
|
||||||
print_utf16((uint16_t*)(uintptr_t) desc.buf, sizeof(desc.buf)/2);
|
if (XFER_RESULT_SUCCESS == xfer_result) {
|
||||||
|
print_utf16((uint16_t*)(uintptr_t) desc.buf, sizeof(desc.buf)/2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
printf("\r\n");
|
printf("\r\n");
|
||||||
|
|
||||||
|
@@ -163,6 +163,7 @@ void hcd_device_close(uint8_t rhport, uint8_t dev_addr);
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// Open an endpoint
|
// Open an endpoint
|
||||||
|
// return true if successfully opened or endpoint is currently opened
|
||||||
bool hcd_edpt_open(uint8_t rhport, uint8_t daddr, tusb_desc_endpoint_t const * ep_desc);
|
bool hcd_edpt_open(uint8_t rhport, uint8_t daddr, tusb_desc_endpoint_t const * ep_desc);
|
||||||
|
|
||||||
// Close an endpoint
|
// Close an endpoint
|
||||||
|
@@ -611,7 +611,7 @@ bool hcd_edpt_open(uint8_t rhport, uint8_t daddr, tusb_desc_endpoint_t const * e
|
|||||||
ep = &_hcd_data.ep[0];
|
ep = &_hcd_data.ep[0];
|
||||||
}else {
|
}else {
|
||||||
if (NULL != find_ep_not_addr0(daddr, ep_num, ep_dir)) {
|
if (NULL != find_ep_not_addr0(daddr, ep_num, ep_dir)) {
|
||||||
return false; // endpoint already opened
|
return true; // already opened
|
||||||
}
|
}
|
||||||
ep = allocate_ep();
|
ep = allocate_ep();
|
||||||
TU_ASSERT(ep);
|
TU_ASSERT(ep);
|
||||||
|
@@ -381,7 +381,9 @@ bool hcd_edpt_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_endpoint_t const
|
|||||||
if (ep_desc->bEndpointAddress == 0) {
|
if (ep_desc->bEndpointAddress == 0) {
|
||||||
p_qhd = qhd_control(dev_addr);
|
p_qhd = qhd_control(dev_addr);
|
||||||
} else {
|
} else {
|
||||||
TU_VERIFY(NULL == qhd_get_from_addr(dev_addr, ep_desc->bEndpointAddress)); // ep not opened yet
|
if (NULL != qhd_get_from_addr(dev_addr, ep_desc->bEndpointAddress)) {
|
||||||
|
return true; // already opened
|
||||||
|
}
|
||||||
p_qhd = qhd_find_free();
|
p_qhd = qhd_find_free();
|
||||||
}
|
}
|
||||||
TU_ASSERT(p_qhd);
|
TU_ASSERT(p_qhd);
|
||||||
|
Reference in New Issue
Block a user