|
|
|
@ -258,42 +258,48 @@ static void cmd_reset(BaseSequentialStream *chp, int argc, char *argv[])
|
|
|
|
;
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DELAY_ON_GAIN_CHANGE 3
|
|
|
|
|
|
|
|
|
|
|
|
int set_frequency(int freq)
|
|
|
|
int set_frequency(int freq)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int delay = 0;
|
|
|
|
bool gain_changed = false;
|
|
|
|
if (frequency == freq)
|
|
|
|
if (frequency == freq)
|
|
|
|
return delay;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (freq > 1400000000 && frequency <= 1400000000) {
|
|
|
|
if (freq > 1400000000 && frequency <= 1400000000) {
|
|
|
|
tlv320aic3204_set_gain(95, 95);
|
|
|
|
tlv320aic3204_set_gain(95, 95);
|
|
|
|
delay += 10;
|
|
|
|
gain_changed = true;
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
if (freq > 1200000000 && frequency <= 1200000000) {
|
|
|
|
if (freq > 1200000000 && frequency <= 1200000000) {
|
|
|
|
tlv320aic3204_set_gain(85, 85);
|
|
|
|
tlv320aic3204_set_gain(85, 85);
|
|
|
|
delay += 10;
|
|
|
|
gain_changed = true;
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
if (freq > 900000000 && frequency <= 900000000) {
|
|
|
|
if (freq > 900000000 && frequency <= 900000000) {
|
|
|
|
tlv320aic3204_set_gain(75, 75);
|
|
|
|
tlv320aic3204_set_gain(75, 75);
|
|
|
|
delay += 10;
|
|
|
|
gain_changed = true;
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
if (freq > 600000000 && frequency <= 600000000) {
|
|
|
|
if (freq > 600000000 && frequency <= 600000000) {
|
|
|
|
tlv320aic3204_set_gain(50, 50);
|
|
|
|
tlv320aic3204_set_gain(50, 50);
|
|
|
|
delay += 10;
|
|
|
|
gain_changed = true;
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
if (freq > FREQ_HARMONICS && frequency <= FREQ_HARMONICS) {
|
|
|
|
if (freq > FREQ_HARMONICS && frequency <= FREQ_HARMONICS) {
|
|
|
|
tlv320aic3204_set_gain(40, 40);
|
|
|
|
tlv320aic3204_set_gain(40, 40);
|
|
|
|
delay += 10;
|
|
|
|
gain_changed = true;
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
if (freq <= FREQ_HARMONICS && frequency > FREQ_HARMONICS) {
|
|
|
|
if (freq <= FREQ_HARMONICS && frequency > FREQ_HARMONICS) {
|
|
|
|
tlv320aic3204_set_gain(0, 0);
|
|
|
|
tlv320aic3204_set_gain(0, 0);
|
|
|
|
delay += 10;
|
|
|
|
gain_changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int8_t ds = drive_strength;
|
|
|
|
int8_t ds = drive_strength;
|
|
|
|
if (ds == DRIVE_STRENGTH_AUTO) {
|
|
|
|
if (ds == DRIVE_STRENGTH_AUTO) {
|
|
|
|
ds = freq > FREQ_HARMONICS ? SI5351_CLK_DRIVE_STRENGTH_8MA : SI5351_CLK_DRIVE_STRENGTH_2MA;
|
|
|
|
ds = freq > FREQ_HARMONICS ? SI5351_CLK_DRIVE_STRENGTH_8MA : SI5351_CLK_DRIVE_STRENGTH_2MA;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delay += si5351_set_frequency_with_offset(freq, frequency_offset, ds);
|
|
|
|
|
|
|
|
|
|
|
|
int delay = si5351_set_frequency_with_offset(freq, frequency_offset, ds);
|
|
|
|
|
|
|
|
if (gain_changed && delay < DELAY_ON_GAIN_CHANGE) {
|
|
|
|
|
|
|
|
delay = DELAY_ON_GAIN_CHANGE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
frequency = freq;
|
|
|
|
frequency = freq;
|
|
|
|
return delay;
|
|
|
|
return delay;
|
|
|
|
@ -642,6 +648,8 @@ ensure_edit_config(void)
|
|
|
|
cal_status = 0;
|
|
|
|
cal_status = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DELAY_CHANNEL_CHANGE 1
|
|
|
|
|
|
|
|
|
|
|
|
// main loop for measurement
|
|
|
|
// main loop for measurement
|
|
|
|
bool sweep(bool break_on_operation)
|
|
|
|
bool sweep(bool break_on_operation)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -659,7 +667,7 @@ bool sweep(bool break_on_operation)
|
|
|
|
(*sample_func)(measured[0][i]);
|
|
|
|
(*sample_func)(measured[0][i]);
|
|
|
|
|
|
|
|
|
|
|
|
tlv320aic3204_select_in1(); // CH1:TRANSMISSION
|
|
|
|
tlv320aic3204_select_in1(); // CH1:TRANSMISSION
|
|
|
|
wait_dsp(delay);
|
|
|
|
wait_dsp(delay + DELAY_CHANNEL_CHANGE);
|
|
|
|
|
|
|
|
|
|
|
|
/* calculate transmission coeficient */
|
|
|
|
/* calculate transmission coeficient */
|
|
|
|
(*sample_func)(measured[1][i]);
|
|
|
|
(*sample_func)(measured[1][i]);
|
|
|
|
|