-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example that uses MRT as embedded-time clock
- Loading branch information
1 parent
a2bc217
commit e84836e
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |