Use composite USB device (Use 3rd party I-CUBE-USBD-Composite package)

This commit is contained in:
Peter 2024-07-01 03:32:52 +08:00
parent 0942397ab3
commit fe95a21e3a
45 changed files with 15132 additions and 11226 deletions

395
.cproject
View File

@ -1,195 +1,202 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage"> <?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings"> <storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.780529400"> <cconfiguration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.780529400">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.780529400" moduleId="org.eclipse.cdt.core.settings" name="Debug"> <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.780529400" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/> <externalSettings/>
<extensions> <extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> <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.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.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.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.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions> </extensions>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="elf" 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="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.780529400" name="Debug" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug"> <configuration artifactExtension="elf" 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="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.780529400" name="Debug" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug">
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.780529400." name="/" resourcePath=""> <folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.780529400." name="/" resourcePath="">
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.358303033" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug"> <toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.358303033" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.1910372314" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" value="STM32L476RETx" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.1910372314" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32L476RETx" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.1896706073" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" value="0" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.1896706073" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.548209644" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" value="0" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.548209644" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.1815446885" name="Floating-point unit" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.fpv4-sp-d16" valueType="enumerated"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.1815446885" name="Floating-point unit" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.fpv4-sp-d16" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.752105239" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.752105239" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1959901903" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" value="genericBoard" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1959901903" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.2052279018" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32L476RETx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../USB_DEVICE/App | ../USB_DEVICE/Target | ../Drivers/STM32L4xx_HAL_Driver/Inc | ../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy | ../Middlewares/ST/STM32_USB_Device_Library/Core/Inc | ../Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc | ../Drivers/CMSIS/Device/ST/STM32L4xx/Include | ../Drivers/CMSIS/Include | ../FATFS/Target | ../FATFS/App | ../Middlewares/Third_Party/FatFs/src || || || USE_HAL_DRIVER | STM32L476xx || || Drivers | Core/Startup | Middlewares | Core | FATFS | USB_DEVICE || || || ${workspace_loc:/${ProjName}/STM32L476RETX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.2052279018" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32L476RETx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32L4xx_HAL_Driver/Inc | ../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32L4xx/Include | ../Drivers/CMSIS/Include | ../FATFS/Target | ../FATFS/App | ../Middlewares/Third_Party/FatFs/src || || || USE_HAL_DRIVER | STM32L476xx || || Drivers | Composite | Core/Startup | Middlewares | Core | FATFS || || || ${workspace_loc:/${ProjName}/STM32L476RETX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.55981348" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" value="80" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.55981348" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="80" valueType="string"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1415040932" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.1415040932" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
<builder buildPath="${workspace_loc:/MCU}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.413045867" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/> <builder buildPath="${workspace_loc:/MCU}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.413045867" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1453788866" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler"> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1453788866" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.1871397726" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.1871397726" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.655694093" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" valueType="definedSymbols"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.655694093" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/> <listOptionValue builtIn="false" value="DEBUG"/>
</option> </option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.498058946" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/> <inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.498058946" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
</tool> </tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.291953565" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler"> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.291953565" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.1827440396" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g3" valueType="enumerated"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.1827440396" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g3" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.2003882628" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.2003882628" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1598630299" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" valueType="definedSymbols"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1598630299" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/> <listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/> <listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
<listOptionValue builtIn="false" value="STM32L476xx"/> <listOptionValue builtIn="false" value="STM32L476xx"/>
</option> </option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.1219479407" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" valueType="includePath"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.1219479407" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../Core/Inc"/> <listOptionValue builtIn="false" value="../Core/Inc"/>
<listOptionValue builtIn="false" value="../USB_DEVICE/App"/> <listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc"/>
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/> <listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy"/>
<listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc"/> <listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L4xx/Include"/>
<listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy"/> <listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Core/Inc"/> <listOptionValue builtIn="false" value="../FATFS/Target"/>
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc"/> <listOptionValue builtIn="false" value="../FATFS/App"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L4xx/Include"/> <listOptionValue builtIn="false" value="../Middlewares/Third_Party/FatFs/src"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/> <listOptionValue builtIn="false" value="../USB_COMPOSITE"/>
<listOptionValue builtIn="false" value="../FATFS/Target"/> <listOptionValue builtIn="false" value="../USB_COMPOSITE/App"/>
<listOptionValue builtIn="false" value="../FATFS/App"/> <listOptionValue builtIn="false" value="../USB_COMPOSITE/Class/CDC_ACM/Inc"/>
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FatFs/src"/> <listOptionValue builtIn="false" value="../USB_COMPOSITE/Class/COMPOSITE/Inc"/>
</option> <listOptionValue builtIn="false" value="../USB_COMPOSITE/Class/MSC/Inc"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1453770499" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/> <listOptionValue builtIn="false" value="../USB_COMPOSITE/Core/Inc"/>
</tool> <listOptionValue builtIn="false" value="../USB_COMPOSITE/Target"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.1067584154" name="MCU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler"> </option>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.1852410882" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g3" valueType="enumerated"/> <inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1453770499" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.828126021" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level"/> </tool>
</tool> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.1067584154" name="MCU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler">
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.563528096" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker"> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.1852410882" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g3" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.504973548" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32L476RETX_FLASH.ld}" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.828126021" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" useByScannerDiscovery="false"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.534978248" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input"> </tool>
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.563528096" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
<additionalInput kind="additionalinput" paths="$(LIBS)"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.504973548" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32L476RETX_FLASH.ld}" valueType="string"/>
</inputType> <inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.534978248" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
</tool> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.1562858700" name="MCU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.395168956" name="MCU GCC Archiver" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver"/> </inputType>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.1222932293" name="MCU Size" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size"/> </tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.294778862" name="MCU Output Converter list file" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.1562858700" name="MCU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.2045533192" name="MCU Output Converter Hex" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.395168956" name="MCU GCC Archiver" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.327865415" name="MCU Output Converter Binary" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.1222932293" name="MCU Size" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.1001802756" name="MCU Output Converter Verilog" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.294778862" name="MCU Output Converter list file" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.2112480903" name="MCU Output Converter Motorola S-rec" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.2045533192" name="MCU Output Converter Hex" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.2070050458" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.327865415" name="MCU Output Converter Binary" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary"/>
</toolChain> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.1001802756" name="MCU Output Converter Verilog" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog"/>
</folderInfo> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.2112480903" name="MCU Output Converter Motorola S-rec" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec"/>
<sourceEntries> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.2070050458" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/> </toolChain>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="FATFS"/> </folderInfo>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/> <sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="USB_DEVICE"/> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="FATFS"/>
</sourceEntries> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="USB_COMPOSITE"/>
</configuration> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Composite"/>
</storageModule> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
</cconfiguration> </sourceEntries>
<cconfiguration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1468485126"> </configuration>
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1468485126" moduleId="org.eclipse.cdt.core.settings" name="Release"> </storageModule>
<externalSettings/> <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
<extensions> </cconfiguration>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/> <cconfiguration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1468485126">
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1468485126" moduleId="org.eclipse.cdt.core.settings" name="Release">
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> <externalSettings/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> <extensions>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/> <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/> <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions> <extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</storageModule> <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<configuration artifactExtension="elf" 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="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1468485126" name="Release" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release"> <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1468485126." name="/" resourcePath=""> </extensions>
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release.923920106" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release"> </storageModule>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.516820873" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" value="STM32L476RETx" valueType="string"/> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.690096695" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" value="0" valueType="string"/> <configuration artifactExtension="elf" 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="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1468485126" name="Release" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.1099500625" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" value="0" valueType="string"/> <folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1468485126." name="/" resourcePath="">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.1742118853" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.fpv4-sp-d16" valueType="enumerated"/> <toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release.923920106" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.release">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.1369332678" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.516820873" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32L476RETx" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.316464862" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" value="genericBoard" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.690096695" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.620943365" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32L476RETx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../USB_DEVICE/App | ../USB_DEVICE/Target | ../Drivers/STM32L4xx_HAL_Driver/Inc | ../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy | ../Middlewares/ST/STM32_USB_Device_Library/Core/Inc | ../Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc | ../Drivers/CMSIS/Device/ST/STM32L4xx/Include | ../Drivers/CMSIS/Include | ../FATFS/Target | ../FATFS/App | ../Middlewares/Third_Party/FatFs/src || || || USE_HAL_DRIVER | STM32L476xx || || Drivers | Core/Startup | Middlewares | Core | FATFS | USB_DEVICE || || || ${workspace_loc:/${ProjName}/STM32L476RETX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.1099500625" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1317875566" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" value="80" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.1742118853" name="Floating-point unit" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.fpv4-sp-d16" valueType="enumerated"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.170399828" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.1369332678" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
<builder buildPath="${workspace_loc:/MCU}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.878247550" managedBuildOn="true" name="Gnu Make Builder.Release" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.316464862" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1301913342" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler"> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.620943365" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.6 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.value.workspace || STM32L476RETx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Core/Inc | ../Drivers/STM32L4xx_HAL_Driver/Inc | ../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy | ../Drivers/CMSIS/Device/ST/STM32L4xx/Include | ../Drivers/CMSIS/Include | ../FATFS/Target | ../FATFS/App | ../Middlewares/Third_Party/FatFs/src || || || USE_HAL_DRIVER | STM32L476xx || || Drivers | Composite | Core/Startup | Middlewares | Core | FATFS || || || ${workspace_loc:/${ProjName}/STM32L476RETX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || || None || || || " valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.922293208" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g0" valueType="enumerated"/> <option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.1317875566" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock" useByScannerDiscovery="false" value="80" valueType="string"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.1045747537" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.170399828" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
</tool> <builder buildPath="${workspace_loc:/MCU}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.878247550" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1920021909" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler"> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1301913342" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.449677543" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g0" valueType="enumerated"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.922293208" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g0" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.1081105768" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/> <inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.1045747537" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1991680702" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" valueType="definedSymbols"> </tool>
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1920021909" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
<listOptionValue builtIn="false" value="STM32L476xx"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.449677543" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
</option> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.1081105768" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.1096520133" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" valueType="includePath"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1991680702" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="../Core/Inc"/> <listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
<listOptionValue builtIn="false" value="../USB_DEVICE/App"/> <listOptionValue builtIn="false" value="STM32L476xx"/>
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/> </option>
<listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc"/> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.1096520133" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy"/> <listOptionValue builtIn="false" value="../Core/Inc"/>
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Core/Inc"/> <listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc"/>
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc"/> <listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc/Legacy"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L4xx/Include"/> <listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L4xx/Include"/>
<listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/> <listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/>
<listOptionValue builtIn="false" value="../FATFS/Target"/> <listOptionValue builtIn="false" value="../FATFS/Target"/>
<listOptionValue builtIn="false" value="../FATFS/App"/> <listOptionValue builtIn="false" value="../FATFS/App"/>
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FatFs/src"/> <listOptionValue builtIn="false" value="../Middlewares/Third_Party/FatFs/src"/>
</option> <listOptionValue builtIn="false" value="../USB_COMPOSITE/App"/>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.838014454" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/> <listOptionValue builtIn="false" value="../USB_COMPOSITE/Class/CDC_ACM/Inc"/>
</tool> <listOptionValue builtIn="false" value="../USB_COMPOSITE/Class/COMPOSITE/Inc"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.2006522579" name="MCU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler"> <listOptionValue builtIn="false" value="../USB_COMPOSITE/Class/MSC/Inc"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.681565266" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g0" valueType="enumerated"/> <listOptionValue builtIn="false" value="../USB_COMPOSITE/Core/Inc"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.1260340870" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.value.os" valueType="enumerated"/> <listOptionValue builtIn="false" value="../USB_COMPOSITE/Target"/>
</tool> </option>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.838434532" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker"> <inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.838014454" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.69444923" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32L476RETX_FLASH.ld}" valueType="string"/> </tool>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.1211403570" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input"> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.2006522579" name="MCU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.681565266" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.debuglevel.value.g0" valueType="enumerated"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.1260340870" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.value.os" valueType="enumerated"/>
</inputType> </tool>
</tool> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.838434532" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.644315967" name="MCU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.69444923" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32L476RETX_FLASH.ld}" valueType="string"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.1083533225" name="MCU GCC Archiver" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver"/> <inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.1211403570" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.1675353304" name="MCU Size" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size"/> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.1931898235" name="MCU Output Converter list file" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.1309365732" name="MCU Output Converter Hex" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex"/> </inputType>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.66237127" name="MCU Output Converter Binary" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary"/> </tool>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.882532136" name="MCU Output Converter Verilog" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.644315967" name="MCU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.122183037" name="MCU Output Converter Motorola S-rec" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.1083533225" name="MCU GCC Archiver" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.244673265" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.1675353304" name="MCU Size" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size"/>
</toolChain> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.1931898235" name="MCU Output Converter list file" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile"/>
</folderInfo> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.1309365732" name="MCU Output Converter Hex" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex"/>
<sourceEntries> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.66237127" name="MCU Output Converter Binary" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.882532136" name="MCU Output Converter Verilog" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="FATFS"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.122183037" name="MCU Output Converter Motorola S-rec" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.244673265" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/> </toolChain>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="USB_DEVICE"/> </folderInfo>
</sourceEntries> <sourceEntries>
</configuration> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
</storageModule> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="FATFS"/>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
</cconfiguration> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Composite"/>
</storageModule> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
<storageModule moduleId="org.eclipse.cdt.core.pathentry"/> </sourceEntries>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> </configuration>
<project id="MCU.null.720477467" name="MCU"/> </storageModule>
</storageModule> <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> </cconfiguration>
<storageModule moduleId="scannerConfiguration"> </storageModule>
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> <storageModule moduleId="org.eclipse.cdt.core.pathentry"/>
<scannerConfigBuildInfo instanceId="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.780529400;com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.780529400.;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.291953565;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1453770499"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId=""/> <project id="MCU.null.720477467" name="MCU"/>
</scannerConfigBuildInfo> </storageModule>
<scannerConfigBuildInfo instanceId="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1468485126;com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1468485126.;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1920021909;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.838014454"> <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId=""/> <storageModule moduleId="scannerConfiguration">
</scannerConfigBuildInfo> <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</storageModule> <scannerConfigBuildInfo instanceId="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.780529400;com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.780529400.;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.291953565;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1453770499">
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
<scannerConfigBuildInfo instanceId="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1468485126;com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1468485126.;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1920021909;com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.838014454">
<autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId=""/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject> </cproject>

2
.gitattributes vendored
View File

@ -1 +1 @@
* text=auto * text=false

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.780529400" name="Debug">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/>
<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="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="917054219300747715" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" 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="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.1468485126" name="Release">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider-reference id="org.eclipse.cdt.ui.UserLanguageSettingsProvider" ref="shared-provider"/>
<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="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="917054219300747715" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
</extension>
</configuration>
</project>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,259 +1,259 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN Header */
/** /**
****************************************************************************** ******************************************************************************
* @file stm32l4xx_it.c * @file stm32l4xx_it.c
* @brief Interrupt Service Routines. * @brief Interrupt Service Routines.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2024 STMicroelectronics. * Copyright (c) 2024 STMicroelectronics.
* All rights reserved. * All rights reserved.
* *
* This software is licensed under terms that can be found in the LICENSE file * This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component. * in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS. * If no LICENSE file comes with this software, it is provided AS-IS.
* *
****************************************************************************** ******************************************************************************
*/ */
/* USER CODE END Header */ /* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "main.h" #include "main.h"
#include "stm32l4xx_it.h" #include "stm32l4xx_it.h"
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
/* USER CODE END Includes */ /* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN TD */ /* USER CODE BEGIN TD */
/* USER CODE END TD */ /* USER CODE END TD */
/* Private define ------------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */ /* USER CODE BEGIN PD */
/* USER CODE END PD */ /* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */ /* USER CODE BEGIN PM */
/* USER CODE END PM */ /* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */ /* USER CODE BEGIN PV */
/* USER CODE END PV */ /* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */ /* USER CODE BEGIN PFP */
/* USER CODE END PFP */ /* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/ /* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */ /* USER CODE BEGIN 0 */
/* USER CODE END 0 */ /* USER CODE END 0 */
/* External variables --------------------------------------------------------*/ /* External variables --------------------------------------------------------*/
extern PCD_HandleTypeDef hpcd_USB_OTG_FS; extern DMA_HandleTypeDef hdma_sdmmc1;
extern DMA_HandleTypeDef hdma_sdmmc1; extern MMC_HandleTypeDef hmmc1;
extern MMC_HandleTypeDef hmmc1; extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
extern TIM_HandleTypeDef htim15; extern TIM_HandleTypeDef htim15;
/* USER CODE BEGIN EV */ /* USER CODE BEGIN EV */
/* USER CODE END EV */ /* USER CODE END EV */
/******************************************************************************/ /******************************************************************************/
/* Cortex-M4 Processor Interruption and Exception Handlers */ /* Cortex-M4 Processor Interruption and Exception Handlers */
/******************************************************************************/ /******************************************************************************/
/** /**
* @brief This function handles Non maskable interrupt. * @brief This function handles Non maskable interrupt.
*/ */
void NMI_Handler(void) void NMI_Handler(void)
{ {
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */ /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
/* USER CODE END NonMaskableInt_IRQn 0 */ /* USER CODE END NonMaskableInt_IRQn 0 */
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */ /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
while (1) while (1)
{ {
} }
/* USER CODE END NonMaskableInt_IRQn 1 */ /* USER CODE END NonMaskableInt_IRQn 1 */
} }
/** /**
* @brief This function handles Hard fault interrupt. * @brief This function handles Hard fault interrupt.
*/ */
void HardFault_Handler(void) void HardFault_Handler(void)
{ {
/* USER CODE BEGIN HardFault_IRQn 0 */ /* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */ /* USER CODE END HardFault_IRQn 0 */
while (1) while (1)
{ {
/* USER CODE BEGIN W1_HardFault_IRQn 0 */ /* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */ /* USER CODE END W1_HardFault_IRQn 0 */
} }
} }
/** /**
* @brief This function handles Memory management fault. * @brief This function handles Memory management fault.
*/ */
void MemManage_Handler(void) void MemManage_Handler(void)
{ {
/* USER CODE BEGIN MemoryManagement_IRQn 0 */ /* USER CODE BEGIN MemoryManagement_IRQn 0 */
/* USER CODE END MemoryManagement_IRQn 0 */ /* USER CODE END MemoryManagement_IRQn 0 */
while (1) while (1)
{ {
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
/* USER CODE END W1_MemoryManagement_IRQn 0 */ /* USER CODE END W1_MemoryManagement_IRQn 0 */
} }
} }
/** /**
* @brief This function handles Prefetch fault, memory access fault. * @brief This function handles Prefetch fault, memory access fault.
*/ */
void BusFault_Handler(void) void BusFault_Handler(void)
{ {
/* USER CODE BEGIN BusFault_IRQn 0 */ /* USER CODE BEGIN BusFault_IRQn 0 */
/* USER CODE END BusFault_IRQn 0 */ /* USER CODE END BusFault_IRQn 0 */
while (1) while (1)
{ {
/* USER CODE BEGIN W1_BusFault_IRQn 0 */ /* USER CODE BEGIN W1_BusFault_IRQn 0 */
/* USER CODE END W1_BusFault_IRQn 0 */ /* USER CODE END W1_BusFault_IRQn 0 */
} }
} }
/** /**
* @brief This function handles Undefined instruction or illegal state. * @brief This function handles Undefined instruction or illegal state.
*/ */
void UsageFault_Handler(void) void UsageFault_Handler(void)
{ {
/* USER CODE BEGIN UsageFault_IRQn 0 */ /* USER CODE BEGIN UsageFault_IRQn 0 */
/* USER CODE END UsageFault_IRQn 0 */ /* USER CODE END UsageFault_IRQn 0 */
while (1) while (1)
{ {
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */ /* USER CODE BEGIN W1_UsageFault_IRQn 0 */
/* USER CODE END W1_UsageFault_IRQn 0 */ /* USER CODE END W1_UsageFault_IRQn 0 */
} }
} }
/** /**
* @brief This function handles System service call via SWI instruction. * @brief This function handles System service call via SWI instruction.
*/ */
void SVC_Handler(void) void SVC_Handler(void)
{ {
/* USER CODE BEGIN SVCall_IRQn 0 */ /* USER CODE BEGIN SVCall_IRQn 0 */
/* USER CODE END SVCall_IRQn 0 */ /* USER CODE END SVCall_IRQn 0 */
/* USER CODE BEGIN SVCall_IRQn 1 */ /* USER CODE BEGIN SVCall_IRQn 1 */
/* USER CODE END SVCall_IRQn 1 */ /* USER CODE END SVCall_IRQn 1 */
} }
/** /**
* @brief This function handles Debug monitor. * @brief This function handles Debug monitor.
*/ */
void DebugMon_Handler(void) void DebugMon_Handler(void)
{ {
/* USER CODE BEGIN DebugMonitor_IRQn 0 */ /* USER CODE BEGIN DebugMonitor_IRQn 0 */
/* USER CODE END DebugMonitor_IRQn 0 */ /* USER CODE END DebugMonitor_IRQn 0 */
/* USER CODE BEGIN DebugMonitor_IRQn 1 */ /* USER CODE BEGIN DebugMonitor_IRQn 1 */
/* USER CODE END DebugMonitor_IRQn 1 */ /* USER CODE END DebugMonitor_IRQn 1 */
} }
/** /**
* @brief This function handles Pendable request for system service. * @brief This function handles Pendable request for system service.
*/ */
void PendSV_Handler(void) void PendSV_Handler(void)
{ {
/* USER CODE BEGIN PendSV_IRQn 0 */ /* USER CODE BEGIN PendSV_IRQn 0 */
/* USER CODE END PendSV_IRQn 0 */ /* USER CODE END PendSV_IRQn 0 */
/* USER CODE BEGIN PendSV_IRQn 1 */ /* USER CODE BEGIN PendSV_IRQn 1 */
/* USER CODE END PendSV_IRQn 1 */ /* USER CODE END PendSV_IRQn 1 */
} }
/** /**
* @brief This function handles System tick timer. * @brief This function handles System tick timer.
*/ */
void SysTick_Handler(void) void SysTick_Handler(void)
{ {
/* USER CODE BEGIN SysTick_IRQn 0 */ /* USER CODE BEGIN SysTick_IRQn 0 */
/* USER CODE END SysTick_IRQn 0 */ /* USER CODE END SysTick_IRQn 0 */
/* USER CODE BEGIN SysTick_IRQn 1 */ /* USER CODE BEGIN SysTick_IRQn 1 */
/* USER CODE END SysTick_IRQn 1 */ /* USER CODE END SysTick_IRQn 1 */
} }
/******************************************************************************/ /******************************************************************************/
/* STM32L4xx Peripheral Interrupt Handlers */ /* STM32L4xx Peripheral Interrupt Handlers */
/* Add here the Interrupt Handlers for the used peripherals. */ /* Add here the Interrupt Handlers for the used peripherals. */
/* For the available peripheral interrupt handler names, */ /* For the available peripheral interrupt handler names, */
/* please refer to the startup file (startup_stm32l4xx.s). */ /* please refer to the startup file (startup_stm32l4xx.s). */
/******************************************************************************/ /******************************************************************************/
/** /**
* @brief This function handles TIM1 break interrupt and TIM15 global interrupt. * @brief This function handles TIM1 break interrupt and TIM15 global interrupt.
*/ */
void TIM1_BRK_TIM15_IRQHandler(void) void TIM1_BRK_TIM15_IRQHandler(void)
{ {
/* USER CODE BEGIN TIM1_BRK_TIM15_IRQn 0 */ /* USER CODE BEGIN TIM1_BRK_TIM15_IRQn 0 */
/* USER CODE END TIM1_BRK_TIM15_IRQn 0 */ /* USER CODE END TIM1_BRK_TIM15_IRQn 0 */
HAL_TIM_IRQHandler(&htim15); HAL_TIM_IRQHandler(&htim15);
/* USER CODE BEGIN TIM1_BRK_TIM15_IRQn 1 */ /* USER CODE BEGIN TIM1_BRK_TIM15_IRQn 1 */
/* USER CODE END TIM1_BRK_TIM15_IRQn 1 */ /* USER CODE END TIM1_BRK_TIM15_IRQn 1 */
} }
/** /**
* @brief This function handles SDMMC1 global interrupt. * @brief This function handles SDMMC1 global interrupt.
*/ */
void SDMMC1_IRQHandler(void) void SDMMC1_IRQHandler(void)
{ {
/* USER CODE BEGIN SDMMC1_IRQn 0 */ /* USER CODE BEGIN SDMMC1_IRQn 0 */
/* USER CODE END SDMMC1_IRQn 0 */ /* USER CODE END SDMMC1_IRQn 0 */
HAL_MMC_IRQHandler(&hmmc1); HAL_MMC_IRQHandler(&hmmc1);
/* USER CODE BEGIN SDMMC1_IRQn 1 */ /* USER CODE BEGIN SDMMC1_IRQn 1 */
/* USER CODE END SDMMC1_IRQn 1 */ /* USER CODE END SDMMC1_IRQn 1 */
} }
/** /**
* @brief This function handles DMA2 channel4 global interrupt. * @brief This function handles DMA2 channel4 global interrupt.
*/ */
void DMA2_Channel4_IRQHandler(void) void DMA2_Channel4_IRQHandler(void)
{ {
/* USER CODE BEGIN DMA2_Channel4_IRQn 0 */ /* USER CODE BEGIN DMA2_Channel4_IRQn 0 */
/* USER CODE END DMA2_Channel4_IRQn 0 */ /* USER CODE END DMA2_Channel4_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_sdmmc1); HAL_DMA_IRQHandler(&hdma_sdmmc1);
/* USER CODE BEGIN DMA2_Channel4_IRQn 1 */ /* USER CODE BEGIN DMA2_Channel4_IRQn 1 */
/* USER CODE END DMA2_Channel4_IRQn 1 */ /* USER CODE END DMA2_Channel4_IRQn 1 */
} }
/** /**
* @brief This function handles USB OTG FS global interrupt. * @brief This function handles USB OTG FS global interrupt.
*/ */
void OTG_FS_IRQHandler(void) void OTG_FS_IRQHandler(void)
{ {
/* USER CODE BEGIN OTG_FS_IRQn 0 */ /* USER CODE BEGIN OTG_FS_IRQn 0 */
/* USER CODE END OTG_FS_IRQn 0 */ /* USER CODE END OTG_FS_IRQn 0 */
HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS); HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS);
/* USER CODE BEGIN OTG_FS_IRQn 1 */ /* USER CODE BEGIN OTG_FS_IRQn 1 */
/* USER CODE END OTG_FS_IRQn 1 */ /* USER CODE END OTG_FS_IRQn 1 */
} }
/* USER CODE BEGIN 1 */ /* USER CODE BEGIN 1 */
/* USER CODE END 1 */ /* USER CODE END 1 */

765
MCU.ioc
View File

@ -1,383 +1,382 @@
#MicroXplorer Configuration settings - do not modify #MicroXplorer Configuration settings - do not modify
CAD.formats= AL94.I-CUBE-USBD-COMPOSITE.1.0.3.IPParameters=_USBD_USE_CDC_ACM,_USBD_USE_MSC,_STM32F1_DEVICE,_USBD_CDC_ACM_COUNT
CAD.pinconfig= AL94.I-CUBE-USBD-COMPOSITE.1.0.3.USBJjComposite_Checked=false
CAD.provider= AL94.I-CUBE-USBD-COMPOSITE.1.0.3._STM32F1_DEVICE=false
CAN1.BS1=CAN_BS1_3TQ AL94.I-CUBE-USBD-COMPOSITE.1.0.3._USBD_CDC_ACM_COUNT=1
CAN1.BS2=CAN_BS2_1TQ AL94.I-CUBE-USBD-COMPOSITE.1.0.3._USBD_USE_CDC_ACM=true
CAN1.CalculateBaudRate=1000000 AL94.I-CUBE-USBD-COMPOSITE.1.0.3._USBD_USE_MSC=true
CAN1.CalculateTimeBit=1000 AL94.I-CUBE-USBD-COMPOSITE.1.0.3_SwParameter=CompositeCcUSBJjCOMPOSITEJjCore\:true;CompositeCcUSBJjCOMPOSITEJjMSCIiBOT\:true;CompositeCcUSBJjCOMPOSITEJjCOMPOSITE\:true;CompositeCcUSBJjCOMPOSITEJjCDCIiACM\:true;
CAN1.CalculateTimeQuantum=200.0 CAD.formats=
CAN1.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,BS1,BS2 CAD.pinconfig=
Dma.Request0=SDMMC1 CAD.provider=
Dma.RequestsNb=1 CAN1.BS1=CAN_BS1_3TQ
Dma.SDMMC1.0.Direction=DMA_MEMORY_TO_PERIPH CAN1.BS2=CAN_BS2_1TQ
Dma.SDMMC1.0.Instance=DMA2_Channel4 CAN1.CalculateBaudRate=1000000
Dma.SDMMC1.0.MemDataAlignment=DMA_MDATAALIGN_WORD CAN1.CalculateTimeBit=1000
Dma.SDMMC1.0.MemInc=DMA_MINC_ENABLE CAN1.CalculateTimeQuantum=200.0
Dma.SDMMC1.0.Mode=DMA_NORMAL CAN1.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,BS1,BS2
Dma.SDMMC1.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD Dma.Request0=SDMMC1
Dma.SDMMC1.0.PeriphInc=DMA_PINC_DISABLE Dma.RequestsNb=1
Dma.SDMMC1.0.Priority=DMA_PRIORITY_LOW Dma.SDMMC1.0.Direction=DMA_MEMORY_TO_PERIPH
Dma.SDMMC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority Dma.SDMMC1.0.Instance=DMA2_Channel4
FATFS.IPParameters=_USE_STRFUNC,_MAX_SS,_MAX_LFN,_USE_LFN Dma.SDMMC1.0.MemDataAlignment=DMA_MDATAALIGN_WORD
FATFS._MAX_LFN=255 Dma.SDMMC1.0.MemInc=DMA_MINC_ENABLE
FATFS._MAX_SS=4096 Dma.SDMMC1.0.Mode=DMA_NORMAL
FATFS._USE_LFN=2 Dma.SDMMC1.0.PeriphDataAlignment=DMA_PDATAALIGN_WORD
FATFS._USE_STRFUNC=1 Dma.SDMMC1.0.PeriphInc=DMA_PINC_DISABLE
File.Version=6 Dma.SDMMC1.0.Priority=DMA_PRIORITY_LOW
GPIO.groupedBy=Group By Peripherals Dma.SDMMC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
I2C3.IPParameters=Timing FATFS.IPParameters=_USE_STRFUNC,_MAX_SS,_MAX_LFN,_USE_LFN
I2C3.Timing=0x10909CEC FATFS._MAX_LFN=255
KeepUserPlacement=false FATFS._MAX_SS=4096
LPUART1.IPParameters=OneBitSampling FATFS._USE_LFN=2
LPUART1.OneBitSampling=UART_ONE_BIT_SAMPLE_DISABLE FATFS._USE_STRFUNC=1
Mcu.CPN=STM32L476RET6 File.Version=6
Mcu.Family=STM32L4 GPIO.groupedBy=Group By Peripherals
Mcu.IP0=CAN1 I2C3.IPParameters=Timing
Mcu.IP1=CRC I2C3.Timing=0x10909CEC
Mcu.IP10=SPI3 KeepUserPlacement=false
Mcu.IP11=SYS LPUART1.IPParameters=OneBitSampling
Mcu.IP12=UART4 LPUART1.OneBitSampling=UART_ONE_BIT_SAMPLE_DISABLE
Mcu.IP13=USART1 Mcu.CPN=STM32L476RET6
Mcu.IP14=USART2 Mcu.Family=STM32L4
Mcu.IP15=USART3 Mcu.IP0=CAN1
Mcu.IP16=USB_DEVICE Mcu.IP1=CRC
Mcu.IP17=USB_OTG_FS Mcu.IP10=SPI3
Mcu.IP2=DMA Mcu.IP11=SYS
Mcu.IP3=FATFS Mcu.IP12=UART4
Mcu.IP4=I2C3 Mcu.IP13=USART1
Mcu.IP5=LPUART1 Mcu.IP14=USART2
Mcu.IP6=NVIC Mcu.IP15=USART3
Mcu.IP7=RCC Mcu.IP16=USB_OTG_FS
Mcu.IP8=SDMMC1 Mcu.IP2=DMA
Mcu.IP9=SPI2 Mcu.IP3=FATFS
Mcu.IPNb=18 Mcu.IP4=I2C3
Mcu.Name=STM32L476R(C-E-G)Tx Mcu.IP5=LPUART1
Mcu.Package=LQFP64 Mcu.IP6=NVIC
Mcu.Pin0=PC13 Mcu.IP7=RCC
Mcu.Pin1=PC14-OSC32_IN (PC14) Mcu.IP8=SDMMC1
Mcu.Pin10=PA1 Mcu.IP9=SPI2
Mcu.Pin11=PA2 Mcu.IPNb=17
Mcu.Pin12=PA3 Mcu.Name=STM32L476R(C-E-G)Tx
Mcu.Pin13=PA4 Mcu.Package=LQFP64
Mcu.Pin14=PA5 Mcu.Pin0=PC13
Mcu.Pin15=PA6 Mcu.Pin1=PC14-OSC32_IN (PC14)
Mcu.Pin16=PA7 Mcu.Pin10=PA1
Mcu.Pin17=PC4 Mcu.Pin11=PA2
Mcu.Pin18=PC5 Mcu.Pin12=PA3
Mcu.Pin19=PB0 Mcu.Pin13=PA4
Mcu.Pin2=PC15-OSC32_OUT (PC15) Mcu.Pin14=PA5
Mcu.Pin20=PB2 Mcu.Pin15=PA6
Mcu.Pin21=PB10 Mcu.Pin16=PA7
Mcu.Pin22=PB11 Mcu.Pin17=PC4
Mcu.Pin23=PB12 Mcu.Pin18=PC5
Mcu.Pin24=PB13 Mcu.Pin19=PB0
Mcu.Pin25=PB14 Mcu.Pin2=PC15-OSC32_OUT (PC15)
Mcu.Pin26=PB15 Mcu.Pin20=PB2
Mcu.Pin27=PC6 Mcu.Pin21=PB10
Mcu.Pin28=PC8 Mcu.Pin22=PB11
Mcu.Pin29=PC9 Mcu.Pin23=PB12
Mcu.Pin3=PH0-OSC_IN (PH0) Mcu.Pin24=PB13
Mcu.Pin30=PA8 Mcu.Pin25=PB14
Mcu.Pin31=PA9 Mcu.Pin26=PB15
Mcu.Pin32=PA10 Mcu.Pin27=PC6
Mcu.Pin33=PA11 Mcu.Pin28=PC8
Mcu.Pin34=PA12 Mcu.Pin29=PC9
Mcu.Pin35=PA13 (JTMS-SWDIO) Mcu.Pin3=PH0-OSC_IN (PH0)
Mcu.Pin36=PA14 (JTCK-SWCLK) Mcu.Pin30=PA8
Mcu.Pin37=PA15 (JTDI) Mcu.Pin31=PA9
Mcu.Pin38=PC10 Mcu.Pin32=PA10
Mcu.Pin39=PC11 Mcu.Pin33=PA11
Mcu.Pin4=PH1-OSC_OUT (PH1) Mcu.Pin34=PA12
Mcu.Pin40=PC12 Mcu.Pin35=PA13 (JTMS-SWDIO)
Mcu.Pin41=PD2 Mcu.Pin36=PA14 (JTCK-SWCLK)
Mcu.Pin42=PB3 (JTDO-TRACESWO) Mcu.Pin37=PA15 (JTDI)
Mcu.Pin43=PB4 (NJTRST) Mcu.Pin38=PC10
Mcu.Pin44=PB5 Mcu.Pin39=PC11
Mcu.Pin45=PB6 Mcu.Pin4=PH1-OSC_OUT (PH1)
Mcu.Pin46=PB7 Mcu.Pin40=PC12
Mcu.Pin47=PB8 Mcu.Pin41=PD2
Mcu.Pin48=PB9 Mcu.Pin42=PB3 (JTDO-TRACESWO)
Mcu.Pin49=VP_CRC_VS_CRC Mcu.Pin43=PB4 (NJTRST)
Mcu.Pin5=PC0 Mcu.Pin44=PB5
Mcu.Pin50=VP_FATFS_VS_Generic Mcu.Pin45=PB6
Mcu.Pin51=VP_SYS_V_PVD_IN Mcu.Pin46=PB7
Mcu.Pin52=VP_SYS_VS_tim15 Mcu.Pin47=PB8
Mcu.Pin53=VP_USB_DEVICE_VS_USB_DEVICE_MSC_FS Mcu.Pin48=PB9
Mcu.Pin6=PC1 Mcu.Pin49=VP_CRC_VS_CRC
Mcu.Pin7=PC2 Mcu.Pin5=PC0
Mcu.Pin8=PC3 Mcu.Pin50=VP_FATFS_VS_Generic
Mcu.Pin9=PA0 Mcu.Pin51=VP_SYS_V_PVD_IN
Mcu.PinsNb=54 Mcu.Pin52=VP_SYS_VS_tim15
Mcu.ThirdPartyNb=0 Mcu.Pin6=PC1
Mcu.UserConstants= Mcu.Pin7=PC2
Mcu.UserName=STM32L476RETx Mcu.Pin8=PC3
MxCube.Version=6.11.1 Mcu.Pin9=PA0
MxDb.Version=DB.6.0.111 Mcu.PinsNb=53
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false Mcu.ThirdParty0=AL94.I-CUBE-USBD-COMPOSITE.1.0.3
NVIC.DMA2_Channel4_IRQn=true\:0\:0\:true\:false\:true\:false\:true\:true Mcu.ThirdPartyNb=1
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false Mcu.UserConstants=
NVIC.ForceEnableDMAVector=true Mcu.UserName=STM32L476RETx
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false MxCube.Version=6.11.1
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false MxDb.Version=DB.6.0.111
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.OTG_FS_IRQn=true\:2\:0\:true\:false\:true\:false\:true\:true NVIC.DMA2_Channel4_IRQn=true\:0\:0\:true\:false\:true\:false\:true\:true
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.ForceEnableDMAVector=true
NVIC.SDMMC1_IRQn=true\:1\:0\:true\:false\:true\:true\:true\:true NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.TIM1_BRK_TIM15_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:true NVIC.OTG_FS_IRQn=true\:2\:0\:true\:false\:true\:true\:true\:true
NVIC.TimeBase=TIM1_BRK_TIM15_IRQn NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.TimeBaseIP=TIM15 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.SDMMC1_IRQn=true\:1\:0\:true\:false\:true\:true\:true\:true
PA0.Mode=Asynchronous NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
PA0.Signal=UART4_TX NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
PA1.Mode=Asynchronous NVIC.TIM1_BRK_TIM15_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:true
PA1.Signal=UART4_RX NVIC.TimeBase=TIM1_BRK_TIM15_IRQn
PA10.Mode=Asynchronous NVIC.TimeBaseIP=TIM15
PA10.Signal=USART1_RX NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
PA11.Mode=Device_Only PA0.Mode=Asynchronous
PA11.Signal=USB_OTG_FS_DM PA0.Signal=UART4_TX
PA12.Mode=Device_Only PA1.Mode=Asynchronous
PA12.Signal=USB_OTG_FS_DP PA1.Signal=UART4_RX
PA13\ (JTMS-SWDIO).Mode=Serial_Wire PA10.Mode=Asynchronous
PA13\ (JTMS-SWDIO).Signal=SYS_JTMS-SWDIO PA10.Signal=USART1_RX
PA14\ (JTCK-SWCLK).Mode=Serial_Wire PA11.Mode=Device_Only
PA14\ (JTCK-SWCLK).Signal=SYS_JTCK-SWCLK PA11.Signal=USB_OTG_FS_DM
PA15\ (JTDI).Locked=true PA12.Mode=Device_Only
PA15\ (JTDI).Signal=GPIO_Output PA12.Signal=USB_OTG_FS_DP
PA2.Mode=Asynchronous PA13\ (JTMS-SWDIO).Mode=Serial_Wire
PA2.Signal=USART2_TX PA13\ (JTMS-SWDIO).Signal=SYS_JTMS-SWDIO
PA3.Mode=Asynchronous PA14\ (JTCK-SWCLK).Mode=Serial_Wire
PA3.Signal=USART2_RX PA14\ (JTCK-SWCLK).Signal=SYS_JTCK-SWCLK
PA4.Locked=true PA15\ (JTDI).Locked=true
PA4.Signal=GPIO_Output PA15\ (JTDI).Signal=GPIO_Output
PA5.Locked=true PA2.Mode=Asynchronous
PA5.Signal=GPIO_Output PA2.Signal=USART2_TX
PA6.Locked=true PA3.Mode=Asynchronous
PA6.Signal=GPIO_Output PA3.Signal=USART2_RX
PA7.Locked=true PA4.Locked=true
PA7.Signal=GPIO_Output PA4.Signal=GPIO_Output
PA8.Locked=true PA5.Locked=true
PA8.Signal=GPIO_Input PA5.Signal=GPIO_Output
PA9.Mode=Asynchronous PA6.Locked=true
PA9.Signal=USART1_TX PA6.Signal=GPIO_Output
PB0.Locked=true PA7.Locked=true
PB0.Signal=GPIO_Output PA7.Signal=GPIO_Output
PB10.Mode=Asynchronous PA8.Locked=true
PB10.Signal=LPUART1_RX PA8.Signal=GPIO_Input
PB11.Mode=Asynchronous PA9.Mode=Asynchronous
PB11.Signal=LPUART1_TX PA9.Signal=USART1_TX
PB12.Mode=Hardware Flow Control (RS485) PB0.Locked=true
PB12.Signal=LPUART1_DE PB0.Signal=GPIO_Output
PB13.Locked=true PB10.Mode=Asynchronous
PB13.Mode=Full_Duplex_Master PB10.Signal=LPUART1_RX
PB13.Signal=SPI2_SCK PB11.Mode=Asynchronous
PB14.Locked=true PB11.Signal=LPUART1_TX
PB14.Mode=Full_Duplex_Master PB12.Mode=Hardware Flow Control (RS485)
PB14.Signal=SPI2_MISO PB12.Signal=LPUART1_DE
PB15.Locked=true PB13.Locked=true
PB15.Mode=Full_Duplex_Master PB13.Mode=Full_Duplex_Master
PB15.Signal=SPI2_MOSI PB13.Signal=SPI2_SCK
PB2.Locked=true PB14.Locked=true
PB2.Signal=GPIO_Output PB14.Mode=Full_Duplex_Master
PB3\ (JTDO-TRACESWO).Mode=Full_Duplex_Master PB14.Signal=SPI2_MISO
PB3\ (JTDO-TRACESWO).Signal=SPI3_SCK PB15.Locked=true
PB4\ (NJTRST).Mode=Full_Duplex_Master PB15.Mode=Full_Duplex_Master
PB4\ (NJTRST).Signal=SPI3_MISO PB15.Signal=SPI2_MOSI
PB5.Mode=Full_Duplex_Master PB2.Locked=true
PB5.Signal=SPI3_MOSI PB2.Signal=GPIO_Output
PB6.Locked=true PB3\ (JTDO-TRACESWO).Mode=Full_Duplex_Master
PB6.Signal=GPIO_Output PB3\ (JTDO-TRACESWO).Signal=SPI3_SCK
PB7.Locked=true PB4\ (NJTRST).Mode=Full_Duplex_Master
PB7.Signal=GPXTI7 PB4\ (NJTRST).Signal=SPI3_MISO
PB8.Mode=CAN_Activate PB5.Mode=Full_Duplex_Master
PB8.Signal=CAN1_RX PB5.Signal=SPI3_MOSI
PB9.Mode=CAN_Activate PB6.Locked=true
PB9.Signal=CAN1_TX PB6.Signal=GPIO_Output
PC0.Mode=I2C PB7.Locked=true
PC0.Signal=I2C3_SCL PB7.Signal=GPXTI7
PC1.Mode=I2C PB8.Mode=CAN_Activate
PC1.Signal=I2C3_SDA PB8.Signal=CAN1_RX
PC10.Mode=mmc_4_bits_Wide_bus PB9.Mode=CAN_Activate
PC10.Signal=SDMMC1_D2 PB9.Signal=CAN1_TX
PC11.Mode=mmc_4_bits_Wide_bus PC0.Mode=I2C
PC11.Signal=SDMMC1_D3 PC0.Signal=I2C3_SCL
PC12.Mode=mmc_4_bits_Wide_bus PC1.Mode=I2C
PC12.Signal=SDMMC1_CK PC1.Signal=I2C3_SDA
PC13.Locked=true PC10.Mode=mmc_4_bits_Wide_bus
PC13.Signal=GPIO_Output PC10.Signal=SDMMC1_D2
PC14-OSC32_IN\ (PC14).Locked=true PC11.Mode=mmc_4_bits_Wide_bus
PC14-OSC32_IN\ (PC14).Signal=GPXTI14 PC11.Signal=SDMMC1_D3
PC15-OSC32_OUT\ (PC15).Locked=true PC12.Mode=mmc_4_bits_Wide_bus
PC15-OSC32_OUT\ (PC15).Signal=GPIO_Output PC12.Signal=SDMMC1_CK
PC2.Locked=true PC13.Locked=true
PC2.Signal=GPXTI2 PC13.Signal=GPIO_Output
PC3.Locked=true PC14-OSC32_IN\ (PC14).Locked=true
PC3.Signal=GPXTI3 PC14-OSC32_IN\ (PC14).Signal=GPXTI14
PC4.Mode=Asynchronous PC15-OSC32_OUT\ (PC15).Locked=true
PC4.Signal=USART3_TX PC15-OSC32_OUT\ (PC15).Signal=GPIO_Output
PC5.Mode=Asynchronous PC2.Locked=true
PC5.Signal=USART3_RX PC2.Signal=GPXTI2
PC6.Locked=true PC3.Locked=true
PC6.Signal=GPIO_Output PC3.Signal=GPXTI3
PC8.Mode=mmc_4_bits_Wide_bus PC4.Mode=Asynchronous
PC8.Signal=SDMMC1_D0 PC4.Signal=USART3_TX
PC9.Mode=mmc_4_bits_Wide_bus PC5.Mode=Asynchronous
PC9.Signal=SDMMC1_D1 PC5.Signal=USART3_RX
PD2.Mode=mmc_4_bits_Wide_bus PC6.Locked=true
PD2.Signal=SDMMC1_CMD PC6.Signal=GPIO_Output
PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator PC8.Mode=mmc_4_bits_Wide_bus
PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN PC8.Signal=SDMMC1_D0
PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator PC9.Mode=mmc_4_bits_Wide_bus
PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT PC9.Signal=SDMMC1_D1
PinOutPanel.RotationAngle=270 PD2.Mode=mmc_4_bits_Wide_bus
ProjectManager.AskForMigrate=true PD2.Signal=SDMMC1_CMD
ProjectManager.BackupPrevious=false PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator
ProjectManager.CompilerOptimize=6 PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN
ProjectManager.ComputerToolchain=false PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator
ProjectManager.CoupleFile=false PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT
ProjectManager.CustomerFirmwarePackage= PinOutPanel.RotationAngle=270
ProjectManager.DefaultFWLocation=true ProjectManager.AskForMigrate=true
ProjectManager.DeletePrevious=true ProjectManager.BackupPrevious=false
ProjectManager.DeviceId=STM32L476RETx ProjectManager.CompilerOptimize=6
ProjectManager.FirmwarePackage=STM32Cube FW_L4 V1.18.0 ProjectManager.ComputerToolchain=false
ProjectManager.FreePins=false ProjectManager.CoupleFile=false
ProjectManager.HalAssertFull=false ProjectManager.CustomerFirmwarePackage=
ProjectManager.HeapSize=0x3000 ProjectManager.DefaultFWLocation=true
ProjectManager.KeepUserCode=true ProjectManager.DeletePrevious=true
ProjectManager.LastFirmware=true ProjectManager.DeviceId=STM32L476RETx
ProjectManager.LibraryCopy=1 ProjectManager.FirmwarePackage=STM32Cube FW_L4 V1.18.0
ProjectManager.MainLocation=Core/Src ProjectManager.FreePins=false
ProjectManager.NoMain=false ProjectManager.HalAssertFull=false
ProjectManager.PreviousToolchain=STM32CubeIDE ProjectManager.HeapSize=0x3000
ProjectManager.ProjectBuild=false ProjectManager.KeepUserCode=true
ProjectManager.ProjectFileName=MCU.ioc ProjectManager.LastFirmware=true
ProjectManager.ProjectName=MCU ProjectManager.LibraryCopy=1
ProjectManager.ProjectStructure= ProjectManager.MainLocation=Core/Src
ProjectManager.RegisterCallBack= ProjectManager.NoMain=false
ProjectManager.StackSize=0x2000 ProjectManager.PreviousToolchain=STM32CubeIDE
ProjectManager.TargetToolchain=STM32CubeIDE ProjectManager.ProjectBuild=false
ProjectManager.ToolChainLocation= ProjectManager.ProjectFileName=MCU.ioc
ProjectManager.UAScriptAfterPath= ProjectManager.ProjectName=MCU
ProjectManager.UAScriptBeforePath= ProjectManager.ProjectStructure=
ProjectManager.UnderRoot=true ProjectManager.RegisterCallBack=
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_CAN1_Init-CAN1-false-HAL-true,5-MX_I2C3_Init-I2C3-false-HAL-true,6-MX_LPUART1_UART_Init-LPUART1-false-HAL-true,7-MX_UART4_Init-UART4-false-HAL-true,8-MX_USART1_UART_Init-USART1-false-HAL-true,9-MX_USART2_UART_Init-USART2-false-HAL-true,10-MX_USART3_UART_Init-USART3-false-HAL-true,11-MX_SDMMC1_MMC_Init-SDMMC1-false-HAL-true,12-MX_SPI3_Init-SPI3-false-HAL-true,13-MX_SPI2_Init-SPI2-false-HAL-true,14-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,15-MX_CRC_Init-CRC-false-HAL-true,16-MX_FATFS_Init-FATFS-false-HAL-false ProjectManager.StackSize=0x2000
RCC.ADCFreq_Value=96000000 ProjectManager.TargetToolchain=STM32CubeIDE
RCC.AHBFreq_Value=80000000 ProjectManager.ToolChainLocation=
RCC.APB1Freq_Value=80000000 ProjectManager.UAScriptAfterPath=
RCC.APB1TimFreq_Value=80000000 ProjectManager.UAScriptBeforePath=
RCC.APB2Freq_Value=80000000 ProjectManager.UnderRoot=true
RCC.APB2TimFreq_Value=80000000 ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_CAN1_Init-CAN1-false-HAL-true,5-MX_I2C3_Init-I2C3-false-HAL-true,6-MX_LPUART1_UART_Init-LPUART1-false-HAL-true,7-MX_UART4_Init-UART4-false-HAL-true,8-MX_USART1_UART_Init-USART1-false-HAL-true,9-MX_USART2_UART_Init-USART2-false-HAL-true,10-MX_USART3_UART_Init-USART3-false-HAL-true,11-MX_SDMMC1_MMC_Init-SDMMC1-false-HAL-true,12-MX_SPI3_Init-SPI3-false-HAL-true,13-MX_SPI2_Init-SPI2-false-HAL-true,14-MX_CRC_Init-CRC-false-HAL-true,15-MX_FATFS_Init-FATFS-false-HAL-false,16-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-false-HAL-true
RCC.CortexFreq_Value=80000000 RCC.ADCFreq_Value=96000000
RCC.DFSDMFreq_Value=80000000 RCC.AHBFreq_Value=80000000
RCC.FCLKCortexFreq_Value=80000000 RCC.APB1Freq_Value=80000000
RCC.FamilyName=M RCC.APB1TimFreq_Value=80000000
RCC.HCLKFreq_Value=80000000 RCC.APB2Freq_Value=80000000
RCC.HSE_VALUE=16000000 RCC.APB2TimFreq_Value=80000000
RCC.HSI_VALUE=16000000 RCC.CortexFreq_Value=80000000
RCC.I2C1Freq_Value=80000000 RCC.DFSDMFreq_Value=80000000
RCC.I2C2Freq_Value=80000000 RCC.FCLKCortexFreq_Value=80000000
RCC.I2C3Freq_Value=80000000 RCC.FamilyName=M
RCC.IPParameters=ADCFreq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,DFSDMFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,MSIClockRange,MSI_VALUE,PLLN,PLLPoutputFreq_Value,PLLQ,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PLLSAI1N,PLLSAI1PoutputFreq_Value,PLLSAI1Q,PLLSAI1QoutputFreq_Value,PLLSAI1RoutputFreq_Value,PLLSAI2PoutputFreq_Value,PLLSAI2RoutputFreq_Value,PLLSourceVirtual,PWRFreq_Value,RNGFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SDMMCFreq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAI1OutputFreq_Value,VCOSAI2OutputFreq_Value RCC.HCLKFreq_Value=80000000
RCC.LPTIM1Freq_Value=80000000 RCC.HSE_VALUE=16000000
RCC.LPTIM2Freq_Value=80000000 RCC.HSI_VALUE=16000000
RCC.LPUART1Freq_Value=80000000 RCC.I2C1Freq_Value=80000000
RCC.LSCOPinFreq_Value=32000 RCC.I2C2Freq_Value=80000000
RCC.LSE_VALUE=32768 RCC.I2C3Freq_Value=80000000
RCC.LSI_VALUE=32000 RCC.IPParameters=ADCFreq_Value,AHBFreq_Value,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,DFSDMFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2C1Freq_Value,I2C2Freq_Value,I2C3Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPUART1Freq_Value,LSCOPinFreq_Value,LSE_VALUE,LSI_VALUE,MCO1PinFreq_Value,MSIClockRange,MSI_VALUE,PLLN,PLLPoutputFreq_Value,PLLQ,PLLQoutputFreq_Value,PLLRCLKFreq_Value,PLLSAI1N,PLLSAI1PoutputFreq_Value,PLLSAI1Q,PLLSAI1QoutputFreq_Value,PLLSAI1RoutputFreq_Value,PLLSAI2PoutputFreq_Value,PLLSAI2RoutputFreq_Value,PLLSourceVirtual,PWRFreq_Value,RNGFreq_Value,SAI1Freq_Value,SAI2Freq_Value,SDMMCFreq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,UART4Freq_Value,UART5Freq_Value,USART1Freq_Value,USART2Freq_Value,USART3Freq_Value,USBFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VCOSAI1OutputFreq_Value,VCOSAI2OutputFreq_Value
RCC.MCO1PinFreq_Value=80000000 RCC.LPTIM1Freq_Value=80000000
RCC.MSIClockRange=RCC_MSIRANGE_9 RCC.LPTIM2Freq_Value=80000000
RCC.MSI_VALUE=24000000 RCC.LPUART1Freq_Value=80000000
RCC.PLLN=10 RCC.LSCOPinFreq_Value=32000
RCC.PLLPoutputFreq_Value=22857142.85714286 RCC.LSE_VALUE=32768
RCC.PLLQ=RCC_PLLQ_DIV4 RCC.LSI_VALUE=32000
RCC.PLLQoutputFreq_Value=40000000 RCC.MCO1PinFreq_Value=80000000
RCC.PLLRCLKFreq_Value=80000000 RCC.MSIClockRange=RCC_MSIRANGE_9
RCC.PLLSAI1N=12 RCC.MSI_VALUE=24000000
RCC.PLLSAI1PoutputFreq_Value=27428571.42857143 RCC.PLLN=10
RCC.PLLSAI1Q=RCC_PLLQ_DIV4 RCC.PLLPoutputFreq_Value=22857142.85714286
RCC.PLLSAI1QoutputFreq_Value=48000000 RCC.PLLQ=RCC_PLLQ_DIV4
RCC.PLLSAI1RoutputFreq_Value=96000000 RCC.PLLQoutputFreq_Value=40000000
RCC.PLLSAI2PoutputFreq_Value=18285714.285714287 RCC.PLLRCLKFreq_Value=80000000
RCC.PLLSAI2RoutputFreq_Value=64000000 RCC.PLLSAI1N=12
RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE RCC.PLLSAI1PoutputFreq_Value=27428571.42857143
RCC.PWRFreq_Value=80000000 RCC.PLLSAI1Q=RCC_PLLQ_DIV4
RCC.RNGFreq_Value=48000000 RCC.PLLSAI1QoutputFreq_Value=48000000
RCC.SAI1Freq_Value=27428571.42857143 RCC.PLLSAI1RoutputFreq_Value=96000000
RCC.SAI2Freq_Value=27428571.42857143 RCC.PLLSAI2PoutputFreq_Value=18285714.285714287
RCC.SDMMCFreq_Value=48000000 RCC.PLLSAI2RoutputFreq_Value=64000000
RCC.SWPMI1Freq_Value=80000000 RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE
RCC.SYSCLKFreq_VALUE=80000000 RCC.PWRFreq_Value=80000000
RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK RCC.RNGFreq_Value=48000000
RCC.UART4Freq_Value=80000000 RCC.SAI1Freq_Value=27428571.42857143
RCC.UART5Freq_Value=80000000 RCC.SAI2Freq_Value=27428571.42857143
RCC.USART1Freq_Value=80000000 RCC.SDMMCFreq_Value=48000000
RCC.USART2Freq_Value=80000000 RCC.SWPMI1Freq_Value=80000000
RCC.USART3Freq_Value=80000000 RCC.SYSCLKFreq_VALUE=80000000
RCC.USBFreq_Value=48000000 RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
RCC.VCOInputFreq_Value=16000000 RCC.UART4Freq_Value=80000000
RCC.VCOOutputFreq_Value=160000000 RCC.UART5Freq_Value=80000000
RCC.VCOSAI1OutputFreq_Value=192000000 RCC.USART1Freq_Value=80000000
RCC.VCOSAI2OutputFreq_Value=128000000 RCC.USART2Freq_Value=80000000
SDMMC1.ClockDiv=0 RCC.USART3Freq_Value=80000000
SDMMC1.ClockPowerSave=SDMMC_CLOCK_POWER_SAVE_ENABLE RCC.USBFreq_Value=48000000
SDMMC1.HardwareFlowControl=SDMMC_HARDWARE_FLOW_CONTROL_ENABLE RCC.VCOInputFreq_Value=16000000
SDMMC1.IPParameters=HardwareFlowControl,ClockDiv,ClockPowerSave RCC.VCOOutputFreq_Value=160000000
SH.GPXTI14.0=GPIO_EXTI14 RCC.VCOSAI1OutputFreq_Value=192000000
SH.GPXTI14.ConfNb=1 RCC.VCOSAI2OutputFreq_Value=128000000
SH.GPXTI2.0=GPIO_EXTI2 SDMMC1.ClockDiv=0
SH.GPXTI2.ConfNb=1 SDMMC1.ClockPowerSave=SDMMC_CLOCK_POWER_SAVE_ENABLE
SH.GPXTI3.0=GPIO_EXTI3 SDMMC1.HardwareFlowControl=SDMMC_HARDWARE_FLOW_CONTROL_ENABLE
SH.GPXTI3.ConfNb=1 SDMMC1.IPParameters=HardwareFlowControl,ClockDiv,ClockPowerSave
SH.GPXTI7.0=GPIO_EXTI7 SH.GPXTI14.0=GPIO_EXTI14
SH.GPXTI7.ConfNb=1 SH.GPXTI14.ConfNb=1
SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2 SH.GPXTI2.0=GPIO_EXTI2
SPI2.CalculateBaudRate=40.0 MBits/s SH.GPXTI2.ConfNb=1
SPI2.Direction=SPI_DIRECTION_2LINES SH.GPXTI3.0=GPIO_EXTI3
SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler SH.GPXTI3.ConfNb=1
SPI2.Mode=SPI_MODE_MASTER SH.GPXTI7.0=GPIO_EXTI7
SPI2.VirtualType=VM_MASTER SH.GPXTI7.ConfNb=1
SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2 SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2
SPI3.CalculateBaudRate=40.0 MBits/s SPI2.CalculateBaudRate=40.0 MBits/s
SPI3.Direction=SPI_DIRECTION_2LINES SPI2.Direction=SPI_DIRECTION_2LINES
SPI3.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler
SPI3.Mode=SPI_MODE_MASTER SPI2.Mode=SPI_MODE_MASTER
SPI3.VirtualType=VM_MASTER SPI2.VirtualType=VM_MASTER
UART4.IPParameters=OverSampling,StopBits,Parity SPI3.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_2
UART4.OverSampling=UART_OVERSAMPLING_8 SPI3.CalculateBaudRate=40.0 MBits/s
UART4.Parity=PARITY_EVEN SPI3.Direction=SPI_DIRECTION_2LINES
UART4.StopBits=UART_STOPBITS_2 SPI3.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler
USART1.IPParameters=VirtualMode-Asynchronous,OverSampling,OneBitSampling,SwapParam SPI3.Mode=SPI_MODE_MASTER
USART1.OneBitSampling=UART_ONE_BIT_SAMPLE_DISABLE SPI3.VirtualType=VM_MASTER
USART1.OverSampling=UART_OVERSAMPLING_8 UART4.IPParameters=OverSampling,StopBits,Parity
USART1.SwapParam=ADVFEATURE_SWAP_DISABLE UART4.OverSampling=UART_OVERSAMPLING_8
USART1.VirtualMode-Asynchronous=VM_ASYNC UART4.Parity=PARITY_EVEN
USART2.BaudRate=1000000 UART4.StopBits=UART_STOPBITS_2
USART2.IPParameters=VirtualMode-Asynchronous,BaudRate USART1.IPParameters=VirtualMode-Asynchronous,OverSampling,OneBitSampling,SwapParam
USART2.VirtualMode-Asynchronous=VM_ASYNC USART1.OneBitSampling=UART_ONE_BIT_SAMPLE_DISABLE
USART3.AutoBaudRateEnableParam=UART_ADVFEATURE_AUTOBAUDRATE_DISABLE USART1.OverSampling=UART_OVERSAMPLING_8
USART3.IPParameters=VirtualMode-Asynchronous,OverSampling,Mode,OneBitSampling,AutoBaudRateEnableParam USART1.SwapParam=ADVFEATURE_SWAP_DISABLE
USART3.Mode=MODE_TX_RX USART1.VirtualMode-Asynchronous=VM_ASYNC
USART3.OneBitSampling=UART_ONE_BIT_SAMPLE_ENABLE USART2.BaudRate=1000000
USART3.OverSampling=UART_OVERSAMPLING_8 USART2.IPParameters=VirtualMode-Asynchronous,BaudRate
USART3.VirtualMode-Asynchronous=VM_ASYNC USART2.VirtualMode-Asynchronous=VM_ASYNC
USB_DEVICE.CLASS_NAME_FS=MSC USART3.AutoBaudRateEnableParam=UART_ADVFEATURE_AUTOBAUDRATE_DISABLE
USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,CLASS_NAME_FS,MSC_MEDIA_PACKET USART3.IPParameters=VirtualMode-Asynchronous,OverSampling,Mode,OneBitSampling,AutoBaudRateEnableParam
USB_DEVICE.MSC_MEDIA_PACKET=2048 USART3.Mode=MODE_TX_RX
USB_DEVICE.VirtualMode=Msc USART3.OneBitSampling=UART_ONE_BIT_SAMPLE_ENABLE
USB_DEVICE.VirtualModeFS=Msc_FS USART3.OverSampling=UART_OVERSAMPLING_8
USB_OTG_FS.IPParameters=VirtualMode USART3.VirtualMode-Asynchronous=VM_ASYNC
USB_OTG_FS.VirtualMode=Device_Only USB_OTG_FS.IPParameters=VirtualMode
VP_CRC_VS_CRC.Mode=CRC_Activate USB_OTG_FS.VirtualMode=Device_Only
VP_CRC_VS_CRC.Signal=CRC_VS_CRC VP_CRC_VS_CRC.Mode=CRC_Activate
VP_FATFS_VS_Generic.Mode=User_defined VP_CRC_VS_CRC.Signal=CRC_VS_CRC
VP_FATFS_VS_Generic.Signal=FATFS_VS_Generic VP_FATFS_VS_Generic.Mode=User_defined
VP_SYS_VS_tim15.Mode=TIM15 VP_FATFS_VS_Generic.Signal=FATFS_VS_Generic
VP_SYS_VS_tim15.Signal=SYS_VS_tim15 VP_SYS_VS_tim15.Mode=TIM15
VP_SYS_V_PVD_IN.Mode=Mode_PVD_Int VP_SYS_VS_tim15.Signal=SYS_VS_tim15
VP_SYS_V_PVD_IN.Signal=SYS_V_PVD_IN VP_SYS_V_PVD_IN.Mode=Mode_PVD_Int
VP_USB_DEVICE_VS_USB_DEVICE_MSC_FS.Mode=MSC_FS VP_SYS_V_PVD_IN.Signal=SYS_V_PVD_IN
VP_USB_DEVICE_VS_USB_DEVICE_MSC_FS.Signal=USB_DEVICE_VS_USB_DEVICE_MSC_FS board=custom
board=custom

View File

@ -1,130 +0,0 @@
/**
******************************************************************************
* @file usbd_msc.h
* @author MCD Application Team
* @brief Header for the usbd_msc.c file
******************************************************************************
* @attention
*
* Copyright (c) 2015 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_MSC_H
#define __USBD_MSC_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_msc_bot.h"
#include "usbd_msc_scsi.h"
#include "usbd_ioreq.h"
/** @addtogroup USBD_MSC_BOT
* @{
*/
/** @defgroup USBD_MSC
* @brief This file is the Header file for usbd_msc.c
* @{
*/
/** @defgroup USBD_BOT_Exported_Defines
* @{
*/
/* MSC Class Config */
#ifndef MSC_MEDIA_PACKET
#define MSC_MEDIA_PACKET 512U
#endif /* MSC_MEDIA_PACKET */
#define MSC_MAX_FS_PACKET 0x40U
#define MSC_MAX_HS_PACKET 0x200U
#define BOT_GET_MAX_LUN 0xFE
#define BOT_RESET 0xFF
#define USB_MSC_CONFIG_DESC_SIZ 32
#ifndef MSC_EPIN_ADDR
#define MSC_EPIN_ADDR 0x81U
#endif /* MSC_EPIN_ADDR */
#ifndef MSC_EPOUT_ADDR
#define MSC_EPOUT_ADDR 0x01U
#endif /* MSC_EPOUT_ADDR */
/**
* @}
*/
/** @defgroup USB_CORE_Exported_Types
* @{
*/
typedef struct _USBD_STORAGE
{
int8_t (* Init)(uint8_t lun);
int8_t (* GetCapacity)(uint8_t lun, uint32_t *block_num, uint16_t *block_size);
int8_t (* IsReady)(uint8_t lun);
int8_t (* IsWriteProtected)(uint8_t lun);
int8_t (* Read)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
int8_t (* Write)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
int8_t (* GetMaxLun)(void);
int8_t *pInquiry;
} USBD_StorageTypeDef;
typedef struct
{
uint32_t max_lun;
uint32_t interface;
uint8_t bot_state;
uint8_t bot_status;
uint32_t bot_data_length;
uint8_t bot_data[MSC_MEDIA_PACKET];
USBD_MSC_BOT_CBWTypeDef cbw;
USBD_MSC_BOT_CSWTypeDef csw;
USBD_SCSI_SenseTypeDef scsi_sense [SENSE_LIST_DEEPTH];
uint8_t scsi_sense_head;
uint8_t scsi_sense_tail;
uint8_t scsi_medium_state;
uint16_t scsi_blk_size;
uint32_t scsi_blk_nbr;
uint32_t scsi_blk_addr;
uint32_t scsi_blk_len;
} USBD_MSC_BOT_HandleTypeDef;
/* Structure for MSC process */
extern USBD_ClassTypeDef USBD_MSC;
#define USBD_MSC_CLASS &USBD_MSC
uint8_t USBD_MSC_RegisterStorage(USBD_HandleTypeDef *pdev,
USBD_StorageTypeDef *fops);
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __USBD_MSC_H */
/**
* @}
*/

View File

@ -1,579 +0,0 @@
/**
******************************************************************************
* @file usbd_msc.c
* @author MCD Application Team
* @brief This file provides all the MSC core functions.
*
******************************************************************************
* @attention
*
* Copyright (c) 2015 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
* @verbatim
*
* ===================================================================
* MSC Class Description
* ===================================================================
* This module manages the MSC class V1.0 following the "Universal
* Serial Bus Mass Storage Class (MSC) Bulk-Only Transport (BOT) Version 1.0
* Sep. 31, 1999".
* This driver implements the following aspects of the specification:
* - Bulk-Only Transport protocol
* - Subclass : SCSI transparent command set (ref. SCSI Primary Commands - 3 (SPC-3))
*
* @endverbatim
*
******************************************************************************
*/
/* BSPDependencies
- "stm32xxxxx_{eval}{discovery}{nucleo_144}.c"
- "stm32xxxxx_{eval}{discovery}_io.c"
- "stm32xxxxx_{eval}{discovery}{adafruit}_sd.c"
EndBSPDependencies */
/* Includes ------------------------------------------------------------------*/
#include "usbd_msc.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{
*/
/** @defgroup MSC_CORE
* @brief Mass storage core module
* @{
*/
/** @defgroup MSC_CORE_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup MSC_CORE_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup MSC_CORE_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup MSC_CORE_Private_FunctionPrototypes
* @{
*/
uint8_t USBD_MSC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
uint8_t USBD_MSC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
uint8_t USBD_MSC_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
uint8_t USBD_MSC_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum);
uint8_t USBD_MSC_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum);
#ifndef USE_USBD_COMPOSITE
uint8_t *USBD_MSC_GetHSCfgDesc(uint16_t *length);
uint8_t *USBD_MSC_GetFSCfgDesc(uint16_t *length);
uint8_t *USBD_MSC_GetOtherSpeedCfgDesc(uint16_t *length);
uint8_t *USBD_MSC_GetDeviceQualifierDescriptor(uint16_t *length);
#endif /* USE_USBD_COMPOSITE */
/**
* @}
*/
/** @defgroup MSC_CORE_Private_Variables
* @{
*/
USBD_ClassTypeDef USBD_MSC =
{
USBD_MSC_Init,
USBD_MSC_DeInit,
USBD_MSC_Setup,
NULL, /*EP0_TxSent*/
NULL, /*EP0_RxReady*/
USBD_MSC_DataIn,
USBD_MSC_DataOut,
NULL, /*SOF */
NULL,
NULL,
#ifdef USE_USBD_COMPOSITE
NULL,
NULL,
NULL,
NULL,
#else
USBD_MSC_GetHSCfgDesc,
USBD_MSC_GetFSCfgDesc,
USBD_MSC_GetOtherSpeedCfgDesc,
USBD_MSC_GetDeviceQualifierDescriptor,
#endif /* USE_USBD_COMPOSITE */
};
/* USB Mass storage device Configuration Descriptor */
#ifndef USE_USBD_COMPOSITE
/* USB Mass storage device Configuration Descriptor */
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
__ALIGN_BEGIN static uint8_t USBD_MSC_CfgDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIGN_END =
{
0x09, /* bLength: Configuration Descriptor size */
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
USB_MSC_CONFIG_DESC_SIZ,
0x00,
0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue */
0x04, /* iConfiguration */
#if (USBD_SELF_POWERED == 1U)
0xC0, /* bmAttributes: Bus Powered according to user configuration */
#else
0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif /* USBD_SELF_POWERED */
USBD_MAX_POWER, /* MaxPower (mA) */
/******************** Mass Storage interface ********************/
0x09, /* bLength: Interface Descriptor size */
0x04, /* bDescriptorType: */
0x00, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints */
0x08, /* bInterfaceClass: MSC Class */
0x06, /* bInterfaceSubClass : SCSI transparent*/
0x50, /* nInterfaceProtocol */
0x05, /* iInterface: */
/******************** Mass Storage Endpoints ********************/
0x07, /* Endpoint descriptor length = 7 */
0x05, /* Endpoint descriptor type */
MSC_EPIN_ADDR, /* Endpoint address (IN, address 1) */
0x02, /* Bulk endpoint type */
LOBYTE(MSC_MAX_FS_PACKET),
HIBYTE(MSC_MAX_FS_PACKET),
0x00, /* Polling interval in milliseconds */
0x07, /* Endpoint descriptor length = 7 */
0x05, /* Endpoint descriptor type */
MSC_EPOUT_ADDR, /* Endpoint address (OUT, address 1) */
0x02, /* Bulk endpoint type */
LOBYTE(MSC_MAX_FS_PACKET),
HIBYTE(MSC_MAX_FS_PACKET),
0x00 /* Polling interval in milliseconds */
};
/* USB Standard Device Descriptor */
__ALIGN_BEGIN static uint8_t USBD_MSC_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
{
USB_LEN_DEV_QUALIFIER_DESC,
USB_DESC_TYPE_DEVICE_QUALIFIER,
0x00,
0x02,
0x00,
0x00,
0x00,
MSC_MAX_FS_PACKET,
0x01,
0x00,
};
#endif /* USE_USBD_COMPOSITE */
uint8_t MSCInEpAdd = MSC_EPIN_ADDR;
uint8_t MSCOutEpAdd = MSC_EPOUT_ADDR;
/**
* @}
*/
/** @defgroup MSC_CORE_Private_Functions
* @{
*/
/**
* @brief USBD_MSC_Init
* Initialize the mass storage configuration
* @param pdev: device instance
* @param cfgidx: configuration index
* @retval status
*/
uint8_t USBD_MSC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
UNUSED(cfgidx);
USBD_MSC_BOT_HandleTypeDef *hmsc;
hmsc = (USBD_MSC_BOT_HandleTypeDef *)USBD_malloc(sizeof(USBD_MSC_BOT_HandleTypeDef));
if (hmsc == NULL)
{
pdev->pClassDataCmsit[pdev->classId] = NULL;
return (uint8_t)USBD_EMEM;
}
pdev->pClassDataCmsit[pdev->classId] = (void *)hmsc;
pdev->pClassData = pdev->pClassDataCmsit[pdev->classId];
#ifdef USE_USBD_COMPOSITE
/* Get the Endpoints addresses allocated for this class instance */
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
#endif /* USE_USBD_COMPOSITE */
if (pdev->dev_speed == USBD_SPEED_HIGH)
{
/* Open EP OUT */
(void)USBD_LL_OpenEP(pdev, MSCOutEpAdd, USBD_EP_TYPE_BULK, MSC_MAX_HS_PACKET);
pdev->ep_out[MSCOutEpAdd & 0xFU].is_used = 1U;
/* Open EP IN */
(void)USBD_LL_OpenEP(pdev, MSCInEpAdd, USBD_EP_TYPE_BULK, MSC_MAX_HS_PACKET);
pdev->ep_in[MSCInEpAdd & 0xFU].is_used = 1U;
}
else
{
/* Open EP OUT */
(void)USBD_LL_OpenEP(pdev, MSCOutEpAdd, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
pdev->ep_out[MSCOutEpAdd & 0xFU].is_used = 1U;
/* Open EP IN */
(void)USBD_LL_OpenEP(pdev, MSCInEpAdd, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
pdev->ep_in[MSCInEpAdd & 0xFU].is_used = 1U;
}
/* Init the BOT layer */
MSC_BOT_Init(pdev);
return (uint8_t)USBD_OK;
}
/**
* @brief USBD_MSC_DeInit
* DeInitialize the mass storage configuration
* @param pdev: device instance
* @param cfgidx: configuration index
* @retval status
*/
uint8_t USBD_MSC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
UNUSED(cfgidx);
#ifdef USE_USBD_COMPOSITE
/* Get the Endpoints addresses allocated for this class instance */
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
#endif /* USE_USBD_COMPOSITE */
/* Close MSC EPs */
(void)USBD_LL_CloseEP(pdev, MSCOutEpAdd);
pdev->ep_out[MSCOutEpAdd & 0xFU].is_used = 0U;
/* Close EP IN */
(void)USBD_LL_CloseEP(pdev, MSCInEpAdd);
pdev->ep_in[MSCInEpAdd & 0xFU].is_used = 0U;
/* Free MSC Class Resources */
if (pdev->pClassDataCmsit[pdev->classId] != NULL)
{
/* De-Init the BOT layer */
MSC_BOT_DeInit(pdev);
(void)USBD_free(pdev->pClassDataCmsit[pdev->classId]);
pdev->pClassDataCmsit[pdev->classId] = NULL;
pdev->pClassData = NULL;
}
return (uint8_t)USBD_OK;
}
/**
* @brief USBD_MSC_Setup
* Handle the MSC specific requests
* @param pdev: device instance
* @param req: USB request
* @retval status
*/
uint8_t USBD_MSC_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
{
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
USBD_StatusTypeDef ret = USBD_OK;
uint16_t status_info = 0U;
#ifdef USE_USBD_COMPOSITE
/* Get the Endpoints addresses allocated for this class instance */
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
#endif /* USE_USBD_COMPOSITE */
if (hmsc == NULL)
{
return (uint8_t)USBD_FAIL;
}
switch (req->bmRequest & USB_REQ_TYPE_MASK)
{
/* Class request */
case USB_REQ_TYPE_CLASS:
switch (req->bRequest)
{
case BOT_GET_MAX_LUN:
if ((req->wValue == 0U) && (req->wLength == 1U) &&
((req->bmRequest & 0x80U) == 0x80U))
{
hmsc->max_lun = (uint32_t)((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->GetMaxLun();
(void)USBD_CtlSendData(pdev, (uint8_t *)&hmsc->max_lun, 1U);
}
else
{
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
}
break;
case BOT_RESET :
if ((req->wValue == 0U) && (req->wLength == 0U) &&
((req->bmRequest & 0x80U) != 0x80U))
{
MSC_BOT_Reset(pdev);
}
else
{
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
}
break;
default:
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
break;
}
break;
/* Interface & Endpoint request */
case USB_REQ_TYPE_STANDARD:
switch (req->bRequest)
{
case USB_REQ_GET_STATUS:
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
(void)USBD_CtlSendData(pdev, (uint8_t *)&status_info, 2U);
}
else
{
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
}
break;
case USB_REQ_GET_INTERFACE:
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
(void)USBD_CtlSendData(pdev, (uint8_t *)&hmsc->interface, 1U);
}
else
{
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
}
break;
case USB_REQ_SET_INTERFACE:
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
hmsc->interface = (uint8_t)(req->wValue);
}
else
{
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
}
break;
case USB_REQ_CLEAR_FEATURE:
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
if (req->wValue == USB_FEATURE_EP_HALT)
{
/* Flush the FIFO */
(void)USBD_LL_FlushEP(pdev, (uint8_t)req->wIndex);
/* Handle BOT error */
MSC_BOT_CplClrFeature(pdev, (uint8_t)req->wIndex);
}
}
break;
default:
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
break;
}
break;
default:
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
break;
}
return (uint8_t)ret;
}
/**
* @brief USBD_MSC_DataIn
* handle data IN Stage
* @param pdev: device instance
* @param epnum: endpoint index
* @retval status
*/
uint8_t USBD_MSC_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
{
MSC_BOT_DataIn(pdev, epnum);
return (uint8_t)USBD_OK;
}
/**
* @brief USBD_MSC_DataOut
* handle data OUT Stage
* @param pdev: device instance
* @param epnum: endpoint index
* @retval status
*/
uint8_t USBD_MSC_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
{
MSC_BOT_DataOut(pdev, epnum);
return (uint8_t)USBD_OK;
}
#ifndef USE_USBD_COMPOSITE
/**
* @brief USBD_MSC_GetHSCfgDesc
* return configuration descriptor
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
uint8_t *USBD_MSC_GetHSCfgDesc(uint16_t *length)
{
USBD_EpDescTypeDef *pEpInDesc = USBD_GetEpDesc(USBD_MSC_CfgDesc, MSC_EPIN_ADDR);
USBD_EpDescTypeDef *pEpOutDesc = USBD_GetEpDesc(USBD_MSC_CfgDesc, MSC_EPOUT_ADDR);
if (pEpInDesc != NULL)
{
pEpInDesc->wMaxPacketSize = MSC_MAX_HS_PACKET;
}
if (pEpOutDesc != NULL)
{
pEpOutDesc->wMaxPacketSize = MSC_MAX_HS_PACKET;
}
*length = (uint16_t)sizeof(USBD_MSC_CfgDesc);
return USBD_MSC_CfgDesc;
}
/**
* @brief USBD_MSC_GetFSCfgDesc
* return configuration descriptor
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
uint8_t *USBD_MSC_GetFSCfgDesc(uint16_t *length)
{
USBD_EpDescTypeDef *pEpInDesc = USBD_GetEpDesc(USBD_MSC_CfgDesc, MSC_EPIN_ADDR);
USBD_EpDescTypeDef *pEpOutDesc = USBD_GetEpDesc(USBD_MSC_CfgDesc, MSC_EPOUT_ADDR);
if (pEpInDesc != NULL)
{
pEpInDesc->wMaxPacketSize = MSC_MAX_FS_PACKET;
}
if (pEpOutDesc != NULL)
{
pEpOutDesc->wMaxPacketSize = MSC_MAX_FS_PACKET;
}
*length = (uint16_t)sizeof(USBD_MSC_CfgDesc);
return USBD_MSC_CfgDesc;
}
/**
* @brief USBD_MSC_GetOtherSpeedCfgDesc
* return other speed configuration descriptor
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
uint8_t *USBD_MSC_GetOtherSpeedCfgDesc(uint16_t *length)
{
USBD_EpDescTypeDef *pEpInDesc = USBD_GetEpDesc(USBD_MSC_CfgDesc, MSC_EPIN_ADDR);
USBD_EpDescTypeDef *pEpOutDesc = USBD_GetEpDesc(USBD_MSC_CfgDesc, MSC_EPOUT_ADDR);
if (pEpInDesc != NULL)
{
pEpInDesc->wMaxPacketSize = MSC_MAX_FS_PACKET;
}
if (pEpOutDesc != NULL)
{
pEpOutDesc->wMaxPacketSize = MSC_MAX_FS_PACKET;
}
*length = (uint16_t)sizeof(USBD_MSC_CfgDesc);
return USBD_MSC_CfgDesc;
}
/**
* @brief DeviceQualifierDescriptor
* return Device Qualifier descriptor
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
uint8_t *USBD_MSC_GetDeviceQualifierDescriptor(uint16_t *length)
{
*length = (uint16_t)sizeof(USBD_MSC_DeviceQualifierDesc);
return USBD_MSC_DeviceQualifierDesc;
}
#endif /* USE_USBD_COMPOSITE */
/**
* @brief USBD_MSC_RegisterStorage
* @param fops: storage callback
* @retval status
*/
uint8_t USBD_MSC_RegisterStorage(USBD_HandleTypeDef *pdev, USBD_StorageTypeDef *fops)
{
if (fops == NULL)
{
return (uint8_t)USBD_FAIL;
}
pdev->pUserData[pdev->classId] = fops;
return (uint8_t)USBD_OK;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/

File diff suppressed because it is too large Load Diff

9
README.md Normal file
View File

@ -0,0 +1,9 @@
# Note about ioc file
Currently CubeMX templates are not implemented for the 3rd party
I-CUBE-USBD-Composite package
See [Issue](https://github.com/alambe94/I-CUBE-USBD-Composite/issues/2)
To fix this I've disabled the package in the CubeMX IOC file to prevent it being
regenerated and have simply renamed and included the populated files.

View File

@ -0,0 +1,88 @@
/**
******************************************************************************
* File Name : AL94.I-CUBE-USBD-COMPOSITE_conf.h
* Description : This file provides code for the configuration
* of the AL94.I-CUBE-USBD-COMPOSITE_conf.h instances.
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __AL94__I_CUBE_USBD_COMPOSITE_CONF__H__
#define __AL94__I_CUBE_USBD_COMPOSITE_CONF__H__
#ifdef __cplusplus
extern "C"
{
#endif
/* Includes ------------------------------------------------------------------*/
/**
MiddleWare name : AL94.I-CUBE-USBD-COMPOSITE.1.0.3
MiddleWare fileName : AL94.I-CUBE-USBD-COMPOSITE_conf.h
MiddleWare version :
*/
/*---------- _USBD_USE_HS -----------*/
#define _USBD_USE_HS false
/*---------- _USBD_USE_CDC_ACM -----------*/
#define _USBD_USE_CDC_ACM true
/*---------- _USBD_CDC_ACM_COUNT -----------*/
#define _USBD_CDC_ACM_COUNT 1
/*---------- _USBD_USE_CDC_RNDIS -----------*/
#define _USBD_USE_CDC_RNDIS false
/*---------- _USBD_USE_CDC_ECM -----------*/
#define _USBD_USE_CDC_ECM false
/*---------- _USBD_USE_HID_MOUSE -----------*/
#define _USBD_USE_HID_MOUSE false
/*---------- _USBD_USE_HID_KEYBOARD -----------*/
#define _USBD_USE_HID_KEYBOARD false
/*---------- _USBD_USE_HID_CUSTOM -----------*/
#define _USBD_USE_HID_CUSTOM false
/*---------- _USBD_USE_UAC_MIC -----------*/
#define _USBD_USE_UAC_MIC false
/*---------- _USBD_USE_UAC_SPKR -----------*/
#define _USBD_USE_UAC_SPKR false
/*---------- _USBD_USE_UVC -----------*/
#define _USBD_USE_UVC false
/*---------- _USBD_USE_MSC -----------*/
#define _USBD_USE_MSC true
/*---------- _USBD_USE_DFU -----------*/
#define _USBD_USE_DFU false
/*---------- _USBD_USE_PRNTR -----------*/
#define _USBD_USE_PRNTR false
/*---------- _STM32F1_DEVICE -----------*/
#define _STM32F1_DEVICE false
#ifdef __cplusplus
}
#endif
#endif /*__ AL94__I_CUBE_USBD_COMPOSITE_CONF__H_H */
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -0,0 +1,168 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : usb_device.c
* @version : v1.0_Cube
* @brief : This file implements the USB Device
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "usb_device.h"
#include "usbd_desc.h"
/* USER CODE BEGIN Includes */
#include "usbd_composite.h"
/* USER CODE END Includes */
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
/* USER CODE END PV */
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE END PFP */
/* USB Device Core handle declaration. */
USBD_HandleTypeDef hUsbDevice;
/*
* -- Insert your variables declaration here --
*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/*
* -- Insert your external function declaration here --
*/
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/**
* Init USB device Library, add supported class and start the library
* @retval None
*/
void MX_USB_DEVICE_Init(void)
{
/* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
/* USER CODE END USB_DEVICE_Init_PreTreatment */
/* Init Device Library, add supported class and start the library. */
USBD_COMPOSITE_Mount_Class();
#if (USBD_USE_HS == 1)
if (USBD_Init(&hUsbDevice, &USBD_Desc, DEVICE_HS) != USBD_OK)
{
Error_Handler();
}
#else
if (USBD_Init(&hUsbDevice, &USBD_Desc, DEVICE_FS) != USBD_OK)
{
Error_Handler();
}
#endif
if (USBD_RegisterClass(&hUsbDevice, &USBD_COMPOSITE) != USBD_OK)
{
Error_Handler();
}
#if (USBD_USE_CDC_ACM == 1)
if (USBD_CDC_ACM_RegisterInterface(&hUsbDevice, &USBD_CDC_ACM_fops) != USBD_OK)
{
Error_Handler();
}
#endif
#if (USBD_USE_CDC_RNDIS == 1)
if (USBD_CDC_RNDIS_RegisterInterface(&hUsbDevice, &USBD_CDC_RNDIS_fops) != USBD_OK)
{
Error_Handler();
}
#endif
#if (USBD_USE_CDC_ECM == 1)
if (USBD_CDC_ECM_RegisterInterface(&hUsbDevice, &USBD_CDC_ECM_fops) != USBD_OK)
{
Error_Handler();
}
#endif
#if (USBD_USE_HID_MOUSE == 1)
#endif
#if (USBD_USE_HID_KEYBOARD == 1)
#endif
#if (USBD_USE_HID_CUSTOM == 1)
if (USBD_CUSTOM_HID_RegisterInterface(&hUsbDevice, &USBD_CustomHID_fops) != USBD_OK)
{
Error_Handler();
}
#endif
#if (USBD_USE_UAC_MIC == 1)
if (USBD_AUDIO_MIC_RegisterInterface(&hUsbDevice, &USBD_AUDIO_MIC_fops_FS) != USBD_OK)
{
Error_Handler();
}
#endif
#if (USBD_USE_UAC_SPKR == 1)
if (USBD_AUDIO_SPKR_RegisterInterface(&hUsbDevice, &USBD_AUDIO_SPKR_fops) != USBD_OK)
{
Error_Handler();
}
#endif
#if (USBD_USE_UVC == 1)
if (USBD_VIDEO_RegisterInterface(&hUsbDevice, &USBD_VIDEO_fops_FS) != USBD_OK)
{
Error_Handler();
}
#endif
#if (USBD_USE_MSC == 1)
if (USBD_MSC_RegisterStorage(&hUsbDevice, &USBD_Storage_Interface_fops) != USBD_OK)
{
Error_Handler();
}
#endif
#if (USBD_USE_DFU == 1)
if (USBD_DFU_RegisterMedia(&hUsbDevice, &USBD_DFU_fops) != USBD_OK)
{
Error_Handler();
}
#endif
#if (USBD_USE_PRNTR == 1)
if (USBD_PRNT_RegisterInterface(&hUsbDevice, &USBD_PRNT_fops) != USBD_OK)
{
Error_Handler();
}
#endif
if (USBD_Start(&hUsbDevice) != USBD_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
/* USER CODE END USB_DEVICE_Init_PostTreatment */
}
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,102 +1,104 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN Header */
/** /**
****************************************************************************** ******************************************************************************
* @file : usb_device.h * @file : usb_device.h
* @version : v2.0_Cube * @version : v1.0_Cube
* @brief : Header for usb_device.c file. * @brief : Header for usb_device.c file.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2024 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
/* USER CODE END Header */ */
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_DEVICE__H__ /* Define to prevent recursive inclusion -------------------------------------*/
#define __USB_DEVICE__H__ #ifndef __USB_DEVICE__H__
#define __USB_DEVICE__H__
#ifdef __cplusplus
extern "C" { #ifdef __cplusplus
#endif extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32l4xx.h" /* Includes ------------------------------------------------------------------*/
#include "stm32l4xx_hal.h" #include "main.h"
#include "usbd_def.h" #include "usbd_def.h"
/* USER CODE BEGIN INCLUDE */ /* USER CODE BEGIN INCLUDE */
/* USER CODE END INCLUDE */ /* USER CODE END INCLUDE */
/** @addtogroup USBD_OTG_DRIVER /** @addtogroup USBD_OTG_DRIVER
* @{ * @{
*/ */
/** @defgroup USBD_DEVICE USBD_DEVICE /** @defgroup USBD_DEVICE USBD_DEVICE
* @brief Device file for Usb otg low level driver. * @brief Device file for Usb otg low level driver.
* @{ * @{
*/ */
/** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables /** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables
* @brief Public variables. * @brief Public variables.
* @{ * @{
*/ */
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */ /* USER CODE BEGIN PV */
/* USER CODE END PV */ /* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */ /* USER CODE BEGIN PFP */
/* USER CODE END PFP */ /* USER CODE END PFP */
/* /*
* -- Insert your variables declaration here -- * -- Insert your variables declaration here --
*/ */
/* USER CODE BEGIN VARIABLES */ /* USER CODE BEGIN VARIABLES */
/* USER CODE END VARIABLES */ /* USER CODE END VARIABLES */
/** /**
* @} * @}
*/ */
/** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype /** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype
* @brief Declaration of public functions for Usb device. * @brief Declaration of public functions for Usb device.
* @{ * @{
*/ */
/** USB Device initialization function. */ /** USB Device initialization function. */
void MX_USB_DEVICE_Init(void); void MX_USB_DEVICE_Init(void);
/* /*
* -- Insert functions declaration here -- * -- Insert functions declaration here --
*/ */
/* USER CODE BEGIN FD */ /* USER CODE BEGIN FD */
/* USER CODE END FD */ /* USER CODE END FD */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
/** /**
* @} * @}
*/ */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* __USB_DEVICE__H__ */ #endif /* __USB_DEVICE__H__ */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -0,0 +1,544 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : usbd_cdc_if.c
* @version : v2.0_Cube
* @brief : Usb device for Virtual Com Port.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "usbd_cdc_acm_if.h"
/* USER CODE BEGIN INCLUDE */
//#include "usart.h"
//#include "tim.h"
/* USER CODE END INCLUDE */
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
/* USER CODE END PV */
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
* @brief Usb device library.
* @{
*/
/** @addtogroup USBD_CDC_IF
* @{
*/
/** @defgroup USBD_CDC_IF_Private_TypesDefinitions USBD_CDC_IF_Private_TypesDefinitions
* @brief Private types.
* @{
*/
/* USER CODE BEGIN PRIVATE_TYPES */
/* USER CODE END PRIVATE_TYPES */
/**
* @}
*/
/** @defgroup USBD_CDC_IF_Private_Defines USBD_CDC_IF_Private_Defines
* @brief Private defines.
* @{
*/
/* USER CODE BEGIN PRIVATE_DEFINES */
/* USER CODE END PRIVATE_DEFINES */
/**
* @}
*/
/** @defgroup USBD_CDC_IF_Private_Macros USBD_CDC_IF_Private_Macros
* @brief Private macros.
* @{
*/
/* USER CODE BEGIN PRIVATE_MACRO */
/* USER CODE END PRIVATE_MACRO */
/**
* @}
*/
/** @defgroup USBD_CDC_IF_Private_Variables USBD_CDC_IF_Private_Variables
* @brief Private variables.
* @{
*/
/* USER CODE BEGIN PRIVATE_VARIABLES */
#define APP_RX_DATA_SIZE 128
#define APP_TX_DATA_SIZE 128
/** RX buffer for USB */
uint8_t RX_Buffer[NUMBER_OF_CDC][APP_RX_DATA_SIZE];
/** TX buffer for USB, RX buffer for UART */
uint8_t TX_Buffer[NUMBER_OF_CDC][APP_TX_DATA_SIZE];
USBD_CDC_ACM_LineCodingTypeDef Line_Coding[NUMBER_OF_CDC];
uint32_t Write_Index[NUMBER_OF_CDC]; /* keep track of received data over UART */
uint32_t Read_Index[NUMBER_OF_CDC]; /* keep track of sent data to USB */
/* USER CODE END PRIVATE_VARIABLES */
/**
* @}
*/
/** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables
* @brief Public variables.
* @{
*/
extern USBD_HandleTypeDef hUsbDevice;
/* USER CODE BEGIN EXPORTED_VARIABLES */
/* USER CODE END EXPORTED_VARIABLES */
/**
* @}
*/
/** @defgroup USBD_CDC_IF_Private_FunctionPrototypes USBD_CDC_IF_Private_FunctionPrototypes
* @brief Private functions declaration.
* @{
*/
static int8_t CDC_Init(uint8_t cdc_ch);
static int8_t CDC_DeInit(uint8_t cdc_ch);
static int8_t CDC_Control(uint8_t cdc_ch, uint8_t cmd, uint8_t *pbuf, uint16_t length);
static int8_t CDC_Receive(uint8_t cdc_ch, uint8_t *pbuf, uint32_t *Len);
static int8_t CDC_TransmitCplt(uint8_t cdc_ch, uint8_t *Buf, uint32_t *Len, uint8_t epnum);
/* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */
//UART_HandleTypeDef *CDC_CH_To_UART_Handle(uint8_t cdc_ch)
//{
// UART_HandleTypeDef *handle = NULL;
//
// if (cdc_ch == 0)
// {
// handle = &huart1;
// }
//#if (0)
// else if (cdc_ch == 1)
// {
// handle = &huart2;
// }
// else if (cdc_ch == 2)
// {
// handle = &huart3;
// }
//#endif
// return handle;
//}
//
//uint8_t UART_Handle_TO_CDC_CH(UART_HandleTypeDef *handle)
//{
// uint8_t cdc_ch = 0;
//
// if (handle == &huart1)
// {
// cdc_ch = 0;
// }
//#if (0)
// else if (handle == &huart2)
// {
// cdc_ch = 1;
// }
// else if (handle == &huart3)
// {
// cdc_ch = 2;
// }
//#endif
// return cdc_ch;
//}
//
//void Change_UART_Setting(uint8_t cdc_ch)
//{
// UART_HandleTypeDef *handle = CDC_CH_To_UART_Handle(cdc_ch);
//
// if (HAL_UART_DeInit(handle) != HAL_OK)
// {
// /* Initialization Error */
// Error_Handler();
// }
// /* set the Stop bit */
// switch (Line_Coding[cdc_ch].format)
// {
// case 0:
// handle->Init.StopBits = UART_STOPBITS_1;
// break;
// case 2:
// handle->Init.StopBits = UART_STOPBITS_2;
// break;
// default:
// handle->Init.StopBits = UART_STOPBITS_1;
// break;
// }
//
// /* set the parity bit*/
// switch (Line_Coding[cdc_ch].paritytype)
// {
// case 0:
// handle->Init.Parity = UART_PARITY_NONE;
// break;
// case 1:
// handle->Init.Parity = UART_PARITY_ODD;
// break;
// case 2:
// handle->Init.Parity = UART_PARITY_EVEN;
// break;
// default:
// handle->Init.Parity = UART_PARITY_NONE;
// break;
// }
//
// /*set the data type : only 8bits and 9bits is supported */
// switch (Line_Coding[cdc_ch].datatype)
// {
// case 0x07:
// /* With this configuration a parity (Even or Odd) must be set */
// handle->Init.WordLength = UART_WORDLENGTH_8B;
// break;
// case 0x08:
// if (handle->Init.Parity == UART_PARITY_NONE)
// {
// handle->Init.WordLength = UART_WORDLENGTH_8B;
// }
// else
// {
// handle->Init.WordLength = UART_WORDLENGTH_9B;
// }
//
// break;
// default:
// handle->Init.WordLength = UART_WORDLENGTH_8B;
// break;
// }
//
// if (Line_Coding[cdc_ch].bitrate == 0)
// {
// Line_Coding[cdc_ch].bitrate = 115200;
// }
//
// handle->Init.BaudRate = Line_Coding[cdc_ch].bitrate;
// handle->Init.HwFlowCtl = UART_HWCONTROL_NONE;
// handle->Init.Mode = UART_MODE_TX_RX;
// handle->Init.OverSampling = UART_OVERSAMPLING_16;
//
// if (HAL_UART_Init(handle) != HAL_OK)
// {
// /* Initialization Error */
// Error_Handler();
// }
//
// /** rx for uart and tx buffer of usb */
// if (HAL_UART_Receive_IT(handle, TX_Buffer[cdc_ch], 1) != HAL_OK)
// {
// /* Transfer error in reception process */
// Error_Handler();
// }
//}
/* USER CODE END PRIVATE_FUNCTIONS_DECLARATION */
/**
* @}
*/
USBD_CDC_ACM_ItfTypeDef USBD_CDC_ACM_fops = {CDC_Init,
CDC_DeInit,
CDC_Control,
CDC_Receive,
CDC_TransmitCplt};
/* Private functions ---------------------------------------------------------*/
/**
* @brief Initializes the CDC media low layer over the FS USB IP
* @retval USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t CDC_Init(uint8_t cdc_ch)
{
/* USER CODE BEGIN 3 */
/* ##-1- Set Application Buffers */
USBD_CDC_SetRxBuffer(cdc_ch, &hUsbDevice, RX_Buffer[cdc_ch]);
// /*##-2- Start the TIM Base generation in interrupt mode ####################*/
// /* Start Channel1 */
// if (HAL_TIM_Base_Start_IT(&htim4) != HAL_OK)
// {
// /* Starting Error */
// Error_Handler();
// }
return (USBD_OK);
/* USER CODE END 3 */
}
/**
* @brief DeInitializes the CDC media low layer
* @retval USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t CDC_DeInit(uint8_t cdc_ch)
{
/* USER CODE BEGIN 4 */
/* DeInitialize the UART peripheral */
// if (HAL_UART_DeInit(CDC_CH_To_UART_Handle(cdc_ch)) != HAL_OK)
// {
// /* Initialization Error */
// Error_Handler();
// }
return (USBD_OK);
/* USER CODE END 4 */
}
/**
* @brief Manage the CDC class requests
* @param cmd: Command code
* @param pbuf: Buffer containing command data (request parameters)
* @param length: Number of data to be sent (in bytes)
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t CDC_Control(uint8_t cdc_ch, uint8_t cmd, uint8_t *pbuf, uint16_t length)
{
/* USER CODE BEGIN 5 */
switch (cmd)
{
case CDC_SEND_ENCAPSULATED_COMMAND:
break;
case CDC_GET_ENCAPSULATED_RESPONSE:
break;
case CDC_SET_COMM_FEATURE:
break;
case CDC_GET_COMM_FEATURE:
break;
case CDC_CLEAR_COMM_FEATURE:
break;
/*******************************************************************************/
/* Line Coding Structure */
/*-----------------------------------------------------------------------------*/
/* Offset | Field | Size | Value | Description */
/* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/
/* 4 | bCharFormat | 1 | Number | Stop bits */
/* 0 - 1 Stop bit */
/* 1 - 1.5 Stop bits */
/* 2 - 2 Stop bits */
/* 5 | bParityType | 1 | Number | Parity */
/* 0 - None */
/* 1 - Odd */
/* 2 - Even */
/* 3 - Mark */
/* 4 - Space */
/* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */
/*******************************************************************************/
case CDC_SET_LINE_CODING:
Line_Coding[cdc_ch].bitrate = (uint32_t)(pbuf[0] | (pbuf[1] << 8) |
(pbuf[2] << 16) | (pbuf[3] << 24));
Line_Coding[cdc_ch].format = pbuf[4];
Line_Coding[cdc_ch].paritytype = pbuf[5];
Line_Coding[cdc_ch].datatype = pbuf[6];
//Change_UART_Setting(cdc_ch);
break;
case CDC_GET_LINE_CODING:
pbuf[0] = (uint8_t)(Line_Coding[cdc_ch].bitrate);
pbuf[1] = (uint8_t)(Line_Coding[cdc_ch].bitrate >> 8);
pbuf[2] = (uint8_t)(Line_Coding[cdc_ch].bitrate >> 16);
pbuf[3] = (uint8_t)(Line_Coding[cdc_ch].bitrate >> 24);
pbuf[4] = Line_Coding[cdc_ch].format;
pbuf[5] = Line_Coding[cdc_ch].paritytype;
pbuf[6] = Line_Coding[cdc_ch].datatype;
break;
case CDC_SET_CONTROL_LINE_STATE:
break;
case CDC_SEND_BREAK:
break;
default:
break;
}
return (USBD_OK);
/* USER CODE END 5 */
}
/**
* @brief Data received over USB OUT endpoint are sent over CDC interface
* through this function.
*
* @note
* This function will issue a NAK packet on any OUT packet received on
* USB endpoint until exiting this function. If you exit this function
* before transfer is complete on CDC interface (ie. using DMA controller)
* it will result in receiving more data while previous ones are still
* not sent.
*
* @param Buf: Buffer of data to be received
* @param Len: Number of data received (in bytes)
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t CDC_Receive(uint8_t cdc_ch, uint8_t *Buf, uint32_t *Len)
{
/* USER CODE BEGIN 6 */
//HAL_UART_Transmit_DMA(CDC_CH_To_UART_Handle(cdc_ch), Buf, *Len);
CDC_Transmit(cdc_ch, Buf, *Len); // echo back on same channel
USBD_CDC_SetRxBuffer(cdc_ch, &hUsbDevice, &Buf[0]);
USBD_CDC_ReceivePacket(cdc_ch, &hUsbDevice);
return (USBD_OK);
/* USER CODE END 6 */
}
/**
* @brief CDC_TransmitCplt_FS
* Data transmited callback
*
* @note
* This function is IN transfer complete callback used to inform user that
* the submitted Data is successfully sent over USB.
*
* @param Buf: Buffer of data to be received
* @param Len: Number of data received (in bytes)
* @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
*/
static int8_t CDC_TransmitCplt(uint8_t cdc_ch, uint8_t *Buf, uint32_t *Len, uint8_t epnum)
{
return (USBD_OK);
}
/**
* @brief CDC_Transmit
* Data to send over USB IN endpoint are sent over CDC interface
* through this function.
* @note
*
*
* @param Buf: Buffer of data to be sent
* @param Len: Number of data to be sent (in bytes)
* @retval USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY
*/
uint8_t CDC_Transmit(uint8_t ch, uint8_t *Buf, uint16_t Len)
{
uint8_t result = USBD_OK;
/* USER CODE BEGIN 7 */
extern USBD_CDC_ACM_HandleTypeDef CDC_ACM_Class_Data[];
USBD_CDC_ACM_HandleTypeDef *hcdc = NULL;
hcdc = &CDC_ACM_Class_Data[ch];
if (hcdc->TxState != 0)
{
return USBD_BUSY;
}
USBD_CDC_SetTxBuffer(ch, &hUsbDevice, Buf, Len);
result = USBD_CDC_TransmitPacket(ch, &hUsbDevice);
/* USER CODE END 7 */
return result;
}
/* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */
//void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
//{
// /* Initiate next USB packet transfer once UART completes transfer (transmitting data over Tx line) */
// //USBD_CDC_ReceivePacket(UART_Handle_TO_CDC_CH(huart), &hUsbDevice);
//}
//void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
//{
// for (uint8_t i = 0; i < NUMBER_OF_CDC; i++)
// {
// uint32_t buffptr;
// uint32_t buffsize;
//
// if (Read_Index[i] != Write_Index[i])
// {
// if (Read_Index[i] > Write_Index[i]) /* Rollback */
// {
// buffsize = APP_TX_DATA_SIZE - Read_Index[i];
// }
// else
// {
// buffsize = Write_Index[i] - Read_Index[i];
// }
//
// buffptr = Read_Index[i];
//
// USBD_CDC_SetTxBuffer(i, &hUsbDevice, &TX_Buffer[i][buffptr], buffsize);
//
// if (USBD_CDC_TransmitPacket(i, &hUsbDevice) == USBD_OK)
// {
// Read_Index[i] += buffsize;
// if (Read_Index[i] == APP_RX_DATA_SIZE)
// {
// Read_Index[i] = 0;
// }
// }
// }
// }
//}
//void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
//{
// uint8_t cdc_ch = UART_Handle_TO_CDC_CH(huart);
// /* Increment Index for buffer writing */
// Write_Index[cdc_ch]++;
//
// /* To avoid buffer overflow */
// if (Write_Index[cdc_ch] == APP_RX_DATA_SIZE)
// {
// Write_Index[cdc_ch] = 0;
// }
//
// /* Start another reception: provide the buffer pointer with offset and the buffer size */
// HAL_UART_Receive_IT(huart, (TX_Buffer[cdc_ch] + Write_Index[cdc_ch]), 1);
//}
/* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -0,0 +1,130 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : usbd_cdc_acm_if.h
* @version : v2.0_Cube
* @brief : Header for usbd_cdc_if.c file.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_CDC_ACM_IF_H__
#define __USBD_CDC_ACM_IF_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_cdc_acm.h"
/* USER CODE BEGIN INCLUDE */
/* USER CODE END INCLUDE */
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
* @brief For Usb device.
* @{
*/
/** @defgroup USBD_CDC_IF USBD_CDC_IF
* @brief Usb VCP device module
* @{
*/
/** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines
* @brief Defines.
* @{
*/
/* USER CODE BEGIN EXPORTED_DEFINES */
/* USER CODE END EXPORTED_DEFINES */
/**
* @}
*/
/** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types
* @brief Types.
* @{
*/
/* USER CODE BEGIN EXPORTED_TYPES */
/* USER CODE END EXPORTED_TYPES */
/**
* @}
*/
/** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros
* @brief Aliases.
* @{
*/
/* USER CODE BEGIN EXPORTED_MACRO */
/* USER CODE END EXPORTED_MACRO */
/**
* @}
*/
/** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables
* @brief Public variables.
* @{
*/
/** CDC Interface callback. */
extern USBD_CDC_ACM_ItfTypeDef USBD_CDC_ACM_fops;
/* USER CODE BEGIN EXPORTED_VARIABLES */
/* USER CODE END EXPORTED_VARIABLES */
/**
* @}
*/
/** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype
* @brief Public functions declaration.
* @{
*/
uint8_t CDC_Transmit(uint8_t ch, uint8_t* Buf, uint16_t Len);
/* USER CODE BEGIN EXPORTED_FUNCTIONS */
/* USER CODE END EXPORTED_FUNCTIONS */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __USBD_CDC_ACM_IF_TEMPLATE_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,445 +1,412 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN Header */
/** /**
****************************************************************************** ******************************************************************************
* @file : App/usbd_desc.c * @file : App/usbd_desc.c
* @version : v2.0_Cube * @version : v1.0_Cube
* @brief : This file implements the USB device descriptors. * @brief : This file implements the USB device descriptors.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2024 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
/* USER CODE END Header */ */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "usbd_core.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_desc.h" #include "usbd_core.h"
#include "usbd_conf.h" #include "usbd_desc.h"
#include "usbd_conf.h"
/* USER CODE BEGIN INCLUDE */
/* USER CODE BEGIN INCLUDE */
/* USER CODE END INCLUDE */ #include "usbd_composite.h"
/* USER CODE END INCLUDE */
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
/* USER CODE END PV */
/* USER CODE END PV */
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
* @{ /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
*/ * @{
*/
/** @addtogroup USBD_DESC
* @{ /** @addtogroup USBD_DESC
*/ * @{
*/
/** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions
* @brief Private types. /** @defgroup USBD_DESC_Private_TypesDefinitions USBD_DESC_Private_TypesDefinitions
* @{ * @brief Private types.
*/ * @{
*/
/* USER CODE BEGIN PRIVATE_TYPES */
/* USER CODE BEGIN PRIVATE_TYPES */
/* USER CODE END PRIVATE_TYPES */
/* USER CODE END PRIVATE_TYPES */
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines
* @brief Private defines. /** @defgroup USBD_DESC_Private_Defines USBD_DESC_Private_Defines
* @{ * @brief Private defines.
*/ * @{
*/
#define USBD_VID 1155
#define USBD_LANGID_STRING 1033 #define USBD_VID 1155
#define USBD_MANUFACTURER_STRING "STMicroelectronics" #define USBD_LANGID_STRING 1033
#define USBD_PID_FS 22314 #define USBD_MANUFACTURER_STRING "STMicroelectronics"
#define USBD_PRODUCT_STRING_FS "STM32 Mass Storage" #if (USBD_USE_DFU == 1)
#define USBD_CONFIGURATION_STRING_FS "MSC Config" #define USBD_PID 57105 // for DFU PID must be 57105, ST proprietary modification
#define USBD_INTERFACE_STRING_FS "MSC Interface" #else
#define USBD_PID 21156
#define USB_SIZ_BOS_DESC 0x0C #endif
#define USBD_PRODUCT_STRING "STM32 COMPOSITE DEVICE"
/* USER CODE BEGIN PRIVATE_DEFINES */ #define USBD_CONFIGURATION_STRING "CONFIGURATION 0"
#define USBD_INTERFACE_STRING "COMPOSITE INTERFACE"
/* USER CODE END PRIVATE_DEFINES */
/* USER CODE BEGIN PRIVATE_DEFINES */
/**
* @} /* USER CODE END PRIVATE_DEFINES */
*/
/**
/* USER CODE BEGIN 0 */ * @}
*/
/* USER CODE END 0 */
/* USER CODE BEGIN 0 */
/** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros
* @brief Private macros. /* USER CODE END 0 */
* @{
*/ /** @defgroup USBD_DESC_Private_Macros USBD_DESC_Private_Macros
* @brief Private macros.
/* USER CODE BEGIN PRIVATE_MACRO */ * @{
*/
/* USER CODE END PRIVATE_MACRO */
/* USER CODE BEGIN PRIVATE_MACRO */
/**
* @} /* USER CODE END PRIVATE_MACRO */
*/
/**
/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes * @}
* @brief Private functions declaration. */
* @{
*/ /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
* @brief Private functions declaration.
static void Get_SerialNum(void); * @{
static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len); */
/** static void Get_SerialNum(void);
* @} static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len);
*/
/**
/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes * @}
* @brief Private functions declaration for FS. */
* @{
*/ /** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
* @brief Private functions declaration for HS.
uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); * @{
uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); */
uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); uint8_t * USBD_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); uint8_t * USBD_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); uint8_t * USBD_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); uint8_t * USBD_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
#if (USBD_LPM_ENABLED == 1) uint8_t * USBD_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length); uint8_t * USBD_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
#endif /* (USBD_LPM_ENABLED == 1) */ uint8_t * USBD_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
/** /**
* @} * @}
*/ */
/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables /** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables
* @brief Private variables. * @brief Private variables.
* @{ * @{
*/ */
USBD_DescriptorsTypeDef FS_Desc = USBD_DescriptorsTypeDef USBD_Desc =
{ {
USBD_FS_DeviceDescriptor USBD_DeviceDescriptor
, USBD_FS_LangIDStrDescriptor , USBD_LangIDStrDescriptor
, USBD_FS_ManufacturerStrDescriptor , USBD_ManufacturerStrDescriptor
, USBD_FS_ProductStrDescriptor , USBD_ProductStrDescriptor
, USBD_FS_SerialStrDescriptor , USBD_SerialStrDescriptor
, USBD_FS_ConfigStrDescriptor , USBD_ConfigStrDescriptor
, USBD_FS_InterfaceStrDescriptor , USBD_InterfaceStrDescriptor
#if (USBD_LPM_ENABLED == 1) };
, USBD_FS_USR_BOSDescriptor
#endif /* (USBD_LPM_ENABLED == 1) */ #if defined ( __ICCARM__ ) /* IAR Compiler */
}; #pragma data_alignment=4
#endif /* defined ( __ICCARM__ ) */
#if defined ( __ICCARM__ ) /* IAR Compiler */ /** USB standard device descriptor. */
#pragma data_alignment=4 __ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END =
#endif /* defined ( __ICCARM__ ) */ {
/** USB standard device descriptor. */ 0x12, /*bLength */
__ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END = USB_DESC_TYPE_DEVICE, /*bDescriptorType*/
{ 0x00, /*bcdUSB */
0x12, /*bLength */ 0x02,
USB_DESC_TYPE_DEVICE, /*bDescriptorType*/ 0xEF, /*bDeviceClass*/
#if (USBD_LPM_ENABLED == 1) 0x02, /*bDeviceSubClass*/
0x01, /*bcdUSB */ /* changed to USB version 2.01 0x01, /*bDeviceProtocol*/
in order to support LPM L1 suspend USB_MAX_EP0_SIZE, /*bMaxPacketSize*/
resume test of USBCV3.0*/ LOBYTE(USBD_VID), /*idVendor*/
#else HIBYTE(USBD_VID), /*idVendor*/
0x00, /*bcdUSB */ LOBYTE(USBD_PID), /*idProduct*/
#endif /* (USBD_LPM_ENABLED == 1) */ HIBYTE(USBD_PID), /*idProduct*/
0x02, 0x00, /*bcdDevice rel. 2.00*/
0x00, /*bDeviceClass*/ 0x02,
0x00, /*bDeviceSubClass*/ USBD_IDX_MFC_STR, /*Index of manufacturer string*/
0x00, /*bDeviceProtocol*/ USBD_IDX_PRODUCT_STR, /*Index of product string*/
USB_MAX_EP0_SIZE, /*bMaxPacketSize*/ USBD_IDX_SERIAL_STR, /*Index of serial number string*/
LOBYTE(USBD_VID), /*idVendor*/ USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/
HIBYTE(USBD_VID), /*idVendor*/ };
LOBYTE(USBD_PID_FS), /*idProduct*/
HIBYTE(USBD_PID_FS), /*idProduct*/ /**
0x00, /*bcdDevice rel. 2.00*/ * @}
0x02, */
USBD_IDX_MFC_STR, /*Index of manufacturer string*/
USBD_IDX_PRODUCT_STR, /*Index of product string*/ /** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables
USBD_IDX_SERIAL_STR, /*Index of serial number string*/ * @brief Private variables.
USBD_MAX_NUM_CONFIGURATION /*bNumConfigurations*/ * @{
}; */
/* USB_DeviceDescriptor */ #if defined ( __ICCARM__ ) /* IAR Compiler */
/** BOS descriptor. */ #pragma data_alignment=4
#if (USBD_LPM_ENABLED == 1) #endif /* defined ( __ICCARM__ ) */
#if defined ( __ICCARM__ ) /* IAR Compiler */
#pragma data_alignment=4 /** USB lang indentifier descriptor. */
#endif /* defined ( __ICCARM__ ) */ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END =
__ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END = {
{ USB_LEN_LANGID_STR_DESC,
0x5, USB_DESC_TYPE_STRING,
USB_DESC_TYPE_BOS, LOBYTE(USBD_LANGID_STRING),
0xC, HIBYTE(USBD_LANGID_STRING)
0x0, };
0x1, /* 1 device capability*/
/* device capability*/ #if defined ( __ICCARM__ ) /* IAR Compiler */
0x7, #pragma data_alignment=4
USB_DEVICE_CAPABITY_TYPE, #endif /* defined ( __ICCARM__ ) */
0x2, /* Internal string descriptor. */
0x2, /* LPM capability bit set*/ __ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END;
0x0,
0x0, #if defined ( __ICCARM__ ) /*!< IAR Compiler */
0x0 #pragma data_alignment=4
}; #endif
#endif /* (USBD_LPM_ENABLED == 1) */ __ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = {
USB_SIZ_STRING_SERIAL,
/** USB_DESC_TYPE_STRING,
* @} };
*/
/**
/** @defgroup USBD_DESC_Private_Variables USBD_DESC_Private_Variables * @}
* @brief Private variables. */
* @{
*/ /** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions
* @brief Private functions.
#if defined ( __ICCARM__ ) /* IAR Compiler */ * @{
#pragma data_alignment=4 */
#endif /* defined ( __ICCARM__ ) */
/**
/** USB lang identifier descriptor. */ * @brief Return the device descriptor
__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END = * @param speed : Current device speed
{ * @param length : Pointer to data length variable
USB_LEN_LANGID_STR_DESC, * @retval Pointer to descriptor buffer
USB_DESC_TYPE_STRING, */
LOBYTE(USBD_LANGID_STRING), uint8_t * USBD_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
HIBYTE(USBD_LANGID_STRING) {
}; UNUSED(speed);
*length = sizeof(USBD_DeviceDesc);
#if defined ( __ICCARM__ ) /* IAR Compiler */ return USBD_DeviceDesc;
#pragma data_alignment=4 }
#endif /* defined ( __ICCARM__ ) */
/* Internal string descriptor. */ /**
__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END; * @brief Return the LangID string descriptor
* @param speed : Current device speed
#if defined ( __ICCARM__ ) /*!< IAR Compiler */ * @param length : Pointer to data length variable
#pragma data_alignment=4 * @retval Pointer to descriptor buffer
#endif */
__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = { uint8_t * USBD_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
USB_SIZ_STRING_SERIAL, {
USB_DESC_TYPE_STRING, UNUSED(speed);
}; *length = sizeof(USBD_LangIDDesc);
return USBD_LangIDDesc;
/** }
* @}
*/ /**
* @brief Return the product string descriptor
/** @defgroup USBD_DESC_Private_Functions USBD_DESC_Private_Functions * @param speed : current device speed
* @brief Private functions. * @param length : pointer to data length variable
* @{ * @retval pointer to descriptor buffer
*/ */
uint8_t * USBD_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
/** {
* @brief Return the device descriptor if(speed == 0)
* @param speed : Current device speed {
* @param length : Pointer to data length variable USBD_GetString((uint8_t *)USBD_PRODUCT_STRING, USBD_StrDesc, length);
* @retval Pointer to descriptor buffer }
*/ else
uint8_t * USBD_FS_DeviceDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) {
{ USBD_GetString((uint8_t *)USBD_PRODUCT_STRING, USBD_StrDesc, length);
UNUSED(speed); }
*length = sizeof(USBD_FS_DeviceDesc); return USBD_StrDesc;
return USBD_FS_DeviceDesc; }
}
/**
/** * @brief Return the manufacturer string descriptor
* @brief Return the LangID string descriptor * @param speed : Current device speed
* @param speed : Current device speed * @param length : Pointer to data length variable
* @param length : Pointer to data length variable * @retval Pointer to descriptor buffer
* @retval Pointer to descriptor buffer */
*/ uint8_t * USBD_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
uint8_t * USBD_FS_LangIDStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) {
{ UNUSED(speed);
UNUSED(speed); USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length);
*length = sizeof(USBD_LangIDDesc); return USBD_StrDesc;
return USBD_LangIDDesc; }
}
/**
/** * @brief Return the serial number string descriptor
* @brief Return the product string descriptor * @param speed : Current device speed
* @param speed : Current device speed * @param length : Pointer to data length variable
* @param length : Pointer to data length variable * @retval Pointer to descriptor buffer
* @retval Pointer to descriptor buffer */
*/ uint8_t * USBD_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
uint8_t * USBD_FS_ProductStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) {
{ UNUSED(speed);
if(speed == 0) *length = USB_SIZ_STRING_SERIAL;
{
USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length); /* Update the serial number string descriptor with the data from the unique
} * ID */
else Get_SerialNum();
{ /* USER CODE BEGIN USBD_SerialStrDescriptor */
USBD_GetString((uint8_t *)USBD_PRODUCT_STRING_FS, USBD_StrDesc, length);
} /* USER CODE END USBD_SerialStrDescriptor */
return USBD_StrDesc;
} return (uint8_t *) USBD_StringSerial;
}
/**
* @brief Return the manufacturer string descriptor /**
* @param speed : Current device speed * @brief Return the configuration string descriptor
* @param length : Pointer to data length variable * @param speed : Current device speed
* @retval Pointer to descriptor buffer * @param length : Pointer to data length variable
*/ * @retval Pointer to descriptor buffer
uint8_t * USBD_FS_ManufacturerStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) */
{ uint8_t * USBD_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
UNUSED(speed); {
USBD_GetString((uint8_t *)USBD_MANUFACTURER_STRING, USBD_StrDesc, length); if(speed == USBD_SPEED_HIGH)
return USBD_StrDesc; {
} USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING, USBD_StrDesc, length);
}
/** else
* @brief Return the serial number string descriptor {
* @param speed : Current device speed USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING, USBD_StrDesc, length);
* @param length : Pointer to data length variable }
* @retval Pointer to descriptor buffer return USBD_StrDesc;
*/ }
uint8_t * USBD_FS_SerialStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
{ /**
UNUSED(speed); * @brief Return the interface string descriptor
*length = USB_SIZ_STRING_SERIAL; * @param speed : Current device speed
* @param length : Pointer to data length variable
/* Update the serial number string descriptor with the data from the unique * @retval Pointer to descriptor buffer
* ID */ */
Get_SerialNum(); uint8_t * USBD_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
/* USER CODE BEGIN USBD_FS_SerialStrDescriptor */ {
if(speed == 0)
/* USER CODE END USBD_FS_SerialStrDescriptor */ {
return (uint8_t *) USBD_StringSerial; USBD_GetString((uint8_t *)USBD_INTERFACE_STRING, USBD_StrDesc, length);
} }
else
/** {
* @brief Return the configuration string descriptor USBD_GetString((uint8_t *)USBD_INTERFACE_STRING, USBD_StrDesc, length);
* @param speed : Current device speed }
* @param length : Pointer to data length variable return USBD_StrDesc;
* @retval Pointer to descriptor buffer }
*/
uint8_t * USBD_FS_ConfigStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) #if (USBD_LPM_ENABLED == 1)
{ /**
if(speed == USBD_SPEED_HIGH) * @brief Return the BOS descriptor
{ * @param speed : Current device speed
USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); * @param length : Pointer to data length variable
} * @retval Pointer to descriptor buffer
else */
{ uint8_t * USBD_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
USBD_GetString((uint8_t *)USBD_CONFIGURATION_STRING_FS, USBD_StrDesc, length); {
} UNUSED(speed);
return USBD_StrDesc; *length = sizeof(USBD_BOSDesc);
} return (uint8_t*)USBD_BOSDesc;
}
/** #endif /* (USBD_LPM_ENABLED == 1) */
* @brief Return the interface string descriptor
* @param speed : Current device speed /**
* @param length : Pointer to data length variable * @brief Create the serial number string descriptor
* @retval Pointer to descriptor buffer * @param None
*/ * @retval None
uint8_t * USBD_FS_InterfaceStrDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) */
{ static void Get_SerialNum(void)
if(speed == 0) {
{ uint32_t deviceserial0, deviceserial1, deviceserial2;
USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length);
} deviceserial0 = *(uint32_t *) DEVICE_ID1;
else deviceserial1 = *(uint32_t *) DEVICE_ID2;
{ deviceserial2 = *(uint32_t *) DEVICE_ID3;
USBD_GetString((uint8_t *)USBD_INTERFACE_STRING_FS, USBD_StrDesc, length);
} deviceserial0 += deviceserial2;
return USBD_StrDesc;
} if (deviceserial0 != 0)
{
#if (USBD_LPM_ENABLED == 1) IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8);
/** IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4);
* @brief Return the BOS descriptor }
* @param speed : Current device speed }
* @param length : Pointer to data length variable
* @retval Pointer to descriptor buffer /**
*/ * @brief Convert Hex 32Bits value into char
uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length) * @param value: value to convert
{ * @param pbuf: pointer to the buffer
UNUSED(speed); * @param len: buffer length
*length = sizeof(USBD_FS_BOSDesc); * @retval None
return (uint8_t*)USBD_FS_BOSDesc; */
} static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len)
#endif /* (USBD_LPM_ENABLED == 1) */ {
uint8_t idx = 0;
/**
* @brief Create the serial number string descriptor for (idx = 0; idx < len; idx++)
* @param None {
* @retval None if (((value >> 28)) < 0xA)
*/ {
static void Get_SerialNum(void) pbuf[2 * idx] = (value >> 28) + '0';
{ }
uint32_t deviceserial0; else
uint32_t deviceserial1; {
uint32_t deviceserial2; pbuf[2 * idx] = (value >> 28) + 'A' - 10;
}
deviceserial0 = *(uint32_t *) DEVICE_ID1;
deviceserial1 = *(uint32_t *) DEVICE_ID2; value = value << 4;
deviceserial2 = *(uint32_t *) DEVICE_ID3;
pbuf[2 * idx + 1] = 0;
deviceserial0 += deviceserial2; }
}
if (deviceserial0 != 0) /**
{ * @}
IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8); */
IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4);
} /**
} * @}
*/
/**
* @brief Convert Hex 32Bits value into char /**
* @param value: value to convert * @}
* @param pbuf: pointer to the buffer */
* @param len: buffer length
* @retval None /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
*/
static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len)
{
uint8_t idx = 0;
for (idx = 0; idx < len; idx++)
{
if (((value >> 28)) < 0xA)
{
pbuf[2 * idx] = (value >> 28) + '0';
}
else
{
pbuf[2 * idx] = (value >> 28) + 'A' - 10;
}
value = value << 4;
pbuf[2 * idx + 1] = 0;
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/

View File

@ -1,143 +1,145 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN Header */
/** /**
****************************************************************************** ******************************************************************************
* @file : usbd_desc.c * @file : usbd_desc.c
* @version : v2.0_Cube * @version : v1.0_Cube
* @brief : Header for usbd_conf.c file. * @brief : Header for usbd_conf.c file.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2024 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
/* USER CODE END Header */ */
/* Define to prevent recursive inclusion -------------------------------------*/ /* USER CODE END Header */
#ifndef __USBD_DESC__C__ /* Define to prevent recursive inclusion -------------------------------------*/
#define __USBD_DESC__C__ #ifndef __USBD_DESC__C__
#define __USBD_DESC__C__
#ifdef __cplusplus
extern "C" { #ifdef __cplusplus
#endif extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_def.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_def.h"
/* USER CODE BEGIN INCLUDE */
/* USER CODE BEGIN INCLUDE */
/* USER CODE END INCLUDE */
/* USER CODE END INCLUDE */
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
* @{ /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
*/ * @{
*/
/** @defgroup USBD_DESC USBD_DESC
* @brief Usb device descriptors module. /** @defgroup USBD_DESC USBD_DESC
* @{ * @brief Usb device descriptors module.
*/ * @{
*/
/** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants
* @brief Constants. /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants
* @{ * @brief Constants.
*/ * @{
#define DEVICE_ID1 (UID_BASE) */
#define DEVICE_ID2 (UID_BASE + 0x4) #define DEVICE_ID1 (UID_BASE)
#define DEVICE_ID3 (UID_BASE + 0x8) #define DEVICE_ID2 (UID_BASE + 0x4)
#define DEVICE_ID3 (UID_BASE + 0x8)
#define USB_SIZ_STRING_SERIAL 0x1A
#define USB_SIZ_STRING_SERIAL 0x1A
/* USER CODE BEGIN EXPORTED_CONSTANTS */
/* USER CODE BEGIN EXPORTED_CONSTANTS */
/* USER CODE END EXPORTED_CONSTANTS */
/* USER CODE END EXPORTED_CONSTANTS */
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines
* @brief Defines. /** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines
* @{ * @brief Defines.
*/ * @{
*/
/* USER CODE BEGIN EXPORTED_DEFINES */
/* USER CODE BEGIN EXPORTED_DEFINES */
/* USER CODE END EXPORTED_DEFINES */
/* USER CODE END EXPORTED_DEFINES */
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions
* @brief Types. /** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions
* @{ * @brief Types.
*/ * @{
*/
/* USER CODE BEGIN EXPORTED_TYPES */
/* USER CODE BEGIN EXPORTED_TYPES */
/* USER CODE END EXPORTED_TYPES */
/* USER CODE END EXPORTED_TYPES */
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros
* @brief Aliases. /** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros
* @{ * @brief Aliases.
*/ * @{
*/
/* USER CODE BEGIN EXPORTED_MACRO */
/* USER CODE BEGIN EXPORTED_MACRO */
/* USER CODE END EXPORTED_MACRO */
/* USER CODE END EXPORTED_MACRO */
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables
* @brief Public variables. /** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables
* @{ * @brief Public variables.
*/ * @{
*/
/** Descriptor for the Usb device. */
extern USBD_DescriptorsTypeDef FS_Desc; /** Descriptor for the Usb device. */
extern USBD_DescriptorsTypeDef USBD_Desc;
/* USER CODE BEGIN EXPORTED_VARIABLES */
/* USER CODE BEGIN EXPORTED_VARIABLES */
/* USER CODE END EXPORTED_VARIABLES */
/* USER CODE END EXPORTED_VARIABLES */
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype
* @brief Public functions declaration. /** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype
* @{ * @brief Public functions declaration.
*/ * @{
*/
/* USER CODE BEGIN EXPORTED_FUNCTIONS */
/* USER CODE BEGIN EXPORTED_FUNCTIONS */
/* USER CODE END EXPORTED_FUNCTIONS */
/* USER CODE END EXPORTED_FUNCTIONS */
/**
* @} /**
*/ * @}
*/
/**
* @} /**
*/ * @}
*/
/**
* @} /**
*/ * @}
*/
#ifdef __cplusplus
} #ifdef __cplusplus
#endif }
#endif
#endif /* __USBD_DESC__C__ */
#endif /* __USBD_DESC__C__ */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,285 +1,279 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN Header */
/** /**
****************************************************************************** ******************************************************************************
* @file : usbd_storage_if.c * @file : usbd_storage_if.c
* @version : v2.0_Cube * @version : v1.0_Cube
* @brief : Memory management layer. * @brief : Memory management layer.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2024 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
/* USER CODE END Header */ */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "usbd_storage_if.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_msc_if.h"
/* USER CODE BEGIN INCLUDE */
/* USER CODE END INCLUDE */ /* USER CODE BEGIN INCLUDE */
/* Private typedef -----------------------------------------------------------*/ /* USER CODE END INCLUDE */
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PV */ /* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
// NOTE: USE RAW BLOCK LEVEL ACCESS FOR USB. /* Private variables ---------------------------------------------------------*/
// USE FATFS DRIVER FOR STM32 EMBEDDED ACCESS. /* USER CODE END PV */
extern MMC_HandleTypeDef hmmc1;
extern DMA_HandleTypeDef hdma_sdmmc1; /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
* @brief Usb device.
#define TIMEOUT 10 * @{
*/
/* USER CODE END PV */
/** @defgroup USBD_STORAGE
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY * @brief Usb mass storage device module
* @brief Usb device. * @{
* @{ */
*/
/** @defgroup USBD_STORAGE_Private_TypesDefinitions
/** @defgroup USBD_STORAGE * @brief Private types.
* @brief Usb mass storage device module * @{
* @{ */
*/
/* USER CODE BEGIN PRIVATE_TYPES */
/** @defgroup USBD_STORAGE_Private_TypesDefinitions
* @brief Private types. /* USER CODE END PRIVATE_TYPES */
* @{
*/ /**
* @}
/* USER CODE BEGIN PRIVATE_TYPES */ */
/* USER CODE END PRIVATE_TYPES */ /** @defgroup USBD_STORAGE_Private_Defines
* @brief Private defines.
/** * @{
* @} */
*/
#define STORAGE_LUN_NBR 1
/** @defgroup USBD_STORAGE_Private_Defines #define STORAGE_BLK_NBR 32 * 1024 / 512
* @brief Private defines. #define STORAGE_BLK_SIZ 512
* @{
*/ /* USER CODE BEGIN PRIVATE_DEFINES */
#define STORAGE_LUN_NBR 1 /* USER CODE END PRIVATE_DEFINES */
#define STORAGE_BLK_NBR 0x10000
#define STORAGE_BLK_SIZ 0x200 /**
* @}
/* USER CODE BEGIN PRIVATE_DEFINES */ */
/* USER CODE END PRIVATE_DEFINES */ /** @defgroup USBD_STORAGE_Private_Macros
* @brief Private macros.
/** * @{
* @} */
*/
/* USER CODE BEGIN PRIVATE_MACRO */
/** @defgroup USBD_STORAGE_Private_Macros extern MMC_HandleTypeDef hmmc1;
* @brief Private macros. /* USER CODE END PRIVATE_MACRO */
* @{
*/ /**
* @}
/* USER CODE BEGIN PRIVATE_MACRO */ */
/* USER CODE END PRIVATE_MACRO */ /** @defgroup USBD_STORAGE_Private_Variables
* @brief Private variables.
/** * @{
* @} */
*/
/* USER CODE BEGIN INQUIRY_DATA */
/** @defgroup USBD_STORAGE_Private_Variables /** USB Mass storage Standard Inquiry Data. */
* @brief Private variables. const int8_t STORAGE_Inquirydata[] = {
* @{ /* 36 */
*/
/* LUN 0 */
/* USER CODE BEGIN INQUIRY_DATA_FS */ 0x00,
/** USB Mass storage Standard Inquiry Data. */ 0x80,
const int8_t STORAGE_Inquirydata_FS[] = { 0x02,
/* 36 */ 0x02,
(STANDARD_INQUIRY_DATA_LEN - 5),
/* LUN 0 */ 0x00,
0x00, 0x00,
0x80, 0x00,
0x02, 'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Manufacturer : 8 bytes */
0x02, 'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */
(STANDARD_INQUIRY_DATA_LEN - 5), ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
0x00, '0', '.', '0', '1' /* Version : 4 Bytes */
0x00, };
0x00, /* USER CODE END INQUIRY_DATA */
'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Manufacturer : 8 bytes */
'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product : 16 Bytes */ /* USER CODE BEGIN PRIVATE_VARIABLES */
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
'0', '.', '0', '1' /* Version : 4 Bytes */ /* USER CODE END PRIVATE_VARIABLES */
};
/* USER CODE END INQUIRY_DATA_FS */ /**
* @}
/* USER CODE BEGIN PRIVATE_VARIABLES */ */
/* USER CODE END PRIVATE_VARIABLES */ /** @defgroup USBD_STORAGE_Exported_Variables
* @brief Public variables.
/** * @{
* @} */
*/
extern USBD_HandleTypeDef hUsbDevice;
/** @defgroup USBD_STORAGE_Exported_Variables
* @brief Public variables. /* USER CODE BEGIN EXPORTED_VARIABLES */
* @{
*/ /* USER CODE END EXPORTED_VARIABLES */
extern USBD_HandleTypeDef hUsbDeviceFS; /**
* @}
/* USER CODE BEGIN EXPORTED_VARIABLES */ */
extern volatile uint8_t mmc_transaction_blks_left;
/* USER CODE END EXPORTED_VARIABLES */ /** @defgroup USBD_STORAGE_Private_FunctionPrototypes
* @brief Private functions declaration.
/** * @{
* @} */
*/
static int8_t STORAGE_Init(uint8_t lun);
/** @defgroup USBD_STORAGE_Private_FunctionPrototypes static int8_t STORAGE_GetCapacity(uint8_t lun, uint32_t *block_num, uint16_t *block_size);
* @brief Private functions declaration. static int8_t STORAGE_IsReady(uint8_t lun);
* @{ static int8_t STORAGE_IsWriteProtected(uint8_t lun);
*/ static int8_t STORAGE_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
static int8_t STORAGE_Write(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
static int8_t STORAGE_Init_FS(uint8_t lun); static int8_t STORAGE_GetMaxLun(void);
static int8_t STORAGE_GetCapacity_FS(uint8_t lun, uint32_t *block_num, uint16_t *block_size);
static int8_t STORAGE_IsReady_FS(uint8_t lun); /* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */
static int8_t STORAGE_IsWriteProtected_FS(uint8_t lun);
static int8_t STORAGE_Read_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len); /* USER CODE END PRIVATE_FUNCTIONS_DECLARATION */
static int8_t STORAGE_Write_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
static int8_t STORAGE_GetMaxLun_FS(void); /**
* @}
/* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */ */
/* USER CODE END PRIVATE_FUNCTIONS_DECLARATION */ USBD_StorageTypeDef USBD_Storage_Interface_fops =
{
/** STORAGE_Init,
* @} STORAGE_GetCapacity,
*/ STORAGE_IsReady,
STORAGE_IsWriteProtected,
USBD_StorageTypeDef USBD_Storage_Interface_fops_FS = STORAGE_Read,
{ STORAGE_Write,
STORAGE_Init_FS, STORAGE_GetMaxLun,
STORAGE_GetCapacity_FS, (int8_t *)STORAGE_Inquirydata};
STORAGE_IsReady_FS,
STORAGE_IsWriteProtected_FS, /* Private functions ---------------------------------------------------------*/
STORAGE_Read_FS, /**
STORAGE_Write_FS, * @brief Initializes over USB FS IP
STORAGE_GetMaxLun_FS, * @param lun:
(int8_t *)STORAGE_Inquirydata_FS * @retval USBD_OK if all operations are OK else USBD_FAIL
}; */
int8_t STORAGE_Init(uint8_t lun)
/* Private functions ---------------------------------------------------------*/ {
/** /* USER CODE BEGIN 2 */
* @brief Initializes over USB FS IP // ALREADY INITIALIZED IN `MX_SDMMC1_MMC_Init` FUNCTION.
* @param lun: return USBD_OK;
* @retval USBD_OK if all operations are OK else USBD_FAIL /* USER CODE END 2 */
*/ }
int8_t STORAGE_Init_FS(uint8_t lun)
{ /**
/* USER CODE BEGIN 2 */ * @brief .
// ALREADY INITIALIZED IN `MX_SDMMC1_MMC_Init` FUNCTION. * @param lun: .
return USBD_OK; * @param block_num: .
/* USER CODE END 2 */ * @param block_size: .
} * @retval USBD_OK if all operations are OK else USBD_FAIL
*/
/** int8_t STORAGE_GetCapacity(uint8_t lun, uint32_t *block_num, uint16_t *block_size)
* @brief . {
* @param lun: . /* USER CODE BEGIN 3 */
* @param block_num: . HAL_MMC_CardInfoTypeDef card_info;
* @param block_size: . HAL_StatusTypeDef status = HAL_MMC_GetCardInfo(&hmmc1, &card_info);
* @retval USBD_OK if all operations are OK else USBD_FAIL *block_num = card_info.LogBlockNbr - 1;
*/ *block_size = card_info.LogBlockSize;
int8_t STORAGE_GetCapacity_FS(uint8_t lun, uint32_t *block_num, uint16_t *block_size) return status;
{ /* USER CODE END 3 */
/* USER CODE BEGIN 3 */ }
HAL_MMC_CardInfoTypeDef card_info;
HAL_StatusTypeDef status = HAL_MMC_GetCardInfo(&hmmc1, &card_info); /**
*block_num = card_info.LogBlockNbr - 1; * @brief .
*block_size = card_info.LogBlockSize; * @param lun: .
return status; * @retval USBD_OK if all operations are OK else USBD_FAIL
/* USER CODE END 3 */ */
} int8_t STORAGE_IsReady(uint8_t lun)
{
/** /* USER CODE BEGIN 4 */
* @brief . // if (HAL_MMC_GetState(&hmmc1) == HAL_MMC_STATE_BUSY || HAL_MMC_GetCardState(&hmmc1) != HAL_MMC_CARD_TRANSFER)
* @param lun: . // return USBD_FAIL;
* @retval USBD_OK if all operations are OK else USBD_FAIL return USBD_OK;
*/ /* USER CODE END 4 */
int8_t STORAGE_IsReady_FS(uint8_t lun) }
{
/* USER CODE BEGIN 4 */ /**
// if (HAL_MMC_GetState(&hmmc1) == HAL_MMC_STATE_BUSY || HAL_MMC_GetCardState(&hmmc1) != HAL_MMC_CARD_TRANSFER) * @brief .
// return USBD_FAIL; * @param lun: .
return USBD_OK; * @retval USBD_OK if all operations are OK else USBD_FAIL
/* USER CODE END 4 */ */
} int8_t STORAGE_IsWriteProtected(uint8_t lun)
{
/** /* USER CODE BEGIN 5 */
* @brief . // ASSUME eMMC IS NEVER WRITE PROTECTED ON THIS PARTICULAR BOARD
* @param lun: . // WRITE PROTECT FEATURE IS NOT USED.
* @retval USBD_OK if all operations are OK else USBD_FAIL return USBD_OK;
*/ /* USER CODE END 5 */
int8_t STORAGE_IsWriteProtected_FS(uint8_t lun) }
{
/* USER CODE BEGIN 5 */ /**
// ASSUME eMMC IS NEVER WRITE PROTECTED ON THIS PARTICULAR BOARD * @brief .
// WRITE PROTECT FEATURE IS NOT USED. * @param lun: .
return USBD_OK; * @retval USBD_OK if all operations are OK else USBD_FAIL
/* USER CODE END 5 */ */
} int8_t STORAGE_Read(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)
{
/** /* USER CODE BEGIN 6 */
* @brief . return MMC_read_blocks(buf, blk_addr, blk_len) == HAL_OK ? USBD_OK : USBD_FAIL;
* @param lun: . /* USER CODE END 6 */
* @retval USBD_OK if all operations are OK else USBD_FAIL }
*/
int8_t STORAGE_Read_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) /**
{ * @brief .
/* USER CODE BEGIN 6 */ * @param lun: .
return MMC_read_blocks(buf, blk_addr, blk_len) == HAL_OK ? USBD_OK : USBD_FAIL; * @retval USBD_OK if all operations are OK else USBD_FAIL
/* USER CODE END 6 */ */
} int8_t STORAGE_Write(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len)
{
/** /* USER CODE BEGIN 7 */
* @brief . return MMC_write_blocks(buf, blk_addr, blk_len) == HAL_OK ? USBD_OK : USBD_FAIL;
* @param lun: . /* USER CODE END 7 */
* @retval USBD_OK if all operations are OK else USBD_FAIL }
*/
int8_t STORAGE_Write_FS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) /**
{ * @brief .
/* USER CODE BEGIN 7 */ * @param None
return MMC_write_blocks(buf, blk_addr, blk_len) == HAL_OK ? USBD_OK : USBD_FAIL; * @retval .
/* USER CODE END 7 */ */
} int8_t STORAGE_GetMaxLun(void)
{
/** /* USER CODE BEGIN 8 */
* @brief . return (STORAGE_LUN_NBR - 1);
* @param None /* USER CODE END 8 */
* @retval . }
*/
int8_t STORAGE_GetMaxLun_FS(void) /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */
{
/* USER CODE BEGIN 8 */ /* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */
return STORAGE_LUN_NBR - 1;
/* USER CODE END 8 */ /**
} * @}
*/
/* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */
/**
/* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */ * @}
*/
/**
* @} /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
*/
/**
* @}
*/

View File

@ -1,127 +1,129 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN Header */
/** /**
****************************************************************************** ******************************************************************************
* @file : usbd_storage_if.h * @file : usbd_storage_if.h
* @version : v2.0_Cube * @version : v1.0_Cube
* @brief : Header for usbd_storage_if.c file. * @brief : Header for usbd_storage_if.c file.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2024 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
/* USER CODE END Header */ */
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_STORAGE_IF_H__ /* Define to prevent recursive inclusion -------------------------------------*/
#define __USBD_STORAGE_IF_H__ #ifndef __USBD_MSC_STORAGE_IF_H__
#define __USBD_MSC_STORAGE_IF_H__
#ifdef __cplusplus
extern "C" { #ifdef __cplusplus
#endif extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_msc.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_msc.h"
/* USER CODE BEGIN INCLUDE */
/* USER CODE BEGIN INCLUDE */
/* USER CODE END INCLUDE */
/* USER CODE END INCLUDE */
/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
* @brief For Usb device. /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
* @{ * @brief For Usb device.
*/ * @{
*/
/** @defgroup USBD_STORAGE USBD_STORAGE
* @brief Header file for the usb_storage_if.c file /** @defgroup USBD_STORAGE USBD_STORAGE
* @{ * @brief Header file for the usb_storage_if.c file
*/ * @{
*/
/** @defgroup USBD_STORAGE_Exported_Defines USBD_STORAGE_Exported_Defines
* @brief Defines. /** @defgroup USBD_STORAGE_Exported_Defines USBD_STORAGE_Exported_Defines
* @{ * @brief Defines.
*/ * @{
*/
/* USER CODE BEGIN EXPORTED_DEFINES */
/* USER CODE BEGIN EXPORTED_DEFINES */
/* USER CODE END EXPORTED_DEFINES */
/* USER CODE END EXPORTED_DEFINES */
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_STORAGE_Exported_Types USBD_STORAGE_Exported_Types
* @brief Types. /** @defgroup USBD_STORAGE_Exported_Types USBD_STORAGE_Exported_Types
* @{ * @brief Types.
*/ * @{
*/
/* USER CODE BEGIN EXPORTED_TYPES */
/* USER CODE BEGIN EXPORTED_TYPES */
/* USER CODE END EXPORTED_TYPES */
/* USER CODE END EXPORTED_TYPES */
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_STORAGE_Exported_Macros USBD_STORAGE_Exported_Macros
* @brief Aliases. /** @defgroup USBD_STORAGE_Exported_Macros USBD_STORAGE_Exported_Macros
* @{ * @brief Aliases.
*/ * @{
*/
/* USER CODE BEGIN EXPORTED_MACRO */
/* USER CODE BEGIN EXPORTED_MACRO */
/* USER CODE END EXPORTED_MACRO */
/* USER CODE END EXPORTED_MACRO */
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_STORAGE_Exported_Variables USBD_STORAGE_Exported_Variables
* @brief Public variables. /** @defgroup USBD_STORAGE_Exported_Variables USBD_STORAGE_Exported_Variables
* @{ * @brief Public variables.
*/ * @{
*/
/** STORAGE Interface callback. */
extern USBD_StorageTypeDef USBD_Storage_Interface_fops_FS; /** STORAGE Interface callback. */
extern USBD_StorageTypeDef USBD_Storage_Interface_fops;
/* USER CODE BEGIN EXPORTED_VARIABLES */
/* USER CODE BEGIN EXPORTED_VARIABLES */
/* USER CODE END EXPORTED_VARIABLES */
/* USER CODE END EXPORTED_VARIABLES */
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_STORAGE_Exported_FunctionsPrototype USBD_STORAGE_Exported_FunctionsPrototype
* @brief Public functions declaration. /** @defgroup USBD_STORAGE_Exported_FunctionsPrototype USBD_STORAGE_Exported_FunctionsPrototype
* @{ * @brief Public functions declaration.
*/ * @{
*/
/* USER CODE BEGIN EXPORTED_FUNCTIONS */
/* USER CODE BEGIN EXPORTED_FUNCTIONS */
/* USER CODE END EXPORTED_FUNCTIONS */
/* USER CODE END EXPORTED_FUNCTIONS */
/**
* @} /**
*/ * @}
*/
/**
* @} /**
*/ * @}
*/
/**
* @} /**
*/ * @}
*/
#ifdef __cplusplus
} #ifdef __cplusplus
#endif }
#endif
#endif /* __USBD_STORAGE_IF_H__ */
#endif /* __USBD_MSC_STORAGE_IF_H__ */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -0,0 +1,189 @@
/**
******************************************************************************
* @file usbd_cdc.h
* @author MCD Application Team
* @brief header file for the usbd_cdc.c file.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_CDC_H
#define __USB_CDC_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_ioreq.h"
#include "AL94.I-CUBE-USBD-COMPOSITE_conf.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{
*/
/** @defgroup usbd_cdc
* @brief This file is the Header file for usbd_cdc.c
* @{
*/
/** @defgroup usbd_cdc_Exported_Defines
* @{
*/
#define CDC_ACM_STR_DESC "STM32 CDC ACM%d"
#define NUMBER_OF_CDC _USBD_CDC_ACM_COUNT
#ifndef CDC_HS_BINTERVAL
#define CDC_HS_BINTERVAL 0x10U
#endif /* CDC_HS_BINTERVAL */
#ifndef CDC_FS_BINTERVAL
#define CDC_FS_BINTERVAL 0x10U
#endif /* CDC_FS_BINTERVAL */
/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
#define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
#define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
#define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
#define USB_CDC_CONFIG_DESC_SIZ (9 + 66 * NUMBER_OF_CDC)
#define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
#define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
#define CDC_REQ_MAX_DATA_SIZE 0x7U
/*---------------------------------------------------------------------*/
/* CDC definitions */
/*---------------------------------------------------------------------*/
#define CDC_SEND_ENCAPSULATED_COMMAND 0x00U
#define CDC_GET_ENCAPSULATED_RESPONSE 0x01U
#define CDC_SET_COMM_FEATURE 0x02U
#define CDC_GET_COMM_FEATURE 0x03U
#define CDC_CLEAR_COMM_FEATURE 0x04U
#define CDC_SET_LINE_CODING 0x20U
#define CDC_GET_LINE_CODING 0x21U
#define CDC_SET_CONTROL_LINE_STATE 0x22U
#define CDC_SEND_BREAK 0x23U
/**
* @}
*/
/** @defgroup USBD_CORE_Exported_TypesDefinitions
* @{
*/
/**
* @}
*/
typedef struct
{
uint32_t bitrate;
uint8_t format;
uint8_t paritytype;
uint8_t datatype;
} USBD_CDC_ACM_LineCodingTypeDef;
typedef struct _USBD_CDC_Itf
{
int8_t (*Init)(uint8_t cdc_ch);
int8_t (*DeInit)(uint8_t cdc_ch);
int8_t (*Control)(uint8_t cdc_ch, uint8_t cmd, uint8_t *pbuf, uint16_t length);
int8_t (*Receive)(uint8_t cdc_ch, uint8_t *Buf, uint32_t *Len);
int8_t (*TransmitCplt)(uint8_t cdc_ch, uint8_t *Buf, uint32_t *Len, uint8_t epnum);
} USBD_CDC_ACM_ItfTypeDef;
typedef struct
{
uint32_t data[NUMBER_OF_CDC][CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */
uint8_t CmdOpCode;
uint8_t CmdLength;
uint8_t *RxBuffer;
uint8_t *TxBuffer;
uint32_t RxLength;
uint32_t TxLength;
__IO uint32_t TxState;
__IO uint32_t RxState;
} USBD_CDC_ACM_HandleTypeDef;
/** @defgroup USBD_CORE_Exported_Macros
* @{
*/
/**
* @}
*/
/** @defgroup USBD_CORE_Exported_Variables
* @{
*/
extern USBD_ClassTypeDef USBD_CDC_ACM;
extern uint8_t CDC_IN_EP[NUMBER_OF_CDC]; /* EP1 for data IN */
extern uint8_t CDC_OUT_EP[NUMBER_OF_CDC]; /* EP1 for data OUT */
extern uint8_t CDC_CMD_EP[NUMBER_OF_CDC]; /* EP2 for CDC commands */
extern uint8_t CDC_CMD_ITF_NBR[NUMBER_OF_CDC]; /* Command Interface Number */
extern uint8_t CDC_COM_ITF_NBR[NUMBER_OF_CDC]; /* Communication Interface Number */
extern uint8_t CDC_STR_DESC_IDX[NUMBER_OF_CDC];
/**
* @}
*/
/** @defgroup USB_CORE_Exported_Functions
* @{
*/
uint8_t USBD_CDC_ACM_RegisterInterface(USBD_HandleTypeDef *pdev,
USBD_CDC_ACM_ItfTypeDef *fops);
uint8_t USBD_CDC_SetTxBuffer(uint8_t ch, USBD_HandleTypeDef *pdev, uint8_t *pbuff,
uint32_t length);
uint8_t USBD_CDC_SetRxBuffer(uint8_t ch, USBD_HandleTypeDef *pdev, uint8_t *pbuff);
uint8_t USBD_CDC_ReceivePacket(uint8_t ch, USBD_HandleTypeDef *pdev);
uint8_t USBD_CDC_TransmitPacket(uint8_t ch, USBD_HandleTypeDef *pdev);
void USBD_Update_CDC_ACM_DESC(uint8_t *desc,
uint8_t cmd_itf,
uint8_t com_itf,
uint8_t in_ep,
uint8_t cmd_ep,
uint8_t out_ep,
uint8_t str_idx);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __USB_CDC_H */
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,154 @@
/**
******************************************************************************
* @file usbd_composite.h
* @author MCD Application Team
* @brief Header file for the usbd_composite.c file.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_COMPOSITE_H
#define __USB_COMPOSITE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stdbool.h"
#include "usbd_ioreq.h"
#include "AL94.I-CUBE-USBD-COMPOSITE_conf.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{
*/
/** @defgroup USBD_COMPOSITE
* @brief This file is the header file for usbd_composite.c
* @{
*/
/** @defgroup USBD_COMPOSITE_Exported_Defines
* @{
*/
#define USBD_USE_HS _USBD_USE_HS
#define USBD_USE_CDC_ACM _USBD_USE_CDC_ACM
#define USBD_CDC_ACM_COUNT _USBD_CDC_ACM_COUNT
#define USBD_USE_CDC_RNDIS _USBD_USE_CDC_RNDIS
#define USBD_USE_CDC_ECM _USBD_USE_CDC_ECM
#define USBD_USE_HID_MOUSE _USBD_USE_HID_MOUSE
#define USBD_USE_HID_KEYBOARD _USBD_USE_HID_KEYBOARD
#define USBD_USE_HID_CUSTOM _USBD_USE_HID_CUSTOM
#define USBD_USE_UAC_MIC _USBD_USE_UAC_MIC
#define USBD_USE_UAC_SPKR _USBD_USE_UAC_SPKR
#define USBD_USE_UVC _USBD_USE_UVC
#define USBD_USE_MSC _USBD_USE_MSC
#define USBD_USE_DFU _USBD_USE_DFU
#define USBD_USE_PRNTR _USBD_USE_PRNTR
#define STM32F1_DEVICE _STM32F1_DEVICE
#if(USBD_USE_CDC_ACM == 1)
#include "usbd_cdc_acm_if.h"
#endif
#if(USBD_USE_CDC_RNDIS == 1)
#include "usbd_cdc_rndis_if.h"
#endif
#if(USBD_USE_CDC_ECM == 1)
#include "usbd_cdc_ecm_if.h"
#endif
#if(USBD_USE_HID_MOUSE == 1)
#include "usbd_hid_mouse.h"
#endif
#if(USBD_USE_HID_KEYBOARD == 1)
#include "usbd_hid_keyboard.h"
#endif
#if(USBD_USE_HID_CUSTOM == 1)
#include "usbd_hid_custom_if.h"
#endif
#if(USBD_USE_UAC_MIC == 1)
#include "usbd_audio_mic_if.h"
#endif
#if(USBD_USE_UAC_SPKR == 1)
#include "usbd_audio_spkr_if.h"
#endif
#if(USBD_USE_UVC == 1)
#include "usbd_video_if.h"
#endif
#if(USBD_USE_MSC == 1)
#include "usbd_msc_if.h"
#endif
#if(USBD_USE_DFU == 1)
#include "usbd_dfu_if.h"
#endif
#if(USBD_USE_PRNTR == 1)
#include "usbd_printer_if.h"
#endif
/**
* @}
*/
/** @defgroup USBD_COMPOSITE_Exported_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup USBD_COMPOSITE_Exported_Macros
* @{
*/
/**
* @}
*/
/** @defgroup USBD_COMPOSITE_Exported_Variables
* @{
*/
extern USBD_ClassTypeDef USBD_COMPOSITE;
/**
* @}
*/
/** @defgroup USB_CORE_Exported_Functions
* @{
*/
void USBD_COMPOSITE_Mount_Class(void);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __USB_COMPOSITE_H */
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,133 @@
/**
******************************************************************************
* @file usbd_msc.h
* @author MCD Application Team
* @brief Header for the usbd_msc.c file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_MSC_H
#define __USBD_MSC_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_msc_bot.h"
#include "usbd_msc_scsi.h"
#include "usbd_ioreq.h"
/** @addtogroup USBD_MSC_BOT
* @{
*/
/** @defgroup USBD_MSC
* @brief This file is the Header file for usbd_msc.c
* @{
*/
/** @defgroup USBD_BOT_Exported_Defines
* @{
*/
#define MSC_BOT_STR_DESC "STM32 MSC DEVICE"
/* MSC Class Config */
#ifndef MSC_MEDIA_PACKET
#define MSC_MEDIA_PACKET 512U
#endif /* MSC_MEDIA_PACKET */
#define MSC_MAX_FS_PACKET 0x40U
#define MSC_MAX_HS_PACKET 0x200U
#define BOT_GET_MAX_LUN 0xFE
#define BOT_RESET 0xFF
#define USB_MSC_CONFIG_DESC_SIZ 32
/**
* @}
*/
/** @defgroup USB_CORE_Exported_Types
* @{
*/
typedef struct _USBD_STORAGE
{
int8_t (*Init)(uint8_t lun);
int8_t (*GetCapacity)(uint8_t lun, uint32_t *block_num, uint16_t *block_size);
int8_t (*IsReady)(uint8_t lun);
int8_t (*IsWriteProtected)(uint8_t lun);
int8_t (*Read)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
int8_t (*Write)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
int8_t (*GetMaxLun)(void);
int8_t *pInquiry;
} USBD_StorageTypeDef;
typedef struct
{
uint32_t max_lun;
uint32_t interface;
uint8_t bot_state;
uint8_t bot_status;
uint32_t bot_data_length;
uint8_t bot_data[MSC_MEDIA_PACKET];
USBD_MSC_BOT_CBWTypeDef cbw;
USBD_MSC_BOT_CSWTypeDef csw;
USBD_SCSI_SenseTypeDef scsi_sense[SENSE_LIST_DEEPTH];
uint8_t scsi_sense_head;
uint8_t scsi_sense_tail;
uint8_t scsi_medium_state;
uint16_t scsi_blk_size;
uint32_t scsi_blk_nbr;
uint32_t scsi_blk_addr;
uint32_t scsi_blk_len;
} USBD_MSC_BOT_HandleTypeDef;
/* Structure for MSC process */
extern USBD_ClassTypeDef USBD_MSC;
extern uint8_t MSC_IN_EP;
extern uint8_t MSC_OUT_EP;
extern uint8_t MSC_ITF_NBR;
extern uint8_t MSC_BOT_STR_DESC_IDX;
uint8_t USBD_MSC_RegisterStorage(USBD_HandleTypeDef *pdev,
USBD_StorageTypeDef *fops);
void USBD_Update_MSC_DESC(uint8_t *desc, uint8_t itf_no, uint8_t in_ep, uint8_t out_ep, uint8_t str_idx);
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __USBD_MSC_H */
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,146 +1,150 @@
/** /**
****************************************************************************** ******************************************************************************
* @file usbd_msc_bot.h * @file usbd_msc_bot.h
* @author MCD Application Team * @author MCD Application Team
* @brief Header for the usbd_msc_bot.c file * @brief Header for the usbd_msc_bot.c file
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2015 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_MSC_BOT_H /* Define to prevent recursive inclusion -------------------------------------*/
#define __USBD_MSC_BOT_H #ifndef __USBD_MSC_BOT_H
#define __USBD_MSC_BOT_H
#ifdef __cplusplus
extern "C" { #ifdef __cplusplus
#endif extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_core.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_core.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{ /** @addtogroup STM32_USB_DEVICE_LIBRARY
*/ * @{
*/
/** @defgroup MSC_BOT
* @brief This file is the Header file for usbd_msc_bot.c /** @defgroup MSC_BOT
* @{ * @brief This file is the Header file for usbd_msc_bot.c
*/ * @{
*/
/** @defgroup USBD_CORE_Exported_Defines
* @{ /** @defgroup USBD_CORE_Exported_Defines
*/ * @{
#define USBD_BOT_IDLE 0U /* Idle state */ */
#define USBD_BOT_DATA_OUT 1U /* Data Out state */ #define USBD_BOT_IDLE 0U /* Idle state */
#define USBD_BOT_DATA_IN 2U /* Data In state */ #define USBD_BOT_DATA_OUT 1U /* Data Out state */
#define USBD_BOT_LAST_DATA_IN 3U /* Last Data In Last */ #define USBD_BOT_DATA_IN 2U /* Data In state */
#define USBD_BOT_SEND_DATA 4U /* Send Immediate data */ #define USBD_BOT_LAST_DATA_IN 3U /* Last Data In Last */
#define USBD_BOT_NO_DATA 5U /* No data Stage */ #define USBD_BOT_SEND_DATA 4U /* Send Immediate data */
#define USBD_BOT_NO_DATA 5U /* No data Stage */
#define USBD_BOT_CBW_SIGNATURE 0x43425355U
#define USBD_BOT_CSW_SIGNATURE 0x53425355U #define USBD_BOT_CBW_SIGNATURE 0x43425355U
#define USBD_BOT_CBW_LENGTH 31U #define USBD_BOT_CSW_SIGNATURE 0x53425355U
#define USBD_BOT_CSW_LENGTH 13U #define USBD_BOT_CBW_LENGTH 31U
#define USBD_BOT_MAX_DATA 256U #define USBD_BOT_CSW_LENGTH 13U
#define USBD_BOT_MAX_DATA 256U
/* CSW Status Definitions */
#define USBD_CSW_CMD_PASSED 0x00U /* CSW Status Definitions */
#define USBD_CSW_CMD_FAILED 0x01U #define USBD_CSW_CMD_PASSED 0x00U
#define USBD_CSW_PHASE_ERROR 0x02U #define USBD_CSW_CMD_FAILED 0x01U
#define USBD_CSW_PHASE_ERROR 0x02U
/* BOT Status */
#define USBD_BOT_STATUS_NORMAL 0U /* BOT Status */
#define USBD_BOT_STATUS_RECOVERY 1U #define USBD_BOT_STATUS_NORMAL 0U
#define USBD_BOT_STATUS_ERROR 2U #define USBD_BOT_STATUS_RECOVERY 1U
#define USBD_BOT_STATUS_ERROR 2U
#define USBD_DIR_IN 0U
#define USBD_DIR_OUT 1U #define USBD_DIR_IN 0U
#define USBD_BOTH_DIR 2U #define USBD_DIR_OUT 1U
#define USBD_BOTH_DIR 2U
/**
* @} /**
*/ * @}
*/
/** @defgroup MSC_CORE_Private_TypesDefinitions
* @{ /** @defgroup MSC_CORE_Private_TypesDefinitions
*/ * @{
*/
typedef struct
{ typedef struct
uint32_t dSignature; {
uint32_t dTag; uint32_t dSignature;
uint32_t dDataLength; uint32_t dTag;
uint8_t bmFlags; uint32_t dDataLength;
uint8_t bLUN; uint8_t bmFlags;
uint8_t bCBLength; uint8_t bLUN;
uint8_t CB[16]; uint8_t bCBLength;
uint8_t ReservedForAlign; uint8_t CB[16];
} USBD_MSC_BOT_CBWTypeDef; uint8_t ReservedForAlign;
}
USBD_MSC_BOT_CBWTypeDef;
typedef struct
{
uint32_t dSignature; typedef struct
uint32_t dTag; {
uint32_t dDataResidue; uint32_t dSignature;
uint8_t bStatus; uint32_t dTag;
uint8_t ReservedForAlign[3]; uint32_t dDataResidue;
} USBD_MSC_BOT_CSWTypeDef; uint8_t bStatus;
uint8_t ReservedForAlign[3];
/** }
* @} USBD_MSC_BOT_CSWTypeDef;
*/
/**
* @}
/** @defgroup USBD_CORE_Exported_Types */
* @{
*/
/** @defgroup USBD_CORE_Exported_Types
/** * @{
* @} */
*/
/** @defgroup USBD_CORE_Exported_FunctionsPrototypes /**
* @{ * @}
*/ */
void MSC_BOT_Init(USBD_HandleTypeDef *pdev); /** @defgroup USBD_CORE_Exported_FunctionsPrototypes
void MSC_BOT_Reset(USBD_HandleTypeDef *pdev); * @{
void MSC_BOT_DeInit(USBD_HandleTypeDef *pdev); */
void MSC_BOT_DataIn(USBD_HandleTypeDef *pdev, void MSC_BOT_Init(USBD_HandleTypeDef *pdev);
uint8_t epnum); void MSC_BOT_Reset(USBD_HandleTypeDef *pdev);
void MSC_BOT_DeInit(USBD_HandleTypeDef *pdev);
void MSC_BOT_DataOut(USBD_HandleTypeDef *pdev, void MSC_BOT_DataIn(USBD_HandleTypeDef *pdev,
uint8_t epnum); uint8_t epnum);
void MSC_BOT_SendCSW(USBD_HandleTypeDef *pdev, void MSC_BOT_DataOut(USBD_HandleTypeDef *pdev,
uint8_t CSW_Status); uint8_t epnum);
void MSC_BOT_CplClrFeature(USBD_HandleTypeDef *pdev, void MSC_BOT_SendCSW(USBD_HandleTypeDef *pdev,
uint8_t epnum); uint8_t CSW_Status);
/**
* @} void MSC_BOT_CplClrFeature(USBD_HandleTypeDef *pdev,
*/ uint8_t epnum);
/**
#ifdef __cplusplus * @}
} */
#endif
#ifdef __cplusplus
#endif /* __USBD_MSC_BOT_H */ }
/** #endif
* @}
*/ #endif /* __USBD_MSC_BOT_H */
/**
/** * @}
* @} */
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,102 +1,105 @@
/** /**
****************************************************************************** ******************************************************************************
* @file usbd_msc_data.h * @file usbd_msc_data.h
* @author MCD Application Team * @author MCD Application Team
* @brief Header for the usbd_msc_data.c file * @brief Header for the usbd_msc_data.c file
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2015 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_MSC_DATA_H /* Define to prevent recursive inclusion -------------------------------------*/
#define __USBD_MSC_DATA_H #ifndef __USBD_MSC_DATA_H
#define __USBD_MSC_DATA_H
#ifdef __cplusplus
extern "C" { #ifdef __cplusplus
#endif extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_conf.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_conf.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{ /** @addtogroup STM32_USB_DEVICE_LIBRARY
*/ * @{
*/
/** @defgroup USB_INFO
* @brief general defines for the usb device library file /** @defgroup USB_INFO
* @{ * @brief general defines for the usb device library file
*/ * @{
*/
/** @defgroup USB_INFO_Exported_Defines
* @{ /** @defgroup USB_INFO_Exported_Defines
*/ * @{
#define MODE_SENSE6_LEN 0x17U */
#define MODE_SENSE10_LEN 0x1BU #define MODE_SENSE6_LEN 0x17U
#define LENGTH_INQUIRY_PAGE00 0x06U #define MODE_SENSE10_LEN 0x1BU
#define LENGTH_INQUIRY_PAGE80 0x08U #define LENGTH_INQUIRY_PAGE00 0x06U
#define LENGTH_FORMAT_CAPACITIES 0x14U #define LENGTH_INQUIRY_PAGE80 0x08U
#define LENGTH_FORMAT_CAPACITIES 0x14U
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_INFO_Exported_TypesDefinitions
* @{ /** @defgroup USBD_INFO_Exported_TypesDefinitions
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup USBD_INFO_Exported_Macros
* @{ /** @defgroup USBD_INFO_Exported_Macros
*/ * @{
*/
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_INFO_Exported_Variables
* @{ /** @defgroup USBD_INFO_Exported_Variables
*/ * @{
extern uint8_t MSC_Page00_Inquiry_Data[LENGTH_INQUIRY_PAGE00]; */
extern uint8_t MSC_Page80_Inquiry_Data[LENGTH_INQUIRY_PAGE80]; extern uint8_t MSC_Page00_Inquiry_Data[LENGTH_INQUIRY_PAGE00];
extern uint8_t MSC_Mode_Sense6_data[MODE_SENSE6_LEN]; extern uint8_t MSC_Page80_Inquiry_Data[LENGTH_INQUIRY_PAGE80];
extern uint8_t MSC_Mode_Sense10_data[MODE_SENSE10_LEN]; extern uint8_t MSC_Mode_Sense6_data[MODE_SENSE6_LEN];
extern uint8_t MSC_Mode_Sense10_data[MODE_SENSE10_LEN];
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_INFO_Exported_FunctionsPrototype
* @{ /** @defgroup USBD_INFO_Exported_FunctionsPrototype
*/ * @{
*/
/**
* @} /**
*/ * @}
*/
#ifdef __cplusplus
} #ifdef __cplusplus
#endif }
#endif
#endif /* __USBD_MSC_DATA_H */
#endif /* __USBD_MSC_DATA_H */
/**
* @} /**
*/ * @}
*/
/**
* @} /**
*/ * @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,182 +1,185 @@
/** /**
****************************************************************************** ******************************************************************************
* @file usbd_msc_scsi.h * @file usbd_msc_scsi.h
* @author MCD Application Team * @author MCD Application Team
* @brief Header for the usbd_msc_scsi.c file * @brief Header for the usbd_msc_scsi.c file
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2015 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_MSC_SCSI_H /* Define to prevent recursive inclusion -------------------------------------*/
#define __USBD_MSC_SCSI_H #ifndef __USBD_MSC_SCSI_H
#define __USBD_MSC_SCSI_H
#ifdef __cplusplus
extern "C" { #ifdef __cplusplus
#endif extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_def.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_def.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{ /** @addtogroup STM32_USB_DEVICE_LIBRARY
*/ * @{
*/
/** @defgroup USBD_SCSI
* @brief header file for the storage disk file /** @defgroup USBD_SCSI
* @{ * @brief header file for the storage disk file
*/ * @{
*/
/** @defgroup USBD_SCSI_Exported_Defines
* @{ /** @defgroup USBD_SCSI_Exported_Defines
*/ * @{
*/
#define SENSE_LIST_DEEPTH 4U
#define SENSE_LIST_DEEPTH 4U
/* SCSI Commands */
#define SCSI_FORMAT_UNIT 0x04U /* SCSI Commands */
#define SCSI_INQUIRY 0x12U #define SCSI_FORMAT_UNIT 0x04U
#define SCSI_MODE_SELECT6 0x15U #define SCSI_INQUIRY 0x12U
#define SCSI_MODE_SELECT10 0x55U #define SCSI_MODE_SELECT6 0x15U
#define SCSI_MODE_SENSE6 0x1AU #define SCSI_MODE_SELECT10 0x55U
#define SCSI_MODE_SENSE10 0x5AU #define SCSI_MODE_SENSE6 0x1AU
#define SCSI_ALLOW_MEDIUM_REMOVAL 0x1EU #define SCSI_MODE_SENSE10 0x5AU
#define SCSI_READ6 0x08U #define SCSI_ALLOW_MEDIUM_REMOVAL 0x1EU
#define SCSI_READ10 0x28U #define SCSI_READ6 0x08U
#define SCSI_READ12 0xA8U #define SCSI_READ10 0x28U
#define SCSI_READ16 0x88U #define SCSI_READ12 0xA8U
#define SCSI_READ16 0x88U
#define SCSI_READ_CAPACITY10 0x25U
#define SCSI_READ_CAPACITY16 0x9EU #define SCSI_READ_CAPACITY10 0x25U
#define SCSI_READ_CAPACITY16 0x9EU
#define SCSI_REQUEST_SENSE 0x03U
#define SCSI_START_STOP_UNIT 0x1BU #define SCSI_REQUEST_SENSE 0x03U
#define SCSI_TEST_UNIT_READY 0x00U #define SCSI_START_STOP_UNIT 0x1BU
#define SCSI_WRITE6 0x0AU #define SCSI_TEST_UNIT_READY 0x00U
#define SCSI_WRITE10 0x2AU #define SCSI_WRITE6 0x0AU
#define SCSI_WRITE12 0xAAU #define SCSI_WRITE10 0x2AU
#define SCSI_WRITE16 0x8AU #define SCSI_WRITE12 0xAAU
#define SCSI_WRITE16 0x8AU
#define SCSI_VERIFY10 0x2FU
#define SCSI_VERIFY12 0xAFU #define SCSI_VERIFY10 0x2FU
#define SCSI_VERIFY16 0x8FU #define SCSI_VERIFY12 0xAFU
#define SCSI_VERIFY16 0x8FU
#define SCSI_SEND_DIAGNOSTIC 0x1DU
#define SCSI_READ_FORMAT_CAPACITIES 0x23U #define SCSI_SEND_DIAGNOSTIC 0x1DU
#define SCSI_READ_FORMAT_CAPACITIES 0x23U
#define NO_SENSE 0U
#define RECOVERED_ERROR 1U #define NO_SENSE 0U
#define NOT_READY 2U #define RECOVERED_ERROR 1U
#define MEDIUM_ERROR 3U #define NOT_READY 2U
#define HARDWARE_ERROR 4U #define MEDIUM_ERROR 3U
#define ILLEGAL_REQUEST 5U #define HARDWARE_ERROR 4U
#define UNIT_ATTENTION 6U #define ILLEGAL_REQUEST 5U
#define DATA_PROTECT 7U #define UNIT_ATTENTION 6U
#define BLANK_CHECK 8U #define DATA_PROTECT 7U
#define MSC_VENDOR_SPECIFIC 9U #define BLANK_CHECK 8U
#define COPY_ABORTED 10U #define VENDOR_SPECIFIC 9U
#define ABORTED_COMMAND 11U #define COPY_ABORTED 10U
#define VOLUME_OVERFLOW 13U #define ABORTED_COMMAND 11U
#define MISCOMPARE 14U #define VOLUME_OVERFLOW 13U
#define MISCOMPARE 14U
#define INVALID_CDB 0x20U
#define INVALID_FIELED_IN_COMMAND 0x24U #define INVALID_CDB 0x20U
#define PARAMETER_LIST_LENGTH_ERROR 0x1AU #define INVALID_FIELED_IN_COMMAND 0x24U
#define INVALID_FIELD_IN_PARAMETER_LIST 0x26U #define PARAMETER_LIST_LENGTH_ERROR 0x1AU
#define ADDRESS_OUT_OF_RANGE 0x21U #define INVALID_FIELD_IN_PARAMETER_LIST 0x26U
#define MEDIUM_NOT_PRESENT 0x3AU #define ADDRESS_OUT_OF_RANGE 0x21U
#define MEDIUM_HAVE_CHANGED 0x28U #define MEDIUM_NOT_PRESENT 0x3AU
#define WRITE_PROTECTED 0x27U #define MEDIUM_HAVE_CHANGED 0x28U
#define UNRECOVERED_READ_ERROR 0x11U #define WRITE_PROTECTED 0x27U
#define WRITE_FAULT 0x03U #define UNRECOVERED_READ_ERROR 0x11U
#define WRITE_FAULT 0x03U
#define READ_FORMAT_CAPACITY_DATA_LEN 0x0CU
#define READ_CAPACITY10_DATA_LEN 0x08U #define READ_FORMAT_CAPACITY_DATA_LEN 0x0CU
#define REQUEST_SENSE_DATA_LEN 0x12U #define READ_CAPACITY10_DATA_LEN 0x08U
#define STANDARD_INQUIRY_DATA_LEN 0x24U #define REQUEST_SENSE_DATA_LEN 0x12U
#define BLKVFY 0x04U #define STANDARD_INQUIRY_DATA_LEN 0x24U
#define BLKVFY 0x04U
#define SCSI_MEDIUM_UNLOCKED 0x00U
#define SCSI_MEDIUM_LOCKED 0x01U #define SCSI_MEDIUM_UNLOCKED 0x00U
#define SCSI_MEDIUM_EJECTED 0x02U #define SCSI_MEDIUM_LOCKED 0x01U
/** #define SCSI_MEDIUM_EJECTED 0x02U
* @} /**
*/ * @}
*/
/** @defgroup USBD_SCSI_Exported_TypesDefinitions
* @{ /** @defgroup USBD_SCSI_Exported_TypesDefinitions
*/ * @{
*/
typedef struct _SENSE_ITEM
{ typedef struct _SENSE_ITEM
uint8_t Skey; {
union uint8_t Skey;
{ union
struct _ASCs {
{ struct _ASCs
uint8_t ASC; {
uint8_t ASCQ; uint8_t ASC;
} b; uint8_t ASCQ;
uint8_t ASC; } b;
uint8_t *pData; uint8_t ASC;
} w; uint8_t *pData;
} USBD_SCSI_SenseTypeDef; } w;
/** } USBD_SCSI_SenseTypeDef;
* @} /**
*/ * @}
*/
/** @defgroup USBD_SCSI_Exported_Macros
* @{ /** @defgroup USBD_SCSI_Exported_Macros
*/ * @{
*/
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_SCSI_Exported_Variables
* @{ /** @defgroup USBD_SCSI_Exported_Variables
*/ * @{
*/
/**
* @} /**
*/ * @}
/** @defgroup USBD_SCSI_Exported_FunctionsPrototype */
* @{ /** @defgroup USBD_SCSI_Exported_FunctionsPrototype
*/ * @{
int8_t SCSI_ProcessCmd(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *cmd); */
int8_t SCSI_ProcessCmd(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *cmd);
void SCSI_SenseCode(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t sKey,
uint8_t ASC); void SCSI_SenseCode(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t sKey,
uint8_t ASC);
/**
* @} /**
*/ * @}
*/
#ifdef __cplusplus
} #ifdef __cplusplus
#endif }
#endif
#endif /* __USBD_MSC_SCSI_H */
/** #endif /* __USBD_MSC_SCSI_H */
* @} /**
*/ * @}
*/
/**
* @} /**
*/ * @}
*/
/**
* @} /**
*/ * @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -0,0 +1,617 @@
/**
******************************************************************************
* @file usbd_msc.c
* @author MCD Application Team
* @brief This file provides all the MSC core functions.
*
* @verbatim
*
* ===================================================================
* MSC Class Description
* ===================================================================
* This module manages the MSC class V1.0 following the "Universal
* Serial Bus Mass Storage Class (MSC) Bulk-Only Transport (BOT) Version 1.0
* Sep. 31, 1999".
* This driver implements the following aspects of the specification:
* - Bulk-Only Transport protocol
* - Subclass : SCSI transparent command set (ref. SCSI Primary Commands - 3 (SPC-3))
*
* @endverbatim
*
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* BSPDependencies
- "stm32xxxxx_{eval}{discovery}{nucleo_144}.c"
- "stm32xxxxx_{eval}{discovery}_io.c"
- "stm32xxxxx_{eval}{discovery}{adafruit}_sd.c"
EndBSPDependencies */
/* Includes ------------------------------------------------------------------*/
#include "usbd_msc.h"
#define _MSC_IN_EP 0x81U
#define _MSC_OUT_EP 0x01U
#define _MSC_ITF_NBR 0x00
#define _MSC_BOT_STR_DESC_IDX 0x00U
uint8_t MSC_IN_EP = _MSC_IN_EP;
uint8_t MSC_OUT_EP = _MSC_OUT_EP;
uint8_t MSC_ITF_NBR = _MSC_ITF_NBR;
uint8_t MSC_BOT_STR_DESC_IDX = _MSC_BOT_STR_DESC_IDX;
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{
*/
/** @defgroup MSC_CORE
* @brief Mass storage core module
* @{
*/
/** @defgroup MSC_CORE_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup MSC_CORE_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup MSC_CORE_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup MSC_CORE_Private_FunctionPrototypes
* @{
*/
uint8_t USBD_MSC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
uint8_t USBD_MSC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
uint8_t USBD_MSC_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
uint8_t USBD_MSC_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum);
uint8_t USBD_MSC_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum);
uint8_t *USBD_MSC_GetHSCfgDesc(uint16_t *length);
uint8_t *USBD_MSC_GetFSCfgDesc(uint16_t *length);
uint8_t *USBD_MSC_GetOtherSpeedCfgDesc(uint16_t *length);
uint8_t *USBD_MSC_GetDeviceQualifierDescriptor(uint16_t *length);
/**
* @}
*/
/** @defgroup MSC_CORE_Private_Variables
* @{
*/
static USBD_MSC_BOT_HandleTypeDef USBD_MSC_Instance;
USBD_ClassTypeDef USBD_MSC =
{
USBD_MSC_Init,
USBD_MSC_DeInit,
USBD_MSC_Setup,
NULL, /*EP0_TxSent*/
NULL, /*EP0_RxReady*/
USBD_MSC_DataIn,
USBD_MSC_DataOut,
NULL, /*SOF */
NULL,
NULL,
USBD_MSC_GetHSCfgDesc,
USBD_MSC_GetFSCfgDesc,
USBD_MSC_GetOtherSpeedCfgDesc,
USBD_MSC_GetDeviceQualifierDescriptor,
};
/* USB Mass storage device Configuration Descriptor */
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
__ALIGN_BEGIN static uint8_t USBD_MSC_CfgHSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIGN_END =
{
0x09, /* bLength: Configuration Descriptor size */
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
USB_MSC_CONFIG_DESC_SIZ,
0x00,
0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue */
0x04, /* iConfiguration */
#if (USBD_SELF_POWERED == 1U)
0xC0, /* bmAttributes: Bus Powered according to user configuration */
#else
0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif
USBD_MAX_POWER, /* MaxPower (mA) */
/******************** Mass Storage interface ********************/
0x09, /* bLength: Interface Descriptor size */
0x04, /* bDescriptorType: */
_MSC_ITF_NBR, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints */
0x08, /* bInterfaceClass: MSC Class */
0x06, /* bInterfaceSubClass : SCSI transparent */
0x50, /* nInterfaceProtocol */
_MSC_BOT_STR_DESC_IDX, /* iInterface */
/******************** Mass Storage Endpoints ********************/
0x07, /* Endpoint descriptor length = 7 */
0x05, /* Endpoint descriptor type */
_MSC_IN_EP, /* Endpoint address (IN, address 1) */
0x02, /* Bulk endpoint type */
LOBYTE(MSC_MAX_HS_PACKET),
HIBYTE(MSC_MAX_HS_PACKET),
0x00, /* Polling interval in milliseconds */
0x07, /* Endpoint descriptor length = 7 */
0x05, /* Endpoint descriptor type */
_MSC_OUT_EP, /* Endpoint address (OUT, address 1) */
0x02, /* Bulk endpoint type */
LOBYTE(MSC_MAX_HS_PACKET),
HIBYTE(MSC_MAX_HS_PACKET),
0x00 /* Polling interval in milliseconds */
};
/* USB Mass storage device Configuration Descriptor */
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
__ALIGN_BEGIN static uint8_t USBD_MSC_CfgFSDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIGN_END =
{
0x09, /* bLength: Configuration Descriptor size */
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
USB_MSC_CONFIG_DESC_SIZ,
0x00,
0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue */
0x04, /* iConfiguration */
#if (USBD_SELF_POWERED == 1U)
0xC0, /* bmAttributes: Bus Powered according to user configuration */
#else
0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif
USBD_MAX_POWER, /* MaxPower (mA) */
/******************** Mass Storage interface ********************/
0x09, /* bLength: Interface Descriptor size */
0x04, /* bDescriptorType: */
_MSC_ITF_NBR, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints*/
0x08, /* bInterfaceClass: MSC Class */
0x06, /* bInterfaceSubClass : SCSI transparent*/
0x50, /* nInterfaceProtocol */
_MSC_BOT_STR_DESC_IDX, /* iInterface: */
/******************** Mass Storage Endpoints ********************/
0x07, /* Endpoint descriptor length = 7 */
0x05, /* Endpoint descriptor type */
_MSC_IN_EP, /* Endpoint address (IN, address 1) */
0x02, /* Bulk endpoint type */
LOBYTE(MSC_MAX_FS_PACKET),
HIBYTE(MSC_MAX_FS_PACKET),
0x00, /* Polling interval in milliseconds */
0x07, /* Endpoint descriptor length = 7 */
0x05, /* Endpoint descriptor type */
_MSC_OUT_EP, /* Endpoint address (OUT, address 1) */
0x02, /* Bulk endpoint type */
LOBYTE(MSC_MAX_FS_PACKET),
HIBYTE(MSC_MAX_FS_PACKET),
0x00 /* Polling interval in milliseconds */
};
__ALIGN_BEGIN static uint8_t USBD_MSC_OtherSpeedCfgDesc[USB_MSC_CONFIG_DESC_SIZ] __ALIGN_END =
{
0x09, /* bLength: Configuration Descriptor size */
USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION,
USB_MSC_CONFIG_DESC_SIZ,
0x00,
0x01, /* bNumInterfaces: 1 interface */
0x01, /* bConfigurationValue */
0x04, /* iConfiguration */
#if (USBD_SELF_POWERED == 1U)
0xC0, /* bmAttributes: Bus Powered according to user configuration */
#else
0x80, /* bmAttributes: Bus Powered according to user configuration */
#endif
USBD_MAX_POWER, /* MaxPower (mA) */
/******************** Mass Storage interface ********************/
0x09, /* bLength: Interface Descriptor size */
0x04, /* bDescriptorType: */
_MSC_ITF_NBR, /* bInterfaceNumber: Number of Interface */
0x00, /* bAlternateSetting: Alternate setting */
0x02, /* bNumEndpoints */
0x08, /* bInterfaceClass: MSC Class */
0x06, /* bInterfaceSubClass : SCSI transparent command set */
0x50, /* nInterfaceProtocol */
_MSC_BOT_STR_DESC_IDX, /* iInterface */
/******************** Mass Storage Endpoints ********************/
0x07, /* Endpoint descriptor length = 7 */
0x05, /* Endpoint descriptor type */
_MSC_IN_EP, /* Endpoint address (IN, address 1) */
0x02, /* Bulk endpoint type */
0x40,
0x00,
0x00, /* Polling interval in milliseconds */
0x07, /* Endpoint descriptor length = 7 */
0x05, /* Endpoint descriptor type */
_MSC_OUT_EP, /* Endpoint address (OUT, address 1) */
0x02, /* Bulk endpoint type */
0x40,
0x00,
0x00 /* Polling interval in milliseconds */
};
/* USB Standard Device Descriptor */
__ALIGN_BEGIN static uint8_t USBD_MSC_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
{
USB_LEN_DEV_QUALIFIER_DESC,
USB_DESC_TYPE_DEVICE_QUALIFIER,
0x00,
0x02,
0x00,
0x00,
0x00,
MSC_MAX_FS_PACKET,
0x01,
0x00,
};
/**
* @}
*/
/** @defgroup MSC_CORE_Private_Functions
* @{
*/
/**
* @brief USBD_MSC_Init
* Initialize the mass storage configuration
* @param pdev: device instance
* @param cfgidx: configuration index
* @retval status
*/
uint8_t USBD_MSC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
UNUSED(cfgidx);
USBD_MSC_BOT_HandleTypeDef *hmsc;
hmsc = &USBD_MSC_Instance;
if (hmsc == NULL)
{
pdev->pClassData_MSC = NULL;
return (uint8_t)USBD_EMEM;
}
pdev->pClassData_MSC = (void *)hmsc;
if (pdev->dev_speed == USBD_SPEED_HIGH)
{
/* Open EP OUT */
(void)USBD_LL_OpenEP(pdev, MSC_OUT_EP, USBD_EP_TYPE_BULK, MSC_MAX_HS_PACKET);
pdev->ep_out[MSC_OUT_EP & 0xFU].is_used = 1U;
/* Open EP IN */
(void)USBD_LL_OpenEP(pdev, MSC_IN_EP, USBD_EP_TYPE_BULK, MSC_MAX_HS_PACKET);
pdev->ep_in[MSC_IN_EP & 0xFU].is_used = 1U;
}
else
{
/* Open EP OUT */
(void)USBD_LL_OpenEP(pdev, MSC_OUT_EP, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
pdev->ep_out[MSC_OUT_EP & 0xFU].is_used = 1U;
/* Open EP IN */
(void)USBD_LL_OpenEP(pdev, MSC_IN_EP, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
pdev->ep_in[MSC_IN_EP & 0xFU].is_used = 1U;
}
/* Init the BOT layer */
MSC_BOT_Init(pdev);
return (uint8_t)USBD_OK;
}
/**
* @brief USBD_MSC_DeInit
* DeInitialize the mass storage configuration
* @param pdev: device instance
* @param cfgidx: configuration index
* @retval status
*/
uint8_t USBD_MSC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
UNUSED(cfgidx);
/* Close MSC EPs */
(void)USBD_LL_CloseEP(pdev, MSC_OUT_EP);
pdev->ep_out[MSC_OUT_EP & 0xFU].is_used = 0U;
/* Close EP IN */
(void)USBD_LL_CloseEP(pdev, MSC_IN_EP);
pdev->ep_in[MSC_IN_EP & 0xFU].is_used = 0U;
/* Free MSC Class Resources */
if (pdev->pClassData_MSC != NULL)
{
/* De-Init the BOT layer */
MSC_BOT_DeInit(pdev);
#if (0)
(void)USBD_free(pdev->pClassData_MSC);
#endif
pdev->pClassData_MSC = NULL;
}
return (uint8_t)USBD_OK;
}
/**
* @brief USBD_MSC_Setup
* Handle the MSC specific requests
* @param pdev: device instance
* @param req: USB request
* @retval status
*/
uint8_t USBD_MSC_Setup(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
{
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData_MSC;
USBD_StatusTypeDef ret = USBD_OK;
uint16_t status_info = 0U;
if (hmsc == NULL)
{
return (uint8_t)USBD_FAIL;
}
switch (req->bmRequest & USB_REQ_TYPE_MASK)
{
/* Class request */
case USB_REQ_TYPE_CLASS:
switch (req->bRequest)
{
case BOT_GET_MAX_LUN:
if ((req->wValue == 0U) && (req->wLength == 1U) &&
((req->bmRequest & 0x80U) == 0x80U))
{
hmsc->max_lun = (uint32_t)((USBD_StorageTypeDef *)pdev->pUserData_MSC)->GetMaxLun();
(void)USBD_CtlSendData(pdev, (uint8_t *)&hmsc->max_lun, 1U);
}
else
{
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
}
break;
case BOT_RESET:
if ((req->wValue == 0U) && (req->wLength == 0U) &&
((req->bmRequest & 0x80U) != 0x80U))
{
MSC_BOT_Reset(pdev);
}
else
{
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
}
break;
default:
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
break;
}
break;
/* Interface & Endpoint request */
case USB_REQ_TYPE_STANDARD:
switch (req->bRequest)
{
case USB_REQ_GET_STATUS:
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
(void)USBD_CtlSendData(pdev, (uint8_t *)&status_info, 2U);
}
else
{
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
}
break;
case USB_REQ_GET_INTERFACE:
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
(void)USBD_CtlSendData(pdev, (uint8_t *)&hmsc->interface, 1U);
}
else
{
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
}
break;
case USB_REQ_SET_INTERFACE:
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
hmsc->interface = (uint8_t)(req->wValue);
}
else
{
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
}
break;
case USB_REQ_CLEAR_FEATURE:
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
if (req->wValue == USB_FEATURE_EP_HALT)
{
/* Flush the FIFO */
(void)USBD_LL_FlushEP(pdev, (uint8_t)req->wIndex);
/* Handle BOT error */
MSC_BOT_CplClrFeature(pdev, (uint8_t)req->wIndex);
}
}
break;
default:
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
break;
}
break;
default:
USBD_CtlError(pdev, req);
ret = USBD_FAIL;
break;
}
return (uint8_t)ret;
}
/**
* @brief USBD_MSC_DataIn
* handle data IN Stage
* @param pdev: device instance
* @param epnum: endpoint index
* @retval status
*/
uint8_t USBD_MSC_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
{
MSC_BOT_DataIn(pdev, epnum);
return (uint8_t)USBD_OK;
}
/**
* @brief USBD_MSC_DataOut
* handle data OUT Stage
* @param pdev: device instance
* @param epnum: endpoint index
* @retval status
*/
uint8_t USBD_MSC_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
{
MSC_BOT_DataOut(pdev, epnum);
return (uint8_t)USBD_OK;
}
/**
* @brief USBD_MSC_GetHSCfgDesc
* return configuration descriptor
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
uint8_t *USBD_MSC_GetHSCfgDesc(uint16_t *length)
{
*length = (uint16_t)sizeof(USBD_MSC_CfgHSDesc);
return USBD_MSC_CfgHSDesc;
}
/**
* @brief USBD_MSC_GetFSCfgDesc
* return configuration descriptor
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
uint8_t *USBD_MSC_GetFSCfgDesc(uint16_t *length)
{
*length = (uint16_t)sizeof(USBD_MSC_CfgFSDesc);
return USBD_MSC_CfgFSDesc;
}
/**
* @brief USBD_MSC_GetOtherSpeedCfgDesc
* return other speed configuration descriptor
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
uint8_t *USBD_MSC_GetOtherSpeedCfgDesc(uint16_t *length)
{
*length = (uint16_t)sizeof(USBD_MSC_OtherSpeedCfgDesc);
return USBD_MSC_OtherSpeedCfgDesc;
}
/**
* @brief DeviceQualifierDescriptor
* return Device Qualifier descriptor
* @param length : pointer data length
* @retval pointer to descriptor buffer
*/
uint8_t *USBD_MSC_GetDeviceQualifierDescriptor(uint16_t *length)
{
*length = (uint16_t)sizeof(USBD_MSC_DeviceQualifierDesc);
return USBD_MSC_DeviceQualifierDesc;
}
/**
* @brief USBD_MSC_RegisterStorage
* @param fops: storage callback
* @retval status
*/
uint8_t USBD_MSC_RegisterStorage(USBD_HandleTypeDef *pdev, USBD_StorageTypeDef *fops)
{
if (fops == NULL)
{
return (uint8_t)USBD_FAIL;
}
pdev->pUserData_MSC = fops;
return (uint8_t)USBD_OK;
}
void USBD_Update_MSC_DESC(uint8_t *desc, uint8_t itf_no, uint8_t in_ep, uint8_t out_ep, uint8_t str_idx)
{
desc[11] = itf_no;
desc[17] = str_idx;
desc[20] = in_ep;
desc[27] = out_ep;
MSC_IN_EP = in_ep;
MSC_OUT_EP = out_ep;
MSC_ITF_NBR = itf_no;
MSC_BOT_STR_DESC_IDX = str_idx;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,478 +1,435 @@
/** /**
****************************************************************************** ******************************************************************************
* @file usbd_msc_bot.c * @file usbd_msc_bot.c
* @author MCD Application Team * @author MCD Application Team
* @brief This file provides all the BOT protocol core functions. * @brief This file provides all the BOT protocol core functions.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2015 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
*/
/* BSPDependencies
- "stm32xxxxx_{eval}{discovery}{nucleo_144}.c" /* BSPDependencies
- "stm32xxxxx_{eval}{discovery}_io.c" - "stm32xxxxx_{eval}{discovery}{nucleo_144}.c"
- "stm32xxxxx_{eval}{discovery}{adafruit}_sd.c" - "stm32xxxxx_{eval}{discovery}_io.c"
EndBSPDependencies */ - "stm32xxxxx_{eval}{discovery}{adafruit}_sd.c"
EndBSPDependencies */
/* Includes ------------------------------------------------------------------*/
#include "usbd_msc_bot.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_msc.h" #include "usbd_msc_bot.h"
#include "usbd_msc_scsi.h" #include "usbd_msc.h"
#include "usbd_ioreq.h" #include "usbd_msc_scsi.h"
#include "usbd_ioreq.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{ /** @addtogroup STM32_USB_DEVICE_LIBRARY
*/ * @{
*/
/** @defgroup MSC_BOT
* @brief BOT protocol module /** @defgroup MSC_BOT
* @{ * @brief BOT protocol module
*/ * @{
*/
/** @defgroup MSC_BOT_Private_TypesDefinitions
* @{ /** @defgroup MSC_BOT_Private_TypesDefinitions
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup MSC_BOT_Private_Defines
* @{ /** @defgroup MSC_BOT_Private_Defines
*/ * @{
*/
/**
* @} /**
*/ * @}
*/
/** @defgroup MSC_BOT_Private_Macros
* @{ /** @defgroup MSC_BOT_Private_Macros
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup MSC_BOT_Private_Variables
* @{ /** @defgroup MSC_BOT_Private_Variables
*/ * @{
extern uint8_t MSCInEpAdd; */
extern uint8_t MSCOutEpAdd;
/** /**
* @} * @}
*/ */
/** @defgroup MSC_BOT_Private_FunctionPrototypes /** @defgroup MSC_BOT_Private_FunctionPrototypes
* @{ * @{
*/ */
static void MSC_BOT_SendData(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint32_t len); static void MSC_BOT_SendData(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint32_t len);
static void MSC_BOT_CBW_Decode(USBD_HandleTypeDef *pdev); static void MSC_BOT_CBW_Decode(USBD_HandleTypeDef *pdev);
static void MSC_BOT_Abort(USBD_HandleTypeDef *pdev); static void MSC_BOT_Abort(USBD_HandleTypeDef *pdev);
/** /**
* @} * @}
*/ */
/** @defgroup MSC_BOT_Private_Functions /** @defgroup MSC_BOT_Private_Functions
* @{ * @{
*/ */
/** /**
* @brief MSC_BOT_Init * @brief MSC_BOT_Init
* Initialize the BOT Process * Initialize the BOT Process
* @param pdev: device instance * @param pdev: device instance
* @retval None * @retval None
*/ */
void MSC_BOT_Init(USBD_HandleTypeDef *pdev) void MSC_BOT_Init(USBD_HandleTypeDef *pdev)
{ {
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId]; USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData_MSC;
#ifdef USE_USBD_COMPOSITE if (hmsc == NULL)
/* Get the Endpoints addresses allocated for this class instance */ {
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId); return;
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId); }
#endif /* USE_USBD_COMPOSITE */
hmsc->bot_state = USBD_BOT_IDLE;
if (hmsc == NULL) hmsc->bot_status = USBD_BOT_STATUS_NORMAL;
{
return; hmsc->scsi_sense_tail = 0U;
} hmsc->scsi_sense_head = 0U;
hmsc->scsi_medium_state = SCSI_MEDIUM_UNLOCKED;
hmsc->bot_state = USBD_BOT_IDLE;
hmsc->bot_status = USBD_BOT_STATUS_NORMAL; ((USBD_StorageTypeDef *)pdev->pUserData_MSC)->Init(0U);
hmsc->scsi_sense_tail = 0U; (void)USBD_LL_FlushEP(pdev, MSC_OUT_EP);
hmsc->scsi_sense_head = 0U; (void)USBD_LL_FlushEP(pdev, MSC_IN_EP);
hmsc->scsi_medium_state = SCSI_MEDIUM_UNLOCKED;
/* Prepare EP to Receive First BOT Cmd */
((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->Init(0U); (void)USBD_LL_PrepareReceive(pdev, MSC_OUT_EP, (uint8_t *)&hmsc->cbw,
USBD_BOT_CBW_LENGTH);
(void)USBD_LL_FlushEP(pdev, MSCOutEpAdd); }
(void)USBD_LL_FlushEP(pdev, MSCInEpAdd);
/**
/* Prepare EP to Receive First BOT Cmd */ * @brief MSC_BOT_Reset
(void)USBD_LL_PrepareReceive(pdev, MSCOutEpAdd, (uint8_t *)&hmsc->cbw, * Reset the BOT Machine
USBD_BOT_CBW_LENGTH); * @param pdev: device instance
} * @retval None
*/
/** void MSC_BOT_Reset(USBD_HandleTypeDef *pdev)
* @brief MSC_BOT_Reset {
* Reset the BOT Machine USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData_MSC;
* @param pdev: device instance
* @retval None if (hmsc == NULL)
*/ {
void MSC_BOT_Reset(USBD_HandleTypeDef *pdev) return;
{ }
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
hmsc->bot_state = USBD_BOT_IDLE;
#ifdef USE_USBD_COMPOSITE hmsc->bot_status = USBD_BOT_STATUS_RECOVERY;
/* Get the Endpoints addresses allocated for this class instance */
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId); (void)USBD_LL_ClearStallEP(pdev, MSC_IN_EP);
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId); (void)USBD_LL_ClearStallEP(pdev, MSC_OUT_EP);
#endif /* USE_USBD_COMPOSITE */
/* Prepare EP to Receive First BOT Cmd */
if (hmsc == NULL) (void)USBD_LL_PrepareReceive(pdev, MSC_OUT_EP, (uint8_t *)&hmsc->cbw,
{ USBD_BOT_CBW_LENGTH);
return; }
}
/**
hmsc->bot_state = USBD_BOT_IDLE; * @brief MSC_BOT_DeInit
hmsc->bot_status = USBD_BOT_STATUS_RECOVERY; * DeInitialize the BOT Machine
* @param pdev: device instance
(void)USBD_LL_ClearStallEP(pdev, MSCInEpAdd); * @retval None
(void)USBD_LL_ClearStallEP(pdev, MSCOutEpAdd); */
void MSC_BOT_DeInit(USBD_HandleTypeDef *pdev)
/* Prepare EP to Receive First BOT Cmd */ {
(void)USBD_LL_PrepareReceive(pdev, MSCOutEpAdd, (uint8_t *)&hmsc->cbw, USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData_MSC;
USBD_BOT_CBW_LENGTH);
} if (hmsc != NULL)
{
/** hmsc->bot_state = USBD_BOT_IDLE;
* @brief MSC_BOT_DeInit }
* DeInitialize the BOT Machine }
* @param pdev: device instance
* @retval None /**
*/ * @brief MSC_BOT_DataIn
void MSC_BOT_DeInit(USBD_HandleTypeDef *pdev) * Handle BOT IN data stage
{ * @param pdev: device instance
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId]; * @param epnum: endpoint index
* @retval None
if (hmsc != NULL) */
{ void MSC_BOT_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
hmsc->bot_state = USBD_BOT_IDLE; {
} UNUSED(epnum);
}
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData_MSC;
/**
* @brief MSC_BOT_DataIn if (hmsc == NULL)
* Handle BOT IN data stage {
* @param pdev: device instance return;
* @param epnum: endpoint index }
* @retval None
*/ switch (hmsc->bot_state)
void MSC_BOT_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum) {
{ case USBD_BOT_DATA_IN:
UNUSED(epnum); if (SCSI_ProcessCmd(pdev, hmsc->cbw.bLUN, &hmsc->cbw.CB[0]) < 0)
{
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId]; MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_FAILED);
}
if (hmsc == NULL) break;
{
return; case USBD_BOT_SEND_DATA:
} case USBD_BOT_LAST_DATA_IN:
MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_PASSED);
switch (hmsc->bot_state) break;
{
case USBD_BOT_DATA_IN: default:
if (SCSI_ProcessCmd(pdev, hmsc->cbw.bLUN, &hmsc->cbw.CB[0]) < 0) break;
{ }
MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_FAILED); }
} /**
break; * @brief MSC_BOT_DataOut
* Process MSC OUT data
case USBD_BOT_SEND_DATA: * @param pdev: device instance
case USBD_BOT_LAST_DATA_IN: * @param epnum: endpoint index
MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_PASSED); * @retval None
break; */
void MSC_BOT_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
default: {
break; UNUSED(epnum);
}
} USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData_MSC;
/**
* @brief MSC_BOT_DataOut if (hmsc == NULL)
* Process MSC OUT data {
* @param pdev: device instance return;
* @param epnum: endpoint index }
* @retval None
*/ switch (hmsc->bot_state)
void MSC_BOT_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum) {
{ case USBD_BOT_IDLE:
UNUSED(epnum); MSC_BOT_CBW_Decode(pdev);
break;
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
case USBD_BOT_DATA_OUT:
if (hmsc == NULL) if (SCSI_ProcessCmd(pdev, hmsc->cbw.bLUN, &hmsc->cbw.CB[0]) < 0)
{ {
return; MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_FAILED);
} }
break;
switch (hmsc->bot_state)
{ default:
case USBD_BOT_IDLE: break;
MSC_BOT_CBW_Decode(pdev); }
break; }
case USBD_BOT_DATA_OUT: /**
if (SCSI_ProcessCmd(pdev, hmsc->cbw.bLUN, &hmsc->cbw.CB[0]) < 0) * @brief MSC_BOT_CBW_Decode
{ * Decode the CBW command and set the BOT state machine accordingly
MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_FAILED); * @param pdev: device instance
} * @retval None
break; */
static void MSC_BOT_CBW_Decode(USBD_HandleTypeDef *pdev)
default: {
break; USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData_MSC;
}
} if (hmsc == NULL)
{
/** return;
* @brief MSC_BOT_CBW_Decode }
* Decode the CBW command and set the BOT state machine accordingly
* @param pdev: device instance hmsc->csw.dTag = hmsc->cbw.dTag;
* @retval None hmsc->csw.dDataResidue = hmsc->cbw.dDataLength;
*/
static void MSC_BOT_CBW_Decode(USBD_HandleTypeDef *pdev) if ((USBD_LL_GetRxDataSize(pdev, MSC_OUT_EP) != USBD_BOT_CBW_LENGTH) ||
{ (hmsc->cbw.dSignature != USBD_BOT_CBW_SIGNATURE) ||
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId]; (hmsc->cbw.bLUN > 1U) || (hmsc->cbw.bCBLength < 1U) ||
(hmsc->cbw.bCBLength > 16U))
#ifdef USE_USBD_COMPOSITE {
/* Get the Endpoints addresses allocated for this class instance */ SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST, INVALID_CDB);
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId); hmsc->bot_status = USBD_BOT_STATUS_ERROR;
#endif /* USE_USBD_COMPOSITE */ MSC_BOT_Abort(pdev);
}
if (hmsc == NULL) else
{ {
return; if (SCSI_ProcessCmd(pdev, hmsc->cbw.bLUN, &hmsc->cbw.CB[0]) < 0)
} {
if (hmsc->bot_state == USBD_BOT_NO_DATA)
hmsc->csw.dTag = hmsc->cbw.dTag; {
hmsc->csw.dDataResidue = hmsc->cbw.dDataLength; MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_FAILED);
}
if ((USBD_LL_GetRxDataSize(pdev, MSCOutEpAdd) != USBD_BOT_CBW_LENGTH) || else
(hmsc->cbw.dSignature != USBD_BOT_CBW_SIGNATURE) || {
(hmsc->cbw.bLUN > 1U) || (hmsc->cbw.bCBLength < 1U) || MSC_BOT_Abort(pdev);
(hmsc->cbw.bCBLength > 16U)) }
{ }
SCSI_SenseCode(pdev, hmsc->cbw.bLUN, ILLEGAL_REQUEST, INVALID_CDB); /* Burst xfer handled internally */
else if ((hmsc->bot_state != USBD_BOT_DATA_IN) &&
hmsc->bot_status = USBD_BOT_STATUS_ERROR; (hmsc->bot_state != USBD_BOT_DATA_OUT) &&
MSC_BOT_Abort(pdev); (hmsc->bot_state != USBD_BOT_LAST_DATA_IN))
} {
else if (hmsc->bot_data_length > 0U)
{ {
if (SCSI_ProcessCmd(pdev, hmsc->cbw.bLUN, &hmsc->cbw.CB[0]) < 0) MSC_BOT_SendData(pdev, hmsc->bot_data, hmsc->bot_data_length);
{ }
if (hmsc->bot_state == USBD_BOT_NO_DATA) else if (hmsc->bot_data_length == 0U)
{ {
MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_FAILED); MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_PASSED);
} }
else else
{ {
MSC_BOT_Abort(pdev); MSC_BOT_Abort(pdev);
} }
} }
/* Burst xfer handled internally */ else
else if ((hmsc->bot_state != USBD_BOT_DATA_IN) && {
(hmsc->bot_state != USBD_BOT_DATA_OUT) && return;
(hmsc->bot_state != USBD_BOT_LAST_DATA_IN)) }
{ }
if (hmsc->bot_data_length > 0U) }
{
MSC_BOT_SendData(pdev, hmsc->bot_data, hmsc->bot_data_length); /**
} * @brief MSC_BOT_SendData
else if (hmsc->bot_data_length == 0U) * Send the requested data
{ * @param pdev: device instance
MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_PASSED); * @param buf: pointer to data buffer
} * @param len: Data Length
else * @retval None
{ */
MSC_BOT_Abort(pdev); static void MSC_BOT_SendData(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint32_t len)
} {
} USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData_MSC;
else
{ uint32_t length = MIN(hmsc->cbw.dDataLength, len);
return;
} if (hmsc == NULL)
} {
} return;
}
/**
* @brief MSC_BOT_SendData hmsc->csw.dDataResidue -= len;
* Send the requested data hmsc->csw.bStatus = USBD_CSW_CMD_PASSED;
* @param pdev: device instance hmsc->bot_state = USBD_BOT_SEND_DATA;
* @param buf: pointer to data buffer
* @param len: Data Length (void)USBD_LL_Transmit(pdev, MSC_IN_EP, pbuf, length);
* @retval None }
*/
static void MSC_BOT_SendData(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint32_t len) /**
{ * @brief MSC_BOT_SendCSW
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId]; * Send the Command Status Wrapper
* @param pdev: device instance
uint32_t length; * @param status : CSW status
* @retval None
#ifdef USE_USBD_COMPOSITE */
/* Get the Endpoints addresses allocated for this class instance */ void MSC_BOT_SendCSW(USBD_HandleTypeDef *pdev, uint8_t CSW_Status)
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId); {
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId); USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData_MSC;
#endif /* USE_USBD_COMPOSITE */
if (hmsc == NULL)
if (hmsc == NULL) {
{ return;
return; }
}
hmsc->csw.dSignature = USBD_BOT_CSW_SIGNATURE;
length = MIN(hmsc->cbw.dDataLength, len); hmsc->csw.bStatus = CSW_Status;
hmsc->bot_state = USBD_BOT_IDLE;
hmsc->csw.dDataResidue -= len;
hmsc->csw.bStatus = USBD_CSW_CMD_PASSED; (void)USBD_LL_Transmit(pdev, MSC_IN_EP, (uint8_t *)&hmsc->csw,
hmsc->bot_state = USBD_BOT_SEND_DATA; USBD_BOT_CSW_LENGTH);
(void)USBD_LL_Transmit(pdev, MSCInEpAdd, pbuf, length); /* Prepare EP to Receive next Cmd */
} (void)USBD_LL_PrepareReceive(pdev, MSC_OUT_EP, (uint8_t *)&hmsc->cbw,
USBD_BOT_CBW_LENGTH);
/** }
* @brief MSC_BOT_SendCSW
* Send the Command Status Wrapper /**
* @param pdev: device instance * @brief MSC_BOT_Abort
* @param status : CSW status * Abort the current transfer
* @retval None * @param pdev: device instance
*/ * @retval status
void MSC_BOT_SendCSW(USBD_HandleTypeDef *pdev, uint8_t CSW_Status) */
{
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId]; static void MSC_BOT_Abort(USBD_HandleTypeDef *pdev)
{
#ifdef USE_USBD_COMPOSITE USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData_MSC;
/* Get the Endpoints addresses allocated for this class instance */
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId); if (hmsc == NULL)
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId); {
#endif /* USE_USBD_COMPOSITE */ return;
}
if (hmsc == NULL)
{ if ((hmsc->cbw.bmFlags == 0U) &&
return; (hmsc->cbw.dDataLength != 0U) &&
} (hmsc->bot_status == USBD_BOT_STATUS_NORMAL))
{
hmsc->csw.dSignature = USBD_BOT_CSW_SIGNATURE; (void)USBD_LL_StallEP(pdev, MSC_OUT_EP);
hmsc->csw.bStatus = CSW_Status; }
hmsc->bot_state = USBD_BOT_IDLE;
(void)USBD_LL_StallEP(pdev, MSC_IN_EP);
(void)USBD_LL_Transmit(pdev, MSCInEpAdd, (uint8_t *)&hmsc->csw,
USBD_BOT_CSW_LENGTH); if (hmsc->bot_status == USBD_BOT_STATUS_ERROR)
{
/* Prepare EP to Receive next Cmd */ (void)USBD_LL_StallEP(pdev, MSC_IN_EP);
(void)USBD_LL_PrepareReceive(pdev, MSCOutEpAdd, (uint8_t *)&hmsc->cbw, (void)USBD_LL_StallEP(pdev, MSC_OUT_EP);
USBD_BOT_CBW_LENGTH); }
} }
/** /**
* @brief MSC_BOT_Abort * @brief MSC_BOT_CplClrFeature
* Abort the current transfer * Complete the clear feature request
* @param pdev: device instance * @param pdev: device instance
* @retval status * @param epnum: endpoint index
*/ * @retval None
*/
static void MSC_BOT_Abort(USBD_HandleTypeDef *pdev)
{ void MSC_BOT_CplClrFeature(USBD_HandleTypeDef *pdev, uint8_t epnum)
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId]; {
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassData_MSC;
#ifdef USE_USBD_COMPOSITE
/* Get the Endpoints addresses allocated for this class instance */ if (hmsc == NULL)
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId); {
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId); return;
#endif /* USE_USBD_COMPOSITE */ }
if (hmsc == NULL) if (hmsc->bot_status == USBD_BOT_STATUS_ERROR) /* Bad CBW Signature */
{ {
return; (void)USBD_LL_StallEP(pdev, MSC_IN_EP);
} (void)USBD_LL_StallEP(pdev, MSC_OUT_EP);
}
if ((hmsc->cbw.bmFlags == 0U) && else if (((epnum & 0x80U) == 0x80U) && (hmsc->bot_status != USBD_BOT_STATUS_RECOVERY))
(hmsc->cbw.dDataLength != 0U) && {
(hmsc->bot_status == USBD_BOT_STATUS_NORMAL)) MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_FAILED);
{ }
(void)USBD_LL_StallEP(pdev, MSCOutEpAdd); else
} {
return;
(void)USBD_LL_StallEP(pdev, MSCInEpAdd); }
}
if (hmsc->bot_status == USBD_BOT_STATUS_ERROR) /**
{ * @}
(void)USBD_LL_StallEP(pdev, MSCInEpAdd); */
(void)USBD_LL_StallEP(pdev, MSCOutEpAdd);
}
} /**
* @}
/** */
* @brief MSC_BOT_CplClrFeature
* Complete the clear feature request
* @param pdev: device instance /**
* @param epnum: endpoint index * @}
* @retval None */
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
void MSC_BOT_CplClrFeature(USBD_HandleTypeDef *pdev, uint8_t epnum)
{
USBD_MSC_BOT_HandleTypeDef *hmsc = (USBD_MSC_BOT_HandleTypeDef *)pdev->pClassDataCmsit[pdev->classId];
#ifdef USE_USBD_COMPOSITE
/* Get the Endpoints addresses allocated for this class instance */
MSCInEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_IN, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
MSCOutEpAdd = USBD_CoreGetEPAdd(pdev, USBD_EP_OUT, USBD_EP_TYPE_BULK, (uint8_t)pdev->classId);
#endif /* USE_USBD_COMPOSITE */
if (hmsc == NULL)
{
return;
}
if (hmsc->bot_status == USBD_BOT_STATUS_ERROR) /* Bad CBW Signature */
{
(void)USBD_LL_StallEP(pdev, MSCInEpAdd);
(void)USBD_LL_StallEP(pdev, MSCOutEpAdd);
}
else if (((epnum & 0x80U) == 0x80U) && (hmsc->bot_status != USBD_BOT_STATUS_RECOVERY))
{
MSC_BOT_SendCSW(pdev, USBD_CSW_CMD_FAILED);
}
else
{
return;
}
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/

View File

@ -1,181 +1,183 @@
/** /**
****************************************************************************** ******************************************************************************
* @file usbd_msc_data.c * @file usbd_msc_data.c
* @author MCD Application Team * @author MCD Application Team
* @brief This file provides all the vital inquiry pages and sense data. * @brief This file provides all the vital inquiry pages and sense data.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2015 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
*/
/* BSPDependencies
- "stm32xxxxx_{eval}{discovery}{nucleo_144}.c" /* BSPDependencies
- "stm32xxxxx_{eval}{discovery}_io.c" - "stm32xxxxx_{eval}{discovery}{nucleo_144}.c"
- "stm32xxxxx_{eval}{discovery}{adafruit}_sd.c" - "stm32xxxxx_{eval}{discovery}_io.c"
EndBSPDependencies */ - "stm32xxxxx_{eval}{discovery}{adafruit}_sd.c"
EndBSPDependencies */
/* Includes ------------------------------------------------------------------*/
#include "usbd_msc_data.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_msc_data.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{ /** @addtogroup STM32_USB_DEVICE_LIBRARY
*/ * @{
*/
/** @defgroup MSC_DATA
* @brief Mass storage info/data module /** @defgroup MSC_DATA
* @{ * @brief Mass storage info/data module
*/ * @{
*/
/** @defgroup MSC_DATA_Private_TypesDefinitions
* @{ /** @defgroup MSC_DATA_Private_TypesDefinitions
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup MSC_DATA_Private_Defines
* @{ /** @defgroup MSC_DATA_Private_Defines
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup MSC_DATA_Private_Macros
* @{ /** @defgroup MSC_DATA_Private_Macros
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup MSC_DATA_Private_Variables
* @{ /** @defgroup MSC_DATA_Private_Variables
*/ * @{
*/
/* USB Mass storage Page 0 Inquiry Data */
uint8_t MSC_Page00_Inquiry_Data[LENGTH_INQUIRY_PAGE00] = /* USB Mass storage Page 0 Inquiry Data */
{ uint8_t MSC_Page00_Inquiry_Data[LENGTH_INQUIRY_PAGE00] =
0x00, {
0x00, 0x00,
0x00, 0x00,
(LENGTH_INQUIRY_PAGE00 - 4U), 0x00,
0x00, (LENGTH_INQUIRY_PAGE00 - 4U),
0x80 0x00,
}; 0x80
};
/* USB Mass storage VPD Page 0x80 Inquiry Data for Unit Serial Number */
uint8_t MSC_Page80_Inquiry_Data[LENGTH_INQUIRY_PAGE80] = /* USB Mass storage VPD Page 0x80 Inquiry Data for Unit Serial Number */
{ uint8_t MSC_Page80_Inquiry_Data[LENGTH_INQUIRY_PAGE80] =
0x00, {
0x80, 0x00,
0x00, 0x80,
LENGTH_INQUIRY_PAGE80, 0x00,
0x20, /* Put Product Serial number */ LENGTH_INQUIRY_PAGE80,
0x20, 0x20, /* Put Product Serial number */
0x20, 0x20,
0x20 0x20,
}; 0x20
};
/* USB Mass storage sense 6 Data */
uint8_t MSC_Mode_Sense6_data[MODE_SENSE6_LEN] = /* USB Mass storage sense 6 Data */
{ uint8_t MSC_Mode_Sense6_data[MODE_SENSE6_LEN] =
0x22, {
0x00, 0x22,
0x00, 0x00,
0x00, 0x00,
0x08, 0x00,
0x12, 0x08,
0x00, 0x12,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00 0x00,
}; 0x00
};
/* USB Mass storage sense 10 Data */
uint8_t MSC_Mode_Sense10_data[MODE_SENSE10_LEN] = /* USB Mass storage sense 10 Data */
{ uint8_t MSC_Mode_Sense10_data[MODE_SENSE10_LEN] =
0x00, {
0x26, 0x00,
0x00, 0x26,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x08, 0x00,
0x12, 0x08,
0x00, 0x12,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00 0x00,
}; 0x00
/** };
* @} /**
*/ * @}
*/
/** @defgroup MSC_DATA_Private_FunctionPrototypes
* @{ /** @defgroup MSC_DATA_Private_FunctionPrototypes
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup MSC_DATA_Private_Functions
* @{ /** @defgroup MSC_DATA_Private_Functions
*/ * @{
*/
/**
* @} /**
*/ * @}
*/
/**
* @} /**
*/ * @}
*/
/**
* @} /**
*/ * @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,172 +1,158 @@
/** /**
****************************************************************************** ******************************************************************************
* @file usbd_core.h * @file usbd_core.h
* @author MCD Application Team * @author MCD Application Team
* @brief Header file for usbd_core.c file * @brief Header file for usbd_core.c file
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2015 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_CORE_H /* Define to prevent recursive inclusion -------------------------------------*/
#define __USBD_CORE_H #ifndef __USBD_CORE_H
#define __USBD_CORE_H
#ifdef __cplusplus
extern "C" { #ifdef __cplusplus
#endif extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_conf.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_def.h" #include "usbd_conf.h"
#include "usbd_ioreq.h" #include "usbd_def.h"
#include "usbd_ctlreq.h" #include "usbd_ioreq.h"
#include "usbd_ctlreq.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{ /** @addtogroup STM32_USB_DEVICE_LIBRARY
*/ * @{
*/
/** @defgroup USBD_CORE
* @brief This file is the Header file for usbd_core.c file /** @defgroup USBD_CORE
* @{ * @brief This file is the Header file for usbd_core.c file
*/ * @{
*/
/** @defgroup USBD_CORE_Exported_Defines
* @{ /** @defgroup USBD_CORE_Exported_Defines
*/ * @{
#ifndef USBD_DEBUG_LEVEL */
#define USBD_DEBUG_LEVEL 0U #ifndef USBD_DEBUG_LEVEL
#endif /* USBD_DEBUG_LEVEL */ #define USBD_DEBUG_LEVEL 0U
/** #endif /* USBD_DEBUG_LEVEL */
* @} /**
*/ * @}
*/
/** @defgroup USBD_CORE_Exported_TypesDefinitions
* @{ /** @defgroup USBD_CORE_Exported_TypesDefinitions
*/ * @{
*/
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_CORE_Exported_Macros
* @{ /** @defgroup USBD_CORE_Exported_Macros
*/ * @{
*/
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_CORE_Exported_Variables
* @{ /** @defgroup USBD_CORE_Exported_Variables
*/ * @{
#define USBD_SOF USBD_LL_SOF */
/** #define USBD_SOF USBD_LL_SOF
* @} /**
*/ * @}
*/
/** @defgroup USBD_CORE_Exported_FunctionsPrototype
* @{ /** @defgroup USBD_CORE_Exported_FunctionsPrototype
*/ * @{
USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id); */
USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev); USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id);
USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev); USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev); USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass); USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass);
#ifdef USE_USBD_COMPOSITE
USBD_StatusTypeDef USBD_RegisterClassComposite(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass, USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev);
USBD_CompositeClassTypeDef classtype, uint8_t *EpAddr); USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
USBD_StatusTypeDef USBD_UnRegisterClassComposite(USBD_HandleTypeDef *pdev);
uint8_t USBD_CoreGetEPAdd(USBD_HandleTypeDef *pdev, uint8_t ep_dir, uint8_t ep_type, uint8_t ClassId); USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup);
#endif /* USE_USBD_COMPOSITE */ USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata);
USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata);
uint8_t USBD_CoreFindIF(USBD_HandleTypeDef *pdev, uint8_t index);
uint8_t USBD_CoreFindEP(USBD_HandleTypeDef *pdev, uint8_t index); USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed);
USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev); USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx); USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup); USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata); USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata);
USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev); USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed);
USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev); /* USBD Low Level Driver */
USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev); USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev); USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum); USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev); uint8_t ep_type, uint16_t ep_mps);
USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
/* USBD Low Level Driver */ USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev); USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev); USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev); USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr);
USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size);
uint8_t ep_type, uint16_t ep_mps);
USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); uint8_t *pbuf, uint32_t size);
USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr); uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr);
void USBD_LL_Delay(uint32_t Delay);
USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr,
uint8_t *pbuf, uint32_t size); /**
* @}
USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, */
uint8_t *pbuf, uint32_t size);
#ifdef __cplusplus
#ifdef USBD_HS_TESTMODE_ENABLE }
USBD_StatusTypeDef USBD_LL_SetTestMode(USBD_HandleTypeDef *pdev, uint8_t testmode); #endif
#endif /* USBD_HS_TESTMODE_ENABLE */
#endif /* __USBD_CORE_H */
uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr); /**
* @}
void USBD_LL_Delay(uint32_t Delay); */
void *USBD_GetEpDesc(uint8_t *pConfDesc, uint8_t EpAddr); /**
USBD_DescHeaderTypeDef *USBD_GetNextDesc(uint8_t *pbuf, uint16_t *ptr); * @}
*/
/**
* @} /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
*/
#ifdef __cplusplus
}
#endif
#endif /* __USBD_CORE_H */
/**
* @}
*/
/**
* @}
*/

View File

@ -1,101 +1,103 @@
/** /**
****************************************************************************** ******************************************************************************
* @file usbd_req.h * @file usbd_req.h
* @author MCD Application Team * @author MCD Application Team
* @brief Header file for the usbd_req.c file * @brief Header file for the usbd_req.c file
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2015 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_REQUEST_H /* Define to prevent recursive inclusion -------------------------------------*/
#define __USB_REQUEST_H #ifndef __USB_REQUEST_H
#define __USB_REQUEST_H
#ifdef __cplusplus
extern "C" { #ifdef __cplusplus
#endif extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_def.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_def.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{ /** @addtogroup STM32_USB_DEVICE_LIBRARY
*/ * @{
*/
/** @defgroup USBD_REQ
* @brief header file for the usbd_req.c file /** @defgroup USBD_REQ
* @{ * @brief header file for the usbd_req.c file
*/ * @{
*/
/** @defgroup USBD_REQ_Exported_Defines
* @{ /** @defgroup USBD_REQ_Exported_Defines
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup USBD_REQ_Exported_Types
* @{ /** @defgroup USBD_REQ_Exported_Types
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup USBD_REQ_Exported_Macros
* @{ /** @defgroup USBD_REQ_Exported_Macros
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup USBD_REQ_Exported_Variables
* @{ /** @defgroup USBD_REQ_Exported_Variables
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup USBD_REQ_Exported_FunctionsPrototype
* @{ /** @defgroup USBD_REQ_Exported_FunctionsPrototype
*/ * @{
*/
USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata); void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len); void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata);
void USBD_GetString(uint8_t *desc, uint8_t *unicode, uint16_t *len);
/**
* @} /**
*/ * @}
*/
#ifdef __cplusplus
} #ifdef __cplusplus
#endif }
#endif
#endif /* __USB_REQUEST_H */
#endif /* __USB_REQUEST_H */
/**
* @} /**
*/ * @}
*/
/**
* @} /**
*/ * @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,516 +1,439 @@
/** /**
****************************************************************************** ******************************************************************************
* @file usbd_def.h * @file usbd_def.h
* @author MCD Application Team * @author MCD Application Team
* @brief General defines for the usb device library * @brief General defines for the usb device library
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2015 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_DEF_H /* Define to prevent recursive inclusion -------------------------------------*/
#define __USBD_DEF_H #ifndef __USBD_DEF_H
#define __USBD_DEF_H
#ifdef __cplusplus
extern "C" { #ifdef __cplusplus
#endif extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_conf.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_conf.h"
/** @addtogroup STM32_USBD_DEVICE_LIBRARY
* @{ /** @addtogroup STM32_USBD_DEVICE_LIBRARY
*/ * @{
*/
/** @defgroup USB_DEF
* @brief general defines for the usb device library file /** @defgroup USB_DEF
* @{ * @brief general defines for the usb device library file
*/ * @{
*/
/** @defgroup USB_DEF_Exported_Defines
* @{ /** @defgroup USB_DEF_Exported_Defines
*/ * @{
*/
#ifndef NULL
#define NULL 0U #ifndef NULL
#endif /* NULL */ #define NULL 0U
#endif /* NULL */
#ifndef USBD_MAX_NUM_INTERFACES
#define USBD_MAX_NUM_INTERFACES 1U #ifndef USBD_MAX_NUM_INTERFACES
#endif /* USBD_MAX_NUM_CONFIGURATION */ #define USBD_MAX_NUM_INTERFACES 1U
#endif /* USBD_MAX_NUM_CONFIGURATION */
#ifndef USBD_MAX_NUM_CONFIGURATION
#define USBD_MAX_NUM_CONFIGURATION 1U #ifndef USBD_MAX_NUM_CONFIGURATION
#endif /* USBD_MAX_NUM_CONFIGURATION */ #define USBD_MAX_NUM_CONFIGURATION 1U
#endif /* USBD_MAX_NUM_CONFIGURATION */
#ifdef USE_USBD_COMPOSITE
#ifndef USBD_MAX_SUPPORTED_CLASS #ifndef USBD_LPM_ENABLED
#define USBD_MAX_SUPPORTED_CLASS 4U #define USBD_LPM_ENABLED 0U
#endif /* USBD_MAX_SUPPORTED_CLASS */ #endif /* USBD_LPM_ENABLED */
#else
#ifndef USBD_MAX_SUPPORTED_CLASS #ifndef USBD_SELF_POWERED
#define USBD_MAX_SUPPORTED_CLASS 1U #define USBD_SELF_POWERED 1U
#endif /* USBD_MAX_SUPPORTED_CLASS */ #endif /*USBD_SELF_POWERED */
#endif /* USE_USBD_COMPOSITE */
#ifndef USBD_MAX_POWER
#ifndef USBD_MAX_CLASS_ENDPOINTS #define USBD_MAX_POWER 0x32U /* 100 mA */
#define USBD_MAX_CLASS_ENDPOINTS 5U #endif /* USBD_MAX_POWER */
#endif /* USBD_MAX_CLASS_ENDPOINTS */
#ifndef USBD_SUPPORT_USER_STRING_DESC
#ifndef USBD_MAX_CLASS_INTERFACES #define USBD_SUPPORT_USER_STRING_DESC 0U
#define USBD_MAX_CLASS_INTERFACES 5U #endif /* USBD_SUPPORT_USER_STRING_DESC */
#endif /* USBD_MAX_CLASS_INTERFACES */
#ifndef USBD_CLASS_USER_STRING_DESC
#ifndef USBD_LPM_ENABLED #define USBD_CLASS_USER_STRING_DESC 0U
#define USBD_LPM_ENABLED 0U #endif /* USBD_CLASS_USER_STRING_DESC */
#endif /* USBD_LPM_ENABLED */
#define USB_LEN_DEV_QUALIFIER_DESC 0x0AU
#ifndef USBD_SELF_POWERED #define USB_LEN_DEV_DESC 0x12U
#define USBD_SELF_POWERED 1U #define USB_LEN_CFG_DESC 0x09U
#endif /*USBD_SELF_POWERED */ #define USB_LEN_IF_DESC 0x09U
#define USB_LEN_EP_DESC 0x07U
#ifndef USBD_MAX_POWER #define USB_LEN_OTG_DESC 0x03U
#define USBD_MAX_POWER 0x32U /* 100 mA */ #define USB_LEN_LANGID_STR_DESC 0x04U
#endif /* USBD_MAX_POWER */ #define USB_LEN_OTHER_SPEED_DESC_SIZ 0x09U
#ifndef USBD_SUPPORT_USER_STRING_DESC #define USBD_IDX_LANGID_STR 0x00U
#define USBD_SUPPORT_USER_STRING_DESC 0U #define USBD_IDX_MFC_STR 0x01U
#endif /* USBD_SUPPORT_USER_STRING_DESC */ #define USBD_IDX_PRODUCT_STR 0x02U
#define USBD_IDX_SERIAL_STR 0x03U
#ifndef USBD_CLASS_USER_STRING_DESC #define USBD_IDX_CONFIG_STR 0x04U
#define USBD_CLASS_USER_STRING_DESC 0U #define USBD_IDX_INTERFACE_STR 0x05U
#endif /* USBD_CLASS_USER_STRING_DESC */
#define USB_REQ_TYPE_STANDARD 0x00U
#define USB_LEN_DEV_QUALIFIER_DESC 0x0AU #define USB_REQ_TYPE_CLASS 0x20U
#define USB_LEN_DEV_DESC 0x12U #define USB_REQ_TYPE_VENDOR 0x40U
#define USB_LEN_CFG_DESC 0x09U #define USB_REQ_TYPE_MASK 0x60U
#define USB_LEN_IF_DESC 0x09U
#define USB_LEN_EP_DESC 0x07U #define USB_REQ_RECIPIENT_DEVICE 0x00U
#define USB_LEN_OTG_DESC 0x03U #define USB_REQ_RECIPIENT_INTERFACE 0x01U
#define USB_LEN_LANGID_STR_DESC 0x04U #define USB_REQ_RECIPIENT_ENDPOINT 0x02U
#define USB_LEN_OTHER_SPEED_DESC_SIZ 0x09U #define USB_REQ_RECIPIENT_MASK 0x03U
#define USBD_IDX_LANGID_STR 0x00U #define USB_REQ_GET_STATUS 0x00U
#define USBD_IDX_MFC_STR 0x01U #define USB_REQ_CLEAR_FEATURE 0x01U
#define USBD_IDX_PRODUCT_STR 0x02U #define USB_REQ_SET_FEATURE 0x03U
#define USBD_IDX_SERIAL_STR 0x03U #define USB_REQ_SET_ADDRESS 0x05U
#define USBD_IDX_CONFIG_STR 0x04U #define USB_REQ_GET_DESCRIPTOR 0x06U
#define USBD_IDX_INTERFACE_STR 0x05U #define USB_REQ_SET_DESCRIPTOR 0x07U
#define USB_REQ_GET_CONFIGURATION 0x08U
#define USB_REQ_TYPE_STANDARD 0x00U #define USB_REQ_SET_CONFIGURATION 0x09U
#define USB_REQ_TYPE_CLASS 0x20U #define USB_REQ_GET_INTERFACE 0x0AU
#define USB_REQ_TYPE_VENDOR 0x40U #define USB_REQ_SET_INTERFACE 0x0BU
#define USB_REQ_TYPE_MASK 0x60U #define USB_REQ_SYNCH_FRAME 0x0CU
#define USB_REQ_RECIPIENT_DEVICE 0x00U #define USB_DESC_TYPE_DEVICE 0x01U
#define USB_REQ_RECIPIENT_INTERFACE 0x01U #define USB_DESC_TYPE_CONFIGURATION 0x02U
#define USB_REQ_RECIPIENT_ENDPOINT 0x02U #define USB_DESC_TYPE_STRING 0x03U
#define USB_REQ_RECIPIENT_MASK 0x03U #define USB_DESC_TYPE_INTERFACE 0x04U
#define USB_DESC_TYPE_ENDPOINT 0x05U
#define USB_REQ_GET_STATUS 0x00U #define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06U
#define USB_REQ_CLEAR_FEATURE 0x01U #define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07U
#define USB_REQ_SET_FEATURE 0x03U #define USB_DESC_TYPE_IAD 0x0BU
#define USB_REQ_SET_ADDRESS 0x05U #define USB_DESC_TYPE_BOS 0x0FU
#define USB_REQ_GET_DESCRIPTOR 0x06U
#define USB_REQ_SET_DESCRIPTOR 0x07U #define USB_CONFIG_REMOTE_WAKEUP 0x02U
#define USB_REQ_GET_CONFIGURATION 0x08U #define USB_CONFIG_SELF_POWERED 0x01U
#define USB_REQ_SET_CONFIGURATION 0x09U
#define USB_REQ_GET_INTERFACE 0x0AU #define USB_FEATURE_EP_HALT 0x00U
#define USB_REQ_SET_INTERFACE 0x0BU #define USB_FEATURE_REMOTE_WAKEUP 0x01U
#define USB_REQ_SYNCH_FRAME 0x0CU #define USB_FEATURE_TEST_MODE 0x02U
#define USB_DESC_TYPE_DEVICE 0x01U #define USB_DEVICE_CAPABITY_TYPE 0x10U
#define USB_DESC_TYPE_CONFIGURATION 0x02U
#define USB_DESC_TYPE_STRING 0x03U #define USB_CONF_DESC_SIZE 0x09U
#define USB_DESC_TYPE_INTERFACE 0x04U #define USB_IF_DESC_SIZE 0x09U
#define USB_DESC_TYPE_ENDPOINT 0x05U #define USB_EP_DESC_SIZE 0x07U
#define USB_DESC_TYPE_DEVICE_QUALIFIER 0x06U #define USB_IAD_DESC_SIZE 0x08U
#define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION 0x07U
#define USB_DESC_TYPE_IAD 0x0BU #define USB_HS_MAX_PACKET_SIZE 512U
#define USB_DESC_TYPE_BOS 0x0FU #define USB_FS_MAX_PACKET_SIZE 64U
#define USB_MAX_EP0_SIZE 64U
#define USB_CONFIG_REMOTE_WAKEUP 0x02U
#define USB_CONFIG_SELF_POWERED 0x01U /* Device Status */
#define USBD_STATE_DEFAULT 0x01U
#define USB_FEATURE_EP_HALT 0x00U #define USBD_STATE_ADDRESSED 0x02U
#define USB_FEATURE_REMOTE_WAKEUP 0x01U #define USBD_STATE_CONFIGURED 0x03U
#define USB_FEATURE_TEST_MODE 0x02U #define USBD_STATE_SUSPENDED 0x04U
#define USB_DEVICE_CAPABITY_TYPE 0x10U
/* EP0 State */
#define USB_CONF_DESC_SIZE 0x09U #define USBD_EP0_IDLE 0x00U
#define USB_IF_DESC_SIZE 0x09U #define USBD_EP0_SETUP 0x01U
#define USB_EP_DESC_SIZE 0x07U #define USBD_EP0_DATA_IN 0x02U
#define USB_IAD_DESC_SIZE 0x08U #define USBD_EP0_DATA_OUT 0x03U
#define USBD_EP0_STATUS_IN 0x04U
#define USB_HS_MAX_PACKET_SIZE 512U #define USBD_EP0_STATUS_OUT 0x05U
#define USB_FS_MAX_PACKET_SIZE 64U #define USBD_EP0_STALL 0x06U
#define USB_MAX_EP0_SIZE 64U
#define USBD_EP_TYPE_CTRL 0x00U
/* Device Status */ #define USBD_EP_TYPE_ISOC 0x01U
#define USBD_STATE_DEFAULT 0x01U #define USBD_EP_TYPE_BULK 0x02U
#define USBD_STATE_ADDRESSED 0x02U #define USBD_EP_TYPE_INTR 0x03U
#define USBD_STATE_CONFIGURED 0x03U
#define USBD_STATE_SUSPENDED 0x04U /**
* @}
*/
/* EP0 State */
#define USBD_EP0_IDLE 0x00U
#define USBD_EP0_SETUP 0x01U /** @defgroup USBD_DEF_Exported_TypesDefinitions
#define USBD_EP0_DATA_IN 0x02U * @{
#define USBD_EP0_DATA_OUT 0x03U */
#define USBD_EP0_STATUS_IN 0x04U
#define USBD_EP0_STATUS_OUT 0x05U typedef struct usb_setup_req
#define USBD_EP0_STALL 0x06U {
uint8_t bmRequest;
#define USBD_EP_TYPE_CTRL 0x00U uint8_t bRequest;
#define USBD_EP_TYPE_ISOC 0x01U uint16_t wValue;
#define USBD_EP_TYPE_BULK 0x02U uint16_t wIndex;
#define USBD_EP_TYPE_INTR 0x03U uint16_t wLength;
} USBD_SetupReqTypedef;
#ifdef USE_USBD_COMPOSITE
#define USBD_EP_IN 0x80U typedef struct
#define USBD_EP_OUT 0x00U {
#define USBD_FUNC_DESCRIPTOR_TYPE 0x24U uint8_t bLength;
#define USBD_DESC_SUBTYPE_ACM 0x0FU uint8_t bDescriptorType;
#define USBD_DESC_ECM_BCD_LOW 0x00U uint16_t wTotalLength;
#define USBD_DESC_ECM_BCD_HIGH 0x10U uint8_t bNumInterfaces;
#endif /* USE_USBD_COMPOSITE */ uint8_t bConfigurationValue;
/** uint8_t iConfiguration;
* @} uint8_t bmAttributes;
*/ uint8_t bMaxPower;
} USBD_ConfigDescTypedef;
/** @defgroup USBD_DEF_Exported_TypesDefinitions typedef struct
* @{ {
*/ uint8_t bLength;
uint8_t bDescriptorType;
typedef struct usb_setup_req uint16_t wTotalLength;
{ uint8_t bNumDeviceCaps;
uint8_t bmRequest; } USBD_BosDescTypedef;
uint8_t bRequest;
uint16_t wValue; typedef struct
uint16_t wIndex; {
uint16_t wLength; uint8_t bLength;
} USBD_SetupReqTypedef; uint8_t bDescriptorType;
uint8_t bEndpointAddress;
typedef struct uint8_t bmAttributes;
{ uint16_t wMaxPacketSize;
uint8_t bLength; uint8_t bInterval;
uint8_t bDescriptorType; } USBD_EpDescTypedef;
uint16_t wTotalLength;
uint8_t bNumInterfaces; struct _USBD_HandleTypeDef;
uint8_t bConfigurationValue;
uint8_t iConfiguration; typedef struct _Device_cb
uint8_t bmAttributes; {
uint8_t bMaxPower; uint8_t (*Init)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx);
} __PACKED USBD_ConfigDescTypeDef; uint8_t (*DeInit)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx);
/* Control Endpoints*/
typedef struct uint8_t (*Setup)(struct _USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
{ uint8_t (*EP0_TxSent)(struct _USBD_HandleTypeDef *pdev);
uint8_t bLength; uint8_t (*EP0_RxReady)(struct _USBD_HandleTypeDef *pdev);
uint8_t bDescriptorType; /* Class Specific Endpoints*/
uint16_t wTotalLength; uint8_t (*DataIn)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
uint8_t bNumDeviceCaps; uint8_t (*DataOut)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
} USBD_BosDescTypeDef; uint8_t (*SOF)(struct _USBD_HandleTypeDef *pdev);
uint8_t (*IsoINIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
typedef struct uint8_t (*IsoOUTIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
{
uint8_t bLength; uint8_t *(*GetHSConfigDescriptor)(uint16_t *length);
uint8_t bDescriptorType; uint8_t *(*GetFSConfigDescriptor)(uint16_t *length);
uint8_t bEndpointAddress; uint8_t *(*GetOtherSpeedConfigDescriptor)(uint16_t *length);
uint8_t bmAttributes; uint8_t *(*GetDeviceQualifierDescriptor)(uint16_t *length);
uint16_t wMaxPacketSize; #if (USBD_SUPPORT_USER_STRING_DESC == 1U)
uint8_t bInterval; uint8_t *(*GetUsrStrDescriptor)(struct _USBD_HandleTypeDef *pdev, uint8_t index, uint16_t *length);
} __PACKED USBD_EpDescTypeDef; #endif
typedef struct } USBD_ClassTypeDef;
{
uint8_t bLength; /* Following USB Device Speed */
uint8_t bDescriptorType; typedef enum
uint8_t bDescriptorSubType; {
} USBD_DescHeaderTypeDef; USBD_SPEED_HIGH = 0U,
USBD_SPEED_FULL = 1U,
struct _USBD_HandleTypeDef; USBD_SPEED_LOW = 2U,
} USBD_SpeedTypeDef;
typedef struct _Device_cb
{ /* Following USB Device status */
uint8_t (*Init)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx); typedef enum
uint8_t (*DeInit)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx); {
/* Control Endpoints*/ USBD_OK = 0U,
uint8_t (*Setup)(struct _USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req); USBD_BUSY,
uint8_t (*EP0_TxSent)(struct _USBD_HandleTypeDef *pdev); USBD_EMEM,
uint8_t (*EP0_RxReady)(struct _USBD_HandleTypeDef *pdev); USBD_FAIL,
/* Class Specific Endpoints*/ } USBD_StatusTypeDef;
uint8_t (*DataIn)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum);
uint8_t (*DataOut)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); /* USB Device descriptors structure */
uint8_t (*SOF)(struct _USBD_HandleTypeDef *pdev); typedef struct
uint8_t (*IsoINIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); {
uint8_t (*IsoOUTIncomplete)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum); uint8_t *(*GetDeviceDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
uint8_t *(*GetLangIDStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
uint8_t *(*GetHSConfigDescriptor)(uint16_t *length); uint8_t *(*GetManufacturerStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
uint8_t *(*GetFSConfigDescriptor)(uint16_t *length); uint8_t *(*GetProductStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
uint8_t *(*GetOtherSpeedConfigDescriptor)(uint16_t *length); uint8_t *(*GetSerialStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
uint8_t *(*GetDeviceQualifierDescriptor)(uint16_t *length); uint8_t *(*GetConfigurationStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
#if (USBD_SUPPORT_USER_STRING_DESC == 1U) uint8_t *(*GetInterfaceStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
uint8_t *(*GetUsrStrDescriptor)(struct _USBD_HandleTypeDef *pdev, uint8_t index, uint16_t *length); #if (USBD_CLASS_USER_STRING_DESC == 1)
#endif /* USBD_SUPPORT_USER_STRING_DESC */ uint8_t *(*GetUserStrDescriptor)(USBD_SpeedTypeDef speed, uint8_t idx, uint16_t *length);
#endif
} USBD_ClassTypeDef; #if ((USBD_LPM_ENABLED == 1U) || (USBD_CLASS_BOS_ENABLED == 1))
uint8_t *(*GetBOSDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length);
/* Following USB Device Speed */ #endif
typedef enum } USBD_DescriptorsTypeDef;
{
USBD_SPEED_HIGH = 0U, /* USB Device handle structure */
USBD_SPEED_FULL = 1U, typedef struct
USBD_SPEED_LOW = 2U, {
} USBD_SpeedTypeDef; uint32_t status;
uint32_t total_length;
/* Following USB Device status */ uint32_t rem_length;
typedef enum uint32_t maxpacket;
{ uint16_t is_used;
USBD_OK = 0U, uint16_t bInterval;
USBD_BUSY, } USBD_EndpointTypeDef;
USBD_EMEM,
USBD_FAIL, /* USB Device handle structure */
} USBD_StatusTypeDef; typedef struct _USBD_HandleTypeDef
{
/* USB Device descriptors structure */ uint8_t id;
typedef struct uint32_t dev_config;
{ uint32_t dev_default_config;
uint8_t *(*GetDeviceDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); uint32_t dev_config_status;
uint8_t *(*GetLangIDStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); USBD_SpeedTypeDef dev_speed;
uint8_t *(*GetManufacturerStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); USBD_EndpointTypeDef ep_in[16];
uint8_t *(*GetProductStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); USBD_EndpointTypeDef ep_out[16];
uint8_t *(*GetSerialStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); __IO uint32_t ep0_state;
uint8_t *(*GetConfigurationStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); uint32_t ep0_data_len;
uint8_t *(*GetInterfaceStrDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); __IO uint8_t dev_state;
#if (USBD_CLASS_USER_STRING_DESC == 1) __IO uint8_t dev_old_state;
uint8_t *(*GetUserStrDescriptor)(USBD_SpeedTypeDef speed, uint8_t idx, uint16_t *length); uint8_t dev_address;
#endif /* USBD_CLASS_USER_STRING_DESC */ uint8_t dev_connection_status;
#if ((USBD_LPM_ENABLED == 1U) || (USBD_CLASS_BOS_ENABLED == 1)) uint8_t dev_test_mode;
uint8_t *(*GetBOSDescriptor)(USBD_SpeedTypeDef speed, uint16_t *length); uint32_t dev_remote_wakeup;
#endif /* (USBD_LPM_ENABLED == 1U) || (USBD_CLASS_BOS_ENABLED == 1) */ uint8_t ConfIdx;
} USBD_DescriptorsTypeDef;
USBD_SetupReqTypedef request;
/* USB Device handle structure */ USBD_DescriptorsTypeDef *pDesc;
typedef struct USBD_ClassTypeDef *pClass;
{ void *pUserData_CDC_ACM;
uint32_t status; void *pClassData_CDC_RNDIS;
uint32_t total_length; void *pUserData_CDC_RNDIS;
uint32_t rem_length; void *pClassData_CDC_ECM;
uint32_t maxpacket; void *pUserData_CDC_ECM;
uint16_t is_used; void *pClassData_HID_Mouse;
uint16_t bInterval; void *pClassData_HID_Keyboard;
} USBD_EndpointTypeDef; void *pClassData_HID_Custom;
void *pUserData_HID_Custom;
#ifdef USE_USBD_COMPOSITE void *pClassData_UAC_MIC;
typedef enum void *pUserData_UAC_MIC;
{ void *pClassData_UAC_SPKR;
CLASS_TYPE_NONE = 0, void *pUserData_UAC_SPKR;
CLASS_TYPE_HID = 1, void *pClassData_UVC;
CLASS_TYPE_CDC = 2, void *pUserData_UVC;
CLASS_TYPE_MSC = 3, void *pClassData_MSC;
CLASS_TYPE_DFU = 4, void *pUserData_MSC;
CLASS_TYPE_CHID = 5, void *pClassData_DFU;
CLASS_TYPE_AUDIO = 6, void *pUserData_DFU;
CLASS_TYPE_ECM = 7, void *pClassData_PRNTR;
CLASS_TYPE_RNDIS = 8, void *pUserData_PRNTR;
CLASS_TYPE_MTP = 9, void *pData;
CLASS_TYPE_VIDEO = 10, void *pBosDesc;
CLASS_TYPE_PRINTER = 11, void *pConfDesc;
CLASS_TYPE_CCID = 12, } USBD_HandleTypeDef;
} USBD_CompositeClassTypeDef;
/**
* @}
/* USB Device handle structure */ */
typedef struct
{
uint8_t add;
uint8_t type; /** @defgroup USBD_DEF_Exported_Macros
uint8_t size; * @{
uint8_t is_used; */
} USBD_EPTypeDef; __STATIC_INLINE uint16_t SWAPBYTE(uint8_t *addr)
{
/* USB Device handle structure */ uint16_t _SwapVal, _Byte1, _Byte2;
typedef struct uint8_t *_pbuff = addr;
{
USBD_CompositeClassTypeDef ClassType; _Byte1 = *(uint8_t *)_pbuff;
uint32_t ClassId; _pbuff++;
uint32_t Active; _Byte2 = *(uint8_t *)_pbuff;
uint32_t NumEps;
USBD_EPTypeDef Eps[USBD_MAX_CLASS_ENDPOINTS]; _SwapVal = (_Byte2 << 8) | _Byte1;
uint8_t *EpAdd;
uint32_t NumIf; return _SwapVal;
uint8_t Ifs[USBD_MAX_CLASS_INTERFACES]; }
uint32_t CurrPcktSze;
} USBD_CompositeElementTypeDef; #ifndef LOBYTE
#endif /* USE_USBD_COMPOSITE */ #define LOBYTE(x) ((uint8_t)((x) & 0x00FFU))
#endif
/* USB Device handle structure */
typedef struct _USBD_HandleTypeDef #ifndef HIBYTE
{ #define HIBYTE(x) ((uint8_t)(((x) & 0xFF00U) >> 8U))
uint8_t id; #endif
uint32_t dev_config;
uint32_t dev_default_config; #ifndef MIN
uint32_t dev_config_status; #define MIN(a, b) (((a) < (b)) ? (a) : (b))
USBD_SpeedTypeDef dev_speed; #endif
USBD_EndpointTypeDef ep_in[16];
USBD_EndpointTypeDef ep_out[16]; #ifndef MAX
__IO uint32_t ep0_state; #define MAX(a, b) (((a) > (b)) ? (a) : (b))
uint32_t ep0_data_len; #endif
__IO uint8_t dev_state;
__IO uint8_t dev_old_state; #if defined ( __GNUC__ )
uint8_t dev_address; #ifndef __weak
uint8_t dev_connection_status; #define __weak __attribute__((weak))
uint8_t dev_test_mode; #endif /* __weak */
uint32_t dev_remote_wakeup; #ifndef __packed
uint8_t ConfIdx; #define __packed __attribute__((__packed__))
#endif /* __packed */
USBD_SetupReqTypedef request; #endif /* __GNUC__ */
USBD_DescriptorsTypeDef *pDesc;
USBD_ClassTypeDef *pClass[USBD_MAX_SUPPORTED_CLASS];
void *pClassData; /* In HS mode and when the DMA is used, all variables and data structures dealing
void *pClassDataCmsit[USBD_MAX_SUPPORTED_CLASS]; with the DMA during the transaction process should be 4-bytes aligned */
void *pUserData[USBD_MAX_SUPPORTED_CLASS];
void *pData; #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
void *pBosDesc; #ifndef __ALIGN_END
void *pConfDesc; #define __ALIGN_END __attribute__ ((aligned (4U)))
uint32_t classId; #endif /* __ALIGN_END */
uint32_t NumClasses; #ifndef __ALIGN_BEGIN
#ifdef USE_USBD_COMPOSITE #define __ALIGN_BEGIN
USBD_CompositeElementTypeDef tclasslist[USBD_MAX_SUPPORTED_CLASS]; #endif /* __ALIGN_BEGIN */
#endif /* USE_USBD_COMPOSITE */ #else
} USBD_HandleTypeDef; #ifndef __ALIGN_END
#define __ALIGN_END
/* USB Device endpoint direction */ #endif /* __ALIGN_END */
typedef enum #ifndef __ALIGN_BEGIN
{ #if defined (__CC_ARM) /* ARM Compiler */
OUT = 0x00, #define __ALIGN_BEGIN __align(4U)
IN = 0x80, #elif defined (__ICCARM__) /* IAR Compiler */
} USBD_EPDirectionTypeDef; #define __ALIGN_BEGIN
#endif /* __CC_ARM */
typedef enum #endif /* __ALIGN_BEGIN */
{ #endif /* __GNUC__ */
NETWORK_CONNECTION = 0x00,
RESPONSE_AVAILABLE = 0x01,
CONNECTION_SPEED_CHANGE = 0x2A /**
} USBD_CDC_NotifCodeTypeDef; * @}
/** */
* @}
*/ /** @defgroup USBD_DEF_Exported_Variables
* @{
*/
/** @defgroup USBD_DEF_Exported_Macros /**
* @{ * @}
*/ */
__STATIC_INLINE uint16_t SWAPBYTE(uint8_t *addr)
{ /** @defgroup USBD_DEF_Exported_FunctionsPrototype
uint16_t _SwapVal; * @{
uint16_t _Byte1; */
uint16_t _Byte2;
uint8_t *_pbuff = addr; /**
* @}
_Byte1 = *(uint8_t *)_pbuff; */
_pbuff++;
_Byte2 = *(uint8_t *)_pbuff; #ifdef __cplusplus
}
_SwapVal = (_Byte2 << 8) | _Byte1; #endif
return _SwapVal; #endif /* __USBD_DEF_H */
}
/**
#ifndef LOBYTE * @}
#define LOBYTE(x) ((uint8_t)((x) & 0x00FFU)) */
#endif /* LOBYTE */
/**
#ifndef HIBYTE * @}
#define HIBYTE(x) ((uint8_t)(((x) & 0xFF00U) >> 8U)) */
#endif /* HIBYTE */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif /* MIN */
#ifndef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif /* MAX */
#if defined ( __GNUC__ )
#ifndef __weak
#define __weak __attribute__((weak))
#endif /* __weak */
#ifndef __packed
#define __packed __attribute__((__packed__))
#endif /* __packed */
#endif /* __GNUC__ */
/* In HS mode and when the DMA is used, all variables and data structures dealing
with the DMA during the transaction process should be 4-bytes aligned */
#if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
#ifndef __ALIGN_END
#define __ALIGN_END __attribute__ ((aligned (4U)))
#endif /* __ALIGN_END */
#ifndef __ALIGN_BEGIN
#define __ALIGN_BEGIN
#endif /* __ALIGN_BEGIN */
#else
#ifndef __ALIGN_END
#define __ALIGN_END
#endif /* __ALIGN_END */
#ifndef __ALIGN_BEGIN
#if defined (__CC_ARM) /* ARM Compiler */
#define __ALIGN_BEGIN __align(4U)
#elif defined (__ICCARM__) /* IAR Compiler */
#define __ALIGN_BEGIN
#endif /* __CC_ARM */
#endif /* __ALIGN_BEGIN */
#endif /* __GNUC__ */
/**
* @}
*/
/** @defgroup USBD_DEF_Exported_Variables
* @{
*/
/**
* @}
*/
/** @defgroup USBD_DEF_Exported_FunctionsPrototype
* @{
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* __USBD_DEF_H */
/**
* @}
*/
/**
* @}
*/

View File

@ -1,113 +1,114 @@
/** /**
****************************************************************************** ******************************************************************************
* @file usbd_ioreq.h * @file usbd_ioreq.h
* @author MCD Application Team * @author MCD Application Team
* @brief Header file for the usbd_ioreq.c file * @brief Header file for the usbd_ioreq.c file
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2015 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_IOREQ_H /* Define to prevent recursive inclusion -------------------------------------*/
#define __USBD_IOREQ_H #ifndef __USBD_IOREQ_H
#define __USBD_IOREQ_H
#ifdef __cplusplus
extern "C" { #ifdef __cplusplus
#endif extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "usbd_def.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_core.h" #include "usbd_def.h"
#include "usbd_core.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{ /** @addtogroup STM32_USB_DEVICE_LIBRARY
*/ * @{
*/
/** @defgroup USBD_IOREQ
* @brief header file for the usbd_ioreq.c file /** @defgroup USBD_IOREQ
* @{ * @brief header file for the usbd_ioreq.c file
*/ * @{
*/
/** @defgroup USBD_IOREQ_Exported_Defines
* @{ /** @defgroup USBD_IOREQ_Exported_Defines
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup USBD_IOREQ_Exported_Types
* @{ /** @defgroup USBD_IOREQ_Exported_Types
*/ * @{
*/
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_IOREQ_Exported_Macros
* @{ /** @defgroup USBD_IOREQ_Exported_Macros
*/ * @{
*/
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_IOREQ_Exported_Variables
* @{ /** @defgroup USBD_IOREQ_Exported_Variables
*/ * @{
*/
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_IOREQ_Exported_FunctionsPrototype
* @{ /** @defgroup USBD_IOREQ_Exported_FunctionsPrototype
*/ * @{
*/
USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
uint8_t *pbuf, uint32_t len); USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
uint8_t *pbuf, uint32_t len);
USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
uint8_t *pbuf, uint32_t len); USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
uint8_t *pbuf, uint32_t len);
USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
uint8_t *pbuf, uint32_t len); USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
uint8_t *pbuf, uint32_t len);
USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
uint8_t *pbuf, uint32_t len); USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
uint8_t *pbuf, uint32_t len);
USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev); USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev);
USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev);
uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr);
/**
* @} /**
*/ * @}
*/
#ifdef __cplusplus
} #ifdef __cplusplus
#endif }
#endif
#endif /* __USBD_IOREQ_H */
#endif /* __USBD_IOREQ_H */
/**
* @} /**
*/ * @}
*/
/**
* @} /**
*/ * @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -0,0 +1,689 @@
/**
******************************************************************************
* @file usbd_core.c
* @author MCD Application Team
* @brief This file provides all the USBD core functions.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "usbd_core.h"
/** @addtogroup STM32_USBD_DEVICE_LIBRARY
* @{
*/
/** @defgroup USBD_CORE
* @brief usbd core module
* @{
*/
/** @defgroup USBD_CORE_Private_TypesDefinitions
* @{
*/
/**
* @}
*/
/** @defgroup USBD_CORE_Private_Defines
* @{
*/
/**
* @}
*/
/** @defgroup USBD_CORE_Private_Macros
* @{
*/
/**
* @}
*/
/** @defgroup USBD_CORE_Private_FunctionPrototypes
* @{
*/
/**
* @}
*/
/** @defgroup USBD_CORE_Private_Variables
* @{
*/
/**
* @}
*/
/** @defgroup USBD_CORE_Private_Functions
* @{
*/
/**
* @brief USBD_Init
* Initializes the device stack and load the class driver
* @param pdev: device instance
* @param pdesc: Descriptor structure address
* @param id: Low level core index
* @retval None
*/
USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev,
USBD_DescriptorsTypeDef *pdesc, uint8_t id)
{
USBD_StatusTypeDef ret;
/* Check whether the USB Host handle is valid */
if (pdev == NULL)
{
#if (USBD_DEBUG_LEVEL > 1U)
USBD_ErrLog("Invalid Device handle");
#endif
return USBD_FAIL;
}
/* Unlink previous class resources */
pdev->pClass = NULL;
pdev->pConfDesc = NULL;
/* Assign USBD Descriptors */
if (pdesc != NULL)
{
pdev->pDesc = pdesc;
}
/* Set Device initial State */
pdev->dev_state = USBD_STATE_DEFAULT;
pdev->id = id;
/* Initialize low level driver */
ret = USBD_LL_Init(pdev);
return ret;
}
/**
* @brief USBD_DeInit
* Re-Initialize the device library
* @param pdev: device instance
* @retval status: status
*/
USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev)
{
USBD_StatusTypeDef ret;
/* Disconnect the USB Device */
(void)USBD_LL_Stop(pdev);
/* Set Default State */
pdev->dev_state = USBD_STATE_DEFAULT;
/* Free Class Resources */
if (pdev->pClass != NULL)
{
pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
pdev->pClass = NULL;
}
/* Free Device descriptors resources */
pdev->pDesc = NULL;
pdev->pConfDesc = NULL;
/* DeInitialize low level driver */
ret = USBD_LL_DeInit(pdev);
return ret;
}
/**
* @brief USBD_RegisterClass
* Link class driver to Device Core.
* @param pDevice : Device Handle
* @param pclass: Class handle
* @retval USBD Status
*/
USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass)
{
uint16_t len = 0U;
if (pclass == NULL)
{
#if (USBD_DEBUG_LEVEL > 1U)
USBD_ErrLog("Invalid Class handle");
#endif
return USBD_FAIL;
}
/* link the class to the USB Device handle */
pdev->pClass = pclass;
/* Get Device Configuration Descriptor */
if (pdev->dev_speed == USBD_SPEED_HIGH)
{
if (pdev->pClass->GetHSConfigDescriptor != NULL)
{
pdev->pConfDesc = (void *)pdev->pClass->GetHSConfigDescriptor(&len);
}
}
else if (pdev->pClass->GetFSConfigDescriptor != NULL)
{
pdev->pConfDesc = (void *)pdev->pClass->GetFSConfigDescriptor(&len);
}
return USBD_OK;
}
/**
* @brief USBD_Start
* Start the USB Device Core.
* @param pdev: Device Handle
* @retval USBD Status
*/
USBD_StatusTypeDef USBD_Start(USBD_HandleTypeDef *pdev)
{
/* Start the low level driver */
return USBD_LL_Start(pdev);
}
/**
* @brief USBD_Stop
* Stop the USB Device Core.
* @param pdev: Device Handle
* @retval USBD Status
*/
USBD_StatusTypeDef USBD_Stop(USBD_HandleTypeDef *pdev)
{
/* Disconnect USB Device */
(void)USBD_LL_Stop(pdev);
/* Free Class Resources */
if (pdev->pClass != NULL)
{
(void)pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
}
return USBD_OK;
}
/**
* @brief USBD_RunTestMode
* Launch test mode process
* @param pdev: device instance
* @retval status
*/
USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev)
{
/* Prevent unused argument compilation warning */
UNUSED(pdev);
return USBD_OK;
}
/**
* @brief USBD_SetClassConfig
* Configure device and start the interface
* @param pdev: device instance
* @param cfgidx: configuration index
* @retval status
*/
USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
USBD_StatusTypeDef ret = USBD_FAIL;
if (pdev->pClass != NULL)
{
/* Set configuration and Start the Class */
ret = (USBD_StatusTypeDef)pdev->pClass->Init(pdev, cfgidx);
}
return ret;
}
/**
* @brief USBD_ClrClassConfig
* Clear current configuration
* @param pdev: device instance
* @param cfgidx: configuration index
* @retval status: USBD_StatusTypeDef
*/
USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
{
/* Clear configuration and De-initialize the Class process */
if (pdev->pClass != NULL)
{
pdev->pClass->DeInit(pdev, cfgidx);
}
return USBD_OK;
}
/**
* @brief USBD_LL_SetupStage
* Handle the setup stage
* @param pdev: device instance
* @retval status
*/
USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup)
{
USBD_StatusTypeDef ret;
USBD_ParseSetupRequest(&pdev->request, psetup);
pdev->ep0_state = USBD_EP0_SETUP;
pdev->ep0_data_len = pdev->request.wLength;
switch (pdev->request.bmRequest & 0x1FU)
{
case USB_REQ_RECIPIENT_DEVICE:
ret = USBD_StdDevReq(pdev, &pdev->request);
break;
case USB_REQ_RECIPIENT_INTERFACE:
ret = USBD_StdItfReq(pdev, &pdev->request);
break;
case USB_REQ_RECIPIENT_ENDPOINT:
ret = USBD_StdEPReq(pdev, &pdev->request);
break;
default:
ret = USBD_LL_StallEP(pdev, (pdev->request.bmRequest & 0x80U));
break;
}
return ret;
}
/**
* @brief USBD_LL_DataOutStage
* Handle data OUT stage
* @param pdev: device instance
* @param epnum: endpoint index
* @param pdata: data pointer
* @retval status
*/
USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev,
uint8_t epnum, uint8_t *pdata)
{
USBD_EndpointTypeDef *pep;
USBD_StatusTypeDef ret;
if (epnum == 0U)
{
pep = &pdev->ep_out[0];
if (pdev->ep0_state == USBD_EP0_DATA_OUT)
{
if (pep->rem_length > pep->maxpacket)
{
pep->rem_length -= pep->maxpacket;
(void)USBD_CtlContinueRx(pdev, pdata, MIN(pep->rem_length, pep->maxpacket));
}
else
{
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
if (pdev->pClass->EP0_RxReady != NULL)
{
pdev->pClass->EP0_RxReady(pdev);
}
}
(void)USBD_CtlSendStatus(pdev);
}
}
else
{
#if 0
if (pdev->ep0_state == USBD_EP0_STATUS_OUT)
{
/*
* STATUS PHASE completed, update ep0_state to idle
*/
pdev->ep0_state = USBD_EP0_IDLE;
(void)USBD_LL_StallEP(pdev, 0U);
}
#endif
}
}
else
{
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
if (pdev->pClass->DataOut != NULL)
{
ret = (USBD_StatusTypeDef)pdev->pClass->DataOut(pdev, epnum);
if (ret != USBD_OK)
{
return ret;
}
}
}
}
return USBD_OK;
}
/**
* @brief USBD_LL_DataInStage
* Handle data in stage
* @param pdev: device instance
* @param epnum: endpoint index
* @retval status
*/
USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev,
uint8_t epnum, uint8_t *pdata)
{
USBD_EndpointTypeDef *pep;
USBD_StatusTypeDef ret;
if (epnum == 0U)
{
pep = &pdev->ep_in[0];
if (pdev->ep0_state == USBD_EP0_DATA_IN)
{
if (pep->rem_length > pep->maxpacket)
{
pep->rem_length -= pep->maxpacket;
(void)USBD_CtlContinueSendData(pdev, pdata, pep->rem_length);
/* Prepare endpoint for premature end of transfer */
(void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
}
else
{
/* last packet is MPS multiple, so send ZLP packet */
if ((pep->maxpacket == pep->rem_length) &&
(pep->total_length >= pep->maxpacket) &&
(pep->total_length < pdev->ep0_data_len))
{
(void)USBD_CtlContinueSendData(pdev, NULL, 0U);
pdev->ep0_data_len = 0U;
/* Prepare endpoint for premature end of transfer */
(void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
}
else
{
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
if (pdev->pClass->EP0_TxSent != NULL)
{
pdev->pClass->EP0_TxSent(pdev);
}
}
(void)USBD_LL_StallEP(pdev, 0x80U);
(void)USBD_CtlReceiveStatus(pdev);
}
}
}
else
{
#if 0
if ((pdev->ep0_state == USBD_EP0_STATUS_IN) ||
(pdev->ep0_state == USBD_EP0_IDLE))
{
(void)USBD_LL_StallEP(pdev, 0x80U);
}
#endif
}
if (pdev->dev_test_mode == 1U)
{
(void)USBD_RunTestMode(pdev);
pdev->dev_test_mode = 0U;
}
}
else
{
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
if (pdev->pClass->DataIn != NULL)
{
ret = (USBD_StatusTypeDef)pdev->pClass->DataIn(pdev, epnum);
if (ret != USBD_OK)
{
return ret;
}
}
}
}
return USBD_OK;
}
/**
* @brief USBD_LL_Reset
* Handle Reset event
* @param pdev: device instance
* @retval status
*/
USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev)
{
/* Upon Reset call user call back */
pdev->dev_state = USBD_STATE_DEFAULT;
pdev->ep0_state = USBD_EP0_IDLE;
pdev->dev_config = 0U;
pdev->dev_remote_wakeup = 0U;
if (pdev->pClass == NULL)
{
return USBD_FAIL;
}
if (pdev->pClass->DeInit != NULL)
{
(void)pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
}
/* Open EP0 OUT */
(void)USBD_LL_OpenEP(pdev, 0x00U, USBD_EP_TYPE_CTRL, USB_MAX_EP0_SIZE);
pdev->ep_out[0x00U & 0xFU].is_used = 1U;
pdev->ep_out[0].maxpacket = USB_MAX_EP0_SIZE;
/* Open EP0 IN */
(void)USBD_LL_OpenEP(pdev, 0x80U, USBD_EP_TYPE_CTRL, USB_MAX_EP0_SIZE);
pdev->ep_in[0x80U & 0xFU].is_used = 1U;
pdev->ep_in[0].maxpacket = USB_MAX_EP0_SIZE;
return USBD_OK;
}
/**
* @brief USBD_LL_SetSpeed
* Handle Reset event
* @param pdev: device instance
* @retval status
*/
USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev,
USBD_SpeedTypeDef speed)
{
pdev->dev_speed = speed;
return USBD_OK;
}
/**
* @brief USBD_LL_Suspend
* Handle Suspend event
* @param pdev: device instance
* @retval status
*/
USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev)
{
pdev->dev_old_state = pdev->dev_state;
pdev->dev_state = USBD_STATE_SUSPENDED;
return USBD_OK;
}
/**
* @brief USBD_LL_Resume
* Handle Resume event
* @param pdev: device instance
* @retval status
*/
USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev)
{
if (pdev->dev_state == USBD_STATE_SUSPENDED)
{
pdev->dev_state = pdev->dev_old_state;
}
return USBD_OK;
}
/**
* @brief USBD_LL_SOF
* Handle SOF event
* @param pdev: device instance
* @retval status
*/
USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev)
{
if (pdev->pClass == NULL)
{
return USBD_FAIL;
}
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
if (pdev->pClass->SOF != NULL)
{
(void)pdev->pClass->SOF(pdev);
}
}
return USBD_OK;
}
/**
* @brief USBD_LL_IsoINIncomplete
* Handle iso in incomplete event
* @param pdev: device instance
* @retval status
*/
USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev,
uint8_t epnum)
{
if (pdev->pClass == NULL)
{
return USBD_FAIL;
}
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
if (pdev->pClass->IsoINIncomplete != NULL)
{
(void)pdev->pClass->IsoINIncomplete(pdev, epnum);
}
}
return USBD_OK;
}
/**
* @brief USBD_LL_IsoOUTIncomplete
* Handle iso out incomplete event
* @param pdev: device instance
* @retval status
*/
USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev,
uint8_t epnum)
{
if (pdev->pClass == NULL)
{
return USBD_FAIL;
}
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
if (pdev->pClass->IsoOUTIncomplete != NULL)
{
(void)pdev->pClass->IsoOUTIncomplete(pdev, epnum);
}
}
return USBD_OK;
}
/**
* @brief USBD_LL_DevConnected
* Handle device connection event
* @param pdev: device instance
* @retval status
*/
USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev)
{
/* Prevent unused argument compilation warning */
UNUSED(pdev);
return USBD_OK;
}
/**
* @brief USBD_LL_DevDisconnected
* Handle device disconnection event
* @param pdev: device instance
* @retval status
*/
USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev)
{
/* Free Class Resources */
pdev->dev_state = USBD_STATE_DEFAULT;
if (pdev->pClass != NULL)
{
(void)pdev->pClass->DeInit(pdev, (uint8_t)pdev->dev_config);
}
return USBD_OK;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,224 +1,226 @@
/** /**
****************************************************************************** ******************************************************************************
* @file usbd_ioreq.c * @file usbd_ioreq.c
* @author MCD Application Team * @author MCD Application Team
* @brief This file provides the IO requests APIs for control endpoints. * @brief This file provides the IO requests APIs for control endpoints.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2015 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2015 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "usbd_ioreq.h" /* Includes ------------------------------------------------------------------*/
#include "usbd_ioreq.h"
/** @addtogroup STM32_USB_DEVICE_LIBRARY
* @{ /** @addtogroup STM32_USB_DEVICE_LIBRARY
*/ * @{
*/
/** @defgroup USBD_IOREQ
* @brief control I/O requests module /** @defgroup USBD_IOREQ
* @{ * @brief control I/O requests module
*/ * @{
*/
/** @defgroup USBD_IOREQ_Private_TypesDefinitions
* @{ /** @defgroup USBD_IOREQ_Private_TypesDefinitions
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup USBD_IOREQ_Private_Defines
* @{ /** @defgroup USBD_IOREQ_Private_Defines
*/ * @{
*/
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_IOREQ_Private_Macros
* @{ /** @defgroup USBD_IOREQ_Private_Macros
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup USBD_IOREQ_Private_Variables
* @{ /** @defgroup USBD_IOREQ_Private_Variables
*/ * @{
*/
/**
* @} /**
*/ * @}
*/
/** @defgroup USBD_IOREQ_Private_FunctionPrototypes
* @{ /** @defgroup USBD_IOREQ_Private_FunctionPrototypes
*/ * @{
/** */
* @} /**
*/ * @}
*/
/** @defgroup USBD_IOREQ_Private_Functions
* @{ /** @defgroup USBD_IOREQ_Private_Functions
*/ * @{
*/
/**
* @brief USBD_CtlSendData /**
* send data on the ctl pipe * @brief USBD_CtlSendData
* @param pdev: device instance * send data on the ctl pipe
* @param buff: pointer to data buffer * @param pdev: device instance
* @param len: length of data to be sent * @param buff: pointer to data buffer
* @retval status * @param len: length of data to be sent
*/ * @retval status
USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, */
uint8_t *pbuf, uint32_t len) USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev,
{ uint8_t *pbuf, uint32_t len)
/* Set EP0 State */ {
pdev->ep0_state = USBD_EP0_DATA_IN; /* Set EP0 State */
pdev->ep_in[0].total_length = len; pdev->ep0_state = USBD_EP0_DATA_IN;
pdev->ep_in[0].total_length = len;
#ifdef USBD_AVOID_PACKET_SPLIT_MPS
pdev->ep_in[0].rem_length = 0U; #ifdef USBD_AVOID_PACKET_SPLIT_MPS
#else pdev->ep_in[0].rem_length = 0U;
pdev->ep_in[0].rem_length = len; #else
#endif /* USBD_AVOID_PACKET_SPLIT_MPS */ pdev->ep_in[0].rem_length = len;
#endif
/* Start the transfer */
(void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len); /* Start the transfer */
(void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
return USBD_OK;
} return USBD_OK;
}
/**
* @brief USBD_CtlContinueSendData /**
* continue sending data on the ctl pipe * @brief USBD_CtlContinueSendData
* @param pdev: device instance * continue sending data on the ctl pipe
* @param buff: pointer to data buffer * @param pdev: device instance
* @param len: length of data to be sent * @param buff: pointer to data buffer
* @retval status * @param len: length of data to be sent
*/ * @retval status
USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, */
uint8_t *pbuf, uint32_t len) USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev,
{ uint8_t *pbuf, uint32_t len)
/* Start the next transfer */ {
(void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len); /* Start the next transfer */
(void)USBD_LL_Transmit(pdev, 0x00U, pbuf, len);
return USBD_OK;
} return USBD_OK;
}
/**
* @brief USBD_CtlPrepareRx /**
* receive data on the ctl pipe * @brief USBD_CtlPrepareRx
* @param pdev: device instance * receive data on the ctl pipe
* @param buff: pointer to data buffer * @param pdev: device instance
* @param len: length of data to be received * @param buff: pointer to data buffer
* @retval status * @param len: length of data to be received
*/ * @retval status
USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, */
uint8_t *pbuf, uint32_t len) USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev,
{ uint8_t *pbuf, uint32_t len)
/* Set EP0 State */ {
pdev->ep0_state = USBD_EP0_DATA_OUT; /* Set EP0 State */
pdev->ep_out[0].total_length = len; pdev->ep0_state = USBD_EP0_DATA_OUT;
pdev->ep_out[0].total_length = len;
#ifdef USBD_AVOID_PACKET_SPLIT_MPS
pdev->ep_out[0].rem_length = 0U; #ifdef USBD_AVOID_PACKET_SPLIT_MPS
#else pdev->ep_out[0].rem_length = 0U;
pdev->ep_out[0].rem_length = len; #else
#endif /* USBD_AVOID_PACKET_SPLIT_MPS */ pdev->ep_out[0].rem_length = len;
#endif
/* Start the transfer */
(void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); /* Start the transfer */
(void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
return USBD_OK;
} return USBD_OK;
}
/**
* @brief USBD_CtlContinueRx /**
* continue receive data on the ctl pipe * @brief USBD_CtlContinueRx
* @param pdev: device instance * continue receive data on the ctl pipe
* @param buff: pointer to data buffer * @param pdev: device instance
* @param len: length of data to be received * @param buff: pointer to data buffer
* @retval status * @param len: length of data to be received
*/ * @retval status
USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, */
uint8_t *pbuf, uint32_t len) USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev,
{ uint8_t *pbuf, uint32_t len)
(void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len); {
(void)USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
return USBD_OK;
} return USBD_OK;
}
/**
* @brief USBD_CtlSendStatus /**
* send zero lzngth packet on the ctl pipe * @brief USBD_CtlSendStatus
* @param pdev: device instance * send zero lzngth packet on the ctl pipe
* @retval status * @param pdev: device instance
*/ * @retval status
USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev) */
{ USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev)
/* Set EP0 State */ {
pdev->ep0_state = USBD_EP0_STATUS_IN; /* Set EP0 State */
pdev->ep0_state = USBD_EP0_STATUS_IN;
/* Start the transfer */
(void)USBD_LL_Transmit(pdev, 0x00U, NULL, 0U); /* Start the transfer */
(void)USBD_LL_Transmit(pdev, 0x00U, NULL, 0U);
return USBD_OK;
} return USBD_OK;
}
/**
* @brief USBD_CtlReceiveStatus /**
* receive zero lzngth packet on the ctl pipe * @brief USBD_CtlReceiveStatus
* @param pdev: device instance * receive zero lzngth packet on the ctl pipe
* @retval status * @param pdev: device instance
*/ * @retval status
USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev) */
{ USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev)
/* Set EP0 State */ {
pdev->ep0_state = USBD_EP0_STATUS_OUT; /* Set EP0 State */
pdev->ep0_state = USBD_EP0_STATUS_OUT;
/* Start the transfer */
(void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U); /* Start the transfer */
(void)USBD_LL_PrepareReceive(pdev, 0U, NULL, 0U);
return USBD_OK;
} return USBD_OK;
}
/**
* @brief USBD_GetRxCount /**
* returns the received data length * @brief USBD_GetRxCount
* @param pdev: device instance * returns the received data length
* @param ep_addr: endpoint address * @param pdev: device instance
* @retval Rx Data blength * @param ep_addr: endpoint address
*/ * @retval Rx Data blength
uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr) */
{ uint32_t USBD_GetRxCount(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
return USBD_LL_GetRxDataSize(pdev, ep_addr); {
} return USBD_LL_GetRxDataSize(pdev, ep_addr);
}
/**
* @} /**
*/ * @}
*/
/**
* @} /**
*/ * @}
*/
/**
* @} /**
*/ * @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -0,0 +1,793 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : Target/usbd_conf.c
* @version : v1.0_Cube
* @brief : This file implements the board support package for the USB device library
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "usbd_def.h"
#include "usbd_core.h"
/* USER CODE BEGIN Includes */
#include "usbd_composite.h"
#if 0
#if (STM32F1_DEVICE) /** for STM32F1 or similar */
#include "usb.h"
#else
#include "usb_otg.h"
#endif
#endif
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
/* USER CODE END PV */
PCD_HandleTypeDef *hpcd_USB_OTG_PTR;
void Error_Handler(void);
/* External functions --------------------------------------------------------*/
/* USER CODE BEGIN 0 */
extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
#define PCD_SPEED_HIGH USBD_SPEED_HIGH
/* USER CODE END 0 */
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
USBD_StatusTypeDef
USBD_Get_USB_Status(HAL_StatusTypeDef hal_status);
HAL_StatusTypeDef HAL_PCDEx_SetTxFiFoInBytes(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size);
HAL_StatusTypeDef HAL_PCDEx_SetRxFiFoInBytes(PCD_HandleTypeDef *hpcd, uint16_t size);
/* USER CODE END PFP */
/* Private functions ---------------------------------------------------------*/
/* USER CODE BEGIN 1 */
#if (!STM32F1_DEVICE)
HAL_StatusTypeDef HAL_PCDEx_SetTxFiFoInBytes(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size)
{
return HAL_PCDEx_SetTxFiFo(hpcd, fifo, (size / 4));
}
HAL_StatusTypeDef HAL_PCDEx_SetRxFiFoInBytes(PCD_HandleTypeDef *hpcd, uint16_t size)
{
return HAL_PCDEx_SetRxFiFo(hpcd, (size / 4));
}
#endif
/* USER CODE END 1 */
/*******************************************************************************
LL Driver Callbacks (PCD -> USB Device Library)
*******************************************************************************/
/* MSP Init */
__weak void HAL_PCD_MspInit(PCD_HandleTypeDef *pcdHandle)
{
/* @see usb_otg.c or usb.c for (STM32F1 or similar) generated by cube **/
}
__weak void HAL_PCD_MspDeInit(PCD_HandleTypeDef *pcdHandle)
{
/* @see usb_otg.c or usb.c for (STM32F1 or similar) generated by cube **/
}
/**
* @brief Setup stage callback
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_SetupStage((USBD_HandleTypeDef *)hpcd->pData, (uint8_t *)hpcd->Setup);
}
/**
* @brief Data Out stage callback.
* @param hpcd: PCD handle
* @param epnum: Endpoint number
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#else
void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_DataOutStage((USBD_HandleTypeDef *)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff);
}
/**
* @brief Data In stage callback.
* @param hpcd: PCD handle
* @param epnum: Endpoint number
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#else
void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_DataInStage((USBD_HandleTypeDef *)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff);
}
/**
* @brief SOF callback.
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_SOF((USBD_HandleTypeDef *)hpcd->pData);
}
/**
* @brief Reset callback.
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_SpeedTypeDef speed = USBD_SPEED_FULL;
if (hpcd->Init.speed == PCD_SPEED_FULL)
{
speed = USBD_SPEED_FULL;
}
#if (!STM32F1_DEVICE)
else if (hpcd->Init.speed == PCD_SPEED_HIGH)
{
speed = USBD_SPEED_HIGH;
}
#endif
else
{
Error_Handler();
}
/* Set Speed. */
USBD_LL_SetSpeed((USBD_HandleTypeDef *)hpcd->pData, speed);
/* Reset Device. */
USBD_LL_Reset((USBD_HandleTypeDef *)hpcd->pData);
}
/**
* @brief Suspend callback.
* When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it)
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
/* Inform USB library that core enters in suspend Mode. */
USBD_LL_Suspend((USBD_HandleTypeDef *)hpcd->pData);
#if (!STM32F1_DEVICE)
__HAL_PCD_GATE_PHYCLOCK(hpcd);
/* Enter in STOP mode. */
/* USER CODE BEGIN 2 */
if (hpcd->Init.low_power_enable)
{
/* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */
SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
}
#endif
/* USER CODE END 2 */
}
/**
* @brief Resume callback.
* When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it)
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
/* USER CODE BEGIN 3 */
/* USER CODE END 3 */
USBD_LL_Resume((USBD_HandleTypeDef *)hpcd->pData);
}
/**
* @brief ISOOUTIncomplete callback.
* @param hpcd: PCD handle
* @param epnum: Endpoint number
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#else
void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef *)hpcd->pData, epnum);
}
/**
* @brief ISOINIncomplete callback.
* @param hpcd: PCD handle
* @param epnum: Endpoint number
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#else
void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_IsoINIncomplete((USBD_HandleTypeDef *)hpcd->pData, epnum);
}
/**
* @brief Connect callback.
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_DevConnected((USBD_HandleTypeDef *)hpcd->pData);
}
/**
* @brief Disconnect callback.
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_DevDisconnected((USBD_HandleTypeDef *)hpcd->pData);
}
/*******************************************************************************
LL Driver Interface (USB Device Library --> PCD)
*******************************************************************************/
/**
* @brief Initializes the low level portion of the device driver.
* @param pdev: Device handle
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)
{
#if (USBD_USE_HS == 1)
/** HIGH SPEED USB */
hpcd_USB_OTG_PTR = &hpcd_USB_OTG_HS;
if (pdev->id == DEVICE_HS)
{
/* Link the driver to the stack. */
hpcd_USB_OTG_PTR->pData = pdev;
pdev->pData = hpcd_USB_OTG_PTR;
/* @see HAL_PCD_Init() usb_otg.c generated by cube **/
HAL_PCDEx_SetRxFiFoInBytes(hpcd_USB_OTG_PTR, 1024);
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, 0, 64); // EP0 IN
#if (USBD_USE_CDC_RNDIS == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CDC_RNDIS_IN_EP & 0x7F), 128);
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CDC_RNDIS_CMD_EP & 0x7F), 64);
#endif
#if (USBD_USE_CDC_ECM == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CDC_ECM_IN_EP & 0x7F), 128);
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CDC_ECM_CMD_EP & 0x7F), 64);
#endif
#if (USBD_USE_HID_MOUSE == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (HID_MOUSE_IN_EP & 0x7F), 64);
#endif
#if (USBD_USE_HID_KEYBOARD == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (HID_KEYBOARD_IN_EP & 0x7F), 64);
#endif
#if (USBD_USE_HID_CUSTOM == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CUSTOM_HID_IN_EP & 0x7F), 64);
#endif
#if (USBD_USE_UAC_MIC == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (AUDIO_MIC_EP & 0x7F), 128);
#endif
#if (USBD_USE_UAC_SPKR == 1)
#endif
#if (USBD_USE_UVC == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (UVC_IN_EP & 0x7F), 128);
#endif
#if (USBD_USE_MSC == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (MSC_IN_EP & 0x7F), 128);
#endif
#if (USBD_USE_DFU == 1)
#endif
#if (USBD_USE_PRNTR == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (PRNT_IN_EP & 0x7F), 128);
#endif
#if (USBD_USE_CDC_ACM == 1)
for (uint8_t i = 0; i < USBD_CDC_ACM_COUNT; i++)
{
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CDC_IN_EP[i] & 0x7F), 128);
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CDC_CMD_EP[i] & 0x7F), 64);
}
#endif
}
#else
/**FULL SPEED USB */
#if (STM32F1_DEVICE) /** for STM32F1 or similar */
hpcd_USB_OTG_PTR = &hpcd_USB_FS; /** hpcd_USB_FS or hpcd_USB_OTG_FS*/
#else
hpcd_USB_OTG_PTR = &hpcd_USB_OTG_FS; /** hpcd_USB_FS or hpcd_USB_OTG_FS*/
#endif
if (pdev->id == DEVICE_FS)
{
/* Link the driver to the stack. */
hpcd_USB_OTG_PTR->pData = pdev;
pdev->pData = hpcd_USB_OTG_PTR;
/* @see HAL_PCD_Init() usb_otg.c generated by cube **/
#if (STM32F1_DEVICE)
/** Device is F1 or similar or if HAL_PCDEx_PMAConfig() is used by HAL driver */
uint16_t pma_track = 0x40; /** PMA offset*/
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, 0x00, PCD_SNG_BUF, pma_track);
pma_track += 0x40;
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, 0x80, PCD_SNG_BUF, pma_track);
pma_track += 0x40;
#if (USBD_USE_CDC_RNDIS == 1)
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, CDC_RNDIS_IN_EP, PCD_SNG_BUF, pma_track);
pma_track += 128;
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, CDC_RNDIS_OUT_EP, PCD_SNG_BUF, pma_track);
pma_track += 128;
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, CDC_RNDIS_CMD_EP, PCD_SNG_BUF, pma_track);
pma_track += 8;
#endif
#if (USBD_USE_CDC_ECM == 1)
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, CDC_ECM_IN_EP, PCD_SNG_BUF, pma_track);
pma_track += 48;
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, CDC_ECM_OUT_EP, PCD_SNG_BUF, pma_track);
pma_track += 48;
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, CDC_ECM_CMD_EP, PCD_SNG_BUF, pma_track);
pma_track += 8;
#endif
#if (USBD_USE_HID_MOUSE == 1)
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, HID_MOUSE_IN_EP, PCD_SNG_BUF, pma_track);
pma_track += 8;
#endif
#if (USBD_USE_HID_KEYBOARD == 1)
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, HID_KEYBOARD_IN_EP, PCD_SNG_BUF, pma_track);
pma_track += 8;
#endif
#if (USBD_USE_HID_CUSTOM == 1)
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, CUSTOM_HID_IN_EP, PCD_SNG_BUF, pma_track);
pma_track += 8;
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, CUSTOM_HID_OUT_EP, PCD_SNG_BUF, pma_track);
pma_track += 8;
#endif
#if (USBD_USE_UAC_MIC == 1)
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, AUDIO_MIC_EP, PCD_SNG_BUF, pma_track);
pma_track += 128;
#endif
#if (USBD_USE_UAC_SPKR == 1)
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, AUDIO_SPKR_EP, PCD_SNG_BUF, pma_track);
pma_track += 128;
#endif
#if (USBD_USE_UVC == 1)
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, UVC_IN_EP, PCD_SNG_BUF, pma_track);
pma_track += 128;
#endif
#if (USBD_USE_MSC == 1)
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, MSC_IN_EP, PCD_SNG_BUF, pma_track);
pma_track += 128;
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, MSC_OUT_EP, PCD_SNG_BUF, pma_track);
pma_track += 128;
#endif
#if (USBD_USE_DFU == 1)
#endif
#if (USBD_USE_PRNTR == 1)
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, PRNT_IN_EP, PCD_SNG_BUF, pma_track);
pma_track += 128;
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, PRNT_OUT_EP, PCD_SNG_BUF, pma_track);
pma_track += 128;
#endif
#if (USBD_USE_CDC_ACM == 1)
for (uint8_t i = 0; i < USBD_CDC_ACM_COUNT; i++)
{
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, CDC_IN_EP[i], PCD_SNG_BUF, pma_track);
pma_track += 48;
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, CDC_OUT_EP[i], PCD_SNG_BUF, pma_track);
pma_track += 48;
HAL_PCDEx_PMAConfig((PCD_HandleTypeDef *)pdev->pData, CDC_CMD_EP[i], PCD_SNG_BUF, pma_track);
pma_track += 8;
}
#endif
#else /** if HAL_PCDEx_SetRxFiFo() is used by HAL driver */
HAL_PCDEx_SetRxFiFoInBytes(hpcd_USB_OTG_PTR, 512); // ALL OUT EP Buffer
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, 0, 64); // EP0 IN
#if (USBD_USE_CDC_RNDIS == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CDC_RNDIS_IN_EP & 0x7F), 128);
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CDC_RNDIS_CMD_EP & 0x7F), 64);
#endif
#if (USBD_USE_CDC_ECM == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CDC_ECM_IN_EP & 0x7F), 128);
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CDC_ECM_CMD_EP & 0x7F), 64);
#endif
#if (USBD_USE_HID_MOUSE == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (HID_MOUSE_IN_EP & 0x7F), 64);
#endif
#if (USBD_USE_HID_KEYBOARD == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (HID_KEYBOARD_IN_EP & 0x7F), 64);
#endif
#if (USBD_USE_HID_CUSTOM == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CUSTOM_HID_IN_EP & 0x7F), 64);
#endif
#if (USBD_USE_UAC_MIC == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (AUDIO_MIC_EP & 0x7F), 128);
#endif
#if (USBD_USE_UAC_SPKR == 1)
#endif
#if (USBD_USE_UVC == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (UVC_IN_EP & 0x7F), 128);
#endif
#if (USBD_USE_MSC == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (MSC_IN_EP & 0x7F), 128);
#endif
#if (USBD_USE_DFU == 1)
#endif
#if (USBD_USE_PRNTR == 1)
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (PRNT_IN_EP & 0x7F), 128);
#endif
#if (USBD_USE_CDC_ACM == 1)
for (uint8_t i = 0; i < USBD_CDC_ACM_COUNT; i++)
{
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CDC_IN_EP[i] & 0x7F), 128);
HAL_PCDEx_SetTxFiFoInBytes(hpcd_USB_OTG_PTR, (CDC_CMD_EP[i] & 0x7F), 64);
}
#endif
#endif
}
#endif
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
/* Register USB PCD CallBacks */
HAL_PCD_RegisterCallback(hpcd_USB_OTG_PTR, HAL_PCD_SOF_CB_ID, PCD_SOFCallback);
HAL_PCD_RegisterCallback(hpcd_USB_OTG_PTR, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback);
HAL_PCD_RegisterCallback(hpcd_USB_OTG_PTR, HAL_PCD_RESET_CB_ID, PCD_ResetCallback);
HAL_PCD_RegisterCallback(hpcd_USB_OTG_PTR, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback);
HAL_PCD_RegisterCallback(hpcd_USB_OTG_PTR, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback);
HAL_PCD_RegisterCallback(hpcd_USB_OTG_PTR, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback);
HAL_PCD_RegisterCallback(hpcd_USB_OTG_PTR, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback);
HAL_PCD_RegisterDataOutStageCallback(hpcd_USB_OTG_PTR, PCD_DataOutStageCallback);
HAL_PCD_RegisterDataInStageCallback(hpcd_USB_OTG_PTR, PCD_DataInStageCallback);
HAL_PCD_RegisterIsoOutIncpltCallback(hpcd_USB_OTG_PTR, PCD_ISOOUTIncompleteCallback);
HAL_PCD_RegisterIsoInIncpltCallback(hpcd_USB_OTG_PTR, PCD_ISOINIncompleteCallback);
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
return USBD_OK;
}
/**
* @brief De-Initializes the low level portion of the device driver.
* @param pdev: Device handle
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_DeInit(pdev->pData);
usb_status = USBD_Get_USB_Status(hal_status);
return usb_status;
}
/**
* @brief Starts the low level portion of the device driver.
* @param pdev: Device handle
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_Start(pdev->pData);
usb_status = USBD_Get_USB_Status(hal_status);
return usb_status;
}
/**
* @brief Stops the low level portion of the device driver.
* @param pdev: Device handle
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_Stop(pdev->pData);
usb_status = USBD_Get_USB_Status(hal_status);
return usb_status;
}
/**
* @brief Opens an endpoint of the low level driver.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @param ep_type: Endpoint type
* @param ep_mps: Endpoint max packet size
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type);
usb_status = USBD_Get_USB_Status(hal_status);
return usb_status;
}
/**
* @brief Closes an endpoint of the low level driver.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr);
usb_status = USBD_Get_USB_Status(hal_status);
return usb_status;
}
/**
* @brief Flushes an endpoint of the Low Level Driver.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr);
usb_status = USBD_Get_USB_Status(hal_status);
return usb_status;
}
/**
* @brief Sets a Stall condition on an endpoint of the Low Level Driver.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr);
usb_status = USBD_Get_USB_Status(hal_status);
return usb_status;
}
/**
* @brief Clears a Stall condition on an endpoint of the Low Level Driver.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr);
usb_status = USBD_Get_USB_Status(hal_status);
return usb_status;
}
/**
* @brief Returns Stall condition.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @retval Stall (1: Yes, 0: No)
*/
uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{
PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef *)pdev->pData;
if ((ep_addr & 0x80) == 0x80)
{
return hpcd->IN_ep[ep_addr & 0x7F].is_stall;
}
else
{
return hpcd->OUT_ep[ep_addr & 0x7F].is_stall;
}
}
/**
* @brief Assigns a USB address to the device.
* @param pdev: Device handle
* @param dev_addr: Device address
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr);
usb_status = USBD_Get_USB_Status(hal_status);
return usb_status;
}
/**
* @brief Transmits data over an endpoint.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @param pbuf: Pointer to data to be sent
* @param size: Data size
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size);
usb_status = USBD_Get_USB_Status(hal_status);
return usb_status;
}
/**
* @brief Prepares an endpoint for reception.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @param pbuf: Pointer to data to be received
* @param size: Data size
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size);
usb_status = USBD_Get_USB_Status(hal_status);
return usb_status;
}
/**
* @brief Returns the last transfered packet size.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @retval Recived Data Size
*/
uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{
return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef *)pdev->pData, ep_addr);
}
/**
* @brief Delays routine for the USB device library.
* @param Delay: Delay in ms
* @retval None
*/
void USBD_LL_Delay(uint32_t Delay)
{
HAL_Delay(Delay);
}
/**
* @brief Retuns the USB status depending on the HAL status:
* @param hal_status: HAL status
* @retval USB status
*/
USBD_StatusTypeDef USBD_Get_USB_Status(HAL_StatusTypeDef hal_status)
{
USBD_StatusTypeDef usb_status = USBD_OK;
switch (hal_status)
{
case HAL_OK:
usb_status = USBD_OK;
break;
case HAL_ERROR:
usb_status = USBD_FAIL;
break;
case HAL_BUSY:
usb_status = USBD_BUSY;
break;
case HAL_TIMEOUT:
usb_status = USBD_FAIL;
break;
default:
usb_status = USBD_FAIL;
break;
}
return usb_status;
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,177 +1,176 @@
/* USER CODE BEGIN Header */ /* USER CODE BEGIN Header */
/** /**
****************************************************************************** ******************************************************************************
* @file : usbd_conf.h * @file : usbd_conf.h
* @version : v2.0_Cube * @version : v1.0_Cube
* @brief : Header for usbd_conf.c file. * @brief : Header for usbd_conf.c file.
****************************************************************************** ******************************************************************************
* @attention * @attention
* *
* Copyright (c) 2024 STMicroelectronics. * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
* All rights reserved. * All rights reserved.</center></h2>
* *
* This software is licensed under terms that can be found in the LICENSE file * This software component is licensed by ST under Ultimate Liberty license
* in the root directory of this software component. * SLA0044, the "License"; You may not use this file except in compliance with
* If no LICENSE file comes with this software, it is provided AS-IS. * the License. You may obtain a copy of the License at:
* * www.st.com/SLA0044
****************************************************************************** *
*/ ******************************************************************************
/* USER CODE END Header */ */
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_CONF__H__ /* Define to prevent recursive inclusion -------------------------------------*/
#define __USBD_CONF__H__ #ifndef __USBD_CONF__H__
#define __USBD_CONF__H__
#ifdef __cplusplus
extern "C" { #ifdef __cplusplus
#endif extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdio.h> /* Includes ------------------------------------------------------------------*/
#include <stdlib.h> #include <stdio.h>
#include <string.h> #include <stdlib.h>
#include "main.h" #include <string.h>
#include "stm32l4xx.h" #include "main.h"
#include "stm32l4xx_hal.h"
/* USER CODE BEGIN INCLUDE */
/* USER CODE BEGIN INCLUDE */
/* USER CODE END INCLUDE */
/* USER CODE END INCLUDE */
/** @addtogroup USBD_OTG_DRIVER
/** @addtogroup USBD_OTG_DRIVER * @brief Driver for Usb device.
* @brief Driver for Usb device. * @{
* @{ */
*/
/** @defgroup USBD_CONF USBD_CONF
/** @defgroup USBD_CONF USBD_CONF * @brief Configuration file for Usb otg low level driver.
* @brief Configuration file for Usb otg low level driver. * @{
* @{ */
*/
/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables
/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables * @brief Public variables.
* @brief Public variables. * @{
* @{ */
*/
/**
/** * @}
* @} */
*/
/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines
/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines * @brief Defines for configuration of the Usb device.
* @brief Defines for configuration of the Usb device. * @{
* @{ */
*/
/*---------- -----------*/
/*---------- -----------*/ #define USBD_MAX_NUM_INTERFACES 15U
#define USBD_MAX_NUM_INTERFACES 1U /*---------- -----------*/
/*---------- -----------*/ #define USBD_MAX_NUM_CONFIGURATION 1U
#define USBD_MAX_NUM_CONFIGURATION 1U /*---------- -----------*/
/*---------- -----------*/ #define USBD_MAX_STR_DESC_SIZ 512U
#define USBD_MAX_STR_DESC_SIZ 512U /*---------- -----------*/
/*---------- -----------*/ #define USBD_SUPPORT_USER_STRING_DESC 1U
#define USBD_DEBUG_LEVEL 0U /*---------- -----------*/
/*---------- -----------*/ #define USBD_DEBUG_LEVEL 0U
#define USBD_LPM_ENABLED 1U /*---------- -----------*/
/*---------- -----------*/ #define USBD_LPM_ENABLED 0U
#define USBD_SELF_POWERED 1U /*---------- -----------*/
/*---------- -----------*/ #define USBD_SELF_POWERED 1U
#define MSC_MEDIA_PACKET 2048U /*---------- -----------*/
/****************************************/
/* #define for FS and HS identification */ /****************************************/
#define DEVICE_FS 0 /* #define for FS and HS identification */
#define DEVICE_FS 0
/** #define DEVICE_HS 1
* @}
*/ /**
* @}
/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros */
* @brief Aliases.
* @{ /** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros
*/ * @brief Aliases.
* @{
/* Memory management macros */ */
/* Memory management macros make sure to use static memory allocation */ /* Memory management macros */
/** Alias for memory allocation. */ /** Alias for memory allocation. */
#define USBD_malloc (void *)USBD_static_malloc #define USBD_malloc malloc
/** Alias for memory release. */ /** Alias for memory release. */
#define USBD_free USBD_static_free #define USBD_free free
/** Alias for memory set. */ /** Alias for memory set. */
#define USBD_memset memset #define USBD_memset memset
/** Alias for memory copy. */ /** Alias for memory copy. */
#define USBD_memcpy memcpy #define USBD_memcpy memcpy
/** Alias for delay. */ /** Alias for delay. */
#define USBD_Delay HAL_Delay #define USBD_Delay HAL_Delay
/* DEBUG macros */ /* DEBUG macros */
#if (USBD_DEBUG_LEVEL > 0) #if (USBD_DEBUG_LEVEL > 0)
#define USBD_UsrLog(...) printf(__VA_ARGS__);\ #define USBD_UsrLog(...) printf(__VA_ARGS__);\
printf("\n"); printf("\n");
#else #else
#define USBD_UsrLog(...) #define USBD_UsrLog(...)
#endif #endif
#if (USBD_DEBUG_LEVEL > 1) #if (USBD_DEBUG_LEVEL > 1)
#define USBD_ErrLog(...) printf("ERROR: ") ;\ #define USBD_ErrLog(...) printf("ERROR: ") ;\
printf(__VA_ARGS__);\ printf(__VA_ARGS__);\
printf("\n"); printf("\n");
#else #else
#define USBD_ErrLog(...) #define USBD_ErrLog(...)
#endif #endif
#if (USBD_DEBUG_LEVEL > 2) #if (USBD_DEBUG_LEVEL > 2)
#define USBD_DbgLog(...) printf("DEBUG : ") ;\ #define USBD_DbgLog(...) printf("DEBUG : ") ;\
printf(__VA_ARGS__);\ printf(__VA_ARGS__);\
printf("\n"); printf("\n");
#else #else
#define USBD_DbgLog(...) #define USBD_DbgLog(...)
#endif #endif
/** /**
* @} * @}
*/ */
/** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types /** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types
* @brief Types. * @brief Types.
* @{ * @{
*/ */
/** /**
* @} * @}
*/ */
/** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype /** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype
* @brief Declaration of public functions for Usb device. * @brief Declaration of public functions for Usb device.
* @{ * @{
*/ */
/* Exported functions -------------------------------------------------------*/ /* Exported functions -------------------------------------------------------*/
void *USBD_static_malloc(uint32_t size);
void USBD_static_free(void *p); /**
* @}
/** */
* @}
*/ /**
* @}
/** */
* @}
*/ /**
* @}
/** */
* @}
*/ #ifdef __cplusplus
}
#ifdef __cplusplus #endif
}
#endif #endif /* __USBD_CONF__H__ */
#endif /* __USBD_CONF__H__ */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@ -1,100 +0,0 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : usb_device.c
* @version : v2.0_Cube
* @brief : This file implements the USB Device
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "usb_device.h"
#include "usbd_core.h"
#include "usbd_desc.h"
#include "usbd_msc.h"
#include "usbd_storage_if.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
/* USER CODE END PV */
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE END PFP */
/* USB Device Core handle declaration. */
USBD_HandleTypeDef hUsbDeviceFS;
extern USBD_DescriptorsTypeDef FS_Desc;
/*
* -- Insert your variables declaration here --
*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/*
* -- Insert your external function declaration here --
*/
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/**
* Init USB device Library, add supported class and start the library
* @retval None
*/
void MX_USB_DEVICE_Init(void)
{
/* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
/* USER CODE END USB_DEVICE_Init_PreTreatment */
/* Init Device Library, add supported class and start the library. */
if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK)
{
Error_Handler();
}
if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_MSC) != USBD_OK)
{
Error_Handler();
}
if (USBD_MSC_RegisterStorage(&hUsbDeviceFS, &USBD_Storage_Interface_fops_FS) != USBD_OK)
{
Error_Handler();
}
if (USBD_Start(&hUsbDeviceFS) != USBD_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
/* USER CODE END USB_DEVICE_Init_PostTreatment */
}
/**
* @}
*/
/**
* @}
*/

View File

@ -1,871 +0,0 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : Target/usbd_conf.c
* @version : v2.0_Cube
* @brief : This file implements the board support package for the USB device library
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "stm32l4xx.h"
#include "stm32l4xx_hal.h"
#include "usbd_def.h"
#include "usbd_core.h"
#include "usbd_msc.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
/* USER CODE END PV */
PCD_HandleTypeDef hpcd_USB_OTG_FS;
void Error_Handler(void);
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/* Exported function prototypes ----------------------------------------------*/
extern USBD_StatusTypeDef USBD_LL_BatteryCharging(USBD_HandleTypeDef *pdev);
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE END PFP */
/* Private functions ---------------------------------------------------------*/
/* USER CODE BEGIN 1 */
static void SystemClockConfig_Resume(void);
/* USER CODE END 1 */
extern void SystemClock_Config(void);
/*******************************************************************************
LL Driver Callbacks (PCD -> USB Device Library)
*******************************************************************************/
/* MSP Init */
void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(pcdHandle->Instance==USB_OTG_FS)
{
/* USER CODE BEGIN USB_OTG_FS_MspInit 0 */
/* USER CODE END USB_OTG_FS_MspInit 0 */
__HAL_RCC_GPIOA_CLK_ENABLE();
/**USB_OTG_FS GPIO Configuration
PA11 ------> USB_OTG_FS_DM
PA12 ------> USB_OTG_FS_DP
*/
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* Peripheral clock enable */
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
/* Enable VDDUSB */
if(__HAL_RCC_PWR_IS_CLK_DISABLED())
{
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_EnableVddUSB();
__HAL_RCC_PWR_CLK_DISABLE();
}
else
{
HAL_PWREx_EnableVddUSB();
}
/* Peripheral interrupt init */
HAL_NVIC_SetPriority(OTG_FS_IRQn, 2, 0);
HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
/* USER CODE BEGIN USB_OTG_FS_MspInit 1 */
/* USER CODE END USB_OTG_FS_MspInit 1 */
}
}
void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle)
{
if(pcdHandle->Instance==USB_OTG_FS)
{
/* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */
/* USER CODE END USB_OTG_FS_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_USB_OTG_FS_CLK_DISABLE();
/**USB_OTG_FS GPIO Configuration
PA11 ------> USB_OTG_FS_DM
PA12 ------> USB_OTG_FS_DP
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
/* Disable VDDUSB */
if(__HAL_RCC_PWR_IS_CLK_DISABLED())
{
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_DisableVddUSB();
__HAL_RCC_PWR_CLK_DISABLE();
}
else
{
HAL_PWREx_DisableVddUSB();
}
/* Peripheral interrupt Deinit*/
HAL_NVIC_DisableIRQ(OTG_FS_IRQn);
/* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */
/* USER CODE END USB_OTG_FS_MspDeInit 1 */
}
}
/**
* @brief Setup stage callback
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_SetupStage((USBD_HandleTypeDef*)hpcd->pData, (uint8_t *)hpcd->Setup);
}
/**
* @brief Data Out stage callback.
* @param hpcd: PCD handle
* @param epnum: Endpoint number
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#else
void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_DataOutStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->OUT_ep[epnum].xfer_buff);
}
/**
* @brief Data In stage callback.
* @param hpcd: PCD handle
* @param epnum: Endpoint number
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#else
void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_DataInStage((USBD_HandleTypeDef*)hpcd->pData, epnum, hpcd->IN_ep[epnum].xfer_buff);
}
/**
* @brief SOF callback.
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_SOF((USBD_HandleTypeDef*)hpcd->pData);
}
/**
* @brief Reset callback.
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_SpeedTypeDef speed = USBD_SPEED_FULL;
if ( hpcd->Init.speed != PCD_SPEED_FULL)
{
Error_Handler();
}
/* Set Speed. */
USBD_LL_SetSpeed((USBD_HandleTypeDef*)hpcd->pData, speed);
/* Reset Device. */
USBD_LL_Reset((USBD_HandleTypeDef*)hpcd->pData);
}
/**
* @brief Suspend callback.
* When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it)
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
__HAL_PCD_GATE_PHYCLOCK(hpcd);
/* Inform USB library that core enters in suspend Mode. */
USBD_LL_Suspend((USBD_HandleTypeDef*)hpcd->pData);
/* Enter in STOP mode. */
/* USER CODE BEGIN 2 */
if (hpcd->Init.low_power_enable)
{
/* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */
SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
}
/* USER CODE END 2 */
}
/**
* @brief Resume callback.
* When Low power mode is enabled the debug cannot be used (IAR, Keil doesn't support it)
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_ResumeCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
__HAL_PCD_UNGATE_PHYCLOCK(hpcd);
/* USER CODE BEGIN 3 */
if (hpcd->Init.low_power_enable)
{
/* Reset SLEEPDEEP bit of Cortex System Control Register. */
SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
SystemClockConfig_Resume();
}
/* USER CODE END 3 */
USBD_LL_Resume((USBD_HandleTypeDef*)hpcd->pData);
}
/**
* @brief ISOOUTIncomplete callback.
* @param hpcd: PCD handle
* @param epnum: Endpoint number
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#else
void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_IsoOUTIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum);
}
/**
* @brief ISOINIncomplete callback.
* @param hpcd: PCD handle
* @param epnum: Endpoint number
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#else
void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_IsoINIncomplete((USBD_HandleTypeDef*)hpcd->pData, epnum);
}
/**
* @brief Connect callback.
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_ConnectCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_DevConnected((USBD_HandleTypeDef*)hpcd->pData);
}
/**
* @brief Disconnect callback.
* @param hpcd: PCD handle
* @retval None
*/
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
static void PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
#else
void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
{
USBD_LL_DevDisconnected((USBD_HandleTypeDef*)hpcd->pData);
}
/*******************************************************************************
LL Driver Interface (USB Device Library --> PCD)
*******************************************************************************/
/**
* @brief Initializes the low level portion of the device driver.
* @param pdev: Device handle
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)
{
/* Init USB Ip. */
if (pdev->id == DEVICE_FS) {
/* Enable USB power on Pwrctrl CR2 register. */
/* Link the driver to the stack. */
hpcd_USB_OTG_FS.pData = pdev;
pdev->pData = &hpcd_USB_OTG_FS;
hpcd_USB_OTG_FS.Instance = USB_OTG_FS;
hpcd_USB_OTG_FS.Init.dev_endpoints = 6;
hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL;
hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE;
hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE;
hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE;
hpcd_USB_OTG_FS.Init.battery_charging_enable = DISABLE;
hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE;
hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE;
if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK)
{
Error_Handler( );
}
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
/* Register USB PCD CallBacks */
HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SOF_CB_ID, PCD_SOFCallback);
HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SETUPSTAGE_CB_ID, PCD_SetupStageCallback);
HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESET_CB_ID, PCD_ResetCallback);
HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_SUSPEND_CB_ID, PCD_SuspendCallback);
HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_RESUME_CB_ID, PCD_ResumeCallback);
HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_CONNECT_CB_ID, PCD_ConnectCallback);
HAL_PCD_RegisterCallback(&hpcd_USB_OTG_FS, HAL_PCD_DISCONNECT_CB_ID, PCD_DisconnectCallback);
HAL_PCD_RegisterDataOutStageCallback(&hpcd_USB_OTG_FS, PCD_DataOutStageCallback);
HAL_PCD_RegisterDataInStageCallback(&hpcd_USB_OTG_FS, PCD_DataInStageCallback);
HAL_PCD_RegisterIsoOutIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOOUTIncompleteCallback);
HAL_PCD_RegisterIsoInIncpltCallback(&hpcd_USB_OTG_FS, PCD_ISOINIncompleteCallback);
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);
HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80);
}
return USBD_OK;
}
/**
* @brief De-Initializes the low level portion of the device driver.
* @param pdev: Device handle
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_DeInit(pdev->pData);
switch (hal_status) {
case HAL_OK :
usb_status = USBD_OK;
break;
case HAL_ERROR :
usb_status = USBD_FAIL;
break;
case HAL_BUSY :
usb_status = USBD_BUSY;
break;
case HAL_TIMEOUT :
usb_status = USBD_FAIL;
break;
default :
usb_status = USBD_FAIL;
break;
}
return usb_status;
}
/**
* @brief Starts the low level portion of the device driver.
* @param pdev: Device handle
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_Start(pdev->pData);
switch (hal_status) {
case HAL_OK :
usb_status = USBD_OK;
break;
case HAL_ERROR :
usb_status = USBD_FAIL;
break;
case HAL_BUSY :
usb_status = USBD_BUSY;
break;
case HAL_TIMEOUT :
usb_status = USBD_FAIL;
break;
default :
usb_status = USBD_FAIL;
break;
}
return usb_status;
}
/**
* @brief Stops the low level portion of the device driver.
* @param pdev: Device handle
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_Stop(pdev->pData);
switch (hal_status) {
case HAL_OK :
usb_status = USBD_OK;
break;
case HAL_ERROR :
usb_status = USBD_FAIL;
break;
case HAL_BUSY :
usb_status = USBD_BUSY;
break;
case HAL_TIMEOUT :
usb_status = USBD_FAIL;
break;
default :
usb_status = USBD_FAIL;
break;
}
return usb_status;
}
/**
* @brief Opens an endpoint of the low level driver.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @param ep_type: Endpoint type
* @param ep_mps: Endpoint max packet size
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type);
switch (hal_status) {
case HAL_OK :
usb_status = USBD_OK;
break;
case HAL_ERROR :
usb_status = USBD_FAIL;
break;
case HAL_BUSY :
usb_status = USBD_BUSY;
break;
case HAL_TIMEOUT :
usb_status = USBD_FAIL;
break;
default :
usb_status = USBD_FAIL;
break;
}
return usb_status;
}
/**
* @brief Closes an endpoint of the low level driver.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr);
switch (hal_status) {
case HAL_OK :
usb_status = USBD_OK;
break;
case HAL_ERROR :
usb_status = USBD_FAIL;
break;
case HAL_BUSY :
usb_status = USBD_BUSY;
break;
case HAL_TIMEOUT :
usb_status = USBD_FAIL;
break;
default :
usb_status = USBD_FAIL;
break;
}
return usb_status;
}
/**
* @brief Flushes an endpoint of the Low Level Driver.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr);
switch (hal_status) {
case HAL_OK :
usb_status = USBD_OK;
break;
case HAL_ERROR :
usb_status = USBD_FAIL;
break;
case HAL_BUSY :
usb_status = USBD_BUSY;
break;
case HAL_TIMEOUT :
usb_status = USBD_FAIL;
break;
default :
usb_status = USBD_FAIL;
break;
}
return usb_status;
}
/**
* @brief Sets a Stall condition on an endpoint of the Low Level Driver.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr);
switch (hal_status) {
case HAL_OK :
usb_status = USBD_OK;
break;
case HAL_ERROR :
usb_status = USBD_FAIL;
break;
case HAL_BUSY :
usb_status = USBD_BUSY;
break;
case HAL_TIMEOUT :
usb_status = USBD_FAIL;
break;
default :
usb_status = USBD_FAIL;
break;
}
return usb_status;
}
/**
* @brief Clears a Stall condition on an endpoint of the Low Level Driver.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr);
switch (hal_status) {
case HAL_OK :
usb_status = USBD_OK;
break;
case HAL_ERROR :
usb_status = USBD_FAIL;
break;
case HAL_BUSY :
usb_status = USBD_BUSY;
break;
case HAL_TIMEOUT :
usb_status = USBD_FAIL;
break;
default :
usb_status = USBD_FAIL;
break;
}
return usb_status;
}
/**
* @brief Returns Stall condition.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @retval Stall (1: Yes, 0: No)
*/
uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{
PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData;
if((ep_addr & 0x80) == 0x80)
{
return hpcd->IN_ep[ep_addr & 0x7F].is_stall;
}
else
{
return hpcd->OUT_ep[ep_addr & 0x7F].is_stall;
}
}
/**
* @brief Assigns a USB address to the device.
* @param pdev: Device handle
* @param dev_addr: Device address
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_addr)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr);
switch (hal_status) {
case HAL_OK :
usb_status = USBD_OK;
break;
case HAL_ERROR :
usb_status = USBD_FAIL;
break;
case HAL_BUSY :
usb_status = USBD_BUSY;
break;
case HAL_TIMEOUT :
usb_status = USBD_FAIL;
break;
default :
usb_status = USBD_FAIL;
break;
}
return usb_status;
}
/**
* @brief Transmits data over an endpoint.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @param pbuf: Pointer to data to be sent
* @param size: Data size
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size);
switch (hal_status) {
case HAL_OK :
usb_status = USBD_OK;
break;
case HAL_ERROR :
usb_status = USBD_FAIL;
break;
case HAL_BUSY :
usb_status = USBD_BUSY;
break;
case HAL_TIMEOUT :
usb_status = USBD_FAIL;
break;
default :
usb_status = USBD_FAIL;
break;
}
return usb_status;
}
/**
* @brief Prepares an endpoint for reception.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @param pbuf: Pointer to data to be received
* @param size: Data size
* @retval USBD status
*/
USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size)
{
HAL_StatusTypeDef hal_status = HAL_OK;
USBD_StatusTypeDef usb_status = USBD_OK;
hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size);
switch (hal_status) {
case HAL_OK :
usb_status = USBD_OK;
break;
case HAL_ERROR :
usb_status = USBD_FAIL;
break;
case HAL_BUSY :
usb_status = USBD_BUSY;
break;
case HAL_TIMEOUT :
usb_status = USBD_FAIL;
break;
default :
usb_status = USBD_FAIL;
break;
}
return usb_status;
}
/**
* @brief Returns the last transferred packet size.
* @param pdev: Device handle
* @param ep_addr: Endpoint number
* @retval Received Data Size
*/
uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
{
return HAL_PCD_EP_GetRxCount((PCD_HandleTypeDef*) pdev->pData, ep_addr);
}
/**
* @brief Send LPM message to user layer
* @param hpcd: PCD handle
* @param msg: LPM message
* @retval None
*/
void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg)
{
switch (msg)
{
case PCD_LPM_L0_ACTIVE:
if (hpcd->Init.low_power_enable)
{
SystemClockConfig_Resume();
/* Reset SLEEPDEEP bit of Cortex System Control Register. */
SCB->SCR &= (uint32_t)~((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
}
__HAL_PCD_UNGATE_PHYCLOCK(hpcd);
USBD_LL_Resume(hpcd->pData);
break;
case PCD_LPM_L1_ACTIVE:
__HAL_PCD_GATE_PHYCLOCK(hpcd);
USBD_LL_Suspend(hpcd->pData);
/* Enter in STOP mode. */
if (hpcd->Init.low_power_enable)
{
/* Set SLEEPDEEP bit and SleepOnExit of Cortex System Control Register. */
SCB->SCR |= (uint32_t)((uint32_t)(SCB_SCR_SLEEPDEEP_Msk | SCB_SCR_SLEEPONEXIT_Msk));
}
break;
}
}
/**
* @brief Delays routine for the USB Device Library.
* @param Delay: Delay in ms
* @retval None
*/
void USBD_LL_Delay(uint32_t Delay)
{
HAL_Delay(Delay);
}
/**
* @brief Static single allocation.
* @param size: Size of allocated memory
* @retval None
*/
void *USBD_static_malloc(uint32_t size)
{
static uint32_t mem[(sizeof(USBD_MSC_BOT_HandleTypeDef)/4)+1];/* On 32-bit boundary */
return mem;
}
/**
* @brief Dummy memory free
* @param p: Pointer to allocated memory address
* @retval None
*/
void USBD_static_free(void *p)
{
}
/* USER CODE BEGIN 5 */
/**
* @brief Configures system clock after wake-up from USB resume callBack:
* enable HSI, PLL and select PLL as system clock source.
* @retval None
*/
static void SystemClockConfig_Resume(void)
{
SystemClock_Config();
}
/* USER CODE END 5 */

View File

@ -16,29 +16,34 @@ target_compile_definitions(
target_include_directories( target_include_directories(
${TARGET_NAME} PRIVATE ${TARGET_NAME} PRIVATE
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Core\\Inc>" "$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Core\\Inc>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_DEVICE\\App>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_DEVICE\\Target>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\STM32L4xx_HAL_Driver\\Inc>" "$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\STM32L4xx_HAL_Driver\\Inc>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\STM32L4xx_HAL_Driver\\Inc\\Legacy>" "$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\STM32L4xx_HAL_Driver\\Inc\\Legacy>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Middlewares\\ST\\STM32_USB_Device_Library\\Core\\Inc>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Middlewares\\ST\\STM32_USB_Device_Library\\Class\\MSC\\Inc>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\CMSIS\\Device\\ST\\STM32L4xx\\Include>" "$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\CMSIS\\Device\\ST\\STM32L4xx\\Include>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\CMSIS\\Include>" "$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\CMSIS\\Include>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/FATFS\\Target>" "$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/FATFS\\Target>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/FATFS\\App>" "$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/FATFS\\App>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Middlewares\\Third_Party\\FatFs\\src>" "$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Middlewares\\Third_Party\\FatFs\\src>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_COMPOSITE>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_COMPOSITE\\App>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_COMPOSITE\\Class\\CDC_ACM\\Inc>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_COMPOSITE\\Class\\COMPOSITE\\Inc>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_COMPOSITE\\Class\\MSC\\Inc>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_COMPOSITE\\Core\\Inc>"
"$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_COMPOSITE\\Target>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Core\\Inc>" "$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Core\\Inc>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_DEVICE\\App>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_DEVICE\\Target>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\STM32L4xx_HAL_Driver\\Inc>" "$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\STM32L4xx_HAL_Driver\\Inc>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\STM32L4xx_HAL_Driver\\Inc\\Legacy>" "$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\STM32L4xx_HAL_Driver\\Inc\\Legacy>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Middlewares\\ST\\STM32_USB_Device_Library\\Core\\Inc>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Middlewares\\ST\\STM32_USB_Device_Library\\Class\\MSC\\Inc>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\CMSIS\\Device\\ST\\STM32L4xx\\Include>" "$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\CMSIS\\Device\\ST\\STM32L4xx\\Include>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\CMSIS\\Include>" "$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Drivers\\CMSIS\\Include>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/FATFS\\Target>" "$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/FATFS\\Target>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/FATFS\\App>" "$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/FATFS\\App>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Middlewares\\Third_Party\\FatFs\\src>" "$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/Middlewares\\Third_Party\\FatFs\\src>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_COMPOSITE\\App>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_COMPOSITE\\Class\\CDC_ACM\\Inc>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_COMPOSITE\\Class\\COMPOSITE\\Inc>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_COMPOSITE\\Class\\MSC\\Inc>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_COMPOSITE\\Core\\Inc>"
"$<$<AND:$<NOT:$<CONFIG:Debug>>,$<COMPILE_LANGUAGE:C>>:${PROJECT_SOURCE_DIR}/USB_COMPOSITE\\Target>"
) )
target_compile_options( target_compile_options(
@ -98,13 +103,20 @@ target_sources(
"FATFS\\App\\fatfs.c" "FATFS\\App\\fatfs.c"
"FATFS\\Target\\bsp_driver_mmc.c" "FATFS\\Target\\bsp_driver_mmc.c"
"FATFS\\Target\\user_diskio.c" "FATFS\\Target\\user_diskio.c"
"Middlewares\\ST\\STM32_USB_Device_Library\\Class\\MSC\\Src\\usbd_msc_bot.c" "USB_COMPOSITE\\App\\usb_device.c"
"Middlewares\\ST\\STM32_USB_Device_Library\\Class\\MSC\\Src\\usbd_msc_data.c" "USB_COMPOSITE\\App\\usbd_cdc_acm_if.c"
"Middlewares\\ST\\STM32_USB_Device_Library\\Class\\MSC\\Src\\usbd_msc_scsi.c" "USB_COMPOSITE\\App\\usbd_desc.c"
"Middlewares\\ST\\STM32_USB_Device_Library\\Class\\MSC\\Src\\usbd_msc.c" "USB_COMPOSITE\\App\\usbd_msc_if.c"
"Middlewares\\ST\\STM32_USB_Device_Library\\Core\\Src\\usbd_core.c" "USB_COMPOSITE\\Class\\CDC_ACM\\Src\\usbd_cdc_acm.c"
"Middlewares\\ST\\STM32_USB_Device_Library\\Core\\Src\\usbd_ctlreq.c" "USB_COMPOSITE\\Class\\COMPOSITE\\Src\\usbd_composite.c"
"Middlewares\\ST\\STM32_USB_Device_Library\\Core\\Src\\usbd_ioreq.c" "USB_COMPOSITE\\Class\\MSC\\Src\\usbd_msc_bot.c"
"USB_COMPOSITE\\Class\\MSC\\Src\\usbd_msc_data.c"
"USB_COMPOSITE\\Class\\MSC\\Src\\usbd_msc_scsi.c"
"USB_COMPOSITE\\Class\\MSC\\Src\\usbd_msc.c"
"USB_COMPOSITE\\Core\\Src\\usbd_core.c"
"USB_COMPOSITE\\Core\\Src\\usbd_ctlreq.c"
"USB_COMPOSITE\\Core\\Src\\usbd_ioreq.c"
"USB_COMPOSITE\\Target\\usbd_conf.c"
"Middlewares\\Third_Party\\FatFs\\src\\diskio.c" "Middlewares\\Third_Party\\FatFs\\src\\diskio.c"
"Middlewares\\Third_Party\\FatFs\\src\\ff_gen_drv.c" "Middlewares\\Third_Party\\FatFs\\src\\ff_gen_drv.c"
"Middlewares\\Third_Party\\FatFs\\src\\ff.c" "Middlewares\\Third_Party\\FatFs\\src\\ff.c"
@ -140,10 +152,6 @@ target_sources(
"Drivers\\STM32L4xx_HAL_Driver\\Src\\stm32l4xx_hal.c" "Drivers\\STM32L4xx_HAL_Driver\\Src\\stm32l4xx_hal.c"
"Drivers\\STM32L4xx_HAL_Driver\\Src\\stm32l4xx_ll_sdmmc.c" "Drivers\\STM32L4xx_HAL_Driver\\Src\\stm32l4xx_ll_sdmmc.c"
"Drivers\\STM32L4xx_HAL_Driver\\Src\\stm32l4xx_ll_usb.c" "Drivers\\STM32L4xx_HAL_Driver\\Src\\stm32l4xx_ll_usb.c"
"USB_DEVICE\\App\\usb_device.c"
"USB_DEVICE\\App\\usbd_desc.c"
"USB_DEVICE\\App\\usbd_storage_if.c"
"USB_DEVICE\\Target\\usbd_conf.c"
) )
add_custom_command( add_custom_command(