New feature: end bind

This new feature is available:
- in serial mode and when binding from the GUI. As soon as the Bind
window is closed = serial bind bit was set and cleared, the current bind
operation will be terminated.
- if the bind was initiated from the Bind on channel feature (bind
channel goes high) then as soon as the bind channel goes low the current
bind operation will be terminated.
Tested on ersky9x which does open a bind window, not sure about
OpenTX...

Some protocols (Hubsan, Assan, FY326, Shenqi...) which are waiting for
model/RX to reply will stay in bind mode.
This commit is contained in:
pascallanger 2017-02-06 18:46:34 +01:00
parent 8d87bfb4a3
commit c02f273d57
9 changed files with 50 additions and 25 deletions

View File

@ -82,6 +82,16 @@ uint16_t limit_channel_100(uint8_t ch)
/** FrSky D and X routines **/ /** FrSky D and X routines **/
/******************************/ /******************************/
#if defined(FRSKYD_CC2500_INO) || defined(FRSKYX_CC2500_INO) #if defined(FRSKYD_CC2500_INO) || defined(FRSKYX_CC2500_INO)
enum {
FRSKY_BIND = 0,
FRSKY_BIND_DONE = 1000,
FRSKY_DATA1,
FRSKY_DATA2,
FRSKY_DATA3,
FRSKY_DATA4,
FRSKY_DATA5
};
void Frsky_init_hop(void) void Frsky_init_hop(void)
{ {
uint8_t val; uint8_t val;

View File

@ -120,6 +120,9 @@ uint16_t ReadFrSky_2way()
CC2500_WriteReg(CC2500_23_FSCAL3, 0x89); CC2500_WriteReg(CC2500_23_FSCAL3, 0x89);
CC2500_Strobe(CC2500_SFRX);//0x3A CC2500_Strobe(CC2500_SFRX);//0x3A
CC2500_WriteData(packet, packet[0]+1); CC2500_WriteData(packet, packet[0]+1);
if(IS_BIND_DONE_on)
state = FRSKY_BIND_DONE;
else
state++; state++;
return 9000; return 9000;
} }

View File

@ -183,6 +183,9 @@ uint16_t ReadFrSkyX()
frskyX_build_bind_packet(); frskyX_build_bind_packet();
CC2500_Strobe(CC2500_SIDLE); CC2500_Strobe(CC2500_SIDLE);
CC2500_WriteData(packet, packet[0]+1); CC2500_WriteData(packet, packet[0]+1);
if(IS_BIND_DONE_on)
state = FRSKY_BIND_DONE;
else
state++; state++;
return 9000; return 9000;
case FRSKY_BIND_DONE: case FRSKY_BIND_DONE:

View File

@ -261,6 +261,7 @@ uint16_t initMT99XX(void)
bind_counter = MT99XX_BIND_COUNT; bind_counter = MT99XX_BIND_COUNT;
memcpy(hopping_frequency,"\x02\x48\x0C\x3e\x16\x34\x20\x2A\x2A\x20\x34\x16\x3e\x0c\x48\x02",16); memcpy(hopping_frequency,"\x02\x48\x0C\x3e\x16\x34\x20\x2A\x2A\x20\x34\x16\x3e\x0c\x48\x02",16);
hopping_frequency_no=0;
MT99XX_initialize_txid(); MT99XX_initialize_txid();
MT99XX_init(); MT99XX_init();

View File

@ -19,7 +19,7 @@
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 1 #define VERSION_MINOR 1
#define VERSION_REVISION 6 #define VERSION_REVISION 6
#define VERSION_PATCH_LEVEL 14 #define VERSION_PATCH_LEVEL 15
//****************** //******************
// Protocols // Protocols
//****************** //******************

View File

@ -505,7 +505,16 @@ uint8_t Update_All()
BIND_CH_PREV_on; BIND_CH_PREV_on;
} }
if(IS_BIND_CH_PREV_on && Servo_data[BIND_CH-1]<PPM_MIN_COMMAND) if(IS_BIND_CH_PREV_on && Servo_data[BIND_CH-1]<PPM_MIN_COMMAND)
{
BIND_CH_PREV_off; BIND_CH_PREV_off;
#if defined(FRSKYD_CC2500_INO) || defined(FRSKYX_CC2500_INO) || defined(FRSKYV_CC2500_INO)
if(protocol==MODE_FRSKYD || protocol==MODE_FRSKYX || protocol==MODE_FRSKYV)
BIND_DONE;
else
#endif
if(bind_counter>2)
bind_counter=2;
}
#endif //ENABLE_BIND_CH #endif //ENABLE_BIND_CH
if(IS_CHANGE_PROTOCOL_FLAG_on) if(IS_CHANGE_PROTOCOL_FLAG_on)
{ // Protocol needs to be changed or relaunched for bind { // Protocol needs to be changed or relaunched for bind
@ -967,7 +976,17 @@ void update_serial_data()
if( ((rx_ok_buff[1]&0x80)!=0) && ((cur_protocol[1]&0x80)==0) ) // Bind flag has been set if( ((rx_ok_buff[1]&0x80)!=0) && ((cur_protocol[1]&0x80)==0) ) // Bind flag has been set
CHANGE_PROTOCOL_FLAG_on; //restart protocol with bind CHANGE_PROTOCOL_FLAG_on; //restart protocol with bind
else else
CHANGE_PROTOCOL_FLAG_off; //no need to restart if( ((rx_ok_buff[1]&0x80)==0) && ((cur_protocol[1]&0x80)!=0) ) // Bind flag has been reset
{
#if defined(FRSKYD_CC2500_INO) || defined(FRSKYX_CC2500_INO) || defined(FRSKYV_CC2500_INO)
if(protocol==MODE_FRSKYD || protocol==MODE_FRSKYX || protocol==MODE_FRSKYV)
BIND_DONE;
else
#endif
if(bind_counter>2)
bind_counter=2;
}
//store current protocol values //store current protocol values
for(uint8_t i=0;i<3;i++) for(uint8_t i=0;i<3;i++)
cur_protocol[i] = rx_ok_buff[i]; cur_protocol[i] = rx_ok_buff[i];

View File

@ -319,12 +319,12 @@ uint16_t symax_callback()
return SYMAX_FIRST_PACKET_DELAY; return SYMAX_FIRST_PACKET_DELAY;
break; break;
case SYMAX_BIND2: case SYMAX_BIND2:
counter = SYMAX_BIND_COUNT; bind_counter = SYMAX_BIND_COUNT;
phase = SYMAX_BIND3; phase = SYMAX_BIND3;
SYMAX_send_packet(1); SYMAX_send_packet(1);
break; break;
case SYMAX_BIND3: case SYMAX_BIND3:
if (counter == 0) if (bind_counter == 0)
{ {
symax_init2(); symax_init2();
phase = SYMAX_DATA; phase = SYMAX_DATA;
@ -333,7 +333,7 @@ uint16_t symax_callback()
else else
{ {
SYMAX_send_packet(1); SYMAX_send_packet(1);
counter--; bind_counter--;
} }
break; break;
case SYMAX_DATA: case SYMAX_DATA:

View File

@ -252,19 +252,18 @@ uint16_t ReadV2x2()
return 150; return 150;
break; break;
case V202_BIND2: case V202_BIND2:
if (packet_sent && NRF24L01_packet_ack() != PKT_ACKED) { if (packet_sent && NRF24L01_packet_ack() != PKT_ACKED)
return V2X2_PACKET_CHKTIME; return V2X2_PACKET_CHKTIME;
}
V2X2_send_packet(1); V2X2_send_packet(1);
if (--counter == 0) { if (--bind_counter == 0)
{
phase = V202_DATA; phase = V202_DATA;
BIND_DONE; BIND_DONE;
} }
break; break;
case V202_DATA: case V202_DATA:
if (packet_sent && NRF24L01_packet_ack() != PKT_ACKED) { if (packet_sent && NRF24L01_packet_ack() != PKT_ACKED)
return V2X2_PACKET_CHKTIME; return V2X2_PACKET_CHKTIME;
}
V2X2_send_packet(0); V2X2_send_packet(0);
break; break;
} }
@ -278,7 +277,7 @@ uint16_t initV2x2()
// //
if (IS_AUTOBIND_FLAG_on) if (IS_AUTOBIND_FLAG_on)
{ {
counter = V2X2_BIND_COUNT; bind_counter = V2X2_BIND_COUNT;
phase = V202_INIT2; phase = V202_INIT2;
} }
else else

View File

@ -16,16 +16,6 @@
#ifndef _IFACE_CC2500_H_ #ifndef _IFACE_CC2500_H_
#define _IFACE_CC2500_H_ #define _IFACE_CC2500_H_
enum {
FRSKY_BIND = 0,
FRSKY_BIND_DONE = 1000,
FRSKY_DATA1,
FRSKY_DATA2,
FRSKY_DATA3,
FRSKY_DATA4,
FRSKY_DATA5
};
enum { enum {
CC2500_00_IOCFG2 = 0x00, // GDO2 output pin configuration CC2500_00_IOCFG2 = 0x00, // GDO2 output pin configuration
CC2500_01_IOCFG1 = 0x01, // GDO1 output pin configuration CC2500_01_IOCFG1 = 0x01, // GDO1 output pin configuration