diff --git a/.travis.yml b/.travis.yml index 05b05d6..089996e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,3 @@ script: - cargo build - cargo test - cargo doc - - cd ../accel-mma84 - - cargo build - - cargo test - - cargo doc diff --git a/tessel/src/lib.rs b/tessel/src/lib.rs index e70ae9f..b62210c 100644 --- a/tessel/src/lib.rs +++ b/tessel/src/lib.rs @@ -7,7 +7,7 @@ use std::collections::HashMap; use std::fs::File; use std::io; use std::io::prelude::*; -use std::rc::Rc; +use std::sync::Arc; use std::sync::{Mutex, MutexGuard, TryLockError}; use std::u8; @@ -80,19 +80,17 @@ pub struct PortGroup { /// # Example /// ``` /// use tessel::Port; -/// -/// let p = Port{socket_path: "path/to/my/socket"}; /// ``` pub struct Port { // Path of the domain socket. - socket: Rc>, + socket: Arc>, pins: HashMap>, } pub struct Pin<'a> { index: usize, _guard: MutexGuard<'a, ()>, - socket: Rc>, + socket: Arc>, } impl<'a> Pin<'a> { @@ -115,7 +113,7 @@ impl Port { // Create and return the port struct Port { - socket: Rc::new(Mutex::new(PortSocket::new(path))), + socket: Arc::new(Mutex::new(PortSocket::new(path))), pins: pins, } } @@ -137,7 +135,7 @@ impl Port { } pub struct I2C<'p> { - socket: Rc>, + socket: Arc>, _scl: Pin<'p>, _sda: Pin<'p>, pub frequency: u32, @@ -145,7 +143,7 @@ pub struct I2C<'p> { impl<'p> I2C<'p> { // TODO: make frequency optional - fn new<'a>(socket: Rc>, scl: Pin<'a>, sda: Pin<'a>, frequency: u32) -> I2C<'a> { + fn new<'a>(socket: Arc>, scl: Pin<'a>, sda: Pin<'a>, frequency: u32) -> I2C<'a> { let baud: u8 = I2C::compute_baud(frequency); let mut i2c = I2C { @@ -164,8 +162,9 @@ impl<'p> I2C<'p> { /// to set the frequency of the I2C Clock /// # Example /// ``` - /// assert_eq!(compute_baud(1000000), 4); - /// `` + /// use tessel::I2C; + /// assert_eq!(I2C::compute_baud(1000000), 4); + /// ``` fn compute_baud(frequency: u32) -> u8 { let mut intermediate: f64 = MCU_MAX_SPEED as f64 / frequency as f64;