mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
refactor dcd_xfer_complete
This commit is contained in:
parent
bf9fc1b318
commit
43cf0fb3df
@ -406,8 +406,8 @@ void xfer_complete_isr(uint8_t port, uint32_t reg_complete)
|
||||
|
||||
if (p_qtd->int_on_complete)
|
||||
{
|
||||
tusb_event_t event = ( p_qtd->xact_err || p_qtd->halted || p_qtd->buffer_err ) ? TUSB_EVENT_XFER_ERROR : TUSB_EVENT_XFER_COMPLETE;
|
||||
usbd_xfer_isr(edpt_hdl, event, p_qtd->expected_bytes - p_qtd->total_bytes); // only number of bytes in the IOC qtd
|
||||
bool succeeded = ( p_qtd->xact_err || p_qtd->halted || p_qtd->buffer_err ) ? false : true;
|
||||
tusb_dcd_xfer_complete(edpt_hdl, p_qtd->expected_bytes - p_qtd->total_bytes, succeeded); // only number of bytes in the IOC qtd
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -481,9 +481,9 @@ void hal_dcd_isr(uint8_t port)
|
||||
.port = port,
|
||||
.index = 0,
|
||||
};
|
||||
tusb_event_t event = ( p_qtd->xact_err || p_qtd->halted || p_qtd->buffer_err ) ? TUSB_EVENT_XFER_ERROR : TUSB_EVENT_XFER_COMPLETE;
|
||||
bool succeeded = ( p_qtd->xact_err || p_qtd->halted || p_qtd->buffer_err ) ? false : true;
|
||||
|
||||
usbd_xfer_isr(edpt_hdl, event, 0); // TODO xferred bytes for control xfer is not needed yet !!!!
|
||||
tusb_dcd_xfer_complete(edpt_hdl, 0, succeeded); // TODO xferred bytes for control xfer is not needed yet !!!!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,9 +165,9 @@ static void endpoint_non_control_isr(uint32_t eot_int)
|
||||
.index = ep_id,
|
||||
.class_code = dcd_data.class_code[ep_id]
|
||||
};
|
||||
tusb_event_t event = (p_last_dd->status == DD_STATUS_NORMAL || p_last_dd->status == DD_STATUS_DATA_UNDERUN) ? TUSB_EVENT_XFER_COMPLETE : TUSB_EVENT_XFER_ERROR;
|
||||
bool succeeded = (p_last_dd->status == DD_STATUS_NORMAL || p_last_dd->status == DD_STATUS_DATA_UNDERUN) ? true : false;
|
||||
|
||||
usbd_xfer_isr(edpt_hdl, event, p_last_dd->present_count); // report only xferred bytes in the IOC qtd
|
||||
tusb_dcd_xfer_complete(edpt_hdl, p_last_dd->present_count, succeeded); // report only xferred bytes in the IOC qtd
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -208,7 +208,7 @@ static void endpoint_control_isr(void)
|
||||
dcd_data.control_dma.int_on_complete = 0;
|
||||
|
||||
// FIXME xferred_byte for control xfer is not needed now !!!
|
||||
usbd_xfer_isr(edpt_hdl, TUSB_EVENT_XFER_COMPLETE, 0);
|
||||
tusb_dcd_xfer_complete(edpt_hdl, 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ static void endpoint_non_control_isr(uint32_t int_status)
|
||||
dcd_data.current_ioc = BIT_CLR_(dcd_data.current_ioc, edpt_hdl.index);
|
||||
|
||||
// TODO no way determine if the transfer is failed or not
|
||||
usbd_xfer_isr(edpt_hdl, TUSB_EVENT_XFER_COMPLETE, dcd_data.current_td[ep_id].xferred_total);
|
||||
tusb_dcd_xfer_complete(edpt_hdl, dcd_data.current_td[ep_id].xferred_total, true);
|
||||
}
|
||||
|
||||
//------------- Next TD is available -------------//
|
||||
@ -291,7 +291,7 @@ static void endpoint_control_isr(uint32_t int_status)
|
||||
dcd_data.current_ioc = BIT_CLR_(dcd_data.current_ioc, ep_id);
|
||||
|
||||
// FIXME xferred_byte for control xfer is not needed now !!!
|
||||
usbd_xfer_isr(edpt_hdl, TUSB_EVENT_XFER_COMPLETE, 0);
|
||||
tusb_dcd_xfer_complete(edpt_hdl, 0, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -498,7 +498,7 @@ void tusb_dcd_setup_received(uint8_t port, uint8_t const* p_request)
|
||||
osal_queue_send(usbd_queue_hdl, &task_event);
|
||||
}
|
||||
|
||||
void usbd_xfer_isr(edpt_hdl_t edpt_hdl, tusb_event_t event, uint32_t xferred_bytes)
|
||||
void tusb_dcd_xfer_complete(edpt_hdl_t edpt_hdl, uint32_t xferred_bytes, bool succeeded)
|
||||
{
|
||||
if (edpt_hdl.index == 0 )
|
||||
{
|
||||
@ -510,7 +510,7 @@ void usbd_xfer_isr(edpt_hdl_t edpt_hdl, tusb_event_t event, uint32_t xferred_byt
|
||||
{
|
||||
.port = edpt_hdl.port,
|
||||
.event_id = USBD_EVENTID_XFER_DONE,
|
||||
.sub_event_id = event
|
||||
.sub_event_id = succeeded ? TUSB_EVENT_XFER_COMPLETE : TUSB_EVENT_XFER_ERROR
|
||||
};
|
||||
|
||||
task_event.xfer_done.xferred_byte = xferred_bytes;
|
||||
|
@ -75,10 +75,13 @@ void tusb_dcd_disconnect (uint8_t port);
|
||||
void tusb_dcd_set_address (uint8_t port, uint8_t dev_addr);
|
||||
void tusb_dcd_set_config (uint8_t port, uint8_t config_num);
|
||||
|
||||
/*------------- Event function -------------*/
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Event Function
|
||||
* Called by DCD to notify USBD
|
||||
*------------------------------------------------------------------*/
|
||||
void tusb_dcd_bus_event(uint8_t port, usbd_bus_event_type_t bus_event);
|
||||
void tusb_dcd_setup_received(uint8_t port, uint8_t const* p_request);
|
||||
void usbd_xfer_isr(edpt_hdl_t edpt_hdl, tusb_event_t event, uint32_t xferred_bytes);
|
||||
void tusb_dcd_xfer_complete(edpt_hdl_t edpt_hdl, uint32_t xferred_bytes, bool succeeded);
|
||||
|
||||
//------------- PIPE API -------------//
|
||||
bool tusb_dcd_control_xfer(uint8_t port, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete);
|
||||
|
Loading…
x
Reference in New Issue
Block a user