diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2016-08-01 08:20:23 +0200 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2016-08-01 08:20:23 +0200 |
commit | bfeeac6e4889d1e9a1083b3c7efc59652981b168 (patch) | |
tree | a937d844a59da7c509685dcd1ddd9933772e526f /template | |
parent | c307e9f234e544386fa3ae53083c7510668e1716 (diff) | |
download | kicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.tar.gz kicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.tar.bz2 kicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.tar.xz kicad-utils-bfeeac6e4889d1e9a1083b3c7efc59652981b168.zip |
o Moving the generation logic to Python, embedding a Python interpreter with the help of pybind11.
o Adding install configuration to CMake to make it easier to reuse the project later on.
o Splitting out the examples into its own project to make it easier to test the whole installation setup and python/template loading.
o Trying to reorganize the code a bit, not very much better yet.
Diffstat (limited to 'template')
-rw-r--r-- | template/intel-quark-d2000.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/template/intel-quark-d2000.py b/template/intel-quark-d2000.py new file mode 100644 index 0000000..85572c5 --- /dev/null +++ b/template/intel-quark-d2000.py @@ -0,0 +1,69 @@ +global generateHeader +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' +} + +generateHeader.println(""" +#include <stddef.h> +#include <qm_gpio.h> + +enum schematic_direction { + schematic_direction_out = 1, + schematic_direction_in = 2 +}; +""") + +usages = generateHeader.netlist.find_usages_of(generateHeader.ref) + +for usage in usages: + node = usage.node_for_ref(generateHeader.ref) + + gpio = gpio_map.get(node.pin) + + if gpio is None: + continue + + generateHeader.println( + 'static const uint8_t SCHEMATIC_' + usage.name + ' = ' + gpio + ';\n' + '\n' + 'static inline\n' + 'qm_rc_t schematic_' + usage.name + '_direction(enum schematic_direction dir) {\n' + ' qm_gpio_port_config_t cfg;\n' + '\n' + ' qm_gpio_get_config(QM_GPIO_0, &cfg);\n' + '\n' + ' if (dir == schematic_direction_out) {\n' + ' cfg.direction |= BIT(SCHEMATIC_' + usage.name + ');\n' + ' } else {\n' + ' cfg.direction &= ~BIT(SCHEMATIC_' + usage.name + ');\n' + ' }\n' + '\n' + ' return qm_gpio_set_config(QM_GPIO_0, &cfg);\n' + '}') |