diff --git a/Multiprotocol/A7105_SPI.ino b/Multiprotocol/A7105_SPI.ino index 56d31f8..00d08c0 100644 --- a/Multiprotocol/A7105_SPI.ino +++ b/Multiprotocol/A7105_SPI.ino @@ -217,6 +217,14 @@ void A7105_Init(void) for (uint8_t i = 0; i < 0x32; i++) { uint8_t val=pgm_read_byte_near(&A7105_Regs[i]); + #ifdef FLYSKY_A7105_INO + if(protocol==MODE_FLYSKY && sub_protocol==CX20) + { + if(i==0x0E) val=0x01 + if(i==0x1F) val=0x1F + if(i==0x20) val=0x1E + } + #endif if( val != 0xFF) A7105_WriteReg(i, val); } diff --git a/Multiprotocol/FlySky_a7105.ino b/Multiprotocol/FlySky_a7105.ino index c1632e7..538f019 100644 --- a/Multiprotocol/FlySky_a7105.ino +++ b/Multiprotocol/FlySky_a7105.ino @@ -55,7 +55,6 @@ const uint8_t PROGMEM V912_X17_SEQ[10] = { 0x14, 0x31, 0x40, 0x49, 0x49, // static void __attribute__((unused)) flysky_apply_extension_flags() { - static uint8_t seq_counter; switch(sub_protocol) { case V9X9: @@ -100,9 +99,9 @@ static void __attribute__((unused)) flysky_apply_extension_flags() break; case V912: - seq_counter++; - if( seq_counter > 9) - seq_counter = 0; + packet_count++; + if( packet_count > 9) + packet_count = 0; packet[12] |= 0x20; // bit 6 is always set ? packet[13] = 0x00; // unknown packet[14] = 0x00; @@ -112,8 +111,8 @@ static void __attribute__((unused)) flysky_apply_extension_flags() packet[14] |= FLAG_V912_TOPBTN; packet[15] = 0x27; // [15] and [16] apparently hold an analog channel with a value lower than 1000 packet[16] = 0x03; // maybe it's there for a pitch channel for a CP copter ? - packet[17] = pgm_read_byte( &V912_X17_SEQ[seq_counter] ) ; // not sure what [17] & [18] are for - if(seq_counter == 0) // V912 Rx does not even read those bytes... [17-20] + packet[17] = pgm_read_byte( &V912_X17_SEQ[packet_count] ) ; // not sure what [17] & [18] are for + if(packet_count == 0) // V912 Rx does not even read those bytes... [17-20] packet[18] = 0x02; else packet[18] = 0x00; @@ -121,6 +120,11 @@ static void __attribute__((unused)) flysky_apply_extension_flags() packet[20] = 0x00; // unknown break; + case CX20: + packet_count++; + packet[19] = 0x00; // unknown + packet[20] = (packet_count<<4)|0x0A; + break; default: break; } @@ -164,7 +168,11 @@ uint16_t ReadFlySky() hopping_frequency_no = (hopping_frequency_no + 1) & 0x0F; A7105_SetPower(); } - return 1510; //1460 on deviation but not working with the latest V911 bricks... Turnigy 9X v2 is 1533, Flysky TX for 9XR/9XR Pro is 1510, V911 TX is 1490. + + if(sub_protocol=CX20) + return 3984; + else + return 1510; //1460 on deviation but not working with the latest V911 bricks... Turnigy 9X v2 is 1533, Flysky TX for 9XR/9XR Pro is 1510, V911 TX is 1490. } const uint8_t PROGMEM tx_channels[8][4] = { @@ -205,7 +213,12 @@ uint16_t initFlySky() hopping_frequency[((chanrow&1)?15-i:i)]=temp-chanoffset; } hopping_frequency_no=0; - + if(sub_protocol==CX20) + {//Haven't figured yet the relation between TX ID and Frequencies + memcpy(rx_tx_addr,"\x06\x35\x89\x72",4); + memcpy(hopping_frequency,"\x35\x85\x21\x71\x2B\x7B\x3A\x53\x49\x26\x0D\x5D\x3F\x8F\x17\x6",16); + } + packet_count=0; if(IS_AUTOBIND_FLAG_on) bind_counter = FLYSKY_BIND_COUNT; else diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 0b10aae..3c0ff9a 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -55,7 +55,8 @@ enum Flysky Flysky = 0, V9X9 = 1, V6X6 = 2, - V912 = 3 + V912 = 3, + CX20 = 4 }; enum AFHDS2A { @@ -240,14 +241,14 @@ struct PPM_Parameters //*** AUX flags *** //******************* #define GET_FLAG(ch, mask) ( ch ? mask : 0) -#define Servo_AUX1 Servo_AUX & _BV(0) -#define Servo_AUX2 Servo_AUX & _BV(1) -#define Servo_AUX3 Servo_AUX & _BV(2) -#define Servo_AUX4 Servo_AUX & _BV(3) -#define Servo_AUX5 Servo_AUX & _BV(4) -#define Servo_AUX6 Servo_AUX & _BV(5) -#define Servo_AUX7 Servo_AUX & _BV(6) -#define Servo_AUX8 Servo_AUX & _BV(7) +#define Servo_AUX1 (Servo_AUX & _BV(0)) +#define Servo_AUX2 (Servo_AUX & _BV(1)) +#define Servo_AUX3 (Servo_AUX & _BV(2)) +#define Servo_AUX4 (Servo_AUX & _BV(3)) +#define Servo_AUX5 (Servo_AUX & _BV(4)) +#define Servo_AUX6 (Servo_AUX & _BV(5)) +#define Servo_AUX7 (Servo_AUX & _BV(6)) +#define Servo_AUX8 (Servo_AUX & _BV(7)) //************************ //*** Power settings *** @@ -415,6 +416,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p -- V9x9 1 V6x6 2 V912 3 + CX20 4 sub_protocol==Hisky Hisky 0 HK310 1 diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index 4a1d950..e5d27bc 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -178,6 +178,7 @@ const PPM_Parameters PPM_prot[15]= { V9X9 V6X6 V912 + CX20 MODE_HUBSAN NONE MODE_FRSKYD