From ca15d7108f5bfe63b6dd272067f579cb29cbdbd1 Mon Sep 17 00:00:00 2001 From: pascallanger Date: Sat, 2 Nov 2019 20:51:41 +0100 Subject: [PATCH] Prep for HoTT protocol and fix STM32 seed --- Multiprotocol/Multi.txt | 1 + Multiprotocol/Multi_Names.ino | 6 +++++- Multiprotocol/Multiprotocol.h | 4 +++- Multiprotocol/Multiprotocol.ino | 26 +++++++++++++++++++++++--- Multiprotocol/Validate.h | 6 ++++++ Multiprotocol/_Config.h | 13 ++++++++----- 6 files changed, 46 insertions(+), 10 deletions(-) diff --git a/Multiprotocol/Multi.txt b/Multiprotocol/Multi.txt index 06ee328..f99ea1c 100644 --- a/Multiprotocol/Multi.txt +++ b/Multiprotocol/Multi.txt @@ -54,4 +54,5 @@ 54,Scanner 55,Frsky_RX 56,AFHDS2A_RX +57,HoTT 63,XN_DUMP,250K,1M,2M diff --git a/Multiprotocol/Multi_Names.ino b/Multiprotocol/Multi_Names.ino index 8c73f7d..e7c84f9 100644 --- a/Multiprotocol/Multi_Names.ino +++ b/Multiprotocol/Multi_Names.ino @@ -70,6 +70,7 @@ const char STR_FLYZONE[] ="FlyZone"; const char STR_SCANNER[] ="Scanner"; const char STR_FRSKY_RX[] ="FrSkyRX"; const char STR_AFHDS2A_RX[] ="FS2A_RX"; +const char STR_HOTT[] ="HoTT"; const char STR_XN297DUMP[] ="XN297DP"; const char STR_SUBTYPE_FLYSKY[] = "\x04""Std\0""V9x9""V6x6""V912""CX20"; @@ -122,7 +123,7 @@ enum #define NO_SUBTYPE nullptr const mm_protocol_definition multi_protocols[] = { -// Protocol as defined in pulses\modules_constants.h, number of sub_protocols - 1, Failsafe supported, Disable channel mapping supported, Subtype string, Option type +// Protocol number, Protocol String, Number of sub_protocols, Sub_protocol strings, Option type #if defined(FLYSKY_A7105_INO) {PROTO_FLYSKY, STR_FLYSKY, 5, STR_SUBTYPE_FLYSKY, OPTION_NONE }, #endif @@ -288,6 +289,9 @@ const mm_protocol_definition multi_protocols[] = { #if defined(AFHDS2A_RX_A7105_INO) {PROTO_AFHDS2A_RX, STR_AFHDS2A_RX,0, NO_SUBTYPE, OPTION_NONE }, #endif +#if defined(HOTT_CC2500_INO) + {PROTO_HOTT, STR_HOTT, 0, NO_SUBTYPE, OPTION_RFTUNE }, +#endif #if defined(XN297DUMP_NRF24L01_INO) {PROTO_XN297DUMP, STR_XN297DUMP, 3, STR_SUBTYPE_XN297DUMP, OPTION_NONE }, #endif diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 73be31d..af9c204 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 0 -#define VERSION_PATCH_LEVEL 30 +#define VERSION_PATCH_LEVEL 31 //****************** // Protocols @@ -83,6 +83,7 @@ enum PROTOCOLS PROTO_SCANNER = 54, // =>CC2500 PROTO_FRSKY_RX = 55, // =>CC2500 PROTO_AFHDS2A_RX= 56, // =>A7105 + PROTO_HOTT = 57, // =>CC2500 PROTO_XN297DUMP = 63, // =>NRF24L01 }; @@ -667,6 +668,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p -- SCANNER 54 FRSKY_RX 55 AFHDS2A_RX 56 + HOTT 57 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 c3a51da..3dcb562 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -319,7 +319,6 @@ void setup() pinMode(S4_pin,INPUT_PULLUP); //Random pins pinMode(PB0, INPUT_ANALOG); // set up pin for analog input - pinMode(PB1, INPUT_ANALOG); // set up pin for analog input //Timers init_HWTimer(); //0.5us @@ -437,10 +436,13 @@ void setup() modules_reset(); #ifndef ORANGE_TX - //Init the seed with a random value created from watchdog timer for all protocols requiring random values #ifdef STM32_BOARD - randomSeed((uint32_t)analogRead(PB0) << 10 | analogRead(PB1)); + uint32_t seed=0; + for(uint8_t i=0;i<4;i++) + seed=(seed<<8) | (analogRead(PB0)& 0xFF); + randomSeed(seed); #else + //Init the seed with a random value created from watchdog timer for all protocols requiring random values randomSeed(random_value()); #endif #endif @@ -501,6 +503,11 @@ void setup() if (protocol==PROTO_HITEC) option = FORCE_HITEC_TUNING; // Use config-defined tuning value for HITEC else + #endif + #if defined(FORCE_HOTT_TUNING) && defined(HOTT_CC2500_INO) + if (protocol==PROTO_HOTT) + option = FORCE_HOTT_TUNING; // Use config-defined tuning value for HOTT + else #endif option = (uint8_t)PPM_prot_line->option; // Use radio-defined option value @@ -1098,6 +1105,14 @@ static void protocol_init() remote_callback = ReadHITEC; break; #endif + #if defined(HOTT_CC2500_INO) + case PROTO_HOTT: + PE1_off; //antenna RF2 + PE2_on; + next_callback = initHOTT(); + remote_callback = ReadHOTT; + break; + #endif #if defined(SCANNER_CC2500_INO) case PROTO_SCANNER: PE1_off; @@ -1528,6 +1543,11 @@ void update_serial_data() if (protocol==PROTO_HITEC) option=FORCE_HITEC_TUNING; // Use config-defined tuning value for HITEC else + #endif + #if defined(FORCE_HOTT_TUNING) && defined(HOTT_CC2500_INO) + if (protocol==PROTO_HOTT) + option=FORCE_HOTT_TUNING; // Use config-defined tuning value for HOTT + else #endif option=rx_ok_buff[3]; // Use radio-defined option value diff --git a/Multiprotocol/Validate.h b/Multiprotocol/Validate.h index febca8b..c240c9a 100644 --- a/Multiprotocol/Validate.h +++ b/Multiprotocol/Validate.h @@ -104,6 +104,11 @@ #error "The SFHSS forced frequency tuning value is outside of the range -127..127." #endif #endif +#ifdef FORCE_HOTT_TUNING + #if ( FORCE_HOTT_TUNING < -127 ) || ( FORCE_HOTT_TUNING > 127 ) + #error "The HOTT 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 ) @@ -195,6 +200,7 @@ #undef XN297L_CC2500_EMU #undef SCANNER_CC2500_INO #undef FRSKY_RX_CC2500_INO + #undef HOTT_CC2500_INO #endif #ifndef NRF24L01_INSTALLED #undef BAYANG_NRF24L01_INO diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index 0af782c..305eba6 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -87,17 +87,18 @@ //#define ORANGE_TX_BLUE /** CC2500 Fine Frequency Tuning **/ -//For optimal performance the CC2500 RF module used by the FrSkyD, FrSkyV, FrSkyX, SFHSS, CORONA, Redpine and Hitec protocols needs to be tuned for each protocol. -//Initial tuning should be done via the radio menu with a genuine FrSky/Futaba/CORONA/Hitec/Redpine receiver. +//For optimal performance the CC2500 RF module used by the CORONA, FrSkyD, FrSkyV, FrSkyX, Hitec, HoTT, SFHSS and Redpine protocols needs to be tuned for each protocol. +//Initial tuning should be done via the radio menu with a genuine CORONA/FrSky/Hitec/HoTT/Futaba/Redpine receiver. //Once a good tuning value is found it can be set here and will override the radio's 'option' setting for all existing and new models which use that protocol. //For more information: https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/tree/master/docs/Frequency_Tuning.md //Uncomment the lines below (remove the "//") and set an appropriate value (replace the "0") to enable. Valid range is -127 to +127. +//#define FORCE_CORONA_TUNING 0 //#define FORCE_FRSKYD_TUNING 0 //#define FORCE_FRSKYV_TUNING 0 //#define FORCE_FRSKYX_TUNING 0 //#define FORCE_SFHSS_TUNING 0 -//#define FORCE_CORONA_TUNING 0 //#define FORCE_HITEC_TUNING 0 +//#define FORCE_HOTT_TUNING 0 //#define FORCE_REDPINE_TUNING 0 /** A7105 Fine Frequency Tuning **/ @@ -178,6 +179,7 @@ #define FRSKYX_CC2500_INO #define FRSKY_RX_CC2500_INO #define HITEC_CC2500_INO +//#define HOTT_CC2500_INO #define SCANNER_CC2500_INO #define SFHSS_CC2500_INO #define REDPINE_CC2500_INO @@ -283,8 +285,7 @@ //Send to OpenTX the current protocol and subprotocol names. Comment to disable. #define MULTI_NAMES //Sync OpenTX frames with the current protocol timing. This feature is only available on the STM32 module. Comment to disable. -//!!! Work in progress !!! Do not enable for internal module -//#define MULTI_SYNC +#define MULTI_SYNC //Comment a line to disable a specific protocol telemetry #define DSM_TELEMETRY // Forward received telemetry packet directly to TX to be decoded by er9x, erskyTX and OpenTX @@ -588,6 +589,8 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= { JJRCX1 X5C1 FQ777_951 + PROTO_HOTT + NONE PROTO_HUBSAN H107 H301