From 1ffb5c405b87c8f6d7ab9abf2399d9498d00b8b6 Mon Sep 17 00:00:00 2001 From: Pascal Langer Date: Sat, 17 Aug 2019 22:37:00 +0200 Subject: [PATCH] New protocol: Flyzone Models compatible with TX FZ-410 Protocol 53 No sub protocol --- Multiprotocol/A7105_SPI.ino | 73 ++++++++++++++++------ Multiprotocol/Flyzone_a7105.ino | 103 ++++++++++++++++++++++++++++++++ Multiprotocol/Multiprotocol.h | 8 ++- Multiprotocol/Multiprotocol.ino | 7 +++ Multiprotocol/Validate.h | 52 +++++++++++----- Multiprotocol/_Config.h | 12 ++-- Protocols_Details.md | 8 +++ 7 files changed, 223 insertions(+), 40 deletions(-) create mode 100644 Multiprotocol/Flyzone_a7105.ino diff --git a/Multiprotocol/A7105_SPI.ino b/Multiprotocol/A7105_SPI.ino index 6483886a4..ae58415b6 100644 --- a/Multiprotocol/A7105_SPI.ino +++ b/Multiprotocol/A7105_SPI.ino @@ -183,8 +183,8 @@ void A7105_AdjustLOBaseFreq(uint8_t cmd) #endif break; case PROTO_BUGS: - #ifdef FORCE_HUBSAN_TUNING - offset=(int16_t)FORCE_HUBSAN_TUNING; + #ifdef FORCE_BUGS_TUNING + offset=(int16_t)FORCE_BUGS_TUNING; #endif break; case PROTO_FLYSKY: @@ -192,6 +192,11 @@ void A7105_AdjustLOBaseFreq(uint8_t cmd) offset=(int16_t)FORCE_FLYSKY_TUNING; #endif break; + case PROTO_FLYZONE: + #ifdef FORCE_FLYZONE_TUNING + offset=(int16_t)FORCE_FLYZONE_TUNING; + #endif + break; case PROTO_AFHDS2A: #ifdef FORCE_AFHDS2A_TUNING offset=(int16_t)FORCE_AFHDS2A_TUNING; @@ -247,22 +252,6 @@ static void __attribute__((unused)) A7105_SetVCOBand(uint8_t vb1, uint8_t vb2) A7105_WriteReg(A7105_25_VCO_SBCAL_I, vb2 | 0x08); } -#ifdef HUBSAN_A7105_INO -const uint8_t PROGMEM HUBSAN_A7105_regs[] = { - 0xFF, 0x63, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF ,0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x05, 0x04, 0xFF, // 00 - 0f - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x2B, 0xFF, 0xFF, 0x62, 0x80, 0xFF, 0xFF, 0x0A, 0xFF, 0xFF, 0x07, // 10 - 1f - 0x17, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 20 - 2f - 0xFF, 0xFF // 30 - 31 -}; -#endif -#ifdef FLYSKY_A7105_INO -const uint8_t PROGMEM FLYSKY_A7105_regs[] = { - 0xff, 0x42, 0x00, 0x14, 0x00, 0xff, 0xff ,0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x05, 0x00, 0x50, // 00 - 0f - 0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x00, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x32, 0xc3, 0x0f, // 10 - 1f - 0x13, 0xc3, 0x00, 0xff, 0x00, 0x00, 0x3b, 0x00, 0x17, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00, // 20 - 2f - 0x01, 0x0f // 30 - 31 -}; -#endif #ifdef AFHDS2A_A7105_INO const uint8_t PROGMEM AFHDS2A_A7105_regs[] = { 0xFF, 0x42 | (1<<5), 0x00, 0x25, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3c, 0x05, 0x00, 0x50, // 00 - 0f @@ -279,6 +268,30 @@ const uint8_t PROGMEM BUGS_A7105_regs[] = { 0x01, 0x0f // 30 - 31 }; #endif +#ifdef FLYSKY_A7105_INO +const uint8_t PROGMEM FLYSKY_A7105_regs[] = { + 0xff, 0x42, 0x00, 0x14, 0x00, 0xff, 0xff ,0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x05, 0x00, 0x50, // 00 - 0f + 0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x00, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x32, 0xc3, 0x0f, // 10 - 1f + 0x13, 0xc3, 0x00, 0xff, 0x00, 0x00, 0x3b, 0x00, 0x17, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00, // 20 - 2f + 0x01, 0x0f // 30 - 31 +}; +#endif +#ifdef FLYZONE_A7105_INO +const uint8_t PROGMEM FLYZONE_A7105_regs[] = { + 0xff, 0x42, 0x00, 0x07, 0x00, 0xff, 0xff ,0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x05, 0x01, 0x50, // 00 - 0f + 0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x00, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x32, 0xc3, 0x1f, // 10 - 1f + 0x12, 0x00, 0x00, 0xff, 0x00, 0x00, 0x3a, 0x00, 0x3f, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00, // 20 - 2f + 0x01, 0x0f // 30 - 31 +}; +#endif +#ifdef HUBSAN_A7105_INO +const uint8_t PROGMEM HUBSAN_A7105_regs[] = { + 0xFF, 0x63, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF ,0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x05, 0x04, 0xFF, // 00 - 0f + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x2B, 0xFF, 0xFF, 0x62, 0x80, 0xFF, 0xFF, 0x0A, 0xFF, 0xFF, 0x07, // 10 - 1f + 0x17, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 20 - 2f + 0xFF, 0xFF // 30 - 31 +}; +#endif #define ID_NORMAL 0x55201041 #define ID_PLUS 0xAA201041 @@ -287,6 +300,14 @@ void A7105_Init(void) uint8_t *A7105_Regs=0; uint8_t vco_calibration0, vco_calibration1; + #ifdef FLYZONE_A7105_INO + if(protocol==PROTO_FLYZONE) + { + A7105_Regs=(uint8_t*)FLYZONE_A7105_regs; + A7105_WriteID(0x25A53C45); + } + else + #endif #ifdef BUGS_A7105_INO if(protocol==PROTO_BUGS) A7105_Regs=(uint8_t*)BUGS_A7105_regs; @@ -360,7 +381,21 @@ void A7105_Init(void) A7105_SetVCOBand(vco_calibration0 & 0x07, vco_calibration1 & 0x07); // Set calibration band value to best match else if(protocol!=PROTO_HUBSAN) - A7105_WriteReg(A7105_25_VCO_SBCAL_I,protocol==PROTO_FLYSKY?0x08:0x0A); //Reset VCO Band calibration + { + switch(protocol) + { + case PROTO_FLYSKY: + vco_calibration1=0x08; + break; + case PROTO_FLYZONE: + vco_calibration1=0x02; + break; + default: + vco_calibration1=0x0A; + break; + } + A7105_WriteReg(A7105_25_VCO_SBCAL_I,vco_calibration1); //Reset VCO Band calibration + } A7105_SetTxRxMode(TX_EN); A7105_SetPower(); diff --git a/Multiprotocol/Flyzone_a7105.ino b/Multiprotocol/Flyzone_a7105.ino new file mode 100644 index 000000000..24c69ee5c --- /dev/null +++ b/Multiprotocol/Flyzone_a7105.ino @@ -0,0 +1,103 @@ +/* + This project is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Multiprotocol is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Multiprotocol. If not, see . + */ +// Compatible with FZ-410 TX + +#if defined(FLYZONE_A7105_INO) + +#include "iface_a7105.h" + +//#define FLYZONE_FORCEID + +#define FLYZONE_BIND_COUNT 220 // 5 sec +#define FLYZONE_BIND_CH 0x18 // TX, RX for bind end is 0x17 + +static void __attribute__((unused)) flyzone_build_packet() +{ + packet[0] = 0xA5; + packet[1] = rx_tx_addr[2]; + packet[2] = rx_tx_addr[3]; + packet[3] = convert_channel_8b(AILERON); //00..80..FF + packet[4] = convert_channel_8b(ELEVATOR); //00..80..FF + packet[5] = convert_channel_8b(THROTTLE); //00..FF + packet[6] = convert_channel_8b(RUDDER); //00..80..FF + packet[7] = 0xFF; +} + +uint16_t ReadFlyzone() +{ + #ifndef FORCE_FLYZONE_TUNING + A7105_AdjustLOBaseFreq(1); + #endif + if(IS_BIND_IN_PROGRESS) + { + packet[0] = 0x1B; + packet[1] = rx_tx_addr[2]; + packet[2] = rx_tx_addr[3]; + A7105_WriteData(3, FLYZONE_BIND_CH); + if (bind_counter--==0) + BIND_DONE; + return 22700; + } + else + { + if(phase>19) + { + phase=0; + flyzone_build_packet(); + A7105_WriteData(8, hopping_frequency[0]); + A7105_SetPower(); + } + else + { + A7105_WriteReg(A7105_0F_PLL_I, hopping_frequency[(phase&0x02)>>1]); + A7105_Strobe(A7105_TX); + } + phase++; + } + return 1500; +} + +uint16_t initFlyzone() +{ + A7105_Init(); + + hopping_frequency[0]=((random(0xfefefefe) & 0x0F)+2)<<2; + hopping_frequency[1]=hopping_frequency[0]+0x50; + + #ifdef FLYZONE_FORCEID + rx_tx_addr[2]=0x35; + rx_tx_addr[3]=0xD0; + hopping_frequency[0]=0x18; + hopping_frequency[1]=0x68; + #endif + + phase=255; + bind_counter = FLYZONE_BIND_COUNT; + return 2400; +} +#endif +// Normal packet is 8 bytes: 0xA5 0xAF 0x59 0x84 0x7A 0x00 0x80 0xFF +// Protocol is using AETR channel order, 1 byte per channel 00..80..FF including trim. Channels are in packet [3,4,5,6]. +// packet[0,1,2,7] values are constant in normal mode. +// packet[0]=0xA5 -> normal mode +// packet[1,2] ->ID +// packet[7]=0xFF -> ??? +// Channel values are updated every 30ms which is quite slow, slower than PPM... +// Packets are sent every 1500µs on 2 different channels. 2 times on first channel, 2 times on second channel and restart. The channels are changing between the files 0x08, 0x58 and 0x18, 0x68. +// +// Bind is sending 3 bytes on channel 0x18: 0x1B 0x35 0xD0 every 22.7ms +// packet[0]=0x1B -> bind mode +// packet[1,2] ->ID +// It listens for the model on channel 0x17 and recieves 0x1B 0x35 0xD0 when the plane accepts bind. \ No newline at end of file diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index c7c599e71..e081422ff 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_REVISION 1 -#define VERSION_PATCH_LEVEL 70 +#define VERSION_PATCH_LEVEL 71 //****************** // Protocols @@ -79,6 +79,7 @@ enum PROTOCOLS PROTO_REDPINE = 50, // =>CC2500 PROTO_POTENSIC = 51, // =>NRF24L01 PROTO_ZSX = 52, // =>NRF24L01 + PROTO_FLYZONE = 53, // =>A7105 PROTO_XN297DUMP = 63, // =>NRF24L01 }; @@ -90,6 +91,10 @@ enum Flysky V912 = 3, CX20 = 4, }; +enum Flyzone +{ + FZ410 = 0, +}; enum Hubsan { H107 = 0, @@ -630,6 +635,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p -- REDPINE 50 POTENSIC 51 ZSX 52 + FLYZONE 53 BindBit=> 0x80 1=Bind/0=No AutoBindBit=> 0x40 1=Yes /0=No RangeCheck=> 0x20 1=Yes /0=No diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index 113757287..ee98be127 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -933,6 +933,13 @@ static void protocol_init() remote_callback = ReadBUGS; break; #endif + #if defined(FLYZONE_A7105_INO) + case PROTO_FLYZONE: + PE1_off; //antenna RF1 + next_callback = initFlyzone(); + remote_callback = ReadFlyzone; + break; + #endif #endif #ifdef CC2500_INSTALLED #if defined(FRSKYD_CC2500_INO) diff --git a/Multiprotocol/Validate.h b/Multiprotocol/Validate.h index 4797f5c9a..c1ff289c7 100644 --- a/Multiprotocol/Validate.h +++ b/Multiprotocol/Validate.h @@ -62,6 +62,12 @@ #endif // Check forced tuning values are valid +//CC2500 +#ifdef FORCE_CORONA_TUNING + #if ( FORCE_CORONA_TUNING < -127 ) || ( FORCE_CORONA_TUNING > 127 ) + #error "The CORONA forced frequency tuning value is outside of the range -127..127." + #endif +#endif #ifdef FORCE_FRSKYD_TUNING #if ( FORCE_FRSKYD_TUNING < -127 ) || ( FORCE_FRSKYD_TUNING > 127 ) #error "The FrSkyD forced frequency tuning value is outside of the range -127..127." @@ -77,14 +83,9 @@ #error "The FrSkyX forced frequency tuning value is outside of the range -127..127." #endif #endif -#ifdef FORCE_SFHSS_TUNING - #if ( FORCE_SFHSS_TUNING < -127 ) || ( FORCE_SFHSS_TUNING > 127 ) - #error "The SFHSS forced frequency tuning value is outside of the range -127..127." - #endif -#endif -#ifdef FORCE_CORONA_TUNING - #if ( FORCE_CORONA_TUNING < -127 ) || ( FORCE_CORONA_TUNING > 127 ) - #error "The CORONA forced frequency tuning value is outside of the range -127..127." +#ifdef FORCE_HITEC_TUNING + #if ( FORCE_HITEC_TUNING < -127 ) || ( FORCE_HITEC_TUNING > 127 ) + #error "The HITEC forced frequency tuning value is outside of the range -127..127." #endif #endif #ifdef FORCE_REDPINE_TUNING @@ -92,9 +93,20 @@ #error "The REDPINE forced frequency tuning value is outside of the range -127..127." #endif #endif -#ifdef FORCE_HITEC_TUNING - #if ( FORCE_HITEC_TUNING < -127 ) || ( FORCE_HITEC_TUNING > 127 ) - #error "The HITEC forced frequency tuning value is outside of the range -127..127." +#ifdef FORCE_SFHSS_TUNING + #if ( FORCE_SFHSS_TUNING < -127 ) || ( FORCE_SFHSS_TUNING > 127 ) + #error "The SFHSS forced frequency tuning value is outside of the range -127..127." + #endif +#endif +//A7105 +#ifdef FORCE_AFHDS2A_TUNING + #if ( FORCE_AFHDS2A_TUNING < -300 ) || ( FORCE_AFHDS2A_TUNING > 300 ) + #error "The AFHDS2A forced frequency tuning value is outside of the range -300..300." + #endif +#endif +#ifdef FORCE_BUGS_TUNING + #if ( FORCE_BUGS_TUNING < -300 ) || ( FORCE_BUGS_TUNING > 300 ) + #error "The BUGS forced frequency tuning value is outside of the range -300..300." #endif #endif #ifdef FORCE_FLYSKY_TUNING @@ -102,20 +114,27 @@ #error "The Flysky forced frequency tuning value is outside of the range -300..300." #endif #endif +#ifdef FORCE_FLYZONE_TUNING + #if ( FORCE_FLYZONE_TUNING < -300 ) || ( FORCE_FLYZONE_TUNING > 300 ) + #error "The Flyzone forced frequency tuning value is outside of the range -300..300." + #endif +#endif #ifdef FORCE_HUBSAN_TUNING #if ( FORCE_HUBSAN_TUNING < -300 ) || ( FORCE_HUBSAN_TUNING > 300 ) #error "The Hubsan forced frequency tuning value is outside of the range -300..300." #endif #endif -#ifdef FORCE_AFHDS2A_TUNING - #if ( FORCE_AFHDS2A_TUNING < -300 ) || ( FORCE_AFHDS2A_TUNING > 300 ) - #error "The AFHDS2A forced frequency tuning value is outside of the range -300..300." - #endif -#endif + #ifndef USE_A7105_CH15_TUNING + #ifndef FORCE_BUGS_TUNING + #define FORCE_BUGS_TUNING 0 + #endif #ifndef FORCE_FLYSKY_TUNING #define FORCE_FLYSKY_TUNING 0 #endif + #ifndef FORCE_FLYZONE_TUNING + #define FORCE_FLYZONE_TUNING 0 + #endif #ifndef FORCE_HUBSAN_TUNING #define FORCE_HUBSAN_TUNING 0 #endif @@ -148,6 +167,7 @@ #undef HUBSAN_A7105_INO #undef AFHDS2A_A7105_INO #undef BUGS_A7105_INO + #undef FLYZONE_A7105_INO #endif #ifndef CYRF6936_INSTALLED #undef DEVO_CYRF6936_INO diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index a4bb62cf2..b1ea29539 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -108,10 +108,11 @@ //Once a good tuning value is found it can be set here and will override the frequency tuning for a specific protocol. //Uncomment the lines below (remove the "//") and set an appropriate value (replace the "0") to enable. Valid range is -300 to +300 and default is 0. +//#define FORCE_AFHDS2A_TUNING 0 +//#define FORCE_BUGS_TUNING 0 //#define FORCE_FLYSKY_TUNING 0 +//#define FORCE_FLYZONE_TUNING 0 //#define FORCE_HUBSAN_TUNING 0 -//#define FORCE_AFHDS2A_TUNING 0 -//#define FORCE_BUGS_TUNING 0 /** CYRF6936 Fine Frequency Tuning **/ //This is required in rare cases where some CYRF6936 modules and/or RXs have an inaccurate crystal oscillator. @@ -155,17 +156,18 @@ //The protocols below need an A7105 to be installed #define AFHDS2A_A7105_INO +#define BUGS_A7105_INO #define FLYSKY_A7105_INO +#define FLYZONE_A7105_INO #define HUBSAN_A7105_INO -#define BUGS_A7105_INO //The protocols below need a CYRF6936 to be installed #define DEVO_CYRF6936_INO #define DSM_CYRF6936_INO #define J6PRO_CYRF6936_INO +#define TRAXXAS_CYRF6936_INO #define WFLY_CYRF6936_INO #define WK2x01_CYRF6936_INO -#define TRAXXAS_CYRF6936_INO //The protocols below need a CC2500 to be installed #define CORONA_CC2500_INO @@ -530,6 +532,8 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= { V6X6 V912 CX20 + PROTO_FLYZONE + FZ410 PROTO_FQ777 NONE PROTO_FRSKYD diff --git a/Protocols_Details.md b/Protocols_Details.md index c0dd7f009..280b16685 100644 --- a/Protocols_Details.md +++ b/Protocols_Details.md @@ -84,6 +84,7 @@ CFlie|38|CFlie||||||||NRF24L01 [ESky150](Protocols_Details.md#ESKY150---35)|35|ESKY150||||||||NRF24L01 [Flysky](Protocols_Details.md#FLYSKY---1)|1|Flysky|V9x9|V6x6|V912|CX20||||A7105 [Flysky AFHDS2A](Protocols_Details.md#FLYSKY-AFHDS2A---28)|28|PWM_IBUS|PPM_IBUS|PWM_SBUS|PPM_SBUS|||||A7105 +[Flyzone](Protocols_Details.md#FLYZONE---53)|53|Flyzone|FZ410|||||||A7105 [FQ777](Protocols_Details.md#FQ777---23)|23|FQ777||||||||NRF24L01 [FrskyD](Protocols_Details.md#FRSKYD---3)|3|FrskyD||||||||CC2500 [FrskyV](Protocols_Details.md#FRSKYV---25)|25|FrskyV||||||||CC2500 @@ -186,6 +187,13 @@ Note that the RX ouput will be AETR whatever the input channel order is. ### Sub_protocol PWM_SBUS - *2* ### Sub_protocol PPM_SBUS - *3* +## FLYZONE - *53* +Models using the Flyzone FZ-410 TX: Fokker D.VII Micro EP RTF + +CH1|CH2|CH3|CH4 +---|---|---|--- +A|E|T|R + ## HUBSAN - *2* Telemetry enabled for battery voltage and TX RSSI