Skip to content

Commit

Permalink
Fixes tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tcr committed Sep 1, 2016
1 parent 32af6ec commit 2492367
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ script:
- cargo build
- cargo test
- cargo doc
- cd ../accel-mma84
- cargo build
- cargo test
- cargo doc
19 changes: 9 additions & 10 deletions tessel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<Mutex<PortSocket>>,
socket: Arc<Mutex<PortSocket>>,
pins: HashMap<usize, Mutex<()>>,
}

pub struct Pin<'a> {
index: usize,
_guard: MutexGuard<'a, ()>,
socket: Rc<Mutex<PortSocket>>,
socket: Arc<Mutex<PortSocket>>,
}

impl<'a> Pin<'a> {
Expand All @@ -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,
}
}
Expand All @@ -137,15 +135,15 @@ impl Port {
}

pub struct I2C<'p> {
socket: Rc<Mutex<PortSocket>>,
socket: Arc<Mutex<PortSocket>>,
_scl: Pin<'p>,
_sda: Pin<'p>,
pub frequency: u32,
}

impl<'p> I2C<'p> {
// TODO: make frequency optional
fn new<'a>(socket: Rc<Mutex<PortSocket>>, scl: Pin<'a>, sda: Pin<'a>, frequency: u32) -> I2C<'a> {
fn new<'a>(socket: Arc<Mutex<PortSocket>>, scl: Pin<'a>, sda: Pin<'a>, frequency: u32) -> I2C<'a> {
let baud: u8 = I2C::compute_baud(frequency);

let mut i2c = I2C {
Expand All @@ -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;
Expand Down

0 comments on commit 2492367

Please sign in to comment.