diff --git a/.cproject b/.cproject new file mode 100644 index 0000000000000000000000000000000000000000..66731b98ce7cd130dc3f25d0e490e22aa5574e3a --- /dev/null +++ b/.cproject @@ -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.exe.debug.613942549"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.exe.debug.613942549" 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.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="axf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="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.exe.debug.613942549" name="Debug" parent="com.crt.advproject.config.exe.debug" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size "${BuildArtifactFileName}"; # arm-none-eabi-objcopy -v -O binary "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin" ; # checksum -p ${TargetChip} -d "${BuildArtifactFileBaseName}.bin"; "> + <folderInfo id="com.crt.advproject.config.exe.debug.613942549." name="/" resourcePath=""> + <toolChain id="com.crt.advproject.toolchain.exe.debug.1014701773" name="NXP MCU Tools" superClass="com.crt.advproject.toolchain.exe.debug"> + <targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.exe.debug.882543894" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.exe.debug"/> + <builder buildPath="${workspace_loc:/Labo_Keyboard}/Debug" id="com.crt.advproject.builder.exe.debug.722760860" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.exe.debug"/> + <tool id="com.crt.advproject.cpp.exe.debug.1161736663" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.exe.debug"> + <option id="com.crt.advproject.cpp.hdrlib.678266389" name="Library headers" superClass="com.crt.advproject.cpp.hdrlib" useByScannerDiscovery="false"/> + <option id="com.crt.advproject.cpp.fpu.13202551" name="Floating point" superClass="com.crt.advproject.cpp.fpu" useByScannerDiscovery="true"/> + <option id="gnu.cpp.compiler.option.preprocessor.def.310449329" superClass="gnu.cpp.compiler.option.preprocessor.def" useByScannerDiscovery="false"/> + </tool> + <tool id="com.crt.advproject.gcc.exe.debug.1331006025" name="MCU C Compiler" superClass="com.crt.advproject.gcc.exe.debug"> + <option id="com.crt.advproject.gcc.thumb.327103022" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/> + <option id="com.crt.advproject.gcc.arch.1678163231" 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.1686322497" 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_CMSIS=CMSIS_CORE_LPC17xx"/> + <listOptionValue builtIn="false" value="__LPC17XX__"/> + <listOptionValue builtIn="false" value="__REDLIB__"/> + </option> + <option id="gnu.c.compiler.option.misc.other.1615650438" 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.1816103936" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/> + <option id="com.crt.advproject.gcc.hdrlib.1233635811" name="Library headers" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Redlib" valueType="enumerated"/> + <option id="com.crt.advproject.gcc.fpu.1350464088" name="Floating point" superClass="com.crt.advproject.gcc.fpu" useByScannerDiscovery="true"/> + <option id="com.crt.advproject.gcc.specs.1483065204" 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.495808465" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/CMSIS_CORE_LPC17xx/inc}""/> + </option> + <option id="com.crt.advproject.gcc.exe.debug.option.optimization.level.2000074488" superClass="com.crt.advproject.gcc.exe.debug.option.optimization.level" useByScannerDiscovery="true"/> + <inputType id="com.crt.advproject.compiler.input.1058785932" superClass="com.crt.advproject.compiler.input"/> + </tool> + <tool id="com.crt.advproject.gas.exe.debug.1410871385" name="MCU Assembler" superClass="com.crt.advproject.gas.exe.debug"> + <option id="com.crt.advproject.gas.thumb.1618988476" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/> + <option id="com.crt.advproject.gas.arch.1870567973" 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.231436674" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -DDEBUG -D__CODE_RED -DCORE_M3 -D__USE_CMSIS=CMSIS_CORE_LPC17xx -D__LPC17XX__ -D__REDLIB__" valueType="string"/> + <option id="com.crt.advproject.gas.hdrlib.125352232" name="Library headers" superClass="com.crt.advproject.gas.hdrlib" value="Redlib" valueType="enumerated"/> + <option id="com.crt.advproject.gas.fpu.1375562808" name="Floating point" superClass="com.crt.advproject.gas.fpu"/> + <option id="com.crt.advproject.gas.specs.1003653227" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.codered" valueType="enumerated"/> + <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.both.asm.option.include.paths.7746426" superClass="gnu.both.asm.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/CMSIS_CORE_LPC17xx/inc}""/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1391121765" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + <inputType id="com.crt.advproject.assembler.input.1527436366" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/> + </tool> + <tool id="com.crt.advproject.link.cpp.exe.debug.1598950481" name="MCU C++ Linker" superClass="com.crt.advproject.link.cpp.exe.debug"> + <option id="com.crt.advproject.link.cpp.hdrlib.1136865890" name="Library" superClass="com.crt.advproject.link.cpp.hdrlib"/> + <option id="com.crt.advproject.link.cpp.fpu.1173277093" name="Floating point" superClass="com.crt.advproject.link.cpp.fpu"/> + </tool> + <tool id="com.crt.advproject.link.exe.debug.1341937632" name="MCU Linker" superClass="com.crt.advproject.link.exe.debug"> + <option id="com.crt.advproject.link.thumb.438979061" name="Thumb mode" superClass="com.crt.advproject.link.thumb" value="true" valueType="boolean"/> + <option id="com.crt.advproject.link.memory.load.image.652428622" name="Plain load image" 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.209477916" name="Heap and Stack placement" superClass="com.crt.advproject.link.memory.heapAndStack.style" valueType="enumerated"/> + <option id="com.crt.advproject.link.memory.heapAndStack.703253315" name="Heap and Stack options" superClass="com.crt.advproject.link.memory.heapAndStack" value="&Heap:Default;Post Data;Default&Stack:Default;End;Default" valueType="string"/> + <option id="com.crt.advproject.link.memory.data.718966401" name="Global data placement" 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.608846832" name="Extra linker script input sections" superClass="com.crt.advproject.link.memory.sections" valueType="stringList"/> + <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.crt.advproject.link.gcc.multicore.master.userobjs.1314631393" name="Slave Objects (not visible)" superClass="com.crt.advproject.link.gcc.multicore.master.userobjs" valueType="userObjs"/> + <option id="com.crt.advproject.link.gcc.multicore.slave.1007134578" name="Multicore configuration" superClass="com.crt.advproject.link.gcc.multicore.slave"/> + <option id="com.crt.advproject.link.arch.1482241411" name="Architecture" superClass="com.crt.advproject.link.arch" value="com.crt.advproject.link.target.cm3" valueType="enumerated"/> + <option id="com.crt.advproject.link.script.141880082" name="Linker script" superClass="com.crt.advproject.link.script" value="Labo_Keyboard_Debug.ld" valueType="string"/> + <option id="com.crt.advproject.link.manage.1248792155" name="Manage linker script" superClass="com.crt.advproject.link.manage" value="true" valueType="boolean"/> + <option id="gnu.c.link.option.nostdlibs.554612554" 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.373541297" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList"> + <listOptionValue builtIn="false" value="-Map="${BuildArtifactFileBaseName}.map""/> + <listOptionValue builtIn="false" value="--cref"/> + <listOptionValue builtIn="false" value="--gc-sections"/> + <listOptionValue builtIn="false" value="-print-memory-usage"/> + </option> + <option id="com.crt.advproject.link.gcc.hdrlib.1760099707" name="Library" superClass="com.crt.advproject.link.gcc.hdrlib" value="com.crt.advproject.gcc.link.hdrlib.codered.none" valueType="enumerated"/> + <option id="com.crt.advproject.link.fpu.475700601" name="Floating point" superClass="com.crt.advproject.link.fpu"/> + <option id="com.crt.advproject.link.gcc.multicore.master.1625029294" name="Multicore master" superClass="com.crt.advproject.link.gcc.multicore.master"/> + <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.libs.1468852738" superClass="gnu.c.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" value="CMSIS_CORE_LPC17xx"/> + </option> + <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.paths.1795555647" superClass="gnu.c.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/CMSIS_CORE_LPC17xx/Debug}""/> + </option> + <option id="com.crt.advproject.link.crpenable.2056618516" superClass="com.crt.advproject.link.crpenable" value="true" valueType="boolean"/> + <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.111018516" 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.1955827995" name="MCU Debugger" superClass="com.crt.advproject.tool.debug.debug"/> + </toolChain> + </folderInfo> + <sourceEntries> + <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.exe.release.1231515308"> + <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.exe.release.1231515308" 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.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="axf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="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.exe.release.1231515308" name="Release" parent="com.crt.advproject.config.exe.release" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size "${BuildArtifactFileName}"; # arm-none-eabi-objcopy -v -O binary "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin" ; # checksum -p ${TargetChip} -d "${BuildArtifactFileBaseName}.bin"; "> + <folderInfo id="com.crt.advproject.config.exe.release.1231515308." name="/" resourcePath=""> + <toolChain id="com.crt.advproject.toolchain.exe.release.1869203581" name="NXP MCU Tools" superClass="com.crt.advproject.toolchain.exe.release"> + <targetPlatform binaryParser="org.eclipse.cdt.core.ELF;org.eclipse.cdt.core.GNU_ELF" id="com.crt.advproject.platform.exe.release.379723996" name="ARM-based MCU (Release)" superClass="com.crt.advproject.platform.exe.release"/> + <builder buildPath="${workspace_loc:/Labo_Keyboard}/Release" id="com.crt.advproject.builder.exe.release.414941885" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.exe.release"/> + <tool id="com.crt.advproject.cpp.exe.release.844129259" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.exe.release"/> + <tool id="com.crt.advproject.gcc.exe.release.1299794553" name="MCU C Compiler" superClass="com.crt.advproject.gcc.exe.release"> + <option id="com.crt.advproject.gcc.thumb.48681669" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/> + <option id="com.crt.advproject.gcc.arch.649788269" 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.976454871" 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_CMSIS=CMSIS_CORE_LPC17xx"/> + <listOptionValue builtIn="false" value="__LPC17XX__"/> + <listOptionValue builtIn="false" value="__REDLIB__"/> + </option> + <option id="gnu.c.compiler.option.misc.other.459010815" 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.2123484550" name="Other optimization flags" superClass="gnu.c.compiler.option.optimization.flags" useByScannerDiscovery="false" value="-fno-common" valueType="string"/> + <option id="com.crt.advproject.gcc.hdrlib.1035408900" superClass="com.crt.advproject.gcc.hdrlib" useByScannerDiscovery="false" value="Redlib" valueType="enumerated"/> + <option id="com.crt.advproject.gcc.specs.2122165542" 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.1909001652" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/CMSIS_CORE_LPC17xx/inc}""/> + </option> + <inputType id="com.crt.advproject.compiler.input.657861116" superClass="com.crt.advproject.compiler.input"/> + </tool> + <tool id="com.crt.advproject.gas.exe.release.1939398957" name="MCU Assembler" superClass="com.crt.advproject.gas.exe.release"> + <option id="com.crt.advproject.gas.thumb.8052322" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/> + <option id="com.crt.advproject.gas.arch.1627140913" 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.323389192" name="Assembler flags" superClass="gnu.both.asm.option.flags.crt" value="-c -x assembler-with-cpp -DNDEBUG -D__CODE_RED -DCORE_M3 -D__USE_CMSIS=CMSIS_CORE_LPC17xx -D__LPC17XX__ -D__REDLIB__" valueType="string"/> + <option id="com.crt.advproject.gas.hdrlib.780335802" superClass="com.crt.advproject.gas.hdrlib" value="Redlib" valueType="enumerated"/> + <option id="com.crt.advproject.gas.specs.1946253947" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.codered" valueType="enumerated"/> + <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.both.asm.option.include.paths.1473592508" superClass="gnu.both.asm.option.include.paths" valueType="includePath"> + <listOptionValue builtIn="false" value=""${workspace_loc:/CMSIS_CORE_LPC17xx/inc}""/> + </option> + <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1477970645" superClass="cdt.managedbuild.tool.gnu.assembler.input"/> + <inputType id="com.crt.advproject.assembler.input.135086495" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/> + </tool> + <tool id="com.crt.advproject.link.cpp.exe.release.1542873800" name="MCU C++ Linker" superClass="com.crt.advproject.link.cpp.exe.release"/> + <tool id="com.crt.advproject.link.exe.release.1021851265" name="MCU Linker" superClass="com.crt.advproject.link.exe.release"> + <option id="com.crt.advproject.link.thumb.1591857072" name="Thumb mode" superClass="com.crt.advproject.link.thumb" value="true" valueType="boolean"/> + <option id="com.crt.advproject.link.memory.load.image.927993698" name="Plain load image" 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.1736737094" name="Heap and Stack placement" superClass="com.crt.advproject.link.memory.heapAndStack.style" valueType="enumerated"/> + <option id="com.crt.advproject.link.memory.heapAndStack.711047798" name="Heap and Stack options" superClass="com.crt.advproject.link.memory.heapAndStack" value="&Heap:Default;Post Data;Default&Stack:Default;End;Default" valueType="string"/> + <option id="com.crt.advproject.link.memory.data.1062023504" name="Global data placement" 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.385692893" name="Extra linker script input sections" superClass="com.crt.advproject.link.memory.sections" valueType="stringList"/> + <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.crt.advproject.link.gcc.multicore.master.userobjs.569003456" name="Slave Objects (not visible)" superClass="com.crt.advproject.link.gcc.multicore.master.userobjs" valueType="userObjs"/> + <option id="com.crt.advproject.link.gcc.multicore.slave.1395276694" name="Multicore configuration" superClass="com.crt.advproject.link.gcc.multicore.slave"/> + <option id="com.crt.advproject.link.arch.428974390" name="Architecture" superClass="com.crt.advproject.link.arch" value="com.crt.advproject.link.target.cm3" valueType="enumerated"/> + <option id="com.crt.advproject.link.script.1569663492" name="Linker script" superClass="com.crt.advproject.link.script" value="Labo_Keyboard_Release.ld" valueType="string"/> + <option id="com.crt.advproject.link.manage.631735649" name="Manage linker script" superClass="com.crt.advproject.link.manage" value="true" valueType="boolean"/> + <option id="gnu.c.link.option.nostdlibs.1111467417" 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.285934511" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList"> + <listOptionValue builtIn="false" value="-Map="${BuildArtifactFileBaseName}.map""/> + <listOptionValue builtIn="false" value="--cref"/> + <listOptionValue builtIn="false" value="--gc-sections"/> + <listOptionValue builtIn="false" value="-print-memory-usage"/> + </option> + <option id="com.crt.advproject.link.gcc.hdrlib.575405103" name="Library" superClass="com.crt.advproject.link.gcc.hdrlib" value="com.crt.advproject.gcc.link.hdrlib.codered.none" valueType="enumerated"/> + <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.libs.1752739164" superClass="gnu.c.link.option.libs" valueType="libs"> + <listOptionValue builtIn="false" value="CMSIS_CORE_LPC17xx"/> + </option> + <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.paths.1892982033" superClass="gnu.c.link.option.paths" valueType="libPaths"> + <listOptionValue builtIn="false" value=""${workspace_loc:/CMSIS_CORE_LPC17xx/Release}""/> + </option> + <option id="com.crt.advproject.link.crpenable.623706927" superClass="com.crt.advproject.link.crpenable" value="true" valueType="boolean"/> + <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.675476394" 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.1031357700" name="MCU Debugger" superClass="com.crt.advproject.tool.debug.release"/> + </toolChain> + </folderInfo> + <sourceEntries> + <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="Labo_Keyboard.com.crt.advproject.projecttype.exe.383194395" name="Executable" projectType="com.crt.advproject.projecttype.exe"/> + </storageModule> + <storageModule moduleId="scannerConfiguration"> + <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/> + </storageModule> + <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/> + <storageModule moduleId="com.crt.config"> + <projectStorage><?xml version="1.0" encoding="UTF-8"?> +<TargetConfig> +<Properties property_2="LPC175x_6x_512.cfx" property_3="NXP" property_4="LPC1769" property_count="5" version="100300"/> +<infoList vendor="NXP"> +<info chip="LPC1769" flash_driver="LPC175x_6x_512.cfx" match_id="0x26113F37" name="LPC1769" package="lpc17_lqfp100.xml" stub="crt_emu_cm3_nxp"> +<chip> +<name>LPC1769</name> +<family>LPC17xx</family> +<vendor>NXP (formerly Philips)</vendor> +<reset board="None" core="Real" sys="Real"/> +<clock changeable="TRUE" freq="20MHz" is_accurate="TRUE"/> +<memory can_program="true" id="Flash" is_ro="true" type="Flash"/> +<memory id="RAM" type="RAM"/> +<memory id="Periph" is_volatile="true" type="Peripheral"/> +<memoryInstance derived_from="Flash" id="MFlash512" location="0x00000000" size="0x80000"/> +<memoryInstance derived_from="RAM" id="RamLoc32" location="0x10000000" size="0x8000"/> +<memoryInstance derived_from="RAM" id="RamAHB32" location="0x2007c000" size="0x8000"/> +<prog_flash blocksz="0x1000" location="0" maxprgbuff="0x1000" progwithcode="TRUE" size="0x10000"/> +<prog_flash blocksz="0x8000" location="0x10000" maxprgbuff="0x1000" progwithcode="TRUE" size="0x70000"/> +</chip> +<processor> +<name gcc_name="cortex-m3">Cortex-M3</name> +<family>Cortex-M</family> +</processor> +</info> +</infoList> +</TargetConfig></projectStorage> + </storageModule> + <storageModule moduleId="refreshScope"/> + <storageModule moduleId="com.crt.advproject"> + <boardId>LPCXpresso1769-CD</boardId> + </storageModule> + <storageModule moduleId="openCmsis"/> + <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/> +</cproject> \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..5586623545a79e61cbf6a46a001845b804d2e7d5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# Beginning # + + + +### MCUXpresso Stuff ### +# General +Debug/ +.settings/ +*.launch + + + +# End # \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000000000000000000000000000000000000..bea01c297faeec21c0630c9c42f3018528697b50 --- /dev/null +++ b/.project @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>Labo_Keyboard</name> + <comment></comment> + <projects> + <project>CMSIS_CORE_LPC17xx</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.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature> + </natures> +</projectDescription> diff --git a/CC_Projet_MiP.pdf b/cahier des charges/CC_Projet_MiP.pdf similarity index 100% rename from CC_Projet_MiP.pdf rename to cahier des charges/CC_Projet_MiP.pdf diff --git a/script/keyboard.py b/script/keyboard.py new file mode 100644 index 0000000000000000000000000000000000000000..a5ba41b4632373c9d271106c6660ae54279531c8 --- /dev/null +++ b/script/keyboard.py @@ -0,0 +1,36 @@ +import serial +import time + +try: + import pyautogui +except: + print("PyAutoGUI is required: pip install pyautogui") + exit() + + +def main(): + + # Configure the serial port + ser = serial.Serial("/dev/ttyUSB0", baudrate=115200, timeout=1) + + while True: + + # Check if there is data waiting to be read + if ser.in_waiting > 0: + + # Read the key from the serial port + key = ser.readline().decode('utf-8').strip() + + # Split to get the key and it's state (UP/DOWN) + key = key.split("./") + + if key[1] == 'DOWN': + pyautogui.keyDown(key[0]) + elif key[1] == 'UP': + pyautogui.keyUp(key[0]) + + # Small delay to prevent 100% CPU usage + time.sleep(0.01) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/src/Labo_Keyboard.c b/src/Labo_Keyboard.c new file mode 100644 index 0000000000000000000000000000000000000000..76f8fba2d2d7096e3b75ba74f5c5ee2a2c52cc01 --- /dev/null +++ b/src/Labo_Keyboard.c @@ -0,0 +1,139 @@ +/* + * Copyright 2022 NXP + * NXP confidential. + * This software is owned or controlled by NXP and may only be used strictly + * in accordance with the applicable license terms. By expressly accepting + * such terms or by downloading, installing, activating and/or otherwise using + * the software, you are agreeing that you have read, and that you agree to + * comply with and are bound by, such license terms. If you do not agree to + * be bound by the applicable license terms, then you may not retain, install, + * activate or otherwise use the software. + */ + +#ifdef __USE_CMSIS +#include "LPC17xx.h" +#endif + +#include <cr_section_macros.h> + +#include "uart.h" +#include "input.h" +#include "lcd.h" +#include "i2c.h" + +#define KEY_SIZE 50 +#define KEY_SHIFT 20 + +#define SHIFT_WIDTH (KEY_SHIFT*3) + +int main_master() +{ + uart_send_string("I'm the Master !\r\n", 18); + + // Draw Keyboard + /*######################## 1 - 6 ########################*/ + square(255, 255, 255, 239, 0, KEY_SIZE*6, 1); + + for(int i = 0; i < 7; i++) + { + square(255, 255, 255, 239-KEY_SIZE, i*KEY_SIZE, 1, KEY_SIZE); + } + + square(255, 255, 255, 239-KEY_SIZE, 0, KEY_SIZE*6, 1); + /*#######################################################*/ + + /*######################## QWERT ########################*/ + for(int i = 0; i < 6; i++) + { + square(255, 255, 255, 239-(KEY_SIZE*2), KEY_SHIFT+i*KEY_SIZE, 1, KEY_SIZE); + } + + square(255, 255, 255, 239-(KEY_SIZE*2), KEY_SHIFT, KEY_SIZE*5, 1); + /*#######################################################*/ + + /*######################## ASDFG ########################*/ + square(255, 255, 255, 239-(KEY_SIZE*2), (KEY_SHIFT*2)+(KEY_SIZE*4), KEY_SIZE, 1); + + for(int i = 0; i < 6; i++) + { + square(255, 255, 255, 239-(KEY_SIZE*3), (KEY_SHIFT*2)+i*KEY_SIZE, 1, KEY_SIZE); + } + + square(255, 255, 255, 239-(KEY_SIZE*3), (KEY_SHIFT*2), KEY_SIZE*5, 1); + /*#######################################################*/ + + /*######################## YXCVB ########################*/ + square(255, 255, 255, 239-(KEY_SIZE*3), (KEY_SHIFT*3)+(KEY_SIZE*4), KEY_SIZE, 1); + + for(int i = 0; i < 6; i++) + { + square(255, 255, 255, 239-(KEY_SIZE*4), (KEY_SHIFT*3)+i*KEY_SIZE, 1, KEY_SIZE); + } + + square(255, 255, 255, 239-(KEY_SIZE*4), (KEY_SHIFT*3), KEY_SIZE*5, 1); + /*#######################################################*/ + + /*######################## SHIFT ########################*/ + square(255, 255, 255, 239-(KEY_SIZE*3), 0, SHIFT_WIDTH, 1); + + square(255, 255, 255, 239-(KEY_SIZE*4), 0, 1, KEY_SIZE); + + square(255, 255, 255, 239-(KEY_SIZE*4), 0, SHIFT_WIDTH, 1); + /*#######################################################*/ + + while(1) + { + + } + + return 0; +} + +int main_slave() +{ + uart_send_string("I'm the Slave !\r\n", 18); + + while(1) + { + + } + + return 0; +} + +int main(void) +{ + // Init UART + uart_init(); + + // Init screen + lcd_init(); + + // Clear screen + black_screen(); + + // Init I2C + i2c_init(); + + //uint8_t addr_data[1] = {0x00}; + //i2c_write_bytes(0x38 << 1, 0xA4, 1, addr_data); + + // Set switch 0 as input + LPC_GPIO2->FIODIR &= ~(1); + + // Get state of switch 0 + LPC_GPIO2->FIOMASK = ~(1); + uint8_t switch_0 = ~(LPC_GPIO2->FIOPIN) & 0b1; + LPC_GPIO2->FIOMASK = 0; + + if(switch_0 == 0) + { + main_master(); + } + else + { + main_slave(); + } + + return 0; +} diff --git a/src/cr_startup_lpc175x_6x.c b/src/cr_startup_lpc175x_6x.c new file mode 100644 index 0000000000000000000000000000000000000000..94fb7670492dd47cafde9f47883d609c4d90f7d5 --- /dev/null +++ b/src/cr_startup_lpc175x_6x.c @@ -0,0 +1,367 @@ +//***************************************************************************** +// LPC175x_6x Microcontroller Startup code for use with LPCXpresso IDE +// +// Version : 150706 +//***************************************************************************** +// +// Copyright(C) NXP Semiconductors, 2014-2015, 2020 +// All rights reserved. +// +// NXP Confidential. This software is owned or controlled by NXP and may only be +// used strictly in accordance with the applicable license terms. +// +// By expressly accepting such terms or by downloading, installing, activating +// and/or otherwise using the software, you are agreeing that you have read, and +// that you agree to comply with and are bound by, such license terms. +// +// If you do not agree to be bound by the applicable license terms, then you may not +// retain, install, activate or otherwise use the software. +//***************************************************************************** + +#if defined (__cplusplus) +#ifdef __REDLIB__ +#error Redlib does not support C++ +#else +//***************************************************************************** +// +// The entry point for the C++ library startup +// +//***************************************************************************** +extern "C" { + extern void __libc_init_array(void); +} +#endif +#endif + +#define WEAK __attribute__ ((weak)) +#define ALIAS(f) __attribute__ ((weak, alias (#f))) + +//***************************************************************************** +#if defined (__cplusplus) +extern "C" { +#endif + +//***************************************************************************** +#if defined (__USE_CMSIS) || defined (__USE_LPCOPEN) +// Declaration of external SystemInit function +extern void SystemInit(void); +#endif + +//***************************************************************************** +// +// Forward declaration of the default handlers. These are aliased. +// When the application defines a handler (with the same name), this will +// automatically take precedence over these weak definitions +// +//***************************************************************************** + void ResetISR(void); +WEAK void NMI_Handler(void); +WEAK void HardFault_Handler(void); +WEAK void MemManage_Handler(void); +WEAK void BusFault_Handler(void); +WEAK void UsageFault_Handler(void); +WEAK void SVC_Handler(void); +WEAK void DebugMon_Handler(void); +WEAK void PendSV_Handler(void); +WEAK void SysTick_Handler(void); +WEAK void IntDefaultHandler(void); + +//***************************************************************************** +// +// Forward declaration of the specific IRQ handlers. These are aliased +// to the IntDefaultHandler, which is a 'forever' loop. When the application +// defines a handler (with the same name), this will automatically take +// precedence over these weak definitions +// +//***************************************************************************** +void WDT_IRQHandler(void) ALIAS(IntDefaultHandler); +void TIMER0_IRQHandler(void) ALIAS(IntDefaultHandler); +void TIMER1_IRQHandler(void) ALIAS(IntDefaultHandler); +void TIMER2_IRQHandler(void) ALIAS(IntDefaultHandler); +void TIMER3_IRQHandler(void) ALIAS(IntDefaultHandler); +void UART0_IRQHandler(void) ALIAS(IntDefaultHandler); +void UART1_IRQHandler(void) ALIAS(IntDefaultHandler); +void UART2_IRQHandler(void) ALIAS(IntDefaultHandler); +void UART3_IRQHandler(void) ALIAS(IntDefaultHandler); +void PWM1_IRQHandler(void) ALIAS(IntDefaultHandler); +void I2C0_IRQHandler(void) ALIAS(IntDefaultHandler); +void I2C1_IRQHandler(void) ALIAS(IntDefaultHandler); +void I2C2_IRQHandler(void) ALIAS(IntDefaultHandler); +void SPI_IRQHandler(void) ALIAS(IntDefaultHandler); +void SSP0_IRQHandler(void) ALIAS(IntDefaultHandler); +void SSP1_IRQHandler(void) ALIAS(IntDefaultHandler); +void PLL0_IRQHandler(void) ALIAS(IntDefaultHandler); +void RTC_IRQHandler(void) ALIAS(IntDefaultHandler); +void EINT0_IRQHandler(void) ALIAS(IntDefaultHandler); +void EINT1_IRQHandler(void) ALIAS(IntDefaultHandler); +void EINT2_IRQHandler(void) ALIAS(IntDefaultHandler); +void EINT3_IRQHandler(void) ALIAS(IntDefaultHandler); +void ADC_IRQHandler(void) ALIAS(IntDefaultHandler); +void BOD_IRQHandler(void) ALIAS(IntDefaultHandler); +void USB_IRQHandler(void) ALIAS(IntDefaultHandler); +void CAN_IRQHandler(void) ALIAS(IntDefaultHandler); +void DMA_IRQHandler(void) ALIAS(IntDefaultHandler); +void I2S_IRQHandler(void) ALIAS(IntDefaultHandler); +#if defined (__USE_LPCOPEN) +void ETH_IRQHandler(void) ALIAS(IntDefaultHandler); +#else +void ENET_IRQHandler(void) ALIAS(IntDefaultHandler); +#endif +void RIT_IRQHandler(void) ALIAS(IntDefaultHandler); +void MCPWM_IRQHandler(void) ALIAS(IntDefaultHandler); +void QEI_IRQHandler(void) ALIAS(IntDefaultHandler); +void PLL1_IRQHandler(void) ALIAS(IntDefaultHandler); +void USBActivity_IRQHandler(void) ALIAS(IntDefaultHandler); +void CANActivity_IRQHandler(void) ALIAS(IntDefaultHandler); + +//***************************************************************************** +// +// The entry point for the application. +// __main() is the entry point for Redlib based applications +// main() is the entry point for Newlib based applications +// +//***************************************************************************** +#if defined (__REDLIB__) +extern void __main(void); +#endif +extern int main(void); +//***************************************************************************** +// +// External declaration for the pointer to the stack top from the Linker Script +// +//***************************************************************************** +extern void _vStackTop(void); + +//***************************************************************************** +// +// External declaration for LPC MCU vector table checksum from Linker Script +// +//***************************************************************************** +WEAK extern void __valid_user_code_checksum(); + +//***************************************************************************** +#if defined (__cplusplus) +} // extern "C" +#endif +//***************************************************************************** +// +// The vector table. +// This relies on the linker script to place at correct location in memory. +// +//***************************************************************************** +extern void (* const g_pfnVectors[])(void); +__attribute__ ((used,section(".isr_vector"))) +void (* const g_pfnVectors[])(void) = { + // Core Level - CM3 + &_vStackTop, // The initial stack pointer + ResetISR, // The reset handler + NMI_Handler, // The NMI handler + HardFault_Handler, // The hard fault handler + MemManage_Handler, // The MPU fault handler + BusFault_Handler, // The bus fault handler + UsageFault_Handler, // The usage fault handler + __valid_user_code_checksum, // LPC MCU Checksum + 0, // Reserved + 0, // Reserved + 0, // Reserved + SVC_Handler, // SVCall handler + DebugMon_Handler, // Debug monitor handler + 0, // Reserved + PendSV_Handler, // The PendSV handler + SysTick_Handler, // The SysTick handler + + // Chip Level - LPC17 + WDT_IRQHandler, // 16, 0x40 - WDT + TIMER0_IRQHandler, // 17, 0x44 - TIMER0 + TIMER1_IRQHandler, // 18, 0x48 - TIMER1 + TIMER2_IRQHandler, // 19, 0x4c - TIMER2 + TIMER3_IRQHandler, // 20, 0x50 - TIMER3 + UART0_IRQHandler, // 21, 0x54 - UART0 + UART1_IRQHandler, // 22, 0x58 - UART1 + UART2_IRQHandler, // 23, 0x5c - UART2 + UART3_IRQHandler, // 24, 0x60 - UART3 + PWM1_IRQHandler, // 25, 0x64 - PWM1 + I2C0_IRQHandler, // 26, 0x68 - I2C0 + I2C1_IRQHandler, // 27, 0x6c - I2C1 + I2C2_IRQHandler, // 28, 0x70 - I2C2 + SPI_IRQHandler, // 29, 0x74 - SPI + SSP0_IRQHandler, // 30, 0x78 - SSP0 + SSP1_IRQHandler, // 31, 0x7c - SSP1 + PLL0_IRQHandler, // 32, 0x80 - PLL0 (Main PLL) + RTC_IRQHandler, // 33, 0x84 - RTC + EINT0_IRQHandler, // 34, 0x88 - EINT0 + EINT1_IRQHandler, // 35, 0x8c - EINT1 + EINT2_IRQHandler, // 36, 0x90 - EINT2 + EINT3_IRQHandler, // 37, 0x94 - EINT3 + ADC_IRQHandler, // 38, 0x98 - ADC + BOD_IRQHandler, // 39, 0x9c - BOD + USB_IRQHandler, // 40, 0xA0 - USB + CAN_IRQHandler, // 41, 0xa4 - CAN + DMA_IRQHandler, // 42, 0xa8 - GP DMA + I2S_IRQHandler, // 43, 0xac - I2S +#if defined (__USE_LPCOPEN) + ETH_IRQHandler, // 44, 0xb0 - Ethernet +#else + ENET_IRQHandler, // 44, 0xb0 - Ethernet +#endif + RIT_IRQHandler, // 45, 0xb4 - RITINT + MCPWM_IRQHandler, // 46, 0xb8 - Motor Control PWM + QEI_IRQHandler, // 47, 0xbc - Quadrature Encoder + PLL1_IRQHandler, // 48, 0xc0 - PLL1 (USB PLL) + USBActivity_IRQHandler, // 49, 0xc4 - USB Activity interrupt to wakeup + CANActivity_IRQHandler, // 50, 0xc8 - CAN Activity interrupt to wakeup +}; + +//***************************************************************************** +// Functions to carry out the initialization of RW and BSS data sections. These +// are written as separate functions rather than being inlined within the +// ResetISR() function in order to cope with MCUs with multiple banks of +// memory. +//***************************************************************************** +__attribute__ ((section(".after_vectors"))) +void data_init(unsigned int romstart, unsigned int start, unsigned int len) { + unsigned int *pulDest = (unsigned int*) start; + unsigned int *pulSrc = (unsigned int*) romstart; + unsigned int loop; + for (loop = 0; loop < len; loop = loop + 4) + *pulDest++ = *pulSrc++; +} + +__attribute__ ((section(".after_vectors"))) +void bss_init(unsigned int start, unsigned int len) { + unsigned int *pulDest = (unsigned int*) start; + unsigned int loop; + for (loop = 0; loop < len; loop = loop + 4) + *pulDest++ = 0; +} + +//***************************************************************************** +// The following symbols are constructs generated by the linker, indicating +// the location of various points in the "Global Section Table". This table is +// created by the linker via the Code Red managed linker script mechanism. It +// contains the load address, execution address and length of each RW data +// section and the execution and length of each BSS (zero initialized) section. +//***************************************************************************** +extern unsigned int __data_section_table; +extern unsigned int __data_section_table_end; +extern unsigned int __bss_section_table; +extern unsigned int __bss_section_table_end; + +//***************************************************************************** +// Reset entry point for your code. +// Sets up a simple runtime environment and initializes the C/C++ +// library. +//***************************************************************************** +__attribute__ ((section(".after_vectors"))) +void +ResetISR(void) { + + // + // Copy the data sections from flash to SRAM. + // + unsigned int LoadAddr, ExeAddr, SectionLen; + unsigned int *SectionTableAddr; + + // Load base address of Global Section Table + SectionTableAddr = &__data_section_table; + + // Copy the data sections from flash to SRAM. + while (SectionTableAddr < &__data_section_table_end) { + LoadAddr = *SectionTableAddr++; + ExeAddr = *SectionTableAddr++; + SectionLen = *SectionTableAddr++; + data_init(LoadAddr, ExeAddr, SectionLen); + } + // At this point, SectionTableAddr = &__bss_section_table; + // Zero fill the bss segment + while (SectionTableAddr < &__bss_section_table_end) { + ExeAddr = *SectionTableAddr++; + SectionLen = *SectionTableAddr++; + bss_init(ExeAddr, SectionLen); + } + +#if defined (__USE_CMSIS) || defined (__USE_LPCOPEN) + SystemInit(); +#endif + +#if defined (__cplusplus) + // + // Call C++ library initialisation + // + __libc_init_array(); +#endif + +#if defined (__REDLIB__) + // Call the Redlib library, which in turn calls main() + __main() ; +#else + main(); +#endif + + // + // main() shouldn't return, but if it does, we'll just enter an infinite loop + // + while (1) { + ; + } +} + +//***************************************************************************** +// Default exception handlers. Override the ones here by defining your own +// handler routines in your application code. +//***************************************************************************** +__attribute__ ((section(".after_vectors"))) +void NMI_Handler(void) +{ while(1) {} +} + +__attribute__ ((section(".after_vectors"))) +void HardFault_Handler(void) +{ while(1) {} +} + +__attribute__ ((section(".after_vectors"))) +void MemManage_Handler(void) +{ while(1) {} +} + +__attribute__ ((section(".after_vectors"))) +void BusFault_Handler(void) +{ while(1) {} +} + +__attribute__ ((section(".after_vectors"))) +void UsageFault_Handler(void) +{ while(1) {} +} + +__attribute__ ((section(".after_vectors"))) +void SVC_Handler(void) +{ while(1) {} +} + +__attribute__ ((section(".after_vectors"))) +void DebugMon_Handler(void) +{ while(1) {} +} + +__attribute__ ((section(".after_vectors"))) +void PendSV_Handler(void) +{ while(1) {} +} + +__attribute__ ((section(".after_vectors"))) +void SysTick_Handler(void) +{ while(1) {} +} + +//***************************************************************************** +// +// Processor ends up here if an unexpected interrupt occurs or a specific +// handler is not present in the application code. +// +//***************************************************************************** +__attribute__ ((section(".after_vectors"))) +void IntDefaultHandler(void) +{ while(1) {} +} diff --git a/src/crp.c b/src/crp.c new file mode 100644 index 0000000000000000000000000000000000000000..6e33068b9a29d48ee8a8c83a428d6e75a95f0593 --- /dev/null +++ b/src/crp.c @@ -0,0 +1,27 @@ +//***************************************************************************** +// crp.c +// +// Source file to create CRP word expected by LPCXpresso IDE linker +//***************************************************************************** +// +// Copyright(C) NXP Semiconductors, 2013, 2020 +// All rights reserved. +// +// NXP Confidential. This software is owned or controlled by NXP and may only be +// used strictly in accordance with the applicable license terms. +// +// By expressly accepting such terms or by downloading, installing, activating +// and/or otherwise using the software, you are agreeing that you have read, and +// that you agree to comply with and are bound by, such license terms. +// +// If you do not agree to be bound by the applicable license terms, then you may not +// retain, install, activate or otherwise use the software. +//***************************************************************************** + +#if defined (__CODE_RED) +#include <NXP/crp.h> +// Variable to store CRP value in. Will be placed automatically +// by the linker when "Enable Code Read Protect" selected. +// See crp.h header for more information +__CRP const unsigned int CRP_WORD = CRP_NO_CRP ; +#endif diff --git a/src/i2c.c b/src/i2c.c new file mode 100644 index 0000000000000000000000000000000000000000..b5cf0f76c966852a8386dd30a7a2d40d075888b4 --- /dev/null +++ b/src/i2c.c @@ -0,0 +1,188 @@ +/* + * i2c.c + * + * Created on: 22 mars 2024 + * Author: padi + */ + +#include "i2c.h" + +typedef struct i2c_transaction +{ + uint8_t slave_addr; + uint8_t write_len; + uint8_t read_len; + uint8_t data_ptr; + uint8_t status; + uint8_t data[32]; +}i2c_transaction; + +i2c_transaction nxt_trans; + +void i2c_trans(i2c_transaction t) +{ + nxt_trans = t; + nxt_trans.status = 0x8; + + LPC_I2C0->I2CONSET = (0b0 << 2) | (0b0 << 3) | (0b0 << 4) | (0b1 << 5) | (0b1 << 6); + + // Wait transaction to end + while(nxt_trans.status != 0); +} + +void i2c_init() +{ + // Clear + LPC_I2C0->I2CONCLR = (0b1 << 2) | (0b1 << 3) | (0b1 << 4) | (0b1 << 5) | (0b1 << 6); + + // Enable I2C peripheral + LPC_SC->PCONP |= (0b1 << 7); + + // Clock + // Set I2C clock (PCLK_I2C0) to CCLK + LPC_SC->PCLKSEL0 &= ~(3 << 14); + LPC_SC->PCLKSEL0 |= (1 << 14); + + // Pins + // Set bits 22 and 24 for SDA0 and SCL0 + LPC_PINCON->PINSEL1 &= ~(0b11 << 22); + LPC_PINCON->PINSEL1 |= (0b1 << 22); + LPC_PINCON->PINSEL1 &= ~(0b11 << 24); + LPC_PINCON->PINSEL1 |= (0b1 << 24); + + // Enable I2C0 + LPC_I2C0->I2CONSET = (0b0 << 2) | (0b0 << 3) | (0b0 << 4) | (0b0 << 5) | (0b1 << 6); + + // Interrupt + NVIC_EnableIRQ(I2C0_IRQn); +} + +void I2C0_IRQHandler() { + int status_trans = LPC_I2C0->I2STAT; + + switch(status_trans) { + // START && REPEATED_START + case 0x08: + case 0x10: + // Clear SI + LPC_I2C0->I2CONCLR = (1 << 5); + + if (nxt_trans.write_len > 0) + LPC_I2C0->I2DAT = (nxt_trans.slave_addr << 1); + else + LPC_I2C0->I2DAT = (nxt_trans.slave_addr << 1) | 1; + break; + + // SLA_W_ACK + case 0x18: + nxt_trans.data_ptr = 0; + + // DATA_TR_ACK + case 0x28: + if (nxt_trans.write_len > 0) + { + LPC_I2C0->I2DAT = nxt_trans.data[nxt_trans.data_ptr++]; + nxt_trans.write_len--; + } + else if (nxt_trans.read_len > 0) + { + // Set AA + LPC_I2C0->I2CONSET = (1 << 5); + } + else + { + LPC_I2C0->I2CONSET = (1 << 4); + // Set STO + nxt_trans.status = 0; + } + break; + + // SLA_R_ACK + case 0x40: + nxt_trans.data_ptr = 0; + + if (nxt_trans.read_len == 1) + // Clear AA + LPC_I2C0->I2CONCLR = (1 << 2); + else + // Set AA + LPC_I2C0->I2CONSET = (1 << 2); + break; + + // DATA_RC_ACK + case 0x50: + if (nxt_trans.read_len > 0) + { + nxt_trans.data[nxt_trans.data_ptr++] = LPC_I2C0->I2DAT; + nxt_trans.read_len--; + + if (nxt_trans.read_len == 1) + // Clear AA + LPC_I2C0->I2CONCLR = (1 << 2); + else + // Set AA + LPC_I2C0->I2CONSET = (1 << 2); + } + break; + + // DATA_RC_NACK + case 0x58: + nxt_trans.data[nxt_trans.data_ptr++] = LPC_I2C0->I2DAT; + nxt_trans.read_len--; + + // DATA_TR_NACK && SLA_W_NACK + case 0x30: + case 0x20: + // Set STO + LPC_I2C0->I2CONSET = (1 << 4); + nxt_trans.status = 0; + break; + + // Error handling for unexpected states + default: + // Clear SI and set STOP condition to reset the bus + // Set STO + LPC_I2C0->I2CONSET = (1 << 4); + nxt_trans.status = 0; + break; + } + + // Clear interrupt + LPC_I2C0->I2CONCLR = (1 << 3); +} + +void i2c_write_bytes(uint8_t addr, uint8_t reg, uint8_t len, uint8_t* source_data) +{ + i2c_transaction t; + + t.slave_addr = addr; + t.data[0] = reg; + t.write_len = len+1; + t.read_len = 0; + + for(int x = 0; x < len; x++) + { + t.data[x+1] = source_data[x]; + } + + i2c_trans(t); +} + +int i2c_read_bytes(uint8_t addr, uint8_t reg, uint8_t len, uint8_t* result_data) +{ + i2c_transaction t; + + t.slave_addr = addr; + t.data[0] = reg; + t.write_len = 1; + t.read_len = len; + + i2c_trans(t); + + for(int x = 0; x < len; x++) + { + result_data[x] = nxt_trans.data[x]; + } + + return 0; +} diff --git a/src/i2c.h b/src/i2c.h new file mode 100644 index 0000000000000000000000000000000000000000..2d7ccda46874490b11b292a968517684c69ca6a0 --- /dev/null +++ b/src/i2c.h @@ -0,0 +1,19 @@ +/* + * i2c.h + * + * Created on: 22 mars 2024 + * Author: padi + */ + +#ifndef I2C_H_ +#define I2C_H_ + +#include "LPC17xx.h" + +#include <stdint.h> + +void i2c_init(); +void i2c_write_bytes(uint8_t addr, uint8_t reg, uint8_t len, uint8_t* source_data); +int i2c_read_bytes(uint8_t addr, uint8_t reg, uint8_t len, uint8_t* result_data); + +#endif /* I2C_H_ */ diff --git a/src/input.c b/src/input.c new file mode 100644 index 0000000000000000000000000000000000000000..d0efa5f23b7d656114106dd5ca85f1d211c7bddd --- /dev/null +++ b/src/input.c @@ -0,0 +1,31 @@ +/* + * input.c + * + * Created on: 12 avr. 2024 + * Author: padi + */ + +#include "input.h" + +void init_button_a() +{ + LPC_GPIO2->FIODIR &= ~(1<<10); +} + +void init_button_b() +{ + LPC_GPIO0->FIODIR &= ~(1<<19); +} + +int button_get_state() +{ + LPC_GPIO2->FIOMASK = ~(1<<10); + uint8_t btn_a = (~(LPC_GPIO2->FIOPIN)>>10) & 0b1; + LPC_GPIO2->FIOMASK = 0x0; + + LPC_GPIO0->FIOMASK = ~(1<<19); + uint8_t btn_b = ((~(LPC_GPIO0->FIOPIN)>>19) & 0b1) << 1; + LPC_GPIO0->FIOMASK = 0x0; + + return btn_a + btn_b; +} diff --git a/src/input.h b/src/input.h new file mode 100644 index 0000000000000000000000000000000000000000..f316ec90de6987a507b7556d3cc2c4b6dca59630 --- /dev/null +++ b/src/input.h @@ -0,0 +1,19 @@ +/* + * input.h + * + * Created on: 12 avr. 2024 + * Author: padi + */ + +#ifndef INPUT_H_ +#define INPUT_H_ + +#include <stdbool.h> +#include "LPC17xx.h" + +void init_button_a(); +void init_button_b(); + +int button_get_state(); + +#endif /* INPUT_H_ */ diff --git a/src/lcd.c b/src/lcd.c new file mode 100644 index 0000000000000000000000000000000000000000..e79bcd9ed55a70fd523368f4a7accb7a8a709cb1 --- /dev/null +++ b/src/lcd.c @@ -0,0 +1,256 @@ +/* + * lcd.c + * + * Created on: Mar 1, 2024 + * Author: padi + */ +#include "lcd.h" + +void lcd_init() +{ + ssp_init(0b0111, 1); + + LPC_GPIO0->FIODIR |= 1 << 16; + LPC_GPIO0->FIOSET = 1 << 16; + + LPC_GPIO1->FIODIR |= 1 << 30; + LPC_GPIO1->FIOSET |= 1 << 30; + + LPC_GPIO1->FIODIR |= 1 << 18; + LPC_GPIO1->FIOSET = 1 << 18; + + // Interrupt for Delay + ILI9341_Initial(); +} + +void lcd_write_data(uint8_t data) +{ + LPC_GPIO0->FIOCLR = 1 << 16; + + ssp_send_buf(&data, 1); + + while(((LPC_SSP0->SR >> 4) & 0x1)){} + + LPC_GPIO0->FIOSET = 1 << 16; +} + +void lcd_write_cmd(uint8_t cmd) +{ + LPC_GPIO1->FIOCLR = 1 << 30; + + lcd_write_data(cmd); + + LPC_GPIO1->FIOSET = 1 << 30; +} + +void RGB(int R, int G, int B) +{ + //Limit the color max value to 255 and min to 0 + R = (R > 255) ? 255 : ((R < 0) ? 0 : R); + G = (G > 255) ? 255 : ((G < 0) ? 0 : G); + B = (B > 255) ? 255 : ((B < 0) ? 0 : B); + + //Max values : + // Red : 31 + // Green : 63 + // Blue : 31 + uint16_t Color_data = (((R * 31) / 255) << 11) | (((G * 63) / 255) << 5) | (B * 31 / 255); + + lcd_write_data(Color_data >> 8); + lcd_write_data(Color_data & 0xFF); +} + +int scrolling_pos = 0; + +void black_screen() +{ + lcd_write_cmd(0x2C); + + for (uint32_t i = 0; i < 240 * 320; i++) + { + RGB(0,0,0); + } +} + +void set_window(uint16_t start_x, uint16_t start_y, uint16_t height, uint16_t width) +{ + //X + lcd_write_cmd(0x2A); + + lcd_write_data(start_x >> 8); + lcd_write_data(start_x & 0xFF); + + uint16_t end_x = start_x+width-1; + + lcd_write_data(end_x >> 8); + lcd_write_data(end_x & 0xFF); + + //Y + lcd_write_cmd(0x2B); + + lcd_write_data(start_y >> 8); + lcd_write_data(start_y & 0xFF); + + uint16_t end_y = start_y+height-1; + + lcd_write_data(end_y >> 8); + lcd_write_data(end_y & 0xFF); +} + +void vertical_scroll() +{ + lcd_write_cmd(0x37); + lcd_write_data((scrolling_pos >> 8) & 0xFF); + lcd_write_data(scrolling_pos & 0xFF); + + scrolling_pos = (scrolling_pos + 1) % 320; + + set_window(0, scrolling_pos-1, 1, 240); + + lcd_write_cmd(0x2C); + + for (uint32_t i = 0; i < 1 * 240; i++) + { + RGB(0, 0, 0); + } + + lcd_write_cmd(0x00); +} + +void square(int R, int G, int B, uint16_t start_x, uint16_t start_y, uint16_t height, uint16_t width) +{ + set_window(start_x, start_y, height, width); + + lcd_write_cmd(0x2C); + + for (uint32_t i = 0; i < height * width; i++) + { + RGB(R, G, B); + } + + lcd_write_cmd(0x00); +} + +void delay(int ms) +{ + for (int var = 0; var < ms * 100000; ++var) + { + + } +} + +void ILI9341_Initial(void) +{ + lcd_write_cmd(0x01); //software reset + delay(5); + + lcd_write_cmd(0x11); + delay(120); + + lcd_write_cmd(0xCF); + lcd_write_data(0x00); + lcd_write_data(0x83); + lcd_write_data(0X30); + + lcd_write_cmd(0xED); + lcd_write_data(0x64); + lcd_write_data(0x03); + lcd_write_data(0X12); + lcd_write_data(0X81); + + lcd_write_cmd(0xE8); + lcd_write_data(0x85); + lcd_write_data(0x01); + lcd_write_data(0x79); + + lcd_write_cmd(0xCB); + lcd_write_data(0x39); + lcd_write_data(0x2C); + lcd_write_data(0x00); + lcd_write_data(0x34); + lcd_write_data(0x02); + + lcd_write_cmd(0xF7); + lcd_write_data(0x20); + + lcd_write_cmd(0xEA); + lcd_write_data(0x00); + lcd_write_data(0x00); + + + lcd_write_cmd(0xC1); //Power control + lcd_write_data(0x11); //SAP[2:0];BT[3:0] + + lcd_write_cmd(0xC5); //VCM control 1 + lcd_write_data(0x34); + lcd_write_data(0x3D); + + lcd_write_cmd(0xC7); //VCM control 2 + lcd_write_data(0xC0); + + lcd_write_cmd(0x36); // Memory Access Control + lcd_write_data(0x08); + + lcd_write_cmd(0x3A); // Pixel format + lcd_write_data(0x55); //16bit + + lcd_write_cmd(0xB1); // Frame rate + lcd_write_data(0x00); + lcd_write_data(0x1D); //65Hz + + lcd_write_cmd(0xB6); // Display Function Control + lcd_write_data(0x0A); + lcd_write_data(0xA2); + lcd_write_data(0x27); + lcd_write_data(0x00); + + lcd_write_cmd(0xb7); //Entry mode + lcd_write_data(0x07); + + + lcd_write_cmd(0xF2); // 3Gamma Function Disable + lcd_write_data(0x08); + + lcd_write_cmd(0x26); //Gamma curve selected + lcd_write_data(0x01); + + + lcd_write_cmd(0xE0); //positive gamma correction + lcd_write_data(0x1f); + lcd_write_data(0x1a); + lcd_write_data(0x18); + lcd_write_data(0x0a); + lcd_write_data(0x0f); + lcd_write_data(0x06); + lcd_write_data(0x45); + lcd_write_data(0x87); + lcd_write_data(0x32); + lcd_write_data(0x0a); + lcd_write_data(0x07); + lcd_write_data(0x02); + lcd_write_data(0x07); + lcd_write_data(0x05); + lcd_write_data(0x00); + + lcd_write_cmd(0xE1); //negamma correction + lcd_write_data(0x00); + lcd_write_data(0x25); + lcd_write_data(0x27); + lcd_write_data(0x05); + lcd_write_data(0x10); + lcd_write_data(0x09); + lcd_write_data(0x3a); + lcd_write_data(0x78); + lcd_write_data(0x4d); + lcd_write_data(0x05); + lcd_write_data(0x18); + lcd_write_data(0x0d); + lcd_write_data(0x38); + lcd_write_data(0x3a); + lcd_write_data(0x1f); + + lcd_write_cmd(0x11); //Exit Sleep + delay(120); + lcd_write_cmd(0x29); //Display on + delay(50); +} diff --git a/src/lcd.h b/src/lcd.h new file mode 100644 index 0000000000000000000000000000000000000000..5cb7cd4060edfea5ec4c6ed8a079c737b542d514 --- /dev/null +++ b/src/lcd.h @@ -0,0 +1,26 @@ +/* + * lcd.h + * + * Created on: Mar 1, 2024 + * Author: padi + */ + +#ifndef LCD_H_ +#define LCD_H_ + +#include "ssp.h" +#include "LPC17xx.h" +#include "systick.h" +#include <cr_section_macros.h> +#include <math.h> + +void lcd_init(); + +void vertical_scroll(); +void black_screen(); +void square(int R, int G, int B, uint16_t start_x, uint16_t start_y, uint16_t height, uint16_t width); +void ILI9341_Initial(void); +void delay(int ms); + + +#endif /* LCD_H_ */ diff --git a/src/ssp.c b/src/ssp.c new file mode 100644 index 0000000000000000000000000000000000000000..2471f8c75122055139f349f97be44c2604f9be61 --- /dev/null +++ b/src/ssp.c @@ -0,0 +1,51 @@ +/* + * ssp.c + * + * Created on: Feb 23, 2024 + * Author: padi + */ + +#include "ssp.h" + +void ssp_init(uint8_t data_size_select, uint8_t scr) +{ + // Power the peripheral + LPC_SC->PCONP |= 1 << 21; + + // Select the functions of the pins + LPC_PINCON->PINSEL0 = ((LPC_PINCON->PINSEL0 & ( ~(3 << 30) )) | (0b10 << 30)); + LPC_PINCON->PINSEL1 = ((LPC_PINCON->PINSEL1 & ( ~(3 << 2) )) | (0b10 << 2)); + LPC_PINCON->PINSEL1 = ((LPC_PINCON->PINSEL1 & ( ~(3 << 4) )) | (0b10 << 4)); + + // Enable interrupt + NVIC_EnableIRQ(SSP0_IRQn); + + // Set Clock + LPC_SC->PCLKSEL1 = (LPC_SC->PCLKSEL1 & (~(3 << 10))) | (2 << 10); + LPC_SSP0->CPSR = 5; + + + // Configure the peripheral + LPC_SSP0->CR0 = data_size_select | (scr << 8); + LPC_SSP0->CR1 = 1 << 1; +} + +void ssp_send_buf(uint8_t *buf, uint32_t length) +{ + for(int x = 0; x < length; x++) + { + while(!(LPC_SSP0->SR & 0x2)){} + + LPC_SSP0->DR = buf[x]; + } +} + +void ssp_receive_buf(uint8_t *buf, uint32_t length) +{ + for(int x = 0; x < length; x++) + { + while(!(LPC_SSP0->SR & 0x4)){} + + buf[x] = LPC_SSP0->DR; + } +} diff --git a/src/ssp.h b/src/ssp.h new file mode 100644 index 0000000000000000000000000000000000000000..03d867dbf0ea472322cc28e5572bf32bf168de05 --- /dev/null +++ b/src/ssp.h @@ -0,0 +1,18 @@ +/* + * ssp.h + * + * Created on: Feb 23, 2024 + * Author: padi + */ + +#ifndef SSP_H_ +#define SSP_H_ + +#include "LPC17xx.h" +#include <cr_section_macros.h> + +void ssp_init(uint8_t data_size_select, uint8_t scr); +void ssp_send_buf(uint8_t *buf, uint32_t length); +void ssp_receive_buf(uint8_t *buf, uint32_t length); + +#endif /* SSP_H_ */ diff --git a/src/systick.c b/src/systick.c new file mode 100644 index 0000000000000000000000000000000000000000..033e6a92a198e501f5b6e1a60cf71fca33886b9f --- /dev/null +++ b/src/systick.c @@ -0,0 +1,35 @@ +/* + * systick.c + * + * Created on: Mar 1, 2024 + * Author: padi + */ + +#include "systick.h" + +int tick_increment; + +void systick_init() +{ + SystemCoreClockUpdate(); + SysTick_Config(SystemCoreClock / 1000); +} + +void SysTick_Handler(void) +{ + tick_increment++; +} + +void Delay(int time) +{ + tick_increment = 0; + + volatile static int nothing = 0 ; + + while (tick_increment < time) + { + nothing++; + } + + LPC_TIM1->TCR &= ~(0b1); +} diff --git a/src/systick.h b/src/systick.h new file mode 100644 index 0000000000000000000000000000000000000000..f09ba56455813a2d04ba3d6d80e54fbace28c4ff --- /dev/null +++ b/src/systick.h @@ -0,0 +1,18 @@ +/* + * systick.h + * + * Created on: Mar 1, 2024 + * Author: padi + */ + +#ifndef SYSTICK_H_ +#define SYSTICK_H_ + +#include "LPC17xx.h" +#include <cr_section_macros.h> + +void systick_init(); +void Delay(int time); + + +#endif /* SYSTICK_H_ */ diff --git a/src/uart.c b/src/uart.c new file mode 100644 index 0000000000000000000000000000000000000000..f42f00bce7d5da3d07987ad6fd499f319eb40a49 --- /dev/null +++ b/src/uart.c @@ -0,0 +1,86 @@ +/* + * uart.c + * + * Created on: 22 mars 2024 + * Author: padi + */ + +#include "uart.h" + +char uart_buffer_in[4096] = {0}; + +void uart_init() +{ + // Turn on UART + LPC_SC->PCONP |= (0b1 << 3); + + // Clock + // Set PCLK_UART0 to CCLK / 1 + LPC_SC->PCLKSEL0 = (LPC_SC->PCLKSEL0 & (~(0b11 << 6))) | (0b01 << 6); + + // Pins + // Set bits 4 and 6 for TXD0 and RXD0 + LPC_PINCON->PINSEL0 = (LPC_PINCON->PINSEL0 & (~(0b1111 << 4))) | (0b0101 << 4); + + // Set bit 2 of FIODIR for TXD0 + LPC_GPIO0->FIODIR = (LPC_GPIO0->FIODIR & (~(1 << 3))) | (1 << 2); + + // Baud rate + // Set DLM + LPC_UART0->DLM = 0b0; + + // Enable DLAB + LPC_UART0->LCR = (0b1 << 7); + + // Set DLL + LPC_UART0->DLL = 54; + + // Set fractional divider + LPC_UART0->FDR = (0b0 & 0b1111) | ((0b1 & 0b1111) << 4); + + + // DLAB + LPC_UART0->LCR = (0b11 << 0) | (0 << 2) | (0 << 3) | (0b00 << 4) | (0 << 6) | (0 << 7); + + // FIFO + // Enable FIFO and reset FIFO buffers + LPC_UART0->FCR = (1 << 0) | (1 << 1) | (1 << 2) | (00 << 6); + + uart_send_string("UART Initialized !\r\n", 20); +} + +void uart_send_string(char *string, uint32_t length) +{ + for(int i = 0; i < length; i++) + { + while (!( LPC_UART0->LSR & (1<<5)) ); + LPC_UART0->THR = string[i]; + } +} + + +int uart_receive_string(char *string, uint32_t length, char *end_char, int timeout) +{ + int timeout_counter = 0; + + for (int i = 0; i < length; i++) + { + while (!(LPC_UART0->LSR & 0x01)) + { + if (timeout_counter >= timeout && timeout != 0) + { + return 0; + } + timeout_counter++; + } + + string[i] = LPC_UART0->RBR; + + if (end_char && string[i] == *end_char) + { + return i + 1; + } + } + + return length; +} diff --git a/src/uart.h b/src/uart.h new file mode 100644 index 0000000000000000000000000000000000000000..cd2aa6d49f40acecdaf45caf7c4d48ab8e84a91c --- /dev/null +++ b/src/uart.h @@ -0,0 +1,20 @@ +/* + * uart.h + * + * Created on: 22 mars 2024 + * Author: padi + */ + +#ifndef UART_H_ +#define UART_H_ + +#include "LPC17xx.h" +#include <stdint.h> + +extern char uart_buffer_in[4096]; + +void uart_init(); +void uart_send_string(char *string, uint32_t length); +int uart_receive_string(char *string, uint32_t length, char * end_char, int timeout); + +#endif /* UART_H_ */