-
Notifications
You must be signed in to change notification settings - Fork 20
/
rtfm_led.rs
49 lines (40 loc) · 1.17 KB
/
rtfm_led.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#![no_main]
#![no_std]
extern crate panic_semihosting;
use cortex_m_semihosting::dbg;
use lpc55s6x_hal as hal;
use hal::{gpio, iocon};
use rtfm::app;
#[allow(deprecated)]
use embedded_hal::digital::v1::OutputPin;
#[app(device = crate::hal::raw)]
const APP: () = {
// Late resources
static mut LED: iocon::Pin<iocon::PIO1_6, iocon::pin_state::Gpio<'_, gpio::direction::Output>> = ();
#[init]
fn init(c: init::Context) -> init::LateResources {
dbg!("init");
let peripherals = hal::Peripherals::take().unwrap();
let mut syscon = peripherals.SYSCON.split();
let gpio = peripherals.GPIO.enable(&mut syscon.handle);
let iocon = peripherals.IOCON.split();
let red_led = iocon.pins.pio1_6
.into_gpio_pin(&gpio)
.into_output_high();
init::LateResources {
LED: red_led,
}
}
#[idle(resources = [LED])]
fn idle(c: idle::Context) -> ! {
let led = c.resources.LED;
loop {
dbg!("low");
#[allow(deprecated)]
led.set_low();
dbg!("high");
#[allow(deprecated)]
led.set_high();
}
}
};