From bfa560413c8052e7ef2be656546b2868e5a993a2 Mon Sep 17 00:00:00 2001 From: Jakub Kaderka Date: Fri, 21 Dec 2018 17:25:22 +0100 Subject: Fixed Timer number generation --- tools/mx2board.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mx2board.py b/tools/mx2board.py index 99b54a3..5bec83c 100755 --- a/tools/mx2board.py +++ b/tools/mx2board.py @@ -275,7 +275,7 @@ def gen_defines(project): defines['LINE_'+label] += ', ' + str(pad_key) + 'U)' if re.search(r"TIM\d+_CH\d$", signal, re.M): - timer = signal.replace('S_TIM', '').replace('_CH', '')[:-1] + timer = signal.replace('TIM', '').replace('_CH', '')[:-1] ch_num = int(signal[-1:]) defines['TIM_' + label] = timer -- cgit v1.2.3 From ceff99507d96795f5040d6a0b493867ceaf35d34 Mon Sep 17 00:00:00 2001 From: Jakub Kaderka Date: Fri, 21 Dec 2018 23:52:26 +0100 Subject: Generate peripherals and channels from signal name --- tools/mx2board.py | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/tools/mx2board.py b/tools/mx2board.py index 5bec83c..14b367c 100755 --- a/tools/mx2board.py +++ b/tools/mx2board.py @@ -230,6 +230,7 @@ def read_project(gpio, filename): or 'DAC' in prop_value \ or 'OSC' in prop_value: pads[pad_port][pad_num]["MODER"] = PIN_MODE_ANALOG + pads[pad_port][pad_num]["SIGNAL"] = prop_value elif 'GPIO_Output' == prop_value: pads[pad_port][pad_num]["MODER"] = PIN_MODE_OUTPUT elif 'GPIO_Input' == prop_value: @@ -274,15 +275,48 @@ def gen_defines(project): defines['LINE_'+label] = 'PAL_LINE(GPIO' + port_key defines['LINE_'+label] += ', ' + str(pad_key) + 'U)' - if re.search(r"TIM\d+_CH\d$", signal, re.M): - timer = signal.replace('TIM', '').replace('_CH', '')[:-1] - ch_num = int(signal[-1:]) - + match = re.search(r"TIM(\d+)_CH(\d)$", signal) + if match: + timer = match.group(1) + ch_num = int(match.group(2)) defines['TIM_' + label] = timer defines['CCR_' + label] = 'CCR' + timer[-1] defines['PWMD_' + label] = 'PWMD' + timer[-1] defines['ICUD_' + label] = 'ICUD' + timer[-1] defines['CHN_' + label] = ch_num - 1 + continue + + match = re.search(r"ADC(\d*)_IN(\d+)$", signal) + if match: + adc = match.group(1) + if len(adc) == 0: + adc = 1 + defines['ADC_' + label] = adc + defines['CHN_' + label] = match.group(2) + continue + + match = re.search(r"USART(\d+)_[RT]X$", signal) + if match: + defines['USART_' + label] = match.group(1) + continue + + match = re.search(r"COMP_DAC(\d+)_group", signal) + if match: + defines['DAC_' + label] = match.group(1) + continue + + match = re.search(r"I2C(\d)_S(CL|DA)", signal) + if match: + defines['I2C_' + label] = match.group(1) + continue + + match = re.search(r"CAN(\d)_[RT]X", signal) + if match: + can = match.group(1) + if len(can) == 0: + can = 1 + defines['CAN_' + label] = can + continue return defines -- cgit v1.2.3 From 4ce121fdb0039a11f9617ca0e8a53bdac57a64c8 Mon Sep 17 00:00:00 2001 From: Jakub Kaderka Date: Sat, 22 Dec 2018 09:12:33 +0100 Subject: Fixed single can generation --- tools/mx2board.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mx2board.py b/tools/mx2board.py index 14b367c..20dcfb3 100755 --- a/tools/mx2board.py +++ b/tools/mx2board.py @@ -310,7 +310,7 @@ def gen_defines(project): defines['I2C_' + label] = match.group(1) continue - match = re.search(r"CAN(\d)_[RT]X", signal) + match = re.search(r"CAN(\d*)_[RT]X", signal) if match: can = match.group(1) if len(can) == 0: -- cgit v1.2.3