From ef8f3d544096eb365ba52a425e0aaedcbbd9e27f Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Sun, 3 Jan 2021 21:22:47 +0800 Subject: [PATCH] Revert #10383: 'Optimize pin reconfiguration in DSHOT ISR for H7' in maintenance branch. --- src/main/drivers/io.h | 3 --- src/main/drivers/pwm_output_dshot_hal.c | 15 ++------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/main/drivers/io.h b/src/main/drivers/io.h index 0bddea227..9c20347a1 100644 --- a/src/main/drivers/io.h +++ b/src/main/drivers/io.h @@ -131,6 +131,3 @@ void IOInitGlobal(void); typedef void (*IOTraverseFuncPtr_t)(IO_t io); void IOTraversePins(IOTraverseFuncPtr_t func); - -GPIO_TypeDef* IO_GPIO(IO_t io); -uint16_t IO_Pin(IO_t io); diff --git a/src/main/drivers/pwm_output_dshot_hal.c b/src/main/drivers/pwm_output_dshot_hal.c index 25d9faa84..d111266ac 100644 --- a/src/main/drivers/pwm_output_dshot_hal.c +++ b/src/main/drivers/pwm_output_dshot_hal.c @@ -117,24 +117,13 @@ FAST_CODE static void pwmDshotSetDirectionInput( timer->ARR = 0xffffffff; #ifdef STM32H7 - // Configure pin as GPIO output to avoid glitch during timer configuration - uint32_t pin = IO_Pin(motor->io); - LL_GPIO_SetPinMode(IO_GPIO(motor->io), pin, LL_GPIO_MODE_OUTPUT); - LL_GPIO_SetPinSpeed(IO_GPIO(motor->io), pin, LL_GPIO_SPEED_FREQ_LOW); // Needs to be low - LL_GPIO_SetPinPull(IO_GPIO(motor->io), pin, LL_GPIO_PULL_NO); - LL_GPIO_SetPinOutputType(IO_GPIO(motor->io), pin, LL_GPIO_OUTPUT_PUSHPULL); + IOConfigGPIO(motor->io, GPIO_MODE_OUTPUT_PP); #endif LL_TIM_IC_Init(timer, motor->llChannel, &motor->icInitStruct); #ifdef STM32H7 - // Configure pin back to timer - LL_GPIO_SetPinMode(IO_GPIO(motor->io), IO_Pin(motor->io), LL_GPIO_MODE_ALTERNATE); - if (IO_Pin(motor->io) & 0xFF) { - LL_GPIO_SetAFPin_0_7(IO_GPIO(motor->io), IO_Pin(motor->io), timerHardware->alternateFunction); - } else { - LL_GPIO_SetAFPin_8_15(IO_GPIO(motor->io), IO_Pin(motor->io), timerHardware->alternateFunction); - } + IOConfigGPIOAF(motor->io, motor->iocfg, timerHardware->alternateFunction); #endif motor->dmaInitStruct.Direction = LL_DMA_DIRECTION_PERIPH_TO_MEMORY; -- 2.11.4.GIT