Exchange hal with own svd2rust generated hal
This commit is contained in:
parent
da153abac6
commit
abaf98de01
@ -13,8 +13,7 @@ cortex-m-semihosting = "0.3.7"
|
||||
|
||||
panic-semihosting = "0.5.6"
|
||||
|
||||
nrf52832-hal = { features = ["rt"], path = "/home/tkl/nrf-hal/nrf52832-hal" }
|
||||
|
||||
nrf52-hal = { git = "https://git.blackfinn.de/rust/nrf52-hal.git" }
|
||||
|
||||
[dependencies.embedded-hal]
|
||||
version = "0.2.3"
|
||||
|
23
src/main.rs
23
src/main.rs
@ -4,9 +4,7 @@ use cortex_m::peripheral::{syst, Peripherals};
|
||||
use cortex_m_rt::{entry, exception};
|
||||
use cortex_m_semihosting::hprintln;
|
||||
|
||||
use embedded_hal::digital::v2::OutputPin;
|
||||
use nrf52832_hal as hal;
|
||||
use nrf52832_hal::gpio::Level;
|
||||
use nrf52_hal as hal;
|
||||
|
||||
use panic_semihosting as _;
|
||||
|
||||
@ -26,10 +24,17 @@ fn main() -> ! {
|
||||
systick.enable_interrupt();
|
||||
systick.enable_counter();
|
||||
|
||||
let p = hal::pac::Peripherals::take().unwrap();
|
||||
let port0 = hal::gpio::p0::Parts::new(p.P0);
|
||||
let mut led = port0.p0_17.into_push_pull_output(Level::Low);
|
||||
led.set_low().unwrap();
|
||||
let nrf_peripherals = hal::Peripherals::take().unwrap();
|
||||
let p0 = nrf_peripherals.P0;
|
||||
|
||||
unsafe {
|
||||
p0.outset.write(|w| w.bits(1 << 17));
|
||||
p0.pin_cnf[17].write(|w| {
|
||||
w.input().disconnect();
|
||||
w.dir().output();
|
||||
w
|
||||
});
|
||||
}
|
||||
|
||||
let mut state:bool = false;
|
||||
loop {
|
||||
@ -38,11 +43,11 @@ fn main() -> ! {
|
||||
FIRE_1S = false;
|
||||
if state {
|
||||
hprintln!("off").unwrap();
|
||||
led.set_low().unwrap();
|
||||
p0.outclr.write(|w| w.bits(1 << 17));
|
||||
state = false;
|
||||
} else {
|
||||
hprintln!("on").unwrap();
|
||||
led.set_high().unwrap();
|
||||
p0.outset.write(|w| w.bits(1 << 17));
|
||||
state = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user