Compare commits

..

No commits in common. "main" and "web" have entirely different histories.
main ... web

101 changed files with 2439 additions and 32014 deletions

View File

@ -1,5 +1,5 @@
#MCUXpresso IDE
#Tue Oct 25 20:03:42 EEST 2022
product.version=11.2.1
product.build=4149
product.name=MCUXpresso IDE v11.2.1 [Build 4149] [2020-10-07]
#Wed Sep 14 11:02:46 EEST 2022
product.name=MCUXpresso IDE v11.5.0 [Build 7232] [2022-01-11]
product.version=11.5.0
product.build=7232

60
.vscode/settings.json vendored
View File

@ -1,63 +1,5 @@
{
"C_Cpp.autocompleteAddParentheses": true,
"files.autoSave": "onFocusChange",
"C_Cpp.codeAnalysis.clangTidy.enabled": true,
"files.associations": {
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"forward_list": "cpp",
"map": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"ratio": "cpp",
"string": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"thread": "cpp",
"typeinfo": "cpp",
"valarray": "cpp"
}
"C_Cpp.codeAnalysis.clangTidy.enabled": true
}

250
DigitalIoPin/.cproject Normal file
View File

@ -0,0 +1,250 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="com.crt.advproject.config.lib.debug.1518062075">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.lib.debug.1518062075" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/DigitalIoPin"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/DigitalIoPin/Debug"/>
<entry flags="RESOLVED" kind="libraryFile" name="DigitalIoPin" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" 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"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="Debug build" errorParsers="org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.config.lib.debug.1518062075" name="Debug" parent="com.crt.advproject.config.lib.debug" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size &quot;lib${BuildArtifactFileName}&quot; ; # arm-none-eabi-objdump -h -S &quot;lib${BuildArtifactFileName}&quot; &gt;&quot;${BuildArtifactFileBaseName}.lss&quot;">
<folderInfo id="com.crt.advproject.config.lib.debug.1518062075." name="/" resourcePath="">
<toolChain id="com.crt.advproject.toolchain.lib.debug.1961308744" name="NXP MCU Tools" superClass="com.crt.advproject.toolchain.lib.debug">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.lib.debug.1571898517" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.lib.debug"/>
<builder buildPath="${workspace_loc:/DigitalIoPin}/Debug" id="com.crt.advproject.builder.lib.debug.464461118" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.debug"/>
<tool id="com.crt.advproject.cpp.lib.debug.310180721" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.debug">
<option id="com.crt.advproject.cpp.thumb.1174398833" name="Thumb mode" superClass="com.crt.advproject.cpp.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.cpp.specs.1404807311" name="Specs" superClass="com.crt.advproject.cpp.specs" useByScannerDiscovery="false" value="com.crt.advproject.cpp.specs.newlib" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.arch.717445824" name="Architecture" superClass="com.crt.advproject.cpp.arch" useByScannerDiscovery="true" value="com.crt.advproject.cpp.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.preprocessor.def.743278416" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
</option>
<option id="gnu.cpp.compiler.option.other.other.1764900680" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions" valueType="string"/>
<option id="gnu.cpp.compiler.option.optimization.flags.1888170804" name="Other optimization flags" superClass="gnu.cpp.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/>
<option id="com.crt.advproject.cpp.hdrlib.639497941" name="Library headers" superClass="com.crt.advproject.cpp.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.fpu.86379455" name="Floating point" superClass="com.crt.advproject.cpp.fpu" useByScannerDiscovery="true"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.2038684751" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
</option>
<option id="com.crt.advproject.cpp.misc.dialect.1112988971" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.cpp.input.39768218" superClass="com.crt.advproject.compiler.cpp.input"/>
</tool>
<tool id="com.crt.advproject.gcc.lib.debug.2041881520" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.debug">
<option id="com.crt.advproject.gcc.thumb.90008040" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gcc.arch.1738776584" name="Architecture" superClass="com.crt.advproject.gcc.arch" useByScannerDiscovery="true" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.2113222256" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
</option>
<option id="gnu.c.compiler.option.misc.other.1001701785" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="gnu.c.compiler.option.optimization.flags.710115128" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.1319379195" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
</option>
<option id="com.crt.advproject.c.misc.dialect.2041400015" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.hdrlib.915238999" name="Library headers" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.specs.140377569" name="Specs" superClass="com.crt.advproject.gcc.specs" useByScannerDiscovery="false" value="com.crt.advproject.gcc.specs.newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.1098630190" superClass="com.crt.advproject.compiler.input"/>
</tool>
<tool id="com.crt.advproject.gas.lib.debug.1984691111" name="MCU Assembler" superClass="com.crt.advproject.gas.lib.debug">
<option id="com.crt.advproject.gas.thumb.386348535" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gas.arch.234822619" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm3" valueType="enumerated"/>
<option id="gnu.both.asm.option.flags.crt.180439041" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -DDEBUG -D__CODE_RED -DCORE_M3 -D__USE_LPCOPEN -D__LPC15XX__ -D__NEWLIB__" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.both.asm.option.include.paths.2025221020" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
</option>
<option id="com.crt.advproject.gas.hdrlib.924759647" name="Library headers" superClass="com.crt.advproject.gas.hdrlib" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gas.specs.401004871" name="Specs" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.newlib" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.950602248" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<inputType id="com.crt.advproject.assembler.input.168277101" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
</tool>
<tool id="com.crt.advproject.ar.lib.debug.1356704773" name="MCU Archiver" superClass="com.crt.advproject.ar.lib.debug"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="com.crt.advproject.config.lib.release.1725812107">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.lib.release.1725812107" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/DigitalIoPin"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/DigitalIoPin/Release"/>
<entry flags="RESOLVED" kind="libraryFile" name="DigitalIoPin" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" 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"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="Release build" errorParsers="org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.config.lib.release.1725812107" name="Release" parent="com.crt.advproject.config.lib.release" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size &quot;lib${BuildArtifactFileName}&quot; ; # arm-none-eabi-objdump -h -S &quot;lib${BuildArtifactFileName}&quot; &gt;&quot;${BuildArtifactFileBaseName}.lss&quot;">
<folderInfo id="com.crt.advproject.config.lib.release.1725812107." name="/" resourcePath="">
<toolChain id="com.crt.advproject.toolchain.lib.release.411289137" name="NXP MCU Tools" superClass="com.crt.advproject.toolchain.lib.release">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.lib.release.1067044818" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.lib.release"/>
<builder buildPath="${workspace_loc:/DigitalIoPin}/Release" id="com.crt.advproject.builder.lib.release.898496842" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.release"/>
<tool id="com.crt.advproject.cpp.lib.release.512458255" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.release">
<option id="com.crt.advproject.cpp.thumb.1656790701" name="Thumb mode" superClass="com.crt.advproject.cpp.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.cpp.specs.1526167256" name="Specs" superClass="com.crt.advproject.cpp.specs" useByScannerDiscovery="false" value="com.crt.advproject.cpp.specs.newlib" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.arch.1770421" name="Architecture" superClass="com.crt.advproject.cpp.arch" useByScannerDiscovery="true" value="com.crt.advproject.cpp.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.preprocessor.def.1768882125" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="NDEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
</option>
<option id="gnu.cpp.compiler.option.other.other.1768718306" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions" valueType="string"/>
<option id="gnu.cpp.compiler.option.optimization.flags.2119998568" name="Other optimization flags" superClass="gnu.cpp.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common -Os" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.2132452733" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
</option>
<option id="com.crt.advproject.cpp.misc.dialect.1903246995" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.hdrlib.553492414" name="Library headers" superClass="com.crt.advproject.cpp.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.cpp.input.590741145" superClass="com.crt.advproject.compiler.cpp.input"/>
</tool>
<tool id="com.crt.advproject.gcc.lib.release.1355642003" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.release">
<option id="com.crt.advproject.gcc.thumb.1754589407" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gcc.arch.143827267" name="Architecture" superClass="com.crt.advproject.gcc.arch" useByScannerDiscovery="true" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.1625879348" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="NDEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
</option>
<option id="gnu.c.compiler.option.misc.other.580338855" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="gnu.c.compiler.option.optimization.flags.1176853982" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.1751298170" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
</option>
<option id="com.crt.advproject.c.misc.dialect.1170395934" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.hdrlib.1768267698" name="Library headers" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.specs.832462962" name="Specs" superClass="com.crt.advproject.gcc.specs" useByScannerDiscovery="false" value="com.crt.advproject.gcc.specs.newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.1568901966" superClass="com.crt.advproject.compiler.input"/>
</tool>
<tool id="com.crt.advproject.gas.lib.release.2070847058" name="MCU Assembler" superClass="com.crt.advproject.gas.lib.release">
<option id="com.crt.advproject.gas.thumb.614016176" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gas.arch.851561506" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm3" valueType="enumerated"/>
<option id="gnu.both.asm.option.flags.crt.360053118" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -DNDEBUG -D__CODE_RED -DCORE_M3 -D__USE_LPCOPEN -D__LPC15XX__ -D__NEWLIB__" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.both.asm.option.include.paths.738388138" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
</option>
<option id="com.crt.advproject.gas.hdrlib.43406557" name="Library headers" superClass="com.crt.advproject.gas.hdrlib" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gas.specs.1304382268" name="Specs" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.newlib" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1427856065" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<inputType id="com.crt.advproject.assembler.input.1062822985" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
</tool>
<tool id="com.crt.advproject.ar.lib.release.1095765352" name="MCU Archiver" superClass="com.crt.advproject.ar.lib.release"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="DigitalIoPin.com.crt.advproject.projecttype.lib.947735594" name="Static Library" projectType="com.crt.advproject.projecttype.lib"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="com.crt.config">
<projectStorage>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;TargetConfig&gt;
&lt;Properties property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="100300"/&gt;
&lt;infoList vendor="NXP"&gt;
&lt;info chip="LPC1549" connectscript="LPC15RunBootRomConnect.scp" flash_driver="LPC15xx_256K.cfx" match_id="0x0" name="LPC1549" resetscript="LPC15RunBootRomReset.scp" stub="crt_emu_cm3_gen"&gt;
&lt;chip&gt;
&lt;name&gt;LPC1549&lt;/name&gt;
&lt;family&gt;LPC15xx&lt;/family&gt;
&lt;vendor&gt;NXP (formerly Philips)&lt;/vendor&gt;
&lt;reset board="None" core="Real" sys="Real"/&gt;
&lt;clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/&gt;
&lt;memory can_program="true" id="Flash" is_ro="true" type="Flash"/&gt;
&lt;memory id="RAM" type="RAM"/&gt;
&lt;memory id="Periph" is_volatile="true" type="Peripheral"/&gt;
&lt;memoryInstance derived_from="Flash" id="MFlash256" location="0x0" size="0x40000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram0_16" location="0x2000000" size="0x4000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram1_16" location="0x2004000" size="0x4000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram2_4" location="0x2008000" size="0x1000"/&gt;
&lt;/chip&gt;
&lt;processor&gt;
&lt;name gcc_name="cortex-m3"&gt;Cortex-M3&lt;/name&gt;
&lt;family&gt;Cortex-M&lt;/family&gt;
&lt;/processor&gt;
&lt;/info&gt;
&lt;/infoList&gt;
&lt;/TargetConfig&gt;</projectStorage>
</storageModule>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="com.crt.advproject">
<boardId>LPCXpresso1549</boardId>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>

1
DigitalIoPin/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/Debug/

29
DigitalIoPin/.project Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>DigitalIoPin</name>
<comment></comment>
<projects>
<project>lpc_chip_15xx</project>
<project>DigitalIoPin</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="com.crt.advproject.config.lib.debug.1518062075" name="Debug">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="com.crt.advproject.GCCBuildCommandParser" keep-relative-paths="false" name="MCU GCC Build Output Parser" parameter="(arm-none-eabi-gcc)|(arm-none-eabi-[gc]\+\+)|(gcc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="1877366442593287523" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
</extension>
</configuration>
<configuration id="com.crt.advproject.config.lib.release.1725812107" name="Release">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider copy-of="extension" id="com.crt.advproject.GCCBuildCommandParser"/>
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="1932457957984350467" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
</extension>
</configuration>
</project>

32
DigitalIoPin/liblinks.xml Normal file
View File

@ -0,0 +1,32 @@
<!-- liblinks.xml
NXP LPCXpresso IDE "Smart update wizard" script file
When executed on a particular application project, will
add appropriate links to the specified library project.
Note that this script assumes that the application project
contains the standard 'Debug' and 'Release' build
configurations.
-->
<project name="" update="true">
<setting id="all.compiler.inc">
<value>${MacroStart}workspace_loc:/${ProjName}/inc${MacroEnd}</value>
</setting>
<setting id="assembler.inc">
<value>${MacroStart}workspace_loc:/${ProjName}/inc${MacroEnd}</value>
</setting>
<setting id="linker.libs">
<value>${ProjName}</value>
</setting>
<setting id="linker.paths" buildType="Debug">
<value>${MacroStart}workspace_loc:/${ProjName}/Debug${MacroEnd}</value>
</setting>
<setting id="linker.paths" buildType="Release">
<value>${MacroStart}workspace_loc:/${ProjName}/Release${MacroEnd}</value>
</setting>
<requires msg="Library project `${ProjName}` not found">
<value>${ProjName}</value>
</requires>
</project>

242
I2C/.cproject Normal file
View File

@ -0,0 +1,242 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="com.crt.advproject.config.lib.debug.191941392">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.lib.debug.191941392" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/I2C"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/I2C/Debug"/>
<entry flags="RESOLVED" kind="libraryFile" name="I2C" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" 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"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="Debug build" errorParsers="org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.config.lib.debug.191941392" name="Debug" parent="com.crt.advproject.config.lib.debug" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size &quot;lib${BuildArtifactFileName}&quot; ; # arm-none-eabi-objdump -h -S &quot;lib${BuildArtifactFileName}&quot; &gt;&quot;${BuildArtifactFileBaseName}.lss&quot;">
<folderInfo id="com.crt.advproject.config.lib.debug.191941392." name="/" resourcePath="">
<toolChain id="com.crt.advproject.toolchain.lib.debug.1051493825" name="NXP MCU Tools" superClass="com.crt.advproject.toolchain.lib.debug">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.lib.debug.207117220" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.lib.debug"/>
<builder buildPath="${workspace_loc:/I2C}/Debug" id="com.crt.advproject.builder.lib.debug.1187274813" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.debug"/>
<tool id="com.crt.advproject.cpp.lib.debug.1875581182" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.debug">
<option id="com.crt.advproject.cpp.thumb.1751667547" name="Thumb mode" superClass="com.crt.advproject.cpp.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.cpp.specs.892692695" name="Specs" superClass="com.crt.advproject.cpp.specs" useByScannerDiscovery="false" value="com.crt.advproject.cpp.specs.newlib" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.arch.2121782955" name="Architecture" superClass="com.crt.advproject.cpp.arch" useByScannerDiscovery="true" value="com.crt.advproject.cpp.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.preprocessor.def.131760459" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
</option>
<option id="gnu.cpp.compiler.option.other.other.1970337386" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions" valueType="string"/>
<option id="gnu.cpp.compiler.option.optimization.flags.926363223" name="Other optimization flags" superClass="gnu.cpp.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/>
<option id="com.crt.advproject.cpp.hdrlib.156538777" name="Library headers" superClass="com.crt.advproject.cpp.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.fpu.1010908349" name="Floating point" superClass="com.crt.advproject.cpp.fpu" useByScannerDiscovery="true"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.672623669" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
</option>
<option id="com.crt.advproject.cpp.misc.dialect.728710465" superClass="com.crt.advproject.cpp.misc.dialect" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.cpp.input.1968272455" superClass="com.crt.advproject.compiler.cpp.input"/>
</tool>
<tool id="com.crt.advproject.gcc.lib.debug.1209411304" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.debug">
<option id="com.crt.advproject.gcc.thumb.1735812566" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gcc.arch.2123237403" name="Architecture" superClass="com.crt.advproject.gcc.arch" useByScannerDiscovery="true" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.700057815" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
</option>
<option id="gnu.c.compiler.option.misc.other.375265842" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="gnu.c.compiler.option.optimization.flags.1393030370" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.616919609" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
</option>
<option id="com.crt.advproject.c.misc.dialect.901436839" superClass="com.crt.advproject.c.misc.dialect" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.hdrlib.1284634346" superClass="com.crt.advproject.gcc.hdrlib" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.specs.2075371117" superClass="com.crt.advproject.gcc.specs" value="com.crt.advproject.gcc.specs.newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.1731651389" superClass="com.crt.advproject.compiler.input"/>
</tool>
<tool id="com.crt.advproject.gas.lib.debug.1402014901" name="MCU Assembler" superClass="com.crt.advproject.gas.lib.debug">
<option id="com.crt.advproject.gas.thumb.1825550506" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gas.arch.1509895458" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm3" valueType="enumerated"/>
<option id="gnu.both.asm.option.flags.crt.1477828788" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -DDEBUG -D__CODE_RED -DCORE_M3 -D__USE_LPCOPEN -D__LPC15XX__ -D__NEWLIB__" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.both.asm.option.include.paths.1394857969" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
</option>
<option id="com.crt.advproject.gas.hdrlib.1860339699" superClass="com.crt.advproject.gas.hdrlib" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gas.specs.611787929" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.newlib" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.962665264" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<inputType id="com.crt.advproject.assembler.input.312348915" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
</tool>
<tool id="com.crt.advproject.ar.lib.debug.1701573172" name="MCU Archiver" superClass="com.crt.advproject.ar.lib.debug"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="com.crt.advproject.config.lib.release.326424186">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.lib.release.326424186" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/I2C"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/I2C/Release"/>
<entry flags="RESOLVED" kind="libraryFile" name="I2C" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" 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"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="Release build" errorParsers="org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.config.lib.release.326424186" name="Release" parent="com.crt.advproject.config.lib.release" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size &quot;lib${BuildArtifactFileName}&quot; ; # arm-none-eabi-objdump -h -S &quot;lib${BuildArtifactFileName}&quot; &gt;&quot;${BuildArtifactFileBaseName}.lss&quot;">
<folderInfo id="com.crt.advproject.config.lib.release.326424186." name="/" resourcePath="">
<toolChain id="com.crt.advproject.toolchain.lib.release.2115062839" name="NXP MCU Tools" superClass="com.crt.advproject.toolchain.lib.release">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.lib.release.686079826" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.lib.release"/>
<builder buildPath="${workspace_loc:/I2C}/Release" id="com.crt.advproject.builder.lib.release.438649826" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.release"/>
<tool id="com.crt.advproject.cpp.lib.release.572759997" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.release">
<option id="com.crt.advproject.cpp.thumb.481099249" name="Thumb mode" superClass="com.crt.advproject.cpp.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.cpp.specs.61616074" name="Specs" superClass="com.crt.advproject.cpp.specs" useByScannerDiscovery="false" value="com.crt.advproject.cpp.specs.newlib" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.arch.2137356314" name="Architecture" superClass="com.crt.advproject.cpp.arch" useByScannerDiscovery="true" value="com.crt.advproject.cpp.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.preprocessor.def.1978024685" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="NDEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
</option>
<option id="gnu.cpp.compiler.option.other.other.1123252998" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions" valueType="string"/>
<option id="gnu.cpp.compiler.option.optimization.flags.1490571408" name="Other optimization flags" superClass="gnu.cpp.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common -Os" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.874979259" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
</option>
<option id="com.crt.advproject.cpp.misc.dialect.614377091" superClass="com.crt.advproject.cpp.misc.dialect" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.hdrlib.1612590666" superClass="com.crt.advproject.cpp.hdrlib" value="Newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.cpp.input.1300934729" superClass="com.crt.advproject.compiler.cpp.input"/>
</tool>
<tool id="com.crt.advproject.gcc.lib.release.469300912" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.release">
<option id="com.crt.advproject.gcc.thumb.1221591191" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gcc.arch.1728058218" name="Architecture" superClass="com.crt.advproject.gcc.arch" useByScannerDiscovery="true" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.1493930901" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="NDEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
</option>
<option id="gnu.c.compiler.option.misc.other.524305218" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="gnu.c.compiler.option.optimization.flags.1944087667" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.1581234441" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
</option>
<option id="com.crt.advproject.c.misc.dialect.1345069742" superClass="com.crt.advproject.c.misc.dialect" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.hdrlib.2008512552" superClass="com.crt.advproject.gcc.hdrlib" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.specs.1203227183" superClass="com.crt.advproject.gcc.specs" value="com.crt.advproject.gcc.specs.newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.314025432" superClass="com.crt.advproject.compiler.input"/>
</tool>
<tool id="com.crt.advproject.gas.lib.release.1070189235" name="MCU Assembler" superClass="com.crt.advproject.gas.lib.release">
<option id="com.crt.advproject.gas.thumb.2019492982" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gas.arch.840899267" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm3" valueType="enumerated"/>
<option id="gnu.both.asm.option.flags.crt.523197721" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -DNDEBUG -D__CODE_RED -DCORE_M3 -D__USE_LPCOPEN -D__LPC15XX__ -D__NEWLIB__" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.both.asm.option.include.paths.10173852" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
</option>
<option id="com.crt.advproject.gas.hdrlib.1031503760" superClass="com.crt.advproject.gas.hdrlib" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gas.specs.136287257" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.newlib" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.516112971" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<inputType id="com.crt.advproject.assembler.input.336128886" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
</tool>
<tool id="com.crt.advproject.ar.lib.release.1951020383" name="MCU Archiver" superClass="com.crt.advproject.ar.lib.release"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="I2C.com.crt.advproject.projecttype.lib.1725884821" name="Static Library" projectType="com.crt.advproject.projecttype.lib"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="com.crt.config">
<projectStorage>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;TargetConfig&gt;
&lt;Properties property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="100300"/&gt;
&lt;infoList vendor="NXP"&gt;
&lt;info chip="LPC1549" connectscript="LPC15RunBootRomConnect.scp" flash_driver="LPC15xx_256K.cfx" match_id="0x0" name="LPC1549" resetscript="LPC15RunBootRomReset.scp" stub="crt_emu_cm3_gen"&gt;
&lt;chip&gt;
&lt;name&gt;LPC1549&lt;/name&gt;
&lt;family&gt;LPC15xx&lt;/family&gt;
&lt;vendor&gt;NXP (formerly Philips)&lt;/vendor&gt;
&lt;reset board="None" core="Real" sys="Real"/&gt;
&lt;clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/&gt;
&lt;memory can_program="true" id="Flash" is_ro="true" type="Flash"/&gt;
&lt;memory id="RAM" type="RAM"/&gt;
&lt;memory id="Periph" is_volatile="true" type="Peripheral"/&gt;
&lt;memoryInstance derived_from="Flash" id="MFlash256" location="0x0" size="0x40000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram0_16" location="0x2000000" size="0x4000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram1_16" location="0x2004000" size="0x4000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram2_4" location="0x2008000" size="0x1000"/&gt;
&lt;/chip&gt;
&lt;processor&gt;
&lt;name gcc_name="cortex-m3"&gt;Cortex-M3&lt;/name&gt;
&lt;family&gt;Cortex-M&lt;/family&gt;
&lt;/processor&gt;
&lt;/info&gt;
&lt;/infoList&gt;
&lt;/TargetConfig&gt;</projectStorage>
</storageModule>
<storageModule moduleId="com.crt.advproject">
<boardId>LPCXpresso1549</boardId>
</storageModule>
</cproject>

1
I2C/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/Debug/

28
I2C/.project Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>I2C</name>
<comment></comment>
<projects>
<project>lpc_chip_15xx</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -15,7 +15,7 @@ struct I2C_config {
unsigned int speed;
unsigned int clock_divider;
unsigned int i2c_mode;
I2C_config(unsigned int dn, unsigned int sp, unsigned int cd): device_number(dn), speed(sp), clock_divider(cd), i2c_mode(IOCON_SFI2C_EN) {};
I2C_config(): device_number(0), speed(100000), clock_divider(40), i2c_mode(IOCON_SFI2C_EN) {};
};
class I2C {

32
I2C/liblinks.xml Normal file
View File

@ -0,0 +1,32 @@
<!-- liblinks.xml
NXP LPCXpresso IDE "Smart update wizard" script file
When executed on a particular application project, will
add appropriate links to the specified library project.
Note that this script assumes that the application project
contains the standard 'Debug' and 'Release' build
configurations.
-->
<project name="" update="true">
<setting id="all.compiler.inc">
<value>${MacroStart}workspace_loc:/${ProjName}/inc${MacroEnd}</value>
</setting>
<setting id="assembler.inc">
<value>${MacroStart}workspace_loc:/${ProjName}/inc${MacroEnd}</value>
</setting>
<setting id="linker.libs">
<value>${ProjName}</value>
</setting>
<setting id="linker.paths" buildType="Debug">
<value>${MacroStart}workspace_loc:/${ProjName}/Debug${MacroEnd}</value>
</setting>
<setting id="linker.paths" buildType="Release">
<value>${MacroStart}workspace_loc:/${ProjName}/Release${MacroEnd}</value>
</setting>
<requires msg="Library project `${ProjName}` not found">
<value>${ProjName}</value>
</requires>
</project>

143
I2C/src/I2C.cpp Normal file
View File

@ -0,0 +1,143 @@
/*
* I2C.cpp
*
* Created on: 21.2.2016
* Author: krl
* Based on example provided by NXP Semiconductors. See copyright notice below.
*/
/*
* @brief I2CM bus master example using polling mode
*
* @note
* Copyright(C) NXP Semiconductors, 2014
* All rights reserved.
*
* @par
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* LPC products. This software is supplied "AS IS" without any warranties of
* any kind, and NXP Semiconductors and its licensor disclaim any and
* all warranties, express or implied, including all implied warranties of
* merchantability, fitness for a particular purpose and non-infringement of
* intellectual property rights. NXP Semiconductors assumes no responsibility
* or liability for the use of the software, conveys no license or rights under any
* patent, copyright, mask work right, or any other intellectual property rights in
* or to any products. NXP Semiconductors reserves the right to make changes
* in the software without notification. NXP Semiconductors also makes no
* representation or warranty that such application will be suitable for the
* specified use without further testing or modification.
*
* @par
* Permission to use, copy, modify, and distribute this software and its
* documentation is hereby granted, under NXP Semiconductors' and its
* licensor's relevant copyrights in the software, without fee, provided that it
* is used in conjunction with NXP Semiconductors microcontrollers. This
* copyright, permission, and disclaimer notice must appear in all copies of
* this code.
*/
#include "I2C.h"
I2C::I2C(const I2C_config &cfg): device(nullptr) {
if(cfg.device_number == 0) {
device = LPC_I2C0;
// board init must have been called before the pins can be configured
Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 22, IOCON_DIGMODE_EN | cfg.i2c_mode);
Chip_IOCON_PinMuxSet(LPC_IOCON, 0, 23, IOCON_DIGMODE_EN | cfg.i2c_mode);
Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SCL);
Chip_SWM_EnableFixedPin(SWM_FIXED_I2C0_SDA);
}
else {
// currently we support only I2C number 0
}
if(device) {
/* Enable I2C clock and reset I2C peripheral - the boot ROM does not
do this */
Chip_I2C_Init(device);
/* Setup clock rate for I2C */
Chip_I2C_SetClockDiv(device, cfg.clock_divider);
/* Setup I2CM transfer rate */
Chip_I2CM_SetBusSpeed(device, cfg.speed);
/* Enable Master Mode */
Chip_I2CM_Enable(device);
}
}
I2C::~I2C() {
// TODO Auto-generated destructor stub
}
bool I2C::write(uint8_t devAddr, uint8_t *txBuffPtr, uint16_t txSize)
{
return transaction(devAddr, txBuffPtr, txSize, nullptr, 0);
}
bool I2C::read(uint8_t devAddr, uint8_t *rxBuffPtr, uint16_t rxSize)
{
return transaction(devAddr, nullptr, 0, rxBuffPtr, rxSize);
}
bool I2C::transaction(uint8_t devAddr, uint8_t *txBuffPtr, uint16_t txSize, uint8_t *rxBuffPtr, uint16_t rxSize) {
I2CM_XFER_T i2cmXferRec;
// make sure that master is idle
while(!Chip_I2CM_IsMasterPending(device));
/* Setup I2C transfer record */
i2cmXferRec.slaveAddr = devAddr;
i2cmXferRec.status = 0;
i2cmXferRec.txSz = txSize;
i2cmXferRec.rxSz = rxSize;
i2cmXferRec.txBuff = txBuffPtr;
i2cmXferRec.rxBuff = rxBuffPtr;
I2CM_XferBlocking(device, &i2cmXferRec);
// Chip_I2CM_XferBlocking returns before stop condition is fully completed
// therefore we need to wait for master to be idle when doing back-to-back transactions (see beginning of the function)
/* Test for valid operation */
if (i2cmXferRec.status == I2CM_STATUS_OK) {
return true;
}
else {
return false;
}
}
/* Transmit and Receive data in master mode */
/* This duplicates (and combines) the functionality of Chip_I2CM_Xfer and Chip_I2CM_XferBlocking with a modification
* that allows us to do a zero length write (needed to use honeywell humidity/temp sensor)
*/
uint32_t I2C::I2CM_XferBlocking(LPC_I2C_T *pI2C, I2CM_XFER_T *xfer)
{
uint32_t ret = 0;
/* start transfer */
/* set the transfer status as busy */
xfer->status = I2CM_STATUS_BUSY;
/* Clear controller state. */
Chip_I2CM_ClearStatus(pI2C, I2C_STAT_MSTRARBLOSS | I2C_STAT_MSTSTSTPERR);
/* Write Address and RW bit to data register */
//Chip_I2CM_WriteByte(pI2C, (xfer->slaveAddr << 1) | (xfer->txSz == 0)); // original NXP version
// krl : both read and write lenght is 0 --> write (for honeywell temp sensor)
Chip_I2CM_WriteByte(pI2C, (xfer->slaveAddr << 1) | (xfer->txSz == 0 && xfer->rxSz != 0));
/* Enter to Master Transmitter mode */
Chip_I2CM_SendStart(pI2C);
while (ret == 0) {
/* wait for status change interrupt */
while (!Chip_I2CM_IsMasterPending(pI2C)) {}
/* call state change handler */
ret = Chip_I2CM_XferHandler(pI2C, xfer);
}
return ret;
}

249
LiquidCrystal/.cproject Normal file
View File

@ -0,0 +1,249 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="com.crt.advproject.config.lib.debug.491234774">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.lib.debug.491234774" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/LiquidCrystal"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/LiquidCrystal/Debug"/>
<entry flags="RESOLVED" kind="libraryFile" name="LiquidCrystal" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" 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"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="Debug build" errorParsers="org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.config.lib.debug.491234774" name="Debug" parent="com.crt.advproject.config.lib.debug" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size &quot;lib${BuildArtifactFileName}&quot; ; # arm-none-eabi-objdump -h -S &quot;lib${BuildArtifactFileName}&quot; &gt;&quot;${BuildArtifactFileBaseName}.lss&quot;">
<folderInfo id="com.crt.advproject.config.lib.debug.491234774." name="/" resourcePath="">
<toolChain id="com.crt.advproject.toolchain.lib.debug.298354626" name="NXP MCU Tools" superClass="com.crt.advproject.toolchain.lib.debug">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.lib.debug.1867685434" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.lib.debug"/>
<builder buildPath="${workspace_loc:/LiquidCrystal}/Debug" id="com.crt.advproject.builder.lib.debug.1049121960" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.debug"/>
<tool id="com.crt.advproject.cpp.lib.debug.2022743513" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.debug">
<option id="com.crt.advproject.cpp.thumb.682731264" name="Thumb mode" superClass="com.crt.advproject.cpp.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.cpp.specs.1747847801" name="Specs" superClass="com.crt.advproject.cpp.specs" useByScannerDiscovery="false" value="com.crt.advproject.cpp.specs.newlib" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.arch.1747698751" name="Architecture" superClass="com.crt.advproject.cpp.arch" useByScannerDiscovery="true" value="com.crt.advproject.cpp.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.preprocessor.def.1721702496" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
</option>
<option id="gnu.cpp.compiler.option.other.other.1776117968" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions" valueType="string"/>
<option id="gnu.cpp.compiler.option.optimization.flags.353447094" name="Other optimization flags" superClass="gnu.cpp.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/>
<option id="com.crt.advproject.cpp.hdrlib.1084356259" name="Library headers" superClass="com.crt.advproject.cpp.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.fpu.2104140646" name="Floating point" superClass="com.crt.advproject.cpp.fpu" useByScannerDiscovery="true"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.1234128704" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
</option>
<option id="com.crt.advproject.cpp.misc.dialect.1625744746" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.cpp.input.691505355" superClass="com.crt.advproject.compiler.cpp.input"/>
</tool>
<tool id="com.crt.advproject.gcc.lib.debug.107454654" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.debug">
<option id="com.crt.advproject.gcc.thumb.1605012992" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gcc.arch.1356678648" name="Architecture" superClass="com.crt.advproject.gcc.arch" useByScannerDiscovery="true" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.2007539358" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
</option>
<option id="gnu.c.compiler.option.misc.other.839584084" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="gnu.c.compiler.option.optimization.flags.52401006" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.633254536" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
</option>
<option id="com.crt.advproject.c.misc.dialect.1170072077" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.hdrlib.13718322" name="Library headers" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.specs.357585551" name="Specs" superClass="com.crt.advproject.gcc.specs" useByScannerDiscovery="false" value="com.crt.advproject.gcc.specs.newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.970167353" superClass="com.crt.advproject.compiler.input"/>
</tool>
<tool id="com.crt.advproject.gas.lib.debug.167079580" name="MCU Assembler" superClass="com.crt.advproject.gas.lib.debug">
<option id="com.crt.advproject.gas.thumb.1588424301" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gas.arch.1568365533" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm3" valueType="enumerated"/>
<option id="gnu.both.asm.option.flags.crt.1300110585" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -DDEBUG -D__CODE_RED -DCORE_M3 -D__USE_LPCOPEN -D__LPC15XX__ -D__NEWLIB__" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.both.asm.option.include.paths.1305629823" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
</option>
<option id="com.crt.advproject.gas.hdrlib.1183097320" name="Library headers" superClass="com.crt.advproject.gas.hdrlib" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gas.specs.1998365769" name="Specs" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.newlib" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1656320489" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<inputType id="com.crt.advproject.assembler.input.1207424849" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
</tool>
<tool id="com.crt.advproject.ar.lib.debug.1806407705" name="MCU Archiver" superClass="com.crt.advproject.ar.lib.debug"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="com.crt.advproject.config.lib.release.178275168">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.lib.release.178275168" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/LiquidCrystal"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/LiquidCrystal/Release"/>
<entry flags="RESOLVED" kind="libraryFile" name="LiquidCrystal" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" 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"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="Release build" errorParsers="org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.config.lib.release.178275168" name="Release" parent="com.crt.advproject.config.lib.release" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size &quot;lib${BuildArtifactFileName}&quot; ; # arm-none-eabi-objdump -h -S &quot;lib${BuildArtifactFileName}&quot; &gt;&quot;${BuildArtifactFileBaseName}.lss&quot;">
<folderInfo id="com.crt.advproject.config.lib.release.178275168." name="/" resourcePath="">
<toolChain id="com.crt.advproject.toolchain.lib.release.814881200" name="NXP MCU Tools" superClass="com.crt.advproject.toolchain.lib.release">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.lib.release.1810295326" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.lib.release"/>
<builder buildPath="${workspace_loc:/LiquidCrystal}/Release" id="com.crt.advproject.builder.lib.release.1490636416" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.release"/>
<tool id="com.crt.advproject.cpp.lib.release.1300243291" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.release">
<option id="com.crt.advproject.cpp.thumb.1242918206" name="Thumb mode" superClass="com.crt.advproject.cpp.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.cpp.specs.687552087" name="Specs" superClass="com.crt.advproject.cpp.specs" useByScannerDiscovery="false" value="com.crt.advproject.cpp.specs.newlib" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.arch.1547856736" name="Architecture" superClass="com.crt.advproject.cpp.arch" useByScannerDiscovery="true" value="com.crt.advproject.cpp.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.preprocessor.def.1767776611" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="NDEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
</option>
<option id="gnu.cpp.compiler.option.other.other.2053580643" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions" valueType="string"/>
<option id="gnu.cpp.compiler.option.optimization.flags.76369618" name="Other optimization flags" superClass="gnu.cpp.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common -Os" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.743427784" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
</option>
<option id="com.crt.advproject.cpp.misc.dialect.545752381" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.hdrlib.2142443075" name="Library headers" superClass="com.crt.advproject.cpp.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.cpp.input.280755041" superClass="com.crt.advproject.compiler.cpp.input"/>
</tool>
<tool id="com.crt.advproject.gcc.lib.release.1008320029" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.release">
<option id="com.crt.advproject.gcc.thumb.1577932001" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gcc.arch.706218826" name="Architecture" superClass="com.crt.advproject.gcc.arch" useByScannerDiscovery="true" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.1519817446" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="NDEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
</option>
<option id="gnu.c.compiler.option.misc.other.1212942126" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="gnu.c.compiler.option.optimization.flags.202142626" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.1898386642" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
</option>
<option id="com.crt.advproject.c.misc.dialect.253229857" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.hdrlib.2004682055" name="Library headers" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.specs.467286936" name="Specs" superClass="com.crt.advproject.gcc.specs" useByScannerDiscovery="false" value="com.crt.advproject.gcc.specs.newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.1284515478" superClass="com.crt.advproject.compiler.input"/>
</tool>
<tool id="com.crt.advproject.gas.lib.release.1806032865" name="MCU Assembler" superClass="com.crt.advproject.gas.lib.release">
<option id="com.crt.advproject.gas.thumb.858134005" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gas.arch.286400153" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm3" valueType="enumerated"/>
<option id="gnu.both.asm.option.flags.crt.63591780" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -DNDEBUG -D__CODE_RED -DCORE_M3 -D__USE_LPCOPEN -D__LPC15XX__ -D__NEWLIB__" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.both.asm.option.include.paths.1947719563" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
</option>
<option id="com.crt.advproject.gas.hdrlib.1508156810" name="Library headers" superClass="com.crt.advproject.gas.hdrlib" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gas.specs.1102924522" name="Specs" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.newlib" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1802849297" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<inputType id="com.crt.advproject.assembler.input.1352132979" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
</tool>
<tool id="com.crt.advproject.ar.lib.release.671284958" name="MCU Archiver" superClass="com.crt.advproject.ar.lib.release"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="LiquidCrystal.com.crt.advproject.projecttype.lib.1884492746" name="Static Library" projectType="com.crt.advproject.projecttype.lib"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="com.crt.config">
<projectStorage>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;TargetConfig&gt;
&lt;Properties property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="100300"/&gt;
&lt;infoList vendor="NXP"&gt;
&lt;info chip="LPC1549" connectscript="LPC15RunBootRomConnect.scp" flash_driver="LPC15xx_256K.cfx" match_id="0x0" name="LPC1549" resetscript="LPC15RunBootRomReset.scp" stub="crt_emu_cm3_gen"&gt;
&lt;chip&gt;
&lt;name&gt;LPC1549&lt;/name&gt;
&lt;family&gt;LPC15xx&lt;/family&gt;
&lt;vendor&gt;NXP (formerly Philips)&lt;/vendor&gt;
&lt;reset board="None" core="Real" sys="Real"/&gt;
&lt;clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/&gt;
&lt;memory can_program="true" id="Flash" is_ro="true" type="Flash"/&gt;
&lt;memory id="RAM" type="RAM"/&gt;
&lt;memory id="Periph" is_volatile="true" type="Peripheral"/&gt;
&lt;memoryInstance derived_from="Flash" id="MFlash256" location="0x0" size="0x40000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram0_16" location="0x2000000" size="0x4000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram1_16" location="0x2004000" size="0x4000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram2_4" location="0x2008000" size="0x1000"/&gt;
&lt;/chip&gt;
&lt;processor&gt;
&lt;name gcc_name="cortex-m3"&gt;Cortex-M3&lt;/name&gt;
&lt;family&gt;Cortex-M&lt;/family&gt;
&lt;/processor&gt;
&lt;/info&gt;
&lt;/infoList&gt;
&lt;/TargetConfig&gt;</projectStorage>
</storageModule>
<storageModule moduleId="com.crt.advproject">
<boardId>LPCXpresso1549</boardId>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>

1
LiquidCrystal/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/Debug/

29
LiquidCrystal/.project Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>LiquidCrystal</name>
<comment></comment>
<projects>
<project>lpc_chip_15xx</project>
<project>DigitalIoPin</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -1,10 +1,11 @@
#ifndef LiquidCrystal_h
#define LiquidCrystal_h
#include "DigitalIoPin.h"
#include "chip.h"
#include <cstddef>
#include <string>
#include "chip.h"
#include "DigitalIoPin.h"
// commands
#define LCD_CLEARDISPLAY 0x01
@ -44,11 +45,11 @@
#define LCD_5x10DOTS 0x04
#define LCD_5x8DOTS 0x00
class LiquidCrystal
{
class LiquidCrystal {
public:
LiquidCrystal (DigitalIoPin *rs, DigitalIoPin *enable, DigitalIoPin *d0,
DigitalIoPin *d1, DigitalIoPin *d2, DigitalIoPin *d3);
LiquidCrystal(DigitalIoPin *rs, DigitalIoPin *enable,
DigitalIoPin *d0, DigitalIoPin *d1, DigitalIoPin *d2, DigitalIoPin *d3);
void begin(uint8_t cols, uint8_t rows, uint8_t charsize = LCD_5x8DOTS);
@ -74,10 +75,6 @@ public:
void command(uint8_t);
void print(std::string const &s);
void print(const char *s);
void printOnLineOne (const char *s);
void printOnLineTwo (const char *s);
void printOnLineOne (std::string const &s);
void printOnLineTwo (std::string const &s);
private:
void send(uint8_t, uint8_t);
@ -95,7 +92,6 @@ private:
uint8_t _initialized;
uint8_t _numlines,_currline;
uint8_t rows, col;
};
#endif

View File

@ -0,0 +1,32 @@
<!-- liblinks.xml
NXP LPCXpresso IDE "Smart update wizard" script file
When executed on a particular application project, will
add appropriate links to the specified library project.
Note that this script assumes that the application project
contains the standard 'Debug' and 'Release' build
configurations.
-->
<project name="" update="true">
<setting id="all.compiler.inc">
<value>${MacroStart}workspace_loc:/${ProjName}/inc${MacroEnd}</value>
</setting>
<setting id="assembler.inc">
<value>${MacroStart}workspace_loc:/${ProjName}/inc${MacroEnd}</value>
</setting>
<setting id="linker.libs">
<value>${ProjName}</value>
</setting>
<setting id="linker.paths" buildType="Debug">
<value>${MacroStart}workspace_loc:/${ProjName}/Debug${MacroEnd}</value>
</setting>
<setting id="linker.paths" buildType="Release">
<value>${MacroStart}workspace_loc:/${ProjName}/Release${MacroEnd}</value>
</setting>
<requires msg="Library project `${ProjName}` not found">
<value>${ProjName}</value>
</requires>
</project>

View File

@ -0,0 +1,268 @@
#include "LiquidCrystal.h"
#include <cstring>
#include "chip.h"
#define LOW 0
#define HIGH 1
void delayMicroseconds(unsigned int us)
{
// implement with RIT
}
// When the display powers up, it is configured as follows:
//
// 1. Display clear
// 2. Function set:
// DL = 1; 8-bit interface data
// N = 0; 1-line display
// F = 0; 5x8 dot character font
// 3. Display on/off control:
// D = 0; Display off
// C = 0; Cursor off
// B = 0; Blinking off
// 4. Entry mode set:
// I/D = 1; Increment by 1
// S = 0; No shift
//
// Note, however, that resetting the Arduino doesn't reset the LCD, so we
// can't assume that its in that state when a sketch starts (and the
// LiquidCrystal constructor is called).
LiquidCrystal::LiquidCrystal(DigitalIoPin *rs, DigitalIoPin *enable,
DigitalIoPin *d0, DigitalIoPin *d1, DigitalIoPin *d2, DigitalIoPin *d3)
{
rs_pin = rs;
enable_pin = enable;
data_pins[0] = d0;
data_pins[1] = d1;
data_pins[2] = d2;
data_pins[3] = d3;
_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
begin(16, 2); // default to 16x2 display
}
void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
if (lines > 1) {
_displayfunction |= LCD_2LINE;
}
_numlines = lines;
_currline = 0;
// for some 1 line displays you can select a 10 pixel high font
if ((dotsize != 0) && (lines == 1)) {
_displayfunction |= LCD_5x10DOTS;
}
// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
// according to datasheet, we need at least 40ms after power rises above 2.7V
// before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
delayMicroseconds(50000);
// Now we pull both RS and R/W low to begin commands
rs_pin->write(false); //digitalWrite(_rs_pin, LOW);
enable_pin->write(false); //digitalWrite(_enable_pin, LOW);
// note: this port supports only 4 bit mode
//put the LCD into 4 bit or 8 bit mode
if (! (_displayfunction & LCD_8BITMODE)) {
// this is according to the hitachi HD44780 datasheet
// figure 24, pg 46
// we start in 8bit mode, try to set 4 bit mode
write4bits(0x03);
delayMicroseconds(4500); // wait min 4.1ms
// second try
write4bits(0x03);
delayMicroseconds(4500); // wait min 4.1ms
// third go!
write4bits(0x03);
delayMicroseconds(150);
// finally, set to 4-bit interface
write4bits(0x02);
} else {
// this is according to the hitachi HD44780 datasheet
// page 45 figure 23
// Send function set command sequence
command(LCD_FUNCTIONSET | _displayfunction);
delayMicroseconds(4500); // wait more than 4.1ms
// second try
command(LCD_FUNCTIONSET | _displayfunction);
delayMicroseconds(150);
// third go
command(LCD_FUNCTIONSET | _displayfunction);
}
// finally, set # lines, font size, etc.
command(LCD_FUNCTIONSET | _displayfunction);
// turn the display on with no cursor or blinking default
_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
display();
// clear it off
clear();
// Initialize to default text direction (for romance languages)
_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
// set the entry mode
command(LCD_ENTRYMODESET | _displaymode);
}
/********** high level commands, for the user! */
void LiquidCrystal::clear()
{
command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero
delayMicroseconds(2000); // this command takes a long time!
}
void LiquidCrystal::home()
{
command(LCD_RETURNHOME); // set cursor position to zero
delayMicroseconds(2000); // this command takes a long time!
}
void LiquidCrystal::print(std::string const &s)
{
}
void LiquidCrystal::print(const char *s)
{
}
void LiquidCrystal::setCursor(uint8_t col, uint8_t row)
{
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
if ( row >= _numlines ) {
row = _numlines-1; // we count rows starting w/0
}
command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
}
// Turn the display on/off (quickly)
void LiquidCrystal::noDisplay() {
_displaycontrol &= ~LCD_DISPLAYON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
void LiquidCrystal::display() {
_displaycontrol |= LCD_DISPLAYON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
// Turns the underline cursor on/off
void LiquidCrystal::noCursor() {
_displaycontrol &= ~LCD_CURSORON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
void LiquidCrystal::cursor() {
_displaycontrol |= LCD_CURSORON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
// Turn on and off the blinking cursor
void LiquidCrystal::noBlink() {
_displaycontrol &= ~LCD_BLINKON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
void LiquidCrystal::blink() {
_displaycontrol |= LCD_BLINKON;
command(LCD_DISPLAYCONTROL | _displaycontrol);
}
// These commands scroll the display without changing the RAM
void LiquidCrystal::scrollDisplayLeft(void) {
command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT);
}
void LiquidCrystal::scrollDisplayRight(void) {
command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT);
}
// This is for text that flows Left to Right
void LiquidCrystal::leftToRight(void) {
_displaymode |= LCD_ENTRYLEFT;
command(LCD_ENTRYMODESET | _displaymode);
}
// This is for text that flows Right to Left
void LiquidCrystal::rightToLeft(void) {
_displaymode &= ~LCD_ENTRYLEFT;
command(LCD_ENTRYMODESET | _displaymode);
}
// This will 'right justify' text from the cursor
void LiquidCrystal::autoscroll(void) {
_displaymode |= LCD_ENTRYSHIFTINCREMENT;
command(LCD_ENTRYMODESET | _displaymode);
}
// This will 'left justify' text from the cursor
void LiquidCrystal::noAutoscroll(void) {
_displaymode &= ~LCD_ENTRYSHIFTINCREMENT;
command(LCD_ENTRYMODESET | _displaymode);
}
// Allows us to fill the first 8 CGRAM locations
// with custom characters
void LiquidCrystal::createChar(uint8_t location, uint8_t charmap[]) {
location &= 0x7; // we only have 8 locations 0-7
command(LCD_SETCGRAMADDR | (location << 3));
for (int i=0; i<8; i++) {
write(charmap[i]);
}
}
/*********** mid level commands, for sending data/cmds */
inline void LiquidCrystal::command(uint8_t value) {
send(value, LOW);
}
inline size_t LiquidCrystal::write(uint8_t value) {
send(value, HIGH);
return 1; // assume sucess
}
/************ low level data pushing commands **********/
// write either command or data
void LiquidCrystal::send(uint8_t value, uint8_t mode) {
rs_pin->write(mode); //digitalWrite(_rs_pin, mode);
write4bits(value>>4);
write4bits(value);
}
void LiquidCrystal::pulseEnable(void) {
enable_pin->write(false); //digitalWrite(_enable_pin, LOW);
delayMicroseconds(1);
enable_pin->write(true); //digitalWrite(_enable_pin, HIGH);
delayMicroseconds(1); // enable pulse must be >450ns
enable_pin->write(false); //digitalWrite(_enable_pin, LOW);
delayMicroseconds(100); // commands need > 37us to settle
}
void LiquidCrystal::write4bits(uint8_t value) {
for (int i = 0; i < 4; i++) {
data_pins[i]->write((value >> i) & 0x01); //digitalWrite(_data_pins[i], (value >> i) & 0x01);
}
pulseEnable();
}

View File

@ -1,37 +1,3 @@
# ESP-Ventilation
A school project to control a simulated ventilation system based on measured CO2 levels <br>
**[Google drive folder](https://docs.google.com/document/d/12K4G12bVbDqZUrHPMkFk3nm1rfgFxZ1O2iIwMq2Nnus/edit?usp=sharing)**
## Embedded Systems Programming Ventilation Project
The objective of this project was to create a smart ventilation system that has the capability to display sensor data and let users set the ventilation fan speed manually, or let the system determine the fan speed in automatic operation by setting the target output air pressure to achieve. This documentation examines the overall system architecture in hardware and software, operation of the system, the development process and goes in detail of the technical implementation. As hardware implementation of this ventilation system is pre-determined, particular attention in this documentation is paid to the embedded software and communications implementation.
## Download latest release
### [esp-vent-main v1.0.0](https://github.com/vas-dav/ESP-Ventilation/releases) (2022-10-31)
> Source code is safely building on **MCUXpresso IDE v11.5.0 [Build 7232] [2022-01-11]**
### Current functionality:
### Modes:
##### Manual:
```
- Buttons to inc/dec fan speed(0-10V) (show in percents 10% == 1V)
- Display fan speed + pressure.
- Fan updates at the same time as UI
- BTN1 inc voltage, BTN2 dec voltage
```
##### Automatic:
```
- Buttons to inc/dec fan pressure level (0-120 Pa) (show in percents 10% == 1V)
- Pressure to inc/dec fan speed
- BTN1 inc pressure, BTN2 dec pressure
```
##### Additional:
```
- BTN3 switch between modes
- BTN4 show sensor values
```
## Latest Changes
* [Closed Pull-requests](https://github.com/vas-dav/ESP-Ventilation/pulls?q=is%3Apr+is%3Aclosed)
#### [Open issues](https://github.com/vas-dav/ESP-Ventilation/issues)
**[Google drive folder](https://drive.google.com/drive/u/0/folders/1m0P0oLnWNH737N3Yf6Oea9ZUBLr58K3S)**

255
StateHandler/.cproject Normal file
View File

@ -0,0 +1,255 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="com.crt.advproject.config.lib.debug.1917324784">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.lib.debug.1917324784" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/StateHandler"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/StateHandler/Debug"/>
<entry flags="RESOLVED" kind="libraryFile" name="StateHandler" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" 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"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="Debug build" errorParsers="org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.config.lib.debug.1917324784" name="Debug" parent="com.crt.advproject.config.lib.debug" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size &quot;lib${BuildArtifactFileName}&quot; ; # arm-none-eabi-objdump -h -S &quot;lib${BuildArtifactFileName}&quot; &gt;&quot;${BuildArtifactFileBaseName}.lss&quot;">
<folderInfo id="com.crt.advproject.config.lib.debug.1917324784." name="/" resourcePath="">
<toolChain id="com.crt.advproject.toolchain.lib.debug.301539991" name="NXP MCU Tools" superClass="com.crt.advproject.toolchain.lib.debug">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.lib.debug.1975706127" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.lib.debug"/>
<builder buildPath="${workspace_loc:/StateHandler}/Debug" id="com.crt.advproject.builder.lib.debug.67415099" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.debug"/>
<tool id="com.crt.advproject.cpp.lib.debug.2122404759" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.debug">
<option id="com.crt.advproject.cpp.thumb.383841445" name="Thumb mode" superClass="com.crt.advproject.cpp.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.cpp.specs.814897417" name="Specs" superClass="com.crt.advproject.cpp.specs" useByScannerDiscovery="false" value="com.crt.advproject.cpp.specs.newlib" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.arch.1669454496" name="Architecture" superClass="com.crt.advproject.cpp.arch" useByScannerDiscovery="true" value="com.crt.advproject.cpp.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.preprocessor.def.414375395" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
</option>
<option id="gnu.cpp.compiler.option.other.other.1878960650" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions" valueType="string"/>
<option id="gnu.cpp.compiler.option.optimization.flags.13127204" name="Other optimization flags" superClass="gnu.cpp.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/>
<option id="com.crt.advproject.cpp.hdrlib.1830728640" name="Library headers" superClass="com.crt.advproject.cpp.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.fpu.1141005092" name="Floating point" superClass="com.crt.advproject.cpp.fpu" useByScannerDiscovery="true"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.102003530" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
</option>
<option id="com.crt.advproject.cpp.misc.dialect.1047276372" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.cpp.input.1472075573" superClass="com.crt.advproject.compiler.cpp.input"/>
</tool>
<tool id="com.crt.advproject.gcc.lib.debug.170081941" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.debug">
<option id="com.crt.advproject.gcc.thumb.1810467282" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gcc.arch.1131084062" name="Architecture" superClass="com.crt.advproject.gcc.arch" useByScannerDiscovery="true" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.2043988332" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
</option>
<option id="gnu.c.compiler.option.misc.other.395371444" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="gnu.c.compiler.option.optimization.flags.1013507885" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.521232105" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
</option>
<option id="com.crt.advproject.c.misc.dialect.1367957643" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.hdrlib.1476293714" name="Library headers" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.specs.172368975" name="Specs" superClass="com.crt.advproject.gcc.specs" useByScannerDiscovery="false" value="com.crt.advproject.gcc.specs.newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.2095363656" superClass="com.crt.advproject.compiler.input"/>
</tool>
<tool id="com.crt.advproject.gas.lib.debug.1648479583" name="MCU Assembler" superClass="com.crt.advproject.gas.lib.debug">
<option id="com.crt.advproject.gas.thumb.1258454219" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gas.arch.158611278" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm3" valueType="enumerated"/>
<option id="gnu.both.asm.option.flags.crt.506823248" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -DDEBUG -D__CODE_RED -DCORE_M3 -D__USE_LPCOPEN -D__LPC15XX__ -D__NEWLIB__" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.both.asm.option.include.paths.875167394" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
</option>
<option id="com.crt.advproject.gas.hdrlib.925707249" name="Library headers" superClass="com.crt.advproject.gas.hdrlib" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gas.specs.1146689581" name="Specs" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.newlib" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.597071682" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<inputType id="com.crt.advproject.assembler.input.766418895" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
</tool>
<tool id="com.crt.advproject.ar.lib.debug.1486080615" name="MCU Archiver" superClass="com.crt.advproject.ar.lib.debug"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="com.crt.advproject.config.lib.release.1933882444">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.lib.release.1933882444" moduleId="org.eclipse.cdt.core.settings" name="Release">
<externalSettings>
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/StateHandler"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/StateHandler/Release"/>
<entry flags="RESOLVED" kind="libraryFile" name="StateHandler" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" 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"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactExtension="a" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.staticLib" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.staticLib" cleanCommand="rm -rf" description="Release build" errorParsers="org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="com.crt.advproject.config.lib.release.1933882444" name="Release" parent="com.crt.advproject.config.lib.release" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size &quot;lib${BuildArtifactFileName}&quot; ; # arm-none-eabi-objdump -h -S &quot;lib${BuildArtifactFileName}&quot; &gt;&quot;${BuildArtifactFileBaseName}.lss&quot;">
<folderInfo id="com.crt.advproject.config.lib.release.1933882444." name="/" resourcePath="">
<toolChain id="com.crt.advproject.toolchain.lib.release.1866760111" name="NXP MCU Tools" superClass="com.crt.advproject.toolchain.lib.release">
<targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.lib.release.527454700" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.lib.release"/>
<builder buildPath="${workspace_loc:/StateHandler}/Release" id="com.crt.advproject.builder.lib.release.456743579" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.release"/>
<tool id="com.crt.advproject.cpp.lib.release.220368493" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.release">
<option id="com.crt.advproject.cpp.thumb.286226772" name="Thumb mode" superClass="com.crt.advproject.cpp.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.cpp.specs.2239614" name="Specs" superClass="com.crt.advproject.cpp.specs" useByScannerDiscovery="false" value="com.crt.advproject.cpp.specs.newlib" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.arch.336981388" name="Architecture" superClass="com.crt.advproject.cpp.arch" useByScannerDiscovery="true" value="com.crt.advproject.cpp.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.preprocessor.def.886659035" name="Defined symbols (-D)" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="NDEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
</option>
<option id="gnu.cpp.compiler.option.other.other.768604422" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions" valueType="string"/>
<option id="gnu.cpp.compiler.option.optimization.flags.1512140371" name="Other optimization flags" superClass="gnu.cpp.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common -Os" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.2063647385" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
</option>
<option id="com.crt.advproject.cpp.misc.dialect.2103564035" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
<option id="com.crt.advproject.cpp.hdrlib.1905759872" name="Library headers" superClass="com.crt.advproject.cpp.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.cpp.input.1496631286" superClass="com.crt.advproject.compiler.cpp.input"/>
</tool>
<tool id="com.crt.advproject.gcc.lib.release.659623667" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.release">
<option id="com.crt.advproject.gcc.thumb.237867421" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gcc.arch.502269057" name="Architecture" superClass="com.crt.advproject.gcc.arch" useByScannerDiscovery="true" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.1403559709" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="NDEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__LPC15XX__"/>
<listOptionValue builtIn="false" value="__NEWLIB__"/>
</option>
<option id="gnu.c.compiler.option.misc.other.283882572" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="gnu.c.compiler.option.optimization.flags.1010923786" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.633333677" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
</option>
<option id="com.crt.advproject.c.misc.dialect.1578394517" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.hdrlib.339012185" name="Library headers" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.specs.1767225016" name="Specs" superClass="com.crt.advproject.gcc.specs" useByScannerDiscovery="false" value="com.crt.advproject.gcc.specs.newlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.948867805" superClass="com.crt.advproject.compiler.input"/>
</tool>
<tool id="com.crt.advproject.gas.lib.release.1133966547" name="MCU Assembler" superClass="com.crt.advproject.gas.lib.release">
<option id="com.crt.advproject.gas.thumb.2127857425" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/>
<option id="com.crt.advproject.gas.arch.1672468268" name="Architecture" superClass="com.crt.advproject.gas.arch" value="com.crt.advproject.gas.target.cm3" valueType="enumerated"/>
<option id="gnu.both.asm.option.flags.crt.1015763638" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -DNDEBUG -D__CODE_RED -DCORE_M3 -D__USE_LPCOPEN -D__LPC15XX__ -D__NEWLIB__" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.both.asm.option.include.paths.1647164058" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc://inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
</option>
<option id="com.crt.advproject.gas.hdrlib.1849085416" name="Library headers" superClass="com.crt.advproject.gas.hdrlib" value="Newlib" valueType="enumerated"/>
<option id="com.crt.advproject.gas.specs.451573115" name="Specs" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.newlib" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.230703659" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<inputType id="com.crt.advproject.assembler.input.693922250" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
</tool>
<tool id="com.crt.advproject.ar.lib.release.517248027" name="MCU Archiver" superClass="com.crt.advproject.ar.lib.release"/>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="StateHandler.com.crt.advproject.projecttype.lib.852909629" name="Static Library" projectType="com.crt.advproject.projecttype.lib"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="com.crt.config">
<projectStorage>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;TargetConfig&gt;
&lt;Properties property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="100300"/&gt;
&lt;infoList vendor="NXP"&gt;
&lt;info chip="LPC1549" connectscript="LPC15RunBootRomConnect.scp" flash_driver="LPC15xx_256K.cfx" match_id="0x0" name="LPC1549" resetscript="LPC15RunBootRomReset.scp" stub="crt_emu_cm3_gen"&gt;
&lt;chip&gt;
&lt;name&gt;LPC1549&lt;/name&gt;
&lt;family&gt;LPC15xx&lt;/family&gt;
&lt;vendor&gt;NXP (formerly Philips)&lt;/vendor&gt;
&lt;reset board="None" core="Real" sys="Real"/&gt;
&lt;clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/&gt;
&lt;memory can_program="true" id="Flash" is_ro="true" type="Flash"/&gt;
&lt;memory id="RAM" type="RAM"/&gt;
&lt;memory id="Periph" is_volatile="true" type="Peripheral"/&gt;
&lt;memoryInstance derived_from="Flash" id="MFlash256" location="0x0" size="0x40000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram0_16" location="0x2000000" size="0x4000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram1_16" location="0x2004000" size="0x4000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram2_4" location="0x2008000" size="0x1000"/&gt;
&lt;/chip&gt;
&lt;processor&gt;
&lt;name gcc_name="cortex-m3"&gt;Cortex-M3&lt;/name&gt;
&lt;family&gt;Cortex-M&lt;/family&gt;
&lt;/processor&gt;
&lt;/info&gt;
&lt;/infoList&gt;
&lt;/TargetConfig&gt;</projectStorage>
</storageModule>
<storageModule moduleId="com.crt.advproject">
<boardId>LPCXpresso1549</boardId>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>

30
StateHandler/.project Normal file
View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>StateHandler</name>
<comment></comment>
<projects>
<project>lpc_chip_15xx</project>
<project>DigitalIoPin</project>
<project>LiquidCrystal</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,78 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
-include ../makefile.init
RM := rm -rf
# All of the sources participating in the build are defined here
-include sources.mk
-include src/subdir.mk
-include subdir.mk
-include objects.mk
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
endif
-include ../makefile.defs
OPTIONAL_TOOL_DEPS := \
$(wildcard ../makefile.defs) \
$(wildcard ../makefile.init) \
$(wildcard ../makefile.targets) \
BUILD_ARTIFACT_NAME := StateHandler
BUILD_ARTIFACT_EXTENSION := a
BUILD_ARTIFACT_PREFIX := lib
BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),)
# Add inputs and outputs from these tool invocations to the build variables
# All Target
all:
+@$(MAKE) --no-print-directory main-build && $(MAKE) --no-print-directory post-build
# Main-build Target
main-build: libStateHandler.a
# Tool invocations
libStateHandler.a: $(OBJS) $(USER_OBJS) makefile objects.mk $(OPTIONAL_TOOL_DEPS)
@echo 'Building target: $@'
@echo 'Invoking: MCU Archiver'
arm-none-eabi-ar -r "libStateHandler.a" $(OBJS) $(USER_OBJS) $(LIBS)
@echo 'Finished building target: $@'
@echo ' '
# Other Targets
clean:
-$(RM) $(CC_DEPS)$(C++_DEPS)$(C_UPPER_DEPS)$(CXX_DEPS)$(OBJS)$(ARCHIVES)$(CPP_DEPS)$(C_DEPS) libStateHandler.a
-@echo ' '
post-build:
-@echo 'Performing post-build steps'
-arm-none-eabi-size "libStateHandler.a" ; # arm-none-eabi-objdump -h -S "libStateHandler.a" >"libStateHandler.lss"
-@echo ' '
.PHONY: all clean dependents post-build
-include ../makefile.targets

View File

@ -0,0 +1,8 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
USER_OBJS :=
LIBS :=

View File

@ -0,0 +1,28 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
C_UPPER_SRCS :=
CXX_SRCS :=
C++_SRCS :=
OBJ_SRCS :=
S_SRCS :=
CC_SRCS :=
ASM_SRCS :=
CPP_SRCS :=
C_SRCS :=
S_UPPER_SRCS :=
O_SRCS :=
CC_DEPS :=
C++_DEPS :=
C_UPPER_DEPS :=
CXX_DEPS :=
OBJS :=
ARCHIVES :=
CPP_DEPS :=
C_DEPS :=
# Every subdirectory with source files must be described here
SUBDIRS := \
src \

View File

@ -0,0 +1,5 @@
../src/Counter.cpp:12:6:void Counter::inc() 16 static
../src/Counter.cpp:20:6:void Counter::dec() 16 static
../src/Counter.cpp:29:5:int Counter::getInit() 16 static
../src/Counter.cpp:33:1:Counter::Counter(int, int) 24 static
../src/Counter.cpp:45:6:void Counter::setInit(int) 16 static

View File

@ -0,0 +1,10 @@
/home/tylen/Desktop/Programming/Projects_Metropolia/ESP-Ventilation/StateHandler/inc/Event.h:13:11:Event::~Event() 16 static
/home/tylen/Desktop/Programming/Projects_Metropolia/ESP-Ventilation/StateHandler/inc/Event.h:13:11:virtual Event::~Event() 16 static
/home/tylen/Desktop/Programming/Projects_Metropolia/ESP-Ventilation/StateHandler/inc/Event.h:26:3:Event::Event(Event::eventType, int, int) 24 static
../src/StateHandler.cpp:10:1:StateHandler::StateHandler() 16 static
../src/StateHandler.cpp:14:1:StateHandler::~StateHandler() 16 static
../src/StateHandler.cpp:14:1:virtual StateHandler::~StateHandler() 16 static
../src/StateHandler.cpp:18:14:unsigned int StateHandler::getSetPressure() 16 static
../src/StateHandler.cpp:22:14:unsigned int StateHandler::getSetSpeed() 16 static
../src/StateHandler.cpp:26:6:void StateHandler::HandleState(const Event&) 16 static
../src/StateHandler.cpp:30:6:void StateHandler::SetState(state_pointer) 64 static

View File

@ -0,0 +1,27 @@
################################################################################
# Automatically-generated file. Do not edit!
################################################################################
# Add inputs and outputs from these tool invocations to the build variables
CPP_SRCS += \
../src/Counter.cpp \
../src/StateHandler.cpp
OBJS += \
./src/Counter.o \
./src/StateHandler.o
CPP_DEPS += \
./src/Counter.d \
./src/StateHandler.d
# Each subdirectory must supply rules for building sources it contributes
src/%.o: ../src/%.cpp src/subdir.mk
@echo 'Building file: $<'
@echo 'Invoking: MCU C++ Compiler'
arm-none-eabi-c++ -DDEBUG -D__CODE_RED -D__NEWLIB__ -DCORE_M3 -D__USE_LPCOPEN -D__LPC15XX__ -I"/home/tylen/Desktop/Programming/Projects_Metropolia/ESP-Ventilation/StateHandler/inc" -I"/home/tylen/Desktop/Programming/Projects_Metropolia/ESP-Ventilation/lpc_board_nxp_lpcxpresso_1549/inc" -I"/home/tylen/Desktop/Programming/Projects_Metropolia/ESP-Ventilation/lpc_chip_15xx/inc" -I"/home/tylen/Desktop/Programming/Projects_Metropolia/ESP-Ventilation/DigitalIoPin/inc" -O0 -fno-common -g3 -Wall -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fmerge-constants -fmacro-prefix-map="$(<D)/"= -mcpu=cortex-m3 -mthumb -fstack-usage -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
@echo 'Finished building: $<'
@echo ' '

View File

@ -0,0 +1,26 @@
/*
* Counter.h
*
* Created on: Sep 1, 2022
* Author: tylen
*/
#ifndef COUNTER_H_
#define COUNTER_H_
class Counter {
public:
Counter(int i, int up);
void inc();
void dec();
int getCurrent();
void setInit(int i);
~Counter() = default;
private:
int init;
int up_lim;
};
#endif /* COUNTER_H_ */

View File

@ -8,13 +8,11 @@
#ifndef EVENT_H_
#define EVENT_H_
class Event
{
class Event {
public:
virtual ~Event(){};
enum eventType
{
enum eventType {
/** Start of the event */
eEnter,
/** End of the event*/
@ -25,9 +23,11 @@ public:
/** Time event */
eTick
};
Event (eventType e = eTick, int val = 0) : type (e), value (val){};
Event(eventType e = eTick, int b = 0, int t = 0)
: type(e), button(b), temp(t){};
eventType type;
int value;
int button;
int temp;
};
#endif /* EVENT_H_ */

View File

@ -0,0 +1,129 @@
/*
* StateHandler.h
*
* Created on: Sep 21, 2022
* Author: tylen
*
* Purpose of this class is to store and pass
* the events of the current mode to further process.
*
* Current goal is to make it to operate on interrupts
* caused by button presses.
*
*/
#ifndef STATE_HANDLER_H_
#define STATE_HANDLER_H_
#include "Counter.h"
#include "DigitalIoPin.h"
#include "Event.h"
#include "LiquidCrystal.h"
/** Buttons enumeration
*
* Current switch state is being passed
* from main to StateHandler through
* a keyEvent. Enumeration determines the state
* of the particular button.
* */
enum _buttons
{
/** Raises the bar up */
BUTTON_CONTROL_UP,
/** Raises the bar down */
BUTTON_CONTROL_DOWN,
/** Toggles the mode between auto and
* manual, which changes the state */
BUTTON_CONTROL_TOG_MODE,
/** Optional button to toggle the
* activation of the current setting.
* Not compulsory to be used. */
BUTTON_CONTROL_TOG_ACTIVE
};
enum _bars
{
/** 0-100 % */
FAN_SPEED,
/** 0-120 Pa */
PRESSURE
};
enum _mode
{
MANUAL,
AUTO
};
class StateHandler;
typedef void (StateHandler::*state_pointer) (const Event &);
class StateHandler
{
public:
StateHandler (LiquidCrystal *lcd);
virtual ~StateHandler ();
/** Get currently set pressure
*
* @return pressure in range of 0-120
*/
unsigned int getSetPressure ();
/** Get currently set FanSpeed
*
* @return speed in range of 0-100
*/
unsigned int getSetSpeed ();
/** Display values on LCD depending on current mode
*
* @param value1 value to be displayed on LCD line 0
* @param value2 value to be displayed on LCD line 1
*/
void displaySet (unsigned int value1, unsigned int value2);
/** Handle the given event of the current state
* @param event event to be handled in the current state
*/
void HandleState (const Event &event);
private:
state_pointer current;
/** Set a new curremt state
* @param newstate new state to be set to current
*/
void SetState (state_pointer newstate);
bool current_mode;
Counter value[2] = { { 0, 100 }, { 0, 120 } };
LiquidCrystal *_lcd;
/** Initialization state
*
* @param event event of the state
*/
void stateInit (const Event &event);
/** Manual state
*
* - set current speed
* - print current pressure
*
* @param event event of the state
*/
void stateManual (const Event &event);
/** Automated state
*
* - print current pressure
* - print set pressure
* - inc/dec fan speed
*
* @param event
*/
void stateAuto (const Event &event);
};
#endif /* STATE_HANDLER_H_ */

32
StateHandler/liblinks.xml Normal file
View File

@ -0,0 +1,32 @@
<!-- liblinks.xml
NXP LPCXpresso IDE "Smart update wizard" script file
When executed on a particular application project, will
add appropriate links to the specified library project.
Note that this script assumes that the application project
contains the standard 'Debug' and 'Release' build
configurations.
-->
<project name="" update="true">
<setting id="all.compiler.inc">
<value>${MacroStart}workspace_loc:/${ProjName}/inc${MacroEnd}</value>
</setting>
<setting id="assembler.inc">
<value>${MacroStart}workspace_loc:/${ProjName}/inc${MacroEnd}</value>
</setting>
<setting id="linker.libs">
<value>${ProjName}</value>
</setting>
<setting id="linker.paths" buildType="Debug">
<value>${MacroStart}workspace_loc:/${ProjName}/Debug${MacroEnd}</value>
</setting>
<setting id="linker.paths" buildType="Release">
<value>${MacroStart}workspace_loc:/${ProjName}/Release${MacroEnd}</value>
</setting>
<requires msg="Library project `${ProjName}` not found">
<value>${ProjName}</value>
</requires>
</project>

View File

@ -0,0 +1,45 @@
/*
* Counter.cpp
*
* Created on: Sep 1, 2022
* Author: tylen
*/
#include "Counter.h"
void Counter::inc() {
if(init >= up_lim){
init = 0;
} else{
++init;
}
}
void Counter::dec() {
if(init <= 0){
init = up_lim;
} else{
--init;
}
}
int Counter::getCurrent(){
return this->init;
}
Counter::Counter(int i, int up) {
up_lim = up;
if(i > up){
init = up;
}else if(i < 0){
init = 0;
}else{
init = i;
}
}
void Counter::setInit(int i){
init = i;
}

View File

@ -0,0 +1,111 @@
/*
* StateHandler.cpp
*
* Created on: Sep 21, 2022
* Author: tylen
*/
#include <StateHandler.h>
StateHandler::StateHandler (LiquidCrystal *lcd)
{
this->_lcd = lcd;
// TODO
}
StateHandler::~StateHandler ()
{
// TODO Auto-generated destructor stub
}
void
StateHandler::displaySet (unsigned int value1, unsigned int value2)
{
// TODO
/**
* MANUAL MODE:
* ----------------
* SPEED: 20%
* PRESSURE: XXPa
* ----------------
* AUTO MODE:
* ----------------
* PRESSURE SET: 35Pa
* PRESSURE CUR: XXPa
* ----------------
*/
}
unsigned int
StateHandler::getSetPressure ()
{
return (unsigned int)this->value[PRESSURE].getCurrent ();
}
unsigned int
StateHandler::getSetSpeed ()
{
return (unsigned int)this->value[FAN_SPEED].getCurrent ();
}
void
StateHandler::HandleState (const Event &event)
{
(this->*current) (event);
}
void
StateHandler::SetState (state_pointer newstate)
{
(this->*current) (Event (Event::eExit));
current = newstate;
(this->*current) (Event (Event::eEnter));
}
void
stateInit (const Event &event)
{
switch (event.type)
{
case Event::eEnter:
break;
case Event::eExit:
break;
case Event::eKey:
break;
case Event::eTick:
break;
}
}
void
stateManual (const Event &event)
{
switch (event.type)
{
case Event::eEnter:
break;
case Event::eExit:
break;
case Event::eKey:
break;
case Event::eTick:
break;
}
}
void
stateAuto (const Event &event)
{
switch (event.type)
{
case Event::eEnter:
break;
case Event::eExit:
break;
case Event::eKey:
break;
case Event::eTick:
break;
}
}

View File

@ -39,11 +39,11 @@
<option id="com.crt.advproject.cpp.fpu.411859745" name="Floating point" superClass="com.crt.advproject.cpp.fpu" useByScannerDiscovery="true"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.733606498" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc/Modbus}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/I2C/inc}&quot;"/>
</option>
<option id="com.crt.advproject.cpp.misc.dialect.1893636131" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.cpp.input.1024506123" superClass="com.crt.advproject.compiler.cpp.input"/>
@ -66,9 +66,11 @@
<option id="gnu.c.compiler.option.optimization.flags.13512348" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.688644944" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/esp-vent-main}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/I2C/inc}&quot;"/>
</option>
<option id="com.crt.advproject.c.misc.dialect.1885316467" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.1491212950" superClass="com.crt.advproject.compiler.input"/>
@ -86,23 +88,18 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/I2C/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/StateHandler/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Timer/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/SwitchController/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PressureWrapper/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/SDP600Sensor/inc}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.486566022" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<inputType id="com.crt.advproject.assembler.input.255980151" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
</tool>
<tool id="com.crt.advproject.link.cpp.exe.debug.1426626994" name="MCU C++ Linker" superClass="com.crt.advproject.link.cpp.exe.debug">
<option id="com.crt.advproject.link.cpp.thumb.1194209702" name="Thumb mode" superClass="com.crt.advproject.link.cpp.thumb" value="true" valueType="boolean"/>
<option id="com.crt.advproject.link.memory.load.image.cpp.1000848894" name="Plain load image" superClass="com.crt.advproject.link.memory.load.image.cpp" useByScannerDiscovery="false" value="" valueType="string"/>
<option defaultValue="com.crt.advproject.heapAndStack.lpcXpressoStyle.cpp" id="com.crt.advproject.link.memory.heapAndStack.style.cpp.981260644" name="Heap and Stack placement" superClass="com.crt.advproject.link.memory.heapAndStack.style.cpp" useByScannerDiscovery="false" valueType="enumerated"/>
<option id="com.crt.advproject.link.memory.load.image.cpp.1000848894" name="Plain load image" superClass="com.crt.advproject.link.memory.load.image.cpp" value="" valueType="string"/>
<option defaultValue="com.crt.advproject.heapAndStack.lpcXpressoStyle.cpp" id="com.crt.advproject.link.memory.heapAndStack.style.cpp.981260644" name="Heap and Stack placement" superClass="com.crt.advproject.link.memory.heapAndStack.style.cpp" valueType="enumerated"/>
<option id="com.crt.advproject.link.memory.heapAndStack.cpp.547910715" name="Heap and Stack options" superClass="com.crt.advproject.link.memory.heapAndStack.cpp" value="&amp;Heap:Default;Post Data;Default&amp;Stack:Default;End;Default" valueType="string"/>
<option id="com.crt.advproject.link.memory.data.cpp.479381724" name="Global data placement" superClass="com.crt.advproject.link.memory.data.cpp" useByScannerDiscovery="false" value="" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.crt.advproject.link.memory.sections.cpp.1578166592" name="Extra linker script input sections" superClass="com.crt.advproject.link.memory.sections.cpp" useByScannerDiscovery="false" valueType="stringList"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.crt.advproject.link.cpp.multicore.master.userobjs.10592627" name="Slave Objects (not visible)" superClass="com.crt.advproject.link.cpp.multicore.master.userobjs" useByScannerDiscovery="false" valueType="userObjs"/>
<option id="com.crt.advproject.link.memory.data.cpp.479381724" name="Global data placement" superClass="com.crt.advproject.link.memory.data.cpp" value="" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.crt.advproject.link.memory.sections.cpp.1578166592" name="Extra linker script input sections" superClass="com.crt.advproject.link.memory.sections.cpp" valueType="stringList"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.crt.advproject.link.cpp.multicore.master.userobjs.10592627" name="Slave Objects (not visible)" superClass="com.crt.advproject.link.cpp.multicore.master.userobjs" valueType="userObjs"/>
<option id="com.crt.advproject.link.cpp.multicore.slave.2071357873" name="Multicore configuration" superClass="com.crt.advproject.link.cpp.multicore.slave"/>
<option id="com.crt.advproject.link.cpp.arch.1780684898" name="Architecture" superClass="com.crt.advproject.link.cpp.arch" value="com.crt.advproject.link.cpp.target.cm3" valueType="enumerated"/>
<option id="com.crt.advproject.link.cpp.script.853146968" name="Linker script" superClass="com.crt.advproject.link.cpp.script" value="&quot;esp-vent-main_Debug.ld&quot;" valueType="string"/>
@ -118,10 +115,16 @@
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.link.option.libs.1364210590" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="lpc_board_nxp_lpcxpresso_1549"/>
<listOptionValue builtIn="false" value="lpc_chip_15xx"/>
<listOptionValue builtIn="false" value="DigitalIoPin"/>
<listOptionValue builtIn="false" value="LiquidCrystal"/>
<listOptionValue builtIn="false" value="I2C"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.link.option.paths.804461696" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/Debug}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/Debug}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/Debug}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/Debug}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/I2C/Debug}&quot;"/>
</option>
<option id="com.crt.advproject.link.cpp.crpenable.8641361" name="Enable automatic placement of Code Read Protection field in image" superClass="com.crt.advproject.link.cpp.crpenable"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.849613399" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
@ -136,6 +139,7 @@
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
@ -184,11 +188,6 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/I2C/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/StateHandler/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Timer/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/SwitchController/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PressureWrapper/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/SDP600Sensor/inc}&quot;"/>
</option>
<option id="com.crt.advproject.cpp.misc.dialect.1640449237" name="Language standard" superClass="com.crt.advproject.cpp.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.cpp.input.812988440" superClass="com.crt.advproject.compiler.cpp.input"/>
@ -216,11 +215,6 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/I2C/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/StateHandler/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Timer/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/SwitchController/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PressureWrapper/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/SDP600Sensor/inc}&quot;"/>
</option>
<option id="com.crt.advproject.c.misc.dialect.1383624929" name="Language standard" superClass="com.crt.advproject.c.misc.dialect" useByScannerDiscovery="true" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.391538574" superClass="com.crt.advproject.compiler.input"/>
@ -238,11 +232,6 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/I2C/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/StateHandler/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Timer/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/SwitchController/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PressureWrapper/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/SDP600Sensor/inc}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1169670567" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
<inputType id="com.crt.advproject.assembler.input.956763731" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
@ -273,11 +262,6 @@
<listOptionValue builtIn="false" value="DigitalIoPin"/>
<listOptionValue builtIn="false" value="LiquidCrystal"/>
<listOptionValue builtIn="false" value="I2C"/>
<listOptionValue builtIn="false" value="StateHandler"/>
<listOptionValue builtIn="false" value="Timer"/>
<listOptionValue builtIn="false" value="SwitchController"/>
<listOptionValue builtIn="false" value="PressureWrapper"/>
<listOptionValue builtIn="false" value="SDP600Sensor"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.link.option.paths.245096214" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/Release}&quot;"/>
@ -285,11 +269,6 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/DigitalIoPin/Release}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/LiquidCrystal/Release}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/I2C/Release}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/StateHandler/Release}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/Timer/Release}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/SwitchController/Release}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PressureWrapper/Release}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/SDP600Sensor/Release}&quot;"/>
</option>
<option id="com.crt.advproject.link.cpp.crpenable.209534913" name="Enable automatic placement of Code Read Protection field in image" superClass="com.crt.advproject.link.cpp.crpenable"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1513506142" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
@ -302,6 +281,7 @@
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="inc"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
</sourceEntries>
</configuration>
@ -317,31 +297,31 @@
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="com.crt.config">
<projectStorage>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&#13;
&lt;TargetConfig&gt;&#13;
&lt;Properties property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="100300"/&gt;&#13;
&lt;infoList vendor="NXP"&gt;&#13;
&lt;info chip="LPC1549" connectscript="LPC15RunBootRomConnect.scp" flash_driver="LPC15xx_256K.cfx" match_id="0x0" name="LPC1549" resetscript="LPC15RunBootRomReset.scp" stub="crt_emu_cm3_gen"&gt;&#13;
&lt;chip&gt;&#13;
&lt;name&gt;LPC1549&lt;/name&gt;&#13;
&lt;family&gt;LPC15xx&lt;/family&gt;&#13;
&lt;vendor&gt;NXP (formerly Philips)&lt;/vendor&gt;&#13;
&lt;reset board="None" core="Real" sys="Real"/&gt;&#13;
&lt;clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/&gt;&#13;
&lt;memory can_program="true" id="Flash" is_ro="true" type="Flash"/&gt;&#13;
&lt;memory id="RAM" type="RAM"/&gt;&#13;
&lt;memory id="Periph" is_volatile="true" type="Peripheral"/&gt;&#13;
&lt;memoryInstance derived_from="Flash" id="MFlash256" location="0x0" size="0x40000"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" id="Ram0_16" location="0x2000000" size="0x4000"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" id="Ram1_16" location="0x2004000" size="0x4000"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" id="Ram2_4" location="0x2008000" size="0x1000"/&gt;&#13;
&lt;/chip&gt;&#13;
&lt;processor&gt;&#13;
&lt;name gcc_name="cortex-m3"&gt;Cortex-M3&lt;/name&gt;&#13;
&lt;family&gt;Cortex-M&lt;/family&gt;&#13;
&lt;/processor&gt;&#13;
&lt;/info&gt;&#13;
&lt;/infoList&gt;&#13;
<projectStorage>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;TargetConfig&gt;
&lt;Properties property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="100300"/&gt;
&lt;infoList vendor="NXP"&gt;
&lt;info chip="LPC1549" connectscript="LPC15RunBootRomConnect.scp" flash_driver="LPC15xx_256K.cfx" match_id="0x0" name="LPC1549" resetscript="LPC15RunBootRomReset.scp" stub="crt_emu_cm3_gen"&gt;
&lt;chip&gt;
&lt;name&gt;LPC1549&lt;/name&gt;
&lt;family&gt;LPC15xx&lt;/family&gt;
&lt;vendor&gt;NXP (formerly Philips)&lt;/vendor&gt;
&lt;reset board="None" core="Real" sys="Real"/&gt;
&lt;clock changeable="TRUE" freq="12MHz" is_accurate="TRUE"/&gt;
&lt;memory can_program="true" id="Flash" is_ro="true" type="Flash"/&gt;
&lt;memory id="RAM" type="RAM"/&gt;
&lt;memory id="Periph" is_volatile="true" type="Peripheral"/&gt;
&lt;memoryInstance derived_from="Flash" id="MFlash256" location="0x0" size="0x40000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram0_16" location="0x2000000" size="0x4000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram1_16" location="0x2004000" size="0x4000"/&gt;
&lt;memoryInstance derived_from="RAM" id="Ram2_4" location="0x2008000" size="0x1000"/&gt;
&lt;/chip&gt;
&lt;processor&gt;
&lt;name gcc_name="cortex-m3"&gt;Cortex-M3&lt;/name&gt;
&lt;family&gt;Cortex-M&lt;/family&gt;
&lt;/processor&gt;
&lt;/info&gt;
&lt;/infoList&gt;
&lt;/TargetConfig&gt;</projectStorage>
</storageModule>
<storageModule moduleId="com.crt.advproject">

View File

@ -8,11 +8,6 @@
<project>DigitalIoPin</project>
<project>LiquidCrystal</project>
<project>I2C</project>
<project>StateHandler</project>
<project>Timer</project>
<project>SwitchController</project>
<project>PressureWrapper</project>
<project>SDP600Sensor</project>
</projects>
<buildSpec>
<buildCommand>

View File

@ -4,7 +4,7 @@
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="com.crt.advproject.GCCBuildCommandParser" keep-relative-paths="false" name="MCU GCC Build Output Parser" parameter="(arm-none-eabi-gcc)|(arm-none-eabi-[gc]\+\+)|(gcc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="315355967405909607" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="1877366442593287523" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -15,7 +15,7 @@
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider copy-of="extension" id="com.crt.advproject.GCCBuildCommandParser"/>
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="361783029533003079" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="1932457957984350467" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

View File

@ -1,96 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.crt.dsfdebug.crtmcu.launchType">
<stringAttribute key=".gdbinit" value=""/>
<booleanAttribute key="attach" value="false"/>
<stringAttribute key="bootrom.stall" value=""/>
<stringAttribute key="com.crt.ctrlcenter.OFSemuDetails" value="LinkServer"/>
<booleanAttribute key="com.crt.ctrlcenter.crtInit" value="true"/>
<stringAttribute key="com.crt.ctrlcenter.currentWireType" value="SWD"/>
<booleanAttribute key="com.crt.ctrlcenter.mainBreakIsHardware" value="true"/>
<stringAttribute key="com.crt.ctrlcenter.serialNumber" value="LinkServerNXP SemiconductorsLPC-LINK2 CMSIS-DAP V5.361OSAVCQOQ"/>
<mapAttribute key="com.crt.ctrlcenter.symbolsGroupSettings"/>
<intAttribute key="com.crt.ctrlcenter.version" value="6"/>
<stringAttribute key="com.nxp.mcuxpresso.flash.base.address" value="0x0"/>
<booleanAttribute key="com.nxp.mcuxpresso.flash.clear.console" value="true"/>
<booleanAttribute key="com.nxp.mcuxpresso.flash.confirm" value="false"/>
<stringAttribute key="com.nxp.mcuxpresso.flash.erase.algorithm" value="Mass erase"/>
<stringAttribute key="com.nxp.mcuxpresso.flash.executable" value="axf"/>
<stringAttribute key="com.nxp.mcuxpresso.flash.program.action" value="Program"/>
<booleanAttribute key="com.nxp.mcuxpresso.flash.reset.target" value="true"/>
<stringAttribute key="com.nxp.mcuxpresso.ide.probe.manufacturer" value="NXP Semiconductors"/>
<stringAttribute key="com.nxp.mcuxpresso.ide.probe.name" value="LPC-LINK2 CMSIS-DAP V5.361"/>
<stringAttribute key="com.nxp.mcuxpresso.ide.probe.type" value="LinkServer"/>
<stringAttribute key="debug.level" value="2"/>
<stringAttribute key="emu.speed" value=""/>
<stringAttribute key="flash.driver.reset" value=""/>
<stringAttribute key="gdbserver.host" value="localhost"/>
<stringAttribute key="gdbserver.port" value="10989"/>
<booleanAttribute key="gdbserver.start" value="true"/>
<stringAttribute key="internal.connect.script" value="LPC15RunBootRomConnect.scp"/>
<booleanAttribute key="internal.has_swo" value="true"/>
<stringAttribute key="internal.prelaunch.command" value=""/>
<stringAttribute key="internal.reset.script" value="LPC15RunBootRomReset.scp"/>
<stringAttribute key="internal.resethandling" value=""/>
<stringAttribute key="internal.semihost" value="On"/>
<stringAttribute key="internal.wirespeed" value=""/>
<stringAttribute key="internal.wiretype" value="SWD*"/>
<stringAttribute key="launch.config.handler" value="com.crt.ctrlcenter.launch.CRTLaunchConfigHandler"/>
<booleanAttribute key="mem.access" value="false"/>
<stringAttribute key="misc.options" value=""/>
<stringAttribute key="ondisconnect" value="cont"/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.delay" value="0"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="set non-stop on&#10;set pagination off&#10;set mi-async&#10;&#10;set remotetimeout 60000&#10;##target_extended_remote##&#10;set mem inaccessible-by-default ${mem.access}&#10;mon ondisconnect ${ondisconnect}&#10;set arm force-mode thumb&#10;${load}&#10;&#9;"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="10989"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value="&#10;${run}&#10;&#9;"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_ON_FORK" value="false"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.EXTERNAL_CONSOLE" value="false"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.GDB_INIT" value=""/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="true"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.REVERSE" value="false"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.REVERSE_MODE" value="UseSoftTrace"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.TRACEPOINT_MODE" value="TP_NORMAL_ONLY"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="gdb"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/esp-vent-main.axf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="esp-vent-main"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="com.crt.advproject.config.exe.debug.1850577128"/>
<booleanAttribute key="org.eclipse.cdt.launch.use_terminal" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/esp-vent-main"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[debug]" value="com.nxp.mcuxpresso.core.debug.support.linkserver.launch.LinkServerGdbLaunch"/>
</mapAttribute>
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;"/>
<stringAttribute key="process_factory_id" value="com.nxp.mcuxpresso.core.debug.override.MCXProcessFactory"/>
<booleanAttribute key="redlink.disable.preconnect.script" value="false"/>
<booleanAttribute key="redlink.enable.flashhashing" value="true"/>
<booleanAttribute key="redlink.enable.rangestepping" value="true"/>
<stringAttribute key="run" value="cont"/>
<booleanAttribute key="vector.catch" value="true"/>
</launchConfiguration>

View File

@ -1,25 +0,0 @@
/*
* Fan.h
*
* Created on: Oct 26, 2022
* Author: tylen
*/
#ifndef FAN_H_
#define FAN_H_
#include "Modbus/ModbusRegister.h"
#include <assert.h>
class Fan
{
public:
Fan (ModbusRegister *A01);
virtual ~Fan ();
void spin (int speed);
private:
ModbusRegister *_A01;
};
#endif /* FAN_H_ */

View File

@ -1,27 +0,0 @@
/*
* GMP252.h
*
* Created on: 20 Oct 2022
* Author: evgenymeshcheryakov
*/
#ifndef GMP252_H_
#define GMP252_H_
#include "Modbus/ModbusMaster.h"
#include "Modbus/ModbusRegister.h"
class GMP252
{
public:
GMP252 ();
int read ();
virtual ~GMP252 ();
private:
ModbusMaster sens;
ModbusRegister regInt;
ModbusRegister regFloat;
};
#endif /* GMP252_H_ */

View File

@ -1,29 +0,0 @@
/*
* HMP60.h
*
* Created on: 20 Oct 2022
* Author: evgenymeshcheryakov
*/
#ifndef HMP60_H_
#define HMP60_H_
#include "Modbus/ModbusMaster.h"
#include "Modbus/ModbusRegister.h"
class HMP60
{
public:
HMP60 ();
int readRH ();
int readT ();
virtual ~HMP60 ();
private:
ModbusMaster sens;
ModbusRegister regRHint;
ModbusRegister regRHfloat;
ModbusRegister regTint;
};
#endif /* HMP60_H_ */

View File

@ -1,148 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014, 2017 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
* Ian Craggs - add connack return code definitions
* Xiang Rong - 442039 Add makefile to Embedded C client
* Ian Craggs - fix for issue #64, bit order in connack response
*******************************************************************************/
#ifndef MQTTCONNECT_H_
#define MQTTCONNECT_H_
enum connack_return_codes
{
MQTT_CONNECTION_ACCEPTED = 0,
MQTT_UNNACCEPTABLE_PROTOCOL = 1,
MQTT_CLIENTID_REJECTED = 2,
MQTT_SERVER_UNAVAILABLE = 3,
MQTT_BAD_USERNAME_OR_PASSWORD = 4,
MQTT_NOT_AUTHORIZED = 5,
};
#if !defined(DLLImport)
#define DLLImport
#endif
#if !defined(DLLExport)
#define DLLExport
#endif
typedef union
{
unsigned char all; /**< all connect flags */
#if defined(REVERSED)
struct
{
unsigned int username : 1; /**< 3.1 user name */
unsigned int password : 1; /**< 3.1 password */
unsigned int willRetain : 1; /**< will retain setting */
unsigned int willQoS : 2; /**< will QoS value */
unsigned int will : 1; /**< will flag */
unsigned int cleansession : 1; /**< clean session flag */
unsigned int : 1; /**< unused */
} bits;
#else
struct
{
unsigned int : 1; /**< unused */
unsigned int cleansession : 1; /**< cleansession flag */
unsigned int will : 1; /**< will flag */
unsigned int willQoS : 2; /**< will QoS value */
unsigned int willRetain : 1; /**< will retain setting */
unsigned int password : 1; /**< 3.1 password */
unsigned int username : 1; /**< 3.1 user name */
} bits;
#endif
} MQTTConnectFlags; /**< connect flags byte */
/**
* Defines the MQTT "Last Will and Testament" (LWT) settings for
* the connect packet.
*/
typedef struct
{
/** The eyecatcher for this structure. must be MQTW. */
char struct_id[4];
/** The version number of this structure. Must be 0 */
int struct_version;
/** The LWT topic to which the LWT message will be published. */
MQTTString topicName;
/** The LWT payload. */
MQTTString message;
/**
* The retained flag for the LWT message (see MQTTAsync_message.retained).
*/
unsigned char retained;
/**
* The quality of service setting for the LWT message (see
* MQTTAsync_message.qos and @ref qos).
*/
char qos;
} MQTTPacket_willOptions;
#define MQTTPacket_willOptions_initializer { {'M', 'Q', 'T', 'W'}, 0, {NULL, {0, NULL}}, {NULL, {0, NULL}}, 0, 0 }
typedef struct
{
/** The eyecatcher for this structure. must be MQTC. */
char struct_id[4];
/** The version number of this structure. Must be 0 */
int struct_version;
/** Version of MQTT to be used. 3 = 3.1 4 = 3.1.1
*/
unsigned char MQTTVersion;
MQTTString clientID;
unsigned short keepAliveInterval;
unsigned char cleansession;
unsigned char willFlag;
MQTTPacket_willOptions will;
MQTTString username;
MQTTString password;
} MQTTPacket_connectData;
typedef union
{
unsigned char all; /**< all connack flags */
#if defined(REVERSED)
struct
{
unsigned int reserved : 7; /**< unused */
unsigned int sessionpresent : 1; /**< session present flag */
} bits;
#else
struct
{
unsigned int sessionpresent : 1; /**< session present flag */
unsigned int reserved: 7; /**< unused */
} bits;
#endif
} MQTTConnackFlags; /**< connack flags byte */
#define MQTTPacket_connectData_initializer { {'M', 'Q', 'T', 'C'}, 0, 4, {NULL, {0, NULL}}, 60, 1, 0, \
MQTTPacket_willOptions_initializer, {NULL, {0, NULL}}, {NULL, {0, NULL}} }
DLLExport int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options);
DLLExport int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len);
DLLExport int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent);
DLLExport int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen);
DLLExport int MQTTSerialize_disconnect(unsigned char* buf, int buflen);
DLLExport int MQTTSerialize_pingreq(unsigned char* buf, int buflen);
#endif /* MQTTCONNECT_H_ */

View File

@ -1,37 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
*******************************************************************************/
#if !defined(MQTTFORMAT_H)
#define MQTTFORMAT_H
#include "StackTrace.h"
#include "MQTTPacket.h"
const char* MQTTPacket_getName(unsigned short packetid);
int MQTTStringFormat_connect(char* strbuf, int strbuflen, MQTTPacket_connectData* data);
int MQTTStringFormat_connack(char* strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent);
int MQTTStringFormat_publish(char* strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained,
unsigned short packetid, MQTTString topicName, unsigned char* payload, int payloadlen);
int MQTTStringFormat_ack(char* strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid);
int MQTTStringFormat_subscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count,
MQTTString topicFilters[], int requestedQoSs[]);
int MQTTStringFormat_suback(char* strbuf, int strbuflen, unsigned short packetid, int count, int* grantedQoSs);
int MQTTStringFormat_unsubscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid,
int count, MQTTString topicFilters[]);
char* MQTTFormat_toClientString(char* strbuf, int strbuflen, unsigned char* buf, int buflen);
char* MQTTFormat_toServerString(char* strbuf, int strbuflen, unsigned char* buf, int buflen);
#endif

View File

@ -1,133 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
* Xiang Rong - 442039 Add makefile to Embedded C client
*******************************************************************************/
#ifndef MQTTPACKET_H_
#define MQTTPACKET_H_
#if defined(__cplusplus) /* If this is a C++ compiler, use C linkage */
extern "C" {
#endif
#if defined(WIN32_DLL) || defined(WIN64_DLL)
#define DLLImport __declspec(dllimport)
#define DLLExport __declspec(dllexport)
#elif defined(LINUX_SO)
#define DLLImport extern
#define DLLExport __attribute__ ((visibility ("default")))
#else
#define DLLImport
#define DLLExport
#endif
enum errors
{
MQTTPACKET_BUFFER_TOO_SHORT = -2,
MQTTPACKET_READ_ERROR = -1,
MQTTPACKET_READ_COMPLETE
};
enum msgTypes
{
CONNECT = 1, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL,
PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK,
PINGREQ, PINGRESP, DISCONNECT
};
/**
* Bitfields for the MQTT header byte.
*/
typedef union
{
unsigned char byte; /**< the whole byte */
#if defined(REVERSED)
struct
{
unsigned int type : 4; /**< message type nibble */
unsigned int dup : 1; /**< DUP flag bit */
unsigned int qos : 2; /**< QoS value, 0, 1 or 2 */
unsigned int retain : 1; /**< retained flag bit */
} bits;
#else
struct
{
unsigned int retain : 1; /**< retained flag bit */
unsigned int qos : 2; /**< QoS value, 0, 1 or 2 */
unsigned int dup : 1; /**< DUP flag bit */
unsigned int type : 4; /**< message type nibble */
} bits;
#endif
} MQTTHeader;
typedef struct
{
int len;
char* data;
} MQTTLenString;
typedef struct
{
char* cstring;
MQTTLenString lenstring;
} MQTTString;
#define MQTTString_initializer {NULL, {0, NULL}}
int MQTTstrlen(MQTTString mqttstring);
#include "MQTTConnect.h"
#include "MQTTPublish.h"
#include "MQTTSubscribe.h"
#include "MQTTUnsubscribe.h"
#include "../inc/MQTT/MQTTFormat.h"
DLLExport int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char type, unsigned char dup, unsigned short packetid);
DLLExport int MQTTDeserialize_ack(unsigned char* packettype, unsigned char* dup, unsigned short* packetid, unsigned char* buf, int buflen);
int MQTTPacket_len(int rem_len);
DLLExport int MQTTPacket_equals(MQTTString* a, char* b);
DLLExport int MQTTPacket_encode(unsigned char* buf, int length);
int MQTTPacket_decode(int (*getcharfn)(unsigned char*, int), int* value);
int MQTTPacket_decodeBuf(unsigned char* buf, int* value);
int readInt(unsigned char** pptr);
char readChar(unsigned char** pptr);
void writeChar(unsigned char** pptr, char c);
void writeInt(unsigned char** pptr, int anInt);
int readMQTTLenString(MQTTString* mqttstring, unsigned char** pptr, unsigned char* enddata);
void writeCString(unsigned char** pptr, const char* string);
void writeMQTTString(unsigned char** pptr, MQTTString mqttstring);
DLLExport int MQTTPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int));
typedef struct {
int (*getfn)(void *, unsigned char*, int); /* must return -1 for error, 0 for call again, or the number of bytes read */
void *sck; /* pointer to whatever the system may use to identify the transport */
int multiplier;
int rem_len;
int len;
char state;
}MQTTTransport;
int MQTTPacket_readnb(unsigned char* buf, int buflen, MQTTTransport *trp);
#ifdef __cplusplus /* If this is a C++ compiler, use C linkage */
}
#endif
#endif /* MQTTPACKET_H_ */

View File

@ -1,38 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
* Xiang Rong - 442039 Add makefile to Embedded C client
*******************************************************************************/
#ifndef MQTTPUBLISH_H_
#define MQTTPUBLISH_H_
#if !defined(DLLImport)
#define DLLImport
#endif
#if !defined(DLLExport)
#define DLLExport
#endif
DLLExport int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid,
MQTTString topicName, unsigned char* payload, int payloadlen);
DLLExport int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName,
unsigned char** payload, int* payloadlen, unsigned char* buf, int len);
DLLExport int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid);
DLLExport int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid);
DLLExport int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid);
#endif /* MQTTPUBLISH_H_ */

View File

@ -1,39 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
* Xiang Rong - 442039 Add makefile to Embedded C client
*******************************************************************************/
#ifndef MQTTSUBSCRIBE_H_
#define MQTTSUBSCRIBE_H_
#if !defined(DLLImport)
#define DLLImport
#endif
#if !defined(DLLExport)
#define DLLExport
#endif
DLLExport int MQTTSerialize_subscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,
int count, MQTTString topicFilters[], int requestedQoSs[]);
DLLExport int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid,
int maxcount, int* count, MQTTString topicFilters[], int requestedQoSs[], unsigned char* buf, int len);
DLLExport int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs);
DLLExport int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int len);
#endif /* MQTTSUBSCRIBE_H_ */

View File

@ -1,38 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
* Xiang Rong - 442039 Add makefile to Embedded C client
*******************************************************************************/
#ifndef MQTTUNSUBSCRIBE_H_
#define MQTTUNSUBSCRIBE_H_
#if !defined(DLLImport)
#define DLLImport
#endif
#if !defined(DLLExport)
#define DLLExport
#endif
DLLExport int MQTTSerialize_unsubscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,
int count, MQTTString topicFilters[]);
DLLExport int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int max_count, int* count, MQTTString topicFilters[],
unsigned char* buf, int len);
DLLExport int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid);
DLLExport int MQTTDeserialize_unsuback(unsigned short* packetid, unsigned char* buf, int len);
#endif /* MQTTUNSUBSCRIBE_H_ */

View File

@ -1,66 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Allan Stockdill-Mander - initial API and implementation and/or initial documentation
*******************************************************************************/
#if !defined(MQTT_lpc1549_H)
#define MQTT_lpc1549_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct Timer
{
uint32_t TicksToWait;
uint32_t Start;
} Timer;
typedef struct Network Network;
struct Network
{
int my_socket;
int (*mqttread) (Network*, unsigned char*, int, int);
int (*mqttwrite) (Network*, unsigned char*, int, int);
void (*disconnect) (Network*);
char ssid[32];
char password[32];
};
void TimerInit(Timer*);
char TimerIsExpired(Timer*);
void TimerCountdownMS(Timer*, unsigned int);
void TimerCountdown(Timer*, unsigned int);
int TimerLeftMS(Timer*);
int lpc1549_read(Network*, unsigned char*, int, int);
int lpc1549_write(Network*, unsigned char*, int, int);
void lpc1549_disconnect(Network*);
void NetworkInit(Network *n, const char *ssid, const char *password);
int NetworkConnect(Network *n, char *address, int port);
void NetworkDisconnect(Network *n);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,78 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
* Ian Craggs - fix for bug #434081
*******************************************************************************/
#ifndef STACKTRACE_H_
#define STACKTRACE_H_
#include <stdio.h>
#define NOSTACKTRACE 1
#if defined(NOSTACKTRACE)
#define FUNC_ENTRY
#define FUNC_ENTRY_NOLOG
#define FUNC_ENTRY_MED
#define FUNC_ENTRY_MAX
#define FUNC_EXIT
#define FUNC_EXIT_NOLOG
#define FUNC_EXIT_MED
#define FUNC_EXIT_MAX
#define FUNC_EXIT_RC(x)
#define FUNC_EXIT_MED_RC(x)
#define FUNC_EXIT_MAX_RC(x)
#else
#if defined(WIN32)
#define inline __inline
#define FUNC_ENTRY StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MINIMUM)
#define FUNC_ENTRY_NOLOG StackTrace_entry(__FUNCTION__, __LINE__, -1)
#define FUNC_ENTRY_MED StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MEDIUM)
#define FUNC_ENTRY_MAX StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MAXIMUM)
#define FUNC_EXIT StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MINIMUM)
#define FUNC_EXIT_NOLOG StackTrace_exit(__FUNCTION__, __LINE__, -1)
#define FUNC_EXIT_MED StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MEDIUM)
#define FUNC_EXIT_MAX StackTrace_exit(__FUNCTION__, __LINE__, NULL, TRACE_MAXIMUM)
#define FUNC_EXIT_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MINIMUM)
#define FUNC_EXIT_MED_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MEDIUM)
#define FUNC_EXIT_MAX_RC(x) StackTrace_exit(__FUNCTION__, __LINE__, &x, TRACE_MAXIMUM)
#else
#define FUNC_ENTRY StackTrace_entry(__func__, __LINE__, TRACE_MINIMUM)
#define FUNC_ENTRY_NOLOG StackTrace_entry(__func__, __LINE__, -1)
#define FUNC_ENTRY_MED StackTrace_entry(__func__, __LINE__, TRACE_MEDIUM)
#define FUNC_ENTRY_MAX StackTrace_entry(__func__, __LINE__, TRACE_MAXIMUM)
#define FUNC_EXIT StackTrace_exit(__func__, __LINE__, NULL, TRACE_MINIMUM)
#define FUNC_EXIT_NOLOG StackTrace_exit(__func__, __LINE__, NULL, -1)
#define FUNC_EXIT_MED StackTrace_exit(__func__, __LINE__, NULL, TRACE_MEDIUM)
#define FUNC_EXIT_MAX StackTrace_exit(__func__, __LINE__, NULL, TRACE_MAXIMUM)
#define FUNC_EXIT_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MINIMUM)
#define FUNC_EXIT_MED_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MEDIUM)
#define FUNC_EXIT_MAX_RC(x) StackTrace_exit(__func__, __LINE__, &x, TRACE_MAXIMUM)
void StackTrace_entry(const char* name, int line, int trace);
void StackTrace_exit(const char* name, int line, void* return_value, int trace);
void StackTrace_printStack(FILE* dest);
char* StackTrace_get(unsigned long);
#endif
#endif
#endif /* STACKTRACE_H_ */

View File

@ -1,20 +0,0 @@
#ifndef ESP8266_H_
#define ESP8266_H_
#ifdef __cplusplus
extern "C" {
#endif
int esp_socket(const char *ssid, const char *password) ;
int esp_connect(int sockfd, const char *addr, int port);
int esp_read(int sockfd, void *data, int length);
int esp_write(int sockfd, const void *data, int length);
int esp_close(int sockfd);
int esp_shutdown(int sockfd, int how);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,299 +0,0 @@
/**
@file
Arduino library for communicating with Modbus slaves over RS232/485 (via RTU
protocol).
@defgroup setup ModbusMaster Object Instantiation/Initialization
@defgroup buffer ModbusMaster Buffer Management
@defgroup discrete Modbus Function Codes for Discrete Coils/Inputs
@defgroup register Modbus Function Codes for Holding/Input Registers
@defgroup constant Modbus Function Codes, Exception Codes
*/
/*
ModbusMaster.h - Arduino library for communicating with Modbus slaves
over RS232/485 (via RTU protocol).
This file is part of ModbusMaster.
ModbusMaster is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ModbusMaster is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ModbusMaster. If not, see <http://www.gnu.org/licenses/>.
Written by Doc Walker (Rx)
Copyright © 2009-2013 Doc Walker <4-20ma at wvfans dot net>
*/
#ifndef ModbusMaster_h
#define ModbusMaster_h
#include "Timer.h"
/**
@def __MODBUSMASTER_DEBUG__ (1).
Set to 1 to enable debugging features within class:
- pin 4 cycles for each byte read in the Modbus response
- pin 5 cycles for each millisecond timeout during the Modbus response
*/
#define __MODBUSMASTER_DEBUG__ (0)
/* _____STANDARD INCLUDES____________________________________________________
*/
// include types & constants of Wiring core API
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
//#include "WProgram.h"
#include <cstddef>
#include <stdint.h>
#endif
#define BYTE 0xA5
/* _____UTILITY MACROS_______________________________________________________
*/
/* _____PROJECT INCLUDES_____________________________________________________
*/
// functions to calculate Modbus Application Data Unit CRC
//#include "util/crc16.h"
// moved inlcuding crc16.h to ModbusMaster.cpp
// functions to manipulate words
///#include "util/word.h"
#include "word.h"
#include "SerialPort.h"
/* _____CLASS DEFINITIONS____________________________________________________
*/
/**
Arduino class library for communicating with Modbus slaves over
RS232/485 (via RTU protocol).
*/
class ModbusMaster
{
public:
ModbusMaster ();
ModbusMaster (uint8_t);
ModbusMaster (uint8_t, uint8_t);
void begin ();
void begin (uint16_t);
void idle (void (*) ());
// Modbus exception codes
/**
Modbus protocol illegal function exception.
The function code received in the query is not an allowable action for
the server (or slave). This may be because the function code is only
applicable to newer devices, and was not implemented in the unit
selected. It could also indicate that the server (or slave) is in the
wrong state to process a request of this type, for example because it is
unconfigured and is being asked to return register values.
@ingroup constant
*/
static const uint8_t ku8MBIllegalFunction = 0x01;
/**
Modbus protocol illegal data address exception.
The data address received in the query is not an allowable address for
the server (or slave). More specifically, the combination of reference
number and transfer length is invalid. For a controller with 100
registers, the ADU addresses the first register as 0, and the last one
as 99. If a request is submitted with a starting register address of 96
and a quantity of registers of 4, then this request will successfully
operate (address-wise at least) on registers 96, 97, 98, 99. If a
request is submitted with a starting register address of 96 and a
quantity of registers of 5, then this request will fail with Exception
Code 0x02 "Illegal Data Address" since it attempts to operate on
registers 96, 97, 98, 99 and 100, and there is no register with address
100.
@ingroup constant
*/
static const uint8_t ku8MBIllegalDataAddress = 0x02;
/**
Modbus protocol illegal data value exception.
A value contained in the query data field is not an allowable value for
server (or slave). This indicates a fault in the structure of the
remainder of a complex request, such as that the implied length is
incorrect. It specifically does NOT mean that a data item submitted for
storage in a register has a value outside the expectation of the
application program, since the MODBUS protocol is unaware of the
significance of any particular value of any particular register.
@ingroup constant
*/
static const uint8_t ku8MBIllegalDataValue = 0x03;
/**
Modbus protocol slave device failure exception.
An unrecoverable error occurred while the server (or slave) was
attempting to perform the requested action.
@ingroup constant
*/
static const uint8_t ku8MBSlaveDeviceFailure = 0x04;
// Class-defined success/exception codes
/**
ModbusMaster success.
Modbus transaction was successful; the following checks were valid:
- slave ID
- function code
- response code
- data
- CRC
@ingroup constant
*/
static const uint8_t ku8MBSuccess = 0x00;
/**
ModbusMaster invalid response slave ID exception.
The slave ID in the response does not match that of the request.
@ingroup constant
*/
static const uint8_t ku8MBInvalidSlaveID = 0xE0;
/**
ModbusMaster invalid response function exception.
The function code in the response does not match that of the request.
@ingroup constant
*/
static const uint8_t ku8MBInvalidFunction = 0xE1;
/**
ModbusMaster response timed out exception.
The entire response was not received within the timeout period,
ModbusMaster::ku8MBResponseTimeout.
@ingroup constant
*/
static const uint8_t ku8MBResponseTimedOut = 0xE2;
/**
ModbusMaster invalid response CRC exception.
The CRC in the response does not match the one calculated.
@ingroup constant
*/
static const uint8_t ku8MBInvalidCRC = 0xE3;
uint16_t getResponseBuffer (uint8_t);
void clearResponseBuffer ();
uint8_t setTransmitBuffer (uint8_t, uint16_t);
void clearTransmitBuffer ();
void beginTransmission (uint16_t);
uint8_t requestFrom (uint16_t, uint16_t);
void sendBit (bool);
void send (uint8_t);
void send (uint16_t);
void send (uint32_t);
uint8_t available (void);
uint16_t receive (void);
uint8_t readCoils (uint16_t, uint16_t);
uint8_t readDiscreteInputs (uint16_t, uint16_t);
uint8_t readHoldingRegisters (uint16_t, uint16_t);
uint8_t readInputRegisters (uint16_t, uint8_t);
uint8_t writeSingleCoil (uint16_t, uint8_t);
uint8_t writeSingleRegister (uint16_t, uint16_t);
uint8_t writeMultipleCoils (uint16_t, uint16_t);
uint8_t writeMultipleCoils ();
uint8_t writeMultipleRegisters (uint16_t, uint16_t);
uint8_t writeMultipleRegisters ();
uint8_t maskWriteRegister (uint16_t, uint16_t, uint16_t);
uint8_t readWriteMultipleRegisters (uint16_t, uint16_t, uint16_t, uint16_t);
uint8_t readWriteMultipleRegisters (uint16_t, uint16_t);
private:
uint8_t _u8SerialPort; ///< serial port (0..3) initialized in constructor
uint8_t _u8MBSlave; ///< Modbus slave (1..255) initialized in constructor
uint16_t _u16BaudRate; ///< baud rate (300..115200) initialized in begin()
static const uint8_t ku8MaxBufferSize
= 64; ///< size of response/transmit buffers
uint16_t _u16ReadAddress; ///< slave register from which to read
uint16_t _u16ReadQty; ///< quantity of words to read
uint16_t _u16ResponseBuffer[ku8MaxBufferSize]; ///< buffer to store Modbus
///< slave response; read via
///< GetResponseBuffer()
uint16_t _u16WriteAddress; ///< slave register to which to write
uint16_t _u16WriteQty; ///< quantity of words to write
uint16_t
_u16TransmitBuffer[ku8MaxBufferSize]; ///< buffer containing data to
///< transmit to Modbus slave; set
///< via SetTransmitBuffer()
uint16_t *txBuffer; // from Wire.h -- need to clean this up Rx
uint8_t _u8TransmitBufferIndex;
uint16_t u16TransmitBufferLength;
uint16_t *rxBuffer; // from Wire.h -- need to clean this up Rx
uint8_t _u8ResponseBufferIndex;
uint8_t _u8ResponseBufferLength;
// Modbus function codes for bit access
static const uint8_t ku8MBReadCoils
= 0x01; ///< Modbus function 0x01 Read Coils
static const uint8_t ku8MBReadDiscreteInputs
= 0x02; ///< Modbus function 0x02 Read Discrete Inputs
static const uint8_t ku8MBWriteSingleCoil
= 0x05; ///< Modbus function 0x05 Write Single Coil
static const uint8_t ku8MBWriteMultipleCoils
= 0x0F; ///< Modbus function 0x0F Write Multiple Coils
// Modbus function codes for 16 bit access
static const uint8_t ku8MBReadHoldingRegisters
= 0x03; ///< Modbus function 0x03 Read Holding Registers
static const uint8_t ku8MBReadInputRegisters
= 0x04; ///< Modbus function 0x04 Read Input Registers
static const uint8_t ku8MBWriteSingleRegister
= 0x06; ///< Modbus function 0x06 Write Single Register
static const uint8_t ku8MBWriteMultipleRegisters
= 0x10; ///< Modbus function 0x10 Write Multiple Registers
static const uint8_t ku8MBMaskWriteRegister
= 0x16; ///< Modbus function 0x16 Mask Write Register
static const uint8_t ku8MBReadWriteMultipleRegisters
= 0x17; ///< Modbus function 0x17 Read Write Multiple Registers
// Modbus timeout [milliseconds]
static const uint16_t ku16MBResponseTimeout
= 2000; ///< Modbus timeout [milliseconds]
// master function that conducts Modbus transactions
uint8_t ModbusMasterTransaction (uint8_t u8MBFunction);
// idle callback function; gets called during idle time between TX and RX
void (*_idle) ();
SerialPort *MBSerial = NULL; // added by KRL
};
#endif
/**
@example examples/Basic/Basic.pde
@example examples/PhoenixContact_nanoLC/PhoenixContact_nanoLC.pde
*/

View File

@ -1,19 +0,0 @@
#ifndef MODBUSREGISTER_H_
#define MODBUSREGISTER_H_
#include "ModbusMaster.h"
class ModbusRegister {
public:
ModbusRegister(ModbusMaster *master, int address, bool holdingRegister = true);
ModbusRegister(const ModbusRegister &) = delete;
virtual ~ModbusRegister();
int read();
void write(int value);
private:
ModbusMaster *m;
int addr;
bool hr;
};
#endif /* MODBUSREGISTER_H_ */

View File

@ -1,20 +0,0 @@
#ifndef SERIALPORT_H_
#define SERIALPORT_H_
#include "Uart.h"
class SerialPort {
public:
SerialPort();
virtual ~SerialPort();
int available();
void begin(int speed = 9600);
int read();
int write(const char* buf, int len);
int print(int val, int format);
void flush();
private:
static LpcUart *u;
};
#endif /* SERIALPORT_H_ */

View File

@ -1,54 +0,0 @@
#ifndef LPCUART_H_
#define LPCUART_H_
#include "chip.h"
struct LpcPinMap {
int port; /* set to -1 to indicate unused pin */
int pin; /* set to -1 to indicate unused pin */
};
struct LpcUartConfig {
LPC_USART_T *pUART;
uint32_t speed;
uint32_t data;
bool rs485;
LpcPinMap tx;
LpcPinMap rx;
LpcPinMap rts; /* used as output enable if RS-485 mode is enabled */
LpcPinMap cts;
};
class LpcUart {
public:
LpcUart(const LpcUartConfig &cfg);
LpcUart(const LpcUart &) = delete;
virtual ~LpcUart();
int free(); /* get amount of free space in transmit buffer */
int peek(); /* get number of received characters in receive buffer */
int write(char c);
int write(const char *s);
int write(const char *buffer, int len);
int read(char &c); /* get a single character. Returns number of characters read --> returns 0 if no character is available */
int read(char *buffer, int len);
void txbreak(bool brk); /* set break signal on */
bool rxbreak(); /* check if break is received */
void speed(int bps); /* change transmission speed */
bool txempty();
void isr(); /* ISR handler. This will be called by the HW ISR handler. Do not call from application */
private:
LPC_USART_T *uart;
IRQn_Type irqn;
/* currently we support only fixed size ring buffers */
static const int UART_RB_SIZE = 256;
/* Transmit and receive ring buffers */
RINGBUFF_T txring;
RINGBUFF_T rxring;
uint8_t rxbuff[UART_RB_SIZE];
uint8_t txbuff[UART_RB_SIZE];
static bool init; /* set when first UART is initialized. We have a global clock setting for all UARTSs */
};
#endif /* LPCUART_H_ */

View File

@ -1,86 +0,0 @@
/**
@file
CRC Computations
@defgroup util_crc16 "util/crc16.h": CRC Computations
@code#include "util/crc16.h"@endcode
This header file provides functions for calculating
cyclic redundancy checks (CRC) using common polynomials.
Modified by Doc Walker to be processor-independent (removed inline
assembler to allow it to compile on SAM3X8E processors).
@par References:
Jack Crenshaw's "Implementing CRCs" article in the January 1992 issue of @e
Embedded @e Systems @e Programming. This may be difficult to find, but it
explains CRC's in very clear and concise terms. Well worth the effort to
obtain a copy.
*/
/* Copyright (c) 2002, 2003, 2004 Marek Michalkiewicz
Copyright (c) 2005, 2007 Joerg Wunsch
Copyright (c) 2013 Dave Hylands
Copyright (c) 2013 Frederic Nadeau
Copyright (c) 2015 Doc Walker
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of the copyright holders nor the names of
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#ifndef _UTIL_CRC16_H_
#define _UTIL_CRC16_H_
/** @ingroup util_crc16
Processor-independent CRC-16 calculation.
Polynomial: x^16 + x^15 + x^2 + 1 (0xA001)<br>
Initial value: 0xFFFF
This CRC is normally used in disk-drive controllers.
@param uint16_t crc (0x0000..0xFFFF)
@param uint8_t a (0x00..0xFF)
@return calculated CRC (0x0000..0xFFFF)
*/
static uint16_t
crc16_update (uint16_t crc, uint8_t a)
{
int i;
crc ^= a;
for (i = 0; i < 8; ++i)
{
if (crc & 1)
crc = (crc >> 1) ^ 0xA001;
else
crc = (crc >> 1);
}
return crc;
}
#endif /* _UTIL_CRC16_H_ */

View File

@ -1,98 +0,0 @@
/**
@file
Utility Functions for Manipulating Words
@defgroup util_word "util/word.h": Utility Functions for Manipulating Words
@code#include "util/word.h"@endcode
This header file provides utility functions for manipulating words.
*/
/*
word.h - Utility Functions for Manipulating Words
This file is part of ModbusMaster.
ModbusMaster is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ModbusMaster is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ModbusMaster. If not, see <http://www.gnu.org/licenses/>.
Written by Doc Walker (Rx)
Copyright © 2009-2015 Doc Walker <4-20ma at wvfans dot net>
*/
#ifndef _UTIL_WORD_H_
#define _UTIL_WORD_H_
/** @ingroup util_word
Return low word of a 32-bit integer.
@param uint32_t ww (0x00000000..0xFFFFFFFF)
@return low word of input (0x0000..0xFFFF)
*/
static inline uint16_t lowWord(uint32_t ww)
{
return (uint16_t) ((ww) & 0xFFFF);
}
/** @ingroup util_word
Return high word of a 32-bit integer.
@param uint32_t ww (0x00000000..0xFFFFFFFF)
@return high word of input (0x0000..0xFFFF)
*/
static inline uint16_t highWord(uint32_t ww)
{
return (uint16_t) ((ww) >> 16);
}
/* utility functions for porting ModbusMaster to LPCXpresso
* added by krl
*/
static inline uint16_t word(uint8_t ww)
{
return (uint16_t) (ww);
}
static inline uint16_t word(uint8_t h, uint8_t l)
{
return (uint16_t) ((h << 8) | l);
}
static inline uint8_t highByte(uint16_t v)
{
return (uint8_t) ((v >> 8) & 0xFF);
}
static inline uint16_t lowByte(uint16_t v)
{
return (uint8_t) (v & 0xFF);
}
static inline uint8_t bitRead(uint8_t v, uint8_t n)
{
return (uint8_t) (v & (1 << n) ? 1 : 0);
}
static inline void bitWrite(uint16_t& v, uint8_t n, uint8_t b)
{
if(b) v = v | (1 << n);
else v = v & ~(1 << n);
}
#endif /* _UTIL_WORD_H_ */

View File

@ -1,62 +0,0 @@
/*
* PressureWrapper.h
*
* Created on: 5 Oct 2022
* Author: evgenymeshcheryakov
*/
#ifndef PRESSUREWRAPPER_H_
#define PRESSUREWRAPPER_H_
#include "I2C.h"
#include <cstdio>
#define ADDRESS 0x40
/**
* @brief structure to hold a raw data from
* the pressure sensor
*/
typedef struct _PRESSURE
{
uint8_t rBuffer[2];
uint8_t crc;
} PRESSURE_DATA;
class PressureWrapper
{
public:
PressureWrapper ();
/*
* @return pressure in Pascal
*/
int getPressure ();
/**
* @brief Check if sensor is ready
*
* @return true if awake
* @return false if asleep
*/
bool isAwake ();
/**
* @brief Wake the sensor up
*
*/
void wakeUp ();
virtual ~PressureWrapper ();
private:
I2C *i2c;
PRESSURE_DATA data = { { 0, 0 }, 0 };
/*
* @return struct with pressure data in
* rBuffer and CRC check in crc
*/
bool getRawPressure ();
};
#endif /* PRESSUREWRAPPER_H_ */

View File

@ -1,27 +0,0 @@
/*
* Counter.h
*
* Created on: Sep 1, 2022
* Author: tylen
*/
#ifndef COUNTER_H_
#define COUNTER_H_
class Counter
{
public:
Counter (unsigned int i, unsigned int up);
void inc ();
void dec ();
unsigned int getCurrent ();
void setInit (unsigned int i);
~Counter () = default;
private:
unsigned int init;
unsigned int up_lim;
unsigned int down_lim;
};
#endif /* COUNTER_H_ */

View File

@ -1,225 +0,0 @@
/*
* StateHandler.h
*
* Created on: Sep 21, 2022
* Author: tylen
*
* Purpose of this class is to store and pass
* the events of the current mode to further process.
*
*
*/
#ifndef STATE_HANDLER_H_
#define STATE_HANDLER_H_
#include "Counter.h"
#include "DigitalIoPin.h"
#include "Event.h"
#include "Fan.h"
#include "GMP252.h"
#include "HMP60.h"
#include "LiquidCrystal.h"
#include "PressureWrapper.h"
#include "Timer.h"
#include "common_control_values.h"
#include "nlohmann/json.hpp"
/** Buttons enumeration
*
* Current switch state is being passed
* from main to StateHandler through
* a keyEvent. Enumeration determines the state
* of the particular button.
*/
enum _buttons
{
/** Raises the bar up */
BUTTON_CONTROL_UP,
/** Raises the bar down */
BUTTON_CONTROL_DOWN,
/** Toggles the mode between auto and
* manual, which changes the state */
BUTTON_CONTROL_TOG_MODE,
/** Optional button to toggle the
* activation of the current setting.
* Not compulsory to be used. */
BUTTON_CONTROL_TOG_ACTIVE,
};
enum _bars
{
/** 0-100 % */
FAN_SPEED,
/** 0-120 Pa */
PRESSURE
};
enum _mode
{
MANUAL,
AUTO,
SENSORS,
ERROR_TIMEOUT
};
enum _sensors
{
PRESSUREDAT,
TEMPERATURE,
HUMIDITY,
CO2
};
class StateHandler;
typedef void (StateHandler::*state_pointer) (const Event &);
class StateHandler
{
public:
StateHandler (LiquidCrystal *lcd, Fan *propeller, PressureWrapper *pressure,
Timer *global);
virtual ~StateHandler ();
/** Get currently set pressure
*
* @return pressure in range of 0-120
*/
unsigned int getSetPressure ();
/** Get currently set FanSpeed
*
* @return speed in range of 0-100
*/
unsigned int getSetSpeed ();
/** Handle the given event of the current state
*
* @param event event to be handled in the current state
*/
void HandleState (const Event &event);
private:
state_pointer current;
bool current_mode;
Counter value[2] = { { 0, 100 }, { 0, 120 } };
/* Motor of fan starts at value 90. probably because of some
* weigh of fan, so voltage within range of 0-89 is not
* sufficient to start motor.
* TODO: Value 89 should be scaled to 0 at some point
*/
Counter fan_speed = { 0, 1000 };
/* Integral controller for PID. should be global, since it
* accumulates error signals encountered since startup
*/
int integral = 0;
int saved_set_value[2] = { 0, 0 };
int saved_curr_value[2] = { 0, 0 };
int sensors_data[4] = { 0 };
int sensor_timer = 0;
int error_timer = 0;
LiquidCrystal *_lcd;
Fan *_propeller;
PressureWrapper *_pressure;
bool pressure_status;
bool task_is_pending;
bool sensor_values_ready;
bool sensor_mode;
uint8_t pressure_achieved;
Timer *state_timer;
/* CO2 sensor object */
GMP252 co2;
/* Humidity and temperature sensor object */
HMP60 humidity;
/** Display values on LCD depending on current mode
*
* MANUAL MODE: SPEED: XX% PRESSURE: XXPa
*
* AUTO MODE: P. SET: XXPa P. CURR: XXPa
*
* @param mode the current printing mode
*/
void displaySet (size_t mode);
/** Set a new curremt state
* @param newstate new state to be set to current
*/
void SetState (state_pointer newstate);
/** Initialization state
*
* @param event event of the state
*/
void stateInit (const Event &event);
/** Manual state
*
* - set current speed
* - print current pressure
*
* @param event event of the state
*/
void stateManual (const Event &event);
/** Automated state
*
* - print current pressure
* - print set pressure
* - inc/dec fan speed
*
* @param event
*/
void stateAuto (const Event &event);
/**
* @brief Get pressure with the state
*
* @param event
*/
void stateGetPressure (const Event &event);
/** Show sensors
*
* @param event event of the state
*/
void stateShowSensors (const Event &event);
/** Handle button presses
*
* @param button current button
*/
void handleControlButtons (uint8_t button);
/** Handle the timer value of eTick event
*
* @param value current event value
*/
void handleTickValue (int value);
/** Save pressure values to class' varibales
*
* @param pressure current pressure
* @param mode current mode
*/
void savePressureAndDisplay (int pressure, size_t mode);
/** Save set values to class' varibales
*
* @param mode current mode
* @return true if saved
* @return false if not saved
*/
bool saveSetAndDisplay (size_t mode);
/** Calculates pid for fan control value
*
*/
void pid ();
int fan_speed_normalized ();
void updateSensorValues ();
};
#endif /* STATE_HANDLER_H_ */

View File

@ -1,34 +0,0 @@
/*
* SwitchController.h
*
* Created on: Oct 17, 2022
* Author: tylen
*/
#ifndef SWITCHCONTROLLER_H_
#define SWITCHCONTROLLER_H_
#include "DigitalIoPin.h"
#include "StateHandler/StateHandler.h"
#include "Timer.h"
class SwitchController
{
public:
SwitchController (DigitalIoPin *button, StateHandler *handler,
int button_mode);
virtual ~SwitchController ();
/** Listen to switch button
*/
void listen ();
private:
DigitalIoPin *b;
StateHandler *h;
bool b_pressed;
int b_mode;
void buttonOnHold ();
void buttonInLoop ();
};
#endif /* SWITCHCONTROLLER_H_ */

View File

@ -1,84 +0,0 @@
/*
* Timer.h
*
* Created on: Oct 14, 2022
* Author: tylen
*/
#ifndef TIMER_H_
#define TIMER_H_
#include "board.h"
#include <atomic>
#include <climits>
static volatile std::atomic_int timer;
static volatile std::atomic<uint32_t> systicks;
extern "C"
{
/**
* @brief Handle interrupt from SysTick timer
* @return Nothing
*/
void SysTick_Handler (void);
}
uint32_t millis ();
class Timer
{
public:
/**
* @brief Initalize the systick configuration with your frequency
*
*/
Timer (uint32_t freq = 1000, bool mode = true);
virtual ~Timer ();
/**
* @brief Tick the counter.
*
* Counter is incremented by one every tick,
* if it gets over the INT_MAX (see limits.h),
* the counter rolls up back to zero and starts
* over.
*
*
* @param ms Counter ticking frequency is provided in milliseconds
*/
void tickCounter (int ms);
/**
* @brief Get the current counter value
*
* @return int counter value
*/
int getCounter ();
/**
* @brief Set counter to 0.
*
*/
void resetCounter ();
/**
* @brief Sleep for amount of time
*
* Time is either in ms or in sec, defined
* by systickInit_xx()
*
* @param ms milliseconds
*/
void Sleep (int ms);
private:
volatile std::atomic_int counter;
volatile std::atomic_int prev_ticks;
uint32_t freq;
bool mode;
};
#endif /* TIMER_H_ */

View File

@ -1,26 +0,0 @@
/*
* common_control_values.h
*
* Created on: Oct 26, 2022
* Author: tylen
*/
#ifndef COMMON_CONTROL_VALUES_H_
#define COMMON_CONTROL_VALUES_H_
#define SSID "SmartIotMQTT"
#define PASSWORD "SmartIot"
#define BROKER_IP "192.168.1.254"
#define BROKER_PORT 1883
#define ONE_K_HZ 1000
enum _global_values
{
LCD_SIZE = 16,
TIMER_GLOBAL_TIMEOUT = 120000,
TIMER_SENSORS_TIMEOUT = 500,
TIMER_PRESSURE_TIMEOUT = 150,
};
#endif /* COMMON_CONTROL_VALUES_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -1,29 +0,0 @@
/*
* serial_port.h
*
* Created on: 25.8.2021
* Author: keijo
*/
#ifndef SERIAL_PORT_H_
#define SERIAL_PORT_H_
#ifdef __cplusplus
extern "C" {
#endif
void serial_init(void *ctx);
void serial_write_buf(void *ctx, const char *buf, int len);
void serial_write_str(void *ctx, const char *s);
int serial_get_char(void *ctx, char *p);
int serial_peek(void *ctx);
#ifdef __cplusplus
}
#endif
#endif /* SERIAL_PORT_H_ */

View File

@ -1,27 +0,0 @@
/*
* systick.h
*
* Created on: 6.9.2021
* Author: keijo
*/
#ifndef SYSTICK_H_
#define SYSTICK_H_
#ifdef __cplusplus
extern "C" {
#endif
uint32_t get_ticks(void);
#ifdef __cplusplus
}
#endif
void Sleep(int ms);
/* this function is required by the modbus library */
uint32_t millis();
#endif /* SYSTICK_H_ */

View File

@ -1,25 +0,0 @@
/*
* Fan.cpp
*
* Created on: Oct 26, 2022
* Author: tylen
*/
#include "Fan.h"
Fan::Fan (ModbusRegister *A01) { this->_A01 = A01; }
Fan::~Fan ()
{
// TODO Auto-generated destructor stub
}
void
Fan::spin (int speed)
{
assert ((this->_A01));
if (speed >= 0 && speed <= 1000)
{
this->_A01->write (speed);
}
}

View File

@ -1,27 +0,0 @@
/*
* GMP252.cpp
*
* Created on: 20 Oct 2022
* Author: evgenymeshcheryakov
*/
#include "GMP252.h"
GMP252::GMP252 ()
: sens{ 240 }, regInt{ &sens, 0x0100 }, regFloat{ &sens, 0x0000 }
{
sens.begin (9600);
}
int
GMP252::read ()
{
int result = regInt.read ();
return result;
}
GMP252::~GMP252 ()
{
// TODO Auto-generated destructor stub
}

View File

@ -1,32 +0,0 @@
/*
* HMP60.cpp
*
* Created on: 20 Oct 2022
* Author: evgenymeshcheryakov
*/
#include <HMP60.h>
HMP60::HMP60 ()
: sens{ 241 }, regRHint{ &sens, 0x0100 }, regTint{ &sens, 0x0101 },
regRHfloat{ &sens, 0x0000 }
{
sens.begin (9600);
}
int
HMP60::readRH ()
{
return (regRHint.read ()) / 10;
}
int
HMP60::readT ()
{
return (regTint.read ()) / 10;
}
HMP60::~HMP60 ()
{
// TODO Auto-generated destructor stub
}

View File

@ -1,160 +0,0 @@
/*
* I2C.cpp
*
* Created on: 21.2.2016
* Author: krl
* Based on example provided by NXP Semiconductors. See copyright notice
* below.
*/
/*
* @brief I2CM bus master example using polling mode
*
* @note
* Copyright(C) NXP Semiconductors, 2014
* All rights reserved.
*
* @par
* Software that is described herein is for illustrative purposes only
* which provides customers with programming information regarding the
* LPC products. This software is supplied "AS IS" without any warranties of
* any kind, and NXP Semiconductors and its licensor disclaim any and
* all warranties, express or implied, including all implied warranties of
* merchantability, fitness for a particular purpose and non-infringement of
* intellectual property rights. NXP Semiconductors assumes no responsibility
* or liability for the use of the software, conveys no license or rights under
* any patent, copyright, mask work right, or any other intellectual property
* rights in or to any products. NXP Semiconductors reserves the right to make
* changes in the software without notification. NXP Semiconductors also makes
* no representation or warranty that such application will be suitable for the
* specified use without further testing or modification.
*
* @par
* Permission to use, copy, modify, and distribute this software and its
* documentation is hereby granted, under NXP Semiconductors' and its
* licensor's relevant copyrights in the software, without fee, provided that
* it is used in conjunction with NXP Semiconductors microcontrollers. This
* copyright, permission, and disclaimer notice must appear in all copies of
* this code.
*/
#include "I2C.h"
I2C::I2C (const I2C_config &cfg) : device (nullptr)
{
// if(cfg.device_number == 0) {
device = LPC_I2C0;
// board init must have been called before the pins can be configured
Chip_IOCON_PinMuxSet (LPC_IOCON, 0, 22, IOCON_DIGMODE_EN | cfg.i2c_mode);
Chip_IOCON_PinMuxSet (LPC_IOCON, 0, 23, IOCON_DIGMODE_EN | cfg.i2c_mode);
Chip_SWM_EnableFixedPin (SWM_FIXED_I2C0_SCL);
Chip_SWM_EnableFixedPin (SWM_FIXED_I2C0_SDA);
//}
// else {
// currently we support only I2C number 0
//}
if (LPC_I2C0)
{
/* Enable I2C clock and reset I2C peripheral - the boot ROM does not
do this */
Chip_I2C_Init (LPC_I2C0);
/* Setup clock rate for I2C */
Chip_I2C_SetClockDiv (LPC_I2C0, cfg.clock_divider);
/* Setup I2CM transfer rate */
Chip_I2CM_SetBusSpeed (LPC_I2C0, cfg.speed);
/* Enable Master Mode */
Chip_I2CM_Enable (LPC_I2C0);
}
}
I2C::~I2C ()
{
// TODO Auto-generated destructor stub
}
bool
I2C::write (uint8_t devAddr, uint8_t *txBuffPtr, uint16_t txSize)
{
return transaction (devAddr, txBuffPtr, txSize, nullptr, 0);
}
bool
I2C::read (uint8_t devAddr, uint8_t *rxBuffPtr, uint16_t rxSize)
{
return transaction (devAddr, nullptr, 0, rxBuffPtr, rxSize);
}
bool
I2C::transaction (uint8_t devAddr, uint8_t *txBuffPtr, uint16_t txSize,
uint8_t *rxBuffPtr, uint16_t rxSize)
{
I2CM_XFER_T i2cmXferRec;
// make sure that master is idle
while (!Chip_I2CM_IsMasterPending (LPC_I2C0))
;
/* Setup I2C transfer record */
i2cmXferRec.slaveAddr = devAddr;
i2cmXferRec.status = 0;
i2cmXferRec.txSz = txSize;
i2cmXferRec.rxSz = rxSize;
i2cmXferRec.txBuff = txBuffPtr;
i2cmXferRec.rxBuff = rxBuffPtr;
I2CM_XferBlocking (LPC_I2C0, &i2cmXferRec);
// Chip_I2CM_XferBlocking returns before stop condition is fully completed
// therefore we need to wait for master to be idle when doing back-to-back
// transactions (see beginning of the function)
/* Test for valid operation */
if (i2cmXferRec.status == I2CM_STATUS_OK)
{
return true;
}
else
{
return false;
}
}
/* Transmit and Receive data in master mode */
/* This duplicates (and combines) the functionality of Chip_I2CM_Xfer and
* Chip_I2CM_XferBlocking with a modification that allows us to do a zero
* length write (needed to use honeywell humidity/temp sensor)
*/
uint32_t
I2C::I2CM_XferBlocking (LPC_I2C_T *pI2C, I2CM_XFER_T *xfer)
{
uint32_t ret = 0;
/* start transfer */
/* set the transfer status as busy */
xfer->status = I2CM_STATUS_BUSY;
/* Clear controller state. */
Chip_I2CM_ClearStatus (pI2C, I2C_STAT_MSTRARBLOSS | I2C_STAT_MSTSTSTPERR);
/* Write Address and RW bit to data register */
// Chip_I2CM_WriteByte(pI2C, (xfer->slaveAddr << 1) | (xfer->txSz == 0)); //
// original NXP version
// krl : both read and write lenght is 0 --> write (for honeywell temp
// sensor)
Chip_I2CM_WriteByte (pI2C, (xfer->slaveAddr << 1)
| (xfer->txSz == 0 && xfer->rxSz != 0));
/* Enter to Master Transmitter mode */
Chip_I2CM_SendStart (pI2C);
while (ret == 0)
{
/* wait for status change interrupt */
while (!Chip_I2CM_IsMasterPending (pI2C))
{
}
/* call state change handler */
ret = Chip_I2CM_XferHandler (pI2C, xfer);
}
return ret;
}

View File

@ -1,375 +0,0 @@
#include "LiquidCrystal.h"
#include "chip.h"
#include <cstring>
#define LOW 0
#define HIGH 1
void
delayMicroseconds (unsigned int us)
{
uint32_t reg;
// calculate compare value
uint64_t cmp = (Chip_Clock_GetSystemClockRate () / 1000000)
* us; // One cycle equals ~72 us, thus cycle * us
// disable RIT compare value may only be changed when RIT is disabled
reg = LPC_RITIMER->CTRL & 0xF;
LPC_RITIMER->CTRL = reg & ~RIT_CTRL_TEN;
// set compare value to RIT
LPC_RITIMER->COMPVAL = (uint32_t)cmp;
LPC_RITIMER->COMPVAL_H = (uint32_t) (cmp >> 32);
// clear RIT counter (so that counting starts from zero)
LPC_RITIMER->COUNTER = (uint32_t)0;
LPC_RITIMER->COUNTER_H = (uint32_t) (0 >> 32);
// enable RIT
reg = LPC_RITIMER->CTRL & 0xF;
LPC_RITIMER->CTRL = reg | RIT_CTRL_TEN;
// wait until RIT Int flag is set
while (!(LPC_RITIMER->CTRL & RIT_CTRL_INT))
;
// disable RIT
reg = LPC_RITIMER->CTRL & 0xF;
LPC_RITIMER->CTRL = reg & ~RIT_CTRL_TEN;
// clear RIT Int flag
reg = LPC_RITIMER->CTRL & 0xF;
LPC_RITIMER->CTRL = reg | RIT_CTRL_INT;
}
// When the display powers up, it is configured as follows:
//
// 1. Display clear
// 2. Function set:
// DL = 1; 8-bit interface data
// N = 0; 1-line display
// F = 0; 5x8 dot character font
// 3. Display on/off control:
// D = 0; Display off
// C = 0; Cursor off
// B = 0; Blinking off
// 4. Entry mode set:
// I/D = 1; Increment by 1
// S = 0; No shift
//
// Note, however, that resetting the Arduino doesn't reset the LCD, so we
// can't assume that its in that state when a sketch starts (and the
// LiquidCrystal constructor is called).
LiquidCrystal::LiquidCrystal (DigitalIoPin *rs, DigitalIoPin *enable,
DigitalIoPin *d0, DigitalIoPin *d1,
DigitalIoPin *d2, DigitalIoPin *d3)
{
rs_pin = rs;
enable_pin = enable;
data_pins[0] = d0;
data_pins[1] = d1;
data_pins[2] = d2;
data_pins[3] = d3;
_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
begin (16, 2); // default to 16x2 display
}
void
LiquidCrystal::begin (uint8_t cols, uint8_t lines, uint8_t dotsize)
{
this->rows = lines;
this->col = cols;
if (lines > 1)
{
_displayfunction |= LCD_2LINE;
}
_numlines = lines;
_currline = 0;
// for some 1 line displays you can select a 10 pixel high font
if ((dotsize != 0) && (lines == 1))
{
_displayfunction |= LCD_5x10DOTS;
}
// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
// according to datasheet, we need at least 40ms after power rises above 2.7V
// before sending commands. Arduino can turn on way befer 4.5V so we'll wait
// 50
delayMicroseconds (50000);
// Now we pull both RS and R/W low to begin commands
rs_pin->write (false); // digitalWrite(_rs_pin, LOW);
enable_pin->write (false); // digitalWrite(_enable_pin, LOW);
// note: this port supports only 4 bit mode
// put the LCD into 4 bit or 8 bit mode
if (!(_displayfunction & LCD_8BITMODE))
{
// this is according to the hitachi HD44780 datasheet
// figure 24, pg 46
// we start in 8bit mode, try to set 4 bit mode
write4bits (0x03);
delayMicroseconds (4500); // wait min 4.1ms
// second try
write4bits (0x03);
delayMicroseconds (4500); // wait min 4.1ms
// third go!
write4bits (0x03);
delayMicroseconds (150);
// finally, set to 4-bit interface
write4bits (0x02);
}
else
{
// this is according to the hitachi HD44780 datasheet
// page 45 figure 23
// Send function set command sequence
command (LCD_FUNCTIONSET | _displayfunction);
delayMicroseconds (4500); // wait more than 4.1ms
// second try
command (LCD_FUNCTIONSET | _displayfunction);
delayMicroseconds (150);
// third go
command (LCD_FUNCTIONSET | _displayfunction);
}
// finally, set # lines, font size, etc.
command (LCD_FUNCTIONSET | _displayfunction);
// turn the display on with no cursor or blinking default
_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
display ();
// clear it off
clear ();
// Initialize to default text direction (for romance languages)
_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
// set the entry mode
command (LCD_ENTRYMODESET | _displaymode);
}
/********** high level commands, for the user! */
void
LiquidCrystal::clear ()
{
command (LCD_CLEARDISPLAY); // clear display, set cursor position to zero
delayMicroseconds (2000); // this command takes a long time!
}
void
LiquidCrystal::home ()
{
command (LCD_RETURNHOME); // set cursor position to zero
delayMicroseconds (2000); // this command takes a long time!
}
void
LiquidCrystal::print (std::string const &s)
{
this->print (s.c_str ());
}
void
LiquidCrystal::print (const char *s)
{
int char_counter = 0;
while (*s && char_counter < this->col)
{
send (*s, HIGH);
char_counter++;
s++;
}
}
void
LiquidCrystal::printOnLineOne (const char *s)
{
setCursor (0, 0);
print (s);
}
void
LiquidCrystal::printOnLineTwo (const char *s)
{
setCursor (0, 1);
print (s);
}
void
LiquidCrystal::printOnLineOne (std::string const &s)
{
printOnLineOne (s.c_str ());
}
void
LiquidCrystal::printOnLineTwo (std::string const &s)
{
printOnLineTwo (s.c_str ());
}
void
LiquidCrystal::setCursor (uint8_t col, uint8_t row)
{
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
if (row >= _numlines)
{
row = _numlines - 1; // we count rows starting w/0
}
command (LCD_SETDDRAMADDR | (col + row_offsets[row]));
}
// Turn the display on/off (quickly)
void
LiquidCrystal::noDisplay ()
{
_displaycontrol &= ~LCD_DISPLAYON;
command (LCD_DISPLAYCONTROL | _displaycontrol);
}
void
LiquidCrystal::display ()
{
_displaycontrol |= LCD_DISPLAYON;
command (LCD_DISPLAYCONTROL | _displaycontrol);
}
// Turns the underline cursor on/off
void
LiquidCrystal::noCursor ()
{
_displaycontrol &= ~LCD_CURSORON;
command (LCD_DISPLAYCONTROL | _displaycontrol);
}
void
LiquidCrystal::cursor ()
{
_displaycontrol |= LCD_CURSORON;
command (LCD_DISPLAYCONTROL | _displaycontrol);
}
// Turn on and off the blinking cursor
void
LiquidCrystal::noBlink ()
{
_displaycontrol &= ~LCD_BLINKON;
command (LCD_DISPLAYCONTROL | _displaycontrol);
}
void
LiquidCrystal::blink ()
{
_displaycontrol |= LCD_BLINKON;
command (LCD_DISPLAYCONTROL | _displaycontrol);
}
// These commands scroll the display without changing the RAM
void
LiquidCrystal::scrollDisplayLeft (void)
{
command (LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT);
}
void
LiquidCrystal::scrollDisplayRight (void)
{
command (LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT);
}
// This is for text that flows Left to Right
void
LiquidCrystal::leftToRight (void)
{
_displaymode |= LCD_ENTRYLEFT;
command (LCD_ENTRYMODESET | _displaymode);
}
// This is for text that flows Right to Left
void
LiquidCrystal::rightToLeft (void)
{
_displaymode &= ~LCD_ENTRYLEFT;
command (LCD_ENTRYMODESET | _displaymode);
}
// This will 'right justify' text from the cursor
void
LiquidCrystal::autoscroll (void)
{
_displaymode |= LCD_ENTRYSHIFTINCREMENT;
command (LCD_ENTRYMODESET | _displaymode);
}
// This will 'left justify' text from the cursor
void
LiquidCrystal::noAutoscroll (void)
{
_displaymode &= ~LCD_ENTRYSHIFTINCREMENT;
command (LCD_ENTRYMODESET | _displaymode);
}
// Allows us to fill the first 8 CGRAM locations
// with custom characters
void
LiquidCrystal::createChar (uint8_t location, uint8_t charmap[])
{
location &= 0x7; // we only have 8 locations 0-7
command (LCD_SETCGRAMADDR | (location << 3));
for (int i = 0; i < 8; i++)
{
write (charmap[i]);
}
}
/*********** mid level commands, for sending data/cmds */
inline void
LiquidCrystal::command (uint8_t value)
{
send (value, LOW);
}
inline size_t
LiquidCrystal::write (uint8_t value)
{
send (value, HIGH);
return 1; // assume sucess
}
/************ low level data pushing commands **********/
// write either command or data
void
LiquidCrystal::send (uint8_t value, uint8_t mode)
{
rs_pin->write (mode); // digitalWrite(_rs_pin, mode);
write4bits (value >> 4);
write4bits (value);
}
void
LiquidCrystal::pulseEnable (void)
{
enable_pin->write (false); // digitalWrite(_enable_pin, LOW);
delayMicroseconds (1);
enable_pin->write (true); // digitalWrite(_enable_pin, HIGH);
delayMicroseconds (1); // enable pulse must be >450ns
enable_pin->write (false); // digitalWrite(_enable_pin, LOW);
delayMicroseconds (100); // commands need > 37us to settle
}
void
LiquidCrystal::write4bits (uint8_t value)
{
for (int i = 0; i < 4; i++)
{
data_pins[i]->write (
(value >> i)
& 0x01); // digitalWrite(_data_pins[i], (value >> i) & 0x01);
}
pulseEnable ();
}

View File

@ -1,214 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
*******************************************************************************/
#include <MQTT/MQTTPacket.h>
#include "../inc/MQTT/StackTrace.h"
#include <string.h>
/**
* Determines the length of the MQTT connect packet that would be produced using the supplied connect options.
* @param options the options to be used to build the connect packet
* @return the length of buffer needed to contain the serialized version of the packet
*/
int MQTTSerialize_connectLength(MQTTPacket_connectData* options)
{
int len = 0;
FUNC_ENTRY;
if (options->MQTTVersion == 3)
len = 12; /* variable depending on MQTT or MQIsdp */
else if (options->MQTTVersion == 4)
len = 10;
len += MQTTstrlen(options->clientID)+2;
if (options->willFlag)
len += MQTTstrlen(options->will.topicName)+2 + MQTTstrlen(options->will.message)+2;
if (options->username.cstring || options->username.lenstring.data)
len += MQTTstrlen(options->username)+2;
if (options->password.cstring || options->password.lenstring.data)
len += MQTTstrlen(options->password)+2;
FUNC_EXIT_RC(len);
return len;
}
/**
* Serializes the connect options into the buffer.
* @param buf the buffer into which the packet will be serialized
* @param len the length in bytes of the supplied buffer
* @param options the options to be used to build the connect packet
* @return serialized length, or error if 0
*/
int MQTTSerialize_connect(unsigned char* buf, int buflen, MQTTPacket_connectData* options)
{
unsigned char *ptr = buf;
MQTTHeader header = {0};
MQTTConnectFlags flags = {0};
int len = 0;
int rc = -1;
FUNC_ENTRY;
if (MQTTPacket_len(len = MQTTSerialize_connectLength(options)) > buflen)
{
rc = MQTTPACKET_BUFFER_TOO_SHORT;
goto exit;
}
header.byte = 0;
header.bits.type = CONNECT;
writeChar(&ptr, header.byte); /* write header */
ptr += MQTTPacket_encode(ptr, len); /* write remaining length */
if (options->MQTTVersion == 4)
{
writeCString(&ptr, "MQTT");
writeChar(&ptr, (char) 4);
}
else
{
writeCString(&ptr, "MQIsdp");
writeChar(&ptr, (char) 3);
}
flags.all = 0;
flags.bits.cleansession = options->cleansession;
flags.bits.will = (options->willFlag) ? 1 : 0;
if (flags.bits.will)
{
flags.bits.willQoS = options->will.qos;
flags.bits.willRetain = options->will.retained;
}
if (options->username.cstring || options->username.lenstring.data)
flags.bits.username = 1;
if (options->password.cstring || options->password.lenstring.data)
flags.bits.password = 1;
writeChar(&ptr, flags.all);
writeInt(&ptr, options->keepAliveInterval);
writeMQTTString(&ptr, options->clientID);
if (options->willFlag)
{
writeMQTTString(&ptr, options->will.topicName);
writeMQTTString(&ptr, options->will.message);
}
if (flags.bits.username)
writeMQTTString(&ptr, options->username);
if (flags.bits.password)
writeMQTTString(&ptr, options->password);
rc = ptr - buf;
exit: FUNC_EXIT_RC(rc);
return rc;
}
/**
* Deserializes the supplied (wire) buffer into connack data - return code
* @param sessionPresent the session present flag returned (only for MQTT 3.1.1)
* @param connack_rc returned integer value of the connack return code
* @param buf the raw buffer data, of the correct length determined by the remaining length field
* @param len the length in bytes of the data in the supplied buffer
* @return error code. 1 is success, 0 is failure
*/
int MQTTDeserialize_connack(unsigned char* sessionPresent, unsigned char* connack_rc, unsigned char* buf, int buflen)
{
MQTTHeader header = {0};
unsigned char* curdata = buf;
unsigned char* enddata = NULL;
int rc = 0;
int mylen;
MQTTConnackFlags flags = {0};
FUNC_ENTRY;
header.byte = readChar(&curdata);
if (header.bits.type != CONNACK)
goto exit;
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
enddata = curdata + mylen;
if (enddata - curdata < 2)
goto exit;
flags.all = readChar(&curdata);
*sessionPresent = flags.bits.sessionpresent;
*connack_rc = readChar(&curdata);
rc = 1;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Serializes a 0-length packet into the supplied buffer, ready for writing to a socket
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer, to avoid overruns
* @param packettype the message type
* @return serialized length, or error if 0
*/
int MQTTSerialize_zero(unsigned char* buf, int buflen, unsigned char packettype)
{
MQTTHeader header = {0};
int rc = -1;
unsigned char *ptr = buf;
FUNC_ENTRY;
if (buflen < 2)
{
rc = MQTTPACKET_BUFFER_TOO_SHORT;
goto exit;
}
header.byte = 0;
header.bits.type = packettype;
writeChar(&ptr, header.byte); /* write header */
ptr += MQTTPacket_encode(ptr, 0); /* write remaining length */
rc = ptr - buf;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Serializes a disconnect packet into the supplied buffer, ready for writing to a socket
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer, to avoid overruns
* @return serialized length, or error if 0
*/
int MQTTSerialize_disconnect(unsigned char* buf, int buflen)
{
return MQTTSerialize_zero(buf, buflen, DISCONNECT);
}
/**
* Serializes a disconnect packet into the supplied buffer, ready for writing to a socket
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer, to avoid overruns
* @return serialized length, or error if 0
*/
int MQTTSerialize_pingreq(unsigned char* buf, int buflen)
{
return MQTTSerialize_zero(buf, buflen, PINGREQ);
}

View File

@ -1,148 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
*******************************************************************************/
#include "../inc/MQTT/MQTTPacket.h"
#include "../inc/MQTT/StackTrace.h"
#include <string.h>
#define min(a, b) ((a < b) ? a : b)
/**
* Validates MQTT protocol name and version combinations
* @param protocol the MQTT protocol name as an MQTTString
* @param version the MQTT protocol version number, as in the connect packet
* @return correct MQTT combination? 1 is true, 0 is false
*/
int MQTTPacket_checkVersion(MQTTString* protocol, int version)
{
int rc = 0;
if (version == 3 && memcmp(protocol->lenstring.data, "MQIsdp",
min(6, protocol->lenstring.len)) == 0)
rc = 1;
else if (version == 4 && memcmp(protocol->lenstring.data, "MQTT",
min(4, protocol->lenstring.len)) == 0)
rc = 1;
return rc;
}
/**
* Deserializes the supplied (wire) buffer into connect data structure
* @param data the connect data structure to be filled out
* @param buf the raw buffer data, of the correct length determined by the remaining length field
* @param len the length in bytes of the data in the supplied buffer
* @return error code. 1 is success, 0 is failure
*/
int MQTTDeserialize_connect(MQTTPacket_connectData* data, unsigned char* buf, int len)
{
MQTTHeader header = {0};
MQTTConnectFlags flags = {0};
unsigned char* curdata = buf;
unsigned char* enddata = &buf[len];
int rc = 0;
MQTTString Protocol;
int version;
int mylen = 0;
FUNC_ENTRY;
header.byte = readChar(&curdata);
if (header.bits.type != CONNECT)
goto exit;
curdata += MQTTPacket_decodeBuf(curdata, &mylen); /* read remaining length */
if (!readMQTTLenString(&Protocol, &curdata, enddata) ||
enddata - curdata < 0) /* do we have enough data to read the protocol version byte? */
goto exit;
version = (int)readChar(&curdata); /* Protocol version */
/* If we don't recognize the protocol version, we don't parse the connect packet on the
* basis that we don't know what the format will be.
*/
if (MQTTPacket_checkVersion(&Protocol, version))
{
flags.all = readChar(&curdata);
data->cleansession = flags.bits.cleansession;
data->keepAliveInterval = readInt(&curdata);
if (!readMQTTLenString(&data->clientID, &curdata, enddata))
goto exit;
data->willFlag = flags.bits.will;
if (flags.bits.will)
{
data->will.qos = flags.bits.willQoS;
data->will.retained = flags.bits.willRetain;
if (!readMQTTLenString(&data->will.topicName, &curdata, enddata) ||
!readMQTTLenString(&data->will.message, &curdata, enddata))
goto exit;
}
if (flags.bits.username)
{
if (enddata - curdata < 3 || !readMQTTLenString(&data->username, &curdata, enddata))
goto exit; /* username flag set, but no username supplied - invalid */
if (flags.bits.password &&
(enddata - curdata < 3 || !readMQTTLenString(&data->password, &curdata, enddata)))
goto exit; /* password flag set, but no password supplied - invalid */
}
else if (flags.bits.password)
goto exit; /* password flag set without username - invalid */
rc = 1;
}
exit:
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Serializes the connack packet into the supplied buffer.
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer
* @param connack_rc the integer connack return code to be used
* @param sessionPresent the MQTT 3.1.1 sessionPresent flag
* @return serialized length, or error if 0
*/
int MQTTSerialize_connack(unsigned char* buf, int buflen, unsigned char connack_rc, unsigned char sessionPresent)
{
MQTTHeader header = {0};
int rc = 0;
unsigned char *ptr = buf;
MQTTConnackFlags flags = {0};
FUNC_ENTRY;
if (buflen < 2)
{
rc = MQTTPACKET_BUFFER_TOO_SHORT;
goto exit;
}
header.byte = 0;
header.bits.type = CONNACK;
writeChar(&ptr, header.byte); /* write header */
ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */
flags.all = 0;
flags.bits.sessionpresent = sessionPresent;
writeChar(&ptr, flags.all);
writeChar(&ptr, connack_rc);
rc = ptr - buf;
exit:
FUNC_EXIT_RC(rc);
return rc;
}

View File

@ -1,107 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
*******************************************************************************/
#include "../inc/MQTT/StackTrace.h"
#include "../inc/MQTT/MQTTPacket.h"
#include <string.h>
#define min(a, b) ((a < b) ? 1 : 0)
/**
* Deserializes the supplied (wire) buffer into publish data
* @param dup returned integer - the MQTT dup flag
* @param qos returned integer - the MQTT QoS value
* @param retained returned integer - the MQTT retained flag
* @param packetid returned integer - the MQTT packet identifier
* @param topicName returned MQTTString - the MQTT topic in the publish
* @param payload returned byte buffer - the MQTT publish payload
* @param payloadlen returned integer - the length of the MQTT payload
* @param buf the raw buffer data, of the correct length determined by the remaining length field
* @param buflen the length in bytes of the data in the supplied buffer
* @return error code. 1 is success
*/
int MQTTDeserialize_publish(unsigned char* dup, int* qos, unsigned char* retained, unsigned short* packetid, MQTTString* topicName,
unsigned char** payload, int* payloadlen, unsigned char* buf, int buflen)
{
MQTTHeader header = {0};
unsigned char* curdata = buf;
unsigned char* enddata = NULL;
int rc = 0;
int mylen = 0;
FUNC_ENTRY;
header.byte = readChar(&curdata);
if (header.bits.type != PUBLISH)
goto exit;
*dup = header.bits.dup;
*qos = header.bits.qos;
*retained = header.bits.retain;
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
enddata = curdata + mylen;
if (!readMQTTLenString(topicName, &curdata, enddata) ||
enddata - curdata < 0) /* do we have enough data to read the protocol version byte? */
goto exit;
if (*qos > 0)
*packetid = readInt(&curdata);
*payloadlen = enddata - curdata;
*payload = curdata;
rc = 1;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Deserializes the supplied (wire) buffer into an ack
* @param packettype returned integer - the MQTT packet type
* @param dup returned integer - the MQTT dup flag
* @param packetid returned integer - the MQTT packet identifier
* @param buf the raw buffer data, of the correct length determined by the remaining length field
* @param buflen the length in bytes of the data in the supplied buffer
* @return error code. 1 is success, 0 is failure
*/
int MQTTDeserialize_ack(unsigned char* packettype, unsigned char* dup, unsigned short* packetid, unsigned char* buf, int buflen)
{
MQTTHeader header = {0};
unsigned char* curdata = buf;
unsigned char* enddata = NULL;
int rc = 0;
int mylen;
FUNC_ENTRY;
header.byte = readChar(&curdata);
*dup = header.bits.dup;
*packettype = header.bits.type;
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
enddata = curdata + mylen;
if (enddata - curdata < 2)
goto exit;
*packetid = readInt(&curdata);
rc = 1;
exit:
FUNC_EXIT_RC(rc);
return rc;
}

View File

@ -1,261 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
*******************************************************************************/
#include <MQTT/MQTTPacket.h>
#include "../inc/MQTT/StackTrace.h"
#include <string.h>
const char* MQTTPacket_names[] =
{
"RESERVED", "CONNECT", "CONNACK", "PUBLISH", "PUBACK", "PUBREC", "PUBREL",
"PUBCOMP", "SUBSCRIBE", "SUBACK", "UNSUBSCRIBE", "UNSUBACK",
"PINGREQ", "PINGRESP", "DISCONNECT"
};
const char* MQTTPacket_getName(unsigned short packetid)
{
return MQTTPacket_names[packetid];
}
int MQTTStringFormat_connect(char* strbuf, int strbuflen, MQTTPacket_connectData* data)
{
int strindex = 0;
strindex = snprintf(strbuf, strbuflen,
"CONNECT MQTT version %d, client id %.*s, clean session %d, keep alive %d",
(int)data->MQTTVersion, data->clientID.lenstring.len, data->clientID.lenstring.data,
(int)data->cleansession, data->keepAliveInterval);
if (data->willFlag)
strindex += snprintf(&strbuf[strindex], strbuflen - strindex,
", will QoS %d, will retain %d, will topic %.*s, will message %.*s",
data->will.qos, data->will.retained,
data->will.topicName.lenstring.len, data->will.topicName.lenstring.data,
data->will.message.lenstring.len, data->will.message.lenstring.data);
if (data->username.lenstring.data && data->username.lenstring.len > 0)
strindex += snprintf(&strbuf[strindex], strbuflen - strindex,
", user name %.*s", data->username.lenstring.len, data->username.lenstring.data);
if (data->password.lenstring.data && data->password.lenstring.len > 0)
strindex += snprintf(&strbuf[strindex], strbuflen - strindex,
", password %.*s", data->password.lenstring.len, data->password.lenstring.data);
return strindex;
}
int MQTTStringFormat_connack(char* strbuf, int strbuflen, unsigned char connack_rc, unsigned char sessionPresent)
{
int strindex = snprintf(strbuf, strbuflen, "CONNACK session present %d, rc %d", sessionPresent, connack_rc);
return strindex;
}
int MQTTStringFormat_publish(char* strbuf, int strbuflen, unsigned char dup, int qos, unsigned char retained,
unsigned short packetid, MQTTString topicName, unsigned char* payload, int payloadlen)
{
int strindex = snprintf(strbuf, strbuflen,
"PUBLISH dup %d, QoS %d, retained %d, packet id %d, topic %.*s, payload length %d, payload %.*s",
dup, qos, retained, packetid,
(topicName.lenstring.len < 20) ? topicName.lenstring.len : 20, topicName.lenstring.data,
payloadlen, (payloadlen < 20) ? payloadlen : 20, payload);
return strindex;
}
int MQTTStringFormat_ack(char* strbuf, int strbuflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
{
int strindex = snprintf(strbuf, strbuflen, "%s, packet id %d", MQTTPacket_names[packettype], packetid);
if (dup)
strindex += snprintf(strbuf + strindex, strbuflen - strindex, ", dup %d", dup);
return strindex;
}
int MQTTStringFormat_subscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid, int count,
MQTTString topicFilters[], int requestedQoSs[])
{
return snprintf(strbuf, strbuflen,
"SUBSCRIBE dup %d, packet id %d count %d topic %.*s qos %d",
dup, packetid, count,
topicFilters[0].lenstring.len, topicFilters[0].lenstring.data,
requestedQoSs[0]);
}
int MQTTStringFormat_suback(char* strbuf, int strbuflen, unsigned short packetid, int count, int* grantedQoSs)
{
return snprintf(strbuf, strbuflen,
"SUBACK packet id %d count %d granted qos %d", packetid, count, grantedQoSs[0]);
}
int MQTTStringFormat_unsubscribe(char* strbuf, int strbuflen, unsigned char dup, unsigned short packetid,
int count, MQTTString topicFilters[])
{
return snprintf(strbuf, strbuflen,
"UNSUBSCRIBE dup %d, packet id %d count %d topic %.*s",
dup, packetid, count,
topicFilters[0].lenstring.len, topicFilters[0].lenstring.data);
}
#if defined(MQTT_CLIENT)
char* MQTTFormat_toClientString(char* strbuf, int strbuflen, unsigned char* buf, int buflen)
{
int index = 0;
int rem_length = 0;
MQTTHeader header = {0};
int strindex = 0;
header.byte = buf[index++];
index += MQTTPacket_decodeBuf(&buf[index], &rem_length);
switch (header.bits.type)
{
case CONNACK:
{
unsigned char sessionPresent, connack_rc;
if (MQTTDeserialize_connack(&sessionPresent, &connack_rc, buf, buflen) == 1)
strindex = MQTTStringFormat_connack(strbuf, strbuflen, connack_rc, sessionPresent);
}
break;
case PUBLISH:
{
unsigned char dup, retained, *payload;
unsigned short packetid;
int qos, payloadlen;
MQTTString topicName = MQTTString_initializer;
if (MQTTDeserialize_publish(&dup, &qos, &retained, &packetid, &topicName,
&payload, &payloadlen, buf, buflen) == 1)
strindex = MQTTStringFormat_publish(strbuf, strbuflen, dup, qos, retained, packetid,
topicName, payload, payloadlen);
}
break;
case PUBACK:
case PUBREC:
case PUBREL:
case PUBCOMP:
{
unsigned char packettype, dup;
unsigned short packetid;
if (MQTTDeserialize_ack(&packettype, &dup, &packetid, buf, buflen) == 1)
strindex = MQTTStringFormat_ack(strbuf, strbuflen, packettype, dup, packetid);
}
break;
case SUBACK:
{
unsigned short packetid;
int maxcount = 1, count = 0;
int grantedQoSs[1];
if (MQTTDeserialize_suback(&packetid, maxcount, &count, grantedQoSs, buf, buflen) == 1)
strindex = MQTTStringFormat_suback(strbuf, strbuflen, packetid, count, grantedQoSs);
}
break;
case UNSUBACK:
{
unsigned short packetid;
if (MQTTDeserialize_unsuback(&packetid, buf, buflen) == 1)
strindex = MQTTStringFormat_ack(strbuf, strbuflen, UNSUBACK, 0, packetid);
}
break;
case PINGREQ:
case PINGRESP:
case DISCONNECT:
strindex = snprintf(strbuf, strbuflen, "%s", MQTTPacket_names[header.bits.type]);
break;
}
return strbuf;
}
#endif
#if defined(MQTT_SERVER)
char* MQTTFormat_toServerString(char* strbuf, int strbuflen, unsigned char* buf, int buflen)
{
int index = 0;
int rem_length = 0;
MQTTHeader header = {0};
int strindex = 0;
header.byte = buf[index++];
index += MQTTPacket_decodeBuf(&buf[index], &rem_length);
switch (header.bits.type)
{
case CONNECT:
{
MQTTPacket_connectData data;
int rc;
if ((rc = MQTTDeserialize_connect(&data, buf, buflen)) == 1)
strindex = MQTTStringFormat_connect(strbuf, strbuflen, &data);
}
break;
case PUBLISH:
{
unsigned char dup, retained, *payload;
unsigned short packetid;
int qos, payloadlen;
MQTTString topicName = MQTTString_initializer;
if (MQTTDeserialize_publish(&dup, &qos, &retained, &packetid, &topicName,
&payload, &payloadlen, buf, buflen) == 1)
strindex = MQTTStringFormat_publish(strbuf, strbuflen, dup, qos, retained, packetid,
topicName, payload, payloadlen);
}
break;
case PUBACK:
case PUBREC:
case PUBREL:
case PUBCOMP:
{
unsigned char packettype, dup;
unsigned short packetid;
if (MQTTDeserialize_ack(&packettype, &dup, &packetid, buf, buflen) == 1)
strindex = MQTTStringFormat_ack(strbuf, strbuflen, packettype, dup, packetid);
}
break;
case SUBSCRIBE:
{
unsigned char dup;
unsigned short packetid;
int maxcount = 1, count = 0;
MQTTString topicFilters[1];
int requestedQoSs[1];
if (MQTTDeserialize_subscribe(&dup, &packetid, maxcount, &count,
topicFilters, requestedQoSs, buf, buflen) == 1)
strindex = MQTTStringFormat_subscribe(strbuf, strbuflen, dup, packetid, count, topicFilters, requestedQoSs);;
}
break;
case UNSUBSCRIBE:
{
unsigned char dup;
unsigned short packetid;
int maxcount = 1, count = 0;
MQTTString topicFilters[1];
if (MQTTDeserialize_unsubscribe(&dup, &packetid, maxcount, &count, topicFilters, buf, buflen) == 1)
strindex = MQTTStringFormat_unsubscribe(strbuf, strbuflen, dup, packetid, count, topicFilters);
}
break;
case PINGREQ:
case PINGRESP:
case DISCONNECT:
strindex = snprintf(strbuf, strbuflen, "%s", MQTTPacket_names[header.bits.type]);
break;
}
strbuf[strbuflen] = '\0';
return strbuf;
}
#endif

View File

@ -1,411 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
* Sergio R. Caprile - non-blocking packet read functions for stream transport
*******************************************************************************/
#include <MQTT/MQTTPacket.h>
#include "../inc/MQTT/StackTrace.h"
#include <string.h>
/**
* Encodes the message length according to the MQTT algorithm
* @param buf the buffer into which the encoded data is written
* @param length the length to be encoded
* @return the number of bytes written to buffer
*/
int MQTTPacket_encode(unsigned char* buf, int length)
{
int rc = 0;
FUNC_ENTRY;
do
{
char d = length % 128;
length /= 128;
/* if there are more digits to encode, set the top bit of this digit */
if (length > 0)
d |= 0x80;
buf[rc++] = d;
} while (length > 0);
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Decodes the message length according to the MQTT algorithm
* @param getcharfn pointer to function to read the next character from the data source
* @param value the decoded length returned
* @return the number of bytes read from the socket
*/
int MQTTPacket_decode(int (*getcharfn)(unsigned char*, int), int* value)
{
unsigned char c;
int multiplier = 1;
int len = 0;
#define MAX_NO_OF_REMAINING_LENGTH_BYTES 4
FUNC_ENTRY;
*value = 0;
do
{
int rc = MQTTPACKET_READ_ERROR;
if (++len > MAX_NO_OF_REMAINING_LENGTH_BYTES)
{
rc = MQTTPACKET_READ_ERROR; /* bad data */
goto exit;
}
rc = (*getcharfn)(&c, 1);
if (rc != 1)
goto exit;
*value += (c & 127) * multiplier;
multiplier *= 128;
} while ((c & 128) != 0);
exit:
FUNC_EXIT_RC(len);
return len;
}
int MQTTPacket_len(int rem_len)
{
rem_len += 1; /* header byte */
/* now remaining_length field */
if (rem_len < 128)
rem_len += 1;
else if (rem_len < 16384)
rem_len += 2;
else if (rem_len < 2097151)
rem_len += 3;
else
rem_len += 4;
return rem_len;
}
static unsigned char* bufptr;
int bufchar(unsigned char* c, int count)
{
int i;
for (i = 0; i < count; ++i)
*c = *bufptr++;
return count;
}
int MQTTPacket_decodeBuf(unsigned char* buf, int* value)
{
bufptr = buf;
return MQTTPacket_decode(bufchar, value);
}
/**
* Calculates an integer from two bytes read from the input buffer
* @param pptr pointer to the input buffer - incremented by the number of bytes used & returned
* @return the integer value calculated
*/
int readInt(unsigned char** pptr)
{
unsigned char* ptr = *pptr;
int len = 256*(*ptr) + (*(ptr+1));
*pptr += 2;
return len;
}
/**
* Reads one character from the input buffer.
* @param pptr pointer to the input buffer - incremented by the number of bytes used & returned
* @return the character read
*/
char readChar(unsigned char** pptr)
{
char c = **pptr;
(*pptr)++;
return c;
}
/**
* Writes one character to an output buffer.
* @param pptr pointer to the output buffer - incremented by the number of bytes used & returned
* @param c the character to write
*/
void writeChar(unsigned char** pptr, char c)
{
**pptr = c;
(*pptr)++;
}
/**
* Writes an integer as 2 bytes to an output buffer.
* @param pptr pointer to the output buffer - incremented by the number of bytes used & returned
* @param anInt the integer to write
*/
void writeInt(unsigned char** pptr, int anInt)
{
**pptr = (unsigned char)(anInt / 256);
(*pptr)++;
**pptr = (unsigned char)(anInt % 256);
(*pptr)++;
}
/**
* Writes a "UTF" string to an output buffer. Converts C string to length-delimited.
* @param pptr pointer to the output buffer - incremented by the number of bytes used & returned
* @param string the C string to write
*/
void writeCString(unsigned char** pptr, const char* string)
{
int len = strlen(string);
writeInt(pptr, len);
memcpy(*pptr, string, len);
*pptr += len;
}
int getLenStringLen(char* ptr)
{
int len = 256*((unsigned char)(*ptr)) + (unsigned char)(*(ptr+1));
return len;
}
void writeMQTTString(unsigned char** pptr, MQTTString mqttstring)
{
if (mqttstring.lenstring.len > 0)
{
writeInt(pptr, mqttstring.lenstring.len);
memcpy(*pptr, mqttstring.lenstring.data, mqttstring.lenstring.len);
*pptr += mqttstring.lenstring.len;
}
else if (mqttstring.cstring)
writeCString(pptr, mqttstring.cstring);
else
writeInt(pptr, 0);
}
/**
* @param mqttstring the MQTTString structure into which the data is to be read
* @param pptr pointer to the output buffer - incremented by the number of bytes used & returned
* @param enddata pointer to the end of the data: do not read beyond
* @return 1 if successful, 0 if not
*/
int readMQTTLenString(MQTTString* mqttstring, unsigned char** pptr, unsigned char* enddata)
{
int rc = 0;
FUNC_ENTRY;
/* the first two bytes are the length of the string */
if (enddata - (*pptr) > 1) /* enough length to read the integer? */
{
mqttstring->lenstring.len = readInt(pptr); /* increments pptr to point past length */
if (&(*pptr)[mqttstring->lenstring.len] <= enddata)
{
mqttstring->lenstring.data = (char*)*pptr;
*pptr += mqttstring->lenstring.len;
rc = 1;
}
}
mqttstring->cstring = NULL;
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Return the length of the MQTTstring - C string if there is one, otherwise the length delimited string
* @param mqttstring the string to return the length of
* @return the length of the string
*/
int MQTTstrlen(MQTTString mqttstring)
{
int rc = 0;
if (mqttstring.cstring)
rc = strlen(mqttstring.cstring);
else
rc = mqttstring.lenstring.len;
return rc;
}
/**
* Compares an MQTTString to a C string
* @param a the MQTTString to compare
* @param bptr the C string to compare
* @return boolean - equal or not
*/
int MQTTPacket_equals(MQTTString* a, char* bptr)
{
int alen = 0,
blen = 0;
char *aptr;
if (a->cstring)
{
aptr = a->cstring;
alen = strlen(a->cstring);
}
else
{
aptr = a->lenstring.data;
alen = a->lenstring.len;
}
blen = strlen(bptr);
return (alen == blen) && (strncmp(aptr, bptr, alen) == 0);
}
/**
* Helper function to read packet data from some source into a buffer
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer
* @param getfn pointer to a function which will read any number of bytes from the needed source
* @return integer MQTT packet type, or -1 on error
* @note the whole message must fit into the caller's buffer
*/
int MQTTPacket_read(unsigned char* buf, int buflen, int (*getfn)(unsigned char*, int))
{
int rc = -1;
MQTTHeader header = {0};
int len = 0;
int rem_len = 0;
/* 1. read the header byte. This has the packet type in it */
if ((*getfn)(buf, 1) != 1)
goto exit;
len = 1;
/* 2. read the remaining length. This is variable in itself */
MQTTPacket_decode(getfn, &rem_len);
len += MQTTPacket_encode(buf + 1, rem_len); /* put the original remaining length back into the buffer */
/* 3. read the rest of the buffer using a callback to supply the rest of the data */
if((rem_len + len) > buflen)
goto exit;
if (rem_len && ((*getfn)(buf + len, rem_len) != rem_len))
goto exit;
header.byte = buf[0];
rc = header.bits.type;
exit:
return rc;
}
/**
* Decodes the message length according to the MQTT algorithm, non-blocking
* @param trp pointer to a transport structure holding what is needed to solve getting data from it
* @param value the decoded length returned
* @return integer the number of bytes read from the socket, 0 for call again, or -1 on error
*/
static int MQTTPacket_decodenb(MQTTTransport *trp)
{
unsigned char c;
int rc = MQTTPACKET_READ_ERROR;
FUNC_ENTRY;
if(trp->len == 0){ /* initialize on first call */
trp->multiplier = 1;
trp->rem_len = 0;
}
do {
int frc;
if (trp->len >= MAX_NO_OF_REMAINING_LENGTH_BYTES)
goto exit;
if ((frc=(*trp->getfn)(trp->sck, &c, 1)) == -1)
goto exit;
if (frc == 0){
rc = 0;
goto exit;
}
++(trp->len);
trp->rem_len += (c & 127) * trp->multiplier;
trp->multiplier *= 128;
} while ((c & 128) != 0);
rc = trp->len;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Helper function to read packet data from some source into a buffer, non-blocking
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer
* @param trp pointer to a transport structure holding what is needed to solve getting data from it
* @return integer MQTT packet type, 0 for call again, or -1 on error
* @note the whole message must fit into the caller's buffer
*/
int MQTTPacket_readnb(unsigned char* buf, int buflen, MQTTTransport *trp)
{
int rc = -1, frc;
MQTTHeader header = {0};
switch(trp->state){
default:
trp->state = 0;
/*FALLTHROUGH*/
case 0:
/* read the header byte. This has the packet type in it */
if ((frc=(*trp->getfn)(trp->sck, buf, 1)) == -1)
goto exit;
if (frc == 0)
return 0;
trp->len = 0;
++trp->state;
/*FALLTHROUGH*/
/* read the remaining length. This is variable in itself */
case 1:
if((frc=MQTTPacket_decodenb(trp)) == MQTTPACKET_READ_ERROR)
goto exit;
if(frc == 0)
return 0;
trp->len = 1 + MQTTPacket_encode(buf + 1, trp->rem_len); /* put the original remaining length back into the buffer */
if((trp->rem_len + trp->len) > buflen)
goto exit;
++trp->state;
/*FALLTHROUGH*/
case 2:
if(trp->rem_len){
/* read the rest of the buffer using a callback to supply the rest of the data */
if ((frc=(*trp->getfn)(trp->sck, buf + trp->len, trp->rem_len)) == -1)
goto exit;
if (frc == 0)
return 0;
trp->rem_len -= frc;
trp->len += frc;
if(trp->rem_len)
return 0;
}
header.byte = buf[0];
rc = header.bits.type;
break;
}
exit:
trp->state = 0;
return rc;
}

View File

@ -1,169 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
* Ian Craggs - fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=453144
*******************************************************************************/
#include <MQTT/MQTTPacket.h>
#include "../inc/MQTT/StackTrace.h"
#include <string.h>
/**
* Determines the length of the MQTT publish packet that would be produced using the supplied parameters
* @param qos the MQTT QoS of the publish (packetid is omitted for QoS 0)
* @param topicName the topic name to be used in the publish
* @param payloadlen the length of the payload to be sent
* @return the length of buffer needed to contain the serialized version of the packet
*/
int MQTTSerialize_publishLength(int qos, MQTTString topicName, int payloadlen)
{
int len = 0;
len += 2 + MQTTstrlen(topicName) + payloadlen;
if (qos > 0)
len += 2; /* packetid */
return len;
}
/**
* Serializes the supplied publish data into the supplied buffer, ready for sending
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer
* @param dup integer - the MQTT dup flag
* @param qos integer - the MQTT QoS value
* @param retained integer - the MQTT retained flag
* @param packetid integer - the MQTT packet identifier
* @param topicName MQTTString - the MQTT topic in the publish
* @param payload byte buffer - the MQTT publish payload
* @param payloadlen integer - the length of the MQTT payload
* @return the length of the serialized data. <= 0 indicates error
*/
int MQTTSerialize_publish(unsigned char* buf, int buflen, unsigned char dup, int qos, unsigned char retained, unsigned short packetid,
MQTTString topicName, unsigned char* payload, int payloadlen)
{
unsigned char *ptr = buf;
MQTTHeader header = {0};
int rem_len = 0;
int rc = 0;
FUNC_ENTRY;
if (MQTTPacket_len(rem_len = MQTTSerialize_publishLength(qos, topicName, payloadlen)) > buflen)
{
rc = MQTTPACKET_BUFFER_TOO_SHORT;
goto exit;
}
header.bits.type = PUBLISH;
header.bits.dup = dup;
header.bits.qos = qos;
header.bits.retain = retained;
writeChar(&ptr, header.byte); /* write header */
ptr += MQTTPacket_encode(ptr, rem_len); /* write remaining length */;
writeMQTTString(&ptr, topicName);
if (qos > 0)
writeInt(&ptr, packetid);
memcpy(ptr, payload, payloadlen);
ptr += payloadlen;
rc = ptr - buf;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Serializes the ack packet into the supplied buffer.
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer
* @param type the MQTT packet type
* @param dup the MQTT dup flag
* @param packetid the MQTT packet identifier
* @return serialized length, or error if 0
*/
int MQTTSerialize_ack(unsigned char* buf, int buflen, unsigned char packettype, unsigned char dup, unsigned short packetid)
{
MQTTHeader header = {0};
int rc = 0;
unsigned char *ptr = buf;
FUNC_ENTRY;
if (buflen < 4)
{
rc = MQTTPACKET_BUFFER_TOO_SHORT;
goto exit;
}
header.bits.type = packettype;
header.bits.dup = dup;
header.bits.qos = (packettype == PUBREL) ? 1 : 0;
writeChar(&ptr, header.byte); /* write header */
ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */
writeInt(&ptr, packetid);
rc = ptr - buf;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Serializes a puback packet into the supplied buffer.
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer
* @param packetid integer - the MQTT packet identifier
* @return serialized length, or error if 0
*/
int MQTTSerialize_puback(unsigned char* buf, int buflen, unsigned short packetid)
{
return MQTTSerialize_ack(buf, buflen, PUBACK, 0, packetid);
}
/**
* Serializes a pubrel packet into the supplied buffer.
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer
* @param dup integer - the MQTT dup flag
* @param packetid integer - the MQTT packet identifier
* @return serialized length, or error if 0
*/
int MQTTSerialize_pubrel(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid)
{
return MQTTSerialize_ack(buf, buflen, PUBREL, dup, packetid);
}
/**
* Serializes a pubrel packet into the supplied buffer.
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer
* @param packetid integer - the MQTT packet identifier
* @return serialized length, or error if 0
*/
int MQTTSerialize_pubcomp(unsigned char* buf, int buflen, unsigned short packetid)
{
return MQTTSerialize_ack(buf, buflen, PUBCOMP, 0, packetid);
}

View File

@ -1,137 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
*******************************************************************************/
#include <MQTT/MQTTPacket.h>
#include "../inc/MQTT/StackTrace.h"
#include <string.h>
/**
* Determines the length of the MQTT subscribe packet that would be produced using the supplied parameters
* @param count the number of topic filter strings in topicFilters
* @param topicFilters the array of topic filter strings to be used in the publish
* @return the length of buffer needed to contain the serialized version of the packet
*/
int MQTTSerialize_subscribeLength(int count, MQTTString topicFilters[])
{
int i;
int len = 2; /* packetid */
for (i = 0; i < count; ++i)
len += 2 + MQTTstrlen(topicFilters[i]) + 1; /* length + topic + req_qos */
return len;
}
/**
* Serializes the supplied subscribe data into the supplied buffer, ready for sending
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied bufferr
* @param dup integer - the MQTT dup flag
* @param packetid integer - the MQTT packet identifier
* @param count - number of members in the topicFilters and reqQos arrays
* @param topicFilters - array of topic filter names
* @param requestedQoSs - array of requested QoS
* @return the length of the serialized data. <= 0 indicates error
*/
int MQTTSerialize_subscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid, int count,
MQTTString topicFilters[], int requestedQoSs[])
{
unsigned char *ptr = buf;
MQTTHeader header = {0};
int rem_len = 0;
int rc = 0;
int i = 0;
FUNC_ENTRY;
if (MQTTPacket_len(rem_len = MQTTSerialize_subscribeLength(count, topicFilters)) > buflen)
{
rc = MQTTPACKET_BUFFER_TOO_SHORT;
goto exit;
}
header.byte = 0;
header.bits.type = SUBSCRIBE;
header.bits.dup = dup;
header.bits.qos = 1;
writeChar(&ptr, header.byte); /* write header */
ptr += MQTTPacket_encode(ptr, rem_len); /* write remaining length */;
writeInt(&ptr, packetid);
for (i = 0; i < count; ++i)
{
writeMQTTString(&ptr, topicFilters[i]);
writeChar(&ptr, requestedQoSs[i]);
}
rc = ptr - buf;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Deserializes the supplied (wire) buffer into suback data
* @param packetid returned integer - the MQTT packet identifier
* @param maxcount - the maximum number of members allowed in the grantedQoSs array
* @param count returned integer - number of members in the grantedQoSs array
* @param grantedQoSs returned array of integers - the granted qualities of service
* @param buf the raw buffer data, of the correct length determined by the remaining length field
* @param buflen the length in bytes of the data in the supplied buffer
* @return error code. 1 is success, 0 is failure
*/
int MQTTDeserialize_suback(unsigned short* packetid, int maxcount, int* count, int grantedQoSs[], unsigned char* buf, int buflen)
{
MQTTHeader header = {0};
unsigned char* curdata = buf;
unsigned char* enddata = NULL;
int rc = 0;
int mylen;
FUNC_ENTRY;
header.byte = readChar(&curdata);
if (header.bits.type != SUBACK)
goto exit;
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
enddata = curdata + mylen;
if (enddata - curdata < 2)
goto exit;
*packetid = readInt(&curdata);
*count = 0;
while (curdata < enddata)
{
if (*count > maxcount)
{
rc = -1;
goto exit;
}
grantedQoSs[(*count)++] = readChar(&curdata);
}
rc = 1;
exit:
FUNC_EXIT_RC(rc);
return rc;
}

View File

@ -1,112 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
*******************************************************************************/
#include "../inc/MQTT/MQTTPacket.h"
#include "../inc/MQTT/StackTrace.h"
#include <string.h>
/**
* Deserializes the supplied (wire) buffer into subscribe data
* @param dup integer returned - the MQTT dup flag
* @param packetid integer returned - the MQTT packet identifier
* @param maxcount - the maximum number of members allowed in the topicFilters and requestedQoSs arrays
* @param count - number of members in the topicFilters and requestedQoSs arrays
* @param topicFilters - array of topic filter names
* @param requestedQoSs - array of requested QoS
* @param buf the raw buffer data, of the correct length determined by the remaining length field
* @param buflen the length in bytes of the data in the supplied buffer
* @return the length of the serialized data. <= 0 indicates error
*/
int MQTTDeserialize_subscribe(unsigned char* dup, unsigned short* packetid, int maxcount, int* count, MQTTString topicFilters[],
int requestedQoSs[], unsigned char* buf, int buflen)
{
MQTTHeader header = {0};
unsigned char* curdata = buf;
unsigned char* enddata = NULL;
int rc = -1;
int mylen = 0;
FUNC_ENTRY;
header.byte = readChar(&curdata);
if (header.bits.type != SUBSCRIBE)
goto exit;
*dup = header.bits.dup;
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
enddata = curdata + mylen;
*packetid = readInt(&curdata);
*count = 0;
while (curdata < enddata)
{
if (!readMQTTLenString(&topicFilters[*count], &curdata, enddata))
goto exit;
if (curdata >= enddata) /* do we have enough data to read the req_qos version byte? */
goto exit;
requestedQoSs[*count] = readChar(&curdata);
(*count)++;
}
rc = 1;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Serializes the supplied suback data into the supplied buffer, ready for sending
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer
* @param packetid integer - the MQTT packet identifier
* @param count - number of members in the grantedQoSs array
* @param grantedQoSs - array of granted QoS
* @return the length of the serialized data. <= 0 indicates error
*/
int MQTTSerialize_suback(unsigned char* buf, int buflen, unsigned short packetid, int count, int* grantedQoSs)
{
MQTTHeader header = {0};
int rc = -1;
unsigned char *ptr = buf;
int i;
FUNC_ENTRY;
if (buflen < 2 + count)
{
rc = MQTTPACKET_BUFFER_TOO_SHORT;
goto exit;
}
header.byte = 0;
header.bits.type = SUBACK;
writeChar(&ptr, header.byte); /* write header */
ptr += MQTTPacket_encode(ptr, 2 + count); /* write remaining length */
writeInt(&ptr, packetid);
for (i = 0; i < count; ++i)
writeChar(&ptr, grantedQoSs[i]);
rc = ptr - buf;
exit:
FUNC_EXIT_RC(rc);
return rc;
}

View File

@ -1,106 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
*******************************************************************************/
#include "../inc/MQTT/MQTTPacket.h"
#include "../inc/MQTT/StackTrace.h"
#include <string.h>
/**
* Determines the length of the MQTT unsubscribe packet that would be produced using the supplied parameters
* @param count the number of topic filter strings in topicFilters
* @param topicFilters the array of topic filter strings to be used in the publish
* @return the length of buffer needed to contain the serialized version of the packet
*/
int MQTTSerialize_unsubscribeLength(int count, MQTTString topicFilters[])
{
int i;
int len = 2; /* packetid */
for (i = 0; i < count; ++i)
len += 2 + MQTTstrlen(topicFilters[i]); /* length + topic*/
return len;
}
/**
* Serializes the supplied unsubscribe data into the supplied buffer, ready for sending
* @param buf the raw buffer data, of the correct length determined by the remaining length field
* @param buflen the length in bytes of the data in the supplied buffer
* @param dup integer - the MQTT dup flag
* @param packetid integer - the MQTT packet identifier
* @param count - number of members in the topicFilters array
* @param topicFilters - array of topic filter names
* @return the length of the serialized data. <= 0 indicates error
*/
int MQTTSerialize_unsubscribe(unsigned char* buf, int buflen, unsigned char dup, unsigned short packetid,
int count, MQTTString topicFilters[])
{
unsigned char *ptr = buf;
MQTTHeader header = {0};
int rem_len = 0;
int rc = -1;
int i = 0;
FUNC_ENTRY;
if (MQTTPacket_len(rem_len = MQTTSerialize_unsubscribeLength(count, topicFilters)) > buflen)
{
rc = MQTTPACKET_BUFFER_TOO_SHORT;
goto exit;
}
header.byte = 0;
header.bits.type = UNSUBSCRIBE;
header.bits.dup = dup;
header.bits.qos = 1;
writeChar(&ptr, header.byte); /* write header */
ptr += MQTTPacket_encode(ptr, rem_len); /* write remaining length */;
writeInt(&ptr, packetid);
for (i = 0; i < count; ++i)
writeMQTTString(&ptr, topicFilters[i]);
rc = ptr - buf;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Deserializes the supplied (wire) buffer into unsuback data
* @param packetid returned integer - the MQTT packet identifier
* @param buf the raw buffer data, of the correct length determined by the remaining length field
* @param buflen the length in bytes of the data in the supplied buffer
* @return error code. 1 is success, 0 is failure
*/
int MQTTDeserialize_unsuback(unsigned short* packetid, unsigned char* buf, int buflen)
{
unsigned char type = 0;
unsigned char dup = 0;
int rc = 0;
FUNC_ENTRY;
rc = MQTTDeserialize_ack(&type, &dup, packetid, buf, buflen);
if (type == UNSUBACK)
rc = 1;
FUNC_EXIT_RC(rc);
return rc;
}

View File

@ -1,102 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Ian Craggs - initial API and implementation and/or initial documentation
*******************************************************************************/
#include <MQTT/MQTTPacket.h>
#include "../inc/MQTT/StackTrace.h"
#include <string.h>
/**
* Deserializes the supplied (wire) buffer into unsubscribe data
* @param dup integer returned - the MQTT dup flag
* @param packetid integer returned - the MQTT packet identifier
* @param maxcount - the maximum number of members allowed in the topicFilters and requestedQoSs arrays
* @param count - number of members in the topicFilters and requestedQoSs arrays
* @param topicFilters - array of topic filter names
* @param buf the raw buffer data, of the correct length determined by the remaining length field
* @param buflen the length in bytes of the data in the supplied buffer
* @return the length of the serialized data. <= 0 indicates error
*/
int MQTTDeserialize_unsubscribe(unsigned char* dup, unsigned short* packetid, int maxcount, int* count, MQTTString topicFilters[],
unsigned char* buf, int len)
{
MQTTHeader header = {0};
unsigned char* curdata = buf;
unsigned char* enddata = NULL;
int rc = 0;
int mylen = 0;
FUNC_ENTRY;
header.byte = readChar(&curdata);
if (header.bits.type != UNSUBSCRIBE)
goto exit;
*dup = header.bits.dup;
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
enddata = curdata + mylen;
*packetid = readInt(&curdata);
*count = 0;
while (curdata < enddata)
{
if (!readMQTTLenString(&topicFilters[*count], &curdata, enddata))
goto exit;
(*count)++;
}
rc = 1;
exit:
FUNC_EXIT_RC(rc);
return rc;
}
/**
* Serializes the supplied unsuback data into the supplied buffer, ready for sending
* @param buf the buffer into which the packet will be serialized
* @param buflen the length in bytes of the supplied buffer
* @param packetid integer - the MQTT packet identifier
* @return the length of the serialized data. <= 0 indicates error
*/
int MQTTSerialize_unsuback(unsigned char* buf, int buflen, unsigned short packetid)
{
MQTTHeader header = {0};
int rc = 0;
unsigned char *ptr = buf;
FUNC_ENTRY;
if (buflen < 2)
{
rc = MQTTPACKET_BUFFER_TOO_SHORT;
goto exit;
}
header.byte = 0;
header.bits.type = UNSUBACK;
writeChar(&ptr, header.byte); /* write header */
ptr += MQTTPacket_encode(ptr, 2); /* write remaining length */
writeInt(&ptr, packetid);
rc = ptr - buf;
exit:
FUNC_EXIT_RC(rc);
return rc;
}

View File

@ -1,140 +0,0 @@
/*******************************************************************************
* Copyright (c) 2014, 2015 IBM Corp.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Allan Stockdill-Mander - initial API and implementation and/or initial documentation
* Ian Craggs - convert to FreeRTOS
*******************************************************************************/
#include <MQTT/MQTT_lpc1549.h>
#include <string.h>
#include "systick.h"
#include "../inc/MQTT/esp8266_socket.h"
void TimerCountdownMS(Timer* timer, unsigned int timeout_ms)
{
timer->TicksToWait = timeout_ms;
timer->Start = get_ticks();
}
void TimerCountdown(Timer* timer, unsigned int timeout)
{
TimerCountdownMS(timer, timeout * 1000);
}
int TimerLeftMS(Timer* timer)
{
int32_t left = (int32_t)timer->TicksToWait - (int32_t)(get_ticks() - timer->Start);
return left < 0 ? 0 : left;
}
char TimerIsExpired(Timer* timer)
{
return (get_ticks() - timer->Start) > timer->TicksToWait;
}
void TimerInit(Timer* timer)
{
timer->TicksToWait = 0;
timer->Start = 0;
}
int lpc1549_read(Network* n, unsigned char* buffer, int len, int timeout_ms)
{
int recvLen = 0;
Timer timer;
TimerCountdownMS(&timer, timeout_ms);
do
{
int rc = 0;
rc = esp_read(n->my_socket, buffer + recvLen, len - recvLen);
if (rc > 0)
recvLen += rc;
else if (rc < 0)
{
recvLen = rc;
break;
}
} while (recvLen < len && !TimerIsExpired(&timer));
return recvLen;
}
int lpc1549_write(Network* n, unsigned char* buffer, int len, int timeout_ms)
{
int sentLen = 0;
Timer timer;
TimerCountdownMS(&timer, timeout_ms);
do
{
int rc = 0;
rc = esp_write(n->my_socket, buffer + sentLen, len - sentLen);
if (rc > 0)
sentLen += rc;
else if (rc < 0)
{
sentLen = rc;
break;
}
} while (sentLen < len && !TimerIsExpired(&timer));
return sentLen;
}
void lpc1549_disconnect(Network* n)
{
esp_close(n->my_socket);
}
void NetworkInit(Network *n, const char *ssid, const char *password)
{
n->mqttread = lpc1549_read;
n->mqttwrite = lpc1549_write;
n->disconnect = lpc1549_disconnect;
strncpy(n->ssid, ssid, 32);
strncpy(n->password, password, 32);
n->my_socket = esp_socket(n->ssid, n->password);
}
int NetworkConnect(Network* n, char* address, int port)
{
return esp_connect(n->my_socket, address, port);
}
void NetworkDisconnect(Network *n)
{
n->disconnect(n);
}

View File

@ -1,755 +0,0 @@
/* ========================================
*
* Copyright YOUR COMPANY, THE YEAR
* All Rights Reserved
* UNPUBLISHED, LICENSED SOFTWARE.
*
* CONFIDENTIAL AND PROPRIETARY INFORMATION
* WHICH IS THE PROPERTY OF your company.
*
* ========================================
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "ring_buffer.h"
#include "../inc/MQTT/esp8266_socket.h"
#include "serial_port.h"
typedef int EspSocket_t;
uint32_t get_ticks(void); // defined externally
#define I_DONT_USE(x) (void) x
#define DEBUGP( ... ) printf( __VA_ARGS__ )
// macro for changing state. Correct operation requires that ctx is a pointer to state machine instance (see state template)
#define TRAN(st) ctx->next_state = st
typedef enum eventTypes { eEnter, eExit, eTick, eReceive, eConnect, eDisconnect, eSend } EventType;
typedef struct event_ {
EventType ev; // event type (= what happened)
// we could add additional data
} event;
static const event evEnter = { eEnter };
static const event evExit = { eExit };
typedef struct smi_ smi;
typedef void (*smf)(smi *, const event *); // prototype of state handler function pointer
#define EVQ_SIZE 32
#define SMI_BUFSIZE 80
#define RC_NOT_AVAILABLE -1
#define RC_OK 0
#define RC_ERROR 1
struct smi_ {
smf state; // current state (function pointer)
smf next_state; // next state (function pointer)
RINGBUFF_T EspEventQ;
event evq_buf[EVQ_SIZE];
int timer;
int count;
int pos;
char buffer[SMI_BUFSIZE];
char ssid[32]; // SSID
char pwd[32]; // password
char sa_data[32]; // ip address
char sa_port[14]; // port number (string)
};
static void stInit(smi *ctx, const event *e);
static void stEchoOff(smi *ctx, const event *e);
static void stStationModeCheck(smi *ctx, const event *e);
static void stStationModeSet(smi *ctx, const event *e);
static void stConnectAP(smi *ctx, const event *e);
static void stReady(smi *ctx, const event *e);
static void stConnectTCP(smi *ctx, const event *e);
static void stConnected(smi *ctx, const event *e);
static void stCloseTCP(smi *ctx, const event *e);
static void stPassthrough(smi *ctx, const event *e);
static void stPassthroughOK(smi *ctx, const event *e);
static void stAT(smi *ctx, const event *e);
static void stCommandMode(smi *ctx, const event *e);
static void EspSocketRun(smi *ctx);
smi EspSocketInstance;
static void port2str(int i, char *str)
{
int m = 100000;
i %= m; // limit integer size to max 5 digits.
while(i / m == 0) m/=10;
while(m > 0) {
*str++ = '0' + i / m;
i %= m;
m /= 10;
}
*str='\0';
}
void smi_init(smi *ctx)
{
serial_init(ctx);
memset(ctx, 0, sizeof(smi));
ctx->state = stInit;
ctx->next_state = stInit;
RingBuffer_Init(&ctx->EspEventQ, ctx->evq_buf, sizeof(event), EVQ_SIZE);
ctx->state(ctx, &evEnter); // enter initial state
}
int esp_socket(const char *ssid, const char *password)
{
smi_init(&EspSocketInstance);
strncpy(EspSocketInstance.ssid, ssid, 32);
strncpy(EspSocketInstance.pwd, password, 32);
while(EspSocketInstance.state != stReady) {
// run esp task and run ticks
EspSocketRun(&EspSocketInstance);
}
return 0;
}
int esp_connect(int sockfd, const char *addr, int port)
{
I_DONT_USE(sockfd);
strncpy(EspSocketInstance.sa_data,addr,sizeof(EspSocketInstance.sa_data)-1);
EspSocketInstance.sa_data[sizeof(EspSocketInstance.sa_data)-1] = '\0';
port2str(port, EspSocketInstance.sa_port);
const event e = { eConnect };
RingBuffer_Insert(&EspSocketInstance.EspEventQ,&e);
int rc = 0;
while(EspSocketInstance.state != stConnected) {
// run esp task and run ticks
EspSocketRun(&EspSocketInstance);
}
return rc;
}
int esp_read(int sockfd, void *data, int length)
{
I_DONT_USE(sockfd);
int count = 0;
if(EspSocketInstance.state == stConnected) {
// read data
while(count < length && serial_get_char(&EspSocketInstance, data)) {
++count;
++data;
}
}
return count;
}
int esp_write(int sockfd, const void *data, int length)
{
I_DONT_USE(sockfd);
if(EspSocketInstance.state == stConnected) {
// write data
serial_write_buf(&EspSocketInstance, data, length);
}
return length;
}
int esp_close(int sockfd)
{
return esp_shutdown(sockfd, -1);
}
int esp_shutdown(int sockfd, int how)
{
I_DONT_USE(sockfd);
I_DONT_USE(how);
const event e = { eDisconnect };
RingBuffer_Insert(&EspSocketInstance.EspEventQ,&e);
while(EspSocketInstance.state != stReady) {
// run esp task and run ticks
EspSocketRun(&EspSocketInstance);
}
return 0;
}
#if 0
/* this is state template */
void stStateTemplate(smi *ctx, const event *e)
{
switch(e->ev) {
case eEnter:
break;
case eExit:
break;
case eTick:
break;
case eReceive:
break;
default:
break;
}
}
#endif
void init_counters(smi *ctx) {
ctx->count = 0;
ctx->pos = 0;
ctx->timer = 0;
}
/* Read and store characters upto specified length.
* Returns true when specified amount of characters have been accumulated. */
void sm_flush(smi *ctx)
{
//DEBUGP("flush: %d\n", (int)xSerialRxWaiting(ctx->ComPort));
while(serial_get_char(ctx, ctx->buffer));
}
/* Read and store characters upto specified length.
* Returns true when specified amount of characters have been accumulated. */
bool sm_read_buffer(smi *ctx, int count)
{
while(ctx->pos < (SMI_BUFSIZE - 1) && ctx->pos < count && serial_get_char(ctx, ctx->buffer + ctx->pos)) {
//putchar(ctx->buffer[ctx->pos]); // debugging
++ctx->pos;
}
return (ctx->pos >= count);
}
/* Read an integer.
* Consumes characters until a non-nondigit is received. The nondigit is also consumed. */
bool sm_read_int(smi *ctx, int *value)
{
bool result = false;
while(ctx->pos < (SMI_BUFSIZE - 1) && serial_get_char(ctx, ctx->buffer + ctx->pos)) {
if(!isdigit((int)ctx->buffer[ctx->pos])) {
ctx->buffer[ctx->pos] = '\0';
*value = atoi(ctx->buffer);
result = true;
break;
}
else {
++ctx->pos;
}
}
return result;
}
/* Read and store data until one of the specified strings is received.
* The matched string is also included in the data .*/
int sm_read_until(smi *ctx, const char **p)
{
int result = RC_NOT_AVAILABLE;
while(result < 0 && ctx->pos < (SMI_BUFSIZE - 1) && serial_get_char(ctx, ctx->buffer + ctx->pos)) {
++ctx->pos;
ctx->buffer[ctx->pos] = '\0';
for(int i = 0; result < 0 && p[i] != NULL; ++i) {
if(strstr(ctx->buffer, p[i]) != NULL) {
result = i;
}
}
}
return result;
}
/* read and store data until result is received */
int sm_read_result(smi *ctx)
{
static const char *result_list[] = { "OK\r\n", "ERROR\r\n", NULL };
return sm_read_until(ctx, result_list);
}
/* read and consume characters until specified string occurs */
bool sm_wait_for(smi *ctx, const char *p)
{
bool result = false;
int len = strlen(p);
while(sm_read_buffer(ctx, len)) {
ctx->buffer[ctx->pos] = '\0';
if(strstr(ctx->buffer, p) != NULL) {
result = true;
break;
}
else {
memmove(ctx->buffer, ctx->buffer + 1, ctx->pos);
--ctx->pos;
}
}
return result;
}
static void stInit(smi *ctx, const event *e)
{
switch(e->ev) {
case eEnter:
DEBUGP("stInit\r\n");
sm_flush(ctx);
init_counters(ctx);
serial_write_str(ctx, "AT\r\n");
break;
case eExit:
break;
case eTick:
++ctx->timer;
//if(ctx->timer == 5) DEBUGP("[%s]", ctx->buffer);
if(ctx->timer >= 10) {
ctx->timer = 0;
++ctx->count;
if(ctx->count < 5) {
serial_write_str(ctx, "AT\r\n");
}
else {
DEBUGP("Error: Module not responding\r\n");
TRAN(stAT);
}
}
break;
case eReceive:
if(sm_wait_for(ctx, "OK\r\n")) {
TRAN(stEchoOff);
}
break;
default:
break;
}
}
static void stAT(smi *ctx, const event *e)
{
switch(e->ev) {
case eEnter:
DEBUGP("stAT\r\n");
init_counters(ctx);
break;
case eExit:
break;
case eTick:
++ctx->timer;
if(ctx->timer == 10) serial_write_str(ctx, "+++");
if(ctx->timer == 25) TRAN(stInit);
break;
case eReceive:
break;
default:
break;
}
}
static void stEchoOff(smi *ctx, const event *e)
{
switch(e->ev) {
case eEnter:
DEBUGP("stEchoOff\r\n");
sm_flush(ctx);
init_counters(ctx);
serial_write_str(ctx, "ATE0\r\n");
break;
case eExit:
break;
case eTick:
++ctx->timer;
if(ctx->timer >= 10) {
++ctx->count;
if(ctx->count < 3) {
serial_write_str(ctx, "ATE0\r\n");
}
else {
DEBUGP("Error: setting local echo off failed\r\n");
TRAN(stInit);
}
}
break;
case eReceive:
if(sm_wait_for(ctx, "OK\r\n")) {
TRAN(stStationModeCheck);
}
break;
default:
break;
}
}
static void stStationModeCheck(smi *ctx, const event *e)
{
int rc = -1;
switch(e->ev) {
case eEnter:
DEBUGP("stStationModeCheck\r\n");
init_counters(ctx);
serial_write_str(ctx, "AT+CWMODE_CUR?\r\n");
break;
case eExit:
break;
case eTick:
break;
case eReceive:
rc = sm_read_result(ctx);
if(rc == RC_OK) {
//DEBUGP("%d: %s", rc, ctx->buffer);
if(strstr(ctx->buffer, "+CWMODE_CUR:1\r\n") != NULL) {
TRAN(stConnectAP);
}
else {
TRAN(stStationModeSet);
}
}
else if(rc == RC_ERROR) {
}
break;
default:
break;
}
}
static void stStationModeSet(smi *ctx, const event *e)
{
switch(e->ev) {
case eEnter:
DEBUGP("stStationModeSet\r\n");
init_counters(ctx);
serial_write_str(ctx, "AT+CWMODE_CUR=1\r\n");
break;
case eExit:
break;
case eTick:
break;
case eReceive:
if(sm_wait_for(ctx, "OK\r\n")) {
TRAN(stStationModeCheck);
}
break;
default:
break;
}
}
static void connect_ssid(smi *ctx)
{
serial_write_str(ctx, "AT+CWJAP_CUR=\"");
serial_write_str(ctx, ctx->ssid);
serial_write_str(ctx, "\",\"");
serial_write_str(ctx, ctx->pwd);
serial_write_str(ctx, "\"\r\n");
}
static void stConnectAP(smi *ctx, const event *e)
{
int rc;
switch(e->ev) {
case eEnter:
DEBUGP("stConnectAP\r\n");
init_counters(ctx);
break;
case eExit:
break;
case eTick:
// may take upto 7 seconds. do we need a timeout?
++ctx->timer;
if(ctx->timer == 1) {
connect_ssid(ctx);
}
if(ctx->timer >= 70) {
ctx->timer = 0;
}
break;
case eReceive:
rc = sm_read_result(ctx);
if(rc == RC_OK) {
//DEBUGP("%d: %s", rc, ctx->buffer);
TRAN(stReady);
}
else if(rc == RC_ERROR) {
// failed: what to do now?
}
break;
default:
break;
}
}
static void stReady(smi *ctx, const event *e)
{
switch(e->ev) {
case eEnter:
DEBUGP("stReady\r\n");
init_counters(ctx);
break;
case eExit:
break;
case eTick:
break;
case eReceive:
break;
case eConnect:
TRAN(stConnectTCP);
break;
default:
break;
}
}
static void connect_tcp(smi *ctx)
{
serial_write_str(ctx, "AT+CIPSTART=\"TCP\",\"");
serial_write_str(ctx, ctx->sa_data);
serial_write_str(ctx, "\",");
serial_write_str(ctx, ctx->sa_port);
serial_write_str(ctx, "\r\n");
}
static void stConnectTCP(smi *ctx, const event *e)
{
int rc;
switch(e->ev) {
case eEnter:
DEBUGP("stConnectTCP\r\n");
init_counters(ctx);
connect_tcp(ctx);
break;
case eExit:
break;
case eTick:
break;
case eReceive:
rc = sm_read_result(ctx);
if(rc == RC_OK) {
//DEBUGP("%d: %s", rc, ctx->buffer);
if(strstr(ctx->buffer, "CONNECT\r\n") != NULL) {
TRAN(stPassthrough);
}
else {
// what else can we get with OK??
}
}
else if(rc == RC_ERROR) {
// failed: what to do now?
DEBUGP("Connect failed\r\n");
connect_tcp(ctx);
}
break;
default:
break;
}
}
static void stPassthrough(smi *ctx, const event *e)
{
int rc;
switch(e->ev) {
case eEnter:
DEBUGP("stPassthrough\r\n");
init_counters(ctx);
serial_write_str(ctx, "AT+CIPMODE=1\r\n");
break;
case eExit:
break;
case eTick:
break;
case eReceive:
rc = sm_read_result(ctx);
if(rc == RC_OK) {
TRAN(stPassthroughOK);
}
else if(rc == RC_ERROR) {
// failed: what to do now?
}
break;
default:
break;
}
}
static void stPassthroughOK(smi *ctx, const event *e)
{
switch(e->ev) {
case eEnter:
DEBUGP("stPassthroughOK\r\n");
init_counters(ctx);
serial_write_str(ctx, "AT+CIPSEND\r\n");
break;
case eExit:
break;
case eTick:
break;
case eReceive:
if(sm_wait_for(ctx, ">")) {
TRAN(stConnected);
}
break;
default:
break;
}
}
static void stConnected(smi *ctx, const event *e)
{
switch(e->ev) {
case eEnter:
DEBUGP("stConnected\r\n");
init_counters(ctx);
break;
case eExit:
break;
case eTick:
break;
case eReceive:
break;
case eDisconnect:
TRAN(stCommandMode);
break;
default:
break;
}
}
static void stCommandMode(smi *ctx, const event *e)
{
switch(e->ev) {
case eEnter:
DEBUGP("stCommandMode\r\n");
init_counters(ctx);
break;
case eExit:
break;
case eTick:
++ctx->timer;
if(ctx->timer == 10) serial_write_str(ctx, "+++");
if(ctx->timer == 25) TRAN(stCloseTCP);
break;
case eReceive:
break;
default:
break;
}
}
static void stCloseTCP(smi *ctx, const event *e)
{
int rc = -1;
switch(e->ev) {
case eEnter:
DEBUGP("stCloseTCP\r\n");
init_counters(ctx);
serial_write_str(ctx, "AT+CIPMODE=0\r\n");;
break;
case eReceive:
rc = sm_read_result(ctx);
if(rc == RC_OK) {
if(strstr(ctx->buffer, "CLOSED") != NULL) {
TRAN(stReady);
}
else {
init_counters(ctx);
serial_write_str(ctx, "AT+CIPCLOSE\r\n");;
}
}
else if(rc == RC_ERROR) {
}
break;
case eExit:
break;
case eTick:
break;
default:
break;
}
}
static void dispatch_event(smi *ctx, const event *e)
{
ctx->state(ctx, e); // dispatch event to current state
if(ctx->state != ctx->next_state) { // check if state was changed
ctx->state(ctx, &evExit); // exit old state (cleanup)
ctx->state = ctx->next_state; // change state
ctx->state(ctx, &evEnter); // enter new state
}
}
/**
* Receive events from queue and dispatch them to state machine
*/
static void EspSocketRun(smi *ctx)
{
event e;
static uint32_t old = 0 ;
uint32_t now = 0 ;
now = get_ticks()/100;
if(now != old) {
const event tick = { eTick };
old = now;
// send ESP tick
RingBuffer_Insert(&ctx->EspEventQ, &tick);
}
if(serial_peek(ctx)) {
const event rcv = { eReceive };
RingBuffer_Insert(&ctx->EspEventQ, &rcv);
}
// read queue
while (RingBuffer_Pop(&ctx->EspEventQ,&e)) {
dispatch_event(ctx, &e); // dispatch event to current state
}
}
/* [] END OF FILE */

View File

@ -1,952 +0,0 @@
/**
@file
Arduino library for communicating with Modbus slaves over RS232/485 (via RTU
protocol).
*/
/*
ModbusMaster.cpp - Arduino library for communicating with Modbus slaves
over RS232/485 (via RTU protocol).
This file is part of ModbusMaster.
ModbusMaster is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ModbusMaster is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ModbusMaster. If not, see <http://www.gnu.org/licenses/>.
Written by Doc Walker (Rx)
Copyright © 2009-2013 Doc Walker <4-20ma at wvfans dot net>
*/
/* _____PROJECT INCLUDES_____________________________________________________
*/
#include "Modbus/ModbusMaster.h"
#include "Modbus/crc16.h"
/* _____GLOBAL VARIABLES_____________________________________________________
*/
#if defined(ARDUINO_ARCH_AVR)
HardwareSerial *MBSerial = &Serial; ///< Pointer to Serial class object
#elif defined(ARDUINO_ARCH_SAM)
UARTClass *MBSerial = &Serial; ///< Pointer to Serial class object
#else
// In the case of undefined Serial the code should still function
// #error "This library only supports boards with an AVR or SAM processor.
// Please open an issue at https://github.com/4-20ma/ModbusMaster/issues and
// indicate which processor/platform you're using."
#endif
/* _____PUBLIC FUNCTIONS_____________________________________________________
*/
/**
Constructor.
Creates class object using default serial port 0, Modbus slave ID 1.
@ingroup setup
*/
ModbusMaster::ModbusMaster (void)
{
_u8SerialPort = 0;
_u8MBSlave = 1;
_u16BaudRate = 0;
}
/**
Constructor.
Creates class object using default serial port 0, specified Modbus slave ID.
@overload void ModbusMaster::ModbusMaster(uint8_t u8MBSlave)
@param u8MBSlave Modbus slave ID (1..255)
@ingroup setup
*/
ModbusMaster::ModbusMaster (uint8_t u8MBSlave)
{
_u8SerialPort = 0;
_u8MBSlave = u8MBSlave;
_u16BaudRate = 0;
}
/**
Constructor.
Creates class object using specified serial port, Modbus slave ID.
@overload void ModbusMaster::ModbusMaster(uint8_t u8SerialPort, uint8_t
u8MBSlave)
@param u8SerialPort serial port (Serial, Serial1..Serial3)
@param u8MBSlave Modbus slave ID (1..255)
@ingroup setup
*/
ModbusMaster::ModbusMaster (uint8_t u8SerialPort, uint8_t u8MBSlave)
{
_u8SerialPort = (u8SerialPort > 3) ? 0 : u8SerialPort;
_u8MBSlave = u8MBSlave;
_u16BaudRate = 0;
}
/**
Initialize class object.
Sets up the serial port using default 19200 baud rate.
Call once class has been instantiated, typically within setup().
@ingroup setup
*/
void
ModbusMaster::begin (void)
{
begin (19200);
}
/**
Initialize class object.
Sets up the serial port using specified baud rate.
Call once class has been instantiated, typically within setup().
@overload ModbusMaster::begin(uint16_t u16BaudRate)
@param u16BaudRate baud rate, in standard increments (300..115200)
@ingroup setup
*/
void
ModbusMaster::begin (uint16_t u16BaudRate)
{
// txBuffer = (uint16_t*) calloc(ku8MaxBufferSize, sizeof(uint16_t));
_u8TransmitBufferIndex = 0;
u16TransmitBufferLength = 0;
#if 0
switch(_u8SerialPort)
{
#if defined(UBRR1H)
case 1:
MBSerial = &Serial1;
break;
#endif
#if defined(UBRR2H)
case 2:
MBSerial = &Serial2;
break;
#endif
#if defined(UBRR3H)
case 3:
MBSerial = &Serial3;
break;
#endif
case 0:
default:
MBSerial = &Serial;
break;
}
#endif
if (MBSerial == NULL)
MBSerial = new SerialPort;
if (u16BaudRate != _u16BaudRate)
{
_u16BaudRate = u16BaudRate;
MBSerial->begin (u16BaudRate);
}
_idle = NULL;
#if __MODBUSMASTER_DEBUG__
// pinMode(4, OUTPUT);
// pinMode(5, OUTPUT);
#endif
}
void
ModbusMaster::beginTransmission (uint16_t u16Address)
{
_u16WriteAddress = u16Address;
_u8TransmitBufferIndex = 0;
u16TransmitBufferLength = 0;
}
// eliminate this function in favor of using existing MB request functions
uint8_t
ModbusMaster::requestFrom (uint16_t address, uint16_t quantity)
{
uint8_t read;
read = 1; // krl: added this to prevent warning. This method is not called
// anywhere...
// clamp to buffer length
if (quantity > ku8MaxBufferSize)
{
quantity = ku8MaxBufferSize;
}
// set rx buffer iterator vars
_u8ResponseBufferIndex = 0;
_u8ResponseBufferLength = read;
return read;
}
void
ModbusMaster::sendBit (bool data)
{
uint8_t txBitIndex = u16TransmitBufferLength % 16;
if ((u16TransmitBufferLength >> 4) < ku8MaxBufferSize)
{
if (0 == txBitIndex)
{
_u16TransmitBuffer[_u8TransmitBufferIndex] = 0;
}
bitWrite (_u16TransmitBuffer[_u8TransmitBufferIndex], txBitIndex, data);
u16TransmitBufferLength++;
_u8TransmitBufferIndex = u16TransmitBufferLength >> 4;
}
}
void
ModbusMaster::send (uint16_t data)
{
if (_u8TransmitBufferIndex < ku8MaxBufferSize)
{
_u16TransmitBuffer[_u8TransmitBufferIndex++] = data;
u16TransmitBufferLength = _u8TransmitBufferIndex << 4;
}
}
void
ModbusMaster::send (uint32_t data)
{
send (lowWord (data));
send (highWord (data));
}
void
ModbusMaster::send (uint8_t data)
{
send (word (data));
}
uint8_t
ModbusMaster::available (void)
{
return _u8ResponseBufferLength - _u8ResponseBufferIndex;
}
uint16_t
ModbusMaster::receive (void)
{
if (_u8ResponseBufferIndex < _u8ResponseBufferLength)
{
return _u16ResponseBuffer[_u8ResponseBufferIndex++];
}
else
{
return 0xFFFF;
}
}
/**
Set idle time callback function (cooperative multitasking).
This function gets called in the idle time between transmission of data
and response from slave. Do not call functions that read from the serial
buffer that is used by ModbusMaster. Use of i2c/TWI, 1-Wire, other
serial ports, etc. is permitted within callback function.
@see ModbusMaster::ModbusMasterTransaction()
*/
void
ModbusMaster::idle (void (*idle) ())
{
_idle = idle;
}
/**
Retrieve data from response buffer.
@see ModbusMaster::clearResponseBuffer()
@param u8Index index of response buffer array (0x00..0x3F)
@return value in position u8Index of response buffer (0x0000..0xFFFF)
@ingroup buffer
*/
uint16_t
ModbusMaster::getResponseBuffer (uint8_t u8Index)
{
if (u8Index < ku8MaxBufferSize)
{
return _u16ResponseBuffer[u8Index];
}
else
{
return 0xFFFF;
}
}
/**
Clear Modbus response buffer.
@see ModbusMaster::getResponseBuffer(uint8_t u8Index)
@ingroup buffer
*/
void
ModbusMaster::clearResponseBuffer ()
{
uint8_t i;
for (i = 0; i < ku8MaxBufferSize; i++)
{
_u16ResponseBuffer[i] = 0;
}
}
/**
Place data in transmit buffer.
@see ModbusMaster::clearTransmitBuffer()
@param u8Index index of transmit buffer array (0x00..0x3F)
@param u16Value value to place in position u8Index of transmit buffer
(0x0000..0xFFFF)
@return 0 on success; exception number on failure
@ingroup buffer
*/
uint8_t
ModbusMaster::setTransmitBuffer (uint8_t u8Index, uint16_t u16Value)
{
if (u8Index < ku8MaxBufferSize)
{
_u16TransmitBuffer[u8Index] = u16Value;
return ku8MBSuccess;
}
else
{
return ku8MBIllegalDataAddress;
}
}
/**
Clear Modbus transmit buffer.
@see ModbusMaster::setTransmitBuffer(uint8_t u8Index, uint16_t u16Value)
@ingroup buffer
*/
void
ModbusMaster::clearTransmitBuffer ()
{
uint8_t i;
for (i = 0; i < ku8MaxBufferSize; i++)
{
_u16TransmitBuffer[i] = 0;
}
}
/**
Modbus function 0x01 Read Coils.
This function code is used to read from 1 to 2000 contiguous status of
coils in a remote device. The request specifies the starting address,
i.e. the address of the first coil specified, and the number of coils.
Coils are addressed starting at zero.
The coils in the response buffer are packed as one coil per bit of the
data field. Status is indicated as 1=ON and 0=OFF. The LSB of the first
data word contains the output addressed in the query. The other coils
follow toward the high order end of this word and from low order to high
order in subsequent words.
If the returned quantity is not a multiple of sixteen, the remaining
bits in the final data word will be padded with zeros (toward the high
order end of the word).
@param u16ReadAddress address of first coil (0x0000..0xFFFF)
@param u16BitQty quantity of coils to read (1..2000, enforced by remote device)
@return 0 on success; exception number on failure
@ingroup discrete
*/
uint8_t
ModbusMaster::readCoils (uint16_t u16ReadAddress, uint16_t u16BitQty)
{
_u16ReadAddress = u16ReadAddress;
_u16ReadQty = u16BitQty;
return ModbusMasterTransaction (ku8MBReadCoils);
}
/**
Modbus function 0x02 Read Discrete Inputs.
This function code is used to read from 1 to 2000 contiguous status of
discrete inputs in a remote device. The request specifies the starting
address, i.e. the address of the first input specified, and the number
of inputs. Discrete inputs are addressed starting at zero.
The discrete inputs in the response buffer are packed as one input per
bit of the data field. Status is indicated as 1=ON; 0=OFF. The LSB of
the first data word contains the input addressed in the query. The other
inputs follow toward the high order end of this word, and from low order
to high order in subsequent words.
If the returned quantity is not a multiple of sixteen, the remaining
bits in the final data word will be padded with zeros (toward the high
order end of the word).
@param u16ReadAddress address of first discrete input (0x0000..0xFFFF)
@param u16BitQty quantity of discrete inputs to read (1..2000, enforced by
remote device)
@return 0 on success; exception number on failure
@ingroup discrete
*/
uint8_t
ModbusMaster::readDiscreteInputs (uint16_t u16ReadAddress, uint16_t u16BitQty)
{
_u16ReadAddress = u16ReadAddress;
_u16ReadQty = u16BitQty;
return ModbusMasterTransaction (ku8MBReadDiscreteInputs);
}
/**
Modbus function 0x03 Read Holding Registers.
This function code is used to read the contents of a contiguous block of
holding registers in a remote device. The request specifies the starting
register address and the number of registers. Registers are addressed
starting at zero.
The register data in the response buffer is packed as one word per
register.
@param u16ReadAddress address of the first holding register (0x0000..0xFFFF)
@param u16ReadQty quantity of holding registers to read (1..125, enforced by
remote device)
@return 0 on success; exception number on failure
@ingroup register
*/
uint8_t
ModbusMaster::readHoldingRegisters (uint16_t u16ReadAddress,
uint16_t u16ReadQty)
{
_u16ReadAddress = u16ReadAddress;
_u16ReadQty = u16ReadQty;
return ModbusMasterTransaction (ku8MBReadHoldingRegisters);
}
/**
Modbus function 0x04 Read Input Registers.
This function code is used to read from 1 to 125 contiguous input
registers in a remote device. The request specifies the starting
register address and the number of registers. Registers are addressed
starting at zero.
The register data in the response buffer is packed as one word per
register.
@param u16ReadAddress address of the first input register (0x0000..0xFFFF)
@param u16ReadQty quantity of input registers to read (1..125, enforced by
remote device)
@return 0 on success; exception number on failure
@ingroup register
*/
uint8_t
ModbusMaster::readInputRegisters (uint16_t u16ReadAddress, uint8_t u16ReadQty)
{
_u16ReadAddress = u16ReadAddress;
_u16ReadQty = u16ReadQty;
return ModbusMasterTransaction (ku8MBReadInputRegisters);
}
/**
Modbus function 0x05 Write Single Coil.
This function code is used to write a single output to either ON or OFF
in a remote device. The requested ON/OFF state is specified by a
constant in the state field. A non-zero value requests the output to be
ON and a value of 0 requests it to be OFF. The request specifies the
address of the coil to be forced. Coils are addressed starting at zero.
@param u16WriteAddress address of the coil (0x0000..0xFFFF)
@param u8State 0=OFF, non-zero=ON (0x00..0xFF)
@return 0 on success; exception number on failure
@ingroup discrete
*/
uint8_t
ModbusMaster::writeSingleCoil (uint16_t u16WriteAddress, uint8_t u8State)
{
_u16WriteAddress = u16WriteAddress;
_u16WriteQty = (u8State ? 0xFF00 : 0x0000);
return ModbusMasterTransaction (ku8MBWriteSingleCoil);
}
/**
Modbus function 0x06 Write Single Register.
This function code is used to write a single holding register in a
remote device. The request specifies the address of the register to be
written. Registers are addressed starting at zero.
@param u16WriteAddress address of the holding register (0x0000..0xFFFF)
@param u16WriteValue value to be written to holding register (0x0000..0xFFFF)
@return 0 on success; exception number on failure
@ingroup register
*/
uint8_t
ModbusMaster::writeSingleRegister (uint16_t u16WriteAddress,
uint16_t u16WriteValue)
{
_u16WriteAddress = u16WriteAddress;
_u16WriteQty = 0;
_u16TransmitBuffer[0] = u16WriteValue;
return ModbusMasterTransaction (ku8MBWriteSingleRegister);
}
/**
Modbus function 0x0F Write Multiple Coils.
This function code is used to force each coil in a sequence of coils to
either ON or OFF in a remote device. The request specifies the coil
references to be forced. Coils are addressed starting at zero.
The requested ON/OFF states are specified by contents of the transmit
buffer. A logical '1' in a bit position of the buffer requests the
corresponding output to be ON. A logical '0' requests it to be OFF.
@param u16WriteAddress address of the first coil (0x0000..0xFFFF)
@param u16BitQty quantity of coils to write (1..2000, enforced by remote
device)
@return 0 on success; exception number on failure
@ingroup discrete
*/
uint8_t
ModbusMaster::writeMultipleCoils (uint16_t u16WriteAddress, uint16_t u16BitQty)
{
_u16WriteAddress = u16WriteAddress;
_u16WriteQty = u16BitQty;
return ModbusMasterTransaction (ku8MBWriteMultipleCoils);
}
uint8_t
ModbusMaster::writeMultipleCoils ()
{
_u16WriteQty = u16TransmitBufferLength;
return ModbusMasterTransaction (ku8MBWriteMultipleCoils);
}
/**
Modbus function 0x10 Write Multiple Registers.
This function code is used to write a block of contiguous registers (1
to 123 registers) in a remote device.
The requested written values are specified in the transmit buffer. Data
is packed as one word per register.
@param u16WriteAddress address of the holding register (0x0000..0xFFFF)
@param u16WriteQty quantity of holding registers to write (1..123, enforced by
remote device)
@return 0 on success; exception number on failure
@ingroup register
*/
uint8_t
ModbusMaster::writeMultipleRegisters (uint16_t u16WriteAddress,
uint16_t u16WriteQty)
{
_u16WriteAddress = u16WriteAddress;
_u16WriteQty = u16WriteQty;
return ModbusMasterTransaction (ku8MBWriteMultipleRegisters);
}
// new version based on Wire.h
uint8_t
ModbusMaster::writeMultipleRegisters ()
{
_u16WriteQty = _u8TransmitBufferIndex;
return ModbusMasterTransaction (ku8MBWriteMultipleRegisters);
}
/**
Modbus function 0x16 Mask Write Register.
This function code is used to modify the contents of a specified holding
register using a combination of an AND mask, an OR mask, and the
register's current contents. The function can be used to set or clear
individual bits in the register.
The request specifies the holding register to be written, the data to be
used as the AND mask, and the data to be used as the OR mask. Registers
are addressed starting at zero.
The function's algorithm is:
Result = (Current Contents && And_Mask) || (Or_Mask && (~And_Mask))
@param u16WriteAddress address of the holding register (0x0000..0xFFFF)
@param u16AndMask AND mask (0x0000..0xFFFF)
@param u16OrMask OR mask (0x0000..0xFFFF)
@return 0 on success; exception number on failure
@ingroup register
*/
uint8_t
ModbusMaster::maskWriteRegister (uint16_t u16WriteAddress, uint16_t u16AndMask,
uint16_t u16OrMask)
{
_u16WriteAddress = u16WriteAddress;
_u16TransmitBuffer[0] = u16AndMask;
_u16TransmitBuffer[1] = u16OrMask;
return ModbusMasterTransaction (ku8MBMaskWriteRegister);
}
/**
Modbus function 0x17 Read Write Multiple Registers.
This function code performs a combination of one read operation and one
write operation in a single MODBUS transaction. The write operation is
performed before the read. Holding registers are addressed starting at
zero.
The request specifies the starting address and number of holding
registers to be read as well as the starting address, and the number of
holding registers. The data to be written is specified in the transmit
buffer.
@param u16ReadAddress address of the first holding register (0x0000..0xFFFF)
@param u16ReadQty quantity of holding registers to read (1..125, enforced by
remote device)
@param u16WriteAddress address of the first holding register (0x0000..0xFFFF)
@param u16WriteQty quantity of holding registers to write (1..121, enforced by
remote device)
@return 0 on success; exception number on failure
@ingroup register
*/
uint8_t
ModbusMaster::readWriteMultipleRegisters (uint16_t u16ReadAddress,
uint16_t u16ReadQty,
uint16_t u16WriteAddress,
uint16_t u16WriteQty)
{
_u16ReadAddress = u16ReadAddress;
_u16ReadQty = u16ReadQty;
_u16WriteAddress = u16WriteAddress;
_u16WriteQty = u16WriteQty;
return ModbusMasterTransaction (ku8MBReadWriteMultipleRegisters);
}
uint8_t
ModbusMaster::readWriteMultipleRegisters (uint16_t u16ReadAddress,
uint16_t u16ReadQty)
{
_u16ReadAddress = u16ReadAddress;
_u16ReadQty = u16ReadQty;
_u16WriteQty = _u8TransmitBufferIndex;
return ModbusMasterTransaction (ku8MBReadWriteMultipleRegisters);
}
/* _____PRIVATE FUNCTIONS____________________________________________________
*/
/**
Modbus transaction engine.
Sequence:
- assemble Modbus Request Application Data Unit (ADU),
based on particular function called
- transmit request over selected serial port
- wait for/retrieve response
- evaluate/disassemble response
- return status (success/exception)
@param u8MBFunction Modbus function (0x01..0xFF)
@return 0 on success; exception number on failure
*/
uint8_t
ModbusMaster::ModbusMasterTransaction (uint8_t u8MBFunction)
{
uint8_t u8ModbusADU[256];
uint8_t u8ModbusADUSize = 0;
uint8_t i, u8Qty;
uint16_t u16CRC;
uint32_t u32StartTime;
uint8_t u8BytesLeft = 8;
uint8_t u8MBStatus = ku8MBSuccess;
// assemble Modbus Request Application Data Unit
u8ModbusADU[u8ModbusADUSize++] = _u8MBSlave;
u8ModbusADU[u8ModbusADUSize++] = u8MBFunction;
switch (u8MBFunction)
{
case ku8MBReadCoils:
case ku8MBReadDiscreteInputs:
case ku8MBReadInputRegisters:
case ku8MBReadHoldingRegisters:
case ku8MBReadWriteMultipleRegisters:
u8ModbusADU[u8ModbusADUSize++] = highByte (_u16ReadAddress);
u8ModbusADU[u8ModbusADUSize++] = lowByte (_u16ReadAddress);
u8ModbusADU[u8ModbusADUSize++] = highByte (_u16ReadQty);
u8ModbusADU[u8ModbusADUSize++] = lowByte (_u16ReadQty);
break;
}
switch (u8MBFunction)
{
case ku8MBWriteSingleCoil:
case ku8MBMaskWriteRegister:
case ku8MBWriteMultipleCoils:
case ku8MBWriteSingleRegister:
case ku8MBWriteMultipleRegisters:
case ku8MBReadWriteMultipleRegisters:
u8ModbusADU[u8ModbusADUSize++] = highByte (_u16WriteAddress);
u8ModbusADU[u8ModbusADUSize++] = lowByte (_u16WriteAddress);
break;
}
switch (u8MBFunction)
{
case ku8MBWriteSingleCoil:
u8ModbusADU[u8ModbusADUSize++] = highByte (_u16WriteQty);
u8ModbusADU[u8ModbusADUSize++] = lowByte (_u16WriteQty);
break;
case ku8MBWriteSingleRegister:
u8ModbusADU[u8ModbusADUSize++] = highByte (_u16TransmitBuffer[0]);
u8ModbusADU[u8ModbusADUSize++] = lowByte (_u16TransmitBuffer[0]);
break;
case ku8MBWriteMultipleCoils:
u8ModbusADU[u8ModbusADUSize++] = highByte (_u16WriteQty);
u8ModbusADU[u8ModbusADUSize++] = lowByte (_u16WriteQty);
u8Qty = (_u16WriteQty % 8) ? ((_u16WriteQty >> 3) + 1)
: (_u16WriteQty >> 3);
u8ModbusADU[u8ModbusADUSize++] = u8Qty;
for (i = 0; i < u8Qty; i++)
{
switch (i % 2)
{
case 0: // i is even
u8ModbusADU[u8ModbusADUSize++]
= lowByte (_u16TransmitBuffer[i >> 1]);
break;
case 1: // i is odd
u8ModbusADU[u8ModbusADUSize++]
= highByte (_u16TransmitBuffer[i >> 1]);
break;
}
}
break;
case ku8MBWriteMultipleRegisters:
case ku8MBReadWriteMultipleRegisters:
u8ModbusADU[u8ModbusADUSize++] = highByte (_u16WriteQty);
u8ModbusADU[u8ModbusADUSize++] = lowByte (_u16WriteQty);
u8ModbusADU[u8ModbusADUSize++] = lowByte (_u16WriteQty << 1);
for (i = 0; i < lowByte (_u16WriteQty); i++)
{
u8ModbusADU[u8ModbusADUSize++] = highByte (_u16TransmitBuffer[i]);
u8ModbusADU[u8ModbusADUSize++] = lowByte (_u16TransmitBuffer[i]);
}
break;
case ku8MBMaskWriteRegister:
u8ModbusADU[u8ModbusADUSize++] = highByte (_u16TransmitBuffer[0]);
u8ModbusADU[u8ModbusADUSize++] = lowByte (_u16TransmitBuffer[0]);
u8ModbusADU[u8ModbusADUSize++] = highByte (_u16TransmitBuffer[1]);
u8ModbusADU[u8ModbusADUSize++] = lowByte (_u16TransmitBuffer[1]);
break;
}
// append CRC
u16CRC = 0xFFFF;
for (i = 0; i < u8ModbusADUSize; i++)
{
u16CRC = crc16_update (u16CRC, u8ModbusADU[i]);
}
u8ModbusADU[u8ModbusADUSize++] = lowByte (u16CRC);
u8ModbusADU[u8ModbusADUSize++] = highByte (u16CRC);
u8ModbusADU[u8ModbusADUSize] = 0;
// flush receive buffer before transmitting request
while (MBSerial->read () != -1)
;
#if 0
// transmit request
for (i = 0; i < u8ModbusADUSize; i++)
{
#if defined(ARDUINO) && ARDUINO >= 100
MBSerial->write(u8ModbusADU[i]);
#else
MBSerial->print(u8ModbusADU[i], BYTE);
#endif
}
#else
MBSerial->write ((char *)u8ModbusADU, u8ModbusADUSize);
#endif
// printf("TX: %02X\n", u8ModbusADU[0]);
u8ModbusADUSize = 0;
MBSerial->flush (); // flush transmit buffer
// loop until we run out of time or bytes, or an error occurs
u32StartTime = millis ();
while (u8BytesLeft && !u8MBStatus)
{
if (MBSerial->available ())
{
#if __MODBUSMASTER_DEBUG__
digitalWrite (4, true);
#endif
u8ModbusADU[u8ModbusADUSize++] = MBSerial->read ();
u8BytesLeft--;
#if __MODBUSMASTER_DEBUG__
digitalWrite (4, false);
#endif
}
else
{
#if __MODBUSMASTER_DEBUG__
digitalWrite (5, true);
#endif
if (_idle)
{
_idle ();
}
#if __MODBUSMASTER_DEBUG__
digitalWrite (5, false);
#endif
}
// evaluate slave ID, function code once enough bytes have been read
if (u8ModbusADUSize == 5)
{
// verify response is for correct Modbus slave
if (u8ModbusADU[0] != _u8MBSlave)
{
u8MBStatus = ku8MBInvalidSlaveID;
break;
}
// verify response is for correct Modbus function code (mask
// exception bit 7)
if ((u8ModbusADU[1] & 0x7F) != u8MBFunction)
{
u8MBStatus = ku8MBInvalidFunction;
break;
}
// check whether Modbus exception occurred; return Modbus Exception
// Code
if (bitRead (u8ModbusADU[1], 7))
{
u8MBStatus = u8ModbusADU[2];
break;
}
// evaluate returned Modbus function code
switch (u8ModbusADU[1])
{
case ku8MBReadCoils:
case ku8MBReadDiscreteInputs:
case ku8MBReadInputRegisters:
case ku8MBReadHoldingRegisters:
case ku8MBReadWriteMultipleRegisters:
u8BytesLeft = u8ModbusADU[2];
break;
case ku8MBWriteSingleCoil:
case ku8MBWriteMultipleCoils:
case ku8MBWriteSingleRegister:
case ku8MBWriteMultipleRegisters:
u8BytesLeft = 3;
break;
case ku8MBMaskWriteRegister:
u8BytesLeft = 5;
break;
}
}
if ((millis () - u32StartTime) > ku16MBResponseTimeout)
{
u8MBStatus = ku8MBResponseTimedOut;
}
}
// verify response is large enough to inspect further
if (!u8MBStatus && u8ModbusADUSize >= 5)
{
// calculate CRC
u16CRC = 0xFFFF;
for (i = 0; i < (u8ModbusADUSize - 2); i++)
{
u16CRC = crc16_update (u16CRC, u8ModbusADU[i]);
}
// verify CRC
if (!u8MBStatus
&& (lowByte (u16CRC) != u8ModbusADU[u8ModbusADUSize - 2]
|| highByte (u16CRC) != u8ModbusADU[u8ModbusADUSize - 1]))
{
u8MBStatus = ku8MBInvalidCRC;
}
}
// disassemble ADU into words
if (!u8MBStatus)
{
// evaluate returned Modbus function code
switch (u8ModbusADU[1])
{
case ku8MBReadCoils:
case ku8MBReadDiscreteInputs:
// load bytes into word; response bytes are ordered L, H, L, H, ...
for (i = 0; i < (u8ModbusADU[2] >> 1); i++)
{
if (i < ku8MaxBufferSize)
{
_u16ResponseBuffer[i]
= word (u8ModbusADU[2 * i + 4], u8ModbusADU[2 * i + 3]);
}
_u8ResponseBufferLength = i;
}
// in the event of an odd number of bytes, load last byte into
// zero-padded word
if (u8ModbusADU[2] % 2)
{
if (i < ku8MaxBufferSize)
{
_u16ResponseBuffer[i] = word (0, u8ModbusADU[2 * i + 3]);
}
_u8ResponseBufferLength = i + 1;
}
break;
case ku8MBReadInputRegisters:
case ku8MBReadHoldingRegisters:
case ku8MBReadWriteMultipleRegisters:
// load bytes into word; response bytes are ordered H, L, H, L, ...
for (i = 0; i < (u8ModbusADU[2] >> 1); i++)
{
if (i < ku8MaxBufferSize)
{
_u16ResponseBuffer[i]
= word (u8ModbusADU[2 * i + 3], u8ModbusADU[2 * i + 4]);
}
_u8ResponseBufferLength = i;
}
break;
}
}
_u8TransmitBufferIndex = 0;
u16TransmitBufferLength = 0;
_u8ResponseBufferIndex = 0;
return u8MBStatus;
}

View File

@ -1,29 +0,0 @@
#include "Modbus/ModbusRegister.h"
ModbusRegister::ModbusRegister(ModbusMaster *master, int address, bool holdingRegister)
:m(master), addr(address), hr(holdingRegister) {
// TODO Auto-generated constructor stub
}
ModbusRegister::~ModbusRegister() {
// TODO Auto-generated destructor stub
}
int ModbusRegister::read() {
uint8_t result = hr ? m->readHoldingRegisters(addr, 1) : m->readInputRegisters(addr, 1) ;
// check if we were able to read
if (result == m->ku8MBSuccess) {
return m->getResponseBuffer(0);
}
return -1;
}
void ModbusRegister::write(int value)
{
// write only if not
volatile uint8_t error = 15;
if(hr)
error = m->writeSingleRegister(addr, value);
}

View File

@ -1,49 +0,0 @@
#include "Modbus/SerialPort.h"
SerialPort::SerialPort() {
if(!u) {
LpcPinMap none = {-1, -1}; // unused pin has negative values in it
LpcPinMap txpin = { 0, 28 }; // transmit pin that goes to rs485 driver chip
LpcPinMap rxpin = { 0, 24 }; // receive pin that goes to rs485 driver chip
LpcPinMap rtspin = { 1, 0 }; // handshake pin that is used to set tranmitter direction
LpcUartConfig cfg = { LPC_USART1, 9600, UART_CFG_DATALEN_8 | UART_CFG_PARITY_NONE | UART_CFG_STOPLEN_2, true, txpin, rxpin, rtspin, none };
u = new LpcUart(cfg);
}
}
LpcUart *SerialPort::u = nullptr;
SerialPort::~SerialPort() {
/* DeInitialize UART peripheral */
delete u;
}
int SerialPort::available() {
return u->peek();
}
void SerialPort::begin(int speed) {
u->speed(speed);
}
int SerialPort::read() {
char byte;
if(u->read(byte)> 0) return (byte);
return -1;
}
int SerialPort::write(const char* buf, int len) {
return u->write(buf, len);
}
int SerialPort::print(int val, int format) {
// here only to maintain compatibility with Arduino interface
(void) val;
(void) format;
return (0);
}
void SerialPort::flush() {
while(!u->txempty()) __WFI();
}

View File

@ -1,214 +0,0 @@
#include <cstring>
#include "Modbus/Uart.h"
static LpcUart *u0;
static LpcUart *u1;
static LpcUart *u2;
extern "C" {
/**
* @brief UART interrupt handler using ring buffers
* @return Nothing
*/
void UART0_IRQHandler(void)
{
if(u0) u0->isr();
}
void UART1_IRQHandler(void)
{
if(u1) u1->isr();
}
void UART2_IRQHandler(void)
{
if(u2) u2->isr();
}
}
void LpcUart::isr() {
Chip_UART_IRQRBHandler(uart, &rxring, &txring);
}
bool LpcUart::init = false;
LpcUart::LpcUart(const LpcUartConfig &cfg) {
CHIP_SWM_PIN_MOVABLE_T tx;
CHIP_SWM_PIN_MOVABLE_T rx;
CHIP_SWM_PIN_MOVABLE_T cts;
CHIP_SWM_PIN_MOVABLE_T rts;
bool use_rts = (cfg.rts.port >= 0);
bool use_cts = (cfg.cts.port >= 0);
if(!init) {
init = true;
/* Before setting up the UART, the global UART clock for USARTS 1-4
* must first be setup. This requires setting the UART divider and
* the UART base clock rate to 16x the maximum UART rate for all
* UARTs.
* */
/* Use main clock rate as base for UART baud rate divider */
Chip_Clock_SetUARTBaseClockRate(Chip_Clock_GetMainClockRate(), false);
}
uart = nullptr; // set default value before checking which UART to configure
if(cfg.pUART == LPC_USART0) {
if(u0) return; // already exists
else u0 = this;
tx = SWM_UART0_TXD_O;
rx = SWM_UART0_RXD_I;
rts = SWM_UART0_RTS_O;
cts = SWM_UART0_CTS_I;
irqn = UART0_IRQn;
}
else if(cfg.pUART == LPC_USART1) {
if(u1) return; // already exists
else u1 = this;
tx = SWM_UART1_TXD_O;
rx = SWM_UART1_RXD_I;
rts = SWM_UART1_RTS_O;
cts = SWM_UART1_CTS_I;
irqn = UART1_IRQn;
}
else if(cfg.pUART == LPC_USART2) {
if(u2) return; // already exists
else u2 = this;
tx = SWM_UART2_TXD_O;
rx = SWM_UART2_RXD_I;
use_rts = false; // UART2 does not support handshakes
use_cts = false;
irqn = UART2_IRQn;
}
else {
return;
}
uart = cfg.pUART; // set the actual value after validity checking
if(cfg.tx.port >= 0) {
Chip_IOCON_PinMuxSet(LPC_IOCON, cfg.tx.port, cfg.tx.pin, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));
Chip_SWM_MovablePortPinAssign(tx, cfg.tx.port, cfg.tx.pin);
}
if(cfg.rx.port >= 0) {
Chip_IOCON_PinMuxSet(LPC_IOCON, cfg.rx.port, cfg.rx.pin, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));
Chip_SWM_MovablePortPinAssign(rx, cfg.rx.port, cfg.rx.pin);
}
if(use_cts) {
Chip_IOCON_PinMuxSet(LPC_IOCON, cfg.cts.port, cfg.cts.pin, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));
Chip_SWM_MovablePortPinAssign(cts, cfg.cts.port, cfg.cts.pin);
}
if(use_rts) {
Chip_IOCON_PinMuxSet(LPC_IOCON, cfg.rts.port, cfg.rts.pin, (IOCON_MODE_INACT | IOCON_DIGMODE_EN));
Chip_SWM_MovablePortPinAssign(rts, cfg.rts.port, cfg.rts.pin);
}
/* Setup UART */
Chip_UART_Init(uart);
Chip_UART_ConfigData(uart, cfg.data);
Chip_UART_SetBaud(uart, cfg.speed);
if(use_rts && cfg.rs485) {
uart->CFG |= (1 << 20); // enable rs485 mode
//uart->CFG |= (1 << 18); // OE turnaraound time
uart->CFG |= (1 << 21);// driver enable polarity (active high)
}
Chip_UART_Enable(uart);
Chip_UART_TXEnable(uart);
/* Before using the ring buffers, initialize them using the ring
buffer init function */
RingBuffer_Init(&rxring, rxbuff, 1, UART_RB_SIZE);
RingBuffer_Init(&txring, txbuff, 1, UART_RB_SIZE);
/* Enable receive data and line status interrupt */
Chip_UART_IntEnable(uart, UART_INTEN_RXRDY);
Chip_UART_IntDisable(uart, UART_INTEN_TXRDY); /* May not be needed */
/* Enable UART interrupt */
NVIC_EnableIRQ(irqn);
}
LpcUart::~LpcUart() {
if(uart != nullptr) {
NVIC_DisableIRQ(irqn);
Chip_UART_IntDisable(uart, UART_INTEN_RXRDY);
Chip_UART_IntDisable(uart, UART_INTEN_TXRDY);
if(uart == LPC_USART0) {
u0 = nullptr;
}
else if(uart == LPC_USART1) {
u1 = nullptr;
}
else if(uart == LPC_USART2) {
u2 = nullptr;
}
}
}
int LpcUart::free()
{
return RingBuffer_GetCount(&txring);;
}
int LpcUart::peek()
{
return RingBuffer_GetCount(&rxring);
}
int LpcUart::read(char &c)
{
return Chip_UART_ReadRB(uart, &rxring, &c, 1);
}
int LpcUart::read(char *buffer, int len)
{
return Chip_UART_ReadRB(uart, &rxring, buffer, len);
}
int LpcUart::write(char c)
{
return Chip_UART_SendRB(uart, &txring, &c, 1);
}
int LpcUart::write(const char *s)
{
return Chip_UART_SendRB(uart, &txring, s, strlen(s));
}
int LpcUart::write(const char *buffer, int len)
{
return Chip_UART_SendRB(uart, &txring, buffer, len);
}
void LpcUart::txbreak(bool brk)
{
// break handling not implemented yeet
}
bool LpcUart::rxbreak()
{
// break handling not implemented yeet
return false;
}
void LpcUart::speed(int bps)
{
Chip_UART_SetBaud(uart, bps);
}
bool LpcUart::txempty()
{
return (RingBuffer_GetCount(&txring) == 0);
}

View File

@ -1,80 +0,0 @@
/*
* PressureWrapper.cpp
*
* Created on: 5 Oct 2022
* Author: evgenymeshcheryakov
*/
#include "PressureWrapper.h"
#include <cstdio>
static uint8_t
crc8 (uint8_t *data, size_t size)
{
uint8_t crc = 0x00;
uint8_t byteCtr;
// calculates 8-Bit checksum with given polynomial
for (byteCtr = 0; byteCtr < size; ++byteCtr)
{
crc ^= (data[byteCtr]);
for (uint8_t bit = 8; bit > 0; --bit)
{
if (crc & 0x80)
crc = (crc << 1) ^ 0x131; // P(x)=x^8+x^5+x^4+1 = 0001 0011 0001
else
crc = (crc << 1);
}
}
return crc;
}
PressureWrapper::PressureWrapper ()
{
NVIC_DisableIRQ (I2C0_IRQn);
I2C_config config (0, 55000, 1309);
I2C i2c_c (config);
i2c = &i2c_c;
}
PressureWrapper::~PressureWrapper ()
{
// TODO Auto-generated destructor stub
}
int
PressureWrapper::getPressure ()
{
int16_t pressure = 0;
if (!getRawPressure ())
{
return -255;
}
if (crc8 (data.rBuffer, 2) == data.crc)
{
pressure = data.rBuffer[0];
pressure = pressure << 8;
pressure |= data.rBuffer[1];
float result = (float)pressure * 0.95 / 240;
return (int)result;
}
}
bool
PressureWrapper::isAwake ()
{
return getRawPressure();
}
void
PressureWrapper::wakeUp ()
{
uint8_t getMeasurementComm = 0xFE;
i2c->transaction (ADDRESS, &getMeasurementComm, 1, data.rBuffer, 3);
}
bool
PressureWrapper::getRawPressure ()
{
uint8_t getMeasurementComm = 0xF1;
return (i2c->transaction (ADDRESS, &getMeasurementComm, 1, data.rBuffer, 3));
}

View File

@ -1,67 +0,0 @@
/*
* Counter.cpp
*
* Created on: Sep 1, 2022
* Author: tylen
*/
#include "StateHandler/Counter.h"
void
Counter::inc ()
{
if (init < up_lim)
{
++init;
}
}
void
Counter::dec ()
{
if (init > down_lim)
{
--init;
}
}
unsigned int
Counter::getCurrent ()
{
return this->init;
}
Counter::Counter (unsigned int down, unsigned int up)
{
up_lim = up;
down_lim = down;
if (down > up)
{
init = up;
}
else if (down < 0)
{
init = 0;
}
else
{
init = down;
}
}
void
Counter::setInit (unsigned int newInit)
{
if (newInit > up_lim)
{
init = up_lim;
}
else if (newInit < down_lim)
{
init = down_lim;
}
else
{
init = newInit;
}
}

View File

@ -1,356 +0,0 @@
/*
* StateHandler.cpp
*
* Created on: Sep 21, 2022
* Author: tylen
*/
#include "StateHandler/StateHandler.h"
StateHandler::StateHandler (LiquidCrystal *lcd, Fan *propeller,
PressureWrapper *pressure, Timer *global)
{
this->_lcd = lcd;
this->_propeller = propeller;
this->_pressure = pressure;
this->state_timer = global;
current = &StateHandler::stateInit;
(this->*current) (Event (Event::eEnter));
current_mode = MANUAL;
sensor_mode = false;
pressure_achieved = 0;
}
StateHandler::~StateHandler ()
{
// TODO Auto-generated destructor stub
}
void
StateHandler::displaySet (size_t mode)
{
char line_up[LCD_SIZE] = { 0 };
char line_down[LCD_SIZE] = { 0 };
switch (mode)
{
case MANUAL:
snprintf (line_up, LCD_SIZE, "SPEED: %03d (M)",
saved_set_value[current_mode]);
snprintf (line_down, LCD_SIZE, "PRESSURE: %03dPa",
saved_curr_value[current_mode]);
break;
case AUTO:
snprintf (line_up, LCD_SIZE, "P.SET: %03dPa(A)",
saved_set_value[current_mode]);
snprintf (line_down, LCD_SIZE, "P.CURR: %03dPa",
saved_curr_value[current_mode]);
break;
case SENSORS:
snprintf (line_up, LCD_SIZE, "PRE:%03d TEM:%02d",
sensors_data[PRESSUREDAT], sensors_data[TEMPERATURE]);
snprintf (line_down, LCD_SIZE, "HUM:%02d CO2:%03d",
sensors_data[HUMIDITY], sensors_data[CO2]);
sensor_values_ready = false;
break;
case ERROR_TIMEOUT:
snprintf (line_up, LCD_SIZE, " FORCE STOP ");
snprintf (line_down, LCD_SIZE, "REASON: TIMEOUT");
break;
default:
break;
}
_lcd->clear ();
_lcd->printOnLineOne (line_up);
_lcd->printOnLineTwo (line_down);
}
unsigned int
StateHandler::getSetPressure ()
{
return (unsigned int)this->value[PRESSURE].getCurrent ();
}
unsigned int
StateHandler::getSetSpeed ()
{
return (unsigned int)this->value[FAN_SPEED].getCurrent ();
}
void
StateHandler::HandleState (const Event &event)
{
(this->*current) (event);
}
void
StateHandler::SetState (state_pointer newstate)
{
(this->*current) (Event (Event::eExit));
current = newstate;
(this->*current) (Event (Event::eEnter));
}
void
StateHandler::stateInit (const Event &event)
{
switch (event.type)
{
case Event::eEnter:
this->_propeller->spin (fan_speed_normalized ());
break;
case Event::eExit:
break;
case Event::eKey:
handleControlButtons (event.value);
break;
case Event::eTick:
if (current_mode == MANUAL)
{
SetState (&StateHandler::stateManual);
}
else
{
SetState (&StateHandler::stateAuto);
}
break;
}
}
void
StateHandler::stateManual (const Event &event)
{
switch (event.type)
{
case Event::eEnter:
displaySet (MANUAL);
break;
case Event::eExit:
break;
case Event::eKey:
handleControlButtons (event.value);
break;
case Event::eTick:
handleTickValue (event.value);
break;
}
}
void
StateHandler::stateAuto (const Event &event)
{
switch (event.type)
{
case Event::eEnter:
displaySet (AUTO);
break;
case Event::eExit:
break;
case Event::eKey:
handleControlButtons (event.value);
break;
case Event::eTick:
handleTickValue (event.value);
if (saved_set_value[AUTO])
{
pid ();
this->_propeller->spin (fan_speed.getCurrent ());
}
if (saved_curr_value[AUTO] == saved_set_value[AUTO])
{
++pressure_achieved;
}
if (pressure_achieved > 5)
{
pressure_achieved = 0;
task_is_pending = false;
}
break;
}
}
void
StateHandler::stateGetPressure (const Event &event)
{
switch (event.type)
{
case Event::eEnter:
pressure_status = _pressure->isAwake ();
break;
case Event::eExit:
break;
case Event::eKey:
handleControlButtons (event.value);
break;
case Event::eTick:
if (!pressure_status)
{
_pressure->wakeUp ();
break;
}
savePressureAndDisplay (_pressure->getPressure (),
((current_mode) ? AUTO : MANUAL));
SetState (current_mode ? &StateHandler::stateAuto
: &StateHandler::stateManual);
break;
}
}
void
StateHandler::stateShowSensors (const Event &event)
{
switch (event.type)
{
case Event::eEnter:
displaySet (SENSORS);
break;
case Event::eExit:
break;
case Event::eKey:
handleControlButtons (event.value);
break;
case Event::eTick:
handleTickValue (event.value);
if (sensor_values_ready)
{
displaySet (SENSORS);
}
if (!sensor_mode)
{
SetState (&StateHandler::stateInit);
}
break;
}
}
void
StateHandler::handleControlButtons (uint8_t button)
{
task_is_pending = true;
error_timer = 0;
switch (button)
{
case BUTTON_CONTROL_DOWN:
this->value[(current_mode)].dec ();
state_timer->resetCounter ();
break;
case BUTTON_CONTROL_UP:
this->value[(current_mode)].inc ();
state_timer->resetCounter ();
break;
case BUTTON_CONTROL_TOG_MODE:
current_mode = !current_mode;
SetState (&StateHandler::stateInit);
state_timer->resetCounter ();
return;
break;
case BUTTON_CONTROL_TOG_ACTIVE:
task_is_pending = false;
sensor_mode = !sensor_mode;
SetState (&StateHandler::stateShowSensors);
return;
break;
default:
break;
}
if (current_mode == MANUAL && saveSetAndDisplay (MANUAL))
{
this->_propeller->spin (fan_speed_normalized ());
}
else
{
saveSetAndDisplay (AUTO);
}
}
void
StateHandler::handleTickValue (int value)
{
if (sensor_timer > TIMER_SENSORS_TIMEOUT && sensor_mode)
{
updateSensorValues ();
sensor_timer = 0;
}
if (value > TIMER_PRESSURE_TIMEOUT)
{
if (!(saved_curr_value[current_mode] == 0
&& saved_set_value[current_mode] == 0)
&& !sensor_mode)
{
SetState (&StateHandler::stateGetPressure);
}
sensor_timer += value;
error_timer += value;
state_timer->resetCounter ();
}
if (error_timer > TIMER_GLOBAL_TIMEOUT && task_is_pending && !sensor_mode)
{
this->fan_speed.setInit (0);
this->value[(current_mode)].setInit (0);
integral = 0;
saveSetAndDisplay (AUTO);
displaySet (ERROR_TIMEOUT);
state_timer->Sleep (2000);
state_timer->resetCounter ();
error_timer = 0;
SetState (&StateHandler::stateInit);
}
}
void
StateHandler::savePressureAndDisplay (int pressure, size_t mode)
{
if (saved_curr_value[mode] != pressure)
{
saved_curr_value[mode] = pressure;
displaySet (mode);
}
}
bool
StateHandler::saveSetAndDisplay (size_t mode)
{
int counterValue = value[mode].getCurrent ();
if (saved_set_value[mode] != counterValue)
{
saved_set_value[mode] = counterValue;
displaySet (mode);
return true;
}
return false;
}
int
StateHandler::fan_speed_normalized ()
{
int speed = value[MANUAL].getCurrent ();
if (speed <= 95)
speed += 5;
return speed * 10;
}
void
StateHandler::pid ()
{
float kP = 0.6, kI = 0.05, kD = 0.125;
int error = 0, last_error = 0, derivative = 0;
error = saved_set_value[AUTO] - saved_curr_value[AUTO];
last_error = error;
integral += error;
derivative = error - last_error;
fan_speed.setInit ((kP * error) + (kI * integral) + (kD * derivative));
}
void
StateHandler::updateSensorValues ()
{
if (!sensor_values_ready)
{
sensors_data[TEMPERATURE] = humidity.readT ();
sensors_data[PRESSUREDAT] = _pressure->getPressure ();
sensors_data[CO2] = co2.read ();
state_timer->tickCounter (5);
sensors_data[HUMIDITY] = humidity.readRH ();
sensor_values_ready = true;
}
}

View File

@ -1,38 +0,0 @@
/*
* SwitchController.cpp
*
* Created on: Oct 17, 2022
* Author: tylen
*/
#include "SwitchController.h"
SwitchController::SwitchController (DigitalIoPin *button,
StateHandler *handler, int button_mode)
{
b = button;
h = handler;
b_pressed = false;
b_mode = button_mode;
}
SwitchController::~SwitchController ()
{
// TODO Auto-generated destructor stub
}
void
SwitchController::listen ()
{
/** Button is pressed for the first time */
if (b->read () && !b_pressed)
{
h->HandleState (Event (Event::eKey, b_mode));
b_pressed = true;
}
/** Button is released */
if (!b->read () && b_pressed)
{
b_pressed = false;
}
}

View File

@ -1,78 +0,0 @@
/*
* Timer.cpp
*
* Created on: Oct 14, 2022
* Author: tylen
*/
#include <Timer.h>
extern "C"
{
void
SysTick_Handler (void)
{
systicks++;
if (timer > 0)
timer--;
}
}
Timer::Timer (uint32_t freq, bool setup) : freq (freq), mode (setup)
{
if (mode)
{
Chip_Clock_SetSysTickClockDiv (1);
uint32_t sysTickRate = Chip_Clock_GetSysTickClockRate ();
SysTick_Config (sysTickRate / freq);
}
resetCounter ();
timer = 0;
prev_ticks = 0;
systicks.store (0, std::memory_order_relaxed);
}
Timer::~Timer ()
{
// TODO Auto-generated destructor stub
}
void
Timer::tickCounter (int ms)
{
if (counter >= INT_MAX)
{
resetCounter ();
}
Sleep (ms);
counter += (systicks - prev_ticks);
prev_ticks = systicks;
}
void
Timer::Sleep (int ms)
{
timer = ms;
while (timer > 0)
{
__WFI ();
}
}
int
Timer::getCounter ()
{
return counter.load (std::memory_order_relaxed);
}
void
Timer::resetCounter ()
{
counter.store (0, std::memory_order_relaxed);
}
uint32_t
millis ()
{
return systicks.load (std::memory_order_relaxed);
}

View File

@ -8,81 +8,39 @@
===============================================================================
*/
#include "DigitalIoPin.h"
#include "Fan.h"
#include "LiquidCrystal.h"
#include "PressureWrapper.h"
#include "StateHandler/StateHandler.h"
#include "SwitchController.h"
#include "Timer.h"
#include "board.h"
#if defined(__USE_LPCOPEN)
#if defined(NO_BOARD_LIB)
#include "chip.h"
#include "common_control_values.h"
#else
#include "board.h"
#endif
#endif
#include <cr_section_macros.h>
// TODO: insert other include files here
// TODO: insert other definitions and declarations here
int
main (void)
{
/* Board init */
#if defined(__USE_LPCOPEN)
// Read clock settings and update SystemCoreClock variable
SystemCoreClockUpdate ();
#if !defined(NO_BOARD_LIB)
// Set up and initialize all required blocks and
// functions related to the board hardware
Board_Init ();
// Set the LED to the state of "On"
Board_LED_Set (0, true);
#endif
#endif
/** LCD setup */
Chip_RIT_Init (LPC_RITIMER);
DigitalIoPin rs (0, 29, false, true, false);
DigitalIoPin en (0, 9, false, true, false);
DigitalIoPin d4 (0, 10, false, true, false);
DigitalIoPin d5 (0, 16, false, true, false);
DigitalIoPin d6 (1, 3, false, true, false);
DigitalIoPin d7 (0, 0, false, true, false);
LiquidCrystal lcd (&rs, &en, &d4, &d5, &d6, &d7);
lcd.clear ();
lcd.printOnLineOne (" ESP-VENT_MAIN ");
/* Timers */
Timer glob_time (ONE_K_HZ, true);
/* Currently not used, but if we have time left,
* quick button increment is needed
* Timer switch_time (ONE_K_HZ, false);
*/
/* Modbus Fan setup */
ModbusMaster fan (1);
fan.begin (9600);
Fan propeller (new ModbusRegister (&fan, 0));
/* Pressure sensor setup */
PressureWrapper sens;
glob_time.Sleep (1000);
/* State Machine */
StateHandler ventMachine (&lcd, &propeller, &sens, &glob_time);
/** Control switches */
DigitalIoPin b_up (0, 7, true, true, true); // A5
SwitchController sw_up (&b_up, &ventMachine, BUTTON_CONTROL_UP);
DigitalIoPin b_down (0, 6, true, true, true); // A4
SwitchController sw_down (&b_down, &ventMachine, BUTTON_CONTROL_DOWN);
DigitalIoPin b_toggle (0, 5, true, true, true); // A3
SwitchController sw_toggle (&b_toggle, &ventMachine,
BUTTON_CONTROL_TOG_MODE);
DigitalIoPin b_toggle_sens (1, 8, true, true, true); // A3
SwitchController sw_toggle_sens (&b_toggle_sens, &ventMachine,
BUTTON_CONTROL_TOG_ACTIVE);
/* Other declarations */
int getcounterValue;
while (1)
{
getcounterValue = glob_time.getCounter ();
sw_up.listen ();
sw_down.listen ();
sw_toggle.listen ();
sw_toggle_sens.listen();
ventMachine.HandleState (Event (Event::eTick, getcounterValue));
glob_time.tickCounter (1);
}
return 0;
}

View File

@ -1,49 +0,0 @@
/*
* serial_port.cpp
*
* Created on: 25.8.2021
* Author: keijo
*/
#include "../inc/Modbus/Uart.h"
#include "serial_port.h"
#ifdef __cplusplus
extern "C" {
#endif
static LpcUart *EspUart;
void serial_init(void *ctx)
{
LpcPinMap none = {-1, -1}; // unused pin has negative values in it
LpcPinMap txpin_esp = { 0, 8 }; // transmit pin
LpcPinMap rxpin_esp = { 1, 6 }; // receive pin
LpcUartConfig cfg = { LPC_USART2, 115200, UART_CFG_DATALEN_8 | UART_CFG_PARITY_NONE | UART_CFG_STOPLEN_1, false, txpin_esp, rxpin_esp, none, none };
EspUart = new LpcUart(cfg);
}
void serial_write_buf(void *ctx, const char *buf, int len)
{
EspUart->write(buf, len);
}
void serial_write_str(void *ctx, const char *s)
{
EspUart->write(s);
}
int serial_get_char(void *ctx, char *p)
{
return EspUart->read(*p);
}
int serial_peek(void *ctx)
{
return EspUart->peek();
}
#ifdef __cplusplus
}
#endif

View File

@ -11,13 +11,13 @@
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
@ -28,18 +28,18 @@
<builder buildPath="${workspace_loc:/lpc_board_nxp_lpcxpresso_1549}/Debug" id="com.crt.advproject.builder.lib.debug.1299423428" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.debug"/>
<tool id="com.crt.advproject.cpp.lib.debug.675557742" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.debug"/>
<tool id="com.crt.advproject.gcc.lib.debug.326990449" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.debug">
<option id="com.crt.advproject.gcc.arch.482614676" name="Architecture" superClass="com.crt.advproject.gcc.arch" useByScannerDiscovery="true" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.thumb.448897723" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.1357926608" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<option id="com.crt.advproject.gcc.arch.482614676" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.thumb.448897723" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1357926608" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="__REDLIB__"/>
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
</option>
<option id="gnu.c.compiler.option.misc.other.318258873" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="com.crt.advproject.gcc.hdrlib.2102792065" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Redlib" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.2082452274" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<option id="gnu.c.compiler.option.misc.other.318258873" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="com.crt.advproject.gcc.hdrlib.2102792065" superClass="com.crt.advproject.gcc.hdrlib" value="Redlib" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.2082452274" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
</option>
@ -74,13 +74,13 @@
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
@ -139,7 +139,7 @@
<storageModule moduleId="com.crt.config">
<projectStorage>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&#13;
&lt;TargetConfig&gt;&#13;
&lt;Properties property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="100300"/&gt;&#13;
&lt;Properties property_0="" property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="70200"/&gt;&#13;
&lt;infoList vendor="NXP"&gt;&#13;
&lt;info chip="LPC1549" connectscript="LPC15RunBootRomConnect.scp" flash_driver="LPC15xx_256K.cfx" match_id="0x0" name="LPC1549" resetscript="LPC15RunBootRomReset.scp" stub="crt_emu_cm3_gen"&gt;&#13;
&lt;chip&gt;&#13;
@ -155,15 +155,52 @@
&lt;memoryInstance derived_from="RAM" id="Ram0_16" location="0x2000000" size="0x4000"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" id="Ram1_16" location="0x2004000" size="0x4000"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" id="Ram2_4" location="0x2008000" size="0x1000"/&gt;&#13;
&lt;peripheralInstance derived_from="V7M_MPU" determined="infoFile" id="MPU" location="0xe000ed90"/&gt;&#13;
&lt;peripheralInstance derived_from="V7M_NVIC" determined="infoFile" id="NVIC" location="0xe000e000"/&gt;&#13;
&lt;peripheralInstance derived_from="V7M_DCR" determined="infoFile" id="DCR" location="0xe000edf0"/&gt;&#13;
&lt;peripheralInstance derived_from="V7M_ITM" determined="infoFile" id="ITM" location="0xe0000000"/&gt;&#13;
&lt;peripheralInstance derived_from="GPIO-PORT" determined="infoFile" id="GPIO-PORT" location="0x1c000000"/&gt;&#13;
&lt;peripheralInstance derived_from="DMA" determined="infoFile" id="DMA" location="0x1c004000"/&gt;&#13;
&lt;peripheralInstance derived_from="USB" determined="infoFile" id="USB" location="0x1c00c000"/&gt;&#13;
&lt;peripheralInstance derived_from="CRC" determined="infoFile" id="CRC" location="0x1c010000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCT0" determined="infoFile" id="SCT0" location="0x1c018000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCT1" determined="infoFile" id="SCT1" location="0x1c01c000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCT2" determined="infoFile" id="SCT2" location="0x1c020000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCT3" determined="infoFile" id="SCT3" location="0x1c024000"/&gt;&#13;
&lt;peripheralInstance derived_from="ADC0" determined="infoFile" id="ADC0" location="0x40000000"/&gt;&#13;
&lt;peripheralInstance derived_from="DAC" determined="infoFile" id="DAC" location="0x40004000"/&gt;&#13;
&lt;peripheralInstance derived_from="ACMP" determined="infoFile" id="ACMP" location="0x40008000"/&gt;&#13;
&lt;peripheralInstance derived_from="INMUX" determined="infoFile" id="INMUX" location="0x40014000"/&gt;&#13;
&lt;peripheralInstance derived_from="RTC" determined="infoFile" id="RTC" location="0x40028000"/&gt;&#13;
&lt;peripheralInstance derived_from="WWDT" determined="infoFile" id="WWDT" location="0x4002c000"/&gt;&#13;
&lt;peripheralInstance derived_from="SWM" determined="infoFile" id="SWM" location="0x40038000"/&gt;&#13;
&lt;peripheralInstance derived_from="PMU" determined="infoFile" id="PMU" location="0x4003c000"/&gt;&#13;
&lt;peripheralInstance derived_from="USART0" determined="infoFile" id="USART0" location="0x40040000"/&gt;&#13;
&lt;peripheralInstance derived_from="USART1" determined="infoFile" id="USART1" location="0x40044000"/&gt;&#13;
&lt;peripheralInstance derived_from="SPI0" determined="infoFile" id="SPI0" location="0x40048000"/&gt;&#13;
&lt;peripheralInstance derived_from="SPI1" determined="infoFile" id="SPI1" location="0x4004c000"/&gt;&#13;
&lt;peripheralInstance derived_from="I2C0" determined="infoFile" id="I2C0" location="0x40050000"/&gt;&#13;
&lt;peripheralInstance derived_from="QEI" determined="infoFile" id="QEI" location="0x40058000"/&gt;&#13;
&lt;peripheralInstance derived_from="SYSCON" determined="infoFile" id="SYSCON" location="0x40074000"/&gt;&#13;
&lt;peripheralInstance derived_from="ADC1" determined="infoFile" id="ADC1" location="0x40080000"/&gt;&#13;
&lt;peripheralInstance derived_from="MRT" determined="infoFile" id="MRT" location="0x400a0000"/&gt;&#13;
&lt;peripheralInstance derived_from="PINT" determined="infoFile" id="PINT" location="0x400a4000"/&gt;&#13;
&lt;peripheralInstance derived_from="GINT0" determined="infoFile" id="GINT0" location="0x400a8000"/&gt;&#13;
&lt;peripheralInstance derived_from="GINT1" determined="infoFile" id="GINT1" location="0x400ac000"/&gt;&#13;
&lt;peripheralInstance derived_from="RIT" determined="infoFile" id="RIT" location="0x400b4000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCTIPU" determined="infoFile" id="SCTIPU" location="0x400b8000"/&gt;&#13;
&lt;peripheralInstance derived_from="FLASHCTRL" determined="infoFile" id="FLASHCTRL" location="0x400bc000"/&gt;&#13;
&lt;peripheralInstance derived_from="USART2" determined="infoFile" id="USART2" location="0x400c0000"/&gt;&#13;
&lt;peripheralInstance derived_from="C-CAN0" determined="infoFile" id="C-CAN0" location="0x400f0000"/&gt;&#13;
&lt;peripheralInstance derived_from="IOCON" determined="infoFile" id="IOCON" location="0x400f8000"/&gt;&#13;
&lt;/chip&gt;&#13;
&lt;processor&gt;&#13;
&lt;name gcc_name="cortex-m3"&gt;Cortex-M3&lt;/name&gt;&#13;
&lt;family&gt;Cortex-M&lt;/family&gt;&#13;
&lt;/processor&gt;&#13;
&lt;link href="LPC15xx_peripheral.xme" show="embed" type="simple"/&gt;&#13;
&lt;/info&gt;&#13;
&lt;/infoList&gt;&#13;
&lt;/TargetConfig&gt;</projectStorage>
</storageModule>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="com.crt.advproject"/>
</cproject>

View File

@ -4,7 +4,7 @@
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="com.crt.advproject.GCCBuildCommandParser" keep-relative-paths="false" name="MCU GCC Build Output Parser" parameter="(arm-none-eabi-gcc)|(arm-none-eabi-[gc]\+\+)|(gcc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="261963773744572127" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="1861603930977800923" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -15,7 +15,7 @@
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider copy-of="extension" id="com.crt.advproject.GCCBuildCommandParser"/>
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="308390835871665599" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="1916695446368863867" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

View File

@ -11,13 +11,13 @@
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
@ -28,20 +28,20 @@
<builder buildPath="${workspace_loc:/lpc_chip_15xx}/Debug" id="com.crt.advproject.builder.lib.debug.274234764" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.debug"/>
<tool id="com.crt.advproject.cpp.lib.debug.71038877" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.debug"/>
<tool id="com.crt.advproject.gcc.lib.debug.1467274336" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.debug">
<option id="com.crt.advproject.gcc.arch.1716932413" name="Architecture" superClass="com.crt.advproject.gcc.arch" useByScannerDiscovery="true" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.thumb.1394882702" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.1812568998" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<option id="com.crt.advproject.gcc.arch.1716932413" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.thumb.1394882702" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1812568998" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="__REDLIB__"/>
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
</option>
<option id="gnu.c.compiler.option.misc.other.876640281" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.1417153574" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<option id="gnu.c.compiler.option.misc.other.876640281" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="gnu.c.compiler.option.include.paths.1417153574" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
</option>
<option id="com.crt.advproject.gcc.hdrlib.804406863" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Redlib" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.hdrlib.804406863" superClass="com.crt.advproject.gcc.hdrlib" value="Redlib" valueType="enumerated"/>
<inputType id="com.crt.advproject.compiler.input.1802839902" superClass="com.crt.advproject.compiler.input"/>
</tool>
<tool id="com.crt.advproject.gas.lib.debug.603923349" name="MCU Assembler" superClass="com.crt.advproject.gas.lib.debug">
@ -73,13 +73,13 @@
</externalSetting>
</externalSettings>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
@ -137,7 +137,7 @@
<storageModule moduleId="com.crt.config">
<projectStorage>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&#13;
&lt;TargetConfig&gt;&#13;
&lt;Properties property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="100300"/&gt;&#13;
&lt;Properties property_0="" property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="70200"/&gt;&#13;
&lt;infoList vendor="NXP"&gt;&#13;
&lt;info chip="LPC1549" connectscript="LPC15RunBootRomConnect.scp" flash_driver="LPC15xx_256K.cfx" match_id="0x0" name="LPC1549" resetscript="LPC15RunBootRomReset.scp" stub="crt_emu_cm3_gen"&gt;&#13;
&lt;chip&gt;&#13;
@ -153,16 +153,52 @@
&lt;memoryInstance derived_from="RAM" id="Ram0_16" location="0x2000000" size="0x4000"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" id="Ram1_16" location="0x2004000" size="0x4000"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" id="Ram2_4" location="0x2008000" size="0x1000"/&gt;&#13;
&lt;peripheralInstance derived_from="V7M_MPU" determined="infoFile" id="MPU" location="0xe000ed90"/&gt;&#13;
&lt;peripheralInstance derived_from="V7M_NVIC" determined="infoFile" id="NVIC" location="0xe000e000"/&gt;&#13;
&lt;peripheralInstance derived_from="V7M_DCR" determined="infoFile" id="DCR" location="0xe000edf0"/&gt;&#13;
&lt;peripheralInstance derived_from="V7M_ITM" determined="infoFile" id="ITM" location="0xe0000000"/&gt;&#13;
&lt;peripheralInstance derived_from="GPIO-PORT" determined="infoFile" id="GPIO-PORT" location="0x1c000000"/&gt;&#13;
&lt;peripheralInstance derived_from="DMA" determined="infoFile" id="DMA" location="0x1c004000"/&gt;&#13;
&lt;peripheralInstance derived_from="USB" determined="infoFile" id="USB" location="0x1c00c000"/&gt;&#13;
&lt;peripheralInstance derived_from="CRC" determined="infoFile" id="CRC" location="0x1c010000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCT0" determined="infoFile" id="SCT0" location="0x1c018000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCT1" determined="infoFile" id="SCT1" location="0x1c01c000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCT2" determined="infoFile" id="SCT2" location="0x1c020000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCT3" determined="infoFile" id="SCT3" location="0x1c024000"/&gt;&#13;
&lt;peripheralInstance derived_from="ADC0" determined="infoFile" id="ADC0" location="0x40000000"/&gt;&#13;
&lt;peripheralInstance derived_from="DAC" determined="infoFile" id="DAC" location="0x40004000"/&gt;&#13;
&lt;peripheralInstance derived_from="ACMP" determined="infoFile" id="ACMP" location="0x40008000"/&gt;&#13;
&lt;peripheralInstance derived_from="INMUX" determined="infoFile" id="INMUX" location="0x40014000"/&gt;&#13;
&lt;peripheralInstance derived_from="RTC" determined="infoFile" id="RTC" location="0x40028000"/&gt;&#13;
&lt;peripheralInstance derived_from="WWDT" determined="infoFile" id="WWDT" location="0x4002c000"/&gt;&#13;
&lt;peripheralInstance derived_from="SWM" determined="infoFile" id="SWM" location="0x40038000"/&gt;&#13;
&lt;peripheralInstance derived_from="PMU" determined="infoFile" id="PMU" location="0x4003c000"/&gt;&#13;
&lt;peripheralInstance derived_from="USART0" determined="infoFile" id="USART0" location="0x40040000"/&gt;&#13;
&lt;peripheralInstance derived_from="USART1" determined="infoFile" id="USART1" location="0x40044000"/&gt;&#13;
&lt;peripheralInstance derived_from="SPI0" determined="infoFile" id="SPI0" location="0x40048000"/&gt;&#13;
&lt;peripheralInstance derived_from="SPI1" determined="infoFile" id="SPI1" location="0x4004c000"/&gt;&#13;
&lt;peripheralInstance derived_from="I2C0" determined="infoFile" id="I2C0" location="0x40050000"/&gt;&#13;
&lt;peripheralInstance derived_from="QEI" determined="infoFile" id="QEI" location="0x40058000"/&gt;&#13;
&lt;peripheralInstance derived_from="SYSCON" determined="infoFile" id="SYSCON" location="0x40074000"/&gt;&#13;
&lt;peripheralInstance derived_from="ADC1" determined="infoFile" id="ADC1" location="0x40080000"/&gt;&#13;
&lt;peripheralInstance derived_from="MRT" determined="infoFile" id="MRT" location="0x400a0000"/&gt;&#13;
&lt;peripheralInstance derived_from="PINT" determined="infoFile" id="PINT" location="0x400a4000"/&gt;&#13;
&lt;peripheralInstance derived_from="GINT0" determined="infoFile" id="GINT0" location="0x400a8000"/&gt;&#13;
&lt;peripheralInstance derived_from="GINT1" determined="infoFile" id="GINT1" location="0x400ac000"/&gt;&#13;
&lt;peripheralInstance derived_from="RIT" determined="infoFile" id="RIT" location="0x400b4000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCTIPU" determined="infoFile" id="SCTIPU" location="0x400b8000"/&gt;&#13;
&lt;peripheralInstance derived_from="FLASHCTRL" determined="infoFile" id="FLASHCTRL" location="0x400bc000"/&gt;&#13;
&lt;peripheralInstance derived_from="USART2" determined="infoFile" id="USART2" location="0x400c0000"/&gt;&#13;
&lt;peripheralInstance derived_from="C-CAN0" determined="infoFile" id="C-CAN0" location="0x400f0000"/&gt;&#13;
&lt;peripheralInstance derived_from="IOCON" determined="infoFile" id="IOCON" location="0x400f8000"/&gt;&#13;
&lt;/chip&gt;&#13;
&lt;processor&gt;&#13;
&lt;name gcc_name="cortex-m3"&gt;Cortex-M3&lt;/name&gt;&#13;
&lt;family&gt;Cortex-M&lt;/family&gt;&#13;
&lt;/processor&gt;&#13;
&lt;link href="LPC15xx_peripheral.xme" show="embed" type="simple"/&gt;&#13;
&lt;/info&gt;&#13;
&lt;/infoList&gt;&#13;
&lt;/TargetConfig&gt;</projectStorage>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="com.crt.advproject"/>
</cproject>

View File

@ -4,7 +4,7 @@
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="com.crt.advproject.GCCBuildCommandParser" keep-relative-paths="false" name="MCU GCC Build Output Parser" parameter="(arm-none-eabi-gcc)|(arm-none-eabi-[gc]\+\+)|(gcc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="261963773744572127" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="1861603930977800923" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -15,7 +15,7 @@
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider copy-of="extension" id="com.crt.advproject.GCCBuildCommandParser"/>
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="308390835871665599" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.crt.advproject.specs.MCUGCCBuiltinSpecsDetector" console="false" env-hash="1916695446368863867" id="com.crt.advproject.GCCBuildSpecCompilerParser" keep-relative-paths="false" name="MCU GCC Built-in Compiler Parser" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

View File

@ -5,13 +5,13 @@
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.exe.debug.1544523192" moduleId="org.eclipse.cdt.core.settings" name="Debug">
<externalSettings/>
<extensions>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
@ -22,19 +22,19 @@
<builder buildPath="${workspace_loc:/periph_blinky}/Debug" id="com.crt.advproject.builder.exe.debug.897034956" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.exe.debug"/>
<tool id="com.crt.advproject.cpp.exe.debug.886624700" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.exe.debug"/>
<tool id="com.crt.advproject.gcc.exe.debug.1985696782" name="MCU C Compiler" superClass="com.crt.advproject.gcc.exe.debug">
<option id="com.crt.advproject.gcc.arch.484897432" name="Architecture" superClass="com.crt.advproject.gcc.arch" useByScannerDiscovery="true" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.thumb.1230538196" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.524065126" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<option id="com.crt.advproject.gcc.arch.484897432" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.thumb.1230538196" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.524065126" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__REDLIB__"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
</option>
<option id="gnu.c.compiler.option.misc.other.1665733234" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="com.crt.advproject.gcc.hdrlib.95117550" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Redlib" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.specs.483357137" superClass="com.crt.advproject.gcc.specs" useByScannerDiscovery="false" value="com.crt.advproject.gcc.specs.codered" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.134237894" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<option id="gnu.c.compiler.option.misc.other.1665733234" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="com.crt.advproject.gcc.hdrlib.95117550" superClass="com.crt.advproject.gcc.hdrlib" value="Redlib" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.specs.483357137" superClass="com.crt.advproject.gcc.specs" value="com.crt.advproject.gcc.specs.codered" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.134237894" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
</option>
@ -51,37 +51,30 @@
</tool>
<tool id="com.crt.advproject.link.cpp.exe.debug.1021463268" name="MCU C++ Linker" superClass="com.crt.advproject.link.cpp.exe.debug"/>
<tool id="com.crt.advproject.link.exe.debug.572212861" name="MCU Linker" superClass="com.crt.advproject.link.exe.debug">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.crt.advproject.link.gcc.multicore.master.userobjs.1911822053" name="Slave Objects (not visible)" superClass="com.crt.advproject.link.gcc.multicore.master.userobjs" valueType="userObjs"/>
<option id="com.crt.advproject.link.gcc.multicore.master.userobjs.1911822053" name="Slave Objects (not visible)" superClass="com.crt.advproject.link.gcc.multicore.master.userobjs" valueType="userObjs"/>
<option id="com.crt.advproject.link.arch.381078876" name="Architecture" superClass="com.crt.advproject.link.arch" value="com.crt.advproject.link.target.cm3" valueType="enumerated"/>
<option id="com.crt.advproject.link.thumb.1562809738" name="Thumb mode" superClass="com.crt.advproject.link.thumb" value="true" valueType="boolean"/>
<option id="com.crt.advproject.link.script.952960727" name="Linker script" superClass="com.crt.advproject.link.script" value="&quot;periph_blinky_Debug.ld&quot;" valueType="string"/>
<option id="com.crt.advproject.link.manage.1969960328" name="Manage linker script" superClass="com.crt.advproject.link.manage" value="true" valueType="boolean"/>
<option id="gnu.c.link.option.nostdlibs.2067876226" name="No startup or default libs (-nostdlib)" superClass="gnu.c.link.option.nostdlibs" value="true" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.other.117531896" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList">
<option id="gnu.c.link.option.other.117531896" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList">
<listOptionValue builtIn="false" value="-Map=&quot;${BuildArtifactFileBaseName}.map&quot;"/>
<listOptionValue builtIn="false" value="--gc-sections"/>
</option>
<option id="com.crt.advproject.link.gcc.hdrlib.234176228" name="Library" superClass="com.crt.advproject.link.gcc.hdrlib" value="com.crt.advproject.gcc.link.hdrlib.codered.nohost" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.libs.2108957282" superClass="gnu.c.link.option.libs" valueType="libs">
<option id="gnu.c.link.option.libs.2108957282" superClass="gnu.c.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="lpc_board_nxp_lpcxpresso_1549"/>
<listOptionValue builtIn="false" value="lpc_chip_15xx"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.paths.1053984928" superClass="gnu.c.link.option.paths" valueType="libPaths">
<option id="gnu.c.link.option.paths.1053984928" superClass="gnu.c.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/Debug}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/Debug}&quot;"/>
</option>
<option id="com.crt.advproject.link.memory.load.image.1479338943" superClass="com.crt.advproject.link.memory.load.image" value="" valueType="string"/>
<option defaultValue="com.crt.advproject.heapAndStack.lpcXpressoStyle" id="com.crt.advproject.link.memory.heapAndStack.style.1016837462" superClass="com.crt.advproject.link.memory.heapAndStack.style" valueType="enumerated"/>
<option id="com.crt.advproject.link.memory.heapAndStack.558795804" superClass="com.crt.advproject.link.memory.heapAndStack" value="&amp;Heap:Default;Post Data;Default&amp;Stack:Default;End;Default" valueType="string"/>
<option id="com.crt.advproject.link.memory.data.1268628929" superClass="com.crt.advproject.link.memory.data" value="" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.crt.advproject.link.memory.sections.2041321552" superClass="com.crt.advproject.link.memory.sections" valueType="stringList"/>
<option id="com.crt.advproject.link.gcc.multicore.slave.1398535141" superClass="com.crt.advproject.link.gcc.multicore.slave"/>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.2012740688" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="com.crt.advproject.tool.debug.debug.1117742078" name="MCU Debugger" superClass="com.crt.advproject.tool.debug.debug"/>
</toolChain>
</folderInfo>
<sourceEntries>
@ -95,13 +88,13 @@
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.exe.release.678615490" 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.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
<extension id="org.eclipse.cdt.core.GNU_ELF" point="org.eclipse.cdt.core.BinaryParser"/>
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
@ -112,19 +105,19 @@
<builder buildPath="${workspace_loc:/periph_blinky}/Release" id="com.crt.advproject.builder.exe.release.947856735" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.exe.release"/>
<tool id="com.crt.advproject.cpp.exe.release.265263030" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.exe.release"/>
<tool id="com.crt.advproject.gcc.exe.release.1271626947" name="MCU C Compiler" superClass="com.crt.advproject.gcc.exe.release">
<option id="com.crt.advproject.gcc.arch.1010176118" name="Architecture" superClass="com.crt.advproject.gcc.arch" useByScannerDiscovery="true" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.thumb.1416302102" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.preprocessor.def.symbols.1864860753" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" useByScannerDiscovery="false" valueType="definedSymbols">
<option id="com.crt.advproject.gcc.arch.1010176118" name="Architecture" superClass="com.crt.advproject.gcc.arch" value="com.crt.advproject.gcc.target.cm3" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.thumb.1416302102" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.1864860753" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="NDEBUG"/>
<listOptionValue builtIn="false" value="__CODE_RED"/>
<listOptionValue builtIn="false" value="__USE_LPCOPEN"/>
<listOptionValue builtIn="false" value="__REDLIB__"/>
<listOptionValue builtIn="false" value="CORE_M3"/>
</option>
<option id="gnu.c.compiler.option.misc.other.1129717556" name="Other flags" superClass="gnu.c.compiler.option.misc.other" useByScannerDiscovery="false" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="com.crt.advproject.gcc.hdrlib.1331162837" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Redlib" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.specs.2012635549" superClass="com.crt.advproject.gcc.specs" useByScannerDiscovery="false" value="com.crt.advproject.gcc.specs.codered" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.660100531" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<option id="gnu.c.compiler.option.misc.other.1129717556" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
<option id="com.crt.advproject.gcc.hdrlib.1331162837" superClass="com.crt.advproject.gcc.hdrlib" value="Redlib" valueType="enumerated"/>
<option id="com.crt.advproject.gcc.specs.2012635549" superClass="com.crt.advproject.gcc.specs" value="com.crt.advproject.gcc.specs.codered" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.660100531" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/inc}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}&quot;"/>
</option>
@ -141,37 +134,30 @@
</tool>
<tool id="com.crt.advproject.link.cpp.exe.release.2111991438" name="MCU C++ Linker" superClass="com.crt.advproject.link.cpp.exe.release"/>
<tool id="com.crt.advproject.link.exe.release.1799445651" name="MCU Linker" superClass="com.crt.advproject.link.exe.release">
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.crt.advproject.link.gcc.multicore.master.userobjs.1845591417" name="Slave Objects (not visible)" superClass="com.crt.advproject.link.gcc.multicore.master.userobjs" valueType="userObjs"/>
<option id="com.crt.advproject.link.gcc.multicore.master.userobjs.1845591417" name="Slave Objects (not visible)" superClass="com.crt.advproject.link.gcc.multicore.master.userobjs" valueType="userObjs"/>
<option id="com.crt.advproject.link.arch.2033182278" name="Architecture" superClass="com.crt.advproject.link.arch" value="com.crt.advproject.link.target.cm3" valueType="enumerated"/>
<option id="com.crt.advproject.link.thumb.264696555" name="Thumb mode" superClass="com.crt.advproject.link.thumb" value="true" valueType="boolean"/>
<option id="com.crt.advproject.link.script.676313327" name="Linker script" superClass="com.crt.advproject.link.script" value="&quot;periph_blinky_Release.ld&quot;" valueType="string"/>
<option id="com.crt.advproject.link.manage.723199826" name="Manage linker script" superClass="com.crt.advproject.link.manage" value="true" valueType="boolean"/>
<option id="gnu.c.link.option.nostdlibs.418246725" name="No startup or default libs (-nostdlib)" superClass="gnu.c.link.option.nostdlibs" value="true" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.other.87362692" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList">
<option id="gnu.c.link.option.other.87362692" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList">
<listOptionValue builtIn="false" value="-Map=&quot;${BuildArtifactFileBaseName}.map&quot;"/>
<listOptionValue builtIn="false" value="--gc-sections"/>
</option>
<option id="com.crt.advproject.link.gcc.hdrlib.171382785" name="Library" superClass="com.crt.advproject.link.gcc.hdrlib" value="com.crt.advproject.gcc.link.hdrlib.codered.nohost" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.libs.1060565585" superClass="gnu.c.link.option.libs" valueType="libs">
<option id="gnu.c.link.option.libs.1060565585" superClass="gnu.c.link.option.libs" valueType="libs">
<listOptionValue builtIn="false" value="lpc_board_nxp_lpcxpresso_1549"/>
<listOptionValue builtIn="false" value="lpc_chip_15xx"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.paths.425792281" superClass="gnu.c.link.option.paths" valueType="libPaths">
<option id="gnu.c.link.option.paths.425792281" superClass="gnu.c.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_chip_15xx/Release}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/Release}&quot;"/>
</option>
<option id="com.crt.advproject.link.memory.load.image.785216222" superClass="com.crt.advproject.link.memory.load.image" value="" valueType="string"/>
<option defaultValue="com.crt.advproject.heapAndStack.lpcXpressoStyle" id="com.crt.advproject.link.memory.heapAndStack.style.1120380707" superClass="com.crt.advproject.link.memory.heapAndStack.style" valueType="enumerated"/>
<option id="com.crt.advproject.link.memory.heapAndStack.1918406385" superClass="com.crt.advproject.link.memory.heapAndStack" value="&amp;Heap:Default;Post Data;Default&amp;Stack:Default;End;Default" valueType="string"/>
<option id="com.crt.advproject.link.memory.data.835026877" superClass="com.crt.advproject.link.memory.data" value="" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.crt.advproject.link.memory.sections.882334272" superClass="com.crt.advproject.link.memory.sections" valueType="stringList"/>
<option id="com.crt.advproject.link.gcc.multicore.slave.645625288" superClass="com.crt.advproject.link.gcc.multicore.slave"/>
<inputType id="cdt.managedbuild.tool.gnu.c.linker.input.869618207" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
</inputType>
</tool>
<tool id="com.crt.advproject.tool.debug.release.2138818563" name="MCU Debugger" superClass="com.crt.advproject.tool.debug.release"/>
</toolChain>
</folderInfo>
<sourceEntries>
@ -192,7 +178,7 @@
<storageModule moduleId="com.crt.config">
<projectStorage>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&#13;
&lt;TargetConfig&gt;&#13;
&lt;Properties property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="100300"/&gt;&#13;
&lt;Properties property_0="" property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="70200"/&gt;&#13;
&lt;infoList vendor="NXP"&gt;&#13;
&lt;info chip="LPC1549" connectscript="LPC15RunBootRomConnect.scp" flash_driver="LPC15xx_256K.cfx" match_id="0x0" name="LPC1549" resetscript="LPC15RunBootRomReset.scp" stub="crt_emu_cm3_gen"&gt;&#13;
&lt;chip&gt;&#13;
@ -208,16 +194,52 @@
&lt;memoryInstance derived_from="RAM" id="Ram0_16" location="0x2000000" size="0x4000"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" id="Ram1_16" location="0x2004000" size="0x4000"/&gt;&#13;
&lt;memoryInstance derived_from="RAM" id="Ram2_4" location="0x2008000" size="0x1000"/&gt;&#13;
&lt;peripheralInstance derived_from="V7M_MPU" determined="infoFile" id="MPU" location="0xe000ed90"/&gt;&#13;
&lt;peripheralInstance derived_from="V7M_NVIC" determined="infoFile" id="NVIC" location="0xe000e000"/&gt;&#13;
&lt;peripheralInstance derived_from="V7M_DCR" determined="infoFile" id="DCR" location="0xe000edf0"/&gt;&#13;
&lt;peripheralInstance derived_from="V7M_ITM" determined="infoFile" id="ITM" location="0xe0000000"/&gt;&#13;
&lt;peripheralInstance derived_from="GPIO-PORT" determined="infoFile" id="GPIO-PORT" location="0x1c000000"/&gt;&#13;
&lt;peripheralInstance derived_from="DMA" determined="infoFile" id="DMA" location="0x1c004000"/&gt;&#13;
&lt;peripheralInstance derived_from="USB" determined="infoFile" id="USB" location="0x1c00c000"/&gt;&#13;
&lt;peripheralInstance derived_from="CRC" determined="infoFile" id="CRC" location="0x1c010000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCT0" determined="infoFile" id="SCT0" location="0x1c018000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCT1" determined="infoFile" id="SCT1" location="0x1c01c000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCT2" determined="infoFile" id="SCT2" location="0x1c020000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCT3" determined="infoFile" id="SCT3" location="0x1c024000"/&gt;&#13;
&lt;peripheralInstance derived_from="ADC0" determined="infoFile" id="ADC0" location="0x40000000"/&gt;&#13;
&lt;peripheralInstance derived_from="DAC" determined="infoFile" id="DAC" location="0x40004000"/&gt;&#13;
&lt;peripheralInstance derived_from="ACMP" determined="infoFile" id="ACMP" location="0x40008000"/&gt;&#13;
&lt;peripheralInstance derived_from="INMUX" determined="infoFile" id="INMUX" location="0x40014000"/&gt;&#13;
&lt;peripheralInstance derived_from="RTC" determined="infoFile" id="RTC" location="0x40028000"/&gt;&#13;
&lt;peripheralInstance derived_from="WWDT" determined="infoFile" id="WWDT" location="0x4002c000"/&gt;&#13;
&lt;peripheralInstance derived_from="SWM" determined="infoFile" id="SWM" location="0x40038000"/&gt;&#13;
&lt;peripheralInstance derived_from="PMU" determined="infoFile" id="PMU" location="0x4003c000"/&gt;&#13;
&lt;peripheralInstance derived_from="USART0" determined="infoFile" id="USART0" location="0x40040000"/&gt;&#13;
&lt;peripheralInstance derived_from="USART1" determined="infoFile" id="USART1" location="0x40044000"/&gt;&#13;
&lt;peripheralInstance derived_from="SPI0" determined="infoFile" id="SPI0" location="0x40048000"/&gt;&#13;
&lt;peripheralInstance derived_from="SPI1" determined="infoFile" id="SPI1" location="0x4004c000"/&gt;&#13;
&lt;peripheralInstance derived_from="I2C0" determined="infoFile" id="I2C0" location="0x40050000"/&gt;&#13;
&lt;peripheralInstance derived_from="QEI" determined="infoFile" id="QEI" location="0x40058000"/&gt;&#13;
&lt;peripheralInstance derived_from="SYSCON" determined="infoFile" id="SYSCON" location="0x40074000"/&gt;&#13;
&lt;peripheralInstance derived_from="ADC1" determined="infoFile" id="ADC1" location="0x40080000"/&gt;&#13;
&lt;peripheralInstance derived_from="MRT" determined="infoFile" id="MRT" location="0x400a0000"/&gt;&#13;
&lt;peripheralInstance derived_from="PINT" determined="infoFile" id="PINT" location="0x400a4000"/&gt;&#13;
&lt;peripheralInstance derived_from="GINT0" determined="infoFile" id="GINT0" location="0x400a8000"/&gt;&#13;
&lt;peripheralInstance derived_from="GINT1" determined="infoFile" id="GINT1" location="0x400ac000"/&gt;&#13;
&lt;peripheralInstance derived_from="RIT" determined="infoFile" id="RIT" location="0x400b4000"/&gt;&#13;
&lt;peripheralInstance derived_from="SCTIPU" determined="infoFile" id="SCTIPU" location="0x400b8000"/&gt;&#13;
&lt;peripheralInstance derived_from="FLASHCTRL" determined="infoFile" id="FLASHCTRL" location="0x400bc000"/&gt;&#13;
&lt;peripheralInstance derived_from="USART2" determined="infoFile" id="USART2" location="0x400c0000"/&gt;&#13;
&lt;peripheralInstance derived_from="C-CAN0" determined="infoFile" id="C-CAN0" location="0x400f0000"/&gt;&#13;
&lt;peripheralInstance derived_from="IOCON" determined="infoFile" id="IOCON" location="0x400f8000"/&gt;&#13;
&lt;/chip&gt;&#13;
&lt;processor&gt;&#13;
&lt;name gcc_name="cortex-m3"&gt;Cortex-M3&lt;/name&gt;&#13;
&lt;family&gt;Cortex-M&lt;/family&gt;&#13;
&lt;/processor&gt;&#13;
&lt;link href="LPC15xx_peripheral.xme" show="embed" type="simple"/&gt;&#13;
&lt;/info&gt;&#13;
&lt;/infoList&gt;&#13;
&lt;/TargetConfig&gt;</projectStorage>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="com.crt.advproject"/>
</cproject>

Some files were not shown because too many files have changed in this diff Show More