mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 19:40:31 +03:00
Fix dshot bidir on H7
This commit is contained in:
parent
08e8afa090
commit
6b0bca4ef5
2 changed files with 21 additions and 0 deletions
|
@ -116,6 +116,7 @@ typedef struct motorDmaOutput_s {
|
||||||
#ifdef STM32H7
|
#ifdef STM32H7
|
||||||
TIM_HandleTypeDef TimHandle;
|
TIM_HandleTypeDef TimHandle;
|
||||||
DMA_HandleTypeDef hdma_tim;
|
DMA_HandleTypeDef hdma_tim;
|
||||||
|
IO_t io;
|
||||||
#endif
|
#endif
|
||||||
uint8_t output;
|
uint8_t output;
|
||||||
uint8_t index;
|
uint8_t index;
|
||||||
|
|
|
@ -115,7 +115,17 @@ static void pwmDshotSetDirectionInput(
|
||||||
}
|
}
|
||||||
LL_TIM_EnableARRPreload(timer); // Only update the period once all channels are done
|
LL_TIM_EnableARRPreload(timer); // Only update the period once all channels are done
|
||||||
timer->ARR = 0xffffffff;
|
timer->ARR = 0xffffffff;
|
||||||
|
|
||||||
|
#ifdef STM32H7
|
||||||
|
IOConfigGPIO(motor->io, GPIO_MODE_OUTPUT_PP);
|
||||||
|
#endif
|
||||||
|
|
||||||
LL_TIM_IC_Init(timer, motor->llChannel, &motor->icInitStruct);
|
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;
|
motor->dmaInitStruct.Direction = LL_DMA_DIRECTION_PERIPH_TO_MEMORY;
|
||||||
xLL_EX_DMA_Init(motor->dmaRef, pDmaInit);
|
xLL_EX_DMA_Init(motor->dmaRef, pDmaInit);
|
||||||
}
|
}
|
||||||
|
@ -240,11 +250,21 @@ bool pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m
|
||||||
#ifdef USE_DSHOT_TELEMETRY
|
#ifdef USE_DSHOT_TELEMETRY
|
||||||
if (useDshotTelemetry) {
|
if (useDshotTelemetry) {
|
||||||
output ^= TIMER_OUTPUT_INVERTED;
|
output ^= TIMER_OUTPUT_INVERTED;
|
||||||
|
#ifdef STM32H7
|
||||||
|
if (output & TIMER_OUTPUT_INVERTED) {
|
||||||
|
IOHi(motorIO);
|
||||||
|
} else {
|
||||||
|
IOLo(motorIO);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
motor->timerHardware = timerHardware;
|
motor->timerHardware = timerHardware;
|
||||||
|
|
||||||
motor->iocfg = IO_CONFIG(GPIO_MODE_AF_PP, GPIO_SPEED_FREQ_VERY_HIGH, pupMode);
|
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);
|
IOConfigGPIOAF(motorIO, motor->iocfg, timerHardware->alternateFunction);
|
||||||
|
|
||||||
if (configureTimer) {
|
if (configureTimer) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue