diff --git a/Multiprotocol/FrSkyDVX_common.ino b/Multiprotocol/FrSkyDVX_common.ino index 801b6e9..573d463 100644 --- a/Multiprotocol/FrSkyDVX_common.ino +++ b/Multiprotocol/FrSkyDVX_common.ino @@ -47,7 +47,8 @@ enum { FRSKY_DATA2, FRSKY_DATA3, FRSKY_DATA4, - FRSKY_DATA5 + FRSKY_DATA5, + FRSKY_DATA6 }; void Frsky_init_hop(void) diff --git a/Multiprotocol/FrSkyX_cc2500.ino b/Multiprotocol/FrSkyX_cc2500.ino index 39ea701..ac66992 100644 --- a/Multiprotocol/FrSkyX_cc2500.ino +++ b/Multiprotocol/FrSkyX_cc2500.ino @@ -276,6 +276,8 @@ static void __attribute__((unused)) FrSkyX_build_packet() uint16_t ReadFrSkyX() { + static bool transmit=true; + switch(state) { default: @@ -300,38 +302,55 @@ uint16_t ReadFrSkyX() case FRSKY_DATA1: 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 ; } - CC2500_SetTxRxMode(TX_EN); FrSkyX_set_start(hopping_frequency_no); - CC2500_SetPower(); + 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_Strobe(CC2500_SFRX); hopping_frequency_no = (hopping_frequency_no+FrSkyX_chanskip)%47; CC2500_Strobe(CC2500_SIDLE); - CC2500_WriteData(packet, packet[0]+1); - state++; + if(transmit) + CC2500_WriteData(packet, packet[0]+1); + state=FRSKY_DATA4; return 5200; - case FRSKY_DATA2: + case FRSKY_DATA4: CC2500_SetTxRxMode(RX_EN); CC2500_Strobe(CC2500_SIDLE); state++; return 200; - case FRSKY_DATA3: + case FRSKY_DATA5: CC2500_Strobe(CC2500_SRX); state++; return 3100; - case FRSKY_DATA4: + case FRSKY_DATA6: telemetry_set_input_sync(9000); 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; CC2500_ReadData(packet_in, len); #if defined TELEMETRY - frsky_check_telemetry(packet_in,len); //check if valid telemetry packets - //parse telemetry packets here - //The same telemetry function used by FrSky(D8). + frsky_check_telemetry(packet_in,len); //Check and parse telemetry packets #endif } else @@ -355,7 +374,11 @@ uint16_t ReadFrSkyX() } FrSkyX_build_packet(); state = FRSKY_DATA1; +#ifdef FRSKYX_LBT + return 270; +#else return 500; +#endif } return 1; } diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 2c71f06..e65312a 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 0 -#define VERSION_PATCH_LEVEL 23 +#define VERSION_PATCH_LEVEL 24 //****************** // Protocols diff --git a/Multiprotocol/_Config.h b/Multiprotocol/_Config.h index c0346b1..7fa5ea3 100644 --- a/Multiprotocol/_Config.h +++ b/Multiprotocol/_Config.h @@ -222,6 +222,12 @@ /*** 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 //--------------------- //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 //Send to OpenTX the current protocol and subprotocol names. Comment to disable. #define MULTI_NAMES -//Sync OpenTX frames with the current protocol timing. This feature is only available on the STM32 module. Comment to disable. -#define MULTI_SYNC +//Sync OpenTX frames with the current protocol timing. This feature is only available on the STM32 module. Uncomment to enable. +//!!!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 #define DSM_TELEMETRY // Forward received telemetry packet directly to TX to be decoded by er9x, erskyTX and OpenTX