From 5d7f6b6c3df77f33360fc9269c12e979ef543041 Mon Sep 17 00:00:00 2001 From: jflyper Date: Sun, 2 Sep 2018 01:02:26 +0900 Subject: [PATCH] Initialize timers assigned to servos appropriately --- src/main/drivers/pwm_output.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/drivers/pwm_output.c b/src/main/drivers/pwm_output.c index 61b5a6425c..ddd1e5b0c0 100644 --- a/src/main/drivers/pwm_output.c +++ b/src/main/drivers/pwm_output.c @@ -557,16 +557,18 @@ void servoDevInit(const servoDevConfig_t *servoConfig) IOInit(servos[servoIndex].io, OWNER_SERVO, RESOURCE_INDEX(servoIndex)); const timerHardware_t *timer = timerGetByTag(tag); -#if defined(USE_HAL_DRIVER) - IOConfigGPIOAF(servos[servoIndex].io, IOCFG_AF_PP, timer->alternateFunction); -#else - IOConfigGPIO(servos[servoIndex].io, IOCFG_AF_PP); -#endif if (timer == NULL) { /* flag failure and disable ability to arm */ break; } + +#if defined(STM32F1) + IOConfigGPIO(servos[servoIndex].io, IOCFG_AF_PP); +#else + IOConfigGPIOAF(servos[servoIndex].io, IOCFG_AF_PP, timer->alternateFunction); +#endif + pwmOutConfig(&servos[servoIndex].channel, timer, PWM_TIMER_1MHZ, PWM_TIMER_1MHZ / servoConfig->servoPwmRate, servoConfig->servoCenterPulse, 0); servos[servoIndex].enabled = true; }