1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 16:55:36 +03:00

Merge pull request #10970 from mikeller/fix_timer_show

This commit is contained in:
Michael Keller 2021-09-27 01:27:20 +13:00 committed by GitHub
commit 597c8db7f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 10 deletions

View file

@ -238,6 +238,18 @@ static bbPort_t *bbAllocMotorPort(int portIndex)
return bbPort;
}
const timerHardware_t *dshotBitbangTimerGetAllocatedByNumberAndChannel(int8_t timerNumber, uint16_t timerChannel)
{
for (int index = 0; index < usedMotorPorts; index++) {
const timerHardware_t *bitbangTimer = bbPorts[index].timhw;
if (bitbangTimer && timerGetTIMNumber(bitbangTimer->tim) == timerNumber && bitbangTimer->channel == timerChannel && bbPorts[index].owner.owner) {
return bitbangTimer;
}
}
return NULL;
}
const resourceOwner_t *dshotBitbangTimerGetOwner(const timerHardware_t *timer)
{
for (int index = 0; index < usedMotorPorts; index++) {
@ -280,7 +292,7 @@ static void bbAllocDma(bbPort_t *bbPort)
#endif
dmaIdentifier_e dmaIdentifier = dmaGetIdentifier(bbPort->dmaResource);
dmaInit(dmaIdentifier, OWNER_DSHOT_BITBANG, bbPort->owner.resourceIndex);
dmaInit(dmaIdentifier, bbPort->owner.owner, bbPort->owner.resourceIndex);
bbPort->dmaSource = timerDmaSource(timhw->channel);
bbPacer_t *bbPacer = bbFindMotorPacer(timhw->tim);

View file

@ -39,4 +39,5 @@ struct motorDevConfig_s;
struct motorDevice_s;
struct motorDevice_s *dshotBitbangDevInit(const struct motorDevConfig_s *motorConfig, uint8_t motorCount);
dshotBitbangStatus_e dshotBitbangGetStatus();
const timerHardware_t *dshotBitbangTimerGetAllocatedByNumberAndChannel(int8_t timerNumber, uint16_t timerChannel);
const resourceOwner_t *dshotBitbangTimerGetOwner(const timerHardware_t *timer);

View file

@ -87,28 +87,27 @@ const timerHardware_t *timerGetAllocatedByNumberAndChannel(int8_t timerNumber, u
}
}
#if defined(USE_DSHOT_BITBANG)
return dshotBitbangTimerGetAllocatedByNumberAndChannel(timerNumber, timerChannel);
#else
return NULL;
#endif
}
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 *assignedTimer = timerGetByTagAndIndex(timerIOConfig(i)->ioTag, timerIOConfig(i)->index);
if (assignedTimer && assignedTimer == timer) {
timerOwner = &timerOwners[i];
break;
return &timerOwners[i];
}
}
#if defined(USE_DSHOT_BITBANG)
if (!timerOwner->owner) {
timerOwner = dshotBitbangTimerGetOwner(timer);
}
#endif
return dshotBitbangTimerGetOwner(timer);
#else
return timerOwner;
#endif
}
const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner, uint8_t resourceIndex)