From 3f9f3f08d2429ee51e1545464686f671253ac98f Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 1 Jul 2013 18:53:25 +0700 Subject: add cdc host driver close cdch_close refractor - add helper function in ehci qhd_next & qtd_next - extract function qhd_create_pipe_handle rename tusb_transfer_type_t to tusb_xfer_type_t add some handling for stall --- tinyusb/class/cdc_host.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tinyusb/class') diff --git a/tinyusb/class/cdc_host.c b/tinyusb/class/cdc_host.c index 81d992c21..9a3cb6ef8 100644 --- a/tinyusb/class/cdc_host.c +++ b/tinyusb/class/cdc_host.c @@ -142,7 +142,30 @@ void cdch_isr(pipe_handle_t pipe_hdl, tusb_event_t event) void cdch_close(uint8_t dev_addr) { + tusb_error_t err1, err2, err3; + cdch_data_t * p_cdc = &cdch_data[dev_addr-1]; + + + if ( pipehandle_is_valid(p_cdc->pipe_notification) ) + { + err1 = hcd_pipe_close(p_cdc->pipe_notification); + } + + if ( pipehandle_is_valid(p_cdc->pipe_in) ) + { + err2 = hcd_pipe_close(p_cdc->pipe_in); + } + + if ( pipehandle_is_valid(p_cdc->pipe_out) ) + { + err3 = hcd_pipe_close(p_cdc->pipe_out); + } + + memclr_(p_cdc, sizeof(cdch_data_t)); + ASSERT(err1 == TUSB_ERROR_NONE && + err2 == TUSB_ERROR_NONE && + err3 == TUSB_ERROR_NONE, (void) 0 ); } #endif -- cgit v1.3.1