Reduced drive level

Removed_REF_marker
erikkaashoek 5 years ago
parent ecd7d207e3
commit 1baebddaf1

@ -136,7 +136,7 @@
* @brief Enables the SERIAL subsystem.
*/
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
#define HAL_USE_SERIAL TRUE
#define HAL_USE_SERIAL FALSE
#endif
/**
@ -291,7 +291,7 @@
* default configuration.
*/
#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
#define SERIAL_DEFAULT_BITRATE 38400
#define SERIAL_DEFAULT_BITRATE 115200
#endif
/**

@ -2546,6 +2546,22 @@ VNA_SHELL_FUNCTION(cmd_help)
/*
* VNA shell functions
*/
// Check USB connection status
static bool usb_IsActive(void){
return usbGetDriverStateI(&USBD1) == USB_ACTIVE;
}
// Check active connection for Shell
static bool shell_check_connect(void){
#ifdef __USE_SERIAL_CONSOLE__
// Serial connection always active
if (config._mode & _MODE_SERIAL)
return true;
#endif
// USB connection can be USB_SUSPENDED
return usb_IsActive();
}
// Check Serial connection requirements
#ifdef __USE_SERIAL_CONSOLE__
#if HAL_USE_SERIAL == FALSE
@ -2563,10 +2579,6 @@ void shell_update_speed(void){
sdStart(&SD1, &s_config); // USART config
}
// Check USB connection status
static bool usb_IsActive(void){
return usbGetDriverStateI(&USBD1) == USB_ACTIVE;
}
void shell_reset_console(void){
// Reset I/O queue over USB (for USB need also connect/disconnect)
if (usb_IsActive()){
@ -2580,14 +2592,6 @@ void shell_reset_console(void){
iqResetI(&SD1.iqueue);
}
// Check active connection for Shell
static bool shell_check_connect(void){
// Serial connection always active
if (config._mode & _MODE_SERIAL)
return true;
// USB connection can be USB_SUSPENDED
return usb_IsActive();
}
static void shell_init_connection(void){
/*
@ -3018,7 +3022,8 @@ int main(void)
while (1) {
if (SDU1.config->usbp->state == USB_ACTIVE) {
// if (SDU1.config->usbp->state == USB_ACTIVE) {
if (shell_check_connect()) {
#ifdef VNA_SHELL_THREAD
#if CH_CFG_USE_WAITEXIT == FALSE
#error "VNA_SHELL_THREAD use chThdWait, need enable CH_CFG_USE_WAITEXIT in chconf.h"
@ -3035,7 +3040,8 @@ int main(void)
VNAShell_executeLine(shell_line);
else
chThdSleepMilliseconds(200);
} while (SDU1.config->usbp->state == USB_ACTIVE);
// } while (SDU1.config->usbp->state == USB_ACTIVE);
} while (shell_check_connect());
#endif
}
chThdSleepMilliseconds(1000);

@ -75,7 +75,7 @@ static freq_t real_old_freq[4] = { 0, 0, 0, 0};
#endif
#ifdef TINYSA4
const float si_drive_dBm [] = {-43, -30.1, -19.5, -15.5, -13, -11, -9.5, -8.1, -6.9, -5.9, -5, -4.2, -3.5, -2.8 , -2.2, -1.7, -1, -0.5, 0};
const float si_drive_dBm [] = {-43.8, -30.0, -21.8, -17.2, -14.2, -11.9, -10.1, -8.6, -7.3, -6.2, -5.2, -4.3, -3.5, -2.8 , -2.2, -1.5, -1, -0.5, 0};
const float adf_drive_dBm[] = {-15,-12,-9,-6};
const uint8_t drive_register[] = {0, 1, 2, 3, 4, 5, 6, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18};
float *drive_dBm = (float *) adf_drive_dBm;
@ -293,9 +293,12 @@ void reset_settings(int m)
setting.step_delay_mode = SD_FAST;
#ifdef TINYSA4
setting.extra_lna = false;
#endif
setting.correction_frequency = config.correction_frequency[CORRECTION_LOW_OUT];
setting.correction_value = config.correction_value[CORRECTION_LOW_OUT];
#else
setting.correction_frequency = config.correction_frequency[CORRECTION_LOW];
setting.correction_value = config.correction_value[CORRECTION_LOW];
#endif
level_min = SL_GENLOW_LEVEL_MIN + LOW_OUT_OFFSET;
level_max = SL_GENLOW_LEVEL_MAX + LOW_OUT_OFFSET;
level_range = level_max - level_min;
@ -1982,7 +1985,11 @@ void update_rbw(void) // calculate the actual_rbw and the vbwSteps (#
vbwSteps = 1; // starting number for all modes
if (!MODE_INPUT(setting.mode)) {
actual_rbw_x10 = 1; // To force substepping of the SI4463
#ifdef TINYSA4
goto done;
#else
return;
#endif
}
if (setting.frequency_step > 0 && MODE_INPUT(setting.mode)) {
setting.vbw_x10 = (setting.frequency_step)/100;
@ -2047,8 +2054,10 @@ void update_rbw(void) // calculate the actual_rbw and the vbwSteps (#
} else { // in all other modes
setting.vbw_x10 = actual_rbw_x10;
}
#ifdef TINYSA4
done:
fill_spur_table(); // IF frequency depends on selected RBW
#endif
}
#ifdef TINYSA4
@ -2591,7 +2600,9 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
correct_RSSI_freq = get_frequency_correction(f);
a += PURE_TO_float(correct_RSSI_freq) + 3.0; // Always 3dB in attenuator
if (a != old_a) {
#ifdef TINYSA4
int very_low_flag = false;
#endif
old_a = a;
a = a - level_max; // convert to all settings maximum power output equals a = zero
if (a < -SWITCH_ATTENUATION) {
@ -2617,8 +2628,12 @@ pureRSSI_t perform(bool break_on_operation, int i, freq_t f, int tracking) /
#else
#define LOWEST_LEVEL MIN_DRIVE
#endif
int d = MAX_DRIVE; // Reduce level till it fits in attenuator range
while (a - BELOW_MAX_DRIVE(d) < - 31 && d > LOWEST_LEVEL) {
int d = MAX_DRIVE-8; // Start in the middle
while (a - BELOW_MAX_DRIVE(d) > 0 && d < MAX_DRIVE) { // Increase if needed
d++;
}
while (a - BELOW_MAX_DRIVE(d) < - 31 && d > LOWEST_LEVEL) { // reduce till it fits attenuator
d--;
}
a -= BELOW_MAX_DRIVE(d);
@ -3356,10 +3371,12 @@ again: // Spur redu
}
#endif
#ifdef TINYSA4
if (LO_shifting)
pureRSSI -= float_TO_PURE_RSSI(config.shift_level_offset);
if (LO_harmonic)
pureRSSI -= float_TO_PURE_RSSI(config.harmonic_level_offset);
#endif
if (RSSI < pureRSSI) // Take max during subscanning
RSSI = pureRSSI;

Loading…
Cancel
Save

Powered by TurnKey Linux.