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:
parent
9eda7b4735
commit
4d79c0fbd2
5 changed files with 16 additions and 19 deletions
|
@ -1589,7 +1589,7 @@ static void cliSerialPassthrough(const char *cmdName, char *cmdline)
|
||||||
for (unsigned i = 0; i < motorsCount; i++) {
|
for (unsigned i = 0; i < motorsCount; i++) {
|
||||||
const ioTag_t tag = motorConfig()->dev.ioTags[i];
|
const ioTag_t tag = motorConfig()->dev.ioTags[i];
|
||||||
if (tag) {
|
if (tag) {
|
||||||
const timerHardware_t *timerHardware = timerGetByTag(tag);
|
const timerHardware_t *timerHardware = timerGetConfiguredByTag(tag);
|
||||||
if (timerHardware) {
|
if (timerHardware) {
|
||||||
IO_t io = IOGetByTag(tag);
|
IO_t io = IOGetByTag(tag);
|
||||||
IOInit(io, OWNER_MOTOR, 0);
|
IOInit(io, OWNER_MOTOR, 0);
|
||||||
|
@ -5646,7 +5646,7 @@ static void cliDmaopt(const char *cmdName, char *cmdline)
|
||||||
#if defined(USE_TIMER_MGMT)
|
#if defined(USE_TIMER_MGMT)
|
||||||
timerIoConfig = timerIoConfigByTag(ioTag);
|
timerIoConfig = timerIoConfigByTag(ioTag);
|
||||||
#endif
|
#endif
|
||||||
timer = timerGetByTag(ioTag);
|
timer = timerGetConfiguredByTag(ioTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
// opt or list
|
// opt or list
|
||||||
|
|
|
@ -476,7 +476,7 @@ static void validateAndFixConfig(void)
|
||||||
|
|
||||||
#if defined(USE_BEEPER)
|
#if defined(USE_BEEPER)
|
||||||
#ifdef USE_TIMER
|
#ifdef USE_TIMER
|
||||||
if (beeperDevConfig()->frequency && !timerGetByTag(beeperDevConfig()->ioTag)) {
|
if (beeperDevConfig()->frequency && !timerGetConfiguredByTag(beeperDevConfig()->ioTag)) {
|
||||||
beeperDevConfigMutable()->frequency = 0;
|
beeperDevConfigMutable()->frequency = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -711,7 +711,7 @@ motorDevice_t *dshotBitbangDevInit(const motorDevConfig_t *motorConfig, uint8_t
|
||||||
|
|
||||||
for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS && motorIndex < motorCount; motorIndex++) {
|
for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS && motorIndex < motorCount; motorIndex++) {
|
||||||
const unsigned reorderedMotorIndex = motorConfig->motorOutputReordering[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]);
|
const IO_t io = IOGetByTag(motorConfig->ioTags[reorderedMotorIndex]);
|
||||||
|
|
||||||
uint8_t output = motorConfig->motorPwmInversion ? timerHardware->output ^ TIMER_OUTPUT_INVERTED : timerHardware->output;
|
uint8_t output = motorConfig->motorPwmInversion ? timerHardware->output ^ TIMER_OUTPUT_INVERTED : timerHardware->output;
|
||||||
|
|
|
@ -281,7 +281,7 @@ struct timerIOConfig_s *timerIoConfigByTag(ioTag_t ioTag);
|
||||||
const timerHardware_t *timerGetAllocatedByNumberAndChannel(int8_t timerNumber, uint16_t timerChannel);
|
const timerHardware_t *timerGetAllocatedByNumberAndChannel(int8_t timerNumber, uint16_t timerChannel);
|
||||||
const resourceOwner_t *timerGetOwner(const timerHardware_t *timer);
|
const resourceOwner_t *timerGetOwner(const timerHardware_t *timer);
|
||||||
#endif
|
#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 *timerAllocate(ioTag_t ioTag, resourceOwner_e owner, uint8_t resourceIndex);
|
||||||
const timerHardware_t *timerGetByTagAndIndex(ioTag_t ioTag, unsigned timerIndex);
|
const timerHardware_t *timerGetByTagAndIndex(ioTag_t ioTag, unsigned timerIndex);
|
||||||
ioTag_t timerioTagGetByUsage(timerUsageFlag_e usageFlag, uint8_t index);
|
ioTag_t timerioTagGetByUsage(timerUsageFlag_e usageFlag, uint8_t index);
|
||||||
|
|
|
@ -44,16 +44,6 @@ timerIOConfig_t *timerIoConfigByTag(ioTag_t ioTag)
|
||||||
return NULL;
|
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)
|
const timerHardware_t *timerGetByTagAndIndex(ioTag_t ioTag, unsigned timerIndex)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -74,9 +64,16 @@ const timerHardware_t *timerGetByTagAndIndex(ioTag_t ioTag, unsigned timerIndex)
|
||||||
return NULL;
|
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);
|
return timerGetByTagAndIndex(ioTag, timerIndex);
|
||||||
}
|
}
|
||||||
|
@ -139,7 +136,7 @@ const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner, uint8
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
const timerHardware_t *timerGetByTag(ioTag_t ioTag)
|
const timerHardware_t *timerGetConfiguredByTag(ioTag_t ioTag)
|
||||||
{
|
{
|
||||||
#if TIMER_CHANNEL_COUNT > 0
|
#if TIMER_CHANNEL_COUNT > 0
|
||||||
for (unsigned i = 0; i < TIMER_CHANNEL_COUNT; i++) {
|
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(owner);
|
||||||
UNUSED(resourceIndex);
|
UNUSED(resourceIndex);
|
||||||
|
|
||||||
return timerGetByTag(ioTag);
|
return timerGetConfiguredByTag(ioTag);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue