imxrt: dshot actuators.json properly detect dshot timers

This commit is contained in:
Peter van der Perk 2024-03-10 16:11:03 +01:00 committed by Peter van der Perk
parent 096dc306be
commit ea494f5d77
1 changed files with 12 additions and 4 deletions

View File

@ -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