Merge pull request #13 from vas-dav/state-machine
State-machine: add timer and ekey functionality
This commit is contained in:
commit
5b2e5ff49c
@ -1,5 +1,5 @@
|
|||||||
#MCUXpresso IDE
|
#MCUXpresso IDE
|
||||||
#Wed Sep 14 11:02:46 EEST 2022
|
#Fri Oct 14 12:50:11 EEST 2022
|
||||||
product.name=MCUXpresso IDE v11.5.0 [Build 7232] [2022-01-11]
|
product.name=MCUXpresso IDE v11.5.0 [Build 7232] [2022-01-11]
|
||||||
product.version=11.5.0
|
product.version=11.5.0
|
||||||
product.build=7232
|
product.build=7232
|
||||||
|
|||||||
@ -8,19 +8,19 @@
|
|||||||
#ifndef COUNTER_H_
|
#ifndef COUNTER_H_
|
||||||
#define COUNTER_H_
|
#define COUNTER_H_
|
||||||
|
|
||||||
class Counter {
|
class Counter
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Counter(int i, int up);
|
Counter (int i, int up);
|
||||||
void inc();
|
void inc ();
|
||||||
void dec();
|
void dec ();
|
||||||
int getCurrent();
|
int getCurrent ();
|
||||||
void setInit(int i);
|
void setInit (int i);
|
||||||
~Counter() = default;
|
~Counter () = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int init;
|
int init;
|
||||||
int up_lim;
|
int up_lim;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif /* COUNTER_H_ */
|
#endif /* COUNTER_H_ */
|
||||||
|
|||||||
@ -23,10 +23,10 @@ class Event {
|
|||||||
/** Time event */
|
/** Time event */
|
||||||
eTick
|
eTick
|
||||||
};
|
};
|
||||||
Event(eventType e = eTick, int b = 0, int t = 0)
|
Event(eventType e = eTick, uint8_t b = 0, int t = 0)
|
||||||
: type(e), button(b), temp(t){};
|
: type(e), button(b), temp(t){};
|
||||||
eventType type;
|
eventType type;
|
||||||
int button;
|
uint8_t button;
|
||||||
int temp;
|
int temp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -124,6 +124,12 @@ private:
|
|||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
void stateAuto (const Event &event);
|
void stateAuto (const Event &event);
|
||||||
|
|
||||||
|
/** Hnadle button presses
|
||||||
|
*
|
||||||
|
* @param button current button
|
||||||
|
*/
|
||||||
|
void handleControlButtons (uint8_t button);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* STATE_HANDLER_H_ */
|
#endif /* STATE_HANDLER_H_ */
|
||||||
|
|||||||
@ -7,39 +7,49 @@
|
|||||||
|
|
||||||
#include "Counter.h"
|
#include "Counter.h"
|
||||||
|
|
||||||
void Counter::inc() {
|
void
|
||||||
if(init >= up_lim){
|
Counter::inc ()
|
||||||
init = 0;
|
{
|
||||||
} else{
|
if (init < up_lim)
|
||||||
++init;
|
{
|
||||||
|
++init;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Counter::dec() {
|
void
|
||||||
if(init <= 0){
|
Counter::dec ()
|
||||||
init = up_lim;
|
{
|
||||||
} else{
|
if (init - 1 > 0)
|
||||||
--init;
|
{
|
||||||
|
--init;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
int Counter::getCurrent(){
|
Counter::getCurrent ()
|
||||||
|
{
|
||||||
return this->init;
|
return this->init;
|
||||||
}
|
}
|
||||||
|
|
||||||
Counter::Counter(int i, int up) {
|
Counter::Counter (int i, int up)
|
||||||
up_lim = up;
|
{
|
||||||
if(i > up){
|
up_lim = up;
|
||||||
init = up;
|
if (i > up)
|
||||||
}else if(i < 0){
|
{
|
||||||
init = 0;
|
init = up;
|
||||||
}else{
|
}
|
||||||
init = i;
|
else if (i < 0)
|
||||||
|
{
|
||||||
|
init = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
init = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Counter::setInit(int i){
|
void
|
||||||
|
Counter::setInit (int i)
|
||||||
|
{
|
||||||
init = i;
|
init = i;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,9 @@
|
|||||||
StateHandler::StateHandler (LiquidCrystal *lcd)
|
StateHandler::StateHandler (LiquidCrystal *lcd)
|
||||||
{
|
{
|
||||||
this->_lcd = lcd;
|
this->_lcd = lcd;
|
||||||
// TODO
|
current = &StateHandler::stateInit;
|
||||||
|
(this->*current) (Event (Event::eEnter));
|
||||||
|
current_mode = MANUAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
StateHandler::~StateHandler ()
|
StateHandler::~StateHandler ()
|
||||||
@ -21,19 +23,41 @@ StateHandler::~StateHandler ()
|
|||||||
void
|
void
|
||||||
StateHandler::displaySet (unsigned int value1, unsigned int value2)
|
StateHandler::displaySet (unsigned int value1, unsigned int value2)
|
||||||
{
|
{
|
||||||
// TODO
|
char line_up[16] = { 0 };
|
||||||
/**
|
char line_down[16] = { 0 };
|
||||||
* MANUAL MODE:
|
|
||||||
* ----------------
|
switch (current_mode)
|
||||||
* SPEED: 20%
|
{
|
||||||
* PRESSURE: XXPa
|
/*
|
||||||
* ----------------
|
* MANUAL MODE:
|
||||||
* AUTO MODE:
|
* ----------------
|
||||||
* ----------------
|
* SPEED: 20%
|
||||||
* PRESSURE SET: 35Pa
|
* PRESSURE: XXPa
|
||||||
* PRESSURE CUR: XXPa
|
* ----------------
|
||||||
* ----------------
|
*/
|
||||||
*/
|
case MANUAL:
|
||||||
|
snprintf (line_up, 16, "SPEED: %02d%", value1);
|
||||||
|
snprintf (line_down, 16, "PRESSURE: %02dPa", value2);
|
||||||
|
break;
|
||||||
|
/*
|
||||||
|
* AUTO MODE:
|
||||||
|
* ----------------
|
||||||
|
* P. SET: 35Pa
|
||||||
|
* P. CURR: XXPa
|
||||||
|
* ----------------
|
||||||
|
*/
|
||||||
|
case AUTO:
|
||||||
|
snprintf (line_up, 16, "P. SET: %02dPa", value1);
|
||||||
|
snprintf (line_down, 16, "P. CURR: %02dPa", value2);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_lcd->clear ();
|
||||||
|
_lcd->setCursor (0, 0);
|
||||||
|
_lcd->print (line_up);
|
||||||
|
_lcd->setCursor (0, 1);
|
||||||
|
_lcd->print (line_down);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
@ -63,15 +87,43 @@ StateHandler::SetState (state_pointer newstate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
stateInit (const Event &event)
|
StateHandler::stateInit (const Event &event)
|
||||||
{
|
{
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case Event::eEnter:
|
case Event::eEnter:
|
||||||
break;
|
break;
|
||||||
case Event::eExit:
|
case Event::eExit:
|
||||||
|
_lcd->clear ();
|
||||||
break;
|
break;
|
||||||
case Event::eKey:
|
case Event::eKey:
|
||||||
|
handleControlButtons (event.button);
|
||||||
|
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:
|
||||||
|
break;
|
||||||
|
case Event::eExit:
|
||||||
|
_lcd->clear ();
|
||||||
|
break;
|
||||||
|
case Event::eKey:
|
||||||
|
handleControlButtons (event.button);
|
||||||
break;
|
break;
|
||||||
case Event::eTick:
|
case Event::eTick:
|
||||||
break;
|
break;
|
||||||
@ -79,15 +131,17 @@ stateInit (const Event &event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
stateManual (const Event &event)
|
StateHandler::stateAuto (const Event &event)
|
||||||
{
|
{
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case Event::eEnter:
|
case Event::eEnter:
|
||||||
break;
|
break;
|
||||||
case Event::eExit:
|
case Event::eExit:
|
||||||
|
_lcd->clear ();
|
||||||
break;
|
break;
|
||||||
case Event::eKey:
|
case Event::eKey:
|
||||||
|
handleControlButtons (event.button);
|
||||||
break;
|
break;
|
||||||
case Event::eTick:
|
case Event::eTick:
|
||||||
break;
|
break;
|
||||||
@ -95,17 +149,21 @@ stateManual (const Event &event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
stateAuto (const Event &event)
|
StateHandler::handleControlButtons (uint8_t button)
|
||||||
{
|
{
|
||||||
switch (event.type)
|
switch (button)
|
||||||
{
|
{
|
||||||
case Event::eEnter:
|
case BUTTON_CONTROL_DOWN:
|
||||||
|
this->value[(current_mode) ? AUTO : MANUAL].dec ();
|
||||||
break;
|
break;
|
||||||
case Event::eExit:
|
case BUTTON_CONTROL_UP:
|
||||||
|
this->value[(current_mode) ? AUTO : MANUAL].inc ();
|
||||||
break;
|
break;
|
||||||
case Event::eKey:
|
case BUTTON_CONTROL_TOG_MODE:
|
||||||
|
current_mode = !current_mode;
|
||||||
|
SetState (&StateHandler::stateInit);
|
||||||
break;
|
break;
|
||||||
case Event::eTick:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
242
Timer/.cproject
Normal file
242
Timer/.cproject
Normal 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.141066949">
|
||||||
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.lib.debug.141066949" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||||
|
<externalSettings>
|
||||||
|
<externalSetting>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Timer"/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Timer/Debug"/>
|
||||||
|
<entry flags="RESOLVED" kind="libraryFile" name="Timer" 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.141066949" name="Debug" parent="com.crt.advproject.config.lib.debug" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size "lib${BuildArtifactFileName}" ; # arm-none-eabi-objdump -h -S "lib${BuildArtifactFileName}" >"${BuildArtifactFileBaseName}.lss"">
|
||||||
|
<folderInfo id="com.crt.advproject.config.lib.debug.141066949." name="/" resourcePath="">
|
||||||
|
<toolChain id="com.crt.advproject.toolchain.lib.debug.1864536258" 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.715190497" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.lib.debug"/>
|
||||||
|
<builder buildPath="${workspace_loc:/Timer}/Debug" id="com.crt.advproject.builder.lib.debug.362371353" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.debug"/>
|
||||||
|
<tool id="com.crt.advproject.cpp.lib.debug.1376747124" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.debug">
|
||||||
|
<option id="com.crt.advproject.cpp.thumb.853945744" name="Thumb mode" superClass="com.crt.advproject.cpp.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option id="com.crt.advproject.cpp.specs.1019234865" 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.1483220001" 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.1211143163" 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.1973382433" 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.1419527755" 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.1666306902" name="Library headers" superClass="com.crt.advproject.cpp.hdrlib" useByScannerDiscovery="false" value="Newlib" valueType="enumerated"/>
|
||||||
|
<option id="com.crt.advproject.cpp.fpu.1485407808" 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.933211393" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_chip_15xx/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc://inc}""/>
|
||||||
|
</option>
|
||||||
|
<option id="com.crt.advproject.cpp.misc.dialect.954981710" 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.997653122" superClass="com.crt.advproject.compiler.cpp.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="com.crt.advproject.gcc.lib.debug.54498589" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.debug">
|
||||||
|
<option id="com.crt.advproject.gcc.thumb.579066531" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option id="com.crt.advproject.gcc.arch.977470243" 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.286152175" 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.1760689758" 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.772772939" 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.197503344" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_chip_15xx/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc://inc}""/>
|
||||||
|
</option>
|
||||||
|
<option id="com.crt.advproject.c.misc.dialect.1063734703" superClass="com.crt.advproject.c.misc.dialect" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
|
||||||
|
<option id="com.crt.advproject.gcc.hdrlib.2095820491" superClass="com.crt.advproject.gcc.hdrlib" value="Newlib" valueType="enumerated"/>
|
||||||
|
<option id="com.crt.advproject.gcc.specs.96244547" superClass="com.crt.advproject.gcc.specs" value="com.crt.advproject.gcc.specs.newlib" valueType="enumerated"/>
|
||||||
|
<inputType id="com.crt.advproject.compiler.input.162099517" superClass="com.crt.advproject.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="com.crt.advproject.gas.lib.debug.363561805" name="MCU Assembler" superClass="com.crt.advproject.gas.lib.debug">
|
||||||
|
<option id="com.crt.advproject.gas.thumb.2066591309" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/>
|
||||||
|
<option id="com.crt.advproject.gas.arch.2024241403" 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.1776970218" 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.1243276742" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_chip_15xx/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc://inc}""/>
|
||||||
|
</option>
|
||||||
|
<option id="com.crt.advproject.gas.hdrlib.1805294167" superClass="com.crt.advproject.gas.hdrlib" value="Newlib" valueType="enumerated"/>
|
||||||
|
<option id="com.crt.advproject.gas.specs.269530202" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.newlib" valueType="enumerated"/>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.469636420" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||||
|
<inputType id="com.crt.advproject.assembler.input.181644609" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="com.crt.advproject.ar.lib.debug.802643729" 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.1759018253">
|
||||||
|
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.crt.advproject.config.lib.release.1759018253" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||||
|
<externalSettings>
|
||||||
|
<externalSetting>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/Timer"/>
|
||||||
|
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/Timer/Release"/>
|
||||||
|
<entry flags="RESOLVED" kind="libraryFile" name="Timer" 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.1759018253" name="Release" parent="com.crt.advproject.config.lib.release" postannouncebuildStep="Performing post-build steps" postbuildStep="arm-none-eabi-size "lib${BuildArtifactFileName}" ; # arm-none-eabi-objdump -h -S "lib${BuildArtifactFileName}" >"${BuildArtifactFileBaseName}.lss"">
|
||||||
|
<folderInfo id="com.crt.advproject.config.lib.release.1759018253." name="/" resourcePath="">
|
||||||
|
<toolChain id="com.crt.advproject.toolchain.lib.release.2133517867" 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.1818530715" name="ARM-based MCU (Debug)" superClass="com.crt.advproject.platform.lib.release"/>
|
||||||
|
<builder buildPath="${workspace_loc:/Timer}/Release" id="com.crt.advproject.builder.lib.release.556933730" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="com.crt.advproject.builder.lib.release"/>
|
||||||
|
<tool id="com.crt.advproject.cpp.lib.release.2046270587" name="MCU C++ Compiler" superClass="com.crt.advproject.cpp.lib.release">
|
||||||
|
<option id="com.crt.advproject.cpp.thumb.2007377019" name="Thumb mode" superClass="com.crt.advproject.cpp.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option id="com.crt.advproject.cpp.specs.1260187295" 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.1789958096" 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.1653719661" 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.2087205212" 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.51742231" 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.1051465865" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_chip_15xx/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc://inc}""/>
|
||||||
|
</option>
|
||||||
|
<option id="com.crt.advproject.cpp.misc.dialect.830307454" superClass="com.crt.advproject.cpp.misc.dialect" value="com.crt.advproject.misc.dialect.c++11" valueType="enumerated"/>
|
||||||
|
<option id="com.crt.advproject.cpp.hdrlib.1979223629" superClass="com.crt.advproject.cpp.hdrlib" value="Newlib" valueType="enumerated"/>
|
||||||
|
<inputType id="com.crt.advproject.compiler.cpp.input.447511707" superClass="com.crt.advproject.compiler.cpp.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="com.crt.advproject.gcc.lib.release.854009082" name="MCU C Compiler" superClass="com.crt.advproject.gcc.lib.release">
|
||||||
|
<option id="com.crt.advproject.gcc.thumb.531224998" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||||
|
<option id="com.crt.advproject.gcc.arch.118103664" 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.349470409" 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.1914235053" 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.873667882" 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.332010264" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_chip_15xx/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc://inc}""/>
|
||||||
|
</option>
|
||||||
|
<option id="com.crt.advproject.c.misc.dialect.1421066475" superClass="com.crt.advproject.c.misc.dialect" value="com.crt.advproject.misc.dialect.c11" valueType="enumerated"/>
|
||||||
|
<option id="com.crt.advproject.gcc.hdrlib.1624299149" superClass="com.crt.advproject.gcc.hdrlib" value="Newlib" valueType="enumerated"/>
|
||||||
|
<option id="com.crt.advproject.gcc.specs.736473378" superClass="com.crt.advproject.gcc.specs" value="com.crt.advproject.gcc.specs.newlib" valueType="enumerated"/>
|
||||||
|
<inputType id="com.crt.advproject.compiler.input.2021903808" superClass="com.crt.advproject.compiler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="com.crt.advproject.gas.lib.release.715361413" name="MCU Assembler" superClass="com.crt.advproject.gas.lib.release">
|
||||||
|
<option id="com.crt.advproject.gas.thumb.1214124388" name="Thumb mode" superClass="com.crt.advproject.gas.thumb" value="true" valueType="boolean"/>
|
||||||
|
<option id="com.crt.advproject.gas.arch.2045542888" 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.1015613135" 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.588165123" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_chip_15xx/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc://inc}""/>
|
||||||
|
</option>
|
||||||
|
<option id="com.crt.advproject.gas.hdrlib.1385331930" superClass="com.crt.advproject.gas.hdrlib" value="Newlib" valueType="enumerated"/>
|
||||||
|
<option id="com.crt.advproject.gas.specs.493366594" superClass="com.crt.advproject.gas.specs" value="com.crt.advproject.gas.specs.newlib" valueType="enumerated"/>
|
||||||
|
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.89226607" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
||||||
|
<inputType id="com.crt.advproject.assembler.input.739713420" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
|
||||||
|
</tool>
|
||||||
|
<tool id="com.crt.advproject.ar.lib.release.3927665" 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="Timer.com.crt.advproject.projecttype.lib.808057918" 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><?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<TargetConfig>
|
||||||
|
<Properties property_2="LPC15xx_256K.cfx" property_3="NXP" property_4="LPC1549" property_count="5" version="100300"/>
|
||||||
|
<infoList vendor="NXP">
|
||||||
|
<info chip="LPC1549" connectscript="LPC15RunBootRomConnect.scp" flash_driver="LPC15xx_256K.cfx" match_id="0x0" name="LPC1549" resetscript="LPC15RunBootRomReset.scp" stub="crt_emu_cm3_gen">
|
||||||
|
<chip>
|
||||||
|
<name>LPC1549</name>
|
||||||
|
<family>LPC15xx</family>
|
||||||
|
<vendor>NXP (formerly Philips)</vendor>
|
||||||
|
<reset board="None" core="Real" sys="Real"/>
|
||||||
|
<clock changeable="TRUE" freq="12MHz" 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="MFlash256" location="0x0" size="0x40000"/>
|
||||||
|
<memoryInstance derived_from="RAM" id="Ram0_16" location="0x2000000" size="0x4000"/>
|
||||||
|
<memoryInstance derived_from="RAM" id="Ram1_16" location="0x2004000" size="0x4000"/>
|
||||||
|
<memoryInstance derived_from="RAM" id="Ram2_4" location="0x2008000" size="0x1000"/>
|
||||||
|
</chip>
|
||||||
|
<processor>
|
||||||
|
<name gcc_name="cortex-m3">Cortex-M3</name>
|
||||||
|
<family>Cortex-M</family>
|
||||||
|
</processor>
|
||||||
|
</info>
|
||||||
|
</infoList>
|
||||||
|
</TargetConfig></projectStorage>
|
||||||
|
</storageModule>
|
||||||
|
<storageModule moduleId="com.crt.advproject">
|
||||||
|
<boardId>LPCXpresso1549</boardId>
|
||||||
|
</storageModule>
|
||||||
|
</cproject>
|
||||||
28
Timer/.project
Normal file
28
Timer/.project
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Timer</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>
|
||||||
76
Timer/inc/Timer.h
Normal file
76
Timer/inc/Timer.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Timer.h
|
||||||
|
*
|
||||||
|
* Created on: Oct 14, 2022
|
||||||
|
* Author: tylen
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TIMER_H_
|
||||||
|
#define TIMER_H_
|
||||||
|
|
||||||
|
#include "board.h"
|
||||||
|
#include <atomic>
|
||||||
|
#include <climits>
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief Handle interrupt from SysTick timer
|
||||||
|
* @return Nothing
|
||||||
|
*/
|
||||||
|
void SysTick_Handler (void);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Timer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Initalize the systick configuration with your frequency
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Timer (uint32_t freq = 1000);
|
||||||
|
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 timer;
|
||||||
|
uint32_t freq;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* TIMER_H_ */
|
||||||
32
Timer/liblinks.xml
Normal file
32
Timer/liblinks.xml
Normal 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>
|
||||||
|
|
||||||
65
Timer/src/Timer.cpp
Normal file
65
Timer/src/Timer.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Timer.cpp
|
||||||
|
*
|
||||||
|
* Created on: Oct 14, 2022
|
||||||
|
* Author: tylen
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Timer.h>
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
void
|
||||||
|
SysTick_Handler (void)
|
||||||
|
{
|
||||||
|
if (timer > 0)
|
||||||
|
timer--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer::Timer (uint32_t freq) : freq (freq)
|
||||||
|
{
|
||||||
|
Chip_Clock_SetSysTickClockDiv (1);
|
||||||
|
uint32_t sysTickRate = Chip_Clock_GetSysTickClockRate ();
|
||||||
|
SysTick_Config (sysTickRate / freq);
|
||||||
|
counter = 0;
|
||||||
|
timer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer::~Timer ()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated destructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Timer::tickCounter (int ms)
|
||||||
|
{
|
||||||
|
if (counter >= INT_MAX)
|
||||||
|
{
|
||||||
|
counter = 0;
|
||||||
|
}
|
||||||
|
counter++;
|
||||||
|
Sleep (ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Timer::Sleep (int ms)
|
||||||
|
{
|
||||||
|
timer = ms;
|
||||||
|
while (timer > 0)
|
||||||
|
{
|
||||||
|
__WFI ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Timer::getCounter ()
|
||||||
|
{
|
||||||
|
return counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Timer::resetCounter ()
|
||||||
|
{
|
||||||
|
counter = 0;
|
||||||
|
}
|
||||||
@ -44,6 +44,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/inc}""/>
|
||||||
</option>
|
</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"/>
|
<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"/>
|
<inputType id="com.crt.advproject.compiler.cpp.input.1024506123" superClass="com.crt.advproject.compiler.cpp.input"/>
|
||||||
@ -71,6 +72,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/inc}""/>
|
||||||
</option>
|
</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"/>
|
<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"/>
|
<inputType id="com.crt.advproject.compiler.input.1491212950" superClass="com.crt.advproject.compiler.input"/>
|
||||||
@ -88,6 +90,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/inc}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.486566022" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
<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"/>
|
<inputType id="com.crt.advproject.assembler.input.255980151" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
|
||||||
@ -118,6 +121,7 @@
|
|||||||
<listOptionValue builtIn="false" value="DigitalIoPin"/>
|
<listOptionValue builtIn="false" value="DigitalIoPin"/>
|
||||||
<listOptionValue builtIn="false" value="LiquidCrystal"/>
|
<listOptionValue builtIn="false" value="LiquidCrystal"/>
|
||||||
<listOptionValue builtIn="false" value="I2C"/>
|
<listOptionValue builtIn="false" value="I2C"/>
|
||||||
|
<listOptionValue builtIn="false" value="StateHandler"/>
|
||||||
</option>
|
</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">
|
<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=""${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/Debug}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/Debug}""/>
|
||||||
@ -125,6 +129,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/Debug}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/Debug}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/Debug}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/Debug}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/Debug}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/Debug}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/Debug}""/>
|
||||||
</option>
|
</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"/>
|
<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">
|
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.849613399" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||||
@ -188,6 +193,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/inc}""/>
|
||||||
</option>
|
</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"/>
|
<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"/>
|
<inputType id="com.crt.advproject.compiler.cpp.input.812988440" superClass="com.crt.advproject.compiler.cpp.input"/>
|
||||||
@ -215,6 +221,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/inc}""/>
|
||||||
</option>
|
</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"/>
|
<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"/>
|
<inputType id="com.crt.advproject.compiler.input.391538574" superClass="com.crt.advproject.compiler.input"/>
|
||||||
@ -232,6 +239,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/inc}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/inc}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/inc}""/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1169670567" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
|
<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"/>
|
<inputType id="com.crt.advproject.assembler.input.956763731" name="Additional Assembly Source Files" superClass="com.crt.advproject.assembler.input"/>
|
||||||
@ -262,6 +270,7 @@
|
|||||||
<listOptionValue builtIn="false" value="DigitalIoPin"/>
|
<listOptionValue builtIn="false" value="DigitalIoPin"/>
|
||||||
<listOptionValue builtIn="false" value="LiquidCrystal"/>
|
<listOptionValue builtIn="false" value="LiquidCrystal"/>
|
||||||
<listOptionValue builtIn="false" value="I2C"/>
|
<listOptionValue builtIn="false" value="I2C"/>
|
||||||
|
<listOptionValue builtIn="false" value="StateHandler"/>
|
||||||
</option>
|
</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">
|
<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=""${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/Release}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/lpc_board_nxp_lpcxpresso_1549/Release}""/>
|
||||||
@ -269,6 +278,7 @@
|
|||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/Release}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/DigitalIoPin/Release}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/Release}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/LiquidCrystal/Release}""/>
|
||||||
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/Release}""/>
|
<listOptionValue builtIn="false" value=""${workspace_loc:/I2C/Release}""/>
|
||||||
|
<listOptionValue builtIn="false" value=""${workspace_loc:/StateHandler/Release}""/>
|
||||||
</option>
|
</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"/>
|
<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">
|
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1513506142" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
<project>DigitalIoPin</project>
|
<project>DigitalIoPin</project>
|
||||||
<project>LiquidCrystal</project>
|
<project>LiquidCrystal</project>
|
||||||
<project>I2C</project>
|
<project>I2C</project>
|
||||||
|
<project>StateHandler</project>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
|
|||||||
@ -16,6 +16,9 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "DigitalIoPin.h"
|
||||||
|
#include "StateHandler.h"
|
||||||
|
|
||||||
#include <cr_section_macros.h>
|
#include <cr_section_macros.h>
|
||||||
|
|
||||||
// TODO: insert other include files here
|
// TODO: insert other include files here
|
||||||
@ -30,7 +33,7 @@ main (void)
|
|||||||
// Read clock settings and update SystemCoreClock variable
|
// Read clock settings and update SystemCoreClock variable
|
||||||
SystemCoreClockUpdate ();
|
SystemCoreClockUpdate ();
|
||||||
#if !defined(NO_BOARD_LIB)
|
#if !defined(NO_BOARD_LIB)
|
||||||
// Set up and initialize all required blocks and
|
// Set b_up_state and initialize all required blocks and
|
||||||
// functions related to the board hardware
|
// functions related to the board hardware
|
||||||
Board_Init ();
|
Board_Init ();
|
||||||
// Set the LED to the state of "On"
|
// Set the LED to the state of "On"
|
||||||
@ -38,8 +41,43 @@ main (void)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
DigitalIoPin b_up ();
|
||||||
|
DigitalIoPin b_down ();
|
||||||
|
DigitalIoPin b_toggle ();
|
||||||
|
bool b_up_state = false, b_down_state = false, b_toggle_state = false;
|
||||||
|
|
||||||
|
StateHandler ventMachine;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
if (b_up.read ())
|
||||||
|
b_up_state = true;
|
||||||
|
if (!b_up.read () && b_up_state)
|
||||||
|
{
|
||||||
|
ventMachine.HandleState (Event (Event::eKey, BUTTON_CONTROL_UP));
|
||||||
|
b_up_state = false;
|
||||||
|
}
|
||||||
|
if (b_down.read ())
|
||||||
|
b_down_state = true;
|
||||||
|
if (!b_down.read () && b_down_state)
|
||||||
|
{
|
||||||
|
ventMachine.HandleState (Event (Event::eKey, BUTTON_CONTROL_DOWN));
|
||||||
|
b_down_state = false;
|
||||||
|
}
|
||||||
|
if (b_toggle.read ())
|
||||||
|
b_toggle_state = true;
|
||||||
|
if (!b_toggle.read () && b_toggle_state)
|
||||||
|
{
|
||||||
|
ventMachine.HandleState (
|
||||||
|
Event (Event::eKey, BUTTON_CONTROL_TOG_MODE));
|
||||||
|
b_toggle_state = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO:
|
||||||
|
* - Update current pressure to eTick
|
||||||
|
*/
|
||||||
|
ventMachine.HandleState (Event (Event::eTick));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user