From b0e7c605a72c6562016f9a4b5c3b02e994f9fe9e Mon Sep 17 00:00:00 2001 From: OSQZSS Date: Sun, 28 Jun 2015 09:46:31 +0900 Subject: [PATCH] Optional sine wave look-up table --- gpssim.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/gpssim.c b/gpssim.c index 4fe4693..cca6b24 100644 --- a/gpssim.c +++ b/gpssim.c @@ -54,6 +54,10 @@ #define SC08 (8) #define SC16 (16) +#define ADC_GAIN (250) // for bladeRF txvga1 = -25dB with 50dB external attenuation + +//#define _SINE_LUT +#ifdef _SINE_LUT int sinTable512[] = { 0,6,12,18,25,31,37,43,50,56,62, 68,75,81,87,93,99,106,112,118,124, @@ -161,6 +165,7 @@ int cosTable512[] = { 495,496,498,499,500,502,503,504,505,506, 507,508,508,509,510,510,511,511,511,511,511 }; +#endif typedef struct { @@ -1142,7 +1147,12 @@ int main(int argc, char *argv[]) unsigned long prevwrd; int nib; +#ifdef _SINE_LUT int ip,qp; + int iTable; +#else + double ip,qp; +#endif void *iq_buff = NULL; gpstime_t grx0,grx1; @@ -1165,8 +1175,6 @@ int main(int argc, char *argv[]) int result; - int iTable; - //////////////////////////////////////////////////////////// // Read options //////////////////////////////////////////////////////////// @@ -1472,15 +1480,23 @@ int main(int argc, char *argv[]) { for (isamp=0; isamp>2); - chan[i].iq_buff[isamp*2+1] = (short)(qp>>2); + chan[i].iq_buff[isamp*2] = (short)(ip>>1); + chan[i].iq_buff[isamp*2+1] = (short)(qp>>1); +#else + ip = chan[i].dataBit * chan[i].codeCA * cos(2.0*PI*chan[i].carr_phase); + qp = chan[i].dataBit * chan[i].codeCA * sin(2.0*PI*chan[i].carr_phase); + // Sotre I/Q samples into buffer + chan[i].iq_buff[isamp*2] = (short)(ADC_GAIN*ip); + chan[i].iq_buff[isamp*2+1] = (short)(ADC_GAIN*qp); +#endif // Update code phase chan[i].code_phase += chan[i].f_code * delt;