fix(hcd) hcd_edpt_open() return true if endpoint is already opened.

This commit is contained in:
hathach
2025-04-03 18:11:33 +07:00
parent 8c1802e41d
commit 4787cd5f54
4 changed files with 25 additions and 13 deletions

View File

@@ -163,6 +163,7 @@ void hcd_device_close(uint8_t rhport, uint8_t dev_addr);
//--------------------------------------------------------------------+
// 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);
// Close an endpoint

View File

@@ -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];
}else {
if (NULL != find_ep_not_addr0(daddr, ep_num, ep_dir)) {
return false; // endpoint already opened
return true; // already opened
}
ep = allocate_ep();
TU_ASSERT(ep);

View File

@@ -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) {
p_qhd = qhd_control(dev_addr);
} 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();
}
TU_ASSERT(p_qhd);