summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorFreeArtMan <=>2015-09-22 20:16:47 +0100
committerFreeArtMan <=>2015-09-22 20:16:47 +0100
commitfa74c1448e236995a34d767a6e76c3055698fb60 (patch)
tree0ec6553d3c73112e0ea458c22c614ed10f5b2246 /hw
parent8adda9187304d8f06f907bfebc93e47207fa4796 (diff)
downloadradiola-fa74c1448e236995a34d767a6e76c3055698fb60.tar.gz
radiola-fa74c1448e236995a34d767a6e76c3055698fb60.zip
Wrapped rtlsdr to hw
Diffstat (limited to 'hw')
-rw-r--r--hw/hw.c285
-rw-r--r--hw/hw.h62
-rw-r--r--hw/make.mk10
3 files changed, 357 insertions, 0 deletions
diff --git a/hw/hw.c b/hw/hw.c
index e69de29..4496a51 100644
--- a/hw/hw.c
+++ b/hw/hw.c
@@ -0,0 +1,285 @@
+#include "hw.h"
+
+uint32_t hw_get_device_count(void)
+{
+ uint32_t ret;
+ ret = rtlsdr_get_device_count();
+ return ret;
+}
+
+
+const char* hw_get_device_name(uint32_t index)
+{
+ const char *ret;
+ ret = rtlsdr_get_device_name( index );
+ return ret;
+}
+
+
+int hw_get_device_usb_strings(uint32_t index,
+ char *manufact,
+ char *product,
+ char *serial)
+{
+ int ret;
+ ret = rtlsdr_get_device_usb_strings( index, manufact, product, serial );
+ return ret;
+}
+
+
+int hw_get_index_by_serial(const char *serial)
+{
+ int ret;
+ rtlsdr_get_index_by_serial( serial );
+ return ret;
+}
+
+
+int hw_open(rtlsdr_dev_t **dev, uint32_t index)
+{
+ int ret;
+ ret = rtlsdr_open( dev, index );
+ return ret;
+}
+
+
+int hw_close(rtlsdr_dev_t *dev)
+{
+ int ret;
+ ret = rtlsdr_close( dev );
+ return ret;
+}
+
+
+int hw_set_xtal_freq(rtlsdr_dev_t *dev, uint32_t rtl_freq,
+ uint32_t tuner_freq)
+{
+ int ret;
+ ret = rtlsdr_set_xtal_freq( dev, rtl_freq, tuner_freq );
+ return ret;
+}
+
+
+int hw_get_xtal_freq(rtlsdr_dev_t *dev, uint32_t *rtl_freq,
+ uint32_t *tuner_freq)
+{
+ int ret;
+ ret = rtlsdr_get_xtal_freq( dev, rtl_freq, tuner_freq );
+ return ret;
+}
+
+
+int hw_get_usb_strings(rtlsdr_dev_t *dev, char *manufact,
+ char *product, char *serial)
+{
+ int ret;
+ ret = rtlsdr_get_usb_strings( dev, manufact, product, serial );
+ return ret;
+}
+
+
+int hw_write_eeprom(rtlsdr_dev_t *dev, uint8_t *data,
+ uint8_t offset, uint16_t len)
+{
+ int ret;
+ ret = rtlsdr_write_eeprom( dev, data, offset, len );
+ return ret;
+}
+
+
+int hw_read_eeprom(rtlsdr_dev_t *dev, uint8_t *data,
+ uint8_t offset, uint16_t len)
+{
+ int ret;
+ ret = rtlsdr_read_eeprom( dev, data, offset, len );
+ return ret;
+}
+
+
+int hw_set_center_freq(rtlsdr_dev_t *dev, uint32_t freq)
+{
+ int ret;
+ ret = rtlsdr_set_center_freq( dev, freq );
+ return ret;
+}
+
+
+uint32_t hw_get_center_freq(rtlsdr_dev_t *dev)
+{
+ uint32_t ret;
+ ret = rtlsdr_get_center_freq( dev );
+ return ret;
+}
+
+
+int hw_set_freq_correction(rtlsdr_dev_t *dev, int ppm)
+{
+ int ret;
+ ret = rtlsdr_set_freq_correction( dev, ppm );
+ return ret;
+}
+
+
+int hw_get_freq_correction(rtlsdr_dev_t *dev)
+{
+ int ret;
+ ret = rtlsdr_get_freq_correction( dev );
+ return ret;
+}
+
+
+enum rtlsdr_tuner hw_get_tuner_type(rtlsdr_dev_t *dev)
+{
+ enum rtlsdr_tuner ret;
+ ret = rtlsdr_get_tuner_type( dev );
+ return ret;
+}
+
+
+int hw_get_tuner_gains(rtlsdr_dev_t *dev, int *gains)
+{
+ int ret;
+ ret = rtlsdr_get_tuner_gains( dev, gains );
+ return ret;
+}
+
+
+int hw_set_tuner_gain(rtlsdr_dev_t *dev, int gain)
+{
+ int ret;
+ ret = rtlsdr_set_tuner_gain( dev, gain );
+ return ret;
+}
+
+
+int hw_get_tuner_gain(rtlsdr_dev_t *dev)
+{
+ int ret;
+ ret = rtlsdr_get_tuner_gain( dev );
+ return ret;
+}
+
+
+int hw_set_tuner_if_gain(rtlsdr_dev_t *dev, int stage, int gain)
+{
+ int ret;
+ ret = rtlsdr_set_tuner_if_gain( dev, stage, gain );
+ return ret;
+}
+
+
+int hw_set_tuner_gain_mode(rtlsdr_dev_t *dev, int manual)
+{
+ int ret;
+ ret = rtlsdr_set_tuner_gain_mode( dev, manual );
+ return ret;
+}
+
+
+int hw_set_sample_rate(rtlsdr_dev_t *dev, uint32_t rate)
+{
+ int ret;
+ ret = rtlsdr_set_sample_rate( dev, rate );
+ return ret;
+}
+
+
+uint32_t hw_get_sample_rate(rtlsdr_dev_t *dev)
+{
+ uint32_t ret;
+ ret = rtlsdr_get_sample_rate( dev );
+ return ret;
+}
+
+
+int hw_set_testmode(rtlsdr_dev_t *dev, int on)
+{
+ int ret;
+ ret = rtlsdr_set_testmode( dev, on );
+ return ret;
+}
+
+
+int hw_set_agc_mode(rtlsdr_dev_t *dev, int on)
+{
+ int ret;
+ ret = rtlsdr_set_agc_mode( dev, on );
+ return ret;
+}
+
+
+int hw_set_direct_sampling(rtlsdr_dev_t *dev, int on)
+{
+ int ret;
+ ret = rtlsdr_set_direct_sampling( dev, on );
+ return ret;
+}
+
+
+int hw_get_direct_sampling(rtlsdr_dev_t *dev)
+{
+ int ret;
+ ret = rtlsdr_get_direct_sampling( dev );
+ return ret;
+}
+
+
+int hw_set_offset_tuning(rtlsdr_dev_t *dev, int on)
+{
+ int ret;
+ ret = rtlsdr_set_offset_tuning( dev, on );
+ return ret;
+}
+
+
+int hw_get_offset_tuning(rtlsdr_dev_t *dev)
+{
+ int ret;
+ ret = rtlsdr_get_offset_tuning( dev );
+ return ret;
+}
+
+
+
+int hw_reset_buffer(rtlsdr_dev_t *dev)
+{
+ int ret;
+ ret = rtlsdr_reset_buffer( dev );
+ return ret;
+}
+
+
+int hw_read_sync(rtlsdr_dev_t *dev, void *buf, int len, int *n_read)
+{
+ int ret;
+ ret = rtlsdr_read_sync( dev, buf, len, n_read );
+ return ret;
+}
+
+
+int hw_wait_async(rtlsdr_dev_t *dev, rtlsdr_read_async_cb_t cb, void *ctx)
+{
+ int ret;
+ ret = rtlsdr_wait_async( dev, cb, ctx );
+ return ret;
+}
+
+
+int hw_read_async(rtlsdr_dev_t *dev,
+ rtlsdr_read_async_cb_t cb,
+ void *ctx,
+ uint32_t buf_num,
+ uint32_t buf_len)
+{
+ int ret;
+ ret = rtlsdr_read_async( dev, cb, ctx, buf_num, buf_len );
+ return ret;
+}
+
+
+int hw_cancel_async(rtlsdr_dev_t *dev)
+{
+ int ret;
+ ret = rtlsdr_cancel_async( dev );
+ return ret;
+} \ No newline at end of file
diff --git a/hw/hw.h b/hw/hw.h
index e69de29..69b943c 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -0,0 +1,62 @@
+#ifndef __RADIOLA_HW_H
+#define __RADIOLA_HW_H
+
+#include <stdio.h>
+#include <stdlib.h>
+
+//#include <r820t.h>
+#include <rtl-sdr.h>
+
+uint32_t hw_get_device_count(void);
+const char* hw_get_device_name(uint32_t index);
+int hw_get_device_usb_strings(uint32_t index,
+ char *manufact,
+ char *product,
+ char *serial);
+int hw_get_index_by_serial(const char *serial);
+int hw_open(rtlsdr_dev_t **dev, uint32_t index);
+int hw_close(rtlsdr_dev_t *dev);
+int hw_set_xtal_freq(rtlsdr_dev_t *dev, uint32_t rtl_freq,
+ uint32_t tuner_freq);
+int hw_get_xtal_freq(rtlsdr_dev_t *dev, uint32_t *rtl_freq,
+ uint32_t *tuner_freq);
+int hw_get_usb_strings(rtlsdr_dev_t *dev, char *manufact,
+ char *product, char *serial);
+int hw_write_eeprom(rtlsdr_dev_t *dev, uint8_t *data,
+ uint8_t offset, uint16_t len);
+int hw_read_eeprom(rtlsdr_dev_t *dev, uint8_t *data,
+ uint8_t offset, uint16_t len);
+int hw_set_center_freq(rtlsdr_dev_t *dev, uint32_t freq);
+uint32_t hw_get_center_freq(rtlsdr_dev_t *dev);
+int hw_set_freq_correction(rtlsdr_dev_t *dev, int ppm);
+int hw_get_freq_correction(rtlsdr_dev_t *dev);
+enum rtlsdr_tuner hw_get_tuner_type(rtlsdr_dev_t *dev);
+int hw_get_tuner_gains(rtlsdr_dev_t *dev, int *gains);
+int hw_set_tuner_gain(rtlsdr_dev_t *dev, int gain);
+int hw_get_tuner_gain(rtlsdr_dev_t *dev);
+int hw_set_tuner_if_gain(rtlsdr_dev_t *dev, int stage, int gain);
+int hw_set_tuner_gain_mode(rtlsdr_dev_t *dev, int manual);
+int hw_set_sample_rate(rtlsdr_dev_t *dev, uint32_t rate);
+uint32_t hw_get_sample_rate(rtlsdr_dev_t *dev);
+int hw_set_testmode(rtlsdr_dev_t *dev, int on);
+int hw_set_agc_mode(rtlsdr_dev_t *dev, int on);
+int hw_set_direct_sampling(rtlsdr_dev_t *dev, int on);
+int hw_get_direct_sampling(rtlsdr_dev_t *dev);
+int hw_set_offset_tuning(rtlsdr_dev_t *dev, int on);
+int hw_get_offset_tuning(rtlsdr_dev_t *dev);
+int hw_reset_buffer(rtlsdr_dev_t *dev);
+int hw_read_sync(rtlsdr_dev_t *dev, void *buf, int len, int *n_read);
+int hw_wait_async(rtlsdr_dev_t *dev, rtlsdr_read_async_cb_t cb, void *ctx);
+int hw_read_async(rtlsdr_dev_t *dev,
+ rtlsdr_read_async_cb_t cb,
+ void *ctx,
+ uint32_t buf_num,
+ uint32_t buf_len);
+int hw_cancel_async(rtlsdr_dev_t *dev);
+
+
+
+
+
+
+#endif \ No newline at end of file
diff --git a/hw/make.mk b/hw/make.mk
new file mode 100644
index 0000000..534a7f5
--- /dev/null
+++ b/hw/make.mk
@@ -0,0 +1,10 @@
+DIR_HW = hw/
+SOURCES_HW += hw/hw.c
+OBJECTS_HW += $(SOURCES_HW:.c=.o)
+LDFLAGS += -lrtlsdr
+
+
+OBJECTS_DIR_HW += $(subst $(DIR_HW),$(BUILD_DIR)$(DIR_HW),$(OBJECTS_HW))
+
+OBJECTS += $(OBJECTS_HW)
+OBJECTS_FINAL += $(OBJECTS_DIR_HW) \ No newline at end of file