Optimize frequency shift
This commit is contained in:
parent
e694692a8c
commit
cb47fd3aa5
1 changed files with 25 additions and 27 deletions
52
src/main.c
52
src/main.c
|
@ -500,7 +500,7 @@ static void rf_rx(void)
|
||||||
* gain but keep it slightly below the maximum to make
|
* gain but keep it slightly below the maximum to make
|
||||||
* sure we do not overshoot often.
|
* sure we do not overshoot often.
|
||||||
*/
|
*/
|
||||||
max_amplitude = max_amplitude / 2;
|
max_amplitude /= 2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We are allowing the counters to only go as high
|
* We are allowing the counters to only go as high
|
||||||
|
@ -509,40 +509,38 @@ static void rf_rx(void)
|
||||||
max_amplitude /= sample_rate;
|
max_amplitude /= sample_rate;
|
||||||
|
|
||||||
for (int i = 0; i < IQ_SAMPLES; i++) {
|
for (int i = 0; i < IQ_SAMPLES; i++) {
|
||||||
uint32_t cos_neg = *cos_ptr++;
|
int sI = 0, sQ = 0;
|
||||||
uint32_t cos_pos = *cos_ptr++;
|
|
||||||
int I1 = cos_neg - cos_pos;
|
|
||||||
|
|
||||||
cos_neg = *cos_ptr++;
|
/*
|
||||||
cos_pos = *cos_ptr++;
|
* I: +I1 -I3 +Q2 -Q4
|
||||||
int I2 = cos_neg - cos_pos;
|
* Q: +Q1 -Q3 -I2 +I4
|
||||||
|
*/
|
||||||
|
sI += *cos_ptr++;
|
||||||
|
sI -= *cos_ptr++;
|
||||||
|
|
||||||
cos_neg = *cos_ptr++;
|
sQ -= *cos_ptr++;
|
||||||
cos_pos = *cos_ptr++;
|
sQ += *cos_ptr++;
|
||||||
int I3 = cos_neg - cos_pos;
|
|
||||||
|
|
||||||
cos_neg = *cos_ptr++;
|
sI -= *cos_ptr++;
|
||||||
cos_pos = *cos_ptr++;
|
sI += *cos_ptr++;
|
||||||
int I4 = cos_neg - cos_pos;
|
|
||||||
|
|
||||||
uint32_t sin_neg = *sin_ptr++;
|
sQ += *cos_ptr++;
|
||||||
uint32_t sin_pos = *sin_ptr++;
|
sQ -= *cos_ptr++;
|
||||||
int Q1 = sin_neg - sin_pos;
|
|
||||||
|
|
||||||
sin_neg = *sin_ptr++;
|
sQ += *sin_ptr++;
|
||||||
sin_pos = *sin_ptr++;
|
sQ -= *sin_ptr++;
|
||||||
int Q2 = sin_neg - sin_pos;
|
|
||||||
|
|
||||||
sin_neg = *sin_ptr++;
|
sI += *sin_ptr++;
|
||||||
sin_pos = *sin_ptr++;
|
sI -= *sin_ptr++;
|
||||||
int Q3 = sin_neg - sin_pos;
|
|
||||||
|
|
||||||
sin_neg = *sin_ptr++;
|
sQ -= *sin_ptr++;
|
||||||
sin_pos = *sin_ptr++;
|
sQ += *sin_ptr++;
|
||||||
int Q4 = sin_neg - sin_pos;
|
|
||||||
|
|
||||||
int64_t I = I1 - I3 + Q2 - Q4;
|
sI -= *sin_ptr++;
|
||||||
int64_t Q = Q1 - Q3 - I2 + I4;
|
sI += *sin_ptr++;
|
||||||
|
|
||||||
|
int64_t I = sI;
|
||||||
|
int64_t Q = sQ;
|
||||||
|
|
||||||
I *= gain;
|
I *= gain;
|
||||||
I /= max_amplitude;
|
I /= max_amplitude;
|
||||||
|
|
Loading…
Reference in a new issue