summaryrefslogtreecommitdiff
path: root/gm_platform/fw/tools
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2020-01-23 14:38:36 +0100
committerjaseg <git@jaseg.net>2020-01-23 14:38:36 +0100
commit410e38651052038e34843b17269d61e75720f0ba (patch)
tree987d1853c55b152d5e1362af4420fa52fcd56a81 /gm_platform/fw/tools
parent6a49b8399fb156d427b5d15746de877ac933ba3d (diff)
downloadmaster-thesis-410e38651052038e34843b17269d61e75720f0ba.tar.gz
master-thesis-410e38651052038e34843b17269d61e75720f0ba.tar.bz2
master-thesis-410e38651052038e34843b17269d61e75720f0ba.zip
board bringup: adc, usart working
Diffstat (limited to 'gm_platform/fw/tools')
-rw-r--r--gm_platform/fw/tools/gen_cmsis_exports.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/gm_platform/fw/tools/gen_cmsis_exports.py b/gm_platform/fw/tools/gen_cmsis_exports.py
new file mode 100644
index 0000000..ba3422b
--- /dev/null
+++ b/gm_platform/fw/tools/gen_cmsis_exports.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python3
+import re
+import os
+
+if __name__ == '__main__':
+ import argparse
+
+ parser = argparse.ArgumentParser()
+ parser.add_argument('cmsis_device_header', nargs='+', type=argparse.FileType('rb'))
+ args = parser.parse_args()
+
+ print('#ifndef __GENERATED_CMSIS_HEADER_EXPORTS__')
+ print('#define __GENERATED_CMSIS_HEADER_EXPORTS__')
+ print()
+ for header in args.cmsis_device_header:
+ lines = header.readlines()
+ name = os.path.basename(header.name)
+ print('#include <{}>'.format(name))
+ print()
+
+ print('/* {} */'.format(name))
+ for l in lines:
+ match = re.match(b'^#define (\w+)\s+\W*(\w+_TypeDef|\w+_Type).*$', l)
+ if match:
+ inst, typedef = match.groups()
+ inst, typedef = inst.decode(), typedef.decode()
+ print('{} *{} = {};'.format(typedef, inst.lower(), inst))
+ print()
+ print('#endif//__GENERATED_CMSIS_HEADER_EXPORTS__')
+