Sync radio -> module

This commit is contained in:
pascallanger 2019-10-10 23:12:09 +02:00
parent 5c7f997e7a
commit cd7ede006c
56 changed files with 216 additions and 38 deletions

View File

@ -320,6 +320,7 @@ uint16_t ReadAFHDS2A()
packet_type = AFHDS2A_PACKET_STICKS;
phase = AFHDS2A_DATA;
case AFHDS2A_DATA:
telemetry_set_input_sync(3850);
AFHDS2A_build_packet(packet_type);
if((A7105_ReadReg(A7105_00_MODE) & 0x01)) // Check if something has been received...
data_rx=0;

View File

@ -127,6 +127,7 @@ uint16_t ASSAN_callback()
phase=ASSAN_DATA2;
return 2000;
case ASSAN_DATA2:
telemetry_set_input_sync(12000);
case ASSAN_DATA3:
ASSAN_send_packet();
phase++; // DATA 3 or 4

View File

@ -299,6 +299,7 @@ uint16_t BUGSMINI_callback()
phase = BUGSMINI_BIND1;
return BUGSMINI_PACKET_INTERVAL - BUGSMINI_WRITE_WAIT;
case BUGSMINI_DATA1:
telemetry_set_input_sync(BUGSMINI_PACKET_INTERVAL);
if( NRF24L01_ReadReg(NRF24L01_07_STATUS) & _BV(NRF24L01_07_RX_DR))
{ // RX fifo data ready => read only 12 bytes to not overwrite channel change flag
XN297_ReadPayload(packet, 12);

View File

@ -283,7 +283,10 @@ uint16_t BAYANG_callback()
if(IS_BIND_DONE)
{
if(packet_count==0)
{
telemetry_set_input_sync((option & BAYANG_OPTION_FLAG_TELEMETRY)?5*BAYANG_PACKET_PERIOD:2*BAYANG_PACKET_PERIOD);
BAYANG_send_packet(0);
}
packet_count++;
#ifdef BAYANG_HUB_TELEMETRY
if (option & BAYANG_OPTION_FLAG_TELEMETRY)

View File

@ -385,6 +385,7 @@ uint16_t ReadBUGS(void)
break;
case BUGS_DATA_1:
telemetry_set_input_sync(BUGS_PACKET_PERIOD);
A7105_SetPower();
BUGS_build_packet(0);
A7105_WriteReg(A7105_03_FIFOI, BUGS_FIFO_SIZE_TX);

View File

@ -406,9 +406,10 @@ uint16_t CABELL_callback()
if (IS_BIND_DONE)
{
CABELL_send_packet(0); // packet_period is set/adjusted in CABELL_send_packet
telemetry_set_input_sync(packet_period);
return packet_period;
}
if (bind_counter == 0)
else if (bind_counter == 0)
{
BIND_DONE;
CABELL_init(); // non-bind address

View File

@ -97,7 +97,7 @@ static inline uint8_t crtp_create_header(uint8_t port, uint8_t channel)
#define TX_ADDR_SIZE 5
// Timeout for callback in uSec, 10ms=10000us for Crazyflie
#define PACKET_PERIOD 10000
#define CFLIE_PACKET_PERIOD 10000
#define MAX_PACKET_SIZE 32 // CRTP is 32 bytes
@ -781,6 +781,7 @@ static uint16_t cflie_callback()
break;
case CFLIE_DATA:
telemetry_set_input_sync(CFLIE_PACKET_PERIOD);
// if (Model.proto_opts[PROTOOPTS_TELEMETRY] == TELEM_ON_CRTPLOG) {
// update_telemetry_crtplog();
// } else if (Model.proto_opts[PROTOOPTS_TELEMETRY] == TELEM_ON_ACKPKT) {
@ -792,7 +793,7 @@ static uint16_t cflie_callback()
send_cmd_packet();
break;
}
return PACKET_PERIOD; // Packet at standard protocol interval
return CFLIE_PACKET_PERIOD; // Packet at standard protocol interval
}
// Generate address to use from TX id and manufacturer id (STM32 unique id)

View File

@ -138,7 +138,10 @@ static void __attribute__((unused)) CG023_init()
uint16_t CG023_callback()
{
if(IS_BIND_DONE)
{
telemetry_set_input_sync(packet_period);
CG023_send_packet(0);
}
else
{
if (bind_counter == 0)

View File

@ -229,6 +229,7 @@ uint16_t CX10_callback()
}
break;
case CX10_DATA:
telemetry_set_input_sync(packet_period);
CX10_Write_Packet(0);
break;
}

View File

@ -258,6 +258,7 @@ static uint16_t __attribute__((unused)) CORONA_build_packet()
uint16_t ReadCORONA()
{
telemetry_set_input_sync(22000);
// Tune frequency if it has been changed
if ( prev_option != option )
{

View File

@ -113,7 +113,10 @@ static void __attribute__((unused)) DM002_init()
uint16_t DM002_callback()
{
if(IS_BIND_DONE)
{
telemetry_set_input_sync(DM002_PACKET_PERIOD);
DM002_send_packet(0);
}
else
{
if (bind_counter == 0)

View File

@ -452,6 +452,7 @@ uint16_t ReadDsm()
DSM_set_sop_data_crc();
return 10000;
case DSM_CH1_WRITE_A:
telemetry_set_input_sync(11000); // Always request 11ms spacing even if we don't use half of it in 22ms mode
case DSM_CH1_WRITE_B:
case DSM_CH2_WRITE_A:
case DSM_CH2_WRITE_B:

View File

@ -272,6 +272,7 @@ uint16_t devo_callback()
static uint8_t txState=0;
if (txState == 0)
{
telemetry_set_input_sync(2400);
txState = 1;
DEVO_BuildPacket();
CYRF_WriteDataPacket(packet);

View File

@ -287,7 +287,10 @@ uint16_t E01X_callback()
}
}
else
{
telemetry_set_input_sync(packet_period);
E01X_send_packet(0);
}
return packet_period;
}

View File

@ -151,7 +151,10 @@ uint8_t ESKY150_convert_2bit_channel(uint8_t num)
uint16_t ESKY150_callback()
{
if(IS_BIND_DONE)
{
telemetry_set_input_sync(ESKY150_SENDING_PACKET_PERIOD);
ESKY150_send_packet();
}
else
{
NRF24L01_WritePayload(packet, ESKY150_PAYLOADSIZE);

View File

@ -135,7 +135,10 @@ static void __attribute__((unused)) ESKY_send_packet(uint8_t bind)
uint16_t ESKY_callback()
{
if(IS_BIND_DONE)
{
telemetry_set_input_sync(ESKY_PACKET_PERIOD);
ESKY_send_packet(0);
}
else
{
ESKY_send_packet(1);

View File

@ -188,7 +188,10 @@ uint16_t FQ777_callback()
}
}
else
{
telemetry_set_input_sync(FQ777_PACKET_PERIOD);
FQ777_send_packet(0);
}
return FQ777_PACKET_PERIOD;
}

View File

@ -188,6 +188,7 @@ uint16_t FY326_callback()
return FY326_PACKET_CHKTIME;
break;
case FY326_DATA:
telemetry_set_input_sync(FY326_PACKET_PERIOD);
FY326_send_packet(0);
break;
}

View File

@ -168,16 +168,13 @@ uint16_t ReadFlySky()
}
else
{
telemetry_set_input_sync(packet_period);
flysky_build_packet(0);
A7105_WriteData(21, hopping_frequency[hopping_frequency_no & 0x0F]);
A7105_SetPower();
}
hopping_frequency_no++;
if(sub_protocol==CX20)
return 3984;
else
return 1510; //1460 on deviation but not working with the latest V911 bricks... Turnigy 9X v2 is 1533, Flysky TX for 9XR/9XR Pro is 1510, V911 TX is 1490.
return packet_period;
}
const uint8_t PROGMEM tx_channels[8][4] = {
@ -235,6 +232,10 @@ uint16_t initFlySky()
}
hopping_frequency_no=0;
packet_count=0;
if(sub_protocol==CX20)
packet_period=3984;
else
packet_period=1510; //1460 on deviation but not working with the latest V911 bricks... Turnigy 9X v2 is 1533, Flysky TX for 9XR/9XR Pro is 1510, V911 TX is 1490.
if(IS_BIND_IN_PROGRESS)
bind_counter = FLYSKY_BIND_COUNT;
else

View File

@ -55,6 +55,7 @@ uint16_t ReadFlyzone()
if(phase>19)
{
phase=0;
telemetry_set_input_sync(20*1500);
flyzone_build_packet();
A7105_WriteData(8, hopping_frequency[0]);
A7105_SetPower();

View File

@ -156,6 +156,7 @@ uint16_t ReadFrSky_2way()
{
if (state == FRSKY_DATA1)
{
telemetry_set_input_sync(9000);
len = CC2500_ReadReg(CC2500_3B_RXBYTES | CC2500_READ_BURST) & 0x7F;
if (len && len<=(0x11+3))// 20bytes
{

View File

@ -117,6 +117,7 @@ uint16_t ReadFRSKYV()
{
if(IS_BIND_DONE)
{ // Normal operation
telemetry_set_input_sync(9006);
uint8_t chan = FRSKYV_calc_channel();
CC2500_Strobe(CC2500_SIDLE);
if (option != prev_option)

View File

@ -322,6 +322,7 @@ uint16_t ReadFrSkyX()
state++;
return 3100;
case FRSKY_DATA4:
telemetry_set_input_sync(9000);
len = CC2500_ReadReg(CC2500_3B_RXBYTES | CC2500_READ_BURST) & 0x7F;
if (len && (len<=(0x0E + 3))) //Telemetry frame is 17
{

View File

@ -208,6 +208,7 @@ uint16_t GD00X_callback()
if(--bind_counter==0)
BIND_DONE;
GD00X_send_packet();
telemetry_set_input_sync(packet_period);
return packet_period;
}

View File

@ -139,6 +139,7 @@ uint16_t GW008_callback()
return 5000;
break;
case GW008_DATA:
telemetry_set_input_sync(GW008_PACKET_PERIOD);
GW008_send_packet(0);
break;
}

View File

@ -177,7 +177,10 @@ static void __attribute__((unused)) H8_3D_init()
uint16_t H8_3D_callback()
{
if(IS_BIND_DONE)
{
telemetry_set_input_sync(packet_period);
H8_3D_send_packet(0);
}
else
{
if (bind_counter == 0)

View File

@ -151,6 +151,7 @@ uint16_t hisky_cb()
phase=6;
break;
case 7: // build packet
telemetry_set_input_sync(5000);
#ifdef FAILSAFE_ENABLE
if(IS_FAILSAFE_VALUES_on && hopping_frequency_no==0)
{ // send failsafe every 100ms
@ -216,6 +217,7 @@ uint16_t hisky_cb()
break;
case 7:
//Build normal packet
telemetry_set_input_sync(9000);
build_ch_data();
break;
case 8:

View File

@ -259,6 +259,7 @@ uint16_t ReadHITEC()
case HITEC_PREP:
if ( prev_option == option )
{ // No user frequency change
telemetry_set_input_sync(HITEC_PACKET_PERIOD);
HITEC_change_chan_fast();
hopping_frequency_no++;
if(hopping_frequency_no>=rf_ch_num)

View File

@ -242,9 +242,12 @@ uint16_t HONTAI_callback()
}
}
else
{
telemetry_set_input_sync(packet_period);
HONTAI_send_packet(0);
}
return sub_protocol == FQ777_951 ? FQ777_951_PACKET_PERIOD : HONTAI_PACKET_PERIOD;
return packet_period;
}
uint16_t initHONTAI()
@ -253,6 +256,7 @@ uint16_t initHONTAI()
bind_counter = HONTAI_BIND_COUNT;
HONTAI_initialize_txid();
HONTAI_init();
packet_period = sub_protocol == FQ777_951 ? FQ777_951_PACKET_PERIOD : HONTAI_PACKET_PERIOD;
return HONTAI_INITIAL_WAIT;
}
#endif

View File

@ -376,6 +376,7 @@ uint16_t ReadHubsan()
case DATA_4:
case DATA_5:
if( txState == 0) { // send packet
telemetry_set_input_sync(10000);
#ifdef HUBSAN_HUB_TELEMETRY
rfMode = A7105_TX;
#endif

View File

@ -201,6 +201,7 @@ uint16_t ReadJ6Pro()
cyrf_datainit();
phase = J6PRO_CHAN_1;
case J6PRO_CHAN_1:
telemetry_set_input_sync(24550);
//Keep transmit power updated
CYRF_SetPower(0x28);
j6pro_build_data_packet();

View File

@ -86,6 +86,7 @@ static void __attribute__((unused)) KF606_init()
uint16_t KF606_callback()
{
telemetry_set_input_sync(KF606_PACKET_PERIOD);
if(IS_BIND_IN_PROGRESS)
if(--bind_counter==0)
{

View File

@ -279,12 +279,14 @@ uint16_t initKN()
packet_period = KN_WL_SENDING_PACKET_PERIOD;
bind_counter = KN_WL_BIND_COUNT;
packet_count = KN_WL_PACKET_SEND_COUNT;
seed = KN_WL_PACKET_SEND_COUNT * KN_WL_SENDING_PACKET_PERIOD;
}
else
{
packet_period = KN_FX_SENDING_PACKET_PERIOD;
bind_counter = KN_FX_BIND_COUNT;
packet_count = KN_FX_PACKET_SEND_COUNT;
seed = KN_FX_PACKET_SEND_COUNT * KN_FX_SENDING_PACKET_PERIOD;
}
kn_init();
phase = IS_BIND_IN_PROGRESS ? KN_PHASE_PRE_BIND : KN_PHASE_PRE_SEND;
@ -318,6 +320,7 @@ uint16_t kn_callback()
case KN_PHASE_SENDING:
if(packet_sent >= packet_count)
{
telemetry_set_input_sync(seed);
packet_sent = 0;
hopping_frequency_no++;
if(hopping_frequency_no >= KN_RF_CH_COUNT) hopping_frequency_no = 0;

View File

@ -327,7 +327,10 @@ static void __attribute__((unused)) MJXQ_initialize_txid()
uint16_t MJXQ_callback()
{
if(IS_BIND_DONE)
{
telemetry_set_input_sync(MJXQ_PACKET_PERIOD);
MJXQ_send_packet(0);
}
else
{
if (bind_counter == 0)

View File

@ -222,7 +222,10 @@ static void __attribute__((unused)) MT99XX_initialize_txid()
uint16_t MT99XX_callback()
{
if(IS_BIND_DONE)
{
telemetry_set_input_sync(packet_period);
MT99XX_send_packet();
}
else
{
if (bind_counter == 0)

View File

@ -19,7 +19,7 @@
#define VERSION_MAJOR 1
#define VERSION_MINOR 3
#define VERSION_REVISION 0
#define VERSION_PATCH_LEVEL 11
#define VERSION_PATCH_LEVEL 13
//******************
// Protocols
@ -322,9 +322,9 @@ enum MultiPacketTypes
MULTI_TELEMETRY_DSM = 4,
MULTI_TELEMETRY_DSMBIND = 5,
MULTI_TELEMETRY_AFHDS2A = 6,
MULTI_TELEMETRY_CONFIG = 7,
MULTI_TELEMETRY_REUSE_1 = 7,
MULTI_TELEMETRY_SYNC = 8,
MULTI_TELEMETRY_SPORT_BUFFER = 9,
MULTI_TELEMETRY_REUSE_2 = 9,
MULTI_TELEMETRY_HITEC = 10,
MULTI_TELEMETRY_SCANNER = 11,
MULTI_TELEMETRY_AFHDS2A_AC = 12,
@ -926,6 +926,19 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
data[0] = RSSI value
data[1-28] telemetry data
Type 0x08 Input synchronisation
Informs the TX about desired rate and current delay
length: 4
data[0-1] Desired refresh rate in ??s
data[2-3] Time (??s) between last serial servo input received and servo input needed (lateness), TX should adjust its
sending time to minimise this value.
data[4] Interval of this message in ms
data[5] Input delay target in 10??s
Note that there are protocols (AFHDS2A) that have a refresh rate that is smaller than the maximum achievable
refresh rate via the serial protocol, in this case, the TX should double the rate and also subract this
refresh rate from the input lag if the input lag is more than the desired refresh rate.
The remote should try to get to zero of (inputdelay+target*10).
Type 0x0A Hitec telemetry data
length: 8
data[0] = TX RSSI value

View File

@ -173,6 +173,10 @@ volatile uint8_t rx_idx=0, rx_len=0;
#define TELEMETRY_BUFFER_SIZE 30
uint8_t packet_in[TELEMETRY_BUFFER_SIZE];//telemetry receiving packets
#if defined(TELEMETRY)
#ifdef MULTI_SYNC
uint32_t last_serial_input=0;
uint16_t inputRefreshRate = 7000;
#endif
#ifdef INVERT_TELEMETRY
#if not defined(ORANGE_TX) && not defined(STM32_BOARD)
// enable bit bash for serial
@ -573,11 +577,11 @@ void loop()
next_callback=2000; // No PPM/serial signal check again in 2ms...
TX_MAIN_PAUSE_off;
tx_resume();
while(next_callback>4000)
while(next_callback>1000)
{ // start to wait here as much as we can...
next_callback-=2000; // We will wait below for 2ms
next_callback-=500; // We will wait below for 0.5ms
cli(); // Disable global int due to RW of 16 bits registers
OCR1A += 2000*2 ; // set compare A for callback
OCR1A += 500*2 ; // set compare A for callback
#ifndef STM32_BOARD
TIFR1=OCF1A_bm; // clear compare A=callback flag
#else
@ -590,12 +594,12 @@ void loop()
break;
}
#ifndef STM32_BOARD
while((TIFR1 & OCF1A_bm) == 0); // wait 2ms...
while((TIFR1 & OCF1A_bm) == 0); // wait 0.5ms...
#else
while((TIMER2_BASE->SR & TIMER_SR_CC1IF)==0);//2ms wait
while((TIMER2_BASE->SR & TIMER_SR_CC1IF)==0);//wait 0.5ms...
#endif
}
// at this point we have a maximum of 4ms in next_callback
// at this point we have a maximum of 1ms in next_callback
next_callback *= 2 ;
cli(); // Disable global int due to RW of 16 bits registers
OCR1A+= next_callback ; // set compare A for callback
@ -666,7 +670,7 @@ uint8_t Update_All()
#if ( !( defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) ) )
if( (protocol == PROTO_FRSKYX_RX) || (protocol == PROTO_SCANNER) || (protocol==PROTO_FRSKYD) || (protocol==PROTO_BAYANG) || (protocol==PROTO_NCC1701) || (protocol==PROTO_BUGS) || (protocol==PROTO_BUGSMINI) || (protocol==PROTO_HUBSAN) || (protocol==PROTO_AFHDS2A) || (protocol==PROTO_FRSKYX) || (protocol==PROTO_DSM) || (protocol==PROTO_CABELL) || (protocol==PROTO_HITEC))
#endif
if(IS_DISABLE_TELEM_off)
if(IS_DISABLE_TELEM_off && !(protocol==PROTO_XN297DUMP))
TelemetryUpdate();
#endif
#ifdef ENABLE_BIND_CH
@ -928,6 +932,9 @@ static void protocol_init()
// reset telemetry
#ifdef TELEMETRY
#ifdef MULTI_SYNC
inputRefreshRate = 7000; // Default value
#endif
tx_pause();
pass=0;
telemetry_link=0;
@ -2027,7 +2034,9 @@ static uint32_t random_id(uint16_t address, uint8_t create_new)
TIMER2_BASE->SR = 0x1E5F & ~TIMER_SR_CC2IF; // Clear Timer2/Comp2 interrupt flag
TIMER2_BASE->DIER |= TIMER_DIER_CC2IE; // Enable Timer2/Comp2 interrupt
#else
cli(); // Disable global int due to RW of 16 bits registers
OCR1B = TCNT1 + 300; // Next byte should show up within 15us=1.5 byte
sei(); // Enable global int
TIFR1 = OCF1B_bm ; // clear OCR1B match flag
SET_TIMSK1_OCIE1B ; // enable interrupt on compare B match
#endif
@ -2047,7 +2056,9 @@ static uint32_t random_id(uint16_t address, uint8_t create_new)
#if defined STM32_BOARD
TIMER2_BASE->CCR2=TIMER2_BASE->CNT + 300; // Next byte should show up within 15us=1.5 byte
#else
cli(); // Disable global int due to RW of 16 bits registers
OCR1B = TCNT1 + 300; // Next byte should show up within 15us=1.5 byte
sei(); // Enable global int
#endif
}
}
@ -2085,7 +2096,11 @@ static uint32_t random_id(uint16_t address, uint8_t create_new)
#endif
{ // Timer1 compare B interrupt
if(rx_idx>=26)
{ // A full frame has been received
{
#ifdef MULTI_SYNC
last_serial_input=TCNT1;
#endif
// A full frame has been received
if(!IS_RX_DONOTUPDATE_on)
{ //Good frame received and main is not working on the buffer
rx_len=rx_idx;

View File

@ -197,6 +197,7 @@ uint16_t NCC_callback()
phase = NCC_BIND_TX2;
return NCC_PACKET_INTERVAL - NCC_WRITE_WAIT;
case NCC_TX3:
telemetry_set_input_sync(NCC_PACKET_INTERVAL);
if( NRF24L01_ReadReg(NRF24L01_07_STATUS) & _BV(NRF24L01_07_RX_DR))
{ // RX fifo data ready
NRF24L01_ReadPayload(packet, NCC_RX_PACKET_LEN);

View File

@ -109,6 +109,7 @@ uint16_t POTENSIC_callback()
BIND_DONE;
XN297_SetTXAddr(rx_tx_addr,5);
}
telemetry_set_input_sync(POTENSIC_PACKET_PERIOD);
POTENSIC_send_packet();
return POTENSIC_PACKET_PERIOD;
}

View File

@ -354,7 +354,10 @@ static void __attribute__((unused)) Q303_initialize_txid()
uint16_t Q303_callback()
{
if(IS_BIND_DONE)
{
telemetry_set_input_sync(packet_period);
Q303_send_packet(0);
}
else
{
if (bind_counter == 0)

View File

@ -125,6 +125,7 @@ static uint16_t ReadREDPINE()
}
else
{
telemetry_set_input_sync(packet_period);
CC2500_SetTxRxMode(TX_EN);
REDPINE_set_channel(hopping_frequency_no);
CC2500_SetPower();
@ -133,10 +134,7 @@ static uint16_t ReadREDPINE()
CC2500_Strobe(CC2500_SIDLE);
hopping_frequency_no = (hopping_frequency_no + 1) % 49;
CC2500_WriteData(packet, REDPINE_PACKET_SIZE);
if (sub_protocol==0)
return REDPINE_LOOPTIME_FAST*100;
else
return REDPINE_LOOPTIME_SLOW*1000;
return packet_period;
}
return 1;
}
@ -235,6 +233,11 @@ static uint16_t initREDPINE()
}
hopping_frequency[49] = 0; // Last channel is the bind channel at hop 0
if (sub_protocol==0)
packet_period = REDPINE_LOOPTIME_FAST*100;
else
packet_period = REDPINE_LOOPTIME_SLOW*1000;
bind_counter=REDPINE_BIND;
REDPINE_init(sub_protocol);
CC2500_SetTxRxMode(TX_EN); // enable PA

View File

@ -235,6 +235,7 @@ uint16_t ReadSFHSS()
#define SFHSS_PACKET_PERIOD 6800
#define SFHSS_DATA2_TIMING 1625 // Adjust this value between 1600 and 1650 if your RX(s) are not operating properly
case SFHSS_DATA1:
telemetry_set_input_sync(6800);
SFHSS_build_data_packet();
SFHSS_send_packet();
phase = SFHSS_DATA2;

View File

@ -63,6 +63,8 @@ void SHENQI_send_packet()
}
else
{
if(packet_count==1)
telemetry_set_input_sync(3000+2508+6*1750);
LT8900_SetAddress(rx_tx_addr,4);
packet[1]=255-convert_channel_8b(RUDDER);
packet[2]=255-convert_channel_16b_limit(THROTTLE,0x60,0xA0);
@ -91,7 +93,9 @@ void SHENQI_send_packet()
uint16_t SHENQI_callback()
{
if(IS_BIND_DONE)
{
SHENQI_send_packet();
}
else
{
if( NRF24L01_ReadReg(NRF24L01_07_STATUS) & _BV(NRF24L01_07_RX_DR))

View File

@ -213,6 +213,7 @@ uint16_t SLT_callback()
switch (phase)
{
case SLT_BUILD:
telemetry_set_input_sync(sub_protocol==SLT_V1?20000:13730);
SLT_build_packet();
phase++;
return SLT_TIMING_BUILD;

View File

@ -359,6 +359,7 @@ uint16_t symax_callback()
}
break;
case SYMAX_DATA:
telemetry_set_input_sync(SYMAX_PACKET_PERIOD);
SYMAX_send_packet(0);
break;
}

View File

@ -162,6 +162,7 @@ uint16_t ReadTRAXXAS()
TRAXXAS_cyrf_data_config();
phase++;
case TRAXXAS_DATA:
telemetry_set_input_sync(13940);
TRAXXAS_send_data_packet();
break;
}

View File

@ -20,10 +20,14 @@
uint8_t RetrySequence ;
#if ( defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) )
uint32_t lastMulti = 0;
#define MULTI_TIME 500 //in ms
#ifdef MULTI_SYNC
#define INPUT_SYNC_TIME 100 //in ms
#define INPUT_ADDITIONAL_DELAY 100 // in 10µs, 100 => 1000 µs
uint32_t lastMulti = 0;
uint32_t lastInputSync = 0;
uint16_t inputDelay = 0;
#endif // MULTI_SYNC
#endif // MULTI_TELEMETRY/MULTI_STATUS
#if defined SPORT_TELEMETRY
@ -76,6 +80,51 @@ static void multi_send_header(uint8_t type, uint8_t len)
Serial_write(len);
}
inline void telemetry_set_input_sync(uint16_t refreshRate)
{
#ifdef MULTI_SYNC
#if defined(STM32_BOARD) && defined(DEBUG_PIN)
static uint8_t c=0;
if (c++%2==0)
{ DEBUG_PIN_on; }
else
{ DEBUG_PIN_off; }
#endif
// Only record input Delay after a frame has really been received
// Otherwise protocols with faster refresh rates then the TX sends (e.g. 3ms vs 6ms) will screw up the calcualtion
inputRefreshRate = refreshRate;
if (last_serial_input != 0)
{
#if defined STM32_BOARD
inputDelay=TIMER2_BASE->CNT;
#else
cli(); // Disable global int due to RW of 16 bits registers
inputDelay = TCNT1; // Next byte should show up within 15us=1.5 byte
sei(); // Enable global int
#endif
inputDelay = (inputDelay - last_serial_input)>>1;
if(inputDelay > 0x8000)
inputDelay =inputDelay - 0x8000;
last_serial_input=0;
}
#else
(void)refreshRate;
#endif
}
#ifdef MULTI_SYNC
static void mult_send_inputsync()
{
multi_send_header(MULTI_TELEMETRY_SYNC, 6);
Serial_write(inputRefreshRate >> 8);
Serial_write(inputRefreshRate & 0xff);
Serial_write(inputDelay >> 8);
Serial_write(inputDelay & 0xff);
Serial_write(INPUT_SYNC_TIME);
Serial_write(INPUT_ADDITIONAL_DELAY);
}
#endif //MULTI_SYNC
static void multi_send_status()
{
multi_send_header(MULTI_TELEMETRY_STATUS, 6);
@ -744,6 +793,14 @@ void TelemetryUpdate()
lastMulti = now;
return;
}
#ifdef MULTI_SYNC
else if ( (now - lastInputSync) > INPUT_SYNC_TIME)
{
mult_send_inputsync();
lastInputSync = now;
return;
}
#endif
#endif
#if defined SPORT_TELEMETRY

View File

@ -264,6 +264,7 @@ uint16_t ReadV2x2()
case V202_DATA:
if (packet_sent && NRF24L01_packet_ack() != PKT_ACKED)
return V2X2_PACKET_CHKTIME;
telemetry_set_input_sync(V2X2_PACKET_PERIOD);
V2X2_send_packet(0);
break;
}

View File

@ -174,6 +174,7 @@ uint16_t V761_callback()
}
return 15730;
case V761_DATA:
telemetry_set_input_sync(V761_PACKET_PERIOD);
V761_send_packet();
break;
}

View File

@ -111,7 +111,10 @@ static void __attribute__((unused)) V911S_initialize_txid()
uint16_t V911S_callback()
{
if(IS_BIND_DONE)
{
telemetry_set_input_sync(V911S_PACKET_PERIOD);
V911S_send_packet(0);
}
else
{
if (bind_counter == 0)

View File

@ -315,6 +315,14 @@
#endif
#endif
#ifdef SPORT_TELEMETRY
#define SPORT_SEND
#endif
#if not defined(MULTI_TELEMETRY)
#undef MULTI_SYNC
#endif
//Make sure TX is defined correctly
#ifndef AILERON
#error You must select a correct channel order.

View File

@ -232,6 +232,7 @@ uint16_t ReadWFLY()
packet_count=0;
phase++;
case WFLY_DATA:
telemetry_set_input_sync(5371);
start=micros();
while ((uint8_t)((uint8_t)micros()-(uint8_t)start) < 200)
if((CYRF_ReadRegister(CYRF_02_TX_CTRL) & 0x80) == 0x00)

View File

@ -435,6 +435,7 @@ uint16_t WK_cb()
{
if (packet_sent == 0)
{
telemetry_set_input_sync(2800);
packet_sent = 1;
if(sub_protocol == WK2801)
WK_BuildPacket_2801();

View File

@ -155,7 +155,10 @@ static void __attribute__((unused)) yd717_init()
uint16_t yd717_callback()
{
if(IS_BIND_DONE)
{
telemetry_set_input_sync(YD717_PACKET_PERIOD);
yd717_send_packet(0);
}
else
{
if (bind_counter == 0)

View File

@ -80,6 +80,7 @@ static void __attribute__((unused)) ZSX_init()
uint16_t ZSX_callback()
{
telemetry_set_input_sync(ZSX_PACKET_PERIOD);
if(IS_BIND_IN_PROGRESS)
if(--bind_counter==0)
{

View File

@ -264,17 +264,19 @@
//For er9x it depends if you have an inveter mod or not on the telemetry pin. If you don't have an inverter comment this line.
#define INVERT_TELEMETRY
//Comment if you don't want to send Multi status telemetry frames (Protocol available, Bind in progress, version...)
//Uncomment if you don't want to send Multi status telemetry frames (Protocol available, Bind in progress, version...)
//Use with er9x/erksy9x, for OpenTX MULTI_TELEMETRY below is preferred instead
//#define MULTI_STATUS
//Uncomment to send Multi status and allow OpenTX to autodetect the telemetry format
//Comment to send Multi status and allow OpenTX to autodetect the telemetry format
//Supported by OpenTX version 2.2 RC9 and newer. NOT supported by er9x/ersky9x use MULTI_STATUS instead.
#define MULTI_TELEMETRY
//Comment to not sync OpenTX and module together
#define MULTI_SYNC
//Comment a line to disable a specific protocol telemetry
#define DSM_TELEMETRY // Forward received telemetry packet directly to TX to be decoded by er9x, ersky9x and OpenTX
#define SPORT_TELEMETRY // Use FrSkyX SPORT format to send telemetry to TX
#define SPORT_TELEMETRY // Use FrSkyX format to send telemetry to TX
#define AFHDS2A_FW_TELEMETRY // Forward received telemetry packet directly to TX to be decoded by ersky9x and OpenTX
#define AFHDS2A_HUB_TELEMETRY // Use FrSkyD Hub format to send basic telemetry to TX like er9x
#define HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
@ -289,11 +291,6 @@
#define FRSKYX_RX_TELEMETRY // Forward channels data to TX
#define AFHDS2A_RX_TELEMETRY // Forward channels data to TX
//SPORT_SEND: passing sport control frames from TX to RX(ex: SxR configuration, changing Betaflight PID or VTX channels on the fly using LUA scripts with OpentX).
//!!!! This is a work in progress!!! Do not enable unless you want to test and report
//#define SPORT_SEND
/****************************/
/*** SERIAL MODE SETTINGS ***/
/****************************/