More comment

Removed_REF_marker
erikkaashoek 5 years ago
parent bd409ec577
commit 00a1715d07

@ -154,11 +154,13 @@ static THD_FUNCTION(Thread1, arg)
} else if (sweep_mode & SWEEP_REMOTE) { } else if (sweep_mode & SWEEP_REMOTE) {
sweep_remote(); sweep_remote();
#endif #endif
#ifdef __CALIBRATE__
} else if (sweep_mode & SWEEP_CALIBRATE) { } 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;
} else { #endif
} else {
// if (setting.mode != -1) // if (setting.mode != -1)
__WFI(); __WFI();
} }
@ -2438,7 +2440,9 @@ static const VNAShellCommand commands[] =
{ "modulation", cmd_modulation, 0 }, { "modulation", cmd_modulation, 0 },
{ "rbw", cmd_rbw, 0 }, { "rbw", cmd_rbw, 0 },
{ "mode", cmd_mode, CMD_WAIT_MUTEX }, { "mode", cmd_mode, CMD_WAIT_MUTEX },
#ifdef __SPUR__
{ "spur", cmd_spur, 0 }, { "spur", cmd_spur, 0 },
#endif
#ifdef TINYSA4 #ifdef TINYSA4
{ "lna", cmd_lna, 0 }, { "lna", cmd_lna, 0 },
{ "ultra", cmd_ultra, 0 }, { "ultra", cmd_ultra, 0 },

@ -53,22 +53,21 @@
#endif #endif
#define __PE4302__ #define __PE4302__
//#define __SIMULATION__ //#define __SIMULATION__
//#define __PIPELINE__ #define __SCROLL__ // Add waterfall option
#define __SCROLL__
#define __ICONS__ #define __ICONS__
#define __MEASURE__ #define __MEASURE__
#define __LINEARITY__ // Not available #define __LINEARITY__ // Not available
#define __SELFTEST__ #define __SELFTEST__ // Add selftest option (not fully disable it)
#define __CALIBRATE__ #define __CALIBRATE__ // Add calibration menu and functions
#define __FAST_SWEEP__ // Pre-fill SI4432 RSSI buffer to get fastest sweep in zero span mode #define __FAST_SWEEP__ // Pre-fill SI4432 RSSI buffer to get fastest sweep in zero span mode
// #define __AUDIO__ // #define __AUDIO__
//#define __HAM_BAND__ //#define __HAM_BAND__
#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__ // Add fast console commands
#define __NICE_BIG_FONT__ #define __NICE_BIG_FONT__ // Add not scaled big font for menus
#define __QUASI_PEAK__ #define __QUASI_PEAK__ // Add quasi peak average option
#define __REMOTE_DESKTOP__ #define __REMOTE_DESKTOP__ // Add remote desktop option
#ifdef TINYSA4 #ifdef TINYSA4
#define __HARMONIC__ #define __HARMONIC__
#endif #endif
@ -273,7 +272,7 @@ extern float *drive_dBm;
extern const int8_t drive_dBm []; extern const int8_t drive_dBm [];
#endif #endif
extern uint8_t signal_is_AM; extern uint8_t signal_is_AM;
extern const int reffer_freq[]; extern const uint32_t reffer_freq[];
extern freq_t minFreq; extern freq_t minFreq;
extern freq_t maxFreq; extern freq_t maxFreq;
int level_is_calibrated(void); int level_is_calibrated(void);
@ -633,7 +632,7 @@ extern config_t config;
//#define settingLevelOffset config.level_offset //#define settingLevelOffset config.level_offset
float get_level_offset(void); float get_level_offset(void);
extern int in_selftest; extern uint8_t in_selftest;
extern int display_test(void); extern int display_test(void);
// //

@ -90,7 +90,7 @@ int generic_option_cmd( const char *cmd, const char *cmd_list, int argc, char *a
return m; return m;
} }
#ifdef __SPUR__
VNA_SHELL_FUNCTION(cmd_spur) VNA_SHELL_FUNCTION(cmd_spur)
{ {
// static const char cmd[] = "off|on"; // static const char cmd[] = "off|on";
@ -109,6 +109,7 @@ VNA_SHELL_FUNCTION(cmd_spur)
redraw_request |= REDRAW_CAL_STATUS | REDRAW_AREA; redraw_request |= REDRAW_CAL_STATUS | REDRAW_AREA;
} }
} }
#endif
#ifdef TINYSA4 #ifdef TINYSA4
VNA_SHELL_FUNCTION(cmd_lna) VNA_SHELL_FUNCTION(cmd_lna)

@ -116,9 +116,9 @@ float level_range;
//int setting.refer = -1; // Off by default //int setting.refer = -1; // Off by default
const int reffer_freq[] = {30000000, 15000000, 10000000, 4000000, 3000000, 2000000, 1000000}; const uint32_t reffer_freq[] = {30000000, 15000000, 10000000, 4000000, 3000000, 2000000, 1000000};
int in_selftest = false; uint8_t in_selftest = false;
void update_min_max_freq(void) void update_min_max_freq(void)
{ {
@ -1042,7 +1042,7 @@ void set_AGC_LNA(void) {
uint8_t v = 0; uint8_t v = 0;
if (!S_STATE(setting.agc)) if (!S_STATE(setting.agc))
v |= 0x80 + 0x20; // Inverse!!!! v |= 0x80 + 0x20; // Inverse!!!!
if (S_STATE(setting.lna)) if (!S_STATE(setting.lna))
v |= 0x08; // Inverse!!!! v |= 0x08; // Inverse!!!!
SI446x_set_AGC_LNA(v); SI446x_set_AGC_LNA(v);
SI4432_old_v[0] = v; SI4432_old_v[0] = v;
@ -1286,7 +1286,7 @@ static const struct {
{ 300, 400, 120, 100}, { 300, 400, 120, 100},
{ 100, 400, 120, 100}, { 100, 400, 120, 100},
{ 30, 900, 300, 100}, { 30, 900, 300, 100},
{ 10, 3000, 600, 100}, { 10, 4000, 600, 100},
{ 0, 9000, 3000, 100} { 0, 9000, 3000, 100}
}; };
#endif #endif
@ -1305,6 +1305,7 @@ static void calculate_step_delay(void)
// Search index in table depend from RBW // Search index in table depend from RBW
uint16_t i=0; uint16_t i=0;
for (i=0;i<ARRAY_COUNT(step_delay_table)-1;i++) for (i=0;i<ARRAY_COUNT(step_delay_table)-1;i++)
if (actual_rbw_x10 >= step_delay_table[i].rbw_x10) if (actual_rbw_x10 >= step_delay_table[i].rbw_x10)
break; break;
@ -1915,13 +1916,13 @@ void interpolate_maximum(int m)
markers[m].frequency = frequencies[idx]; markers[m].frequency = frequencies[idx];
if (idx > 0 && idx < sweep_points-1) if (idx > 0 && idx < sweep_points-1)
{ {
const int32_t delta_Hz = (int64_t)frequencies[idx + 0] - frequencies[idx + 1];
const float y1 = actual_t[idx - 1]; const float y1 = actual_t[idx - 1];
const float y2 = actual_t[idx + 0]; const float y2 = actual_t[idx + 0];
const float y3 = actual_t[idx + 1]; const float y3 = actual_t[idx + 1];
const float d = 0.5f * (y1 - y3) / ((y1 - (2 * y2) + y3) + 1e-12f); const float d = abs(delta_Hz) * 0.5f * (y1 - y3) / ((y1 - (2 * y2) + y3) + 1e-12f);
//const float bin = (float)idx + d; //const float bin = (float)idx + d;
const int32_t delta_Hz = abs((int64_t)frequencies[idx + 0] - frequencies[idx + 1]); markers[m].frequency += d;
markers[m].frequency += (int32_t)(delta_Hz * d);
} }
} }
@ -2516,8 +2517,10 @@ modulation_again:
goto skip_LO_setting; // No more LO changes required, save some time and jump over the code goto skip_LO_setting; // No more LO changes required, save some time and jump over the code
freq_t local_IF; freq_t local_IF;
#ifdef __SPUR__
spur_second_pass = false; spur_second_pass = false;
again: // Spur reduction jumps to here for second measurement again: // Spur reduction jumps to here for second measurement
#endif
local_IF=0; // to get rid of warning local_IF=0; // to get rid of warning
#ifdef TINYSA4 #ifdef TINYSA4
@ -3189,10 +3192,10 @@ sweep_again: // stay in sweep loop when output mo
// START_PROFILE // START_PROFILE
if (i == 0) { // Prepare peak finding if (i == 0 || frequencies[i] < actual_rbw_x10 * 200) { // Prepare peak finding
cur_max = 0; // Always at least one maximum cur_max = 0; // Always at least one maximum
temppeakIndex = 0; temppeakIndex = 0;
temppeakLevel = actual_t[i]; temppeakLevel = actual_t[0];
max_index[0] = 0; max_index[0] = 0;
downslope = true; downslope = true;
} }
@ -3342,7 +3345,7 @@ sweep_again: // stay in sweep loop when output mo
#endif #endif
// -------------------------- auto attenuate ---------------------------------- // -------------------------- auto attenuate ----------------------------------
#ifdef TINYSA4 #ifdef TINYSA4
#define AUTO_TARGET_LEVEL -30 #define AUTO_TARGET_LEVEL -35
#else #else
#define AUTO_TARGET_LEVEL -25 #define AUTO_TARGET_LEVEL -25
#endif #endif
@ -4598,9 +4601,9 @@ void reset_calibration(void)
#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)
{ {
#ifdef __CALIBRATE__
int local_test_status; int local_test_status;
int old_sweep_points = setting._sweep_points; int old_sweep_points = setting._sweep_points;
in_selftest = true; in_selftest = true;
@ -4681,8 +4684,8 @@ quit:
sweep_mode = SWEEP_ENABLE; sweep_mode = SWEEP_ENABLE;
set_refer_output(-1); set_refer_output(-1);
reset_settings(M_LOW); reset_settings(M_LOW);
#endif
} }
#endif
#pragma GCC pop_options #pragma GCC pop_options

@ -104,7 +104,7 @@ static uint8_t shiftIn(void)
}while(--i); }while(--i);
#else #else
SPI2_CLK_HIGH; SPI2_CLK_HIGH;
value|=SPI2_portSDO; value =SPI2_portSDO;
SPI2_CLK_LOW; SPI2_CLK_LOW;
value<<=1; value<<=1;
SPI2_CLK_HIGH; SPI2_CLK_HIGH;
@ -186,43 +186,46 @@ uint16_t SI4432_Sel = GPIO_RX_SEL; // currently selected SI4432
#define SELECT_DELAY 10 #define SELECT_DELAY 10
void SI4432_shiftOutDword(uint32_t buf, uint16_t size) { void SI4432_shiftOutDword(uint32_t buf, uint16_t size) {
palClearPad(GPIOC, SI_nSEL[SI4432_Sel]); uint16_t port = SI_nSEL[SI4432_Sel];
palClearPad(GPIOC, port);
do{ do{
shiftOut(buf); shiftOut(buf);
buf>>=8; buf>>=8;
}while(--size); }while(--size);
palSetPad(GPIOC, SI_nSEL[SI4432_Sel]); palSetPad(GPIOC, port);
} }
#ifndef SI4432_Write_Byte #ifndef SI4432_Write_Byte
void SI4432_Write_Byte(uint8_t ADR, uint8_t DATA ) void SI4432_Write_Byte(uint8_t ADR, uint8_t DATA )
{ {
uint16_t port = SI_nSEL[SI4432_Sel];
// if (SI4432_guard) // if (SI4432_guard)
// while(1) ; // while(1) ;
// SI4432_guard = 1; // SI4432_guard = 1;
// SPI2_CLK_LOW; // SPI2_CLK_LOW;
palClearPad(GPIOC, SI_nSEL[SI4432_Sel]); palClearPad(GPIOC, port);
// chThdSleepMicroseconds(SELECT_DELAY); // chThdSleepMicroseconds(SELECT_DELAY);
ADR |= 0x80 ; // RW = 1 ADR |= 0x80 ; // RW = 1
shiftOut( ADR ); shiftOut( ADR );
shiftOut( DATA ); shiftOut( DATA );
palSetPad(GPIOC, SI_nSEL[SI4432_Sel]); palSetPad(GPIOC, port);
// SI4432_guard = 0; // SI4432_guard = 0;
} }
void SI4432_Write_2_Byte(uint8_t ADR, uint8_t DATA1, uint8_t DATA2) void SI4432_Write_2_Byte(uint8_t ADR, uint8_t DATA1, uint8_t DATA2)
{ {
uint16_t port = SI_nSEL[SI4432_Sel];
// if (SI4432_guard) // if (SI4432_guard)
// while(1) ; // while(1) ;
// SI4432_guard = 1; // SI4432_guard = 1;
// SPI2_CLK_LOW; // SPI2_CLK_LOW;
palClearPad(GPIOC, SI_nSEL[SI4432_Sel]); palClearPad(GPIOC, port);
// chThdSleepMicroseconds(SELECT_DELAY); // chThdSleepMicroseconds(SELECT_DELAY);
ADR |= 0x80 ; // RW = 1 ADR |= 0x80 ; // RW = 1
shiftOut( ADR ); shiftOut( ADR );
shiftOut( DATA1 ); shiftOut( DATA1 );
shiftOut( DATA2 ); shiftOut( DATA2 );
palSetPad(GPIOC, SI_nSEL[SI4432_Sel]); palSetPad(GPIOC, port);
// SI4432_guard = 0; // SI4432_guard = 0;
} }
#endif #endif
@ -230,18 +233,19 @@ void SI4432_Write_2_Byte(uint8_t ADR, uint8_t DATA1, uint8_t DATA2)
#ifndef SI4432_Write_3_Byte #ifndef SI4432_Write_3_Byte
void SI4432_Write_3_Byte(uint8_t ADR, uint8_t DATA1, uint8_t DATA2, uint8_t DATA3) void SI4432_Write_3_Byte(uint8_t ADR, uint8_t DATA1, uint8_t DATA2, uint8_t DATA3)
{ {
uint16_t port = SI_nSEL[SI4432_Sel];
// if (SI4432_guard) // if (SI4432_guard)
// while(1) ; // while(1) ;
// SI4432_guard = 1; // SI4432_guard = 1;
// SPI2_CLK_LOW; // SPI2_CLK_LOW;
palClearPad(GPIOC, SI_nSEL[SI4432_Sel]); palClearPad(GPIOC, port);
// chThdSleepMicroseconds(SELECT_DELAY); // chThdSleepMicroseconds(SELECT_DELAY);
ADR |= 0x80 ; // RW = 1 ADR |= 0x80 ; // RW = 1
shiftOut( ADR ); shiftOut( ADR );
shiftOut( DATA1 ); shiftOut( DATA1 );
shiftOut( DATA2 ); shiftOut( DATA2 );
shiftOut( DATA3 ); shiftOut( DATA3 );
palSetPad(GPIOC, SI_nSEL[SI4432_Sel]); palSetPad(GPIOC, port);
// SI4432_guard = 0; // SI4432_guard = 0;
} }
#endif #endif
@ -249,14 +253,15 @@ void SI4432_Write_3_Byte(uint8_t ADR, uint8_t DATA1, uint8_t DATA2, uint8_t DATA
uint8_t SI4432_Read_Byte(uint8_t ADR) uint8_t SI4432_Read_Byte(uint8_t ADR)
{ {
uint8_t DATA ; uint8_t DATA ;
uint16_t port = SI_nSEL[SI4432_Sel];
// if (SI4432_guard) // if (SI4432_guard)
// while(1) ; // while(1) ;
// SI4432_guard = 1; // SI4432_guard = 1;
// SPI2_CLK_LOW; // SPI2_CLK_LOW;
palClearPad(GPIOC, SI_nSEL[SI4432_Sel]); palClearPad(GPIOC, port);
shiftOut(ADR); shiftOut(ADR);
DATA = shiftIn(); DATA = shiftIn();
palSetPad(GPIOC, SI_nSEL[SI4432_Sel]); palSetPad(GPIOC, port);
// SI4432_guard = 0; // SI4432_guard = 0;
return DATA ; return DATA ;
} }

@ -203,8 +203,8 @@ static void shiftOutBuf(uint8_t *buf, uint16_t size) {
} }
#endif #endif
int SI4432_step_delay = 1500; uint32_t SI4432_step_delay = 1500;
int SI4432_offset_delay = 1500; uint32_t SI4432_offset_delay = 1500;
#define MINIMUM_WAIT_FOR_RSSI 280 #define MINIMUM_WAIT_FOR_RSSI 280
#ifdef __SI4432__ #ifdef __SI4432__

@ -613,6 +613,7 @@ UI_FUNCTION_CALLBACK(menu_autosettings_cb)
// draw_cal_status(); // draw_cal_status();
} }
#ifdef __CALIBRATE__
static UI_FUNCTION_CALLBACK(menu_calibrate_cb) static UI_FUNCTION_CALLBACK(menu_calibrate_cb)
{ {
(void)data; (void)data;
@ -626,6 +627,7 @@ static UI_FUNCTION_CALLBACK(menu_calibrate_cb)
break; break;
} }
} }
#endif
static UI_FUNCTION_ADV_CALLBACK(menu_scanning_speed_acb) static UI_FUNCTION_ADV_CALLBACK(menu_scanning_speed_acb)
{ {
@ -1937,14 +1939,16 @@ static const menuitem_t menu_measure[] = {
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
#ifdef __CALIBRATE__
static const menuitem_t menu_calibrate[] = static const menuitem_t menu_calibrate[] =
{ {
{ MT_FORM | MT_TITLE, 0, "Connect HIGH and LOW", NULL}, { MT_FORM | MT_TITLE, 0, "Connect HIGH and LOW", NULL},
{ MT_FORM | MT_CALLBACK, 0, "CALIBRATE", menu_calibrate_cb}, { MT_FORM | MT_CALLBACK, 0, "CALIBRATE", menu_calibrate_cb},
{ MT_FORM | MT_CALLBACK, 0, "RESET CALBRATION", menu_calibrate_cb}, { MT_FORM | MT_CALLBACK, 0, "RESET CALBRATION", menu_calibrate_cb},
{ MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel { MT_FORM | MT_NONE, 0, NULL, NULL } // sentinel
}; };
#endif
#ifdef __USE_SERIAL_CONSOLE__ #ifdef __USE_SERIAL_CONSOLE__
//19200, 38400, 57600, 74800, 115200, 230400, 460800, 921600, 1843200, 3686400 //19200, 38400, 57600, 74800, 115200, 230400, 460800, 921600, 1843200, 3686400
@ -1992,7 +1996,9 @@ const menuitem_t menu_touch[] = {
static const menuitem_t menu_config[] = { static const menuitem_t menu_config[] = {
{ MT_SUBMENU, 0, "TOUCH", menu_touch}, { MT_SUBMENU, 0, "TOUCH", menu_touch},
{ MT_CALLBACK, CONFIG_MENUITEM_SELFTEST, "SELF TEST", menu_config_cb}, { MT_CALLBACK, CONFIG_MENUITEM_SELFTEST, "SELF TEST", menu_config_cb},
#ifdef __CALIBRATE__
{ MT_SUBMENU, 0, "LEVEL CAL", menu_calibrate}, { MT_SUBMENU, 0, "LEVEL CAL", menu_calibrate},
#endif
{ MT_CALLBACK, CONFIG_MENUITEM_VERSION, "VERSION", menu_config_cb}, { MT_CALLBACK, CONFIG_MENUITEM_VERSION, "VERSION", menu_config_cb},
#ifdef __USE_SERIAL_CONSOLE__ #ifdef __USE_SERIAL_CONSOLE__
{ MT_SUBMENU, 0, "CONNECTION", menu_connection}, { MT_SUBMENU, 0, "CONNECTION", menu_connection},

Loading…
Cancel
Save

Powered by TurnKey Linux.