diff options
author | dianshi <arturs.artamonovs@protonmail.com> | 2022-07-11 20:45:23 +0100 |
---|---|---|
committer | dianshi <arturs.artamonovs@protonmail.com> | 2022-07-11 20:45:23 +0100 |
commit | 501862bceaea3010d5c426d54cdb12b6c4ca2433 (patch) | |
tree | fd064673b0b937082971626dbb44f1cbef8b830a /hardware | |
parent | ec61b3e0e6084950eb4d5c95f83e442a01765a35 (diff) | |
download | r820sdr-init-501862bceaea3010d5c426d54cdb12b6c4ca2433.tar.gz r820sdr-init-501862bceaea3010d5c426d54cdb12b6c4ca2433.zip |
Add make file for libusb. add latest changes to main.swift
Diffstat (limited to 'hardware')
-rw-r--r-- | hardware/r820.swift | 72 | ||||
-rw-r--r-- | hardware/src/libusb/make.mk | 22 |
2 files changed, 94 insertions, 0 deletions
diff --git a/hardware/r820.swift b/hardware/r820.swift new file mode 100644 index 0000000..63921d7 --- /dev/null +++ b/hardware/r820.swift @@ -0,0 +1,72 @@ +// +// r820.swift +// r820sdr-init +// +// Created by Jacky Jack on 15/03/2022. +// + +import Foundation + +public class R820API { + + + func R820() { + print("Start device API") + } + + func getDeviceCount() -> UInt32 { + return rtlsdr_get_device_count() + } + + + +} + +public class R820Tuner { + var deviceInitalized:Bool = false + var dev: OpaquePointer? = nil + + /** + Function to initialise tunner + - Parameters: + - + */ + func R820Tuner() { + print("Initialise tunner") + } + + func open(index devId: UInt32) { + let err = rtlsdr_open(&dev,devId) + if (err != 0) { + print("Error couldnt open device") + return + } + deviceInitalized = true + } + + func close() { + if self.deviceInitalized { + rtlsdr_close(dev); + dev = nil + } + } + + func getCenterFrequency()->UInt32 { + return rtlsdr_get_center_freq(dev) + } + + func setCenterFrequency(freq: UInt32) -> Int32 { + return rtlsdr_set_center_freq(dev, freq) + } + + func getSampleRate() -> UInt32 { + return rtlsdr_get_sample_rate(dev) + } + + func setSampleRate(samplerate: UInt32) -> Int32 { + return rtlsdr_set_sample_rate(dev, samplerate) + } + + + +} diff --git a/hardware/src/libusb/make.mk b/hardware/src/libusb/make.mk new file mode 100644 index 0000000..acf8f12 --- /dev/null +++ b/hardware/src/libusb/make.mk @@ -0,0 +1,22 @@ +DIR=src + +SRC_UTILS_PRE += $(wildcard $(DIR)/os/*.c) +SRC_UTILS += $(wildcard $(DIR)/*.c) +OBJ_UTILS += $(SRC_UTILS:.c=.o) +OBJ_UTILS_PRE += $(SRC_UTILS_PRE:.c=.o) +LDFLAGS_UTILS = +INCLUDE = -I./include -I./src +CFLAGS = -fPIC + +build-src: src-pre + echo $(SRC_UTILS_PRE) + echo $(SRC_UTILS) + +$(DIR)-pre: $(OBJ_UTILS_PRE) $(OBJ_UTILS) + +$(DIR)/os/%.o: $(DIR)/os/%.c + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $(BUILD_DIR)$@ + +$(DIR)/%.o: $(DIR)/%.c + echo "B" + $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $(BUILD_DIR)$@ $(LDFLAGS_UTILS)
\ No newline at end of file |