From 7f7137320ab39d544280f9fae8cda28925a18948 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Mon, 10 Oct 2022 05:12:27 -0700 Subject: [PATCH] fix imxrt: use 1:1 timer group to channel association --- .../output_groups_from_timer_config.py | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Tools/module_config/output_groups_from_timer_config.py b/Tools/module_config/output_groups_from_timer_config.py index f334bd5822..561c71fd84 100755 --- a/Tools/module_config/output_groups_from_timer_config.py +++ b/Tools/module_config/output_groups_from_timer_config.py @@ -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))