|
|
|
@ -624,16 +624,16 @@ void toggle_AGC(void)
|
|
|
|
void auto_set_AGC_LNA(int auto_set) // Adapt the AGC setting if needed
|
|
|
|
void auto_set_AGC_LNA(int auto_set) // Adapt the AGC setting if needed
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef __SI4432__
|
|
|
|
#ifdef __SI4432__
|
|
|
|
static unsigned char old_v;
|
|
|
|
static unsigned char old_v[2];
|
|
|
|
unsigned char v;
|
|
|
|
unsigned char v;
|
|
|
|
if (auto_set)
|
|
|
|
if (auto_set)
|
|
|
|
v = 0x60; // Enable AGC and disable LNA
|
|
|
|
v = 0x60; // Enable AGC and disable LNA
|
|
|
|
else
|
|
|
|
else
|
|
|
|
v = 0x40; // Disable AGC and enable LNA
|
|
|
|
v = 0x50; // Disable AGC and enable LNA
|
|
|
|
if (old_v != v) {
|
|
|
|
if (old_v[MODE_SELECT(setting.mode)] != v) {
|
|
|
|
SI4432_Sel = SI4432_RX ;
|
|
|
|
SI4432_Sel = MODE_SELECT(setting.mode);
|
|
|
|
SI4432_Write_Byte(SI4432_AGC_OVERRIDE, v);
|
|
|
|
SI4432_Write_Byte(SI4432_AGC_OVERRIDE, v);
|
|
|
|
old_v = v;
|
|
|
|
old_v[MODE_SELECT(setting.mode)] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1676,7 +1676,7 @@ modulation_again:
|
|
|
|
|
|
|
|
|
|
|
|
set_freq (2, IF_2 + lf); // Scanning LO up to IF2
|
|
|
|
set_freq (2, IF_2 + lf); // Scanning LO up to IF2
|
|
|
|
set_freq (3, IF_2 - 433800000); // Down from IF2 to fixed second IF in Ultra SA mode
|
|
|
|
set_freq (3, IF_2 - 433800000); // Down from IF2 to fixed second IF in Ultra SA mode
|
|
|
|
set_freq (SI4432_LO, 433800000); // Second IF fixe in Ultra SA mode
|
|
|
|
set_freq (SI4432_LO, 433800000); // Second IF fixed in Ultra SA mode
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#ifdef __SI4432__
|
|
|
|
#ifdef __SI4432__
|
|
|
|
if (setting.mode == M_LOW && !setting.tracking && S_STATE(setting.below_IF)) // if in low input mode and below IF
|
|
|
|
if (setting.mode == M_LOW && !setting.tracking && S_STATE(setting.below_IF)) // if in low input mode and below IF
|
|
|
|
@ -1816,6 +1816,7 @@ static bool sweep(bool break_on_operation)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
float RSSI;
|
|
|
|
float RSSI;
|
|
|
|
int16_t downslope;
|
|
|
|
int16_t downslope;
|
|
|
|
|
|
|
|
uint32_t peak_freq = 0;
|
|
|
|
// if (setting.mode== -1)
|
|
|
|
// if (setting.mode== -1)
|
|
|
|
// return;
|
|
|
|
// return;
|
|
|
|
// START_PROFILE;
|
|
|
|
// START_PROFILE;
|
|
|
|
@ -1864,6 +1865,19 @@ sweep_again: // stay in sweep loop when output mo
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------- in loop AGC ---------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!in_selftest && setting.mode == M_HIGH && S_IS_AUTO(setting.agc) && UNIT_IS_LOG(setting.unit)) {
|
|
|
|
|
|
|
|
if (RSSI > -55) {
|
|
|
|
|
|
|
|
peak_freq = frequencies[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (peak_freq != 0 && frequencies[i] - peak_freq < 1700000)
|
|
|
|
|
|
|
|
auto_set_AGC_LNA(false);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
auto_set_AGC_LNA(TRUE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Delay between points if needed, (all delays can apply in SI4432 fill)
|
|
|
|
// Delay between points if needed, (all delays can apply in SI4432 fill)
|
|
|
|
if (setting.measure_sweep_time_us == 0){ // If not already in buffer
|
|
|
|
if (setting.measure_sweep_time_us == 0){ // If not already in buffer
|
|
|
|
if (setting.additional_step_delay_us && (MODE_INPUT(setting.mode) || setting.modulation == MO_NONE)) { // No delay when modulation is active
|
|
|
|
if (setting.additional_step_delay_us && (MODE_INPUT(setting.mode) || setting.modulation == MO_NONE)) { // No delay when modulation is active
|
|
|
|
@ -2090,13 +2104,16 @@ sweep_again: // stay in sweep loop when output mo
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------------------------- auto AGC ----------------------------------
|
|
|
|
// ---------------------------------- auto AGC ----------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
if (!in_selftest && MODE_INPUT(setting.mode) && S_IS_AUTO(setting.agc) && UNIT_IS_LINEAR(setting.unit)) { // Auto AGC in linear mode
|
|
|
|
|
|
|
|
|
|
|
|
if (!in_selftest && MODE_INPUT(setting.mode) && S_IS_AUTO(setting.agc)) {
|
|
|
|
float actual_max_level = actual_t[max_index[0]] - get_attenuation();
|
|
|
|
float actual_max_level = actual_t[max_index[0]] - get_attenuation();
|
|
|
|
|
|
|
|
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);
|
|
|
|
auto_set_AGC_LNA(false);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
auto_set_AGC_LNA(TRUE);
|
|
|
|
auto_set_AGC_LNA(TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------- auto reflevel ---------------------------------
|
|
|
|
// -------------------------- auto reflevel ---------------------------------
|
|
|
|
|