Skip to content

Commit

Permalink
cargo fmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
cr1901 committed Feb 19, 2022
1 parent 0085983 commit feb792d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/temp-hal/hal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use core::convert::Infallible;

use embedded_hal::i2c::{
self,
blocking::{Read as I2cRead, Write as I2cWrite}
blocking::{Read as I2cRead, Write as I2cWrite},
};
use embedded_hal::serial::{self, nb::Write as SerWrite};
use embedded_hal::timer::{nb::CountDown, Periodic};
Expand Down
33 changes: 19 additions & 14 deletions examples/temp-hal/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ use tcn75a::{ConfigReg, Resolution, Tcn75a};
// interrupts, thus is not static.
static TIMER: mspint::Mutex<RefCell<Option<Timer>>> = mspint::Mutex::new(RefCell::new(None));
static SERIAL: mspint::Mutex<RefCell<Option<Serial>>> = mspint::Mutex::new(RefCell::new(None));
static PORT1_PINS: mspint::Mutex<OnceCell<{{device}}::PORT_1_2>> = mspint::Mutex::new(OnceCell::new());
static TEMP_DISPLAY: mspint::Mutex<Cell<TempDisplay>> = mspint::Mutex::new(Cell::new(TempDisplay::Celsius));
static PORT1_PINS: mspint::Mutex<OnceCell<{{device}}::PORT_1_2>> =
mspint::Mutex::new(OnceCell::new());
static TEMP_DISPLAY: mspint::Mutex<Cell<TempDisplay>> =
mspint::Mutex::new(Cell::new(TempDisplay::Celsius));

#[derive(Debug, Clone, Copy)]
enum TempDisplay {
Expand All @@ -54,8 +56,12 @@ fn init(cs: mspint::CriticalSection) -> Tcn75a<I2c> {
clock.bcsctl1.modify(|_, w| w.diva().diva_1()); // Divide AUX clock by two (6000 Hz).

let port_1_2 = &p.PORT_1_2;
port_1_2.p1dir.modify(|_, w| w.p0().set_bit().p3().clear_bit());
port_1_2.p1out.modify(|_, w| w.p0().set_bit().p3().set_bit()); // Pullup on P3.
port_1_2
.p1dir
.modify(|_, w| w.p0().set_bit().p3().clear_bit());
port_1_2
.p1out
.modify(|_, w| w.p0().set_bit().p3().set_bit()); // Pullup on P3.
port_1_2.p1ren.modify(|_, w| w.p3().set_bit());

// Set bits for UART and I2C operation.
Expand All @@ -81,9 +87,7 @@ fn init(cs: mspint::CriticalSection) -> Tcn75a<I2c> {
});

// Set bit to interrupt on button on P1.3
port_1_2.p1ie.modify(|_, w| {
w.p3().set_bit()
});
port_1_2.p1ie.modify(|_, w| w.p3().set_bit());

let mut timer = Timer::new(p.TIMER0_A3);
timer.start(6000u16).unwrap();
Expand Down Expand Up @@ -119,8 +123,10 @@ fn main(mut tcn: Tcn75a<I2c>) -> ! {
// Avoid bringing in formatting for panic due to optimization
// issues.
let tmp: I8F8 = match tmp_result {
Ok(t) => { t.into() }
Err(_) => { I8F8!(0) }
Ok(t) => t.into(),
Err(_) => {
I8F8!(0)
}
};

let s: &mut dyn SerWrite<Error = serial::ErrorKind> = s_ref.as_mut().unwrap();
Expand All @@ -132,9 +138,10 @@ fn main(mut tcn: Tcn75a<I2c>) -> ! {
}
TempDisplay::Fahrenheit => {
// Don't bring in FixedI32 formatting.
let tmp_f: newtypes::fmt::I9F7SmallFmt = (I9F7!(1.8) * I9F7::lossy_from(tmp) + I9F7!(32)).into();
let tmp_f: newtypes::fmt::I9F7SmallFmt =
(I9F7!(1.8) * I9F7::lossy_from(tmp) + I9F7!(32)).into();
write!(s, "{} F\n", tmp_f).unwrap()
},
}
}
}
_ => {}
Expand All @@ -155,9 +162,7 @@ fn PORT1(cs: CriticalSection) {

TEMP_DISPLAY.borrow(cs).set(temp_display);

p.p1ifg.modify(|_, w| {
w.p3().clear_bit()
});
p.p1ifg.modify(|_, w| w.p3().clear_bit());
}

#[interrupt]
Expand Down

0 comments on commit feb792d

Please sign in to comment.