From 73aab88109fa44429fb17bf4a3728d4d6a63873c Mon Sep 17 00:00:00 2001 From: pascallanger Date: Tue, 20 Sep 2016 18:27:09 +0200 Subject: [PATCH] Some cleanning --- Multiprotocol/DSM_cyrf6936.ino | 12 +- Multiprotocol/Multiprotocol.h | 24 +- Multiprotocol/Multiprotocol.ino | 462 ++++++++++++++++-------------- Multiprotocol/SHENQI_nrf24l01.ino | 2 +- Multiprotocol/_Config.h | 107 ++++--- 5 files changed, 322 insertions(+), 285 deletions(-) diff --git a/Multiprotocol/DSM_cyrf6936.ino b/Multiprotocol/DSM_cyrf6936.ino index 609f6f6..2b31084 100644 --- a/Multiprotocol/DSM_cyrf6936.ino +++ b/Multiprotocol/DSM_cyrf6936.ino @@ -414,16 +414,23 @@ uint16_t ReadDsm() #define DSM_WRITE_DELAY 1550 // Time after write to verify write complete #define DSM_READ_DELAY 600 // Time before write to check read phase, and switch channels. Was 400 but 600 seems what the 328p needs to read a packet uint16_t start; - uint8_t rx_phase; - uint8_t len; + #if defined DSM_TELEMETRY + uint8_t rx_phase; + uint8_t len; + #endif switch(phase) { case DSM_BIND_WRITE: if(bind_counter--==0) + #if defined DSM_TELEMETRY phase=DSM_BIND_CHECK; //Check RX answer + #else + phase=DSM_CHANSEL; //Switch to normal mode + #endif CYRF_WriteDataPacket(packet); return 10000; + #if defined DSM_TELEMETRY case DSM_BIND_CHECK: CYRF_ConfigDataCode((const uint8_t *)"\x98\x88\x1B\xE4\x30\x79\x03\x84\xC9\x2C\x06\x93\x86\xB9\x9E", 16); CYRF_SetTxRxMode(RX_EN); //Receive mode @@ -467,6 +474,7 @@ uint16_t ReadDsm() CYRF_WriteRegister(CYRF_0F_XACT_CFG, 0x0C); // Read mode CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x83); // Prepare to receive return 7000; + #endif case DSM_CHANSEL: BIND_DONE; //Select channels and configure for writing data diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 1e19dac..02c7293 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -182,7 +182,7 @@ struct PPM_Parameters //******************* // TX -#define SERIAL_TX_pin 1 // PD1 +#define SERIAL_TX_pin 1 //PD1 #define SERIAL_TX_port PORTD #define SERIAL_TX_ddr DDRD #define SERIAL_TX_output SERIAL_TX_ddr |= _BV(SERIAL_TX_pin) @@ -201,12 +201,16 @@ struct PPM_Parameters // Dial #define MODE_DIAL1_pin 2 #define MODE_DIAL1_port PORTB +#define MODE_DIAL1_ipr PINB #define MODE_DIAL2_pin 3 #define MODE_DIAL2_port PORTB +#define MODE_DIAL2_ipr PINB #define MODE_DIAL3_pin 4 #define MODE_DIAL3_port PORTB +#define MODE_DIAL3_ipr PINB #define MODE_DIAL4_pin 0 #define MODE_DIAL4_port PORTC +#define MODE_DIAL4_ipr PINC // PPM #define PPM_pin 3 //D3 = PD3 @@ -223,7 +227,7 @@ struct PPM_Parameters #else #define SDI_on SDI_port |= _BV(SDI_pin) #define SDI_off SDI_port &= ~_BV(SDI_pin) - #define SDI_1 (SDI_ipr & _BV(SDI_pin)) != 0x00 + #define SDI_1 (SDI_ipr & _BV(SDI_pin)) #define SDI_0 (SDI_ipr & _BV(SDI_pin)) == 0x00 #endif #define SDI_input SDI_ddr &= ~_BV(SDI_pin) @@ -234,10 +238,10 @@ struct PPM_Parameters #define SDO_port PORTD #define SDO_ipr PIND #ifdef XMEGA - #define SDO_1 (SDO_port.IN & _BV(SDO_pin)) != 0x00 + #define SDO_1 (SDO_port.IN & _BV(SDO_pin)) #define SDO_0 (SDO_port.IN & _BV(SDO_pin)) == 0x00 #else - #define SDO_1 (SDO_ipr & _BV(SDO_pin)) != 0x00 + #define SDO_1 (SDO_ipr & _BV(SDO_pin)) #define SDO_0 (SDO_ipr & _BV(SDO_pin)) == 0x00 #endif @@ -245,7 +249,7 @@ struct PPM_Parameters #define SCLK_port PORTD #define SCLK_ddr DDRD #ifdef XMEGA - #define SCLK_pin 7 //D7 + #define SCLK_pin 7 //PD7 #define SCLK_on SCLK_port.OUTSET = _BV(SCLK_pin) #define SCLK_off SCLK_port.OUTCLR = _BV(SCLK_pin) #else @@ -259,7 +263,7 @@ struct PPM_Parameters #define A7105_CSN_pin 2 //D2 = PD2 #define A7105_CSN_port PORTD #define A7105_CSN_ddr DDRD -#define A7105_CSN_output A7105_CSN_ddr |= _BV(A7105_CSN_pin) +#define A7105_CSN_output A7105_CSN_ddr |= _BV(A7105_CSN_pin) #define A7105_CSN_on A7105_CSN_port |= _BV(A7105_CSN_pin) #define A7105_CSN_off A7105_CSN_port &= ~_BV(A7105_CSN_pin) @@ -283,7 +287,7 @@ struct PPM_Parameters // CYRF6936 #ifdef XMEGA - #define CYRF_CSN_pin 4 //D4 + #define CYRF_CSN_pin 4 //PD4 #define CYRF_CSN_port PORTD #define CYRF_CSN_ddr DDRD #define CYRF_CSN_on CYRF_CSN_port.OUTSET = _BV(CYRF_CSN_pin) @@ -335,7 +339,7 @@ struct PPM_Parameters #define LED_off LED_port.OUTSET = _BV(LED_pin) #define LED_toggle LED_port.OUTTGL = _BV(LED_pin) #define LED_output LED_port.DIRSET = _BV(LED_pin) - #define IS_LED_on ( (LED_port.OUT & _BV(LED_pin)) != 0x00 ) + #define IS_LED_on (LED_port.OUT & _BV(LED_pin)) #else #define LED_pin 5 //D13 = PB5 #define LED_port PORTB @@ -344,7 +348,7 @@ struct PPM_Parameters #define LED_off LED_port &= ~_BV(LED_pin) #define LED_toggle LED_port ^= _BV(LED_pin) #define LED_output LED_ddr |= _BV(LED_pin) - #define IS_LED_on ( (LED_port & _BV(LED_pin)) != 0x00 ) + #define IS_LED_on (LED_port & _BV(LED_pin)) #endif //BIND @@ -358,9 +362,9 @@ struct PPM_Parameters #define BIND_ipr PINB #define BIND_ddr DDRB #define BIND_SET_INPUT BIND_ddr &= ~_BV(BIND_pin) + #define BIND_SET_OUTPUT BIND_ddr |= _BV(BIND_pin) #define BIND_SET_PULLUP BIND_port |= _BV(BIND_pin) #define IS_BIND_BUTTON_on ( (BIND_ipr & _BV(BIND_pin)) == 0x00 ) - #define BIND_SET_OUTPUT BIND_ddr |= _BV(BIND_pin) #endif // Macros diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index 3139f3b..c4557da 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -30,10 +30,10 @@ #include "TX_Def.h" #ifdef XMEGA - #undef ENABLE_PPM // Disable PPM for orange module - #undef A7105_INSTALLED // Disable A7105 for orange module - #undef CC2500_INSTALLED // Disable CC2500 for orange module - #undef NRF24L01_INSTALLED // Disable NRF for orange module + #undef ENABLE_PPM // Disable PPM for OrangeTX module + #undef A7105_INSTALLED // Disable A7105 for OrangeTX module + #undef CC2500_INSTALLED // Disable CC2500 for OrangeTX module + #undef NRF24L01_INSTALLED // Disable NRF for OrangeTX module #endif //Global constants/variables @@ -97,23 +97,6 @@ volatile uint16_t PPM_data[NUM_CHN]; //Random variable volatile uint32_t gWDT_entropy=0; #endif -// Serial variables -#ifdef INVERT_TELEMETRY -// enable bit bash for serial - #ifndef XMEGA - #define BASH_SERIAL 1 - #endif - #define INVERT_SERIAL 1 -#endif -#define BAUD 100000 -#define RXBUFFER_SIZE 26 -#define TXBUFFER_SIZE 32 -volatile uint8_t rx_buff[RXBUFFER_SIZE]; -volatile uint8_t rx_ok_buff[RXBUFFER_SIZE]; -#ifndef BASH_SERIAL - volatile uint8_t tx_buff[TXBUFFER_SIZE]; -#endif -volatile uint8_t discard_frame = 0; //Serial protocol uint8_t sub_protocol; @@ -123,16 +106,54 @@ uint8_t cur_protocol[3]; uint8_t prev_option; uint8_t prev_power=0xFD; // unused power value +//Serial RX variables +#define BAUD 100000 +#define RXBUFFER_SIZE 26 +volatile uint8_t rx_buff[RXBUFFER_SIZE]; +volatile uint8_t rx_ok_buff[RXBUFFER_SIZE]; +volatile uint8_t discard_frame = 0; + +//Make sure telemetry is selected correctly +#ifndef TELEMETRY + #undef INVERT_TELEMETRY + #undef DSM_TELEMETRY + #undef SPORT_TELEMETRY + #undef HUB_TELEMETRY +#else + #if not defined(CYRF6936_INSTALLED) || not defined(DSM_CYRF6936_INO) + #undef DSM_TELEMETRY + #endif + #if (not defined(CC2500_INSTALLED) || not defined(FRSKYD_CC2500_INO)) && (not defined(A7105_INSTALLED) || not defined(HUBSAN_A7105_INO)) + #undef HUB_TELEMETRY + #endif + #if not defined(CC2500_INSTALLED) || not defined(FRSKYX_CC2500_INO) + #undef SPORT_TELEMETRY + #endif +#endif +#if not defined(DSM_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(SPORT_TELEMETRY) + #undef TELEMETRY + #undef INVERT_TELEMETRY +#endif + // Telemetry #define MAX_PKT 27 uint8_t pkt[MAX_PKT];//telemetry receiving packets #if defined(TELEMETRY) + #ifdef INVERT_TELEMETRY + // enable bit bash for serial + #ifndef XMEGA + #define BASH_SERIAL 1 + #endif + #define INVERT_SERIAL 1 + #endif uint8_t pass = 0; uint8_t pktt[MAX_PKT];//telemetry receiving packets -#ifndef BASH_SERIAL - volatile uint8_t tx_head=0; - volatile uint8_t tx_tail=0; -#endif // BASH_SERIAL + #ifndef BASH_SERIAL + #define TXBUFFER_SIZE 32 + volatile uint8_t tx_buff[TXBUFFER_SIZE]; + volatile uint8_t tx_head=0; + volatile uint8_t tx_tail=0; + #endif // BASH_SERIAL uint8_t v_lipo; int16_t RSSI_dBm; //const uint8_t RSSI_offset=72;//69 71.72 values db @@ -173,7 +194,7 @@ void setup() #else // General pinout // all inputs - DDRB=DDRC=DDRD=0x00; + DDRB=0x00;DDRC=0x00;DDRD=0x00; // outputs SDI_output; SCLK_output; @@ -192,7 +213,7 @@ void setup() #endif PE1_output; PE2_output; - SERIAL_TX_output; + //SERIAL_TX_output; // pullups MODE_DIAL1_port |= _BV(MODE_DIAL1_pin); @@ -216,12 +237,12 @@ void setup() #ifdef CC2500_INSTALLED CC25_CSN_on; #endif - #ifdef NRF24L01_INSTALLED - NRF_CSN_on; - #endif #ifdef CYRF6936_INSTALLED CYRF_CSN_on; #endif + #ifdef NRF24L01_INSTALLED + NRF_CSN_on; + #endif // Set SPI lines SDI_on; SCLK_off; @@ -246,12 +267,11 @@ void setup() #ifndef ENABLE_PPM mode_select = MODE_SERIAL ; // force serial mode #else - mode_select=0x0F - ( ( (PINB>>2)&0x07 ) | ( (PINC<<3)&0x08) );//encoder dip switches 1,2,4,8=>B2,B3,B4,C0 - /*mode_select = 0x0F - ( - ((MODE_DIAL1_port & MODE_DIAL1_pin) ? 1 : 0) + - ((MODE_DIAL2_port & MODE_DIAL2_pin) ? 2 : 0) + - ((MODE_DIAL3_port & MODE_DIAL3_pin) ? 4 : 0) + - ((MODE_DIAL4_port & MODE_DIAL4_pin) ? 8 : 0));*/ + mode_select = + ((MODE_DIAL1_ipr & _BV(MODE_DIAL1_pin)) ? 0 : 1) + + ((MODE_DIAL2_ipr & _BV(MODE_DIAL2_pin)) ? 0 : 2) + + ((MODE_DIAL3_ipr & _BV(MODE_DIAL3_pin)) ? 0 : 4) + + ((MODE_DIAL4_ipr & _BV(MODE_DIAL4_pin)) ? 0 : 8); #endif // Update LED @@ -407,7 +427,7 @@ void Update_All() #endif //ENABLE_PPM update_led_status(); #if defined(TELEMETRY) - if( (protocol==MODE_FRSKYD) || (protocol==MODE_HUBSAN) || (protocol==MODE_FRSKYX) || (protocol==MODE_DSM) ) + if((protocol==MODE_FRSKYD) || (protocol==MODE_HUBSAN) || (protocol==MODE_FRSKYX) || (protocol==MODE_DSM) ) TelemetryUpdate(); #endif } @@ -508,191 +528,199 @@ static void protocol_init() switch(protocol) // Init the requested protocol { - #if defined(FLYSKY_A7105_INO) - case MODE_FLYSKY: - PE1_off; //antenna RF1 - next_callback = initFlySky(); - remote_callback = ReadFlySky; - break; + #ifdef A7105_INSTALLED + #if defined(FLYSKY_A7105_INO) + case MODE_FLYSKY: + PE1_off; //antenna RF1 + next_callback = initFlySky(); + remote_callback = ReadFlySky; + break; + #endif + #if defined(HUBSAN_A7105_INO) + case MODE_HUBSAN: + PE1_off; //antenna RF1 + if(IS_BIND_BUTTON_FLAG_on) random_id(10,true); // Generate new ID if bind button is pressed. + next_callback = initHubsan(); + remote_callback = ReadHubsan; + break; + #endif #endif - #if defined(HUBSAN_A7105_INO) - case MODE_HUBSAN: - PE1_off; //antenna RF1 - if(IS_BIND_BUTTON_FLAG_on) random_id(10,true); // Generate new ID if bind button is pressed. - next_callback = initHubsan(); - remote_callback = ReadHubsan; - break; + #ifdef CC2500_INSTALLED + #if defined(FRSKYD_CC2500_INO) + case MODE_FRSKYD: + PE1_off; //antenna RF2 + PE2_on; + next_callback = initFrSky_2way(); + remote_callback = ReadFrSky_2way; + break; + #endif + #if defined(FRSKYV_CC2500_INO) + case MODE_FRSKYV: + PE1_off; //antenna RF2 + PE2_on; + next_callback = initFRSKYV(); + remote_callback = ReadFRSKYV; + break; + #endif + #if defined(FRSKYX_CC2500_INO) + case MODE_FRSKYX: + PE1_off; //antenna RF2 + PE2_on; + next_callback = initFrSkyX(); + remote_callback = ReadFrSkyX; + break; + #endif + #if defined(SFHSS_CC2500_INO) + case MODE_SFHSS: + PE1_off; //antenna RF2 + PE2_on; + next_callback = initSFHSS(); + remote_callback = ReadSFHSS; + break; + #endif #endif - #if defined(FRSKYD_CC2500_INO) - case MODE_FRSKYD: - PE1_off; //antenna RF2 - PE2_on; - next_callback = initFrSky_2way(); - remote_callback = ReadFrSky_2way; - break; - #endif - #if defined(FRSKYV_CC2500_INO) - case MODE_FRSKYV: - PE1_off; //antenna RF2 - PE2_on; - next_callback = initFRSKYV(); - remote_callback = ReadFRSKYV; - break; - #endif - #if defined(FRSKYX_CC2500_INO) - case MODE_FRSKYX: - PE1_off; //antenna RF2 - PE2_on; - next_callback = initFrSkyX(); - remote_callback = ReadFrSkyX; - break; - #endif - #if defined(SFHSS_CC2500_INO) - case MODE_SFHSS: - PE1_off; //antenna RF2 - PE2_on; - next_callback = initSFHSS(); - remote_callback = ReadSFHSS; - break; - #endif - #if defined(DSM_CYRF6936_INO) - case MODE_DSM: - PE2_on; //antenna RF4 - next_callback = initDsm(); - //Servo_data[2]=1500;//before binding - remote_callback = ReadDsm; - break; - #endif - #if defined(DEVO_CYRF6936_INO) - case MODE_DEVO: - #ifdef ENABLE_PPM - if(mode_select) //PPM mode - { - if(IS_BIND_BUTTON_FLAG_on) + #ifdef CYRF6936_INSTALLED + #if defined(DSM_CYRF6936_INO) + case MODE_DSM: + PE2_on; //antenna RF4 + next_callback = initDsm(); + //Servo_data[2]=1500;//before binding + remote_callback = ReadDsm; + break; + #endif + #if defined(DEVO_CYRF6936_INO) + case MODE_DEVO: + #ifdef ENABLE_PPM + if(mode_select) //PPM mode { - eeprom_write_byte((uint8_t*)(30+mode_select),0x00); // reset to autobind mode for the current model - option=0; + if(IS_BIND_BUTTON_FLAG_on) + { + eeprom_write_byte((uint8_t*)(30+mode_select),0x00); // reset to autobind mode for the current model + option=0; + } + else + { + option=eeprom_read_byte((uint8_t*)(30+mode_select)); // load previous mode: autobind or fixed id + if(option!=1) option=0; // if not fixed id mode then it should be autobind + } } - else - { - option=eeprom_read_byte((uint8_t*)(30+mode_select)); // load previous mode: autobind or fixed id - if(option!=1) option=0; // if not fixed id mode then it should be autobind - } - } - #endif //ENABLE_PPM - PE2_on; //antenna RF4 - next_callback = DevoInit(); - remote_callback = devo_callback; - break; + #endif //ENABLE_PPM + PE2_on; //antenna RF4 + next_callback = DevoInit(); + remote_callback = devo_callback; + break; + #endif + #if defined(J6PRO_CYRF6936_INO) + case MODE_J6PRO: + PE2_on; //antenna RF4 + next_callback = initJ6Pro(); + remote_callback = ReadJ6Pro; + break; + #endif #endif - #if defined(J6PRO_CYRF6936_INO) - case MODE_J6PRO: - PE2_on; //antenna RF4 - next_callback = initJ6Pro(); - remote_callback = ReadJ6Pro; - break; - #endif - #if defined(HISKY_NRF24L01_INO) - case MODE_HISKY: - next_callback=initHiSky(); - remote_callback = hisky_cb; - break; - #endif - #if defined(V2X2_NRF24L01_INO) - case MODE_V2X2: - next_callback = initV2x2(); - remote_callback = ReadV2x2; - break; - #endif - #if defined(YD717_NRF24L01_INO) - case MODE_YD717: - next_callback=initYD717(); - remote_callback = yd717_callback; - break; - #endif - #if defined(KN_NRF24L01_INO) - case MODE_KN: - next_callback = initKN(); - remote_callback = kn_callback; - break; - #endif - #if defined(SYMAX_NRF24L01_INO) - case MODE_SYMAX: - next_callback = initSymax(); - remote_callback = symax_callback; - break; - #endif - #if defined(SLT_NRF24L01_INO) - case MODE_SLT: - next_callback=initSLT(); - remote_callback = SLT_callback; - break; - #endif - #if defined(CX10_NRF24L01_INO) - case MODE_CX10: - next_callback=initCX10(); - remote_callback = CX10_callback; - break; - #endif - #if defined(CG023_NRF24L01_INO) - case MODE_CG023: - next_callback=initCG023(); - remote_callback = CG023_callback; - break; - #endif - #if defined(BAYANG_NRF24L01_INO) - case MODE_BAYANG: - next_callback=initBAYANG(); - remote_callback = BAYANG_callback; - break; - #endif - #if defined(ESKY_NRF24L01_INO) - case MODE_ESKY: - next_callback=initESKY(); - remote_callback = ESKY_callback; - break; - #endif - #if defined(MT99XX_NRF24L01_INO) - case MODE_MT99XX: - next_callback=initMT99XX(); - remote_callback = MT99XX_callback; - break; - #endif - #if defined(MJXQ_NRF24L01_INO) - case MODE_MJXQ: - next_callback=initMJXQ(); - remote_callback = MJXQ_callback; - break; - #endif - #if defined(SHENQI_NRF24L01_INO) - case MODE_SHENQI: - next_callback=initSHENQI(); - remote_callback = SHENQI_callback; - break; - #endif - #if defined(FY326_NRF24L01_INO) - case MODE_FY326: - next_callback=initFY326(); - remote_callback = FY326_callback; - break; - #endif - #if defined(FQ777_NRF24L01_INO) - case MODE_FQ777: - next_callback=initFQ777(); - remote_callback = FQ777_callback; - break; - #endif - #if defined(ASSAN_NRF24L01_INO) - case MODE_ASSAN: - next_callback=initASSAN(); - remote_callback = ASSAN_callback; - break; - #endif - #if defined(HONTAI_NRF24L01_INO) - case MODE_HONTAI: - next_callback=initHONTAI(); - remote_callback = HONTAI_callback; - break; + #ifdef NRF24L01_INSTALLED + #if defined(HISKY_NRF24L01_INO) + case MODE_HISKY: + next_callback=initHiSky(); + remote_callback = hisky_cb; + break; + #endif + #if defined(V2X2_NRF24L01_INO) + case MODE_V2X2: + next_callback = initV2x2(); + remote_callback = ReadV2x2; + break; + #endif + #if defined(YD717_NRF24L01_INO) + case MODE_YD717: + next_callback=initYD717(); + remote_callback = yd717_callback; + break; + #endif + #if defined(KN_NRF24L01_INO) + case MODE_KN: + next_callback = initKN(); + remote_callback = kn_callback; + break; + #endif + #if defined(SYMAX_NRF24L01_INO) + case MODE_SYMAX: + next_callback = initSymax(); + remote_callback = symax_callback; + break; + #endif + #if defined(SLT_NRF24L01_INO) + case MODE_SLT: + next_callback=initSLT(); + remote_callback = SLT_callback; + break; + #endif + #if defined(CX10_NRF24L01_INO) + case MODE_CX10: + next_callback=initCX10(); + remote_callback = CX10_callback; + break; + #endif + #if defined(CG023_NRF24L01_INO) + case MODE_CG023: + next_callback=initCG023(); + remote_callback = CG023_callback; + break; + #endif + #if defined(BAYANG_NRF24L01_INO) + case MODE_BAYANG: + next_callback=initBAYANG(); + remote_callback = BAYANG_callback; + break; + #endif + #if defined(ESKY_NRF24L01_INO) + case MODE_ESKY: + next_callback=initESKY(); + remote_callback = ESKY_callback; + break; + #endif + #if defined(MT99XX_NRF24L01_INO) + case MODE_MT99XX: + next_callback=initMT99XX(); + remote_callback = MT99XX_callback; + break; + #endif + #if defined(MJXQ_NRF24L01_INO) + case MODE_MJXQ: + next_callback=initMJXQ(); + remote_callback = MJXQ_callback; + break; + #endif + #if defined(SHENQI_NRF24L01_INO) + case MODE_SHENQI: + next_callback=initSHENQI(); + remote_callback = SHENQI_callback; + break; + #endif + #if defined(FY326_NRF24L01_INO) + case MODE_FY326: + next_callback=initFY326(); + remote_callback = FY326_callback; + break; + #endif + #if defined(FQ777_NRF24L01_INO) + case MODE_FQ777: + next_callback=initFQ777(); + remote_callback = FQ777_callback; + break; + #endif + #if defined(ASSAN_NRF24L01_INO) + case MODE_ASSAN: + next_callback=initASSAN(); + remote_callback = ASSAN_callback; + break; + #endif + #if defined(HONTAI_NRF24L01_INO) + case MODE_HONTAI: + next_callback=initHONTAI(); + remote_callback = HONTAI_callback; + break; + #endif #endif } diff --git a/Multiprotocol/SHENQI_nrf24l01.ino b/Multiprotocol/SHENQI_nrf24l01.ino index 293e30b..71fd825 100644 --- a/Multiprotocol/SHENQI_nrf24l01.ino +++ b/Multiprotocol/SHENQI_nrf24l01.ino @@ -116,7 +116,7 @@ uint16_t initSHENQI() SHENQI_init(); hopping_frequency_no = 0; packet_count=0; - packet_period=100; + packet_period=500; return 1000; } diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index 5dd32a7..7369e0f 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -25,54 +25,59 @@ #define AETR -/****************************/ -/*** PROTOCOLS TO INCLUDE ***/ -/****************************/ -//In this section select the protocols you want to be accessible when using the module. -//All the protocols will not fit in the module so you need to pick and choose. - +/**************************/ +/*** RF CHIPS INSTALLED ***/ +/**************************/ //There are 4 RF components supported. If one of them is not installed you must comment it using "//". -//This is also a quick way to reduce the number of protocols and save Flash space. +//If a chip is not installed all associated protocols are disabled. +//4-in-1 modules have all RF chips installed +//!!!If a RF chip is present it MUST be marked as installed!!! or weird things will happen you have been warned. #define A7105_INSTALLED #define CYRF6936_INSTALLED #define CC2500_INSTALLED #define NRF24L01_INSTALLED -//Bellow is the list of all available protocols. Comment the protocols you are not using with "//" to save Flash space. -#ifdef A7105_INSTALLED - #define FLYSKY_A7105_INO - #define HUBSAN_A7105_INO -#endif -#ifdef CYRF6936_INSTALLED - #define DEVO_CYRF6936_INO - #define DSM_CYRF6936_INO - #define J6PRO_CYRF6936_INO -#endif -#ifdef CC2500_INSTALLED - #define FRSKYD_CC2500_INO - #define FRSKYV_CC2500_INO - #define FRSKYX_CC2500_INO - #define SFHSS_CC2500_INO -#endif -#ifdef NRF24L01_INSTALLED - #define BAYANG_NRF24L01_INO - #define CG023_NRF24L01_INO - #define CX10_NRF24L01_INO - #define ESKY_NRF24L01_INO - #define HISKY_NRF24L01_INO - #define KN_NRF24L01_INO - #define SLT_NRF24L01_INO - #define SYMAX_NRF24L01_INO - #define V2X2_NRF24L01_INO - #define YD717_NRF24L01_INO - #define MT99XX_NRF24L01_INO - #define MJXQ_NRF24L01_INO - #define SHENQI_NRF24L01_INO - #define FY326_NRF24L01_INO - #define FQ777_NRF24L01_INO - #define ASSAN_NRF24L01_INO - #define HONTAI_NRF24L01_INO -#endif + +/****************************/ +/*** PROTOCOLS TO INCLUDE ***/ +/****************************/ +//In this section select the protocols you want to be accessible when using the module. +//All the protocols will not fit in the module so you need to pick and choose. +//Comment the protocols you are not using with "//" to save Flash space. + +//The protocols below need an A7105 to be installed +#define FLYSKY_A7105_INO +#define HUBSAN_A7105_INO + +//The protocols below need a CYRF6936 to be installed +#define DEVO_CYRF6936_INO +#define DSM_CYRF6936_INO +#define J6PRO_CYRF6936_INO + +//The protocols below need a CC2500 to be installed +#define FRSKYD_CC2500_INO +#define FRSKYV_CC2500_INO +#define FRSKYX_CC2500_INO +#define SFHSS_CC2500_INO + +//The protocols below need a NRF24L01 to be installed +#define BAYANG_NRF24L01_INO +#define CG023_NRF24L01_INO +#define CX10_NRF24L01_INO +#define ESKY_NRF24L01_INO +#define HISKY_NRF24L01_INO +#define KN_NRF24L01_INO +#define SLT_NRF24L01_INO +#define SYMAX_NRF24L01_INO +#define V2X2_NRF24L01_INO +#define YD717_NRF24L01_INO +#define MT99XX_NRF24L01_INO +#define MJXQ_NRF24L01_INO +#define SHENQI_NRF24L01_INO +#define FY326_NRF24L01_INO +#define FQ777_NRF24L01_INO +#define ASSAN_NRF24L01_INO +#define HONTAI_NRF24L01_INO /**************************/ @@ -85,20 +90,12 @@ //Uncomment to invert the polarity of the telemetry serial signal. //For ER9X and ERSKY9X it must be commented. For OpenTX it must be uncommented. -//#define INVERT_TELEMETRY 1 +//#define INVERT_TELEMETRY //Comment a line to disable a protocol telemetry -#if defined(TELEMETRY) - #if defined DSM_CYRF6936_INO - #define DSM_TELEMETRY - #endif - #if defined FRSKYX_CC2500_INO - #define SPORT_TELEMETRY - #endif - #if defined FRSKYD_CC2500_INO - #define HUB_TELEMETRY - #endif -#endif +#define DSM_TELEMETRY +#define SPORT_TELEMETRY +#define HUB_TELEMETRY /****************************/ @@ -152,7 +149,7 @@ const PPM_Parameters PPM_prot[15]= { /* 3 */ {MODE_FRSKYD, 0 , 0 , P_HIGH , NO_AUTOBIND , 40 }, // option=fine freq tuning /* 4 */ {MODE_HISKY , Hisky , 0 , P_HIGH , NO_AUTOBIND , 0 }, /* 5 */ {MODE_V2X2 , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 }, -/* 6 */ {MODE_DSM , DSM2_22 , 0 , P_HIGH , NO_AUTOBIND , 6 }, // option=6 channels @ 22ms +/* 6 */ {MODE_DSM , DSM2_22 , 0 , P_HIGH , NO_AUTOBIND , 6 }, // option=number of channels /* 7 */ {MODE_DEVO , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 }, /* 8 */ {MODE_YD717 , YD717 , 0 , P_HIGH , NO_AUTOBIND , 0 }, /* 9 */ {MODE_KN , WLTOYS , 0 , P_HIGH , NO_AUTOBIND , 0 },