2929#define SLT_NFREQCHANNELS 15
3030#define SLT_TXID_SIZE 4
3131#define SLT_BIND_CHANNEL 0x50
32+ #define SLT6_CH_MIN 182 // 10-bit AETR minimum (captures: 180-185, symmetric around 512)
33+ #define SLT6_CH_MAX 842 // 10-bit AETR maximum (captures: 829-843, symmetric around 512)
34+ #define SLT6_SW_THRESHOLD 273 // ~33% of half-range (820/3) for 3-position switch zones
3235
3336enum {
3437 // flags going to packet[6] (Q200)
@@ -54,9 +57,32 @@ enum {
5457 SLT_BIND2,
5558};
5659
60+ // SLT6 sub-cycle states: 3 sub-cycles per triple, each with 2 copies
61+ enum {
62+ SLT6_BUILD_A=0 , // Build packet, configure for 7B sub-cycle
63+ SLT6_DATA_A1, // Send 7B copy 1
64+ SLT6_DATA_A2, // Send 7B copy 2, configure for 6B sub-cycle
65+ SLT6_DATA_B1, // Send 6B copy 1
66+ SLT6_DATA_B2, // Send 6B copy 2, configure for 5B sub-cycle
67+ SLT6_DATA_C1, // Send 5B copy 1
68+ SLT6_DATA_C2, // Send 5B copy 2
69+ SLT6_BIND, // Send bind packet
70+ };
71+
72+ // SLT6 address XOR values for the 3 sub-cycles
73+ #define SLT6_ADDR_XOR_A 0x00 // 7B sub-cycle: base address
74+ #define SLT6_ADDR_XOR_B 0x06 // 6B sub-cycle: byte[0] XOR 0x06
75+ #define SLT6_ADDR_XOR_C 0x09 // 5B sub-cycle: byte[0] XOR 0x09
76+
77+ // SLT6 timing (from capture 12b, in microseconds)
78+ #define SLT6_TIMING_SUBCYCLE 5994 // ~6000us between sub-cycle starts
79+ #define SLT6_TIMING_PAIR 1633 // ~1633us between the two copies within a sub-cycle
80+ #define SLT6_TIMING_BUILD 1000 // Build+config time at start of each triple
81+ #define SLT6_TIMING_TRIPLE (3 * SLT6_TIMING_SUBCYCLE) // ~18ms triple period
82+
5783static void __attribute__ ((unused)) SLT_RF_init()
5884{
59- NRF250K_Init ();
85+ XN297_Configure (XN297_CRCEN, XN297_SCRAMBLED, XN297_250K, option == 0 ); // SLT: option==0 uses NRF24L01, option!=0 uses CC2500 with freq tuning
6086 NRF250K_SetTXAddr (rx_tx_addr, SLT_TXID_SIZE);
6187}
6288
@@ -193,17 +219,58 @@ static void __attribute__((unused)) SLT_build_packet()
193219 packet[i] = 0x00 ;
194220}
195221
222+ // SLT6: build 7-byte data packet from current channel values
223+ static void __attribute__ ((unused)) SLT6_build_packet()
224+ {
225+ // aileron, elevator, throttle, rudder (10-bit, limited range)
226+ uint8_t e = 0 ;
227+ for (uint8_t i = 0 ; i < 4 ; ++i)
228+ {
229+ uint16_t v = convert_channel_16b_limit (CH_AETR[i], SLT6_CH_MIN, SLT6_CH_MAX);
230+ packet[i] = v;
231+ e = (e >> 2 ) | (uint8_t ) ((v >> 2 ) & 0xC0 );
232+ }
233+ packet[4 ] = e;
234+
235+ // Flight mode: 3 positions at ~33% each
236+ if (Channel_data[CH5] > CHANNEL_MID + SLT6_SW_THRESHOLD)
237+ packet[5 ] = 0xD0 ;
238+ else if (Channel_data[CH5] < CHANNEL_MID - SLT6_SW_THRESHOLD)
239+ packet[5 ] = 0x30 ;
240+ else
241+ packet[5 ] = 0x80 ;
242+
243+ // Panic: only active when CH6 is below -33%, center and up = no panic
244+ if (Channel_data[CH6] < CHANNEL_MID - SLT6_SW_THRESHOLD)
245+ packet[6 ] = 0x30 ;
246+ else
247+ packet[6 ] = 0xD0 ;
248+ }
249+
250+ // SLT6: configure radio for a sub-cycle (set address and channel)
251+ static void __attribute__ ((unused)) SLT6_configure_radio(uint8_t addr_xor, uint8_t hop_offset)
252+ {
253+ SLT_wait_radio ();
254+ // Set TX address with XOR on byte[0]
255+ uint8_t addr[SLT_TXID_SIZE];
256+ memcpy (addr, rx_tx_addr, SLT_TXID_SIZE);
257+ addr[0 ] ^= addr_xor;
258+ NRF250K_SetTXAddr (addr, SLT_TXID_SIZE);
259+ // Set RF channel
260+ NRF250K_Hopping ((hopping_frequency_no + hop_offset) % SLT_NFREQCHANNELS);
261+ }
262+
196263static void __attribute__ ((unused)) SLT_send_bind_packet()
197264{
198265 SLT_wait_radio ();
199- if (phase == SLT_BIND2)
200- NRF250K_Hopping (SLT_NFREQCHANNELS); // Bind channel for BIND2 only
266+ if (phase == SLT_BIND2 || phase == SLT6_BIND )
267+ NRF250K_Hopping (SLT_NFREQCHANNELS); // Bind channel for BIND2 and SLT6 BIND
201268 BIND_IN_PROGRESS; // Limit TX power to bind level
202269 NRF250K_SetPower ();
203270 BIND_DONE;
204271 NRF250K_SetTXAddr ((uint8_t *)" \x7E\xB8\x63\xA9 " , SLT_TXID_SIZE);
205272 memcpy ((void *)packet, (void *)rx_tx_addr, SLT_TXID_SIZE);
206- if (phase == SLT_BIND2)
273+ if (phase == SLT_BIND2 || phase == SLT6_BIND )
207274 SLT_send_packet (SLT_TXID_SIZE);
208275 else // SLT_BIND1
209276 SLT_send_packet (packet_length);
@@ -222,8 +289,71 @@ static void __attribute__((unused)) SLT_send_bind_packet()
222289#define SLT_Q100_TIMING_BIND1 3652
223290#define SLT_Q100_TIMING_BIND2 1217
224291#define SLT_MR100_TIMING_BIND2 1008
292+
293+ // SLT6 callback: triple-address state machine
294+ // Each triple: 3 sub-cycles (7B, 6B, 5B), each sent twice, with different addresses and channels
295+ static uint16_t __attribute__ ((unused)) SLT6_callback()
296+ {
297+ switch (phase)
298+ {
299+ case SLT6_BUILD_A:
300+ #ifdef MULTI_SYNC
301+ telemetry_set_input_sync (SLT6_TIMING_TRIPLE);
302+ #endif
303+ SLT6_build_packet ();
304+ NRF250K_SetPower ();
305+ SLT6_configure_radio (SLT6_ADDR_XOR_A, 0 ); // 7B sub-cycle: base address, hop+0
306+ phase = SLT6_DATA_A1;
307+ return SLT6_TIMING_BUILD;
308+ case SLT6_DATA_A1:
309+ SLT_send_packet (7 );
310+ phase = SLT6_DATA_A2;
311+ return SLT6_TIMING_PAIR; // 1633us between copies
312+ case SLT6_DATA_A2:
313+ SLT_send_packet (7 );
314+ SLT6_configure_radio (SLT6_ADDR_XOR_B, 3 ); // 6B sub-cycle: XOR 0x06 address, hop+3
315+ phase = SLT6_DATA_B1;
316+ return SLT6_TIMING_SUBCYCLE - SLT6_TIMING_PAIR; // 4361us to next sub-cycle TX
317+ case SLT6_DATA_B1:
318+ SLT_send_packet (6 );
319+ phase = SLT6_DATA_B2;
320+ return SLT6_TIMING_PAIR;
321+ case SLT6_DATA_B2:
322+ SLT_send_packet (6 );
323+ SLT6_configure_radio (SLT6_ADDR_XOR_C, 6 ); // 5B sub-cycle: XOR 0x09 address, hop+6
324+ phase = SLT6_DATA_C1;
325+ return SLT6_TIMING_SUBCYCLE - SLT6_TIMING_PAIR; // 4361us
326+ case SLT6_DATA_C1:
327+ SLT_send_packet (5 );
328+ phase = SLT6_DATA_C2;
329+ return SLT6_TIMING_PAIR;
330+ case SLT6_DATA_C2:
331+ SLT_send_packet (5 );
332+ // Advance hopping for next triple
333+ if (++hopping_frequency_no >= SLT_NFREQCHANNELS)
334+ hopping_frequency_no = 0 ;
335+ if (++packet_count >= 100 )
336+ {// Send bind packet periodically
337+ packet_count = 0 ;
338+ phase = SLT6_BIND;
339+ return SLT_V1_TIMING_BIND2;
340+ }
341+ phase = SLT6_BUILD_A;
342+ return SLT6_TIMING_SUBCYCLE - SLT6_TIMING_PAIR - SLT6_TIMING_BUILD; // Gap before next build
343+ case SLT6_BIND:
344+ SLT_send_bind_packet ();
345+ phase = SLT6_BUILD_A;
346+ return SLT6_TIMING_SUBCYCLE - SLT6_TIMING_PAIR - SLT6_TIMING_BUILD;
347+ }
348+ return SLT6_TIMING_TRIPLE;
349+ }
350+
225351uint16_t SLT_callback ()
226352{
353+ // SLT6 has its own state machine
354+ if (sub_protocol == SLT6_Tx)
355+ return SLT6_callback ();
356+
227357 switch (phase)
228358 {
229359 case SLT_BUILD:
@@ -323,7 +453,15 @@ void SLT_init()
323453 packet_sent = 0 ;
324454 hopping_frequency_no = 0 ;
325455
326- if (sub_protocol == SLT_V1)
456+ if (sub_protocol == SLT6_Tx)
457+ {
458+ hopping_frequency_no = 1 ; // SLT6 starts hopping at index 1 (verified from captures)
459+ // packet_length not used for SLT6 (lengths vary per sub-cycle)
460+ #ifdef MULTI_SYNC
461+ packet_period = SLT6_TIMING_TRIPLE;
462+ #endif
463+ }
464+ else if (sub_protocol == SLT_V1)
327465 {
328466 packet_length = SLT_PAYLOADSIZE_V1;
329467 rf_ch_num = 1 ; // 2 packets per frame
@@ -397,7 +535,10 @@ void SLT_init()
397535 SLT_RF_init ();
398536 SLT_set_freq ();
399537
400- phase = SLT_BUILD;
538+ if (sub_protocol == SLT6_Tx)
539+ phase = SLT6_BUILD_A;
540+ else
541+ phase = SLT_BUILD;
401542}
402543
403544#endif
0 commit comments