Added Software projects
git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@55 9fe90eed-be63-e94b-8204-d34ff4c2ff93
This commit is contained in:
@@ -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__ */
|
||||
@@ -0,0 +1,559 @@
|
||||
/**
|
||||
* \defgroup uipopt Configuration options for uIP
|
||||
* @{
|
||||
*
|
||||
* uIP is configured using the per-project configuration file
|
||||
* uipopt.h. This file contains all compile-time options for uIP and
|
||||
* should be tweaked to match each specific project. The uIP
|
||||
* distribution contains a documented example "uipopt.h" that can be
|
||||
* copied and modified for each project.
|
||||
*
|
||||
* \note Most of the configuration options in the uipopt.h should not
|
||||
* be changed, but rather the per-project uip-conf.h file.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Configuration options for uIP.
|
||||
* \author Adam Dunkels <adam@dunkels.com>
|
||||
*
|
||||
* This file is used for tweaking various configuration options for
|
||||
* uIP. You should make a copy of this file into one of your project's
|
||||
* directories instead of editing this example "uipopt.h" file that
|
||||
* comes with the uIP distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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: uipopt.h,v 1.1.2.3 2006/12/04 18:52:39 fredrikh Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __UIPOPT_H__
|
||||
#define __UIPOPT_H__
|
||||
|
||||
#ifndef UIP_LITTLE_ENDIAN
|
||||
#define UIP_LITTLE_ENDIAN 3412
|
||||
#endif /* UIP_LITTLE_ENDIAN */
|
||||
#ifndef UIP_BIG_ENDIAN
|
||||
#define UIP_BIG_ENDIAN 1234
|
||||
#endif /* UIP_BIG_ENDIAN */
|
||||
|
||||
#include "uip-conf.h"
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \name Static configuration options
|
||||
* @{
|
||||
*
|
||||
* These configuration options can be used for setting the IP address
|
||||
* settings statically, but only if UIP_FIXEDADDR is set to 1. The
|
||||
* configuration options for a specific node includes IP address,
|
||||
* netmask and default router as well as the Ethernet address. The
|
||||
* netmask, default router and Ethernet address are appliciable only
|
||||
* if uIP should be run over Ethernet.
|
||||
*
|
||||
* All of these should be changed to suit your project.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Determines if uIP should use a fixed IP address or not.
|
||||
*
|
||||
* If uIP should use a fixed IP address, the settings are set in the
|
||||
* uipopt.h file. If not, the macros uip_sethostaddr(),
|
||||
* uip_setdraddr() and uip_setnetmask() should be used instead.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_FIXEDADDR 0
|
||||
|
||||
/**
|
||||
* Ping IP address asignment.
|
||||
*
|
||||
* uIP uses a "ping" packets for setting its own IP address if this
|
||||
* option is set. If so, uIP will start with an empty IP address and
|
||||
* the destination IP address of the first incoming "ping" (ICMP echo)
|
||||
* packet will be used for setting the hosts IP address.
|
||||
*
|
||||
* \note This works only if UIP_FIXEDADDR is 0.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_PINGADDRCONF
|
||||
#define UIP_PINGADDRCONF UIP_CONF_PINGADDRCONF
|
||||
#else /* UIP_CONF_PINGADDRCONF */
|
||||
#define UIP_PINGADDRCONF 0
|
||||
#endif /* UIP_CONF_PINGADDRCONF */
|
||||
|
||||
|
||||
/**
|
||||
* Specifies if the uIP ARP module should be compiled with a fixed
|
||||
* Ethernet MAC address or not.
|
||||
*
|
||||
* If this configuration option is 0, the macro uip_setethaddr() can
|
||||
* be used to specify the Ethernet address at run-time.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_FIXEDETHADDR 1
|
||||
|
||||
#define UIP_ETHADDR0 0x00 /**< The first octet of the Ethernet
|
||||
address if UIP_FIXEDETHADDR is
|
||||
1. \hideinitializer */
|
||||
#define UIP_ETHADDR1 0xFF /**< The second octet of the Ethernet
|
||||
address if UIP_FIXEDETHADDR is
|
||||
1. \hideinitializer */
|
||||
#define UIP_ETHADDR2 0xFF /**< The third octet of the Ethernet
|
||||
address if UIP_FIXEDETHADDR is
|
||||
1. \hideinitializer */
|
||||
#define UIP_ETHADDR3 0xFF /**< The fourth octet of the Ethernet
|
||||
address if UIP_FIXEDETHADDR is
|
||||
1. \hideinitializer */
|
||||
#define UIP_ETHADDR4 0xFF /**< The fifth octet of the Ethernet
|
||||
address if UIP_FIXEDETHADDR is
|
||||
1. \hideinitializer */
|
||||
#define UIP_ETHADDR5 0xFF /**< The sixth octet of the Ethernet
|
||||
address if UIP_FIXEDETHADDR is
|
||||
1. \hideinitializer */
|
||||
|
||||
|
||||
/** @} */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name IP configuration options
|
||||
* @{
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* The IP TTL (time to live) of IP packets sent by uIP.
|
||||
*
|
||||
* This should normally not be changed.
|
||||
*/
|
||||
#define UIP_TTL 64
|
||||
|
||||
/**
|
||||
* Turn on support for IP packet reassembly.
|
||||
*
|
||||
* uIP supports reassembly of fragmented IP packets. This features
|
||||
* requires an additonal amount of RAM to hold the reassembly buffer
|
||||
* and the reassembly code size is approximately 700 bytes. The
|
||||
* reassembly buffer is of the same size as the uip_buf buffer
|
||||
* (configured by UIP_BUFSIZE).
|
||||
*
|
||||
* \note IP packet reassembly is not heavily tested.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_REASSEMBLY 0
|
||||
|
||||
/**
|
||||
* The maximum time an IP fragment should wait in the reassembly
|
||||
* buffer before it is dropped.
|
||||
*
|
||||
*/
|
||||
#define UIP_REASS_MAXAGE 40
|
||||
|
||||
/** @} */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name UDP configuration options
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Toggles wether UDP support should be compiled in or not.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_UDP
|
||||
#define UIP_UDP UIP_CONF_UDP
|
||||
#else /* UIP_CONF_UDP */
|
||||
#define UIP_UDP 0
|
||||
#endif /* UIP_CONF_UDP */
|
||||
|
||||
/**
|
||||
* Toggles if UDP checksums should be used or not.
|
||||
*
|
||||
* \note Support for UDP checksums is currently not included in uIP,
|
||||
* so this option has no function.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_UDP_CHECKSUMS
|
||||
#define UIP_UDP_CHECKSUMS UIP_CONF_UDP_CHECKSUMS
|
||||
#else
|
||||
#define UIP_UDP_CHECKSUMS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum amount of concurrent UDP connections.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_UDP_CONNS
|
||||
#define UIP_UDP_CONNS UIP_CONF_UDP_CONNS
|
||||
#else /* UIP_CONF_UDP_CONNS */
|
||||
#define UIP_UDP_CONNS 10
|
||||
#endif /* UIP_CONF_UDP_CONNS */
|
||||
|
||||
/**
|
||||
* The name of the function that should be called when UDP datagrams arrive.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
|
||||
|
||||
/** @} */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name TCP configuration options
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Determines if support for opening connections from uIP should be
|
||||
* compiled in.
|
||||
*
|
||||
* If the applications that are running on top of uIP for this project
|
||||
* do not need to open outgoing TCP connections, this configration
|
||||
* option can be turned off to reduce the code size of uIP.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_ACTIVE_OPEN 1
|
||||
|
||||
/**
|
||||
* The maximum number of simultaneously open TCP connections.
|
||||
*
|
||||
* Since the TCP connections are statically allocated, turning this
|
||||
* configuration knob down results in less RAM used. Each TCP
|
||||
* connection requires approximatly 30 bytes of memory.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifndef UIP_CONF_MAX_CONNECTIONS
|
||||
#define UIP_CONNS 10
|
||||
#else /* UIP_CONF_MAX_CONNECTIONS */
|
||||
#define UIP_CONNS UIP_CONF_MAX_CONNECTIONS
|
||||
#endif /* UIP_CONF_MAX_CONNECTIONS */
|
||||
|
||||
|
||||
/**
|
||||
* The maximum number of simultaneously listening TCP ports.
|
||||
*
|
||||
* Each listening TCP port requires 2 bytes of memory.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifndef UIP_CONF_MAX_LISTENPORTS
|
||||
#define UIP_LISTENPORTS 20
|
||||
#else /* UIP_CONF_MAX_LISTENPORTS */
|
||||
#define UIP_LISTENPORTS UIP_CONF_MAX_LISTENPORTS
|
||||
#endif /* UIP_CONF_MAX_LISTENPORTS */
|
||||
|
||||
/**
|
||||
* Determines if support for TCP urgent data notification should be
|
||||
* compiled in.
|
||||
*
|
||||
* Urgent data (out-of-band data) is a rarely used TCP feature that
|
||||
* very seldom would be required.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#define UIP_URGDATA 0
|
||||
|
||||
/**
|
||||
* The initial retransmission timeout counted in timer pulses.
|
||||
*
|
||||
* This should not be changed.
|
||||
*/
|
||||
#define UIP_RTO 3
|
||||
|
||||
/**
|
||||
* The maximum number of times a segment should be retransmitted
|
||||
* before the connection should be aborted.
|
||||
*
|
||||
* This should not be changed.
|
||||
*/
|
||||
#define UIP_MAXRTX 8
|
||||
|
||||
/**
|
||||
* The maximum number of times a SYN segment should be retransmitted
|
||||
* before a connection request should be deemed to have been
|
||||
* unsuccessful.
|
||||
*
|
||||
* This should not need to be changed.
|
||||
*/
|
||||
#define UIP_MAXSYNRTX 5
|
||||
|
||||
/**
|
||||
* The TCP maximum segment size.
|
||||
*
|
||||
* This is should not be to set to more than
|
||||
* UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN.
|
||||
*/
|
||||
#define UIP_TCP_MSS (UIP_BUFSIZE - UIP_LLH_LEN - UIP_TCPIP_HLEN)
|
||||
|
||||
/**
|
||||
* The size of the advertised receiver's window.
|
||||
*
|
||||
* Should be set low (i.e., to the size of the uip_buf buffer) is the
|
||||
* application is slow to process incoming data, or high (32768 bytes)
|
||||
* if the application processes data quickly.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifndef UIP_CONF_RECEIVE_WINDOW
|
||||
#define UIP_RECEIVE_WINDOW UIP_TCP_MSS
|
||||
#else
|
||||
#define UIP_RECEIVE_WINDOW UIP_CONF_RECEIVE_WINDOW
|
||||
#endif
|
||||
|
||||
/**
|
||||
* How long a connection should stay in the TIME_WAIT state.
|
||||
*
|
||||
* This configiration option has no real implication, and it should be
|
||||
* left untouched.
|
||||
*/
|
||||
#define UIP_TIME_WAIT_TIMEOUT 120
|
||||
|
||||
|
||||
/** @} */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name ARP configuration options
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The size of the ARP table.
|
||||
*
|
||||
* This option should be set to a larger value if this uIP node will
|
||||
* have many connections from the local network.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_ARPTAB_SIZE
|
||||
#define UIP_ARPTAB_SIZE UIP_CONF_ARPTAB_SIZE
|
||||
#else
|
||||
#define UIP_ARPTAB_SIZE 8
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maxium age of ARP table entries measured in 10ths of seconds.
|
||||
*
|
||||
* An UIP_ARP_MAXAGE of 120 corresponds to 20 minutes (BSD
|
||||
* default).
|
||||
*/
|
||||
#define UIP_ARP_MAXAGE 120
|
||||
|
||||
/** @} */
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \name General configuration options
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The size of the uIP packet buffer.
|
||||
*
|
||||
* The uIP packet buffer should not be smaller than 60 bytes, and does
|
||||
* not need to be larger than 1500 bytes. Lower size results in lower
|
||||
* TCP throughput, larger size results in higher TCP throughput.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifndef UIP_CONF_BUFFER_SIZE
|
||||
#define UIP_BUFSIZE 1520
|
||||
#else /* UIP_CONF_BUFFER_SIZE */
|
||||
#define UIP_BUFSIZE UIP_CONF_BUFFER_SIZE
|
||||
#endif /* UIP_CONF_BUFFER_SIZE */
|
||||
|
||||
|
||||
/**
|
||||
* Determines if statistics support should be compiled in.
|
||||
*
|
||||
* The statistics is useful for debugging and to show the user.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifndef UIP_CONF_STATISTICS
|
||||
#define UIP_STATISTICS 0
|
||||
#else /* UIP_CONF_STATISTICS */
|
||||
#define UIP_STATISTICS UIP_CONF_STATISTICS
|
||||
#endif /* UIP_CONF_STATISTICS */
|
||||
|
||||
/**
|
||||
* Determines if logging of certain events should be compiled in.
|
||||
*
|
||||
* This is useful mostly for debugging. The function uip_log()
|
||||
* must be implemented to suit the architecture of the project, if
|
||||
* logging is turned on.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifndef UIP_CONF_LOGGING
|
||||
#define UIP_LOGGING 0
|
||||
#else /* UIP_CONF_LOGGING */
|
||||
#define UIP_LOGGING UIP_CONF_LOGGING
|
||||
#endif /* UIP_CONF_LOGGING */
|
||||
|
||||
/**
|
||||
* Broadcast support.
|
||||
*
|
||||
* This flag configures IP broadcast support. This is useful only
|
||||
* together with UDP.
|
||||
*
|
||||
* \hideinitializer
|
||||
*
|
||||
*/
|
||||
#ifndef UIP_CONF_BROADCAST
|
||||
#define UIP_BROADCAST 0
|
||||
#else /* UIP_CONF_BROADCAST */
|
||||
#define UIP_BROADCAST UIP_CONF_BROADCAST
|
||||
#endif /* UIP_CONF_BROADCAST */
|
||||
|
||||
/**
|
||||
* Print out a uIP log message.
|
||||
*
|
||||
* This function must be implemented by the module that uses uIP, and
|
||||
* is called by uIP whenever a log message is generated.
|
||||
*/
|
||||
void uip_log(char *msg);
|
||||
|
||||
/**
|
||||
* The link level header length.
|
||||
*
|
||||
* This is the offset into the uip_buf where the IP header can be
|
||||
* found. For Ethernet, this should be set to 14. For SLIP, this
|
||||
* should be set to 0.
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_LLH_LEN
|
||||
#define UIP_LLH_LEN UIP_CONF_LLH_LEN
|
||||
#else /* UIP_CONF_LLH_LEN */
|
||||
#define UIP_LLH_LEN 14
|
||||
#endif /* UIP_CONF_LLH_LEN */
|
||||
|
||||
/** @} */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \name CPU architecture configuration
|
||||
* @{
|
||||
*
|
||||
* The CPU architecture configuration is where the endianess of the
|
||||
* CPU on which uIP is to be run is specified. Most CPUs today are
|
||||
* little endian, and the most notable exception are the Motorolas
|
||||
* which are big endian. The BYTE_ORDER macro should be changed to
|
||||
* reflect the CPU architecture on which uIP is to be run.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The byte order of the CPU architecture on which uIP is to be run.
|
||||
*
|
||||
* This option can be either BIG_ENDIAN (Motorola byte order) or
|
||||
* LITTLE_ENDIAN (Intel byte order).
|
||||
*
|
||||
* \hideinitializer
|
||||
*/
|
||||
#ifdef UIP_CONF_BYTE_ORDER
|
||||
#define UIP_BYTE_ORDER UIP_CONF_BYTE_ORDER
|
||||
#else /* UIP_CONF_BYTE_ORDER */
|
||||
#define UIP_BYTE_ORDER UIP_LITTLE_ENDIAN
|
||||
#endif /* UIP_CONF_BYTE_ORDER */
|
||||
|
||||
/** @} */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \name Appication specific configurations
|
||||
* @{
|
||||
*
|
||||
* An uIP application is implemented using a single application
|
||||
* function that is called by uIP whenever a TCP/IP event occurs. The
|
||||
* name of this function must be registered with uIP at compile time
|
||||
* using the UIP_APPCALL definition.
|
||||
*
|
||||
* uIP applications can store the application state within the
|
||||
* uip_conn structure by specifying the type of the application
|
||||
* structure by typedef:ing the type uip_tcp_appstate_t and uip_udp_appstate_t.
|
||||
*
|
||||
* The file containing the definitions must be included in the
|
||||
* uipopt.h file.
|
||||
*
|
||||
* The following example illustrates how this can look.
|
||||
\code
|
||||
|
||||
void httpd_appcall(void);
|
||||
#define UIP_APPCALL httpd_appcall
|
||||
|
||||
struct httpd_state {
|
||||
u8_t state;
|
||||
u16_t count;
|
||||
char *dataptr;
|
||||
char *script;
|
||||
};
|
||||
typedef struct httpd_state uip_tcp_appstate_t
|
||||
\endcode
|
||||
*/
|
||||
|
||||
/**
|
||||
* \var #define UIP_APPCALL
|
||||
*
|
||||
* The name of the application function that uIP should call in
|
||||
* response to TCP/IP events.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \var typedef uip_tcp_appstate_t
|
||||
*
|
||||
* The type of the application state that is to be stored in the
|
||||
* uip_conn structure. This usually is typedef:ed to a struct holding
|
||||
* application state information.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \var typedef uip_udp_appstate_t
|
||||
*
|
||||
* The type of the application state that is to be stored in the
|
||||
* uip_conn structure. This usually is typedef:ed to a struct holding
|
||||
* application state information.
|
||||
*/
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
#endif /* __UIPOPT_H__ */
|
||||
@@ -0,0 +1,78 @@
|
||||
/*****************************************************************************
|
||||
* irq.c: Interrupt handler C file for NXP LPC230x Family Microprocessors
|
||||
*
|
||||
* Copyright(C) 2006, NXP Semiconductor
|
||||
* All rights reserved.
|
||||
*
|
||||
* History
|
||||
* 2006.07.13 ver 1.00 Prelimnary version, first Release
|
||||
*
|
||||
******************************************************************************/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
#include "irq.h"
|
||||
|
||||
/* Initialize the interrupt controller */
|
||||
/******************************************************************************
|
||||
** Function name: init_VIC
|
||||
**
|
||||
** Descriptions: Initialize VIC interrupt controller.
|
||||
** parameters: None
|
||||
** Returned value: None
|
||||
**
|
||||
******************************************************************************/
|
||||
void init_VIC(void)
|
||||
{
|
||||
UINT32 i = 0;
|
||||
UINT32 *vect_addr, *vect_cntl;
|
||||
|
||||
/* initialize VIC*/
|
||||
VICIntEnClr = 0xffffffff;
|
||||
VICVectAddr = 0;
|
||||
VICIntSelect = 0;
|
||||
|
||||
/* set all the vector and vector control register to 0 */
|
||||
for ( i = 0; i < VIC_SIZE; i++ )
|
||||
{
|
||||
vect_addr = (UINT32 *)(VIC_BASE_ADDR + VECT_ADDR_INDEX + i*4);
|
||||
vect_cntl = (UINT32 *)(VIC_BASE_ADDR + VECT_CNTL_INDEX + i*4);
|
||||
*vect_addr = 0x0;
|
||||
*vect_cntl = 0xF;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
** Function name: install_irq
|
||||
**
|
||||
** Descriptions: Install interrupt handler
|
||||
** parameters: Interrupt number, interrupt handler address,
|
||||
** interrupt priority
|
||||
** Returned value: true or false, return false if IntNum is out of range
|
||||
**
|
||||
******************************************************************************/
|
||||
BOOLEAN install_irq( UINT32 IntNumber, void *HandlerAddr, UINT32 Priority )
|
||||
{
|
||||
UINT32 *vect_addr;
|
||||
UINT32 *vect_cntl;
|
||||
|
||||
VICIntEnClr = 1 << IntNumber; /* Disable Interrupt */
|
||||
if ( IntNumber >= VIC_SIZE )
|
||||
{
|
||||
return ( FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* find first un-assigned VIC address for the handler */
|
||||
vect_addr = (UINT32 *)(VIC_BASE_ADDR + VECT_ADDR_INDEX + IntNumber*4);
|
||||
vect_cntl = (UINT32 *)(VIC_BASE_ADDR + VECT_CNTL_INDEX + IntNumber*4);
|
||||
*vect_addr = (UINT32)HandlerAddr; /* set interrupt vector */
|
||||
*vect_cntl = Priority;
|
||||
VICIntEnable = 1 << IntNumber; /* Enable Interrupt */
|
||||
return( TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
** End Of File
|
||||
******************************************************************************/
|
||||
@@ -0,0 +1,73 @@
|
||||
/******************************************************************************
|
||||
* irq.h: Interrupt related Header file for NXP LPC230x Family
|
||||
* Microprocessors
|
||||
*
|
||||
* Copyright(C) 2006, NXP Semiconductor
|
||||
* All rights reserved.
|
||||
*
|
||||
* History
|
||||
* 2006.09.01 ver 1.00 Prelimnary version, first Release
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef __IRQ_H
|
||||
#define __IRQ_H
|
||||
|
||||
#define I_Bit 0x80
|
||||
#define F_Bit 0x40
|
||||
|
||||
#define SYS32Mode 0x1F
|
||||
#define IRQ32Mode 0x12
|
||||
#define FIQ32Mode 0x11
|
||||
|
||||
#define HIGHEST_PRIORITY 0x01
|
||||
#define LOWEST_PRIORITY 0x0F
|
||||
|
||||
#define WDT_INT 0
|
||||
#define SWI_INT 1
|
||||
#define ARM_CORE0_INT 2
|
||||
#define ARM_CORE1_INT 3
|
||||
#define TIMER0_INT 4
|
||||
#define TIMER1_INT 5
|
||||
#define UART0_INT 6
|
||||
#define UART1_INT 7
|
||||
#define PWM0_1_INT 8
|
||||
#define I2C0_INT 9
|
||||
#define SPI0_INT 10 /* SPI and SSP0 share VIC slot */
|
||||
#define SSP0_INT 10
|
||||
#define SSP1_INT 11
|
||||
#define PLL_INT 12
|
||||
#define RTC_INT 13
|
||||
#define EINT0_INT 14
|
||||
#define EINT1_INT 15
|
||||
#define EINT2_INT 16
|
||||
#define EINT3_INT 17
|
||||
#define ADC0_INT 18
|
||||
#define I2C1_INT 19
|
||||
#define BOD_INT 20
|
||||
#define EMAC_INT 21
|
||||
#define USB_INT 22
|
||||
#define CAN_INT 23
|
||||
#define MCI_INT 24
|
||||
#define GPDMA_INT 25
|
||||
#define TIMER2_INT 26
|
||||
#define TIMER3_INT 27
|
||||
#define UART2_INT 28
|
||||
#define UART3_INT 29
|
||||
#define I2C2_INT 30
|
||||
#define I2S_INT 31
|
||||
|
||||
#define VIC_SIZE 32
|
||||
|
||||
//#define VIC_BASE_ADDR ((unsigned int)&VICIRQSTATUS)
|
||||
|
||||
#define VECT_ADDR_INDEX 0x100
|
||||
#define VECT_CNTL_INDEX 0x200
|
||||
|
||||
void init_VIC( void );
|
||||
BOOLEAN install_irq( UINT32 IntNumber, void *HandlerAddr, UINT32 Priority );
|
||||
|
||||
#endif /* end __IRQ_H */
|
||||
|
||||
/******************************************************************************
|
||||
** End Of File
|
||||
******************************************************************************/
|
||||
@@ -0,0 +1,121 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* 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 "leds.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define LED0_MASK 0x00000010
|
||||
#define LED1_MASK 0x00000020
|
||||
#define LEDS_MASK (LED0_MASK | LED1_MASK)
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void ledInit()
|
||||
{
|
||||
SCS |= (1UL<<0);
|
||||
// set GPIOM in SCS for fast IO
|
||||
|
||||
// Set pin 4 & 5 of port 4 as output
|
||||
FIO0DIR |= LEDS_MASK;
|
||||
|
||||
// Turn LED's off
|
||||
FIO0CLR = LEDS_MASK;
|
||||
}
|
||||
|
||||
void ledSet(t_led_ids ledId, BOOLEAN on)
|
||||
{
|
||||
UINT32 ledMask;
|
||||
|
||||
ledMask = (ledId == LED0 ? LED0_MASK : LED1_MASK);
|
||||
|
||||
if (on == TRUE)
|
||||
{
|
||||
FIO0SET = ledMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
FIO0CLR = ledMask;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOLEAN ledGet( t_led_ids ledId )
|
||||
{
|
||||
UINT32 ledMask;
|
||||
|
||||
ledMask = (ledId == LED0 ? LED0_MASK : LED1_MASK);
|
||||
|
||||
|
||||
if (FIO0PIN & ledMask)
|
||||
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void ledToggle(t_led_ids ledId)
|
||||
{
|
||||
UINT32 ledMask;
|
||||
|
||||
ledMask = (ledId == LED0 ? LED0_MASK : LED1_MASK);
|
||||
if (FIO0PIN & ledMask)
|
||||
{
|
||||
FIO0CLR = ledMask;
|
||||
// Turn off led
|
||||
}
|
||||
else
|
||||
{
|
||||
FIO0SET = ledMask;
|
||||
// Turn on led
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* leds.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: LED-driver interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 10-09-2007, Marcel Mulder.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __LEDS_H__
|
||||
#define __LEDS_H__
|
||||
|
||||
/** \file leds.h
|
||||
\brief LED driver interface.
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
LED0, /**< First LED */
|
||||
LED1 /**< Second LED*/
|
||||
} t_led_ids;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** \brief Initialize of leds interface.*/
|
||||
void ledInit( void );
|
||||
|
||||
/** \brief Sets the status of a LED.*/
|
||||
void ledSet( t_led_ids ledId, BOOLEAN on );
|
||||
|
||||
/** \brief Returns the status of a LED.*/
|
||||
BOOLEAN ledGet( t_led_ids ledId );
|
||||
|
||||
/** \brief Toggles the status of a LED.*/
|
||||
void ledToggle( t_led_ids ledId );
|
||||
|
||||
|
||||
#endif /* __LEDS_H__ */
|
||||
@@ -0,0 +1,217 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* logging.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: log driver
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, Nov 28, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* Compiler includes */
|
||||
#include "string.h"
|
||||
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "logging.h"
|
||||
#include "serial.h"
|
||||
#include "SerOut.h"
|
||||
|
||||
#include "fat_public.h"
|
||||
#include "fat_intern.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
char returndate[12];
|
||||
char returntime[9];
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void enableLog (void)
|
||||
{
|
||||
LogFlag = TRUE;
|
||||
}
|
||||
|
||||
|
||||
void disableLog (void)
|
||||
{
|
||||
LogFlag = FALSE;
|
||||
}
|
||||
|
||||
|
||||
void startLog (UINT32 serialnumber)
|
||||
{
|
||||
char fileName[13];
|
||||
char fileExt[4] = ".txt";
|
||||
|
||||
sprintf (fileName, "%i", serialnumber); /* Convert INT-Value to DEZ-String */
|
||||
strncat (fileName, fileExt, 4);
|
||||
debugPrint ("\n\r");
|
||||
debugPrint (fileName);
|
||||
|
||||
FAT_StatusOut (f_open (&log_file, fileName, (FA_READ | FA_WRITE | FA_CREATE_ALWAYS)));
|
||||
}
|
||||
|
||||
|
||||
void stopLog (void)
|
||||
{
|
||||
FAT_StatusOut (f_sync (&log_file));
|
||||
FAT_StatusOut (f_close (&log_file));
|
||||
}
|
||||
|
||||
|
||||
void writeLog (t_logSource source, t_serial_devices ComPort, Messagetype_t urgency, char * Message)
|
||||
{
|
||||
UINT32 bytes_written;
|
||||
UINT32 string_length;
|
||||
char WriteBuffer[512];
|
||||
|
||||
if (LogFlag == TRUE)
|
||||
{
|
||||
|
||||
if (ComPort == COM1)
|
||||
{
|
||||
strcpy(WriteBuffer, "\nSerial Port: COM1\t");
|
||||
}
|
||||
else if (ComPort == COM2)
|
||||
{
|
||||
strcpy(WriteBuffer, "\nSerial Port: COM2\t");
|
||||
}
|
||||
|
||||
if (source == LogInput)
|
||||
{
|
||||
strcat(WriteBuffer, "Direction: Input\t");
|
||||
}
|
||||
else if (source == LogOutput)
|
||||
{
|
||||
strcat(WriteBuffer, "Direction: Output\t");
|
||||
}
|
||||
|
||||
switch (urgency)
|
||||
{
|
||||
case importantMessage:
|
||||
strcat(WriteBuffer, "Urgency: important Message\t");
|
||||
break;
|
||||
case headerMessage:
|
||||
strcat(WriteBuffer, "Urgency: header Message\t\t");
|
||||
break;
|
||||
case resultMessage:
|
||||
strcat(WriteBuffer, "Urgency: result Message\t\t");
|
||||
break;
|
||||
case noteMessage:
|
||||
strcat(WriteBuffer, "Urgency: note Message\t\t");
|
||||
break;
|
||||
case testMessage:
|
||||
strcat(WriteBuffer, "Urgency: test Message\t\t");
|
||||
break;
|
||||
case menuMessage:
|
||||
strcat(WriteBuffer, "Urgency: menu Message\t\t");
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
// strcat(WriteBuffer, "\n");
|
||||
strcat(WriteBuffer, Message);
|
||||
|
||||
string_length = strlen(WriteBuffer);
|
||||
|
||||
f_write(&log_file, &WriteBuffer, string_length, &bytes_written);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void listLog (char* path)
|
||||
{
|
||||
UINT32 loopcnt;
|
||||
DIR directory;
|
||||
FILINFO fileinfo;
|
||||
|
||||
if (f_opendir(&directory, path) == FR_OK)
|
||||
{
|
||||
loopcnt = strlen(path);
|
||||
|
||||
sendString (SerOutPort, TRUE, importantMessage,
|
||||
"Content of ", path, ":\n\r");
|
||||
|
||||
while ((f_readdir(&directory, &fileinfo) == FR_OK) && fileinfo.fname[0])
|
||||
{
|
||||
sendString (SerOutPort, TRUE, importantMessage,
|
||||
f_tab, &fileinfo.fname[0], Dummy);
|
||||
sendString (SerOutPort, FALSE, importantMessage,
|
||||
f_tab, ItoDStr (fileinfo.fsize), Dummy);
|
||||
sendString (SerOutPort, FALSE, importantMessage,
|
||||
f_tab, formatFiledate (fileinfo.fdate), Dummy);
|
||||
sendString (SerOutPort, FALSE, importantMessage,
|
||||
f_tab, formatFiletime (fileinfo.ftime), Dummy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char * formatFiledate (UINT16 date)
|
||||
{
|
||||
char date_devider = '-';
|
||||
|
||||
strcpy (returndate, ItoDStr (date & 0x0000001F));
|
||||
returndate[2] = date_devider;
|
||||
|
||||
strcat (returndate, ItoDStr ((date & 0x000001E0) >> 5));
|
||||
returndate[5] = date_devider;
|
||||
|
||||
strcat (returndate, ItoDStr (1980 + ((date & 0x0000FE00) >> 9)));
|
||||
returndate[10] = '\0';
|
||||
|
||||
return (returndate);
|
||||
}
|
||||
|
||||
|
||||
char * formatFiletime (UINT16 time)
|
||||
{
|
||||
char date_devider = ':';
|
||||
|
||||
strcpy (returntime, ItoDStr ((time & 0x0000F800) >> 11));
|
||||
returntime[2] = date_devider;
|
||||
|
||||
strcat (returntime, ItoDStr ((time & 0x000007E0) >> 5));
|
||||
returntime[5] = date_devider;
|
||||
|
||||
strcat (returntime, ItoDStr (2 * (time & 0x0000001F)));
|
||||
returntime[8] = '\0';
|
||||
|
||||
return (returntime);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* logging.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 28, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef LOGGING_H_
|
||||
#define LOGGING_H_
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "serial.h"
|
||||
#include "SerOut.h"
|
||||
|
||||
#include "fat_public.h"
|
||||
#include "fat_intern.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef enum _t_logSource
|
||||
{
|
||||
LogInput = 0,
|
||||
LogOutput = 1
|
||||
} t_logSource;
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
BOOLEAN LogFlag;
|
||||
FATFS SD_CARD;
|
||||
FIL log_file;
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void enableLog (void);
|
||||
void disableLog (void);
|
||||
void startLog (UINT32 serialnumber);
|
||||
void stopLog (void);
|
||||
void writeLog (t_logSource source, t_serial_devices ComPort, Messagetype_t urgency, char * Message);
|
||||
void listLog (char* path);
|
||||
|
||||
char * formatFiledate (UINT16 date);
|
||||
char * formatFiletime (UINT16 date);
|
||||
|
||||
|
||||
#endif /*LOGGING_H_*/
|
||||
@@ -0,0 +1,89 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* mem.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: Non-volatile memory interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 10-09-2007, Marcel Mulder.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __MEM_H__
|
||||
#define __MEM_H__
|
||||
|
||||
/** \file mem.h
|
||||
\brief Non-volatile memory interface.
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SEEPROM, /**< Serial (SPI) EEPROM*/
|
||||
SFLASH, /**< Serial (SPI) FLASH*/
|
||||
IFLASH, /**< Internal FLASH*/
|
||||
ISRAM /**< Internal battery backupped SRAM*/
|
||||
} t_mem_devices;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** \brief Initialize non-volatile memory interface.*/
|
||||
void memInit (void);
|
||||
|
||||
/** \brief Read from non-volatile memory.
|
||||
\retval len Length of data
|
||||
\retval data Pointer to data
|
||||
\retval bool True if succesfull
|
||||
*/
|
||||
BOOLEAN memRead (
|
||||
t_mem_devices memDevices,
|
||||
UINT32 addr, /**< Address of memory device*/
|
||||
UINT16 * len, /**< Pointer to length of data*/
|
||||
UINT8 * data /**< Pointer to data*/
|
||||
);
|
||||
|
||||
/** \brief Write to non-volatile memory.
|
||||
\retval bool True if succesfull
|
||||
*/
|
||||
BOOLEAN memWrite (
|
||||
t_mem_devices memDevices,
|
||||
UINT32 addr, /**< Address of memory device*/
|
||||
UINT16 len, /**< Length of data*/
|
||||
UINT8 * data /**< Pointer to data*/
|
||||
);
|
||||
|
||||
#endif /* __MEM_H__ */
|
||||
@@ -0,0 +1,810 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* mmc.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, Apr 22, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/* Compiler Includes */
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "mmc.h"
|
||||
#include "mmc_transfer.h"
|
||||
#include "dio.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define MMC_GLOBAL
|
||||
|
||||
#define __no_init
|
||||
|
||||
#define CSD_GET_TRAN_SPEED_EXP() (MmcSdCsd[ 0]&0x07)
|
||||
#define CSD_GET_TRAN_SPEED_MANT() ((MmcSdCsd[ 0]&0xF8)>>3 )
|
||||
#define CSD_GET_NSAC() (MmcSdCsd[ 1] )
|
||||
#define CSD_GET_TAAC_EXP() (MmcSdCsd[ 2]&0x7)
|
||||
#define CSD_GET_TAAC_MANT() ((MmcSdCsd[ 2]&0xF8)>>3 )
|
||||
#define CSD_GET_R2W_FACTOR() ((MmcSdCsd[15]&0x1C)>>2 )
|
||||
#define CSD_GET_READ_BL_LEN() (MmcSdCsd[ 6]&0x0F)
|
||||
#define CSD_GET_C_SIZE() (((MmcSdCsd[ 5]&0x03)<<10) + (MmcSdCsd[4]<<2) + ((MmcSdCsd[11]&0xc0)>>6))
|
||||
#define CSD_GET_C_SIZE_MULT() (((MmcSdCsd[10]&0x03)<<1 ) +((MmcSdCsd[9]&0x80)>>7))
|
||||
#define CSD_GET_PERM_WRITE_PROTECT() ((MmcSdCsd[13]&0x20)>>5 )
|
||||
#define CSD_GET_TMP_WRITE_PROTECT() ((MmcSdCsd[13]&0x10)>>4 )
|
||||
|
||||
volatile UINT32 i;
|
||||
|
||||
|
||||
#define SpcInquiryRemovableMedium 0x80
|
||||
#define SpcInquiryStandartVersion 5
|
||||
#define SizeOfInquiryDescMmcDsk 36
|
||||
|
||||
const UINT32 MmcTransfExp[] =
|
||||
{ 10000UL, 100000UL, 1000000UL, 10000000UL, 0UL, 0UL, 0UL, 0UL,
|
||||
};
|
||||
|
||||
const UINT32 MmmcAccessTime [] =
|
||||
{ 1UL, 10UL, 100UL, 1000UL, 10000UL, 100000UL, 1000000UL, 10000000UL,
|
||||
};
|
||||
|
||||
const UINT32 MmcCsdMant[] =
|
||||
{ 0UL, 10UL, 12UL, 13UL, 15UL, 20UL, 25UL, 30UL, 35UL, 40UL, 45UL, 50UL,
|
||||
55UL, 60UL, 70UL, 80UL,
|
||||
};
|
||||
|
||||
const MmcCommads_t MmcCmd[CMD_END] =
|
||||
{ /* {TxData, Arg, Resp} */
|
||||
{ 0x00, MmcNoArg, MmcNoResp }, /* CMD0 */
|
||||
{ 0x01, MmcOcr, MmcR3 }, /* CMD1 */
|
||||
{ 0x02, MmcNoArg, MmcR2 }, /* CMD2 */
|
||||
{ 0x03, MmcRelAddr, MmcR1 }, /* CMD3 */
|
||||
{ 0x07, MmcRelAddr, MmcR1 }, /* CMD7 */
|
||||
{ 0x09, MmcRelAddr, MmcR2 }, /* CMD9 */
|
||||
{ 0x0A, MmcRelAddr, MmcR2 }, /* CMD10 */
|
||||
{ 0x0C, MmcNoArg, MmcR1b }, /* CMD12 */
|
||||
{ 0x0D, MmcRelAddr, MmcR1 }, /* CMD13 */
|
||||
{ 0x10, MmcBlockLen, MmcR1 }, /* CMD16 */
|
||||
{ 0x11, MmcDataAdd, MmcR1 }, /* CMD17 */
|
||||
{ 0x12, MmcDataAdd, MmcR1 }, /* CMD18 */
|
||||
{ 0x18, MmcDataAdd, MmcR1 }, /* CMD24 */
|
||||
{ 0x19, MmcDataAdd, MmcR1 }, /* CMD25 */
|
||||
{ 0x1B, MmcOcr, MmcR1 }, /* CMD27 */
|
||||
{ 0x1C, MmcDataAdd, MmcR1b }, /* CMD28 */
|
||||
{ 0x1D, MmcDataAdd, MmcR1b }, /* CMD29 */
|
||||
{ 0x1E, MmcDataAdd, MmcR1 }, /* CMD30 */
|
||||
{ 0x20, MmcDataAdd, MmcR1 }, /* CMD32 */
|
||||
{ 0x21, MmcDataAdd, MmcR1 }, /* CMD33 */
|
||||
{ 0x22, MmcDataAdd, MmcR1 }, /* CMD34 */
|
||||
{ 0x23, MmcDataAdd, MmcR1 }, /* CMD35 */
|
||||
{ 0x24, MmcDataAdd, MmcR1 }, /* CMD36 */
|
||||
{ 0x25, MmcDataAdd, MmcR1 }, /* CMD37 */
|
||||
{ 0x26, MmcNoArg, MmcR1b }, /* CMD38 */
|
||||
{ 0x2A, MmcNoArg, MmcR1b }, /* CMD42 */
|
||||
{ 0x37, MmcRelAddr, MmcR1 }, /* CMD55 */
|
||||
{ 0x38, MmcNoArg, MmcR1 }, /* CMD56 */
|
||||
{ 0x06, MmcDataAdd, MmcR1 }, /* ACMD46 */
|
||||
{ 0x29, MmcDataAdd, MmcR3 }, /* ACMD41 */
|
||||
};
|
||||
|
||||
const UINT8 MmcDskInquiry[]__attribute__((aligned (4)))=
|
||||
{
|
||||
SbcDirectAccess, /* 0 PERIPHERAL QUALIFIER AND DEVICE*/
|
||||
SpcInquiryRemovableMedium, /* 1 RMB */
|
||||
SpcInquiryStandartVersion, /* 2 VERSION */
|
||||
0x02, /* 3 NORMACA HISUP RESPONSE FORMAT */
|
||||
36-4, /* 4 ADDITIONAL LENGTH (n-4) */
|
||||
0x00, /* 5 SCCS */
|
||||
/* for parallel SCSI only */
|
||||
0x00, /* 6 BQUE ENCSERV VS MULTIP MCHNGR Obsolete Obsolete ADDR16 */
|
||||
0x00, /* 7 RELADR Obsolete WBUS16† SYNC† LINKED Obsolete CMDQUE VS*/
|
||||
'I','A','R',' ','S','y','s','.', /* 8 - 15 VENDOR IDENTIFICATION */
|
||||
/* 16 - 31 PRODUCT IDENTIFICATION */
|
||||
'L','P','C','2','3','7','8',' ','S','t','o','r','a','g','e',' ',
|
||||
'1','.','0','0', /* 32 - 35 PRODUCT REVISION LEVEL */
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
static UINT32 CardRCA;
|
||||
UINT32 MmcLastError;
|
||||
UINT32 dlycnt;
|
||||
UINT32 Tnac;
|
||||
UINT32 Twr;
|
||||
|
||||
UINT8 MmcSdCsd[16]__attribute__ ((aligned (4)));
|
||||
static BOOLEAN bMmcPermWriteProtect;
|
||||
BOOLEAN bMmcChanged;
|
||||
|
||||
DiskCtrlBlk_t MmcDskCtrlBlk;
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* Function returns TRUE if Card is inserted, FALSE if Card is removed */
|
||||
inline BOOLEAN MmcPresent(void)
|
||||
{
|
||||
return (!(MMC_CP_FIO & MMC_CP_MASK));
|
||||
}
|
||||
|
||||
|
||||
/* Function returns TRUE is WriteProtection is activated, FALSE if
|
||||
* Protection is off. If no Card is inserted, Function will also return
|
||||
* TRUE. This results from the physical Switch Connection (See Datasheet).
|
||||
* Usage of this Function only makes Sense with previous TRUE-Return
|
||||
* from MmcPresent.
|
||||
*/
|
||||
inline BOOLEAN MmcWriteProtect(void)
|
||||
{
|
||||
if (!(MMC_WP_FIO & MMC_WP_MASK))
|
||||
{
|
||||
return (FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
UINT32 MmcSetClockFreq (UINT32 Frequency)
|
||||
{
|
||||
UINT32 Pclk = SYS_GetFPclk(MCI_PCLK_OFFSET);
|
||||
UINT32 Div;
|
||||
Frequency <<= 1;
|
||||
|
||||
for(Div = 1; Div <= 256; ++Div)
|
||||
{
|
||||
if((Frequency * Div)> Pclk)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
MCI_CLOCK = ((Div - 1) & 0xFF); /* Set Clock Devider (Bit 0-7) */
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
MCI_CLOCK |= (1 << 8); /* enable Clock (Bit 8) */
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
MCI_CLOCK |= (1 << 9); /* Set PowerSave (Bit 9) */
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
|
||||
return(Pclk/(Div<<1)); /* Return real frequency */
|
||||
}
|
||||
|
||||
void MmcInit(void)
|
||||
{
|
||||
UINT32 i;
|
||||
|
||||
MMC_CP_DIR &= ~MMC_CP_MASK; /* Set CP to Input */
|
||||
MMC_CP_MODE &=~(1 << 24); /* Neither PullUp nor PullDown */
|
||||
MMC_CP_MODE |= (1 << 25);
|
||||
|
||||
MMC_WP_DIR &= ~MMC_WP_MASK; /* Set WP to Input */
|
||||
MMC_WP_MODE &=~(1 << 22); /* Neither PullUp nor PullDown */
|
||||
MMC_WP_MODE |= (1 << 23);
|
||||
|
||||
|
||||
PCLKSEL1 |= (1 << 24); /* set divider to /1 (Bit 24&25) */
|
||||
PCLKSEL1 &=~(1 << 25);
|
||||
|
||||
PCONP |= 0x30000000; /* Set Power up */
|
||||
|
||||
PINSEL1 &=~(1 << 6); /* Assign Pin 0.19 (Bit 6&7) */
|
||||
PINSEL1 |= (1 << 7);
|
||||
PINSEL1 &=~(1 << 8); /* Assign Pin 0.20 (Bit 8&9) */
|
||||
PINSEL1 |= (1 << 9);
|
||||
PINSEL1 &=~(1 << 10); /* Assign Pin 0.21 (Bit 10&11) */
|
||||
PINSEL1 |= (1 << 11);
|
||||
PINSEL1 &=~(1 << 12); /* Assign Pin 0.22 (Bit 12&13) */
|
||||
PINSEL1 |= (1 << 13);
|
||||
PINSEL4 &=~(1 << 22); /* Assign Pin 2.11 (Bit 22&23) */
|
||||
PINSEL4 |= (1 << 23);
|
||||
PINSEL4 &=~(1 << 24); /* Assign Pin 2.12 (Bit 24&25) */
|
||||
PINSEL4 |= (1 << 25);
|
||||
PINSEL4 &=~(1 << 26); /* Assign Pin 2.13 (Bit 26&27) */
|
||||
PINSEL4 |= (1 << 27);
|
||||
|
||||
|
||||
PINMODE1 &=~(1 << 6) & ~(1 << 7); /* Set PullUp Pin 0.19 (Bit 6&7) */
|
||||
PINMODE1 &=~(1 << 8) & ~(1 << 9); /* Set PullUp Pin 0.20 (Bit 8&9) */
|
||||
PINMODE1 &=~(1 << 10) & ~(1 << 11); /* Set PullUp Pin 0.21 (Bit 10&11) */
|
||||
PINMODE1 &=~(1 << 12) & ~(1 << 13); /* Set PullUp Pin 0.22 (Bit 12&13) */
|
||||
|
||||
|
||||
MCI_COMMAND = 0; /* Clear MCI Command Register */
|
||||
MCI_DATA_CTRL = 0; /* Clear MCI Data Control Register */
|
||||
MCI_CLEAR = 0x7FF; /* Clear all pending interrupts. */
|
||||
|
||||
/* Power up, switch on VCC for the Flash Card - Wait shortly */
|
||||
MCI_POWER = 0x02;
|
||||
for (i = 0; i < 50000; i++);
|
||||
|
||||
|
||||
MCI_POWER |= 0x01; /* Power on the Flash Card. */
|
||||
for (i = 0; i < 50000; i++); /* Wait shortly */
|
||||
|
||||
MmcPowerDown();
|
||||
|
||||
GPDMA_SYNC = 0; /* DMA sync enable */
|
||||
GPDMA_INT_ERR_CLR = 3; /* Clear DMA Error Interrupts */
|
||||
GPDMA_INT_TCCLR = 3; /* Clear DMA Interrupts */
|
||||
|
||||
}
|
||||
|
||||
void MmcPowerDown(void)
|
||||
{
|
||||
SCS |= (1 << 3); /* Init Power State (Bit 3) */
|
||||
MCI_POWER = 0;
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
MCI_MASK0 = 0; /* Disable all interrupts for now */
|
||||
MCI_MASK1 = 0;
|
||||
MCI_COMMAND = 0;
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
MCI_DATA_CTRL = 0;
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
MCI_CLEAR = 0x7FF;
|
||||
|
||||
MCI_CLOCK &=~(1 << 11); /* clear all pending interrupts */
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
|
||||
MmcSetClockFreq(IdentificationModeClock); /* ClkFreq Ident Mode< 400kHz */
|
||||
}
|
||||
|
||||
|
||||
MmcState_t MmcSendCmd(MmcSpiCmdInd_t ComdInd, pUINT32 pArg)
|
||||
{
|
||||
UINT32 Status;
|
||||
union
|
||||
{
|
||||
UINT32 Data;
|
||||
struct
|
||||
{
|
||||
UINT32 CMDINDEX : 6;
|
||||
UINT32 RESPONSE : 1;
|
||||
UINT32 LONGRSP : 1;
|
||||
UINT32 INTERRUPT : 1;
|
||||
UINT32 PENDING : 1;
|
||||
UINT32 ENABLE : 1;
|
||||
UINT32 :21;
|
||||
};
|
||||
} Command;
|
||||
|
||||
/* The Command engine has to be Disabled when modifying the Argument
|
||||
* of the Peripheral
|
||||
*/
|
||||
while ((MCI_STATUS << 11) == TRUE) /* While a Command is in Progress */
|
||||
{
|
||||
MCI_COMMAND = 0; /* Clear MCI Command Register */
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
}
|
||||
Command.Data = 0;
|
||||
|
||||
/* Copy Command-specific Index-Argument from MmcCmd LookUp Table to
|
||||
* Command struct
|
||||
*/
|
||||
Command.CMDINDEX = MmcCmd[ComdInd].TxData;
|
||||
if (pArg != NULL) /* Set Command Response depending on*/
|
||||
{ /* asked Argument */
|
||||
switch (MmcCmd[ComdInd].Resp)
|
||||
{
|
||||
case MmcR2:
|
||||
Command.LONGRSP = 1;
|
||||
case MmcR1:
|
||||
case MmcR1b:
|
||||
case MmcR3:
|
||||
Command.RESPONSE = 1;
|
||||
case MmcNoResp:;
|
||||
}
|
||||
}
|
||||
Command.ENABLE = 1;
|
||||
|
||||
if (MmcCmd[ComdInd].Arg != MmcNoArg) /* If Argument exists */
|
||||
{
|
||||
MCI_ARGUMENT = *pArg; /* Copy Argument to MCI Argument Reg*/
|
||||
}
|
||||
else
|
||||
{
|
||||
MCI_ARGUMENT = 0;
|
||||
}
|
||||
|
||||
MCI_COMMAND = Command.Data; /* Send Command to Card */
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
while ((Status = MCI_STATUS & 0x000000C5) == 0);/* Wait command respond */
|
||||
|
||||
MCI_CLEAR = Status; /* Clear actual Status */
|
||||
|
||||
if (Status & (1UL << 2)) /* If Command TimeOut occourses */
|
||||
{
|
||||
MCI_COMMAND = 0; /* reset Command Register */
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
return (MmcNoResponse); /* Return with Error Message */
|
||||
}
|
||||
if (Status & (1UL << 0)) /* Command CRC Error */
|
||||
{
|
||||
switch (MCI_COMMAND & 0x3F) /* Ignore CRC Error for following */
|
||||
{ /* Commands */
|
||||
case 1: /* CMD1 */
|
||||
case 41: /* ACMD42 */
|
||||
case 12: /* CMD12 */
|
||||
MCI_COMMAND = 0;
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
MCI_ARGUMENT = 0xFFFFFFFF;
|
||||
break;
|
||||
default: /* No CRC Error Ignoring */
|
||||
MCI_COMMAND = 0;
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
return (MmcCardError);
|
||||
}
|
||||
}
|
||||
|
||||
if (pArg != NULL)
|
||||
{
|
||||
switch (MmcCmd[ComdInd].Resp) /* Handle Command Response */
|
||||
{
|
||||
case MmcNoResp:
|
||||
break;
|
||||
case MmcR3:
|
||||
*pArg = MCI_RESP0;
|
||||
break;
|
||||
case MmcR2:
|
||||
*pArg++ = MCI_RESP0;
|
||||
*pArg++ = MCI_RESP1;
|
||||
*pArg++ = MCI_RESP2;
|
||||
*pArg++ = MCI_RESP3;
|
||||
break;
|
||||
default:
|
||||
if (MmcCmd[ComdInd].TxData != (MCI_RESP_CMD & 0x3F)) /* Bit 0-5*/
|
||||
{
|
||||
return (MmcCardError);
|
||||
}
|
||||
*pArg = MCI_RESP0;
|
||||
}
|
||||
}
|
||||
MCI_COMMAND = 0;
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
return (MmcOk);
|
||||
}
|
||||
|
||||
UINT32 Status;
|
||||
MmcState_t MmcInitMedia(void)
|
||||
{
|
||||
UINT32 i;
|
||||
UINT32 res;
|
||||
UINT32 loopcnt;
|
||||
volatile UINT32 Dly;
|
||||
UINT8 MmcSdCid[16];
|
||||
BOOLEAN CardDetected = FALSE;
|
||||
|
||||
Tnac = 1;
|
||||
if (MmcPresent() == FALSE) /* If no Card inserted */
|
||||
{
|
||||
if (MCI_POWER & 0x3) /* Is Power up? */
|
||||
{
|
||||
MmcPowerDown(); /* Set to power down state */
|
||||
}
|
||||
return (MmcNoPresent); /* Return with Error Message */
|
||||
}
|
||||
|
||||
MmcPowerDown(); /* Power Down */
|
||||
MmcDly_1ms(100);
|
||||
|
||||
MCI_POWER &=~(1 << 0); /* power up (Bit 1) */
|
||||
MCI_POWER |= (1 << 1);
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
while ((MCI_POWER & 0x3) != 0x2);
|
||||
|
||||
MCI_POWER |= (1 << 0); /* power reserved (Bit 0) */
|
||||
MCI_POWER &=~(1 << 1);
|
||||
MmcDly_1ms(100);
|
||||
MCI_POWER &=~(1 << 6); /* Disable OpenDrain Mode */
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
|
||||
MCI_POWER = 0x02; /* Power up (Bit 1) */
|
||||
for (loopcnt = 0; loopcnt < 50000; loopcnt++);
|
||||
|
||||
MCI_POWER |= 0x01; /* Power on the Flash Card */
|
||||
for (loopcnt = 0; loopcnt < 50000; loopcnt++);
|
||||
|
||||
if (MmcSendCmd(CMD0, NULL) != MmcOk) /* Send Cmd0, Reset Card */
|
||||
{
|
||||
return (MmcNoResponse);
|
||||
}
|
||||
|
||||
MCI_POWER |= 0x40; /* Set OpenDrain output control */
|
||||
|
||||
MmcDskCtrlBlk.DiskType = DiskMMC; /* Determinate Card type SD or MMC */
|
||||
for (i=100; i; --i) /* Try detecting several Times */
|
||||
{
|
||||
MCI_POWER &=~(1 << 6); /* Disable OpenDrain Mode */
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
res = 0;
|
||||
if (((Status = MmcSendCmd(CMD55, &res)) == MmcOk) && (res & 0x100))
|
||||
{ /* Send Notification for ACMD41 */
|
||||
res = OcrReg;
|
||||
if ((MmcSendCmd(ACMD41, &res) == MmcOk) && (res & 0x80000000))
|
||||
/* Activates Init Process (only SD) */
|
||||
{ /* Gets here when SD Card detected */
|
||||
CardDetected = TRUE;
|
||||
MmcDskCtrlBlk.DiskType = DiskSD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else /* If Cmd55 fails */
|
||||
{
|
||||
MCI_POWER |= (1 << 6); /* enable OpenDrain Mode */
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
res = OcrReg;
|
||||
if (MmcSendCmd(CMD1, &res) == MmcOk && (res & 0x80000000))
|
||||
/* CMD1 for MMC Init sequence */
|
||||
{ /* Gets here when MMC Card detected */
|
||||
CardDetected = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
MmcDly_1ms(50);
|
||||
} /* end Card Detection */
|
||||
|
||||
if (CardDetected == FALSE) /* If no Card recognized */
|
||||
{
|
||||
return (MmcNoResponse); /* Return with Error Message */
|
||||
}
|
||||
if (MmcSendCmd(CMD2, (pUINT32)MmcSdCid) != MmcOk) /* Read CID from Card */
|
||||
{
|
||||
return (MmcNoResponse); /* Return with Error Message */
|
||||
}
|
||||
|
||||
/* Set address */
|
||||
CardRCA = (MmcDskCtrlBlk.DiskType == DiskMMC) ? 0x00010000 : 0x00000000;
|
||||
if (MmcSendCmd(CMD3, &CardRCA) != MmcOk)
|
||||
{
|
||||
return (MmcNoResponse);
|
||||
}
|
||||
if (MmcDskCtrlBlk.DiskType == DiskSD)
|
||||
{
|
||||
CardRCA &= 0xFFFF0000;
|
||||
}
|
||||
else
|
||||
{
|
||||
CardRCA = 0x00010000;
|
||||
}
|
||||
|
||||
MCI_POWER &=~(1 << 6); /* Disable OpenDrain Mode */
|
||||
for(dlycnt = 10; dlycnt > 0;dlycnt--);
|
||||
|
||||
|
||||
/* Read Card specific Data from Card */
|
||||
MmcSdCsd[0] = 0;
|
||||
MmcSdCsd[1] = 0;
|
||||
MmcSdCsd[2] = CardRCA >> 16;
|
||||
MmcSdCsd[3] = CardRCA >> 24;
|
||||
if (MmcSendCmd(CMD9, (pUINT32)MmcSdCsd) != MmcOk)
|
||||
{
|
||||
return (MmcNoResponse);
|
||||
}
|
||||
|
||||
MmcCsdImplemet(); /* Implement CSD data */
|
||||
|
||||
res = CardRCA;
|
||||
if (MmcSendCmd(CMD7, &res) != MmcOk) /* Select Card */
|
||||
{
|
||||
return (MmcNoResponse);
|
||||
}
|
||||
res = CardRCA;
|
||||
if (MmcOk != MmcSendCmd(CMD13, &res)) /* Send Card Status Register */
|
||||
{
|
||||
return (MmcNoResponse);
|
||||
} else if (!(res & READY_FOR_DATA) || ((res & CURRENT_STATE)
|
||||
!= CARD_TRAN))
|
||||
{
|
||||
return (MmcCardError);
|
||||
}
|
||||
|
||||
if (MmcDskCtrlBlk.DiskType == DiskSD)
|
||||
{
|
||||
MCI_CLOCK |= (1 << 11); /* Use wide bus for SD */
|
||||
for (loopcnt = 0; loopcnt < 100; loopcnt++);
|
||||
|
||||
res = CardRCA;
|
||||
if (((Status = MmcSendCmd(CMD55, &res)) != MmcOk) || !(res & 0x100))
|
||||
/* Send Notification for ACMD6 */
|
||||
{
|
||||
return (MmcCardError);
|
||||
}
|
||||
|
||||
res = 2;
|
||||
if (MmcSendCmd(ACMD6, &res) != MmcOk) /* Set bus width 4bits */
|
||||
{
|
||||
return (MmcCardError);
|
||||
}
|
||||
}
|
||||
|
||||
res = MmcDskCtrlBlk.BlockSize;
|
||||
if (MmcSendCmd(CMD16, &res)) /* Set Block size */
|
||||
{
|
||||
return (MmcNoResponse);
|
||||
}
|
||||
|
||||
return (MmcOk);
|
||||
}
|
||||
|
||||
UINT32 Tets;
|
||||
void MmcCsdImplemet(void)
|
||||
{
|
||||
UINT32 Freq;
|
||||
UINT64 Tmp;
|
||||
// Calculate SPI max clock
|
||||
Freq = MmcTransfExp[CSD_GET_TRAN_SPEED_EXP()] * MmcCsdMant[CSD_GET_TRAN_SPEED_MANT()];
|
||||
Freq = MmcSetClockFreq(Freq);
|
||||
if (MmcDskCtrlBlk.DiskType == DiskMMC)
|
||||
{
|
||||
// Calculate Time outs for MMC cards
|
||||
Tmp = MmmcAccessTime[CSD_GET_TAAC_EXP()] * MmcCsdMant[CSD_GET_TAAC_MANT()];
|
||||
Tmp /= 10000; // us
|
||||
// Freq [Hz], Tmp[1 us], *10
|
||||
Tmp = (Freq*Tmp)/100000LL;
|
||||
// NSAC*100*10
|
||||
Tmp += 1000*CSD_GET_NSAC();
|
||||
// Max time out
|
||||
Tnac = Tmp;
|
||||
Twr = Tmp * (1<<CSD_GET_R2W_FACTOR());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Calculate Time outs for SD cards
|
||||
// Freq [Hz], RD_TIME_OUT[ms]
|
||||
Tmp = Freq/1000;
|
||||
Tnac = Tmp * RD_TIME_OUT;
|
||||
Twr = Tmp * WR_TIME_OUT;
|
||||
}
|
||||
// Calculate Block size and Block Number
|
||||
MmcDskCtrlBlk.BlockSize = 1<<CSD_GET_READ_BL_LEN();
|
||||
MmcDskCtrlBlk.BlockNumb = (CSD_GET_C_SIZE()+1)*(4<<CSD_GET_C_SIZE_MULT());
|
||||
// Set Write Protect
|
||||
bMmcPermWriteProtect = CSD_GET_PERM_WRITE_PROTECT() |\
|
||||
CSD_GET_TMP_WRITE_PROTECT();
|
||||
MmcDskCtrlBlk.WriteProtect = MmcWriteProtect() |\
|
||||
bMmcPermWriteProtect;
|
||||
}
|
||||
|
||||
|
||||
inline MmcState_t MmcVerify(const UINT8 * pData, UINT32 Add, UINT32 Length)
|
||||
{
|
||||
|
||||
__no_init static UINT8 TempBuffer[2048]__attribute__ ((section (".dmaram")));
|
||||
/* maximum block length is 2048 */
|
||||
MmcState_t Status = MmcOk;
|
||||
UINT32 i = 0;
|
||||
|
||||
while (Length)
|
||||
{
|
||||
Status = MmcReadBlock(TempBuffer, Add);
|
||||
if (Status != MmcOk)
|
||||
{
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < MmcDskCtrlBlk.BlockSize; ++i)
|
||||
{
|
||||
if (TempBuffer[i] != *pData++)
|
||||
{
|
||||
return (MmcMiscompare);
|
||||
}
|
||||
}
|
||||
Length -= MmcDskCtrlBlk.BlockSize;
|
||||
Add += MmcDskCtrlBlk.BlockSize;
|
||||
}
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
||||
UINT32 MmcGetLastError(void)
|
||||
{
|
||||
return(MmcLastError);
|
||||
}
|
||||
|
||||
void MmcStatusUpdate(void)
|
||||
{
|
||||
UINT32 Data = CardRCA;
|
||||
// Update WP state
|
||||
MmcDskCtrlBlk.WriteProtect = MmcWriteProtect() |\
|
||||
bMmcPermWriteProtect;
|
||||
if (!MmcPresent())
|
||||
{
|
||||
MmcDskCtrlBlk.DiskStatus = DiskNotPresent;
|
||||
MmcPowerDown();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((MmcDskCtrlBlk.DiskStatus != DiskCommandPass))
|
||||
{
|
||||
switch (MmcInitMedia())
|
||||
{
|
||||
case MmcOk:
|
||||
MmcDskCtrlBlk.DiskStatus = DiskCommandPass;
|
||||
MmcDskCtrlBlk.MediaChanged = TRUE;
|
||||
break;
|
||||
case MmcCardError:
|
||||
MmcDskCtrlBlk.DiskStatus = DiskNotReady;
|
||||
break;
|
||||
default:
|
||||
MmcDskCtrlBlk.DiskStatus = DiskNotPresent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (MmcSendCmd(CMD13, &Data) != MmcOk)
|
||||
{
|
||||
MmcDskCtrlBlk.DiskStatus = DiskNotReady;
|
||||
}
|
||||
else if (!(Data & READY_FOR_DATA))
|
||||
{
|
||||
MmcDskCtrlBlk.DiskStatus = DiskNotReady;
|
||||
}
|
||||
else if ((Data & CURRENT_STATE) == CARD_TRAN)
|
||||
{
|
||||
MmcDskCtrlBlk.DiskStatus = DiskCommandPass;
|
||||
}
|
||||
else
|
||||
{
|
||||
MmcDskCtrlBlk.DiskStatus = DiskNotReady;
|
||||
}
|
||||
}
|
||||
|
||||
void MmcDiskInit(void)
|
||||
{
|
||||
MmcDskCtrlBlk.BlockNumb =0;
|
||||
MmcDskCtrlBlk.BlockSize =0;
|
||||
MmcLastError = 0;
|
||||
// Init SPI
|
||||
MmcInit();
|
||||
// Media Init
|
||||
switch (MmcInitMedia())
|
||||
{
|
||||
case MmcOk:
|
||||
MmcCsdImplemet();
|
||||
MmcDskCtrlBlk.DiskStatus = DiskCommandPass;
|
||||
MmcDskCtrlBlk.MediaChanged = TRUE;
|
||||
break;
|
||||
case MmcCardError:
|
||||
MmcDskCtrlBlk.DiskStatus = DiskNotReady;
|
||||
break;
|
||||
default:
|
||||
MmcDskCtrlBlk.DiskStatus = DiskNotPresent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MMC_DISK_INFO
|
||||
UINT32 MmcDiskInfo (pUINT8 pData, DiskInfoType_t DiskInfoType)
|
||||
{
|
||||
pMmc3FormatCapResponse_t pFormatCapacity;
|
||||
switch (DiskInfoType)
|
||||
{
|
||||
case DiskInquiry:
|
||||
memcpy(pData,MmcDskInquiry,SizeOfInquiryDescMmcDsk);
|
||||
return(SizeOfInquiryDescMmcDsk);
|
||||
case DiskFormatCapacity:
|
||||
pFormatCapacity = (pMmc3FormatCapResponse_t)pData;
|
||||
memset(pFormatCapacity,0,sizeof(Mmc3FormatCapResponse_t));
|
||||
pFormatCapacity->CapacityListLength = sizeof(Mmc3FormatCapDescriptor_t);
|
||||
if (MmcDskCtrlBlk.DiskStatus != DiskCommandPass)
|
||||
{
|
||||
pFormatCapacity->MaximumDescriptor.DescriptorType = FormattedMedia;
|
||||
pFormatCapacity->MaximumDescriptor.BlockLength[0] = (MmcDskCtrlBlk.BlockSize >> 16) & 0xFF;
|
||||
pFormatCapacity->MaximumDescriptor.BlockLength[1] = (MmcDskCtrlBlk.BlockSize >> 8) & 0xFF;
|
||||
pFormatCapacity->MaximumDescriptor.BlockLength[2] = (MmcDskCtrlBlk.BlockSize ) & 0xFF;
|
||||
pFormatCapacity->MaximumDescriptor.NumberofBlocks[0] = (MmcDskCtrlBlk.BlockNumb >> 24) & 0xFF;
|
||||
pFormatCapacity->MaximumDescriptor.NumberofBlocks[1] = (MmcDskCtrlBlk.BlockNumb >> 16) & 0xFF;
|
||||
pFormatCapacity->MaximumDescriptor.NumberofBlocks[2] = (MmcDskCtrlBlk.BlockNumb >> 8) & 0xFF;
|
||||
pFormatCapacity->MaximumDescriptor.NumberofBlocks[3] = (MmcDskCtrlBlk.BlockNumb ) & 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
pFormatCapacity->MaximumDescriptor.DescriptorType = NoMediaPresent;
|
||||
pFormatCapacity->MaximumDescriptor.BlockLength[0] = (2048 >> 16) & 0xFF;
|
||||
pFormatCapacity->MaximumDescriptor.BlockLength[1] = (2048 >> 8) & 0xFF;
|
||||
pFormatCapacity->MaximumDescriptor.BlockLength[2] = (2048 ) & 0xFF;
|
||||
pFormatCapacity->MaximumDescriptor.NumberofBlocks[0] = (0xFFFFFFFF >> 24) & 0xFF;
|
||||
pFormatCapacity->MaximumDescriptor.NumberofBlocks[1] = (0xFFFFFFFF >> 16) & 0xFF;
|
||||
pFormatCapacity->MaximumDescriptor.NumberofBlocks[2] = (0xFFFFFFFF >> 8) & 0xFF;
|
||||
pFormatCapacity->MaximumDescriptor.NumberofBlocks[3] = (0xFFFFFFFF ) & 0xFF;
|
||||
}
|
||||
return(sizeof(Mmc3FormatCapResponse_t));
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
pDiskCtrlBlk_t MmcGetDiskCtrlBkl(void)
|
||||
{
|
||||
return (&MmcDskCtrlBlk);
|
||||
}
|
||||
|
||||
UINT32 SYS_GetFSclk(void)
|
||||
{
|
||||
UINT32 Mul = 1, Div = 1, Osc, Fsclk;
|
||||
if (PLLSTAT & (1 << 25))
|
||||
{
|
||||
// when PLL is connected
|
||||
Mul = (PLLSTAT & 0x7FFF) +1;
|
||||
Div = ((PLLSTAT >> 16) & 0xFF) +1;
|
||||
}
|
||||
|
||||
// Find clk source
|
||||
switch (CLKSRCSEL & 0x3)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
UINT32 SYS_GetFPclk(UINT32 Periphery)
|
||||
{
|
||||
UINT32 Fpclk;
|
||||
pUINT32 pReg = (pUINT32)((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);
|
||||
}
|
||||
|
||||
void Dly100us(void *arg)
|
||||
{
|
||||
volatile UINT32 Dly = (UINT32)arg, Dly100;
|
||||
for (; Dly; Dly--)
|
||||
for (Dly100 = 500; Dly100; Dly100--)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,533 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* mmc.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, Apr 22, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __MMC_H
|
||||
#define __MMC_H
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifdef MMC_GLOBAL
|
||||
#define MMC_EXTERN
|
||||
#else
|
||||
#define MMC_EXTERN extern
|
||||
#endif
|
||||
|
||||
extern void Dly100us(void *arg);
|
||||
|
||||
#define MMC_DISK_INFO
|
||||
#define MMC_DISK_LUN 0
|
||||
|
||||
/* Hardware depends definitions */
|
||||
#define IdentificationModeClock 400000
|
||||
#define PC_PCSPI1 (1<<10)
|
||||
#define PC_PCSPI0 (1<<8)
|
||||
|
||||
#define RTC_OSC_FREQ (32768UL)
|
||||
|
||||
#define RD_TIME_OUT 100LL /* SD Max. Block Read Access Time */
|
||||
#define WR_TIME_OUT 250LL /* SD Max. Block Write Access Time */
|
||||
|
||||
#define OcrReg 0x00FF8000
|
||||
|
||||
/* Card Status register */
|
||||
#define READY_FOR_DATA (1UL << 8)
|
||||
#define CURRENT_STATE (0xFUL << 9)
|
||||
#define ERASE_RESET (1UL << 13)
|
||||
#define CARD_ECC_DISABLED (1UL << 14)
|
||||
#define WP_ERASE_SKIP (1UL << 15)
|
||||
#define CID_CSD_OVERWRITE (1UL << 16)
|
||||
#define ERROR (1UL << 17)
|
||||
#define ILLEGAL_COMMAND (1UL << 22)
|
||||
#define COM_CRC_ERROR (1UL << 23)
|
||||
#define WP_VIOLATION (1UL << 26)
|
||||
#define ERASE_PARAM (1UL << 27)
|
||||
#define ERASE_SEQ_ERROR (1UL << 28)
|
||||
#define BLOCK_LEN_ERROR (1UL << 29)
|
||||
#define ADDRESS_ERROR (1UL << 30)
|
||||
#define OUT_OF_RANGE (1UL << 31)
|
||||
|
||||
/* Card states */
|
||||
#define CARD_IDLE (0UL << 9)
|
||||
#define CARD_READY (1UL << 9)
|
||||
#define CARD_IDENT (2UL << 9)
|
||||
#define CARD_STBY (3UL << 9)
|
||||
#define CARD_TRAN (4UL << 9)
|
||||
#define CARD_DATA (5UL << 9)
|
||||
#define CARD_RCV (6UL << 9)
|
||||
#define CARD_PRG (7UL << 9)
|
||||
#define CARD_DIS (8UL << 9)
|
||||
|
||||
#define MmcDly_1ms(Delay) Dly100us((void*)(10 * Delay))
|
||||
|
||||
|
||||
/* WORKAROUND
|
||||
* As long as MCI_CP and MCI_WP are swapped, right PinMapping
|
||||
* is done here.
|
||||
* After Hardware Update, simply use commented PinMasks instead
|
||||
* of the corrected ones.
|
||||
*/
|
||||
|
||||
// MMC/SD card switches
|
||||
// Card present
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2) and IO_CTRL (1)
|
||||
#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2))
|
||||
#define MMC_CP_MASK (1UL << 4)
|
||||
#define MMC_CP_DIR FIO0PIN1
|
||||
#define MMC_CP_FDIR FIO0DIR
|
||||
#define MMC_CP_IO FIO0PIN1
|
||||
#define MMC_CP_FIO FIO0PIN1
|
||||
#define MMC_CP_MODE PINMODE1 /* Bit 12&13 */
|
||||
#else
|
||||
/* Pin 87 (P0.17) */
|
||||
#define MMC_CP_MASK (1UL << 1)
|
||||
#define MMC_CP_DIR FIO0PIN2
|
||||
#define MMC_CP_FDIR FIO0DIR
|
||||
#define MMC_CP_IO FIO0PIN2
|
||||
#define MMC_CP_FIO FIO0PIN2
|
||||
#define MMC_CP_MODE PINMODE1
|
||||
#endif
|
||||
|
||||
|
||||
// Card write protect
|
||||
// \MARK NEW PINSETTINGS FOR TESTER (2) and IO_CTRL (1)
|
||||
#if ((PINSET_TESTER == 1) || (PINSET_TESTER == 2))
|
||||
#define MMC_WP_MASK (1UL << 3)
|
||||
#define MMC_WP_DIR FIO0DIR
|
||||
#define MMC_WP_FDIR FIO0DIR
|
||||
#define MMC_WP_IO FIO0PIN1
|
||||
#define MMC_WP_FIO FIO0PIN1
|
||||
#define MMC_WP_MODE PINMODE1 /* Bit 13&14 */
|
||||
#else
|
||||
/* Pin 64 (P1.29) */
|
||||
#define MMC_WP_MASK (1UL << 5)
|
||||
#define MMC_WP_DIR FIO1DIR3
|
||||
#define MMC_WP_FDIR FIO1DIR
|
||||
#define MMC_WP_IO FIO1PIN3
|
||||
#define MMC_WP_FIO FIO1PIN3
|
||||
#define MMC_WP_MODE PINMODE3
|
||||
#endif
|
||||
|
||||
|
||||
#define DMA_MMCSD 4 /* MMC/SD */
|
||||
|
||||
#define MCI_PCLK_OFFSET 56
|
||||
|
||||
#define I_RC_OSC_FREQ (4000000)
|
||||
#define MAIN_OSC_FREQ (12000000)
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
typedef enum _DiskStatusCode_t
|
||||
{
|
||||
DiskCommandPass = 0, DiskNotReady, DiskNotPresent,
|
||||
DiskParametersError, DiskMiscompareError, DiskChanged,
|
||||
DiskUknowError,
|
||||
} DiskStatusCode_t;
|
||||
|
||||
typedef enum _DiskIoRequest_t
|
||||
{
|
||||
DiskWrite = 0, DiskRead, DiskVerify,
|
||||
} DiskIoRequest_t;
|
||||
|
||||
typedef enum _DiskInfoType_t
|
||||
{
|
||||
DiskInquiry = 0, DiskFormatCapacity,
|
||||
} DiskInfoType_t;
|
||||
|
||||
typedef enum _DiskType_t
|
||||
{
|
||||
DiskMMC, DiskSD, DiskUnknow,
|
||||
} DiskType_t;
|
||||
|
||||
typedef struct _DiskCtrlBlk_t
|
||||
{
|
||||
UINT32 BlockNumb;
|
||||
UINT32 BlockSize;
|
||||
DiskStatusCode_t DiskStatus;
|
||||
DiskType_t DiskType;
|
||||
BOOLEAN WriteProtect;
|
||||
BOOLEAN MediaChanged;
|
||||
} DiskCtrlBlk_t, *pDiskCtrlBlk_t;
|
||||
|
||||
typedef enum _MmcState_t
|
||||
{
|
||||
MmcOk = 0,
|
||||
MmcNoPresent = 1,
|
||||
MmcNoResponse = 2 ,
|
||||
MmcCardError = 3,
|
||||
MmcMiscompare = 4,
|
||||
MmcDmaError = 5,
|
||||
MmcProtect = 6
|
||||
} MmcState_t;
|
||||
|
||||
typedef enum _MmcSpiCmdInd_t
|
||||
{
|
||||
CMD0 = 0, /* Resets the MultiMediaCard */
|
||||
CMD1, /* Activates card’s init process */
|
||||
CMD2, /* Asks all cards to send its card identification (CID) */
|
||||
CMD3, /* Set relative address */
|
||||
CMD7, /* Select/deselect card the card is selected by its own */
|
||||
/* relative address and deselected by other address. */
|
||||
/* address 0 deselects all */
|
||||
CMD9, /* Asks the card to send its card-specific data (CSD) */
|
||||
CMD10, /* Asks the card to send its card identification (CID) */
|
||||
CMD12, /* Stop transmission on multiple block read */
|
||||
CMD13, /* Asks the selected card to send its status register */
|
||||
CMD16, /* Selects a block length (in bytes) for all following */
|
||||
/* block commands (read and write) */
|
||||
CMD17, /* Read block of size selected in SET_BLOCKLEN command */
|
||||
CMD18, /* Continuously transfers data blocks from card to host */
|
||||
/* until interrupted by a Stop command or the requested */
|
||||
/* number of data blocks transmitted */
|
||||
CMD24, /* Write block of size selected in SET_BLOCKLEN command */
|
||||
CMD25, /* Continuously writes blocks of data until ‘Stop Tran’ */
|
||||
/* Token or the requested number of blocks received */
|
||||
CMD27, /* Programming of the programmable bits of the CSD */
|
||||
CMD28, /* If the card has write protection features, this */
|
||||
/* command sets the write protection bit of the */
|
||||
/* addressed group. The properties of write protection */
|
||||
/* are coded in the card specific data (WP_GRP_SIZE). */
|
||||
CMD29, /* If the card has write protection features, this */
|
||||
/* command clears protection bit of the addressed group */
|
||||
CMD30, /* If the card has write protection features, this */
|
||||
/* command asks the card to send the status of the write*/
|
||||
/* protection bits */
|
||||
CMD32, /* Sets the address of first sector of the erase group */
|
||||
CMD33, /* Sets the address of the last sector in a continuous */
|
||||
/* range within selected erase group, or the address */
|
||||
/* of a single sector to be selected for erase */
|
||||
CMD34, /* Removes one previously selected sector from the */
|
||||
/* erase selection */
|
||||
CMD35, /* Sets the address of the first erase group within a */
|
||||
/* range to be selected for erase */
|
||||
CMD36, /* Sets the address of the last erase group within a */
|
||||
/* continuous range to be selected for erase */
|
||||
CMD37, /* Removes one previously selected erase group from the */
|
||||
/* erase selection. */
|
||||
CMD38, /* Erases all previously selected sectors */
|
||||
CMD42, /* Used to set/reset the password or lock/unlock the */
|
||||
/* card. The size of the Data Block is defined by the */
|
||||
/* ET_BLOCK_LEN command */
|
||||
CMD55, /* Notifies the card that the next command is an */
|
||||
/* application specific command (Non standard command) */
|
||||
CMD56, /* Used either to transfer a Data Block to the card or */
|
||||
/* to get a Data Block from the card for general */
|
||||
/* purpose/application specific commands. The size */
|
||||
/* of Data Block is defined with SET_BLOCK_LEN command */
|
||||
ACMD6, /* Defines data bus width (’00’=1bit or’10’=4 bits bus) */
|
||||
/* (Only for SD) */
|
||||
ACMD41, /* Activates card initialization process (Only for SD) */
|
||||
CMD_END /* End of commands index */
|
||||
} MmcSpiCmdInd_t;
|
||||
|
||||
typedef enum _MmcAgmType_t
|
||||
{
|
||||
MmcNoArg = 0,
|
||||
MmcBlockLen,
|
||||
MmcDataAdd,
|
||||
MmcRelAddr,
|
||||
MmcOcr
|
||||
} MmcAgmType_t;
|
||||
|
||||
typedef enum _MmcRespType_t
|
||||
{
|
||||
MmcNoResp = 0,
|
||||
MmcR1,
|
||||
MmcR1b,
|
||||
MmcR2,
|
||||
MmcR3
|
||||
} MmcRespType_t;
|
||||
|
||||
typedef struct _MmcCommads_t
|
||||
{
|
||||
UINT8 TxData;
|
||||
MmcAgmType_t Arg;
|
||||
MmcRespType_t Resp;
|
||||
} MmcCommads_t;
|
||||
|
||||
typedef union _DataCtrl_t
|
||||
{
|
||||
UINT32 Data;
|
||||
struct
|
||||
{
|
||||
UINT32 ENABLE : 1;
|
||||
UINT32 DIRECTION : 1;
|
||||
UINT32 MODE : 1;
|
||||
UINT32 DMAENABLE : 1;
|
||||
UINT32 BLOCKSIZE : 4;
|
||||
UINT32 :24;
|
||||
};
|
||||
} DataCtrl_t, *pDataCtrl_t;
|
||||
|
||||
typedef struct _Mmc3FormatCapDescriptor_t
|
||||
{
|
||||
UINT8 NumberofBlocks[4];
|
||||
struct
|
||||
{
|
||||
UINT8 DescriptorType : 2;
|
||||
UINT8 FormatType : 6;
|
||||
};
|
||||
UINT8 BlockLength[3];
|
||||
} Mmc3FormatCapDescriptor_t, *pMmc3FormatCapDescriptor_t;
|
||||
|
||||
typedef struct _Mmc3FormatCapResponse_t
|
||||
{
|
||||
UINT8 Reserved0;
|
||||
UINT8 Reserved1;
|
||||
UINT8 Reserved2;
|
||||
UINT8 CapacityListLength;
|
||||
Mmc3FormatCapDescriptor_t MaximumDescriptor;
|
||||
} Mmc3FormatCapResponse_t, * pMmc3FormatCapResponse_t;
|
||||
|
||||
typedef enum _SpcPeripheralDeviceType_t
|
||||
{
|
||||
SbcDirectAccess = 0, SscSequentialAccess,SSCPrinter,SpcProcessor,
|
||||
ScbWriteOnce,Mmc2CDROM,Scsi2Scanner,SbcOpticalMemory,
|
||||
SmcMediumChanger,Scsi2Communications,DefinedByASCIT8_1,DefinedByASCIT8_2,
|
||||
Scc2StorageArrayController,SesEnclosureServices,RbcSimplifiedDirectAccess,
|
||||
OcrwOpticalCardReader,BridgingExpanders,OsdObjectBasedStorage, UnknowType = 0x1F,
|
||||
} SpcPeripheralDeviceType_t;
|
||||
|
||||
typedef enum _FormatCapacityDescType_t
|
||||
{
|
||||
UnformattedMedia = 1, FormattedMedia, NoMediaPresent,
|
||||
} FormatCapacityDescType_t;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
extern UINT32 SYS_GetFpclk(UINT32 Periphery);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcPresent
|
||||
*
|
||||
* checks if a Card is inserted.
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - true if Card is inserted, false if not
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
inline BOOLEAN MmcPresent(void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcWriteProtect
|
||||
*
|
||||
* checks if inserted Card is write protected.
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: BOOLEAN - true if Card is protected, false if not
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
inline BOOLEAN MmcWriteProtect(void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcSetClockFreq
|
||||
*
|
||||
* Sets SPI Clock Frequency
|
||||
*
|
||||
* Parameters: UINT32 - Frequency
|
||||
*
|
||||
* Return: UINT32
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
UINT32 MmcSetClockFreq(UINT32 Frequency);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcInit
|
||||
*
|
||||
* Initialises the MMC Interface and sets it to SPI Mode. Sets Card Present
|
||||
* and WriteProtect Pins.
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void MmcInit(void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcPowerDown
|
||||
*
|
||||
* Sets to PowerDown state
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void MmcPowerDown(void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcSendCmd
|
||||
*
|
||||
* Implements and sends a Command to MMC
|
||||
*
|
||||
* Parameters: MmcSpiCmdInd_t ComdInd - specific Command
|
||||
* UINT32 Arg - Command Argument
|
||||
*
|
||||
* Return: MmcState_t - Response from Card
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
MmcState_t MmcSendCmd(MmcSpiCmdInd_t ComdInd, pUINT32 pArg);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcInitMedia
|
||||
*
|
||||
* Detects and initialises a connected MMC
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: MmcState_t - Response from Card
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
MmcState_t MmcInitMedia(void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcCsdImplement
|
||||
*
|
||||
* Implement Data from CSD
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void MmcCsdImplemet(void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcVerify
|
||||
*
|
||||
* Verifies a MMC
|
||||
*
|
||||
* Parameters: const UINT8 * pData - Pointer to Data
|
||||
* UINT32 Add - Address of Data
|
||||
* UINT32 Length - Length of Data
|
||||
*
|
||||
* Return: MmcState_t - Response from Card
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
inline MmcState_t MmcVerify(const UINT8 * pData, UINT32 Add,
|
||||
UINT32 Length);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcGetLastError
|
||||
*
|
||||
* Returns last occured ERROR
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: UINT32 - Last occured Error
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
UINT32 MmcGetLastError(void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcStatusUpdate
|
||||
*
|
||||
* Updates the status of SD/MMC Card
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void MmcStatusUpdate(void);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcDiskInit
|
||||
*
|
||||
* Initialises MMC/SD Disk
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: void
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void MmcDiskInit(void);
|
||||
|
||||
#ifdef MMC_DISK_INFO
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcDiskInfo
|
||||
*
|
||||
* Returns Pointer to Info Structure of inserted Disk
|
||||
*
|
||||
* Parameters: pUINT8 pData - Pointer to Data
|
||||
* DiskInfoType_t DiskInfoType - Info Type
|
||||
*
|
||||
* Return: UINT32
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
UINT32 MmcDiskInfo(pUINT8 pData, DiskInfoType_t DiskInfoType);
|
||||
#endif // MMC_DISK_INFO
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcGetDiskCtrlBkl
|
||||
*
|
||||
* Returns Pointer to Control Block Structure
|
||||
*
|
||||
* Parameters: void
|
||||
*
|
||||
* Return: pDiskCtrlBlock_t - Pointer to Control Block
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
pDiskCtrlBlk_t MmcGetDiskCtrlBkl(void);
|
||||
|
||||
|
||||
UINT32 SYS_GetFSclk(void);
|
||||
|
||||
|
||||
UINT32 SYS_GetFPclk(UINT32 Periphery);
|
||||
|
||||
/*************************************************************************
|
||||
* Function Name: Dly100us
|
||||
* Parameters: void *arg
|
||||
* Return: void
|
||||
*
|
||||
* Description: Delay [100us]
|
||||
*
|
||||
*************************************************************************/
|
||||
void Dly100us(void *arg);
|
||||
|
||||
|
||||
|
||||
#endif // __MMC_H
|
||||
|
||||
|
||||
@@ -0,0 +1,307 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* mmc_transfer.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, May 08, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include <string.h>
|
||||
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "mmc_transfer.h"
|
||||
#include "mmc.h"
|
||||
#include "dio.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define Card_Page_Size 512
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
extern UINT32 Tnac;
|
||||
extern UINT32 Twr;
|
||||
extern DiskCtrlBlk_t MmcDskCtrlBlk;
|
||||
|
||||
UINT32 dlycnt;
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
UINT8 ReadFromCard[512] __attribute__ ((section (".dmaram")));
|
||||
UINT8 WriteToCard[512] __attribute__ ((section (".dmaram")));
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
MmcState_t CardRead (pUINT8 pData, UINT32 Address, UINT32 Length)
|
||||
{
|
||||
UINT32 ArrayIndex = 0;
|
||||
UINT32 loopcnt;
|
||||
MmcState_t Status = MmcOk;
|
||||
|
||||
for (loopcnt = 0; loopcnt < Card_Page_Size; loopcnt++)/* Prepare Buffer */
|
||||
{
|
||||
ReadFromCard[loopcnt] = 0; /* Set all Positions to Zero */
|
||||
}
|
||||
|
||||
/* Error or Wrong Argument Handle Block */
|
||||
if (MmcPresent() == FALSE) /* Check if Card is present */
|
||||
{
|
||||
return (MmcNoPresent); /* Return NoCardPresent State */
|
||||
}
|
||||
if (checkLength(Length) == FALSE) /* Check Read Length for validity */
|
||||
{
|
||||
return (MmcMiscompare); /* Return WrongLength State */
|
||||
}
|
||||
|
||||
Address = ((Address / Card_Page_Size) * Card_Page_Size);
|
||||
/* Calculate first Address of Page */
|
||||
|
||||
do /* Loop to handle multible Reads */
|
||||
{
|
||||
Status = MmcReadBlock((pUINT8)ReadFromCard, Address);
|
||||
/* Read 512 from Card */
|
||||
memcpy (&(pData[ArrayIndex]), ReadFromCard, Card_Page_Size);
|
||||
/* Copy read Content to User Buffer */
|
||||
|
||||
/* Recalculate Loop Values */
|
||||
Length -= Card_Page_Size;
|
||||
Address += Card_Page_Size;
|
||||
ArrayIndex += Card_Page_Size;
|
||||
} while (Length > 0);
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
||||
MmcState_t CardWrite (pUINT8 pData, UINT32 Address, UINT32 Length)
|
||||
{
|
||||
UINT32 ArrayIndex = 0;
|
||||
UINT32 loopcnt;
|
||||
MmcState_t Status = MmcOk;
|
||||
|
||||
for (loopcnt = 0; loopcnt < Card_Page_Size; loopcnt++)/* Prepare Buffer */
|
||||
{
|
||||
WriteToCard[loopcnt] = 0; /* Set all Positions to Zero */
|
||||
}
|
||||
|
||||
/* Error or Wrong Argument Handle Block */
|
||||
if (MmcPresent() == FALSE) /* Check if Card is Present */
|
||||
{
|
||||
return (MmcNoPresent); /* Return NoCardPresent State */
|
||||
}
|
||||
if (MmcWriteProtect() == TRUE) /* Check if Card is Writeprotected */
|
||||
{
|
||||
return (MmcProtect); /* Return WriteProtect State */
|
||||
}
|
||||
if (checkLength(Length) == FALSE) /* Check Read Length for validity */
|
||||
{
|
||||
return (MmcMiscompare); /* Return WrongLength State */
|
||||
}
|
||||
if (Address < 0x200) /* Defend Master Boot Sector */
|
||||
{
|
||||
return (MmcCardError); /* Return Error State */
|
||||
}
|
||||
|
||||
|
||||
Address = ((Address / Card_Page_Size) * Card_Page_Size);
|
||||
/* Calculate first Address of Page */
|
||||
|
||||
do
|
||||
{
|
||||
memcpy (WriteToCard, &(pData[ArrayIndex]), Card_Page_Size);
|
||||
/* Copy 512Bytes in send-Buffer */
|
||||
Status = MmcWriteBlock((pUINT8)WriteToCard, Address);
|
||||
/* Write 512 Bytes to Card */
|
||||
|
||||
/* Recalculate Loop Values */
|
||||
Length -= Card_Page_Size;
|
||||
Address += Card_Page_Size;
|
||||
ArrayIndex += Card_Page_Size;
|
||||
} while (Length > 0);
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
||||
inline BOOLEAN checkLength (UINT32 Length)
|
||||
{
|
||||
if (Length == 0)
|
||||
{
|
||||
return (FALSE);
|
||||
}
|
||||
/* Check data length - Must be divisible of Card Block Size */
|
||||
if ((Length % MmcDskCtrlBlk.BlockSize) != 0)
|
||||
{
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
inline MmcState_t MmcReadBlock(pUINT8 pData, UINT32 Add)
|
||||
{
|
||||
UINT32 Data;
|
||||
MmcState_t Status = MmcOk;
|
||||
|
||||
PCONP |= (1 << 29); /* Turn on MCI Power */
|
||||
MCI_DATA_TMR = Tnac; /* Set Read Timeout */
|
||||
MCI_CLEAR = 0x000007FF; /* Clear all Interrupt Flags */
|
||||
|
||||
/* General Purpose DMA (GPDMA) Control Settings for Reading */
|
||||
GPDMA_CONFIG = 0x00; /* Disable DMA */
|
||||
GPDMA_CH0_LLI = 0; /* No link List available */
|
||||
GPDMA_CH0_CTRL = 0x00; /* Reset DMA Control Block */
|
||||
GPDMA_CH0_SRC = (UINT32)&MCI_FIFO; /* Set MCI FIFO as Source Adress */
|
||||
|
||||
GPDMA_CH0_CTRL = (Card_Page_Size & 0x0FFF) /* 512 Byte Transfer Size */
|
||||
| (0x04 << 12) /* 32 Bit Source Burst Size */
|
||||
| (0x04 << 15) /* 32 Bit Destination Burst Size */
|
||||
| (0x02 << 18) /* 32 Bit Source width size */
|
||||
| (0x00 << 21) /* 8 Bit Destination width size */
|
||||
| (1 << 27) /* Destination index increment */
|
||||
| (1U << 31); /* Terminal count interrupt */
|
||||
|
||||
MCI_DATA_LEN = MmcDskCtrlBlk.BlockSize; /* Set Transfer Blocksize */
|
||||
Data = Add; /* Hand over Adress */
|
||||
Status = MmcSendCmd(CMD17, &Data); /* Send Write Command to Card */
|
||||
|
||||
|
||||
if (MmcOk != Status) /* If Command Response is not OK: */
|
||||
{
|
||||
return (Status); /* return Status and exit Function */
|
||||
}
|
||||
|
||||
if (!(Data & READY_FOR_DATA)
|
||||
||((Data & CURRENT_STATE) != CARD_TRAN))
|
||||
{ /* Check Command Response */
|
||||
MmcSendCmd(CMD12, NULL);
|
||||
return (MmcCardError);
|
||||
}
|
||||
|
||||
GPDMA_CH0_DEST = (UINT32)pData; /* Set DMA Destination Adress */
|
||||
|
||||
/* DMA Channel Configuration Block */
|
||||
GPDMA_CH0_CFG = 0x00; /* Reset DMA Channel Configuration */
|
||||
GPDMA_CH0_CFG = (0x10000)
|
||||
| (0x04 << 1) /* Source Device is Peripheral */
|
||||
| (0x00 << 6) /* Destination Device is Memory */
|
||||
| (0x06 << 11); /* Peripheral to Memory Mode */
|
||||
|
||||
GPDMA_INT_TCCLR = 0x01; /* Clear all Terminal Interrupts */
|
||||
GPDMA_CONFIG = 0x01; /* enable GPDMA after setup Channel */
|
||||
while ((GPDMA_CONFIG & 0x01)!= 0x01); /* Poll Enable bit until set */
|
||||
GPDMA_CH0_CFG |= (1 << 0); /* enable DMA Channel */
|
||||
|
||||
MCI_DATA_CTRL = (0x0001) /* Data Transfer enable */
|
||||
| (0x01 << 1) /* From Card to Controller */
|
||||
| (0x00 << 2) /* Block Data Transfer */
|
||||
| (0x01 << 3) /* DMA enabled */
|
||||
| (0x09 << 4); /* BlockSize 2^9 = 512 Byte */
|
||||
for(dlycnt = 10; dlycnt > 0; dlycnt--);
|
||||
|
||||
while (MCI_STATUS & (1 << 13)); /* Poll RxActive until read finish */
|
||||
GPDMA_CH0_CFG &=~(1 << 0); /* Disable DMA channel */
|
||||
MCI_DATA_CTRL = 0; /* Reset Data Control Register */
|
||||
for(dlycnt = 10; dlycnt > 0; dlycnt--);
|
||||
|
||||
/* Interrupt Handling Block */
|
||||
if (GPDMA_RAW_INT_ERR_STAT & (1 << 0)) /* Channel requests Interrupt */
|
||||
{
|
||||
GPDMA_INT_ERR_CLR |= (1 << 0); /* clear Flag, terminate transfer */
|
||||
return (MmcDmaError);
|
||||
}
|
||||
|
||||
/* Error Handling Block */
|
||||
if (MCI_STATUS & (1 << 3)) /* Timeout Error */
|
||||
{
|
||||
MCI_CLEAR = 1UL << 3; /* Clear Timeout Bit */
|
||||
return (MmcNoResponse); /* Return with Error Message */
|
||||
}
|
||||
if (MCI_STATUS & (1 << 9)) /* StartBit not detected in Wide */
|
||||
{ /* Bus Mode on every four Lines */
|
||||
MCI_CLEAR = 1UL << 9; /* Clear StartBitError bit */
|
||||
return (MmcCardError); /* Return with Error Message */
|
||||
}
|
||||
if (MCI_STATUS & (1 << 1)) /* DATA CRC Error */
|
||||
{
|
||||
MCI_CLEAR = 1UL << 1; /* Clear Data CRC Error Bit */
|
||||
return (MmcCardError); /* Return with Error Message */
|
||||
}
|
||||
if (MCI_STATUS & (1 << 5)) /* Read FIFO Overrun Error */
|
||||
{
|
||||
MCI_CLEAR = 1UL << 5; /* Clean FIFO Overrun Error Bit */
|
||||
return (MmcCardError); /* Return with Error Message */
|
||||
}
|
||||
|
||||
MCI_CLEAR = (1UL << 8) /* Clear DATA END and DATA BLOCK END*/
|
||||
| (1UL << 10);
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
||||
inline MmcState_t MmcWriteBlock(const UINT8 * pData, UINT32 Add)
|
||||
{
|
||||
UINT32 Data;
|
||||
|
||||
|
||||
MmcState_t Status = MmcOk;
|
||||
|
||||
PCONP |= (1 << 29); /* Turn on MCI Power */
|
||||
MCI_DATA_TMR = Twr; /* Set write Timeout */
|
||||
MCI_CLEAR = 0x000007FF; /* Clear all related flags */
|
||||
|
||||
/* General Purpose DMA (GPDMA) Control Settings for Writing */
|
||||
GPDMA_CONFIG = 0x00; /* Disable DMA */
|
||||
GPDMA_CH0_LLI = 0; /* No link List */
|
||||
GPDMA_CH0_CTRL = 0x00; /* Reset DMA Control Block */
|
||||
GPDMA_CH0_DEST = (UINT32)&MCI_FIFO; /* Set MCI FIFO as Destination */
|
||||
|
||||
GPDMA_CH0_CTRL = (Card_Page_Size & 0x0FFF) /* 512 Byte Transfer Size */
|
||||
| (0x04 << 12) /* 32 Bit Source Burst Size */
|
||||
| (0x04 << 15) /* 32 Bit Destination Burst Size */
|
||||
| (0x00 << 18) /* 8 bit Source width Size */
|
||||
| (0x02 << 21) /* 32 Bit Destination width Size */
|
||||
| (1 << 26) /* Source index increment */
|
||||
| (1U << 31); /* Terminal count interrupt enable */
|
||||
|
||||
|
||||
MCI_DATA_LEN = MmcDskCtrlBlk.BlockSize; /* Set Transfer Blocksize */
|
||||
Data = Add; /* Hand over Adress */
|
||||
Status = MmcSendCmd(CMD24, &Data); /* Send Write Command */
|
||||
|
||||
if (MmcOk != Status) /* If Command Response is NOT OK */
|
||||
{
|
||||
return (Status); /* Return with Error Message */
|
||||
}
|
||||
|
||||
if (!(Data & READY_FOR_DATA)
|
||||
|| ((Data & CURRENT_STATE) != CARD_TRAN))
|
||||
{ /* Check Command Response */
|
||||
MmcSendCmd(CMD12, NULL);
|
||||
return (MmcCardError);
|
||||
@@ -0,0 +1,122 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* mmc_transfer.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, May 08, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef MMC_TRANSFER_H_
|
||||
#define MMC_TRANSFER_H_
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
#include "mmc.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: CardRead
|
||||
*
|
||||
* Reads user defined blocks and lengths from memory card
|
||||
*
|
||||
* Parameters: pUINT8 pData - Data to read to
|
||||
* UINT32 Add - Address to read from
|
||||
* UINT32 Length - Length of Data to be read
|
||||
*
|
||||
* Return: MmcState_t - Response from Card
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
MmcState_t CardRead (pUINT8 pData, UINT32 Address, UINT32 Length);
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: CardWrite
|
||||
*
|
||||
* Writes user defined blocks and lengths to memory card
|
||||
*
|
||||
* Parameters: pUINT8 pData - Data to write
|
||||
* UINT32 Add - Address to write to
|
||||
* UINT32 Length - Length of Data to be written
|
||||
*
|
||||
* Return: MmcState_t - Response from Card
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
MmcState_t CardWrite (pUINT8 pData, UINT32 Address, UINT32 Length);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: checkLength
|
||||
*
|
||||
* Functions checks asked read/write length for valid length-value, which is
|
||||
* a multible from cards blocksize.
|
||||
*
|
||||
* Parameters: UINT32 Length - Length of Block to read or write
|
||||
*
|
||||
* Return: BOOLEAN - TRUE if length fits, FALSE if not
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
inline BOOLEAN checkLength (UINT32 Length);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcReadBlock
|
||||
*
|
||||
* Reads from a MMC
|
||||
*
|
||||
* Parameters: pUINT8 pData - Pointer to where Content is read
|
||||
* UINT32 Add - Address to read from
|
||||
*
|
||||
* Return: MmcState_t - Response from Card
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
inline MmcState_t MmcReadBlock(pUINT8 pData, UINT32 Add);
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function: MmcWriteBlock
|
||||
*
|
||||
* Writes to a MMC
|
||||
*
|
||||
* Parameters: const UINT8 * pData - Data to write
|
||||
* UINT32 Add - Address to write to
|
||||
*
|
||||
* Return: MmcState_t - Response from Card
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
inline MmcState_t MmcWriteBlock(const UINT8 * pData, UINT32 Add);
|
||||
|
||||
|
||||
#endif /*MMC_TRANSFER_H_*/
|
||||
@@ -0,0 +1,173 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* power.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: Checks for power supply
|
||||
* ---------------------------------------------------------------------------
|
||||
* 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 "power.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define ADC_INTERRUPT_FLAG 1 /* 1 is interrupt driven, 0 is polling */
|
||||
|
||||
#define ADC_OFFSET 0x10
|
||||
#define ADC_INDEX 4
|
||||
|
||||
#define ADC_DONE 0x80000000
|
||||
#define ADC_OVERRUN 0x40000000
|
||||
#define ADC_ADINT 0x00010000
|
||||
|
||||
#define ADC_NUM 8 /* for LPC23xx */
|
||||
#define ADC_CLK 1000000 /* set to 1Mhz */
|
||||
|
||||
#define VCC_DIVIDER_R1 22000
|
||||
#define VCC_DIVIDER_R2 19100
|
||||
#define VCC_DIVIDER_CORR ((VCC_DIVIDER_R2 * 1000) / (VCC_DIVIDER_R1 + VCC_DIVIDER_R2))
|
||||
#define V24_DIVIDER_R1 33000
|
||||
#define V24_DIVIDER_R2 3300
|
||||
#define V24_DIVIDER_CORR ((V24_DIVIDER_R2 * 1000) / (V24_DIVIDER_R1 + V24_DIVIDER_R2))
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
static UINT16 ADC0Read( UINT8 channelNum );
|
||||
static UINT16 Convert2mV( UINT32 dataRegistry );
|
||||
|
||||
|
||||
void powerInit()
|
||||
{
|
||||
/* Enable CLOCK into ADC controller */
|
||||
PCONP |= (1 << 12);
|
||||
|
||||
/* all the related pins are set to ADC inputs, AD0.0, 4 and 5 */
|
||||
PINSEL1 &= ~0x0000C000; /* P0.23, A0.0, function 01 */
|
||||
PINSEL1 |= 0x00004000;
|
||||
PINSEL3 |= 0xC0000000; /* P1.31, A0.5, function 11 */
|
||||
|
||||
AD0CR = ( 0x21 << 0 ) | /* SEL=1,select channel 0,4 and 5 on ADC0 */
|
||||
( 0 << 8 ) | /* CLKDIV = Fpclk / 1000000 - 1 => 2.4 MHz */
|
||||
( 1 << 16 ) | /* BURST = 0, no BURST, software controlled */
|
||||
( 0 << 17 ) | /* CLKS = 0, 11 clocks/10 bits */
|
||||
( 1 << 21 ) | /* PDN = 1, normal operation */
|
||||
( 0 << 22 ) | /* TEST1:0 = 00 */
|
||||
( 0 << 24 ) | /* START = 0 A/D conversion stops */
|
||||
( 0 << 27 ); /* EDGE = 0 (CAP/MAT singal falling,trigger A/D conversion) */
|
||||
}
|
||||
|
||||
UINT16 powerVccVoltage()
|
||||
{
|
||||
UINT32 adcDataRegister;
|
||||
UINT32 voltage;
|
||||
|
||||
adcDataRegister = AD0DR5;
|
||||
voltage = Convert2mV( adcDataRegister );
|
||||
|
||||
// Correct voltage divider
|
||||
voltage = (voltage * 1000)/VCC_DIVIDER_CORR;
|
||||
|
||||
return voltage;
|
||||
}
|
||||
|
||||
UINT16 powerV24Voltage()
|
||||
{
|
||||
UINT32 adcDataRegister;
|
||||
UINT32 voltage;
|
||||
|
||||
adcDataRegister = AD0DR0;
|
||||
voltage = Convert2mV( adcDataRegister );
|
||||
|
||||
// Correct voltage divider
|
||||
voltage = (voltage * 1000)/V24_DIVIDER_CORR;
|
||||
|
||||
return voltage;
|
||||
}
|
||||
|
||||
|
||||
UINT16 Convert2mV( UINT32 dataRegister )
|
||||
{
|
||||
UINT32 pwrDummy;
|
||||
dataRegister = dataRegister >> 6;
|
||||
dataRegister = dataRegister & 0x03FF;
|
||||
|
||||
// Convert ADC value to voltage (0..1024 -> 0.. 3300 mV)
|
||||
dataRegister = (dataRegister * 3300) / (1024);
|
||||
pwrDummy = dataRegister;
|
||||
|
||||
return (UINT16)dataRegister;
|
||||
}
|
||||
|
||||
UINT16 ADC0Read( UINT8 channelNum )
|
||||
{
|
||||
UINT16 regVal, ADC_Data;
|
||||
|
||||
/* channel number is 0 through 7 */
|
||||
if ( channelNum >= ADC_NUM )
|
||||
{
|
||||
channelNum = 0; /* reset channel number to 0 */
|
||||
}
|
||||
AD0CR &= 0xFFFFFF00;
|
||||
AD0CR |= (1 << 24) | (1 << channelNum);
|
||||
/* switch channel,start A/D convert */
|
||||
|
||||
while ( 1 ) /* wait until end of A/D convert */
|
||||
{
|
||||
regVal = *(volatile unsigned long *)(AD0_BASE_ADDR + ADC_OFFSET + ADC_INDEX * channelNum);
|
||||
/* read result of A/D conversion */
|
||||
if ( regVal & ADC_DONE )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AD0CR &= 0xF8FFFFFF; /* stop ADC now */
|
||||
if ( regVal & ADC_OVERRUN ) /* save data when it's not overrun, otherwise, return zero */
|
||||
{
|
||||
return ( 0 );
|
||||
}
|
||||
ADC_Data = ( regVal >> 6 ) & 0x3FF;
|
||||
return ( ADC_Data ); /* return A/D conversion value */
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* power.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: Power supply checks
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 10-09-2007, Marcel Mulder.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __POWER_H__
|
||||
#define __POWER_H__
|
||||
/** \file power.h
|
||||
\brief Checks voltage on power supplies
|
||||
*/
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void powerInit( void );
|
||||
UINT16 powerVccVoltage( void );
|
||||
UINT16 powerV24Voltage( void );
|
||||
|
||||
#endif /* __POWER_H__ */
|
||||
@@ -0,0 +1,122 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* relay.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, Nov 10, 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 "relay.h"
|
||||
#include "dio.h"
|
||||
#include "ElecStatusCache.h"
|
||||
//#include "dioISR.h"
|
||||
//#include "armVIC.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define PORT0_BASE_ADDR (FIO_BASE_ADDR) /* Fast IO Base Address */
|
||||
#define PORT1_BASE_ADDR (FIO_BASE_ADDR + 0x20) /* Offset for Port2 */
|
||||
|
||||
#define DIR_OFFSET (0x00) /* Offset of 32Bit DID register */
|
||||
#define MASK_OFFSET (0x10) /* Offset of 32bit MASK register*/
|
||||
#define PIN_OFFSET (0x14) /* Offset of 32Bit PIN register */
|
||||
#define SET_OFFSET (0x18) /* Offset of 32Bit SET register */
|
||||
#define CLR_OFFSET (0x1C) /* Offset of 32Bit CLR register */
|
||||
|
||||
#define RLY_CHANNELS 6
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
t_input rly_inputPins[RLY_CHANNELS] =
|
||||
{
|
||||
{ PORT1_BASE_ADDR, BIT(26), NULL }, /* Relay Input 0 */
|
||||
{ PORT1_BASE_ADDR, BIT(27), NULL }, /* Relay Input 1 */
|
||||
{ PORT1_BASE_ADDR, BIT(28), NULL }, /* Relay Input 2 */
|
||||
{ PORT1_BASE_ADDR, BIT(29), NULL }, /* Relay Input 3 */
|
||||
{ PORT1_BASE_ADDR, BIT(30), NULL }, /* Relay Input 4 */
|
||||
{ PORT1_BASE_ADDR, BIT(31), NULL }, /* Relay Input 5 */
|
||||
|
||||
};
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void rlyInit(void)
|
||||
{
|
||||
UINT8 loopcnt;
|
||||
volatile UINT32 *gpioRegister;
|
||||
|
||||
SCS |= (1UL<<0); /* GPIOM in SCS to fast IO */
|
||||
|
||||
/* Set registers for all Inputs in right Mode */
|
||||
for (loopcnt=0; loopcnt < RLY_CHANNELS; loopcnt++)
|
||||
{
|
||||
/* Clear MASK register of corresponding Input */
|
||||
gpioRegister = (UINT32 *)(rly_inputPins[loopcnt].portBaseAddr + MASK_OFFSET);
|
||||
*gpioRegister &= ~(rly_inputPins[loopcnt].pinMask);
|
||||
|
||||
/* Set corresponding channel to direction INPUT */
|
||||
gpioRegister = (UINT32 *)(rly_inputPins[loopcnt].portBaseAddr + DIR_OFFSET);
|
||||
*gpioRegister &= ~(rly_inputPins[loopcnt].pinMask);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOLEAN rlyRead(UINT8 device, UINT8 channel)
|
||||
{
|
||||
BOOLEAN Result;
|
||||
volatile UINT32 *gpioRegister;
|
||||
|
||||
/* Set pointer to corresponding channel register */
|
||||
gpioRegister = (UINT32 *)(rly_inputPins[channel].portBaseAddr + PIN_OFFSET);
|
||||
|
||||
/* Receive Result from Register (Inputs are LOW-active) */
|
||||
if (*gpioRegister & rly_inputPins[channel].pinMask)
|
||||
{
|
||||
/* Received a HIGH state, so INPUT is LOW or FALSE */
|
||||
Result = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Received a LOW state, so INPUT is HIGH or TRUE */
|
||||
Result = TRUE;
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* relay.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 10, 2008, MMi
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef RELAY_H_
|
||||
#define RELAY_H_
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* Hardware Includes */
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void rlyInit(void);
|
||||
|
||||
BOOLEAN rlyRead(UINT8 device, UINT8 channel);
|
||||
|
||||
#endif /*RELAY_H_*/
|
||||
@@ -0,0 +1,163 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* rtc.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: Real time clock functionality
|
||||
* ---------------------------------------------------------------------------
|
||||
* 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 "rtc.h"
|
||||
#include "dio.h"
|
||||
|
||||
#include "BusProtocol.h"
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define IMSEC 0x00000001
|
||||
#define IMMIN 0x00000002
|
||||
#define IMHOUR 0x00000004
|
||||
#define IMDOM 0x00000008
|
||||
#define IMDOW 0x00000010
|
||||
#define IMDOY 0x00000020
|
||||
#define IMMON 0x00000040
|
||||
#define IMYEAR 0x00000080
|
||||
|
||||
#define AMRSEC 0x00000001 /* Alarm mask for Seconds */
|
||||
#define AMRMIN 0x00000002 /* Alarm mask for Minutes */
|
||||
#define AMRHOUR 0x00000004 /* Alarm mask for Hours */
|
||||
#define AMRDOM 0x00000008 /* Alarm mask for Day of Month */
|
||||
#define AMRDOW 0x00000010 /* Alarm mask for Day of Week */
|
||||
#define AMRDOY 0x00000020 /* Alarm mask for Day of Year */
|
||||
#define AMRMON 0x00000040 /* Alarm mask for Month */
|
||||
#define AMRYEAR 0x00000080 /* Alarm mask for Year */
|
||||
|
||||
#define PREINT_RTC 0x000001C8 /* Prescaler value, integer portion, PCLK = 15Mhz */
|
||||
#define PREFRAC_RTC 0x000061C0 /* Prescaler value, fraction portion,PCLK = 15Mhz */
|
||||
#define ILR_RTCCIF 0x01
|
||||
#define ILR_RTCALF 0x02
|
||||
|
||||
#define CCR_CLKEN 0x01
|
||||
#define CCR_CTCRST 0x02
|
||||
#define CCR_CLKSRC 0x10
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
extern UINT32 interruptcounter;
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void rtcISR (void) __attribute__ ((naked));
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** \brief Initialize RTC interface.*/
|
||||
void rtcInit(void)
|
||||
{
|
||||
/*--- Initialize registers ---*/
|
||||
RTC_AMR = 0;
|
||||
RTC_CIIR = 0;
|
||||
//RTC_CCR = 0;
|
||||
//RTC_PREINT = PREINT_RTC;
|
||||
//RTC_PREFRAC = PREFRAC_RTC;
|
||||
|
||||
RTC_CCR = (CCR_CLKEN | CCR_CLKSRC);
|
||||
|
||||
|
||||
/* Enable RTC interrupt and register it to the VIC */
|
||||
//portENTER_CRITICAL();
|
||||
// {
|
||||
// VICIntSelect &= ~(VIC_CHAN_TO_MASK(VIC_CHAN_NUM_RTC));
|
||||
// VICIntEnClr = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_RTC);
|
||||
// VICVectAddr13 = (void *)rtcISR;
|
||||
// VICVectCntl3 = 0x06;
|
||||
// VICIntEnable = VIC_CHAN_TO_MASK(VIC_CHAN_NUM_RTC);
|
||||
// }
|
||||
//portEXIT_CRITICAL();
|
||||
|
||||
//RTC_CIIR |= 0x01; /* Enable Interrupt every Second */
|
||||
//RTC_CISS = 0x80; /* Enable SubSecond Interrupt (488u)*/
|
||||
|
||||
}
|
||||
|
||||
/** \brief Read real time clock.*/
|
||||
void rtcRead(t_rtc * time)
|
||||
{
|
||||
time->sec = RTC_SEC;
|
||||
time->min = RTC_MIN;
|
||||
time->hour = RTC_HOUR;
|
||||
time->day = RTC_DOM;
|
||||
time->dom = RTC_DOM;
|
||||
time->dow = RTC_DOW;
|
||||
time->doy = RTC_DOY;
|
||||
time->mon = RTC_MONTH;
|
||||
time->year = RTC_YEAR;
|
||||
}
|
||||
|
||||
/** \brief Write to real time clock.*/
|
||||
void rtcWrite(t_rtc * time)
|
||||
{
|
||||
RTC_SEC = time->sec;
|
||||
RTC_MIN = time->min;
|
||||
RTC_HOUR = time->hour;
|
||||
RTC_DOM = time->day;
|
||||
RTC_DOW = time->dow;
|
||||
RTC_DOY = time->doy;
|
||||
RTC_MONTH = time->mon;
|
||||
RTC_YEAR = time->year;
|
||||
}
|
||||
// Alarms
|
||||
|
||||
|
||||
/* RTC INTERRUPT SERVICE ROUTINE */
|
||||
void rtcISR ()
|
||||
{
|
||||
portSAVE_CONTEXT(); /* Save context of interrupted task */
|
||||
{
|
||||
|
||||
if (RTC_ILR & 0x01) /* Check for Seconds Interrupt */
|
||||
{
|
||||
RTC_ILR = 0x1; /* Clear Seconds Interrupt */
|
||||
}
|
||||
if (RTC_ILR & 0x04) /* Check for SubSecond Interrupt */
|
||||
{
|
||||
RTC_ILR = 0x4; /* Clear SubSeconds Interrupt */
|
||||
}
|
||||
|
||||
VICVectAddr = 0x00000000; /* clear Interrupts from the VIC */
|
||||
}
|
||||
/* Restore the context of whichever task is going to run once the interrupt
|
||||
* completes.
|
||||
*/
|
||||
portRESTORE_CONTEXT();
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* rtc.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: Real Time Clock interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 10-09-2007, Marcel Mulder.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __RTC_H__
|
||||
#define __RTC_H__
|
||||
/** \file rtc.h
|
||||
\brief Real Time Clock interface.
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef struct t_RTC {
|
||||
UINT8 sec; /**< Seconds */
|
||||
UINT8 min; /**< Minutes */
|
||||
UINT8 hour; /**< Hours */
|
||||
UINT8 day; /**< Day */
|
||||
UINT8 dow; /**< Day of week (0..7) */
|
||||
UINT8 mon; /**< Month */
|
||||
UINT8 dom; /**< Day of month */
|
||||
UINT16 year; /**< Year */
|
||||
UINT16 doy; /**< Day of year */
|
||||
} t_rtc;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** \brief Initialize logging interface.*/
|
||||
void rtcInit (void);
|
||||
|
||||
/** \brief Read real time clock.*/
|
||||
void rtcRead (
|
||||
t_rtc * time
|
||||
);
|
||||
|
||||
/** \brief Write to real time clock.*/
|
||||
void rtcWrite (
|
||||
t_rtc * time
|
||||
);
|
||||
// Alarms
|
||||
|
||||
|
||||
|
||||
#endif /* __RTC_H__ */
|
||||
@@ -0,0 +1,236 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* serial.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: Serial port 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 "serial.h"
|
||||
#include "armVIC.h"
|
||||
#include "uart.h"
|
||||
|
||||
/* FreeRTOS includes */
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define NR_OF_COMPORTS 2
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/** \brief Initialize of serial interface.*/
|
||||
void serInit (
|
||||
t_serial_devices device,
|
||||
UINT16 baudrate, /**< baudrate: B1200, B9600, B19200, B38400, B57600, B115200*/
|
||||
UINT8 mode, /**< 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 */
|
||||
UINT8 fmode /**< fmode: UART_FIFO_OFF, UART_FIFO_1, UART_FIFO_4, UART_FIFO_8,
|
||||
UART_FIFO_14*/
|
||||
)
|
||||
{
|
||||
switch( device )
|
||||
{
|
||||
case(COM1):
|
||||
uart0Init( baudrate, mode, fmode );
|
||||
break;
|
||||
case(COM2):
|
||||
uart1Init( baudrate, mode, fmode );
|
||||
|
||||
// Enable Handshake lines as well
|
||||
U1_CTS_PINSEL_REG = ( U1_CTS_PINSEL_REG & ~U1_CTS_PINMASK ) | U1_CTS_PINSEL;
|
||||
U1_RTS_PINSEL_REG = ( U1_RTS_PINSEL_REG & ~U1_RTS_PINMASK ) | U1_RTS_PINSEL;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** \brief Write data of a certain length to a serial port.*/
|
||||
void serWrite (
|
||||
t_serial_devices device,
|
||||
UINT16 length, /**< Lengh of data in bytes */
|
||||
UINT8 * data /**< Pointer to data */
|
||||
)
|
||||
{
|
||||
switch( device )
|
||||
{
|
||||
case(COM1):
|
||||
uart0Write( (char *)data, length);
|
||||
break;
|
||||
case(COM2):
|
||||
uart1Write( (char *)data, length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Reads data from serial port.
|
||||
\retval Lengt of received data in bytes*/
|
||||
UINT16 serRead (
|
||||
t_serial_devices device,
|
||||
UINT8 * data /**< Pointer to data */
|
||||
)
|
||||
{
|
||||
UINT16 bytesReceived = 0;
|
||||
BOOLEAN receivedSomething;
|
||||
|
||||
do
|
||||
{
|
||||
receivedSomething = serGet( 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 serGet(
|
||||
t_serial_devices device,
|
||||
UINT8 * byte /**< Pointer to byte to return data*/
|
||||
)
|
||||
{
|
||||
int receivedChar = -1;
|
||||
|
||||
switch( device )
|
||||
{
|
||||
case(COM1):
|
||||
receivedChar = uart0Getch();
|
||||
break;
|
||||
case(COM2):
|
||||
receivedChar = uart1Getch();
|
||||
break;
|
||||
}
|
||||
|
||||
if (receivedChar >= 0)
|
||||
{
|
||||
*byte = (UINT8)receivedChar;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Send byte to serial port. */
|
||||
void serPut(
|
||||
t_serial_devices device,
|
||||
UINT8 value /**< Byte to send*/
|
||||
)
|
||||
{
|
||||
switch( device )
|
||||
{
|
||||
case(COM1):
|
||||
uart0Putch( value );
|
||||
break;
|
||||
case(COM2):
|
||||
uart1Putch( value );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** \brief Flush serial port buffers. */
|
||||
void serFlush(
|
||||
t_serial_devices device
|
||||
)
|
||||
{
|
||||
switch( device )
|
||||
{
|
||||
case(COM1):
|
||||
uart0TxFlush( );
|
||||
break;
|
||||
case(COM2):
|
||||
uart1TxFlush( );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** \brief Check if receive buffers is empty.
|
||||
\retval bool Returns true if recieve buffer is empty */
|
||||
BOOLEAN serEmpty(
|
||||
t_serial_devices device
|
||||
)
|
||||
{
|
||||
switch( device )
|
||||
{
|
||||
case(COM1):
|
||||
return (uart0RxEmpty( ) != 0);
|
||||
break;
|
||||
case(COM2):
|
||||
return (uart1RxEmpty( ) != 0);
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
RESULT serSetModemControl(
|
||||
t_serial_devices device,
|
||||
BOOLEAN enable
|
||||
)
|
||||
{
|
||||
if (device == COM2)
|
||||
{
|
||||
if (enable == TRUE)
|
||||
{
|
||||
U1MCR |= (UMCR_RTS_EN | UMCR_CTS_EN);
|
||||
}
|
||||
else
|
||||
{
|
||||
U1MCR &= ~(UMCR_RTS_EN | UMCR_CTS_EN);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* serial.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: RS232 interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 10-09-2007, Marcel Mulder.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef __SERIAL_H__
|
||||
#define __SERIAL_H__
|
||||
|
||||
/** \file serial.h
|
||||
\brief RS232 (UART) interface.
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "sys_config.h"
|
||||
#include "lpc23xx.h"
|
||||
#include "types.h"
|
||||
#include "uart.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Constant and macro definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Type definitions.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
COM1, /**< First RS232 port*/
|
||||
COM2 /**< Second RS232 port*/
|
||||
} t_serial_devices;
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Variable declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Function declarations.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
/** \brief Initialize of serial interface.*/
|
||||
void serInit (
|
||||
t_serial_devices device,
|
||||
UINT16 baudrate, /**< baudrate: B1200, B9600, B19200, B38400, B57600, B115200*/
|
||||
UINT8 mode, /**< 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 */
|
||||
UINT8 fmode /**< fmode: UART_FIFO_OFF, UART_FIFO_1, UART_FIFO_4, UART_FIFO_8,
|
||||
UART_FIFO_14*/
|
||||
);
|
||||
|
||||
/** \brief Write data of a certain length to a serial port.*/
|
||||
void serWrite (
|
||||
t_serial_devices device,
|
||||
UINT16 length, /**< Lengh of data in bytes */
|
||||
UINT8 * data /**< Pointer to data */
|
||||
);
|
||||
|
||||
/** \brief Reads data from serial port.
|
||||
\retval Lengt of received data in bytes*/
|
||||
UINT16 serRead (
|
||||
t_serial_devices device,
|
||||
UINT8 * data /**< Pointer to data */
|
||||
);
|
||||
|
||||
/** \brief Get byte from serial port.
|
||||
\retval bool Returns true if there was data */
|
||||
BOOLEAN serGet(
|
||||
t_serial_devices device,
|
||||
UINT8 * byte /**< Pointer to byte to return data*/
|
||||
);
|
||||
|
||||
/** \brief Send byte to serial port. */
|
||||
void serPut(
|
||||
t_serial_devices device,
|
||||
UINT8 value /**< Byte to send*/
|
||||
);
|
||||
|
||||
/** \brief Flush serial port buffers. */
|
||||
void serFlush(
|
||||
t_serial_devices device
|
||||
);
|
||||
|
||||
/** \brief Check if receive buffers is empty.
|
||||
\retval bool Returns true if recieve buffer is empty */
|
||||
BOOLEAN serEmpty(
|
||||
t_serial_devices device
|
||||
);
|
||||
|
||||
/** \brief Enables handshaking to use serial-port with an external modem
|
||||
* When enabled the CTS/RTS lines are used for communication with external modem.
|
||||
* The ModemControl is only supported by COM2
|
||||
* \retval OK Modem control was altered succesfull
|
||||
* \retval ERROR Modem control couldn't be altered (COM1 doesn't support modem control
|
||||
*/
|
||||
RESULT serSetModemControl(
|
||||
t_serial_devices device, /**< COM1 or COM2 */
|
||||
BOOLEAN enable /**< Enable/disable modem control */
|
||||
);
|
||||
|
||||
#endif /* __SERIAL_H__ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user