From ea494f5d7718f0803623eba0cf8dd494fdec2a92 Mon Sep 17 00:00:00 2001 From: Peter van der Perk Date: Sun, 10 Mar 2024 16:11:03 +0100 Subject: [PATCH] imxrt: dshot actuators.json properly detect dshot timers --- .../output_groups_from_timer_config.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Tools/module_config/output_groups_from_timer_config.py b/Tools/module_config/output_groups_from_timer_config.py index 62ea7c8214..8a932ec9de 100755 --- a/Tools/module_config/output_groups_from_timer_config.py +++ b/Tools/module_config/output_groups_from_timer_config.py @@ -54,12 +54,21 @@ def extract_timer_from_channel(line, timer_names): return None +def imxrt_is_dshot(line): + + # NXP FlexPWM format format: initIOPWM(PWM::FlexPWM2), + search = re.search('(initIOPWMDshot)', line, re.IGNORECASE) + if search: + return True + + return False + def get_timer_groups(timer_config_file, verbose=False): with open(timer_config_file, 'r') as f: timer_config = f.read() # timers - dshot_support = {} # key: timer + dshot_support = {str(i): False for i in range(16)} timers_start_marker = 'io_timers_t io_timers' timers_start = timer_config.find(timers_start_marker) if timers_start == -1: @@ -78,10 +87,9 @@ def get_timer_groups(timer_config_file, verbose=False): if timer_type == 'imxrt': if verbose: print('imxrt timer found') timer_names.append(timer) + if imxrt_is_dshot(line): + dshot_support[str(len(timers))] = True timers.append(str(len(timers))) - dshot_support = {str(i): False for i in range(16)} - for i in range(8): # First 8 channels support dshot - dshot_support[str(i)] = True elif timer: if verbose: print('found timer def: {:}'.format(timer)) dshot_support[timer] = 'DMA' in line