Moved remotely
git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@113 9fe90eed-be63-e94b-8204-d34ff4c2ff93
This commit is contained in:
@@ -0,0 +1,607 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?>
|
||||
|
||||
<cproject>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.cygwin.lib.debug.1544585684">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cygwin.lib.debug.1544585684" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/BusProtocol"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/BusProtocol/Debug"/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="a" artifactName="BusProtocol" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cygwin.lib.debug.1544585684" name="Debug" parent="cdt.managedbuild.config.gnu.cygwin.lib.debug" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="" prebuildStep="">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cygwin.lib.debug.1544585684." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.lib.debug.326940027" name="Cygwin GCC" superClass="cdt.managedbuild.toolchain.gnu.cygwin.lib.debug">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.cygwin.lib.debug.1094805505" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.cygwin.lib.debug"/>
|
||||
<builder autoBuildTarget="all" buildPath="${workspace_loc:/BusProtocol/Debug}" cleanBuildTarget="clean" enableAutoBuild="false" enableCleanBuild="true" enabledIncrementalBuild="true" id="cdt.managedbuild.target.gnu.builder.cygwin.lib.debug.1509971901" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.cygwin.lib.debug"/>
|
||||
<tool command="arm-elf-as" id="cdt.managedbuild.tool.gnu.assembler.cygwin.lib.debug.772227085" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.lib.debug">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1203300128" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
<tool command="arm-elf-ar" id="cdt.managedbuild.tool.gnu.archiver.cygwin.lib.debug.777348117" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.cygwin.lib.debug"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.lib.debug.858821726" name="Cygwin C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.lib.debug"/>
|
||||
<tool command="arm-elf-gcc" id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.debug.1733787066" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.debug">
|
||||
<option id="gnu.c.compiler.option.include.paths.1509385572" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Drivers}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BusProtocol}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/FreeRTOS/include}""/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1680796165" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="ROWLEY_LPC23xx"/>
|
||||
<listOptionValue builtIn="false" value="THUMB_INTERWORK"/>
|
||||
<listOptionValue builtIn="false" value="ALIGN_STRUCT_END=__attribute\(\(aligned\(4\)\)\)"/>
|
||||
<listOptionValue builtIn="false" value="PACK_STRUCT_END=__attribute\(\(packed\)\)"/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.misc.other.499633930" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fomit-frame-pointer -mcpu=arm7tdmi -fshort-enums -mthumb-interwork" valueType="string"/>
|
||||
<option id="gnu.c.compiler.cygwin.lib.debug.option.optimization.level.563157300" name="Optimization Level" superClass="gnu.c.compiler.cygwin.lib.debug.option.optimization.level" value="gnu.c.optimization.level.more" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.456804014" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.linker.cygwin.base.1773436851" name="Cygwin C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.base"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.base.1204613450" name="Cygwin C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.base"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
|
||||
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.lib.release.1186752811;cdt.managedbuild.config.gnu.cygwin.lib.release.1186752811.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.release.782884106;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.2138187002">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.lib.debug.1544585684;cdt.managedbuild.config.gnu.cygwin.lib.debug.1544585684.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.debug.1733787066;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.456804014">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="arm-elf-gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="cdt.managedbuild.config.gnu.cygwin.lib.release.1186752811">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.cygwin.lib.release.1186752811" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/BusProtocol"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/BusProtocol/Release"/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="a" artifactName="BusProtocol" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.cygwin.lib.release.1186752811" name="Release" parent="cdt.managedbuild.config.gnu.cygwin.lib.release">
|
||||
<folderInfo id="cdt.managedbuild.config.gnu.cygwin.lib.release.1186752811." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.lib.release.1075073645" name="Cygwin GCC" superClass="cdt.managedbuild.toolchain.gnu.cygwin.lib.release">
|
||||
<targetPlatform id="cdt.managedbuild.target.gnu.platform.cygwin.lib.release.152549363" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.cygwin.lib.release"/>
|
||||
<builder buildPath="${workspace_loc:/BusProtocol/Release}" id="cdt.managedbuild.target.gnu.builder.cygwin.lib.release.1933028258" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.cygwin.lib.release"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.assembler.cygwin.lib.release.983843060" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.lib.release">
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.329238432" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.archiver.cygwin.lib.release.919655387" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.cygwin.lib.release"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.lib.release.1331857812" name="Cygwin C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.lib.release">
|
||||
<option id="gnu.cpp.compiler.cygwin.lib.release.option.optimization.level.1532574349" name="Optimization Level" superClass="gnu.cpp.compiler.cygwin.lib.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.cygwin.lib.release.option.debugging.level.1861766211" name="Debug Level" superClass="gnu.cpp.compiler.cygwin.lib.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.release.782884106" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.release">
|
||||
<option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.cygwin.lib.release.option.optimization.level.1435830" name="Optimization Level" superClass="gnu.c.compiler.cygwin.lib.release.option.optimization.level" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.cygwin.lib.release.option.debugging.level.570236671" name="Debug Level" superClass="gnu.c.compiler.cygwin.lib.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.2138187002" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.linker.cygwin.base.1391519689" name="Cygwin C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.base"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.base.1610264802" name="Cygwin C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.cygwin.base"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
|
||||
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.lib.release.1186752811;cdt.managedbuild.config.gnu.cygwin.lib.release.1186752811.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.release.782884106;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.2138187002">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.cygwin.lib.debug.1544585684;cdt.managedbuild.config.gnu.cygwin.lib.debug.1544585684.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.lib.debug.1733787066;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.456804014">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="arm-elf-gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="BusProtocol.cdt.managedbuild.target.gnu.cygwin.lib.1635067160" name="Static Library" projectType="cdt.managedbuild.target.gnu.cygwin.lib"/>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>BusProtocol</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>Drivers</project>
|
||||
<project>FreeRTOS</project>
|
||||
<project>inc</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
|
||||
<value>clean</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||
<value>make</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.contents</key>
|
||||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildLocation</key>
|
||||
<value>${workspace_loc:/BusProtocol/Debug}</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,131 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* BpMessageFormat.c - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 29, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "BpMessageFormat.h"
|
||||
#include "Crc.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/** \brief Calculates the CRC over payload etc... and sets unique start byte
|
||||
*
|
||||
* \param msg Message over which the CRC should be calculated
|
||||
*/
|
||||
void bpmsgEncodeMessage( t_bpmsg_message * msg )
|
||||
{
|
||||
UINT16 crc;
|
||||
|
||||
crc = crcCalc( &msg->payloadSize, 1, 0);
|
||||
crc = crcCalc( msg->payload, msg->payloadSize, crc);
|
||||
|
||||
msg->crc = crc;
|
||||
}
|
||||
|
||||
|
||||
void bpmsgAdd16bit(UINT8 *payloadlocation, UINT16 data)
|
||||
{
|
||||
UINT8 index = 0;
|
||||
|
||||
payloadlocation[index] = (UINT8)(data >> 8);
|
||||
index++;
|
||||
payloadlocation[index] = (UINT8)(data & 0x00FF);
|
||||
}
|
||||
|
||||
|
||||
void bpmsgAdd32bit(UINT8 *payloadlocation, UINT32 data)
|
||||
{
|
||||
UINT8 index = 0;
|
||||
|
||||
payloadlocation[index] = (UINT8)(data >> 24);
|
||||
index++;
|
||||
payloadlocation[index] = (UINT8)(data >> 16);
|
||||
index++;
|
||||
payloadlocation[index] = (UINT8)(data >> 8);
|
||||
index++;
|
||||
payloadlocation[index] = (UINT8)(data & 0xFF);
|
||||
|
||||
}
|
||||
|
||||
UINT8 bpmsgGet8bit(UINT8 *payload, UINT8 *payloadIndex)
|
||||
{
|
||||
UINT8 result;
|
||||
|
||||
result = (UINT8)payload[*payloadIndex];
|
||||
(*payloadIndex)++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
UINT16 bpmsgGet16bit(UINT8 *payload, UINT8 *payloadIndex)
|
||||
{
|
||||
UINT16 result;
|
||||
|
||||
result = ((UINT16)payload[*payloadIndex]) << 8;
|
||||
(*payloadIndex)++;
|
||||
result += ((UINT16)payload[*payloadIndex] & 0x00FF);
|
||||
(*payloadIndex)++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
UINT32 bpmsgGet32bit(UINT8 *payload, UINT8 *payloadIndex)
|
||||
{
|
||||
UINT32 result;
|
||||
|
||||
result = ((UINT32)payload[*payloadIndex]) << 24;
|
||||
(*payloadIndex)++;
|
||||
result += ((UINT32)payload[*payloadIndex]) << 16;
|
||||
(*payloadIndex)++;
|
||||
result += ((UINT32)payload[*payloadIndex]) << 8;
|
||||
(*payloadIndex)++;
|
||||
result += ((UINT32)payload[*payloadIndex] & 0x000000FF);
|
||||
(*payloadIndex)++;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* BpMessageFormat.h - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 29, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __BPMESSAGEFORMAT_H__
|
||||
#define __BPMESSAGEFORMAT_H__
|
||||
/** \file BpMessageFormat.h
|
||||
\brief
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define BPMSG_STARTBYTE (0xAA)
|
||||
|
||||
#define BPMSG_MSGID_PASSTURN (0x00)
|
||||
#define BPMSG_MSGID_RESETCLIENT (0x01)
|
||||
#define BPMSG_MSGID_GIVEELECTRONICSTATUS (0x02)
|
||||
#define BPMSG_MSGID_SETDACVALUE (0x03)
|
||||
#define BPMSG_MSGID_SETDIGITALOUTVALUE (0x04)
|
||||
#define BPMSG_MSGID_SETADCMODE (0x05)
|
||||
#define BPMSG_MSGID_SETALLDIGITALOUT (0x06)
|
||||
#define BPMSG_MSGID_SETALLDACVALUES (0x07)
|
||||
#define BPMSG_MSGID_SETALLDOUTPUT (0x08)
|
||||
#define BPMSG_MSGID_CALLRPC (0x10)
|
||||
#define BPMSG_MSGID_GIVERPCRESULTS (0x11)
|
||||
|
||||
#define BPMSG_BROADCAST_ID (0xFF)
|
||||
#define BPMSG_MASTER_DEVID (0x01)
|
||||
#define BPMSG_STATUS_FINISHEDSENDING (0xC0)
|
||||
#define BPMSG_STATUS_BUSYSENDING (0x40)
|
||||
#define BPMSG_DACMODE_VOLTAGE (0x00)
|
||||
#define BPMSG_DACMODE_CURRENT (0x01)
|
||||
#define BPMSG_ADCMODE_VOLTAGE (0x00)
|
||||
#define BPMSG_ADCMODE_CURRENT (0x01)
|
||||
#define BPMSG_RPC_ERRORRESULT (0xFF)
|
||||
|
||||
#define BPMSG_UINT32_SIZE (4)
|
||||
#define BPMSG_UINT16_SIZE (2)
|
||||
#define BPMSG_UINT8_SIZE (1)
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef struct t_BPMSG_MESSAGE {
|
||||
UINT8 uniqueStartByte;
|
||||
UINT8 senderId;
|
||||
UINT8 targetId;
|
||||
UINT8 packetNr;
|
||||
UINT8 status;
|
||||
UINT8 messageId;
|
||||
UINT8 payloadSize;
|
||||
UINT8 *payload;
|
||||
UINT16 crc;
|
||||
} t_bpmsg_message;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \brief Calculates the CRC over payload and sets unique start byte */
|
||||
void bpmsgEncodeMessage( t_bpmsg_message * msg );
|
||||
void bpmsgAdd16bit(UINT8 *payloadlocation, UINT16 data);
|
||||
void bpmsgAdd32bit(UINT8 *payloadlocation, UINT32 data);
|
||||
UINT8 bpmsgGet8bit(UINT8 *payload, UINT8 *payloadIndex);
|
||||
UINT16 bpmsgGet16bit(UINT8 *payload, UINT8 *payloadIndex);
|
||||
UINT32 bpmsgGet32bit(UINT8 *payload, UINT8 *payloadIndex);
|
||||
|
||||
#endif /* __BPMESSAGEFORMAT_H__ */
|
||||
@@ -0,0 +1,685 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* BusProtocol.c - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 28, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "BusProtocol.h"
|
||||
#include "ProtocolThread.h"
|
||||
#include "MessageHandlerQueue.h"
|
||||
#include "RemoteProcedureCalls.h"
|
||||
#include "RpcResults.h"
|
||||
#include "bus.h"
|
||||
#include "serial.h"
|
||||
#include "ElecStatusCache.h"
|
||||
#include "mem_mod.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef struct t_BP_ADMIN {
|
||||
UINT8 deviceId;
|
||||
UINT8 rpcRequestNr;
|
||||
int rpcHandle;
|
||||
int rpcrHandle;
|
||||
int bpthreadHandle;
|
||||
int messageHandlerHandle;
|
||||
} t_bp_admin;
|
||||
|
||||
memman *bpMessagePool;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
static void WriteElectricStatusCallback( int handle, BOOLEAN isDigital, UINT8 device, UINT8 channel, UINT16 value );
|
||||
|
||||
/** \brief Initialises the BusProtocol
|
||||
*
|
||||
* \param bus The bus to communicate on
|
||||
* \param deviceId the bus identity for this device
|
||||
* \retval the handle for the BusProtocol-driver (0 = unsuccesfull)
|
||||
*/
|
||||
int bpInit( t_bus_devices recvBus, t_bus_devices sendBus, UINT8 deviceId, UINT8 highestDeviceId, UINT8 inputQueueSize )
|
||||
{
|
||||
t_bp_admin *newBusProtocol = (t_bp_admin *)pvPortMalloc( sizeof(t_bp_admin));
|
||||
|
||||
if (newBusProtocol != NULL)
|
||||
{
|
||||
// Fill administration
|
||||
newBusProtocol->deviceId = deviceId;
|
||||
newBusProtocol->rpcRequestNr = 0;
|
||||
newBusProtocol->rpcHandle = rpcInit();
|
||||
newBusProtocol->rpcrHandle = rpcrInit();
|
||||
newBusProtocol->messageHandlerHandle = mhqInit();
|
||||
|
||||
// Allocate payload queue
|
||||
bpMessagePool = Memmod_Create( inputQueueSize, 64); // Make sure size is dividable by 4
|
||||
|
||||
// Register RPC Callback
|
||||
mhqAdd( newBusProtocol->messageHandlerHandle, BPMSG_MSGID_CALLRPC, rpcRequestHandler, newBusProtocol->rpcHandle );
|
||||
|
||||
// Register RPC-result Callback
|
||||
mhqAdd( newBusProtocol->messageHandlerHandle, BPMSG_MSGID_GIVERPCRESULTS, rpcrRequestHandler, newBusProtocol->rpcrHandle );
|
||||
|
||||
// Register Write electronic status callbac )
|
||||
bpecAttachWriteCallback(newBusProtocol, WriteElectricStatusCallback);
|
||||
|
||||
// Open bus
|
||||
busInit(recvBus);
|
||||
if (recvBus != sendBus)
|
||||
{
|
||||
busInit(sendBus);
|
||||
}
|
||||
|
||||
// Create & start thread to poll bus
|
||||
newBusProtocol->bpthreadHandle = bpthreadStart( recvBus, sendBus, deviceId, highestDeviceId, (int)newBusProtocol, newBusProtocol->messageHandlerHandle );
|
||||
}
|
||||
|
||||
return (int)newBusProtocol;
|
||||
}
|
||||
|
||||
/** \brief Closes the active BusProtocol
|
||||
*
|
||||
* \post Protocol on this handle cannot be used anymore
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
*/
|
||||
void bpDeinit( int handle )
|
||||
{
|
||||
// Stop & Destroy the bus poll thread
|
||||
rpcDeinit( ((t_bp_admin *)handle)->rpcHandle );
|
||||
rpcrDeinit( ((t_bp_admin *)handle)->rpcrHandle );
|
||||
bpthreadStop( ((t_bp_admin *)handle)->bpthreadHandle );
|
||||
|
||||
// Free BusProtocol-administration
|
||||
vPortFree( (void *)handle );
|
||||
}
|
||||
|
||||
|
||||
/** \brief Indicates whether a message a device is received in the last 10 seconds
|
||||
* Only used by the master
|
||||
*/
|
||||
BOOLEAN bpDeviceIsDetected( int handle, UINT8 deviceId )
|
||||
{
|
||||
return bpthreadDeviceIsDetected(((t_bp_admin *)handle)->bpthreadHandle, deviceId);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Sends message to pass turn (Nothing to send)
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
*/
|
||||
void bpSendPassTurn( int handle )
|
||||
{
|
||||
t_bpmsg_message sendPassTurnMessage;
|
||||
|
||||
BP_DEBUG_OUT('p');BP_DEBUG_OUT('>');
|
||||
|
||||
// Create new message
|
||||
sendPassTurnMessage.uniqueStartByte = BPMSG_STARTBYTE;
|
||||
sendPassTurnMessage.senderId = ((t_bp_admin *)handle)->deviceId;
|
||||
sendPassTurnMessage.targetId = BPMSG_BROADCAST_ID;
|
||||
sendPassTurnMessage.packetNr = 0; // packetNr filled at transmitting time
|
||||
sendPassTurnMessage.status = 0; // Clear status (filled by ProtocolThread)
|
||||
sendPassTurnMessage.messageId = BPMSG_MSGID_PASSTURN;
|
||||
sendPassTurnMessage.payloadSize = 0;
|
||||
sendPassTurnMessage.payload = NULL;
|
||||
|
||||
// Calculate CRC
|
||||
bpmsgEncodeMessage(&sendPassTurnMessage);
|
||||
|
||||
bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendPassTurnMessage);
|
||||
}
|
||||
|
||||
/** \brief Sends message to reset another bus device
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
* \param deviceId Identity of targeted bus device (0xFF = all devices)
|
||||
*/
|
||||
void bpSendResetClient( int handle, UINT8 deviceId )
|
||||
{
|
||||
t_bpmsg_message sendResetClientMessage;
|
||||
|
||||
// Create new message
|
||||
sendResetClientMessage.uniqueStartByte = BPMSG_STARTBYTE;
|
||||
sendResetClientMessage.senderId = ((t_bp_admin *)handle)->deviceId;
|
||||
sendResetClientMessage.targetId = deviceId;
|
||||
sendResetClientMessage.packetNr = 0; // packetNr filled at transmitting time
|
||||
sendResetClientMessage.status = 0; // Clear status (filled by ProtocolThread)
|
||||
sendResetClientMessage.messageId = BPMSG_MSGID_RESETCLIENT;
|
||||
sendResetClientMessage.payloadSize = 0;
|
||||
sendResetClientMessage.payload = NULL;
|
||||
|
||||
// Calculate CRC
|
||||
bpmsgEncodeMessage(&sendResetClientMessage);
|
||||
|
||||
bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendResetClientMessage);
|
||||
}
|
||||
|
||||
/** \brief Sends message with all electronic information (DAC's, ADC's and digital I/O)
|
||||
*
|
||||
* Broadcasts the electronic status of the device
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
* \param nrOfAdcValues Number of ADC-values included in the message
|
||||
* \param adcValues Pointer to a UINT16 array
|
||||
* \param nrOfDacValues Number of DAC-values included in the message
|
||||
* \param dacValues Pointer to a UINT16 array
|
||||
* \param nrOfDiValues Number of digital input values included in the message
|
||||
* \param diValues Digital input channel values (8 channels per byte)
|
||||
* \param nrOfDoValues Number of digital output values inculded in the message
|
||||
* \param doValues Digital output channel values (8 channels per byte)
|
||||
*/
|
||||
void bpSendGiveElectronicStatus( int handle,
|
||||
UINT8 nrOfAdcValues,
|
||||
UINT16 *adcValues,
|
||||
UINT8 nrOfDacValues,
|
||||
UINT16 *dacValues,
|
||||
UINT8 nrOfDiValues,
|
||||
UINT8 *diValues,
|
||||
UINT8 nrOfDoValues,
|
||||
UINT8 *doValues
|
||||
)
|
||||
{
|
||||
t_bpmsg_message sendGiveElectronicStatusMessage;
|
||||
UINT8 *payload;
|
||||
UINT16 payloadSize;
|
||||
UINT8 payloadIndex = 0;
|
||||
UINT8 index;
|
||||
|
||||
// Determine payload size
|
||||
payloadSize = BPMSG_UINT8_SIZE;
|
||||
payloadSize += nrOfAdcValues * BPMSG_UINT16_SIZE;
|
||||
payloadSize += BPMSG_UINT8_SIZE;
|
||||
payloadSize += nrOfDacValues * BPMSG_UINT16_SIZE;
|
||||
payloadSize += BPMSG_UINT8_SIZE;
|
||||
payloadSize += nrOfDiValues * BPMSG_UINT8_SIZE;
|
||||
payloadSize += BPMSG_UINT8_SIZE;
|
||||
payloadSize += nrOfDoValues * BPMSG_UINT8_SIZE;
|
||||
|
||||
payload = (UINT8 *)Memmod_Alloc( bpMessagePool );
|
||||
if (payload == 0) return;
|
||||
|
||||
// Create new message
|
||||
sendGiveElectronicStatusMessage.uniqueStartByte = BPMSG_STARTBYTE;
|
||||
sendGiveElectronicStatusMessage.senderId = ((t_bp_admin *)handle)->deviceId;
|
||||
sendGiveElectronicStatusMessage.targetId = BPMSG_BROADCAST_ID;
|
||||
sendGiveElectronicStatusMessage.packetNr = 0; // packetNr filled at transmitting time
|
||||
sendGiveElectronicStatusMessage.status = 0; // Clear status (filled by ProtocolThread)
|
||||
sendGiveElectronicStatusMessage.messageId = BPMSG_MSGID_GIVEELECTRONICSTATUS;
|
||||
sendGiveElectronicStatusMessage.payloadSize = payloadSize;
|
||||
sendGiveElectronicStatusMessage.payload = payload;
|
||||
|
||||
// Fill Payload
|
||||
payload[payloadIndex] = nrOfAdcValues;
|
||||
payloadIndex += BPMSG_UINT8_SIZE;
|
||||
for (index = 0; index < nrOfAdcValues; index++)
|
||||
{
|
||||
bpmsgAdd16bit( &payload[payloadIndex], adcValues[index]);
|
||||
payloadIndex += BPMSG_UINT16_SIZE;
|
||||
}
|
||||
|
||||
payload[payloadIndex] = nrOfDacValues;
|
||||
payloadIndex += BPMSG_UINT8_SIZE;
|
||||
for (index = 0; index < nrOfDacValues; index++)
|
||||
{
|
||||
bpmsgAdd16bit( &payload[payloadIndex], dacValues[index]);
|
||||
payloadIndex += BPMSG_UINT16_SIZE;
|
||||
}
|
||||
|
||||
payload[payloadIndex] = nrOfDiValues;
|
||||
payloadIndex += BPMSG_UINT8_SIZE;
|
||||
for (index = 0; index < nrOfDiValues; index++)
|
||||
{
|
||||
payload[payloadIndex] = diValues[index];
|
||||
payloadIndex += BPMSG_UINT8_SIZE;
|
||||
}
|
||||
|
||||
payload[payloadIndex] = nrOfDoValues;
|
||||
payloadIndex += BPMSG_UINT8_SIZE;
|
||||
for (index = 0; index < nrOfDoValues; index++)
|
||||
{
|
||||
payload[payloadIndex] = doValues[index];
|
||||
payloadIndex += BPMSG_UINT8_SIZE;
|
||||
}
|
||||
|
||||
// Calculate CRC
|
||||
bpmsgEncodeMessage(&sendGiveElectronicStatusMessage);
|
||||
|
||||
bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendGiveElectronicStatusMessage);
|
||||
}
|
||||
|
||||
/** \brief Sends message to set a DAC on another bus device
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
* \param deviceId Identity of targeted bus device
|
||||
* \param channelNr Number of the DAC-channel
|
||||
* \param dacMode Voltage (0) / Ampere (<> 0)
|
||||
* \param davValue New DAC value (voltage: 0-10000mV, ampere: 0-20000uA)
|
||||
*/
|
||||
void bpSendSetDacValue( int handle, UINT8 deviceId, UINT8 channelNr, UINT8 dacMode, UINT16 dacValue )
|
||||
{
|
||||
t_bpmsg_message sendSetDacMessage;
|
||||
UINT8 *payload = (UINT8 *) Memmod_Alloc( bpMessagePool );
|
||||
if (payload == 0) return;
|
||||
|
||||
BP_DEBUG_OUT('a'); BP_DEBUG_OUT('>');
|
||||
|
||||
// Create new message
|
||||
sendSetDacMessage.uniqueStartByte = BPMSG_STARTBYTE;
|
||||
sendSetDacMessage.senderId = ((t_bp_admin *)handle)->deviceId;
|
||||
sendSetDacMessage.targetId = deviceId;
|
||||
sendSetDacMessage.packetNr = 0; // packetNr filled at transmitting time
|
||||
sendSetDacMessage.status = 0; // Clear status (filled by ProtocolThread)
|
||||
sendSetDacMessage.messageId = BPMSG_MSGID_SETDACVALUE;
|
||||
sendSetDacMessage.payloadSize = 4;
|
||||
sendSetDacMessage.payload = payload;
|
||||
|
||||
// Fill Payload
|
||||
payload[0] = channelNr;
|
||||
payload[1] = dacMode;
|
||||
bpmsgAdd16bit( &payload[2], dacValue);
|
||||
|
||||
// Calculate CRC
|
||||
bpmsgEncodeMessage(&sendSetDacMessage);
|
||||
|
||||
bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetDacMessage);
|
||||
}
|
||||
|
||||
/** \brief Sends message to set the values of all DAC's on another bus device
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
* \param deviceId Identity of targeted bus device
|
||||
* \param davValue pointer to array with 4 DAC value, i.e. DAC-value position 0 for Channel 0 etc... (voltage: 0-10000mV, ampere: 0-20000uA)
|
||||
*/
|
||||
void bpSendSetAllDacValues( int handle, UINT8 deviceId, UINT16 *dacValue )
|
||||
{
|
||||
t_bpmsg_message sendSetDacMessage;
|
||||
UINT8 *payload = (UINT8 *) Memmod_Alloc( bpMessagePool );
|
||||
if (payload == 0) return;
|
||||
|
||||
BP_DEBUG_OUT('a'); BP_DEBUG_OUT('>');
|
||||
|
||||
// Create new message
|
||||
sendSetDacMessage.uniqueStartByte = BPMSG_STARTBYTE;
|
||||
sendSetDacMessage.senderId = ((t_bp_admin *)handle)->deviceId;
|
||||
sendSetDacMessage.targetId = deviceId;
|
||||
sendSetDacMessage.packetNr = 0; // packetNr filled at transmitting time
|
||||
sendSetDacMessage.status = 0; // Clear status (filled by ProtocolThread)
|
||||
sendSetDacMessage.messageId = BPMSG_MSGID_SETALLDACVALUES;
|
||||
sendSetDacMessage.payloadSize = 4 * 2;
|
||||
sendSetDacMessage.payload = payload;
|
||||
|
||||
// Fill Payload
|
||||
bpmsgAdd16bit( &payload[0], dacValue[0]);
|
||||
bpmsgAdd16bit( &payload[2], dacValue[1]);
|
||||
bpmsgAdd16bit( &payload[4], dacValue[2]);
|
||||
bpmsgAdd16bit( &payload[6], dacValue[3]);
|
||||
|
||||
// Calculate CRC
|
||||
bpmsgEncodeMessage(&sendSetDacMessage);
|
||||
|
||||
bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetDacMessage);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Sends message to set a digital out on another bus device
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
* \param bitNr Number of the digital output pin
|
||||
* \param value Low-level (0) or High-level (<> 0)
|
||||
*/
|
||||
void bpSendSetDigitalOutValue( int handle, UINT8 deviceId, UINT8 bitNr, UINT8 value )
|
||||
{
|
||||
t_bpmsg_message sendSetDoMessage;
|
||||
UINT8 *payload = (UINT8 *)Memmod_Alloc( bpMessagePool );
|
||||
if (payload == 0) return;
|
||||
|
||||
BP_DEBUG_OUT('d'); BP_DEBUG_OUT('>');
|
||||
|
||||
// Create new message
|
||||
sendSetDoMessage.uniqueStartByte = BPMSG_STARTBYTE;
|
||||
sendSetDoMessage.senderId = ((t_bp_admin *)handle)->deviceId;
|
||||
sendSetDoMessage.targetId = deviceId;
|
||||
sendSetDoMessage.packetNr = 0; // packetNr filled at transmitting time
|
||||
sendSetDoMessage.status = 0; // Clear status (filled by ProtocolThread)
|
||||
sendSetDoMessage.messageId = BPMSG_MSGID_SETDIGITALOUTVALUE;
|
||||
sendSetDoMessage.payloadSize = 2;
|
||||
sendSetDoMessage.payload = payload;
|
||||
|
||||
// Fill Payload
|
||||
payload[0] = bitNr;
|
||||
payload[1] = value;
|
||||
|
||||
// Calculate CRC
|
||||
bpmsgEncodeMessage(&sendSetDoMessage);
|
||||
|
||||
bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetDoMessage);
|
||||
}
|
||||
|
||||
/** \brief Sends message to set all digital out ports at once on another bus device
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
* \param deviceId The ID of the other bus device
|
||||
* \param bits All bitsNumber of the digital output pin
|
||||
*/
|
||||
void bpSendSetAllDigitalOut( int handle, UINT8 deviceId, UINT8 bits)
|
||||
{
|
||||
t_bpmsg_message sendSetDoMessage;
|
||||
UINT8 *payload = (UINT8 *)Memmod_Alloc( bpMessagePool );
|
||||
if (payload == 0) return;
|
||||
|
||||
BP_DEBUG_OUT('d'); BP_DEBUG_OUT('>');
|
||||
|
||||
// Create new message
|
||||
sendSetDoMessage.uniqueStartByte = BPMSG_STARTBYTE;
|
||||
sendSetDoMessage.senderId = ((t_bp_admin *)handle)->deviceId;
|
||||
sendSetDoMessage.targetId = deviceId;
|
||||
sendSetDoMessage.packetNr = 0; // packetNr filled at transmitting time
|
||||
sendSetDoMessage.status = 0; // Clear status (filled by ProtocolThread)
|
||||
sendSetDoMessage.messageId = BPMSG_MSGID_SETALLDIGITALOUT;
|
||||
sendSetDoMessage.payloadSize = 1;
|
||||
sendSetDoMessage.payload = payload;
|
||||
|
||||
// Fill Payload
|
||||
payload[0] = bits;
|
||||
|
||||
// Calculate CRC
|
||||
bpmsgEncodeMessage(&sendSetDoMessage);
|
||||
|
||||
bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetDoMessage);
|
||||
}
|
||||
|
||||
/** \brief Sends message to set all outputs (analogue & digital) on another bus device
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
* \param deviceId Identity of targeted bus device
|
||||
* \param bits All bitsNumber of the digital output pin
|
||||
* \param davValue pointer to array with 4 DAC value, i.e. DAC-value position 0 for Channel 0 etc... (voltage: 0-10000mV, ampere: 0-20000uA)
|
||||
*/
|
||||
void bpSendSetAllOutput( int handle, UINT8 deviceId, UINT8 bits, UINT16 *dacValue )
|
||||
{
|
||||
t_bpmsg_message sendSetAllOutpuntMessage;
|
||||
UINT8 *payload = (UINT8 *) Memmod_Alloc( bpMessagePool );
|
||||
if (payload == 0) return;
|
||||
|
||||
BP_DEBUG_OUT('a'); BP_DEBUG_OUT('o'); BP_DEBUG_OUT('>');
|
||||
|
||||
// Create new message
|
||||
sendSetAllOutpuntMessage.uniqueStartByte = BPMSG_STARTBYTE;
|
||||
sendSetAllOutpuntMessage.senderId = ((t_bp_admin *)handle)->deviceId;
|
||||
sendSetAllOutpuntMessage.targetId = deviceId;
|
||||
sendSetAllOutpuntMessage.packetNr = 0; // packetNr filled at transmitting time
|
||||
sendSetAllOutpuntMessage.status = 0; // Clear status (filled by ProtocolThread)
|
||||
sendSetAllOutpuntMessage.messageId = BPMSG_MSGID_SETALLDOUTPUT;
|
||||
sendSetAllOutpuntMessage.payloadSize = (4 * 2) + 1;
|
||||
sendSetAllOutpuntMessage.payload = payload;
|
||||
|
||||
// Fill Payload
|
||||
payload[0] = bits;
|
||||
bpmsgAdd16bit( &payload[1], dacValue[0]);
|
||||
bpmsgAdd16bit( &payload[3], dacValue[1]);
|
||||
bpmsgAdd16bit( &payload[5], dacValue[2]);
|
||||
bpmsgAdd16bit( &payload[7], dacValue[3]);
|
||||
|
||||
// Calculate CRC
|
||||
bpmsgEncodeMessage(&sendSetAllOutpuntMessage);
|
||||
|
||||
bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendSetAllOutpuntMessage);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Sends message to call an Remote Procedure Call on an other bus device
|
||||
*
|
||||
* Request to execute a procedure on another device
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
* \param deviceId Identity of targeted bus device
|
||||
* \param functionId Identity of the RPC-function
|
||||
* \param nrOfParams Number of parameters for the RPC-function
|
||||
* \param params Pointer to an array of 32-bit integers
|
||||
*/
|
||||
void bpSendCallRpc( int handle, UINT8 deviceId, UINT8 functionId, UINT8 nrOfParams, INT32 *params )
|
||||
{
|
||||
t_bpmsg_message sendCallRpcMessage;
|
||||
UINT8 *payload;
|
||||
UINT8 payloadSize;
|
||||
UINT8 payloadIndex = 0;
|
||||
UINT8 index;
|
||||
|
||||
BP_DEBUG_OUT('c'); BP_DEBUG_OUT('>');
|
||||
|
||||
// Determine payload size
|
||||
payloadSize = 3 * BPMSG_UINT8_SIZE;
|
||||
payloadSize += nrOfParams * BPMSG_UINT32_SIZE;
|
||||
|
||||
payload = (UINT8 *)Memmod_Alloc( bpMessagePool );
|
||||
if (payload == 0) return;
|
||||
|
||||
// Create new message
|
||||
sendCallRpcMessage.uniqueStartByte = BPMSG_STARTBYTE;
|
||||
sendCallRpcMessage.senderId = ((t_bp_admin *)handle)->deviceId;
|
||||
sendCallRpcMessage.targetId = deviceId;
|
||||
sendCallRpcMessage.packetNr = 0; // packetNr filled at transmitting time
|
||||
sendCallRpcMessage.status = 0; // Clear status (filled by ProtocolThread)
|
||||
sendCallRpcMessage.messageId = BPMSG_MSGID_CALLRPC;
|
||||
sendCallRpcMessage.payloadSize = payloadSize;
|
||||
sendCallRpcMessage.payload = payload;
|
||||
|
||||
// Fill Payload
|
||||
payload[payloadIndex] = ((t_bp_admin *)handle)->rpcRequestNr;
|
||||
((t_bp_admin *)handle)->rpcRequestNr++;
|
||||
payloadIndex += BPMSG_UINT8_SIZE;
|
||||
|
||||
payload[payloadIndex] = functionId;
|
||||
payloadIndex += BPMSG_UINT8_SIZE;
|
||||
|
||||
payload[payloadIndex] = nrOfParams;
|
||||
payloadIndex += BPMSG_UINT8_SIZE;
|
||||
|
||||
for (index = 0; index < nrOfParams; index++)
|
||||
{
|
||||
bpmsgAdd32bit( payload + payloadIndex, (UINT32)params[index]);
|
||||
payloadIndex += BPMSG_UINT32_SIZE;
|
||||
}
|
||||
|
||||
if (payloadIndex >= 54)
|
||||
{
|
||||
serWrite(1, sizeof("Message too large"), "Message too large");
|
||||
}
|
||||
|
||||
// Calculate CRC
|
||||
bpmsgEncodeMessage(&sendCallRpcMessage);
|
||||
|
||||
bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendCallRpcMessage);
|
||||
}
|
||||
|
||||
/** \brief Sends message to give result on issued RPC-function
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
* \param nrOfResults Number of results to be send
|
||||
* \param results Pointer to array with results.
|
||||
*/
|
||||
void bpSendRpcResult( int handle, UINT8 deviceId, UINT8 functionId, UINT8 requestNr, UINT8 nrOfResults, INT32 *results )
|
||||
{
|
||||
t_bpmsg_message sendCallRpcResultMessage;
|
||||
UINT8 *payload;
|
||||
UINT8 payloadSize;
|
||||
UINT8 payloadIndex = 0;
|
||||
UINT8 index;
|
||||
|
||||
BP_DEBUG_OUT('r'); BP_DEBUG_OUT('>');
|
||||
|
||||
// Determine payload size
|
||||
payloadSize = 3 * BPMSG_UINT8_SIZE;
|
||||
payloadSize += nrOfResults * BPMSG_UINT32_SIZE;
|
||||
|
||||
payload = (UINT8 *)Memmod_Alloc( bpMessagePool );
|
||||
if (payload == 0) return;
|
||||
|
||||
// Create new message
|
||||
sendCallRpcResultMessage.uniqueStartByte = BPMSG_STARTBYTE;
|
||||
sendCallRpcResultMessage.senderId = ((t_bp_admin *)handle)->deviceId;
|
||||
sendCallRpcResultMessage.targetId = deviceId;
|
||||
sendCallRpcResultMessage.packetNr = 0; // packetNr filled at transmitting time
|
||||
sendCallRpcResultMessage.status = 0; // Clear status (filled by ProtocolThread)
|
||||
sendCallRpcResultMessage.messageId = BPMSG_MSGID_GIVERPCRESULTS;
|
||||
sendCallRpcResultMessage.payloadSize = payloadSize;
|
||||
sendCallRpcResultMessage.payload = payload;
|
||||
|
||||
// Fill Payload
|
||||
payload[payloadIndex] = requestNr;
|
||||
payloadIndex += BPMSG_UINT8_SIZE;
|
||||
|
||||
payload[payloadIndex] = functionId;
|
||||
payloadIndex += BPMSG_UINT8_SIZE;
|
||||
|
||||
payload[payloadIndex] = nrOfResults;
|
||||
payloadIndex += BPMSG_UINT8_SIZE;
|
||||
|
||||
for (index = 0; index < nrOfResults; index++)
|
||||
{
|
||||
bpmsgAdd32bit( &payload[payloadIndex], (UINT32)results[index]);
|
||||
payloadIndex += BPMSG_UINT32_SIZE;
|
||||
}
|
||||
|
||||
// Calculate CRC
|
||||
bpmsgEncodeMessage(&sendCallRpcResultMessage);
|
||||
|
||||
bpthreadAddMessage(((t_bp_admin *)handle)->bpthreadHandle, &sendCallRpcResultMessage);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Attachs a callback, which is called when it is the device its turn to send data on the bus
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
* \param onMyTurnCallback pointer to the callback function
|
||||
*/
|
||||
void bpAttachOnMyTurn( int handle, t_bp_myturn_callback onMyTurnCallback )
|
||||
{
|
||||
t_bp_admin *bpAdmin = (t_bp_admin *)handle;
|
||||
|
||||
bpthreadAttachMyTurn( bpAdmin->bpthreadHandle, onMyTurnCallback);
|
||||
}
|
||||
|
||||
/** \brief Detaches the above callback
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
* \param onMyTurnCallback pointer to the callback function
|
||||
*/
|
||||
void bpDetachOnMyTurn( int handle, t_bp_myturn_callback onMyTurnCallback )
|
||||
{
|
||||
t_bp_admin *bpAdmin = (t_bp_admin *)handle;
|
||||
|
||||
bpthreadDetachMyTurn( bpAdmin->bpthreadHandle, onMyTurnCallback);
|
||||
}
|
||||
|
||||
/** \brief Attachs a RPC-function, which can be called by another bus device
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
* \param functionId The identity of the RPC-function
|
||||
* \param functionPointer Pointer to actual RPC-function
|
||||
* \param nrOfParams Number of parameters, required by RPC
|
||||
*/
|
||||
void bpAttachRpc( int handle, UINT8 functionId, char * functionName, t_rpc_remote_procedure_call functionPointer, UINT8 nrOfParams )
|
||||
{
|
||||
t_bp_admin *bpAdmin = (t_bp_admin *)handle;
|
||||
|
||||
rpcAdd( bpAdmin->rpcHandle, functionId, functionName, functionPointer, nrOfParams);
|
||||
}
|
||||
|
||||
/** \brief Detaches the above RPC-function
|
||||
*
|
||||
* \post RPC-function is not supported anymore
|
||||
* \param handle The handle for the BusProtocol (received with bpInit())
|
||||
* \param functionId Identity of the detached RPC-function
|
||||
*/
|
||||
void bpDetachRpc( int handle, UINT8 functionId )
|
||||
{
|
||||
t_bp_admin *bpAdmin = (t_bp_admin *)handle;
|
||||
|
||||
rpcRemove( bpAdmin->rpcHandle, functionId );
|
||||
}
|
||||
|
||||
/** \brief Attachs a "RPC result"-function, which is a result of a requeste RPC-call on another bus device
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (returned by bpInit())
|
||||
* \param functionId The functionId on which the result should be catched
|
||||
* \param functionPointer The funtion which must be called when a RPC-result is received.
|
||||
*/
|
||||
void bpAttachRpcResult( int handle, UINT8 functionId, t_bp_rpcresult_callback functionPointer, UINT8 nrOfResults )
|
||||
{
|
||||
t_bp_admin *bpAdmin = (t_bp_admin *)handle;
|
||||
|
||||
rpcrAdd( bpAdmin->rpcrHandle, functionId, functionPointer, nrOfResults);
|
||||
}
|
||||
|
||||
/** \brief Detaches the above "RPC result"-function
|
||||
*
|
||||
* \param handle The handle for the BusProtocol (returned by bpInit())
|
||||
* \param functionId The functionId on which the result should be catched
|
||||
*/
|
||||
void bpDetachRpcResult( int handle, UINT8 functionId )
|
||||
{
|
||||
t_bp_admin *bpAdmin = (t_bp_admin *)handle;
|
||||
|
||||
rpcrRemove( bpAdmin->rpcrHandle, functionId );
|
||||
}
|
||||
|
||||
t_rpc_entity *bpLookupRpcEntry( int handle, UINT8 functionId )
|
||||
{
|
||||
t_bp_admin *bpAdmin = (t_bp_admin *)handle;
|
||||
|
||||
return rpcLookupEntry( bpAdmin->rpcHandle, functionId );
|
||||
}
|
||||
|
||||
|
||||
void WriteElectricStatusCallback( int handle, BOOLEAN isDigital, UINT8 device, UINT8 channel, UINT16 value )
|
||||
{
|
||||
if (isDigital)
|
||||
{
|
||||
bpSendSetDigitalOutValue( handle, device, channel, (BOOLEAN)value ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
bpSendSetDacValue( handle, device, channel, 0, value );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* BusProtocol.h - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 28, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __BUSPROTOCOL_H__
|
||||
#define __BUSPROTOCOL_H__
|
||||
/** \file BusProtocol.h
|
||||
\brief Implementation of BusProtocol
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "bus.h"
|
||||
#include "RemoteProcedureCalls.h"
|
||||
#include "BpMessageFormat.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define MASTER_DEVICE_ID (1)
|
||||
#define MAX_PAYLOAD_SIZE (50)
|
||||
#define BP_DEBUG_OUT(a) /* serPut( COM2, a) */
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef void (*t_bp_myturn_callback)(void);
|
||||
typedef void (*t_bp_rpcresult_callback)( UINT8 requestNr, UINT8 nrOfResults, UINT32 *results );
|
||||
typedef void (*t_bp_messagehandler)(t_bpmsg_message *receivedMessage, int ownHandler );
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \brief Initialises the BusProtocol */
|
||||
int bpInit( t_bus_devices recvBus, t_bus_devices sendBus, UINT8 deviceId, UINT8 highestDeviceId, UINT8 inputQueueSize );
|
||||
|
||||
/** \brief Closes the active BusProtocol */
|
||||
void bpDeinit( int handle );
|
||||
|
||||
/** \brief Indicates whether a message a device is received in the last 10 seconds
|
||||
* Only used by the master
|
||||
*/
|
||||
BOOLEAN bpDeviceIsDetected( int handle, UINT8 deviceId );
|
||||
|
||||
/** \brief Sends message to pass turn (Nothing to send) */
|
||||
void bpSendPassTurn( int handle );
|
||||
|
||||
/** \brief Sends message to reset another bus device */
|
||||
void bpSendResetClient( int handle, UINT8 deviceId );
|
||||
|
||||
/** \brief Sends message with all electronic information (DAC's, ADC's and digital I/O) */
|
||||
void bpSendGiveElectronicStatus( int handle,
|
||||
UINT8 nrOfAdcValues,
|
||||
UINT16 *adcValues,
|
||||
UINT8 nrOfDacValues,
|
||||
UINT16 *dacValues,
|
||||
UINT8 nrOfDiValues,
|
||||
UINT8 *diValues,
|
||||
UINT8 nrOfDoValues,
|
||||
UINT8 *doValues
|
||||
);
|
||||
|
||||
/** \brief Sends message to set a DAC on another bus device */
|
||||
void bpSendSetDacValue( int handle, UINT8 deviceId, UINT8 channelNr, UINT8 dacMode, UINT16 dacValue );
|
||||
|
||||
/** \brief Sends message to set the values of all DAC's on another bus device */
|
||||
void bpSendSetAllDacValues( int handle, UINT8 deviceId, UINT16 *dacValue );
|
||||
|
||||
/** \brief Sends message to set a digital out on another bus device */
|
||||
void bpSendSetDigitalOutValue( int handle, UINT8 deviceId, UINT8 bitNr, UINT8 value );
|
||||
|
||||
/** \brief Sends message to set all digital out ports at once on another bus device */
|
||||
void bpSendSetAllDigitalOut( int handle, UINT8 deviceId, UINT8 bits);
|
||||
|
||||
/** \brief Sends message to set all outputs (analogue & digital) on another bus device */
|
||||
void bpSendSetAllOutput( int handle, UINT8 deviceId, UINT8 bits, UINT16 *dacValue);
|
||||
|
||||
/** \brief Sends message to call an Remote Procedure Call on an other bus device */
|
||||
void bpSendCallRpc( int handle, UINT8 deviceId, UINT8 functionId, UINT8 nrOfParams, INT32 *params );
|
||||
|
||||
/** \brief Attachs a callback, which is called when it is the device its turn to send data on the bus */
|
||||
void bpAttachOnMyTurn( int handle, t_bp_myturn_callback onMyTurnCallback );
|
||||
|
||||
/** \brief Detaches the above callback */
|
||||
void bpDetachOnMyTurn( int handle, t_bp_myturn_callback onMyTurnCallback );
|
||||
|
||||
/** \brief Attach callback on receiving a specific message */
|
||||
void bpAttachMessageHandler( int handle, UINT8 messageId, t_bp_messagehandler messageHandler);
|
||||
|
||||
/** \brief Attach callback on receiving a specific message */
|
||||
void bpDetachMessageHandler( int handle, UINT8 messageId, t_bp_messagehandler messageHandler);
|
||||
|
||||
/** \brief Attachs a RPC-function, which can be called by another bus device */
|
||||
void bpAttachRpc( int handle, UINT8 functionId, char * functionName, t_rpc_remote_procedure_call functionPointer, UINT8 nrOfParams );
|
||||
|
||||
/** \brief Detaches the above RPC-function */
|
||||
void bpDetachRpc( int handle, UINT8 functionId );
|
||||
|
||||
/** \brief Attachs a "RPC result"-function, which is a result of a requeste RPC-call on another bus device */
|
||||
void bpAttachRpcResult( int handle, UINT8 functionId, t_bp_rpcresult_callback functionPointer, UINT8 nrOfResult );
|
||||
|
||||
/** \brief Detaches the above "RPC result"-function */
|
||||
void bpDetachRpcResult( int handle, UINT8 functionId );
|
||||
|
||||
t_rpc_entity *bpLookupRpcEntry( int handle, UINT8 functionId );
|
||||
|
||||
/** \brief Sends message to give result on issued RPC-function */
|
||||
void bpSendRpcResult( int handle, UINT8 deviceId, UINT8 functionId, UINT8 requestNr, UINT8 nrOfResults, INT32 *results );
|
||||
|
||||
#endif /* __BUSPROTOCOL_H__ */
|
||||
@@ -0,0 +1,123 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Crc.c - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 31, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "crc.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
const UINT16 CRC_table[256] =
|
||||
{
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
|
||||
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
|
||||
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
|
||||
0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
|
||||
0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
|
||||
0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
|
||||
0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
|
||||
0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
|
||||
0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
|
||||
0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
|
||||
0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
|
||||
0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
|
||||
0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
|
||||
0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
|
||||
0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
|
||||
0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
|
||||
0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
|
||||
0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
|
||||
0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
|
||||
0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
|
||||
0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
|
||||
0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
||||
0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
|
||||
0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
|
||||
0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
|
||||
0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
|
||||
0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
|
||||
0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
|
||||
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
|
||||
0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
|
||||
0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
|
||||
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief Calculate 16 bit CRC
|
||||
*
|
||||
* a function to calculate an serial 16 bit CRC
|
||||
* according to the CCITT V.024 standard
|
||||
* To short down the calculation time of the serial CRC
|
||||
* a hash table is used.
|
||||
* This CRC is a fast (with hash table) and good CRC for
|
||||
* data transfer and integrity test of data storage. It can effectively
|
||||
* can detect errors by data transfer. 16 Bit is good for data blocks from
|
||||
* 0 - 4 KByte with a residual risk for non detection of 10E-8 per transfer.
|
||||
* (Multiply this with the error factor of the transmit line)
|
||||
*
|
||||
* The polynoom of CRC-16-CCIT = x^16 + x^12 + x^5 + 1
|
||||
*
|
||||
* \param data Build the crc from this data block
|
||||
* \param length Length of the data block
|
||||
* \param feed Initial CRC value (take 0 by default)
|
||||
*/
|
||||
UINT16 crcCalc(UINT8 * data, UINT32 length, UINT16 feed)
|
||||
{
|
||||
unsigned short crc = feed;
|
||||
unsigned char index;
|
||||
unsigned int count;
|
||||
|
||||
for(count=0; count<length; count++)
|
||||
{
|
||||
index = (unsigned char)(crc >> 8);
|
||||
crc = crc & 0x00FF;
|
||||
crc = (crc << 8);
|
||||
crc &= 0xFF00;
|
||||
crc = crc ^ CRC_table[index] ^ (*data & 0x00FF);
|
||||
data++;
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Crc.h - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 31, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __CRC_H__
|
||||
#define __CRC_H__
|
||||
/** \file Crc.h
|
||||
\brief
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
UINT16 crcCalc(UINT8 * pData, UINT32 length, UINT16 feed);
|
||||
|
||||
#endif /* __CRC_H__ */
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* MessageHandlerQueue.c - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 30, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "MessageHandlerQueue.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
typedef struct t_mhq_ENTITY
|
||||
{
|
||||
UINT8 messageId;
|
||||
t_bp_messagehandler messageHandler;
|
||||
int ownHandle;
|
||||
struct t_mhq_ENTITY *next;
|
||||
struct t_mhq_ENTITY *previous;
|
||||
} t_mhq_entity;
|
||||
|
||||
typedef struct t_mhq_ADMIN
|
||||
{
|
||||
struct t_mhq_ENTITY *head;
|
||||
struct t_mhq_ENTITY *tail;
|
||||
} t_mhq_admin;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
static t_mhq_entity *lookupMhqEntry(int handle, UINT8 messageId);
|
||||
|
||||
|
||||
int mhqInit()
|
||||
{
|
||||
t_mhq_admin *newAdmin = (t_mhq_admin *)pvPortMalloc( sizeof(t_mhq_admin) );
|
||||
|
||||
newAdmin->head = NULL;
|
||||
|
||||
return (int)newAdmin;
|
||||
}
|
||||
|
||||
void mhqDeinit(int handle)
|
||||
{
|
||||
t_mhq_entity *iterator = ((t_mhq_admin *)handle)->head;
|
||||
|
||||
while (iterator != NULL)
|
||||
{
|
||||
t_mhq_entity *nextItem = iterator->next;
|
||||
vPortFree( iterator );
|
||||
iterator = nextItem;
|
||||
}
|
||||
|
||||
vPortFree( (t_mhq_admin *)handle );
|
||||
}
|
||||
|
||||
void mhqAdd(int handle, UINT8 messageId, t_bp_messagehandler messageHandler, int ownHandle)
|
||||
{
|
||||
t_mhq_admin *theAdmin = (t_mhq_admin *)handle;
|
||||
t_mhq_entity *newEntry = (t_mhq_entity *)pvPortMalloc( sizeof(t_mhq_entity) );
|
||||
|
||||
// fill entry
|
||||
newEntry->messageId = messageId;
|
||||
newEntry->messageHandler = messageHandler;
|
||||
newEntry->ownHandle = ownHandle;
|
||||
newEntry->next = NULL;
|
||||
newEntry->previous = NULL;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
// Add to linked list
|
||||
if (theAdmin->head != NULL)
|
||||
{
|
||||
theAdmin->tail->next = newEntry;
|
||||
newEntry->previous = theAdmin->tail;
|
||||
theAdmin->tail = newEntry;
|
||||
}
|
||||
else
|
||||
{
|
||||
theAdmin->head = newEntry;
|
||||
theAdmin->tail = newEntry;
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
void mhqRemove(int handle, UINT8 messageId, t_bp_messagehandler messageHandler)
|
||||
{
|
||||
t_mhq_entity *entry = lookupMhqEntry(handle, messageId);
|
||||
t_mhq_admin *theAdmin = (t_mhq_admin *)handle;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
if (entry != NULL)
|
||||
{
|
||||
// rebuild linked list
|
||||
if (entry->next != NULL)
|
||||
{
|
||||
entry->next->previous = entry->previous;
|
||||
}
|
||||
else
|
||||
{
|
||||
theAdmin->tail = entry->previous;
|
||||
}
|
||||
|
||||
if (entry->previous != NULL)
|
||||
{
|
||||
entry->previous->next = entry->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
theAdmin->head = entry->next;
|
||||
}
|
||||
|
||||
// remove entry
|
||||
vPortFree( entry );
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
}
|
||||
|
||||
RESULT mhqExecute(int handle, UINT8 messageId, t_bpmsg_message *message)
|
||||
{
|
||||
t_mhq_entity *item = lookupMhqEntry(handle, messageId);
|
||||
|
||||
if (item != NULL)
|
||||
{
|
||||
item->messageHandler( message, item->ownHandle );
|
||||
|
||||
return OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
t_mhq_entity *lookupMhqEntry(int handle, UINT8 messageId)
|
||||
{
|
||||
t_mhq_admin *theAdmin = (t_mhq_admin *)handle;
|
||||
t_mhq_entity *result = NULL;
|
||||
t_mhq_entity *iterator;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
iterator = theAdmin->head;
|
||||
while ((result == NULL) && (iterator != NULL))
|
||||
{
|
||||
if (iterator->messageId == messageId)
|
||||
{
|
||||
result = iterator;
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator = iterator->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* MessageHandlerQueue.h - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 30, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __MESSAGEHANDLERQUEUE_H__
|
||||
#define __MESSAGEHANDLERQUEUE_H__
|
||||
/** \file MessageHandlerQueue.h
|
||||
\brief Contains a list of message handlers
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "BusProtocol.h"
|
||||
#include "BpMessageFormat.h"
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int mhqInit();
|
||||
void mhqAdd(int handle, UINT8 messageId, t_bp_messagehandler messageHandler, int ownHandle);
|
||||
void mhqRemove(int handle, UINT8 messageId, t_bp_messagehandler messageHandler);
|
||||
RESULT mhqExecute(int handle, UINT8 messageId, t_bpmsg_message *message);
|
||||
|
||||
|
||||
#endif /* __MESSAGEHANDLERQUEUE_H__ */
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* MessageQueue.c - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 29, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "MessageQueue.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
t_mq_messagequeue *mqInit()
|
||||
{
|
||||
t_mq_messagequeue *newMessageQueue = (t_mq_messagequeue *)pvPortMalloc( sizeof(t_mq_messagequeue) );
|
||||
|
||||
newMessageQueue->count = 0;
|
||||
newMessageQueue->head = 0;
|
||||
newMessageQueue->tail = 0;
|
||||
|
||||
return newMessageQueue;
|
||||
}
|
||||
|
||||
RESULT mqAdd( t_mq_messagequeue *queue, t_bpmsg_message *message)
|
||||
{
|
||||
RESULT result = OK;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
if(queue->count >= TX_QUEUE_SIZE)
|
||||
{
|
||||
result = ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy( &(queue->messages[queue->tail]), message, sizeof(t_bpmsg_message) );
|
||||
queue->count++;
|
||||
queue->tail = (queue->tail + 1) % TX_QUEUE_SIZE;
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
RESULT mqGet( t_mq_messagequeue *queue, t_bpmsg_message *message)
|
||||
{
|
||||
RESULT result = OK;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
if(queue->count > 0)
|
||||
{
|
||||
memcpy( message, &(queue->messages[queue->head]), sizeof(t_bpmsg_message) );
|
||||
queue->head = (queue->head + 1) % TX_QUEUE_SIZE;
|
||||
queue->count--;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = ERROR;
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOLEAN mqEmpty( t_mq_messagequeue *queue )
|
||||
{
|
||||
UINT8 count;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
count = queue->count;
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
return ( count == 0 ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* MessageQueue.h - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 29, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __MESSAGEQUEUE_H__
|
||||
#define __MESSAGEQUEUE_H__
|
||||
/** \file MessageQueue.h
|
||||
\brief
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "BpMessageFormat.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define TX_QUEUE_SIZE (20)
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef struct t_mq_MESSAGEQUEUE
|
||||
{
|
||||
t_bpmsg_message messages[TX_QUEUE_SIZE];
|
||||
UINT8 head;
|
||||
UINT8 tail;
|
||||
UINT8 count;
|
||||
} t_mq_messagequeue;
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
t_mq_messagequeue *mqInit();
|
||||
RESULT mqAdd( t_mq_messagequeue *queue, t_bpmsg_message *message);
|
||||
RESULT mqGet( t_mq_messagequeue *queue, t_bpmsg_message *message);
|
||||
BOOLEAN mqEmpty( t_mq_messagequeue *queue );
|
||||
|
||||
|
||||
#endif /* __MESSAGEQUEUE_H__ */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,80 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* ProtocolThread.h - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 29, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __PROTOCOLTHREAD_H__
|
||||
#define __PROTOCOLTHREAD_H__
|
||||
/** \file ProtocolThread.h
|
||||
\brief Thread which handles the messaging of the protocol.
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "bus.h"
|
||||
#include "BpMessageFormat.h"
|
||||
#include "BusProtocol.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** \brief Starts the protocol handling thread */
|
||||
int bpthreadStart( t_bus_devices recvBus, t_bus_devices sendBus, UINT8 deviceId, UINT8 highestDeviceId, int bpHandle, int mhqHandle );
|
||||
|
||||
/** \brief Stops the protocol handling thread */
|
||||
void bpthreadStop( int handle );
|
||||
|
||||
/** \brief Indicates whether a message a device is received in the last 10 seconds
|
||||
* Only used by the master
|
||||
*/
|
||||
BOOLEAN bpthreadDeviceIsDetected( int handle, UINT8 deviceId );
|
||||
|
||||
/** \brief Add a message to the tx-queue. Message will be send when its this device its turn */
|
||||
void bpthreadAddMessage( int handle, t_bpmsg_message *message );
|
||||
|
||||
/** \brief Attaches a callback function to MyTurn-event, which notifies when it is this device its turn */
|
||||
void bpthreadAttachMyTurn( int handle, t_bp_myturn_callback callback);
|
||||
|
||||
/** \brief Detaches the callback function to MyTurn-event */
|
||||
void bpthreadDetachMyTurn( int handle, t_bp_myturn_callback callback);
|
||||
|
||||
|
||||
#endif /* __PROTOCOLTHREAD_H__ */
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* RemoteProcedureCalls.c - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 29, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "RemoteProcedureCalls.h"
|
||||
#include "serial.h"
|
||||
#include "BusProtocol.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
#include "mem_mod.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define RPC_DISPATCH_QUEUE_SIZE (10)
|
||||
|
||||
|
||||
extern memman *bpMessagePool;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
//static t_rpc_entity *lookupRpcEntry( int handle, UINT8 functionId );
|
||||
|
||||
|
||||
/** \brief Initialises a Remote Procedure Call administration
|
||||
*
|
||||
* \returns Handle to Remote Procedure Call administration (0 = failure)
|
||||
*/
|
||||
int rpcInit()
|
||||
{
|
||||
t_rpc_admin *newAdmin = (t_rpc_admin *)pvPortMalloc( sizeof(t_rpc_admin) );
|
||||
if (newAdmin != NULL)
|
||||
{
|
||||
newAdmin->firstEntry = NULL;
|
||||
newAdmin->lastEntry = NULL;
|
||||
}
|
||||
|
||||
return (int)newAdmin;
|
||||
}
|
||||
|
||||
/** \brief Deinitialises the Remote Procedure Call administration
|
||||
*
|
||||
* \param handle Handle to RPC-adminstration
|
||||
*/
|
||||
void rpcDeinit( int handle )
|
||||
{
|
||||
t_rpc_admin *theAdmin = (t_rpc_admin *)handle;
|
||||
|
||||
// Remove whole list
|
||||
if (theAdmin->firstEntry != NULL)
|
||||
{
|
||||
t_rpc_entity *entry = theAdmin->firstEntry;
|
||||
|
||||
while (entry != NULL)
|
||||
{
|
||||
t_rpc_entity *nextEntry = entry->next;
|
||||
|
||||
vPortFree( entry );
|
||||
|
||||
entry = nextEntry;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove admin
|
||||
vPortFree( (void *)handle );
|
||||
}
|
||||
|
||||
/** \brief Adds a Remote Procedure Call to the administration
|
||||
*
|
||||
* \param handle Handle to RPC-administration
|
||||
* \param functionId Identifier for RPC
|
||||
* \param nrOfParams Nr of parameters required by RPC-function
|
||||
*/
|
||||
void rpcAdd( int handle, UINT8 functionId, char * functionName, t_rpc_remote_procedure_call funcptr, UINT8 nrOfParams )
|
||||
{
|
||||
t_rpc_entity *newEntry = (t_rpc_entity *)pvPortMalloc( sizeof(t_rpc_entity) );
|
||||
t_rpc_admin *theAdmin = (t_rpc_admin *)handle;
|
||||
|
||||
// fill entry
|
||||
newEntry->functionId = functionId;
|
||||
newEntry->functionName = functionName;
|
||||
newEntry->rpcFunction = funcptr;
|
||||
newEntry->nrOfParams = nrOfParams;
|
||||
newEntry->next = NULL;
|
||||
newEntry->previous = NULL;
|
||||
|
||||
// Add to linked list
|
||||
if (theAdmin->firstEntry != NULL)
|
||||
{
|
||||
theAdmin->lastEntry->next = newEntry;
|
||||
newEntry->previous = theAdmin->lastEntry;
|
||||
theAdmin->lastEntry = newEntry;
|
||||
}
|
||||
else
|
||||
{
|
||||
theAdmin->firstEntry = newEntry;
|
||||
theAdmin->lastEntry = newEntry;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Removes a Remote Procedure Call to the administration
|
||||
*
|
||||
* \param handle Handle to RPC-administration
|
||||
* \param functionId Identifier for RPC-function
|
||||
*/
|
||||
void rpcRemove( int handle, UINT8 functionId )
|
||||
{
|
||||
t_rpc_entity *entry = rpcLookupEntry(handle, functionId);
|
||||
t_rpc_admin *theAdmin = (t_rpc_admin *)handle;
|
||||
|
||||
if (entry != NULL)
|
||||
{
|
||||
// rebuild linked list
|
||||
if (entry->next != NULL)
|
||||
{
|
||||
entry->next->previous = entry->previous;
|
||||
}
|
||||
else
|
||||
{
|
||||
theAdmin->lastEntry = entry->previous;
|
||||
}
|
||||
|
||||
if (entry->previous != NULL)
|
||||
{
|
||||
entry->previous->next = entry->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
theAdmin->firstEntry = entry->next;
|
||||
}
|
||||
|
||||
// remove entry
|
||||
vPortFree( entry );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** \brief Looks up a Remote Procedure Call to the administration
|
||||
*
|
||||
* \param handle Handle to RPC-administration
|
||||
* \param functionId Identifier for RPC-function
|
||||
* \retval Pointer to RPC-function (NULL when not found)
|
||||
*/
|
||||
t_rpc_remote_procedure_call rpcLookup( int handle, UINT8 functionId )
|
||||
{
|
||||
t_rpc_remote_procedure_call result = NULL;
|
||||
t_rpc_entity *entry = rpcLookupEntry(handle, functionId);
|
||||
|
||||
if (entry != NULL)
|
||||
{
|
||||
result = entry->rpcFunction;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** \brief Executes a Remote Procedure Call
|
||||
*
|
||||
* \param handle Handle to RPC-administration
|
||||
* \param nrOfParams Nr of parameters in params-array
|
||||
* \param params Pointer to array with all parameters
|
||||
* \retval OK RPC request is send
|
||||
* \retval ERROR Unable to send RPC request
|
||||
*/
|
||||
RESULT rpcExecute( int handle, UINT8 functionId, UINT8 nrOfParams, const UINT32 *params )
|
||||
{
|
||||
t_rpc_entity *entry = rpcLookupEntry(handle, functionId);
|
||||
if (entry != NULL)
|
||||
{
|
||||
// Dispatch function to rpcThread
|
||||
// execute function
|
||||
//result = entry->rpcFunction;
|
||||
return OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
t_rpc_entity *rpcLookupEntry( int handle, UINT8 functionId )
|
||||
{
|
||||
t_rpc_admin *theAdmin = (t_rpc_admin *)handle;
|
||||
t_rpc_entity *result = NULL;
|
||||
t_rpc_entity *iterator;
|
||||
|
||||
iterator = theAdmin->firstEntry;
|
||||
while ((result == NULL) && (iterator != NULL))
|
||||
{
|
||||
if (iterator->functionId == functionId)
|
||||
{
|
||||
result = iterator;
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator = iterator->next;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void rpcRequestHandler(t_bpmsg_message *msg, int ownHandler)
|
||||
{
|
||||
UINT8 index = 0;
|
||||
UINT8 count;
|
||||
UINT8 targetId, senderId, requestNr, functionId, nrOfParams;
|
||||
UINT32 *params;
|
||||
t_rpc_entity *rpcEntry;
|
||||
|
||||
// Decode message
|
||||
targetId = msg->targetId;
|
||||
senderId = msg->senderId;
|
||||
requestNr = bpmsgGet8bit( msg->payload, &index);
|
||||
functionId = bpmsgGet8bit( msg->payload, &index);
|
||||
nrOfParams = bpmsgGet8bit( msg->payload, &index);
|
||||
|
||||
BP_DEBUG_OUT('{');
|
||||
BP_DEBUG_OUT('a' + functionId);
|
||||
|
||||
// Allocate an array for the params
|
||||
if (nrOfParams > 0)
|
||||
{
|
||||
params = (UINT32 *)Memmod_Alloc( bpMessagePool );
|
||||
if (params != NULL)
|
||||
{
|
||||
for (count = 0; count < nrOfParams; count++)
|
||||
{
|
||||
params[count] = bpmsgGet32bit(msg->payload, &index);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Error already indicated by heap_2.c
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
params = NULL;
|
||||
}
|
||||
|
||||
// Call RPC-function
|
||||
rpcEntry = rpcLookupEntry(ownHandler, functionId);
|
||||
if (rpcEntry != NULL)
|
||||
{
|
||||
BP_DEBUG_OUT('a' + functionId);
|
||||
// execute function
|
||||
rpcEntry->rpcFunction( senderId, targetId, requestNr, functionId, nrOfParams, params );
|
||||
}
|
||||
|
||||
if (params != NULL)
|
||||
{
|
||||
Memmod_Free( bpMessagePool, params );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* RemoteProcedureCalls.h - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: Holds supported Remote Procedure Calls
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 29, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __REMOTEPROCEDURECALLS_H__
|
||||
#define __REMOTEPROCEDURECALLS_H__
|
||||
/** \file RemoteProcedureCalls.h
|
||||
\brief
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "BpMessageFormat.h"
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
typedef void (*t_rpc_remote_procedure_call)( UINT8 senderId, UINT8 targetId, UINT8 requestNr, UINT8 functionId, UINT8 nrOfParams, UINT32 *params );
|
||||
|
||||
typedef struct t_RPC_ENTITY {
|
||||
UINT8 functionId;
|
||||
char * functionName;
|
||||
UINT8 nrOfParams;
|
||||
t_rpc_remote_procedure_call rpcFunction;
|
||||
struct t_RPC_ENTITY *next;
|
||||
struct t_RPC_ENTITY *previous;
|
||||
} t_rpc_entity;
|
||||
|
||||
typedef struct t_RPC_ADMIN {
|
||||
t_rpc_entity *firstEntry;
|
||||
t_rpc_entity *lastEntry;
|
||||
} t_rpc_admin;
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** \brief Initialises a Remote Procedure Call administration */
|
||||
int rpcInit();
|
||||
|
||||
/** \brief Deinitialises the Remote Procedure Call administration */
|
||||
void rpcDeinit( int handle );
|
||||
|
||||
/** \brief Adds a Remote Procedure Call to the administration */
|
||||
void rpcAdd( int handle, UINT8 functionId, char * functionName, t_rpc_remote_procedure_call funcptr, UINT8 nrOfParams );
|
||||
|
||||
/** \brief Removes a Remote Procedure Call to the administration */
|
||||
void rpcRemove( int handle, UINT8 functionId );
|
||||
|
||||
/** \brief Looks up a Remote Procedure Call to the administration */
|
||||
t_rpc_remote_procedure_call rpcLookup( int handle, UINT8 functionId );
|
||||
|
||||
/** \brief Executes a Remote Procedure Call */
|
||||
RESULT rpcExecute( int handle, UINT8 functionId, UINT8 nrOfParams, const UINT32 *params );
|
||||
|
||||
t_rpc_entity *rpcLookupEntry( int handle, UINT8 functionId );
|
||||
|
||||
/** \brief Message handler for RPC-requests */
|
||||
void rpcRequestHandler(t_bpmsg_message *msg, int ownHandler);
|
||||
|
||||
#endif /* __REMOTEPROCEDURECALLS_H__ */
|
||||
@@ -0,0 +1,288 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* RemoteProcedureCalls.c - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 29, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "RpcResults.h"
|
||||
#include "serial.h"
|
||||
#include "BusProtocol.h"
|
||||
#include "mem_mod.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define RPCR_DISPATCH_QUEUE_SIZE (10)
|
||||
|
||||
typedef struct t_RPCR_ENTITY {
|
||||
UINT8 functionId;
|
||||
UINT8 nrOfParams;
|
||||
t_bp_rpcresult_callback rpcrFunction;
|
||||
struct t_RPCR_ENTITY *next;
|
||||
struct t_RPCR_ENTITY *previous;
|
||||
} t_rpcr_entity;
|
||||
|
||||
typedef struct t_RPCR_ADMIN {
|
||||
t_rpcr_entity *firstEntry;
|
||||
t_rpcr_entity *lastEntry;
|
||||
} t_rpcr_admin;
|
||||
|
||||
extern memman *bpMessagePool;
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
static t_rpcr_entity *lookupRpcrEntry( int handle, UINT8 functionId );
|
||||
|
||||
|
||||
/** \brief Initialises a Remote Procedure Call administration
|
||||
*
|
||||
* \returns Handle to Remote Procedure Call administration (0 = failure)
|
||||
*/
|
||||
int rpcrInit()
|
||||
{
|
||||
t_rpcr_admin *newAdmin = (t_rpcr_admin *)pvPortMalloc( sizeof(t_rpcr_admin) );
|
||||
if (newAdmin != NULL)
|
||||
{
|
||||
newAdmin->firstEntry = NULL;
|
||||
newAdmin->lastEntry = NULL;
|
||||
}
|
||||
|
||||
return (int)newAdmin;
|
||||
}
|
||||
|
||||
/** \brief Deinitialises the Remote Procedure Call administration
|
||||
*
|
||||
* \param handle Handle to RPC-adminstration
|
||||
*/
|
||||
void rpcrDeinit( int handle )
|
||||
{
|
||||
t_rpcr_admin *theAdmin = (t_rpcr_admin *)handle;
|
||||
|
||||
// Remove whole list
|
||||
if (theAdmin->firstEntry != NULL)
|
||||
{
|
||||
t_rpcr_entity *entry = theAdmin->firstEntry;
|
||||
|
||||
while (entry != NULL)
|
||||
{
|
||||
t_rpcr_entity *nextEntry = entry->next;
|
||||
|
||||
vPortFree( entry );
|
||||
|
||||
entry = nextEntry;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove admin
|
||||
vPortFree( (void *)handle );
|
||||
}
|
||||
|
||||
/** \brief Adds a Remote Procedure Call to the administration
|
||||
*
|
||||
* \param handle Handle to RPC-administration
|
||||
* \param functionId Identifier for RPC
|
||||
* \param nrOfParams Nr of parameters required by RPC-function
|
||||
*/
|
||||
void rpcrAdd( int handle, UINT8 functionId, t_bp_rpcresult_callback funcptr, UINT8 nrOfParams )
|
||||
{
|
||||
t_rpcr_entity *newEntry = (t_rpcr_entity *)pvPortMalloc( sizeof(t_rpcr_entity) );
|
||||
t_rpcr_admin *theAdmin = (t_rpcr_admin *)handle;
|
||||
|
||||
// fill entry
|
||||
newEntry->functionId = functionId;
|
||||
newEntry->rpcrFunction = funcptr;
|
||||
newEntry->nrOfParams = nrOfParams;
|
||||
newEntry->next = NULL;
|
||||
newEntry->previous = NULL;
|
||||
|
||||
// Add to linked list
|
||||
if (theAdmin->firstEntry != NULL)
|
||||
{
|
||||
theAdmin->lastEntry->next = newEntry;
|
||||
newEntry->previous = theAdmin->lastEntry;
|
||||
theAdmin->lastEntry = newEntry;
|
||||
}
|
||||
else
|
||||
{
|
||||
theAdmin->firstEntry = newEntry;
|
||||
theAdmin->lastEntry = newEntry;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Removes a Remote Procedure Call to the administration
|
||||
*
|
||||
* \param handle Handle to RPC-administration
|
||||
* \param functionId Identifier for RPC-function
|
||||
*/
|
||||
void rpcrRemove( int handle, UINT8 functionId )
|
||||
{
|
||||
t_rpcr_entity *entry = lookupRpcrEntry(handle, functionId);
|
||||
t_rpcr_admin *theAdmin = (t_rpcr_admin *)handle;
|
||||
|
||||
if (entry != NULL)
|
||||
{
|
||||
// rebuild linked list
|
||||
if (entry->next != NULL)
|
||||
{
|
||||
entry->next->previous = entry->previous;
|
||||
}
|
||||
else
|
||||
{
|
||||
theAdmin->lastEntry = entry->previous;
|
||||
}
|
||||
|
||||
if (entry->previous != NULL)
|
||||
{
|
||||
entry->previous->next = entry->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
theAdmin->firstEntry = entry->next;
|
||||
}
|
||||
|
||||
// remove entry
|
||||
vPortFree( entry );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** \brief Looks up a Remote Procedure Call to the administration
|
||||
*
|
||||
* \param handle Handle to RPC-administration
|
||||
* \param functionId Identifier for RPC-function
|
||||
* \retval Pointer to RPC-function (NULL when not found)
|
||||
*/
|
||||
t_bp_rpcresult_callback rpcrLookup( int handle, UINT8 functionId )
|
||||
{
|
||||
t_bp_rpcresult_callback result = NULL;
|
||||
t_rpcr_entity *entry = lookupRpcrEntry(handle, functionId);
|
||||
|
||||
if (entry != NULL)
|
||||
{
|
||||
result = entry->rpcrFunction;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
t_rpcr_entity *lookupRpcrEntry( int handle, UINT8 functionId )
|
||||
{
|
||||
t_rpcr_admin *theAdmin = (t_rpcr_admin *)handle;
|
||||
t_rpcr_entity *result = NULL;
|
||||
t_rpcr_entity *iterator;
|
||||
|
||||
iterator = theAdmin->firstEntry;
|
||||
while ((result == NULL) && (iterator != NULL))
|
||||
{
|
||||
if (iterator->functionId == functionId)
|
||||
{
|
||||
result = iterator;
|
||||
}
|
||||
else
|
||||
{
|
||||
iterator = iterator->next;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void rpcrRequestHandler(t_bpmsg_message *msg, int ownHandler)
|
||||
{
|
||||
UINT8 index = 0;
|
||||
UINT8 count;
|
||||
UINT8 targetId, senderId, requestNr, functionId, nrOfResults;
|
||||
UINT32 *results;
|
||||
t_rpcr_entity *rpcrEntry;
|
||||
|
||||
BP_DEBUG_OUT( '!');
|
||||
|
||||
// Decode message
|
||||
targetId = msg->targetId;
|
||||
senderId = msg->senderId;
|
||||
requestNr = bpmsgGet8bit( msg->payload, &index);
|
||||
functionId = bpmsgGet8bit( msg->payload, &index);
|
||||
nrOfResults = bpmsgGet8bit( msg->payload, &index);
|
||||
|
||||
// Allocate an array for the params
|
||||
if (nrOfResults > 0)
|
||||
{
|
||||
results = (UINT32 *)Memmod_Alloc( bpMessagePool );
|
||||
if (results != NULL)
|
||||
{
|
||||
for (count = 0; count < nrOfResults; count++)
|
||||
{
|
||||
results[count] = bpmsgGet32bit(msg->payload, &index);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Error already indicated by heap_2.c
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
results = NULL;
|
||||
}
|
||||
|
||||
// Call RPC-function
|
||||
rpcrEntry = lookupRpcrEntry(ownHandler, functionId);
|
||||
if (rpcrEntry != NULL)
|
||||
{
|
||||
// execute function
|
||||
BP_DEBUG_OUT('#');
|
||||
rpcrEntry->rpcrFunction( requestNr, nrOfResults, results );
|
||||
}
|
||||
|
||||
if (results != NULL)
|
||||
{
|
||||
Memmod_Free( bpMessagePool, results );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* RpcResults.h - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: Holds supported Remote Procedure Calls
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 29, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __RPCRESULTS_H__
|
||||
#define __RPCRESULTS_H__
|
||||
/** \file RpcResults.h
|
||||
\brief
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "BusProtocol.h"
|
||||
#include "BpMessageFormat.h"
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** \brief Initialises a Remote Procedure Call-Result administration */
|
||||
int rpcrInit();
|
||||
|
||||
/** \brief Deinitialises the Remote Procedure Call-Result administration */
|
||||
void rpcrDeinit( int handle );
|
||||
|
||||
/** \brief Adds a RPC-result handler to the administration */
|
||||
void rpcrAdd( int handle, UINT8 functionId, t_bp_rpcresult_callback funcptr, UINT8 nrOfParams);
|
||||
|
||||
/** \brief Removes a RPC-result handler to the administration */
|
||||
void rpcrRemove( int handle, UINT8 functionId );
|
||||
|
||||
/** \brief Looks up a RPC-result handler to the administration */
|
||||
t_bp_rpcresult_callback rpcrLookup( int handle, UINT8 functionId );
|
||||
|
||||
/** \brief Message handler for RPC-requests */
|
||||
void rpcrRequestHandler(t_bpmsg_message *msg, int ownHandler);
|
||||
|
||||
#endif /* __RPCRESULTS_H__ */
|
||||
@@ -0,0 +1,90 @@
|
||||
|
||||
#include "mem_mod.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "Task.h"
|
||||
#include "Queue.h"
|
||||
|
||||
extern void serWrite (
|
||||
int device,
|
||||
short length, /**< Lengh of data in bytes */
|
||||
char * data /**< Pointer to data */
|
||||
);
|
||||
|
||||
void Memmod_Init(memman *me,unsigned char buf_count,unsigned short buf_size)
|
||||
{
|
||||
unsigned char *buffer;
|
||||
unsigned short i;
|
||||
me->count = buf_count;
|
||||
me->size = buf_size;
|
||||
buffer = pvPortMalloc(buf_count*buf_size);
|
||||
me->buffer = buffer;
|
||||
me->free_index = buf_count;
|
||||
me->freelist = pvPortMalloc(buf_count*sizeof(link_item));
|
||||
for(i=0;i<buf_count;i++)
|
||||
{
|
||||
me->freelist[i].data = buffer;
|
||||
buffer = buffer+buf_size;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char* Memmod_GetBuffer(memman *me)
|
||||
{
|
||||
return me->buffer;
|
||||
}
|
||||
|
||||
memman *Memmod_Create(unsigned char buf_count,unsigned short buf_size)
|
||||
{
|
||||
memman *new_item;
|
||||
new_item = (memman *)pvPortMalloc(sizeof(memman));
|
||||
Memmod_Init(new_item,buf_count,buf_size);
|
||||
return new_item;
|
||||
}
|
||||
|
||||
void *Memmod_Alloc(memman *me)
|
||||
{
|
||||
unsigned char index;
|
||||
void *retval;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
index = me->free_index;
|
||||
if(index > 0)
|
||||
{
|
||||
index--;
|
||||
me->free_index=index;
|
||||
retval = me->freelist[index].data;
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = 0;
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
if (retval == 0)
|
||||
{
|
||||
serWrite(1, sizeof("buffer error"), "buffer error");
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
void Memmod_Free(memman *me,void *buffer)
|
||||
{
|
||||
unsigned char index;
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
{
|
||||
index = me->free_index;
|
||||
if(index < me->count)
|
||||
{
|
||||
me->freelist[index].data = buffer;
|
||||
index++;
|
||||
me->free_index=index;
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef _MEM_MODH
|
||||
#define _MEM_MODH
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct link_item
|
||||
{
|
||||
void *data;
|
||||
} link_item;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char count;
|
||||
unsigned char size;
|
||||
unsigned char free_index;
|
||||
void *buffer;
|
||||
link_item *freelist;
|
||||
} memman;
|
||||
|
||||
void Memmod_Init(memman *me,unsigned char buf_count,unsigned short buf_size);
|
||||
memman *Memmod_Create(unsigned char buf_count,unsigned short buf_size);
|
||||
unsigned char* Memmod_GetBuffer(memman *me);
|
||||
void *Memmod_Alloc(memman *me);
|
||||
void Memmod_Free(memman *me,void *buffer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,554 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?>
|
||||
|
||||
<cproject>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939">
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="a" artifactName="Drivers" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" description="" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939" name="Debug" parent="org.eclipse.cdt.build.core.prefbase.cfg" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="" prebuildStep="">
|
||||
<folderInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939." name="/" resourcePath="">
|
||||
<toolChain id="cdt.managedbuild.toolchain.gnu.cygwin.base.633642026" name="Cygwin GCC" superClass="cdt.managedbuild.toolchain.gnu.cygwin.base" unusedChildren="cdt.managedbuild.tool.gnu.cpp.compiler.cygwin.base;cdt.managedbuild.tool.gnu.cpp.linker.cygwin.base">
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.Cygwin_PE" id="cdt.managedbuild.target.gnu.platform.cygwin.base.2110914823" name="Debug Platform" osList="win32" superClass="cdt.managedbuild.target.gnu.platform.cygwin.base"/>
|
||||
<builder buildPath="${workspace_loc:/Drivers/Debug}" id="cdt.managedbuild.target.gnu.builder.cygwin.base.607554776" keepEnvironmentInBuildfile="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.cygwin.base"/>
|
||||
<tool command="arm-elf-ar" id="cdt.managedbuild.tool.gnu.archiver.cygwin.base.357143976" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.cygwin.base">
|
||||
<option id="gnu.both.lib.option.flags.1185130714" name="Archiver flags" superClass="gnu.both.lib.option.flags" value="-r" valueType="string"/>
|
||||
</tool>
|
||||
<tool command="arm-elf-gcc" id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base">
|
||||
<option id="gnu.c.compiler.option.include.paths.1137340833" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/MmcFilesystem}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Drivers/webserver}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Drivers/webserver/httpd-fs}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Drivers/ethernet/httpd}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Drivers/ethernet/httpd/httpd-fs}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Drivers/ethernet}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/FreeRTOS/include}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/BusProtocol}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/Drivers}""/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.misc.other.1949135949" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fomit-frame-pointer -mcpu=arm7tdmi -fshort-enums -mthumb-interwork" valueType="string"/>
|
||||
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1085516223" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="ROWLEY_LPC23xx"/>
|
||||
<listOptionValue builtIn="false" value="LPC23xx"/>
|
||||
<listOptionValue builtIn="false" value="LPC2378_PORTB"/>
|
||||
<listOptionValue builtIn="false" value="PACK_STRUCT_END=__attribute\(\(packed\)\)"/>
|
||||
<listOptionValue builtIn="false" value="ALIGN_STRUCT_END=__attribute\(\(aligned\(4\)\)\)"/>
|
||||
</option>
|
||||
<option id="gnu.c.compiler.option.optimization.level.1752774671" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" value="gnu.c.optimization.level.more" valueType="enumerated"/>
|
||||
<option id="gnu.c.compiler.option.misc.verbose.462009253" name="Verbose (-v)" superClass="gnu.c.compiler.option.misc.verbose" value="false" valueType="boolean"/>
|
||||
<option id="gnu.c.compiler.option.misc.ansi.2137510527" name="Support ANSI programs (-ansi)" superClass="gnu.c.compiler.option.misc.ansi" value="false" valueType="boolean"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.604520423" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool command="arm-elf-as" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" id="cdt.managedbuild.tool.gnu.assembler.cygwin.base.406320894" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.cygwin.base">
|
||||
<option id="gnu.both.asm.option.flags.1225377542" name="Assembler flags" superClass="gnu.both.asm.option.flags" value="-mcpu=arm7tdmi " valueType="string"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1377488642" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.linker.cygwin.base.1772915699" name="Cygwin C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.cygwin.base"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<fileInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939.1726487795" name="uart2ISR.c" rcbsApplicability="disable" resourcePath="uart2ISR.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.807212826">
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.807212826" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668">
|
||||
<option id="gnu.c.compiler.option.misc.other.1483219050" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fomit-frame-pointer -mcpu=arm7tdmi -mthumb-interwork" valueType="string"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.538962034" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.1247135253" name="Resource Custom Build Step">
|
||||
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.1636187940" name="Resource Custom Build Step Input Type">
|
||||
<additionalInput kind="additionalinputdependency" paths=""/>
|
||||
</inputType>
|
||||
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.2037878102" name="Resource Custom Build Step Output Type"/>
|
||||
</tool>
|
||||
</fileInfo>
|
||||
<fileInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939.542584516" name="ssp0ISR.h" rcbsApplicability="disable" resourcePath="ssp0ISR.h" toolsToInvoke="">
|
||||
<tool announcement="Invoking: Resource Custom Build Step" command="" customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.1012553571" name="Resource Custom Build Step">
|
||||
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.220483950" name="Resource Custom Build Step Input Type">
|
||||
<additionalInput kind="additionalinputdependency" paths=""/>
|
||||
</inputType>
|
||||
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1469071974" name="Resource Custom Build Step Output Type" outputNames=""/>
|
||||
</tool>
|
||||
</fileInfo>
|
||||
<fileInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939.1910095641" name="uartISR.c" rcbsApplicability="disable" resourcePath="uartISR.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.1416994682">
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.1416994682" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668">
|
||||
<option id="gnu.c.compiler.option.misc.other.1446657461" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fomit-frame-pointer -mcpu=arm7tdmi -mthumb-interwork" valueType="string"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.140142352" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.1456382687" name="Resource Custom Build Step">
|
||||
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.477895768" name="Resource Custom Build Step Input Type">
|
||||
<additionalInput kind="additionalinputdependency" paths=""/>
|
||||
</inputType>
|
||||
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1335295582" name="Resource Custom Build Step Output Type"/>
|
||||
</tool>
|
||||
</fileInfo>
|
||||
<fileInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939.71673656" name="uart3ISR.c" rcbsApplicability="disable" resourcePath="uart3ISR.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.362131041">
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.362131041" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668">
|
||||
<option id="gnu.c.compiler.option.misc.other.225622065" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fomit-frame-pointer -mcpu=arm7tdmi -mthumb-interwork" valueType="string"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.401063069" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.413027139" name="Resource Custom Build Step">
|
||||
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.1803766596" name="Resource Custom Build Step Input Type">
|
||||
<additionalInput kind="additionalinputdependency" paths=""/>
|
||||
</inputType>
|
||||
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1065873980" name="Resource Custom Build Step Output Type"/>
|
||||
</tool>
|
||||
</fileInfo>
|
||||
<fileInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939.291818688" name="armVIC.h" rcbsApplicability="disable" resourcePath="armVIC.h" toolsToInvoke=""/>
|
||||
<fileInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939.1708887602" name="InternalFlash.c" rcbsApplicability="disable" resourcePath="InternalFlash.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.932504930">
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.932504930" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668">
|
||||
<option id="gnu.c.compiler.option.misc.other.558003532" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fomit-frame-pointer -mcpu=arm7tdmi -mthumb-interwork -Wa,-adhlns=InternalFlash.lst" valueType="string"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.1690946070" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool announcement="Invoking: Resource Custom Build Step" command="" customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.961589329" name="Resource Custom Build Step">
|
||||
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.1906296082" name="Resource Custom Build Step Input Type">
|
||||
<additionalInput kind="additionalinputdependency" paths=""/>
|
||||
</inputType>
|
||||
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1575197997" name="Resource Custom Build Step Output Type" outputNames=""/>
|
||||
</tool>
|
||||
</fileInfo>
|
||||
<fileInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939.1994651202" name="ssp0ISR.c" rcbsApplicability="disable" resourcePath="ssp0ISR.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.913112132">
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.913112132" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668">
|
||||
<option id="gnu.c.compiler.option.misc.other.494774626" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fomit-frame-pointer -mcpu=arm7tdmi -mthumb-interwork" valueType="string"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.1950626595" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.1012067148" name="Resource Custom Build Step">
|
||||
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.1191788519" name="Resource Custom Build Step Input Type">
|
||||
<additionalInput kind="additionalinputdependency" paths=""/>
|
||||
</inputType>
|
||||
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.904965216" name="Resource Custom Build Step Output Type"/>
|
||||
</tool>
|
||||
</fileInfo>
|
||||
<fileInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939.498448602" name="ssp1ISR.c" rcbsApplicability="disable" resourcePath="ssp1ISR.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.2078712431">
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.2078712431" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668">
|
||||
<option id="gnu.c.compiler.option.misc.other.1436529494" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fomit-frame-pointer -mcpu=arm7tdmi -mthumb-interwork" valueType="string"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.2052416051" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.1278877933" name="Resource Custom Build Step">
|
||||
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.2116630855" name="Resource Custom Build Step Input Type">
|
||||
<additionalInput kind="additionalinputdependency" paths=""/>
|
||||
</inputType>
|
||||
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1780833023" name="Resource Custom Build Step Output Type"/>
|
||||
</tool>
|
||||
</fileInfo>
|
||||
<fileInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939.295586484" name="dioISR.c" rcbsApplicability="disable" resourcePath="dioISR.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.1556128745">
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.1556128745" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668">
|
||||
<option id="gnu.c.compiler.option.misc.other.525661100" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fomit-frame-pointer -mcpu=arm7tdmi -mthumb-interwork" valueType="string"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.1249324241" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.1640417589" name="Resource Custom Build Step">
|
||||
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.1006727924" name="Resource Custom Build Step Input Type">
|
||||
<additionalInput kind="additionalinputdependency" paths=""/>
|
||||
</inputType>
|
||||
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.1533768805" name="Resource Custom Build Step Output Type"/>
|
||||
</tool>
|
||||
</fileInfo>
|
||||
<fileInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939.22360852" name="armVIC.c" rcbsApplicability="disable" resourcePath="armVIC.c" toolsToInvoke="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.591611026">
|
||||
<tool id="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668.591611026" name="Cygwin C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668">
|
||||
<option id="gnu.c.compiler.option.misc.other.828490660" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fomit-frame-pointer -mcpu=arm7tdmi -mthumb-interwork" valueType="string"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.823549379" superClass="cdt.managedbuild.tool.gnu.c.compiler.input.cygwin"/>
|
||||
</tool>
|
||||
<tool customBuildStep="true" id="org.eclipse.cdt.managedbuilder.ui.rcbs.1351627299" name="Resource Custom Build Step">
|
||||
<inputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.inputtype.1687122584" name="Resource Custom Build Step Input Type">
|
||||
<additionalInput kind="additionalinputdependency" paths=""/>
|
||||
</inputType>
|
||||
<outputType id="org.eclipse.cdt.managedbuilder.ui.rcbs.outputtype.113518925" name="Resource Custom Build Step Output Type"/>
|
||||
</tool>
|
||||
</fileInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="webserver|ethernet|spi0.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings>
|
||||
<externalSetting>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Drivers"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Drivers/Debug"/>
|
||||
</externalSetting>
|
||||
</externalSettings>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
|
||||
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.604520423">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="arm-elf-gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1129081297">
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="" artifactName="Drivers" buildProperties="" description="" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1129081297" name="Release" parent="org.eclipse.cdt.build.core.prefbase.cfg">
|
||||
<folderInfo id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1129081297." name="/" resourcePath="">
|
||||
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1880939016" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
|
||||
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.eclipse.cdt.build.core.prefbase.toolchain.1880939016.902038749" name=""/>
|
||||
<builder id="org.eclipse.cdt.build.core.settings.default.builder.251371665" keepEnvironmentInBuildfile="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.3457715" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.1309685191" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1220779287" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.1638995662" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1684595952" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
<tool id="org.eclipse.cdt.build.core.settings.holder.275834681" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
|
||||
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1651791339" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="webserver|ethernet|spi0.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1129081297" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
|
||||
<storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<scannerConfigBuildInfo instanceId="preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939;preference.org.eclipse.cdt.managedbuilder.core.configurationDataProvider.1098510086.1154456939.;cdt.managedbuild.tool.gnu.c.compiler.cygwin.base.835204668;cdt.managedbuild.tool.gnu.c.compiler.input.cygwin.604520423">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="arm-elf-gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="Drivers.null.1361814750" name="Drivers"/>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Drivers</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
<project>FreeRTOS</project>
|
||||
<project>inc</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
|
||||
<triggers>clean,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
|
||||
<value>clean</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>?name?</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildCommand</key>
|
||||
<value>make</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.contents</key>
|
||||
<value>org.eclipse.cdt.make.core.activeConfigSettings</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildLocation</key>
|
||||
<value>${workspace_loc:/Drivers/Debug}</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||
<value>true</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||
<value>false</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.fullBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.buildArguments</key>
|
||||
<value></value>
|
||||
</dictionary>
|
||||
<dictionary>
|
||||
<key>org.eclipse.cdt.make.core.autoBuildTarget</key>
|
||||
<value>all</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
|
||||
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
|
||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,20 @@
|
||||
All:
|
||||
UINT8 device [0..255] 0 = Self
|
||||
1..32 = Remote
|
||||
ADC:
|
||||
UINT8 channel [0..255] 0..7 = valid
|
||||
8..255 = future use
|
||||
if mode == VOLTAGE UINT16 value [0..10000] mV
|
||||
if mode == CURRENT UINT16 value [0..20000] uA
|
||||
|
||||
DAC:
|
||||
UINT8 channel [0..255] 0..3 = valid
|
||||
4..255 = future use
|
||||
if mode == VOLTAGE UINT16 value [0..10000] mV
|
||||
if mode == CURRENT UINT16 value [0..20000] uA
|
||||
|
||||
serial:
|
||||
Baudrate: B1200, B9600, B19200, B38400, B57600, B115200
|
||||
Mode: UART_8N1, UART_7N1, UART_8N2, UART_7N2, UART_8E1, UART_7E1, UART_8E2, UART_7E2, UART_8O1, UART_7O1, UART_8O2, UART_7O2
|
||||
FMode: UART_FIFO_OFF, UART_FIFO_1, UART_FIFO_4, UART_FIFO_8, UART_FIFO_14
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Bootloader.c - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: Activates the bootloader.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Feb 21, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "sys_config.h"
|
||||
#include "Bootloader.h"
|
||||
#include "watchdog.h"
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef void (*t_bootloader_startup)(void);
|
||||
#define BOOTMODE_ADDR 0x4000005C
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
//* \brief Jumps to bootloader
|
||||
void blActivateBootloader()
|
||||
{
|
||||
// Set direction pin for storing
|
||||
*((UINT32 *)BOOTMODE_ADDR) = STAY_IN_BOOTLOADER;
|
||||
|
||||
DISABLE_INTERRUPTS();
|
||||
|
||||
watchdogEnable( 1 ); // force watchdog reset
|
||||
}
|
||||
|
||||
|
||||
t_bl_bootmodes blGetBootmode()
|
||||
{
|
||||
if ( *((UINT32 *)BOOTMODE_ADDR) == (UINT32)STAY_IN_BOOTLOADER)
|
||||
{
|
||||
return STAY_IN_BOOTLOADER;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CONTINUE_APPLICATION;
|
||||
}
|
||||
}
|
||||
|
||||
void blResetBootmode()
|
||||
{
|
||||
*((UINT32 *)BOOTMODE_ADDR) = CONTINUE_APPLICATION;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Bootloader.h - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Feb 21, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __BOOTLOADER_H__
|
||||
#define __BOOTLOADER_H__
|
||||
/** \file Bootloader.h
|
||||
\brief Activates the bootloader
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef enum { STAY_IN_BOOTLOADER = 0xABCDEF01, CONTINUE_APPLICATION = 0 } t_bl_bootmodes;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \brief Sets the bootmode to STAY_IN_BOOTLOADER and activates the bootloader */
|
||||
void blActivateBootloader();
|
||||
|
||||
/** \brief Returns the bootmode */
|
||||
t_bl_bootmodes blGetBootmode();
|
||||
|
||||
/** \brief Sets bootmode to default status (CONTINUE APPLICATION) */
|
||||
void blResetBootmode();
|
||||
|
||||
#endif /* __BOOTLOADER_H__ */
|
||||
@@ -0,0 +1,267 @@
|
||||
# Doxyfile 1.5.3
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = "Landustrie IO controller API "
|
||||
PROJECT_NUMBER = V0.1
|
||||
OUTPUT_DIRECTORY = P:/LAN_2636/SW/API/Doxygen
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF = "The $name class " \
|
||||
"The $name widget " \
|
||||
"The $name file " \
|
||||
is \
|
||||
provides \
|
||||
specifies \
|
||||
contains \
|
||||
represents \
|
||||
a \
|
||||
an \
|
||||
the
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
STRIP_FROM_PATH = C:/Tools/doxygen/bin/
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 8
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SUBGROUPING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = NO
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = NO
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text "
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = P:/LAN_2636/SW/API
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS = *.c \
|
||||
*.cc \
|
||||
*.cxx \
|
||||
*.cpp \
|
||||
*.c++ \
|
||||
*.d \
|
||||
*.java \
|
||||
*.ii \
|
||||
*.ixx \
|
||||
*.ipp \
|
||||
*.i++ \
|
||||
*.inl \
|
||||
*.h \
|
||||
*.hh \
|
||||
*.hxx \
|
||||
*.hpp \
|
||||
*.h++ \
|
||||
*.idl \
|
||||
*.odl \
|
||||
*.cs \
|
||||
*.php \
|
||||
*.php3 \
|
||||
*.inc \
|
||||
*.m \
|
||||
*.mm \
|
||||
*.dox \
|
||||
*.py
|
||||
RECURSIVE = NO
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_SYMBOLS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS = *
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
REFERENCES_LINK_SOURCE = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = NO
|
||||
TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = YES
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = YES
|
||||
USE_PDFLATEX = YES
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = NO
|
||||
MSCGEN_PATH =
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = YES
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
CALLER_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_DEPTH = 1000
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
@@ -0,0 +1,271 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* BusProtocol.c - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 28, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "ElecStatusCache.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define MAX_NR_DEVICES 20
|
||||
#define CACHE_NOT_USED 0xFF
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
static UINT16 *bpecAdcReadCache[MAX_NR_DEVICES];
|
||||
static UINT8 bpecAdcReadCacheSize[MAX_NR_DEVICES];
|
||||
static UINT16 *bpecDacReadBackCache[MAX_NR_DEVICES];
|
||||
static UINT8 bpecDacReadBackCacheSize[MAX_NR_DEVICES];
|
||||
static BOOLEAN *bpecDioReadCache[MAX_NR_DEVICES];
|
||||
static UINT8 bpecDioReadCacheSize[MAX_NR_DEVICES];
|
||||
static BOOLEAN *bpecDioReadBackCache[MAX_NR_DEVICES];
|
||||
static UINT8 bpecDioReadBackCacheSize[MAX_NR_DEVICES];
|
||||
static t_bpec_write_callback bpecWriteCallback;
|
||||
static int bpecBusProtocolHandle;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void bpecInit()
|
||||
{
|
||||
int i;
|
||||
|
||||
bpecWriteCallback = NULL;
|
||||
bpecBusProtocolHandle = -1;
|
||||
|
||||
// Empty the administration
|
||||
for (i = 0; i < MAX_NR_DEVICES; i++)
|
||||
{
|
||||
bpecAdcReadCache[i] = NULL;
|
||||
bpecAdcReadCacheSize[i] = CACHE_NOT_USED;
|
||||
bpecDacReadBackCache[i] = NULL;
|
||||
bpecDacReadBackCacheSize[i] = CACHE_NOT_USED;
|
||||
bpecDioReadCache[i] = NULL;
|
||||
bpecDioReadCacheSize[i] = CACHE_NOT_USED;
|
||||
bpecDioReadBackCache[i] = NULL;
|
||||
bpecDioReadBackCacheSize[i] = CACHE_NOT_USED;
|
||||
}
|
||||
}
|
||||
|
||||
void bpecAttachWriteCallback(int busProtocolHandle, t_bpec_write_callback callback)
|
||||
{
|
||||
bpecBusProtocolHandle = busProtocolHandle;
|
||||
bpecWriteCallback = callback;
|
||||
}
|
||||
|
||||
void bpecDetachWriteCallback()
|
||||
{
|
||||
bpecBusProtocolHandle = -1;
|
||||
bpecWriteCallback = NULL;
|
||||
}
|
||||
|
||||
void bpecWriteDacValue( UINT8 device, UINT8 channel, UINT16 dacValue )
|
||||
{
|
||||
if (bpecWriteCallback != NULL)
|
||||
{
|
||||
bpecWriteCallback( bpecBusProtocolHandle, FALSE, device, channel, dacValue );
|
||||
}
|
||||
}
|
||||
|
||||
void bpecWriteDioValue( UINT8 device, UINT8 channel, BOOLEAN doValue )
|
||||
{
|
||||
if (bpecWriteCallback != NULL)
|
||||
{
|
||||
bpecWriteCallback( bpecBusProtocolHandle, TRUE, device, channel, (UINT16)doValue );
|
||||
}
|
||||
}
|
||||
|
||||
void bpecSetAdcReadCache( UINT8 device, UINT16 adcValues[], UINT8 nrOfAdcValues)
|
||||
{
|
||||
static int NrOfAllocs = 0;
|
||||
if (bpecAdcReadCacheSize[device] != nrOfAdcValues)
|
||||
{
|
||||
if (bpecAdcReadCacheSize[device] == CACHE_NOT_USED)
|
||||
{
|
||||
NrOfAllocs++;
|
||||
bpecAdcReadCache[device] = pvPortMalloc( nrOfAdcValues * sizeof(UINT16) );
|
||||
if (bpecAdcReadCache[device] != NULL)
|
||||
{
|
||||
bpecAdcReadCacheSize[device] = nrOfAdcValues;
|
||||
memcpy(bpecAdcReadCache[device], adcValues, nrOfAdcValues * sizeof(UINT16));
|
||||
} /* else Failure */
|
||||
}
|
||||
/* else Failure */
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(bpecAdcReadCache[device], adcValues, nrOfAdcValues * sizeof(UINT16));
|
||||
}
|
||||
}
|
||||
|
||||
void bpecSetDioReadCache( UINT8 device, BOOLEAN dioValues[], UINT8 nrOfDioValues)
|
||||
{
|
||||
if (bpecDioReadCacheSize[device] != nrOfDioValues)
|
||||
{
|
||||
if (bpecDioReadCacheSize[device] == CACHE_NOT_USED)
|
||||
{
|
||||
bpecDioReadCache[device] = pvPortMalloc( nrOfDioValues * sizeof(BOOLEAN) );
|
||||
if (bpecDioReadCache[device] != NULL)
|
||||
{
|
||||
bpecDioReadCacheSize[device] = nrOfDioValues;
|
||||
memcpy(bpecDioReadCache[device], dioValues, nrOfDioValues * sizeof(BOOLEAN));
|
||||
} /* else Failure */
|
||||
}
|
||||
/* else Failure */
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(bpecDioReadCache[device], dioValues, nrOfDioValues * sizeof(BOOLEAN));
|
||||
}
|
||||
}
|
||||
|
||||
void bpecSetDioReadBackCache( UINT8 device, BOOLEAN dioValues[], UINT8 nrOfDioValues)
|
||||
{
|
||||
static int NrOfWritings = 0;
|
||||
static int LastSetDevice = 0;
|
||||
static int LastSetNrOfDioValues = 0;
|
||||
NrOfWritings++;
|
||||
LastSetDevice = device;
|
||||
LastSetNrOfDioValues = nrOfDioValues;
|
||||
|
||||
if (bpecDioReadBackCacheSize[device] != nrOfDioValues)
|
||||
{
|
||||
if (bpecDioReadBackCacheSize[device] == CACHE_NOT_USED)
|
||||
{
|
||||
bpecDioReadBackCache[device] = pvPortMalloc( nrOfDioValues * sizeof(BOOLEAN) );
|
||||
if (bpecDioReadBackCache[device] != NULL)
|
||||
{
|
||||
bpecDioReadBackCacheSize[device] = nrOfDioValues;
|
||||
memcpy(bpecDioReadBackCache[device], dioValues, nrOfDioValues * sizeof(BOOLEAN));
|
||||
} /* else Failure */
|
||||
}
|
||||
/* else Failure */
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(bpecDioReadBackCache[device], dioValues, nrOfDioValues * sizeof(BOOLEAN));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void bpecSetDacReadBackCache( UINT8 device, UINT16 dacValues[], UINT8 nrOfDacValues)
|
||||
{
|
||||
if (bpecDacReadBackCacheSize[device] != nrOfDacValues)
|
||||
{
|
||||
if (bpecDacReadBackCacheSize[device] == CACHE_NOT_USED)
|
||||
{
|
||||
bpecDacReadBackCache[device] = pvPortMalloc( nrOfDacValues * sizeof(UINT16) );
|
||||
if (bpecDacReadBackCache[device] != NULL)
|
||||
{
|
||||
bpecDacReadBackCacheSize[device] = nrOfDacValues;
|
||||
memcpy(bpecDacReadBackCache[device], dacValues, nrOfDacValues * sizeof(UINT16));
|
||||
} /* else Failure */
|
||||
}
|
||||
/* else Failure */
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(bpecDacReadBackCache[device], dacValues, nrOfDacValues * sizeof(UINT16));
|
||||
}
|
||||
}
|
||||
|
||||
UINT16 bpecAdcRead( UINT8 device, UINT8 channel )
|
||||
{
|
||||
UINT16 result = 0;
|
||||
|
||||
if (bpecAdcReadCacheSize[device] != CACHE_NOT_USED)
|
||||
{
|
||||
if (channel < bpecAdcReadCacheSize[device])
|
||||
{
|
||||
result = (bpecAdcReadCache[device])[channel];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOLEAN bpecDioRead( UINT8 device, UINT8 channel )
|
||||
{
|
||||
BOOLEAN result = FALSE;
|
||||
|
||||
if (bpecDioReadCacheSize[device] != CACHE_NOT_USED)
|
||||
{
|
||||
if (channel < bpecDioReadCacheSize[device])
|
||||
{
|
||||
result = (bpecDioReadCache[device])[channel];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOLEAN bpecDioReadBack( UINT8 device, UINT8 channel )
|
||||
{
|
||||
BOOLEAN result = FALSE;
|
||||
|
||||
if (bpecDioReadBackCacheSize[device] != CACHE_NOT_USED)
|
||||
{
|
||||
if (channel < bpecDioReadBackCacheSize[device])
|
||||
{
|
||||
result = (bpecDioReadBackCache[device])[channel];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
UINT16 bpecDacReadBack( UINT8 device, UINT8 channel )
|
||||
{
|
||||
UINT16 result = 0;
|
||||
|
||||
if (bpecDacReadBackCacheSize[device] != CACHE_NOT_USED)
|
||||
{
|
||||
if (channel < bpecDacReadBackCacheSize[device])
|
||||
{
|
||||
result = (bpecDacReadBackCache[device])[channel];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* ElecStatusCache.h - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: Stores all electronic status of other IO-controllers
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Jan 29, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __ELECSTATUSCACHE_H__
|
||||
#define __ELECSTATUSCACHE_H__
|
||||
/** \file ElecStatusCache.h
|
||||
\brief
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
//#include "BpMessageFormat.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef void (*t_bpec_write_callback)( int handle, BOOLEAN isDigital, UINT8 device, UINT8 channel, UINT16 value );
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void bpecInit();
|
||||
void bpecAttachWriteCallback(int busProtocolHandle, t_bpec_write_callback callback);
|
||||
void bpecDetachWriteCallback();
|
||||
void bpecWriteDacValue( UINT8 device, UINT8 channel, UINT16 dacValue );
|
||||
void bpecWriteDioValue( UINT8 device, UINT8 channel, BOOLEAN doValue );
|
||||
void bpecSetAdcReadCache( UINT8 device, UINT16 adcValues[], UINT8 nrOfAdcValues);
|
||||
void bpecSetDioReadCache( UINT8 device, BOOLEAN dioValues[], UINT8 nrOfDioValues);
|
||||
void bpecSetDioReadBackCache( UINT8 device, BOOLEAN dioValues[], UINT8 nrOfDioValues);
|
||||
void bpecSetDacReadBackCache( UINT8 device, UINT16 dacValues[], UINT8 nrOfDacValues);
|
||||
UINT16 bpecAdcRead( UINT8 device, UINT8 channel );
|
||||
BOOLEAN bpecDioRead( UINT8 device, UINT8 channel );
|
||||
BOOLEAN bpecDioReadBack( UINT8 device, UINT8 channel );
|
||||
UINT16 bpecDacReadBack( UINT8 device, UINT8 channel );
|
||||
|
||||
#endif /* __ELECSTATUSCACHE_H__ */
|
||||
@@ -0,0 +1,217 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* InternalFlash.c - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Feb 11, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "types.h"
|
||||
#include "sys_config.h"
|
||||
#include "InternalFlash.h"
|
||||
#include "leds.h"
|
||||
#include "sys_config.h"
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define IAP_LOCATION 0x7ffffff1
|
||||
|
||||
#define IAP_PREPARE_CMD (50)
|
||||
#define IAP_COPY_RAM2FLASH_CMD (51)
|
||||
#define IAP_ERASE_SECTORS_CMD (52)
|
||||
#define IAP_BLANK_CHECK_SECTORS_CMD (53)
|
||||
#define IAP_READ_PART_ID_CMD (54)
|
||||
#define IAP_READ_BOOTCODE_V_CMD (55)
|
||||
#define IAP_COMPARE_CMD (56)
|
||||
#define IAP_REINVOKE_ISP_CMD (57)
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
static unsigned int command[5];
|
||||
static unsigned int result[2];
|
||||
|
||||
typedef void (*IAP)(unsigned int [],unsigned int[]);
|
||||
IAP iap_entry;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \brief Initialises the internal flash module */
|
||||
void iflashInit()
|
||||
{
|
||||
iap_entry=(IAP) IAP_LOCATION;
|
||||
}
|
||||
|
||||
/** \brief Prepares the flash for erasing and programming (must be called before these actions)
|
||||
*
|
||||
* This command must be executed before executing "Copy RAM to flash" or "Erase
|
||||
* Sector(s)" command. Successful execution of the "Copy RAM to flash" or "Erase
|
||||
* Sector(s)" command causes relevant sectors to be protected again. The boot
|
||||
* sector can not be prepared by this command. To prepare a single sector use the
|
||||
* same "Start" and "End" sector numbers
|
||||
*
|
||||
* \param beginSector Start sector number (0-27)
|
||||
* \param endSector End Sector Number (should be greater than or equal to start sector number).
|
||||
* \retval CMD_SUCCESS prepare was succesfull
|
||||
* \retval BUSY
|
||||
* \retval INVALID_SECTOR
|
||||
*/
|
||||
iflashresult iflashPrepare(UINT8 beginSector, UINT8 endSector)
|
||||
{
|
||||
// Build command
|
||||
command[0] = IAP_PREPARE_CMD;
|
||||
command[1] = beginSector;
|
||||
command[2] = endSector;
|
||||
|
||||
//DISABLE_INTERRUPTS();
|
||||
|
||||
iap_entry (command, result);
|
||||
|
||||
//ENABLE_INTERRUPTS();
|
||||
|
||||
// readout result
|
||||
|
||||
return result[0];
|
||||
//return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
/** \brief Erases one sector on the internal flash
|
||||
*
|
||||
* \param sector Sector nr to be erased (0-27)
|
||||
* \retval CMD_SUCCESS
|
||||
* \retval BUSY
|
||||
* \retval SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION
|
||||
* \retval INVALID_SECTOR
|
||||
*/
|
||||
iflashresult iflashErase( UINT8 sector )
|
||||
{
|
||||
// Build command
|
||||
command[0] = IAP_ERASE_SECTORS_CMD;
|
||||
command[1] = sector; // start sector
|
||||
command[2] = sector; // end sector
|
||||
command[3] = CCLK/1000; // Clock frequency in kHz
|
||||
|
||||
DISABLE_INTERRUPTS();
|
||||
|
||||
iap_entry (command, result);
|
||||
|
||||
ENABLE_INTERRUPTS();
|
||||
|
||||
return result[0];
|
||||
}
|
||||
|
||||
|
||||
/** \brief Programs some data on the flash
|
||||
*
|
||||
* \param address Addres on flash to which the data must be programmed
|
||||
* \param dataLength Nr of bytes in data array (Should be 256 | 512 | 1024 | 4096.)
|
||||
* \param data The data-array that should be programmed
|
||||
* \retval CMD_SUCCESS
|
||||
* \retval SRC_ADDR_ERROR (Address not a word boundary)
|
||||
* \retval DST_ADDR_ERROR (Address not on correct boundary)
|
||||
* \retval SRC_ADDR_NOT_MAPPED
|
||||
* \retval DST_ADDR_NOT_MAPPED
|
||||
* \retval COUNT_ERROR (Byte count is not 256 | 512 | 1024 | 4096)
|
||||
* \retval SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION
|
||||
* \retval BUSY
|
||||
*/
|
||||
iflashresult iflashProgram( UINT32 address, UINT16 dataLength, UINT8 *data)
|
||||
{
|
||||
// Build command
|
||||
command[0] = IAP_COPY_RAM2FLASH_CMD;
|
||||
command[1] = address; // flash address
|
||||
command[2] = (UINT32)data; // RAM address
|
||||
command[3] = dataLength; // Nr of bytes Should be 256 | 512 | 1024 | 4096.
|
||||
command[4] = CCLK/1000; // Clock frequency in kHz
|
||||
|
||||
DISABLE_INTERRUPTS();
|
||||
|
||||
iap_entry (command, result);
|
||||
|
||||
ENABLE_INTERRUPTS();
|
||||
|
||||
return result[0];
|
||||
}
|
||||
|
||||
/** \brief Compares the data with the data on the internal flash on location "address"
|
||||
*
|
||||
* \param address Addres on flash to which the data must be programmed
|
||||
* \param dataLength Number of bytes to be compared; should be a multiple of 4.
|
||||
* \param data The data-array that should be programmed
|
||||
* \retval CMD_SUCCESS
|
||||
* \retval COMPARE_ERROR
|
||||
* \retval COUNT_ERROR (Byte count is not a multiple of 4)
|
||||
* \retval ADDR_ERROR
|
||||
* \retval ADDR_NOT_MAPPED
|
||||
*/
|
||||
iflashresult iflashVerify( UINT32 address, UINT16 dataLength, UINT8 *data)
|
||||
{
|
||||
// Build command
|
||||
command[0] = IAP_COMPARE_CMD;
|
||||
command[1] = address; // flash address
|
||||
command[2] = (UINT32)data; // RAM address
|
||||
command[3] = dataLength;
|
||||
|
||||
iap_entry (command, result);
|
||||
|
||||
return result[0];
|
||||
}
|
||||
|
||||
/** \brief This command is used to read the part identification number.
|
||||
*
|
||||
* \retval the Part identification number
|
||||
*/
|
||||
UINT32 iflashReadPartId()
|
||||
{
|
||||
// Build command
|
||||
command[0] = IAP_READ_PART_ID_CMD;
|
||||
|
||||
iap_entry (command, result);
|
||||
|
||||
return result[1];
|
||||
}
|
||||
|
||||
/** \brief This command is used to read the boot code version number. */
|
||||
UINT32 iflashReadBootcodeVersionNr()
|
||||
{
|
||||
// Build command
|
||||
command[0] = IAP_READ_BOOTCODE_V_CMD;
|
||||
|
||||
iap_entry (command, result);
|
||||
|
||||
return result[1];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* InternalFlash.h - v0.1 (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Feb 11, 2008, FSc
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __INTERNALFLASH_H__
|
||||
#define __INTERNALFLASH_H__
|
||||
/** \file InternalFlash.h
|
||||
\brief
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
CMD_SUCCESS = 0,
|
||||
INVALID_COMMAND = 1,
|
||||
SRC_ADDR_ERROR = 2,
|
||||
DST_ADDR_ERROR = 3,
|
||||
SRC_ADDR_NOT_MAPPED = 4,
|
||||
DST_ADDR_NOT_MAPPED = 5,
|
||||
COUNT_ERROR = 6,
|
||||
INVALID_SECTOR = 7,
|
||||
SECTOR_NOT_BLANK = 8,
|
||||
SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION = 9,
|
||||
COMPARE_ERROR = 10,
|
||||
BUSY = 11
|
||||
} iflashresult;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/** \brief Initialises the internal flash module */
|
||||
void iflashInit();
|
||||
|
||||
/** \brief Prepares the flash for erasing and programming (must be called before these actions) */
|
||||
iflashresult iflashPrepare(UINT8 beginSector, UINT8 endSector);
|
||||
|
||||
/** \brief Erases one sector on the internal flash */
|
||||
iflashresult iflashErase( UINT8 sector );
|
||||
|
||||
/** \brief Programs some data on the flash */
|
||||
iflashresult iflashProgram( UINT32 address, UINT16 dataLength, UINT8 *data);
|
||||
|
||||
/** \brief Compares the data with the data on the internal flash on location "address" */
|
||||
iflashresult iflashVerify( UINT32 address, UINT16 dataLength, UINT8 *data);
|
||||
|
||||
/** \brief This command is used to read the part identification number. */
|
||||
UINT32 iflashReadPartId();
|
||||
|
||||
/** \brief This command is used to read the boot code version number. */
|
||||
UINT32 iflashReadBootcodeVersionNr();
|
||||
|
||||
|
||||
#endif /* __INTERNALFLASH_H__ */
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef LPC_REGS_H__
|
||||
#define LPC_REGS_H__
|
||||
|
||||
#include "LPC23xx.h"
|
||||
#include "LPC_UTIL_DEFS.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,237 @@
|
||||
/* "ripped from the R O Software example and extended by mthomas */
|
||||
|
||||
#ifndef LPC_UTILDEFS_H
|
||||
#define LPC_UTILDEFS_H
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// CLKSRC defines
|
||||
#define CLKSRC_INT_RC (0x00)
|
||||
#define CLKSRC_MAIN_OSC (0x01)
|
||||
#define CLKSRC_MIN_RTC (0x02)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// SCS defines
|
||||
#define SCS_GPIOM (1UL<<0)
|
||||
#define SCS_EMC_RST_DIS (1UL<<1)
|
||||
#define SCS_MCIPWR (1UL<<3)
|
||||
#define SCS_OSCRANGE (1UL<<4)
|
||||
#define SCS_OSCEN (1UL<<5)
|
||||
#define SCS_OSCSTAT (1UL<<6)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// MAM defines
|
||||
#define MAMCR_OFF 0
|
||||
#define MAMCR_PART 1
|
||||
#define MAMCR_FULL 2
|
||||
|
||||
#define MAMTIM_CYCLES (((CCLK) + 19999999) / 20000000)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// MEMMAP defines
|
||||
#define MEMMAP_BBLK 0 // Interrupt Vectors in Boot Block
|
||||
#define MEMMAP_FLASH 1 // Interrupt Vectors in Flash
|
||||
#define MEMMAP_SRAM 2 // Interrupt Vectors in SRAM
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// VPBDIV defines & computations
|
||||
#define VPBDIV_VALUE (PBSD & 0x03) // VPBDIV value
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// SCS defines - mthomas
|
||||
#define GPIO0M (1 << 0)
|
||||
#define GPIO1M (1 << 1)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// UART defines
|
||||
|
||||
#define U0_TX_PINSEL_REG PINSEL0
|
||||
#define U0_TX_PINSEL (1UL<<4) /* PINSEL0 Value for UART0 TX */
|
||||
#define U0_TX_PINMASK (3UL<<4) /* PINSEL0 Mask for UART0 RX */
|
||||
#define U0_RX_PINSEL_REG PINSEL0
|
||||
#define U0_RX_PINSEL (1UL<<6) /* PINSEL0 Value for UART0 TX */
|
||||
#define U0_RX_PINMASK (3UL<<6) /* PINSEL0 Mask for UART0 RX */
|
||||
|
||||
#define U1_TX_PINSEL_REG PINSEL4
|
||||
#define U1_TX_PINSEL (2UL<<0) /* PINSEL4 Value for UART1 TX */
|
||||
#define U1_TX_PINMASK (3UL<<0) /* PINSEL4 Mask for UART1 RX */
|
||||
#define U1_RX_PINSEL_REG PINSEL4
|
||||
#define U1_RX_PINSEL (2UL<<2) /* PINSEL4 Value for UART1 TX */
|
||||
#define U1_RX_PINMASK (3UL<<2) /* PINSEL4 Mask for UART1 RX */
|
||||
#define U1_CTS_PINSEL_REG PINSEL4
|
||||
#define U1_CTS_PINSEL (2UL<<4) /* PINSEL4 Value for UART1 TX */
|
||||
#define U1_CTS_PINMASK (3UL<<4) /* PINSEL4 Mask for UART1 RX */
|
||||
#define U1_RTS_PINSEL_REG PINSEL4
|
||||
#define U1_RTS_PINSEL (2UL<<14) /* PINSEL4 Value for UART1 TX */
|
||||
#define U1_RTS_PINMASK (3UL<<14) /* PINSEL4 Mask for UART1 RX */
|
||||
|
||||
// Interrupt Enable Register bit definitions
|
||||
#define UIER_RBR (1UL << 0) // (UIER_ERBFI) Enable Receive Data Available Interrupt
|
||||
#define UIER_THRE (1UL << 1) // (UIER_ETBEI) Enable Transmit Holding Register Empty Interrupt
|
||||
#define UIER_RX_LINE_STAT (1UL << 2) // (UIER_ELSI) Enable Receive Line Status Interrupt
|
||||
#define UIER_MODEM_STAT_INT_EN (1UL<<3) // (UIER_EDSSI)
|
||||
#define UIER_CTS_INT_ENT (1UL << 7)
|
||||
#define UIER_ABTOIntEn (1UL << 8)
|
||||
#define UIER_ABE0IntEn (1UL << 9)
|
||||
|
||||
// Interrupt ID Register bit definitions
|
||||
#define UIIR_NO_INT (1 << 0) // NO INTERRUPTS PENDING if set
|
||||
#define UIIR_MS_INT (0 << 1) // MODEM Status
|
||||
#define UIIR_THRE_INT (1 << 1) // Transmit Holding Register Empty
|
||||
#define UIIR_RDA_INT (2 << 1) // Receive Data Available
|
||||
#define UIIR_RLS_INT (3 << 1) // Receive Line Status
|
||||
#define UIIR_CTI_INT (6 << 1) // Character Timeout Indicator
|
||||
#define UIIR_ID_MASK 0x0E
|
||||
#define UIIR_FIFO_ENABLE (1<<6)
|
||||
#define UIIR_ABEOInt (1<<8)
|
||||
#define UIIR_ABTOInt (1<<9)
|
||||
|
||||
// FIFO Control Register bit definitions
|
||||
#define UFCR_FIFO_ENABLE (1 << 0) // FIFO Enable
|
||||
#define UFCR_RX_FIFO_RESET (1 << 1) // Reset Receive FIFO
|
||||
#define UFCR_TX_FIFO_RESET (1 << 2) // Reset Transmit FIFO
|
||||
#define UFCR_FIFO_TRIG1 (0 << 6) // Trigger @ 1 character in FIFO
|
||||
#define UFCR_FIFO_TRIG4 (1 << 6) // Trigger @ 4 characters in FIFO
|
||||
#define UFCR_FIFO_TRIG8 (2 << 6) // Trigger @ 8 characters in FIFO
|
||||
#define UFCR_FIFO_TRIG14 (3 << 6) // Trigger @ 14 characters in FIFO
|
||||
|
||||
// Line Control Register bit definitions
|
||||
#define ULCR_CHAR_5 (0 << 0) // 5-bit character length
|
||||
#define ULCR_CHAR_6 (1 << 0) // 6-bit character length
|
||||
#define ULCR_CHAR_7 (2 << 0) // 7-bit character length
|
||||
#define ULCR_CHAR_8 (3 << 0) // 8-bit character length
|
||||
#define ULCR_STOP_1 (0 << 2) // 1 stop bit
|
||||
#define ULCR_STOP_2 (1 << 2) // 2 stop bits
|
||||
#define ULCR_PAR_NO (0 << 3) // No Parity
|
||||
#define ULCR_PAR_ODD (1 << 3) // Odd Parity
|
||||
#define ULCR_PAR_EVEN (3 << 3) // Even Parity
|
||||
#define ULCR_PAR_MARK (5 << 3) // MARK "1" Parity
|
||||
#define ULCR_PAR_SPACE (7 << 3) // SPACE "0" Paruty
|
||||
#define ULCR_BREAK_ENABLE (1 << 6) // Output BREAK line condition
|
||||
#define ULCR_DLAB_ENABLE (1 << 7) // Enable Divisor Latch Access
|
||||
|
||||
// Modem Control Register bit definitions
|
||||
#define UMCR_DTR (1 << 0) // Data Terminal Ready
|
||||
#define UMCR_RTS (1 << 1) // Request To Send
|
||||
#define UMCR_LB (1 << 4) // Loopback
|
||||
#define UMCR_RTS_EN (1 << 6) // Automatic RTS enable
|
||||
#define UMCR_CTS_EN (1 << 7) // Automatic CTS enable
|
||||
|
||||
// Line Status Register bit definitions
|
||||
#define ULSR_RDR (1 << 0) // Receive Data Ready
|
||||
#define ULSR_OE (1 << 1) // Overrun Error
|
||||
#define ULSR_PE (1 << 2) // Parity Error
|
||||
#define ULSR_FE (1 << 3) // Framing Error
|
||||
#define ULSR_BI (1 << 4) // Break Interrupt
|
||||
#define ULSR_THRE (1 << 5) // Transmit Holding Register Empty
|
||||
#define ULSR_TEMT (1 << 6) // Transmitter Empty
|
||||
#define ULSR_RXFE (1 << 7) // Error in Receive FIFO
|
||||
#define ULSR_ERR_MASK 0x1E
|
||||
|
||||
// Modem Status Register bit definitions
|
||||
#define UMSR_DCTS (1 << 0) // Delta Clear To Send
|
||||
#define UMSR_DDSR (1 << 1) // Delta Data Set Ready
|
||||
#define UMSR_TERI (1 << 2) // Trailing Edge Ring Indicator
|
||||
#define UMSR_DDCD (1 << 3) // Delta Data Carrier Detect
|
||||
#define UMSR_CTS (1 << 4) // Clear To Send
|
||||
#define UMSR_DSR (1 << 5) // Data Set Ready
|
||||
#define UMSR_RI (1 << 6) // Ring Indicator
|
||||
#define UMSR_DCD (1 << 7) // Data Carrier Detect
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// TIMER defines
|
||||
|
||||
// Timer Interrupt Register Bit Definitions
|
||||
#define TIR_MR0I (1 << 0) // Interrupt flag for match channel 0
|
||||
#define TIR_MR1I (1 << 1) // Interrupt flag for match channel 1
|
||||
#define TIR_MR2I (1 << 2) // Interrupt flag for match channel 2
|
||||
#define TIR_MR3I (1 << 3) // Interrupt flag for match channel 3
|
||||
#define TIR_CR0I (1 << 4) // Interrupt flag for capture channel 0 event
|
||||
#define TIR_CR1I (1 << 5) // Interrupt flag for capture channel 1 event
|
||||
#define TIR_CR2I (1 << 6) // Interrupt flag for capture channel 2 event
|
||||
#define TIR_CR3I (1 << 7) // Interrupt flag for capture channel 3 event
|
||||
|
||||
// PWM Interrupt Register Bit Definitions
|
||||
#define PWMIR_MR0I (1 << 0) // Interrupt flag for match channel 0
|
||||
#define PWMIR_MR1I (1 << 1) // Interrupt flag for match channel 1
|
||||
#define PWMIR_MR2I (1 << 2) // Interrupt flag for match channel 2
|
||||
#define PWMIR_MR3I (1 << 3) // Interrupt flag for match channel 3
|
||||
#define PWMIR_MR4I (1 << 8) // Interrupt flag for match channel 4
|
||||
#define PWMIR_MR5I (1 << 9) // Interrupt flag for match channel 5
|
||||
#define PWMIR_MR6I (1 << 10) // Interrupt flag for match channel 6
|
||||
#define PWMIR_MASK (0x070F)
|
||||
|
||||
// Timer Control Register Bit Definitions
|
||||
#define TCR_ENABLE (1 << 0)
|
||||
#define TCR_RESET (1 << 1)
|
||||
|
||||
// PWM Control Register Bit Definitions
|
||||
#define PWMCR_ENABLE (1 << 0)
|
||||
#define PWMCR_RESET (1 << 1)
|
||||
|
||||
// Timer Match Control Register Bit Definitions
|
||||
#define TMCR_MR0_I (1 << 0) // Enable Interrupt when MR0 matches TC
|
||||
#define TMCR_MR0_R (1 << 1) // Enable Reset of TC upon MR0 match
|
||||
#define TMCR_MR0_S (1 << 2) // Enable Stop of TC upon MR0 match
|
||||
#define TMCR_MR1_I (1 << 3) // Enable Interrupt when MR1 matches TC
|
||||
#define TMCR_MR1_R (1 << 4) // Enable Reset of TC upon MR1 match
|
||||
#define TMCR_MR1_S (1 << 5) // Enable Stop of TC upon MR1 match
|
||||
#define TMCR_MR2_I (1 << 6) // Enable Interrupt when MR2 matches TC
|
||||
#define TMCR_MR2_R (1 << 7) // Enable Reset of TC upon MR2 match
|
||||
#define TMCR_MR2_S (1 << 8) // Enable Stop of TC upon MR2 match
|
||||
#define TMCR_MR3_I (1 << 9) // Enable Interrupt when MR3 matches TC
|
||||
#define TMCR_MR3_R (1 << 10) // Enable Reset of TC upon MR3 match
|
||||
#define TMCR_MR3_S (1 << 11) // Enable Stop of TC upon MR3 match
|
||||
|
||||
// Timer Capture Control Register Bit Definitions
|
||||
#define TCCR_CR0_R (1 << 0) // Enable Rising edge on CAPn.0 will load TC to CR0
|
||||
#define TCCR_CR0_F (1 << 1) // Enable Falling edge on CAPn.0 will load TC to CR0
|
||||
#define TCCR_CR0_I (1 << 2) // Enable Interrupt on load of CR0
|
||||
#define TCCR_CR1_R (1 << 3) // Enable Rising edge on CAPn.1 will load TC to CR1
|
||||
#define TCCR_CR1_F (1 << 4) // Enable Falling edge on CAPn.1 will load TC to CR1
|
||||
#define TCCR_CR1_I (1 << 5) // Enable Interrupt on load of CR1
|
||||
#define TCCR_CR2_R (1 << 6) // Enable Rising edge on CAPn.2 will load TC to CR2
|
||||
#define TCCR_CR2_F (1 << 7) // Enable Falling edge on CAPn.2 will load TC to CR2
|
||||
#define TCCR_CR2_I (1 << 8) // Enable Interrupt on load of CR2
|
||||
#define TCCR_CR3_R (1 << 9) // Enable Rising edge on CAPn.3 will load TC to CR3
|
||||
#define TCCR_CR3_F (1 << 10) // Enable Falling edge on CAPn.3 will load TC to CR3
|
||||
#define TCCR_CR3_I (1 << 11) // Enable Interrupt on load of CR3
|
||||
|
||||
#if 0
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// VIC defines
|
||||
|
||||
// VIC Channel Assignments
|
||||
#define VIC_WDT 0
|
||||
#define VIC_TIMER0 4
|
||||
#define VIC_TIMER1 5
|
||||
#define VIC_UART0 6
|
||||
#define VIC_UART1 7
|
||||
#define VIC_PWM 8
|
||||
#define VIC_PWM0 8
|
||||
#define VIC_I2C 9
|
||||
#define VIC_SPI 10
|
||||
#define VIC_SPI0 10
|
||||
#define VIC_SPI1 11
|
||||
#define VIC_PLL 12
|
||||
#define VIC_RTC 13
|
||||
#define VIC_EINT0 14
|
||||
#define VIC_EINT1 15
|
||||
#define VIC_EINT2 16
|
||||
#define VIC_EINT3 17
|
||||
#define VIC_ADC 18
|
||||
|
||||
// Vector Control Register bit definitions
|
||||
#define VIC_ENABLE (1 << 5)
|
||||
|
||||
// Convert Channel Number to Bit Value
|
||||
#define VIC_BIT(chan) (1L << (chan))
|
||||
|
||||
#endif
|
||||
|
||||
#define VECT_ADDR_INDEX 0x100
|
||||
#define VECT_CNTL_INDEX 0x200
|
||||
#define VECT_PRIO_INDEX 0x200
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* FILENAME.c (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* Contains a Function so send Messages on COM1/COM2 to a Terminal.
|
||||
* Contains some handy Functions to convert different DataTypes to Strings
|
||||
*
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Feb 11, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "Task.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "SerOut.h"
|
||||
#include "serial.h"
|
||||
#include "logging.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
extern UINT32 interruptcounter;
|
||||
extern UINT32 switchcounter;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
char CustomMessage[40];
|
||||
char BoolRestoStrMessage[40];
|
||||
char D_array[40];
|
||||
char F_array[40];
|
||||
char H_array[40];
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void sendString(t_serial_devices ComPort, BOOLEAN newline,
|
||||
Messagetype_t urgency, char * DefMessage, char * Devider,
|
||||
char * CstmMessage)
|
||||
{
|
||||
BOOLEAN allowPrintout = TRUE;
|
||||
|
||||
switch (urgency)
|
||||
{
|
||||
case importantMessage:
|
||||
if (block_ImportantMessage == TRUE)
|
||||
{
|
||||
allowPrintout = FALSE;
|
||||
}
|
||||
break;
|
||||
case headerMessage:
|
||||
if (block_HeaderMessage == TRUE)
|
||||
{
|
||||
allowPrintout = FALSE;
|
||||
}
|
||||
break;
|
||||
case resultMessage:
|
||||
if (block_ResultMessage == TRUE)
|
||||
{
|
||||
allowPrintout = FALSE;
|
||||
}
|
||||
break;
|
||||
case noteMessage:
|
||||
if (block_NoteMessage == TRUE)
|
||||
{
|
||||
allowPrintout = FALSE;
|
||||
}
|
||||
break;
|
||||
case testMessage:
|
||||
if (block_TestMessage == TRUE)
|
||||
{
|
||||
allowPrintout = FALSE;
|
||||
}
|
||||
break;
|
||||
case menuMessage:
|
||||
if (block_MenuMessage == TRUE)
|
||||
{
|
||||
allowPrintout = FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
if ((allowPrintout == TRUE) || (LogFlag == TRUE))
|
||||
{
|
||||
|
||||
if ((allowPrintout == TRUE) && (newline == TRUE))
|
||||
{
|
||||
serWrite(ComPort, strlen("\n\r"), (UINT8 *)"\n\r");
|
||||
}
|
||||
|
||||
strcpy(CustomMessage, DefMessage); /* Copy first Message to String */
|
||||
strcat(CustomMessage, Devider); /* Copy second Message to String*/
|
||||
strcat(CustomMessage, CstmMessage); /* Copy third Message to String */
|
||||
|
||||
if ((urgency == menuMessage)&& (block_MenuMessage == TRUE))
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
||||
else
|
||||
{
|
||||
writeLog(LogOutput, ComPort, urgency, CustomMessage);
|
||||
}
|
||||
|
||||
if (allowPrintout == TRUE)
|
||||
{
|
||||
/* Send built String to defined COM */
|
||||
serWrite(ComPort, strlen(CustomMessage), (UINT8 *) CustomMessage);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void debugPrint(char * Message)
|
||||
{
|
||||
serWrite(SerOutPort, strlen(Message), (UINT8 *)Message);
|
||||
}
|
||||
|
||||
|
||||
char * BooltoStr (BOOLEAN var)
|
||||
{
|
||||
if (var == TRUE) /* If BOOLEAN Variable is TRUE */
|
||||
{
|
||||
strcpy(BoolRestoStrMessage, "HIGH/TRUE");
|
||||
}
|
||||
else /* If BOOLEAN Variable is FALSE */
|
||||
{
|
||||
strcpy(BoolRestoStrMessage, " LOW/FALSE ");
|
||||
}
|
||||
return BoolRestoStrMessage; /* Return built String */
|
||||
}
|
||||
|
||||
|
||||
char * BoolRestoStr(BOOLEAN Result)
|
||||
{
|
||||
if (Result == TRUE) /* If BOOLEAN Variable is TRUE */
|
||||
{
|
||||
strcpy(BoolRestoStrMessage, "PASSED "); /* Copy "PASSED" to String */
|
||||
}
|
||||
else /* If BOOLEAN Variable is FALSE */
|
||||
{
|
||||
strcpy(BoolRestoStrMessage, " FAILED "); /* Copy "FAILED"to String */
|
||||
}
|
||||
return BoolRestoStrMessage; /* Return built String */
|
||||
}
|
||||
|
||||
char * ItoDStr(UINT32 IntValue)
|
||||
{
|
||||
sprintf(D_array, "%i", IntValue); /* Convert INT-Value to DEZ-String */
|
||||
return D_array; /* Return DEZ-String */
|
||||
}
|
||||
|
||||
char * FtoDStr(float IntValue)
|
||||
{
|
||||
sprintf(F_array, "%f", IntValue); /* Convert INT-Value to DEZ-String */
|
||||
return F_array; /* Return FLOAT-String */
|
||||
}
|
||||
|
||||
char * ItoHStr(UINT32 IntValue)
|
||||
{
|
||||
sprintf(H_array, "%X", IntValue); /* Convert INT-Value to HEX-String */
|
||||
return H_array; /* Return HEX-String */
|
||||
}
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* FILENAME.h (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* Headerfile for SerOut.c
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Feb 11, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef SEROUT_H_
|
||||
#define SEROUT_H_
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "Task.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "serial.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/*predefines for sendString Function */
|
||||
#define StartMessage "\nBegin Test: "
|
||||
#define EndMessage "End Test: "
|
||||
#define NewLine "\n\r"
|
||||
#define f_tab "\t"
|
||||
#define s_tab "\t\t"
|
||||
#define f_lines "\t---- "
|
||||
#define s_lines "\t\t---- "
|
||||
#define tabdevider "\t/\t"
|
||||
#define devider " / "
|
||||
#define Dummy ""
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef enum _Messagetype_t
|
||||
{
|
||||
importantMessage = 0,
|
||||
headerMessage,
|
||||
resultMessage,
|
||||
noteMessage,
|
||||
testMessage,
|
||||
menuMessage
|
||||
} Messagetype_t;
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN block_ImportantMessage;
|
||||
BOOLEAN block_HeaderMessage;
|
||||
BOOLEAN block_ResultMessage;
|
||||
BOOLEAN block_NoteMessage;
|
||||
BOOLEAN block_TestMessage;
|
||||
BOOLEAN block_MenuMessage;
|
||||
BOOLEAN block_SpinningWheel;
|
||||
BOOLEAN GotoNewLine;
|
||||
|
||||
/* Message in- and output */
|
||||
t_serial_devices SerOutPort; /* General used COM-Port */
|
||||
t_serial_devices MenuPort; /* Port for the Prompt-menu */
|
||||
|
||||
// \note help
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: sendString
|
||||
*
|
||||
* Function to send a String on COM1 or COM2
|
||||
*
|
||||
* Parameters: t_serial_devices ComPort, - defines the COM-Port to use
|
||||
* BOOLEAN newline, - write to a newline or not
|
||||
* char * DefMessage, - First Message to send
|
||||
* char * Devider, - second Message to send
|
||||
* char * CstmMessage - third Message to send
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void sendString (t_serial_devices ComPort,
|
||||
BOOLEAN newline,
|
||||
Messagetype_t urgency,
|
||||
char * DefMessage,
|
||||
char * Devider,
|
||||
char * CstmMessage);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: debugPrint
|
||||
*
|
||||
* Function for a fast and easy stringOut method
|
||||
*
|
||||
* Parameters: char * Message - Message to send
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void debugPrint (char * Message);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: BooltoStr / BoolRestoStr
|
||||
*
|
||||
* Functions to convert a certain BOOLEAN-Value wether to "high" / "passed" or
|
||||
* "low" / "failed" String.
|
||||
*
|
||||
* Parameters: BOOLEAN Result - the Value to be converted
|
||||
*
|
||||
* Return: char * - converted String
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
char * BooltoStr (BOOLEAN var);
|
||||
char * BoolRestoStr (BOOLEAN Result);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: ItoDStr
|
||||
*
|
||||
* Function to convert a certain INT-Value to a dezimal formated String
|
||||
*
|
||||
* Parameters: UINT16 IntValue - the Value to be converted
|
||||
*
|
||||
* Return: char * - converted String
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
char * ItoDStr (UINT32 IntValue);
|
||||
char * FtoDStr (float IntValue);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: ItoHStr
|
||||
*
|
||||
* Function to convert a certain INT-Value to a hexadezimal formated String
|
||||
*
|
||||
* Parameters: UINT16 IntValue - the Value to be converted
|
||||
*
|
||||
* Return: char * - converted String
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
char * ItoHStr (UINT32 IntValue);
|
||||
|
||||
|
||||
|
||||
#endif /*SEROUT_H_*/
|
||||
@@ -0,0 +1,303 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* adc.c - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: ADC-driver (MCP3208-CI/SL)
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 28-11-2007, fvds.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "adc.h"
|
||||
#include "ssp0.h"
|
||||
#include "ElecStatusCache.h"
|
||||
#include "calibrateaio.h"
|
||||
#include "sys_config.h"
|
||||
#include "dio.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define ADC_CS_DIR_REG FIO1DIR
|
||||
#define ADC_CS_SET_REG FIO1SET
|
||||
#define ADC_CS_CLR_REG FIO1CLR
|
||||
#define ADC_CS_BIT BIT( 25 )
|
||||
#define ADC_CS_DISABLE (ADC_CS_SET_REG = ADC_CS_BIT)
|
||||
#define ADC_CS_ENABLE (ADC_CS_CLR_REG = ADC_CS_BIT)
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define ADC_CV_DIR_REG FIO3DIR
|
||||
#define ADC_CV_PIN_REG FIO3PIN
|
||||
#define ADC_CV_SET_REG FIO3SET
|
||||
#define ADC_CV_CLR_REG FIO3CLR
|
||||
#else
|
||||
#define ADC_CV_DIR_REG_P1 FIO1DIR
|
||||
#define ADC_CV_DIR_REG_P2 FIO2DIR
|
||||
#define ADC_CV_PIN_REG_P1 FIO1PIN
|
||||
#define ADC_CV_PIN_REG_P2 FIO2PIN
|
||||
#define ADC_CV_SET_REG_P1 FIO1SET
|
||||
#define ADC_CV_SET_REG_P2 FIO2SET
|
||||
#define ADC_CV_CLR_REG_P1 FIO1CLR
|
||||
#define ADC_CV_CLR_REG_P2 FIO2CLR
|
||||
#endif
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define CURRENT_VOLTAGE_BITS (0x000000FF)
|
||||
#else
|
||||
#define CURRENT_VOLTAGE_BITS_P1 (0x3C000000)
|
||||
#define CURRENT_VOLTAGE_BITS_P2 (0x00000078)
|
||||
#endif
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define ADC_MUX_DIR FIO3DIR
|
||||
#define ADC_MUX_SET FIO3SET
|
||||
#define ADC_MUX_CLR FIO3CLR
|
||||
|
||||
#define ADC_MUX_BIT BIT(23)
|
||||
#define ADC_MUX_EN (ADC_MUX_SET = ADC_MUX_BIT)
|
||||
#define ADC_MUX_DS (ADC_MUX_CLR = ADC_MUX_BIT)
|
||||
#endif
|
||||
|
||||
#define spiWrite ssp0Write
|
||||
#define spiRead ssp0Read
|
||||
#define spiWriteBuffer ssp0WriteBuffer
|
||||
#define spiReadBuffer ssp0ReadBuffer
|
||||
#define spiTakeBus ssp0TakeBus
|
||||
#define spiReleaseBus ssp0ReleaseBus
|
||||
|
||||
#define ADC_START_CMD (0x04)
|
||||
#define ADC_SINGLE_ENDED (0x02)
|
||||
#define ADC_DIFFERENTIAL (0x00)
|
||||
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
UINT16 InputVoltageCorrection[8];
|
||||
UINT16 InputCurrentCorrection[8];
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void adcInit (void)
|
||||
{
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
/* TESTER Pins like IO_CTRL REV_B */
|
||||
ADC_CV_DIR_REG |= CURRENT_VOLTAGE_BITS;
|
||||
#else
|
||||
ADC_CV_DIR_REG_P1 |= CURRENT_VOLTAGE_BITS_P1;
|
||||
ADC_CV_DIR_REG_P2 |= CURRENT_VOLTAGE_BITS_P2;
|
||||
#endif
|
||||
#if (PINSET_TESTER == 2)
|
||||
/* TESTER Pins like IO_CTRL REV_B */
|
||||
ADC_CV_SET_REG = CURRENT_VOLTAGE_BITS; // Default all bits to current
|
||||
#else
|
||||
ADC_CV_SET_REG_P1 = CURRENT_VOLTAGE_BITS_P1;
|
||||
ADC_CV_SET_REG_P2 = CURRENT_VOLTAGE_BITS_P2;
|
||||
#endif
|
||||
|
||||
ADC_CS_DIR_REG |= ADC_CS_BIT;
|
||||
ADC_CS_DISABLE;
|
||||
|
||||
loadCorrectionValue(InputVoltageCorrection, VoltageInput);
|
||||
loadCorrectionValue(InputCurrentCorrection, CurrentInput);
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
ADC_MUX_DIR |= ADC_MUX_BIT;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void adc_MuxEn (BOOLEAN mode)
|
||||
{
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
if (mode == TRUE)
|
||||
{
|
||||
ADC_MUX_EN; /* Set MUX to ExtensionBoard */
|
||||
}
|
||||
else
|
||||
{
|
||||
ADC_MUX_DS; /* Set MUX to MainBoard */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOLEAN adc_MuxRB (void)
|
||||
{
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
if (ADC_MUX_SET & ADC_MUX_BIT)
|
||||
{
|
||||
/* Mux is switched to ExtensionBoard */
|
||||
return (TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Mux is switched to MainBoard */
|
||||
return (FALSE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/** \brief Select input mode (Voltage or Current) of a certain channel. */
|
||||
void adcMode (
|
||||
UINT8 channel, /**< 0..7 = valid, 8..255 = future use */
|
||||
t_adc_mode mode
|
||||
)
|
||||
{
|
||||
#if (PINSET_TESTER == 2)
|
||||
/* TESTER Pins like IO_CTRL REV_B */
|
||||
if (channel >= maxADC_Channels ) return; // Channel doesn't exist
|
||||
|
||||
if (mode == adcVOLTAGE)
|
||||
{
|
||||
ADC_CV_CLR_REG = BIT( channel );
|
||||
}
|
||||
else
|
||||
{
|
||||
ADC_CV_SET_REG = BIT( channel );
|
||||
}
|
||||
#else
|
||||
if (channel >= maxADC_Channels ) return; // Channel doesn't exist
|
||||
|
||||
if (mode == adcVOLTAGE)
|
||||
{
|
||||
if (channel <= 3)
|
||||
{
|
||||
ADC_CV_CLR_REG_P1 = BIT (26 + channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
ADC_CV_CLR_REG_P2 = BIT (channel - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (channel <= 3)
|
||||
{
|
||||
ADC_CV_SET_REG_P1 = BIT (26 + channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
ADC_CV_SET_REG_P2 = BIT (channel - 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/** \brief Read analog value in mV or uA depending on adcMode
|
||||
\retval value VOLTAGE: 0..10000[mV], CURRENT: 0..20000[uA] */
|
||||
UINT16 adcRead (
|
||||
UINT8 device, /**< 0 = Self, 1..32 = Remote device */
|
||||
UINT8 channel /**< 0..7 = valid, 8..255 = future use */
|
||||
)
|
||||
{
|
||||
UINT8 spiAdcCommand[3];
|
||||
UINT8 spiAdcResponse[3];
|
||||
UINT16 adcResult;
|
||||
UINT32 range;
|
||||
UINT32 measuredValue;
|
||||
|
||||
if (device > 0)
|
||||
{
|
||||
measuredValue = bpecAdcRead(device, channel);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (channel >= maxADC_Channels) return 0;
|
||||
|
||||
spiAdcCommand[0] = (ADC_START_CMD | ADC_SINGLE_ENDED);
|
||||
spiAdcCommand[0] |= (channel >> 2) & 0x01;
|
||||
spiAdcCommand[1] = (channel << 6);
|
||||
spiAdcCommand[2] = 0;
|
||||
|
||||
spiTakeBus();
|
||||
{
|
||||
ADC_CS_ENABLE;
|
||||
|
||||
spiWriteBuffer( spiAdcCommand, 3 );
|
||||
spiReadBuffer( spiAdcResponse, 3 );
|
||||
|
||||
ADC_CS_DISABLE;
|
||||
}
|
||||
spiReleaseBus();
|
||||
|
||||
adcResult = (UINT16)(spiAdcResponse[1] & 0x0F) << 8;
|
||||
adcResult |= (UINT16)spiAdcResponse[2];
|
||||
|
||||
// Convert ADC value (0-4096) to measured value
|
||||
// Determin range Voltage = 10000 & Ampere = 20000
|
||||
#if (PINSET_TESTER == 2)
|
||||
/* TESTER Pins like IO_CTRL REV_B */
|
||||
if ((ADC_CV_PIN_REG & BIT( channel )) == 0)
|
||||
#else
|
||||
if ((((ADC_CV_PIN_REG_P1 & BIT (26 + channel)) == 0) && (channel <= 3))
|
||||
|| (((ADC_CV_PIN_REG_P2 & BIT (channel - 1)) == 0) && (channel >= 4)))
|
||||
#endif
|
||||
{
|
||||
range = 10000;
|
||||
measuredValue = (adcResult * range) / InputVoltageCorrection[channel];
|
||||
}
|
||||
else
|
||||
{
|
||||
range = 20000;
|
||||
measuredValue = (adcResult * range) / InputCurrentCorrection[channel];
|
||||
}
|
||||
}
|
||||
|
||||
return (UINT16)measuredValue;
|
||||
}
|
||||
|
||||
void adcModeAll (t_adc_mode mode)
|
||||
{
|
||||
adcMode (0, mode);
|
||||
adcMode (1, mode);
|
||||
adcMode (2, mode);
|
||||
adcMode (3, mode);
|
||||
adcMode (4, mode);
|
||||
adcMode (5, mode);
|
||||
adcMode (6, mode);
|
||||
adcMode (7, mode);
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* adc.h - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: Analog to digital signal interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 10-09-2007, Marcel Mulder.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __ADC_H__
|
||||
#define __ADC_H__
|
||||
/** \file adc.h
|
||||
\brief Analog to digital signal interface.
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** Maximum number of real analog channels*/
|
||||
#define maxADC_Channels (8)
|
||||
#define maxADC_VOLTAGE (10000)
|
||||
#define maxADC_CURRENT (20000)
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
adcVOLTAGE, /**< Voltage mode 0 to 10V */
|
||||
adcCURRENT /**< Current mode 0 to 20mA */
|
||||
} t_adc_mode;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** \brief Initialize ADC.*/
|
||||
void adcInit (void);
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
|
||||
void adc_MuxEn (BOOLEAN mode);
|
||||
|
||||
BOOLEAN adc_MuxRB (void);
|
||||
|
||||
|
||||
/** \brief Select input mode (Voltage or Current) of a certain channel. */
|
||||
void adcMode (
|
||||
UINT8 channel, /**< 0..7 = valid, 8..255 = future use */
|
||||
t_adc_mode mode
|
||||
);
|
||||
|
||||
/** \brief Read analog value in mV or uA depending on adcMode
|
||||
\retval value VOLTAGE: 0..10000[mV], CURRENT: 0..20000[uA] */
|
||||
UINT16 adcRead (
|
||||
UINT8 device, /**< 0 = Self, 1..32 = Remote device */
|
||||
UINT8 channel /**< 0..7 = valid, 8..255 = future use */
|
||||
);
|
||||
|
||||
void adcModeAll (t_adc_mode mode);
|
||||
|
||||
#endif /* __ADC_H__ */
|
||||
@@ -0,0 +1,19 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* $RCSfile: $
|
||||
* $Revision: $
|
||||
*
|
||||
* This module defines some regularly used typedefs
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef APP_TYPES_H__
|
||||
#define APP_TYPES_H__
|
||||
|
||||
/* typedefs are here */
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h> /* NULL */
|
||||
|
||||
typedef enum {false, true} boolean;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,85 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* $RCSfile: $
|
||||
* $Revision: $
|
||||
*
|
||||
* This module provides the interface routines for setting up and
|
||||
* controlling the various interrupt modes present on the ARM processor.
|
||||
* Copyright 2004, R O SoftWare
|
||||
* No guarantees, warrantees, or promises, implied or otherwise.
|
||||
* May be used for hobby or commercial purposes provided copyright
|
||||
* notice remains intact.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#include "app_types.h"
|
||||
#include "armVIC.h"
|
||||
|
||||
#define IRQ_MASK 0x00000080
|
||||
#define FIQ_MASK 0x00000040
|
||||
#define INT_MASK (IRQ_MASK | FIQ_MASK)
|
||||
|
||||
static inline unsigned __get_cpsr(void)
|
||||
{
|
||||
unsigned long retval;
|
||||
asm volatile (" mrs %0, cpsr" : "=r" (retval) : /* no inputs */ );
|
||||
return retval;
|
||||
}
|
||||
|
||||
static inline void __set_cpsr(unsigned val)
|
||||
{
|
||||
asm volatile (" msr cpsr, %0" : /* no outputs */ : "r" (val) );
|
||||
}
|
||||
|
||||
unsigned disableIRQ(void)
|
||||
{
|
||||
unsigned _cpsr;
|
||||
|
||||
_cpsr = __get_cpsr();
|
||||
__set_cpsr(_cpsr | IRQ_MASK);
|
||||
return _cpsr;
|
||||
}
|
||||
|
||||
unsigned restoreIRQ(unsigned oldCPSR)
|
||||
{
|
||||
unsigned _cpsr;
|
||||
|
||||
_cpsr = __get_cpsr();
|
||||
__set_cpsr((_cpsr & ~IRQ_MASK) | (oldCPSR & IRQ_MASK));
|
||||
return _cpsr;
|
||||
}
|
||||
|
||||
unsigned enableIRQ(void)
|
||||
{
|
||||
unsigned _cpsr;
|
||||
|
||||
_cpsr = __get_cpsr();
|
||||
__set_cpsr(_cpsr & ~IRQ_MASK);
|
||||
return _cpsr;
|
||||
}
|
||||
|
||||
unsigned disableFIQ(void)
|
||||
{
|
||||
unsigned _cpsr;
|
||||
|
||||
_cpsr = __get_cpsr();
|
||||
__set_cpsr(_cpsr | FIQ_MASK);
|
||||
return _cpsr;
|
||||
}
|
||||
|
||||
unsigned restoreFIQ(unsigned oldCPSR)
|
||||
{
|
||||
unsigned _cpsr;
|
||||
|
||||
_cpsr = __get_cpsr();
|
||||
__set_cpsr((_cpsr & ~FIQ_MASK) | (oldCPSR & FIQ_MASK));
|
||||
return _cpsr;
|
||||
}
|
||||
|
||||
unsigned enableFIQ(void)
|
||||
{
|
||||
unsigned _cpsr;
|
||||
|
||||
_cpsr = __get_cpsr();
|
||||
__set_cpsr(_cpsr & ~FIQ_MASK);
|
||||
return _cpsr;
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* $RCSfile: $
|
||||
* $Revision: $
|
||||
*
|
||||
* This module provides the interface definitions for setting up and
|
||||
* controlling the various interrupt modes present on the ARM processor.
|
||||
* Copyright 2004, R O SoftWare
|
||||
* No guarantees, warrantees, or promises, implied or otherwise.
|
||||
* May be used for hobby or commercial purposes provided copyright
|
||||
* notice remains intact.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef INC_ARM_VIC_H
|
||||
#define INC_ARM_VIC_H
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* MACRO Name: ISR_ENTRY()
|
||||
*
|
||||
* Description:
|
||||
* This MACRO is used upon entry to an ISR. The current version of
|
||||
* the gcc compiler for ARM does not produce correct code for
|
||||
* interrupt routines to operate properly with THUMB code. The MACRO
|
||||
* performs the following steps:
|
||||
*
|
||||
* 1 - Adjust address at which execution should resume after servicing
|
||||
* ISR to compensate for IRQ entry
|
||||
* 2 - Save the non-banked registers r0-r12 and lr onto the IRQ stack.
|
||||
* 3 - Get the status of the interrupted program is in SPSR.
|
||||
* 4 - Push it onto the IRQ stack as well.
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define ISR_ENTRY() asm volatile(" sub lr, lr,#4\n" \
|
||||
" stmfd sp!,{r0-r12,lr}\n" \
|
||||
" mrs r1, spsr\n" \
|
||||
" stmfd sp!,{r1}")
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* MACRO Name: ISR_EXIT()
|
||||
*
|
||||
* Description:
|
||||
* This MACRO is used to exit an ISR. The current version of the gcc
|
||||
* compiler for ARM does not produce correct code for interrupt
|
||||
* routines to operate properly with THUMB code. The MACRO performs
|
||||
* the following steps:
|
||||
*
|
||||
* 1 - Recover SPSR value from stack
|
||||
* 2 - and restore its value
|
||||
* 3 - Pop the return address & the saved general registers from
|
||||
* the IRQ stack & return
|
||||
*
|
||||
*****************************************************************************/
|
||||
#define ISR_EXIT() asm volatile(" ldmfd sp!,{r1}\n" \
|
||||
" msr spsr_c,r1\n" \
|
||||
" ldmfd sp!,{r0-r12,pc}^")
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Function Name: disableIRQ()
|
||||
*
|
||||
* Description:
|
||||
* This function sets the IRQ disable bit in the status register
|
||||
*
|
||||
* Calling Sequence:
|
||||
* void
|
||||
*
|
||||
* Returns:
|
||||
* previous value of CPSR
|
||||
*
|
||||
*****************************************************************************/
|
||||
unsigned disableIRQ(void);
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Function Name: enableIRQ()
|
||||
*
|
||||
* Description:
|
||||
* This function clears the IRQ disable bit in the status register
|
||||
*
|
||||
* Calling Sequence:
|
||||
* void
|
||||
*
|
||||
* Returns:
|
||||
* previous value of CPSR
|
||||
*
|
||||
*****************************************************************************/
|
||||
unsigned enableIRQ(void);
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Function Name: restoreIRQ()
|
||||
*
|
||||
* Description:
|
||||
* This function restores the IRQ disable bit in the status register
|
||||
* to the value contained within passed oldCPSR
|
||||
*
|
||||
* Calling Sequence:
|
||||
* void
|
||||
*
|
||||
* Returns:
|
||||
* previous value of CPSR
|
||||
*
|
||||
*****************************************************************************/
|
||||
unsigned restoreIRQ(unsigned oldCPSR);
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Function Name: disableFIQ()
|
||||
*
|
||||
* Description:
|
||||
* This function sets the FIQ disable bit in the status register
|
||||
*
|
||||
* Calling Sequence:
|
||||
* void
|
||||
*
|
||||
* Returns:
|
||||
* previous value of CPSR
|
||||
*
|
||||
*****************************************************************************/
|
||||
unsigned disableFIQ(void);
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Function Name: enableFIQ()
|
||||
*
|
||||
* Description:
|
||||
* This function clears the FIQ disable bit in the status register
|
||||
*
|
||||
* Calling Sequence:
|
||||
* void
|
||||
*
|
||||
* Returns:
|
||||
* previous value of CPSR
|
||||
*
|
||||
*****************************************************************************/
|
||||
unsigned enableFIQ(void);
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Function Name: restoreIRQ()
|
||||
*
|
||||
* Description:
|
||||
* This function restores the FIQ disable bit in the status register
|
||||
* to the value contained within passed oldCPSR
|
||||
*
|
||||
* Calling Sequence:
|
||||
* void
|
||||
*
|
||||
* Returns:
|
||||
* previous value of CPSR
|
||||
*
|
||||
*****************************************************************************/
|
||||
unsigned restoreFIQ(unsigned oldCPSR);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,317 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* bus.c - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: RS-485 bus driver
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 28-11-2007, fvds.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
#include "bus.h"
|
||||
#include "armVIC.h"
|
||||
#include "uart2.h"
|
||||
#include "uart3.h"
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define NR_OF_BUSPORTS 2
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
// \TODO WATCH OUT PATCHES FOR UART2
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define UB2_DE_PINSEL_REG PINSEL2
|
||||
#define UB2_DE_PINSEL (0UL<<4) /* PINSEL8 Value for GPIO (P2.2) */
|
||||
#define UB2_DE_PINMASK (3UL<<4) /* PINSEL8 Mask for GPIO (P2.2) */
|
||||
#define UB2_RE_PINSEL_REG PINSEL2
|
||||
#define UB2_RE_PINSEL (0UL<<6) /* PINSEL8 Value for GPIO (P2.3) */
|
||||
#define UB2_RE_PINMASK (3UL<<6) /* PINSEL8 Mask for GPIO (P2.3) */
|
||||
#define UB3_DE_PINSEL_REG PINSEL2
|
||||
#define UB3_DE_PINSEL (0UL<<10) /* PINSEL8 Value for GPIO (P2.5) */
|
||||
#define UB3_DE_PINMASK (3UL<<10) /* PINSEL8 Mask for GPIO (P2.5) */
|
||||
#define UB3_RE_PINSEL_REG PINSEL2
|
||||
#define UB3_RE_PINSEL (0UL<<12) /* PINSEL8 Value for GPIO (P2.6) */
|
||||
#define UB3_RE_PINMASK (3UL<<12) /* PINSEL8 Mask for GPIO (P2.6) */
|
||||
#else
|
||||
#define UB2_DE_PINSEL_REG PINSEL3
|
||||
#define UB2_DE_PINSEL (0UL<<0) /* PINSEL3 Value for GPIO */
|
||||
#define UB2_DE_PINMASK (3UL<<0) /* PINSEL3 Mask for GPIO */
|
||||
#define UB2_RE_PINSEL_REG PINSEL3
|
||||
#define UB2_RE_PINSEL (0UL<<2) /* PINSEL3 Value for GPIO */
|
||||
#define UB2_RE_PINMASK (3UL<<2) /* PINSEL3 Mask for GPIO */
|
||||
#define UB3_DE_PINSEL_REG PINSEL3
|
||||
#define UB3_DE_PINSEL (0UL<<4) /* PINSEL3 Value for GPIO */
|
||||
#define UB3_DE_PINMASK (3UL<<4) /* PINSEL3 Mask for GPIO */
|
||||
#define UB3_RE_PINSEL_REG PINSEL3
|
||||
#define UB3_RE_PINSEL (0UL<<6) /* PINSEL3 Value for GPIO */
|
||||
#define UB3_RE_PINMASK (3UL<<6) /* PINSEL3 Mask for GPIO */
|
||||
#endif
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define UB2_REN_DE_DIR_REG FIO2DIR
|
||||
#define UB2_REN_DE_SET_REG FIO2SET
|
||||
#define UB2_REN_DE_CLR_REG FIO2CLR
|
||||
#else
|
||||
#define UB2_REN_DE_DIR_REG FIO1DIR
|
||||
#define UB2_REN_DE_SET_REG FIO1SET
|
||||
#define UB2_REN_DE_CLR_REG FIO1CLR
|
||||
#endif
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define UB2_REN_BIT BIT(3)
|
||||
#define UB2_DE_BIT BIT(2)
|
||||
#else
|
||||
#define UB2_REN_BIT BIT(17)
|
||||
#define UB2_DE_BIT BIT(16)
|
||||
#endif
|
||||
#define UB2_REN_DE_BITS (UB2_REN_BIT | UB2_DE_BIT)
|
||||
#define UB2_TX_MODE (UB2_REN_DE_SET_REG = UB2_REN_DE_BITS)
|
||||
#define UB2_RX_MODE (UB2_REN_DE_CLR_REG = UB2_REN_DE_BITS)
|
||||
#define UB2_LOOPBACK_MODE
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define UB3_REN_DE_DIR_REG FIO2DIR
|
||||
#define UB3_REN_DE_SET_REG FIO2SET
|
||||
#define UB3_REN_DE_CLR_REG FIO2CLR
|
||||
#else
|
||||
#define UB3_REN_DE_DIR_REG FIO1DIR
|
||||
#define UB3_REN_DE_SET_REG FIO1SET
|
||||
#define UB3_REN_DE_CLR_REG FIO1CLR
|
||||
#endif
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define UB3_REN_BIT BIT(6)
|
||||
#define UB3_DE_BIT BIT(5)
|
||||
#else
|
||||
#define UB3_REN_BIT BIT(19)
|
||||
#define UB3_DE_BIT BIT(18)
|
||||
#endif
|
||||
#define UB3_REN_DE_BITS (UB3_REN_BIT | UB3_DE_BIT)
|
||||
#define UB3_TX_MODE (UB3_REN_DE_SET_REG = UB3_REN_DE_BITS)
|
||||
#define UB3_RX_MODE (UB3_REN_DE_CLR_REG = UB3_REN_DE_BITS)
|
||||
#define UB3_LOOPBACK_MODE
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void onUart2TxFinished();
|
||||
void onUart3TxFinished();
|
||||
|
||||
|
||||
/** \brief Initialize of serial interface.*/
|
||||
void busInit (
|
||||
t_bus_devices device
|
||||
)
|
||||
{
|
||||
SCS |= (1UL<<0); // set GPIOM in SCS for fast IO
|
||||
|
||||
switch( device )
|
||||
{
|
||||
case(BUS1):
|
||||
// set EN/DE pins for BUS0
|
||||
UB2_DE_PINSEL_REG = ( UB2_DE_PINSEL_REG & ~UB2_DE_PINMASK ) | UB2_DE_PINSEL;
|
||||
UB2_RE_PINSEL_REG = ( UB2_RE_PINSEL_REG & ~UB2_RE_PINMASK ) | UB2_RE_PINSEL;
|
||||
|
||||
// set EN/DE pin as output and in Receive mode
|
||||
UB2_REN_DE_DIR_REG |= UB2_REN_DE_BITS;
|
||||
UB2_RX_MODE;
|
||||
uart2Init( B38400, UART_8N1, UART_FIFO_8 ); // \TODO BAUDRATE
|
||||
uart2SubscribeTxFinished( onUart2TxFinished );
|
||||
|
||||
break;
|
||||
case(BUS2):
|
||||
// set EN/DE pins for BUS1
|
||||
UB3_DE_PINSEL_REG = ( UB3_DE_PINSEL_REG & ~UB3_DE_PINMASK ) | UB3_DE_PINSEL;
|
||||
UB3_RE_PINSEL_REG = ( UB3_RE_PINSEL_REG & ~UB3_RE_PINMASK ) | UB3_RE_PINSEL;
|
||||
|
||||
// set EN/DE pin as output and in Receive mode
|
||||
UB3_REN_DE_DIR_REG |= UB3_REN_DE_BITS;
|
||||
UB3_RX_MODE;
|
||||
|
||||
uart3Init( B38400, UART_8N1, UART_FIFO_8 ); // \TODO BAUDRATE
|
||||
uart3SubscribeTxFinished( onUart3TxFinished );
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** \brief Write data of a certain length to a serial port.*/
|
||||
void busWrite (
|
||||
t_bus_devices device,
|
||||
UINT16 length, /**< Lengh of data in bytes */
|
||||
UINT8 *data /**< Pointer to data */
|
||||
)
|
||||
{
|
||||
switch( device )
|
||||
{
|
||||
case(BUS1):
|
||||
UB2_TX_MODE;
|
||||
uart2Write( (char *)data, length);
|
||||
break;
|
||||
|
||||
case(BUS2):
|
||||
UB3_TX_MODE;
|
||||
uart3Write( (char *)data, length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Reads data from serial port.
|
||||
\retval Length of received data in bytes*/
|
||||
UINT16 busRead (
|
||||
t_bus_devices device,
|
||||
UINT8 * data /**< Pointer to data */
|
||||
)
|
||||
{
|
||||
UINT16 bytesReceived = 0;
|
||||
BOOLEAN receivedSomething;
|
||||
do
|
||||
{
|
||||
receivedSomething = busGet( device, &(data[bytesReceived]));
|
||||
if (receivedSomething)
|
||||
bytesReceived++;
|
||||
} while(receivedSomething);
|
||||
|
||||
return bytesReceived;
|
||||
}
|
||||
|
||||
/** \brief Get byte from serial port.
|
||||
\retval bool Returns true if there was data */
|
||||
BOOLEAN busGet(
|
||||
t_bus_devices device,
|
||||
UINT8 * byte /**< Pointer to byte to return data*/
|
||||
)
|
||||
{
|
||||
int receivedChar = -1;
|
||||
|
||||
switch( device )
|
||||
{
|
||||
case(BUS1):
|
||||
receivedChar = uart2Getch();
|
||||
break;
|
||||
case(BUS2):
|
||||
receivedChar = uart3Getch();
|
||||
break;
|
||||
}
|
||||
|
||||
if (receivedChar >= 0)
|
||||
{
|
||||
*byte = (UINT8)receivedChar;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Send byte to serial port. */
|
||||
void busPut(
|
||||
t_bus_devices device,
|
||||
UINT8 value /**< Byte to send*/
|
||||
)
|
||||
{
|
||||
switch( device )
|
||||
{
|
||||
case(BUS1):
|
||||
UB2_TX_MODE;
|
||||
uart2Putch( value );
|
||||
break;
|
||||
case(BUS2):
|
||||
UB3_TX_MODE;
|
||||
uart3Putch( value );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** \brief Flush serial port buffers. */
|
||||
void busFlush(
|
||||
t_bus_devices device
|
||||
)
|
||||
{
|
||||
switch( device )
|
||||
{
|
||||
case(BUS1):
|
||||
uart2TxFlush( );
|
||||
break;
|
||||
case(BUS2):
|
||||
uart3TxFlush( );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** \brief Check if receive buffers is empty.
|
||||
\retval bool Returns true if recieve buffer is empty */
|
||||
BOOLEAN busEmpty(
|
||||
t_bus_devices device
|
||||
)
|
||||
{
|
||||
switch( device )
|
||||
{
|
||||
case(BUS1):
|
||||
return (uart2RxEmpty( ) != 0);
|
||||
break;
|
||||
case(BUS2):
|
||||
return (uart3RxEmpty( ) != 0);
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
void onUart2TxFinished()
|
||||
{
|
||||
// After all characters are send, put back in Receiver mode
|
||||
UB2_RX_MODE;
|
||||
}
|
||||
|
||||
void onUart3TxFinished()
|
||||
{
|
||||
// After all characters are send, put back in Receiver mode
|
||||
UB3_RX_MODE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* bus.h - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: RS485 interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 10-09-2007, Marcel Mulder.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __BUS_H__
|
||||
#define __BUS_H__
|
||||
|
||||
/** \file bus.h
|
||||
\brief RS485 (UART) interface.
|
||||
*/
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
#include "uart.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
BUS1, /**< First RS485 port*/
|
||||
BUS2 /**< Second RS485 port*/
|
||||
} t_bus_devices;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** \brief Initialize of serial bus interface.*/
|
||||
void busInit (
|
||||
t_bus_devices device
|
||||
);
|
||||
|
||||
/** \brief Write data of a certain length to a serial bus.*/
|
||||
void busWrite (
|
||||
t_bus_devices device,
|
||||
UINT16 length, /**< Lengh of data in bytes */
|
||||
UINT8 * data /**< Pointer to data */
|
||||
);
|
||||
|
||||
/** \brief Reads data from serial bus.
|
||||
\retval Lengt of received data in bytes*/
|
||||
UINT16 busRead (
|
||||
t_bus_devices device,
|
||||
UINT8 * data /**< Pointer to data */
|
||||
);
|
||||
|
||||
/** \brief Get byte from serial bus.
|
||||
\retval bool Returns true if there was data */
|
||||
BOOLEAN busGet(
|
||||
t_bus_devices device,
|
||||
UINT8 * byte /**< Pointer to byte to return data*/
|
||||
);
|
||||
|
||||
/** \brief Send byte to serial bus. */
|
||||
void busPut(
|
||||
t_bus_devices device,
|
||||
UINT8 value /**< Byte to send*/
|
||||
);
|
||||
|
||||
/** \brief Flush serial bus buffers. */
|
||||
void busFlush(
|
||||
t_bus_devices device
|
||||
);
|
||||
|
||||
/** \brief Check if receive buffers is empty.
|
||||
\retval bool Returns true if recieve buffer is empty
|
||||
*/
|
||||
BOOLEAN busEmpty(
|
||||
t_bus_devices device
|
||||
);
|
||||
|
||||
#endif /* __BUS_H__ */
|
||||
@@ -0,0 +1,769 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* calibrateaio.c (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Mei 22, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* APPLICATION NOTES:
|
||||
* Voltage Input Calibration: All Inputs need to be connected to the defined,
|
||||
* preset Voltage Value (e.g. 10 V).
|
||||
*
|
||||
* Voltage Output Calibration: Output 0-3 need to be connected to own Inputs
|
||||
* 0-3.
|
||||
*
|
||||
* Current Input Calibration: All Inputs need to be connected to the defined,
|
||||
* preset Current Value (e.g. 20 mA per channel)
|
||||
*
|
||||
* Current Output Calibration: Output 0-3 need to be connected to own Inputs
|
||||
* 0-3. All other Connections must be removed.
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "Task.h"
|
||||
#include "semphr.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "calibrateaio.h"
|
||||
#include "adc.h"
|
||||
#include "dac.h"
|
||||
#include "dio.h"
|
||||
#include "eeprom.h"
|
||||
#include "ssp0.h"
|
||||
#include "BusProtocol.h"
|
||||
#include "serial.h"
|
||||
#include "SerOut.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define NumberOfOutputChannels maxDAC_Channels /* See dac.h */
|
||||
#define NumberOfInputChannels maxADC_Channels /* See adc.h */
|
||||
|
||||
#define MaximumCurrent 20000 /* Maximum driveable Current */
|
||||
#define MaximumVoltage 10000 /* Maximum driveable Voltage */
|
||||
|
||||
/* Addresses, where correction factors are stored in the EEPROM */
|
||||
#define VI_Address 0x00 /* Adress of Voltage Input Factor */
|
||||
#define CI_Address 0x10 /* Adress of Current Input Factor */
|
||||
#define VO_Address 0x20 /* Adress of Voltage Output Factor */
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define CO_Address 0x30 /* Adress of Current Output Factor */
|
||||
#else
|
||||
#define CO_Address 0x28 /* Adress of Current Output Factor */
|
||||
#endif
|
||||
|
||||
#define VI_ByteLength 0x10 /* Length of VI Entry in Bytes */
|
||||
#define CI_ByteLength 0x10 /* Length of CI Entry in Bytes */
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define VO_ByteLength 0x10 /* Length of VO Entry in Bytes */
|
||||
#define CO_ByteLength 0x10 /* Length of CO Entry in Bytes */
|
||||
#else
|
||||
#define VO_ByteLength 0x08 /* Length of VO Entry in Bytes */
|
||||
#define CO_ByteLength 0x08 /* Length of CO Entry in Bytes */
|
||||
#endif
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define ident_VoltageInput 0x40 /* Stat of Volt. Input Calibration */
|
||||
#define ident_VoltageOutput 0x41 /* Stat of Volt. Output Calibration */
|
||||
#define ident_CurrentInput 0x42 /* Stat of Curr. Input Calibration */
|
||||
#define ident_CurrentOutput 0x43 /* Stat of Curr. Output Calibration */
|
||||
#else
|
||||
#define ident_VoltageInput 0x30 /* Stat of Volt. Input Calibration */
|
||||
#define ident_VoltageOutput 0x31 /* Stat of Volt. Output Calibration */
|
||||
#define ident_CurrentInput 0x32 /* Stat of Curr. Input Calibration */
|
||||
#define ident_CurrentOutput 0x33 /* Stat of Curr. Output Calibration */
|
||||
#endif
|
||||
|
||||
#define DAC_CHANNEL_A (0x8000)
|
||||
#define DAC_CHANNEL_B (0x0000)
|
||||
|
||||
|
||||
#define spiWriteBuffer ssp0WriteBuffer
|
||||
#define spiReadBuffer ssp0ReadBuffer
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* External Arrays where system stores calibration values for temporary use */
|
||||
extern UINT16 OutputVoltageCorrection[NumberOfOutputChannels];
|
||||
extern UINT16 OutputCurrentCorrection[NumberOfOutputChannels];
|
||||
extern UINT16 InputVoltageCorrection[NumberOfInputChannels];
|
||||
extern UINT16 InputCurrentCorrection[NumberOfInputChannels];
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void killStats (void)
|
||||
{
|
||||
eepromWrite(ident_VoltageInput, 0x00); /* Write 0x00 to EEPROM Adress */
|
||||
eepromWrite(ident_VoltageOutput, 0x00);
|
||||
eepromWrite(ident_CurrentInput, 0x00);
|
||||
eepromWrite(ident_CurrentOutput, 0x00);
|
||||
}
|
||||
|
||||
void defaultStats (void)
|
||||
{
|
||||
eepromWrite(ident_VoltageInput, ident_default); /* Write DEFAULT Value */
|
||||
eepromWrite(ident_VoltageOutput, ident_default);
|
||||
eepromWrite(ident_CurrentInput, ident_default);
|
||||
eepromWrite(ident_CurrentOutput, ident_default);
|
||||
}
|
||||
|
||||
void calibratedStats (void)
|
||||
{
|
||||
eepromWrite(ident_VoltageInput, ident_calibrated); /* Write CALIBRATED */
|
||||
eepromWrite(ident_VoltageOutput, ident_calibrated);
|
||||
eepromWrite(ident_CurrentInput, ident_calibrated);
|
||||
eepromWrite(ident_CurrentOutput, ident_calibrated);
|
||||
}
|
||||
|
||||
|
||||
void calibrationInit (void)
|
||||
{
|
||||
UINT8 volin;
|
||||
UINT8 volout;
|
||||
UINT8 curin;
|
||||
UINT8 curout;
|
||||
|
||||
/* Readout Stats from EEPROM */
|
||||
eepromRead(ident_VoltageInput, &volin);
|
||||
eepromRead(ident_VoltageOutput, &volout);
|
||||
eepromRead(ident_CurrentInput, &curin);
|
||||
eepromRead(ident_CurrentOutput, &curout);
|
||||
|
||||
/* If a Stat is not defined, delete the Values and reset them to DEFAULT*/
|
||||
if ((volin != ident_default) && (volin != ident_calibrated))
|
||||
{
|
||||
deleteCorrectionValue(VoltageInput);
|
||||
loadCorrectionValue_defaultTarget(VoltageInput);
|
||||
}
|
||||
if ((volout != ident_default) && (volout != ident_calibrated))
|
||||
{
|
||||
deleteCorrectionValue(VoltageOutput);
|
||||
loadCorrectionValue_defaultTarget(VoltageOutput);
|
||||
}
|
||||
if ((curin != ident_default) && (curin != ident_calibrated))
|
||||
{
|
||||
deleteCorrectionValue(CurrentInput);
|
||||
loadCorrectionValue_defaultTarget(CurrentInput);
|
||||
}
|
||||
if ((curout != ident_default) && (curout != ident_calibrated))
|
||||
{
|
||||
deleteCorrectionValue(CurrentOutput);
|
||||
loadCorrectionValue_defaultTarget(CurrentOutput);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
UINT8 returnCalibrationStatus (daadCorrection_t correctionType)
|
||||
{
|
||||
UINT8 readback;
|
||||
|
||||
/* read corresponding Stats from EEPROM */
|
||||
switch (correctionType)
|
||||
{
|
||||
case VoltageInput: eepromRead(ident_VoltageInput, &readback);
|
||||
break;
|
||||
case VoltageOutput: eepromRead(ident_VoltageOutput, &readback);
|
||||
break;
|
||||
case CurrentInput: eepromRead(ident_CurrentInput, &readback);
|
||||
break;
|
||||
case CurrentOutput: eepromRead(ident_CurrentOutput, &readback);
|
||||
break;
|
||||
}
|
||||
|
||||
return (readback); /* Return read Value to Caller */
|
||||
}
|
||||
|
||||
|
||||
UINT8 showLocalCalibrationStatus (INT32 correctionType)
|
||||
{
|
||||
UINT8 readback;
|
||||
|
||||
readback = returnCalibrationStatus (correctionType);
|
||||
|
||||
if (readback & ident_default)
|
||||
{
|
||||
sendString (SerOutPort, FALSE, importantMessage,
|
||||
"Values are in DEFAULT Mode", Dummy, Dummy);
|
||||
}
|
||||
else if (readback & ident_calibrated)
|
||||
{
|
||||
sendString (SerOutPort, FALSE, importantMessage,
|
||||
"Values are in CALIBRATED Mode", Dummy, Dummy);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendString (SerOutPort, FALSE, importantMessage,
|
||||
"NO VALID VALUES IN EEPROM", Dummy, Dummy);
|
||||
}
|
||||
|
||||
return (readback);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Calibration of Analogue Inputs in Voltage Mode:
|
||||
* Attach Voltage Supply with Calibration Value (recommended: 10,000 V) to
|
||||
* the Input(s) you want to calibrate. Software will read out the real,
|
||||
* digital Value from the ADC and uses this as Point of Calibration. Value
|
||||
* will be stored in EEPROM (Adresses see above).
|
||||
*/
|
||||
|
||||
void calibrateVoltageInput(void)
|
||||
{
|
||||
/* Local Variable Declaration */
|
||||
UINT32 adcResult;
|
||||
UINT32 loopcnt;
|
||||
UINT16 VoltageInputCorrection[8];
|
||||
UINT8 spiAdcCommand[3];
|
||||
UINT8 spiAdcResponse[3];
|
||||
|
||||
/* Delete/Reset old Calibration Values */
|
||||
deleteCorrectionValue (VoltageInput);
|
||||
/* Load default Calibration Values from EEPROM */
|
||||
loadCorrectionValue(InputVoltageCorrection, VoltageInput);
|
||||
|
||||
adcModeAll (adcVOLTAGE); /* Set ADC to Mode VOLTAGE */
|
||||
|
||||
loopcnt = 0;
|
||||
|
||||
do /* Do single for every Input */
|
||||
{
|
||||
/* Reset readback Variables */
|
||||
adcResult = 0;
|
||||
spiAdcResponse[0] = 0;
|
||||
spiAdcResponse[1] = 0;
|
||||
spiAdcResponse[2] = 0;
|
||||
|
||||
/* Build SPI Command */
|
||||
spiAdcCommand[0] = 0x06;
|
||||
spiAdcCommand[0] |= (loopcnt >> 2) & 0x01;
|
||||
spiAdcCommand[1] = (loopcnt << 6);
|
||||
spiAdcCommand[2] = 0;
|
||||
|
||||
FIO1CLR = BIT( 25 ); /* Enable Chipselect of ADC */
|
||||
|
||||
spiWriteBuffer( spiAdcCommand, 3 ); /* send Command */
|
||||
spiReadBuffer( spiAdcResponse, 3 ); /* receive Response */
|
||||
|
||||
FIO1SET = BIT( 25 ); /* Disbale Chipselect of ADC */
|
||||
|
||||
/* Build 12 Bit Result out of 8 and 4 Bit readBack */
|
||||
adcResult = (UINT16)(spiAdcResponse[1] & 0x0F) << 8;
|
||||
adcResult |= (UINT16)spiAdcResponse[2];
|
||||
|
||||
|
||||
/* Store result in Array for Voltage Input Correction */
|
||||
VoltageInputCorrection[loopcnt] = adcResult;
|
||||
|
||||
loopcnt++;
|
||||
} while (loopcnt < NumberOfInputChannels);
|
||||
|
||||
|
||||
/* Save Correction Values to EEPROM */
|
||||
saveCorrectionValue(VoltageInputCorrection, VoltageInput);
|
||||
/* Load new Calibration Values from EEPROM */
|
||||
loadCorrectionValue(InputVoltageCorrection, VoltageInput);
|
||||
}
|
||||
|
||||
|
||||
/* Calibration of Analogue Outputs in Voltage Mode:
|
||||
* Attach the Output you want to calibrate to its corresponding Input
|
||||
* (e.g. Output 1 to Input 1). Software will set up In- and Outputs
|
||||
* automatically. The Correction Value will be calculated and stored in
|
||||
* the EEPROM (Adresses see above).
|
||||
*/
|
||||
void calibrateVoltageOutput (void)
|
||||
{
|
||||
UINT16 spiCommand;
|
||||
UINT16 channel = 0;
|
||||
UINT16 value = 0xF80;
|
||||
UINT16 readVoltage;
|
||||
UINT16 VoltageOutputCorrection[4];
|
||||
BOOLEAN leaveloop = FALSE;
|
||||
|
||||
/* Delete/Reset old Calibration Values */
|
||||
deleteCorrectionValue (VoltageOutput);
|
||||
/* Load default Calibration Values from EEPROM */
|
||||
loadCorrectionValue(OutputVoltageCorrection, VoltageOutput);
|
||||
|
||||
|
||||
dacModeAll (dacVOLTAGE); /* Set Output Types to Voltage */
|
||||
adcModeAll (dacVOLTAGE); /* Set Input Types to Voltage */
|
||||
vTaskDelay (100);
|
||||
|
||||
do /* Single for every Channel */
|
||||
{
|
||||
do /* As long as false channel Result */
|
||||
{
|
||||
/* Build and send SPI Command */
|
||||
spiCommand = 0x3000;
|
||||
spiCommand |= ((channel & 0x01) ==
|
||||
0x01 ? DAC_CHANNEL_B : DAC_CHANNEL_A);
|
||||
spiCommand |= (UINT16) value;
|
||||
WriteDacCommand( spiCommand, (channel >> 1));
|
||||
|
||||
vTaskDelay (50);
|
||||
|
||||
readVoltage = adcRead (0, channel);
|
||||
|
||||
/* Is Result exactly 10000?
|
||||
* If so, wait for 1 Second and test again. If no change, Result
|
||||
* is OK and Correction Value is stored. If not, test further
|
||||
*/
|
||||
if (readVoltage == 10000)
|
||||
{
|
||||
vTaskDelay (1000);
|
||||
if ((readVoltage = adcRead (0, channel)) == 10000)
|
||||
{
|
||||
VoltageOutputCorrection[channel] = value;
|
||||
leaveloop = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* If Readback is too:
|
||||
* LOW: increase Output and try again
|
||||
* HIGH: decrease Output and try again
|
||||
*/
|
||||
else if (readVoltage > 10000)
|
||||
{
|
||||
value -= 0x01;
|
||||
}
|
||||
else if (readVoltage < 10000)
|
||||
{
|
||||
value += 0x01;
|
||||
}
|
||||
|
||||
} while (leaveloop == FALSE);
|
||||
|
||||
/* Reset loop Values for next Channel */
|
||||
leaveloop = FALSE;
|
||||
value = 0xF80;
|
||||
channel++;
|
||||
} while (channel < NumberOfOutputChannels);
|
||||
|
||||
/* Save Correction Values to EEPROM */
|
||||
saveCorrectionValue(VoltageOutputCorrection, VoltageOutput);
|
||||
/* Load new Calibration Values from EEPROM */
|
||||
loadCorrectionValue(OutputVoltageCorrection, VoltageOutput);
|
||||
}
|
||||
|
||||
/* Calibration of Analogue Inputs in Current Mode:
|
||||
* Attach Current Supply with Calibration Value (recommended: 20,000 mA) to
|
||||
* the first Input you want to calibrate. Software will read out the real,
|
||||
* digital Value from the ADC and uses this as Point of Calibration. Continue
|
||||
* with the next channel when software prompts to press enter.
|
||||
* Value will be stored in EEPROM (Adresses see above).
|
||||
* NEVER CONNECT MORE THAN ONE CHANNEL TO CURRENT SUPPLY ONCE
|
||||
*/
|
||||
void calibrateCurrentInput (void)
|
||||
{
|
||||
UINT32 channel = 0;
|
||||
UINT16 adcResult;
|
||||
UINT16 CurrentInputCorrection[8];
|
||||
UINT8 buffer;
|
||||
UINT8 spiAdcCommand[3];
|
||||
UINT8 spiAdcResponse[3];
|
||||
BOOLEAN receive;
|
||||
|
||||
/* Delete/Reset old Calibration Values */
|
||||
deleteCorrectionValue (CurrentInput);
|
||||
/* Load default Calibration Values from EEPROM */
|
||||
loadCorrectionValue(InputCurrentCorrection, CurrentInput);
|
||||
|
||||
|
||||
adcModeAll (adcCURRENT); /* Set ADC Mode to CURRENT */
|
||||
vTaskDelay (100);
|
||||
|
||||
|
||||
do /* Single for every Channel */
|
||||
{
|
||||
/* Just for Testing!!! */
|
||||
receive = FALSE;
|
||||
buffer = 0;
|
||||
sendString (SerOutPort, TRUE, importantMessage,
|
||||
"Press ENTER to continue with Channel ", ItoDStr (channel), Dummy);
|
||||
do /* do-while loop for String input */
|
||||
{
|
||||
vTaskDelay (10);
|
||||
receive = serGet(MenuPort, &buffer);
|
||||
} while ((buffer != 13) && (buffer != 32));
|
||||
|
||||
|
||||
/* Reset readback Variables */
|
||||
adcResult = 0x00;
|
||||
spiAdcResponse[0] = 0;
|
||||
spiAdcResponse[1] = 0;
|
||||
spiAdcResponse[2] = 0;
|
||||
|
||||
/* Build SPI Command */
|
||||
spiAdcCommand[0] = 0x06;
|
||||
spiAdcCommand[0] |= (channel >> 2) & 0x01;
|
||||
spiAdcCommand[1] = (channel << 6);
|
||||
spiAdcCommand[2] = 0;
|
||||
|
||||
FIO1CLR = BIT( 25 ); /* ADC chipselect enable */
|
||||
|
||||
spiWriteBuffer( spiAdcCommand, 3 ); /* Send SPI Command */
|
||||
spiReadBuffer( spiAdcResponse, 3 ); /* Receive Response */
|
||||
|
||||
FIO1SET = BIT( 25 ); /* ADC Chipselect disable */
|
||||
|
||||
/* Build 12 Bit Result out of 8 and 4 Bit readBack */
|
||||
adcResult = (UINT16)(spiAdcResponse[1] & 0x0F) << 8;
|
||||
adcResult |= (UINT16)spiAdcResponse[2];
|
||||
|
||||
|
||||
/* Store Value to Array */
|
||||
CurrentInputCorrection[channel] = adcResult;
|
||||
|
||||
channel++; /* Test next Channel */
|
||||
} while (channel < 8);
|
||||
|
||||
/* Save Correction Values to EEPROM */
|
||||
saveCorrectionValue(CurrentInputCorrection, CurrentInput);
|
||||
/* Load new Calibration Values from EEPROM */
|
||||
loadCorrectionValue(InputCurrentCorrection, CurrentInput);
|
||||
}
|
||||
|
||||
/* Connect Analogue Outputs to the corresponding analogue Inputs. Software
|
||||
* will prevent of double-usage of channels.
|
||||
* Values will be stored in EEPROM automatically
|
||||
*/
|
||||
void calibrateCurrentOutput (void)
|
||||
{
|
||||
UINT16 spiCommand;
|
||||
UINT16 channel = 0;
|
||||
UINT16 value = 0xF80;
|
||||
UINT16 readCurrent;
|
||||
UINT16 CurrentOutputCorrection[4];
|
||||
BOOLEAN leaveloop = FALSE;
|
||||
|
||||
/* Delete/Reset old Calibration Values */
|
||||
deleteCorrectionValue (CurrentOutput);
|
||||
/* Load default Calibration Values from EEPROM */
|
||||
loadCorrectionValue(OutputCurrentCorrection, CurrentOutput);
|
||||
|
||||
|
||||
dacModeAll (dacCURRENT); /* Set Output Types to Voltage */
|
||||
|
||||
adcMode(0, adcCURRENT);
|
||||
adcMode(1, adcCURRENT);
|
||||
adcMode(2, adcCURRENT);
|
||||
adcMode(3, adcCURRENT);
|
||||
adcMode(4, adcVOLTAGE);
|
||||
adcMode(5, adcVOLTAGE);
|
||||
adcMode(6, adcVOLTAGE);
|
||||
adcMode(7, adcVOLTAGE);
|
||||
|
||||
vTaskDelay (100);
|
||||
|
||||
do /* Single for every Channel */
|
||||
{
|
||||
do /* As long as false channel Result */
|
||||
{
|
||||
/* Build and send SPI Command */
|
||||
spiCommand = 0x3000;
|
||||
spiCommand |= ((channel & 0x01) ==
|
||||
0x01 ? DAC_CHANNEL_B : DAC_CHANNEL_A);
|
||||
spiCommand |= (UINT16) value;
|
||||
WriteDacCommand( spiCommand, (channel >> 1));
|
||||
|
||||
vTaskDelay (50);
|
||||
|
||||
readCurrent = adcRead (0, channel);
|
||||
|
||||
/* Is Result exactly 20000?
|
||||
* If so, wait for 1 Second and test again. If no change, Result
|
||||
* is OK and Correction Value is stored. If not, test further
|
||||
*/
|
||||
|
||||
if (readCurrent == 20000)
|
||||
{
|
||||
vTaskDelay (1000);
|
||||
if ((readCurrent = adcRead (0, channel)) == 20000)
|
||||
{
|
||||
CurrentOutputCorrection[channel] = value;
|
||||
leaveloop = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* If Readback is too:
|
||||
* LOW: increase Output and try again
|
||||
* HIGH: decrease Output and try again
|
||||
*/
|
||||
else if (readCurrent > 20000)
|
||||
{
|
||||
value -= 0x01;
|
||||
}
|
||||
else if (readCurrent < 20000)
|
||||
{
|
||||
value += 0x01;
|
||||
}
|
||||
|
||||
} while (leaveloop == FALSE);
|
||||
|
||||
/* Reset loop Values for next Channel */
|
||||
leaveloop = FALSE;
|
||||
value = 0xF80;
|
||||
channel++;
|
||||
} while (channel < NumberOfOutputChannels);
|
||||
|
||||
/* Save Correction Values to EEPROM */
|
||||
saveCorrectionValue(CurrentOutputCorrection, CurrentOutput);
|
||||
/* Load new Calibration Values from EEPROM */
|
||||
loadCorrectionValue(OutputCurrentCorrection, CurrentOutput);
|
||||
}
|
||||
|
||||
|
||||
void saveCorrectionValue(pUINT16 CorrectionValueArray,
|
||||
daadCorrection_t correctionType)
|
||||
{
|
||||
UINT32 loopcnt = 0;
|
||||
UINT8 sendBuffer[16];
|
||||
|
||||
switch (correctionType)
|
||||
{
|
||||
case VoltageInput: /* Voltage Input Correction */
|
||||
while (loopcnt < NumberOfInputChannels)
|
||||
{
|
||||
/* Build 8Bit Array out of 16Bit Array */
|
||||
sendBuffer [2*loopcnt] = (CorrectionValueArray[loopcnt]
|
||||
& 0x00FF);
|
||||
sendBuffer [2*loopcnt+1] = ((CorrectionValueArray[loopcnt]
|
||||
& 0xFF00) >> 8);
|
||||
loopcnt++;
|
||||
}
|
||||
/* Send built Array to EEPROM with specific Address and Length */
|
||||
eepromWriteBuffer(VI_Address, sendBuffer, VI_ByteLength);
|
||||
eepromWrite(ident_VoltageInput, ident_calibrated);
|
||||
break;
|
||||
|
||||
case VoltageOutput: /* Voltage Output Correction */
|
||||
while (loopcnt < NumberOfOutputChannels)
|
||||
{
|
||||
sendBuffer [2*loopcnt] = (CorrectionValueArray[loopcnt]
|
||||
& 0x00FF);
|
||||
sendBuffer [2*loopcnt+1] = ((CorrectionValueArray[loopcnt]
|
||||
& 0xFF00) >> 8);
|
||||
loopcnt++;
|
||||
}
|
||||
|
||||
eepromWriteBuffer(VO_Address, sendBuffer, VO_ByteLength);
|
||||
eepromWrite(ident_VoltageOutput, ident_calibrated);
|
||||
break;
|
||||
|
||||
case CurrentInput: /* Current Input Correction */
|
||||
while (loopcnt < NumberOfInputChannels)
|
||||
{
|
||||
sendBuffer [2*loopcnt] = (CorrectionValueArray[loopcnt]
|
||||
& 0x00FF);
|
||||
sendBuffer [2*loopcnt+1] = ((CorrectionValueArray[loopcnt]
|
||||
& 0xFF00) >> 8);
|
||||
loopcnt++;
|
||||
}
|
||||
|
||||
eepromWriteBuffer(CI_Address, sendBuffer, CI_ByteLength);
|
||||
eepromWrite(ident_CurrentInput, ident_calibrated);
|
||||
break;
|
||||
|
||||
case CurrentOutput: /* Current Output Correction */
|
||||
while (loopcnt < NumberOfOutputChannels)
|
||||
{
|
||||
sendBuffer [2*loopcnt] = (CorrectionValueArray[loopcnt]
|
||||
& 0x00FF);
|
||||
sendBuffer [2*loopcnt+1] = ((CorrectionValueArray[loopcnt]
|
||||
& 0xFF00) >> 8);
|
||||
loopcnt++;
|
||||
}
|
||||
|
||||
eepromWriteBuffer(CO_Address, sendBuffer, CO_ByteLength);
|
||||
eepromWrite(ident_CurrentOutput, ident_calibrated);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loadCorrectionValue_defaultTarget (daadCorrection_t correctionType)
|
||||
{
|
||||
UINT32 loopcnt = 0;
|
||||
UINT8 receiveArray[16];
|
||||
|
||||
switch (correctionType)
|
||||
{
|
||||
case VoltageInput: /* Voltage Input Correction */
|
||||
/* Read EEPROM entry on specific Address and Length */
|
||||
eepromReadBuffer(VI_Address, receiveArray, VI_ByteLength);
|
||||
|
||||
/* Build 16 Bit Array out of 8 Bit Array */
|
||||
while (loopcnt < NumberOfInputChannels)
|
||||
{
|
||||
InputVoltageCorrection[loopcnt] = (receiveArray[2*loopcnt]&0xFF)
|
||||
| ((receiveArray[2*loopcnt+1]&0xFF) << 8);
|
||||
loopcnt++;
|
||||
}
|
||||
break;
|
||||
|
||||
case VoltageOutput: /* Voltage Output Correction */
|
||||
eepromReadBuffer(VO_Address, receiveArray, VO_ByteLength);
|
||||
while (loopcnt < NumberOfOutputChannels)
|
||||
{
|
||||
OutputVoltageCorrection[loopcnt] = (receiveArray[2*loopcnt]&0xFF)
|
||||
| ((receiveArray[2*loopcnt+1]&0xFF) << 8);
|
||||
loopcnt++;
|
||||
}
|
||||
break;
|
||||
|
||||
case CurrentInput: /* Current Input Correction */
|
||||
eepromReadBuffer(CI_Address, receiveArray, CI_ByteLength);
|
||||
while (loopcnt < NumberOfInputChannels)
|
||||
{
|
||||
InputCurrentCorrection[loopcnt] = (receiveArray[2*loopcnt]&0xFF)
|
||||
| ((receiveArray[2*loopcnt+1]&0xFF) << 8);
|
||||
loopcnt++;
|
||||
}
|
||||
break;
|
||||
|
||||
case CurrentOutput: /* Current Output Correction */
|
||||
eepromReadBuffer(CO_Address, receiveArray, CO_ByteLength);
|
||||
while (loopcnt < NumberOfOutputChannels)
|
||||
{
|
||||
OutputCurrentCorrection[loopcnt] = (receiveArray[2*loopcnt]&0xFF)
|
||||
| ((receiveArray[2*loopcnt+1]&0xFF) << 8);
|
||||
loopcnt++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loadCorrectionValue(pUINT16 CorrectionValueArray,
|
||||
daadCorrection_t correctionType)
|
||||
{
|
||||
UINT32 loopcnt = 0;
|
||||
UINT8 receiveArray[16];
|
||||
|
||||
switch (correctionType)
|
||||
{
|
||||
case VoltageInput: /* Voltage Input Correction */
|
||||
/* Read EEPROM entry on specific Address and Length */
|
||||
eepromReadBuffer(VI_Address, receiveArray, VI_ByteLength);
|
||||
|
||||
/* Build 16 Bit Array out of 8 Bit Array */
|
||||
while (loopcnt < NumberOfInputChannels)
|
||||
{
|
||||
CorrectionValueArray[loopcnt] = (receiveArray[2*loopcnt]&0xFF)
|
||||
| ((receiveArray[2*loopcnt+1]&0xFF) << 8);
|
||||
loopcnt++;
|
||||
}
|
||||
break;
|
||||
|
||||
case VoltageOutput: /* Voltage Output Correction */
|
||||
eepromReadBuffer(VO_Address, receiveArray, VO_ByteLength);
|
||||
while (loopcnt < NumberOfOutputChannels)
|
||||
{
|
||||
CorrectionValueArray[loopcnt] = (receiveArray[2*loopcnt]&0xFF)
|
||||
| ((receiveArray[2*loopcnt+1]&0xFF) << 8);
|
||||
loopcnt++;
|
||||
}
|
||||
break;
|
||||
|
||||
case CurrentInput: /* Current Input Correction */
|
||||
eepromReadBuffer(CI_Address, receiveArray, CI_ByteLength);
|
||||
while (loopcnt < NumberOfInputChannels)
|
||||
{
|
||||
CorrectionValueArray[loopcnt] = (receiveArray[2*loopcnt]&0xFF)
|
||||
| ((receiveArray[2*loopcnt+1]&0xFF) << 8);
|
||||
loopcnt++;
|
||||
}
|
||||
break;
|
||||
|
||||
case CurrentOutput: /* Current Output Correction */
|
||||
eepromReadBuffer(CO_Address, receiveArray, CO_ByteLength);
|
||||
while (loopcnt < NumberOfOutputChannels)
|
||||
{
|
||||
CorrectionValueArray[loopcnt] = (receiveArray[2*loopcnt]&0xFF)
|
||||
| ((receiveArray[2*loopcnt+1]&0xFF) << 8);
|
||||
loopcnt++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void deleteCorrectionValue (daadCorrection_t correctionType)
|
||||
{
|
||||
UINT32 loopcnt;
|
||||
UINT8 emptyBuffer[16];
|
||||
|
||||
/* Build NULL-Array */
|
||||
for (loopcnt = 0; loopcnt < NumberOfInputChannels; loopcnt++)
|
||||
{
|
||||
emptyBuffer[2*loopcnt] = 0xFF;
|
||||
emptyBuffer[2*loopcnt+1] = 0x0F;
|
||||
}
|
||||
|
||||
switch (correctionType)
|
||||
{
|
||||
case VoltageInput:
|
||||
eepromWriteBuffer (VI_Address, emptyBuffer, VI_ByteLength);
|
||||
eepromWrite(ident_VoltageInput, ident_default);
|
||||
break;
|
||||
case VoltageOutput:
|
||||
eepromWriteBuffer (VO_Address, emptyBuffer, VO_ByteLength);
|
||||
eepromWrite(ident_VoltageOutput, ident_default);
|
||||
break;
|
||||
case CurrentInput:
|
||||
eepromWriteBuffer (CI_Address, emptyBuffer, CI_ByteLength);
|
||||
eepromWrite(ident_CurrentInput, ident_default);
|
||||
break;
|
||||
case CurrentOutput:
|
||||
eepromWriteBuffer (CO_Address, emptyBuffer, CO_ByteLength);
|
||||
eepromWrite(ident_CurrentOutput, ident_default);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* calibrateaio.h (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: Digital inputs/outputs interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Mei 22, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef CALIBRATEAIO_H_
|
||||
#define CALIBRATEAIO_H_
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define ident_calibrated 0x55
|
||||
#define ident_default 0xAA
|
||||
|
||||
#define maxCAL_types (4)
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef enum _daadCorrection_t
|
||||
{
|
||||
VoltageInput = 0,
|
||||
VoltageOutput = 1,
|
||||
CurrentInput = 2,
|
||||
CurrentOutput = 3
|
||||
|
||||
} daadCorrection_t;
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: killStats
|
||||
*
|
||||
* Function deletes all calibration Stats in EEPROM
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void killStats (void);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: defaultStats
|
||||
*
|
||||
* Function resets all calibration Stats in EEPROM to default
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void defaultStats (void);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: calibratedStats
|
||||
*
|
||||
* Function sets all calibration stats in EEPROM to "CALIBRATED"
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void calibratedStats (void);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: calibrationInit
|
||||
*
|
||||
* Initialisation of Calibration status.
|
||||
* Function should be called in bootup sequence. It reads all four calibration
|
||||
* Stats from the EEPROM. If a Stat is neither set to DEFAULT nor to
|
||||
* CALIBRATED, the INIT-Function will automatically reset the corresponding
|
||||
* Calibration Values in EEPROM to DEFAULT (0x0FFF).
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void calibrationInit (void);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: returnCalibrationStatus
|
||||
*
|
||||
* Function sets all calibration stats in EEPROM to "CALIBRATED"
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
UINT8 returnCalibrationStatus (daadCorrection_t correctionType);
|
||||
UINT8 showLocalCalibrationStatus (INT32 correctionType);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: calibrateVoltageInput
|
||||
*
|
||||
* function to calibrate the Voltage Input.
|
||||
* Appliance hints: see Function in calibrateaio.c
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void calibrateVoltageInput (void);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: calibrateVoltageOutput
|
||||
*
|
||||
* function to calibrate the Voltage Output.
|
||||
* Appliance hints: see Function in calibrateaio.c
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void calibrateVoltageOutput (void);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: calibrateCurrentInput
|
||||
*
|
||||
* function to calibrate the Current Input.
|
||||
* Appliance hints: see Function in calibrateaio.c
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void calibrateCurrentInput (void);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: calibrateCurrentOutput
|
||||
*
|
||||
* function to calibrate the Current Output.
|
||||
* Appliance hints: see Function in calibrateaio.c
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void calibrateCurrentOutput (void);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: saveCorrectionValue
|
||||
*
|
||||
* Function to save Corection Values to the EEPROM. The Storage Addresses are
|
||||
* mentioned in calibrateaio.c (Makro definitions). Storage Addresses and
|
||||
* Lengths depend on the type of Correction Values (given in correctionType).
|
||||
*
|
||||
* Parameters: pUINT16 CorrectionValueArray - Pointer to Value Array
|
||||
* daadCorrection_t correctionType - Type of Calibration
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void saveCorrectionValue (pUINT16 CorrectionValueArray,
|
||||
daadCorrection_t correctionType);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: loadCorrectionValue_defaultTarget / loadCorrectionValue
|
||||
*
|
||||
* Function to load Corection Values from EEPROM into the temporary work
|
||||
* Array.
|
||||
* The Read Addresses are mentioned in calibrateaio.c (Makro definitions).
|
||||
* Read Addresses and Lengths depend on the type of Correction Values (given
|
||||
* in correctionType).
|
||||
* loadCorrectionValue_defaultTarget will load the Values to the default
|
||||
* Target Arrays, which are defined in adc.c and dac.c
|
||||
*
|
||||
* Parameters: pUINT16 CorrectionValueArray - Pointer to Value Array
|
||||
* daadCorrection_t correctionType - Type of Calibration
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void loadCorrectionValue_defaultTarget (daadCorrection_t correctionType);
|
||||
void loadCorrectionValue(pUINT16 CorrectionValueArray,
|
||||
daadCorrection_t correctionType);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: deleteCorrectionValue
|
||||
*
|
||||
* Function to delete the previous Calibration Values in EEPROM on the
|
||||
* Address and Length depending on the Type (given in correctionType).
|
||||
* Because the adc/dac Drivers multiplicate with the correction Values, they
|
||||
* are not written to Zero but to 0xFFF, which results then in a
|
||||
* calculation with 1.
|
||||
* This function only overwrites the Values in EEPROM. The default Values then
|
||||
* must be loaded with loadCorrectionValue().
|
||||
*
|
||||
* Parameters: daadCorrection_t correctionType - Type of Calibration Values
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void deleteCorrectionValue (daadCorrection_t correctionType);
|
||||
|
||||
|
||||
|
||||
#endif /*CALIBRATEAIO_H_*/
|
||||
@@ -0,0 +1,460 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* can.c (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Feb 11, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* Hardware Includes */
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "Task.h"
|
||||
#include "queue.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "can.h"
|
||||
#include "SerOut.h"
|
||||
#include "armVIC.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define CAN_PORT 2
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
static UINT32 debugVar = 0;
|
||||
static UINT32 debugCnt = 0;
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
UINT16 volatile gCANFilter = 0; /* Number of global set filters */
|
||||
|
||||
CAN_MSG volatile gCANList[MAX_FILTERS]; /* CAN message list */
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
UINT16 CANInit (UINT32 can_btr)
|
||||
{
|
||||
|
||||
PCONP |= (1 << 14); /* power on CAN2 */
|
||||
|
||||
|
||||
/* Enable Pins for CAN interface */
|
||||
/* Set P0.4 to function 10 (RD2) */
|
||||
PINSEL0 &=~(1 << 8); /* Clear Bit 8 in PINSEL0 */
|
||||
PINSEL0 |= (1 << 9); /* set bit 9 in PINSEL0 */
|
||||
/* Set P0.5 to function 10 (TD2) */
|
||||
PINSEL0 &=~(1 << 10); /* Clear bit 10 in PINSEL0 */
|
||||
PINSEL0 |= (1 << 11); /* Set bit 11 in PINSEL0 */
|
||||
|
||||
gCANFilter = 0; /* Reset previous Filters */
|
||||
// CAN_AFMR = 0x00000001L; /* Switch off Aceptance Filter */
|
||||
|
||||
CAN2MOD = 0x00000001; /* Set Mode to Reset (Bit 0) */
|
||||
CAN2IER = 0x00000000; /* Disable all CAN2 Interrupts */
|
||||
CAN2GSR = 0x00000000; /* Clear all status bits */
|
||||
CAN2BTR = can_btr; /* Set bus timing */
|
||||
|
||||
/* Set Address of CAN ISR to Vectored Interrupt Address 23 */
|
||||
VICVectAddr23 = (unsigned long) CAN_IRS_Handler;
|
||||
VICVectCntl23 = 1; /* Set a low interrupt priority */
|
||||
VICIntEnable |= (1 << 23); /* Enable CAN interrupt */
|
||||
|
||||
// CAN2IER = 0x00000081; /* Enable all RX and Err IRQs */
|
||||
CAN2IER = 0x00000001; /* Enable all RX IRQs */
|
||||
CAN2MOD = 0x00000000; /* Set Mode to Normal (Bit 0) */
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
UINT16 CANSetFilter (UINT32 CANID)
|
||||
{
|
||||
UINT32 loopcnt = 0;
|
||||
UINT32 regbuffer = 0;
|
||||
UINT32 buf0;
|
||||
UINT32 buf1;
|
||||
UINT32 ID_lower;
|
||||
UINT32 ID_upper;
|
||||
UINT32 *pAddr;
|
||||
|
||||
CAN_AFMR = 0x00000001L; /* Switch off Acceptance filter */
|
||||
|
||||
if (gCANFilter == 0)
|
||||
{
|
||||
/* First filter set - Init Entry of position Zero */
|
||||
/* Make first array entry for CAN device 1
|
||||
* This is necessary due to the following sort algorithm
|
||||
*/
|
||||
gCANList[0].Dat1 = 0x000037FFL;
|
||||
}
|
||||
|
||||
if (gCANFilter >= MAX_FILTERS)
|
||||
{
|
||||
/* If Array index exceeds the limit, return with error */
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
CANID &= 0x000007FFL; /* Mask the 11-bit ID */
|
||||
CANID |= ((CAN_PORT - 1) << 13); /* Add PORT# to ID */
|
||||
|
||||
/* Filters must be sorted by interface, then by priority */
|
||||
|
||||
/* Algorithm to sort new entry into excisting array */
|
||||
while (loopcnt < gCANFilter) /* Look through all entries */
|
||||
{
|
||||
if ((gCANList[loopcnt].Dat1 & 0x0000FFFFL)> CANID)
|
||||
{
|
||||
/* Found position to insert new entry */
|
||||
break;
|
||||
}
|
||||
loopcnt++;
|
||||
}
|
||||
|
||||
buf0 = gCANList[loopcnt].Dat1; /* Buffer old array entry */
|
||||
gCANList[loopcnt].Dat1 = CANID; /* Insert the new entry */
|
||||
|
||||
/* move all remaining entries one position up */
|
||||
gCANFilter++; /* Increase Filter counter */
|
||||
while (loopcnt < gCANFilter)
|
||||
{
|
||||
loopcnt++;
|
||||
buf1 = gCANList[loopcnt].Dat1;
|
||||
gCANList[loopcnt].Dat1 = buf0;
|
||||
buf0 = buf1;
|
||||
}
|
||||
|
||||
|
||||
CAN_SFF_SA = regbuffer; /* Set Std Frame Start Address */
|
||||
/* Set pointer to the Filter RAM base Address */
|
||||
pAddr = ( UINT32 *) ACCEPTANCE_FILTER_RAM_BASE;
|
||||
|
||||
for (loopcnt = 0; loopcnt < ((gCANFilter + 1) / 2); loopcnt++)
|
||||
{
|
||||
ID_lower = gCANList[loopcnt * 2].Dat1 & 0x0000FFFFL;
|
||||
ID_upper = gCANList[loopcnt * 2 + 1].Dat1 & 0x0000FFFFL;
|
||||
// candata = (ID_lower << 16) + ID_upper; // \TODO IS THIS WORKING?
|
||||
// *pAddr = candata;
|
||||
*pAddr = (ID_lower << 16) + ID_upper;
|
||||
regbuffer += 4;
|
||||
pAddr++;
|
||||
}
|
||||
|
||||
/* regbuffer points to the End of the Table */
|
||||
|
||||
CAN_SFF_GRP_SA = regbuffer; /* Set Std Group Start Address */
|
||||
|
||||
// Set pointer for Extended Frame Individual
|
||||
// Extended Frame Start Address Register
|
||||
CAN_EFF_SA = regbuffer; /* Set Extd. Frame Start Address*/
|
||||
|
||||
CAN_EFF_GRP_SA = regbuffer; /* Set Extd. Group Start Address*/
|
||||
|
||||
CAN_EOT = regbuffer; /* Set End of Table */
|
||||
|
||||
CAN_AFMR = 0; /* enable Acception Filter */
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
UINT16 CANPushMessage (CAN_MSG *pTransmitBuf)
|
||||
{
|
||||
UINT32 *pAddr;
|
||||
UINT32 *pCandata;
|
||||
UINT8 TXBufOffset;
|
||||
|
||||
pAddr = (UINT32 *) &CAN2SR; // CANSR
|
||||
|
||||
/* Check if one of the three transmit buffers are available, use first */
|
||||
if (!(*pAddr & 0x00000004L))
|
||||
{
|
||||
/* First Buffer is not available */
|
||||
if (!(*pAddr & 0x00000400L))
|
||||
{
|
||||
/* Second Buffer is not available */
|
||||
if (!(*pAddr & 0x00040000L))
|
||||
{
|
||||
/* Third Buffer is not available -> No Buffer available */
|
||||
return (FALSE); /* Abort transmission, Error */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Third Buffer is available, set Buffer offset */
|
||||
TXBufOffset = 0x08;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Second Buffer is available, set Buffer offset */
|
||||
TXBufOffset = 0x04;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* First Buffer is available, set Buffer offset */
|
||||
TXBufOffset = 0x00;
|
||||
}
|
||||
|
||||
/* Write Data to Transmit Frame Information Register */
|
||||
pAddr = (UINT32 *) &CAN2TFI1 + TXBufOffset; /* Set pointer to CAN2TFIx */ // \TODO WATCH HERE (had offset)!!!
|
||||
*pAddr = (pTransmitBuf->Dat1 & 0x000F0000L);
|
||||
|
||||
/* Write CAN ID to Transmit Identifier Register */
|
||||
pAddr++; /* Increase pointer to CAN2TIDx */
|
||||
*pAddr = pTransmitBuf->Dat1 & 0x000007FFL;
|
||||
|
||||
/* Write first four Bytes to Transmit Data Register A */
|
||||
pCandata = (UINT32 *) &(pTransmitBuf->DatA); /* Get first 4 bytes */
|
||||
pAddr++; /* Set pointer to DataA register*/
|
||||
*pAddr = *pCandata; /* Write first 4 bytes to DataA */
|
||||
|
||||
/* Write second four Bytes to Transmit Data Register B */
|
||||
pCandata++; /* Get second four bytes */
|
||||
pAddr++; /* Point to DataB register */
|
||||
*pAddr = *pCandata; /* Write second 4 Bytes to DataB*/
|
||||
|
||||
|
||||
/* Write Transmission Request to CAN2 Command Register
|
||||
* This Action is depending on the chosen transmission buffer (1-3)
|
||||
* Two bits must be written - Bit (0): (TR) Transmission Request
|
||||
* Bit (5|6|7): (STBx) Select Buffer (1|2|3)
|
||||
*/
|
||||
if (TXBufOffset == 0x00)
|
||||
{
|
||||
/* First buffer was chosen. Write TR and STB1 */
|
||||
CAN2CMR = 0x21;
|
||||
}
|
||||
else if (TXBufOffset == 0x04)
|
||||
{
|
||||
/* Second buffer was chosen. Write TR and STB2 */
|
||||
CAN2CMR = 0x41;
|
||||
}
|
||||
else if (TXBufOffset == 0x08)
|
||||
{
|
||||
/* Third buffer was chosen. Write TR and STB3 */
|
||||
CAN2CMR = 0x81;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No Buffer was chosen, return with error (should not come here) */
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
UINT16 CANPullMessage (CAN_MSG *pReceiveBuf)
|
||||
{
|
||||
UINT32 loopcnt = 0;
|
||||
UINT32 *pSrc;
|
||||
UINT32 *pDst;
|
||||
UINT32 match;
|
||||
|
||||
|
||||
/* Initialise Source and Destination Pointer */
|
||||
pSrc = (UINT32 *) &(gCANList[0].Dat1);
|
||||
pDst = (UINT32 *) &(pReceiveBuf->Dat1);
|
||||
|
||||
/* Prepare match value for CAN interface */
|
||||
match = CAN_PORT << 13;
|
||||
match |= 0x03000000L; /* Semaphore bits are 11b */
|
||||
|
||||
while (loopcnt < gCANFilter)
|
||||
{
|
||||
/* Scan for every set Filter */
|
||||
if ((*pSrc & 0x0300E000L) == match)
|
||||
{
|
||||
/* A new Message is detected in Source Array */
|
||||
*pSrc &= 0xFCFFFFFFL; /* clear Semaphore */
|
||||
|
||||
*pDst = *pSrc; /* Copy Dat1 from SRC to DST */
|
||||
|
||||
pSrc++; /* Set SRC-Pointer to SRC.DataA */
|
||||
pDst++; /* Set DST-Pointer to DST.DataA */
|
||||
|
||||
*pDst = *pSrc; /* Copy DatA from SRC to DST */
|
||||
|
||||
pSrc++; /* Set SRC-Pointer to SRC.DataB */
|
||||
pDst++; /* Set DST-Pointer to DST.DataB */
|
||||
|
||||
*pDst = *pSrc; /* Copy DatB from SRC to DST */
|
||||
|
||||
pSrc -= 2; // Reset SRC-Pointer to Dat1 */
|
||||
pDst -= 2; // Reset DST-Pointer to Dat1 */
|
||||
|
||||
if ((*pSrc & 0x03000000L) == 0)
|
||||
{
|
||||
/* If actual SRC was updated while reading, return to caller
|
||||
* This is to prevent of ignoring the message that came in while
|
||||
* reading, which would not be noticed if the message counter
|
||||
* will be increased like the loop will do in the next step
|
||||
*/
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
loopcnt++; /* Go to next Message in Buffer */
|
||||
pSrc += 3; /* Increase SRC-Pointer to next */
|
||||
}
|
||||
return (FALSE); /* Return False if no Message in*/
|
||||
}
|
||||
|
||||
|
||||
void CAN_IRS_Handler()
|
||||
{
|
||||
UINT32 CANStatus;
|
||||
|
||||
ISR_ENTRY();
|
||||
CANStatus = CAN_RX_SR;
|
||||
if (CANStatus & (1 << 8))
|
||||
{
|
||||
/* A received Message is available in CAN1 controller */
|
||||
CAN_CANISR_Rx1();
|
||||
}
|
||||
if (CANStatus & (1 << 9))
|
||||
{
|
||||
/* A received Message is available in CAN2 controller */
|
||||
CAN_CANISR_Rx2();
|
||||
}
|
||||
|
||||
/* Error Interrupts are currently disabled due to purpose of CAN driver */
|
||||
if (CAN_MSR & (1 << 1))
|
||||
{
|
||||
/* At least one Error-Counter of CAN2 has reached the limit */
|
||||
CAN_CANISR_Err();
|
||||
}
|
||||
if (CAN1GSR & (1 << 6 ))
|
||||
{
|
||||
/* The error count includes both TX and RX */
|
||||
}
|
||||
if (CAN2GSR & (1 << 6 ))
|
||||
{
|
||||
/* The error count includes both TX and RX */
|
||||
}
|
||||
if (CAN2ICR & (1 << 7))
|
||||
{
|
||||
/* Error-on-Bus Interrupt detected */
|
||||
CAN_ERRORBUS();
|
||||
}
|
||||
|
||||
VICVectAddr = 0; /* Acknowledge Interrupt */
|
||||
|
||||
ISR_EXIT();
|
||||
}
|
||||
|
||||
|
||||
void CAN_CANISR_Rx1 (void)
|
||||
{
|
||||
UINT32 buf;
|
||||
UINT32 *pDest;
|
||||
|
||||
if (!(CAN1RFS & 0xC0000400L))
|
||||
{ // 11-bit ID, no RTR, matched a filter
|
||||
|
||||
// initialize destination pointer
|
||||
// filter number is in lower 10 bits of C1RFS
|
||||
pDest = (UINT32 *) &(gCANList[(CAN1RFS & 0x000003FFL)].Dat1);
|
||||
|
||||
// calculate contents for first entry into CAN list
|
||||
buf = CAN1RFS & 0xC00F0000L; // mask FF, RTR and DLC
|
||||
buf |= 0x01002000L; // set semaphore to 01b and CAN port to 1
|
||||
buf |= CAN1RID & 0x000007FFL; // get CAN message ID
|
||||
|
||||
// now copy entire message to CAN list
|
||||
*pDest = buf;
|
||||
pDest++; // set to gCANList[(C1RFS & 0x000003FFL)].DatA
|
||||
*pDest = CAN1RDA;
|
||||
pDest++; // set to gCANList[(C1RFS & 0x000003FFL)].DatB
|
||||
*pDest = CAN1RDB;
|
||||
|
||||
// now set the sempahore to complete
|
||||
buf |= 0x03000000L; // set semaphore to 11b
|
||||
pDest -= 2; // set to gCANList[(C1RFS & 0x000003FFL)].Dat1
|
||||
*pDest = buf;
|
||||
}
|
||||
|
||||
CAN1CMR = 0x04; // release receive buffer
|
||||
}
|
||||
|
||||
|
||||
void CAN_CANISR_Rx2(void)
|
||||
{
|
||||
UINT32 buf;
|
||||
UINT32 *pDest;
|
||||
|
||||
debugVar = 0x00000001;
|
||||
|
||||
if (!(CAN2RFS & 0xC0000400L))
|
||||
{
|
||||
/* 11-bit ID, no RTR */
|
||||
debugVar = 0x00000011;
|
||||
/* initialize Destination Pointer */
|
||||
/* Filter Nmber is in bit 0-9 of CAN2RFS */
|
||||
pDest = (UINT32 *) &(gCANList[(CAN2RFS & 0x000003FFL)].Dat1);
|
||||
// pDest = (UINT32 *) &(gCANList[(1)].Dat1);
|
||||
|
||||
/* Calculate contents for first entry into CAN list */
|
||||
buf = CAN2RFS & 0xC00F0000L; /* Mask FF, RTR and DLC */
|
||||
buf |= 0x01004000L; /* set sema to 01b and port to 2*/
|
||||
buf |= CAN2RID & 0x000007FFL; /* get CAN message ID */
|
||||
|
||||
/* Copy entire message to CAN list */
|
||||
*pDest = buf; /* Copy Dat1 to DST */
|
||||
pDest++; /* Set Pointer to DataA */
|
||||
*pDest = CAN2RDA; /* copy DataA */
|
||||
pDest++; /* Set Pointer to DataB */
|
||||
*pDest = CAN2RDB; /* Copy DataB */
|
||||
|
||||
|
||||
buf |= 0x03000000L; /* semaphore to 11b (complete) */
|
||||
pDest -= 2; /* Set back to Dat1 */
|
||||
*pDest = buf; /* update semaphore in DST */
|
||||
}
|
||||
|
||||
debugCnt++;
|
||||
CAN2CMR = 0x04; /* Release Receive Buffer */
|
||||
}
|
||||
|
||||
|
||||
void CAN_CANISR_Err (void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CAN_ERRORBUS (void)
|
||||
{
|
||||
volatile UINT32 regRead;
|
||||
|
||||
regRead = CAN2ICR;
|
||||
|
||||
debugPrint("released");
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* can.h (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Feb 11, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef CAN_H_
|
||||
#define CAN_H_
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* Hardware Includes */
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Maximum number of total FullCAN Filters for ALL CAN interfaces
|
||||
#define MAX_FILTERS 20
|
||||
|
||||
// Define CAN SFR address bases
|
||||
#define CAN_REG_BASE (0xE0000000)
|
||||
#define ACCEPTANCE_FILTER_RAM_BASE (CAN_REG_BASE + 0x00038000)
|
||||
#define ACCEPTANCE_FILTER_REGISTER_BASE (CAN_REG_BASE + 0x0003C000)
|
||||
#define CENTRAL_CAN_REGISTER_BASE (CAN_REG_BASE + 0x00040000)
|
||||
|
||||
// Common CAN bit rates
|
||||
#define CANBitrate50_12MHz 0x001C000E
|
||||
#define CANBitrate125k_12MHz 0x001C0005
|
||||
#define CANBitrate250k_12MHz 0x001C0002
|
||||
|
||||
// CAN Interrupt Service Routines
|
||||
void CAN_IRS_Handler (void) __attribute__ ((naked, interrupt("IRQ")));
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
// Type definition to hold a FullCAN message
|
||||
// Compatible to FullCAN Mode Stored Messages in LPC User Manual
|
||||
typedef struct
|
||||
{
|
||||
UINT32 Dat1; // Bits 0..10: CAN Message ID
|
||||
// Bits 13..15: CAN interface number (1..4)
|
||||
// Bits 16..19: DLC - Data Length Counter
|
||||
// Bits 24..25: Semaphore bits
|
||||
UINT32 DatA; // CAN Message Data Bytes 0-3
|
||||
UINT32 DatB; // CAN Message Data Bytes 4-7
|
||||
} CAN_MSG;
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
UINT16 CANInit (
|
||||
UINT32 can_btr /* CAN Baud Rate setting */
|
||||
);
|
||||
|
||||
|
||||
UINT16 CANSetFilter
|
||||
(
|
||||
UINT32 CANID // 11-bit CAN message identifier
|
||||
);
|
||||
|
||||
|
||||
|
||||
UINT16 CANPushMessage (
|
||||
CAN_MSG *pTransmitBuf // Source pointer to a CAN message
|
||||
);
|
||||
|
||||
|
||||
UINT16 CANPullMessage (
|
||||
CAN_MSG *pReceiveBuf // Destination pointer to a CAN message
|
||||
);
|
||||
|
||||
|
||||
void CAN_CANISR_Rx1 (void);
|
||||
void CAN_CANISR_Rx2 (void);
|
||||
void CAN_CANISR_Err (void);
|
||||
void CAN_ERRORBUS (void);
|
||||
|
||||
|
||||
|
||||
#endif /*CAN_H_*/
|
||||
@@ -0,0 +1,416 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* dac.c - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: ADC-driver
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 28-11-2007, fvds.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "dac.h"
|
||||
#include "sys_config.h"
|
||||
#include "ssp0.h"
|
||||
#include "dio.h"
|
||||
#include "calibrateaio.h"
|
||||
#include "ElecStatusCache.h"
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define DAC_CS_DIR_REG FIO1DIR
|
||||
#define DAC_CS_SET_REG FIO1SET
|
||||
#define DAC_CS_CLR_REG FIO1CLR
|
||||
#define DAC1_CS_BIT BIT( 21 )
|
||||
#define DAC2_CS_BIT BIT( 22 )
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define DAC3_CS_BIT BIT( 19)
|
||||
#endif
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define DACS_CS_BITS (DAC1_CS_BIT | DAC2_CS_BIT | DAC3_CS_BIT)
|
||||
#else
|
||||
#define DACS_CS_BITS (DAC1_CS_BIT | DAC2_CS_BIT)
|
||||
#endif
|
||||
|
||||
#define DAC1_CS_DISABLE (DAC_CS_SET_REG = DAC1_CS_BIT)
|
||||
#define DAC1_CS_ENABLE (DAC_CS_CLR_REG = DAC1_CS_BIT)
|
||||
#define DAC2_CS_DISABLE (DAC_CS_SET_REG = DAC2_CS_BIT)
|
||||
#define DAC2_CS_ENABLE (DAC_CS_CLR_REG = DAC2_CS_BIT)
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define DAC3_CS_DISABLE (DAC_CS_SET_REG = DAC3_CS_BIT)
|
||||
#define DAC3_CS_ENABLE (DAC_CS_CLR_REG = DAC3_CS_BIT)
|
||||
#endif
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define DAC_CV_DIR_REG FIO4DIR
|
||||
#define DAC_CV_SET_REG FIO4SET
|
||||
#define DAC_CV_CLR_REG FIO4CLR
|
||||
#else
|
||||
#define DAC_CV_DIR_REG FIO3DIR
|
||||
#define DAC_CV_SET_REG FIO3SET
|
||||
#define DAC_CV_CLR_REG FIO3CLR
|
||||
#endif
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define CURRENT_VOLTAGE_BITS (0x0000003F)
|
||||
#else
|
||||
#define CURRENT_VOLTAGE_BITS (0x07800000)
|
||||
#endif
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define DAC_MUX_DIR FIO3DIR
|
||||
#define DAC_MUX_SET FIO3SET
|
||||
#define DAC_MUX_CLR FIO3CLR
|
||||
|
||||
#define DAC_MUX_BIT BIT(24)
|
||||
#define DAC_MUX_EN (DAC_MUX_SET = DAC_MUX_BIT)
|
||||
#define DAC_MUX_DS (DAC_MUX_CLR = DAC_MUX_BIT)
|
||||
#endif
|
||||
|
||||
#define spiWrite ssp0Write
|
||||
#define spiRead ssp0Read
|
||||
#define spiWriteBuffer ssp0WriteBuffer
|
||||
#define spiReadBuffer ssp0ReadBuffer
|
||||
#define spiTakeBus ssp0TakeBus
|
||||
#define spiReleaseBus ssp0ReleaseBus
|
||||
|
||||
|
||||
#define DAC_CHANNEL_A (0x8000)
|
||||
#define DAC_CHANNEL_B (0x0000)
|
||||
|
||||
#define DAC_OUTPUT_BUFFERED (0x4000)
|
||||
#define DAC_OUTPUT_UNBUFFERED (0x0000)
|
||||
#define DAC_OUTPUT_GAIN_1x (0x2000)
|
||||
#define DAC_OUTPUT_GAIN_2x (0x0000)
|
||||
#define DAC_SHDN_OPDC (0x1000)
|
||||
#define DAC_SHDN_DISABLED (0x0000)
|
||||
#define DAC_MAX_SETTING (4095)
|
||||
#define DAC_MAX_CURRENT (20000)
|
||||
#define DAC_MAX_VOLTAGE (10000)
|
||||
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
UINT16 OutputVoltageCorrection[maxDAC_Channels];
|
||||
UINT16 OutputCurrentCorrection[maxDAC_Channels];
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
t_dac_mode channelModes[maxDAC_Channels] =
|
||||
{
|
||||
dacCURRENT,
|
||||
dacCURRENT,
|
||||
dacCURRENT,
|
||||
dacCURRENT,
|
||||
dacCURRENT,
|
||||
dacCURRENT
|
||||
};
|
||||
|
||||
UINT16 channelSetting[maxDAC_Channels] =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
#else
|
||||
t_dac_mode channelModes[maxDAC_Channels] =
|
||||
{
|
||||
dacCURRENT,
|
||||
dacCURRENT,
|
||||
dacCURRENT,
|
||||
dacCURRENT
|
||||
};
|
||||
|
||||
UINT16 channelSetting[maxDAC_Channels] =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
void dacInit (void)
|
||||
{
|
||||
DAC_CV_DIR_REG |= CURRENT_VOLTAGE_BITS;
|
||||
DAC_CV_CLR_REG = CURRENT_VOLTAGE_BITS; // Default all bits to current
|
||||
DAC_CS_DIR_REG |= DACS_CS_BITS;
|
||||
DAC1_CS_DISABLE;
|
||||
DAC2_CS_DISABLE;
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
DAC3_CS_DISABLE;
|
||||
DAC_MUX_DIR |= DAC_MUX_BIT;
|
||||
#endif
|
||||
|
||||
loadCorrectionValue(OutputVoltageCorrection, VoltageOutput);
|
||||
loadCorrectionValue(OutputCurrentCorrection, CurrentOutput);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void dac_MuxEn (BOOLEAN mode)
|
||||
{
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
if (mode == TRUE)
|
||||
{
|
||||
DAC_MUX_EN; /* Set MUX to ExtensionBoard */
|
||||
}
|
||||
else
|
||||
{
|
||||
DAC_MUX_DS; /* Set MUX to MainBoard */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOLEAN dac_MuxRB (void)
|
||||
{
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
if (DAC_MUX_SET & DAC_MUX_BIT)
|
||||
{
|
||||
/* Mux is switched to ExtensionBoard */
|
||||
return (TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Mux is switched to MainBoard */
|
||||
return (FALSE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** \brief Select output mode (Voltage or Current) of a certain channel. */
|
||||
void dacMode (
|
||||
UINT8 channel, /*< 0..5 = valid */
|
||||
t_dac_mode mode
|
||||
)
|
||||
{
|
||||
UINT32 channelMask;
|
||||
|
||||
if (channel >= maxDAC_Channels ) return; // Channel doesn't exist
|
||||
|
||||
channelModes[channel] = mode;
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
channelMask = BIT( (UINT32)(channel) ); /* channel bit + offset */
|
||||
#else
|
||||
channelMask = BIT( (UINT32)(channel + 23) ); /* channel bit + offset */
|
||||
#endif
|
||||
if (mode == dacVOLTAGE)
|
||||
{
|
||||
DAC_CV_SET_REG = channelMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
DAC_CV_CLR_REG = channelMask;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** \brief Write analog value in mV or uA depending on dacMode */
|
||||
void dacWrite(
|
||||
UINT8 device, /**< 0 = Self, valid */
|
||||
UINT8 channel, /**< 0..5 = valid */
|
||||
UINT16 value /*< VOLTAGE: 0..10000[mV], CURRENT: 0..20000[uA] */
|
||||
)
|
||||
{
|
||||
UINT16 spiCommand;
|
||||
UINT32 dacSetting;
|
||||
UINT32 divideValue;
|
||||
|
||||
if (device == 0)
|
||||
{
|
||||
|
||||
if (channel >= maxDAC_Channels ) return; // Channel doesn't exist
|
||||
|
||||
channelSetting[ channel] = value;
|
||||
|
||||
// Assemble DAC command
|
||||
spiCommand = DAC_OUTPUT_UNBUFFERED | DAC_OUTPUT_GAIN_1x | DAC_SHDN_OPDC;
|
||||
spiCommand |= ( (channel & 0x01) == 0x01 ? DAC_CHANNEL_B : DAC_CHANNEL_A);
|
||||
divideValue = (channelModes[channel] == dacVOLTAGE ? DAC_MAX_VOLTAGE : DAC_MAX_CURRENT);
|
||||
|
||||
// dacSetting = ((UINT32)value * DAC_MAX_SETTING) / divideValue;
|
||||
|
||||
if (channelModes[channel] == dacVOLTAGE)
|
||||
{
|
||||
dacSetting = (UINT32)value * OutputVoltageCorrection[channel] / divideValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
dacSetting = (UINT32)value * OutputCurrentCorrection[channel] / divideValue;
|
||||
}
|
||||
|
||||
if (dacSetting > DAC_MAX_SETTING) return;
|
||||
|
||||
spiCommand |= (UINT16) dacSetting;
|
||||
|
||||
/* devide channel by 2 on send the SPI command with WriteDacCommand
|
||||
* channel 0-1: dac0
|
||||
* channel 2-3: dac1
|
||||
* channel 4-5: dac2 */
|
||||
WriteDacCommand( spiCommand, (channel >> 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
bpecWriteDacValue(device, channel, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UINT16 dacReadBack (
|
||||
UINT8 device, /**< 0 = Self, 1..32 = Remote device */
|
||||
UINT8 channel /**< 0..3 = valid, 8..255 = future use */
|
||||
)
|
||||
{
|
||||
if (device == 0)
|
||||
{
|
||||
if (channel >= maxDAC_Channels ) return 0; // Channel doesn't exist)
|
||||
|
||||
return channelSetting[ channel ];
|
||||
}
|
||||
else
|
||||
{
|
||||
return bpecDacReadBack(device, channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WriteDacCommand( UINT16 spiCommand, UINT8 dacNr )
|
||||
{
|
||||
UINT8 spiCommandArray[2];
|
||||
UINT8 spiResponse[2];
|
||||
|
||||
spiTakeBus();
|
||||
{
|
||||
// dacNr 0: DAC 0
|
||||
// dacNr 1: DAC 1
|
||||
// dacNr 2: DAC 2
|
||||
// Enable correct ChipSelect
|
||||
switch (dacNr)
|
||||
{
|
||||
case 0:
|
||||
DAC1_CS_ENABLE;
|
||||
break;
|
||||
case 1:
|
||||
DAC2_CS_ENABLE;
|
||||
break;
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
case 2: DAC3_CS_ENABLE;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
// if (dacNr == 0)
|
||||
// {
|
||||
// DAC1_CS_ENABLE;
|
||||
// } else
|
||||
// {
|
||||
// DAC2_CS_ENABLE;
|
||||
// }
|
||||
|
||||
spiCommandArray[0] = (spiCommand >> 8) & 0xFF;
|
||||
spiCommandArray[1] = spiCommand & 0xFF;
|
||||
|
||||
spiWriteBuffer( spiCommandArray, 2);
|
||||
spiReadBuffer( spiResponse, 2 );
|
||||
|
||||
// dacNr 0: DAC 0
|
||||
// dacNr 1: DAC 1
|
||||
// dacNr 2: DAC 2
|
||||
// Enable correct ChipSelect
|
||||
switch (dacNr)
|
||||
{
|
||||
case 0:
|
||||
DAC1_CS_DISABLE;
|
||||
break;
|
||||
case 1:
|
||||
DAC2_CS_DISABLE;
|
||||
break;
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
case 2:
|
||||
DAC3_CS_DISABLE;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
// if (dacNr == 0)
|
||||
// {
|
||||
// DAC1_CS_DISABLE;
|
||||
// } else
|
||||
// {
|
||||
// DAC2_CS_DISABLE;
|
||||
// }
|
||||
}
|
||||
spiReleaseBus();
|
||||
}
|
||||
|
||||
void dacModeAll (t_dac_mode mode)
|
||||
{
|
||||
dacMode(0, mode);
|
||||
dacMode(1, mode);
|
||||
dacMode(2, mode);
|
||||
dacMode(3, mode);
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
dacMode(4, mode);
|
||||
dacMode(5, mode);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* dac.h - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: Digital to analog signal interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 10-09-2007, Marcel Mulder.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __DAC_H__
|
||||
#define __DAC_H__
|
||||
/** \file dac.h
|
||||
\brief Digital to analog signal interface.
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** Maximum number of real analog channels*/
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define maxDAC_Channels 6
|
||||
#else
|
||||
#define maxDAC_Channels 4
|
||||
#endif
|
||||
#define maxDAC_VOLTAGE (10000)
|
||||
#define maxDAC_CURRENT (20000)
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
dacVOLTAGE, /**< Voltage mode 0 to 10V */
|
||||
dacCURRENT /**< Current mode 0 to 20mA */
|
||||
} t_dac_mode;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** \brief Initialize DAC.*/
|
||||
void dacInit (void);
|
||||
|
||||
|
||||
void dac_MuxEn (BOOLEAN mode);
|
||||
|
||||
BOOLEAN dac_MuxRB (void);
|
||||
|
||||
|
||||
/** \brief Select input mode (Voltage or Current) of a certain channel. */
|
||||
void dacMode(
|
||||
UINT8 channel, /**< 0..3 = valid, 8..255 = future use */
|
||||
t_dac_mode mode
|
||||
);
|
||||
|
||||
/** \brief Write analog value in mV or uA depending on dacMode */
|
||||
void dacWrite(
|
||||
UINT8 device, /**< 0 = Self, 1..32 = Remote device */
|
||||
UINT8 channel, /**< 0..3 = valid, 8..255 = future use */
|
||||
UINT16 value /**< VOLTAGE: 0..10000[mV], CURRENT: 0..20000[uA] */
|
||||
);
|
||||
|
||||
/** \brief Read analog value in mV or uA depending on dacMode
|
||||
\retval value VOLTAGE: 0..10000[mV], CURRENT: 0..20000[uA] */
|
||||
UINT16 dacReadBack (
|
||||
UINT8 device, /**< 0 = Self, 1..32 = Remote device */
|
||||
UINT8 channel /**< 0..3 = valid, 8..255 = future use */
|
||||
);
|
||||
|
||||
void WriteDacCommand( UINT16 spiCommand, UINT8 dacNr );
|
||||
|
||||
void dacModeAll (t_dac_mode mode);
|
||||
|
||||
#endif /* __DAC_H__ */
|
||||
@@ -0,0 +1,716 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* dio.c - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: Digital inputs/outputs interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 28-11-2007, fvds.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* Compiler includes */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Hardware Includes */
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "Task.h"
|
||||
#include "queue.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "dio.h"
|
||||
#include "dioISR.h"
|
||||
#include "armVIC.h"
|
||||
#include "ElecStatusCache.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define PORT0_BASE_ADDR FIO_BASE_ADDR
|
||||
#define PORT1_BASE_ADDR (FIO_BASE_ADDR + 0x20)
|
||||
#define PORT2_BASE_ADDR (FIO_BASE_ADDR + 0x40)
|
||||
#define PORT3_BASE_ADDR (FIO_BASE_ADDR + 0x60)
|
||||
#define PORT4_BASE_ADDR (FIO_BASE_ADDR + 0x80)
|
||||
|
||||
#define DIR_OFFSET (0x00)
|
||||
#define MASK_OFFSET (0x10)
|
||||
#define PIN_OFFSET (0x14)
|
||||
#define SET_OFFSET (0x18)
|
||||
#define CLR_OFFSET (0x1C)
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
#define DIO_MUX_DIR FIO3DIR
|
||||
#define DIO_MUX_SET FIO3SET
|
||||
#define DIO_MUX_CLR FIO3CLR
|
||||
|
||||
#define DIN_MUX_BIT BIT(25)
|
||||
#define DIN_MUX_SET (DIO_MUX_SET = DIN_MUX_BIT)
|
||||
#define DIN_MUX_CLR (DIO_MUX_CLR = DIN_MUX_BIT)
|
||||
|
||||
|
||||
#define DOUT_MUX_BIT BIT(26)
|
||||
#define DOUT_MUX_SET (DIO_MUX_SET = DOUT_MUX_BIT)
|
||||
#define DOUT_MUX_CLR (DIO_MUX_CLR = DOUT_MUX_BIT)
|
||||
#endif
|
||||
|
||||
#define DISPATCH_TASK_PRIO (tskIDLE_PRIORITY + 5)
|
||||
#define DISPATCH_QUEUE_SIZE 10
|
||||
|
||||
#define Int_queue_time 3 /* In Miliseconds */
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
portTickType dechatterStopTime[maxDI_Channels]; /* Contains tickcount Value, where*/
|
||||
/* dechattering timeout occours */
|
||||
|
||||
UINT8 dechatterLockFlag[maxDI_Channels] = /* Channel Lock Flag */
|
||||
{
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
UINT32 dechatterTime[maxDI_Channels] = /* TimeDelay until dechatter timeout*/
|
||||
{
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
10
|
||||
};
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
t_output outputPins[maxDO_Channels] =
|
||||
{
|
||||
{ PORT4_BASE_ADDR, BIT(8) }, // DOUT0
|
||||
{ PORT4_BASE_ADDR, BIT(9) }, // DOUT1
|
||||
{ PORT4_BASE_ADDR, BIT(10) }, // DOUT2
|
||||
{ PORT4_BASE_ADDR, BIT(11) }, // DOUT3
|
||||
{ PORT4_BASE_ADDR, BIT(12) }, // DOUT4
|
||||
{ PORT4_BASE_ADDR, BIT(13) }, // DOUT5
|
||||
{ PORT4_BASE_ADDR, BIT(14) }, // DOUT6
|
||||
{ PORT4_BASE_ADDR, BIT(15) } // DOUT7
|
||||
};
|
||||
#else
|
||||
t_output outputPins[maxDO_Channels] =
|
||||
{
|
||||
{ PORT1_BASE_ADDR, BIT(0) }, // DOUT0
|
||||
{ PORT1_BASE_ADDR, BIT(1) }, // DOUT1
|
||||
{ PORT1_BASE_ADDR, BIT(4) }, // DOUT2
|
||||
{ PORT1_BASE_ADDR, BIT(8) }, // DOUT3
|
||||
{ PORT1_BASE_ADDR, BIT(9) }, // DOUT4
|
||||
{ PORT1_BASE_ADDR, BIT(10) }, // DOUT5
|
||||
{ PORT1_BASE_ADDR, BIT(14) }, // DOUT6
|
||||
{ PORT1_BASE_ADDR, BIT(15) } // DOUT7
|
||||
};
|
||||
#endif
|
||||
|
||||
t_input inputPins[maxDI_Channels] =
|
||||
{
|
||||
{ PORT0_BASE_ADDR, BIT(15), NULL }, // DIN0
|
||||
{ PORT0_BASE_ADDR, BIT(16), NULL }, // DIN1
|
||||
{ PORT0_BASE_ADDR, BIT(17), NULL }, // DIN2
|
||||
{ PORT0_BASE_ADDR, BIT(18), NULL }, // DIN3
|
||||
{ PORT0_BASE_ADDR, BIT(24), NULL }, // DIN4
|
||||
{ PORT0_BASE_ADDR, BIT(25), NULL }, // DIN5
|
||||
{ PORT0_BASE_ADDR, BIT(26), NULL }, // DIN6
|
||||
{ PORT0_BASE_ADDR, BIT(27), NULL }, // DIN7
|
||||
{ PORT0_BASE_ADDR, BIT(28), NULL }, // DIN8
|
||||
{ PORT0_BASE_ADDR, BIT(29), NULL }, // DIN9
|
||||
{ PORT0_BASE_ADDR, BIT(30), NULL } // DIN10
|
||||
};
|
||||
|
||||
BOOLEAN dioActive = FALSE;
|
||||
xQueueHandle dispatchedIsrQueue= 0;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
static void setMaskDirRegisters(void);
|
||||
static void enableChannelInterrupt(UINT8 channel);
|
||||
static void disableChannelInterrupt(UINT8 channel);
|
||||
static void isrDispatchTask(void *pvParameters);
|
||||
static BOOLEAN hasTimeoutPast( UINT32 endTick );
|
||||
static void startDechatterInput (UINT8 ChannelNumber, t_di_mode Edge);
|
||||
static void endDechatterInput (void);
|
||||
static void callAllCallbacks(t_callbackListItem *pCallbackList, t_di_mode detectedEdge);
|
||||
|
||||
|
||||
|
||||
void dioInit(void)
|
||||
{
|
||||
SCS |= (1UL<<0); /* GPIOM in SCS to fast IO */
|
||||
|
||||
setMaskDirRegisters(); /* Init channel Registers */
|
||||
dioActive= TRUE; /* Set global dioAcitve */
|
||||
|
||||
/* Create queue and Task for ISR-displatching */
|
||||
dispatchedIsrQueue = xQueueCreate( DISPATCH_QUEUE_SIZE, sizeof(t_IsrDispatchQueueItem));
|
||||
xTaskCreate(isrDispatchTask, ( signed portCHAR * ) "dioIsrDispatcher",
|
||||
configMINIMAL_STACK_SIZE, NULL, DISPATCH_TASK_PRIO, NULL);
|
||||
|
||||
/* Enable GPIO interrupt */
|
||||
portENTER_CRITICAL();
|
||||
{
|
||||
VICIntSelect &= ~(VIC_CHAN_TO_MASK(VIC_CHAN_NUM_EINT3));
|
||||
VICIntEnClr = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_EINT3);
|
||||
VICVectAddr17 = (void *)gpioISR;
|
||||
VICVectCntl7 = 0x01;
|
||||
VICIntEnable = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_EINT3);
|
||||
}
|
||||
portEXIT_CRITICAL();
|
||||
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
/* Init both MUX lines as Outputs */
|
||||
DIO_MUX_DIR |= (DIN_MUX_BIT | DOUT_MUX_BIT);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void dio_inMuxEn (BOOLEAN mode)
|
||||
{
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
if (mode == TRUE)
|
||||
{
|
||||
DIN_MUX_SET;
|
||||
}
|
||||
else
|
||||
{
|
||||
DIN_MUX_CLR;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void dio_outMuxEn (BOOLEAN mode)
|
||||
{
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
if (mode == TRUE)
|
||||
{
|
||||
DOUT_MUX_SET;
|
||||
}
|
||||
else
|
||||
{
|
||||
DOUT_MUX_CLR;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOLEAN dio_inMuxRB (void)
|
||||
{
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
if (DIO_MUX_SET & DIN_MUX_BIT)
|
||||
{
|
||||
/* MUX of digital input is switched to Extension Board */
|
||||
return (TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* MUX of digital input is switched to Main Board */
|
||||
return (FALSE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
BOOLEAN dio_outMuxRB (void)
|
||||
{
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2)
|
||||
#if (PINSET_TESTER == 2)
|
||||
if (DIO_MUX_SET & DOUT_MUX_BIT)
|
||||
{
|
||||
/* MUX of digital input is switched to Extension Board */
|
||||
return (TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* MUX of digital input is switched to Main Board */
|
||||
return (FALSE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
RESULT dioRegisterCallback (t_dio_callbackfunc pFunc, UINT8 channel, t_di_mode mode)
|
||||
{
|
||||
RESULT result = OK;
|
||||
|
||||
disableChannelInterrupt(channel);
|
||||
|
||||
// Create item
|
||||
t_callbackListItem *newCallbackListItem =
|
||||
(t_callbackListItem *) pvPortMalloc(sizeof(t_callbackListItem));
|
||||
if (newCallbackListItem == NULL)
|
||||
{
|
||||
result = ERROR;
|
||||
} else
|
||||
{
|
||||
if (inputPins[channel].pCallbackList == NULL)
|
||||
{
|
||||
enableChannelInterrupt(channel);
|
||||
}
|
||||
|
||||
// Fill list item
|
||||
newCallbackListItem->pCallback = pFunc;
|
||||
newCallbackListItem->mode = mode;
|
||||
|
||||
// Add to front of list
|
||||
newCallbackListItem->next = inputPins[channel].pCallbackList;
|
||||
inputPins[channel].pCallbackList = newCallbackListItem;
|
||||
}
|
||||
|
||||
enableChannelInterrupt(channel);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** \brief Remove register callback function for digital input
|
||||
* \retval OK Callback was removed succesfully
|
||||
* \retval ERROR Failed to remove Callback-function from channel
|
||||
*/
|
||||
RESULT dioRemoveCallback(t_dio_callbackfunc pFunc, UINT8 channel)
|
||||
{
|
||||
RESULT result = OK;
|
||||
|
||||
disableChannelInterrupt(channel);
|
||||
|
||||
// Check if channel has callback list
|
||||
if (inputPins[channel].pCallbackList == NULL)
|
||||
{
|
||||
result = ERROR;
|
||||
} else
|
||||
{
|
||||
BOOLEAN callbackFound = FALSE;
|
||||
t_callbackListItem * previousItem= NULL;
|
||||
t_callbackListItem * currentItem = inputPins[channel].pCallbackList;
|
||||
|
||||
// Find callbackfunc
|
||||
while ((!callbackFound) && (currentItem != NULL))
|
||||
{
|
||||
callbackFound = (currentItem->pCallback == pFunc);
|
||||
|
||||
if (!callbackFound)
|
||||
{
|
||||
previousItem = currentItem;
|
||||
currentItem = currentItem->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (callbackFound)
|
||||
{
|
||||
if (previousItem == NULL)
|
||||
{
|
||||
// Remove first item from list
|
||||
inputPins[channel].pCallbackList = currentItem->next;
|
||||
} else
|
||||
{
|
||||
// Remove list item
|
||||
previousItem->next = currentItem->next;
|
||||
}
|
||||
vPortFree(currentItem); // Release resources of listitem
|
||||
} else
|
||||
{
|
||||
result = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (inputPins[channel].pCallbackList != NULL)
|
||||
{
|
||||
enableChannelInterrupt(channel);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** \brief Read digital input.*/
|
||||
BOOLEAN dioRead(UINT8 device, /**< 0 = Self, 1..32 = Remote device */
|
||||
UINT8 channel /**< 0..10 = valid, 11..255 = future use */
|
||||
)
|
||||
{
|
||||
BOOLEAN Result;
|
||||
volatile UINT32 *gpioRegister;
|
||||
|
||||
if (device == 0)
|
||||
{
|
||||
gpioRegister = (UINT32 *)(inputPins[channel].portBaseAddr + PIN_OFFSET);
|
||||
|
||||
// device is now ignored, future implementation
|
||||
|
||||
// Get result
|
||||
if (*gpioRegister & inputPins[channel].pinMask)
|
||||
{
|
||||
Result = FALSE;
|
||||
} else
|
||||
{
|
||||
Result = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Result = bpecDioRead( device, channel );
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
/** \brief Readback digital outputs.*/
|
||||
BOOLEAN dioReadBack(UINT8 device, /**< 0 = Self, 1..32 = Remote device */
|
||||
UINT8 channel /**< 0..7 = valid, 8..255 = future use */
|
||||
)
|
||||
{
|
||||
BOOLEAN Result;
|
||||
volatile UINT32 *gpioRegister;
|
||||
|
||||
if (device == 0)
|
||||
{
|
||||
gpioRegister = (UINT32 *)(outputPins[channel].portBaseAddr + PIN_OFFSET);
|
||||
|
||||
// device is now ignored, future implementation
|
||||
|
||||
// Get result
|
||||
// NOTE: Input signal is inverted
|
||||
if (*gpioRegister & outputPins[channel].pinMask)
|
||||
{
|
||||
Result = TRUE;
|
||||
} else
|
||||
{
|
||||
Result = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Result = bpecDioReadBack( device, channel );
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
/** \brief Write digital outputs.*/
|
||||
void dioWrite(UINT8 device, /**< 0 = Self, 1..32 = Remote device */
|
||||
UINT8 channel, /**< 0..7 = valid, 8..255 = future use */
|
||||
BOOLEAN data)
|
||||
{
|
||||
volatile UINT32 *gpioRegister;
|
||||
|
||||
if (device == 0)
|
||||
{
|
||||
if (data == TRUE)
|
||||
{
|
||||
gpioRegister = (UINT32 *)(outputPins[channel].portBaseAddr
|
||||
+ SET_OFFSET);
|
||||
*gpioRegister = outputPins[channel].pinMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
gpioRegister = (UINT32 *)(outputPins[channel].portBaseAddr
|
||||
+ CLR_OFFSET);
|
||||
*gpioRegister = outputPins[channel].pinMask;
|
||||
}
|
||||
} else
|
||||
{
|
||||
bpecWriteDioValue(device, channel, data);
|
||||
}
|
||||
}
|
||||
|
||||
void setMaskDirRegisters()
|
||||
{
|
||||
int i;
|
||||
volatile UINT32 *gpioRegister;
|
||||
|
||||
for (i=0; i< maxDO_Channels; i++)
|
||||
{
|
||||
// Clear bit in mask Register
|
||||
gpioRegister = (UINT32 *)(outputPins[i].portBaseAddr + MASK_OFFSET);
|
||||
*gpioRegister &= ~(outputPins[i].pinMask);
|
||||
|
||||
// Set direction bit to output
|
||||
gpioRegister = (UINT32 *)(outputPins[i].portBaseAddr + DIR_OFFSET);
|
||||
*gpioRegister |= outputPins[i].pinMask;
|
||||
}
|
||||
|
||||
for (i=0; i< maxDI_Channels; i++)
|
||||
{
|
||||
// Clear bit in maskRegister
|
||||
gpioRegister = (UINT32 *)(inputPins[i].portBaseAddr + MASK_OFFSET);
|
||||
*gpioRegister &= ~(inputPins[i].pinMask);
|
||||
|
||||
// Set direction bit to input
|
||||
gpioRegister = (UINT32 *)(inputPins[i].portBaseAddr + DIR_OFFSET);
|
||||
*gpioRegister &= ~(inputPins[i].pinMask);
|
||||
|
||||
// Reset callback functions
|
||||
inputPins[i].pCallbackList = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void enableChannelInterrupt(UINT8 channel)
|
||||
{
|
||||
if (inputPins[channel].portBaseAddr == PORT0_BASE_ADDR)
|
||||
{
|
||||
IO0_INT_CLR = inputPins[channel].pinMask;
|
||||
IO0_INT_EN_R |= inputPins[channel].pinMask;
|
||||
IO0_INT_EN_F |= inputPins[channel].pinMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
IO2_INT_CLR = inputPins[channel].pinMask;
|
||||
IO2_INT_EN_R |= inputPins[channel].pinMask;
|
||||
IO2_INT_EN_F |= inputPins[channel].pinMask;
|
||||
}
|
||||
}
|
||||
|
||||
void disableChannelInterrupt(UINT8 channel)
|
||||
{
|
||||
if (inputPins[channel].portBaseAddr == PORT0_BASE_ADDR)
|
||||
{
|
||||
IO0_INT_EN_R &= ~BIT(inputPins[channel].pinMask);
|
||||
IO0_INT_EN_F &= ~BIT(inputPins[channel].pinMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
IO2_INT_EN_R &= ~BIT(inputPins[channel].pinMask);
|
||||
IO2_INT_EN_F &= ~BIT(inputPins[channel].pinMask);
|
||||
}
|
||||
}
|
||||
|
||||
void isrDispatchTask(void *pvParameters)
|
||||
{
|
||||
t_IsrDispatchQueueItem dispatchItem;
|
||||
UINT32 channelcnt;
|
||||
|
||||
do /* As long as active */
|
||||
{
|
||||
/* If an Input Interrupt occures, enter if Statement */
|
||||
if (xQueueReceive(dispatchedIsrQueue, &dispatchItem, Int_queue_time))
|
||||
{
|
||||
/* Check for each single Channel, which one is active */
|
||||
for (channelcnt=0; channelcnt < maxDI_Channels; channelcnt++)
|
||||
{
|
||||
/* Go further if CallBack exists for corresponding Channel */
|
||||
if (inputPins[channelcnt].pCallbackList != NULL)
|
||||
{
|
||||
/* Check if this bit is active */
|
||||
int portIndex = (inputPins[channelcnt].portBaseAddr
|
||||
== PORT0_BASE_ADDR ? 0 : 1);
|
||||
|
||||
/* Check if Interrupt occured from a RISING EDGE */
|
||||
if (dispatchItem.riseInterrupts[ portIndex ]
|
||||
& inputPins[channelcnt].pinMask)
|
||||
{ /* Rising Edge Interrupt detected */
|
||||
if (dechatterTime[channelcnt] == 0)
|
||||
{ /* If dechatterTime is set to ZERO */
|
||||
/* call Callback directly */
|
||||
callAllCallbacks(
|
||||
inputPins[channelcnt].pCallbackList,
|
||||
RISING_EDGE);
|
||||
}
|
||||
else /* If there is a dechattering Time */
|
||||
{ /* Start dechattering the Input */
|
||||
startDechatterInput(channelcnt, RISING_EDGE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if Interrupt occured from a FALLING EDGE */
|
||||
if (dispatchItem.fallInterrupts[ portIndex ]
|
||||
& inputPins[channelcnt].pinMask)
|
||||
{ /* Falling Edge Interrupt detected */
|
||||
if (dechatterTime[channelcnt] == 0)
|
||||
{ /* If dechatterTime is set to ZERO */
|
||||
/* call Callback directly */
|
||||
callAllCallbacks(
|
||||
inputPins[channelcnt].pCallbackList,
|
||||
FALLING_EDGE);
|
||||
}
|
||||
else /* if there is a dechattering Time */
|
||||
{ /* Start dechattering the Input */
|
||||
startDechatterInput(channelcnt, FALLING_EDGE);
|
||||
}
|
||||
}
|
||||
} /* EndIf CallBack exists Check */
|
||||
} /* End of FOR Loop */
|
||||
} /* End Check for occuring Interrupt */
|
||||
|
||||
|
||||
endDechatterInput(); /* Call dechatter monitor Function */
|
||||
|
||||
} while (dioActive == TRUE);
|
||||
}
|
||||
|
||||
|
||||
void startDechatterInput(UINT8 ChannelNumber, t_di_mode Edge)
|
||||
{
|
||||
|
||||
/* If corresponding Channel is currently not monitored */
|
||||
if (dechatterLockFlag[ChannelNumber] == 0)
|
||||
{
|
||||
/* Set dechatter Timer */
|
||||
dechatterStopTime[ChannelNumber] = xTaskGetTickCount()
|
||||
+ dechatterTime[ChannelNumber];
|
||||
/* Handle type of detected Edge in channel Lock Flag */
|
||||
switch (Edge)
|
||||
{
|
||||
case RISING_EDGE:
|
||||
dechatterLockFlag[ChannelNumber] = 1;
|
||||
break;
|
||||
case FALLING_EDGE:
|
||||
dechatterLockFlag[ChannelNumber] = 2;
|
||||
break;
|
||||
// case BOTH_EDGES:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If come here, an already monitored Channel causes a new Interrupt
|
||||
* (which means, within the Timer a new Edge occured)
|
||||
* This is a chatter!
|
||||
* Reload the Timer!
|
||||
*/
|
||||
else
|
||||
{
|
||||
dechatterStopTime[ChannelNumber] = xTaskGetTickCount()
|
||||
+ dechatterTime[ChannelNumber];
|
||||
}
|
||||
|
||||
}
|
||||
void endDechatterInput(void)
|
||||
{
|
||||
UINT32 channelcnt;
|
||||
|
||||
/* Check every single Channel */
|
||||
for (channelcnt = 0; channelcnt < maxDI_Channels; channelcnt++)
|
||||
{
|
||||
/* If Timeout for corresponding channel occured */
|
||||
if (hasTimeoutPast( dechatterStopTime[channelcnt]) )
|
||||
{
|
||||
/* Switch corresponding to the former detected Edge */
|
||||
switch (dechatterLockFlag[channelcnt])
|
||||
{
|
||||
case 1: /* a Rising Edge was dechattered */
|
||||
/* Is Input still High? If Yes, channel is dechattered */
|
||||
if (dioRead(0, channelcnt) == TRUE)
|
||||
{ /* Call Callback Functions */
|
||||
callAllCallbacks(inputPins[channelcnt].pCallbackList,
|
||||
RISING_EDGE);
|
||||
}
|
||||
dechatterLockFlag[channelcnt] = 0; /* release Lock Flag */
|
||||
break;
|
||||
|
||||
case 2: /* a Falling Edge was dechattered */
|
||||
/* Is Input still Low? If Yes, channel is dechattered */
|
||||
if (dioRead(0, channelcnt) == FALSE)
|
||||
{ /* Call Callback Functions */
|
||||
callAllCallbacks(inputPins[channelcnt].pCallbackList,
|
||||
FALLING_EDGE);
|
||||
}
|
||||
dechatterLockFlag[channelcnt] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void callAllCallbacks(t_callbackListItem *pCallbackList, t_di_mode detectedEdge)
|
||||
{
|
||||
while (pCallbackList != NULL)
|
||||
{
|
||||
if ( (pCallbackList->mode == detectedEdge) || (pCallbackList->mode
|
||||
== BOTH_EDGES))
|
||||
{
|
||||
// Call the callback
|
||||
pCallbackList->pCallback();
|
||||
}
|
||||
|
||||
// Check next item
|
||||
pCallbackList = pCallbackList->next;
|
||||
}
|
||||
}
|
||||
|
||||
void dioSetDechatterTime(UINT8 channel, UINT32 time)
|
||||
{
|
||||
dechatterTime[channel] = time;
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN hasTimeoutPast( UINT32 endTick )
|
||||
{
|
||||
UINT32 nowTick = xTaskGetTickCount();
|
||||
|
||||
if (nowTick >= endTick)
|
||||
{
|
||||
if ((nowTick - endTick) > 0x0000FFFF)
|
||||
{
|
||||
// the endTick has gone through 0 point, nowTick is at end of range
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// nowTick passed endTick.
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((endTick - nowTick) > 0x0000FFFF)
|
||||
{
|
||||
|
||||
// the endTick was at end of range, nowTick has gone through 0 point
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// nowTick still has to pass endTick
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* dio.h - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: Digital inputs/outputs interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 10-09-2007, Marcel Mulder.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __DIO_H__
|
||||
#define __DIO_H__
|
||||
/** \file dio.h
|
||||
\brief Digital inputs/outputs interface.
|
||||
*/
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** Maximum number of digital inputs*/
|
||||
//const UINT8 maxDI_Channels = 11;
|
||||
#define maxDI_Channels (11)
|
||||
/** Maximum number of digital outputs*/
|
||||
//const UINT8 maxDO_Channels = 8;
|
||||
#define maxDO_Channels (8)
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef void (*t_dio_callbackfunc)(void);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RISING_EDGE, /**< Generates interrupt on rising edge*/
|
||||
FALLING_EDGE, /**< Generates interrupt on falling edge*/
|
||||
BOTH_EDGES /**< Generates interrupt on both edges*/
|
||||
} t_di_mode;
|
||||
|
||||
typedef struct t_OUTPUT {
|
||||
UINT32 portBaseAddr;
|
||||
UINT32 pinMask;
|
||||
} t_output;
|
||||
|
||||
typedef struct t_CALLBACKLISTITEM {
|
||||
t_dio_callbackfunc pCallback;
|
||||
t_di_mode mode;
|
||||
struct t_CALLBACKLISTITEM *next;
|
||||
} t_callbackListItem;
|
||||
|
||||
typedef struct t_INPUT {
|
||||
UINT32 portBaseAddr;
|
||||
UINT32 pinMask;
|
||||
t_callbackListItem *pCallbackList;
|
||||
} t_input;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** \brief Initialize DIO.*/
|
||||
void dioInit (void);
|
||||
|
||||
void dio_inMuxEn (BOOLEAN mode);
|
||||
|
||||
void dio_outMuxEn (BOOLEAN mode);
|
||||
|
||||
BOOLEAN dio_inMuxRB (void);
|
||||
|
||||
BOOLEAN dio_outMuxRB (void);
|
||||
|
||||
|
||||
/** \brief Register callback function digital input events defined in mode
|
||||
(rising, falling edge or both) */
|
||||
RESULT dioRegisterCallback(
|
||||
t_dio_callbackfunc pFunc, /**< Function pointer to callback function */
|
||||
UINT8 channel, /**< 0..10 = valid, 11..255 = future use */
|
||||
t_di_mode mode
|
||||
);
|
||||
|
||||
/** \brief Remove register callback function for digital input*/
|
||||
RESULT dioRemoveCallback(
|
||||
t_dio_callbackfunc pFunc,
|
||||
UINT8 channel
|
||||
);
|
||||
|
||||
/** \brief Read digital input.*/
|
||||
BOOLEAN dioRead (
|
||||
UINT8 device, /**< 0 = Self, 1..32 = Remote device */
|
||||
UINT8 channel /**< 0..10 = valid, 11..255 = future use */
|
||||
);
|
||||
|
||||
/** \brief Readback digital outputs.*/
|
||||
BOOLEAN dioReadBack (
|
||||
UINT8 device, /**< 0 = Self, 1..32 = Remote device */
|
||||
UINT8 channel /**< 0..7 = valid, 8..255 = future use */
|
||||
);
|
||||
|
||||
/** \brief Write digital outputs.*/
|
||||
void dioWrite (
|
||||
UINT8 device, /**< 0 = Self, 1..32 = Remote device */
|
||||
UINT8 channel, /**< 0..7 = valid, 8..255 = future use */
|
||||
BOOLEAN data
|
||||
);
|
||||
|
||||
void dioSetDechatterTime(
|
||||
UINT8 channel,
|
||||
UINT32 time
|
||||
);
|
||||
|
||||
#endif /* __DIO_H__ */
|
||||
@@ -0,0 +1,102 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* dio.c - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: Digital inputs/outputs interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 28-11-2007, fvds.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
#include "dio.h"
|
||||
#include "dioISR.h"
|
||||
#include "armVIC.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "Task.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
extern xQueueHandle dispatchedIsrQueue;
|
||||
t_IsrDispatchQueueItem dispatchItem;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
volatile UINT32 receivedInts = 0;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
static void GpioHandler( void );
|
||||
|
||||
|
||||
void gpioISR()
|
||||
{
|
||||
/* Save the context of the interrupted task. */
|
||||
portSAVE_CONTEXT();
|
||||
{
|
||||
/* Call the handler to do the work. This must be a separate function to
|
||||
the wrapper to ensure the correct stack frame is set up. */
|
||||
GpioHandler();
|
||||
}
|
||||
/* Restore the context of whichever task is going to run once the interrupt
|
||||
completes. */
|
||||
portRESTORE_CONTEXT();
|
||||
}
|
||||
|
||||
|
||||
void GpioHandler( void )
|
||||
{
|
||||
receivedInts++;
|
||||
|
||||
// Check flags
|
||||
// -=NOTE=- Because input signal is inverted; the rising and
|
||||
// falling signal are switched.
|
||||
dispatchItem.riseInterrupts[0] = IO0_INT_STAT_F;
|
||||
dispatchItem.fallInterrupts[0] = IO0_INT_STAT_R;
|
||||
dispatchItem.riseInterrupts[1] = IO2_INT_STAT_R;
|
||||
dispatchItem.fallInterrupts[1] = IO2_INT_STAT_F;
|
||||
|
||||
xQueueSendToBackFromISR( dispatchedIsrQueue, &dispatchItem, pdFALSE );
|
||||
|
||||
IO0_INT_CLR = 0xFFFFFFFF;
|
||||
IO2_INT_CLR = 0xFFFFFFFF;
|
||||
|
||||
VICVectAddr = 0x00000000; // clear this interrupt from the VIC
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* dio.h - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: Digital inputs/outputs interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 10-09-2007, Marcel Mulder.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __DIOISR_H__
|
||||
#define __DIOISR_H__
|
||||
/** \file dio.h
|
||||
\brief Digital inputs/outputs interface.
|
||||
*/
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef struct t_ISRDISPATCHQUEUEITEM {
|
||||
UINT32 riseInterrupts[2];
|
||||
UINT32 fallInterrupts[2];
|
||||
} t_IsrDispatchQueueItem;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void gpioISR(void) __attribute__ ((naked));
|
||||
|
||||
#endif /* __DIOISR_H__ */
|
||||
@@ -0,0 +1,385 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* eeporm.c - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: EEPROM-driver
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 28-11-2007, fvds.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
#include "sys_config.h"
|
||||
#include "ssp1.h"
|
||||
#include "eeprom.h"
|
||||
#include "armVIC.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define EEPROM_CS_DIR_REG FIO0DIR
|
||||
#define EEPROM_CS_SET_REG FIO0SET
|
||||
#define EEPROM_CS_CLR_REG FIO0CLR
|
||||
#define EEPROM_CS_BIT BIT( 6 )
|
||||
#define EEPROM_CS_DISABLE (EEPROM_CS_SET_REG = EEPROM_CS_BIT)
|
||||
#define EEPROM_CS_ENABLE (EEPROM_CS_CLR_REG = EEPROM_CS_BIT)
|
||||
#define EEPROM_PAGE_SIZE (128)
|
||||
|
||||
#define SPICMD_WRITE_STATUS 0x01
|
||||
#define SPICMD_WRITE 0x02
|
||||
#define SPICMD_READ 0x03
|
||||
#define SPICMD_WRITE_DISABLE 0x04
|
||||
#define SPICMD_READ_STATUS 0x05
|
||||
#define SPICMD_WRITE_ENABLE 0x06
|
||||
|
||||
#define SPICMD_STATUS_WIP 0x01
|
||||
#define SPICMD_STATUS_WEL 0x02
|
||||
#define SPICMD_STATUS_BP0 0x04
|
||||
#define SPICMD_STATUS_BP1 0x08
|
||||
#define SPICMD_STATUS_WPEN 0x80
|
||||
|
||||
#define spiWrite ssp1Write
|
||||
#define spiRead ssp1Read
|
||||
#define spiWriteBuffer ssp1WriteBuffer
|
||||
#define spiReadBuffer ssp1ReadBuffer
|
||||
#define spiTakeBus ssp1TakeBus
|
||||
#define spiReleaseBus ssp1ReleaseBus
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
//extern UINT16 adres_var[];
|
||||
UINT16 adres_var[MAX_VARSINEEPROM]; // t.b.v. aantal variabelen in EEPROM JHi 12-03-2008
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
static void DisableWriteProtection(void);
|
||||
static void WaitForEndOfWrite(void);
|
||||
static void WaitForEndOfWrite(void);
|
||||
static void WriteDataByte(UINT16 address, UINT8 dataOut);
|
||||
static void WriteDataArray(UINT16 address, UINT8 *buffer, UINT16 size);
|
||||
static void ReadDataByte(UINT16 address, UINT8 *dataOut);
|
||||
static void ReadDataArray(UINT16 address, UINT8 *buffer, UINT16 size);
|
||||
static void WriteEnable(void);
|
||||
static UINT8 GetStatus(void);
|
||||
|
||||
|
||||
void eepromInit()
|
||||
{
|
||||
// Setup ChipSelect line
|
||||
SCS |= (1UL<<0); // set GPIOM in SCS for fast IO
|
||||
EEPROM_CS_DIR_REG |= EEPROM_CS_BIT;
|
||||
EEPROM_CS_DISABLE;
|
||||
}
|
||||
|
||||
RESULT eepromRead(UINT16 address, UINT8 *byte)
|
||||
{
|
||||
WaitForEndOfWrite();
|
||||
|
||||
ReadDataByte(address, byte);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
RESULT eepromWrite(UINT16 address, UINT8 byte)
|
||||
{
|
||||
WaitForEndOfWrite();
|
||||
|
||||
WriteEnable();
|
||||
|
||||
//EEPROM_DELAY;
|
||||
|
||||
WriteDataByte( address, byte );
|
||||
|
||||
//EEPROM_WRITE_DELAY;
|
||||
//EEPROM_Status |= C25LCXX_STATUS_WIP; // indicate we started a write action
|
||||
|
||||
return OK;
|
||||
|
||||
}
|
||||
|
||||
RESULT eepromWriteBuffer(UINT16 address, UINT8 *buffer, UINT16 bufferSize)
|
||||
{
|
||||
// Split up in page boundaries, if necessary
|
||||
while (bufferSize > 0)
|
||||
{
|
||||
UINT16 length;
|
||||
UINT16 endAddress;
|
||||
|
||||
// Calculate length
|
||||
if (bufferSize >= EEPROM_PAGE_SIZE)
|
||||
{
|
||||
endAddress = address + EEPROM_PAGE_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
endAddress = address + bufferSize;
|
||||
}
|
||||
|
||||
// Check if buffer overflows a page
|
||||
if (((endAddress - 1) / EEPROM_PAGE_SIZE) == (address / EEPROM_PAGE_SIZE))
|
||||
{
|
||||
// buffer doesn't exceed page
|
||||
length = endAddress - address;
|
||||
}
|
||||
else
|
||||
{
|
||||
// buffer exceeds page
|
||||
length = endAddress - (endAddress % EEPROM_PAGE_SIZE) - address;
|
||||
}
|
||||
|
||||
WaitForEndOfWrite();
|
||||
WriteEnable();
|
||||
WriteDataArray( address, buffer, length );
|
||||
|
||||
bufferSize = bufferSize - length;
|
||||
address = address + length;
|
||||
buffer = buffer + length;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
RESULT eepromReadBuffer(UINT16 address, UINT8 *buffer, UINT16 bufferSize)
|
||||
{
|
||||
WaitForEndOfWrite();
|
||||
|
||||
while (bufferSize > 0)
|
||||
{
|
||||
int length = EEPROM_PAGE_SIZE;
|
||||
if (bufferSize < EEPROM_PAGE_SIZE)
|
||||
{
|
||||
length = bufferSize;
|
||||
}
|
||||
|
||||
ReadDataArray( address, buffer, length );
|
||||
|
||||
bufferSize -= length;
|
||||
address = address + length;
|
||||
buffer = buffer + length;
|
||||
|
||||
if (bufferSize > 0) vTaskDelay(3);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
RESULT eepromWriteVar(int variableId, void *parameter )
|
||||
{
|
||||
UINT16 address = adres_var[variableId];
|
||||
UINT16 length = adres_var[variableId + 1] - address;
|
||||
|
||||
return eepromWriteBuffer( address, parameter, length );
|
||||
}
|
||||
|
||||
|
||||
RESULT eepromReadVar(int variableId, void *parameter )
|
||||
{
|
||||
UINT16 address = adres_var[variableId];
|
||||
UINT16 length = adres_var[variableId + 1] - address;
|
||||
|
||||
return eepromReadBuffer( address, parameter, length );
|
||||
}
|
||||
|
||||
void DisableWriteProtection()
|
||||
{
|
||||
WriteEnable();
|
||||
}
|
||||
|
||||
UINT8
|
||||
GetStatus()
|
||||
{
|
||||
UINT8 spiCommand[2];
|
||||
static UINT8 status;
|
||||
|
||||
spiCommand[0] = SPICMD_READ_STATUS;
|
||||
spiCommand[1] = 0x00;
|
||||
|
||||
spiTakeBus();
|
||||
{
|
||||
EEPROM_CS_ENABLE;
|
||||
|
||||
spiWriteBuffer( spiCommand, 2 );
|
||||
spiReadBuffer( spiCommand, 2 );
|
||||
|
||||
EEPROM_CS_DISABLE;
|
||||
}
|
||||
spiReleaseBus();
|
||||
|
||||
status = spiCommand[1];
|
||||
|
||||
return spiCommand[1]; // lsb of word
|
||||
}
|
||||
|
||||
void WaitForEndOfWrite(void)
|
||||
{
|
||||
UINT8 eepromStatus = GetStatus();
|
||||
|
||||
while ((eepromStatus & SPICMD_STATUS_WIP) != 0x00)
|
||||
{
|
||||
eepromStatus = GetStatus();
|
||||
}
|
||||
}
|
||||
|
||||
void WriteEnable()
|
||||
{
|
||||
UINT8 spiCommand[1];
|
||||
|
||||
spiCommand[0] = SPICMD_WRITE_ENABLE;
|
||||
|
||||
spiTakeBus();
|
||||
{
|
||||
EEPROM_CS_ENABLE;
|
||||
|
||||
spiWriteBuffer( spiCommand, 1 );
|
||||
spiReadBuffer( spiCommand, 1 );
|
||||
|
||||
EEPROM_CS_DISABLE;
|
||||
}
|
||||
spiReleaseBus();
|
||||
}
|
||||
|
||||
|
||||
void WriteDataByte(UINT16 address, UINT8 dataOut)
|
||||
{
|
||||
UINT8 spiCommand[4];
|
||||
UINT8 spiResponse[4];
|
||||
|
||||
spiCommand[0] = SPICMD_WRITE;
|
||||
spiCommand[1] = ((address >> 8) & 0xFF);
|
||||
spiCommand[2] = address & 0xFF;
|
||||
spiCommand[3] = dataOut;
|
||||
|
||||
spiTakeBus();
|
||||
{
|
||||
EEPROM_CS_ENABLE;
|
||||
|
||||
spiWriteBuffer( spiCommand, 4 );
|
||||
spiReadBuffer( spiResponse, 4 );
|
||||
|
||||
EEPROM_CS_DISABLE;
|
||||
}
|
||||
spiReleaseBus();
|
||||
|
||||
}
|
||||
|
||||
void ReadDataByte(UINT16 address, UINT8 *byte)
|
||||
{
|
||||
UINT8 spiCommand[4];
|
||||
UINT8 spiResponse[4];
|
||||
|
||||
spiCommand[0] = SPICMD_READ;
|
||||
spiCommand[1] = ((address >> 8) & 0x00FF);
|
||||
spiCommand[2] = (address & 0x00FF);
|
||||
spiCommand[3] = 0x00;
|
||||
|
||||
spiTakeBus();
|
||||
{
|
||||
EEPROM_CS_ENABLE;
|
||||
|
||||
spiWriteBuffer( spiCommand, 4 );
|
||||
spiReadBuffer( spiResponse, 4 );
|
||||
|
||||
EEPROM_CS_DISABLE;
|
||||
}
|
||||
spiReleaseBus();
|
||||
|
||||
*byte = (UINT8)spiResponse[3];
|
||||
}
|
||||
|
||||
void WriteDataArray(UINT16 address, UINT8 *buffer, UINT16 size)
|
||||
{
|
||||
UINT8 spiCommand[3];
|
||||
UINT8 spiResponse[3];
|
||||
UINT8 dummyResponse;
|
||||
UINT16 index;
|
||||
|
||||
spiTakeBus();
|
||||
{
|
||||
EEPROM_CS_ENABLE;
|
||||
|
||||
spiCommand[0] = SPICMD_WRITE;
|
||||
spiCommand[1] = ((address >> 8) & 0xFF);
|
||||
spiCommand[2] = address & 0xFF;
|
||||
|
||||
// Write command + address
|
||||
spiWriteBuffer( spiCommand, 3 );
|
||||
spiWriteBuffer( buffer, size );
|
||||
spiReadBuffer( spiResponse, 3 );
|
||||
for (index = 0; index < size; index++)
|
||||
{
|
||||
spiRead( &dummyResponse );
|
||||
}
|
||||
|
||||
|
||||
EEPROM_CS_DISABLE;
|
||||
}
|
||||
spiReleaseBus();
|
||||
}
|
||||
|
||||
void ReadDataArray(UINT16 address, UINT8 *buffer, UINT16 size)
|
||||
{
|
||||
UINT8 spiCommand[3];
|
||||
UINT8 spiResponse[3];
|
||||
UINT16 index;
|
||||
|
||||
spiCommand[0] = SPICMD_READ;
|
||||
spiCommand[1] = ((address >> 8) & 0x00FF);
|
||||
spiCommand[2] = (address & 0x00FF);
|
||||
|
||||
// Fill buffer with zero's
|
||||
for (index = 0; index < size; index++)
|
||||
{
|
||||
buffer[index] = 0x00;
|
||||
}
|
||||
|
||||
spiTakeBus();
|
||||
{
|
||||
EEPROM_CS_ENABLE;
|
||||
|
||||
spiWriteBuffer( spiCommand, 3 );
|
||||
spiWriteBuffer( buffer, size );
|
||||
spiReadBuffer( spiResponse, 3 );
|
||||
|
||||
for (index = 0; index < size; index++)
|
||||
{
|
||||
spiRead( buffer );
|
||||
buffer++;
|
||||
}
|
||||
|
||||
EEPROM_CS_DISABLE;
|
||||
}
|
||||
spiReleaseBus();
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* eeprom.h - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: EEPROM interface
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 10-09-2007, Marcel Mulder.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __EEPROM_H__
|
||||
#define __EEPROM_H__
|
||||
/** \file eeprom.h
|
||||
\brief EEPROM interface (tested on m95512)
|
||||
*/
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define eepromSIZE (2^16) // 64 kBytes = 512 kBit = 2^16
|
||||
#define MAX_VARSINEEPROM 300 // Let op max. aantal vaiabelen in eeprom
|
||||
// JHi 12-03-2008
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void eepromInit( void );
|
||||
RESULT eepromWrite( UINT16 address, UINT8 byte );
|
||||
RESULT eepromRead( UINT16 address, UINT8 *byte );
|
||||
RESULT eepromWriteBuffer( UINT16 address, UINT8 *buffer, UINT16 bufferSize );
|
||||
RESULT eepromReadBuffer( UINT16 address, UINT8 *buffer, UINT16 bufferSize );
|
||||
RESULT eepromWriteVar(int variableId, void *parameter );
|
||||
RESULT eepromReadVar(int variableId, void *parameter );
|
||||
|
||||
#endif /* __EEPROM_H__ */
|
||||
@@ -0,0 +1,460 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* Used with ICCARM and AARM.
|
||||
*
|
||||
* (c) Copyright IAR Systems 2006
|
||||
*
|
||||
* File name : LPC23xx_enet.c
|
||||
* Description : MAC/DMA Controller with DMA (ENET) driver
|
||||
*
|
||||
* History :
|
||||
* 1. Date : December 14, 2006
|
||||
* Author : Stanimir Bonev
|
||||
* Description : Create
|
||||
*
|
||||
* $Revision: 1.1.2.3 $
|
||||
**************************************************************************/
|
||||
|
||||
#define __no_init /* Dummy for __no_init */
|
||||
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
#include "LPC23xx_enet.h"
|
||||
|
||||
//#pragma segment="EMAC_DMA_RAM"
|
||||
|
||||
//#pragma location="EMAC_DMA_RAM"
|
||||
//#pragma data_alignment=4
|
||||
__no_init EnetDmaRxDesc_t EnetDmaRx[ENET_DMA_DESC_NUMB]__attribute__ ((section (".ethram"))) __attribute__((aligned (4)));
|
||||
//#pragma location="EMAC_DMA_RAM"
|
||||
//#pragma data_alignment=8
|
||||
__no_init EnetDmaRxStatus_t EnetDmaRxSta[ENET_DMA_DESC_NUMB]__attribute__ ((section (".ethram"))) __attribute__((aligned (8)));
|
||||
//#pragma location="EMAC_DMA_RAM"
|
||||
//#pragma data_alignment=4
|
||||
__no_init Int8U RxBuff0[EMAC_MAX_PACKET_SIZE]__attribute__ ((section (".ethram"))) __attribute__((aligned (4)));
|
||||
//#pragma location="EMAC_DMA_RAM"
|
||||
//#pragma data_alignment=4
|
||||
__no_init Int8U RxBuff1[EMAC_MAX_PACKET_SIZE]__attribute__ ((section (".ethram"))) __attribute__((aligned (4)));
|
||||
|
||||
|
||||
//#pragma location="EMAC_DMA_RAM"
|
||||
//#pragma data_alignment=4
|
||||
__no_init EnetDmaTxDesc_t EnetDmaTx[ENET_DMA_DESC_NUMB]__attribute__ ((section (".ethram"))) __attribute__((aligned (4)));
|
||||
//#pragma location="EMAC_DMA_RAM"
|
||||
//#pragma data_alignment=4
|
||||
__no_init EnetDmaTxStatus_t EnetDmaTxSta[ENET_DMA_DESC_NUMB]__attribute__ ((section (".ethram"))) __attribute__((aligned (4)));
|
||||
//#pragma location="EMAC_DMA_RAM"
|
||||
//#pragma data_alignment=4
|
||||
__no_init Int8U TxBuff0[EMAC_MAX_PACKET_SIZE]__attribute__ ((section (".ethram"))) __attribute__((aligned (4)));
|
||||
//#pragma location="EMAC_DMA_RAM"
|
||||
//#pragma data_alignment=4
|
||||
__no_init Int8U TxBuff1[EMAC_MAX_PACKET_SIZE]__attribute__ ((section (".ethram"))) __attribute__((aligned (4)));
|
||||
|
||||
static Int8U PhyAddr;
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name:
|
||||
* Parameters: None
|
||||
*
|
||||
* Return: Boolean
|
||||
*
|
||||
* Description: Init MAC/DMA Controller
|
||||
*
|
||||
*************************************************************************/
|
||||
Boolean tapdev_init(void)
|
||||
{
|
||||
Int32U Reg,to,i;
|
||||
|
||||
// Pins assignment
|
||||
PINMODE2 = 0xA02A220A; // P1[0,1,4,6,8,9,10,14,15] disable pu/pd
|
||||
PINMODE3 = 0x0000000A; // P1[17:16] disable pu/pd
|
||||
PINSEL2 = 0x50151105; // selects P1[0,1,4,6,8,9,10,14,15]
|
||||
PINSEL3 = 0x00000005; // selects P1[17:16]
|
||||
// clk enable
|
||||
// PCONP_bit.PCENET = 1;
|
||||
PCONP |= (1 << 30); /* Set Bit 30 (eth) in PCONP */
|
||||
// POWERDOWN_bit.POWERDOWN = 0;
|
||||
MAC_POWERDOWN &=~(1 << 31); /* Clear Bit 31(powerdown) */
|
||||
// Reset entire MAC
|
||||
MAC_MAC1 = 0x0000CF00; /* Reset entire MAC */
|
||||
MAC_COMMAND = 0x0038; /* Reset all control registers */
|
||||
MAC_MAC1 = 0; /* Clear entire MAC */
|
||||
// COMMAND_bit.RMII = 1;
|
||||
MAC_COMMAND |= (1 << 9); /* Set Bit 9 (RMII) in CMD */
|
||||
MAC_SUPP = 0; /* Clear PHY support register */
|
||||
MAC_TEST = 0; /* Clear test register */
|
||||
|
||||
// write the station address registers
|
||||
MAC_SA0 = (UIP_ETHADDR1<<8) | UIP_ETHADDR0;
|
||||
MAC_SA1 = (UIP_ETHADDR3<<8) | UIP_ETHADDR2;
|
||||
MAC_SA2 = (UIP_ETHADDR5<<8) | UIP_ETHADDR4;
|
||||
|
||||
MAC_MAXF = 0x600; /* Set maximum Frame */
|
||||
MAC_MCFG = 0x8018; /* clk/20 */
|
||||
MAC_MCMD = 0; /* Clear MCommand register */
|
||||
|
||||
// MIIM init
|
||||
// MCFG_bit.RSTMIIMGMT = 0;
|
||||
MAC_MCFG &=~(1 << 15); /* Clear RSTMIIMGMT Bit */
|
||||
|
||||
// descriptors init
|
||||
// MAC1_bit.RSTMCSTX = 1;
|
||||
MAC_MAC1 |= (1 << 9); /* Set Bit 9 (RSTMCSTX) in MAC1 */
|
||||
// COMMAND_bit.TXENABLE = 0;
|
||||
MAC_COMMAND &=~(1 << 1); /* Clear Bit 1 (TXENABLE) */
|
||||
// MAC1_bit.RSTTX = 1;
|
||||
MAC_MAC1 |= (1 << 8); /* Set Bit 8 (RSTTX) in MAC1 */
|
||||
// COMMAND_bit.TXRESET = 1;
|
||||
MAC_COMMAND |= (1 << 4); /* Set Bit 4 (TXRESET) in MCMD */
|
||||
// MAC1_bit.RSTMCSTX = 0;
|
||||
MAC_MAC1 &=~(1 << 9); /* Clear Bit 9 (RSTMCSTX) */
|
||||
// MAC1_bit.RSTTX = 0;
|
||||
MAC_MAC1 &=~(1 << 8); /* Clear Bit 8 (RSTTX) in MAC1 */
|
||||
|
||||
// MAC1_bit.RE = 0;
|
||||
MAC_MAC1 &=~(1 << 0); /* Clear Bit 0 (RE) in MAC1 */
|
||||
// MAC1_bit.RSTMCSRX = 1;
|
||||
MAC_MAC1 |= (1 << 11); /* Set Bit 11 (RSTMCSRX) in MAC1*/
|
||||
// COMMAND_bit.RXENABLE = 0;
|
||||
MAC_COMMAND &=~(1 << 0); /* Clear Bit 0 (RXENABLE) */
|
||||
// MAC1_bit.RSTRX = 1;
|
||||
MAC_MAC1 |= (1 << 10); /* Set Bit 10 (RSTRX) in MAC1 */
|
||||
// COMMAND_bit.RXRESET = 1;
|
||||
MAC_COMMAND |= (1 << 5); /* Set Bit 5 (RXRESET) in MCMD */
|
||||
// MAC1_bit.RSTMCSRX = 0;
|
||||
MAC_MAC1 &=~(1 << 11); /* Clear Bit 11 (RSTMCSRX) */
|
||||
// MAC1_bit.RSTRX = 0;
|
||||
MAC_MAC1 &=~(1 << 10); /* Clear Bit 10 (RSTRX) */
|
||||
|
||||
MAC_RXDESCRIPTORNUM = ENET_DMA_DESC_NUMB-1;
|
||||
MAC_TXDESCRIPTORNUM = ENET_DMA_DESC_NUMB-1;
|
||||
// COMMAND_bit.PASSRUNTFRAME = 1;
|
||||
MAC_COMMAND |= (1 << 6); /* Set Bit 6 (PASSRUNTFRAME) */
|
||||
// COMMAND_bit.PASSRXFILTER = 1;
|
||||
MAC_COMMAND |= (1 << 7); /* Set Bit 7 (PASSRXFILTER) */
|
||||
// MAC1_bit.PARF = 1;
|
||||
MAC_MAC1 |= (1 << 1); /* Set bit 1 (PARF) in MAC1 */
|
||||
MAC_MAC2 = 0x30; /* Set CRCEN & PADCRCEN in MAC2 */
|
||||
|
||||
// CLRT_bit.RM = 0xF;
|
||||
// CLRT_bit.CW = 0x37;
|
||||
MAC_CLRT = 0x0000370F; /* Set RM (0xF) and CW (0x3700) */
|
||||
|
||||
// IPGR_bit.IPGR2 = 0x12;
|
||||
// IPGR_bit.IPGR1 = 0x0c;
|
||||
MAC_IPGR = 0x00000C12; /*Set IPGR2(0x12) & IPGR1(0xC00)*/
|
||||
|
||||
MAC_IPGT = 0x12; /* Set IPGT register */
|
||||
// MAC2_bit.FD = COMMAND_bit.FULLDUPLEX = 0;
|
||||
MAC_MAC2 &=~(1 << 0); /* Clear Bit 0 (FD) in MAC2 */
|
||||
MAC_COMMAND &=~(1 << 10); /* Clear Bit 10 (FULLDUPLEX) */
|
||||
// SUPP_bit.SPEED = 0;
|
||||
MAC_SUPP &=~(1 << 8); /* Clear Bit 8 (SPEED) in SUPP */
|
||||
|
||||
|
||||
/* find PHY address */
|
||||
for(PhyAddr = 1; PhyAddr < 32; ++PhyAddr)
|
||||
{
|
||||
/* See Micrel PHY KS8721 Users Manual for more details */
|
||||
if((ENET_MIIReadRegister(PhyAddr, PHY_PHYIDR1) & 0xFFFF) != 0x0022)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((ENET_MIIReadRegister(PhyAddr, PHY_PHYIDR2) & 0xFFFF) == 0x1619)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(PhyAddr == 32)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
printf("PHY Address - %d\r\n",PhyAddr);
|
||||
|
||||
ENET_MIIWriteRegister(PhyAddr,PHY_BMCR,BMCR_RESET);
|
||||
|
||||
to = PHY_TO;
|
||||
|
||||
while(to)
|
||||
{
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,PHY_BMCR);
|
||||
|
||||
if(!(Reg & BMCR_RESET))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!to)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
#ifdef TRACE_PHY
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,0);
|
||||
printf("PHY_BMCR(0) - 0x%04X\n\r",Reg);
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,1);
|
||||
printf("PHY_BMSR(1) - 0x%04X\n\r",Reg);
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,0x4);
|
||||
printf("PHY_ANAR(4) - 0x%04X\n\r",Reg);
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,0x5);
|
||||
printf("PHY_ANLPAR(5) - 0x%04X\n\r",Reg);
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,0x6);
|
||||
printf("PHY_ANER(6) - 0x%04X\n\r",Reg);
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,0x1f);
|
||||
printf("PHY_100PHY(1F) - 0x%04X\n\r",Reg);
|
||||
#endif // TRACE_PHY
|
||||
|
||||
if(ENET_MIIReadRegister(PhyAddr,PHY_BMSR ) & BMSR_NOPREAM)
|
||||
{
|
||||
// PHY support preamble suppression
|
||||
MAC_MCFG |= 1 << 1;
|
||||
}
|
||||
|
||||
#if AUTO_NEGOTIATION_ENA != 0
|
||||
// PHY interrupt init, clear and enable
|
||||
// Set Auto-Negotiation Advertisement
|
||||
ENET_MIIWriteRegister(PhyAddr,PHY_ANAR, 1 | ANAR_10BT | ANAR_10BT_FULL | ANAR_100BT | ANAR_100BT_FULL);
|
||||
// Enable Auto-Negotiation
|
||||
Reg = BMCR_AN | BMCR_RE_AN;
|
||||
#else
|
||||
|
||||
Reg = 0;
|
||||
|
||||
if(FIX_DUPLEX == FULL_DUPLEX)
|
||||
{
|
||||
Reg |= BMCR_DUPLEX;
|
||||
}
|
||||
|
||||
if(FIX_SPEED == SPEED_100)
|
||||
{
|
||||
Reg |= BMCR_SPEED_100;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ENET_MIIWriteRegister(PhyAddr,PHY_BMCR,Reg);
|
||||
|
||||
to = PHY_TO;
|
||||
|
||||
while(to)
|
||||
{
|
||||
--to;
|
||||
if(ENET_MIIReadRegister(PhyAddr,PHY_BMSR) & BMSR_LINK_ESTABLISHED)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!to)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
#ifdef TRACE_PHY
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,0);
|
||||
printf("PHY_BMCR(0) - 0x%04X\n\r",Reg);
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,1);
|
||||
printf("PHY_BMSR(1) - 0x%04X\n\r",Reg);
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,0x4);
|
||||
printf("PHY_ANAR(4) - 0x%04X\n\r",Reg);
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,0x5);
|
||||
printf("PHY_ANLPAR(5) - 0x%04X\n\r",Reg);
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,0x6);
|
||||
printf("PHY_ANER(6) - 0x%04X\n\r",Reg);
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,0x1f);
|
||||
printf("PHY_100PHY(1F) - 0x%04X\n\r",Reg);
|
||||
#endif // TRACE_PHY
|
||||
|
||||
Reg = ENET_MIIReadRegister(PhyAddr,PHY_100PHY) & PHYCR_MODE;
|
||||
|
||||
switch(Reg)
|
||||
{
|
||||
case 0x04: // 10 BASE T Half-duplex
|
||||
printf("10 BASE T Half-duplex\r\n");
|
||||
Reg = 0;
|
||||
break;
|
||||
case 0x08: // 100 BASE TX Half-duplex
|
||||
printf("100 BASE TX Half-duplex\r\n");
|
||||
Reg = BMCR_SPEED_100;
|
||||
// SUPP_bit.SPEED = 1;
|
||||
MAC_SUPP |= (1 << 8); /* Set Bit 8 (SPEED) in SUPP */
|
||||
break;
|
||||
case 0x14: // 10 BASE T Full-duplex
|
||||
printf("10 BASE T Full-duplex\r\n");
|
||||
Reg = BMCR_DUPLEX;
|
||||
MAC_IPGT = 0x15;
|
||||
// MAC2_bit.FD = COMMAND_bit.FULLDUPLEX = 1;
|
||||
MAC_MAC2 |= (1 << 0); /* Set Bit 0 (FD) in MAC2 */
|
||||
MAC_COMMAND |= (1 << 10); /* Set Bit 10 (FULLDUPLEX) */
|
||||
break;
|
||||
case 0x18: // 100 BASE TX Full-duplex
|
||||
printf("100 BASE TX Full-duplex\r\n");
|
||||
Reg = BMCR_SPEED_100 | BMCR_DUPLEX;
|
||||
MAC_IPGT = 0x15;
|
||||
// MAC2_bit.FD = COMMAND_bit.FULLDUPLEX = 1;
|
||||
MAC_MAC2 |= (1 << 0); /* Set Bit 0 (FD) in MAC2 */
|
||||
MAC_COMMAND |= (1 << 10); /* Set Bit 10 (FULLDUPLEX) */
|
||||
// SUPP_bit.SPEED = 1;
|
||||
MAC_SUPP |= (1 << 8); /* Set Bit 8 (SPEED) in SUPP */
|
||||
break;
|
||||
default:
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
// Disable Auto-Negotiation and update speed and duplex settings
|
||||
ENET_MIIWriteRegister(PhyAddr,PHY_BMCR,Reg);
|
||||
|
||||
to = PHY_TO;
|
||||
|
||||
while(to)
|
||||
{
|
||||
--to;
|
||||
if(ENET_MIIReadRegister(PhyAddr,PHY_BMSR) & BMSR_LINK_ESTABLISHED)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!to)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
for( i = 0; i < ENET_DMA_DESC_NUMB; ++i)
|
||||
{
|
||||
EnetDmaRx[i].EnetRxCtrl.Size = EMAC_MAX_PACKET_SIZE-1;
|
||||
EnetDmaRx[i].EnetRxCtrl.Intr = 1;
|
||||
EnetDmaRxSta[i].Data[0] = EnetDmaRxSta[i].Data[1] = 0;
|
||||
|
||||
EnetDmaTx[i].EnetTxCtrl.Data = (1<<31) | (1<<30) | (1<<29) | (1<<28) | (1<<26) | (EMAC_MAX_PACKET_SIZE-1);
|
||||
EnetDmaTxSta[i].Data = 0;
|
||||
|
||||
}
|
||||
|
||||
EnetDmaRx[0].pBuffer = (pInt32U)RxBuff0;
|
||||
EnetDmaRx[1].pBuffer = (pInt32U)RxBuff1;
|
||||
EnetDmaTx[0].pBuffer = (pInt32U)TxBuff0;
|
||||
EnetDmaTx[1].pBuffer = (pInt32U)TxBuff1;
|
||||
MAC_RXCONSUMEINDEX = 0;
|
||||
MAC_TXPRODUCEINDEX = 0;
|
||||
MAC_TXDESCRIPTOR = (Int32U)EnetDmaTx;
|
||||
MAC_TXSTATUS = (Int32U)EnetDmaTxSta;
|
||||
MAC_RXDESCRIPTOR = (Int32U)EnetDmaRx;
|
||||
MAC_RXSTATUS = (Int32U)EnetDmaRxSta;
|
||||
|
||||
// COMMAND_bit.RXENABLE = 1;
|
||||
MAC_COMMAND |= (1 << 0); /* Set Bit 0 (RXENABLE) in CMD */
|
||||
// MAC1_bit.RE = 1;
|
||||
MAC_MAC1 |= (1 << 0); /* Set Bit 0 (RE) in MAC1 */
|
||||
// COMMAND_bit.TXENABLE = 1;
|
||||
MAC_COMMAND |= (1 << 1); /* Set Bit 1 (TXENABLE) in CMD */
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: tapdev_read
|
||||
* Parameters:
|
||||
* Return:
|
||||
*
|
||||
* Description: Read data for MAC/DMA Controller
|
||||
*
|
||||
*************************************************************************/
|
||||
Int32U tapdev_read(void * pPacket)
|
||||
{
|
||||
Int32U Indx = MAC_RXCONSUMEINDEX;
|
||||
Int32U Size = EMAC_MAX_PACKET_SIZE;
|
||||
if(Indx == MAC_RXPRODUCEINDEX)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
Size = MIN(Size,(EnetDmaRxSta[Indx].RxSize+1));
|
||||
memcpy(pPacket,EnetDmaRx[Indx].pBuffer,Size);
|
||||
if(++Indx > MAC_RXDESCRIPTORNUM)
|
||||
{
|
||||
Indx = 0;
|
||||
}
|
||||
MAC_RXCONSUMEINDEX = Indx;
|
||||
return(Size);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: tapdev_send
|
||||
* Parameters:
|
||||
* Return: Boolean
|
||||
*
|
||||
* Description: Send data to MAC/DMA Controller
|
||||
*
|
||||
*************************************************************************/
|
||||
Boolean tapdev_send(void *pPacket, Int32U size)
|
||||
{
|
||||
Int32U Indx, IndxHold = MAC_TXPRODUCEINDEX + 1;
|
||||
if(size == 0)
|
||||
{
|
||||
return(TRUE);
|
||||
}
|
||||
if(IndxHold > MAC_TXDESCRIPTORNUM)
|
||||
{
|
||||
IndxHold = 0;
|
||||
}
|
||||
if(IndxHold == MAC_TXCONSUMEINDEX)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
Indx = MAC_TXPRODUCEINDEX;
|
||||
size = MIN(size,EMAC_MAX_PACKET_SIZE);
|
||||
memcpy(EnetDmaTx[Indx].pBuffer,pPacket,size);
|
||||
EnetDmaTx[Indx].EnetTxCtrl.Size = size - 1;
|
||||
MAC_TXPRODUCEINDEX = IndxHold;
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: ENET_MIIWriteRegister
|
||||
* Parameters: Int8U DevId, Int8U RegAddr, Int32U Value
|
||||
* Return: none
|
||||
*
|
||||
* Description: Writes a value on the PHY registers
|
||||
*
|
||||
*************************************************************************/
|
||||
static void ENET_MIIWriteRegister (Int8U DevId, Int8U RegAddr, Int32U Value)
|
||||
{
|
||||
MAC_MCMD = 0; /* set read operation */
|
||||
// MADR_bit.PHY_ADDR = DevId;
|
||||
|
||||
MAC_MADR = MAC_MADR & 0xFFFFE0E0; /* Reset PHY_ADDR and REG_ADDR */
|
||||
MAC_MADR |= (DevId << 8) | (RegAddr << 0); /* Set PHY_ADDR and REG_ADDR */ // \TODO is this working??
|
||||
|
||||
MAC_MWTD = Value;
|
||||
// while(MIND_bit.BUSY);
|
||||
while (MAC_MIND & (1 << 0)); // \TODO is this working??
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: ENET_MIIReadRegister
|
||||
* Parameters: Int8U DevId, Int8U RegAddr, Int32U Value
|
||||
* Return: Int32U
|
||||
*
|
||||
* Description: Read a value from the PHY registers
|
||||
*
|
||||
*************************************************************************/
|
||||
static Int32U ENET_MIIReadRegister (Int8U DevId, Int8U RegAddr)
|
||||
{
|
||||
MAC_MCMD = 0;
|
||||
// MADR_bit.PHY_ADDR = DevId; // set the MII Physical address
|
||||
// MADR_bit.REGADDR = RegAddr; // set the MII register address
|
||||
MAC_MADR = MAC_MADR & 0xFFFFE0E0; /* Reset PHY_ADDR and REG_ADDR */
|
||||
MAC_MADR |= (DevId << 8) | (RegAddr << 0); /* Set PHY_ADDR and REG_ADDR */ // \TODO is this working??
|
||||
|
||||
MAC_MCMD = 1; // set read operation
|
||||
// while(MIND_bit.BUSY | MIND_bit.NOT_VALID);
|
||||
while (MAC_MIND & (5 << 0)); // \TODO is this working??
|
||||
return(MAC_MRDD);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,314 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* Used with ICCARM and AARM.
|
||||
*
|
||||
* (c) Copyright IAR Systems 2006
|
||||
*
|
||||
* File name : LPC23xx_enet.h
|
||||
* Description : MAC/DMA Controller with DMA (ENET) driver include file
|
||||
*
|
||||
* History :
|
||||
* 1. Date : December 14, 2006
|
||||
* Author : Stanimir Bonev
|
||||
* Description : Create
|
||||
*
|
||||
* $Revision: 1.1.2.3 $
|
||||
**************************************************************************/
|
||||
#include <includes.h>
|
||||
|
||||
#ifndef __LPC23XX_ENET_H
|
||||
#define __LPC23XX_ENET_H
|
||||
|
||||
|
||||
#define EMAC_MAX_PACKET_SIZE (UIP_CONF_BUFFER_SIZE + 16)
|
||||
#define ENET_DMA_DESC_NUMB 2
|
||||
#define ENET_OK (1)
|
||||
#define ENET_NOK (0)
|
||||
|
||||
#define AUTO_NEGOTIATION_ENA 0 // Enable PHY Auto-negotiation
|
||||
|
||||
#define PHY_TO 666666 // ~10sec
|
||||
|
||||
// KS8721B1
|
||||
#define PHY_BMCR 0x0000
|
||||
#define PHY_BMSR 0x0001
|
||||
#define PHY_PHYIDR1 0x0002
|
||||
#define PHY_PHYIDR2 0x0003
|
||||
#define PHY_ANAR 0x0004
|
||||
#define PHY_ANLPAR 0x0005
|
||||
#define PHY_ANLPARNP 0x0005
|
||||
#define PHY_ANER 0x0006
|
||||
#define PHY_ANNPTR 0x0007
|
||||
#define PHY_LPNPA 0x0008
|
||||
|
||||
#define PHY_RECR 0x0015
|
||||
#define PHY_INTCTRL 0x001B
|
||||
#define PHY_100PHY 0x001F
|
||||
|
||||
/* BMCR bitmap */
|
||||
#define BMCR_RESET 0x8000
|
||||
#define BMCR_LOOPBACK 0x4000
|
||||
#define BMCR_SPEED_100 0x2000
|
||||
#define BMCR_AN 0x1000
|
||||
#define BMCR_POWERDOWN 0x0800
|
||||
#define BMCR_ISOLATE 0x0400
|
||||
#define BMCR_RE_AN 0x0200
|
||||
#define BMCR_DUPLEX 0x0100
|
||||
|
||||
/* BMSR bitmap */
|
||||
#define BMSR_100BE_T4 0x8000
|
||||
#define BMSR_100TX_FULL 0x4000
|
||||
#define BMSR_100TX_HALF 0x2000
|
||||
#define BMSR_10BE_FULL 0x1000
|
||||
#define BMSR_10BE_HALF 0x0800
|
||||
#define BMSR_NOPREAM 0x0040
|
||||
#define BMSR_AUTO_DONE 0x0020
|
||||
#define BMSR_REMOTE_FAULT 0x0010
|
||||
#define BMSR_NO_AUTO 0x0008
|
||||
#define BMSR_LINK_ESTABLISHED 0x0004
|
||||
|
||||
/* PHY_ANAR bitmap */
|
||||
#define ANAR_NEXT_PAGE 0x8000
|
||||
#define ANAR_REMOTE_FAULT 0x2000
|
||||
#define ANAR_PAUSE 0x0400
|
||||
#define ANAR_100BE_T4 0x0200
|
||||
#define ANAR_100BT_FULL 0x0100
|
||||
#define ANAR_100BT 0x0080
|
||||
#define ANAR_10BT_FULL 0x0040
|
||||
#define ANAR_10BT 0x0020
|
||||
#define ANAR_SELECTOR 0x001F
|
||||
|
||||
/* ANLPAR bitmap */
|
||||
#define ANLPAR_NEXT_PAGE 0x8000
|
||||
#define ANLPAR_ACKN 0x4000
|
||||
#define ANLPAR_REMOTE_FAULT 0x2000
|
||||
#define ANLPAR_PAUSE 0x0C00
|
||||
#define ANLPAR_100BE_T4 0x0200
|
||||
#define ANLPAR_100BT_FULL 0x0100
|
||||
#define ANLPAR_100BT 0x0080
|
||||
#define ANLPAR_10BT_FULL 0x0040
|
||||
#define ANLPAR_10BT 0x0020
|
||||
#define ANLPAR_SELECTOR 0x001F
|
||||
|
||||
/* PHY_100PHY setting */
|
||||
#define PHYCR_MDIX_DIS 0x2000
|
||||
#define PHYCR_ENR_DET 0x1000
|
||||
#define PHYCR_FORCE_LINK 0x0800
|
||||
#define PHYCR_POWER_SAVING 0x0400
|
||||
#define PHYCR_INTR_LEVEL 0x0200
|
||||
#define PHYCR_JABBER_ENA 0x0100
|
||||
#define PHYCR_PAUSE_ENA 0x0080
|
||||
#define PHYCR_PHY_ISO 0x0040
|
||||
#define PHYCR_MODE 0x001C
|
||||
#define PHYCR_SQE_TST_ENA 0x0002
|
||||
#define PHYCR_SCRAM_DIS 0x0001
|
||||
|
||||
#define SPEED_100 1
|
||||
#define SPEED_10 0
|
||||
#define FULL_DUPLEX 1
|
||||
#define HALF_DUPLEX 0
|
||||
|
||||
#define FIX_SPEED SPEED_100
|
||||
#define FIX_DUPLEX FULL_DUPLEX
|
||||
|
||||
typedef union _EnetRxCR_t
|
||||
{
|
||||
Int32U Data;
|
||||
struct {
|
||||
Int32U DMA_XFERCOUNT :12;
|
||||
Int32U CONT_EN : 1;
|
||||
Int32U : 1;
|
||||
Int32U NXT_EN : 1;
|
||||
Int32U DLY_EN : 1;
|
||||
Int32U : 1;
|
||||
Int32U ENTRY_TRIG : 5;
|
||||
Int32U ADDR_WRAP :10;
|
||||
};
|
||||
} EnetRxCR_t, * pEnetRxCR_t;
|
||||
|
||||
typedef union _EnetRxSR_t
|
||||
{
|
||||
Int32U Data;
|
||||
struct {
|
||||
Int32U FrameLength :11;
|
||||
Int32U : 1;
|
||||
Int32U Overlength : 1;
|
||||
Int32U FalseCarrier : 1;
|
||||
Int32U WatchdogTO : 1;
|
||||
Int32U RuntFrame : 1;
|
||||
Int32U Valid : 1;
|
||||
Int32U LateCollision : 1;
|
||||
Int32U FrameType : 1;
|
||||
Int32U MIIError : 1;
|
||||
Int32U ExtraBits : 1;
|
||||
Int32U CRCError : 1;
|
||||
Int32U OneLevelVLAN : 1;
|
||||
Int32U TwoLevelVLAN : 1;
|
||||
Int32U LengthError : 1;
|
||||
Int32U ControlFrame : 1;
|
||||
Int32U UnsupportedFrame: 1;
|
||||
Int32U MulticastFrame : 1;
|
||||
Int32U BroadcastFrame : 1;
|
||||
Int32U FilteringFail : 1;
|
||||
Int32U PacketFilter : 1;
|
||||
Int32U FrameAbort : 1;
|
||||
};
|
||||
} EnetRxSR_t, * pEnetRxSR_t;
|
||||
|
||||
typedef union _EnetTxSR_t
|
||||
{
|
||||
Int32U Data;
|
||||
struct {
|
||||
Int32U FrameAborted : 1;
|
||||
Int32U : 1;
|
||||
Int32U NoCarrier : 1;
|
||||
Int32U LossOfCarrier : 1;
|
||||
Int32U ExcessiveDef : 1;
|
||||
Int32U LateCollision : 1;
|
||||
Int32U ExcessiveColl : 1;
|
||||
Int32U UnderRun : 1;
|
||||
Int32U Deferred : 1;
|
||||
Int32U LateCollisionObs: 1;
|
||||
Int32U CollisionCount : 4;
|
||||
Int32U : 2;
|
||||
Int32U Valid : 1;
|
||||
Int32U : 1;
|
||||
Int32U ByteCounter :13;
|
||||
Int32U PacketRetry : 1;
|
||||
};
|
||||
} EnetTxSR_t, * pEnetTxSR_t;
|
||||
|
||||
|
||||
typedef union _EnetTxCtrl_t
|
||||
{
|
||||
Int32U Data;
|
||||
struct
|
||||
{
|
||||
Int32U Size : 11;
|
||||
Int32U : 15;
|
||||
Int32U Override : 1;
|
||||
Int32U Huge : 1;
|
||||
Int32U Pad : 1;
|
||||
Int32U CRC : 1;
|
||||
Int32U Last : 1;
|
||||
Int32U Intr : 1;
|
||||
};
|
||||
} EnetTxCtrl_t, *pEnetTxCtrl_t;
|
||||
|
||||
typedef struct _EnetDmaTxDesc_t
|
||||
{
|
||||
pInt32U pBuffer;
|
||||
EnetTxCtrl_t EnetTxCtrl;
|
||||
} EnetDmaTxDesc_t, * pEnetDmaTxDesc_t;
|
||||
|
||||
typedef union _EnetDmaTxStatus_t
|
||||
{
|
||||
Int32U Data;
|
||||
struct
|
||||
{
|
||||
Int32U :21;
|
||||
Int32U CollisionCount : 4;
|
||||
Int32U Defer : 1;
|
||||
Int32U ExcessiveDefer : 1;
|
||||
Int32U ExcessiveCollision : 1;
|
||||
Int32U LateCollision : 1;
|
||||
Int32U Underrun : 1;
|
||||
Int32U NoDescriptor : 1;
|
||||
Int32U Error : 1;
|
||||
};
|
||||
} EnetDmaTxStatus_t, * pEnetDmaTxStatus_t;
|
||||
|
||||
typedef struct _EnetRxCtrl_t
|
||||
{
|
||||
Int32U Size : 11;
|
||||
Int32U : 20;
|
||||
Int32U Intr : 1;
|
||||
} EnetRxCtrl_t, *pEnetRxCtrl_t;
|
||||
|
||||
typedef struct _EnetDmaRxDesc_t
|
||||
{
|
||||
pInt32U pBuffer;
|
||||
EnetRxCtrl_t EnetRxCtrl;
|
||||
} EnetDmaRxDesc_t, * pEnetDmaRxDesc_t;
|
||||
|
||||
typedef union _EnetDmaRxStatus_t
|
||||
{
|
||||
Int32U Data[2];
|
||||
struct
|
||||
{
|
||||
Int32U RxSize :11;
|
||||
Int32U : 7;
|
||||
Int32U ControlFrame : 1;
|
||||
Int32U VLAN : 1;
|
||||
Int32U FailFilter : 1;
|
||||
Int32U Multicast : 1;
|
||||
Int32U Broadcast : 1;
|
||||
Int32U CRCError : 1;
|
||||
Int32U SymbolError : 1;
|
||||
Int32U LengthError : 1;
|
||||
Int32U RangeError : 1;
|
||||
Int32U AlignmentError : 1;
|
||||
Int32U Overrun : 1;
|
||||
Int32U NoDescriptor : 1;
|
||||
Int32U LastFlag : 1;
|
||||
Int32U Error : 1;
|
||||
Int32U SAHashCRC : 8;
|
||||
Int32U : 8;
|
||||
Int32U DAHashCRC : 8;
|
||||
Int32U : 8;
|
||||
};
|
||||
} EnetDmaRxStatus_t, * pEnetDmaRxStatus_t;
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name:
|
||||
* Parameters: None
|
||||
*
|
||||
* Return: None
|
||||
*
|
||||
* Description: Init MAC/DMA Controller
|
||||
*
|
||||
*************************************************************************/
|
||||
Boolean tapdev_init(void);
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: tapdev_read
|
||||
* Parameters:
|
||||
* Return:
|
||||
*
|
||||
* Description: Read data for MAC/DMA Controller
|
||||
*
|
||||
*************************************************************************/
|
||||
Int32U tapdev_read(void * pPacket);
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: tapdev_send
|
||||
* Parameters:
|
||||
* Return: Boolean
|
||||
*
|
||||
* Description: Send data to MAC/DMA Controller
|
||||
*
|
||||
*************************************************************************/
|
||||
Boolean tapdev_send (void *pPacket, Int32U size);
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: ENET_MIIWriteRegister
|
||||
* Parameters: Int8U DevId, Int8U RegAddr, Int32U Value
|
||||
* Return: none
|
||||
*
|
||||
* Description: Writes a value on the PHY registers
|
||||
*
|
||||
*************************************************************************/
|
||||
static void ENET_MIIWriteRegister (Int8U DevId, Int8U RegAddr, Int32U Value);
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: ENET_MIIReadRegister
|
||||
* Parameters: Int8U DevId, Int8U RegAddr, Int32U Value
|
||||
* Return: Int32U
|
||||
*
|
||||
* Description: Read a value from the PHY registers
|
||||
*
|
||||
*************************************************************************/
|
||||
static Int32U ENET_MIIReadRegister (Int8U DevId, Int8U RegAddr);
|
||||
|
||||
#endif // __LPC23XX_ENET_H
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** Common definition for IAR EW ARM
|
||||
**
|
||||
** Used with ARM IAR C/C++ Compiler and Assembler.
|
||||
**
|
||||
** (c) Copyright IAR Systems 2006
|
||||
**
|
||||
** $Revision: 1.4 $
|
||||
**
|
||||
***************************************************************************/
|
||||
#ifndef __ARM_COMM_DEF_H
|
||||
#define __ARM_COMM_DEF_H
|
||||
|
||||
#define MHZ *1000000l
|
||||
#define KHZ *1000l
|
||||
#define HZ *1l
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE (1 == 0)
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (1==1)
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void*)0)
|
||||
#endif
|
||||
|
||||
typedef double Flo64; // Double precision floating point
|
||||
typedef double * pFlo64;
|
||||
typedef float Flo32; // Single precision floating point
|
||||
typedef float * pFlo32;
|
||||
typedef signed long long Int64S; // Signed 64 bit quantity
|
||||
typedef signed long long * pInt64S;
|
||||
typedef unsigned long long Int64U; // Unsigned 64 bit quantity
|
||||
typedef unsigned long long * pInt64U;
|
||||
typedef signed int Int32S; // Signed 32 bit quantity
|
||||
typedef signed int * pInt32S;
|
||||
typedef unsigned int Int32U; // Unsigned 32 bit quantity
|
||||
typedef unsigned int * pInt32U;
|
||||
typedef signed short Int16S; // Signed 16 bit quantity
|
||||
typedef signed short * pInt16S;
|
||||
typedef unsigned short Int16U; // Unsigned 16 bit quantity
|
||||
typedef unsigned short * pInt16U;
|
||||
typedef signed char Int8S; // Signed 8 bit quantity
|
||||
typedef signed char * pInt8S;
|
||||
typedef unsigned char Int8U; // Unsigned 8 bit quantity
|
||||
typedef unsigned char * pInt8U;
|
||||
typedef unsigned char Boolean; // Boolean
|
||||
typedef unsigned char * pBoolean;
|
||||
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define _2BL(a) (Int8U)(a),(Int8U)(a>>8)
|
||||
#define _2BB(a) (Int8U)(a>>8),(Int8U)(a),
|
||||
#define _3BL(a) (Int8U)(a),(Int8U)(a>>8),(Int8U)(a>>16)
|
||||
#define _3BB(a) (Int8U)(a>>16),(Int8U)(a>>8),(Int8U)(a)
|
||||
#define _4BL(a) (Int8U)(a),(Int8U)(a>>8),(Int8U)(a>>16),(Int8U)(a>>24)
|
||||
#define _4BB(a) (Int8U)(a>>24),(Int8U)(a>>16),(Int8U)(a>>8),(Int8U)(a)
|
||||
|
||||
typedef void * (*CommUserFpnt_t)(void *);
|
||||
typedef void (*VoidFpnt_t)(void);
|
||||
|
||||
// Atomic exchange of data between a memory cell and a register
|
||||
// return value of the memory cell
|
||||
//inline Int32U AtomicExchange (Int32U State, pInt32U Flag)
|
||||
//{
|
||||
// asm("swp r0, r0, [r1]");
|
||||
// return(State);
|
||||
//}
|
||||
|
||||
#define LongToBin(n) (((n >> 21) & 0x80) | \
|
||||
((n >> 18) & 0x40) | \
|
||||
((n >> 15) & 0x20) | \
|
||||
((n >> 12) & 0x10) | \
|
||||
((n >> 9) & 0x08) | \
|
||||
((n >> 6) & 0x04) | \
|
||||
((n >> 3) & 0x02) | \
|
||||
((n ) & 0x01))
|
||||
|
||||
#define __BIN(n) LongToBin(0x##n##l)
|
||||
|
||||
#define BIN8(n) __BIN(n)
|
||||
#define BIN(n) __BIN(n)
|
||||
#define BIN16(b1,b2) (( __BIN(b1) << 8) + \
|
||||
__BIN(b2))
|
||||
#define BIN32(b1,b2,b3,b4) ((((u32_t)__BIN(b1)) << 24ul) + \
|
||||
(((u32_t)__BIN(b2)) << 16ul) + \
|
||||
(((u32_t)__BIN(b3)) << 8ul) + \
|
||||
(u32_t)__BIN(b4))
|
||||
|
||||
#endif // __ARM_COMM_DEF_H
|
||||
@@ -0,0 +1,293 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** This file defines the board specific definition
|
||||
**
|
||||
** Used with ARM IAR C/C++ Compiler and Assembler.
|
||||
**
|
||||
** (c) Copyright IAR Systems 2005
|
||||
**
|
||||
** $Revision: 1.4 $
|
||||
**
|
||||
***************************************************************************/
|
||||
#include "arm_comm.h"
|
||||
|
||||
#ifndef __BOARD_H
|
||||
#define __BOARD_H
|
||||
|
||||
#define I_RC_OSC_FREQ (4000000)
|
||||
#define MAIN_OSC_FREQ (12000000)
|
||||
#define RTC_OSC_FREQ (32768UL)
|
||||
|
||||
#if defined(IAR_LPC_2378_SK)
|
||||
|
||||
// USB Link LED
|
||||
#define USB_LINK_LED_MASK (1UL<<13)
|
||||
#define USB_LINK_LED_DIR IO0DIR
|
||||
#define USB_LINK_LED_FDIR FIO0DIR
|
||||
#define USB_LINK_LED_SET IO0SET
|
||||
#define USB_LINK_LED_FSET FIO0SET
|
||||
#define USB_LINK_LED_CLR IO0CLR
|
||||
#define USB_LINK_LED_FCLR FIO0CLR
|
||||
#define USB_LINK_LED_IO IO0PIN
|
||||
#define USB_LINK_LED_FIO FIO0PIN
|
||||
|
||||
// LCD Backlight
|
||||
#define LCD_BL_MASK (1UL<<26)
|
||||
#define LCD_BL_DIR IO1DIR
|
||||
#define LCD_BL_FDIR FIO1DIR
|
||||
#define LCD_BL_SET IO1SET
|
||||
#define LCD_BL_FSET FIO1SET
|
||||
#define LCD_BL_CLR IO1CLR
|
||||
#define LCD_BL_FCLR FIO1CLR
|
||||
#define LCD_BL_IO IO1PIN
|
||||
#define LCD_BL_FIO FIO1PIN
|
||||
// LCD Reset
|
||||
#define LCD_RST_MASK (1UL<<25)
|
||||
#define LCD_RST_FDIR FIO3DIR
|
||||
#define LCD_RST_FSET FIO3SET
|
||||
#define LCD_RST_FCLR FIO3CLR
|
||||
#define LCD_RST_FIO FIO3PIN
|
||||
// LCD CS
|
||||
#define LCD_CS_MASK (1UL<<21)
|
||||
#define LCD_CS_DIR IO1DIR
|
||||
#define LCD_CS_FDIR FIO1DIR
|
||||
#define LCD_CS_SET IO1SET
|
||||
#define LCD_CS_FSET FIO1SET
|
||||
#define LCD_CS_CLR IO1CLR
|
||||
#define LCD_CS_FCLR FIO1CLR
|
||||
#define LCD_CS_IO IO1PIN
|
||||
#define LCD_CS_FIO FIO1PIN
|
||||
|
||||
// Buttons
|
||||
#define B1_MASK (1UL<<29)
|
||||
#define B1_DIR IO0DIR
|
||||
#define B1_FDIR FIO0DIR
|
||||
#define B1_IO IO0PIN
|
||||
#define B1_FIO FIO0PIN
|
||||
|
||||
#define B2_MASK (1UL<<18)
|
||||
#define B2_DIR IO0DIR
|
||||
#define B2_FDIR FIO0DIR
|
||||
#define B2_IO IO0PIN
|
||||
#define B2_FIO FIO0PIN
|
||||
|
||||
// Joystick
|
||||
#define JS_RIGHT_MASK (1UL << 22)
|
||||
#define JS_LEFT_MASK (1UL << 27)
|
||||
#define JS_UP_MASK (1UL << 18)
|
||||
#define JS_DOWN_MASK (1UL << 19)
|
||||
#define JS_CENTER_MASK (1UL << 25)
|
||||
#define JS_DIR IO1DIR
|
||||
#define JS_FDIR FIO1DIR
|
||||
#define JS_IO IO1PIN
|
||||
#define JS_FIO FIO1PIN
|
||||
|
||||
// MMC/SD card switches
|
||||
// Card present
|
||||
#define MMC_CP_MASK (1UL << 17)
|
||||
#define MMC_CP_DIR IO0DIR
|
||||
#define MMC_CP_FDIR FIO0DIR
|
||||
#define MMC_CP_IO IO0PIN
|
||||
#define MMC_CP_FIO FIO0PIN
|
||||
#define MMC_CP_MODE PINMODE1_bit.P0_17
|
||||
|
||||
// Card write protect
|
||||
#define MMC_WP_MASK (1UL << 29)
|
||||
#define MMC_WP_DIR IO1DIR
|
||||
#define MMC_WP_FDIR FIO1DIR
|
||||
#define MMC_WP_IO IO1PIN
|
||||
#define MMC_WP_FIO FIO1PIN
|
||||
#define MMC_WP_MODE PINMODE3_bit.P1_29
|
||||
|
||||
//MMA
|
||||
#define X_CHANNEL 1
|
||||
#define X_CHANNEL_SEL PINSEL1_bit.P0_24
|
||||
#define Y_CHANNEL 0
|
||||
#define Y_CHANNEL_SEL PINSEL1_bit.P0_23
|
||||
#define Z_CHANNEL 6
|
||||
#define Z_CHANNEL_SEL PINSEL0_bit.P0_12
|
||||
|
||||
// Analog trim
|
||||
#define ANALOG_TRIM_CHANNEL 5
|
||||
#define ANALOG_TRIM_CHANNEL_SEL PINSEL3_bit.P1_31
|
||||
|
||||
// MIC Input
|
||||
#define MIC_IN_CHANNEL 3
|
||||
#define MIC_IN_CHANNEL_SEL PINMODE1_bit.P0_25
|
||||
|
||||
// Check for board revision.
|
||||
// The board with PHY routing mistake have 4.7k resistor on port P0.21 and
|
||||
// internal pull-up can't set logical 1.
|
||||
// To fix routing mistake U4's pin 9 must be swaped with pin 22 and add pull
|
||||
// down 1k resistor on a pin 9.
|
||||
#define BOARD_BUG_CTRL PINMODE1_bit.P0_21
|
||||
#define BOARD_BUG_FDATA FIO0PIN_bit.P0_21
|
||||
#define BOARD_BUG_DATA IO0PIN_bit.P0_21
|
||||
|
||||
#elif defined(IAR_LPC_P2378_SK)
|
||||
|
||||
// USB Link LED
|
||||
#define USB_LINK_LED_MASK (1UL<<13)
|
||||
#define USB_LINK_LED_DIR IO0DIR
|
||||
#define USB_LINK_LED_FDIR FIO0DIR
|
||||
#define USB_LINK_LED_SET IO0SET
|
||||
#define USB_LINK_LED_FSET FIO0SET
|
||||
#define USB_LINK_LED_CLR IO0CLR
|
||||
#define USB_LINK_LED_FCLR FIO0CLR
|
||||
#define USB_LINK_LED_IO IO0PIN
|
||||
#define USB_LINK_LED_FIO FIO0PIN
|
||||
|
||||
// Status LED
|
||||
#define STATUS_LED_MASK (1UL<<19)
|
||||
#define STATUS_LED_DIR IO1DIR
|
||||
#define STATUS_LED_FDIR FIO1DIR
|
||||
#define STATUS_LED_SET IO1SET
|
||||
#define STATUS_LED_FSET FIO1SET
|
||||
#define STATUS_LED_CLR IO1CLR
|
||||
#define STATUS_LED_FCLR FIO1CLR
|
||||
#define STATUS_LED_IO IO1PIN
|
||||
#define STATUS_LED_FIO FIO1PIN
|
||||
|
||||
// Buttons
|
||||
#define B1_MASK (1UL<<30)
|
||||
#define B1_DIR IO0DIR
|
||||
#define B1_FDIR FIO0DIR
|
||||
#define B1_IO IO0PIN
|
||||
#define B1_FIO FIO0PIN
|
||||
|
||||
#define B2_MASK (1UL<<6)
|
||||
#define B2_DIR IO0DIR
|
||||
#define B2_FDIR FIO0DIR
|
||||
#define B2_IO IO0PIN
|
||||
#define B2_FIO FIO0PIN
|
||||
|
||||
// MMC/SD card switches
|
||||
// Card present
|
||||
#define MMC_CP_MASK (1UL << 29)
|
||||
#define MMC_CP_DIR IO0DIR
|
||||
#define MMC_CP_FDIR FIO0DIR
|
||||
#define MMC_CP_IO IO0PIN
|
||||
#define MMC_CP_FIO FIO0PIN
|
||||
#define MMC_CP_MODE PINMODE1_bit.P0_29
|
||||
|
||||
// Card write protect
|
||||
#define MMC_WP_MASK (1UL << 28)
|
||||
#define MMC_WP_DIR IO1DIR
|
||||
#define MMC_WP_FDIR FIO1DIR
|
||||
#define MMC_WP_IO IO1PIN
|
||||
#define MMC_WP_FIO FIO1PIN
|
||||
#define MMC_WP_MODE PINMODE3_bit.P1_28
|
||||
|
||||
// Check for board revision.
|
||||
// The board with PHY routing mistake have 4.7k resistor on port P0.21 and
|
||||
// internal pull-up can't set logical 1.
|
||||
// To fix routing mistake U4's pin 9 must be swaped with pin 22 and add pull
|
||||
// down 1k resistor on a pin 9.
|
||||
#define BOARD_BUG_CTRL PINMODE1_bit.P0_21
|
||||
#define BOARD_BUG_FDATA FIO0PIN_bit.P0_21
|
||||
#define BOARD_BUG_DATA IO0PIN_bit.P0_21
|
||||
|
||||
#else
|
||||
//#error define type of the board
|
||||
#endif
|
||||
|
||||
// PCLK offset
|
||||
#define WDT_PCLK_OFFSET 0
|
||||
#define TIMER0_PCLK_OFFSET 2
|
||||
#define TIMER1_PCLK_OFFSET 4
|
||||
#define UART0_PCLK_OFFSET 6
|
||||
#define UART1_PCLK_OFFSET 8
|
||||
#define PWM0_PCLK_OFFSET 10
|
||||
#define PWM1_PCLK_OFFSET 12
|
||||
#define I2C0_PCLK_OFFSET 14
|
||||
#define SPI_PCLK_OFFSET 16
|
||||
#define RTC_PCLK_OFFSET 18
|
||||
#define SSP1_PCLK_OFFSET 20
|
||||
#define DAC_PCLK_OFFSET 22
|
||||
#define ADC_PCLK_OFFSET 24
|
||||
#define CAN1_PCLK_OFFSET 26
|
||||
#define CAN2_PCLK_OFFSET 28
|
||||
#define ACF_PCLK_OFFSET 30
|
||||
#define BAT_RAM_PCLK_OFFSET 32
|
||||
#define GPIO_PCLK_OFFSET 34
|
||||
#define PCB_PCLK_OFFSET 36
|
||||
#define I2C1_PCLK_OFFSET 38
|
||||
//#define 40
|
||||
#define SSP0_PCLK_OFFSET 42
|
||||
#define TIMER2_PCLK_OFFSET 44
|
||||
#define TIMER3_PCLK_OFFSET 46
|
||||
#define UART2_PCLK_OFFSET 48
|
||||
#define UART3_PCLK_OFFSET 50
|
||||
#define I2C2_PCLK_OFFSET 52
|
||||
#define I2S_PCLK_OFFSET 54
|
||||
#define MCI_PCLK_OFFSET 56
|
||||
//#define 58
|
||||
#define PCLK_PCLK_OFFSET 60
|
||||
//#define 62
|
||||
|
||||
#define IRQ_FLAG 0x80
|
||||
#define FIQ_FLAG 0x40
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: restore_IRQ
|
||||
* Parameters: unsigned long IFlag
|
||||
* Return: void
|
||||
* Description: Restore I flag state
|
||||
*
|
||||
*************************************************************************/
|
||||
//inline
|
||||
//void restore_IRQ(unsigned long IFlag)
|
||||
//{
|
||||
//unsigned long tmp;
|
||||
// tmp=__get_CPSR();
|
||||
// __set_CPSR(tmp & (IFlag | ~IRQ_FLAG));
|
||||
//}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: disable_IRQ
|
||||
* Parameters:
|
||||
* Return: unsigned long
|
||||
* Description: Disable IRQ and return previous state state of flags I
|
||||
*
|
||||
*************************************************************************/
|
||||
//inline
|
||||
//unsigned long disable_IRQ(void)
|
||||
//{
|
||||
//unsigned long tmp;
|
||||
// tmp=__get_CPSR();
|
||||
// __set_CPSR(tmp | IRQ_FLAG);
|
||||
// return tmp & IRQ_FLAG;
|
||||
//}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: restore_interrupts
|
||||
* Parameters: unsigned long IFlag
|
||||
* Return: void
|
||||
* Description: Restore F,I flag state
|
||||
*
|
||||
*************************************************************************/
|
||||
//inline
|
||||
//void restore_interrupts(unsigned long IFlag)
|
||||
//{
|
||||
//unsigned long tmp;
|
||||
// tmp=__get_CPSR();
|
||||
// __set_CPSR(tmp & (IFlag | ~(IRQ_FLAG | FIQ_FLAG)));
|
||||
//}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: disable_interrupts
|
||||
* Parameters:
|
||||
* Return: unsigned long
|
||||
* Description: Disable interrupts and return previous state state of flags I
|
||||
*
|
||||
*************************************************************************/
|
||||
//inline
|
||||
//unsigned long disable_interrupts(void)
|
||||
//{
|
||||
//unsigned long tmp;
|
||||
// tmp=__get_CPSR();
|
||||
// __set_CPSR(tmp | IRQ_FLAG | FIQ_FLAG);
|
||||
// return tmp;
|
||||
//}
|
||||
|
||||
#endif /* __BOARD_H */
|
||||
@@ -0,0 +1,98 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* Used with ICCARM and AARM.
|
||||
*
|
||||
* (c) Copyright IAR Systems 2006
|
||||
*
|
||||
* File name : clock-arch.c
|
||||
* Description : Implementation of architecture-specific clock functionality
|
||||
*
|
||||
* History :
|
||||
* 1. Date : October 4, 2006
|
||||
* Author : Stanimir Bonev
|
||||
* Description : Create
|
||||
*
|
||||
* $Revision: 1.1.2.3 $
|
||||
**************************************************************************/
|
||||
#include "LPC23xx.h"
|
||||
|
||||
#include "clock-arch.h"
|
||||
#include "ethernet.h"
|
||||
|
||||
volatile clock_time_t Ticks;
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: Tim0Handler
|
||||
* Parameters: none
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Description: Timer 0 interrupt handler
|
||||
*
|
||||
*************************************************************************/
|
||||
static
|
||||
void Timer1IntrHandler (void)
|
||||
{
|
||||
++Ticks;
|
||||
// T0IR_bit.MR0INT = 1;
|
||||
T1IR |= (1 << 1);
|
||||
VICIRQStatus = 0;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: clock_init
|
||||
* Parameters: Int32U IntrPriority
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Description: Timer init
|
||||
*
|
||||
*************************************************************************/
|
||||
void clock_init(Int32U IntrPriority)
|
||||
{
|
||||
Ticks = 0;
|
||||
|
||||
// Init Time0
|
||||
// PCONP_bit.PCTIM0 = 1;
|
||||
PCONP |= (1 << 2); /* Enable Timer 1 CLK */
|
||||
// T0TCR_bit.CE = 0;
|
||||
T1TCR &=~(1 << 0); /* Disable Counter 1 */
|
||||
// T0TCR_bit.CR = 1;
|
||||
T1TCR |= (1 << 1); /* Reset Counter 1 */
|
||||
// T0TCR_bit.CR = 0;
|
||||
T1TCR &=~(1 << 1); /* Relase Reset on Counter 1 */
|
||||
// T0CTCR_bit.CTM = 0;
|
||||
T1CTCR &=~(1 << 0) &~(1 << 1); /* Mode: every rising PCLK edge */
|
||||
|
||||
// T0MCR_bit.MR0I = 1;
|
||||
T1MCR |= (1 << 3); /* Enable Interrupt on MR1 */
|
||||
// T0MCR_bit.MR0R = 1;
|
||||
T1MCR |= (1 << 4); /* Enable reset on MR1 */
|
||||
// T0MCR_bit.MR0S = 0;
|
||||
T1MCR &=~(1 << 5); /* Disable stop on MR1 */
|
||||
|
||||
T1PR = 0; /* set timer 1 period */
|
||||
|
||||
T1MR0 = SYS_GetFpclk(TIMER0_PCLK_OFFSET)/(TICK_PER_SEC);
|
||||
// init timer 0 interrupt
|
||||
// T0IR_bit.MR0INT = 1;
|
||||
T1IR |= (1 << 1); /* clear pending interrupt */
|
||||
VIC_SetVectoredIRQ(Timer1IntrHandler,IntrPriority,VIC_CHAN_NUM_Timer1);
|
||||
VICIntEnable |= 1UL << VIC_CHAN_NUM_Timer1;
|
||||
// T0TCR_bit.CE = 1;
|
||||
T1TCR |= (1 << 0); /* Enable Counter */
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: clock_init
|
||||
* Parameters: none
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Description: The current clock time, measured in system ticks
|
||||
*
|
||||
*************************************************************************/
|
||||
clock_time_t clock_time(void)
|
||||
{
|
||||
return(Ticks);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* Used with ICCARM and AARM.
|
||||
*
|
||||
* (c) Copyright IAR Systems 2006
|
||||
*
|
||||
* File name : clock-arch.h
|
||||
* Description : Implementation of architecture-specific clock
|
||||
* functionality include file
|
||||
*
|
||||
* History :
|
||||
* 1. Date : October 4, 2006
|
||||
* Author : Stanimir Bonev
|
||||
* Description : Create
|
||||
*
|
||||
* $Revision: 1.1.2.3 $
|
||||
**************************************************************************/
|
||||
#include "includes.h"
|
||||
|
||||
#ifndef __CLOCK_ARCH_H__
|
||||
#define __CLOCK_ARCH_H__
|
||||
|
||||
#define TICK_PER_SEC 100
|
||||
|
||||
typedef Int32U clock_time_t;
|
||||
|
||||
#define CLOCK_CONF_SECOND TICK_PER_SEC
|
||||
|
||||
extern Int32U SYS_GetFpclk(Int32U Periphery);
|
||||
extern void VIC_SetVectoredIRQ(void(*pIRQSub)(), unsigned int Priority,
|
||||
unsigned int VicIntSource);
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: Tim0Handler
|
||||
* Parameters: none
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Description: Timer 0 interrupt handler
|
||||
*
|
||||
*************************************************************************/
|
||||
static
|
||||
void Timer1IntrHandler (void);
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: clock_init
|
||||
* Parameters: Int32U IntrPriority
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Description: Timer init
|
||||
*
|
||||
*************************************************************************/
|
||||
//void clock_init(Int32U IntrPriority);
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: clock_init
|
||||
* Parameters: none
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Description: The current clock time, measured in system ticks
|
||||
*
|
||||
*************************************************************************/
|
||||
clock_time_t clock_time(void);
|
||||
|
||||
#endif /* __CLOCK_ARCH_H__ */
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* \defgroup clock Clock interface
|
||||
*
|
||||
* The clock interface is the interface between the \ref timer "timer library"
|
||||
* and the platform specific clock functionality. The clock
|
||||
* interface must be implemented for each platform that uses the \ref
|
||||
* timer "timer library".
|
||||
*
|
||||
* The clock interface does only one this: it measures time. The clock
|
||||
* interface provides a macro, CLOCK_SECOND, which corresponds to one
|
||||
* second of system time.
|
||||
*
|
||||
* \sa \ref timer "Timer library"
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: clock.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
#ifndef __CLOCK_H__
|
||||
#define __CLOCK_H__
|
||||
|
||||
#include "clock-arch.h"
|
||||
|
||||
/**
|
||||
* Initialize the clock library.
|
||||
*
|
||||
* This function initializes the clock library and should be called
|
||||
* from the main() function of the system.
|
||||
*
|
||||
*/
|
||||
//void clock_init(Int32U IntrPriority);
|
||||
|
||||
/**
|
||||
* Get the current clock time.
|
||||
*
|
||||
* This function returns the current system clock time.
|
||||
*
|
||||
* \return The current clock time, measured in system ticks.
|
||||
*/
|
||||
clock_time_t clock_time(void);
|
||||
|
||||
/**
|
||||
* A second, measured in system clock time.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef CLOCK_CONF_SECOND
|
||||
#define CLOCK_SECOND CLOCK_CONF_SECOND
|
||||
#else
|
||||
#define CLOCK_SECOND (clock_time_t)32
|
||||
#endif
|
||||
|
||||
#endif /* __CLOCK_H__ */
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,349 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* Used with ICCARM and AARM.
|
||||
*
|
||||
* (c) Copyright IAR Systems 2007
|
||||
*
|
||||
* File name : main.c
|
||||
* Description : Main module
|
||||
*
|
||||
* History :
|
||||
* 1. Date : February 3, 2007
|
||||
* Author : Stanimir Bonev
|
||||
* Description : Create
|
||||
*
|
||||
* This example project shows how to use the IAR Embedded Workbench for ARM
|
||||
* to develop code for the IAR LPC-2378-SK board.
|
||||
* It implements WEB server.
|
||||
* The default IP address is:
|
||||
* 192.168.0.100
|
||||
* The physical MAC address is (defined in uipopt.h):
|
||||
* 00-ff-ff-ff-ff-ff
|
||||
*
|
||||
* Jumpers:
|
||||
* PWR_SEL - depending of power source
|
||||
* RST_E - unfilled
|
||||
* ISP_E - unfilled
|
||||
*
|
||||
* Note:
|
||||
* After power-up the controller get clock from internal RC oscillator that
|
||||
* is unstable and may fail with J-Link auto detect, therefore adaptive clocking
|
||||
* should always be used. The adaptive clock can be select from menu:
|
||||
* Project->Options..., section Debugger->J-Link/J-Trace JTAG Speed - Adaptive.
|
||||
*
|
||||
**************************************************************************
|
||||
* Copyright (c) 2001-2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
**************************************************************************
|
||||
*
|
||||
* $Revision: 1.0 $
|
||||
*
|
||||
**************************************************************************/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
#define BUF ((struct uip_eth_hdr *)&uip_buf[0])
|
||||
|
||||
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: VIC_SetVectoredIRQ
|
||||
* Parameters: void(*pIRQSub)()
|
||||
* unsigned int VicIrqSlot
|
||||
* unsigned int VicIntSouce
|
||||
*
|
||||
* Return: void
|
||||
*
|
||||
* Description: Init vectored interrupts
|
||||
*
|
||||
*************************************************************************/
|
||||
void VIC_SetVectoredIRQ(void(*pIRQSub)(), unsigned int Priority,
|
||||
unsigned int VicIntSource)
|
||||
{
|
||||
unsigned long volatile *pReg;
|
||||
// load base address of vectored address registers
|
||||
pReg = &VICVectAddr0;
|
||||
// Set Address of callback function to corresponding Slot
|
||||
*(pReg+VicIntSource) = (unsigned long)pIRQSub;
|
||||
// load base address of ctrl registers
|
||||
pReg = &VICVectCntl0;
|
||||
// Set source channel and enable the slot
|
||||
*(pReg+VicIntSource) = Priority;
|
||||
// Clear FIQ select bit
|
||||
VICIntSelect &= ~(1 << VicIntSource);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: GpioInit
|
||||
* Parameters: void
|
||||
* Return: void
|
||||
*
|
||||
* Description: Reset all GPIO pins to default: primary function
|
||||
*
|
||||
*************************************************************************/
|
||||
void GpioInit(void)
|
||||
{
|
||||
// Set to inputs
|
||||
IODIR0 = \
|
||||
IODIR1 = \
|
||||
FIO0DIR = \
|
||||
FIO1DIR = \
|
||||
FIO2DIR = \
|
||||
FIO3DIR = \
|
||||
FIO4DIR = 0;
|
||||
|
||||
// Enable Fast GPIO0,1
|
||||
// SCS_bit.GPIOM = 1;
|
||||
SCS |= (1 << 0);
|
||||
|
||||
// clear mask registers
|
||||
FIO0MASK =\
|
||||
FIO1MASK =\
|
||||
FIO2MASK =\
|
||||
FIO3MASK =\
|
||||
FIO4MASK = 0;
|
||||
|
||||
// Reset all GPIO pins to default primary function
|
||||
PINSEL0 =\
|
||||
PINSEL1 =\
|
||||
PINSEL2 =\
|
||||
PINSEL3 =\
|
||||
PINSEL4 =\
|
||||
PINSEL5 =\
|
||||
PINSEL6 =\
|
||||
PINSEL7 =\
|
||||
PINSEL8 =\
|
||||
PINSEL9 =\
|
||||
PINSEL10= 0;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: SYS_GetFsclk
|
||||
* Parameters: none
|
||||
* Return: Int32U
|
||||
*
|
||||
* Description: return Sclk [Hz]
|
||||
*
|
||||
*************************************************************************/
|
||||
Int32U SYS_GetFsclk(void)
|
||||
{
|
||||
Int32U Mul = 1, Div = 1, Osc, Fsclk;
|
||||
// if(PLLSTAT_bit.PLLC)
|
||||
if (PLLSTAT & (1 << 25)) // \TODO is this working??
|
||||
{
|
||||
// when PLL is connected
|
||||
// Mul = PLLSTAT_bit.MSEL + 1;
|
||||
Mul = (PLLSTAT & 0x00007FFF) + 1; // \TODO is this working??
|
||||
// Div = PLLSTAT_bit.NSEL + 1;
|
||||
Div = (PLLSTAT & 0x00FF0000) + 1; // \TODO is this working??
|
||||
|
||||
}
|
||||
|
||||
// Find clk source
|
||||
// switch(CLKSRCSEL_bit.CLKSRC)
|
||||
switch (CLKSRCSEL | 0x00000003) // \TODO is this working??
|
||||
{
|
||||
case 0:
|
||||
Osc = I_RC_OSC_FREQ;
|
||||
break;
|
||||
case 1:
|
||||
Osc = MAIN_OSC_FREQ;
|
||||
break;
|
||||
case 2:
|
||||
Osc = RTC_OSC_FREQ;
|
||||
break;
|
||||
default:
|
||||
Osc = 0;
|
||||
}
|
||||
// Calculate system frequency
|
||||
Fsclk = Osc*Mul*2;
|
||||
Fsclk /= Div*(CCLKCFG+1);
|
||||
return(Fsclk);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: SYS_GetFpclk
|
||||
* Parameters: Int32U Periphery
|
||||
* Return: Int32U
|
||||
*
|
||||
* Description: return Pclk [Hz]
|
||||
*
|
||||
*************************************************************************/
|
||||
Int32U SYS_GetFpclk(Int32U Periphery)
|
||||
{
|
||||
Int32U Fpclk;
|
||||
pInt32U pReg = (pInt32U)((Periphery < 32)?&PCLKSEL0:&PCLKSEL1);
|
||||
|
||||
Periphery &= 0x1F; // %32
|
||||
Fpclk = SYS_GetFsclk();
|
||||
// find peripheral appropriate periphery divider
|
||||
switch((*pReg >> Periphery) & 3)
|
||||
{
|
||||
case 0:
|
||||
Fpclk /= 4;
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
Fpclk /= 2;
|
||||
break;
|
||||
default:
|
||||
Fpclk /= 8;
|
||||
}
|
||||
return(Fpclk);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: Dly100us
|
||||
* Parameters: void *arg
|
||||
* Return: void
|
||||
*
|
||||
* Description: Delay [100us]
|
||||
*
|
||||
*************************************************************************/
|
||||
//void Dly100us(void *arg)
|
||||
//{
|
||||
//volatile Int32U Dly = (Int32U)arg, Dly100;
|
||||
// for(;Dly;Dly--)
|
||||
// for(Dly100 = 350; Dly100; Dly100--);
|
||||
//}
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: main
|
||||
* Parameters: none
|
||||
*
|
||||
* Return: none
|
||||
*
|
||||
* Description: main
|
||||
*
|
||||
*************************************************************************/
|
||||
void ethInit(void)
|
||||
{
|
||||
unsigned int i;
|
||||
uip_ipaddr_t ipaddr;
|
||||
struct timer periodic_timer, arp_timer;
|
||||
|
||||
// Init GPIO
|
||||
GpioInit();
|
||||
|
||||
|
||||
timer_set(&periodic_timer, CLOCK_SECOND / 2);
|
||||
timer_set(&arp_timer, CLOCK_SECOND * 10);
|
||||
|
||||
// Initialize the ethernet device driver
|
||||
while(!tapdev_init());
|
||||
|
||||
ENABLE_INTERRUPTS();
|
||||
|
||||
|
||||
|
||||
// uIP web server
|
||||
// Initialize the uIP TCP/IP stack.
|
||||
uip_init();
|
||||
|
||||
uip_ipaddr(ipaddr, 192,168,1,82);
|
||||
uip_sethostaddr(ipaddr);
|
||||
uip_ipaddr(ipaddr, 192,168,1,2);
|
||||
uip_setdraddr(ipaddr);
|
||||
uip_ipaddr(ipaddr, 255,255,255,0);
|
||||
uip_setnetmask(ipaddr);
|
||||
|
||||
// Initialize the HTTP server.
|
||||
httpd_init();
|
||||
|
||||
while(1)
|
||||
{
|
||||
uip_len = tapdev_read(uip_buf);
|
||||
if(uip_len > 0)
|
||||
{
|
||||
if(BUF->type == htons(UIP_ETHTYPE_IP))
|
||||
{
|
||||
uip_arp_ipin();
|
||||
uip_input();
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if(uip_len > 0)
|
||||
{
|
||||
uip_arp_out();
|
||||
tapdev_send(uip_buf,uip_len);
|
||||
}
|
||||
}
|
||||
else if(BUF->type == htons(UIP_ETHTYPE_ARP))
|
||||
{
|
||||
uip_arp_arpin();
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if(uip_len > 0)
|
||||
{
|
||||
tapdev_send(uip_buf,uip_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(timer_expired(&periodic_timer))
|
||||
{
|
||||
timer_reset(&periodic_timer);
|
||||
for(i = 0; i < UIP_CONNS; i++)
|
||||
{
|
||||
uip_periodic(i);
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if(uip_len > 0)
|
||||
{
|
||||
uip_arp_out();
|
||||
tapdev_send(uip_buf,uip_len);
|
||||
}
|
||||
}
|
||||
#if UIP_UDP
|
||||
for(i = 0; i < UIP_UDP_CONNS; i++) {
|
||||
uip_udp_periodic(i);
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if(uip_len > 0) {
|
||||
uip_arp_out();
|
||||
tapdev_send();
|
||||
}
|
||||
}
|
||||
#endif /* UIP_UDP */
|
||||
/* Call the ARP timer function every 10 seconds. */
|
||||
if(timer_expired(&arp_timer))
|
||||
{
|
||||
timer_reset(&arp_timer);
|
||||
uip_arp_timer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* ethernet.h (c) 2008 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description:
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Nov 11, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void VIC_SetVectoredIRQ(void(*pIRQSub)(), unsigned int Priority,
|
||||
unsigned int VicIntSource);
|
||||
|
||||
void ethInit (void);
|
||||
|
||||
#ifndef ETHERNET_H_
|
||||
#define ETHERNET_H_
|
||||
|
||||
#endif /*ETHERNET_H_*/
|
||||
@@ -0,0 +1,102 @@
|
||||
const char http_http[8] =
|
||||
/* "http://" */
|
||||
{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, };
|
||||
const char http_200[5] =
|
||||
/* "200 " */
|
||||
{0x32, 0x30, 0x30, 0x20, };
|
||||
const char http_301[5] =
|
||||
/* "301 " */
|
||||
{0x33, 0x30, 0x31, 0x20, };
|
||||
const char http_302[5] =
|
||||
/* "302 " */
|
||||
{0x33, 0x30, 0x32, 0x20, };
|
||||
const char http_get[5] =
|
||||
/* "GET " */
|
||||
{0x47, 0x45, 0x54, 0x20, };
|
||||
const char http_10[9] =
|
||||
/* "HTTP/1.0" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, };
|
||||
const char http_11[9] =
|
||||
/* "HTTP/1.1" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, };
|
||||
const char http_content_type[15] =
|
||||
/* "content-type: " */
|
||||
{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, };
|
||||
const char http_texthtml[10] =
|
||||
/* "text/html" */
|
||||
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_location[11] =
|
||||
/* "location: " */
|
||||
{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
|
||||
const char http_host[7] =
|
||||
/* "host: " */
|
||||
{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
|
||||
const char http_crnl[3] =
|
||||
/* "\r\n" */
|
||||
{0xd, 0xa, };
|
||||
const char http_index_html[12] =
|
||||
/* "/index.html" */
|
||||
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_404_html[10] =
|
||||
/* "/404.html" */
|
||||
{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_referer[9] =
|
||||
/* "Referer:" */
|
||||
{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, };
|
||||
const char http_header_200[84] =
|
||||
/* "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
|
||||
const char http_header_404[91] =
|
||||
/* "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
|
||||
const char http_content_type_plain[29] =
|
||||
/* "Content-type: text/plain\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_html[28] =
|
||||
/* "Content-type: text/html\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_css [27] =
|
||||
/* "Content-type: text/css\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_text[28] =
|
||||
/* "Content-type: text/text\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_png [28] =
|
||||
/* "Content-type: image/png\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_gif [28] =
|
||||
/* "Content-type: image/gif\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_jpg [29] =
|
||||
/* "Content-type: image/jpeg\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_binary[43] =
|
||||
/* "Content-type: application/octet-stream\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_html[6] =
|
||||
/* ".html" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_shtml[7] =
|
||||
/* ".shtml" */
|
||||
{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_htm[5] =
|
||||
/* ".htm" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, };
|
||||
const char http_css[5] =
|
||||
/* ".css" */
|
||||
{0x2e, 0x63, 0x73, 0x73, };
|
||||
const char http_png[5] =
|
||||
/* ".png" */
|
||||
{0x2e, 0x70, 0x6e, 0x67, };
|
||||
const char http_gif[5] =
|
||||
/* ".gif" */
|
||||
{0x2e, 0x67, 0x69, 0x66, };
|
||||
const char http_jpg[5] =
|
||||
/* ".jpg" */
|
||||
{0x2e, 0x6a, 0x70, 0x67, };
|
||||
const char http_text[5] =
|
||||
/* ".txt" */
|
||||
{0x2e, 0x74, 0x78, 0x74, };
|
||||
const char http_txt[5] =
|
||||
/* ".txt" */
|
||||
{0x2e, 0x74, 0x78, 0x74, };
|
||||
@@ -0,0 +1,34 @@
|
||||
extern const char http_http[8];
|
||||
extern const char http_200[5];
|
||||
extern const char http_301[5];
|
||||
extern const char http_302[5];
|
||||
extern const char http_get[5];
|
||||
extern const char http_10[9];
|
||||
extern const char http_11[9];
|
||||
extern const char http_content_type[15];
|
||||
extern const char http_texthtml[10];
|
||||
extern const char http_location[11];
|
||||
extern const char http_host[7];
|
||||
extern const char http_crnl[3];
|
||||
extern const char http_index_html[12];
|
||||
extern const char http_404_html[10];
|
||||
extern const char http_referer[9];
|
||||
extern const char http_header_200[84];
|
||||
extern const char http_header_404[91];
|
||||
extern const char http_content_type_plain[29];
|
||||
extern const char http_content_type_html[28];
|
||||
extern const char http_content_type_css [27];
|
||||
extern const char http_content_type_text[28];
|
||||
extern const char http_content_type_png [28];
|
||||
extern const char http_content_type_gif [28];
|
||||
extern const char http_content_type_jpg [29];
|
||||
extern const char http_content_type_binary[43];
|
||||
extern const char http_html[6];
|
||||
extern const char http_shtml[7];
|
||||
extern const char http_htm[5];
|
||||
extern const char http_css[5];
|
||||
extern const char http_png[5];
|
||||
extern const char http_gif[5];
|
||||
extern const char http_jpg[5];
|
||||
extern const char http_text[5];
|
||||
extern const char http_txt[5];
|
||||
@@ -0,0 +1,203 @@
|
||||
/**
|
||||
* \addtogroup httpd
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Web server script interface
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2006, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: httpd-cgi.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "uip.h"
|
||||
#include "psock.h"
|
||||
#include "httpd.h"
|
||||
#include "httpd-cgi.h"
|
||||
#include "httpd-fs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
HTTPD_CGI_CALL(file, "file-stats", file_stats);
|
||||
HTTPD_CGI_CALL(tcp, "tcp-connections", tcp_stats);
|
||||
HTTPD_CGI_CALL(net, "net-stats", net_stats);
|
||||
|
||||
static const struct httpd_cgi_call *calls[] = { &file, &tcp, &net, NULL };
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(nullfunction(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
httpd_cgifunction
|
||||
httpd_cgi(char *name)
|
||||
{
|
||||
const struct httpd_cgi_call **f;
|
||||
|
||||
/* Find the matching name in the table, return the function. */
|
||||
for(f = calls; *f != NULL; ++f) {
|
||||
if(strncmp((*f)->name, name, strlen((*f)->name)) == 0) {
|
||||
return (*f)->function;
|
||||
}
|
||||
}
|
||||
return nullfunction;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
generate_file_stats(void *arg)
|
||||
{
|
||||
char *f = (char *)arg;
|
||||
return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE, "%5u", httpd_fs_count(f));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_file_stats, strchr(ptr, ' ') + 1);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static const char closed[] = /* "CLOSED",*/
|
||||
{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
|
||||
static const char syn_rcvd[] = /* "SYN-RCVD",*/
|
||||
{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56,
|
||||
0x44, 0};
|
||||
static const char syn_sent[] = /* "SYN-SENT",*/
|
||||
{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e,
|
||||
0x54, 0};
|
||||
static const char established[] = /* "ESTABLISHED",*/
|
||||
{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48,
|
||||
0x45, 0x44, 0};
|
||||
static const char fin_wait_1[] = /* "FIN-WAIT-1",*/
|
||||
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
|
||||
0x54, 0x2d, 0x31, 0};
|
||||
static const char fin_wait_2[] = /* "FIN-WAIT-2",*/
|
||||
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
|
||||
0x54, 0x2d, 0x32, 0};
|
||||
static const char closing[] = /* "CLOSING",*/
|
||||
{0x43, 0x4c, 0x4f, 0x53, 0x49,
|
||||
0x4e, 0x47, 0};
|
||||
static const char time_wait[] = /* "TIME-WAIT,"*/
|
||||
{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41,
|
||||
0x49, 0x54, 0};
|
||||
static const char last_ack[] = /* "LAST-ACK"*/
|
||||
{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43,
|
||||
0x4b, 0};
|
||||
|
||||
static const char *states[] = {
|
||||
closed,
|
||||
syn_rcvd,
|
||||
syn_sent,
|
||||
established,
|
||||
fin_wait_1,
|
||||
fin_wait_2,
|
||||
closing,
|
||||
time_wait,
|
||||
last_ack};
|
||||
|
||||
|
||||
static unsigned short
|
||||
generate_tcp_stats(void *arg)
|
||||
{
|
||||
struct uip_conn *conn;
|
||||
struct httpd_state *s = (struct httpd_state *)arg;
|
||||
|
||||
conn = &uip_conns[s->count];
|
||||
return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE,
|
||||
"<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
|
||||
htons(conn->lport),
|
||||
htons(conn->ripaddr[0]) >> 8,
|
||||
htons(conn->ripaddr[0]) & 0xff,
|
||||
htons(conn->ripaddr[1]) >> 8,
|
||||
htons(conn->ripaddr[1]) & 0xff,
|
||||
htons(conn->rport),
|
||||
states[conn->tcpstateflags & UIP_TS_MASK],
|
||||
conn->nrtx,
|
||||
conn->timer,
|
||||
(uip_outstanding(conn))? '*':' ',
|
||||
(uip_stopped(conn))? '!':' ');
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
for(s->count = 0; s->count < UIP_CONNS; ++s->count) {
|
||||
if((uip_conns[s->count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_tcp_stats, s);
|
||||
}
|
||||
}
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
generate_net_stats(void *arg)
|
||||
{
|
||||
struct httpd_state *s = (struct httpd_state *)arg;
|
||||
return snprintf((char *)uip_appdata, UIP_APPDATA_SIZE,
|
||||
"%5u\n", ((uip_stats_t *)&uip_stat)[s->count]);
|
||||
}
|
||||
|
||||
static
|
||||
PT_THREAD(net_stats(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
#if UIP_STATISTICS
|
||||
|
||||
for(s->count = 0; s->count < sizeof(uip_stat) / sizeof(uip_stats_t);
|
||||
++s->count) {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_net_stats, s);
|
||||
}
|
||||
|
||||
#endif /* UIP_STATISTICS */
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* \addtogroup httpd
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Web server script interface header file
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: httpd-cgi.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __HTTPD_CGI_H__
|
||||
#define __HTTPD_CGI_H__
|
||||
|
||||
#include "psock.h"
|
||||
#include "httpd.h"
|
||||
|
||||
typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *));
|
||||
|
||||
httpd_cgifunction httpd_cgi(char *name);
|
||||
|
||||
struct httpd_cgi_call {
|
||||
const char *name;
|
||||
const httpd_cgifunction function;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief HTTPD CGI function declaration
|
||||
* \param name The C variable name of the function
|
||||
* \param str The string name of the function, used in the script file
|
||||
* \param function A pointer to the function that implements it
|
||||
*
|
||||
* This macro is used for declaring a HTTPD CGI
|
||||
* function. This function is then added to the list of
|
||||
* HTTPD CGI functions with the httpd_cgi_add() function.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define HTTPD_CGI_CALL(name, str, function) \
|
||||
static PT_THREAD(function(struct httpd_state *, char *)); \
|
||||
static const struct httpd_cgi_call name = {str, function}
|
||||
|
||||
void httpd_cgi_init(void);
|
||||
#endif /* __HTTPD_CGI_H__ */
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd-fs.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
|
||||
#include "httpd.h"
|
||||
#include "httpd-fs.h"
|
||||
#include "httpd-fsdata.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif /* NULL */
|
||||
|
||||
#include "httpd-fsdata.c"
|
||||
|
||||
#if HTTPD_FS_STATISTICS
|
||||
static u16_t count[HTTPD_FS_NUMFILES];
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static u8_t
|
||||
httpd_fs_strcmp(const char *str1, const char *str2)
|
||||
{
|
||||
u8_t i;
|
||||
i = 0;
|
||||
loop:
|
||||
|
||||
if(str2[i] == 0 ||
|
||||
str1[i] == '\r' ||
|
||||
str1[i] == '\n') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(str1[i] != str2[i]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
++i;
|
||||
goto loop;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int
|
||||
httpd_fs_open(const char *name, struct httpd_fs_file *file)
|
||||
{
|
||||
#if HTTPD_FS_STATISTICS
|
||||
u16_t i = 0;
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
struct httpd_fsdata_file_noconst *f;
|
||||
|
||||
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
||||
f != NULL;
|
||||
f = (struct httpd_fsdata_file_noconst *)f->next) {
|
||||
|
||||
if(httpd_fs_strcmp(name, f->name) == 0) {
|
||||
file->data = f->data;
|
||||
file->len = f->len;
|
||||
#if HTTPD_FS_STATISTICS
|
||||
++count[i];
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
return 1;
|
||||
}
|
||||
#if HTTPD_FS_STATISTICS
|
||||
++i;
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_fs_init(void)
|
||||
{
|
||||
#if HTTPD_FS_STATISTICS
|
||||
u16_t i;
|
||||
for(i = 0; i < HTTPD_FS_NUMFILES; i++) {
|
||||
count[i] = 0;
|
||||
}
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if HTTPD_FS_STATISTICS
|
||||
u16_t httpd_fs_count
|
||||
(char *name)
|
||||
{
|
||||
struct httpd_fsdata_file_noconst *f;
|
||||
u16_t i;
|
||||
|
||||
i = 0;
|
||||
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
||||
f != NULL;
|
||||
f = (struct httpd_fsdata_file_noconst *)f->next) {
|
||||
|
||||
if(httpd_fs_strcmp(name, f->name) == 0) {
|
||||
return count[i];
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd-fs.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
#ifndef __HTTPD_FS_H__
|
||||
#define __HTTPD_FS_H__
|
||||
|
||||
#define HTTPD_FS_STATISTICS 1
|
||||
|
||||
struct httpd_fs_file {
|
||||
char *data;
|
||||
int len;
|
||||
};
|
||||
|
||||
/* file must be allocated by caller and will be filled in
|
||||
by the function. */
|
||||
int httpd_fs_open(const char *name, struct httpd_fs_file *file);
|
||||
|
||||
#ifdef HTTPD_FS_STATISTICS
|
||||
#if HTTPD_FS_STATISTICS == 1
|
||||
u16_t httpd_fs_count(char *name);
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
|
||||
void httpd_fs_init(void);
|
||||
|
||||
#endif /* __HTTPD_FS_H__ */
|
||||
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<body bgcolor="white">
|
||||
<center>
|
||||
<h1>404 - file not found</h1>
|
||||
<h3>Go <a href="/">here</a> instead.</h3>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 196 B |
@@ -0,0 +1,35 @@
|
||||
%!: /header.html
|
||||
<h1>File statistics</h1>
|
||||
<center>
|
||||
<table width="300">
|
||||
<tr><td><a href="/index.html">/index.html</a></td>
|
||||
<td>%! file-stats /index.html
|
||||
</td><td><img src="/fade.png" height=10 width=%! file-stats /index.html
|
||||
> </td></tr>
|
||||
<tr><td><a href="/files.shtml">/files.shtml</a></td>
|
||||
<td>%! file-stats /files.shtml
|
||||
</td><td><img src="/fade.png" height=10 width=%! file-stats /files.shtml
|
||||
> </td></tr>
|
||||
<tr><td><a href="/tcp.shtml">/tcp.shtml</a></td>
|
||||
<td>%! file-stats /tcp.shtml
|
||||
</td><td><img src="/fade.png" height=10 width=%! file-stats /tcp.shtml
|
||||
> </td></tr>
|
||||
<tr><td><a href="/stats.shtml">/stats.shtml</a></td>
|
||||
<td>%! file-stats /stats.shtml
|
||||
</td><td><img src="/fade.png" height=10 width=%! file-stats /stats.shtml
|
||||
> </td></tr>
|
||||
<tr><td><a href="/style.css">/style.css</a></td>
|
||||
<td>%! file-stats /style.css
|
||||
</td><td><img src="/fade.png" height=10 width=%! file-stats /style.css
|
||||
> </td></tr>
|
||||
<tr><td><a href="/404.html">/404.html</a></td>
|
||||
<td>%! file-stats /404.html
|
||||
</td><td><img src="/fade.png" height=10 width=%! file-stats /404.html
|
||||
> </td></tr>
|
||||
<tr><td><a href="/fade.png">/fade.png</a></td>
|
||||
<td>%! file-stats /fade.png
|
||||
</td><td><img src="/fade.png" height=10 width=%! file-stats /fade.png
|
||||
> </td></tr>
|
||||
</table>
|
||||
</center>
|
||||
%!: /footer.html
|
||||
@@ -0,0 +1,2 @@
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Welcome to the uIP web server!</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
</head>
|
||||
<body bgcolor="#fffeec" text="black">
|
||||
|
||||
<div class="menu">
|
||||
<div class="menubox"><a href="/">Front page</a></div>
|
||||
<div class="menubox"><a href="files.shtml">File statistics</a></div>
|
||||
<div class="menubox"><a href="stats.shtml">Network statistics</a></div>
|
||||
<div class="menubox"><a href="tcp.shtml">Network
|
||||
connections</a></div>
|
||||
<br>
|
||||
</div>
|
||||
|
||||
<div class="contentblock">
|
||||
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Welcome to the uIP web server!</title>
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
</head>
|
||||
<body bgcolor="#fffeec" text="black">
|
||||
|
||||
<div class="menu">
|
||||
<div class="menubox"><a href="/">Front page</a></div>
|
||||
<div class="menubox"><a href="files.shtml">File statistics</a></div>
|
||||
<div class="menubox"><a href="stats.shtml">Network statistics</a></div>
|
||||
<div class="menubox"><a href="tcp.shtml">Network
|
||||
connections</a></div>
|
||||
<br>
|
||||
</div>
|
||||
|
||||
<div class="contentblock">
|
||||
<p>
|
||||
These web pages are served by a small web server running on top of
|
||||
the <a href="http://www.sics.se/~adam/uip/">uIP embedded TCP/IP
|
||||
stack</a>.
|
||||
</p>
|
||||
<p>
|
||||
Click on the links above for web server statistics.
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,5 @@
|
||||
%!: /header.html
|
||||
<h1>System processes</h1><br><table width="100%">
|
||||
<tr><th>ID</th><th>Name</th><th>Priority</th><th>Poll handler</th><th>Event handler</th><th>Procstate</th></tr>
|
||||
%! processes
|
||||
%!: /footer.html
|
||||
@@ -0,0 +1,31 @@
|
||||
%!: /header.html
|
||||
<h1>Network statistics</h1>
|
||||
<center>
|
||||
<table width="300" border="0">
|
||||
<tr><td><pre>
|
||||
IP Packets received
|
||||
Packets sent
|
||||
Packets dropped
|
||||
IP errors IP version/header length
|
||||
IP length, high byte
|
||||
IP length, low byte
|
||||
IP fragments
|
||||
Header checksum
|
||||
Wrong protocol
|
||||
ICMP Packets received
|
||||
Packets sent
|
||||
Packets dropped
|
||||
Type errors
|
||||
TCP Packets received
|
||||
Packets sent
|
||||
Packets dropped
|
||||
Checksum errors
|
||||
Data packets without ACKs
|
||||
Resets
|
||||
Retransmissions
|
||||
No connection avaliable
|
||||
Connection attempts to closed ports
|
||||
</pre></td><td><pre>%! net-stats
|
||||
</pre></table>
|
||||
</center>
|
||||
%!: /footer.html
|
||||
@@ -0,0 +1,92 @@
|
||||
h1
|
||||
{
|
||||
text-align: center;
|
||||
font-size:14pt;
|
||||
font-family:arial,helvetica;
|
||||
font-weight:bold;
|
||||
padding:10px;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
|
||||
background-color: #fffeec;
|
||||
color:black;
|
||||
|
||||
font-size:8pt;
|
||||
font-family:arial,helvetica;
|
||||
}
|
||||
|
||||
.menu
|
||||
{
|
||||
margin: 4px;
|
||||
width:60%;
|
||||
|
||||
padding:2px;
|
||||
|
||||
border: solid 1px;
|
||||
background-color: #fffcd2;
|
||||
text-align:left;
|
||||
|
||||
font-size:9pt;
|
||||
font-family:arial,helvetica;
|
||||
}
|
||||
|
||||
div.menubox
|
||||
{
|
||||
width: 25%;
|
||||
border: 0;
|
||||
float: left;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.contentblock
|
||||
{
|
||||
margin: 4px;
|
||||
width:60%;
|
||||
|
||||
padding:2px;
|
||||
|
||||
border: 1px dotted;
|
||||
background-color: white;
|
||||
|
||||
font-size:8pt;
|
||||
font-family:arial,helvetica;
|
||||
|
||||
}
|
||||
|
||||
p.intro
|
||||
{
|
||||
margin-left:20px;
|
||||
margin-right:20px;
|
||||
|
||||
font-size:10pt;
|
||||
/* font-weight:bold; */
|
||||
font-family:arial,helvetica;
|
||||
}
|
||||
|
||||
p.clink
|
||||
{
|
||||
font-size:12pt;
|
||||
font-family:courier,monospace;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
p.clink9
|
||||
{
|
||||
font-size:9pt;
|
||||
font-family:courier,monospace;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
|
||||
p
|
||||
{
|
||||
padding-left:10px;
|
||||
}
|
||||
|
||||
p.right
|
||||
{
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
%!: /header.html
|
||||
<h1>Current connections</h1><br><table width="100%">
|
||||
<tr><th>Local</th><th>Remote</th><th>State</th><th>Retransmissions</th><th>Timer</th><th>Flags</th></tr>
|
||||
%! tcp-connections
|
||||
%!: /footer.html
|
||||
@@ -0,0 +1,637 @@
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
#include "httpd-fsdata.h"
|
||||
|
||||
|
||||
|
||||
static const unsigned char data_processes_shtml[] = {
|
||||
/* /processes.shtml */
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31,
|
||||
0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72,
|
||||
0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x68,
|
||||
0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62,
|
||||
0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22,
|
||||
0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72,
|
||||
0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x49, 0x44, 0x3c, 0x2f, 0x74,
|
||||
0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4e, 0x61, 0x6d, 0x65,
|
||||
0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50,
|
||||
0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x3c, 0x2f, 0x74,
|
||||
0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50, 0x6f, 0x6c, 0x6c,
|
||||
0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c, 0x2f,
|
||||
0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x45, 0x76, 0x65,
|
||||
0x6e, 0x74, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72,
|
||||
0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x50,
|
||||
0x72, 0x6f, 0x63, 0x73, 0x74, 0x61, 0x74, 0x65, 0x3c, 0x2f,
|
||||
0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25,
|
||||
0x21, 0x20, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65,
|
||||
0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, 0x6f, 0x6f,
|
||||
0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0};
|
||||
|
||||
static const unsigned char data_404_html[] = {
|
||||
/* /404.html */
|
||||
0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x20, 0x20, 0x3c,
|
||||
0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 0x6c,
|
||||
0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 0x22,
|
||||
0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x63, 0x65, 0x6e,
|
||||
0x74, 0x65, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x3c, 0x68, 0x31, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d,
|
||||
0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20,
|
||||
0x66, 0x6f, 0x75, 0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x31, 0x3e,
|
||||
0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x68, 0x33,
|
||||
0x3e, 0x47, 0x6f, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65,
|
||||
0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x68, 0x65, 0x72, 0x65,
|
||||
0x3c, 0x2f, 0x61, 0x3e, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x65,
|
||||
0x61, 0x64, 0x2e, 0x3c, 0x2f, 0x68, 0x33, 0x3e, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65,
|
||||
0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64,
|
||||
0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e,
|
||||
0};
|
||||
|
||||
static const unsigned char data_files_shtml[] = {
|
||||
/* /files.shtml */
|
||||
0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31,
|
||||
0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x73, 0x74, 0x61, 0x74,
|
||||
0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x68, 0x31,
|
||||
0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e,
|
||||
0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69,
|
||||
0x64, 0x74, 0x68, 0x3d, 0x22, 0x33, 0x30, 0x30, 0x22, 0x3e,
|
||||
0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c,
|
||||
0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x69,
|
||||
0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22,
|
||||
0x3e, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74,
|
||||
0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64,
|
||||
0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66,
|
||||
0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20,
|
||||
0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d,
|
||||
0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64,
|
||||
0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63, 0x3d,
|
||||
0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67,
|
||||
0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x31,
|
||||
0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25, 0x21,
|
||||
0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74,
|
||||
0x73, 0x20, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68,
|
||||
0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64,
|
||||
0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x72,
|
||||
0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72,
|
||||
0x65, 0x66, 0x3d, 0x22, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73,
|
||||
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x66,
|
||||
0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c,
|
||||
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa,
|
||||
0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c,
|
||||
0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x66,
|
||||
0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c,
|
||||
0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e,
|
||||
0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63, 0x3d, 0x22,
|
||||
0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22,
|
||||
0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d, 0x31, 0x30,
|
||||
0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25, 0x21, 0x20,
|
||||
0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73,
|
||||
0x20, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68,
|
||||
0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64,
|
||||
0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x72,
|
||||
0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72,
|
||||
0x65, 0x66, 0x3d, 0x22, 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73,
|
||||
0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f, 0x74, 0x63, 0x70,
|
||||
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e,
|
||||
0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e,
|
||||
0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74,
|
||||
0x61, 0x74, 0x73, 0x20, 0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73,
|
||||
0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e,
|
||||
0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73,
|
||||
0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e,
|
||||
0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68,
|
||||
0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68,
|
||||
0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73,
|
||||
0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x74, 0x63, 0x70, 0x2e,
|
||||
0x73, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f,
|
||||
0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c,
|
||||
0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 0x61,
|
||||
0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e,
|
||||
0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74,
|
||||
0x6d, 0x6c, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64,
|
||||
0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x25, 0x21, 0x20, 0x66,
|
||||
0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20,
|
||||
0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74,
|
||||
0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74,
|
||||
0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72, 0x63,
|
||||
0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e,
|
||||
0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x3d,
|
||||
0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x25,
|
||||
0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74, 0x61,
|
||||
0x74, 0x73, 0x20, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e,
|
||||
0x73, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f,
|
||||
0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c,
|
||||
0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x73, 0x74, 0x79,
|
||||
0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x2f, 0x73,
|
||||
0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x3c, 0x2f,
|
||||
0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74,
|
||||
0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d,
|
||||
0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x73, 0x74, 0x79,
|
||||
0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0xa, 0x3c, 0x2f, 0x74,
|
||||
0x64, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67,
|
||||
0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64,
|
||||
0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69,
|
||||
0x67, 0x68, 0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64,
|
||||
0x74, 0x68, 0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65,
|
||||
0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x73, 0x74,
|
||||
0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0xa, 0x3e, 0x20,
|
||||
0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e,
|
||||
0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c,
|
||||
0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x34,
|
||||
0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x2f,
|
||||
0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x3c, 0x2f,
|
||||
0x61, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74,
|
||||
0x64, 0x3e, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d,
|
||||
0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x34, 0x30, 0x34,
|
||||
0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x2f, 0x74, 0x64,
|
||||
0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20,
|
||||
0x73, 0x72, 0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65,
|
||||
0x2e, 0x70, 0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67,
|
||||
0x68, 0x74, 0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74,
|
||||
0x68, 0x3d, 0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d,
|
||||
0x73, 0x74, 0x61, 0x74, 0x73, 0x20, 0x2f, 0x34, 0x30, 0x34,
|
||||
0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3e, 0x20, 0x3c, 0x2f,
|
||||
0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c,
|
||||
0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64,
|
||||
0x65, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x3e, 0x2f, 0x66, 0x61,
|
||||
0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0x3c, 0x2f, 0x61, 0x3e,
|
||||
0x3c, 0x2f, 0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e,
|
||||
0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74,
|
||||
0x61, 0x74, 0x73, 0x20, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e,
|
||||
0x70, 0x6e, 0x67, 0xa, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c,
|
||||
0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 0x73, 0x72,
|
||||
0x63, 0x3d, 0x22, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70,
|
||||
0x6e, 0x67, 0x22, 0x20, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74,
|
||||
0x3d, 0x31, 0x30, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d,
|
||||
0x25, 0x21, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x2d, 0x73, 0x74,
|
||||
0x61, 0x74, 0x73, 0x20, 0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e,
|
||||
0x70, 0x6e, 0x67, 0xa, 0x3e, 0x20, 0x3c, 0x2f, 0x74, 0x64,
|
||||
0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x3c, 0x2f, 0x74,
|
||||
0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, 0x63, 0x65,
|
||||
0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20,
|
||||
0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74,
|
||||
0x6d, 0x6c, 0xa, 0};
|
||||
|
||||
static const unsigned char data_footer_html[] = {
|
||||
/* /footer.html */
|
||||
0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa,
|
||||
0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0};
|
||||
|
||||
static const unsigned char data_header_html[] = {
|
||||
/* /header.html */
|
||||
0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20,
|
||||
0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49,
|
||||
0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f,
|
||||
0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20,
|
||||
0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73,
|
||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45,
|
||||
0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
|
||||
0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72,
|
||||
0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34,
|
||||
0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64,
|
||||
0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e,
|
||||
0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f,
|
||||
0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x49, 0x50, 0x20, 0x77,
|
||||
0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21,
|
||||
0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72,
|
||||
0x65, 0x6c, 0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73,
|
||||
0x68, 0x65, 0x65, 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65,
|
||||
0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73,
|
||||
0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x73, 0x74,
|
||||
0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x20,
|
||||
0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64,
|
||||
0x3e, 0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20,
|
||||
0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23,
|
||||
0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x22, 0x20, 0x74, 0x65,
|
||||
0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22,
|
||||
0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20,
|
||||
0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e,
|
||||
0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76,
|
||||
0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65,
|
||||
0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46,
|
||||
0x72, 0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c,
|
||||
0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61,
|
||||
0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f,
|
||||
0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66,
|
||||
0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68,
|
||||
0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20,
|
||||
0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73,
|
||||
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e,
|
||||
0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c,
|
||||
0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62,
|
||||
0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65,
|
||||
0x66, 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73,
|
||||
0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77,
|
||||
0x6f, 0x72, 0x6b, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73,
|
||||
0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f,
|
||||
0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69,
|
||||
0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d,
|
||||
0x65, 0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61,
|
||||
0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70,
|
||||
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65,
|
||||
0x74, 0x77, 0x6f, 0x72, 0x6b, 0xa, 0x20, 0x20, 0x63, 0x6f,
|
||||
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c,
|
||||
0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c,
|
||||
0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0xa, 0x20,
|
||||
0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73,
|
||||
0x73, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
|
||||
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0};
|
||||
|
||||
static const unsigned char data_index_html[] = {
|
||||
/* /index.html */
|
||||
0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20,
|
||||
0x48, 0x54, 0x4d, 0x4c, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49,
|
||||
0x43, 0x20, 0x22, 0x2d, 0x2f, 0x2f, 0x57, 0x33, 0x43, 0x2f,
|
||||
0x2f, 0x44, 0x54, 0x44, 0x20, 0x48, 0x54, 0x4d, 0x4c, 0x20,
|
||||
0x34, 0x2e, 0x30, 0x31, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73,
|
||||
0x69, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2f, 0x2f, 0x45,
|
||||
0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
|
||||
0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72,
|
||||
0x67, 0x2f, 0x54, 0x52, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x34,
|
||||
0x2f, 0x6c, 0x6f, 0x6f, 0x73, 0x65, 0x2e, 0x64, 0x74, 0x64,
|
||||
0x22, 0x3e, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e,
|
||||
0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f,
|
||||
0x20, 0x74, 0x68, 0x65, 0x20, 0x75, 0x49, 0x50, 0x20, 0x77,
|
||||
0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x21,
|
||||
0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x3c, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x72,
|
||||
0x65, 0x6c, 0x3d, 0x22, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x73,
|
||||
0x68, 0x65, 0x65, 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65,
|
||||
0x3d, 0x22, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73,
|
||||
0x22, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x73, 0x74,
|
||||
0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0x22, 0x3e, 0x20,
|
||||
0x20, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64,
|
||||
0x3e, 0xa, 0x20, 0x20, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20,
|
||||
0x62, 0x67, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x23,
|
||||
0x66, 0x66, 0x66, 0x65, 0x65, 0x63, 0x22, 0x20, 0x74, 0x65,
|
||||
0x78, 0x74, 0x3d, 0x22, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x22,
|
||||
0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20,
|
||||
0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e,
|
||||
0x75, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76,
|
||||
0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65,
|
||||
0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x22, 0x3e, 0x46,
|
||||
0x72, 0x6f, 0x6e, 0x74, 0x20, 0x70, 0x61, 0x67, 0x65, 0x3c,
|
||||
0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61,
|
||||
0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f,
|
||||
0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66,
|
||||
0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68,
|
||||
0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x46, 0x69, 0x6c, 0x65, 0x20,
|
||||
0x73, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73,
|
||||
0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e,
|
||||
0xa, 0x20, 0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c,
|
||||
0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d, 0x65, 0x6e, 0x75, 0x62,
|
||||
0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65,
|
||||
0x66, 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73,
|
||||
0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65, 0x74, 0x77,
|
||||
0x6f, 0x72, 0x6b, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69, 0x73,
|
||||
0x74, 0x69, 0x63, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 0x2f,
|
||||
0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x64, 0x69,
|
||||
0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d, 0x22, 0x6d,
|
||||
0x65, 0x6e, 0x75, 0x62, 0x6f, 0x78, 0x22, 0x3e, 0x3c, 0x61,
|
||||
0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x74, 0x63, 0x70,
|
||||
0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0x22, 0x3e, 0x4e, 0x65,
|
||||
0x74, 0x77, 0x6f, 0x72, 0x6b, 0xa, 0x20, 0x20, 0x63, 0x6f,
|
||||
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c,
|
||||
0x2f, 0x61, 0x3e, 0x3c, 0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c,
|
||||
0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c,
|
||||
0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x3d,
|
||||
0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c,
|
||||
0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x70,
|
||||
0x3e, 0xa, 0x20, 0x20, 0x54, 0x68, 0x65, 0x73, 0x65, 0x20,
|
||||
0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 0x65, 0x73, 0x20,
|
||||
0x61, 0x72, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64,
|
||||
0x20, 0x62, 0x79, 0x20, 0x61, 0x20, 0x73, 0x6d, 0x61, 0x6c,
|
||||
0x6c, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76,
|
||||
0x65, 0x72, 0x20, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67,
|
||||
0x20, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x70, 0x20, 0x6f, 0x66,
|
||||
0xa, 0x20, 0x20, 0x74, 0x68, 0x65, 0x20, 0x3c, 0x61, 0x20,
|
||||
0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70,
|
||||
0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63,
|
||||
0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d,
|
||||
0x2f, 0x75, 0x69, 0x70, 0x2f, 0x22, 0x3e, 0x75, 0x49, 0x50,
|
||||
0x20, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20,
|
||||
0x54, 0x43, 0x50, 0x2f, 0x49, 0x50, 0xa, 0x20, 0x20, 0x73,
|
||||
0x74, 0x61, 0x63, 0x6b, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0xa,
|
||||
0x20, 0x20, 0x3c, 0x2f, 0x70, 0x3e, 0xa, 0x20, 0x20, 0x3c,
|
||||
0x70, 0x3e, 0xa, 0x20, 0x20, 0x43, 0x6c, 0x69, 0x63, 0x6b,
|
||||
0x20, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x69,
|
||||
0x6e, 0x6b, 0x73, 0x20, 0x61, 0x62, 0x6f, 0x76, 0x65, 0x20,
|
||||
0x66, 0x6f, 0x72, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 0x65,
|
||||
0x72, 0x76, 0x65, 0x72, 0x20, 0x73, 0x74, 0x61, 0x74, 0x69,
|
||||
0x73, 0x74, 0x69, 0x63, 0x73, 0x2e, 0xa, 0x20, 0x20, 0x3c,
|
||||
0x2f, 0x70, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62,
|
||||
0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d,
|
||||
0x6c, 0x3e, 0xa, 0};
|
||||
|
||||
static const unsigned char data_style_css[] = {
|
||||
/* /style.css */
|
||||
0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0,
|
||||
0x68, 0x31, 0x20, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x74, 0x65,
|
||||
0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20,
|
||||
0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x20, 0x20,
|
||||
0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a,
|
||||
0x31, 0x34, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f,
|
||||
0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a,
|
||||
0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76,
|
||||
0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0xa, 0x20, 0x20, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74,
|
||||
0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0xa, 0x20, 0x20, 0x70,
|
||||
0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x31, 0x30, 0x70,
|
||||
0x78, 0x3b, 0x20, 0xa, 0x7d, 0xa, 0xa, 0x62, 0x6f, 0x64,
|
||||
0x79, 0xa, 0x7b, 0xa, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63,
|
||||
0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f,
|
||||
0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66, 0x65,
|
||||
0x65, 0x63, 0x3b, 0xa, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f,
|
||||
0x72, 0x3a, 0x62, 0x6c, 0x61, 0x63, 0x6b, 0x3b, 0xa, 0xa,
|
||||
0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a,
|
||||
0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79,
|
||||
0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c,
|
||||
0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0xa, 0x7d, 0xa,
|
||||
0xa, 0x2e, 0x6d, 0x65, 0x6e, 0x75, 0xa, 0x7b, 0xa, 0x20,
|
||||
0x20, 0x6d, 0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x34,
|
||||
0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74,
|
||||
0x68, 0x3a, 0x36, 0x30, 0x25, 0x3b, 0xa, 0xa, 0x20, 0x20,
|
||||
0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x32, 0x70,
|
||||
0x78, 0x3b, 0xa, 0x9, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72,
|
||||
0x64, 0x65, 0x72, 0x3a, 0x20, 0x73, 0x6f, 0x6c, 0x69, 0x64,
|
||||
0x20, 0x31, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61,
|
||||
0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63,
|
||||
0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x66, 0x66, 0x66,
|
||||
0x63, 0x64, 0x32, 0x3b, 0xa, 0x20, 0x20, 0x74, 0x65, 0x78,
|
||||
0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x6c, 0x65,
|
||||
0x66, 0x74, 0x3b, 0xa, 0x20, 0x20, 0xa, 0x20, 0x20, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x39,
|
||||
0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74,
|
||||
0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72,
|
||||
0x69, 0x61, 0x6c, 0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74,
|
||||
0x69, 0x63, 0x61, 0x3b, 0x20, 0x20, 0xa, 0x7d, 0xa, 0xa,
|
||||
0x64, 0x69, 0x76, 0x2e, 0x6d, 0x65, 0x6e, 0x75, 0x62, 0x6f,
|
||||
0x78, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74,
|
||||
0x68, 0x3a, 0x20, 0x32, 0x35, 0x25, 0x3b, 0xa, 0x20, 0x20,
|
||||
0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3a, 0x20, 0x30, 0x3b,
|
||||
0xa, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3a, 0x20,
|
||||
0x6c, 0x65, 0x66, 0x74, 0x3b, 0xa, 0x74, 0x65, 0x78, 0x74,
|
||||
0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a, 0x20, 0x63, 0x65,
|
||||
0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x7d, 0xa, 0xa, 0x2e,
|
||||
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x62, 0x6c, 0x6f,
|
||||
0x63, 0x6b, 0xa, 0x7b, 0x20, 0x20, 0xa, 0x20, 0x20, 0x6d,
|
||||
0x61, 0x72, 0x67, 0x69, 0x6e, 0x3a, 0x20, 0x34, 0x70, 0x78,
|
||||
0x3b, 0xa, 0x20, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3a,
|
||||
0x36, 0x30, 0x25, 0x3b, 0xa, 0xa, 0x20, 0x20, 0x70, 0x61,
|
||||
0x64, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x32, 0x70, 0x78, 0x3b,
|
||||
0xa, 0xa, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72,
|
||||
0x3a, 0x20, 0x31, 0x70, 0x78, 0x20, 0x64, 0x6f, 0x74, 0x74,
|
||||
0x65, 0x64, 0x3b, 0xa, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b,
|
||||
0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c,
|
||||
0x6f, 0x72, 0x3a, 0x20, 0x77, 0x68, 0x69, 0x74, 0x65, 0x3b,
|
||||
0xa, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73,
|
||||
0x69, 0x7a, 0x65, 0x3a, 0x38, 0x70, 0x74, 0x3b, 0xa, 0x20,
|
||||
0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69,
|
||||
0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x68,
|
||||
0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x3b, 0x20,
|
||||
0x20, 0xa, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x69, 0x6e,
|
||||
0x74, 0x72, 0x6f, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x6d, 0x61,
|
||||
0x72, 0x67, 0x69, 0x6e, 0x2d, 0x6c, 0x65, 0x66, 0x74, 0x3a,
|
||||
0x32, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x20, 0x20, 0x6d, 0x61,
|
||||
0x72, 0x67, 0x69, 0x6e, 0x2d, 0x72, 0x69, 0x67, 0x68, 0x74,
|
||||
0x3a, 0x32, 0x30, 0x70, 0x78, 0x3b, 0xa, 0xa, 0x20, 0x20,
|
||||
0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a,
|
||||
0x31, 0x30, 0x70, 0x74, 0x3b, 0xa, 0x2f, 0x2a, 0x20, 0x20,
|
||||
0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x77, 0x65, 0x69, 0x67, 0x68,
|
||||
0x74, 0x3a, 0x62, 0x6f, 0x6c, 0x64, 0x3b, 0x20, 0x2a, 0x2f,
|
||||
0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61,
|
||||
0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x61, 0x72, 0x69, 0x61, 0x6c,
|
||||
0x2c, 0x68, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61,
|
||||
0x3b, 0x20, 0x20, 0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x63,
|
||||
0x6c, 0x69, 0x6e, 0x6b, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x66,
|
||||
0x6f, 0x6e, 0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x31,
|
||||
0x32, 0x70, 0x74, 0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e,
|
||||
0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x63,
|
||||
0x6f, 0x75, 0x72, 0x69, 0x65, 0x72, 0x2c, 0x6d, 0x6f, 0x6e,
|
||||
0x6f, 0x73, 0x70, 0x61, 0x63, 0x65, 0x3b, 0x20, 0x20, 0xa,
|
||||
0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69,
|
||||
0x67, 0x6e, 0x3a, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b,
|
||||
0xa, 0x7d, 0xa, 0xa, 0x70, 0x2e, 0x63, 0x6c, 0x69, 0x6e,
|
||||
0x6b, 0x39, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e,
|
||||
0x74, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x3a, 0x39, 0x70, 0x74,
|
||||
0x3b, 0xa, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66,
|
||||
0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x63, 0x6f, 0x75, 0x72,
|
||||
0x69, 0x65, 0x72, 0x2c, 0x6d, 0x6f, 0x6e, 0x6f, 0x73, 0x70,
|
||||
0x61, 0x63, 0x65, 0x3b, 0x20, 0x20, 0xa, 0x20, 0x20, 0x74,
|
||||
0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69, 0x67, 0x6e, 0x3a,
|
||||
0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3b, 0xa, 0x7d, 0xa,
|
||||
0xa, 0xa, 0x70, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x70, 0x61,
|
||||
0x64, 0x64, 0x69, 0x6e, 0x67, 0x2d, 0x6c, 0x65, 0x66, 0x74,
|
||||
0x3a, 0x31, 0x30, 0x70, 0x78, 0x3b, 0xa, 0x7d, 0xa, 0xa,
|
||||
0x70, 0x2e, 0x72, 0x69, 0x67, 0x68, 0x74, 0xa, 0x7b, 0xa,
|
||||
0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69,
|
||||
0x67, 0x6e, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x20,
|
||||
0xa, 0x7d, 0xa, 0xa, 0};
|
||||
|
||||
static const unsigned char data_tcp_shtml[] = {
|
||||
/* /tcp.shtml */
|
||||
0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31,
|
||||
0x3e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x63,
|
||||
0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73,
|
||||
0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c,
|
||||
0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74,
|
||||
0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa,
|
||||
0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4c, 0x6f,
|
||||
0x63, 0x61, 0x6c, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74,
|
||||
0x68, 0x3e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3c, 0x2f,
|
||||
0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x53, 0x74, 0x61,
|
||||
0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68,
|
||||
0x3e, 0x52, 0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69,
|
||||
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x74, 0x68,
|
||||
0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54, 0x69, 0x6d, 0x65, 0x72,
|
||||
0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x46,
|
||||
0x6c, 0x61, 0x67, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c,
|
||||
0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x20, 0x74, 0x63,
|
||||
0x70, 0x2d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66,
|
||||
0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c,
|
||||
0};
|
||||
|
||||
static const unsigned char data_fade_png[] = {
|
||||
/* /fade.png */
|
||||
0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0,
|
||||
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 00, 00,
|
||||
00, 0xd, 0x49, 0x48, 0x44, 0x52, 00, 00, 00, 0x4,
|
||||
00, 00, 00, 0xa, 0x8, 0x2, 00, 00, 00, 0x1c,
|
||||
0x99, 0x68, 0x59, 00, 00, 00, 0x9, 0x70, 0x48, 0x59,
|
||||
0x73, 00, 00, 0xb, 0x13, 00, 00, 0xb, 0x13, 0x1,
|
||||
00, 0x9a, 0x9c, 0x18, 00, 00, 00, 0x7, 0x74, 0x49,
|
||||
0x4d, 0x45, 0x7, 0xd6, 0x6, 0x8, 0x14, 0x1b, 0x39, 0xaf,
|
||||
0x5b, 0xc0, 0xe3, 00, 00, 00, 0x1d, 0x74, 0x45, 0x58,
|
||||
0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 00, 0x43,
|
||||
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74,
|
||||
0x68, 0x20, 0x54, 0x68, 0x65, 0x20, 0x47, 0x49, 0x4d, 0x50,
|
||||
0xef, 0x64, 0x25, 0x6e, 00, 00, 00, 0x3a, 0x49, 0x44,
|
||||
0x41, 0x54, 0x8, 0xd7, 0x75, 0x8c, 0x31, 0x12, 00, 0x10,
|
||||
0x10, 0xc4, 0x2e, 0x37, 0x9e, 0x40, 0x65, 0xfd, 0xff, 0x83,
|
||||
0xf4, 0xa, 0x1c, 0x8d, 0x54, 0x9b, 0xc9, 0xcc, 0x9a, 0x3d,
|
||||
0x90, 0x73, 0x71, 0x67, 0x91, 0xd4, 0x74, 0x36, 0xa9, 0x55,
|
||||
0x1, 0xf8, 0x29, 0x58, 0xc8, 0xbf, 0x48, 0xc4, 0x81, 0x74,
|
||||
0xb, 0xa3, 0xf, 0x7c, 0xdb, 0x4, 0xe8, 0x40, 0x5, 0xdf,
|
||||
0xa1, 0xf3, 0xfc, 0x73, 00, 00, 00, 00, 0x49, 0x45,
|
||||
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0};
|
||||
|
||||
static const unsigned char data_stats_shtml[] = {
|
||||
/* /stats.shtml */
|
||||
0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0xa, 0x3c, 0x68, 0x31,
|
||||
0x3e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x73,
|
||||
0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x3c,
|
||||
0x2f, 0x68, 0x31, 0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74,
|
||||
0x65, 0x72, 0x3e, 0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65,
|
||||
0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x33, 0x30,
|
||||
0x30, 0x22, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d,
|
||||
0x22, 0x30, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72, 0x3e, 0x3c,
|
||||
0x74, 0x64, 0x3e, 0x3c, 0x70, 0x72, 0x65, 0x3e, 0xa, 0x49,
|
||||
0x50, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20,
|
||||
0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x64, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20,
|
||||
0x73, 0x65, 0x6e, 0x74, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64,
|
||||
0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x49, 0x50, 0x20,
|
||||
0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x20, 0x20, 0x20, 0x20,
|
||||
0x49, 0x50, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e,
|
||||
0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x6c, 0x65,
|
||||
0x6e, 0x67, 0x74, 0x68, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x50,
|
||||
0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x2c, 0x20, 0x68,
|
||||
0x69, 0x67, 0x68, 0x20, 0x62, 0x79, 0x74, 0x65, 0xa, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x49, 0x50, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74,
|
||||
0x68, 0x2c, 0x20, 0x6c, 0x6f, 0x77, 0x20, 0x62, 0x79, 0x74,
|
||||
0x65, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x49, 0x50, 0x20, 0x66, 0x72,
|
||||
0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0xa, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x63, 0x68,
|
||||
0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0xa, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x57, 0x72, 0x6f, 0x6e, 0x67, 0x20, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x63, 0x6f, 0x6c, 0xa, 0x49, 0x43, 0x4d, 0x50, 0x9,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65,
|
||||
0x74, 0x73, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65,
|
||||
0x64, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65,
|
||||
0x74, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, 0xa, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64,
|
||||
0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x54, 0x79, 0x70, 0x65, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72,
|
||||
0x73, 0xa, 0x54, 0x43, 0x50, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65,
|
||||
0x74, 0x73, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65,
|
||||
0x64, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x61, 0x63, 0x6b, 0x65,
|
||||
0x74, 0x73, 0x20, 0x73, 0x65, 0x6e, 0x74, 0xa, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, 0x20, 0x64,
|
||||
0x72, 0x6f, 0x70, 0x70, 0x65, 0x64, 0xa, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x43, 0x68, 0x65, 0x63, 0x6b, 0x73, 0x75, 0x6d, 0x20, 0x65,
|
||||
0x72, 0x72, 0x6f, 0x72, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x44,
|
||||
0x61, 0x74, 0x61, 0x20, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74,
|
||||
0x73, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x20,
|
||||
0x41, 0x43, 0x4b, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x52, 0x65,
|
||||
0x73, 0x65, 0x74, 0x73, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x52, 0x65,
|
||||
0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x4e, 0x6f, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x20, 0x61, 0x76, 0x61, 0x6c, 0x69, 0x61,
|
||||
0x62, 0x6c, 0x65, 0xa, 0x9, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||
0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x20, 0x61, 0x74, 0x74, 0x65, 0x6d, 0x70, 0x74, 0x73, 0x20,
|
||||
0x74, 0x6f, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x64, 0x20,
|
||||
0x70, 0x6f, 0x72, 0x74, 0x73, 0xa, 0x3c, 0x2f, 0x70, 0x72,
|
||||
0x65, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x74, 0x64,
|
||||
0x3e, 0x3c, 0x70, 0x72, 0x65, 0x3e, 0x25, 0x21, 0x20, 0x6e,
|
||||
0x65, 0x74, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x73, 0xa, 0x3c,
|
||||
0x2f, 0x70, 0x72, 0x65, 0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62,
|
||||
0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74,
|
||||
0x65, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66,
|
||||
0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c,
|
||||
0xa, 0};
|
||||
/*
|
||||
const struct httpd_fsdata_file file_processes_shtml[] = {{NULL, data_processes_shtml, data_processes_shtml + 17, sizeof(data_processes_shtml) - 17}};
|
||||
|
||||
const struct httpd_fsdata_file file_404_html[] = {{file_processes_shtml, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
|
||||
|
||||
const struct httpd_fsdata_file file_files_shtml[] = {{file_404_html, data_files_shtml, data_files_shtml + 13, sizeof(data_files_shtml) - 13}};
|
||||
|
||||
const struct httpd_fsdata_file file_footer_html[] = {{file_files_shtml, data_footer_html, data_footer_html + 13, sizeof(data_footer_html) - 13}};
|
||||
|
||||
const struct httpd_fsdata_file file_header_html[] = {{file_footer_html, data_header_html, data_header_html + 13, sizeof(data_header_html) - 13}};
|
||||
|
||||
const struct httpd_fsdata_file file_index_html[] = {{file_header_html, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
|
||||
|
||||
const struct httpd_fsdata_file file_style_css[] = {{file_index_html, data_style_css, data_style_css + 11, sizeof(data_style_css) - 11}};
|
||||
|
||||
const struct httpd_fsdata_file file_tcp_shtml[] = {{file_style_css, data_tcp_shtml, data_tcp_shtml + 11, sizeof(data_tcp_shtml) - 11}};
|
||||
|
||||
const struct httpd_fsdata_file file_fade_png[] = {{file_tcp_shtml, data_fade_png, data_fade_png + 10, sizeof(data_fade_png) - 10}};
|
||||
|
||||
const struct httpd_fsdata_file file_stats_shtml[] = {{file_fade_png, data_stats_shtml, data_stats_shtml + 13, sizeof(data_stats_shtml) - 13}};
|
||||
|
||||
#define HTTPD_FS_ROOT file_stats_shtml
|
||||
*/
|
||||
|
||||
const struct httpd_fsdata_file file_processes_shtml = {NULL, (char const*)data_processes_shtml, (char const*)data_processes_shtml + 17, sizeof(data_processes_shtml) - 17};
|
||||
|
||||
const struct httpd_fsdata_file file_404_html = {&file_processes_shtml, (char const*)data_404_html, (char const*)data_404_html + 10, sizeof(data_404_html) - 10};
|
||||
|
||||
const struct httpd_fsdata_file file_files_shtml = {&file_404_html, (char const*)data_files_shtml, (char const*)data_files_shtml + 13, sizeof(data_files_shtml) - 13};
|
||||
|
||||
const struct httpd_fsdata_file file_footer_html = {&file_files_shtml, (char const*)data_footer_html, (char const*)data_footer_html + 13, sizeof(data_footer_html) - 13};
|
||||
|
||||
const struct httpd_fsdata_file file_header_html = {&file_footer_html, (char const*)data_header_html, (char const*)data_header_html + 13, sizeof(data_header_html) - 13};
|
||||
|
||||
const struct httpd_fsdata_file file_index_html = {&file_header_html, (char const*)data_index_html, (char const*)data_index_html + 12, sizeof(data_index_html) - 12};
|
||||
|
||||
const struct httpd_fsdata_file file_style_css = {&file_index_html, (char const*)data_style_css, (char const*)data_style_css + 11, sizeof(data_style_css) - 11};
|
||||
|
||||
const struct httpd_fsdata_file file_tcp_shtml = {&file_style_css, (char const*)data_tcp_shtml, (char const*)data_tcp_shtml + 11, sizeof(data_tcp_shtml) - 11};
|
||||
|
||||
const struct httpd_fsdata_file file_fade_png = {&file_tcp_shtml, (char const*)data_fade_png, (char const*)data_fade_png + 10, sizeof(data_fade_png) - 10};
|
||||
|
||||
const struct httpd_fsdata_file file_stats_shtml = {&file_fade_png, (char const*)data_stats_shtml, (char const*)data_stats_shtml + 13, sizeof(data_stats_shtml) - 13};
|
||||
|
||||
#define HTTPD_FS_ROOT &file_stats_shtml
|
||||
|
||||
#define HTTPD_FS_NUMFILES 10
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd-fsdata.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
#ifndef __HTTPD_FSDATA_H__
|
||||
#define __HTTPD_FSDATA_H__
|
||||
|
||||
#include "uip.h"
|
||||
|
||||
struct httpd_fsdata_file {
|
||||
const struct httpd_fsdata_file *next;
|
||||
const char *name;
|
||||
const char *data;
|
||||
const int len;
|
||||
#ifdef HTTPD_FS_STATISTICS
|
||||
#if HTTPD_FS_STATISTICS == 1
|
||||
u16_t count;
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
};
|
||||
|
||||
struct httpd_fsdata_file_noconst {
|
||||
struct httpd_fsdata_file *next;
|
||||
char *name;
|
||||
char *data;
|
||||
int len;
|
||||
#ifdef HTTPD_FS_STATISTICS
|
||||
#if HTTPD_FS_STATISTICS == 1
|
||||
u16_t count;
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
};
|
||||
|
||||
#endif /* __HTTPD_FSDATA_H__ */
|
||||
@@ -0,0 +1,338 @@
|
||||
/**
|
||||
* \addtogroup apps
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup httpd Web server
|
||||
* @{
|
||||
* The uIP web server is a very simplistic implementation of an HTTP
|
||||
* server. It can serve web pages and files from a read-only ROM
|
||||
* filesystem, and provides a very small scripting language.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Web server
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: httpd.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
|
||||
#include "uip.h"
|
||||
#include "httpd.h"
|
||||
#include "httpd-fs.h"
|
||||
#include "httpd-cgi.h"
|
||||
#include "http-strings.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define STATE_WAITING 0
|
||||
#define STATE_OUTPUT 1
|
||||
|
||||
#define ISO_nl 0x0a
|
||||
#define ISO_space 0x20
|
||||
#define ISO_bang 0x21
|
||||
#define ISO_percent 0x25
|
||||
#define ISO_period 0x2e
|
||||
#define ISO_slash 0x2f
|
||||
#define ISO_colon 0x3a
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
generate_part_of_file(void *state)
|
||||
{
|
||||
struct httpd_state *s = (struct httpd_state *)state;
|
||||
|
||||
if(s->file.len > uip_mss()) {
|
||||
s->len = uip_mss();
|
||||
} else {
|
||||
s->len = s->file.len;
|
||||
}
|
||||
memcpy(uip_appdata, s->file.data, s->len);
|
||||
|
||||
return s->len;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_file(struct httpd_state *s))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
do {
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_part_of_file, s);
|
||||
s->file.len -= s->len;
|
||||
s->file.data += s->len;
|
||||
} while(s->file.len > 0);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_part_of_file(struct httpd_state *s))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_SEND(&s->sout, s->file.data, s->len);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
next_scriptstate(struct httpd_state *s)
|
||||
{
|
||||
char *p;
|
||||
p = strchr(s->scriptptr, ISO_nl) + 1;
|
||||
s->scriptlen -= (unsigned short)(p - s->scriptptr);
|
||||
s->scriptptr = p;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(handle_script(struct httpd_state *s))
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
PT_BEGIN(&s->scriptpt);
|
||||
|
||||
|
||||
while(s->file.len > 0) {
|
||||
|
||||
/* Check if we should start executing a script. */
|
||||
if(*s->file.data == ISO_percent &&
|
||||
*(s->file.data + 1) == ISO_bang) {
|
||||
s->scriptptr = s->file.data + 3;
|
||||
s->scriptlen = s->file.len - 3;
|
||||
if(*(s->scriptptr - 1) == ISO_colon) {
|
||||
httpd_fs_open(s->scriptptr + 1, &s->file);
|
||||
PT_WAIT_THREAD(&s->scriptpt, send_file(s));
|
||||
} else {
|
||||
PT_WAIT_THREAD(&s->scriptpt,
|
||||
httpd_cgi(s->scriptptr)(s, s->scriptptr));
|
||||
}
|
||||
next_scriptstate(s);
|
||||
|
||||
/* The script is over, so we reset the pointers and continue
|
||||
sending the rest of the file. */
|
||||
s->file.data = s->scriptptr;
|
||||
s->file.len = s->scriptlen;
|
||||
} else {
|
||||
/* See if we find the start of script marker in the block of HTML
|
||||
to be sent. */
|
||||
|
||||
if(s->file.len > uip_mss()) {
|
||||
s->len = uip_mss();
|
||||
} else {
|
||||
s->len = s->file.len;
|
||||
}
|
||||
|
||||
if(*s->file.data == ISO_percent) {
|
||||
ptr = strchr(s->file.data + 1, ISO_percent);
|
||||
} else {
|
||||
ptr = strchr(s->file.data, ISO_percent);
|
||||
}
|
||||
if(ptr != NULL &&
|
||||
ptr != s->file.data) {
|
||||
s->len = (int)(ptr - s->file.data);
|
||||
if(s->len >= uip_mss()) {
|
||||
s->len = uip_mss();
|
||||
}
|
||||
}
|
||||
PT_WAIT_THREAD(&s->scriptpt, send_part_of_file(s));
|
||||
s->file.data += s->len;
|
||||
s->file.len -= s->len;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
PT_END(&s->scriptpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_SEND_STR(&s->sout, statushdr);
|
||||
|
||||
ptr = strrchr(s->filename, ISO_period);
|
||||
if(ptr == NULL) {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_binary);
|
||||
} else if(strncmp(http_html, ptr, 5) == 0 ||
|
||||
strncmp(http_shtml, ptr, 6) == 0) {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_html);
|
||||
} else if(strncmp(http_css, ptr, 4) == 0) {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_css);
|
||||
} else if(strncmp(http_png, ptr, 4) == 0) {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_png);
|
||||
} else if(strncmp(http_gif, ptr, 4) == 0) {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_gif);
|
||||
} else if(strncmp(http_jpg, ptr, 4) == 0) {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_jpg);
|
||||
} else {
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_plain);
|
||||
}
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(handle_output(struct httpd_state *s))
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
PT_BEGIN(&s->outputpt);
|
||||
|
||||
if(!httpd_fs_open(s->filename, &s->file)) {
|
||||
httpd_fs_open(http_404_html, &s->file);
|
||||
strcpy(s->filename, http_404_html);
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_headers(s,
|
||||
http_header_404));
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_file(s));
|
||||
} else {
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_headers(s,
|
||||
http_header_200));
|
||||
ptr = strchr(s->filename, ISO_period);
|
||||
if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0) {
|
||||
PT_INIT(&s->scriptpt);
|
||||
PT_WAIT_THREAD(&s->outputpt, handle_script(s));
|
||||
} else {
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_file(s));
|
||||
}
|
||||
}
|
||||
PSOCK_CLOSE(&s->sout);
|
||||
PT_END(&s->outputpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(handle_input(struct httpd_state *s))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sin);
|
||||
|
||||
PSOCK_READTO(&s->sin, ISO_space);
|
||||
|
||||
|
||||
if(strncmp(s->inputbuf, http_get, 4) != 0) {
|
||||
PSOCK_CLOSE_EXIT(&s->sin);
|
||||
}
|
||||
PSOCK_READTO(&s->sin, ISO_space);
|
||||
|
||||
if(s->inputbuf[0] != ISO_slash) {
|
||||
PSOCK_CLOSE_EXIT(&s->sin);
|
||||
}
|
||||
|
||||
if(s->inputbuf[1] == ISO_space) {
|
||||
strncpy(s->filename, http_index_html, sizeof(s->filename));
|
||||
} else {
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
|
||||
strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename));
|
||||
}
|
||||
|
||||
/* httpd_log_file(uip_conn->ripaddr, s->filename);*/
|
||||
|
||||
s->state = STATE_OUTPUT;
|
||||
|
||||
while(1) {
|
||||
PSOCK_READTO(&s->sin, ISO_nl);
|
||||
|
||||
if(strncmp(s->inputbuf, http_referer, 8) == 0) {
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
|
||||
/* httpd_log(&s->inputbuf[9]);*/
|
||||
}
|
||||
}
|
||||
|
||||
PSOCK_END(&s->sin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
handle_connection(struct httpd_state *s)
|
||||
{
|
||||
handle_input(s);
|
||||
if(s->state == STATE_OUTPUT) {
|
||||
handle_output(s);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_appcall(void)
|
||||
{
|
||||
struct httpd_state *s = (struct httpd_state *)&(uip_conn->appstate);
|
||||
|
||||
if(uip_closed() || uip_aborted() || uip_timedout()) {
|
||||
} else if(uip_connected()) {
|
||||
PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1);
|
||||
PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1);
|
||||
PT_INIT(&s->outputpt);
|
||||
s->state = STATE_WAITING;
|
||||
/* timer_set(&s->timer, CLOCK_SECOND * 100);*/
|
||||
s->timer = 0;
|
||||
handle_connection(s);
|
||||
} else if(s != NULL) {
|
||||
if(uip_poll()) {
|
||||
++s->timer;
|
||||
if(s->timer >= 20) {
|
||||
uip_abort();
|
||||
}
|
||||
} else {
|
||||
s->timer = 0;
|
||||
}
|
||||
handle_connection(s);
|
||||
} else {
|
||||
uip_abort();
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Initialize the web server
|
||||
*
|
||||
* This function initializes the web server and should be
|
||||
* called at system boot-up.
|
||||
*/
|
||||
void
|
||||
httpd_init(void)
|
||||
{
|
||||
uip_listen(HTONS(80));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2005, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: httpd.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __HTTPD_H__
|
||||
#define __HTTPD_H__
|
||||
|
||||
#include "psock.h"
|
||||
#include "httpd-fs.h"
|
||||
|
||||
struct httpd_state {
|
||||
unsigned char timer;
|
||||
struct psock sin, sout;
|
||||
struct pt outputpt, scriptpt;
|
||||
char inputbuf[50];
|
||||
char filename[20];
|
||||
char state;
|
||||
struct httpd_fs_file file;
|
||||
int len;
|
||||
char *scriptptr;
|
||||
int scriptlen;
|
||||
|
||||
unsigned short count;
|
||||
};
|
||||
|
||||
void httpd_init(void);
|
||||
void httpd_appcall(void);
|
||||
|
||||
void httpd_log(char *msg);
|
||||
void httpd_log_file(u16_t *requester, char *file);
|
||||
|
||||
#endif /* __HTTPD_H__ */
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* $Id: webserver.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*
|
||||
*/
|
||||
#ifndef __WEBSERVER_H__
|
||||
#define __WEBSERVER_H__
|
||||
|
||||
#include "httpd.h"
|
||||
|
||||
typedef struct httpd_state uip_tcp_appstate_t;
|
||||
/* UIP_APPCALL: the name of the application function. This function
|
||||
must return void and take no arguments (i.e., C type "void
|
||||
appfunc(void)"). */
|
||||
#ifndef UIP_APPCALL
|
||||
#define UIP_APPCALL httpd_appcall
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __WEBSERVER_H__ */
|
||||
@@ -0,0 +1,42 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
**
|
||||
** Master include file
|
||||
**
|
||||
** Used with ARM IAR C/C++ Compiler
|
||||
**
|
||||
** (c) Copyright IAR Systems 2007
|
||||
**
|
||||
** $Revision: 1.0 $
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __INCLUDES_H
|
||||
#define __INCLUDES_H
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "arm_comm.h"
|
||||
#include "board.h"
|
||||
|
||||
#include "lpc23xx_enet.h"
|
||||
|
||||
#include "clock-arch.h"
|
||||
|
||||
#include "timer.h"
|
||||
#include "uip-conf.h"
|
||||
#include "uipopt.h"
|
||||
#include "uip_arp.h"
|
||||
#include "uip.h"
|
||||
|
||||
#include "httpd.h"
|
||||
|
||||
#endif // __INCLUDES_H
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: lc-addrlabels.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup lc
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Implementation of local continuations based on the "Labels as
|
||||
* values" feature of gcc
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* This implementation of local continuations is based on a special
|
||||
* feature of the GCC C compiler called "labels as values". This
|
||||
* feature allows assigning pointers with the address of the code
|
||||
* corresponding to a particular C label.
|
||||
*
|
||||
* For more information, see the GCC documentation:
|
||||
* http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
|
||||
*
|
||||
* Thanks to dividuum for finding the nice local scope label
|
||||
* implementation.
|
||||
*/
|
||||
|
||||
#ifndef __LC_ADDRLABELS_H__
|
||||
#define __LC_ADDRLABELS_H__
|
||||
|
||||
/** \hideinitializer */
|
||||
typedef void * lc_t;
|
||||
|
||||
#define LC_INIT(s) s = NULL
|
||||
|
||||
|
||||
#define LC_RESUME(s) \
|
||||
do { \
|
||||
if(s != NULL) { \
|
||||
goto *s; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define LC_SET(s) \
|
||||
do { ({ __label__ resume; resume: (s) = &&resume; }); }while(0)
|
||||
|
||||
#define LC_END(s)
|
||||
|
||||
#endif /* __LC_ADDRLABELS_H__ */
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: lc-switch.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup lc
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Implementation of local continuations based on switch() statment
|
||||
* \author Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* This implementation of local continuations uses the C switch()
|
||||
* statement to resume execution of a function somewhere inside the
|
||||
* function's body. The implementation is based on the fact that
|
||||
* switch() statements are able to jump directly into the bodies of
|
||||
* control structures such as if() or while() statmenets.
|
||||
*
|
||||
* This implementation borrows heavily from Simon Tatham's coroutines
|
||||
* implementation in C:
|
||||
* http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
|
||||
*/
|
||||
|
||||
#ifndef __LC_SWITCH_H__
|
||||
#define __LC_SWTICH_H__
|
||||
|
||||
/* WARNING! lc implementation using switch() does not work if an
|
||||
LC_SET() is done within another switch() statement! */
|
||||
|
||||
/** \hideinitializer */
|
||||
typedef unsigned short lc_t;
|
||||
|
||||
#define LC_INIT(s) s = 0;
|
||||
|
||||
#define LC_RESUME(s) switch(s) { case 0:
|
||||
|
||||
#define LC_SET(s) s = __LINE__; case __LINE__:
|
||||
|
||||
#define LC_END(s) }
|
||||
|
||||
#endif /* __LC_SWITCH_H__ */
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: lc.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup pt
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup lc Local continuations
|
||||
* @{
|
||||
*
|
||||
* Local continuations form the basis for implementing protothreads. A
|
||||
* local continuation can be <i>set</i> in a specific function to
|
||||
* capture the state of the function. After a local continuation has
|
||||
* been set can be <i>resumed</i> in order to restore the state of the
|
||||
* function at the point where the local continuation was set.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file lc.h
|
||||
* Local continuations
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef DOXYGEN
|
||||
/**
|
||||
* Initialize a local continuation.
|
||||
*
|
||||
* This operation initializes the local continuation, thereby
|
||||
* unsetting any previously set continuation state.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define LC_INIT(lc)
|
||||
|
||||
/**
|
||||
* Set a local continuation.
|
||||
*
|
||||
* The set operation saves the state of the function at the point
|
||||
* where the operation is executed. As far as the set operation is
|
||||
* concerned, the state of the function does <b>not</b> include the
|
||||
* call-stack or local (automatic) variables, but only the program
|
||||
* counter and such CPU registers that needs to be saved.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define LC_SET(lc)
|
||||
|
||||
/**
|
||||
* Resume a local continuation.
|
||||
*
|
||||
* The resume operation resumes a previously set local continuation, thus
|
||||
* restoring the state in which the function was when the local
|
||||
* continuation was set. If the local continuation has not been
|
||||
* previously set, the resume operation does nothing.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define LC_RESUME(lc)
|
||||
|
||||
/**
|
||||
* Mark the end of local continuation usage.
|
||||
*
|
||||
* The end operation signifies that local continuations should not be
|
||||
* used any more in the function. This operation is not needed for
|
||||
* most implementations of local continuation, but is required by a
|
||||
* few implementations.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define LC_END(lc)
|
||||
|
||||
/**
|
||||
* \var typedef lc_t;
|
||||
*
|
||||
* The local continuation type.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#endif /* DOXYGEN */
|
||||
|
||||
#ifndef __LC_H__
|
||||
#define __LC_H__
|
||||
|
||||
#ifdef LC_CONF_INCLUDE
|
||||
#include LC_CONF_INCLUDE
|
||||
#else
|
||||
#include "lc-switch.h"
|
||||
#endif /* LC_CONF_INCLUDE */
|
||||
|
||||
#endif /* __LC_H__ */
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
@@ -0,0 +1,338 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: psock.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "uipopt.h"
|
||||
#include "psock.h"
|
||||
#include "uip.h"
|
||||
|
||||
#define STATE_NONE 0
|
||||
#define STATE_ACKED 1
|
||||
#define STATE_READ 2
|
||||
#define STATE_BLOCKED_NEWDATA 3
|
||||
#define STATE_BLOCKED_CLOSE 4
|
||||
#define STATE_BLOCKED_SEND 5
|
||||
#define STATE_DATA_SENT 6
|
||||
|
||||
/*
|
||||
* Return value of the buffering functions that indicates that a
|
||||
* buffer was not filled by incoming data.
|
||||
*
|
||||
*/
|
||||
#define BUF_NOT_FULL 0
|
||||
#define BUF_NOT_FOUND 0
|
||||
|
||||
/*
|
||||
* Return value of the buffering functions that indicates that a
|
||||
* buffer was completely filled by incoming data.
|
||||
*
|
||||
*/
|
||||
#define BUF_FULL 1
|
||||
|
||||
/*
|
||||
* Return value of the buffering functions that indicates that an
|
||||
* end-marker byte was found.
|
||||
*
|
||||
*/
|
||||
#define BUF_FOUND 2
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
buf_setup(struct psock_buf *buf,
|
||||
u8_t *bufptr, u16_t bufsize)
|
||||
{
|
||||
buf->ptr = bufptr;
|
||||
buf->left = bufsize;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static u8_t
|
||||
buf_bufdata(struct psock_buf *buf, u16_t len,
|
||||
u8_t **dataptr, u16_t *datalen)
|
||||
{
|
||||
if(*datalen < buf->left) {
|
||||
memcpy(buf->ptr, *dataptr, *datalen);
|
||||
buf->ptr += *datalen;
|
||||
buf->left -= *datalen;
|
||||
*dataptr += *datalen;
|
||||
*datalen = 0;
|
||||
return BUF_NOT_FULL;
|
||||
} else if(*datalen == buf->left) {
|
||||
memcpy(buf->ptr, *dataptr, *datalen);
|
||||
buf->ptr += *datalen;
|
||||
buf->left = 0;
|
||||
*dataptr += *datalen;
|
||||
*datalen = 0;
|
||||
return BUF_FULL;
|
||||
} else {
|
||||
memcpy(buf->ptr, *dataptr, buf->left);
|
||||
buf->ptr += buf->left;
|
||||
*datalen -= buf->left;
|
||||
*dataptr += buf->left;
|
||||
buf->left = 0;
|
||||
return BUF_FULL;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static u8_t
|
||||
buf_bufto(register struct psock_buf *buf, u8_t endmarker,
|
||||
register u8_t **dataptr, register u16_t *datalen)
|
||||
{
|
||||
u8_t c;
|
||||
while(buf->left > 0 && *datalen > 0) {
|
||||
c = *buf->ptr = **dataptr;
|
||||
++*dataptr;
|
||||
++buf->ptr;
|
||||
--*datalen;
|
||||
--buf->left;
|
||||
|
||||
if(c == endmarker) {
|
||||
return BUF_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
if(*datalen == 0) {
|
||||
return BUF_NOT_FOUND;
|
||||
}
|
||||
|
||||
while(*datalen > 0) {
|
||||
c = **dataptr;
|
||||
--*datalen;
|
||||
++*dataptr;
|
||||
|
||||
if(c == endmarker) {
|
||||
return BUF_FOUND | BUF_FULL;
|
||||
}
|
||||
}
|
||||
|
||||
return BUF_FULL;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static char
|
||||
send_data(register struct psock *s)
|
||||
{
|
||||
if(s->state != STATE_DATA_SENT || uip_rexmit()) {
|
||||
if(s->sendlen > uip_mss()) {
|
||||
uip_send(s->sendptr, uip_mss());
|
||||
} else {
|
||||
uip_send(s->sendptr, s->sendlen);
|
||||
}
|
||||
s->state = STATE_DATA_SENT;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static char
|
||||
data_acked(register struct psock *s)
|
||||
{
|
||||
if(s->state == STATE_DATA_SENT && uip_acked()) {
|
||||
if(s->sendlen > uip_mss()) {
|
||||
s->sendlen -= uip_mss();
|
||||
s->sendptr += uip_mss();
|
||||
} else {
|
||||
s->sendptr += s->sendlen;
|
||||
s->sendlen = 0;
|
||||
}
|
||||
s->state = STATE_ACKED;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PT_THREAD(psock_send(register struct psock *s, const char *buf,
|
||||
unsigned int len))
|
||||
{
|
||||
PT_BEGIN(&s->psockpt);
|
||||
|
||||
/* If there is no data to send, we exit immediately. */
|
||||
if(len == 0) {
|
||||
PT_EXIT(&s->psockpt);
|
||||
}
|
||||
|
||||
/* Save the length of and a pointer to the data that is to be
|
||||
sent. */
|
||||
s->sendptr = (u8_t *)buf;
|
||||
s->sendlen = len;
|
||||
|
||||
s->state = STATE_NONE;
|
||||
|
||||
/* We loop here until all data is sent. The s->sendlen variable is
|
||||
updated by the data_sent() function. */
|
||||
while(s->sendlen > 0) {
|
||||
|
||||
/*
|
||||
* The condition for this PT_WAIT_UNTIL is a little tricky: the
|
||||
* protothread will wait here until all data has been acknowledged
|
||||
* (data_acked() returns true) and until all data has been sent
|
||||
* (send_data() returns true). The two functions data_acked() and
|
||||
* send_data() must be called in succession to ensure that all
|
||||
* data is sent. Therefore the & operator is used instead of the
|
||||
* && operator, which would cause only the data_acked() function
|
||||
* to be called when it returns false.
|
||||
*/
|
||||
PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s));
|
||||
}
|
||||
|
||||
s->state = STATE_NONE;
|
||||
|
||||
PT_END(&s->psockpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PT_THREAD(psock_generator_send(register struct psock *s,
|
||||
unsigned short (*generate)(void *), void *arg))
|
||||
{
|
||||
PT_BEGIN(&s->psockpt);
|
||||
|
||||
/* Ensure that there is a generator function to call. */
|
||||
if(generate == NULL) {
|
||||
PT_EXIT(&s->psockpt);
|
||||
}
|
||||
|
||||
/* Call the generator function to generate the data in the
|
||||
uip_appdata buffer. */
|
||||
s->sendlen = generate(arg);
|
||||
s->sendptr = uip_appdata;
|
||||
|
||||
s->state = STATE_NONE;
|
||||
do {
|
||||
/* Call the generator function again if we are called to perform a
|
||||
retransmission. */
|
||||
if(uip_rexmit()) {
|
||||
generate(arg);
|
||||
}
|
||||
/* Wait until all data is sent and acknowledged. */
|
||||
PT_WAIT_UNTIL(&s->psockpt, data_acked(s) & send_data(s));
|
||||
} while(s->sendlen > 0);
|
||||
|
||||
s->state = STATE_NONE;
|
||||
|
||||
PT_END(&s->psockpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
u16_t
|
||||
psock_datalen(struct psock *psock)
|
||||
{
|
||||
return psock->bufsize - psock->buf.left;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
char
|
||||
psock_newdata(struct psock *s)
|
||||
{
|
||||
if(s->readlen > 0) {
|
||||
/* There is data in the uip_appdata buffer that has not yet been
|
||||
read with the PSOCK_READ functions. */
|
||||
return 1;
|
||||
} else if(s->state == STATE_READ) {
|
||||
/* All data in uip_appdata buffer already consumed. */
|
||||
s->state = STATE_BLOCKED_NEWDATA;
|
||||
return 0;
|
||||
} else if(uip_newdata()) {
|
||||
/* There is new data that has not been consumed. */
|
||||
return 1;
|
||||
} else {
|
||||
/* There is no new data. */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PT_THREAD(psock_readto(register struct psock *psock, unsigned char c))
|
||||
{
|
||||
PT_BEGIN(&psock->psockpt);
|
||||
|
||||
buf_setup(&psock->buf, (u8_t *)psock->bufptr, psock->bufsize);
|
||||
|
||||
/* XXX: Should add buf_checkmarker() before do{} loop, if
|
||||
incoming data has been handled while waiting for a write. */
|
||||
|
||||
do {
|
||||
if(psock->readlen == 0) {
|
||||
PT_WAIT_UNTIL(&psock->psockpt, psock_newdata(psock));
|
||||
psock->state = STATE_READ;
|
||||
psock->readptr = (u8_t *)uip_appdata;
|
||||
psock->readlen = uip_datalen();
|
||||
}
|
||||
} while((buf_bufto(&psock->buf, c,
|
||||
&psock->readptr,
|
||||
&psock->readlen) & BUF_FOUND) == 0);
|
||||
|
||||
if(psock_datalen(psock) == 0) {
|
||||
psock->state = STATE_NONE;
|
||||
PT_RESTART(&psock->psockpt);
|
||||
}
|
||||
PT_END(&psock->psockpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PT_THREAD(psock_readbuf(register struct psock *psock))
|
||||
{
|
||||
PT_BEGIN(&psock->psockpt);
|
||||
|
||||
buf_setup(&psock->buf, (u8_t *)psock->bufptr, psock->bufsize);
|
||||
|
||||
/* XXX: Should add buf_checkmarker() before do{} loop, if
|
||||
incoming data has been handled while waiting for a write. */
|
||||
|
||||
do {
|
||||
if(psock->readlen == 0) {
|
||||
PT_WAIT_UNTIL(&psock->psockpt, psock_newdata(psock));
|
||||
printf("Waited for newdata\n");
|
||||
psock->state = STATE_READ;
|
||||
psock->readptr = (u8_t *)uip_appdata;
|
||||
psock->readlen = uip_datalen();
|
||||
}
|
||||
} while(buf_bufdata(&psock->buf, psock->bufsize,
|
||||
&psock->readptr,
|
||||
&psock->readlen) != BUF_FULL);
|
||||
|
||||
if(psock_datalen(psock) == 0) {
|
||||
psock->state = STATE_NONE;
|
||||
PT_RESTART(&psock->psockpt);
|
||||
}
|
||||
PT_END(&psock->psockpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
psock_init(register struct psock *psock, char *buffer, unsigned int buffersize)
|
||||
{
|
||||
psock->state = STATE_NONE;
|
||||
psock->readlen = 0;
|
||||
psock->bufptr = buffer;
|
||||
psock->bufsize = buffersize;
|
||||
buf_setup(&psock->buf, (u8_t *)buffer, buffersize);
|
||||
PT_INIT(&psock->pt);
|
||||
PT_INIT(&psock->psockpt);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: psock.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup psock Protosockets library
|
||||
* @{
|
||||
*
|
||||
* The protosocket library provides an interface to the uIP stack that is
|
||||
* similar to the traditional BSD socket interface. Unlike programs
|
||||
* written for the ordinary uIP event-driven interface, programs
|
||||
* written with the protosocket library are executed in a sequential
|
||||
* fashion and does not have to be implemented as explicit state
|
||||
* machines.
|
||||
*
|
||||
* Protosockets only work with TCP connections.
|
||||
*
|
||||
* The protosocket library uses \ref pt protothreads to provide
|
||||
* sequential control flow. This makes the protosockets lightweight in
|
||||
* terms of memory, but also means that protosockets inherits the
|
||||
* functional limitations of protothreads. Each protosocket lives only
|
||||
* within a single function. Automatic variables (stack variables) are
|
||||
* not retained across a protosocket library function call.
|
||||
*
|
||||
* \note Because the protosocket library uses protothreads, local
|
||||
* variables will not always be saved across a call to a protosocket
|
||||
* library function. It is therefore advised that local variables are
|
||||
* used with extreme care.
|
||||
*
|
||||
* The protosocket library provides functions for sending data without
|
||||
* having to deal with retransmissions and acknowledgements, as well
|
||||
* as functions for reading data without having to deal with data
|
||||
* being split across more than one TCP segment.
|
||||
*
|
||||
* Because each protosocket runs as a protothread, the protosocket has to be
|
||||
* started with a call to PSOCK_BEGIN() at the start of the function
|
||||
* in which the protosocket is used. Similarly, the protosocket protothread can
|
||||
* be terminated by a call to PSOCK_EXIT().
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Protosocket library header file
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PSOCK_H__
|
||||
#define __PSOCK_H__
|
||||
|
||||
#include "uipopt.h"
|
||||
#include "pt.h"
|
||||
|
||||
/*
|
||||
* The structure that holds the state of a buffer.
|
||||
*
|
||||
* This structure holds the state of a uIP buffer. The structure has
|
||||
* no user-visible elements, but is used through the functions
|
||||
* provided by the library.
|
||||
*
|
||||
*/
|
||||
struct psock_buf {
|
||||
u8_t *ptr;
|
||||
unsigned short left;
|
||||
};
|
||||
|
||||
/**
|
||||
* The representation of a protosocket.
|
||||
*
|
||||
* The protosocket structrure is an opaque structure with no user-visible
|
||||
* elements.
|
||||
*/
|
||||
struct psock {
|
||||
struct pt pt, psockpt; /* Protothreads - one that's using the psock
|
||||
functions, and one that runs inside the
|
||||
psock functions. */
|
||||
const u8_t *sendptr; /* Pointer to the next data to be sent. */
|
||||
u8_t *readptr; /* Pointer to the next data to be read. */
|
||||
|
||||
char *bufptr; /* Pointer to the buffer used for buffering
|
||||
incoming data. */
|
||||
|
||||
u16_t sendlen; /* The number of bytes left to be sent. */
|
||||
u16_t readlen; /* The number of bytes left to be read. */
|
||||
|
||||
struct psock_buf buf; /* The structure holding the state of the
|
||||
input buffer. */
|
||||
unsigned int bufsize; /* The size of the input buffer. */
|
||||
|
||||
unsigned char state; /* The state of the protosocket. */
|
||||
};
|
||||
|
||||
void psock_init(struct psock *psock, char *buffer, unsigned int buffersize);
|
||||
/**
|
||||
* Initialize a protosocket.
|
||||
*
|
||||
* This macro initializes a protosocket and must be called before the
|
||||
* protosocket is used. The initialization also specifies the input buffer
|
||||
* for the protosocket.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket to be
|
||||
* initialized
|
||||
*
|
||||
* \param buffer (char *) A pointer to the input buffer for the
|
||||
* protosocket.
|
||||
*
|
||||
* \param buffersize (unsigned int) The size of the input buffer.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_INIT(psock, buffer, buffersize) \
|
||||
psock_init(psock, buffer, buffersize)
|
||||
|
||||
/**
|
||||
* Start the protosocket protothread in a function.
|
||||
*
|
||||
* This macro starts the protothread associated with the protosocket and
|
||||
* must come before other protosocket calls in the function it is used.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket to be
|
||||
* started.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_BEGIN(psock) PT_BEGIN(&((psock)->pt))
|
||||
|
||||
PT_THREAD(psock_send(struct psock *psock, const char *buf, unsigned int len));
|
||||
/**
|
||||
* Send data.
|
||||
*
|
||||
* This macro sends data over a protosocket. The protosocket protothread blocks
|
||||
* until all data has been sent and is known to have been received by
|
||||
* the remote end of the TCP connection.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket over which
|
||||
* data is to be sent.
|
||||
*
|
||||
* \param data (char *) A pointer to the data that is to be sent.
|
||||
*
|
||||
* \param datalen (unsigned int) The length of the data that is to be
|
||||
* sent.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_SEND(psock, data, datalen) \
|
||||
PT_WAIT_THREAD(&((psock)->pt), psock_send(psock, data, datalen))
|
||||
|
||||
/**
|
||||
* \brief Send a null-terminated string.
|
||||
* \param psock Pointer to the protosocket.
|
||||
* \param str The string to be sent.
|
||||
*
|
||||
* This function sends a null-terminated string over the
|
||||
* protosocket.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_SEND_STR(psock, str) \
|
||||
PT_WAIT_THREAD(&((psock)->pt), psock_send(psock, str, strlen(str)))
|
||||
|
||||
PT_THREAD(psock_generator_send(struct psock *psock,
|
||||
unsigned short (*f)(void *), void *arg));
|
||||
|
||||
/**
|
||||
* \brief Generate data with a function and send it
|
||||
* \param psock Pointer to the protosocket.
|
||||
* \param generator Pointer to the generator function
|
||||
* \param arg Argument to the generator function
|
||||
*
|
||||
* This function generates data and sends it over the
|
||||
* protosocket. This can be used to dynamically generate
|
||||
* data for a transmission, instead of generating the data
|
||||
* in a buffer beforehand. This function reduces the need for
|
||||
* buffer memory. The generator function is implemented by
|
||||
* the application, and a pointer to the function is given
|
||||
* as an argument with the call to PSOCK_GENERATOR_SEND().
|
||||
*
|
||||
* The generator function should place the generated data
|
||||
* directly in the uip_appdata buffer, and return the
|
||||
* length of the generated data. The generator function is
|
||||
* called by the protosocket layer when the data first is
|
||||
* sent, and once for every retransmission that is needed.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_GENERATOR_SEND(psock, generator, arg) \
|
||||
PT_WAIT_THREAD(&((psock)->pt), \
|
||||
psock_generator_send(psock, generator, arg))
|
||||
|
||||
|
||||
/**
|
||||
* Close a protosocket.
|
||||
*
|
||||
* This macro closes a protosocket and can only be called from within the
|
||||
* protothread in which the protosocket lives.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket that is to
|
||||
* be closed.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_CLOSE(psock) uip_close()
|
||||
|
||||
PT_THREAD(psock_readbuf(struct psock *psock));
|
||||
/**
|
||||
* Read data until the buffer is full.
|
||||
*
|
||||
* This macro will block waiting for data and read the data into the
|
||||
* input buffer specified with the call to PSOCK_INIT(). Data is read
|
||||
* until the buffer is full..
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket from which
|
||||
* data should be read.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_READBUF(psock) \
|
||||
PT_WAIT_THREAD(&((psock)->pt), psock_readbuf(psock))
|
||||
|
||||
PT_THREAD(psock_readto(struct psock *psock, unsigned char c));
|
||||
/**
|
||||
* Read data up to a specified character.
|
||||
*
|
||||
* This macro will block waiting for data and read the data into the
|
||||
* input buffer specified with the call to PSOCK_INIT(). Data is only
|
||||
* read until the specifieed character appears in the data stream.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket from which
|
||||
* data should be read.
|
||||
*
|
||||
* \param c (char) The character at which to stop reading.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_READTO(psock, c) \
|
||||
PT_WAIT_THREAD(&((psock)->pt), psock_readto(psock, c))
|
||||
|
||||
/**
|
||||
* The length of the data that was previously read.
|
||||
*
|
||||
* This macro returns the length of the data that was previously read
|
||||
* using PSOCK_READTO() or PSOCK_READ().
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket holding the data.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_DATALEN(psock) psock_datalen(psock)
|
||||
|
||||
u16_t psock_datalen(struct psock *psock);
|
||||
|
||||
/**
|
||||
* Exit the protosocket's protothread.
|
||||
*
|
||||
* This macro terminates the protothread of the protosocket and should
|
||||
* almost always be used in conjunction with PSOCK_CLOSE().
|
||||
*
|
||||
* \sa PSOCK_CLOSE_EXIT()
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_EXIT(psock) PT_EXIT(&((psock)->pt))
|
||||
|
||||
/**
|
||||
* Close a protosocket and exit the protosocket's protothread.
|
||||
*
|
||||
* This macro closes a protosocket and exits the protosocket's protothread.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_CLOSE_EXIT(psock) \
|
||||
do { \
|
||||
PSOCK_CLOSE(psock); \
|
||||
PSOCK_EXIT(psock); \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Declare the end of a protosocket's protothread.
|
||||
*
|
||||
* This macro is used for declaring that the protosocket's protothread
|
||||
* ends. It must always be used together with a matching PSOCK_BEGIN()
|
||||
* macro.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_END(psock) PT_END(&((psock)->pt))
|
||||
|
||||
char psock_newdata(struct psock *s);
|
||||
|
||||
/**
|
||||
* Check if new data has arrived on a protosocket.
|
||||
*
|
||||
* This macro is used in conjunction with the PSOCK_WAIT_UNTIL()
|
||||
* macro to check if data has arrived on a protosocket.
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_NEWDATA(psock) psock_newdata(psock)
|
||||
|
||||
/**
|
||||
* Wait until a condition is true.
|
||||
*
|
||||
* This macro blocks the protothread until the specified condition is
|
||||
* true. The macro PSOCK_NEWDATA() can be used to check if new data
|
||||
* arrives when the protosocket is waiting.
|
||||
*
|
||||
* Typically, this macro is used as follows:
|
||||
*
|
||||
\code
|
||||
PT_THREAD(thread(struct psock *s, struct timer *t))
|
||||
{
|
||||
PSOCK_BEGIN(s);
|
||||
|
||||
PSOCK_WAIT_UNTIL(s, PSOCK_NEWADATA(s) || timer_expired(t));
|
||||
|
||||
if(PSOCK_NEWDATA(s)) {
|
||||
PSOCK_READTO(s, '\n');
|
||||
} else {
|
||||
handle_timed_out(s);
|
||||
}
|
||||
|
||||
PSOCK_END(s);
|
||||
}
|
||||
\endcode
|
||||
*
|
||||
* \param psock (struct psock *) A pointer to the protosocket.
|
||||
* \param condition The condition to wait for.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PSOCK_WAIT_UNTIL(psock, condition) \
|
||||
PT_WAIT_UNTIL(&((psock)->pt), (condition));
|
||||
|
||||
#define PSOCK_WAIT_THREAD(psock, condition) \
|
||||
PT_WAIT_THREAD(&((psock)->pt), (condition))
|
||||
|
||||
#endif /* __PSOCK_H__ */
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2005, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: pt.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup pt
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Protothreads implementation.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __PT_H__
|
||||
#define __PT_H__
|
||||
|
||||
#include "lc.h"
|
||||
|
||||
struct pt {
|
||||
lc_t lc;
|
||||
};
|
||||
|
||||
#define PT_WAITING 0
|
||||
#define PT_EXITED 1
|
||||
#define PT_ENDED 2
|
||||
#define PT_YIELDED 3
|
||||
|
||||
/**
|
||||
* \name Initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initialize a protothread.
|
||||
*
|
||||
* Initializes a protothread. Initialization must be done prior to
|
||||
* starting to execute the protothread.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
*
|
||||
* \sa PT_SPAWN()
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_INIT(pt) LC_INIT((pt)->lc)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Declaration and definition
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Declaration of a protothread.
|
||||
*
|
||||
* This macro is used to declare a protothread. All protothreads must
|
||||
* be declared with this macro.
|
||||
*
|
||||
* \param name_args The name and arguments of the C function
|
||||
* implementing the protothread.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_THREAD(name_args) char name_args
|
||||
|
||||
/**
|
||||
* Declare the start of a protothread inside the C function
|
||||
* implementing the protothread.
|
||||
*
|
||||
* This macro is used to declare the starting point of a
|
||||
* protothread. It should be placed at the start of the function in
|
||||
* which the protothread runs. All C statements above the PT_BEGIN()
|
||||
* invokation will be executed each time the protothread is scheduled.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_BEGIN(pt) { volatile char PT_YIELD_FLAG = 1; LC_RESUME((pt)->lc)
|
||||
|
||||
/**
|
||||
* Declare the end of a protothread.
|
||||
*
|
||||
* This macro is used for declaring that a protothread ends. It must
|
||||
* always be used together with a matching PT_BEGIN() macro.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_END(pt) LC_END((pt)->lc); PT_YIELD_FLAG = 0; \
|
||||
PT_INIT(pt); return PT_ENDED; }
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Blocked wait
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Block and wait until condition is true.
|
||||
*
|
||||
* This macro blocks the protothread until the specified condition is
|
||||
* true.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
* \param condition The condition.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_WAIT_UNTIL(pt, condition) \
|
||||
do { \
|
||||
LC_SET((pt)->lc); \
|
||||
if(!(condition)) { \
|
||||
return PT_WAITING; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Block and wait while condition is true.
|
||||
*
|
||||
* This function blocks and waits while condition is true. See
|
||||
* PT_WAIT_UNTIL().
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
* \param cond The condition.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_WAIT_WHILE(pt, cond) PT_WAIT_UNTIL((pt), !(cond))
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Hierarchical protothreads
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Block and wait until a child protothread completes.
|
||||
*
|
||||
* This macro schedules a child protothread. The current protothread
|
||||
* will block until the child protothread completes.
|
||||
*
|
||||
* \note The child protothread must be manually initialized with the
|
||||
* PT_INIT() function before this function is used.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
* \param thread The child protothread with arguments
|
||||
*
|
||||
* \sa PT_SPAWN()
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_WAIT_THREAD(pt, thread) PT_WAIT_WHILE((pt), PT_SCHEDULE(thread))
|
||||
|
||||
/**
|
||||
* Spawn a child protothread and wait until it exits.
|
||||
*
|
||||
* This macro spawns a child protothread and waits until it exits. The
|
||||
* macro can only be used within a protothread.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
* \param child A pointer to the child protothread's control structure.
|
||||
* \param thread The child protothread with arguments
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_SPAWN(pt, child, thread) \
|
||||
do { \
|
||||
PT_INIT((child)); \
|
||||
PT_WAIT_THREAD((pt), (thread)); \
|
||||
} while(0)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Exiting and restarting
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Restart the protothread.
|
||||
*
|
||||
* This macro will block and cause the running protothread to restart
|
||||
* its execution at the place of the PT_BEGIN() call.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_RESTART(pt) \
|
||||
do { \
|
||||
PT_INIT(pt); \
|
||||
return PT_WAITING; \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* Exit the protothread.
|
||||
*
|
||||
* This macro causes the protothread to exit. If the protothread was
|
||||
* spawned by another protothread, the parent protothread will become
|
||||
* unblocked and can continue to run.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_EXIT(pt) \
|
||||
do { \
|
||||
PT_INIT(pt); \
|
||||
return PT_EXITED; \
|
||||
} while(0)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Calling a protothread
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Schedule a protothread.
|
||||
*
|
||||
* This function shedules a protothread. The return value of the
|
||||
* function is non-zero if the protothread is running or zero if the
|
||||
* protothread has exited.
|
||||
*
|
||||
* \param f The call to the C function implementing the protothread to
|
||||
* be scheduled
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_SCHEDULE(f) ((f) == PT_WAITING)
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \name Yielding from a protothread
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Yield from the current protothread.
|
||||
*
|
||||
* This function will yield the protothread, thereby allowing other
|
||||
* processing to take place in the system.
|
||||
*
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_YIELD(pt) \
|
||||
do { \
|
||||
PT_YIELD_FLAG = 0; \
|
||||
LC_SET((pt)->lc); \
|
||||
if(PT_YIELD_FLAG == 0) { \
|
||||
return PT_YIELDED; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* \brief Yield from the protothread until a condition occurs.
|
||||
* \param pt A pointer to the protothread control structure.
|
||||
* \param cond The condition.
|
||||
*
|
||||
* This function will yield the protothread, until the
|
||||
* specified condition evaluates to true.
|
||||
*
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define PT_YIELD_UNTIL(pt, cond) \
|
||||
do { \
|
||||
PT_YIELD_FLAG = 0; \
|
||||
LC_SET((pt)->lc); \
|
||||
if((PT_YIELD_FLAG == 0) || !(cond)) { \
|
||||
return PT_YIELDED; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* __PT_H__ */
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* \addtogroup timer
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Timer library implementation.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: timer.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
|
||||
#include "clock.h"
|
||||
#include "timer.h"
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Set a timer.
|
||||
*
|
||||
* This function is used to set a timer for a time sometime in the
|
||||
* future. The function timer_expired() will evaluate to true after
|
||||
* the timer has expired.
|
||||
*
|
||||
* \param t A pointer to the timer
|
||||
* \param interval The interval before the timer expires.
|
||||
*
|
||||
*/
|
||||
void
|
||||
timer_set(struct timer *t, clock_time_t interval)
|
||||
{
|
||||
t->interval = interval;
|
||||
t->start = clock_time();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Reset the timer with the same interval.
|
||||
*
|
||||
* This function resets the timer with the same interval that was
|
||||
* given to the timer_set() function. The start point of the interval
|
||||
* is the exact time that the timer last expired. Therefore, this
|
||||
* function will cause the timer to be stable over time, unlike the
|
||||
* timer_rester() function.
|
||||
*
|
||||
* \param t A pointer to the timer.
|
||||
*
|
||||
* \sa timer_restart()
|
||||
*/
|
||||
void
|
||||
timer_reset(struct timer *t)
|
||||
{
|
||||
t->start += t->interval;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Restart the timer from the current point in time
|
||||
*
|
||||
* This function restarts a timer with the same interval that was
|
||||
* given to the timer_set() function. The timer will start at the
|
||||
* current time.
|
||||
*
|
||||
* \note A periodic timer will drift if this function is used to reset
|
||||
* it. For preioric timers, use the timer_reset() function instead.
|
||||
*
|
||||
* \param t A pointer to the timer.
|
||||
*
|
||||
* \sa timer_reset()
|
||||
*/
|
||||
void
|
||||
timer_restart(struct timer *t)
|
||||
{
|
||||
t->start = clock_time();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Check if a timer has expired.
|
||||
*
|
||||
* This function tests if a timer has expired and returns true or
|
||||
* false depending on its status.
|
||||
*
|
||||
* \param t A pointer to the timer
|
||||
*
|
||||
* \return Non-zero if the timer has expired, zero otherwise.
|
||||
*
|
||||
*/
|
||||
int
|
||||
timer_expired(struct timer *t)
|
||||
{
|
||||
return (clock_time_t)(clock_time() - t->start) >= (clock_time_t)t->interval;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* \defgroup timer Timer library
|
||||
*
|
||||
* The timer library provides functions for setting, resetting and
|
||||
* restarting timers, and for checking if a timer has expired. An
|
||||
* application must "manually" check if its timers have expired; this
|
||||
* is not done automatically.
|
||||
*
|
||||
* A timer is declared as a \c struct \c timer and all access to the
|
||||
* timer is made by a pointer to the declared timer.
|
||||
*
|
||||
* \note The timer library uses the \ref clock "Clock library" to
|
||||
* measure time. Intervals should be specified in the format used by
|
||||
* the clock library.
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Timer library header file.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: timer.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
#ifndef __TIMER_H__
|
||||
#define __TIMER_H__
|
||||
|
||||
#include "clock.h"
|
||||
|
||||
/**
|
||||
* A timer.
|
||||
*
|
||||
* This structure is used for declaring a timer. The timer must be set
|
||||
* with timer_set() before it can be used.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
struct timer {
|
||||
clock_time_t start;
|
||||
clock_time_t interval;
|
||||
};
|
||||
|
||||
void timer_set(struct timer *t, clock_time_t interval);
|
||||
void timer_reset(struct timer *t);
|
||||
void timer_restart(struct timer *t);
|
||||
int timer_expired(struct timer *t);
|
||||
|
||||
#endif /* __TIMER_H__ */
|
||||
|
||||
/** @} */
|
||||
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* \addtogroup uipopt
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \name Project-specific configuration options
|
||||
* @{
|
||||
*
|
||||
* uIP has a number of configuration options that can be overridden
|
||||
* for each project. These are kept in a project-specific uip-conf.h
|
||||
* file and all configuration names have the prefix UIP_CONF.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* $Id: uip-conf.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* An example uIP configuration file
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef __UIP_CONF_H__
|
||||
#define __UIP_CONF_H__
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/**
|
||||
* 8 bit datatype
|
||||
*
|
||||
* This typedef defines the 8-bit type used throughout uIP.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
typedef uint8_t u8_t;
|
||||
|
||||
/**
|
||||
* 16 bit datatype
|
||||
*
|
||||
* This typedef defines the 16-bit type used throughout uIP.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
typedef uint16_t u16_t;
|
||||
|
||||
/**
|
||||
* Statistics datatype
|
||||
*
|
||||
* This typedef defines the dataype used for keeping statistics in
|
||||
* uIP.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
typedef unsigned short uip_stats_t;
|
||||
|
||||
/**
|
||||
* Maximum number of TCP connections.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_MAX_CONNECTIONS 40
|
||||
|
||||
/**
|
||||
* Maximum number of listening TCP ports.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_MAX_LISTENPORTS 40
|
||||
|
||||
/**
|
||||
* uIP buffer size.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_BUFFER_SIZE 1520
|
||||
|
||||
/**
|
||||
* CPU byte order.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_BYTE_ORDER LITTLE_ENDIAN
|
||||
|
||||
/**
|
||||
* Logging on or off
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_LOGGING 0
|
||||
|
||||
/**
|
||||
* UDP support on or off
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_UDP 0
|
||||
|
||||
/**
|
||||
* UDP checksums on or off
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_UDP_CHECKSUMS 1
|
||||
|
||||
/**
|
||||
* uIP statistics on or off
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_CONF_STATISTICS 1
|
||||
|
||||
/* Here we include the header file for the application(s) we use in
|
||||
our project. */
|
||||
/*#include "smtp.h"*/
|
||||
/*#include "hello-world.h"*/
|
||||
/*#include "telnetd.h"*/
|
||||
#include "webserver.h"
|
||||
/*#include "dhcpc.h"*/
|
||||
/*#include "resolv.h"*/
|
||||
/*#include "webclient.h"*/
|
||||
|
||||
#endif /* __UIP_CONF_H__ */
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* \addtogroup uip
|
||||
* {@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup uiparch Architecture specific uIP functions
|
||||
* @{
|
||||
*
|
||||
* The functions in the architecture specific module implement the IP
|
||||
* check sum and 32-bit additions.
|
||||
*
|
||||
* The IP checksum calculation is the most computationally expensive
|
||||
* operation in the TCP/IP stack and it therefore pays off to
|
||||
* implement this in efficient assembler. The purpose of the uip-arch
|
||||
* module is to let the checksum functions to be implemented in
|
||||
* architecture specific assembler.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Declarations of architecture specific functions.
|
||||
* \author Adam Dunkels <adam@dunkels.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: uip_arch.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __UIP_ARCH_H__
|
||||
#define __UIP_ARCH_H__
|
||||
|
||||
#include "uip.h"
|
||||
|
||||
/**
|
||||
* Carry out a 32-bit addition.
|
||||
*
|
||||
* Because not all architectures for which uIP is intended has native
|
||||
* 32-bit arithmetic, uIP uses an external C function for doing the
|
||||
* required 32-bit additions in the TCP protocol processing. This
|
||||
* function should add the two arguments and place the result in the
|
||||
* global variable uip_acc32.
|
||||
*
|
||||
* \note The 32-bit integer pointed to by the op32 parameter and the
|
||||
* result in the uip_acc32 variable are in network byte order (big
|
||||
* endian).
|
||||
*
|
||||
* \param op32 A pointer to a 4-byte array representing a 32-bit
|
||||
* integer in network byte order (big endian).
|
||||
*
|
||||
* \param op16 A 16-bit integer in host byte order.
|
||||
*/
|
||||
void uip_add32(u8_t *op32, u16_t op16);
|
||||
|
||||
/**
|
||||
* Calculate the Internet checksum over a buffer.
|
||||
*
|
||||
* The Internet checksum is the one's complement of the one's
|
||||
* complement sum of all 16-bit words in the buffer.
|
||||
*
|
||||
* See RFC1071.
|
||||
*
|
||||
* \note This function is not called in the current version of uIP,
|
||||
* but future versions might make use of it.
|
||||
*
|
||||
* \param buf A pointer to the buffer over which the checksum is to be
|
||||
* computed.
|
||||
*
|
||||
* \param len The length of the buffer over which the checksum is to
|
||||
* be computed.
|
||||
*
|
||||
* \return The Internet checksum of the buffer.
|
||||
*/
|
||||
u16_t uip_chksum(u16_t *buf, u16_t len);
|
||||
|
||||
/**
|
||||
* Calculate the IP header checksum of the packet header in uip_buf.
|
||||
*
|
||||
* The IP header checksum is the Internet checksum of the 20 bytes of
|
||||
* the IP header.
|
||||
*
|
||||
* \return The IP header checksum of the IP header in the uip_buf
|
||||
* buffer.
|
||||
*/
|
||||
u16_t uip_ipchksum(void);
|
||||
|
||||
/**
|
||||
* Calculate the TCP checksum of the packet in uip_buf and uip_appdata.
|
||||
*
|
||||
* The TCP checksum is the Internet checksum of data contents of the
|
||||
* TCP segment, and a pseudo-header as defined in RFC793.
|
||||
*
|
||||
* \note The uip_appdata pointer that points to the packet data may
|
||||
* point anywhere in memory, so it is not possible to simply calculate
|
||||
* the Internet checksum of the contents of the uip_buf buffer.
|
||||
*
|
||||
* \return The TCP checksum of the TCP segment in uip_buf and pointed
|
||||
* to by uip_appdata.
|
||||
*/
|
||||
u16_t uip_tcpchksum(void);
|
||||
|
||||
u16_t uip_udpchksum(void);
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
#endif /* __UIP_ARCH_H__ */
|
||||
@@ -0,0 +1,423 @@
|
||||
/**
|
||||
* \addtogroup uip
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup uiparp uIP Address Resolution Protocol
|
||||
* @{
|
||||
*
|
||||
* The Address Resolution Protocol ARP is used for mapping between IP
|
||||
* addresses and link level addresses such as the Ethernet MAC
|
||||
* addresses. ARP uses broadcast queries to ask for the link level
|
||||
* address of a known IP address and the host which is configured with
|
||||
* the IP address for which the query was meant, will respond with its
|
||||
* link level address.
|
||||
*
|
||||
* \note This ARP implementation only supports Ethernet.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Implementation of the ARP Address Resolution Protocol.
|
||||
* \author Adam Dunkels <adam@dunkels.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: uip_arp.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "uip_arp.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct arp_hdr {
|
||||
struct uip_eth_hdr ethhdr;
|
||||
u16_t hwtype;
|
||||
u16_t protocol;
|
||||
u8_t hwlen;
|
||||
u8_t protolen;
|
||||
u16_t opcode;
|
||||
struct uip_eth_addr shwaddr;
|
||||
u16_t sipaddr[2];
|
||||
struct uip_eth_addr dhwaddr;
|
||||
u16_t dipaddr[2];
|
||||
};
|
||||
|
||||
struct ethip_hdr {
|
||||
struct uip_eth_hdr ethhdr;
|
||||
/* IP header. */
|
||||
u8_t vhl,
|
||||
tos,
|
||||
len[2],
|
||||
ipid[2],
|
||||
ipoffset[2],
|
||||
ttl,
|
||||
proto;
|
||||
u16_t ipchksum;
|
||||
u16_t srcipaddr[2],
|
||||
destipaddr[2];
|
||||
};
|
||||
|
||||
#define ARP_REQUEST 1
|
||||
#define ARP_REPLY 2
|
||||
|
||||
#define ARP_HWTYPE_ETH 1
|
||||
|
||||
struct arp_entry {
|
||||
u16_t ipaddr[2];
|
||||
struct uip_eth_addr ethaddr;
|
||||
u8_t time;
|
||||
};
|
||||
|
||||
static const struct uip_eth_addr broadcast_ethaddr =
|
||||
{{0xff,0xff,0xff,0xff,0xff,0xff}};
|
||||
static const u16_t broadcast_ipaddr[2] = {0xffff,0xffff};
|
||||
|
||||
static struct arp_entry arp_table[UIP_ARPTAB_SIZE];
|
||||
static u16_t ipaddr[2];
|
||||
static u8_t i, c;
|
||||
|
||||
static u8_t arptime;
|
||||
static u8_t tmpage;
|
||||
|
||||
#define BUF ((struct arp_hdr *)&uip_buf[0])
|
||||
#define IPBUF ((struct ethip_hdr *)&uip_buf[0])
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Initialize the ARP module.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_arp_init(void)
|
||||
{
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
memset(arp_table[i].ipaddr, 0, 4);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Periodic ARP processing function.
|
||||
*
|
||||
* This function performs periodic timer processing in the ARP module
|
||||
* and should be called at regular intervals. The recommended interval
|
||||
* is 10 seconds between the calls.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_arp_timer(void)
|
||||
{
|
||||
struct arp_entry *tabptr;
|
||||
|
||||
++arptime;
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
if((tabptr->ipaddr[0] | tabptr->ipaddr[1]) != 0 &&
|
||||
arptime - tabptr->time >= UIP_ARP_MAXAGE) {
|
||||
memset(tabptr->ipaddr, 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
uip_arp_update(u16_t *ipaddr, struct uip_eth_addr *ethaddr)
|
||||
{
|
||||
register struct arp_entry *tabptr;
|
||||
/* Walk through the ARP mapping table and try to find an entry to
|
||||
update. If none is found, the IP -> MAC address mapping is
|
||||
inserted in the ARP table. */
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
|
||||
tabptr = &arp_table[i];
|
||||
/* Only check those entries that are actually in use. */
|
||||
if(tabptr->ipaddr[0] != 0 &&
|
||||
tabptr->ipaddr[1] != 0) {
|
||||
|
||||
/* Check if the source IP address of the incoming packet matches
|
||||
the IP address in this ARP table entry. */
|
||||
if(ipaddr[0] == tabptr->ipaddr[0] &&
|
||||
ipaddr[1] == tabptr->ipaddr[1]) {
|
||||
|
||||
/* An old entry found, update this and return. */
|
||||
memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
|
||||
tabptr->time = arptime;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If we get here, no existing ARP table entry was found, so we
|
||||
create one. */
|
||||
|
||||
/* First, we try to find an unused entry in the ARP table. */
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
if(tabptr->ipaddr[0] == 0 &&
|
||||
tabptr->ipaddr[1] == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If no unused entry is found, we try to find the oldest entry and
|
||||
throw it away. */
|
||||
if(i == UIP_ARPTAB_SIZE) {
|
||||
tmpage = 0;
|
||||
c = 0;
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
if(arptime - tabptr->time > tmpage) {
|
||||
tmpage = arptime - tabptr->time;
|
||||
c = i;
|
||||
}
|
||||
}
|
||||
i = c;
|
||||
tabptr = &arp_table[i];
|
||||
}
|
||||
|
||||
/* Now, i is the ARP table entry which we will fill with the new
|
||||
information. */
|
||||
memcpy(tabptr->ipaddr, ipaddr, 4);
|
||||
memcpy(tabptr->ethaddr.addr, ethaddr->addr, 6);
|
||||
tabptr->time = arptime;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* ARP processing for incoming IP packets
|
||||
*
|
||||
* This function should be called by the device driver when an IP
|
||||
* packet has been received. The function will check if the address is
|
||||
* in the ARP cache, and if so the ARP cache entry will be
|
||||
* refreshed. If no ARP cache entry was found, a new one is created.
|
||||
*
|
||||
* This function expects an IP packet with a prepended Ethernet header
|
||||
* in the uip_buf[] buffer, and the length of the packet in the global
|
||||
* variable uip_len.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if 0
|
||||
void
|
||||
uip_arp_ipin(void)
|
||||
{
|
||||
uip_len -= sizeof(struct uip_eth_hdr);
|
||||
|
||||
/* Only insert/update an entry if the source IP address of the
|
||||
incoming IP packet comes from a host on the local network. */
|
||||
if((IPBUF->srcipaddr[0] & uip_netmask[0]) !=
|
||||
(uip_hostaddr[0] & uip_netmask[0])) {
|
||||
return;
|
||||
}
|
||||
if((IPBUF->srcipaddr[1] & uip_netmask[1]) !=
|
||||
(uip_hostaddr[1] & uip_netmask[1])) {
|
||||
return;
|
||||
}
|
||||
uip_arp_update(IPBUF->srcipaddr, &(IPBUF->ethhdr.src));
|
||||
|
||||
return;
|
||||
}
|
||||
#endif /* 0 */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* ARP processing for incoming ARP packets.
|
||||
*
|
||||
* This function should be called by the device driver when an ARP
|
||||
* packet has been received. The function will act differently
|
||||
* depending on the ARP packet type: if it is a reply for a request
|
||||
* that we previously sent out, the ARP cache will be filled in with
|
||||
* the values from the ARP reply. If the incoming ARP packet is an ARP
|
||||
* request for our IP address, an ARP reply packet is created and put
|
||||
* into the uip_buf[] buffer.
|
||||
*
|
||||
* When the function returns, the value of the global variable uip_len
|
||||
* indicates whether the device driver should send out a packet or
|
||||
* not. If uip_len is zero, no packet should be sent. If uip_len is
|
||||
* non-zero, it contains the length of the outbound packet that is
|
||||
* present in the uip_buf[] buffer.
|
||||
*
|
||||
* This function expects an ARP packet with a prepended Ethernet
|
||||
* header in the uip_buf[] buffer, and the length of the packet in the
|
||||
* global variable uip_len.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_arp_arpin(void)
|
||||
{
|
||||
|
||||
if(uip_len < sizeof(struct arp_hdr)) {
|
||||
uip_len = 0;
|
||||
return;
|
||||
}
|
||||
uip_len = 0;
|
||||
|
||||
switch(BUF->opcode) {
|
||||
case HTONS(ARP_REQUEST):
|
||||
/* ARP request. If it asked for our address, we send out a
|
||||
reply. */
|
||||
if(uip_ipaddr_cmp(BUF->dipaddr, uip_hostaddr)) {
|
||||
/* First, we register the one who made the request in our ARP
|
||||
table, since it is likely that we will do more communication
|
||||
with this host in the future. */
|
||||
uip_arp_update(BUF->sipaddr, &BUF->shwaddr);
|
||||
|
||||
/* The reply opcode is 2. */
|
||||
BUF->opcode = HTONS(2);
|
||||
|
||||
memcpy(BUF->dhwaddr.addr, BUF->shwaddr.addr, 6);
|
||||
memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
|
||||
memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||
memcpy(BUF->ethhdr.dest.addr, BUF->dhwaddr.addr, 6);
|
||||
|
||||
BUF->dipaddr[0] = BUF->sipaddr[0];
|
||||
BUF->dipaddr[1] = BUF->sipaddr[1];
|
||||
BUF->sipaddr[0] = uip_hostaddr[0];
|
||||
BUF->sipaddr[1] = uip_hostaddr[1];
|
||||
|
||||
BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
|
||||
uip_len = sizeof(struct arp_hdr);
|
||||
}
|
||||
break;
|
||||
case HTONS(ARP_REPLY):
|
||||
/* ARP reply. We insert or update the ARP table if it was meant
|
||||
for us. */
|
||||
if(uip_ipaddr_cmp(BUF->dipaddr, uip_hostaddr)) {
|
||||
uip_arp_update(BUF->sipaddr, &BUF->shwaddr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* Prepend Ethernet header to an outbound IP packet and see if we need
|
||||
* to send out an ARP request.
|
||||
*
|
||||
* This function should be called before sending out an IP packet. The
|
||||
* function checks the destination IP address of the IP packet to see
|
||||
* what Ethernet MAC address that should be used as a destination MAC
|
||||
* address on the Ethernet.
|
||||
*
|
||||
* If the destination IP address is in the local network (determined
|
||||
* by logical ANDing of netmask and our IP address), the function
|
||||
* checks the ARP cache to see if an entry for the destination IP
|
||||
* address is found. If so, an Ethernet header is prepended and the
|
||||
* function returns. If no ARP cache entry is found for the
|
||||
* destination IP address, the packet in the uip_buf[] is replaced by
|
||||
* an ARP request packet for the IP address. The IP packet is dropped
|
||||
* and it is assumed that they higher level protocols (e.g., TCP)
|
||||
* eventually will retransmit the dropped packet.
|
||||
*
|
||||
* If the destination IP address is not on the local network, the IP
|
||||
* address of the default router is used instead.
|
||||
*
|
||||
* When the function returns, a packet is present in the uip_buf[]
|
||||
* buffer, and the length of the packet is in the global variable
|
||||
* uip_len.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_arp_out(void)
|
||||
{
|
||||
struct arp_entry *tabptr;
|
||||
|
||||
/* Find the destination IP address in the ARP table and construct
|
||||
the Ethernet header. If the destination IP addres isn't on the
|
||||
local network, we use the default router's IP address instead.
|
||||
|
||||
If not ARP table entry is found, we overwrite the original IP
|
||||
packet with an ARP request for the IP address. */
|
||||
|
||||
/* First check if destination is a local broadcast. */
|
||||
if(uip_ipaddr_cmp(IPBUF->destipaddr, broadcast_ipaddr)) {
|
||||
memcpy(IPBUF->ethhdr.dest.addr, broadcast_ethaddr.addr, 6);
|
||||
} else {
|
||||
/* Check if the destination address is on the local network. */
|
||||
if(!uip_ipaddr_maskcmp(IPBUF->destipaddr, uip_hostaddr, uip_netmask)) {
|
||||
/* Destination address was not on the local network, so we need to
|
||||
use the default router's IP address instead of the destination
|
||||
address when determining the MAC address. */
|
||||
uip_ipaddr_copy(ipaddr, uip_draddr);
|
||||
} else {
|
||||
/* Else, we use the destination IP address. */
|
||||
uip_ipaddr_copy(ipaddr, IPBUF->destipaddr);
|
||||
}
|
||||
|
||||
for(i = 0; i < UIP_ARPTAB_SIZE; ++i) {
|
||||
tabptr = &arp_table[i];
|
||||
if(uip_ipaddr_cmp(ipaddr, tabptr->ipaddr)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(i == UIP_ARPTAB_SIZE) {
|
||||
/* The destination address was not in our ARP table, so we
|
||||
overwrite the IP packet with an ARP request. */
|
||||
|
||||
memset(BUF->ethhdr.dest.addr, 0xff, 6);
|
||||
memset(BUF->dhwaddr.addr, 0x00, 6);
|
||||
memcpy(BUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||
memcpy(BUF->shwaddr.addr, uip_ethaddr.addr, 6);
|
||||
|
||||
uip_ipaddr_copy(BUF->dipaddr, ipaddr);
|
||||
uip_ipaddr_copy(BUF->sipaddr, uip_hostaddr);
|
||||
BUF->opcode = HTONS(ARP_REQUEST); /* ARP request. */
|
||||
BUF->hwtype = HTONS(ARP_HWTYPE_ETH);
|
||||
BUF->protocol = HTONS(UIP_ETHTYPE_IP);
|
||||
BUF->hwlen = 6;
|
||||
BUF->protolen = 4;
|
||||
BUF->ethhdr.type = HTONS(UIP_ETHTYPE_ARP);
|
||||
|
||||
uip_appdata = &uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN];
|
||||
|
||||
uip_len = sizeof(struct arp_hdr);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Build an ethernet header. */
|
||||
memcpy(IPBUF->ethhdr.dest.addr, tabptr->ethaddr.addr, 6);
|
||||
}
|
||||
memcpy(IPBUF->ethhdr.src.addr, uip_ethaddr.addr, 6);
|
||||
|
||||
IPBUF->ethhdr.type = HTONS(UIP_ETHTYPE_IP);
|
||||
|
||||
uip_len += sizeof(struct uip_eth_hdr);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* \addtogroup uip
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup uiparp
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Macros and definitions for the ARP module.
|
||||
* \author Adam Dunkels <adam@dunkels.com>
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: uip_arp.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __UIP_ARP_H__
|
||||
#define __UIP_ARP_H__
|
||||
|
||||
#include "uip.h"
|
||||
|
||||
#if UIP_FIXEDETHADDR
|
||||
extern const struct uip_eth_addr uip_ethaddr;
|
||||
#else
|
||||
extern struct uip_eth_addr uip_ethaddr;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The Ethernet header.
|
||||
*/
|
||||
struct uip_eth_hdr {
|
||||
struct uip_eth_addr dest;
|
||||
struct uip_eth_addr src;
|
||||
u16_t type;
|
||||
};
|
||||
|
||||
#define UIP_ETHTYPE_ARP 0x0806
|
||||
#define UIP_ETHTYPE_IP 0x0800
|
||||
#define UIP_ETHTYPE_IP6 0x86dd
|
||||
|
||||
|
||||
/* The uip_arp_init() function must be called before any of the other
|
||||
ARP functions. */
|
||||
void uip_arp_init(void);
|
||||
|
||||
/* The uip_arp_ipin() function should be called whenever an IP packet
|
||||
arrives from the Ethernet. This function refreshes the ARP table or
|
||||
inserts a new mapping if none exists. The function assumes that an
|
||||
IP packet with an Ethernet header is present in the uip_buf buffer
|
||||
and that the length of the packet is in the uip_len variable. */
|
||||
/*void uip_arp_ipin(void);*/
|
||||
#define uip_arp_ipin()
|
||||
|
||||
/* The uip_arp_arpin() should be called when an ARP packet is received
|
||||
by the Ethernet driver. This function also assumes that the
|
||||
Ethernet frame is present in the uip_buf buffer. When the
|
||||
uip_arp_arpin() function returns, the contents of the uip_buf
|
||||
buffer should be sent out on the Ethernet if the uip_len variable
|
||||
is > 0. */
|
||||
void uip_arp_arpin(void);
|
||||
|
||||
/* The uip_arp_out() function should be called when an IP packet
|
||||
should be sent out on the Ethernet. This function creates an
|
||||
Ethernet header before the IP header in the uip_buf buffer. The
|
||||
Ethernet header will have the correct Ethernet MAC destination
|
||||
address filled in if an ARP table entry for the destination IP
|
||||
address (or the IP address of the default router) is present. If no
|
||||
such table entry is found, the IP packet is overwritten with an ARP
|
||||
request and we rely on TCP to retransmit the packet that was
|
||||
overwritten. In any case, the uip_len variable holds the length of
|
||||
the Ethernet frame that should be transmitted. */
|
||||
void uip_arp_out(void);
|
||||
|
||||
/* The uip_arp_timer() function should be called every ten seconds. It
|
||||
is responsible for flushing old entries in the ARP table. */
|
||||
void uip_arp_timer(void);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* \addtogroup uipconffunc
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Specifiy the Ethernet MAC address.
|
||||
*
|
||||
* The ARP code needs to know the MAC address of the Ethernet card in
|
||||
* order to be able to respond to ARP queries and to generate working
|
||||
* Ethernet headers.
|
||||
*
|
||||
* \note This macro only specifies the Ethernet MAC address to the ARP
|
||||
* code. It cannot be used to change the MAC address of the Ethernet
|
||||
* card.
|
||||
*
|
||||
* \param eaddr A pointer to a struct uip_eth_addr containing the
|
||||
* Ethernet MAC address of the Ethernet card.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#if UIP_FIXEDETHADDR == 0
|
||||
#define uip_setethaddr(eaddr) do {uip_ethaddr.addr[0] = eaddr.addr[0]; \
|
||||
uip_ethaddr.addr[1] = eaddr.addr[1];\
|
||||
uip_ethaddr.addr[2] = eaddr.addr[2];\
|
||||
uip_ethaddr.addr[3] = eaddr.addr[3];\
|
||||
uip_ethaddr.addr[4] = eaddr.addr[4];\
|
||||
uip_ethaddr.addr[5] = eaddr.addr[5];} while(0)
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
#endif /* __UIP_ARP_H__ */
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Adam Dunkels and the Swedish Institute of
|
||||
* Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* $Id: uiplib.c,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "uip.h"
|
||||
#include "uiplib.h"
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
uiplib_ipaddrconv(char *addrstr, unsigned char *ipaddr)
|
||||
{
|
||||
unsigned char tmp;
|
||||
char c;
|
||||
unsigned char i, j;
|
||||
|
||||
tmp = 0;
|
||||
|
||||
for(i = 0; i < 4; ++i) {
|
||||
j = 0;
|
||||
do {
|
||||
c = *addrstr;
|
||||
++j;
|
||||
if(j > 4) {
|
||||
return 0;
|
||||
}
|
||||
if(c == '.' || c == 0) {
|
||||
*ipaddr = tmp;
|
||||
++ipaddr;
|
||||
tmp = 0;
|
||||
} else if(c >= '0' && c <= '9') {
|
||||
tmp = (tmp * 10) + (c - '0');
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
++addrstr;
|
||||
} while(c != '.' && c != 0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* \file
|
||||
* Various uIP library functions.
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack
|
||||
*
|
||||
* $Id: uiplib.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*
|
||||
*/
|
||||
#ifndef __UIPLIB_H__
|
||||
#define __UIPLIB_H__
|
||||
|
||||
/**
|
||||
* \addtogroup uipconvfunc
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Convert a textual representation of an IP address to a numerical representation.
|
||||
*
|
||||
* This function takes a textual representation of an IP address in
|
||||
* the form a.b.c.d and converts it into a 4-byte array that can be
|
||||
* used by other uIP functions.
|
||||
*
|
||||
* \param addrstr A pointer to a string containing the IP address in
|
||||
* textual form.
|
||||
*
|
||||
* \param addr A pointer to a 4-byte array that will be filled in with
|
||||
* the numerical representation of the address.
|
||||
*
|
||||
* \retval 0 If the IP address could not be parsed.
|
||||
* \retval Non-zero If the IP address was parsed.
|
||||
*/
|
||||
unsigned char uiplib_ipaddrconv(char *addrstr, unsigned char *addr);
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* __UIPLIB_H__ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user