correct ehci control endpoint address report on xfer complete

improve host log
This commit is contained in:
hathach
2021-05-11 18:11:46 +07:00
parent 3a7f8b3ac3
commit 13613eafb7
3 changed files with 15 additions and 10 deletions

View File

@@ -513,18 +513,19 @@ static void qhd_xfer_complete_isr(ehci_qhd_t * p_qhd)
// free all TDs from the head td to the first active TD
while(p_qhd->p_qtd_list_head != NULL && !p_qhd->p_qtd_list_head->active)
{
// TD need to be freed and removed from qhd, before invoking callback
bool is_ioc = (p_qhd->p_qtd_list_head->int_on_complete != 0);
p_qhd->total_xferred_bytes += p_qhd->p_qtd_list_head->expected_bytes - p_qhd->p_qtd_list_head->total_bytes;
ehci_qtd_t * volatile qtd = (ehci_qtd_t * volatile) p_qhd->p_qtd_list_head;
bool const is_ioc = (qtd->int_on_complete != 0);
uint8_t const ep_addr = tu_edpt_addr(p_qhd->ep_number, qtd->pid == EHCI_PID_IN ? 1 : 0);
p_qhd->p_qtd_list_head->used = 0; // free QTD
p_qhd->total_xferred_bytes += qtd->expected_bytes - qtd->total_bytes;
// TD need to be freed and removed from qhd, before invoking callback
qtd->used = 0; // free QTD
qtd_remove_1st_from_qhd(p_qhd);
if (is_ioc)
{
// end of request
// call USBH callback
hcd_event_xfer_complete(p_qhd->dev_addr, tu_edpt_addr(p_qhd->ep_number, p_qhd->pid == EHCI_PID_IN ? 1 : 0), p_qhd->total_xferred_bytes, XFER_RESULT_SUCCESS, true);
hcd_event_xfer_complete(p_qhd->dev_addr, ep_addr, p_qhd->total_xferred_bytes, XFER_RESULT_SUCCESS, true);
p_qhd->total_xferred_bytes = 0;
}
}