From fa74c1448e236995a34d767a6e76c3055698fb60 Mon Sep 17 00:00:00 2001 From: FreeArtMan <=> Date: Tue, 22 Sep 2015 20:16:47 +0100 Subject: Wrapped rtlsdr to hw --- Makefile | 19 +++- TODO | 4 +- draw/glui.c | 0 draw/glui.h | 0 draw/make.mk | 0 draw/tui.c | 0 draw/tui.h | 0 draw/ui.c | 0 draw/ui.h | 0 hw/hw.c | 285 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/hw.h | 62 +++++++++++++ hw/make.mk | 10 +++ radiola.c | 2 + test/Makefile | 19 ++-- 14 files changed, 391 insertions(+), 10 deletions(-) create mode 100644 draw/glui.c create mode 100644 draw/glui.h create mode 100644 draw/make.mk create mode 100644 draw/tui.c create mode 100644 draw/tui.h create mode 100644 draw/ui.c create mode 100644 draw/ui.h create mode 100644 hw/make.mk diff --git a/Makefile b/Makefile index 7f7d3b4..0a6c6e0 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,21 @@ CC=gcc CFLAGS= LDFLAGS= +BUILD_DIR=build/ -make: - $(CC) radiola.c -o $(PROJECT) +SOURCES= +OBJECTS= +OBJECTS_FINAL= + + + +include hw/make.mk + +make: $(OBJECTS) + $(CC) $(OBJECTS_FINAL) $(PROJECT).c -o $(PROJECT) $(LDFLAGS) + +%.o: %.c + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $(BUILD_DIR)$@ + +clean: + rm -f $(PROJECT) diff --git a/TODO b/TODO index d70d875..872aab1 100644 --- a/TODO +++ b/TODO @@ -21,4 +21,6 @@ am demod [AUDIO] play sound - stream sound to web \ No newline at end of file + stream sound to web + +rtlsdr? no dithering? in with brain it is? \ No newline at end of file diff --git a/draw/glui.c b/draw/glui.c new file mode 100644 index 0000000..e69de29 diff --git a/draw/glui.h b/draw/glui.h new file mode 100644 index 0000000..e69de29 diff --git a/draw/make.mk b/draw/make.mk new file mode 100644 index 0000000..e69de29 diff --git a/draw/tui.c b/draw/tui.c new file mode 100644 index 0000000..e69de29 diff --git a/draw/tui.h b/draw/tui.h new file mode 100644 index 0000000..e69de29 diff --git a/draw/ui.c b/draw/ui.c new file mode 100644 index 0000000..e69de29 diff --git a/draw/ui.h b/draw/ui.h new file mode 100644 index 0000000..e69de29 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 +#include + +//#include +#include + +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 diff --git a/radiola.c b/radiola.c index 40872c8..6386fe2 100644 --- a/radiola.c +++ b/radiola.c @@ -1,6 +1,8 @@ #include #include +#include "hw/hw.h" + int main() { return 0; diff --git a/test/Makefile b/test/Makefile index 8e36d37..5ee5a91 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,15 +1,20 @@ CC=gcc -CFLAGS=-I../../r820t/include -LDFLAGS= `pkg-config --libs libusb` -L../../../r820t -lr820t -Wl,-rpath=../../../r820t - -SOURCE += $(wildcard *.c) +CFLAGS= +#LDFLAGS= `pkg-config --libs libusb` -L../../../r820t -lr820t -Wl,-rpath=../../../r820t +LDFLAGS=`pkg-config --libs libusb` -lrtlsdr +SOURCE = $(wildcard *.c) +OBJECTS = BIN = $(SOURCE:.c=) -make: $(BIN) - @echo $< %: %.c - $(CC) $(LDFLAGS) $(CFLAGS) $< -o $@ + $(CC) $(LDFLAGS) $(CFLAGS) $< -o $@ + +%.o: %.c + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $(BUILD_DIR)$@ + +make: $(BIN) + clean: rm -f $(BIN) \ No newline at end of file -- cgit v1.2.3