more hcd_pipe to hcd_edpt rename

This commit is contained in:
hathach 2018-12-11 13:15:05 +07:00
parent 0d04e6eb96
commit dbc560658a
No known key found for this signature in database
GPG Key ID: 2FA891220FBFD581
8 changed files with 29 additions and 27 deletions

View File

@ -80,13 +80,13 @@ bool tuh_cdc_is_busy(uint8_t dev_addr, cdc_pipeid_t pipeid)
switch (pipeid) switch (pipeid)
{ {
case CDC_PIPE_NOTIFICATION: case CDC_PIPE_NOTIFICATION:
return hcd_pipe_is_busy(dev_addr, p_cdc->ep_notif ); return hcd_edpt_busy(dev_addr, p_cdc->ep_notif );
case CDC_PIPE_DATA_IN: case CDC_PIPE_DATA_IN:
return hcd_pipe_is_busy(dev_addr, p_cdc->ep_in ); return hcd_edpt_busy(dev_addr, p_cdc->ep_in );
case CDC_PIPE_DATA_OUT: case CDC_PIPE_DATA_OUT:
return hcd_pipe_is_busy(dev_addr, p_cdc->ep_out ); return hcd_edpt_busy(dev_addr, p_cdc->ep_out );
default: default:
return false; return false;
@ -110,7 +110,7 @@ bool tuh_cdc_send(uint8_t dev_addr, void const * p_data, uint32_t length, bool i
TU_VERIFY( p_data != NULL && length, TUSB_ERROR_INVALID_PARA); TU_VERIFY( p_data != NULL && length, TUSB_ERROR_INVALID_PARA);
uint8_t const ep_out = cdch_data[dev_addr-1].ep_out; uint8_t const ep_out = cdch_data[dev_addr-1].ep_out;
if ( hcd_pipe_is_busy(dev_addr, ep_out) ) return false; if ( hcd_edpt_busy(dev_addr, ep_out) ) return false;
return hcd_pipe_xfer(dev_addr, ep_out, (void *) p_data, length, is_notify); return hcd_pipe_xfer(dev_addr, ep_out, (void *) p_data, length, is_notify);
} }
@ -121,7 +121,7 @@ bool tuh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length, bool is
TU_VERIFY( p_buffer != NULL && length, TUSB_ERROR_INVALID_PARA); TU_VERIFY( p_buffer != NULL && length, TUSB_ERROR_INVALID_PARA);
uint8_t const ep_in = cdch_data[dev_addr-1].ep_in; uint8_t const ep_in = cdch_data[dev_addr-1].ep_in;
if ( hcd_pipe_is_busy(dev_addr, ep_in) ) return false; if ( hcd_edpt_busy(dev_addr, ep_in) ) return false;
return hcd_pipe_xfer(dev_addr, ep_in, p_buffer, length, is_notify); return hcd_pipe_xfer(dev_addr, ep_in, p_buffer, length, is_notify);
} }

View File

@ -78,7 +78,7 @@ tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_int
// TODO change to use is configured function // TODO change to use is configured function
TU_ASSERT (TUSB_DEVICE_STATE_CONFIGURED == tuh_device_get_state(dev_addr), TUSB_ERROR_DEVICE_NOT_READY); TU_ASSERT (TUSB_DEVICE_STATE_CONFIGURED == tuh_device_get_state(dev_addr), TUSB_ERROR_DEVICE_NOT_READY);
TU_VERIFY (report, TUSB_ERROR_INVALID_PARA); TU_VERIFY (report, TUSB_ERROR_INVALID_PARA);
TU_ASSERT (!hcd_pipe_is_busy(p_hid->pipe_hdl), TUSB_ERROR_INTERFACE_IS_BUSY); TU_ASSERT (!hcd_edpt_busy(p_hid->pipe_hdl), TUSB_ERROR_INTERFACE_IS_BUSY);
TU_ASSERT_ERR( hcd_pipe_xfer(p_hid->pipe_hdl, report, p_hid->report_size, true) ) ; TU_ASSERT_ERR( hcd_pipe_xfer(p_hid->pipe_hdl, report, p_hid->report_size, true) ) ;
@ -118,7 +118,7 @@ tusb_error_t tuh_hid_keyboard_get_report(uint8_t dev_addr, void* p_report)
bool tuh_hid_keyboard_is_busy(uint8_t dev_addr) bool tuh_hid_keyboard_is_busy(uint8_t dev_addr)
{ {
return tuh_hid_keyboard_is_mounted(dev_addr) && return tuh_hid_keyboard_is_mounted(dev_addr) &&
hcd_pipe_is_busy( keyboardh_data[dev_addr-1].pipe_hdl ); hcd_edpt_busy( keyboardh_data[dev_addr-1].pipe_hdl );
} }
#endif #endif
@ -139,7 +139,7 @@ bool tuh_hid_mouse_is_mounted(uint8_t dev_addr)
bool tuh_hid_mouse_is_busy(uint8_t dev_addr) bool tuh_hid_mouse_is_busy(uint8_t dev_addr)
{ {
return tuh_hid_mouse_is_mounted(dev_addr) && return tuh_hid_mouse_is_mounted(dev_addr) &&
hcd_pipe_is_busy( mouseh_data[dev_addr-1].pipe_hdl ); hcd_edpt_busy( mouseh_data[dev_addr-1].pipe_hdl );
} }
tusb_error_t tuh_hid_mouse_get_report(uint8_t dev_addr, void * report) tusb_error_t tuh_hid_mouse_get_report(uint8_t dev_addr, void * report)

View File

@ -76,7 +76,7 @@ bool tuh_msc_is_mounted(uint8_t dev_addr)
bool tuh_msc_is_busy(uint8_t dev_addr) bool tuh_msc_is_busy(uint8_t dev_addr)
{ {
return msch_data[dev_addr-1].is_initialized && return msch_data[dev_addr-1].is_initialized &&
hcd_pipe_is_busy(dev_addr, msch_data[dev_addr-1].ep_in); hcd_edpt_busy(dev_addr, msch_data[dev_addr-1].ep_in);
} }
uint8_t const* tuh_msc_get_vendor_name(uint8_t dev_addr) uint8_t const* tuh_msc_get_vendor_name(uint8_t dev_addr)
@ -361,7 +361,7 @@ bool msch_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *it
// NOTE: my toshiba thumb-drive stall the first Read Capacity and require the sequence // NOTE: my toshiba thumb-drive stall the first Read Capacity and require the sequence
// Read Capacity --> Stalled --> Clear Stall --> Request Sense --> Read Capacity (2) to work // Read Capacity --> Stalled --> Clear Stall --> Request Sense --> Read Capacity (2) to work
if ( hcd_pipe_is_stalled(dev_addr, p_msc->ep_in) ) if ( hcd_edpt_stalled(dev_addr, p_msc->ep_in) )
{ {
// clear stall TODO abstract clear stall function // clear stall TODO abstract clear stall function
request = (tusb_control_request_t) { request = (tusb_control_request_t) {
@ -374,7 +374,7 @@ bool msch_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *it
TU_ASSERT(usbh_control_xfer( dev_addr, &request, NULL )); TU_ASSERT(usbh_control_xfer( dev_addr, &request, NULL ));
hcd_pipe_clear_stall(dev_addr, p_msc->ep_in); hcd_edpt_clear_stall(dev_addr, p_msc->ep_in);
TU_ASSERT( osal_semaphore_wait(msch_sem_hdl, SCSI_XFER_TIMEOUT) ); // wait for SCSI status TU_ASSERT( osal_semaphore_wait(msch_sem_hdl, SCSI_XFER_TIMEOUT) ); // wait for SCSI status
//------------- SCSI Request Sense -------------// //------------- SCSI Request Sense -------------//

View File

@ -420,19 +420,19 @@ bool hcd_pipe_close(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr)
return true; return true;
} }
bool hcd_pipe_is_busy(uint8_t dev_addr, uint8_t ep_addr) bool hcd_edpt_busy(uint8_t dev_addr, uint8_t ep_addr)
{ {
ehci_qhd_t *p_qhd = qhd_get_from_addr(dev_addr, ep_addr); ehci_qhd_t *p_qhd = qhd_get_from_addr(dev_addr, ep_addr);
return !p_qhd->qtd_overlay.halted && (p_qhd->p_qtd_list_head != NULL); return !p_qhd->qtd_overlay.halted && (p_qhd->p_qtd_list_head != NULL);
} }
bool hcd_pipe_is_stalled(uint8_t dev_addr, uint8_t ep_addr) bool hcd_edpt_stalled(uint8_t dev_addr, uint8_t ep_addr)
{ {
ehci_qhd_t *p_qhd = qhd_get_from_addr(dev_addr, ep_addr); ehci_qhd_t *p_qhd = qhd_get_from_addr(dev_addr, ep_addr);
return p_qhd->qtd_overlay.halted && !qhd_has_xact_error(p_qhd); return p_qhd->qtd_overlay.halted && !qhd_has_xact_error(p_qhd);
} }
bool hcd_pipe_clear_stall(uint8_t dev_addr, uint8_t ep_addr) bool hcd_edpt_clear_stall(uint8_t dev_addr, uint8_t ep_addr)
{ {
ehci_qhd_t *p_qhd = qhd_get_from_addr(dev_addr, ep_addr); ehci_qhd_t *p_qhd = qhd_get_from_addr(dev_addr, ep_addr);
p_qhd->qtd_overlay.halted = 0; p_qhd->qtd_overlay.halted = 0;

View File

@ -131,8 +131,14 @@ void hcd_event_xfer_complete(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t ev
bool hcd_setup_send(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet[8]); bool hcd_setup_send(uint8_t rhport, uint8_t dev_addr, uint8_t const setup_packet[8]);
bool hcd_edpt_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_endpoint_t const * ep_desc); bool hcd_edpt_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_endpoint_t const * ep_desc);
bool hcd_edpt_busy(uint8_t dev_addr, uint8_t ep_addr);
bool hcd_edpt_stalled(uint8_t dev_addr, uint8_t ep_addr);
bool hcd_edpt_clear_stall(uint8_t dev_addr, uint8_t ep_addr);
// TODO remove
bool hcd_edpt_close(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr); bool hcd_edpt_close(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr);
bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_t buflen); bool hcd_edpt_xfer(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t * buffer, uint16_t buflen);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// PIPE API // PIPE API
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@ -141,10 +147,6 @@ bool hcd_pipe_queue_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t buffer[], ui
bool hcd_pipe_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete); bool hcd_pipe_xfer(uint8_t dev_addr, uint8_t ep_addr, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete);
bool hcd_pipe_close(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr); // TODO remove bool hcd_pipe_close(uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr); // TODO remove
bool hcd_pipe_is_busy(uint8_t dev_addr, uint8_t ep_addr);
bool hcd_pipe_is_stalled(uint8_t dev_addr, uint8_t ep_addr); // stalled also counted as error
bool hcd_pipe_clear_stall(uint8_t dev_addr, uint8_t ep_addr);
#if 0 #if 0
tusb_error_t hcd_pipe_cancel()ATTR_WARN_UNUSED_RESULT; tusb_error_t hcd_pipe_cancel()ATTR_WARN_UNUSED_RESULT;
#endif #endif

View File

@ -583,19 +583,19 @@ tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl)
return TUSB_ERROR_FAILED; return TUSB_ERROR_FAILED;
} }
bool hcd_pipe_is_busy(pipe_handle_t pipe_hdl) bool hcd_edpt_busy(pipe_handle_t pipe_hdl)
{ {
ohci_ed_t const * const p_ed = ed_from_pipe_handle(pipe_hdl); ohci_ed_t const * const p_ed = ed_from_pipe_handle(pipe_hdl);
return tu_align16(p_ed->td_head.address) != tu_align16(p_ed->td_tail.address); return tu_align16(p_ed->td_head.address) != tu_align16(p_ed->td_tail.address);
} }
bool hcd_pipe_is_stalled(pipe_handle_t pipe_hdl) bool hcd_edpt_stalled(pipe_handle_t pipe_hdl)
{ {
ohci_ed_t const * const p_ed = ed_from_pipe_handle(pipe_hdl); ohci_ed_t const * const p_ed = ed_from_pipe_handle(pipe_hdl);
return p_ed->td_head.halted && p_ed->is_stalled; return p_ed->td_head.halted && p_ed->is_stalled;
} }
tusb_error_t hcd_pipe_clear_stall(pipe_handle_t pipe_hdl) tusb_error_t hcd_edpt_clear_stall(pipe_handle_t pipe_hdl)
{ {
ohci_ed_t * const p_ed = ed_from_pipe_handle(pipe_hdl); ohci_ed_t * const p_ed = ed_from_pipe_handle(pipe_hdl);

View File

@ -187,7 +187,7 @@ void test_keyboard_get_device_not_ready(void)
void test_keyboard_get_report_xfer_failed() void test_keyboard_get_report_xfer_failed()
{ {
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
hcd_pipe_is_busy_ExpectAndReturn(p_hidh_kbd->pipe_hdl, false); hcd_edpt_busy_ExpectAndReturn(p_hidh_kbd->pipe_hdl, false);
hcd_pipe_xfer_ExpectAndReturn(p_hidh_kbd->pipe_hdl, (uint8_t*) &report, p_hidh_kbd->report_size, true, TUSB_ERROR_INVALID_PARA); hcd_pipe_xfer_ExpectAndReturn(p_hidh_kbd->pipe_hdl, (uint8_t*) &report, p_hidh_kbd->report_size, true, TUSB_ERROR_INVALID_PARA);
//------------- Code Under TEST -------------// //------------- Code Under TEST -------------//
@ -197,7 +197,7 @@ void test_keyboard_get_report_xfer_failed()
void test_keyboard_get_report_xfer_failed_busy() void test_keyboard_get_report_xfer_failed_busy()
{ {
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
hcd_pipe_is_busy_ExpectAndReturn(p_hidh_kbd->pipe_hdl, true); hcd_edpt_busy_ExpectAndReturn(p_hidh_kbd->pipe_hdl, true);
TEST_ASSERT_EQUAL(TUSB_ERROR_INTERFACE_IS_BUSY, tusbh_hid_keyboard_get_report(dev_addr, &report)); TEST_ASSERT_EQUAL(TUSB_ERROR_INTERFACE_IS_BUSY, tusbh_hid_keyboard_get_report(dev_addr, &report));
} }
@ -206,7 +206,7 @@ void test_keyboard_get_ok()
{ {
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
// TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, tusbh_hid_keyboard_status(dev_addr)); // TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, tusbh_hid_keyboard_status(dev_addr));
hcd_pipe_is_busy_ExpectAndReturn(p_hidh_kbd->pipe_hdl, false); hcd_edpt_busy_ExpectAndReturn(p_hidh_kbd->pipe_hdl, false);
hcd_pipe_xfer_ExpectAndReturn(p_hidh_kbd->pipe_hdl, (uint8_t*) &report, p_hidh_kbd->report_size, true, TUSB_ERROR_NONE); hcd_pipe_xfer_ExpectAndReturn(p_hidh_kbd->pipe_hdl, (uint8_t*) &report, p_hidh_kbd->report_size, true, TUSB_ERROR_NONE);
//------------- Code Under TEST -------------// //------------- Code Under TEST -------------//

View File

@ -159,7 +159,7 @@ void test_mouse_get_device_not_ready(void)
void test_mouse_get_report_xfer_failed() void test_mouse_get_report_xfer_failed()
{ {
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
hcd_pipe_is_busy_ExpectAndReturn(p_hidh_mouse->pipe_hdl, false); hcd_edpt_busy_ExpectAndReturn(p_hidh_mouse->pipe_hdl, false);
hcd_pipe_xfer_ExpectAndReturn(p_hidh_mouse->pipe_hdl, (uint8_t*) &report, p_hidh_mouse->report_size, true, TUSB_ERROR_INVALID_PARA); hcd_pipe_xfer_ExpectAndReturn(p_hidh_mouse->pipe_hdl, (uint8_t*) &report, p_hidh_mouse->report_size, true, TUSB_ERROR_INVALID_PARA);
//------------- Code Under TEST -------------// //------------- Code Under TEST -------------//
@ -169,7 +169,7 @@ void test_mouse_get_report_xfer_failed()
void test_mouse_get_report_xfer_failed_busy() void test_mouse_get_report_xfer_failed_busy()
{ {
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
hcd_pipe_is_busy_ExpectAndReturn(p_hidh_mouse->pipe_hdl, true); hcd_edpt_busy_ExpectAndReturn(p_hidh_mouse->pipe_hdl, true);
TEST_ASSERT_EQUAL(TUSB_ERROR_INTERFACE_IS_BUSY, tusbh_hid_mouse_get_report(dev_addr, &report)); TEST_ASSERT_EQUAL(TUSB_ERROR_INTERFACE_IS_BUSY, tusbh_hid_mouse_get_report(dev_addr, &report));
} }
@ -178,7 +178,7 @@ void test_mouse_get_ok()
{ {
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
// TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, tusbh_hid_mouse_status(dev_addr)); // TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, tusbh_hid_mouse_status(dev_addr));
hcd_pipe_is_busy_ExpectAndReturn(p_hidh_mouse->pipe_hdl, false); hcd_edpt_busy_ExpectAndReturn(p_hidh_mouse->pipe_hdl, false);
hcd_pipe_xfer_ExpectAndReturn(p_hidh_mouse->pipe_hdl, (uint8_t*) &report, p_hidh_mouse->report_size, true, TUSB_ERROR_NONE); hcd_pipe_xfer_ExpectAndReturn(p_hidh_mouse->pipe_hdl, (uint8_t*) &report, p_hidh_mouse->report_size, true, TUSB_ERROR_NONE);
//------------- Code Under TEST -------------// //------------- Code Under TEST -------------//