kopia lustrzana https://github.com/solokeys/solo1
move things around and add efm8 and efm32 builds
rodzic
e446e29318
commit
fb9a592d50
|
@ -61,3 +61,6 @@ tools/attest
|
|||
|
||||
sdk_15.0.0/
|
||||
_build/
|
||||
|
||||
GNU\ *
|
||||
Keil\ *
|
||||
|
|
23
device.h
23
device.h
|
@ -1,23 +0,0 @@
|
|||
#ifndef _DEVICE_H
|
||||
#define _DEVICE_H
|
||||
|
||||
void device_init();
|
||||
|
||||
uint64_t millis();
|
||||
|
||||
// HID message size in bytes
|
||||
#define HID_MESSAGE_SIZE 64
|
||||
|
||||
void usbhid_init();
|
||||
|
||||
int usbhid_recv(uint8_t * msg);
|
||||
|
||||
void usbhid_send(uint8_t * msg);
|
||||
|
||||
void usbhid_close();
|
||||
|
||||
void main_loop_delay();
|
||||
|
||||
void heartbeat();
|
||||
|
||||
#endif
|
|
@ -0,0 +1,229 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.debug#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.debug#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904" moduleId="org.eclipse.cdt.core.settings" name="GNU ARM v7.2.1 - Debug">
|
||||
<macros>
|
||||
<stringMacro name="StudioSdkPath" type="VALUE_PATH_DIR" value="${StudioSdkPathFromID:com.silabs.sdk.stack.super:1.1.1._310456152}"/>
|
||||
<stringMacro name="StudioToolchainPath" type="VALUE_PATH_DIR" value="${StudioToolchainPathFromID:com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904}"/>
|
||||
</macros>
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.HEX" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.EBL" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.GBL" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.BIN" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.S37" 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.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule buildConfig.stockConfigId="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.debug#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904" cppBuildConfig.builtinIncludes="studio:/sdk/platform/CMSIS/Include/ studio:/sdk/platform/emlib/inc/ studio:/sdk/hardware/kit/SLSTK3401A_EFM32PG/config/ studio:/sdk/platform/Device/SiliconLabs/EFM32PG1B/Include/ studio:/sdk/hardware/kit/common/drivers/ studio:/sdk/platform/CMSIS/Include/ studio:/sdk/platform/emlib/inc/ studio:/sdk/hardware/kit/SLSTK3401A_EFM32PG/config/ studio:/sdk/platform/Device/SiliconLabs/EFM32PG1B/Include/ studio:/sdk/hardware/kit/common/drivers/" cppBuildConfig.builtinLibraryFiles="" cppBuildConfig.builtinLibraryNames="" cppBuildConfig.builtinLibraryObjects="" cppBuildConfig.builtinLibraryPaths="" cppBuildConfig.builtinMacros="EFM32PG1B200F256GM48 EFM32PG1B200F256GM48" moduleId="com.silabs.ss.framework.ide.project.core.cpp" projectCommon.referencedModules="[{"builtinExcludes":[],"builtinSources":[],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.exx32.common.drivers\">\r\n <exclusions pattern=\".*\"/>\r\n</project:MModule>"},{"builtinExcludes":[],"builtinSources":["CMSIS/EFM32PG1B/startup_gcc_efm32pg1b.s","CMSIS/EFM32PG1B/system_efm32pg1b.c"],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.exx32.part\"/>"},{"builtinExcludes":[],"builtinSources":[],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.exx32.common.CMSIS\">\r\n <exclusions pattern=\".*\"/>\r\n</project:MModule>"},{"builtinExcludes":["emlib/em_timer.c"],"builtinSources":["emlib/em_gpio.c","emlib/em_system.c","emlib/em_cmu.c","emlib/em_cryotimer.c","emlib/em_assert.c","emlib/em_emu.c","emlib/em_usart.c","emlib/em_timer.c"],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.exx32.common.emlib\">\r\n <inclusions pattern=\"emlib/em_system.c\"/>\r\n <inclusions pattern=\"emlib/em_emu.c\"/>\r\n <inclusions pattern=\"emlib/em_cmu.c\"/>\r\n <inclusions pattern=\"emlib/em_device.c\"/>\r\n <inclusions pattern=\"emlib/em_chip.c\"/>\r\n <inclusions pattern=\"emlib/em_assert.c\"/>\r\n <inclusions pattern=\"emlib/em_cryotimer.c\"/>\r\n <inclusions pattern=\"emlib/em_gpio.c\"/>\r\n <inclusions pattern=\"emlib/em_usart.c\"/>\r\n</project:MModule>"},{"builtinExcludes":[],"builtinSources":[],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.exx32.board\"/>"}]" projectCommon.toolchainId="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904"/>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" description="" id="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.debug#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904" name="GNU ARM v7.2.1 - Debug" parent="com.silabs.ide.si32.gcc.cdt.managedbuild.config.gnu.exe">
|
||||
<folderInfo id="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.debug#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904." name="/" resourcePath="">
|
||||
<toolChain id="com.silabs.ide.si32.gcc.cdt.managedbuild.toolchain.exe.1911691633" name="Si32 GNU ARM" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.toolchain.exe">
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.toolchain.debug.level.50213284" name="Debug Level" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.toolchain.debug.level" value="com.silabs.ide.si32.gcc.cdt.managedbuild.toolchain.debug.level.default" valueType="enumerated"/>
|
||||
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF;com.silabs.ss.framework.debugger.core.BIN;com.silabs.ss.framework.debugger.core.HEX;com.silabs.ss.framework.debugger.core.S37;com.silabs.ss.framework.debugger.core.EBL;com.silabs.ss.framework.debugger.core.GBL" id="com.silabs.ide.si32.gcc.cdt.managedbuild.target.gnu.platform.base.1696251138" isAbstract="false" name="Debug Platform" osList="win32,linux,macosx" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.target.gnu.platform.base"/>
|
||||
<builder buildPath="${workspace_loc:/EFM32}/GNU ARM v7.2.1 - Debug" id="com.silabs.ide.si32.gcc.cdt.managedbuild.target.gnu.builder.base.819523820" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Si32 GNU ARM Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.target.gnu.builder.base">
|
||||
<outputEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="GNU ARM v7.2.1 - Debug"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="outputPath" name="GNU ARM v7.2.1 - Release"/>
|
||||
</outputEntries>
|
||||
</builder>
|
||||
<tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.base.1333897234" name="GNU ARM C Compiler" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.base">
|
||||
<option id="gnu.c.compiler.option.optimization.level.2126040501" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" value="gnu.c.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.def.symbols.840936075" name="Defined symbols (-D)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.def.symbols" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="DEBUG=1"/>
|
||||
<listOptionValue builtIn="false" value="EFM32PG1B200F256GM48=1"/>
|
||||
</option>
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.debug.builtin.520588332" name="Always branch to builtin functions (-fno-builtin)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.debug.builtin" value="true" valueType="boolean"/>
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.debug.prolog.968514718" name="Generate debugger-friendly prologs (-mno-sched-prolog)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.debug.prolog" value="true" valueType="boolean"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.512507932" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/EFM32/inc}""/>
|
||||
<listOptionValue builtIn="false" value="C:/Users/conor/Desktop/u2f-one/crypto/sha256"/>
|
||||
<listOptionValue builtIn="false" value="C:/Users/conor/Desktop/u2f-one/crypto/micro-ecc"/>
|
||||
<listOptionValue builtIn="false" value="C:/Users/conor/Desktop/u2f-one/crypto/tiny-AES-c"/>
|
||||
<listOptionValue builtIn="false" value="C:/Users/conor/Desktop/u2f-one/fido2"/>
|
||||
<listOptionValue builtIn="false" value="C:/Users/conor/Desktop/u2f-one/tinycbor/src"/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/hardware/kit/common/bsp""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/platform/CMSIS/Include""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/platform/emlib/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/hardware/kit/SLSTK3401A_EFM32PG/config""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/platform/Device/SiliconLabs/EFM32PG1B/Include""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/hardware/kit/common/drivers""/>
|
||||
</option>
|
||||
<inputType id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.input.492241787" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.compiler.base.2037449609" name="GNU ARM C++ Compiler" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.compiler.base">
|
||||
<option id="gnu.cpp.compiler.option.optimization.level.1457234551" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.compiler.debug.builtin.352493524" name="Always branch to builtin functions (-fno-builtin)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.compiler.debug.builtin" value="true" valueType="boolean"/>
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.compiler.debug.prolog.1409695025" name="Generate debugger-friendly prologs (-mno-sched-prolog)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.compiler.debug.prolog" value="true" valueType="boolean"/>
|
||||
</tool>
|
||||
<tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.assembler.base.292016695" name="GNU ARM Assembler" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.assembler.base">
|
||||
<option id="gnu.both.asm.option.include.paths.1965579973" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/EFM32/inc}""/>
|
||||
<listOptionValue builtIn="false" value="C:/Users/conor/Desktop/u2f-one/crypto/micro-ecc"/>
|
||||
<listOptionValue builtIn="false" value="C:/Users/conor/Desktop/u2f-one/crypto/tiny-AES-c"/>
|
||||
<listOptionValue builtIn="false" value="C:/Users/conor/Desktop/u2f-one/fido2"/>
|
||||
<listOptionValue builtIn="false" value="C:/Users/conor/Desktop/u2f-one/tinycbor/src"/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/hardware/kit/common/bsp""/>
|
||||
<listOptionValue builtIn="false" value="C:/Users/conor/Desktop/u2f-one/crypto"/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/platform/CMSIS/Include""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/platform/emlib/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/hardware/kit/SLSTK3401A_EFM32PG/config""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/platform/Device/SiliconLabs/EFM32PG1B/Include""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/hardware/kit/common/drivers""/>
|
||||
</option>
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.as.def.symbols.788575142" name="Defined symbols (-D)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.as.def.symbols" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="DEBUG=1"/>
|
||||
<listOptionValue builtIn="false" value="EFM32PG1B200F256GM48=1"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.724838549" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.linker.base.680374566" name="GNU ARM C Linker" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.linker.base">
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.linker.nostdlibs.180221163" name="No startup or default libs (-nostdlib)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.linker.nostdlibs" value="false" valueType="boolean"/>
|
||||
<option id="gnu.c.link.option.libs.2103653915" name="Libraries (-l)" superClass="gnu.c.link.option.libs" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="tinycbor"/>
|
||||
</option>
|
||||
<option id="gnu.c.link.option.paths.921756731" name="Library search path (-L)" superClass="gnu.c.link.option.paths" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="C:/Users/conor/Desktop/u2f-one/tinycbor/lib/"/>
|
||||
</option>
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.linker.category.ordering.selection.172160776" name="Linker input ordering" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.linker.category.ordering.selection" value="./src/InitDevice.o;./src/device.o;./src/main.o;./src/printing.o;./src/retargetio.o;./fido2/crypto.o;./fido2/ctap.o;./fido2/ctap_parse.o;./fido2/ctaphid.o;./fido2/log.o;./fido2/main.o;./fido2/stubs.o;./fido2/test_power.o;./fido2/u2f.o;./fido2/util.o;./emlib/em_assert.o;./emlib/em_cmu.o;./emlib/em_cryotimer.o;./emlib/em_emu.o;./emlib/em_gpio.o;./emlib/em_system.o;./emlib/em_usart.o;./crypto/tiny-AES-c/aes.o;./crypto/sha256/sha256.o;./crypto/micro-ecc/uECC.o;./CMSIS/EFM32PG1B/startup_gcc_efm32pg1b.o;./CMSIS/EFM32PG1B/system_efm32pg1b.o;-ltinycbor" valueType="string"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1977486948" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.linker.base.849945946" name="GNU ARM C++ Linker" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.linker.base"/>
|
||||
<tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.archiver.base.1005614888" name="GNU ARM Archiver" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.archiver.base"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="emlib/em_timer.c|crypto|fido2" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry excluding="aes-gcm|micro-ecc/examples|micro-ecc/scripts|micro-ecc/test|tiny-AES-c/test.c" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="crypto"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="fido2"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.release#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.release#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904" moduleId="org.eclipse.cdt.core.settings" name="GNU ARM v7.2.1 - Release">
|
||||
<macros>
|
||||
<stringMacro name="StudioSdkPath" type="VALUE_PATH_DIR" value="${StudioSdkPathFromID:com.silabs.sdk.stack.super:1.1.1._310456152}"/>
|
||||
<stringMacro name="StudioToolchainPath" type="VALUE_PATH_DIR" value="${StudioToolchainPathFromID:com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904}"/>
|
||||
</macros>
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.HEX" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.EBL" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.GBL" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.BIN" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.S37" 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.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule buildConfig.stockConfigId="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.release#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904" cppBuildConfig.builtinIncludes="studio:/sdk/platform/CMSIS/Include/ studio:/sdk/platform/emlib/inc/ studio:/sdk/hardware/kit/SLSTK3401A_EFM32PG/config/ studio:/sdk/platform/Device/SiliconLabs/EFM32PG1B/Include/ studio:/sdk/hardware/kit/common/drivers/ studio:/sdk/hardware/kit/common/bsp/ studio:/sdk/platform/CMSIS/Include/ studio:/sdk/platform/emlib/inc/ studio:/sdk/hardware/kit/SLSTK3401A_EFM32PG/config/ studio:/sdk/platform/Device/SiliconLabs/EFM32PG1B/Include/ studio:/sdk/hardware/kit/common/drivers/ studio:/sdk/hardware/kit/common/bsp/" cppBuildConfig.builtinLibraryFiles="" cppBuildConfig.builtinLibraryNames="" cppBuildConfig.builtinLibraryObjects="" cppBuildConfig.builtinLibraryPaths="" cppBuildConfig.builtinMacros="EFM32PG1B200F256GM48 EFM32PG1B200F256GM48" moduleId="com.silabs.ss.framework.ide.project.core.cpp" projectCommon.referencedModules="[{"builtinExcludes":["emlib/em_timer.c"],"builtinSources":["emlib/em_gpio.c","emlib/em_system.c","emlib/em_cmu.c","emlib/em_cryotimer.c","emlib/em_assert.c","emlib/em_emu.c","emlib/em_usart.c","emlib/em_timer.c"],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.exx32.common.emlib\">\r\n <inclusions pattern=\"emlib/em_system.c\"/>\r\n <inclusions pattern=\"emlib/em_emu.c\"/>\r\n <inclusions pattern=\"emlib/em_cmu.c\"/>\r\n <inclusions pattern=\"emlib/em_device.c\"/>\r\n <inclusions pattern=\"emlib/em_chip.c\"/>\r\n <inclusions pattern=\"emlib/em_assert.c\"/>\r\n <inclusions pattern=\"emlib/em_cryotimer.c\"/>\r\n <inclusions pattern=\"emlib/em_gpio.c\"/>\r\n <inclusions pattern=\"emlib/em_usart.c\"/>\r\n</project:MModule>"},{"builtinExcludes":[],"builtinSources":[],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.exx32.board\"/>"},{"builtinExcludes":[],"builtinSources":["CMSIS/EFM32PG1B/startup_gcc_efm32pg1b.s","CMSIS/EFM32PG1B/system_efm32pg1b.c"],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.exx32.part\"/>"},{"builtinExcludes":[],"builtinSources":[],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.exx32.common.bsp\">\r\n <exclusions pattern=\".*\"/>\r\n</project:MModule>"},{"builtinExcludes":[],"builtinSources":[],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.exx32.common.CMSIS\">\r\n <exclusions pattern=\".*\"/>\r\n</project:MModule>"},{"builtinExcludes":[],"builtinSources":[],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.exx32.common.drivers\">\r\n <exclusions pattern=\".*\"/>\r\n</project:MModule>"}]" projectCommon.toolchainId="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904"/>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" description="" id="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.release#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904" name="GNU ARM v7.2.1 - Release" parent="com.silabs.ide.si32.gcc.cdt.managedbuild.config.gnu.exe">
|
||||
<folderInfo id="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.release#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904." name="/" resourcePath="">
|
||||
<toolChain id="com.silabs.ide.si32.gcc.cdt.managedbuild.toolchain.exe.549136935" name="Si32 GNU ARM" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.toolchain.exe">
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.toolchain.debug.level.1845706396" name="Debug Level" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.toolchain.debug.level" value="com.silabs.ide.si32.gcc.cdt.managedbuild.toolchain.debug.level.default" valueType="enumerated"/>
|
||||
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF;com.silabs.ss.framework.debugger.core.BIN;com.silabs.ss.framework.debugger.core.HEX;com.silabs.ss.framework.debugger.core.S37;com.silabs.ss.framework.debugger.core.EBL;com.silabs.ss.framework.debugger.core.GBL" id="com.silabs.ide.si32.gcc.cdt.managedbuild.target.gnu.platform.base.864981011" isAbstract="false" name="Debug Platform" osList="win32,linux,macosx" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.target.gnu.platform.base"/>
|
||||
<builder buildPath="${workspace_loc:/EFM32}/GNU ARM v7.2.1 - Release" id="com.silabs.ide.si32.gcc.cdt.managedbuild.target.gnu.builder.base.1502675340" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Si32 GNU ARM Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.target.gnu.builder.base"/>
|
||||
<tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.base.1602498713" name="GNU ARM C Compiler" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.base">
|
||||
<option id="gnu.c.compiler.option.optimization.level.1837577148" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" value="gnu.c.optimization.level.most" valueType="enumerated"/>
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.def.symbols.440688103" name="Defined symbols (-D)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.def.symbols" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="NDEBUG=1"/>
|
||||
<listOptionValue builtIn="false" value="EFM32PG1B200F256GM48=1"/>
|
||||
</option>
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.debug.builtin.1198109492" name="Always branch to builtin functions (-fno-builtin)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.debug.builtin" value="false" valueType="boolean"/>
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.debug.prolog.1913266060" name="Generate debugger-friendly prologs (-mno-sched-prolog)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.debug.prolog" value="false" valueType="boolean"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.656306182" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/platform/CMSIS/Include""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/platform/emlib/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/hardware/kit/SLSTK3401A_EFM32PG/config""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/platform/Device/SiliconLabs/EFM32PG1B/Include""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/hardware/kit/common/drivers""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/hardware/kit/common/bsp""/>
|
||||
</option>
|
||||
<inputType id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.input.165765548" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.compiler.base.2079890034" name="GNU ARM C++ Compiler" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.compiler.base">
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.compiler.debug.builtin.1316926038" name="Always branch to builtin functions (-fno-builtin)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.compiler.debug.builtin" value="false" valueType="boolean"/>
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.compiler.debug.prolog.424207122" name="Generate debugger-friendly prologs (-mno-sched-prolog)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.compiler.debug.prolog" value="false" valueType="boolean"/>
|
||||
</tool>
|
||||
<tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.assembler.base.977311863" name="GNU ARM Assembler" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.assembler.base">
|
||||
<option id="gnu.both.asm.option.include.paths.1646608287" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${ProjDirPath}/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/platform/CMSIS/Include""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/platform/emlib/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/hardware/kit/SLSTK3401A_EFM32PG/config""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/platform/Device/SiliconLabs/EFM32PG1B/Include""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/hardware/kit/common/drivers""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/hardware/kit/common/bsp""/>
|
||||
</option>
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.as.def.symbols.1247070583" name="Defined symbols (-D)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.as.def.symbols" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="EFM32PG1B200F256GM48=1"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1843484845" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.linker.base.1339230788" name="GNU ARM C Linker" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.linker.base">
|
||||
<option id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.linker.nostdlibs.1152796268" name="No startup or default libs (-nostdlib)" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.linker.nostdlibs" value="false" valueType="boolean"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.455926526" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.linker.base.1629435011" name="GNU ARM C++ Linker" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.cpp.linker.base"/>
|
||||
<tool id="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.archiver.base.1989933519" name="GNU ARM Archiver" superClass="com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.archiver.base"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="emlib/em_timer.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="com.silabs.ss.framework.ide.project.core.cpp" project.generation="15" projectCommon.boardIds="brd2500a:0.0.0" projectCommon.buildArtifactType="EXE" projectCommon.importModeId="COPY" projectCommon.partId="mcu.arm.efm32.pg1.efm32pg1b200f256gm48" projectCommon.sdkId="com.silabs.sdk.stack.super:1.1.1._310456152"/>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="EFM32.com.silabs.ss.framework.ide.project.core.cdt.cdtMbsProjectType.1696568425" name="SLS CDT Project" projectType="com.silabs.ss.framework.ide.project.core.cdt.cdtMbsProjectType"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.release#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904;com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.release#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904.;com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.base.1602498713;com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.input.165765548">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.debug#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904;com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt.debug#com.silabs.ss.tool.ide.arm.toolchain.gnu.cdt:7.2.1.20170904.;com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.base.1333897234;com.silabs.ide.si32.gcc.cdt.managedbuild.tool.gnu.c.compiler.input.492241787">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="GNU ARM v7.2.1 - Release">
|
||||
<resource resourceType="PROJECT" workspacePath="/EFM32"/>
|
||||
</configuration>
|
||||
<configuration configurationName="GNU ARM v7.2.1 - Debug">
|
||||
<resource resourceType="PROJECT" workspacePath="/EFM32"/>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
</cproject>
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>EFM32</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>com.silabs.ss.framework.ide.project.sls.core.SLSProjectNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
<linkedResources>
|
||||
<link>
|
||||
<name>crypto</name>
|
||||
<type>2</type>
|
||||
<location>C:/Users/conor/Desktop/u2f-one/crypto/</location>
|
||||
</link>
|
||||
<link>
|
||||
<name>fido2</name>
|
||||
<type>2</type>
|
||||
<location>C:/Users/conor/Desktop/u2f-one/fido2/</location>
|
||||
</link>
|
||||
</linkedResources>
|
||||
</projectDescription>
|
|
@ -0,0 +1,2 @@
|
|||
copiedFilesOriginState={}
|
||||
eclipse.preferences.version=1
|
|
@ -0,0 +1,70 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.cdt.codan.checkers.errnoreturn=Warning
|
||||
org.eclipse.cdt.codan.checkers.errnoreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
|
||||
org.eclipse.cdt.codan.checkers.errreturnvalue=Error
|
||||
org.eclipse.cdt.codan.checkers.errreturnvalue.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.checkers.nocommentinside=-Error
|
||||
org.eclipse.cdt.codan.checkers.nocommentinside.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.checkers.nolinecomment=-Error
|
||||
org.eclipse.cdt.codan.checkers.nolinecomment.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.checkers.noreturn=Error
|
||||
org.eclipse.cdt.codan.checkers.noreturn.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},implicit\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},no_break_comment\=>"no break",last_case_param\=>false,empty_case_param\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},unknown\=>false,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.ClassMembersInitialization.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},skip\=>true}
|
||||
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
|
||||
org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>()}
|
||||
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},paramNot\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},else\=>false,afterelse\=>false}
|
||||
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true}
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
|
||||
org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true},macro\=>true,exceptions\=>("@(\#)","$Id")}
|
||||
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
|
||||
org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>true,RUN_ON_INC_BUILD\=>true,RUN_ON_FILE_OPEN\=>false,RUN_ON_FILE_SAVE\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
|
|
@ -0,0 +1,317 @@
|
|||
/* @file startup_efm32pg1b.S
|
||||
* @brief startup file for Silicon Labs EFM32PG1B devices.
|
||||
* For use with GCC for ARM Embedded Processors
|
||||
* @version 5.2.2
|
||||
* Date: 12 June 2014
|
||||
*
|
||||
*/
|
||||
/* Copyright (c) 2011 - 2014 ARM LIMITED
|
||||
|
||||
All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
- Neither the name of ARM nor the names of its contributors may be used
|
||||
to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
*
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
.syntax unified
|
||||
.arch armv7-m
|
||||
.section .stack
|
||||
.align 3
|
||||
#ifdef __STACK_SIZE
|
||||
.equ Stack_Size, __STACK_SIZE
|
||||
#else
|
||||
.equ Stack_Size, 0x00000400
|
||||
#endif
|
||||
.globl __StackTop
|
||||
.globl __StackLimit
|
||||
__StackLimit:
|
||||
.space Stack_Size
|
||||
.size __StackLimit, . - __StackLimit
|
||||
__StackTop:
|
||||
.size __StackTop, . - __StackTop
|
||||
|
||||
.section .heap
|
||||
.align 3
|
||||
#ifdef __HEAP_SIZE
|
||||
.equ Heap_Size, __HEAP_SIZE
|
||||
#else
|
||||
.equ Heap_Size, 0x00000C00
|
||||
#endif
|
||||
.globl __HeapBase
|
||||
.globl __HeapLimit
|
||||
__HeapBase:
|
||||
.if Heap_Size
|
||||
.space Heap_Size
|
||||
.endif
|
||||
.size __HeapBase, . - __HeapBase
|
||||
__HeapLimit:
|
||||
.size __HeapLimit, . - __HeapLimit
|
||||
|
||||
.section .vectors
|
||||
.align 2
|
||||
.globl __Vectors
|
||||
__Vectors:
|
||||
.long __StackTop /* Top of Stack */
|
||||
.long Reset_Handler /* Reset Handler */
|
||||
.long NMI_Handler /* NMI Handler */
|
||||
.long HardFault_Handler /* Hard Fault Handler */
|
||||
.long MemManage_Handler /* MPU Fault Handler */
|
||||
.long BusFault_Handler /* Bus Fault Handler */
|
||||
.long UsageFault_Handler /* Usage Fault Handler */
|
||||
.long Default_Handler /* Reserved */
|
||||
.long Default_Handler /* Reserved */
|
||||
.long Default_Handler /* Reserved */
|
||||
.long Default_Handler /* Reserved */
|
||||
.long SVC_Handler /* SVCall Handler */
|
||||
.long DebugMon_Handler /* Debug Monitor Handler */
|
||||
.long Default_Handler /* Reserved */
|
||||
.long PendSV_Handler /* PendSV Handler */
|
||||
.long SysTick_Handler /* SysTick Handler */
|
||||
|
||||
/* External interrupts */
|
||||
.long EMU_IRQHandler /* 0 - EMU */
|
||||
.long Default_Handler /* 1 - Reserved */
|
||||
.long WDOG0_IRQHandler /* 2 - WDOG0 */
|
||||
.long Default_Handler /* 3 - Reserved */
|
||||
.long Default_Handler /* 4 - Reserved */
|
||||
.long Default_Handler /* 5 - Reserved */
|
||||
.long Default_Handler /* 6 - Reserved */
|
||||
.long Default_Handler /* 7 - Reserved */
|
||||
.long LDMA_IRQHandler /* 8 - LDMA */
|
||||
.long GPIO_EVEN_IRQHandler /* 9 - GPIO_EVEN */
|
||||
.long TIMER0_IRQHandler /* 10 - TIMER0 */
|
||||
.long USART0_RX_IRQHandler /* 11 - USART0_RX */
|
||||
.long USART0_TX_IRQHandler /* 12 - USART0_TX */
|
||||
.long ACMP0_IRQHandler /* 13 - ACMP0 */
|
||||
.long ADC0_IRQHandler /* 14 - ADC0 */
|
||||
.long IDAC0_IRQHandler /* 15 - IDAC0 */
|
||||
.long I2C0_IRQHandler /* 16 - I2C0 */
|
||||
.long GPIO_ODD_IRQHandler /* 17 - GPIO_ODD */
|
||||
.long TIMER1_IRQHandler /* 18 - TIMER1 */
|
||||
.long USART1_RX_IRQHandler /* 19 - USART1_RX */
|
||||
.long USART1_TX_IRQHandler /* 20 - USART1_TX */
|
||||
.long LEUART0_IRQHandler /* 21 - LEUART0 */
|
||||
.long PCNT0_IRQHandler /* 22 - PCNT0 */
|
||||
.long CMU_IRQHandler /* 23 - CMU */
|
||||
.long MSC_IRQHandler /* 24 - MSC */
|
||||
.long CRYPTO_IRQHandler /* 25 - CRYPTO */
|
||||
.long LETIMER0_IRQHandler /* 26 - LETIMER0 */
|
||||
.long Default_Handler /* 27 - Reserved */
|
||||
.long Default_Handler /* 28 - Reserved */
|
||||
.long RTCC_IRQHandler /* 29 - RTCC */
|
||||
.long Default_Handler /* 30 - Reserved */
|
||||
.long CRYOTIMER_IRQHandler /* 31 - CRYOTIMER */
|
||||
.long Default_Handler /* 32 - Reserved */
|
||||
.long FPUEH_IRQHandler /* 33 - FPUEH */
|
||||
|
||||
|
||||
.size __Vectors, . - __Vectors
|
||||
|
||||
.text
|
||||
.thumb
|
||||
.thumb_func
|
||||
.align 2
|
||||
.globl Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
Reset_Handler:
|
||||
#ifndef __NO_SYSTEM_INIT
|
||||
ldr r0, =SystemInit
|
||||
blx r0
|
||||
#endif
|
||||
|
||||
/* Firstly it copies data from read only memory to RAM. There are two schemes
|
||||
* to copy. One can copy more than one sections. Another can only copy
|
||||
* one section. The former scheme needs more instructions and read-only
|
||||
* data to implement than the latter.
|
||||
* Macro __STARTUP_COPY_MULTIPLE is used to choose between two schemes. */
|
||||
|
||||
#ifdef __STARTUP_COPY_MULTIPLE
|
||||
/* Multiple sections scheme.
|
||||
*
|
||||
* Between symbol address __copy_table_start__ and __copy_table_end__,
|
||||
* there are array of triplets, each of which specify:
|
||||
* offset 0: LMA of start of a section to copy from
|
||||
* offset 4: VMA of start of a section to copy to
|
||||
* offset 8: size of the section to copy. Must be multiply of 4
|
||||
*
|
||||
* All addresses must be aligned to 4 bytes boundary.
|
||||
*/
|
||||
ldr r4, =__copy_table_start__
|
||||
ldr r5, =__copy_table_end__
|
||||
|
||||
.L_loop0:
|
||||
cmp r4, r5
|
||||
bge .L_loop0_done
|
||||
ldr r1, [r4]
|
||||
ldr r2, [r4, #4]
|
||||
ldr r3, [r4, #8]
|
||||
|
||||
.L_loop0_0:
|
||||
subs r3, #4
|
||||
ittt ge
|
||||
ldrge r0, [r1, r3]
|
||||
strge r0, [r2, r3]
|
||||
bge .L_loop0_0
|
||||
|
||||
adds r4, #12
|
||||
b .L_loop0
|
||||
|
||||
.L_loop0_done:
|
||||
#else
|
||||
/* Single section scheme.
|
||||
*
|
||||
* The ranges of copy from/to are specified by following symbols
|
||||
* __etext: LMA of start of the section to copy from. Usually end of text
|
||||
* __data_start__: VMA of start of the section to copy to
|
||||
* __data_end__: VMA of end of the section to copy to
|
||||
*
|
||||
* All addresses must be aligned to 4 bytes boundary.
|
||||
*/
|
||||
ldr r1, =__etext
|
||||
ldr r2, =__data_start__
|
||||
ldr r3, =__data_end__
|
||||
|
||||
.L_loop1:
|
||||
cmp r2, r3
|
||||
ittt lt
|
||||
ldrlt r0, [r1], #4
|
||||
strlt r0, [r2], #4
|
||||
blt .L_loop1
|
||||
#endif /*__STARTUP_COPY_MULTIPLE */
|
||||
|
||||
/* This part of work usually is done in C library startup code. Otherwise,
|
||||
* define this macro to enable it in this startup.
|
||||
*
|
||||
* There are two schemes too. One can clear multiple BSS sections. Another
|
||||
* can only clear one section. The former is more size expensive than the
|
||||
* latter.
|
||||
*
|
||||
* Define macro __STARTUP_CLEAR_BSS_MULTIPLE to choose the former.
|
||||
* Otherwise efine macro __STARTUP_CLEAR_BSS to choose the later.
|
||||
*/
|
||||
#ifdef __STARTUP_CLEAR_BSS_MULTIPLE
|
||||
/* Multiple sections scheme.
|
||||
*
|
||||
* Between symbol address __zero_table_start__ and __zero_table_end__,
|
||||
* there are array of tuples specifying:
|
||||
* offset 0: Start of a BSS section
|
||||
* offset 4: Size of this BSS section. Must be multiply of 4
|
||||
*/
|
||||
ldr r3, =__zero_table_start__
|
||||
ldr r4, =__zero_table_end__
|
||||
|
||||
.L_loop2:
|
||||
cmp r3, r4
|
||||
bge .L_loop2_done
|
||||
ldr r1, [r3]
|
||||
ldr r2, [r3, #4]
|
||||
movs r0, 0
|
||||
|
||||
.L_loop2_0:
|
||||
subs r2, #4
|
||||
itt ge
|
||||
strge r0, [r1, r2]
|
||||
bge .L_loop2_0
|
||||
adds r3, #8
|
||||
b .L_loop2
|
||||
.L_loop2_done:
|
||||
#elif defined (__STARTUP_CLEAR_BSS)
|
||||
/* Single BSS section scheme.
|
||||
*
|
||||
* The BSS section is specified by following symbols
|
||||
* __bss_start__: start of the BSS section.
|
||||
* __bss_end__: end of the BSS section.
|
||||
*
|
||||
* Both addresses must be aligned to 4 bytes boundary.
|
||||
*/
|
||||
ldr r1, =__bss_start__
|
||||
ldr r2, =__bss_end__
|
||||
|
||||
movs r0, 0
|
||||
.L_loop3:
|
||||
cmp r1, r2
|
||||
itt lt
|
||||
strlt r0, [r1], #4
|
||||
blt .L_loop3
|
||||
#endif /* __STARTUP_CLEAR_BSS_MULTIPLE || __STARTUP_CLEAR_BSS */
|
||||
|
||||
#ifndef __START
|
||||
#define __START _start
|
||||
#endif
|
||||
bl __START
|
||||
|
||||
.pool
|
||||
.size Reset_Handler, . - Reset_Handler
|
||||
|
||||
.align 1
|
||||
.thumb_func
|
||||
.weak Default_Handler
|
||||
.type Default_Handler, %function
|
||||
Default_Handler:
|
||||
b .
|
||||
.size Default_Handler, . - Default_Handler
|
||||
|
||||
/* Macro to define default handlers. Default handler
|
||||
* will be weak symbol and just dead loops. They can be
|
||||
* overwritten by other handlers */
|
||||
.macro def_irq_handler handler_name
|
||||
.weak \handler_name
|
||||
.set \handler_name, Default_Handler
|
||||
.endm
|
||||
|
||||
def_irq_handler NMI_Handler
|
||||
def_irq_handler HardFault_Handler
|
||||
def_irq_handler MemManage_Handler
|
||||
def_irq_handler BusFault_Handler
|
||||
def_irq_handler UsageFault_Handler
|
||||
def_irq_handler SVC_Handler
|
||||
def_irq_handler DebugMon_Handler
|
||||
def_irq_handler PendSV_Handler
|
||||
def_irq_handler SysTick_Handler
|
||||
|
||||
|
||||
def_irq_handler EMU_IRQHandler
|
||||
def_irq_handler WDOG0_IRQHandler
|
||||
def_irq_handler LDMA_IRQHandler
|
||||
def_irq_handler GPIO_EVEN_IRQHandler
|
||||
def_irq_handler TIMER0_IRQHandler
|
||||
def_irq_handler USART0_RX_IRQHandler
|
||||
def_irq_handler USART0_TX_IRQHandler
|
||||
def_irq_handler ACMP0_IRQHandler
|
||||
def_irq_handler ADC0_IRQHandler
|
||||
def_irq_handler IDAC0_IRQHandler
|
||||
def_irq_handler I2C0_IRQHandler
|
||||
def_irq_handler GPIO_ODD_IRQHandler
|
||||
def_irq_handler TIMER1_IRQHandler
|
||||
def_irq_handler USART1_RX_IRQHandler
|
||||
def_irq_handler USART1_TX_IRQHandler
|
||||
def_irq_handler LEUART0_IRQHandler
|
||||
def_irq_handler PCNT0_IRQHandler
|
||||
def_irq_handler CMU_IRQHandler
|
||||
def_irq_handler MSC_IRQHandler
|
||||
def_irq_handler CRYPTO_IRQHandler
|
||||
def_irq_handler LETIMER0_IRQHandler
|
||||
def_irq_handler RTCC_IRQHandler
|
||||
def_irq_handler CRYOTIMER_IRQHandler
|
||||
def_irq_handler FPUEH_IRQHandler
|
||||
|
||||
.end
|
|
@ -0,0 +1,389 @@
|
|||
/***************************************************************************//**
|
||||
* @file system_efm32pg1b.c
|
||||
* @brief CMSIS Cortex-M3/M4 System Layer for EFM32 devices.
|
||||
* @version 5.2.2
|
||||
******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2017 Silicon Laboratories, Inc. http://www.silabs.com</b>
|
||||
******************************************************************************
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software.@n
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.@n
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Laboratories, Inc.
|
||||
* has no obligation to support this Software. Silicon Laboratories, Inc. is
|
||||
* providing the Software "AS IS", with no express or implied warranties of any
|
||||
* kind, including, but not limited to, any implied warranties of
|
||||
* merchantability or fitness for any particular purpose or warranties against
|
||||
* infringement of any proprietary rights of a third party.
|
||||
*
|
||||
* Silicon Laboratories, Inc. will not be liable for any consequential,
|
||||
* incidental, or special damages, or any other relief, or for any claim by
|
||||
* any third party, arising from your use of this Software.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "em_device.h"
|
||||
|
||||
/*******************************************************************************
|
||||
****************************** DEFINES ************************************
|
||||
******************************************************************************/
|
||||
|
||||
/** LFRCO frequency, tuned to below frequency during manufacturing. */
|
||||
#define EFM32_LFRCO_FREQ (32768UL)
|
||||
/** ULFRCO frequency */
|
||||
#define EFM32_ULFRCO_FREQ (1000UL)
|
||||
|
||||
/*******************************************************************************
|
||||
************************** LOCAL VARIABLES ********************************
|
||||
******************************************************************************/
|
||||
|
||||
/* System oscillator frequencies. These frequencies are normally constant */
|
||||
/* for a target, but they are made configurable in order to allow run-time */
|
||||
/* handling of different boards. The crystal oscillator clocks can be set */
|
||||
/* compile time to a non-default value by defining respective EFM_nFXO_FREQ */
|
||||
/* values according to board design. By defining the EFM_nFXO_FREQ to 0, */
|
||||
/* one indicates that the oscillator is not present, in order to save some */
|
||||
/* SW footprint. */
|
||||
|
||||
#ifndef EFM32_HFRCO_MAX_FREQ
|
||||
/** Maximum HFRCO frequency */
|
||||
#define EFM32_HFRCO_MAX_FREQ (38000000UL)
|
||||
#endif
|
||||
|
||||
#ifndef EFM32_HFXO_FREQ
|
||||
/** HFXO frequency */
|
||||
#define EFM32_HFXO_FREQ (40000000UL)
|
||||
#endif
|
||||
|
||||
#ifndef EFM32_HFRCO_STARTUP_FREQ
|
||||
/** HFRCO startup frequency */
|
||||
#define EFM32_HFRCO_STARTUP_FREQ (19000000UL)
|
||||
#endif
|
||||
|
||||
|
||||
/* Do not define variable if HF crystal oscillator not present */
|
||||
#if (EFM32_HFXO_FREQ > 0UL)
|
||||
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
|
||||
/** System HFXO clock. */
|
||||
static uint32_t SystemHFXOClock = EFM32_HFXO_FREQ;
|
||||
/** @endcond (DO_NOT_INCLUDE_WITH_DOXYGEN) */
|
||||
#endif
|
||||
|
||||
#ifndef EFM32_LFXO_FREQ
|
||||
/** LFXO frequency */
|
||||
#define EFM32_LFXO_FREQ (EFM32_LFRCO_FREQ)
|
||||
#endif
|
||||
/* Do not define variable if LF crystal oscillator not present */
|
||||
#if (EFM32_LFXO_FREQ > 0UL)
|
||||
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
|
||||
/** System LFXO clock. */
|
||||
static uint32_t SystemLFXOClock = 32768UL;
|
||||
/** @endcond (DO_NOT_INCLUDE_WITH_DOXYGEN) */
|
||||
#endif
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
************************** GLOBAL VARIABLES *******************************
|
||||
******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* System System Clock Frequency (Core Clock).
|
||||
*
|
||||
* @details
|
||||
* Required CMSIS global variable that must be kept up-to-date.
|
||||
*/
|
||||
uint32_t SystemCoreClock = EFM32_HFRCO_STARTUP_FREQ;
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* System HFRCO frequency
|
||||
*
|
||||
* @note
|
||||
* This is an EFM32 proprietary variable, not part of the CMSIS definition.
|
||||
*
|
||||
* @details
|
||||
* Frequency of the system HFRCO oscillator
|
||||
*/
|
||||
uint32_t SystemHfrcoFreq = EFM32_HFRCO_STARTUP_FREQ;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
************************** GLOBAL FUNCTIONS *******************************
|
||||
******************************************************************************/
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Get the current core clock frequency.
|
||||
*
|
||||
* @details
|
||||
* Calculate and get the current core clock frequency based on the current
|
||||
* configuration. Assuming that the SystemCoreClock global variable is
|
||||
* maintained, the core clock frequency is stored in that variable as well.
|
||||
* This function will however calculate the core clock based on actual HW
|
||||
* configuration. It will also update the SystemCoreClock global variable.
|
||||
*
|
||||
* @note
|
||||
* This is an EFM32 proprietary function, not part of the CMSIS definition.
|
||||
*
|
||||
* @return
|
||||
* The current core clock frequency in Hz.
|
||||
******************************************************************************/
|
||||
uint32_t SystemCoreClockGet(void)
|
||||
{
|
||||
uint32_t ret;
|
||||
uint32_t presc;
|
||||
|
||||
ret = SystemHFClockGet();
|
||||
presc = (CMU->HFCOREPRESC & _CMU_HFCOREPRESC_PRESC_MASK) >>
|
||||
_CMU_HFCOREPRESC_PRESC_SHIFT;
|
||||
ret /= (presc + 1);
|
||||
|
||||
/* Keep CMSIS system clock variable up-to-date */
|
||||
SystemCoreClock = ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Get the maximum core clock frequency.
|
||||
*
|
||||
* @note
|
||||
* This is an EFM32 proprietary function, not part of the CMSIS definition.
|
||||
*
|
||||
* @return
|
||||
* The maximum core clock frequency in Hz.
|
||||
******************************************************************************/
|
||||
uint32_t SystemMaxCoreClockGet(void)
|
||||
{
|
||||
return (EFM32_HFRCO_MAX_FREQ > EFM32_HFXO_FREQ ? \
|
||||
EFM32_HFRCO_MAX_FREQ : EFM32_HFXO_FREQ);
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Get the current HFCLK frequency.
|
||||
*
|
||||
* @note
|
||||
* This is an EFM32 proprietary function, not part of the CMSIS definition.
|
||||
*
|
||||
* @return
|
||||
* The current HFCLK frequency in Hz.
|
||||
******************************************************************************/
|
||||
uint32_t SystemHFClockGet(void)
|
||||
{
|
||||
uint32_t ret;
|
||||
|
||||
switch (CMU->HFCLKSTATUS & _CMU_HFCLKSTATUS_SELECTED_MASK)
|
||||
{
|
||||
case CMU_HFCLKSTATUS_SELECTED_LFXO:
|
||||
#if (EFM32_LFXO_FREQ > 0)
|
||||
ret = SystemLFXOClock;
|
||||
#else
|
||||
/* We should not get here, since core should not be clocked. May */
|
||||
/* be caused by a misconfiguration though. */
|
||||
ret = 0;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case CMU_HFCLKSTATUS_SELECTED_LFRCO:
|
||||
ret = EFM32_LFRCO_FREQ;
|
||||
break;
|
||||
|
||||
case CMU_HFCLKSTATUS_SELECTED_HFXO:
|
||||
#if (EFM32_HFXO_FREQ > 0)
|
||||
ret = SystemHFXOClock;
|
||||
#else
|
||||
/* We should not get here, since core should not be clocked. May */
|
||||
/* be caused by a misconfiguration though. */
|
||||
ret = 0;
|
||||
#endif
|
||||
break;
|
||||
|
||||
default: /* CMU_HFCLKSTATUS_SELECTED_HFRCO */
|
||||
ret = SystemHfrcoFreq;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret / (1U + ((CMU->HFPRESC & _CMU_HFPRESC_PRESC_MASK)
|
||||
>> _CMU_HFPRESC_PRESC_SHIFT));
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Get high frequency crystal oscillator clock frequency for target system.
|
||||
*
|
||||
* @note
|
||||
* This is an EFM32 proprietary function, not part of the CMSIS definition.
|
||||
*
|
||||
* @return
|
||||
* HFXO frequency in Hz.
|
||||
*****************************************************************************/
|
||||
uint32_t SystemHFXOClockGet(void)
|
||||
{
|
||||
/* External crystal oscillator present? */
|
||||
#if (EFM32_HFXO_FREQ > 0)
|
||||
return SystemHFXOClock;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Set high frequency crystal oscillator clock frequency for target system.
|
||||
*
|
||||
* @note
|
||||
* This function is mainly provided for being able to handle target systems
|
||||
* with different HF crystal oscillator frequencies run-time. If used, it
|
||||
* should probably only be used once during system startup.
|
||||
*
|
||||
* @note
|
||||
* This is an EFM32 proprietary function, not part of the CMSIS definition.
|
||||
*
|
||||
* @param[in] freq
|
||||
* HFXO frequency in Hz used for target.
|
||||
*****************************************************************************/
|
||||
void SystemHFXOClockSet(uint32_t freq)
|
||||
{
|
||||
/* External crystal oscillator present? */
|
||||
#if (EFM32_HFXO_FREQ > 0)
|
||||
SystemHFXOClock = freq;
|
||||
|
||||
/* Update core clock frequency if HFXO is used to clock core */
|
||||
if ((CMU->HFCLKSTATUS & _CMU_HFCLKSTATUS_SELECTED_MASK) == CMU_HFCLKSTATUS_SELECTED_HFXO)
|
||||
{
|
||||
/* The function will update the global variable */
|
||||
SystemCoreClockGet();
|
||||
}
|
||||
#else
|
||||
(void)freq; /* Unused parameter */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Initialize the system.
|
||||
*
|
||||
* @details
|
||||
* Do required generic HW system init.
|
||||
*
|
||||
* @note
|
||||
* This function is invoked during system init, before the main() routine
|
||||
* and any data has been initialized. For this reason, it cannot do any
|
||||
* initialization of variables etc.
|
||||
*****************************************************************************/
|
||||
void SystemInit(void)
|
||||
{
|
||||
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
|
||||
/* Set floating point coprosessor access mode. */
|
||||
SCB->CPACR |= ((3UL << 10*2) | /* set CP10 Full Access */
|
||||
(3UL << 11*2) ); /* set CP11 Full Access */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Get low frequency RC oscillator clock frequency for target system.
|
||||
*
|
||||
* @note
|
||||
* This is an EFM32 proprietary function, not part of the CMSIS definition.
|
||||
*
|
||||
* @return
|
||||
* LFRCO frequency in Hz.
|
||||
*****************************************************************************/
|
||||
uint32_t SystemLFRCOClockGet(void)
|
||||
{
|
||||
/* Currently we assume that this frequency is properly tuned during */
|
||||
/* manufacturing and is not changed after reset. If future requirements */
|
||||
/* for re-tuning by user, we can add support for that. */
|
||||
return EFM32_LFRCO_FREQ;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Get ultra low frequency RC oscillator clock frequency for target system.
|
||||
*
|
||||
* @note
|
||||
* This is an EFM32 proprietary function, not part of the CMSIS definition.
|
||||
*
|
||||
* @return
|
||||
* ULFRCO frequency in Hz.
|
||||
*****************************************************************************/
|
||||
uint32_t SystemULFRCOClockGet(void)
|
||||
{
|
||||
/* The ULFRCO frequency is not tuned, and can be very inaccurate */
|
||||
return EFM32_ULFRCO_FREQ;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Get low frequency crystal oscillator clock frequency for target system.
|
||||
*
|
||||
* @note
|
||||
* This is an EFM32 proprietary function, not part of the CMSIS definition.
|
||||
*
|
||||
* @return
|
||||
* LFXO frequency in Hz.
|
||||
*****************************************************************************/
|
||||
uint32_t SystemLFXOClockGet(void)
|
||||
{
|
||||
/* External crystal oscillator present? */
|
||||
#if (EFM32_LFXO_FREQ > 0)
|
||||
return SystemLFXOClock;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Set low frequency crystal oscillator clock frequency for target system.
|
||||
*
|
||||
* @note
|
||||
* This function is mainly provided for being able to handle target systems
|
||||
* with different HF crystal oscillator frequencies run-time. If used, it
|
||||
* should probably only be used once during system startup.
|
||||
*
|
||||
* @note
|
||||
* This is an EFM32 proprietary function, not part of the CMSIS definition.
|
||||
*
|
||||
* @param[in] freq
|
||||
* LFXO frequency in Hz used for target.
|
||||
*****************************************************************************/
|
||||
void SystemLFXOClockSet(uint32_t freq)
|
||||
{
|
||||
/* External crystal oscillator present? */
|
||||
#if (EFM32_LFXO_FREQ > 0)
|
||||
SystemLFXOClock = freq;
|
||||
|
||||
/* Update core clock frequency if LFXO is used to clock core */
|
||||
if ((CMU->HFCLKSTATUS & _CMU_HFCLKSTATUS_SELECTED_MASK) == CMU_HFCLKSTATUS_SELECTED_LFXO)
|
||||
{
|
||||
/* The function will update the global variable */
|
||||
SystemCoreClockGet();
|
||||
}
|
||||
#else
|
||||
(void)freq; /* Unused parameter */
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="ASCII"?>
|
||||
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="EFM32PG1B200F256GM48" partId="mcu.arm.efm32.pg1.efm32pg1b200f256gm48" contextId="%DEFAULT%">
|
||||
<mode name="DefaultMode">
|
||||
<property object="CMU" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="CMU" propertyId="clocksettings.hfrcosettings.hfrcofrequency" value="38 MHz"/>
|
||||
<property object="CMU" propertyId="clocksettings.lfclocksettings.lfrcorequired" value="Yes"/>
|
||||
<property object="CRYOTIMER" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="CRYOTIMER" propertyId="cryotimer.clocking.eventafterevery" value="1 cycle"/>
|
||||
<property object="CRYOTIMER" propertyId="cryotimer.clocking.prescalerforcryotimer" value="Divide by 32"/>
|
||||
<property object="DefaultMode" propertyId="mode.diagramLocation" value="100, 100"/>
|
||||
<property object="EMU" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="GPIO" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="PA0" propertyId="ports.settings.pinmode" value="Push-pull"/>
|
||||
<property object="PA1" propertyId="ports.settings.dout" value="1"/>
|
||||
<property object="PA1" propertyId="ports.settings.filter" value="Enabled"/>
|
||||
<property object="PA1" propertyId="ports.settings.pinmode" value="Input pull"/>
|
||||
<property object="PA1" propertyId="ports.settings.pulldirection" value="Pullup"/>
|
||||
<property object="PA1" propertyId="ports.settings.pullup" value="Enabled"/>
|
||||
<property object="PA3" propertyId="ports.settings.pinmode" value="Push-pull"/>
|
||||
<property object="PA5" propertyId="ports.settings.dout" value="1"/>
|
||||
<property object="PA5" propertyId="ports.settings.filter" value="Enabled"/>
|
||||
<property object="PA5" propertyId="ports.settings.pinmode" value="Push-pull"/>
|
||||
<property object="PA5" propertyId="ports.settings.pulldirection" value="Pullup"/>
|
||||
<property object="PA5" propertyId="ports.settings.pullup" value="Enabled"/>
|
||||
<property object="PF4" propertyId="ports.settings.pinmode" value="Push-pull"/>
|
||||
<property object="PF5" propertyId="ports.settings.pinmode" value="Push-pull"/>
|
||||
<property object="PORTIO" propertyId="portio.usart0.enable.cts" value="Enabled"/>
|
||||
<property object="PORTIO" propertyId="portio.usart0.enable.rts" value="Enabled"/>
|
||||
<property object="PORTIO" propertyId="portio.usart0.enable.rx" value="Enabled"/>
|
||||
<property object="PORTIO" propertyId="portio.usart0.enable.tx" value="Enabled"/>
|
||||
<property object="PORTIO" propertyId="portio.usart0.location.usart0_ctsloc" value="30"/>
|
||||
<property object="PORTIO" propertyId="portio.usart0.location.usart0_rtsloc" value="30"/>
|
||||
<property object="TIMER0" propertyId="timer.clocksettings.clockselection" value="TIM0_CC1 input"/>
|
||||
<property object="USART0" propertyId="ABPeripheral.included" value="true"/>
|
||||
</mode>
|
||||
<modeTransition>
|
||||
<property object="RESET → DefaultMode" propertyId="modeTransition.source" value="RESET"/>
|
||||
<property object="RESET → DefaultMode" propertyId="modeTransition.target" value="DefaultMode"/>
|
||||
</modeTransition>
|
||||
</device:XMLDevice>
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
CC=arm-none-eabi-gcc
|
||||
|
||||
all:
|
||||
cd 'GNU ARM v7.2.1 - Debug' && make all
|
||||
|
||||
|
||||
#arm-none-eabi-gcc -g -gdwarf-2 -mcpu=cortex-m4 -mthumb -std=c99 '-DDEBUG=1' '-DEFM32PG1B200F256GM48=1' -IC:/Users/conor/Desktop/u2f-one/crypto/sha256 -IC:/Users/conor/Desktop/u2f-one/crypto/micro-ecc -IC:/Users/conor/Desktop/u2f-one/crypto/tiny-AES-c -I"C:\Users\conor\Desktop\u2f-one\efm32\inc" -IC:/Users/conor/Desktop/u2f-one/fido2 -IC:/Users/conor/Desktop/u2f-one/tinycbor/src -I"C:/SiliconLabs/SimplicityStudio/v4/developer/sdks/gecko_sdk_suite/v1.1//platform/CMSIS/Include" -I"C:/SiliconLabs/SimplicityStudio/v4/developer/sdks/gecko_sdk_suite/v1.1//hardware/kit/common/drivers" -I"C:/SiliconLabs/SimplicityStudio/v4/developer/sdks/gecko_sdk_suite/v1.1//hardware/kit/SLSTK3401A_EFM32PG/config" -I"C:/SiliconLabs/SimplicityStudio/v4/developer/sdks/gecko_sdk_suite/v1.1//platform/Device/SiliconLabs/EFM32PG1B/Include" -I"C:/SiliconLabs/SimplicityStudio/v4/developer/sdks/gecko_sdk_suite/v1.1//platform/emlib/inc" -I"C:/SiliconLabs/SimplicityStudio/v4/developer/sdks/gecko_sdk_suite/v1.1//hardware/kit/common/bsp" -O0 -Wall -c -fmessage-length=0 -mno-sched-prolog -fno-builtin -ffunction-sections -fdata-sections -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -MMD -MP -MF"src/device.d" -MT"src/device.o" -o "src/device.o" "../src/device.c"
|
||||
|
||||
|
||||
#arm-none-eabi-gcc -g -gdwarf-2 -mcpu=cortex-m4 -mthumb -T "EFM32.ld" -Xlinker --gc-sections -Xlinker -Map="EFM32.map" -mfpu=fpv4-sp-d16 -mfloat-abi=softfp --specs=nano.specs -o EFM32.axf "./CMSIS/EFM32PG1B/startup_gcc_efm32pg1b.o" "./CMSIS/EFM32PG1B/system_efm32pg1b.o" "./crypto/micro-ecc/uECC.o" "./crypto/sha256/sha256.o" "./crypto/tiny-AES-c/aes.o" "./emlib/em_assert.o" "./emlib/em_cmu.o" "./emlib/em_emu.o" "./emlib/em_gpio.o" "./emlib/em_system.o" "./emlib/em_usart.o" "./fido2/crypto.o" "./fido2/ctap.o" "./fido2/ctap_parse.o" "./fido2/ctaphid.o" "./fido2/log.o" "./fido2/main.o" "./fido2/stubs.o" "./fido2/test_power.o" "./fido2/u2f.o" "./fido2/util.o" "./src/InitDevice.o" "./src/device.o" "./src/main.o" "./src/printing.o" "./src/retargetio.o" -Wl,--start-group -lgcc -lc -lnosys -Wl,--end-group
|
||||
|
||||
|
||||
cbor:
|
||||
cd ../tinycbor/ && make clean
|
||||
cd ../tinycbor/ && make CC="$(CC)" \
|
||||
LDFLAGS="-lgcc -lc -lnosys --specs=nosys.specs -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -mthumb " \
|
||||
CFLAGS="-g -gdwarf-2 -mcpu=cortex-m4 -mthumb -std=c99 -DEFM32PG1B200F256GM48=1 -O3 -Wall -c -fmessage-length=0 -mno-sched-prolog -fno-builtin -ffunction-sections -fdata-sections -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -MMD -MP "
|
||||
|
||||
|
||||
|
||||
clean:
|
||||
cd 'GNU ARM v7.2.1 - Debug' && make clean
|
|
@ -0,0 +1,81 @@
|
|||
/***************************************************************************//**
|
||||
* @file em_assert.c
|
||||
* @brief Assert API
|
||||
* @version 5.2.2
|
||||
*******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b>
|
||||
*******************************************************************************
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
|
||||
* obligation to support this Software. Silicon Labs is providing the
|
||||
* Software "AS IS", with no express or implied warranties of any kind,
|
||||
* including, but not limited to, any implied warranties of merchantability
|
||||
* or fitness for any particular purpose or warranties against infringement
|
||||
* of any proprietary rights of a third party.
|
||||
*
|
||||
* Silicon Labs will not be liable for any consequential, incidental, or
|
||||
* special damages, or any other relief, or for any claim by any third party,
|
||||
* arising from your use of this Software.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "em_assert.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
/***************************************************************************//**
|
||||
* @addtogroup emlib
|
||||
* @{
|
||||
******************************************************************************/
|
||||
|
||||
/***************************************************************************//**
|
||||
* @addtogroup ASSERT
|
||||
* @{
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(DEBUG_EFM)
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* EFM internal assert handling.
|
||||
*
|
||||
* This function is invoked through EFM_ASSERT() macro usage only, it should
|
||||
* not be used explicitly.
|
||||
*
|
||||
* This implementation simply enters an indefinite loop, allowing
|
||||
* the use of a debugger to determine cause of failure. By defining
|
||||
* DEBUG_EFM_USER to the preprocessor for all files, a user defined version
|
||||
* of this function must be defined and will be invoked instead, possibly
|
||||
* providing output of assertion location.
|
||||
*
|
||||
* @note
|
||||
* This function is not used unless @ref DEBUG_EFM is defined
|
||||
* during preprocessing of EFM_ASSERT() usage.
|
||||
*
|
||||
* @param[in] file
|
||||
* Name of source file where assertion failed.
|
||||
*
|
||||
* @param[in] line
|
||||
* Line number in source file where assertion failed.
|
||||
******************************************************************************/
|
||||
void assertEFM(const char *file, int line)
|
||||
{
|
||||
(void)file; /* Unused parameter */
|
||||
(void)line; /* Unused parameter */
|
||||
|
||||
while (true) {
|
||||
}
|
||||
}
|
||||
#endif /* DEBUG_EFM */
|
||||
|
||||
/** @} (end addtogroup ASSERT) */
|
||||
/** @} (end addtogroup emlib) */
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,61 @@
|
|||
/***************************************************************************//**
|
||||
* @file em_cryotimer.c
|
||||
* @brief Ultra Low Energy Timer/Counter (CRYOTIMER) peripheral API
|
||||
* @version 5.2.2
|
||||
*******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b>
|
||||
*******************************************************************************
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software.@n
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.@n
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
|
||||
* obligation to support this Software. Silicon Labs is providing the
|
||||
* Software "AS IS", with no express or implied warranties of any kind,
|
||||
* including, but not limited to, any implied warranties of merchantability
|
||||
* or fitness for any particular purpose or warranties against infringement
|
||||
* of any proprietary rights of a third party.
|
||||
*
|
||||
* Silicon Labs will not be liable for any consequential, incidental, or
|
||||
* special damages, or any other relief, or for any claim by any third party,
|
||||
* arising from your use of this Software.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "em_cryotimer.h"
|
||||
#include "em_bus.h"
|
||||
|
||||
#if defined(CRYOTIMER_PRESENT) && (CRYOTIMER_COUNT == 1)
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Initialize the CRYOTIMER.
|
||||
*
|
||||
* @details
|
||||
* Use this function to initialize the CRYOTIMER.
|
||||
* Select prescaler setting and select low frequency oscillator.
|
||||
* Refer to the configuration structure @ref CRYOTIMER_Init_TypeDef for more
|
||||
* details.
|
||||
*
|
||||
* @param[in] init
|
||||
* Pointer to initialization structure.
|
||||
******************************************************************************/
|
||||
void CRYOTIMER_Init(const CRYOTIMER_Init_TypeDef *init)
|
||||
{
|
||||
CRYOTIMER->PERIODSEL = (uint32_t)init->period & _CRYOTIMER_PERIODSEL_MASK;
|
||||
CRYOTIMER->CTRL = ((uint32_t)init->enable << _CRYOTIMER_CTRL_EN_SHIFT)
|
||||
| ((uint32_t)init->debugRun << _CRYOTIMER_CTRL_DEBUGRUN_SHIFT)
|
||||
| ((uint32_t)init->osc << _CRYOTIMER_CTRL_OSCSEL_SHIFT)
|
||||
| ((uint32_t)init->presc << _CRYOTIMER_CTRL_PRESC_SHIFT);
|
||||
CRYOTIMER_EM4WakeupEnable(init->em4Wakeup);
|
||||
}
|
||||
|
||||
#endif /* defined(CRYOTIMER_PRESENT) && (CRYOTIMER_COUNT > 0) */
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,367 @@
|
|||
/***************************************************************************//**
|
||||
* @file em_gpio.c
|
||||
* @brief General Purpose IO (GPIO) peripheral API
|
||||
* devices.
|
||||
* @version 5.2.2
|
||||
*******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b>
|
||||
*******************************************************************************
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
|
||||
* obligation to support this Software. Silicon Labs is providing the
|
||||
* Software "AS IS", with no express or implied warranties of any kind,
|
||||
* including, but not limited to, any implied warranties of merchantability
|
||||
* or fitness for any particular purpose or warranties against infringement
|
||||
* of any proprietary rights of a third party.
|
||||
*
|
||||
* Silicon Labs will not be liable for any consequential, incidental, or
|
||||
* special damages, or any other relief, or for any claim by any third party,
|
||||
* arising from your use of this Software.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "em_gpio.h"
|
||||
|
||||
#if defined(GPIO_COUNT) && (GPIO_COUNT > 0)
|
||||
|
||||
/***************************************************************************//**
|
||||
* @addtogroup emlib
|
||||
* @{
|
||||
******************************************************************************/
|
||||
|
||||
/***************************************************************************//**
|
||||
* @addtogroup GPIO
|
||||
* @brief General Purpose Input/Output (GPIO) API
|
||||
* @details
|
||||
* This module contains functions to control the GPIO peripheral of Silicon
|
||||
* Labs 32-bit MCUs and SoCs. The GPIO peripheral is used for pin configuration
|
||||
* and direct pin manipulation and sensing as well as routing for peripheral
|
||||
* pin connections.
|
||||
* @{
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
******************************* DEFINES ***********************************
|
||||
******************************************************************************/
|
||||
|
||||
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
|
||||
|
||||
/** Validation of pin typically usable in assert statements. */
|
||||
#define GPIO_DRIVEMODE_VALID(mode) ((mode) <= 3)
|
||||
#define GPIO_STRENGHT_VALID(strenght) (!((strenght) \
|
||||
& ~(_GPIO_P_CTRL_DRIVESTRENGTH_MASK \
|
||||
| _GPIO_P_CTRL_DRIVESTRENGTHALT_MASK)))
|
||||
/** @endcond */
|
||||
|
||||
/*******************************************************************************
|
||||
************************** GLOBAL FUNCTIONS *******************************
|
||||
******************************************************************************/
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Sets the pin location of the debug pins (Serial Wire interface).
|
||||
*
|
||||
* @note
|
||||
* Changing the pins used for debugging uncontrolled, may result in a lockout.
|
||||
*
|
||||
* @param[in] location
|
||||
* The debug pin location to use (0-3).
|
||||
******************************************************************************/
|
||||
void GPIO_DbgLocationSet(unsigned int location)
|
||||
{
|
||||
#if defined (_GPIO_ROUTE_SWLOCATION_MASK)
|
||||
EFM_ASSERT(location < AFCHANLOC_MAX);
|
||||
|
||||
GPIO->ROUTE = (GPIO->ROUTE & ~_GPIO_ROUTE_SWLOCATION_MASK)
|
||||
| (location << _GPIO_ROUTE_SWLOCATION_SHIFT);
|
||||
#else
|
||||
(void)location;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined (_GPIO_P_CTRL_DRIVEMODE_MASK)
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Sets the drive mode for a GPIO port.
|
||||
*
|
||||
* @param[in] port
|
||||
* The GPIO port to access.
|
||||
*
|
||||
* @param[in] mode
|
||||
* Drive mode to use for port.
|
||||
******************************************************************************/
|
||||
void GPIO_DriveModeSet(GPIO_Port_TypeDef port, GPIO_DriveMode_TypeDef mode)
|
||||
{
|
||||
EFM_ASSERT(GPIO_PORT_VALID(port) && GPIO_DRIVEMODE_VALID(mode));
|
||||
|
||||
GPIO->P[port].CTRL = (GPIO->P[port].CTRL & ~(_GPIO_P_CTRL_DRIVEMODE_MASK))
|
||||
| (mode << _GPIO_P_CTRL_DRIVEMODE_SHIFT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_GPIO_P_CTRL_DRIVESTRENGTH_MASK)
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Sets the drive strength for a GPIO port.
|
||||
*
|
||||
* @param[in] port
|
||||
* The GPIO port to access.
|
||||
*
|
||||
* @param[in] strength
|
||||
* Drive strength to use for port.
|
||||
******************************************************************************/
|
||||
void GPIO_DriveStrengthSet(GPIO_Port_TypeDef port,
|
||||
GPIO_DriveStrength_TypeDef strength)
|
||||
{
|
||||
EFM_ASSERT(GPIO_PORT_VALID(port) && GPIO_STRENGHT_VALID(strength));
|
||||
BUS_RegMaskedWrite(&GPIO->P[port].CTRL,
|
||||
_GPIO_P_CTRL_DRIVESTRENGTH_MASK | _GPIO_P_CTRL_DRIVESTRENGTHALT_MASK,
|
||||
strength);
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Configure GPIO external pin interrupt.
|
||||
*
|
||||
* @details
|
||||
* If reconfiguring a GPIO interrupt that is already enabled, it is generally
|
||||
* recommended to disable it first, see GPIO_Disable().
|
||||
*
|
||||
* The actual GPIO interrupt handler must be in place before enabling the
|
||||
* interrupt.
|
||||
*
|
||||
* Notice that any pending interrupt for the selected interrupt is cleared
|
||||
* by this function.
|
||||
*
|
||||
* @note
|
||||
* On series 0 devices the pin number parameter is not used. The
|
||||
* pin number used on these devices is hardwired to the interrupt with the
|
||||
* same number. @n
|
||||
* On series 1 devices, pin number can be selected freely within a group.
|
||||
* Interrupt numbers are divided into 4 groups (intNo / 4) and valid pin
|
||||
* number within the interrupt groups are:
|
||||
* 0: pins 0-3
|
||||
* 1: pins 4-7
|
||||
* 2: pins 8-11
|
||||
* 3: pins 12-15
|
||||
*
|
||||
* @param[in] port
|
||||
* The port to associate with @p pin.
|
||||
*
|
||||
* @param[in] pin
|
||||
* The pin number on the port.
|
||||
*
|
||||
* @param[in] intNo
|
||||
* The interrupt number to trigger.
|
||||
*
|
||||
* @param[in] risingEdge
|
||||
* Set to true if interrupts shall be enabled on rising edge, otherwise false.
|
||||
*
|
||||
* @param[in] fallingEdge
|
||||
* Set to true if interrupts shall be enabled on falling edge, otherwise false.
|
||||
*
|
||||
* @param[in] enable
|
||||
* Set to true if interrupt shall be enabled after configuration completed,
|
||||
* false to leave disabled. See GPIO_IntDisable() and GPIO_IntEnable().
|
||||
******************************************************************************/
|
||||
void GPIO_ExtIntConfig(GPIO_Port_TypeDef port,
|
||||
unsigned int pin,
|
||||
unsigned int intNo,
|
||||
bool risingEdge,
|
||||
bool fallingEdge,
|
||||
bool enable)
|
||||
{
|
||||
uint32_t tmp = 0;
|
||||
#if !defined(_GPIO_EXTIPINSELL_MASK)
|
||||
(void)pin;
|
||||
#endif
|
||||
|
||||
EFM_ASSERT(GPIO_PORT_PIN_VALID(port, pin));
|
||||
#if defined(_GPIO_EXTIPINSELL_MASK)
|
||||
EFM_ASSERT(GPIO_INTNO_PIN_VALID(intNo, pin));
|
||||
#endif
|
||||
|
||||
/* There are two registers controlling the interrupt configuration:
|
||||
* The EXTIPSELL register controls pins 0-7 and EXTIPSELH controls
|
||||
* pins 8-15. */
|
||||
if (intNo < 8) {
|
||||
BUS_RegMaskedWrite(&GPIO->EXTIPSELL,
|
||||
_GPIO_EXTIPSELL_EXTIPSEL0_MASK
|
||||
<< (_GPIO_EXTIPSELL_EXTIPSEL1_SHIFT * intNo),
|
||||
port << (_GPIO_EXTIPSELL_EXTIPSEL1_SHIFT * intNo));
|
||||
} else {
|
||||
tmp = intNo - 8;
|
||||
BUS_RegMaskedWrite(&GPIO->EXTIPSELH,
|
||||
_GPIO_EXTIPSELH_EXTIPSEL8_MASK
|
||||
<< (_GPIO_EXTIPSELH_EXTIPSEL9_SHIFT * tmp),
|
||||
port << (_GPIO_EXTIPSELH_EXTIPSEL9_SHIFT * tmp));
|
||||
}
|
||||
|
||||
#if defined(_GPIO_EXTIPINSELL_MASK)
|
||||
/* There are two registers controlling the interrupt/pin number mapping:
|
||||
* The EXTIPINSELL register controls interrupt 0-7 and EXTIPINSELH controls
|
||||
* interrupt 8-15. */
|
||||
if (intNo < 8) {
|
||||
BUS_RegMaskedWrite(&GPIO->EXTIPINSELL,
|
||||
_GPIO_EXTIPINSELL_EXTIPINSEL0_MASK
|
||||
<< (_GPIO_EXTIPINSELL_EXTIPINSEL1_SHIFT * intNo),
|
||||
((pin % 4) & _GPIO_EXTIPINSELL_EXTIPINSEL0_MASK)
|
||||
<< (_GPIO_EXTIPINSELL_EXTIPINSEL1_SHIFT * intNo));
|
||||
} else {
|
||||
BUS_RegMaskedWrite(&GPIO->EXTIPINSELH,
|
||||
_GPIO_EXTIPINSELH_EXTIPINSEL8_MASK
|
||||
<< (_GPIO_EXTIPINSELH_EXTIPINSEL9_SHIFT * tmp),
|
||||
((pin % 4) & _GPIO_EXTIPINSELH_EXTIPINSEL8_MASK)
|
||||
<< (_GPIO_EXTIPSELH_EXTIPSEL9_SHIFT * tmp));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Enable/disable rising edge */
|
||||
BUS_RegBitWrite(&(GPIO->EXTIRISE), intNo, risingEdge);
|
||||
|
||||
/* Enable/disable falling edge */
|
||||
BUS_RegBitWrite(&(GPIO->EXTIFALL), intNo, fallingEdge);
|
||||
|
||||
/* Clear any pending interrupt */
|
||||
GPIO->IFC = 1 << intNo;
|
||||
|
||||
/* Finally enable/disable interrupt */
|
||||
BUS_RegBitWrite(&(GPIO->IEN), intNo, enable);
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Set the mode for a GPIO pin.
|
||||
*
|
||||
* @param[in] port
|
||||
* The GPIO port to access.
|
||||
*
|
||||
* @param[in] pin
|
||||
* The pin number in the port.
|
||||
*
|
||||
* @param[in] mode
|
||||
* The desired pin mode.
|
||||
*
|
||||
* @param[in] out
|
||||
* Value to set for pin in DOUT register. The DOUT setting is important for
|
||||
* even some input mode configurations, determining pull-up/down direction.
|
||||
******************************************************************************/
|
||||
void GPIO_PinModeSet(GPIO_Port_TypeDef port,
|
||||
unsigned int pin,
|
||||
GPIO_Mode_TypeDef mode,
|
||||
unsigned int out)
|
||||
{
|
||||
EFM_ASSERT(GPIO_PORT_PIN_VALID(port, pin));
|
||||
|
||||
/* If disabling pin, do not modify DOUT in order to reduce chance for */
|
||||
/* glitch/spike (may not be sufficient precaution in all use cases) */
|
||||
if (mode != gpioModeDisabled) {
|
||||
if (out) {
|
||||
GPIO_PinOutSet(port, pin);
|
||||
} else {
|
||||
GPIO_PinOutClear(port, pin);
|
||||
}
|
||||
}
|
||||
|
||||
/* There are two registers controlling the pins for each port. The MODEL
|
||||
* register controls pins 0-7 and MODEH controls pins 8-15. */
|
||||
if (pin < 8) {
|
||||
GPIO->P[port].MODEL = (GPIO->P[port].MODEL & ~(0xFu << (pin * 4)))
|
||||
| (mode << (pin * 4));
|
||||
} else {
|
||||
GPIO->P[port].MODEH = (GPIO->P[port].MODEH & ~(0xFu << ((pin - 8) * 4)))
|
||||
| (mode << ((pin - 8) * 4));
|
||||
}
|
||||
|
||||
if (mode == gpioModeDisabled) {
|
||||
if (out) {
|
||||
GPIO_PinOutSet(port, pin);
|
||||
} else {
|
||||
GPIO_PinOutClear(port, pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Get the mode for a GPIO pin.
|
||||
*
|
||||
* @param[in] port
|
||||
* The GPIO port to access.
|
||||
*
|
||||
* @param[in] pin
|
||||
* The pin number in the port.
|
||||
*
|
||||
* @return
|
||||
* The pin mode.
|
||||
******************************************************************************/
|
||||
GPIO_Mode_TypeDef GPIO_PinModeGet(GPIO_Port_TypeDef port,
|
||||
unsigned int pin)
|
||||
{
|
||||
EFM_ASSERT(GPIO_PORT_PIN_VALID(port, pin));
|
||||
|
||||
if (pin < 8) {
|
||||
return (GPIO_Mode_TypeDef) ((GPIO->P[port].MODEL >> (pin * 4)) & 0xF);
|
||||
} else {
|
||||
return (GPIO_Mode_TypeDef) ((GPIO->P[port].MODEH >> ((pin - 8) * 4)) & 0xF);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_GPIO_EM4WUEN_MASK)
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Enable GPIO pin wake-up from EM4. When the function exits,
|
||||
* EM4 mode can be safely entered.
|
||||
*
|
||||
* @note
|
||||
* It is assumed that the GPIO pin modes are set correctly.
|
||||
* Valid modes are @ref gpioModeInput and @ref gpioModeInputPull.
|
||||
*
|
||||
* @param[in] pinmask
|
||||
* Bitmask containing the bitwise logic OR of which GPIO pin(s) to enable.
|
||||
* Refer to Reference Manuals for pinmask to GPIO port/pin mapping.
|
||||
* @param[in] polaritymask
|
||||
* Bitmask containing the bitwise logic OR of GPIO pin(s) wake-up polarity.
|
||||
* Refer to Reference Manuals for pinmask to GPIO port/pin mapping.
|
||||
*****************************************************************************/
|
||||
void GPIO_EM4EnablePinWakeup(uint32_t pinmask, uint32_t polaritymask)
|
||||
{
|
||||
EFM_ASSERT((pinmask & ~_GPIO_EM4WUEN_MASK) == 0);
|
||||
|
||||
#if defined(_GPIO_EM4WUPOL_MASK)
|
||||
EFM_ASSERT((polaritymask & ~_GPIO_EM4WUPOL_MASK) == 0);
|
||||
GPIO->EM4WUPOL &= ~pinmask; /* Set wakeup polarity */
|
||||
GPIO->EM4WUPOL |= pinmask & polaritymask;
|
||||
#elif defined(_GPIO_EXTILEVEL_MASK)
|
||||
EFM_ASSERT((polaritymask & ~_GPIO_EXTILEVEL_MASK) == 0);
|
||||
GPIO->EXTILEVEL &= ~pinmask;
|
||||
GPIO->EXTILEVEL |= pinmask & polaritymask;
|
||||
#endif
|
||||
GPIO->EM4WUEN |= pinmask; /* Enable wakeup */
|
||||
|
||||
GPIO_EM4SetPinRetention(true); /* Enable pin retention */
|
||||
|
||||
#if defined(_GPIO_CMD_EM4WUCLR_MASK)
|
||||
GPIO->CMD = GPIO_CMD_EM4WUCLR; /* Clear wake-up logic */
|
||||
#elif defined(_GPIO_IFC_EM4WU_MASK)
|
||||
GPIO_IntClear(pinmask);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/** @} (end addtogroup GPIO) */
|
||||
/** @} (end addtogroup emlib) */
|
||||
|
||||
#endif /* defined(GPIO_COUNT) && (GPIO_COUNT > 0) */
|
|
@ -0,0 +1,114 @@
|
|||
/***************************************************************************//**
|
||||
* @file em_system.c
|
||||
* @brief System Peripheral API
|
||||
* @version 5.2.2
|
||||
*******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b>
|
||||
*******************************************************************************
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
|
||||
* obligation to support this Software. Silicon Labs is providing the
|
||||
* Software "AS IS", with no express or implied warranties of any kind,
|
||||
* including, but not limited to, any implied warranties of merchantability
|
||||
* or fitness for any particular purpose or warranties against infringement
|
||||
* of any proprietary rights of a third party.
|
||||
*
|
||||
* Silicon Labs will not be liable for any consequential, incidental, or
|
||||
* special damages, or any other relief, or for any claim by any third party,
|
||||
* arising from your use of this Software.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "em_system.h"
|
||||
#include "em_assert.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/***************************************************************************//**
|
||||
* @addtogroup emlib
|
||||
* @{
|
||||
******************************************************************************/
|
||||
|
||||
/***************************************************************************//**
|
||||
* @addtogroup SYSTEM
|
||||
* @{
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
************************** GLOBAL FUNCTIONS *******************************
|
||||
******************************************************************************/
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Get chip major/minor revision.
|
||||
*
|
||||
* @param[out] rev
|
||||
* Location to place chip revision info.
|
||||
******************************************************************************/
|
||||
void SYSTEM_ChipRevisionGet(SYSTEM_ChipRevision_TypeDef *rev)
|
||||
{
|
||||
uint8_t tmp;
|
||||
|
||||
EFM_ASSERT(rev);
|
||||
|
||||
/* CHIP FAMILY bit [5:2] */
|
||||
tmp = (((ROMTABLE->PID1 & _ROMTABLE_PID1_FAMILYMSB_MASK) >> _ROMTABLE_PID1_FAMILYMSB_SHIFT) << 2);
|
||||
/* CHIP FAMILY bit [1:0] */
|
||||
tmp |= ((ROMTABLE->PID0 & _ROMTABLE_PID0_FAMILYLSB_MASK) >> _ROMTABLE_PID0_FAMILYLSB_SHIFT);
|
||||
rev->family = tmp;
|
||||
|
||||
/* CHIP MAJOR bit [3:0] */
|
||||
rev->major = (ROMTABLE->PID0 & _ROMTABLE_PID0_REVMAJOR_MASK) >> _ROMTABLE_PID0_REVMAJOR_SHIFT;
|
||||
|
||||
/* CHIP MINOR bit [7:4] */
|
||||
tmp = (((ROMTABLE->PID2 & _ROMTABLE_PID2_REVMINORMSB_MASK) >> _ROMTABLE_PID2_REVMINORMSB_SHIFT) << 4);
|
||||
/* CHIP MINOR bit [3:0] */
|
||||
tmp |= ((ROMTABLE->PID3 & _ROMTABLE_PID3_REVMINORLSB_MASK) >> _ROMTABLE_PID3_REVMINORLSB_SHIFT);
|
||||
rev->minor = tmp;
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Get factory calibration value for a given peripheral register.
|
||||
*
|
||||
* @param[in] regAddress
|
||||
* Peripheral calibration register address to get calibration value for. If
|
||||
* a calibration value is found then this register is updated with the
|
||||
* calibration value.
|
||||
*
|
||||
* @return
|
||||
* True if a calibration value exists, false otherwise.
|
||||
******************************************************************************/
|
||||
bool SYSTEM_GetCalibrationValue(volatile uint32_t *regAddress)
|
||||
{
|
||||
SYSTEM_CalAddrVal_TypeDef * p, * end;
|
||||
|
||||
p = (SYSTEM_CalAddrVal_TypeDef *)(DEVINFO_BASE & 0xFFFFF000);
|
||||
end = (SYSTEM_CalAddrVal_TypeDef *)DEVINFO_BASE;
|
||||
|
||||
for (; p < end; p++) {
|
||||
if (p->address == 0xFFFFFFFF) {
|
||||
/* Found table terminator */
|
||||
return false;
|
||||
}
|
||||
if (p->address == (uint32_t)regAddress) {
|
||||
*regAddress = p->calValue;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/* Nothing found for regAddress */
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @} (end addtogroup SYSTEM) */
|
||||
/** @} (end addtogroup emlib) */
|
|
@ -0,0 +1,253 @@
|
|||
/***************************************************************************//**
|
||||
* @file em_timer.c
|
||||
* @brief Timer/counter (TIMER) Peripheral API
|
||||
* @version 5.2.2
|
||||
*******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b>
|
||||
*******************************************************************************
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software.
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
*
|
||||
* DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
|
||||
* obligation to support this Software. Silicon Labs is providing the
|
||||
* Software "AS IS", with no express or implied warranties of any kind,
|
||||
* including, but not limited to, any implied warranties of merchantability
|
||||
* or fitness for any particular purpose or warranties against infringement
|
||||
* of any proprietary rights of a third party.
|
||||
*
|
||||
* Silicon Labs will not be liable for any consequential, incidental, or
|
||||
* special damages, or any other relief, or for any claim by any third party,
|
||||
* arising from your use of this Software.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "em_timer.h"
|
||||
#if defined(TIMER_COUNT) && (TIMER_COUNT > 0)
|
||||
|
||||
#include "em_assert.h"
|
||||
|
||||
/***************************************************************************//**
|
||||
* @addtogroup emlib
|
||||
* @{
|
||||
******************************************************************************/
|
||||
|
||||
/***************************************************************************//**
|
||||
* @addtogroup TIMER
|
||||
* @brief Timer/Counter (TIMER) Peripheral API
|
||||
* @details
|
||||
* The timer module consists of three main parts:
|
||||
* @li General timer config and enable control.
|
||||
* @li Compare/capture control.
|
||||
* @li Dead time insertion control (may not be available for all timers).
|
||||
* @{
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
************************** GLOBAL FUNCTIONS *******************************
|
||||
******************************************************************************/
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Initialize TIMER.
|
||||
*
|
||||
* @details
|
||||
* Notice that counter top must be configured separately with for instance
|
||||
* TIMER_TopSet(). In addition, compare/capture and dead-time insertion
|
||||
* init must be initialized separately if used. That should probably
|
||||
* be done prior to the use of this function if configuring the TIMER to
|
||||
* start when initialization is completed.
|
||||
*
|
||||
* @param[in] timer
|
||||
* Pointer to TIMER peripheral register block.
|
||||
*
|
||||
* @param[in] init
|
||||
* Pointer to TIMER initialization structure.
|
||||
******************************************************************************/
|
||||
void TIMER_Init(TIMER_TypeDef *timer, const TIMER_Init_TypeDef *init)
|
||||
{
|
||||
EFM_ASSERT(TIMER_REF_VALID(timer));
|
||||
|
||||
/* Stop timer if specified to be disabled (dosn't hurt if already stopped) */
|
||||
if (!(init->enable)) {
|
||||
timer->CMD = TIMER_CMD_STOP;
|
||||
}
|
||||
|
||||
/* Reset counter */
|
||||
timer->CNT = _TIMER_CNT_RESETVALUE;
|
||||
|
||||
timer->CTRL = ((uint32_t)(init->prescale) << _TIMER_CTRL_PRESC_SHIFT)
|
||||
| ((uint32_t)(init->clkSel) << _TIMER_CTRL_CLKSEL_SHIFT)
|
||||
| ((uint32_t)(init->fallAction) << _TIMER_CTRL_FALLA_SHIFT)
|
||||
| ((uint32_t)(init->riseAction) << _TIMER_CTRL_RISEA_SHIFT)
|
||||
| ((uint32_t)(init->mode) << _TIMER_CTRL_MODE_SHIFT)
|
||||
| (init->debugRun ? TIMER_CTRL_DEBUGRUN : 0)
|
||||
| (init->dmaClrAct ? TIMER_CTRL_DMACLRACT : 0)
|
||||
| (init->quadModeX4 ? TIMER_CTRL_QDM_X4 : 0)
|
||||
| (init->oneShot ? TIMER_CTRL_OSMEN : 0)
|
||||
|
||||
#if defined(TIMER_CTRL_X2CNT) && defined(TIMER_CTRL_ATI)
|
||||
| (init->count2x ? TIMER_CTRL_X2CNT : 0)
|
||||
| (init->ati ? TIMER_CTRL_ATI : 0)
|
||||
#endif
|
||||
| (init->sync ? TIMER_CTRL_SYNC : 0);
|
||||
|
||||
/* Start timer if specified to be enabled (dosn't hurt if already started) */
|
||||
if (init->enable) {
|
||||
timer->CMD = TIMER_CMD_START;
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Initialize TIMER compare/capture channel.
|
||||
*
|
||||
* @details
|
||||
* Notice that if operating channel in compare mode, the CCV and CCVB register
|
||||
* must be set separately as required.
|
||||
*
|
||||
* @param[in] timer
|
||||
* Pointer to TIMER peripheral register block.
|
||||
*
|
||||
* @param[in] ch
|
||||
* Compare/capture channel to init for.
|
||||
*
|
||||
* @param[in] init
|
||||
* Pointer to TIMER initialization structure.
|
||||
******************************************************************************/
|
||||
void TIMER_InitCC(TIMER_TypeDef *timer,
|
||||
unsigned int ch,
|
||||
const TIMER_InitCC_TypeDef *init)
|
||||
{
|
||||
EFM_ASSERT(TIMER_REF_VALID(timer));
|
||||
EFM_ASSERT(TIMER_CH_VALID(ch));
|
||||
|
||||
timer->CC[ch].CTRL =
|
||||
((uint32_t)(init->eventCtrl) << _TIMER_CC_CTRL_ICEVCTRL_SHIFT)
|
||||
| ((uint32_t)(init->edge) << _TIMER_CC_CTRL_ICEDGE_SHIFT)
|
||||
| ((uint32_t)(init->prsSel) << _TIMER_CC_CTRL_PRSSEL_SHIFT)
|
||||
| ((uint32_t)(init->cufoa) << _TIMER_CC_CTRL_CUFOA_SHIFT)
|
||||
| ((uint32_t)(init->cofoa) << _TIMER_CC_CTRL_COFOA_SHIFT)
|
||||
| ((uint32_t)(init->cmoa) << _TIMER_CC_CTRL_CMOA_SHIFT)
|
||||
| ((uint32_t)(init->mode) << _TIMER_CC_CTRL_MODE_SHIFT)
|
||||
| (init->filter ? TIMER_CC_CTRL_FILT_ENABLE : 0)
|
||||
| (init->prsInput ? TIMER_CC_CTRL_INSEL_PRS : 0)
|
||||
| (init->coist ? TIMER_CC_CTRL_COIST : 0)
|
||||
| (init->outInvert ? TIMER_CC_CTRL_OUTINV : 0);
|
||||
}
|
||||
|
||||
#if defined(_TIMER_DTCTRL_MASK)
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Initialize the TIMER DTI unit.
|
||||
*
|
||||
* @param[in] timer
|
||||
* Pointer to TIMER peripheral register block.
|
||||
*
|
||||
* @param[in] init
|
||||
* Pointer to TIMER DTI initialization structure.
|
||||
******************************************************************************/
|
||||
void TIMER_InitDTI(TIMER_TypeDef *timer, const TIMER_InitDTI_TypeDef *init)
|
||||
{
|
||||
EFM_ASSERT(TIMER0 == timer);
|
||||
|
||||
/* Make sure the DTI unit is disabled while initializing. */
|
||||
TIMER_EnableDTI(timer, false);
|
||||
|
||||
/* Setup the DTCTRL register.
|
||||
The enable bit will be set at the end of the function if specified. */
|
||||
timer->DTCTRL =
|
||||
(init->autoRestart ? TIMER_DTCTRL_DTDAS : 0)
|
||||
| (init->activeLowOut ? TIMER_DTCTRL_DTIPOL : 0)
|
||||
| (init->invertComplementaryOut ? TIMER_DTCTRL_DTCINV : 0)
|
||||
| (init->enablePrsSource ? TIMER_DTCTRL_DTPRSEN : 0)
|
||||
| ((uint32_t)(init->prsSel) << _TIMER_DTCTRL_DTPRSSEL_SHIFT);
|
||||
|
||||
/* Setup the DTTIME register. */
|
||||
timer->DTTIME =
|
||||
((uint32_t)(init->prescale) << _TIMER_DTTIME_DTPRESC_SHIFT)
|
||||
| ((uint32_t)(init->riseTime) << _TIMER_DTTIME_DTRISET_SHIFT)
|
||||
| ((uint32_t)(init->fallTime) << _TIMER_DTTIME_DTFALLT_SHIFT);
|
||||
|
||||
/* Setup the DTFC register. */
|
||||
timer->DTFC =
|
||||
(init->enableFaultSourceCoreLockup ? TIMER_DTFC_DTLOCKUPFEN : 0)
|
||||
| (init->enableFaultSourceDebugger ? TIMER_DTFC_DTDBGFEN : 0)
|
||||
| (init->enableFaultSourcePrsSel0 ? TIMER_DTFC_DTPRS0FEN : 0)
|
||||
| (init->enableFaultSourcePrsSel1 ? TIMER_DTFC_DTPRS1FEN : 0)
|
||||
| ((uint32_t)(init->faultAction) << _TIMER_DTFC_DTFA_SHIFT)
|
||||
| ((uint32_t)(init->faultSourcePrsSel0) << _TIMER_DTFC_DTPRS0FSEL_SHIFT)
|
||||
| ((uint32_t)(init->faultSourcePrsSel1) << _TIMER_DTFC_DTPRS1FSEL_SHIFT);
|
||||
|
||||
/* Setup the DTOGEN register. */
|
||||
timer->DTOGEN = init->outputsEnableMask;
|
||||
|
||||
/* Clear any previous DTI faults. */
|
||||
TIMER_ClearDTIFault(timer, TIMER_GetDTIFault(timer));
|
||||
|
||||
/* Enable/disable before returning. */
|
||||
TIMER_EnableDTI(timer, init->enable);
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief
|
||||
* Reset TIMER to same state as after a HW reset.
|
||||
*
|
||||
* @note
|
||||
* The ROUTE register is NOT reset by this function, in order to allow for
|
||||
* centralized setup of this feature.
|
||||
*
|
||||
* @param[in] timer
|
||||
* Pointer to TIMER peripheral register block.
|
||||
******************************************************************************/
|
||||
void TIMER_Reset(TIMER_TypeDef *timer)
|
||||
{
|
||||
int i;
|
||||
|
||||
EFM_ASSERT(TIMER_REF_VALID(timer));
|
||||
|
||||
/* Make sure disabled first, before resetting other registers */
|
||||
timer->CMD = TIMER_CMD_STOP;
|
||||
|
||||
timer->CTRL = _TIMER_CTRL_RESETVALUE;
|
||||
timer->IEN = _TIMER_IEN_RESETVALUE;
|
||||
timer->IFC = _TIMER_IFC_MASK;
|
||||
timer->TOPB = _TIMER_TOPB_RESETVALUE;
|
||||
/* Write TOP after TOPB to invalidate TOPB (clear TIMER_STATUS_TOPBV) */
|
||||
timer->TOP = _TIMER_TOP_RESETVALUE;
|
||||
timer->CNT = _TIMER_CNT_RESETVALUE;
|
||||
/* Do not reset route register, setting should be done independently */
|
||||
/* (Note: ROUTE register may be locked by DTLOCK register.) */
|
||||
|
||||
for (i = 0; TIMER_CH_VALID(i); i++) {
|
||||
timer->CC[i].CTRL = _TIMER_CC_CTRL_RESETVALUE;
|
||||
timer->CC[i].CCV = _TIMER_CC_CCV_RESETVALUE;
|
||||
timer->CC[i].CCVB = _TIMER_CC_CCVB_RESETVALUE;
|
||||
}
|
||||
|
||||
/* Reset dead time insertion module, no effect on timers without DTI */
|
||||
|
||||
#if defined(TIMER_DTLOCK_LOCKKEY_UNLOCK)
|
||||
/* Unlock DTI registers first in case locked */
|
||||
timer->DTLOCK = TIMER_DTLOCK_LOCKKEY_UNLOCK;
|
||||
|
||||
timer->DTCTRL = _TIMER_DTCTRL_RESETVALUE;
|
||||
timer->DTTIME = _TIMER_DTTIME_RESETVALUE;
|
||||
timer->DTFC = _TIMER_DTFC_RESETVALUE;
|
||||
timer->DTOGEN = _TIMER_DTOGEN_RESETVALUE;
|
||||
timer->DTFAULTC = _TIMER_DTFAULTC_MASK;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @} (end addtogroup TIMER) */
|
||||
/** @} (end addtogroup emlib) */
|
||||
#endif /* defined(TIMER_COUNT) && (TIMER_COUNT > 0) */
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,48 @@
|
|||
//=========================================================
|
||||
// inc/InitDevice.h: generated by Hardware Configurator
|
||||
//
|
||||
// This file will be regenerated when saving a document.
|
||||
// leave the sections inside the "$[...]" comment tags alone
|
||||
// or they will be overwritten!
|
||||
//=========================================================
|
||||
#ifndef __INIT_DEVICE_H__
|
||||
#define __INIT_DEVICE_H__
|
||||
|
||||
// USER CONSTANTS
|
||||
// USER PROTOTYPES
|
||||
|
||||
// $[Mode Transition Prototypes]
|
||||
extern void enter_DefaultMode_from_RESET(void);
|
||||
// [Mode Transition Prototypes]$
|
||||
|
||||
// $[Config(Per-Module Mode)Transition Prototypes]
|
||||
extern void EMU_enter_DefaultMode_from_RESET(void);
|
||||
extern void LFXO_enter_DefaultMode_from_RESET(void);
|
||||
extern void CMU_enter_DefaultMode_from_RESET(void);
|
||||
extern void ADC0_enter_DefaultMode_from_RESET(void);
|
||||
extern void ACMP0_enter_DefaultMode_from_RESET(void);
|
||||
extern void ACMP1_enter_DefaultMode_from_RESET(void);
|
||||
extern void IDAC0_enter_DefaultMode_from_RESET(void);
|
||||
extern void RTCC_enter_DefaultMode_from_RESET(void);
|
||||
extern void USART0_enter_DefaultMode_from_RESET(void);
|
||||
extern void USART1_enter_DefaultMode_from_RESET(void);
|
||||
extern void LEUART0_enter_DefaultMode_from_RESET(void);
|
||||
extern void WDOG0_enter_DefaultMode_from_RESET(void);
|
||||
extern void I2C0_enter_DefaultMode_from_RESET(void);
|
||||
extern void GPCRC_enter_DefaultMode_from_RESET(void);
|
||||
extern void LDMA_enter_DefaultMode_from_RESET(void);
|
||||
extern void TIMER0_enter_DefaultMode_from_RESET(void);
|
||||
extern void TIMER1_enter_DefaultMode_from_RESET(void);
|
||||
extern void LETIMER0_enter_DefaultMode_from_RESET(void);
|
||||
extern void CRYOTIMER_enter_DefaultMode_from_RESET(void);
|
||||
extern void PCNT0_enter_DefaultMode_from_RESET(void);
|
||||
extern void PRS_enter_DefaultMode_from_RESET(void);
|
||||
extern void PORTIO_enter_DefaultMode_from_RESET(void);
|
||||
// [Config(Per-Module Mode)Transition Prototypes]$
|
||||
|
||||
// $[User-defined pin name abstraction]
|
||||
|
||||
// [User-defined pin name abstraction]$
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,547 @@
|
|||
//=========================================================
|
||||
// src/InitDevice.c: generated by Hardware Configurator
|
||||
//
|
||||
// This file will be regenerated when saving a document.
|
||||
// leave the sections inside the "$[...]" comment tags alone
|
||||
// or they will be overwritten!
|
||||
//=========================================================
|
||||
|
||||
// USER INCLUDES
|
||||
#include "InitDevice.h"
|
||||
|
||||
// USER PROTOTYPES
|
||||
// USER FUNCTIONS
|
||||
|
||||
// $[Library includes]
|
||||
#include "em_system.h"
|
||||
#include "em_emu.h"
|
||||
#include "em_cmu.h"
|
||||
#include "em_device.h"
|
||||
#include "em_chip.h"
|
||||
#include "em_assert.h"
|
||||
#include "em_cryotimer.h"
|
||||
#include "em_gpio.h"
|
||||
#include "em_usart.h"
|
||||
// [Library includes]$
|
||||
|
||||
//==============================================================================
|
||||
// enter_DefaultMode_from_RESET
|
||||
//==============================================================================
|
||||
extern void enter_DefaultMode_from_RESET(void) {
|
||||
// $[Config Calls]
|
||||
CHIP_Init();
|
||||
|
||||
EMU_enter_DefaultMode_from_RESET();
|
||||
CMU_enter_DefaultMode_from_RESET();
|
||||
USART0_enter_DefaultMode_from_RESET();
|
||||
CRYOTIMER_enter_DefaultMode_from_RESET();
|
||||
PORTIO_enter_DefaultMode_from_RESET();
|
||||
// [Config Calls]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// EMU_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void EMU_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[EMU Initialization]
|
||||
/* Initialize DCDC regulator */
|
||||
EMU_DCDCInit_TypeDef dcdcInit = EMU_DCDCINIT_DEFAULT;
|
||||
|
||||
dcdcInit.powerConfig = emuPowerConfig_DcdcToDvdd;
|
||||
dcdcInit.dcdcMode = emuDcdcMode_LowNoise;
|
||||
dcdcInit.mVout = 1800;
|
||||
dcdcInit.em01LoadCurrent_mA = 15;
|
||||
dcdcInit.em234LoadCurrent_uA = 10;
|
||||
dcdcInit.maxCurrent_mA = 200;
|
||||
dcdcInit.anaPeripheralPower = emuDcdcAnaPeripheralPower_DCDC;
|
||||
dcdcInit.reverseCurrentControl = 160;
|
||||
|
||||
EMU_DCDCInit(&dcdcInit);
|
||||
/* Initialize EM2/EM3 mode */
|
||||
EMU_EM23Init_TypeDef em23Init = EMU_EM23INIT_DEFAULT;
|
||||
|
||||
em23Init.em23VregFullEn = 0;
|
||||
|
||||
EMU_EM23Init(&em23Init);
|
||||
/* Initialize EM4H/S mode */
|
||||
EMU_EM4Init_TypeDef em4Init = EMU_EM4INIT_DEFAULT;
|
||||
|
||||
em4Init.retainLfrco = 0;
|
||||
em4Init.retainLfxo = 0;
|
||||
em4Init.retainUlfrco = 0;
|
||||
em4Init.em4State = emuEM4Shutoff;
|
||||
em4Init.pinRetentionMode = emuPinRetentionDisable;
|
||||
|
||||
EMU_EM4Init(&em4Init);
|
||||
// [EMU Initialization]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// LFXO_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void LFXO_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// CMU_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void CMU_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[High Frequency Clock Setup]
|
||||
/* Initializing HFXO */
|
||||
CMU_HFXOInit_TypeDef hfxoInit = CMU_HFXOINIT_DEFAULT;
|
||||
|
||||
CMU_HFXOInit(&hfxoInit);
|
||||
|
||||
/* Setting system HFRCO frequency */
|
||||
CMU_HFRCOFreqSet (cmuHFRCOFreq_38M0Hz);
|
||||
|
||||
/* Using HFRCO as high frequency clock, HFCLK */
|
||||
CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFRCO);
|
||||
// [High Frequency Clock Setup]$
|
||||
|
||||
// $[LE clocks enable]
|
||||
/* Enable LFRCO oscillator, and wait for it to be stable */
|
||||
CMU_OscillatorEnable(cmuOsc_LFRCO, true, true);
|
||||
|
||||
// [LE clocks enable]$
|
||||
|
||||
// $[LFACLK Setup]
|
||||
/* LFACLK is disabled */
|
||||
// [LFACLK Setup]$
|
||||
// $[LFBCLK Setup]
|
||||
/* LFBCLK is disabled */
|
||||
// [LFBCLK Setup]$
|
||||
// $[LFECLK Setup]
|
||||
/* LFECLK is disabled */
|
||||
// [LFECLK Setup]$
|
||||
// $[Peripheral Clock enables]
|
||||
/* Enable clock for HF peripherals */
|
||||
CMU_ClockEnable(cmuClock_HFPER, true);
|
||||
|
||||
/* Enable clock for CRYOTIMER */
|
||||
CMU_ClockEnable(cmuClock_CRYOTIMER, true);
|
||||
|
||||
/* Enable clock for USART0 */
|
||||
CMU_ClockEnable(cmuClock_USART0, true);
|
||||
|
||||
/* Enable clock for GPIO by default */
|
||||
CMU_ClockEnable(cmuClock_GPIO, true);
|
||||
|
||||
// [Peripheral Clock enables]$
|
||||
|
||||
// $[Clock output]
|
||||
/* Disable CLKOUT0 output */
|
||||
CMU->CTRL = (CMU->CTRL & ~_CMU_CTRL_CLKOUTSEL0_MASK)
|
||||
| CMU_CTRL_CLKOUTSEL0_DISABLED;
|
||||
/* Disable CLKOUT1 output */
|
||||
CMU->CTRL = (CMU->CTRL & ~_CMU_CTRL_CLKOUTSEL1_MASK)
|
||||
| CMU_CTRL_CLKOUTSEL1_DISABLED;
|
||||
|
||||
// [Clock output]$
|
||||
|
||||
// $[CMU_IO]
|
||||
/* Disable CLKOUT0 pin */
|
||||
CMU->ROUTEPEN &= ~CMU_ROUTEPEN_CLKOUT0PEN;
|
||||
|
||||
/* Disable CLKOUT1 pin */
|
||||
CMU->ROUTEPEN &= ~CMU_ROUTEPEN_CLKOUT1PEN;
|
||||
|
||||
// [CMU_IO]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// ADC0_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void ADC0_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[ADC0_Init]
|
||||
// [ADC0_Init]$
|
||||
|
||||
// $[ADC0_InputConfiguration]
|
||||
// [ADC0_InputConfiguration]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// ACMP0_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void ACMP0_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[ACMP0_Init]
|
||||
// [ACMP0_Init]$
|
||||
|
||||
// $[ACMP0_IO]
|
||||
// [ACMP0_IO]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// ACMP1_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void ACMP1_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[ACMP1_Init]
|
||||
// [ACMP1_Init]$
|
||||
|
||||
// $[ACMP1_IO]
|
||||
// [ACMP1_IO]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// IDAC0_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void IDAC0_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// RTCC_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void RTCC_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[Compare/Capture Channel 0 init]
|
||||
// [Compare/Capture Channel 0 init]$
|
||||
|
||||
// $[Compare/Capture Channel 1 init]
|
||||
// [Compare/Capture Channel 1 init]$
|
||||
|
||||
// $[Compare/Capture Channel 2 init]
|
||||
// [Compare/Capture Channel 2 init]$
|
||||
|
||||
// $[RTCC init]
|
||||
// [RTCC init]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// USART0_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void USART0_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[USART_InitAsync]
|
||||
USART_InitAsync_TypeDef initasync = USART_INITASYNC_DEFAULT;
|
||||
|
||||
initasync.enable = usartDisable;
|
||||
initasync.baudrate = 115200;
|
||||
initasync.databits = usartDatabits8;
|
||||
initasync.parity = usartNoParity;
|
||||
initasync.stopbits = usartStopbits1;
|
||||
initasync.oversampling = usartOVS16;
|
||||
#if defined( USART_INPUT_RXPRS ) && defined( USART_CTRL_MVDIS )
|
||||
initasync.mvdis = 0;
|
||||
initasync.prsRxEnable = 0;
|
||||
initasync.prsRxCh = 0;
|
||||
#endif
|
||||
|
||||
USART_InitAsync(USART0, &initasync);
|
||||
// [USART_InitAsync]$
|
||||
|
||||
// $[USART_InitSync]
|
||||
// [USART_InitSync]$
|
||||
|
||||
// $[USART_InitPrsTrigger]
|
||||
USART_PrsTriggerInit_TypeDef initprs = USART_INITPRSTRIGGER_DEFAULT;
|
||||
|
||||
initprs.rxTriggerEnable = 0;
|
||||
initprs.txTriggerEnable = 0;
|
||||
initprs.prsTriggerChannel = usartPrsTriggerCh0;
|
||||
|
||||
USART_InitPrsTrigger(USART0, &initprs);
|
||||
// [USART_InitPrsTrigger]$
|
||||
|
||||
// $[USART_InitIO]
|
||||
/* Disable CLK pin */
|
||||
USART0->ROUTELOC0 = (USART0->ROUTELOC0 & (~_USART_ROUTELOC0_CLKLOC_MASK))
|
||||
| USART_ROUTELOC0_CLKLOC_LOC0;
|
||||
USART0->ROUTEPEN = USART0->ROUTEPEN & (~USART_ROUTEPEN_CLKPEN);
|
||||
|
||||
/* Disable CS pin */
|
||||
USART0->ROUTELOC0 = (USART0->ROUTELOC0 & (~_USART_ROUTELOC0_CSLOC_MASK))
|
||||
| USART_ROUTELOC0_CSLOC_LOC0;
|
||||
USART0->ROUTEPEN = USART0->ROUTEPEN & (~USART_ROUTEPEN_CSPEN);
|
||||
|
||||
/* Set up CTS pin */
|
||||
USART0->ROUTELOC1 = (USART0->ROUTELOC1 & (~_USART_ROUTELOC1_CTSLOC_MASK))
|
||||
| USART_ROUTELOC1_CTSLOC_LOC30;
|
||||
USART0->ROUTEPEN = USART0->ROUTEPEN | USART_ROUTEPEN_CTSPEN;
|
||||
|
||||
/* Set up RTS pin */
|
||||
USART0->ROUTELOC1 = (USART0->ROUTELOC1 & (~_USART_ROUTELOC1_RTSLOC_MASK))
|
||||
| USART_ROUTELOC1_RTSLOC_LOC30;
|
||||
USART0->ROUTEPEN = USART0->ROUTEPEN | USART_ROUTEPEN_RTSPEN;
|
||||
|
||||
/* Set up RX pin */
|
||||
USART0->ROUTELOC0 = (USART0->ROUTELOC0 & (~_USART_ROUTELOC0_RXLOC_MASK))
|
||||
| USART_ROUTELOC0_RXLOC_LOC0;
|
||||
USART0->ROUTEPEN = USART0->ROUTEPEN | USART_ROUTEPEN_RXPEN;
|
||||
|
||||
/* Set up TX pin */
|
||||
USART0->ROUTELOC0 = (USART0->ROUTELOC0 & (~_USART_ROUTELOC0_TXLOC_MASK))
|
||||
| USART_ROUTELOC0_TXLOC_LOC0;
|
||||
USART0->ROUTEPEN = USART0->ROUTEPEN | USART_ROUTEPEN_TXPEN;
|
||||
|
||||
// [USART_InitIO]$
|
||||
|
||||
// $[USART_Misc]
|
||||
/* Disable CTS */
|
||||
USART0->CTRLX = USART0->CTRLX & (~USART_CTRLX_CTSEN);
|
||||
/* Set CTS active low */
|
||||
USART0->CTRLX = USART0->CTRLX & (~USART_CTRLX_CTSINV);
|
||||
/* Set RTS active low */
|
||||
USART0->CTRLX = USART0->CTRLX & (~USART_CTRLX_RTSINV);
|
||||
/* Set CS active low */
|
||||
USART0->CTRL = USART0->CTRL & (~USART_CTRL_CSINV);
|
||||
/* Set TX active high */
|
||||
USART0->CTRL = USART0->CTRL & (~USART_CTRL_TXINV);
|
||||
/* Set RX active high */
|
||||
USART0->CTRL = USART0->CTRL & (~USART_CTRL_RXINV);
|
||||
// [USART_Misc]$
|
||||
|
||||
// $[USART_Enable]
|
||||
|
||||
/* Enable USART if opted by user */
|
||||
USART_Enable(USART0, usartEnable);
|
||||
// [USART_Enable]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// USART1_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void USART1_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[USART_InitAsync]
|
||||
// [USART_InitAsync]$
|
||||
|
||||
// $[USART_InitSync]
|
||||
// [USART_InitSync]$
|
||||
|
||||
// $[USART_InitPrsTrigger]
|
||||
// [USART_InitPrsTrigger]$
|
||||
|
||||
// $[USART_InitIO]
|
||||
// [USART_InitIO]$
|
||||
|
||||
// $[USART_Misc]
|
||||
// [USART_Misc]$
|
||||
|
||||
// $[USART_Enable]
|
||||
// [USART_Enable]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// LEUART0_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void LEUART0_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[LEUART0 initialization]
|
||||
// [LEUART0 initialization]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// WDOG0_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void WDOG0_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[WDOG Initialization]
|
||||
// [WDOG Initialization]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// I2C0_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void I2C0_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[I2C0 I/O setup]
|
||||
// [I2C0 I/O setup]$
|
||||
|
||||
// $[I2C0 initialization]
|
||||
// [I2C0 initialization]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// GPCRC_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void GPCRC_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// LDMA_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void LDMA_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// TIMER0_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void TIMER0_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[TIMER0 I/O setup]
|
||||
// [TIMER0 I/O setup]$
|
||||
|
||||
// $[TIMER0 initialization]
|
||||
// [TIMER0 initialization]$
|
||||
|
||||
// $[TIMER0 CC0 init]
|
||||
// [TIMER0 CC0 init]$
|
||||
|
||||
// $[TIMER0 CC1 init]
|
||||
// [TIMER0 CC1 init]$
|
||||
|
||||
// $[TIMER0 CC2 init]
|
||||
// [TIMER0 CC2 init]$
|
||||
|
||||
// $[TIMER0 DTI init]
|
||||
// [TIMER0 DTI init]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// TIMER1_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void TIMER1_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[TIMER1 I/O setup]
|
||||
// [TIMER1 I/O setup]$
|
||||
|
||||
// $[TIMER1 initialization]
|
||||
// [TIMER1 initialization]$
|
||||
|
||||
// $[TIMER1 CC0 init]
|
||||
// [TIMER1 CC0 init]$
|
||||
|
||||
// $[TIMER1 CC1 init]
|
||||
// [TIMER1 CC1 init]$
|
||||
|
||||
// $[TIMER1 CC2 init]
|
||||
// [TIMER1 CC2 init]$
|
||||
|
||||
// $[TIMER1 CC3 init]
|
||||
// [TIMER1 CC3 init]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// LETIMER0_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void LETIMER0_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[LETIMER0 Compare Values]
|
||||
// [LETIMER0 Compare Values]$
|
||||
|
||||
// $[LETIMER0 Repeat Values]
|
||||
// [LETIMER0 Repeat Values]$
|
||||
|
||||
// $[LETIMER0 Initialization]
|
||||
// [LETIMER0 Initialization]$
|
||||
|
||||
// $[LETIMER0 PRS Input Triggers]
|
||||
// [LETIMER0 PRS Input Triggers]$
|
||||
|
||||
// $[LETIMER0 I/O setup]
|
||||
// [LETIMER0 I/O setup]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// CRYOTIMER_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void CRYOTIMER_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[CRYOTIMER_Init]
|
||||
CRYOTIMER_Init_TypeDef cryoInit = CRYOTIMER_INIT_DEFAULT;
|
||||
|
||||
/* General settings */
|
||||
cryoInit.enable = 1;
|
||||
cryoInit.debugRun = 0;
|
||||
cryoInit.em4Wakeup = 0;
|
||||
|
||||
/* Clocking settings */
|
||||
/* With a frequency of 32768Hz on LFRCO, this will result in a 0.98 ms timeout */
|
||||
cryoInit.osc = cryotimerOscLFRCO;
|
||||
cryoInit.presc = cryotimerPresc_32;
|
||||
cryoInit.period = cryotimerPeriod_1;
|
||||
CRYOTIMER_Init(&cryoInit);
|
||||
// [CRYOTIMER_Init]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// PCNT0_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void PCNT0_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[PCNT0 I/O setup]
|
||||
// [PCNT0 I/O setup]$
|
||||
|
||||
// $[PCNT0 initialization]
|
||||
// [PCNT0 initialization]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// PRS_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void PRS_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[PRS initialization]
|
||||
// [PRS initialization]$
|
||||
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// PORTIO_enter_DefaultMode_from_RESET
|
||||
//================================================================================
|
||||
extern void PORTIO_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
// $[Port A Configuration]
|
||||
|
||||
/* Pin PA0 is configured to Push-pull */
|
||||
GPIO_PinModeSet(gpioPortA, 0, gpioModePushPull, 0);
|
||||
|
||||
/* Pin PA1 is configured to Input enabled with pull-up */
|
||||
GPIO_PinModeSet(gpioPortA, 1, gpioModeInputPull, 1);
|
||||
|
||||
/* Pin PA3 is configured to Push-pull */
|
||||
GPIO_PinModeSet(gpioPortA, 3, gpioModePushPull, 0);
|
||||
|
||||
/* Pin PA5 is configured to Push-pull */
|
||||
GPIO_PinModeSet(gpioPortA, 5, gpioModePushPull, 1);
|
||||
// [Port A Configuration]$
|
||||
|
||||
// $[Port B Configuration]
|
||||
// [Port B Configuration]$
|
||||
|
||||
// $[Port C Configuration]
|
||||
// [Port C Configuration]$
|
||||
|
||||
// $[Port D Configuration]
|
||||
// [Port D Configuration]$
|
||||
|
||||
// $[Port E Configuration]
|
||||
// [Port E Configuration]$
|
||||
|
||||
// $[Port F Configuration]
|
||||
|
||||
/* Pin PF4 is configured to Push-pull */
|
||||
GPIO_PinModeSet(gpioPortF, 4, gpioModePushPull, 0);
|
||||
|
||||
/* Pin PF5 is configured to Push-pull */
|
||||
GPIO_PinModeSet(gpioPortF, 5, gpioModePushPull, 0);
|
||||
// [Port F Configuration]$
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* app.h
|
||||
*
|
||||
* Created on: Jun 26, 2018
|
||||
* Author: conor
|
||||
*/
|
||||
|
||||
#ifndef SRC_APP_H_
|
||||
#define SRC_APP_H_
|
||||
|
||||
#define PRINTING_USE_VCOM
|
||||
|
||||
#define USING_DEV_BOARD
|
||||
|
||||
void printing_init();
|
||||
|
||||
|
||||
#endif /* SRC_APP_H_ */
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* device.c
|
||||
*
|
||||
* Created on: Jun 27, 2018
|
||||
* Author: conor
|
||||
*/
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "em_chip.h"
|
||||
#include "em_gpio.h"
|
||||
|
||||
#include "cbor.h"
|
||||
#include "log.h"
|
||||
#include "ctaphid.h"
|
||||
#include "util.h"
|
||||
|
||||
// Generate @num bytes of random numbers to @dest
|
||||
// return 1 if success, error otherwise
|
||||
int ctap_generate_rng(uint8_t * dst, size_t num)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
*dst++ = rand();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32_t _c1 = 0, _c2 = 0;
|
||||
uint32_t ctap_atomic_count(int sel)
|
||||
{
|
||||
if (sel == 0)
|
||||
{
|
||||
_c1++;
|
||||
return _c1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_c2++;
|
||||
return _c2;
|
||||
}
|
||||
}
|
||||
|
||||
// Verify the user
|
||||
// return 1 if user is verified, 0 if not
|
||||
int ctap_user_verification(uint8_t arg)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Test for user presence
|
||||
// Return 1 for user is present, 0 user not present
|
||||
int ctap_user_presence_test()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Must be implemented by application
|
||||
// data is HID_MESSAGE_SIZE long in bytes
|
||||
void ctaphid_write_block(uint8_t * data)
|
||||
{
|
||||
dump_hex(data, HID_MESSAGE_SIZE);
|
||||
}
|
||||
|
||||
void heartbeat()
|
||||
{
|
||||
static int beat = 0;
|
||||
GPIO_PinOutToggle(gpioPortF,4);
|
||||
GPIO_PinOutToggle(gpioPortF,5);
|
||||
// printf("heartbeat %d\r\n", CRYOTIMER->CNT);
|
||||
}
|
||||
|
||||
uint64_t millis()
|
||||
{
|
||||
return CRYOTIMER->CNT;
|
||||
}
|
||||
|
||||
|
||||
void usbhid_init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int usbhid_recv(uint8_t * msg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void usbhid_send(uint8_t * msg)
|
||||
{
|
||||
}
|
||||
|
||||
void usbhid_close()
|
||||
{
|
||||
}
|
||||
|
||||
void main_loop_delay()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void device_init(void)
|
||||
{
|
||||
/* Chip errata */
|
||||
CHIP_Init();
|
||||
enter_DefaultMode_from_RESET();
|
||||
|
||||
GPIO_PinModeSet(gpioPortF,
|
||||
4,
|
||||
gpioModePushPull,
|
||||
0);
|
||||
|
||||
GPIO_PinModeSet(gpioPortF,
|
||||
5,
|
||||
gpioModePushPull,
|
||||
1);
|
||||
|
||||
|
||||
|
||||
|
||||
printing_init();
|
||||
|
||||
CborEncoder test;
|
||||
uint8_t buf[20];
|
||||
cbor_encoder_init(&test, buf, 20, 0);
|
||||
|
||||
printf("Device init\r\n");
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "em_chip.h"
|
||||
#include "em_cmu.h"
|
||||
#include "em_emu.h"
|
||||
#include "em_core.h"
|
||||
#include "em_gpio.h"
|
||||
|
||||
#include "InitDevice.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "cbor.h"
|
|
@ -0,0 +1,82 @@
|
|||
#include "em_chip.h"
|
||||
#include "em_cmu.h"
|
||||
#include "em_emu.h"
|
||||
#include "em_core.h"
|
||||
#include "em_usart.h"
|
||||
#include "em_gpio.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "app.h"
|
||||
#ifndef PRINTING_USE_VCOM
|
||||
int RETARGET_WriteChar(char c)
|
||||
{
|
||||
return ITM_SendChar(c);
|
||||
}
|
||||
|
||||
int RETARGET_ReadChar(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void setupSWOForPrint(void)
|
||||
{
|
||||
/* Enable GPIO clock. */
|
||||
CMU_ClockEnable(cmuClock_GPIO, true);
|
||||
|
||||
/* Enable Serial wire output pin */
|
||||
GPIO->ROUTEPEN |= GPIO_ROUTEPEN_SWVPEN;
|
||||
|
||||
/* Set location 0 */
|
||||
GPIO->ROUTELOC0 = GPIO_ROUTELOC0_SWVLOC_LOC0;
|
||||
|
||||
/* Enable output on pin - GPIO Port F, Pin 2 */
|
||||
GPIO->P[5].MODEL &= ~(_GPIO_P_MODEL_MODE2_MASK);
|
||||
GPIO->P[5].MODEL |= GPIO_P_MODEL_MODE2_PUSHPULL;
|
||||
|
||||
/* Enable debug clock AUXHFRCO */
|
||||
CMU_OscillatorEnable(cmuOsc_AUXHFRCO, true, true);
|
||||
CMU->OSCENCMD = CMU_OSCENCMD_AUXHFRCOEN;
|
||||
|
||||
/* Wait until clock is ready */
|
||||
while (!(CMU->STATUS & CMU_STATUS_AUXHFRCORDY));
|
||||
|
||||
/* Enable trace in core debug */
|
||||
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
|
||||
ITM->LAR = 0xC5ACCE55;
|
||||
ITM->TER = 0x0;
|
||||
ITM->TCR = 0x0;
|
||||
TPI->SPPR = 2;
|
||||
TPI->ACPR = 0x15; // changed from 0x0F on Giant, etc. to account for 19 MHz default AUXHFRCO frequency
|
||||
ITM->TPR = 0x0;
|
||||
DWT->CTRL = 0x400003FE;
|
||||
ITM->TCR = 0x0001000D;
|
||||
TPI->FFCR = 0x00000100;
|
||||
ITM->TER = 0x1;
|
||||
}
|
||||
|
||||
|
||||
void printing_init()
|
||||
{
|
||||
setupSWOForPrint();
|
||||
}
|
||||
#else
|
||||
|
||||
int RETARGET_WriteChar(char c)
|
||||
{
|
||||
USART_Tx(USART0,c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RETARGET_ReadChar(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void printing_init()
|
||||
{
|
||||
// GPIO_PinModeSet(gpioPortA,5,gpioModePushPull,1); // VCOM enable
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,475 @@
|
|||
/***************************************************************************//**
|
||||
* @file
|
||||
* @brief Provide stdio retargeting for all supported toolchains.
|
||||
* @version 5.5.0
|
||||
*******************************************************************************
|
||||
* # License
|
||||
* <b>Copyright 2015 Silicon Labs, Inc. http://www.silabs.com</b>
|
||||
*******************************************************************************
|
||||
*
|
||||
* This file is licensed under the Silabs License Agreement. See the file
|
||||
* "Silabs_License_Agreement.txt" for details. Before using this software for
|
||||
* any purpose, you must agree to the terms of that agreement.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/***************************************************************************//**
|
||||
* @addtogroup RetargetIo
|
||||
* @{ This module provide low-level stubs for retargetting stdio for all
|
||||
* supported toolchains.
|
||||
* The stubs are minimal yet sufficient implementations.
|
||||
* Refer to chapter 12 in the reference manual for newlib 1.17.0
|
||||
* for details on implementing newlib stubs.
|
||||
******************************************************************************/
|
||||
|
||||
extern int RETARGET_ReadChar(void);
|
||||
extern int RETARGET_WriteChar(char c);
|
||||
|
||||
#if !defined(__CROSSWORKS_ARM) && defined(__GNUC__)
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "em_device.h"
|
||||
|
||||
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
|
||||
int fileno(FILE *);
|
||||
/** @endcond */
|
||||
|
||||
int _close(int file);
|
||||
int _fstat(int file, struct stat *st);
|
||||
int _isatty(int file);
|
||||
int _lseek(int file, int ptr, int dir);
|
||||
int _read(int file, char *ptr, int len);
|
||||
caddr_t _sbrk(int incr);
|
||||
int _write(int file, const char *ptr, int len);
|
||||
|
||||
extern char _end; /**< Defined by the linker */
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Close a file.
|
||||
*
|
||||
* @param[in] file
|
||||
* File you want to close.
|
||||
*
|
||||
* @return
|
||||
* Returns 0 when the file is closed.
|
||||
*****************************************************************************/
|
||||
int _close(int file)
|
||||
{
|
||||
(void) file;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Exit the program.
|
||||
* @param[in] status The value to return to the parent process as the
|
||||
* exit status (not used).
|
||||
*****************************************************************************/
|
||||
void _exit(int status)
|
||||
{
|
||||
(void) status;
|
||||
while (1) {
|
||||
} /* Hang here forever... */
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Status of an open file.
|
||||
*
|
||||
* @param[in] file
|
||||
* Check status for this file.
|
||||
*
|
||||
* @param[in] st
|
||||
* Status information.
|
||||
*
|
||||
* @return
|
||||
* Returns 0 when st_mode is set to character special.
|
||||
*****************************************************************************/
|
||||
int _fstat(int file, struct stat *st)
|
||||
{
|
||||
(void) file;
|
||||
st->st_mode = S_IFCHR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Get process ID.
|
||||
*****************************************************************************/
|
||||
int _getpid(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Query whether output stream is a terminal.
|
||||
*
|
||||
* @param[in] file
|
||||
* Descriptor for the file.
|
||||
*
|
||||
* @return
|
||||
* Returns 1 when query is done.
|
||||
*****************************************************************************/
|
||||
int _isatty(int file)
|
||||
{
|
||||
(void) file;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Send signal to process.
|
||||
* @param[in] pid Process id (not used).
|
||||
* @param[in] sig Signal to send (not used).
|
||||
*****************************************************************************/
|
||||
int _kill(int pid, int sig)
|
||||
{
|
||||
(void)pid;
|
||||
(void)sig;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Set position in a file.
|
||||
*
|
||||
* @param[in] file
|
||||
* Descriptor for the file.
|
||||
*
|
||||
* @param[in] ptr
|
||||
* Poiter to the argument offset.
|
||||
*
|
||||
* @param[in] dir
|
||||
* Directory whence.
|
||||
*
|
||||
* @return
|
||||
* Returns 0 when position is set.
|
||||
*****************************************************************************/
|
||||
int _lseek(int file, int ptr, int dir)
|
||||
{
|
||||
(void) file;
|
||||
(void) ptr;
|
||||
(void) dir;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Read from a file.
|
||||
*
|
||||
* @param[in] file
|
||||
* Descriptor for the file you want to read from.
|
||||
*
|
||||
* @param[in] ptr
|
||||
* Pointer to the chacaters that are beeing read.
|
||||
*
|
||||
* @param[in] len
|
||||
* Number of characters to be read.
|
||||
*
|
||||
* @return
|
||||
* Number of characters that have been read.
|
||||
*****************************************************************************/
|
||||
int _read(int file, char *ptr, int len)
|
||||
{
|
||||
int c, rxCount = 0;
|
||||
|
||||
(void) file;
|
||||
|
||||
while (len--) {
|
||||
if ((c = RETARGET_ReadChar()) != -1) {
|
||||
*ptr++ = c;
|
||||
rxCount++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rxCount <= 0) {
|
||||
return -1; /* Error exit */
|
||||
}
|
||||
|
||||
return rxCount;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Increase heap.
|
||||
*
|
||||
* @param[in] incr
|
||||
* Number of bytes you want increment the program's data space.
|
||||
*
|
||||
* @return
|
||||
* Rsturns a pointer to the start of the new area.
|
||||
*****************************************************************************/
|
||||
caddr_t _sbrk(int incr)
|
||||
{
|
||||
static char *heap_end;
|
||||
char *prev_heap_end;
|
||||
|
||||
if (heap_end == 0) {
|
||||
heap_end = &_end;
|
||||
}
|
||||
|
||||
prev_heap_end = heap_end;
|
||||
heap_end += incr;
|
||||
|
||||
return (caddr_t) prev_heap_end;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Write to a file.
|
||||
*
|
||||
* @param[in] file
|
||||
* Descriptor for the file you want to write to.
|
||||
*
|
||||
* @param[in] ptr
|
||||
* Pointer to the text you want to write
|
||||
*
|
||||
* @param[in] len
|
||||
* Number of characters to be written.
|
||||
*
|
||||
* @return
|
||||
* Number of characters that have been written.
|
||||
*****************************************************************************/
|
||||
int _write(int file, const char *ptr, int len)
|
||||
{
|
||||
int txCount;
|
||||
|
||||
(void) file;
|
||||
|
||||
for (txCount = 0; txCount < len; txCount++) {
|
||||
RETARGET_WriteChar(*ptr++);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
#endif /* !defined( __CROSSWORKS_ARM ) && defined( __GNUC__ ) */
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
/*******************
|
||||
*
|
||||
* Copyright 1998-2003 IAR Systems. All rights reserved.
|
||||
*
|
||||
* $Revision: 38614 $
|
||||
*
|
||||
* This is a template implementation of the "__write" function used by
|
||||
* the standard library. Replace it with a system-specific
|
||||
* implementation.
|
||||
*
|
||||
* The "__write" function should output "size" number of bytes from
|
||||
* "buffer" in some application-specific way. It should return the
|
||||
* number of characters written, or _LLIO_ERROR on failure.
|
||||
*
|
||||
* If "buffer" is zero then __write should perform flushing of
|
||||
* internal buffers, if any. In this case "handle" can be -1 to
|
||||
* indicate that all handles should be flushed.
|
||||
*
|
||||
* The template implementation below assumes that the application
|
||||
* provides the function "MyLowLevelPutchar". It should return the
|
||||
* character written, or -1 on failure.
|
||||
*
|
||||
********************/
|
||||
|
||||
#include <yfuns.h>
|
||||
#include <stdint.h>
|
||||
#include "em_common.h"
|
||||
|
||||
_STD_BEGIN
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Transmit buffer to USART1
|
||||
* @param buffer Array of characters to send
|
||||
* @param nbytes Number of bytes to transmit
|
||||
* @return Number of bytes sent
|
||||
*****************************************************************************/
|
||||
static int TxBuf(uint8_t *buffer, int nbytes)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nbytes; i++) {
|
||||
RETARGET_WriteChar(*buffer++);
|
||||
}
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the __write implementation uses internal buffering, uncomment
|
||||
* the following line to ensure that we are called with "buffer" as 0
|
||||
* (i.e. flush) when the application terminates.
|
||||
*/
|
||||
size_t __write(int handle, const unsigned char * buffer, size_t size)
|
||||
{
|
||||
/* Remove the #if #endif pair to enable the implementation */
|
||||
|
||||
size_t nChars = 0;
|
||||
|
||||
if (buffer == 0) {
|
||||
/*
|
||||
* This means that we should flush internal buffers. Since we
|
||||
* don't we just return. (Remember, "handle" == -1 means that all
|
||||
* handles should be flushed.)
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This template only writes to "standard out" and "standard err",
|
||||
* for all other file handles it returns failure. */
|
||||
if (handle != _LLIO_STDOUT && handle != _LLIO_STDERR) {
|
||||
return _LLIO_ERROR;
|
||||
}
|
||||
|
||||
/* Hook into USART1 transmit function here */
|
||||
if (TxBuf((uint8_t *) buffer, size) != size) {
|
||||
return _LLIO_ERROR;
|
||||
} else {
|
||||
nChars = size;
|
||||
}
|
||||
|
||||
return nChars;
|
||||
}
|
||||
|
||||
size_t __read(int handle, unsigned char * buffer, size_t size)
|
||||
{
|
||||
/* Remove the #if #endif pair to enable the implementation */
|
||||
int nChars = 0;
|
||||
|
||||
/* This template only reads from "standard in", for all other file
|
||||
* handles it returns failure. */
|
||||
if (handle != _LLIO_STDIN) {
|
||||
return _LLIO_ERROR;
|
||||
}
|
||||
|
||||
for (/* Empty */; size > 0; --size) {
|
||||
int c = RETARGET_ReadChar();
|
||||
if (c < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
*buffer++ = c;
|
||||
++nChars;
|
||||
}
|
||||
|
||||
return nChars;
|
||||
}
|
||||
|
||||
_STD_END
|
||||
|
||||
#endif /* defined( __ICCARM__ ) */
|
||||
|
||||
#if defined(__CROSSWORKS_ARM)
|
||||
|
||||
/* Pass each of these function straight to the USART */
|
||||
int __putchar(int ch)
|
||||
{
|
||||
return(RETARGET_WriteChar(ch));
|
||||
}
|
||||
|
||||
int __getchar(void)
|
||||
{
|
||||
return(RETARGET_ReadChar());
|
||||
}
|
||||
|
||||
#endif /* defined( __CROSSWORKS_ARM ) */
|
||||
|
||||
#if defined(__CC_ARM)
|
||||
/******************************************************************************/
|
||||
/* RETARGET.C: 'Retarget' layer for target-dependent low level functions */
|
||||
/******************************************************************************/
|
||||
/* This file is part of the uVision/ARM development tools. */
|
||||
/* Copyright (c) 2005-2006 Keil Software. All rights reserved. */
|
||||
/* This software may only be used under the terms of a valid, current, */
|
||||
/* end user licence from KEIL for a compatible version of KEIL software */
|
||||
/* development tools. Nothing else gives you the right to use this software. */
|
||||
/******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* #pragma import(__use_no_semihosting_swi) */
|
||||
|
||||
struct __FILE{
|
||||
int handle;
|
||||
};
|
||||
|
||||
/**Standard output stream*/
|
||||
FILE __stdout;
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Writes character to file
|
||||
*
|
||||
* @param[in] f
|
||||
* File
|
||||
*
|
||||
* @param[in] ch
|
||||
* Character
|
||||
*
|
||||
* @return
|
||||
* Written character
|
||||
*****************************************************************************/
|
||||
int fputc(int ch, FILE *f)
|
||||
{
|
||||
return(RETARGET_WriteChar(ch));
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Reads character from file
|
||||
*
|
||||
* @param[in] f
|
||||
* File
|
||||
*
|
||||
* @return
|
||||
* Character
|
||||
*****************************************************************************/
|
||||
int fgetc(FILE *f)
|
||||
{
|
||||
return(RETARGET_ReadChar());
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Tests the error indicator for the stream pointed
|
||||
* to by file
|
||||
*
|
||||
* @param[in] f
|
||||
* File
|
||||
*
|
||||
* @return
|
||||
* Returns non-zero if it is set
|
||||
*****************************************************************************/
|
||||
int ferror(FILE *f)
|
||||
{
|
||||
/* Your implementation of ferror */
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Writes a character to the console
|
||||
*
|
||||
* @param[in] ch
|
||||
* Character
|
||||
*****************************************************************************/
|
||||
void _ttywrch(int ch)
|
||||
{
|
||||
RETARGET_WriteChar(ch);
|
||||
}
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief
|
||||
* Library exit function. This function is called if stack
|
||||
* overflow occurs.
|
||||
*
|
||||
* @param[in] return_code
|
||||
* Return code
|
||||
*****************************************************************************/
|
||||
void _sys_exit(int return_code)
|
||||
{
|
||||
label: goto label;/* endless loop */
|
||||
}
|
||||
#endif /* defined( __CC_ARM ) */
|
||||
|
||||
/** @} (end group RetargetIo) */
|
|
@ -0,0 +1,188 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.debug#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.debug#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0" moduleId="org.eclipse.cdt.core.settings" name="Keil 8051 v9.53 - Debug">
|
||||
<macros>
|
||||
<stringMacro name="StudioSdkPath" type="VALUE_PATH_DIR" value="${StudioSdkPathFromID:com.silabs.sdk.8051:4.1.1._-963069327}"/>
|
||||
<stringMacro name="StudioToolchainPath" type="VALUE_PATH_DIR" value="${StudioToolchainPathFromID:com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0}"/>
|
||||
</macros>
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.HEX" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.tool.ide.c8051.debug.OMF2" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.EBL" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.GBL" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.tool.ide.c8051.debug.OMF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.BIN" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.S37" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.KeilErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule buildConfig.stockConfigId="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.debug#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0" cppBuildConfig.builtinIncludes="studio:/sdk/Lib/efm8_usb/inc/ studio:/sdk/Lib/efm8_assert/ studio:/sdk/Device/EFM8UB1/peripheral_driver/inc/ studio:/sdk/Device/shared/si8051base/ studio:/sdk/Device/EFM8UB1/inc/ studio:/sdk/Lib/efm8_usbc/lib_kernel/inc/ studio:/sdk/Lib/efm8_usbc/lib_usbc_pd/inc/ studio:/sdk/Lib/efm8_usb/inc/ studio:/sdk/Lib/efm8_assert/ studio:/sdk/Device/EFM8UB1/peripheral_driver/inc/ studio:/sdk/Device/shared/si8051base/ studio:/sdk/Device/EFM8UB1/inc/ studio:/sdk/Lib/efm8_usbc/lib_kernel/inc/ studio:/sdk/Lib/efm8_usbc/lib_usbc_pd/inc/" cppBuildConfig.builtinLibraryFiles="" cppBuildConfig.builtinLibraryNames="" cppBuildConfig.builtinLibraryObjects="" cppBuildConfig.builtinLibraryPaths="" cppBuildConfig.builtinMacros="" moduleId="com.silabs.ss.framework.ide.project.core.cpp" projectCommon.boardIds="brd5000a:0.0.0.A02" projectCommon.partId="mcu.8051.efm8.ub1.efm8ub10f16g-b-qfn28" projectCommon.referencedModules="[{"builtinExcludes":[],"builtinSources":["lib/efm8ub1/peripheralDrivers/src/usb_0.c","lib/efm8ub1/peripheralDrivers/inc/usb_0.h"],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.si8051.external.efm8PeripheralDriver.usb0\"/>"},{"builtinExcludes":[],"builtinSources":["lib/efm8_assert/assert.c","lib/efm8_assert/assert.h"],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.si8051.external.efm8Library.assert\"/>"},{"builtinExcludes":[],"builtinSources":["lib/efm8_usb/inc/efm8_usb.h","lib/efm8_usb/src/efm8_usbd.c","lib/efm8_usb/src/efm8_usbdch9.c","lib/efm8_usb/src/efm8_usbdep.c","lib/efm8_usb/src/efm8_usbdint.c","lib/efm8_usb/Readme.txt"],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.si8051.external.efm8Library.usb\"/>"},{"builtinExcludes":[],"builtinSources":["src/SILABS_STARTUP.A51"],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.si8051.shared\"/>"},{"builtinExcludes":[],"builtinSources":[],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.si8051.external.efm8Library.usbc\"/>"}]" projectCommon.sdkId="com.silabs.sdk.8051:4.1.1._-963069327" projectCommon.toolchainId="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0"/>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="omf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.debug#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0" name="Keil 8051 v9.53 - Debug" parent="com.silabs.ide.si8051.keil.exe.default">
|
||||
<folderInfo id="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.debug#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0." name="/" resourcePath="">
|
||||
<toolChain id="com.silabs.ide.si8051.keil.toolchain.exe.default.803196567" name="Keil 8051" superClass="com.silabs.ide.si8051.keil.toolchain.exe.default">
|
||||
<option id="com.silabs.ide.si8051.keil.toolchain.category.general.debug.1285835962" name="Generate debug information" superClass="com.silabs.ide.si8051.keil.toolchain.category.general.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.silabs.ide.si8051.keil.toolchain.category.general.extended_assembler.1124669083" name="Use Extended Assembler (AX51) instead of A51" superClass="com.silabs.ide.si8051.keil.toolchain.category.general.extended_assembler" value="true" valueType="boolean"/>
|
||||
<option id="com.silabs.ide.si8051.keil.toolchain.category.general.extended_linker.1220060828" name="Use Extended Linker (LX51) instead of BL51" superClass="com.silabs.ide.si8051.keil.toolchain.category.general.extended_linker" value="true" valueType="boolean"/>
|
||||
<option id="com.silabs.ide.si8051.keil.toolchain.category.general.memory_model.923432818" name="Memory model" superClass="com.silabs.ide.si8051.keil.toolchain.category.general.memory_model" value="com.silabs.ide.si8051.keil.toolchain.category.general.memory_model.large" valueType="enumerated"/>
|
||||
<targetPlatform binaryParser="com.silabs.ss.tool.ide.c8051.debug.OMF;com.silabs.ss.tool.ide.c8051.debug.OMF2;com.silabs.ss.framework.debugger.core.BIN;com.silabs.ss.framework.debugger.core.HEX;com.silabs.ss.framework.debugger.core.S37;com.silabs.ss.framework.debugger.core.EBL;com.silabs.ss.framework.debugger.core.GBL" id="com.silabs.ide.si8051.keil.targetplatform.1736873507" isAbstract="false" superClass="com.silabs.ide.si8051.keil.targetplatform"/>
|
||||
<builder buildPath="${workspace_loc:/efm8}/Keil 8051 v9.53 - Debug" id="com.silabs.ide.si8051.keil.builder.699981897" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Keil Builder" parallelBuildOn="false" superClass="com.silabs.ide.si8051.keil.builder"/>
|
||||
<tool id="com.silabs.ide.si8051.keil.toolchain.compiler.161237451" name="Keil 8051 Compiler" superClass="com.silabs.ide.si8051.keil.toolchain.compiler">
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.symbols.def.1394396371" name="Defined symbols (DEFINE(...))" superClass="com.silabs.ide.si8051.keil.compiler.category.symbols.def" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="DEBUG=1"/>
|
||||
</option>
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.optimization.level.816863969" name="Level" superClass="com.silabs.ide.si8051.keil.compiler.category.optimization.level" value="com.silabs.ide.si8051.keil.compiler.category.optimization.level.9" valueType="enumerated"/>
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.optimization.emphasis.628030751" name="Emphasis" superClass="com.silabs.ide.si8051.keil.compiler.category.optimization.emphasis" value="com.silabs.ide.si8051.keil.compiler.category.optimization.emphasis.speed" valueType="enumerated"/>
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.includes.paths.1243816580" name="Include paths (INCDIR(...))" superClass="com.silabs.ide.si8051.keil.compiler.category.includes.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc/config}""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usb/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_assert""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/EFM8UB1/peripheral_driver/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/shared/si8051base""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/EFM8UB1/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usbc/lib_kernel/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usbc/lib_usbc_pd/inc""/>
|
||||
</option>
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.misc.extraflags.1584403236" name="Additional Flags" superClass="com.silabs.ide.si8051.keil.compiler.category.misc.extraflags" value="OA" valueType="string"/>
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.general.code.1474638890" name="Code size" superClass="com.silabs.ide.si8051.keil.compiler.category.general.code" value="com.silabs.ide.si8051.keil.compiler.category.general.code.small" valueType="enumerated"/>
|
||||
<inputType id="com.silabs.ide.si8051.keil.compiler.inputType.1048026013" superClass="com.silabs.ide.si8051.keil.compiler.inputType"/>
|
||||
</tool>
|
||||
<tool command="AX51" id="com.silabs.ide.si8051.keil.toolchain.assembler.683449334" name="Keil 8051 Assembler" superClass="com.silabs.ide.si8051.keil.toolchain.assembler">
|
||||
<option id="com.silabs.ide.si8051.keil.assembler.category.symbols.def.677208820" name="Defined symbols (SET(...))" superClass="com.silabs.ide.si8051.keil.assembler.category.symbols.def"/>
|
||||
<option id="com.silabs.ide.si8051.keil.assembler.category.includes.paths.1772111840" name="Include paths (INCDIR(...))" superClass="com.silabs.ide.si8051.keil.assembler.category.includes.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc/config}""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usb/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_assert""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/EFM8UB1/peripheral_driver/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/shared/si8051base""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/EFM8UB1/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usbc/lib_kernel/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usbc/lib_usbc_pd/inc""/>
|
||||
</option>
|
||||
<inputType id="com.silabs.ide.si8051.keil.assembler.inputType.1712887970" superClass="com.silabs.ide.si8051.keil.assembler.inputType"/>
|
||||
</tool>
|
||||
<tool command="LX51" id="com.silabs.ide.si8051.keil.toolchain.linker.367126547" name="Keil 8051 Linker" superClass="com.silabs.ide.si8051.keil.toolchain.linker">
|
||||
<option id="com.silabs.ide.si8051.keil.linker.category.general.use_control_file.117123054" name="Use linker control file" superClass="com.silabs.ide.si8051.keil.linker.category.general.use_control_file" value="false" valueType="boolean"/>
|
||||
<option id="com.silabs.ide.si8051.keil.linker.category.ordering.selection.1520457668" name="Linker input ordering" superClass="com.silabs.ide.si8051.keil.linker.category.ordering.selection" value="./src/InitDevice.OBJ;./src/SILABS_STARTUP.OBJ;./src/callback.OBJ;./src/descriptors.OBJ;./src/main.OBJ;./src/printing.OBJ;./lib/efm8ub1/peripheralDrivers/src/usb_0.OBJ;./lib/efm8_usb/src/efm8_usbd.OBJ;./lib/efm8_usb/src/efm8_usbdch9.OBJ;./lib/efm8_usb/src/efm8_usbdep.OBJ;./lib/efm8_usb/src/efm8_usbdint.OBJ;./lib/efm8_assert/assert.OBJ" valueType="string"/>
|
||||
<inputType id="com.silabs.ide.si8051.keil.linker.inputType.320881486" superClass="com.silabs.ide.si8051.keil.linker.inputType"/>
|
||||
</tool>
|
||||
<tool id="com.silabs.ide.si8051.keil.toolchain.librarian.1238681544" name="Keil 8051 Library Manager" superClass="com.silabs.ide.si8051.keil.toolchain.librarian"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding=".git/objects/info|.git/objects/pack|.git/refs/tags|lib/c8051f320|lib/c8051f326|lib/c8051f340|lib/c8051f380|lib/efm8ub2|lib/efm8ub3|lib/efm8ub4|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.release#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.release#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0" moduleId="org.eclipse.cdt.core.settings" name="Keil 8051 v9.53 - Release">
|
||||
<macros>
|
||||
<stringMacro name="StudioSdkPath" type="VALUE_PATH_DIR" value="${StudioSdkPathFromID:com.silabs.sdk.8051:4.1.1._-963069327}"/>
|
||||
<stringMacro name="StudioToolchainPath" type="VALUE_PATH_DIR" value="${StudioToolchainPathFromID:com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0}"/>
|
||||
</macros>
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.HEX" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.tool.ide.c8051.debug.OMF2" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.EBL" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.GBL" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.tool.ide.c8051.debug.OMF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.BIN" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="com.silabs.ss.framework.debugger.core.S37" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.KeilErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule buildConfig.stockConfigId="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.release#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0" cppBuildConfig.builtinIncludes="studio:/sdk/Lib/efm8_usb/inc/ studio:/sdk/Lib/efm8_assert/ studio:/sdk/Device/EFM8UB1/peripheral_driver/inc/ studio:/sdk/Device/shared/si8051base/ studio:/sdk/Device/EFM8UB1/inc/ studio:/sdk/Lib/efm8_usbc/lib_kernel/inc/ studio:/sdk/Lib/efm8_usbc/lib_usbc_pd/inc/ studio:/sdk/Lib/efm8_usb/inc/ studio:/sdk/Lib/efm8_assert/ studio:/sdk/Device/EFM8UB1/peripheral_driver/inc/ studio:/sdk/Device/shared/si8051base/ studio:/sdk/Device/EFM8UB1/inc/ studio:/sdk/Lib/efm8_usbc/lib_kernel/inc/ studio:/sdk/Lib/efm8_usbc/lib_usbc_pd/inc/" cppBuildConfig.builtinLibraryFiles="" cppBuildConfig.builtinLibraryNames="" cppBuildConfig.builtinLibraryObjects="" cppBuildConfig.builtinLibraryPaths="" cppBuildConfig.builtinMacros="" moduleId="com.silabs.ss.framework.ide.project.core.cpp" projectCommon.referencedModules="[{"builtinExcludes":[],"builtinSources":[],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.si8051.external.efm8Library.usbc\"/>"},{"builtinExcludes":[],"builtinSources":["lib/efm8ub1/peripheralDrivers/src/usb_0.c","lib/efm8ub1/peripheralDrivers/inc/usb_0.h"],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.si8051.external.efm8PeripheralDriver.usb0\"/>"},{"builtinExcludes":[],"builtinSources":["lib/efm8_usb/inc/efm8_usb.h","lib/efm8_usb/src/efm8_usbd.c","lib/efm8_usb/src/efm8_usbdch9.c","lib/efm8_usb/src/efm8_usbdep.c","lib/efm8_usb/src/efm8_usbdint.c","lib/efm8_usb/Readme.txt"],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.si8051.external.efm8Library.usb\"/>"},{"builtinExcludes":[],"builtinSources":["lib/efm8_assert/assert.c","lib/efm8_assert/assert.h"],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.si8051.external.efm8Library.assert\"/>"},{"builtinExcludes":[],"builtinSources":["src/SILABS_STARTUP.A51"],"builtin":true,"module":"<project:MModule xmlns:project=\"http://www.silabs.com/ss/Project.ecore\" builtin=\"true\" id=\"com.silabs.sdk.si8051.shared\"/>"}]" projectCommon.toolchainId="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0"/>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="omf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.release#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0" name="Keil 8051 v9.53 - Release" parent="com.silabs.ide.si8051.keil.exe.default">
|
||||
<folderInfo id="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.release#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0." name="/" resourcePath="">
|
||||
<toolChain id="com.silabs.ide.si8051.keil.toolchain.exe.default.2049529147" name="Keil 8051" superClass="com.silabs.ide.si8051.keil.toolchain.exe.default">
|
||||
<option id="com.silabs.ide.si8051.keil.toolchain.category.general.debug.498309818" name="Generate debug information" superClass="com.silabs.ide.si8051.keil.toolchain.category.general.debug" value="true" valueType="boolean"/>
|
||||
<option id="com.silabs.ide.si8051.keil.toolchain.category.general.extended_assembler.1283846940" name="Use Extended Assembler (AX51) instead of A51" superClass="com.silabs.ide.si8051.keil.toolchain.category.general.extended_assembler" value="true" valueType="boolean"/>
|
||||
<option id="com.silabs.ide.si8051.keil.toolchain.category.general.extended_linker.146017776" name="Use Extended Linker (LX51) instead of BL51" superClass="com.silabs.ide.si8051.keil.toolchain.category.general.extended_linker" value="true" valueType="boolean"/>
|
||||
<option id="com.silabs.ide.si8051.keil.toolchain.category.general.memory_model.640114993" name="Memory model" superClass="com.silabs.ide.si8051.keil.toolchain.category.general.memory_model" value="com.silabs.ide.si8051.keil.toolchain.category.general.memory_model.small" valueType="enumerated"/>
|
||||
<targetPlatform binaryParser="com.silabs.ss.tool.ide.c8051.debug.OMF;com.silabs.ss.tool.ide.c8051.debug.OMF2;com.silabs.ss.framework.debugger.core.BIN;com.silabs.ss.framework.debugger.core.HEX;com.silabs.ss.framework.debugger.core.S37;com.silabs.ss.framework.debugger.core.EBL;com.silabs.ss.framework.debugger.core.GBL" id="com.silabs.ide.si8051.keil.targetplatform.690223176" isAbstract="false" superClass="com.silabs.ide.si8051.keil.targetplatform"/>
|
||||
<builder buildPath="${workspace_loc:/efm8}/Keil 8051 v9.53 - Release" id="com.silabs.ide.si8051.keil.builder.1329230955" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Keil Builder" parallelBuildOn="false" superClass="com.silabs.ide.si8051.keil.builder"/>
|
||||
<tool id="com.silabs.ide.si8051.keil.toolchain.compiler.1966285955" name="Keil 8051 Compiler" superClass="com.silabs.ide.si8051.keil.toolchain.compiler">
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.optimization.level.851586321" name="Level" superClass="com.silabs.ide.si8051.keil.compiler.category.optimization.level" value="com.silabs.ide.si8051.keil.compiler.category.optimization.level.9" valueType="enumerated"/>
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.symbols.def.497293805" name="Defined symbols (DEFINE(...))" superClass="com.silabs.ide.si8051.keil.compiler.category.symbols.def" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="NDEBUG=1"/>
|
||||
</option>
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.optimization.coloring.2036986310" name="Global register coloring" superClass="com.silabs.ide.si8051.keil.compiler.category.optimization.coloring" value="true" valueType="boolean"/>
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.optimization.emphasis.777114717" name="Emphasis" superClass="com.silabs.ide.si8051.keil.compiler.category.optimization.emphasis" value="com.silabs.ide.si8051.keil.compiler.category.optimization.emphasis.speed" valueType="enumerated"/>
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.includes.paths.882106026" name="Include paths (INCDIR(...))" superClass="com.silabs.ide.si8051.keil.compiler.category.includes.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc/config}""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usb/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_assert""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/EFM8UB1/peripheral_driver/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/shared/si8051base""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/EFM8UB1/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usbc/lib_kernel/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usbc/lib_usbc_pd/inc""/>
|
||||
</option>
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.misc.extraflags.1520964257" name="Additional Flags" superClass="com.silabs.ide.si8051.keil.compiler.category.misc.extraflags" value="OA" valueType="string"/>
|
||||
<option id="com.silabs.ide.si8051.keil.compiler.category.general.code.1101784529" name="Code size" superClass="com.silabs.ide.si8051.keil.compiler.category.general.code" value="com.silabs.ide.si8051.keil.compiler.category.general.code.large" valueType="enumerated"/>
|
||||
<inputType id="com.silabs.ide.si8051.keil.compiler.inputType.1366062481" superClass="com.silabs.ide.si8051.keil.compiler.inputType"/>
|
||||
</tool>
|
||||
<tool command="AX51" id="com.silabs.ide.si8051.keil.toolchain.assembler.862226894" name="Keil 8051 Assembler" superClass="com.silabs.ide.si8051.keil.toolchain.assembler">
|
||||
<option id="com.silabs.ide.si8051.keil.assembler.category.symbols.def.1379136974" name="Defined symbols (SET(...))" superClass="com.silabs.ide.si8051.keil.assembler.category.symbols.def" valueType="stringList">
|
||||
<listOptionValue builtIn="false" value="SILABS_STARTUP=1"/>
|
||||
</option>
|
||||
<option id="com.silabs.ide.si8051.keil.assembler.category.includes.paths.2327129" name="Include paths (INCDIR(...))" superClass="com.silabs.ide.si8051.keil.assembler.category.includes.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc/config}""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usb/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_assert""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/EFM8UB1/peripheral_driver/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/shared/si8051base""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Device/EFM8UB1/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usbc/lib_kernel/inc""/>
|
||||
<listOptionValue builtIn="false" value=""${StudioSdkPath}/Lib/efm8_usbc/lib_usbc_pd/inc""/>
|
||||
</option>
|
||||
<inputType id="com.silabs.ide.si8051.keil.assembler.inputType.1906467347" superClass="com.silabs.ide.si8051.keil.assembler.inputType"/>
|
||||
</tool>
|
||||
<tool command="LX51" id="com.silabs.ide.si8051.keil.toolchain.linker.1259644704" name="Keil 8051 Linker" superClass="com.silabs.ide.si8051.keil.toolchain.linker">
|
||||
<option id="com.silabs.ide.si8051.keil.linker.category.general.use_control_file.1886409616" name="Use linker control file" superClass="com.silabs.ide.si8051.keil.linker.category.general.use_control_file" value="true" valueType="boolean"/>
|
||||
<inputType id="com.silabs.ide.si8051.keil.linker.inputType.1526176751" superClass="com.silabs.ide.si8051.keil.linker.inputType"/>
|
||||
</tool>
|
||||
<tool id="com.silabs.ide.si8051.keil.toolchain.librarian.1609353969" name="Keil 8051 Library Manager" superClass="com.silabs.ide.si8051.keil.toolchain.librarian"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding=".git/objects/info|.git/objects/pack|.git/refs/tags|lib/c8051f320|lib/c8051f326|lib/c8051f340|lib/c8051f380|lib/efm8ub2|lib/efm8ub3|lib/efm8ub4|src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="com.silabs.ss.framework.ide.project.core.cpp" project.generation="41" projectCommon.boardIds="brd5000a:0.0.0.A02" projectCommon.buildArtifactType="EXE" projectCommon.importModeId="COPY" projectCommon.partId="mcu.8051.efm8.ub1.efm8ub10f16g-b-qfn28" projectCommon.sdkId="com.silabs.sdk.8051:4.1.1._-963069327"/>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="efm8.com.silabs.ss.framework.ide.project.core.cdt.cdtMbsProjectType.972220390" name="SLS CDT Project" projectType="com.silabs.ss.framework.ide.project.core.cdt.cdtMbsProjectType"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.debug#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0;com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.debug#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0.">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.silabs.ide.si8051.keil.KeilScannerInfoCollector"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.release#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0;com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt.release#com.silabs.ss.tool.ide.c8051.toolchain.keil.cdt:9.53.0.">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.silabs.ide.si8051.keil.KeilScannerInfoCollector"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
</cproject>
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>efm8</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>com.silabs.ss.framework.ide.project.sls.core.SLSProjectNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,2 @@
|
|||
copiedFilesOriginState={}
|
||||
eclipse.preferences.version=1
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0" encoding="ASCII"?>
|
||||
<device:XMLDevice xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:device="http://www.silabs.com/ss/hwconfig/document/device.ecore" name="EFM8UB10F16G-B-QFN28" partId="mcu.8051.efm8.ub1.efm8ub10f16g-b-qfn28" version="4.0.1" contextId="%DEFAULT%">
|
||||
<mode name="DefaultMode">
|
||||
<property object="CIP51_0" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="CIP51_0" propertyId="cip51.prefetchenginecontrol.enableprefetch" value="Enabled"/>
|
||||
<property object="CIP51_0" propertyId="cip51.prefetchenginecontrol.flashreadtiming" value="SYSCLK is below 50 MHz"/>
|
||||
<property object="CLOCK_0" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="CLOCK_0" propertyId="clock.clockselect.clocksourcedivider" value="SYSCLK / 1"/>
|
||||
<property object="CLOCK_0" propertyId="clock.clockselect.selectclocksource" value="Internal High Frequency Oscillator 1"/>
|
||||
<property object="CROSSBAR0" propertyId="xbar0.uart1.data" value="Enabled"/>
|
||||
<property object="DefaultMode" propertyId="mode.diagramLocation" value="100, 100"/>
|
||||
<property object="INTERRUPT_0" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="INTERRUPT_0" propertyId="interrupt.interruptenable.enableallinterrupts" value="Enabled"/>
|
||||
<property object="P0.0" propertyId="ports.settings.iomode" value="Digital Push-Pull Output"/>
|
||||
<property object="P0.0" propertyId="ports.settings.outputmode" value="Push-pull"/>
|
||||
<property object="PBCFG_0" propertyId="pbcfg.settings.enablecrossbar" value="Enabled"/>
|
||||
<property object="TIMER01_0" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="TIMER16_2" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="TIMER16_2" propertyId="timer16.control.clocksource" value="SYSCLK"/>
|
||||
<property object="TIMER16_2" propertyId="timer16.control.runcontrol" value="Start"/>
|
||||
<property object="TIMER16_2" propertyId="timer16.control.timerrunningstate" value="Timer is Running"/>
|
||||
<property object="TIMER16_2" propertyId="timer16.initandreloadvalue.targetoverflowfrequency" value="1000"/>
|
||||
<property object="TIMER16_2" propertyId="timer16.initandreloadvalue.timerreloadvalue" value="17536"/>
|
||||
<property object="TIMER16_2" propertyId="timer16.reloadhighbyte.reloadhighbyte" value="68"/>
|
||||
<property object="TIMER16_2" propertyId="timer16.reloadlowbyte.reloadlowbyte" value="128"/>
|
||||
<property object="TIMER16_3" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="TIMER16_3" propertyId="timer16.control.clocksource" value="SYSCLK"/>
|
||||
<property object="TIMER16_4" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="TIMER_SETUP_0" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="TIMER_SETUP_0" propertyId="timer_setup.clockcontrol.timer2lowbyteclockselect" value="Use SYSCLK"/>
|
||||
<property object="TIMER_SETUP_0" propertyId="timer_setup.clockcontrol.timer3lowbyteclockselect" value="Use SYSCLK"/>
|
||||
<property object="UARTE_1" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="UARTE_1" propertyId="uarte.baudrategeneratorcontrol.actualbaudrate" value="115384"/>
|
||||
<property object="UARTE_1" propertyId="uarte.baudrategeneratorcontrol.baudrateprescaler" value="Divide by 1"/>
|
||||
<property object="UARTE_1" propertyId="uarte.baudrategeneratorcontrol.baudratereloadhigh" value="255"/>
|
||||
<property object="UARTE_1" propertyId="uarte.baudrategeneratorcontrol.baudratereloadlow" value="48"/>
|
||||
<property object="UARTE_1" propertyId="uarte.baudrategeneratorcontrol.enablebaudrategenerator" value="Enabled"/>
|
||||
<property object="UARTE_1" propertyId="uarte.baudrategeneratorcontrol.expectedbaudrate" value="115200"/>
|
||||
<property object="UARTE_1" propertyId="uarte.serialportcontrol.enablereceive" value="Enabled"/>
|
||||
<property object="UART_0" propertyId="uart.serialportcontrol.actualbaudrate" value="93750 Baud"/>
|
||||
<property object="UART_0" propertyId="uart.serialportcontrol.timer1overflowfrequency" value="187.500 kHz"/>
|
||||
<property object="USBLIB_0" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="USBLIB_0" propertyId="configuration.configurationparameters.configurationstring" value="conf"/>
|
||||
<property object="USBLIB_0" propertyId="configuration.configurationparameters.devicepower" value="Bus-Powered"/>
|
||||
<property object="USBLIB_0" propertyId="device.deviceproperties.bmaxpacketsize" value="64"/>
|
||||
<property object="USBLIB_0" propertyId="device.deviceproperties.productidpid" value="35535"/>
|
||||
<property object="USBLIB_0" propertyId="device.deviceproperties.productstring" value="EOS Wallet"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1in.bulkmaxpacketsizebytes" value="64"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1in.endpoint1in" value="Enabled"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1in.maxpacketsizebytes" value="64"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1in.pollingintervalms" value="5"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1in.transfertype" value="Interrupt"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1out.endpoint1out" value="Enabled"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1out.maxpacketsizebytes" value="64"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1out.pollingintervalms" value="5"/>
|
||||
<property object="USBLIB_0" propertyId="endpoints.endpoint1out.transfertype" value="Interrupt"/>
|
||||
<property object="USBLIB_0" propertyId="interfaces.interface0.interfaceclass" value="HID (Human Interface Device)"/>
|
||||
<property object="USBLIB_0" propertyId="library.callbackfunctions.resetcallback" value="Enabled"/>
|
||||
<property object="USBLIB_0" propertyId="library.callbackfunctions.selfpoweredcallback" value="Enabled"/>
|
||||
<property object="USBLIB_0" propertyId="library.callbackfunctions.setupcommandcallback" value="Enabled"/>
|
||||
<property object="USBLIB_0" propertyId="library.callbackfunctions.statechangecallback" value="Enabled"/>
|
||||
<property object="USBLIB_0" propertyId="library.libraryconfiguration.clockrecovery" value="Enabled"/>
|
||||
<property object="VREG_0" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="WDT_0" propertyId="ABPeripheral.included" value="true"/>
|
||||
<property object="WDT_0" propertyId="wdt.watchdogcontrol.wdtenable" value="Disable"/>
|
||||
</mode>
|
||||
<modeTransition>
|
||||
<property object="RESET → DefaultMode" propertyId="modeTransition.source" value="RESET"/>
|
||||
<property object="RESET → DefaultMode" propertyId="modeTransition.target" value="DefaultMode"/>
|
||||
</modeTransition>
|
||||
</device:XMLDevice>
|
|
@ -0,0 +1,33 @@
|
|||
//=========================================================
|
||||
// inc/InitDevice.h: generated by Hardware Configurator
|
||||
//
|
||||
// This file will be regenerated when saving a document.
|
||||
// leave the sections inside the "$[...]" comment tags alone
|
||||
// or they will be overwritten!
|
||||
//=========================================================
|
||||
#ifndef __INIT_DEVICE_H__
|
||||
#define __INIT_DEVICE_H__
|
||||
|
||||
// USER CONSTANTS
|
||||
// USER PROTOTYPES
|
||||
|
||||
// $[Mode Transition Prototypes]
|
||||
extern void enter_DefaultMode_from_RESET(void);
|
||||
// [Mode Transition Prototypes]$
|
||||
|
||||
// $[Config(Per-Module Mode)Transition Prototypes]
|
||||
extern void WDT_0_enter_DefaultMode_from_RESET(void);
|
||||
extern void PORTS_0_enter_DefaultMode_from_RESET(void);
|
||||
extern void PBCFG_0_enter_DefaultMode_from_RESET(void);
|
||||
extern void CIP51_0_enter_DefaultMode_from_RESET(void);
|
||||
extern void CLOCK_0_enter_DefaultMode_from_RESET(void);
|
||||
extern void TIMER16_2_enter_DefaultMode_from_RESET(void);
|
||||
extern void TIMER16_3_enter_DefaultMode_from_RESET(void);
|
||||
extern void TIMER_SETUP_0_enter_DefaultMode_from_RESET(void);
|
||||
extern void UARTE_1_enter_DefaultMode_from_RESET(void);
|
||||
extern void INTERRUPT_0_enter_DefaultMode_from_RESET(void);
|
||||
extern void USBLIB_0_enter_DefaultMode_from_RESET(void);
|
||||
// [Config(Per-Module Mode)Transition Prototypes]$
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* app.h
|
||||
*
|
||||
* Created on: Jun 25, 2018
|
||||
* Author: conor
|
||||
*/
|
||||
|
||||
#ifndef INC_APP_H_
|
||||
#define INC_APP_H_
|
||||
|
||||
#define USE_PRINTING
|
||||
|
||||
#endif /* INC_APP_H_ */
|
|
@ -0,0 +1,157 @@
|
|||
/*******************************************************************************
|
||||
* @file usbconfig.h
|
||||
* @brief USB protocol stack library, application supplied configuration options.
|
||||
*******************************************************************************/
|
||||
|
||||
//=============================================================================
|
||||
// inc/config/usbconfig.h: generated by Hardware Configurator
|
||||
//
|
||||
// This file will be regenerated when saving a document. leave the sections
|
||||
// inside the "$[...]" comment tags alone or they will be overwritten!
|
||||
//=============================================================================
|
||||
#ifndef __SILICON_LABS_USBCONFIG_H
|
||||
#define __SILICON_LABS_USBCONFIG_H
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Specify bus- or self-powered
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[Device Power]
|
||||
#define SLAB_USB_BUS_POWERED 1
|
||||
// [Device Power]$
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Specify USB speed
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[USB Speed]
|
||||
#define SLAB_USB_FULL_SPEED 1
|
||||
// [USB Speed]$
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Enable or disable the clock recovery
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[Clock Recovery]
|
||||
#define SLAB_USB_CLOCK_RECOVERY_ENABLED 1
|
||||
// [Clock Recovery]$
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Enable or disable remote wakeup
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[Remote Wake-up]
|
||||
#define SLAB_USB_REMOTE_WAKEUP_ENABLED 0
|
||||
// [Remote Wake-up]$
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Specify number of interfaces and whether any interfaces support alternate
|
||||
// settings
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[Number of Interfaces]
|
||||
#define SLAB_USB_NUM_INTERFACES 1
|
||||
#define SLAB_USB_SUPPORT_ALT_INTERFACES 0
|
||||
// [Number of Interfaces]$
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Enable or disable each endpoint
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[Endpoints Used]
|
||||
#define SLAB_USB_EP1IN_USED 1
|
||||
#define SLAB_USB_EP1OUT_USED 1
|
||||
#define SLAB_USB_EP2IN_USED 0
|
||||
#define SLAB_USB_EP2OUT_USED 0
|
||||
#define SLAB_USB_EP3IN_USED 0
|
||||
#define SLAB_USB_EP3OUT_USED 0
|
||||
// [Endpoints Used]$
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Specify maximum packet size for each endpoint
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[Endpoint Max Packet Size]
|
||||
#define SLAB_USB_EP1IN_MAX_PACKET_SIZE 64
|
||||
#define SLAB_USB_EP1OUT_MAX_PACKET_SIZE 64
|
||||
#define SLAB_USB_EP2IN_MAX_PACKET_SIZE 1
|
||||
#define SLAB_USB_EP2OUT_MAX_PACKET_SIZE 1
|
||||
#define SLAB_USB_EP3IN_MAX_PACKET_SIZE 1
|
||||
#define SLAB_USB_EP3OUT_MAX_PACKET_SIZE 1
|
||||
// [Endpoint Max Packet Size]$
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Specify transfer type of each endpoint
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[Endpoint Transfer Type]
|
||||
#define SLAB_USB_EP1IN_TRANSFER_TYPE USB_EPTYPE_INTR
|
||||
#define SLAB_USB_EP1OUT_TRANSFER_TYPE USB_EPTYPE_INTR
|
||||
#define SLAB_USB_EP2IN_TRANSFER_TYPE USB_EPTYPE_BULK
|
||||
#define SLAB_USB_EP2OUT_TRANSFER_TYPE USB_EPTYPE_BULK
|
||||
#define SLAB_USB_EP3IN_TRANSFER_TYPE USB_EPTYPE_ISOC
|
||||
#define SLAB_USB_EP3OUT_TRANSFER_TYPE USB_EPTYPE_ISOC
|
||||
// [Endpoint Transfer Type]$
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Enable or disable callback functions
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[Callback Functions]
|
||||
#define SLAB_USB_HANDLER_CB 0
|
||||
#define SLAB_USB_IS_SELF_POWERED_CB 1
|
||||
#define SLAB_USB_RESET_CB 1
|
||||
#define SLAB_USB_SETUP_CMD_CB 1
|
||||
#define SLAB_USB_SOF_CB 0
|
||||
#define SLAB_USB_STATE_CHANGE_CB 1
|
||||
// [Callback Functions]$
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Specify number of languages supported by string descriptors.
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[Number of Languages]
|
||||
#define SLAB_USB_NUM_LANGUAGES 1
|
||||
// [Number of Languages]$
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// If only one descriptor language is supported, specify that language here.
|
||||
// If multiple descriptor languages are supported, this value is ignored and
|
||||
// the supported languages must listed in the
|
||||
// myUsbStringTableLanguageIDsDescriptor structure.
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[USB Language]
|
||||
#define SLAB_USB_LANGUAGE USB_LANGID_ENUS
|
||||
// [USB Language]$
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
//
|
||||
// Set the power saving mode
|
||||
//
|
||||
// SLAB_USB_PWRSAVE_MODE configures when the device will automatically enter
|
||||
// the USB power-save mode. It is a bitmask constant with bit values:
|
||||
// USB_PWRSAVE_MODE_OFF - No energy saving mode selected
|
||||
// USB_PWRSAVE_MODE_ONSUSPEND - Enter USB power-save mode on USB suspend
|
||||
// USB_PWRSAVE_MODE_ONVBUSOFF - Enter USB power-save mode when not attached
|
||||
// to the USB host.
|
||||
// USB_PWRSAVE_MODE_FASTWAKE - Exit USB power-save mode more quickly, but
|
||||
// consume more power while in USB power-save
|
||||
// mode.
|
||||
// While the device is in USB power-save mode
|
||||
// (typically during USB suspend), the
|
||||
// internal voltage regulator stays in normal
|
||||
// power mode instead of entering suspend
|
||||
// power mode.
|
||||
// This is an advanced feature that may be
|
||||
// useful in certain applications that support
|
||||
// remote wakeup.
|
||||
//
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[Power Save Mode]
|
||||
#define SLAB_USB_PWRSAVE_MODE USB_PWRSAVE_MODE_OFF
|
||||
// [Power Save Mode]$
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Enable or disable polled mode
|
||||
//
|
||||
// When enabled, the application must call USBD_Run() periodically to process
|
||||
// USB events.
|
||||
// When disabled, USB events will be handled automatically by an interrupt
|
||||
// handler.
|
||||
// -----------------------------------------------------------------------------
|
||||
// $[Polled Mode]
|
||||
#define SLAB_USB_POLLED_MODE 0
|
||||
// [Polled Mode]$
|
||||
|
||||
#endif // __SILICON_LABS_USBCONFIG_H
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*******************************************************************************
|
||||
* @file descriptors.h
|
||||
* @brief USB descriptors header file.
|
||||
*******************************************************************************/
|
||||
|
||||
//=============================================================================
|
||||
// inc/descriptors.h: generated by Hardware Configurator
|
||||
//
|
||||
// This file will be regenerated when saving a document. leave the sections
|
||||
// inside the "$[...]" comment tags alone or they will be overwritten!
|
||||
//=============================================================================
|
||||
#ifndef __SILICON_LABS_DESCRIPTORS_H
|
||||
#define __SILICON_LABS_DESCRIPTORS_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <si_toolchain.h>
|
||||
#include <endian.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <efm8_usb.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// -------------------- USB Identification ------------------------------------
|
||||
//
|
||||
// **********
|
||||
// NOTE: YOU MUST PROVIDE YOUR OWN USB VID/PID (below)
|
||||
// **********
|
||||
//
|
||||
// Following are the definition of the USB VID and PID. These are, by default,
|
||||
// values that are assigned to Silicon Labs. These values are provided merely
|
||||
// as an example. You may not use the Silicon Labs VID/PID values in your
|
||||
// product. You must provide your own assigned VID and PID values.
|
||||
//-----------------------------------------------------------------------------
|
||||
// $[Vendor ID]
|
||||
#define USB_VENDOR_ID htole16(0x10c4)
|
||||
// [Vendor ID]$
|
||||
|
||||
// $[Product ID]
|
||||
#define USB_PRODUCT_ID htole16(0x8acf)
|
||||
// [Product ID]$
|
||||
|
||||
extern SI_SEGMENT_VARIABLE(ReportDescriptor0[34], const uint8_t, SI_SEG_CODE);
|
||||
|
||||
extern SI_SEGMENT_VARIABLE(deviceDesc[], const USB_DeviceDescriptor_TypeDef, SI_SEG_CODE);
|
||||
extern SI_SEGMENT_VARIABLE(configDesc[], const uint8_t, SI_SEG_CODE);
|
||||
extern SI_SEGMENT_VARIABLE(initstruct, const USBD_Init_TypeDef, SI_SEG_CODE);
|
||||
|
||||
#define HID_PACKET_SIZE 64
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __SILICON_LABS_DESCRIPTORS_H
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Conor Patrick
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef PRINTING_H_
|
||||
#define PRINTING_H_
|
||||
|
||||
#include <SI_EFM8UB1_Register_Enums.h>
|
||||
#include <efm8_usb.h>
|
||||
#include <stdint.h>
|
||||
#include "app.h"
|
||||
|
||||
#define watchdog() (WDTCN = 0xA5)
|
||||
|
||||
#define reboot() (RSTSRC = 1 << 4)
|
||||
|
||||
void u2f_delay(uint32_t ms);
|
||||
|
||||
void usb_write(uint8_t* buf, uint8_t len);
|
||||
|
||||
|
||||
|
||||
#ifdef USE_PRINTING
|
||||
|
||||
void dump_hex(uint8_t* hex, uint8_t len);
|
||||
|
||||
void cputd(uint32_t i);
|
||||
void cputx(uint32_t i);
|
||||
|
||||
#define cputb(x) cputx((uint8_t) (x))
|
||||
#define cputl(x) cputd((uint32_t) (x))
|
||||
#define cputlx(x) cputx((uint32_t) (x))
|
||||
|
||||
void cprints(const char * str);
|
||||
void cprintb(const char * tag, uint8_t c, ...);
|
||||
void cprintd(const char * tag, uint8_t c, ...);
|
||||
void cprintx(const char * tag, uint8_t c, ...);
|
||||
void cprintl(const char * tag, uint8_t c, ...);
|
||||
void cprintlx(const char * tag, uint8_t c, ...);
|
||||
|
||||
#else
|
||||
|
||||
#define cprintx(x)
|
||||
#define cprintb(x)
|
||||
#define cprintlx(x)
|
||||
#define cprintl(x)
|
||||
#define cprintd(x)
|
||||
#define cprints(x)
|
||||
|
||||
#define cputx(x)
|
||||
#define cputb(x)
|
||||
#define cputl(x)
|
||||
#define cputlx(x)
|
||||
|
||||
#define putf(x)
|
||||
#define dump_hex(x)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* BSP_H_ */
|
|
@ -0,0 +1,12 @@
|
|||
/**************************************************************************//**
|
||||
* Copyright (c) 2015 by Silicon Laboratories Inc. All rights reserved.
|
||||
*
|
||||
* http://developer.silabs.com/legal/version/v11/Silicon_Labs_Software_License_Agreement.txt
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef NDEBUG
|
||||
void slab_Assert()
|
||||
{
|
||||
while ( 1 );
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,60 @@
|
|||
/******************************************************************************
|
||||
* Copyright (c) 2014 by Silicon Laboratories Inc. All rights reserved.
|
||||
*
|
||||
* http://developer.silabs.com/legal/version/v11/Silicon_Labs_Software_License_Agreement.txt
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef __ASSERT_H__
|
||||
|
||||
#include "efm8_config.h"
|
||||
|
||||
/**************************************************************************//**
|
||||
* @addtogroup efm8_assert
|
||||
* @{
|
||||
*
|
||||
* @brief Runtime assert for EFM8
|
||||
*
|
||||
* This module contains a runtime assert macro. It can be compiled out by setting
|
||||
* the NDEBUG flag.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
/**************************************************************************//**
|
||||
* @def NDEBUG
|
||||
* @brief Controls if the asserts are present.
|
||||
*
|
||||
* Asserts are removed if this symbol is defined
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/**************************************************************************//**
|
||||
* @def USER_ASSERT
|
||||
* @brief User implemented assert function.
|
||||
*
|
||||
* When asserts are enabled the default handler can be be replaced with a user defined
|
||||
* function of the form 'void userAssertName( const char * file, int line )' by setting
|
||||
* the value of USER_ASSERT to the userAssertName.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
/**************************************************************************//**
|
||||
* @def SLAB_ASSERT(expr)
|
||||
* @brief default implementation of assert_failed.
|
||||
*
|
||||
* This function can be replaced by a user defined assert function by setting the USER_ASSERT flag
|
||||
*****************************************************************************/
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define SLAB_ASSERT(expr)
|
||||
#else
|
||||
#ifdef USER_ASSERT
|
||||
#define SLAB_ASSERT(expr) ((expr) ? ((void)0) : USER_ASSERT( __FILE__, __LINE__ ))
|
||||
#else
|
||||
void slab_Assert();
|
||||
//Yes this is smaller than if(!expr){assert}
|
||||
#define SLAB_ASSERT(expr) if(expr){}else{slab_Assert();}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif //!__ASSERT_H__
|
|
@ -0,0 +1,63 @@
|
|||
-------------------------------------------------------------------------------
|
||||
Readme.txt
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Copyright 2014 Silicon Laboratories, Inc.
|
||||
http://developer.silabs.com/legal/version/v11/Silicon_Labs_Software_License_Agreement.txt
|
||||
|
||||
Program Description:
|
||||
-------------------
|
||||
|
||||
This is the generic EFM8 USB Firmware Library. Please see the EFM8 Libraries
|
||||
Documentation for more information (/doc/EFM8/software/Lib/index.html).
|
||||
|
||||
Known Issues and Limitations:
|
||||
----------------------------
|
||||
|
||||
1) The library does not reset its Data Toggle after receiving a SET_INTERFACE
|
||||
request.
|
||||
|
||||
Target and Tool Chain Information:
|
||||
---------------------------------
|
||||
|
||||
Target: EFM8UB1, EFM8UB2, EFM8UB3, EFM8UB4, C8051F320/1, C8051F326/7, C8051F34x, C8051F38x
|
||||
Tool chain: Keil
|
||||
|
||||
File List:
|
||||
---------
|
||||
|
||||
/inc/efm8_usb.h
|
||||
/src/efm8_usbd.c
|
||||
/src/efm8_usbdch9.c
|
||||
/src/efm8_usbdep.c
|
||||
/src/efm8_usbdint.c
|
||||
|
||||
Release Information:
|
||||
-------------------
|
||||
|
||||
Version 1.0.0
|
||||
- Initial release.
|
||||
|
||||
Version 1.0.1
|
||||
- Fixed bug in logic of remote wakeup feature where the device would
|
||||
attempt to wake the host before enabling its USB transceiver.
|
||||
- Fixed bug where the device would stall the Data Phase instead of the
|
||||
Setup Phase when sending a procedural stall on Endpoint 0.
|
||||
- Fixed bug where a bus-powered device would look at VBUS after a USB Reset
|
||||
to determine if it should enter the Default or Attached State. VBUS is
|
||||
always present on a bus-powered device, so it should automatically enter
|
||||
the Default State.
|
||||
- Removed code that generated a compiler warning when
|
||||
USB_PWRSAVE_MODE_FASTWAKE was enabled.
|
||||
- Improved documentation of USB_PWRSAVE_MODE_FASTWAKE feature.
|
||||
|
||||
Version 1.0.2
|
||||
- Added ability to detect short OUT packet in Isochronous mode and
|
||||
stuff the buffer with zeroes to keep isochronous stream in sync.
|
||||
|
||||
Version 1.0.3
|
||||
- Added support for EFM8UB3 and EFM8UB4 devices.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
End Of File
|
||||
-------------------------------------------------------------------------------
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,780 @@
|
|||
/**************************************************************************//**
|
||||
* Copyright (c) 2015 by Silicon Laboratories Inc. All rights reserved.
|
||||
*
|
||||
* http://developer.silabs.com/legal/version/v11/Silicon_Labs_Software_License_Agreement.txt
|
||||
*****************************************************************************/
|
||||
|
||||
#include "si_toolchain.h"
|
||||
#include "efm8_usb.h"
|
||||
#include "assert.h"
|
||||
#include <stdint.h>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Global Variables
|
||||
|
||||
/// Tracks the state of the USB device and endpoints and contains pointers
|
||||
/// to all descriptors.
|
||||
SI_SEGMENT_VARIABLE(myUsbDevice, USBD_Device_TypeDef, MEM_MODEL_SEG);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Macros
|
||||
|
||||
/// Returns the requested endpoint object of type USBD_Ep_TypeDef
|
||||
/// This macro does not check that epAddr is valid, so the calling function
|
||||
/// should verify epAddr before using the macro.
|
||||
#define GetEp(epAddr) (&myUsbDevice.ep0 + epAddr)
|
||||
|
||||
|
||||
#if SLAB_USB_POLLED_MODE
|
||||
#define DISABLE_USB_INTS {}
|
||||
#define ENABLE_USB_INTS {}
|
||||
|
||||
#else
|
||||
/// Saves the current state of the USB Interrupt Enable to a variable called
|
||||
/// usbIntsEnabled, then disables USB interrupts.
|
||||
#define DISABLE_USB_INTS { usbIntsEnabled = USB_GetIntsEnabled(); USB_DisableInts(); }
|
||||
|
||||
/// Sets the USB Interrupt Enable bit to the value of usbIntsEnabled.
|
||||
/// @ref DISABLE_USB_INTS must be used before this macro is used.
|
||||
#define ENABLE_USB_INTS { if (usbIntsEnabled) {USB_EnableInts(); } }
|
||||
#endif // SLAB_USB_POLLED_MODE
|
||||
|
||||
// Function in efm8_usbdint.c to force load the module for libraries
|
||||
extern void forceModuleLoad_usbint(void);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// USB API Functions
|
||||
|
||||
void USBD_AbortAllTransfers(void)
|
||||
{
|
||||
uint8_t i;
|
||||
bool usbIntsEnabled;
|
||||
|
||||
USB_SaveSfrPage();
|
||||
DISABLE_USB_INTS;
|
||||
|
||||
// Call USBD_AbortTransfer() for each endpoint
|
||||
for (i = 1; i < SLAB_USB_NUM_EPS_USED; i++)
|
||||
{
|
||||
USBD_AbortTransfer(i);
|
||||
}
|
||||
|
||||
ENABLE_USB_INTS;
|
||||
USB_RestoreSfrPage();
|
||||
}
|
||||
|
||||
int8_t USBD_AbortTransfer(uint8_t epAddr)
|
||||
{
|
||||
SI_VARIABLE_SEGMENT_POINTER(ep, USBD_Ep_TypeDef, MEM_MODEL_SEG);
|
||||
int8_t retVal = USB_STATUS_OK;
|
||||
bool usbIntsEnabled;
|
||||
|
||||
USB_SaveSfrPage();
|
||||
|
||||
// Verify this is a valid endpoint address and is not Endpoint 0.
|
||||
if ((epAddr == EP0) || (epAddr >= SLAB_USB_NUM_EPS_USED))
|
||||
{
|
||||
SLAB_ASSERT(false);
|
||||
retVal = USB_STATUS_ILLEGAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
DISABLE_USB_INTS;
|
||||
ep = GetEp(epAddr);
|
||||
|
||||
// If the state of the endpoint is already idle, there is not need to abort
|
||||
// a transfer
|
||||
if (ep->state != D_EP_IDLE)
|
||||
{
|
||||
switch (epAddr)
|
||||
{
|
||||
#if SLAB_USB_EP1IN_USED
|
||||
case EP1IN:
|
||||
USB_AbortInEp(1);
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP2IN_USED
|
||||
case EP2IN:
|
||||
USB_AbortInEp(2);
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP3IN_USED
|
||||
case EP3IN:
|
||||
USB_AbortInEp(3);
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP1OUT_USED
|
||||
case EP1OUT:
|
||||
USB_AbortOutEp(1);
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP2OUT_USED
|
||||
case EP2OUT:
|
||||
USB_AbortOutEp(2);
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP3OUT_USED
|
||||
case EP3OUT:
|
||||
USB_AbortOutEp(3);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set the endpoint state to idle and clear out endpoint state variables
|
||||
ep->state = D_EP_IDLE;
|
||||
ep->misc.c = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ENABLE_USB_INTS;
|
||||
USB_RestoreSfrPage();
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void USBD_Connect(void)
|
||||
{
|
||||
USB_SaveSfrPage();
|
||||
myUsbDevice.ep0.state = D_EP_IDLE;
|
||||
USB_EnablePullUpResistor();
|
||||
USB_EnableTransceiver();
|
||||
USB_RestoreSfrPage();
|
||||
}
|
||||
|
||||
void USBD_Disconnect(void)
|
||||
{
|
||||
USB_SaveSfrPage();
|
||||
USB_DisablePullUpResistor();
|
||||
USB_RestoreSfrPage();
|
||||
}
|
||||
|
||||
bool USBD_EpIsBusy(uint8_t epAddr)
|
||||
{
|
||||
SI_VARIABLE_SEGMENT_POINTER(ep, USBD_Ep_TypeDef, MEM_MODEL_SEG);
|
||||
|
||||
// Verify this is a valid endpoint address
|
||||
if (epAddr >= SLAB_USB_NUM_EPS_USED)
|
||||
{
|
||||
SLAB_ASSERT(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
ep = GetEp(epAddr);
|
||||
|
||||
if (ep->state == D_EP_IDLE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
USBD_State_TypeDef USBD_GetUsbState(void)
|
||||
{
|
||||
return myUsbDevice.state;
|
||||
}
|
||||
|
||||
int8_t USBD_Init(SI_VARIABLE_SEGMENT_POINTER(p, const USBD_Init_TypeDef, SI_SEG_GENERIC))
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
USB_SaveSfrPage();
|
||||
USB_DisableInts();
|
||||
|
||||
// This forces the liner to bring in the contents efm8_usbdint
|
||||
// It is place here since all users MUST call this function
|
||||
// for the library to work properly
|
||||
forceModuleLoad_usbint();
|
||||
|
||||
|
||||
// Zero out the myUsbDevice struct, then initialize all non-zero members
|
||||
for (i = 0; i < sizeof(myUsbDevice); i++)
|
||||
{
|
||||
*((SI_VARIABLE_SEGMENT_POINTER(, uint8_t, MEM_MODEL_SEG))&myUsbDevice + i) = 0;
|
||||
}
|
||||
|
||||
// Get the USB descriptors from p
|
||||
myUsbDevice.deviceDescriptor = p->deviceDescriptor;
|
||||
myUsbDevice.configDescriptor = p->configDescriptor;
|
||||
myUsbDevice.stringDescriptors = p->stringDescriptors;
|
||||
myUsbDevice.numberOfStrings = p->numberOfStrings;
|
||||
|
||||
// Enable USB clock
|
||||
#if SLAB_USB_FULL_SPEED
|
||||
USB_SetClockIntOsc();
|
||||
USB_SelectFullSpeed();
|
||||
#else
|
||||
USB_SetClockIntOscDiv8();
|
||||
USB_SelectLowSpeed();
|
||||
#endif // SLAB_USB_FULL_SPEED
|
||||
|
||||
// Enable or disable VBUS detection
|
||||
#if SLAB_USB_BUS_POWERED
|
||||
USB_VbusDetectDisable();
|
||||
#else
|
||||
USB_VbusDetectEnable();
|
||||
#endif
|
||||
|
||||
USB_ForceReset();
|
||||
USB_EnableDeviceInts();
|
||||
USBD_Connect();
|
||||
|
||||
// If VBUS is present, the state should be Default.
|
||||
// Otherwise, it is Attached.
|
||||
#if SLAB_USB_BUS_POWERED
|
||||
myUsbDevice.state = USBD_STATE_DEFAULT;
|
||||
#else
|
||||
if (USB_IsVbusOn())
|
||||
{
|
||||
myUsbDevice.state = USBD_STATE_DEFAULT;
|
||||
}
|
||||
else
|
||||
{
|
||||
myUsbDevice.state = USBD_STATE_ATTACHED;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Only enable USB interrupts when not in polled mode
|
||||
#if (SLAB_USB_POLLED_MODE == 0)
|
||||
USB_EnableInts();
|
||||
#endif
|
||||
|
||||
USB_RestoreSfrPage();
|
||||
USB_DisableInhibit();
|
||||
|
||||
return USB_STATUS_OK;
|
||||
}
|
||||
|
||||
int8_t USBD_Read(uint8_t epAddr,
|
||||
SI_VARIABLE_SEGMENT_POINTER(dat, uint8_t, SI_SEG_GENERIC),
|
||||
uint16_t byteCount,
|
||||
bool callback)
|
||||
{
|
||||
bool usbIntsEnabled;
|
||||
SI_VARIABLE_SEGMENT_POINTER(ep, USBD_Ep_TypeDef, MEM_MODEL_SEG);
|
||||
|
||||
USB_SaveSfrPage();
|
||||
|
||||
// Verify the endpoint address is valid.
|
||||
switch (epAddr)
|
||||
{
|
||||
case EP0:
|
||||
#if SLAB_USB_EP1OUT_USED
|
||||
case EP1OUT:
|
||||
#endif
|
||||
#if SLAB_USB_EP2OUT_USED
|
||||
case EP2OUT:
|
||||
#endif
|
||||
#if SLAB_USB_EP3OUT_USED
|
||||
case EP3OUT:
|
||||
#endif
|
||||
break;
|
||||
#if SLAB_USB_EP1IN_USED
|
||||
case EP1IN:
|
||||
#endif
|
||||
#if SLAB_USB_EP2IN_USED
|
||||
case EP2IN:
|
||||
#endif
|
||||
#if SLAB_USB_EP3IN_USED
|
||||
case EP3IN:
|
||||
#endif
|
||||
default:
|
||||
SLAB_ASSERT(false);
|
||||
return USB_STATUS_ILLEGAL;
|
||||
}
|
||||
|
||||
// If the device has not been configured, we cannot start a transfer.
|
||||
if ((epAddr != EP0) && (myUsbDevice.state != USBD_STATE_CONFIGURED))
|
||||
{
|
||||
return USB_STATUS_DEVICE_UNCONFIGURED;
|
||||
}
|
||||
|
||||
ep = GetEp(epAddr);
|
||||
|
||||
// If the endpoint is not idle, we cannot start a new transfer.
|
||||
// Return the appropriate error code.
|
||||
if (ep->state != D_EP_IDLE)
|
||||
{
|
||||
if (ep->state == D_EP_STALL)
|
||||
{
|
||||
return USB_STATUS_EP_STALLED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return USB_STATUS_EP_BUSY;
|
||||
}
|
||||
}
|
||||
|
||||
DISABLE_USB_INTS;
|
||||
|
||||
ep->buf = dat;
|
||||
ep->remaining = byteCount;
|
||||
ep->state = D_EP_RECEIVING;
|
||||
ep->misc.bits.callback = callback;
|
||||
ep->misc.bits.waitForRead = false;
|
||||
|
||||
// If isochronous, set the buffer index to 0
|
||||
#if ((SLAB_USB_EP3OUT_USED) && (SLAB_USB_EP3OUT_TRANSFER_TYPE == USB_EPTYPE_ISOC))
|
||||
if (epAddr == EP3OUT)
|
||||
{
|
||||
myUsbDevice.ep3outIsoIdx = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
ENABLE_USB_INTS;
|
||||
USB_RestoreSfrPage();
|
||||
|
||||
return USB_STATUS_OK;
|
||||
}
|
||||
|
||||
#if SLAB_USB_REMOTE_WAKEUP_ENABLED
|
||||
int8_t USBD_RemoteWakeup(void)
|
||||
{
|
||||
// The device must be suspended and Remote Wakeup must have been previously
|
||||
// configured with a SET_FEATURE (Remote Wakeup) command.
|
||||
if ((myUsbDevice.state != USBD_STATE_SUSPENDED) ||
|
||||
(myUsbDevice.remoteWakeupEnabled == false))
|
||||
{
|
||||
return USB_STATUS_ILLEGAL;
|
||||
}
|
||||
|
||||
USB_ForceResume();
|
||||
USBD_RemoteWakeupDelay(); // Application will provide the delay between
|
||||
// starting and stopping the resume signal.
|
||||
USB_ClearResume();
|
||||
|
||||
return USB_STATUS_OK;
|
||||
}
|
||||
#endif // SLAB_USB_REMOTE_WAKEUP_ENABLED
|
||||
|
||||
#if SLAB_USB_POLLED_MODE
|
||||
void USBD_Run(void)
|
||||
{
|
||||
usbIrqHandler();
|
||||
}
|
||||
#endif // SLAB_USB_POLLED_MODE
|
||||
|
||||
int8_t USBD_StallEp(uint8_t epAddr)
|
||||
{
|
||||
bool usbIntsEnabled;
|
||||
|
||||
USB_SaveSfrPage();
|
||||
|
||||
// Verify the endpoint address is valid and not Endpoint 0.
|
||||
if ((epAddr == EP0) || (epAddr >= SLAB_USB_NUM_EPS_USED))
|
||||
{
|
||||
SLAB_ASSERT(false);
|
||||
return USB_STATUS_ILLEGAL;
|
||||
}
|
||||
|
||||
DISABLE_USB_INTS;
|
||||
|
||||
// Halt the appropriate endpoint by sending a stall and setting the endpoint
|
||||
// state to Halted (D_EP_HALT).
|
||||
switch (epAddr)
|
||||
{
|
||||
#if SLAB_USB_EP1IN_USED
|
||||
case (EP1IN):
|
||||
myUsbDevice.ep1in.state = D_EP_HALT;
|
||||
USB_SetIndex(1);
|
||||
USB_EpnInStall();
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP2IN_USED
|
||||
case (EP2IN):
|
||||
myUsbDevice.ep2in.state = D_EP_HALT;
|
||||
USB_SetIndex(2);
|
||||
USB_EpnInStall();
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP3IN_USED
|
||||
case (EP3IN):
|
||||
myUsbDevice.ep3in.state = D_EP_HALT;
|
||||
USB_SetIndex(3);
|
||||
USB_EpnInStall();
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP1OUT_USED
|
||||
case (EP1OUT):
|
||||
myUsbDevice.ep1out.state = D_EP_HALT;
|
||||
USB_SetIndex(1);
|
||||
USB_EpnOutStall();
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP2OUT_USED
|
||||
case (EP2OUT):
|
||||
myUsbDevice.ep2out.state = D_EP_HALT;
|
||||
USB_SetIndex(2);
|
||||
USB_EpnOutStall();
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP3OUT_USED
|
||||
case (EP3OUT):
|
||||
myUsbDevice.ep3out.state = D_EP_HALT;
|
||||
USB_SetIndex(3);
|
||||
USB_EpnOutStall();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
ENABLE_USB_INTS;
|
||||
USB_RestoreSfrPage();
|
||||
|
||||
return USB_STATUS_OK;
|
||||
}
|
||||
|
||||
void USBD_Stop(void)
|
||||
{
|
||||
USB_DisableInts();
|
||||
USBD_Disconnect();
|
||||
USBD_SetUsbState(USBD_STATE_NONE);
|
||||
}
|
||||
|
||||
void USBD_Suspend(void)
|
||||
{
|
||||
#if (!(SLAB_USB_PWRSAVE_MODE & USB_PWRSAVE_MODE_FASTWAKE))
|
||||
uint8_t i;
|
||||
#endif
|
||||
bool regulatorEnabled, prefetchEnabled;
|
||||
#if SLAB_USB_REMOTE_WAKEUP_ENABLED
|
||||
bool remoteWakeup = false;
|
||||
#endif
|
||||
|
||||
USB_SaveSfrPage();
|
||||
|
||||
// If the USB_PWRSAVE_MODE_ONVBUSOFF is enabled, we can enter suspend if VBUS
|
||||
// is not present even if the USB has not detected a suspend event.
|
||||
#if ((!(SLAB_USB_PWRSAVE_MODE & USB_PWRSAVE_MODE_ONVBUSOFF)) || \
|
||||
(SLAB_USB_BUS_POWERED))
|
||||
if (USB_IsSuspended() == true)
|
||||
#else
|
||||
if ((USB_IsSuspended() == true) || (USB_IsVbusOn() == false))
|
||||
#endif
|
||||
{
|
||||
USB_SuspendTransceiver();
|
||||
|
||||
#if SLAB_USB_FULL_SPEED
|
||||
USB_SetSuspendClock();
|
||||
#endif
|
||||
|
||||
// Get the state of the prefetch engine enable bit and disable the prefetch
|
||||
// engine
|
||||
prefetchEnabled = USB_IsPrefetchEnabled();
|
||||
USB_DisablePrefetch();
|
||||
|
||||
// Get the state of the internal regulator before suspending it.
|
||||
if (USB_IsRegulatorEnabled() == true)
|
||||
{
|
||||
regulatorEnabled = true;
|
||||
|
||||
#if (SLAB_USB_PWRSAVE_MODE & USB_PWRSAVE_MODE_FASTWAKE)
|
||||
USB_SuspendRegulatorFastWake();
|
||||
#else
|
||||
USB_SuspendRegulator();
|
||||
|
||||
// Wait at least 12 clock instructions before halting the internal oscillator
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
regulatorEnabled = false;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
USB_SuspendOscillator();
|
||||
|
||||
// When we arrive here, the device has waked from suspend mode.
|
||||
|
||||
#if SLAB_USB_REMOTE_WAKEUP_ENABLED
|
||||
// If remote wakeup is enabled, query the application if the remote
|
||||
// wakeup event occurred. If so, exit USBD_Suspend().
|
||||
if (USB_IsSuspended() == true)
|
||||
{
|
||||
remoteWakeup = USBD_RemoteWakeupCb();
|
||||
if (remoteWakeup == true)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if ((!(SLAB_USB_PWRSAVE_MODE & USB_PWRSAVE_MODE_ONVBUSOFF)) && \
|
||||
(SLAB_USB_BUS_POWERED == 0))
|
||||
// If the USB_PWRSAVE_MODE_ONVBUSOFF mode is disabled, VBUS has been
|
||||
// removed, so exit USBD_Suspend().
|
||||
if (USB_IsVbusOn() == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ((!(SLAB_USB_PWRSAVE_MODE & USB_PWRSAVE_MODE_ONVBUSOFF)) || \
|
||||
(SLAB_USB_BUS_POWERED))
|
||||
} while (USB_IsSuspended() == true);
|
||||
#else
|
||||
} while ((USB_IsSuspended() == true) || (USB_IsVbusOn() == false));
|
||||
#endif
|
||||
// Restore the internal regulator
|
||||
if (regulatorEnabled == true)
|
||||
{
|
||||
USB_UnsuspendRegulator();
|
||||
}
|
||||
|
||||
// Restore the prefetch engine
|
||||
if (prefetchEnabled == true)
|
||||
{
|
||||
USB_EnablePrefetch();
|
||||
}
|
||||
|
||||
#if SLAB_USB_FULL_SPEED
|
||||
// Restore the clock
|
||||
USB_SetNormalClock();
|
||||
#endif
|
||||
USB_EnableTransceiver();
|
||||
|
||||
#if SLAB_USB_REMOTE_WAKEUP_ENABLED
|
||||
// If the device woke from suspend due to a remote wakeup source, call
|
||||
// USBD_RemoteWakeup() here to wake up the host.
|
||||
if (remoteWakeup == true)
|
||||
{
|
||||
// Wake up the host
|
||||
if (USBD_RemoteWakeup() == USB_STATUS_OK)
|
||||
{
|
||||
// If the remote wakeup succeeded, transition out of USB suspend state
|
||||
USBD_SetUsbState(myUsbDevice.savedState);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
USB_RestoreSfrPage();
|
||||
}
|
||||
|
||||
int8_t USBD_UnStallEp(uint8_t epAddr)
|
||||
{
|
||||
bool usbIntsEnabled;
|
||||
|
||||
USB_SaveSfrPage();
|
||||
|
||||
// Verify the endpoint address is valid and not Endpoint 0.
|
||||
if ((epAddr == EP0) || (epAddr >= SLAB_USB_NUM_EPS_USED))
|
||||
{
|
||||
SLAB_ASSERT(false);
|
||||
return USB_STATUS_ILLEGAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
DISABLE_USB_INTS;
|
||||
|
||||
// End the stall condition and set the endpoint state to idle.
|
||||
switch (epAddr)
|
||||
{
|
||||
#if SLAB_USB_EP1IN_USED
|
||||
case (EP1IN):
|
||||
myUsbDevice.ep1in.state = D_EP_IDLE;
|
||||
USB_SetIndex(1);
|
||||
USB_EpnInEndStall();
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP2IN_USED
|
||||
case (EP2IN):
|
||||
myUsbDevice.ep2in.state = D_EP_IDLE;
|
||||
USB_SetIndex(2);
|
||||
USB_EpnInEndStall();
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP3IN_USED
|
||||
case (EP3IN):
|
||||
myUsbDevice.ep3in.state = D_EP_IDLE;
|
||||
USB_SetIndex(3);
|
||||
USB_EpnInEndStall();
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP1OUT_USED
|
||||
case (EP1OUT):
|
||||
myUsbDevice.ep1out.state = D_EP_IDLE;
|
||||
USB_SetIndex(1);
|
||||
USB_EpnOutEndStall();
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP2OUT_USED
|
||||
case (EP2OUT):
|
||||
myUsbDevice.ep2out.state = D_EP_IDLE;
|
||||
USB_SetIndex(2);
|
||||
USB_EpnOutEndStall();
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP3OUT_USED
|
||||
case (EP3OUT):
|
||||
myUsbDevice.ep3out.state = D_EP_IDLE;
|
||||
USB_SetIndex(3);
|
||||
USB_EpnOutEndStall();
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
ENABLE_USB_INTS;
|
||||
USB_RestoreSfrPage();
|
||||
}
|
||||
|
||||
return USB_STATUS_OK;
|
||||
}
|
||||
|
||||
int8_t USBD_Write(uint8_t epAddr,
|
||||
SI_VARIABLE_SEGMENT_POINTER(dat, uint8_t, SI_SEG_GENERIC),
|
||||
uint16_t byteCount,
|
||||
bool callback)
|
||||
{
|
||||
bool usbIntsEnabled;
|
||||
SI_VARIABLE_SEGMENT_POINTER(ep, USBD_Ep_TypeDef, MEM_MODEL_SEG);
|
||||
|
||||
USB_SaveSfrPage();
|
||||
|
||||
// Verify the endpoint address is valid.
|
||||
switch (epAddr)
|
||||
{
|
||||
case EP0:
|
||||
#if SLAB_USB_EP1IN_USED
|
||||
case EP1IN:
|
||||
#endif
|
||||
#if SLAB_USB_EP2IN_USED
|
||||
case EP2IN:
|
||||
#endif
|
||||
#if SLAB_USB_EP3IN_USED
|
||||
case EP3IN:
|
||||
#endif
|
||||
break;
|
||||
#if SLAB_USB_EP1OUT_USED
|
||||
case EP1OUT:
|
||||
#endif
|
||||
#if SLAB_USB_EP2OUT_USED
|
||||
case EP2OUT:
|
||||
#endif
|
||||
#if SLAB_USB_EP3OUT_USED
|
||||
case EP3OUT:
|
||||
#endif
|
||||
default:
|
||||
SLAB_ASSERT(false);
|
||||
return USB_STATUS_ILLEGAL;
|
||||
}
|
||||
|
||||
// If the device is not configured and it is not Endpoint 0, we cannot begin
|
||||
// a transfer.
|
||||
if ((epAddr != EP0) && (myUsbDevice.state != USBD_STATE_CONFIGURED))
|
||||
{
|
||||
return USB_STATUS_DEVICE_UNCONFIGURED;
|
||||
}
|
||||
|
||||
ep = GetEp(epAddr);
|
||||
|
||||
// If the endpoint is not idle, we cannot start a new transfer.
|
||||
// Return the appropriate error code.
|
||||
if (ep->state != D_EP_IDLE)
|
||||
{
|
||||
if (ep->state == D_EP_STALL)
|
||||
{
|
||||
return USB_STATUS_EP_STALLED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return USB_STATUS_EP_BUSY;
|
||||
}
|
||||
}
|
||||
|
||||
DISABLE_USB_INTS;
|
||||
|
||||
ep->buf = dat;
|
||||
ep->remaining = byteCount;
|
||||
ep->state = D_EP_TRANSMITTING;
|
||||
ep->misc.bits.callback = callback;
|
||||
|
||||
switch (epAddr)
|
||||
{
|
||||
// For Endpoint 0, set the inPacketPending flag to true. The USB handler
|
||||
// will see this on the next SOF and begin the transfer.
|
||||
case (EP0):
|
||||
myUsbDevice.ep0.misc.bits.inPacketPending = true;
|
||||
break;
|
||||
|
||||
// For data endpoints, we will call USB_WriteFIFO here to reduce latency
|
||||
// between the call to USBD_Write() and the first packet being sent.
|
||||
#if SLAB_USB_EP1IN_USED
|
||||
case (EP1IN):
|
||||
USB_WriteFIFO(1,
|
||||
(byteCount > SLAB_USB_EP1IN_MAX_PACKET_SIZE) ? SLAB_USB_EP1IN_MAX_PACKET_SIZE : byteCount,
|
||||
myUsbDevice.ep1in.buf,
|
||||
true);
|
||||
break;
|
||||
#endif // SLAB_USB_EP1IN_USED
|
||||
#if SLAB_USB_EP2IN_USED
|
||||
case (EP2IN):
|
||||
USB_WriteFIFO(2,
|
||||
(byteCount > SLAB_USB_EP2IN_MAX_PACKET_SIZE) ? SLAB_USB_EP2IN_MAX_PACKET_SIZE : byteCount,
|
||||
myUsbDevice.ep2in.buf,
|
||||
true);
|
||||
break;
|
||||
#endif // SLAB_USB_EP2IN_USED
|
||||
#if SLAB_USB_EP3IN_USED
|
||||
case (EP3IN):
|
||||
#if ((SLAB_USB_EP3IN_TRANSFER_TYPE == USB_EPTYPE_BULK) || (SLAB_USB_EP3IN_TRANSFER_TYPE == USB_EPTYPE_INTR))
|
||||
USB_WriteFIFO(3,
|
||||
(byteCount > SLAB_USB_EP3IN_MAX_PACKET_SIZE) ? SLAB_USB_EP3IN_MAX_PACKET_SIZE : byteCount,
|
||||
myUsbDevice.ep3in.buf,
|
||||
true);
|
||||
#elif (SLAB_USB_EP3IN_TRANSFER_TYPE == USB_EPTYPE_ISOC)
|
||||
myUsbDevice.ep3in.misc.bits.inPacketPending = true;
|
||||
myUsbDevice.ep3inIsoIdx = 0;
|
||||
#endif
|
||||
break;
|
||||
#endif // SLAB_USB_EP3IN_USED
|
||||
}
|
||||
|
||||
ENABLE_USB_INTS;
|
||||
USB_RestoreSfrPage();
|
||||
|
||||
return USB_STATUS_OK;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// UtilityFunctions
|
||||
|
||||
void USBD_SetUsbState(USBD_State_TypeDef newState)
|
||||
{
|
||||
#if (SLAB_USB_SUPPORT_ALT_INTERFACES)
|
||||
uint8_t i;
|
||||
#endif
|
||||
USBD_State_TypeDef currentState;
|
||||
|
||||
currentState = myUsbDevice.state;
|
||||
|
||||
// If the device is un-configuring, disable the data endpoints and clear out
|
||||
// alternate interface settings
|
||||
if ((currentState >= USBD_STATE_SUSPENDED)
|
||||
&& (newState < USBD_STATE_SUSPENDED))
|
||||
{
|
||||
USBD_AbortAllTransfers();
|
||||
|
||||
#if (SLAB_USB_SUPPORT_ALT_INTERFACES)
|
||||
for (i = 0; i < SLAB_USB_NUM_INTERFACES; i++)
|
||||
{
|
||||
myUsbDevice.interfaceAltSetting[i] = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (newState == USBD_STATE_SUSPENDED)
|
||||
{
|
||||
myUsbDevice.savedState = currentState;
|
||||
}
|
||||
|
||||
myUsbDevice.state = newState;
|
||||
|
||||
#if SLAB_USB_STATE_CHANGE_CB
|
||||
if (currentState != newState)
|
||||
{
|
||||
USBD_DeviceStateChangeCb(currentState, newState);
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -0,0 +1,870 @@
|
|||
/**************************************************************************//**
|
||||
* Copyright (c) 2015 by Silicon Laboratories Inc. All rights reserved.
|
||||
*
|
||||
* http://developer.silabs.com/legal/version/v11/Silicon_Labs_Software_License_Agreement.txt
|
||||
*****************************************************************************/
|
||||
|
||||
#include "si_toolchain.h"
|
||||
#include "efm8_usb.h"
|
||||
#include <stdint.h>
|
||||
#include <endian.h>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function Prototypes
|
||||
|
||||
static USB_Status_TypeDef ClearFeature(void);
|
||||
static USB_Status_TypeDef GetConfiguration(void);
|
||||
static USB_Status_TypeDef GetDescriptor(void);
|
||||
static USB_Status_TypeDef GetInterface(void);
|
||||
static USB_Status_TypeDef GetStatus(void);
|
||||
static USB_Status_TypeDef SetAddress(void);
|
||||
static USB_Status_TypeDef SetConfiguration(void);
|
||||
static USB_Status_TypeDef SetFeature(void);
|
||||
static USB_Status_TypeDef SetInterface(void);
|
||||
static void USBD_ActivateAllEps(bool forceIdle);
|
||||
static void EP0_Write(SI_VARIABLE_SEGMENT_POINTER(dat, uint8_t, SI_SEG_GENERIC), uint16_t numBytes);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Global Variables
|
||||
|
||||
extern SI_SEGMENT_VARIABLE(myUsbDevice, USBD_Device_TypeDef, MEM_MODEL_SEG);
|
||||
const SI_SEGMENT_VARIABLE(txZero[2], uint8_t, SI_SEG_CODE);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Static Global Variables
|
||||
|
||||
static uint16_t pStatus;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Chapter 9 Functions
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Processes Standard Request (Chapter 9 Command)
|
||||
* @return Status of request (type @ref USB_Status_TypeDef)
|
||||
* @note This function takes no parameters, but it uses the setup command
|
||||
* stored in @ref myUsbDevice.setup.
|
||||
******************************************************************************/
|
||||
USB_Status_TypeDef USBDCH9_SetupCmd(void)
|
||||
{
|
||||
USB_Status_TypeDef status = USB_STATUS_OK;
|
||||
|
||||
switch (myUsbDevice.setup.bRequest)
|
||||
{
|
||||
case GET_STATUS:
|
||||
status = GetStatus();
|
||||
break;
|
||||
|
||||
case CLEAR_FEATURE:
|
||||
status = ClearFeature();
|
||||
break;
|
||||
|
||||
case SET_FEATURE:
|
||||
status = SetFeature();
|
||||
break;
|
||||
|
||||
case SET_ADDRESS:
|
||||
status = SetAddress();
|
||||
break;
|
||||
|
||||
case GET_DESCRIPTOR:
|
||||
status = GetDescriptor();
|
||||
break;
|
||||
|
||||
case GET_CONFIGURATION:
|
||||
status = GetConfiguration();
|
||||
break;
|
||||
|
||||
case SET_CONFIGURATION:
|
||||
status = SetConfiguration();
|
||||
break;
|
||||
|
||||
case GET_INTERFACE:
|
||||
status = GetInterface();
|
||||
break;
|
||||
|
||||
case SET_INTERFACE:
|
||||
status = SetInterface();
|
||||
break;
|
||||
|
||||
default:
|
||||
status = USB_STATUS_REQ_ERR;
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Clears the requested feature
|
||||
* @details Supports CLEAR_FEATURE for Remote Wakeup and Endpoint Halt
|
||||
* @return Status of request (type @ref USB_Status_TypeDef)
|
||||
* @note This function takes no parameters, but it uses the setup command
|
||||
* stored in @ref myUsbDevice.setup.
|
||||
******************************************************************************/
|
||||
static USB_Status_TypeDef ClearFeature(void)
|
||||
{
|
||||
USB_Status_TypeDef retVal = USB_STATUS_REQ_ERR;
|
||||
|
||||
if (myUsbDevice.setup.wLength == 0)
|
||||
{
|
||||
switch (myUsbDevice.setup.bmRequestType.Recipient)
|
||||
{
|
||||
#if SLAB_USB_REMOTE_WAKEUP_ENABLED
|
||||
case USB_SETUP_RECIPIENT_DEVICE:
|
||||
if ((myUsbDevice.setup.wIndex == 0)
|
||||
&& (myUsbDevice.setup.wValue == USB_FEATURE_DEVICE_REMOTE_WAKEUP)
|
||||
&& (myUsbDevice.state >= USBD_STATE_ADDRESSED))
|
||||
{
|
||||
// Remote wakeup feature clear
|
||||
myUsbDevice.remoteWakeupEnabled = false;
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
#endif // SLAB_USB_REMOTE_WAKEUP_ENABLED
|
||||
case USB_SETUP_RECIPIENT_ENDPOINT:
|
||||
if (myUsbDevice.setup.wValue == USB_FEATURE_ENDPOINT_HALT)
|
||||
{
|
||||
// Device does not support halting endpoint 0, but do not return
|
||||
// an error as this is a valid request
|
||||
if (((myUsbDevice.setup.wIndex & ~USB_EP_DIR_IN) == 0)
|
||||
&& (myUsbDevice.state >= USBD_STATE_ADDRESSED))
|
||||
{
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
else if (((myUsbDevice.setup.wIndex & ~USB_SETUP_DIR_D2H) < SLAB_USB_NUM_EPS_USED)
|
||||
&& (myUsbDevice.state == USBD_STATE_CONFIGURED))
|
||||
{
|
||||
retVal = USB_STATUS_OK;
|
||||
USB_SetIndex((myUsbDevice.setup.wIndex & 0xFF) & ~USB_SETUP_DIR_D2H);
|
||||
|
||||
#if (SLAB_USB_EP1IN_USED || SLAB_USB_EP2IN_USED || SLAB_USB_EP3IN_USED)
|
||||
if ((myUsbDevice.setup.wIndex & 0xFF) & USB_EP_DIR_IN)
|
||||
{
|
||||
USB_EpnInEndStallAndClearDataToggle();
|
||||
}
|
||||
#endif
|
||||
#if (SLAB_USB_EP1OUT_USED || SLAB_USB_EP2OUT_USED || SLAB_USB_EP3OUT_USED)
|
||||
if (((myUsbDevice.setup.wIndex & 0xFF) & USB_EP_DIR_IN) == 0)
|
||||
{
|
||||
USB_EpnOutEndStallAndClearDataToggle();
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (myUsbDevice.setup.wIndex & 0xFF)
|
||||
{
|
||||
#if SLAB_USB_EP1OUT_USED
|
||||
case (USB_EP_DIR_OUT | 1):
|
||||
if (myUsbDevice.ep1out.state != D_EP_RECEIVING)
|
||||
{
|
||||
myUsbDevice.ep1out.state = D_EP_IDLE;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP2OUT_USED
|
||||
case (USB_EP_DIR_OUT | 2):
|
||||
if (myUsbDevice.ep2out.state != D_EP_RECEIVING)
|
||||
{
|
||||
myUsbDevice.ep2out.state = D_EP_IDLE;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP3OUT_USED
|
||||
case (USB_EP_DIR_OUT | 3):
|
||||
if (myUsbDevice.ep3out.state != D_EP_RECEIVING)
|
||||
{
|
||||
myUsbDevice.ep3out.state = D_EP_IDLE;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP1IN_USED
|
||||
case (USB_EP_DIR_IN | 1):
|
||||
if (myUsbDevice.ep1in.state != D_EP_TRANSMITTING)
|
||||
{
|
||||
myUsbDevice.ep1in.state = D_EP_IDLE;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP2IN_USED
|
||||
case (USB_EP_DIR_IN | 2):
|
||||
if (myUsbDevice.ep2in.state != D_EP_TRANSMITTING)
|
||||
{
|
||||
myUsbDevice.ep2in.state = D_EP_IDLE;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP3IN_USED
|
||||
case (USB_EP_DIR_IN | 3):
|
||||
if (myUsbDevice.ep3in.state != D_EP_TRANSMITTING)
|
||||
{
|
||||
myUsbDevice.ep3in.state = D_EP_IDLE;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Gets the current configuration value
|
||||
* @details Zero means the device is not configured, a non-zero value
|
||||
* is the configuration value of the configured device.
|
||||
* @return Status of request (type @ref USB_Status_TypeDef)
|
||||
* @note This function takes no parameters, but it uses the setup command
|
||||
* stored in @ref myUsbDevice.setup.
|
||||
******************************************************************************/
|
||||
static USB_Status_TypeDef GetConfiguration(void)
|
||||
{
|
||||
USB_Status_TypeDef retVal = USB_STATUS_REQ_ERR;
|
||||
|
||||
if ((myUsbDevice.setup.wIndex == 0)
|
||||
&& (myUsbDevice.setup.wValue == 0)
|
||||
&& (myUsbDevice.setup.wLength == 1)
|
||||
&& (myUsbDevice.setup.bmRequestType.Direction == USB_SETUP_DIR_IN)
|
||||
&& (myUsbDevice.setup.bmRequestType.Recipient == USB_SETUP_RECIPIENT_DEVICE))
|
||||
{
|
||||
if (myUsbDevice.state == USBD_STATE_ADDRESSED)
|
||||
{
|
||||
EP0_Write((SI_VARIABLE_SEGMENT_POINTER(, uint8_t, SI_SEG_GENERIC))txZero, 1);
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
else if (myUsbDevice.state == USBD_STATE_CONFIGURED)
|
||||
{
|
||||
EP0_Write(&myUsbDevice.configurationValue, 1);
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Sends the requested USB Descriptor
|
||||
* @details Supports single or multiple languages (configured by
|
||||
* @ref SLAB_USB_NUM_LANGUAGES).
|
||||
* @return Status of request (type @ref USB_Status_TypeDef)
|
||||
* @note This function takes no parameters, but it uses the setup command
|
||||
* stored in @ref myUsbDevice.setup.
|
||||
******************************************************************************/
|
||||
static USB_Status_TypeDef GetDescriptor(void)
|
||||
{
|
||||
#if (SLAB_USB_NUM_LANGUAGES > 1)
|
||||
bool langSupported;
|
||||
uint8_t lang;
|
||||
#endif
|
||||
|
||||
uint8_t index;
|
||||
uint16_t length = 0;
|
||||
SI_VARIABLE_SEGMENT_POINTER(dat, uint8_t, SI_SEG_GENERIC);
|
||||
USB_Status_TypeDef retVal = USB_STATUS_REQ_ERR;
|
||||
|
||||
if (*((uint8_t *)&myUsbDevice.setup.bmRequestType) ==
|
||||
(USB_SETUP_DIR_D2H | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_DEVICE))
|
||||
{
|
||||
index = myUsbDevice.setup.wValue & 0xFF;
|
||||
|
||||
switch (myUsbDevice.setup.wValue >> 8)
|
||||
{
|
||||
case USB_DEVICE_DESCRIPTOR:
|
||||
if (index != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
dat = (SI_VARIABLE_SEGMENT_POINTER(, uint8_t, SI_SEG_GENERIC))myUsbDevice.deviceDescriptor;
|
||||
length = myUsbDevice.deviceDescriptor->bLength;
|
||||
break;
|
||||
|
||||
case USB_CONFIG_DESCRIPTOR:
|
||||
if (index != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
dat = (SI_VARIABLE_SEGMENT_POINTER(, uint8_t, SI_SEG_GENERIC))myUsbDevice.configDescriptor;
|
||||
length = le16toh(myUsbDevice.configDescriptor->wTotalLength);
|
||||
break;
|
||||
|
||||
case USB_STRING_DESCRIPTOR:
|
||||
#if (SLAB_USB_NUM_LANGUAGES == 1)
|
||||
|
||||
dat = (SI_VARIABLE_SEGMENT_POINTER(, uint8_t, SI_SEG_GENERIC))myUsbDevice.stringDescriptors[index];
|
||||
|
||||
// Index 0 is the language string. If SLAB_USB_NUM_LANGUAGES == 1, we
|
||||
// know the length will be 4 and the format will be UTF16LE.
|
||||
if (index == 0)
|
||||
{
|
||||
length = 4;
|
||||
myUsbDevice.ep0String.encoding.type = USB_STRING_DESCRIPTOR_UTF16LE;
|
||||
}
|
||||
// Otherwise, verify the language is correct (either the value set as
|
||||
// SLAB_USB_LANGUAGE in usbconfig.h, or 0).
|
||||
else if ((myUsbDevice.setup.wIndex == 0) || (myUsbDevice.setup.wIndex == SLAB_USB_LANGUAGE))
|
||||
{
|
||||
// Verify the index is valid
|
||||
if (index < myUsbDevice.numberOfStrings)
|
||||
{
|
||||
length = *(dat + USB_STRING_DESCRIPTOR_LENGTH);
|
||||
myUsbDevice.ep0String.encoding.type = *(dat + USB_STRING_DESCRIPTOR_ENCODING);
|
||||
dat += USB_STRING_DESCRIPTOR_LENGTH;
|
||||
myUsbDevice.ep0String.encoding.init = true;
|
||||
}
|
||||
}
|
||||
#elif (SLAB_USB_NUM_LANGUAGES > 1)
|
||||
|
||||
langSupported = false;
|
||||
|
||||
// Index 0 is the language.
|
||||
if (index == 0)
|
||||
{
|
||||
dat = ((SI_VARIABLE_SEGMENT_POINTER(, uint8_t, SI_SEG_GENERIC))myUsbDevice.stringDescriptors->languageArray[0][index]);
|
||||
length = *((uint8_t *)dat);
|
||||
myUsbDevice.ep0String.encoding.type = USB_STRING_DESCRIPTOR_UTF16LE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, verify the language is one of the supported languages or 0.
|
||||
for (lang = 0; lang < SLAB_USB_NUM_LANGUAGES; lang++)
|
||||
{
|
||||
if ((myUsbDevice.stringDescriptors->languageIDs[lang] == myUsbDevice.setup.wIndex)
|
||||
|| (myUsbDevice.stringDescriptors->languageIDs[lang] == 0))
|
||||
{
|
||||
langSupported = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((langSupported == true) && (index < myUsbDevice.numberOfStrings))
|
||||
{
|
||||
dat = ((SI_VARIABLE_SEGMENT_POINTER(, uint8_t, SI_SEG_GENERIC))myUsbDevice.stringDescriptors->languageArray[lang][index]);
|
||||
length = *(dat + USB_STRING_DESCRIPTOR_LENGTH);
|
||||
myUsbDevice.ep0String.encoding.type = *(dat + USB_STRING_DESCRIPTOR_ENCODING);
|
||||
dat += USB_STRING_DESCRIPTOR_LENGTH;
|
||||
|
||||
if (myUsbDevice.ep0String.encoding.type == USB_STRING_DESCRIPTOR_UTF16LE_PACKED)
|
||||
{
|
||||
myUsbDevice.ep0String.encoding.init = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
myUsbDevice.ep0String.encoding.init = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // ( SLAB_USB_NUM_LANGUAGES == 1 )
|
||||
}
|
||||
|
||||
// If there is a descriptor to send, get the proper length, then call
|
||||
// EP0_Write() to send.
|
||||
if (length)
|
||||
{
|
||||
if (length > myUsbDevice.setup.wLength)
|
||||
{
|
||||
length = myUsbDevice.setup.wLength;
|
||||
}
|
||||
|
||||
EP0_Write(dat, length);
|
||||
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Sends the current interface alternate setting
|
||||
* @details Sends 0x0000 if alternate interfaces are not supported.
|
||||
* @return Status of request (type @ref USB_Status_TypeDef)
|
||||
* @note This function takes no parameters, but it uses the setup command
|
||||
* stored in @ref myUsbDevice.setup.
|
||||
******************************************************************************/
|
||||
static USB_Status_TypeDef GetInterface(void)
|
||||
{
|
||||
uint16_t interface = myUsbDevice.setup.wIndex;
|
||||
USB_Status_TypeDef retVal = USB_STATUS_REQ_ERR;
|
||||
|
||||
if ((interface < SLAB_USB_NUM_INTERFACES)
|
||||
&& (myUsbDevice.setup.wLength == 1)
|
||||
&& (myUsbDevice.setup.wValue == 0)
|
||||
&& (*((uint8_t *)&myUsbDevice.setup.bmRequestType) ==
|
||||
(USB_SETUP_DIR_D2H | USB_SETUP_TYPE_STANDARD | USB_SETUP_RECIPIENT_INTERFACE)))
|
||||
{
|
||||
if (myUsbDevice.state == USBD_STATE_CONFIGURED)
|
||||
{
|
||||
#if (SLAB_USB_SUPPORT_ALT_INTERFACES)
|
||||
// Return the alternate setting for the specified interface
|
||||
EP0_Write((SI_VARIABLE_SEGMENT_POINTER(, uint8_t, SI_SEG_GENERIC))&myUsbDevice.interfaceAltSetting[interface], 1);
|
||||
#else
|
||||
// Alternate interfaces are not supported, so return 0x0000.
|
||||
EP0_Write((SI_VARIABLE_SEGMENT_POINTER(, uint8_t, SI_SEG_GENERIC))&txZero, 1);
|
||||
#endif
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Sends the requested Remote Wakeup, Self-Powered, or
|
||||
* Endpoint Status
|
||||
* @return Status of request (type @ref USB_Status_TypeDef)
|
||||
* @note This function takes no parameters, but it uses the setup command
|
||||
* stored in @ref myUsbDevice.setup.
|
||||
******************************************************************************/
|
||||
static USB_Status_TypeDef GetStatus(void)
|
||||
{
|
||||
USB_Status_TypeDef retVal = USB_STATUS_REQ_ERR;
|
||||
|
||||
if ((myUsbDevice.setup.wLength == 2)
|
||||
&& (myUsbDevice.setup.wValue == 0)
|
||||
&& (myUsbDevice.setup.bmRequestType.Direction == USB_SETUP_DIR_IN)
|
||||
&& (myUsbDevice.state >= USBD_STATE_ADDRESSED))
|
||||
{
|
||||
pStatus = htole16(0); // Default return value is 0x0000
|
||||
|
||||
switch (myUsbDevice.setup.bmRequestType.Recipient)
|
||||
{
|
||||
case USB_SETUP_RECIPIENT_DEVICE:
|
||||
if (myUsbDevice.setup.wIndex == 0)
|
||||
{
|
||||
#if SLAB_USB_REMOTE_WAKEUP_ENABLED
|
||||
// Remote wakeup feature status
|
||||
if (myUsbDevice.remoteWakeupEnabled)
|
||||
{
|
||||
pStatus |= htole16(REMOTE_WAKEUP_ENABLED);
|
||||
}
|
||||
#endif // SLAB_USB_REMOTE_WAKEUP_ENABLED
|
||||
|
||||
#if SLAB_USB_IS_SELF_POWERED_CB
|
||||
// Current self/bus power status
|
||||
if (USBD_IsSelfPoweredCb())
|
||||
{
|
||||
pStatus |= htole16(DEVICE_IS_SELFPOWERED);
|
||||
}
|
||||
#elif (SLAB_USB_BUS_POWERED == 0)
|
||||
pStatus |= htole16(DEVICE_IS_SELFPOWERED);
|
||||
#endif // SLAB_USB_IS_SELF_POWERED_CB
|
||||
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
|
||||
case USB_SETUP_RECIPIENT_INTERFACE:
|
||||
if (myUsbDevice.setup.wIndex < SLAB_USB_NUM_INTERFACES)
|
||||
{
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case USB_SETUP_RECIPIENT_ENDPOINT:
|
||||
// Device does not support halting endpoint 0, but do not give
|
||||
// an error as this is a valid request
|
||||
if (((myUsbDevice.setup.wIndex & ~USB_EP_DIR_IN) == 0)
|
||||
&& (myUsbDevice.state == USBD_STATE_ADDRESSED))
|
||||
{
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
else if (myUsbDevice.state == USBD_STATE_CONFIGURED)
|
||||
{
|
||||
switch (myUsbDevice.setup.wIndex & 0xFF)
|
||||
{
|
||||
#if SLAB_USB_EP1OUT_USED
|
||||
case (USB_EP_DIR_OUT | 1):
|
||||
if (myUsbDevice.ep1out.state == D_EP_HALT)
|
||||
{
|
||||
pStatus = htole16(1);
|
||||
}
|
||||
retVal = USB_STATUS_OK;
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP2OUT_USED
|
||||
case (USB_EP_DIR_OUT | 2):
|
||||
if (myUsbDevice.ep2out.state == D_EP_HALT)
|
||||
{
|
||||
pStatus = htole16(1);
|
||||
}
|
||||
retVal = USB_STATUS_OK;
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP3OUT_USED
|
||||
case (USB_EP_DIR_OUT | 3):
|
||||
if (myUsbDevice.ep3out.state == D_EP_HALT)
|
||||
{
|
||||
pStatus = htole16(1);
|
||||
}
|
||||
retVal = USB_STATUS_OK;
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP1IN_USED
|
||||
case (USB_EP_DIR_IN | 1):
|
||||
if (myUsbDevice.ep1in.state == D_EP_HALT)
|
||||
{
|
||||
pStatus = htole16(1);
|
||||
}
|
||||
retVal = USB_STATUS_OK;
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP2IN_USED
|
||||
case (USB_EP_DIR_IN | 2):
|
||||
if (myUsbDevice.ep2in.state == D_EP_HALT)
|
||||
{
|
||||
pStatus = htole16(1);
|
||||
}
|
||||
retVal = USB_STATUS_OK;
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP3IN_USED
|
||||
case (USB_EP_DIR_IN | 3):
|
||||
if (myUsbDevice.ep3in.state == D_EP_HALT)
|
||||
{
|
||||
pStatus = htole16(1);
|
||||
}
|
||||
retVal = USB_STATUS_OK;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// If the command was valid, send the requested status.
|
||||
if (retVal == USB_STATUS_OK)
|
||||
{
|
||||
EP0_Write((SI_VARIABLE_SEGMENT_POINTER(, uint8_t, SI_SEG_GENERIC))&pStatus, 2);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Sets the Address
|
||||
* @return Status of request (type @ref USB_Status_TypeDef)
|
||||
* @note This function takes no parameters, but it uses the setup command
|
||||
* stored in @ref myUsbDevice.setup.
|
||||
******************************************************************************/
|
||||
static USB_Status_TypeDef SetAddress(void)
|
||||
{
|
||||
USB_Status_TypeDef retVal = USB_STATUS_REQ_ERR;
|
||||
|
||||
if ((myUsbDevice.setup.wValue < 128)
|
||||
&& (myUsbDevice.setup.wLength == 0)
|
||||
&& (myUsbDevice.setup.bmRequestType.Recipient == USB_SETUP_RECIPIENT_DEVICE)
|
||||
&& (myUsbDevice.setup.wIndex == 0))
|
||||
{
|
||||
// If the device is in the Default state and the address is non-zero, put
|
||||
// the device in the Addressed state.
|
||||
if (myUsbDevice.state == USBD_STATE_DEFAULT)
|
||||
{
|
||||
if (myUsbDevice.setup.wValue != 0)
|
||||
{
|
||||
USBD_SetUsbState(USBD_STATE_ADDRESSED);
|
||||
}
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
// If the device is already addressed and the address is zero, put the
|
||||
// device in the Default state.
|
||||
else if (myUsbDevice.state == USBD_STATE_ADDRESSED)
|
||||
{
|
||||
if (myUsbDevice.setup.wValue == 0)
|
||||
{
|
||||
USBD_SetUsbState(USBD_STATE_DEFAULT);
|
||||
}
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
|
||||
// Set the new address if the request was valid.
|
||||
if (retVal == USB_STATUS_OK)
|
||||
{
|
||||
USB_SetAddress(myUsbDevice.setup.wValue);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Sets the Configuration
|
||||
* @return Status of request (type @ref USB_Status_TypeDef)
|
||||
* @note This function takes no parameters, but it uses the setup command
|
||||
* stored in @ref myUsbDevice.setup.
|
||||
******************************************************************************/
|
||||
static USB_Status_TypeDef SetConfiguration(void)
|
||||
{
|
||||
USB_Status_TypeDef retVal = USB_STATUS_REQ_ERR;
|
||||
|
||||
if (((myUsbDevice.setup.wValue >> 8) == 0)
|
||||
&& (myUsbDevice.setup.bmRequestType.Recipient == USB_SETUP_RECIPIENT_DEVICE)
|
||||
&& (myUsbDevice.setup.wLength == 0)
|
||||
&& (myUsbDevice.setup.wIndex == 0))
|
||||
{
|
||||
// If the device is in the Addressed state and a valid Configuration value
|
||||
// was sent, enter the Configured state.
|
||||
if (myUsbDevice.state == USBD_STATE_ADDRESSED)
|
||||
{
|
||||
if ((myUsbDevice.setup.wValue == 0)
|
||||
|| (myUsbDevice.setup.wValue == myUsbDevice.configDescriptor->bConfigurationValue))
|
||||
{
|
||||
myUsbDevice.configurationValue = myUsbDevice.setup.wValue;
|
||||
if (myUsbDevice.setup.wValue == myUsbDevice.configDescriptor->bConfigurationValue)
|
||||
{
|
||||
USBD_ActivateAllEps(true);
|
||||
USBD_SetUsbState(USBD_STATE_CONFIGURED);
|
||||
}
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
}
|
||||
// If the device is in the Configured state and Configuration zero is sent,
|
||||
// abort all transfer and enter the Addressed state.
|
||||
else if (myUsbDevice.state == USBD_STATE_CONFIGURED)
|
||||
{
|
||||
if ((myUsbDevice.setup.wValue == 0)
|
||||
|| (myUsbDevice.setup.wValue == myUsbDevice.configDescriptor->bConfigurationValue))
|
||||
{
|
||||
myUsbDevice.configurationValue = myUsbDevice.setup.wValue;
|
||||
if (myUsbDevice.setup.wValue == 0)
|
||||
{
|
||||
USBD_SetUsbState(USBD_STATE_ADDRESSED);
|
||||
USBD_AbortAllTransfers();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reenable device endpoints, will reset data toggles
|
||||
USBD_ActivateAllEps(false);
|
||||
}
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Sets the Remote Wakeup or Endpoint Halt Feature
|
||||
* @return Status of request (type @ref USB_Status_TypeDef)
|
||||
* @note This function takes no parameters, but it uses the setup command
|
||||
* stored in @ref myUsbDevice.setup.
|
||||
******************************************************************************/
|
||||
static USB_Status_TypeDef SetFeature(void)
|
||||
{
|
||||
USB_Status_TypeDef retVal = USB_STATUS_REQ_ERR;
|
||||
|
||||
if (myUsbDevice.setup.wLength == 0)
|
||||
{
|
||||
switch (myUsbDevice.setup.bmRequestType.Recipient)
|
||||
{
|
||||
#if SLAB_USB_REMOTE_WAKEUP_ENABLED
|
||||
case USB_SETUP_RECIPIENT_DEVICE:
|
||||
if ((myUsbDevice.setup.wIndex == 0) // ITF no. 0
|
||||
&& (myUsbDevice.setup.wValue == USB_FEATURE_DEVICE_REMOTE_WAKEUP)
|
||||
&& (myUsbDevice.state == USBD_STATE_CONFIGURED))
|
||||
{
|
||||
myUsbDevice.remoteWakeupEnabled = true;
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
#endif // SLAB_USB_REMOTE_WAKEUP_ENABLED
|
||||
case USB_SETUP_RECIPIENT_ENDPOINT:
|
||||
// Device does not support halting endpoint 0, but do not return
|
||||
// an error as this is a valid request
|
||||
if (((myUsbDevice.setup.wIndex & ~USB_EP_DIR_IN) == 0)
|
||||
&& (myUsbDevice.state >= USBD_STATE_ADDRESSED))
|
||||
{
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
else if ((((myUsbDevice.setup.wIndex) & ~USB_SETUP_DIR_D2H) < SLAB_USB_NUM_EPS_USED)
|
||||
&& (myUsbDevice.setup.wValue == USB_FEATURE_ENDPOINT_HALT)
|
||||
&& (myUsbDevice.state == USBD_STATE_CONFIGURED))
|
||||
{
|
||||
retVal = USB_STATUS_OK;
|
||||
USB_SetIndex((myUsbDevice.setup.wIndex & 0xFF) & ~USB_SETUP_DIR_D2H);
|
||||
|
||||
// Enable Stalls on the specified endpoint.
|
||||
#if (SLAB_USB_EP1IN_USED || SLAB_USB_EP2IN_USED || SLAB_USB_EP3IN_USED)
|
||||
if ((myUsbDevice.setup.wIndex & 0xFF) & USB_EP_DIR_IN)
|
||||
{
|
||||
USB_EpnInStall();
|
||||
}
|
||||
#endif
|
||||
#if (SLAB_USB_EP1OUT_USED || SLAB_USB_EP2OUT_USED || SLAB_USB_EP3OUT_USED)
|
||||
if (((myUsbDevice.setup.wIndex & 0xFF) & USB_EP_DIR_IN) == 0)
|
||||
{
|
||||
USB_EpnOutStall();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Put the specified endpoint in the Halted state.
|
||||
switch (myUsbDevice.setup.wIndex & 0xFF)
|
||||
{
|
||||
#if SLAB_USB_EP1OUT_USED
|
||||
case (USB_EP_DIR_OUT | 1):
|
||||
myUsbDevice.ep1out.state = D_EP_HALT;
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP2OUT_USED
|
||||
case (USB_EP_DIR_OUT | 2):
|
||||
myUsbDevice.ep2out.state = D_EP_HALT;
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP3OUT_USED
|
||||
case (USB_EP_DIR_OUT | 3):
|
||||
myUsbDevice.ep3out.state = D_EP_HALT;
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP1IN_USED
|
||||
case (USB_EP_DIR_IN | 1):
|
||||
myUsbDevice.ep1in.state = D_EP_HALT;
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP2IN_USED
|
||||
case (USB_EP_DIR_IN | 2):
|
||||
myUsbDevice.ep2in.state = D_EP_HALT;
|
||||
break;
|
||||
#endif
|
||||
#if SLAB_USB_EP3IN_USED
|
||||
case (USB_EP_DIR_IN | 3):
|
||||
myUsbDevice.ep3in.state = D_EP_HALT;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Sets the Interface and Alternate Interface (if supported)
|
||||
* @return Status of request (type @ref USB_Status_TypeDef)
|
||||
* @note This function takes no parameters, but it uses the setup command
|
||||
* stored in @ref myUsbDevice.setup.
|
||||
******************************************************************************/
|
||||
static USB_Status_TypeDef SetInterface(void)
|
||||
{
|
||||
USB_Status_TypeDef retVal = USB_STATUS_REQ_ERR;
|
||||
uint8_t interface = (uint8_t)myUsbDevice.setup.wIndex;
|
||||
uint8_t altSetting = (uint8_t)myUsbDevice.setup.wValue;
|
||||
|
||||
if ((interface < SLAB_USB_NUM_INTERFACES)
|
||||
&& (myUsbDevice.state == USBD_STATE_CONFIGURED)
|
||||
&& (myUsbDevice.setup.wLength == 0)
|
||||
#if (SLAB_USB_SUPPORT_ALT_INTERFACES == 0)
|
||||
&& (altSetting == 0)
|
||||
#endif
|
||||
&& (myUsbDevice.setup.bmRequestType.Recipient == USB_SETUP_RECIPIENT_INTERFACE))
|
||||
{
|
||||
#if (SLAB_USB_SUPPORT_ALT_INTERFACES)
|
||||
if (USBD_SetInterfaceCb(interface, altSetting) == USB_STATUS_OK)
|
||||
{
|
||||
myUsbDevice.interfaceAltSetting[interface] = altSetting;
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
#else
|
||||
#if (SLAB_USB_NUM_INTERFACES == 1)
|
||||
// Reset data toggles on EP's
|
||||
USBD_ActivateAllEps(false);
|
||||
#endif // ( SLAB_USB_NUM_INTERFACES == 1 )
|
||||
retVal = USB_STATUS_OK;
|
||||
#endif // ( SLAB_USB_SUPPORT_ALT_INTERFACES )
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Utility Functions
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Enables all endpoints for data transfers
|
||||
* @return Status of request (type @ref USB_Status_TypeDef)
|
||||
* @note This function takes no parameters, but it uses the setup command
|
||||
* stored in @ref myUsbDevice.setup.
|
||||
******************************************************************************/
|
||||
static void USBD_ActivateAllEps(bool forceIdle)
|
||||
{
|
||||
if (forceIdle == true)
|
||||
{
|
||||
#if SLAB_USB_EP1IN_USED
|
||||
myUsbDevice.ep1in.state = D_EP_IDLE;
|
||||
#endif
|
||||
#if SLAB_USB_EP2IN_USED
|
||||
myUsbDevice.ep2in.state = D_EP_IDLE;
|
||||
#endif
|
||||
#if SLAB_USB_EP3IN_USED
|
||||
myUsbDevice.ep3in.state = D_EP_IDLE;
|
||||
#endif
|
||||
#if SLAB_USB_EP1OUT_USED
|
||||
myUsbDevice.ep1out.state = D_EP_IDLE;
|
||||
#endif
|
||||
#if SLAB_USB_EP2OUT_USED
|
||||
myUsbDevice.ep2out.state = D_EP_IDLE;
|
||||
#endif
|
||||
#if SLAB_USB_EP3OUT_USED
|
||||
myUsbDevice.ep3out.state = D_EP_IDLE;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if SLAB_USB_EP1IN_USED
|
||||
USB_ActivateEp(1, // ep
|
||||
SLAB_USB_EP1IN_MAX_PACKET_SIZE, // packetSize
|
||||
1, // inDir
|
||||
SLAB_USB_EP1OUT_USED, // splitMode
|
||||
0); // isoMod
|
||||
#endif // SLAB_USB_EP1IN_USED
|
||||
#if SLAB_USB_EP2IN_USED
|
||||
USB_ActivateEp(2, // ep
|
||||
SLAB_USB_EP2IN_MAX_PACKET_SIZE, // packetSize
|
||||
1, // inDir
|
||||
SLAB_USB_EP2OUT_USED, // splitMode
|
||||
0); // isoMod
|
||||
#endif // SLAB_USB_EP2IN_USED
|
||||
#if SLAB_USB_EP3IN_USED
|
||||
USB_ActivateEp(3, // ep
|
||||
SLAB_USB_EP3IN_MAX_PACKET_SIZE, // packetSize
|
||||
1, // inDir
|
||||
SLAB_USB_EP3OUT_USED, // splitMode
|
||||
(SLAB_USB_EP3IN_TRANSFER_TYPE == USB_EPTYPE_ISOC)); // isoMod
|
||||
#endif // SLAB_USB_EP3IN_USED
|
||||
#if SLAB_USB_EP1OUT_USED
|
||||
USB_ActivateEp(1, // ep
|
||||
SLAB_USB_EP1OUT_MAX_PACKET_SIZE, // packetSize
|
||||
0, // inDir
|
||||
SLAB_USB_EP1IN_USED, // splitMode
|
||||
0); // isoMod
|
||||
#endif // SLAB_USB_EP1OUT_USED
|
||||
#if SLAB_USB_EP2OUT_USED
|
||||
USB_ActivateEp(2, // ep
|
||||
SLAB_USB_EP2OUT_MAX_PACKET_SIZE, // packetSize
|
||||
0, // inDir
|
||||
SLAB_USB_EP2IN_USED, // splitMode
|
||||
0); // isoMod
|
||||
#endif // SLAB_USB_EP2OUT_USED
|
||||
#if SLAB_USB_EP3OUT_USED
|
||||
USB_ActivateEp(3, // ep
|
||||
SLAB_USB_EP3OUT_MAX_PACKET_SIZE, // packetSize
|
||||
0, // inDir
|
||||
SLAB_USB_EP3IN_USED, // splitMode
|
||||
(SLAB_USB_EP3OUT_TRANSFER_TYPE == USB_EPTYPE_ISOC)); // isoMod
|
||||
#endif // SLAB_USB_EP1OUT_USED
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Sets up an Endpoint 0 Write
|
||||
* @param dat
|
||||
* Data to transmit on Endpoint 0
|
||||
* @param numBytes
|
||||
* Number of bytes to transmit on Endpoint 0
|
||||
******************************************************************************/
|
||||
static void EP0_Write(SI_VARIABLE_SEGMENT_POINTER(dat, uint8_t, SI_SEG_GENERIC), uint16_t numBytes)
|
||||
{
|
||||
if (myUsbDevice.ep0.state == D_EP_IDLE)
|
||||
{
|
||||
myUsbDevice.ep0.buf = dat;
|
||||
myUsbDevice.ep0.remaining = numBytes;
|
||||
myUsbDevice.ep0.state = D_EP_TRANSMITTING;
|
||||
myUsbDevice.ep0.misc.c = 0;
|
||||
}
|
||||
}
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,687 @@
|
|||
/**************************************************************************//**
|
||||
* Copyright (c) 2015 by Silicon Laboratories Inc. All rights reserved.
|
||||
*
|
||||
* http://developer.silabs.com/legal/version/v11/Silicon_Labs_Software_License_Agreement.txt
|
||||
*****************************************************************************/
|
||||
|
||||
#include "si_toolchain.h"
|
||||
#include "efm8_usb.h"
|
||||
#include <stdint.h>
|
||||
#include <endian.h>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Global variables
|
||||
|
||||
extern SI_SEGMENT_VARIABLE(myUsbDevice, USBD_Device_TypeDef, MEM_MODEL_SEG);
|
||||
extern SI_SEGMENT_VARIABLE(txZero[2], const uint8_t, SI_SEG_CODE);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
|
||||
static void handleUsbEp0Int(void);
|
||||
static void handleUsbResetInt(void);
|
||||
static void handleUsbSuspendInt(void);
|
||||
static void handleUsbResumeInt(void);
|
||||
static void handleUsbEp0Tx(void);
|
||||
static void handleUsbEp0Rx(void);
|
||||
static void USB_ReadFIFOSetup(void);
|
||||
|
||||
#if (SLAB_USB_EP1IN_USED)
|
||||
void handleUsbIn1Int(void);
|
||||
#endif // SLAB_USB_EP1IN_USED
|
||||
#if (SLAB_USB_EP2IN_USED)
|
||||
void handleUsbIn2Int(void);
|
||||
#endif // SLAB_USB_EP2IN_USED
|
||||
#if (SLAB_USB_EP3IN_USED)
|
||||
void handleUsbIn3Int(void);
|
||||
#endif // SLAB_USB_EP3IN_USED
|
||||
|
||||
#if (SLAB_USB_EP1OUT_USED)
|
||||
void handleUsbOut1Int(void);
|
||||
#endif // SLAB_USB_EP1OUT_USED
|
||||
#if (SLAB_USB_EP2OUT_USED)
|
||||
void handleUsbOut2Int(void);
|
||||
#endif // SLAB_USB_EP2OUT_USED
|
||||
#if (SLAB_USB_EP3OUT_USED)
|
||||
void handleUsbOut3Int(void);
|
||||
#endif // SLAB_USB_EP3OUT_USED
|
||||
|
||||
void SendEp0Stall(void);
|
||||
|
||||
#if SLAB_USB_UTF8_STRINGS == 1
|
||||
static uint8_t decodeUtf8toUcs2(
|
||||
const uint8_t *pUtf8in,
|
||||
SI_VARIABLE_SEGMENT_POINTER(pUcs2out, uint16_t, MEM_MODEL_SEG));
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Functions
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief First-level handler for USB peripheral interrupt
|
||||
* @details If @ref SLAB_USB_POLLED_MODE is 1, this becomes a regular
|
||||
* function instead of an ISR and must be called by the application
|
||||
* periodically.
|
||||
******************************************************************************/
|
||||
#if (SLAB_USB_POLLED_MODE == 0)
|
||||
SI_INTERRUPT(usbIrqHandler, USB0_IRQn)
|
||||
#else
|
||||
void usbIrqHandler(void)
|
||||
#endif
|
||||
{
|
||||
uint8_t statusCommon, statusIn, statusOut, indexSave;
|
||||
|
||||
#if SLAB_USB_HANDLER_CB
|
||||
// Callback to user before processing
|
||||
USBD_EnterHandler();
|
||||
#endif
|
||||
|
||||
// Get the interrupt sources
|
||||
statusCommon = USB_GetCommonInts();
|
||||
statusIn = USB_GetInInts();
|
||||
statusOut = USB_GetOutInts();
|
||||
|
||||
#if SLAB_USB_POLLED_MODE
|
||||
if ((statusCommon == 0) && (statusIn == 0) && (statusOut == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Save the current index
|
||||
indexSave = USB_GetIndex();
|
||||
|
||||
// Check Common USB Interrupts
|
||||
if (USB_IsSofIntActive(statusCommon))
|
||||
{
|
||||
#if SLAB_USB_SOF_CB
|
||||
USBD_SofCb(USB_GetSofNumber());
|
||||
#endif // SLAB_USB_SOF_CB
|
||||
|
||||
// Check for unhandled USB packets on EP0 and set the corresponding IN or
|
||||
// OUT interrupt active flag if necessary.
|
||||
if (((myUsbDevice.ep0.misc.bits.outPacketPending == true) && (myUsbDevice.ep0.state == D_EP_RECEIVING)) ||
|
||||
((myUsbDevice.ep0.misc.bits.inPacketPending == true) && (myUsbDevice.ep0.state == D_EP_TRANSMITTING)))
|
||||
{
|
||||
USB_SetEp0IntActive(statusIn);
|
||||
}
|
||||
// Check for unhandled USB OUT packets and set the corresponding OUT
|
||||
// interrupt active flag if necessary.
|
||||
#if SLAB_USB_EP1OUT_USED
|
||||
if ((myUsbDevice.ep1out.misc.bits.outPacketPending == true) && (myUsbDevice.ep1out.state == D_EP_RECEIVING))
|
||||
{
|
||||
USB_SetOut1IntActive(statusOut);
|
||||
}
|
||||
#endif
|
||||
#if SLAB_USB_EP2OUT_USED
|
||||
if ((myUsbDevice.ep2out.misc.bits.outPacketPending == true) && (myUsbDevice.ep2out.state == D_EP_RECEIVING))
|
||||
{
|
||||
USB_SetOut2IntActive(statusOut);
|
||||
}
|
||||
#endif
|
||||
#if SLAB_USB_EP3OUT_USED
|
||||
if ((myUsbDevice.ep3out.misc.bits.outPacketPending == true) && (myUsbDevice.ep3out.state == D_EP_RECEIVING))
|
||||
{
|
||||
USB_SetOut3IntActive(statusOut);
|
||||
}
|
||||
#endif
|
||||
#if (SLAB_USB_EP3IN_USED && (SLAB_USB_EP3IN_TRANSFER_TYPE == USB_EPTYPE_ISOC))
|
||||
if ((myUsbDevice.ep3in.misc.bits.inPacketPending == true) && (myUsbDevice.ep3in.state == D_EP_TRANSMITTING))
|
||||
{
|
||||
USB_SetIn3IntActive(statusIn);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (USB_IsResetIntActive(statusCommon))
|
||||
{
|
||||
handleUsbResetInt();
|
||||
|
||||
// If VBUS is not present on detection of a USB reset, enter suspend mode.
|
||||
#if (SLAB_USB_PWRSAVE_MODE & USB_PWRSAVE_MODE_ONVBUSOFF)
|
||||
if (USB_IsVbusOn() == false)
|
||||
{
|
||||
USB_SetSuspendIntActive(statusCommon);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (USB_IsResumeIntActive(statusCommon))
|
||||
{
|
||||
handleUsbResumeInt();
|
||||
}
|
||||
|
||||
if (USB_IsSuspendIntActive(statusCommon))
|
||||
{
|
||||
handleUsbSuspendInt();
|
||||
}
|
||||
|
||||
#if SLAB_USB_EP3IN_USED
|
||||
if (USB_IsIn3IntActive(statusIn))
|
||||
{
|
||||
handleUsbIn3Int();
|
||||
}
|
||||
#endif // EP3IN_USED
|
||||
|
||||
#if SLAB_USB_EP3OUT_USED
|
||||
if (USB_IsOut3IntActive(statusOut))
|
||||
{
|
||||
handleUsbOut3Int();
|
||||
}
|
||||
#endif // EP3OUT_USED
|
||||
|
||||
#if SLAB_USB_EP2IN_USED
|
||||
if (USB_IsIn2IntActive(statusIn))
|
||||
{
|
||||
handleUsbIn2Int();
|
||||
}
|
||||
#endif // EP2IN_USED
|
||||
|
||||
#if SLAB_USB_EP1IN_USED
|
||||
if (USB_IsIn1IntActive(statusIn))
|
||||
{
|
||||
handleUsbIn1Int();
|
||||
}
|
||||
#endif // EP1IN_USED
|
||||
|
||||
#if SLAB_USB_EP2OUT_USED
|
||||
if (USB_IsOut2IntActive(statusOut))
|
||||
{
|
||||
handleUsbOut2Int();
|
||||
}
|
||||
#endif // EP2OUT_USED
|
||||
|
||||
#if SLAB_USB_EP1OUT_USED
|
||||
if (USB_IsOut1IntActive(statusOut))
|
||||
{
|
||||
handleUsbOut1Int();
|
||||
}
|
||||
#endif // EP1OUT_USED
|
||||
|
||||
// Check USB Endpoint 0 Interrupt
|
||||
if (USB_IsEp0IntActive(statusIn))
|
||||
{
|
||||
handleUsbEp0Int();
|
||||
}
|
||||
|
||||
// Restore index
|
||||
USB_SetIndex(indexSave);
|
||||
|
||||
#if SLAB_USB_HANDLER_CB
|
||||
// Callback to user before exiting
|
||||
USBD_ExitHandler();
|
||||
#endif
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Handles Endpoint 0 transfer interrupt
|
||||
******************************************************************************/
|
||||
static void handleUsbEp0Int(void)
|
||||
{
|
||||
USB_Status_TypeDef retVal = USB_STATUS_REQ_UNHANDLED;
|
||||
|
||||
USB_SetIndex(0);
|
||||
|
||||
if (USB_Ep0SentStall() || USB_GetSetupEnd())
|
||||
{
|
||||
USB_Ep0ClearSentStall();
|
||||
USB_ServicedSetupEnd();
|
||||
myUsbDevice.ep0.state = D_EP_IDLE;
|
||||
myUsbDevice.ep0.misc.c = 0;
|
||||
}
|
||||
if (USB_Ep0OutPacketReady())
|
||||
{
|
||||
if (myUsbDevice.ep0.misc.bits.waitForRead == true)
|
||||
{
|
||||
myUsbDevice.ep0.misc.bits.outPacketPending = true;
|
||||
}
|
||||
else if (myUsbDevice.ep0.state == D_EP_IDLE)
|
||||
{
|
||||
myUsbDevice.ep0String.c = USB_STRING_DESCRIPTOR_UTF16LE;
|
||||
USB_ReadFIFOSetup();
|
||||
|
||||
// Vendor unique, Class or Standard setup commands override?
|
||||
#if SLAB_USB_SETUP_CMD_CB
|
||||
retVal = USBD_SetupCmdCb(&myUsbDevice.setup);
|
||||
|
||||
if (retVal == USB_STATUS_REQ_UNHANDLED)
|
||||
{
|
||||
#endif
|
||||
if (myUsbDevice.setup.bmRequestType.Type == USB_SETUP_TYPE_STANDARD)
|
||||
{
|
||||
retVal = USBDCH9_SetupCmd();
|
||||
}
|
||||
#if SLAB_USB_SETUP_CMD_CB
|
||||
}
|
||||
#endif
|
||||
|
||||
// Reset index to 0 in case the call to USBD_SetupCmdCb() or
|
||||
// USBDCH9_SetupCmd() changed it.
|
||||
USB_SetIndex(0);
|
||||
|
||||
// Put the Enpoint 0 hardware into the correct state here.
|
||||
if (retVal == USB_STATUS_OK)
|
||||
{
|
||||
// If wLength is 0, there is no Data Phase
|
||||
// Set both the Serviced Out Packet Ready and Data End bits
|
||||
if (myUsbDevice.setup.wLength == 0)
|
||||
{
|
||||
USB_Ep0SetLastOutPacketReady();
|
||||
}
|
||||
// If wLength is non-zero, there is a Data Phase.
|
||||
// Set only the Serviced Out Packet Ready bit.
|
||||
else
|
||||
{
|
||||
USB_Ep0ServicedOutPacketReady();
|
||||
|
||||
#if SLAB_USB_SETUP_CMD_CB
|
||||
// If OUT packet but callback didn't set up a USBD_Read and we are expecting a
|
||||
// data byte then we need to wait for the read to be setup and NACK packets until
|
||||
// USBD_Read is called.
|
||||
if ((myUsbDevice.setup.bmRequestType.Direction == USB_SETUP_DIR_OUT)
|
||||
&& (myUsbDevice.ep0.state != D_EP_RECEIVING))
|
||||
{
|
||||
myUsbDevice.ep0.misc.bits.waitForRead = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
// If the setup transaction detected an error, send a stall
|
||||
else
|
||||
{
|
||||
SendEp0Stall();
|
||||
}
|
||||
}
|
||||
else if (myUsbDevice.ep0.state == D_EP_RECEIVING)
|
||||
{
|
||||
handleUsbEp0Rx();
|
||||
}
|
||||
else
|
||||
{
|
||||
myUsbDevice.ep0.misc.bits.outPacketPending = true;
|
||||
}
|
||||
}
|
||||
if ((myUsbDevice.ep0.state == D_EP_TRANSMITTING) && (USB_Ep0InPacketReady() == 0))
|
||||
{
|
||||
handleUsbEp0Tx();
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Reads and formats a setup packet
|
||||
******************************************************************************/
|
||||
static void USB_ReadFIFOSetup(void)
|
||||
{
|
||||
SI_VARIABLE_SEGMENT_POINTER(ptr, uint16_t, MEM_MODEL_SEG) = (SI_VARIABLE_SEGMENT_POINTER(, uint16_t, MEM_MODEL_SEG))&myUsbDevice.setup;
|
||||
|
||||
USB_ReadFIFO(0, 8, (SI_VARIABLE_SEGMENT_POINTER(, uint8_t, SI_SEG_GENERIC))ptr);
|
||||
|
||||
// Modify for Endian-ness of the compiler
|
||||
ptr[1] = le16toh(ptr[1]);
|
||||
ptr[2] = le16toh(ptr[2]);
|
||||
ptr[3] = le16toh(ptr[3]);
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Handles USB port reset interrupt
|
||||
* @details After receiving a USB reset, halt all endpoints except for
|
||||
* Endpoint 0, set the device state, and configure USB hardware.
|
||||
******************************************************************************/
|
||||
static void handleUsbResetInt(void)
|
||||
{
|
||||
// Setup EP0 to receive SETUP packets
|
||||
myUsbDevice.ep0.state = D_EP_IDLE;
|
||||
|
||||
// Halt all other endpoints
|
||||
#if SLAB_USB_EP1IN_USED
|
||||
myUsbDevice.ep1in.state = D_EP_HALT;
|
||||
#endif
|
||||
#if SLAB_USB_EP2IN_USED
|
||||
myUsbDevice.ep2in.state = D_EP_HALT;
|
||||
#endif
|
||||
#if SLAB_USB_EP3IN_USED
|
||||
myUsbDevice.ep3in.state = D_EP_HALT;
|
||||
#endif
|
||||
#if SLAB_USB_EP1OUT_USED
|
||||
myUsbDevice.ep1out.state = D_EP_HALT;
|
||||
#endif
|
||||
#if SLAB_USB_EP2OUT_USED
|
||||
myUsbDevice.ep2out.state = D_EP_HALT;
|
||||
#endif
|
||||
#if SLAB_USB_EP3OUT_USED
|
||||
myUsbDevice.ep3out.state = D_EP_HALT;
|
||||
#endif
|
||||
|
||||
// After a USB reset, some USB hardware configurations will be reset and must
|
||||
// be reconfigured.
|
||||
|
||||
// Re-enable clock recovery
|
||||
#if SLAB_USB_CLOCK_RECOVERY_ENABLED
|
||||
#if SLAB_USB_FULL_SPEED
|
||||
USB_EnableFullSpeedClockRecovery();
|
||||
#else
|
||||
USB_EnableLowSpeedClockRecovery();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Re-enable USB interrupts
|
||||
USB_EnableSuspendDetection();
|
||||
USB_EnableDeviceInts();
|
||||
|
||||
// If the device is bus-powered, always put it in the Default state.
|
||||
// If the device is self-powered and VBUS is present, put the device in the
|
||||
// Default state. Otherwise, put it in the Attached state.
|
||||
#if (!SLAB_USB_BUS_POWERED) && \
|
||||
(!(SLAB_USB_PWRSAVE_MODE & USB_PWRSAVE_MODE_ONVBUSOFF))
|
||||
if (USB_IsVbusOn())
|
||||
{
|
||||
USBD_SetUsbState(USBD_STATE_DEFAULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
USBD_SetUsbState(USBD_STATE_ATTACHED);
|
||||
}
|
||||
#else
|
||||
USBD_SetUsbState(USBD_STATE_DEFAULT);
|
||||
#endif // (!(SLAB_USB_PWRSAVE_MODE & USB_PWRSAVE_MODE_ONVBUSOFF))
|
||||
|
||||
#if SLAB_USB_RESET_CB
|
||||
// Make the USB Reset Callback
|
||||
USBD_ResetCb();
|
||||
#endif
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Handle USB port suspend interrupt
|
||||
* @details After receiving a USB reset, set the device state and
|
||||
* call @ref USBD_Suspend() if configured to do so in
|
||||
* @ref SLAB_USB_PWRSAVE_MODE
|
||||
******************************************************************************/
|
||||
static void handleUsbSuspendInt(void)
|
||||
{
|
||||
if (myUsbDevice.state >= USBD_STATE_POWERED)
|
||||
{
|
||||
USBD_SetUsbState(USBD_STATE_SUSPENDED);
|
||||
|
||||
#if (SLAB_USB_PWRSAVE_MODE & USB_PWRSAVE_MODE_ONSUSPEND)
|
||||
USBD_Suspend();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Handles USB port resume interrupt
|
||||
* @details Restore the device state to its previous value.
|
||||
******************************************************************************/
|
||||
static void handleUsbResumeInt(void)
|
||||
{
|
||||
USBD_SetUsbState(myUsbDevice.savedState);
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Handles transmit data phase on Endpoint 0
|
||||
******************************************************************************/
|
||||
static void handleUsbEp0Tx(void)
|
||||
{
|
||||
uint8_t count, count_snapshot, i;
|
||||
bool callback = myUsbDevice.ep0.misc.bits.callback;
|
||||
|
||||
// The number of bytes to send in the next packet must be less than or equal
|
||||
// to the maximum EP0 packet size.
|
||||
count = (myUsbDevice.ep0.remaining >= USB_EP0_SIZE) ?
|
||||
USB_EP0_SIZE : myUsbDevice.ep0.remaining;
|
||||
|
||||
// Save the packet size for future use.
|
||||
count_snapshot = count;
|
||||
|
||||
// Strings can use the USB_STRING_DESCRIPTOR_UTF16LE_PACKED type to pack
|
||||
// UTF16LE data without the zero's between each character.
|
||||
// If the current string is of type USB_STRING_DESCRIPTOR_UTF16LE_PACKED,
|
||||
// unpack it by inserting a zero between each character in the string.
|
||||
if ((myUsbDevice.ep0String.encoding.type == USB_STRING_DESCRIPTOR_UTF16LE_PACKED)
|
||||
#if SLAB_USB_UTF8_STRINGS == 1
|
||||
|| (myUsbDevice.ep0String.encoding.type == USB_STRING_DESCRIPTOR_UTF8)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
// If ep0String.encoding.init is true, this is the beginning of the string.
|
||||
// The first two bytes of the string are the bLength and bDescriptorType
|
||||
// fields. These are not packed like the reset of the string, so write them
|
||||
// to the FIFO and set ep0String.encoding.init to false.
|
||||
if (myUsbDevice.ep0String.encoding.init == true)
|
||||
{
|
||||
USB_WriteFIFO(0, 2, myUsbDevice.ep0.buf, false);
|
||||
myUsbDevice.ep0.buf += 2;
|
||||
count -= 2;
|
||||
myUsbDevice.ep0String.encoding.init = false;
|
||||
}
|
||||
|
||||
// Insert a 0x00 between each character of the string.
|
||||
for (i = 0; i < count / 2; i++)
|
||||
{
|
||||
#if SLAB_USB_UTF8_STRINGS == 1
|
||||
if (myUsbDevice.ep0String.encoding.type == USB_STRING_DESCRIPTOR_UTF8)
|
||||
{
|
||||
SI_SEGMENT_VARIABLE(ucs2, uint16_t, MEM_MODEL_SEG);
|
||||
uint8_t utf8count;
|
||||
|
||||
// decode the utf8 into ucs2 for usb string
|
||||
utf8count = decodeUtf8toUcs2(myUsbDevice.ep0.buf, &ucs2);
|
||||
|
||||
// if consumed utf8 bytes is 0, it means either null byte was
|
||||
// input or bad utf8 byte sequence. Either way its an error and
|
||||
// there's not much we can do. So just advance the input string
|
||||
// by one character and keep going until count is expired.
|
||||
if (utf8count == 0)
|
||||
{
|
||||
utf8count = 1;
|
||||
}
|
||||
|
||||
// adjust to next char in utf8 byte sequence
|
||||
myUsbDevice.ep0.buf += utf8count;
|
||||
ucs2 = htole16(ucs2); // usb 16-bit chars are little endian
|
||||
USB_WriteFIFO(0, 2, (SI_VARIABLE_SEGMENT_POINTER(, uint8_t, SI_SEG_GENERIC))&ucs2, false);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
USB_WriteFIFO(0, 1, (SI_VARIABLE_SEGMENT_POINTER(, uint8_t, SI_SEG_GENERIC))myUsbDevice.ep0.buf, false);
|
||||
myUsbDevice.ep0.buf++;
|
||||
USB_WriteFIFO(0, 1, (SI_VARIABLE_SEGMENT_POINTER(, uint8_t, SI_SEG_GENERIC))&txZero, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
// For any data other than USB_STRING_DESCRIPTOR_UTF16LE_PACKED, just send the
|
||||
// data normally.
|
||||
else
|
||||
{
|
||||
USB_WriteFIFO(0, count, myUsbDevice.ep0.buf, false);
|
||||
myUsbDevice.ep0.buf += count;
|
||||
}
|
||||
|
||||
myUsbDevice.ep0.misc.bits.inPacketPending = false;
|
||||
myUsbDevice.ep0.remaining -= count_snapshot;
|
||||
|
||||
// If the last packet of the transfer is exactly the maximum EP0 packet size,
|
||||
// we will have to send a ZLP (zero-length packet) after the last data packet
|
||||
// to signal to the host that the transfer is complete.
|
||||
// Check for the ZLP packet case here.
|
||||
if ((myUsbDevice.ep0.remaining == 0) && (count_snapshot != USB_EP0_SIZE))
|
||||
{
|
||||
USB_Ep0SetLastInPacketReady();
|
||||
myUsbDevice.ep0.state = D_EP_IDLE;
|
||||
myUsbDevice.ep0String.c = USB_STRING_DESCRIPTOR_UTF16LE;
|
||||
myUsbDevice.ep0.misc.c = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do not call USB_Ep0SetLastInPacketReady() because we still need to send
|
||||
// the ZLP.
|
||||
USB_Ep0SetInPacketReady();
|
||||
}
|
||||
// Make callback if requested
|
||||
if (callback == true)
|
||||
{
|
||||
USBD_XferCompleteCb(EP0, USB_STATUS_OK, count_snapshot, myUsbDevice.ep0.remaining);
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Handles receive data phase on Endpoint 0
|
||||
******************************************************************************/
|
||||
void handleUsbEp0Rx(void)
|
||||
{
|
||||
uint8_t count;
|
||||
USB_Status_TypeDef status;
|
||||
bool callback = myUsbDevice.ep0.misc.bits.callback;
|
||||
|
||||
// Get the number of bytes received
|
||||
count = USB_Ep0GetCount();
|
||||
|
||||
// If the call to USBD_Read() did not give a large enough buffer to hold this
|
||||
// data, set the outPacketPending flag and signal an RX overrun.
|
||||
if (myUsbDevice.ep0.remaining < count)
|
||||
{
|
||||
myUsbDevice.ep0.state = D_EP_IDLE;
|
||||
myUsbDevice.ep0.misc.bits.outPacketPending = true;
|
||||
status = USB_STATUS_EP_RX_BUFFER_OVERRUN;
|
||||
}
|
||||
else
|
||||
{
|
||||
USB_ReadFIFO(0, count, myUsbDevice.ep0.buf);
|
||||
myUsbDevice.ep0.buf += count;
|
||||
myUsbDevice.ep0.remaining -= count;
|
||||
status = USB_STATUS_OK;
|
||||
|
||||
// If the last packet of the transfer is exactly the maximum EP0 packet
|
||||
// size, we will must wait to receive a ZLP (zero-length packet) after the
|
||||
// last data packet. This signals that the host has completed the transfer.
|
||||
// Check for the ZLP packet case here.
|
||||
if ((myUsbDevice.ep0.remaining == 0) && (count != USB_EP0_SIZE))
|
||||
{
|
||||
USB_Ep0SetLastOutPacketReady();
|
||||
myUsbDevice.ep0.state = D_EP_IDLE;
|
||||
myUsbDevice.ep0.misc.bits.callback = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do not call USB_Ep0SetLastOutPacketReady() until we get the ZLP.
|
||||
USB_Ep0ServicedOutPacketReady();
|
||||
}
|
||||
}
|
||||
|
||||
// Make callback if requested
|
||||
if (callback == true)
|
||||
{
|
||||
USBD_XferCompleteCb(EP0, status, count, myUsbDevice.ep0.remaining);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************//**
|
||||
* @brief Send a procedural stall on Endpoint 0
|
||||
******************************************************************************/
|
||||
void SendEp0Stall(void)
|
||||
{
|
||||
USB_SetIndex(0);
|
||||
myUsbDevice.ep0.state = D_EP_STALL;
|
||||
USB_Ep0SendStall();
|
||||
}
|
||||
|
||||
#if SLAB_USB_UTF8_STRINGS == 1
|
||||
/***************************************************************************//**
|
||||
* Decodes UTF-8 to UCS-2 (16-bit) character encoding that is used
|
||||
* for USB string descriptors.
|
||||
*
|
||||
* @param pUtf8in pointer to next character in UTF-8 string
|
||||
* @param pUcs2out pointer to location for 16-bit character output
|
||||
*
|
||||
* Decodes a UTF-8 byte sequence into a single UCS-2 character. This
|
||||
* will only decode up to 16-bit code point and will not handle the
|
||||
* 21-bit case (4 bytes input).
|
||||
*
|
||||
* For valid cases, the UTF8 character sequence decoded into a 16-bit
|
||||
* character and stored at the location pointed at by _pUcs2out_.
|
||||
* The function will then return the number of input bytes that were
|
||||
* consumed (1, 2, or 3). The caller can use the return value to find
|
||||
* the start of the next character sequence in a utf-8 string.
|
||||
*
|
||||
* If either of the input pointers are NULL, then 0 is returned.
|
||||
*
|
||||
* If the first input character is NULL, then the output 16-bit value
|
||||
* will be set to NULL and the function will return 0.
|
||||
*
|
||||
* If any other invalid sequence is detected, then the 16-bit output
|
||||
* will be set to the equivalent of the question mark character (0x003F)
|
||||
* and the return code will be 0.
|
||||
*
|
||||
* @return count of UTF8 bytes consumed
|
||||
******************************************************************************/
|
||||
static uint8_t decodeUtf8toUcs2(
|
||||
const uint8_t *pUtf8in,
|
||||
SI_VARIABLE_SEGMENT_POINTER(pUcs2out, uint16_t, MEM_MODEL_SEG))
|
||||
{
|
||||
uint8_t ret = 0;
|
||||
|
||||
// check the input pointers
|
||||
if (!pUtf8in || !pUcs2out)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// set default decode to error '?';
|
||||
*pUcs2out = '?';
|
||||
|
||||
// valid cases:
|
||||
// 0xxxxxxx (7 bits)
|
||||
// 110xxxxx 10xxxxxx (11 bits)
|
||||
// 1110xxxx 10xxxxxx 10xxxxxx (16 bits)
|
||||
|
||||
// null input
|
||||
if (pUtf8in[0] == 0)
|
||||
{
|
||||
*pUcs2out = 0;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
// 7-bit char
|
||||
else if (pUtf8in[0] < 128)
|
||||
{
|
||||
*pUcs2out = pUtf8in[0];
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
// 11-bit char
|
||||
else if ((pUtf8in[0] & 0xE0) == 0xC0)
|
||||
{
|
||||
if ((pUtf8in[1] & 0xC0) == 0x80)
|
||||
{
|
||||
*pUcs2out = ((pUtf8in[0] & 0x1F) << 6) | (pUtf8in[1] & 0x3F);
|
||||
ret = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// 16-bit char
|
||||
else if ((pUtf8in[0] & 0xF0) == 0xE0)
|
||||
{
|
||||
if ((pUtf8in[1] & 0xC0) == 0x80)
|
||||
{
|
||||
if ((pUtf8in[2] & 0xC0) == 0x80)
|
||||
{
|
||||
*pUcs2out = ((pUtf8in[0] & 0x0F) << 12)
|
||||
| ((pUtf8in[1] & 0x3F) << 6)
|
||||
| (pUtf8in[2] & 0x3F);
|
||||
ret = 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif // SLAB_USB_UTF8_STRINGS
|
||||
|
||||
// This function is called from USBD_Init(). It forces the user project to pull
|
||||
// this module from the library so that the declared ISR can be seen and
|
||||
// included. If this is not done then this entire module by never be included
|
||||
// and the ISR will not be present.
|
||||
void forceModuleLoad_usbint(void){}
|
Plik diff jest za duży
Load Diff
|
@ -0,0 +1,238 @@
|
|||
/**************************************************************************//**
|
||||
* Copyright (c) 2015 by Silicon Laboratories Inc. All rights reserved.
|
||||
*
|
||||
* http://developer.silabs.com/legal/version/v11/Silicon_Labs_Software_License_Agreement.txt
|
||||
*****************************************************************************/
|
||||
|
||||
#include "usb_0.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/** @addtogroup usb_0_runtime USB0 Runtime API */
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Functions
|
||||
|
||||
// -------------------------------
|
||||
// Utility Functions
|
||||
|
||||
/**************************************************************************//**
|
||||
* @brief Reads a 16-bit indirect USB register value
|
||||
* @param [in] regAddr
|
||||
* Address of high byte of 16-bit USB indirect register to read
|
||||
* @return 16-bit register value
|
||||
*****************************************************************************/
|
||||
static uint16_t USB_GetShortRegister(uint8_t regAddr)
|
||||
{
|
||||
uint16_t retVal;
|
||||
|
||||
USB_READ_BYTE(regAddr);
|
||||
retVal = (USB0DAT << 8);
|
||||
USB_READ_BYTE((regAddr - 1));
|
||||
retVal |= USB0DAT;
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// USB0 Peripheral Driver Functions
|
||||
|
||||
void USB_SetIndex(uint8_t epsel)
|
||||
{
|
||||
USB_WRITE_BYTE(INDEX, epsel);
|
||||
}
|
||||
|
||||
uint8_t USB_GetCommonInts(void)
|
||||
{
|
||||
USB_READ_BYTE(CMINT);
|
||||
return USB0DAT;
|
||||
}
|
||||
|
||||
uint8_t USB_GetInInts(void)
|
||||
{
|
||||
USB_READ_BYTE(IN1INT);
|
||||
return USB0DAT;
|
||||
}
|
||||
|
||||
uint8_t USB_GetOutInts(void)
|
||||
{
|
||||
USB_READ_BYTE(OUT1INT);
|
||||
return USB0DAT;
|
||||
}
|
||||
|
||||
uint8_t USB_GetIndex(void)
|
||||
{
|
||||
USB_READ_BYTE(INDEX);
|
||||
return USB0DAT;
|
||||
}
|
||||
|
||||
bool USB_IsSuspended(void)
|
||||
{
|
||||
USB_READ_BYTE(POWER);
|
||||
return USB0DAT & POWER_SUSMD__SUSPENDED;
|
||||
}
|
||||
|
||||
bool USB_GetSetupEnd(void)
|
||||
{
|
||||
USB_READ_BYTE(E0CSR);
|
||||
return USB0DAT & E0CSR_SUEND__SET;
|
||||
}
|
||||
|
||||
bool USB_Ep0SentStall(void)
|
||||
{
|
||||
USB_READ_BYTE(E0CSR);
|
||||
return USB0DAT & E0CSR_STSTL__SET;
|
||||
}
|
||||
|
||||
bool USB_Ep0OutPacketReady(void)
|
||||
{
|
||||
USB_READ_BYTE(E0CSR);
|
||||
return USB0DAT & E0CSR_OPRDY__SET;
|
||||
}
|
||||
|
||||
bool USB_Ep0InPacketReady(void)
|
||||
{
|
||||
USB_READ_BYTE(E0CSR);
|
||||
return USB0DAT & E0CSR_INPRDY__SET;
|
||||
}
|
||||
|
||||
uint8_t USB_Ep0GetCount(void)
|
||||
{
|
||||
USB_READ_BYTE(E0CNT);
|
||||
return USB0DAT;
|
||||
}
|
||||
|
||||
bool USB_EpnInGetSentStall(void)
|
||||
{
|
||||
USB_READ_BYTE(EINCSRL);
|
||||
return (bool)(USB0DAT & EINCSRL_STSTL__SET);
|
||||
}
|
||||
|
||||
void USB_AbortInEp(uint8_t fifoNum)
|
||||
{
|
||||
USB_SetIndex(fifoNum);
|
||||
USB_EpnInFlush();
|
||||
USB_EpnInFlush();
|
||||
}
|
||||
|
||||
bool USB_EpnOutGetSentStall(void)
|
||||
{
|
||||
USB_READ_BYTE(EOUTCSRL);
|
||||
return (bool)(USB0DAT & EOUTCSRL_STSTL__SET);
|
||||
}
|
||||
|
||||
bool USB_EpnGetOutPacketReady(void)
|
||||
{
|
||||
USB_READ_BYTE(EOUTCSRL);
|
||||
return (bool)(USB0DAT & EOUTCSRL_OPRDY__SET);
|
||||
}
|
||||
|
||||
bool USB_EpnGetDataError(void)
|
||||
{
|
||||
USB_READ_BYTE(EOUTCSRL);
|
||||
return (bool)(USB0DAT & EOUTCSRL_DATERR__SET);
|
||||
}
|
||||
|
||||
uint16_t USB_EpOutGetCount(void)
|
||||
{
|
||||
return USB_GetShortRegister(EOUTCNTH);
|
||||
}
|
||||
|
||||
void USB_AbortOutEp(uint8_t fifoNum)
|
||||
{
|
||||
USB_SetIndex(fifoNum);
|
||||
USB_EpnOutFlush();
|
||||
USB_EpnOutFlush();
|
||||
}
|
||||
|
||||
void USB_ActivateEp(uint8_t ep,
|
||||
uint16_t packetSize,
|
||||
bool inDir,
|
||||
bool splitMode,
|
||||
bool isoMode)
|
||||
{
|
||||
uint8_t CSRH_mask = 0;
|
||||
uint16_t fifoSize;
|
||||
|
||||
USB_SetIndex(ep);
|
||||
|
||||
// Determine the available fifoSize for a given endpoint based on the
|
||||
// splitMode setting
|
||||
fifoSize = (splitMode == true) ? (16 << ep) : (32 << ep);
|
||||
|
||||
if (packetSize <= fifoSize)
|
||||
{
|
||||
CSRH_mask |= EINCSRH_DBIEN__ENABLED;
|
||||
}
|
||||
|
||||
if (isoMode == true)
|
||||
{
|
||||
CSRH_mask |= EINCSRH_ISO__ENABLED;
|
||||
}
|
||||
|
||||
if (inDir == true)
|
||||
{
|
||||
CSRH_mask |= EINCSRH_DIRSEL__IN;
|
||||
|
||||
if (splitMode == true)
|
||||
{
|
||||
CSRH_mask |= EINCSRH_SPLIT__ENABLED;
|
||||
}
|
||||
USB_WRITE_BYTE(EINCSRL, EINCSRL_CLRDT__BMASK);
|
||||
USB_WRITE_BYTE(EINCSRH, CSRH_mask);
|
||||
}
|
||||
else // OUT
|
||||
{
|
||||
USB_WRITE_BYTE(EOUTCSRL, EOUTCSRL_CLRDT__BMASK);
|
||||
USB_WRITE_BYTE(EOUTCSRH, CSRH_mask);
|
||||
|
||||
if (splitMode == false)
|
||||
{
|
||||
USB_WRITE_BYTE(EINCSRH, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t USB_GetSofNumber(void)
|
||||
{
|
||||
return USB_GetShortRegister(FRAMEH);
|
||||
}
|
||||
|
||||
bool USB_GetIntsEnabled(void)
|
||||
{
|
||||
SFRPAGE = PG2_PAGE;
|
||||
return (bool)(EIE2 & EIE2_EUSB0__ENABLED);
|
||||
}
|
||||
|
||||
bool USB_IsPrefetchEnabled(void)
|
||||
{
|
||||
SFRPAGE = PG2_PAGE;
|
||||
return (bool)(PFE0CN & PFE0CN_PFEN__ENABLED);
|
||||
}
|
||||
|
||||
bool USB_IsRegulatorEnabled(void)
|
||||
{
|
||||
SFRPAGE = PG3_PAGE;
|
||||
return !(REG1CN & REG1CN_REG1ENB__DISABLED);
|
||||
}
|
||||
|
||||
void USB_SuspendOscillator(void)
|
||||
{
|
||||
uint8_t clkSelSave = CLKSEL & 0x7F;
|
||||
|
||||
CLKSEL = (CLKSEL_CLKDIV__SYSCLK_DIV_8 | CLKSEL_CLKSL__HFOSC0);
|
||||
SFRPAGE = LEGACY_PAGE;
|
||||
PCON1 |= PCON1_SUSPEND__SUSPEND;
|
||||
CLKSEL = clkSelSave;
|
||||
|
||||
// If the target frequency is over 24MHz, our write to CLKSEL will be ignored.
|
||||
// If this is the case we need to do two writes: one to 24 MHz followed by the
|
||||
// actual value.
|
||||
if ((CLKSEL & 0x7F) != clkSelSave)
|
||||
{
|
||||
CLKSEL = (CLKSEL_CLKDIV__SYSCLK_DIV_1 | CLKSEL_CLKSL__HFOSC0);
|
||||
CLKSEL = clkSelSave;
|
||||
}
|
||||
}
|
||||
|
||||
/** @} (end addtogroup usb_0_runtime USB0 Runtime API) */
|
|
@ -0,0 +1,366 @@
|
|||
//=========================================================
|
||||
// src/InitDevice.c: generated by Hardware Configurator
|
||||
//
|
||||
// This file will be regenerated when saving a document.
|
||||
// leave the sections inside the "$[...]" comment tags alone
|
||||
// or they will be overwritten!
|
||||
//=========================================================
|
||||
|
||||
// USER INCLUDES
|
||||
#include <SI_EFM8UB1_Register_Enums.h>
|
||||
#include "InitDevice.h"
|
||||
|
||||
// USER PROTOTYPES
|
||||
// USER FUNCTIONS
|
||||
|
||||
// $[Library Includes]
|
||||
#include "efm8_usb.h"
|
||||
#include "descriptors.h"
|
||||
#include "usb_0.h"
|
||||
// [Library Includes]$
|
||||
|
||||
//==============================================================================
|
||||
// enter_DefaultMode_from_RESET
|
||||
//==============================================================================
|
||||
extern void enter_DefaultMode_from_RESET(void) {
|
||||
// $[Config Calls]
|
||||
// Save the SFRPAGE
|
||||
uint8_t SFRPAGE_save = SFRPAGE;
|
||||
WDT_0_enter_DefaultMode_from_RESET();
|
||||
PORTS_0_enter_DefaultMode_from_RESET();
|
||||
PBCFG_0_enter_DefaultMode_from_RESET();
|
||||
CIP51_0_enter_DefaultMode_from_RESET();
|
||||
CLOCK_0_enter_DefaultMode_from_RESET();
|
||||
TIMER16_2_enter_DefaultMode_from_RESET();
|
||||
TIMER16_3_enter_DefaultMode_from_RESET();
|
||||
TIMER_SETUP_0_enter_DefaultMode_from_RESET();
|
||||
UARTE_1_enter_DefaultMode_from_RESET();
|
||||
INTERRUPT_0_enter_DefaultMode_from_RESET();
|
||||
USBLIB_0_enter_DefaultMode_from_RESET();
|
||||
// Restore the SFRPAGE
|
||||
SFRPAGE = SFRPAGE_save;
|
||||
// [Config Calls]$
|
||||
|
||||
}
|
||||
|
||||
extern void INTERRUPT_0_enter_DefaultMode_from_RESET(void) {
|
||||
// $[EIE1 - Extended Interrupt Enable 1]
|
||||
// [EIE1 - Extended Interrupt Enable 1]$
|
||||
|
||||
// $[EIE2 - Extended Interrupt Enable 2]
|
||||
// [EIE2 - Extended Interrupt Enable 2]$
|
||||
|
||||
// $[EIP1H - Extended Interrupt Priority 1 High]
|
||||
// [EIP1H - Extended Interrupt Priority 1 High]$
|
||||
|
||||
// $[EIP1 - Extended Interrupt Priority 1 Low]
|
||||
// [EIP1 - Extended Interrupt Priority 1 Low]$
|
||||
|
||||
// $[EIP2 - Extended Interrupt Priority 2]
|
||||
// [EIP2 - Extended Interrupt Priority 2]$
|
||||
|
||||
// $[EIP2H - Extended Interrupt Priority 2 High]
|
||||
// [EIP2H - Extended Interrupt Priority 2 High]$
|
||||
|
||||
// $[IE - Interrupt Enable]
|
||||
/***********************************************************************
|
||||
- Enable each interrupt according to its individual mask setting
|
||||
- Disable external interrupt 0
|
||||
- Disable external interrupt 1
|
||||
- Disable all SPI0 interrupts
|
||||
- Disable all Timer 0 interrupt
|
||||
- Disable all Timer 1 interrupt
|
||||
- Disable Timer 2 interrupt
|
||||
- Disable UART0 interrupt
|
||||
***********************************************************************/
|
||||
SFRPAGE = 0x00;
|
||||
IE = IE_EA__ENABLED | IE_EX0__DISABLED | IE_EX1__DISABLED
|
||||
| IE_ESPI0__DISABLED | IE_ET0__DISABLED | IE_ET1__DISABLED
|
||||
| IE_ET2__DISABLED | IE_ES0__DISABLED;
|
||||
// [IE - Interrupt Enable]$
|
||||
|
||||
// $[IP - Interrupt Priority]
|
||||
// [IP - Interrupt Priority]$
|
||||
|
||||
// $[IPH - Interrupt Priority High]
|
||||
// [IPH - Interrupt Priority High]$
|
||||
|
||||
}
|
||||
|
||||
extern void USBLIB_0_enter_DefaultMode_from_RESET(void) {
|
||||
// $[USBD Init]
|
||||
USBD_Init (&initstruct);
|
||||
// [USBD Init]$
|
||||
|
||||
}
|
||||
|
||||
extern void CLOCK_0_enter_DefaultMode_from_RESET(void) {
|
||||
// $[HFOSC1 Setup]
|
||||
// Ensure SYSCLK is > 24 MHz before switching to HFOSC1
|
||||
SFRPAGE = 0x00;
|
||||
CLKSEL = CLKSEL_CLKSL__HFOSC0 | CLKSEL_CLKDIV__SYSCLK_DIV_1;
|
||||
while ((CLKSEL & CLKSEL_DIVRDY__BMASK) == CLKSEL_DIVRDY__NOT_READY)
|
||||
;
|
||||
// [HFOSC1 Setup]$
|
||||
|
||||
// $[CLKSEL - Clock Select]
|
||||
/***********************************************************************
|
||||
- Clock derived from the Internal High Frequency Oscillator 1
|
||||
- SYSCLK is equal to selected clock source divided by 1
|
||||
***********************************************************************/
|
||||
CLKSEL = CLKSEL_CLKSL__HFOSC1 | CLKSEL_CLKDIV__SYSCLK_DIV_1;
|
||||
while ((CLKSEL & CLKSEL_DIVRDY__BMASK) == CLKSEL_DIVRDY__NOT_READY)
|
||||
;
|
||||
// [CLKSEL - Clock Select]$
|
||||
|
||||
}
|
||||
|
||||
extern void WDT_0_enter_DefaultMode_from_RESET(void) {
|
||||
// $[WDTCN - Watchdog Timer Control]
|
||||
SFRPAGE = 0x00;
|
||||
//Disable Watchdog with key sequence
|
||||
WDTCN = 0xDE; //First key
|
||||
WDTCN = 0xAD; //Second key
|
||||
// [WDTCN - Watchdog Timer Control]$
|
||||
|
||||
}
|
||||
|
||||
extern void CIP51_0_enter_DefaultMode_from_RESET(void) {
|
||||
// $[PFE0CN - Prefetch Engine Control]
|
||||
/***********************************************************************
|
||||
- Enable the prefetch engine
|
||||
- SYSCLK < 50 MHz
|
||||
***********************************************************************/
|
||||
SFRPAGE = 0x10;
|
||||
PFE0CN = PFE0CN_PFEN__ENABLED | PFE0CN_FLRT__SYSCLK_BELOW_50_MHZ;
|
||||
// [PFE0CN - Prefetch Engine Control]$
|
||||
|
||||
}
|
||||
|
||||
extern void PBCFG_0_enter_DefaultMode_from_RESET(void) {
|
||||
// $[XBR2 - Port I/O Crossbar 2]
|
||||
/***********************************************************************
|
||||
- Weak Pullups enabled
|
||||
- Crossbar enabled
|
||||
- UART1 TX1 RX1 routed to Port pins
|
||||
- UART1 RTS1 unavailable at Port pin
|
||||
- UART1 CTS1 unavailable at Port pin
|
||||
***********************************************************************/
|
||||
XBR2 = XBR2_WEAKPUD__PULL_UPS_ENABLED | XBR2_XBARE__ENABLED
|
||||
| XBR2_URT1E__ENABLED | XBR2_URT1RTSE__DISABLED
|
||||
| XBR2_URT1CTSE__DISABLED;
|
||||
// [XBR2 - Port I/O Crossbar 2]$
|
||||
|
||||
// $[PRTDRV - Port Drive Strength]
|
||||
// [PRTDRV - Port Drive Strength]$
|
||||
|
||||
// $[XBR0 - Port I/O Crossbar 0]
|
||||
// [XBR0 - Port I/O Crossbar 0]$
|
||||
|
||||
// $[XBR1 - Port I/O Crossbar 1]
|
||||
// [XBR1 - Port I/O Crossbar 1]$
|
||||
|
||||
}
|
||||
|
||||
extern void TIMER_SETUP_0_enter_DefaultMode_from_RESET(void) {
|
||||
// $[CKCON0 - Clock Control 0]
|
||||
/***********************************************************************
|
||||
- System clock divided by 12
|
||||
- Counter/Timer 0 uses the clock defined by the prescale field, SCA
|
||||
- Timer 2 high byte uses the clock defined by T2XCLK in TMR2CN0
|
||||
- Timer 2 low byte uses the system clock
|
||||
- Timer 3 high byte uses the clock defined by T3XCLK in TMR3CN0
|
||||
- Timer 3 low byte uses the system clock
|
||||
- Timer 1 uses the clock defined by the prescale field, SCA
|
||||
***********************************************************************/
|
||||
CKCON0 = CKCON0_SCA__SYSCLK_DIV_12 | CKCON0_T0M__PRESCALE
|
||||
| CKCON0_T2MH__EXTERNAL_CLOCK | CKCON0_T2ML__SYSCLK
|
||||
| CKCON0_T3MH__EXTERNAL_CLOCK | CKCON0_T3ML__SYSCLK
|
||||
| CKCON0_T1M__PRESCALE;
|
||||
// [CKCON0 - Clock Control 0]$
|
||||
|
||||
// $[CKCON1 - Clock Control 1]
|
||||
// [CKCON1 - Clock Control 1]$
|
||||
|
||||
// $[TMOD - Timer 0/1 Mode]
|
||||
// [TMOD - Timer 0/1 Mode]$
|
||||
|
||||
// $[TCON - Timer 0/1 Control]
|
||||
// [TCON - Timer 0/1 Control]$
|
||||
|
||||
}
|
||||
|
||||
extern void UARTE_1_enter_DefaultMode_from_RESET(void) {
|
||||
// $[SBCON1 - UART1 Baud Rate Generator Control]
|
||||
/***********************************************************************
|
||||
- Enable the baud rate generator
|
||||
- Prescaler = 1
|
||||
***********************************************************************/
|
||||
SFRPAGE = 0x20;
|
||||
SBCON1 = SBCON1_BREN__ENABLED | SBCON1_BPS__DIV_BY_1;
|
||||
// [SBCON1 - UART1 Baud Rate Generator Control]$
|
||||
|
||||
// $[SMOD1 - UART1 Mode]
|
||||
// [SMOD1 - UART1 Mode]$
|
||||
|
||||
// $[UART1FCN0 - UART1 FIFO Control 0]
|
||||
// [UART1FCN0 - UART1 FIFO Control 0]$
|
||||
|
||||
// $[SBRLH1 - UART1 Baud Rate Generator High Byte]
|
||||
/***********************************************************************
|
||||
- UART1 Baud Rate Reload High = 0xFF
|
||||
***********************************************************************/
|
||||
SBRLH1 = (0xFF << SBRLH1_BRH__SHIFT);
|
||||
// [SBRLH1 - UART1 Baud Rate Generator High Byte]$
|
||||
|
||||
// $[SBRLL1 - UART1 Baud Rate Generator Low Byte]
|
||||
/***********************************************************************
|
||||
- UART1 Baud Rate Reload Low = 0x30
|
||||
***********************************************************************/
|
||||
SBRLL1 = (0x30 << SBRLL1_BRL__SHIFT);
|
||||
// [SBRLL1 - UART1 Baud Rate Generator Low Byte]$
|
||||
|
||||
// $[UART1LIN - UART1 LIN Configuration]
|
||||
// [UART1LIN - UART1 LIN Configuration]$
|
||||
|
||||
// $[SCON1 - UART1 Serial Port Control]
|
||||
/***********************************************************************
|
||||
- UART1 reception enabled
|
||||
***********************************************************************/
|
||||
SCON1 |= SCON1_REN__RECEIVE_ENABLED;
|
||||
// [SCON1 - UART1 Serial Port Control]$
|
||||
|
||||
// $[UART1FCN1 - UART1 FIFO Control 1]
|
||||
// [UART1FCN1 - UART1 FIFO Control 1]$
|
||||
|
||||
}
|
||||
|
||||
extern void TIMER16_2_enter_DefaultMode_from_RESET(void) {
|
||||
// $[Timer Initialization]
|
||||
// Save Timer Configuration
|
||||
uint8_t TMR2CN0_TR2_save;
|
||||
TMR2CN0_TR2_save = TMR2CN0 & TMR2CN0_TR2__BMASK;
|
||||
// Stop Timer
|
||||
TMR2CN0 &= ~(TMR2CN0_TR2__BMASK);
|
||||
// [Timer Initialization]$
|
||||
|
||||
// $[TMR2CN1 - Timer 2 Control 1]
|
||||
// [TMR2CN1 - Timer 2 Control 1]$
|
||||
|
||||
// $[TMR2CN0 - Timer 2 Control]
|
||||
// [TMR2CN0 - Timer 2 Control]$
|
||||
|
||||
// $[TMR2H - Timer 2 High Byte]
|
||||
// [TMR2H - Timer 2 High Byte]$
|
||||
|
||||
// $[TMR2L - Timer 2 Low Byte]
|
||||
// [TMR2L - Timer 2 Low Byte]$
|
||||
|
||||
// $[TMR2RLH - Timer 2 Reload High Byte]
|
||||
/***********************************************************************
|
||||
- Timer 2 Reload High Byte = 0x44
|
||||
***********************************************************************/
|
||||
TMR2RLH = (0x44 << TMR2RLH_TMR2RLH__SHIFT);
|
||||
// [TMR2RLH - Timer 2 Reload High Byte]$
|
||||
|
||||
// $[TMR2RLL - Timer 2 Reload Low Byte]
|
||||
/***********************************************************************
|
||||
- Timer 2 Reload Low Byte = 0x80
|
||||
***********************************************************************/
|
||||
TMR2RLL = (0x80 << TMR2RLL_TMR2RLL__SHIFT);
|
||||
// [TMR2RLL - Timer 2 Reload Low Byte]$
|
||||
|
||||
// $[TMR2CN0]
|
||||
/***********************************************************************
|
||||
- Start Timer 2 running
|
||||
***********************************************************************/
|
||||
TMR2CN0 |= TMR2CN0_TR2__RUN;
|
||||
// [TMR2CN0]$
|
||||
|
||||
// $[Timer Restoration]
|
||||
// Restore Timer Configuration
|
||||
TMR2CN0 |= TMR2CN0_TR2_save;
|
||||
// [Timer Restoration]$
|
||||
|
||||
}
|
||||
|
||||
extern void TIMER16_3_enter_DefaultMode_from_RESET(void) {
|
||||
// $[Timer Initialization]
|
||||
// Save Timer Configuration
|
||||
uint8_t TMR3CN0_TR3_save;
|
||||
TMR3CN0_TR3_save = TMR3CN0 & TMR3CN0_TR3__BMASK;
|
||||
// Stop Timer
|
||||
TMR3CN0 &= ~(TMR3CN0_TR3__BMASK);
|
||||
// [Timer Initialization]$
|
||||
|
||||
// $[TMR3CN1 - Timer 3 Control 1]
|
||||
// [TMR3CN1 - Timer 3 Control 1]$
|
||||
|
||||
// $[TMR3CN0 - Timer 3 Control]
|
||||
// [TMR3CN0 - Timer 3 Control]$
|
||||
|
||||
// $[TMR3H - Timer 3 High Byte]
|
||||
// [TMR3H - Timer 3 High Byte]$
|
||||
|
||||
// $[TMR3L - Timer 3 Low Byte]
|
||||
// [TMR3L - Timer 3 Low Byte]$
|
||||
|
||||
// $[TMR3RLH - Timer 3 Reload High Byte]
|
||||
// [TMR3RLH - Timer 3 Reload High Byte]$
|
||||
|
||||
// $[TMR3RLL - Timer 3 Reload Low Byte]
|
||||
// [TMR3RLL - Timer 3 Reload Low Byte]$
|
||||
|
||||
// $[TMR3CN0]
|
||||
// [TMR3CN0]$
|
||||
|
||||
// $[Timer Restoration]
|
||||
// Restore Timer Configuration
|
||||
TMR3CN0 |= TMR3CN0_TR3_save;
|
||||
// [Timer Restoration]$
|
||||
|
||||
}
|
||||
|
||||
extern void PORTS_0_enter_DefaultMode_from_RESET(void) {
|
||||
// $[P0 - Port 0 Pin Latch]
|
||||
// [P0 - Port 0 Pin Latch]$
|
||||
|
||||
// $[P0MDOUT - Port 0 Output Mode]
|
||||
/***********************************************************************
|
||||
- P0.0 output is push-pull
|
||||
- P0.1 output is open-drain
|
||||
- P0.2 output is open-drain
|
||||
- P0.3 output is open-drain
|
||||
- P0.4 output is open-drain
|
||||
- P0.5 output is open-drain
|
||||
- P0.6 output is open-drain
|
||||
- P0.7 output is open-drain
|
||||
***********************************************************************/
|
||||
P0MDOUT = P0MDOUT_B0__PUSH_PULL | P0MDOUT_B1__OPEN_DRAIN
|
||||
| P0MDOUT_B2__OPEN_DRAIN | P0MDOUT_B3__OPEN_DRAIN
|
||||
| P0MDOUT_B4__OPEN_DRAIN | P0MDOUT_B5__OPEN_DRAIN
|
||||
| P0MDOUT_B6__OPEN_DRAIN | P0MDOUT_B7__OPEN_DRAIN;
|
||||
// [P0MDOUT - Port 0 Output Mode]$
|
||||
|
||||
// $[P0MDIN - Port 0 Input Mode]
|
||||
// [P0MDIN - Port 0 Input Mode]$
|
||||
|
||||
// $[P0SKIP - Port 0 Skip]
|
||||
// [P0SKIP - Port 0 Skip]$
|
||||
|
||||
// $[P0MASK - Port 0 Mask]
|
||||
// [P0MASK - Port 0 Mask]$
|
||||
|
||||
// $[P0MAT - Port 0 Match]
|
||||
// [P0MAT - Port 0 Match]$
|
||||
|
||||
}
|
||||
|
||||
extern void PORTS_1_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
}
|
||||
|
||||
extern void PORTS_2_enter_DefaultMode_from_RESET(void) {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,203 @@
|
|||
$NOMOD51
|
||||
;------------------------------------------------------------------------------
|
||||
; This file is part of the C51 Compiler package
|
||||
; Copyright (c) 1988-2005 Keil Elektronik GmbH and Keil Software, Inc.
|
||||
; Version 8.01
|
||||
;
|
||||
; *** <<< Use Configuration Wizard in Context Menu >>> ***
|
||||
;------------------------------------------------------------------------------
|
||||
; STARTUP.A51: This code is executed after processor reset.
|
||||
;
|
||||
; To translate this file use A51 with the following invocation:
|
||||
;
|
||||
; A51 STARTUP.A51
|
||||
;
|
||||
; To link the modified STARTUP.OBJ file to your application use the following
|
||||
; Lx51 invocation:
|
||||
;
|
||||
; Lx51 your object file list, STARTUP.OBJ controls
|
||||
;
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; User-defined <h> Power-On Initialization of Memory
|
||||
;
|
||||
; With the following EQU statements the initialization of memory
|
||||
; at processor reset can be defined:
|
||||
;
|
||||
; <o> IDATALEN: IDATA memory size <0x0-0x100>
|
||||
; <i> Note: The absolute start-address of IDATA memory is always 0
|
||||
; <i> The IDATA space overlaps physically the DATA and BIT areas.
|
||||
IDATALEN EQU 80H
|
||||
;
|
||||
; <o> XDATASTART: XDATA memory start address <0x0-0xFFFF>
|
||||
; <i> The absolute start address of XDATA memory
|
||||
XDATASTART EQU 0
|
||||
;
|
||||
; <o> XDATALEN: XDATA memory size <0x0-0xFFFF>
|
||||
; <i> The length of XDATA memory in bytes.
|
||||
XDATALEN EQU 0
|
||||
;
|
||||
; <o> PDATASTART: PDATA memory start address <0x0-0xFFFF>
|
||||
; <i> The absolute start address of PDATA memory
|
||||
PDATASTART EQU 0H
|
||||
;
|
||||
; <o> PDATALEN: PDATA memory size <0x0-0xFF>
|
||||
; <i> The length of PDATA memory in bytes.
|
||||
PDATALEN EQU 0H
|
||||
;
|
||||
;</h>
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
;<h> Reentrant Stack Initialization
|
||||
;
|
||||
; The following EQU statements define the stack pointer for reentrant
|
||||
; functions and initialized it:
|
||||
;
|
||||
; <h> Stack Space for reentrant functions in the SMALL model.
|
||||
; <q> IBPSTACK: Enable SMALL model reentrant stack
|
||||
; <i> Stack space for reentrant functions in the SMALL model.
|
||||
IBPSTACK EQU 0 ; set to 1 if small reentrant is used.
|
||||
; <o> IBPSTACKTOP: End address of SMALL model stack <0x0-0xFF>
|
||||
; <i> Set the top of the stack to the highest location.
|
||||
IBPSTACKTOP EQU 0xFF +1 ; default 0FFH+1
|
||||
; </h>
|
||||
;
|
||||
; <h> Stack Space for reentrant functions in the LARGE model.
|
||||
; <q> XBPSTACK: Enable LARGE model reentrant stack
|
||||
; <i> Stack space for reentrant functions in the LARGE model.
|
||||
XBPSTACK EQU 0 ; set to 1 if large reentrant is used.
|
||||
; <o> XBPSTACKTOP: End address of LARGE model stack <0x0-0xFFFF>
|
||||
; <i> Set the top of the stack to the highest location.
|
||||
XBPSTACKTOP EQU 0xFFFF +1 ; default 0FFFFH+1
|
||||
; </h>
|
||||
;
|
||||
; <h> Stack Space for reentrant functions in the COMPACT model.
|
||||
; <q> PBPSTACK: Enable COMPACT model reentrant stack
|
||||
; <i> Stack space for reentrant functions in the COMPACT model.
|
||||
PBPSTACK EQU 0 ; set to 1 if compact reentrant is used.
|
||||
;
|
||||
; <o> PBPSTACKTOP: End address of COMPACT model stack <0x0-0xFFFF>
|
||||
; <i> Set the top of the stack to the highest location.
|
||||
PBPSTACKTOP EQU 0xFF +1 ; default 0FFH+1
|
||||
; </h>
|
||||
;</h>
|
||||
;------------------------------------------------------------------------------
|
||||
;
|
||||
; Memory Page for Using the Compact Model with 64 KByte xdata RAM
|
||||
; <e>Compact Model Page Definition
|
||||
;
|
||||
; <i>Define the XDATA page used for PDATA variables.
|
||||
; <i>PPAGE must conform with the PPAGE set in the linker invocation.
|
||||
;
|
||||
; Enable pdata memory page initalization
|
||||
PPAGEENABLE EQU 0 ; set to 1 if pdata object are used.
|
||||
;
|
||||
; <o> PPAGE number <0x0-0xFF>
|
||||
; <i> uppermost 256-byte address of the page used for PDATA variables.
|
||||
PPAGE EQU 0
|
||||
;
|
||||
; <o> SFR address which supplies uppermost address byte <0x0-0xFF>
|
||||
; <i> most 8051 variants use P2 as uppermost address byte
|
||||
PPAGE_SFR DATA 0A0H
|
||||
;
|
||||
; </e>
|
||||
;------------------------------------------------------------------------------
|
||||
|
||||
; Standard SFR Symbols
|
||||
ACC DATA 0E0H
|
||||
B DATA 0F0H
|
||||
SP DATA 81H
|
||||
DPL DATA 82H
|
||||
DPH DATA 83H
|
||||
|
||||
NAME ?C_STARTUP
|
||||
|
||||
|
||||
?C_C51STARTUP SEGMENT CODE
|
||||
?STACK SEGMENT IDATA
|
||||
|
||||
RSEG ?STACK
|
||||
DS 1
|
||||
|
||||
EXTRN CODE (?C_START)
|
||||
PUBLIC ?C_STARTUP
|
||||
|
||||
CSEG AT 0
|
||||
?C_STARTUP: LJMP STARTUP1
|
||||
|
||||
RSEG ?C_C51STARTUP
|
||||
|
||||
STARTUP1:
|
||||
|
||||
$IF (SILABS_STARTUP = 1)
|
||||
EXTRN CODE (SiLabs_Startup)
|
||||
LCALL SiLabs_Startup
|
||||
$ENDIF
|
||||
|
||||
IF IDATALEN <> 0
|
||||
MOV R0,#IDATALEN - 1
|
||||
CLR A
|
||||
IDATALOOP: MOV @R0,A
|
||||
DJNZ R0,IDATALOOP
|
||||
ENDIF
|
||||
|
||||
IF XDATALEN <> 0
|
||||
MOV DPTR,#XDATASTART
|
||||
MOV R7,#LOW (XDATALEN)
|
||||
IF (LOW (XDATALEN)) <> 0
|
||||
MOV R6,#(HIGH (XDATALEN)) +1
|
||||
ELSE
|
||||
MOV R6,#HIGH (XDATALEN)
|
||||
ENDIF
|
||||
CLR A
|
||||
XDATALOOP: MOVX @DPTR,A
|
||||
INC DPTR
|
||||
DJNZ R7,XDATALOOP
|
||||
DJNZ R6,XDATALOOP
|
||||
ENDIF
|
||||
|
||||
IF PPAGEENABLE <> 0
|
||||
MOV PPAGE_SFR,#PPAGE
|
||||
ENDIF
|
||||
|
||||
IF PDATALEN <> 0
|
||||
MOV R0,#LOW (PDATASTART)
|
||||
MOV R7,#LOW (PDATALEN)
|
||||
CLR A
|
||||
PDATALOOP: MOVX @R0,A
|
||||
INC R0
|
||||
DJNZ R7,PDATALOOP
|
||||
ENDIF
|
||||
|
||||
IF IBPSTACK <> 0
|
||||
EXTRN DATA (?C_IBP)
|
||||
|
||||
MOV ?C_IBP,#LOW IBPSTACKTOP
|
||||
ENDIF
|
||||
|
||||
IF XBPSTACK <> 0
|
||||
EXTRN DATA (?C_XBP)
|
||||
|
||||
MOV ?C_XBP,#HIGH XBPSTACKTOP
|
||||
MOV ?C_XBP+1,#LOW XBPSTACKTOP
|
||||
ENDIF
|
||||
|
||||
IF PBPSTACK <> 0
|
||||
EXTRN DATA (?C_PBP)
|
||||
MOV ?C_PBP,#LOW PBPSTACKTOP
|
||||
ENDIF
|
||||
|
||||
MOV SP,#?STACK-1
|
||||
|
||||
; This code is required if you use L51_BANK.A51 with Banking Mode 4
|
||||
;<h> Code Banking
|
||||
; <q> Select Bank 0 for L51_BANK.A51 Mode 4
|
||||
$IF (USE_BANKING = 1)
|
||||
; <i> Initialize bank mechanism to code bank 0 when using L51_BANK.A51 with Banking Mode 4.
|
||||
EXTRN CODE (?B_SWITCH0)
|
||||
CALL ?B_SWITCH0 ; init bank mechanism to code bank 0
|
||||
$ENDIF
|
||||
;</h>
|
||||
LJMP ?C_START
|
||||
|
||||
END
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Conor Patrick
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
*/
|
||||
#include <SI_EFM8UB1_Register_Enums.h>
|
||||
#include <efm8_usb.h>
|
||||
#include <stdio.h>
|
||||
#include "descriptors.h"
|
||||
|
||||
#define UNUSED(expr) do { (void)(expr); } while (0)
|
||||
|
||||
#define HID_INTERFACE_INDEX 0
|
||||
|
||||
uint8_t tmpBuffer;
|
||||
|
||||
|
||||
|
||||
void USBD_ResetCb(void) {
|
||||
// u2f_print_ev("USBD_ResetCb\r\n");
|
||||
}
|
||||
|
||||
|
||||
void USBD_DeviceStateChangeCb(USBD_State_TypeDef oldState,
|
||||
USBD_State_TypeDef newState) {
|
||||
|
||||
UNUSED(oldState);
|
||||
UNUSED(newState);
|
||||
|
||||
// u2f_print_ev("USBD_DeviceStateChangeCb\r\n");
|
||||
}
|
||||
|
||||
bool USBD_IsSelfPoweredCb(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Necessary routine for USB HID
|
||||
USB_Status_TypeDef USBD_SetupCmdCb(
|
||||
SI_VARIABLE_SEGMENT_POINTER(setup, USB_Setup_TypeDef, MEM_MODEL_SEG)) {
|
||||
|
||||
USB_Status_TypeDef retVal = USB_STATUS_REQ_UNHANDLED;
|
||||
|
||||
|
||||
if ((setup->bmRequestType.Type == USB_SETUP_TYPE_STANDARD)
|
||||
&& (setup->bmRequestType.Direction == USB_SETUP_DIR_IN)
|
||||
&& (setup->bmRequestType.Recipient == USB_SETUP_RECIPIENT_INTERFACE)) {
|
||||
// A HID device must extend the standard GET_DESCRIPTOR command
|
||||
// with support for HID descriptors.
|
||||
|
||||
switch (setup->bRequest) {
|
||||
case GET_DESCRIPTOR:
|
||||
if (setup->wIndex == 0)
|
||||
{
|
||||
if ((setup->wValue >> 8) == USB_HID_REPORT_DESCRIPTOR) {
|
||||
|
||||
USBD_Write(EP0, ReportDescriptor0,
|
||||
EFM8_MIN(sizeof(ReportDescriptor0), setup->wLength),
|
||||
false);
|
||||
retVal = USB_STATUS_OK;
|
||||
|
||||
} else if ((setup->wValue >> 8) == USB_HID_DESCRIPTOR) {
|
||||
|
||||
USBD_Write(EP0, (&configDesc[18]),
|
||||
EFM8_MIN(USB_HID_DESCSIZE, setup->wLength), false);
|
||||
retVal = USB_STATUS_OK;
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ((setup->bmRequestType.Type == USB_SETUP_TYPE_CLASS)
|
||||
&& (setup->bmRequestType.Recipient == USB_SETUP_RECIPIENT_INTERFACE)
|
||||
&& (setup->wIndex == HID_INTERFACE_INDEX))
|
||||
{
|
||||
// Implement the necessary HID class specific commands.
|
||||
switch (setup->bRequest)
|
||||
{
|
||||
case USB_HID_SET_IDLE:
|
||||
if (((setup->wValue & 0xFF) == 0) // Report ID
|
||||
&& (setup->wLength == 0)
|
||||
&& (setup->bmRequestType.Direction != USB_SETUP_DIR_IN))
|
||||
{
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
|
||||
case USB_HID_GET_IDLE:
|
||||
if ((setup->wValue == 0) // Report ID
|
||||
&& (setup->wLength == 1)
|
||||
&& (setup->bmRequestType.Direction == USB_SETUP_DIR_IN))
|
||||
{
|
||||
tmpBuffer = 24;
|
||||
USBD_Write(EP0, &tmpBuffer, 1, false);
|
||||
retVal = USB_STATUS_OK;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
uint8_t hidmsgbuf[64];
|
||||
uint16_t USBD_XferCompleteCb(uint8_t epAddr, USB_Status_TypeDef status,
|
||||
uint16_t xferred, uint16_t remaining ) {
|
||||
|
||||
UNUSED(status);
|
||||
UNUSED(xferred);
|
||||
UNUSED(remaining);
|
||||
|
||||
|
||||
if (epAddr == EP1OUT)
|
||||
{
|
||||
// set_app_u2f_hid_msg((struct u2f_hid_msg *) hidmsgbuf );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
//=============================================================================
|
||||
// src/descriptors.c: generated by Hardware Configurator
|
||||
//
|
||||
// This file is only generated if it does not exist. Modifications in this file
|
||||
// will persist even if Configurator generates code. To refresh this file,
|
||||
// you must first delete it and then regenerate code.
|
||||
//=============================================================================
|
||||
//-----------------------------------------------------------------------------
|
||||
// Includes
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <si_toolchain.h>
|
||||
#include <endian.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <efm8_usb.h>
|
||||
#include "descriptors.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// HID Report Descriptor for Interface 0
|
||||
SI_SEGMENT_VARIABLE(ReportDescriptor0[34],
|
||||
const uint8_t,
|
||||
SI_SEG_CODE) =
|
||||
{
|
||||
|
||||
0x06, 0xd0, 0xf1,// USAGE_PAGE (FIDO Alliance)
|
||||
0x09, 0x01,// USAGE (Keyboard)
|
||||
0xa1, 0x01,// COLLECTION (Application)
|
||||
|
||||
0x09, 0x20, // USAGE (Input Report Data)
|
||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
|
||||
0x75, 0x08, // REPORT_SIZE (8)
|
||||
0x95, HID_PACKET_SIZE, // REPORT_COUNT (64)
|
||||
0x81, 0x02, // INPUT (Data,Var,Abs)
|
||||
0x09, 0x21, // USAGE(Output Report Data)
|
||||
0x15, 0x00, // LOGICAL_MINIMUM (0)
|
||||
0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255)
|
||||
0x75, 0x08, // REPORT_SIZE (8)
|
||||
0x95, HID_PACKET_SIZE, // REPORT_COUNT (64)
|
||||
0x91, 0x02, // OUTPUT (Data,Var,Abs)
|
||||
|
||||
|
||||
0xc0,// END_COLLECTION
|
||||
|
||||
};
|
||||
SI_SEGMENT_VARIABLE(deviceDesc[],
|
||||
const USB_DeviceDescriptor_TypeDef,
|
||||
SI_SEG_CODE) =
|
||||
{
|
||||
USB_DEVICE_DESCSIZE, // bLength
|
||||
USB_DEVICE_DESCRIPTOR,// bLength
|
||||
htole16(0x0200),// bcdUSB
|
||||
0,// bDeviceClass
|
||||
0,// bDeviceSubClass
|
||||
0,// bDeviceProtocol
|
||||
64,// bMaxPacketSize
|
||||
USB_VENDOR_ID,// idVendor
|
||||
USB_PRODUCT_ID,// idProduct
|
||||
htole16(0x0100),// bcdDevice
|
||||
1,// iManufacturer
|
||||
2,// iProduct
|
||||
3,// iSerialNumber
|
||||
1,// bNumConfigurations
|
||||
};
|
||||
|
||||
SI_SEGMENT_VARIABLE(configDesc[],
|
||||
const uint8_t,
|
||||
SI_SEG_CODE) =
|
||||
{
|
||||
USB_CONFIG_DESCSIZE, // bLength
|
||||
USB_CONFIG_DESCRIPTOR,// bLength
|
||||
0x29,// wTotalLength(LSB)
|
||||
0x00,// wTotalLength(MSB)
|
||||
1,// bNumInterfaces
|
||||
1,// bConfigurationValue
|
||||
0,// iConfiguration
|
||||
|
||||
CONFIG_DESC_BM_RESERVED_D7,// bmAttrib: Bus powered
|
||||
|
||||
CONFIG_DESC_MAXPOWER_mA(100),// bMaxPower: 100 mA
|
||||
|
||||
//Interface 0 Descriptor
|
||||
USB_INTERFACE_DESCSIZE,// bLength
|
||||
USB_INTERFACE_DESCRIPTOR,// bDescriptorType
|
||||
0,// bInterfaceNumber
|
||||
0,// bAlternateSetting
|
||||
2,// bNumEndpoints
|
||||
3,// bInterfaceClass: HID (Human Interface Device)
|
||||
0,// bInterfaceSubClass
|
||||
0,// bInterfaceProtocol
|
||||
4,// iInterface
|
||||
|
||||
//HID Descriptor
|
||||
USB_HID_DESCSIZE,// bLength
|
||||
USB_HID_DESCRIPTOR,// bLength
|
||||
0x11,// bcdHID (LSB)
|
||||
0x01,// bcdHID (MSB)
|
||||
0,// bCountryCode
|
||||
1,// bNumDescriptors
|
||||
USB_HID_REPORT_DESCRIPTOR,// bDescriptorType
|
||||
sizeof( ReportDescriptor0 ),// wDescriptorLength(LSB)
|
||||
sizeof( ReportDescriptor0 )>>8,// wDescriptorLength(MSB)
|
||||
|
||||
//Endpoint 1 IN Descriptor
|
||||
USB_ENDPOINT_DESCSIZE,// bLength
|
||||
USB_ENDPOINT_DESCRIPTOR,// bDescriptorType
|
||||
0x81,// bEndpointAddress
|
||||
USB_EPTYPE_INTR,// bAttrib
|
||||
HID_PACKET_SIZE,// wMaxPacketSize (LSB)
|
||||
0x00,// wMaxPacketSize (MSB)
|
||||
5,// bInterval
|
||||
|
||||
//Endpoint 1 OUT Descriptor
|
||||
USB_ENDPOINT_DESCSIZE,// bLength
|
||||
USB_ENDPOINT_DESCRIPTOR,// bDescriptorType
|
||||
0x01,// bEndpointAddress
|
||||
USB_EPTYPE_INTR,// bAttrib
|
||||
HID_PACKET_SIZE,// wMaxPacketSize (LSB)
|
||||
0x00,// wMaxPacketSize (MSB)
|
||||
5,// bInterval
|
||||
};
|
||||
|
||||
#define LANG_STRING htole16( SLAB_USB_LANGUAGE )
|
||||
#define MFR_STRING 'S','i','l','i','c','o','n',' ','L','a','b','s','\0'
|
||||
#define MFR_SIZE 13
|
||||
#define PROD_STRING 'E','O','S',' ','W','a','l','l','e','t','\0'
|
||||
#define PROD_SIZE 11
|
||||
#define SER_STRING '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','\0'
|
||||
#define SER_SIZE 17
|
||||
#define CFG_STRING 'C','o','n','f','i','g',' ','#','1','\0'
|
||||
#define CFG_SIZE 10
|
||||
#define INT0_STRING 'E','O','S',' ','W','a','l','l','e','t','\0'
|
||||
#define INT0_SIZE 11
|
||||
|
||||
LANGID_STATIC_CONST_STRING_DESC( langDesc[], LANG_STRING );
|
||||
UTF16LE_PACKED_STATIC_CONST_STRING_DESC( mfrDesc[], MFR_STRING, MFR_SIZE);
|
||||
UTF16LE_PACKED_STATIC_CONST_STRING_DESC( prodDesc[], PROD_STRING, PROD_SIZE);
|
||||
UTF16LE_PACKED_STATIC_CONST_STRING_DESC( serDesc[], SER_STRING, SER_SIZE);
|
||||
UTF16LE_PACKED_STATIC_CONST_STRING_DESC( cfgDesc[], CFG_STRING, CFG_SIZE);
|
||||
UTF16LE_PACKED_STATIC_CONST_STRING_DESC( int0Desc[], INT0_STRING, INT0_SIZE);
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
SI_SEGMENT_POINTER(myUsbStringTable_USEnglish[],
|
||||
static const USB_StringDescriptor_TypeDef,
|
||||
const SI_SEG_CODE) =
|
||||
{
|
||||
langDesc,
|
||||
mfrDesc,
|
||||
prodDesc,
|
||||
serDesc,
|
||||
int0Desc,
|
||||
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
SI_SEGMENT_VARIABLE(initstruct,
|
||||
const USBD_Init_TypeDef,
|
||||
SI_SEG_CODE) =
|
||||
{
|
||||
deviceDesc, // deviceDescriptor
|
||||
configDesc,// configDescriptor
|
||||
myUsbStringTable_USEnglish,// stringDescriptors
|
||||
sizeof(myUsbStringTable_USEnglish) / sizeof(void *)// numberOfStrings
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#include <SI_EFM8UB1_Register_Enums.h>
|
||||
#include "InitDevice.h"
|
||||
#include "efm8_usb.h"
|
||||
#include "printing.h"
|
||||
|
||||
|
||||
|
||||
|
||||
int main(void) {
|
||||
enter_DefaultMode_from_RESET();
|
||||
|
||||
cprints("hello,world\r\n");
|
||||
|
||||
while (1) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* printing.c
|
||||
*
|
||||
* Created on: Jun 25, 2018
|
||||
* Author: conor
|
||||
*/
|
||||
|
||||
#include <SI_EFM8UB1_Register_Enums.h>
|
||||
#include <efm8_usb.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include "printing.h"
|
||||
|
||||
void putf(char c)
|
||||
{
|
||||
uint8_t i;
|
||||
SBUF0 = c;
|
||||
// Blocking delay that works for 115200 baud on this device (<1ms)
|
||||
for (i=0; i<200; i++){}
|
||||
for (i=0; i<200; i++){}
|
||||
for (i=0; i<190; i++){}
|
||||
watchdog();
|
||||
}
|
||||
|
||||
|
||||
void dump_hex(uint8_t* hex, uint8_t len)
|
||||
{
|
||||
uint8_t i;
|
||||
for (i=0 ; i < len ; i++)
|
||||
{
|
||||
if (hex[i]<0x10)
|
||||
{
|
||||
putf('0');
|
||||
}
|
||||
cputb(hex[i]);
|
||||
}
|
||||
cprints("\r\n");
|
||||
}
|
||||
|
||||
|
||||
void cprints(char* d)
|
||||
{
|
||||
while(*d)
|
||||
{
|
||||
// UART0 output queue
|
||||
putf(*d++);
|
||||
}
|
||||
}
|
||||
|
||||
static void int2str_reduce_n(char ** snum, uint32_t copy, uint8_t n)
|
||||
{
|
||||
do
|
||||
{
|
||||
copy /= n;
|
||||
}while(copy);
|
||||
}
|
||||
|
||||
|
||||
static const char * __digits = "0123456789abcdef";
|
||||
static char xdata __int2str_buf[9];
|
||||
|
||||
static void int2str_map_n(char ** snum, uint32_t i, uint8_t n)
|
||||
{
|
||||
do
|
||||
{
|
||||
*--*snum = __digits[i % n];
|
||||
i /= n;
|
||||
}while(i);
|
||||
}
|
||||
|
||||
#define dint2str(i) __int2strn(i,10)
|
||||
#define xint2str(i) __int2strn(i,16)
|
||||
|
||||
char * __int2strn(int32_t i, uint8_t n)
|
||||
{
|
||||
char * snum = __int2str_buf;
|
||||
if (i<0) *snum++ = '-';
|
||||
int2str_reduce_n(&snum, i, n);
|
||||
*snum = '\0';
|
||||
int2str_map_n(&snum, i, n);
|
||||
return snum;
|
||||
}
|
||||
|
||||
void cputd(int32_t i)
|
||||
{
|
||||
cprints(dint2str((int32_t)i));
|
||||
}
|
||||
|
||||
void cputx(int32_t i)
|
||||
{
|
||||
cprints(xint2str(i));
|
||||
}
|
||||
|
||||
static void put_space()
|
||||
{
|
||||
cprints(" ");
|
||||
}
|
||||
static void put_line()
|
||||
{
|
||||
cprints("\r\n");
|
||||
}
|
||||
|
||||
void cprintd(const char * tag, uint8_t c, ...)
|
||||
{
|
||||
va_list args;
|
||||
cprints(tag);
|
||||
va_start(args,c);
|
||||
while(c--)
|
||||
{
|
||||
cputd((int32_t)va_arg(args, int16_t));
|
||||
|
||||
}
|
||||
put_line();
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void cprintl(const char * tag, uint8_t c, ...)
|
||||
{
|
||||
va_list args;
|
||||
cprints(tag);
|
||||
va_start(args,c);
|
||||
while(c--)
|
||||
{
|
||||
cputl(va_arg(args, int32_t));
|
||||
cprints(" ");
|
||||
}
|
||||
put_line();
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void cprintx(const char * tag, uint8_t c, ...)
|
||||
{
|
||||
va_list args;
|
||||
cprints(tag);
|
||||
va_start(args,c);
|
||||
while(c--)
|
||||
{
|
||||
cputx((int32_t)va_arg(args, uint16_t));
|
||||
cprints(" ");
|
||||
}
|
||||
put_line();
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void cprintb(const char * tag, uint8_t c, ...)
|
||||
{
|
||||
va_list args;
|
||||
cprints(tag);
|
||||
va_start(args,c);
|
||||
while(c--)
|
||||
{
|
||||
cputb(va_arg(args, uint8_t));
|
||||
put_space();
|
||||
}
|
||||
put_line();
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void cprintlx(const char * tag, uint8_t c, ...)
|
||||
{
|
||||
va_list args;
|
||||
cprints(tag);
|
||||
va_start(args,c);
|
||||
while(c--)
|
||||
{
|
||||
cputlx(va_arg(args, int32_t));
|
||||
put_space();
|
||||
}
|
||||
put_line();
|
||||
va_end(args);
|
||||
}
|
|
@ -6,6 +6,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
#include "util.h"
|
||||
#include "crypto.h"
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
#define _CTAP_H
|
||||
|
||||
#include "cbor.h"
|
||||
#include "device.h"
|
||||
|
||||
#define CTAP_MAKE_CREDENTIAL 0x01
|
||||
#define CTAP_GET_ASSERTION 0x02
|
||||
|
@ -257,25 +258,7 @@ void ctap_reset();
|
|||
int8_t ctap_device_locked();
|
||||
|
||||
|
||||
// Test for user presence
|
||||
// Return 1 for user is present, 0 user not present
|
||||
extern int ctap_user_presence_test();
|
||||
|
||||
// Generate @num bytes of random numbers to @dest
|
||||
// return 1 if success, error otherwise
|
||||
extern int ctap_generate_rng(uint8_t * dst, size_t num);
|
||||
|
||||
// Increment atomic counter and return it.
|
||||
// Must support two counters, @sel selects counter0 or counter1.
|
||||
uint32_t ctap_atomic_count(int sel);
|
||||
|
||||
// Verify the user
|
||||
// return 1 if user is verified, 0 if not
|
||||
extern int ctap_user_verification(uint8_t arg);
|
||||
|
||||
// Must be implemented by application
|
||||
// data is HID_MESSAGE_SIZE long in bytes
|
||||
extern void ctaphid_write_block(uint8_t * data);
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,44 @@
|
|||
#ifndef _DEVICE_H
|
||||
#define _DEVICE_H
|
||||
|
||||
void device_init();
|
||||
|
||||
uint64_t millis();
|
||||
|
||||
// HID message size in bytes
|
||||
#define HID_MESSAGE_SIZE 64
|
||||
|
||||
void usbhid_init();
|
||||
|
||||
int usbhid_recv(uint8_t * msg);
|
||||
|
||||
void usbhid_send(uint8_t * msg);
|
||||
|
||||
void usbhid_close();
|
||||
|
||||
void main_loop_delay();
|
||||
|
||||
void heartbeat();
|
||||
|
||||
|
||||
// Test for user presence
|
||||
// Return 1 for user is present, 0 user not present
|
||||
extern int ctap_user_presence_test();
|
||||
|
||||
// Generate @num bytes of random numbers to @dest
|
||||
// return 1 if success, error otherwise
|
||||
extern int ctap_generate_rng(uint8_t * dst, size_t num);
|
||||
|
||||
// Increment atomic counter and return it.
|
||||
// Must support two counters, @sel selects counter0 or counter1.
|
||||
uint32_t ctap_atomic_count(int sel);
|
||||
|
||||
// Verify the user
|
||||
// return 1 if user is verified, 0 if not
|
||||
extern int ctap_user_verification(uint8_t arg);
|
||||
|
||||
// Must be implemented by application
|
||||
// data is HID_MESSAGE_SIZE long in bytes
|
||||
extern void ctaphid_write_block(uint8_t * data);
|
||||
|
||||
#endif
|
|
@ -38,8 +38,8 @@ int main(int argc, char * argv[])
|
|||
TAG_ERR
|
||||
);
|
||||
|
||||
printf1(TAG_GEN,"init device\n");
|
||||
device_init();
|
||||
printf1(TAG_GEN,"init device\n");
|
||||
|
||||
printf1(TAG_GEN,"init ctaphid\n");
|
||||
ctaphid_init();
|
377
old-crypto.c
377
old-crypto.c
|
@ -1,377 +0,0 @@
|
|||
/*
|
||||
* Wrapper for crypto implementation on device
|
||||
*
|
||||
* */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sdk_common.h"
|
||||
#include "nrf_assert.h"
|
||||
#include "nrf_log.h"
|
||||
#include "nrf_log_ctrl.h"
|
||||
#include "nrf_log_default_backends.h"
|
||||
#include "nrf_crypto.h"
|
||||
#include "nrf_crypto_ecc.h"
|
||||
#include "nrf_crypto_error.h"
|
||||
#include "nrf_crypto_ecdsa.h"
|
||||
#include "mem_manager.h"
|
||||
|
||||
|
||||
#include "util.h"
|
||||
#include "crypto.h"
|
||||
#include "sha256.h"
|
||||
#include "uECC.h"
|
||||
#include "aes.h"
|
||||
#include "ctap.h"
|
||||
|
||||
|
||||
const uint8_t attestation_cert_der[];
|
||||
const uint16_t attestation_cert_der_size;
|
||||
const uint8_t attestation_key[];
|
||||
const uint16_t attestation_key_size;
|
||||
|
||||
|
||||
|
||||
static SHA256_CTX sha256_ctx;
|
||||
|
||||
|
||||
static const uint8_t * _signing_key = NULL;
|
||||
|
||||
// Secrets for testing only
|
||||
static uint8_t master_secret[32] = "\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xaa\xbb\xcc\xdd\xee\xff"
|
||||
"\xff\xee\xdd\xcc\xbb\xaa\x99\x88\x77\x66\x55\x44\x33\x22\x11\x00";
|
||||
|
||||
static uint8_t transport_secret[32] = "\x10\x01\x22\x33\x44\x55\x66\x77\x87\x90\x0a\xbb\x3c\xd8\xee\xff"
|
||||
"\xff\xee\x8d\x1c\x3b\xfa\x99\x88\x77\x86\x55\x44\xd3\xff\x33\x00";
|
||||
|
||||
|
||||
|
||||
void crypto_sha256_init()
|
||||
{
|
||||
sha256_init(&sha256_ctx);
|
||||
}
|
||||
|
||||
void crypto_reset_master_secret()
|
||||
{
|
||||
ctap_generate_rng(master_secret, 32);
|
||||
}
|
||||
|
||||
|
||||
void crypto_sha256_update(uint8_t * data, size_t len)
|
||||
{
|
||||
sha256_update(&sha256_ctx, data, len);
|
||||
}
|
||||
|
||||
void crypto_sha256_update_secret()
|
||||
{
|
||||
sha256_update(&sha256_ctx, master_secret, 32);
|
||||
}
|
||||
|
||||
void crypto_sha256_final(uint8_t * hash)
|
||||
{
|
||||
sha256_final(&sha256_ctx, hash);
|
||||
}
|
||||
|
||||
void crypto_sha256_hmac_init(uint8_t * key, uint32_t klen, uint8_t * hmac)
|
||||
{
|
||||
uint8_t buf[64];
|
||||
int i;
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (key == CRYPTO_MASTER_KEY)
|
||||
{
|
||||
key = master_secret;
|
||||
klen = sizeof(master_secret);
|
||||
}
|
||||
|
||||
if(klen > 64)
|
||||
{
|
||||
printf("Error, key size must be <= 64\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memmove(buf, key, klen);
|
||||
|
||||
for (i = 0; i < sizeof(buf); i++)
|
||||
{
|
||||
buf[i] = buf[i] ^ 0x36;
|
||||
}
|
||||
|
||||
crypto_sha256_init();
|
||||
crypto_sha256_update(buf, 64);
|
||||
}
|
||||
|
||||
void crypto_sha256_hmac_final(uint8_t * key, uint32_t klen, uint8_t * hmac)
|
||||
{
|
||||
uint8_t buf[64];
|
||||
int i;
|
||||
crypto_sha256_final(hmac);
|
||||
memset(buf, 0, sizeof(buf));
|
||||
if (key == CRYPTO_MASTER_KEY)
|
||||
{
|
||||
key = master_secret;
|
||||
klen = sizeof(master_secret);
|
||||
}
|
||||
|
||||
|
||||
if(klen > 64)
|
||||
{
|
||||
printf("Error, key size must be <= 64\n");
|
||||
exit(1);
|
||||
}
|
||||
memmove(buf, key, klen);
|
||||
|
||||
for (i = 0; i < sizeof(buf); i++)
|
||||
{
|
||||
buf[i] = buf[i] ^ 0x5c;
|
||||
}
|
||||
|
||||
crypto_sha256_init();
|
||||
crypto_sha256_update(buf, 64);
|
||||
crypto_sha256_update(hmac, 32);
|
||||
crypto_sha256_final(hmac);
|
||||
}
|
||||
|
||||
|
||||
void crypto_ecc256_init()
|
||||
{
|
||||
int ret;
|
||||
ret = nrf_mem_init();
|
||||
if (ret != NRF_SUCCESS)
|
||||
{
|
||||
printf("nrf_mem_init fail %d\n", ret);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = nrf_crypto_init();
|
||||
if (ret != NRF_SUCCESS)
|
||||
{
|
||||
printf("nrf_crypto_init fail 0x%02x\n", ret);
|
||||
printf("nrf_crypto_init fail %s\n", nrf_strerror_get(ret));
|
||||
printf("nrf_crypto_init fail %s\n", nrf_strerror_get(ret));
|
||||
printf("nrf_crypto_init fail %s\n", nrf_strerror_get(ret));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
uECC_set_rng((uECC_RNG_Function)ctap_generate_rng);
|
||||
}
|
||||
|
||||
|
||||
void crypto_ecc256_load_attestation_key()
|
||||
{
|
||||
_signing_key = attestation_key;
|
||||
}
|
||||
|
||||
void crypto_ecc256_sign(uint8_t * data, int len, uint8_t * sig)
|
||||
{
|
||||
nrf_crypto_ecc_private_key_t privkey;
|
||||
nrf_crypto_ecdsa_sign_context_t context;
|
||||
ret_code_t ret = NRF_SUCCESS;
|
||||
size_t sigsz;
|
||||
|
||||
/*dump_hex(_signing_key,32);*/
|
||||
memset(&privkey, 0, sizeof(nrf_crypto_ecc_private_key_t));
|
||||
memset(&context, 0, sizeof(nrf_crypto_ecdsa_sign_context_t));
|
||||
|
||||
ret = nrf_crypto_ecc_private_key_from_raw(&g_nrf_crypto_ecc_secp256r1_curve_info,
|
||||
&privkey,
|
||||
_signing_key,
|
||||
(size_t)32);
|
||||
if (ret != NRF_SUCCESS)
|
||||
{
|
||||
printf("private_key_from_raw failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sigsz = 64;
|
||||
ret = nrf_crypto_ecdsa_sign(&context,
|
||||
&privkey,
|
||||
data,
|
||||
(size_t)len,
|
||||
sig,
|
||||
&sigsz);
|
||||
if (ret != NRF_SUCCESS)
|
||||
{
|
||||
printf("crypto_ecdsa failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (sigsz != 64)
|
||||
{
|
||||
printf("sig wrong size %d\n", sigsz);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = nrf_crypto_ecc_private_key_free(&privkey);
|
||||
|
||||
if (ret != NRF_SUCCESS)
|
||||
{
|
||||
printf("crypto free failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key, uECC_Curve curve);*/
|
||||
void crypto_ecc256_derive_public_key(uint8_t * data, int len, uint8_t * x, uint8_t * y)
|
||||
{
|
||||
nrf_crypto_ecc_private_key_t nrfprivkey;
|
||||
nrf_crypto_ecc_public_key_calculate_context_t context;
|
||||
nrf_crypto_ecc_public_key_t nrfpubkey;
|
||||
uint8_t privkey[32];
|
||||
uint8_t pubkey[64];
|
||||
size_t sz;
|
||||
ret_code_t ret = NRF_SUCCESS;
|
||||
memset(&nrfprivkey, 0, sizeof(nrf_crypto_ecc_private_key_t));
|
||||
memset(&context, 0, sizeof(nrf_crypto_ecc_public_key_calculate_context_t));
|
||||
|
||||
generate_private_key(data,len,NULL,0,privkey);
|
||||
|
||||
|
||||
ret = nrf_crypto_ecc_private_key_from_raw(&g_nrf_crypto_ecc_secp256r1_curve_info,
|
||||
&nrfprivkey,
|
||||
privkey,
|
||||
(size_t)32);
|
||||
if (ret != NRF_SUCCESS)
|
||||
{
|
||||
printf("private_key_from_raw failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = nrf_crypto_ecc_public_key_calculate(&context, &nrfprivkey, &nrfpubkey);
|
||||
|
||||
if (ret != NRF_SUCCESS)
|
||||
{
|
||||
printf("public key compute failed: %s\n", nrf_strerror_get(ret));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sz = sizeof(pubkey);
|
||||
nrf_crypto_ecc_public_key_to_raw(&nrfpubkey, pubkey, &sz);
|
||||
|
||||
memmove(x,pubkey,32);
|
||||
memmove(y,pubkey+32,32);
|
||||
|
||||
nrf_crypto_ecc_public_key_free(&nrfpubkey);
|
||||
nrf_crypto_ecc_private_key_free(&nrfprivkey);
|
||||
|
||||
}
|
||||
|
||||
void crypto_ecc256_load_key(uint8_t * data, int len, uint8_t * data2, int len2)
|
||||
{
|
||||
static uint8_t privkey[32];
|
||||
generate_private_key(data,len,data2,len2,privkey);
|
||||
_signing_key = privkey;
|
||||
}
|
||||
|
||||
void crypto_ecc256_make_key_pair(uint8_t * pubkey, uint8_t * privkey)
|
||||
{
|
||||
if (uECC_make_key(pubkey, privkey, uECC_secp256r1()) != 1)
|
||||
{
|
||||
printf("Error, uECC_make_key failed\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void crypto_ecc256_shared_secret(const uint8_t * pubkey, const uint8_t * privkey, uint8_t * shared_secret)
|
||||
{
|
||||
if (uECC_shared_secret(pubkey, privkey, shared_secret, uECC_secp256r1()) != 1)
|
||||
{
|
||||
printf("Error, uECC_shared_secret failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void generate_private_key(uint8_t * data, int len, uint8_t * data2, int len2, uint8_t * privkey)
|
||||
{
|
||||
crypto_sha256_hmac_init(CRYPTO_MASTER_KEY, 0, privkey);
|
||||
crypto_sha256_update(data, len);
|
||||
crypto_sha256_update(data2, len2);
|
||||
crypto_sha256_update(master_secret, 32);
|
||||
crypto_sha256_hmac_final(CRYPTO_MASTER_KEY, 0, privkey);
|
||||
}
|
||||
|
||||
struct AES_ctx aes_ctx;
|
||||
void crypto_aes256_init(uint8_t * key, uint8_t * nonce)
|
||||
{
|
||||
if (key == CRYPTO_TRANSPORT_KEY)
|
||||
{
|
||||
AES_init_ctx(&aes_ctx, transport_secret);
|
||||
}
|
||||
else
|
||||
{
|
||||
AES_init_ctx(&aes_ctx, key);
|
||||
}
|
||||
if (nonce == NULL)
|
||||
{
|
||||
memset(aes_ctx.Iv, 0, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
memmove(aes_ctx.Iv, nonce, 16);
|
||||
}
|
||||
}
|
||||
|
||||
// prevent round key recomputation
|
||||
void crypto_aes256_reset_iv(uint8_t * nonce)
|
||||
{
|
||||
if (nonce == NULL)
|
||||
{
|
||||
memset(aes_ctx.Iv, 0, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
memmove(aes_ctx.Iv, nonce, 16);
|
||||
}
|
||||
}
|
||||
|
||||
void crypto_aes256_decrypt(uint8_t * buf, int length)
|
||||
{
|
||||
AES_CBC_decrypt_buffer(&aes_ctx, buf, length);
|
||||
}
|
||||
|
||||
void crypto_aes256_encrypt(uint8_t * buf, int length)
|
||||
{
|
||||
AES_CBC_encrypt_buffer(&aes_ctx, buf, length);
|
||||
}
|
||||
|
||||
|
||||
const uint8_t attestation_cert_der[] =
|
||||
"\x30\x82\x01\xfb\x30\x82\x01\xa1\xa0\x03\x02\x01\x02\x02\x01\x00\x30\x0a\x06\x08"
|
||||
"\x2a\x86\x48\xce\x3d\x04\x03\x02\x30\x2c\x31\x0b\x30\x09\x06\x03\x55\x04\x06\x13"
|
||||
"\x02\x55\x53\x31\x0b\x30\x09\x06\x03\x55\x04\x08\x0c\x02\x4d\x44\x31\x10\x30\x0e"
|
||||
"\x06\x03\x55\x04\x0a\x0c\x07\x54\x45\x53\x54\x20\x43\x41\x30\x20\x17\x0d\x31\x38"
|
||||
"\x30\x35\x31\x30\x30\x33\x30\x36\x32\x30\x5a\x18\x0f\x32\x30\x36\x38\x30\x34\x32"
|
||||
"\x37\x30\x33\x30\x36\x32\x30\x5a\x30\x7c\x31\x0b\x30\x09\x06\x03\x55\x04\x06\x13"
|
||||
"\x02\x55\x53\x31\x0b\x30\x09\x06\x03\x55\x04\x08\x0c\x02\x4d\x44\x31\x0f\x30\x0d"
|
||||
"\x06\x03\x55\x04\x07\x0c\x06\x4c\x61\x75\x72\x65\x6c\x31\x15\x30\x13\x06\x03\x55"
|
||||
"\x04\x0a\x0c\x0c\x54\x45\x53\x54\x20\x43\x4f\x4d\x50\x41\x4e\x59\x31\x22\x30\x20"
|
||||
"\x06\x03\x55\x04\x0b\x0c\x19\x41\x75\x74\x68\x65\x6e\x74\x69\x63\x61\x74\x6f\x72"
|
||||
"\x20\x41\x74\x74\x65\x73\x74\x61\x74\x69\x6f\x6e\x31\x14\x30\x12\x06\x03\x55\x04"
|
||||
"\x03\x0c\x0b\x63\x6f\x6e\x6f\x72\x70\x70\x2e\x63\x6f\x6d\x30\x59\x30\x13\x06\x07"
|
||||
"\x2a\x86\x48\xce\x3d\x02\x01\x06\x08\x2a\x86\x48\xce\x3d\x03\x01\x07\x03\x42\x00"
|
||||
"\x04\x45\xa9\x02\xc1\x2e\x9c\x0a\x33\xfa\x3e\x84\x50\x4a\xb8\x02\xdc\x4d\xb9\xaf"
|
||||
"\x15\xb1\xb6\x3a\xea\x8d\x3f\x03\x03\x55\x65\x7d\x70\x3f\xb4\x02\xa4\x97\xf4\x83"
|
||||
"\xb8\xa6\xf9\x3c\xd0\x18\xad\x92\x0c\xb7\x8a\x5a\x3e\x14\x48\x92\xef\x08\xf8\xca"
|
||||
"\xea\xfb\x32\xab\x20\xa3\x62\x30\x60\x30\x46\x06\x03\x55\x1d\x23\x04\x3f\x30\x3d"
|
||||
"\xa1\x30\xa4\x2e\x30\x2c\x31\x0b\x30\x09\x06\x03\x55\x04\x06\x13\x02\x55\x53\x31"
|
||||
"\x0b\x30\x09\x06\x03\x55\x04\x08\x0c\x02\x4d\x44\x31\x10\x30\x0e\x06\x03\x55\x04"
|
||||
"\x0a\x0c\x07\x54\x45\x53\x54\x20\x43\x41\x82\x09\x00\xf7\xc9\xec\x89\xf2\x63\x94"
|
||||
"\xd9\x30\x09\x06\x03\x55\x1d\x13\x04\x02\x30\x00\x30\x0b\x06\x03\x55\x1d\x0f\x04"
|
||||
"\x04\x03\x02\x04\xf0\x30\x0a\x06\x08\x2a\x86\x48\xce\x3d\x04\x03\x02\x03\x48\x00"
|
||||
"\x30\x45\x02\x20\x18\x38\xb0\x45\x03\x69\xaa\xa7\xb7\x38\x62\x01\xaf\x24\x97\x5e"
|
||||
"\x7e\x74\x64\x1b\xa3\x7b\xf7\xe6\xd3\xaf\x79\x28\xdb\xdc\xa5\x88\x02\x21\x00\xcd"
|
||||
"\x06\xf1\xe3\xab\x16\x21\x8e\xd8\xc0\x14\xaf\x09\x4f\x5b\x73\xef\x5e\x9e\x4b\xe7"
|
||||
"\x35\xeb\xdd\x9b\x6d\x8f\x7d\xf3\xc4\x3a\xd7";
|
||||
|
||||
|
||||
const uint16_t attestation_cert_der_size = sizeof(attestation_cert_der)-1;
|
||||
|
||||
|
||||
const uint8_t attestation_key[] = "\xcd\x67\xaa\x31\x0d\x09\x1e\xd1\x6e\x7e\x98\x92\xaa\x07\x0e\x19\x94\xfc\xd7\x14\xae\x7c\x40\x8f\xb9\x46\xb7\x2e\x5f\xe7\x5d\x30";
|
||||
const uint16_t attestation_key_size = sizeof(attestation_key)-1;
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIIB+zCCAaGgAwIBAgIBADAKBggqhkjOPQQDAjAsMQswCQYDVQQGEwJVUzELMAkG
|
||||
A1UECAwCTUQxEDAOBgNVBAoMB1RFU1QgQ0EwIBcNMTgwNTEwMDMwNjIwWhgPMjA2
|
||||
ODA0MjcwMzA2MjBaMHwxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJNRDEPMA0GA1UE
|
||||
BwwGTGF1cmVsMRUwEwYDVQQKDAxURVNUIENPTVBBTlkxIjAgBgNVBAsMGUF1dGhl
|
||||
bnRpY2F0b3IgQXR0ZXN0YXRpb24xFDASBgNVBAMMC2Nvbm9ycHAuY29tMFkwEwYH
|
||||
KoZIzj0CAQYIKoZIzj0DAQcDQgAERakCwS6cCjP6PoRQSrgC3E25rxWxtjrqjT8D
|
||||
A1VlfXA/tAKkl/SDuKb5PNAYrZIMt4paPhRIku8I+Mrq+zKrIKNiMGAwRgYDVR0j
|
||||
BD8wPaEwpC4wLDELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk1EMRAwDgYDVQQKDAdU
|
||||
RVNUIENBggkA98nsifJjlNkwCQYDVR0TBAIwADALBgNVHQ8EBAMCBPAwCgYIKoZI
|
||||
zj0EAwIDSAAwRQIgGDiwRQNpqqe3OGIBrySXXn50ZBuje/fm0695KNvcpYgCIQDN
|
||||
BvHjqxYhjtjAFK8JT1tz716eS+c1692bbY9988Q61w==
|
||||
-----END CERTIFICATE-----
|
Ładowanie…
Reference in New Issue