summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2018-07-29 13:31:08 +0300
committerYuval Adam <_@yuv.al>2018-07-29 13:31:08 +0300
commitc04a539100d278e03490193bdfa76b664b93b2b8 (patch)
tree8d27f5db3598c01a8d5468dce6851ee80d7995ba
parent78d432f07d35f05b5a9c8cba91b2ea794847f898 (diff)
Extract devices into separate files
-rw-r--r--src/devices/fc0013.rs8
-rw-r--r--src/devices/mod.rs11
-rw-r--r--src/devices/r820t.rs8
-rw-r--r--src/lib.rs26
-rw-r--r--src/main.rs12
5 files changed, 32 insertions, 33 deletions
diff --git a/src/devices/fc0013.rs b/src/devices/fc0013.rs
new file mode 100644
index 0000000..bd5ab50
--- /dev/null
+++ b/src/devices/fc0013.rs
@@ -0,0 +1,8 @@
+use super::Device;
+
+pub const FC0013: Device = Device {
+ NAME: "Fitipower FC0013",
+ I2C_ADDR: 0xc6,
+ CHECK_ADDR: 0x00,
+ CHECK_VAL: 0xa3
+};
diff --git a/src/devices/mod.rs b/src/devices/mod.rs
new file mode 100644
index 0000000..5221bec
--- /dev/null
+++ b/src/devices/mod.rs
@@ -0,0 +1,11 @@
+pub mod fc0013;
+pub mod r820t;
+
+#[allow(non_snake_case)]
+pub struct Device {
+ pub NAME: &'static str,
+ pub I2C_ADDR: u8,
+ pub CHECK_ADDR: u8,
+ pub CHECK_VAL: u8
+}
+
diff --git a/src/devices/r820t.rs b/src/devices/r820t.rs
new file mode 100644
index 0000000..094816a
--- /dev/null
+++ b/src/devices/r820t.rs
@@ -0,0 +1,8 @@
+use super::Device;
+
+pub const R820T: Device = Device {
+ NAME: "Rafael Micro R820T",
+ I2C_ADDR: 0x34,
+ CHECK_ADDR: 0x00,
+ CHECK_VAL: 0x69
+};
diff --git a/src/lib.rs b/src/lib.rs
index e271f50..2bd0de1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,5 +1,7 @@
extern crate libusb;
+mod devices;
+
use std::time::Duration;
use libusb::{Direction, RequestType, Recipient};
@@ -23,30 +25,12 @@ const ADDR_SYS_DEMOD_CTL_1: u16 = 0x300b;
const INTERFACE_ID: u8 = 0;
-// extract this shit to an external file (but can't get it to fucking work)
-#[allow(non_snake_case)]
-struct Device {
- NAME: &'static str,
- I2C_ADDR: u8,
- CHECK_ADDR: u8,
- CHECK_VAL: u8
-}
+use devices::*;
const DEVICES: [Device; 2] = [
- Device {
- NAME: "Rafael Micro R820T",
- I2C_ADDR: 0x34,
- CHECK_ADDR: 0x00,
- CHECK_VAL: 0x69
- },
- Device {
- NAME: "Fitipower FC0013",
- I2C_ADDR: 0xc6,
- CHECK_ADDR: 0x00,
- CHECK_VAL: 0xa3
- }
+ fc0013::FC0013,
+ r820t::R820T
];
-///////////
const CTRL_TIMEOUT: Duration = Duration::from_millis(300);
const KNOWN_DEVICES: [(u16, u16, &str); 2] = [
diff --git a/src/main.rs b/src/main.rs
deleted file mode 100644
index 1bdade5..0000000
--- a/src/main.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-extern crate libusb;
-
-mod lib;
-
-use lib::RtlSdr;
-
-fn main() {
- println!("Running");
- let ctx = libusb::Context::new().unwrap();
- let mut rtlsdr = RtlSdr::new(&ctx);
- rtlsdr.init();
-}