Skip to content

Commit

Permalink
Add example that uses MRT as embedded-time clock
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Oct 16, 2020
1 parent a2bc217 commit e84836e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ required-features = ["rt-selected", "82x"]
name = "i2c_eeprom"
required-features = ["rt-selected"]

[[example]]
name = "mrt_clock"
required-features = ["rt-selected", "845"]

[[example]]
name = "pinint"
required-features = ["rt-selected", "845"]
Expand Down
32 changes: 32 additions & 0 deletions examples/mrt_clock.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#![no_main]
#![no_std]

extern crate panic_rtt_target;

use embedded_time::{duration::Extensions as _, Clock as _};
use lpc8xx_hal::{cortex_m_rt::entry, gpio::Level, mrt, Peripherals};

#[entry]
fn main() -> ! {
rtt_target::rtt_init_print!();

let p = Peripherals::take().unwrap();

let mut syscon = p.SYSCON.split();
let gpio = p.GPIO.enable(&mut syscon.handle);
let mut mrt = p.MRT0.split(&mut syscon.handle).mrt0;

let mut led = p
.pins
.pio1_1
.into_output_pin(gpio.tokens.pio1_1, Level::Low);

loop {
mrt.start(mrt::MAX_VALUE);

let timer = mrt.new_timer(1u32.seconds());
timer.start().unwrap().wait().unwrap();

led.toggle();
}
}

0 comments on commit e84836e

Please sign in to comment.