From ec92edfc853dffe63c49e23ef03e640f27460eb4 Mon Sep 17 00:00:00 2001 From: pascallanger Date: Thu, 19 Dec 2019 23:40:33 +0100 Subject: [PATCH] New protocol Tiger Model: Tiger drone 1400782 Protocol number: 61 No sub_protocol CH5: Flip CH6: Light --- Multiprotocol/Multi.txt | 1 + Multiprotocol/Multi_Names.ino | 6 +- Multiprotocol/Multiprotocol.h | 4 +- Multiprotocol/Multiprotocol.ino | 6 ++ Multiprotocol/Tiger_nrf24l01.ino | 179 +++++++++++++++++++++++++++++++ Multiprotocol/Validate.h | 1 + Multiprotocol/_Config.h | 3 + Protocols_Details.md | 8 ++ 8 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 Multiprotocol/Tiger_nrf24l01.ino diff --git a/Multiprotocol/Multi.txt b/Multiprotocol/Multi.txt index e07a4b8..5bb313d 100644 --- a/Multiprotocol/Multi.txt +++ b/Multiprotocol/Multi.txt @@ -58,4 +58,5 @@ 58,FX816,P38 59,Bayang_RX 60,Pelikan +61,Tiger 63,XN_DUMP,250K,1M,2M,AUTO diff --git a/Multiprotocol/Multi_Names.ino b/Multiprotocol/Multi_Names.ino index a6a90ed..00f790f 100644 --- a/Multiprotocol/Multi_Names.ino +++ b/Multiprotocol/Multi_Names.ino @@ -74,6 +74,7 @@ const char STR_HOTT[] ="HoTT"; const char STR_FX816[] ="FX816"; const char STR_BAYANG_RX[] ="BayanRX"; const char STR_PELIKAN[] ="Pelikan"; +const char STR_TIGER[] ="Tiger"; const char STR_XN297DUMP[] ="XN297DP"; const char STR_SUBTYPE_FLYSKY[] = "\x04""Std\0""V9x9""V6x6""V912""CX20"; @@ -305,9 +306,12 @@ const mm_protocol_definition multi_protocols[] = { #if defined(BAYANG_RX_NRF24L01_INO) {PROTO_BAYANG_RX, STR_BAYANG_RX, 0, NO_SUBTYPE, OPTION_NONE }, #endif -#if defined(BAYANG_RX_NRF24L01_INO) +#if defined(PELIKAN_A7105_INO) {PROTO_PELIKAN, STR_PELIKAN , 0, NO_SUBTYPE, OPTION_NONE }, #endif +#if defined(TIGER_NRF24L01_INO) + {PROTO_TIGER, STR_TIGER , 0, NO_SUBTYPE, OPTION_NONE }, +#endif #if defined(XN297DUMP_NRF24L01_INO) {PROTO_XN297DUMP, STR_XN297DUMP, 3, STR_SUBTYPE_XN297DUMP, OPTION_RFCHAN }, #endif diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 462f528..4f100fe 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 49 +#define VERSION_PATCH_LEVEL 50 //****************** // Protocols @@ -87,6 +87,7 @@ enum PROTOCOLS PROTO_FX816 = 58, // =>NRF24L01 PROTO_BAYANG_RX = 59, // =>NRF24L01 PROTO_PELIKAN = 60, // =>A7105 + PROTO_TIGER = 61, // =>NRF24L01 PROTO_XN297DUMP = 63, // =>NRF24L01 }; @@ -696,6 +697,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p -- FX816 58 BAYANG_RX 59 PELIKAN 60 + TIGER 61 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 022d719..583d4a7 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -1435,6 +1435,12 @@ static void protocol_init() remote_callback = Bayang_Rx_callback; break; #endif + #if defined(TIGER_NRF24L01_INO) + case PROTO_TIGER: + next_callback=initTIGER(); + remote_callback = TIGER_callback; + break; + #endif #if defined(XN297DUMP_NRF24L01_INO) case PROTO_XN297DUMP: next_callback=initXN297Dump(); diff --git a/Multiprotocol/Tiger_nrf24l01.ino b/Multiprotocol/Tiger_nrf24l01.ino new file mode 100644 index 0000000..ba5a908 --- /dev/null +++ b/Multiprotocol/Tiger_nrf24l01.ino @@ -0,0 +1,179 @@ +/* + 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 Tiger Drone 1400782. + +#if defined(TIGER_NRF24L01_INO) + +#include "iface_nrf24l01.h" + +#define TIGER_FORCE_ID + +#define TIGER_INITIAL_WAIT 500 +#define TIGER_PACKET_PERIOD 3940 +#define TIGER_RF_NUM_CHANNELS 4 +#define TIGER_BIND_RF_NUM_CHANNELS 8 +#define TIGER_PAYLOAD_SIZE 16 +#define TIGER_BIND_COUNT 761 //3sec + + +static uint8_t __attribute__((unused)) TIGER_convert_channel(uint8_t num) +{ + uint8_t val=convert_channel_8b(num); + // 00=center, 01..7F=left, 80..FF=right + if(val==80) + val=0; + else + if(val>80) + val--; + else + if(val==0) + val++; + return val; +} + +static void __attribute__((unused)) TIGER_send_packet() +{ + if(IS_BIND_DONE) + { + //Channels + packet[0]=convert_channel_8b(THROTTLE); // 00..FF + packet[1]=TIGER_convert_channel(RUDDER); // 00=center, 01..7F=left, 80..FF=right + packet[2]=TIGER_convert_channel(ELEVATOR); // 00=center, 01..7F=down, 80..FF=up + packet[3]=TIGER_convert_channel(AILERON); // 00=center, 01..7F=left, 80..FF=right + //Flags + packet[14]= GET_FLAG(CH5_SW, 0x04) //FLIP + | GET_FLAG(CH6_SW, 0x10); //LIGHT + } + //Check + crc8=0; + for(uint8_t i=0;i>1]); + hopping_frequency_no++; + if(IS_BIND_IN_PROGRESS) + { + if(hopping_frequency_no>=2*TIGER_BIND_RF_NUM_CHANNELS) + hopping_frequency_no=0; + } + else + { + if(hopping_frequency_no>=2*(TIGER_BIND_RF_NUM_CHANNELS+TIGER_RF_NUM_CHANNELS)) + hopping_frequency_no=2*TIGER_BIND_RF_NUM_CHANNELS; + } + + //Clear packet status bits and TX FIFO + NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); + NRF24L01_FlushTx(); + //Send packet + XN297_WritePayload(packet, TIGER_PAYLOAD_SIZE); + //Set tx_power + NRF24L01_SetPower(); +} + +static void __attribute__((unused)) TIGER_init() +{ + NRF24L01_Initialize(); + NRF24L01_SetTxRxMode(TX_EN); + XN297_SetTXAddr((uint8_t *)"\x68\x94\xA6\xD5\xC3", 5); + NRF24L01_FlushTx(); + NRF24L01_FlushRx(); + NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); // Clear data ready, data sent, and retransmit + NRF24L01_WriteReg(NRF24L01_01_EN_AA, 0x00); // No Auto Acknowldgement on all data pipes + NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x01); // Enable data pipe 0 only + NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps + NRF24L01_WriteReg(NRF24L01_04_SETUP_RETR, 0x00); // No retransmits + NRF24L01_SetPower(); + NRF24L01_Activate(0x73); // Activate feature register + NRF24L01_WriteReg(NRF24L01_1C_DYNPD, 0x00); // Disable dynamic payload length on all pipes + NRF24L01_WriteReg(NRF24L01_1D_FEATURE, 0x01); + NRF24L01_Activate(0x73); + // Power on, TX mode, 2byte CRC + XN297_Configure(_BV(NRF24L01_00_EN_CRC) | _BV(NRF24L01_00_CRCO) | _BV(NRF24L01_00_PWR_UP)); +} + +static void __attribute__((unused)) TIGER_initialize_txid() +{ +#ifdef TIGER_FORCE_ID + rx_tx_addr[0]=0x64; + rx_tx_addr[1]=0x39; + rx_tx_addr[2]=0x12; + rx_tx_addr[3]=0x00; + rx_tx_addr[4]=0x00; + memcpy(hopping_frequency,"\x0E\x39\x1C\x07\x24\x3E\x2B\x47",TIGER_BIND_RF_NUM_CHANNELS); + memcpy(&hopping_frequency[TIGER_BIND_RF_NUM_CHANNELS],"\x36\x41\x37\x4E",TIGER_RF_NUM_CHANNELS); +#endif + //prepare bind packet + memset(&packet[0], 0x00, 4); + memset(&packet[4], 0x40, 10); + memcpy(&packet[7], rx_tx_addr, 5); + packet[14]=0xC0; +} + +uint16_t TIGER_callback() +{ + #ifdef MULTI_SYNC + telemetry_set_input_sync(TIGER_PACKET_PERIOD); + #endif + if(IS_BIND_IN_PROGRESS) + if(--bind_counter==0) + { + BIND_DONE; + XN297_SetTXAddr((uint8_t *)"\x49\xA6\x83\xEB\x4B", 5); + } + TIGER_send_packet(); + return TIGER_PACKET_PERIOD; +} + +uint16_t initTIGER() +{ + BIND_IN_PROGRESS; // autobind protocol + TIGER_initialize_txid(); + TIGER_init(); + hopping_frequency_no = 0; + bind_counter=TIGER_BIND_COUNT; + return TIGER_INITIAL_WAIT; +} + +#endif +/*Bind +- RF setup: 1Mbps, scrambled, CRC +- TX addr: 0x68 0x94 0xA6 0xD5 0xC3 +- 8 RF channels: 0x0E 0x39 0x1C 0x07 0x24 0x3E 0x2B 0x47 +- 2 packets per RF channel, 3940µs between packets +- payload 16 bytes: 0x00 0x00 0x00 0x00 0x40 0x40 0x40 0x64 0x39 0x12 0x00 0x00 0x40 0x40 0xC0 0xAF +- payload[15]=sum of payload[0..14] +- the only difference with normal packets is the payload[14]=0xC0 +- ??? payload[7..11] TX ID ??? + +Normal +- RF setup: 1Mbps +- TX addr: 0x49 0xA6 0x83 0xEB 0x4B +- 4 RF channels: 0x36 0x41 0x37 0x4E +- 2 packets per RF channel, 3940µs between packets +- payload 16 bytes: 0x00 0x00 0x00 0x00 0x40 0x40 0x40 0x64 0x39 0x12 0x00 0x00 0x40 0x40 0x00 0xEF +- payload[15]=sum of payload[0..14] +- throttle is on payload[0] 00..FF +- rudder is on payload[1] 00=center, 80..FF=right, 01..7F=left +- elevator is on payload[2] 00=center, 80..FF=up, 01..7F=down +- aileron is on payload[3] 00=center, 80..FF=right, 01..7F=left +- trims payload[4..6] +- ??? payload[7..11] TX ID ??? +- ??? payload[12..13] ??? +- flip is on payload[14] and flag 0x04 +- light is on payload[14] and flag 0x10 +*/ \ No newline at end of file diff --git a/Multiprotocol/Validate.h b/Multiprotocol/Validate.h index 6bdc9f1..492423d 100644 --- a/Multiprotocol/Validate.h +++ b/Multiprotocol/Validate.h @@ -241,6 +241,7 @@ #undef POTENSIC_NRF24L01_INO #undef ZSX_NRF24L01_INO #undef BAYANG_RX_NRF24L01_INO + #undef TIGER_NRF24L01_INO #endif //Make sure telemetry is selected correctly diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index f18da49..af67ea9 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -216,6 +216,7 @@ #define SHENQI_NRF24L01_INO #define SLT_NRF24L01_INO #define SYMAX_NRF24L01_INO +#define TIGER_NRF24L01_INO #define V2X2_NRF24L01_INO #define V761_NRF24L01_INO #define V911S_NRF24L01_INO @@ -656,6 +657,8 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= { PROTO_SYMAX SYMAX SYMAX5C + PROTO_TIGER + NONE PROTO_TRAXXAS RX6519 PROTO_V2X2 diff --git a/Protocols_Details.md b/Protocols_Details.md index f1f0da8..53e63bc 100644 --- a/Protocols_Details.md +++ b/Protocols_Details.md @@ -118,6 +118,7 @@ CFlie|38|CFlie||||||||NRF24L01| [Shenqi](Protocols_Details.md#Shenqi---19)|19|Shenqi||||||||NRF24L01|LT8900 [SLT](Protocols_Details.md#SLT---11)|11|SLT_V1|SLT_V2|Q100|Q200|MR100||||NRF24L01| [SymaX](Protocols_Details.md#Symax---10)|10|SYMAX|SYMAX5C|||||||NRF24L01| +[Tiger](Protocols_Details.md#Tiger---61)|61|Tiger||||||||NRF24L01|XN297 [Traxxas](Protocols_Details.md#Traxxas---43)|43|RX6519||||||||CYRF6936| [V2x2](Protocols_Details.md#V2X2---5)|5|V2x2|JXD506|||||||NRF24L01| [V761](Protocols_Details.md#V761---48)|48|V761||||||||NRF24L01|XN297 @@ -1278,6 +1279,13 @@ CH10|CH11|CH12 ---|---|--- Start/Stop|EMERGENCY|CAMERA_UP/DN +## Tiger - *61* +Autobind protocol + +CH1|CH2|CH3|CH4|CH5|CH6 +---|---|---|---|---|--- +A|E|T|R|FLIP|LIGHT + ## V761 - *48* Model: Volantex V761 and may be other