grc: fix required gain

This commit is contained in:
Jan Hamal Dvořák 2024-08-03 10:00:36 +02:00
parent 347582cfc1
commit bf2491f612
2 changed files with 14 additions and 12 deletions

View file

@ -374,7 +374,7 @@ blocks:
freq7: 100e6
freq8: 100e6
freq9: 100e6
gain0: '0'
gain0: '30'
gain1: '10'
gain10: '10'
gain11: '10'

View file

@ -22,7 +22,7 @@
#include <stdlib.h>
#define VREG_VOLTAGE VREG_VOLTAGE_1_20
#define CLK_SYS_HZ (288 * MHZ)
#define CLK_SYS_HZ (300 * MHZ)
#define INIT_SAMPLE_RATE 200000
#define INIT_FREQ 94600000
@ -559,11 +559,13 @@ inline static struct IQ next_sample()
I *= gain;
I /= 1024;
I *= max_amplitude_mul;
I += 127.4 * (1 << 16);
I /= (1 << 16);
Q *= gain;
Q /= 1024;
Q *= max_amplitude_mul;
Q += 127.4 * (1 << 16);
Q /= (1 << 16);
return (struct IQ){ I, Q };
@ -586,19 +588,19 @@ static void rf_rx(void)
int64_t I = IQ.I;
int64_t Q = IQ.Q;
if (I > 127)
I = 127;
else if (I < -128)
I = -128;
if (I < 0)
I = 0;
else if (I > 255)
I = 255;
*blockptr++ = (uint8_t)I + 128;
*blockptr++ = I;
if (Q > 127)
Q = 127;
else if (Q < -128)
Q = -128;
if (Q < 0)
Q = 0;
else if (Q > 255)
Q = 255;
*blockptr++ = (uint8_t)Q + 128;
*blockptr++ = Q;
}
if (queue_try_add(&iq_queue, &block)) {