Merge branch 'tinySA-V4-SI4463' of https://github.com/erikkaashoek/tinySA into DiSlord_tinySA-V4

multi_trace
DiSlord 5 years ago
commit a4173f600c

@ -247,11 +247,9 @@ int shell_printf(const char *fmt, ...)
if (shell_stream == NULL) return 0; if (shell_stream == NULL) return 0;
va_list ap; va_list ap;
int formatted_bytes = 0; int formatted_bytes = 0;
if (shell_stream) {
va_start(ap, fmt); va_start(ap, fmt);
formatted_bytes = chvprintf(shell_stream, fmt, ap); formatted_bytes = chvprintf(shell_stream, fmt, ap);
va_end(ap); va_end(ap);
}
return formatted_bytes; return formatted_bytes;
} }

@ -305,7 +305,7 @@ void set_actual_power(float);
void SetGenerate(int); void SetGenerate(int);
void set_RBW(uint32_t rbw_x10); void set_RBW(uint32_t rbw_x10);
#ifdef __VBW__ #ifdef __VBW__
void set_VBW(uint32_t vbw_x10); void set_VBW(uint32_t vbw_x100);
#endif #endif
void set_lo_drive(int d); void set_lo_drive(int d);
void set_rx_drive(int d); void set_rx_drive(int d);
@ -991,7 +991,7 @@ typedef struct setting
freq_t slider_span; freq_t slider_span;
uint32_t rbw_x10; uint32_t rbw_x10;
uint32_t vbw_x10; uint32_t vbw_x100;
float reflevel; float reflevel;
float scale; float scale;

@ -240,13 +240,13 @@ void reset_settings(int m)
setting.step_delay = 0; setting.step_delay = 0;
setting.offset_delay = 0; setting.offset_delay = 0;
setting.step_delay_mode = SD_NORMAL; setting.step_delay_mode = SD_NORMAL;
setting.vbw_x10 = 0; // Auto mode setting.vbw_x100 = 0; // Auto mode
setting.repeat = 1;
setting.auto_reflevel = true; // Must be after SetReflevel setting.auto_reflevel = true; // Must be after SetReflevel
setting.decay=20; setting.decay=20;
setting.attack=1; setting.attack=1;
setting.noise=5; setting.noise=5;
setting.below_IF = S_AUTO_OFF; setting.below_IF = S_AUTO_OFF;
setting.repeat = 1;
setting.tracking_output = false; setting.tracking_output = false;
setting.measurement = M_OFF; setting.measurement = M_OFF;
#ifdef TINYSA4 #ifdef TINYSA4
@ -1028,9 +1028,13 @@ void set_RBW(uint32_t rbw_x10)
} }
#ifdef __VBW__ #ifdef __VBW__
void set_VBW(uint32_t vbw_x10) void set_VBW(uint32_t vbw_x100)
{ {
setting.vbw_x10 = vbw_x10; setting.vbw_x100 = vbw_x100;
if (vbw_x100 == 0)
setting.repeat = 1;
else
setting.repeat = vbw_x100;
dirty = true; dirty = true;
} }
#endif #endif
@ -2623,19 +2627,22 @@ int test_output_switch = false;
int test_output_drive = 0; int test_output_drive = 0;
int test_output_attenuate = 0; int test_output_attenuate = 0;
bool level_error = false; bool level_error = false;
static float old_temp = 0.0;
#endif #endif
pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) // Measure the RSSI for one frequency, used from sweep and other measurement routines. Must do all HW setup pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) // Measure the RSSI for one frequency, used from sweep and other measurement routines. Must do all HW setup
{ {
int modulation_delay = 0; int modulation_delay = 0;
int modulation_index = 0; int modulation_index = 0;
int modulation_count_iter = 0; int modulation_count_iter = 0;
int spur_second_pass = false; int spur_second_pass = false;
if (i == 0) {
#ifdef TINYSA4 #ifdef TINYSA4
if (i == 0 && old_temp != Si446x_get_temp()) {
old_temp = Si446x_get_temp();
calculate_static_correction(); // In case temperature changed. calculate_static_correction(); // In case temperature changed.
#endif
} }
#endif
if (i == 0 && dirty ) { // if first point in scan and dirty if (i == 0 && dirty ) { // if first point in scan and dirty
#ifdef __ADF4351__ #ifdef __ADF4351__
clear_frequency_cache(); clear_frequency_cache();
@ -2673,8 +2680,8 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
calculate_static_correction(); calculate_static_correction();
#ifdef __MCU_CLOCK_SHIFT__ #ifdef __MCU_CLOCK_SHIFT__
if (!in_selftest) clock_above_48MHz(); if (!in_selftest) clock_above_48MHz();
#endif
is_below = false; is_below = false;
#endif
correct_RSSI_freq = get_frequency_correction(f); // for i == 0 and freq_step == 0; correct_RSSI_freq = get_frequency_correction(f); // for i == 0 and freq_step == 0;
} else { } else {
#ifdef __MCU_CLOCK_SHIFT__ #ifdef __MCU_CLOCK_SHIFT__
@ -3852,7 +3859,7 @@ static bool sweep(bool break_on_operation)
// #ifdef __VBW__ // #ifdef __VBW__
#if 0 #if 0
#ifdef __FFT_VBW__ #ifdef __FFT_VBW__
if (setting.vbw_x10 != 0 && sweep_points == 256) { if (setting.vbw_x100 != 0 && sweep_points == 256) {
float m = 150; float m = 150;
for (int i=0;i<sweep_points;i++) { for (int i=0;i<sweep_points;i++) {
if (m > temp_t[i]) if (m > temp_t[i])
@ -3866,7 +3873,7 @@ static bool sweep(bool break_on_operation)
} }
FFT(real, imag, 256, false); FFT(real, imag, 256, false);
#if 1 #if 1
for (int i = 128 - setting.vbw_x10; i<128+setting.vbw_x10; i++) { for (int i = 128 - setting.vbw_x100; i<128+setting.vbw_x100; i++) {
real[i] = 0; real[i] = 0;
imag[i] = 0; imag[i] = 0;
} }
@ -3883,7 +3890,7 @@ static bool sweep(bool break_on_operation)
// ------------------------ do VBW processing ------------------------------ // ------------------------ do VBW processing ------------------------------
if (setting.frequency_step) { if (setting.frequency_step) {
int vbw_count_div2 = actual_rbw_x10 * 100 / setting.frequency_step / (setting.vbw_x10 == 0 ? 10 : setting.vbw_x10); int vbw_count_div2 = actual_rbw_x10 * 100 / setting.frequency_step / (setting.vbw_x100 == 0 ? 10 : setting.vbw_x100);
while(vbw_count_div2-- > 0){ while(vbw_count_div2-- > 0){
pureRSSI_t prev = temp_t[0]; pureRSSI_t prev = temp_t[0];
int j; int j;
@ -5667,7 +5674,7 @@ quit:
test_validate(TEST_SPUR); // Validate test test_validate(TEST_SPUR); // Validate test
} }
#ifdef TINYSA4 #ifdef TINYSA4
} else if (test == 7) { // RBW level test } else if (test == 7) { // RBW level test, param -1 keeps correction
in_selftest = true; in_selftest = true;
ui_mode_normal(); ui_mode_normal();
set_scale(2); set_scale(2);
@ -5675,14 +5682,23 @@ quit:
shell_printf("\n\r"); shell_printf("\n\r");
float first_level=-23.5; float first_level=-23.5;
// setting.R = 3; // setting.R = 3;
if (setting.test_argument < 0) {
switch_SI4463_RSSI_correction(false); switch_SI4463_RSSI_correction(false);
setting.test_argument = 0;
}
for (int j= SI4432_RBW_count-1; j >= 0; j-- ) { for (int j= SI4432_RBW_count-1; j >= 0; j-- ) {
if (setting.test_argument != 0) if (setting.test_argument != 0)
j = setting.test_argument; j = setting.test_argument;
test_prepare(TEST_LEVEL); test_prepare(TEST_LEVEL);
setting.rbw_x10 = force_rbw(j); setting.rbw_x10 = force_rbw(j);
osalThreadSleepMilliseconds(200); osalThreadSleepMilliseconds(200);
setting.spur_removal = S_ON; // setting.spur_removal = S_ON;
setting.R = 3;
set_average(AV_100);
test_acquire(TEST_LEVEL); // Acquire test
test_acquire(TEST_LEVEL); // Acquire test
test_acquire(TEST_LEVEL); // Acquire test
test_acquire(TEST_LEVEL); // Acquire test
test_acquire(TEST_LEVEL); // Acquire test test_acquire(TEST_LEVEL); // Acquire test
test_validate(TEST_LEVEL); // Validate test test_validate(TEST_LEVEL); // Validate test
// if (j == SI4432_RBW_count-1) // if (j == SI4432_RBW_count-1)
@ -5703,6 +5719,11 @@ quit:
set_repeat(5); set_repeat(5);
setting.rbw_x10 = force_rbw(j); setting.rbw_x10 = force_rbw(j);
set_sweep_frequency(ST_SPAN, (freq_t)(setting.rbw_x10 * (1000 << k))); set_sweep_frequency(ST_SPAN, (freq_t)(setting.rbw_x10 * (1000 << k)));
set_average(AV_100);
test_acquire(TEST_RBW); // Acquire test
test_acquire(TEST_RBW); // Acquire test
test_acquire(TEST_RBW); // Acquire test
test_acquire(TEST_RBW); // Acquire test
test_acquire(TEST_RBW); // Acquire test test_acquire(TEST_RBW); // Acquire test
test_validate(TEST_RBW); // Validate test test_validate(TEST_RBW); // Validate test
// if (j == SI4432_RBW_count-1) // if (j == SI4432_RBW_count-1)
@ -5734,6 +5755,11 @@ quit:
setting.rbw_x10 = force_rbw(j); setting.rbw_x10 = force_rbw(j);
setting.extra_lna = true; setting.extra_lna = true;
osalThreadSleepMilliseconds(200); osalThreadSleepMilliseconds(200);
set_average(AV_100);
test_acquire(TC_LEVEL); // Acquire test
test_acquire(TC_LEVEL); // Acquire test
test_acquire(TC_LEVEL); // Acquire test
test_acquire(TC_LEVEL); // Acquire test
test_acquire(TC_LEVEL); // Acquire test test_acquire(TC_LEVEL); // Acquire test
test_validate(TEST_NOISE); // Validate test test_validate(TEST_NOISE); // Validate test
peakLevel += - logf(actual_rbw_x10*100.0) * (10.0/logf(10.0)) peakLevel += - logf(actual_rbw_x10*100.0) * (10.0/logf(10.0))
@ -5760,7 +5786,13 @@ quit:
setting.rbw_x10 = force_rbw(j); setting.rbw_x10 = force_rbw(j);
setting.extra_lna = true; setting.extra_lna = true;
osalThreadSleepMilliseconds(200); osalThreadSleepMilliseconds(200);
set_sweep_frequency(ST_SPAN, (freq_t)(setting.rbw_x10 * (1000 << k))); set_sweep_frequency(ST_SPAN, (freq_t)(setting.rbw_x10 * (1000 << k)));
set_average(AV_100);
test_acquire(TC_LEVEL); // Acquire test
test_acquire(TC_LEVEL); // Acquire test
test_acquire(TC_LEVEL); // Acquire test
test_acquire(TC_LEVEL); // Acquire test
test_acquire(TC_LEVEL); // Acquire test test_acquire(TC_LEVEL); // Acquire test
test_validate(TEST_NOISE_RBW); // Validate test test_validate(TEST_NOISE_RBW); // Validate test
peakLevel += - logf(actual_rbw_x10*100.0) * (10.0/logf(10.0)) peakLevel += - logf(actual_rbw_x10*100.0) * (10.0/logf(10.0))
@ -5830,7 +5862,6 @@ void calibrate_modulation(int modulation, int8_t *correction)
#define CALIBRATE_RBWS 1 #define CALIBRATE_RBWS 1
const int power_rbw [5] = { 100, 300, 30, 10, 3 }; const int power_rbw [5] = { 100, 300, 30, 10, 3 };
#ifdef __CALIBRATE__
void calibrate(void) void calibrate(void)
{ {
int local_test_status; int local_test_status;
@ -5869,6 +5900,9 @@ again:
set_attenuation(10); set_attenuation(10);
set_repeat(5); set_repeat(5);
setting.spur_removal = S_OFF; setting.spur_removal = S_OFF;
set_average(AV_100);
test_acquire(test_case); // Acquire test
test_acquire(test_case); // Acquire test
test_acquire(test_case); // Acquire test test_acquire(test_case); // Acquire test
local_test_status = test_validate(test_case); // Validate test local_test_status = test_validate(test_case); // Validate test
#else #else
@ -5878,8 +5912,9 @@ again:
test_case += 1; test_case += 1;
#endif #endif
test_prepare(test_case); test_prepare(test_case);
// set_RBW(8500); set_RBW(3000);
set_attenuation(10); set_attenuation(10);
set_average(AV_100);
test_acquire(test_case); // Acquire test test_acquire(test_case); // Acquire test
test_acquire(test_case); // Acquire test test_acquire(test_case); // Acquire test
test_acquire(test_case); // Acquire test test_acquire(test_case); // Acquire test
@ -5911,7 +5946,7 @@ again:
goto again; goto again;
} }
#endif #endif
#if 0 // No high input calibration as CAL OUTPUT is unreliable #if 0 // No high input calibration as CAL OUTPUT is unreliable
set_RBW(100); set_RBW(100);
test_prepare(TEST_POWER+1); test_prepare(TEST_POWER+1);
@ -5951,7 +5986,7 @@ quit:
set_refer_output(-1); set_refer_output(-1);
reset_settings(M_LOW); reset_settings(M_LOW);
} }
#endif
#ifdef TINYSA4 #ifdef TINYSA4

@ -1360,7 +1360,7 @@ int16_t Si446x_RSSI(void)
// SI4463_WAIT_CTS; // Wait for CTS // SI4463_WAIT_CTS; // Wait for CTS
do{ do{
// if (MODE_INPUT(setting.mode) && RSSI_R // if (MODE_INPUT(setting.mode) && RSSI_R
#define SAMPLE_COUNT 3 #define SAMPLE_COUNT 1
int j = SAMPLE_COUNT; //setting.repeat; int j = SAMPLE_COUNT; //setting.repeat;
int RSSI_RAW_ARRAY[3]; int RSSI_RAW_ARRAY[3];
do{ do{
@ -1391,7 +1391,7 @@ int16_t Si446x_RSSI(void)
RSSI_RAW += DEVICE_TO_PURE_RSSI(RSSI_RAW_ARRAY[0]); RSSI_RAW += DEVICE_TO_PURE_RSSI(RSSI_RAW_ARRAY[0]);
#endif #endif
if (--i <= 0) break; if (--i <= 0) break;
// my_microsecond_delay(100); my_microsecond_delay(100);
}while(1); }while(1);
if (setting.repeat > 1) if (setting.repeat > 1)
@ -1523,15 +1523,15 @@ typedef struct {
static const RBW_t RBW_choices[] = static const RBW_t RBW_choices[] =
{ {
// BW register corr freq // BW register corr freq
{SI4463_RBW_02kHz, 15,3,22}, {SI4463_RBW_02kHz, 14,3,22},
{SI4463_RBW_1kHz, 20,10,9}, {SI4463_RBW_1kHz, 18,10,9},
{SI4463_RBW_3kHz, 15,30,8}, {SI4463_RBW_3kHz, 14,30,8},
{SI4463_RBW_10kHz, 10,100,6}, {SI4463_RBW_10kHz, 6,100,6},
{SI4463_RBW_30kHz, 15,300,2}, {SI4463_RBW_30kHz, 11,300,2},
{SI4463_RBW_100kHz,10,1000,-1}, {SI4463_RBW_100kHz, 6,1000,-1},
{SI4463_RBW_300kHz,10,3000,-15}, {SI4463_RBW_300kHz, 6,3000,-15},
{SI4463_RBW_600kHz,10,6000,-21}, {SI4463_RBW_600kHz, 6,6000,-21},
{SI4463_RBW_850kHz,20,8500,-29}, {SI4463_RBW_850kHz,16,8500,-29},
}; };
const uint8_t SI4432_RBW_count = ((int)(sizeof(RBW_choices)/sizeof(RBW_t))); const uint8_t SI4432_RBW_count = ((int)(sizeof(RBW_choices)/sizeof(RBW_t)));

@ -1622,8 +1622,8 @@ static const char* rbwsel_text[]={"auto","300","1k","3k","10k","30k","100k","300
static const uint16_t rbwsel_x10[]={0,30,100,300,1000,3000,6000}; static const uint16_t rbwsel_x10[]={0,30,100,300,1000,3000,6000};
#endif #endif
#ifdef __VBW__ #ifdef __VBW__
static const uint16_t vbwsel_x10[]={0,1,3,10,30,100}; static const uint16_t vbwsel_x100[]={0,100,30,10,3,1};
static const char* vbwsel_text[]={"auto","0.1", "0.3"," "," 3","10"}; static const char* vbwsel_text[]={"auto","0.01","0.03", "0.1", "0.3"," "};
#endif #endif
static UI_FUNCTION_ADV_CALLBACK(menu_rbw_acb) static UI_FUNCTION_ADV_CALLBACK(menu_rbw_acb)
@ -1648,10 +1648,10 @@ static UI_FUNCTION_ADV_CALLBACK(menu_vbw_acb)
(void)item; (void)item;
if (b){ if (b){
b->param_1.text = vbwsel_text[data]; b->param_1.text = vbwsel_text[data];
b->icon = setting.vbw_x10 == vbwsel_x10[data] ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP; b->icon = setting.vbw_x100 == vbwsel_x100[data] ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
return; return;
} }
set_VBW(vbwsel_x10[data]); set_VBW(vbwsel_x100[data]);
menu_move_back(true); menu_move_back(true);
} }
@ -3460,15 +3460,15 @@ redraw_cal_status:
#ifdef __VBW__ #ifdef __VBW__
// VBW // VBW
if (setting.frequency_step > 0) { if (setting.frequency_step > 0) {
int vbw = setting.vbw_x10; int vbw = setting.vbw_x100;
if (vbw != 0) if (vbw != 0)
color = LCD_BRIGHT_COLOR_GREEN; color = LCD_BRIGHT_COLOR_GREEN;
else { else {
color = LCD_FG_COLOR; color = LCD_FG_COLOR;
vbw = 10; vbw = 1;
} }
ili9341_set_foreground(color); ili9341_set_foreground(color);
lcd_printf(x, y, "VBW:\n%.1FHz", actual_rbw_x10*100.0 *vbw/10.0); lcd_printf(x, y, "VBW:\n%.1FHz", actual_rbw_x10*100.0 / vbw);
y = add_quick_menu(y+=YSTEP, (menuitem_t *)menu_vbw); y = add_quick_menu(y+=YSTEP, (menuitem_t *)menu_vbw);
} }
#endif #endif

Loading…
Cancel
Save

Powered by TurnKey Linux.