From d0a9d14b87d1600ec5427ccc7740454300aa4fe0 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Tue, 19 May 2015 23:42:41 +0100 Subject: [PATCH] Allow CLI to be compiled out. First cut, as proof-of-concept. This allows CJMCU target to be built without CLI and with Blackbox. --- src/main/io/serial.c | 9 ++++++++- src/main/io/serial_cli.c | 10 +++++++--- src/main/main.c | 3 +++ src/main/target/ALIENWIIF3/target.h | 2 +- src/main/target/CC3D/target.h | 1 + src/main/target/CHEBUZZF3/target.h | 1 + src/main/target/CJMCU/target.h | 5 +++++ src/main/target/EUSTM32F103RC/target.h | 1 + src/main/target/NAZE/target.h | 1 + src/main/target/NAZE32PRO/target.h | 1 + src/main/target/OLIMEXINO/target.h | 1 + src/main/target/PORT103R/target.h | 1 + src/main/target/SPARKY/target.h | 3 ++- src/main/target/SPRACINGF3/target.h | 1 + src/main/target/STM32F3DISCOVERY/target.h | 1 + 15 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/main/io/serial.c b/src/main/io/serial.c index d382f48c72..3b4c59f1d8 100644 --- a/src/main/io/serial.c +++ b/src/main/io/serial.c @@ -346,11 +346,13 @@ void serialInit(serialConfig_t *initialSerialConfig, bool softserialEnabled) void handleSerial(void) { +#ifdef USE_CLI // in cli mode, all serial stuff goes to here. enter cli mode by sending # if (cliMode) { cliProcess(); return; } +#endif mspProcess(); } @@ -366,9 +368,14 @@ void cliEnter(serialPort_t *serialPort); void evaluateOtherData(serialPort_t *serialPort, uint8_t receivedChar) { +#ifndef USE_CLI + UNUSED(serialPort); +#else if (receivedChar == '#') { cliEnter(serialPort); - } else if (receivedChar == serialConfig->reboot_character) { + } +#endif + if (receivedChar == serialConfig->reboot_character) { systemResetToBootloader(); } } diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index 51c279f5d1..6d04cade01 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -84,6 +84,12 @@ #include "serial_cli.h" +// FIXME remove this for targets that don't need a CLI. Perhaps use a no-op macro when USE_CLI is not enabled +// signal that we're in cli mode +uint8_t cliMode = 0; + +#ifdef USE_CLI + extern uint16_t cycleTime; // FIXME dependency on mw.c void gpsEnablePassthrough(serialPort_t *gpsPassthroughPort); @@ -132,9 +138,6 @@ static void cliFlashWrite(char *cmdline); static void cliFlashRead(char *cmdline); #endif -// signal that we're in cli mode -uint8_t cliMode = 0; - // buffer static char cliBuffer[48]; static uint32_t bufferIndex = 0; @@ -1767,3 +1770,4 @@ void cliInit(serialConfig_t *serialConfig) { UNUSED(serialConfig); } +#endif diff --git a/src/main/main.c b/src/main/main.c index 1af10189bc..d45466e3af 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -347,7 +347,10 @@ void init(void) imuInit(); mspInit(&masterConfig.serialConfig); + +#ifdef USE_CLI cliInit(&masterConfig.serialConfig); +#endif failsafeInit(&masterConfig.rxConfig); diff --git a/src/main/target/ALIENWIIF3/target.h b/src/main/target/ALIENWIIF3/target.h index 20528062ae..70b3367ee2 100644 --- a/src/main/target/ALIENWIIF3/target.h +++ b/src/main/target/ALIENWIIF3/target.h @@ -116,7 +116,7 @@ //#define DISPLAY #define AUTOTUNE #define USE_SERVOS - +#define USE_CLI #define SPEKTRUM_BIND // USART2, PA3 diff --git a/src/main/target/CC3D/target.h b/src/main/target/CC3D/target.h index b7a6c82249..22db9a574c 100644 --- a/src/main/target/CC3D/target.h +++ b/src/main/target/CC3D/target.h @@ -113,6 +113,7 @@ #define SERIAL_RX #define AUTOTUNE #define USE_SERVOS +#define USE_CLI #if defined(OPBL) #undef AUTOTUNE // disabled for OPBL build due to code size. diff --git a/src/main/target/CHEBUZZF3/target.h b/src/main/target/CHEBUZZF3/target.h index 4739829eaa..8bca64d8d2 100644 --- a/src/main/target/CHEBUZZF3/target.h +++ b/src/main/target/CHEBUZZF3/target.h @@ -123,3 +123,4 @@ #define SERIAL_RX #define AUTOTUNE #define USE_SERVOS +#define USE_CLI diff --git a/src/main/target/CJMCU/target.h b/src/main/target/CJMCU/target.h index f923b7cb6b..20e1bcc58d 100644 --- a/src/main/target/CJMCU/target.h +++ b/src/main/target/CJMCU/target.h @@ -59,6 +59,7 @@ #define SERIAL_RX //#define USE_SERVOS +#define USE_CLI #define SPEKTRUM_BIND // USART2, PA3 @@ -68,6 +69,10 @@ // Since the CJMCU PCB has holes for 4 motors in each corner we can save same flash space by disabling support for other mixers. #define USE_QUAD_MIXER_ONLY + #if (FLASH_SIZE > 64) #define BLACKBOX #endif + +//#undef USE_CLI +//#define BLACKBOX diff --git a/src/main/target/EUSTM32F103RC/target.h b/src/main/target/EUSTM32F103RC/target.h index 05b304ccd2..8a873282ec 100644 --- a/src/main/target/EUSTM32F103RC/target.h +++ b/src/main/target/EUSTM32F103RC/target.h @@ -125,6 +125,7 @@ #define SERIAL_RX #define AUTOTUNE #define USE_SERVOS +#define USE_CLI #define SPEKTRUM_BIND // USART2, PA3 diff --git a/src/main/target/NAZE/target.h b/src/main/target/NAZE/target.h index 20a4644166..a2ab1450ba 100644 --- a/src/main/target/NAZE/target.h +++ b/src/main/target/NAZE/target.h @@ -165,6 +165,7 @@ #define SERIAL_RX #define AUTOTUNE #define USE_SERVOS +#define USE_CLI #define SPEKTRUM_BIND // USART2, PA3 diff --git a/src/main/target/NAZE32PRO/target.h b/src/main/target/NAZE32PRO/target.h index da072a3bdb..6b35128d32 100644 --- a/src/main/target/NAZE32PRO/target.h +++ b/src/main/target/NAZE32PRO/target.h @@ -46,6 +46,7 @@ #define SERIAL_RX #define AUTOTUNE #define USE_SERVOS +#define USE_CLI #define SPEKTRUM_BIND // USART2, PA3 diff --git a/src/main/target/OLIMEXINO/target.h b/src/main/target/OLIMEXINO/target.h index 963de3c1a9..3a2adb0c70 100644 --- a/src/main/target/OLIMEXINO/target.h +++ b/src/main/target/OLIMEXINO/target.h @@ -112,3 +112,4 @@ #define AUTOTUNE #define BLACKBOX #define USE_SERVOS +#define USE_CLI diff --git a/src/main/target/PORT103R/target.h b/src/main/target/PORT103R/target.h index 1ba71e90fd..f87be5a22e 100644 --- a/src/main/target/PORT103R/target.h +++ b/src/main/target/PORT103R/target.h @@ -136,3 +136,4 @@ #define SERIAL_RX #define AUTOTUNE #define USE_SERVOS +#define USE_CLI diff --git a/src/main/target/SPARKY/target.h b/src/main/target/SPARKY/target.h index b5f36dce9e..1c835d2b02 100644 --- a/src/main/target/SPARKY/target.h +++ b/src/main/target/SPARKY/target.h @@ -109,11 +109,12 @@ #define AUTOTUNE #define BLACKBOX +#define TELEMETRY #define SERIAL_RX #define GPS #define DISPLAY #define USE_SERVOS -#define TELEMETRY +#define USE_CLI #define LED_STRIP #if 1 diff --git a/src/main/target/SPRACINGF3/target.h b/src/main/target/SPRACINGF3/target.h index da8aab45ad..64de123da9 100644 --- a/src/main/target/SPRACINGF3/target.h +++ b/src/main/target/SPRACINGF3/target.h @@ -153,3 +153,4 @@ #define AUTOTUNE #define DISPLAY #define USE_SERVOS +#define USE_CLI diff --git a/src/main/target/STM32F3DISCOVERY/target.h b/src/main/target/STM32F3DISCOVERY/target.h index b1d1c2cc02..3eccb8cee0 100644 --- a/src/main/target/STM32F3DISCOVERY/target.h +++ b/src/main/target/STM32F3DISCOVERY/target.h @@ -97,3 +97,4 @@ #define SERIAL_RX #define AUTOTUNE #define USE_SERVOS +#define USE_CLI