summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart <lekaiser@uos.de>2020-08-18 17:31:49 +0200
committerLennart <lekaiser@uos.de>2020-08-18 17:31:49 +0200
commit550482401d95720306873d1fa1de11717c5845dc (patch)
treeaa38f8aa4cf239dfdb1f7da3d8389ea0871e8f63
parent714e5788be7b89f937fe8dbf270b8035c4f7d436 (diff)
Working version
-rw-r--r--Makefile4
-rw-r--r--include/driver/resistive_load.h10
-rw-r--r--include/object/ptalog.h2
-rw-r--r--model/driver/resistive_load.dfa38
-rw-r--r--model/driver/resistive_load_8.dfa45
-rw-r--r--src/app/ledblink_and_other_pin/main.cc37
-rw-r--r--src/driver/resistive_load.cc84
7 files changed, 211 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 98779b1..727ea37 100644
--- a/Makefile
+++ b/Makefile
@@ -141,11 +141,15 @@ ifneq ($(findstring resistive_load,${drivers}), )
resistor2_pin ?= p3_1
resistor3_pin ?= p3_2
resistor4_pin ?= p3_3
+ resistor5_pin ?= p1_4
+ resistor6_pin ?= p1_5
COMMON_FLAGS += -DDRIVER_RESISTIVE_LOAD
COMMON_FLAGS += -DRESISTIVE_LOAD_PIN1=GPIO::${resistor1_pin}
COMMON_FLAGS += -DRESISTIVE_LOAD_PIN2=GPIO::${resistor2_pin}
COMMON_FLAGS += -DRESISTIVE_LOAD_PIN3=GPIO::${resistor3_pin}
COMMON_FLAGS += -DRESISTIVE_LOAD_PIN4=GPIO::${resistor4_pin}
+ COMMON_FLAGS += -DRESISTIVE_LOAD_PIN5=GPIO::${resistor5_pin}
+ COMMON_FLAGS += -DRESISTIVE_LOAD_PIN6=GPIO::${resistor6_pin}
endif
ifneq ($(findstring softi2c,${drivers}), )
diff --git a/include/driver/resistive_load.h b/include/driver/resistive_load.h
index 74725ac..b4c4566 100644
--- a/include/driver/resistive_load.h
+++ b/include/driver/resistive_load.h
@@ -23,7 +23,15 @@ class ResistiveLoad {
void switchTo3K3(); // 3K25 (R2)
void switchTo10K(); // 9K86 (R4)
void switchTo47K(); // 46K3 (R3)
- void nop1K0(unsigned int duration_ms);
+
+ void switchTo2K2();
+ void switchTo4K7();
+ void switchTo680();
+
+ void switchTo2K();
+ void switchTo1K8();
+ void switchTo1K3();
+ void nop1K0(unsigned int duration_ms);
void nop2K4(unsigned int duration_ms);
void nop3K3(unsigned int duration_ms);
void nop10K(unsigned int duration_ms);
diff --git a/include/object/ptalog.h b/include/object/ptalog.h
index 6394474..6d5cf4d 100644
--- a/include/object/ptalog.h
+++ b/include/object/ptalog.h
@@ -148,7 +148,7 @@ class PTALog {
counter.start();
#endif
#ifndef PTALOG_GPIO_BEFORE
- gpio.write(sync_pin, 1);
+ gpio.write(sync_pin, 1);
#endif
}
#endif
diff --git a/model/driver/resistive_load.dfa b/model/driver/resistive_load.dfa
index a2bf3dd..efcf853 100644
--- a/model/driver/resistive_load.dfa
+++ b/model/driver/resistive_load.dfa
@@ -16,29 +16,53 @@ states:
- P3_4MW
- P1_1MW
- P235UW
+ - P4_9MW
+ - P5MW
+ - P15_8MW
+ - P5_2MW
+ - P6_1MW
+ - P8_3MW
transition:
setup:
src: [UNINITIALIZED]
dst: SLEEP
switchToNone:
- src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW, P4_9MW, P5MW, P15_8MW, P5_2MW, P6_1MW, P8_3MW]
dst: SLEEP
switchTo750:
- src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW, P4_9MW, P5MW, P15_8MW, P5_2MW, P6_1MW, P8_3MW]
dst: P14MW
switchTo1K0:
- src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW, P4_9MW, P5MW, P15_8MW, P5_2MW, P6_1MW, P8_3MW]
dst: P11MW
switchTo2K4:
- src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW, P4_9MW, P5MW, P15_8MW, P5_2MW, P6_1MW, P8_3MW]
dst: P4_4MW
switchTo3K3:
- src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW, P4_9MW, P5MW, P15_8MW, P5_2MW, P6_1MW, P8_3MW]
dst: P3_4MW
switchTo10K:
- src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW, P4_9MW, P5MW, P15_8MW, P5_2MW, P6_1MW, P8_3MW]
dst: P1_1MW
switchTo47K:
- src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW, P4_9MW, P5MW, P15_8MW, P5_2MW, P6_1MW, P8_3MW]
dst: P235UW
+ switchTo2K2:
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW, P4_9MW, P5MW, P15_8MW, P5_2MW, P6_1MW, P8_3MW]
+ dst: P4_9MW
+ switchTo4K7:
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW, P4_9MW, P5MW, P15_8MW, P5_2MW, P6_1MW, P8_3MW]
+ dst: P5MW
+ switchTo680:
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW, P4_9MW, P5MW, P15_8MW, P5_2MW, P6_1MW, P8_3MW]
+ dst: P15_8MW
+ switchTo2K:
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW, P4_9MW, P5MW, P15_8MW, P5_2MW, P6_1MW, P8_3MW]
+ dst: P5_2MW
+ switchTo1K8:
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW, P4_9MW, P5MW, P15_8MW, P5_2MW, P6_1MW, P8_3MW]
+ dst: P6_1MW
+ switchTo1K3:
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW, P4_9MW, P5MW, P15_8MW, P5_2MW, P6_1MW, P8_3MW]
+ dst: P8_3MW \ No newline at end of file
diff --git a/model/driver/resistive_load_8.dfa b/model/driver/resistive_load_8.dfa
new file mode 100644
index 0000000..fdb767d
--- /dev/null
+++ b/model/driver/resistive_load_8.dfa
@@ -0,0 +1,45 @@
+codegen:
+ instance: resistiveLoad
+ includes:
+ - driver/resistive_load.h
+ - driver/resistive_load_8.h
+ flags:
+ - drivers=resistive_load
+ setup:
+ - resistiveLoad.setup();
+
+states:
+ - UNINITIALIZED
+ - SLEEP
+ - P14MW
+ - P11MW
+ - P4_4MW
+ - P3_4MW
+ - P1_1MW
+ - P235UW
+
+transition:
+ setup:
+ src: [UNINITIALIZED]
+ dst: SLEEP
+ switchToNone:
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ dst: SLEEP
+ switchTo750:
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ dst: P14MW
+ switchTo1K0:
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ dst: P11MW
+ switchTo2K4:
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ dst: P4_4MW
+ switchTo3K3:
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ dst: P3_4MW
+ switchTo10K:
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ dst: P1_1MW
+ switchTo47K:
+ src: [UNINITIALIZED, SLEEP, P14MW, P11MW, P4_4MW, P3_4MW, P1_1MW, P235UW]
+ dst: P235UW
diff --git a/src/app/ledblink_and_other_pin/main.cc b/src/app/ledblink_and_other_pin/main.cc
new file mode 100644
index 0000000..9a8afc1
--- /dev/null
+++ b/src/app/ledblink_and_other_pin/main.cc
@@ -0,0 +1,37 @@
+#include "arch.h"
+#include "driver/gpio.h"
+#include "driver/stdout.h"
+#include "driver/uptime.h"
+
+bool on = false;
+
+void loop(void)
+{
+ gpio.led_toggle(1);
+ if(on) {
+ gpio.write(GPIO::p1_2, 1);
+ }else{
+
+ }
+ on = !on;
+#ifdef TIMER_S
+ kout << dec << uptime.get_s() << endl;
+#else
+ kout << "beep boop" << endl;
+#endif
+}
+
+int main(void)
+{
+ arch.setup();
+ gpio.setup();
+ kout.setup();
+
+ gpio.led_on(0);
+ kout << "Hello, World!" << endl;
+ kout << "Test, World!" << endl;
+
+ arch.idle_loop();
+
+ return 0;
+}
diff --git a/src/driver/resistive_load.cc b/src/driver/resistive_load.cc
index 419c6c0..0c3009c 100644
--- a/src/driver/resistive_load.cc
+++ b/src/driver/resistive_load.cc
@@ -18,12 +18,22 @@
#error RESISTIVE_LOAD_PIN4 must be set
#endif
+#ifndef RESISTIVE_LOAD_PIN5
+#error RESISTIVE_LOAD_PIN5 must be set
+#endif
+
+#ifndef RESISTIVE_LOAD_PIN6
+#error RESISTIVE_LOAD_PIN6 must be set
+#endif
+
void ResistiveLoad::setup()
{
gpio.output(RESISTIVE_LOAD_PIN1, 0);
gpio.output(RESISTIVE_LOAD_PIN2, 0);
gpio.output(RESISTIVE_LOAD_PIN3, 0);
gpio.output(RESISTIVE_LOAD_PIN4, 0);
+ gpio.output(RESISTIVE_LOAD_PIN5, 0);
+ gpio.output(RESISTIVE_LOAD_PIN6, 0);
}
void ResistiveLoad::switchToNone()
@@ -32,6 +42,8 @@ void ResistiveLoad::switchToNone()
gpio.write(RESISTIVE_LOAD_PIN2, 0);
gpio.write(RESISTIVE_LOAD_PIN3, 0);
gpio.write(RESISTIVE_LOAD_PIN4, 0);
+ gpio.write(RESISTIVE_LOAD_PIN5, 0);
+ gpio.write(RESISTIVE_LOAD_PIN6, 0);
}
void ResistiveLoad::switchTo750()
@@ -40,6 +52,8 @@ void ResistiveLoad::switchTo750()
gpio.write(RESISTIVE_LOAD_PIN2, 1);
gpio.write(RESISTIVE_LOAD_PIN3, 0);
gpio.write(RESISTIVE_LOAD_PIN4, 0);
+ gpio.write(RESISTIVE_LOAD_PIN5, 0);
+ gpio.write(RESISTIVE_LOAD_PIN6, 0);
}
void ResistiveLoad::switchTo1K0()
@@ -48,6 +62,8 @@ void ResistiveLoad::switchTo1K0()
gpio.write(RESISTIVE_LOAD_PIN2, 0);
gpio.write(RESISTIVE_LOAD_PIN3, 0);
gpio.write(RESISTIVE_LOAD_PIN4, 0);
+ gpio.write(RESISTIVE_LOAD_PIN5, 0);
+ gpio.write(RESISTIVE_LOAD_PIN6, 0);
}
void ResistiveLoad::switchTo2K4()
@@ -56,6 +72,8 @@ void ResistiveLoad::switchTo2K4()
gpio.write(RESISTIVE_LOAD_PIN2, 1);
gpio.write(RESISTIVE_LOAD_PIN3, 0);
gpio.write(RESISTIVE_LOAD_PIN4, 1);
+ gpio.write(RESISTIVE_LOAD_PIN5, 0);
+ gpio.write(RESISTIVE_LOAD_PIN6, 0);
}
void ResistiveLoad::switchTo3K3()
@@ -64,6 +82,8 @@ void ResistiveLoad::switchTo3K3()
gpio.write(RESISTIVE_LOAD_PIN2, 1);
gpio.write(RESISTIVE_LOAD_PIN3, 0);
gpio.write(RESISTIVE_LOAD_PIN4, 0);
+ gpio.write(RESISTIVE_LOAD_PIN5, 0);
+ gpio.write(RESISTIVE_LOAD_PIN6, 0);
}
void ResistiveLoad::switchTo10K()
@@ -72,6 +92,8 @@ void ResistiveLoad::switchTo10K()
gpio.write(RESISTIVE_LOAD_PIN2, 0);
gpio.write(RESISTIVE_LOAD_PIN3, 0);
gpio.write(RESISTIVE_LOAD_PIN4, 1);
+ gpio.write(RESISTIVE_LOAD_PIN5, 0);
+ gpio.write(RESISTIVE_LOAD_PIN6, 0);
}
void ResistiveLoad::switchTo47K()
@@ -80,6 +102,68 @@ void ResistiveLoad::switchTo47K()
gpio.write(RESISTIVE_LOAD_PIN2, 0);
gpio.write(RESISTIVE_LOAD_PIN3, 1);
gpio.write(RESISTIVE_LOAD_PIN4, 0);
+ gpio.write(RESISTIVE_LOAD_PIN5, 0);
+ gpio.write(RESISTIVE_LOAD_PIN6, 0);
+}
+
+void ResistiveLoad::switchTo2K2()
+{
+ gpio.write(RESISTIVE_LOAD_PIN1, 0);
+ gpio.write(RESISTIVE_LOAD_PIN2, 0);
+ gpio.write(RESISTIVE_LOAD_PIN3, 0);
+ gpio.write(RESISTIVE_LOAD_PIN4, 0);
+ gpio.write(RESISTIVE_LOAD_PIN5, 1);
+ gpio.write(RESISTIVE_LOAD_PIN6, 0);
+}
+
+void ResistiveLoad::switchTo4K7()
+{
+ gpio.write(RESISTIVE_LOAD_PIN1, 0);
+ gpio.write(RESISTIVE_LOAD_PIN2, 0);
+ gpio.write(RESISTIVE_LOAD_PIN3, 0);
+ gpio.write(RESISTIVE_LOAD_PIN4, 0);
+ gpio.write(RESISTIVE_LOAD_PIN5, 0);
+ gpio.write(RESISTIVE_LOAD_PIN6, 1);
+}
+
+void ResistiveLoad::switchTo680()
+{
+ gpio.write(RESISTIVE_LOAD_PIN1, 1);
+ gpio.write(RESISTIVE_LOAD_PIN2, 0);
+ gpio.write(RESISTIVE_LOAD_PIN3, 0);
+ gpio.write(RESISTIVE_LOAD_PIN4, 0);
+ gpio.write(RESISTIVE_LOAD_PIN5, 1);
+ gpio.write(RESISTIVE_LOAD_PIN6, 0);
+}
+
+void ResistiveLoad::switchTo2K()
+{
+ gpio.write(RESISTIVE_LOAD_PIN1, 0);
+ gpio.write(RESISTIVE_LOAD_PIN2, 0);
+ gpio.write(RESISTIVE_LOAD_PIN3, 1);
+ gpio.write(RESISTIVE_LOAD_PIN4, 0);
+ gpio.write(RESISTIVE_LOAD_PIN5, 1);
+ gpio.write(RESISTIVE_LOAD_PIN6, 0);
+}
+
+void ResistiveLoad::switchTo1K8()
+{
+ gpio.write(RESISTIVE_LOAD_PIN1, 0);
+ gpio.write(RESISTIVE_LOAD_PIN2, 0);
+ gpio.write(RESISTIVE_LOAD_PIN3, 0);
+ gpio.write(RESISTIVE_LOAD_PIN4, 1);
+ gpio.write(RESISTIVE_LOAD_PIN5, 1);
+ gpio.write(RESISTIVE_LOAD_PIN6, 0);
+}
+
+void ResistiveLoad::switchTo1K3()
+{
+ gpio.write(RESISTIVE_LOAD_PIN1, 0);
+ gpio.write(RESISTIVE_LOAD_PIN2, 1);
+ gpio.write(RESISTIVE_LOAD_PIN3, 0);
+ gpio.write(RESISTIVE_LOAD_PIN4, 0);
+ gpio.write(RESISTIVE_LOAD_PIN5, 1);
+ gpio.write(RESISTIVE_LOAD_PIN6, 0);
}
void ResistiveLoad::nop1K0(unsigned int duration_ms)