From c4646d7a77b939dce1fa48c80d1ba36b489220a3 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Sat, 29 Nov 2014 01:16:36 +0100 Subject: [PATCH 01/35] AlienWii32 alternative defaults for NAZE target Activate via OPTIONS="ALIENWII32" during make --- src/main/config/config.c | 14 ++++++++++++++ src/main/target/NAZE/target.h | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/src/main/config/config.c b/src/main/config/config.c index bc96cdc18..058975add 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -435,6 +435,20 @@ static void resetConf(void) applyDefaultLedStripConfig(masterConfig.ledConfigs); #endif + // alternative defaults AlienWii32 (activate via OPTIONS="ALIENWII32" during make for NAZE target) +#ifdef ALIENWII32 + featureSet(FEATURE_RX_MSP); + featureSet(FEATURE_MOTOR_STOP); + masterConfig.serialConfig.serial_port_scenario[1] = lookupScenarioIndex(SCENARIO_SERIAL_RX_ONLY); + masterConfig.rxConfig.serialrx_provider = 1; + masterConfig.escAndServoConfig.minthrottle = 1000; + masterConfig.escAndServoConfig.maxthrottle = 2000; + currentControlRateProfile->rcRate8 = 130; + currentControlRateProfile->rollPitchRate = 20; + currentControlRateProfile->yawRate = 60; + parseRcChannels("TAER1234", &masterConfig.rxConfig); +#endif + // copy first profile into remaining profile for (i = 1; i < MAX_PROFILE_COUNT; i++) { memcpy(&masterConfig.profile[i], currentProfile, sizeof(profile_t)); diff --git a/src/main/target/NAZE/target.h b/src/main/target/NAZE/target.h index 3e69fde49..c32259e26 100644 --- a/src/main/target/NAZE/target.h +++ b/src/main/target/NAZE/target.h @@ -111,3 +111,8 @@ #define TELEMETRY #define SERIAL_RX #define AUTOTUNE + + // alternative defaults AlienWii32 (activate via OPTIONS="ALIENWII32" during make for NAZE target) +#ifdef ALIENWII32 +#define BRUSHED_MOTORS +#endif From 910753121ed85d6d291225f99223cd0dc9d61bf4 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Sat, 29 Nov 2014 14:45:11 +0100 Subject: [PATCH 02/35] Updates and fixes fix FEATURE_RX_SERIAL --- src/main/config/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/config/config.c b/src/main/config/config.c index 058975add..752407be0 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -437,7 +437,7 @@ static void resetConf(void) // alternative defaults AlienWii32 (activate via OPTIONS="ALIENWII32" during make for NAZE target) #ifdef ALIENWII32 - featureSet(FEATURE_RX_MSP); + featureSet(FEATURE_RX_SERIAL); featureSet(FEATURE_MOTOR_STOP); masterConfig.serialConfig.serial_port_scenario[1] = lookupScenarioIndex(SCENARIO_SERIAL_RX_ONLY); masterConfig.rxConfig.serialrx_provider = 1; From a58353692ef1cd9956744bc4180a6cb80e2006b5 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Sat, 29 Nov 2014 16:21:03 +0100 Subject: [PATCH 03/35] AlienWii32 Spektrum bind integation --- src/main/config/config.c | 1 + src/main/target/NAZE/target.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/config/config.c b/src/main/config/config.c index 752407be0..bf60ced1e 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -441,6 +441,7 @@ static void resetConf(void) featureSet(FEATURE_MOTOR_STOP); masterConfig.serialConfig.serial_port_scenario[1] = lookupScenarioIndex(SCENARIO_SERIAL_RX_ONLY); masterConfig.rxConfig.serialrx_provider = 1; + masterConfig.rxConfig.spektrum_sat_bind = 5; masterConfig.escAndServoConfig.minthrottle = 1000; masterConfig.escAndServoConfig.maxthrottle = 2000; currentControlRateProfile->rcRate8 = 130; diff --git a/src/main/target/NAZE/target.h b/src/main/target/NAZE/target.h index c32259e26..f5fe08102 100644 --- a/src/main/target/NAZE/target.h +++ b/src/main/target/NAZE/target.h @@ -115,4 +115,5 @@ // alternative defaults AlienWii32 (activate via OPTIONS="ALIENWII32" during make for NAZE target) #ifdef ALIENWII32 #define BRUSHED_MOTORS +#define HARDWARE_BIND_PLUG #endif From e33513b6c81407c24dd7814af478ed1bb6b854b9 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Sat, 29 Nov 2014 16:51:17 +0100 Subject: [PATCH 04/35] Update motor_pwm_rate to 32000 --- src/main/config/config.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/config/config.c b/src/main/config/config.c index bf60ced1e..6cd0723c0 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -444,6 +444,7 @@ static void resetConf(void) masterConfig.rxConfig.spektrum_sat_bind = 5; masterConfig.escAndServoConfig.minthrottle = 1000; masterConfig.escAndServoConfig.maxthrottle = 2000; + masterConfig.motor_pwm_rate = 32000; currentControlRateProfile->rcRate8 = 130; currentControlRateProfile->rollPitchRate = 20; currentControlRateProfile->yawRate = 60; From 17d1c6e610be1d3341b082b3b1e2abdc2d21597e Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Sun, 30 Nov 2014 11:07:41 +0100 Subject: [PATCH 05/35] Adding documentaion and fix Board - AlienWii32.md Spectrum bind.md Adding Feature failsave --- docs/Board - AlienWii32.md | 24 ++++++++++++++++++++++++ docs/Spektrum bind.md | 35 +++++++++++++++++++++++++++++++++++ src/main/config/config.c | 1 + 3 files changed, 60 insertions(+) create mode 100644 docs/Board - AlienWii32.md create mode 100644 docs/Spektrum bind.md diff --git a/docs/Board - AlienWii32.md b/docs/Board - AlienWii32.md new file mode 100644 index 000000000..7c2866622 --- /dev/null +++ b/docs/Board - AlienWii32.md @@ -0,0 +1,24 @@ +# Board - AlienWii32 + +The AlienWii32 is actually in prototype stage only a few sample exist. There is some more field testing ongoing. The information below is preliminary an will be updated as needed. + +Here are the Hardware specifications: + +- STM32F103CBT6 MCU +- MPU6050 accelerometer/gyro sensor unit +- 8x 4.2A brushed ESCs, integrated, to run the strongest micro motors +- extra-wide traces on the PCB, for maximum power throughput +- USB port, integrated (subject to change) +- * serial connection for external DSM2/DSMX sat receiver (e.g. Spektrum SAT, OrangeRx R100 or Lemon RX) +- alternatively PPM receiver connection (i.e. Deltag Rx31) +- ground and 3.3V for the receiver +- hardware bind plug for easy binding +- motor connections are at the corners for a clean look with reduced wiring +- dimensions: 30x32mm +- direct operation from an single cell lipoly battery + +* Spektrum Compatible DSM2 satellites are supported out of the box. DSMX sat will work with DSM2 protocol wit default settings. Changes can be done as usual via CLI or the Cleanflight configurator. + +The pin layout is similar as the NAZE32 or the related clones. The hardware bind pin is connected to pin 41 (PB5). The AlienWii32 firmware will be build with TARGET=NAZE and OTIONS="AlienWii32". +The firmware image will come with alternative default settings which will give a plug and play experience. There is no computer need to get this into the air with an smAL quadcopter. +anyhow to use this in an Hexa- or Octocopter or to do some more tuning additional CLI changes are required as usual. \ No newline at end of file diff --git a/docs/Spektrum bind.md b/docs/Spektrum bind.md new file mode 100644 index 000000000..f5b8a8342 --- /dev/null +++ b/docs/Spektrum bind.md @@ -0,0 +1,35 @@ +# Spektrum bind support + +Spektrum bind with hardware bind plug support. + +## Hardware + +The hardware bind plug will be enabled via defining HARDWARE_BIND_PLUG during building of the firmware. +This is done automatically if the AlienWii32 firmware is build. The bind plug is expected between pin 41 +(PB5 STM32F103CBT6) and ground. The bind code will actually work for USART2 (PA3 STM32F103CBT6). + +## Function + +If the bind plug is set the bind mode will be permanently activated during the firmware start-up. The +spektrum_sat_bind CLI parameter is defining the number of bind impulses (1-10) send to the satellite receiver. +If there is no hardware bind plug present the bind code will be executed ones after the next start (hardware +reset or power on) of the firmware and the spektrum_sat_bind parameter will be reset to 0 when done. The bind +code will not be executed during an soft rest of the MCU. Please refer to your receiver documentation for more +details of the specific receiver in bind mode. Usually the bind mode will be indicated with some flashing LED’s. +The Bind plug should be always removed for normal flying. + +## Table with spektrum_sat_bind parameter Value + +| Value | Receiver mode | +| ----- | ---------------| +| 3 | DSM2 1024/22ms | +| 5 | DSM2 2048/11ms | +| 7 | DSMX 22ms | +| 9 | DSMX 11ms | + +More detailed information regarding the sattelite binding process can be found here: +http://wiki.openpilot.org/display/Doc/Spektrum+Satellite + +### Supported Hardware + +all NAZE Targets (NAZE32, Flip32, AlienWii32 with hardware bind pin) diff --git a/src/main/config/config.c b/src/main/config/config.c index 6cd0723c0..292c6dad7 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -439,6 +439,7 @@ static void resetConf(void) #ifdef ALIENWII32 featureSet(FEATURE_RX_SERIAL); featureSet(FEATURE_MOTOR_STOP); + featureSet(FEATURE_FAILSAVE); masterConfig.serialConfig.serial_port_scenario[1] = lookupScenarioIndex(SCENARIO_SERIAL_RX_ONLY); masterConfig.rxConfig.serialrx_provider = 1; masterConfig.rxConfig.spektrum_sat_bind = 5; From 4b2f35ccefa7a79c85b8a82bf802e7ccda823774 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Sun, 30 Nov 2014 12:03:49 +0100 Subject: [PATCH 06/35] Documentation updates and spelling fixes --- docs/Board - AlienWii32.md | 10 ++++------ docs/Spektrum bind.md | 26 +++++++++----------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/docs/Board - AlienWii32.md b/docs/Board - AlienWii32.md index 7c2866622..51dcddb81 100644 --- a/docs/Board - AlienWii32.md +++ b/docs/Board - AlienWii32.md @@ -1,8 +1,8 @@ # Board - AlienWii32 -The AlienWii32 is actually in prototype stage only a few sample exist. There is some more field testing ongoing. The information below is preliminary an will be updated as needed. +The AlienWii32 is actually in prototype stage only a few samples exist. There is some more field testing ongoing. The information below is preliminary an will be updated as needed. -Here are the Hardware specifications: +Here are the hardware specifications: - STM32F103CBT6 MCU - MPU6050 accelerometer/gyro sensor unit @@ -17,8 +17,6 @@ Here are the Hardware specifications: - dimensions: 30x32mm - direct operation from an single cell lipoly battery -* Spektrum Compatible DSM2 satellites are supported out of the box. DSMX sat will work with DSM2 protocol wit default settings. Changes can be done as usual via CLI or the Cleanflight configurator. +* Spektrum Compatible DSM2 satellites are supported out of the box. DSMX sat will work with DSM2 protocol with default settings. Changes can be done as usual via CLI or the Cleanflight configurator. -The pin layout is similar as the NAZE32 or the related clones. The hardware bind pin is connected to pin 41 (PB5). The AlienWii32 firmware will be build with TARGET=NAZE and OTIONS="AlienWii32". -The firmware image will come with alternative default settings which will give a plug and play experience. There is no computer need to get this into the air with an smAL quadcopter. -anyhow to use this in an Hexa- or Octocopter or to do some more tuning additional CLI changes are required as usual. \ No newline at end of file +The pin layout is very similar as the NAZE32 or the related clones (MW32, Flip32 etc). The hardware bind pin is connected to pin 41 (PB5). The AlienWii32 firmware will be build with TARGET=NAZE and OPTIONS="AlienWii32". The firmware image will come with alternative default settings which will give the user an plug and play experience. There is no computer need to get this into the air with an smal quadcopter. Anyhow to use this in an Hexa- or Octocopter or to do some more tuning additional CLI changes are required as usual. \ No newline at end of file diff --git a/docs/Spektrum bind.md b/docs/Spektrum bind.md index f5b8a8342..4c014c78f 100644 --- a/docs/Spektrum bind.md +++ b/docs/Spektrum bind.md @@ -4,32 +4,24 @@ Spektrum bind with hardware bind plug support. ## Hardware -The hardware bind plug will be enabled via defining HARDWARE_BIND_PLUG during building of the firmware. -This is done automatically if the AlienWii32 firmware is build. The bind plug is expected between pin 41 -(PB5 STM32F103CBT6) and ground. The bind code will actually work for USART2 (PA3 STM32F103CBT6). +The hardware bind plug will be enabled via defining HARDWARE_BIND_PLUG during building of the firmware. This is done automatically if the AlienWii32 firmware is build. The bind plug is expected between pin 41 (PB5 STM32F103CBT6) and ground. The bind code will actually work for USART2 (PA3 STM32F103CBT6). ## Function -If the bind plug is set the bind mode will be permanently activated during the firmware start-up. The -spektrum_sat_bind CLI parameter is defining the number of bind impulses (1-10) send to the satellite receiver. -If there is no hardware bind plug present the bind code will be executed ones after the next start (hardware -reset or power on) of the firmware and the spektrum_sat_bind parameter will be reset to 0 when done. The bind -code will not be executed during an soft rest of the MCU. Please refer to your receiver documentation for more -details of the specific receiver in bind mode. Usually the bind mode will be indicated with some flashing LED’s. -The Bind plug should be always removed for normal flying. +If the bind plug is set the bind mode will be permanently activated during the firmware start-up. The spektrum_sat_bind CLI parameter is defining the number of bind impulses (1-10) send to the satellite receiver. Please refer to the table below. If there is no hardware bind plug present and the spektrum_sat_bind paremeter is set the bind code will be executed one time only after the next start of the firmware (hardware reset or power on). The spektrum_sat_bind parameter will be reset to 0 when done. The bind code will not be executed during an soft rest of the MCU. Please refer to the sattelite receiver documentation for more details of the specific receiver in bind mode. Usually the bind mode will be indicated with some flashing LED’s. The Bind plug should be always removed for normal flying. ## Table with spektrum_sat_bind parameter Value -| Value | Receiver mode | -| ----- | ---------------| -| 3 | DSM2 1024/22ms | -| 5 | DSM2 2048/11ms | -| 7 | DSMX 22ms | -| 9 | DSMX 11ms | +| Value | Receiver mode | Notes | +| ----- | ---------------| --------| +| 3 | DSM2 1024/22ms | | +| 5 | DSM2 2048/11ms | default | +| 7 | DSMX 22ms | | +| 9 | DSMX 11ms | | More detailed information regarding the sattelite binding process can be found here: http://wiki.openpilot.org/display/Doc/Spektrum+Satellite ### Supported Hardware -all NAZE Targets (NAZE32, Flip32, AlienWii32 with hardware bind pin) +all NAZE targets (NAZE32, MW32, Flip32, AlienWii32 with hardware bind pin) From a6296460900172ea932ab9af8d8db5bb61fb9c97 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Mon, 1 Dec 2014 14:39:32 +0100 Subject: [PATCH 07/35] Update documentation, Update Spektrum_bind.md additional defines for hardware bind plug (AlienWii32) --- docs/Spektrum bind.md | 20 ++++++++++++++++---- src/main/target/NAZE/target.h | 4 +++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/docs/Spektrum bind.md b/docs/Spektrum bind.md index 4c014c78f..9fc19cff8 100644 --- a/docs/Spektrum bind.md +++ b/docs/Spektrum bind.md @@ -2,15 +2,27 @@ Spektrum bind with hardware bind plug support. +## The Spektrum bind code is actually only enabled for the NAZE target. The following parameters can be used to enable and configure this for other targets after more testing: + + #define SPEKTRUM_BIND Enables the Spektrum bind code + #define BIND_PORT GPIOA Defines the port for the bind pin + #define BIND_PIN Pin_3 Defines the bind pin (the satellite receiver is connected to) + +This is to activate the Hardware bind pug feature + + #define HARDWARE_BIND_PLUG Enables the hardware bind plug feature + #define BINDPLUG_PORT GPIOB Defines the port for the hardware bind plug + #define BINDPLUG_PIN Pin_5 Defines the hardware bind plug pin + ## Hardware The hardware bind plug will be enabled via defining HARDWARE_BIND_PLUG during building of the firmware. This is done automatically if the AlienWii32 firmware is build. The bind plug is expected between pin 41 (PB5 STM32F103CBT6) and ground. The bind code will actually work for USART2 (PA3 STM32F103CBT6). ## Function -If the bind plug is set the bind mode will be permanently activated during the firmware start-up. The spektrum_sat_bind CLI parameter is defining the number of bind impulses (1-10) send to the satellite receiver. Please refer to the table below. If there is no hardware bind plug present and the spektrum_sat_bind paremeter is set the bind code will be executed one time only after the next start of the firmware (hardware reset or power on). The spektrum_sat_bind parameter will be reset to 0 when done. The bind code will not be executed during an soft rest of the MCU. Please refer to the sattelite receiver documentation for more details of the specific receiver in bind mode. Usually the bind mode will be indicated with some flashing LED’s. The Bind plug should be always removed for normal flying. +If the bind plug is set the bind mode will be permanently activated during the firmware start-up. The spektrum_sat_bind CLI parameter is defining the number of bind impulses (1-10) send to the satellite receiver. Please refer to the table below. If there is no hardware bind plug present and the spektrum_sat_bind parameter is set the bind code will be executed one time only after the next start of the firmware (hardware reset or power on). The spektrum_sat_bind parameter will be reset to 0 when done. The bind code will not be executed during an soft rest of the MCU. Please refer to the satellite receiver documentation for more details of the specific receiver in bind mode. Usually the bind mode will be indicated with some flashing LED’s. The Bind plug should be always removed for normal flying. -## Table with spektrum_sat_bind parameter Value +## Table with spektrum_sat_bind parameter value | Value | Receiver mode | Notes | | ----- | ---------------| --------| @@ -19,9 +31,9 @@ If the bind plug is set the bind mode will be permanently activated during the f | 7 | DSMX 22ms | | | 9 | DSMX 11ms | | -More detailed information regarding the sattelite binding process can be found here: +More detailed information regarding the satellite binding process can be found here: http://wiki.openpilot.org/display/Doc/Spektrum+Satellite ### Supported Hardware -all NAZE targets (NAZE32, MW32, Flip32, AlienWii32 with hardware bind pin) +all NAZE targets (NAZE32, MW32, Flip32, AlienWii32 with hardware bind plug) \ No newline at end of file diff --git a/src/main/target/NAZE/target.h b/src/main/target/NAZE/target.h index f5fe08102..54e2ba295 100644 --- a/src/main/target/NAZE/target.h +++ b/src/main/target/NAZE/target.h @@ -112,8 +112,10 @@ #define SERIAL_RX #define AUTOTUNE - // alternative defaults AlienWii32 (activate via OPTIONS="ALIENWII32" during make for NAZE target) +// alternative defaults AlienWii32 (activate via OPTIONS="ALIENWII32" during make for NAZE target) #ifdef ALIENWII32 #define BRUSHED_MOTORS #define HARDWARE_BIND_PLUG +#define BINDPLUG_PORT GPIOB +#define BINDPLUG_PIN Pin_5 #endif From ece3859f9d4a7f0a49c03181321246b48a735fdd Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Mon, 1 Dec 2014 17:30:05 +0100 Subject: [PATCH 08/35] Add comment regarding bind plug --- src/main/target/NAZE/target.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/target/NAZE/target.h b/src/main/target/NAZE/target.h index 54e2ba295..8e4b3f814 100644 --- a/src/main/target/NAZE/target.h +++ b/src/main/target/NAZE/target.h @@ -116,6 +116,7 @@ #ifdef ALIENWII32 #define BRUSHED_MOTORS #define HARDWARE_BIND_PLUG +// Hardware bind plug at PB5 (Pin 41) #define BINDPLUG_PORT GPIOB #define BINDPLUG_PIN Pin_5 #endif From 74ba59b6b6f23078938ebceb4707ed5f86462fa2 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Tue, 2 Dec 2014 08:48:04 +0100 Subject: [PATCH 09/35] Documentation update --- docs/Spektrum bind.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/Spektrum bind.md b/docs/Spektrum bind.md index 9fc19cff8..26d1068ba 100644 --- a/docs/Spektrum bind.md +++ b/docs/Spektrum bind.md @@ -2,17 +2,17 @@ Spektrum bind with hardware bind plug support. -## The Spektrum bind code is actually only enabled for the NAZE target. The following parameters can be used to enable and configure this for other targets after more testing: +### The Spektrum bind code is actually only enabled for the NAZE, NAZE32PRO, CJMCU, CC3D targets. The following parameters can be used to enable and configure this for other targets after more testing: - #define SPEKTRUM_BIND Enables the Spektrum bind code - #define BIND_PORT GPIOA Defines the port for the bind pin - #define BIND_PIN Pin_3 Defines the bind pin (the satellite receiver is connected to) + SPEKTRUM_BIND Enables the Spektrum bind code + BIND_PORT GPIOA Defines the port for the bind pin + BIND_PIN Pin_3 Defines the bind pin (the satellite receiver is connected to) This is to activate the Hardware bind pug feature - #define HARDWARE_BIND_PLUG Enables the hardware bind plug feature - #define BINDPLUG_PORT GPIOB Defines the port for the hardware bind plug - #define BINDPLUG_PIN Pin_5 Defines the hardware bind plug pin + HARDWARE_BIND_PLUG Enables the hardware bind plug feature + BINDPLUG_PORT GPIOB Defines the port for the hardware bind plug + BINDPLUG_PIN Pin_5 Defines the hardware bind plug pin ## Hardware @@ -36,4 +36,4 @@ http://wiki.openpilot.org/display/Doc/Spektrum+Satellite ### Supported Hardware -all NAZE targets (NAZE32, MW32, Flip32, AlienWii32 with hardware bind plug) \ No newline at end of file +NAZE, NAZE32PRO, CJMCU, CC3D targets (AlienWii32 with hardware bind plug) \ No newline at end of file From 63ace537927ef4a7e4f9723409ba28dabf9ff1bc Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Tue, 2 Dec 2014 09:37:41 +0100 Subject: [PATCH 10/35] Documentation formatting fix --- docs/Spektrum bind.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/Spektrum bind.md b/docs/Spektrum bind.md index 26d1068ba..f64689c5c 100644 --- a/docs/Spektrum bind.md +++ b/docs/Spektrum bind.md @@ -2,7 +2,9 @@ Spektrum bind with hardware bind plug support. -### The Spektrum bind code is actually only enabled for the NAZE, NAZE32PRO, CJMCU, CC3D targets. The following parameters can be used to enable and configure this for other targets after more testing: +### The Spektrum bind code is actually only enabled for the NAZE, NAZE32PRO, CJMCU, CC3D targets. + +The following parameters can be used to enable and configure this for other targets after more testing: SPEKTRUM_BIND Enables the Spektrum bind code BIND_PORT GPIOA Defines the port for the bind pin From e03fc9e62291f307fede8717af383abdd04d4a5d Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Wed, 3 Dec 2014 08:55:30 +0100 Subject: [PATCH 11/35] Update documentation to reflect te softreset removal --- docs/Spektrum bind.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/Spektrum bind.md b/docs/Spektrum bind.md index f64689c5c..9d815663c 100644 --- a/docs/Spektrum bind.md +++ b/docs/Spektrum bind.md @@ -4,7 +4,9 @@ Spektrum bind with hardware bind plug support. ### The Spektrum bind code is actually only enabled for the NAZE, NAZE32PRO, CJMCU, CC3D targets. -The following parameters can be used to enable and configure this for other targets after more testing: +## Configure the bind code + +The following parameters can be used to enable and configure this in the related target.h file: SPEKTRUM_BIND Enables the Spektrum bind code BIND_PORT GPIOA Defines the port for the bind pin @@ -18,11 +20,11 @@ This is to activate the Hardware bind pug feature ## Hardware -The hardware bind plug will be enabled via defining HARDWARE_BIND_PLUG during building of the firmware. This is done automatically if the AlienWii32 firmware is build. The bind plug is expected between pin 41 (PB5 STM32F103CBT6) and ground. The bind code will actually work for USART2 (PA3 STM32F103CBT6). +The hardware bind plug will be enabled via defining HARDWARE_BIND_PLUG during building of the firmware. BINDPLUG_PORT and BINDPLUG_PIN also need to be defined (please see above). This is done automatically if the AlienWii32 firmware is build. The hardware bind plug is expected between the bind pin and ground. ## Function -If the bind plug is set the bind mode will be permanently activated during the firmware start-up. The spektrum_sat_bind CLI parameter is defining the number of bind impulses (1-10) send to the satellite receiver. Please refer to the table below. If there is no hardware bind plug present and the spektrum_sat_bind parameter is set the bind code will be executed one time only after the next start of the firmware (hardware reset or power on). The spektrum_sat_bind parameter will be reset to 0 when done. The bind code will not be executed during an soft rest of the MCU. Please refer to the satellite receiver documentation for more details of the specific receiver in bind mode. Usually the bind mode will be indicated with some flashing LED’s. The Bind plug should be always removed for normal flying. +The bind code will actually work for NAZE, NAZE32PRO, CJMCU targets (USART2) and CC3D target (USART3, flex port). The spektrum_sat_bind CLI parameter is defining the number of bind impulses (1-10) send to the satellite receiver. If it will set to 0 bind will be disabled in any case. Please refer to the table below. If the hardware bind plug is configured the bind mode will only be activated if spektrum_sat_bind is set to a value between 1 and 10 and the plug is set during the firmware start-up. The bind plug should be always removed for normal flying. If no hardware bind plug is used the spektrum_sat_bind parameter should be reset to 0 manually after the bind is succefuly done. Please refer to the satellite receiver documentation for more details of the specific receiver in bind mode. Usually the bind mode will be indicated with some flashing LED’s. ## Table with spektrum_sat_bind parameter value @@ -38,4 +40,4 @@ http://wiki.openpilot.org/display/Doc/Spektrum+Satellite ### Supported Hardware -NAZE, NAZE32PRO, CJMCU, CC3D targets (AlienWii32 with hardware bind plug) \ No newline at end of file +NAZE, NAZE32PRO, CJMCU, CC3D targets (AlienWii32 with hardware bind plug) From b1b49c7260c283e38f64e3d3f05587cd4c97589e Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Wed, 3 Dec 2014 09:28:00 +0100 Subject: [PATCH 12/35] Formatting and spelling fixes --- docs/Spektrum bind.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Spektrum bind.md b/docs/Spektrum bind.md index 9d815663c..1fbb0b83d 100644 --- a/docs/Spektrum bind.md +++ b/docs/Spektrum bind.md @@ -2,7 +2,7 @@ Spektrum bind with hardware bind plug support. -### The Spektrum bind code is actually only enabled for the NAZE, NAZE32PRO, CJMCU, CC3D targets. +The Spektrum bind code is actually only enabled for the NAZE, NAZE32PRO, CJMCU, CC3D targets. ## Configure the bind code @@ -12,7 +12,7 @@ The following parameters can be used to enable and configure this in the related BIND_PORT GPIOA Defines the port for the bind pin BIND_PIN Pin_3 Defines the bind pin (the satellite receiver is connected to) -This is to activate the Hardware bind pug feature +This is to activate the hardware bind plug feature HARDWARE_BIND_PLUG Enables the hardware bind plug feature BINDPLUG_PORT GPIOB Defines the port for the hardware bind plug From 7e24a050b497c9277f48d686a174a9619bfc3036 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Fri, 5 Dec 2014 07:58:49 +0100 Subject: [PATCH 13/35] Update information regarding Deltang receivers. --- docs/Board - AlienWii32.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Board - AlienWii32.md b/docs/Board - AlienWii32.md index 51dcddb81..ca79f20f2 100644 --- a/docs/Board - AlienWii32.md +++ b/docs/Board - AlienWii32.md @@ -17,6 +17,6 @@ Here are the hardware specifications: - dimensions: 30x32mm - direct operation from an single cell lipoly battery -* Spektrum Compatible DSM2 satellites are supported out of the box. DSMX sat will work with DSM2 protocol with default settings. Changes can be done as usual via CLI or the Cleanflight configurator. +* Spektrum Compatible DSM2 satellites are supported out of the box. DSMX sat will work with DSM2 protocol with default settings. Changes can be done as usual via CLI or the Cleanflight configurator. Deltang receivers in serial mode will work like any other Spektrum satellite receiver (10bit, 22ms) only the bind process will be different. -The pin layout is very similar as the NAZE32 or the related clones (MW32, Flip32 etc). The hardware bind pin is connected to pin 41 (PB5). The AlienWii32 firmware will be build with TARGET=NAZE and OPTIONS="AlienWii32". The firmware image will come with alternative default settings which will give the user an plug and play experience. There is no computer need to get this into the air with an smal quadcopter. Anyhow to use this in an Hexa- or Octocopter or to do some more tuning additional CLI changes are required as usual. \ No newline at end of file +The pin layout is very similar as the NAZE32 or the related clones (MW32, Flip32, etc.). The hardware bind pin is connected to pin 41 (PB5). The AlienWii32 firmware will be build with TARGET=NAZE and OPTIONS="AlienWii32". The firmware image will come with alternative default settings which will give the user an plug and play experience. There is no computer need to get this into the air with an smal quadcopter. For the bind mode DSM2, 11bit, 22ms is preset. Anyhow to use this in an Hexa- or Octocopter or to do some more tuning additional CLI changes are required as usual. \ No newline at end of file From 0061ce1c2260e0edd06061286678b64afa26cad6 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Fri, 5 Dec 2014 08:25:04 +0100 Subject: [PATCH 14/35] Some more documentation updates and spelling fixes --- docs/Board - AlienWii32.md | 44 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/docs/Board - AlienWii32.md b/docs/Board - AlienWii32.md index ca79f20f2..d48919b81 100644 --- a/docs/Board - AlienWii32.md +++ b/docs/Board - AlienWii32.md @@ -1,22 +1,22 @@ -# Board - AlienWii32 - -The AlienWii32 is actually in prototype stage only a few samples exist. There is some more field testing ongoing. The information below is preliminary an will be updated as needed. - -Here are the hardware specifications: - -- STM32F103CBT6 MCU -- MPU6050 accelerometer/gyro sensor unit -- 8x 4.2A brushed ESCs, integrated, to run the strongest micro motors -- extra-wide traces on the PCB, for maximum power throughput -- USB port, integrated (subject to change) -- * serial connection for external DSM2/DSMX sat receiver (e.g. Spektrum SAT, OrangeRx R100 or Lemon RX) -- alternatively PPM receiver connection (i.e. Deltag Rx31) -- ground and 3.3V for the receiver -- hardware bind plug for easy binding -- motor connections are at the corners for a clean look with reduced wiring -- dimensions: 30x32mm -- direct operation from an single cell lipoly battery - -* Spektrum Compatible DSM2 satellites are supported out of the box. DSMX sat will work with DSM2 protocol with default settings. Changes can be done as usual via CLI or the Cleanflight configurator. Deltang receivers in serial mode will work like any other Spektrum satellite receiver (10bit, 22ms) only the bind process will be different. - -The pin layout is very similar as the NAZE32 or the related clones (MW32, Flip32, etc.). The hardware bind pin is connected to pin 41 (PB5). The AlienWii32 firmware will be build with TARGET=NAZE and OPTIONS="AlienWii32". The firmware image will come with alternative default settings which will give the user an plug and play experience. There is no computer need to get this into the air with an smal quadcopter. For the bind mode DSM2, 11bit, 22ms is preset. Anyhow to use this in an Hexa- or Octocopter or to do some more tuning additional CLI changes are required as usual. \ No newline at end of file +# Board - AlienWii32 + +The AlienWii32 is actually in prototype stage only a few samples exist. There is some more field testing ongoing. The information below is preliminary and will be updated as needed. + +Here are the hardware specifications: + +- STM32F103CBT6 MCU +- MPU6050 accelerometer/gyro sensor unit +- 8x 4.2A brushed ESCs, integrated, to run the strongest micro motors +- extra-wide traces on the PCB, for maximum power throughput +- USB port, integrated (subject to change) +- (*) serial connection for external DSM2/DSMX sat receiver (e.g. Spektrum SAT, OrangeRx R100 or Lemon RX) +- alternatively PPM receiver connection (i.e. Deltang Rx31) +- ground and 3.3V for the receiver +- hardware bind plug for easy binding +- motor connections are at the corners for a clean look with reduced wiring +- dimensions: 30x32mm +- direct operation from an single cell lipoly battery + +(*) Spektrum Compatible DSM2 satellites are supported out of the box. DSMX sat will work with DSM2 protocol with default settings (DSM2, 11bit, 22ms is preset). Changes can be done as usual via CLI or the Cleanflight configurator. Deltang receivers in serial mode will work like any other Spektrum satellite receiver (10bit, 22ms) only the bind process will be different. + +The pin layout is very similar as the NAZE32 or the related clones (MW32, Flip32, etc.). The hardware bind pin is connected to pin 41 (PB5). The AlienWii32 firmware will be built with TARGET=NAZE and OPTIONS="AlienWii32". The firmware image will come with alternative default settings which will give the user a plug and play experience. There is no computer needed to get this into the air with an small Quadcopter. Anyhow to use the AlienWii32 in an Hexa- or Octocopter or to do some more tuning additional configuration changes can be done as usual. From 7369aac4d7b138f85c0088a61154d2bc3e24cb4f Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Sun, 7 Dec 2014 12:32:36 +0100 Subject: [PATCH 15/35] Update documentation to reflect soft reset detection --- docs/Spektrum bind.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Spektrum bind.md b/docs/Spektrum bind.md index 1fbb0b83d..f74968624 100644 --- a/docs/Spektrum bind.md +++ b/docs/Spektrum bind.md @@ -20,11 +20,11 @@ This is to activate the hardware bind plug feature ## Hardware -The hardware bind plug will be enabled via defining HARDWARE_BIND_PLUG during building of the firmware. BINDPLUG_PORT and BINDPLUG_PIN also need to be defined (please see above). This is done automatically if the AlienWii32 firmware is build. The hardware bind plug is expected between the bind pin and ground. +The hardware bind plug will be enabled via defining HARDWARE_BIND_PLUG during building of the firmware. BINDPLUG_PORT and BINDPLUG_PIN also need to be defined (please see above). This is done automatically if the AlienWii32 firmware is build. The hardware bind plug is expected between the defined bind pin and ground. ## Function -The bind code will actually work for NAZE, NAZE32PRO, CJMCU targets (USART2) and CC3D target (USART3, flex port). The spektrum_sat_bind CLI parameter is defining the number of bind impulses (1-10) send to the satellite receiver. If it will set to 0 bind will be disabled in any case. Please refer to the table below. If the hardware bind plug is configured the bind mode will only be activated if spektrum_sat_bind is set to a value between 1 and 10 and the plug is set during the firmware start-up. The bind plug should be always removed for normal flying. If no hardware bind plug is used the spektrum_sat_bind parameter should be reset to 0 manually after the bind is succefuly done. Please refer to the satellite receiver documentation for more details of the specific receiver in bind mode. Usually the bind mode will be indicated with some flashing LED’s. +The bind code will actually work for NAZE, NAZE32PRO, CJMCU targets (USART2) and CC3D target (USART3, flex port). The spektrum_sat_bind CLI parameter is defining the number of bind impulses (1-10) send to the satellite receiver. Setting spektrum_sat_bind to zero will disable the bind mode in any case. The bind mode will not be activated after an software reset. Please refer to the table below for the different possible values. If the hardware bind plug is configured the bind mode will only be activated if the plug is set during the firmware start-up. The bind plug should be always removed for normal flying. If no hardware bind plug is used the spektrum_sat_bind parameter will trigger the bind process during the next hardware reset and will be automatically disabled after this. Please refer to the satellite receiver documentation for more details of the specific receiver in bind mode. Usually the bind mode will be indicated with some flashing LEDs. ## Table with spektrum_sat_bind parameter value From 2499e39e5aa62fe8f18deca0a069490d895e5629 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Sun, 14 Dec 2014 22:11:12 +0100 Subject: [PATCH 16/35] Add custom mixer configuration for AllienWii32 The preconfigured custom mixer allows clean cabling for Octocopter builds with the AlienWii32 board --- src/main/config/config.c | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/main/config/config.c b/src/main/config/config.c index 292c6dad7..2ef5da7b6 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -450,6 +450,54 @@ static void resetConf(void) currentControlRateProfile->rollPitchRate = 20; currentControlRateProfile->yawRate = 60; parseRcChannels("TAER1234", &masterConfig.rxConfig); + + // { 1.0f, -0.5f, 1.0f, -1.0f }, // REAR_R + masterConfig.customMixer[0].throttle = 1.0f; + masterConfig.customMixer[0].roll = -0.5f; + masterConfig.customMixer[0].pitch = 1.0f; + masterConfig.customMixer[0].yaw = -1.0f; + + // { 1.0f, -0.5f, -1.0f, 1.0f }, // FRONT_R + masterConfig.customMixer[1].throttle = 1.0f; + masterConfig.customMixer[1].roll = -0.5f; + masterConfig.customMixer[1].pitch = -1.0f; + masterConfig.customMixer[1].yaw = 1.0f; + + // { 1.0f, 0.5f, 1.0f, 1.0f }, // REAR_L + masterConfig.customMixer[2].throttle = 1.0f; + masterConfig.customMixer[2].roll = 0.5f; + masterConfig.customMixer[2].pitch = 1.0f; + masterConfig.customMixer[2].yaw = 1.0f; + + // { 1.0f, 0.5f, -1.0f, -1.0f }, // FRONT_L + masterConfig.customMixer[3].throttle = 1.0f; + masterConfig.customMixer[3].roll = 0.5f; + masterConfig.customMixer[3].pitch = -1.0f; + masterConfig.customMixer[3].yaw = -1.0f; + + // { 1.0f, -1.0f, -0.5f, -1.0f }, // MIDFRONT_R + masterConfig.customMixer[4].throttle = 1.0f; + masterConfig.customMixer[4].roll = -1.0f; + masterConfig.customMixer[4].pitch = -0.5f; + masterConfig.customMixer[4].yaw = -1.0f; + + // { 1.0f, 1.0f, -0.5f, 1.0f }, // MIDFRONT_L + masterConfig.customMixer[5].throttle = 1.0f; + masterConfig.customMixer[5].roll = 1.0f; + masterConfig.customMixer[5].pitch = -0.5f; + masterConfig.customMixer[5].yaw = 1.0f; + + // { 1.0f, -1.0f, 0.5f, 1.0f }, // MIDREAR_R + masterConfig.customMixer[6].throttle = 1.0f; + masterConfig.customMixer[6].roll = -1.0f; + masterConfig.customMixer[6].pitch = 0.5f; + masterConfig.customMixer[6].yaw = 1.0f; + + // { 1.0f, 1.0f, 0.5f, -1.0f }, // MIDREAR_L + masterConfig.customMixer[7].throttle = 1.0f; + masterConfig.customMixer[7].roll = 1.0f; + masterConfig.customMixer[7].pitch = 0.5f; + masterConfig.customMixer[7].yaw = -1.0f; #endif // copy first profile into remaining profile From 4b0d5e7e154c0a7415a116923234dfe65d130b73 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Mon, 15 Dec 2014 07:46:47 +0100 Subject: [PATCH 17/35] Use same PWM mapping for PPM and Serial RX Without this fix an Octocopter with serialh RX will not work. Standard receiver mapping with only 6 motors outputs will apply. --- src/main/drivers/pwm_mapping.c | 3 ++- src/main/drivers/pwm_mapping.h | 1 + src/main/main.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/drivers/pwm_mapping.c b/src/main/drivers/pwm_mapping.c index b7fa0a5cf..1a93dfd1f 100644 --- a/src/main/drivers/pwm_mapping.c +++ b/src/main/drivers/pwm_mapping.c @@ -28,6 +28,7 @@ #include "pwm_output.h" #include "pwm_rx.h" #include "pwm_mapping.h" +#include "config/config.h" /* Configuration maps @@ -257,7 +258,7 @@ pwmOutputConfiguration_t *pwmInit(drv_pwm_config_t *init) // this is pretty hacky shit, but it will do for now. array of 4 config maps, [ multiPWM multiPPM airPWM airPPM ] if (init->airplane) i = 2; // switch to air hardware config - if (init->usePPM) + if (init->usePPM || init->useSerialRx) i++; // next index is for PPM setup = hardwareMaps[i]; diff --git a/src/main/drivers/pwm_mapping.h b/src/main/drivers/pwm_mapping.h index ff3b186cb..73246db29 100644 --- a/src/main/drivers/pwm_mapping.h +++ b/src/main/drivers/pwm_mapping.h @@ -38,6 +38,7 @@ typedef struct drv_pwm_config_t { bool useParallelPWM; bool usePPM; + bool useSerialRx; bool useRSSIADC; bool useCurrentMeterADC; #ifdef STM32F10X diff --git a/src/main/main.c b/src/main/main.c index e77d5b304..3c776d7bb 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -269,6 +269,7 @@ void init(void) pwm_params.useCurrentMeterADC = feature(FEATURE_CURRENT_METER); pwm_params.useLEDStrip = feature(FEATURE_LED_STRIP); pwm_params.usePPM = feature(FEATURE_RX_PPM); + pwm_params.useSerialRx = feature(FEATURE_RX_SERIAL); pwm_params.useServos = isMixerUsingServos(); pwm_params.extraServos = currentProfile->gimbalConfig.gimbal_flags & GIMBAL_FORWARDAUX; pwm_params.motorPwmRate = masterConfig.motor_pwm_rate; From 64c5cda1f7b6d78504830cf8617fc18e6218acc9 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Mon, 15 Dec 2014 11:00:04 +0100 Subject: [PATCH 18/35] Remove include from pwm_mapping.c (not needed) --- src/main/drivers/pwm_mapping.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/drivers/pwm_mapping.c b/src/main/drivers/pwm_mapping.c index 1a93dfd1f..bdc2b3d70 100644 --- a/src/main/drivers/pwm_mapping.c +++ b/src/main/drivers/pwm_mapping.c @@ -28,7 +28,6 @@ #include "pwm_output.h" #include "pwm_rx.h" #include "pwm_mapping.h" -#include "config/config.h" /* Configuration maps From eea8f905954e0c788870ad56d8fdc700b6621501 Mon Sep 17 00:00:00 2001 From: Petr Ledvina Date: Mon, 22 Dec 2014 14:39:50 +0100 Subject: [PATCH 19/35] auto-disarm implementation, slight rewrite of HFMan commit 931478054e70cd6a51916ea9430f041f61b7f7ba Added automatic disarm after 5 seconds when feature MOTOR_STOP is enabled (has no effect on FIXED_WING configurations.) Users that don't have a buzzer to warn when board is armed and use feature MOTOR_STOP can forget to disarm the board. For example after landing they pick up copter and then accidentally move throttle up when trying to remove flight battery. Configurable via CLI using 'set auto_disarm_board=x' where x is 0-60 seconds. If zero, does not auto_disarm. --- src/main/config/config.c | 1 + src/main/config/config_master.h | 1 + src/main/io/serial_cli.c | 1 + src/main/mw.c | 15 +++++++++++++++ 4 files changed, 18 insertions(+) diff --git a/src/main/config/config.c b/src/main/config/config.c index 736aad70d..6fec36f3e 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -352,6 +352,7 @@ static void resetConf(void) masterConfig.retarded_arm = 0; masterConfig.disarm_kill_switch = 1; + masterConfig.auto_disarm_delay = 5; masterConfig.small_angle = 25; masterConfig.airplaneConfig.flaps_speed = 0; diff --git a/src/main/config/config_master.h b/src/main/config/config_master.h index e3f1eeb03..0078762ce 100644 --- a/src/main/config/config_master.h +++ b/src/main/config/config_master.h @@ -63,6 +63,7 @@ typedef struct master_t { uint8_t retarded_arm; // allow disarm/arm on throttle down + roll left/right uint8_t disarm_kill_switch; // allow disarm via AUX switch regardless of throttle value + uint8_t auto_disarm_delay; // allow automatically disarming multicopters after auto_disarm_delay seconds of zero throttle. Disabled when 0 uint8_t small_angle; airplaneConfig_t airplaneConfig; diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index d7f52ec1c..eacd1a333 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -232,6 +232,7 @@ const clivalue_t valueTable[] = { { "retarded_arm", VAR_UINT8 | MASTER_VALUE, &masterConfig.retarded_arm, 0, 1 }, { "disarm_kill_switch", VAR_UINT8 | MASTER_VALUE, &masterConfig.disarm_kill_switch, 0, 1 }, + { "auto_disarm_delay", VAR_UINT8 | MASTER_VALUE, &masterConfig.auto_disarm_delay, 0, 60 }, { "small_angle", VAR_UINT8 | MASTER_VALUE, &masterConfig.small_angle, 0, 180 }, { "flaps_speed", VAR_UINT8 | MASTER_VALUE, &masterConfig.airplaneConfig.flaps_speed, 0, 100 }, diff --git a/src/main/mw.c b/src/main/mw.c index 58c56f85c..6cfaafe8b 100644 --- a/src/main/mw.c +++ b/src/main/mw.c @@ -91,6 +91,7 @@ uint16_t cycleTime = 0; // this is the number in micro second to achieve int16_t headFreeModeHold; int16_t telemTemperature1; // gyro sensor temperature +static uint32_t disarmTime; // Time of automatic disarm when "Don't spin the motors when armed" is enabled and auto_disarm_delay is nonzero extern uint8_t dynP8[3], dynI8[3], dynD8[3]; extern failsafe_t *failsafe; @@ -326,6 +327,8 @@ void mwArm(void) } } #endif + disarmTime = millis() + masterConfig.auto_disarm_delay * 1000; // start disarm timeout, will be extended when throttle is nonzero + return; } } @@ -493,6 +496,18 @@ void processRx(void) resetErrorAngle(); resetErrorGyro(); } + // When armed and motors aren't spinning, disarm board after delay so users without buzzer won't lose fingers. + // mixTable constrains motor commands, so checking throttleStatus is enough + if (ARMING_FLAG(ARMED) + && feature(FEATURE_MOTOR_STOP) && !STATE(FIXED_WING) + && masterConfig.auto_disarm_delay != 0) { + if (throttleStatus == THROTTLE_LOW) { + if ((int32_t)(disarmTime - millis()) < 0) // delay is over + mwDisarm(); + } else { + disarmTime = millis() + masterConfig.auto_disarm_delay * 1000; // extend delay + } + } processRcStickPositions(&masterConfig.rxConfig, throttleStatus, masterConfig.retarded_arm, masterConfig.disarm_kill_switch); From 73869a75e3ea552d7111974e75087273a8cc5d45 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Tue, 23 Dec 2014 18:04:51 +0100 Subject: [PATCH 20/35] Some final documentation updates --- docs/Board - AlienWii32.md | 10 ++++++---- docs/Spektrum bind.md | 24 +++++++++++++++--------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/docs/Board - AlienWii32.md b/docs/Board - AlienWii32.md index d48919b81..b0bb08e3d 100644 --- a/docs/Board - AlienWii32.md +++ b/docs/Board - AlienWii32.md @@ -8,15 +8,17 @@ Here are the hardware specifications: - MPU6050 accelerometer/gyro sensor unit - 8x 4.2A brushed ESCs, integrated, to run the strongest micro motors - extra-wide traces on the PCB, for maximum power throughput -- USB port, integrated (subject to change) +- USB port, integrated - (*) serial connection for external DSM2/DSMX sat receiver (e.g. Spektrum SAT, OrangeRx R100 or Lemon RX) - alternatively PPM receiver connection (i.e. Deltang Rx31) - ground and 3.3V for the receiver - hardware bind plug for easy binding - motor connections are at the corners for a clean look with reduced wiring -- dimensions: 30x32mm +- dimensions: 29x33mm - direct operation from an single cell lipoly battery -(*) Spektrum Compatible DSM2 satellites are supported out of the box. DSMX sat will work with DSM2 protocol with default settings (DSM2, 11bit, 22ms is preset). Changes can be done as usual via CLI or the Cleanflight configurator. Deltang receivers in serial mode will work like any other Spektrum satellite receiver (10bit, 22ms) only the bind process will be different. +(*) Spektrum Compatible DSM2 satellites are supported out of the box. DSMX sat will work with DSM2 protocol with default settings (DSM2, 11bit, 11ms is preset). -The pin layout is very similar as the NAZE32 or the related clones (MW32, Flip32, etc.). The hardware bind pin is connected to pin 41 (PB5). The AlienWii32 firmware will be built with TARGET=NAZE and OPTIONS="AlienWii32". The firmware image will come with alternative default settings which will give the user a plug and play experience. There is no computer needed to get this into the air with an small Quadcopter. Anyhow to use the AlienWii32 in an Hexa- or Octocopter or to do some more tuning additional configuration changes can be done as usual. +Deltang receivers in serial mode will work like any other Spektrum satellite receiver (10bit, 22ms) only the bind process will be different. + +The pin layout is very similar as the NAZE32 or the related clones (MW32, Flip32, etc.). The hardware bind pin is connected to pin 41 (PB5). The AlienWii32 firmware will be built with TARGET=NAZE and OPTIONS="AlienWii32". The firmware image will come with alternative default settings which will give the user a plug and play experience. There is no computer needed to get this into the air with an small Quadcopter. An preconfigured custom mixer for an Octocopter is part of the default settings to allow clean straight wiring with the AlienWii32. The mixer can be activated with "mixer custom" in the CLI. To use the AlienWii32 in an Hexa- or Octocopter or to do some more tuning additional configuration changes can be done as usual in the CLI or the Cleanflight configurator. \ No newline at end of file diff --git a/docs/Spektrum bind.md b/docs/Spektrum bind.md index f74968624..d81ebbcba 100644 --- a/docs/Spektrum bind.md +++ b/docs/Spektrum bind.md @@ -2,7 +2,7 @@ Spektrum bind with hardware bind plug support. -The Spektrum bind code is actually only enabled for the NAZE, NAZE32PRO, CJMCU, CC3D targets. +The Spektrum bind code is actually enabled for the NAZE, NAZE32PRO, CJMCU, EUSTM32F103RC, SPARKY, CC3D targets. ## Configure the bind code @@ -24,20 +24,26 @@ The hardware bind plug will be enabled via defining HARDWARE_BIND_PLUG during bu ## Function -The bind code will actually work for NAZE, NAZE32PRO, CJMCU targets (USART2) and CC3D target (USART3, flex port). The spektrum_sat_bind CLI parameter is defining the number of bind impulses (1-10) send to the satellite receiver. Setting spektrum_sat_bind to zero will disable the bind mode in any case. The bind mode will not be activated after an software reset. Please refer to the table below for the different possible values. If the hardware bind plug is configured the bind mode will only be activated if the plug is set during the firmware start-up. The bind plug should be always removed for normal flying. If no hardware bind plug is used the spektrum_sat_bind parameter will trigger the bind process during the next hardware reset and will be automatically disabled after this. Please refer to the satellite receiver documentation for more details of the specific receiver in bind mode. Usually the bind mode will be indicated with some flashing LEDs. +The bind code will actually work for NAZE, NAZE32PRO, CJMCU, EUSTM32F103RC, SPARKY targets (USART2) and CC3D target (USART3, flex port). The spektrum_sat_bind CLI parameter is defining the number of bind impulses (1-10) send to the satellite receiver. Setting spektrum_sat_bind to zero will disable the bind mode in any case. The bind mode will only be activated after an power on or hard reset. Please refer to the table below for the different possible values. + +If the hardware bind plug is configured the bind mode will only be activated if the plug is set during the firmware start-up. The value of the spektrum_sat_bind parameter will be permanently preserved. The bind plug should be always removed for normal flying. + +If no hardware bind plug is used the spektrum_sat_bind parameter will trigger the bind process during the next hardware reset and will be automatically reset to "0" after this. + +Please refer to the satellite receiver documentation for more details of the specific receiver in bind mode. Usually the bind mode will be indicated with some flashing LEDs. ## Table with spektrum_sat_bind parameter value -| Value | Receiver mode | Notes | -| ----- | ---------------| --------| -| 3 | DSM2 1024/22ms | | -| 5 | DSM2 2048/11ms | default | -| 7 | DSMX 22ms | | -| 9 | DSMX 11ms | | +| Value | Receiver mode | Notes | +| ----- | ---------------| -------------------| +| 3 | DSM2 1024/22ms | | +| 5 | DSM2 2048/11ms | default AlienWii32 | +| 7 | DSMX 22ms | | +| 9 | DSMX 11ms | | More detailed information regarding the satellite binding process can be found here: http://wiki.openpilot.org/display/Doc/Spektrum+Satellite ### Supported Hardware -NAZE, NAZE32PRO, CJMCU, CC3D targets (AlienWii32 with hardware bind plug) +NAZE, NAZE32PRO, CJMCU, SPARKY, EUSTM32F103RC, CC3D targets (AlienWii32 with hardware bind plug) From e7cac196a18493a3017708b14ef757f1447ad896 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 26 Dec 2014 18:06:01 +0000 Subject: [PATCH 21/35] Prevent MSP from hogging the CPU. --- src/main/io/serial_msp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index 27268a779..e5a7f69d5 100644 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -760,7 +760,7 @@ static bool processOutCommand(uint8_t cmdMSP) break; case MSP_RAW_IMU: headSerialReply(18); - // Retarded hack until multiwiidorks start using real units for sensor data + // Hack due to choice of units for sensor data in multiwii if (acc_1G > 1024) { for (i = 0; i < 3; i++) serialize16(accSmooth[i] / 8); @@ -982,7 +982,7 @@ static bool processOutCommand(uint8_t cmdMSP) serialize8(GPS_svinfo_svid[i]); serialize8(GPS_svinfo_quality[i]); serialize8(GPS_svinfo_cno[i]); - } + } break; #endif case MSP_DEBUG: @@ -1469,6 +1469,7 @@ static void mspProcessPort(void) tailSerialReply(); } currentPort->c_state = IDLE; + break; // process one command so as not to block. } } } From bee8bded90210d5331a608e2426644a475575c99 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 26 Dec 2014 18:52:14 +0000 Subject: [PATCH 22/35] SPARKY - Add TODO item. --- docs/Board - Sparky.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Board - Sparky.md b/docs/Board - Sparky.md index ae0c943bb..61d55d50f 100644 --- a/docs/Board - Sparky.md +++ b/docs/Board - Sparky.md @@ -23,6 +23,7 @@ Tested with revision 1 board. * Sonar * Display (via Flex port) * Softserial - though having 3 hardware serial ports makes it a little redundant. +* Airplane PWM mappings. # Flashing From bbf9e6db232eba63abce5cfc5ab58dccad810d5b Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 26 Dec 2014 20:02:10 +0000 Subject: [PATCH 23/35] Rename disarmTime to disarmAt for clarity. --- src/main/mw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/mw.c b/src/main/mw.c index bcce27fda..f046a7575 100644 --- a/src/main/mw.c +++ b/src/main/mw.c @@ -91,7 +91,7 @@ uint16_t cycleTime = 0; // this is the number in micro second to achieve int16_t headFreeModeHold; int16_t telemTemperature1; // gyro sensor temperature -static uint32_t disarmTime; // Time of automatic disarm when "Don't spin the motors when armed" is enabled and auto_disarm_delay is nonzero +static uint32_t disarmAt; // Time of automatic disarm when "Don't spin the motors when armed" is enabled and auto_disarm_delay is nonzero extern uint8_t dynP8[3], dynI8[3], dynD8[3]; extern failsafe_t *failsafe; @@ -327,7 +327,7 @@ void mwArm(void) } } #endif - disarmTime = millis() + masterConfig.auto_disarm_delay * 1000; // start disarm timeout, will be extended when throttle is nonzero + disarmAt = millis() + masterConfig.auto_disarm_delay * 1000; // start disarm timeout, will be extended when throttle is nonzero return; } @@ -502,10 +502,10 @@ void processRx(void) && feature(FEATURE_MOTOR_STOP) && !STATE(FIXED_WING) && masterConfig.auto_disarm_delay != 0) { if (throttleStatus == THROTTLE_LOW) { - if ((int32_t)(disarmTime - millis()) < 0) // delay is over + if ((int32_t)(disarmAt - millis()) < 0) // delay is over mwDisarm(); } else { - disarmTime = millis() + masterConfig.auto_disarm_delay * 1000; // extend delay + disarmAt = millis() + masterConfig.auto_disarm_delay * 1000; // extend delay } } From c0dbde03188e3b301bf25d028e702a75b219d09f Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 26 Dec 2014 20:04:17 +0000 Subject: [PATCH 24/35] Fix unable to arm using after setting mode range for arm and being able to arm using sticks after removing all mode ranges for arm. --- src/main/io/rc_controls.c | 2 ++ src/main/io/serial_msp.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/main/io/rc_controls.c b/src/main/io/rc_controls.c index 7247a8a22..d8662e1ad 100644 --- a/src/main/io/rc_controls.c +++ b/src/main/io/rc_controls.c @@ -519,6 +519,8 @@ void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions, es escAndServoConfig = escAndServoConfigToUse; pidProfile = pidProfileToUse; + isUsingSticksToArm = true; + for (index = 0; index < MAX_MODE_ACTIVATION_CONDITION_COUNT; index++) { modeActivationCondition_t *modeActivationCondition = &modeActivationConditions[index]; if (modeActivationCondition->modeId == BOXARM && IS_RANGE_USABLE(&modeActivationCondition->range)) { diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index e5a7f69d5..ca74d0c08 100644 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -80,6 +80,8 @@ extern uint16_t cycleTime; // FIXME dependency on mw.c extern uint16_t rssi; // FIXME dependency on mw.c extern int16_t debug[4]; // FIXME dependency on mw.c +void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions, escAndServoConfig_t *escAndServoConfigToUse, pidProfile_t *pidProfileToUse); + /** * MSP Guidelines, emphasis is used to clarify. * @@ -1172,6 +1174,8 @@ static bool processInCommand(void) mac->auxChannelIndex = read8(); mac->range.startStep = read8(); mac->range.endStep = read8(); + + useRcControlsConfig(currentProfile->modeActivationConditions, &masterConfig.escAndServoConfig, ¤tProfile->pidProfile); } else { headSerialError(0); } From 347b156727f6f0afc5844771c995264acdccb9fa Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 26 Dec 2014 20:22:13 +0000 Subject: [PATCH 25/35] Avoid calling mwDisarm() when due to having auto_disarm_delay when using switch to arm(). --- src/main/io/rc_controls.c | 5 +++++ src/main/io/rc_controls.h | 1 + src/main/mw.c | 7 +++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/io/rc_controls.c b/src/main/io/rc_controls.c index d8662e1ad..66db65127 100644 --- a/src/main/io/rc_controls.c +++ b/src/main/io/rc_controls.c @@ -57,6 +57,11 @@ int16_t rcCommand[4]; // interval [1000;2000] for THROTTLE and [-500;+ uint32_t rcModeActivationMask; // one bit per mode defined in boxId_e +bool isUsingSticksForArming(void) +{ + return isUsingSticksToArm; +} + bool areSticksInApModePosition(uint16_t ap_mode) { return abs(rcCommand[ROLL]) < ap_mode && abs(rcCommand[PITCH]) < ap_mode; diff --git a/src/main/io/rc_controls.h b/src/main/io/rc_controls.h index 051e25214..745acd468 100644 --- a/src/main/io/rc_controls.h +++ b/src/main/io/rc_controls.h @@ -213,3 +213,4 @@ void configureAdjustment(uint8_t index, uint8_t auxChannelIndex, const adjustmen void updateAdjustmentStates(adjustmentRange_t *adjustmentRanges); void processRcAdjustments(controlRateConfig_t *controlRateConfig, rxConfig_t *rxConfig); +bool isUsingSticksForArming(void); diff --git a/src/main/mw.c b/src/main/mw.c index f046a7575..54defd191 100644 --- a/src/main/mw.c +++ b/src/main/mw.c @@ -498,9 +498,12 @@ void processRx(void) } // When armed and motors aren't spinning, disarm board after delay so users without buzzer won't lose fingers. // mixTable constrains motor commands, so checking throttleStatus is enough - if (ARMING_FLAG(ARMED) + if ( + ARMING_FLAG(ARMED) && feature(FEATURE_MOTOR_STOP) && !STATE(FIXED_WING) - && masterConfig.auto_disarm_delay != 0) { + && masterConfig.auto_disarm_delay != 0 + && isUsingSticksForArming() + ) { if (throttleStatus == THROTTLE_LOW) { if ((int32_t)(disarmAt - millis()) < 0) // delay is over mwDisarm(); From 6ced3b24a241827d5aeb385512bc7bccaef9b102 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 26 Dec 2014 20:37:20 +0000 Subject: [PATCH 26/35] Update Naze32 softserial pin documentation. Fixes #255 --- docs/Board - Naze32.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/Board - Naze32.md b/docs/Board - Naze32.md index 9409435f6..3f4a9dc77 100644 --- a/docs/Board - Naze32.md +++ b/docs/Board - Naze32.md @@ -37,7 +37,7 @@ When SOFTSERIAL is enabled, LED_STRIP and CURRENT_METER are unavailable, but two | Pin | Identifier | Function | Notes | | --- | ---------- | -------------- | -------------------------------- | -| 7 | 5 | SOFTSERIAL1 TX | Enable `feature SOFTSERIAL` | -| 8 | 6 | SOFTSERIAL1 RX | | -| 9 | 7 | SOFTSERIAL2 TX | | -| 10 | 8 | SOFTSERIAL2 RX | | +| 7 | 5 | SOFTSERIAL1 RX | Enable `feature SOFTSERIAL`| +| 8 | 6 | SOFTSERIAL1 TX | | +| 9 | 7 | SOFTSERIAL2 RX | | +| 10 | 8 | SOFTSERIAL2 TX | | From 1ea0fec58f85e0a312d70359cde2c1eb20b5227b Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Sat, 27 Dec 2014 01:08:13 +0100 Subject: [PATCH 27/35] AlienWii32 fix FEATURE_FAILSAFE --- src/main/config/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/config/config.c b/src/main/config/config.c index 0468b4798..f1f569575 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -449,7 +449,7 @@ static void resetConf(void) #ifdef ALIENWII32 featureSet(FEATURE_RX_SERIAL); featureSet(FEATURE_MOTOR_STOP); - featureSet(FEATURE_FAILSAVE); + featureSet(FEATURE_FAILSAFE); masterConfig.serialConfig.serial_port_scenario[1] = lookupScenarioIndex(SCENARIO_SERIAL_RX_ONLY); masterConfig.rxConfig.serialrx_provider = 1; masterConfig.rxConfig.spektrum_sat_bind = 5; From 5401092afaabf3b19391c3da8d3fb3fc211df889 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Sun, 28 Dec 2014 00:46:24 +0000 Subject: [PATCH 28/35] Improve SBus code. Fix SBus Failsafe detection, tested with FrSky X8R and X4RSB. Check for end-byte to improve robustness. Less logic. Better definition of frame structure eliminates the '-1's. --- src/main/rx/sbus.c | 105 +++++++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 36 deletions(-) diff --git a/src/main/rx/sbus.c b/src/main/rx/sbus.c index d6e9247f6..71c543c4a 100644 --- a/src/main/rx/sbus.c +++ b/src/main/rx/sbus.c @@ -35,9 +35,14 @@ #include "rx/rx.h" #include "rx/sbus.h" +#define DEBUG_SBUS_PACKETS + + #define SBUS_MAX_CHANNEL 16 #define SBUS_FRAME_SIZE 25 -#define SBUS_SYNCBYTE 0x0F + +#define SBUS_FRAME_BEGIN_BYTE 0x0F +#define SBUS_FRAME_END_BYTE 0x00 #define SBUS_BAUDRATE 100000 @@ -48,6 +53,7 @@ static uint16_t sbusReadRawRC(rxRuntimeConfig_t *rxRuntimeConfig, uint8_t chan); static uint32_t sbusChannelData[SBUS_MAX_CHANNEL]; static serialPort_t *sBusPort; +static uint32_t sbusSignalLostEventCount = 0; void sbusUpdateSerialRxFunctionConstraint(functionConstraint_t *functionConstraint) { @@ -71,7 +77,14 @@ bool sbusInit(rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig, rcReadRa return sBusPort != NULL; } -struct sbus_dat { +#define SBUS_FLAG_RESERVED_1 (1 << 0) +#define SBUS_FLAG_RESERVED_2 (1 << 1) +#define SBUS_FLAG_SIGNAL_LOSS (1 << 2) +#define SBUS_FLAG_FAILSAFE_ACTIVE (1 << 3) + +struct sbusFrame_s { + uint8_t syncByte; + // 176 bits of data (11 bits per channel * 16 channels) = 22 bytes. unsigned int chan0 : 11; unsigned int chan1 : 11; unsigned int chan2 : 11; @@ -88,39 +101,53 @@ struct sbus_dat { unsigned int chan13 : 11; unsigned int chan14 : 11; unsigned int chan15 : 11; + uint8_t flags; + uint8_t endByte; } __attribute__ ((__packed__)); typedef union { - uint8_t in[SBUS_FRAME_SIZE]; - struct sbus_dat msg; -} sbus_msg; + uint8_t bytes[SBUS_FRAME_SIZE]; + struct sbusFrame_s frame; +} sbusFrame_t; -static sbus_msg sbus; +static sbusFrame_t sbusFrame; // Receive ISR callback static void sbusDataReceive(uint16_t c) { - uint32_t sbusTime; - static uint32_t sbusTimeLast; - static uint8_t sbusFramePosition; +#ifdef DEBUG_SBUS_PACKETS + static uint8_t sbusUnusedFrameCount = 0; +#endif - sbusTime = micros(); - if ((sbusTime - sbusTimeLast) > 2500) // sbus2 fast timing + static uint8_t sbusFramePosition = 0; + static uint32_t sbusTimeoutAt = 0; + uint32_t now = millis(); + + if ((int32_t)(sbusTimeoutAt - now) < 0) { sbusFramePosition = 0; - sbusTimeLast = sbusTime; + } + sbusTimeoutAt = now + 2500; - if (sbusFramePosition == 0 && c != SBUS_SYNCBYTE) + sbusFrame.bytes[sbusFramePosition] = (uint8_t)c; + + if (sbusFramePosition == 0 && c != SBUS_FRAME_BEGIN_BYTE) { return; + } - sbusFrameDone = false; // lazy main loop didnt fetch the stuff - if (sbusFramePosition != 0) - sbus.in[sbusFramePosition - 1] = (uint8_t)c; + sbusFramePosition++; - if (sbusFramePosition == SBUS_FRAME_SIZE - 1) { - sbusFrameDone = true; + if (sbusFramePosition == SBUS_FRAME_SIZE) { + if (sbusFrame.frame.endByte == SBUS_FRAME_END_BYTE) { + sbusFrameDone = true; + } sbusFramePosition = 0; } else { - sbusFramePosition++; +#ifdef DEBUG_SBUS_PACKETS + if (sbusFrameDone) { + sbusUnusedFrameCount++; + } +#endif + sbusFrameDone = false; } } @@ -130,26 +157,32 @@ bool sbusFrameComplete(void) return false; } sbusFrameDone = false; - if ((sbus.in[SBUS_FRAME_SIZE - 3] >> 3) & 0x0001) { + + if (sbusFrame.frame.flags & SBUS_FLAG_SIGNAL_LOSS) { + // internal failsafe enabled and rx failsafe flag set + sbusSignalLostEventCount++; + } + if (sbusFrame.frame.flags & SBUS_FLAG_FAILSAFE_ACTIVE) { // internal failsafe enabled and rx failsafe flag set return false; } - sbusChannelData[0] = sbus.msg.chan0; - sbusChannelData[1] = sbus.msg.chan1; - sbusChannelData[2] = sbus.msg.chan2; - sbusChannelData[3] = sbus.msg.chan3; - sbusChannelData[4] = sbus.msg.chan4; - sbusChannelData[5] = sbus.msg.chan5; - sbusChannelData[6] = sbus.msg.chan6; - sbusChannelData[7] = sbus.msg.chan7; - sbusChannelData[8] = sbus.msg.chan8; - sbusChannelData[9] = sbus.msg.chan9; - sbusChannelData[10] = sbus.msg.chan10; - sbusChannelData[11] = sbus.msg.chan11; - sbusChannelData[12] = sbus.msg.chan12; - sbusChannelData[13] = sbus.msg.chan13; - sbusChannelData[14] = sbus.msg.chan14; - sbusChannelData[15] = sbus.msg.chan15; + + sbusChannelData[0] = sbusFrame.frame.chan0; + sbusChannelData[1] = sbusFrame.frame.chan1; + sbusChannelData[2] = sbusFrame.frame.chan2; + sbusChannelData[3] = sbusFrame.frame.chan3; + sbusChannelData[4] = sbusFrame.frame.chan4; + sbusChannelData[5] = sbusFrame.frame.chan5; + sbusChannelData[6] = sbusFrame.frame.chan6; + sbusChannelData[7] = sbusFrame.frame.chan7; + sbusChannelData[8] = sbusFrame.frame.chan8; + sbusChannelData[9] = sbusFrame.frame.chan9; + sbusChannelData[10] = sbusFrame.frame.chan10; + sbusChannelData[11] = sbusFrame.frame.chan11; + sbusChannelData[12] = sbusFrame.frame.chan12; + sbusChannelData[13] = sbusFrame.frame.chan13; + sbusChannelData[14] = sbusFrame.frame.chan14; + sbusChannelData[15] = sbusFrame.frame.chan15; return true; } From 10d507ccc6a963d38cb3a599c51cbb16d1372f05 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Sun, 28 Dec 2014 00:47:29 +0000 Subject: [PATCH 29/35] LedStrip failsafe warning now correctly checks that the feature is enabled. --- src/main/io/ledstrip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/io/ledstrip.c b/src/main/io/ledstrip.c index 37949dc94..5c6b3880e 100644 --- a/src/main/io/ledstrip.c +++ b/src/main/io/ledstrip.c @@ -573,7 +573,7 @@ void applyLedWarningLayer(uint8_t updateNow) if (feature(FEATURE_VBAT) && calculateBatteryState() != BATTERY_OK) { warningFlags |= WARNING_FLAG_LOW_BATTERY; } - if (failsafe->vTable->hasTimerElapsed()) { + if (feature(FEATURE_FAILSAFE) && failsafe->vTable->hasTimerElapsed()) { warningFlags |= WARNING_FLAG_FAILSAFE; } if (!ARMING_FLAG(ARMED) && !ARMING_FLAG(OK_TO_ARM)) { From 4e2b9c22a66b9e801b04dee3c864dcd4926b64dc Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Sun, 28 Dec 2014 00:47:42 +0000 Subject: [PATCH 30/35] Update failsafe documentation. --- docs/Failsafe.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/Failsafe.md b/docs/Failsafe.md index 915d504cb..a5fafa4b6 100644 --- a/docs/Failsafe.md +++ b/docs/Failsafe.md @@ -22,9 +22,15 @@ The failsafe system attempts to detect when your receiver looses signal. It the The failsafe is activated when: +Either: a) no valid channel data from the RX via Serial RX. b) the first 4 Parallel PWM/PPM channels do not have valid signals. +And: +c) the failsafe guard time specified by `failsafe_delay` has elapsed. + +## Configuration + There are a few settings for it, as below. Failsafe delays are configured in 0.1 second steps. From b9771105152da82ab05d7c26a215b5783469d614 Mon Sep 17 00:00:00 2001 From: Akfreak Date: Sat, 27 Dec 2014 21:44:03 -0800 Subject: [PATCH 31/35] Update README.md I think we need a link to the Cleanflight releases in the Read Me. --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 898acc727..ab3e94edf 100644 --- a/README.md +++ b/README.md @@ -118,4 +118,7 @@ https://travis-ci.org/cleanflight/cleanflight [![Build Status](https://travis-ci.org/cleanflight/cleanflight.svg?branch=master)](https://travis-ci.org/cleanflight/cleanflight) +## Cleanflight Releases +https://github.com/cleanflight/cleanflight/releases + From 2b90f675b2e9d3d07b50dee8dbe1fc3a1235b203 Mon Sep 17 00:00:00 2001 From: Michael Jakob Date: Sun, 28 Dec 2014 12:45:15 +0100 Subject: [PATCH 32/35] Support ALIENWIIF1 as an separate target This will allow to build an HEX file independently to the NAZE target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An ALIENWIIF3 may also come in the future based on STM32F303. Both likely will share the same default settings. This is why I don’t use ALIENWII32 as target name yet. --- .travis.yml | 1 + Makefile | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9ef497f54..a456e51de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ env: - TARGET=PORT103R - TARGET=SPARKY - TARGET=STM32F3DISCOVERY + - TARGET=ALIENWIIF1 language: c compiler: arm-none-eabi-gcc before_install: sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded && sudo apt-get update diff --git a/Makefile b/Makefile index 735281011..1b4f18ba8 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ SERIAL_DEVICE ?= /dev/ttyUSB0 FORKNAME = cleanflight -VALID_TARGETS = NAZE NAZE32PRO OLIMEXINO STM32F3DISCOVERY CHEBUZZF3 CC3D CJMCU EUSTM32F103RC MASSIVEF3 PORT103R SPARKY +VALID_TARGETS = NAZE NAZE32PRO OLIMEXINO STM32F3DISCOVERY CHEBUZZF3 CC3D CJMCU EUSTM32F103RC MASSIVEF3 PORT103R SPARKY ALIENWIIF1 # Valid targets for OP BootLoader support OPBL_VALID_TARGETS = CC3D @@ -152,6 +152,12 @@ endif TARGET_DIR = $(ROOT)/src/main/target/$(TARGET) TARGET_SRC = $(notdir $(wildcard $(TARGET_DIR)/*.c)) +ifeq ($(TARGET),ALIENWIIF1) +# ALIENWIIF1 is a VARIANT of NAZE +TARGET_FLAGS := $(TARGET_FLAGS) -DNAZE -DALIENWII32 +TARGET_DIR = $(ROOT)/src/main/target/NAZE +endif + INCLUDE_DIRS := $(INCLUDE_DIRS) \ $(TARGET_DIR) @@ -251,6 +257,8 @@ NAZE_SRC = startup_stm32f10x_md_gcc.S \ $(HIGHEND_SRC) \ $(COMMON_SRC) +ALIENWIIF1_SRC = $(NAZE_SRC) + EUSTM32F103RC_SRC = startup_stm32f10x_hd_gcc.S \ drivers/accgyro_adxl345.c \ drivers/accgyro_bma280.c \ From 98343af7a2f4d60d7b06207fda54c84d4eb55397 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 2 Jan 2015 18:31:51 +0000 Subject: [PATCH 33/35] Break MSP_API_VERSION into smaller more specific commands. Bump MSP API version to 1.1. Set FC version to 1.4 to match next release. --- src/main/io/serial_msp.c | 74 +++++++++++++++++++--------------------- src/main/version.h | 2 +- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index ca74d0c08..42eb50853 100644 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -98,7 +98,7 @@ void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions, es * API consumers should ALWAYS handle communication failures gracefully and attempt to continue * without the information if possible. Clients MAY log/display a suitable message. * - * API clients should NOT attempt any communication if they can't handle the API MAJOR VERSION. + * API clients should NOT attempt any communication if they can't handle the returned API MAJOR VERSION. * * API clients SHOULD attempt communication if the API MINOR VERSION has increased from the time * the API client was written and handle command failures gracefully. Clients MAY disable @@ -121,7 +121,7 @@ void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions, es #define MSP_PROTOCOL_VERSION 0 #define API_VERSION_MAJOR 1 // increment when major changes are made -#define API_VERSION_MINOR 0 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR +#define API_VERSION_MINOR 1 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR #define API_VERSION_LENGTH 2 @@ -154,21 +154,11 @@ const char *boardIdentifier = TARGET_BOARD_IDENTIFIER; #define CAP_NAVCAP ((uint32_t)1 << 4) #define CAP_EXTAUX ((uint32_t)1 << 5) -/** - * Returns MSP protocol version - * API version - * Flight Controller Identifier - * Flight Controller build version (major, minor, patchlevel) - * Board Identifier - * Board Hardware Revision - * Build Date - "MMM DD YYYY" MMM = Jan/Feb/... - * Build Time - "HH:MM:SS" - * SCM reference length - * SCM reference (git revision, svn commit id) - * Additional FC information length - * Additional FC information (as decided by the FC, for FC specific tools to use as required) - **/ #define MSP_API_VERSION 1 //out message +#define MSP_FC_VARIANT 2 //out message +#define MSP_FC_VERSION 3 //out message +#define MSP_BOARD_INFO 4 //out message +#define MSP_BUILD_INFO 5 //out message // // MSP commands for Cleanflight original features @@ -214,13 +204,13 @@ const char *boardIdentifier = TARGET_BOARD_IDENTIFIER; // FIXME - Provided for backwards compatibility with configurator code until configurator is updated. // DEPRECATED - DO NOT USE "MSP_CONFIG" and MSP_SET_CONFIG. In Cleanflight, isolated commands already exist and should be used instead. -#define MSP_CONFIG 66 //out message baseflight-specific settings that aren't covered elsewhere -#define MSP_SET_CONFIG 67 //in message baseflight-specific settings save +#define MSP_BF_CONFIG 66 //out message baseflight-specific settings that aren't covered elsewhere +#define MSP_BF_SET_CONFIG 67 //in message baseflight-specific settings save #define MSP_REBOOT 68 //in message reboot settings -// DEPRECATED - Use MSP_API_VERSION instead -#define MSP_BUILD_INFO 69 //out message build date as well as some space for future expansion +// DEPRECATED - Use MSP_BUILD_INFO instead +#define MSP_BF_BUILD_INFO 69 //out message build date as well as some space for future expansion // // Multwii original MSP commands @@ -657,35 +647,37 @@ static bool processOutCommand(uint8_t cmdMSP) switch (cmdMSP) { case MSP_API_VERSION: - // the components of this command are in an order such that future changes could be made to it without breaking clients. - // i.e. most important first. headSerialReply( 1 + // protocol version length - API_VERSION_LENGTH + - FLIGHT_CONTROLLER_IDENTIFIER_LENGTH + - FLIGHT_CONTROLLER_VERSION_LENGTH + - BOARD_IDENTIFIER_LENGTH + - BOARD_HARDWARE_REVISION_LENGTH + - BUILD_DATE_LENGTH + - BUILD_TIME_LENGTH + - 1 + // scm reference length - GIT_SHORT_REVISION_LENGTH + - 1 // additional FC specific length - // no addition FC specific data yet. + API_VERSION_LENGTH ); serialize8(MSP_PROTOCOL_VERSION); serialize8(API_VERSION_MAJOR); serialize8(API_VERSION_MINOR); + break; + + case MSP_FC_VARIANT: + headSerialReply(FLIGHT_CONTROLLER_IDENTIFIER_LENGTH); for (i = 0; i < FLIGHT_CONTROLLER_IDENTIFIER_LENGTH; i++) { serialize8(flightControllerIdentifier[i]); } + break; + + case MSP_FC_VERSION: + headSerialReply(FLIGHT_CONTROLLER_VERSION_LENGTH); serialize8(FC_VERSION_MAJOR); serialize8(FC_VERSION_MINOR); serialize8(FC_VERSION_PATCH_LEVEL); + break; + case MSP_BOARD_INFO: + headSerialReply( + BOARD_IDENTIFIER_LENGTH + + BOARD_HARDWARE_REVISION_LENGTH + ); for (i = 0; i < BOARD_IDENTIFIER_LENGTH; i++) { serialize8(boardIdentifier[i]); } @@ -694,6 +686,14 @@ static bool processOutCommand(uint8_t cmdMSP) #else serialize16(0); // No other build targets currently have hardware revision detection. #endif + break; + + case MSP_BUILD_INFO: + headSerialReply( + BUILD_DATE_LENGTH + + BUILD_TIME_LENGTH + + GIT_SHORT_REVISION_LENGTH + ); for (i = 0; i < BUILD_DATE_LENGTH; i++) { serialize8(buildDate[i]); @@ -702,11 +702,9 @@ static bool processOutCommand(uint8_t cmdMSP) serialize8(buildTime[i]); } - serialize8(GIT_SHORT_REVISION_LENGTH); for (i = 0; i < GIT_SHORT_REVISION_LENGTH; i++) { serialize8(shortGitRevision[i]); } - serialize8(0); // No flight controller specific information to follow. break; // DEPRECATED - Use MSP_API_VERSION @@ -1052,7 +1050,7 @@ static bool processOutCommand(uint8_t cmdMSP) serialize8(masterConfig.rxConfig.rcmap[i]); break; - case MSP_CONFIG: + case MSP_BF_CONFIG: headSerialReply(1 + 4 + 1 + 2 + 2 + 2 + 2 + 2); serialize8(masterConfig.mixerMode); @@ -1090,7 +1088,7 @@ static bool processOutCommand(uint8_t cmdMSP) } break; #endif - case MSP_BUILD_INFO: + case MSP_BF_BUILD_INFO: headSerialReply(11 + 4 + 4); for (i = 0; i < 11; i++) serialize8(buildDate[i]); // MMM DD YYYY as ascii, MMM = Jan/Feb... etc @@ -1368,7 +1366,7 @@ static bool processInCommand(void) } break; - case MSP_SET_CONFIG: + case MSP_BF_SET_CONFIG: #ifdef USE_QUAD_MIXER_ONLY read8(); // mixerMode ignored diff --git a/src/main/version.h b/src/main/version.h index 841d91068..1872c1f89 100644 --- a/src/main/version.h +++ b/src/main/version.h @@ -16,7 +16,7 @@ */ #define FC_VERSION_MAJOR 1 // increment when a major release is made (big new feature, etc) -#define FC_VERSION_MINOR 0 // increment when a minor release is made (small new feature, change etc) +#define FC_VERSION_MINOR 4 // increment when a minor release is made (small new feature, change etc) #define FC_VERSION_PATCH_LEVEL 0 // increment when a bug is fixed #define MW_VERSION 231 From 98b258e83f59d2f89f66526ffa74c15719e905d1 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 2 Jan 2015 19:20:30 +0000 Subject: [PATCH 34/35] Ensure that rcRate great than 1.0 doesn't cause stability issues when aircraft is inverted. See #281. --- src/main/flight/flight.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/flight/flight.c b/src/main/flight/flight.c index f6dea18ce..22ee35fc9 100644 --- a/src/main/flight/flight.c +++ b/src/main/flight/flight.c @@ -189,7 +189,8 @@ static void pidMultiWii(pidProfile_t *pidProfile, controlRateConfig_t *controlRa UNUSED(controlRateConfig); // **** PITCH & ROLL & YAW PID **** - prop = max(abs(rcCommand[PITCH]), abs(rcCommand[ROLL])); // range [0;500] + prop = min(max(abs(rcCommand[PITCH]), abs(rcCommand[ROLL])), 500); // range [0;500] + for (axis = 0; axis < 3; axis++) { if ((FLIGHT_MODE(ANGLE_MODE) || FLIGHT_MODE(HORIZON_MODE)) && (axis == FD_ROLL || axis == FD_PITCH)) { // MODE relying on ACC // observe max inclination From 73e82b8446aad4bef4e6496cc9a2c6948ff08db2 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Sat, 3 Jan 2015 00:54:24 +0000 Subject: [PATCH 35/35] Adding new (private) MSP commands for configurating serial port scenarios and baud rates. --- src/main/io/serial.c | 11 +++++---- src/main/io/serial.h | 37 ++++++------------------------ src/main/io/serial_msp.c | 43 ++++++++++++++++++++++++++++++++--- src/main/target/NAZE/target.h | 2 +- 4 files changed, 54 insertions(+), 39 deletions(-) diff --git a/src/main/io/serial.c b/src/main/io/serial.c index 4f569b8aa..a05894189 100644 --- a/src/main/io/serial.c +++ b/src/main/io/serial.c @@ -81,7 +81,7 @@ static serialPortFunction_t serialPortFunctions[SERIAL_PORT_COUNT] = { #endif }; -static const serialPortConstraint_t serialPortConstraints[SERIAL_PORT_COUNT] = { +const serialPortConstraint_t serialPortConstraints[SERIAL_PORT_COUNT] = { {SERIAL_PORT_USB_VCP, 9600, 115200, SPF_NONE }, {SERIAL_PORT_USART1, 9600, 115200, SPF_NONE | SPF_SUPPORTS_SBUS_MODE | SPF_SUPPORTS_BIDIR_MODE}, {SERIAL_PORT_USART2, 9600, 115200, SPF_SUPPORTS_CALLBACK | SPF_SUPPORTS_SBUS_MODE | SPF_SUPPORTS_BIDIR_MODE}, @@ -102,7 +102,7 @@ static serialPortFunction_t serialPortFunctions[SERIAL_PORT_COUNT] = { {SERIAL_PORT_SOFTSERIAL1, NULL, SCENARIO_UNUSED, FUNCTION_NONE} }; -static const serialPortConstraint_t serialPortConstraints[SERIAL_PORT_COUNT] = { +const serialPortConstraint_t serialPortConstraints[SERIAL_PORT_COUNT] = { {SERIAL_PORT_USART1, 9600, 115200, SPF_NONE | SPF_SUPPORTS_SBUS_MODE | SPF_SUPPORTS_BIDIR_MODE}, {SERIAL_PORT_USART3, 9600, 115200, SPF_SUPPORTS_CALLBACK | SPF_SUPPORTS_SBUS_MODE | SPF_SUPPORTS_BIDIR_MODE}, {SERIAL_PORT_SOFTSERIAL1, 9600, 19200, SPF_SUPPORTS_CALLBACK | SPF_IS_SOFTWARE_INVERTABLE} @@ -118,7 +118,7 @@ static serialPortFunction_t serialPortFunctions[SERIAL_PORT_COUNT] = { #endif }; -static const serialPortConstraint_t serialPortConstraints[SERIAL_PORT_COUNT] = { +const serialPortConstraint_t serialPortConstraints[SERIAL_PORT_COUNT] = { {SERIAL_PORT_USART1, 9600, 115200, SPF_NONE | SPF_SUPPORTS_SBUS_MODE | SPF_SUPPORTS_BIDIR_MODE}, {SERIAL_PORT_USART2, 9600, 115200, SPF_SUPPORTS_CALLBACK | SPF_SUPPORTS_SBUS_MODE | SPF_SUPPORTS_BIDIR_MODE}, #if (SERIAL_PORT_COUNT > 2) @@ -544,9 +544,10 @@ serialPort_t *findSharedSerialPort(serialPortFunction_e functionToUse, uint16_t void applySerialConfigToPortFunctions(serialConfig_t *serialConfig) { - uint32_t portIndex = 0, serialPortIdentifier; + uint32_t portIndex = 0, serialPortIdentifier, constraintIndex; - for (serialPortIdentifier = 0; serialPortIdentifier < SERIAL_PORT_IDENTIFIER_COUNT && portIndex < SERIAL_PORT_COUNT; serialPortIdentifier++) { + for (constraintIndex = 0; constraintIndex < SERIAL_PORT_COUNT && portIndex < SERIAL_PORT_COUNT; constraintIndex++) { + serialPortIdentifier = serialPortConstraints[constraintIndex].identifier; uint32_t functionIndex = lookupSerialPortFunctionIndexByIdentifier(serialPortIdentifier); if (functionIndex == IDENTIFIER_NOT_FOUND) { continue; diff --git a/src/main/io/serial.h b/src/main/io/serial.h index 043d2c486..854044421 100644 --- a/src/main/io/serial.h +++ b/src/main/io/serial.h @@ -73,42 +73,18 @@ typedef enum { #endif } serialPortIndex_e; - -#ifdef STM32F303xC - -typedef enum { - SERIAL_PORT_USB_VCP = 0, - SERIAL_PORT_USART1, - SERIAL_PORT_USART2, - SERIAL_PORT_USART3, - SERIAL_PORT_USART4 -} serialPortIdentifier_e; - -#define SERIAL_PORT_IDENTIFIER_COUNT 5 -#else - -#ifdef CC3D - -typedef enum { - SERIAL_PORT_USART1 = 0, - SERIAL_PORT_USART3, - SERIAL_PORT_SOFTSERIAL1, -} serialPortIdentifier_e; - -#define SERIAL_PORT_IDENTIFIER_COUNT 3 -#else - +// serial port identifiers are now fixed, these values are used by MSP commands. typedef enum { SERIAL_PORT_USART1 = 0, SERIAL_PORT_USART2, SERIAL_PORT_USART3, - SERIAL_PORT_SOFTSERIAL1, - SERIAL_PORT_SOFTSERIAL2 + SERIAL_PORT_USART4, + SERIAL_PORT_USB_VCP = 20, + SERIAL_PORT_SOFTSERIAL1 = 30, + SERIAL_PORT_SOFTSERIAL2, + SERIAL_PORT_IDENTIFIER_MAX = SERIAL_PORT_SOFTSERIAL2 } serialPortIdentifier_e; -#define SERIAL_PORT_IDENTIFIER_COUNT 5 -#endif -#endif // bitmask typedef enum { @@ -125,6 +101,7 @@ typedef struct serialPortConstraint_s { uint32_t maxBaudRate; serialPortFeature_t feature; } serialPortConstraint_t; +extern const serialPortConstraint_t serialPortConstraints[SERIAL_PORT_COUNT]; typedef struct serialPortFunction_s { serialPortIdentifier_e identifier; diff --git a/src/main/io/serial_msp.c b/src/main/io/serial_msp.c index 42eb50853..b43409bf5 100644 --- a/src/main/io/serial_msp.c +++ b/src/main/io/serial_msp.c @@ -196,6 +196,10 @@ const char *boardIdentifier = TARGET_BOARD_IDENTIFIER; #define MSP_ADJUSTMENT_RANGES 52 #define MSP_SET_ADJUSTMENT_RANGE 53 +// private - only to be used by the configurator, the commands are likely to change +#define MSP_CF_SERIAL_CONFIG 54 +#define MSP_SET_CF_SERIAL_CONFIG 55 + // // Baseflight MSP commands (if enabled they exist in Cleanflight) // @@ -203,9 +207,9 @@ const char *boardIdentifier = TARGET_BOARD_IDENTIFIER; #define MSP_SET_RX_MAP 65 //in message set rx map, numchannels to set comes from MSP_RX_MAP // FIXME - Provided for backwards compatibility with configurator code until configurator is updated. -// DEPRECATED - DO NOT USE "MSP_CONFIG" and MSP_SET_CONFIG. In Cleanflight, isolated commands already exist and should be used instead. +// DEPRECATED - DO NOT USE "MSP_BF_CONFIG" and MSP_SET_BF_CONFIG. In Cleanflight, isolated commands already exist and should be used instead. #define MSP_BF_CONFIG 66 //out message baseflight-specific settings that aren't covered elsewhere -#define MSP_BF_SET_CONFIG 67 //in message baseflight-specific settings save +#define MSP_SET_BF_CONFIG 67 //in message baseflight-specific settings save #define MSP_REBOOT 68 //in message reboot settings @@ -1066,6 +1070,21 @@ static bool processOutCommand(uint8_t cmdMSP) serialize16(masterConfig.batteryConfig.currentMeterOffset); break; + case MSP_CF_SERIAL_CONFIG: + headSerialReply( + ((sizeof(uint8_t) * 2) * SERIAL_PORT_COUNT) + + (sizeof(uint32_t) * 4) + ); + for (i = 0; i < SERIAL_PORT_COUNT; i++) { + serialize8(serialPortConstraints[i].identifier); + serialize8(masterConfig.serialConfig.serial_port_scenario[i]); + } + serialize32(masterConfig.serialConfig.msp_baudrate); + serialize32(masterConfig.serialConfig.cli_baudrate); + serialize32(masterConfig.serialConfig.gps_baudrate); + serialize32(masterConfig.serialConfig.gps_passthrough_baudrate); + break; + #ifdef LED_STRIP case MSP_LED_COLORS: headSerialReply(CONFIGURABLE_COLOR_COUNT * 4); @@ -1366,7 +1385,7 @@ static bool processInCommand(void) } break; - case MSP_BF_SET_CONFIG: + case MSP_SET_BF_CONFIG: #ifdef USE_QUAD_MIXER_ONLY read8(); // mixerMode ignored @@ -1387,6 +1406,24 @@ static bool processInCommand(void) masterConfig.batteryConfig.currentMeterOffset = read16(); break; + case MSP_SET_CF_SERIAL_CONFIG: + { + uint8_t baudRateSize = (sizeof(uint32_t) * 4); + uint8_t serialPortCount = currentPort->dataSize - baudRateSize; + if (serialPortCount != SERIAL_PORT_COUNT) { + headSerialError(0); + break; + } + for (i = 0; i < SERIAL_PORT_COUNT; i++) { + masterConfig.serialConfig.serial_port_scenario[i] = read8(); + } + masterConfig.serialConfig.msp_baudrate = read32(); + masterConfig.serialConfig.cli_baudrate = read32(); + masterConfig.serialConfig.gps_baudrate = read32(); + masterConfig.serialConfig.gps_passthrough_baudrate = read32(); + } + break; + #ifdef LED_STRIP case MSP_SET_LED_COLORS: for (i = 0; i < CONFIGURABLE_COLOR_COUNT; i++) { diff --git a/src/main/target/NAZE/target.h b/src/main/target/NAZE/target.h index dce2448db..453cb18e9 100644 --- a/src/main/target/NAZE/target.h +++ b/src/main/target/NAZE/target.h @@ -17,7 +17,7 @@ #pragma once -#define TARGET_BOARD_IDENTIFIER "AFNA" // AFroNAze - NAZE might be considerd misleading on Naze clones like the flip32. +#define TARGET_BOARD_IDENTIFIER "AFNA" // AFroNAze - NAZE might be considered misleading on Naze clones like the flip32. #define LED0_GPIO GPIOB #define LED0_PIN Pin_3 // PB3 (LED)