diff options
| author | Dimitri Stolnikov <horiz0n@gmx.net> | 2012-04-25 22:32:51 +0200 |
|---|---|---|
| committer | Dimitri Stolnikov <horiz0n@gmx.net> | 2012-04-25 22:32:51 +0200 |
| commit | bad6fb080b774c680f6d1eda4e1a00dad5a8cd20 (patch) | |
| tree | 66e4b25f5b3a2f374fbf81a51e4043dcb1d87926 /src/tuner_e4000.c | |
| parent | 8a1d6d69bdba90195468eb9c666e72e3eed3fe27 (diff) | |
introduce api to configure crystal oscillator frequency
Usually both, the RTL and the tuner ICs use the same clock. Changing the
clock may make sense if you are applying an external clock to the tuner
or to compensate the frequency (and samplerate) error caused by the
original cheap crystal.
This commit covers all tuner drivers except of the Fitipower FC2580
Diffstat (limited to 'src/tuner_e4000.c')
| -rw-r--r-- | src/tuner_e4000.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/tuner_e4000.c b/src/tuner_e4000.c index 60ca91a..5772331 100644 --- a/src/tuner_e4000.c +++ b/src/tuner_e4000.c @@ -22,8 +22,7 @@ /* glue functions to rtl-sdr code */ int -I2CReadByte( - void *pTuner, +I2CReadByte(void *pTuner, unsigned char NoUse, unsigned char RegAddr, unsigned char *pReadingByte @@ -31,10 +30,10 @@ I2CReadByte( { uint8_t data = RegAddr; - if (rtlsdr_i2c_write((rtlsdr_dev_t *)pTuner, E4K_I2C_ADDR, &data, 1) < 0) + if (rtlsdr_i2c_write_fn(pTuner, E4K_I2C_ADDR, &data, 1) < 0) return E4000_I2C_FAIL; - if (rtlsdr_i2c_read((rtlsdr_dev_t *)pTuner, E4K_I2C_ADDR, &data, 1) < 0) + if (rtlsdr_i2c_read_fn(pTuner, E4K_I2C_ADDR, &data, 1) < 0) return E4000_I2C_FAIL; *pReadingByte = data; @@ -54,15 +53,14 @@ I2CWriteByte(void *pTuner, data[0] = RegAddr; data[1] = WritingByte; - if (rtlsdr_i2c_write((rtlsdr_dev_t *)pTuner, E4K_I2C_ADDR, data, 2) < 0) + if (rtlsdr_i2c_write_fn(pTuner, E4K_I2C_ADDR, data, 2) < 0) return E4000_I2C_FAIL; return E4000_I2C_SUCCESS; } int -I2CWriteArray( - void *pTuner, +I2CWriteArray(void *pTuner, unsigned char NoUse, unsigned char RegStartAddr, unsigned char ByteNum, @@ -77,7 +75,7 @@ I2CWriteArray( for(i = 0; i < ByteNum; i++) WritingBuffer[1 + i] = pWritingBytes[i]; - if (rtlsdr_i2c_write((rtlsdr_dev_t *)pTuner, E4K_I2C_ADDR, WritingBuffer, ByteNum + 1) < 0) + if (rtlsdr_i2c_write_fn(pTuner, E4K_I2C_ADDR, WritingBuffer, ByteNum + 1) < 0) return E4000_I2C_FAIL; return E4000_I2C_SUCCESS; @@ -134,7 +132,7 @@ e4000_SetRfFreqHz( int RfFreqKhz; int CrystalFreqKhz; - int CrystalFreqHz = CRYSTAL_FREQ; + int CrystalFreqHz = rtlsdr_get_tuner_clock(pTuner); // Set tuner RF frequency in KHz. // Note: 1. RfFreqKhz = round(RfFreqHz / 1000) @@ -187,7 +185,7 @@ e4000_SetBandwidthHz( int BandwidthKhz; int CrystalFreqKhz; - int CrystalFreqHz = CRYSTAL_FREQ; + int CrystalFreqHz = rtlsdr_get_tuner_clock(pTuner); // Get tuner extra module. |
