aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-07-27 21:06:48 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2016-07-27 21:06:48 +0200
commitf9c8c5da8de36b0f95bc92e37e15d299b434c03f (patch)
tree4927f779d0502974b02ac83e4089f7d4dde6e805
parent5e846554a48be59ba7278194567b9e1a25058958 (diff)
downloadkicad-utils-f9c8c5da8de36b0f95bc92e37e15d299b434c03f.tar.gz
kicad-utils-f9c8c5da8de36b0f95bc92e37e15d299b434c03f.tar.bz2
kicad-utils-f9c8c5da8de36b0f95bc92e37e15d299b434c03f.tar.xz
kicad-utils-f9c8c5da8de36b0f95bc92e37e15d299b434c03f.zip
more intel stuff.
-rw-r--r--examples/intel-quark-d2000/schematic.h37
-rw-r--r--main.cpp47
2 files changed, 72 insertions, 12 deletions
diff --git a/examples/intel-quark-d2000/schematic.h b/examples/intel-quark-d2000/schematic.h
index 3ca8e86..62545f0 100644
--- a/examples/intel-quark-d2000/schematic.h
+++ b/examples/intel-quark-d2000/schematic.h
@@ -8,8 +8,45 @@ Generated from schematic for reference U1, part INTEL_QUARK_D2000 in library kic
*/
#include <stddef.h>
+#include <qm_gpio.h>
+enum schematic_direction {
+ schematic_direction_out = 1,
+ schematic_direction_in = 2
+};
static const uint8_t SCHEMATIC_STATUS_LED = 15;
+
+static inline
+qm_rc_t schematic_PUSH_BUTTON_direction(enum schematic_direction dir) {
+ qm_gpio_port_config_t cfg;
+
+ qm_gpio_get_config(QM_GPIO_0, &cfg);
+
+ if (dir == schematic_direction_out) {
+ cfg.direction |= BIT(SCHEMATIC_PUSH_BUTTON);
+ } else {
+ cfg.direction &= ~BIT(SCHEMATIC_PUSH_BUTTON);
+ }
+
+ return qm_gpio_set_config(QM_GPIO_0, &cfg);
+}
+
static const uint8_t SCHEMATIC_PUSH_BUTTON = 11;
+static inline
+qm_rc_t schematic_PUSH_BUTTON_direction(enum schematic_direction dir) {
+ qm_gpio_port_config_t cfg;
+
+ qm_gpio_get_config(QM_GPIO_0, &cfg);
+
+ if (dir == schematic_direction_out) {
+ cfg.direction |= BIT(SCHEMATIC_PUSH_BUTTON);
+ } else {
+ cfg.direction &= ~BIT(SCHEMATIC_PUSH_BUTTON);
+ }
+
+ return qm_gpio_set_config(QM_GPIO_0, &cfg);
+}
+
+
#endif // SCHEMATIC_H
diff --git a/main.cpp b/main.cpp
index 811a08f..4449f46 100644
--- a/main.cpp
+++ b/main.cpp
@@ -107,14 +107,14 @@ public:
virtual bool generate(stringstream &out, const string &ref, const vector<const net *> usages) override {
static map<int, string> gpio_map{
- {2, "10"},
- {3, "11"},
- {4, "12"},
- {5, "13"},
- {6, "14"},
- {7, "15"},
- {8, "16"},
- {9, "17"},
+ {2, "10"},
+ {3, "11"},
+ {4, "12"},
+ {5, "13"},
+ {6, "14"},
+ {7, "15"},
+ {8, "16"},
+ {9, "17"},
{10, "18"},
{11, "9"},
@@ -138,16 +138,39 @@ public:
};
out << "#include <stddef.h>" << endl;
+ out << "#include <qm_gpio.h>" << endl;
out << endl;
+ out << "enum schematic_direction {" << endl;
+ out << " schematic_direction_out = 1," << endl;
+ out << " schematic_direction_in = 2" << endl;
+ out << "};" << endl;;
for (auto &usage: usages) {
auto node = usage->node_for_ref(ref);
auto gpio = gpio_map.find(node->pin);
- if (gpio != gpio_map.end()) {
- out << "static const uint8_t SCHEMATIC_" << usage->name << " = " << gpio->second << ";" << endl;
+ if (gpio == gpio_map.end()) {
+ continue;
}
+
+ out << "static const uint8_t SCHEMATIC_" << usage->name << " = " << gpio->second << ";" << endl;
+ out << endl;
+ out << "static inline" << endl;
+ out << "qm_rc_t schematic_PUSH_BUTTON_direction(enum schematic_direction dir) {" << endl;
+ out << " qm_gpio_port_config_t cfg;" << endl;
+ out << "" << endl;
+ out << " qm_gpio_get_config(QM_GPIO_0, &cfg);" << endl;
+ out << "" << endl;
+ out << " if (dir == schematic_direction_out) {" << endl;
+ out << " cfg.direction |= BIT(SCHEMATIC_PUSH_BUTTON);" << endl;
+ out << " } else {" << endl;
+ out << " cfg.direction &= ~BIT(SCHEMATIC_PUSH_BUTTON);" << endl;
+ out << " }" << endl;
+ out << "" << endl;
+ out << " return qm_gpio_set_config(QM_GPIO_0, &cfg);" << endl;
+ out << "}" << endl;
+ out << endl;
}
return true;
@@ -236,7 +259,8 @@ bool generate(const char *ref, const trygvis::kicad::netlist::netlist &netlist,
out << "/*" << endl;
out << "THIS FILE IS GENERATED. DO NOT EDIT." << endl;
out << endl;
- out << "Generated from schematic for reference " << ref << ", part " << partName << " in library " << library->name << "." << endl;
+ out << "Generated from schematic for reference " << ref << ", part " << partName << " in library " <<
+ library->name << "." << endl;
out << "*/" << endl;
out << endl;
@@ -244,7 +268,6 @@ bool generate(const char *ref, const trygvis::kicad::netlist::netlist &netlist,
part->generate(out, ref, usages);
- out << endl;
out << "#endif // SCHEMATIC_H" << endl;
return true;