diff options
| author | hathach <[email protected]> | 2013-09-24 15:05:11 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-09-24 15:21:16 +0700 |
| commit | 63b776f7cf3bb7fe64c2f3b3e383a90b2c50683f (patch) | |
| tree | 1df33c2d8b80310eb7da613e56830181b0cf2fca /tests | |
| parent | c4fef827b1f6cb33b9cc336687bd4ff791f8eec9 (diff) | |
add some tests support for msc host
refractor msch buffer for getting inital scsi like inquiry, read capacity
adding support for resovling stall on control pipe
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/lpc18xx_43xx/test/host/ehci/test_ehci_usbh_hcd_integration.c | 1 | ||||
| -rw-r--r-- | tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c | 21 | ||||
| -rw-r--r-- | tests/lpc18xx_43xx/test/host/hid/test_hid_host.c | 1 | ||||
| -rw-r--r-- | tests/lpc18xx_43xx/test/host/hid/test_hidh_generic.c | 4 | ||||
| -rw-r--r-- | tests/lpc18xx_43xx/test/host/hid/test_hidh_keyboard.c | 6 | ||||
| -rw-r--r-- | tests/lpc18xx_43xx/test/host/hid/test_hidh_mouse.c | 22 | ||||
| -rw-r--r-- | tests/lpc18xx_43xx/test/host/host_helper.h | 14 | ||||
| -rw-r--r-- | tests/lpc18xx_43xx/test/host/msc/msch_callback.h | 66 | ||||
| -rw-r--r-- | tests/lpc18xx_43xx/test/host/msc/test_msc_host.c | 101 | ||||
| -rw-r--r-- | tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c | 36 | ||||
| -rw-r--r-- | tests/support/descriptor_test.c | 89 | ||||
| -rw-r--r-- | tests/support/descriptor_test.h | 15 | ||||
| -rw-r--r-- | tests/support/tusb_config.h | 1 |
13 files changed, 331 insertions, 46 deletions
diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_ehci_usbh_hcd_integration.c b/tests/lpc18xx_43xx/test/host/ehci/test_ehci_usbh_hcd_integration.c index 424710b57..2b6de2d44 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_ehci_usbh_hcd_integration.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_ehci_usbh_hcd_integration.c @@ -46,6 +46,7 @@ #include "hal.h" #include "mock_osal.h" #include "mock_hid_host.h" +#include "mock_msc_host.h" #include "mock_cdc_host.h" #include "hcd.h" diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c index 17a08f2b8..f5f4a0d76 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c @@ -253,6 +253,13 @@ void test_control_xfer_error_isr(void) ehci_controller_run_error(hostid); TEST_ASSERT_EQUAL(0, p_control_qhd->total_xferred_bytes); + + TEST_ASSERT_NULL( p_control_qhd->p_qtd_list_head ); + TEST_ASSERT_NULL( p_control_qhd->p_qtd_list_tail ); + + TEST_ASSERT_TRUE( p_control_qhd->qtd_overlay.next.terminate); + TEST_ASSERT_TRUE( p_control_qhd->qtd_overlay.alternate.terminate); + TEST_ASSERT_FALSE( p_control_qhd->qtd_overlay.halted); } void test_control_xfer_error_stall(void) @@ -265,4 +272,18 @@ void test_control_xfer_error_stall(void) ehci_controller_run_stall(hostid); TEST_ASSERT_EQUAL(0, p_control_qhd->total_xferred_bytes); + + TEST_ASSERT_NULL( p_control_qhd->p_qtd_list_head ); + TEST_ASSERT_NULL( p_control_qhd->p_qtd_list_tail ); + + TEST_ASSERT_TRUE( p_control_qhd->qtd_overlay.next.terminate); + TEST_ASSERT_TRUE( p_control_qhd->qtd_overlay.alternate.terminate); + TEST_ASSERT_FALSE( p_control_qhd->qtd_overlay.halted); + + #if 0 // no neeed + TEST_ASSERT_FALSE( p_setup->used ); + TEST_ASSERT_FALSE( p_data->used ); + TEST_ASSERT_FALSE( p_status->used ); + #endif } + diff --git a/tests/lpc18xx_43xx/test/host/hid/test_hid_host.c b/tests/lpc18xx_43xx/test/host/hid/test_hid_host.c index d2f9f3063..abf80ac57 100644 --- a/tests/lpc18xx_43xx/test/host/hid/test_hid_host.c +++ b/tests/lpc18xx_43xx/test/host/hid/test_hid_host.c @@ -42,6 +42,7 @@ #include "errors.h" #include "binary.h" #include "type_helper.h" +#include "common/common.h" #include "descriptor_test.h" #include "mock_osal.h" diff --git a/tests/lpc18xx_43xx/test/host/hid/test_hidh_generic.c b/tests/lpc18xx_43xx/test/host/hid/test_hidh_generic.c index f367fb821..8d6c2704d 100644 --- a/tests/lpc18xx_43xx/test/host/hid/test_hidh_generic.c +++ b/tests/lpc18xx_43xx/test/host/hid/test_hidh_generic.c @@ -44,8 +44,10 @@ #include "hid_host.h" #include "mock_osal.h" #include "mock_cdc_host.h" -#include "usbh.h" +#include "mock_msc_host.h" + #include "mock_hcd.h" +#include "usbh.h" #include "mock_hidh_callback.h" #include "descriptor_test.h" #include "host_helper.h" diff --git a/tests/lpc18xx_43xx/test/host/hid/test_hidh_keyboard.c b/tests/lpc18xx_43xx/test/host/hid/test_hidh_keyboard.c index 3cbc5c868..fbc6b33f6 100644 --- a/tests/lpc18xx_43xx/test/host/hid/test_hidh_keyboard.c +++ b/tests/lpc18xx_43xx/test/host/hid/test_hidh_keyboard.c @@ -118,7 +118,7 @@ void test_keyboard_is_supported_ok(void) TEST_ASSERT_TRUE( tusbh_hid_keyboard_is_mounted(dev_addr) ); } -static tusb_error_t stub_set_idle_request(uint8_t address, tusb_control_request_t const* p_request, uint8_t* data, int num_call) +tusb_error_t stub_set_idle_request(uint8_t address, tusb_control_request_t const* p_request, uint8_t* data, int num_call) { TEST_ASSERT_EQUAL( dev_addr, address); @@ -143,7 +143,9 @@ void test_keyboard_open_ok(void) hidh_init(); - usbh_control_xfer_subtask_StubWithCallback(stub_set_idle_request); + usbh_control_xfer_subtask_ExpectAndReturn(dev_addr, bm_request_type(TUSB_DIR_HOST_TO_DEV, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_INTERFACE), + HID_REQUEST_CONTROL_SET_IDLE, 0, p_kbd_interface_desc->bInterfaceNumber, 0, NULL, + TUSB_ERROR_NONE); hcd_pipe_open_ExpectAndReturn(dev_addr, p_kdb_endpoint_desc, TUSB_CLASS_HID, pipe_hdl); tusbh_hid_keyboard_mounted_cb_Expect(dev_addr); diff --git a/tests/lpc18xx_43xx/test/host/hid/test_hidh_mouse.c b/tests/lpc18xx_43xx/test/host/hid/test_hidh_mouse.c index 010286ccb..89d1bb7b6 100644 --- a/tests/lpc18xx_43xx/test/host/hid/test_hidh_mouse.c +++ b/tests/lpc18xx_43xx/test/host/hid/test_hidh_mouse.c @@ -107,24 +107,6 @@ void test_mouse_is_supported_ok(void) TEST_ASSERT_TRUE( tusbh_hid_mouse_is_mounted(dev_addr) ); } -static tusb_error_t stub_set_idle_request(uint8_t address, tusb_control_request_t const* p_request, uint8_t* data, int num_call) -{ - TEST_ASSERT_EQUAL( dev_addr, address); - - //------------- expecting Set Idle with value = 0 -------------// - TEST_ASSERT_NOT_NULL( p_request ); - TEST_ASSERT_EQUAL(TUSB_DIR_HOST_TO_DEV , p_request->bmRequestType_bit.direction); - TEST_ASSERT_EQUAL(TUSB_REQUEST_TYPE_CLASS , p_request->bmRequestType_bit.type); - TEST_ASSERT_EQUAL(TUSB_REQUEST_RECIPIENT_INTERFACE , p_request->bmRequestType_bit.recipient); - TEST_ASSERT_EQUAL(HID_REQUEST_CONTROL_SET_IDLE , p_request->bRequest); - TEST_ASSERT_EQUAL(0 , p_request->wValue); - TEST_ASSERT_EQUAL(p_mouse_interface_desc->bInterfaceNumber , p_request->wIndex); - - TEST_ASSERT_NULL(data); - - return TUSB_ERROR_NONE; -} - void test_mouse_open_ok(void) { uint16_t length=0; @@ -132,7 +114,9 @@ void test_mouse_open_ok(void) hidh_init(); - usbh_control_xfer_subtask_StubWithCallback(stub_set_idle_request); + usbh_control_xfer_subtask_ExpectAndReturn(dev_addr, bm_request_type(TUSB_DIR_HOST_TO_DEV, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_INTERFACE), + HID_REQUEST_CONTROL_SET_IDLE, 0, p_mouse_interface_desc->bInterfaceNumber, 0, NULL, + TUSB_ERROR_NONE); hcd_pipe_open_ExpectAndReturn(dev_addr, p_mouse_endpoint_desc, TUSB_CLASS_HID, pipe_hdl); tusbh_hid_mouse_mounted_cb_Expect(dev_addr); diff --git a/tests/lpc18xx_43xx/test/host/host_helper.h b/tests/lpc18xx_43xx/test/host/host_helper.h index a81ce37d9..90ef24976 100644 --- a/tests/lpc18xx_43xx/test/host/host_helper.h +++ b/tests/lpc18xx_43xx/test/host/host_helper.h @@ -41,7 +41,7 @@ #include "host/usbh_hcd.h" static inline void helper_class_init_expect(void) -{ +{ // class code number order #if TUSB_CFG_HOST_CDC cdch_init_Expect(); #endif @@ -50,22 +50,20 @@ static inline void helper_class_init_expect(void) hidh_init_Expect(); #endif - //TODO update more classes -} +#if TUSB_CFG_HOST_MSC + msch_init_Expect(); +#endif -static inline void helper_class_close_expect(uint8_t dev_addr) -{ - hidh_close_Expect(dev_addr); //TODO update more classes } - static inline void helper_usbh_init_expect(void) { - osal_semaphore_create_IgnoreAndReturn( (osal_semaphore_handle_t) 0x1234); osal_queue_create_IgnoreAndReturn( (osal_queue_handle_t) 0x4566 ); osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE); + + osal_semaphore_create_IgnoreAndReturn( (osal_semaphore_handle_t) 0x1234); osal_mutex_create_IgnoreAndReturn((osal_mutex_handle_t) 0x789a); } diff --git a/tests/lpc18xx_43xx/test/host/msc/msch_callback.h b/tests/lpc18xx_43xx/test/host/msc/msch_callback.h new file mode 100644 index 000000000..b91db23fe --- /dev/null +++ b/tests/lpc18xx_43xx/test/host/msc/msch_callback.h @@ -0,0 +1,66 @@ +/**************************************************************************/ +/*! + @file msch_callback.h + @author hathach (tinyusb.org) + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2013, hathach (tinyusb.org) + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + This file is part of the tinyusb stack. +*/ +/**************************************************************************/ + +/** \ingroup TBD + * \defgroup TBD + * \brief TBD + * + * @{ + */ + +#ifndef _TUSB_MSCH_CALLBACK_H_ +#define _TUSB_MSCH_CALLBACK_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#include "common/common.h" + +void tusbh_msc_mounted_cb(uint8_t dev_addr); +void tusbh_msc_unmounted_isr(uint8_t dev_addr); +void tusbh_msc_isr(uint8_t dev_addr, tusb_event_t event); + + +#ifdef __cplusplus + } +#endif + +#endif /* _TUSB_MSCH_CALLBACK_H_ */ + +/** @} */ diff --git a/tests/lpc18xx_43xx/test/host/msc/test_msc_host.c b/tests/lpc18xx_43xx/test/host/msc/test_msc_host.c index 4e42b3023..75a7549d5 100644 --- a/tests/lpc18xx_43xx/test/host/msc/test_msc_host.c +++ b/tests/lpc18xx_43xx/test/host/msc/test_msc_host.c @@ -43,21 +43,108 @@ #include "binary.h" #include "type_helper.h" -//#include "descriptor_test.h" -//#include "msc_host.h" -//#include "usbh.h" -//#include "hcd.h" -//#include "ehci.h" +#include "descriptor_test.h" +#include "mock_osal.h" +#include "mock_hcd.h" +#include "mock_usbh.h" + +#include "mock_msch_callback.h" +#include "msc_host.h" + +extern msch_interface_t msch_data[TUSB_CFG_HOST_DEVICE_MAX]; + +static tusb_descriptor_interface_t const *p_msc_interface_desc = &desc_configuration.msc_interface; +static tusb_descriptor_endpoint_t const *p_edp_in = &desc_configuration.msc_endpoint_in; +static tusb_descriptor_endpoint_t const *p_edp_out = &desc_configuration.msc_endpoint_out; + +static msch_interface_t* p_msc; + +static uint8_t dev_addr; +static pipe_handle_t pipe_in, pipe_out; +static pipe_handle_t const pipe_null = { 0 }; +static uint16_t length; void setUp(void) { + dev_addr = RANDOM(TUSB_CFG_HOST_DEVICE_MAX)+1; + + msch_init(); + TEST_ASSERT_MEM_ZERO(msch_data, sizeof(msch_interface_t)*TUSB_CFG_HOST_DEVICE_MAX); + + p_msc = &msch_data[dev_addr-1]; + pipe_in = (pipe_handle_t) {.dev_addr = dev_addr, .xfer_type = TUSB_XFER_BULK, .index = 1}; + pipe_out = (pipe_handle_t) {.dev_addr = dev_addr, .xfer_type = TUSB_XFER_BULK, .index = 2}; } void tearDown(void) { + length = 0; +} + +void test_open_pipe_in_failed(void) +{ + hcd_pipe_open_ExpectAndReturn(dev_addr, p_edp_in, TUSB_CLASS_MSC, pipe_null); + + TEST_ASSERT_EQUAL(TUSB_ERROR_HCD_OPEN_PIPE_FAILED, msch_open_subtask(dev_addr, p_msc_interface_desc, &length)); +} + +void test_open_pipe_out_failed(void) +{ + hcd_pipe_open_ExpectAndReturn(dev_addr, p_edp_in, TUSB_CLASS_MSC, (pipe_handle_t) {1} ); + hcd_pipe_open_ExpectAndReturn(dev_addr, p_edp_out, TUSB_CLASS_MSC, pipe_null); + + TEST_ASSERT_EQUAL(TUSB_ERROR_HCD_OPEN_PIPE_FAILED, msch_open_subtask(dev_addr, p_msc_interface_desc, &length)); +} + +tusb_error_t stub_control_xfer(uint8_t dev_addr, uint8_t bmRequestType, uint8_t bRequest, + uint16_t wValue, uint16_t wIndex, uint16_t wLength, uint8_t* data, int num_call) +{ + switch ( num_call ) + { + case 0: // get max lun + TEST_ASSERT_EQUAL(bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_INTERFACE), + bmRequestType); + TEST_ASSERT_EQUAL(MSC_REQUEST_GET_MAX_LUN, bRequest); + TEST_ASSERT_EQUAL(p_msc_interface_desc->bInterfaceNumber, wIndex); + TEST_ASSERT_EQUAL(1, wLength); + *data = 1; // TODO multiple LUN support + break; + + default: + TEST_FAIL(); + return TUSB_ERROR_FAILED; + } + + return TUSB_ERROR_NONE; } -void test_() +void test_open_desc_length(void) { - // TEST_IGNORE(); + hcd_pipe_open_ExpectAndReturn(dev_addr, p_edp_in, TUSB_CLASS_MSC, pipe_in); + hcd_pipe_open_ExpectAndReturn(dev_addr, p_edp_out, TUSB_CLASS_MSC, pipe_out); + + usbh_control_xfer_subtask_IgnoreAndReturn(TUSB_ERROR_NONE); + hcd_pipe_xfer_IgnoreAndReturn(TUSB_ERROR_NONE); + hcd_pipe_queue_xfer_IgnoreAndReturn(TUSB_ERROR_NONE); + + //------------- Code Under Test -------------// + TEST_ASSERT_STATUS( msch_open_subtask(dev_addr, p_msc_interface_desc, &length) ); + + TEST_ASSERT_EQUAL(sizeof(tusb_descriptor_interface_t) + 2*sizeof(tusb_descriptor_endpoint_t), + length); } + +void test_open_ok(void) +{ + hcd_pipe_open_ExpectAndReturn(dev_addr, p_edp_in, TUSB_CLASS_MSC, pipe_in); + hcd_pipe_open_ExpectAndReturn(dev_addr, p_edp_out, TUSB_CLASS_MSC, pipe_out); + + //------------- get max lun -------------// + usbh_control_xfer_subtask_StubWithCallback(stub_control_xfer); + + //------------- Code Under Test -------------// + TEST_ASSERT_STATUS( msch_open_subtask(dev_addr, p_msc_interface_desc, &length) ); + + TEST_ASSERT_EQUAL(p_msc_interface_desc->bInterfaceNumber, p_msc->interface_number); +} + diff --git a/tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c b/tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c index b036084d3..5d658449f 100644 --- a/tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c +++ b/tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c @@ -48,6 +48,7 @@ #include "mock_tusb_callback.h" #include "mock_hid_host.h" #include "mock_cdc_host.h" +#include "mock_msc_host.h" extern usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; extern uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE]; @@ -177,12 +178,31 @@ tusb_error_t control_xfer_stub(uint8_t dev_addr, const tusb_control_request_t * return TUSB_ERROR_NONE; } -tusb_error_t hidh_install_stub(uint8_t dev_addr, tusb_descriptor_interface_t const *descriptor, uint16_t *p_length, int num_call) +tusb_error_t stub_hidh_open(uint8_t dev_addr, tusb_descriptor_interface_t const *descriptor, uint16_t *p_length, int num_call) { *p_length = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t); return TUSB_ERROR_NONE; } +tusb_error_t stub_msch_open(uint8_t dev_addr, tusb_descriptor_interface_t const *descriptor, uint16_t *p_length, int num_call) +{ + *p_length = sizeof(tusb_descriptor_interface_t) + 2*sizeof(tusb_descriptor_endpoint_t); + return TUSB_ERROR_NONE; +} + +tusb_error_t stub_cdch_open(uint8_t dev_addr, tusb_descriptor_interface_t const *descriptor, uint16_t *p_length, int num_call) +{ + *p_length = + //------------- Comm Interface -------------// + sizeof(tusb_descriptor_interface_t) + sizeof(cdc_desc_func_header_t) + + sizeof(cdc_desc_func_abstract_control_management_t) + sizeof(cdc_desc_func_union_t) + + sizeof(tusb_descriptor_endpoint_t) + + //------------- Data Interface -------------// + sizeof(tusb_descriptor_interface_t) + 2*sizeof(tusb_descriptor_endpoint_t); + + return TUSB_ERROR_NONE; +} + //--------------------------------------------------------------------+ // enumeration //--------------------------------------------------------------------+ @@ -264,11 +284,6 @@ void test_enum_failed_get_full_config_desc(void) usbh_enumeration_task(NULL); } -void class_install_expect(void) -{ - hidh_open_subtask_StubWithCallback(hidh_install_stub); -} - void test_enum_parse_config_desc(void) { osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(5)); @@ -295,11 +310,16 @@ void test_enum_set_configure(void) osal_mutex_reset_Expect( usbh_devices[0].control.mutex_hdl ); hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE); tusbh_device_attached_cb_ExpectAndReturn((tusb_descriptor_device_t*) enum_data_buffer, 1); - class_install_expect(); + + // class open TODO more class expect + hidh_open_subtask_StubWithCallback(stub_hidh_open); + msch_open_subtask_StubWithCallback(stub_msch_open); + cdch_open_subtask_StubWithCallback(stub_cdch_open); tusbh_device_mount_succeed_cb_Expect(1); usbh_enumeration_task(NULL); - TEST_ASSERT_EQUAL(TUSB_CLASS_FLAG_HID, usbh_devices[1].flag_supported_class); // TODO change later + TEST_ASSERT_EQUAL(TUSB_CLASS_FLAG_HID | TUSB_CLASS_FLAG_MSC | TUSB_CLASS_FLAG_CDC, + usbh_devices[1].flag_supported_class); // TODO change later } diff --git a/tests/support/descriptor_test.c b/tests/support/descriptor_test.c index 725baa841..e8daadb91 100644 --- a/tests/support/descriptor_test.c +++ b/tests/support/descriptor_test.c @@ -151,7 +151,7 @@ const app_configuration_desc_t desc_configuration = .bDescriptorType = TUSB_DESC_TYPE_CONFIGURATION, .wTotalLength = sizeof(app_configuration_desc_t) - 1, // exclude termination - .bNumInterfaces = 3, + .bNumInterfaces = 5, .bConfigurationValue = 1, .iConfiguration = 0x00, @@ -263,5 +263,92 @@ const app_configuration_desc_t desc_configuration = .bInterval = 1 }, + //------------- CDC Serial -------------// + .cdc_comm_interface = + { + .bLength = sizeof(tusb_descriptor_interface_t), + .bDescriptorType = TUSB_DESC_TYPE_INTERFACE, + .bInterfaceNumber = 4, + .bAlternateSetting = 0, + .bNumEndpoints = 1, + .bInterfaceClass = TUSB_CLASS_CDC, + .bInterfaceSubClass = CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL, + .bInterfaceProtocol = CDC_COMM_PROTOCOL_ATCOMMAND, + .iInterface = 0x00 + }, + + .cdc_header = + { + .bLength = sizeof(cdc_desc_func_header_t), + .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC, + .bDescriptorSubType = CDC_FUNC_DESC_HEADER, + .bcdCDC = 0x0120 + }, + + .cdc_acm = + { + .bLength = sizeof(cdc_desc_func_abstract_control_management_t), + .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC, + .bDescriptorSubType = CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT, + .bmCapabilities = { // 0x06 + .support_line_request = 1, + .support_send_break = 1 + } + }, + + .cdc_union = + { + .bLength = sizeof(cdc_desc_func_union_t), // plus number of + .bDescriptorType = TUSB_DESC_TYPE_INTERFACE_CLASS_SPECIFIC, + .bDescriptorSubType = CDC_FUNC_DESC_UNION, + .bControlInterface = 1, + .bSubordinateInterface = 2, + }, + + .cdc_endpoint_notification = + { + .bLength = sizeof(tusb_descriptor_endpoint_t), + .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT, + .bEndpointAddress = 0x84, + .bmAttributes = { .xfer = TUSB_XFER_INTERRUPT }, + .wMaxPacketSize = 8, + .bInterval = 0x0a // lowest polling rate + }, + + //------------- CDC Data Interface -------------// + .cdc_data_interface = + { + .bLength = sizeof(tusb_descriptor_interface_t), + .bDescriptorType = TUSB_DESC_TYPE_INTERFACE, + .bInterfaceNumber = 5, + .bAlternateSetting = 0x00, + .bNumEndpoints = 2, + .bInterfaceClass = TUSB_CLASS_CDC_DATA, + .bInterfaceSubClass = 0, + .bInterfaceProtocol = 0, + .iInterface = 0x00 + }, + + .cdc_endpoint_out = + { + .bLength = sizeof(tusb_descriptor_endpoint_t), + .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT, + .bEndpointAddress = 5, + .bmAttributes = { .xfer = TUSB_XFER_BULK }, + .wMaxPacketSize = 64, + .bInterval = 0 + }, + + .cdc_endpoint_in = + { + .bLength = sizeof(tusb_descriptor_endpoint_t), + .bDescriptorType = TUSB_DESC_TYPE_ENDPOINT, + .bEndpointAddress = 0x85, + .bmAttributes = { .xfer = TUSB_XFER_BULK }, + .wMaxPacketSize = 64, + .bInterval = 0 + }, + + // TODO CDC & RNDIS .ConfigDescTermination = 0, }; diff --git a/tests/support/descriptor_test.h b/tests/support/descriptor_test.h index 39d23e2c1..a452d95ef 100644 --- a/tests/support/descriptor_test.h +++ b/tests/support/descriptor_test.h @@ -59,6 +59,7 @@ #include "common/common.h" #include "class/hid.h" #include "class/msc.h" +#include "class/cdc.h" typedef struct { @@ -98,6 +99,20 @@ typedef struct tusb_descriptor_endpoint_t msc_endpoint_in; tusb_descriptor_endpoint_t msc_endpoint_out; + //------------- CDC Serial -------------// + //CDC Control Interface + tusb_descriptor_interface_t cdc_comm_interface; + cdc_desc_func_header_t cdc_header; + cdc_desc_func_abstract_control_management_t cdc_acm; + cdc_desc_func_union_t cdc_union; + tusb_descriptor_endpoint_t cdc_endpoint_notification; + + //CDC Data Interface + tusb_descriptor_interface_t cdc_data_interface; + tusb_descriptor_endpoint_t cdc_endpoint_out; + tusb_descriptor_endpoint_t cdc_endpoint_in; + + unsigned char ConfigDescTermination; } app_configuration_desc_t; diff --git a/tests/support/tusb_config.h b/tests/support/tusb_config.h index e9c7b92a4..320b32222 100644 --- a/tests/support/tusb_config.h +++ b/tests/support/tusb_config.h @@ -74,6 +74,7 @@ //------------- CLASS -------------// #define TUSB_CFG_HOST_HID_KEYBOARD 1 #define TUSB_CFG_HOST_HID_MOUSE 1 +#define TUSB_CFG_HOST_MSC 1 #define TUSB_CFG_HOST_CDC 1 #define TUSB_CFG_HOST_CDC_RNDIS 1 |
