mirror of
https://github.com/rtlsdrblog/rtl-sdr-blog.git
synced 2025-06-25 12:47:50 +02:00
add autotools based build system
This commit is contained in:
5
include/Makefile.am
Normal file
5
include/Makefile.am
Normal file
@ -0,0 +1,5 @@
|
||||
rtlsdr_HEADERS = rtl-sdr.h
|
||||
|
||||
noinst_HEADERS = i2c.h tuner_e4000.h tuner_fc0013.h
|
||||
|
||||
rtlsdrdir = $(includedir)
|
9
include/i2c.h
Normal file
9
include/i2c.h
Normal file
@ -0,0 +1,9 @@
|
||||
#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
|
73
include/rtl-sdr.h
Normal file
73
include/rtl-sdr.h
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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 */
|
234
include/tuner_e4000.h
Normal file
234
include/tuner_e4000.h
Normal file
@ -0,0 +1,234 @@
|
||||
#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
|
155
include/tuner_fc0013.h
Normal file
155
include/tuner_fc0013.h
Normal file
@ -0,0 +1,155 @@
|
||||
#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
|
Reference in New Issue
Block a user