1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 03:20:00 +03:00

H7 - Fix bi-directional DSHOT (#8961)

H7 - Fix bi-directional DSHOT
This commit is contained in:
Michael Keller 2019-09-29 10:24:54 +13:00 committed by GitHub
commit 13f95df078
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View file

@ -116,6 +116,7 @@ typedef struct motorDmaOutput_s {
#ifdef STM32H7
TIM_HandleTypeDef TimHandle;
DMA_HandleTypeDef hdma_tim;
IO_t io;
#endif
uint8_t output;
uint8_t index;

View file

@ -115,7 +115,17 @@ static void pwmDshotSetDirectionInput(
}
LL_TIM_EnableARRPreload(timer); // Only update the period once all channels are done
timer->ARR = 0xffffffff;
#ifdef STM32H7
IOConfigGPIO(motor->io, GPIO_MODE_OUTPUT_PP);
#endif
LL_TIM_IC_Init(timer, motor->llChannel, &motor->icInitStruct);
#ifdef STM32H7
IOConfigGPIOAF(motor->io, motor->iocfg, timerHardware->alternateFunction);
#endif
motor->dmaInitStruct.Direction = LL_DMA_DIRECTION_PERIPH_TO_MEMORY;
xLL_EX_DMA_Init(motor->dmaRef, pDmaInit);
}
@ -240,11 +250,21 @@ bool pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m
#ifdef USE_DSHOT_TELEMETRY
if (useDshotTelemetry) {
output ^= TIMER_OUTPUT_INVERTED;
#ifdef STM32H7
if (output & TIMER_OUTPUT_INVERTED) {
IOHi(motorIO);
} else {
IOLo(motorIO);
}
#endif
}
#endif
motor->timerHardware = timerHardware;
motor->iocfg = IO_CONFIG(GPIO_MODE_AF_PP, GPIO_SPEED_FREQ_VERY_HIGH, pupMode);
#ifdef STM32H7
motor->io = motorIO;
#endif
IOConfigGPIOAF(motorIO, motor->iocfg, timerHardware->alternateFunction);
if (configureTimer) {