mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 05:15:25 +03:00
Improved initialisation order. Stopped calling pidInit before gyro detected (#4218)
This commit is contained in:
parent
ac1cc31ae5
commit
db8698d801
3 changed files with 70 additions and 60 deletions
|
@ -376,32 +376,6 @@ void init(void)
|
|||
serialInit(feature(FEATURE_SOFTSERIAL), SERIAL_PORT_NONE);
|
||||
#endif
|
||||
|
||||
mixerInit(mixerConfig()->mixerMode);
|
||||
#ifdef USE_SERVOS
|
||||
servosInit();
|
||||
#endif
|
||||
|
||||
uint16_t idlePulse = motorConfig()->mincommand;
|
||||
if (feature(FEATURE_3D)) {
|
||||
idlePulse = flight3DConfig()->neutral3d;
|
||||
}
|
||||
|
||||
if (motorConfig()->dev.motorPwmProtocol == PWM_TYPE_BRUSHED) {
|
||||
featureClear(FEATURE_3D);
|
||||
idlePulse = 0; // brushed motors
|
||||
}
|
||||
|
||||
mixerConfigureOutput();
|
||||
motorDevInit(&motorConfig()->dev, idlePulse, getMotorCount());
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
servoConfigureOutput();
|
||||
if (isMixerUsingServos()) {
|
||||
//pwm_params.useChannelForwarding = feature(FEATURE_CHANNEL_FORWARDING);
|
||||
servoDevInit(&servoConfig()->dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (0) {}
|
||||
#if defined(USE_PPM)
|
||||
else if (feature(FEATURE_RX_PPM)) {
|
||||
|
@ -414,8 +388,6 @@ void init(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
systemState |= SYSTEM_STATE_MOTORS_READY;
|
||||
|
||||
#ifdef BEEPER
|
||||
beeperInit(beeperDevConfig());
|
||||
#endif
|
||||
|
@ -528,10 +500,33 @@ void init(void)
|
|||
LED0_OFF;
|
||||
LED1_OFF;
|
||||
|
||||
// gyro.targetLooptime set in sensorsAutodetect(), so we are ready to call pidInit()
|
||||
// gyro.targetLooptime set in sensorsAutodetect(),
|
||||
// so we are ready to call validateAndFixGyroConfig(), pidInit(), and setAccelerationFilter()
|
||||
validateAndFixGyroConfig();
|
||||
pidInit(currentPidProfile);
|
||||
setAccelerationFilter(accelerometerConfig()->acc_lpf_hz);
|
||||
|
||||
mixerInit(mixerConfig()->mixerMode);
|
||||
|
||||
uint16_t idlePulse = motorConfig()->mincommand;
|
||||
if (feature(FEATURE_3D)) {
|
||||
idlePulse = flight3DConfig()->neutral3d;
|
||||
}
|
||||
if (motorConfig()->dev.motorPwmProtocol == PWM_TYPE_BRUSHED) {
|
||||
featureClear(FEATURE_3D);
|
||||
idlePulse = 0; // brushed motors
|
||||
}
|
||||
mixerConfigureOutput();
|
||||
motorDevInit(&motorConfig()->dev, idlePulse, getMotorCount());
|
||||
systemState |= SYSTEM_STATE_MOTORS_READY;
|
||||
|
||||
#ifdef USE_SERVOS
|
||||
servosInit();
|
||||
servoConfigureOutput();
|
||||
if (isMixerUsingServos()) {
|
||||
//pwm_params.useChannelForwarding = feature(FEATURE_CHANNEL_FORWARDING);
|
||||
servoDevInit(&servoConfig()->dev);
|
||||
}
|
||||
servosFilterInit();
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue