diff --git a/tests/test/host/msc/test_msc_host.c b/tests/test/host/msc/test_msc_host.c index 9a1459306..4e42b3023 100644 --- a/tests/test/host/msc/test_msc_host.c +++ b/tests/test/host/msc/test_msc_host.c @@ -43,6 +43,12 @@ #include "binary.h" #include "type_helper.h" +//#include "descriptor_test.h" +//#include "msc_host.h" +//#include "usbh.h" +//#include "hcd.h" +//#include "ehci.h" + void setUp(void) { } diff --git a/tests/test/host/usbh/test_usbh.c b/tests/test/host/usbh/test_usbh.c index 6964ab9cb..4f5d7082c 100644 --- a/tests/test/host/usbh/test_usbh.c +++ b/tests/test/host/usbh/test_usbh.c @@ -121,7 +121,7 @@ void class_init_expect(void) void test_usbh_init_ok(void) { - osal_queue_handle_t dummy = 0x1122; + osal_queue_handle_t q_hdl_dummy = 0x1122; usbh_device_info_t device_info_zero[TUSB_CFG_HOST_DEVICE_MAX+1]; memclr_(device_info_zero, sizeof(usbh_device_info_t)*(TUSB_CFG_HOST_DEVICE_MAX+1)); @@ -136,7 +136,7 @@ void test_usbh_init_ok(void) } osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE); - osal_queue_create_IgnoreAndReturn(dummy); + osal_queue_create_IgnoreAndReturn(q_hdl_dummy); class_init_expect(); diff --git a/tests/test/support/descriptor_test.c b/tests/test/support/descriptor_test.c index 030ffa38e..02d2ba527 100644 --- a/tests/test/support/descriptor_test.c +++ b/tests/test/support/descriptor_test.c @@ -61,7 +61,7 @@ tusb_descriptor_device_t const desc_device = .bNumConfigurations = 0x02 } ; -// + TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4) const uint8_t keyboard_report_descriptor[] = { HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ), @@ -227,6 +227,39 @@ const app_configuration_desc_t desc_configuration = .bInterval = 0x0A }, + //------------- Mass Storage -------------// + .msc_interface = + { + .bLength = sizeof(tusb_descriptor_interface_t), + .bDescriptorType = TUSB_DESC_INTERFACE, + .bInterfaceNumber = 3, + .bAlternateSetting = 0x00, + .bNumEndpoints = 2, + .bInterfaceClass = TUSB_CLASS_MSC, + .bInterfaceSubClass = MSC_SUBCLASS_SCSI, + .bInterfaceProtocol = MSC_PROTOCOL_BOT, + .iInterface = 0x00 + }, + + .msc_endpoint_in = + { + .bLength = sizeof(tusb_descriptor_endpoint_t), + .bDescriptorType = TUSB_DESC_ENDPOINT, + .bEndpointAddress = 0x83, + .bmAttributes = { .xfer = TUSB_XFER_BULK }, + .wMaxPacketSize = 512, + .bInterval = 1 + }, + + .msc_endpoint_out = + { + .bLength = sizeof(tusb_descriptor_endpoint_t), + .bDescriptorType = TUSB_DESC_ENDPOINT, + .bEndpointAddress = 0x03, + .bmAttributes = { .xfer = TUSB_XFER_BULK }, + .wMaxPacketSize = 512, + .bInterval = 1 + }, .ConfigDescTermination = 0, }; diff --git a/tests/test/support/descriptor_test.h b/tests/test/support/descriptor_test.h index 4ad116e93..39d23e2c1 100644 --- a/tests/test/support/descriptor_test.h +++ b/tests/test/support/descriptor_test.h @@ -58,6 +58,7 @@ #include "common/common.h" #include "class/hid.h" +#include "class/msc.h" typedef struct { @@ -92,6 +93,11 @@ typedef struct tusb_hid_descriptor_hid_t mouse_hid; tusb_descriptor_endpoint_t mouse_endpoint; + //------------- Mass Storage -------------// + tusb_descriptor_interface_t msc_interface; + tusb_descriptor_endpoint_t msc_endpoint_in; + tusb_descriptor_endpoint_t msc_endpoint_out; + unsigned char ConfigDescTermination; } app_configuration_desc_t; diff --git a/tests/test/support/ehci_controller.c b/tests/test/support/ehci_controller.c index 03d63a207..a29f4d6be 100644 --- a/tests/test/support/ehci_controller.c +++ b/tests/test/support/ehci_controller.c @@ -40,12 +40,10 @@ // INCLUDE //--------------------------------------------------------------------+ #include "unity.h" -#include "tusb_option.h" -#include "errors.h" -#include "binary.h" +#include "common/common.h" #include "hal.h" -#include "ehci.h" #include "usbh_hcd.h" +#include "ehci.h" //--------------------------------------------------------------------+ diff --git a/tests/test/support/test_template.c b/tests/test/support/test_template.c deleted file mode 100644 index 5e25c22b7..000000000 --- a/tests/test/support/test_template.c +++ /dev/null @@ -1,53 +0,0 @@ -/**************************************************************************/ -/*! - @file test_template.c - @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. -*/ -/**************************************************************************/ - -#include "unity.h" - -void setUp(void) -{ -} - -void tearDown(void) -{ -} - -void test_() -{ - // TEST_IGNORE(); -} - diff --git a/tinyusb/class/hid.h b/tinyusb/class/hid.h index c526ab2b4..cf70f66aa 100644 --- a/tinyusb/class/hid.h +++ b/tinyusb/class/hid.h @@ -46,12 +46,12 @@ #ifndef _TUSB_HID_H_ #define _TUSB_HID_H_ +#include "common/common.h" + #ifdef __cplusplus extern "C" { #endif -#include "common/common.h" - enum { HID_SUBCLASS_NONE = 0, HID_SUBCLASS_BOOT = 1 diff --git a/tinyusb/class/msc.h b/tinyusb/class/msc.h index ad9f46c4b..53e2e93df 100644 --- a/tinyusb/class/msc.h +++ b/tinyusb/class/msc.h @@ -52,6 +52,26 @@ extern "C" { #endif +//--------------------------------------------------------------------+ +// USB Class Constant +//--------------------------------------------------------------------+ +enum { + MSC_SUBCLASS_RBC = 1 , + MSC_SUBCLASS_SFF_MMC , + MSC_SUBCLASS_QIC , + MSC_SUBCLASS_UFI , + MSC_SUBCLASS_SFF , + MSC_SUBCLASS_SCSI +}; + +// CBI only approved to use with full-speed floopy disk & should not used with highspeed or device other than floopy +enum { + MSC_PROTOCOL_CBI = 0, + MSC_PROTOCOL_CBI_NO_INTERRUPT = 1, + MSC_PROTOCOL_BOT = 0x50 +}; + + //--------------------------------------------------------------------+ // SCSI Primary Command (SPC-4) //--------------------------------------------------------------------+ diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index 43dae3235..21c457c17 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -533,11 +533,12 @@ void async_list_process_isr(ehci_qhd_t * const async_head) void period_list_process_isr(uint8_t hostid, uint8_t interval_ms) { uint8_t max_loop = 0; + uint32_t const period_1ms_addr = (uint32_t) get_period_head(hostid, 1); ehci_link_t next_item = * get_period_head(hostid, interval_ms); // TODO abstract max loop guard for period while( !next_item.terminate && - !(interval_ms > 1 && align32(next_item.address) == (uint32_t) get_period_head(hostid, 1)) && + !(interval_ms > 1 && period_1ms_addr == align32(next_item.address)) && max_loop < (EHCI_MAX_QHD + EHCI_MAX_ITD + EHCI_MAX_SITD)) { switch ( next_item.type ) diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index cda5418ff..28c114e1e 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -243,7 +243,7 @@ void usbh_device_unplugged_isr(uint8_t hostid) usbh_class_drivers[class_code].close) { usbh_class_drivers[class_code].close(dev_addr); - } + } } } diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h index 176342809..e542e519a 100644 --- a/tinyusb/osal/osal_none.h +++ b/tinyusb/osal/osal_none.h @@ -147,7 +147,7 @@ static inline volatile uint32_t osal_tick_get(void) #define SUBTASK_ASSERT(condition) \ ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, , , \ (condition), TUSB_ERROR_OSAL_TASK_FAILED, "%s", "evaluated to false") - +// TODO remove assert with handler by catching error in enum main task #define SUBTASK_ASSERT_WITH_HANDLER(condition, func_call) \ ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, ,\ condition, TUSB_ERROR_OSAL_TASK_FAILED, "%s", "evaluated to false") diff --git a/todo.md b/todo.md index 7cd4e36ae..af6e2b6f2 100644 --- a/todo.md +++ b/todo.md @@ -1,5 +1,8 @@ # TODO # -- [ ] display SHA commit on demo -- [ ] guideline for create a new issue -- [ ] make some doxygen documentation +- display SHA commit on demo +- guideline for create a new issue +- make some doxygen documentation +- reporter task to move callback out of isr +- test freeRTOS +- refractor for integration test