diff options
| author | hathach <[email protected]> | 2013-02-06 12:03:01 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-02-06 12:03:01 +0700 |
| commit | e20025b54d16deccbd6e86433f31d80f5a976fd4 (patch) | |
| tree | b94fc6905de315cc5ce3778d297cc711cc195f0f | |
| parent | aeccdfde3f4462fae5e3b9cbb4eae76526bdb204 (diff) | |
refractor move test enum to its own file
add assert with handler
add task assert with error catcher
| -rw-r--r-- | .cproject | 487 | ||||
| -rw-r--r-- | tests/project.yml | 3 | ||||
| -rw-r--r-- | tests/test/host/test_enum_task.c | 191 | ||||
| -rw-r--r-- | tests/test/host/test_usbh.c | 116 | ||||
| -rw-r--r-- | tests/test/support/descriptor_test.c | 2 | ||||
| -rw-r--r-- | tests/test/support/descriptor_test.h | 3 | ||||
| -rw-r--r-- | tests/test/support/tusb_callback.h | 71 | ||||
| -rw-r--r-- | tinyusb/class/hid_host.c | 2 | ||||
| -rw-r--r-- | tinyusb/common/assertion.h | 14 | ||||
| -rw-r--r-- | tinyusb/common/common.h | 3 | ||||
| -rw-r--r-- | tinyusb/common/errors.h | 1 | ||||
| -rw-r--r-- | tinyusb/host/hcd.h | 6 | ||||
| -rw-r--r-- | tinyusb/host/usbh.c | 10 | ||||
| -rw-r--r-- | tinyusb/host/usbh.h | 10 | ||||
| -rw-r--r-- | tinyusb/osal/osal.h | 7 | ||||
| -rw-r--r-- | tinyusb/osal/osal_none.h | 16 |
16 files changed, 404 insertions, 538 deletions
@@ -11,34 +11,39 @@ <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> </extensions> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> - <configuration artifactName="${ProjName}" buildProperties="" description="" id="com.crt.advproject.toolchain.exe.debug.1281391870" name="Debug" parent="org.eclipse.cdt.build.core.emptycfg"> + <configuration artifactName="${ProjName}" buildProperties="" description="" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser;org.eclipse.cdt.core.MakeErrorParser" id="com.crt.advproject.toolchain.exe.debug.1281391870" name="Debug" parent="org.eclipse.cdt.build.core.emptycfg"> <folderInfo id="com.crt.advproject.toolchain.exe.debug.1281391870.1757637439" name="/" resourcePath=""> - <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.base.248496218" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.base"> - <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.PE" id="cdt.managedbuild.target.gnu.platform.mingw.base.123743094" name="Debug Platform" osList="win32" superClass="cdt.managedbuild.target.gnu.platform.mingw.base"/> - <builder buildPath="${workspace_loc:/tinyusb/Debug}" command="rake.bat" id="cdt.managedbuild.target.gnu.builder.base.116607615" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/> - <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.base.1462015373" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.base"> - <option id="gnu.both.asm.option.include.paths.1191135150" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath"> + <toolChain errorParsers="" id="cdt.managedbuild.toolchain.gnu.mingw.base.760207820" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.base"> + <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.PE" id="cdt.managedbuild.target.gnu.platform.mingw.base.1767850371" name="Debug Platform" osList="win32" superClass="cdt.managedbuild.target.gnu.platform.mingw.base"/> + <builder buildPath="${workspace_loc:/tinyusb/Debug}" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator" id="cdt.managedbuild.builder.gnu.cross.972264119" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/> + <tool errorParsers="org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.tool.gnu.assembler.mingw.base.232020028" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.base"> + <option id="gnu.both.asm.option.include.paths.186595949" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath"> <listOptionValue builtIn="false" value=""C:\nxp\LPCXpresso_4.3.0_1023\lpcxpresso\Tools\lib\gcc\arm-none-eabi\4.5.1\include""/> <listOptionValue builtIn="false" value=""C:\nxp\LPCXpresso_4.3.0_1023\lpcxpresso\Tools\lib\gcc\arm-none-eabi\4.5.1\include-fixed""/> <listOptionValue builtIn="false" value=""C:\nxp\LPCXpresso_4.3.0_1023\lpcxpresso\Tools\arm-none-eabi\include""/> </option> - <inputType id="cdt.managedbuild.tool.gnu.assembler.input.820249915" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.2093181178" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> </tool> - <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1971628796" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/> - <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.base.1549929089" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.base"/> - <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.base.1352687236" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.base"> - <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1754985414" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> + <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.1485867060" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.base.694786126" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.base"/> + <tool errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="cdt.managedbuild.tool.gnu.c.compiler.mingw.base.1588045403" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.base"> + <option id="gnu.c.compiler.option.preprocessor.def.symbols.1484610767" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> + <listOptionValue builtIn="false" value="__BASE_FILE__=__FILE__"/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.451457393" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/> </tool> - <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.2070776537" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base"> - <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1107767356" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> + <tool errorParsers="org.eclipse.cdt.core.GLDErrorParser" id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.1896871485" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base"> + <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1762310351" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/> </inputType> </tool> - <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.1796109719" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base"/> + <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.420552955" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base"/> </toolChain> </folderInfo> <sourceEntries> @@ -98,38 +103,66 @@ </infoList> </TargetConfig></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> <storageModule moduleId="scannerConfiguration"> <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> - <profile id="com.crt.advproject.GCCManagedMakePerProjectProfileCPP"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-c++" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="com.crt.advproject.GCCManagedMakePerProjectProfile"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file} " command="arm-none-eabi-gcc" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="com.crt.advproject.GASManagedMakePerProjectProfile"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-x assembler-with-cpp -E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-gcc" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> <buildOutputProvider> <openAction enabled="true" filePath=""/> @@ -140,16 +173,6 @@ <parser enabled="true"/> </scannerInfoProvider> </profile> - <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="makefileGenerator"> - <runAction arguments="-E -P -v -dD" command="" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> <buildOutputProvider> <openAction enabled="true" filePath=""/> @@ -180,68 +203,8 @@ <parser enabled="true"/> </scannerInfoProvider> </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> <scannerConfigBuildInfo instanceId="com.crt.advproject.toolchain.exe.debug.1281391870.909223166;com.crt.advproject.toolchain.exe.debug.1281391870.909223166.;cdt.managedbuild.tool.gnu.c.compiler.mingw.base.1123347799;cdt.managedbuild.tool.gnu.c.compiler.input.1476468867"> <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> - <profile id="com.crt.advproject.GCCManagedMakePerProjectProfileCPP"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-c++" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="com.crt.advproject.GCCManagedMakePerProjectProfile"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file} " command="arm-none-eabi-gcc" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="com.crt.advproject.GASManagedMakePerProjectProfile"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-x assembler-with-cpp -E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-gcc" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> <buildOutputProvider> <openAction enabled="true" filePath=""/> @@ -252,16 +215,6 @@ <parser enabled="true"/> </scannerInfoProvider> </profile> - <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="makefileGenerator"> - <runAction arguments="-E -P -v -dD" command="" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> <buildOutputProvider> <openAction enabled="true" filePath=""/> @@ -292,69 +245,9 @@ <parser enabled="true"/> </scannerInfoProvider> </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> </scannerConfigBuildInfo> <scannerConfigBuildInfo instanceId="com.crt.advproject.toolchain.exe.debug.1281391870;com.crt.advproject.toolchain.exe.debug.1281391870.1757637439;com.crt.advproject.gcc.exe.debug.872963007;com.crt.advproject.compiler.input.2103556147"> <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.crt.advproject.GCCManagedMakePerProjectProfile"/> - <profile id="com.crt.advproject.GCCManagedMakePerProjectProfileCPP"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-c++" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="com.crt.advproject.GCCManagedMakePerProjectProfile"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file} " command="arm-none-eabi-gcc" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="com.crt.advproject.GASManagedMakePerProjectProfile"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-x assembler-with-cpp -E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-gcc" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> <buildOutputProvider> <openAction enabled="true" filePath=""/> @@ -365,16 +258,6 @@ <parser enabled="true"/> </scannerInfoProvider> </profile> - <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="makefileGenerator"> - <runAction arguments="-E -P -v -dD" command="" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> <buildOutputProvider> <openAction enabled="true" filePath=""/> @@ -405,69 +288,9 @@ <parser enabled="true"/> </scannerInfoProvider> </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> </scannerConfigBuildInfo> <scannerConfigBuildInfo instanceId="com.crt.advproject.toolchain.exe.debug.1281391870;com.crt.advproject.toolchain.exe.debug.1281391870.1757637439;cdt.managedbuild.tool.gnu.c.compiler.mingw.base.1352687236;cdt.managedbuild.tool.gnu.c.compiler.input.1754985414"> <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> - <profile id="com.crt.advproject.GCCManagedMakePerProjectProfileCPP"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-c++" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="com.crt.advproject.GCCManagedMakePerProjectProfile"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file} " command="arm-none-eabi-gcc" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="com.crt.advproject.GASManagedMakePerProjectProfile"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-x assembler-with-cpp -E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-gcc" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> <buildOutputProvider> <openAction enabled="true" filePath=""/> @@ -478,16 +301,6 @@ <parser enabled="true"/> </scannerInfoProvider> </profile> - <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="makefileGenerator"> - <runAction arguments="-E -P -v -dD" command="" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> <buildOutputProvider> <openAction enabled="true" filePath=""/> @@ -518,69 +331,52 @@ <parser enabled="true"/> </scannerInfoProvider> </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="com.crt.advproject.toolchain.exe.debug.1281391870;com.crt.advproject.toolchain.exe.debug.1281391870.1757637439;cdt.managedbuild.tool.gnu.c.compiler.mingw.base.1588045403;cdt.managedbuild.tool.gnu.c.compiler.input.451457393"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/> + <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> <buildOutputProvider> <openAction enabled="true" filePath=""/> <parser enabled="true"/> </buildOutputProvider> <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> + <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> <parser enabled="true"/> </scannerInfoProvider> </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> + <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> <buildOutputProvider> <openAction enabled="true" filePath=""/> <parser enabled="true"/> </buildOutputProvider> <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> + <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/> <parser enabled="true"/> </scannerInfoProvider> </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> + <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"> <buildOutputProvider> <openAction enabled="true" filePath=""/> <parser enabled="true"/> </buildOutputProvider> <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - </scannerConfigBuildInfo> - <scannerConfigBuildInfo instanceId="com.crt.advproject.toolchain.exe.debug.1281391870;com.crt.advproject.toolchain.exe.debug.1281391870.1757637439;com.crt.advproject.gas.exe.debug.11272906;com.crt.advproject.assembler.input.1065303549"> - <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.crt.advproject.GCCManagedMakePerProjectProfile"/> - <profile id="com.crt.advproject.GCCManagedMakePerProjectProfileCPP"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-c++" useDefault="true"/> + <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> <parser enabled="true"/> </scannerInfoProvider> </profile> - <profile id="com.crt.advproject.GCCManagedMakePerProjectProfile"> + <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> - </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file} " command="arm-none-eabi-gcc" useDefault="true"/> + <openAction enabled="true" filePath=""/> <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="com.crt.advproject.GASManagedMakePerProjectProfile"> - <buildOutputProvider> - <openAction enabled="false" filePath=""/> - <parser enabled="false"/> </buildOutputProvider> - <scannerInfoProvider id="com.crt.advproject.specsFile"> - <runAction arguments="-x assembler-with-cpp -E -P -v -dD ${plugin_state_location}/${specs_file}" command="arm-none-eabi-gcc" useDefault="true"/> + <scannerInfoProvider id="specsFile"> + <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> <parser enabled="true"/> </scannerInfoProvider> </profile> + </scannerConfigBuildInfo> + <scannerConfigBuildInfo instanceId="com.crt.advproject.toolchain.exe.debug.1281391870;com.crt.advproject.toolchain.exe.debug.1281391870.1757637439;com.crt.advproject.gas.exe.debug.11272906;com.crt.advproject.assembler.input.1065303549"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.crt.advproject.GCCManagedMakePerProjectProfile"/> <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"> <buildOutputProvider> <openAction enabled="true" filePath=""/> @@ -591,16 +387,6 @@ <parser enabled="true"/> </scannerInfoProvider> </profile> - <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="makefileGenerator"> - <runAction arguments="-E -P -v -dD" command="" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"> <buildOutputProvider> <openAction enabled="true" filePath=""/> @@ -631,92 +417,7 @@ <parser enabled="true"/> </scannerInfoProvider> </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/${specs_file}"'" command="sh" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'g++ -E -P -v -dD "${plugin_state_location}/specs.cpp"'" command="sh" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> - <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"> - <buildOutputProvider> - <openAction enabled="true" filePath=""/> - <parser enabled="true"/> - </buildOutputProvider> - <scannerInfoProvider id="specsFile"> - <runAction arguments="-c 'gcc -E -P -v -dD "${plugin_state_location}/specs.c"'" command="sh" useDefault="true"/> - <parser enabled="true"/> - </scannerInfoProvider> - </profile> </scannerConfigBuildInfo> </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"/> + <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> </cproject> diff --git a/tests/project.yml b/tests/project.yml index 54da541dd..54a07be6f 100644 --- a/tests/project.yml +++ b/tests/project.yml @@ -88,6 +88,7 @@ :load_paths: - vendor/ceedling/plugins :enabled: - - stdout_pretty_tests_report + #- stdout_pretty_tests_report + - stdout_ide_tests_report - module_generator ... diff --git a/tests/test/host/test_enum_task.c b/tests/test/host/test_enum_task.c new file mode 100644 index 000000000..8c57cc85b --- /dev/null +++ b/tests/test/host/test_enum_task.c @@ -0,0 +1,191 @@ +/* + * test_enum_task.c + * + * Created on: Feb 5, 2013 + * Author: hathach + */ + +/* + * Software License Agreement (BSD License) + * Copyright (c) 2012, hathach (tinyusb.net) + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 tiny usb stack. + */ + +#include "unity.h" +#include "errors.h" +#include "usbh.h" +#include "descriptor_test.h" +#include "mock_osal.h" +#include "mock_hcd.h" +#include "mock_usbh_hcd.h" +#include "mock_tusb_callback.h" + +extern usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX]; +extern usbh_device_addr0_t device_addr0; +tusb_handle_device_t dev_hdl; +pipe_handle_t pipe_addr0 = 12; + +usbh_enumerate_t const enum_connect = { + .core_id = 0, + .hub_addr = 0, + .hub_port = 0, + .connect_status = 1 +}; + +void queue_recv_stub (osal_queue_handle_t const queue_hdl, uint32_t *p_data, uint32_t msec, tusb_error_t *p_error, int num_call); +void semaphore_wait_success_stub(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error, int num_call); +tusb_error_t control_xfer_stub(pipe_handle_t pipe_hdl, const tusb_std_request_t * const p_request, uint8_t data[], int num_call); + +void setUp(void) +{ + memclr_(usbh_device_info_pool, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX); + + osal_queue_receive_StubWithCallback(queue_recv_stub); + osal_semaphore_wait_StubWithCallback(semaphore_wait_success_stub); + hcd_pipe_control_xfer_StubWithCallback(control_xfer_stub); + + hcd_port_connect_status_ExpectAndReturn(enum_connect.core_id, true); + hcd_port_speed_ExpectAndReturn(enum_connect.core_id, TUSB_SPEED_FULL); + + hcd_addr0_open_IgnoreAndReturn(TUSB_ERROR_NONE); + hcd_addr0_close_IgnoreAndReturn(TUSB_ERROR_NONE); +} + +void tearDown(void) +{ +} + +//--------------------------------------------------------------------+ +// STUB & HELPER +//--------------------------------------------------------------------+ +void queue_recv_stub (osal_queue_handle_t const queue_hdl, uint32_t *p_data, uint32_t msec, tusb_error_t *p_error, int num_call) +{ + (*p_data) = ( *((uint32_t*) &enum_connect) ); + (*p_error) = TUSB_ERROR_NONE; +} + +void semaphore_wait_success_stub(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error, int num_call) +{ + (*p_error) = TUSB_ERROR_NONE; +} + +#define semaphore_wait_timeout_stub(n) semaphore_wait_timeout_##n +#define semaphore_wait_timeout(n) \ + void semaphore_wait_timeout_##n(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error, int num_call) {\ + if (num_call >= n)\ + (*p_error) = TUSB_ERROR_OSAL_TIMEOUT;\ + else \ + (*p_error) = TUSB_ERROR_NONE;\ + } + +semaphore_wait_timeout(0) +semaphore_wait_timeout(1) +semaphore_wait_timeout(2) +semaphore_wait_timeout(3) +semaphore_wait_timeout(4) + +tusb_error_t control_xfer_stub(pipe_handle_t pipe_hdl, const tusb_std_request_t * const p_request, uint8_t data[], int num_call) +{ + switch (num_call) + { + case 0: // get 8 bytes of device descriptor + TEST_ASSERT_EQUAL(TUSB_REQUEST_GET_DESCRIPTOR, p_request->bRequest); + TEST_ASSERT_EQUAL(TUSB_DESC_DEVICE, p_request->wValue >> 8); + TEST_ASSERT_EQUAL(8, p_request->wLength); + memcpy(data, &desc_device, p_request->wLength); + break; + + case 1: // set device address + TEST_ASSERT_EQUAL(TUSB_REQUEST_SET_ADDRESS, p_request->bRequest); + TEST_ASSERT_EQUAL(p_request->wValue, 1); + break; + + case 2: // get full device decriptor for new address + TEST_ASSERT_EQUAL(TUSB_REQUEST_GET_DESCRIPTOR, p_request->bRequest); + TEST_ASSERT_EQUAL(TUSB_DESC_DEVICE, p_request->wValue >> 8); + TEST_ASSERT_EQUAL(18, p_request->wLength); + memcpy(data, &desc_device, p_request->wLength); + break; + + case 3: // get 9 bytes of configuration descriptor + TEST_ASSERT_EQUAL(TUSB_REQUEST_GET_DESCRIPTOR, p_request->bRequest); + TEST_ASSERT_EQUAL(TUSB_DESC_CONFIGURATION, p_request->wValue >> 8); + TEST_ASSERT_EQUAL(9, p_request->wLength); + memcpy(data, &desc_configuration, p_request->wLength); + break; + + case 4: // get full-length configuration descriptor + TEST_ASSERT_EQUAL(TUSB_REQUEST_GET_DESCRIPTOR, p_request->bRequest); + TEST_ASSERT_EQUAL(TUSB_DESC_CONFIGURATION, p_request->wValue >> 8); + TEST_ASSERT_EQUAL(desc_configuration.configuration.wTotalLength, p_request->wLength); + memcpy(data, &desc_configuration, p_request->wLength); + break; + } + + return TUSB_ERROR_NONE; +} + +//--------------------------------------------------------------------+ +// enum connect directed +//--------------------------------------------------------------------+ +void test_failed_get_first_dev_desc(void) +{ + osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(0)); + tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_FAILED, NULL); + + usbh_enumeration_task(); +} + +void test_enum_task_connect(void) +{ + + usbh_enumeration_task(); + + TEST_ASSERT_EQUAL(TUSB_DEVICE_STATUS_ADDRESSED, usbh_device_info_pool[0].status); + TEST_ASSERT_EQUAL(TUSB_SPEED_FULL, usbh_device_info_pool[0].speed); + TEST_ASSERT_EQUAL(enum_connect.core_id, usbh_device_info_pool[0].core_id); + TEST_ASSERT_EQUAL(enum_connect.hub_addr, usbh_device_info_pool[0].hub_addr); + TEST_ASSERT_EQUAL(enum_connect.hub_port, usbh_device_info_pool[0].hub_port); + +// hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE); + +} + +void test_enum_task_disconnect(void) +{ + TEST_IGNORE(); +} + +void test_enum_task_connect_via_hub(void) +{ + TEST_IGNORE(); +} + +void test_enum_task_disconnect_via_hub(void) +{ + TEST_IGNORE(); +} diff --git a/tests/test/host/test_usbh.c b/tests/test/host/test_usbh.c index 911756ede..e0fc003ee 100644 --- a/tests/test/host/test_usbh.c +++ b/tests/test/host/test_usbh.c @@ -38,7 +38,6 @@ #include "unity.h" #include "errors.h" #include "usbh.h" -#include "descriptor_test.h" #include "mock_osal.h" #include "mock_hcd.h" #include "mock_usbh_hcd.h" @@ -83,13 +82,12 @@ void test_usbh_init_queue_create_failed(void) TEST_ASSERT_EQUAL(TUSB_ERROR_OSAL_QUEUE_FAILED, usbh_init()); } - void test_usbh_init_ok(void) { uint32_t dummy; usbh_device_info_t device_info_zero[TUSB_CFG_HOST_DEVICE_MAX]; - memset(device_info_zero, 0, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX); + memclr_(device_info_zero, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX); for(uint32_t i=0; i<TUSB_CFG_HOST_CONTROLLER_NUM; i++) hcd_init_ExpectAndReturn(i, TUSB_ERROR_NONE); @@ -115,115 +113,3 @@ void test_usbh_status_get_succeed(void) usbh_device_info_pool[dev_hdl].status = TUSB_DEVICE_STATUS_READY; TEST_ASSERT_EQUAL( TUSB_DEVICE_STATUS_READY, tusbh_device_status_get(dev_hdl) ); } - -//--------------------------------------------------------------------+ -// enum task -//--------------------------------------------------------------------+ -extern osal_queue_handle_t enum_queue_hdl; -usbh_enumerate_t enum_connect = -{ - .core_id = 0, - .hub_addr = 0, - .hub_port = 0, - .connect_status = 1 -}; -extern usbh_device_addr0_t device_addr0; - - -void queue_recv_stub (osal_queue_handle_t const queue_hdl, uint32_t *p_data, uint32_t msec, tusb_error_t *p_error, int num_call) -{ - TEST_ASSERT_EQUAL_PTR(enum_queue_hdl, queue_hdl); - (*p_data) = ( *((uint32_t*) &enum_connect) ); - (*p_error) = TUSB_ERROR_NONE; -} - -void semaphore_wait_stub(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error, int num_call) -{ - (*p_error) = TUSB_ERROR_NONE; -} - -tusb_error_t get_device_desc_stub(pipe_handle_t pipe_hdl, const tusb_std_request_t * const p_request, uint8_t data[], int num_call) -{ - TEST_ASSERT(num_call < 2); - TEST_ASSERT_EQUAL(TUSB_REQUEST_GET_DESCRIPTOR, p_request->bRequest); - TEST_ASSERT_EQUAL(TUSB_DESC_DEVICE, p_request->wValue >> 8); - - memcpy(data, &desc_device, p_request->wLength); - - return TUSB_ERROR_NONE; -} - -tusb_error_t set_device_addr_stub(pipe_handle_t pipe_hdl, const tusb_std_request_t * const p_request, uint8_t data[], int num_call) -{ - TEST_ASSERT_EQUAL(TUSB_REQUEST_SET_ADDRESS, p_request->bRequest); - TEST_ASSERT_EQUAL(p_request->wValue, 1); - return TUSB_ERROR_NONE; -} - -tusb_error_t get_configuration_desc_stub(pipe_handle_t pipe_hdl, const tusb_std_request_t * const p_request, uint8_t data[], int num_call) -{ - TEST_ASSERT(num_call < 2); - - TEST_ASSERT_EQUAL(TUSB_REQUEST_GET_DESCRIPTOR, p_request->bRequest); - TEST_ASSERT_EQUAL(TUSB_DESC_CONFIGURATION, p_request->wValue >> 8); - - memcpy(data, &desc_device, p_request->wLength); - - return TUSB_ERROR_NONE; -} - -void test_enum_task_connect(void) -{ - pipe_handle_t pipe_addr0 = 12; - - osal_queue_receive_StubWithCallback(queue_recv_stub); - hcd_port_connect_status_ExpectAndReturn(enum_connect.core_id, true); - hcd_port_speed_ExpectAndReturn(enum_connect.core_id, TUSB_SPEED_FULL); - - { - hcd_addr0_open_IgnoreAndReturn(TUSB_ERROR_NONE); - - // get 8-byte of device descriptor - hcd_pipe_control_xfer_StubWithCallback(get_device_desc_stub); - osal_semaphore_wait_StubWithCallback(semaphore_wait_stub); - // set device address - hcd_pipe_control_xfer_StubWithCallback(set_device_addr_stub); - osal_semaphore_wait_StubWithCallback(semaphore_wait_stub); - - hcd_addr0_close_IgnoreAndReturn(TUSB_ERROR_NONE); - } - - usbh_enumeration_task(); - - TEST_ASSERT_EQUAL(TUSB_DEVICE_STATUS_ADDRESSED, usbh_device_info_pool[0].status); - TEST_ASSERT_EQUAL(TUSB_SPEED_FULL, usbh_device_info_pool[0].speed); - TEST_ASSERT_EQUAL(enum_connect.core_id, usbh_device_info_pool[0].core_id); - TEST_ASSERT_EQUAL(enum_connect.hub_addr, usbh_device_info_pool[0].hub_addr); - TEST_ASSERT_EQUAL(enum_connect.hub_port, usbh_device_info_pool[0].hub_port); - - hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE); - - hcd_pipe_control_xfer_StubWithCallback(get_device_desc_stub); // get full device descriptor - osal_semaphore_wait_StubWithCallback(semaphore_wait_stub); - - hcd_pipe_control_xfer_StubWithCallback(get_configuration_desc_stub); // get 9 bytes of configuration descriptor - osal_semaphore_wait_StubWithCallback(semaphore_wait_stub); - - hcd_pipe_control_xfer_StubWithCallback(get_configuration_desc_stub); // get full-length configuration descriptor - osal_semaphore_wait_StubWithCallback(semaphore_wait_stub); -} - -void test_enum_task_disconnect(void) -{ - TEST_IGNORE(); -} - -void test_enum_task_connect_via_hub(void) -{ - TEST_IGNORE(); -} - -void test_enum_task_disconnect_via_hub(void) -{ - TEST_IGNORE(); -} diff --git a/tests/test/support/descriptor_test.c b/tests/test/support/descriptor_test.c index bbc5c72c6..7851716ad 100644 --- a/tests/test/support/descriptor_test.c +++ b/tests/test/support/descriptor_test.c @@ -39,7 +39,7 @@ #include "descriptor_test.h" TUSB_CFG_ATTR_USBRAM ATTR_ALIGNED(4) -tusb_descriptor_device_t desc_device = +tusb_descriptor_device_t const desc_device = { .bLength = sizeof(tusb_descriptor_device_t), .bDescriptorType = TUSB_DESC_DEVICE, diff --git a/tests/test/support/descriptor_test.h b/tests/test/support/descriptor_test.h index 71f6351c9..70694b1b7 100644 --- a/tests/test/support/descriptor_test.h +++ b/tests/test/support/descriptor_test.h @@ -98,7 +98,8 @@ typedef struct unsigned char ConfigDescTermination; } app_configuration_desc_t; -extern tusb_descriptor_device_t desc_device; +extern tusb_descriptor_device_t const desc_device; +extern app_configuration_desc_t const desc_configuration; #ifdef __cplusplus } diff --git a/tests/test/support/tusb_callback.h b/tests/test/support/tusb_callback.h new file mode 100644 index 000000000..5a6e11eb5 --- /dev/null +++ b/tests/test/support/tusb_callback.h @@ -0,0 +1,71 @@ +/* + * tusb_callback.h + * + * Created on: Feb 5, 2013 + * Author: hathach + */ + +/* + * Software License Agreement (BSD License) + * Copyright (c) 2012, hathach (tinyusb.net) + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 tiny usb 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" + +uint8_t tusbh_device_attached_cb (tusb_descriptor_device_t const *p_desc_device) ATTR_WEAK ATTR_WARN_UNUSED_RESULT; +void tusbh_device_mounted_cb (tusb_handle_device_t device_hdl) 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_ */ + +/** @} */ diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c index eeed7cb0b..07abb7e6a 100644 --- a/tinyusb/class/hid_host.c +++ b/tinyusb/class/hid_host.c @@ -91,7 +91,7 @@ uint8_t tusbh_hid_keyboard_no_instances(tusb_handle_device_t const device_hdl) //--------------------------------------------------------------------+ void class_hid_keyboard_init(void) { - memset(&keyboard_info_pool, 0, sizeof(class_hid_keyboard_info_t)*TUSB_CFG_HOST_DEVICE_MAX); + memclr_(&keyboard_info_pool, sizeof(class_hid_keyboard_info_t)*TUSB_CFG_HOST_DEVICE_MAX); } tusb_error_t class_hid_keyboard_install(uint8_t const dev_addr, uint8_t const *descriptor) diff --git a/tinyusb/common/assertion.h b/tinyusb/common/assertion.h index f6aff004e..e8ce24c0a 100644 --- a/tinyusb/common/assertion.h +++ b/tinyusb/common/assertion.h @@ -69,25 +69,25 @@ extern "C" // Assert Helper //--------------------------------------------------------------------+ #define ASSERT_MESSAGE(format, ...)\ - _PRINTF("Assert at %s: %s:%d: " format "\n", __FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__) + _PRINTF("Assert at %s %s %d: " format "\n", __BASE_FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__) #ifndef _TEST_ASSERT_ - #define ASSERT_ERROR_HANDLER(x) return (x) + #define ASSERT_ERROR_HANDLER(x, para) return (x) #else - #define ASSERT_ERROR_HANDLER(x) Throw(x) + #define ASSERT_ERROR_HANDLER(x, para) Throw(x) #endif -#define ASSERT_DEFINE(...) ASSERT_DEFINE_WITH_HANDLER(ASSERT_ERROR_HANDLER, __VA_ARGS__) - -#define ASSERT_DEFINE_WITH_HANDLER(error_handler, setup_statement, condition, error, format, ...) \ +#define ASSERT_DEFINE_WITH_HANDLER(error_handler, handler_para, setup_statement, condition, error, format, ...) \ do{\ setup_statement;\ if (!(condition)) {\ ASSERT_MESSAGE(format, __VA_ARGS__);\ - error_handler(error);\ + error_handler(error, handler_para);\ }\ }while(0) +#define ASSERT_DEFINE(...) ASSERT_DEFINE_WITH_HANDLER(ASSERT_ERROR_HANDLER, NULL, __VA_ARGS__) + //--------------------------------------------------------------------+ // tusb_error_t Status Assert TODO use ASSERT_DEFINE //--------------------------------------------------------------------+ diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h index 403ca5d6c..a3c8cfef5 100644 --- a/tinyusb/common/common.h +++ b/tinyusb/common/common.h @@ -98,6 +98,9 @@ #define U32_TO_U8S_BE(u32) U32_B1_U8(u32), U32_B2_U8(u32), U32_B3_U8(u32), U32_B4_U8(u32) #define U32_TO_U8S_LE(u32) U32_B4_U8(u32), U32_B3_U8(u32), U32_B2_U8(u32), U32_B1_U8(u32) + +#define memclr_(buffer, size) memset(buffer, 0, size) + /// form an uint32_t from 4 x uint8_t static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) ATTR_ALWAYS_INLINE ATTR_CONST; static inline uint32_t u32_from_u8(uint8_t b1, uint8_t b2, uint8_t b3, uint8_t b4) diff --git a/tinyusb/common/errors.h b/tinyusb/common/errors.h index 2d8a80e22..42a7a3975 100644 --- a/tinyusb/common/errors.h +++ b/tinyusb/common/errors.h @@ -66,6 +66,7 @@ ENTRY(TUSB_ERROR_CLASS_DEVICE_DONT_SUPPORT)\ ENTRY(TUSB_ERROR_CLASS_DATA_NOT_AVAILABLE)\ ENTRY(TUSB_ERROR_HCD_FAILED)\ + ENTRY(TUSB_ERROR_USBH_MOUNT_FAILED)\ ENTRY(TUSB_ERROR_OSAL_TIMEOUT)\ ENTRY(TUSB_ERROR_OSAL_TASK_FAILED)\ ENTRY(TUSB_ERROR_OSAL_QUEUE_FAILED)\ diff --git a/tinyusb/host/hcd.h b/tinyusb/host/hcd.h index db16ce869..079a0c4f3 100644 --- a/tinyusb/host/hcd.h +++ b/tinyusb/host/hcd.h @@ -71,9 +71,9 @@ tusb_error_t hcd_init(uint8_t hostid) ATTR_WARN_UNUSED_RESULT; //--------------------------------------------------------------------+ // PIPE API //--------------------------------------------------------------------+ -pipe_handle_t hcd_pipe_control_open(uint8_t dev_addr, uint8_t max_packet_size); -tusb_error_t hcd_pipe_control_xfer(pipe_handle_t pipe_hdl, tusb_std_request_t const * p_request, uint8_t data[]); -pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * endpoint_desc); +pipe_handle_t hcd_pipe_control_open(uint8_t dev_addr, uint8_t max_packet_size) ATTR_WARN_UNUSED_RESULT; +tusb_error_t hcd_pipe_control_xfer(pipe_handle_t pipe_hdl, tusb_std_request_t const * p_request, uint8_t data[]) ATTR_WARN_UNUSED_RESULT; +pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * endpoint_desc) ATTR_WARN_UNUSED_RESULT; #if 0 //tusb_error_t hcd_pipe_open( diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index ffdb2769f..371514748 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -89,16 +89,14 @@ void usbh_enumeration_task(void) OSAL_TASK_LOOP_BEGIN - osal_queue_receive(enum_queue_hdl, (uint32_t*)(&device_addr0.enum_entry), OSAL_TIMEOUT_NORMAL, &error); - TASK_ASSERT_STATUS(error); + osal_queue_receive(enum_queue_hdl, (uint32_t*)(&device_addr0.enum_entry), OSAL_TIMEOUT_WAIT_FOREVER, &error); if (device_addr0.enum_entry.hub_addr == 0) // direct connection { TASK_ASSERT(device_addr0.enum_entry.connect_status == hcd_port_connect_status(device_addr0.enum_entry.core_id)); // there chances the event is out-dated device_addr0.speed = hcd_port_speed(device_addr0.enum_entry.core_id); - error = hcd_addr0_open(&device_addr0); - TASK_ASSERT_STATUS(error); + TASK_ASSERT_STATUS( hcd_addr0_open(&device_addr0) ); { // Get first 8 bytes of device descriptor to get Control Endpoint Size tusb_std_request_t request_device_desc = { @@ -110,7 +108,7 @@ void usbh_enumeration_task(void) hcd_pipe_control_xfer(device_addr0.pipe_hdl, &request_device_desc, enum_data_buffer); osal_semaphore_wait(device_addr0.sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // careful of local variable without static - TASK_ASSERT_STATUS(error); + TASK_ASSERT_STATUS_HANDLER(error, tusbh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_FAILED, NULL)); } new_addr = get_new_address(); @@ -158,7 +156,7 @@ tusb_error_t usbh_init(void) { uint32_t i; - memset(usbh_device_info_pool, 0, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX); + memclr_(usbh_device_info_pool, sizeof(usbh_device_info_t)*TUSB_CFG_HOST_DEVICE_MAX); for(i=0; i<TUSB_CFG_HOST_CONTROLLER_NUM; i++) { diff --git a/tinyusb/host/usbh.h b/tinyusb/host/usbh.h index 03d6cbbc2..2d9c44a85 100644 --- a/tinyusb/host/usbh.h +++ b/tinyusb/host/usbh.h @@ -127,9 +127,11 @@ typedef uint8_t tusbh_device_status_t; //--------------------------------------------------------------------+ // APPLICATION API //--------------------------------------------------------------------+ -void tusbh_device_mounting_cb (tusb_error_t const error, tusb_handle_device_t const device_hdl); -void tusbh_device_mounted_cb (tusb_error_t const error, tusb_handle_device_t const device_hdl); -tusb_error_t tusbh_configuration_set (tusb_handle_device_t const device_hdl, uint8_t const configure_number) ATTR_WARN_UNUSED_RESULT; +uint8_t tusbh_device_attached_cb (tusb_descriptor_device_t const *p_desc_device) ATTR_WEAK ATTR_WARN_UNUSED_RESULT; +void tusbh_device_mounted_cb (tusb_handle_device_t device_hdl) ATTR_WEAK; +void tusbh_device_mount_failed_cb(tusb_error_t error, tusb_descriptor_device_t const *p_desc_device) ATTR_WEAK; + +tusb_error_t tusbh_configuration_set (tusb_handle_device_t device_hdl, uint8_t configure_number) ATTR_WARN_UNUSED_RESULT; tusbh_device_status_t tusbh_device_status_get (tusb_handle_device_t const device_hdl) ATTR_WARN_UNUSED_RESULT; #if TUSB_CFG_OS == TUSB_OS_NONE // TODO move later @@ -147,7 +149,7 @@ static inline void tusb_tick_tock(void) tusb_error_t usbh_init(void); pipe_status_t usbh_pipe_status_get(pipe_handle_t pipe_hdl) ATTR_WARN_UNUSED_RESULT; -void usbh_enum_task(void); +void usbh_enumeration_task(void); #endif diff --git a/tinyusb/osal/osal.h b/tinyusb/osal/osal.h index 055f28d1a..2482695fa 100644 --- a/tinyusb/osal/osal.h +++ b/tinyusb/osal/osal.h @@ -85,10 +85,17 @@ typedef uint32_t osal_task_t; #define OSAL_TASK_LOOP_BEGIN #define OSAL_TASK_LOOP_END +#define TASK_ASSERT_ERROR_HANDLER(error, func_call)\ + func_call; return error + +#define TASK_ASSERT_STATUS_HANDLER(sts, func_call) \ + ASSERT_DEFINE_WITH_HANDLER(TASK_ASSERT_ERROR_HANDLER, func_call, tusb_error_t status = (tusb_error_t)(sts),\ + TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status]) #define TASK_ASSERT_STATUS(sts) \ ASSERT_DEFINE(tusb_error_t status = (tusb_error_t)(sts),\ TUSB_ERROR_NONE == status, (void) 0, "%s", TUSB_ErrorStr[status]) + #define TASK_ASSERT(condition) ASSERT(condition, (void) 0) tusb_error_t osal_task_create(osal_task_t *task); diff --git a/tinyusb/osal/osal_none.h b/tinyusb/osal/osal_none.h index 93f77d593..e424d4143 100644 --- a/tinyusb/osal/osal_none.h +++ b/tinyusb/osal/osal_none.h @@ -90,12 +90,16 @@ uint32_t osal_tick_get(void); state = 0;\ } -#define TASK_ASSERT_ERROR_HANDLER \ - state = 0; break; +#define TASK_ASSERT_ERROR_HANDLER(error, func_call) \ + func_call; state = 0; break -#define TASK_ASSERT(condition) ASSERT_DEFINE_WITH_HANDLER(TASK_ASSERT_ERROR_HANDLER, , (condition), (void) 0, "%s", "evaluated to false") +#define TASK_ASSERT_STATUS_HANDLER(sts, func_call) \ + ASSERT_DEFINE_WITH_HANDLER(TASK_ASSERT_ERROR_HANDLER, func_call, tusb_error_t status = (tusb_error_t)(sts),\ + TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status]) + +#define TASK_ASSERT(condition) ASSERT_DEFINE_WITH_HANDLER(TASK_ASSERT_ERROR_HANDLER, , , (condition), (void) 0, "%s", "evaluated to false") #define TASK_ASSERT_STATUS(sts) \ - ASSERT_DEFINE_WITH_HANDLER(TASK_ASSERT_ERROR_HANDLER, tusb_error_t status = (tusb_error_t)(sts),\ + ASSERT_DEFINE_WITH_HANDLER(TASK_ASSERT_ERROR_HANDLER, , tusb_error_t status = (tusb_error_t)(sts),\ TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status]) //--------------------------------------------------------------------+ // Semaphore API @@ -129,7 +133,7 @@ static inline tusb_error_t osal_semaphore_post(osal_semaphore_handle_t const se timeout = osal_tick_get();\ state = __LINE__; case __LINE__:\ if( *(sem_hdl) == 0 ) {\ - if ( timeout + osal_tick_from_msec(msec) < osal_tick_get() ) /* time out */ \ + if ( (msec != OSAL_TIMEOUT_WAIT_FOREVER) && (timeout + osal_tick_from_msec(msec) < osal_tick_get()) ) /* time out */ \ *(p_error) = TUSB_ERROR_OSAL_TIMEOUT;\ else\ return;\ @@ -194,7 +198,7 @@ static inline tusb_error_t osal_queue_send(osal_queue_handle_t const queue_hdl, timeout = osal_tick_get();\ state = __LINE__; case __LINE__:\ if( queue_hdl-> count == 0 ) {\ - if ( timeout + osal_tick_from_msec(msec) < osal_tick_get() ) /* time out */ \ + if ( (msec != OSAL_TIMEOUT_WAIT_FOREVER) && ( timeout + osal_tick_from_msec(msec) < osal_tick_get() )) /* time out */ \ *(p_error) = TUSB_ERROR_OSAL_TIMEOUT;\ else\ return;\ |
