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

multi_trace
DiSlord 5 years ago
commit 1564293d25

@ -118,11 +118,8 @@ static THD_FUNCTION(Thread1, arg)
(void)arg;
chRegSetThreadName("sweep");
/*
* Load custom config from SD card if present
*/
#ifdef __SD_CARD_LOAD__
sd_card_load_config("config.ini");
sd_card_load_config("autoload.ini");
#endif
#ifndef TINYSA4
@ -249,10 +246,12 @@ int shell_printf(const char *fmt, ...)
{
if (shell_stream == NULL) return 0;
va_list ap;
int formatted_bytes;
va_start(ap, fmt);
formatted_bytes = chvprintf(shell_stream, fmt, ap);
va_end(ap);
int formatted_bytes = 0;
if (shell_stream) {
va_start(ap, fmt);
formatted_bytes = chvprintf(shell_stream, fmt, ap);
va_end(ap);
}
return formatted_bytes;
}
@ -2277,7 +2276,6 @@ int main(void)
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL);
while (1) {
// if (SDU1.config->usbp->state == USB_ACTIVE) {
if (shell_check_connect()) {

@ -1190,6 +1190,7 @@ void clear_all_config_prop_data(void);
extern void ui_init(void);
extern void ui_process(void);
int current_menu_is_form(void);
extern float nf_gain;
void ui_mode_normal(void);
void ui_mode_menu(void);
@ -1446,6 +1447,7 @@ extern bool ADF4351_frequency_changed;
extern bool SI4463_frequency_changed;
extern bool SI4463_offset_changed;
extern int16_t SI4463_noise_correction_x10;
void switch_SI4463_RSSI_correction(bool);
extern int old_R;
extern float Si446x_get_temp(void);
#define ENBW_Hz SI4463_ENBW_Hz

@ -1602,10 +1602,10 @@ static void cell_draw_marker_info(int x0, int y0)
aNP = marker_to_value(0);
#endif
float mNF = aNP - logf(actual_rbw_x10*100.0) * (10.0/logf(10.0)) + 173.93 + SI4463_noise_correction_x10/10.0; // measured noise figure at 20C
if (setting.external_gain != 0) {
float mnf = expf(mNF/10 * logf(10)); // measure noise factor
if (nf_gain != 0) {
float mnf = expf((mNF - nf_gain)/10 * logf(10)); // measure noise factor
float tnf = expf(config.noise_figure/10 * logf(10)); // tinySA noise factor
float amp_gain = expf(setting.external_gain/10 * logf(10));
float amp_gain = expf(nf_gain/10 * logf(10));
float anf = mnf - (tnf - 1.0)/amp_gain;
mNF = 10*logf(anf)/logf(10);
}
@ -1617,7 +1617,7 @@ static void cell_draw_marker_info(int x0, int y0)
// j = 1;
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
int ypos = 1 + (j/2)*(16) - y0;
cell_printf(xpos, ypos, FONT_b"NF: %4.1f", mNF);
cell_printf(xpos, ypos, FONT_b"GAIN: %4.1fdB NF: %4.1f", nf_gain, mNF);
break;
#endif
} else

@ -4780,7 +4780,7 @@ enum {
#ifdef TINYSA4
//#define CAL_LEVEL -23.5
#define CAL_LEVEL -23
#define CAL_LEVEL -23.1
#else
#define CAL_LEVEL (has_esd ? -26.2 : -25)
#endif
@ -4833,8 +4833,8 @@ const test_case_t test_case [] =
#define TEST_SPUR 23
TEST_CASE_STRUCT(TC_BELOW, TP_SILENT, 144, 8, -95, 0, 0), // 22 Measure 48MHz spur
#define TEST_LEVEL 24
TEST_CASE_STRUCT(TC_LEVEL, TP_30MHZ, 30, 0, CAL_LEVEL, 145, -55), // 23 Measure level
TEST_CASE_STRUCT(TC_LEVEL, TP_30MHZ_LNA, 30, 0, CAL_LEVEL, 145, -55), // 23 Measure level
TEST_CASE_STRUCT(TC_LEVEL, TP_30MHZ, 30.000, 0, CAL_LEVEL, 145, -55), // 23 Measure level
TEST_CASE_STRUCT(TC_LEVEL, TP_30MHZ_LNA, 30.000, 0, CAL_LEVEL, 145, -55), // 23 Measure level
TEST_CASE_STRUCT(TC_LEVEL, TPH_30MHZ, 150, 0, CAL_LEVEL-30, 145, -55), // 23 Measure level
};
@ -5657,11 +5657,16 @@ quit:
shell_printf("%d: %9.3q\n\r",i, peakFreq);
test_validate(TEST_SPUR); // Validate test
}
} else if (false && test == 7) { // RBW level test
#ifdef TINYSA4
} else if (test == 7) { // RBW level test
in_selftest = true;
ui_mode_normal();
set_scale(2);
set_reflevel(-22);
shell_printf("\n\r");
float first_level=0;
float first_level=-23.2;
setting.R = 3;
switch_SI4463_RSSI_correction(false);
for (int j= SI4432_RBW_count-1; j >= 0; j-- ) {
if (setting.test_argument != 0)
j = setting.test_argument;
@ -5671,29 +5676,40 @@ quit:
setting.spur_removal = S_ON;
test_acquire(TEST_LEVEL); // Acquire test
test_validate(TEST_LEVEL); // Validate test
if (j == SI4432_RBW_count-1)
first_level = peakLevel;
shell_printf("RBW = %7.1fk, level = %6.2f, corr = %6.2f\n\r",actual_rbw_x10/10.0 , peakLevel, (first_level - peakLevel + 1.5)*10.0 );
// if (j == SI4432_RBW_count-1)
// first_level = peakLevel;
shell_printf("RBW = %7.1fk, level = %6.2f, corr = %6.2f\n\r",actual_rbw_x10/10.0 , peakLevel, (first_level - peakLevel)*10.0 );
if (setting.test_argument != 0)
break;
}
#if 0 // Does not center on frequency!!!!!
shell_printf("\n\r");
for (int j= SI4432_RBW_count-1; j >= 0; j-- ) {
if (setting.test_argument != 0)
j = setting.test_argument;
test_prepare(TEST_LEVEL+2);
setting.rbw_x10 = force_rbw(j);
test_acquire(TEST_LEVEL+2); // Acquire test
test_validate(TEST_LEVEL+2); // Validate test
if (j == SI4432_RBW_count-1)
first_level = peakLevel;
shell_printf("RBW = %7.1fk, level = %6.2f, corr = %6.2f\n\r",actual_rbw_x10/10.0 , peakLevel, (first_level - peakLevel + 1.5)*10.0 );
if (setting.test_argument != 0)
break;
#if 1 // Does not center on frequency!!!!!
for (int k = 0; k< 4; k++) {
shell_printf("\n\r%d ", k);
for (int j= SI4432_RBW_count-1; j >= 0; j-- ) {
if (setting.test_argument != 0)
j = setting.test_argument;
test_prepare(TEST_RBW);
// setting.step_delay_mode = SD_PRECISE;
set_repeat(5);
setting.rbw_x10 = force_rbw(j);
set_sweep_frequency(ST_SPAN, (freq_t)(setting.rbw_x10 * (1000 << k)));
test_acquire(TEST_RBW); // Acquire test
test_validate(TEST_RBW); // Validate test
// if (j == SI4432_RBW_count-1)
// first_level = peakLevel;
// shell_printf("RBW = %7.1fk, level = %6.2f, corr = %6.2f\n\r",actual_rbw_x10/10.0 , peakLevel, (first_level - peakLevel)*10.0 );
shell_printf("%6.2f ", (first_level - peakLevel)*10.0 );
if (setting.test_argument != 0)
break;
}
}
#endif
shell_printf("\n\r");
setting.R = 0;
switch_SI4463_RSSI_correction(true);
reset_settings(M_LOW);
#endif
}
show_test_info = FALSE;

@ -1360,7 +1360,7 @@ int16_t Si446x_RSSI(void)
// SI4463_WAIT_CTS; // Wait for CTS
do{
// if (MODE_INPUT(setting.mode) && RSSI_R
#define SAMPLE_COUNT 1
#define SAMPLE_COUNT 3
int j = SAMPLE_COUNT; //setting.repeat;
int RSSI_RAW_ARRAY[3];
do{
@ -1523,20 +1523,21 @@ typedef struct {
static const RBW_t RBW_choices[] =
{
// BW register corr freq
{SI4463_RBW_02kHz, 18,3,42},
{SI4463_RBW_1kHz, 18,10,22},
{SI4463_RBW_3kHz, 12,30,21},
{SI4463_RBW_10kHz, 7,100,20},
{SI4463_RBW_30kHz, 10,300,20},
{SI4463_RBW_100kHz,2,1000,26},
{SI4463_RBW_300kHz,2,3000,19},
{SI4463_RBW_600kHz,3,6000,18},
{SI4463_RBW_850kHz,12,8500,15},
{SI4463_RBW_02kHz, 16,3,42},
{SI4463_RBW_1kHz, 20,10,29},
{SI4463_RBW_3kHz, 15,30,28},
{SI4463_RBW_10kHz, 5,100,26},
{SI4463_RBW_30kHz, 11,300,22},
{SI4463_RBW_100kHz,9,1000,19},
{SI4463_RBW_300kHz,8,3000,5},
{SI4463_RBW_600kHz,9,6000,-1},
{SI4463_RBW_850kHz,19,8500,-9},
};
const uint8_t SI4432_RBW_count = ((int)(sizeof(RBW_choices)/sizeof(RBW_t)));
static pureRSSI_t SI4463_RSSI_correction = float_TO_PURE_RSSI(-120);
bool SI4463_RSSI_correction_enabled = true;
int16_t SI4463_noise_correction_x10;
static int prev_band = -1;
@ -1544,6 +1545,10 @@ pureRSSI_t getSI4463_RSSI_correction(void){
return SI4463_RSSI_correction;
};
void switch_SI4463_RSSI_correction(bool enabled){
SI4463_RSSI_correction_enabled = enabled;
};
uint16_t force_rbw(int f)
{
@ -1562,7 +1567,7 @@ uint16_t force_rbw(int f)
// SI4463_wait_for_cts();
set_RSSI_comp();
// prev_band = -1;
SI4463_RSSI_correction = float_TO_PURE_RSSI(RBW_choices[f].RSSI_correction_x_10 - 1200)/10; // Set RSSI correction
SI4463_RSSI_correction = ( SI4463_RSSI_correction_enabled ? float_TO_PURE_RSSI(RBW_choices[f].RSSI_correction_x_10 - 1200)/10 : float_TO_PURE_RSSI(-120) ) ; // Set RSSI correction
SI4463_noise_correction_x10 = RBW_choices[f].noise_correction_x10;
return RBW_choices[f].RBWx10; // RBW achieved by SI4463 in kHz * 10
}

@ -790,7 +790,7 @@ static UI_FUNCTION_ADV_CALLBACK(menu_store_preset_acb)
UI_FUNCTION_CALLBACK(menu_load_config_cb)
{
(void)item;
sd_card_load_config((data?"config.ini":"setting.ini"));
sd_card_load_config("config.ini");
ui_mode_normal();
}
#endif
@ -1151,6 +1151,7 @@ static UI_FUNCTION_CALLBACK(menu_clearconfig_cb)
ui_mode_normal();
}
float nf_gain;
const char * const averageText[] = { "OFF", "MIN", "MAX", "MAXD", " A 4", "A 16", "AVER", "QUASI", "DECONV"};
static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
@ -1348,13 +1349,17 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
markers[0].mtype = M_NOISE; // Not tracking
set_extra_lna(true);
kp_help_text = "Amplifier Gain ";
float old_gain = setting.external_gain;
ui_mode_keypad(KM_EXT_GAIN);
kp_help_text = "Noise frequency";
nf_gain = setting.external_gain;
setting.external_gain = old_gain;
kp_help_text = "Noise center frequency";
ui_mode_keypad(KM_CENTER);
set_marker_frequency(0, uistat.value);
// kp_help_text = "Noise width";
// ui_mode_keypad(KM_SPAN);
set_sweep_frequency(ST_SPAN, 0);
kp_help_text = "Noise span";
ui_mode_keypad(KM_SPAN);
set_RBW(get_sweep_frequency(ST_SPAN)/100 / 100);
// set_sweep_frequency(ST_SPAN, 0);
set_average(AV_100);
break;
#endif
@ -2518,7 +2523,7 @@ static const menuitem_t menu_settings4[] =
#endif
#ifdef __SD_CARD_LOAD__
{ MT_CALLBACK, 0 , "LOAD\nCONFIG.INI", menu_load_config_cb},
{ MT_CALLBACK, 1 , "LOAD\nSETTING.INI", menu_load_config_cb},
// { MT_CALLBACK, 1 , "LOAD\nSETTING.INI", menu_load_config_cb},
#endif
{ MT_CALLBACK, 0 , "CLEAR\nCONFIG", menu_clearconfig_cb},
#ifdef __HARMONIC__

Loading…
Cancel
Save

Powered by TurnKey Linux.