mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-09 23:38:10 +00:00
FrSkyX LBT: implement LBT instead of transmitting all the time
Needs to be activated using FRSKYX_LBT for now.
This commit is contained in:
parent
0fddd9c119
commit
9f1bdc901c
@ -47,7 +47,8 @@ enum {
|
|||||||
FRSKY_DATA2,
|
FRSKY_DATA2,
|
||||||
FRSKY_DATA3,
|
FRSKY_DATA3,
|
||||||
FRSKY_DATA4,
|
FRSKY_DATA4,
|
||||||
FRSKY_DATA5
|
FRSKY_DATA5,
|
||||||
|
FRSKY_DATA6
|
||||||
};
|
};
|
||||||
|
|
||||||
void Frsky_init_hop(void)
|
void Frsky_init_hop(void)
|
||||||
|
@ -276,6 +276,8 @@ static void __attribute__((unused)) FrSkyX_build_packet()
|
|||||||
|
|
||||||
uint16_t ReadFrSkyX()
|
uint16_t ReadFrSkyX()
|
||||||
{
|
{
|
||||||
|
static bool transmit=true;
|
||||||
|
|
||||||
switch(state)
|
switch(state)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
@ -300,38 +302,55 @@ uint16_t ReadFrSkyX()
|
|||||||
case FRSKY_DATA1:
|
case FRSKY_DATA1:
|
||||||
if ( prev_option != option )
|
if ( prev_option != option )
|
||||||
{
|
{
|
||||||
CC2500_WriteReg(CC2500_0C_FSCTRL0,option); // Frequency offset hack
|
CC2500_WriteReg(CC2500_0C_FSCTRL0,option); //Frequency offset hack
|
||||||
prev_option = option ;
|
prev_option = option ;
|
||||||
}
|
}
|
||||||
CC2500_SetTxRxMode(TX_EN);
|
|
||||||
FrSkyX_set_start(hopping_frequency_no);
|
FrSkyX_set_start(hopping_frequency_no);
|
||||||
|
transmit=true;
|
||||||
|
#ifdef FRSKYX_LBT
|
||||||
|
CC2500_Strobe(CC2500_SIDLE);
|
||||||
|
state++;
|
||||||
|
return 210; //Wait for the freq to stabilize
|
||||||
|
case FRSKY_DATA2:
|
||||||
|
CC2500_Strobe(CC2500_SRX); //Acquire RSSI
|
||||||
|
state++;
|
||||||
|
return 20;
|
||||||
|
case FRSKY_DATA3:
|
||||||
|
uint8_t rssi;
|
||||||
|
rssi = CC2500_ReadReg(CC2500_34_RSSI | CC2500_READ_BURST); // 0.5 db/count, RSSI value read from the RSSI status register is a 2's complement number
|
||||||
|
if ((sub_protocol & 2) && rssi > 72 && rssi < 128) //LBT and RSSI between -36 to -8.5 dBm
|
||||||
|
{
|
||||||
|
transmit=false;
|
||||||
|
debugln("Busy %d %d",hopping_frequency_no,rssi);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
CC2500_SetTxRxMode(TX_EN);
|
||||||
CC2500_SetPower();
|
CC2500_SetPower();
|
||||||
CC2500_Strobe(CC2500_SFRX);
|
CC2500_Strobe(CC2500_SFRX);
|
||||||
hopping_frequency_no = (hopping_frequency_no+FrSkyX_chanskip)%47;
|
hopping_frequency_no = (hopping_frequency_no+FrSkyX_chanskip)%47;
|
||||||
CC2500_Strobe(CC2500_SIDLE);
|
CC2500_Strobe(CC2500_SIDLE);
|
||||||
CC2500_WriteData(packet, packet[0]+1);
|
if(transmit)
|
||||||
state++;
|
CC2500_WriteData(packet, packet[0]+1);
|
||||||
|
state=FRSKY_DATA4;
|
||||||
return 5200;
|
return 5200;
|
||||||
case FRSKY_DATA2:
|
case FRSKY_DATA4:
|
||||||
CC2500_SetTxRxMode(RX_EN);
|
CC2500_SetTxRxMode(RX_EN);
|
||||||
CC2500_Strobe(CC2500_SIDLE);
|
CC2500_Strobe(CC2500_SIDLE);
|
||||||
state++;
|
state++;
|
||||||
return 200;
|
return 200;
|
||||||
case FRSKY_DATA3:
|
case FRSKY_DATA5:
|
||||||
CC2500_Strobe(CC2500_SRX);
|
CC2500_Strobe(CC2500_SRX);
|
||||||
state++;
|
state++;
|
||||||
return 3100;
|
return 3100;
|
||||||
case FRSKY_DATA4:
|
case FRSKY_DATA6:
|
||||||
telemetry_set_input_sync(9000);
|
telemetry_set_input_sync(9000);
|
||||||
len = CC2500_ReadReg(CC2500_3B_RXBYTES | CC2500_READ_BURST) & 0x7F;
|
len = CC2500_ReadReg(CC2500_3B_RXBYTES | CC2500_READ_BURST) & 0x7F;
|
||||||
if (len && (len<=(0x0E + 3))) //Telemetry frame is 17
|
if (len && (len<=(0x0E + 3))) //Telemetry frame is 17
|
||||||
{
|
{
|
||||||
packet_count=0;
|
packet_count=0;
|
||||||
CC2500_ReadData(packet_in, len);
|
CC2500_ReadData(packet_in, len);
|
||||||
#if defined TELEMETRY
|
#if defined TELEMETRY
|
||||||
frsky_check_telemetry(packet_in,len); //check if valid telemetry packets
|
frsky_check_telemetry(packet_in,len); //Check and parse telemetry packets
|
||||||
//parse telemetry packets here
|
|
||||||
//The same telemetry function used by FrSky(D8).
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -355,7 +374,11 @@ uint16_t ReadFrSkyX()
|
|||||||
}
|
}
|
||||||
FrSkyX_build_packet();
|
FrSkyX_build_packet();
|
||||||
state = FRSKY_DATA1;
|
state = FRSKY_DATA1;
|
||||||
|
#ifdef FRSKYX_LBT
|
||||||
|
return 270;
|
||||||
|
#else
|
||||||
return 500;
|
return 500;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 3
|
#define VERSION_MINOR 3
|
||||||
#define VERSION_REVISION 0
|
#define VERSION_REVISION 0
|
||||||
#define VERSION_PATCH_LEVEL 23
|
#define VERSION_PATCH_LEVEL 24
|
||||||
|
|
||||||
//******************
|
//******************
|
||||||
// Protocols
|
// Protocols
|
||||||
|
@ -222,6 +222,12 @@
|
|||||||
/*** PROTOCOLS SETTINGS ***/
|
/*** PROTOCOLS SETTINGS ***/
|
||||||
/***************************/
|
/***************************/
|
||||||
|
|
||||||
|
//FrSkyX specific setting
|
||||||
|
//-----------------------
|
||||||
|
//EU LBT setting
|
||||||
|
//If commented the TX will not check if a channel is busy before transmitting
|
||||||
|
//#define FRSKYX_LBT
|
||||||
|
|
||||||
//DSM specific settings
|
//DSM specific settings
|
||||||
//---------------------
|
//---------------------
|
||||||
//The DSM protocol is using by default the Spektrum throw of 1100..1900us @100% and 1000..2000us @125%.
|
//The DSM protocol is using by default the Spektrum throw of 1100..1900us @100% and 1000..2000us @125%.
|
||||||
@ -274,8 +280,9 @@
|
|||||||
#define MULTI_TELEMETRY
|
#define MULTI_TELEMETRY
|
||||||
//Send to OpenTX the current protocol and subprotocol names. Comment to disable.
|
//Send to OpenTX the current protocol and subprotocol names. Comment to disable.
|
||||||
#define MULTI_NAMES
|
#define MULTI_NAMES
|
||||||
//Sync OpenTX frames with the current protocol timing. This feature is only available on the STM32 module. Comment to disable.
|
//Sync OpenTX frames with the current protocol timing. This feature is only available on the STM32 module. Uncomment to enable.
|
||||||
#define MULTI_SYNC
|
//!!!Work in progress!!! it's currently known to cause issues. Enable only if you know what you are doing.
|
||||||
|
//#define MULTI_SYNC
|
||||||
|
|
||||||
//Comment a line to disable a specific protocol telemetry
|
//Comment a line to disable a specific protocol telemetry
|
||||||
#define DSM_TELEMETRY // Forward received telemetry packet directly to TX to be decoded by er9x, erskyTX and OpenTX
|
#define DSM_TELEMETRY // Forward received telemetry packet directly to TX to be decoded by er9x, erskyTX and OpenTX
|
||||||
|
Loading…
x
Reference in New Issue
Block a user