aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorFabien Poussin <fabien.poussin@gmail.com>2019-09-19 19:46:06 +0200
committerFabien Poussin <fabien.poussin@gmail.com>2019-09-19 19:47:15 +0200
commit8f7c2d187bbb02915f44b926c7aa02185402aef7 (patch)
treef387a976a938f8a9765f1593f3270d6773242dbc /tools
parent6736a9099b184ba3fed01fb36e915d86ffa4f0da (diff)
downloadChibiOS-Contrib-8f7c2d187bbb02915f44b926c7aa02185402aef7.tar.gz
ChibiOS-Contrib-8f7c2d187bbb02915f44b926c7aa02185402aef7.tar.bz2
ChibiOS-Contrib-8f7c2d187bbb02915f44b926c7aa02185402aef7.zip
Adding support for STM32L4 in mx2board
Diffstat (limited to 'tools')
-rwxr-xr-xtools/mx2board.py26
-rw-r--r--tools/templates/board_gpio.tpl15
2 files changed, 33 insertions, 8 deletions
diff --git a/tools/mx2board.py b/tools/mx2board.py
index 8ab155d..a805e9f 100755
--- a/tools/mx2board.py
+++ b/tools/mx2board.py
@@ -35,11 +35,15 @@ PIN_PUPDR_FLOATING = "PIN_PUPDR_FLOATING({0})"
PIN_PUPDR_PULLUP = "PIN_PUPDR_PULLUP({0})"
PIN_PUPDR_PULLDOWN = "PIN_PUPDR_PULLDOWN({0})"
PIN_AFIO_AF = "PIN_AFIO_AF({0}, {1})"
+PIN_ASCR_DISABLED = "PIN_ASCR_DISABLED({0})"
+PIN_ASCR_ENABLED = "PIN_ASCR_ENABLED({0})"
+PIN_LOCKR_DISABLED = "PIN_LOCKR_DISABLED({0})"
+PIN_LOCKR_ENABLED = "PIN_LOCKR_ENABLED({0})"
FMT = '{0}'
FMT_DEF = '({0})'
-PIN_CONF_LIST = ['MODER', 'OTYPER', 'OSPEEDR', 'PUPDR', 'ODR']
+PIN_CONF_LIST = ['MODER', 'OTYPER', 'OSPEEDR', 'PUPDR', 'ODR', 'ASCR', 'LOCKR']
PIN_CONF_LIST_AF = ['AFRL', 'AFRH']
DEFAULT_PAD = {"SIGNAL": "UNUSED",
@@ -48,7 +52,9 @@ DEFAULT_PAD = {"SIGNAL": "UNUSED",
"OTYPER": PIN_OTYPE_PUSHPULL,
"OSPEEDR": PIN_OSPEED_VERYLOW,
"PUPDR": PIN_PUPDR_FLOATING,
- "ODR": PIN_ODR_LOW}
+ "ODR": PIN_ODR_LOW,
+ "ASCR": PIN_ASCR_DISABLED,
+ "LOCKR": PIN_LOCKR_DISABLED}
PIN_MODE_TRANSLATE = {"GPIO_MODE_AF_PP": PIN_MODE_ALTERNATE,
"GPIO_MODE_ANALOG": PIN_MODE_ANALOG,
@@ -207,8 +213,13 @@ def read_project(gpio, filename):
with open(filename, 'r') as mx_file:
tmp = mx_file.readlines()
pads = {}
+ mcu = 'Unknown'
+
+ for l in tmp:
+ if l.startswith('Mcu.Name'):
+ mcu = l.split('=')[-1].strip()
- # Default all pads to analog
+ # Default pad mode is analog, here we assign proper mode and speed.
for p in gpio['ports'].keys():
pads[p] = {}
for i in range(0, 16):
@@ -267,7 +278,7 @@ def read_project(gpio, filename):
pads[pad_port][pad_num]["OTYPER"] = PIN_OTYPE_OPENDRAIN
- return pads
+ return mcu, pads
# Add defines for all pins with labels
@@ -389,10 +400,11 @@ if __name__ == '__main__':
else:
gpio_file = get_gpio_file(args.project, args.mx)
gpio = read_gpio(gpio_file)
- proj = read_project(gpio, args.project)
+
+ mcu, proj = read_project(gpio, args.project)
defines = gen_defines(proj)
ports = gen_ports(gpio, proj)
-
+
with open(cur_path + '/templates/board_gpio.tpl', 'r') as tpl_file:
tpl = tpl_file.read()
template = Template(tpl)
@@ -405,6 +417,6 @@ if __name__ == '__main__':
for p in sorted(ports.keys()):
ports_sorted.append((p, ports[p]))
- template.stream(defines=defines_sorted, ports=ports_sorted).dump(args.output)
+ template.stream(defines=defines_sorted, ports=ports_sorted, ascr_lockr='L4' in mcu).dump(args.output)
print('File generated at ' + args.output)
diff --git a/tools/templates/board_gpio.tpl b/tools/templates/board_gpio.tpl
index 07a316d..1e770f1 100644
--- a/tools/templates/board_gpio.tpl
+++ b/tools/templates/board_gpio.tpl
@@ -50,6 +50,19 @@
{{ i }} | \
{%- endfor %}
0)
+{% if ascr_lockr %}
+#define VAL_GPIO{{p}}_ASCR ( \
+ {%- for i in v.ASCR %}
+ {{ i }} | \
+ {%- endfor %}
+ 0)
+
+#define VAL_GPIO{{p}}_LOCKR ( \
+ {%- for i in v.LOCKR %}
+ {{ i }} | \
+ {%- endfor %}
+ 0)
+{% endif %}
{% endfor %}
-#endif \ No newline at end of file
+#endif