PC control working

tinySA-v0.2
erikkaashoek 6 years ago
parent eef33fa47f
commit 0827aaa16d

@ -138,6 +138,8 @@ static THD_FUNCTION(Thread1, arg)
// call from lowest level to save stack space
self_test(setting.test);
sweep_mode = SWEEP_ENABLE;
} else if (sweep_mode & SWEEP_REMOTE) {
sweep_remote();
} else if (sweep_mode & SWEEP_CALIBRATE) {
// call from lowest level to save stack space
calibrate();
@ -2261,6 +2263,7 @@ static const VNAShellCommand commands[] =
{ "attenuate", cmd_attenuate, 0 },
{ "rbw", cmd_rbw, 0 },
{ "mode", cmd_mode, 0 },
{ "spur", cmd_spur, 0 },
{ "selftest", cmd_selftest, 0 },
{ "x", cmd_x, 0 },
{ "i", cmd_i, 0 },

@ -150,10 +150,11 @@ enum {
#define MODE_LOW(x) ((x) == M_LOW || (x) == M_GENLOW )
#define MODE_SELECT(x) (MODE_HIGH(x) ? 1 : 0)
#define SWEEP_ENABLE 0x01
#define SWEEP_ONCE 0x02
#define SWEEP_ENABLE 0x01
#define SWEEP_ONCE 0x02
#define SWEEP_CALIBRATE 0x04
#define SWEEP_SELFTEST 0x08
#define SWEEP_REMOTE 0x10
extern int8_t sweep_mode;
extern const char *info_about[];
@ -214,7 +215,7 @@ void set_modulation(int);
void set_measurement(int);
// extern int settingSpeed;
//extern int setting.step_delay;
void sweep_remote(void);
#ifdef __VNA__
/*
* dsp.c

@ -31,6 +31,21 @@ VNA_SHELL_FUNCTION(cmd_mode)
goto usage;
}
VNA_SHELL_FUNCTION(cmd_spur)
{
if (argc != 1) {
usage:
shell_printf("usage: spur on|off\r\n");
return;
}
if (strcmp(argv[0],"on") == 0) {
setting.spur = 1;
} else if (strcmp(argv[0],"off") == 0) {
setting.spur = 0;
} else
goto usage;
}
VNA_SHELL_FUNCTION(cmd_attenuate)
{
if (argc != 1) {
@ -183,31 +198,39 @@ return; // Don't use!!!!
VNA_SHELL_FUNCTION(cmd_o)
{
(void) argc;
return;
uint32_t value = my_atoi(argv[0]);
// if (VFO == 0)
// setting.frequency_IF = value;
set_freq(VFO, value);
if (VFO == 0)
setting.frequency_IF = value;
// set_freq(VFO, value);
}
VNA_SHELL_FUNCTION(cmd_d)
{
(void) argc;
int32_t a = my_atoi(argv[0]);
setting.drive = a;
// setting.drive = a;
}
VNA_SHELL_FUNCTION(cmd_a)
{
(void)argc;
if (argc != 1) {
shell_printf("a=%d\r\n", frequencyStart);
return;
}
int32_t value = my_atoi(argv[0]);
frequencyStart = value;
}
VNA_SHELL_FUNCTION(cmd_b)
{
(void)argc;
if (argc != 1) {
shell_printf("b=%d\r\n", frequencyStop);
return;
}
int32_t value = my_atoi(argv[0]);
frequencyStop = value;
}
@ -221,6 +244,10 @@ VNA_SHELL_FUNCTION(cmd_t)
VNA_SHELL_FUNCTION(cmd_e)
{
(void)argc;
if (argc != 1) {
shell_printf("e=%d\r\n", setting.tracking);
return;
}
setting.tracking = my_atoi(argv[0]);
if (setting.tracking == -1)
setting.tracking = false;
@ -234,45 +261,54 @@ VNA_SHELL_FUNCTION(cmd_e)
VNA_SHELL_FUNCTION(cmd_s)
{
(void)argc;
if (argc != 1) {
shell_printf("s=%d\r\n", points);
return;
}
points = my_atoi(argv[0]);
}
VNA_SHELL_FUNCTION(cmd_m)
void sweep_remote(void)
{
(void)argc;
(void)argv;
set_mode(0);
setting.tracking = false; //Default test setup
setting.step_atten = false;
set_attenuation(0);
set_reflevel(-10);
set_sweep_frequency(ST_START,frequencyStart - setting.frequency_IF );
set_sweep_frequency(ST_STOP, frequencyStop - setting.frequency_IF);
draw_cal_status();
pause_sweep();
int32_t f_step = (frequencyStop-frequencyStart)/ points;
palClearPad(GPIOB, GPIOB_LED); // disable led and wait for voltage stabilization
int old_step = setting.frequency_step;
uint32_t f_step = (frequencyStop-frequencyStart)/ points;
setting.frequency_step = f_step;
update_rbw();
chThdSleepMilliseconds(10);
streamPut(shell_stream, '{');
dirty = true;
for (int i = 0; i<points; i++) {
float val = perform(false, i, frequencyStart - setting.frequency_IF + f_step * i, setting.tracking);
streamPut(shell_stream, 'x');
int v = val*2 + 256;
streamPut(shell_stream, (uint8_t)(v & 0xFF));
streamPut(shell_stream, (uint8_t)((v>>8) & 0xFF));
// enable led
if (operation_requested)
break;
float val = perform(false, i, frequencyStart - setting.frequency_IF + f_step * i, false);
streamPut(shell_stream, 'x');
int v = val*2 + 256;
streamPut(shell_stream, (uint8_t)(v & 0xFF));
streamPut(shell_stream, (uint8_t)((v>>8) & 0xFF));
// enable led
}
streamPut(shell_stream, '}');
setting.frequency_step = old_step;
update_rbw();
resume_sweep();
palSetPad(GPIOB, GPIOB_LED);
sweep_mode = 0;
}
VNA_SHELL_FUNCTION(cmd_m)
{
(void)argc;
(void)argv;
// set_mode(0);
// setting.tracking = false; //Default test setup
// setting.step_atten = false;
// set_attenuation(0);
// set_reflevel(-10);
// set_sweep_frequency(ST_START,frequencyStart - setting.frequency_IF );
// set_sweep_frequency(ST_STOP, frequencyStop - setting.frequency_IF);
// draw_cal_status();
pause_sweep();
// update_rbw();
chThdSleepMilliseconds(10);
sweep_mode = SWEEP_REMOTE;
// update_rbw();
}
VNA_SHELL_FUNCTION(cmd_p)

@ -768,6 +768,7 @@ static const int spur_table[] =
22960000,
28960000,
29800000,
38105000,
49500000,
#ifdef IF_AT_4339
780000, // 433.9MHz table

@ -1501,7 +1501,7 @@ static void menu_item_modify_attribute(
mark = true;
}
} else if (menu == menu_stimulus) {
if (item == 5 /* PAUSE */ && !(sweep_mode&SWEEP_ENABLE)) {
if (item == 6 && setting.spur) {
mark = true;
}
} else if (menu == menu_average) {

Loading…
Cancel
Save

Powered by TurnKey Linux.