diff --git a/src/main/cli/cli.c b/src/main/cli/cli.c index 56ca481fe4..23796a07f4 100644 --- a/src/main/cli/cli.c +++ b/src/main/cli/cli.c @@ -1589,7 +1589,7 @@ static void cliSerialPassthrough(const char *cmdName, char *cmdline) for (unsigned i = 0; i < motorsCount; i++) { const ioTag_t tag = motorConfig()->dev.ioTags[i]; if (tag) { - const timerHardware_t *timerHardware = timerGetByTag(tag); + const timerHardware_t *timerHardware = timerGetConfiguredByTag(tag); if (timerHardware) { IO_t io = IOGetByTag(tag); IOInit(io, OWNER_MOTOR, 0); @@ -5646,7 +5646,7 @@ static void cliDmaopt(const char *cmdName, char *cmdline) #if defined(USE_TIMER_MGMT) timerIoConfig = timerIoConfigByTag(ioTag); #endif - timer = timerGetByTag(ioTag); + timer = timerGetConfiguredByTag(ioTag); } // opt or list diff --git a/src/main/config/config.c b/src/main/config/config.c index e4f66f028e..699b83ab0d 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -476,7 +476,7 @@ static void validateAndFixConfig(void) #if defined(USE_BEEPER) #ifdef USE_TIMER - if (beeperDevConfig()->frequency && !timerGetByTag(beeperDevConfig()->ioTag)) { + if (beeperDevConfig()->frequency && !timerGetConfiguredByTag(beeperDevConfig()->ioTag)) { beeperDevConfigMutable()->frequency = 0; } #endif diff --git a/src/main/drivers/dshot_bitbang.c b/src/main/drivers/dshot_bitbang.c index 9775355e96..7047519809 100644 --- a/src/main/drivers/dshot_bitbang.c +++ b/src/main/drivers/dshot_bitbang.c @@ -711,7 +711,7 @@ motorDevice_t *dshotBitbangDevInit(const motorDevConfig_t *motorConfig, uint8_t for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS && motorIndex < motorCount; motorIndex++) { const unsigned reorderedMotorIndex = motorConfig->motorOutputReordering[motorIndex]; - const timerHardware_t *timerHardware = timerGetByTag(motorConfig->ioTags[reorderedMotorIndex]); + const timerHardware_t *timerHardware = timerGetConfiguredByTag(motorConfig->ioTags[reorderedMotorIndex]); const IO_t io = IOGetByTag(motorConfig->ioTags[reorderedMotorIndex]); uint8_t output = motorConfig->motorPwmInversion ? timerHardware->output ^ TIMER_OUTPUT_INVERTED : timerHardware->output; diff --git a/src/main/drivers/timer.h b/src/main/drivers/timer.h index 42e00eff43..f00043cc46 100644 --- a/src/main/drivers/timer.h +++ b/src/main/drivers/timer.h @@ -281,7 +281,7 @@ struct timerIOConfig_s *timerIoConfigByTag(ioTag_t ioTag); const timerHardware_t *timerGetAllocatedByNumberAndChannel(int8_t timerNumber, uint16_t timerChannel); const resourceOwner_t *timerGetOwner(const timerHardware_t *timer); #endif -const timerHardware_t *timerGetByTag(ioTag_t ioTag); +const timerHardware_t *timerGetConfiguredByTag(ioTag_t ioTag); const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner, uint8_t resourceIndex); const timerHardware_t *timerGetByTagAndIndex(ioTag_t ioTag, unsigned timerIndex); ioTag_t timerioTagGetByUsage(timerUsageFlag_e usageFlag, uint8_t index); diff --git a/src/main/drivers/timer_common.c b/src/main/drivers/timer_common.c index 9139c83b69..661baf60df 100644 --- a/src/main/drivers/timer_common.c +++ b/src/main/drivers/timer_common.c @@ -44,16 +44,6 @@ timerIOConfig_t *timerIoConfigByTag(ioTag_t ioTag) return NULL; } -static uint8_t timerIndexByTag(ioTag_t ioTag) -{ - for (unsigned i = 0; i < MAX_TIMER_PINMAP_COUNT; i++) { - if (timerIOConfig(i)->ioTag == ioTag) { - return timerIOConfig(i)->index; - } - } - return 0; -} - const timerHardware_t *timerGetByTagAndIndex(ioTag_t ioTag, unsigned timerIndex) { @@ -74,9 +64,16 @@ const timerHardware_t *timerGetByTagAndIndex(ioTag_t ioTag, unsigned timerIndex) return NULL; } -const timerHardware_t *timerGetByTag(ioTag_t ioTag) +const timerHardware_t *timerGetConfiguredByTag(ioTag_t ioTag) { - uint8_t timerIndex = timerIndexByTag(ioTag); + uint8_t timerIndex = 0; + for (unsigned i = 0; i < MAX_TIMER_PINMAP_COUNT; i++) { + if (timerIOConfig(i)->ioTag == ioTag) { + timerIndex = timerIOConfig(i)->index; + + break; + } + } return timerGetByTagAndIndex(ioTag, timerIndex); } @@ -139,7 +136,7 @@ const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner, uint8 } #else -const timerHardware_t *timerGetByTag(ioTag_t ioTag) +const timerHardware_t *timerGetConfiguredByTag(ioTag_t ioTag) { #if TIMER_CHANNEL_COUNT > 0 for (unsigned i = 0; i < TIMER_CHANNEL_COUNT; i++) { @@ -158,7 +155,7 @@ const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner, uint8 UNUSED(owner); UNUSED(resourceIndex); - return timerGetByTag(ioTag); + return timerGetConfiguredByTag(ioTag); } #endif