aboutsummaryrefslogtreecommitdiff
path: root/driver_fw/gen_cmsis_exports.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2018-12-22 14:38:07 +0900
committerjaseg <git@jaseg.net>2018-12-22 14:38:07 +0900
commit468fe59d9747078830dd489668b8c8ee8520b4a5 (patch)
treebc73e97cf0a0be0fba3f2a685143baf20116db1d /driver_fw/gen_cmsis_exports.py
parent132fd4f9c0184be033533953cc2c7ae92da311d9 (diff)
download8seg-468fe59d9747078830dd489668b8c8ee8520b4a5.tar.gz
8seg-468fe59d9747078830dd489668b8c8ee8520b4a5.tar.bz2
8seg-468fe59d9747078830dd489668b8c8ee8520b4a5.zip
First AC/mux test working
Diffstat (limited to 'driver_fw/gen_cmsis_exports.py')
-rw-r--r--driver_fw/gen_cmsis_exports.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/driver_fw/gen_cmsis_exports.py b/driver_fw/gen_cmsis_exports.py
new file mode 100644
index 0000000..ba3422b
--- /dev/null
+++ b/driver_fw/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__')
+