1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 11:59:58 +03:00

Rename timer functions to make them easier to understand.

This commit is contained in:
Michael Keller 2021-07-27 23:25:53 +12:00
parent 9eda7b4735
commit 4d79c0fbd2
5 changed files with 16 additions and 19 deletions

View file

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

View file

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

View file

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

View file

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

View file

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