Skip to content
Snippets Groups Projects
Commit a292df3a authored by Per Lindgren's avatar Per Lindgren
Browse files

app6

parent e62e1d74
No related branches found
No related tags found
No related merge requests found
#![no_main]
#![no_std]
use cortex_m_semihosting::hprintln;
use nrf52832_hal as hal;
#[allow(unused_imports)]
use panic_semihosting;
use rtfm::app;
use embedded_hal::digital::OutputPin;
use hal::gpio;
use hal::gpio::p0::*;
use hal::gpio::Level;
use hal::gpio::*;
use hal::prelude::GpioExt;
const PERIOD : u32 = 64_000_000;
#[app(device = crate::hal::target)]
const APP: () = {
// Late resources
static mut LED: P0_14<gpio::Output<PushPull>> = ();
#[init(spawn = [low])]
fn init() -> init::LateResources {
hprintln!("init").unwrap();
let port0 = device.P0.split();
let led = port0.p0_14.into_push_pull_output(Level::High);
spawn.low().unwrap();
init::LateResources { LED : led }
}
#[task(schedule = [high], resources = [LED])]
fn low() {
resources.LED.set_low();
schedule.high(
scheduled + PERIOD.cycles()
).unwrap();
}
#[task(schedule = [low], resources = [LED])]
fn high() {
resources.LED.set_high();
schedule.low(
scheduled + PERIOD.cycles()
).unwrap();
}
extern "C" {
fn SWI1_EGU1();
}
};
#![no_main]
#![no_std]
use cortex_m_semihosting::hprintln;
use nrf52832_hal as hal;
#[allow(unused_imports)]
use panic_semihosting;
use rtfm::app;
use embedded_hal::digital::OutputPin;
use hal::gpio;
use hal::gpio::p0::*;
use hal::gpio::Level;
use hal::gpio::*;
use hal::prelude::GpioExt;
const PERIOD : u32 = 64_000_000;
#[app(device = crate::hal::target)]
const APP: () = {
// Late resources
static mut LED: P0_14<gpio::Output<PushPull>> = ();
#[init(spawn = [low])]
fn init() -> init::LateResources {
hprintln!("init").unwrap();
let port0 = device.P0.split();
let led = port0.p0_14.into_push_pull_output(Level::High);
spawn.low().unwrap();
init::LateResources { LED : led }
}
#[task(schedule = [high], resources = [LED])]
fn low() {
resources.LED.set_low();
schedule.high(
scheduled + PERIOD.cycles()
).unwrap();
}
#[task(schedule = [low], resources = [LED])]
fn high() {
resources.LED.set_high();
schedule.low(
scheduled + PERIOD.cycles()
).unwrap();
}
extern "C" {
fn SWI1_EGU1();
}
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment