SLT: added sub_protocols

SLT (11) sub_protocols are now
 - V1 (0): original 6 channels
 - V2 (1): 6 channels, might be able to add channel 7 and 8 but need testing
 - Q200 (2): 5 channels + switches: CH9=FMODE, CH10=FLIP, CH11=VIDON, CH12=VIDOFF
This commit is contained in:
Pascal Langer 2018-09-03 16:02:43 +02:00
parent 2ac20cb575
commit 82fb5dd0da
5 changed files with 115 additions and 39 deletions

View File

@ -8,7 +8,7 @@
8,YD717,YD717,SKYWLKR,SYMAX4,XINXUN,NIHUI 8,YD717,YD717,SKYWLKR,SYMAX4,XINXUN,NIHUI
9,KN,WLTOYS,FEILUN 9,KN,WLTOYS,FEILUN
10,SymaX,SYMAX,SYMAX5C 10,SymaX,SYMAX,SYMAX5C
11,SLT,SLT,VISTA 11,SLT,SLT_V1,SLT_V2,Q200
12,CX10,GREEN,BLUE,DM007,---,J3015_1,J3015_2,MK33041 12,CX10,GREEN,BLUE,DM007,---,J3015_1,J3015_2,MK33041
13,CG023,CG023,YD829 13,CG023,CG023,YD829
14,Bayang,Bayang,H8S3D,X16_AH,IRDRONE 14,Bayang,Bayang,H8S3D,X16_AH,IRDRONE

View File

@ -19,7 +19,7 @@
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_REVISION 0 #define VERSION_REVISION 0
#define VERSION_PATCH_LEVEL 36 #define VERSION_PATCH_LEVEL 38
//****************** //******************
// Protocols // Protocols
@ -76,7 +76,7 @@ enum Flysky
V9X9 = 1, V9X9 = 1,
V6X6 = 2, V6X6 = 2,
V912 = 3, V912 = 3,
CX20 = 4 CX20 = 4,
}; };
enum Hubsan enum Hubsan
{ {
@ -94,7 +94,7 @@ enum AFHDS2A
enum Hisky enum Hisky
{ {
Hisky = 0, Hisky = 0,
HK310 = 1 HK310 = 1,
}; };
enum DSM enum DSM
{ {
@ -102,7 +102,7 @@ enum DSM
DSM2_11 = 1, DSM2_11 = 1,
DSMX_22 = 2, DSMX_22 = 2,
DSMX_11 = 3, DSMX_11 = 3,
DSM_AUTO = 4 DSM_AUTO = 4,
}; };
enum YD717 enum YD717
{ {
@ -110,22 +110,23 @@ enum YD717
SKYWLKR = 1, SKYWLKR = 1,
SYMAX4 = 2, SYMAX4 = 2,
XINXUN = 3, XINXUN = 3,
NIHUI = 4 NIHUI = 4,
}; };
enum KN enum KN
{ {
WLTOYS = 0, WLTOYS = 0,
FEILUN = 1 FEILUN = 1,
}; };
enum SYMAX enum SYMAX
{ {
SYMAX = 0, SYMAX = 0,
SYMAX5C = 1 SYMAX5C = 1,
}; };
enum SLT enum SLT
{ {
SLT = 0, SLT_V1 = 0,
VISTA = 1 SLT_V2 = 1,
Q200 = 2,
}; };
enum CX10 enum CX10
{ {
@ -163,7 +164,7 @@ enum MT99XX
H7 = 1, H7 = 1,
YZ = 2, YZ = 2,
LS = 3, LS = 3,
FY805 = 4 FY805 = 4,
}; };
enum MJXQ enum MJXQ
{ {
@ -185,8 +186,8 @@ enum HONTAI
{ {
HONTAI = 0, HONTAI = 0,
JJRCX1 = 1, JJRCX1 = 1,
X5C1 = 2, X5C1 = 2,
FQ777_951 =3 FQ777_951 =3,
}; };
enum V2X2 enum V2X2
{ {
@ -698,6 +699,10 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
OPT_FW 0 OPT_FW 0
OPT_HUB 1 OPT_HUB 1
MINIMA 2 MINIMA 2
sub_protocol==SLT
SLT_V1 0
SLT_V2 1
Q200 2
Power value => 0x80 0=High/1=Low Power value => 0x80 0=High/1=Low
Stream[3] = option_protocol; Stream[3] = option_protocol;

View File

@ -19,16 +19,26 @@
#include "iface_nrf24l01.h" #include "iface_nrf24l01.h"
// For code readability // For code readability
#define SLT_PAYLOADSIZE 7 #define SLT_PAYLOADSIZE_V1 7
#define SLT_PAYLOADSIZE_V2 11
#define SLT_NFREQCHANNELS 15 #define SLT_NFREQCHANNELS 15
#define SLT_TXID_SIZE 4 #define SLT_TXID_SIZE 4
enum{
// flags going to packet[6] (Q200)
FLAG_Q200_FMODE = 0x20,
FLAG_Q200_VIDON = 0x10,
FLAG_Q200_FLIP = 0x08,
FLAG_Q200_VIDOFF= 0x04,
};
enum { enum {
SLT_BUILD=0, SLT_BUILD=0,
SLT_DATA1, SLT_DATA1,
SLT_DATA2, SLT_DATA2,
SLT_DATA3, SLT_DATA3,
SLT_BIND SLT_BIND1,
SLT_BIND2
}; };
static void __attribute__((unused)) SLT_init() static void __attribute__((unused)) SLT_init()
@ -43,7 +53,10 @@ static void __attribute__((unused)) SLT_init()
NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, 4); // bytes of data payload for pipe 1 NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, 4); // bytes of data payload for pipe 1
NRF24L01_SetBitrate(NRF24L01_BR_250K); // 256kbps NRF24L01_SetBitrate(NRF24L01_BR_250K); // 256kbps
NRF24L01_SetPower(); NRF24L01_SetPower();
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, (uint8_t*)"\xC3\xC3\xAA\x55", 4); if(sub_protocol==SLT_V1)
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, (uint8_t*)"\xC3\xC3\xAA\x55", 4);
else // V2
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, (uint8_t*)"\x7E\xB8\x63\xA9", 4);
NRF24L01_FlushRx(); NRF24L01_FlushRx();
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, rx_tx_addr, SLT_TXID_SIZE); NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, rx_tx_addr, SLT_TXID_SIZE);
NRF24L01_FlushTx(); NRF24L01_FlushTx();
@ -53,6 +66,9 @@ static void __attribute__((unused)) SLT_init()
static void __attribute__((unused)) SLT_set_freq(void) static void __attribute__((unused)) SLT_set_freq(void)
{ {
// Use adress 1-3 for model match
for (uint8_t i = 0; i < SLT_TXID_SIZE; ++i)
rx_tx_addr[i]=rx_tx_addr[i+1];
// Frequency hopping sequence generation // Frequency hopping sequence generation
for (uint8_t i = 0; i < SLT_TXID_SIZE; ++i) for (uint8_t i = 0; i < SLT_TXID_SIZE; ++i)
{ {
@ -91,12 +107,12 @@ static void __attribute__((unused)) SLT_wait_radio()
packet_sent = 0; packet_sent = 0;
} }
static void __attribute__((unused)) SLT_send_data(uint8_t *data, uint8_t len) static void __attribute__((unused)) SLT_send_packet(uint8_t len)
{ {
SLT_wait_radio(); SLT_wait_radio();
NRF24L01_FlushTx(); NRF24L01_FlushTx();
NRF24L01_WriteReg(NRF24L01_07_STATUS, _BV(NRF24L01_07_TX_DS) | _BV(NRF24L01_07_RX_DR) | _BV(NRF24L01_07_MAX_RT)); NRF24L01_WriteReg(NRF24L01_07_STATUS, _BV(NRF24L01_07_TX_DS) | _BV(NRF24L01_07_RX_DR) | _BV(NRF24L01_07_MAX_RT));
NRF24L01_WritePayload(data, len); NRF24L01_WritePayload(packet, len);
//NRF24L01_PulseCE(); //NRF24L01_PulseCE();
packet_sent = 1; packet_sent = 1;
} }
@ -108,7 +124,7 @@ static void __attribute__((unused)) SLT_build_packet()
if (++hopping_frequency_no >= SLT_NFREQCHANNELS) if (++hopping_frequency_no >= SLT_NFREQCHANNELS)
hopping_frequency_no = 0; hopping_frequency_no = 0;
// aileron, elevator, throttle, rudder, gear, pitch // aileron, elevator, throttle, rudder, gear, pitch
uint8_t e = 0; // byte where extension 2 bits for every 10-bit channel are packed uint8_t e = 0; // byte where extension 2 bits for every 10-bit channel are packed
for (uint8_t i = 0; i < 4; ++i) for (uint8_t i = 0; i < 4; ++i)
{ {
@ -121,6 +137,20 @@ static void __attribute__((unused)) SLT_build_packet()
// 8-bit channels // 8-bit channels
packet[5] = convert_channel_8b(CH5); packet[5] = convert_channel_8b(CH5);
packet[6] = convert_channel_8b(CH6); packet[6] = convert_channel_8b(CH6);
if(sub_protocol!=SLT_V1)
{
if(sub_protocol==Q200)
{
packet[6] = GET_FLAG(CH9_SW, FLAG_Q200_FMODE)
|GET_FLAG(CH10_SW, FLAG_Q200_FLIP)
|GET_FLAG(CH11_SW, FLAG_Q200_VIDON)
|GET_FLAG(CH12_SW, FLAG_Q200_VIDOFF);
}
packet[7]=0x00; //unknown, ch7?? To try : = convert_channel_8b(CH7);
packet[8]=0x7F; //unknown, ch8?? To try : = convert_channel_8b(CH8);
packet[9]=0xAA; //unknown
packet[10]=0x00; //unknown
}
} }
static void __attribute__((unused)) SLT_send_bind_packet() static void __attribute__((unused)) SLT_send_bind_packet()
@ -132,14 +162,25 @@ static void __attribute__((unused)) SLT_send_bind_packet()
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, (uint8_t *)"\x7E\xB8\x63\xA9", SLT_TXID_SIZE); NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, (uint8_t *)"\x7E\xB8\x63\xA9", SLT_TXID_SIZE);
NRF24L01_WriteReg(NRF24L01_05_RF_CH, 0x50); NRF24L01_WriteReg(NRF24L01_05_RF_CH, 0x50);
SLT_send_data(rx_tx_addr, SLT_TXID_SIZE); memcpy((void*)packet,(void*)rx_tx_addr,SLT_TXID_SIZE);
if(phase==SLT_BIND2)
SLT_send_packet(SLT_TXID_SIZE);
else // SLT_BIND1
SLT_send_packet(SLT_PAYLOADSIZE_V2);
SLT_wait_radio(); //Wait until the packet's sent before changing TX address! SLT_wait_radio(); //Wait until the packet's sent before changing TX address!
NRF24L01_SetPower(); //Change power back to normal level NRF24L01_SetPower(); //Change power back to normal level
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, rx_tx_addr, SLT_TXID_SIZE); if(phase==SLT_BIND2) // after V1 bind and V2 second bind packet
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, rx_tx_addr, SLT_TXID_SIZE);
} }
#define SLT_TIMING_BUILD 1000
#define SLT_V1_TIMING_PACKET 1000
#define SLT_V2_TIMING_PACKET 2042
#define SLT_V1_TIMING_BIND2 1000
#define SLT_V2_TIMING_BIND1 6507
#define SLT_V2_TIMING_BIND2 2112
uint16_t SLT_callback() uint16_t SLT_callback()
{ {
switch (phase) switch (phase)
@ -147,33 +188,59 @@ uint16_t SLT_callback()
case SLT_BUILD: case SLT_BUILD:
SLT_build_packet(); SLT_build_packet();
phase++; phase++;
return 1000; return SLT_TIMING_BUILD;
case SLT_DATA1: case SLT_DATA1:
SLT_send_data(packet, SLT_PAYLOADSIZE);
phase++;
return 1000;
case SLT_DATA2: case SLT_DATA2:
SLT_send_data(packet, SLT_PAYLOADSIZE);
phase++; phase++;
return 1000; if(sub_protocol==SLT_V1)
case SLT_DATA3:
SLT_send_data(packet, SLT_PAYLOADSIZE);
if (++packet_count >= 100)
{ {
SLT_send_packet(SLT_PAYLOADSIZE_V1);
return SLT_V1_TIMING_PACKET;
}
else //V2
{
SLT_send_packet(SLT_PAYLOADSIZE_V2);
return SLT_V2_TIMING_PACKET;
}
case SLT_DATA3:
if(sub_protocol==SLT_V1)
SLT_send_packet(SLT_PAYLOADSIZE_V1);
else //V2
SLT_send_packet(SLT_PAYLOADSIZE_V2);
if (++packet_count >= 100)
{// Send bind packet
packet_count = 0; packet_count = 0;
phase++; if(sub_protocol==SLT_V1)
return 1000; {
phase=SLT_BIND2;
return SLT_V1_TIMING_BIND2;
}
else //V2
{
phase=SLT_BIND1;
return SLT_V2_TIMING_BIND1;
}
} }
else else
{ {// Continue to send normal packets
NRF24L01_SetPower(); // Set tx_power NRF24L01_SetPower(); // Set tx_power
phase = SLT_BUILD; phase = SLT_BUILD;
return 19000; if(sub_protocol==SLT_V1)
return 20000-SLT_TIMING_BUILD;
else //V2
return 13730-SLT_TIMING_BUILD;
} }
case SLT_BIND: case SLT_BIND1:
SLT_send_bind_packet();
phase++;
return SLT_V2_TIMING_BIND2;
case SLT_BIND2:
SLT_send_bind_packet(); SLT_send_bind_packet();
phase = SLT_BUILD; phase = SLT_BUILD;
return 18000; if(sub_protocol==SLT_V1)
return 20000-SLT_TIMING_BUILD-SLT_V1_TIMING_BIND2;
else //V2
return 13730-SLT_TIMING_BUILD-SLT_V2_TIMING_BIND1-SLT_V2_TIMING_BIND2;
} }
return 19000; return 19000;
} }
@ -185,7 +252,7 @@ uint16_t initSLT()
hopping_frequency_no = 0; hopping_frequency_no = 0;
SLT_set_freq(); SLT_set_freq();
SLT_init(); SLT_init();
phase = SLT_BIND; phase = SLT_BUILD;
return 50000; return 50000;
} }

View File

@ -57,7 +57,7 @@ const uint8_t PROGMEM WFLY_init_vals[][2] = {
static void __attribute__((unused)) WFLY_cyrf_bind_config() static void __attribute__((unused)) WFLY_cyrf_bind_config()
{ {
for(uint8_t i = 0; i < sizeof(init_vals) / 2; i++) for(uint8_t i = 0; i < sizeof(WFLY_init_vals) / 2; i++)
CYRF_WriteRegister(pgm_read_byte_near(&WFLY_init_vals[i][0]), pgm_read_byte_near(&WFLY_init_vals[i][1])); CYRF_WriteRegister(pgm_read_byte_near(&WFLY_init_vals[i][0]), pgm_read_byte_near(&WFLY_init_vals[i][1]));
CYRF_PROGMEM_ConfigSOPCode(WFLY_sop_bind); CYRF_PROGMEM_ConfigSOPCode(WFLY_sop_bind);
@ -67,7 +67,7 @@ static void __attribute__((unused)) WFLY_cyrf_bind_config()
static void __attribute__((unused)) WFLY_cyrf_data_config() static void __attribute__((unused)) WFLY_cyrf_data_config()
{ {
for(uint8_t i = 0; i < (sizeof(init_vals) / 2)-3; i++) for(uint8_t i = 0; i < (sizeof(WFLY_init_vals) / 2)-3; i++)
CYRF_WriteRegister(pgm_read_byte_near(&WFLY_init_vals[i][0]), pgm_read_byte_near(&WFLY_init_vals[i][1])); CYRF_WriteRegister(pgm_read_byte_near(&WFLY_init_vals[i][0]), pgm_read_byte_near(&WFLY_init_vals[i][1]));
//CYRF_WriteRegister(CYRF_1E_RX_OVERRIDE, 0x08); // Do not accept CRC with 0 seed but not needed since the RX is not sending any data... //CYRF_WriteRegister(CYRF_1E_RX_OVERRIDE, 0x08); // Do not accept CRC with 0 seed but not needed since the RX is not sending any data...

View File

@ -562,6 +562,10 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
NONE NONE
PROTO_BUGS PROTO_BUGS
NONE NONE
PROTO_SLT
SLT_V1
SLT_V2
Q200
*/ */
// RX_Num is used for TX & RX match. Using different RX_Num values for each receiver will prevent starting a model with the false config loaded... // RX_Num is used for TX & RX match. Using different RX_Num values for each receiver will prevent starting a model with the false config loaded...