agc: update squelch threshold more often

This fixes the noise level tracking in test cases like the loopback
test where the signal has already ramped up before the first noise level
update.
This commit is contained in:
Thomas Kolb 2024-05-25 18:16:24 +02:00
parent ca241f266b
commit 5f8346d290

View file

@ -184,7 +184,7 @@ static enum squelch_state_t update_and_check_squelch(layer1_rx_t *rx, unsigned i
float level = agc_crcf_get_rssi(rx->agc); float level = agc_crcf_get_rssi(rx->agc);
enum squelch_state_t result = SQUELCH_CLOSED; enum squelch_state_t result = SQUELCH_CLOSED;
if((sample_idx & 0xFF) == 0) { // every 256 samples if((sample_idx & 0x3F) == 0) { // every 64 samples
if(level < rx->noise_floor_level) { if(level < rx->noise_floor_level) {
rx->noise_floor_level = level; rx->noise_floor_level = level;
} else { } else {
@ -197,7 +197,7 @@ static enum squelch_state_t update_and_check_squelch(layer1_rx_t *rx, unsigned i
switch(agc_crcf_squelch_get_status(rx->agc)) { switch(agc_crcf_squelch_get_status(rx->agc)) {
case LIQUID_AGC_SQUELCH_RISE: case LIQUID_AGC_SQUELCH_RISE:
DEBUG_LOG("Squelch disabled at #%u RSSI = %.3f dB [thr: %.3f dB]\n", sample_idx, level, agc_crcf_squelch_get_threshold(rx->agc)); DEBUG_LOG("Squelch disabled at #%zu RSSI = %.3f dB [thr: %.3f dB]\n", rx->sample_index, level, agc_crcf_squelch_get_threshold(rx->agc));
result = SQUELCH_JUST_OPENED; result = SQUELCH_JUST_OPENED;
break; break;
@ -206,7 +206,7 @@ static enum squelch_state_t update_and_check_squelch(layer1_rx_t *rx, unsigned i
break; break;
case LIQUID_AGC_SQUELCH_FALL: case LIQUID_AGC_SQUELCH_FALL:
DEBUG_LOG("Squelch enabled at #%u RSSI = %.3f dB [thr: %.3f dB]\n", sample_idx, level, agc_crcf_squelch_get_threshold(rx->agc)); DEBUG_LOG("Squelch enabled at #%zu RSSI = %.3f dB [thr: %.3f dB]\n", rx->sample_index, level, agc_crcf_squelch_get_threshold(rx->agc));
// fall through // fall through
case LIQUID_AGC_SQUELCH_SIGNALLO: case LIQUID_AGC_SQUELCH_SIGNALLO:
case LIQUID_AGC_SQUELCH_ENABLED: case LIQUID_AGC_SQUELCH_ENABLED: