From 70081340faa7ef7a09816cc63822bb215a86ad67 Mon Sep 17 00:00:00 2001 From: Thorsten Laux Date: Sun, 11 Aug 2019 17:47:15 +0200 Subject: [PATCH] Fix dshot on h7 --- src/main/drivers/pwm_output_dshot_hal_hal.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/drivers/pwm_output_dshot_hal_hal.c b/src/main/drivers/pwm_output_dshot_hal_hal.c index 97bb00efae..0aad25694e 100644 --- a/src/main/drivers/pwm_output_dshot_hal_hal.c +++ b/src/main/drivers/pwm_output_dshot_hal_hal.c @@ -274,12 +274,19 @@ void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m TIM_TypeDef *timer = timerHardware->tim; // "timer" is confusing; "tim"? const IO_t motorIO = IOGetByTag(timerHardware->tag); + uint8_t pupMode = (output & TIMER_OUTPUT_INVERTED) ? GPIO_PULLDOWN : GPIO_PULLUP; +#ifdef USE_DSHOT_TELEMETRY + if (useDshotTelemetry) { + output ^= TIMER_OUTPUT_INVERTED; + } +#endif + motor->iocfg = IO_CONFIG(GPIO_MODE_AF_PP, GPIO_SPEED_FREQ_VERY_HIGH, pupMode); const uint8_t timerIndex = getTimerIndex(timer); const bool configureTimer = (timerIndex == dmaMotorTimerCount - 1); IOInit(motorIO, OWNER_MOTOR, RESOURCE_INDEX(motorIndex)); - IOConfigGPIOAF(motorIO, IO_CONFIG(GPIO_MODE_AF_PP, GPIO_SPEED_FREQ_VERY_HIGH, GPIO_PULLDOWN), timerHardware->alternateFunction); + IOConfigGPIOAF(motorIO, motor->iocfg, timerHardware->alternateFunction); // Configure time base