summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-05-08 16:21:33 +0200
committerNao Pross <naopross@thearcway.org>2018-05-08 16:21:33 +0200
commit2490b24a1ced7372e4462c60802748e426901da1 (patch)
treee7ec935869975c526d6786d1c78e0e10046ab25d
parentCheck if substring is empty in split(), minor fix in command parsing (diff)
downloadSAMLiquidSmoke-master.tar.gz
SAMLiquidSmoke-master.zip
Add notes, rename gpio class to gpio_pin and rename led variablesHEADmaster
-rw-r--r--hal/hwconfig.cpp24
-rw-r--r--hal/pin.hpp10
-rw-r--r--led.cpp6
-rw-r--r--led.hpp8
-rw-r--r--main.cpp53
-rw-r--r--nbproject/Makefile-default.mk6
-rw-r--r--nbproject/Makefile-genesis.properties14
-rw-r--r--nbproject/Makefile-local-default.mk29
-rw-r--r--nbproject/configurations.xml7
9 files changed, 93 insertions, 64 deletions
diff --git a/hal/hwconfig.cpp b/hal/hwconfig.cpp
index f443f59..1f4cdff 100644
--- a/hal/hwconfig.cpp
+++ b/hal/hwconfig.cpp
@@ -24,12 +24,32 @@ void hw::regunlock()
void osc::initialize()
{
hw::regunlock();
- // CF no clock failure; COSC FRCDIV; PLLODIV DIV_256; UFRCEN disabled; PBDIVRDY disabled; SLOCK out of lock; FRCDIV FRC/1; SLPEN Idle on WAIT instruction; NOSC FRCDIV; PLLMULT MUL_24; SOSCEN disabled; PBDIV DIV_8; CLKLOCK unlocked; OSWEN Switch is Complete; SOSCRDY disabled;
+ // CF no clock failure;
+ // COSC FRCDIV;
+ // PLLODIV DIV_256;
+ // UFRCEN disabled;
+ // PBDIVRDY disabled;
+ // SLOCK out of lock;
+ // FRCDIV FRC/1;
+ // SLPEN Idle on WAIT instruction;
+ // NOSC FRCDIV; PLLMULT MUL_24;
+ // SOSCEN disabled;
+ // PBDIV DIV_8;
+ // CLKLOCK unlocked;
+ // OSWEN Switch is Complete;
+ // SOSCRDY disabled;
OSCCON = 0x381F7700;
hw::reglock();
// TUN Center Frequency;
OSCTUN = 0x0;
- // DIVSWEN disabled; RSLP disabled; ACTIVE Active; ROSEL SYSCLK; OE Not Driven out on REFCLKO pin; SIDL disabled; RODIV 0; ON disabled;
+ // DIVSWEN disabled;
+ // RSLP disabled;
+ // ACTIVE Active;
+ // ROSEL SYSCLK;
+ // OE Not Driven out on REFCLKO pin;
+ // SIDL disabled;
+ // RODIV 0;
+ // ON disabled;
REFOCON = 0x100;
// ROTRIM 0;
REFOTRIM = 0x0;
diff --git a/hal/pin.hpp b/hal/pin.hpp
index ab9d3ad..13e9a52 100644
--- a/hal/pin.hpp
+++ b/hal/pin.hpp
@@ -8,14 +8,16 @@
#ifndef PIN_HPP
#define PIN_HPP
+#include <cstdint>
+
extern "C" {
#include <xc.h>
}
-class gpio
+class gpio_pin
{
public:
- virtual ~gpio() {}
+ virtual ~gpio_pin() {}
// digital mode methods
virtual void set_mode(unsigned m) = 0;
@@ -31,11 +33,11 @@ public:
// TODO: analog mode methods
protected:
- gpio() {}
+ gpio_pin() {}
};
template<unsigned bit>
-class io_pin : public gpio {
+class io_pin : public gpio_pin {
public:
enum class mode : unsigned
{ INPUT = 1, OUTPUT = 0 };
diff --git a/led.cpp b/led.cpp
index 4888d84..7cfcb0f 100644
--- a/led.cpp
+++ b/led.cpp
@@ -7,7 +7,7 @@
#include "led.hpp"
-led::led(gpio *pin, led::color color) : _pin(pin), _color(color)
+led::led(gpio_pin *pin, led::color color) : _pin(pin), _color(color)
{
_pin->set_mode(0); // output
}
@@ -18,14 +18,14 @@ led::~led()
}
-void led::pin(gpio *pin)
+void led::pin(gpio_pin *pin)
{
if (pin) {
_pin = pin;
}
}
-gpio * led::pin() const
+gpio_pin * led::pin() const
{
return _pin;
}
diff --git a/led.hpp b/led.hpp
index 0e674bb..f266d4b 100644
--- a/led.hpp
+++ b/led.hpp
@@ -19,11 +19,11 @@ public:
RED, GREEN, YELLOW,
};
- led(gpio *pin, color color);
+ led(gpio_pin *pin, color color);
virtual ~led();
- void pin(gpio *pin);
- gpio * pin() const ;
+ void pin(gpio_pin *pin);
+ gpio_pin * pin() const ;
void get_color(color color);
color set_color() const;
@@ -37,7 +37,7 @@ public:
private:
led() {}
- gpio *_pin = nullptr;
+ gpio_pin *_pin = nullptr;
color _color;
};
diff --git a/main.cpp b/main.cpp
index de37652..4d00772 100644
--- a/main.cpp
+++ b/main.cpp
@@ -5,6 +5,7 @@
* Created on May 1, 2018, 6:18 PM
*/
+// Note: there is some debug code in uart.tpp that controls the RGB led
// #define DEBUG
// basic devices
@@ -54,7 +55,7 @@ std::vector<std::string> split(const std::string& str, const char sep)
return v;
}
-int main(int argc, char** argv)
+int main(int argc, char *argv[])
{
osc::initialize();
interrupts::initialize();
@@ -69,14 +70,14 @@ int main(int argc, char** argv)
io_pin<7> led3_pin(&LATEbits, &TRISEbits, &PORTEbits);
// build leds
- led led1(static_cast<gpio *>(&led1_pin), led::color::RED);
- led led2(static_cast<gpio *>(&led2_pin), led::color::GREEN);
- led led3(static_cast<gpio *>(&led3_pin), led::color::YELLOW);
+ led led_red(static_cast<gpio_pin *>(&led1_pin), led::color::RED);
+ led led_green(static_cast<gpio_pin *>(&led2_pin), led::color::GREEN);
+ led led_yellow(static_cast<gpio_pin *>(&led3_pin), led::color::YELLOW);
#ifdef DEBUG
- led1.set(1);
- led2.set(1);
- led3.set(1);
+ led_red.set(1);
+ led_green.set(1);
+ led_yellow.set(1);
uart::write<1>("started\n\r");
#endif
@@ -90,11 +91,15 @@ int main(int argc, char** argv)
do {
input += uart::read_wait<1>();
+ // Note: does not work with teraterm on windows
// DEL character
if (input.back() == '\x7f') {
input.pop_back();
- input.pop_back();
- uart::write<1>("\b \b");
+
+ if (input.size() > 1) {
+ input.pop_back();
+ uart::write<1>("\b \b");
+ }
}
} while (input.back() != '\r' && input.back() != '\n');
@@ -140,9 +145,9 @@ int main(int argc, char** argv)
if (command[0] == "show") {
if (command[1] == "led") {
if (command[2] == "all") {
- uart::print<1>(led1.to_string());
- uart::print<1>(led2.to_string());
- uart::print<1>(led3.to_string());
+ uart::print<1>(led_red.to_string());
+ uart::print<1>(led_green.to_string());
+ uart::print<1>(led_yellow.to_string());
}
}
}
@@ -162,31 +167,31 @@ int main(int argc, char** argv)
if (command[1] == "led") {
if (command[2] == "red") {
if (command[3] == "on") {
- led1.set(1);
+ led_red.set(1);
} else if (command[3] == "off") {
- led1.set(0);
+ led_red.set(0);
}
} else if (command[2] == "green") {
if (command[3] == "on") {
- led2.set(1);
+ led_green.set(1);
} else if (command[3] == "off") {
- led2.set(0);
+ led_green.set(0);
}
} else if (command[2] == "yellow") {
if (command[3] == "on") {
- led3.set(1);
+ led_yellow.set(1);
} else if (command[3] == "off") {
- led3.set(0);
+ led_yellow.set(0);
}
} else if (command[2] == "all") {
if (command[3] == "on") {
- led1.set(1);
- led2.set(1);
- led3.set(1);
+ led_red.set(1);
+ led_green.set(1);
+ led_yellow.set(1);
} else if (command[3] == "off") {
- led1.set(0);
- led2.set(0);
- led3.set(0);
+ led_red.set(0);
+ led_green.set(0);
+ led_yellow.set(0);
}
}
}
diff --git a/nbproject/Makefile-default.mk b/nbproject/Makefile-default.mk
index 3dcd31b..757d817 100644
--- a/nbproject/Makefile-default.mk
+++ b/nbproject/Makefile-default.mk
@@ -19,7 +19,7 @@ endif
endif
# Environment
-MKDIR=mkdir -p
+MKDIR=gnumkdir -p
RM=rm -f
MV=mv
CP=cp
@@ -162,7 +162,7 @@ else
dist/${CND_CONF}/${IMAGE_TYPE}/LiquidSmoke.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE}
${MP_CPPC} $(MP_EXTRA_LD_PRE) -mprocessor=$(MP_PROCESSOR_OPTION) -o dist/${CND_CONF}/${IMAGE_TYPE}/LiquidSmoke.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED} -DXPRJ_default=$(CND_CONF) $(COMPARISON_BUILD) -Wl,--defsym=__MPLAB_BUILD=1$(MP_EXTRA_LD_POST)$(MP_LINKER_FILE_OPTION),--defsym=_min_heap_size=32K,--no-code-in-dinit,--no-dinit-in-serial-mem,-Map="${DISTDIR}/${PROJECTNAME}.${IMAGE_TYPE}.map",--memorysummary,dist/${CND_CONF}/${IMAGE_TYPE}/memoryfile.xml
- ${MP_CC_DIR}/xc32-bin2hex dist/${CND_CONF}/${IMAGE_TYPE}/LiquidSmoke.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX}
+ ${MP_CC_DIR}\\xc32-bin2hex dist/${CND_CONF}/${IMAGE_TYPE}/LiquidSmoke.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX}
endif
@@ -181,7 +181,7 @@ endif
# Enable dependency checking
.dep.inc: .depcheck-impl
-DEPFILES=$(shell "${PATH_TO_IDE_BIN}"mplabwildcard ${POSSIBLE_DEPFILES})
+DEPFILES=$(shell mplabwildcard ${POSSIBLE_DEPFILES})
ifneq (${DEPFILES},)
include ${DEPFILES}
endif
diff --git a/nbproject/Makefile-genesis.properties b/nbproject/Makefile-genesis.properties
index bd9d9ba..f2db881 100644
--- a/nbproject/Makefile-genesis.properties
+++ b/nbproject/Makefile-genesis.properties
@@ -1,9 +1,9 @@
#
-#Sat May 05 14:33:20 CEST 2018
-default.com-microchip-mplab-nbide-toolchainXC32-XC32LanguageToolchain.md5=fcf9db1a3d46b4ef4e0a46afcbf02251
-default.languagetoolchain.dir=/opt/microchip/xc32/v2.05/bin
-configurations-xml=4957a7627114c3c1c982e099652971a3
-com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=c8c2915d32f5d7e4be49831bc9827ab0
-default.languagetoolchain.version=2.05
-host.platform=linux
+#Tue May 08 16:07:06 CEST 2018
+default.com-microchip-mplab-nbide-toolchainXC32-XC32LanguageToolchain.md5=002e07fc35a732566b3c80c1ed2897e8
+default.languagetoolchain.dir=C\:\\Program Files\\Microchip\\xc32\\v1.44\\bin
+configurations-xml=2397e9904cff683529583ff173edf25d
+com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=5d30ff5128b14865c8a3796a8f0bb8a0
+default.languagetoolchain.version=1.44
+host.platform=windows
conf.ids=default
diff --git a/nbproject/Makefile-local-default.mk b/nbproject/Makefile-local-default.mk
index 39019b0..1dd99ba 100644
--- a/nbproject/Makefile-local-default.mk
+++ b/nbproject/Makefile-local-default.mk
@@ -14,23 +14,24 @@
# You can invoke make with the values of the macros:
# $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ...
#
-PATH_TO_IDE_BIN=/opt/microchip/mplabx/v4.15/mplab_ide/platform/../mplab_ide/modules/../../bin/
+SHELL=cmd.exe
+PATH_TO_IDE_BIN=C:/Program Files/Microchip/MPLABX/v4.05/mplab_ide/platform/../mplab_ide/modules/../../bin/
# Adding MPLAB X bin directory to path.
-PATH:=/opt/microchip/mplabx/v4.15/mplab_ide/platform/../mplab_ide/modules/../../bin/:$(PATH)
+PATH:=C:/Program Files/Microchip/MPLABX/v4.05/mplab_ide/platform/../mplab_ide/modules/../../bin/:$(PATH)
# Path to java used to run MPLAB X when this makefile was created
-MP_JAVA_PATH="/opt/microchip/mplabx/v4.15/sys/java/jre1.8.0_144/bin/"
+MP_JAVA_PATH="C:\Program Files\Microchip\MPLABX\v4.05\sys\java\jre1.8.0_144/bin/"
OS_CURRENT="$(shell uname -s)"
-MP_CC="/opt/microchip/xc32/v2.05/bin/xc32-gcc"
-MP_CPPC="/opt/microchip/xc32/v2.05/bin/xc32-g++"
+MP_CC="C:\Program Files\Microchip\xc32\v1.44\bin\xc32-gcc.exe"
+MP_CPPC="C:\Program Files\Microchip\xc32\v1.44\bin\xc32-g++.exe"
# MP_BC is not defined
-MP_AS="/opt/microchip/xc32/v2.05/bin/xc32-as"
-MP_LD="/opt/microchip/xc32/v2.05/bin/xc32-ld"
-MP_AR="/opt/microchip/xc32/v2.05/bin/xc32-ar"
-DEP_GEN=${MP_JAVA_PATH}java -jar "/opt/microchip/mplabx/v4.15/mplab_ide/platform/../mplab_ide/modules/../../bin/extractobjectdependencies.jar"
-MP_CC_DIR="/opt/microchip/xc32/v2.05/bin"
-MP_CPPC_DIR="/opt/microchip/xc32/v2.05/bin"
+MP_AS="C:\Program Files\Microchip\xc32\v1.44\bin\xc32-as.exe"
+MP_LD="C:\Program Files\Microchip\xc32\v1.44\bin\xc32-ld.exe"
+MP_AR="C:\Program Files\Microchip\xc32\v1.44\bin\xc32-ar.exe"
+DEP_GEN=${MP_JAVA_PATH}java -jar "C:/Program Files/Microchip/MPLABX/v4.05/mplab_ide/platform/../mplab_ide/modules/../../bin/extractobjectdependencies.jar"
+MP_CC_DIR="C:\Program Files\Microchip\xc32\v1.44\bin"
+MP_CPPC_DIR="C:\Program Files\Microchip\xc32\v1.44\bin"
# MP_BC_DIR is not defined
-MP_AS_DIR="/opt/microchip/xc32/v2.05/bin"
-MP_LD_DIR="/opt/microchip/xc32/v2.05/bin"
-MP_AR_DIR="/opt/microchip/xc32/v2.05/bin"
+MP_AS_DIR="C:\Program Files\Microchip\xc32\v1.44\bin"
+MP_LD_DIR="C:\Program Files\Microchip\xc32\v1.44\bin"
+MP_AR_DIR="C:\Program Files\Microchip\xc32\v1.44\bin"
# MP_BC_DIR is not defined
diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml
index 8f500b7..db18a0b 100644
--- a/nbproject/configurations.xml
+++ b/nbproject/configurations.xml
@@ -18,6 +18,7 @@
<itemPath>mcc_generated_files/pin_manager.h</itemPath>
<itemPath>mcc_generated_files/uart1.h</itemPath>
</logicalFolder>
+ <itemPath>led.hpp</itemPath>
</logicalFolder>
<logicalFolder name="LinkerScript"
displayName="Linker Files"
@@ -40,7 +41,6 @@
<itemPath>mcc_generated_files/uart1.c</itemPath>
</logicalFolder>
<itemPath>main.cpp</itemPath>
- <itemPath>led.hpp</itemPath>
<itemPath>led.cpp</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
@@ -64,8 +64,8 @@
<targetPluginBoard></targetPluginBoard>
<platformTool>PKOBSKDEPlatformTool</platformTool>
<languageToolchain>XC32</languageToolchain>
- <languageToolchainVersion>2.05</languageToolchainVersion>
- <platform>2</platform>
+ <languageToolchainVersion>1.44</languageToolchainVersion>
+ <platform>3</platform>
</toolsSet>
<compileType>
<linkerTool>
@@ -225,6 +225,7 @@
<property key="ToolFirmwareFilePath"
value="Press to browse for a specific firmware version"/>
<property key="ToolFirmwareOption.UseLatestFirmware" value="true"/>
+ <property key="firmware.download.all" value="false"/>
<property key="memories.configurationmemory" value="true"/>
<property key="memories.dataflash" value="true"/>
<property key="memories.eeprom" value="true"/>