mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 21:35:44 +03:00
Merge pull request #3938 from mikeller/fix_dshot_command_all_motors
Enable only DMA for channels that are used.
This commit is contained in:
commit
624e9b64b5
4 changed files with 6 additions and 4 deletions
|
@ -397,9 +397,6 @@ void pwmWriteDshotCommand(uint8_t index, uint8_t motorCount, uint8_t command)
|
|||
motorDmaOutput_t *const motor = getMotorDmaOutput(i);
|
||||
motor->requestTelemetry = true;
|
||||
pwmWriteDshotInt(i, command);
|
||||
} else {
|
||||
// Needed to avoid DMA errors
|
||||
pwmWriteDshotInt(i, DSHOT_CMD_MOTOR_STOP);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -115,6 +115,7 @@ typedef struct {
|
|||
const timerHardware_t *timerHardware;
|
||||
uint16_t value;
|
||||
uint16_t timerDmaSource;
|
||||
motorDmaTimer_t *timer;
|
||||
volatile bool requestTelemetry;
|
||||
#if defined(STM32F3) || defined(STM32F4) || defined(STM32F7)
|
||||
uint32_t dmaBuffer[DSHOT_DMA_BUFFER_SIZE];
|
||||
|
|
|
@ -66,6 +66,7 @@ void pwmWriteDshotInt(uint8_t index, uint16_t value)
|
|||
|
||||
uint8_t bufferSize = loadDmaBuffer(motor, packet);
|
||||
|
||||
motor->timer->timerDmaSources |= motor->timerDmaSource;
|
||||
DMA_SetCurrDataCounter(motor->timerHardware->dmaRef, bufferSize);
|
||||
DMA_Cmd(motor->timerHardware->dmaRef, ENABLE);
|
||||
}
|
||||
|
@ -77,6 +78,7 @@ void pwmCompleteDshotMotorUpdate(uint8_t motorCount)
|
|||
for (int i = 0; i < dmaMotorTimerCount; i++) {
|
||||
TIM_SetCounter(dmaMotorTimers[i].timer, 0);
|
||||
TIM_DMACmd(dmaMotorTimers[i].timer, dmaMotorTimers[i].timerDmaSources, ENABLE);
|
||||
dmaMotorTimers[i].timerDmaSources = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -138,7 +140,8 @@ void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m
|
|||
timerOCInit(timer, timerHardware->channel, &TIM_OCInitStructure);
|
||||
timerOCPreloadConfig(timer, timerHardware->channel, TIM_OCPreload_Enable);
|
||||
motor->timerDmaSource = timerDmaSource(timerHardware->channel);
|
||||
dmaMotorTimers[timerIndex].timerDmaSources |= motor->timerDmaSource;
|
||||
motor->timer = &dmaMotorTimers[timerIndex];
|
||||
motor->timer->timerDmaSources &= ~motor->timerDmaSource;
|
||||
|
||||
TIM_CCxCmd(timer, timerHardware->channel, TIM_CCx_Enable);
|
||||
|
||||
|
|
|
@ -120,6 +120,7 @@ void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m
|
|||
}
|
||||
|
||||
motor->timerDmaSource = timerDmaSource(timerHardware->channel);
|
||||
motor->timer = &dmaMotorTimers[timerIndex];
|
||||
dmaMotorTimers[timerIndex].timerDmaSources |= motor->timerDmaSource;
|
||||
|
||||
/* Set the parameters to be configured */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue