added dcd_dma_descriptor_t typdef

reorganize test project, multiple test projects each is specifically for an MCU
This commit is contained in:
hathach
2013-06-05 11:23:41 +07:00
parent 6fb34f0e7a
commit f69fefefa9
45 changed files with 190 additions and 89 deletions
+1
View File
@@ -0,0 +1 @@
just a build folder
+91
View File
@@ -0,0 +1,91 @@
---
# Notes:
# Sample project C code is not presently written to produce a release artifact.
# As such, release build options are disabled.
# This sample, therefore, only demonstrates running a collection of unit tests.
:project:
:use_exceptions: TRUE
:use_test_preprocessor: TRUE
:use_auxiliary_dependencies: TRUE
:use_deep_dependencies: TRUE
:build_root: build
# :release_build: TRUE
:test_file_prefix: test_
:release_build:
:output: test_tinyusb.exe
:use_assembly: FALSE
:environment:
:extension:
:executable: .exe
:paths:
:test:
- +:test/**
:source:
- ../../tinyusb/**
- +:../../demos/bsp/lpc43xx/**
- +:../../demos/device/keyboard/*
- -:../../demos/
- ../../vendor/freertos/freertos/Source/*
- ../../vendor/freertos/freertos/Source/portable/MSVC-MingW/*
:support:
- ../support
:defines:
# in order to add common defines:
# 1) remove the trailing [] from the :common: section
# 2) add entries to the :common: section (e.g. :test: has TEST defined)
:commmon: &common_defines
- MCU=MCU_LPC43XX -std=gnu99
# - -mx32
- CORE_M4
- __CODE_RED
- _TINY_USB_SOURCE_FILE_
- _TEST_
:test:
- *common_defines
:test_preprocess:
- *common_defines
# :release:
# :release_preprocess:
#:flags:
# :test:
# :compile:
# :dcd_lpc175x_6x.c:
# - -DMCU=MCU_LPC175X_6X
# Ceedling defaults to using gcc for compiling, linking, etc.
# As [:tools] is blank, gcc will be used (so long as it's in your system path)
# See documentation to configure a given toolchain for use
:cmock:
:mock_prefix: mock_
:when_no_prototypes: :warn
:enforce_strict_ordering: TRUE
:plugins:
- :ignore
- :callback
- :array
#:ignore: :args_only
:treat_as:
uint8: HEX8
uint16: HEX16
uint32: UINT32
int8: INT8
bool: UINT8
:plugins:
:load_paths:
- ../vendor/ceedling/plugins
:enabled:
#- stdout_pretty_tests_report
- stdout_ide_tests_report
- module_generator
...
+4
View File
@@ -0,0 +1,4 @@
PROJECT_CEEDLING_ROOT = "../vendor/ceedling"
load "#{PROJECT_CEEDLING_ROOT}/lib/rakefile.rb"
task :default => %w[ test:all release ]
-132
View File
@@ -1,132 +0,0 @@
/*
FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.
FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
***************************************************************************
* *
* FreeRTOS tutorial books are available in pdf and paperback. *
* Complete, revised, and edited pdf reference manuals are also *
* available. *
* *
* Purchasing FreeRTOS documentation will not only help you, by *
* ensuring you get running as quickly as possible and with an *
* in-depth knowledge of how to use FreeRTOS, it will also help *
* the FreeRTOS project to continue with its mission of providing *
* professional grade, cross platform, de facto standard solutions *
* for microcontrollers - completely free of charge! *
* *
* >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
* *
* Thank you for using FreeRTOS, and thank you for your support! *
* *
***************************************************************************
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
>>>NOTE<<< The modification to the GPL is included to allow you to
distribute a combined work that includes FreeRTOS without being obliged to
provide the source code for proprietary components outside of the FreeRTOS
kernel. FreeRTOS is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details. You should have received a copy of the GNU General Public
License and the FreeRTOS license exception along with FreeRTOS; if not it
can be viewed here: http://www.freertos.org/a00114.html and also obtained
by writing to Richard Barry, contact details for whom are available on the
FreeRTOS WEB site.
1 tab == 4 spaces!
***************************************************************************
* *
* Having a problem? Start by reading the FAQ "My application does *
* not run, what could be wrong?" *
* *
* http://www.FreeRTOS.org/FAQHelp.html *
* *
***************************************************************************
http://www.FreeRTOS.org - Documentation, training, latest versions, license
and contact details.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool.
Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
the code with commercial support, indemnification, and middleware, under
the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
provide a safety engineered and independently SIL3 certified version under
the SafeRTOS brand: http://www.SafeRTOS.com.
*/
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
/*
* The following #error directive is to remind users that a batch file must be
* executed prior to this project being built. The batch file *cannot* be
* executed from within the IDE! Once it has been executed, re-open or refresh
* the Eclipse project and remove the #error line below.
*/
//#error Ensure CreateProjectDirectoryStructure.bat has been executed before building. See comment immediately above.
/*-----------------------------------------------------------
* Application specific definitions.
*
* These definitions should be adjusted for your particular hardware and
* application requirements.
*
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
*----------------------------------------------------------*/
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0
#define configTICK_RATE_HZ ( 50 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 20 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */
#define configTOTAL_HEAP_SIZE ( ( size_t ) 0 ) /* This parameter has no effect when heap_3.c is included in the project. */
#define configMAX_TASK_NAME_LEN ( 12 )
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_CO_ROUTINES 0
#define configUSE_MUTEXES 1
#define configGENERATE_RUN_TIME_STATS 0
#define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_RECURSIVE_MUTEXES 1
#define configQUEUE_REGISTRY_SIZE 0
#define configUSE_MALLOC_FAILED_HOOK 1
#define configUSE_APPLICATION_TASK_TAG 0
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 7 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
#define INCLUDE_xTaskGetSchedulerState 1
#endif /* FREERTOS_CONFIG_H */
File diff suppressed because it is too large Load Diff
-267
View File
@@ -1,267 +0,0 @@
/**************************************************************************/
/*!
@file descriptor_test.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 "tusb_option.h"
#include "descriptor_test.h"
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
const uint8_t keyboard_report_descriptor[] = {
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
HID_USAGE ( HID_USAGE_DESKTOP_KEYBOARD ),
HID_COLLECTION ( HID_COLLECTION_APPLICATION ),
HID_USAGE_PAGE ( HID_USAGE_PAGE_KEYBOARD ),
HID_USAGE_MIN ( 224 ),
HID_USAGE_MAX ( 231 ),
HID_LOGICAL_MIN ( 0 ),
HID_LOGICAL_MAX ( 1 ),
HID_REPORT_COUNT ( 8 ), /* 8 bits */
HID_REPORT_SIZE ( 1 ),
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), /* maskable modifier key */
HID_REPORT_COUNT ( 1 ),
HID_REPORT_SIZE ( 8 ),
HID_INPUT ( HID_CONSTANT ), /* reserved */
HID_USAGE_PAGE ( HID_USAGE_PAGE_LED ),
HID_USAGE_MIN ( 1 ),
HID_USAGE_MAX ( 5 ),
HID_REPORT_COUNT ( 5 ),
HID_REPORT_SIZE ( 1 ),
HID_OUTPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ), /* 5-bit Led report */
HID_REPORT_COUNT ( 1 ),
HID_REPORT_SIZE ( 3 ), /* led padding */
HID_OUTPUT ( HID_CONSTANT ),
HID_USAGE_PAGE (HID_USAGE_PAGE_KEYBOARD),
HID_USAGE_MIN ( 0 ),
HID_USAGE_MAX ( 101 ),
HID_LOGICAL_MIN ( 0 ),
HID_LOGICAL_MAX ( 101 ),
HID_REPORT_COUNT ( 6 ),
HID_REPORT_SIZE ( 8 ),
HID_INPUT ( HID_DATA | HID_ARRAY | HID_ABSOLUTE ), /* keycodes array 6 items */
HID_COLLECTION_END
};
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
const uint8_t mouse_report_descriptor[] = {
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
HID_USAGE ( HID_USAGE_DESKTOP_MOUSE ),
HID_COLLECTION ( HID_COLLECTION_APPLICATION ),
HID_USAGE (HID_USAGE_DESKTOP_POINTER),
HID_COLLECTION ( HID_COLLECTION_PHYSICAL ),
HID_USAGE_PAGE ( HID_USAGE_PAGE_BUTTON ),
HID_USAGE_MIN ( 1 ),
HID_USAGE_MAX ( 3 ),
HID_LOGICAL_MIN ( 0 ),
HID_LOGICAL_MAX ( 1 ),
HID_REPORT_COUNT ( 3 ), /* Left, Right and Middle mouse*/
HID_REPORT_SIZE ( 1 ),
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ),
HID_REPORT_COUNT ( 1 ),
HID_REPORT_SIZE ( 5 ),
HID_INPUT ( HID_CONSTANT ), /* reserved */
HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP ),
HID_USAGE ( HID_USAGE_DESKTOP_X ),
HID_USAGE ( HID_USAGE_DESKTOP_Y ),
HID_LOGICAL_MIN ( 0x81 ), /* -127 */
HID_LOGICAL_MAX ( 0x7f ), /* 127 */
HID_REPORT_COUNT ( 2 ), /* X, Y position */
HID_REPORT_SIZE ( 8 ),
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), /* relative values */
HID_COLLECTION_END,
HID_COLLECTION_END
};
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
tusb_descriptor_device_t const desc_device =
{
.bLength = sizeof(tusb_descriptor_device_t),
.bDescriptorType = TUSB_DESC_TYPE_DEVICE,
.bcdUSB = 0x0200,
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
.bMaxPacketSize0 = 64,
.idVendor = 0x1FC9,
.idProduct = 0x4000,
.bcdDevice = 0x0100,
.iManufacturer = 0x01,
.iProduct = 0x02,
.iSerialNumber = 0x03,
.bNumConfigurations = 0x02
} ;
TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4)
const app_configuration_desc_t desc_configuration =
{
.configuration =
{
.bLength = sizeof(tusb_descriptor_configuration_t),
.bDescriptorType = TUSB_DESC_TYPE_CONFIGURATION,
.wTotalLength = sizeof(app_configuration_desc_t) - 1, // exclude termination
.bNumInterfaces = 1,
.bConfigurationValue = 1,
.iConfiguration = 0x00,
.bmAttributes = TUSB_DESC_CONFIG_ATT_BUS_POWER,
.bMaxPower = TUSB_DESC_CONFIG_POWER_MA(100)
},
//------------- HID Keyboard -------------//
.keyboard_interface =
{
.bLength = sizeof(tusb_descriptor_interface_t),
.bDescriptorType = TUSB_DESC_TYPE_INTERFACE,
.bInterfaceNumber = 1,
.bAlternateSetting = 0x00,
.bNumEndpoints = 1,
.bInterfaceClass = TUSB_CLASS_HID,
.bInterfaceSubClass = HID_SUBCLASS_BOOT,
.bInterfaceProtocol = HID_PROTOCOL_KEYBOARD,
.iInterface = 0x00
},
.keyboard_hid =
{
.bLength = sizeof(tusb_hid_descriptor_hid_t),
.bDescriptorType = HID_DESC_TYPE_HID,
.bcdHID = 0x0111,
.bCountryCode = HID_Local_NotSupported,
.bNumDescriptors = 1,
.bReportType = HID_DESC_TYPE_REPORT,
.wReportLength = sizeof(keyboard_report_descriptor)
},
.keyboard_endpoint =
{
.bLength = sizeof(tusb_descriptor_endpoint_t),
.bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
.bEndpointAddress = 0x81,
.bmAttributes = { .xfer = TUSB_XFER_INTERRUPT },
.wMaxPacketSize = 0x08,
.bInterval = 0x0A
},
//------------- HID Mouse -------------//
.mouse_interface =
{
.bLength = sizeof(tusb_descriptor_interface_t),
.bDescriptorType = TUSB_DESC_TYPE_INTERFACE,
.bInterfaceNumber = 2,
.bAlternateSetting = 0x00,
.bNumEndpoints = 1,
.bInterfaceClass = TUSB_CLASS_HID,
.bInterfaceSubClass = HID_SUBCLASS_BOOT,
.bInterfaceProtocol = HID_PROTOCOL_MOUSE,
.iInterface = 0x00
},
.mouse_hid =
{
.bLength = sizeof(tusb_hid_descriptor_hid_t),
.bDescriptorType = HID_DESC_TYPE_HID,
.bcdHID = 0x0111,
.bCountryCode = HID_Local_NotSupported,
.bNumDescriptors = 1,
.bReportType = HID_DESC_TYPE_REPORT,
.wReportLength = sizeof(mouse_report_descriptor)
},
.mouse_endpoint =
{
.bLength = sizeof(tusb_descriptor_endpoint_t),
.bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
.bEndpointAddress = 0x82,
.bmAttributes = { .xfer = TUSB_XFER_INTERRUPT },
.wMaxPacketSize = 0x08,
.bInterval = 0x0A
},
//------------- Mass Storage -------------//
.msc_interface =
{
.bLength = sizeof(tusb_descriptor_interface_t),
.bDescriptorType = TUSB_DESC_TYPE_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_TYPE_ENDPOINT,
.bEndpointAddress = 0x83,
.bmAttributes = { .xfer = TUSB_XFER_BULK },
.wMaxPacketSize = 512,
.bInterval = 1
},
.msc_endpoint_out =
{
.bLength = sizeof(tusb_descriptor_endpoint_t),
.bDescriptorType = TUSB_DESC_TYPE_ENDPOINT,
.bEndpointAddress = 0x03,
.bmAttributes = { .xfer = TUSB_XFER_BULK },
.wMaxPacketSize = 512,
.bInterval = 1
},
.ConfigDescTermination = 0,
};
-114
View File
@@ -1,114 +0,0 @@
/**************************************************************************/
/*!
@file descriptor_test.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.
*/
/**************************************************************************/
/** \file
* \brief TBD
*
* \note TBD
*/
/** \ingroup TBD
* \defgroup TBD
* \brief TBD
*
* @{
*/
#ifndef _TUSB_TEST_DESCRIPTOR_H_
#define _TUSB_TEST_DESCRIPTOR_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "common/common.h"
#include "class/hid.h"
#include "class/msc.h"
typedef struct
{
tusb_descriptor_configuration_t configuration;
#if 0 //&& IAD_DESC_REQUIRED
tusb_descriptor_interface_association_t CDC_IAD;
#endif
#if 0 //&& TUSB_CFG_DEVICE_CDC
//CDC - Serial
//CDC Control Interface
tusb_descriptor_interface_t CDC_CCI_Interface;
CDC_HEADER_DESCRIPTOR CDC_Header;
CDC_ABSTRACT_CONTROL_MANAGEMENT_DESCRIPTOR CDC_ACM;
CDC_UNION_1SLAVE_DESCRIPTOR CDC_Union;
tusb_descriptor_endpoint_t CDC_NotificationEndpoint;
//CDC Data Interface
tusb_descriptor_interface_t CDC_DCI_Interface;
tusb_descriptor_endpoint_t CDC_DataOutEndpoint;
tusb_descriptor_endpoint_t CDC_DataInEndpoint;
#endif
//------------- HID Keyboard -------------//
tusb_descriptor_interface_t keyboard_interface;
tusb_hid_descriptor_hid_t keyboard_hid;
tusb_descriptor_endpoint_t keyboard_endpoint;
//------------- HID Mouse -------------//
tusb_descriptor_interface_t mouse_interface;
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;
extern tusb_descriptor_device_t const desc_device;
extern app_configuration_desc_t const desc_configuration;
extern const uint8_t keyboard_report_descriptor[];
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_TEST_DESCRIPTOR_H_ */
/** @} */
-195
View File
@@ -1,195 +0,0 @@
/**************************************************************************/
/*!
@file ehci_controller_fake.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
//--------------------------------------------------------------------+
#include "unity.h"
#include "common/common.h"
#include "hal.h"
#include "usbh_hcd.h"
#include "ehci.h"
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
LPC_USB0_Type lpc_usb0;
LPC_USB1_Type lpc_usb1;
extern usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
//--------------------------------------------------------------------+
// IMPLEMENTATION
//--------------------------------------------------------------------+
void ehci_controller_init(void)
{
memclr_(&lpc_usb0, sizeof(LPC_USB0_Type));
memclr_(&lpc_usb1, sizeof(LPC_USB1_Type));
}
void ehci_controller_control_xfer_proceed(uint8_t dev_addr, uint8_t p_data[])
{
ehci_registers_t* const regs = get_operational_register( usbh_devices[dev_addr].core_id );
ehci_qhd_t * p_qhd = get_control_qhd(dev_addr);
ehci_qtd_t * p_qtd_setup = get_control_qtds(dev_addr);
ehci_qtd_t * p_qtd_data = p_qtd_setup + 1;
ehci_qtd_t * p_qtd_status = p_qtd_setup + 2;
tusb_std_request_t const *p_request = (tusb_std_request_t *) p_qtd_setup->buffer[0];
if (p_request->wLength > 0 && p_request->bmRequestType.direction == TUSB_DIR_DEV_TO_HOST)
{
memcpy(p_qtd_data, p_data, p_request->wLength);
}
//------------- retire all QTDs -------------//
p_qtd_setup->active = p_qtd_data->active = p_qtd_status->active = 0;
p_qhd->qtd_overlay = *p_qtd_status;
regs->usb_sts = EHCI_INT_MASK_NXP_ASYNC | EHCI_INT_MASK_NXP_PERIODIC;
hcd_isr( usbh_devices[dev_addr].core_id );
}
void complete_qtd_in_qhd(ehci_qhd_t *p_qhd)
{
if ( !p_qhd->qtd_overlay.halted )
{
while(!p_qhd->qtd_overlay.next.terminate)
{
ehci_qtd_t* p_qtd = (ehci_qtd_t*) align32(p_qhd->qtd_overlay.next.address);
p_qtd->active = 0;
p_qhd->qtd_overlay = *p_qtd;
}
}
}
bool complete_all_qtd_in_async(ehci_qhd_t *head)
{
ehci_qhd_t *p_qhd = head;
do
{
complete_qtd_in_qhd(p_qhd);
p_qhd = (ehci_qhd_t*) align32(p_qhd->next.address);
}while(p_qhd != head); // stop if loop around
return true;
}
bool complete_all_qtd_in_period(ehci_link_t *head)
{
while(!head->terminate)
{
uint32_t queue_type = head->type;
head = (ehci_link_t*) align32(head->address);
if ( queue_type == EHCI_QUEUE_ELEMENT_QHD)
{
complete_qtd_in_qhd( (ehci_qhd_t*) head );
}
}
return true;
}
void ehci_controller_run(uint8_t hostid)
{
//------------- Async List -------------//
ehci_registers_t* const regs = get_operational_register(hostid);
complete_all_qtd_in_async((ehci_qhd_t*) regs->async_list_base);
//------------- Period List -------------//
for(uint8_t i=1; i <= EHCI_FRAMELIST_SIZE; i *= 2)
{
complete_all_qtd_in_period( get_period_head(hostid, i) );
}
regs->usb_sts = EHCI_INT_MASK_NXP_ASYNC | EHCI_INT_MASK_NXP_PERIODIC;
hcd_isr(hostid);
}
void ehci_controller_run_error(uint8_t hostid)
{
//------------- Async List -------------//
ehci_registers_t* const regs = get_operational_register(hostid);
ehci_qhd_t *p_qhd = (ehci_qhd_t*) regs->async_list_base;
do
{
if ( !p_qhd->qtd_overlay.halted )
{
if(!p_qhd->qtd_overlay.next.terminate)
{
ehci_qtd_t* p_qtd = (ehci_qtd_t*) align32(p_qhd->qtd_overlay.next.address);
p_qtd->active = 0;
p_qtd->babble_err = p_qtd->buffer_err = p_qtd->xact_err = 1;
p_qhd->qtd_overlay = *p_qtd;
}
}
p_qhd = (ehci_qhd_t*) align32(p_qhd->next.address);
}while(p_qhd != get_async_head(hostid)); // stop if loop around
//------------- Period List -------------//
regs->usb_sts = EHCI_INT_MASK_ERROR;
hcd_isr(hostid);
}
void ehci_controller_device_plug(uint8_t hostid, tusb_speed_t speed)
{
ehci_registers_t* const regs = get_operational_register(hostid);
regs->usb_sts_bit.port_change_detect = 1;
regs->portsc_bit.connect_status_change = 1;
regs->portsc_bit.current_connect_status = 1;
regs->portsc_bit.nxp_port_speed = speed;
hcd_isr(hostid);
}
void ehci_controller_device_unplug(uint8_t hostid)
{
ehci_registers_t* const regs = get_operational_register(hostid);
regs->usb_sts_bit.port_change_detect = 1;
regs->portsc_bit.connect_status_change = 1;
regs->portsc_bit.current_connect_status = 0;
hcd_isr(hostid);
}
-84
View File
@@ -1,84 +0,0 @@
/**************************************************************************/
/*!
@file ehci_controller_fake
@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.
*/
/**************************************************************************/
/** \file
* \brief TBD
*
* \note TBD
*/
/** \ingroup TBD
* \defgroup TBD
* \brief TBD
*
* @{
*/
#ifndef _TUSB_EHCI_CONTROLLER_H_
#define _TUSB_EHCI_CONTROLLER_H_
#include "host/hcd.h"
#ifdef __cplusplus
extern "C" {
#endif
extern ehci_data_t ehci_data;
void ehci_controller_init(void);
void ehci_controller_run(uint8_t hostid);
void ehci_controller_run_error(uint8_t hostid);
void ehci_controller_control_xfer_proceed(uint8_t dev_addr, uint8_t p_data[]);
void ehci_controller_device_plug(uint8_t hostid, tusb_speed_t speed);
void ehci_controller_device_unplug(uint8_t hostid);
ehci_registers_t* get_operational_register(uint8_t hostid);
ehci_link_t* get_period_frame_list(uint8_t hostid);
ehci_qhd_t* get_async_head(uint8_t hostid);
ehci_link_t* get_period_head(uint8_t hostid, uint8_t interval_ms);
ehci_qhd_t* get_control_qhd(uint8_t dev_addr);
ehci_qtd_t* get_control_qtds(uint8_t dev_addr);
ehci_qhd_t* qhd_get_from_pipe_handle(pipe_handle_t pipe_hdl);
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_EHCI_CONTROLLER_H_ */
/** @} */
-73
View File
@@ -1,73 +0,0 @@
/**************************************************************************/
/*!
@file hidh_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.
*/
/**************************************************************************/
/** \file
* \brief TBD
*
* \note TBD
*/
/** \ingroup TBD
* \defgroup TBD
* \brief TBD
*
* @{
*/
#ifndef _TUSB_TUSB_CALLBACK_H_
#define _TUSB_TUSB_CALLBACK_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "common/common.h"
#include "usbh.h"
//------------- core -------------//
uint8_t tusbh_device_attached_cb (tusb_descriptor_device_t const *p_desc_device) ATTR_WEAK ATTR_WARN_UNUSED_RESULT;
void tusbh_device_mount_succeed_cb (uint8_t dev_addr) ATTR_WEAK;
void tusbh_device_mount_failed_cb(tusb_error_t error, tusb_descriptor_device_t const *p_desc_device) ATTR_WEAK;
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_TUSB_CALLBACK_H_ */
/** @} */
-124
View File
@@ -1,124 +0,0 @@
/**************************************************************************/
/*!
@file tusb_config.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.
*/
/**************************************************************************/
/** \file
* \brief TBD
*
* \note TBD
*/
/** \ingroup TBD
* \defgroup TBD
* \brief TBD
*
* @{
*/
#ifndef _TUSB_TUSB_CONFIG_H_
#define _TUSB_TUSB_CONFIG_H_
#ifdef __cplusplus
extern "C" {
#endif
//--------------------------------------------------------------------+
// CONTROLLER CONFIGURATION
//--------------------------------------------------------------------+
#define TUSB_CFG_CONTROLLER0_MODE (TUSB_MODE_HOST | TUSB_MODE_DEVICE)
#define TUSB_CFG_CONTROLLER1_MODE TUSB_MODE_HOST
//--------------------------------------------------------------------+
// HOST CONFIGURATION
//--------------------------------------------------------------------+
//------------- CORE -------------//
#define TUSB_CFG_HOST_DEVICE_MAX 2
#define TUSB_CFG_CONFIGURATION_MAX 2
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 256
//------------- CLASS -------------//
#define TUSB_CFG_HOST_HID_KEYBOARD 1
#define TUSB_CFG_HOST_HID_MOUSE 1
#define HOST_HCD_XFER_INTERRUPT
#define HOST_HCD_XFER_BULK
//#define HOST_HCD_XFER_ISOCHRONOUS
// Test support
#define TEST_CONTROLLER_HOST_START_INDEX \
( ((CONTROLLER_HOST_NUMBER == 1) && (TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST)) ? 1 : 0)
//--------------------------------------------------------------------+
// DEVICE CONFIGURATION
//--------------------------------------------------------------------+
#define TUSB_CFG_DEVICE_STRING_MANUFACTURER "tinyusb.org"
#define TUSB_CFG_DEVICE_STRING_PRODUCT "Device Example"
#define TUSB_CFG_DEVICE_STRING_SERIAL "1234"
#define TUSB_CFG_DEVICE_VENDORID 0x1FC9 // NXP
//#define TUSB_CFG_DEVICE_PRODUCTID 0x4567
#define TUSB_CFG_DEVICE_USE_ROM_DRIVER 1
//------------- CLASS -------------//
#define TUSB_CFG_DEVICE_HID_KEYBOARD 1
#define TUSB_CFG_DEVICE_HID_MOUSE 1
#define TUSB_CFG_DEVICE_HID_GENERIC 0
#define TUSB_CFG_DEVICE_MSC 0
#define TUSB_CFG_DEVICE_CDC 0
//--------------------------------------------------------------------+
// COMMON CONFIGURATION
//--------------------------------------------------------------------+
#define TUSB_CFG_DEBUG 3
#define TUSB_CFG_OS TUSB_OS_NONE
#define TUSB_CFG_OS_TICKS_PER_SECOND 1000 // 1 ms tick
#define TUSB_CFG_ATTR_USBRAM
#ifdef __cplusplus
}
#endif
#define RANDOM(n) (rand()%(n))
#endif /* _TUSB_TUSB_CONFIG_H_ */
/** @} */
-78
View File
@@ -1,78 +0,0 @@
/**************************************************************************/
/*!
@file type_helper.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.
*/
/**************************************************************************/
/** \file
* \brief TBD
*
* \note TBD
*/
/** \ingroup TBD
* \defgroup TBD
* \brief TBD
*
* @{
*/
#ifndef _TUSB_TYPE_HELPER_H_
#define _TUSB_TYPE_HELPER_H_
#ifdef __cplusplus
extern "C" {
#endif
#define TEST_ASSERT_PIPE_HANDLE(expected, actual)\
TEST_ASSERT_EQUAL(expected.dev_addr, actual.dev_addr);\
TEST_ASSERT_EQUAL(expected.xfer_type, actual.xfer_type);\
TEST_ASSERT_EQUAL(expected.index, actual.index);\
#define TEST_ASSERT_MEM_ZERO(buffer, size)\
do{\
for (uint32_t i=0; i<size; i++)\
TEST_ASSERT_EQUAL_HEX8(0, ((uint8_t*)buffer)[i]);\
}while(0)
#define TEST_ASSERT_STATUS( actual )\
TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, (actual) )
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_TYPE_HELPER_H_ */
/** @} */
@@ -41,6 +41,7 @@
#include "tusb_option.h"
#include "errors.h"
#include "binary.h"
#include "type_helper.h"
#include "hal.h"
#include "hcd.h"
@@ -55,26 +56,6 @@ usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1];
//--------------------------------------------------------------------+
// Setup/Teardown + helper declare
//--------------------------------------------------------------------+
// log2_of a value is equivalent to its highest set bit's position
#define BITFIELD_OFFSET_OF_MEMBER(struct_type, member, bitfield_member) \
({\
uint32_t value=0;\
struct_type str;\
memclr_((void*)&str, sizeof(struct_type));\
str.member.bitfield_member = 1;\
memcpy(&value, (void*)&str.member, sizeof(str.member));\
log2_of( value );\
})
#define BITFIELD_OFFSET_OF_UINT32(struct_type, offset, bitfield_member) \
({\
struct_type str;\
memclr_(&str, sizeof(struct_type));\
str.bitfield_member = 1;\
log2_of( ((uint32_t*) &str)[offset] );\
})
void setUp(void)
{