mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-26 01:35:35 +03:00
Refactor PWM rate and make it configurable only for brushed protocols
This commit is contained in:
parent
3914c4f02e
commit
283ebd22c7
7 changed files with 43 additions and 44 deletions
|
@ -237,40 +237,8 @@ void validateAndFixConfig(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef BRUSHED_MOTORS
|
||||
motorConfigMutable()->motorPwmRate = constrain(motorConfig()->motorPwmRate, 500, 32000);
|
||||
#else
|
||||
switch (motorConfig()->motorPwmProtocol) {
|
||||
default:
|
||||
case PWM_TYPE_STANDARD: // Limited to 490 Hz
|
||||
motorConfigMutable()->motorPwmRate = MIN(motorConfig()->motorPwmRate, 490);
|
||||
break;
|
||||
case PWM_TYPE_ONESHOT125: // Limited to 3900 Hz
|
||||
motorConfigMutable()->motorPwmRate = MIN(motorConfig()->motorPwmRate, 3900);
|
||||
break;
|
||||
case PWM_TYPE_MULTISHOT: // 2-16 kHz
|
||||
motorConfigMutable()->motorPwmRate = constrain(motorConfig()->motorPwmRate, 2000, 16000);
|
||||
break;
|
||||
case PWM_TYPE_BRUSHED: // 500Hz - 32kHz
|
||||
motorConfigMutable()->motorPwmRate = constrain(motorConfig()->motorPwmRate, 500, 32000);
|
||||
break;
|
||||
#ifdef USE_DSHOT
|
||||
// One DSHOT packet takes 16 bits x 19 ticks + 2uS = 304 timer ticks + 2uS
|
||||
case PWM_TYPE_DSHOT150:
|
||||
motorConfigMutable()->motorPwmRate = MIN(motorConfig()->motorPwmRate, 4000);
|
||||
break;
|
||||
case PWM_TYPE_DSHOT300:
|
||||
motorConfigMutable()->motorPwmRate = MIN(motorConfig()->motorPwmRate, 8000);
|
||||
break;
|
||||
// Although DSHOT 600+ support >16kHz update rate it's not practical because of increased CPU load
|
||||
// It's more reasonable to use slower-speed DSHOT at higher rate for better reliability
|
||||
case PWM_TYPE_DSHOT600:
|
||||
motorConfigMutable()->motorPwmRate = MIN(motorConfig()->motorPwmRate, 16000);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Call target-specific validation function
|
||||
validateAndFixTargetConfig();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue