mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-13 02:07:53 +00:00
Send spectrum data by packets of 5 channels
This commit is contained in:
parent
57a90c2f56
commit
f864e61c67
@ -888,4 +888,8 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
|
|||||||
data[3-7] telemetry data
|
data[3-7] telemetry data
|
||||||
Full description at the bottom of Hitec_cc2500.ino
|
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
|
||||||
*/
|
*/
|
||||||
|
@ -17,17 +17,13 @@
|
|||||||
|
|
||||||
#include "iface_cc2500.h"
|
#include "iface_cc2500.h"
|
||||||
|
|
||||||
struct Scanner {
|
#define SCAN_MAX_RADIOCHANNEL 249 // 2483 MHz
|
||||||
uint8_t chan_min;
|
#define SCAN_CHANNEL_LOCK_TIME 300 // with precalibration, channel requires only 90 usec for synthesizer to settle
|
||||||
uint8_t chan_max;
|
#define SCAN_CHANS_PER_PACKET 5
|
||||||
} Scanner;
|
|
||||||
|
|
||||||
#define MIN_RADIOCHANNEL 0x00
|
|
||||||
#define MAX_RADIOCHANNEL 255
|
|
||||||
#define CHANNEL_LOCK_TIME 300 // with precalibration, channel requires only 90 usec for synthesizer to settle
|
|
||||||
#define INTERNAL_AVERAGE 6
|
|
||||||
#define AVERAGE_INTVL 30
|
#define AVERAGE_INTVL 30
|
||||||
|
|
||||||
|
static uint8_t scan_tlm_index;
|
||||||
|
|
||||||
enum ScanStates {
|
enum ScanStates {
|
||||||
SCAN_CHANNEL_CHANGE = 0,
|
SCAN_CHANNEL_CHANGE = 0,
|
||||||
SCAN_GET_RSSI = 1,
|
SCAN_GET_RSSI = 1,
|
||||||
@ -65,7 +61,7 @@ static void __attribute__((unused)) Scanner_cc2500_init()
|
|||||||
|
|
||||||
static void __attribute__((unused)) Scanner_calibrate()
|
static void __attribute__((unused)) Scanner_calibrate()
|
||||||
{
|
{
|
||||||
for (int c = 0; c < MAX_RADIOCHANNEL; c++) {
|
for (int c = 0; c < SCAN_MAX_RADIOCHANNEL; c++) {
|
||||||
CC2500_Strobe(CC2500_SIDLE);
|
CC2500_Strobe(CC2500_SIDLE);
|
||||||
CC2500_WriteReg(CC2500_0A_CHANNR, c);
|
CC2500_WriteReg(CC2500_0A_CHANNR, c);
|
||||||
CC2500_Strobe(CC2500_SCAL);
|
CC2500_Strobe(CC2500_SCAL);
|
||||||
@ -77,7 +73,7 @@ static void __attribute__((unused)) Scanner_calibrate()
|
|||||||
|
|
||||||
static void __attribute__((unused)) Scanner_scan_next()
|
static void __attribute__((unused)) Scanner_scan_next()
|
||||||
{
|
{
|
||||||
CC2500_WriteReg(CC2500_0A_CHANNR, Scanner.chan_min + rf_ch_num);
|
CC2500_WriteReg(CC2500_0A_CHANNR, rf_ch_num);
|
||||||
CC2500_WriteReg(CC2500_25_FSCAL1, calData[rf_ch_num]);
|
CC2500_WriteReg(CC2500_25_FSCAL1, calData[rf_ch_num]);
|
||||||
CC2500_Strobe(CC2500_SFRX);
|
CC2500_Strobe(CC2500_SFRX);
|
||||||
CC2500_Strobe(CC2500_SRX);
|
CC2500_Strobe(CC2500_SRX);
|
||||||
@ -103,27 +99,29 @@ uint16 Scanner_callback()
|
|||||||
switch (phase) {
|
switch (phase) {
|
||||||
case SCAN_CHANNEL_CHANGE:
|
case SCAN_CHANNEL_CHANGE:
|
||||||
rf_ch_num++;
|
rf_ch_num++;
|
||||||
if (rf_ch_num >= (Scanner.chan_max - Scanner.chan_min + 1))
|
if (rf_ch_num >= (SCAN_MAX_RADIOCHANNEL + 1))
|
||||||
rf_ch_num = 0;
|
rf_ch_num = 0;
|
||||||
|
if (scan_tlm_index++ == 0)
|
||||||
|
pkt[0] = rf_ch_num; // start channel for telemetry packet
|
||||||
Scanner_scan_next();
|
Scanner_scan_next();
|
||||||
phase = SCAN_GET_RSSI;
|
phase = SCAN_GET_RSSI;
|
||||||
return CHANNEL_LOCK_TIME;
|
return SCAN_CHANNEL_LOCK_TIME;
|
||||||
case SCAN_GET_RSSI:
|
case SCAN_GET_RSSI:
|
||||||
rssi_value = Scanner_scan_rssi();
|
|
||||||
phase = SCAN_CHANNEL_CHANGE;
|
phase = SCAN_CHANNEL_CHANGE;
|
||||||
// send data to TX
|
pkt[scan_tlm_index] = Scanner_scan_rssi();
|
||||||
pkt[0] = rf_ch_num;
|
if (scan_tlm_index == SCAN_CHANS_PER_PACKET) {
|
||||||
pkt[1] = rssi_value;
|
// send data to TX
|
||||||
telemetry_link = 1;
|
telemetry_link = 1;
|
||||||
|
scan_tlm_index = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return AVERAGE_INTVL;
|
return AVERAGE_INTVL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t initScanner(void)
|
uint16_t initScanner(void)
|
||||||
{
|
{
|
||||||
Scanner.chan_min = 0; // 2400 MHz
|
rf_ch_num = SCAN_MAX_RADIOCHANNEL;
|
||||||
Scanner.chan_max = 249; // 2483 Mhz
|
scan_tlm_index = 0;
|
||||||
rf_ch_num = 0;
|
|
||||||
phase = SCAN_CHANNEL_CHANGE;
|
phase = SCAN_CHANNEL_CHANGE;
|
||||||
CC2500_Reset();
|
CC2500_Reset();
|
||||||
Scanner_cc2500_init();
|
Scanner_cc2500_init();
|
||||||
|
@ -174,12 +174,13 @@ static void multi_send_status()
|
|||||||
void spectrum_scanner_frame()
|
void spectrum_scanner_frame()
|
||||||
{
|
{
|
||||||
#if defined MULTI_TELEMETRY
|
#if defined MULTI_TELEMETRY
|
||||||
multi_send_header(MULTI_TELEMETRY_SCANNER, 2);
|
multi_send_header(MULTI_TELEMETRY_SCANNER, SCAN_CHANS_PER_PACKET + 1);
|
||||||
#else
|
#else
|
||||||
Serial_write(0xAA); // Telemetry packet
|
Serial_write(0xAA); // Telemetry packet
|
||||||
#endif
|
#endif
|
||||||
Serial_write(pkt[0]); // frequency (channel)
|
Serial_write(pkt[0]); // start channel
|
||||||
Serial_write(pkt[1]); // RSSI power level
|
for(uint8_t ch = 0; ch < SCAN_CHANS_PER_PACKET; ch++)
|
||||||
|
Serial_write(pkt[ch+1]); // RSSI power levels
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user