mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-04 16:28:10 +00:00
Scanner 2.4GHz
Thanks to Goebish for this spectrum analyzer. It will work soon with the OpenTX 2.3 Spectrum Analyser tool.
This commit is contained in:
parent
6a74b83f98
commit
7d327c1622
@ -51,4 +51,5 @@
|
||||
51,Potensic,A20
|
||||
52,ZSX,280
|
||||
53,Flyzone,FZ-410
|
||||
54,Scanner
|
||||
63,XN_DUMP,250K,1M,2M
|
||||
|
@ -19,7 +19,7 @@
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_REVISION 1
|
||||
#define VERSION_PATCH_LEVEL 74
|
||||
#define VERSION_PATCH_LEVEL 75
|
||||
|
||||
//******************
|
||||
// Protocols
|
||||
@ -80,6 +80,7 @@ enum PROTOCOLS
|
||||
PROTO_POTENSIC = 51, // =>NRF24L01
|
||||
PROTO_ZSX = 52, // =>NRF24L01
|
||||
PROTO_FLYZONE = 53, // =>A7105
|
||||
PROTO_SCANNER = 54, // =>CC2500
|
||||
PROTO_XN297DUMP = 63, // =>NRF24L01
|
||||
};
|
||||
|
||||
@ -318,6 +319,7 @@ enum MultiPacketTypes
|
||||
MULTI_TELEMETRY_SYNC = 8,
|
||||
MULTI_TELEMETRY_SPORT_POLLING = 9,
|
||||
MULTI_TELEMETRY_HITEC = 10,
|
||||
MULTI_TELEMETRY_SCANNER = 11,
|
||||
};
|
||||
|
||||
// Macros
|
||||
@ -636,6 +638,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
|
||||
POTENSIC 51
|
||||
ZSX 52
|
||||
FLYZONE 53
|
||||
SCANNER 54
|
||||
BindBit=> 0x80 1=Bind/0=No
|
||||
AutoBindBit=> 0x40 1=Yes /0=No
|
||||
RangeCheck=> 0x20 1=Yes /0=No
|
||||
@ -885,4 +888,8 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
|
||||
data[3-7] telemetry data
|
||||
Full description at the bottom of Hitec_cc2500.ino
|
||||
|
||||
Type 0x0B Spectrum Scanner telemetry data
|
||||
length: 6
|
||||
data[0] = start channel (2400 + x*0.333 Mhz)
|
||||
data[1-5] power levels
|
||||
*/
|
||||
|
@ -114,7 +114,12 @@ uint8_t armed, arm_flags, arm_channel_previous;
|
||||
uint8_t num_ch;
|
||||
|
||||
#ifdef CC2500_INSTALLED
|
||||
uint8_t calData[50];
|
||||
#ifdef SCANNER_CC2500_INO
|
||||
uint8_t calData[255];
|
||||
#define SCAN_CHANS_PER_PACKET 5
|
||||
#else
|
||||
uint8_t calData[50];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CHECK_FOR_BOOTLOADER
|
||||
@ -643,7 +648,7 @@ uint8_t Update_All()
|
||||
update_led_status();
|
||||
#if defined(TELEMETRY)
|
||||
#if ( !( defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) ) )
|
||||
if( (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))
|
||||
if( (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
|
||||
TelemetryUpdate();
|
||||
#endif
|
||||
@ -1016,6 +1021,14 @@ static void protocol_init()
|
||||
remote_callback = ReadHITEC;
|
||||
break;
|
||||
#endif
|
||||
#if defined(SCANNER_CC2500_INO)
|
||||
case PROTO_SCANNER:
|
||||
PE1_off;
|
||||
PE2_on; //antenna RF2
|
||||
next_callback = initScanner();
|
||||
remote_callback = Scanner_callback;
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CYRF6936_INSTALLED
|
||||
#if defined(DSM_CYRF6936_INO)
|
||||
|
136
Multiprotocol/Scanner_cc2500.ino
Normal file
136
Multiprotocol/Scanner_cc2500.ino
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
This project is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Multiprotocol is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(SCANNER_CC2500_INO)
|
||||
|
||||
#include "iface_cc2500.h"
|
||||
|
||||
#define SCAN_MAX_RADIOCHANNEL 249 // 2483 MHz
|
||||
#define SCAN_CHANNEL_LOCK_TIME 300 // with precalibration, channel requires only 90 usec for synthesizer to settle
|
||||
#define SCAN_AVERAGE_INTVL 30
|
||||
|
||||
static uint8_t scan_tlm_index;
|
||||
|
||||
enum ScanStates {
|
||||
SCAN_CHANNEL_CHANGE = 0,
|
||||
SCAN_GET_RSSI = 1,
|
||||
};
|
||||
|
||||
static void __attribute__((unused)) Scanner_cc2500_init()
|
||||
{
|
||||
/* Initialize CC2500 chip */
|
||||
CC2500_WriteReg(CC2500_08_PKTCTRL0, 0x12); // Packet Automation Control
|
||||
CC2500_WriteReg(CC2500_0B_FSCTRL1, 0x0A); // Frequency Synthesizer Control
|
||||
CC2500_WriteReg(CC2500_0C_FSCTRL0, 0x00); // Frequency Synthesizer Control
|
||||
CC2500_WriteReg(CC2500_0D_FREQ2, 0x5C); // Frequency Control Word, High Byte
|
||||
CC2500_WriteReg(CC2500_0E_FREQ1, 0x4E); // Frequency Control Word, Middle Byte
|
||||
CC2500_WriteReg(CC2500_0F_FREQ0, 0xC3); // Frequency Control Word, Low Byte
|
||||
CC2500_WriteReg(CC2500_10_MDMCFG4, 0x8D); // Modem Configuration
|
||||
CC2500_WriteReg(CC2500_11_MDMCFG3, 0x3B); // Modem Configuration
|
||||
CC2500_WriteReg(CC2500_12_MDMCFG2, 0x10); // Modem Configuration
|
||||
CC2500_WriteReg(CC2500_13_MDMCFG1, 0x23); // Modem Configuration
|
||||
CC2500_WriteReg(CC2500_14_MDMCFG0, 0xA4); // Modem Configuration
|
||||
CC2500_WriteReg(CC2500_15_DEVIATN, 0x62); // Modem Deviation Setting
|
||||
CC2500_WriteReg(CC2500_18_MCSM0, 0x08); // Main Radio Control State Machine Configuration
|
||||
CC2500_WriteReg(CC2500_19_FOCCFG, 0x1D); // Frequency Offset Compensation Configuration
|
||||
CC2500_WriteReg(CC2500_1A_BSCFG, 0x1C); // Bit Synchronization Configuration
|
||||
CC2500_WriteReg(CC2500_1B_AGCCTRL2, 0xC7); // AGC Control
|
||||
CC2500_WriteReg(CC2500_1C_AGCCTRL1, 0x00); // AGC Control
|
||||
CC2500_WriteReg(CC2500_1D_AGCCTRL0, 0xB0); // AGC Control
|
||||
CC2500_WriteReg(CC2500_21_FREND1, 0xB6); // Front End RX Configuration
|
||||
|
||||
CC2500_SetTxRxMode(RX_EN); // Receive mode
|
||||
CC2500_Strobe(CC2500_SIDLE);
|
||||
CC2500_Strobe(CC2500_SRX);
|
||||
|
||||
delayMicroseconds(1000); // wait for RX to activate
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) Scanner_calibrate()
|
||||
{
|
||||
for (uint8_t c = 0; c < SCAN_MAX_RADIOCHANNEL; c++)
|
||||
{
|
||||
CC2500_Strobe(CC2500_SIDLE);
|
||||
CC2500_WriteReg(CC2500_0A_CHANNR, c);
|
||||
CC2500_Strobe(CC2500_SCAL);
|
||||
delayMicroseconds(900);
|
||||
calData[c] = CC2500_ReadReg(CC2500_25_FSCAL1);
|
||||
}
|
||||
CC2500_Strobe(CC2500_SIDLE);
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) Scanner_scan_next()
|
||||
{
|
||||
CC2500_WriteReg(CC2500_0A_CHANNR, rf_ch_num);
|
||||
CC2500_WriteReg(CC2500_25_FSCAL1, calData[rf_ch_num]);
|
||||
CC2500_Strobe(CC2500_SFRX);
|
||||
CC2500_Strobe(CC2500_SRX);
|
||||
}
|
||||
|
||||
static int __attribute__((unused)) Scanner_scan_rssi()
|
||||
{
|
||||
uint8_t rssi;
|
||||
rssi = CC2500_ReadReg(0x40 | CC2500_34_RSSI); // 0.5 db/count, RSSI value read from the RSSI status register is a 2's complement number
|
||||
uint8_t rssi_rel;
|
||||
if (rssi >= 128) {
|
||||
rssi_rel = rssi - 128; // relative power levels 0-127 (equals -137 to -72 dBm)
|
||||
}
|
||||
else {
|
||||
rssi_rel = rssi + 128; // relativ power levels 128-255 (equals -73 to -10 dBm)
|
||||
}
|
||||
return rssi_rel;
|
||||
}
|
||||
|
||||
uint16_t Scanner_callback()
|
||||
{
|
||||
switch (phase)
|
||||
{
|
||||
case SCAN_CHANNEL_CHANGE:
|
||||
rf_ch_num++;
|
||||
if (rf_ch_num >= (SCAN_MAX_RADIOCHANNEL + 1))
|
||||
rf_ch_num = 0;
|
||||
if (scan_tlm_index++ == 0)
|
||||
pkt[0] = rf_ch_num; // start channel for telemetry packet
|
||||
Scanner_scan_next();
|
||||
phase = SCAN_GET_RSSI;
|
||||
return SCAN_CHANNEL_LOCK_TIME;
|
||||
case SCAN_GET_RSSI:
|
||||
phase = SCAN_CHANNEL_CHANGE;
|
||||
pkt[scan_tlm_index] = Scanner_scan_rssi();
|
||||
if (scan_tlm_index == SCAN_CHANS_PER_PACKET)
|
||||
{
|
||||
// send data to TX
|
||||
telemetry_link = 1;
|
||||
scan_tlm_index = 0;
|
||||
}
|
||||
}
|
||||
return SCAN_AVERAGE_INTVL;
|
||||
}
|
||||
|
||||
uint16_t initScanner(void)
|
||||
{
|
||||
rf_ch_num = SCAN_MAX_RADIOCHANNEL;
|
||||
scan_tlm_index = 0;
|
||||
phase = SCAN_CHANNEL_CHANGE;
|
||||
Scanner_cc2500_init();
|
||||
CC2500_Strobe(CC2500_SRX);
|
||||
Scanner_calibrate();
|
||||
CC2500_Strobe(CC2500_SIDLE);
|
||||
CC2500_SetTxRxMode(RX_EN);
|
||||
CC2500_Strobe(CC2500_SRX); // Receive mode
|
||||
return 1250;
|
||||
}
|
||||
|
||||
#endif
|
@ -170,6 +170,20 @@ static void multi_send_status()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef SCANNER_TELEMETRY
|
||||
void spectrum_scanner_frame()
|
||||
{
|
||||
#if defined MULTI_TELEMETRY
|
||||
multi_send_header(MULTI_TELEMETRY_SCANNER, SCAN_CHANS_PER_PACKET + 1);
|
||||
#else
|
||||
Serial_write(0xAA); // Telemetry packet
|
||||
#endif
|
||||
Serial_write(pkt[0]); // start channel
|
||||
for(uint8_t ch = 0; ch < SCAN_CHANS_PER_PACKET; ch++)
|
||||
Serial_write(pkt[ch+1]); // RSSI power levels
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef AFHDS2A_FW_TELEMETRY
|
||||
void AFHDSA_short_frame()
|
||||
{
|
||||
@ -996,6 +1010,15 @@ void TelemetryUpdate()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined SCANNER_TELEMETRY
|
||||
if (telemetry_link && protocol == PROTO_SCANNER)
|
||||
{
|
||||
spectrum_scanner_frame();
|
||||
telemetry_link = 0;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if((telemetry_link & 1 )&& protocol != PROTO_FRSKYX)
|
||||
{ // FrSkyD + Hubsan + AFHDS2A + Bayang + Cabell + Hitec + Bugs + BugsMini + NCC1701
|
||||
frsky_link_frame();
|
||||
|
@ -192,6 +192,7 @@
|
||||
#undef REDPINE_CC2500_INO
|
||||
#undef HITEC_CC2500_INO
|
||||
#undef XN297L_CC2500_EMU
|
||||
#undef SCANNER_CC2500_INO
|
||||
#endif
|
||||
#ifndef NRF24L01_INSTALLED
|
||||
#undef BAYANG_NRF24L01_INO
|
||||
@ -248,6 +249,7 @@
|
||||
#undef DSM_TELEMETRY
|
||||
#undef MULTI_STATUS
|
||||
#undef MULTI_TELEMETRY
|
||||
#undef SCANNER_TELEMETRY
|
||||
#else
|
||||
#if defined MULTI_TELEMETRY && not defined INVERT_TELEMETRY
|
||||
#warning MULTI_TELEMETRY has been defined but not INVERT_TELEMETRY. They should be both enabled for OpenTX telemetry and status to work.
|
||||
@ -291,7 +293,7 @@
|
||||
#if not defined(DSM_CYRF6936_INO)
|
||||
#undef DSM_TELEMETRY
|
||||
#endif
|
||||
#if not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(NCC1701_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY)
|
||||
#if not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(NCC1701_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY) && not defined(SCANNER_TELEMETRY)
|
||||
#undef TELEMETRY
|
||||
#undef INVERT_TELEMETRY
|
||||
#undef SPORT_POLLING
|
||||
|
@ -165,7 +165,7 @@
|
||||
#define DEVO_CYRF6936_INO
|
||||
#define DSM_CYRF6936_INO
|
||||
#define J6PRO_CYRF6936_INO
|
||||
#define TRAXXAS_CYRF6936_INO
|
||||
#define TRAXXAS_CYRF6936_INO
|
||||
#define WFLY_CYRF6936_INO
|
||||
#define WK2x01_CYRF6936_INO
|
||||
|
||||
@ -175,6 +175,7 @@
|
||||
#define FRSKYV_CC2500_INO
|
||||
#define FRSKYX_CC2500_INO
|
||||
#define HITEC_CC2500_INO
|
||||
#define SCANNER_CC2500_INO
|
||||
#define SFHSS_CC2500_INO
|
||||
#define REDPINE_CC2500_INO
|
||||
|
||||
@ -294,6 +295,7 @@
|
||||
#define CABELL_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||
#define HITEC_HUB_TELEMETRY // Use FrSkyD Hub format to send basic telemetry to the radios which can decode it like er9x, ersky9x and OpenTX
|
||||
#define HITEC_FW_TELEMETRY // Under development: Forward received telemetry packets to be decoded by ersky9x and OpenTX
|
||||
#define SCANNER_TELEMETRY // Forward spectrum scanner data to TX
|
||||
|
||||
//SPORT_POLLING is an implementation of the same polling routine as XJT module for sport telemetry bidirectional communication.
|
||||
//This is useful for passing sport control frames from TX to RX(ex: changing Betaflight PID or VTX channels on the fly using LUA scripts with OpentX).
|
||||
@ -611,6 +613,8 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
|
||||
PROTO_REDPINE
|
||||
RED_FAST
|
||||
RED_SLOW
|
||||
PROTO_SCANNER
|
||||
NONE
|
||||
PROTO_SFHSS
|
||||
NONE
|
||||
PROTO_SHENQI
|
||||
|
@ -108,6 +108,7 @@ CFlie|38|CFlie||||||||NRF24L01|
|
||||
[Q2X2](Protocols_Details.md#Q2X2---29)|29|Q222|Q242|Q282||||||NRF24L01|
|
||||
[Q303](Protocols_Details.md#Q303---31)|31|Q303|CX35|CX10D|CX10WD|||||NRF24L01|XN297
|
||||
[Redpine](Protocols_Details.md#Redpine---50)|50|FAST|SLOW|||||||NRF24L01|
|
||||
[Scanner](Protocols_Details.md#Scanner---54)|54|||||||||CC2500|
|
||||
[SFHSS](Protocols_Details.md#SFHSS---21)|21|SFHSS||||||||CC2500|
|
||||
[Shenqi](Protocols_Details.md#Shenqi---19)|19|Shenqi||||||||NRF24L01|LT8900
|
||||
[SLT](Protocols_Details.md#SLT---11)|11|SLT_V1|SLT_V2|Q100|Q200|MR100||||NRF24L01|
|
||||
@ -381,6 +382,9 @@ CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8
|
||||
---|---|---|---|---|---|---|---
|
||||
A|E|T|R|CH5|CH6|CH7|CH8
|
||||
|
||||
## Scanner - *54*
|
||||
2.4GHz scanner accessible using the OpenTX 2.3 Spectrum Analyser tool.
|
||||
|
||||
***
|
||||
# CYRF6936 RF Module
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user