mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-01 01:57:52 +00:00
Scanner in blocking mode for best perf
This commit is contained in:
parent
b07b081a15
commit
2686cd0c48
@ -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 40
|
#define VERSION_PATCH_LEVEL 41
|
||||||
|
|
||||||
//******************
|
//******************
|
||||||
// Protocols
|
// Protocols
|
||||||
|
@ -18,13 +18,11 @@
|
|||||||
#include "iface_cc2500.h"
|
#include "iface_cc2500.h"
|
||||||
|
|
||||||
#define SCAN_MAX_RADIOCHANNEL 249 // 2483 MHz
|
#define SCAN_MAX_RADIOCHANNEL 249 // 2483 MHz
|
||||||
#define SCAN_CHANNEL_LOCK_TIME 210 // with precalibration, channel requires only 90 usec for synthesizer to settle
|
#define SCAN_CHANNEL_LOCK_TIME 90 // with precalibration, channel requires only 90 usec for synthesizer to settle
|
||||||
#define SCAN_AVERAGE_INTVL 20
|
#define SCAN_AVERAGE_INTVL 20
|
||||||
#define SCAN_MAX_COUNT 10
|
#define SCAN_MAX_COUNT 10
|
||||||
#define SCAN_CHANS_PER_PACKET 5
|
#define SCAN_CHANS_PER_PACKET 5
|
||||||
|
|
||||||
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,
|
||||||
@ -97,49 +95,46 @@ static int __attribute__((unused)) Scanner_scan_rssi()
|
|||||||
|
|
||||||
uint16_t Scanner_callback()
|
uint16_t Scanner_callback()
|
||||||
{
|
{
|
||||||
static uint8_t max_count, max_rssi;
|
uint8_t rssi,max_rssi;
|
||||||
uint8_t rssi;
|
|
||||||
switch (phase)
|
//!!!Blocking mode protocol!!!
|
||||||
{
|
TX_MAIN_PAUSE_off;
|
||||||
case SCAN_CHANNEL_CHANGE:
|
tx_resume();
|
||||||
if(telemetry_link == 0) {
|
while(1)
|
||||||
max_count = 0;
|
{ //Start
|
||||||
max_rssi = 0;
|
packet_in[0] = rf_ch_num; // start channel for telemetry packet
|
||||||
rf_ch_num++;
|
for(uint8_t i=0;i<SCAN_CHANS_PER_PACKET;i++)
|
||||||
if (rf_ch_num >= (SCAN_MAX_RADIOCHANNEL + 1))
|
{
|
||||||
rf_ch_num = 0;
|
Scanner_scan_next(); // set channel
|
||||||
if (scan_tlm_index++ == 0)
|
delayMicroseconds(SCAN_CHANNEL_LOCK_TIME); // wait for freq to adjust
|
||||||
packet_in[0] = rf_ch_num; // start channel for telemetry packet
|
max_rssi = 0;
|
||||||
Scanner_scan_next();
|
for(uint8_t j=0;j<SCAN_MAX_COUNT;j++)
|
||||||
phase = SCAN_GET_RSSI;
|
{
|
||||||
}
|
rssi = Scanner_scan_rssi();
|
||||||
return SCAN_CHANNEL_LOCK_TIME;
|
if(rssi >= max_rssi) max_rssi = rssi;
|
||||||
case SCAN_GET_RSSI:
|
delayMicroseconds(SCAN_AVERAGE_INTVL); // wait before next read
|
||||||
rssi = Scanner_scan_rssi();
|
|
||||||
if(rssi >= max_rssi) {
|
|
||||||
max_rssi = rssi;
|
|
||||||
packet_in[scan_tlm_index] = rssi;
|
|
||||||
}
|
|
||||||
max_count++;
|
|
||||||
if(max_count > SCAN_MAX_COUNT) {
|
|
||||||
phase = SCAN_CHANNEL_CHANGE;
|
|
||||||
if (scan_tlm_index == SCAN_CHANS_PER_PACKET)
|
|
||||||
{
|
|
||||||
// send data to TX
|
|
||||||
telemetry_link = 1;
|
|
||||||
scan_tlm_index = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
packet_in[i+1] = max_rssi;
|
||||||
|
//next channel
|
||||||
|
rf_ch_num++;
|
||||||
|
if (rf_ch_num >= (SCAN_MAX_RADIOCHANNEL + 1))
|
||||||
|
rf_ch_num = 0;
|
||||||
|
}
|
||||||
|
telemetry_link = 1;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if(Update_All())
|
||||||
|
return 1000; // protocol has changed, give back the control to main
|
||||||
|
}
|
||||||
|
while(telemetry_link == 1);
|
||||||
}
|
}
|
||||||
return SCAN_AVERAGE_INTVL;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t initScanner(void)
|
uint16_t initScanner(void)
|
||||||
{
|
{
|
||||||
rf_ch_num = SCAN_MAX_RADIOCHANNEL;
|
rf_ch_num = 0;
|
||||||
scan_tlm_index = 0;
|
|
||||||
telemetry_link = 0;
|
telemetry_link = 0;
|
||||||
phase = SCAN_CHANNEL_CHANGE;
|
|
||||||
Scanner_cc2500_init();
|
Scanner_cc2500_init();
|
||||||
CC2500_Strobe(CC2500_SRX);
|
CC2500_Strobe(CC2500_SRX);
|
||||||
Scanner_calibrate();
|
Scanner_calibrate();
|
||||||
|
@ -836,7 +836,7 @@ void TelemetryUpdate()
|
|||||||
t -= h ;
|
t -= h ;
|
||||||
if ( t < 32 )
|
if ( t < 32 )
|
||||||
{
|
{
|
||||||
//debugln("TEL_BUF_FULL %d",t);
|
debugln("TEL_BUF_FULL %d",t);
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
/* else
|
/* else
|
||||||
@ -846,7 +846,7 @@ void TelemetryUpdate()
|
|||||||
#endif
|
#endif
|
||||||
#if defined(MULTI_TELEMETRY) || defined(MULTI_STATUS)
|
#if defined(MULTI_TELEMETRY) || defined(MULTI_STATUS)
|
||||||
uint32_t now = millis();
|
uint32_t now = millis();
|
||||||
if (IS_SEND_MULTI_STATUS_on || ((now - lastMulti) > MULTI_TIME))
|
if ((IS_SEND_MULTI_STATUS_on || ((now - lastMulti) > MULTI_TIME))&& protocol != PROTO_SCANNER)
|
||||||
{
|
{
|
||||||
multi_send_status();
|
multi_send_status();
|
||||||
SEND_MULTI_STATUS_off;
|
SEND_MULTI_STATUS_off;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user