mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Added PG config definitions 4
This commit is contained in:
parent
fd1d8d532e
commit
c92679f454
10 changed files with 110 additions and 13 deletions
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "drivers/system.h"
|
||||
#include "drivers/pwm_output.h"
|
||||
#include "drivers/pwm_esc_detect.h"
|
||||
|
||||
#include "io/motors.h"
|
||||
|
||||
|
@ -69,6 +70,43 @@ PG_RESET_TEMPLATE(mixerConfig_t, mixerConfig,
|
|||
.yaw_motor_direction = 1,
|
||||
);
|
||||
|
||||
PG_REGISTER_WITH_RESET_FN(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 0);
|
||||
|
||||
void pgResetFn_motorConfig(motorConfig_t *motorConfig)
|
||||
{
|
||||
#ifdef BRUSHED_MOTORS
|
||||
motorConfig->minthrottle = 1000;
|
||||
motorConfig->dev.motorPwmRate = BRUSHED_MOTORS_PWM_RATE;
|
||||
motorConfig->dev.motorPwmProtocol = PWM_TYPE_BRUSHED;
|
||||
motorConfig->dev.useUnsyncedPwm = true;
|
||||
#else
|
||||
#ifdef BRUSHED_ESC_AUTODETECT
|
||||
if (hardwareMotorType == MOTOR_BRUSHED) {
|
||||
motorConfig->minthrottle = 1000;
|
||||
motorConfig->dev.motorPwmRate = BRUSHED_MOTORS_PWM_RATE;
|
||||
motorConfig->dev.motorPwmProtocol = PWM_TYPE_BRUSHED;
|
||||
motorConfig->dev.useUnsyncedPwm = true;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
motorConfig->minthrottle = 1070;
|
||||
motorConfig->dev.motorPwmRate = BRUSHLESS_MOTORS_PWM_RATE;
|
||||
motorConfig->dev.motorPwmProtocol = PWM_TYPE_ONESHOT125;
|
||||
}
|
||||
#endif
|
||||
motorConfig->maxthrottle = 2000;
|
||||
motorConfig->mincommand = 1000;
|
||||
motorConfig->digitalIdleOffsetPercent = 4.5f;
|
||||
|
||||
int motorIndex = 0;
|
||||
for (int i = 0; i < USABLE_TIMER_CHANNEL_COUNT && motorIndex < MAX_SUPPORTED_MOTORS; i++) {
|
||||
if (timerHardware[i].usageFlags & TIM_USE_MOTOR) {
|
||||
motorConfig->dev.ioTags[motorIndex] = timerHardware[i].tag;
|
||||
motorIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define EXTERNAL_DSHOT_CONVERSION_FACTOR 2
|
||||
// (minimum output value(1001) - (minimum input value(48) / conversion factor(2))
|
||||
#define EXTERNAL_DSHOT_CONVERSION_OFFSET 977
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue