mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 22:35:23 +03:00
Add comment about duplicate initialization of timers and DMAs
This commit is contained in:
parent
6efe34d4da
commit
825bc7aaba
2 changed files with 8 additions and 0 deletions
|
@ -144,6 +144,10 @@ void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m
|
||||||
TIM_TypeDef *timer = timerHardware->tim;
|
TIM_TypeDef *timer = timerHardware->tim;
|
||||||
const IO_t motorIO = IOGetByTag(timerHardware->tag);
|
const IO_t motorIO = IOGetByTag(timerHardware->tag);
|
||||||
|
|
||||||
|
// Boolean configureTimer is always true when different channels of the same timer are processed in sequence,
|
||||||
|
// causing the timer and the associated DMA initialized more than once.
|
||||||
|
// To fix this, getTimerIndex must be expanded to return if a new timer has been requested.
|
||||||
|
// However, since the initialization is idempotent, it is left as is in a favor of flash space (for now).
|
||||||
const uint8_t timerIndex = getTimerIndex(timer);
|
const uint8_t timerIndex = getTimerIndex(timer);
|
||||||
const bool configureTimer = (timerIndex == dmaMotorTimerCount-1);
|
const bool configureTimer = (timerIndex == dmaMotorTimerCount-1);
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,10 @@ void pwmDshotMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t m
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note that a timer and an associated DMA are initialized more than once.
|
||||||
|
// To fix it, getTimerIndex must be expanded to return if a new timer has been requested.
|
||||||
|
// However, since the initialization is idempotent, it is left as is in a favor of flash space (for now).
|
||||||
|
|
||||||
motor->timer = &dmaMotorTimers[getTimerIndex(timer)];
|
motor->timer = &dmaMotorTimers[getTimerIndex(timer)];
|
||||||
|
|
||||||
/* Set the common dma handle parameters to be configured */
|
/* Set the common dma handle parameters to be configured */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue