diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 67 |
1 files changed, 65 insertions, 2 deletions
@@ -6,6 +6,7 @@ #include <getopt.h> #include <cstring> #include <memory> +#include <map> #include "trygvis/kicad.h" using namespace std; @@ -97,6 +98,61 @@ public: } }; +class intel_quark_d2000 : public part { +public: + intel_quark_d2000() : part("INTEL_QUARK_D2000") { } + + ~intel_quark_d2000() { + } + + 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"}, + {10, "18"}, + + {11, "9"}, + {13, "20"}, + {14, "21"}, + {15, "22"}, + {16, "23"}, + {18, "19"}, + + {21, "24"}, + + {31, "0"}, + {32, "1"}, + {33, "2"}, + {34, "3"}, + {35, "4"}, + {36, "5"}, + {37, "6"}, + {38, "7"}, + {39, "8"}, + }; + + out << "#include <stddef.h>" << 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; + } + } + + return true; + } +}; class library { public: @@ -114,7 +170,7 @@ public: } } - return nullptr; + return nullopt; } }; @@ -125,6 +181,7 @@ public: kicad_gen() { library kicad_utils("kicad_utils"); kicad_utils.parts.push_back(make_unique<arduino_uno>()); + kicad_utils.parts.push_back(make_unique<intel_quark_d2000>()); libraries.push_back(std::move(kicad_utils)); } @@ -136,7 +193,7 @@ public: } } - return nullptr; + return nullopt; } }; @@ -176,6 +233,12 @@ bool generate(const char *ref, const trygvis::kicad::netlist::netlist &netlist, out << "#ifndef SCHEMATIC_H" << endl; out << "#define SCHEMATIC_H" << endl; out << endl; + 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 << "*/" << endl; + out << endl; auto usages = netlist.find_usage_of(ref); |