Introduction of Banks for the switch protocol selection

This commit is contained in:
Pascal Langer
2018-01-30 12:02:45 +01:00
parent f4a4f67453
commit ab27ee50b0
12 changed files with 449 additions and 280 deletions

View File

@@ -27,7 +27,7 @@ void A7105_WriteData(uint8_t len, uint8_t channel)
for (i = 0; i < len; i++)
SPI_Write(packet[i]);
A7105_CSN_on;
if(protocol!=MODE_FLYSKY)
if(protocol!=PROTO_FLYSKY)
{
A7105_Strobe(A7105_STANDBY); //Force standby mode, ie cancel any TX or RX...
A7105_SetTxRxMode(TX_EN); //Switch to PA
@@ -177,17 +177,17 @@ void A7105_AdjustLOBaseFreq(uint8_t cmd)
old_offset=2048;
switch(protocol)
{
case MODE_HUBSAN:
case PROTO_HUBSAN:
#ifdef FORCE_HUBSAN_TUNING
offset=(int16_t)FORCE_HUBSAN_TUNING;
#endif
break;
case MODE_FLYSKY:
case PROTO_FLYSKY:
#ifdef FORCE_FLYSKY_TUNING
offset=(int16_t)FORCE_FLYSKY_TUNING;
#endif
break;
case MODE_AFHDS2A:
case PROTO_AFHDS2A:
#ifdef FORCE_AFHDS2A_TUNING
offset=(int16_t)FORCE_AFHDS2A_TUNING;
#endif
@@ -255,7 +255,7 @@ void A7105_Init(void)
uint8_t *A7105_Regs=0;
#ifdef HUBSAN_A7105_INO
if(protocol==MODE_HUBSAN)
if(protocol==PROTO_HUBSAN)
{
A7105_WriteID(ID_NORMAL);
A7105_Regs=(uint8_t*)HUBSAN_A7105_regs;
@@ -265,7 +265,7 @@ void A7105_Init(void)
{
A7105_WriteID(0x5475c52A);//0x2Ac57554
#ifdef FLYSKY_A7105_INO
if(protocol==MODE_FLYSKY)
if(protocol==PROTO_FLYSKY)
A7105_Regs=(uint8_t*)FLYSKY_A7105_regs;
else
#endif
@@ -280,7 +280,7 @@ void A7105_Init(void)
{
uint8_t val=pgm_read_byte_near(&A7105_Regs[i]);
#ifdef FLYSKY_A7105_INO
if(protocol==MODE_FLYSKY && sub_protocol==CX20)
if(protocol==PROTO_FLYSKY && sub_protocol==CX20)
{
if(i==0x0E) val=0x01;
if(i==0x1F) val=0x1F;
@@ -298,7 +298,7 @@ void A7105_Init(void)
// A7105_ReadReg(A7105_22_IF_CALIB_I);
// A7105_ReadReg(A7105_24_VCO_CURCAL);
if(protocol!=MODE_HUBSAN)
if(protocol!=PROTO_HUBSAN)
{
//VCO Current Calibration
A7105_WriteReg(A7105_24_VCO_CURCAL,0x13); //Recommended calibration from A7105 Datasheet
@@ -319,8 +319,8 @@ void A7105_Init(void)
// A7105_ReadReg(A7105_25_VCO_SBCAL_I);
//Reset VCO Band calibration
if(protocol!=MODE_HUBSAN)
A7105_WriteReg(A7105_25_VCO_SBCAL_I,protocol==MODE_FLYSKY?0x08:0x0A);
if(protocol!=PROTO_HUBSAN)
A7105_WriteReg(A7105_25_VCO_SBCAL_I,protocol==PROTO_FLYSKY?0x08:0x0A);
A7105_SetTxRxMode(TX_EN);
A7105_SetPower();

View File

@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
*/
// compatible with Cheerson CX-10 blue & newer red pcb, CX-10A, CX11, CX-10 green pcb, DM007, Floureon FX-10, JXD 509 (Q282)
// compatible with Cheerson CX-10 blue & newer red pcb, CX-10A, CX11, CX-10 green pcb, DM007, Floureon FX-10, JXD 509 (Q282), Q222, Q242 and Q282
// Last sync with hexfet new_protocols/cx10_nrf24l01.c dated 2015-11-26
#if defined(CX10_NRF24L01_INO)
@@ -81,9 +81,9 @@ static void __attribute__((unused)) CX10_Write_Packet(uint8_t bind)
flags |= GET_FLAG(!CH7_SW, 0x10) // Channel 7 - picture
|GET_FLAG( CH8_SW, 0x08); // Channel 8 - video
break;
case Q282:
case Q242:
case Q222:
case F_Q282:
case F_Q242:
case F_Q222:
memcpy(&packet[15], "\x10\x10\xaa\xaa\x00\x00", 6);
//FLIP|LED|PICTURE|VIDEO|HEADLESS|RTH|XCAL|YCAL
flags2 = GET_FLAG(CH5_SW, 0x80) // Channel 5 - FLIP
@@ -92,7 +92,7 @@ static void __attribute__((unused)) CX10_Write_Packet(uint8_t bind)
|GET_FLAG(CH11_SW, 0x04) // Channel 11 - XCAL
|GET_FLAG(CH12_SW, 0x02); // Channel 12 - YCAL or Start/Stop motors on JXD 509
if(sub_protocol==Q242)
if(sub_protocol==F_Q242)
{
flags=2;
flags2|= GET_FLAG(CH7_SW,0x01) // Channel 7 - picture
@@ -101,16 +101,16 @@ static void __attribute__((unused)) CX10_Write_Packet(uint8_t bind)
packet[18]=0x00;
}
else
{ // Q282 & Q222
{ // F_Q282 & F_Q222
flags=3; // expert
if(CH8_SW) // Channel 8 - Q282 video / Q222 Module 1
if(CH8_SW) // Channel 8 - F_Q282 video / F_Q222 Module 1
{
if (!(video_state & 0x20)) video_state ^= 0x21;
}
else
if (video_state & 0x20) video_state &= 0x01;
flags2 |= video_state
|GET_FLAG(CH7_SW,0x10); // Channel 7 - Q282 picture / Q222 Module 2
|GET_FLAG(CH7_SW,0x10); // Channel 7 - F_Q282 picture / F_Q222 Module 2
}
if(CH10_SW) flags |=0x80; // Channel 10 - RTH
break;
@@ -238,12 +238,12 @@ uint16_t CX10_callback()
static void __attribute__((unused)) CX10_initialize_txid()
{
rx_tx_addr[1]%= 0x30;
if(sub_protocol&0x08) //Q2X2 protocols
if(sub_protocol&0x08) //F_Q2X2 protocols
{
uint8_t offset=0; //Q282
if(sub_protocol==Q242)
uint8_t offset=0; //F_Q282
if(sub_protocol==F_Q242)
offset=2;
if(sub_protocol==Q222)
if(sub_protocol==F_Q222)
offset=3;
for(uint8_t i=0;i<4;i++)
hopping_frequency[i]=0x46+2*i+offset;
@@ -272,7 +272,7 @@ uint16_t initCX10(void)
}
else
{
if(sub_protocol&0x08) //Q2X2 protocols
if(sub_protocol&0x08) //F_Q2X2 protocols
packet_length = Q2X2_PACKET_SIZE;
else
packet_length = CX10_PACKET_SIZE;

View File

@@ -63,7 +63,7 @@ static void __attribute__((unused)) DEVO_add_pkt_suffix()
BIND_SET_PULLUP; // set pullup
if(IS_BIND_BUTTON_on)
{
eeprom_write_byte((EE_ADDR)(MODELMODE_EEPROM_OFFSET+mode_select),0x01); // Set fixed id mode for the current model
eeprom_write_byte((EE_ADDR)(MODELMODE_EEPROM_OFFSET+RX_num),0x01); // Set fixed id mode for the current model
option=1;
}
BIND_SET_OUTPUT;

View File

@@ -73,18 +73,18 @@ static void __attribute__((unused)) HONTAI_send_packet(uint8_t bind)
packet[4] = convert_channel_16b_limit(AILERON, 63, 0); // Aileron
packet[5] = convert_channel_16b_limit(ELEVATOR, 0, 63); // Elevator
packet[6] = convert_channel_16b_limit(RUDDER, 0, 63); // Rudder
if(sub_protocol == FORMAT_X5C1)
if(sub_protocol == X5C1)
packet[7] = convert_channel_16b_limit(AILERON, 0, 63)-31; // Aileron trim
else
packet[7] = convert_channel_16b_limit(AILERON, 0, 32)-16; // Aileron trim
packet[8] = convert_channel_16b_limit(RUDDER, 0, 32)-16; // Rudder trim
if (sub_protocol == FORMAT_X5C1)
if (sub_protocol == X5C1)
packet[9] = convert_channel_16b_limit(ELEVATOR, 0, 63)-31; // Elevator trim
else
packet[9] = convert_channel_16b_limit(ELEVATOR, 0, 32)-16; // Elevator trim
switch(sub_protocol)
{
case FORMAT_HONTAI:
case HONTAI:
packet[0] = 0x0B;
packet[3] |= GET_FLAG(CH7_SW, 0x01); // Picture
packet[4] |= GET_FLAG(CH10_SW, 0x80) // RTH
@@ -93,7 +93,7 @@ static void __attribute__((unused)) HONTAI_send_packet(uint8_t bind)
| GET_FLAG(CH5_SW, 0x40); // Flip
packet[6] |= GET_FLAG(CH8_SW, 0x80); // Video
break;
case FORMAT_JJRCX1:
case JJRCX1:
packet[0] = GET_FLAG(CH6_SW, 0x02); // Arm
packet[3] |= GET_FLAG(CH7_SW, 0x01); // Picture
packet[4] |= 0x80; // unknown
@@ -104,7 +104,7 @@ static void __attribute__((unused)) HONTAI_send_packet(uint8_t bind)
| GET_FLAG(CH10_SW, 0x02) // RTH
| GET_FLAG(CH9_SW, 0x01); // Headless
break;
case FORMAT_X5C1:
case X5C1:
packet[0] = 0x0B;
packet[3] |= GET_FLAG(CH7_SW, 0x01); // Picture
packet[4] = 0x80 // unknown
@@ -116,7 +116,7 @@ static void __attribute__((unused)) HONTAI_send_packet(uint8_t bind)
| GET_FLAG(CH10_SW, 0x02) // RTH
| GET_FLAG(CH9_SW, 0x01); // Headless
break;
case FORMAT_FQ777_951:
case FQ777_951:
packet[0] = GET_FLAG(CH7_SW, 0x01) // Picture
| GET_FLAG(CH8_SW, 0x02); // Video
packet[3] |= GET_FLAG(CH5_SW, 0x01); // Flip
@@ -129,7 +129,7 @@ static void __attribute__((unused)) HONTAI_send_packet(uint8_t bind)
crc16(packet, bind ? HONTAI_BIND_PACKET_SIZE:HONTAI_PACKET_SIZE);
// Power on, TX mode, 2byte CRC
if(sub_protocol == FORMAT_JJRCX1)
if(sub_protocol == JJRCX1)
NRF24L01_SetTxRxMode(TX_EN);
else
XN297_Configure(_BV(NRF24L01_00_EN_CRC) | _BV(NRF24L01_00_CRCO) | _BV(NRF24L01_00_PWR_UP));
@@ -140,7 +140,7 @@ static void __attribute__((unused)) HONTAI_send_packet(uint8_t bind)
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70);
NRF24L01_FlushTx();
if(sub_protocol == FORMAT_JJRCX1)
if(sub_protocol == JJRCX1)
NRF24L01_WritePayload(packet, bind ? HONTAI_BIND_PACKET_SIZE:HONTAI_PACKET_SIZE);
else
XN297_WritePayload(packet, bind ? HONTAI_BIND_PACKET_SIZE:HONTAI_PACKET_SIZE);
@@ -154,7 +154,7 @@ static void __attribute__((unused)) HONTAI_init()
NRF24L01_SetTxRxMode(TX_EN);
if(sub_protocol == FORMAT_JJRCX1)
if(sub_protocol == JJRCX1)
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, (uint8_t*)"\xd2\xb5\x99\xb3\x4a", 5);
else
XN297_SetTXAddr((const uint8_t*)"\xd2\xb5\x99\xb3\x4a", 5);
@@ -166,7 +166,7 @@ static void __attribute__((unused)) HONTAI_init()
NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps
NRF24L01_SetPower();
NRF24L01_Activate(0x73); // Activate feature register
if(sub_protocol == FORMAT_JJRCX1)
if(sub_protocol == JJRCX1)
{
NRF24L01_WriteReg(NRF24L01_04_SETUP_RETR, 0xff); // JJRC uses dynamic payload length
NRF24L01_WriteReg(NRF24L01_1C_DYNPD, 0x3f); // match other stock settings even though AA disabled...
@@ -201,21 +201,21 @@ static void __attribute__((unused)) HONTAI_init2()
data_tx_addr[2] = pgm_read_byte_near( &HONTAI_addr_vals[2][ rx_tx_addr[4] & 0x0f]);
data_tx_addr[3] = pgm_read_byte_near( &HONTAI_addr_vals[3][(rx_tx_addr[4] >> 4) & 0x0f]);
data_tx_addr[4] = 0x24;
if(sub_protocol == FORMAT_JJRCX1)
if(sub_protocol == JJRCX1)
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, data_tx_addr, sizeof(data_tx_addr));
else
XN297_SetTXAddr(data_tx_addr, sizeof(data_tx_addr));
//Hopping frequency table
for(uint8_t i=0;i<3;i++)
hopping_frequency[i]=pgm_read_byte_near( &HONTAI_hopping_frequency_nonels[sub_protocol == FORMAT_JJRCX1?1:0][i] );
hopping_frequency[i]=pgm_read_byte_near( &HONTAI_hopping_frequency_nonels[sub_protocol == JJRCX1?1:0][i] );
hopping_frequency_no=0;
}
static void __attribute__((unused)) HONTAI_initialize_txid()
{
rx_tx_addr[4] = rx_tx_addr[2];
if(sub_protocol == FORMAT_HONTAI || sub_protocol == FORMAT_FQ777_951)
if(sub_protocol == HONTAI || sub_protocol == FQ777_951)
{
rx_tx_addr[0] = 0x4c; // first three bytes some kind of model id? - set same as stock tx
rx_tx_addr[1] = 0x4b;
@@ -244,7 +244,7 @@ uint16_t HONTAI_callback()
else
HONTAI_send_packet(0);
return sub_protocol == FORMAT_FQ777_951 ? FQ777_951_PACKET_PERIOD : HONTAI_PACKET_PERIOD;
return sub_protocol == FQ777_951 ? FQ777_951_PACKET_PERIOD : HONTAI_PACKET_PERIOD;
}
uint16_t initHONTAI()

View File

@@ -19,50 +19,50 @@
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_REVISION 0
#define VERSION_PATCH_LEVEL 15
#define VERSION_PATCH_LEVEL 16
//******************
// Protocols
//******************
enum PROTOCOLS
{
MODE_SERIAL = 0, // Serial commands
MODE_FLYSKY = 1, // =>A7105
MODE_HUBSAN = 2, // =>A7105
MODE_FRSKYD = 3, // =>CC2500
MODE_HISKY = 4, // =>NRF24L01
MODE_V2X2 = 5, // =>NRF24L01
MODE_DSM = 6, // =>CYRF6936
MODE_DEVO = 7, // =>CYRF6936
MODE_YD717 = 8, // =>NRF24L01
MODE_KN = 9, // =>NRF24L01
MODE_SYMAX = 10, // =>NRF24L01
MODE_SLT = 11, // =>NRF24L01
MODE_CX10 = 12, // =>NRF24L01
MODE_CG023 = 13, // =>NRF24L01
MODE_BAYANG = 14, // =>NRF24L01
MODE_FRSKYX = 15, // =>CC2500
MODE_ESKY = 16, // =>NRF24L01
MODE_MT99XX = 17, // =>NRF24L01
MODE_MJXQ = 18, // =>NRF24L01
MODE_SHENQI = 19, // =>NRF24L01
MODE_FY326 = 20, // =>NRF24L01
MODE_SFHSS = 21, // =>CC2500
MODE_J6PRO = 22, // =>CYRF6936
MODE_FQ777 = 23, // =>NRF24L01
MODE_ASSAN = 24, // =>NRF24L01
MODE_FRSKYV = 25, // =>CC2500
MODE_HONTAI = 26, // =>NRF24L01
MODE_OPENLRS = 27, // =>OpenLRS hardware
MODE_AFHDS2A = 28, // =>A7105
MODE_Q2X2 = 29, // =>NRF24L01, extension of CX-10 protocol
MODE_WK2x01 = 30, // =>CYRF6936
MODE_Q303 = 31, // =>NRF24L01
MODE_GW008 = 32, // =>NRF24L01
MODE_DM002 = 33, // =>NRF24L01
MODE_CABELL = 34, // =>NRF24L01
MODE_ESKY150 = 35, // =>NRF24L01
MODE_H8_3D = 36, // =>NRF24L01
MODE_CORONA = 37, // =>CC2500
PROTO_FLYSKY = 1, // =>A7105
PROTO_HUBSAN = 2, // =>A7105
PROTO_FRSKYD = 3, // =>CC2500
PROTO_HISKY = 4, // =>NRF24L01
PROTO_V2X2 = 5, // =>NRF24L01
PROTO_DSM = 6, // =>CYRF6936
PROTO_DEVO = 7, // =>CYRF6936
PROTO_YD717 = 8, // =>NRF24L01
PROTO_KN = 9, // =>NRF24L01
PROTO_SYMAX = 10, // =>NRF24L01
PROTO_SLT = 11, // =>NRF24L01
PROTO_CX10 = 12, // =>NRF24L01
PROTO_CG023 = 13, // =>NRF24L01
PROTO_BAYANG = 14, // =>NRF24L01
PROTO_FRSKYX = 15, // =>CC2500
PROTO_ESKY = 16, // =>NRF24L01
PROTO_MT99XX = 17, // =>NRF24L01
PROTO_MJXQ = 18, // =>NRF24L01
PROTO_SHENQI = 19, // =>NRF24L01
PROTO_FY326 = 20, // =>NRF24L01
PROTO_SFHSS = 21, // =>CC2500
PROTO_J6PRO = 22, // =>CYRF6936
PROTO_FQ777 = 23, // =>NRF24L01
PROTO_ASSAN = 24, // =>NRF24L01
PROTO_FRSKYV = 25, // =>CC2500
PROTO_HONTAI = 26, // =>NRF24L01
PROTO_OPENLRS = 27, // =>OpenLRS hardware
PROTO_AFHDS2A = 28, // =>A7105
PROTO_Q2X2 = 29, // =>NRF24L01, extension of CX-10 protocol
PROTO_WK2x01 = 30, // =>CYRF6936
PROTO_Q303 = 31, // =>NRF24L01
PROTO_GW008 = 32, // =>NRF24L01
PROTO_DM002 = 33, // =>NRF24L01
PROTO_CABELL = 34, // =>NRF24L01
PROTO_ESKY150 = 35, // =>NRF24L01
PROTO_H8_3D = 36, // =>NRF24L01
PROTO_CORONA = 37, // =>CC2500
};
enum Flysky
@@ -133,9 +133,12 @@ enum CX10
};
enum Q2X2
{
Q222 = 8,
Q242 = 9,
Q282 = 10,
Q222 = 0,
Q242 = 1,
Q282 = 2,
F_Q222 = 8,
F_Q242 = 9,
F_Q282 = 10,
};
enum CG023
{
@@ -175,10 +178,10 @@ enum FRSKYX
};
enum HONTAI
{
FORMAT_HONTAI = 0,
FORMAT_JJRCX1 = 1,
FORMAT_X5C1 = 2,
FORMAT_FQ777_951 =3
HONTAI = 0,
JJRCX1 = 1,
X5C1 = 2,
FQ777_951 =3
};
enum V2X2
{
@@ -359,6 +362,9 @@ enum MultiPacketTypes
#define BLINK_BAD_PROTO_TIME_LOW 1000
#define BLINK_WAIT_BIND_TIME_HIGH 1000
#define BLINK_WAIT_BIND_TIME_LOW 100
#define BLINK_BANK_TIME_HIGH 50
#define BLINK_BANK_TIME_LOW 500
#define BLINK_BANK_REPEAT 1500
//*******************
//*** AUX flags ***
@@ -490,12 +496,12 @@ enum {
/** EEPROM Layout */
#define EEPROM_ID_OFFSET 10 // Module ID (4 bytes)
#define EEPROM_BANK_OFFSET 15 // Current bank number (1 byte)
#define EEPROM_ID_VALID_OFFSET 20 // 1 byte flag that ID is valid
#define MODELMODE_EEPROM_OFFSET 30 // Autobind mode, 1 byte per model, end is 46
#define AFHDS2A_EEPROM_OFFSET 50 // RX ID, 4 byte per model id, end is 114
#define CONFIG_EEPROM_OFFSET 120 // Current configuration of the multimodule
//****************************************
//*** MULTI protocol serial definition ***
//****************************************
@@ -629,10 +635,10 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
EU_16 2
EU_8 3
sub_protocol==HONTAI
FORMAT_HONTAI 0
FORMAT_JJRCX1 1
FORMAT_X5C1 2
FORMAT_FQ777_951 3
HONTAI 0
JJRCX1 1
X5C1 2
FQ777_951 3
sub_protocol==AFHDS2A
PWM_IBUS 0
PPM_IBUS 1

View File

@@ -38,7 +38,7 @@
#include "_Config.h"
//Personal config file
#if __has_include("_MyConfig.h") || defined(USE_MY_CONFIG)
#if defined(USE_MY_CONFIG)
#include "_MyConfig.h"
#endif
@@ -300,10 +300,10 @@ void setup()
SERIAL_TX_output;
// pullups
MODE_DIAL1_port |= _BV(MODE_DIAL1_pin);
MODE_DIAL2_port |= _BV(MODE_DIAL2_pin);
MODE_DIAL3_port |= _BV(MODE_DIAL3_pin);
MODE_DIAL4_port |= _BV(MODE_DIAL4_pin);
PROTO_DIAL1_port |= _BV(PROTO_DIAL1_pin);
PROTO_DIAL2_port |= _BV(PROTO_DIAL2_pin);
PROTO_DIAL3_port |= _BV(PROTO_DIAL3_pin);
PROTO_DIAL4_port |= _BV(PROTO_DIAL4_pin);
BIND_port |= _BV(BIND_pin);
// Timer1 config
@@ -357,13 +357,17 @@ void setup()
mode_select= 0x0F -(uint8_t)(((GPIOA->regs->IDR)>>4)&0x0F);
#else
mode_select =
((MODE_DIAL1_ipr & _BV(MODE_DIAL1_pin)) ? 0 : 1) +
((MODE_DIAL2_ipr & _BV(MODE_DIAL2_pin)) ? 0 : 2) +
((MODE_DIAL3_ipr & _BV(MODE_DIAL3_pin)) ? 0 : 4) +
((MODE_DIAL4_ipr & _BV(MODE_DIAL4_pin)) ? 0 : 8);
((PROTO_DIAL1_ipr & _BV(PROTO_DIAL1_pin)) ? 0 : 1) +
((PROTO_DIAL2_ipr & _BV(PROTO_DIAL2_pin)) ? 0 : 2) +
((PROTO_DIAL3_ipr & _BV(PROTO_DIAL3_pin)) ? 0 : 4) +
((PROTO_DIAL4_ipr & _BV(PROTO_DIAL4_pin)) ? 0 : 8);
#endif
//mode_select=1;
debugln("Mode switch reads as %d", mode_select);
debugln("Protocol selection switch reads as %d", mode_select);
#ifdef ENABLE_PPM
uint8_t bank=bank_switch();
#endif
// Set default channels' value
InitChannel();
@@ -373,7 +377,7 @@ void setup()
// Update LED
LED_off;
LED_output;
LED_output;
//Init RF modules
modules_reset();
@@ -396,47 +400,47 @@ void setup()
//Protocol and interrupts initialization
if(mode_select != MODE_SERIAL)
{ // PPM
mode_select--;
protocol = PPM_prot[mode_select].protocol;
uint8_t line=bank*14+mode_select-1;
protocol = PPM_prot[line].protocol;
cur_protocol[1] = protocol;
sub_protocol = PPM_prot[mode_select].sub_proto;
RX_num = PPM_prot[mode_select].rx_num;
sub_protocol = PPM_prot[line].sub_proto;
RX_num = PPM_prot[line].rx_num;
//Forced frequency tuning values for CC2500 protocols
#if defined(FORCE_FRSKYD_TUNING) && defined(FRSKYD_CC2500_INO)
if(protocol==MODE_FRSKYD)
if(protocol==PROTO_FRSKYD)
option = FORCE_FRSKYD_TUNING; // Use config-defined tuning value for FrSkyD
else
#endif
#if defined(FORCE_FRSKYV_TUNING) && defined(FRSKYV_CC2500_INO)
if(protocol==MODE_FRSKYV)
if(protocol==PROTO_FRSKYV)
option = FORCE_FRSKYV_TUNING; // Use config-defined tuning value for FrSkyV
else
#endif
#if defined(FORCE_FRSKYX_TUNING) && defined(FRSKYX_CC2500_INO)
if(protocol==MODE_FRSKYX)
if(protocol==PROTO_FRSKYX)
option = FORCE_FRSKYX_TUNING; // Use config-defined tuning value for FrSkyX
else
#endif
#if defined(FORCE_SFHSS_TUNING) && defined(SFHSS_CC2500_INO)
if (protocol==MODE_SFHSS)
if (protocol==PROTO_SFHSS)
option = FORCE_SFHSS_TUNING; // Use config-defined tuning value for SFHSS
else
#endif
#if defined(FORCE_CORONA_TUNING) && defined(CORONA_CC2500_INO)
if (protocol==MODE_CORONA)
if (protocol==PROTO_CORONA)
option = FORCE_CORONA_TUNING; // Use config-defined tuning value for CORONA
else
#endif
option = PPM_prot[mode_select].option; // Use radio-defined option value
option = PPM_prot[line].option; // Use radio-defined option value
if(PPM_prot[mode_select].power) POWER_FLAG_on;
if(PPM_prot[mode_select].autobind)
if(PPM_prot[line].power) POWER_FLAG_on;
if(PPM_prot[line].autobind)
{
AUTOBIND_FLAG_on;
BIND_IN_PROGRESS; // Force a bind at protocol startup
}
mode_select++;
line++;
protocol_init();
@@ -601,7 +605,7 @@ uint8_t Update_All()
update_led_status();
#if defined(TELEMETRY)
#if ( !( defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) ) )
if( (protocol==MODE_FRSKYD) || (protocol==MODE_BAYANG) || (protocol==MODE_HUBSAN) || (protocol==MODE_AFHDS2A) || (protocol==MODE_FRSKYX) || (protocol==MODE_DSM) || (protocol==MODE_CABELL) )
if( (protocol==PROTO_FRSKYD) || (protocol==PROTO_BAYANG) || (protocol==PROTO_HUBSAN) || (protocol==PROTO_AFHDS2A) || (protocol==PROTO_FRSKYX) || (protocol==PROTO_DSM) || (protocol==PROTO_CABELL) )
#endif
TelemetryUpdate();
#endif
@@ -617,7 +621,7 @@ uint8_t Update_All()
BIND_CH_PREV_off;
//Request protocol to terminate bind
#if defined(FRSKYD_CC2500_INO) || defined(FRSKYX_CC2500_INO) || defined(FRSKYV_CC2500_INO)
if(protocol==MODE_FRSKYD || protocol==MODE_FRSKYX || protocol==MODE_FRSKYV)
if(protocol==PROTO_FRSKYD || protocol==PROTO_FRSKYX || protocol==PROTO_FRSKYV)
BIND_DONE;
else
#endif
@@ -700,6 +704,88 @@ static void update_led_status(void)
}
}
#ifdef ENABLE_PPM
uint8_t bank_switch(void)
{
uint8_t bank=eeprom_read_byte((EE_ADDR)EEPROM_BANK_OFFSET);
if(bank>=NBR_BANKS)
{ // Wrong number of bank
eeprom_write_byte((EE_ADDR)EEPROM_BANK_OFFSET,0x00); // set bank to 0
bank=0;
}
debugln("Using bank %d", bank);
phase=3;
uint32_t check=millis();
blink=millis();
while(mode_select==15)
{ //loop here if the dial is on position 15 for user to select the bank
if(blink<millis())
{
switch(phase & 0x03)
{ // Flash bank number of times
case 0:
LED_on;
blink+=BLINK_BANK_TIME_HIGH;
phase++;
break;
case 1:
LED_off;
blink+=BLINK_BANK_TIME_LOW;
phase++;
break;
case 2:
if( (phase>>2) >= bank)
{
phase=0;
blink+=BLINK_BANK_REPEAT;
}
else
phase+=2;
break;
case 3:
LED_output;
LED_off;
blink+=BLINK_BANK_TIME_LOW;
phase=0;
break;
}
}
if(check<millis())
{
//Test bind button: for AVR it's shared with the LED so some work is needed to check it...
#ifndef STM32_BOARD
bool led=IS_LED_on;
BIND_SET_INPUT;
BIND_SET_PULLUP;
#endif
bool test_bind=IS_BIND_BUTTON_on;
#ifndef STM32_BOARD
if(led)
LED_on;
else
LED_off;
LED_output;
#endif
if( test_bind )
{ // Increase bank
LED_on;
bank++;
if(bank>=NBR_BANKS)
bank=0;
eeprom_write_byte((EE_ADDR)EEPROM_BANK_OFFSET,bank);
debugln("Using bank %d", bank);
phase=3;
blink+=BLINK_BANK_REPEAT;
check+=2*BLINK_BANK_REPEAT;
}
check+=1;
}
}
return bank;
}
#endif
inline void tx_pause()
{
#ifdef TELEMETRY
@@ -799,21 +885,21 @@ static void protocol_init()
{
#ifdef A7105_INSTALLED
#if defined(FLYSKY_A7105_INO)
case MODE_FLYSKY:
case PROTO_FLYSKY:
PE1_off; //antenna RF1
next_callback = initFlySky();
remote_callback = ReadFlySky;
break;
#endif
#if defined(AFHDS2A_A7105_INO)
case MODE_AFHDS2A:
case PROTO_AFHDS2A:
PE1_off; //antenna RF1
next_callback = initAFHDS2A();
remote_callback = ReadAFHDS2A;
break;
#endif
#if defined(HUBSAN_A7105_INO)
case MODE_HUBSAN:
case PROTO_HUBSAN:
PE1_off; //antenna RF1
if(IS_BIND_BUTTON_FLAG_on) random_id(EEPROM_ID_OFFSET,true); // Generate new ID if bind button is pressed.
next_callback = initHubsan();
@@ -823,7 +909,7 @@ static void protocol_init()
#endif
#ifdef CC2500_INSTALLED
#if defined(FRSKYD_CC2500_INO)
case MODE_FRSKYD:
case PROTO_FRSKYD:
PE1_off; //antenna RF2
PE2_on;
next_callback = initFrSky_2way();
@@ -831,7 +917,7 @@ static void protocol_init()
break;
#endif
#if defined(FRSKYV_CC2500_INO)
case MODE_FRSKYV:
case PROTO_FRSKYV:
PE1_off; //antenna RF2
PE2_on;
next_callback = initFRSKYV();
@@ -839,7 +925,7 @@ static void protocol_init()
break;
#endif
#if defined(FRSKYX_CC2500_INO)
case MODE_FRSKYX:
case PROTO_FRSKYX:
PE1_off; //antenna RF2
PE2_on;
next_callback = initFrSkyX();
@@ -847,7 +933,7 @@ static void protocol_init()
break;
#endif
#if defined(SFHSS_CC2500_INO)
case MODE_SFHSS:
case PROTO_SFHSS:
PE1_off; //antenna RF2
PE2_on;
next_callback = initSFHSS();
@@ -855,7 +941,7 @@ static void protocol_init()
break;
#endif
#if defined(CORONA_CC2500_INO)
case MODE_CORONA:
case PROTO_CORONA:
PE1_off; //antenna RF2
PE2_on;
next_callback = initCORONA();
@@ -865,25 +951,25 @@ static void protocol_init()
#endif
#ifdef CYRF6936_INSTALLED
#if defined(DSM_CYRF6936_INO)
case MODE_DSM:
case PROTO_DSM:
PE2_on; //antenna RF4
next_callback = initDsm();
remote_callback = ReadDsm;
break;
#endif
#if defined(DEVO_CYRF6936_INO)
case MODE_DEVO:
case PROTO_DEVO:
#ifdef ENABLE_PPM
if(mode_select) //PPM mode
{
if(IS_BIND_BUTTON_FLAG_on)
{
eeprom_write_byte((EE_ADDR)(MODELMODE_EEPROM_OFFSET+mode_select),0x00); // reset to autobind mode for the current model
eeprom_write_byte((EE_ADDR)(MODELMODE_EEPROM_OFFSET+RX_num),0x00); // reset to autobind mode for the current model
option=0;
}
else
{
option=eeprom_read_byte((EE_ADDR)(MODELMODE_EEPROM_OFFSET+mode_select)); // load previous mode: autobind or fixed id
option=eeprom_read_byte((EE_ADDR)(MODELMODE_EEPROM_OFFSET+RX_num)); // load previous mode: autobind or fixed id
if(option!=1) option=0; // if not fixed id mode then it should be autobind
}
}
@@ -894,18 +980,18 @@ static void protocol_init()
break;
#endif
#if defined(WK2x01_CYRF6936_INO)
case MODE_WK2x01:
case PROTO_WK2x01:
#ifdef ENABLE_PPM
if(mode_select) //PPM mode
{
if(IS_BIND_BUTTON_FLAG_on)
{
eeprom_write_byte((EE_ADDR)(MODELMODE_EEPROM_OFFSET+mode_select),0x00); // reset to autobind mode for the current model
eeprom_write_byte((EE_ADDR)(MODELMODE_EEPROM_OFFSET+RX_num),0x00); // reset to autobind mode for the current model
option=0;
}
else
{
option=eeprom_read_byte((EE_ADDR)(MODELMODE_EEPROM_OFFSET+mode_select)); // load previous mode: autobind or fixed id
option=eeprom_read_byte((EE_ADDR)(MODELMODE_EEPROM_OFFSET+RX_num)); // load previous mode: autobind or fixed id
if(option!=1) option=0; // if not fixed id mode then it should be autobind
}
}
@@ -916,7 +1002,7 @@ static void protocol_init()
break;
#endif
#if defined(J6PRO_CYRF6936_INO)
case MODE_J6PRO:
case PROTO_J6PRO:
PE2_on; //antenna RF4
next_callback = initJ6Pro();
remote_callback = ReadJ6Pro;
@@ -925,141 +1011,141 @@ static void protocol_init()
#endif
#ifdef NRF24L01_INSTALLED
#if defined(HISKY_NRF24L01_INO)
case MODE_HISKY:
case PROTO_HISKY:
next_callback=initHiSky();
remote_callback = hisky_cb;
break;
#endif
#if defined(V2X2_NRF24L01_INO)
case MODE_V2X2:
case PROTO_V2X2:
next_callback = initV2x2();
remote_callback = ReadV2x2;
break;
#endif
#if defined(YD717_NRF24L01_INO)
case MODE_YD717:
case PROTO_YD717:
next_callback=initYD717();
remote_callback = yd717_callback;
break;
#endif
#if defined(KN_NRF24L01_INO)
case MODE_KN:
case PROTO_KN:
next_callback = initKN();
remote_callback = kn_callback;
break;
#endif
#if defined(SYMAX_NRF24L01_INO)
case MODE_SYMAX:
case PROTO_SYMAX:
next_callback = initSymax();
remote_callback = symax_callback;
break;
#endif
#if defined(SLT_NRF24L01_INO)
case MODE_SLT:
case PROTO_SLT:
next_callback=initSLT();
remote_callback = SLT_callback;
break;
#endif
#if defined(CX10_NRF24L01_INO)
case MODE_Q2X2:
case PROTO_Q2X2:
sub_protocol|=0x08; // Increase the number of sub_protocols for CX-10
case MODE_CX10:
case PROTO_CX10:
next_callback=initCX10();
remote_callback = CX10_callback;
break;
#endif
#if defined(CG023_NRF24L01_INO)
case MODE_CG023:
case PROTO_CG023:
next_callback=initCG023();
remote_callback = CG023_callback;
break;
#endif
#if defined(BAYANG_NRF24L01_INO)
case MODE_BAYANG:
case PROTO_BAYANG:
next_callback=initBAYANG();
remote_callback = BAYANG_callback;
break;
#endif
#if defined(ESKY_NRF24L01_INO)
case MODE_ESKY:
case PROTO_ESKY:
next_callback=initESKY();
remote_callback = ESKY_callback;
break;
#endif
#if defined(MT99XX_NRF24L01_INO)
case MODE_MT99XX:
case PROTO_MT99XX:
next_callback=initMT99XX();
remote_callback = MT99XX_callback;
break;
#endif
#if defined(MJXQ_NRF24L01_INO)
case MODE_MJXQ:
case PROTO_MJXQ:
next_callback=initMJXQ();
remote_callback = MJXQ_callback;
break;
#endif
#if defined(SHENQI_NRF24L01_INO)
case MODE_SHENQI:
case PROTO_SHENQI:
next_callback=initSHENQI();
remote_callback = SHENQI_callback;
break;
#endif
#if defined(FY326_NRF24L01_INO)
case MODE_FY326:
case PROTO_FY326:
next_callback=initFY326();
remote_callback = FY326_callback;
break;
#endif
#if defined(FQ777_NRF24L01_INO)
case MODE_FQ777:
case PROTO_FQ777:
next_callback=initFQ777();
remote_callback = FQ777_callback;
break;
#endif
#if defined(ASSAN_NRF24L01_INO)
case MODE_ASSAN:
case PROTO_ASSAN:
next_callback=initASSAN();
remote_callback = ASSAN_callback;
break;
#endif
#if defined(HONTAI_NRF24L01_INO)
case MODE_HONTAI:
case PROTO_HONTAI:
next_callback=initHONTAI();
remote_callback = HONTAI_callback;
break;
#endif
#if defined(Q303_NRF24L01_INO)
case MODE_Q303:
case PROTO_Q303:
next_callback=initQ303();
remote_callback = Q303_callback;
break;
#endif
#if defined(GW008_NRF24L01_INO)
case MODE_GW008:
case PROTO_GW008:
next_callback=initGW008();
remote_callback = GW008_callback;
break;
#endif
#if defined(DM002_NRF24L01_INO)
case MODE_DM002:
case PROTO_DM002:
next_callback=initDM002();
remote_callback = DM002_callback;
break;
#endif
#if defined(CABELL_NRF24L01_INO)
case MODE_CABELL:
case PROTO_CABELL:
next_callback=initCABELL();
remote_callback = CABELL_callback;
break;
#endif
#if defined(ESKY150_NRF24L01_INO)
case MODE_ESKY150:
case PROTO_ESKY150:
next_callback=initESKY150();
remote_callback = ESKY150_callback;
break;
#endif
#if defined(H8_3D_NRF24L01_INO)
case MODE_H8_3D:
case PROTO_H8_3D:
next_callback=initH8_3D();
remote_callback = H8_3D_callback;
break;
@@ -1114,27 +1200,27 @@ void update_serial_data()
//Forced frequency tuning values for CC2500 protocols
#if defined(FORCE_FRSKYD_TUNING) && defined(FRSKYD_CC2500_INO)
if(protocol==MODE_FRSKYD)
if(protocol==PROTO_FRSKYD)
option=FORCE_FRSKYD_TUNING; // Use config-defined tuning value for FrSkyD
else
#endif
#if defined(FORCE_FRSKYV_TUNING) && defined(FRSKYV_CC2500_INO)
if(protocol==MODE_FRSKYV)
if(protocol==PROTO_FRSKYV)
option=FORCE_FRSKYV_TUNING; // Use config-defined tuning value for FrSkyV
else
#endif
#if defined(FORCE_FRSKYX_TUNING) && defined(FRSKYX_CC2500_INO)
if(protocol==MODE_FRSKYX)
if(protocol==PROTO_FRSKYX)
option=FORCE_FRSKYX_TUNING; // Use config-defined tuning value for FrSkyX
else
#endif
#if defined(FORCE_SFHSS_TUNING) && defined(SFHSS_CC2500_INO)
if (protocol==MODE_SFHSS)
if (protocol==PROTO_SFHSS)
option=FORCE_SFHSS_TUNING; // Use config-defined tuning value for SFHSS
else
#endif
#if defined(FORCE_CORONA_TUNING) && defined(CORONA_CC2500_INO)
if (protocol==MODE_CORONA)
if (protocol==PROTO_CORONA)
option=FORCE_CORONA_TUNING; // Use config-defined tuning value for CORONA
else
#endif
@@ -1175,7 +1261,7 @@ void update_serial_data()
if( ((rx_ok_buff[1]&0x80)==0) && ((cur_protocol[1]&0x80)!=0) ) // Bind flag has been reset
{ // Request protocol to end bind
#if defined(FRSKYD_CC2500_INO) || defined(FRSKYX_CC2500_INO) || defined(FRSKYV_CC2500_INO)
if(protocol==MODE_FRSKYD || protocol==MODE_FRSKYX || protocol==MODE_FRSKYV)
if(protocol==PROTO_FRSKYD || protocol==PROTO_FRSKYX || protocol==PROTO_FRSKYV)
BIND_DONE;
else
#endif
@@ -1441,11 +1527,11 @@ void pollBoot()
#if defined(TELEMETRY)
void PPM_Telemetry_serial_init()
{
if( (protocol==MODE_FRSKYD) || (protocol==MODE_HUBSAN) || (protocol==MODE_AFHDS2A) || (protocol==MODE_BAYANG) || (protocol==MODE_CABELL) )
if( (protocol==PROTO_FRSKYD) || (protocol==PROTO_HUBSAN) || (protocol==PROTO_AFHDS2A) || (protocol==PROTO_BAYANG) || (protocol==PROTO_CABELL) )
initTXSerial( SPEED_9600 ) ;
if(protocol==MODE_FRSKYX)
if(protocol==PROTO_FRSKYX)
initTXSerial( SPEED_57600 ) ;
if(protocol==MODE_DSM)
if(protocol==PROTO_DSM)
initTXSerial( SPEED_125K ) ;
}
#endif

View File

@@ -32,18 +32,18 @@
#endif
// Dial
#define MODE_DIAL1_pin 2
#define MODE_DIAL1_port PORTB
#define MODE_DIAL1_ipr PINB
#define MODE_DIAL2_pin 3
#define MODE_DIAL2_port PORTB
#define MODE_DIAL2_ipr PINB
#define MODE_DIAL3_pin 4
#define MODE_DIAL3_port PORTB
#define MODE_DIAL3_ipr PINB
#define MODE_DIAL4_pin 0
#define MODE_DIAL4_port PORTC
#define MODE_DIAL4_ipr PINC
#define PROTO_DIAL1_pin 2
#define PROTO_DIAL1_port PORTB
#define PROTO_DIAL1_ipr PINB
#define PROTO_DIAL2_pin 3
#define PROTO_DIAL2_port PORTB
#define PROTO_DIAL2_ipr PINB
#define PROTO_DIAL3_pin 4
#define PROTO_DIAL3_port PORTB
#define PROTO_DIAL3_ipr PINB
#define PROTO_DIAL4_pin 0
#define PROTO_DIAL4_port PORTC
#define PROTO_DIAL4_ipr PINC
// PPM
#define PPM_pin 3 //D3 = PD3
@@ -291,6 +291,7 @@
#define LED_output pinMode(LED_pin,OUTPUT)
#define IS_LED_on ( digitalRead(LED_pin)==HIGH)
//iRangeX modules have a second LED
#define LED2_on digitalWrite(LED2_pin,HIGH)
#define LED2_off digitalWrite(LED2_pin,LOW)
#define LED2_toggle digitalWrite(LED2_pin ,!digitalRead(LED2_pin))

View File

@@ -113,14 +113,14 @@ static void multi_send_status()
//Is failsafe supported?
switch (protocol)
{
case MODE_HISKY:
case PROTO_HISKY:
if(sub_protocol!=HK310)
break;
case MODE_AFHDS2A:
case MODE_DEVO:
case MODE_SFHSS:
case MODE_WK2x01:
case MODE_FRSKYX:
case PROTO_AFHDS2A:
case PROTO_DEVO:
case PROTO_SFHSS:
case PROTO_WK2x01:
case PROTO_FRSKYX:
flags |= 0x20; //Yes
default:
break;
@@ -219,7 +219,7 @@ void frsky_check_telemetry(uint8_t *pkt,uint8_t len)
if(pktt[6]>0 && pktt[6]<=10)
{
if (protocol==MODE_FRSKYD)
if (protocol==PROTO_FRSKYD)
{
if ( ( pktt[7] & 0x1F ) == (telemetry_counter & 0x1F) )
{
@@ -243,7 +243,7 @@ void frsky_check_telemetry(uint8_t *pkt,uint8_t len)
//
#if defined SPORT_TELEMETRY && defined FRSKYX_CC2500_INO
telemetry_lost=0;
if (protocol==MODE_FRSKYX)
if (protocol==PROTO_FRSKYX)
{
uint16_t lcrc = frskyX_crc_x(&pkt[3], len-7 ) ;
@@ -340,7 +340,7 @@ void init_frskyd_link_telemetry()
void frsky_link_frame()
{
frame[0] = 0xFE; // Link frame
if (protocol==MODE_FRSKYD)
if (protocol==PROTO_FRSKYD)
{
frame[1] = pktt[3]; // A1
frame[2] = pktt[4]; // A2
@@ -349,7 +349,7 @@ void frsky_link_frame()
telemetry_link |= 2 ; // Send hub if available
}
else
if (protocol==MODE_HUBSAN||protocol==MODE_AFHDS2A||protocol==MODE_BAYANG||protocol==MODE_CABELL)
if (protocol==PROTO_HUBSAN||protocol==PROTO_AFHDS2A||protocol==PROTO_BAYANG||protocol==PROTO_CABELL)
{
frame[1] = v_lipo1;
frame[2] = v_lipo2;
@@ -854,7 +854,7 @@ void TelemetryUpdate()
#endif
#if defined SPORT_TELEMETRY
if (protocol==MODE_FRSKYX)
if (protocol==PROTO_FRSKYX)
{ // FrSkyX
for(;;)
{
@@ -900,7 +900,7 @@ void TelemetryUpdate()
#endif // SPORT_TELEMETRY
#if defined DSM_TELEMETRY
if(telemetry_link && protocol == MODE_DSM)
if(telemetry_link && protocol == PROTO_DSM)
{ // DSM
DSM_frame();
telemetry_link=0;
@@ -908,7 +908,7 @@ void TelemetryUpdate()
}
#endif
#if defined AFHDS2A_FW_TELEMETRY
if(telemetry_link == 2 && protocol == MODE_AFHDS2A)
if(telemetry_link == 2 && protocol == PROTO_AFHDS2A)
{
AFHDSA_short_frame();
telemetry_link=0;
@@ -916,13 +916,13 @@ void TelemetryUpdate()
}
#endif
if((telemetry_link & 1 )&& protocol != MODE_FRSKYX)
if((telemetry_link & 1 )&& protocol != PROTO_FRSKYX)
{ // FrSkyD + Hubsan + AFHDS2A + Bayang + Cabell
frsky_link_frame();
return;
}
#if defined HUB_TELEMETRY
if((telemetry_link & 2) && protocol == MODE_FRSKYD)
if((telemetry_link & 2) && protocol == PROTO_FRSKYD)
{ // FrSkyD
frsky_user_frame();
return;

View File

@@ -49,6 +49,11 @@
#error "You have enabled CHECK_FOR_BOOTLOADER but not selected the 'Flash from TX' bootloader."
#endif
//Check number of banks
#if NBR_BANKS < 1 || NBR_BANKS > 5
#error "You need to select a number of banks between 1 and 5."
#endif
//Check failsafe throttle value
#ifdef FAILSAFE_ENABLE
#if ( FAILSAFE_THROTTLE_LOW < -125 ) || ( FAILSAFE_THROTTLE_LOW > 125 )

View File

@@ -294,7 +294,7 @@ static void __attribute__((unused)) WK_build_beacon_pkt_2801()
BIND_SET_PULLUP; // set pullup
if(IS_BIND_BUTTON_on)
{
eeprom_write_byte((EE_ADDR)(MODELMODE_EEPROM_OFFSET+mode_select),0x01); // Set fixed id mode for the current model
eeprom_write_byte((EE_ADDR)(MODELMODE_EEPROM_OFFSET+RX_num),0x01); // Set fixed id mode for the current model
option=1;
}
BIND_SET_OUTPUT;
@@ -303,7 +303,7 @@ static void __attribute__((unused)) WK_build_beacon_pkt_2801()
if(prev_option!=option && IS_BIND_DONE)
{
set_rx_tx_addr(MProtocol_id);
rx_tx_addr[2]=rx_tx_addr[3]<<4; // Make use of RX_Num
rx_tx_addr[2]=rx_tx_addr[3]<<4; // Make use of RX_num
bind_counter = WK_BIND_COUNT / 8 + 1;
}
if (option)
@@ -490,7 +490,7 @@ uint16_t WK_setup()
}
else
{
rx_tx_addr[2]=rx_tx_addr[3]<<4; // Make use of RX_Num
rx_tx_addr[2]=rx_tx_addr[3]<<4; // Make use of RX_num
bind_counter = 0;
phase = WK_BOUND_1;
BIND_DONE;

View File

@@ -22,7 +22,7 @@
/********************/
//If you know parameters you want for sure to be enabled or disabled which survives in future, you can use a file named "_MyConfig.h".
//An example is given within the file named "_MyConfig.h.example" which needs to be renamed if you want to use it.
//To enable this config file remove the // from the line below. It's automatically loaded if the file exists for the AVR platform but not STM32...
//To enable this config file remove the // from the line below.
//#define USE_MY_CONFIG
@@ -305,160 +305,240 @@
/** Dial Protocol Selector Settings **/
//The table below indicates which protocol to run when a specific position on the dial has been selected.
//All fields and values are explained below. Everything is configurable from here like in the Serial mode.
//Example: You can associate multiple times the same protocol to different dial positions to take advantage of the model match (RX_Num)
const PPM_Parameters PPM_prot[15]= {
//Tip: You can associate multiple times the same protocol to different dial positions to take advantage of the model match based on RX_Num
//A system of banks enable the access to more protocols than positions on the dial. Banks can be selected by placing the dial on position 15, power up the module and
// short press the bind button multiple times until you reach the desired one. The bank number currently selected is indicated by the number of LED flash.
//The parameter below indicates the number of desired banks between 1 and 5. Default is 5.
#define NBR_BANKS 5
const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
#if NBR_BANKS > 0
//****************************** BANK 1 ******************************
// Dial Protocol Sub protocol RX_Num Power Auto Bind Option
/* 1 */ {MODE_FLYSKY, Flysky , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 2 */ {MODE_HUBSAN, H107 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 3 */ {MODE_FRSKYD, 0 , 0 , P_HIGH , NO_AUTOBIND , 40 }, // option=fine freq tuning
/* 4 */ {MODE_HISKY , Hisky , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 5 */ {MODE_V2X2 , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 6 */ {MODE_DSM , DSMX_11 , 0 , P_HIGH , NO_AUTOBIND , 6 }, // option=number of channels
/* 7 */ {MODE_DSM , DSM2_22 , 0 , P_HIGH , NO_AUTOBIND , 6 },
/* 8 */ {MODE_YD717 , YD717 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 9 */ {MODE_KN , WLTOYS , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 10 */ {MODE_SYMAX , SYMAX , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 11 */ {MODE_SLT , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 12 */ {MODE_CX10 , CX10_BLUE , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 13 */ {MODE_CG023 , CG023 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 14 */ {MODE_BAYANG, BAYANG , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 15 */ {MODE_SYMAX , SYMAX5C , 0 , P_HIGH , NO_AUTOBIND , 0 }
/* 1 */ {PROTO_FLYSKY, Flysky , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 2 */ {PROTO_AFHDS2A, PWM_IBUS , 0 , P_HIGH , NO_AUTOBIND , 0 }, // RX number 0
/* 3 */ {PROTO_AFHDS2A, PWM_IBUS , 1 , P_HIGH , NO_AUTOBIND , 0 }, // RX number 1
/* 4 */ {PROTO_AFHDS2A, PWM_IBUS , 2 , P_HIGH , NO_AUTOBIND , 0 }, // RX number 2
/* 5 */ {PROTO_AFHDS2A, PWM_IBUS , 3 , P_HIGH , NO_AUTOBIND , 0 }, // RX number 3
/* 6 */ {PROTO_AFHDS2A, PWM_IBUS , 2 , P_HIGH , NO_AUTOBIND , 0 }, // RX number 4
/* 7 */ {PROTO_AFHDS2A, PWM_IBUS , 3 , P_HIGH , NO_AUTOBIND , 0 }, // RX number 5
/* 8 */ {PROTO_SFHSS, H107 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 9 */ {PROTO_FRSKYV, 0 , 0 , P_HIGH , NO_AUTOBIND , 40 }, // option=fine freq tuning
/* 10 */ {PROTO_FRSKYD, 0 , 0 , P_HIGH , NO_AUTOBIND , 40 }, // option=fine freq tuning
/* 11 */ {PROTO_FRSKYX, CH_16 , 0 , P_HIGH , NO_AUTOBIND , 40 }, // option=fine freq tuning
/* 12 */ {PROTO_FRSKYX, EU_16 , 0 , P_HIGH , NO_AUTOBIND , 40 }, // option=fine freq tuning
/* 13 */ {PROTO_DEVO , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 14 */ {PROTO_WK2x01, WK2801 , 0 , P_HIGH , NO_AUTOBIND , 0 },
#endif
#if NBR_BANKS > 1
//****************************** BANK 2 ******************************
// Dial Protocol Sub protocol RX_Num Power Auto Bind Option
/* 1 */ {PROTO_DSM , DSM2_11 , 0 , P_HIGH , NO_AUTOBIND , 6 }, // option=number of channels
/* 2 */ {PROTO_DSM , DSM2_22 , 0 , P_HIGH , NO_AUTOBIND , 6 }, // option=number of channels
/* 3 */ {PROTO_DSM , DSMX_11 , 0 , P_HIGH , NO_AUTOBIND , 6 }, // option=number of channels
/* 4 */ {PROTO_DSM , DSMX_22 , 0 , P_HIGH , NO_AUTOBIND , 6 }, // option=number of channels
/* 5 */ {PROTO_DSM , DSM2_11 , 0 , P_HIGH , NO_AUTOBIND , 8 }, // option=number of channels
/* 6 */ {PROTO_DSM , DSM2_22 , 0 , P_HIGH , NO_AUTOBIND , 8 }, // option=number of channels
/* 7 */ {PROTO_DSM , DSMX_11 , 0 , P_HIGH , NO_AUTOBIND , 8 }, // option=number of channels
/* 8 */ {PROTO_DSM , DSMX_22 , 0 , P_HIGH , NO_AUTOBIND , 8 }, // option=number of channels
/* 9 */ {PROTO_SLT , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 10 */ {PROTO_HUBSAN, H107 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 11 */ {PROTO_HUBSAN, H301 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 12 */ {PROTO_HUBSAN, H501 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 13 */ {PROTO_HISKY , Hisky , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 14 */ {PROTO_V2X2 , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
#endif
#if NBR_BANKS > 2
//****************************** BANK 3 ******************************
// Dial Protocol Sub protocol RX_Num Power Auto Bind Option
/* 1 */ {PROTO_ESKY , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 2 */ {PROTO_ESKY150, 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 3 */ {PROTO_ASSAN, 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 4 */ {PROTO_CORONA, COR_V2 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 5 */ {PROTO_SYMAX , SYMAX , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 6 */ {PROTO_KN , WLTOYS , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 7 */ {PROTO_BAYANG, BAYANG , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 8 */ {PROTO_BAYANG, H8S3D , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 9 */ {PROTO_BAYANG, X16_AH , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 10 */ {PROTO_BAYANG, IRDRONE , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 11 */ {PROTO_H8_3D, H8_3D , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 12 */ {PROTO_H8_3D, H20H , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 13 */ {PROTO_H8_3D, H20MINI , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 14 */ {PROTO_H8_3D, H30MINI , 0 , P_HIGH , NO_AUTOBIND , 0 },
#endif
#if NBR_BANKS > 3
//****************************** BANK 4 ******************************
// Dial Protocol Sub protocol RX_Num Power Auto Bind Option
/* 1 */ {PROTO_MJXQ , WLH08 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 2 */ {PROTO_MJXQ , X600 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 3 */ {PROTO_MJXQ , X800 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 4 */ {PROTO_MJXQ , H26D , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 5 */ {PROTO_MJXQ , E010 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 6 */ {PROTO_MJXQ , H26WH , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 7 */ {PROTO_HONTAI, HONTAI , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 8 */ {PROTO_HONTAI, JJRCX1 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 9 */ {PROTO_HONTAI, X5C1 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 10 */ {PROTO_HONTAI, FQ777_951 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 11 */ {PROTO_Q303 , Q303 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 12 */ {PROTO_Q303 , CX35 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 13 */ {PROTO_Q303 , CX10D , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 14 */ {PROTO_Q303 , CX10WD , 0 , P_HIGH , NO_AUTOBIND , 0 },
#endif
#if NBR_BANKS > 4
//****************************** BANK 5 ******************************
// Dial Protocol Sub protocol RX_Num Power Auto Bind Option
/* 1 */ {PROTO_CX10 , CX10_GREEN , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 2 */ {PROTO_CX10 , CX10_BLUE , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 3 */ {PROTO_CX10 , DM007 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 4 */ {PROTO_CX10 , JC3015_1 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 5 */ {PROTO_CX10 , JC3015_2 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 6 */ {PROTO_CX10 , MK33041 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 7 */ {PROTO_Q2X2 , Q222 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 8 */ {PROTO_Q2X2 , Q242 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 9 */ {PROTO_Q2X2 , Q282 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 10 */ {PROTO_CG023, CG023 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 11 */ {PROTO_CG023, YD829 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 12 */ {PROTO_FQ777, 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 13 */ {PROTO_YD717, YD717 , 0 , P_HIGH , NO_AUTOBIND , 0 },
/* 14 */ {PROTO_MT99XX, MT99 , 0 , P_HIGH , NO_AUTOBIND , 0 },
#endif
};
/* Available protocols and associated sub protocols to pick and choose from
MODE_FLYSKY
PROTO_FLYSKY
Flysky
V9X9
V6X6
V912
CX20
MODE_HUBSAN
PROTO_HUBSAN
H107
H301
H501
MODE_FRSKYV
PROTO_FRSKYV
NONE
MODE_FRSKYD
PROTO_FRSKYD
NONE
MODE_FRSKYX
PROTO_FRSKYX
CH_16
CH_8
EU_16
EU_8
MODE_HISKY
PROTO_HISKY
Hisky
HK310
MODE_V2X2
PROTO_V2X2
V2X2
JXD506
MODE_DSM
PROTO_DSM
DSM2_22
DSM2_11
DSMX_22
DSMX_11
MODE_DEVO
PROTO_DEVO
NONE
MODE_YD717
PROTO_YD717
YD717
SKYWLKR
SYMAX4
XINXUN
NIHUI
MODE_KN
PROTO_KN
WLTOYS
FEILUN
MODE_SYMAX
PROTO_SYMAX
SYMAX
SYMAX5C
MODE_SLT
PROTO_SLT
NONE
MODE_CX10
PROTO_CX10
CX10_GREEN
CX10_BLUE
DM007
JC3015_1
JC3015_2
MK33041
MODE_Q2X2
PROTO_Q2X2
Q222
Q242
Q282
MODE_SLT
PROTO_SLT
SLT
VISTA
MODE_CG023
PROTO_CG023
CG023
YD829
MODE_BAYANG
PROTO_BAYANG
BAYANG
H8S3D
X16_AH
IRDRONE
MODE_ESKY
PROTO_ESKY
NONE
MODE_MT99XX
PROTO_MT99XX
MT99
H7
YZ
LS
FY805
MODE_MJXQ
PROTO_MJXQ
WLH08
X600
X800
H26D
E010
H26WH
MODE_SHENQI
PROTO_SHENQI
NONE
MODE_FY326
PROTO_FY326
FY326
FY319
MODE_SFHSS
PROTO_SFHSS
NONE
MODE_J6PRO
PROTO_J6PRO
NONE
MODE_FQ777
PROTO_FQ777
NONE
MODE_ASSAN
PROTO_ASSAN
NONE
MODE_HONTAI
FORMAT_HONTAI
FORMAT_JJRCX1
FORMAT_X5C1
FORMAT_FQ777_951
MODE_AFHDS2A
PROTO_HONTAI
HONTAI
JJRCX1
X5C1
FQ777_951
PROTO_AFHDS2A
PWM_IBUS
PPM_IBUS
PWM_SBUS
PPM_SBUS
MODE_WK2X01
PROTO_WK2x01
WK2801
WK2401
W6_5_1
W6_6_1
W6_HEL
W6_HEL_I
MODE_Q303
PROTO_Q303
Q303
CX35
CX10D
CX10WD
MODE_GW008
PROTO_GW008
NONE
MODE_DM002
PROTO_DM002
NONE
MODE_CABELL
PROTO_CABELL
CABELL_V3
CABELL_V3_TELEMETRY
CABELL_SET_FAIL_SAFE
CABELL_UNBIND
MODE_ESKY150
MODE_H8_3D
PROTO_ESKY150
PROTO_H8_3D
H8_3D
H20H
H20 Mini
H30 Mini
MODE_CORONA
H20MINI
H30MINI
PROTO_CORONA
COR_V1
COR_V2
*/