mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-04 18:38:13 +00:00
FrSkyR9: TQLY = percentage of telemetry frames per second
This commit is contained in:
parent
78421748ba
commit
84132678cc
@ -90,8 +90,6 @@ uint16_t initAFHDS2A_Rx()
|
||||
|
||||
uint16_t AFHDS2A_Rx_callback()
|
||||
{
|
||||
static uint32_t pps_timer = 0;
|
||||
static uint16_t pps_counter = 0;
|
||||
static int8_t read_retry;
|
||||
int16_t temp;
|
||||
uint8_t i;
|
||||
|
@ -126,8 +126,6 @@ uint16_t Bayang_Rx_callback()
|
||||
{
|
||||
uint8_t i;
|
||||
static int8_t read_retry;
|
||||
static uint16_t pps_counter;
|
||||
static uint32_t pps_timer = 0;
|
||||
|
||||
switch (phase) {
|
||||
case BAYANG_RX_BIND:
|
||||
|
@ -209,8 +209,6 @@ uint16_t DSM_Rx_callback()
|
||||
{
|
||||
uint8_t rx_status;
|
||||
static uint8_t read_retry=0;
|
||||
static uint16_t pps_counter;
|
||||
static uint32_t pps_timer = 0;
|
||||
|
||||
switch (phase)
|
||||
{
|
||||
|
@ -381,7 +381,7 @@ void Frsky_init_clone(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FRSKYX_CC2500_INO) || defined(FRSKYL_CC2500_INO) || defined(FRSKYR9_SX1276_INO)
|
||||
#if defined(FRSKYX_CC2500_INO) || defined(FRSKYR9_SX1276_INO)
|
||||
uint8_t FrSkyX_TX_Seq, FrSkyX_TX_IN_Seq;
|
||||
uint8_t FrSkyX_RX_Seq ;
|
||||
|
||||
@ -394,6 +394,20 @@ uint8_t FrSkyX_RX_Seq ;
|
||||
// Store FrskyX telemetry
|
||||
struct t_FrSkyX_TX_Frame FrSkyX_TX_Frames[4] ;
|
||||
#endif
|
||||
|
||||
static void __attribute__((unused)) FrSkyX_telem_init(void)
|
||||
{
|
||||
FrSkyX_TX_Seq = 0x08 ; // Request init
|
||||
#ifdef SPORT_SEND
|
||||
FrSkyX_TX_IN_Seq = 0xFF ; // No sequence received yet
|
||||
for(uint8_t i=0;i<4;i++)
|
||||
FrSkyX_TX_Frames[i].count=0;// discard frames in current output buffer
|
||||
SportHead=SportTail=0; // empty data buffer
|
||||
#endif
|
||||
FrSkyX_RX_Seq = 0 ; // Seq 0 to start with
|
||||
telemetry_lost=1;
|
||||
telemetry_link=0; //Stop sending telemetry
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(FRSKYX_CC2500_INO) || defined(FRSKYL_CC2500_INO)
|
||||
|
@ -113,17 +113,9 @@ uint16_t initFrSkyR9()
|
||||
SX1276_SetPaDac(true);
|
||||
SX1276_SetTxRxMode(TX_EN); // Set RF switch to TX
|
||||
|
||||
FrSkyX_TX_Seq = 0x08 ; // Request init
|
||||
FrSkyX_TX_IN_Seq = 0xFF ; // No sequence received yet
|
||||
#ifdef SPORT_SEND
|
||||
for(uint8_t i=0;i<4;i++)
|
||||
FrSkyX_TX_Frames[i].count=0; // discard frames in current output buffer
|
||||
SportHead=SportTail=0; // empty data buffer
|
||||
#endif
|
||||
FrSkyX_RX_Seq = 0 ; // Seq 0 to start with
|
||||
FrSkyX_telem_init();
|
||||
|
||||
phase=FRSKYR9_FREQ;
|
||||
|
||||
return 20000; // start calling FrSkyR9_callback in 20 milliseconds
|
||||
}
|
||||
|
||||
@ -176,7 +168,6 @@ uint16_t FrSkyR9_callback()
|
||||
phase++;
|
||||
return 7400;
|
||||
case FRSKYR9_RX2:
|
||||
telemetry_link=0;
|
||||
if( (SX1276_ReadReg(SX1276_12_REGIRQFLAGS)&0xF0) == (_BV(SX1276_REGIRQFLAGS_RXDONE) | _BV(SX1276_REGIRQFLAGS_VALIDHEADER)) )
|
||||
{
|
||||
if(SX1276_ReadReg(SX1276_13_REGRXNBBYTES)==13)
|
||||
@ -188,34 +179,27 @@ uint16_t FrSkyR9_callback()
|
||||
RX_RSSI=packet_in[0]<<1;
|
||||
else
|
||||
v_lipo1=(packet_in[0]<<1)+1;
|
||||
TX_LQI=~(SX1276_ReadReg(SX1276_19_PACKETSNR)>>2)+1;
|
||||
//TX_LQI=~(SX1276_ReadReg(SX1276_19_PACKETSNR)>>2)+1;
|
||||
TX_RSSI=SX1276_ReadReg(SX1276_1A_PACKETRSSI)-157;
|
||||
for(uint8_t i=0;i<9;i++)
|
||||
packet[4+i]=packet_in[i]; //Adjust buffer to match FrSkyX
|
||||
frsky_process_telemetry(packet,len); //Check and parse telemetry packets
|
||||
pps_counter++;
|
||||
if(TX_LQI==0)
|
||||
TX_LQI++; //Recover telemetry right away
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!telemetry_link)
|
||||
{
|
||||
packet_count++;
|
||||
//debugln("M %d",packet_count);
|
||||
// restart sequence on missed packet - might need count or timeout instead of one missed
|
||||
if(packet_count>100)
|
||||
{//~1sec
|
||||
FrSkyX_TX_Seq = 0x08 ; //Request init
|
||||
FrSkyX_TX_IN_Seq = 0xFF ; //No sequence received yet
|
||||
#ifdef SPORT_SEND
|
||||
for(uint8_t i=0;i<4;i++)
|
||||
FrSkyX_TX_Frames[i].count=0; //Discard frames in current output buffer
|
||||
#endif
|
||||
packet_count=0;
|
||||
telemetry_lost=1;
|
||||
telemetry_link=0; //Stop sending telemetry
|
||||
if (millis() - pps_timer >= 1000)
|
||||
{//50pps @20ms
|
||||
pps_timer = millis();
|
||||
debugln("%d pps", pps_counter);
|
||||
TX_LQI = pps_counter<<1; // Max=100pps
|
||||
pps_counter = 0;
|
||||
}
|
||||
CC2500_Strobe(CC2500_SFRX); //Flush the RXFIFO
|
||||
}
|
||||
if(!telemetry_lost)
|
||||
if(TX_LQI==0)
|
||||
FrSkyX_telem_init();
|
||||
else
|
||||
telemetry_link=1; // Send telemetry out anyway
|
||||
//Clear all flags
|
||||
SX1276_WriteReg(SX1276_12_REGIRQFLAGS,0xFF);
|
||||
|
@ -275,7 +275,6 @@ uint16_t ReadFrSkyX()
|
||||
#endif
|
||||
#if defined TELEMETRY
|
||||
telemetry_link=1; //Send telemetry out anyway
|
||||
#endif
|
||||
len = CC2500_ReadReg(CC2500_3B_RXBYTES | CC2500_READ_BURST) & 0x7F;
|
||||
if (len && len <= 17) //Telemetry frame is 17 bytes
|
||||
{
|
||||
@ -290,7 +289,6 @@ uint16_t ReadFrSkyX()
|
||||
len=17;
|
||||
}
|
||||
}
|
||||
#if defined TELEMETRY
|
||||
if(len==17 && (protocol==PROTO_FRSKYX || (protocol==PROTO_FRSKYX2 && (packet_in[len-1] & 0x80))) )
|
||||
{//Telemetry received with valid crc for FRSKYX2
|
||||
//Debug
|
||||
@ -301,7 +299,6 @@ uint16_t ReadFrSkyX()
|
||||
else
|
||||
len=0; // bad
|
||||
}
|
||||
#endif
|
||||
//debugln("");
|
||||
}
|
||||
if(len!=17)
|
||||
@ -309,22 +306,11 @@ uint16_t ReadFrSkyX()
|
||||
packet_count++;
|
||||
//debugln("M %d",packet_count);
|
||||
// restart sequence on missed packet - might need count or timeout instead of one missed
|
||||
if(packet_count>100)
|
||||
{//~1sec
|
||||
FrSkyX_TX_Seq = 0x08 ; //Request init
|
||||
FrSkyX_TX_IN_Seq = 0xFF ; //No sequence received yet
|
||||
#ifdef SPORT_SEND
|
||||
for(uint8_t i=0;i<4;i++)
|
||||
FrSkyX_TX_Frames[i].count=0; //Discard frames in current output buffer
|
||||
#endif
|
||||
packet_count=0;
|
||||
#if defined TELEMETRY
|
||||
telemetry_lost=1;
|
||||
telemetry_link=0; //Stop sending telemetry
|
||||
#endif
|
||||
if(packet_count>100)//~1sec
|
||||
FrSkyX_telem_init();
|
||||
}
|
||||
#endif
|
||||
CC2500_Strobe(CC2500_SFRX); //Flush the RXFIFO
|
||||
}
|
||||
state = FRSKY_DATA1;
|
||||
return 400; // FCC & LBT
|
||||
}
|
||||
@ -370,14 +356,7 @@ uint16_t initFrSkyX()
|
||||
state = FRSKY_DATA1;
|
||||
FrSkyX_initialize_data(0);
|
||||
}
|
||||
FrSkyX_TX_Seq = 0x08 ; // Request init
|
||||
FrSkyX_TX_IN_Seq = 0xFF ; // No sequence received yet
|
||||
#ifdef SPORT_SEND
|
||||
for(uint8_t i=0;i<4;i++)
|
||||
FrSkyX_TX_Frames[i].count=0; // discard frames in current output buffer
|
||||
SportHead=SportTail=0; // empty data buffer
|
||||
#endif
|
||||
FrSkyX_RX_Seq = 0 ; // Seq 0 to start with
|
||||
FrSkyX_telem_init();
|
||||
return 10000;
|
||||
}
|
||||
#endif
|
||||
|
@ -379,8 +379,6 @@ uint16_t initFrSky_Rx()
|
||||
|
||||
uint16_t FrSky_Rx_callback()
|
||||
{
|
||||
static uint32_t pps_timer=0;
|
||||
static uint8_t pps_counter=0;
|
||||
static int8_t read_retry = 0;
|
||||
static int8_t tune_low, tune_high;
|
||||
uint8_t len, ch;
|
||||
|
@ -274,10 +274,6 @@ static void __attribute__((unused)) HOTT_prep_data_packet()
|
||||
|
||||
uint16_t ReadHOTT()
|
||||
{
|
||||
#ifdef HOTT_FW_TELEMETRY
|
||||
static uint8_t pps_counter=0;
|
||||
#endif
|
||||
|
||||
switch(phase)
|
||||
{
|
||||
case HOTT_START:
|
||||
|
@ -19,7 +19,7 @@
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_REVISION 1
|
||||
#define VERSION_PATCH_LEVEL 33
|
||||
#define VERSION_PATCH_LEVEL 34
|
||||
|
||||
//******************
|
||||
// Protocols
|
||||
|
@ -119,6 +119,8 @@ uint16_t state;
|
||||
uint8_t len;
|
||||
uint8_t armed, arm_flags, arm_channel_previous;
|
||||
uint8_t num_ch;
|
||||
uint32_t pps_timer = 0;
|
||||
uint16_t pps_counter = 0;
|
||||
|
||||
#ifdef CC2500_INSTALLED
|
||||
#ifdef SCANNER_CC2500_INO
|
||||
|
Loading…
x
Reference in New Issue
Block a user