mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 21:35:44 +03:00
rearranged startup / sensor detection for production testing. moved dead gyro endless loop out of the way.
This commit is contained in:
parent
2d248676f5
commit
c1fcdabdc1
3 changed files with 29 additions and 20 deletions
38
src/main.c
38
src/main.c
|
@ -32,6 +32,7 @@ int main(void)
|
|||
uint8_t i;
|
||||
drv_pwm_config_t pwm_params;
|
||||
drv_adc_config_t adc_params;
|
||||
bool sensorsOK = false;
|
||||
#ifdef SOFTSERIAL_LOOPBACK
|
||||
serialPort_t* loopbackPort1 = NULL;
|
||||
serialPort_t* loopbackPort2 = NULL;
|
||||
|
@ -63,15 +64,33 @@ int main(void)
|
|||
// We have these sensors; SENSORS_SET defined in board.h depending on hardware platform
|
||||
sensorsSet(SENSORS_SET);
|
||||
// drop out any sensors that don't seem to work, init all the others. halt if gyro is dead.
|
||||
sensorsAutodetect();
|
||||
imuInit(); // Mag is initialized inside imuInit
|
||||
mixerInit(); // this will set core.useServo var depending on mixer type
|
||||
sensorsOK = sensorsAutodetect();
|
||||
|
||||
// production debug output
|
||||
#ifdef PROD_DEBUG
|
||||
productionDebug();
|
||||
#endif
|
||||
|
||||
// if gyro was not detected due to whatever reason, we give up now.
|
||||
if (!sensorsOK)
|
||||
failureMode(3);
|
||||
|
||||
LED1_ON;
|
||||
LED0_OFF;
|
||||
for (i = 0; i < 10; i++) {
|
||||
LED1_TOGGLE;
|
||||
LED0_TOGGLE;
|
||||
delay(25);
|
||||
BEEP_ON;
|
||||
delay(25);
|
||||
BEEP_OFF;
|
||||
}
|
||||
LED0_OFF;
|
||||
LED1_OFF;
|
||||
|
||||
imuInit(); // Mag is initialized inside imuInit
|
||||
mixerInit(); // this will set core.useServo var depending on mixer type
|
||||
|
||||
serialInit(mcfg.serial_baudrate);
|
||||
|
||||
// when using airplane/wing mixer, servo/motor outputs are remapped
|
||||
|
@ -169,19 +188,6 @@ int main(void)
|
|||
calibratingB = CALIBRATING_BARO_CYCLES; // 10 seconds init_delay + 200 * 25 ms = 15 seconds before ground pressure settles
|
||||
f.SMALL_ANGLE = 1;
|
||||
|
||||
LED1_ON;
|
||||
LED0_OFF;
|
||||
for (i = 0; i < 10; i++) {
|
||||
LED1_TOGGLE;
|
||||
LED0_TOGGLE;
|
||||
delay(25);
|
||||
BEEP_ON;
|
||||
delay(25);
|
||||
BEEP_OFF;
|
||||
}
|
||||
LED0_OFF;
|
||||
LED1_OFF;
|
||||
|
||||
// loopy
|
||||
while (1) {
|
||||
loop();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue