mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-14 20:10:18 +03:00
Added indication for N-channel timers to 'resource show all'.
This commit is contained in:
parent
864cf3f3b4
commit
9eda7b4735
5 changed files with 29 additions and 14 deletions
|
@ -5864,7 +5864,8 @@ static void showTimers(void)
|
|||
cliPrintf("TIM%d:", timerNumber);
|
||||
bool timerUsed = false;
|
||||
for (unsigned timerIndex = 0; timerIndex < CC_CHANNELS_PER_TIMER; timerIndex++) {
|
||||
const resourceOwner_t *timerOwner = timerGetOwner(timerNumber, CC_CHANNEL_FROM_INDEX(timerIndex));
|
||||
const timerHardware_t *timer = timerGetAllocatedByNumberAndChannel(timerNumber, CC_CHANNEL_FROM_INDEX(timerIndex));
|
||||
const resourceOwner_t *timerOwner = timerGetOwner(timer);
|
||||
if (timerOwner->owner) {
|
||||
if (!timerUsed) {
|
||||
timerUsed = true;
|
||||
|
@ -5873,9 +5874,9 @@ static void showTimers(void)
|
|||
}
|
||||
|
||||
if (timerOwner->resourceIndex > 0) {
|
||||
cliPrintLinef(" CH%d: %s %d", timerIndex + 1, ownerNames[timerOwner->owner], timerOwner->resourceIndex);
|
||||
cliPrintLinef(" CH%d%s: %s %d", timerIndex + 1, timer->output & TIMER_OUTPUT_N_CHANNEL ? "N" : " ", ownerNames[timerOwner->owner], timerOwner->resourceIndex);
|
||||
} else {
|
||||
cliPrintLinef(" CH%d: %s", timerIndex + 1, ownerNames[timerOwner->owner]);
|
||||
cliPrintLinef(" CH%d%s: %s", timerIndex + 1, timer->output & TIMER_OUTPUT_N_CHANNEL ? "N" : " ", ownerNames[timerOwner->owner]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,11 +245,11 @@ static bbPort_t *bbAllocMotorPort(int portIndex)
|
|||
return bbPort;
|
||||
}
|
||||
|
||||
const resourceOwner_t *dshotBitbangTimerGetOwner(int8_t timerNumber, uint16_t timerChannel)
|
||||
const resourceOwner_t *dshotBitbangTimerGetOwner(const timerHardware_t *timer)
|
||||
{
|
||||
for (int index = 0; index < usedMotorPorts; index++) {
|
||||
const timerHardware_t *timer = bbPorts[index].timhw;
|
||||
if (timerGetTIMNumber(timer->tim) == timerNumber && timer->channel == timerChannel) {
|
||||
const timerHardware_t *bitbangTimer = bbPorts[index].timhw;
|
||||
if (bitbangTimer && bitbangTimer == timer) {
|
||||
return &bbPorts[index].owner;
|
||||
}
|
||||
}
|
||||
|
@ -351,7 +351,8 @@ static void bbFindPacerTimer(void)
|
|||
}
|
||||
bool timerConflict = false;
|
||||
for (int channel = 0; channel < CC_CHANNELS_PER_TIMER; channel++) {
|
||||
const resourceOwner_e timerOwner = timerGetOwner(timNumber, CC_CHANNEL_FROM_INDEX(channel))->owner;
|
||||
const timerHardware_t *timer = timerGetAllocatedByNumberAndChannel(timNumber, CC_CHANNEL_FROM_INDEX(channel));
|
||||
const resourceOwner_e timerOwner = timerGetOwner(timer)->owner;
|
||||
if (timerOwner != OWNER_FREE && timerOwner != OWNER_DSHOT_BITBANG) {
|
||||
timerConflict = true;
|
||||
break;
|
||||
|
|
|
@ -39,4 +39,4 @@ struct motorDevConfig_s;
|
|||
struct motorDevice_s;
|
||||
struct motorDevice_s *dshotBitbangDevInit(const struct motorDevConfig_s *motorConfig, uint8_t motorCount);
|
||||
dshotBitbangStatus_e dshotBitbangGetStatus();
|
||||
const resourceOwner_t *dshotBitbangTimerGetOwner(int8_t timerNumber, uint16_t timerChannel);
|
||||
const resourceOwner_t *dshotBitbangTimerGetOwner(const timerHardware_t *timer);
|
||||
|
|
|
@ -278,7 +278,8 @@ extern const resourceOwner_t freeOwner;
|
|||
struct timerIOConfig_s;
|
||||
|
||||
struct timerIOConfig_s *timerIoConfigByTag(ioTag_t ioTag);
|
||||
const resourceOwner_t *timerGetOwner(int8_t timerNumber, uint16_t timerChannel);
|
||||
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 *timerAllocate(ioTag_t ioTag, resourceOwner_e owner, uint8_t resourceIndex);
|
||||
|
|
|
@ -81,12 +81,24 @@ const timerHardware_t *timerGetByTag(ioTag_t ioTag)
|
|||
return timerGetByTagAndIndex(ioTag, timerIndex);
|
||||
}
|
||||
|
||||
const resourceOwner_t *timerGetOwner(int8_t timerNumber, uint16_t timerChannel)
|
||||
const timerHardware_t *timerGetAllocatedByNumberAndChannel(int8_t timerNumber, uint16_t timerChannel)
|
||||
{
|
||||
for (unsigned i = 0; i < MAX_TIMER_PINMAP_COUNT; i++) {
|
||||
const timerHardware_t *timer = timerGetByTagAndIndex(timerIOConfig(i)->ioTag, timerIOConfig(i)->index);
|
||||
if (timer && timerGetTIMNumber(timer->tim) == timerNumber && timer->channel == timerChannel && timerOwners[i].owner) {
|
||||
return timer;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const resourceOwner_t *timerGetOwner(const timerHardware_t *timer)
|
||||
{
|
||||
const resourceOwner_t *timerOwner = &freeOwner;
|
||||
for (unsigned i = 0; i < MAX_TIMER_PINMAP_COUNT; i++) {
|
||||
const timerHardware_t *timer = timerGetByTagAndIndex(timerIOConfig(i)->ioTag, timerIOConfig(i)->index);
|
||||
if (timer && timerGetTIMNumber(timer->tim) == timerNumber && timer->channel == timerChannel) {
|
||||
const timerHardware_t *assignedTimer = timerGetByTagAndIndex(timerIOConfig(i)->ioTag, timerIOConfig(i)->index);
|
||||
if (assignedTimer && assignedTimer == timer) {
|
||||
timerOwner = &timerOwners[i];
|
||||
|
||||
break;
|
||||
|
@ -95,7 +107,7 @@ const resourceOwner_t *timerGetOwner(int8_t timerNumber, uint16_t timerChannel)
|
|||
|
||||
#if defined(USE_DSHOT_BITBANG)
|
||||
if (!timerOwner->owner) {
|
||||
timerOwner = dshotBitbangTimerGetOwner(timerNumber, timerChannel);
|
||||
timerOwner = dshotBitbangTimerGetOwner(timer);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -112,7 +124,7 @@ const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner, uint8
|
|||
if (timerIOConfig(i)->ioTag == ioTag) {
|
||||
const timerHardware_t *timer = timerGetByTagAndIndex(ioTag, timerIOConfig(i)->index);
|
||||
|
||||
if (timerGetOwner(timerGetTIMNumber(timer->tim), timer->channel)->owner) {
|
||||
if (timerGetOwner(timer)->owner) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue