Merge branch 'DiSlord_test_branch'

pull/4/head
erikkaashoek 6 years ago
commit ac01195637

@ -2452,6 +2452,7 @@ static void VNAShell_executeLine(char *line)
if (strcmp(scp->sc_name, shell_args[0]) == 0) {
if (scp->flags & CMD_WAIT_MUTEX) {
shell_function = scp->sc_function;
operation_requested|=OP_CONSOLE;
// Wait execute command in sweep thread
do {
osalThreadSleepMilliseconds(100);

@ -863,7 +863,7 @@ byte SI4432_Read_Byte( byte ADR );
void SI4432_Init(void);
void SI4432_Drive(int);
float SI4432_RSSI(uint32_t i, int s);
int16_t SI4432_RSSI(uint32_t i, int s);
#ifdef __FAST_SWEEP__
void SI4432_Fill(int s, int start);
#if 0

@ -1515,56 +1515,64 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M
else
signal_path_loss = +7; // Loss in dB (+ is gain)
#define T_LEVEL_UNDEF (1<<(16-2)) // should drop after 2 shifts left
#define T_LEVEL_BELOW 1
#define T_LEVEL_ABOVE 0
#define T_LEVEL_CLEAN ~(1<<2) // cleanup old trigger data
uint16_t data_level = T_LEVEL_UNDEF;
int wait_for_trigger = false;
int old_SI4432_step_delay = SI4432_step_delay;
if (i == 0 && setting.frequency_step == 0 && setting.trigger != T_AUTO) { // if in zero span mode and wait for trigger to happen and NOT in trigger mode
wait_for_trigger = true; // signal the wait for trigger
SI4432_step_delay = 0;
}
float subRSSI;
static float correct_RSSI; // This is re-used between calls
if (i == 0 || setting.frequency_step != 0 ) // only cases where the value can change
correct_RSSI = get_level_offset()+ get_attenuation() - signal_path_loss - setting.offset + get_frequency_correction(f); // calcuate the RSSI correction for later use
// Cache trigger search mode
register uint16_t t_mode;
if (setting.trigger_direction == T_UP)
t_mode = (T_LEVEL_BELOW<<1)|T_LEVEL_ABOVE; // from bottom to up
else
t_mode = (T_LEVEL_ABOVE<<1)|T_LEVEL_BELOW; // from up to bottom
wait:
if (i == 0 && t == 0) // if first point in scan (here is get 1 point data)
correct_RSSI = get_level_offset()
+ get_attenuation()
- signal_path_loss
- setting.offset
+ get_frequency_correction(f)
+ getSI4432_RSSI_correction(); // calcuate the RSSI correction for later use
if (i == 0 && t == 0) // if first point in scan (here is get 1 point data)
start_of_sweep_timestamp = chVTGetSystemTimeX(); // initialize start sweep time
int16_t pureRSSI;
// if ( i < 3)
// shell_printf("%d %.3f %.3f %.1f\r\n", i, local_IF/1000000.0, lf/1000000.0, subRSSI);
subRSSI = SI4432_RSSI(lf, MODE_SELECT(setting.mode)) + correct_RSSI ; // Get RSSI, either from pre-filled buffer or by reading SI4432 RSSI
// if ( i < 3)
// shell_printf("%d %.3f %.3f %.1f\r\n", i, local_IF/1000000.0, lf/1000000.0, subRSSI);
if (wait_for_trigger) { // wait for trigger to happen
if ((operation_requested || shell_function) && break_on_operation) // allow aborting a wait for trigger
break; // abort
// ************** trigger mode if need
#define T_LEVEL_UNDEF (1<<(16-2)) // should drop after 2 shifts left
#define T_LEVEL_BELOW 1
#define T_LEVEL_ABOVE 0
#define T_LEVEL_CLEAN ~(1<<2) // cleanup old trigger data
// Store data level bitfield (remember only last 2 states)
// T_LEVEL_UNDEF mode bit drop after 2 shifts
data_level = ((data_level<<1) | (subRSSI < setting.trigger_level ? T_LEVEL_BELOW : T_LEVEL_ABOVE))&(T_LEVEL_CLEAN);
// wait trigger
if (data_level != t_mode) // trigger level change
goto wait; // get next rssi
if (i == 0 && setting.frequency_step == 0 && setting.trigger != T_AUTO) { // if in zero span mode and wait for trigger to happen and NOT in trigger mode
register uint16_t t_mode;
uint16_t trigger_lvl;
uint16_t data_level = T_LEVEL_UNDEF;
// Calculate trigger level
trigger_lvl = (setting.trigger_level - correct_RSSI) * 32;
if (setting.trigger_direction == T_UP)
t_mode = (T_LEVEL_BELOW<<1)|T_LEVEL_ABOVE; // from bottom to up
else
t_mode = (T_LEVEL_ABOVE<<1)|T_LEVEL_BELOW; // from up to bottom
do{ // wait for trigger to happen
pureRSSI = SI4432_Read_Byte(SI4432_REG_RSSI)<<4;
if (break_on_operation && operation_requested) // allow aborting a wait for trigger
break; // abort
// Store data level bitfield (remember only last 2 states)
// T_LEVEL_UNDEF mode bit drop after 2 shifts
data_level = ((data_level<<1) | (pureRSSI < trigger_lvl ? T_LEVEL_BELOW : T_LEVEL_ABOVE))&(T_LEVEL_CLEAN);
// wait trigger
}while(data_level != t_mode); // trigger level change
#ifdef __FAST_SWEEP__
if (setting.spur == 0 && old_SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) {
SI4432_Fill(MODE_SELECT(setting.mode), 1); // fast mode possible to pre-fill RSSI buffer
if (setting.spur == 0 && SI4432_step_delay == 0 && setting.repeat == 1 && setting.sweep_time_us < 100*ONE_MS_TIME) {
SI4432_Fill(MODE_SELECT(setting.mode), 1); // fast mode possible to pre-fill RSSI buffer
}
#endif
if (setting.trigger == T_SINGLE)
pause_sweep(); // Trigger once so pause after this sweep has completed!!!!!!!
start_of_sweep_timestamp = chVTGetSystemTimeX();
}
SI4432_step_delay = old_SI4432_step_delay;
else
pureRSSI = SI4432_RSSI(lf, MODE_SELECT(setting.mode)); // Get RSSI, either from pre-filled buffer
float subRSSI = pureRSSI / 32.0;
// add correction
subRSSI+=correct_RSSI;
#ifdef __SPUR__
if (setting.spur == 1) { // If first spur pass
spur_RSSI = subRSSI; // remember measure RSSI
@ -1579,7 +1587,7 @@ float perform(bool break_on_operation, int i, uint32_t f, int tracking) // M
if (RSSI < subRSSI) // Take max during subscanning
RSSI = subRSSI;
t++; // one subscan done
if ((operation_requested || shell_function ) && break_on_operation) // break subscanning if requested
if (break_on_operation && operation_requested) // break subscanning if requested
break; // abort
} while (t < vbwSteps); // till all sub steps done
return(RSSI);
@ -1677,7 +1685,7 @@ sweep_again: // stay in sweep loop when output mo
}
// if break back to top level to handle ui operation
if ((operation_requested || shell_function) && break_on_operation) { // break loop if needed
if (break_on_operation && operation_requested) { // break loop if needed
if (setting.actual_sweep_time_us > ONE_SECOND_TIME && MODE_INPUT(setting.mode)) {
ili9341_fill(OFFSETX, HEIGHT_NOSCROLL+1, WIDTH, 1, 0); // Erase progress bar
}

@ -437,7 +437,11 @@ void SI4432_Fill(int s, int start)
#define MINIMUM_WAIT_FOR_RSSI 280
int SI4432_offset_delay = 300;
float SI4432_RSSI(uint32_t i, int s)
float getSI4432_RSSI_correction(void){
return SI4432_RSSI_correction;
};
int16_t SI4432_RSSI(uint32_t i, int s)
{
(void) i;
int32_t RSSI_RAW;
@ -451,11 +455,9 @@ float SI4432_RSSI(uint32_t i, int s)
//START_PROFILE
#ifdef __FAST_SWEEP__
if (buf_read) {
float dBm = ((float)((unsigned char)age[buf_index++]))/2 + SI4432_RSSI_correction;
if (buf_index == sweep_points) {
if (buf_index == sweep_points-1)
buf_read = false;
}
return dBm;
return (unsigned char)age[buf_index++]<<4;
}
#endif
SI4432_Sel = s;
@ -475,24 +477,22 @@ float SI4432_RSSI(uint32_t i, int s)
// chThdSleepMicroseconds(SI4432_step_delay);
i = setting.repeat;
RSSI_RAW = 0;
again:
RSSI_RAW += ((unsigned int)SI4432_Read_Byte(SI4432_REG_RSSI)) << 4 ;
i--;
if (i > 0) {
do{
RSSI_RAW += ((unsigned int)SI4432_Read_Byte(SI4432_REG_RSSI))<<4;
if (--i == 0) break;
my_microsecond_delay(100);
goto again;
}
}while(1);
if (setting.repeat > 1)
RSSI_RAW = RSSI_RAW / setting.repeat;
// if (MODE_INPUT(setting.mode) && RSSI_RAW == 0)
// SI4432_Init();
float dBm = ((float)RSSI_RAW)/32.0 + SI4432_RSSI_correction;
#ifdef __SIMULATION__
dBm = Simulated_SI4432_RSSI(i,s);
RSSI_RAW = Simulated_SI4432_RSSI(i,s)<<4;
#endif
//STOP_PROFILE
// Serial.println(dBm,2);
return dBm ;
return RSSI_RAW;
}

@ -110,7 +110,8 @@ void SI4432_Write_Byte(byte ADR, byte DATA );
byte SI4432_Read_Byte( byte ADR );
void SI4432_Init(void);
float SI4432_RSSI(uint32_t i, int s);
float getSI4432_RSSI_correction(void);
int16_t SI4432_RSSI(uint32_t i, int s);
#ifdef __SIMULATION__
float Simulated_SI4432_RSSI(uint32_t i, int s);
#endif

Loading…
Cancel
Save

Powered by TurnKey Linux.