mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
Fixed 'timer show' for bitbanged Dshot timers.
This commit is contained in:
parent
a2bbd31c9c
commit
60b1e99826
3 changed files with 22 additions and 10 deletions
|
@ -238,6 +238,18 @@ static bbPort_t *bbAllocMotorPort(int portIndex)
|
||||||
return bbPort;
|
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)
|
const resourceOwner_t *dshotBitbangTimerGetOwner(const timerHardware_t *timer)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < usedMotorPorts; index++) {
|
for (int index = 0; index < usedMotorPorts; index++) {
|
||||||
|
@ -280,7 +292,7 @@ static void bbAllocDma(bbPort_t *bbPort)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dmaIdentifier_e dmaIdentifier = dmaGetIdentifier(bbPort->dmaResource);
|
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);
|
bbPort->dmaSource = timerDmaSource(timhw->channel);
|
||||||
|
|
||||||
bbPacer_t *bbPacer = bbFindMotorPacer(timhw->tim);
|
bbPacer_t *bbPacer = bbFindMotorPacer(timhw->tim);
|
||||||
|
|
|
@ -39,4 +39,5 @@ struct motorDevConfig_s;
|
||||||
struct motorDevice_s;
|
struct motorDevice_s;
|
||||||
struct motorDevice_s *dshotBitbangDevInit(const struct motorDevConfig_s *motorConfig, uint8_t motorCount);
|
struct motorDevice_s *dshotBitbangDevInit(const struct motorDevConfig_s *motorConfig, uint8_t motorCount);
|
||||||
dshotBitbangStatus_e dshotBitbangGetStatus();
|
dshotBitbangStatus_e dshotBitbangGetStatus();
|
||||||
|
const timerHardware_t *dshotBitbangTimerGetAllocatedByNumberAndChannel(int8_t timerNumber, uint16_t timerChannel);
|
||||||
const resourceOwner_t *dshotBitbangTimerGetOwner(const timerHardware_t *timer);
|
const resourceOwner_t *dshotBitbangTimerGetOwner(const timerHardware_t *timer);
|
||||||
|
|
|
@ -87,28 +87,27 @@ const timerHardware_t *timerGetAllocatedByNumberAndChannel(int8_t timerNumber, u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_DSHOT_BITBANG)
|
||||||
|
return dshotBitbangTimerGetAllocatedByNumberAndChannel(timerNumber, timerChannel);
|
||||||
|
#else
|
||||||
return NULL;
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const resourceOwner_t *timerGetOwner(const timerHardware_t *timer)
|
const resourceOwner_t *timerGetOwner(const timerHardware_t *timer)
|
||||||
{
|
{
|
||||||
const resourceOwner_t *timerOwner = &freeOwner;
|
|
||||||
for (unsigned i = 0; i < MAX_TIMER_PINMAP_COUNT; i++) {
|
for (unsigned i = 0; i < MAX_TIMER_PINMAP_COUNT; i++) {
|
||||||
const timerHardware_t *assignedTimer = timerGetByTagAndIndex(timerIOConfig(i)->ioTag, timerIOConfig(i)->index);
|
const timerHardware_t *assignedTimer = timerGetByTagAndIndex(timerIOConfig(i)->ioTag, timerIOConfig(i)->index);
|
||||||
if (assignedTimer && assignedTimer == timer) {
|
if (assignedTimer && assignedTimer == timer) {
|
||||||
timerOwner = &timerOwners[i];
|
return &timerOwners[i];
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_DSHOT_BITBANG)
|
#if defined(USE_DSHOT_BITBANG)
|
||||||
if (!timerOwner->owner) {
|
return dshotBitbangTimerGetOwner(timer);
|
||||||
timerOwner = dshotBitbangTimerGetOwner(timer);
|
#else
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return timerOwner;
|
return timerOwner;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue