mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 09:16:07 +03:00
Improvements and order by ascending as requested
This commit is contained in:
parent
81da3040a2
commit
9c9a3fe909
6 changed files with 29 additions and 74 deletions
|
@ -139,21 +139,8 @@ void pwmDigitalMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t
|
|||
if (configureTimer) {
|
||||
RCC_ClockCmd(timerRCC(timer), ENABLE);
|
||||
|
||||
uint32_t hz;
|
||||
switch (pwmProtocolType) {
|
||||
case(PWM_TYPE_DSHOT600):
|
||||
hz = MOTOR_DSHOT600_MHZ * 1000000;
|
||||
break;
|
||||
case(PWM_TYPE_DSHOT300):
|
||||
hz = MOTOR_DSHOT300_MHZ * 1000000;
|
||||
break;
|
||||
default:
|
||||
case(PWM_TYPE_DSHOT150):
|
||||
hz = MOTOR_DSHOT150_MHZ * 1000000;
|
||||
}
|
||||
|
||||
motor->TimHandle.Instance = timerHardware->tim;
|
||||
motor->TimHandle.Init.Prescaler = (SystemCoreClock / timerClockDivisor(timer) / hz) - 1;;
|
||||
motor->TimHandle.Init.Prescaler = (SystemCoreClock / timerClockDivisor(timer) / getDshotHz(pwmProtocolType)) - 1;;
|
||||
motor->TimHandle.Init.Period = MOTOR_BITLENGTH;
|
||||
motor->TimHandle.Init.RepetitionCounter = 0;
|
||||
motor->TimHandle.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
|
@ -170,21 +157,7 @@ void pwmDigitalMotorHardwareConfig(const timerHardware_t *timerHardware, uint8_t
|
|||
motor->TimHandle = dmaMotors[timerIndex].TimHandle;
|
||||
}
|
||||
|
||||
switch (timerHardware->channel) {
|
||||
case TIM_CHANNEL_1:
|
||||
motor->timerDmaSource = TIM_DMA_ID_CC1;
|
||||
break;
|
||||
case TIM_CHANNEL_2:
|
||||
motor->timerDmaSource = TIM_DMA_ID_CC2;
|
||||
break;
|
||||
case TIM_CHANNEL_3:
|
||||
motor->timerDmaSource = TIM_DMA_ID_CC3;
|
||||
break;
|
||||
case TIM_CHANNEL_4:
|
||||
motor->timerDmaSource = TIM_DMA_ID_CC4;
|
||||
break;
|
||||
}
|
||||
|
||||
motor->timerDmaSource = timerDmaSource(timerHardware->channel);
|
||||
dmaMotorTimers[timerIndex].timerDmaSources |= motor->timerDmaSource;
|
||||
|
||||
/* Set the parameters to be configured */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue