From 6a0c5836dea782b3fa80c2f0df23e5fa49acbcbe Mon Sep 17 00:00:00 2001 From: mikeller Date: Mon, 5 Aug 2019 19:39:26 +1200 Subject: [PATCH] Added 'timer show' command to CLI. --- src/main/cli/cli.c | 238 ++++++++++-------- src/main/drivers/camera_control.c | 2 +- src/main/drivers/dshot_dpwm.c | 2 +- src/main/drivers/light_ws2811strip_hal.c | 2 +- .../drivers/light_ws2811strip_stdperiph.c | 2 +- src/main/drivers/pwm_output.c | 4 +- src/main/drivers/rx/rx_pwm.c | 4 +- src/main/drivers/serial_escserial.c | 6 +- src/main/drivers/serial_softserial.c | 4 +- src/main/drivers/sound_beeper.c | 2 +- src/main/drivers/timer.c | 11 +- src/main/drivers/timer.h | 3 + src/main/drivers/timer_common.c | 47 +++- src/main/drivers/timer_hal.c | 11 +- src/main/drivers/transponder_ir_io_hal.c | 2 +- .../drivers/transponder_ir_io_stdperiph.c | 2 +- 16 files changed, 217 insertions(+), 125 deletions(-) diff --git a/src/main/cli/cli.c b/src/main/cli/cli.c index e9bb7e4f1..b1bd4f225 100644 --- a/src/main/cli/cli.c +++ b/src/main/cli/cli.c @@ -4892,7 +4892,7 @@ static bool strToPin(char *pch, ioTag_t *tag) } #ifdef USE_DMA -static void printDma(void) +static void showDma(void) { cliPrintLinefeed(); @@ -5304,7 +5304,7 @@ static void cliDma(char* cmdline) { int len = strlen(cmdline); if (len && strncasecmp(cmdline, "show", len) == 0) { - printDma(); + showDma(); return; } @@ -5316,103 +5316,6 @@ static void cliDma(char* cmdline) #endif } #endif - -static void cliResource(char *cmdline) -{ - char *pch = NULL; - char *saveptr; - - pch = strtok_r(cmdline, " ", &saveptr); - if (!pch) { - printResource(DUMP_MASTER | HIDE_UNUSED, NULL); - - return; - } else if (strcasecmp(pch, "show") == 0) { -#ifdef MINIMAL_CLI - cliPrintLine("IO"); -#else - cliPrintLine("Currently active IO resource assignments:\r\n(reboot to update)"); - cliRepeat('-', 20); -#endif - for (int i = 0; i < DEFIO_IO_USED_COUNT; i++) { - const char* owner; - owner = ownerNames[ioRecs[i].owner]; - - cliPrintf("%c%02d: %s", IO_GPIOPortIdx(ioRecs + i) + 'A', IO_GPIOPinIdx(ioRecs + i), owner); - if (ioRecs[i].index > 0) { - cliPrintf(" %d", ioRecs[i].index); - } - cliPrintLinefeed(); - } - -#if defined(USE_DMA) - pch = strtok_r(NULL, " ", &saveptr); - if (strcasecmp(pch, "all") == 0) { - cliDma("show"); - } -#endif - - return; - } - - uint8_t resourceIndex = 0; - int index = 0; - for (resourceIndex = 0; ; resourceIndex++) { - if (resourceIndex >= ARRAYLEN(resourceTable)) { - cliPrintErrorLinef("INVALID RESOURCE NAME: '%s'", pch); - return; - } - - const char * resourceName = ownerNames[resourceTable[resourceIndex].owner]; - if (strncasecmp(pch, resourceName, strlen(resourceName)) == 0) { - break; - } - } - - pch = strtok_r(NULL, " ", &saveptr); - index = atoi(pch); - - if (resourceTable[resourceIndex].maxIndex > 0 || index > 0) { - if (index <= 0 || index > MAX_RESOURCE_INDEX(resourceTable[resourceIndex].maxIndex)) { - cliShowArgumentRangeError("INDEX", 1, MAX_RESOURCE_INDEX(resourceTable[resourceIndex].maxIndex)); - return; - } - index -= 1; - - pch = strtok_r(NULL, " ", &saveptr); - } - - ioTag_t *tag = getIoTag(resourceTable[resourceIndex], index); - - if (strlen(pch) > 0) { - if (strToPin(pch, tag)) { - if (*tag == IO_TAG_NONE) { -#ifdef MINIMAL_CLI - cliPrintLine("Freed"); -#else - cliPrintLine("Resource is freed"); -#endif - return; - } else { - ioRec_t *rec = IO_Rec(IOGetByTag(*tag)); - if (rec) { - resourceCheck(resourceIndex, index, *tag); -#ifdef MINIMAL_CLI - cliPrintLinef(" %c%02d set", IO_GPIOPortIdx(rec) + 'A', IO_GPIOPinIdx(rec)); -#else - cliPrintLinef("\r\nResource is set to %c%02d", IO_GPIOPortIdx(rec) + 'A', IO_GPIOPinIdx(rec)); -#endif - } else { - cliShowParseError(); - } - return; - } - } - } - - cliShowParseError(); -} - #endif // USE_RESOURCE_MGMT #ifdef USE_TIMER_MGMT @@ -5517,6 +5420,40 @@ static void alternateFunctionToString(const ioTag_t ioTag, const int index, char } } +static void showTimers(void) +{ + cliPrintLinefeed(); + +#ifdef MINIMAL_CLI + cliPrintLine("Timers:"); +#else + cliPrintLine("Currently active Timers:"); + cliRepeat('-', 23); +#endif + + int8_t timerNumber; + for (int i = 0; (timerNumber = timerGetNumberByIndex(i)); i++) { + cliPrintf("TIM%d:", timerNumber); + bool timerUsed = false; + for (unsigned timerIndex = 0; timerIndex < CC_CHANNELS_PER_TIMER; timerIndex++) { + const resourceOwner_e owner = timerGetOwner(timerNumber, CC_CHANNEL_FROM_INDEX(timerIndex)); + if (owner) { + if (!timerUsed) { + timerUsed = true; + + cliPrintLinefeed(); + } + + cliPrintLinef(" CH%d: %s", timerIndex + 1, ownerNames[owner]); + } + } + + if (!timerUsed) { + cliPrintLine(" FREE"); + } + } +} + static void cliTimer(char *cmdline) { int len = strlen(cmdline); @@ -5530,7 +5467,7 @@ static void cliTimer(char *cmdline) return; } else if (strncasecmp(cmdline, "show", len) == 0) { - cliPrintErrorLinef("NOT IMPLEMENTED YET"); + showTimers(); return; } @@ -5646,6 +5583,107 @@ static void cliTimer(char *cmdline) } #endif +#if defined(USE_RESOURCE_MGMT) +static void cliResource(char *cmdline) +{ + char *pch = NULL; + char *saveptr; + + pch = strtok_r(cmdline, " ", &saveptr); + if (!pch) { + printResource(DUMP_MASTER | HIDE_UNUSED, NULL); + + return; + } else if (strcasecmp(pch, "show") == 0) { +#ifdef MINIMAL_CLI + cliPrintLine("IO"); +#else + cliPrintLine("Currently active IO resource assignments:\r\n(reboot to update)"); + cliRepeat('-', 20); +#endif + for (int i = 0; i < DEFIO_IO_USED_COUNT; i++) { + const char* owner; + owner = ownerNames[ioRecs[i].owner]; + + cliPrintf("%c%02d: %s", IO_GPIOPortIdx(ioRecs + i) + 'A', IO_GPIOPinIdx(ioRecs + i), owner); + if (ioRecs[i].index > 0) { + cliPrintf(" %d", ioRecs[i].index); + } + cliPrintLinefeed(); + } + + pch = strtok_r(NULL, " ", &saveptr); + if (strcasecmp(pch, "all") == 0) { +#if defined(USE_TIMER_MGMT) + cliTimer("show"); +#endif +#if defined(USE_DMA) + cliDma("show"); +#endif + } + + return; + } + + uint8_t resourceIndex = 0; + int index = 0; + for (resourceIndex = 0; ; resourceIndex++) { + if (resourceIndex >= ARRAYLEN(resourceTable)) { + cliPrintErrorLinef("INVALID RESOURCE NAME: '%s'", pch); + return; + } + + const char * resourceName = ownerNames[resourceTable[resourceIndex].owner]; + if (strncasecmp(pch, resourceName, strlen(resourceName)) == 0) { + break; + } + } + + pch = strtok_r(NULL, " ", &saveptr); + index = atoi(pch); + + if (resourceTable[resourceIndex].maxIndex > 0 || index > 0) { + if (index <= 0 || index > MAX_RESOURCE_INDEX(resourceTable[resourceIndex].maxIndex)) { + cliShowArgumentRangeError("INDEX", 1, MAX_RESOURCE_INDEX(resourceTable[resourceIndex].maxIndex)); + return; + } + index -= 1; + + pch = strtok_r(NULL, " ", &saveptr); + } + + ioTag_t *tag = getIoTag(resourceTable[resourceIndex], index); + + if (strlen(pch) > 0) { + if (strToPin(pch, tag)) { + if (*tag == IO_TAG_NONE) { +#ifdef MINIMAL_CLI + cliPrintLine("Freed"); +#else + cliPrintLine("Resource is freed"); +#endif + return; + } else { + ioRec_t *rec = IO_Rec(IOGetByTag(*tag)); + if (rec) { + resourceCheck(resourceIndex, index, *tag); +#ifdef MINIMAL_CLI + cliPrintLinef(" %c%02d set", IO_GPIOPortIdx(rec) + 'A', IO_GPIOPinIdx(rec)); +#else + cliPrintLinef("\r\nResource is set to %c%02d", IO_GPIOPortIdx(rec) + 'A', IO_GPIOPinIdx(rec)); +#endif + } else { + cliShowParseError(); + } + return; + } + } + } + + cliShowParseError(); +} +#endif + #ifdef USE_DSHOT_TELEMETRY static void cliDshotTelemetryInfo(char *cmdline) { diff --git a/src/main/drivers/camera_control.c b/src/main/drivers/camera_control.c index 88f2150f3..8e984b45f 100644 --- a/src/main/drivers/camera_control.c +++ b/src/main/drivers/camera_control.c @@ -131,7 +131,7 @@ void cameraControlInit(void) if (CAMERA_CONTROL_MODE_HARDWARE_PWM == cameraControlConfig()->mode) { #ifdef CAMERA_CONTROL_HARDWARE_PWM_AVAILABLE - const timerHardware_t *timerHardware = timerGetByTag(cameraControlConfig()->ioTag); + const timerHardware_t *timerHardware = timerAllocate(cameraControlConfig()->ioTag, OWNER_CAMERA_CONTROL); if (!timerHardware) { return; diff --git a/src/main/drivers/dshot_dpwm.c b/src/main/drivers/dshot_dpwm.c index 861bd7e50..b907566ad 100644 --- a/src/main/drivers/dshot_dpwm.c +++ b/src/main/drivers/dshot_dpwm.c @@ -177,7 +177,7 @@ motorDevice_t *dshotPwmDevInit(const motorDevConfig_t *motorConfig, uint16_t idl for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS && motorIndex < motorCount; motorIndex++) { const ioTag_t tag = motorConfig->ioTags[motorIndex]; - const timerHardware_t *timerHardware = timerGetByTag(tag); + const timerHardware_t *timerHardware = timerAllocate(tag, OWNER_MOTOR); if (timerHardware == NULL) { /* not enough motors initialised for the mixer or a break in the motors */ diff --git a/src/main/drivers/light_ws2811strip_hal.c b/src/main/drivers/light_ws2811strip_hal.c index 03c39c5e2..ffc8bf9e8 100644 --- a/src/main/drivers/light_ws2811strip_hal.c +++ b/src/main/drivers/light_ws2811strip_hal.c @@ -55,7 +55,7 @@ bool ws2811LedStripHardwareInit(ioTag_t ioTag) return false; } - const timerHardware_t *timerHardware = timerGetByTag(ioTag); + const timerHardware_t *timerHardware = timerAllocate(ioTag, OWNER_LED_STRIP); if (timerHardware == NULL) { return false; diff --git a/src/main/drivers/light_ws2811strip_stdperiph.c b/src/main/drivers/light_ws2811strip_stdperiph.c index a1a95481b..adc903676 100644 --- a/src/main/drivers/light_ws2811strip_stdperiph.c +++ b/src/main/drivers/light_ws2811strip_stdperiph.c @@ -83,7 +83,7 @@ bool ws2811LedStripHardwareInit(ioTag_t ioTag) TIM_OCInitTypeDef TIM_OCInitStructure; DMA_InitTypeDef DMA_InitStructure; - const timerHardware_t *timerHardware = timerGetByTag(ioTag); + const timerHardware_t *timerHardware = timerAllocate(ioTag, OWNER_LED_STRIP); if (timerHardware == NULL) { return false; diff --git a/src/main/drivers/pwm_output.c b/src/main/drivers/pwm_output.c index 0f65d88d1..928d02421 100644 --- a/src/main/drivers/pwm_output.c +++ b/src/main/drivers/pwm_output.c @@ -213,7 +213,7 @@ motorDevice_t *motorPwmDevInit(const motorDevConfig_t *motorConfig, uint16_t idl for (int motorIndex = 0; motorIndex < MAX_SUPPORTED_MOTORS && motorIndex < motorCount; motorIndex++) { const ioTag_t tag = motorConfig->ioTags[motorIndex]; - const timerHardware_t *timerHardware = timerGetByTag(tag); + const timerHardware_t *timerHardware = timerAllocate(tag, OWNER_MOTOR); if (timerHardware == NULL) { /* not enough motors initialised for the mixer or a break in the motors */ @@ -294,7 +294,7 @@ void servoDevInit(const servoDevConfig_t *servoConfig) IOInit(servos[servoIndex].io, OWNER_SERVO, RESOURCE_INDEX(servoIndex)); - const timerHardware_t *timer = timerGetByTag(tag); + const timerHardware_t *timer = timerAllocate(tag, OWNER_SERVO); if (timer == NULL) { /* flag failure and disable ability to arm */ diff --git a/src/main/drivers/rx/rx_pwm.c b/src/main/drivers/rx/rx_pwm.c index 5cbbddb63..e543fb66e 100644 --- a/src/main/drivers/rx/rx_pwm.c +++ b/src/main/drivers/rx/rx_pwm.c @@ -371,7 +371,7 @@ void pwmRxInit(const pwmConfig_t *pwmConfig) pwmInputPort_t *port = &pwmInputPorts[channel]; - const timerHardware_t *timer = timerGetByTag(pwmConfig->ioTags[channel]); + const timerHardware_t *timer = timerAllocate(pwmConfig->ioTags[channel], OWNER_PWMINPUT); if (!timer) { /* TODO: maybe fail here if not enough channels? */ @@ -428,7 +428,7 @@ void ppmRxInit(const ppmConfig_t *ppmConfig) pwmInputPort_t *port = &pwmInputPorts[FIRST_PWM_PORT]; - const timerHardware_t *timer = timerGetByTag(ppmConfig->ioTag); + const timerHardware_t *timer = timerAllocate(ppmConfig->ioTag, OWNER_PPMINPUT); if (!timer) { /* TODO: fail here? */ return; diff --git a/src/main/drivers/serial_escserial.c b/src/main/drivers/serial_escserial.c index cad669278..fd612f8f3 100644 --- a/src/main/drivers/serial_escserial.c +++ b/src/main/drivers/serial_escserial.c @@ -668,7 +668,7 @@ static serialPort_t *openEscSerial(const motorDevConfig_t *motorConfig, escSeria } if (mode != PROTOCOL_KISSALL) { const ioTag_t tag = motorConfig->ioTags[output]; - const timerHardware_t *timerHardware = timerGetByTag(tag); + const timerHardware_t *timerHardware = timerAllocate(tag, OWNER_MOTOR); if (timerHardware == NULL) { return NULL; @@ -686,7 +686,7 @@ static serialPort_t *openEscSerial(const motorDevConfig_t *motorConfig, escSeria } escSerial->mode = mode; - escSerial->txTimerHardware = timerGetByTag(escSerialConfig()->ioTag); + escSerial->txTimerHardware = timerAllocate(escSerialConfig()->ioTag, OWNER_MOTOR); if (escSerial->txTimerHardware == NULL) { return NULL; } @@ -745,7 +745,7 @@ static serialPort_t *openEscSerial(const motorDevConfig_t *motorConfig, escSeria if (pwmMotors[i].enabled && pwmMotors[i].io != IO_NONE) { const ioTag_t tag = motorConfig->ioTags[i]; if (tag != IO_TAG_NONE) { - const timerHardware_t *timerHardware = timerGetByTag(tag); + const timerHardware_t *timerHardware = timerAllocate(tag, OWNER_MOTOR); if (timerHardware) { escSerialOutputPortConfig(timerHardware); escOutputs[escSerial->outputCount].io = pwmMotors[i].io; diff --git a/src/main/drivers/serial_softserial.c b/src/main/drivers/serial_softserial.c index 69841de7d..39cb3d42d 100644 --- a/src/main/drivers/serial_softserial.c +++ b/src/main/drivers/serial_softserial.c @@ -242,8 +242,8 @@ serialPort_t *openSoftSerial(softSerialPortIndex_e portIndex, serialReceiveCallb ioTag_t tagRx = serialPinConfig()->ioTagRx[pinCfgIndex]; ioTag_t tagTx = serialPinConfig()->ioTagTx[pinCfgIndex]; - const timerHardware_t *timerRx = timerGetByTag(tagRx); - const timerHardware_t *timerTx = timerGetByTag(tagTx); + const timerHardware_t *timerRx = timerAllocate(tagRx, OWNER_SERIAL_RX); + const timerHardware_t *timerTx = timerAllocate(tagTx, OWNER_SERIAL_TX); IO_t rxIO = IOGetByTag(tagRx); IO_t txIO = IOGetByTag(tagTx); diff --git a/src/main/drivers/sound_beeper.c b/src/main/drivers/sound_beeper.c index 1481e117e..a80999d24 100644 --- a/src/main/drivers/sound_beeper.c +++ b/src/main/drivers/sound_beeper.c @@ -61,7 +61,7 @@ static void pwmToggleBeeper(void) static void beeperPwmInit(const ioTag_t tag, uint16_t frequency) { - const timerHardware_t *timer = timerGetByTag(tag); + const timerHardware_t *timer = timerAllocate(tag, OWNER_BEEPER); IO_t beeperIO = IOGetByTag(tag); if (beeperIO && timer) { diff --git a/src/main/drivers/timer.c b/src/main/drivers/timer.c index f61730268..114bb4bf7 100644 --- a/src/main/drivers/timer.c +++ b/src/main/drivers/timer.c @@ -257,10 +257,8 @@ const int8_t timerNumbers[USED_TIMER_COUNT] = { #undef _DEF }; -int8_t timerGetTIMNumber(const TIM_TypeDef *tim) +int8_t timerGetNumberByIndex(uint8_t index) { - uint8_t index = lookupTimerIndex(tim); - if (index < USED_TIMER_COUNT) { return timerNumbers[index]; } else { @@ -268,6 +266,13 @@ int8_t timerGetTIMNumber(const TIM_TypeDef *tim) } } +int8_t timerGetTIMNumber(const TIM_TypeDef *tim) +{ + const uint8_t index = lookupTimerIndex(tim); + + return timerGetNumberByIndex(index); +} + static inline uint8_t lookupChannelIndex(const uint16_t channel) { return channel >> 2; diff --git a/src/main/drivers/timer.h b/src/main/drivers/timer.h index 14272afe8..819ef1759 100644 --- a/src/main/drivers/timer.h +++ b/src/main/drivers/timer.h @@ -270,8 +270,10 @@ uint8_t timerInputIrq(TIM_TypeDef *tim); #if defined(USE_TIMER_MGMT) timerIOConfig_t *timerIoConfigByTag(ioTag_t ioTag); +resourceOwner_e timerGetOwner(int8_t timerNumber, uint16_t timerChannel); #endif const timerHardware_t *timerGetByTag(ioTag_t ioTag); +const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner); const timerHardware_t *timerGetByTagAndIndex(ioTag_t ioTag, unsigned timerIndex); ioTag_t timerioTagGetByUsage(timerUsageFlag_e usageFlag, uint8_t index); @@ -292,5 +294,6 @@ uint16_t timerGetPrescalerByDesiredHertz(TIM_TypeDef *tim, uint32_t hz); uint16_t timerGetPrescalerByDesiredMhz(TIM_TypeDef *tim, uint16_t mhz); uint16_t timerGetPeriodByPrescaler(TIM_TypeDef *tim, uint16_t prescaler, uint32_t hz); +int8_t timerGetNumberByIndex(uint8_t index); int8_t timerGetTIMNumber(const TIM_TypeDef *tim); uint8_t timerLookupChannelIndex(const uint16_t channel); diff --git a/src/main/drivers/timer_common.c b/src/main/drivers/timer_common.c index 533536214..399368c03 100644 --- a/src/main/drivers/timer_common.c +++ b/src/main/drivers/timer_common.c @@ -27,9 +27,9 @@ #ifdef USE_TIMER_MGMT #include "pg/timerio.h" -#endif -#ifdef USE_TIMER_MGMT +static resourceOwner_e timerOwners[MAX_TIMER_PINMAP_COUNT]; + timerIOConfig_t *timerIoConfigByTag(ioTag_t ioTag) { for (unsigned i = 0; i < MAX_TIMER_PINMAP_COUNT; i++) { @@ -37,7 +37,7 @@ timerIOConfig_t *timerIoConfigByTag(ioTag_t ioTag) return timerIOConfigMutable(i); } } - UNUSED(ioTag); + return NULL; } @@ -78,6 +78,40 @@ const timerHardware_t *timerGetByTag(ioTag_t ioTag) return timerGetByTagAndIndex(ioTag, timerIndex); } +resourceOwner_e timerGetOwner(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) { + return timerOwners[i]; + } + } + + return OWNER_FREE; +} + +const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner) +{ + if (!ioTag) { + return NULL; + } + + for (unsigned i = 0; i < MAX_TIMER_PINMAP_COUNT; i++) { + if (timerIOConfig(i)->ioTag == ioTag) { + const timerHardware_t *timer = timerGetByTagAndIndex(ioTag, timerIOConfig(i)->index); + + if (timerGetOwner(timerGetTIMNumber(timer->tim), timer->channel)) { + return NULL; + } + + timerOwners[i] = owner; + + return timer; + } + } + + return NULL; +} #else const timerHardware_t *timerGetByTag(ioTag_t ioTag) @@ -93,6 +127,13 @@ const timerHardware_t *timerGetByTag(ioTag_t ioTag) #endif return NULL; } + +const timerHardware_t *timerAllocate(ioTag_t ioTag, resourceOwner_e owner) +{ + UNUSED(owner); + + return timerGetByTag(ioTag); +} #endif ioTag_t timerioTagGetByUsage(timerUsageFlag_e usageFlag, uint8_t index) diff --git a/src/main/drivers/timer_hal.c b/src/main/drivers/timer_hal.c index ae5aed74b..9cd429490 100644 --- a/src/main/drivers/timer_hal.c +++ b/src/main/drivers/timer_hal.c @@ -264,10 +264,8 @@ const int8_t timerNumbers[USED_TIMER_COUNT] = { #undef _DEF }; -int8_t timerGetTIMNumber(const TIM_TypeDef *tim) +int8_t timerGetNumberByIndex(uint8_t index) { - uint8_t index = lookupTimerIndex(tim); - if (index < USED_TIMER_COUNT) { return timerNumbers[index]; } else { @@ -275,6 +273,13 @@ int8_t timerGetTIMNumber(const TIM_TypeDef *tim) } } +int8_t timerGetTIMNumber(const TIM_TypeDef *tim) +{ + uint8_t index = lookupTimerIndex(tim); + + return timerGetNumberByIndex(index); +} + static inline uint8_t lookupChannelIndex(const uint16_t channel) { return channel >> 2; diff --git a/src/main/drivers/transponder_ir_io_hal.c b/src/main/drivers/transponder_ir_io_hal.c index 6da26f2b4..8aea49d32 100644 --- a/src/main/drivers/transponder_ir_io_hal.c +++ b/src/main/drivers/transponder_ir_io_hal.c @@ -72,7 +72,7 @@ void transponderIrHardwareInit(ioTag_t ioTag, transponder_t *transponder) return; } - const timerHardware_t *timerHardware = timerGetByTag(ioTag); + const timerHardware_t *timerHardware = timerAllocate(ioTag, OWNER_TRANSPONDER); TIM_TypeDef *timer = timerHardware->tim; timerChannel = timerHardware->channel; output = timerHardware->output; diff --git a/src/main/drivers/transponder_ir_io_stdperiph.c b/src/main/drivers/transponder_ir_io_stdperiph.c index 426c18534..f80003711 100644 --- a/src/main/drivers/transponder_ir_io_stdperiph.c +++ b/src/main/drivers/transponder_ir_io_stdperiph.c @@ -67,7 +67,7 @@ void transponderIrHardwareInit(ioTag_t ioTag, transponder_t *transponder) TIM_OCInitTypeDef TIM_OCInitStructure; DMA_InitTypeDef DMA_InitStructure; - const timerHardware_t *timerHardware = timerGetByTag(ioTag); + const timerHardware_t *timerHardware = timerAllocate(ioTag, OWNER_TRANSPONDER); timer = timerHardware->tim; alternateFunction = timerHardware->alternateFunction;