@@ -25,13 +25,15 @@ Multiprotocol is distributed in the hope that it will be useful,
2525#define V761_BIND_COUNT 200
2626#define V761_BIND_FREQ 0x28
2727#define V761_RF_NUM_CHANNELS 3
28+ #define TOPRC_BIND_FREQ 0x2A
29+ #define TOPRC_PACKET_PERIOD 14120 // Timeout for callback in uSec
2830
2931enum
30- {
32+ {
3133 V761_BIND1 = 0 ,
3234 V761_BIND2,
3335 V761_DATA
34- };
36+ };
3537
3638static void __attribute__ ((unused)) V761_set_checksum()
3739{
@@ -56,14 +58,11 @@ static void __attribute__((unused)) V761_send_packet()
5658
5759 if (phase != V761_DATA)
5860 {
59- packet[0 ] = rx_tx_addr[0 ];
60- packet[1 ] = rx_tx_addr[1 ];
61- packet[2 ] = rx_tx_addr[2 ];
62- packet[3 ] = rx_tx_addr[3 ];
61+ memcpy (packet, rx_tx_addr, 4 );
6362 packet[4 ] = hopping_frequency[1 ];
6463 packet[5 ] = hopping_frequency[2 ];
6564 if (phase == V761_BIND2)
66- packet[6 ] = 0xf0 ; // ?
65+ packet[6 ] = 0xF0 ; // ?
6766 }
6867 else
6968 {
@@ -72,22 +71,21 @@ static void __attribute__((unused)) V761_send_packet()
7271 {
7372 hopping_frequency_no = 0 ;
7473 packet_count++;
75- if (packet_count >= 4 )
76- packet_count = 0 ;
74+ packet_count &= 0x03 ;
7775 }
7876
7977 packet[0 ] = convert_channel_8b (THROTTLE); // Throttle
8078 packet[2 ] = convert_channel_8b (ELEVATOR)>>1 ; // Elevator
8179
82- if (sub_protocol==V761_3CH )
80+ if (sub_protocol == V761_4CH || sub_protocol == V761_TOPRC )
8381 {
84- packet[1 ] = convert_channel_8b (RUDDER )>>1 ; // Rudder
85- packet[3 ] = convert_channel_8b (AILERON )>>1 ; // Aileron
82+ packet[1 ] = convert_channel_8b (AILERON )>>1 ; // Aileron
83+ packet[3 ] = convert_channel_8b (RUDDER )>>1 ; // Rudder
8684 }
8785 else
8886 {
89- packet[1 ] = convert_channel_8b (AILERON )>>1 ; // Aileron
90- packet[3 ] = convert_channel_8b (RUDDER )>>1 ; // Rudder
87+ packet[1 ] = convert_channel_8b (RUDDER )>>1 ; // Rudder
88+ packet[3 ] = convert_channel_8b (AILERON )>>1 ; // Aileron
9189 }
9290
9391 packet[5 ] = packet_count<<6 ; // 0X, 4X, 8X, CX
@@ -112,7 +110,7 @@ static void __attribute__((unused)) V761_send_packet()
112110 packet[6 ] = GET_FLAG (CH7_SW, 0x20 ) // Flip
113111 |GET_FLAG (CH8_SW, 0x08 ) // RTH activation
114112 |GET_FLAG (CH9_SW, 0x10 ); // RTH on/off
115- if (sub_protocol== V761_3CH)
113+ if (sub_protocol == V761_3CH)
116114 packet[6 ] |= 0x80 ; // Unknown, set on original V761-1 dump but not on eachine dumps, keeping for compatibility
117115 }
118116 V761_set_checksum ();
@@ -137,28 +135,36 @@ static void __attribute__((unused)) V761_RF_init()
137135static void __attribute__ ((unused)) V761_initialize_txid()
138136{
139137 #ifdef V761_FORCE_ID
140- switch (RX_num%5 )
138+ if (sub_protocol == V761_TOPRC)
139+ { // Dump from air on TopRCHobby TX
140+ memcpy (rx_tx_addr,(uint8_t *)" \xD5\x01\x00\x00 " ,4 );
141+ memcpy (hopping_frequency,(uint8_t *)" \x2E\x41 " ,2 );
142+ }
143+ else
141144 {
142- case 1 : // Dump from air on Protonus TX
143- memcpy (rx_tx_addr,(uint8_t *)" \xE8\xE4\x45\x09 " ,4 );
144- memcpy (hopping_frequency,(uint8_t *)" \x0D\x21 " ,2 );
145- break ;
146- case 2 : // Dump from air on mshagg2 TX
147- memcpy (rx_tx_addr,(uint8_t *)" \xAE\xD1\x45\x09 " ,4 );
148- memcpy (hopping_frequency,(uint8_t *)" \x13\x1D " ,2 );
149- break ;
150- case 3 : // Dump from air on MikeHRC Eachine TX
151- memcpy (rx_tx_addr,(uint8_t *)" \x08\x03\x00\xA0 " ,4 );
152- memcpy (hopping_frequency,(uint8_t *)" \x0D\x21 " ,2 );
153- break ;
154- case 4 : // Dump from air on Crashanium Eachine TX
155- memcpy (rx_tx_addr,(uint8_t *)" \x58\x08\x00\xA0 " ,4 );
156- memcpy (hopping_frequency,(uint8_t *)" \x0D\x31 " ,2 );
157- break ;
158- default : // Dump from SPI
159- memcpy (rx_tx_addr,(uint8_t *)" \x6f\x2c\xb1\x93 " ,4 );
160- memcpy (hopping_frequency,(uint8_t *)" \x14\x1e " ,2 );
161- break ;
145+ switch (RX_num%5 )
146+ {
147+ case 1 : // Dump from air on Protonus TX
148+ memcpy (rx_tx_addr,(uint8_t *)" \xE8\xE4\x45\x09 " ,4 );
149+ memcpy (hopping_frequency,(uint8_t *)" \x0D\x21 " ,2 );
150+ break ;
151+ case 2 : // Dump from air on mshagg2 TX
152+ memcpy (rx_tx_addr,(uint8_t *)" \xAE\xD1\x45\x09 " ,4 );
153+ memcpy (hopping_frequency,(uint8_t *)" \x13\x1D " ,2 );
154+ break ;
155+ case 3 : // Dump from air on MikeHRC Eachine TX
156+ memcpy (rx_tx_addr,(uint8_t *)" \x08\x03\x00\xA0 " ,4 );
157+ memcpy (hopping_frequency,(uint8_t *)" \x0D\x21 " ,2 );
158+ break ;
159+ case 4 : // Dump from air on Crashanium Eachine TX
160+ memcpy (rx_tx_addr,(uint8_t *)" \x58\x08\x00\xA0 " ,4 );
161+ memcpy (hopping_frequency,(uint8_t *)" \x0D\x31 " ,2 );
162+ break ;
163+ default : // Dump from SPI
164+ memcpy (rx_tx_addr,(uint8_t *)" \x6f\x2c\xb1\x93 " ,4 );
165+ memcpy (hopping_frequency,(uint8_t *)" \x14\x1e " ,2 );
166+ break ;
167+ }
162168 }
163169 #else
164170 // Tested with Eachine RX
@@ -180,8 +186,8 @@ uint16_t V761_callback()
180186 if (bind_counter)
181187 bind_counter--;
182188 packet_count ++;
183- XN297_RFChannel (V761_BIND_FREQ);
184- XN297_SetTXAddr (( uint8_t *) " \x34\x43\x10\x10 " , 4 );
189+ XN297_RFChannel (sub_protocol == V761_TOPRC ? TOPRC_BIND_FREQ : V761_BIND_FREQ);
190+ XN297_SetTXAddr (rx_id , 4 );
185191 V761_send_packet ();
186192 if (packet_count >= 20 )
187193 {
@@ -210,17 +216,28 @@ uint16_t V761_callback()
210216 return 15730 ;
211217 case V761_DATA:
212218 #ifdef MULTI_SYNC
213- telemetry_set_input_sync (V761_PACKET_PERIOD );
219+ telemetry_set_input_sync (packet_period );
214220 #endif
215221 V761_send_packet ();
216222 break ;
217223 }
218- return V761_PACKET_PERIOD ;
224+ return packet_period ;
219225}
220226
221227void V761_init (void )
222228{
223229 V761_initialize_txid ();
230+ if (sub_protocol == V761_TOPRC)
231+ {
232+ memcpy (rx_id,(uint8_t *)" \x20\x21\x05\x0A " ,4 );
233+ packet_period = TOPRC_PACKET_PERIOD;
234+ }
235+ else
236+ {
237+ memcpy (rx_id,(uint8_t *)" \x34\x43\x10\x10 " ,4 );
238+ packet_period = V761_PACKET_PERIOD;
239+ }
240+
224241 if (IS_BIND_IN_PROGRESS)
225242 {
226243 bind_counter = V761_BIND_COUNT;
@@ -231,7 +248,7 @@ void V761_init(void)
231248 XN297_SetTXAddr (rx_tx_addr, 4 );
232249 phase = V761_DATA;
233250 }
234-
251+
235252 V761_RF_init ();
236253 hopping_frequency_no = 0 ;
237254 packet_count = 0 ;
0 commit comments