diff --git a/tests/lpc18xx_43xx/test/host/cdc/test_cdc_host.c b/tests/lpc18xx_43xx/test/host/cdc/test_cdc_host.c index cd95f3fcd..8bd1d46b7 100644 --- a/tests/lpc18xx_43xx/test/host/cdc/test_cdc_host.c +++ b/tests/lpc18xx_43xx/test/host/cdc/test_cdc_host.c @@ -155,6 +155,39 @@ void test_cdch_open_acm_capacity_check(void) TEST_ASSERT_EQUAL_MEMORY(&cdc_config_descriptor.cdc_acm.bmCapabilities, &p_cdc->acm_capability, 1); } +void test_cdch_close_device(void) +{ + pipe_handle_t pipe_notification = { + .dev_addr = 1, + .xfer_type = TUSB_XFER_INTERRUPT + }; + + pipe_handle_t pipe_out = { + .dev_addr = 1, + .xfer_type = TUSB_XFER_BULK, + .index = 0 + }; + + pipe_handle_t pipe_int = { + .dev_addr = 1, + .xfer_type = TUSB_XFER_BULK, + .index = 1 + }; + + hcd_pipe_open_ExpectAndReturn(dev_addr, p_endpoint_notification, TUSB_CLASS_CDC, pipe_notification); + hcd_pipe_open_ExpectAndReturn(dev_addr, p_endpoint_out, TUSB_CLASS_CDC, pipe_out); + hcd_pipe_open_ExpectAndReturn(dev_addr, p_endpoint_in, TUSB_CLASS_CDC, pipe_int); + + TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, cdch_open_subtask(dev_addr, p_comm_interface, &length) ); + + hcd_pipe_close_ExpectAndReturn(pipe_notification , TUSB_ERROR_NONE); + hcd_pipe_close_ExpectAndReturn(pipe_int , TUSB_ERROR_NONE); + hcd_pipe_close_ExpectAndReturn(pipe_out , TUSB_ERROR_NONE); + + //------------- CUT -------------// + cdch_close(dev_addr); +} + diff --git a/tinyusb/class/cdc_host.c b/tinyusb/class/cdc_host.c index 9a3cb6ef8..ce1f67e20 100644 --- a/tinyusb/class/cdc_host.c +++ b/tinyusb/class/cdc_host.c @@ -57,6 +57,18 @@ //--------------------------------------------------------------------+ /*STATIC_*/ cdch_data_t cdch_data[TUSB_CFG_HOST_DEVICE_MAX]; +//--------------------------------------------------------------------+ +// APPLICATION API (parameter validation needed) +//--------------------------------------------------------------------+ +bool tusbh_cdc_serial_is_mounted(uint8_t dev_addr) +{ + // TODO consider all AT Command as serial candidate + return + (tusbh_device_get_mounted_class_flag(dev_addr) & BIT_(TUSB_CLASS_CDC) ) && + (CDC_COMM_PROTOCOL_ATCOMMAND <= cdch_data[dev_addr-1].interface_protocol) && + (cdch_data[dev_addr-1].interface_protocol <= CDC_COMM_PROTOCOL_ATCOMMAND_CDMA); +} + //--------------------------------------------------------------------+ // USBH-CLASS DRIVER API //--------------------------------------------------------------------+ diff --git a/tinyusb/class/cdc_host.h b/tinyusb/class/cdc_host.h index 5eee3670b..2b39a6fd7 100644 --- a/tinyusb/class/cdc_host.h +++ b/tinyusb/class/cdc_host.h @@ -57,11 +57,11 @@ //--------------------------------------------------------------------+ // APPLICATION PUBLIC API //--------------------------------------------------------------------+ -bool tusbh_cdc_acm_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; +//bool tusbh_cdc_acm_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; bool tusbh_cdc_serial_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; bool tusbh_cdc_rndis_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; -tusb_interface_status_t tusbh_cdc_send(void const * p_data, uint32_t length); +tusb_interface_status_t tusbh_cdc_send(void const * p_data, uint32_t length, bool is_notify); //--------------------------------------------------------------------+ // USBH-CLASS API diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index 97aaae680..3e75c265a 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -964,7 +964,7 @@ static ehci_link_t* list_find_previous_item(ehci_link_t* p_head, ehci_link_t* p_ uint32_t max_loop = 0; while( (align32(p_prev->address) != (uint32_t) p_head) && // not loop around (align32(p_prev->address) != (uint32_t) p_current) && // not found yet - !p_prev->terminate && // not advancable + !p_prev->terminate && // not advanceable max_loop < EHCI_MAX_QHD) { p_prev = list_next(p_prev);