parent
df63da6098
commit
6364488dc2
@ -0,0 +1,227 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||||
|
<cconfiguration id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.728343049">
|
||||||
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.728343049" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||||
|
<externalSettings/>
|
||||||
|
<extensions>
|
||||||
|
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GASErrorParser" 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.GLDErrorParser" 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.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
</extensions>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="${cross_rm} -rf" description="" id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.728343049" name="Debug" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug">
|
||||||
|
<folderInfo id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.728343049." name="/" resourcePath="">
|
||||||
|
<toolChain id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.debug.400478197" name="RISC-V Cross GCC" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.debug">
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.1025383446" name="Create flash image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting.1716732716" name="Create extended listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting" useByScannerDiscovery="false"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize.1382758251" name="Print size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.491048255" name="Optimization Level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.none" valueType="enumerated"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength.994504285" name="Message length (-fmessage-length=0)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar.589018915" name="'char' is signed (-fsigned-char)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections.218359231" name="Function sections (-ffunction-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections.926896656" name="Data sections (-fdata-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.1072449627" name="Debug level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.max" valueType="enumerated"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format.2085703920" name="Debug format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format" useByScannerDiscovery="true"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name.383906086" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name" useByScannerDiscovery="false" value="xPack GNU RISC-V Embedded GCC" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix.1576932370" name="Prefix" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix" useByScannerDiscovery="false" value="riscv-none-embed-" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c.812416764" name="C compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c" useByScannerDiscovery="false" value="gcc" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp.714294643" name="C++ compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp" useByScannerDiscovery="false" value="g++" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar.323340030" name="Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar" useByScannerDiscovery="false" value="ar" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy.1947281609" name="Hex/Bin converter" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy" useByScannerDiscovery="false" value="objcopy" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump.1724546708" name="Listing generator" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump" useByScannerDiscovery="false" value="objdump" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size.1880227298" name="Size command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size" useByScannerDiscovery="false" value="size" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make.1815679973" name="Build command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make" useByScannerDiscovery="false" value="make" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm.1261068934" name="Remove command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm" useByScannerDiscovery="false" value="rm" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id.1503692628" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.id" useByScannerDiscovery="false" value="2273142912" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel.1186656505" name="Code model" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.codemodel.low" valueType="enumerated"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base.1275547413" name="Architecture" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.base" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.arch.rv32i" valueType="enumerated"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply.1840818555" name="Multiply extension (RVM)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.multiply" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic.2109971404" name="Atomic extension (RVA)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.atomic" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed.756159799" name="Compressed extension (RVC)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.isa.compressed" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer.617108302" name="Integer ABI" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.target.abi.integer" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.abi.integer.ilp32" valueType="enumerated"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.other.2035224218" name="Other warning flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.other" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.allwarn.1538424584" name="Enable all common warnings (-Wall)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.warnings.allwarn" useByScannerDiscovery="true" value="true" valueType="boolean"/>
|
||||||
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform.248155089" isAbstract="false" osList="all" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform"/>
|
||||||
|
<builder buildPath="${workspace_loc:/GD32V_DOWNSTREAM}/Debug" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.902560381" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.1745396686" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor.1443647993" name="Use preprocessor" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths.243029531" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/GD32V_DOWNSTREAM/Firmware/RISCV/drivers}""/>
|
||||||
|
</option>
|
||||||
|
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input.658912135" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.616007437" name="GNU RISC-V Cross C Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler">
|
||||||
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths.1714081614" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/GD32V_DOWNSTREAM/Include}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/GD32V_DOWNSTREAM/Firmware/RISCV/stubs}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/GD32V_DOWNSTREAM/Firmware/RISCV/env_Eclipse}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/GD32V_DOWNSTREAM/Firmware/RISCV/drivers}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/GD32V_DOWNSTREAM/Firmware/GD32VF103_standard_peripheral/Include}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/GD32V_DOWNSTREAM/Firmware/GD32VF103_usbfs_driver/Include}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/GD32V_DOWNSTREAM/Firmware/GD32VF103_standard_peripheral}""/>
|
||||||
|
</option>
|
||||||
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.609467163" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
|
||||||
|
<listOptionValue builtIn="false" value="USE_STDPERIPH_DRIVER"/>
|
||||||
|
<listOptionValue builtIn="false" value="GD32VF103V_EVAL"/>
|
||||||
|
<listOptionValue builtIn="false" value="USE_USB_FS"/>
|
||||||
|
</option>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other.1233054372" name="Other compiler flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other" useByScannerDiscovery="true" value="-fshort-wchar" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otherwarnings.1986320347" name="Other warning flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otherwarnings" useByScannerDiscovery="true" value="" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.494756384" name="Language standard" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.gnu11" valueType="enumerated"/>
|
||||||
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files.332526514" name="Include files (-include)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.files" useByScannerDiscovery="true" valueType="includeFiles">
|
||||||
|
<listOptionValue builtIn="false" value="sys/cdefs.h"/>
|
||||||
|
</option>
|
||||||
|
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.753310393" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.331065885" name="GNU RISC-V Cross C++ Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler"/>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.1500512939" name="GNU RISC-V Cross C Linker" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker">
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections.1406013079" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other.881581150" name="Other linker flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other" useByScannerDiscovery="false" value="" valueType="string"/>
|
||||||
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.scriptfile.63314848" name="Script files (-T)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.scriptfile" useByScannerDiscovery="false" valueType="stringList">
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/GD32V_DOWNSTREAM/Firmware/RISCV/env_Eclipse/GD32VF103xB.lds}""/>
|
||||||
|
</option>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostart.641891865" name="Do not use standard start files (-nostartfiles)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostart" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnano.307643067" name="Use newlib-nano (--specs=nano.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnano" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnosys.1055996996" name="Do not use syscalls (--specs=nosys.specs)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usenewlibnosys" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usescanffloat.1605124970" name="Use float with nano scanf (-u _scanf_float)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.usescanffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||||
|
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.input.1045138732" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.input">
|
||||||
|
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||||
|
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||||
|
</inputType>
|
||||||
|
</tool>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker.569827687" name="GNU RISC-V Cross C++ Linker" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker">
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.gcsections.1258206109" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.gcsections" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.other.1362532349" name="Other linker flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.other" value="--specs=nosys.specs" valueType="string"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver.1708670750" name="GNU RISC-V Cross Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver"/>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.1187869466" name="GNU RISC-V Cross Create Flash Image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash"/>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting.1023202173" name="GNU RISC-V Cross Create Listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting">
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source.59042045" name="Display source (--source|-S)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.allheaders.77447319" name="Display all headers (--all-headers|-x)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.allheaders" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.demangle.619042423" name="Demangle names (--demangle|-C)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.demangle" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.linenumbers.1441358865" name="Display line numbers (--line-numbers|-l)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.linenumbers" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.wide.1476903631" name="Wide lines (--wide|-w)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.wide" value="true" valueType="boolean"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize.195090094" name="GNU RISC-V Cross Print Size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize">
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format.580245023" name="Size format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format" useByScannerDiscovery="false"/>
|
||||||
|
</tool>
|
||||||
|
</toolChain>
|
||||||
|
</folderInfo>
|
||||||
|
<sourceEntries>
|
||||||
|
<entry excluding=".settings" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||||
|
</sourceEntries>
|
||||||
|
</configuration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||||
|
<storageModule moduleId="ilg.gnumcueclipse.managedbuild.packs"/>
|
||||||
|
<storageModule moduleId="ilg.gnuarmeclipse.managedbuild.packs"/>
|
||||||
|
</cconfiguration>
|
||||||
|
<cconfiguration id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1212712783">
|
||||||
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1212712783" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||||
|
<externalSettings/>
|
||||||
|
<extensions>
|
||||||
|
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||||
|
<extension id="org.eclipse.cdt.core.GASErrorParser" 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.GLDErrorParser" 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.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||||
|
</extensions>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" cleanCommand="${cross_rm} -rf" description="" id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1212712783" name="Release" optionalBuildProperties="" parent="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release">
|
||||||
|
<folderInfo id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1212712783." name="/" resourcePath="">
|
||||||
|
<toolChain id="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release.243672508" name="RISC-V Cross GCC" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.toolchain.elf.release">
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash.1700898671" name="Create flash image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createflash" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting.328584812" name="Create extended listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.createlisting"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize.272362945" name="Print size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.addtools.printsize" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.1536050800" name="Optimization Level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.level.size" valueType="enumerated"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength.39322645" name="Message length (-fmessage-length=0)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.messagelength" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar.899168086" name="'char' is signed (-fsigned-char)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.signedchar" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections.62073107" name="Function sections (-ffunction-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.functionsections" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections.1098739386" name="Data sections (-fdata-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.optimization.datasections" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level.508095950" name="Debug level" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.level"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format.102756495" name="Debug format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.debugging.format"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name.740045372" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.toolchain.name" value="xPack GNU RISC-V Embedded GCC" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix.1822913735" name="Prefix" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.prefix" value="riscv-none-embed-" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c.448956677" name="C compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.c" value="gcc" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp.1123993921" name="C++ compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.cpp" value="g++" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar.1152695436" name="Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.ar" value="ar" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy.1493388139" name="Hex/Bin converter" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objcopy" value="objcopy" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump.981420114" name="Listing generator" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.objdump" value="objdump" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size.1829669584" name="Size command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.size" value="size" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make.1117810088" name="Build command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.make" value="make" valueType="string"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm.2140218021" name="Remove command" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.command.rm" value="rm" valueType="string"/>
|
||||||
|
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform.2108318268" isAbstract="false" osList="all" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.targetPlatform"/>
|
||||||
|
<builder buildPath="${workspace_loc:/GD32V_DOWNSTREAM}/Release" id="ilg.gnumcueclipse.managedbuild.cross.riscv.builder.186440277" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.builder"/>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.518021490" name="GNU RISC-V Cross Assembler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler">
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor.1673457069" name="Use preprocessor" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.assembler.usepreprocessor" value="true" valueType="boolean"/>
|
||||||
|
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input.783307255" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.assembler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.426963626" name="GNU RISC-V Cross C Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler">
|
||||||
|
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.1491970636" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.1538616535" name="GNU RISC-V Cross C++ Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler"/>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.758486686" name="GNU RISC-V Cross C Linker" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker">
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections.1382121408" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other.1330603069" name="Other linker flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other" value="--specs=nosys.specs" valueType="string"/>
|
||||||
|
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.input.259281420" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.input">
|
||||||
|
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||||
|
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||||
|
</inputType>
|
||||||
|
</tool>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker.1855427232" name="GNU RISC-V Cross C++ Linker" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.linker">
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.gcsections.946367409" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.gcsections" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.other.1299809017" name="Other linker flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.cpp.linker.other" value="--specs=nosys.specs" valueType="string"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver.749886662" name="GNU RISC-V Cross Archiver" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.archiver"/>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.390053621" name="GNU RISC-V Cross Create Flash Image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash"/>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting.2099945203" name="GNU RISC-V Cross Create Listing" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createlisting">
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source.1147439475" name="Display source (--source|-S)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.source" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.allheaders.191393003" name="Display all headers (--all-headers|-x)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.allheaders" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.demangle.1795174068" name="Demangle names (--demangle|-C)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.demangle" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.linenumbers.1308205785" name="Display line numbers (--line-numbers|-l)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.linenumbers" value="true" valueType="boolean"/>
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.wide.596347778" name="Wide lines (--wide|-w)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createlisting.wide" value="true" valueType="boolean"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize.516476214" name="GNU RISC-V Cross Print Size" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.printsize">
|
||||||
|
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format.1683859393" name="Size format" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.printsize.format"/>
|
||||||
|
</tool>
|
||||||
|
</toolChain>
|
||||||
|
</folderInfo>
|
||||||
|
<sourceEntries>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Source"/>
|
||||||
|
</sourceEntries>
|
||||||
|
</configuration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||||
|
</cconfiguration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
|
<project id="GD32V_DOWNSTREAM.ilg.gnumcueclipse.managedbuild.cross.riscv.target.elf.215691552" name="Executable" projectType="ilg.gnumcueclipse.managedbuild.cross.riscv.target.elf"/>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="scannerConfiguration">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||||
|
<scannerConfigBuildInfo instanceId="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1212712783;ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1212712783.;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.426963626;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.1491970636">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
<scannerConfigBuildInfo instanceId="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.728343049;ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.728343049.;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.616007437;ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.753310393">
|
||||||
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||||
|
</scannerConfigBuildInfo>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||||
|
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||||
|
<configuration configurationName="Debug">
|
||||||
|
<resource resourceType="PROJECT" workspacePath="/GD32V_DOWNSTREAM"/>
|
||||||
|
</configuration>
|
||||||
|
<configuration configurationName="Release">
|
||||||
|
<resource resourceType="PROJECT" workspacePath="/GD32V_DOWNSTREAM"/>
|
||||||
|
</configuration>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||||
|
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||||
|
</cproject>
|
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>GD32V_DOWNSTREAM</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||||
|
<triggers>clean,full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||||
|
<triggers>full,incremental,</triggers>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||||
|
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||||
|
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<project>
|
||||||
|
<configuration id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.debug.728343049" name="Debug">
|
||||||
|
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||||
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
|
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-968577711971396154" id="org.eclipse.embedcdt.managedbuild.cross.riscv.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
|
</provider>
|
||||||
|
</extension>
|
||||||
|
</configuration>
|
||||||
|
<configuration id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1212712783" name="Release">
|
||||||
|
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||||
|
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||||
|
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
|
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||||
|
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-975472658385132917" id="org.eclipse.embedcdt.managedbuild.cross.riscv.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||||
|
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||||
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
|
</provider>
|
||||||
|
</extension>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
@ -0,0 +1,109 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.cdt.codan.checkers.errnoreturn=Warning
|
||||||
|
org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return\\")",implicit\=>false}
|
||||||
|
org.eclipse.cdt.codan.checkers.errreturnvalue=Error
|
||||||
|
org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused return value\\")"}
|
||||||
|
org.eclipse.cdt.codan.checkers.localvarreturn=-Warning
|
||||||
|
org.eclipse.cdt.codan.checkers.localvarreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Returning the address of a local variable\\")"}
|
||||||
|
org.eclipse.cdt.codan.checkers.nocommentinside=-Error
|
||||||
|
org.eclipse.cdt.codan.checkers.nocommentinside.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Nesting comments\\")"}
|
||||||
|
org.eclipse.cdt.codan.checkers.nolinecomment=-Error
|
||||||
|
org.eclipse.cdt.codan.checkers.nolinecomment.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Line comments\\")"}
|
||||||
|
org.eclipse.cdt.codan.checkers.noreturn=Error
|
||||||
|
org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No return value\\")",implicit\=>false}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Abstract class cannot be instantiated\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Ambiguous problem\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment in condition\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Assignment to itself\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.BlacklistProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.BlacklistProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function or method is blacklisted\\")",blacklist\=>()}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CStyleCastProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CStyleCastProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"C-Style cast instead of C++ cast\\")",checkMacro\=>true}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"No break at end of case\\")",no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false,enable_fallthrough_quickfix_param\=>false}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Catching by reference is recommended\\")",unknown\=>false,exceptions\=>()}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Circular inheritance\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class members should be properly initialized\\")",skip\=>true}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CopyrightProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.CopyrightProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Lack of copyright information\\")",regex\=>".*Copyright.*"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.DecltypeAutoProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid 'decltype(auto)' specifier\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Field cannot be resolved\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.FloatCompareProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.FloatCompareProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Direct float comparison\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Function cannot be resolved\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.GotoStatementProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.GotoStatementProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Goto statement used\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid arguments\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid template argument\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Label statement not found\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MagicNumberProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MagicNumberProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Avoid magic numbers\\")",checkArray\=>true,checkOperatorParen\=>true,exceptions\=>(1,0,-1,2,1.0,0.0,-1.0)}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Member declaration not found\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Method cannot be resolved\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MissCaseProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MissCaseProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing cases in switch\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MissDefaultProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MissDefaultProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing default in switch\\")",defaultWithAllEnums\=>false}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MissReferenceProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MissReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing reference return value in assignment operator\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MissSelfCheckProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MissSelfCheckProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Missing self check in assignment operator\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MultipleDeclarationsProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.MultipleDeclarationsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Multiple variable declaration\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Name convention for function\\")",pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.NoDiscardProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.NoDiscardProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return value not evaluated\\")",macro\=>true}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Class has a virtual method and non-virtual destructor\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid overload\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redeclaration\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Invalid redefinition\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Return with parenthesis\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Format String Vulnerability\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ShallowCopyProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.ShallowCopyProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Miss copy constructor or assignment operator\\")",onlynew\=>false}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Statement has no effect\\")",macro\=>true,exceptions\=>()}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.StaticVariableInHeaderProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.StaticVariableInHeaderProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Static variable in header file\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suggested parenthesis around expression\\")",paramNot\=>false}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Suspicious semicolon\\")",else\=>false,afterelse\=>false}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.SymbolShadowingProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.SymbolShadowingProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol shadowing\\")",paramFuncParameters\=>true}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Type cannot be resolved\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused function declaration\\")",macro\=>true}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused static function\\")",macro\=>true}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Unused variable declaration in file scope\\")",macro\=>true,exceptions\=>("@(\#)","$Id")}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UsingInHeaderProblem=-Warning
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.UsingInHeaderProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Using directive in header\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Symbol is not resolved\\")"}
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.VirtualMethodCallProblem=-Error
|
||||||
|
org.eclipse.cdt.codan.internal.checkers.VirtualMethodCallProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},suppression_comment\=>"@suppress(\\"Virtual method call in constructor/destructor\\")"}
|
@ -0,0 +1,6 @@
|
|||||||
|
doxygen/doxygen_new_line_after_brief=true
|
||||||
|
doxygen/doxygen_use_brief_tag=false
|
||||||
|
doxygen/doxygen_use_javadoc_tags=true
|
||||||
|
doxygen/doxygen_use_pre_tag=false
|
||||||
|
doxygen/doxygen_use_structural_commands=false
|
||||||
|
eclipse.preferences.version=1
|
@ -0,0 +1,2 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "integer.h"
|
||||||
|
#include "fattime.h"
|
||||||
|
|
||||||
|
|
||||||
|
DWORD get_fattime (void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,63 @@
|
|||||||
|
/*!
|
||||||
|
\file gd32vf103_it.c
|
||||||
|
\brief main interrupt service routines
|
||||||
|
|
||||||
|
\version 2019-06-05, V1.0.0, firmware for GD32VF103
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) 2019, GigaDevice Semiconductor Inc.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the copyright holder nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "drv_usbh_int.h"
|
||||||
|
#include "drv_usb_hw.h"
|
||||||
|
#include "gd32vf103_it.h"
|
||||||
|
|
||||||
|
extern usb_core_driver usbh_msc_core;
|
||||||
|
|
||||||
|
extern void usb_timer_irq (void);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief this function handles USBD interrupt
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void USBFS_IRQHandler (void)
|
||||||
|
{
|
||||||
|
usbh_isr (&usbh_msc_core);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief this function handles timer2 updata interrupt request.
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void TIMER2_IRQHandler(void)
|
||||||
|
{
|
||||||
|
usb_timer_irq();
|
||||||
|
}
|
@ -0,0 +1,256 @@
|
|||||||
|
/*!
|
||||||
|
\file gd32vf103_usb_hw.c
|
||||||
|
\brief this file implements the board support package for the USB host library
|
||||||
|
|
||||||
|
\version 2019-06-05, V1.0.0, firmware for GD32VF103
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) 2019, GigaDevice Semiconductor Inc.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the copyright holder nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "drv_usb_hw.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define TIM_MSEC_DELAY 0x01
|
||||||
|
#define TIM_USEC_DELAY 0x02
|
||||||
|
|
||||||
|
#define HOST_POWERSW_PORT_RCC RCU_GPIOD
|
||||||
|
#define HOST_POWERSW_PORT GPIOD
|
||||||
|
#define HOST_POWERSW_VBUS GPIO_PIN_13
|
||||||
|
|
||||||
|
__IO uint32_t delay_time = 0;
|
||||||
|
__IO uint32_t usbfs_prescaler = 0;
|
||||||
|
__IO uint32_t timer_prescaler = 5;
|
||||||
|
|
||||||
|
static void hwp_time_set (uint8_t unit);
|
||||||
|
static void hwp_delay (uint32_t ntime, uint8_t unit);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief configure USB clock
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usb_rcu_config (void)
|
||||||
|
{
|
||||||
|
uint32_t system_clock = rcu_clock_freq_get(CK_SYS);
|
||||||
|
|
||||||
|
if (system_clock == 48000000) {
|
||||||
|
usbfs_prescaler = RCU_CKUSB_CKPLL_DIV1;
|
||||||
|
timer_prescaler = 3;
|
||||||
|
} else if (system_clock == 72000000) {
|
||||||
|
usbfs_prescaler = RCU_CKUSB_CKPLL_DIV1_5;
|
||||||
|
timer_prescaler = 5;
|
||||||
|
} else if (system_clock == 96000000) {
|
||||||
|
usbfs_prescaler = RCU_CKUSB_CKPLL_DIV2;
|
||||||
|
timer_prescaler = 7;
|
||||||
|
} else {
|
||||||
|
/* reserved */
|
||||||
|
}
|
||||||
|
|
||||||
|
rcu_usb_clock_config(usbfs_prescaler);
|
||||||
|
rcu_periph_clock_enable(RCU_USBFS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief configure USB global interrupt
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usb_intr_config (void)
|
||||||
|
{
|
||||||
|
eclic_irq_enable((uint8_t)USBFS_IRQn, 1, 0);
|
||||||
|
|
||||||
|
#ifdef USB_OTG_FS_LOW_PWR_MGMT_SUPPORT
|
||||||
|
|
||||||
|
/* enable the power module clock */
|
||||||
|
rcu_periph_clock_enable(RCU_PMU);
|
||||||
|
|
||||||
|
/* USB wakeup EXTI line configuration */
|
||||||
|
exti_interrupt_flag_clear(EXTI_18);
|
||||||
|
exti_init(EXTI_18, EXTI_INTERRUPT, EXTI_TRIG_RISING);
|
||||||
|
exti_interrupt_enable(EXTI_18);
|
||||||
|
|
||||||
|
eclic_irq_enable((uint8_t)USBFS_WKUP_IRQn, 3U, 0U);
|
||||||
|
|
||||||
|
#endif /* USBHS_LOW_PWR_MGMT_SUPPORT */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief drives the VBUS signal through gpio
|
||||||
|
\param[in] state: VBUS states
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usb_vbus_drive (uint8_t state)
|
||||||
|
{
|
||||||
|
if (0 == state)
|
||||||
|
{
|
||||||
|
/* DISABLE is needed on output of the Power Switch */
|
||||||
|
gpio_bit_reset(HOST_POWERSW_PORT, HOST_POWERSW_VBUS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*ENABLE the Power Switch by driving the Enable LOW */
|
||||||
|
gpio_bit_set(HOST_POWERSW_PORT, HOST_POWERSW_VBUS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief configures the GPIO for the VBUS
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usb_vbus_config (void)
|
||||||
|
{
|
||||||
|
rcu_periph_clock_enable(HOST_POWERSW_PORT_RCC);
|
||||||
|
|
||||||
|
gpio_init(HOST_POWERSW_PORT, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, HOST_POWERSW_VBUS);
|
||||||
|
|
||||||
|
/* by default, disable is needed on output of the power switch */
|
||||||
|
gpio_bit_set(HOST_POWERSW_PORT, HOST_POWERSW_VBUS);
|
||||||
|
|
||||||
|
/* Delay is need for stabilising the Vbus Low in Reset Condition,
|
||||||
|
* when Vbus=1 and Reset-button is pressed by user
|
||||||
|
*/
|
||||||
|
usb_mdelay (2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief initializes delay unit using Timer2
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usb_timer_init (void)
|
||||||
|
{
|
||||||
|
rcu_periph_clock_enable(RCU_TIMER2);
|
||||||
|
|
||||||
|
eclic_irq_enable(TIMER2_IRQn, 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief delay in micro seconds
|
||||||
|
\param[in] usec: value of delay required in micro seconds
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usb_udelay (const uint32_t usec)
|
||||||
|
{
|
||||||
|
hwp_delay(usec, TIM_USEC_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief delay in milli seconds
|
||||||
|
\param[in] msec: value of delay required in milli seconds
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usb_mdelay (const uint32_t msec)
|
||||||
|
{
|
||||||
|
hwp_delay(msec, TIM_MSEC_DELAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief timer base IRQ
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usb_timer_irq (void)
|
||||||
|
{
|
||||||
|
if (timer_interrupt_flag_get(TIMER2, TIMER_INT_UP) != RESET){
|
||||||
|
timer_interrupt_flag_clear(TIMER2, TIMER_INT_UP);
|
||||||
|
|
||||||
|
if (delay_time > 0x00U){
|
||||||
|
delay_time--;
|
||||||
|
} else {
|
||||||
|
timer_disable(TIMER2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief delay routine based on TIM2
|
||||||
|
\param[in] ntime: delay Time
|
||||||
|
\param[in] unit: delay Time unit = mili sec / micro sec
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
static void hwp_delay(uint32_t ntime, uint8_t unit)
|
||||||
|
{
|
||||||
|
delay_time = ntime;
|
||||||
|
hwp_time_set(unit);
|
||||||
|
|
||||||
|
while(delay_time != 0);
|
||||||
|
|
||||||
|
timer_disable(TIMER2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief configures TIM2 for delay routine based on TIM2
|
||||||
|
\param[in] unit: msec /usec
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
static void hwp_time_set(uint8_t unit)
|
||||||
|
{
|
||||||
|
timer_parameter_struct timer_basestructure;
|
||||||
|
|
||||||
|
timer_disable(TIMER2);
|
||||||
|
timer_interrupt_disable(TIMER2, TIMER_INT_UP);
|
||||||
|
|
||||||
|
if (unit == TIM_USEC_DELAY) {
|
||||||
|
timer_basestructure.period = 11;
|
||||||
|
} else if(unit == TIM_MSEC_DELAY) {
|
||||||
|
timer_basestructure.period = 11999;
|
||||||
|
} else {
|
||||||
|
/* no operation */
|
||||||
|
}
|
||||||
|
|
||||||
|
timer_basestructure.prescaler = timer_prescaler;
|
||||||
|
timer_basestructure.alignedmode = TIMER_COUNTER_EDGE;
|
||||||
|
timer_basestructure.counterdirection = TIMER_COUNTER_UP;
|
||||||
|
timer_basestructure.clockdivision = TIMER_CKDIV_DIV1;
|
||||||
|
timer_basestructure.repetitioncounter = 0;
|
||||||
|
|
||||||
|
timer_init(TIMER2, &timer_basestructure);
|
||||||
|
|
||||||
|
timer_interrupt_flag_clear(TIMER2, TIMER_INT_UP);
|
||||||
|
|
||||||
|
timer_auto_reload_shadow_enable(TIMER2);
|
||||||
|
|
||||||
|
/* timer2 interrupt enable */
|
||||||
|
timer_interrupt_enable(TIMER2, TIMER_INT_UP);
|
||||||
|
|
||||||
|
/* timer2 enable counter */
|
||||||
|
timer_enable(TIMER2);
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
/*!
|
||||||
|
\file main.c
|
||||||
|
\brief this file realizes the MSC host
|
||||||
|
|
||||||
|
\version 2019-06-05, V1.0.0, firmware for GD32VF103
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) 2019, GigaDevice Semiconductor Inc.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the copyright holder nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "drv_usb_hw.h"
|
||||||
|
#include "drv_usb_core.h"
|
||||||
|
#include "usbh_usr.h"
|
||||||
|
#include "usbh_msc_core.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
usb_core_driver usbh_msc_core;
|
||||||
|
|
||||||
|
usbh_host usb_host = {
|
||||||
|
.class_cb = &usbh_msc_cb,
|
||||||
|
.usr_cb = &user_callback_funs,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
usbh_host hUsbHostFS;
|
||||||
|
|
||||||
|
void Downstream_HostUserCallback(usbh_host *phost, uint8_t id){
|
||||||
|
//dummy
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Main routine for HID mouse / keyboard class application
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
eclic_global_interrupt_enable();
|
||||||
|
|
||||||
|
eclic_priority_group_set(ECLIC_PRIGROUP_LEVEL2_PRIO2);
|
||||||
|
|
||||||
|
usb_rcu_config();
|
||||||
|
|
||||||
|
usb_timer_init();
|
||||||
|
|
||||||
|
/* configure GPIO pin used for switching VBUS power and charge pump I/O */
|
||||||
|
// usb_vbus_config();
|
||||||
|
|
||||||
|
usbh_init (&usbh_msc_core, USB_CORE_ENUM_FS, &usb_host,Downstream_HostUserCallback);
|
||||||
|
|
||||||
|
/* enable interrupts */
|
||||||
|
usb_intr_config();
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
/* Host state handler */
|
||||||
|
usbh_core_task (&usbh_msc_core, &usb_host);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,998 @@
|
|||||||
|
/*!
|
||||||
|
\file system_gd32vf103.h
|
||||||
|
\brief RISC-V Device Peripheral Access Layer Source File for
|
||||||
|
GD32VF103 Device Series
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) 2019, GigaDevice Semiconductor Inc.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the copyright holder nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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 refers the RISC-V standard, some adjustments are made according to GigaDevice chips */
|
||||||
|
|
||||||
|
#include "gd32vf103.h"
|
||||||
|
|
||||||
|
/* system frequency define */
|
||||||
|
#define __IRC8M (IRC8M_VALUE) /* internal 8 MHz RC oscillator frequency */
|
||||||
|
#define __HXTAL (HXTAL_VALUE) /* high speed crystal oscillator frequency */
|
||||||
|
#define __SYS_OSC_CLK (__IRC8M) /* main oscillator frequency */
|
||||||
|
|
||||||
|
/* select a system clock by uncommenting the following line */
|
||||||
|
/* use IRC8M */
|
||||||
|
//#define __SYSTEM_CLOCK_48M_PLL_IRC8M (uint32_t)(48000000)
|
||||||
|
//#define __SYSTEM_CLOCK_72M_PLL_IRC8M (uint32_t)(72000000)
|
||||||
|
//#define __SYSTEM_CLOCK_108M_PLL_IRC8M (uint32_t)(108000000)
|
||||||
|
|
||||||
|
/********************************************************************/
|
||||||
|
//#define __SYSTEM_CLOCK_HXTAL (HXTAL_VALUE)
|
||||||
|
//#define __SYSTEM_CLOCK_24M_PLL_HXTAL (uint32_t)(24000000)
|
||||||
|
/********************************************************************/
|
||||||
|
|
||||||
|
//#define __SYSTEM_CLOCK_36M_PLL_HXTAL (uint32_t)(36000000)
|
||||||
|
//#define __SYSTEM_CLOCK_48M_PLL_HXTAL (uint32_t)(48000000)
|
||||||
|
//#define __SYSTEM_CLOCK_56M_PLL_HXTAL (uint32_t)(56000000)
|
||||||
|
//#define __SYSTEM_CLOCK_72M_PLL_HXTAL (uint32_t)(72000000)
|
||||||
|
#define __SYSTEM_CLOCK_96M_PLL_HXTAL (uint32_t)(96000000)
|
||||||
|
//#define __SYSTEM_CLOCK_108M_PLL_HXTAL (uint32_t)(108000000)
|
||||||
|
|
||||||
|
#define SEL_IRC8M 0x00U
|
||||||
|
#define SEL_HXTAL 0x01U
|
||||||
|
#define SEL_PLL 0x02U
|
||||||
|
|
||||||
|
/* set the system clock frequency and declare the system clock configuration function */
|
||||||
|
#ifdef __SYSTEM_CLOCK_48M_PLL_IRC8M
|
||||||
|
uint32_t SystemCoreClock = __SYSTEM_CLOCK_48M_PLL_IRC8M;
|
||||||
|
static void system_clock_48m_irc8m(void);
|
||||||
|
#elif defined (__SYSTEM_CLOCK_72M_PLL_IRC8M)
|
||||||
|
uint32_t SystemCoreClock = __SYSTEM_CLOCK_72M_PLL_IRC8M;
|
||||||
|
static void system_clock_72m_irc8m(void);
|
||||||
|
#elif defined (__SYSTEM_CLOCK_108M_PLL_IRC8M)
|
||||||
|
uint32_t SystemCoreClock = __SYSTEM_CLOCK_108M_PLL_IRC8M;
|
||||||
|
static void system_clock_108m_irc8m(void);
|
||||||
|
|
||||||
|
#elif defined (__SYSTEM_CLOCK_HXTAL)
|
||||||
|
uint32_t SystemCoreClock = __SYSTEM_CLOCK_HXTAL;
|
||||||
|
static void system_clock_hxtal(void);
|
||||||
|
#elif defined (__SYSTEM_CLOCK_24M_PLL_HXTAL)
|
||||||
|
uint32_t SystemCoreClock = __SYSTEM_CLOCK_24M_PLL_HXTAL;
|
||||||
|
static void system_clock_24m_hxtal(void);
|
||||||
|
#elif defined (__SYSTEM_CLOCK_36M_PLL_HXTAL)
|
||||||
|
uint32_t SystemCoreClock = __SYSTEM_CLOCK_36M_PLL_HXTAL;
|
||||||
|
static void system_clock_36m_hxtal(void);
|
||||||
|
#elif defined (__SYSTEM_CLOCK_48M_PLL_HXTAL)
|
||||||
|
uint32_t SystemCoreClock = __SYSTEM_CLOCK_48M_PLL_HXTAL;
|
||||||
|
static void system_clock_48m_hxtal(void);
|
||||||
|
#elif defined (__SYSTEM_CLOCK_56M_PLL_HXTAL)
|
||||||
|
uint32_t SystemCoreClock = __SYSTEM_CLOCK_56M_PLL_HXTAL;
|
||||||
|
static void system_clock_56m_hxtal(void);
|
||||||
|
#elif defined (__SYSTEM_CLOCK_72M_PLL_HXTAL)
|
||||||
|
uint32_t SystemCoreClock = __SYSTEM_CLOCK_72M_PLL_HXTAL;
|
||||||
|
static void system_clock_72m_hxtal(void);
|
||||||
|
#elif defined (__SYSTEM_CLOCK_96M_PLL_HXTAL)
|
||||||
|
uint32_t SystemCoreClock = __SYSTEM_CLOCK_96M_PLL_HXTAL;
|
||||||
|
static void system_clock_96m_hxtal(void);
|
||||||
|
#elif defined (__SYSTEM_CLOCK_108M_PLL_HXTAL)
|
||||||
|
uint32_t SystemCoreClock = __SYSTEM_CLOCK_108M_PLL_HXTAL;
|
||||||
|
static void system_clock_108m_hxtal(void);
|
||||||
|
#else
|
||||||
|
uint32_t SystemCoreClock = IRC8M_VALUE;
|
||||||
|
#endif /* __SYSTEM_CLOCK_48M_PLL_IRC8M */
|
||||||
|
|
||||||
|
/* configure the system clock */
|
||||||
|
static void system_clock_config(void);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief configure the system clock
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
static void system_clock_config(void)
|
||||||
|
{
|
||||||
|
#ifdef __SYSTEM_CLOCK_HXTAL
|
||||||
|
system_clock_hxtal();
|
||||||
|
#elif defined (__SYSTEM_CLOCK_24M_PLL_HXTAL)
|
||||||
|
system_clock_24m_hxtal();
|
||||||
|
#elif defined (__SYSTEM_CLOCK_36M_PLL_HXTAL)
|
||||||
|
system_clock_36m_hxtal();
|
||||||
|
#elif defined (__SYSTEM_CLOCK_48M_PLL_HXTAL)
|
||||||
|
system_clock_48m_hxtal();
|
||||||
|
#elif defined (__SYSTEM_CLOCK_56M_PLL_HXTAL)
|
||||||
|
system_clock_56m_hxtal();
|
||||||
|
#elif defined (__SYSTEM_CLOCK_72M_PLL_HXTAL)
|
||||||
|
system_clock_72m_hxtal();
|
||||||
|
#elif defined (__SYSTEM_CLOCK_96M_PLL_HXTAL)
|
||||||
|
system_clock_96m_hxtal();
|
||||||
|
#elif defined (__SYSTEM_CLOCK_108M_PLL_HXTAL)
|
||||||
|
system_clock_108m_hxtal();
|
||||||
|
|
||||||
|
#elif defined (__SYSTEM_CLOCK_48M_PLL_IRC8M)
|
||||||
|
system_clock_48m_irc8m();
|
||||||
|
#elif defined (__SYSTEM_CLOCK_72M_PLL_IRC8M)
|
||||||
|
system_clock_72m_irc8m();
|
||||||
|
#elif defined (__SYSTEM_CLOCK_108M_PLL_IRC8M)
|
||||||
|
system_clock_108m_irc8m();
|
||||||
|
#endif /* __SYSTEM_CLOCK_HXTAL */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief setup the microcontroller system, initialize the system
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void SystemInit(void)
|
||||||
|
{
|
||||||
|
/* reset the RCC clock configuration to the default reset state */
|
||||||
|
/* enable IRC8M */
|
||||||
|
RCU_CTL |= RCU_CTL_IRC8MEN;
|
||||||
|
|
||||||
|
/* reset SCS, AHBPSC, APB1PSC, APB2PSC, ADCPSC, CKOUT0SEL bits */
|
||||||
|
RCU_CFG0 &= ~(RCU_CFG0_SCS | RCU_CFG0_AHBPSC | RCU_CFG0_APB1PSC | RCU_CFG0_APB2PSC |
|
||||||
|
RCU_CFG0_ADCPSC | RCU_CFG0_ADCPSC_2 | RCU_CFG0_CKOUT0SEL);
|
||||||
|
|
||||||
|
/* reset HXTALEN, CKMEN, PLLEN bits */
|
||||||
|
RCU_CTL &= ~(RCU_CTL_HXTALEN | RCU_CTL_CKMEN | RCU_CTL_PLLEN);
|
||||||
|
|
||||||
|
/* Reset HXTALBPS bit */
|
||||||
|
RCU_CTL &= ~(RCU_CTL_HXTALBPS);
|
||||||
|
|
||||||
|
/* reset PLLSEL, PREDV0_LSB, PLLMF, USBFSPSC bits */
|
||||||
|
|
||||||
|
RCU_CFG0 &= ~(RCU_CFG0_PLLSEL | RCU_CFG0_PREDV0_LSB | RCU_CFG0_PLLMF |
|
||||||
|
RCU_CFG0_USBFSPSC | RCU_CFG0_PLLMF_4);
|
||||||
|
RCU_CFG1 = 0x00000000U;
|
||||||
|
|
||||||
|
/* Reset HXTALEN, CKMEN, PLLEN, PLL1EN and PLL2EN bits */
|
||||||
|
RCU_CTL &= ~(RCU_CTL_PLLEN | RCU_CTL_PLL1EN | RCU_CTL_PLL2EN | RCU_CTL_CKMEN | RCU_CTL_HXTALEN);
|
||||||
|
/* disable all interrupts */
|
||||||
|
RCU_INT = 0x00FF0000U;
|
||||||
|
|
||||||
|
/* Configure the System clock source, PLL Multiplier, AHB/APBx prescalers and Flash settings */
|
||||||
|
system_clock_config();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief update the SystemCoreClock with current core clock retrieved from cpu registers
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void SystemCoreClockUpdate(void)
|
||||||
|
{
|
||||||
|
uint32_t scss;
|
||||||
|
uint32_t pllsel, predv0sel, pllmf, ck_src;
|
||||||
|
uint32_t predv0, predv1, pll1mf;
|
||||||
|
|
||||||
|
scss = GET_BITS(RCU_CFG0, 2, 3);
|
||||||
|
|
||||||
|
switch (scss)
|
||||||
|
{
|
||||||
|
/* IRC8M is selected as CK_SYS */
|
||||||
|
case SEL_IRC8M:
|
||||||
|
SystemCoreClock = IRC8M_VALUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* HXTAL is selected as CK_SYS */
|
||||||
|
case SEL_HXTAL:
|
||||||
|
SystemCoreClock = HXTAL_VALUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* PLL is selected as CK_SYS */
|
||||||
|
case SEL_PLL:
|
||||||
|
/* PLL clock source selection, HXTAL or IRC8M/2 */
|
||||||
|
pllsel = (RCU_CFG0 & RCU_CFG0_PLLSEL);
|
||||||
|
|
||||||
|
|
||||||
|
if(RCU_PLLSRC_IRC8M_DIV2 == pllsel){
|
||||||
|
/* PLL clock source is IRC8M/2 */
|
||||||
|
ck_src = IRC8M_VALUE / 2U;
|
||||||
|
}else{
|
||||||
|
/* PLL clock source is HXTAL */
|
||||||
|
ck_src = HXTAL_VALUE;
|
||||||
|
|
||||||
|
predv0sel = (RCU_CFG1 & RCU_CFG1_PREDV0SEL);
|
||||||
|
|
||||||
|
/* source clock use PLL1 */
|
||||||
|
if(RCU_PREDV0SRC_CKPLL1 == predv0sel){
|
||||||
|
predv1 = ((RCU_CFG1 & RCU_CFG1_PREDV1) >> 4) + 1U;
|
||||||
|
pll1mf = ((RCU_CFG1 & RCU_CFG1_PLL1MF) >> 8) + 2U;
|
||||||
|
if(17U == pll1mf){
|
||||||
|
pll1mf = 20U;
|
||||||
|
}
|
||||||
|
ck_src = (ck_src / predv1) * pll1mf;
|
||||||
|
}
|
||||||
|
predv0 = (RCU_CFG1 & RCU_CFG1_PREDV0) + 1U;
|
||||||
|
ck_src /= predv0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* PLL multiplication factor */
|
||||||
|
pllmf = GET_BITS(RCU_CFG0, 18, 21);
|
||||||
|
|
||||||
|
if((RCU_CFG0 & RCU_CFG0_PLLMF_4)){
|
||||||
|
pllmf |= 0x10U;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pllmf >= 15U){
|
||||||
|
pllmf += 1U;
|
||||||
|
}else{
|
||||||
|
pllmf += 2U;
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemCoreClock = ck_src * pllmf;
|
||||||
|
|
||||||
|
if(15U == pllmf){
|
||||||
|
/* PLL source clock multiply by 6.5 */
|
||||||
|
SystemCoreClock = ck_src * 6U + ck_src / 2U;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* IRC8M is selected as CK_SYS */
|
||||||
|
default:
|
||||||
|
SystemCoreClock = IRC8M_VALUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __SYSTEM_CLOCK_HXTAL
|
||||||
|
/*!
|
||||||
|
\brief configure the system clock to HXTAL
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
static void system_clock_hxtal(void)
|
||||||
|
{
|
||||||
|
uint32_t timeout = 0U;
|
||||||
|
uint32_t stab_flag = 0U;
|
||||||
|
|
||||||
|
/* enable HXTAL */
|
||||||
|
RCU_CTL |= RCU_CTL_HXTALEN;
|
||||||
|
|
||||||
|
/* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
|
||||||
|
do{
|
||||||
|
timeout++;
|
||||||
|
stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
|
||||||
|
}while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
|
||||||
|
|
||||||
|
/* if fail */
|
||||||
|
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
|
||||||
|
while(1){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* AHB = SYSCLK */
|
||||||
|
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
|
||||||
|
/* APB2 = AHB/1 */
|
||||||
|
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
|
||||||
|
/* APB1 = AHB/2 */
|
||||||
|
RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
|
||||||
|
|
||||||
|
/* select HXTAL as system clock */
|
||||||
|
RCU_CFG0 &= ~RCU_CFG0_SCS;
|
||||||
|
RCU_CFG0 |= RCU_CKSYSSRC_HXTAL;
|
||||||
|
|
||||||
|
/* wait until HXTAL is selected as system clock */
|
||||||
|
while(0 == (RCU_CFG0 & RCU_SCSS_HXTAL)){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined (__SYSTEM_CLOCK_24M_PLL_HXTAL)
|
||||||
|
/*!
|
||||||
|
\brief configure the system clock to 24M by PLL which selects HXTAL(MD/HD/XD:8M; CL:25M) as its clock source
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
static void system_clock_24m_hxtal(void)
|
||||||
|
{
|
||||||
|
uint32_t timeout = 0U;
|
||||||
|
uint32_t stab_flag = 0U;
|
||||||
|
|
||||||
|
/* enable HXTAL */
|
||||||
|
RCU_CTL |= RCU_CTL_HXTALEN;
|
||||||
|
|
||||||
|
/* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
|
||||||
|
do{
|
||||||
|
timeout++;
|
||||||
|
stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
|
||||||
|
}while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
|
||||||
|
|
||||||
|
/* if fail */
|
||||||
|
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
|
||||||
|
while(1){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* HXTAL is stable */
|
||||||
|
/* AHB = SYSCLK */
|
||||||
|
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
|
||||||
|
/* APB2 = AHB/1 */
|
||||||
|
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
|
||||||
|
/* APB1 = AHB/2 */
|
||||||
|
RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
|
||||||
|
|
||||||
|
/* CK_PLL = (CK_PREDIV0) * 6 = 24 MHz */
|
||||||
|
RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
|
||||||
|
RCU_CFG0 |= (RCU_PLLSRC_HXTAL | RCU_PLL_MUL6);
|
||||||
|
|
||||||
|
if(HXTAL_VALUE==25000000){
|
||||||
|
/* CK_PREDIV0 = (CK_HXTAL)/5 *8 /10 = 4 MHz */
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV1 | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_CKPLL1 | RCU_PLL1_MUL8 | RCU_PREDV1_DIV5 | RCU_PREDV0_DIV10);
|
||||||
|
|
||||||
|
/* enable PLL1 */
|
||||||
|
RCU_CTL |= RCU_CTL_PLL1EN;
|
||||||
|
/* wait till PLL1 is ready */
|
||||||
|
while((RCU_CTL & RCU_CTL_PLL1STB) == 0){
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(HXTAL_VALUE==8000000){
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PREDV1 | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_HXTAL | RCU_PREDV0_DIV2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* enable PLL */
|
||||||
|
RCU_CTL |= RCU_CTL_PLLEN;
|
||||||
|
|
||||||
|
/* wait until PLL is stable */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select PLL as system clock */
|
||||||
|
RCU_CFG0 &= ~RCU_CFG0_SCS;
|
||||||
|
RCU_CFG0 |= RCU_CKSYSSRC_PLL;
|
||||||
|
|
||||||
|
/* wait until PLL is selected as system clock */
|
||||||
|
while(0U == (RCU_CFG0 & RCU_SCSS_PLL)){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined (__SYSTEM_CLOCK_36M_PLL_HXTAL)
|
||||||
|
/*!
|
||||||
|
\brief configure the system clock to 36M by PLL which selects HXTAL(MD/HD/XD:8M; CL:25M) as its clock source
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
static void system_clock_36m_hxtal(void)
|
||||||
|
{
|
||||||
|
uint32_t timeout = 0U;
|
||||||
|
uint32_t stab_flag = 0U;
|
||||||
|
|
||||||
|
/* enable HXTAL */
|
||||||
|
RCU_CTL |= RCU_CTL_HXTALEN;
|
||||||
|
|
||||||
|
/* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
|
||||||
|
do{
|
||||||
|
timeout++;
|
||||||
|
stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
|
||||||
|
}while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
|
||||||
|
|
||||||
|
/* if fail */
|
||||||
|
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
|
||||||
|
while(1){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* HXTAL is stable */
|
||||||
|
/* AHB = SYSCLK */
|
||||||
|
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
|
||||||
|
/* APB2 = AHB/1 */
|
||||||
|
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
|
||||||
|
/* APB1 = AHB/2 */
|
||||||
|
RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
|
||||||
|
|
||||||
|
/* CK_PLL = (CK_PREDIV0) * 9 = 36 MHz */
|
||||||
|
RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
|
||||||
|
RCU_CFG0 |= (RCU_PLLSRC_HXTAL | RCU_PLL_MUL9);
|
||||||
|
|
||||||
|
if(HXTAL_VALUE==25000000){
|
||||||
|
/* CK_PREDIV0 = (CK_HXTAL)/5 *8 /10 = 4 MHz */
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV1 | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_CKPLL1 | RCU_PLL1_MUL8 | RCU_PREDV1_DIV5 | RCU_PREDV0_DIV10);
|
||||||
|
|
||||||
|
/* enable PLL1 */
|
||||||
|
RCU_CTL |= RCU_CTL_PLL1EN;
|
||||||
|
/* wait till PLL1 is ready */
|
||||||
|
while((RCU_CTL & RCU_CTL_PLL1STB) == 0){
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(HXTAL_VALUE==8000000){
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PREDV1 | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_HXTAL | RCU_PREDV0_DIV2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* enable PLL */
|
||||||
|
RCU_CTL |= RCU_CTL_PLLEN;
|
||||||
|
|
||||||
|
/* wait until PLL is stable */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select PLL as system clock */
|
||||||
|
RCU_CFG0 &= ~RCU_CFG0_SCS;
|
||||||
|
RCU_CFG0 |= RCU_CKSYSSRC_PLL;
|
||||||
|
|
||||||
|
/* wait until PLL is selected as system clock */
|
||||||
|
while(0U == (RCU_CFG0 & RCU_SCSS_PLL)){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined (__SYSTEM_CLOCK_48M_PLL_HXTAL)
|
||||||
|
/*!
|
||||||
|
\brief configure the system clock to 48M by PLL which selects HXTAL(MD/HD/XD:8M; CL:25M) as its clock source
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
static void system_clock_48m_hxtal(void)
|
||||||
|
{
|
||||||
|
uint32_t timeout = 0U;
|
||||||
|
uint32_t stab_flag = 0U;
|
||||||
|
|
||||||
|
/* enable HXTAL */
|
||||||
|
RCU_CTL |= RCU_CTL_HXTALEN;
|
||||||
|
|
||||||
|
/* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
|
||||||
|
do{
|
||||||
|
timeout++;
|
||||||
|
stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
|
||||||
|
}while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
|
||||||
|
|
||||||
|
/* if fail */
|
||||||
|
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
|
||||||
|
while(1){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* HXTAL is stable */
|
||||||
|
/* AHB = SYSCLK */
|
||||||
|
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
|
||||||
|
/* APB2 = AHB/1 */
|
||||||
|
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
|
||||||
|
/* APB1 = AHB/2 */
|
||||||
|
RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
|
||||||
|
|
||||||
|
/* CK_PLL = (CK_PREDIV0) * 12 = 48 MHz */
|
||||||
|
RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
|
||||||
|
RCU_CFG0 |= (RCU_PLLSRC_HXTAL | RCU_PLL_MUL12);
|
||||||
|
|
||||||
|
if(HXTAL_VALUE==25000000){
|
||||||
|
|
||||||
|
/* CK_PREDIV0 = (CK_HXTAL)/5 *8 /10 = 4 MHz */
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV1 | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_CKPLL1 | RCU_PLL1_MUL8 | RCU_PREDV1_DIV5 | RCU_PREDV0_DIV10);
|
||||||
|
|
||||||
|
/* enable PLL1 */
|
||||||
|
RCU_CTL |= RCU_CTL_PLL1EN;
|
||||||
|
/* wait till PLL1 is ready */
|
||||||
|
while((RCU_CTL & RCU_CTL_PLL1STB) == 0){
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(HXTAL_VALUE==8000000){
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PREDV1 | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_HXTAL | RCU_PREDV0_DIV2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* enable PLL */
|
||||||
|
RCU_CTL |= RCU_CTL_PLLEN;
|
||||||
|
|
||||||
|
/* wait until PLL is stable */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select PLL as system clock */
|
||||||
|
RCU_CFG0 &= ~RCU_CFG0_SCS;
|
||||||
|
RCU_CFG0 |= RCU_CKSYSSRC_PLL;
|
||||||
|
|
||||||
|
/* wait until PLL is selected as system clock */
|
||||||
|
while(0U == (RCU_CFG0 & RCU_SCSS_PLL)){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined (__SYSTEM_CLOCK_56M_PLL_HXTAL)
|
||||||
|
/*!
|
||||||
|
\brief configure the system clock to 56M by PLL which selects HXTAL(MD/HD/XD:8M; CL:25M) as its clock source
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
static void system_clock_56m_hxtal(void)
|
||||||
|
{
|
||||||
|
uint32_t timeout = 0U;
|
||||||
|
uint32_t stab_flag = 0U;
|
||||||
|
|
||||||
|
/* enable HXTAL */
|
||||||
|
RCU_CTL |= RCU_CTL_HXTALEN;
|
||||||
|
|
||||||
|
/* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
|
||||||
|
do{
|
||||||
|
timeout++;
|
||||||
|
stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
|
||||||
|
}while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
|
||||||
|
|
||||||
|
/* if fail */
|
||||||
|
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
|
||||||
|
while(1){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* HXTAL is stable */
|
||||||
|
/* AHB = SYSCLK */
|
||||||
|
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
|
||||||
|
/* APB2 = AHB/1 */
|
||||||
|
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
|
||||||
|
/* APB1 = AHB/2 */
|
||||||
|
RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
|
||||||
|
|
||||||
|
/* CK_PLL = (CK_PREDIV0) * 14 = 56 MHz */
|
||||||
|
RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
|
||||||
|
RCU_CFG0 |= (RCU_PLLSRC_HXTAL | RCU_PLL_MUL14);
|
||||||
|
|
||||||
|
if(HXTAL_VALUE==25000000){
|
||||||
|
|
||||||
|
/* CK_PREDIV0 = (CK_HXTAL)/5 *8 /10 = 4 MHz */
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV1 | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_CKPLL1 | RCU_PLL1_MUL8 | RCU_PREDV1_DIV5 | RCU_PREDV0_DIV10);
|
||||||
|
|
||||||
|
/* enable PLL1 */
|
||||||
|
RCU_CTL |= RCU_CTL_PLL1EN;
|
||||||
|
/* wait till PLL1 is ready */
|
||||||
|
while((RCU_CTL & RCU_CTL_PLL1STB) == 0){
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(HXTAL_VALUE==8000000){
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PREDV1 | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_HXTAL | RCU_PREDV0_DIV2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* enable PLL */
|
||||||
|
RCU_CTL |= RCU_CTL_PLLEN;
|
||||||
|
|
||||||
|
/* wait until PLL is stable */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select PLL as system clock */
|
||||||
|
RCU_CFG0 &= ~RCU_CFG0_SCS;
|
||||||
|
RCU_CFG0 |= RCU_CKSYSSRC_PLL;
|
||||||
|
|
||||||
|
/* wait until PLL is selected as system clock */
|
||||||
|
while(0U == (RCU_CFG0 & RCU_SCSS_PLL)){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined (__SYSTEM_CLOCK_72M_PLL_HXTAL)
|
||||||
|
/*!
|
||||||
|
\brief configure the system clock to 72M by PLL which selects HXTAL(MD/HD/XD:8M; CL:25M) as its clock source
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
static void system_clock_72m_hxtal(void)
|
||||||
|
{
|
||||||
|
uint32_t timeout = 0U;
|
||||||
|
uint32_t stab_flag = 0U;
|
||||||
|
|
||||||
|
/* enable HXTAL */
|
||||||
|
RCU_CTL |= RCU_CTL_HXTALEN;
|
||||||
|
|
||||||
|
/* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
|
||||||
|
do{
|
||||||
|
timeout++;
|
||||||
|
stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
|
||||||
|
}while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
|
||||||
|
|
||||||
|
/* if fail */
|
||||||
|
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
|
||||||
|
while(1){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* HXTAL is stable */
|
||||||
|
/* AHB = SYSCLK */
|
||||||
|
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
|
||||||
|
/* APB2 = AHB/1 */
|
||||||
|
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
|
||||||
|
/* APB1 = AHB/2 */
|
||||||
|
RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
|
||||||
|
|
||||||
|
/* CK_PLL = (CK_PREDIV0) * 18 = 72 MHz */
|
||||||
|
RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
|
||||||
|
RCU_CFG0 |= (RCU_PLLSRC_HXTAL | RCU_PLL_MUL18);
|
||||||
|
|
||||||
|
|
||||||
|
if(HXTAL_VALUE==25000000){
|
||||||
|
|
||||||
|
/* CK_PREDIV0 = (CK_HXTAL)/5 *8 /10 = 4 MHz */
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV1 | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_CKPLL1 | RCU_PLL1_MUL8 | RCU_PREDV1_DIV5 | RCU_PREDV0_DIV10);
|
||||||
|
|
||||||
|
/* enable PLL1 */
|
||||||
|
RCU_CTL |= RCU_CTL_PLL1EN;
|
||||||
|
/* wait till PLL1 is ready */
|
||||||
|
while((RCU_CTL & RCU_CTL_PLL1STB) == 0){
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(HXTAL_VALUE==8000000){
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PREDV1 | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_HXTAL | RCU_PREDV0_DIV2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* enable PLL */
|
||||||
|
RCU_CTL |= RCU_CTL_PLLEN;
|
||||||
|
|
||||||
|
/* wait until PLL is stable */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select PLL as system clock */
|
||||||
|
RCU_CFG0 &= ~RCU_CFG0_SCS;
|
||||||
|
RCU_CFG0 |= RCU_CKSYSSRC_PLL;
|
||||||
|
|
||||||
|
/* wait until PLL is selected as system clock */
|
||||||
|
while(0U == (RCU_CFG0 & RCU_SCSS_PLL)){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined (__SYSTEM_CLOCK_96M_PLL_HXTAL)
|
||||||
|
/*!
|
||||||
|
\brief configure the system clock to 96M by PLL which selects HXTAL(MD/HD/XD:8M; CL:25M) as its clock source
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
static void system_clock_96m_hxtal(void)
|
||||||
|
{
|
||||||
|
uint32_t timeout = 0U;
|
||||||
|
uint32_t stab_flag = 0U;
|
||||||
|
|
||||||
|
/* enable HXTAL */
|
||||||
|
RCU_CTL |= RCU_CTL_HXTALEN;
|
||||||
|
|
||||||
|
/* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
|
||||||
|
do{
|
||||||
|
timeout++;
|
||||||
|
stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
|
||||||
|
}while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
|
||||||
|
|
||||||
|
/* if fail */
|
||||||
|
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
|
||||||
|
while(1){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* HXTAL is stable */
|
||||||
|
/* AHB = SYSCLK */
|
||||||
|
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
|
||||||
|
/* APB2 = AHB/1 */
|
||||||
|
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
|
||||||
|
/* APB1 = AHB/2 */
|
||||||
|
RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
|
||||||
|
|
||||||
|
if(HXTAL_VALUE==25000000){
|
||||||
|
|
||||||
|
/* CK_PLL = (CK_PREDIV0) * 24 = 96 MHz */
|
||||||
|
RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
|
||||||
|
RCU_CFG0 |= (RCU_PLLSRC_HXTAL | RCU_PLL_MUL24);
|
||||||
|
|
||||||
|
/* CK_PREDIV0 = (CK_HXTAL)/5 *8 /10 = 4 MHz */
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV1 | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_CKPLL1 | RCU_PLL1_MUL8 | RCU_PREDV1_DIV5 | RCU_PREDV0_DIV10);
|
||||||
|
/* enable PLL1 */
|
||||||
|
RCU_CTL |= RCU_CTL_PLL1EN;
|
||||||
|
/* wait till PLL1 is ready */
|
||||||
|
while((RCU_CTL & RCU_CTL_PLL1STB) == 0){
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(HXTAL_VALUE==8000000){
|
||||||
|
/* CK_PLL = (CK_PREDIV0) * 24 = 96 MHz */
|
||||||
|
RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
|
||||||
|
RCU_CFG0 |= (RCU_PLLSRC_HXTAL | RCU_PLL_MUL24);
|
||||||
|
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PREDV1 | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_HXTAL | RCU_PREDV0_DIV2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* enable PLL */
|
||||||
|
RCU_CTL |= RCU_CTL_PLLEN;
|
||||||
|
|
||||||
|
/* wait until PLL is stable */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select PLL as system clock */
|
||||||
|
RCU_CFG0 &= ~RCU_CFG0_SCS;
|
||||||
|
RCU_CFG0 |= RCU_CKSYSSRC_PLL;
|
||||||
|
|
||||||
|
/* wait until PLL is selected as system clock */
|
||||||
|
while(0U == (RCU_CFG0 & RCU_SCSS_PLL)){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined (__SYSTEM_CLOCK_108M_PLL_HXTAL)
|
||||||
|
/*!
|
||||||
|
\brief configure the system clock to 108M by PLL which selects HXTAL(MD/HD/XD:8M; CL:25M) as its clock source
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void system_clock_108m_hxtal(void)
|
||||||
|
{
|
||||||
|
uint32_t timeout = 0U;
|
||||||
|
uint32_t stab_flag = 0U;
|
||||||
|
|
||||||
|
/* enable HXTAL */
|
||||||
|
RCU_CTL |= RCU_CTL_HXTALEN;
|
||||||
|
|
||||||
|
/* wait until HXTAL is stable or the startup time is longer than HXTAL_STARTUP_TIMEOUT */
|
||||||
|
do{
|
||||||
|
timeout++;
|
||||||
|
stab_flag = (RCU_CTL & RCU_CTL_HXTALSTB);
|
||||||
|
}while((0U == stab_flag) && (HXTAL_STARTUP_TIMEOUT != timeout));
|
||||||
|
|
||||||
|
/* if fail */
|
||||||
|
if(0U == (RCU_CTL & RCU_CTL_HXTALSTB)){
|
||||||
|
while(1){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* HXTAL is stable */
|
||||||
|
/* AHB = SYSCLK */
|
||||||
|
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
|
||||||
|
/* APB2 = AHB/1 */
|
||||||
|
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
|
||||||
|
/* APB1 = AHB/2 */
|
||||||
|
RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
|
||||||
|
|
||||||
|
/* CK_PLL = (CK_PREDIV0) * 27 = 108 MHz */
|
||||||
|
RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
|
||||||
|
RCU_CFG0 |= (RCU_PLLSRC_HXTAL | RCU_PLL_MUL27);
|
||||||
|
|
||||||
|
if(HXTAL_VALUE==25000000){
|
||||||
|
/* CK_PREDIV0 = (CK_HXTAL)/5 *8 /10 = 4 MHz */
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PREDV1 | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_CKPLL1 | RCU_PREDV1_DIV5 | RCU_PLL1_MUL8 | RCU_PREDV0_DIV10);
|
||||||
|
|
||||||
|
/* enable PLL1 */
|
||||||
|
RCU_CTL |= RCU_CTL_PLL1EN;
|
||||||
|
/* wait till PLL1 is ready */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLL1STB)){
|
||||||
|
}
|
||||||
|
|
||||||
|
/* enable PLL1 */
|
||||||
|
RCU_CTL |= RCU_CTL_PLL2EN;
|
||||||
|
/* wait till PLL1 is ready */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLL2STB)){
|
||||||
|
}
|
||||||
|
}else if(HXTAL_VALUE==8000000){
|
||||||
|
RCU_CFG1 &= ~(RCU_CFG1_PREDV0SEL | RCU_CFG1_PREDV1 | RCU_CFG1_PLL1MF | RCU_CFG1_PREDV0);
|
||||||
|
RCU_CFG1 |= (RCU_PREDV0SRC_HXTAL | RCU_PREDV0_DIV2 | RCU_PREDV1_DIV2 | RCU_PLL1_MUL20 | RCU_PLL2_MUL20);
|
||||||
|
|
||||||
|
/* enable PLL1 */
|
||||||
|
RCU_CTL |= RCU_CTL_PLL1EN;
|
||||||
|
/* wait till PLL1 is ready */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLL1STB)){
|
||||||
|
}
|
||||||
|
|
||||||
|
/* enable PLL2 */
|
||||||
|
RCU_CTL |= RCU_CTL_PLL2EN;
|
||||||
|
/* wait till PLL1 is ready */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLL2STB)){
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/* enable PLL */
|
||||||
|
RCU_CTL |= RCU_CTL_PLLEN;
|
||||||
|
|
||||||
|
/* wait until PLL is stable */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select PLL as system clock */
|
||||||
|
RCU_CFG0 &= ~RCU_CFG0_SCS;
|
||||||
|
RCU_CFG0 |= RCU_CKSYSSRC_PLL;
|
||||||
|
|
||||||
|
/* wait until PLL is selected as system clock */
|
||||||
|
while(0U == (RCU_CFG0 & RCU_SCSS_PLL)){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined (__SYSTEM_CLOCK_48M_PLL_IRC8M)
|
||||||
|
/*!
|
||||||
|
\brief configure the system clock to 48M by PLL which selects IRC8M as its clock source
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
static void system_clock_48m_irc8m(void)
|
||||||
|
{
|
||||||
|
uint32_t timeout = 0U;
|
||||||
|
uint32_t stab_flag = 0U;
|
||||||
|
|
||||||
|
/* enable IRC8M */
|
||||||
|
RCU_CTL |= RCU_CTL_IRC8MEN;
|
||||||
|
|
||||||
|
/* wait until IRC8M is stable or the startup time is longer than IRC8M_STARTUP_TIMEOUT */
|
||||||
|
do{
|
||||||
|
timeout++;
|
||||||
|
stab_flag = (RCU_CTL & RCU_CTL_IRC8MSTB);
|
||||||
|
}
|
||||||
|
while((0U == stab_flag) && (IRC8M_STARTUP_TIMEOUT != timeout));
|
||||||
|
|
||||||
|
/* if fail */
|
||||||
|
if(0U == (RCU_CTL & RCU_CTL_IRC8MSTB)){
|
||||||
|
while(1){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IRC8M is stable */
|
||||||
|
/* AHB = SYSCLK */
|
||||||
|
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
|
||||||
|
/* APB2 = AHB/1 */
|
||||||
|
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
|
||||||
|
/* APB1 = AHB/2 */
|
||||||
|
RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
|
||||||
|
|
||||||
|
/* CK_PLL = (CK_IRC8M/2) * 12 = 48 MHz */
|
||||||
|
RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
|
||||||
|
RCU_CFG0 |= RCU_PLL_MUL12;
|
||||||
|
|
||||||
|
/* enable PLL */
|
||||||
|
RCU_CTL |= RCU_CTL_PLLEN;
|
||||||
|
|
||||||
|
/* wait until PLL is stable */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select PLL as system clock */
|
||||||
|
RCU_CFG0 &= ~RCU_CFG0_SCS;
|
||||||
|
RCU_CFG0 |= RCU_CKSYSSRC_PLL;
|
||||||
|
|
||||||
|
/* wait until PLL is selected as system clock */
|
||||||
|
while(0U == (RCU_CFG0 & RCU_SCSS_PLL)){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined (__SYSTEM_CLOCK_72M_PLL_IRC8M)
|
||||||
|
/*!
|
||||||
|
\brief configure the system clock to 72M by PLL which selects IRC8M as its clock source
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
static void system_clock_72m_irc8m(void)
|
||||||
|
{
|
||||||
|
uint32_t timeout = 0U;
|
||||||
|
uint32_t stab_flag = 0U;
|
||||||
|
|
||||||
|
/* enable IRC8M */
|
||||||
|
RCU_CTL |= RCU_CTL_IRC8MEN;
|
||||||
|
|
||||||
|
/* wait until IRC8M is stable or the startup time is longer than IRC8M_STARTUP_TIMEOUT */
|
||||||
|
do{
|
||||||
|
timeout++;
|
||||||
|
stab_flag = (RCU_CTL & RCU_CTL_IRC8MSTB);
|
||||||
|
}
|
||||||
|
while((0U == stab_flag) && (IRC8M_STARTUP_TIMEOUT != timeout));
|
||||||
|
|
||||||
|
/* if fail */
|
||||||
|
if(0U == (RCU_CTL & RCU_CTL_IRC8MSTB)){
|
||||||
|
while(1){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IRC8M is stable */
|
||||||
|
/* AHB = SYSCLK */
|
||||||
|
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
|
||||||
|
/* APB2 = AHB/1 */
|
||||||
|
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
|
||||||
|
/* APB1 = AHB/2 */
|
||||||
|
RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
|
||||||
|
|
||||||
|
/* CK_PLL = (CK_IRC8M/2) * 18 = 72 MHz */
|
||||||
|
RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
|
||||||
|
RCU_CFG0 |= RCU_PLL_MUL18;
|
||||||
|
|
||||||
|
/* enable PLL */
|
||||||
|
RCU_CTL |= RCU_CTL_PLLEN;
|
||||||
|
|
||||||
|
/* wait until PLL is stable */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select PLL as system clock */
|
||||||
|
RCU_CFG0 &= ~RCU_CFG0_SCS;
|
||||||
|
RCU_CFG0 |= RCU_CKSYSSRC_PLL;
|
||||||
|
|
||||||
|
/* wait until PLL is selected as system clock */
|
||||||
|
while(0U == (RCU_CFG0 & RCU_SCSS_PLL)){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined (__SYSTEM_CLOCK_108M_PLL_IRC8M)
|
||||||
|
/*!
|
||||||
|
\brief configure the system clock to 108M by PLL which selects IRC8M as its clock source
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
static void system_clock_108m_irc8m(void)
|
||||||
|
{
|
||||||
|
uint32_t timeout = 0U;
|
||||||
|
uint32_t stab_flag = 0U;
|
||||||
|
|
||||||
|
/* enable IRC8M */
|
||||||
|
RCU_CTL |= RCU_CTL_IRC8MEN;
|
||||||
|
|
||||||
|
/* wait until IRC8M is stable or the startup time is longer than IRC8M_STARTUP_TIMEOUT */
|
||||||
|
do{
|
||||||
|
timeout++;
|
||||||
|
stab_flag = (RCU_CTL & RCU_CTL_IRC8MSTB);
|
||||||
|
}
|
||||||
|
while((0U == stab_flag) && (IRC8M_STARTUP_TIMEOUT != timeout));
|
||||||
|
|
||||||
|
/* if fail */
|
||||||
|
if(0U == (RCU_CTL & RCU_CTL_IRC8MSTB)){
|
||||||
|
while(1){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* IRC8M is stable */
|
||||||
|
/* AHB = SYSCLK */
|
||||||
|
RCU_CFG0 |= RCU_AHB_CKSYS_DIV1;
|
||||||
|
/* APB2 = AHB/1 */
|
||||||
|
RCU_CFG0 |= RCU_APB2_CKAHB_DIV1;
|
||||||
|
/* APB1 = AHB/2 */
|
||||||
|
RCU_CFG0 |= RCU_APB1_CKAHB_DIV2;
|
||||||
|
|
||||||
|
/* CK_PLL = (CK_IRC8M/2) * 27 = 108 MHz */
|
||||||
|
RCU_CFG0 &= ~(RCU_CFG0_PLLMF | RCU_CFG0_PLLMF_4);
|
||||||
|
RCU_CFG0 |= RCU_PLL_MUL27;
|
||||||
|
|
||||||
|
/* enable PLL */
|
||||||
|
RCU_CTL |= RCU_CTL_PLLEN;
|
||||||
|
|
||||||
|
/* wait until PLL is stable */
|
||||||
|
while(0U == (RCU_CTL & RCU_CTL_PLLSTB)){
|
||||||
|
}
|
||||||
|
|
||||||
|
/* select PLL as system clock */
|
||||||
|
RCU_CFG0 &= ~RCU_CFG0_SCS;
|
||||||
|
RCU_CFG0 |= RCU_CKSYSSRC_PLL;
|
||||||
|
|
||||||
|
/* wait until PLL is selected as system clock */
|
||||||
|
while(0U == (RCU_CFG0 & RCU_SCSS_PLL)){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,454 @@
|
|||||||
|
/*!
|
||||||
|
\file usbh_msc_bbb.c
|
||||||
|
\brief USB MSC BBB protocol related functions
|
||||||
|
|
||||||
|
\version 2019-06-05, V1.0.0, firmware for GD32VF103
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) 2019, GigaDevice Semiconductor Inc.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the copyright holder nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "usbh_transc.h"
|
||||||
|
#include "drv_usbh_int.h"
|
||||||
|
#include "usbh_msc_core.h"
|
||||||
|
#include "usbh_msc_scsi.h"
|
||||||
|
#include "usbh_msc_bbb.h"
|
||||||
|
|
||||||
|
usbh_cbw_pkt msc_cbw_data;
|
||||||
|
usbh_csw_pkt msc_csw_data;
|
||||||
|
|
||||||
|
static uint32_t bot_stall_error_count; /* keeps count of stall error cases */
|
||||||
|
usbh_botxfer msc_botxfer_param;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief initialize the mass storage parameters
|
||||||
|
\param[in] pudev: pointer to usb core instance
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_msc_init (usb_core_driver *pudev)
|
||||||
|
{
|
||||||
|
if (pudev->host.connect_status) {
|
||||||
|
msc_cbw_data.field.dCBWSignature = BBB_CBW_SIGNATURE;
|
||||||
|
msc_cbw_data.field.dCBWTag = USBH_MSC_BOT_CBW_TAG;
|
||||||
|
msc_cbw_data.field.bCBWLUN = 0; /* only one lun is supported */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bot_stall_error_count = 0;
|
||||||
|
|
||||||
|
msc_error_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief manage the different states of BOT transfer and updates the status to upper layer
|
||||||
|
\param[in] pudev: pointer to usb core instance
|
||||||
|
\param[in] puhost: pointer to usb host
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_msc_botxfer (usb_core_driver *pudev, usbh_host *puhost)
|
||||||
|
{
|
||||||
|
uint8_t xfer_dir, index;
|
||||||
|
static uint32_t remain_len;
|
||||||
|
static uint8_t *data_pointer, *data_pointer_prev;
|
||||||
|
static uint8_t error_dir;
|
||||||
|
|
||||||
|
usbh_status status;
|
||||||
|
|
||||||
|
usb_urb_state URB_Status = URB_IDLE;
|
||||||
|
|
||||||
|
if (pudev->host.connect_status) {
|
||||||
|
switch (msc_botxfer_param.bot_state) {
|
||||||
|
case USBH_MSC_SEND_CBW:
|
||||||
|
/* send CBW */
|
||||||
|
usbh_data_send (pudev,
|
||||||
|
&msc_cbw_data.CBWArray[0],
|
||||||
|
msc_machine.hc_num_out,
|
||||||
|
BBB_CBW_LENGTH);
|
||||||
|
|
||||||
|
msc_botxfer_param.bot_state_bkp = USBH_MSC_SEND_CBW;
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_SENT_CBW;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_SENT_CBW:
|
||||||
|
URB_Status = usbh_urbstate_get(pudev, msc_machine.hc_num_out);
|
||||||
|
|
||||||
|
if (URB_Status == URB_DONE) {
|
||||||
|
bot_stall_error_count = 0;
|
||||||
|
msc_botxfer_param.bot_state_bkp = USBH_MSC_SENT_CBW;
|
||||||
|
|
||||||
|
/* if the CBW packet is sent successful, then change the state */
|
||||||
|
xfer_dir = (msc_cbw_data.field.bmCBWFlags & USB_TRX_MASK);
|
||||||
|
|
||||||
|
if (msc_cbw_data.field.dCBWDataTransferLength != 0) {
|
||||||
|
remain_len = msc_cbw_data.field.dCBWDataTransferLength;
|
||||||
|
data_pointer = msc_botxfer_param.xfer_buf;
|
||||||
|
data_pointer_prev = data_pointer;
|
||||||
|
|
||||||
|
/* if there is data transfer stage */
|
||||||
|
if (xfer_dir == USB_TRX_IN) {
|
||||||
|
/* data direction is IN */
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_BOT_DATAIN_STATE;
|
||||||
|
} else {
|
||||||
|
/* data direction is OUT */
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_BOT_DATAOUT_STATE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* If there is NO Data Transfer Stage */
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_RECEIVE_CSW_STATE;
|
||||||
|
}
|
||||||
|
} else if (URB_Status == URB_NOTREADY) {
|
||||||
|
msc_botxfer_param.bot_state = msc_botxfer_param.bot_state_bkp;
|
||||||
|
} else if (URB_Status == URB_STALL) {
|
||||||
|
error_dir = USBH_MSC_DIR_OUT;
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_BOT_ERROR_OUT;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_BOT_DATAIN_STATE:
|
||||||
|
URB_Status = usbh_urbstate_get(pudev, msc_machine.hc_num_in);
|
||||||
|
|
||||||
|
/* BOT DATA IN stage */
|
||||||
|
if ((URB_Status == URB_DONE) ||
|
||||||
|
(msc_botxfer_param.bot_state_bkp != USBH_MSC_BOT_DATAIN_STATE)) {
|
||||||
|
bot_stall_error_count = 0;
|
||||||
|
msc_botxfer_param.bot_state_bkp = USBH_MSC_BOT_DATAIN_STATE;
|
||||||
|
|
||||||
|
if (remain_len > msc_machine.msc_bulk_epinsize) {
|
||||||
|
usbh_data_recev (pudev,
|
||||||
|
data_pointer,
|
||||||
|
msc_machine.hc_num_in,
|
||||||
|
msc_machine.msc_bulk_epinsize);
|
||||||
|
|
||||||
|
remain_len -= msc_machine.msc_bulk_epinsize;
|
||||||
|
data_pointer = data_pointer + msc_machine.msc_bulk_epinsize;
|
||||||
|
} else if (remain_len == 0) {
|
||||||
|
/* if value was 0, and successful transfer, then change the state */
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_RECEIVE_CSW_STATE;
|
||||||
|
} else {
|
||||||
|
usbh_data_recev (pudev,
|
||||||
|
data_pointer,
|
||||||
|
msc_machine.hc_num_in,
|
||||||
|
remain_len);
|
||||||
|
|
||||||
|
remain_len = 0; /* reset this value and keep in same state */
|
||||||
|
}
|
||||||
|
} else if(URB_Status == URB_STALL) {
|
||||||
|
/* this is data stage stall condition */
|
||||||
|
|
||||||
|
error_dir = USBH_MSC_DIR_IN;
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_BOT_ERROR_IN;
|
||||||
|
|
||||||
|
/* Refer to USB Mass-Storage Class : BOT (www.usb.org)
|
||||||
|
6.7.2 Host expects to receive data from the device
|
||||||
|
3. On a STALL condition receiving data, then:
|
||||||
|
The host shall accept the data received.
|
||||||
|
The host shall clear the Bulk-In pipe.
|
||||||
|
4. The host shall attempt to receive a CSW.
|
||||||
|
|
||||||
|
msc_botxfer_param.bot_state_bkp is used to switch to the Original
|
||||||
|
state after the ClearFeature Command is issued.
|
||||||
|
*/
|
||||||
|
msc_botxfer_param.bot_state_bkp = USBH_MSC_RECEIVE_CSW_STATE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_BOT_DATAOUT_STATE:
|
||||||
|
/* BOT DATA OUT stage */
|
||||||
|
URB_Status = usbh_urbstate_get(pudev, msc_machine.hc_num_out);
|
||||||
|
if (URB_Status == URB_DONE) {
|
||||||
|
bot_stall_error_count = 0;
|
||||||
|
msc_botxfer_param.bot_state_bkp = USBH_MSC_BOT_DATAOUT_STATE;
|
||||||
|
|
||||||
|
if (remain_len > msc_machine.msc_bulk_epoutsize) {
|
||||||
|
usbh_data_send (pudev,
|
||||||
|
data_pointer,
|
||||||
|
msc_machine.hc_num_out,
|
||||||
|
msc_machine.msc_bulk_epoutsize);
|
||||||
|
|
||||||
|
data_pointer_prev = data_pointer;
|
||||||
|
data_pointer = data_pointer + msc_machine.msc_bulk_epoutsize;
|
||||||
|
|
||||||
|
remain_len = remain_len - msc_machine.msc_bulk_epoutsize;
|
||||||
|
} else if (remain_len == 0) {
|
||||||
|
/* if value was 0, and successful transfer, then change the state */
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_RECEIVE_CSW_STATE;
|
||||||
|
} else {
|
||||||
|
usbh_data_send (pudev,
|
||||||
|
data_pointer,
|
||||||
|
msc_machine.hc_num_out,
|
||||||
|
remain_len);
|
||||||
|
|
||||||
|
remain_len = 0; /* reset this value and keep in same state */
|
||||||
|
}
|
||||||
|
} else if (URB_Status == URB_NOTREADY) {
|
||||||
|
if (data_pointer != data_pointer_prev) {
|
||||||
|
usbh_data_send (pudev,
|
||||||
|
(data_pointer - msc_machine.msc_bulk_epoutsize),
|
||||||
|
msc_machine.hc_num_out,
|
||||||
|
msc_machine.msc_bulk_epoutsize);
|
||||||
|
} else {
|
||||||
|
usbh_data_send (pudev,
|
||||||
|
data_pointer,
|
||||||
|
msc_machine.hc_num_out,
|
||||||
|
msc_machine.msc_bulk_epoutsize);
|
||||||
|
}
|
||||||
|
} else if (URB_Status == URB_STALL) {
|
||||||
|
error_dir = USBH_MSC_DIR_OUT;
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_BOT_ERROR_OUT;
|
||||||
|
|
||||||
|
/* Refer to USB Mass-Storage Class : BOT (www.usb.org)
|
||||||
|
6.7.3 Ho - Host expects to send data to the device
|
||||||
|
3. On a STALL condition sending data, then:
|
||||||
|
" The host shall clear the Bulk-Out pipe.
|
||||||
|
4. The host shall attempt to receive a CSW.
|
||||||
|
|
||||||
|
The Above statement will do the clear the Bulk-Out pipe.
|
||||||
|
The Below statement will help in Getting the CSW.
|
||||||
|
|
||||||
|
msc_botxfer_param.bot_state_bkp is used to switch to the Original
|
||||||
|
state after the ClearFeature Command is issued.
|
||||||
|
*/
|
||||||
|
|
||||||
|
msc_botxfer_param.bot_state_bkp = USBH_MSC_RECEIVE_CSW_STATE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_RECEIVE_CSW_STATE:
|
||||||
|
/* BOT CSW stage */
|
||||||
|
/* NOTE: We cannot reset the BOTStallErrorCount here as it may come from the clearFeature from previous command */
|
||||||
|
msc_botxfer_param.bot_state_bkp = USBH_MSC_RECEIVE_CSW_STATE;
|
||||||
|
msc_botxfer_param.xfer_buf = msc_csw_data.CSWArray;
|
||||||
|
msc_botxfer_param.data_len = USBH_MSC_CSW_MAX_LENGTH;
|
||||||
|
|
||||||
|
for (index = BBB_CSW_LENGTH; index != 0; index--) {
|
||||||
|
msc_csw_data.CSWArray[index] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
msc_csw_data.CSWArray[0] = 0;
|
||||||
|
|
||||||
|
usbh_data_recev (pudev,
|
||||||
|
msc_botxfer_param.xfer_buf,
|
||||||
|
msc_machine.hc_num_in,
|
||||||
|
USBH_MSC_CSW_MAX_LENGTH);
|
||||||
|
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_DECODE_CSW;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_DECODE_CSW:
|
||||||
|
URB_Status = usbh_urbstate_get(pudev, msc_machine.hc_num_in);
|
||||||
|
|
||||||
|
/* decode CSW */
|
||||||
|
if (URB_Status == URB_DONE) {
|
||||||
|
bot_stall_error_count = 0;
|
||||||
|
msc_botxfer_param.bot_state_bkp = USBH_MSC_RECEIVE_CSW_STATE;
|
||||||
|
msc_botxfer_param.msc_state = msc_botxfer_param.msc_state_current ;
|
||||||
|
msc_botxfer_param.bot_xfer_status = usbh_msc_csw_decode (pudev , puhost);
|
||||||
|
} else if (URB_Status == URB_STALL) {
|
||||||
|
error_dir = USBH_MSC_DIR_IN;
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_BOT_ERROR_IN;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_BOT_ERROR_IN:
|
||||||
|
status = usbh_msc_bot_abort(pudev, puhost, USBH_MSC_DIR_IN);
|
||||||
|
|
||||||
|
if (status == USBH_OK) {
|
||||||
|
/* check if the error was due in both the directions */
|
||||||
|
if (error_dir == USBH_MSC_BOTH_DIR) {
|
||||||
|
/* if both directions are needed, switch to OUT direction */
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_BOT_ERROR_OUT;
|
||||||
|
} else {
|
||||||
|
/* switch back to the original state, in many cases this will be USBH_MSC_RECEIVE_CSW_STATE state */
|
||||||
|
msc_botxfer_param.bot_state = msc_botxfer_param.bot_state_bkp;
|
||||||
|
}
|
||||||
|
} else if (status == USBH_UNRECOVERED_ERROR) {
|
||||||
|
/* this means that there is a stall error limit, do reset recovery */
|
||||||
|
msc_botxfer_param.bot_xfer_status = USBH_MSC_PHASE_ERROR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_BOT_ERROR_OUT:
|
||||||
|
status = usbh_msc_bot_abort (pudev, puhost, USBH_MSC_DIR_OUT);
|
||||||
|
|
||||||
|
if (status == USBH_OK) {
|
||||||
|
/* switch back to the original state */
|
||||||
|
msc_botxfer_param.bot_state = msc_botxfer_param.bot_state_bkp;
|
||||||
|
} else if (status == USBH_UNRECOVERED_ERROR) {
|
||||||
|
/* this means that there is a stall error limit, do reset recovery */
|
||||||
|
msc_botxfer_param.bot_xfer_status = USBH_MSC_PHASE_ERROR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief manages the different error handling for stall
|
||||||
|
\param[in] pudev: pointer to usb core instance
|
||||||
|
\param[in] puhost: pointer to usb host
|
||||||
|
\param[in] direction: data IN or OUT
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
usbh_status usbh_msc_bot_abort (usb_core_driver *pudev, usbh_host *puhost, uint8_t direction)
|
||||||
|
{
|
||||||
|
usbh_status status = USBH_BUSY;
|
||||||
|
|
||||||
|
switch (direction) {
|
||||||
|
case USBH_MSC_DIR_IN :
|
||||||
|
/* send clrfeture command on bulk IN endpoint */
|
||||||
|
status = usbh_clrfeature(pudev,
|
||||||
|
puhost,
|
||||||
|
msc_machine.msc_bulk_epin,
|
||||||
|
msc_machine.hc_num_in);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_DIR_OUT :
|
||||||
|
/*send clrfeature command on bulk OUT endpoint */
|
||||||
|
status = usbh_clrfeature(pudev,
|
||||||
|
puhost,
|
||||||
|
msc_machine.msc_bulk_epout,
|
||||||
|
msc_machine.hc_num_out);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
bot_stall_error_count++; /* check continous number of times, stall has occured */
|
||||||
|
|
||||||
|
if (bot_stall_error_count > MAX_BULK_STALL_COUNT_LIMIT) {
|
||||||
|
status = USBH_UNRECOVERED_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief decode the CSW received by the device and updates the same to upper layer
|
||||||
|
\param[in] pudev: pointer to usb core instance
|
||||||
|
\param[in] puhost: pointer to usb host
|
||||||
|
\param[out] none
|
||||||
|
\retval on success USBH_MSC_OK, on failure USBH_MSC_FAIL
|
||||||
|
\notes
|
||||||
|
Refer to USB Mass-Storage Class: BOT (www.usb.org)
|
||||||
|
6.3.1 Valid CSW Conditions :
|
||||||
|
The host shall consider the CSW valid when:
|
||||||
|
1. dCSWSignature is equal to 53425355h
|
||||||
|
2. the CSW is 13 (Dh) bytes in length,
|
||||||
|
3. dCSWTag matches the dCBWTag from the corresponding CBW.
|
||||||
|
*/
|
||||||
|
uint8_t usbh_msc_csw_decode (usb_core_driver *pudev, usbh_host *puhost)
|
||||||
|
{
|
||||||
|
uint8_t status;
|
||||||
|
uint32_t data_xfercount = 0;
|
||||||
|
|
||||||
|
status = USBH_MSC_FAIL;
|
||||||
|
|
||||||
|
if (pudev->host.connect_status) {
|
||||||
|
/* checking if the transfer length is diffrent than 13 */
|
||||||
|
data_xfercount = usbh_xfercount_get (pudev, msc_machine.hc_num_in);
|
||||||
|
|
||||||
|
if (data_xfercount != BBB_CSW_LENGTH) {
|
||||||
|
/* (4) Hi > Dn (Host expects to receive data from the device,
|
||||||
|
Device intends to transfer no data)
|
||||||
|
(5) Hi > Di (Host expects to receive data from the device,
|
||||||
|
Device intends to send data to the host)
|
||||||
|
(9) Ho > Dn (Host expects to send data to the device,
|
||||||
|
Device intends to transfer no data)
|
||||||
|
(11) Ho > Do (Host expects to send data to the device,
|
||||||
|
Device intends to receive data from the host)
|
||||||
|
*/
|
||||||
|
|
||||||
|
status = USBH_MSC_PHASE_ERROR;
|
||||||
|
} else {
|
||||||
|
/* CSW length is correct */
|
||||||
|
|
||||||
|
/* check validity of the CSW Signature and CSWStatus */
|
||||||
|
if (msc_csw_data.field.dCSWSignature == BBB_CSW_SIGNATURE) {
|
||||||
|
/* check condition 1. dCSWSignature is equal to 53425355h */
|
||||||
|
if (msc_csw_data.field.dCSWTag == msc_cbw_data.field.dCBWTag) {
|
||||||
|
/* check condition 3. dCSWTag matches the dCBWTag from the corresponding CBW */
|
||||||
|
if (msc_csw_data.field.bCSWStatus == USBH_MSC_OK) {
|
||||||
|
/* refer to USB Mass-Storage Class : BOT (www.usb.org)
|
||||||
|
Hn Host expects no data transfers
|
||||||
|
Hi Host expects to receive data from the device
|
||||||
|
Ho Host expects to send data to the device
|
||||||
|
|
||||||
|
Dn Device intends to transfer no data
|
||||||
|
Di Device intends to send data to the host
|
||||||
|
Do Device intends to receive data from the host
|
||||||
|
|
||||||
|
Section 6.7
|
||||||
|
(1) Hn = Dn (Host expects no data transfers,
|
||||||
|
Device intends to transfer no data)
|
||||||
|
(6) Hi = Di (Host expects to receive data from the device,
|
||||||
|
Device intends to send data to the host)
|
||||||
|
(12) Ho = Do (Host expects to send data to the device,
|
||||||
|
Device intends to receive data from the host)
|
||||||
|
*/
|
||||||
|
|
||||||
|
status = USBH_MSC_OK;
|
||||||
|
} else if (msc_csw_data.field.bCSWStatus == USBH_MSC_FAIL) {
|
||||||
|
status = USBH_MSC_FAIL;
|
||||||
|
} else if(msc_csw_data.field.bCSWStatus == USBH_MSC_PHASE_ERROR) {
|
||||||
|
/* refer to USB Mass-Storage Class : BOT (www.usb.org)
|
||||||
|
Section 6.7
|
||||||
|
(2) Hn < Di ( Host expects no data transfers,
|
||||||
|
Device intends to send data to the host)
|
||||||
|
(3) Hn < Do ( Host expects no data transfers,
|
||||||
|
Device intends to receive data from the host)
|
||||||
|
(7) Hi < Di ( Host expects to receive data from the device,
|
||||||
|
Device intends to send data to the host)
|
||||||
|
(8) Hi <> Do ( Host expects to receive data from the device,
|
||||||
|
Device intends to receive data from the host)
|
||||||
|
(10) Ho <> Di (Host expects to send data to the device,
|
||||||
|
Di Device intends to send data to the host)
|
||||||
|
(13) Ho < Do (Host expects to send data to the device,
|
||||||
|
Device intends to receive data from the host)
|
||||||
|
*/
|
||||||
|
|
||||||
|
status = USBH_MSC_PHASE_ERROR;
|
||||||
|
}
|
||||||
|
} /* CSW tag matching is checked */
|
||||||
|
} /* CSW signature correct checking */else {
|
||||||
|
/* If the CSW signature is not valid, we sall return the phase error to
|
||||||
|
upper layers for reset recovery */
|
||||||
|
status = USBH_MSC_PHASE_ERROR;
|
||||||
|
}
|
||||||
|
} /* CSW length check */
|
||||||
|
}
|
||||||
|
|
||||||
|
msc_botxfer_param.bot_xfer_status = status;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
@ -0,0 +1,367 @@
|
|||||||
|
/*!
|
||||||
|
\file usbh_msc_core.c
|
||||||
|
\brief USB MSC(mass storage device) class driver
|
||||||
|
|
||||||
|
\version 2019-06-05, V1.0.0, firmware for GD32VF103
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) 2019, GigaDevice Semiconductor Inc.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the copyright holder nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "usbh_pipe.h"
|
||||||
|
#include "usbh_transc.h"
|
||||||
|
#include "usbh_msc_core.h"
|
||||||
|
#include "usbh_msc_scsi.h"
|
||||||
|
#include "usbh_msc_bbb.h"
|
||||||
|
|
||||||
|
#define USBH_MSC_ERROR_RETRY_LIMIT 10
|
||||||
|
|
||||||
|
uint8_t msc_error_count = 0;
|
||||||
|
|
||||||
|
usbh_msc_machine msc_machine;
|
||||||
|
|
||||||
|
static void usbh_msc_itf_deinit (usb_core_driver *pudev, void *puhost);
|
||||||
|
static usbh_status usbh_msc_itf_init (usb_core_driver *pudev, void *puhost);
|
||||||
|
static usbh_status usbh_msc_handle (usb_core_driver *pudev, void *puhost);
|
||||||
|
static usbh_status usbh_msc_req (usb_core_driver *pudev, void *puhost);
|
||||||
|
static usbh_status usbh_msc_maxlun_get (usb_core_driver *pudev, usbh_host *puhost);
|
||||||
|
|
||||||
|
usbh_class_cb usbh_msc_cb =
|
||||||
|
{
|
||||||
|
usbh_msc_itf_init,
|
||||||
|
usbh_msc_itf_deinit,
|
||||||
|
usbh_msc_req,
|
||||||
|
usbh_msc_handle,
|
||||||
|
};
|
||||||
|
|
||||||
|
void usbh_msc_error_handle (uint8_t status);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief interface initialization for MSC class
|
||||||
|
\param[in] pudev: pointer to usb core instance
|
||||||
|
\param[in] puhost: pointer to usb host
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
static usbh_status usbh_msc_itf_init (usb_core_driver *pudev, void *puhost)
|
||||||
|
{
|
||||||
|
usbh_host *pphost = puhost;
|
||||||
|
|
||||||
|
usb_desc_itf *itf_desc = &pphost->dev_prop.itf_desc[0];
|
||||||
|
|
||||||
|
if ((itf_desc->bInterfaceClass == MSC_CLASS) &&
|
||||||
|
(itf_desc->bInterfaceProtocol == MSC_PROTOCOL)) {
|
||||||
|
|
||||||
|
usb_desc_ep *ep_desc = &pphost->dev_prop.ep_desc[0][0];
|
||||||
|
|
||||||
|
if (ep_desc->bEndpointAddress & 0x80) {
|
||||||
|
msc_machine.msc_bulk_epin = ep_desc->bEndpointAddress;
|
||||||
|
msc_machine.msc_bulk_epinsize = ep_desc->wMaxPacketSize;
|
||||||
|
} else {
|
||||||
|
msc_machine.msc_bulk_epout = ep_desc->bEndpointAddress;
|
||||||
|
msc_machine.msc_bulk_epoutsize = ep_desc->wMaxPacketSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
ep_desc = &pphost->dev_prop.ep_desc[0][1];
|
||||||
|
|
||||||
|
if (ep_desc->bEndpointAddress & 0x80) {
|
||||||
|
msc_machine.msc_bulk_epin = ep_desc->bEndpointAddress;
|
||||||
|
msc_machine.msc_bulk_epinsize = ep_desc->wMaxPacketSize;
|
||||||
|
} else {
|
||||||
|
msc_machine.msc_bulk_epout = ep_desc->bEndpointAddress;
|
||||||
|
msc_machine.msc_bulk_epoutsize = ep_desc->wMaxPacketSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
msc_machine.hc_num_out = usbh_pipe_allocate(pudev, msc_machine.msc_bulk_epout);
|
||||||
|
|
||||||
|
msc_machine.hc_num_in = usbh_pipe_allocate(pudev, msc_machine.msc_bulk_epin);
|
||||||
|
|
||||||
|
|
||||||
|
/* open the new channels */
|
||||||
|
usbh_pipe_create (pudev,
|
||||||
|
&pphost->dev_prop,
|
||||||
|
msc_machine.hc_num_out,
|
||||||
|
USB_EPTYPE_BULK,
|
||||||
|
msc_machine.msc_bulk_epoutsize);
|
||||||
|
|
||||||
|
usbh_pipe_create (pudev,
|
||||||
|
&pphost->dev_prop,
|
||||||
|
msc_machine.hc_num_in,
|
||||||
|
USB_EPTYPE_BULK,
|
||||||
|
msc_machine.msc_bulk_epinsize);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
pphost->usr_cb->dev_not_supported();
|
||||||
|
}
|
||||||
|
|
||||||
|
return USBH_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief de-initialize interface by freeing host channels allocated to interface
|
||||||
|
\param[in] pudev: pointer to usb core instance
|
||||||
|
\param[in] puhost: pointer to usb host
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
void usbh_msc_itf_deinit (usb_core_driver *pudev, void *puhost)
|
||||||
|
{
|
||||||
|
if (msc_machine.hc_num_out) {
|
||||||
|
usb_pipe_halt (pudev, msc_machine.hc_num_out);
|
||||||
|
usbh_pipe_free (pudev, msc_machine.hc_num_out);
|
||||||
|
|
||||||
|
msc_machine.hc_num_out = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msc_machine.hc_num_in) {
|
||||||
|
usb_pipe_halt (pudev, msc_machine.hc_num_in);
|
||||||
|
usbh_pipe_free (pudev, msc_machine.hc_num_in);
|
||||||
|
|
||||||
|
msc_machine.hc_num_in = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief initialize the MSC state machine
|
||||||
|
\param[in] pudev: pointer to usb core instance
|
||||||
|
\param[in] puhost: pointer to usb host
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
static usbh_status usbh_msc_req (usb_core_driver *pudev, void *puhost)
|
||||||
|
{
|
||||||
|
usbh_status status = USBH_OK;
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_BOT_INIT_STATE;
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief MSC state machine handler
|
||||||
|
\param[in] pudev: pointer to usb core instance
|
||||||
|
\param[in] puhost: pointer to usb host
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
static usbh_status usbh_msc_handle (usb_core_driver *pudev, void *puhost)
|
||||||
|
{
|
||||||
|
usbh_host *pphost = puhost;
|
||||||
|
usbh_status status = USBH_BUSY;
|
||||||
|
uint8_t msc_status = USBH_MSC_BUSY;
|
||||||
|
uint8_t app_status = 0;
|
||||||
|
|
||||||
|
static uint8_t max_lun_exceed = FALSE;
|
||||||
|
|
||||||
|
if (pudev->host.connect_status) {
|
||||||
|
switch (msc_botxfer_param.msc_state) {
|
||||||
|
case USBH_MSC_BOT_INIT_STATE:
|
||||||
|
usbh_msc_init(pudev);
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_BOT_RESET;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_BOT_RESET:
|
||||||
|
status = USBH_OK;
|
||||||
|
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_GET_MAX_LUN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_GET_MAX_LUN:
|
||||||
|
/* issue Get_MaxLun request */
|
||||||
|
status = usbh_msc_maxlun_get (pudev, puhost);
|
||||||
|
|
||||||
|
if (status == USBH_OK) {
|
||||||
|
msc_machine.max_lun = *(msc_machine.buf);
|
||||||
|
|
||||||
|
/* if device has more that one logical unit then it is not supported */
|
||||||
|
if ((msc_machine.max_lun > 0) && (max_lun_exceed == FALSE)) {
|
||||||
|
max_lun_exceed = TRUE;
|
||||||
|
//pphost->usr_cb->dev_not_supported();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_TEST_UNIT_READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == USBH_NOT_SUPPORTED) {
|
||||||
|
/* if the command has failed, then we need to move to next state, after
|
||||||
|
STALL condition is cleared by Control-Transfer */
|
||||||
|
msc_botxfer_param.msc_state_bkp = USBH_MSC_TEST_UNIT_READY;
|
||||||
|
|
||||||
|
/* a clear feature should be issued here */
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_CTRL_ERROR_STATE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_CTRL_ERROR_STATE:
|
||||||
|
/* issue clearfeature request */
|
||||||
|
status = usbh_clrfeature(pudev,
|
||||||
|
puhost,
|
||||||
|
0x00,
|
||||||
|
pphost->control.pipe_out_num);
|
||||||
|
|
||||||
|
if (status == USBH_OK) {
|
||||||
|
/* if GetMaxLun request not support, assume single LUN configuration */
|
||||||
|
msc_machine.max_lun = 0;
|
||||||
|
|
||||||
|
msc_botxfer_param.msc_state = msc_botxfer_param.msc_state_bkp;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_TEST_UNIT_READY:
|
||||||
|
/* issue SCSI command TestUnitReady */
|
||||||
|
msc_status = usbh_msc_test_unitready(pudev);
|
||||||
|
|
||||||
|
if (msc_status == USBH_MSC_OK) {
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_READ_CAPACITY10;
|
||||||
|
msc_error_count = 0;
|
||||||
|
status = USBH_OK;
|
||||||
|
} else {
|
||||||
|
usbh_msc_error_handle (msc_status);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_READ_CAPACITY10:
|
||||||
|
/* issue READ_CAPACITY10 SCSI command */
|
||||||
|
msc_status = usbh_msc_read_capacity10(pudev);
|
||||||
|
|
||||||
|
if (msc_status == USBH_MSC_OK) {
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_MODE_SENSE6;
|
||||||
|
msc_error_count = 0;
|
||||||
|
status = USBH_OK;
|
||||||
|
} else {
|
||||||
|
usbh_msc_error_handle (msc_status);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_MODE_SENSE6:
|
||||||
|
/* issue ModeSense6 SCSI command for detecting if device is write-protected */
|
||||||
|
msc_status = usbh_msc_mode_sense6 (pudev);
|
||||||
|
|
||||||
|
if (msc_status == USBH_MSC_OK) {
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_DEFAULT_APPLI_STATE;
|
||||||
|
msc_error_count = 0;
|
||||||
|
status = USBH_OK;
|
||||||
|
} else {
|
||||||
|
usbh_msc_error_handle (msc_status);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_REQUEST_SENSE:
|
||||||
|
/* issue RequestSense SCSI command for retreiving error code */
|
||||||
|
msc_status = usbh_msc_request_sense (pudev);
|
||||||
|
if (msc_status == USBH_MSC_OK) {
|
||||||
|
msc_botxfer_param.msc_state = msc_botxfer_param.msc_state_bkp;
|
||||||
|
status = USBH_OK;
|
||||||
|
} else {
|
||||||
|
usbh_msc_error_handle (msc_status);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_BOT_USB_TRANSFERS:
|
||||||
|
/* process the BOT state machine */
|
||||||
|
usbh_msc_botxfer(pudev , puhost);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_DEFAULT_APPLI_STATE:
|
||||||
|
/* process application callback for MSC */
|
||||||
|
app_status = pphost->usr_cb->dev_user_app();
|
||||||
|
|
||||||
|
if (app_status == 0) {
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_DEFAULT_APPLI_STATE;
|
||||||
|
} else if (app_status == 1) {
|
||||||
|
/* de-init requested from application layer */
|
||||||
|
status = USBH_APPLY_DEINIT;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_MSC_UNRECOVERED_STATE:
|
||||||
|
status = USBH_UNRECOVERED_ERROR;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief get max lun of the mass storage device
|
||||||
|
\param[in] pudev: pointer to usb core instance
|
||||||
|
\param[in] puhost: pointer to usb host
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
static usbh_status usbh_msc_maxlun_get (usb_core_driver *pudev, usbh_host *puhost)
|
||||||
|
{
|
||||||
|
usbh_status status = USBH_BUSY;
|
||||||
|
|
||||||
|
if (puhost->control.ctl_state == CTL_IDLE) {
|
||||||
|
puhost->control.setup.req = (usb_req) {
|
||||||
|
.bmRequestType = USB_TRX_IN | USB_REQTYPE_CLASS | USB_RECPTYPE_ITF,
|
||||||
|
.bRequest = BBB_GET_MAX_LUN,
|
||||||
|
.wValue = 0,
|
||||||
|
.wIndex = 0,
|
||||||
|
.wLength = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
usbh_ctlstate_config (puhost, msc_machine.buf, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
status = usbh_ctl_handler (pudev, puhost);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief handling errors occuring during the MSC state machine
|
||||||
|
\param[in] status: error status
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
void usbh_msc_error_handle (uint8_t status)
|
||||||
|
{
|
||||||
|
if (status == USBH_MSC_FAIL) {
|
||||||
|
msc_error_count++;
|
||||||
|
|
||||||
|
if (msc_error_count < USBH_MSC_ERROR_RETRY_LIMIT) {
|
||||||
|
/* try msc level error recovery, issue the request sense to get drive error reason */
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_REQUEST_SENSE;
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
} else {
|
||||||
|
/* error trials exceeded the limit, go to unrecovered state */
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_UNRECOVERED_STATE;
|
||||||
|
}
|
||||||
|
} else if (status == USBH_MSC_PHASE_ERROR) {
|
||||||
|
/* phase error, go to unrecoovered state */
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_UNRECOVERED_STATE;
|
||||||
|
} else if (status == USBH_MSC_BUSY) {
|
||||||
|
/* no change in state */
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,222 @@
|
|||||||
|
/*!
|
||||||
|
\file usbh_msc_fatfs.c
|
||||||
|
\brief USB MSC host FATFS related functions
|
||||||
|
|
||||||
|
\version 2019-06-05, V1.0.0, firmware for GD32VF103
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) 2019, GigaDevice Semiconductor Inc.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the copyright holder nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "usb_conf.h"
|
||||||
|
#include "diskio.h"
|
||||||
|
#include "usbh_msc_core.h"
|
||||||
|
|
||||||
|
static volatile DSTATUS state = STA_NOINIT; /* disk status */
|
||||||
|
|
||||||
|
extern usb_core_driver usbh_msc_core;
|
||||||
|
extern usbh_host usb_host;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief initialize the disk drive
|
||||||
|
\param[in] drv: physical drive number (0)
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
DSTATUS disk_initialize (BYTE drv)
|
||||||
|
{
|
||||||
|
if (usbh_msc_core.host.connect_status) {
|
||||||
|
state &= ~STA_NOINIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief get disk status
|
||||||
|
\param[in] drv: physical drive number (0)
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
DSTATUS disk_status (BYTE drv)
|
||||||
|
{
|
||||||
|
if (drv) {
|
||||||
|
return STA_NOINIT; /* supports only single drive */
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief read sectors
|
||||||
|
\param[in] drv: physical drive number (0)
|
||||||
|
\param[in] buff: pointer to the data buffer to store read data
|
||||||
|
\param[in] sector: start sector number (LBA)
|
||||||
|
\param[in] count: sector count (1..255)
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
DRESULT disk_read (BYTE drv,
|
||||||
|
BYTE *buff,
|
||||||
|
DWORD sector,
|
||||||
|
BYTE count)
|
||||||
|
{
|
||||||
|
BYTE status = USBH_MSC_OK;
|
||||||
|
|
||||||
|
if (drv || !count) {
|
||||||
|
return RES_PARERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state & STA_NOINIT) {
|
||||||
|
return RES_NOTRDY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (usbh_msc_core.host.connect_status) {
|
||||||
|
do {
|
||||||
|
status = usbh_msc_read10 (&usbh_msc_core, buff,sector, 512 * count);
|
||||||
|
usbh_msc_botxfer(&usbh_msc_core, &usb_host);
|
||||||
|
|
||||||
|
if (!usbh_msc_core.host.connect_status) {
|
||||||
|
return RES_ERROR;
|
||||||
|
}
|
||||||
|
} while(status == USBH_MSC_BUSY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == USBH_MSC_OK) {
|
||||||
|
return RES_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RES_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if _READONLY == 0
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief write sectors
|
||||||
|
\param[in] drv: physical drive number (0)
|
||||||
|
\param[in] buff: pointer to the data buffer to store read data
|
||||||
|
\param[in] sector: start sector number (LBA)
|
||||||
|
\param[in] count: sector count (1..255)
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
DRESULT disk_write (BYTE drv,
|
||||||
|
const BYTE *buff,
|
||||||
|
DWORD sector,
|
||||||
|
BYTE count)
|
||||||
|
{
|
||||||
|
BYTE status = USBH_MSC_OK;
|
||||||
|
|
||||||
|
if (drv || !count) {
|
||||||
|
return RES_PARERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state & STA_NOINIT) {
|
||||||
|
return RES_NOTRDY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state & STA_PROTECT) {
|
||||||
|
return RES_WRPRT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (usbh_msc_core.host.connect_status) {
|
||||||
|
do {
|
||||||
|
status = usbh_msc_write10 (&usbh_msc_core, (BYTE*)buff,sector, 512 * count);
|
||||||
|
usbh_msc_botxfer(&usbh_msc_core, &usb_host);
|
||||||
|
|
||||||
|
if (!usbh_msc_core.host.connect_status) {
|
||||||
|
return RES_ERROR;
|
||||||
|
}
|
||||||
|
} while(status == USBH_MSC_BUSY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == USBH_MSC_OK) {
|
||||||
|
return RES_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RES_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _READONLY == 0 */
|
||||||
|
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
/* Miscellaneous Functions */
|
||||||
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if _USE_IOCTL != 0
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief I/O control function
|
||||||
|
\param[in] drv: physical drive number (0)
|
||||||
|
\param[in] ctrl: control code
|
||||||
|
\param[in] buff: pointer to the data buffer to store read data
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
DRESULT disk_ioctl (BYTE drv,
|
||||||
|
BYTE ctrl,
|
||||||
|
void *buff)
|
||||||
|
{
|
||||||
|
DRESULT res = RES_OK;
|
||||||
|
|
||||||
|
if (drv) {
|
||||||
|
return RES_PARERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = RES_ERROR;
|
||||||
|
|
||||||
|
if (state & STA_NOINIT) {
|
||||||
|
return RES_NOTRDY;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (ctrl) {
|
||||||
|
case CTRL_SYNC: /* make sure that no pending write process */
|
||||||
|
res = RES_OK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GET_SECTOR_COUNT: /* get number of sectors on the disk (dword) */
|
||||||
|
*(DWORD*)buff = (DWORD) usbh_msc_param.msc_capacity;
|
||||||
|
res = RES_OK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GET_SECTOR_SIZE: /* get r/w sector size (word) */
|
||||||
|
*(WORD*)buff = 512;
|
||||||
|
res = RES_OK;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GET_BLOCK_SIZE: /* get erase block size in unit of sector (dword) */
|
||||||
|
*(DWORD*)buff = 512;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
res = RES_PARERR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
#endif /* _USE_IOCTL != 0 */
|
@ -0,0 +1,488 @@
|
|||||||
|
/*!
|
||||||
|
\file usbh_msc_scsi.c
|
||||||
|
\brief USB MSC SCSI commands implemention
|
||||||
|
|
||||||
|
\version 2019-06-05, V1.0.0, firmware for GD32VF103
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) 2019, GigaDevice Semiconductor Inc.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the copyright holder nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "usbh_msc_core.h"
|
||||||
|
#include "usbh_msc_scsi.h"
|
||||||
|
#include "usbh_msc_bbb.h"
|
||||||
|
|
||||||
|
usbh_msc_parameter usbh_msc_param;
|
||||||
|
|
||||||
|
uint8_t usbh_databuf_in[512];
|
||||||
|
uint8_t usbh_databuf_out[512];
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief send 'Test unit ready' command to the device
|
||||||
|
\param[in] pudev: pointer to usb device
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
uint8_t usbh_msc_test_unitready (usb_core_driver *pudev)
|
||||||
|
{
|
||||||
|
uint8_t index;
|
||||||
|
usbh_msc_status status = USBH_MSC_BUSY;
|
||||||
|
|
||||||
|
if (pudev->host.connect_status) {
|
||||||
|
switch (msc_botxfer_param.cmd_state_machine) {
|
||||||
|
case CMD_SEND_STATE:
|
||||||
|
/* prepare the CBW and relevent field */
|
||||||
|
msc_cbw_data.field.dCBWDataTransferLength = 0; /* no data transfer */
|
||||||
|
msc_cbw_data.field.bmCBWFlags = USB_TRX_OUT;
|
||||||
|
msc_cbw_data.field.bCBWCBLength = CBW_LENGTH_TEST_UNIT_READY;
|
||||||
|
|
||||||
|
msc_botxfer_param.xfer_buf = msc_csw_data.CSWArray;
|
||||||
|
msc_botxfer_param.data_len = USBH_MSC_CSW_MAX_LENGTH;
|
||||||
|
msc_botxfer_param.msc_state_current = USBH_MSC_TEST_UNIT_READY;
|
||||||
|
|
||||||
|
for (index = CBW_CB_LENGTH; index != 0; index--) {
|
||||||
|
msc_cbw_data.field.CBWCB[index] = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
msc_cbw_data.field.CBWCB[0] = SCSI_TEST_UNIT_READY;
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_SEND_CBW;
|
||||||
|
|
||||||
|
/* start the transfer, then let the state machine magage the other transactions */
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_BOT_USB_TRANSFERS;
|
||||||
|
msc_botxfer_param.bot_xfer_status = USBH_MSC_BUSY;
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_WAIT_STATUS;
|
||||||
|
|
||||||
|
status = USBH_MSC_BUSY;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CMD_WAIT_STATUS:
|
||||||
|
if (msc_botxfer_param.bot_xfer_status == USBH_MSC_OK) {
|
||||||
|
/* commands successfully sent and response received */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_OK;
|
||||||
|
} else if ( msc_botxfer_param.bot_xfer_status == USBH_MSC_FAIL) {
|
||||||
|
/* failure mode */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_FAIL;
|
||||||
|
} else if (msc_botxfer_param.bot_xfer_status == USBH_MSC_PHASE_ERROR) {
|
||||||
|
/* failure mode */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_PHASE_ERROR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief send the read capacity command to the device
|
||||||
|
\param[in] pudev: pointer to usb device
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
uint8_t usbh_msc_read_capacity10 (usb_core_driver *pudev)
|
||||||
|
{
|
||||||
|
uint8_t index;
|
||||||
|
usbh_msc_status status = USBH_MSC_BUSY;
|
||||||
|
|
||||||
|
if (pudev->host.connect_status) {
|
||||||
|
switch (msc_botxfer_param.cmd_state_machine) {
|
||||||
|
case CMD_SEND_STATE:
|
||||||
|
/* prepare the CBW and relevent field */
|
||||||
|
msc_cbw_data.field.dCBWDataTransferLength = READ_CAPACITY10_DATA_LEN;
|
||||||
|
msc_cbw_data.field.bmCBWFlags = USB_TRX_IN;
|
||||||
|
msc_cbw_data.field.bCBWCBLength = CBW_LENGTH;
|
||||||
|
|
||||||
|
msc_botxfer_param.xfer_buf = usbh_databuf_in;
|
||||||
|
msc_botxfer_param.msc_state_current = USBH_MSC_READ_CAPACITY10;
|
||||||
|
|
||||||
|
for (index = CBW_CB_LENGTH; index != 0; index--) {
|
||||||
|
msc_cbw_data.field.CBWCB[index] = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
msc_cbw_data.field.CBWCB[0] = SCSI_READ_CAPACITY10;
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_SEND_CBW;
|
||||||
|
|
||||||
|
/* start the transfer, then let the state machine manage the other transactions */
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_BOT_USB_TRANSFERS;
|
||||||
|
msc_botxfer_param.bot_xfer_status = USBH_MSC_BUSY;
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_WAIT_STATUS;
|
||||||
|
|
||||||
|
status = USBH_MSC_BUSY;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CMD_WAIT_STATUS:
|
||||||
|
if (msc_botxfer_param.bot_xfer_status == USBH_MSC_OK) {
|
||||||
|
/* assign the capacity */
|
||||||
|
(((uint8_t*)&usbh_msc_param.msc_capacity )[3]) = usbh_databuf_in[0];
|
||||||
|
(((uint8_t*)&usbh_msc_param.msc_capacity )[2]) = usbh_databuf_in[1];
|
||||||
|
(((uint8_t*)&usbh_msc_param.msc_capacity )[1]) = usbh_databuf_in[2];
|
||||||
|
(((uint8_t*)&usbh_msc_param.msc_capacity )[0]) = usbh_databuf_in[3];
|
||||||
|
|
||||||
|
/* assign the page length */
|
||||||
|
(((uint8_t*)&usbh_msc_param.msc_page_len )[1]) = usbh_databuf_in[6];
|
||||||
|
(((uint8_t*)&usbh_msc_param.msc_page_len )[0]) = usbh_databuf_in[7];
|
||||||
|
|
||||||
|
/* commands successfully sent and response received */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_OK;
|
||||||
|
} else if (msc_botxfer_param.bot_xfer_status == USBH_MSC_FAIL) {
|
||||||
|
/* failure mode */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_FAIL;
|
||||||
|
} else if (msc_botxfer_param.bot_xfer_status == USBH_MSC_PHASE_ERROR) {
|
||||||
|
/* Failure Mode */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_PHASE_ERROR;
|
||||||
|
} else {
|
||||||
|
/* wait for the commands to get completed */
|
||||||
|
/* no change in state machine */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief send the mode sense6 command to the device
|
||||||
|
\param[in] pudev: pointer to usb device
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
uint8_t usbh_msc_mode_sense6 (usb_core_driver *pudev)
|
||||||
|
{
|
||||||
|
uint8_t index;
|
||||||
|
usbh_msc_status status = USBH_MSC_BUSY;
|
||||||
|
|
||||||
|
if (pudev->host.connect_status) {
|
||||||
|
switch (msc_botxfer_param.cmd_state_machine) {
|
||||||
|
case CMD_SEND_STATE:
|
||||||
|
/* prepare the CBW and relevent field */
|
||||||
|
msc_cbw_data.field.dCBWDataTransferLength = XFER_LEN_MODE_SENSE6;
|
||||||
|
msc_cbw_data.field.bmCBWFlags = USB_TRX_IN;
|
||||||
|
msc_cbw_data.field.bCBWCBLength = CBW_LENGTH;
|
||||||
|
|
||||||
|
msc_botxfer_param.xfer_buf = usbh_databuf_in;
|
||||||
|
msc_botxfer_param.msc_state_current = USBH_MSC_MODE_SENSE6;
|
||||||
|
|
||||||
|
for (index = CBW_CB_LENGTH; index != 0; index--) {
|
||||||
|
msc_cbw_data.field.CBWCB[index] = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
msc_cbw_data.field.CBWCB[0] = SCSI_MODE_SENSE6;
|
||||||
|
msc_cbw_data.field.CBWCB[2] = MODE_SENSE_PAGE_CONTROL_FIELD | MODE_SENSE_PAGE_CODE;
|
||||||
|
msc_cbw_data.field.CBWCB[4] = XFER_LEN_MODE_SENSE6;
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_SEND_CBW;
|
||||||
|
|
||||||
|
/* start the transfer, then let the state machine manage the other transactions */
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_BOT_USB_TRANSFERS;
|
||||||
|
msc_botxfer_param.bot_xfer_status = USBH_MSC_BUSY;
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_WAIT_STATUS;
|
||||||
|
|
||||||
|
status = USBH_MSC_BUSY;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CMD_WAIT_STATUS:
|
||||||
|
if (msc_botxfer_param.bot_xfer_status == USBH_MSC_OK) {
|
||||||
|
/* assign the write protect status */
|
||||||
|
/* if writeprotect = 0, writing is allowed
|
||||||
|
if writeprotect != 0, disk is write protected */
|
||||||
|
if (usbh_databuf_in[2] & MASK_MODE_SENSE_WRITE_PROTECT) {
|
||||||
|
usbh_msc_param.msc_write_protect = DISK_WRITE_PROTECTED;
|
||||||
|
} else {
|
||||||
|
usbh_msc_param.msc_write_protect = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* commands successfully sent and response received */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_OK;
|
||||||
|
} else if (msc_botxfer_param.bot_xfer_status == USBH_MSC_FAIL) {
|
||||||
|
/* failure mode */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_FAIL;
|
||||||
|
} else if (msc_botxfer_param.bot_xfer_status == USBH_MSC_PHASE_ERROR) {
|
||||||
|
/* failure mode */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_PHASE_ERROR;
|
||||||
|
} else {
|
||||||
|
/* wait for the commands to get completed */
|
||||||
|
/* no change in state machine */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief send the Request Sense command to the device
|
||||||
|
\param[in] pudev: pointer to usb device
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
uint8_t usbh_msc_request_sense (usb_core_driver *pudev)
|
||||||
|
{
|
||||||
|
usbh_msc_status status = USBH_MSC_BUSY;
|
||||||
|
uint8_t index;
|
||||||
|
|
||||||
|
if (pudev->host.connect_status) {
|
||||||
|
switch (msc_botxfer_param.cmd_state_machine) {
|
||||||
|
case CMD_SEND_STATE:
|
||||||
|
/* prepare the cbw and relevent field */
|
||||||
|
msc_cbw_data.field.dCBWDataTransferLength = ALLOCATION_LENGTH_REQUEST_SENSE;
|
||||||
|
msc_cbw_data.field.bmCBWFlags = USB_TRX_IN;
|
||||||
|
msc_cbw_data.field.bCBWCBLength = CBW_LENGTH;
|
||||||
|
|
||||||
|
msc_botxfer_param.xfer_buf = usbh_databuf_in;
|
||||||
|
msc_botxfer_param.msc_state_bkp = msc_botxfer_param.msc_state_current;
|
||||||
|
msc_botxfer_param.msc_state_current = USBH_MSC_REQUEST_SENSE;
|
||||||
|
|
||||||
|
for (index = CBW_CB_LENGTH; index != 0; index--) {
|
||||||
|
msc_cbw_data.field.CBWCB[index] = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
msc_cbw_data.field.CBWCB[0] = SCSI_REQUEST_SENSE;
|
||||||
|
msc_cbw_data.field.CBWCB[1] = DESC_REQUEST_SENSE;
|
||||||
|
msc_cbw_data.field.CBWCB[4] = ALLOCATION_LENGTH_REQUEST_SENSE;
|
||||||
|
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_SEND_CBW;
|
||||||
|
|
||||||
|
/* start the transfer, then let the state machine magage the other transactions */
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_BOT_USB_TRANSFERS;
|
||||||
|
msc_botxfer_param.bot_xfer_status = USBH_MSC_BUSY;
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_WAIT_STATUS;
|
||||||
|
|
||||||
|
status = USBH_MSC_BUSY;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CMD_WAIT_STATUS:
|
||||||
|
if (msc_botxfer_param.bot_xfer_status == USBH_MSC_OK) {
|
||||||
|
/* get sense data */
|
||||||
|
(((uint8_t*)&usbh_msc_param.msc_sense_key )[3]) = usbh_databuf_in[0];
|
||||||
|
(((uint8_t*)&usbh_msc_param.msc_sense_key )[2]) = usbh_databuf_in[1];
|
||||||
|
(((uint8_t*)&usbh_msc_param.msc_sense_key )[1]) = usbh_databuf_in[2];
|
||||||
|
(((uint8_t*)&usbh_msc_param.msc_sense_key )[0]) = usbh_databuf_in[3];
|
||||||
|
|
||||||
|
/* commands successfully sent and response received */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_OK;
|
||||||
|
} else if (msc_botxfer_param.bot_xfer_status == USBH_MSC_FAIL) {
|
||||||
|
/* failure mode */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_FAIL;
|
||||||
|
} else if ( msc_botxfer_param.bot_xfer_status == USBH_MSC_PHASE_ERROR ) {
|
||||||
|
/* failure mode */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_PHASE_ERROR;
|
||||||
|
} else {
|
||||||
|
/* wait for the commands to get completed */
|
||||||
|
/* no change in state machine */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief send the write10 command to the device
|
||||||
|
\param[in] pudev: pointer to usb device
|
||||||
|
\param[in] data_buf: data buffer contains the data to write
|
||||||
|
\param[in] addr: address to which the data will be written
|
||||||
|
\param[in] byte_num: number of bytes to be written
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
uint8_t usbh_msc_write10 (usb_core_driver *pudev, uint8_t *data_buf, uint32_t addr, uint32_t byte_num)
|
||||||
|
{
|
||||||
|
uint8_t index;
|
||||||
|
uint16_t nbOfPages;
|
||||||
|
usbh_msc_status status = USBH_MSC_BUSY;
|
||||||
|
|
||||||
|
if (pudev->host.connect_status) {
|
||||||
|
switch (msc_botxfer_param.cmd_state_machine) {
|
||||||
|
case CMD_SEND_STATE:
|
||||||
|
msc_cbw_data.field.dCBWDataTransferLength = byte_num;
|
||||||
|
msc_cbw_data.field.bmCBWFlags = USB_TRX_OUT;
|
||||||
|
msc_cbw_data.field.bCBWCBLength = CBW_LENGTH;
|
||||||
|
msc_botxfer_param.xfer_buf = data_buf;
|
||||||
|
|
||||||
|
for (index = CBW_CB_LENGTH; index != 0; index--) {
|
||||||
|
msc_cbw_data.field.CBWCB[index] = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
msc_cbw_data.field.CBWCB[0] = SCSI_WRITE10;
|
||||||
|
|
||||||
|
/* logical block address */
|
||||||
|
msc_cbw_data.field.CBWCB[2] = (((uint8_t*)&addr)[3]);
|
||||||
|
msc_cbw_data.field.CBWCB[3] = (((uint8_t*)&addr)[2]);
|
||||||
|
msc_cbw_data.field.CBWCB[4] = (((uint8_t*)&addr)[1]);
|
||||||
|
msc_cbw_data.field.CBWCB[5] = (((uint8_t*)&addr)[0]);
|
||||||
|
|
||||||
|
/* USBH_MSC_PAGE_LENGTH = 512*/
|
||||||
|
nbOfPages = byte_num / USBH_MSC_PAGE_LENGTH;
|
||||||
|
|
||||||
|
/* tranfer length */
|
||||||
|
msc_cbw_data.field.CBWCB[7] = (((uint8_t *)&nbOfPages)[1]);
|
||||||
|
msc_cbw_data.field.CBWCB[8] = (((uint8_t *)&nbOfPages)[0]);
|
||||||
|
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_SEND_CBW;
|
||||||
|
|
||||||
|
/* start the transfer, then let the state machine magage the other transactions */
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_BOT_USB_TRANSFERS;
|
||||||
|
msc_botxfer_param.bot_xfer_status = USBH_MSC_BUSY;
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_WAIT_STATUS;
|
||||||
|
|
||||||
|
status = USBH_MSC_BUSY;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CMD_WAIT_STATUS:
|
||||||
|
if (msc_botxfer_param.bot_xfer_status == USBH_MSC_OK) {
|
||||||
|
/* commands successfully sent and response received */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_OK;
|
||||||
|
} else if (msc_botxfer_param.bot_xfer_status == USBH_MSC_FAIL) {
|
||||||
|
/* failure mode */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
} else if (msc_botxfer_param.bot_xfer_status == USBH_MSC_PHASE_ERROR) {
|
||||||
|
/* failure mode */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_PHASE_ERROR;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief send the read10 command to the device
|
||||||
|
\param[in] pudev: pointer to usb device
|
||||||
|
\param[in] data_buf: data buffer contains the data to write
|
||||||
|
\param[in] addr: address to which the data will be written
|
||||||
|
\param[in] byte_num: number of bytes to be written
|
||||||
|
\param[out] none
|
||||||
|
\retval operation status
|
||||||
|
*/
|
||||||
|
uint8_t usbh_msc_read10 (usb_core_driver *pudev, uint8_t *data_buf, uint32_t addr, uint32_t byte_num)
|
||||||
|
{
|
||||||
|
uint8_t index;
|
||||||
|
uint16_t nbOfPages;
|
||||||
|
|
||||||
|
static usbh_msc_status status = USBH_MSC_BUSY;
|
||||||
|
|
||||||
|
status = USBH_MSC_BUSY;
|
||||||
|
|
||||||
|
if (pudev->host.connect_status) {
|
||||||
|
switch (msc_botxfer_param.cmd_state_machine) {
|
||||||
|
case CMD_SEND_STATE:
|
||||||
|
/* prepare the CBW and relevent field */
|
||||||
|
msc_cbw_data.field.dCBWDataTransferLength = byte_num;
|
||||||
|
msc_cbw_data.field.bmCBWFlags = USB_TRX_IN;
|
||||||
|
msc_cbw_data.field.bCBWCBLength = CBW_LENGTH;
|
||||||
|
|
||||||
|
msc_botxfer_param.xfer_buf = data_buf;
|
||||||
|
|
||||||
|
for(index = CBW_CB_LENGTH; index != 0; index--)
|
||||||
|
{
|
||||||
|
msc_cbw_data.field.CBWCB[index] = 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
msc_cbw_data.field.CBWCB[0] = SCSI_READ10;
|
||||||
|
|
||||||
|
/* logical block address */
|
||||||
|
msc_cbw_data.field.CBWCB[2] = (((uint8_t*)&addr)[3]);
|
||||||
|
msc_cbw_data.field.CBWCB[3] = (((uint8_t*)&addr)[2]);
|
||||||
|
msc_cbw_data.field.CBWCB[4] = (((uint8_t*)&addr)[1]);
|
||||||
|
msc_cbw_data.field.CBWCB[5] = (((uint8_t*)&addr)[0]);
|
||||||
|
|
||||||
|
/* USBH_MSC_PAGE_LENGTH = 512 */
|
||||||
|
nbOfPages = byte_num / USBH_MSC_PAGE_LENGTH;
|
||||||
|
|
||||||
|
/* tranfer length */
|
||||||
|
msc_cbw_data.field.CBWCB[7] = (((uint8_t *)&nbOfPages)[1]);
|
||||||
|
msc_cbw_data.field.CBWCB[8] = (((uint8_t *)&nbOfPages)[0]);
|
||||||
|
|
||||||
|
msc_botxfer_param.bot_state = USBH_MSC_SEND_CBW;
|
||||||
|
|
||||||
|
/* start the transfer, then let the state machine magage the other transactions */
|
||||||
|
msc_botxfer_param.msc_state = USBH_MSC_BOT_USB_TRANSFERS;
|
||||||
|
msc_botxfer_param.bot_xfer_status = USBH_MSC_BUSY;
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_WAIT_STATUS;
|
||||||
|
|
||||||
|
status = USBH_MSC_BUSY;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CMD_WAIT_STATUS:
|
||||||
|
if ((msc_botxfer_param.bot_xfer_status == USBH_MSC_OK) && \
|
||||||
|
(pudev->host.connect_status)) {
|
||||||
|
/* commands successfully sent and response received */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_OK;
|
||||||
|
} else if ((msc_botxfer_param.bot_xfer_status == USBH_MSC_FAIL) && \
|
||||||
|
(pudev->host.connect_status)) {
|
||||||
|
/* failure mode */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
} else if (msc_botxfer_param.bot_xfer_status == USBH_MSC_PHASE_ERROR) {
|
||||||
|
/* failure mode */
|
||||||
|
msc_botxfer_param.cmd_state_machine = CMD_SEND_STATE;
|
||||||
|
status = USBH_MSC_PHASE_ERROR;
|
||||||
|
} else {
|
||||||
|
/* wait for the commands to get completed */
|
||||||
|
/* no change in state machine */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
@ -0,0 +1,512 @@
|
|||||||
|
/*!
|
||||||
|
\file usbh_usr.c
|
||||||
|
\brief user application layer for USBFS host-mode MSC class operation
|
||||||
|
|
||||||
|
\version 2019-06-05, V1.0.0, firmware for GD32VF103
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Copyright (c) 2019, GigaDevice Semiconductor Inc.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
3. Neither the name of the copyright holder nor the names of its contributors
|
||||||
|
may be used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "usbh_usr.h"
|
||||||
|
#include "drv_usb_hw.h"
|
||||||
|
#include "ff.h"
|
||||||
|
#include "usbh_msc_core.h"
|
||||||
|
#include "usbh_msc_scsi.h"
|
||||||
|
#include "usbh_msc_bbb.h"
|
||||||
|
|
||||||
|
extern usb_core_driver usbh_msc_core;
|
||||||
|
|
||||||
|
FATFS fatfs;
|
||||||
|
FIL file;
|
||||||
|
|
||||||
|
uint8_t line_idx = 0;
|
||||||
|
uint8_t need_clear = 0;
|
||||||
|
uint8_t usbh_usr_application_state = USBH_USR_FS_INIT;
|
||||||
|
uint8_t WriteTextBuff[] = "GD32 Connectivity line Host Demo application using FAT_FS ";
|
||||||
|
|
||||||
|
/* points to the DEVICE_PROP structure of current device */
|
||||||
|
usbh_user_cb user_callback_funs =
|
||||||
|
{
|
||||||
|
usbh_user_init,
|
||||||
|
usbh_user_deinit,
|
||||||
|
usbh_user_device_connected,
|
||||||
|
usbh_user_device_reset,
|
||||||
|
usbh_user_device_disconnected,
|
||||||
|
usbh_user_over_current_detected,
|
||||||
|
usbh_user_device_speed_detected,
|
||||||
|
usbh_user_device_desc_available,
|
||||||
|
usbh_user_device_address_assigned,
|
||||||
|
usbh_user_configuration_descavailable,
|
||||||
|
usbh_user_manufacturer_string,
|
||||||
|
usbh_user_product_string,
|
||||||
|
usbh_user_serialnum_string,
|
||||||
|
usbh_user_enumeration_finish,
|
||||||
|
usbh_user_userinput,
|
||||||
|
usbh_usr_msc_application,
|
||||||
|
usbh_user_device_not_supported,
|
||||||
|
usbh_user_unrecovered_error
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t MSG_HOST_INIT[] = "> Host Library Initialized.";
|
||||||
|
const uint8_t MSG_DEV_ATTACHED[] = "> Device Attached.";
|
||||||
|
const uint8_t MSG_DEV_DISCONNECTED[] = "> Device Disconnected.";
|
||||||
|
const uint8_t MSG_DEV_ENUMERATED[] = "> Enumeration completed.";
|
||||||
|
const uint8_t MSG_DEV_HIGHSPEED[] = "> High speed device detected.";
|
||||||
|
const uint8_t MSG_DEV_FULLSPEED[] = "> Full speed device detected.";
|
||||||
|
const uint8_t MSG_DEV_LOWSPEED[] = "> Low speed device detected.";
|
||||||
|
const uint8_t MSG_DEV_ERROR[] = "> Device fault.";
|
||||||
|
|
||||||
|
const uint8_t MSG_HOST_HEADER[] = "> USBFS MSC Host";
|
||||||
|
const uint8_t MSG_HOST_FOOTER[] = "> USB Host Library v2.0.0";
|
||||||
|
|
||||||
|
const uint8_t MSG_LIB_START[] = "##### USB Host library started #####";
|
||||||
|
const uint8_t MSG_DEV_NOSUP[] = "> Device not supported.";
|
||||||
|
const uint8_t MSG_OVERCURRENT[] = "> Overcurrent detected.";
|
||||||
|
const uint8_t MSG_RESET_DEV[] = "> Reset the USB device.";
|
||||||
|
|
||||||
|
const uint8_t MSG_MSC_CLASS[] = "> Mass storage device connected.";
|
||||||
|
const uint8_t MSG_HID_CLASS[] = "> HID device connected.";
|
||||||
|
const uint8_t MSG_DISK_SIZE[] = "> Size of the disk in MBytes: ";
|
||||||
|
const uint8_t MSG_LUN[] = "> LUN Available in the device:";
|
||||||
|
const uint8_t MSG_ROOT_CONT[] = "> Exploring disk flash ...";
|
||||||
|
const uint8_t MSG_WR_PROTECT[] = "> The disk is write protected.";
|
||||||
|
const uint8_t MSG_UNREC_ERROR[] = "> UNRECOVERED ERROR STATE.";
|
||||||
|
const uint8_t MSG_FILE_NOTINIT[] = "> Cannot initialize File System.";
|
||||||
|
const uint8_t MSG_FILE_INIT[] = "> File System initialized.";
|
||||||
|
const uint8_t MSG_Write_File[] = "> Writing File to disk flash ...";
|
||||||
|
const uint8_t MSG_Write_Protect[] = "> Disk flash is write protected ";
|
||||||
|
const uint8_t MSG_NOT_WRITE[] = "> GD32.TXT CANNOT be writen.";
|
||||||
|
const uint8_t MSG_CREATE_FILE[] = "> GD32.TXT created in the disk.";
|
||||||
|
|
||||||
|
static uint8_t explore_disk (char* path, uint8_t recu_level);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user operation for host-mode initialization
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_init(void)
|
||||||
|
{
|
||||||
|
static uint8_t startup = 0U;
|
||||||
|
|
||||||
|
if (0U == startup) {
|
||||||
|
startup = 1U;
|
||||||
|
|
||||||
|
//lcd_log_print((uint8_t *)MSG_LIB_START, sizeof(MSG_LIB_START) - 1, LCD_COLOR_WHITE);
|
||||||
|
|
||||||
|
//lcd_log_footer_set((uint8_t *)MSG_HOST_FOOTER, 70);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user operation for device attached
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_device_connected(void)
|
||||||
|
{
|
||||||
|
//lcd_log_print((uint8_t *)MSG_DEV_ATTACHED, sizeof(MSG_DEV_ATTACHED) - 1, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user operation when unrecoveredError happens
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_unrecovered_error (void)
|
||||||
|
{
|
||||||
|
//lcd_log_print((uint8_t *)MSG_UNREC_ERROR, sizeof(MSG_UNREC_ERROR) - 1, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user operation for device disconnect event
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_device_disconnected (void)
|
||||||
|
{
|
||||||
|
//lcd_log_print((uint8_t *)MSG_DEV_DISCONNECTED, sizeof(MSG_DEV_DISCONNECTED) - 1, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user operation for reset USB Device
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_device_reset(void)
|
||||||
|
{
|
||||||
|
//lcd_log_print((uint8_t *)MSG_RESET_DEV, sizeof(MSG_RESET_DEV) - 1, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user operation for detectting device speed
|
||||||
|
\param[in] device_speed: device speed
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_device_speed_detected(uint32_t device_speed)
|
||||||
|
{
|
||||||
|
if (PORT_SPEED_HIGH == device_speed) {
|
||||||
|
//lcd_log_print((uint8_t *)MSG_DEV_HIGHSPEED, sizeof(MSG_DEV_HIGHSPEED) - 1, LCD_COLOR_WHITE);
|
||||||
|
} else if(PORT_SPEED_FULL == device_speed) {
|
||||||
|
//lcd_log_print((uint8_t *)MSG_DEV_FULLSPEED, sizeof(MSG_DEV_FULLSPEED) - 1, LCD_COLOR_WHITE);
|
||||||
|
} else if(PORT_SPEED_LOW == device_speed) {
|
||||||
|
//lcd_log_print((uint8_t *)MSG_DEV_LOWSPEED, sizeof(MSG_DEV_LOWSPEED) - 1, LCD_COLOR_WHITE);
|
||||||
|
} else {
|
||||||
|
//lcd_log_print((uint8_t *)MSG_DEV_ERROR, sizeof(MSG_DEV_ERROR) - 1, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user operation when device descriptor is available
|
||||||
|
\param[in] device_desc: device descriptor
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_device_desc_available(void *device_desc)
|
||||||
|
{
|
||||||
|
uint8_t TempStr[64], str_len = 0;
|
||||||
|
usb_desc_dev *pDevStr = device_desc;
|
||||||
|
|
||||||
|
sprintf((char *)TempStr, "VID: %04Xh", (uint32_t)pDevStr->idVendor);
|
||||||
|
str_len = strlen((const char *)TempStr);
|
||||||
|
//lcd_log_print((uint8_t *)TempStr, str_len, LCD_COLOR_WHITE);
|
||||||
|
|
||||||
|
sprintf((char *)TempStr, "PID: %04Xh", (uint32_t)pDevStr->idProduct);
|
||||||
|
str_len = strlen((const char *)TempStr);
|
||||||
|
//lcd_log_print((uint8_t *)TempStr, str_len, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief usb device is successfully assigned the Address
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_device_address_assigned(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user operation when configuration descriptor is available
|
||||||
|
\param[in] cfg_desc: pointer to configuration descriptor
|
||||||
|
\param[in] itf_desc: pointer to interface descriptor
|
||||||
|
\param[in] ep_desc: pointer to endpoint descriptor
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_configuration_descavailable(usb_desc_config *cfg_desc,
|
||||||
|
usb_desc_itf *itf_desc,
|
||||||
|
usb_desc_ep *ep_desc)
|
||||||
|
{
|
||||||
|
usb_desc_itf *id = itf_desc;
|
||||||
|
|
||||||
|
if (0x08U == (*id).bInterfaceClass) {
|
||||||
|
//lcd_log_print((uint8_t *)MSG_MSC_CLASS, sizeof(MSG_MSC_CLASS) - 1, LCD_COLOR_WHITE);
|
||||||
|
} else if (0x03U == (*id).bInterfaceClass) {
|
||||||
|
//lcd_log_print((uint8_t *)MSG_HID_CLASS, sizeof(MSG_HID_CLASS) - 1, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user operation when manufacturer string exists
|
||||||
|
\param[in] manufacturer_string: manufacturer string of usb device
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_manufacturer_string(void *manufacturer_string)
|
||||||
|
{
|
||||||
|
uint8_t TempStr[64], str_len = 0;
|
||||||
|
|
||||||
|
sprintf((char *)TempStr, "Manufacturer: %s", (char *)manufacturer_string);
|
||||||
|
str_len = strlen((const char *)TempStr);
|
||||||
|
//lcd_log_print((uint8_t *)TempStr, str_len, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user operation when product string exists
|
||||||
|
\param[in] product_string: product string of usb device
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_product_string(void *product_string)
|
||||||
|
{
|
||||||
|
uint8_t TempStr[64], str_len = 0;
|
||||||
|
|
||||||
|
sprintf((char *)TempStr, "Product: %s", (char *)product_string);
|
||||||
|
str_len = strlen((const char *)TempStr);
|
||||||
|
//lcd_log_print((uint8_t *)TempStr, str_len, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user operatin when serialNum string exists
|
||||||
|
\param[in] serial_num_string: serialNum string of usb device
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_serialnum_string(void *serial_num_string)
|
||||||
|
{
|
||||||
|
uint8_t TempStr[64], str_len = 0;
|
||||||
|
|
||||||
|
sprintf((char *)TempStr, "Serial Number: %s", (char *)serial_num_string);
|
||||||
|
str_len = strlen((const char *)TempStr);
|
||||||
|
//lcd_log_print((uint8_t *)TempStr, str_len, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user response request is displayed to ask for application jump to class
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_enumeration_finish(void)
|
||||||
|
{
|
||||||
|
uint8_t Str1[] = "To see the disk information: ";
|
||||||
|
uint8_t Str2[] = "Press CET Key...";
|
||||||
|
|
||||||
|
//lcd_log_print((uint8_t *)MSG_DEV_ENUMERATED, sizeof(MSG_DEV_ENUMERATED) - 1, LCD_COLOR_WHITE);
|
||||||
|
//lcd_log_print((uint8_t *)Str1, sizeof(Str1) - 1, LCD_COLOR_GREEN);
|
||||||
|
//lcd_log_print((uint8_t *)Str2, sizeof(Str2) - 1, LCD_COLOR_GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user operation when device is not supported
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_device_not_supported(void)
|
||||||
|
{
|
||||||
|
//lcd_log_print((uint8_t *)MSG_DEV_NOSUP, sizeof(MSG_DEV_NOSUP) - 1, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user action for application state entry
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval user response for user key
|
||||||
|
*/
|
||||||
|
usbh_user_status usbh_user_userinput(void)
|
||||||
|
{
|
||||||
|
usbh_user_status usbh_usr_status = USBH_USER_NO_RESP;
|
||||||
|
|
||||||
|
return usbh_usr_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief user operation for device overcurrent detection event
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_over_current_detected (void)
|
||||||
|
{
|
||||||
|
//lcd_log_print((uint8_t *)MSG_OVERCURRENT, sizeof(MSG_OVERCURRENT) - 1, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief demo application for mass storage
|
||||||
|
\param[in] pudev: pointer to device
|
||||||
|
\param[in] id: no use here
|
||||||
|
\param[out] none
|
||||||
|
\retval status
|
||||||
|
*/
|
||||||
|
int usbh_usr_msc_application(void)
|
||||||
|
{
|
||||||
|
FRESULT res;
|
||||||
|
uint16_t bytesWritten, bytesToWrite;
|
||||||
|
|
||||||
|
uint8_t Str1[] = "> To see the root content of the disk ";
|
||||||
|
uint8_t Str2[] = "> Press C Key to write file";
|
||||||
|
uint8_t Str3[] = "> The MSC host demo is end.";
|
||||||
|
uint8_t Str4[] = "> Press CET key...";
|
||||||
|
uint8_t TempStr[64], str_len = 0;
|
||||||
|
|
||||||
|
switch(usbh_usr_application_state)
|
||||||
|
{
|
||||||
|
case USBH_USR_FS_INIT:
|
||||||
|
/* initialises the file system*/
|
||||||
|
if (FR_OK != f_mount(0, &fatfs)) {
|
||||||
|
//lcd_log_print((uint8_t *)MSG_FILE_NOTINIT, sizeof(MSG_FILE_NOTINIT) - 1, LCD_COLOR_WHITE);
|
||||||
|
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//lcd_log_print((uint8_t *)MSG_FILE_INIT, sizeof(MSG_FILE_INIT) - 1, LCD_COLOR_WHITE);
|
||||||
|
|
||||||
|
sprintf((char *)TempStr, "> Disk capacity: %ud Bytes.", \
|
||||||
|
usbh_msc_param.msc_capacity * usbh_msc_param.msc_page_len);
|
||||||
|
|
||||||
|
str_len = strlen((const char *)TempStr);
|
||||||
|
|
||||||
|
//lcd_log_print((uint8_t *)TempStr, str_len, LCD_COLOR_WHITE);
|
||||||
|
|
||||||
|
if (DISK_WRITE_PROTECTED == usbh_msc_param.msc_write_protect) {
|
||||||
|
//lcd_log_print((uint8_t *)MSG_WR_PROTECT, sizeof(MSG_WR_PROTECT) - 1, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
usbh_usr_application_state = USBH_USR_FS_READLIST;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_USR_FS_READLIST:
|
||||||
|
//lcd_log_print((uint8_t *)MSG_ROOT_CONT, sizeof(MSG_ROOT_CONT) - 1, LCD_COLOR_WHITE);
|
||||||
|
//lcd_log_print((uint8_t *)Str1, sizeof(Str1) - 1, LCD_COLOR_GREEN);
|
||||||
|
//lcd_log_print((uint8_t *)Str4, sizeof(Str4) - 1, LCD_COLOR_GREEN);
|
||||||
|
|
||||||
|
//explore_disk("0:/", 1);
|
||||||
|
line_idx = 0;
|
||||||
|
usbh_usr_application_state = USBH_USR_FS_WRITEFILE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_USR_FS_WRITEFILE:
|
||||||
|
usb_mdelay(100U);
|
||||||
|
|
||||||
|
//lcd_log_print((uint8_t *)Str2, sizeof(Str2) - 1, LCD_COLOR_GREEN);
|
||||||
|
|
||||||
|
//lcd_log_print((uint8_t *)MSG_Write_File, sizeof(MSG_Write_File) - 1, LCD_COLOR_WHITE);
|
||||||
|
|
||||||
|
if (DISK_WRITE_PROTECTED == usbh_msc_param.msc_write_protect) {
|
||||||
|
//lcd_log_print((uint8_t *)MSG_Write_Protect, sizeof(MSG_Write_Protect) - 1, LCD_COLOR_WHITE);
|
||||||
|
|
||||||
|
usbh_usr_application_state = USBH_USR_FS_DEMOEND;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* register work area for logical drives */
|
||||||
|
f_mount(0, &fatfs);
|
||||||
|
|
||||||
|
if (FR_OK == f_open(&file, "0:GD32.TXT", FA_CREATE_ALWAYS | FA_WRITE)) {
|
||||||
|
/* write buffer to file */
|
||||||
|
bytesToWrite = sizeof(WriteTextBuff);
|
||||||
|
res = f_write (&file, WriteTextBuff, bytesToWrite, (void *)&bytesWritten);
|
||||||
|
/* EOF or error */
|
||||||
|
if ((0U == bytesWritten) || (FR_OK != res)) {
|
||||||
|
//lcd_log_print((uint8_t *)MSG_NOT_WRITE, sizeof(MSG_NOT_WRITE) - 1, LCD_COLOR_WHITE);
|
||||||
|
} else {
|
||||||
|
//lcd_log_print((uint8_t *)MSG_CREATE_FILE, sizeof(MSG_CREATE_FILE) - 1, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* close file and filesystem */
|
||||||
|
f_close(&file);
|
||||||
|
f_mount(0, NULL);
|
||||||
|
} else {
|
||||||
|
//lcd_log_print((uint8_t *)MSG_CREATE_FILE, sizeof(MSG_CREATE_FILE) - 1, LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
usbh_usr_application_state = USBH_USR_FS_DEMOEND;
|
||||||
|
//lcd_log_print((uint8_t *)Str3, sizeof(Str3) - 1, LCD_COLOR_GREEN);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case USBH_USR_FS_DEMOEND:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief displays disk content
|
||||||
|
\param[in] path: pointer to root path
|
||||||
|
\param[in] recu_level: recursive level
|
||||||
|
\param[out] none
|
||||||
|
\retval status
|
||||||
|
*/
|
||||||
|
static uint8_t explore_disk (char* path, uint8_t recu_level)
|
||||||
|
{
|
||||||
|
FRESULT res;
|
||||||
|
FILINFO fno;
|
||||||
|
DIR dir;
|
||||||
|
char *fn;
|
||||||
|
|
||||||
|
uint8_t Str2[] = "Press B Key to continue";
|
||||||
|
|
||||||
|
res = f_opendir(&dir, path);
|
||||||
|
|
||||||
|
if (res == FR_OK) {
|
||||||
|
while (usbh_msc_core.host.connect_status) {
|
||||||
|
res = f_readdir(&dir, &fno);
|
||||||
|
if (FR_OK != res || 0U == fno.fname[0]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('.' == fno.fname[0]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn = fno.fname;
|
||||||
|
|
||||||
|
line_idx++;
|
||||||
|
|
||||||
|
if (line_idx > 4) {
|
||||||
|
line_idx = 0;
|
||||||
|
|
||||||
|
//lcd_log_print((uint8_t *)Str2, sizeof(Str2) - 1, LCD_COLOR_GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (1U == recu_level) {
|
||||||
|
uint8_t temp[] = " |__";
|
||||||
|
//lcd_log_print((uint8_t *)temp, strlen((const char *)temp), LCD_COLOR_WHITE);
|
||||||
|
} else if(2U == recu_level) {
|
||||||
|
uint8_t temp[] = " | |__";
|
||||||
|
//lcd_log_print((uint8_t *)temp, strlen((const char *)temp), LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AM_DIR == (fno.fattrib & AM_MASK)) {
|
||||||
|
//lcd_log_print((uint8_t *)fno.fname, strlen(fno.fname), LCD_COLOR_RED);
|
||||||
|
} else {
|
||||||
|
//lcd_log_print((uint8_t *)fno.fname, strlen(fno.fname), LCD_COLOR_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((AM_DIR == (fno.fattrib & AM_MASK)) && (1U == recu_level)) {
|
||||||
|
explore_disk(fn, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief deinit user state and associated variables
|
||||||
|
\param[in] none
|
||||||
|
\param[out] none
|
||||||
|
\retval none
|
||||||
|
*/
|
||||||
|
void usbh_user_deinit(void)
|
||||||
|
{
|
||||||
|
usbh_usr_application_state = USBH_USR_FS_INIT;
|
||||||
|
}
|
Loading…
Reference in new issue