Removed some floats

master v1.3
erikkaashoek 5 years ago
parent a95ec1d8cc
commit 232494b66b

@ -23,6 +23,8 @@
#include "spi.h" #include "spi.h"
// Allow enable DMA for read display data // Allow enable DMA for read display data
//#define __USE_DISPLAY_DMA_RX__ //#define __USE_DISPLAY_DMA_RX__

@ -146,9 +146,11 @@ static THD_FUNCTION(Thread1, arg)
// call from lowest level to save stack space // call from lowest level to save stack space
self_test(setting.test); self_test(setting.test);
// sweep_mode = SWEEP_ENABLE; // sweep_mode = SWEEP_ENABLE;
} else if (sweep_mode & SWEEP_REMOTE) { #ifdef __SINGLE_LETTER__
} else if (sweep_mode & SWEEP_REMOTE) {
sweep_remote(); sweep_remote();
} else if (sweep_mode & SWEEP_CALIBRATE) { #endif
} else if (sweep_mode & SWEEP_CALIBRATE) {
// call from lowest level to save stack space // call from lowest level to save stack space
calibrate(); calibrate();
sweep_mode = SWEEP_ENABLE; sweep_mode = SWEEP_ENABLE;
@ -3021,7 +3023,7 @@ void HardFault_Handler(void)
void hard_fault_handler_c(uint32_t *sp) void hard_fault_handler_c(uint32_t *sp)
{ {
#if 1 #if 0
uint32_t r0 = sp[0]; uint32_t r0 = sp[0];
uint32_t r1 = sp[1]; uint32_t r1 = sp[1];
uint32_t r2 = sp[2]; uint32_t r2 = sp[2];

@ -51,9 +51,9 @@
#define __SPUR__ // Does spur reduction by shifting IF #define __SPUR__ // Does spur reduction by shifting IF
//#define __USE_SERIAL_CONSOLE__ // Enable serial I/O connection (need enable HAL_USE_SERIAL as TRUE in halconf.h) //#define __USE_SERIAL_CONSOLE__ // Enable serial I/O connection (need enable HAL_USE_SERIAL as TRUE in halconf.h)
#define __SINGLE_LETTER__ #define __SINGLE_LETTER__
//#define __NICE_BIG_FONT__ #define __NICE_BIG_FONT__
#define __QUASI_PEAK__ #define __QUASI_PEAK__
#define __REMOTE_DESKTOP__ //#define __REMOTE_DESKTOP__
#ifdef TINYSA3 #ifdef TINYSA3
#define DEFAULT_IF 433800000 #define DEFAULT_IF 433800000

@ -556,6 +556,8 @@ VNA_SHELL_FUNCTION(cmd_z)
#endif #endif
#ifdef __SINGLE_LETTER__
void sweep_remote(void) void sweep_remote(void)
{ {
uint32_t i; uint32_t i;
@ -582,7 +584,6 @@ void sweep_remote(void)
sweep_mode = 0; sweep_mode = 0;
} }
#ifdef __SINGLE_LETTER__
VNA_SHELL_FUNCTION(cmd_m) VNA_SHELL_FUNCTION(cmd_m)
{ {
(void)argc; (void)argc;

@ -2240,7 +2240,7 @@ sweep_again: // stay in sweep loop when output mo
#endif #endif
if (check_for_AM) { if (check_for_AM) {
int AGC_value = (SI4432_Read_Byte(0x69) & 0x01f) * 3.0 - 90.0; int AGC_value = (SI4432_Read_Byte(0x69) & 0x01f) * 3 - 90;
if (AGC_value < last_AGC_value && last_AGC_direction_up ) { if (AGC_value < last_AGC_value && last_AGC_direction_up ) {
AGC_flip_count++; AGC_flip_count++;
} else if (AGC_value > last_AGC_value && !last_AGC_direction_up ) { } else if (AGC_value > last_AGC_value && !last_AGC_direction_up ) {
@ -2496,7 +2496,7 @@ sweep_again: // stay in sweep loop when output mo
if (!in_selftest && MODE_INPUT(setting.mode)) { if (!in_selftest && MODE_INPUT(setting.mode)) {
#ifdef __SI4432__ #ifdef __SI4432__
if (S_IS_AUTO(setting.agc)) { if (S_IS_AUTO(setting.agc)) {
float actual_max_level = actual_t[max_index[0]] - get_attenuation(); int actual_max_level = actual_t[max_index[0]] - get_attenuation(); // No need to use float
if (UNIT_IS_LINEAR(setting.unit)) { // Auto AGC in linear mode if (UNIT_IS_LINEAR(setting.unit)) { // Auto AGC in linear mode
if (actual_max_level > - 45) if (actual_max_level > - 45)
auto_set_AGC_LNA(false, 0); // Strong signal, no AGC and no LNA auto_set_AGC_LNA(false, 0); // Strong signal, no AGC and no LNA
@ -2674,10 +2674,11 @@ sweep_again: // stay in sweep loop when output mo
} }
} else if (setting.measurement == M_AM) { // ----------------AM measurement } else if (setting.measurement == M_AM) { // ----------------AM measurement
if (S_IS_AUTO(setting.agc )) { if (S_IS_AUTO(setting.agc )) {
if (actual_t[max_index[0]] - get_attenuation() > -20 ) { int actual_level = actual_t[max_index[0]] - get_attenuation(); // no need for float
if (actual_level > -20 ) {
setting.agc = S_AUTO_OFF; setting.agc = S_AUTO_OFF;
setting.lna = S_AUTO_OFF; setting.lna = S_AUTO_OFF;
} else if (actual_t[max_index[0]] - get_attenuation() < -45 ) { } else if (actual_level < -45 ) {
setting.agc = S_AUTO_ON; setting.agc = S_AUTO_ON;
setting.lna = S_AUTO_ON; setting.lna = S_AUTO_ON;
} else { } else {
@ -2832,7 +2833,7 @@ int marker_search_max(void)
return found; return found;
} }
#define MINMAX_DELTA 10 #define MINMAX_DELTA_X10 100
int int
@ -2843,22 +2844,22 @@ marker_search_left_min(int from)
if (uistat.current_trace == -1) if (uistat.current_trace == -1)
return -1; return -1;
float value = actual_t[from]; int value_x10 = actual_t[from]*10;
for (i = from - 1; i >= 0; i--) { for (i = from - 1; i >= 0; i--) {
float new_value = actual_t[i]; int new_value_x10 = actual_t[i]*10;
if (new_value > value) { if (new_value_x10 > value_x10) {
value = new_value; // follow up value_x10 = new_value_x10; // follow up
// found = i; // found = i;
} else if (new_value < value - MINMAX_DELTA ) } else if (new_value_x10 < value_x10 - MINMAX_DELTA_X10 )
break; // past the maximum break; // past the maximum
} }
for (; i >= 0; i--) { for (; i >= 0; i--) {
float new_value = actual_t[i]; int new_value_x10 = actual_t[i]*10;
if (new_value < value) { if (new_value_x10 < value_x10) {
value = new_value; // follow down value_x10 = new_value_x10; // follow down
found = i; found = i;
} else if (new_value > value + MINMAX_DELTA ) } else if (new_value_x10 > value_x10 + MINMAX_DELTA_X10 )
break; break;
} }
return found; return found;
@ -2872,21 +2873,21 @@ marker_search_right_min(int from)
if (uistat.current_trace == -1) if (uistat.current_trace == -1)
return -1; return -1;
float value = actual_t[from]; int value_x10 = actual_t[from]*10;
for (i = from + 1; i < sweep_points; i++) { for (i = from + 1; i < sweep_points; i++) {
float new_value = actual_t[i]; int new_value_x10 = actual_t[i]*10;
if (new_value > value) { // follow up if (new_value_x10 > value_x10) { // follow up
value = new_value; value_x10 = new_value_x10;
// found = i; // found = i;
} else if (new_value < value - MINMAX_DELTA) // less then largest value - noise } else if (new_value_x10 < value_x10 - MINMAX_DELTA_X10) // less then largest value_x10 - noise
break; // past the maximum break; // past the maximum
} }
for (; i < sweep_points; i++) { for (; i < sweep_points; i++) {
float new_value = actual_t[i]; int new_value_x10 = actual_t[i]*10;
if (new_value < value) { // follow down if (new_value_x10 < value_x10) { // follow down
value = new_value; value_x10 = new_value_x10;
found = i; found = i;
} else if (new_value > value + MINMAX_DELTA) // larger then smallest value + noise } else if (new_value_x10 > value_x10 + MINMAX_DELTA_X10) // larger then smallest value_x10 + noise
break; break;
} }
return found; return found;
@ -3112,8 +3113,7 @@ int validate_atten(int i) {
if (j == 0) if (j == 0)
reference_peak_level = summed_peak_level; reference_peak_level = summed_peak_level;
else { else {
// shell_printf("Attenuation %.2fdB, measured level %.2fdBm, delta %.2fdB\n\r",((float)j)/2.0, summed_peak_level, summed_peak_level - reference_peak_level); // if (SDU1.config->usbp->state == USB_ACTIVE) shell_printf("Attenuation %.2fdB, measured level %.2fdBm, delta %.2fdB\n\r",a, summed_peak_level, summed_peak_level - reference_peak_level);
if (SDU1.config->usbp->state == USB_ACTIVE) shell_printf("Attenuation %.2fdB, measured level %.2fdBm, delta %.2fdB\n\r",a, summed_peak_level, summed_peak_level - reference_peak_level);
#define ATTEN_TEST_CRITERIA 1 #define ATTEN_TEST_CRITERIA 1
if (summed_peak_level - reference_peak_level <= -ATTEN_TEST_CRITERIA || summed_peak_level - reference_peak_level >= ATTEN_TEST_CRITERIA) { if (summed_peak_level - reference_peak_level <= -ATTEN_TEST_CRITERIA || summed_peak_level - reference_peak_level >= ATTEN_TEST_CRITERIA) {
status = TS_FAIL; status = TS_FAIL;
@ -3582,8 +3582,6 @@ void self_test(int test)
set_sweep_frequency(ST_SPAN, 0); set_sweep_frequency(ST_SPAN, 0);
break; break;
} }
}
#endif
} else if (test == 6) { } else if (test == 6) {
in_selftest = true; // Spur search in_selftest = true; // Spur search
reset_settings(M_LOW); reset_settings(M_LOW);
@ -3598,9 +3596,8 @@ void self_test(int test)
test_acquire(TEST_SPUR); // Acquire test test_acquire(TEST_SPUR); // Acquire test
shell_printf("%d: %9.3q\n\r",i, peakFreq); shell_printf("%d: %9.3q\n\r",i, peakFreq);
test_validate(TEST_SPUR); // Validate test test_validate(TEST_SPUR); // Validate test
} }
#endif
} }
show_test_info = FALSE; show_test_info = FALSE;

Loading…
Cancel
Save

Powered by TurnKey Linux.