1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 14:25:20 +03:00

Added resource index display.

This commit is contained in:
mikeller 2019-08-07 01:14:25 +12:00 committed by Michael Keller
parent c2db38fec9
commit 768b345166
20 changed files with 74 additions and 80 deletions

View file

@ -28,7 +28,7 @@
#ifdef USE_TIMER_MGMT
#include "pg/timerio.h"
static resourceOwner_e timerOwners[MAX_TIMER_PINMAP_COUNT];
static resourceOwner_t timerOwners[MAX_TIMER_PINMAP_COUNT];
timerIOConfig_t *timerIoConfigByTag(ioTag_t ioTag)
{
@ -78,19 +78,21 @@ const timerHardware_t *timerGetByTag(ioTag_t ioTag)
return timerGetByTagAndIndex(ioTag, timerIndex);
}
resourceOwner_e timerGetOwner(int8_t timerNumber, uint16_t timerChannel)
const resourceOwner_t *timerGetOwner(int8_t timerNumber, uint16_t timerChannel)
{
static resourceOwner_t freeOwner = { .owner = OWNER_FREE, .resourceIndex = 0 };
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) {
return timerOwners[i];
return &timerOwners[i];
}
}
return OWNER_FREE;
return &freeOwner;
}
const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner)
const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner, uint8_t resourceIndex)
{
if (!ioTag) {
return NULL;
@ -100,11 +102,12 @@ const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner)
if (timerIOConfig(i)->ioTag == ioTag) {
const timerHardware_t *timer = timerGetByTagAndIndex(ioTag, timerIOConfig(i)->index);
if (timerGetOwner(timerGetTIMNumber(timer->tim), timer->channel)) {
if (timerGetOwner(timerGetTIMNumber(timer->tim), timer->channel)->owner) {
return NULL;
}
timerOwners[i] = owner;
timerOwners[i].owner = owner;
timerOwners[i].resourceIndex = resourceIndex;
return timer;
}
@ -128,9 +131,10 @@ const timerHardware_t *timerGetByTag(ioTag_t ioTag)
return NULL;
}
const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner)
const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner, uint8_t resourceIndex)
{
UNUSED(owner);
UNUSED(resourceIndex);
return timerGetByTag(ioTag);
}
@ -155,3 +159,4 @@ ioTag_t timerioTagGetByUsage(timerUsageFlag_e usageFlag, uint8_t index)
return IO_TAG_NONE;
}
#endif