diff options
author | jaseg <git@jaseg.net> | 2018-12-20 18:54:41 +0900 |
---|---|---|
committer | jaseg <git@jaseg.net> | 2018-12-20 18:54:41 +0900 |
commit | 90038f4378b7cdbe98e32ed1e5e3055dbe4776f2 (patch) | |
tree | 3982be300f99a7eabd1d6a5c9be973822bac3044 /fw/tools | |
parent | 111b7a6bf37a271125f453bd2904cd72fd8f5b38 (diff) | |
download | 8seg-90038f4378b7cdbe98e32ed1e5e3055dbe4776f2.tar.gz 8seg-90038f4378b7cdbe98e32ed1e5e3055dbe4776f2.tar.bz2 8seg-90038f4378b7cdbe98e32ed1e5e3055dbe4776f2.zip |
Add initial center firmware
Diffstat (limited to 'fw/tools')
-rw-r--r-- | fw/tools/gen_cmsis_exports.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/fw/tools/gen_cmsis_exports.py b/fw/tools/gen_cmsis_exports.py new file mode 100644 index 0000000..ba3422b --- /dev/null +++ b/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__') + |