From ff5c44b4dcd3b72a593a58cf2c90d930f2c43c80 Mon Sep 17 00:00:00 2001 From: blckmn Date: Sat, 5 Nov 2016 06:51:43 +1100 Subject: [PATCH] Allow any allocation for motors and servos --- src/main/drivers/pwm_output.c | 4 ++-- src/main/drivers/timer.c | 2 +- src/main/drivers/timer.h | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/drivers/pwm_output.c b/src/main/drivers/pwm_output.c index ea28c3e48..b98367c53 100644 --- a/src/main/drivers/pwm_output.c +++ b/src/main/drivers/pwm_output.c @@ -208,7 +208,7 @@ void motorInit(const motorConfig_t *motorConfig, uint16_t idlePulse, uint8_t mot break; } - const timerHardware_t *timerHardware = timerGetByTag(tag, TIM_USE_MOTOR); + const timerHardware_t *timerHardware = timerGetByTag(tag, TIM_USE_ANY); if (timerHardware == NULL) { /* flag failure and disable ability to arm */ @@ -271,7 +271,7 @@ void servoInit(const servoConfig_t *servoConfig) IOInit(servos[servoIndex].io, OWNER_SERVO, RESOURCE_OUTPUT, RESOURCE_INDEX(servoIndex)); IOConfigGPIO(servos[servoIndex].io, IOCFG_AF_PP); - const timerHardware_t *timer = timerGetByTag(tag, TIM_USE_SERVO); + const timerHardware_t *timer = timerGetByTag(tag, TIM_USE_ANY); if (timer == NULL) { /* flag failure and disable ability to arm */ diff --git a/src/main/drivers/timer.c b/src/main/drivers/timer.c index 77096a1cb..4a6dad8f4 100755 --- a/src/main/drivers/timer.c +++ b/src/main/drivers/timer.c @@ -759,7 +759,7 @@ const timerHardware_t *timerGetByTag(ioTag_t tag, timerUsageFlag_e flag) { for (int i = 0; i < USABLE_TIMER_CHANNEL_COUNT; i++) { if (timerHardware[i].tag == tag) { - if (timerHardware[i].usageFlags & flag) { + if (timerHardware[i].usageFlags & flag || flag == 0) { return &timerHardware[i]; } } diff --git a/src/main/drivers/timer.h b/src/main/drivers/timer.h index 9a86a9210..f84b15e29 100644 --- a/src/main/drivers/timer.h +++ b/src/main/drivers/timer.h @@ -55,6 +55,7 @@ typedef uint32_t timCNT_t; #endif typedef enum { + TIM_USE_ANY = 0x0, TIM_USE_PPM = 0x1, TIM_USE_PWM = 0x2, TIM_USE_MOTOR = 0x4,