Use YAML for UCD definitions
Use a Python script to generate the UCD power sequencer information
needed for the pseq-monitor application.
Change-Id: I51f4b61bb4f22705584b73ba599b517780fa9adc
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/power-sequencer/gen-ucd90160-defs.py b/power-sequencer/gen-ucd90160-defs.py
new file mode 100755
index 0000000..1eb0d06
--- /dev/null
+++ b/power-sequencer/gen-ucd90160-defs.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+import os
+import yaml
+from argparse import ArgumentParser
+from mako.template import Template
+from mako.lookup import TemplateLookup
+
+if __name__ == '__main__':
+ parser = ArgumentParser(
+ description="Power sequencer UCD90160 definition parser")
+
+ parser.add_argument('-i', '--input_yaml', dest='input_yaml',
+ default="example/ucd90160.yaml",
+ help='UCD90160 definitions YAML')
+
+ parser.add_argument('-o', '--output_dir', dest='output_dir',
+ default=".",
+ help='output directory')
+
+ args = parser.parse_args()
+
+ if not args.input_yaml or not args.output_dir:
+ parser.print_usage()
+ sys.exit(1)
+
+ with open(args.input_yaml, 'r') as ucd90160_input:
+ ucd90160_data = yaml.safe_load(ucd90160_input) or {}
+
+ templates_dir = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "templates")
+
+ output_file = os.path.join(args.output_dir, "ucd90160_defs.cpp")
+
+ mylookup = TemplateLookup(
+ directories=templates_dir.split())
+ mytemplate = mylookup.get_template('ucd90160_defs.mako.cpp')
+
+ with open(output_file, 'w') as output:
+ output.write(mytemplate.render(ucd90160s=ucd90160_data))