diff options
| author | Lucian Copeland <hierophect@gmail.com> | 2020-03-28 18:30:46 -0400 |
|---|---|---|
| committer | Lucian Copeland <hierophect@gmail.com> | 2020-03-28 18:30:46 -0400 |
| commit | e2be0696865992cda67f5bdeba5aeb5b4c2fdcd4 (patch) | |
| tree | 64547a2302df6d301ab0a5e85b461f9d8fe3f38e /ports/stm/tools/parse_pins_csv.py | |
| parent | 7995bcac4009d2b3e20f42a26de72d5411e7e462 (diff) | |
Support cached internal flash on the H743
Diffstat (limited to 'ports/stm/tools/parse_pins_csv.py')
| -rw-r--r-- | ports/stm/tools/parse_pins_csv.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/ports/stm/tools/parse_pins_csv.py b/ports/stm/tools/parse_pins_csv.py new file mode 100644 index 000000000..b69b4791b --- /dev/null +++ b/ports/stm/tools/parse_pins_csv.py @@ -0,0 +1,49 @@ +# This file is part of the MicroPython project, http://micropython.org/ +# +# The MIT License (MIT) +# +# Copyright (c) 2020 Lucian Copeland for Adafruit Industries +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +import csv +import sys + +# Use: parse_pins_csv.py Filename.csv +# Designed for use with .csv files from Micropython, or in identical format +# created via Datasheet peripheral tables with a Sheets program. +# +# See examples/nucleo_h743.csv for example formatting. + +# Open target file +with open(sys.argv[1]) as csv_file: + csv_reader = csv.reader(csv_file, delimiter=',') + line_count = 0 + + print("STATIC const mp_rom_map_elem_t board_module_globals_table[] = {") + + for row in csv_reader: + label = row[0] + pin = row[1] + if len(pin) < 4: + pin = pin[:2] + '0' + pin[2:] + print("{ MP_ROM_QSTR(MP_QSTR_" + label + "), MP_ROM_PTR(&pin_" + pin + ") },") + line_count += 1 + + print(f'Processed {line_count} lines.') |
