diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile | 10 | ||||
| -rw-r--r-- | src/Makefile.am | 15 | ||||
| -rw-r--r-- | src/i2c.h | 9 | ||||
| -rw-r--r-- | src/main.c | 4 | ||||
| -rw-r--r-- | src/rtl-sdr.c | 8 | ||||
| -rw-r--r-- | src/rtl-sdr.h | 73 | ||||
| -rw-r--r-- | src/tuner_e4000.h | 234 | ||||
| -rw-r--r-- | src/tuner_fc0013.h | 155 |
8 files changed, 21 insertions, 487 deletions
diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index 09070df..0000000 --- a/src/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -LDFLAGS=`pkg-config --libs libusb-1.0` -CFLAGS=-Wall -g -O0 `pkg-config --cflags libusb-1.0` - -all: rtl-sdr - -rtl-sdr: main.o rtl-sdr.o tuner_e4000.o tuner_fc0013.c - $(CC) -o $@ $^ $(LDFLAGS) - -clean: - @rm -f rtl-sdr *.o diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..4313876 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,15 @@ +# This is _NOT_ the library release version, it's an API version. +# Please read Chapter 6 "Library interface versions" of the libtool documentation before making any modification +LIBVERSION=0:0:0 + +INCLUDES = $(all_includes) -I$(top_srcdir)/include +AM_CFLAGS = -fPIC -Wall + +lib_LTLIBRARIES = librtlsdr.la + +librtlsdr_la_SOURCES = rtl-sdr.c tuner_e4000.c tuner_fc0013.c +librtlsdr_la_LDFALGS = -version-info $(LIBVERSION) + +bin_PROGRAMS = rtl_sdr +rtl_sdr_SOURCES = main.c +rtl_sdr_LDADD = librtlsdr.la diff --git a/src/i2c.h b/src/i2c.h deleted file mode 100644 index 0877380..0000000 --- a/src/i2c.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __I2C_H -#define __I2C_H - -typedef int rtlsdr_dev_t; - -int rtlsdr_i2c_write(rtlsdr_dev_t *dev, uint8_t i2c_addr, uint8_t *buffer, int len); -int rtlsdr_i2c_read(rtlsdr_dev_t *dev, uint8_t i2c_addr, uint8_t *buffer, int len); - -#endif @@ -32,7 +32,7 @@ static int do_exit = 0; void usage(void) { - printf("rtl-sdr, an I/Q recorder for RTL2832 based USB-sticks\n\n" + printf("rtl-sdr, an I/Q recorder for RTL2832 based DVB-T receivers\n\n" "Usage:\t -f frequency to tune to [Hz]\n" "\t[-s samplerate (default: 2048000 Hz)]\n" "\toutput filename\n"); @@ -48,7 +48,7 @@ int main(int argc, char **argv) { struct sigaction sigact; int r, opt; - char *filename; + char *filename = NULL; uint32_t frequency = 0, samp_rate = 2048000; uint8_t buffer[READLEN]; uint32_t n_read; diff --git a/src/rtl-sdr.c b/src/rtl-sdr.c index cabaa58..d3bc060 100644 --- a/src/rtl-sdr.c +++ b/src/rtl-sdr.c @@ -399,7 +399,7 @@ uint32_t rtlsdr_get_device_count(void) { int i, j; libusb_device **list; - uint32_t device_count; + uint32_t device_count = 0; struct libusb_device_descriptor dd; ssize_t cnt = libusb_get_device_list(NULL, &list); @@ -424,7 +424,7 @@ const char *rtlsdr_get_device_name(uint32_t index) libusb_device **list; ssize_t cnt = libusb_get_device_list(NULL, &list); - + if (index > cnt - 1) return NULL; @@ -451,7 +451,7 @@ rtlsdr_dev_t *rtlsdr_open(int index) memset(dev, 0, sizeof(rtlsdr_dev_t)); ssize_t cnt = libusb_get_device_list(NULL, &list); - + for (i = 0; i < cnt; i++) { device = list[i]; @@ -483,7 +483,7 @@ rtlsdr_dev_t *rtlsdr_open(int index) } libusb_free_device_list(list, 0); - + unsigned char buffer[256]; libusb_get_string_descriptor_ascii(dev->devh, 0, buffer, sizeof(buffer) ); diff --git a/src/rtl-sdr.h b/src/rtl-sdr.h deleted file mode 100644 index 0b22eb1..0000000 --- a/src/rtl-sdr.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * rtl-sdr, a poor man's SDR using a Realtek RTL2832 based DVB-stick - * Copyright (C) 2012 by Steve Markgraf <steve@steve-m.de> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - *(at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __RTL_SDR_H -#define __RTL_SDR_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdint.h> - -typedef int rtlsdr_dev_t; - -/* must be called once before using any other library functions */ -int rtlsdr_init(void); - -/* must be called once at application shutdown */ -void rtlsdr_exit(void); - -uint32_t rtlsdr_get_device_count(void); - -const char *rtlsdr_get_device_name(uint32_t index); - -rtlsdr_dev_t *rtlsdr_open(uint32_t index); - -int rtlsdr_close(rtlsdr_dev_t *dev); - -/* configuration functions */ - -int rtlsdr_set_center_freq(rtlsdr_dev_t *dev, uint32_t freq); - -int rtlsdr_get_center_freq(rtlsdr_dev_t *dev); - -int rtlsdr_set_freq_correction(rtlsdr_dev_t *dev, int32_t ppm); - -int32_t rtlsdr_get_freq_correction(rtlsdr_dev_t *dev); - -/* this will select the baseband filters according to the requested sample rate */ -int rtlsdr_set_sample_rate(rtlsdr_dev_t *dev, uint32_t rate); - -int rtlsdr_get_sample_rate(rtlsdr_dev_t *dev); - -/* streaming functions */ - -int rtlsdr_reset_buffer(rtlsdr_dev_t *dev); - -int rtlsdr_read_sync(rtlsdr_dev_t *dev, void *buf, uint32_t len, uint32_t *n_read); - -typedef void(*rtlsdr_async_read_cb_t)(const char *buf, uint32_t len, void *ctx); - -int rtlsdr_async_loop(rtlsdr_dev_t *dev, rtlsdr_async_read_cb_t cb, void *ctx); - -#ifdef __cplusplus -} -#endif - -#endif /* __RTL_SDR_H */ diff --git a/src/tuner_e4000.h b/src/tuner_e4000.h deleted file mode 100644 index 4c78f3e..0000000 --- a/src/tuner_e4000.h +++ /dev/null @@ -1,234 +0,0 @@ -#ifndef __TUNER_E4000_H -#define __TUNER_E4000_H - -/** - -@file - -@brief E4000 tuner module declaration - -One can manipulate E4000 tuner through E4000 module. -E4000 module is derived from tuner module. - - - -@par Example: -@code - -// The example is the same as the tuner example in tuner_base.h except the listed lines. - - - -#include "tuner_e4000.h" - - -... - - - -int main(void) -{ - TUNER_MODULE *pTuner; - E4000_EXTRA_MODULE *pTunerExtra; - - TUNER_MODULE TunerModuleMemory; - BASE_INTERFACE_MODULE BaseInterfaceModuleMemory; -// I2C_BRIDGE_MODULE I2cBridgeModuleMemory; - - unsigned long BandwidthMode; - - - ... - - - - // Build E4000 tuner module. - BuildE4000Module( - &pTuner, - &TunerModuleMemory, - &BaseInterfaceModuleMemory, - &I2cBridgeModuleMemory, - 0xac, // I2C device address is 0xac in 8-bit format. - CRYSTAL_FREQ_16384000HZ, // Crystal frequency is 16.384 MHz. - E4000_AGC_INTERNAL // The E4000 AGC mode is internal AGC mode. - ); - - - - - - // Get E4000 tuner extra module. - pTunerExtra = (T2266_EXTRA_MODULE *)(pTuner->pExtra); - - - - - - // ==== Initialize tuner and set its parameters ===== - - ... - - // Set E4000 bandwidth. - pTunerExtra->SetBandwidthMode(pTuner, E4000_BANDWIDTH_6MHZ); - - - - - - // ==== Get tuner information ===== - - ... - - // Get E4000 bandwidth. - pTunerExtra->GetBandwidthMode(pTuner, &BandwidthMode); - - - - // See the example for other tuner functions in tuner_base.h - - - return 0; -} - - -@endcode - -*/ - - - - - -//#include "tuner_base.h" - - - - - -// The following context is implemented for E4000 source code. - - -// Definition (implemeted for E4000) -#define E4000_1_SUCCESS 1 -#define E4000_1_FAIL 0 -#define E4000_I2C_SUCCESS 1 -#define E4000_I2C_FAIL 0 - - - -// Function (implemeted for E4000) -int -I2CReadByte(void *pTuner, - unsigned char NoUse, - unsigned char RegAddr, - unsigned char *pReadingByte - ); - -int -I2CWriteByte( - void *pTuner, - unsigned char NoUse, - unsigned char RegAddr, - unsigned char WritingByte - ); - -int -I2CWriteArray(void *pTuner, - unsigned char NoUse, - unsigned char RegStartAddr, - unsigned char ByteNum, - unsigned char *pWritingBytes - ); - - - -// Functions (from E4000 source code) -int tunerreset (void *pTuner); -int Tunerclock(void *pTuner); -int Qpeak(void *pTuner); -int DCoffloop(void *pTuner); -int GainControlinit(void *pTuner); - -int Gainmanual(void *pTuner); -int E4000_gain_freq(void *pTuner, int frequency); -int PLL(void *pTuner, int Ref_clk, int Freq); -int LNAfilter(void *pTuner, int Freq); -int IFfilter(void *pTuner, int bandwidth, int Ref_clk); -int freqband(void *pTuner, int Freq); -int DCoffLUT(void *pTuner); -int GainControlauto(void *pTuner); - -int E4000_sensitivity(void *pTuner, int Freq, int bandwidth); -int E4000_linearity(void *pTuner, int Freq, int bandwidth); -int E4000_high_linearity(void *pTuner); -int E4000_nominal(void *pTuner, int Freq, int bandwidth); - - -// The following context is E4000 tuner API source code - -// Definitions - -// Bandwidth in Hz -enum E4000_BANDWIDTH_HZ -{ - E4000_BANDWIDTH_6000000HZ = 6000000, - E4000_BANDWIDTH_7000000HZ = 7000000, - E4000_BANDWIDTH_8000000HZ = 8000000, -}; - - -// Manipulaing functions -void -e4000_GetTunerType( - void *pTuner, - int *pTunerType - ); - -void -e4000_GetDeviceAddr( - void *pTuner, - unsigned char *pDeviceAddr - ); - -int -e4000_Initialize( - void *pTuner - ); - -int -e4000_SetRfFreqHz( - void *pTuner, - unsigned long RfFreqHz - ); - -int -e4000_GetRfFreqHz( - void *pTuner, - unsigned long *pRfFreqHz - ); - - - - - -// Extra manipulaing functions -int -e4000_GetRegByte( - void *pTuner, - unsigned char RegAddr, - unsigned char *pReadingByte - ); - -int -e4000_SetBandwidthHz( - void *pTuner, - unsigned long BandwidthHz - ); - -int -e4000_GetBandwidthHz( - void *pTuner, - unsigned long *pBandwidthHz - ); - -#endif diff --git a/src/tuner_fc0013.h b/src/tuner_fc0013.h deleted file mode 100644 index b405808..0000000 --- a/src/tuner_fc0013.h +++ /dev/null @@ -1,155 +0,0 @@ -#ifndef __TUNER_FC0013_H -#define __TUNER_FC0013_H - -/** - -@file - -@brief FC0013 tuner module declaration - -One can manipulate FC0013 tuner through FC0013 module. -FC0013 module is derived from tuner module. - - -// The following context is implemented for FC0013 source code. - -**/ - -// Definitions -enum FC0013_TRUE_FALSE_STATUS -{ - FC0013_FALSE, - FC0013_TRUE, -}; - - -enum FC0013_I2C_STATUS -{ - FC0013_I2C_SUCCESS, - FC0013_I2C_ERROR, -}; - - -enum FC0013_FUNCTION_STATUS -{ - FC0013_FUNCTION_SUCCESS, - FC0013_FUNCTION_ERROR, -}; - - - -// Functions -int FC0013_Read(void *pTuner, unsigned char RegAddr, unsigned char *pByte); -int FC0013_Write(void *pTuner, unsigned char RegAddr, unsigned char Byte); - -int -fc0013_SetRegMaskBits( - void *pTuner, - unsigned char RegAddr, - unsigned char Msb, - unsigned char Lsb, - const unsigned char WritingValue - ); - -int -fc0013_GetRegMaskBits( - void *pTuner, - unsigned char RegAddr, - unsigned char Msb, - unsigned char Lsb, - unsigned char *pReadingValue - ); - -int FC0013_Open(void *pTuner); -int FC0013_SetFrequency(void *pTuner, unsigned long Frequency, unsigned short Bandwidth); - -// Set VHF Track depends on input frequency -int FC0013_SetVhfTrack(void *pTuner, unsigned long Frequency); - - -// The following context is FC0013 tuner API source code - - -// Definitions - -// Bandwidth mode -enum FC0013_BANDWIDTH_MODE -{ - FC0013_BANDWIDTH_6000000HZ = 6, - FC0013_BANDWIDTH_7000000HZ = 7, - FC0013_BANDWIDTH_8000000HZ = 8, -}; - - -// Default for initialing -#define FC0013_RF_FREQ_HZ_DEFAULT 50000000 -#define FC0013_BANDWIDTH_MODE_DEFAULT FC0013_BANDWIDTH_8000000HZ - - -// Tuner LNA -enum FC0013_LNA_GAIN_VALUE -{ - FC0013_LNA_GAIN_LOW = 0x00, // -6.3dB - FC0013_LNA_GAIN_MIDDLE = 0x08, // 7.1dB - FC0013_LNA_GAIN_HIGH_17 = 0x11, // 19.1dB - FC0013_LNA_GAIN_HIGH_19 = 0x10, // 19.7dB -}; - -// Manipulaing functions -void -fc0013_GetTunerType( - void *pTuner, - int *pTunerType - ); - -void -fc0013_GetDeviceAddr( - void *pTuner, - unsigned char *pDeviceAddr - ); - -int -fc0013_Initialize( - void *pTuner - ); - -int -fc0013_SetRfFreqHz( - void *pTuner, - unsigned long RfFreqHz - ); - -int -fc0013_GetRfFreqHz( - void *pTuner, - unsigned long *pRfFreqHz - ); - -// Extra manipulaing functions -int -fc0013_SetBandwidthMode( - void *pTuner, - int BandwidthMode - ); - -int -fc0013_GetBandwidthMode( - void *pTuner, - int *pBandwidthMode - ); - -int -fc0013_RcCalReset( - void *pTuner - ); - -int -fc0013_RcCalAdd( - void *pTuner, - int RcValue - ); - - - - -#endif |
