diff options
Diffstat (limited to 'usb-benchmark-project')
-rw-r--r-- | usb-benchmark-project/Makefile | 211 | ||||
-rw-r--r-- | usb-benchmark-project/benchm_drv.c | 51 | ||||
-rw-r--r-- | usb-benchmark-project/benchm_drv.h | 5 | ||||
-rw-r--r-- | usb-benchmark-project/bin/.empty_dir | 0 | ||||
-rw-r--r-- | usb-benchmark-project/main.c | 559 | ||||
-rw-r--r-- | usb-benchmark-project/obj/.empty_dir | 0 | ||||
-rw-r--r-- | usb-benchmark-project/usb_desc.c | 289 |
7 files changed, 1115 insertions, 0 deletions
diff --git a/usb-benchmark-project/Makefile b/usb-benchmark-project/Makefile new file mode 100644 index 0000000..2957b7e --- /dev/null +++ b/usb-benchmark-project/Makefile @@ -0,0 +1,211 @@ +# ---------------------------------------------------------------------------- +# ATMEL Microcontroller Software Support +# ---------------------------------------------------------------------------- +# Copyright (c) 2008, Atmel Corporation +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# - Redistributions of source code must retain the above copyright notice, +# this list of conditions and the disclaimer below. +# +# Atmel's name may not be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE +# DISCLAIMED. IN NO EVENT SHALL ATMEL 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. +# ---------------------------------------------------------------------------- + +# Makefile for compiling the usb-device-core-project project + +#------------------------------------------------------------------------------- +# User-modifiable options +#------------------------------------------------------------------------------- + +# Chip & board used for compilation +# (can be overriden by adding CHIP=chip and BOARD=board to the command-line) +CHIP = at91sam3u4 +BOARD = at91sam3u-ek + +# Trace level used for compilation +# (can be overriden by adding TRACE_LEVEL=#number to the command-line) +# TRACE_LEVEL_DEBUG 5 +# TRACE_LEVEL_INFO 4 +# TRACE_LEVEL_WARNING 3 +# TRACE_LEVEL_ERROR 2 +# TRACE_LEVEL_FATAL 1 +# TRACE_LEVEL_NO_TRACE 0 +TRACE_LEVEL = 4 + +# Optimization level, put in comment for debugging +OPTIMIZATION = -Os + +# AT91 library directory +AT91LIB = ../../at91lib + +# External library +EXT_LIBS= ../external_libs + +# Output file basename +OUTPUT = usb-benchmark-project-$(BOARD)-$(CHIP) + +# Compile with chip specific features +include $(AT91LIB)/boards/$(BOARD)/$(CHIP)/chip.mak + +# Compile for all memories available on the board (this sets $(MEMORIES)) +include $(AT91LIB)/boards/$(BOARD)/board.mak + +# Output directories +BIN = bin +OBJ = obj + +#------------------------------------------------------------------------------- +# Tools +#------------------------------------------------------------------------------- + +# Tool suffix when cross-compiling +CROSS_COMPILE = arm-none-eabi- + +# Compilation tools +CC = $(CROSS_COMPILE)gcc +SIZE = $(CROSS_COMPILE)size +STRIP = $(CROSS_COMPILE)strip +OBJCOPY = $(CROSS_COMPILE)objcopy + +# Flags +INCLUDES += -I$(AT91LIB)/boards/$(BOARD) +INCLUDES += -I$(AT91LIB)/peripherals +INCLUDES += -I$(AT91LIB)/components +INCLUDES += -I$(AT91LIB) +INCLUDES += -I$(EXT_LIBS) +INCLUDES += -I$(EXT_LIBS)/cmsis + +ifeq ($(CHIP_CORE), cortexm3) +TARGET_OPTS = -mcpu=cortex-m3 -mthumb +else +TARGET_OPTS = +endif + +CFLAGS += $(TARGET_OPTS) +CFLAGS += -Wall -mlong-calls -ffunction-sections +CFLAGS += -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -DTRACE_LEVEL=$(TRACE_LEVEL) +ASFLAGS = $(TARGET_OPTS) -Wall -g $(OPTIMIZATION) $(INCLUDES) -D$(CHIP) -D__ASSEMBLY__ +LDFLAGS = -g $(OPTIMIZATION) -nostartfiles $(TARGET_OPTS) -Wl,--gc-sections + +#------------------------------------------------------------------------------- +# Files +#------------------------------------------------------------------------------- + +# Directories where source files can be found +PERIPH = $(AT91LIB)/peripherals +BOARDS = $(AT91LIB)/boards +USB = $(AT91LIB)/usb +UTILITY = $(AT91LIB)/utility + +VPATH += $(USB)/device/core +VPATH += $(USB)/common/core +VPATH += $(PERIPH)/dbgu +VPATH += $(PERIPH)/pio +VPATH += $(PERIPH)/irq +VPATH += $(PERIPH)/pmc +VPATH += $(PERIPH)/cp15 +VPATH += $(UTILITY) +VPATH += $(BOARDS)/$(BOARD) +VPATH += $(BOARDS)/$(BOARD)/$(CHIP) +VPATH += $(EXT_LIBS)/cmsis + +# Objects built from C source files +C_OBJECTS += usb_desc.o main.o benchm_drv.o +#C_OBJECTS += USBD_UDP.o +C_OBJECTS += USBD_UDPHS.o +C_OBJECTS += USBDDriver.o +C_OBJECTS += USBDCallbacks_Initialized.o +C_OBJECTS += USBDCallbacks_Reset.o +#C_OBJECTS += USBDCallbacks_Resumed.o +#C_OBJECTS += USBDCallbacks_Suspended.o +C_OBJECTS += USBDDriverCb_CfgChanged.o +C_OBJECTS += USBDDriverCb_IfSettingChanged.o +C_OBJECTS += USBInterfaceRequest.o +C_OBJECTS += USBFeatureRequest.o +C_OBJECTS += USBGenericRequest.o +C_OBJECTS += USBGetDescriptorRequest.o +C_OBJECTS += USBSetAddressRequest.o +C_OBJECTS += USBSetConfigurationRequest.o +C_OBJECTS += USBGenericDescriptor.o +C_OBJECTS += USBConfigurationDescriptor.o +C_OBJECTS += USBEndpointDescriptor.o +C_OBJECTS += dbgu.o +C_OBJECTS += pio.o +C_OBJECTS += pio_it.o +C_OBJECTS += pmc.o +C_OBJECTS += led.o +C_OBJECTS += string.o +C_OBJECTS += stdio.o +C_OBJECTS += trace.o +C_OBJECTS += board_memories.o +C_OBJECTS += board_lowlevel.o + +# Objects for different chips +ifeq ($(CHIP_CORE), cortexm3) +C_OBJECTS += nvic.o +C_OBJECTS += exceptions.o +C_OBJECTS += board_cstartup_gnu.o +C_OBJECTS += core_cm3.o +else +C_OBJECTS += aic.o +C_OBJECTS += cp15.o +endif + +# Objects built from Assembly source files +ifneq ($(CHIP_CORE), cortexm3) +ASM_OBJECTS += board_cstartup.o +ASM_OBJECTS += cp15_asm.o +endif + +# Append OBJ and BIN directories to output filename +OUTPUT := $(BIN)/$(OUTPUT) + +#------------------------------------------------------------------------------- +# Rules +#------------------------------------------------------------------------------- + +all: $(BIN) $(OBJ) $(MEMORIES) + +$(BIN) $(OBJ): + mkdir $@ + +define RULES +C_OBJECTS_$(1) = $(addprefix $(OBJ)/$(1)_, $(C_OBJECTS)) +ASM_OBJECTS_$(1) = $(addprefix $(OBJ)/$(1)_, $(ASM_OBJECTS)) + +$(1): $$(ASM_OBJECTS_$(1)) $$(C_OBJECTS_$(1)) + $(CC) $(LDFLAGS) -T"$(AT91LIB)/boards/$(BOARD)/$(CHIP)/$$@.lds" -o $(OUTPUT)-$$@.elf $$^ + $(OBJCOPY) -O binary $(OUTPUT)-$$@.elf $(OUTPUT)-$$@.bin + $(SIZE) $$^ $(OUTPUT)-$$@.elf + +$$(C_OBJECTS_$(1)): $(OBJ)/$(1)_%.o: %.c Makefile $(OBJ) $(BIN) + $(CC) $(CFLAGS) -D$(1) -c -o $$@ $$< + +$$(ASM_OBJECTS_$(1)): $(OBJ)/$(1)_%.o: %.S Makefile $(OBJ) $(BIN) + $(CC) $(ASFLAGS) -D$(1) -c -o $$@ $$< + +debug_$(1): $(1) + perl ../resources/gdb/debug.pl $(OUTPUT)-$(1).elf + +endef + +$(foreach MEMORY, $(MEMORIES), $(eval $(call RULES,$(MEMORY)))) + +clean: + -rm -f $(OBJ)/*.o $(BIN)/*.bin $(BIN)/*.elf + diff --git a/usb-benchmark-project/benchm_drv.c b/usb-benchmark-project/benchm_drv.c new file mode 100644 index 0000000..c6295f0 --- /dev/null +++ b/usb-benchmark-project/benchm_drv.c @@ -0,0 +1,51 @@ +#include <stdlib.h> +#include <stdint.h> +#include <board.h> +#include <utility/trace.h> + +#include <usb/common/core/USBGenericRequest.h> +#include <usb/device/core/USBD.h> +#include <usb/device/core/USBDDriver.h> +#include <usb/device/core/USBDDriverDescriptors.h> +#include <usb/device/core/USBDCallbacks.h> + + +extern const USBDDriverDescriptors usb_perf_driver_desc; + +static unsigned char driver_interfaces[3]; +static USBDDriver benchm_driver; + + +/* call-back for control EP requests from the host */ +void USBDCallbacks_RequestReceived(const USBGenericRequest *req) +{ + /* forward all (other) requests to core */ + USBDDriver_RequestHandler(&benchm_driver, req); +} + +void benchmark_drv_init(void) +{ + USBDDriver_Initialize(&benchm_driver, &usb_perf_driver_desc, + driver_interfaces); + USBD_Init(); +} + +const uint8_t test_data[2048]; + +static void wr_compl_cb(void *arg, unsigned char status, unsigned int transferred, unsigned int remain) +{ + uint8_t epnr = arg; + + /* re-start */ + if (status == 0 && remain == 0) { + //printf("."); + benchmark_start(epnr); + } else + printf("Err: EP%u wr_compl, status 0x%02u, xfr %u, remain %u\r\n", + epnr, status, transferred, remain); +} + +void benchmark_start(uint8_t epnr) +{ + USBD_Write(epnr, &test_data, sizeof(test_data), wr_compl_cb, epnr); +} diff --git a/usb-benchmark-project/benchm_drv.h b/usb-benchmark-project/benchm_drv.h new file mode 100644 index 0000000..3df3fa3 --- /dev/null +++ b/usb-benchmark-project/benchm_drv.h @@ -0,0 +1,5 @@ +#include <stdint.h> + +extern void benchmark_drv_init(void); + +void benchmark_start(uint8_t epnr); diff --git a/usb-benchmark-project/bin/.empty_dir b/usb-benchmark-project/bin/.empty_dir new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/usb-benchmark-project/bin/.empty_dir diff --git a/usb-benchmark-project/main.c b/usb-benchmark-project/main.c new file mode 100644 index 0000000..45e6c2b --- /dev/null +++ b/usb-benchmark-project/main.c @@ -0,0 +1,559 @@ +/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
+ * ----------------------------------------------------------------------------
+ */
+
+//-----------------------------------------------------------------------------
+/// \dir "USB Enumeration project"
+///
+/// !!!Purpose
+///
+/// The USB Enumeration Project will help you to get familiar with the
+/// USB Device Port(UDP)interface on AT91SAM microcontrollers. Also
+/// it can help you to be familiar with the USB Framework that is used for
+/// rapid development of USB-compliant class drivers such as USB Communication
+/// Device class (CDC).
+///
+/// You can find following information depends on your needs:
+/// - Sample usage of USB Device Framework.
+/// - USB enumerate sequence, the standard and class-specific descriptors and
+/// requests handling.
+/// - The initialize sequence and usage of UDP interface.
+///
+/// !See
+/// - pio: Pin configurations and peripheral configure.
+/// - usb: USB Device Framework and UDP interface driver
+/// - "AT91 USB device framework"
+/// - "USBD API"
+/// - "USB Device Enumeration"
+///
+/// !!!Requirements
+///
+/// This package can be used with all Atmel evaluation kits that have UDP
+/// interface.
+///
+/// The current supported board list:
+/// - at91sam7s-ek (exclude at91sam7s32)
+/// - at91sam7x-ek
+/// - at91sam7xc-ek
+/// - at91sam7a3-ek
+/// - at91sam7se-ek
+/// - at91sam9260-ek
+/// - at91sam9263-ek
+///
+/// !!!Description
+///
+/// When an EK running this program connected to a host (PC for example), with
+/// USB cable, host will notice the attachment of a USB %device. No %device
+/// driver offered for the %device now.
+///
+/// !!!Usage
+///
+/// -# Build the program and download it inside the evaluation board. Please
+/// refer to the
+/// <a href="http://www.atmel.com/dyn/resources/prod_documents/doc6224.pdf">
+/// SAM-BA User Guide</a>, the
+/// <a href="http://www.atmel.com/dyn/resources/prod_documents/doc6310.pdf">
+/// GNU-Based Software Development</a> application note or to the
+/// <a href="ftp://ftp.iar.se/WWWfiles/arm/Guides/EWARM_UserGuide.ENU.pdf">
+/// IAR EWARM User Guide</a>, depending on your chosen solution.
+/// -# On the computer, open and configure a terminal application
+/// (e.g. HyperTerminal on Microsoft Windows) with these settings:
+/// - 115200 bauds
+/// - 8 bits of data
+/// - No parity
+/// - 1 stop bit
+/// - No flow control
+/// -# Start the application.
+/// -# In the terminal window, the following text should appear:
+/// \code
+/// -- USB Device Core Project xxx --
+/// -- AT91xxxxxx-xx
+/// -- Compiled: xxx xx xxxx xx:xx:xx --
+/// \endcode
+/// -# When connecting USB cable to windows, the LED blinks, and the host
+/// reports a new USB %device attachment.
+///
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+/// \unit
+///
+/// !Purpose
+///
+/// This file contains all the specific code for the
+/// usb-device-core-project
+///
+/// !Contents
+///
+/// The code can be roughly broken down as follows:
+/// - Configuration functions
+/// - VBus_Configure
+/// - PIO configurations in start of main
+/// - Interrupt handlers
+/// - ISR_Vbus
+/// - Callback functions
+/// - USBDCallbacks_RequestReceived
+/// - The main function, which implements the program behavior
+///
+/// Please refer to the list of functions in the #Overview# tab of this unit
+/// for more detailed information.
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include <board.h>
+#include <utility/trace.h>
+#include <utility/led.h>
+#include <pio/pio.h>
+#include <pio/pio_it.h>
+#include <usb/common/core/USBGenericDescriptor.h>
+#include <usb/common/core/USBDeviceDescriptor.h>
+#include <usb/common/core/USBConfigurationDescriptor.h>
+#include <usb/common/core/USBInterfaceDescriptor.h>
+#include <usb/common/core/USBGenericRequest.h>
+#include <usb/device/core/USBD.h>
+#include <usb/device/core/USBDDriver.h>
+#include <usb/device/core/USBDDriverDescriptors.h>
+#include <usb/device/core/USBDCallbacks.h>
+#include <pmc/pmc.h>
+
+#include "benchm_drv.h"
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+/// Use for power management
+#define STATE_IDLE 0
+/// The USB device is in suspend state
+#define STATE_SUSPEND 4
+/// The USB device is in resume state
+#define STATE_RESUME 5
+
+//------------------------------------------------------------------------------
+// Internal variables
+//------------------------------------------------------------------------------
+/// State of USB, for suspend and resume
+unsigned char USBState = STATE_IDLE;
+
+//------------------------------------------------------------------------------
+// Local types
+//------------------------------------------------------------------------------
+/// Configuration descriptors with one interface.
+struct SimpleConfigurationDescriptors {
+
+ USBConfigurationDescriptor configuration;
+ USBInterfaceDescriptor interface;
+};
+
+//------------------------------------------------------------------------------
+// Local variables
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+// VBus monitoring (optional)
+//------------------------------------------------------------------------------
+#if defined(PIN_USB_VBUS)
+
+#define VBUS_CONFIGURE() VBus_Configure()
+
+/// VBus pin instance.
+static const Pin pinVbus = PIN_USB_VBUS;
+
+//------------------------------------------------------------------------------
+/// Handles interrupts coming from PIO controllers.
+//------------------------------------------------------------------------------
+static void ISR_Vbus(const Pin *pPin)
+{
+ // Check current level on VBus
+ if (PIO_Get(&pinVbus)) {
+
+ TRACE_INFO("VBUS conn\n\r");
+ USBD_Connect();
+ }
+ else {
+
+ TRACE_INFO("VBUS discon\n\r");
+ USBD_Disconnect();
+ }
+}
+
+//------------------------------------------------------------------------------
+/// Configures the VBus pin to trigger an interrupt when the level on that pin
+/// changes.
+//------------------------------------------------------------------------------
+static void VBus_Configure( void )
+{
+ TRACE_INFO("VBus configuration\n\r");
+
+ // Configure PIO
+ PIO_Configure(&pinVbus, 1);
+ PIO_ConfigureIt(&pinVbus, ISR_Vbus);
+ PIO_EnableIt(&pinVbus);
+
+ // Check current level on VBus
+ if (PIO_Get(&pinVbus)) {
+
+ // if VBUS present, force the connect
+ TRACE_INFO("VBUS conn\n\r");
+ USBD_Connect();
+ }
+ else {
+ TRACE_INFO("VBUS discon\n\r");
+ USBD_Disconnect();
+ }
+}
+
+#else
+ #define VBUS_CONFIGURE() USBD_Connect()
+#endif //#if defined(PIN_USB_VBUS)
+
+#if defined (CP15_PRESENT)
+//------------------------------------------------------------------------------
+/// Put the CPU in 32kHz, disable PLL, main oscillator
+/// Put voltage regulator in standby mode
+//------------------------------------------------------------------------------
+void LowPowerMode(void)
+{
+ PMC_CPUInIdleMode();
+}
+//------------------------------------------------------------------------------
+/// Put voltage regulator in normal mode
+/// Return the CPU to normal speed 48MHz, enable PLL, main oscillator
+//------------------------------------------------------------------------------
+void NormalPowerMode(void)
+{
+}
+
+#elif defined(at91sam7a3)
+//------------------------------------------------------------------------------
+/// Put the CPU in 32kHz, disable PLL, main oscillator
+//------------------------------------------------------------------------------
+void LowPowerMode(void)
+{
+ // MCK=48MHz to MCK=32kHz
+ // MCK = SLCK/2 : change source first from 48 000 000 to 18. / 2 = 9M
+ AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ // MCK=SLCK : then change prescaler
+ AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_CSS_SLOW_CLK;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ // disable PLL
+ AT91C_BASE_PMC->PMC_PLLR = 0;
+ // Disable Main Oscillator
+ AT91C_BASE_PMC->PMC_MOR = 0;
+
+ PMC_DisableProcessorClock();
+}
+//------------------------------------------------------------------------------
+/// Return the CPU to normal speed 48MHz, enable PLL, main oscillator
+//------------------------------------------------------------------------------
+void NormalPowerMode(void)
+{
+ // MCK=32kHz to MCK=48MHz
+ // enable Main Oscillator
+ AT91C_BASE_PMC->PMC_MOR = (( (AT91C_CKGR_OSCOUNT & (0x06 <<8)) | AT91C_CKGR_MOSCEN ));
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MOSCS ) );
+
+ // enable PLL@96MHz
+ AT91C_BASE_PMC->PMC_PLLR = ((AT91C_CKGR_DIV & 0x0E) |
+ (AT91C_CKGR_PLLCOUNT & (28<<8)) |
+ (AT91C_CKGR_MUL & (0x48<<16)));
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCK ) );
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ AT91C_BASE_CKGR->CKGR_PLLR |= AT91C_CKGR_USBDIV_1 ;
+ // MCK=SLCK/2 : change prescaler first
+ AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ // MCK=PLLCK/2 : then change source
+ AT91C_BASE_PMC->PMC_MCKR |= AT91C_PMC_CSS_PLL_CLK ;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+}
+
+#elif defined (at91sam7se)
+//------------------------------------------------------------------------------
+/// Put the CPU in 32kHz, disable PLL, main oscillator
+/// Put voltage regulator in standby mode
+//------------------------------------------------------------------------------
+void LowPowerMode(void)
+{
+ // MCK=48MHz to MCK=32kHz
+ // MCK = SLCK/2 : change source first from 48 000 000 to 18. / 2 = 9M
+ AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ // MCK=SLCK : then change prescaler
+ AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_CSS_SLOW_CLK;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ // disable PLL
+ AT91C_BASE_PMC->PMC_PLLR = 0;
+ // Disable Main Oscillator
+ AT91C_BASE_PMC->PMC_MOR = 0;
+
+ // Voltage regulator in standby mode : Enable VREG Low Power Mode
+ AT91C_BASE_VREG->VREG_MR |= AT91C_VREG_PSTDBY;
+
+ PMC_DisableProcessorClock();
+}
+//------------------------------------------------------------------------------
+/// Put voltage regulator in normal mode
+/// Return the CPU to normal speed 48MHz, enable PLL, main oscillator
+//------------------------------------------------------------------------------
+void NormalPowerMode(void)
+{
+ // Voltage regulator in normal mode : Disable VREG Low Power Mode
+ AT91C_BASE_VREG->VREG_MR &= ~AT91C_VREG_PSTDBY;
+
+ // MCK=32kHz to MCK=48MHz
+ // enable Main Oscillator
+ AT91C_BASE_PMC->PMC_MOR = (( (AT91C_CKGR_OSCOUNT & (0x06 <<8)) | AT91C_CKGR_MOSCEN ));
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MOSCS ) );
+
+ // enable PLL@96MHz
+ AT91C_BASE_PMC->PMC_PLLR = ((AT91C_CKGR_DIV & 0x0E) |
+ (AT91C_CKGR_PLLCOUNT & (28<<8)) |
+ (AT91C_CKGR_MUL & (0x48<<16)));
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCK ) );
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ AT91C_BASE_CKGR->CKGR_PLLR |= AT91C_CKGR_USBDIV_1 ;
+ // MCK=SLCK/2 : change prescaler first
+ AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ // MCK=PLLCK/2 : then change source
+ AT91C_BASE_PMC->PMC_MCKR |= AT91C_PMC_CSS_PLL_CLK ;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+}
+
+#elif defined (at91sam7s)
+//------------------------------------------------------------------------------
+/// Put the CPU in 32kHz, disable PLL, main oscillator
+/// Put voltage regulator in standby mode
+//------------------------------------------------------------------------------
+void LowPowerMode(void)
+{
+ // MCK=48MHz to MCK=32kHz
+ // MCK = SLCK/2 : change source first from 48 000 000 to 18. / 2 = 9M
+ AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ // MCK=SLCK : then change prescaler
+ AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_CSS_SLOW_CLK;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ // disable PLL
+ AT91C_BASE_PMC->PMC_PLLR = 0;
+ // Disable Main Oscillator
+ AT91C_BASE_PMC->PMC_MOR = 0;
+
+ // Voltage regulator in standby mode : Enable VREG Low Power Mode
+ AT91C_BASE_VREG->VREG_MR |= AT91C_VREG_PSTDBY;
+
+ PMC_DisableProcessorClock();
+}
+
+//------------------------------------------------------------------------------
+/// Put voltage regulator in normal mode
+/// Return the CPU to normal speed 48MHz, enable PLL, main oscillator
+//------------------------------------------------------------------------------
+void NormalPowerMode(void)
+{
+ // Voltage regulator in normal mode : Disable VREG Low Power Mode
+ AT91C_BASE_VREG->VREG_MR &= ~AT91C_VREG_PSTDBY;
+
+ // MCK=32kHz to MCK=48MHz
+ // enable Main Oscillator
+ AT91C_BASE_PMC->PMC_MOR = (( (AT91C_CKGR_OSCOUNT & (0x06 <<8)) | AT91C_CKGR_MOSCEN ));
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MOSCS ) );
+
+ // enable PLL@96MHz
+ AT91C_BASE_PMC->PMC_PLLR = ((AT91C_CKGR_DIV & 0x0E) |
+ (AT91C_CKGR_PLLCOUNT & (28<<8)) |
+ (AT91C_CKGR_MUL & (0x48<<16)));
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCK ) );
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ AT91C_BASE_CKGR->CKGR_PLLR |= AT91C_CKGR_USBDIV_1 ;
+ // MCK=SLCK/2 : change prescaler first
+ AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ // MCK=PLLCK/2 : then change source
+ AT91C_BASE_PMC->PMC_MCKR |= AT91C_PMC_CSS_PLL_CLK ;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+
+}
+
+#elif defined (at91sam7x) || defined (at91sam7xc)
+//------------------------------------------------------------------------------
+/// Put the CPU in 32kHz, disable PLL, main oscillator
+/// Put voltage regulator in standby mode
+//------------------------------------------------------------------------------
+void LowPowerMode(void)
+{
+ // MCK=48MHz to MCK=32kHz
+ // MCK = SLCK/2 : change source first from 48 000 000 to 18. / 2 = 9M
+ AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ // MCK=SLCK : then change prescaler
+ AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_CSS_SLOW_CLK;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ // disable PLL
+ AT91C_BASE_PMC->PMC_PLLR = 0;
+ // Disable Main Oscillator
+ AT91C_BASE_PMC->PMC_MOR = 0;
+
+ // Voltage regulator in standby mode : Enable VREG Low Power Mode
+ AT91C_BASE_VREG->VREG_MR |= AT91C_VREG_PSTDBY;
+
+ PMC_DisableProcessorClock();
+}
+
+//------------------------------------------------------------------------------
+/// Put voltage regulator in normal mode
+/// Return the CPU to normal speed 48MHz, enable PLL, main oscillator
+//------------------------------------------------------------------------------
+void NormalPowerMode(void)
+{
+ // Voltage regulator in normal mode : Disable VREG Low Power Mode
+ AT91C_BASE_VREG->VREG_MR &= ~AT91C_VREG_PSTDBY;
+
+ // MCK=32kHz to MCK=48MHz
+ // enable Main Oscillator
+ AT91C_BASE_PMC->PMC_MOR = (( (AT91C_CKGR_OSCOUNT & (0x06 <<8)) | AT91C_CKGR_MOSCEN ));
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MOSCS ) );
+
+ // enable PLL@96MHz
+ AT91C_BASE_PMC->PMC_PLLR = ((AT91C_CKGR_DIV & 0x0E) |
+ (AT91C_CKGR_PLLCOUNT & (28<<8)) |
+ (AT91C_CKGR_MUL & (0x48<<16)));
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_LOCK ) );
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ AT91C_BASE_CKGR->CKGR_PLLR |= AT91C_CKGR_USBDIV_1 ;
+ // MCK=SLCK/2 : change prescaler first
+ AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_PRES_CLK_2;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+ // MCK=PLLCK/2 : then change source
+ AT91C_BASE_PMC->PMC_MCKR |= AT91C_PMC_CSS_PLL_CLK ;
+ while( !( AT91C_BASE_PMC->PMC_SR & AT91C_PMC_MCKRDY ) );
+}
+#else
+//------------------------------------------------------------------------------
+/// Put the CPU in low power mode (for customer)
+//------------------------------------------------------------------------------
+static void LowPowerMode(void)
+{
+}
+
+//------------------------------------------------------------------------------
+/// Return the CPU to normal speed (for customer)
+//------------------------------------------------------------------------------
+static void NormalPowerMode(void)
+{
+}
+#endif
+
+//------------------------------------------------------------------------------
+// Callbacks re-implementation
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+/// Invoked when the USB device leaves the Suspended state. By default,
+/// configures the LEDs.
+//------------------------------------------------------------------------------
+void USBDCallbacks_Resumed(void)
+{
+ // Initialize LEDs
+ LED_Configure(USBD_LEDPOWER);
+ LED_Set(USBD_LEDPOWER);
+ LED_Configure(USBD_LEDUSB);
+ LED_Clear(USBD_LEDUSB);
+ USBState = STATE_RESUME;
+}
+
+//------------------------------------------------------------------------------
+/// Invoked when the USB device gets suspended. By default, turns off all LEDs.
+//------------------------------------------------------------------------------
+void USBDCallbacks_Suspended(void)
+{
+ // Turn off LEDs
+ LED_Clear(USBD_LEDPOWER);
+ LED_Clear(USBD_LEDUSB);
+ USBState = STATE_SUSPEND;
+}
+
+//------------------------------------------------------------------------------
+// Global functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Initializes the system, connects the USB and waits indefinitely.
+//------------------------------------------------------------------------------
+int main()
+{
+ TRACE_CONFIGURE(DBGU_STANDARD, 115200, BOARD_MCK);
+ printf("-- USB Benchmark Project %s --\n\r", SOFTPACK_VERSION);
+ printf("-- %s\n\r", BOARD_NAME);
+ printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__);
+
+ // If they are present, configure Vbus & Wake-up pins
+ PIO_InitializeInterrupts(0);
+
+ // If there is on board power, switch it off
+ #ifdef PIN_USB_POWER_ENB
+ { const Pin pinUsbPwr = PIN_USB_POWER_ENB;
+ PIO_Configure(&pinUsbPwr, 1);
+ }
+ #endif
+
+ // USB initialization, Disable Pull-up
+ TRACE_INFO("USB initialization\n\r");
+ benchmark_drv_init();
+
+ // Wait about 10ms so that host detach the device to re-enumerate
+ // Device connection
+ TRACE_INFO("Connecting device\n\r");
+
+ // Enable Vbus detect, connect if needed (vbus detected)
+ VBUS_CONFIGURE();
+ while (USBD_GetState() < USBD_STATE_CONFIGURED);
+
+ //benchmark_start(2);
+ benchmark_start(5);
+
+ // Infinite loop
+ while (1) {
+ if( USBState == STATE_SUSPEND ) {
+ TRACE_DEBUG("suspend !\n\r");
+ LowPowerMode();
+ USBState = STATE_IDLE;
+ }
+ if( USBState == STATE_RESUME ) {
+ // Return in normal MODE
+ TRACE_DEBUG("resume !\n\r");
+ NormalPowerMode();
+ USBState = STATE_IDLE;
+ }
+ }
+}
+
diff --git a/usb-benchmark-project/obj/.empty_dir b/usb-benchmark-project/obj/.empty_dir new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/usb-benchmark-project/obj/.empty_dir diff --git a/usb-benchmark-project/usb_desc.c b/usb-benchmark-project/usb_desc.c new file mode 100644 index 0000000..a17afff --- /dev/null +++ b/usb-benchmark-project/usb_desc.c @@ -0,0 +1,289 @@ +#include <stdlib.h> + +#include <board.h> + +#include <usb/common/core/USBGenericDescriptor.h> +#include <usb/common/core/USBDeviceDescriptor.h> +#include <usb/common/core/USBConfigurationDescriptor.h> +#include <usb/common/core/USBInterfaceDescriptor.h> +#include <usb/common/core/USBEndpointDescriptor.h> +//#include <usb/common/core/USBStringDescriptor.h> + +#include <usb/device/core/USBDDriver.h> +#include <usb/device/core/USBDDriverDescriptors.h> + +#define MIN(a, b) ((a < b) ? a : b) + +#define ISOCH + +struct perf_conf_descs { + USBConfigurationDescriptor configuration; + USBInterfaceDescriptor interface; + USBEndpointDescriptor bulkOut; + USBEndpointDescriptor bulkIn; + USBEndpointDescriptor bulkIn5; +} __attribute__((packed)); + +static const USBDeviceDescriptor dev_desc = { + .bLength = sizeof(USBDeviceDescriptor), + .bDescriptorType = USBGenericDescriptor_DEVICE, + .bcdUSB = USBDeviceDescriptor_USB2_00, + .bDeviceClass = 0xff, + .bDeviceSubClass = 0xff, + .bDeviceProtocol = 0xff, + .bMaxPacketSize0 = CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), + .idVendor = 0x16c0, + .idProduct = 0x0763, + .bcdDevice = 0x0100, + .iManufacturer = 0, + .iProduct = 0, + .iSerialNumber = 0, + .bNumConfigurations = 1, +}; + +static const USBDeviceQualifierDescriptor qual_desc = { + .bLength = sizeof(USBDeviceQualifierDescriptor), + .bDescriptorType = USBGenericDescriptor_DEVICEQUALIFIER, + .bcdUSB = USBDeviceDescriptor_USB2_00, + .bDeviceClass = 0xff, + .bDeviceSubClass = 0, + .bDeviceProtocol = 0xff, + .bMaxPacketSize0 = CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0), + .bNumConfigurations = 1, + .bReserved = 0, +}; + +static const struct perf_conf_descs conf_desc = { + .configuration = { + .bLength = sizeof(USBConfigurationDescriptor), + .bDescriptorType = USBGenericDescriptor_CONFIGURATION, + .wTotalLength = sizeof(struct perf_conf_descs), + .bNumInterfaces = 1, + .bConfigurationValue = 1, + .iConfiguration = 0, + .bmAttributes = BOARD_USB_BMATTRIBUTES, + .bMaxPower = USBConfigurationDescriptor_POWER(100), + }, + .interface = { + .bLength = sizeof(USBInterfaceDescriptor), + .bDescriptorType = USBGenericDescriptor_INTERFACE, + .bInterfaceNumber = 0, + .bAlternateSetting = 0, + .bNumEndpoints = 3, + .bInterfaceClass = 0xff, + .bInterfaceSubClass = 0, + .bInterfaceProtocol = 0xff, + .iInterface = 0, + }, + .bulkOut = { + .bLength = sizeof(USBEndpointDescriptor), + .bDescriptorType = USBGenericDescriptor_ENDPOINT, + .bEndpointAddress = USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, 1), + .bmAttributes = USBEndpointDescriptor_BULK, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(1), USBEndpointDescriptor_MAXBULKSIZE_FS), + .bInterval = 0, + }, + .bulkIn = { + .bLength = sizeof(USBEndpointDescriptor), + .bDescriptorType = USBGenericDescriptor_ENDPOINT, + .bEndpointAddress = USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, 2), + .bmAttributes = USBEndpointDescriptor_BULK, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(2), USBEndpointDescriptor_MAXBULKSIZE_FS), + .bInterval = 0, + }, + .bulkIn5 = { + .bLength = sizeof(USBEndpointDescriptor), + .bDescriptorType = USBGenericDescriptor_ENDPOINT, + .bEndpointAddress = USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, 5), +#ifdef ISOCH + .bmAttributes = USBEndpointDescriptor_ISOCHRONOUS, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(5), USBEndpointDescriptor_MAXISOCHRONOUSSIZE_FS), + .bInterval = 0, +#else + .bmAttributes = USBEndpointDescriptor_BULK, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(5), USBEndpointDescriptor_MAXBULKSIZE_FS), + .bInterval = 0x04, +#endif + }, +}; +static const struct perf_conf_descs conf_desc_hs = { + .configuration = { + .bLength = sizeof(USBConfigurationDescriptor), + .bDescriptorType = USBGenericDescriptor_CONFIGURATION, + .wTotalLength = sizeof(struct perf_conf_descs), + .bNumInterfaces = 1, + .bConfigurationValue = 1, + .iConfiguration = 0, + .bmAttributes = BOARD_USB_BMATTRIBUTES, + .bMaxPower = USBConfigurationDescriptor_POWER(100), + }, + .interface = { + .bLength = sizeof(USBInterfaceDescriptor), + .bDescriptorType = USBGenericDescriptor_INTERFACE, + .bInterfaceNumber = 0, + .bAlternateSetting = 0, + .bNumEndpoints = 3, + .bInterfaceClass = 0xff, + .bInterfaceSubClass = 0, + .bInterfaceProtocol = 0xff, + .iInterface = 0, + }, + .bulkOut = { + .bLength = sizeof(USBEndpointDescriptor), + .bDescriptorType = USBGenericDescriptor_ENDPOINT, + .bEndpointAddress = USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, 1), + .bmAttributes = USBEndpointDescriptor_BULK, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(1), USBEndpointDescriptor_MAXBULKSIZE_HS), + .bInterval = 0, + }, + .bulkIn = { + .bLength = sizeof(USBEndpointDescriptor), + .bDescriptorType = USBGenericDescriptor_ENDPOINT, + .bEndpointAddress = USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, 2), + .bmAttributes = USBEndpointDescriptor_BULK, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(2), USBEndpointDescriptor_MAXBULKSIZE_HS), + .bInterval = 0, + }, + .bulkIn5 = { + .bLength = sizeof(USBEndpointDescriptor), + .bDescriptorType = USBGenericDescriptor_ENDPOINT, + .bEndpointAddress = USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, 5), + +#ifdef ISOCH + .bmAttributes = USBEndpointDescriptor_ISOCHRONOUS, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(5), USBEndpointDescriptor_MAXISOCHRONOUSSIZE_HS), + .bInterval = 0, +#else + .bmAttributes = USBEndpointDescriptor_BULK, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(5), USBEndpointDescriptor_MAXBULKSIZE_HS), + .bInterval = 0, +#endif + }, +}; + +static const struct perf_conf_descs conf_desc_other_fs = { + .configuration = { + .bLength = sizeof(USBConfigurationDescriptor), + .bDescriptorType = USBGenericDescriptor_OTHERSPEEDCONFIGURATION, + .wTotalLength = sizeof(struct perf_conf_descs), + .bNumInterfaces = 1, + .bConfigurationValue = 1, + .iConfiguration = 0, + .bmAttributes = BOARD_USB_BMATTRIBUTES, + .bMaxPower = USBConfigurationDescriptor_POWER(100), + }, + .interface = { + .bLength = sizeof(USBInterfaceDescriptor), + .bDescriptorType = USBGenericDescriptor_INTERFACE, + .bInterfaceNumber = 0, + .bAlternateSetting = 0, + .bNumEndpoints = 3, + .bInterfaceClass = 0xff, + .bInterfaceSubClass = 0, + .bInterfaceProtocol = 0xff, + .iInterface = 0, + }, + .bulkOut = { + .bLength = sizeof(USBEndpointDescriptor), + .bDescriptorType = USBGenericDescriptor_ENDPOINT, + .bEndpointAddress = USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, 1), + .bmAttributes = USBEndpointDescriptor_BULK, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(1), USBEndpointDescriptor_MAXBULKSIZE_FS), + .bInterval = 0, + }, + .bulkIn = { + .bLength = sizeof(USBEndpointDescriptor), + .bDescriptorType = USBGenericDescriptor_ENDPOINT, + .bEndpointAddress = USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, 2), + .bmAttributes = USBEndpointDescriptor_BULK, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(2), USBEndpointDescriptor_MAXBULKSIZE_FS), + .bInterval = 0, + }, + .bulkIn5 = { + .bLength = sizeof(USBEndpointDescriptor), + .bDescriptorType = USBGenericDescriptor_ENDPOINT, + .bEndpointAddress = USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, 5), +#ifdef ISOCH + .bmAttributes = USBEndpointDescriptor_ISOCHRONOUS, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(5), USBEndpointDescriptor_MAXISOCHRONOUSSIZE_FS), + .bInterval = 0x04, +#else + .bmAttributes = USBEndpointDescriptor_BULK, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(5), USBEndpointDescriptor_MAXBULKSIZE_FS), + .bInterval = 0, +#endif + }, +}; +static const struct perf_conf_descs conf_desc_other_hs = { + .configuration = { + .bLength = sizeof(USBConfigurationDescriptor), + .bDescriptorType = USBGenericDescriptor_OTHERSPEEDCONFIGURATION, + .wTotalLength = sizeof(struct perf_conf_descs), + .bNumInterfaces = 1, + .bConfigurationValue = 1, + .iConfiguration = 0, + .bmAttributes = BOARD_USB_BMATTRIBUTES, + .bMaxPower = USBConfigurationDescriptor_POWER(100), + }, + .interface = { + .bLength = sizeof(USBInterfaceDescriptor), + .bDescriptorType = USBGenericDescriptor_INTERFACE, + .bInterfaceNumber = 0, + .bAlternateSetting = 0, + .bNumEndpoints = 3, + .bInterfaceClass = 0xff, + .bInterfaceSubClass = 0, + .bInterfaceProtocol = 0xff, + .iInterface = 0, + }, + .bulkOut = { + .bLength = sizeof(USBEndpointDescriptor), + .bDescriptorType = USBGenericDescriptor_ENDPOINT, + .bEndpointAddress = USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, 1), + .bmAttributes = USBEndpointDescriptor_BULK, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(1), USBEndpointDescriptor_MAXBULKSIZE_HS), + .bInterval = 0, + }, + .bulkIn = { + .bLength = sizeof(USBEndpointDescriptor), + .bDescriptorType = USBGenericDescriptor_ENDPOINT, + .bEndpointAddress = USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, 2), + .bmAttributes = USBEndpointDescriptor_BULK, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(2), USBEndpointDescriptor_MAXBULKSIZE_HS), + .bInterval = 0, + }, + .bulkIn5 = { + .bLength = sizeof(USBEndpointDescriptor), + .bDescriptorType = USBGenericDescriptor_ENDPOINT, + .bEndpointAddress = USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, 5), +#ifdef ISOCH + .bmAttributes = USBEndpointDescriptor_ISOCHRONOUS, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(5), USBEndpointDescriptor_MAXISOCHRONOUSSIZE_HS), + .bInterval = 0x04, +#else + .bmAttributes = USBEndpointDescriptor_BULK, + .wMaxPacketSize = MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(5), USBEndpointDescriptor_MAXBULKSIZE_HS), + .bInterval = 0, +#endif + }, +}; + +const USBDDriverDescriptors usb_perf_driver_desc = { + .pFsDevice = &dev_desc, + .pFsConfiguration = &conf_desc, + .pFsQualifier = &qual_desc, + .pFsOtherSpeed = &conf_desc_other_fs, + .pHsDevice = &dev_desc, + .pHsConfiguration = &conf_desc_hs, + .pHsQualifier = &qual_desc, + .pHsOtherSpeed = &conf_desc_other_hs, + .pStrings = NULL, + .numStrings = 0, +}; + +#if 0 +static USBDDriver perftest_usbdriver = { + .pDescriptors = &driver_desc, + //.pInterfaces = +}; +#endif |