diff options
| author | hathach <[email protected]> | 2013-01-18 14:39:42 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-01-18 14:39:42 +0700 |
| commit | d8c8b9e38ad94ab84c24f22c2ecb79ce4d78b7ba (patch) | |
| tree | 1090e26f45a534e5113f28d82f8381eef274e358 | |
| parent | 7976e2fd55d33a0bf8a74a729eb246a8842d58ee (diff) | |
add ASSERT POINTER support
add hid host and separate hid host & device
update host project setting with EA4357 board
add para checking test for hid host
| -rw-r--r-- | demos/device/keyboard/main.c | 16 | ||||
| -rw-r--r-- | demos/device/keyboard/tusb_config.h | 2 | ||||
| -rw-r--r-- | demos/host/.cproject | 444 | ||||
| -rw-r--r-- | demos/host/.project | 5 | ||||
| -rw-r--r-- | demos/host/main.c | 13 | ||||
| -rw-r--r-- | demos/host/tusb_config.h | 91 | ||||
| -rw-r--r-- | tests/project.yml | 2 | ||||
| -rw-r--r-- | tests/test/host/test_hid_host.c (renamed from tests/test/host/test_host_hid.c) | 0 | ||||
| -rw-r--r-- | tests/test/host/test_hid_host_keyboard.c (renamed from tests/test/host/test_host_hid_keyboard.c) | 11 | ||||
| -rw-r--r-- | tinyusb/class/hid.c | 10 | ||||
| -rw-r--r-- | tinyusb/class/hid.h | 56 | ||||
| -rw-r--r-- | tinyusb/class/hid_device.h | 105 | ||||
| -rw-r--r-- | tinyusb/class/hid_host.c | 51 | ||||
| -rw-r--r-- | tinyusb/class/hid_host.h | 70 | ||||
| -rw-r--r-- | tinyusb/common/assertion.h | 10 | ||||
| -rw-r--r-- | tinyusb/common/common.h | 3 |
16 files changed, 816 insertions, 73 deletions
diff --git a/demos/device/keyboard/main.c b/demos/device/keyboard/main.c index 19f2da104..324c6a51c 100644 --- a/demos/device/keyboard/main.c +++ b/demos/device/keyboard/main.c @@ -2,17 +2,19 @@ #include <stdio.h> #include <string.h> -#include <cr_section_macros.h> -#include <NXP/crp.h> #include "boards/board.h" #include "tusb.h" -// Variable to store CRP value in. Will be placed automatically -// by the linker when "Enable Code Read Protect" selected. -// See crp.h header for more information -__CRP const unsigned int CRP_WORD = CRP_NO_CRP ; +#if defined(__CODE_RED) + #include <cr_section_macros.h> + #include <NXP/crp.h> + // Variable to store CRP value in. Will be placed automatically + // by the linker when "Enable Code Read Protect" selected. + // See crp.h header for more information + __CRP const unsigned int CRP_WORD = CRP_NO_CRP ; +#endif -int main(void) +int main(void) { uint32_t current_tick = system_ticks; diff --git a/demos/device/keyboard/tusb_config.h b/demos/device/keyboard/tusb_config.h index d9cb23c4a..877b41712 100644 --- a/demos/device/keyboard/tusb_config.h +++ b/demos/device/keyboard/tusb_config.h @@ -67,6 +67,8 @@ /// Enable HID Mouse support //#define TUSB_CFG_DEVICE_HID_MOUSE +#define TUSB_CFG_DEBUG 3 + #ifdef __CODE_RED // make use of code red's support for ram region macros #if (MCU == MCU_LPC11UXX) || (MCU == MCU_LPC13UXX) #define TUSB_RAM_SECTION ".data.$RAM2" diff --git a/demos/host/.cproject b/demos/host/.cproject index e7525ec41..6d8f8efb2 100644 --- a/demos/host/.cproject +++ b/demos/host/.cproject @@ -5,6 +5,11 @@ <storageModule moduleId="org.eclipse.cdt.core.settings"> <cconfiguration id="com.crt.advproject.config.exe.debug.1239969983"> <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.exe.debug.1239969983" moduleId="org.eclipse.cdt.core.settings" name="Board NGX4330"> + <macros> + <stringMacro name="CFLAGS_OFF" type="VALUE_TEXT" value=""/> + <stringMacro name="CFLAGS" type="VALUE_TEXT" value="${CFLAGS_OFF}"/> + <stringMacro name="CFLAGS_ON" type="VALUE_TEXT" value="-pedantic -Wextra -Wswitch-default -Wunsafe-loop-optimizations -Wcast-align -Wlogical-op -Wpacked-bitfield-compat -Wpadded -Wnested-externs -Wredundant-decls -Winline -Wpacked"/> + </macros> <externalSettings/> <extensions> <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> @@ -24,11 +29,12 @@ <targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.exe.debug.1898304169" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.exe.debug"/> <builder buildPath="${workspace_loc:/host/Debug}" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator" id="com.crt.advproject.builder.exe.debug.1178085975" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.exe.debug"/> <tool id="com.crt.advproject.cpp.exe.debug.1677456292" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.exe.debug"/> - <tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="com.crt.advproject.gcc.exe.debug.597047349" name="MCU C Compiler" superClass="com.crt.advproject.gcc.exe.debug"> + <tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${CFLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="com.crt.advproject.gcc.exe.debug.597047349" name="MCU C Compiler" superClass="com.crt.advproject.gcc.exe.debug"> <option id="com.crt.advproject.gcc.arch.2146151354" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm4" valueType="enumerated"/> <option id="com.crt.advproject.gcc.thumb.1396414714" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/> <option id="gnu.c.compiler.option.preprocessor.def.symbols.161831329" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> <listOptionValue builtIn="false" value="__REDLIB__"/> + <listOptionValue builtIn="false" value="__USE_CMSIS=CMSISv2p10_LPC43xx_DriverLib"/> <listOptionValue builtIn="false" value="CORE_M4"/> <listOptionValue builtIn="false" value="MCU=MCU_LPC43XX"/> <listOptionValue builtIn="false" value="BOARD=BOARD_NGX4330"/> @@ -39,7 +45,8 @@ <option id="gnu.c.compiler.option.include.paths.970795437" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> <listOptionValue builtIn="false" value=""${workspace_loc:/CMSISv2p10_LPC43xx_DriverLib/inc}""/> <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/bsp}""/> - <listOptionValue builtIn="false" value=""${workspace_loc:/tinyusb}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/tinyusb}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}""/> </option> <option id="com.crt.advproject.c.misc.dialect.861665028" name="C Dialect" superClass="com.crt.advproject.c.misc.dialect" value="com.crt.advproject.misc.dialect.gnu99" valueType="enumerated"/> <inputType id="com.crt.advproject.compiler.input.217124913" superClass="com.crt.advproject.compiler.input"/> @@ -54,7 +61,7 @@ <tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GLDErrorParser" id="com.crt.advproject.link.exe.debug.1137849179" name="MCU Linker" superClass="com.crt.advproject.link.exe.debug"> <option id="com.crt.advproject.link.arch.1187341700" name="Architecture" superClass="com.crt.advproject.link.arch" value="com.crt.advproject.link.target.cm4" valueType="enumerated"/> <option id="com.crt.advproject.link.thumb.981715979" name="Thumb mode" superClass="com.crt.advproject.link.thumb" value="true" valueType="boolean"/> - <option id="com.crt.advproject.link.script.2116791390" name="Linker script" superClass="com.crt.advproject.link.script" value=""host_NGX4330.ld"" valueType="string"/> + <option id="com.crt.advproject.link.script.2116791390" name="Linker script" superClass="com.crt.advproject.link.script" value=""host_Board_NGX4330.ld"" valueType="string"/> <option id="com.crt.advproject.link.manage.1536072802" name="Manage linker script" superClass="com.crt.advproject.link.manage" value="true" valueType="boolean"/> <option id="gnu.c.link.option.nostdlibs.837843167" name="No startup or default libs (-nostdlib)" superClass="gnu.c.link.option.nostdlibs" value="true" valueType="boolean"/> <option id="gnu.c.link.option.other.908441611" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList"> @@ -62,14 +69,12 @@ <listOptionValue builtIn="false" value="--gc-sections"/> </option> <option id="gnu.c.link.option.libs.1088600788" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs"> - <listOptionValue builtIn="false" value="tinyusb"/> <listOptionValue builtIn="false" value="CMSISv2p10_LPC43xx_DriverLib"/> </option> <option id="gnu.c.link.option.paths.1352371726" name="Library search path (-L)" superClass="gnu.c.link.option.paths" valueType="libPaths"> <listOptionValue builtIn="false" value=""${workspace_loc:/CMSISv2p10_LPC43xx_DriverLib/Debug}""/> - <listOptionValue builtIn="false" value=""${workspace_loc:/tinyusb/lpc43xx}""/> </option> - <option id="com.crt.advproject.link.gcc.hdrlib.1912639139" name="Use C library" superClass="com.crt.advproject.link.gcc.hdrlib" value="com.crt.advproject.gcc.link.hdrlib.codered.semihost" valueType="enumerated"/> + <option id="com.crt.advproject.link.gcc.hdrlib.1912639139" name="Use C library" superClass="com.crt.advproject.link.gcc.hdrlib" value="com.crt.advproject.gcc.link.hdrlib.codered.nohost" valueType="enumerated"/> <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1768732506" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/> @@ -425,6 +430,433 @@ </storageModule> <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/> </cconfiguration> + <cconfiguration id="com.crt.advproject.config.exe.debug.1239969983.636406670"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.exe.debug.1239969983.636406670" moduleId="org.eclipse.cdt.core.settings" name="Board EA4357"> + <macros> + <stringMacro name="CFLAGS_OFF" type="VALUE_TEXT" value=""/> + <stringMacro name="CFLAGS" type="VALUE_TEXT" value="${CFLAGS_OFF}"/> + <stringMacro name="CFLAGS_ON" type="VALUE_TEXT" value="-pedantic -Wextra -Wswitch-default -Wunsafe-loop-optimizations -Wcast-align -Wlogical-op -Wpacked-bitfield-compat -Wpadded -Wnested-externs -Wredundant-decls -Winline -Wpacked"/> + </macros> + <externalSettings/> + <extensions> + <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/> + <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.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> + </extensions> + </storageModule> + <storageModule moduleId="cdtBuildSystem" version="4.0.0"> + <configuration artifactExtension="axf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="Embedded Artist" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GmakeErrorParser" id="com.crt.advproject.config.exe.debug.1239969983.636406670" name="Board EA4357" parent="com.crt.advproject.config.exe.debug" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size "${BuildArtifactFileName}"; # arm-none-eabi-objcopy -O binary "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin" ; checksum -p ${TargetChip} -d "${BuildArtifactFileBaseName}.bin"; " preannouncebuildStep="" prebuildStep=""> + <folderInfo id="com.crt.advproject.config.exe.debug.1239969983.636406670." name="/" resourcePath=""> + <toolChain errorParsers="" id="com.crt.advproject.toolchain.exe.debug.1990531949" name="Code Red MCU Tools" superClass="com.crt.advproject.toolchain.exe.debug"> + <targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.exe.debug.2049669948" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.exe.debug"/> + <builder buildPath="${workspace_loc:/host/Debug}" errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator" id="com.crt.advproject.builder.exe.debug.1432862600" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.exe.debug"/> + <tool id="com.crt.advproject.cpp.exe.debug.964171687" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.exe.debug"/> + <tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${CFLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GCCErrorParser" id="com.crt.advproject.gcc.exe.debug.502985594" name="MCU C Compiler" superClass="com.crt.advproject.gcc.exe.debug"> + <option id="com.crt.advproject.gcc.arch.625803892" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm4" valueType="enumerated"/> + <option id="com.crt.advproject.gcc.thumb.1149795974" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/> + <option id="gnu.c.compiler.option.preprocessor.def.symbols.510918973" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols"> + <listOptionValue builtIn="false" value="__REDLIB__"/> + <listOptionValue builtIn="false" value="__USE_CMSIS=CMSISv2p10_LPC43xx_DriverLib"/> + <listOptionValue builtIn="false" value="CORE_M4"/> + <listOptionValue builtIn="false" value="MCU=MCU_LPC43XX"/> + <listOptionValue builtIn="false" value="BOARD=BOARD_EA4357"/> + <listOptionValue builtIn="false" value="DEBUG"/> + <listOptionValue builtIn="false" value="__CODE_RED"/> + </option> + <option id="gnu.c.compiler.option.misc.other.740032111" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/> + <option id="gnu.c.compiler.option.include.paths.967143576" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/CMSISv2p10_LPC43xx_DriverLib/inc}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/bsp}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/tinyusb}""/> + <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}""/> + </option> + <option id="com.crt.advproject.c.misc.dialect.785308269" name="C Dialect" superClass="com.crt.advproject.c.misc.dialect" value="com.crt.advproject.misc.dialect.gnu99" valueType="enumerated"/> + <inputType id="com.crt.advproject.compiler.input.772057054" superClass="com.crt.advproject.compiler.input"/> + </tool> + <tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.gas.exe.debug.973267950" name="MCU Assembler" superClass="com.crt.advproject.gas.exe.debug"> + <option id="com.crt.advproject.gas.arch.733211533" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm4" valueType="enumerated"/> + <option id="com.crt.advproject.gas.thumb.154920324" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/> + <option id="gnu.both.asm.option.flags.crt.220166654" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -D__REDLIB__ -DDEBUG -D__CODE_RED" valueType="string"/> + <inputType id="com.crt.advproject.assembler.input.1834537770" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/> + </tool> + <tool id="com.crt.advproject.link.cpp.exe.debug.1510590263" name="MCU C++ Linker" superClass="com.crt.advproject.link.cpp.exe.debug"/> + <tool command="arm-none-eabi-gcc" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GLDErrorParser" id="com.crt.advproject.link.exe.debug.1770663329" name="MCU Linker" superClass="com.crt.advproject.link.exe.debug"> + <option id="com.crt.advproject.link.arch.1264750550" name="Architecture" superClass="com.crt.advproject.link.arch" value="com.crt.advproject.link.target.cm4" valueType="enumerated"/> + <option id="com.crt.advproject.link.thumb.1129500777" name="Thumb mode" superClass="com.crt.advproject.link.thumb" value="true" valueType="boolean"/> + <option id="com.crt.advproject.link.script.1484718299" name="Linker script" superClass="com.crt.advproject.link.script" value=""host_Board_NGX4330.ld"" valueType="string"/> + <option id="com.crt.advproject.link.manage.887685321" name="Manage linker script" superClass="com.crt.advproject.link.manage" value="true" valueType="boolean"/> + <option id="gnu.c.link.option.nostdlibs.1623667904" name="No startup or default libs (-nostdlib)" superClass="gnu.c.link.option.nostdlibs" value="true" valueType="boolean"/> + <option id="gnu.c.link.option.other.510975547" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList"> + <listOptionValue builtIn="false" value="-Map="${BuildArtifactFileBaseName}.map""/> + <listOptionValue builtIn="false" value="--gc-sections"/> + </option> + <option id="gnu.c.link.option.libs.1825587478" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" value="CMSISv2p10_LPC43xx_DriverLib"/> + </option> + <option id="gnu.c.link.option.paths.916077707" name="Library search path (-L)" superClass="gnu.c.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/CMSISv2p10_LPC43xx_DriverLib/Debug}""/> + </option> + <option id="com.crt.advproject.link.gcc.hdrlib.1015545513" name="Use C library" superClass="com.crt.advproject.link.gcc.hdrlib" value="com.crt.advproject.gcc.link.hdrlib.codered.nohost" valueType="enumerated"/> + <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.388300407" superClass="cdt.managedbuild.tool.gnu.c.linker.input"> + <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> + <additionalInput kind="additionalinput" paths="$(LIBS)"/> + </inputType> + </tool> + </toolChain> + </folderInfo> + <sourceEntries> + <entry excluding="NGX|bsp/lpc13uxx|bsp/lpc11uxx" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/> + </sourceEntries> + </configuration> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> + <storageModule moduleId="org.eclipse.cdt.core.language.mapping"/> + <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=""/> + <parser enabled="true"/> + </buildOutputProvider> + <scannerInfoProvider id="specsFile"> + <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.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=""/> + <parser enabled="true"/> + </buildOutputProvider> + <scannerInfoProvider id="specsFile"> + <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.GCCManagedMakePerProjectProfileCPP"> + <buildOutputProvider> + <openAction enabled="true" filePath=""/> + <parser enabled="true"/> + </buildOutputProvider> + <scannerInfoProvider id="specsFile"> + <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> + <parser enabled="true"/> + </scannerInfoProvider> + </profile> + <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> + <buildOutputProvider> + <openAction enabled="true" filePath=""/> + <parser enabled="true"/> + </buildOutputProvider> + <scannerInfoProvider id="specsFile"> + <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> + <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.config.exe.debug.1239969983;com.crt.advproject.config.exe.debug.1239969983.;com.crt.advproject.gas.exe.debug.1376287865;com.crt.advproject.assembler.input.1812008425"> + <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=""/> + <parser enabled="true"/> + </buildOutputProvider> + <scannerInfoProvider id="specsFile"> + <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.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=""/> + <parser enabled="true"/> + </buildOutputProvider> + <scannerInfoProvider id="specsFile"> + <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.GCCManagedMakePerProjectProfileCPP"> + <buildOutputProvider> + <openAction enabled="true" filePath=""/> + <parser enabled="true"/> + </buildOutputProvider> + <scannerInfoProvider id="specsFile"> + <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> + <parser enabled="true"/> + </scannerInfoProvider> + </profile> + <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> + <buildOutputProvider> + <openAction enabled="true" filePath=""/> + <parser enabled="true"/> + </buildOutputProvider> + <scannerInfoProvider id="specsFile"> + <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> + <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.config.exe.debug.1239969983;com.crt.advproject.config.exe.debug.1239969983.;com.crt.advproject.gcc.exe.debug.597047349;com.crt.advproject.compiler.input.217124913"> + <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=""/> + <parser enabled="true"/> + </buildOutputProvider> + <scannerInfoProvider id="specsFile"> + <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.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=""/> + <parser enabled="true"/> + </buildOutputProvider> + <scannerInfoProvider id="specsFile"> + <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.GCCManagedMakePerProjectProfileCPP"> + <buildOutputProvider> + <openAction enabled="true" filePath=""/> + <parser enabled="true"/> + </buildOutputProvider> + <scannerInfoProvider id="specsFile"> + <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/> + <parser enabled="true"/> + </scannerInfoProvider> + </profile> + <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"> + <buildOutputProvider> + <openAction enabled="true" filePath=""/> + <parser enabled="true"/> + </buildOutputProvider> + <scannerInfoProvider id="specsFile"> + <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/> + <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.internal.ui.text.commentOwnerProjectMappings"/> + </cconfiguration> </storageModule> <storageModule moduleId="cdtBuildSystem" version="4.0.0"> <project id="host.com.crt.advproject.projecttype.exe.1859815870" name="Executable" projectType="com.crt.advproject.projecttype.exe"/> diff --git a/demos/host/.project b/demos/host/.project index d6830eea7..09e353e6e 100644 --- a/demos/host/.project +++ b/demos/host/.project @@ -86,6 +86,11 @@ <type>2</type> <locationURI>PARENT-1-PROJECT_LOC/bsp</locationURI> </link> + <link> + <name>tinyusb</name> + <type>2</type> + <location>C:/Users/hathach/Dropbox/tinyusb/workspace/tinyusb/tinyusb</location> + </link> </linkedResources> <filteredResources> <filter> diff --git a/demos/host/main.c b/demos/host/main.c index ff10332f0..a96f9cbb9 100644 --- a/demos/host/main.c +++ b/demos/host/main.c @@ -1,3 +1,7 @@ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + #include "boards/board.h" #include "tusb.h" @@ -15,15 +19,18 @@ int main(void) uint32_t current_tick = system_ticks; board_init(); - tusb_init(0); + tusb_init(); while (1) { if (current_tick + 1000 < system_ticks) { current_tick += 1000; - board_leds(0x03, (current_tick/1000)%2); /* Toggle LED once per second */ - printf("hello world"); + board_leds(0x01, (current_tick/1000)%2); /* Toggle LED once per second */ + + printf("tinyusb: " __DATE__ "\t" __TIME__ "\n"); } } + + return 0; } diff --git a/demos/host/tusb_config.h b/demos/host/tusb_config.h new file mode 100644 index 000000000..ae2d29b70 --- /dev/null +++ b/demos/host/tusb_config.h @@ -0,0 +1,91 @@ +/* + * tusb_config.h + * + * Created on: Jan 11, 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_CONFIG_H_ +#define _TUSB_TUSB_CONFIG_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#define TUSB_CFG_HOST + +/// Enable Device Support +//#define TUSB_CFG_DEVICE + +/// Enable CDC Support +//#define TUSB_CFG_DEVICE_CDC + +/// Enable HID Keyboard support +#define TUSB_CFG_DEVICE_HID_KEYBOARD + +/// Enable HID Mouse support +//#define TUSB_CFG_DEVICE_HID_MOUSE + +#define TUSB_CFG_DEBUG 3 + +#ifdef __CODE_RED // make use of code red's support for ram region macros + #if (MCU == MCU_LPC11UXX) || (MCU == MCU_LPC13UXX) + #define TUSB_RAM_SECTION ".data.$RAM2" + #elif (MCU == MCU_LPC43XX) + #define TUSB_RAM_SECTION ".data.$RAM3" + #endif + + #define TUSB_ATTR_RAM_SECTION __attribute__ ((section(TUSB_RAM_SECTION))) +#endif + + +#ifdef __cplusplus + } +#endif + +#endif /* _TUSB_TUSB_CONFIG_H_ */ + +/** @} */ diff --git a/tests/project.yml b/tests/project.yml index 84661367e..ec4c6cb42 100644 --- a/tests/project.yml +++ b/tests/project.yml @@ -47,7 +47,7 @@ - _TEST_ - MCU=MCU_LPC43XX - CORE_M4 - - __CODE_RED + - __CODE_RED :test_preprocess: - *common_defines - _TEST_ diff --git a/tests/test/host/test_host_hid.c b/tests/test/host/test_hid_host.c index 3891034e5..3891034e5 100644 --- a/tests/test/host/test_host_hid.c +++ b/tests/test/host/test_hid_host.c diff --git a/tests/test/host/test_host_hid_keyboard.c b/tests/test/host/test_hid_host_keyboard.c index cf5a541d3..e02c18a84 100644 --- a/tests/test/host/test_host_hid_keyboard.c +++ b/tests/test/host/test_hid_host_keyboard.c @@ -35,6 +35,10 @@ * This file is part of the tiny usb stack. */ +#include "unity.h" +#include "hid.h" +#include "hid_host.h" + void setUp(void) { } @@ -43,7 +47,10 @@ void tearDown(void) { } -void test_() +void test_keyboard_get_invalid_parameter() { - TEST_IGNORE(); + tusb_interface_keyboard_handle_t handle; + tusb_keyboard_report_t report; + TEST_ASSERT_FALSE (tusb_host_keyboard_get(NULL, &report)); + TEST_ASSERT_FALSE (tusb_host_keyboard_get(&handle, NULL)); } diff --git a/tinyusb/class/hid.c b/tinyusb/class/hid.c index ec2df6156..dceb4d7db 100644 --- a/tinyusb/class/hid.c +++ b/tinyusb/class/hid.c @@ -40,7 +40,7 @@ #if defined DEVICE_CLASS_HID && defined TUSB_CFG_DEVICE #ifdef TUSB_CFG_DEVICE_HID_KEYBOARD -USB_HID_KeyboardReport_t hid_keyboard_report; +tusb_keyboard_report_t hid_keyboard_report; static volatile bool bKeyChanged = false; #endif @@ -67,7 +67,7 @@ ErrorCode_t HID_GetReport( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t #ifdef TUSB_CFG_DEVICE_HID_KEYBOARD case HID_PROTOCOL_KEYBOARD: *pBuffer = (uint8_t*) &hid_keyboard_report; - *plength = sizeof(USB_HID_KeyboardReport_t); + *plength = sizeof(tusb_keyboard_report_t); if (!bKeyChanged) { @@ -131,9 +131,9 @@ ErrorCode_t HID_EpIn_Hdlr (USBD_HANDLE_T hUsb, void* data, uint32_t event) case HID_PROTOCOL_KEYBOARD: if (!bKeyChanged) { - memset(&hid_keyboard_report, 0, sizeof(USB_HID_KeyboardReport_t)); + memset(&hid_keyboard_report, 0, sizeof(tusb_keyboard_report_t)); } - USBD_API->hw->WriteEP(hUsb, pHidCtrl->epin_adr, (uint8_t*) &hid_keyboard_report, sizeof(USB_HID_KeyboardReport_t)); + USBD_API->hw->WriteEP(hUsb, pHidCtrl->epin_adr, (uint8_t*) &hid_keyboard_report, sizeof(tusb_keyboard_report_t)); bKeyChanged = false; break; #endif @@ -223,7 +223,7 @@ TUSB_Error_t tusb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *c TUSB_Error_t tusb_hid_configured(USBD_HANDLE_T hUsb) { #ifdef TUSB_CFG_DEVICE_HID_KEYBOARD - USBD_API->hw->WriteEP(hUsb , HID_KEYBOARD_EP_IN , (uint8_t* ) &hid_keyboard_report , sizeof(USB_HID_KeyboardReport_t) ); // initial packet for IN endpoint , will not work if omitted + USBD_API->hw->WriteEP(hUsb , HID_KEYBOARD_EP_IN , (uint8_t* ) &hid_keyboard_report , sizeof(tusb_keyboard_report_t) ); // initial packet for IN endpoint , will not work if omitted #endif #ifdef TUSB_CFG_DEVICE_HID_MOUSE diff --git a/tinyusb/class/hid.h b/tinyusb/class/hid.h index 4779e9e81..0add02bfc 100644 --- a/tinyusb/class/hid.h +++ b/tinyusb/class/hid.h @@ -58,14 +58,6 @@ // TODO refractor #include "common/common.h" -#ifdef TUSB_CFG_DEVICE -#include "device/dcd.h" -#endif - -#ifdef TUSB_CFG_HOST -#include "device/hcd.h" -#endif - /** \struct USB_HID_MouseReport_t * \brief Standard HID Boot Protocol Mouse Report. * @@ -78,7 +70,7 @@ typedef ATTR_PREPACKED struct int8_t Y; /**< Current delta Y movement on the mouse. */ } ATTR_PACKED USB_HID_MouseReport_t; -/** \struct USB_HID_KeyboardReport_t +/** \struct tusb_keyboard_report_t * \brief Standard HID Boot Protocol Keyboard Report. * * Type define for a standard Boot Protocol Keyboard report @@ -88,7 +80,7 @@ typedef ATTR_PREPACKED struct uint8_t Modifier; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of HID_KEYBOARD_MODIFER_* masks). */ uint8_t Reserved; /**< Reserved for OEM use, always set to 0. */ uint8_t KeyCode[6]; /**< Key codes of the currently pressed keys. */ -} ATTR_PACKED USB_HID_KeyboardReport_t; +} ATTR_PACKED tusb_keyboard_report_t; /** \enum USB_HID_MOUSE_BUTTON_CODE * \brief Button codes for HID mouse @@ -158,48 +150,18 @@ enum USB_HID_LOCAL_CODE HID_Local_Turkish_F }; -#ifdef DEVICE_ROMDRIVER -/** \brief Initialize HID driver - * - * \param[in] para1 - * \param[out] para2 - * \return Error Code of the \ref TUSB_ERROR enum - * \note - */ -TUSB_Error_t tusb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *const pIntfDesc, uint8_t const * const pHIDReportDesc, uint32_t ReportDescLength, uint32_t* mem_base, uint32_t* mem_size); - -/** \brief Notify HID class that usb is configured - * - * \param[in] para1 - * \param[out] para2 - * \return Error Code of the \ref TUSB_ERROR enum - * \note - */ -TUSB_Error_t tusb_hid_configured(USBD_HANDLE_T hUsb); - -/** \brief Used by Application to send Keycode to Host - * - * \param[in] para1 - * \param[out] para2 - * \return Error Code of the \ref TUSB_ERROR enum - * \note - */ -TUSB_Error_t tusb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], uint8_t numkey); - -/** \brief - * - * \param[in] para1 - * \param[out] para2 - * \return Error Code of the \ref TUSB_ERROR enum - * \note - */ -TUSB_Error_t tusb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y); +#ifdef TUSB_CFG_DEVICE + #include "device/dcd.h" + #include "hid_device.h" #endif - #ifdef TUSB_CFG_HOST + #include "host/hcd.h" + #include "hid_host.h" #endif + + #ifdef __cplusplus } #endif diff --git a/tinyusb/class/hid_device.h b/tinyusb/class/hid_device.h new file mode 100644 index 000000000..31c3a489f --- /dev/null +++ b/tinyusb/class/hid_device.h @@ -0,0 +1,105 @@ +/* + * hid_device.h + * + * Created on: Jan 18, 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_HID_DEVICE_H_ +#define _TUSB_HID_DEVICE_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#include "hid.h" + +#ifdef DEVICE_ROMDRIVER +/** \brief Initialize HID driver + * + * \param[in] para1 + * \param[out] para2 + * \return Error Code of the \ref TUSB_ERROR enum + * \note + */ +TUSB_Error_t tusb_hid_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *const pIntfDesc, uint8_t const * const pHIDReportDesc, uint32_t ReportDescLength, uint32_t* mem_base, uint32_t* mem_size); + +/** \brief Notify HID class that usb is configured + * + * \param[in] para1 + * \param[out] para2 + * \return Error Code of the \ref TUSB_ERROR enum + * \note + */ +TUSB_Error_t tusb_hid_configured(USBD_HANDLE_T hUsb); + +/** \brief Used by Application to send Keycode to Host + * + * \param[in] para1 + * \param[out] para2 + * \return Error Code of the \ref TUSB_ERROR enum + * \note + */ +TUSB_Error_t tusb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], uint8_t numkey); + +/** \brief + * + * \param[in] para1 + * \param[out] para2 + * \return Error Code of the \ref TUSB_ERROR enum + * \note + */ +TUSB_Error_t tusb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y); + +#endif /* ROM DRIVRER */ + +#ifdef __cplusplus + } +#endif + +#endif /* _TUSB_HID_DEVICE_H_ */ + +/** @} */ diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c new file mode 100644 index 000000000..17b1aca0e --- /dev/null +++ b/tinyusb/class/hid_host.c @@ -0,0 +1,51 @@ +/* + * hid_host.c + * + * Created on: Dec 20, 2012 + * 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 "hid.h" + +#if defined DEVICE_CLASS_HID && defined TUSB_CFG_HOST + +bool tusb_host_keyboard_get(tusb_interface_keyboard_handle_t const * const handle, tusb_keyboard_report_t * const report) +{ + ASSSERT_PTR(handle, false); + ASSSERT_PTR(report, false); + + return true; +} + +#endif + diff --git a/tinyusb/class/hid_host.h b/tinyusb/class/hid_host.h new file mode 100644 index 000000000..856edff7c --- /dev/null +++ b/tinyusb/class/hid_host.h @@ -0,0 +1,70 @@ +/* + * hid_host.h + * + * Created on: Jan 18, 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_HID_HOST_H_ +#define _TUSB_HID_HOST_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#include "hid.h" + +typedef uint32_t tusb_interface_keyboard_handle_t; + +bool tusb_host_keyboard_get(tusb_interface_keyboard_handle_t const * const handle, tusb_keyboard_report_t *report); + +#ifdef __cplusplus + } +#endif + +#endif /* _TUSB_HID_HOST_H_ */ + +/** @} */ diff --git a/tinyusb/common/assertion.h b/tinyusb/common/assertion.h index a1aa968e9..cf99622d8 100644 --- a/tinyusb/common/assertion.h +++ b/tinyusb/common/assertion.h @@ -98,7 +98,7 @@ extern "C" // Logical Assert //--------------------------------------------------------------------+ #define ASSERT(...) ASSERT_TRUE(__VA_ARGS__) -#define ASSERT_TRUE(condition , error) ASSERT_DEFINE( ,(condition), error, "%s", "evaluated to false") +#define ASSERT_TRUE(condition , error) ASSERT_DEFINE( , (condition), error, "%s", "evaluated to false") #define ASSERT_FALSE(condition , error) ASSERT_DEFINE( ,!(condition), error, "%s", "evaluated to true") //--------------------------------------------------------------------+ @@ -129,6 +129,14 @@ extern "C" #define ASSERT_HEX_EQUAL(...) ASSERT_XXX_EQUAL("0x%x", __VA_ARGS__) #define ASSERT_HEX_WITHIN(...) ASSERT_XXX_WITHIN("0x%x", __VA_ARGS__) +//--------------------------------------------------------------------+ +// Pointer Assert +//--------------------------------------------------------------------+ +#define ASSSERT_PTR(...) ASSERT_PTR_NOT_NULL(__VA_ARGS__) +#define ASSERT_PTR_NOT_NULL(pointer, error) ASSERT_DEFINE( , NULL != (pointer), error, "%s", "pointer is NULL") +#define ASSSERT_PTR_NULL(pointer, error) ASSERT_DEFINE( , NULL == (pointer), error, "%s", "pointer is NULL") + + #ifdef __cplusplus } #endif diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h index a17fb62dc..1aae86fe8 100644 --- a/tinyusb/common/common.h +++ b/tinyusb/common/common.h @@ -56,8 +56,9 @@ extern "C" { #endif -#include <stddef.h> #include <stdbool.h> +#include <stdint.h> +#include <stddef.h> #include <string.h> #include <stdio.h> |
