From adee15a8064156f71e33719d198a97abe9ed68c0 Mon Sep 17 00:00:00 2001 From: jflyper Date: Fri, 30 Jun 2017 08:51:06 +0900 Subject: [PATCH] Allow gyro-less booting --- src/main/fc/cli.c | 2 +- src/main/fc/fc_init.c | 4 ++-- src/main/fc/fc_tasks.c | 7 +++++-- src/main/fc/runtime_config.c | 5 +++++ src/main/fc/runtime_config.h | 2 ++ 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c index ea06814106..8c67fb9367 100755 --- a/src/main/fc/cli.c +++ b/src/main/fc/cli.c @@ -2711,7 +2711,7 @@ static void cliStatus(char *cmdline) const int systemRate = getTaskDeltaTime(TASK_SYSTEM) == 0 ? 0 : (int)(1000000.0f / ((float)getTaskDeltaTime(TASK_SYSTEM))); cliPrintLinef("CPU:%d%%, cycle time: %d, GYRO rate: %d, RX rate: %d, System rate: %d", constrain(averageSystemLoadPercent, 0, 100), getTaskDeltaTime(TASK_GYROPID), gyroRate, rxRate, systemRate); - + cliPrintLinef("Arming disable flags: 0x%x", getArmingDisableFlags() & ~ARMING_DISABLED_CLI); } #ifndef SKIP_TASK_STATISTICS diff --git a/src/main/fc/fc_init.c b/src/main/fc/fc_init.c index 780ba0e413..06e74a50be 100644 --- a/src/main/fc/fc_init.c +++ b/src/main/fc/fc_init.c @@ -478,8 +478,8 @@ void init(void) initBoardAlignment(boardAlignment()); if (!sensorsAutodetect()) { - // if gyro was not detected due to whatever reason, we give up now. - failureMode(FAILURE_MISSING_ACC); + // if gyro was not detected due to whatever reason, don't arm. + setArmingDisabled(ARMING_DISABLED_NO_GYRO); } systemState |= SYSTEM_STATE_SENSORS_READY; diff --git a/src/main/fc/fc_tasks.c b/src/main/fc/fc_tasks.c index 209a746650..5e1bb3b3b7 100644 --- a/src/main/fc/fc_tasks.c +++ b/src/main/fc/fc_tasks.c @@ -259,8 +259,11 @@ void osdSlaveTasksInit(void) void fcTasksInit(void) { schedulerInit(); - rescheduleTask(TASK_GYROPID, gyro.targetLooptime); - setTaskEnabled(TASK_GYROPID, true); + + if (sensors(SENSOR_GYRO)) { + rescheduleTask(TASK_GYROPID, gyro.targetLooptime); + setTaskEnabled(TASK_GYROPID, true); + } if (sensors(SENSOR_ACC)) { setTaskEnabled(TASK_ACCEL, true); diff --git a/src/main/fc/runtime_config.c b/src/main/fc/runtime_config.c index 40a92eb034..17bd29105b 100644 --- a/src/main/fc/runtime_config.c +++ b/src/main/fc/runtime_config.c @@ -46,6 +46,11 @@ bool isArmingDisabled() return armingDisableFlags; } +armingDisableFlags_e getArmingDisableFlags(void) +{ + return armingDisableFlags; +} + /** * Enables the given flight mode. A beep is sounded if the flight mode * has changed. Returns the new 'flightModeFlags' value. diff --git a/src/main/fc/runtime_config.h b/src/main/fc/runtime_config.h index ffa3604ffd..de2623a315 100644 --- a/src/main/fc/runtime_config.h +++ b/src/main/fc/runtime_config.h @@ -40,11 +40,13 @@ typedef enum { ARMING_DISABLED_CMS_MENU = (1 << 7), ARMING_DISABLED_OSD_MENU = (1 << 8), ARMING_DISABLED_BST = (1 << 9), + ARMING_DISABLED_NO_GYRO = (1 << 10), } armingDisableFlags_e; void setArmingDisabled(armingDisableFlags_e flag); void unsetArmingDisabled(armingDisableFlags_e flag); bool isArmingDisabled(void); +armingDisableFlags_e getArmingDisableFlags(void); typedef enum { ANGLE_MODE = (1 << 0),