Просмотр исходного кода

added dcd_dma_descriptor_t typdef
reorganize test project, multiple test projects each is specifically for an MCU

hathach 12 лет назад
Родитель
Сommit
f69fefefa9
45 измененных файлов с 190 добавлено и 89 удалено
  1. 116 55
      .cproject
  2. 1 1
      .travis.yml
  3. 1 0
      tests/lpc175x_6x/build/readme.md
  4. 0 0
      tests/support/FreeRTOSConfig.h
  5. 0 0
      tests/support/LPC43xx.h
  6. 0 0
      tests/support/descriptor_test.c
  7. 0 0
      tests/support/descriptor_test.h
  8. 0 0
      tests/support/ehci_controller_fake.c
  9. 0 0
      tests/support/ehci_controller_fake.h
  10. 0 0
      tests/support/tusb_callback.h
  11. 0 0
      tests/support/tusb_config.h
  12. 20 0
      tests/support/type_helper.h
  13. 1 0
      tests/test/build/readme.md
  14. 10 12
      tests/test/project.yml
  15. 1 1
      tests/test/rakefile.rb
  16. 0 0
      tests/test/test/device/usbd/test_usbd.c
  17. 0 0
      tests/test/test/host/ehci/test_ehci_init.c
  18. 0 0
      tests/test/test/host/ehci/test_ehci_isr.c
  19. 1 20
      tests/test/test/host/ehci/test_ehci_structure.c
  20. 0 0
      tests/test/test/host/ehci/test_ehci_usbh_hcd_integration.c
  21. 0 0
      tests/test/test/host/ehci/test_pipe_bulk_open.c
  22. 0 0
      tests/test/test/host/ehci/test_pipe_bulk_xfer.c
  23. 0 0
      tests/test/test/host/ehci/test_pipe_control_open.c
  24. 0 0
      tests/test/test/host/ehci/test_pipe_control_xfer.c
  25. 0 0
      tests/test/test/host/ehci/test_pipe_interrupt_open.c
  26. 0 0
      tests/test/test/host/ehci/test_pipe_interrupt_xfer.c
  27. 0 0
      tests/test/test/host/ehci/test_pipe_isochronous_open.c
  28. 0 0
      tests/test/test/host/hid/hidh_callback.h
  29. 0 0
      tests/test/test/host/hid/test_hid_host.c
  30. 0 0
      tests/test/test/host/hid/test_hidh_keyboard.c
  31. 0 0
      tests/test/test/host/hid/test_hidh_mouse.c
  32. 0 0
      tests/test/test/host/host_helper.h
  33. 0 0
      tests/test/test/host/hub/test_hub.c
  34. 0 0
      tests/test/test/host/integration/test_hidh_keyboard_integrate.c
  35. 0 0
      tests/test/test/host/msc/test_msc_host.c
  36. 0 0
      tests/test/test/host/usbh/test_enum_task.c
  37. 0 0
      tests/test/test/host/usbh/test_usbh.c
  38. 0 0
      tests/test/test/test_assertion.c
  39. 0 0
      tests/test/test/test_binary_const.c
  40. 0 0
      tests/test/test/test_fifo.c
  41. 0 0
      tests/test/test/test_osal_freeRTOS.c
  42. 0 0
      tests/test/test/test_osal_none.c
  43. 0 0
      tests/test/test/test_project_settings.c
  44. 1 0
      tinyusb/device/dcd_lpc175x_6x.c
  45. 38 0
      tinyusb/device/dcd_lpc175x_6x.h

+ 116 - 55
.cproject

@@ -101,61 +101,6 @@
 </infoList>
 &lt;/TargetConfig&gt;</projectStorage>
 	</storageModule>
-	<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
-		<buildTargets>
-			<target name="clean" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
-				<buildCommand>rake.bat</buildCommand>
-				<buildArguments/>
-				<buildTarget>clean</buildTarget>
-				<stopOnError>true</stopOnError>
-				<useDefaultCommand>false</useDefaultCommand>
-				<runAllBuilders>true</runAllBuilders>
-			</target>
-			<target name="release" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
-				<buildCommand>rake.bat</buildCommand>
-				<buildArguments/>
-				<buildTarget>release</buildTarget>
-				<stopOnError>true</stopOnError>
-				<useDefaultCommand>false</useDefaultCommand>
-				<runAllBuilders>true</runAllBuilders>
-			</target>
-			<target name="test" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
-				<buildCommand>rake.bat</buildCommand>
-				<buildTarget>test:all</buildTarget>
-				<stopOnError>true</stopOnError>
-				<useDefaultCommand>false</useDefaultCommand>
-				<runAllBuilders>true</runAllBuilders>
-			</target>
-			<target name="test delta" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
-				<buildCommand>rake.bat</buildCommand>
-				<buildTarget>test:delta</buildTarget>
-				<stopOnError>true</stopOnError>
-				<useDefaultCommand>false</useDefaultCommand>
-				<runAllBuilders>true</runAllBuilders>
-			</target>
-			<target name="clobber" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
-				<buildCommand>rake.bat</buildCommand>
-				<buildTarget>clobber</buildTarget>
-				<stopOnError>true</stopOnError>
-				<useDefaultCommand>false</useDefaultCommand>
-				<runAllBuilders>true</runAllBuilders>
-			</target>
-			<target name="test verbose" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
-				<buildCommand>rake.bat</buildCommand>
-				<buildTarget>verbosity[4] test:all</buildTarget>
-				<stopOnError>true</stopOnError>
-				<useDefaultCommand>false</useDefaultCommand>
-				<runAllBuilders>true</runAllBuilders>
-			</target>
-			<target name="test verbose delta" path="tests" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
-				<buildCommand>rake.bat</buildCommand>
-				<buildTarget>verbosity[4] test:delta</buildTarget>
-				<stopOnError>true</stopOnError>
-				<useDefaultCommand>false</useDefaultCommand>
-				<runAllBuilders>true</runAllBuilders>
-			</target>
-		</buildTargets>
-	</storageModule>
 	<storageModule moduleId="refreshScope" versionNumber="1">
 		<resource resourceType="PROJECT" workspacePath="/tinyusb"/>
 	</storageModule>
@@ -418,4 +363,120 @@
 		</scannerConfigBuildInfo>
 	</storageModule>
 	<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
+	<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
+		<buildTargets>
+			<target name="clean" path="tests/test" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>clean</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+			<target name="clobber" path="tests/test" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>clobber</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+			<target name="release" path="tests/test" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>release</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+			<target name="test" path="tests/test" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>test:all</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+			<target name="test delta" path="tests/test" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>test:delta</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+			<target name="test verbose" path="tests/test" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>verbosity[4] test:all</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+			<target name="test verbose delta" path="tests/test" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>verbosity[4] test:delta</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+			<target name="clean" path="tests/lpc175x_6x" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>clean</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+			<target name="clobber" path="tests/lpc175x_6x" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>clobber</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+			<target name="release" path="tests/lpc175x_6x" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>release</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+			<target name="test" path="tests/lpc175x_6x" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>test:all</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+			<target name="test delta" path="tests/lpc175x_6x" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>test:delta</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+			<target name="test verbose" path="tests/lpc175x_6x" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>verbosity[4] test:all</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+			<target name="test verbose delta" path="tests/lpc175x_6x" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
+				<buildCommand>rake.bat</buildCommand>
+				<buildArguments/>
+				<buildTarget>verbosity[4] test:delta</buildTarget>
+				<stopOnError>true</stopOnError>
+				<useDefaultCommand>false</useDefaultCommand>
+				<runAllBuilders>true</runAllBuilders>
+			</target>
+		</buildTargets>
+	</storageModule>
 </cproject>

+ 1 - 1
.travis.yml

@@ -1,4 +1,4 @@
 language: c
 compiler:
   - gcc
-script: cd tests/ && mkdir build && rake test:all
+script: cd tests/test  && rake test:all && cd ../lpc175x_6x  && rake test:all

+ 1 - 0
tests/lpc175x_6x/build/readme.md

@@ -0,0 +1 @@
+just a build folder

+ 0 - 0
tests/test/support/FreeRTOSConfig.h → tests/support/FreeRTOSConfig.h


+ 0 - 0
tests/test/support/LPC43xx.h → tests/support/LPC43xx.h


+ 0 - 0
tests/test/support/descriptor_test.c → tests/support/descriptor_test.c


+ 0 - 0
tests/test/support/descriptor_test.h → tests/support/descriptor_test.h


+ 0 - 0
tests/test/support/ehci_controller_fake.c → tests/support/ehci_controller_fake.c


+ 0 - 0
tests/test/support/ehci_controller_fake.h → tests/support/ehci_controller_fake.h


+ 0 - 0
tests/test/support/tusb_callback.h → tests/support/tusb_callback.h


+ 0 - 0
tests/test/support/tusb_config.h → tests/support/tusb_config.h


+ 20 - 0
tests/test/support/type_helper.h → tests/support/type_helper.h

@@ -69,6 +69,26 @@
 
 #define TEST_ASSERT_STATUS( actual )\
   TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, (actual) )
+
+// 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] );\
+  })
+
 #ifdef __cplusplus
  }
 #endif

+ 1 - 0
tests/test/build/readme.md

@@ -0,0 +1 @@
+just a build folder

+ 10 - 12
tests/project.yml → tests/test/project.yml

@@ -26,17 +26,16 @@
 :paths:
   :test:
     - +:test/**
-    - -:test/support
   :source:
-    - ../tinyusb/**
-    - +:../demos/bsp/lpc43xx/**
-    - +:../demos/device/keyboard/*
-    - -:../demos/
-    - ../vendor/freertos/freertos/Source/*
-    - ../vendor/freertos/freertos/Source/portable/MSVC-MingW/*
+    - ../../tinyusb/**
+    - +:../../demos/bsp/lpc43xx/**
+    - +:../../demos/device/keyboard/*
+    - -:../../demos/
+    - ../../vendor/freertos/freertos/Source/*
+    - ../../vendor/freertos/freertos/Source/portable/MSVC-MingW/*
     
   :support:
-    - test/support
+    - ../support
 
 :defines:
   # in order to add common defines:
@@ -59,8 +58,8 @@
 #:flags:
 #  :test:
 #    :compile:
-#      :hid_host:
-#        - -Dstatic=
+#      :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)
@@ -75,7 +74,6 @@
     - :callback
     - :array
   #:ignore: :args_only
-#  :unity_helper_path: test/support/type_helper.h
   :treat_as:
     uint8:    HEX8
     uint16:   HEX16
@@ -85,7 +83,7 @@
 
 :plugins:
   :load_paths:
-    - vendor/ceedling/plugins
+    - ../vendor/ceedling/plugins
   :enabled:
     #- stdout_pretty_tests_report
     - stdout_ide_tests_report

+ 1 - 1
tests/rakefile.rb → tests/test/rakefile.rb

@@ -1,4 +1,4 @@
-PROJECT_CEEDLING_ROOT = "vendor/ceedling"
+PROJECT_CEEDLING_ROOT = "../vendor/ceedling"
 load "#{PROJECT_CEEDLING_ROOT}/lib/rakefile.rb"
 
 task :default => %w[ test:all release ]

+ 0 - 0
tests/test/device/usbd/test_usbd.c → tests/test/test/device/usbd/test_usbd.c


+ 0 - 0
tests/test/host/ehci/test_ehci_init.c → tests/test/test/host/ehci/test_ehci_init.c


+ 0 - 0
tests/test/host/ehci/test_ehci_isr.c → tests/test/test/host/ehci/test_ehci_isr.c


+ 1 - 20
tests/test/host/ehci/test_ehci_structure.c → tests/test/test/host/ehci/test_ehci_structure.c

@@ -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)
 {
 

+ 0 - 0
tests/test/host/ehci/test_ehci_usbh_hcd_integration.c → tests/test/test/host/ehci/test_ehci_usbh_hcd_integration.c


+ 0 - 0
tests/test/host/ehci/test_pipe_bulk_open.c → tests/test/test/host/ehci/test_pipe_bulk_open.c


+ 0 - 0
tests/test/host/ehci/test_pipe_bulk_xfer.c → tests/test/test/host/ehci/test_pipe_bulk_xfer.c


+ 0 - 0
tests/test/host/ehci/test_pipe_control_open.c → tests/test/test/host/ehci/test_pipe_control_open.c


+ 0 - 0
tests/test/host/ehci/test_pipe_control_xfer.c → tests/test/test/host/ehci/test_pipe_control_xfer.c


+ 0 - 0
tests/test/host/ehci/test_pipe_interrupt_open.c → tests/test/test/host/ehci/test_pipe_interrupt_open.c


+ 0 - 0
tests/test/host/ehci/test_pipe_interrupt_xfer.c → tests/test/test/host/ehci/test_pipe_interrupt_xfer.c


+ 0 - 0
tests/test/host/ehci/test_pipe_isochronous_open.c → tests/test/test/host/ehci/test_pipe_isochronous_open.c


+ 0 - 0
tests/test/host/hid/hidh_callback.h → tests/test/test/host/hid/hidh_callback.h


+ 0 - 0
tests/test/host/hid/test_hid_host.c → tests/test/test/host/hid/test_hid_host.c


+ 0 - 0
tests/test/host/hid/test_hidh_keyboard.c → tests/test/test/host/hid/test_hidh_keyboard.c


+ 0 - 0
tests/test/host/hid/test_hidh_mouse.c → tests/test/test/host/hid/test_hidh_mouse.c


+ 0 - 0
tests/test/host/host_helper.h → tests/test/test/host/host_helper.h


+ 0 - 0
tests/test/host/hub/test_hub.c → tests/test/test/host/hub/test_hub.c


+ 0 - 0
tests/test/host/integration/test_hidh_keyboard_integrate.c → tests/test/test/host/integration/test_hidh_keyboard_integrate.c


+ 0 - 0
tests/test/host/msc/test_msc_host.c → tests/test/test/host/msc/test_msc_host.c


+ 0 - 0
tests/test/host/usbh/test_enum_task.c → tests/test/test/host/usbh/test_enum_task.c


+ 0 - 0
tests/test/host/usbh/test_usbh.c → tests/test/test/host/usbh/test_usbh.c


+ 0 - 0
tests/test/test_assertion.c → tests/test/test/test_assertion.c


+ 0 - 0
tests/test/test_binary_const.c → tests/test/test/test_binary_const.c


+ 0 - 0
tests/test/test_fifo.c → tests/test/test/test_fifo.c


+ 0 - 0
tests/test/test_osal_freeRTOS.c → tests/test/test/test_osal_freeRTOS.c


+ 0 - 0
tests/test/test_osal_none.c → tests/test/test/test_osal_none.c


+ 0 - 0
tests/test/test_project_settings.c → tests/test/test/test_project_settings.c


+ 1 - 0
tinyusb/device/dcd_lpc175x_6x.c

@@ -51,6 +51,7 @@
 //--------------------------------------------------------------------+
 // MACRO CONSTANT TYPEDEF
 //--------------------------------------------------------------------+
+STATIC_ dcd_dma_descriptor_t* dcd_udca[32] ATTR_ALIGNED(128) TUSB_CFG_ATTR_USBRAM;
 
 //--------------------------------------------------------------------+
 // INTERNAL OBJECT & FUNCTION DECLARATION

+ 38 - 0
tinyusb/device/dcd_lpc175x_6x.h

@@ -46,11 +46,49 @@
 #ifndef _TUSB_DCD_LPC175X_6X_H_
 #define _TUSB_DCD_LPC175X_6X_H_
 
+#include "common/common.h"
+
 #ifdef __cplusplus
  extern "C" {
 #endif
 
 
+typedef struct
+{
+	//------------- Word 0 -------------//
+	uint32_t next;
+
+	//------------- Word 1 -------------//
+	uint16_t mode            : 2; // either normal or ATLE(auto length extraction)
+	uint16_t is_next_valid   : 1;
+	uint16_t                 : 1;
+	uint16_t is_isochronous  : 1; // is an iso endpoint
+	uint16_t max_packet_size : 11;
+	volatile uint16_t buffer_length;
+
+	//------------- Word 2 -------------//
+	volatile uint8_t* buffer_start_addr;
+
+	//------------- Word 3 -------------//
+	volatile uint16_t is_retired                   : 1; // initialized to zero
+	volatile uint16_t status                       : 4;
+	volatile uint16_t iso_last_packet_valid        : 1;
+	volatile uint16_t atle_is_lsb_extracted        : 1;	// used in ATLE mode
+	volatile uint16_t atle_is_msb_extracted        : 1;	// used in ATLE mode
+	volatile uint16_t atle_message_length_position : 6; // used in ATLE mode
+	uint16_t                                       : 2;
+	volatile uint16_t present_count; // The number of bytes transferred by the DMA engine. The DMA engine updates this field after completing each packet transfer.
+
+	//------------- Word 4 -------------//
+//	uint32_t iso_packet_size_addr;		// iso only, can be omitted for non-iso
+} ATTR_ALIGNED(4) dcd_dma_descriptor_t;
+
+#define DCD_DD_NUM 10 // TODO scale with configure
+typedef struct {
+  dcd_dma_descriptor_t dd[DCD_DD_NUM];
+
+}dcd_data_t;
+
 #ifdef __cplusplus
  }
 #endif