fix imxrt: use 1:1 timer group to channel association

This commit is contained in:
David Sidrane 2022-10-10 05:12:27 -07:00 committed by Beat Küng
parent 7e9ec325f7
commit 7f7137320a
1 changed files with 15 additions and 7 deletions

View File

@ -32,16 +32,16 @@ def extract_timer(line):
# Try format: initIOTimer(Timer::Timer5, DMA{DMA::Index1, DMA::Stream0, DMA::Channel6}),
search = re.search('Timer::([0-9a-zA-Z_]+)[,\)]', line, re.IGNORECASE)
if search:
return search.group(1)
return search.group(1), 'generic'
# nxp rt1062 format: initIOPWM(PWM::FlexPWM2),
search = re.search('PWM::Flex([0-9a-zA-Z_]+)[,\)]', line, re.IGNORECASE)
if search:
return search.group(1)
return search.group(1), 'imxrt'
return None
return None, 'unknown'
def extract_timer_from_channel(line):
def extract_timer_from_channel(line, num_channels_already_found):
# Try format: initIOTimerChannel(io_timers, {Timer::Timer5, Timer::Channel1}, {GPIO::PortA, GPIO::Pin0}),
search = re.search('Timer::([0-9a-zA-Z_]+), ', line, re.IGNORECASE)
if search:
@ -50,7 +50,8 @@ def extract_timer_from_channel(line):
# nxp rt1062 format: initIOTimerChannel(io_timers, {PWM::PWM2_PWM_A, PWM::Submodule0}, IOMUX::Pad::GPIO_B0_06),
search = re.search('PWM::(PWM[0-9]+)[_,\)]', line, re.IGNORECASE)
if search:
return search.group(1)
# imxrt uses a 1:1 timer group to channel association
return str(num_channels_already_found)
return None
@ -72,7 +73,14 @@ def get_timer_groups(timer_config_file, verbose=False):
line = line.strip()
if len(line) == 0 or line.startswith('//'):
continue
timer = extract_timer(line)
timer, timer_type = extract_timer(line)
if timer_type == 'imxrt':
if verbose: print('imxrt timer found')
max_num_channels = 16 # Just add a fixed number of timers
timers = [str(i) for i in range(max_num_channels)]
dshot_support = {str(i): False for i in range(max_num_channels)}
break
if timer:
if verbose: print('found timer def: {:}'.format(timer))
@ -101,7 +109,7 @@ def get_timer_groups(timer_config_file, verbose=False):
continue
if verbose: print('--'+line+'--')
timer = extract_timer_from_channel(line)
timer = extract_timer_from_channel(line, len(channel_timers))
if timer:
if verbose: print('Found timer: {:} in channel line {:}'.format(timer, line))